ROM Hack Button List for NTR cheat plugin creation?

Metab

Well-Known Member
OP
Member
Joined
Mar 23, 2013
Messages
155
Trophies
0
Age
27
Location
Where dat ass is
XP
289
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
27
Location
Where dat ass is
XP
289
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
27
Location
Where dat ass is
XP
289
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
27
Location
Where dat ass is
XP
289
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
27
Location
Where dat ass is
XP
289
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,958
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
  • Psionic Roshambo @ Psionic Roshambo:
    @The Real Jdbye, I could see AMD trying to pull off the CPU GPU tandem thing, would be a way to maybe close the gap a bit with Nvidia. Plus it would kinda put Nvidia at a future disadvantage since Nvidia can't make X86/64 CPUs? Intel and AMD licensing issues... I wonder how much that has held back innovation.
  • The Real Jdbye @ The Real Jdbye:
    i don't think nvidia wants to get in the x64 cpu market anyways
  • The Real Jdbye @ The Real Jdbye:
    you've seen how much intel is struggling getting into the gpu market
  • The Real Jdbye @ The Real Jdbye:
    and nvidia is already doing ARM
  • The Real Jdbye @ The Real Jdbye:
    i don't think they want to take more focus away from their gpus
  • Psionic Roshambo @ Psionic Roshambo:
    Yeah I think Nvidia s future lays in AI GPU acceleration stuff if they can get that going it's going to be super interesting in the long term
  • Psionic Roshambo @ Psionic Roshambo:
    AI assisted game creation might become a thing
  • Psionic Roshambo @ Psionic Roshambo:
    At least that's something I think would be pretty cool.
  • Psionic Roshambo @ Psionic Roshambo:
    Don some VR glasses and gloves and talk to the computer and paint entire worlds
  • Psionic Roshambo @ Psionic Roshambo:
    "OK Cortana I want that mountain a little taller and more snow on top, and I would like some random ancient pine forest around the bottom"
  • Psionic Roshambo @ Psionic Roshambo:
    "Now we need a spring fed river flowing down the north side and add some wild life appropriate for the biome"
  • Psionic Roshambo @ Psionic Roshambo:
    Many TBs of assets and the programming of something like that is going to be tough but I think it's something we might see in 20 years maybe sooner
  • The Real Jdbye @ The Real Jdbye:
    @Psionic Roshambo AI assisted game creation is kinda already here, there was recently that AI that can turn any 2D image into a fully modeled 3D object, it's not perfect, but it's a starting point, beats starting from zero
    +1
  • The Real Jdbye @ The Real Jdbye:
    before that there was one to generate a fully modeled scene from a 2D image
    +1
  • The Real Jdbye @ The Real Jdbye:
    but most recently, there was one that actually generates a working unity scene with terrain and textures already set up that you can import right into unity, that's a huge time saver right there
    +1
  • The Real Jdbye @ The Real Jdbye:
    and using LLMs to generate NPC dialogue and even dynamically generated quests is something i'm sure is already happening
    +1
  • The Real Jdbye @ The Real Jdbye:
    will just take some time for games made using those things to be completed and released
    +1
  • K3Nv2 @ K3Nv2:
    @The Real Jdbye, it's bed bath and beyond you nitwit
  • The Real Jdbye @ The Real Jdbye:
    @K3Nv2 you said instructions with pictures, same difference
  • Psionic Roshambo @ Psionic Roshambo:
    Lol now with 32GBs of VRAM Ken?
  • K3Nv2 @ K3Nv2:
    No IKEA shit breaks within a month bed bath and beyond goes beyond
  • K3Nv2 @ K3Nv2:
    Plus pictures don't always cut it with furniture when there's like 10 different bolt styles and they're just like figure it out
  • K3Nv2 @ K3Nv2:
    It's not like how people whack it to uremums onlyfans :teach:
    K3Nv2 @ K3Nv2: It's not like how people whack it to uremums onlyfans :teach: