[Reverse-engineering] [th03] Round-or-result frame counter

Would be ZUN bloat if it didn't actually have an effect, since way too
many things read from it 😩

Part of P0280, funded by [Anonymous], Blue Bolt, and JonathKane.
This commit is contained in:
nmlgc 2024-04-14 16:32:14 +02:00
parent 09f5292c0a
commit c8443b77fe
2 changed files with 75 additions and 71 deletions

View File

@ -4,3 +4,7 @@ extern unsigned char round_frame_mod2;
extern unsigned char round_frame_mod4; extern unsigned char round_frame_mod4;
extern unsigned char round_frame_mod8; extern unsigned char round_frame_mod8;
extern unsigned char round_frame_mod16; extern unsigned char round_frame_mod16;
// Starts out as a 16-bit copy of [round_frame], but is reset to 0 at the start
// of the round result animation.
extern uint16_t round_or_result_frame;

View File

@ -280,7 +280,7 @@ loc_9845:
call farfp_20F24 call farfp_20F24
cmp byte_23AFA, 0 cmp byte_23AFA, 0
jz short loc_986C jz short loc_986C
test byte ptr word_23AF6, 1 test byte ptr _round_or_result_frame, 1
jz loc_9A62 jz loc_9A62
loc_986C: loc_986C:
@ -334,7 +334,7 @@ loc_986C:
jnb short loc_994E jnb short loc_994E
cmp _p2.rounds_won, 2 cmp _p2.rounds_won, 2
jnb short loc_994E jnb short loc_994E
cmp word_23AF6, 0A0h cmp _round_or_result_frame, 160
jz short loc_9986 jz short loc_9986
cmp byte_1FBC3, 0 cmp byte_1FBC3, 0
jz short loc_99B1 jz short loc_99B1
@ -343,7 +343,7 @@ loc_986C:
loc_994E: loc_994E:
call sub_E3F2 call sub_E3F2
mov ax, word_23AF6 mov ax, _round_or_result_frame
cmp ax, word_1E6E8 cmp ax, word_1E6E8
jz short loc_9986 jz short loc_9986
cmp byte_1FBC3, 0 cmp byte_1FBC3, 0
@ -362,7 +362,7 @@ loc_9973:
les bx, _resident les bx, _resident
cmp es:[bx+resident_t.pid_winner], 0 cmp es:[bx+resident_t.pid_winner], 0
jz short loc_994E jz short loc_994E
cmp word_23AF6, 0A0h cmp _round_or_result_frame, 160
jnz short loc_998E jnz short loc_998E
loc_9986: loc_9986:
@ -418,7 +418,7 @@ loc_99DF:
; --------------------------------------------------------------------------- ; ---------------------------------------------------------------------------
loc_99F7: loc_99F7:
test byte ptr word_23AF6, 1 test byte ptr _round_or_result_frame, 1
jnz short loc_9A14 jnz short loc_9A14
mov vsync_Count1, 0 mov vsync_Count1, 0
@ -450,7 +450,7 @@ loc_9A25:
loc_9A62: loc_9A62:
inc _round_frame inc _round_frame
inc word_23AF6 inc _round_or_result_frame
mov al, byte ptr _round_frame mov al, byte ptr _round_frame
and al, 0Fh and al, 0Fh
mov _round_frame_mod16, al mov _round_frame_mod16, al
@ -460,14 +460,14 @@ loc_9A62:
mov _round_frame_mod4, al mov _round_frame_mod4, al
and al, 1 and al, 1
mov _round_frame_mod2, al mov _round_frame_mod2, al
test byte ptr word_23AF6, 3Fh test byte ptr _round_or_result_frame, 63
jnz short loc_9AC9 jnz short loc_9AC9
cmp byte_23AF8, 7Fh cmp byte_23AF8, 7Fh
jnb short loc_9A94 jnb short loc_9A94
inc byte_23AF8 inc byte_23AF8
loc_9A94: loc_9A94:
test word_23AF6, 3FFh test _round_or_result_frame, 1023
jnz short loc_9AB5 jnz short loc_9AB5
call @randring_fill$qv call @randring_fill$qv
cmp _p1.miss_damage_next, 6 cmp _p1.miss_damage_next, 6
@ -480,7 +480,7 @@ loc_9AAA:
inc _p2.miss_damage_next inc _p2.miss_damage_next
loc_9AB5: loc_9AB5:
cmp word_23AF6, 7D0h cmp _round_or_result_frame, 2000
jnb short loc_9AC9 jnb short loc_9AC9
mov _p1.cpu_frame, 0 mov _p1.cpu_frame, 0
mov _p2.cpu_frame, 0 mov _p2.cpu_frame, 0
@ -2721,7 +2721,7 @@ sub_B80B proc near
mov dx, 1 mov dx, 1
mov ah, SPRITE16_SET_MONO mov ah, SPRITE16_SET_MONO
int SPRITE16 int SPRITE16
mov dx, word_23AF6 mov dx, _round_or_result_frame
; Hack (and dx, 1) ; Hack (and dx, 1)
db 081h db 081h
db 0e2h db 0e2h
@ -3878,7 +3878,7 @@ loc_C159:
mov al, 1 mov al, 1
sub al, _pid_PID_current sub al, _pid_PID_current
mov es:[bx+resident_t.pid_winner], al mov es:[bx+resident_t.pid_winner], al
mov word_23AF6, 0 mov _round_or_result_frame, 0
mov al, 1 mov al, 1
sub al, _pid_PID_current sub al, _pid_PID_current
push ax push ax
@ -3887,7 +3887,7 @@ loc_C159:
; --------------------------------------------------------------------------- ; ---------------------------------------------------------------------------
loc_C1CD: loc_C1CD:
mov ax, word_23AF6 mov ax, _round_or_result_frame
and ax, 1 and ax, 1
imul ax, 30 imul ax, 30
add ax, 100 add ax, 100
@ -4041,7 +4041,7 @@ sub_C248 endp
sub_C2F9 proc near sub_C2F9 proc near
var_2 = word ptr -2 @@frame_mod_32 = word ptr -2
enter 2, 0 enter 2, 0
push si push si
@ -4061,10 +4061,10 @@ var_2 = word ptr -2
imul dx, PLAYFIELD_W_BORDERED imul dx, PLAYFIELD_W_BORDERED
add dx, 96 add dx, 96
mov si, dx mov si, dx
mov ax, word_23AF6 mov ax, _round_or_result_frame
and ax, 1Fh and ax, 31
mov [bp+var_2], ax mov [bp+@@frame_mod_32], ax
cmp [bp+var_2], 10h cmp [bp+@@frame_mod_32], 16
jge short loc_C34F jge short loc_C34F
add ax, 32 add ax, 32
jmp short loc_C355 jmp short loc_C355
@ -4072,7 +4072,7 @@ var_2 = word ptr -2
loc_C34F: loc_C34F:
mov ax, 64 mov ax, 64
sub ax, [bp+var_2] sub ax, [bp+@@frame_mod_32]
loc_C355: loc_C355:
mov di, ax mov di, ax
@ -4439,7 +4439,7 @@ arg_0 = word ptr 4
mov [bp+var_6], ax mov [bp+var_6], ax
mov ax, [si+2] mov ax, [si+2]
mov [bp+var_8], ax mov [bp+var_8], ax
test byte ptr word_23AF6, 3 test byte ptr _round_or_result_frame, 3
jnz short loc_C5AA jnz short loc_C5AA
mov [bp+var_B], (64 / 2) mov [bp+var_B], (64 / 2)
jmp short loc_C5A1 jmp short loc_C5A1
@ -4816,7 +4816,7 @@ sub_C830 proc near
call egc_off call egc_off
cmp _p1.hyper_active, 0 cmp _p1.hyper_active, 0
jz short loc_C881 jz short loc_C881
test byte ptr word_23AF6, 1 test byte ptr _round_or_result_frame, 1
jz short loc_C881 jz short loc_C881
mov ax, _p1.gauge_avail mov ax, _p1.gauge_avail
shr ax, 10 shr ax, 10
@ -4846,7 +4846,7 @@ loc_C86E:
loc_C881: loc_C881:
cmp _p2.hyper_active, 0 cmp _p2.hyper_active, 0
jz short loc_C8C1 jz short loc_C8C1
test byte ptr word_23AF6, 1 test byte ptr _round_or_result_frame, 1
jz short loc_C8C1 jz short loc_C8C1
mov ax, _p2.gauge_avail mov ax, _p2.gauge_avail
shr ax, 10 shr ax, 10
@ -4910,7 +4910,7 @@ var_1 = byte ptr -1
jle short loc_C921 jle short loc_C921
cmp _p1.hyper_active, 0 cmp _p1.hyper_active, 0
jz short loc_C901 jz short loc_C901
test byte ptr word_23AF6, 1 test byte ptr _round_or_result_frame, 1
jz short loc_C909 jz short loc_C909
loc_C901: loc_C901:
@ -4935,7 +4935,7 @@ loc_C921:
jle short loc_C956 jle short loc_C956
cmp _p2.hyper_active, 0 cmp _p2.hyper_active, 0
jz short loc_C936 jz short loc_C936
test byte ptr word_23AF6, 1 test byte ptr _round_or_result_frame, 1
jz short loc_C93E jz short loc_C93E
loc_C936: loc_C936:
@ -6034,41 +6034,41 @@ sub_D135 endp
sub_D1E7 proc far sub_D1E7 proc far
var_3 = byte ptr -3 var_3 = byte ptr -3
var_2 = word ptr -2 @@frame_mod_4096 = word ptr -2
enter 4, 0 enter 4, 0
push si push si
push di push di
mov ax, word_23AF6 mov ax, _round_or_result_frame
and ax, 0FFFh and ax, 4095
mov [bp+var_2], ax mov [bp+@@frame_mod_4096], ax
cmp [bp+var_2], 400h cmp [bp+@@frame_mod_4096], 1024
jl short loc_D24B jl short loc_D24B
cmp [bp+var_2], 500h cmp [bp+@@frame_mod_4096], 1280
jge short loc_D20C jge short loc_D20C
test byte ptr [bp+var_2], 7 test byte ptr [bp+@@frame_mod_4096], 7
jnz short loc_D24F jnz short loc_D24F
jmp short loc_D23B jmp short loc_D23B
; --------------------------------------------------------------------------- ; ---------------------------------------------------------------------------
loc_D20C: loc_D20C:
cmp [bp+var_2], 800h cmp [bp+@@frame_mod_4096], 2048
jl short loc_D24B jl short loc_D24B
cmp [bp+var_2], 900h cmp [bp+@@frame_mod_4096], 2304
jge short loc_D222 jge short loc_D222
test byte ptr [bp+var_2], 3 test byte ptr [bp+@@frame_mod_4096], 3
jnz short loc_D24F jnz short loc_D24F
jmp short loc_D241 jmp short loc_D241
; --------------------------------------------------------------------------- ; ---------------------------------------------------------------------------
loc_D222: loc_D222:
cmp [bp+var_2], 0C00h cmp [bp+@@frame_mod_4096], 3072
jl short loc_D24B jl short loc_D24B
cmp [bp+var_2], 0FE0h cmp [bp+@@frame_mod_4096], 4064
jge short loc_D24B jge short loc_D24B
mov ax, [bp+var_2] mov ax, [bp+@@frame_mod_4096]
and ax, 7Fh and ax, 127
cmp ax, 40h cmp ax, 64
jge short loc_D241 jge short loc_D241
loc_D23B: loc_D23B:
@ -6284,41 +6284,41 @@ sub_D340 endp
sub_D3F9 proc far sub_D3F9 proc far
var_3 = byte ptr -3 var_3 = byte ptr -3
var_2 = word ptr -2 @@frame_mod_4096 = word ptr -2
enter 4, 0 enter 4, 0
push si push si
push di push di
mov ax, word_23AF6 mov ax, _round_or_result_frame
and ax, 0FFFh and ax, 4095
mov [bp+var_2], ax mov [bp+@@frame_mod_4096], ax
cmp [bp+var_2], 400h cmp [bp+@@frame_mod_4096], 1024
jl short loc_D45D jl short loc_D45D
cmp [bp+var_2], 500h cmp [bp+@@frame_mod_4096], 1280
jge short loc_D41E jge short loc_D41E
test byte ptr [bp+var_2], 7 test byte ptr [bp+@@frame_mod_4096], 7
jnz short loc_D461 jnz short loc_D461
jmp short loc_D44D jmp short loc_D44D
; --------------------------------------------------------------------------- ; ---------------------------------------------------------------------------
loc_D41E: loc_D41E:
cmp [bp+var_2], 800h cmp [bp+@@frame_mod_4096], 2048
jl short loc_D45D jl short loc_D45D
cmp [bp+var_2], 900h cmp [bp+@@frame_mod_4096], 2304
jge short loc_D434 jge short loc_D434
test byte ptr [bp+var_2], 3 test byte ptr [bp+@@frame_mod_4096], 3
jnz short loc_D461 jnz short loc_D461
jmp short loc_D453 jmp short loc_D453
; --------------------------------------------------------------------------- ; ---------------------------------------------------------------------------
loc_D434: loc_D434:
cmp [bp+var_2], 0C00h cmp [bp+@@frame_mod_4096], 3072
jl short loc_D45D jl short loc_D45D
cmp [bp+var_2], 0FE0h cmp [bp+@@frame_mod_4096], 4064
jge short loc_D45D jge short loc_D45D
mov ax, [bp+var_2] mov ax, [bp+@@frame_mod_4096]
and ax, 7Fh and ax, 127
cmp ax, 40h cmp ax, 64
jge short loc_D453 jge short loc_D453
loc_D44D: loc_D44D:
@ -6386,7 +6386,7 @@ loc_D4D3:
xor dx, dx xor dx, dx
cmp si, 28h ; '(' cmp si, 28h ; '('
jb short loc_D4E6 jb short loc_D4E6
mov dx, [bp+var_2] mov dx, [bp+@@frame_mod_4096]
; Hack (and dx, 1Fh) ; Hack (and dx, 1Fh)
db 081h db 081h
db 0e2h db 0e2h
@ -7133,7 +7133,7 @@ loc_DB3C:
mov al, [bp+var_5] mov al, [bp+var_5]
mov ah, 0 mov ah, 0
push ax push ax
mov ax, word_23AF6 mov ax, _round_or_result_frame
xor dx, dx xor dx, dx
pop bx pop bx
div bx div bx
@ -7661,7 +7661,7 @@ loc_DFAB:
sar ax, 5 sar ax, 5
add ax, -15 add ax, -15
mov [bp+@@y], ax mov [bp+@@y], ax
mov ax, word_23AF6 mov ax, _round_or_result_frame
shr ax, 2 shr ax, 2
and ax, 3 and ax, 3
add ax, di add ax, di
@ -7978,7 +7978,7 @@ loc_E339:
cmp ax, 40h cmp ax, 40h
jl short loc_E332 jl short loc_E332
mov _round_frame, 0 mov _round_frame, 0
mov word_23AF6, 0 mov _round_or_result_frame, 0
mov byte_23AF9, 1 mov byte_23AF9, 1
mov byte_23B00, 0 mov byte_23B00, 0
pop di pop di
@ -8096,7 +8096,7 @@ var_6 = dword ptr -6
add si, 28h ; '(' add si, 28h ; '('
loc_E411: loc_E411:
mov ax, word_23AF6 mov ax, _round_or_result_frame
and ax, 7 and ax, 7
cmp ax, 1 cmp ax, 1
jnz loc_E602 jnz loc_E602
@ -8130,7 +8130,7 @@ loc_E4A2:
shl ax, 7 shl ax, 7
add ax, offset _players add ax, offset _players
mov di, ax mov di, ax
cmp word_23AF6, 1 cmp _round_or_result_frame, 1
jnz loc_E5AC jnz loc_E5AC
mov al, [di+player_t.combo_hits_max] mov al, [di+player_t.combo_hits_max]
mov _win_combo_hits_max, al mov _win_combo_hits_max, al
@ -9450,7 +9450,7 @@ var_2 = word ptr -2
loc_FA0A: loc_FA0A:
cmp byte_1F353, 1 cmp byte_1F353, 1
jnz short loc_FA6D jnz short loc_FA6D
mov ax, word_23AF6 mov ax, _round_or_result_frame
and ax, 3 and ax, 3
cmp ax, 2 cmp ax, 2
jnb short loc_FA49 jnb short loc_FA49
@ -14579,7 +14579,7 @@ loc_12859:
loc_12860: loc_12860:
mov byte_23E50, 1 ; default mov byte_23E50, 1 ; default
test byte ptr word_23AF6, 3 test byte ptr _round_or_result_frame, 3
jnz short loc_12871 jnz short loc_12871
mov ax, 1 mov ax, 1
jmp short loc_12873 jmp short loc_12873
@ -16456,7 +16456,7 @@ var_6 = word ptr -6
mov _sprite16_put_h, 24 mov _sprite16_put_h, 24
cmp word_1F3B0, 40h cmp word_1F3B0, 40h
jnb short loc_138E4 jnb short loc_138E4
test byte ptr word_23AF6, 1 test byte ptr _round_or_result_frame, 1
jnz loc_13987 jnz loc_13987
loc_138E4: loc_138E4:
@ -18714,7 +18714,7 @@ arg_4 = word ptr 8
mov di, [bp+arg_4] mov di, [bp+arg_4]
mov si, [bp+arg_0] mov si, [bp+arg_0]
mov ax, si mov ax, si
add ax, word_23AF6 add ax, _round_or_result_frame
mov si, ax mov si, ax
and si, 3 and si, 3
mov ax, si mov ax, si
@ -18753,7 +18753,7 @@ reimu_14CE3 proc far
push si push si
cmp byte_205CC, 0 cmp byte_205CC, 0
jz short loc_14CF7 jz short loc_14CF7
test byte ptr word_23AF6, 1 test byte ptr _round_or_result_frame, 1
jnz loc_14D7E jnz loc_14D7E
loc_14CF7: loc_14CF7:
@ -20295,7 +20295,7 @@ loc_159DD:
mov bx, ax mov bx, ax
cmp _bomb_state[bx], BOMB_INACTIVE cmp _bomb_state[bx], BOMB_INACTIVE
jz short loc_159F8 jz short loc_159F8
test byte ptr word_23AF6, 1 test byte ptr _round_or_result_frame, 1
jnz short loc_159F8 jnz short loc_159F8
inc [bp+var_5] inc [bp+var_5]
@ -20758,7 +20758,7 @@ loc_15E27:
loc_15E29: loc_15E29:
push ax push ax
mov ax, word_23AF6 mov ax, _round_or_result_frame
and ax, 3 and ax, 3
cmp ax, 2 cmp ax, 2
jnb short loc_15E3A jnb short loc_15E3A
@ -24705,9 +24705,9 @@ loc_17E45:
push dx ; pid push dx ; pid
call @playfield_fg_x_to_screen$qii call @playfield_fg_x_to_screen$qii
mov [bp+@@x], ax mov [bp+@@x], ax
mov ax, word_23AF6 mov ax, _round_or_result_frame
and ax, 1FFh and ax, 511
cmp ax, 100h cmp ax, 256
jnb short loc_17E6F jnb short loc_17E6F
push 1200h push 1200h
call @randring2_next16_mod$qui call @randring2_next16_mod$qui
@ -35650,9 +35650,9 @@ _pid_PID_current label byte
_pid_PID_so_attack label byte _pid_PID_so_attack label byte
_pid db ? _pid db ?
evendata evendata
public _round_frame public _round_frame, _round_or_result_frame
_round_frame dd ? _round_frame dd ?
word_23AF6 dw ? _round_or_result_frame dw ?
byte_23AF8 db ? byte_23AF8 db ?
byte_23AF9 db ? byte_23AF9 db ?
byte_23AFA db ? byte_23AFA db ?