13 June 2023, 21:03 | #1 |
Registered User
Join Date: Jun 2023
Location: Sweden
Posts: 2
|
How to binary patch that uses input.device?
The title is vague so let me explain further. A system friendly game (written for KS2.x) uses input.device to grab key presses from the user. Arrow keys and keypad 1, 2, 3, 5 have the same function, but the function for keypad 7, 8, 9 exist only there. This makes it difficult on Amiga 600 that does not have a keypad, so I want to binary patch the code to "remap" they keys, sort of.
If $BFEC01 was used, that would have been easy to find where the keys are read and simply patch it. However, now input.device, with a horrible mess of events and handlers and what-not, are involved which makes it impossible to straight up find where in the disassembled code the actual key handling routine is. In the reference manual for Devices I know for a fact that the raw codes for NP 7-9 is 0x3D, 0x3E, 0x3F, but there is no hit for these bytes anywhere in the code so there must be some other kind of pointer magic involved and I don't know how to untangle this mess. If I just managed to find the actual key handling code things would be simpler, but I cannot navigate to it because I don't know what I should look fore. My best guess is this part, but I'm completely confused and I think I'm on the wrong track to even remotely find anything. Code:
CODE:00021408 loc_21408: ; CODE XREF: IORequestAndMaskEtc+68?j CODE:00021408 ; IORequestAndMaskEtc+8C?j ... CODE:00021408 044 0C46 00B8 cmpi.w #$B8,d6 CODE:0002140C 044 6E2E bgt.s loc_2143C CODE:0002140E 044 0C46 00B0 cmpi.w #$B0,d6 CODE:00021412 044 6D28 blt.s loc_2143C CODE:00021414 044 0C46 00B5 cmpi.w #$B5,d6 CODE:00021418 044 6604 bne.s loc_2141E CODE:0002141A 044 3C3C 00B5 move.w #$B5,d6 CODE:0002141E CODE:0002141E loc_2141E: ; CODE XREF: IORequestAndMaskEtc+F6?j CODE:0002141E 044 0C46 00B8 cmpi.w #$B8,d6 CODE:00021422 044 6604 bne.s loc_21428 CODE:00021424 044 3C3C 00B8 move.w #$B8,d6 CODE:00021428 CODE:00021428 loc_21428: ; CODE XREF: IORequestAndMaskEtc+100?j CODE:00021428 044 0C46 00B3 cmpi.w #$B3,d6 CODE:0002142C 044 6604 bne.s loc_21432 CODE:0002142E 044 3C3C 00B3 move.w #$B3,d6 CODE:00021432 CODE:00021432 loc_21432: ; CODE XREF: IORequestAndMaskEtc+10A?j CODE:00021432 044 0C46 00B0 cmpi.w #$B0,d6 CODE:00021436 044 6604 bne.s loc_2143C CODE:00021438 044 3C3C 00B0 move.w #$B0,d6 CODE:0002143C CODE:0002143C loc_2143C: ; CODE XREF: IORequestAndMaskEtc+EA?j CODE:0002143C ; IORequestAndMaskEtc+F0?j ... CODE:0002143C 044 4A46 tst.w d6 CODE:0002143E 044 6740 beq.s loc_21480 CODE:00021440 044 2004 move.l d4,d0 CODE:00021442 044 0240 0003 andi.w #3,d0 CODE:00021446 044 6704 beq.s loc_2144C CODE:00021448 044 0646 0100 addi.w #$100,d6 CODE:0002144C CODE:0002144C loc_2144C: ; CODE XREF: IORequestAndMaskEtc+124?j CODE:0002144C 044 0804 0003 btst #3,d4 CODE:00021450 044 6704 beq.s loc_21456 CODE:00021452 044 0646 0200 addi.w #$200,d6 CODE:00021456 CODE:00021456 loc_21456: ; CODE XREF: IORequestAndMaskEtc+12E?j CODE:00021456 044 2004 move.l d4,d0 CODE:00021458 044 0240 0030 andi.w #$30,d0 ; '0' CODE:0002145C 044 6704 beq.s loc_21462 CODE:0002145E 044 0646 0400 addi.w #$400,d6 CODE:00021462 CODE:00021462 loc_21462: ; CODE XREF: IORequestAndMaskEtc+13A?j CODE:00021462 044 0804 0006 btst #6,d4 CODE:00021466 044 6704 beq.s loc_2146C CODE:00021468 044 0646 1000 addi.w #$1000,d6 CODE:0002146C CODE:0002146C loc_2146C: ; CODE XREF: IORequestAndMaskEtc+144?j CODE:0002146C 044 0804 0007 btst #7,d4 CODE:00021470 044 6704 beq.s loc_21476 CODE:00021472 044 0646 2000 addi.w #$2000,d6 CODE:00021476 CODE:00021476 loc_21476: ; CODE XREF: IORequestAndMaskEtc+14E?j CODE:00021476 044 0807 0007 btst #7,d7 CODE:0002147A 044 6704 beq.s loc_21480 CODE:0002147C 044 0646 0800 addi.w #$800,d6 CODE:00021480 So my question is: what strategy should I use to be able to find the key handling code? I have a full disassembly (by IDA) but I cannot set any breakpoints and investigate anything in realtime, so I have to figure it out only by using the disassembly. (I have read https://eab.abime.net/showthread.php?t=62322 which is an interesting and related thread, but my head hurts even more. Classes in assembly is horrible) Last edited by gurksallad; 13 June 2023 at 21:09. |
13 June 2023, 22:08 | #2 |
Going nowhere
Join Date: Oct 2001
Location: United Kingdom
Age: 50
Posts: 9,014
|
Any particular game?
|
16 June 2023, 11:59 | #3 |
Registered User
Join Date: Jan 2019
Location: Germany
Posts: 3,250
|
If the game uses the input device, then there should be commodities that generate the key events for the numeric keypad for you, emulating it. Thus, there is no patch required.
|
22 June 2023, 18:40 | #4 |
Registered User
Join Date: Jun 2023
Location: Sweden
Posts: 2
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
input.device PeekQualifier | Gilloo | Coders. System | 1 | 28 December 2017 15:56 |
Input Device Clash | Hungry Horace | support.FS-UAE | 2 | 12 October 2014 23:36 |
Putty Input Lag - New Patch Possible? | manic23 | Games images which need to be WHDified | 8 | 18 May 2013 21:27 |
(ASM, C ) input.device | Asman | Coders. General | 4 | 16 July 2009 10:10 |
|
|