[Decompilation] [th04] Extra unlock / High Score sprite loading

Part of P0298, funded by [Anonymous], Blue Bolt, and Splashman.
This commit is contained in:
nmlgc 2024-11-30 04:27:56 +01:00
parent 495205e16a
commit 840aedebf6
7 changed files with 86 additions and 161 deletions

View File

@ -905,7 +905,6 @@ th05:branch(MODEL_LARGE, { cflags = "-DBINARY='O'" }):link("op", {
"th05/score_e.cpp",
"th05/hi_view.cpp",
"th05_op.asm",
"th05/hi_view_.cpp",
"th05/m_char.cpp",
})
th05:branch(MODEL_LARGE, { cflags = "-DBINARY='M'" }):link("main", {

View File

@ -197,7 +197,7 @@ tlink @obj\th05\memchk.@l
echo 5 -O -I -S -G -M libs/kaja/ongchk.com bin/th05/zuninit.com bin/th05/res_kso.com bin/th05/gjinit.com bin/th05/memchk.com>obj\th05\zuncom.@z
bin\Pipeline\zungen.com obj/Pipeline/zun_stub.bin obj\th05\zuncom.@z obj/th05/zuncom.bin
bin\Pipeline\comcstm.com th05/zun.txt obj/th05/zuncom.bin obj/Pipeline/cstmstub.bin 628731748 bin/th05/zun.com
echo -c -I. -O -b- -3 -Z -d -DGAME=5 -ml -DBINARY='O' -nobj/th05/ th05/op_main.cpp th05/vector.cpp th05/musicp_c.cpp th05/snd_load.cpp th05/snd_kaja.cpp th05/pi_cpp_1.cpp th05/pi_cpp_2.cpp th05/initop.cpp th05/inp_h_w.cpp th05/snd_dlym.cpp th05/cdg_p_nc.cpp th05/frmdelay.cpp th05/egcrect.cpp th05/op_setup.cpp th05/cfg.cpp th05/op_title.cpp th05/op_music.cpp th05/score_db.cpp th05/score_e.cpp th05/hi_view.cpp th05/hi_view_.cpp th05/m_char.cpp>obj\batch018.@c
echo -c -I. -O -b- -3 -Z -d -DGAME=5 -ml -DBINARY='O' -nobj/th05/ th05/op_main.cpp th05/vector.cpp th05/musicp_c.cpp th05/snd_load.cpp th05/snd_kaja.cpp th05/pi_cpp_1.cpp th05/pi_cpp_2.cpp th05/initop.cpp th05/inp_h_w.cpp th05/snd_dlym.cpp th05/cdg_p_nc.cpp th05/frmdelay.cpp th05/egcrect.cpp th05/op_setup.cpp th05/cfg.cpp th05/op_title.cpp th05/op_music.cpp th05/score_db.cpp th05/score_e.cpp th05/hi_view.cpp th05/m_char.cpp>obj\batch018.@c
tcc @obj/batch018.@c
tasm32 /m /mx /kh32768 /t /dGAME=5 th05_op_master.asm obj\th05\opm.obj
tasm32 /m /mx /kh32768 /t /dGAME=5 th05_op2.asm obj\th05\op2.obj
@ -208,7 +208,7 @@ tasm32 /m /mx /kh32768 /t /dGAME=5 th05\pi_asm_1.asm obj\th05\pi_asm_1.obj
tasm32 /m /mx /kh32768 /t /dGAME=5 th05\pi_asm_2.asm obj\th05\pi_asm_2.obj
tasm32 /m /mx /kh32768 /t /dGAME=5 th05\input_s.asm obj\th05\input_s.obj
tasm32 /m /mx /kh32768 /t /dGAME=5 th05_op.asm obj\th05\op.obj
echo -c -s -E c0l.obj obj\th05\op_main.obj obj\th05\opm.obj obj\th03\hfliplut.obj obj\th04\snd_pmdr.obj obj\th04\snd_mmdr.obj obj\th04\snd_mode.obj obj\th02\exit_dos.obj obj\th04\grppsafx.obj obj\th05\op2.obj obj\th04\cdg_p_na.obj obj\th02\snd_se_r.obj obj\th04\snd_se.obj obj\th04\bgimage.obj obj\th05\cdg_put.obj obj\th04\exit.obj obj\th05\vector.obj obj\th05\musicp_c.obj obj\th05\musicp_a.obj obj\th05\bgimager.obj obj\th05\snd_load.obj obj\th05\snd_kaja.obj obj\th05\pi_cpp_1.obj obj\th05\pi_asm_1.obj obj\th05\pi_cpp_2.obj obj\th05\pi_asm_2.obj obj\th05\initop.obj obj\th05\input_s.obj obj\th05\inp_h_w.obj obj\th05\snd_dlym.obj obj\th05\cdg_p_nc.obj obj\th05\frmdelay.obj obj\th04\cdg_load.obj obj\th05\egcrect.obj obj\th05\op_setup.obj obj\th04\zunsoft.obj obj\th05\cfg.obj obj\th05\op_title.obj obj\th05\op_music.obj obj\th05\score_db.obj obj\th05\score_e.obj obj\th05\hi_view.obj obj\th05\op.obj obj\th05\hi_view_.obj obj\th05\m_char.obj, bin\th05\op.exe, obj\th05\op.map, emu.lib mathl.lib cl.lib>obj\th05\op.@l
echo -c -s -E c0l.obj obj\th05\op_main.obj obj\th05\opm.obj obj\th03\hfliplut.obj obj\th04\snd_pmdr.obj obj\th04\snd_mmdr.obj obj\th04\snd_mode.obj obj\th02\exit_dos.obj obj\th04\grppsafx.obj obj\th05\op2.obj obj\th04\cdg_p_na.obj obj\th02\snd_se_r.obj obj\th04\snd_se.obj obj\th04\bgimage.obj obj\th05\cdg_put.obj obj\th04\exit.obj obj\th05\vector.obj obj\th05\musicp_c.obj obj\th05\musicp_a.obj obj\th05\bgimager.obj obj\th05\snd_load.obj obj\th05\snd_kaja.obj obj\th05\pi_cpp_1.obj obj\th05\pi_asm_1.obj obj\th05\pi_cpp_2.obj obj\th05\pi_asm_2.obj obj\th05\initop.obj obj\th05\input_s.obj obj\th05\inp_h_w.obj obj\th05\snd_dlym.obj obj\th05\cdg_p_nc.obj obj\th05\frmdelay.obj obj\th04\cdg_load.obj obj\th05\egcrect.obj obj\th05\op_setup.obj obj\th04\zunsoft.obj obj\th05\cfg.obj obj\th05\op_title.obj obj\th05\op_music.obj obj\th05\score_db.obj obj\th05\score_e.obj obj\th05\hi_view.obj obj\th05\op.obj obj\th05\m_char.obj, bin\th05\op.exe, obj\th05\op.map, emu.lib mathl.lib cl.lib>obj\th05\op.@l
tlink @obj\th05\op.@l
tasm32 /m /mx /kh32768 /t /dGAME=5 th05_main.asm obj\th05\main.obj
echo -c -I. -O -b- -3 -Z -d -DGAME=5 -ml -DBINARY='M' -nobj/th05/ th05/demo.cpp th05/ems.cpp th05/cfg_lres.cpp th05/main010.cpp th05/f_dialog.cpp th05/dialog.cpp th05/boss_exp.cpp th05/playfld.cpp 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 th05/midboss5.cpp th05/hud_ovrl.cpp th05/bullet_p.cpp th05/player_a.cpp th05/bullet_c.cpp th05/bullet_t.cpp th05/initmain.cpp th05/gather.cpp th05/main032.cpp>obj\batch019.@c

View File

@ -1,12 +0,0 @@
public _hi, _hi2
if GAME eq 4
public _hi_reimu, _hi_marisa
_hi_reimu label scoredat_section_t
_hi scoredat_section_t <?>
_hi_marisa label scoredat_section_t
_hi2 scoredat_section_t <?>
else
_hi scoredat_section_t <?>
_hi2 scoredat_section_t <?>
endif
_scoredat_unused db ?

View File

@ -81,6 +81,21 @@ static const screen_x_t RANK_LEFT = (RES_X - GLYPH_FULL_W - RANK_W);
static const screen_y_t RANK_TOP = (RES_Y - (GLYPH_H / 2) - GLYPH_H);
/// -----------
/// State
/// -----
scoredat_section_t hi;
scoredat_section_t hi2;
static uint8_t scoredat_unused; // ZUN bloat
unsigned char rank;
unsigned char cleared_with[PLAYCHAR_COUNT][RANK_COUNT];
bool extra_unlocked;
#if (GAME == 4)
int8_t unused[48]; // ZUN bloat
#endif
/// -----
// ZUN bloat: The main difference between the TH04 and TH05 implementations is
// that TH04 explicitly spells out its two characters while TH05 sanely loops
// over its four. The `debloated` branch would also migrate TH04 to loops.
@ -428,3 +443,71 @@ void near regist_view_menu(void)
snd_load(BGM_MENU_MAIN_FN, SND_LOAD_SONG);
snd_kaja_func(KAJA_SONG_PLAY, 0);
}
#if (GAME == 5)
void near cleardata_and_regist_view_sprites_load(void)
{
extra_unlocked = false;
for(int playchar = PLAYCHAR_REIMU; playchar < PLAYCHAR_COUNT; playchar++) {
rank = RANK_EASY;
while(rank < RANK_COUNT) {
if(hiscore_scoredat_load_for(playchar)) {
break;
}
cleared_with[playchar][rank] = hi.score.cleared;
if(cleared_with[playchar][rank] != SCOREDAT_CLEARED) {
cleared_with[playchar][rank] = false;
}
if(rank < RANK_EXTRA) {
extra_unlocked |= cleared_with[playchar][rank];
}
rank++;
}
}
rank = resident->rank;
super_entry_bfnt("scnum.bft");
super_entry_bfnt("hi_m.bft");
// ZUN bloat: Integrate into the upper loop
for(playchar = PLAYCHAR_REIMU; playchar < PLAYCHAR_COUNT; playchar++) {
extra_playable_with[playchar] = (
cleared_with[playchar][RANK_EASY] |
cleared_with[playchar][RANK_NORMAL] |
cleared_with[playchar][RANK_HARD] |
cleared_with[playchar][RANK_LUNATIC]
);
}
}
#else
// ZUN bloat: Same as the TH05 version, just with Reimu and Marisa spelled out
// instead of looped over.
void near cleardata_and_regist_view_sprites_load(void)
{
rank = RANK_EASY;
while(rank < RANK_COUNT) {
if(hiscore_scoredat_load_both()) {
break;
}
cleared_with[PLAYCHAR_REIMU][rank] = hi.score.cleared;
cleared_with[PLAYCHAR_MARISA][rank] = hi2.score.cleared;
if(cleared_with[PLAYCHAR_REIMU][rank] > SCOREDAT_CLEARED_BOTH) {
cleared_with[PLAYCHAR_REIMU][rank] = false;
}
if(cleared_with[PLAYCHAR_MARISA][rank] > SCOREDAT_CLEARED_BOTH) {
cleared_with[PLAYCHAR_MARISA][rank] = false;
}
if(rank != RANK_EASY) {
extra_unlocked |= (
cleared_with[PLAYCHAR_REIMU][rank] |
cleared_with[PLAYCHAR_MARISA][rank]
);
}
rank++;
}
rank = resident->rank;
super_entry_bfnt("scnum.bft");
super_entry_bfnt("hi_m.bft");
}
#endif

View File

@ -22,7 +22,7 @@ include ReC98.inc
include th04/th04.inc
include th04/sprites/op_cdg.inc
op_01 group OP_SETUP_TEXT, SCORE_TEXT, op_01_TEXT
op_01 group OP_SETUP_TEXT, op_01_TEXT
; ===========================================================================
@ -52,89 +52,8 @@ OP_SETUP_TEXT segment byte public 'CODE' use16
include th04/zunsoft.asm
OP_SETUP_TEXT ends
SCORE_TEXT segment byte public 'CODE' use16
@hiscore_scoredat_load_both$qv procdesc near
SCORE_TEXT ends
op_01_TEXT segment byte public 'CODE' use16
; =============== S U B R O U T I N E =======================================
; Attributes: bp-based frame
public @cleardata_and_regist_view_sprite$qv
@cleardata_and_regist_view_sprite$qv proc near
push bp
mov bp, sp
mov _rank, RANK_EASY
jmp loc_CC6F
; ---------------------------------------------------------------------------
loc_CBEE:
call @hiscore_scoredat_load_both$qv
or al, al
jnz loc_CC78
mov al, _rank
mov ah, 0
mov dl, _hi_reimu.score.cleared
mov bx, ax
mov _cleared_with_reimu[bx], dl
mov al, _rank
mov ah, 0
mov dl, _hi_marisa.score.cleared
mov bx, ax
mov _cleared_with_marisa[bx], dl
mov al, _rank
mov ah, 0
mov bx, ax
cmp _cleared_with_reimu[bx], SCOREDAT_CLEARED_BOTH
jbe short loc_CC2F
mov al, _rank
mov ah, 0
mov bx, ax
mov _cleared_with_reimu[bx], 0
loc_CC2F:
mov al, _rank
mov ah, 0
mov bx, ax
cmp _cleared_with_marisa[bx], SCOREDAT_CLEARED_BOTH
jbe short loc_CC49
mov al, _rank
mov ah, 0
mov bx, ax
mov _cleared_with_marisa[bx], 0
loc_CC49:
cmp _rank, RANK_EASY
jz short loc_CC6B
mov al, _rank
mov ah, 0
mov bx, ax
mov al, _cleared_with_reimu[bx]
mov dl, _rank
mov dh, 0
mov bx, dx
or al, _cleared_with_marisa[bx]
or _extra_unlocked, al
loc_CC6B:
inc _rank
loc_CC6F:
cmp _rank, RANK_COUNT
jb loc_CBEE
loc_CC78:
les bx, _resident
mov al, es:[bx+resident_t.rank]
mov _rank, al
call super_entry_bfnt pascal, ds, offset aScnum_bft ; "scnum.bft"
call super_entry_bfnt pascal, ds, offset aHi_m_bft ; "hi_m.bft"
pop bp
retn
@cleardata_and_regist_view_sprite$qv endp
; =============== S U B R O U T I N E =======================================
; Attributes: bp-based frame
@ -395,9 +314,6 @@ SHARED ends
include th04/zunsoft[data].asm
aScnum_bft db 'scnum.bft',0
aHi_m_bft db 'hi_m.bft',0
db 0
aSft1_cd2 db 'sft1.cd2',0
aSft2_cd2 db 'sft2.cd2',0
aCar_cd2 db 'car.cd2',0
@ -429,14 +345,5 @@ aOp1_pi_1 db 'op1.pi',0
extern _key_det:word
include th04/zunsoft[bss].asm
include th04/formats/scoredat_op[bss].asm
public _rank
_rank db ?
public _cleared_with, _extra_unlocked
_cleared_with label byte
_cleared_with_reimu db RANK_COUNT dup (?)
_cleared_with_marisa db RANK_COUNT dup (?)
_extra_unlocked db ?
db 49 dup(?)
end

View File

@ -1 +0,0 @@
#include "th05/hiscore/view_.cpp"

View File

@ -1,51 +0,0 @@
#include "libs/master.lib/pc98_gfx.hpp"
#include "th04/formats/scoredat/scoredat.hpp"
#include "th04/op/clear.hpp"
#include "th05/resident.hpp"
#include "th05/op/op.hpp"
scoredat_section_t hi;
scoredat_section_t hi2;
static uint8_t scoredat_unused; // ZUN bloat
unsigned char rank;
unsigned char cleared_with[PLAYCHAR_COUNT][RANK_COUNT];
bool extra_unlocked;
void near cleardata_and_regist_view_sprites_load(void)
{
int playchar;
extra_unlocked = false;
for(playchar = PLAYCHAR_REIMU; playchar < PLAYCHAR_COUNT; playchar++) {
rank = RANK_EASY;
while(rank < RANK_COUNT) {
bool pascal near hiscore_scoredat_load_for(int playchar);
if(hiscore_scoredat_load_for(playchar)) {
break;
}
cleared_with[playchar][rank] = hi.score.cleared;
if(cleared_with[playchar][rank] != SCOREDAT_CLEARED) {
cleared_with[playchar][rank] = false;
}
if(rank < RANK_EXTRA) {
extra_unlocked |= cleared_with[playchar][rank];
}
rank++;
}
}
rank = resident->rank;
super_entry_bfnt("scnum.bft");
super_entry_bfnt("hi_m.bft");
for(playchar = PLAYCHAR_REIMU; playchar < PLAYCHAR_COUNT; playchar++) {
// MODDERS: Iterate over ranks instead
extra_playable_with[playchar] = (
cleared_with[playchar][RANK_EASY] |
cleared_with[playchar][RANK_NORMAL] |
cleared_with[playchar][RANK_HARD] |
cleared_with[playchar][RANK_LUNATIC]
);
}
}