ROM Hack Button List for NTR cheat plugin creation?

Metab

Well-Known Member
OP
Member
Joined
Mar 23, 2013
Messages
155
Trophies
0
Age
28
Location
Where dat ass is
XP
299
Country
Learning how to create cheats with this:
https://gbatemp.net/threads/tutorial-building-ntr-custom-firmware-cheat-plugins-w-cheat-menu.411189/
Is there some documentation on each button on the 3DS' corresponding code snippet for useage?

A snippet in the thread tells me select is 'BUTTON_SE'

Code:
key = getKey();
        if (key == BUTTON_SE) {
            // toggle cheats when SELECT button pressed
            cheatEnabled = !cheatEnabled;
            // wait until key is up
            waitKeyUp();
        }
        if (cheatEnabled) {
            // freeze hearts
            WRITEU16(0x168b6044 , 0x5050);
            // freeze rupees
            WRITEU16(0x168b5fa8 , 9999);
        }
 

Nanquitas

Well-Known Member
Member
Joined
Sep 29, 2015
Messages
2,345
Trophies
0
Age
30
Location
South of France :)
XP
3,336
Country
France
Hi :)

The buttons are defined in a file (don't remember the names), but here the list:
Code:
BUTTON_A
BUTTON_B
BUTTON_X
BUTTON_Y
BUTTON_DL
BUTTON_DR
BUTTON_DD
BUTTON_DU
BUTTON_L
BUTTON_R
BUTTON_SE
BUTTON_ST

Of course you can use multiple button with the '+' operator.
exemple:
Code:
if (getKey() == BUTTON_L + BUTTON_R + BUTTON_X)
{
// do a super ultra amazing thing !!!
}

Some functions I found useful if you don't have those:
Code:
//Wait for the all the input to be released
void    releaseKey(void)
{
    while (1)
    {
        if (getKey() == 0)
            return;
    }
}

//Wait for the input to change
void    waitKeyChange(u32  keys)
{
    while (1)
    {
        if (getKey() != keys)
            return;
    }
}

//Wait for an input
u32    waitKey(void)
{
    while (1)
    {
        if (getKey() != 0)
            return (getKey());
    }
}
 
  • Like
Reactions: cearp

Metab

Well-Known Member
OP
Member
Joined
Mar 23, 2013
Messages
155
Trophies
0
Age
28
Location
Where dat ass is
XP
299
Country
ey = getKey(); if (key == BUTTON_SE) { // toggle cheats when SELECT button pressed cheatEnabled = !cheatEnabled; // wait until key is up waitKeyUp(); } if (cheatEnabled) { // freeze hearts WRITEU16(0x168b6044 , 0x5050); // freez
Hi :)

The buttons are defined in a file (don't remember the names), but here the list:
Code:
BUTTON_A
BUTTON_B
BUTTON_X
BUTTON_Y
BUTTON_DL
BUTTON_DR
BUTTON_DD
BUTTON_DU
BUTTON_L
BUTTON_R
BUTTON_SE
BUTTON_ST

Of course you can use multiple button with the '+' operator.
exemple:
Code:
if (getKey() == BUTTON_L + BUTTON_R + BUTTON_X)
{
// do a super ultra amazing thing !!!
}

Some functions I found useful if you don't have those:
Code:
//Wait for the all the input to be released
void    releaseKey(void)
{
    while (1)
    {
        if (getKey() == 0)
            return;
    }
}

//Wait for the input to change
void    waitKeyChange(u32  keys)
{
    while (1)
    {
        if (getKey() != keys)
            return;
    }
}

//Wait for an input
u32    waitKey(void)
{
    while (1)
    {
        if (getKey() != 0)
            return (getKey());
    }
}
WOw I really appreciate you posting that it helps alot,
So far out of the codes ive tested (freez vaue for Naruto game, and A to boost on mario game) its all crashed, am I just getting bad codes (atleast with the freeze ones which are straight foward)?
 

Nanquitas

Well-Known Member
Member
Joined
Sep 29, 2015
Messages
2,345
Trophies
0
Age
30
Location
South of France :)
XP
3,336
Country
France
Post the code you wrote, I'll help you debugging it. ;)

If the console crash, it's more than just a bad code.
Probably a wrong address, or an address you don't have the right to edit.
 
  • Like
Reactions: cearp

Metab

Well-Known Member
OP
Member
Joined
Mar 23, 2013
Messages
155
Trophies
0
Age
28
Location
Where dat ass is
XP
299
Country
Post the code you wrote, I'll help you debugging it. ;)

If the console crash, it's more than just a bad code.
Probably a wrong address, or an address you don't have the right to edit.
Sure, sec
But when it crashes its not like bam, gone, its like 'something went wrong, hold power button' message.
 

Metab

Well-Known Member
OP
Member
Joined
Mar 23, 2013
Messages
155
Trophies
0
Age
28
Location
Where dat ass is
XP
299
Country
Yeah, it's always like that. ;)
Ah no worries, here my Mario Kart 7 attempts
cheatEnabled[0] boolean was an attempt at 'A to boost' copied straight from http://www.fort42.com/gateshark/game14/6819/
cheatEnabled[1] boolean is attempting to unlock all charatcers from here http://www.fort42.com/gateshark/game14/1998/
Code:
#include "global.h"

#define WRITEU8(addr, data) *(vu8*)(addr) = data
#define WRITEU16(addr, data) *(vu16*)(addr) = data
#define WRITEU32(addr, data) *(vu32*)(addr) = data

u32 threadStack[0x1000];
Handle fsUserHandle;
FS_archive sdmcArchive;


#define IO_BASE_PAD        1
#define IO_BASE_LCD        2
#define IO_BASE_PDC        3
#define IO_BASE_GSPHEAP        4

u32 IoBasePad = 0xFFFD4000;

u32 getKey() {
    return (*(vu32*)(IoBasePad) ^ 0xFFF) & 0xFFF;
}

void waitKeyUp() {
    while (getKey() != 0) {
        svc_sleepThread(100000000);
    }
}

u8 cheatEnabled[64];
int isNewNtr = 0;


u32 plgGetIoBase(u32 IoType);
GAME_PLUGIN_MENU gamePluginMenu;

void initMenu() {
    memset(&gamePluginMenu, 0, sizeof(GAME_PLUGIN_MENU));
}

void addMenuEntry(u8* str) {
    if (gamePluginMenu.count > 64) {
        return;
    }
    u32 pos = gamePluginMenu.count;
    u32 len = strlen(str) + 1;
    gamePluginMenu.offsetInBuffer[pos] = gamePluginMenu.bufOffset;
    strcpy(&(gamePluginMenu.buf[gamePluginMenu.bufOffset]), str);
   
    gamePluginMenu.count += 1;
    gamePluginMenu.bufOffset += len;
}

u32 updateMenu() {
    PLGLOADER_INFO *plgLoaderInfo = (void*)0x07000000;
    plgLoaderInfo->gamePluginPid = getCurrentProcessId();
    plgLoaderInfo->gamePluginMenuAddr = (u32)&gamePluginMenu;
   
    u32 ret = 0;
    u32 hProcess;
    u32 homeMenuPid = plgGetIoBase(5);
    if (homeMenuPid == 0) {
        return 1;
    }
    ret = svc_openProcess(&hProcess, homeMenuPid);
    if (ret != 0) {
        return ret;
    }
    copyRemoteMemory( hProcess, &(plgLoaderInfo->gamePluginPid), CURRENT_PROCESS_HANDLE,  &(plgLoaderInfo->gamePluginPid), 8);
    final:
    svc_closeHandle(hProcess);
    return ret;
}

int scanMenu() {
    u32 i;
    for (i = 0; i < gamePluginMenu.count; i++) {
        if (gamePluginMenu.state[i]) {
            gamePluginMenu.state[i] = 0;
            return i;
        }
    }
    return -1;
}

// detect language (0: english)
int detectLanguage() {
    // unimplemented
    return 0;
}

// add one cheat menu entry
void addCheatMenuEntry(u8* str) {
    u8 buf[100];
    xsprintf(buf, "[ ] %s", str);
    addMenuEntry(buf);
}

// this function will be called when the state of cheat item changed
void onCheatItemChanged(int id, int enable) {
    // TODO: handle on cheat item is select or unselected
   

}

// freeze the value
void freezeCheatValue() {
    if(cheatEnabled[1]) {
        WRITEU16(0xD3000000, 0x14000000);
        WRITEU16(0x1013CD30, 0x00003FFF);
    }
   
    /*if (cheatEnabled[0]) {
        WRITEU16(0x2041A178, 0x00000078);
        WRITEU16(0x20419FDC, 0x00000078);
        WRITEU16(0x2041A314, 0x00000078);
        WRITEU16(0x2041A984, 0x00000078);
        WRITEU16(0x2041AE58, 0x00000078);
        WRITEU16(0x2041A64C, 0x00000078);
    }*/
    // TODO: handle your own cheat items
}

// update the menu status
void updateCheatEnableDisplay(id) {
    gamePluginMenu.buf[gamePluginMenu.offsetInBuffer[id] + 1] = cheatEnabled[id] ? 'X' : ' ';
}

// scan and handle events
void scanCheatMenu() {
    int ret = scanMenu();
    if (ret != -1) {
        cheatEnabled[ret] = !cheatEnabled[ret];
        updateCheatEnableDisplay(ret);
        onCheatItemChanged(ret, cheatEnabled[ret]);
    }
}

// init
void initCheatMenu() {
    initMenu();
    addCheatMenuEntry("A to boost(Broken!)");
    addCheatMenuEntry("All Karts!");
    //addCheatMenuEntry("Naruto EXP");
   
    updateMenu();
}

void gamePluginEntry() {
    u32 ret, key;
    INIT_SHARED_FUNC(plgGetIoBase, 8);
    INIT_SHARED_FUNC(copyRemoteMemory, 9);
    // wait for game starts up (5 seconds)
    svc_sleepThread(5000000000);

    if (((NS_CONFIG*)(NS_CONFIGURE_ADDR))->sharedFunc[8]) {
        isNewNtr = 1;
    } else {
        isNewNtr = 0;
    }
   
    if (isNewNtr) {
        IoBasePad = plgGetIoBase(IO_BASE_PAD);
    }
    initCheatMenu();
    while (1) {
        svc_sleepThread(100000000);
        key = getKey();
        if (cheatEnabled[0]) {
            if (key == BUTTON_A) {
                WRITEU16(0xD3000000, 0x10000000);
                WRITEU16(0x947909D4, 0x00000001);
                WRITEU16(0x6400F750, 0x00000000);
                WRITEU16(0xB400F750, 0x00000000);
                WRITEU16(0xB0000518, 0x00000000);
                WRITEU16(0xB000001C, 0x00000000);
                WRITEU16(0x0000103C, 0x04000000);
                WRITEU16(0xD2000000, 0x00000000);
                 // toggle cheats when SELECT button pressed
                 //cheatEnabled[0] = !cheatEnabled[0];
                 // wait until key is up
                 //waitKeyUp();
            }
        }
        scanCheatMenu();
        freezeCheatValue();
    }
}

Please ignore how messy it is, I plan to write a program that will just auto generate this piece of code and I can just dump gateway codes into!
 

Nanquitas

Well-Known Member
Member
Joined
Sep 29, 2015
Messages
2,345
Trophies
0
Age
30
Location
South of France :)
XP
3,336
Country
France
Hmm, the problem is that you just wrote the raw gateways codes, you didn't convert them in C.

