From 80cec5b2318da7a36a863138f9834d28d4401bd1 Mon Sep 17 00:00:00 2001 From: nmlgc Date: Sat, 28 Dec 2019 21:20:48 +0100 Subject: [PATCH] [Reverse-engineering] [th03] 1P/2P selection gaiji cursor Part of P0064, funded by Touhou Patch Center. --- pc98.h | 3 +- pc98.inc | 3 +- th03/gaiji/gaiji.h | 16 +++++++++ th03/gaiji/gaiji.inc | 19 ++++++++++ th03/strings/p_cursor[data].asm | 7 ++++ th03/th03.inc | 1 + th03_op.asm | 61 ++++++++++++++------------------- 7 files changed, 72 insertions(+), 38 deletions(-) create mode 100644 th03/gaiji/gaiji.h create mode 100644 th03/gaiji/gaiji.inc create mode 100644 th03/strings/p_cursor[data].asm diff --git a/pc98.h b/pc98.h index 1ddfa940..a82049a0 100644 --- a/pc98.h +++ b/pc98.h @@ -4,7 +4,8 @@ /// Text /// ---- -#define GAIJI_TRAM_W 2 +#define GAIJI_W 16 +#define GAIJI_TRAM_W (GAIJI_W / 8) #define GLYPH_HEIGHT 16 /// ---- diff --git a/pc98.inc b/pc98.inc index baf29f8f..b1eee647 100644 --- a/pc98.inc +++ b/pc98.inc @@ -4,7 +4,8 @@ ; Text ; ==== -GAIJI_TRAM_W = 2 +GAIJI_W = 16 +GAIJI_TRAM_W = (GAIJI_W / 8) GLYPH_HEIGHT = 16 ; ==== diff --git a/th03/gaiji/gaiji.h b/th03/gaiji/gaiji.h new file mode 100644 index 00000000..55e8ba31 --- /dev/null +++ b/th03/gaiji/gaiji.h @@ -0,0 +1,16 @@ +// ReC98 +// ----- +// Gaiji available to TH03 + +// 1P/2P selection cursor +#define gc_GAIJI_W 2 +typedef enum { + gc_P1_TOP_1 = 0x12, + gc_P1_TOP_2 = 0x13, + gc_P1_BOTTOM_1 = 0x14, + gc_P1_BOTTOM_2 = 0x15, + gc_P2_TOP_1 = 0x16, + gc_P2_TOP_2 = 0x17, + gc_P2_BOTTOM_1 = 0x18, + gc_P2_BOTTOM_2 = 0x19, +} gaiji_cursor_t; diff --git a/th03/gaiji/gaiji.inc b/th03/gaiji/gaiji.inc new file mode 100644 index 00000000..b6e2c1de --- /dev/null +++ b/th03/gaiji/gaiji.inc @@ -0,0 +1,19 @@ +; ReC98 +; ----- +; Gaiji available to TH03 + +; 1P/2P selection cursor +; ---------------------- +gc_GAIJI_W = 2 + +gc_P1_TOP_1 = 012h +gc_P1_TOP_2 = 013h +gc_P1_BOTTOM_1 = 014h +gc_P1_BOTTOM_2 = 015h +gc_P2_TOP_1 = 016h +gc_P2_TOP_2 = 017h +gc_P2_BOTTOM_1 = 018h +gc_P2_BOTTOM_2 = 019h +; ---------------------- + +include th03/gaiji/bar.inc diff --git a/th03/strings/p_cursor[data].asm b/th03/strings/p_cursor[data].asm new file mode 100644 index 00000000..be01e020 --- /dev/null +++ b/th03/strings/p_cursor[data].asm @@ -0,0 +1,7 @@ +public _P_CURSOR_TOP, _P_CURSOR_BOTTOM +_P_CURSOR_TOP label byte + db gc_P1_TOP_1, gc_P1_TOP_2, 0 + db gc_P2_TOP_1, gc_P2_TOP_2, 0 +_P_CURSOR_BOTTOM label byte + db gc_P1_BOTTOM_1, gc_P1_BOTTOM_2, 0 + db gc_P2_BOTTOM_1, gc_P2_BOTTOM_2, 0 diff --git a/th03/th03.inc b/th03/th03.inc index 46e1d6a6..d1b1c594 100644 --- a/th03/th03.inc +++ b/th03/th03.inc @@ -1,6 +1,7 @@ GAME = 3 include defconv.inc include th03/mem.inc +include th03/gaiji/gaiji.inc include th03/math/randring.inc include th03/hardware/input.inc include th03/chars/chars.inc diff --git a/th03_op.asm b/th03_op.asm index 20fc2624..18f289b3 100644 --- a/th03_op.asm +++ b/th03_op.asm @@ -3183,11 +3183,11 @@ sub_B747 endp ; =============== S U B R O U T I N E ======================================= ; Attributes: bp-based frame +public P_CURSOR_PUT +p_cursor_put proc near -sub_B8A6 proc near - -var_2 = word ptr -2 -arg_0 = byte ptr 4 +@@y = word ptr -2 +@@col = byte ptr 4 arg_2 = word ptr 6 enter 2, 0 @@ -3197,36 +3197,36 @@ arg_2 = word ptr 6 mov ax, si shl ax, 4 shl ax, 3 - add ax, 0F0h + add ax, 240 mov di, ax mov al, [si+2468h] cbw - imul ax, 14h - add ax, 80h - mov [bp+var_2], ax + imul ax, 20 + add ax, 128 + mov [bp+@@y], ax push di push ax - push 10h + push GAIJI_W push ds mov ax, si - imul ax, 3 - add ax, 0A4Dh + imul ax, (gc_GAIJI_W + 1) + add ax, offset _P_CURSOR_TOP push ax - mov al, [bp+arg_0] + mov al, [bp+@@col] mov ah, 0 push ax call graph_gaiji_puts push di - mov ax, [bp+var_2] - add ax, 10h + mov ax, [bp+@@y] + add ax, GLYPH_HEIGHT push ax - push 10h + push GAIJI_W push ds mov ax, si - imul ax, 3 - add ax, 0A53h + imul ax, (gc_GAIJI_W + 1) + add ax, offset _P_CURSOR_BOTTOM push ax - mov al, [bp+arg_0] + mov al, [bp+@@col] mov ah, 0 push ax call graph_gaiji_puts @@ -3234,7 +3234,7 @@ arg_2 = word ptr 6 pop si leave retn 4 -sub_B8A6 endp +p_cursor_put endp ; =============== S U B R O U T I N E ======================================= @@ -3474,7 +3474,7 @@ loc_BB22: loc_BB24: push ax - call sub_B8A6 + call p_cursor_put push 1 cmp byte_FC5B, 0 jz short loc_BB35 @@ -3487,7 +3487,7 @@ loc_BB35: loc_BB37: push ax - call sub_B8A6 + call p_cursor_put call _input_reset_sense_key_held call _input_mode push _input_mp_p1 @@ -3615,7 +3615,7 @@ loc_BC8E: loc_BC90: push ax - call sub_B8A6 + call p_cursor_put cmp byte_FC5A, 0 jz short loc_BCAE push 1 @@ -3630,7 +3630,7 @@ loc_BCA8: loc_BCAA: push ax - call sub_B8A6 + call p_cursor_put loc_BCAE: push _input_sp @@ -3748,7 +3748,7 @@ loc_BDDD: loc_BDDF: push ax - call sub_B8A6 + call p_cursor_put call _input_reset_sense_key_held call _input_mode push _input_sp @@ -4108,18 +4108,7 @@ off_E1FE dd a00sl_cd2 db 5 db 5 db 3 - db 12h - db 13h - db 0 - db 16h - db 17h - db 0 - db 14h - db 15h - db 0 - db 18h - db 19h - db 0 +include th03/strings/p_cursor[data].asm db 0 db 0 a00sl_cd2 db '00SL.CD2',0