ROM Hack Can you edit the button controls on a ds rom?

  • Thread starter Jugo
  • Start date
  • Views 13,220
  • Replies 27
  • Likes 1

Jugo

Well-Known Member
OP
Newcomer
Joined
Apr 17, 2010
Messages
83
Trophies
0
XP
78
Country
United States
I mean like swapping them. Ex: Switching the B and X buttons in pokemon so you can use the menu with B and run with X.
 
  • Like
Reactions: BatIron

Cyan

GBATemp's lurking knight
Former Staff
Joined
Oct 27, 2002
Messages
23,749
Trophies
4
Age
46
Location
Engine room, learning
XP
15,662
Country
France
Such a hack has already been done on other games (like Zelda to enable moving with D-pad instead of stylus).

I don't know how hard it is to change the button layout, but I just wanted to tell you that it's possible.
 

syko5150

GBAtemp Syko!
Member
Joined
Apr 25, 2009
Messages
3,091
Trophies
0
Age
38
Location
California
Website
Visit site
XP
213
Country
United States
Cyan said:
Such a hack has already been done on other games (like Zelda to enable moving with D-pad instead of stylus).

I don't know how hard it is to change the button layout, but I just wanted to tell you that it's possible.
I would say it's possible as it's been done on games like Guitar Hero to allow you to change which buttons match to which colors.
 

FAST6191

Techromancer
Editorial Team
Joined
Nov 21, 2005
Messages
36,798
Trophies
3
XP
28,375
Country
United Kingdom
Guitar hero, zelda Dpad and starfox Dpad hacks were actually a cut above what you want to do here. The touch screen to dpad stuff actually rewrote parts of the game to operate in such a manner (it made the buttons change things the touch screen was previously responsible for) where the guitar hero used part of the GBA slot as a bus which actually added buttons to the DS that the hacks then turned the game away from and pointed at the buttons. I also recall a cheat for trauma center that reset patient health based upon a "miss" that might be worth looking at (or not as a miss probably registers in other places).

Generally speaking the buttons which all have their own memory mapping are read every so often (might be refresh) and usually dumped to another memory section to use. Theory behind that if you have ever had a mouse that would double click for a single click chances are the switch was experiencing a failure method known as switch bounce (part was worn and making the circuit twice usually)- by copying it to the memory section and only using that you can negate this somewhat (the method is called debouncing).
That aside over getting back to the hacking the button register is detailed http://nocash.emubase.de/gbatek.htm#dskeypad
GBA part which has a bit more info
http://nocash.emubase.de/gbatek.htm#gbakeypadinput

You get to figure out what the game does and edit it. Naturally this means ASM hacking (if cheats do it they change the binary in memory).

I personally would find the debounced copy (it might be a straight copy of the register but some games have been known to set a byte for each which is awesome as you then just have to change (or in your case swap) the destination) and fiddle with that (or indeed change how it gets there) so what was the button "a" bit is now the button "b" otherwise you run the risk of having to chase down interrupts and game logic and changing how they all work which is potentially a very long and boring process.

Although I said starfox stuff was actually a bit outside what you want there is a nice guide to it http://crackerscrap.com/docs/sfchacktut.html which covers a lot of the background theory and implementation of the hack.

Others have gone the electrical engineering route and physically remapped the buttons which is easier if you can swing a soldering iron.
 

Galaxia

Member
Newcomer
Joined
Feb 5, 2017
Messages
7
Trophies
0
Age
35
XP
52
Country
Guitar hero, zelda Dpad and starfox Dpad hacks were actually a cut above what you want to do here. The touch screen to dpad stuff actually rewrote parts of the game to operate in such a manner (it made the buttons change things the touch screen was previously responsible for) where the guitar hero used part of the GBA slot as a bus which actually added buttons to the DS that the hacks then turned the game away from and pointed at the buttons. I also recall a cheat for trauma center that reset patient health based upon a "miss" that might be worth looking at (or not as a miss probably registers in other places).

Generally speaking the buttons which all have their own memory mapping are read every so often (might be refresh) and usually dumped to another memory section to use. Theory behind that if you have ever had a mouse that would double click for a single click chances are the switch was experiencing a failure method known as switch bounce (part was worn and making the circuit twice usually)- by copying it to the memory section and only using that you can negate this somewhat (the method is called debouncing).
That aside over getting back to the hacking the button register is detailed http://nocash.emubase.de/gbatek.htm#dskeypad
GBA part which has a bit more info
http://nocash.emubase.de/gbatek.htm#gbakeypadinput

You get to figure out what the game does and edit it. Naturally this means ASM hacking (if cheats do it they change the binary in memory).