Look how the gateways codes are working (and means), and convert them in C.

In my github (search for Nanquitas ;) ) I've shared two sources of plugins I made.
Look for the cheats.c file, all the codes I've translated are in it.
 

Metab

Well-Known Member
OP
Member
Joined
Mar 23, 2013
Messages
155
Trophies
0
Age
28
Location
Where dat ass is
XP
299
Country
Hmm, the problem is that you just wrote the raw gateways codes, you didn't convert them in C.

Look how the gateways codes are working (and means), and convert them in C.

In my github (search for Nanquitas ;) ) I've shared two sources of plugins I made.
Look for the cheats.c file, all the codes I've translated are in it.
Ah I see, ive fond your github page but im not sure how to convert these values in C (Or what that means! D:)
But your code is great reference and will make making my program and cheat files way easier!
 

Nanquitas

Well-Known Member
Member
Joined
Sep 29, 2015
Messages
2,345
Trophies
0
Age
30
Location
South of France :)
XP
3,336
Country
France
To help you if you plan using my sources:
The only files you need to edit are the menu.c, cheats.c and you add the prototype of your cheats functions in the cheats.h.

Then in gameplg.c you have key_trigger functions, you can add functions which will be executed with keys in it.

You don't need to edit the rest of the files, unless you know C and know how to optimize it.
The spoiler / cheats, are all done automatically when you're stating the menu.

