Simplified lives defines (#439)
* Combined ENABLE_LIVES and DEFAULT_NUM_LIVES, and removed SAVE_NUM_LIVES * removed commented out lines * numLives no longer modified by default when lives are disabled This allows for the variable to be repurposed more easily * Remove SAVE_NUM_LIVES define * Remove SAVE_NUM_LIVES and DISABLE_LIVES define (Take 2) * Apply MAX_NUM_LIVES and MAX_NUM_COINS to update_hud_values() Co-authored-by: gheskett <gheskett@gmail.com>
This commit is contained in:
1 parent
1ef73290d9
commit
74730e7852
11 files changed
+29
-100
No files matched your search
@@ -12,29 +12,19 @@
|
||||
// #define ENABLE_VANILLA_LEVEL_SPECIFIC_CHECKS
|
||||
|
||||
/**
|
||||
* Disables lives and hides the lives counter.
|
||||
* Enable lives and the lives counter. The number next to the define is the number of lives you start with.
|
||||
*/
|
||||
#define DISABLE_LIVES
|
||||
|
||||
/**
|
||||
* Saves the number of lives to the save file (Does nothing if DISABLE_LIVES is enabled).
|
||||
*/
|
||||
#define SAVE_NUM_LIVES
|
||||
|
||||
/**
|
||||
* This is the number of lives Mario starts with after a game over or starting the game for the first time (must be lower than 127).
|
||||
*/
|
||||
#define DEFAULT_NUM_LIVES 4
|
||||
// #define ENABLE_LIVES 4
|
||||
|
||||
/**
|
||||
* This can be 0..127.
|
||||
*/
|
||||
#define MAX_NUM_LIVES 100
|
||||
#define MAX_NUM_LIVES 100
|
||||
|
||||
/**
|
||||
* This can be 0..32767.
|
||||
*/
|
||||
#define MAX_NUM_COINS 999
|
||||
#define MAX_NUM_COINS 999
|
||||
|
||||
/**
|
||||
* Air/breath meter is separate from health meter when underwater.
|
||||
|
||||
@@ -151,10 +151,6 @@
|
||||
* config_game.h
|
||||
*/
|
||||
|
||||
#ifdef DISABLE_LIVES
|
||||
#undef SAVE_NUM_LIVES
|
||||
#endif // DISABLE_LIVES
|
||||
|
||||
#ifndef START_LEVEL
|
||||
#define START_LEVEL LEVEL_CASTLE_GROUNDS
|
||||
#endif // !START_LEVEL
|
||||
|
||||
@@ -9,9 +9,8 @@ void bhv_1up_interact(void) {
|
||||
gMarioState->breathCounter = 31;
|
||||
#endif
|
||||
#endif
|
||||
#ifdef ENABLE_LIVES
|
||||
gMarioState->numLives++;
|
||||
#ifdef SAVE_NUM_LIVES
|
||||
save_file_set_num_lives(gMarioState->numLives);
|
||||
#endif
|
||||
o->activeFlags = ACTIVE_FLAG_DEACTIVATED;
|
||||
#if ENABLE_RUMBLE
|
||||
|
||||
@@ -143,12 +143,10 @@ void yoshi_finish_jumping_and_despawn_loop(void) {
|
||||
}
|
||||
|
||||
void yoshi_give_present_loop(void) {
|
||||
#ifdef ENABLE_LIVES
|
||||
s32 globalTimer = gGlobalTimer;
|
||||
|
||||
if (gHudDisplay.lives == 100) {
|
||||
#ifdef SAVE_NUM_LIVES
|
||||
save_file_set_num_lives(gMarioState->numLives);
|
||||
#endif
|
||||
if (gHudDisplay.lives == MAX_NUM_LIVES) {
|
||||
play_sound(SOUND_GENERAL_COLLECT_1UP, gGlobalSoundSource);
|
||||
gSpecialTripleJump = TRUE;
|
||||
o->oAction = YOSHI_ACT_WALK_JUMP_OFF_ROOF;
|
||||
@@ -159,6 +157,12 @@ void yoshi_give_present_loop(void) {
|
||||
play_sound(SOUND_MENU_YOSHI_GAIN_LIVES, gGlobalSoundSource);
|
||||
gMarioState->numLives++;
|
||||
}
|
||||
#else
|
||||
play_sound(SOUND_GENERAL_COLLECT_1UP, gGlobalSoundSource);
|
||||
gSpecialTripleJump = TRUE;
|
||||
o->oAction = YOSHI_ACT_WALK_JUMP_OFF_ROOF;
|
||||
return;
|
||||
#endif
|
||||
}
|
||||
|
||||
void bhv_yoshi_loop(void) {
|
||||
|
||||
+1
-7
@@ -27,15 +27,9 @@
|
||||
**/
|
||||
|
||||
#ifdef BREATH_METER
|
||||
// #ifdef DISABLE_LIVES
|
||||
// #define HUD_BREATH_METER_X 64
|
||||
// #define HUD_BREATH_METER_Y 200
|
||||
// #define HUD_BREATH_METER_HIDDEN_Y 300
|
||||
// #else
|
||||
#define HUD_BREATH_METER_X 40
|
||||
#define HUD_BREATH_METER_Y 32
|
||||
#define HUD_BREATH_METER_HIDDEN_Y -20
|
||||
// #endif
|
||||
#endif
|
||||
|
||||
// ------------- FPS COUNTER ---------------
|
||||
@@ -562,7 +556,7 @@ void render_hud(void) {
|
||||
render_hud_cannon_reticle();
|
||||
}
|
||||
|
||||
#ifndef DISABLE_LIVES
|
||||
#ifdef ENABLE_LIVES
|
||||
if (hudDisplayFlags & HUD_DISPLAY_FLAG_LIVES) {
|
||||
render_hud_mario_lives();
|
||||
}
|
||||
|
||||
@@ -1993,7 +1993,7 @@ void print_hud_course_complete_coins(s16 x, s16 y) {
|
||||
gCourseCompleteCoins++;
|
||||
play_sound(SOUND_MENU_YOSHI_GAIN_LIVES, gGlobalSoundSource);
|
||||
|
||||
#ifndef DISABLE_LIVES
|
||||
#ifdef ENABLE_LIVES
|
||||
if (gCourseCompleteCoins && ((gCourseCompleteCoins % 50) == 0)) {
|
||||
play_sound(SOUND_GENERAL_COLLECT_1UP, gGlobalSoundSource);
|
||||
gMarioState->numLives++;
|
||||
@@ -2137,9 +2137,6 @@ s32 render_course_complete_screen(void) {
|
||||
case DIALOG_STATE_OPENING:
|
||||
render_course_complete_lvl_info_and_hud_str();
|
||||
if (gCourseDoneMenuTimer > 100 && gCourseCompleteCoinsEqual) {
|
||||
#ifdef SAVE_NUM_LIVES
|
||||
save_file_set_num_lives(gMarioState->numLives);
|
||||
#endif
|
||||
gDialogBoxState = DIALOG_STATE_VERTICAL;
|
||||
level_set_transition(-1, NULL);
|
||||
gDialogTextAlpha = 0;
|
||||
|
||||
+7
-21
@@ -698,9 +698,6 @@ s16 level_trigger_warp(struct MarioState *m, s32 warpOp) {
|
||||
s32 fadeMusic = TRUE;
|
||||
|
||||
if (sDelayedWarpOp == WARP_OP_NONE) {
|
||||
#ifdef SAVE_NUM_LIVES
|
||||
save_file_set_num_lives(m->numLives);
|
||||
#endif
|
||||
m->invincTimer = -1;
|
||||
sDelayedWarpArg = WARP_FLAGS_NONE;
|
||||
sDelayedWarpOp = warpOp;
|
||||
@@ -731,7 +728,7 @@ s16 level_trigger_warp(struct MarioState *m, s32 warpOp) {
|
||||
break;
|
||||
|
||||
case WARP_OP_DEATH:
|
||||
#ifndef DISABLE_LIVES
|
||||
#ifdef ENABLE_LIVES
|
||||
if (m->numLives == 0) {
|
||||
sDelayedWarpOp = WARP_OP_GAME_OVER;
|
||||
}
|
||||
@@ -748,7 +745,7 @@ s16 level_trigger_warp(struct MarioState *m, s32 warpOp) {
|
||||
case WARP_OP_WARP_FLOOR:
|
||||
sSourceWarpNodeId = WARP_NODE_WARP_FLOOR;
|
||||
if (area_get_warp_node(sSourceWarpNodeId) == NULL) {
|
||||
#ifndef DISABLE_LIVES
|
||||
#ifdef ENABLE_LIVES
|
||||
if (m->numLives == 0) {
|
||||
sDelayedWarpOp = WARP_OP_GAME_OVER;
|
||||
} else {
|
||||
@@ -916,30 +913,19 @@ void update_hud_values(void) {
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef SAVE_NUM_LIVES
|
||||
#ifdef ENABLE_LIVES
|
||||
if (gMarioState->numLives > MAX_NUM_LIVES) {
|
||||
gMarioState->numLives = MAX_NUM_LIVES;
|
||||
save_file_set_num_lives(MAX_NUM_LIVES);
|
||||
}
|
||||
#else
|
||||
if (gMarioState->numLives > 100) {
|
||||
gMarioState->numLives = 100;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if BUGFIX_MAX_LIVES
|
||||
if (gMarioState->numCoins > 999) {
|
||||
gMarioState->numCoins = 999;
|
||||
if (gMarioState->numCoins > MAX_NUM_COINS) {
|
||||
gMarioState->numCoins = MAX_NUM_COINS;
|
||||
}
|
||||
|
||||
if (gHudDisplay.coins > 999) {
|
||||
gHudDisplay.coins = 999;
|
||||
if (gHudDisplay.coins > MAX_NUM_COINS) {
|
||||
gHudDisplay.coins = MAX_NUM_COINS;
|
||||
}
|
||||
#else
|
||||
if (gMarioState->numCoins > 999) {
|
||||
gMarioState->numLives = (s8) 999; //! Wrong variable
|
||||
}
|
||||
#endif
|
||||
|
||||
gHudDisplay.stars = gMarioState->numStars;
|
||||
gHudDisplay.lives = gMarioState->numLives;
|
||||
|
||||
+3
-5
@@ -1871,12 +1871,10 @@ void init_mario_from_save_file(void) {
|
||||
gMarioState->numCoins = 0;
|
||||
gMarioState->numStars = save_file_get_total_star_count(gCurrSaveFileNum - 1, COURSE_MIN - 1, COURSE_MAX - 1);
|
||||
gMarioState->numKeys = 0;
|
||||
|
||||
#ifdef SAVE_NUM_LIVES
|
||||
s8 savedLives = save_file_get_num_lives();
|
||||
gMarioState->numLives = (savedLives > DEFAULT_NUM_LIVES) ? savedLives : DEFAULT_NUM_LIVES;
|
||||
#ifdef ENABLE_LIVES
|
||||
gMarioState->numLives = ENABLE_LIVES;
|
||||
#else
|
||||
gMarioState->numLives = DEFAULT_NUM_LIVES;
|
||||
gMarioState->numLives = 0;
|
||||
#endif
|
||||
gMarioState->health = 0x880;
|
||||
#ifdef BREATH_METER
|
||||
|
||||
@@ -1178,9 +1178,8 @@ s32 act_death_exit(struct MarioState *m) {
|
||||
#if ENABLE_RUMBLE
|
||||
queue_rumble_data(5, 80);
|
||||
#endif
|
||||
#ifdef ENABLE_LIVES
|
||||
m->numLives--;
|
||||
#ifdef SAVE_NUM_LIVES
|
||||
save_file_set_num_lives(m->numLives);
|
||||
#endif
|
||||
// restore 7.75 units of health
|
||||
m->healCounter = 31;
|
||||
@@ -1196,9 +1195,8 @@ s32 act_death_exit(struct MarioState *m) {
|
||||
s32 act_unused_death_exit(struct MarioState *m) {
|
||||
if (launch_mario_until_land(m, ACT_FREEFALL_LAND_STOP, MARIO_ANIM_GENERAL_FALL, 0.0f)) {
|
||||
play_sound(SOUND_MARIO_OOOF2, m->marioObj->header.gfx.cameraToObject);
|
||||
#ifdef ENABLE_LIVES
|
||||
m->numLives--;
|
||||
#ifdef SAVE_NUM_LIVES
|
||||
save_file_set_num_lives(m->numLives);
|
||||
#endif
|
||||
// restore 7.75 units of health
|
||||
m->healCounter = 31;
|
||||
@@ -1217,9 +1215,8 @@ s32 act_falling_death_exit(struct MarioState *m) {
|
||||
#if ENABLE_RUMBLE
|
||||
queue_rumble_data(5, 80);
|
||||
#endif
|
||||
#ifdef ENABLE_LIVES
|
||||
m->numLives--;
|
||||
#ifdef SAVE_NUM_LIVES
|
||||
save_file_set_num_lives(m->numLives);
|
||||
#endif
|
||||
// restore 7.75 units of health
|
||||
m->healCounter = 31;
|
||||
@@ -1273,9 +1270,8 @@ s32 act_special_death_exit(struct MarioState *m) {
|
||||
#if ENABLE_RUMBLE
|
||||
queue_rumble_data(5, 80);
|
||||
#endif
|
||||
#ifdef ENABLE_LIVES
|
||||
m->numLives--;
|
||||
#ifdef SAVE_NUM_LIVES
|
||||
save_file_set_num_lives(m->numLives);
|
||||
#endif
|
||||
m->healCounter = 31;
|
||||
}
|
||||
|
||||
@@ -658,11 +658,7 @@ void save_file_set_cap_pos(s16 x, s16 y, s16 z) {
|
||||
|
||||
saveFile->capLevel = gCurrLevelNum;
|
||||
saveFile->capArea = gCurrAreaIndex;
|
||||
#ifndef SAVE_NUM_LIVES
|
||||
vec3s_set(saveFile->capPos, x, y, z);
|
||||
#else
|
||||
(void) x; (void) y; (void) z; // Address compiler warnings for unused variables
|
||||
#endif
|
||||
save_file_set_flags(SAVE_FLAG_CAP_ON_GROUND);
|
||||
}
|
||||
|
||||
@@ -672,30 +668,12 @@ s32 save_file_get_cap_pos(Vec3s capPos) {
|
||||
|
||||
if (saveFile->capLevel == gCurrLevelNum && saveFile->capArea == gCurrAreaIndex
|
||||
&& (flags & SAVE_FLAG_CAP_ON_GROUND)) {
|
||||
#ifdef SAVE_NUM_LIVES
|
||||
vec3_zero(capPos);
|
||||
#else
|
||||
vec3s_copy(capPos, saveFile->capPos);
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#ifdef SAVE_NUM_LIVES
|
||||
void save_file_set_num_lives(s8 numLives) {
|
||||
struct SaveFile *saveFile = &gSaveBuffer.files[gCurrSaveFileNum - 1][0];
|
||||
saveFile->numLives = numLives;
|
||||
saveFile->flags |= SAVE_FLAG_FILE_EXISTS;
|
||||
gSaveFileModified = TRUE;
|
||||
}
|
||||
|
||||
s32 save_file_get_num_lives(void) {
|
||||
struct SaveFile *saveFile = &gSaveBuffer.files[gCurrSaveFileNum - 1][0];
|
||||
return saveFile->numLives;
|
||||
}
|
||||
#endif
|
||||
|
||||
void save_file_set_sound_mode(u16 mode) {
|
||||
set_sound_mode(mode);
|
||||
gSaveBuffer.menuData.soundMode = mode;
|
||||
|
||||
@@ -30,14 +30,9 @@ struct SaveFile {
|
||||
// cap can always be found in a fixed spot within the course
|
||||
u8 capLevel;
|
||||
u8 capArea;
|
||||
#ifdef SAVE_NUM_LIVES
|
||||
s8 numLives;
|
||||
u8 filler[5];
|
||||
#else
|
||||
// Note: the coordinates get set, but are never actually used, since the
|
||||
// cap can always be found in a fixed spot within the course
|
||||
Vec3s capPos; // 48 bits
|
||||
#endif
|
||||
|
||||
u32 flags;
|
||||
|
||||
@@ -190,10 +185,6 @@ s32 save_file_is_cannon_unlocked(void);
|
||||
void save_file_set_cannon_unlocked(void);
|
||||
void save_file_set_cap_pos(s16 x, s16 y, s16 z);
|
||||
s32 save_file_get_cap_pos(Vec3s capPos);
|
||||
#ifdef SAVE_NUM_LIVES
|
||||
s32 save_file_get_num_lives(void);
|
||||
void save_file_set_num_lives(s8 numLives);
|
||||
#endif
|
||||
void save_file_set_sound_mode(u16 mode);
|
||||
u32 save_file_get_sound_mode(void);
|
||||
#ifdef WIDE
|
||||
|
||||
Reference in new issue
Block a user