From a2200fef28ea49dc6ac52bff57a8e60e75102d51 Mon Sep 17 00:00:00 2001 From: nmlgc Date: Sat, 6 Aug 2022 02:40:31 +0200 Subject: [PATCH] [Decompilation] [th01] Stage timer: Move all data to C land Part of P0211, funded by Lmocinemod and Arandui. --- th01/main/stage/timer.cpp | 24 ++++++++++++++++++++---- th01_reiiden.asm | 16 +--------------- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/th01/main/stage/timer.cpp b/th01/main/stage/timer.cpp index be5193f2..e0b003ab 100644 --- a/th01/main/stage/timer.cpp +++ b/th01/main/stage/timer.cpp @@ -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 /// --------- @@ -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 { @@ -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++; diff --git a/th01_reiiden.asm b/th01_reiiden.asm index 7a1cdc02..b0e5cabf 100644 --- a/th01_reiiden.asm +++ b/th01_reiiden.asm @@ -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 @@ -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 ? @@ -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