You can also find all the functions availbale in the cheats.h. The names should be understandable.

Also my plugins are usable online. ;)
 

Nanquitas

Well-Known Member
Member
Joined
Sep 29, 2015
Messages
2,345
Trophies
0
Age
30
Location
South of France :)
XP
3,336
Country
France
If you're motivated, with a little time to learn the basics of C programming, I'm sure you can find how the whole thing work.

Or you can take one of my plugin, and comparing the C code I wrote with the Gateway's codes from fort42 to see how I did the conversion. ;)
 

BerserkLeon

Not-so-new member
Member
Joined
Mar 22, 2010
Messages
460
Trophies
1
Age
34
Location
Pennsylvania
XP
538
Country
United States
@Nanquitas how did you make them work online? I've only experience with menucheat.

Also I don't know C but Ill look for your sources and see what code types you've figured out.

...A program to drop the copy/pasteble stuff into a new file sounds nice, but you could probably do it with autohotkey or another macro program.
 

Ricken

Searching for the air to breathe~
Member
Joined
Jan 19, 2016
Messages
2,661
Trophies
1
Age
21
Location
Mid-Michigan
XP
2,960
Country
United States
If you're motivated, with a little time to learn the basics of C programming, I'm sure you can find how the whole thing work.

Or you can take one of my plugin, and comparing the C code I wrote with the Gateway's codes from fort42 to see how I did the conversion.
Just let me say, you would be a godsend if you made something to convert the Gateshark codes then generate a cheat.plg ;)
 

