mirror of https://github.com/nmlgc/ReC98.git
[Decompilation] [th01] Loading and initializing common data used in all stages
Stupid one-off functions deserve stupid names, Part 2. If it only loaded sprites, I might have given it a somewhat better name. Part of P0167, funded by Ember2528.
This commit is contained in:
parent
6e0f9e568a
commit
6e7ab07659
|
@ -55,9 +55,9 @@ typedef StupidBytewiseWrapperAround<struct {
|
|||
// Returns 0 on success, 1 on failure.
|
||||
int scoredat_load();
|
||||
|
||||
// Returns the high score for the difficulty previously loaded by
|
||||
// scoredat_load().
|
||||
uint32_t scoredat_hiscore_get();
|
||||
// Loads only the high score for the current [rank] into the resident
|
||||
// structure.
|
||||
void scoredat_load_hiscore();
|
||||
|
||||
// Sets [str] to the null-terminated name at the given [place] for the
|
||||
// difficulty previously loaded by scoredat_load().
|
||||
|
|
|
@ -91,3 +91,10 @@ public:
|
|||
};
|
||||
|
||||
extern CShootoutLaser shootout_lasers[SHOOTOUT_LASER_COUNT];
|
||||
|
||||
#define shootout_lasers_init(i) { \
|
||||
for(i = 0; i < SHOOTOUT_LASER_COUNT; i++) { \
|
||||
int id = i; \
|
||||
shootout_lasers[i].id = id; \
|
||||
} \
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ class CPlayerAnim {
|
|||
pixel_t h;
|
||||
int bos_image_count;
|
||||
|
||||
public:
|
||||
// Loads all images from the .BOS file with the given [fn] inside the
|
||||
// currently active packfile. Always returns 0.
|
||||
int load(const char fn[PF_FN_LEN]);
|
||||
|
@ -37,7 +38,6 @@ class CPlayerAnim {
|
|||
// multiple of 16 and inside the [-RES_X, RES_X[ range, and is pretty much
|
||||
// broken otherwise.
|
||||
|
||||
public:
|
||||
// Precisely restores pixels according to the alpha mask of [image] from
|
||||
// VRAM page 1, starting at (⌊left/8⌋*8, top).
|
||||
void unput_8(screen_x_t left, vram_y_t top, int image) const;
|
||||
|
|
|
@ -19,3 +19,6 @@ bool16 bomb_update_and_render(int frame);
|
|||
// Returns `true` if an active bomb deals damage to the boss on the current
|
||||
// [frame].
|
||||
bool16 bomb_deals_damage(unsigned long frame);
|
||||
|
||||
// Loads the kuji-in .GRC sprites used at the beginning of the bomb animation.
|
||||
void bomb_kuji_load(void);
|
||||
|
|
|
@ -5,3 +5,8 @@ extern unsigned int stage_timer;
|
|||
// scene_init_and_load().
|
||||
extern char default_grp_fn[15];
|
||||
extern char default_bgm_fn[15];
|
||||
|
||||
// Specifies whether PTN_SLOT_STG contains the full set of sprites required for
|
||||
// card-flipping stages (`false`), or the trimmed-down version for boss stages
|
||||
// (`true`).
|
||||
extern bool ptn_slot_stg_has_reduced_sprites;
|
||||
|
|
|
@ -16,8 +16,18 @@ extern "C" {
|
|||
#include "twobyte.h"
|
||||
#include "th01/hardware/frmdelay.h"
|
||||
#include "th01/hardware/input.hpp"
|
||||
#include "th01/formats/pf.hpp"
|
||||
#include "th01/formats/ptn.hpp"
|
||||
#include "th01/hiscore/scoredat.hpp"
|
||||
#include "th01/main/debug.hpp"
|
||||
#include "th01/main/player/anim.hpp"
|
||||
#include "th01/main/player/bomb.hpp"
|
||||
#include "th01/main/bullet/laser_s.hpp"
|
||||
}
|
||||
#include "th01/main/stage/stages.hpp"
|
||||
#include "th01/main/hud/hud.hpp"
|
||||
#include "th01/shiftjis/fns.hpp"
|
||||
extern "C" {
|
||||
|
||||
extern const char esc_cls[];
|
||||
|
||||
|
@ -199,4 +209,32 @@ void pascal stage_num_animate(unsigned int stage_num)
|
|||
printf(esc_cls);
|
||||
}
|
||||
|
||||
void load_and_init_stuff_used_in_all_stages(void)
|
||||
{
|
||||
extern const char mask_grf[];
|
||||
extern const char miko_ac_bos[];
|
||||
extern const char miko_ac2_bos[];
|
||||
#undef PTN_STG_CARDFLIP_FN
|
||||
extern const char PTN_STG_CARDFLIP_FN[];
|
||||
extern const char miko_ptn[];
|
||||
|
||||
int i;
|
||||
|
||||
scoredat_load_hiscore();
|
||||
hud_bg_load(mask_grf);
|
||||
player_48x48.load(miko_ac_bos);
|
||||
player_48x32.load(miko_ac2_bos);
|
||||
ptn_load(PTN_SLOT_STG, PTN_STG_CARDFLIP_FN);
|
||||
ptn_load(PTN_SLOT_MIKO, miko_ptn);
|
||||
ptn_new(PTN_SLOT_BG_HUD, (PTN_BG_last - PTN_BG_first));
|
||||
/* TODO: Replace with the decompiled call
|
||||
* bomb_kuji_load();
|
||||
* once that function is part of this translation unit */
|
||||
__asm {
|
||||
nop; push cs; call near ptr bomb_kuji_load;
|
||||
}
|
||||
shootout_lasers_init(i);
|
||||
ptn_slot_stg_has_reduced_sprites = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -36,6 +36,8 @@ extern char rank;
|
|||
#define scoredat_close() file_close()
|
||||
#include "th01/hiscore/scorelod.cpp"
|
||||
|
||||
// Returns the high score for the difficulty previously loaded by
|
||||
// scoredat_load().
|
||||
uint32_t scoredat_hiscore_get()
|
||||
{
|
||||
return scoredat_points[0];
|
||||
|
|
|
@ -1,2 +1,4 @@
|
|||
#define MISSILE_FN "boss3_m.ptn"
|
||||
#define SE_FN "zigoku.mde"
|
||||
#define PTN_STG_CARDFLIP_FN "stg.ptn"
|
||||
#define PTN_STG_BOSS_FN "stg_b.ptn"
|
||||
|
|
|
@ -38,13 +38,15 @@ typedef enum {
|
|||
} main_ptn_slot_t;
|
||||
|
||||
typedef enum {
|
||||
// stg(_b).ptn
|
||||
// -----------
|
||||
/// stg(_b).ptn
|
||||
/// -----------
|
||||
PTN_HUD = PTN_ID(PTN_SLOT_STG, 0),
|
||||
PTN_SHOT,
|
||||
PTN_BLAST, // ???
|
||||
PTN_ORB,
|
||||
|
||||
// stg.ptn exclusives
|
||||
// ------------------
|
||||
PTN_CARD_UNUSED = 7,
|
||||
PTN_CARD_3HP, PTN_CARD_3HP_HALF, PTN_CARD_3HP_EDGE,
|
||||
PTN_CARD_2HP, PTN_CARD_2HP_HALF, PTN_CARD_2HP_EDGE,
|
||||
|
@ -66,7 +68,8 @@ typedef enum {
|
|||
|
||||
PTN_ITEM_BOMB,
|
||||
PTN_ITEM_POINT,
|
||||
// -----------
|
||||
// ------------------
|
||||
/// -----------
|
||||
|
||||
// miko.ptn
|
||||
// --------
|
||||
|
@ -95,7 +98,8 @@ typedef enum {
|
|||
// HUD (snapped backgrounds)
|
||||
// -------------------------
|
||||
// The usage code doesn't really cap either of these, though...
|
||||
PTN_BG_LIVES = PTN_ID(PTN_SLOT_BG_HUD, 0),
|
||||
PTN_BG_first = PTN_ID(PTN_SLOT_BG_HUD, 0),
|
||||
PTN_BG_LIVES = PTN_BG_first,
|
||||
PTN_BG_LIVES_last = last_for_quarters(PTN_BG_LIVES, LIVES_MAX),
|
||||
PTN_BG_STAGE,
|
||||
PTN_BG_STAGE_last, // But the original game only need a single quarter?
|
||||
|
@ -114,5 +118,6 @@ typedef enum {
|
|||
PTN_BG_TIMER_last = last_for_quarters(PTN_BG_TIMER, (TIMER_DIGITS / 2)),
|
||||
|
||||
PTN_BG_HP,
|
||||
PTN_BG_last = PTN_ID(PTN_SLOT_BG_HUD, 26)
|
||||
// -------------------------
|
||||
} main_ptn_id_t;
|
||||
|
|
|
@ -125,47 +125,7 @@ main_011_TEXT segment byte public 'CODE' use16
|
|||
extern _input_reset_sense:proc
|
||||
extern TRAM_X16_KANJI_CENTER_REVERSE:proc
|
||||
extern STAGE_NUM_ANIMATE:proc
|
||||
|
||||
; =============== S U B R O U T I N E =======================================
|
||||
|
||||
; Attributes: bp-based frame
|
||||
|
||||
sub_BC87 proc far
|
||||
|
||||
@@i = word ptr -2
|
||||
|
||||
enter 2, 0
|
||||
push si
|
||||
call sub_14BD2
|
||||
call @hud_bg_load$qnxc stdcall, offset aMask_grf, ds
|
||||
call @CPlayerAnim@load$qxnxc stdcall, offset _player_48x48, ds, offset aMiko_ac_bos, ds ; "miko_ac.bos"
|
||||
call @CPlayerAnim@load$qxnxc stdcall, offset _player_48x32, ds, offset aMiko_ac2_bos, ds ; "miko_ac2.bos"
|
||||
call _ptn_load stdcall, PTN_SLOT_STG, offset aStg_ptn, ds ; "stg.ptn"
|
||||
call _ptn_load stdcall, PTN_SLOT_MIKO, offset aMiko_ptn, ds ; "miko.ptn"
|
||||
call _ptn_new stdcall, (26 shl 16) or PTN_SLOT_BG_HUD
|
||||
add sp, 24h
|
||||
nopcall sub_BEB1
|
||||
xor si, si
|
||||
jmp short loc_BCF1
|
||||
; ---------------------------------------------------------------------------
|
||||
|
||||
loc_BCE1:
|
||||
mov [bp+@@i], si
|
||||
mov bx, si
|
||||
imul bx, size CShootoutLaser
|
||||
mov al, byte ptr [bp+@@i]
|
||||
mov _shootout_lasers[bx].SL_id, al
|
||||
inc si
|
||||
|
||||
loc_BCF1:
|
||||
cmp si, SHOOTOUT_LASER_COUNT
|
||||
jl short loc_BCE1
|
||||
mov byte_34AA4, 0
|
||||
pop si
|
||||
leave
|
||||
retf
|
||||
sub_BC87 endp
|
||||
|
||||
extern _load_and_init_stuff_used_in_all_:proc
|
||||
|
||||
; =============== S U B R O U T I N E =======================================
|
||||
|
||||
|
@ -314,8 +274,8 @@ sub_BCFE endp
|
|||
; =============== S U B R O U T I N E =======================================
|
||||
|
||||
; Attributes: bp-based frame
|
||||
|
||||
sub_BEB1 proc far
|
||||
public _bomb_kuji_load
|
||||
_bomb_kuji_load proc far
|
||||
push bp
|
||||
mov bp, sp
|
||||
call _grc_load stdcall, GRC_SLOT_BOMB_KUJI_1, offset aKuzi1_grc, ds
|
||||
|
@ -323,7 +283,7 @@ sub_BEB1 proc far
|
|||
add sp, 0Ch
|
||||
pop bp
|
||||
retf
|
||||
sub_BEB1 endp
|
||||
_bomb_kuji_load endp
|
||||
|
||||
|
||||
; =============== S U B R O U T I N E =======================================
|
||||
|
@ -2536,7 +2496,7 @@ loc_D795:
|
|||
call _coreleft
|
||||
mov word ptr dword_36C1A+2, dx
|
||||
mov word ptr dword_36C1A, ax
|
||||
call sub_BC87
|
||||
call _load_and_init_stuff_used_in_all_
|
||||
call _z_graph_init
|
||||
push 0
|
||||
call _graph_accesspage_func
|
||||
|
@ -2756,22 +2716,22 @@ loc_D9CA:
|
|||
mov _first_stage_in_scene, 1
|
||||
call @items_bomb_reset$qv
|
||||
call @items_point_reset$qv
|
||||
cmp byte_34AA4, 0
|
||||
cmp _ptn_slot_stg_has_reduced_sprites, 0
|
||||
jnz short loc_DA2A
|
||||
call _ptn_free stdcall, PTN_SLOT_STG
|
||||
pop cx
|
||||
call _ptn_load c, PTN_SLOT_STG, offset aStg_b_ptn, ds ; "stg_b.ptn"
|
||||
mov byte_34AA4, 1
|
||||
mov _ptn_slot_stg_has_reduced_sprites, 1
|
||||
jmp short loc_DA2A
|
||||
; ---------------------------------------------------------------------------
|
||||
|
||||
loc_DA06:
|
||||
cmp byte_34AA4, 0
|
||||
cmp _ptn_slot_stg_has_reduced_sprites, 0
|
||||
jz short loc_DA2A
|
||||
call _ptn_free stdcall, PTN_SLOT_STG
|
||||
pop cx
|
||||
call _ptn_load c, PTN_SLOT_STG, offset aStg_ptn, ds ; "stg.ptn"
|
||||
mov byte_34AA4, 0
|
||||
call _ptn_load c, PTN_SLOT_STG, offset _PTN_STG_CARDFLIP_FN, ds ; "stg.ptn"
|
||||
mov _ptn_slot_stg_has_reduced_sprites, 0
|
||||
jmp short $+2
|
||||
|
||||
loc_DA2A:
|
||||
|
@ -3567,7 +3527,6 @@ SHARED ends
|
|||
|
||||
; Segment type: Pure code
|
||||
PTN_GRP_GRZ segment byte public 'CODE' use16
|
||||
extern _ptn_new:proc
|
||||
extern _ptn_load:proc
|
||||
extern _ptn_free:proc
|
||||
extern _grp_palette_load_show_sane:proc
|
||||
|
@ -5824,8 +5783,8 @@ main_19__TEXT segment byte public 'CODE' use16
|
|||
; =============== S U B R O U T I N E =======================================
|
||||
|
||||
; Attributes: bp-based frame
|
||||
|
||||
sub_14BD2 proc far
|
||||
public _scoredat_load_hiscore
|
||||
_scoredat_load_hiscore proc far
|
||||
push bp
|
||||
mov bp, sp
|
||||
call main_19:_scoredat_load
|
||||
|
@ -5839,7 +5798,7 @@ sub_14BD2 proc far
|
|||
call _scoredat_free
|
||||
pop bp
|
||||
retf
|
||||
sub_14BD2 endp
|
||||
_scoredat_load_hiscore endp
|
||||
|
||||
main_19__TEXT ends
|
||||
|
||||
|
@ -5847,7 +5806,6 @@ main_19__TEXT ends
|
|||
|
||||
; Segment type: Pure code
|
||||
main_20_TEXT segment byte public 'CODE' use16
|
||||
extern @CPlayerAnim@load$qxnxc:proc
|
||||
main_20_TEXT ends
|
||||
|
||||
; ===========================================================================
|
||||
|
@ -5980,7 +5938,6 @@ main_24_TEXT ends
|
|||
; Segment type: Pure code
|
||||
main_25_TEXT segment byte public 'CODE' use16
|
||||
extern @hud_score_and_cardcombo_render$qv:proc
|
||||
extern @hud_bg_load$qnxc:proc
|
||||
extern @hud_lives_put$qi:proc
|
||||
extern @hud_bg_snap_and_put$qv:proc
|
||||
main_25_TEXT ends
|
||||
|
@ -30217,7 +30174,8 @@ _orb_prev_left dw ORB_LEFT_START
|
|||
_orb_prev_top dw ORB_TOP_START
|
||||
word_34A92 dw 0
|
||||
include th01/main/player/orb[data].asm
|
||||
byte_34AA4 db 0
|
||||
public _ptn_slot_stg_has_reduced_sprites
|
||||
_ptn_slot_stg_has_reduced_sprites db 0
|
||||
unk_34AA5 db 0Fh
|
||||
db 0Fh
|
||||
db 0Fh
|
||||
|
@ -30277,11 +30235,12 @@ aHard db 'HARD',0
|
|||
aLunatic db 'LUNATIC',0
|
||||
public _esc_cls
|
||||
_esc_cls db 1Bh,'*',0
|
||||
aMask_grf db 'mask.grf',0
|
||||
aMiko_ac_bos db 'miko_ac.bos',0
|
||||
aMiko_ac2_bos db 'miko_ac2.bos',0
|
||||
aStg_ptn db 'stg.ptn',0
|
||||
aMiko_ptn db 'miko.ptn',0
|
||||
public _mask_grf, _miko_ac_bos, _miko_ac2_bos, _PTN_STG_CARDFLIP_FN, _miko_ptn
|
||||
_mask_grf db 'mask.grf',0
|
||||
_miko_ac_bos db 'miko_ac.bos',0
|
||||
_miko_ac2_bos db 'miko_ac2.bos',0
|
||||
_PTN_STG_CARDFLIP_FN db 'stg.ptn',0
|
||||
_miko_ptn db 'miko.ptn',0
|
||||
_esc_color_bg_black_fg_black db 1Bh,'[16;40m',0
|
||||
_esc_cursor_to_x0_y0 db 1Bh,'[0;0H',0
|
||||
_space db ' ',0
|
||||
|
|
Loading…
Reference in New Issue