Hacking Circle Pad patches for Super Mario 64 DS and other games (in TwilightMenu with TWPatcher and RTCom)

SuperGuy

Member
Newcomer
Joined
Nov 1, 2021
Messages
9
Trophies
0
Age
22
XP
59
Country
United States

TLDR list of mods I've made

a bit more lengthy description is probably somewhere below in the text, in the changelog
  • 3DS-NDS Key Remapper: Patch generator that lets you remap keys in any NDS game. You can also map/remap the CPad, CStick and ZL & ZR buttons. For example, you can assign the CStick to the ABXY buttons to make aiming easier in some FPS games. To use it, visit the page, tick some checkboxes, copy the resulting cheatcode and paste it into your game in R4CCE. Requires the latest version of nds-bootstrap (v70.0 or newer). A couple of examples of its use.
  • Animal Crossing: Wild World
  • C.O.P.: The Recruit
    • CPad is also used for steering a vehicle (a little bit)
    • CStick to control the camera
  • Call of Duty: Black Ops (New3DS only)
    • CStick to control the camera
    • ZR to run
  • Call of Duty: Modern Warfare 3 - Defiance (New3DS only)
    • CStick to control the camera
    • ZR to run
  • Call of Duty: World at War (New3DS only)
    • CStick to control the camera
    • ZR to run
  • Chibi-Robo: Clean Sweep! (Okaeri! Chibi-Robo! Happy Rich Oosouji!)
    • `CPad` to run, push, climb, use the Chibi-Vacuum, Chibi-Eyes, &c.
    • `Select` to interact with objects (when a red exclamation mark appears)
    • `Left` to open/close the Chibi-Menu
    • `Down` to equip the Chibi-Vacuum
    • `Up` to pick up, drop, or pull out the Plug from an outlet
    • `A/B` to answer "Yes" or "No" to a question
  • Chibi-Robo: Park Patrol
  • Dementium: The Ward (New3DS only)
    • CStick to control the camera
    • ZR to run
  • Dementium II (New3DS only)
    • CStick to control the camera
    • ZR to run
  • Dragon Ball: Origins
  • Dragon Ball: Origins 2
    • To work, set the input method to "Buttons Only" or "Both", not "Stylus Only"
  • Dragon Quest IX: Sentinels of the Starry Skies
  • Final Fantasy III
  • Final Fantasy IV
  • Flower, Sun and Rain: Murder and Mystery in Paradise
  • Geometry Wars: Galaxies (New3DS only)
    • CPad to move
    • CStick to shoot
    • To swap CPad and CStick, set "Handed" in the Options to "Left"
  • Golden Sun: Dark Dawn
  • GoldenEye 007 (New3DS only)
    • CStick to control the camera
    • ZR to run
  • Grand Theft Auto: Chinatown Wars
  • Harvest Moon DS: Island of Happiness
  • Harvest Moon DS: Sunshine Islands
  • Inazuma Eleven
  • Inazuma Eleven 2
  • Inazuma Eleven 3
  • Kingdom Hearts: 358-2 Days
    • CStick to control the camera
  • Kingdom Hearts: Re-coded
    • CStick to control the camera
  • LEGO Batman: The Videogame
  • LEGO Harry Potter: Years 1-4
  • LEGO Indiana Jones: The Original Adventures
  • LEGO Indiana Jones 2: The Adventure Continues
  • LEGO Star Wars: The Complete Saga
  • Lost in Blue
  • Lost in Blue 2
  • Lost in Blue 3
  • Magician's Quest: Mysterious Times
  • Metroid Prime: Hunters (CPad + CStick + Gyroscope, New 3DS only):
    • ZR to toggle the Scan Visor
    • ZL + Down to enable/disable the gyroscope
    • ZL + Up to recalibrate the gyro
    • ZL + Left to switch the gyro's axis (from Y to Z and back) responsible for turning the camera left/right
    • There is a version of the mod with an alternative controls scheme
    • The gyro may not work on certain devices due to incompatibility. I have no way to fix it.
  • Mini Ninjas
  • Moon (New3DS only)
    • CStick to control the camera
  • Nostalgia
  • Okamiden
  • Pac-Man World 3
  • Rayman DS
  • Ridge Racer DS
  • Rune Factory: A Fantasy Harvest Moon
  • Rune Factory 2: A Fantasy Harvest Moon
  • Rune Factory 3: A Fantasy Harvest Moon
  • Solatorobo: Red the Hunter
  • Star Fox Command:
  • Super Mario 64 DS:
  • Super Monkey Ball: Touch & Roll
  • Tak: The Great Juju Challenge
    • CStick to control the camera
  • Transformers: Decepticons
  • The Legend of Zelda: Phantom Hourglass and Spirit Tracks:
    • CPad is additionally used to rotate the camera around the train/ship
    • L + R + Down to unmap/map the CPad from the DPad (useful if you're using the DPad mods (i.e. Phantom Hourglass and Spirit Tracks))
  • The Wizard of Oz: Beyond the Yellow Brick Road
    • L/R for camera control
  • The World Ends with You
    • CPad or CStick to move the character
Source Code for most of my mods, all of them are about 95% identical (just a copy/paste). It might be useful if you want to port a mod to another platform (like an emulator or something). Then you only need the Arm9 part and a set of memory offsets (i.e. where to hook the game, etc) depending on the version of the game (and maybe the way it's all combined into one whole AR code), everything else is 3DS-TWPatcher-RTCom specific.



Original message from 2022-12-15:

Hello.
I couldn't find info about whether someone has already done this or not. My searching skills are terrible these days.

Anyway, I made this thing that allows playing sm64ds on 3DS using the Circle Pad like an almost normal human being. It was relatively simple, albeit time consuming. It requires TWPatcher (the last version, preferably) with RTCom enabled (as well as the Luma's config option "Enable loading external FIRMs and modules"), although it's enabled by default and probably impossible to disable at that point. And If it doesn't work, it may help to update the TwilightMenu app to the last version.

The patch is in the form of Action Replay code. It's in the zip file. Just select one text file from it with the cheat code for your rom. Get the cheat database file `usrcheat.dat` from your 3DS. It's supposed to be at `/_nds/TWiLightMenu/extras/usrcheat.dat` . If it's not there, then it can be downloaded somewhere on the internet. After that, open the cheat database in the program "r4cce" (or maybe somewhere else, i don't know), choose or add your game rom, and copy/paste this Action Replay code there. Save it and copy the file back to the device. By the way, there is also an already prepopulated `usrcheat.dat` (useful for quick testing). All what's left is to enable the cheat in the TwilightMenu menu. And it should work. Or maybe it won't, I don't know. It works for me (I've got New 2DS XL, the OS version is 11.12.0). There are too many things that can go wrong.

There are also cheat versions that allow camera rotation with the Nub stick X, ZL and ZR buttons. Nothing fancy here, they are just mapped to the buttons Left arrow / Right arrow on the touchscreen and obviously work only on the New 2DS/New 3DS devices. Plus, it looks like the Nub stick requires some additional preprocessing as its values seem to be rotated 45 degrees, so more chances of not-working, but whatever.



Troubleshooting (in case something doesn't work)

Examples: your game freezes completely at startup (all you see is a white screen), the game in general runs slowly, you can't control the main character, or it feels like all the buttons are being pressed at the same time, etc. The reason for this is most likely that you have not patched the TWL_FIRM (or rather TwlBg in it) properly with TWPatcher. Make sure that you've read its documentation and applied it appropriately. Maybe the following list will help you.
  • Games that don't support widescreen (or just mods for games that otherwise support widescreen) may need a separately patched TwlBg. Make two TwlBg versions in TWPatcher, one with widescreen and one without (both should have RTCom). Put the one with widescreen in "_nds/TWiLightMenu/TwlBg/" and rename it to "Widescreen.cxi" (or whatever the official guides say to enable widescreen). Leave the one without widescreen in "/luma/sysmodules" as "TwlBg.cxi". That way, TwilightMenu should swap them when a game has widescreen support and 16:10 mode is set, and not touch them otherwise.
  • Make sure the "external FIRMs and modules" option is enabled in Luma's configuration screen.
  • Update TWPatcher, TwilightMenu, Luma3DS, ...
  • Get the correct cheatcode .txt file for your version of a game. Just as an example: "ASME-F486F859 (USA v1.1)". "ASME" is a rom code (bytes 0xC-0xF), "F486F859" is a bitwise NOT of CRC32 (aka CRC-32/JAMCRC) of the first 200 bytes of the game's header (the cheat engine uses it to identify a game). "v1.1" means the second revision (aka "Rev 1", byte 0x1E)


Update 2022-12-20:
The current version has a problem with the game's music slowdown by about 10-15%.
I've made an alternative version "v2" that uses slightly different faulty approach. Instead of working with the RTCom to communicate with the Arm11 all the time, it only uses it to upload a piece of code that would overwrite some RTC functionality of TwlBg (not permanently, of course) and would hijack the RTC regs to pass the CPad data instead of actual time.
Although, there are two problems with my implementation.
Firstly, in super rare cases it may (or maybe it can't anymore, I'm not sure) crash the console (because it modifies code at runtime, probably in front of another thread that theoretically can execute it at that moment; and I don't even want to think about caching). But it seems fine for now, I've relaunched the game like 40 times and it was okay.
Secondly, it overwrites part of functionality that may be actually important, but I've never seen this code executed myself (my guess is it has something to do with alarms, but I don't use them). In either way, I think this is an interesting idea when executed properly

Update 2022-12-23:
New version v2.3. This time the patch won't replace any potentially useful functionality of TwlBg (it most likely didn't before anyway). I've also changed a bit the way ZL&ZR work. They are no longer hardcoded to the camera rotation. They can be swapped or remapped to other functions such as crouching or jumping. To remap these two keys (and half of the others), just go here, select your version, set preferred controls, and copy the AR code. Then the code can be added as usual in "r4cce" (as the new one, no need to extend this patch). However, I don't think this feature is very helpful.
In addition, I've added support for the iQue version of the game. And if someone's interested in the "technical" details of this project, there is also a Github page for this whole project. The code may not be exactly understandable, but if one had enough motivation to include CPad, CStick, or Gyroscope support to another game, this part certainly wouldn't be the hardest.

Update 2023-01-03
v2.4. a few mostly cosmetic changes.
- Reduced the cheatcodes' size by half by using the "EXXXXXXX NNNNNNNN" AR instruction to copy bytes in bulk instead of word by word. The speed should also increase similarly. Before, I thought that these codes get somehow optimized or converted into ARM, but it seems like nds-bootstrap has a piece of code that simply interprets them directly at runtime, 60 times per second, over and over again.
- The clock in nds-bootstrap's in-game menu now works properly. Solved by passing the CPad data through other RTC registers (alarm time 2 and DSi's counter).
- Reading RTC regs from NDS usually requires some kind of delay (gbatek says 5us for each bit transferred; nintendo puts a ~40 cycles there). But it looks like it's unnecessary in this case, everything works without them. That's naive, but I'd like to believe the reason for that is, as these legacy RTC registers are emulated, there are no real hardware behind it, thus delays aren't needed (on 3ds). The removal of these delays might be important, because some games (not this one, except for music) are hypersensitive to delays in their VBlank IRQ handlers.
- The problem with the sound distortions that I've mentioned somewhere around here has been finally solved (again). This time I rely on Arm11's RTCom autorelease feature (if I understand it correctly) to asynchronously initialize all the stuff and dynamically patch TwlBg. I think it used to take 20ms which was too much for Arm7 to swallow and so the distortions could pop up. Now Arm7 just sends one command to Arm11 to do all the work and doesn't wait for the answer (that frame).

