From 974136a5262e225089e13bec7f8ceef3bef20da6 Mon Sep 17 00:00:00 2001 From: nmlgc Date: Mon, 9 Oct 2023 16:14:06 +0200 Subject: [PATCH] [Decompilation] [th04/th05] Stage tiles: Renderer activation Part of P0258, funded by [Anonymous] and Blue Bolt. --- Makefile.mak | 4 +-- th04/main/tile/inv[bss].asm | 4 +++ th04/main/tile/tile.cpp | 29 ++++++++++++++++ th04/main/tile/tile.hpp | 15 +++++++++ th04/tile.cpp | 1 + th04_main.asm | 66 +++++------------------------------- th05_main.asm | 67 ++++--------------------------------- 7 files changed, 66 insertions(+), 120 deletions(-) create mode 100644 th04/main/tile/tile.cpp create mode 100644 th04/tile.cpp diff --git a/Makefile.mak b/Makefile.mak index 75e408ca..1de6fc36 100644 --- a/Makefile.mak +++ b/Makefile.mak @@ -152,7 +152,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\demo.cpp th04\ems.cpp th04\tile_set.cpp th04\std.cpp th04\playfld.cpp th04\midboss4.cpp th04\f_dialog.cpp bin\th04\dialog_f.obj th04\dialog.cpp th04\boss_exp.cpp th04\stages.cpp th04\player_m.cpp bin\th04\player_p.obj bin\th04\scoreupd.obj th04\hud_ovrl.cpp bin\th04\cfg_lres.obj bin\th04\checkerb.obj bin\th04\mb_inv.obj bin\th04\boss_bd.obj bin\th01\vplanset.obj bin\th03\vector.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\midboss.cpp bin\th04\hud_hp.obj th04\mb_dft.cpp bin\th04\vector2n.obj bin\th04\spark_a.obj bin\th04\grcg_3.obj bin\th04\it_spl_u.obj th04\boss_4m.cpp th04\bullet_u.cpp th04\bullet_a.cpp th04\boss.cpp th04\boss_4r.cpp th04\boss_x2.cpp +bin\th04\main.exe: bin\th04\main.obj bin\th04\slowdown.obj th04\demo.cpp th04\ems.cpp th04\tile_set.cpp th04\std.cpp bin\th04\tile.obj th04\playfld.cpp th04\midboss4.cpp th04\f_dialog.cpp bin\th04\dialog_f.obj th04\dialog.cpp th04\boss_exp.cpp th04\stages.cpp th04\player_m.cpp bin\th04\player_p.obj bin\th04\scoreupd.obj th04\hud_ovrl.cpp bin\th04\cfg_lres.obj bin\th04\checkerb.obj bin\th04\mb_inv.obj bin\th04\boss_bd.obj bin\th01\vplanset.obj bin\th03\vector.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\midboss.cpp bin\th04\hud_hp.obj th04\mb_dft.cpp bin\th04\vector2n.obj bin\th04\spark_a.obj bin\th04\grcg_3.obj bin\th04\it_spl_u.obj th04\boss_4m.cpp th04\bullet_u.cpp th04\bullet_a.cpp th04\boss.cpp th04\boss_4r.cpp th04\boss_x2.cpp $(CC) $(CFLAGS) $(LARGE_LFLAGS) -DGAME=4 -DBINARY='M' -3 -Z -nbin\th04\ -eMAIN.EXE @&&| $** | @@ -175,7 +175,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\demo.cpp th05\ems.cpp bin\th05\cfg_lres.obj th05\main010.cpp th05\f_dialog.cpp bin\th05\dialog_f.obj th05\dialog.cpp th05\boss_exp.cpp th05\playfld.cpp bin\th04\mb_inv.obj bin\th04\boss_bd.obj th05\boss_bg.cpp th05\laser_rh.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\midboss5.cpp th05\hud_ovrl.cpp bin\th04\player_p.obj bin\th04\vector2n.obj bin\th05\spark_a.obj th05\bullet_p.cpp bin\th04\grcg_3.obj th05\player_a.cpp bin\th05\bullet_1.obj th05\bullet_c.cpp bin\th03\vector.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\midboss.cpp bin\th04\hud_hp.obj th05\mb_dft.cpp th05\laser.cpp th05\cheeto_u.cpp bin\th04\it_spl_u.obj th05\bullet_u.cpp th05\midboss1.cpp th05\boss_1.cpp th05\boss_4.cpp th05\boss_6.cpp th05\boss_x.cpp th05\boss.cpp th05\main014.cpp +bin\th05\main.exe: bin\th05\main.obj bin\th04\slowdown.obj th05\demo.cpp th05\ems.cpp bin\th05\cfg_lres.obj bin\th04\tile.obj th05\main010.cpp th05\f_dialog.cpp bin\th05\dialog_f.obj th05\dialog.cpp th05\boss_exp.cpp th05\playfld.cpp bin\th04\mb_inv.obj bin\th04\boss_bd.obj th05\boss_bg.cpp th05\laser_rh.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\midboss5.cpp th05\hud_ovrl.cpp bin\th04\player_p.obj bin\th04\vector2n.obj bin\th05\spark_a.obj th05\bullet_p.cpp bin\th04\grcg_3.obj th05\player_a.cpp bin\th05\bullet_1.obj th05\bullet_c.cpp bin\th03\vector.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\midboss.cpp bin\th04\hud_hp.obj th05\mb_dft.cpp th05\laser.cpp th05\cheeto_u.cpp bin\th04\it_spl_u.obj th05\bullet_u.cpp th05\midboss1.cpp th05\boss_1.cpp th05\boss_4.cpp th05\boss_6.cpp th05\boss_x.cpp th05\boss.cpp th05\main014.cpp $(CC) $(CFLAGS) $(LARGE_LFLAGS) -3 -Z -DGAME=5 -DBINARY='M' -nbin\th05\ -eMAIN.EXE @&&| $** | diff --git a/th04/main/tile/inv[bss].asm b/th04/main/tile/inv[bss].asm index 91021cac..f4cdd84c 100644 --- a/th04/main/tile/inv[bss].asm +++ b/th04/main/tile/inv[bss].asm @@ -1,7 +1,11 @@ public _scroll_line_on_page, _tile_invalidate_box public _bg_render_not_bombing, _bg_render_bombing, _bg_render_bombing_func +public _tile_render_all_time _scroll_line_on_page dw 2 dup(?) _tile_invalidate_box Point _bg_render_not_bombing dw ? _bg_render_bombing dw ? _bg_render_bombing_func dw ? + dw ? +_tile_render_all_time db ? + evendata diff --git a/th04/main/tile/tile.cpp b/th04/main/tile/tile.cpp new file mode 100644 index 00000000..816251c6 --- /dev/null +++ b/th04/main/tile/tile.cpp @@ -0,0 +1,29 @@ +#pragma option -zPmain_01 + +#include "platform.h" +#include "pc98.h" +#include "th04/main/bg.hpp" +#include "th04/main/tile/tile.hpp" + +#define render_all_time tile_render_all_time +extern uint8_t render_all_time; + +static void pascal near tiles_render_all_timed(void) +{ + tiles_render_all(); + render_all_time--; + if(render_all_time == 0) { + bg_render_not_bombing = tiles_render; + } +} + +void tiles_activate(void) +{ + bg_render_not_bombing = tiles_render; +} + +void pascal tiles_activate_and_render_all_for_next_N_frames(uint8_t n) +{ + render_all_time = n; + bg_render_not_bombing = tiles_render_all_timed; +} diff --git a/th04/main/tile/tile.hpp b/th04/main/tile/tile.hpp index 7bafd6c9..b38597b1 100644 --- a/th04/main/tile/tile.hpp +++ b/th04/main/tile/tile.hpp @@ -85,6 +85,21 @@ void pascal near tiles_redraw_invalidated(void); // Invalidates all entity types, then redraws the invalidated tiles. void pascal near tiles_render(void); +// Sets [bg_render_not_bombing] to [tiles_render]. +void tiles_activate(void); + +// Sets [bg_render_not_bombing] to a function that calls [tiles_render_all] for +// the next [n] frames, and then sets the function pointer back to +// [tiles_render]. With [n] = 2, this removes the remnants of in-game dialog +// graphics from both VRAM pages. +// This is only needed for TH04's post-boss dialog; it's also called for the +// pre-boss ones, but [bg_render_not_bombing] is immediately overwritten with +// the boss-specific background render function which does the same job via +// tiles_render_after_custom(). In TH05, the boss-specific functions remove the +// graphics of both the pre-boss and post-boss dialogs, and this function is +// unused. +void pascal tiles_activate_and_render_all_for_next_N_frames(uint8_t n); + // Used for switching back to a tiled background after rendering anything else, // like in-game dialog, or a custom background. Makes sure to first render all // tiles to both VRAM pages, then performs regular redrawing of only the diff --git a/th04/tile.cpp b/th04/tile.cpp new file mode 100644 index 00000000..91a11a3c --- /dev/null +++ b/th04/tile.cpp @@ -0,0 +1 @@ +#include "th04/main/tile/tile.cpp" diff --git a/th04_main.asm b/th04_main.asm index e96789ff..52c1a7de 100644 --- a/th04_main.asm +++ b/th04_main.asm @@ -43,7 +43,7 @@ include th04/main/enemy/enemy.inc extern _tolower:proc extern __ctype:byte -main_01 group SLOWDOWN_TEXT, DEMO_TEXT, EMS_TEXT, TILE_SET_TEXT, STD_TEXT, mai_TEXT, PLAYFLD_TEXT, M4_RENDER_TEXT, DIALOG_TEXT, BOSS_EXP_TEXT, main_TEXT, STAGES_TEXT, main__TEXT, PLAYER_M_TEXT, PLAYER_P_TEXT, main_0_TEXT, HUD_OVRL_TEXT, main_01_TEXT, main_012_TEXT, CFG_LRES_TEXT, main_013_TEXT, CHECKERB_TEXT, MB_INV_TEXT, BOSS_BD_TEXT, BOSS_BG_TEXT +main_01 group SLOWDOWN_TEXT, DEMO_TEXT, EMS_TEXT, TILE_SET_TEXT, STD_TEXT, TILE_TEXT, mai_TEXT, PLAYFLD_TEXT, M4_RENDER_TEXT, DIALOG_TEXT, BOSS_EXP_TEXT, main_TEXT, STAGES_TEXT, main__TEXT, PLAYER_M_TEXT, PLAYER_P_TEXT, main_0_TEXT, HUD_OVRL_TEXT, main_01_TEXT, main_012_TEXT, CFG_LRES_TEXT, main_013_TEXT, CHECKERB_TEXT, MB_INV_TEXT, BOSS_BD_TEXT, BOSS_BG_TEXT g_SHARED group SHARED, SHARED_ main_03 group GATHER_TEXT, SCROLLY3_TEXT, MOTION_3_TEXT, main_032_TEXT, VECTOR2N_TEXT, SPARK_A_TEXT, GRCG_3_TEXT, IT_SPL_U_TEXT, B4M_UPDATE_TEXT, main_033_TEXT, MIDBOSS_TEXT, HUD_HP_TEXT, MB_DFT_TEXT, main_034_TEXT, BULLET_U_TEXT, BULLET_A_TEXT, main_035_TEXT, BOSS_TEXT, main_036_TEXT @@ -884,7 +884,7 @@ loc_B156: kajacall KAJA_SONG_PLAY loc_B1AE: - nopcall main_01:sub_CB99 + nopcall @tiles_activate$qv mov _overlay1, offset @overlay_stage_enter_update_and_r$qv mov _overlay2, offset nullfunc_near pop si @@ -1029,7 +1029,7 @@ STD_TEXT segment byte public 'CODE' use16 @std_load$qv procdesc near STD_TEXT ends -mai_TEXT segment word public 'CODE' use16 +TILE_TEXT segment word public 'CODE' use16 include th04/formats/std.asm ; =============== S U B R O U T I N E ======================================= @@ -1764,58 +1764,11 @@ public @TILES_RENDER$QV retn @tiles_render$qv endp + extern @tiles_activate$qv:proc + extern @TILES_ACTIVATE_AND_RENDER_ALL_FO$QUC:proc +TILE_TEXT ends -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_CB80 proc near - push bp - mov bp, sp - call @tiles_render_all$qv - dec byte_255B0 - cmp byte_255B0, 0 - jnz short loc_CB97 - mov _bg_render_not_bombing, offset @tiles_render$qv - -loc_CB97: - pop bp - retn -sub_CB80 endp - - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_CB99 proc far - push bp - mov bp, sp - mov _bg_render_not_bombing, offset @tiles_render$qv - pop bp - retf -sub_CB99 endp - - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_CBA4 proc far - -arg_0 = byte ptr 6 - - push bp - mov bp, sp - mov al, [bp+arg_0] - mov byte_255B0, al - mov _bg_render_not_bombing, offset sub_CB80 - pop bp - retf 2 -sub_CBA4 endp - -; --------------------------------------------------------------------------- - db 0 +mai_TEXT segment word public 'CODE' use16 include th04/main/tile/render_a.asm ; =============== S U B R O U T I N E ======================================= @@ -2810,7 +2763,7 @@ public @dialog_animate$qv call main_01:sub_D016 call main_01:sub_D56C push 2 - nopcall main_01:sub_CBA4 + nopcall @tiles_activate_and_render_all_fo$quc call @dialog_exit$qv graph_accesspage _page_back push 1 @@ -31242,9 +31195,6 @@ public _midboss3_patterns_done _midboss3_patterns_done db ? db 5 dup(?) include th04/main/tile/inv[bss].asm - db 2 dup(?) -byte_255B0 db ? - db ? byte_255B2 db ? byte_255B3 db ? byte_255B4 db ? diff --git a/th05_main.asm b/th05_main.asm index cb8f7e95..0cf7b9b4 100644 --- a/th05_main.asm +++ b/th05_main.asm @@ -37,7 +37,7 @@ include th05/main/enemy/enemy.inc extern _execl:proc extern _strlen:proc -main_01 group SLOWDOWN_TEXT, DEMO_TEXT, EMS_TEXT, mai_TEXT, CFG_LRES_TEXT, MB_INV_TEXT, BOSS_BD_TEXT, BOSS_BG_TEXT, LASER_RH_TEXT, main_TEXT, main__TEXT, PLAYFLD_TEXT, main_0_TEXT, HUD_OVRL_TEXT, DIALOG_TEXT, BOSS_EXP_TEXT, PLAYER_P_TEXT, main_01_TEXT +main_01 group SLOWDOWN_TEXT, DEMO_TEXT, EMS_TEXT, TILE_TEXT, mai_TEXT, CFG_LRES_TEXT, MB_INV_TEXT, BOSS_BD_TEXT, BOSS_BG_TEXT, LASER_RH_TEXT, main_TEXT, main__TEXT, PLAYFLD_TEXT, main_0_TEXT, HUD_OVRL_TEXT, DIALOG_TEXT, BOSS_EXP_TEXT, PLAYER_P_TEXT, main_01_TEXT g_SHARED group SHARED, SHARED_ main_03 group SCROLLY3_TEXT, MOTION_3_TEXT, main_031_TEXT, VECTOR2N_TEXT, SPARK_A_TEXT, BULLET_P_TEXT, GRCG_3_TEXT, PLAYER_A_TEXT, BULLET_A_TEXT, main_032_TEXT, main_033_TEXT, MIDBOSS_TEXT, HUD_HP_TEXT, MB_DFT_TEXT, LASER_SC_TEXT, CHEETO_U_TEXT, IT_SPL_U_TEXT, BULLET_U_TEXT, MIDBOSS1_TEXT, B1_UPDATE_TEXT, B4_UPDATE_TEXT, main_035_TEXT, B6_UPDATE_TEXT, BX_UPDATE_TEXT, main_036_TEXT, BOSS_TEXT @@ -900,7 +900,7 @@ loc_B3C5: call super_entry_bfnt loc_B3CA: - nopcall sub_BF27 + nopcall @tiles_activate$qv mov _pellet_bottom_col, GC_RG mov al, _stage_id mov ah, 0 @@ -1174,7 +1174,7 @@ CFG_LRES_TEXT segment byte public 'CODE' use16 _cfg_load_resident_ptr procdesc near CFG_LRES_TEXT ends -mai_TEXT segment word public 'CODE' use16 +TILE_TEXT segment word public 'CODE' use16 ; =============== S U B R O U T I N E ======================================= @@ -1496,61 +1496,11 @@ public @TILES_RENDER$QV retn @tiles_render$qv endp + extern @tiles_activate$qv:proc + extern @TILES_ACTIVATE_AND_RENDER_ALL_FO$QUC:proc +TILE_TEXT ends -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_BF0E proc near - push bp - mov bp, sp - call @tiles_render_all$qv - dec byte_23F5E - cmp byte_23F5E, 0 - jnz short loc_BF25 - mov _bg_render_not_bombing, offset @tiles_render$qv - -loc_BF25: - pop bp - retn -sub_BF0E endp - - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_BF27 proc far - push bp - mov bp, sp - mov _bg_render_not_bombing, offset @tiles_render$qv - pop bp - retf -sub_BF27 endp - - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_BF32 proc far - -arg_0 = byte ptr 6 - - push bp - mov bp, sp - mov al, [bp+arg_0] - mov byte_23F5E, al - mov _bg_render_not_bombing, offset sub_BF0E - pop bp - retf 2 -sub_BF32 endp - -; --------------------------------------------------------------------------- - db 0 - -; =============== S U B R O U T I N E ======================================= - +mai_TEXT segment word public 'CODE' use16 include th04/main/tile/redraw.asm include th04/main/scroll_y_1.asm MOTION_UPDATE_DEF 1 @@ -20701,9 +20651,6 @@ byte_23F04 db ? word_23F06 dw ? include th04/formats/std[bss].asm include th04/main/tile/inv[bss].asm - db 2 dup(?) -byte_23F5E db ? - db ? ; word_23F60 dw ? include th02/math/randring[bss].asm include th04/main/pointnum/render[bss].asm