From 295d5a8c6c568ebda83c1ce37760b5d17fc03cae Mon Sep 17 00:00:00 2001 From: nmlgc Date: Wed, 9 Mar 2022 17:33:49 +0100 Subject: [PATCH] [Decompilation] [th05] Bosses: Player sprite collision MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit TH05 only…? Yes, moving over a boss sprite doesn't actually kill the player in TH04. Part of P0186, funded by [Anonymous] and Blue Bolt. --- Makefile.mak | 2 +- th04/main/boss/boss.cpp | 42 +++++++++++++++++++++++++++++++++++++++++ th05/boss.cpp | 1 + th05_main.asm | 34 ++++++--------------------------- 4 files changed, 50 insertions(+), 29 deletions(-) create mode 100644 th04/main/boss/boss.cpp create mode 100644 th05/boss.cpp diff --git a/Makefile.mak b/Makefile.mak index 89fb405c..db1a19bd 100644 --- a/Makefile.mak +++ b/Makefile.mak @@ -149,7 +149,7 @@ bin\th05\op.exe: th05\op010.cpp bin\th05\op.obj th05\op011.cpp th05\m_char.cpp b $** | -bin\th05\main.exe: bin\th05\main.obj bin\th04\slowdown.obj th05\ems.cpp bin\th05\cfg_lres.obj th05\main010.cpp th05\dialog.cpp th05\playfld.cpp th05\main011.cpp th05\p_common.cpp th05\p_reimu.cpp th05\p_marisa.cpp th05\p_mima.cpp th05\p_yuuka.cpp bin\th05\player.obj bin\th05\hud_bar.obj bin\th05\scoreupd.obj th05\hud_ovrl.cpp bin\th04\player_p.obj th05\main014.cpp th05\player_a.cpp bin\th05\bullet_1.obj th05\bullet_c.cpp bin\th03\vector2.obj bin\th03\hfliplut.obj bin\th04\snd_pmdr.obj bin\th04\snd_mmdr.obj bin\th04\snd_mode.obj bin\th05\bullet.obj th05\bullet_t.cpp bin\th04\cdg_p_na.obj bin\th04\snd_se_r.obj bin\th04\snd_se.obj bin\th05\cdg_put.obj bin\th04\exit.obj bin\th05\vector.obj bin\th05\snd_load.obj bin\th05\snd_kaja.obj bin\th05\initmain.obj bin\th05\input_s.obj bin\th05\inp_h_w.obj bin\th05\frmdelay.obj bin\th04\cdg_load.obj bin\th04\scrolly3.obj bin\th04\motion_3.obj th05\gather.cpp th05\main032.cpp th05\mb_dft.cpp th05\laser_sc.cpp th05\curveb_u.cpp bin\th04\it_spl_u.obj th05\bullet_u.cpp th05\main034.cpp th05\main035.cpp +bin\th05\main.exe: bin\th05\main.obj bin\th04\slowdown.obj th05\ems.cpp bin\th05\cfg_lres.obj th05\main010.cpp th05\dialog.cpp th05\playfld.cpp th05\main011.cpp th05\p_common.cpp th05\p_reimu.cpp th05\p_marisa.cpp th05\p_mima.cpp th05\p_yuuka.cpp bin\th05\player.obj bin\th05\hud_bar.obj bin\th05\scoreupd.obj th05\hud_ovrl.cpp bin\th04\player_p.obj th05\main014.cpp th05\player_a.cpp bin\th05\bullet_1.obj th05\bullet_c.cpp bin\th03\vector2.obj bin\th03\hfliplut.obj bin\th04\snd_pmdr.obj bin\th04\snd_mmdr.obj bin\th04\snd_mode.obj bin\th05\bullet.obj th05\bullet_t.cpp bin\th04\cdg_p_na.obj bin\th04\snd_se_r.obj bin\th04\snd_se.obj bin\th05\cdg_put.obj bin\th04\exit.obj bin\th05\vector.obj bin\th05\snd_load.obj bin\th05\snd_kaja.obj bin\th05\initmain.obj bin\th05\input_s.obj bin\th05\inp_h_w.obj bin\th05\frmdelay.obj bin\th04\cdg_load.obj bin\th04\scrolly3.obj bin\th04\motion_3.obj th05\gather.cpp th05\main032.cpp th05\mb_dft.cpp th05\laser_sc.cpp th05\curveb_u.cpp bin\th04\it_spl_u.obj th05\bullet_u.cpp th05\main034.cpp th05\main035.cpp th05\boss.cpp $(CC) $(CFLAGS) $(LARGE_LFLAGS) -3 -Z -DGAME=5 -DBINARY='M' -nbin\th05\ -eMAIN.EXE @&&| $** | diff --git a/th04/main/boss/boss.cpp b/th04/main/boss/boss.cpp new file mode 100644 index 00000000..caf29333 --- /dev/null +++ b/th04/main/boss/boss.cpp @@ -0,0 +1,42 @@ +#include "platform.h" +#include "pc98.h" +#include "th01/math/overlap.hpp" +#include "th01/math/subpixel.hpp" +#include "th04/math/motion.hpp" +extern "C" { +#include "th04/main/playfld.hpp" +} +#include "th04/main/boss/boss.hpp" +#include "th04/main/player/player.hpp" + +#if (GAME == 5) + // Processes any collision between the player and boss sprites. + void near boss_hittest_player(void); +#else + // Moving on top of the boss doesn't kill the player in TH04. + inline void boss_hittest_player(void) { + } +#endif + +#if (GAME == 5) + void near boss_hittest_player(void) + { + #define delta_x static_cast(_AX) + #define delta_y static_cast(_DX) + + delta_x = boss.pos.cur.x.v; + delta_y = boss.pos.cur.y.v; + delta_x -= player_pos.cur.x.v; + delta_y -= player_pos.cur.y.v; + + // You probably wouldn't swap X and Y in sane code. + if(overlap_wh_inplace_fast( + delta_y, delta_x, to_sp(BOSS_H / 2), to_sp(BOSS_W / 2) + )) { + player_is_hit = true; + } + + #undef delta_y + #undef delta_x + } +#endif diff --git a/th05/boss.cpp b/th05/boss.cpp new file mode 100644 index 00000000..6cf702e5 --- /dev/null +++ b/th05/boss.cpp @@ -0,0 +1 @@ +#include "th04/main/boss/boss.cpp" diff --git a/th05_main.asm b/th05_main.asm index 011ae687..c378fbd9 100644 --- a/th05_main.asm +++ b/th05_main.asm @@ -39,7 +39,7 @@ include th05/main/enemy/enemy.inc main_01 group SLOWDOWN_TEXT, m_TEXT, EMS_TEXT, ma_TEXT, CFG_LRES_TEXT, mai_TEXT, main_TEXT, main__TEXT, PLAYFLD_TEXT, main_0_TEXT, HUD_OVRL_TEXT, DIALOG_TEXT, PLAYER_P_TEXT, main_01_TEXT g_SHARED group SHARED, SHARED_ -main_03 group SCROLLY3_TEXT, MOTION_3_TEXT, main_031_TEXT, BULLET_A_TEXT, main_032_TEXT, main_033_TEXT, MB_DFT_TEXT, LASER_SC_TEXT, CURVEB_U_TEXT, IT_SPL_U_TEXT, BULLET_U_TEXT, main_034_TEXT, main_035_TEXT, main_036_TEXT +main_03 group SCROLLY3_TEXT, MOTION_3_TEXT, main_031_TEXT, BULLET_A_TEXT, main_032_TEXT, main_033_TEXT, MB_DFT_TEXT, LASER_SC_TEXT, CURVEB_U_TEXT, IT_SPL_U_TEXT, BULLET_U_TEXT, main_034_TEXT, main_035_TEXT, main_036_TEXT, BOSS_TEXT ; =========================================================================== @@ -23454,7 +23454,7 @@ sub_1FA5E proc near loc_1FA8E: mov byte_2297E, 0 - call sub_1FD62 + call @boss_hittest_player$qv mov ax, si pop si pop bp @@ -23716,34 +23716,12 @@ loc_1FD5D: pop bp retn 2 boss_death_sequence_function endp - - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_1FD62 proc near - push bp - mov bp, sp - mov ax, _boss_pos.cur.x - mov dx, _boss_pos.cur.y - sub ax, _player_pos.cur.x - sub dx, _player_pos.cur.y - add dx, 16 * 16 - cmp dx, 32 * 16 - ja short loc_1FD8B - add ax, 16 * 16 - cmp ax, 32 * 16 - ja short loc_1FD8B - mov _player_is_hit, 1 - -loc_1FD8B: - pop bp - retn -sub_1FD62 endp - main_036_TEXT ends +BOSS_TEXT segment byte public 'CODE' use16 + @boss_hittest_player$qv procdesc near +BOSS_TEXT ends + .data byte_20A70 db 0