From f0be7dadf4b950558142fb2aa1e19e398ae9240d Mon Sep 17 00:00:00 2001 From: nmlgc Date: Sun, 22 Feb 2015 22:33:07 +0100 Subject: [PATCH] [Reverse-engineering] [th02] Keyboard input Don't really understand the other games yet because they start introducing joystick support and TH03 has multiplayer and then there are these master.lib modifications that don't really make any sense to me, especially when you add that TH04 seemingly does not read js_stat *at all*, yet still works just fine with a gamepad and... urgh. --- th02/hardware/input.inc | 13 ++ th02/hardware/input_sense.asm | 117 ++++++++++++++ th02/hardware/input_sense[bss].asm | 2 + th02/th02.asm | 1 + th02_main.asm | 249 +++++++---------------------- th02_maine.asm | 171 ++------------------ th02_op.asm | 221 +++++-------------------- 7 files changed, 248 insertions(+), 526 deletions(-) create mode 100644 th02/hardware/input.inc create mode 100644 th02/hardware/input_sense.asm create mode 100644 th02/hardware/input_sense[bss].asm diff --git a/th02/hardware/input.inc b/th02/hardware/input.inc new file mode 100644 index 00000000..85f7351d --- /dev/null +++ b/th02/hardware/input.inc @@ -0,0 +1,13 @@ +INPUT_UP = 1 +INPUT_DOWN = 2 +INPUT_LEFT = 4 +INPUT_RIGHT = 8 +INPUT_SHOT = 10h +INPUT_BOMB = 20h +INPUT_CANCEL = 40h +INPUT_OK = 80h +INPUT_Q = 100h +INPUT_UP_LEFT = 1000h +INPUT_UP_RIGHT = 2000h +INPUT_DOWN_LEFT = 4000h +INPUT_DOWN_RIGHT = 8000h diff --git a/th02/hardware/input_sense.asm b/th02/hardware/input_sense.asm new file mode 100644 index 00000000..e7d4a5d5 --- /dev/null +++ b/th02/hardware/input_sense.asm @@ -0,0 +1,117 @@ +; void DEFCONV input_sense(void); +proc_defconv input_sense + mov _input, 0 + mov al, 7 + mov ah, 4 + int 18h + mov bh, ah + mov al, 8 + mov ah, 4 + int 18h + test bh, 4 + jnz short @@up + test ah, 8 + jz short @@left? + +@@up: + or _input, INPUT_UP + +@@left?: + test bh, 8 + jnz short @@left + test ah, 40h + jz short @@num7? + +@@left: + or _input, INPUT_LEFT + +@@num7?: + test ah, 4 + jz short @@num9? + or _input, INPUT_UP_LEFT + +@@num9?: + test ah, 10h + jz short @@down? + or _input, INPUT_UP_RIGHT + +@@down?: + mov al, 9 + mov ah, 4 + int 18h + test bh, 20h + jnz short @@down + test ah, 8 + jz short @@right? + +@@down: + or _input, INPUT_DOWN + +@@right?: + test bh, 10h + jnz short @@right + test ah, 1 + jz short @@num1? + +@@right: + or _input, INPUT_RIGHT + +@@num1?: + test ah, 4 + jz short @@num3? + or _input, INPUT_DOWN_LEFT + +@@num3?: + test ah, 10h + jz short @@z? + or _input, INPUT_DOWN_RIGHT + +@@z?: + mov al, 5 + mov ah, 4 + int 18h + test ah, 2 + jz short @@x? + or _input, INPUT_SHOT + +@@x?: + test ah, 4 + jz short @@esc? + or _input, INPUT_BOMB + +@@esc?: + mov al, 0 + mov ah, 4 + int 18h + test ah, 1 + jz short @@return? + or _input, INPUT_CANCEL + +@@return?: + mov al, 3 + mov ah, 4 + int 18h + test ah, 10h + jz short @@q? + or _input, INPUT_OK + +@@q?: + mov al, 2 + mov ah, 4 + int 18h + test ah, 1 + jz short @@space? + or _input, INPUT_Q + +@@space?: + mov al, 6 + mov ah, 4 + int 18h + test ah, 10h + jz short @@ret + or _input, INPUT_SHOT + +@@ret: + retf +endp_defconv + even diff --git a/th02/hardware/input_sense[bss].asm b/th02/hardware/input_sense[bss].asm new file mode 100644 index 00000000..a6b3d14f --- /dev/null +++ b/th02/hardware/input_sense[bss].asm @@ -0,0 +1,2 @@ +public _input +_input dw ? diff --git a/th02/th02.asm b/th02/th02.asm index 1654f3de..cf16b4f4 100644 --- a/th02/th02.asm +++ b/th02/th02.asm @@ -1,3 +1,4 @@ GAME = 2 include defconv_c.inc +include th02/hardware/input.inc include th02/frame_delay_macro.asm diff --git a/th02_main.asm b/th02_main.asm index 5584bc82..a47ad471 100644 --- a/th02_main.asm +++ b/th02_main.asm @@ -2001,7 +2001,7 @@ loc_B237: call gaiji_putsa pascal, (18 shl 16) + 12, ds, offset gDEMO_PLAY, TX_YELLOW + TX_BLINK loc_B249: - mov word_1FFA8, 0 + mov _input, 0 loc_B24F: call farfp_1F4A4 @@ -2615,20 +2615,20 @@ loc_BA33: loc_BA3D: push TX_WHITE call gaiji_putsa - call sub_F62E + call _input_sense inc si cmp [bp+var_1], 0 jnz short loc_BA5C - cmp word_1FFA8, 0 + cmp _input, 0 jnz short loc_BA5C mov [bp+var_1], 1 loc_BA5C: cmp [bp+var_1], 1 jnz loc_BB30 - test byte ptr word_1FFA8, 1 + test byte ptr _input, 1 jnz short loc_BA72 - test byte ptr word_1FFA8, 2 + test byte ptr _input, 2 jz short loc_BAC8 loc_BA72: @@ -2662,9 +2662,9 @@ loc_BA98: mov [bp+var_1], 0 loc_BAC8: - test byte ptr word_1FFA8, 80h + test byte ptr _input, INPUT_OK jnz short loc_BAD6 - test byte ptr word_1FFA8, 10h + test byte ptr _input, INPUT_SHOT jz short loc_BB24 loc_BAD6: @@ -2682,7 +2682,7 @@ loc_BAE3: mov byte_1DB74, 0 loc_BB24: - test byte ptr word_1FFA8, 40h + test byte ptr _input, INPUT_CANCEL jz loc_BCA4 jmp loc_BCA0 ; --------------------------------------------------------------------------- @@ -2690,11 +2690,11 @@ loc_BB24: loc_BB30: cmp [bp+var_1], 2 jnz short loc_BB9D - cmp word_1FFA8, 0 + cmp _input, 0 jnz loc_BCA4 mov PaletteTone, 64h ; 'd' call far ptr palette_show - mov word_1FFA8, 0 + mov _input, 0 call gaiji_putsa pascal, (18 shl 16) + 12, ds, offset g11SPACES, TX_WHITE call gaiji_putsa pascal, (17 shl 16) + 14, ds, offset g11SPACES, TX_WHITE call gaiji_putsa pascal, (17 shl 16) + 15, ds, offset g11SPACES, TX_WHITE @@ -2706,7 +2706,7 @@ loc_BB30: loc_BB9D: cmp [bp+var_1], 3 jnz short loc_BBB2 - cmp word_1FFA8, 0 + cmp _input, 0 jnz loc_BCA4 inc [bp+var_1] jmp loc_BCA4 @@ -2715,9 +2715,9 @@ loc_BB9D: loc_BBB2: cmp [bp+var_1], 4 jnz loc_BCA4 - test byte ptr word_1FFA8, 1 + test byte ptr _input, 1 jnz short loc_BBC8 - test byte ptr word_1FFA8, 2 + test byte ptr _input, 2 jz short loc_BC1E loc_BBC8: @@ -2751,9 +2751,9 @@ loc_BBEE: mov [bp+var_1], 3 loc_BC1E: - test byte ptr word_1FFA8, 80h + test byte ptr _input, INPUT_OK jnz short loc_BC2C - test byte ptr word_1FFA8, 10h + test byte ptr _input, INPUT_SHOT jz short loc_BC99 loc_BC2C: @@ -2774,7 +2774,7 @@ loc_BC94: ; --------------------------------------------------------------------------- loc_BC99: - test byte ptr word_1FFA8, 40h + test byte ptr _input, INPUT_CANCEL jz short loc_BCA4 loc_BCA0: @@ -2906,7 +2906,7 @@ loc_BDA2: mov dx, word_20344 mov bx, ax mov ss:[bx], dx - call sub_F62E + call _input_sense les bx, dword_2026C cmp byte ptr es:[bx+27h], 0 jz short loc_BDCC @@ -2928,7 +2928,7 @@ loc_BDE8: call farfp_23A76 call sub_10BC6 call sub_41AA - test byte ptr word_1FFA8, 40h + test byte ptr _input, INPUT_CANCEL jz short loc_BE0F call sub_B9E2 or ax, ax @@ -3367,20 +3367,20 @@ sub_C13E endp sub_C1E4 proc far push bp mov bp, sp - cmp word_1FFA8, 0 + cmp _input, 0 jnz short loc_C20B mov ax, word_1DB86 add ax, ax les bx, dword_1F4A8 add bx, ax mov ax, es:[bx] - mov word_1FFA8, ax + mov _input, ax inc word_1DB86 cmp word_1DB86, 1B26h jl short loc_C222 loc_C20B: - mov word_1FFA8, 0 + mov _input, 0 push 0Ah call palette_black_out mov byte_20607, 1 @@ -3605,15 +3605,15 @@ loc_C3E5: jge loc_C348 push 1Eh call frame_delay - mov word_1FFA8, 0 + mov _input, 0 jmp short loc_C400 ; --------------------------------------------------------------------------- loc_C3FB: - call sub_F62E + call _input_sense loc_C400: - cmp word_1FFA8, 0 + cmp _input, 0 jz short loc_C3FB call sub_FBE9 call sub_1C9FE @@ -3637,10 +3637,10 @@ loc_C400: mov di, 1 loc_C47A: - call sub_F62E + call _input_sense cmp [bp+var_2], 0 jnz short loc_C493 - cmp word_1FFA8, 0 + cmp _input, 0 jnz short loc_C493 mov [bp+var_2], 1 jmp short loc_C4A5 @@ -3649,19 +3649,19 @@ loc_C47A: loc_C493: cmp [bp+var_2], 1 jnz short loc_C4A5 - cmp word_1FFA8, 0 + cmp _input, 0 jz short loc_C4A5 mov [bp+var_2], 2 loc_C4A5: - test byte ptr word_1FFA8, 1 + test byte ptr _input, 1 jz short loc_C4B8 mov di, 1 push 0E500E1h call sub_C2F4 loc_C4B8: - test byte ptr word_1FFA8, 2 + test byte ptr _input, 2 jz short loc_C4CA xor di, di push 0E100E5h @@ -3670,11 +3670,11 @@ loc_C4B8: loc_C4CA: cmp [bp+var_2], 2 jnz short loc_C4E5 - test byte ptr word_1FFA8, 10h + test byte ptr _input, INPUT_SHOT jnz short loc_C4EE - test byte ptr word_1FFA8, 80h + test byte ptr _input, INPUT_OK jnz short loc_C4EE - test byte ptr word_1FFA8, 40h + test byte ptr _input, INPUT_CANCEL jnz short loc_C4EE loc_C4E5: @@ -3684,7 +3684,7 @@ loc_C4E5: ; --------------------------------------------------------------------------- loc_C4EE: - test byte ptr word_1FFA8, 40h + test byte ptr _input, INPUT_CANCEL jz short loc_C4F7 loc_C4F5: @@ -9439,7 +9439,7 @@ loc_F1F2: loc_F1F7: cmp byte_20604, 0 jnz loc_F43E - mov ax, word_1FFA8 + mov ax, _input and ax, 0F000h cmp ax, 4000h jz loc_F29E @@ -9456,7 +9456,7 @@ loc_F21B: jz loc_F2A4 loc_F222: - mov bx, word_1FFA8 + mov bx, _input and bx, 0Fh dec bx cmp bx, 9 @@ -9601,7 +9601,7 @@ loc_F2FB: sub ax, di mov bx, word_205F4 mov [bx], ax - test byte ptr word_1FFA8, 10h + test byte ptr _input, INPUT_SHOT jz short loc_F349 cmp byte_1EB0D, 0FFh jnz short loc_F336 @@ -9671,7 +9671,7 @@ loc_F3B3: mov byte_1E519, al mov al, byte_2060F mov byte_1E51A, al - test word_1FFA8, 0C002h + test _input, INPUT_DOWN or INPUT_DOWN_LEFT or INPUT_DOWN_RIGHT jz short loc_F3F1 mov al, byte_20610 add al, 5 @@ -9684,7 +9684,7 @@ loc_F3B3: ; --------------------------------------------------------------------------- loc_F3F1: - test word_1FFA8, 0F00Fh + test _input, INPUT_UP or INPUT_DOWN or INPUT_LEFT or INPUT_RIGHT or INPUT_UP_LEFT or INPUT_UP_RIGHT or INPUT_DOWN_LEFT or INPUT_DOWN_RIGHT jnz short loc_F417 mov al, byte_20610 add al, 0FBh @@ -9712,7 +9712,7 @@ loc_F426: dec byte_22D4B loc_F434: - test byte ptr word_1FFA8, 20h + test byte ptr _input, INPUT_BOMB jz short loc_F43E call sub_E280 @@ -9973,144 +9973,7 @@ sub_F5B1 endp include th02/frame_delay.asm db 0 - -; =============== S U B R O U T I N E ======================================= - - -sub_F62E proc far - mov word_1FFA8, 0 - mov al, 7 - mov ah, 4 - int 18h ; TRANSFER TO ROM BASIC - ; causes transfer to ROM-based BASIC (IBM-PC) - ; often reboots a compatible; often has no effect at all - mov bh, ah - mov al, 8 - mov ah, 4 - int 18h ; TRANSFER TO ROM BASIC - ; causes transfer to ROM-based BASIC (IBM-PC) - ; often reboots a compatible; often has no effect at all - test bh, 4 - jnz short loc_F64C - test ah, 8 - jz short loc_F651 - -loc_F64C: - or word_1FFA8, 1 - -loc_F651: - test bh, 8 - jnz short loc_F65B - test ah, 40h - jz short loc_F660 - -loc_F65B: - or word_1FFA8, 4 - -loc_F660: - test ah, 4 - jz short loc_F66B - or word_1FFA8, 1000h - -loc_F66B: - test ah, 10h - jz short loc_F676 - or word_1FFA8, 2000h - -loc_F676: - mov al, 9 - mov ah, 4 - int 18h ; TRANSFER TO ROM BASIC - ; causes transfer to ROM-based BASIC (IBM-PC) - ; often reboots a compatible; often has no effect at all - test bh, 20h - jnz short loc_F686 - test ah, 8 - jz short loc_F68B - -loc_F686: - or word_1FFA8, 2 - -loc_F68B: - test bh, 10h - jnz short loc_F695 - test ah, 1 - jz short loc_F69A - -loc_F695: - or word_1FFA8, 8 - -loc_F69A: - test ah, 4 - jz short loc_F6A5 - or word_1FFA8, 4000h - -loc_F6A5: - test ah, 10h - jz short loc_F6B0 - or word_1FFA8, 8000h - -loc_F6B0: - mov al, 5 - mov ah, 4 - int 18h ; TRANSFER TO ROM BASIC - ; causes transfer to ROM-based BASIC (IBM-PC) - ; often reboots a compatible; often has no effect at all - test ah, 2 - jz short loc_F6C0 - or word_1FFA8, 10h - -loc_F6C0: - test ah, 4 - jz short loc_F6CA - or word_1FFA8, 20h - -loc_F6CA: - mov al, 0 - mov ah, 4 - int 18h ; TRANSFER TO ROM BASIC - ; causes transfer to ROM-based BASIC (IBM-PC) - ; often reboots a compatible; often has no effect at all - test ah, 1 - jz short loc_F6DA - or word_1FFA8, 40h - -loc_F6DA: - mov al, 3 - mov ah, 4 - int 18h ; TRANSFER TO ROM BASIC - ; causes transfer to ROM-based BASIC (IBM-PC) - ; often reboots a compatible; often has no effect at all - test ah, 10h - jz short loc_F6EB - or word_1FFA8, 80h - -loc_F6EB: - mov al, 2 - mov ah, 4 - int 18h ; TRANSFER TO ROM BASIC - ; causes transfer to ROM-based BASIC (IBM-PC) - ; often reboots a compatible; often has no effect at all - test ah, 1 - jz short loc_F6FC - or word_1FFA8, 100h - -loc_F6FC: - mov al, 6 - mov ah, 4 - int 18h ; TRANSFER TO ROM BASIC - ; causes transfer to ROM-based BASIC (IBM-PC) - ; often reboots a compatible; often has no effect at all - test ah, 10h - jz short locret_F70C - or word_1FFA8, 10h - -locret_F70C: - retf -sub_F62E endp - -; --------------------------------------------------------------------------- - nop +include th02/hardware/input_sense.asm ; =============== S U B R O U T I N E ======================================= @@ -10721,7 +10584,7 @@ loc_FD5A: call _snd_se_reset call sub_DE4E call _snd_se_update - mov word_1FFA8, 1 + mov _input, 1 call sub_F4BC pop si leave @@ -10860,7 +10723,7 @@ loc_FEB9: call _snd_se_reset call sub_DE4E call _snd_se_update - mov word_1FFA8, 1 + mov _input, 1 call sub_F4BC pop si leave @@ -17005,7 +16868,7 @@ arg_0 = word ptr 4 ; --------------------------------------------------------------------------- loc_13090: - call sub_F62E + call _input_sense push [bp+arg_0] call sub_12F23 cmp si, 24h ; '$' @@ -17039,7 +16902,7 @@ loc_130CC: loc_130CF: inc di - cmp word_1FFA8, 0 + cmp _input, 0 jz short loc_130DE mov [bp+var_2], 1 jmp short loc_130EA @@ -34693,17 +34556,17 @@ loc_1CB6B: call sub_1C785 xor di, di mov [bp+var_8], 0 - mov word_1FFA8, 0 + mov _input, 0 mov [bp+var_A], 1 loc_1CB89: mov [bp+var_B], 0 loc_1CB8D: - call sub_F62E + call _input_sense cmp [bp+var_A], 0 jnz loc_1CCFE - test byte ptr word_1FFA8, 1 + test byte ptr _input, 1 jz short loc_1CBC3 push di push [bp+var_8] @@ -34721,7 +34584,7 @@ loc_1CBB9: call sub_1C8E3 loc_1CBC3: - test byte ptr word_1FFA8, 2 + test byte ptr _input, 2 jz short loc_1CBEC push di push [bp+var_8] @@ -34739,7 +34602,7 @@ loc_1CBE2: call sub_1C8E3 loc_1CBEC: - test byte ptr word_1FFA8, 4 + test byte ptr _input, 4 jz short loc_1CC0F push di push [bp+var_8] @@ -34757,7 +34620,7 @@ loc_1CC05: call sub_1C8E3 loc_1CC0F: - test byte ptr word_1FFA8, 8 + test byte ptr _input, 8 jz short loc_1CC32 push di push [bp+var_8] @@ -34775,9 +34638,9 @@ loc_1CC28: call sub_1C8E3 loc_1CC32: - test byte ptr word_1FFA8, 10h + test byte ptr _input, INPUT_SHOT jnz short loc_1CC42 - test byte ptr word_1FFA8, 80h + test byte ptr _input, INPUT_OK jz loc_1CCD7 loc_1CC42: @@ -34862,7 +34725,7 @@ loc_1CCD0: call sub_1C914 loc_1CCD7: - test byte ptr word_1FFA8, 20h + test byte ptr _input, INPUT_BOMB jz short loc_1CCF7 mov bx, [bp+var_2] imul bx, 7 @@ -34878,13 +34741,13 @@ loc_1CCF0: call sub_1C914 loc_1CCF7: - test byte ptr word_1FFA8, 40h + test byte ptr _input, INPUT_CANCEL jnz short loc_1CD2E loc_1CCFE: push 1 call frame_delay - mov ax, word_1FFA8 + mov ax, _input mov [bp+var_A], ax cmp [bp+var_A], 0 jz loc_1CB89 @@ -37466,7 +37329,7 @@ include libs/master.lib/super_put_rect[bss].asm include th01/hardware/vram_planes[bss].asm include th02/formats/pi_slots[bss].asm include libs/master.lib/pfint21[bss].asm -word_1FFA8 dw ? +include th02/hardware/input_sense[bss].asm include th02/hardware/snd[bss].asm include th02/hardware/snd_load[bss].asm dword_1FFBC dd ? diff --git a/th02_maine.asm b/th02_maine.asm index b9b61283..128c97ed 100644 --- a/th02_maine.asm +++ b/th02_maine.asm @@ -244,7 +244,7 @@ arg_A = word ptr 0Eh ; --------------------------------------------------------------------------- loc_9660: - call sub_B536 + call _input_sense les bx, [bp+arg_2] add bx, si mov al, es:[bx] @@ -268,7 +268,7 @@ loc_9660: add sp, 0Ah cmp byte_F02B, 0 jz short loc_96B9 - cmp word_FAEE, 0 + cmp _input, 0 jz short loc_96B9 test di, 3 jz short loc_96C1 @@ -297,10 +297,10 @@ loc_96C4: ; --------------------------------------------------------------------------- loc_96CD: - call sub_B536 + call _input_sense cmp byte_F02B, 0 jz short loc_96E4 - cmp word_FAEE, 0 + cmp _input, 0 jz short loc_96E4 push 0 jmp short loc_96E6 @@ -3479,144 +3479,7 @@ include th01/hardware/vram_planes_set.asm include th02/formats/pi_slot_load.asm include th02/frame_delay.asm db 0 - -; =============== S U B R O U T I N E ======================================= - - -sub_B536 proc far - mov word_FAEE, 0 - mov al, 7 - mov ah, 4 - int 18h ; TRANSFER TO ROM BASIC - ; causes transfer to ROM-based BASIC (IBM-PC) - ; often reboots a compatible; often has no effect at all - mov bh, ah - mov al, 8 - mov ah, 4 - int 18h ; TRANSFER TO ROM BASIC - ; causes transfer to ROM-based BASIC (IBM-PC) - ; often reboots a compatible; often has no effect at all - test bh, 4 - jnz short loc_B554 - test ah, 8 - jz short loc_B559 - -loc_B554: - or word_FAEE, 1 - -loc_B559: - test bh, 8 - jnz short loc_B563 - test ah, 40h - jz short loc_B568 - -loc_B563: - or word_FAEE, 4 - -loc_B568: - test ah, 4 - jz short loc_B573 - or word_FAEE, 1000h - -loc_B573: - test ah, 10h - jz short loc_B57E - or word_FAEE, 2000h - -loc_B57E: - mov al, 9 - mov ah, 4 - int 18h ; TRANSFER TO ROM BASIC - ; causes transfer to ROM-based BASIC (IBM-PC) - ; often reboots a compatible; often has no effect at all - test bh, 20h - jnz short loc_B58E - test ah, 8 - jz short loc_B593 - -loc_B58E: - or word_FAEE, 2 - -loc_B593: - test bh, 10h - jnz short loc_B59D - test ah, 1 - jz short loc_B5A2 - -loc_B59D: - or word_FAEE, 8 - -loc_B5A2: - test ah, 4 - jz short loc_B5AD - or word_FAEE, 4000h - -loc_B5AD: - test ah, 10h - jz short loc_B5B8 - or word_FAEE, 8000h - -loc_B5B8: - mov al, 5 - mov ah, 4 - int 18h ; TRANSFER TO ROM BASIC - ; causes transfer to ROM-based BASIC (IBM-PC) - ; often reboots a compatible; often has no effect at all - test ah, 2 - jz short loc_B5C8 - or word_FAEE, 10h - -loc_B5C8: - test ah, 4 - jz short loc_B5D2 - or word_FAEE, 20h - -loc_B5D2: - mov al, 0 - mov ah, 4 - int 18h ; TRANSFER TO ROM BASIC - ; causes transfer to ROM-based BASIC (IBM-PC) - ; often reboots a compatible; often has no effect at all - test ah, 1 - jz short loc_B5E2 - or word_FAEE, 40h - -loc_B5E2: - mov al, 3 - mov ah, 4 - int 18h ; TRANSFER TO ROM BASIC - ; causes transfer to ROM-based BASIC (IBM-PC) - ; often reboots a compatible; often has no effect at all - test ah, 10h - jz short loc_B5F3 - or word_FAEE, 80h - -loc_B5F3: - mov al, 2 - mov ah, 4 - int 18h ; TRANSFER TO ROM BASIC - ; causes transfer to ROM-based BASIC (IBM-PC) - ; often reboots a compatible; often has no effect at all - test ah, 1 - jz short loc_B604 - or word_FAEE, 100h - -loc_B604: - mov al, 6 - mov ah, 4 - int 18h ; TRANSFER TO ROM BASIC - ; causes transfer to ROM-based BASIC (IBM-PC) - ; often reboots a compatible; often has no effect at all - test ah, 10h - jz short locret_B614 - or word_FAEE, 10h - -locret_B614: - retf -sub_B536 endp - -; --------------------------------------------------------------------------- - nop +include th02/hardware/input_sense.asm ; =============== S U B R O U T I N E ======================================= @@ -4421,17 +4284,17 @@ loc_BDEC: call sub_BA25 xor di, di mov [bp+var_8], 0 - mov word_FAEE, 0 + mov _input, 0 mov [bp+var_A], 1 loc_BE0A: mov [bp+var_B], 0 loc_BE0E: - call sub_B536 + call _input_sense cmp [bp+var_A], 0 jnz loc_BF7F - test byte ptr word_FAEE, 1 + test byte ptr _input, 1 jz short loc_BE44 push di push [bp+var_8] @@ -4449,7 +4312,7 @@ loc_BE3A: call sub_BB83 loc_BE44: - test byte ptr word_FAEE, 2 + test byte ptr _input, 2 jz short loc_BE6D push di push [bp+var_8] @@ -4467,7 +4330,7 @@ loc_BE63: call sub_BB83 loc_BE6D: - test byte ptr word_FAEE, 4 + test byte ptr _input, 4 jz short loc_BE90 push di push [bp+var_8] @@ -4485,7 +4348,7 @@ loc_BE86: call sub_BB83 loc_BE90: - test byte ptr word_FAEE, 8 + test byte ptr _input, 8 jz short loc_BEB3 push di push [bp+var_8] @@ -4503,9 +4366,9 @@ loc_BEA9: call sub_BB83 loc_BEB3: - test byte ptr word_FAEE, 10h + test byte ptr _input, INPUT_SHOT jnz short loc_BEC3 - test byte ptr word_FAEE, 80h + test byte ptr _input, INPUT_OK jz loc_BF58 loc_BEC3: @@ -4590,7 +4453,7 @@ loc_BF51: call sub_BBB4 loc_BF58: - test byte ptr word_FAEE, 20h + test byte ptr _input, INPUT_BOMB jz short loc_BF78 mov bx, [bp+var_2] imul bx, 7 @@ -4606,13 +4469,13 @@ loc_BF71: call sub_BBB4 loc_BF78: - test byte ptr word_FAEE, 40h + test byte ptr _input, INPUT_CANCEL jnz short loc_BFAF loc_BF7F: push 1 call frame_delay - mov ax, word_FAEE + mov ax, _input mov [bp+var_A], ax cmp [bp+var_A], 0 jz loc_BE0A @@ -6500,7 +6363,7 @@ include libs/master.lib/superpa[bss].asm include th01/hardware/vram_planes[bss].asm include th02/formats/pi_slots[bss].asm include libs/master.lib/pfint21[bss].asm -word_FAEE dw ? +include th02/hardware/input_sense[bss].asm include th02/hardware/snd[bss].asm include th02/hardware/snd_load[bss].asm dword_FB02 dd ? diff --git a/th02_op.asm b/th02_op.asm index df6d9cc9..9a1a6b12 100644 --- a/th02_op.asm +++ b/th02_op.asm @@ -938,7 +938,7 @@ loc_A34B: mov fp_E902, offset sub_A1F5 loc_A356: - cmp word_F3C8, 0 + cmp _input, 0 jnz short loc_A362 mov byte_E8F8, 1 @@ -949,23 +949,23 @@ loc_A362: ; --------------------------------------------------------------------------- loc_A36C: - test byte ptr word_F3C8, 1 + test byte ptr _input, INPUT_UP jz short loc_A37A push 5 push 0FFFFh call sub_A2A2 loc_A37A: - test byte ptr word_F3C8, 2 + test byte ptr _input, INPUT_DOWN jz short loc_A388 push 5 push 1 call sub_A2A2 loc_A388: - test byte ptr word_F3C8, 10h + test byte ptr _input, INPUT_SHOT jnz short loc_A399 - test byte ptr word_F3C8, 80h + test byte ptr _input, INPUT_OK jnz short loc_A399 jmp loc_A448 ; --------------------------------------------------------------------------- @@ -1039,12 +1039,12 @@ loc_A443: mov byte_D6C2, 1 loc_A448: - test byte ptr word_F3C8, 40h + test byte ptr _input, INPUT_CANCEL jz short loc_A454 mov byte_D6C2, 1 loc_A454: - cmp word_F3C8, 0 + cmp _input, 0 jz short loc_A466 mov byte_E8F8, 0 mov word_E8FC, 0 @@ -1429,7 +1429,7 @@ loc_A794: mov fp_E902, offset sub_A510 loc_A79F: - cmp word_F3C8, 0 + cmp _input, 0 jnz short loc_A7AB mov byte_D791, 1 @@ -1440,21 +1440,21 @@ loc_A7AB: ; --------------------------------------------------------------------------- loc_A7B5: - test byte ptr word_F3C8, 1 + test byte ptr _input, INPUT_UP jz short loc_A7C3 push 6 push 0FFFFh call sub_A2A2 loc_A7C3: - test byte ptr word_F3C8, 2 + test byte ptr _input, INPUT_DOWN jz short loc_A7D1 push 6 push 1 call sub_A2A2 loc_A7D1: - test byte ptr word_F3C8, 8 + test byte ptr _input, INPUT_RIGHT jnz short loc_A7DB jmp loc_A85C ; --------------------------------------------------------------------------- @@ -1518,7 +1518,7 @@ loc_A851: call sub_A510 pascal, ax, TX_WHITE loc_A85C: - test byte ptr word_F3C8, 4 + test byte ptr _input, INPUT_LEFT jnz short loc_A866 jmp loc_A8E7 ; --------------------------------------------------------------------------- @@ -1584,9 +1584,9 @@ loc_A8DC: call sub_A510 loc_A8E7: - test byte ptr word_F3C8, 10h + test byte ptr _input, INPUT_SHOT jnz short loc_A8F8 - test byte ptr word_F3C8, 80h + test byte ptr _input, INPUT_OK jnz short loc_A8F8 jmp loc_A97F ; --------------------------------------------------------------------------- @@ -1628,14 +1628,14 @@ loc_A970: mov byte_D792, 0 loc_A97F: - test byte ptr word_F3C8, 40h + test byte ptr _input, INPUT_CANCEL jz short loc_A995 mov byte_D6C0, 3 mov byte_D6C1, 0 mov byte_D792, 0 loc_A995: - cmp word_F3C8, 0 + cmp _input, 0 jz short loc_A9A1 mov byte_D791, 0 @@ -1731,7 +1731,7 @@ loc_AA35: out dx, al loc_AA4A: - mov word_F3C8, 0 + mov _input, 0 mov al, snd_bgm_mode mov snd_active, al les bx, dword_F3DC @@ -1753,13 +1753,13 @@ loc_AA8F: call _pi_slot_load stdcall, 2, offset aTs3_pi, ds call _pi_slot_load stdcall, 1, offset aTs2_pi, ds add sp, 0Ch - mov word_F3C8, 0 + mov _input, 0 mov word_E8FC, 0 jmp short loc_AAF0 ; --------------------------------------------------------------------------- loc_AABA: - call sub_AED0 + call _input_sense cmp byte_D6C1, 0 jnz short loc_AACC call sub_A2FB @@ -2251,144 +2251,7 @@ loc_AEAE: sub_AE00 endp include th02/frame_delay_.asm - -; =============== S U B R O U T I N E ======================================= - - -sub_AED0 proc far - mov word_F3C8, 0 - mov al, 7 - mov ah, 4 - int 18h ; TRANSFER TO ROM BASIC - ; causes transfer to ROM-based BASIC (IBM-PC) - ; often reboots a compatible; often has no effect at all - mov bh, ah - mov al, 8 - mov ah, 4 - int 18h ; TRANSFER TO ROM BASIC - ; causes transfer to ROM-based BASIC (IBM-PC) - ; often reboots a compatible; often has no effect at all - test bh, 4 - jnz short loc_AEEE - test ah, 8 - jz short loc_AEF3 - -loc_AEEE: - or word_F3C8, 1 - -loc_AEF3: - test bh, 8 - jnz short loc_AEFD - test ah, 40h - jz short loc_AF02 - -loc_AEFD: - or word_F3C8, 4 - -loc_AF02: - test ah, 4 - jz short loc_AF0D - or word_F3C8, 1000h - -loc_AF0D: - test ah, 10h - jz short loc_AF18 - or word_F3C8, 2000h - -loc_AF18: - mov al, 9 - mov ah, 4 - int 18h ; TRANSFER TO ROM BASIC - ; causes transfer to ROM-based BASIC (IBM-PC) - ; often reboots a compatible; often has no effect at all - test bh, 20h - jnz short loc_AF28 - test ah, 8 - jz short loc_AF2D - -loc_AF28: - or word_F3C8, 2 - -loc_AF2D: - test bh, 10h - jnz short loc_AF37 - test ah, 1 - jz short loc_AF3C - -loc_AF37: - or word_F3C8, 8 - -loc_AF3C: - test ah, 4 - jz short loc_AF47 - or word_F3C8, 4000h - -loc_AF47: - test ah, 10h - jz short loc_AF52 - or word_F3C8, 8000h - -loc_AF52: - mov al, 5 - mov ah, 4 - int 18h ; TRANSFER TO ROM BASIC - ; causes transfer to ROM-based BASIC (IBM-PC) - ; often reboots a compatible; often has no effect at all - test ah, 2 - jz short loc_AF62 - or word_F3C8, 10h - -loc_AF62: - test ah, 4 - jz short loc_AF6C - or word_F3C8, 20h - -loc_AF6C: - mov al, 0 - mov ah, 4 - int 18h ; TRANSFER TO ROM BASIC - ; causes transfer to ROM-based BASIC (IBM-PC) - ; often reboots a compatible; often has no effect at all - test ah, 1 - jz short loc_AF7C - or word_F3C8, 40h - -loc_AF7C: - mov al, 3 - mov ah, 4 - int 18h ; TRANSFER TO ROM BASIC - ; causes transfer to ROM-based BASIC (IBM-PC) - ; often reboots a compatible; often has no effect at all - test ah, 10h - jz short loc_AF8D - or word_F3C8, 80h - -loc_AF8D: - mov al, 2 - mov ah, 4 - int 18h ; TRANSFER TO ROM BASIC - ; causes transfer to ROM-based BASIC (IBM-PC) - ; often reboots a compatible; often has no effect at all - test ah, 1 - jz short loc_AF9E - or word_F3C8, 100h - -loc_AF9E: - mov al, 6 - mov ah, 4 - int 18h ; TRANSFER TO ROM BASIC - ; causes transfer to ROM-based BASIC (IBM-PC) - ; often reboots a compatible; often has no effect at all - test ah, 10h - jz short locret_AFAE - or word_F3C8, 10h - -locret_AFAE: - retf -sub_AED0 endp - -; --------------------------------------------------------------------------- - nop +include th02/hardware/input_sense.asm ; =============== S U B R O U T I N E ======================================= @@ -3129,10 +2992,10 @@ loc_B7B7: out dx, al loc_B808: - call sub_AED0 + call _input_sense or si, si jnz short loc_B81D - cmp word_F3C8, 0 + cmp _input, 0 jnz short loc_B81D mov si, 1 jmp short loc_B829 @@ -3141,7 +3004,7 @@ loc_B808: loc_B81D: cmp si, 1 jnz short loc_B829 - cmp word_F3C8, 0 + cmp _input, 0 jnz short loc_B84F loc_B829: @@ -3161,7 +3024,7 @@ loc_B829: jbe short loc_B808 loc_B84F: - mov word_F3C8, 0 + mov _input, 0 push 14h call frame_delay push 0 @@ -3795,14 +3658,14 @@ var_6 = byte ptr -6 call sub_BBC0 loc_BD54: - call sub_AED0 + call _input_sense or si, si jz short loc_BD60 jmp loc_BF95 ; --------------------------------------------------------------------------- loc_BD60: - test byte ptr word_F3C8, 4 + test byte ptr _input, INPUT_LEFT jnz short loc_BD6A jmp loc_BE6D ; --------------------------------------------------------------------------- @@ -3914,7 +3777,7 @@ loc_BE0F: add sp, 6 loc_BE6D: - test byte ptr word_F3C8, 8 + test byte ptr _input, INPUT_RIGHT jnz short loc_BE77 jmp loc_BF7A ; --------------------------------------------------------------------------- @@ -4026,9 +3889,9 @@ loc_BF1C: add sp, 6 loc_BF7A: - test byte ptr word_F3C8, 10h + test byte ptr _input, INPUT_SHOT jnz short loc_BF88 - test byte ptr word_F3C8, 80h + test byte ptr _input, INPUT_OK jz short loc_BF95 loc_BF88: @@ -4041,7 +3904,7 @@ loc_BF88: loc_BF95: push 1 call frame_delay - mov si, word_F3C8 + mov si, _input or si, si jz short loc_BFB2 inc di @@ -5068,16 +4931,16 @@ var_1 = byte ptr -1 call far ptr palette_show loc_C849: - call sub_AED0 - cmp word_F3C8, 0 + call _input_sense + cmp _input, 0 jz short loc_C85A call sub_C3AC jmp short loc_C849 ; --------------------------------------------------------------------------- loc_C85A: - call sub_AED0 - test byte ptr word_F3C8, 1 + call _input_sense + test byte ptr _input, INPUT_UP jz short loc_C895 push word_F57C push 3 @@ -5102,7 +4965,7 @@ loc_C88C: call sub_BFF5 loc_C895: - test byte ptr word_F3C8, 2 + test byte ptr _input, INPUT_DOWN jz short loc_C8CB push word_F57C push 3 @@ -5127,9 +4990,9 @@ loc_C8C2: call sub_BFF5 loc_C8CB: - test byte ptr word_F3C8, 10h + test byte ptr _input, INPUT_SHOT jnz short loc_C8D9 - test byte ptr word_F3C8, 80h + test byte ptr _input, INPUT_OK jz short loc_C950 loc_C8D9: @@ -5176,9 +5039,9 @@ loc_C8E3: call sub_C726 loc_C950: - test byte ptr word_F3C8, 40h + test byte ptr _input, INPUT_CANCEL jnz short loc_C967 - cmp word_F3C8, 0 + cmp _input, 0 jz short loc_C961 jmp loc_C849 ; --------------------------------------------------------------------------- @@ -5189,8 +5052,8 @@ loc_C961: ; --------------------------------------------------------------------------- loc_C967: - call sub_AED0 - cmp word_F3C8, 0 + call _input_sense + cmp _input, 0 jz short loc_C978 call sub_C3AC jmp short loc_C967 @@ -5473,7 +5336,7 @@ include libs/master.lib/super_put_rect[bss].asm include th01/hardware/vram_planes[bss].asm include th02/formats/pi_slots[bss].asm include libs/master.lib/pfint21[bss].asm -word_F3C8 dw ? +include th02/hardware/input_sense[bss].asm include th02/hardware/snd[bss].asm include th02/hardware/snd_load[bss].asm dword_F3DC dd ?