From 030908ebde78f8f8ac7f0acf18399e2d15263e78 Mon Sep 17 00:00:00 2001 From: nmlgc Date: Mon, 19 Jun 2023 20:49:53 +0200 Subject: [PATCH] [Decompilation] [th04] Stage 4 midboss: Rendering Getting back one letter for the dummy segments within the first group. Part of P0245, funded by [Anonymous], Blue Bolt, Ember2528, and Yanga. --- Makefile.mak | 2 +- th02/main/playfld.hpp | 8 ++--- th04/formats/dialog.cpp | 2 +- th04/main/midboss/m4.cpp | 45 ++++++++++++++++++++++++ th04/midboss4.cpp | 1 + th04_main.asm | 76 +++++----------------------------------- 6 files changed, 60 insertions(+), 74 deletions(-) create mode 100644 th04/main/midboss/m4.cpp create mode 100644 th04/midboss4.cpp diff --git a/Makefile.mak b/Makefile.mak index 72dcf768..8aca4523 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\f_dialog.cpp th04\dialog.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 th04\playfld.cpp th04\midboss4.cpp th04\f_dialog.cpp th04\dialog.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 @&&| $** | diff --git a/th02/main/playfld.hpp b/th02/main/playfld.hpp index 6666503e..e2468bf5 100644 --- a/th02/main/playfld.hpp +++ b/th02/main/playfld.hpp @@ -100,11 +100,11 @@ center_y < to_sp((h / 2) - PLAYFIELD_ROLL_MARGIN) \ ) -#define playfield_clip_center_bottom_small(center_y, h) ( \ - center_y >= to_sp(PLAYFIELD_BOTTOM + PLAYFIELD_ROLL_MARGIN - (h / 2)) \ +#define playfield_clip_center_bottom_small_roll(center_y, h) ( \ + center_y >= to_sp(PLAYFIELD_H + PLAYFIELD_ROLL_MARGIN - (h / 2)) \ ) -#define playfield_clip_center_bottom_large(center_y, h) ( \ - center_y > to_sp(PLAYFIELD_BOTTOM + PLAYFIELD_ROLL_MARGIN - (h / 2)) \ +#define playfield_clip_center_bottom_large_roll(center_y, h) ( \ + center_y > to_sp(PLAYFIELD_H + PLAYFIELD_ROLL_MARGIN - (h / 2)) \ ) #define playfield_clip_left_small( left, w) (left <= (PLAYFIELD_LEFT - w)) diff --git a/th04/formats/dialog.cpp b/th04/formats/dialog.cpp index 13c2f0a2..a662b078 100644 --- a/th04/formats/dialog.cpp +++ b/th04/formats/dialog.cpp @@ -1,4 +1,4 @@ -#pragma option -zCmai_TEXT +#pragma option -zCM4_RENDER_TEXT #include #include "platform.h" diff --git a/th04/main/midboss/m4.cpp b/th04/main/midboss/m4.cpp new file mode 100644 index 00000000..d22cec67 --- /dev/null +++ b/th04/main/midboss/m4.cpp @@ -0,0 +1,45 @@ +/// Stage 4 midboss +/// --------------- + +#pragma option -zCM4_RENDER_TEXT -zPmain_01 + +#include "platform.h" +#include "pc98.h" +#include "master.hpp" +#include "th01/math/subpixel.hpp" +#include "th02/v_colors.hpp" +#include "th04/math/motion.hpp" +#include "th04/main/scroll.hpp" +#include "th04/main/phase.hpp" +#include "th04/main/playfld.hpp" +#include "th04/main/midboss/midboss.hpp" +#include "th04/main/hud/hud.hpp" +#include "th04/sprites/main_pat.h" + +// Constants +// --------- + +static const pixel_t MIDBOSS4_W = 64; +static const pixel_t MIDBOSS4_H = 64; +// --------- + +void pascal near midboss4_render(void) +{ + // ZUN bug: Should use the large variant instead. + if(playfield_clip_point_yx_small_roll( + midboss.pos.cur, MIDBOSS4_W, MIDBOSS4_H + )) { + return; + } + screen_x_t left = midboss.pos.cur.x.to_pixel(); + vram_y_t top = midboss.pos.cur.to_vram_top_scrolled_seg1(MIDBOSS4_H); + if(midboss.phase <= 2) { + int patnum = (PAT_MIDBOSS4_STILL_LEFT + midboss.sprite); + if(midboss.pos.cur.x.v >= to_sp(PLAYFIELD_W / 2)) { + patnum += M4C_CELS; + } + midboss_put_generic(left, top, patnum); + } else if(midboss.phase == PHASE_EXPLODE_BIG) { + midboss_defeat_render(); + } +} diff --git a/th04/midboss4.cpp b/th04/midboss4.cpp new file mode 100644 index 00000000..fa139692 --- /dev/null +++ b/th04/midboss4.cpp @@ -0,0 +1 @@ +#include "th04/main/midboss/m4.cpp" diff --git a/th04_main.asm b/th04_main.asm index 4e60c200..7b9ec4a5 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, m_TEXT, DEMO_TEXT, EMS_TEXT, TILE_SET_TEXT, STD_TEXT, ma_TEXT, PLAYFLD_TEXT, mai_TEXT, DIALOG_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, ma_TEXT, DEMO_TEXT, EMS_TEXT, TILE_SET_TEXT, STD_TEXT, mai_TEXT, PLAYFLD_TEXT, M4_RENDER_TEXT, DIALOG_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 @@ -270,7 +270,7 @@ SLOWDOWN_TEXT segment word public 'CODE' use16 SLOWDOWN_TEXT ends ; Segment type: Pure code -m_TEXT segment word public 'CODE' use16 +ma_TEXT segment word public 'CODE' use16 assume cs:main_01 ;org 1 assume es:nothing, ss:nothing, ds:_DATA, fs:nothing, gs:nothing @@ -1011,7 +1011,7 @@ var_4 = dword ptr -4 leave retn demo_load endp -m_TEXT ends +ma_TEXT ends DEMO_TEXT segment byte public 'CODE' use16 @DemoPlay$qv procdesc near @@ -1031,7 +1031,7 @@ STD_TEXT segment byte public 'CODE' use16 @std_load$qv procdesc near STD_TEXT ends -ma_TEXT segment word public 'CODE' use16 +mai_TEXT segment word public 'CODE' use16 include th04/formats/std.asm ; =============== S U B R O U T I N E ======================================= @@ -1940,75 +1940,15 @@ loc_CD31: pop bp retn sub_CCD6 endp -ma_TEXT ends +mai_TEXT ends PLAYFLD_TEXT segment byte public 'CODE' use16 @playfield_shake_update_and_rende$qv procdesc pascal near PLAYFLD_TEXT ends -mai_TEXT segment byte public 'CODE' use16 - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame -public @MIDBOSS4_RENDER$QV -@midboss4_render$qv proc near - -@@y = word ptr -2 - - enter 2, 0 - push si - push di - cmp _midboss_pos.cur.y, 0 - jle short loc_CE8F - cmp _midboss_pos.cur.y, (368 shl 4) - jge short loc_CE8F - cmp _midboss_pos.cur.x, 0 - jle short loc_CE8F - cmp _midboss_pos.cur.x, (384 shl 4) - jge short loc_CE8F - mov ax, _midboss_pos.cur.x - sar ax, 4 - mov di, ax - mov ax, _midboss_pos.cur.y - add ax, (-16 shl 4) - call main_01:scroll_subpixel_y_to_vram_seg1 pascal, ax - mov [bp+@@y], ax - cmp _midboss_phase, 2 - ja short loc_CE85 - mov al, _midboss_sprite - mov ah, 0 - add ax, PAT_MIDBOSS4_STILL_LEFT - mov si, ax - cmp _midboss_pos.cur.x, (192 shl 4) - jl short loc_CE5B - add si, M4C_CELS - -loc_CE5B: - cmp _midboss_damage_this_frame, 0 - jnz short loc_CE6E - call super_roll_put pascal, di, [bp+@@y], si - jmp short loc_CE8F -; --------------------------------------------------------------------------- - -loc_CE6E: - call super_roll_put_1plane pascal, di, [bp+@@y], si, large PLANE_PUT or GC_BRGI - mov _midboss_damage_this_frame, 0 - jmp short loc_CE8F -; --------------------------------------------------------------------------- - -loc_CE85: - cmp _midboss_phase, PHASE_EXPLODE_BIG - jnz short loc_CE8F - call @midboss_defeat_render$qv - -loc_CE8F: - pop di - pop si - leave - retn -@midboss4_render$qv endp -mai_TEXT ends +M4_RENDER_TEXT segment byte public 'CODE' use16 + @MIDBOSS4_RENDER$QV procdesc pascal near +M4_RENDER_TEXT ends DIALOG_TEXT segment byte public 'CODE' use16 @dialog_load$qv procdesc near