Update 2023-01-18
I've created patches for several additional games.
Half of the patches are rather dumb and only use the CPad to control the direction of the main character, not their speed. Also, the cheats are mostly untested, I've only checked a few places here and there
  • Metroid Prime: Hunters (New 3DS/New 2DS only) - the CPad controls Samus' movement (in both the morph ball form and the "normal" FPS form). The nub stick controls the camera's left/right and up/down movement. ZR opens/closes the Scan Visor. There is also a gyroscope support for controlling the camera, albeit super awkward. Pressing ZL + Down toggles the gyroscope, but it needs to be calibrated first. To do that, place the console on a flat surface (or just hold it still) and press ZL + Up. Pressing ZL + Left toggles between the gyro axis responsible for the camera's horizontal rotation (Y or Z). Essentially it depends on how you hold the console, probably the right way would be to interpolate between them based on the accelerometer data, but that's too much for a hack. Overall, just a dumb gimmick.
  • Rayman DS - generally meaningless since the 3DS already has a native port that doesn't run in 16 fps (the DSi mode makes things just a little bit better). However, as a 3D platformer, it may be the best use case for such mods
  • The Legend of Zelda: Spirit Tracks - the CPad also controls the rotation of the camera around the train. Additionally, CPad is unmapped from the dpad keys (because by default they open the menu, map, etc). But if you're going to play with the DPad mods (one and two), you'll need to put it back. For that, press the "L+R+Down" combination, it will map or unmap the dpad
  • The Legend of Zelda: Phantom Hourglass - same, but for the ship
  • Grand Theft Auto: Chinatown Wars
  • Dragon Quest IX
  • LEGO Star Wars: The Complete Saga
  • Mini Ninjas
  • Okamiden
  • Animal Crossing: Wild World
