[Decompilation] [th04/th05] Midbosses: Sprite area invalidation

Part of P0192, funded by [Anonymous], nrook, and -Tom-.
This commit is contained in:
nmlgc 2022-04-24 03:54:19 +02:00
parent fb924f7f9a
commit 5edc459749
9 changed files with 63 additions and 72 deletions

View File

@ -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\th04\boss_bd.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 bin\th04\hud_hp.obj th04\mb_dft.cpp 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\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\th04\mb_inv.obj bin\th04\boss_bd.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 bin\th04\hud_hp.obj th04\mb_dft.cpp 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 @&&|
$**
|
@ -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\f_dialog.cpp th05\dialog.cpp th05\playfld.cpp bin\th04\boss_bd.obj th05\boss_bg.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\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 bin\th04\hud_hp.obj th05\mb_dft.cpp th05\laser_sc.cpp th05\cheeto_u.cpp bin\th04\it_spl_u.obj th05\bullet_u.cpp th05\midboss1.cpp th05\main034.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\ems.cpp bin\th05\cfg_lres.obj th05\main010.cpp th05\f_dialog.cpp th05\dialog.cpp th05\playfld.cpp bin\th04\mb_inv.obj bin\th04\boss_bd.obj th05\boss_bg.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\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 bin\th04\hud_hp.obj th05\mb_dft.cpp th05\laser_sc.cpp th05\cheeto_u.cpp bin\th04\it_spl_u.obj th05\bullet_u.cpp th05\midboss1.cpp th05\main034.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 @&&|
$**
|

View File

