From d973380a9c573a6258f39ac3dc9c1f30c4b9970b Mon Sep 17 00:00:00 2001 From: nmlgc Date: Thu, 10 Sep 2020 21:02:02 +0200 Subject: [PATCH] [Reverse-engineering] [th03/th04/th05] High score menu: Entered place Part of P0116, funded by [Anonymous] and Lmocinemod. --- th03/formats/scoredat.h | 1 + th03/formats/scoredat.inc | 1 + th03/hiscore/regist[bss].asm | 8 ++++ th03_mainl.asm | 52 +++++++++++------------ th04_maine.asm | 72 +++++++++++++++---------------- th05_maine.asm | 82 ++++++++++++++++++------------------ 6 files changed, 113 insertions(+), 103 deletions(-) create mode 100644 th03/formats/scoredat.h create mode 100644 th03/formats/scoredat.inc create mode 100644 th03/hiscore/regist[bss].asm diff --git a/th03/formats/scoredat.h b/th03/formats/scoredat.h new file mode 100644 index 00000000..7e185baa --- /dev/null +++ b/th03/formats/scoredat.h @@ -0,0 +1 @@ +#define SCOREDAT_PLACES 10 diff --git a/th03/formats/scoredat.inc b/th03/formats/scoredat.inc new file mode 100644 index 00000000..dc2badd6 --- /dev/null +++ b/th03/formats/scoredat.inc @@ -0,0 +1 @@ +SCOREDAT_PLACES = 10 diff --git a/th03/hiscore/regist[bss].asm b/th03/hiscore/regist[bss].asm new file mode 100644 index 00000000..58064066 --- /dev/null +++ b/th03/hiscore/regist[bss].asm @@ -0,0 +1,8 @@ +PLACE_NONE = (-1) + +public _entered_place +if (GAME ge 4) + _entered_place db ? +else + _entered_place dw ? +endif diff --git a/th03_mainl.asm b/th03_mainl.asm index 30cc0880..3747777c 100644 --- a/th03_mainl.asm +++ b/th03_mainl.asm @@ -2960,10 +2960,10 @@ sub_AFAC proc near retn sub_AFAC endp - ; =============== S U B R O U T I N E ======================================= ; Attributes: bp-based frame +include th03/formats/scoredat.inc sub_B03D proc near push bp @@ -3014,16 +3014,16 @@ loc_B090: inc si loc_B091: - cmp si, 0Ah + cmp si, SCOREDAT_PLACES jl short loc_B046 - cmp si, 0Ah + cmp si, SCOREDAT_PLACES jnz short loc_B0A1 - mov ax, 0FFFFh - jmp loc_B183 + mov ax, -1 + jmp @@ret ; --------------------------------------------------------------------------- loc_B0A1: - cmp si, 9 + cmp si, (SCOREDAT_PLACES - 1) jge short loc_B100 mov di, 8 jmp short loc_B0FC @@ -3140,7 +3140,7 @@ loc_B16B: mov [si+22A6h], al mov ax, si -loc_B183: +@@ret: pop di pop si pop bp @@ -3359,7 +3359,7 @@ var_7 = byte ptr -7 var_6 = word ptr -6 var_4 = word ptr -4 var_2 = word ptr -2 -arg_0 = word ptr 4 +@@place = word ptr 4 arg_2 = word ptr 6 arg_4 = word ptr 8 @@ -3367,8 +3367,8 @@ arg_4 = word ptr 8 push si push di mov si, [bp+arg_4] - mov di, [bp+arg_0] - cmp word_106AC, di + mov di, [bp+@@place] + cmp _entered_place, di jnz short loc_B306 mov ax, 1 jmp short loc_B308 @@ -3379,7 +3379,7 @@ loc_B306: loc_B308: mov [bp+var_6], ax - cmp word_106AC, di + cmp _entered_place, di jnz short loc_B315 mov al, 0Fh jmp short loc_B317 @@ -3390,7 +3390,7 @@ loc_B315: loc_B317: mov [bp+var_7], al - cmp word_106AC, 0FFFFh + cmp _entered_place, -1 jnz short loc_B32A mov [bp+var_6], 1 mov [bp+var_7], 0Fh @@ -3606,7 +3606,7 @@ var_2 = word ptr -2 mov [bp+var_D], 0 mov [bp+var_E], 7 mov [bp+var_F], 0 - mov ax, word_106AC + mov ax, _entered_place imul ax, 14h add ax, 68h ; 'h' mov si, ax @@ -3812,7 +3812,7 @@ loc_B60C: push dx push si call sub_B1F6 - mov bx, word_106AC + mov bx, _entered_place shl bx, 3 mov al, [bp+var_E] mov ah, 0 @@ -3832,7 +3832,7 @@ loc_B64B: ; --------------------------------------------------------------------------- loc_B657: - mov bx, word_106AC + mov bx, _entered_place shl bx, 3 mov al, [bp+var_E] mov ah, 0 @@ -3871,7 +3871,7 @@ loc_B687: push dx push si call sub_B1F6 - mov bx, word_106AC + mov bx, _entered_place shl bx, 3 mov al, [bp+var_E] mov ah, 0 @@ -3907,13 +3907,13 @@ loc_B6D3: push dx push si call sub_B1F6 - mov bx, word_106AC + mov bx, _entered_place shl bx, 3 mov al, [bp+var_E] mov ah, 0 add bx, ax mov byte ptr [bx+21F0h], 0Eh - push word_106AC + push _entered_place call sub_B450 mov ax, [bp+var_2] mov bx, 10h @@ -3965,7 +3965,7 @@ var_1 = byte ptr -1 ; --------------------------------------------------------------------------- loc_B758: - mov bx, word_106AC + mov bx, _entered_place shl bx, 3 add bx, cx cmp byte ptr [bx+21F0h], 0Eh @@ -3992,7 +3992,7 @@ loc_B76E: ; --------------------------------------------------------------------------- loc_B78B: - mov bx, word_106AC + mov bx, _entered_place shl bx, 3 add bx, cx mov al, [di] @@ -4007,7 +4007,7 @@ loc_B79C: ; --------------------------------------------------------------------------- loc_B7A2: - mov bx, word_106AC + mov bx, _entered_place shl bx, 3 mov al, [bx+21F0h] mov [bp+var_1], al @@ -4016,7 +4016,7 @@ loc_B7A2: ; --------------------------------------------------------------------------- loc_B7B4: - mov bx, word_106AC + mov bx, _entered_place shl bx, 3 add bx, cx mov al, [bx+21F0h] @@ -4058,17 +4058,17 @@ sub_B7D2 proc near les bx, _resident cmp es:[bx+resident_t.story_stage], STAGE_NONE jnz short loc_B819 - mov word_106AC, 0FFFFh + mov _entered_place, -1 jmp short loc_B81F ; --------------------------------------------------------------------------- loc_B819: call sub_B03D - mov word_106AC, ax + mov _entered_place, ax loc_B81F: call sub_AFAC - cmp word_106AC, 0FFFFh + cmp _entered_place, -1 jnz short loc_B835 call sub_B429 push 2 @@ -6031,7 +6031,7 @@ byte_10636 db ? db 115 dup(?) byte_106AA db ? byte_106AB db ? -word_106AC dw ? +include th03/hiscore/regist[bss].asm db 2 dup(?) byte_106B0 db ? db 1281 dup(?) diff --git a/th04_maine.asm b/th04_maine.asm index a6368327..74daefff 100644 --- a/th04_maine.asm +++ b/th04_maine.asm @@ -3526,10 +3526,10 @@ sub_C316 endp sub_C3B2 proc near -var_2 = word ptr -2 +@@place = word ptr -2 enter 2, 0 - mov [bp+var_2], 9 + mov [bp+@@place], (SCOREDAT_PLACES - 1) jmp short loc_C40E ; --------------------------------------------------------------------------- @@ -3543,7 +3543,7 @@ loc_C3C2: add bx, cx mov al, es:[bx+resident_t.score_last] mov ah, 0 - mov bx, [bp+var_2] + mov bx, [bp+@@place] shl bx, 3 add bx, cx mov dl, _hi.score.g_points[bx] @@ -3555,7 +3555,7 @@ loc_C3C2: add bx, cx mov al, es:[bx+resident_t.score_last] mov ah, 0 - mov bx, [bp+var_2] + mov bx, [bp+@@place] shl bx, 3 add bx, cx mov dl, _hi.score.g_points[bx] @@ -3570,30 +3570,30 @@ loc_C407: jge short loc_C3C2 loc_C40B: - dec [bp+var_2] + dec [bp+@@place] loc_C40E: - cmp [bp+var_2], 0 + cmp [bp+@@place], 0 jge short loc_C3BD - mov byte_125B6, 0 + mov _entered_place, 0 jmp short loc_C430 ; --------------------------------------------------------------------------- loc_C41B: - cmp [bp+var_2], 9 + cmp [bp+@@place], (SCOREDAT_PLACES - 1) jnz short loc_C428 - mov byte_125B6, 0FFh + mov _entered_place, -1 leave retn ; --------------------------------------------------------------------------- loc_C428: - mov al, byte ptr [bp+var_2] + mov al, byte ptr [bp+@@place] inc al - mov byte_125B6, al + mov _entered_place, al loc_C430: - mov [bp+var_2], 8 + mov [bp+@@place], (SCOREDAT_PLACES - 2) jmp short loc_C489 ; --------------------------------------------------------------------------- @@ -3603,11 +3603,11 @@ loc_C437: ; --------------------------------------------------------------------------- loc_C43C: - mov bx, [bp+var_2] + mov bx, [bp+@@place] imul bx, (SCOREDAT_NAME_LEN + 1) add bx, cx mov al, _hi.score.g_name[0 * (SCOREDAT_NAME_LEN + 1)][bx] - mov bx, [bp+var_2] + mov bx, [bp+@@place] imul bx, (SCOREDAT_NAME_LEN + 1) add bx, cx mov _hi.score.g_name[1 * (SCOREDAT_NAME_LEN + 1)][bx], al @@ -3621,11 +3621,11 @@ loc_C455: ; --------------------------------------------------------------------------- loc_C45E: - mov bx, [bp+var_2] + mov bx, [bp+@@place] shl bx, 3 add bx, cx mov al, _hi.score.g_points[0 * SCORE_DIGITS][bx] - mov bx, [bp+var_2] + mov bx, [bp+@@place] shl bx, 3 add bx, cx mov _hi.score.g_points[1 * SCORE_DIGITS][bx], al @@ -3634,22 +3634,22 @@ loc_C45E: loc_C477: or cx, cx jge short loc_C45E - mov bx, [bp+var_2] + mov bx, [bp+@@place] mov al, _hi.score.g_stage+0[bx] mov _hi.score.g_stage+1[bx], al - dec [bp+var_2] + dec [bp+@@place] loc_C489: - mov al, byte_125B6 + mov al, _entered_place mov ah, 0 - cmp ax, [bp+var_2] + cmp ax, [bp+@@place] jle short loc_C437 mov cx, (SCOREDAT_NAME_LEN - 1) jmp short loc_C4AA ; --------------------------------------------------------------------------- loc_C498: - mov al, byte_125B6 + mov al, _entered_place mov ah, 0 imul ax, (SCOREDAT_NAME_LEN + 1) add ax, cx @@ -3669,7 +3669,7 @@ loc_C4B3: add bx, cx mov al, es:[bx+resident_t.score_last] add al, gb_0_ - mov dl, byte_125B6 + mov dl, _entered_place mov dh, 0 shl dx, 3 add dx, cx @@ -3683,7 +3683,7 @@ loc_C4D1: les bx, _resident cmp es:[bx+resident_t.end_sequence], ES_EXTRA jb short loc_C4EE - mov al, byte_125B6 + mov al, _entered_place mov ah, 0 mov bx, ax mov _hi.score.g_stage[bx], gs_ALL @@ -3695,7 +3695,7 @@ loc_C4EE: les bx, _resident mov al, es:[bx+resident_t.stage] add al, gb_1_ - mov dl, byte_125B6 + mov dl, _entered_place mov dh, 0 mov bx, dx mov _hi.score.g_stage[bx], al @@ -3743,7 +3743,7 @@ loc_C52E: loc_C531: mov di, ax - mov al, byte_125B6 + mov al, _entered_place mov ah, 0 cmp ax, si jnz short loc_C549 @@ -3849,7 +3849,7 @@ arg_4 = word ptr 8 push di mov si, [bp+arg_4] mov di, [bp+arg_2] - mov al, byte_125B6 + mov al, _entered_place mov ah, 0 cmp ax, si jnz short loc_C60E @@ -4058,7 +4058,7 @@ loc_C73C: push ax push 14 call graph_gaiji_puts - mov al, byte_125B6 + mov al, _entered_place mov ah, 0 cmp ax, si jnz short loc_C76E @@ -4264,7 +4264,7 @@ loc_C8CB: ; --------------------------------------------------------------------------- loc_C8D9: - mov byte_125B6, 0FFh + mov _entered_place, -1 mov al, byte ptr word_125B8 mov ah, 0 push ax @@ -4325,7 +4325,7 @@ loc_C95E: kajacall KAJA_SONG_PLAY push 2 call palette_black_in - cmp byte_125B6, 0FFh + cmp _entered_place, -1 jz loc_CB7F mov [bp+var_6], 0 jmp short loc_C9CB @@ -4457,9 +4457,9 @@ loc_CA9A: ; --------------------------------------------------------------------------- loc_CAA0: - mov al, byte_125B6 + mov al, _entered_place mov ah, 0 - imul ax, 9 + imul ax, (SCOREDAT_NAME_LEN + 1) mov bx, ax mov _hi.score.g_name[bx+si], g_EMPTY or si, si @@ -4475,7 +4475,7 @@ loc_CAB6: ; --------------------------------------------------------------------------- loc_CABD: - mov al, byte_125B6 + mov al, _entered_place mov ah, 0 imul ax, (SCOREDAT_NAME_LEN + 1) mov dl, [bp+var_A] @@ -4502,7 +4502,7 @@ loc_CAF4: inc si loc_CAF5: - mov al, byte_125B6 + mov al, _entered_place mov ah, 0 push ax push word_125B8 @@ -4512,7 +4512,7 @@ loc_CAF5: loc_CB03: test _key_det.lo, low INPUT_BOMB jz short loc_CB2C - mov al, byte_125B6 + mov al, _entered_place mov ah, 0 imul ax, (SCOREDAT_NAME_LEN + 1) mov bx, ax @@ -4522,7 +4522,7 @@ loc_CB03: dec si loc_CB1E: - mov al, byte_125B6 + mov al, _entered_place mov ah, 0 push ax push word_125B8 @@ -4934,7 +4934,7 @@ unk_124D3 db ? ; byte_124EF db ? db 2 dup(?) include th04/formats/scoredat[bss].asm -byte_125B6 db ? +include th03/hiscore/regist[bss].asm _hiscore_rank db ? word_125B8 dw ? diff --git a/th05_maine.asm b/th05_maine.asm index 876959b7..c900f4f3 100644 --- a/th05_maine.asm +++ b/th05_maine.asm @@ -1955,10 +1955,10 @@ sub_B6A3 endp sub_B730 proc near -var_2 = word ptr -2 +@@place = word ptr -2 enter 2, 0 - mov [bp+var_2], 4 + mov [bp+@@place], (SCOREDAT_PLACES - 1) jmp short loc_B78C ; --------------------------------------------------------------------------- @@ -1972,7 +1972,7 @@ loc_B740: add bx, cx mov al, es:[bx+resident_t.score_last] mov ah, 0 - mov bx, [bp+var_2] + mov bx, [bp+@@place] shl bx, 3 add bx, cx mov dl, _hi.score.g_points[bx] @@ -1984,7 +1984,7 @@ loc_B740: add bx, cx mov al, es:[bx+resident_t.score_last] mov ah, 0 - mov bx, [bp+var_2] + mov bx, [bp+@@place] shl bx, 3 add bx, cx mov dl, _hi.score.g_points[bx] @@ -1999,30 +1999,30 @@ loc_B785: jge short loc_B740 loc_B789: - dec [bp+var_2] + dec [bp+@@place] loc_B78C: - cmp [bp+var_2], 0 + cmp [bp+@@place], 0 jge short loc_B73B - mov byte_15176, 0 + mov _entered_place, 0 jmp short loc_B7AE ; --------------------------------------------------------------------------- loc_B799: - cmp [bp+var_2], 4 + cmp [bp+@@place], 4 jnz short loc_B7A6 - mov byte_15176, 0FFh + mov _entered_place, -1 leave retn ; --------------------------------------------------------------------------- loc_B7A6: - mov al, byte ptr [bp+var_2] + mov al, byte ptr [bp+@@place] inc al - mov byte_15176, al + mov _entered_place, al loc_B7AE: - mov [bp+var_2], 3 + mov [bp+@@place], 3 jmp short loc_B807 ; --------------------------------------------------------------------------- @@ -2032,11 +2032,11 @@ loc_B7B5: ; --------------------------------------------------------------------------- loc_B7BA: - mov bx, [bp+var_2] + mov bx, [bp+@@place] imul bx, (SCOREDAT_NAME_LEN + 1) add bx, cx mov al, _hi.score.g_name[0 * (SCOREDAT_NAME_LEN + 1)][bx] - mov bx, [bp+var_2] + mov bx, [bp+@@place] imul bx, (SCOREDAT_NAME_LEN + 1) add bx, cx mov _hi.score.g_name[1 * (SCOREDAT_NAME_LEN + 1)][bx], al @@ -2050,11 +2050,11 @@ loc_B7D3: ; --------------------------------------------------------------------------- loc_B7DC: - mov bx, [bp+var_2] + mov bx, [bp+@@place] shl bx, 3 add bx, cx mov al, _hi.score.g_points[0 * SCORE_DIGITS][bx] - mov bx, [bp+var_2] + mov bx, [bp+@@place] shl bx, 3 add bx, cx mov _hi.score.g_points[1 * SCORE_DIGITS][bx], al @@ -2063,22 +2063,22 @@ loc_B7DC: loc_B7F5: or cx, cx jge short loc_B7DC - mov bx, [bp+var_2] + mov bx, [bp+@@place] mov al, _hi.score.g_stage+0[bx] mov _hi.score.g_stage+1[bx], al - dec [bp+var_2] + dec [bp+@@place] loc_B807: - mov al, byte_15176 + mov al, _entered_place mov ah, 0 - cmp ax, [bp+var_2] + cmp ax, [bp+@@place] jle short loc_B7B5 mov cx, (SCOREDAT_NAME_LEN - 1) jmp short loc_B828 ; --------------------------------------------------------------------------- loc_B816: - mov al, byte_15176 + mov al, _entered_place mov ah, 0 imul ax, (SCOREDAT_NAME_LEN + 1) add ax, cx @@ -2098,7 +2098,7 @@ loc_B831: add bx, cx mov al, es:[bx+resident_t.score_last] add al, gb_0_ - mov dl, byte_15176 + mov dl, _entered_place mov dh, 0 shl dx, 3 add dx, cx @@ -2112,7 +2112,7 @@ loc_B84F: les bx, _resident cmp es:[bx+resident_t.end_sequence], ES_EXTRA jb short loc_B86C - mov al, byte_15176 + mov al, _entered_place mov ah, 0 mov bx, ax mov _hi.score.g_stage[bx], gs_ALL @@ -2126,7 +2126,7 @@ loc_B86C: les bx, _resident mov al, es:[bx+resident_t.stage] add al, gb_1_ - mov dl, byte_15176 + mov dl, _entered_place mov dh, 0 mov bx, dx mov _hi.score.g_stage[bx], al @@ -2135,7 +2135,7 @@ loc_B86C: ; --------------------------------------------------------------------------- loc_B88B: - mov al, byte_15176 + mov al, _entered_place mov ah, 0 mov bx, ax mov _hi.score.g_stage[bx], gb_1_ @@ -2227,7 +2227,7 @@ loc_B907: mov [bp+@@y], ax loc_B90A: - mov al, byte_15176 + mov al, _entered_place mov ah, 0 cmp ax, si jnz short loc_B922 @@ -2331,7 +2331,7 @@ arg_4 = word ptr 8 push si push di mov si, [bp+arg_4] - mov al, byte_15176 + mov al, _entered_place mov ah, 0 cmp ax, si jnz short loc_B9E1 @@ -2719,7 +2719,7 @@ loc_BC67: mov ah, 0 cmp ax, [bp+arg_0] jnz short loc_BC8F - mov al, byte_15176 + mov al, _entered_place mov ah, 0 cmp ax, si jz short loc_BCC4 @@ -3072,7 +3072,7 @@ loc_BEC8: loc_BECC: cmp di, 8 jl short loc_BE83 - mov al, byte_15176 + mov al, _entered_place mov ah, 0 push ax push word ptr playchar_15178 @@ -3306,9 +3306,9 @@ loc_C0CC: jnb short loc_C141 inc byte ptr [si] mov word ptr [si+14h], 0 - mov al, byte_15176 + mov al, _entered_place mov ah, 0 - imul ax, 9 + imul ax, (SCOREDAT_NAME_LEN + 1) mov dl, [si+1] mov bx, ax mov _hi.score.g_name[bx+di], dl @@ -3531,7 +3531,7 @@ loc_C2AD: ; --------------------------------------------------------------------------- loc_C2BB: - mov byte_15176, 0FFh + mov _entered_place, -1 mov al, playchar_15178 mov ah, 0 push ax @@ -3556,16 +3556,16 @@ loc_C307: kajacall KAJA_SONG_PLAY push 2 call palette_black_in - cmp byte_15176, 0FFh + cmp _entered_place, -1 jz loc_C5C3 - mov al, byte_15176 + mov al, _entered_place mov ah, 0 push ax push word ptr playchar_15178 push 0 call sub_BA84 graph_accesspage 0 - mov al, byte_15176 + mov al, _entered_place mov ah, 0 push ax push word ptr playchar_15178 @@ -3699,9 +3699,9 @@ loc_C448: ; --------------------------------------------------------------------------- loc_C469: - mov al, byte_15176 + mov al, _entered_place mov ah, 0 - imul ax, 9 + imul ax, (SCOREDAT_NAME_LEN + 1) add ax, word_11622 mov bx, ax mov _hi.score.g_name[bx], g_EMPTY @@ -3743,7 +3743,7 @@ loc_C4D4: call snd_se_play pascal, 11 push si push di - mov al, byte_15176 + mov al, _entered_place mov ah, 0 push ax push word ptr playchar_15178 @@ -3772,9 +3772,9 @@ loc_C512: loc_C516: test _key_det.lo, low INPUT_BOMB jz short loc_C576 - mov al, byte_15176 + mov al, _entered_place mov ah, 0 - imul ax, 9 + imul ax, (SCOREDAT_NAME_LEN + 1) add ax, word_11622 mov bx, ax mov _hi.score.g_name[bx], g_EMPTY @@ -8093,7 +8093,7 @@ playchar_15018 db ? db ? include th04/formats/scoredat[bss].asm db 252 dup(?) -byte_15176 db ? +include th03/hiscore/regist[bss].asm _hiscore_rank db ? playchar_15178 db ? db 3 dup(?)