From 76ea88c0bc6aae4d2fae6c81f662d9df025b9c8b Mon Sep 17 00:00:00 2001 From: nmlgc Date: Mon, 27 Dec 2021 23:54:17 +0100 Subject: [PATCH] [Decompilation] [th01] Sariel: Move already referenced literals to C land After the previous commit, we can already do this now, and therefore have to do less at once in the end. Part of P0174, funded by Ember2528. --- th01/main/boss/b20m.cpp | 46 +++++++++++++++++++++-------------------- th01_reiiden.asm | 42 +++++++++++++------------------------ 2 files changed, 38 insertions(+), 50 deletions(-) diff --git a/th01/main/boss/b20m.cpp b/th01/main/boss/b20m.cpp index b9d8572d..babb6ca0 100644 --- a/th01/main/boss/b20m.cpp +++ b/th01/main/boss/b20m.cpp @@ -62,19 +62,9 @@ extern bool initial_hp_rendered; // File names // ---------- -// TODO: Inline (if used 1×), or #define (if used >1×), once Sariel is done -extern const char boss6_l_grp[]; -extern const char boss6_h_grp[]; -extern const char TENSI_MDT[]; -extern const char SE_FN[]; +#include "th01/shiftjis/fns.hpp" + extern const char* BG_IMAGES[4]; -extern const char boss6_1_bos[]; -extern const char boss6_2_bos[]; -extern const char boss6_3_bos[]; -extern const char boss6gr1_grc[]; -extern const char boss6gr2_grc[]; -extern const char boss6gr3_grc[]; -extern const char boss6gr4_grc[]; // ---------- // Entities (and animations) @@ -85,9 +75,9 @@ extern const char boss6gr4_grc[]; #define anm_wand boss_anims[1] inline void sariel_ent_load(void) { - ent_shield.load(boss6_1_bos, 0); - anm_wand.load(boss6_2_bos, 0); - anm_dress.load(boss6_3_bos, 1); + ent_shield.load("boss6_1.bos", 0); + anm_wand.load("boss6_2.bos", 0); + anm_dress.load("boss6_3.bos", 1); } inline void sariel_ent_free(void) { @@ -106,10 +96,10 @@ static const main_grc_slot_t GRC_SLOT_SPAWNCROSS = GRC_SLOT_BOSS_3; static const main_grc_slot_t GRC_SLOT_LEAFSPLASH = GRC_SLOT_BOSS_4; inline void sariel_grc_load(void) { - grc_load(GRC_SLOT_VORTEX_DEBRIS, boss6gr1_grc); - grc_load(GRC_SLOT_BIRD, boss6gr2_grc); - grc_load(GRC_SLOT_SPAWNCROSS, boss6gr3_grc); - grc_load(GRC_SLOT_LEAFSPLASH, boss6gr4_grc); + grc_load(GRC_SLOT_VORTEX_DEBRIS, "boss6gr1.grc"); + grc_load(GRC_SLOT_BIRD, "boss6gr2.grc"); + grc_load(GRC_SLOT_SPAWNCROSS, "boss6gr3.grc"); + grc_load(GRC_SLOT_LEAFSPLASH, "boss6gr4.grc"); } inline void sariel_grc_free(void) { @@ -126,6 +116,18 @@ inline void sariel_grc_free(void) { static const main_ptn_slot_t PTN_SLOT_BG_ENT = PTN_SLOT_BOSS_1; // ---- +// Temporary storage for compiler-generated string literals +// -------------------------------------------------------- + +char ANGEL[] = "ANGEL"; +char OF[] = "OF"; +char DEATH[] = "DEATH"; +char boss6_a1_grp[] = "BOSS6_A1.GRP"; +char boss6_a2_grp[] = "BOSS6_A2.GRP"; +char boss6_a3_grp[] = "BOSS6_A3.GRP"; +char boss6_a4_grp[] = "BOSS6_A4.GRP"; +// -------------------------------------------------------- + #define select_for_rank sariel_select_for_rank #include "th01/main/select_r.cpp" @@ -135,12 +137,12 @@ void sariel_entrance(int8_t) text_fillca(' ', (TX_BLACK | TX_REVERSE)); - /* graph_accesspage_func(0); */ grp_put_palette_show(boss6_l_grp); - /**/graph_accesspage_func(1)/**/; grp_put_palette_show(boss6_h_grp); + /* graph_accesspage_func(0); */ grp_put_palette_show("boss6_l.grp"); + /**/graph_accesspage_func(1)/**/; grp_put_palette_show("boss6_h.grp"); graph_accesspage_func(0); stageobjs_init_and_render(BOSS_STAGE); - mdrv2_bgm_load(TENSI_MDT); + mdrv2_bgm_load("TENSI.MDT"); mdrv2_se_load(SE_FN); mdrv2_bgm_play(); diff --git a/th01_reiiden.asm b/th01_reiiden.asm index 175a9017..41b7c356 100644 --- a/th01_reiiden.asm +++ b/th01_reiiden.asm @@ -29848,18 +29848,18 @@ flt_35D91 dd 640.0 ; Hack. Let's better use bytes for accuracy here. dbl_35D95 db 09ah, 099h, 099h, 099h, 099h, 099h, 0a9h, 03fh db 0 - dd aAngel ; "ANGEL" - dd aOf ; "OF" - dd aDeath ; "DEATH" + dd _ANGEL + dd _OF + dd _DEATH public _game_cleared _game_cleared db 0 public _BG_IMAGES _BG_IMAGES label dword - dd aBoss6_a1_grp ; "BOSS6_A1.GRP" - dd aBoss6_a2_grp ; "BOSS6_A2.GRP" - dd aBoss6_a3_grp ; "BOSS6_A3.GRP" - dd aBoss6_a4_grp ; "BOSS6_A4.GRP" + dd _boss6_a1_grp + dd _boss6_a2_grp + dd _boss6_a3_grp + dd _boss6_a4_grp public _spawnray_target_prev_x, _spawnray_target_prev_y _spawnray_target_prev_x dw 999 _spawnray_target_prev_y dw 999 @@ -29946,27 +29946,13 @@ word_35E97 dw 0 word_35E99 dw 0 public _sariel_invincibility_flash_colors _sariel_invincibility_flash_colors db 3, 4, 5 -aAngel db 'ANGEL',0 -aOf db 'OF',0 -aDeath db 'DEATH',0 -aBoss6_a1_grp db 'BOSS6_A1.GRP',0 -aBoss6_a2_grp db 'BOSS6_A2.GRP',0 -aBoss6_a3_grp db 'BOSS6_A3.GRP',0 -aBoss6_a4_grp db 'BOSS6_A4.GRP',0 -public _boss6_l_grp, _boss6_h_grp, _TENSI_MDT, _SE_FN -_boss6_l_grp db 'boss6_l.grp',0 -_boss6_h_grp db 'boss6_h.grp',0 -_TENSI_MDT db 'TENSI.MDT',0 -_SE_FN db 'zigoku.mde',0 -public _boss6_1_bos, _boss6_2_bos, _boss6_3_bos -public _boss6gr1_grc, _boss6gr2_grc, _boss6gr3_grc, _boss6gr4_grc -_boss6_1_bos db 'boss6_1.bos',0 -_boss6_2_bos db 'boss6_2.bos',0 -_boss6_3_bos db 'boss6_3.bos',0 -_boss6gr1_grc db 'boss6gr1.grc',0 -_boss6gr2_grc db 'boss6gr2.grc',0 -_boss6gr3_grc db 'boss6gr3.grc',0 -_boss6gr4_grc db 'boss6gr4.grc',0 + extern _ANGEL:byte + extern _OF:byte + extern _DEATH:byte + extern _boss6_a1_grp:byte + extern _boss6_a2_grp:byte + extern _boss6_a3_grp:byte + extern _boss6_a4_grp:byte extern _f1000_0:dword extern _f1001_0:dword extern _f12_0:dword