I personally would find the debounced copy (it might be a straight copy of the register but some games have been known to set a byte for each which is awesome as you then just have to change (or in your case swap) the destination) and fiddle with that (or indeed change how it gets there) so what was the button "a" bit is now the button "b" otherwise you run the risk of having to chase down interrupts and game logic and changing how they all work which is potentially a very long and boring process.

Although I said starfox stuff was actually a bit outside what you want there is a nice guide to it http://crackerscrap.com/docs/sfchacktut.html which covers a lot of the background theory and implementation of the hack.

Others have gone the electrical engineering route and physically remapped the buttons which is easier if you can swing a soldering iron.

Could you please explain how to find the controls and how to edit the values of the buttons? The links you gave are all down. I would like to edit the atrocious controls of Kirby Super Star Ultra and Kirby Squeak Squad, and swap the b and y buttons.
 

FAST6191

Techromancer
Editorial Team
Joined
Nov 21, 2005
Messages
36,798
Trophies
3
XP
28,375
Country
United Kingdom
The starfox one was archived
https://web.archive.org/web/20110604163902/http://crackerscrap.com/docs/sfchacktut.html

GBAtek is now located
http://problemkaputt.de/gbatek.htm

The stuff I wrote above is pretty much what I would say today.

The GBAtek link shows the (read only) bit of memory which the system changes when buttons are pressed. For the reasons mentioned in the first post then sensible game coders will copy this state every vblank usually (maybe hblank for something really strange or it could be some other set period or prior to a certain operation in some cases) to somewhere in memory. Anything that depends upon the button press will likely then read that area of memory.
You then get to figure out what the game reads from that area and does in response. Three main approaches game devs will use

1) All hard coded right down to the assembly level
2) Control mapping setups
3) Full remapping.

At a code level 2) and 3) will probably look fairly similar but where you might need to go full bore assembly hack you might be able to find a sort of table in the game somewhere to change what it calls a given setup.

1) will probably look something like
[read control state into memory/register]
either compare or do some boolean operation and then compare to find if the button you want is pressed
if pressed call jump/shoot/start game/glug potion/whatever routine
else carry on with life

You then get to alter this compare to read the results of another button. In the case of the DS it might be slightly more complex if you want to read the X and Y buttons as they are DS special registers and not GBA buttons which are A and B. Chances are the devs will do it all in one lump and it will probably not be anything drastic but be aware of that.
Quote from gbatek
4000136h - NDS7 - EXTKEYIN - Key X/Y Input (R)

0 Button X (0=Pressed, 1=Released)
1 Button Y (0=Pressed, 1=Released)

To this end if you wanted to read the result of Y rather than X you would want to get the function to look at bit 1 rather than bit 0 by altering whatever means it uses (could be many things but will be fairly obvious).

The cowboy method is also an option but will probably be game wide where the above is more precise. If you don't care then great, it is also useful if you have many functions all looking at one button and you want to change them all without hunting down each individual one.
I mentioned it copying to memory. After it has copied to memory then you jump in and swap whatever bits or disable whatever bit you want (some people like this if their shoulder buttons fail and look as though they are constantly pressed). Or to go back to the case above and say swap X and Y then you would want to figure out if either was pressed, store that and that alone in a number that represents the other, set both to be low and then probably do a logical OR with the results of that to swap buttons.
 
  • Like
Reactions: Galaxia

Galaxia

Member
Newcomer
Joined
Feb 5, 2017
Messages
7
Trophies
0
Age
35
XP
52
Country
1) All hard coded right down to the assembly level
2) Control mapping setups
3) Full remapping.

Quote from gbatek
4000136h - NDS7 - EXTKEYIN - Key X/Y Input (R)

0 Button X (0=Pressed, 1=Released)
1 Button Y (0=Pressed, 1=Released)

To this end if you wanted to read the result of Y rather than X you would want to get the function to look at bit 1 rather than bit 0 by altering whatever means it uses (could be many things but will be fairly obvious).

The cowboy method is also an option but will probably be game wide where the above is more precise. If you don't care then great, it is also useful if you have many functions all looking at one button and you want to change them all without hunting down each individual one.
I mentioned it copying to memory. After it has copied to memory then you jump in and swap whatever bits or disable whatever bit you want (some people like this if their shoulder buttons fail and look as though they are constantly pressed). Or to go back to the case above and say swap X and Y then you would want to figure out if either was pressed, store that and that alone in a number that represents the other, set both to be low and then probably do a logical OR with the results of that to swap buttons.

Thank you for replying to something on a 6 year old post so quickly. Most of what you wrote went over my head, (I am but a simple man that wishes to play Kirby properly) but I think I'll try the cowboy method and replace all instances of one button press causing something with another button press. I don't no what I'm doing, but I still appreciate ya. ^̮^
 

