[Decompilation] [th01] YuugenMagan: Sprite loading and initial variables

Doing this one now allows us to completely get rid of a bunch of ASM
land declations…

Part of P0202, funded by [Anonymous] and Yanga.
This commit is contained in:
nmlgc 2022-06-21 19:39:02 +02:00
parent 988cf64bf3
commit 3f52d9a16f
8 changed files with 161 additions and 214 deletions

View File

@ -48,7 +48,7 @@ bin\th01\op.exe: bin\piloadc.obj bin\th01\op.obj th01\op_01.cpp bin\th01\frmdela
$**
|
bin\th01\reiiden.exe: bin\piloadc.obj bin\th01\reiiden.obj th01\main_010.cpp th01\main_011.cpp th01\main_012.cpp bin\th01\frmdelay.obj bin\th01\vsync.obj bin\th01\ztext.obj bin\th01\initexit.obj bin\th01\graph.obj bin\th01\ptn_0to1.obj bin\th01\vplanset.obj th01\main_07.cpp bin\th01\ptn.obj th01\main_08.cpp bin\th01\grz.obj th01\main_09.cpp th01\grpinv32.cpp bin\th01\resstuff.obj th01\scrollup.cpp th01\egcrows.cpp th01\pgtrans.cpp th01\2x_main.cpp th01\egcwave.cpp th01\grph1to0.cpp th01\main_14.cpp th01\main_15.cpp bin\th01\mdrv2.obj th01\main_17.cpp th01\main_19.cpp th01\main_20.cpp th01\main_21.cpp th01\main_23.cpp th01\main_24.cpp th01\main_25.cpp th01\main_26.cpp th01\main_27.cpp th01\main_29.cpp th01\main_30.cpp th01\main_31.cpp th01\main_32.cpp th01\main_32_.cpp th01\main_33.cpp th01\main_34.cpp th01\main_35.cpp th01\main_36.cpp th01\main_37.cpp th01\main_38.cpp
bin\th01\reiiden.exe: bin\piloadc.obj bin\th01\reiiden.obj th01\main_010.cpp th01\main_011.cpp th01\main_012.cpp bin\th01\frmdelay.obj bin\th01\vsync.obj bin\th01\ztext.obj bin\th01\initexit.obj bin\th01\graph.obj bin\th01\ptn_0to1.obj bin\th01\vplanset.obj th01\main_07.cpp bin\th01\ptn.obj th01\main_08.cpp bin\th01\grz.obj th01\main_09.cpp th01\grpinv32.cpp bin\th01\resstuff.obj th01\scrollup.cpp th01\egcrows.cpp th01\pgtrans.cpp th01\2x_main.cpp th01\egcwave.cpp th01\grph1to0.cpp th01\main_14.cpp th01\main_15.cpp bin\th01\mdrv2.obj th01\main_17.cpp th01\main_19.cpp th01\main_20.cpp th01\main_21.cpp th01\main_23.cpp th01\main_24.cpp th01\main_25.cpp th01\main_26.cpp th01\main_27.cpp th01\main_28.cpp th01\main_29.cpp th01\main_30.cpp th01\main_31.cpp th01\main_32.cpp th01\main_32_.cpp th01\main_33.cpp th01\main_34.cpp th01\main_35.cpp th01\main_36.cpp th01\main_37.cpp th01\main_38.cpp
$(CC) $(CFLAGS) $(LARGE_LFLAGS) -3 -Z -d -DGAME=1 -DBINARY='M' -nbin\th01\ -eREIIDEN.EXE @&&|
$**
|

View File

