Fixed bug when reseting with better camera.

Fixed bug when reseting with a dialog box onscreen.
Added seperate timer for speedruns / Fixed conflict with in-game timer.
Added feature to store last warp to use when reseting.(L+R)
Changed reset to Z+R to prevet conflicts with Better Camera.
This commit is contained in:
John Collins 2020-09-06 14:30:05 -05:00
parent eff481e151
commit 2d22401db4
6 changed files with 108 additions and 16 deletions

View File

@ -363,7 +363,43 @@ void render_hud_timer(void) {
render_hud_tex_lut(GFX_DIMENSIONS_RECT_FROM_RIGHT_EDGE(46), 32, (*hudLUT)[GLYPH_DOUBLE_QUOTE]);
gSPDisplayList(gDisplayListHead++, dl_hud_img_end);
}
void render_hud_speedrunning_timer(void) {
u8 *(*hudLUT)[58];
u16 timerValFrames;
u16 timerMins;
u16 timerSecs;
u16 timerFracSecs;
hudLUT = segmented_to_virtual(&main_hud_lut);
timerValFrames = gHudDisplay.speedRunTimer;
#ifdef VERSION_EU
switch (eu_get_language()) {
case LANGUAGE_ENGLISH:
print_text(GFX_DIMENSIONS_RECT_FROM_RIGHT_EDGE(150), 185, "TIME");
break;
case LANGUAGE_FRENCH:
print_text(GFX_DIMENSIONS_RECT_FROM_RIGHT_EDGE(155), 185, "TEMPS");
break;
case LANGUAGE_GERMAN:
print_text(GFX_DIMENSIONS_RECT_FROM_RIGHT_EDGE(150), 185, "ZEIT");
break;
}
#endif
timerMins = timerValFrames / (30 * 60);
timerSecs = (timerValFrames - (timerMins * 1800)) / 30;
timerFracSecs = ((timerValFrames - (timerMins * 1800) - (timerSecs * 30)) & 0xFFFF) ;
#ifndef VERSION_EU
print_text(GFX_DIMENSIONS_RECT_FROM_RIGHT_EDGE(190), 167, "RUN TIME");
#endif
print_text_fmt_int(GFX_DIMENSIONS_RECT_FROM_RIGHT_EDGE(91), 167, "%0d", timerMins);
print_text_fmt_int(GFX_DIMENSIONS_RECT_FROM_RIGHT_EDGE(71), 167, "%02d", timerSecs);
print_text_fmt_int(GFX_DIMENSIONS_RECT_FROM_RIGHT_EDGE(37), 167, "%02d", timerFracSecs);
gSPDisplayList(gDisplayListHead++, dl_hud_img_begin);
render_hud_tex_lut(GFX_DIMENSIONS_RECT_FROM_RIGHT_EDGE(81), 50, (*hudLUT)[GLYPH_APOSTROPHE]);
render_hud_tex_lut(GFX_DIMENSIONS_RECT_FROM_RIGHT_EDGE(46), 50, (*hudLUT)[GLYPH_DOUBLE_QUOTE]);
gSPDisplayList(gDisplayListHead++, dl_hud_img_end);
}
/**
* Sets HUD status camera value depending of the actions
* defined in update_camera_status.
@ -476,6 +512,9 @@ void render_hud(void) {
if (hudDisplayFlags & HUD_DISPLAY_FLAG_TIMER && configHUD) {
render_hud_timer();
}
if (hudDisplayFlags & HUD_DISPLAY_FLAG_SPEED_TIMER && configHUD) {
render_hud_speedrunning_timer();
}
}
}

View File

@ -162,6 +162,7 @@ u16 D_80339ECA;
s16 sTransitionTimer;
void (*sTransitionUpdate)(s16 *);
struct WarpDest sWarpDest;
struct WarpDest storedWarpDest;
s16 D_80339EE0;
s16 sDelayedWarpOp;
s16 sDelayedWarpTimer;
@ -171,6 +172,7 @@ s32 sDelayedWarpArg;
s16 unusedEULevelUpdateBss1;
#endif
s8 sTimerRunning;
s8 speedTimerRunning;
s8 gShouldNotPlayCastleMusic;
struct MarioState *gMarioState = &gMarioStates[0];
@ -179,6 +181,7 @@ s8 D_8032C9E0 = 0;
u8 unused3[4];
u8 unused4[2];
u16 level_control_timer(s32 timerOp) {
switch (timerOp) {
case TIMER_CONTROL_SHOW:
@ -204,6 +207,31 @@ u16 level_control_timer(s32 timerOp) {
return gHudDisplay.timer;
}
u16 speed_running_control_timer(s32 timerOp) {
switch (timerOp) {
case TIMER_CONTROL_SHOW:
gHudDisplay.flags |= HUD_DISPLAY_FLAG_SPEED_TIMER;
speedTimerRunning = FALSE;
gHudDisplay.speedRunTimer = 0;
break;
case TIMER_CONTROL_START:
speedTimerRunning = TRUE;
break;
case TIMER_CONTROL_STOP:
speedTimerRunning = FALSE;
break;
case TIMER_CONTROL_HIDE:
gHudDisplay.flags &= ~HUD_DISPLAY_FLAG_SPEED_TIMER;
speedTimerRunning = FALSE;
gHudDisplay.speedRunTimer = 0;
break;
}
return gHudDisplay.speedRunTimer;
}
u32 pressed_pause(void) {
u32 val4 = get_dialog_id() >= 0;
@ -478,11 +506,12 @@ void warp_level(void) {
gCurrLevelNum = sWarpDest.levelNum;
level_control_timer(TIMER_CONTROL_HIDE);
load_area(sWarpDest.areaIdx);
init_mario_after_warp();
level_control_timer(TIMER_CONTROL_SHOW);
level_control_timer(TIMER_CONTROL_START);
speed_running_control_timer(TIMER_CONTROL_SHOW);
speed_running_control_timer(TIMER_CONTROL_START);
}
void warp_credits(void) {
@ -672,6 +701,7 @@ void initiate_painting_warp(void) {
if (!(warpNode.destLevel & 0x80)) {
D_8032C9E0 = check_warp_checkpoint(&warpNode);
}
skipStarSelect = false;
initiate_warp(warpNode.destLevel & 0x7F, warpNode.destArea, warpNode.destNode, 0);
check_if_should_set_warp_checkpoint(&warpNode);
@ -981,7 +1011,9 @@ s32 play_mode_normal(void) {
if (sTimerRunning && gHudDisplay.timer < 17999) {
gHudDisplay.timer += 1;
}
if (speedTimerRunning) {
gHudDisplay.speedRunTimer += 1;
}
area_update_objects();
update_hud_values();
@ -1226,7 +1258,7 @@ s32 init_level(void) {
if (gMarioState->action == ACT_INTRO_CUTSCENE) {
sound_banks_disable(2, 0x0330);
}
return 1;
}
@ -1317,17 +1349,15 @@ s32 lvl_set_current_level(UNUSED s16 arg0, s32 levelNum) {
return 0;
}
if(levelResetActNum){
if(skipStarSelect){
return 0;
}
return 1;
}
s32 resetLevelAct(UNUSED s16 arg0){
s32 returnVal = levelResetActNum;
levelResetActNum = 0;
return returnVal;
s32 resetLevelAct(UNUSED s16 arg0) {
return levelResetActNum;
}
/**
* Play the "thank you so much for to playing my game" sound.

View File

@ -78,7 +78,7 @@ struct WarpDest {
u8 nodeId;
u32 arg;
};
extern struct WarpDest storedWarpDest;
extern struct WarpDest sWarpDest;
extern s16 D_80339EE0;
@ -97,6 +97,7 @@ struct HudDisplay {
/*0x08*/ s16 keys;
/*0x0A*/ s16 flags;
/*0x0C*/ u16 timer;
u32 speedRunTimer;
};
extern struct HudDisplay gHudDisplay;
@ -110,6 +111,7 @@ enum HUDDisplayFlag {
HUD_DISPLAY_FLAG_KEYS = 0x0010,
HUD_DISPLAY_FLAG_UNKNOWN_0020 = 0x0020,
HUD_DISPLAY_FLAG_TIMER = 0x0040,
HUD_DISPLAY_FLAG_SPEED_TIMER = 0x0080,
HUD_DISPLAY_FLAG_EMPHASIZE_POWER = 0x8000,
HUD_DISPLAY_NONE = 0x0000,

View File

@ -37,8 +37,11 @@
#include "pc/cheats.h"
#ifdef BETTERCAMERA
#include "bettercamera.h"
extern f32 newcam_yaw_acc;
extern f32 newcam_tilt_acc;
#endif
int levelResetActNum = 0;
u8 skipStarSelect = false;
u32 unused80339F10;
s8 filler80339F1C[20];
@ -1414,12 +1417,30 @@ void update_mario_inputs(struct MarioState *m) {
update_mario_geometry_inputs(m);
debug_print_speed_action_normal(m);
if(m->controller->buttonDown& L_TRIG && m->controller->buttonPressed & R_TRIG){
sWarpDest.levelNum = gCurrLevelNum;
sWarpDest.areaIdx = m->area->index;
if (m->controller->buttonDown & L_TRIG && m->controller->buttonPressed & R_TRIG) {
storedWarpDest = sWarpDest;
levelResetActNum = gCurrActNum;
}
if (m->controller->buttonDown & Z_TRIG && m->controller->buttonPressed & R_TRIG) {
skipStarSelect = true;
m->health = 0x880;
if (storedWarpDest.levelNum != 0) {
sWarpDest = storedWarpDest;
levelResetActNum = gCurrActNum;
} else {
sWarpDest.levelNum = gCurrLevelNum;
sWarpDest.areaIdx = m->area->index;
}
sWarpDest.type = 1;
reset_dialog_render_state();
#ifdef BETTERCAMERA
newcam_yaw_acc = 0;
newcam_tilt_acc = 0;
#endif
}
/* Moonjump cheat */
while (Cheats.MoonJump == true && Cheats.EnableCheats == true && m->controller->buttonDown & L_TRIG ){

View File

@ -51,5 +51,6 @@ s32 execute_mario_action(UNUSED struct Object *o);
void init_mario(void);
void init_mario_from_save_file(void);
extern s32 levelResetActNum;
extern u8 skipStarSelect;
#endif // MARIO_H

View File

@ -52,7 +52,6 @@ static s8 sSelectableStarIndex = 0;
// Act Selector menu timer that keeps counting until you choose an act.
static s32 sActSelectorMenuTimer = 0;
extern int levelResetActNum;
/**
* Act Selector Star Type Loop Action
@ -391,8 +390,8 @@ Gfx *geo_act_selector_strings(s16 callContext, UNUSED struct GraphNode *node) {
*/
s32 lvl_init_act_selector_values_and_stars(UNUSED s32 arg, UNUSED s32 unused) {
u8 stars = save_file_get_star_flags(gCurrSaveFileNum - 1, gCurrCourseNum - 1);
sLoadedActNum = 0;
sLoadedActNum = 0;
sInitSelectedActNum = 0;
sVisibleStars = 0;
sActSelectorMenuTimer = 0;