FAST6191

Techromancer
Editorial Team
Joined
Nov 21, 2005
Messages
36,798
Trophies
3
XP
28,375
Country
United Kingdom
Afraid there are not really any easy ins here. In the case of 2 and 3 there might be but identifying what goes in the first place still has to happen. In the case of text and graphics you can learn enough to change some games fairly radically in short order but assembly is often the end stage in learning and most far reaching thing for a reason. Similarly if someone hands a worked up version to you then you can do a lot; if you found the guitar hero stuff here then the later threads were all people tweaking the cheat button mappings to their preference, though it is a different type of hack in some ways it is not entirely dissimilar in how it would play out for the end user wanting to refine things.

I am sitting here trying to think if there is a means to teach you what is likely to be seen in control hacking and spare some of the other stuff that might not be so relevant. However it is all so variable in what goes that I can't do much without basically doing the hack for you, and while it is not going to be a months long slog it is not a postpone my afternoon film thing either.
 
  • Like
Reactions: Galaxia

skawo

Well-Known Member
Member
Joined
Aug 18, 2015
Messages
582
Trophies
0
Age
34
XP
2,764
Country
Which game would you want this done to?

I'm fairly sure I could get it done pretty quickly.

EDIT:
I would like to edit the atrocious controls of Kirby Super Star Ultra and Kirby Squeak Squad, and swap the b and y buttons.

Oh. OK. Will try.
 
Last edited by skawo,
  • Like
Reactions: Galaxia

skawo

Well-Known Member
Member
Joined
Aug 18, 2015
Messages
582
Trophies
0
Age
34
XP
2,764
Country
I dunno, is this OK? Seems to work to me, but please check:
https://dl.dropboxusercontent.com/u/4558852/2696 - Kirby Super Stars Ultra (U)(XenoPhobia).xdelta

Applies to ROM w/ same filename.