@ -1,11 +1,32 @@
/// Makai Stage 10 Boss - YuugenMagan
/// ---------------------------------
#include <stddef.h>
#include "platform.h"
#include "pc98.h"
#include "planar.h"
#include "th01/v_colors.hpp"
#include "th01/math/area.hpp"
#include "th01/math/subpixel.hpp"
#include "th01/hardware/palette.h"
#include "th01/shiftjis/fns.hpp"
#undef MISSILE_FN
#define MISSILE_FN boss3_m_ptn
extern const char MISSILE_FN[];
#include "th01/main/vars.hpp"
extern "C" {
#include "th01/formats/grp.h"
}
#include "th01/formats/pf.hpp"
#include "th01/formats/ptn.hpp"
#include "th01/main/particle.hpp"
#include "th01/main/playfld.hpp"
#include "th01/main/boss/boss.hpp"
#include "th01/main/boss/entity_a.hpp"
#include "th01/main/boss/palette.hpp"
#include "th01/main/bullet/missile.hpp"
#include "th01/main/hud/hp.hpp"
#include "th01/main/player/orb.hpp"
#define flash_colors yuugenmagan_flash_colors
#define invincible yuugenmagan_invincible
@ -15,8 +36,118 @@ extern bool16 invincible;
extern int invincibility_frame;
extern bool initial_hp_rendered;
// Always denotes the last phase that ends with that amount of HP.
enum yuugenmagan_hp_t {
HP_TOTAL = 16,
PHASE_3_END_HP = 12,
PHASE_7_END_HP = 8,
};
// Entities
// --------
static const int EYE_COUNT = 5;
static const pixel_t EYE_W = 64;
static const pixel_t EYE_H = 48;
static const pixel_t EYE_HITBOX_LEFT = (-4 + ORB_HITBOX_W);
static const pixel_t EYE_HITBOX_TOP = (-4 + ORB_HITBOX_W);
static const pixel_t EYE_HITBOX_RIGHT = (EYE_W + 4 - ORB_HITBOX_W);
static const pixel_t EYE_HITBOX_BOTTOM = (EYE_H - ORB_HITBOX_H);
enum yuugenmagan_cel_t {
C_HIDDEN = 0,
};
enum yuugenmagan_eye_t {
E_WEST = 0,
E_EAST = 1,
E_SOUTHWEST = 2,
E_SOUTHEAST = 3,
E_NORTH = 4,
};
#define eyes reinterpret_cast<CBossEntitySized<EYE_W, EYE_H> *>(boss_entities)
inline void yuugenmagan_ent_load(void) {
extern const char boss2_bos[];
eyes[0].load(boss2_bos, 0);
eyes[1].metadata_assign(eyes[0]);
eyes[2].metadata_assign(eyes[0]);
eyes[3].metadata_assign(eyes[0]);
eyes[4].metadata_assign(eyes[0]);
}
// --------
// .PTN
// ----
static const main_ptn_slot_t PTN_SLOT_MISSILE = PTN_SLOT_BOSS_1;
// ----
void yuugenmagan_load(void)
{
yuugenmagan_ent_load();
void yuugenmagan_setup(void);
yuugenmagan_setup();
Missiles.load(PTN_SLOT_MISSILE);
Missiles.reset();
}
void yuugenmagan_setup(void)
{
extern const char boss2_grp[];
int col;
int comp;
grp_palette_load_show(boss2_grp);
boss_palette_snap();
// MODDERS: Loop over all eyes instead.
eyes[0].set_image(C_HIDDEN);
eyes[1].set_image(C_HIDDEN);
eyes[2].set_image(C_HIDDEN);
eyes[3].set_image(C_HIDDEN);
eyes[4].set_image(C_HIDDEN);
palette_copy(boss_post_defeat_palette, z_Palettes, col, comp);
// These exactly correspond to the yellow boxes in BOSS2.GRP.
eyes[ E_WEST].pos_set( 64, 128);
eyes[ E_EAST].pos_set(512, 128);
eyes[E_SOUTHWEST].pos_set(192, 176);
eyes[E_SOUTHEAST].pos_set(384, 176);
eyes[ E_NORTH].pos_set(288, 64);
// MODDERS: Loop over all eyes instead.
eyes[0].hitbox_set(
EYE_HITBOX_LEFT, EYE_HITBOX_TOP, EYE_HITBOX_RIGHT, EYE_HITBOX_BOTTOM
);
eyes[1].hitbox_set(
EYE_HITBOX_LEFT, EYE_HITBOX_TOP, EYE_HITBOX_RIGHT, EYE_HITBOX_BOTTOM
);
eyes[2].hitbox_set(
EYE_HITBOX_LEFT, EYE_HITBOX_TOP, EYE_HITBOX_RIGHT, EYE_HITBOX_BOTTOM
);
eyes[3].hitbox_set(
EYE_HITBOX_LEFT, EYE_HITBOX_TOP, EYE_HITBOX_RIGHT, EYE_HITBOX_BOTTOM
);
eyes[4].hitbox_set(
EYE_HITBOX_LEFT, EYE_HITBOX_TOP, EYE_HITBOX_RIGHT, EYE_HITBOX_BOTTOM
);
eyes[0].hitbox_orb_inactive = true;
eyes[1].hitbox_orb_inactive = true;
eyes[2].hitbox_orb_inactive = true;
eyes[3].hitbox_orb_inactive = true;
eyes[4].hitbox_orb_inactive = true;
boss_phase_frame = 0;
boss_phase = 0;
boss_hp = HP_TOTAL;
hud_hp_first_white = PHASE_3_END_HP;
hud_hp_first_redwhite = PHASE_7_END_HP;
// (redundant, no particles are shown in this fight)
particles_unput_update_render(PO_INITIALIZE, V_WHITE);
}

