Skip to content

Commit

Permalink
new timer code
Browse files Browse the repository at this point in the history
  • Loading branch information
Reonu committed Jul 9, 2021
1 parent 59b1364 commit 95d82d1
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 29 deletions.
7 changes: 0 additions & 7 deletions include/text_strings.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,6 @@
// Ingame Menu
#define TEXT_PAUSE _("PAUSE") // Pause text, Castle Courses
#define TEXT_HUD_CONGRATULATIONS _("CONGRATULATIONS") // Course Complete Text, Bowser Courses
#define TEXT_HUD_CURRENT_RATIO_43 _("CURRENT ASPECT RATIO: 4:3. PRESS L TO CHANGE")
#define TEXT_HUD_CURRENT_RATIO_169 _("CURRENT ASPECT RATIO: 16:9. PRESS L TO CHANGE")
#define TEXT_HUD_CURRENT_RATIO_1610 _("CURRENT ASPECT RATIO: 16:10. PRESS L TO CHANGE")
#define TEXT_HUD_CURRENT_RATIO_219 _("CURRENT ASPECT RATIO: 21:9. PRESS L TO CHANGE")
#define TEXT_HUD_CURRENT_RATIO_329 _("CURRENT ASPECT RATIO: 32:9 lmao. PRESS L TO CHANGE")
#define TEXT_HUD_WIDE_INFO _("PLEASE CONFIGURE YOUR DISPLAY OR YOUR EMULATOR TO")
#define TEXT_HUD_WIDE_INFO2 _("STRETCH THE IMAGE")

//Widescreen stuff
#ifdef WIDE
Expand Down
24 changes: 24 additions & 0 deletions src/game/dividetimer.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
.globl dividetimer
dividetimer:
li $t6, 30
divu $a0, $t6
li $t7, 60
li $t8, 100
mfhi $t9
mflo $t0
multu $t9, $t8
nop
nop
mflo $t1
divu $t1, $t6
nop
nop
mflo $t2
divu $t0, $t7
sw $t2, ($a3)
nop
mfhi $t3
mflo $t4
sw $t3, ($a2)
sw $t4, ($a1)
jr $ra
2 changes: 1 addition & 1 deletion src/game/game_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ u8 gIsConsole;
#ifdef WIDE
u8 gWidescreen;
#endif
u64 gSpeedrunTimer;
u32 gSpeedrunTimer;

u16 sCurrFBNum = 0;
u16 frameBufferIndex = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/game/game_init.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ extern u8 gIsConsole;
#ifdef WIDE
extern u8 gWidescreen;
#endif
extern u64 gSpeedrunTimer;
extern u32 gSpeedrunTimer;
#ifdef EEP
extern s8 gEepromProbe;
#endif
Expand Down
19 changes: 1 addition & 18 deletions src/game/mario.c
Original file line number Diff line number Diff line change
Expand Up @@ -1820,24 +1820,7 @@ extern s16 s8DirModeBaseYaw;
update_mario_health(gMarioState);
update_mario_info_for_cam(gMarioState);
mario_update_hitbox_and_cap_model(gMarioState);

if (gCurrLevelNum == LEVEL_CCM || gCurrAreaIndex != 0x03) {
gSpeedrunTimer++;
}


u64 timerMinutes = gSpeedrunTimer / (30 * 60);
u64 timerSeconds = (gSpeedrunTimer - (timerMinutes * 1800)) / 30;
u64 fracSecs = ((gSpeedrunTimer - (timerMinutes * 1800) - (timerSeconds * 30)) & 0xFFFF) / 3;
if (timerMinutes < 100) {
print_text_fmt_int(GFX_DIMENSIONS_RECT_FROM_RIGHT_EDGE(102), 210, "%02d", timerMinutes);
} else {
print_text_fmt_int(GFX_DIMENSIONS_RECT_FROM_RIGHT_EDGE(113), 210, "%02d", timerMinutes);
}

print_text_fmt_int(GFX_DIMENSIONS_RECT_FROM_RIGHT_EDGE(71), 210, "%02d", timerSeconds);
print_text_fmt_int(GFX_DIMENSIONS_RECT_FROM_RIGHT_EDGE(37), 210, "%d", fracSecs);


// Both of the wind handling portions play wind audio only in
// non-Japanese releases.
if (gMarioState->floor->type == SURFACE_HORIZONTAL_WIND) {
Expand Down
22 changes: 20 additions & 2 deletions src/game/rendering_graph_node.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "sm64.h"
#include "game_init.h"
#include "engine/extended_bounds.h"
#include "level_update.h"

#include "config.h"

Expand Down Expand Up @@ -290,8 +291,7 @@ static void geo_process_ortho_projection(struct GraphNodeOrthoProjection *node)
/**
* Process a perspective projection node.
*/
extern s32 widescreen = 0;

extern void dividetimer(int timer, int *minute, int *second, int *centisecond);
static void geo_process_perspective(struct GraphNodePerspective *node) {
if (node->fnNode.func != NULL) {
node->fnNode.func(GEO_CONTEXT_RENDER, &node->fnNode.node, gMatStack[gMatStackIndex]);
Expand All @@ -318,6 +318,24 @@ static void geo_process_perspective(struct GraphNodePerspective *node) {
gCurGraphNodeCamFrustum = node;
geo_process_node_and_siblings(node->fnNode.node.children);
gCurGraphNodeCamFrustum = NULL;

if ((gCurrLevelNum == LEVEL_CCM || gCurrAreaIndex != 0x03) && (gCurrLevelNum != 0x01)) {
gSpeedrunTimer++;
}

int timerMinutes;
int timerSeconds;
int timerCentiseconds;
dividetimer(gSpeedrunTimer, &timerMinutes, &timerSeconds, &timerCentiseconds);
if (timerMinutes < 100) {
print_text_fmt_int(GFX_DIMENSIONS_RECT_FROM_RIGHT_EDGE(122), 210, "%02d", timerMinutes);
} else {
print_text_fmt_int(GFX_DIMENSIONS_RECT_FROM_RIGHT_EDGE(133), 210, "%02d", timerMinutes);
}

print_text_fmt_int(GFX_DIMENSIONS_RECT_FROM_RIGHT_EDGE(91), 210, "%02d", timerSeconds);
print_text_fmt_int(GFX_DIMENSIONS_RECT_FROM_RIGHT_EDGE(57), 210, "%02d", timerCentiseconds);

}
}

Expand Down

0 comments on commit 95d82d1

Please sign in to comment.