From 9e8fa66a7ab749e11a7a19e71c3f598e7faa8288 Mon Sep 17 00:00:00 2001 From: nmlgc Date: Sun, 29 Dec 2019 17:47:23 +0100 Subject: [PATCH] [Reverse-engineering] [th04/th05] Stage display in the High Score menu Part of P0064, funded by Touhou Patch Center. --- th04/gaiji/gaiji.inc | 3 +- th04/hiscore/hiscore.h | 1 + th04/hiscore/hiscore_stage_put.asm | 47 +++++++++++++++++++++ th04_op.asm | 67 ++++-------------------------- th05_op.asm | 55 +----------------------- 5 files changed, 60 insertions(+), 113 deletions(-) create mode 100644 th04/hiscore/hiscore.h create mode 100644 th04/hiscore/hiscore_stage_put.asm diff --git a/th04/gaiji/gaiji.inc b/th04/gaiji/gaiji.inc index dae24012..e2e31c94 100644 --- a/th04/gaiji/gaiji.inc +++ b/th04/gaiji/gaiji.inc @@ -7,4 +7,5 @@ include th03/gaiji/bar.inc include th02/gaiji/boldfont.inc gs_DOT = 0C4h gs_ALL = 0E9h -g_HISCORE_EMPTY = 0EFh +g_HISCORE_STAGE_EMPTY = 0EFh +g_NONE = 0FFh diff --git a/th04/hiscore/hiscore.h b/th04/hiscore/hiscore.h new file mode 100644 index 00000000..7dbcce22 --- /dev/null +++ b/th04/hiscore/hiscore.h @@ -0,0 +1 @@ +void pascal near score_stage_put(int x, int y, unsigned int g_stage); diff --git a/th04/hiscore/hiscore_stage_put.asm b/th04/hiscore/hiscore_stage_put.asm new file mode 100644 index 00000000..74466e40 --- /dev/null +++ b/th04/hiscore/hiscore_stage_put.asm @@ -0,0 +1,47 @@ +public HISCORE_STAGE_PUT +hiscore_stage_put proc near + +@@g_stage = word ptr 4 +@@y = word ptr 6 +@@x = word ptr 8 + + push bp + mov bp, sp + push si + push di + mov si, [bp+@@x] + mov di, [bp+@@y] + cmp [bp+@@g_stage], g_NONE + jz short @@put_empty + lea ax, [si+2] + push ax + lea ax, [di+2] + push ax + push [bp+@@g_stage] + push 14 + call graph_gaiji_putc + push si + push di + push [bp+@@g_stage] + jmp short @@put_main +; --------------------------------------------------------------------------- + +@@put_empty: + lea ax, [si+2] + push ax + lea ax, [di+2] + push ax + push (g_HISCORE_STAGE_EMPTY shl 16) or 14 + call graph_gaiji_putc + push si + push di + push g_HISCORE_STAGE_EMPTY + +@@put_main: + push 7 + call graph_gaiji_putc + pop di + pop si + pop bp + retn 6 +hiscore_stage_put endp diff --git a/th04_op.asm b/th04_op.asm index 43dc4ffe..a5d52702 100644 --- a/th04_op.asm +++ b/th04_op.asm @@ -2304,58 +2304,7 @@ loc_C899: retn 4 sub_C79E endp - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_C8A5 proc near - -@@gaiji = word ptr 4 -@@y = word ptr 6 -@@x = word ptr 8 - - push bp - mov bp, sp - push si - push di - mov si, [bp+@@x] - mov di, [bp+@@y] - cmp [bp+@@gaiji], 0FFh - jz short loc_C8D0 - lea ax, [si+2] - push ax - lea ax, [di+2] - push ax - push [bp+@@gaiji] - push 14 - call graph_gaiji_putc - push si - push di - push [bp+@@gaiji] - jmp short loc_C8E8 -; --------------------------------------------------------------------------- - -loc_C8D0: - lea ax, [si+2] - push ax - lea ax, [di+2] - push ax - push (g_HISCORE_EMPTY shl 16) or 14 - call graph_gaiji_putc - push si - push di - push g_HISCORE_EMPTY - -loc_C8E8: - push 7 - call graph_gaiji_putc - pop di - pop si - pop bp - retn 6 -sub_C8A5 endp - +include th04/hiscore/hiscore_stage_put.asm ; =============== S U B R O U T I N E ======================================= @@ -2410,12 +2359,12 @@ arg_0 = word ptr 4 call graph_gaiji_puts push 600000h call sub_C79E - push 1240060h + push (292 shl 16) or 96 mov al, _hi_reimu.score.g_stage[si] mov ah, 0 push ax - call sub_C8A5 - push 2580060h + call hiscore_stage_put + push (600 shl 16) or 96 jmp loc_CA0A ; --------------------------------------------------------------------------- @@ -2469,20 +2418,20 @@ loc_C989: push di push si call sub_C79E - push 124h + push 292 push di mov al, _hi_reimu.score.g_stage[si] mov ah, 0 push ax - call sub_C8A5 - push 258h + call hiscore_stage_put + push 600 push di loc_CA0A: mov al, _hi_marisa.score.g_stage[si] mov ah, 0 push ax - call sub_C8A5 + call hiscore_stage_put pop di pop si pop bp diff --git a/th05_op.asm b/th05_op.asm index 36707b5a..c5eab38c 100644 --- a/th05_op.asm +++ b/th05_op.asm @@ -2751,58 +2751,7 @@ loc_CAA4: retn 6 sub_CA1B endp - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_CAB0 proc near - -@@gaiji = word ptr 4 -@@y = word ptr 6 -@@x = word ptr 8 - - push bp - mov bp, sp - push si - push di - mov si, [bp+@@x] - mov di, [bp+@@y] - cmp [bp+@@gaiji], 0FFh - jz short loc_CADB - lea ax, [si+2] - push ax - lea ax, [di+2] - push ax - push [bp+@@gaiji] - push 14 - call graph_gaiji_putc - push si - push di - push [bp+@@gaiji] - jmp short loc_CAF3 -; --------------------------------------------------------------------------- - -loc_CADB: - lea ax, [si+2] - push ax - lea ax, [di+2] - push ax - push (g_HISCORE_EMPTY shl 16) or 14 - call graph_gaiji_putc - push si - push di - push g_HISCORE_EMPTY - -loc_CAF3: - push 7 - call graph_gaiji_putc - pop di - pop si - pop bp - retn 6 -sub_CAB0 endp - +include th04/hiscore/hiscore_stage_put.asm ; =============== S U B R O U T I N E ======================================= @@ -2930,7 +2879,7 @@ loc_CB74: mov al, _hi.score.g_stage[bx] mov ah, 0 push ax - call sub_CAB0 + call hiscore_stage_put pop di pop si leave