View File

@ -61,6 +61,8 @@ void singyoku_main(void);
void singyoku_free(void);
// Makai
void yuugenmagan_load(void);
void elis_load(void);
void elis_main(void);
void elis_free(void);

View File

@ -579,11 +579,6 @@ void CBossEntity::move_lock_and_put_8(
}
}
static const pixel_t ORB_HITBOX_LEFT = ((ORB_W / 2) - (ORB_W / 4));
static const pixel_t ORB_HITBOX_TOP = ((ORB_H / 2) - (ORB_H / 4));
static const pixel_t ORB_HITBOX_RIGHT = ((ORB_W / 2) + (ORB_W / 4));
static const pixel_t ORB_HITBOX_BOTTOM = ((ORB_H / 2) + (ORB_H / 4));
bool16 CBossEntity::hittest_orb(void) const
{
if(hitbox_orb_inactive == true) {

View File

@ -21,60 +21,7 @@ CBossEntity struc
BE_bos_slot db ?
CBossEntity ends
copy16 macro dst:req, src:req, member:req
mov ax, src.member
mov dst.member, ax
endm
copy8 macro dst:req, src:req, member:req
mov al, src.member
mov dst.member, al
endm
area_t__copy macro dst:req, src:req
copy16 dst, src, A_left
copy16 dst, src, A_right
copy16 dst, src, A_top
copy16 dst, src, A_bottom
endm
CBossEntity__ctor macro that:req
mov that.BE_loading, 0
mov that.BE_zero_3, 0
endm
CBossEntity__copy macro dst:req, src:req
copy16 dst, src, BE_cur_left
copy16 dst, src, BE_cur_top
copy16 dst, src, BE_prev_left
copy16 dst, src, BE_prev_top
copy16 dst, src, BE_vram_w
copy16 dst, src, BE_h
area_t__copy dst.BE_move_clamp, src.BE_move_clamp
area_t__copy dst.BE_hitbox_orb, src.BE_hitbox_orb
copy16 dst, src, BE_prev_delta_y
copy16 dst, src, BE_prev_delta_x
copy16 dst, src, BE_bos_image_count
copy16 dst, src, BE_zero_1
copy16 dst, src, BE_bos_image
copy16 dst, src, BE_unknown
copy16 dst, src, BE_hitbox_orb_inactive
copy16 dst, src, BE_loading
copy16 dst, src, BE_move_lock_frame
copy16 dst, src, BE_zero_2
copy8 dst, src, BE_zero_3
copy8 dst, src, BE_bos_slot
endm
CBossEntity__load macro that:req, slot:req, fn:req
mov that.BE_loading, 1
call @CBossEntity@load_inner$qxnxci stdcall, offset that, ds, offset fn, ds, slot
mov that.BE_loading, 0
endm
CBossEntity__hitbox_set macro that:req, left:req, top:req, right:req, bottom:req
mov that.BE_hitbox_orb.A_left, left
mov that.BE_hitbox_orb.A_right, right
mov that.BE_hitbox_orb.A_top, top
mov that.BE_hitbox_orb.A_bottom, bottom
endm

View File

@ -1,6 +1,14 @@
static const pixel_t ORB_W = 32;
static const pixel_t ORB_H = 32;
static const pixel_t ORB_HITBOX_W = (ORB_W / 2);
static const pixel_t ORB_HITBOX_H = (ORB_W / 2);
static const pixel_t ORB_HITBOX_LEFT = ((ORB_W / 2) - (ORB_HITBOX_W / 2));
static const pixel_t ORB_HITBOX_TOP = ((ORB_H / 2) - (ORB_HITBOX_H / 2));
static const pixel_t ORB_HITBOX_RIGHT = ((ORB_W / 2) + (ORB_HITBOX_W / 2));
static const pixel_t ORB_HITBOX_BOTTOM = ((ORB_H / 2) + (ORB_HITBOX_H / 2));
static const screen_x_t ORB_LEFT_MIN = (PLAYFIELD_LEFT);
static const screen_x_t ORB_LEFT_MAX = (PLAYFIELD_RIGHT - ORB_W);
static const screen_y_t ORB_TOP_MIN = (PLAYFIELD_TOP);

6
th01/main_28.cpp Normal file
View File

@ -0,0 +1,6 @@
/* ReC98
* -----
* Code segment #28 of TH01's REIIDEN.EXE
*/
#include "th01/main/boss/b10m.cpp"

View File

@ -63,6 +63,7 @@ main_01 group main_010_TEXT, main_011_TEXT, main_012_TEXT, main_013_TEXT
main_15 group main_15_TEXT, main_15__TEXT
main_19 group main_19_TEXT, main_19__TEXT
main_21 group main_21_TEXT, main_21__TEXT
main_28 group main_28_TEXT, main_28__TEXT
main_29 group main_29_TEXT, main_29__TEXT
main_31 group main_31_TEXT, main_31__TEXT
main_32 group main_32_TEXT, main_32__TEXT
@ -2449,7 +2450,7 @@ loc_D89B:
pushd [bp+s1] ; dest
call _strcpy
add sp, 8
call _yuugenmagan_load
call @yuugenmagan_load$qv
jmp loc_D96D
; ---------------------------------------------------------------------------
@ -5059,7 +5060,6 @@ main_21_TEXT segment byte public 'CODE' use16
extern @CBossEntity@load_inner$qxnxci:proc
extern @CBossEntity@metadata_get$xqmimuct1t1:proc
extern @CBossEntity@put_8$xqiii:proc
extern @CBossEntity@pos_set$qiiiiiii:proc
extern @CBossEntity@move_lock_unput_and_put_8$qiiii:proc
extern @CBossEntity@hittest_orb$xqv:proc
extern @bos_entity_free$qi:proc
@ -5199,9 +5199,13 @@ main_27_TEXT ends
; ===========================================================================
; Segment type: Pure code
main_28_TEXT segment byte public 'CODE' use16
assume cs:main_28_TEXT
extern @yuugenmagan_load$qv:proc
main_28_TEXT ends
; Segment type: Pure code
main_28__TEXT segment byte public 'CODE' use16
assume cs:main_28
;org 0Fh
assume es:nothing, ss:nothing, ds:_DATA, fs:nothing, gs:nothing
@ -5218,152 +5222,6 @@ eye_north equ <boss_entity_4>
PTN_SLOT_MISSILE = PTN_SLOT_BOSS_1
; =============== S U B R O U T I N E =======================================
; Attributes: bp-based frame
public _yuugenmagan_load
_yuugenmagan_load proc c
local @@template_east:CBossEntity
local @@template_southwest:CBossEntity
local @@template_southeast:CBossEntity
local @@template_north:CBossEntity
CBossEntity__load eye_west, 0, aBoss2_bos
CBossEntity__copy @@template_east, eye_west
push ds
push offset eye_east.BE_h
push ds
push offset eye_east.BE_vram_w
push ds
push offset eye_east.BE_bos_slot
push ds
push offset eye_east.BE_bos_image_count
push ss
lea ax, @@template_east
push ax
call @CBossEntity@metadata_get$xqmimuct1t1
CBossEntity__copy @@template_southwest, eye_west
push ds
push offset eye_southwest.BE_h
push ds
push offset eye_southwest.BE_vram_w
push ds
push offset eye_southwest.BE_bos_slot
push ds
push offset eye_southwest.BE_bos_image_count
push ss
lea ax, @@template_southwest
push ax
call @CBossEntity@metadata_get$xqmimuct1t1
add sp, 32h
CBossEntity__copy @@template_southeast, eye_west
push ds
push offset eye_southeast.BE_h
push ds
push offset eye_southeast.BE_vram_w
push ds
push offset eye_southeast.BE_bos_slot
push ds
push offset eye_southeast.BE_bos_image_count
push ss
lea ax, @@template_southeast
push ax
call @CBossEntity@metadata_get$xqmimuct1t1
CBossEntity__copy @@template_north, eye_west
push ds
push offset eye_north.BE_h
push ds
push offset eye_north.BE_vram_w
push ds
push offset eye_north.BE_bos_slot
push ds
push offset eye_north.BE_bos_image_count
push ss
lea ax, @@template_north
push ax
call @CBossEntity@metadata_get$xqmimuct1t1
nopcall sub_1B383
call @ptn_load$q15main_ptn_slot_tnxc stdcall, PTN_SLOT_MISSILE, offset aBoss3_m_ptn, ds ; "boss3_m.ptn"
mov _Missiles.MISSILE_ptn_id_base, (PTN_SLOT_MISSILE * PTN_IMAGES_PER_SLOT)
call @CMissiles@reset$qv stdcall, offset _Missiles, ds
add sp, 32h
ret
_yuugenmagan_load endp
; =============== S U B R O U T I N E =======================================
; Attributes: bp-based frame
sub_1B383 proc far
push bp
mov bp, sp
push si
push di
call _grp_palette_load_show c, offset aBoss2_grp_0, ds ; "boss2.grp"
call @boss_palette_snap$qv
mov eye_0.BE_bos_image, 0
mov eye_1.BE_bos_image, 0
mov eye_2.BE_bos_image, 0
mov eye_3.BE_bos_image, 0
mov eye_4.BE_bos_image, 0
xor si, si
jmp short loc_1B3D8
; ---------------------------------------------------------------------------
loc_1B3BB:
xor di, di
jmp short loc_1B3D2
; ---------------------------------------------------------------------------
loc_1B3BF:
mov bx, si
imul bx, size rgb_t
mov al, _z_Palettes[bx+di]
mov bx, si
imul bx, size rgb_t
mov byte ptr _boss_post_defeat_palette[bx+di], al
inc di
loc_1B3D2:
cmp di, size rgb_t
jl short loc_1B3BF
inc si
loc_1B3D8:
cmp si, COLOR_COUNT
jl short loc_1B3BB
call @CBossEntity@pos_set$qiiiiiii stdcall, offset eye_west, ds, 64, large 128 or (48 shl 16), large 0 or (736 shl 16), large 64 or (304 shl 16)
call @CBossEntity@pos_set$qiiiiiii stdcall, offset eye_east, ds, 512, large 128 or (48 shl 16), large 0 or (736 shl 16), large 64 or (304 shl 16)
add sp, 24h
call @CBossEntity@pos_set$qiiiiiii stdcall, offset eye_southwest, ds, 192, large 176 or (48 shl 16), large 0 or (736 shl 16), large 64 or (304 shl 16)
call @CBossEntity@pos_set$qiiiiiii stdcall, offset eye_southeast, ds, 384, large 176 or (48 shl 16), large 0 or (736 shl 16), large 64 or (304 shl 16)
add sp, 24h
call @CBossEntity@pos_set$qiiiiiii stdcall, offset eye_north, ds, 288, large 64 or (48 shl 16), large 0 or (736 shl 16), large 64 or (304 shl 16)
CBossEntity__hitbox_set eye_0, 12, 12, 52, 32
CBossEntity__hitbox_set eye_1, 12, 12, 52, 32
CBossEntity__hitbox_set eye_2, 12, 12, 52, 32
CBossEntity__hitbox_set eye_3, 12, 12, 52, 32
CBossEntity__hitbox_set eye_4, 12, 12, 52, 32
mov eye_0.BE_hitbox_orb_inactive, 1
mov eye_1.BE_hitbox_orb_inactive, 1
mov eye_2.BE_hitbox_orb_inactive, 1
mov eye_3.BE_hitbox_orb_inactive, 1
mov eye_4.BE_hitbox_orb_inactive, 1
mov _boss_phase_frame, 0
mov _boss_phase, 0
mov _boss_hp, 16
mov _hud_hp_first_white, 12
mov _hud_hp_first_redwhite, 8
call @particles_unput_update_render$q17particle_origin_ti stdcall, large PO_INITIALIZE or (V_WHITE shl 16)
add sp, 16h
pop di
pop si
pop bp
retf
sub_1B383 endp
; =============== S U B R O U T I N E =======================================
; Attributes: bp-based frame
@ -9516,7 +9374,7 @@ eye_1 equ <>
eye_2 equ <>
eye_3 equ <>
eye_4 equ <>
main_28_TEXT ends
main_28__TEXT ends
; ===========================================================================
@ -13449,9 +13307,10 @@ _ORB_FORCE_REPEL_CONSTANT dq -10.0
public _yuugenmagan_invincibility_flash_colors, _yuugenmagan_invincible
_yuugenmagan_invincibility_flash_colors db 1, 11
_yuugenmagan_invincible dw 0
aBoss2_bos db 'boss2.bos',0
aBoss3_m_ptn db 'boss3_m.ptn',0
aBoss2_grp_0 db 'boss2.grp',0
public _boss2_bos, _boss3_m_ptn, _boss2_grp
_boss2_bos db 'boss2.bos',0
_boss3_m_ptn db 'boss3_m.ptn',0
_boss2_grp db 'boss2.grp',0
flt_35B76 dd 2.0
public _mima_meteor_active
_mima_meteor_active db 1
@ -13820,7 +13679,6 @@ _hud_hp_first_redwhite dw ?
PARTICLE_COUNT = 40
PO_TOP_RIGHT = 1
PO_INITIALIZE = 255
public _particles_spawn_interval, _particles_velocity_base_max, _particles_x
public _particles_y, _particles_velocity_x, _particles_velocity_y
public _particles_alive, _particles_velocity_base, _particles_spawn_cycle