From b0c2122eec2814bb40647c1b6634664e2adbac29 Mon Sep 17 00:00:00 2001 From: nmlgc Date: Mon, 16 Sep 2019 13:01:53 +0200 Subject: [PATCH] [Decompilation] [th05] Stage-related .BB file loading boilerplate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Yay for alignment, allowing us once again to only move unrelated variable declarations over to C… Part of P0031, funded by zorg. --- th04/formats/bb.h | 5 +++++ th04/formats/bb_stage.c | 25 +++++++++++++++++++++++++ th04/shared.hpp | 12 ++++-------- th05/main_01.cpp | 3 +++ th05/th05.hpp | 5 +++++ th05_main.asm | 6 ++---- 6 files changed, 44 insertions(+), 12 deletions(-) create mode 100644 th04/formats/bb.h create mode 100644 th04/formats/bb_stage.c diff --git a/th04/formats/bb.h b/th04/formats/bb.h new file mode 100644 index 00000000..47ba10f2 --- /dev/null +++ b/th04/formats/bb.h @@ -0,0 +1,5 @@ +#define BB_SIZE 2048 + +typedef char __seg* bb_seg_t; + +void pascal near bb_stage_load(const char far* fn); diff --git a/th04/formats/bb_stage.c b/th04/formats/bb_stage.c new file mode 100644 index 00000000..9dc2f258 --- /dev/null +++ b/th04/formats/bb_stage.c @@ -0,0 +1,25 @@ +extern bb_seg_t bb_stage_seg; + +void pascal near bb_stage_load(const char far* fn) +{ +#if GAME == 5 + bb_stage_seg = bb_load(fn); +#else + file_ropen(fn); + bb_stage_seg = (bb_seg_t)hmem_allocbyte(BB_SIZE); + file_read(bb_stage_seg, BB_SIZE); + file_close(fn); +#endif +} + +#if GAME == 5 +void pascal near bb_stage_free(void) +#else +void pascal far bb_stage_free(void) +#endif +{ + if(bb_stage_seg) { + hmem_free((unsigned int)bb_stage_seg); + bb_stage_seg = 0; + } +} diff --git a/th04/shared.hpp b/th04/shared.hpp index e2906f42..33392b2e 100644 --- a/th04/shared.hpp +++ b/th04/shared.hpp @@ -50,15 +50,11 @@ int pascal far select_for_rank( ); /// ---- -/// Formats - .BB -/// ------------- -void pascal near bb_stage_load(const char far* fn); -/// ------------- - -/// Formats - .CDG/.CD2 -/// ------------------- +/// Formats +/// ------- #include "th03/formats/cdg.h" -/// ------------------- +#include "th04/formats/bb.h" +/// ------- /// Stages /// ------ diff --git a/th05/main_01.cpp b/th05/main_01.cpp index 09c3b49e..006e8a99 100644 --- a/th05/main_01.cpp +++ b/th05/main_01.cpp @@ -20,6 +20,7 @@ char boss_phase_timed_out = 0; void pascal near boss_reset(void); +#include "th04/formats/bb_stage.c" #include "th05/stage/setup.cpp" // Adds the entire score delta at once to the current score. @@ -30,4 +31,6 @@ void pascal score_delta_commit(void) } } +static int unused_6CAC[3]; + } diff --git a/th05/th05.hpp b/th05/th05.hpp index 0688cd77..09b97411 100644 --- a/th05/th05.hpp +++ b/th05/th05.hpp @@ -6,6 +6,11 @@ #include "ReC98.h" #include "th04/shared.hpp" +/// Formats +/// ------- +bb_seg_t pascal near bb_load(const char far *fn); +/// ------- + /// Stages /// ------ void pascal near stage2_update(void); diff --git a/th05_main.asm b/th05_main.asm index 43eda849..65d91d6a 100644 --- a/th05_main.asm +++ b/th05_main.asm @@ -17886,7 +17886,8 @@ boss_reset proc near retn boss_reset endp -include th04/formats/bb_stage.asm + BB_STAGE_LOAD procdesc near + BB_STAGE_FREE procdesc near STAGE1_SETUP procdesc near STAGE2_SETUP procdesc near STAGE3_SETUP procdesc near @@ -45513,8 +45514,5 @@ byte_2D084 db ? byte_2D085 db ? include th04/formats/bb_stage[bss].asm include th04/boss/hitbox[bss].asm - dd ? ; - db ? ; - db ? ; end