Update 2023-01-25
- There was a problem when 3DS could just crash when starting a game (with 3-5% chance). I've fixed it and updated all patches (it's solved by flushing the data cache and invalidating instruction cache after patching the TwlBg at runtime). UPDATED: it's a lie. The crashes still happen.
- In Metroid, the camera could start moving in the opposite direction if you pushed the nub stick too hard. That also is supposed to be fixed now

Update 2023-02-19
- 3DS-NDS Key Remapper is a patch generator that allows you to map/remap any 3DS key to one or a combination of NDS keys. Furthermore, it's possible to map the CPad and CStick with ZL & ZR (for the New 3DS family); essentially, the sticks can behave as four separate keys (like CPad usually does when emulating the DPad). And, most importantly, it should theoretically work with any NDS game.
- To use just visit the page, click some checkboxes to setup mappings, copy the resulting cheatcode, and insert it into your game in R4CCE. Normally, this cheat should get activated after about 20 seconds (to avoid conflicts with my other patches). Due to this "late" initialization, there may be sound distortions (you'll know when you hear them). If this happens, just open and close nds-boostrap's in-game menu several times and the sound should eventually shift back. Or change the sound mode in a game's settings to something other than "Surround" or "Headphones" (if that's possible). Or change the start delay on the generation page to something like 10 if you're not using any CPad patches. Actually, there is another thing where it can interfere with the CPad patches. For simplicity's sake some patches (notably Metroid, Zeldas and Star Fox) unmap the CPad from the DPad (because the DPad isn't responsible for movement in those games and does something else (or it was just easier for me)). This remapper, when enabled, will override those settings.
- The Key Remapper works exactly like my other patches (uploading code to arm11, patching TwlBg at runtime, inserting a hook, etc), except here I don't pass any data to Arm7, but simply use Arm11's LGY_HIDEMU_MASK register to override native NDS keys (normally used to map CPad to DPad). The interesting thing here is that a cheatcode can be executed directly from nds-boostrap's cheat engine. It's useful in this case, because I'm patching TwlBg (that doesn't differ from game to game) rather than a specific game, so I don't need to know its layout. Also not sure about any performance implications. Won't be surprised if there are some timing delays, etc, because each key is funneled through that register.
- This thing requires the latest version of nds-bootstrap (currently v70). Older versions had a bug that didn't allow the C2 instruction to be used (it lets us execute arbitrary ARM code directly from a cheatcode, without uploading it into the game's memory).

