CPCWiki forum

General Category => Games => Topic started by: mr_lou on 18:08, 07 January 12

Title: Hacking default control-keys in games
Post by: mr_lou on 18:08, 07 January 12
Is it difficult to hack a binary and find and change the control-keys in the binary?
For example, the game Fruity Frank has keys to control Frank, but they can't be changed. How difficult / easy is it to find where these keys are defined and change them into other keys?

Since someone will probably ask, here's why:
Finally got AdvMESS working on my Lincade cabinet, so I can emulate Amstrad CPC on it too now.
But to get the joysticks working on MAME earlier, I had to buy a rather expensive unit to connect the wires from the joystick buttons to the keyboard, so that they are actually keys. (There is no USB joystick support in Lincade yet).

As a result, I'm stuck with key-controls in CPC games as well (I am using the joystick, but it's mapped to keys). That's fine for many games though, since they have definable keys. But I'm wondering if I have options for the other games, like e.g. hacking the binary.

The keys I've mapped the joystick to are
UP = Arrow up
DOWN = Arrow down
LEFT = Arrow left
RIGHT = Arrow right
FIRE = CTRL
Title: Re: Hacking default control-keys in games
Post by: Devilmarkus on 18:51, 07 January 12
I think it's easier to map the joystick to the correct CPC-keys (CPC-Joystick is also a "keyboard")
Title: Re: Hacking default control-keys in games
Post by: mr_lou on 19:03, 07 January 12
Quote from: Devilmarkus on 18:51, 07 January 12
I think it's easier to map the joystick to the correct CPC-keys (CPC-Joystick is also a "keyboard")

Not possible. It's hardwired.

It's a device like this that sits between the keyboard and the joystick wires. I have no control which keys are used. That's mapped on the print.
http://arcadeshoppen.dk/image/cache/ipac-800x800.jpg (http://arcadeshoppen.dk/image/cache/ipac-800x800.jpg)
Title: Re: Hacking default control-keys in games
Post by: mr_lou on 19:29, 07 January 12
I'd think it's a matter of finding "CALL &BB1E" (KM TEST KEY) in the binary. In other words, search for "CD 1E BB", and then in the following bytes look for the byte-values matching the keycode I want to replace.

Finding "CD 1E BB" isn't difficult. But finding a list of the Amstrad CPC keycodes is difficult. (My CPC manual is packed down).
Does anyone know where such a list is online?

As far as I remember, keycodes aren't the same as character codes.
Maybe I can code some BASIC program to show what keycode is being pressed? It's not done with INKEY$ then, but with what?
Title: Re: Hacking default control-keys in games
Post by: Nich on 20:02, 07 January 12
Quote from: mr_lou on 19:29, 07 January 12But finding a list of the Amstrad CPC keycodes is difficult. (My CPC manual is packed down).
Does anyone know where such a list is online?
Try this page (http://www.cpctech.org.uk/docs/keyboard.html) at The Unofficial Amstrad WWW Resource. It shows the keyboard matrix as a table, but it doesn't list actual key numbers. To calculate a key number from the table, multiply the line number by 8, then add the bit number (e.g. SPACE = line 5, bit 7; key number = 5*8 + 7 = key number 47).
Title: Re: Hacking default control-keys in games
Post by: mr_lou on 20:33, 07 January 12
I got Offset to take a picture and send me.

There I see that Z and X have keycodes 71 and 63, meaning 47 and 3F in hexidecimal.
But I can't find those numbers after the CD 1E BB piece, so it's apparently not that easy.
Title: Re: Hacking default control-keys in games
Post by: mr_lou on 22:42, 07 January 12
Well, I found the locations for the 4 directional keycodes, and changed one of them to test, and it works fine.

But I still need the keycodes for the arrow keys before I can change them.

And then I need to find where the location is for the fire-button.  :)

So who can tell me the keycodes for the arrow-keys?
Title: Re: Hacking default control-keys in games
Post by: tastefulmrship on 09:15, 08 January 12
Quote from: mr_lou on 22:42, 07 January 12
So who can tell me the keycodes for the arrow-keys?
0, 1, 2, 8 & 9
Title: Re: Hacking default control-keys in games
Post by: mr_lou on 09:29, 08 January 12
Doh

Thanks.

But more sillyness: I could set the keys in the emulator afterall. I just had to "unlock" it first.
In MAME you press TAB to set keys and such. In AdvMESS you have to press Scroll Lock first before you can press TAB.

So now all games are fine now.  :) Yay
Powered by SMFPacks Menu Editor Mod