From 5e4f1f0f1d3be03c31ae0e3bee739c9645879e20 Mon Sep 17 00:00:00 2001 From: nmlgc Date: Mon, 14 Mar 2022 16:45:05 +0100 Subject: [PATCH] [Reverse-engineering] [th04] Gengetsu: Wave teleport amplitude Given how close the string literals of TH04's boss defeat sequence function are to the end of its data segment, it makes sense to figure out the three values after it right now. Part of P0187, funded by [Anonymous] and Blue Bolt. --- Makefile.mak | 2 +- th04/boss_x2.cpp | 1 + th04/main/boss/{bx_1.asm => bx1.asm} | 0 th04/main/boss/{bx_1.cpp => bx1.cpp} | 0 th04/main/boss/bx2.cpp | 7 ++++++ th04_main.asm | 35 ++++++++++++++-------------- 6 files changed, 26 insertions(+), 19 deletions(-) create mode 100644 th04/boss_x2.cpp rename th04/main/boss/{bx_1.asm => bx1.asm} (100%) rename th04/main/boss/{bx_1.cpp => bx1.cpp} (100%) create mode 100644 th04/main/boss/bx2.cpp diff --git a/Makefile.mak b/Makefile.mak index 946f6ee3..c3fbe250 100644 --- a/Makefile.mak +++ b/Makefile.mak @@ -126,7 +126,7 @@ bin\th04\op.exe: bin\th04\op.obj th04\m_char.cpp bin\th01\vplanset.obj bin\th02\ $** | -bin\th04\main.exe: bin\th04\main.obj bin\th04\slowdown.obj th04\ems.cpp th04\playfld.cpp th04\f_dialog.cpp th04\dialog.cpp bin\th04\player_p.obj bin\th04\scoreupd.obj th04\hud_ovrl.cpp bin\th04\cfg_lres.obj bin\th01\vplanset.obj bin\th03\vector2.obj bin\th02\frmdely1.obj bin\th03\hfliplut.obj th04\mpn_free.cpp bin\th04\input_w.obj th04\mpn_l_i.cpp bin\th04\vector.obj bin\th04\snd_pmdr.obj bin\th04\snd_mmdr.obj bin\th04\snd_kaja.obj bin\th04\snd_mode.obj bin\th04\snd_load.obj bin\th04\cdg_put.obj bin\th04\exit.obj bin\th04\initmain.obj bin\th04\cdg_p_na.obj bin\th04\cdg_p_pr.obj bin\th04\input_s.obj bin\th04\snd_se_r.obj bin\th04\snd_se.obj bin\th04\cdg_load.obj th04\gather.cpp bin\th04\scrolly3.obj bin\th04\motion_3.obj th04\mb_dft.cpp bin\th04\it_spl_u.obj th04\bullet_u.cpp th04\bullet_a.cpp +bin\th04\main.exe: bin\th04\main.obj bin\th04\slowdown.obj th04\ems.cpp th04\playfld.cpp th04\f_dialog.cpp th04\dialog.cpp bin\th04\player_p.obj bin\th04\scoreupd.obj th04\hud_ovrl.cpp bin\th04\cfg_lres.obj bin\th01\vplanset.obj bin\th03\vector2.obj bin\th02\frmdely1.obj bin\th03\hfliplut.obj th04\mpn_free.cpp bin\th04\input_w.obj th04\mpn_l_i.cpp bin\th04\vector.obj bin\th04\snd_pmdr.obj bin\th04\snd_mmdr.obj bin\th04\snd_kaja.obj bin\th04\snd_mode.obj bin\th04\snd_load.obj bin\th04\cdg_put.obj bin\th04\exit.obj bin\th04\initmain.obj bin\th04\cdg_p_na.obj bin\th04\cdg_p_pr.obj bin\th04\input_s.obj bin\th04\snd_se_r.obj bin\th04\snd_se.obj bin\th04\cdg_load.obj th04\gather.cpp bin\th04\scrolly3.obj bin\th04\motion_3.obj th04\mb_dft.cpp bin\th04\it_spl_u.obj th04\bullet_u.cpp th04\bullet_a.cpp th04\boss_x2.cpp $(CC) $(CFLAGS) $(LARGE_LFLAGS) -DGAME=4 -DBINARY='M' -3 -Z -nbin\th04\ -eMAIN.EXE @&&| $** | diff --git a/th04/boss_x2.cpp b/th04/boss_x2.cpp new file mode 100644 index 00000000..c0d4ca84 --- /dev/null +++ b/th04/boss_x2.cpp @@ -0,0 +1 @@ +#include "th04/main/boss/bx2.cpp" diff --git a/th04/main/boss/bx_1.asm b/th04/main/boss/bx1.asm similarity index 100% rename from th04/main/boss/bx_1.asm rename to th04/main/boss/bx1.asm diff --git a/th04/main/boss/bx_1.cpp b/th04/main/boss/bx1.cpp similarity index 100% rename from th04/main/boss/bx_1.cpp rename to th04/main/boss/bx1.cpp diff --git a/th04/main/boss/bx2.cpp b/th04/main/boss/bx2.cpp new file mode 100644 index 00000000..eb548015 --- /dev/null +++ b/th04/main/boss/bx2.cpp @@ -0,0 +1,7 @@ +/// Extra Stage Boss #2 - Gengetsu +/// ------------------------------ + +#include "platform.h" + +#define wave_amp gengetsu_wave_amp +uint8_t wave_amp = 0x00; // Should really have been signed. diff --git a/th04_main.asm b/th04_main.asm index 25f12b1b..7f82a8b3 100644 --- a/th04_main.asm +++ b/th04_main.asm @@ -11891,19 +11891,19 @@ var_2 = word ptr -2 mov si, ax cmp _boss_phase, PHASE_EXPLODE_BIG jnb loc_1306D - cmp amp_237F8, 0 + cmp _gengetsu_wave_amp, 0 jz short loc_12FE7 push di push ax mov al, _boss_sprite mov ah, 0 push ax - mov al, amp_237F8 + mov al, _gengetsu_wave_amp mov ah, 0 mov dx, 80 sub dx, ax push dx - push word ptr amp_237F8 + push word ptr _gengetsu_wave_amp mov al, _boss_angle mov ah, 0 push ax @@ -11915,12 +11915,12 @@ var_2 = word ptr -2 mov ah, 0 inc ax push ax - mov al, amp_237F8 + mov al, _gengetsu_wave_amp mov ah, 0 mov dx, 80 sub dx, ax push dx - push word ptr amp_237F8 + push word ptr _gengetsu_wave_amp mov al, _boss_angle mov ah, 0 push ax @@ -20092,7 +20092,7 @@ loc_18682: retn mugetsu_18655 endp -include th04/main/boss/bx_1.asm +include th04/main/boss/bx1.asm ; =============== S U B R O U T I N E ======================================= @@ -30367,20 +30367,20 @@ loc_1F994: add _boss_pos.cur.x, ax cmp _boss_phase_frame, 32 jg short loc_1F9A9 - mov al, amp_237F8 + mov al, _gengetsu_wave_amp add al, 2 jmp short loc_1F9AE ; --------------------------------------------------------------------------- loc_1F9A9: - mov al, amp_237F8 + mov al, _gengetsu_wave_amp add al, -2 loc_1F9AE: - mov amp_237F8, al + mov _gengetsu_wave_amp, al cmp _boss_phase_frame, 64 jnz short loc_1F9C1 - mov amp_237F8, 0 + mov _gengetsu_wave_amp, 0 mov al, 1 pop bp retn @@ -30433,18 +30433,18 @@ loc_1FA00: loc_1FA07: cmp _boss_phase_frame, 64 jg short loc_1FA14 - inc amp_237F8 + inc _gengetsu_wave_amp jmp short loc_1FA18 ; --------------------------------------------------------------------------- loc_1FA14: - dec amp_237F8 + dec _gengetsu_wave_amp loc_1FA18: cmp _boss_phase_frame, 128 jnz short loc_1FA2F mov _boss_pos.cur.x, (192 shl 4) - mov amp_237F8, 0 + mov _gengetsu_wave_amp, 0 mov al, 1 pop bp retn @@ -31335,7 +31335,7 @@ gengetsu_20202 proc near mov bp, sp cmp byte_259EF, 0 jz short loc_20220 - cmp amp_237F8, 0 + cmp _gengetsu_wave_amp, 0 jnz short loc_20220 call sub_1E5D8 pascal, (48 shl 4) or ((48 shl 4) shl 16), 10 jmp short loc_20233 @@ -31344,7 +31344,7 @@ gengetsu_20202 proc near loc_20220: cmp _boss_sprite, 0 jz short loc_20233 - cmp amp_237F8, 0 + cmp _gengetsu_wave_amp, 0 jnz short loc_20233 call sub_1E64E pop bp @@ -31855,7 +31855,7 @@ loc_206B1: ; --------------------------------------------------------------------------- loc_206B6: - cmp amp_237F8, 0 + cmp _gengetsu_wave_amp, 0 jnz short loc_206C9 mov ax, _boss_pos.cur.x mov _homing_target.x, ax @@ -32536,8 +32536,7 @@ aSt06bk2_cdg db 'st06bk2.cdg',0 aSt06b_bb db 'st06b.bb',0 byte_237F6 db 0 byte_237F7 db 0 -amp_237F8 db 0 - even + extern _gengetsu_wave_amp:byte .data?