Plus some lazy CPad patches:
  • Chibi-Robo! Park Patrol
  • Final Fantasy III
  • Final Fantasy IV
  • Kingdom Hearts: 358-2 Days
  • Kingdom Hearts: Re-coded
  • Magician's Quest: Mysterious Times
  • Nostalgia
  • Rune Factory 3: A Fantasy Harvest Moon
  • Solatorobo: Red the Hunter
  • Star Fox Command - A to boost, B to brake. This one is essentially a dpad patch by Cracker, except that I modified it to use the CPad.

Update 2023-04-16
  • Finally fixed a bug that could rarely crash the console when starting a game (I didn't handle RTCom errors properly)
  • Fixed a bug in Final Fantasy 3 when it would take too long to complete a turn during a battle
  • In SM64DS, the virtual joystick (a target) is now hidden from the bottom screen when the CPad is being used
  • The camera can now be controlled with the CStick in the Kingdom Hearts games in new New3DS-family-only versions
And several new mods for the following games:
  • C.O.P.: The Recruit
    • CPad is also used for steering a vehicle (a little bit)
    • CStick to control the camera
  • Call of Duty: Black Ops (New3DS only)
    • CStick to control the camera
    • ZR to run
    • To modify the sensitivity of the CStick (i.e. to increase the speed of the camera), find the hexadecimal number "00000142" in the cheatcode (it's somewhere near the end) and change it to something else
  • Chibi-Robo: Clean Sweep! (Okaeri! Chibi-Robo! Happy Rich Oosouji!)
    • `CPad` to run, push, climb, use the Chibi-Vacuum, Chibi-Eyes, &c.
    • `Select` to interact with objects (when a red exclamation mark appears)
    • `Left` to open/close the Chibi-Menu
    • `Down` to equip the Chibi-Vacuum
    • `Up` to pick up, drop, or pull out the Plug from an outlet
    • `A/B` to answer "Yes" or "No" to a question
  • Dementium II (New3DS only)
    • CStick to control the camera
    • ZR to run
    • To change the CStick sensitivity, find and modify the hex number "00000011" in the cheatcode
  • Flower, Sun and Rain: Murder and Mystery in Paradise
  • GoldenEye 007 (New3DS only)
    • CStick to control the camera
    • ZR to run
    • To change the CStick sensitivity, find and modify the hex number "00000210" in the cheatcode

Update 2023-04-20
  • LEGO Batman: The Videogame
  • LEGO Harry Potter: Years 1-4
  • LEGO Indiana Jones: The Original Adventures
  • LEGO Indiana Jones 2: The Adventure Continues
Update 2023-04-23
  • Pac-Man World 3
Update 2023-07-30
Fixed a bug in "Kingdom Hearts 358/2 Days" that caused the camera to go up without pressing any key

Update 2023-08-13
  • Rune Factory: A Fantasy Harvest Moon
  • Rune Factory 2: A Fantasy Harvest Moon
  • Transformers: Decepticons
Update 2023-08-21
  • Super Monkey Ball: Touch & Roll
Update 2023-09-13
  • Golden Sun: Dark Dawn
Update 2023-10-05
  • Ridge Racer DS
Update 2023-10-15
  • Dragon Ball: Origins
  • Dragon Ball: Origins 2
  • Lost in Blue
  • Lost in Blue 2
  • Lost in Blue 3
Update 2023-10-16
  • Geometry Wars: Galaxies (New3DS only)
    • CPad to move
    • CStick to shoot
    • To swap CPad and CStick, set "Handed" in the Options to "Left"
Update 2023-10-31
Fixed an issue in LoZ: Spirit Tracks (compatibility with the DPad patch)
  • Call of Duty: World at War (New3DS only)
    • CStick to control the camera
    • ZR to run
    • To change the CStick sensitivity (camera speed) find and change this hex value in the cheat code: 00000020
  • Dementium: The Ward (New3DS only)
    • CStick to control the camera
    • ZR to run
    • To change the CStick sensitivity (camera speed) find and change this hex value in the cheat code: 00000011
  • Harvest Moon DS: Island of Happiness
  • Harvest Moon DS: Sunshine Islands
  • Moon (New3DS only)
    • CStick to control the camera
    • To change the CStick sensitivity (camera speed) find and change this hex value in the cheat code: 00000011
Update 2023-11-12
  • The Wizard of Oz: Beyond the Yellow Brick Road
    • L/R for camera control
Update 2023-11-16
  • Inazuma Eleven
  • Inazuma Eleven 2
  • Inazuma Eleven 3
Update 2023-12-16
Now, In Star Fox, you can do a barrel roll by pressing X
New mods:
  • Call of Duty: Modern Warfare 3 - Defiance (New3DS only)
    • CStick to control the camera
    • ZR to run
    • To change the CStick sensitivity (camera speed) find and change this hex value in the cheat code: 00000152
  • Star Wars: Lethal Alliance
Update 2023-12-19
Fixed a small bug in Star Wars: Lethal Alliance. Now there's a proper 360 movement (previously the game would prioritize the forward direction for the main character)

Update 2023-12-28
  • The World Ends with You
    • CPad or CStick to move the character
Update 2024-03-31
  • Tak: The Great Juju Challenge
    • CStick to control the camera
  • fixed a bug in Metroi Prime Hunters that allowed you to control certain enemies and move the character during the cutscenes











Just in case, I did not check all of them. They may not work properly or may be out of date.

I by @Cragdore
II by @The Catboy
III by @Vendicatorealato
IV by @Russ9876
V by @selcuk



xdelta version of the patches for SM64DS by @DeadSkullzJr (Action Replay cheatcodes or usrcheat.dat are not required anymore)

Thanks for the amazing work Shoco, and I appreciate the link to my video. It was an amazing experience playing through these games with the circle pad's smooth controls. 2024 is looking to be an ambitious year for 3DS and Wii U homebrew, and I can't stress enough how impressive you modders' work ends up being.
 
  • Like
Reactions: shoco

Chris_Highwind

Well-Known Member
Member
Joined
Mar 21, 2010
Messages
437
Trophies
1
Age
33
Location
Mooresville, NC
XP
573
Country
United States
Would it be possible to edit the SM64DS patch for New 3DS so that the ZL and ZR buttons function as L and R respectively? My R button no longer functions, so I'm unable to do anything that requires the R button, and I've been trying to map everything that the R button does to the ZR button when/if I can.
 

shoco

Well-Known Member
OP
Member
Joined
Aug 1, 2019
Messages
118
Trophies
0
XP
508
Country
Russia
It would be amazing to have this mod for Phantasy Star Zero! It seems quite a few people complain about the controls.
Cpad Analog movement, and if possible the mini cstick for the camera, would be a real quality of life enhancement for the game.

ZL / ZR being able to trigger actions from the 2nd action palette would be cool too, but maybe out of scope.
So can Sonic Chronicles get a circle pad patch now? @shoco
Now that I think of it, Crash of the Titans is another game that would benefit from the CPad patch.
Any chance you could make a patch for the Japanese version of Animal Crossing Wild World? Would really appreciate it, thanks.
Done.

Ah, thank you so much! It appears I can indeed attach files. I should note that there are *three* airships in Final Fantasy IV, and I don't think they're all in the same location (it's a little tricky moving them all to the same place). I hope a .7z is alright.

Oh, and there are three ships in Final Fantasy III as well, but you blow one up in the first hour or so of the game.
Thanks for the saves. I have updated the mod for Final Fantasy 4. And as I can see, the airships work correctly in Final Fantasy 3 already without any changes.

Hi shoco, I tried the Cpad code for The Koopa Who Stole Christmas on the O3DS and the ROM crashes on boot, but when I tried the Cstick version it does work but the camera moves with the Cpad as well. Could you fix the first one to work as intended? Thanks
I can confirm, on my side it crashes on nds-bootstrap red screen after selecting the save file in game. The version of The Koopa Who Stole Christmas is 1.1.1, and I am on a New 3DS with TWL v27.0.0 + nds-bootstrap v1.4.3.
Please try this one (use the Europe version as usual). If it doesn't work, I'd like to have your saves. And update nds-bootstrap just in case
Post automatically merged:

Would it be possible to edit the SM64DS patch for New 3DS so that the ZL and ZR buttons function as L and R respectively? My R button no longer functions, so I'm unable to do anything that requires the R button, and I've been trying to map everything that the R button does to the ZR button when/if I can.
I think you can already do it either with sm64ds_remap_codegen or 3ds_nds_remap_codegen
 

Attachments

  • sm64ds_cpad_mod_v2.zip
    42.1 KB · Views: 1

That1Tem

New Member
Newbie
Joined
Apr 26, 2024
Messages
1
Trophies
0
Age
22
XP
3
Country
United States
How do you get the sm64 ds patch to appear for another super Mario 3d
Post automatically merged:

Could someone explain how to use the sm64 ds 1.0 patch with Another super Mario bros
 
Last edited by That1Tem,

cearp

瓜老外
Developer
Joined
May 26, 2008
Messages
8,726
Trophies
2
XP
8,512
Country
Tuvalu
Update 2024-04-26
New games:
  • - Phantasy Star 0
    • CStick to control the camera
    • ZL & ZR to trigger actions from the second palette (i.e. the same as pressing R+Y and R+A)
Thank you buddy I will try to test that out next week - so cool!! Massively appreciated :toot:
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
    K3Nv2 @ K3Nv2: Lol rappers still promoting crypto