[Reverse-engineering] [th04/th05] Difficulty/character-based value selection

Funded by -Tom-.
This commit is contained in:
nmlgc 2019-03-01 18:49:57 +01:00
parent c241af414f
commit ae9651c693
4 changed files with 149 additions and 148 deletions

24
th04/select_for_rank.asm Normal file
View File

@ -0,0 +1,24 @@
; Returns the parameter for the current difficulty. The ASM always passes the
; 4 parameters with two 32-bit pushes, whose visual layout matches the
; parameter list:
;
; push ([for_easy] shl 16) or [for_normal]
; push ([for_hard] shl 16) or [for_lunatic]
; int pascal far select_for_rank(
; int for_easy, int for_normal,
; int for_hard, int for_lunatic
; );
public select_for_rank
select_for_rank proc far
mov al, _rank
select_for:
xor ah, ah
add ax, ax
mov bx, 0Ah
sub bx, ax
add bx, sp
mov ax, ss:[bx]
retf 8
select_for_rank endp

View File

@ -2712,21 +2712,7 @@ sub_C34E proc near
sub_C34E endp sub_C34E endp
include th04/playperf.asm include th04/playperf.asm
include th04/select_for_rank.asm
; =============== S U B R O U T I N E =======================================
sub_C396 proc far
mov al, _rank
xor ah, ah
add ax, ax
mov bx, 0Ah
sub bx, ax
add bx, sp
mov ax, ss:[bx]
retf 8
sub_C396 endp
; =============== S U B R O U T I N E ======================================= ; =============== S U B R O U T I N E =======================================
@ -36439,9 +36425,9 @@ sub_1E0B3 proc far
call super_entry_bfnt call super_entry_bfnt
call _cdg_load_single_noalpha pascal, 16, ds, offset aSt01bk_cdg, 0 call _cdg_load_single_noalpha pascal, 16, ds, offset aSt01bk_cdg, 0
call bb_stage_load pascal, ds, offset aSt01_bb call bb_stage_load pascal, ds, offset aSt01_bb
push 0FF0080h push (255 shl 16) or 128
push 200008h push ( 32 shl 16) or 8
call sub_C396 call select_for_rank
mov byte_2D01E, al mov byte_2D01E, al
mov _stage_render, offset nullsub_1 mov _stage_render, offset nullsub_1
mov _stage_invalidate, offset nullsub_1 mov _stage_invalidate, offset nullsub_1
@ -36520,33 +36506,33 @@ sub_1E245 proc far
jnz loc_1E359 jnz loc_1E359
setfarfp _boss_update_func, sub_1F3AB setfarfp _boss_update_func, sub_1F3AB
mov _boss_fg_render_func, offset sub_12E93 mov _boss_fg_render_func, offset sub_12E93
push 40006h push ( 4 shl 16) or 6
push 8000Ch push ( 8 shl 16) or 12
call sub_C396 call select_for_rank
mov byte_2D01E, al mov byte_2D01E, al
push 10000Ch push (16 shl 16) or 12
push 80006h push ( 8 shl 16) or 6
call sub_C396 call select_for_rank
mov byte_2D01F, al mov byte_2D01F, al
push 10002h push ( 1 shl 16) or 2
push 30004h push ( 3 shl 16) or 4
call sub_C396 call select_for_rank
mov byte_2D020, al mov byte_2D020, al
push 170017h push (23 shl 16) or 23
push 180018h push (24 shl 16) or 24
call sub_C396 call select_for_rank
mov byte_2D021, al mov byte_2D021, al
push 80009h push ( 8 shl 16) or 9
push 9000Ah push ( 9 shl 16) or 10
call sub_C396 call select_for_rank
mov byte_2D022, al mov byte_2D022, al
push 120010h push (18 shl 16) or 16
push 0E000Ah push (14 shl 16) or 10
call sub_C396 call select_for_rank
mov byte_2D023, al mov byte_2D023, al
push 60008h push ( 6 shl 16) or 8
push 9000Ah push ( 9 shl 16) or 10
call sub_C396 call select_for_rank
mov byte_2D024, al mov byte_2D024, al
jmp short loc_1E371 jmp short loc_1E371
; --------------------------------------------------------------------------- ; ---------------------------------------------------------------------------
@ -36618,9 +36604,9 @@ sub_1E3C2 proc far
mov word_2D038, 0BE0h mov word_2D038, 0BE0h
mov _stage_render, offset stage5_render mov _stage_render, offset stage5_render
mov _stage_invalidate, offset stage5_invalidate mov _stage_invalidate, offset stage5_invalidate
push 9000A0h push (144 shl 16) or 160
push 0A800B4h push (168 shl 16) or 180
call sub_C396 call select_for_rank
mov byte_2D01E, al mov byte_2D01E, al
pop bp pop bp
retf retf
@ -36651,13 +36637,13 @@ sub_1E47C proc far
call bb_stage_load pascal, ds, offset aSt05_bb call bb_stage_load pascal, ds, offset aSt05_bb
mov _stage_render, offset nullsub_1 mov _stage_render, offset nullsub_1
mov _stage_invalidate, offset nullsub_1 mov _stage_invalidate, offset nullsub_1
push 300040h push (48 shl 16) or 64
push 500060h push (80 shl 16) or 96
call sub_C396 call select_for_rank
mov byte_2D01E, al mov byte_2D01E, al
push 10001h push ( 1 shl 16) or 1
push 20004h push ( 2 shl 16) or 4
call sub_C396 call select_for_rank
mov byte_2D01F, al mov byte_2D01F, al
pop bp pop bp
retf retf

