Skip to content

Commit

Permalink
[Reverse-engineering] [th04] Gengetsu: Wave teleport amplitude
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
nmlgc committed Mar 26, 2022
1 parent 9e75a62 commit 5e4f1f0
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Makefile.mak
Expand Up @@ -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 @&&|
$**
|
Expand Down
1 change: 1 addition & 0 deletions th04/boss_x2.cpp
@@ -0,0 +1 @@
#include "th04/main/boss/bx2.cpp"
File renamed without changes.
File renamed without changes.
7 changes: 7 additions & 0 deletions 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.
35 changes: 17 additions & 18 deletions th04_main.asm
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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 =======================================

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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?

Expand Down

0 comments on commit 5e4f1f0

Please sign in to comment.