@ -1,6 +1,3 @@
#define ENEMY_W 32
#define ENEMY_H 32
enum enemy_flag_t {
EF_FREE = 0,
EF_ALIVE = 1,

5
th04/main/enemy/size.hpp Normal file
View File

@ -0,0 +1,5 @@
#define ENEMY_W 32
#define ENEMY_H 32
static const pixel_t ENEMY_KILL_W = 32;
static const pixel_t ENEMY_KILL_H = 32;

View File

@ -1,12 +1,10 @@
; *_func() functions are "activated" by setting the regular function once the
; midboss battle starts.
public _midboss_active, _midboss_invalidate?
public _midboss_active, _midboss_invalidate
public _midboss_update, _midboss_update_func
public _midboss_render, _midboss_render_func
_midboss_active db ?
db ?
_midboss_invalidate? dw ?
evendata
_midboss_invalidate dw ?
_midboss_update dd ?
_midboss_render dw ?
_midboss_update_func dd ?

30
th04/main/midboss/inv.cpp Normal file
View File

@ -0,0 +1,30 @@
#pragma option -3
#include "platform.h"
#include "pc98.h"
#include "master.hpp"
#include "th01/math/subpixel.hpp"
#include "th04/math/motion.hpp"
extern "C" {
#include "th04/main/playfld.hpp"
}
#include "th04/main/phase.hpp"
#include "th04/main/enemy/size.hpp"
#include "th04/main/midboss/midboss.hpp"
#include "th04/main/tile/tile.hpp"
// See tile.hpp for the reason this declaration is necessary
extern "C" void pascal near tiles_invalidate_around(const SPPoint center);
void pascal near midboss_invalidate_func(void)
{
if(midboss.phase < PHASE_EXPLODE_BIG) {
tile_invalidate_box.x = MIDBOSS_W_MAX;
tile_invalidate_box.y = MIDBOSS_H_MAX;
tiles_invalidate_around(midboss.pos.prev);
} else {
tile_invalidate_box.x = (ENEMY_KILL_W * 4);
tile_invalidate_box.y = (ENEMY_KILL_H * 4);
tiles_invalidate_around(midboss.pos.cur);
}
}

View File

@ -1,3 +1,5 @@
static const pixel_t MIDBOSS_W_MAX = 64;
static const pixel_t MIDBOSS_H_MAX = 64;
static const unsigned int MIDBOSS_BONUS_UNIT_VALUE = 1280;
typedef struct {
@ -21,11 +23,14 @@ extern bool midboss_active;
// new point number popup per unit around the midboss sprite.
void pascal near midboss_score_bonus(unsigned int units);
// Callbacks
// Callbacks. *_func() functions are "activated" by setting the regular
// function once the midboss battle starts.
extern nearfunc_t_near midboss_invalidate;
extern farfunc_t_near midboss_update_func;
extern nearfunc_t_near midboss_render_func;
void midboss_reset(void);
void pascal near midboss_invalidate_func(void);
// Processes any collision of player shots within a box with the given radius
// around the current position of the midboss. Returns the total amount of

1
th04/mb_inv.cpp Normal file
View File

@ -0,0 +1 @@
#include "th04/main/midboss/inv.cpp"

View File

@ -43,7 +43,7 @@ include th04/main/enemy/enemy.inc
extern _tolower:proc
extern __ctype:byte
main_01 group SLOWDOWN_TEXT, ma_TEXT, EMS_TEXT, mai_TEXT, PLAYFLD_TEXT, main_TEXT, DIALOG_TEXT, main__TEXT, PLAYER_P_TEXT, main_0_TEXT, HUD_OVRL_TEXT, main_01_TEXT, main_012_TEXT, CFG_LRES_TEXT, main_013_TEXT, BOSS_BD_TEXT, BOSS_BG_TEXT
main_01 group SLOWDOWN_TEXT, ma_TEXT, EMS_TEXT, mai_TEXT, PLAYFLD_TEXT, main_TEXT, DIALOG_TEXT, main__TEXT, PLAYER_P_TEXT, main_0_TEXT, HUD_OVRL_TEXT, main_01_TEXT, main_012_TEXT, CFG_LRES_TEXT, main_013_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, IT_SPL_U_TEXT, BOSS_4M_TEXT, main_033_TEXT, HUD_HP_TEXT, MB_DFT_TEXT, main_034_TEXT, BULLET_U_TEXT, BULLET_A_TEXT, main_035_TEXT, BOSS_TEXT, main_036_TEXT
@ -1908,7 +1908,7 @@ tiles_render proc near
call items_invalidate
call _sparks_invalidate
call main_01:pointnums_invalidate
call _midboss_invalidate?
call _midboss_invalidate
call _stage_invalidate
call main_01:tiles_redraw_invalidated
pop bp
@ -10120,35 +10120,12 @@ loc_12122:
pop di
retn
sub_12076 endp
; =============== S U B R O U T I N E =======================================
; Attributes: bp-based frame
sub_12124 proc near
push bp
mov bp, sp
cmp _midboss_phase, PHASE_EXPLODE_BIG
jnb short loc_12141
mov _tile_invalidate_box.x, 64
mov _tile_invalidate_box.y, 64
pushd [_midboss_pos.prev]
jmp short loc_12152
; ---------------------------------------------------------------------------
loc_12141:
mov _tile_invalidate_box.x, 128
mov _tile_invalidate_box.y, 128
pushd [_midboss_pos.cur]
loc_12152:
call main_01:tiles_invalidate_around
pop bp
retn
sub_12124 endp
main_013_TEXT ends
MB_INV_TEXT segment byte public 'CODE' use16
@MIDBOSS_INVALIDATE_FUNC$QV procdesc near
MB_INV_TEXT ends
BOSS_BD_TEXT segment byte public 'CODE' use16
@BOSS_BACKDROP_RENDER$QIIC procdesc pascal near \
left_and_top:dword, col:byte
@ -22502,7 +22479,7 @@ public @midboss_reset$qv
@midboss_reset$qv proc far
push bp
mov bp, sp
mov _midboss_invalidate?, offset nullfunc_near
mov _midboss_invalidate, offset nullfunc_near
mov _midboss_render, offset nullfunc_near
setfarfp _midboss_update, nullfunc_far
mov _midboss_active, 0
@ -22522,7 +22499,7 @@ sub_19EE4 proc far
mov ax, _midboss_frames_until
cmp ax, _stage_frame
jnz short loc_19F14
mov _midboss_invalidate?, offset sub_12124
mov _midboss_invalidate, offset @midboss_invalidate_func$qv
mov ax, _midboss_render_func
mov _midboss_render, ax
mov eax, _midboss_update_func

View File

@ -37,7 +37,7 @@ include th05/main/enemy/enemy.inc
extern _execl:proc
extern _strlen:proc
main_01 group SLOWDOWN_TEXT, m_TEXT, EMS_TEXT, ma_TEXT, CFG_LRES_TEXT, mai_TEXT, BOSS_BD_TEXT, BOSS_BG_TEXT, main_TEXT, main__TEXT, PLAYFLD_TEXT, main_0_TEXT, HUD_OVRL_TEXT, DIALOG_TEXT, PLAYER_P_TEXT, main_01_TEXT
main_01 group SLOWDOWN_TEXT, m_TEXT, EMS_TEXT, ma_TEXT, CFG_LRES_TEXT, mai_TEXT, MB_INV_TEXT, BOSS_BD_TEXT, BOSS_BG_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, HUD_HP_TEXT, MB_DFT_TEXT, LASER_SC_TEXT, CHEETO_U_TEXT, IT_SPL_U_TEXT, BULLET_U_TEXT, MIDBOSS1_TEXT, main_034_TEXT, main_035_TEXT, BOSS_6_TEXT, BOSS_X_TEXT, main_036_TEXT, BOSS_TEXT
@ -1542,7 +1542,7 @@ tiles_render proc near
call items_invalidate
call _sparks_invalidate
call pointnums_invalidate
call _midboss_invalidate?
call _midboss_invalidate
call _stage_invalidate
call tiles_redraw_invalidated
pop bp
@ -2782,34 +2782,12 @@ sub_CFEE proc near
sub_CFEE endp
include th04/hardware/grcg_fill_rows.asm
; =============== S U B R O U T I N E =======================================
; Attributes: bp-based frame
sub_D032 proc near
push bp
mov bp, sp
cmp _midboss_phase, PHASE_EXPLODE_BIG
jnb short loc_D04F
mov _tile_invalidate_box.x, 64
mov _tile_invalidate_box.y, 64
pushd [_midboss_pos.prev]
jmp short loc_D060
; ---------------------------------------------------------------------------
loc_D04F:
mov _tile_invalidate_box.x, 128
mov _tile_invalidate_box.y, 128
pushd [_midboss_pos.cur]
loc_D060:
call tiles_invalidate_around
pop bp
retn
sub_D032 endp
mai_TEXT ends
MB_INV_TEXT segment byte public 'CODE' use16
@MIDBOSS_INVALIDATE_FUNC$QV procdesc near
MB_INV_TEXT ends
BOSS_BD_TEXT segment byte public 'CODE' use16
BOSS_BD_TEXT ends
@ -10332,7 +10310,7 @@ public @midboss_reset$qv
@midboss_reset$qv proc far
push bp
mov bp, sp
mov _midboss_invalidate?, offset nullfunc_near
mov _midboss_invalidate, offset nullfunc_near
mov _midboss_render, offset nullfunc_near
setfarfp _midboss_update, nullfunc_far
mov _midboss_hp, 0
@ -10351,7 +10329,7 @@ sub_17322 proc far
mov ax, _midboss_frames_until
cmp ax, _stage_frame
jnz short loc_17352
mov _midboss_invalidate?, offset sub_D032
mov _midboss_invalidate, offset @midboss_invalidate_func$qv
mov ax, _midboss_render_func
mov _midboss_render, ax
mov eax, _midboss_update_func