It's a fairly lame approach, but whatever:
Code:
nsub_0200182C_main:
   STMFD SP!, {R0-R3}
   MOV R0, R4
   MOV R1, R4
   LDR R2, =0x802
   LSR R0, R0, #1
   LSR R1, R1, #11
   ANDS R0, #1
   EORNE R4, R2
   ANDS R1, #1
   EORNE R4, R2
   LDMFD SP!, {R0-R3}
   STRH R4, [R0, #0xE4]
   STRH R4, [R0, #0xE6]
   STRH R4, [R0, #0xE8]
   B 0x2001830
 
  • Like
Reactions: Xeddius and Galaxia

Galaxia

Member
Newcomer
Joined
Feb 5, 2017
Messages
7
Trophies
0
Age
35
XP
52
Country
I dunno, is this OK? Seems to work to me, but please check:
https://dl.dropboxusercontent.com/u/4558852/2696 - Kirby Super Stars Ultra (U)(XenoPhobia).xdelta

Applies to ROM w/ same filename.

It's a fairly lame approach, but whatever:
Code:
nsub_0200182C_main:
   STMFD SP!, {R0-R3}
   MOV R0, R4
   MOV R1, R4
   LDR R2, =0x802
   LSR R0, R0, #1
   LSR R1, R1, #11
   ANDS R0, #1
   EORNE R4, R2
   ANDS R1, #1
   EORNE R4, R2
   LDMFD SP!, {R0-R3}
   STRH R4, [R0, #0xE4]
   STRH R4, [R0, #0xE6]
   STRH R4, [R0, #0xE8]
   B 0x2001830
It isn't working. Xdelta says it can't find the patch when I try to apply it.
 

skawo

Well-Known Member
Member
Joined
Aug 18, 2015
Messages
582
Trophies
0
Age
34
XP
2,764
Country
...That would imply you haven't selected the patch, or are doing something else wrong in the patcher, not a problem with the patch itself.
 
  • Like
Reactions: Galaxia

Galaxia

Member
Newcomer
Joined
Feb 5, 2017
Messages
7
Trophies
0
Age
35
XP
52
Country
...That would imply you haven't selected the patch, or are doing something else wrong in the patcher, not a problem with the patch itself.
Yup, you were right...
While you're at it, could you make something like this for Squeak Squad? From what I understand the game uses the same engine.
 

Galaxia

Member
Newcomer
Joined
Feb 5, 2017
Messages
7
Trophies
0
Age
35
XP
52
Country
...That would imply you haven't selected the patch, or are doing something else wrong in the patcher, not a problem with the patch itself.
Wait, I still can't patch it, when I try it "xdelta3: target window checksum mismatch: XD3_INVALID_INPUT" comes up. I'm pretty sure that it is a bad ROM... Perhap you shoul try it again with the (E) version.
 

FAST6191

Techromancer
Editorial Team
Joined
Nov 21, 2005
Messages
36,798
Trophies
3
XP
28,375
Country
United Kingdom
I have seen a few pre trimmed ROMs about the place as well. Xdelta should have the option to force ignore any input checksums.
 

Xeddius

Member
Newcomer
Joined
Apr 8, 2018
Messages
12
Trophies
0
Age
30
XP
99
Country
United States
Sorry to bump this old thread, but I also want to remap the original controls to the DS game (Kirby Super Star Ultra). The link you posted is now 404'ed, is there a chance you could re-upload it somewhere or post it to github? I have 0 experience modding ds roms as is (I can apply the patch but creating one is beyond my current scope of knowledge/expertise.) (And I've also scoured the web for a copy of the file with no luck.)
 
Last edited by Xeddius,

FAST6191

Techromancer
Editorial Team
Joined
Nov 21, 2005
Messages
36,798
Trophies
3
XP
28,375
Country
United Kingdom
I don't appear to have the patch but someone could probably recreate it with that assembly fragment up there.
Indeed you might even be able to make it a cheat -- it would be 16-18 lines long but that is doable.

Alas I am not with my normal hacking tools today and I don't know if http://shell-storm.org/online/Online-Assembler-and-Disassembler/ is going to do what it needs to do.

skawo was apparently here a few weeks back so I will send them a PM to see if they still have the patch, I will include you in it too.
 
  • Like
Reactions: Xeddius

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • BakerMan
    I rather enjoy a life of taking it easy. I haven't reached that life yet though.
  • K3Nv2 @ K3Nv2:
    No real point since movies are 30fps
  • BigOnYa @ BigOnYa:
    Not a big movie buff, more of a gamer tbh. And Series X is 120hz 8k ready, but yea only 120hz 4k games out right now, but thinking of in the future.
  • K3Nv2 @ K3Nv2:
    Mostly why you never see TV manufacturers going post 60hz
  • BigOnYa @ BigOnYa:
    I only watch tv when i goto bed, it puts me to sleep, and I have a nas drive filled w my fav shows so i can watch them in order, commercial free. I usually watch Married w Children, or South Park
  • K3Nv2 @ K3Nv2:
    Stremio ruined my need for nas
  • BigOnYa @ BigOnYa:
    I stream from Nas to firestick, one on every tv, and use Kodi. I'm happy w it, plays everything. (I pirate/torrent shows/movies on pc, and put on nas)
  • K3Nv2 @ K3Nv2:
    Kodi repost are still pretty popular
  • BigOnYa @ BigOnYa:
    What the hell is Kodi reposts? what do you mean, or "Wut?" -xdqwerty
  • K3Nv2 @ K3Nv2:
    Google them basically web crawlers to movie sites
  • BigOnYa @ BigOnYa:
    oh you mean the 3rd party apps on Kodi, yea i know what you mean, yea there are still a few cool ones, in fact watched the new planet of the apes movie other night w wifey thru one, was good pic surprisingly, not a cam
  • BigOnYa @ BigOnYa:
    Damn, only $2.06 and free shipping. Gotta cost more for them to ship than $2.06
    +1
  • BigOnYa @ BigOnYa:
    I got my Dad a firestick for Xmas and showed him those 3rd party sites on Kodi, he loves it, all he watches anymore. He said he has got 3 letters from AT&T already about pirating, but he says f them, let them shut my internet off (He wants out of his AT&T contract anyways)
  • K3Nv2 @ K3Nv2:
    That's where stremio comes to play never got a letter about it
  • BigOnYa @ BigOnYa:
    I just use a VPN, even give him my login and password so can use it also, and he refuses, he's funny.
  • BigOnYa @ BigOnYa:
    I had to find and get him an old style flip phone even without text, cause thats what he wanted. No text, no internet, only phone calls. Old, old school.
  • Psionic Roshambo @ Psionic Roshambo:
    @BigOnYa, Lol I bought a new USB card reader thing on AliExpress last month for I think like 87 cents. Free shipping from China... It arrived it works and honestly I don't understand how it was so cheap.
    +1
  • BakerMan @ BakerMan:
    fellas
  • BakerMan @ BakerMan:
    would you rather have a 9-5 desk job with poor pay or work for an intergalactic space militia with no guarantee of being paid?
  • BakerMan @ BakerMan:
    basically, normal boring job or halo and/or helldivers irl
  • SylverReZ @ SylverReZ:
    Lol. Have you heard about this?
  • SylverReZ @ SylverReZ:
    I wish the people who make these emulators know the basic primer course on copyright and trademarks.
    SylverReZ @ SylverReZ: I wish the people who make these emulators know the basic primer course on copyright and trademarks.