Skip to content

Commit

Permalink
[Decompilation] [th01] Stage timer: Move all data to C land
Browse files Browse the repository at this point in the history
Part of P0211, funded by Lmocinemod and Arandui.
  • Loading branch information
nmlgc committed Aug 8, 2022
1 parent d29b128 commit a2200fe
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
24 changes: 20 additions & 4 deletions th01/main/stage/timer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,15 @@ extern "C" {
#include "th01/main/stage/stages.hpp"
#include "th01/main/stage/timer.hpp"

extern unsigned int frames_since_harryup;
unsigned int stage_timer;
static unsigned int frames_since_harryup;

// Function ordering fails
// -----------------------

void harryup_animate(void);
void pattern_harryup(void);
// -----------------------

/// Constants
/// ---------
Expand Down Expand Up @@ -66,9 +71,20 @@ inline void unput(void) {

void timer_init_for(int stage_id, int route)
{
extern unsigned int STAGE_TIMES[
static unsigned int STAGE_TIMES[
STAGES_OUTSIDE_ROUTE + (STAGES_ON_ROUTE * ROUTE_COUNT)
];
] = {
1000, 1000, 1000, 1000, 2000, // Shrine
// Makai
1200, 1200, 1200, 1200, 3000, // (06 - 10)
1400, 1400, 1400, 1400, 4000, // (11 - 15)
1600, 1600, 1600, 600, 6000, // (16 - 20)
// Jigoku
1200, 1200, 1200, 1200, 2000, // (06 - 10)
1400, 1400, 1400, 1400, 4000, // (11 - 15)
1600, 1800, 1800, 1600, 8000, // (16 - 20)
};

if(stage_id < STAGES_OUTSIDE_ROUTE) {
stage_timer = STAGE_TIMES[stage_id];
} else {
Expand Down Expand Up @@ -184,7 +200,7 @@ void harryup_animate(void)

void pattern_harryup(void)
{
extern unsigned char harryup_cycle;
static unsigned char harryup_cycle;

frames_since_harryup++;
harryup_cycle++;
Expand Down
16 changes: 1 addition & 15 deletions th01_reiiden.asm
Original file line number Diff line number Diff line change
Expand Up @@ -4893,17 +4893,6 @@ include th01/hardware/grppfnfx_ptrs[data].asm
public _score_prev
_score_prev dd 0
include th01/hardware/grppfnfx[data].asm
public _STAGE_TIMES
_STAGE_TIMES label word
dw 1000, 1000, 1000, 1000, 2000 ; Shrine
; Makai
dw 1200, 1200, 1200, 1200, 3000 ; (06 - 10)
dw 1400, 1400, 1400, 1400, 4000 ; (11 - 15)
dw 1600, 1600, 1600, 600, 6000 ; (16 - 20)
; Jigoku
dw 1200, 1200, 1200, 1200, 2000 ; (06 - 10)
dw 1400, 1400, 1400, 1400, 4000 ; (11 - 15)
dw 1600, 1800, 1800, 1600, 8000 ; (16 - 20)

extern _ptn_sloppy_unput_before_alpha_pu:byte
extern _card_flip_cycle:byte
Expand Down Expand Up @@ -5044,10 +5033,6 @@ _items_bomb item_t ITEM_BOMB_COUNT dup(<?>)
_items_point item_t ITEM_POINT_COUNT dup(<?>)

include th01/main/hud/hud[bss].asm
public _stage_timer, _frames_since_harryup, _harryup_cycle
_stage_timer dw ?
_frames_since_harryup dw ?
_harryup_cycle db ?

CCards struc
C_left dd ?
Expand All @@ -5066,6 +5051,7 @@ CObstacles struc
O_count dw ?
CObstacles ends

extern _stage_timer:word
extern _stageobj_bgs:dword
extern _stageobj_bgs_size:dword
extern _cards:CCards
Expand Down

0 comments on commit a2200fe

Please sign in to comment.