Nanquitas

Well-Known Member
Member
Joined
Sep 29, 2015
Messages
2,345
Trophies
0
Age
30
Location
South of France :)
XP
3,336
Country
France
@Nanquitas how did you make them work online? I've only experience with menucheat.

Also I don't know C but Ill look for your sources and see what code types you've figured out.

...A program to drop the copy/pasteble stuff into a new file sounds nice, but you could probably do it with autohotkey or another macro program.

I did my own main.c to make them work online.
The sources given by Cell9 contains the main.c already compiled and it's in it that Cell9 blocked the networks. ;)

All the Gateshark Code can be converted to plugin. ;)

--------------------- MERGED ---------------------------

Just let me say, you would be a godsend if you made something to convert the Gateshark codes then generate a cheat.plg ;)
Maybe I'll work on something like that, but I want to do a plugin that can read and execute gateways code from text file directly on the 3DS.
But I don't know when I'll do that, I haven't too much time and I already have a project going on (RAM Explorer)...

But one day who knows... ;)
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
  • TwoSpikedHands @ TwoSpikedHands:
    @Sicklyboy I am wanting to fully change the game and bend it to my will lol. I would like to eventually have the ability to add more characters, enemies, even have a completely different story if i wanted. I already have the ability to change the tilemaps in the US version, so I can basically make my own map and warp to it in game - so I'm pretty far into it!
  • TwoSpikedHands @ TwoSpikedHands:
    I really would like to make a hack that I would enjoy playing, and maybe other people would too. swapping to the EU version would also mean my US friends could not legally play it
  • TwoSpikedHands @ TwoSpikedHands:
    I am definitely considering porting over some of the EU features without using the actual ROM itself, tbh that would probably be the best way to go about it... but i'm sad that the voice acting is so.... not good on the US version. May not be a way around that though
  • TwoSpikedHands @ TwoSpikedHands:
    I appreciate the insight!
  • The Real Jdbye @ The Real Jdbye:
    @TwoSpikedHands just switch, all the knowledge you learned still applies and most of the code and assets should be the same anyway
  • The Real Jdbye @ The Real Jdbye:
    and realistically they wouldn't

    be able to play it legally anyway since they need a ROM and they probably don't have the means to dump it themselves
  • The Real Jdbye @ The Real Jdbye:
    why the shit does the shitbox randomly insert newlines in my messages
  • Veho @ Veho:
    It does that when I edit a post.
  • Veho @ Veho:
    It inserts a newline in a random spot.
  • The Real Jdbye @ The Real Jdbye:
    never had that i don't think
  • Karma177 @ Karma177:
    do y'all think having an sd card that has a write speed of 700kb/s is a bad idea?
    trying to restore emunand rn but it's taking ages... (also when I finished the first time hekate decided to delete all my fucking files :wacko:)
  • The Real Jdbye @ The Real Jdbye:
    @Karma177 that sd card is 100% faulty so yes, its a bad idea
  • The Real Jdbye @ The Real Jdbye:
    even the slowest non-sdhc sd cards are a few MB/s
  • Karma177 @ Karma177:
    @The Real Jdbye it hasn't given me any error trying to write things on it so I don't really think it's faulty (pasted 40/50gb+ folders and no write errors)
  • DinohScene @ DinohScene:
    run h2testw on it
    +1
  • DinohScene @ DinohScene:
    when SD cards/microSD write speeds drop below a meg a sec, they're usually on the verge of dying
    +1
  • Psionic Roshambo @ Psionic Roshambo:
    Samsung SD format can sometimes fix them too
  • Purple_Heart @ Purple_Heart:
    yes looks like an faulty sd
  • Purple_Heart @ Purple_Heart:
    @Psionic Roshambo i may try that with my dead sd cards
    +1
  • Psionic Roshambo @ Psionic Roshambo:
    It's always worth a shot
  • TwoSpikedHands @ TwoSpikedHands:
    @The Real Jdbye, I considered that, but i'll have to wait until i can get the eu version in the mail lol
  • I @ I-need-help-with-wup-wiiu:
    i need help with nusspli failed downloads, can someone respond to my thread? pretty please:wub:
  • Sheeba- @ Sheeba-:
    I can't wait to hack my 11.00 PS4 pro
    Sheeba- @ Sheeba-: I can't wait to hack my 11.00 PS4 pro