View File

@ -0,0 +1,17 @@
; Returns the parameter for the current player character. The ASM always
; passes the 4 parameters with two 32-bit pushes, whose visual layout matches
; the parameter list:
;
; push ([for_reimu] shl 16) or [for_marisa]
; push ( [for_mima] shl 16) or [for_yuuka]
; int pascal far select_for_playchar(
; int for_reimu, int for_marisa,
; int for_mima, int for_yuuka
; );
public select_for_playchar
select_for_playchar proc far
mov al, playchar
jmp short select_for
select_for_playchar endp
nop

View File

@ -2638,13 +2638,13 @@ loc_C4BC:
nopcall sub_104BB nopcall sub_104BB
mov byte_2429A, 1 mov byte_2429A, 1
mov byte_2429B, 0 mov byte_2429B, 0
push 0C000A0h push (192 shl 16) or 160
push 9000E0h push (144 shl 16) or 224
nopcall sub_E752 nopcall select_for_playchar
mov chara_invulnerable_time_left, al mov chara_invulnerable_time_left, al
push 0C00080h push (192 shl 16) or 128
push 6000C0h push ( 96 shl 16) or 192
nopcall sub_E752 nopcall select_for_playchar
mov _bullet_clear_time, al mov _bullet_clear_time, al
mov ax, fp_23F5A mov ax, fp_23F5A
mov fp_23F58, ax mov fp_23F58, ax
@ -6833,34 +6833,8 @@ sub_E708 endp
; --------------------------------------------------------------------------- ; ---------------------------------------------------------------------------
nop nop
include th04/playperf.asm include th04/playperf.asm
include th05/select_for_playchar.asm
; =============== S U B R O U T I N E ======================================= include th04/select_for_rank.asm
sub_E752 proc far
mov al, playchar
jmp short loc_E75B
sub_E752 endp
; ---------------------------------------------------------------------------
nop
; =============== S U B R O U T I N E =======================================
sub_E758 proc far
mov al, _rank
loc_E75B:
xor ah, ah
add ax, ax
mov bx, 0Ah
sub bx, ax
add bx, sp
mov ax, ss:[bx]
retf 8
sub_E758 endp
; =============== S U B R O U T I N E ======================================= ; =============== S U B R O U T I N E =======================================
@ -14121,9 +14095,9 @@ loc_1274B:
loc_12769: loc_12769:
cmp frame_mod4, 0 cmp frame_mod4, 0
jnz short loc_12783 jnz short loc_12783
push 30004h push ( 3 shl 16) or 4
push 0F0003h push (15 shl 16) or 3
nopcall sub_E752 nopcall select_for_playchar
add si, ax add si, ax
loc_12783: loc_12783:
@ -18557,13 +18531,13 @@ sub_14879 proc near
call super_entry_bfnt call super_entry_bfnt
call _cdg_load_all_noalpha pascal, 16, ds, offset aSt04bk_cdg call _cdg_load_all_noalpha pascal, 16, ds, offset aSt04bk_cdg
call bb_stage_load pascal, ds, offset aSt04_bb call bb_stage_load pascal, ds, offset aSt04_bb
push 14000Ah push (20 shl 16) or 10
push 60006h push ( 6 shl 16) or 6
nopcall sub_E758 nopcall select_for_rank
mov byte_2D076, al mov byte_2D076, al
push 300020h push (48 shl 16) or 32
push 180018h push (24 shl 16) or 24
nopcall sub_E758 nopcall select_for_rank
mov byte_2D077, al mov byte_2D077, al
mov _stage_render, offset nullsub_2 mov _stage_render, offset nullsub_2
mov _stage_invalidate, offset nullsub_2 mov _stage_invalidate, offset nullsub_2
@ -24248,9 +24222,9 @@ loc_17EC3:
; --------------------------------------------------------------------------- ; ---------------------------------------------------------------------------
loc_17EE9: loc_17EE9:
push 3C00500h push (3C0h shl 16) or 500h
push 5000500h push (500h shl 16) or 500h
call sub_E758 call select_for_rank
loc_17EFA: loc_17EFA:
mov [bp+var_8], ax mov [bp+var_8], ax
@ -25061,9 +25035,9 @@ loc_1863F:
mov byte ptr word_26006, al mov byte ptr word_26006, al
mov byte_26000, 2 mov byte_26000, 2
mov byte_26001, 0Ah mov byte_26001, 0Ah
push 1050106h push (261 shl 16) or 262
push 1070108h push (263 shl 16) or 264
call sub_E758 call select_for_rank
mov word ptr dword_26002, ax mov word ptr dword_26002, ax
mov byte ptr word_26006+1, 20h ; ' ' mov byte ptr word_26006+1, 20h ; ' '
mov byte ptr word_25FFA+1, 0 mov byte ptr word_25FFA+1, 0
@ -25844,9 +25818,9 @@ loc_18D6F:
mov byte ptr word_25FFA+1, 54h ; 'T' mov byte ptr word_25FFA+1, 54h ; 'T'
mov byte_26000, 6 mov byte_26000, 6
mov byte ptr word_26006+1, 20h ; ' ' mov byte ptr word_26006+1, 20h ; ' '
push 50A050Ch push (50Ah shl 16) or 50Ch
push 60C060Eh push (60Ch shl 16) or 60Eh
call sub_E758 call select_for_rank
mov word ptr dword_26002+2, ax mov word ptr dword_26002+2, ax
mov byte ptr word_26006, 0C0h mov byte ptr word_26006, 0C0h
pop bp pop bp
@ -26609,11 +26583,11 @@ loc_193F5:
jnz short loc_19437 jnz short loc_19437
mov byte_26000, 9 mov byte_26000, 9
mov byte ptr word_25FFA+1, 30h ; '0' mov byte ptr word_25FFA+1, 30h ; '0'
push 1010402h push (101h shl 16) or 402h
push 3030404h push (303h shl 16) or 404h
loc_19412: loc_19412:
call sub_E758 call select_for_rank
mov word ptr dword_26002, ax mov word ptr dword_26002, ax
mov word ptr dword_26002+2, 808h mov word ptr dword_26002+2, 808h
@ -32980,13 +32954,13 @@ loc_1CC7F:
cmp byte_2D083, 0 cmp byte_2D083, 0
jnz short loc_1CCD0 jnz short loc_1CCD0
mov byte_2D083, 1 mov byte_2D083, 1
push 100008h push (16 shl 16) or 8
push 40004h push ( 4 shl 16) or 4
call sub_E758 call select_for_rank
mov byte_2D076, al mov byte_2D076, al
push 280030h push (40 shl 16) or 48
push 340034h push (52 shl 16) or 52
call sub_E758 call select_for_rank
mov byte_2D082, al mov byte_2D082, al
push 0 push 0
call add_explode_effect_function call add_explode_effect_function
@ -33323,13 +33297,13 @@ loc_1D030:
cmp byte_2D083, 0 cmp byte_2D083, 0
jnz short loc_1D081 jnz short loc_1D081
mov byte_2D083, 1 mov byte_2D083, 1
push 22001Ch push (34 shl 16) or 28
push 140014h push (20 shl 16) or 20
call sub_E758 call select_for_rank
mov byte_2D077, al mov byte_2D077, al
push 280030h push (40 shl 16) or 48
push 340030h push (52 shl 16) or 48
call sub_E758 call select_for_rank
mov byte_2D082, al mov byte_2D082, al
push 0 push 0
call add_explode_effect_function call add_explode_effect_function
@ -33366,9 +33340,9 @@ yumeko_1D085 proc near
mov byte ptr word_25FFA+1, 34h ; '4' mov byte ptr word_25FFA+1, 34h ; '4'
mov byte_26000, 2 mov byte_26000, 2
mov byte ptr dword_26002, 5 mov byte ptr dword_26002, 5
push 180010h push (24 shl 16) or 16
push 0C000Ah push (12 shl 16) or 10
call sub_E758 call select_for_rank
mov byte ptr dword_26002+1, al mov byte ptr dword_26002+1, al
mov byte ptr word_26006+1, 80h mov byte ptr word_26006+1, 80h
call snd_se_play pascal, 8 call snd_se_play pascal, 8
@ -33377,9 +33351,9 @@ yumeko_1D085 proc near
push 200h push 200h
call _randring2_next16_mod call _randring2_next16_mod
mov _boss2_pos.cur.y, ax mov _boss2_pos.cur.y, ax
push 28001Eh push (40 shl 16) or 30
push 180010h push (24 shl 16) or 16
call sub_E758 call select_for_rank
mov byte_2D085, al mov byte_2D085, al
mov byte_2D084, 0 mov byte_2D084, 0
@ -34065,9 +34039,9 @@ sub_1D6E1 proc near
call _randring2_next16 call _randring2_next16
mov byte ptr word_26006, al mov byte ptr word_26006, al
mov byte ptr dword_26002, 10h mov byte ptr dword_26002, 10h
push 10000Ch push (16 shl 16) or 12
push 80004h push ( 8 shl 16) or 4
call sub_E758 call select_for_rank
mov byte_2D085, al mov byte_2D085, al
loc_1D719: loc_1D719:
@ -34211,9 +34185,9 @@ sub_1D83A proc near
mov byte_26000, 9 mov byte_26000, 9
mov byte ptr word_26006, 0 mov byte ptr word_26006, 0
mov word ptr dword_26002, 402h mov word ptr dword_26002, 402h
push 0C050C06h push (0C05h shl 16) or 0C06h
push 0D060D07h push (0D06h shl 16) or 0D07h
call sub_E758 call select_for_rank
mov word ptr dword_26002+2, ax mov word ptr dword_26002+2, ax
mov byte ptr word_26006+1, 20h ; ' ' mov byte ptr word_26006+1, 20h ; ' '
@ -34447,9 +34421,9 @@ loc_1DA6A:
mov byte ptr word_25FFA+1, 2Ch ; ',' mov byte ptr word_25FFA+1, 2Ch ; ','
mov byte_26000, 3 mov byte_26000, 3
mov byte ptr dword_26002, 5 mov byte ptr dword_26002, 5
push 10000Ch push (16 shl 16) or 12
push 0A0008h push (10 shl 16) or 8
call sub_E758 call select_for_rank
mov byte ptr dword_26002+1, al mov byte ptr dword_26002+1, al
mov byte ptr word_26006, 0 mov byte ptr word_26006, 0
mov byte ptr word_26006+1, 30h ; '0' mov byte ptr word_26006+1, 30h ; '0'
@ -34474,13 +34448,13 @@ sub_1DAD2 proc near
jl loc_1DB78 jl loc_1DB78
cmp boss_phase_frame, 80h cmp boss_phase_frame, 80h
jnz short loc_1DB10 jnz short loc_1DB10
push 800030h push (128 shl 16) or 48
push 200018h push ( 32 shl 16) or 24
call sub_E758 call select_for_rank
mov byte_2D084, al mov byte_2D084, al
push 200028h push ( 32 shl 16) or 40
push 300038h push ( 48 shl 16) or 56
call sub_E758 call select_for_rank
mov byte_2D085, al mov byte_2D085, al
loc_1DB10: loc_1DB10:
@ -34624,9 +34598,9 @@ sub_1DC2F proc near
jle loc_1DCFD jle loc_1DCFD
cmp boss_phase_frame, 81h cmp boss_phase_frame, 81h
jnz short loc_1DC59 jnz short loc_1DC59
push 600020h push (96 shl 16) or 32
push 1C0018h push (28 shl 16) or 24
call sub_E758 call select_for_rank
mov byte_2D085, al mov byte_2D085, al
loc_1DC59: loc_1DC59:
@ -34746,9 +34720,9 @@ loc_1DD72:
jnz short loc_1DDC3 jnz short loc_1DDC3
mov byte_2D084, 20h ; ' ' mov byte_2D084, 20h ; ' '
mov byte_2D085, 0 mov byte_2D085, 0
push 400028h push (64 shl 16) or 40
push 20001Ch push (32 shl 16) or 28
call sub_E758 call select_for_rank
mov byte_2D083, al mov byte_2D083, al
mov byte_2D082, 0 mov byte_2D082, 0
mov byte_2D081, 0 mov byte_2D081, 0
@ -34962,9 +34936,9 @@ loc_1DFFB:
inc word_22852 inc word_22852
cmp ax, 41h ; 'A' cmp ax, 41h ; 'A'
jnz short locret_1E020 jnz short locret_1E020
push 340014h push (52 shl 16) or 20
push 10000Ch push (16 shl 16) or 12
call sub_E758 call select_for_rank
mov byte_2D083, al mov byte_2D083, al
push 0 push 0
call add_explode_effect_function call add_explode_effect_function
@ -35291,9 +35265,9 @@ loc_1E333:
mov boss_phase_frame, 0 mov boss_phase_frame, 0
mov _boss_pos.velocity.y, 0 mov _boss_pos.velocity.y, 0
mov _boss_custombullets_render, offset sub_11073 mov _boss_custombullets_render, offset sub_11073
push 3200230h push ((50 shl 4) shl 16) or (35 shl 4)
push 2D00320h push ((45 shl 4) shl 16) or (50 shl 4)
call sub_E752 call select_for_playchar
mov _boss_hitbox_radius.x, ax mov _boss_hitbox_radius.x, ax
mov fp_2CE4A, offset sub_1DA1C mov fp_2CE4A, offset sub_1DA1C