Pages: 1
Posted on 09-25-12, 07:30 pm (rev. 1 by ImageBot on 11-21-16, 02:31 am)
Super Mario
( ͡° ͜ʖ ͡°)

Karma: 10010
Posts: 2592/4457
Since: 06-08-11

The code:
#include<nds.h>
#include "nsmb.h"

extern "C" {
        void OS_Panic();
        void myprintf(u16 something[2], u16* screenPtr, const char* str);
}

void hook_020123DC()
{
        if(!(REG_KEYINPUT & KEY_SELECT))
                OS_Panic();
}

#define WHITE 0xD000
#define GREEN 0xE000
#define RED 0xF000

void printAtPos(int x, int y, int color, const char* c)
{
        u16** topScreenPtr = (u16**) 0x020859EC;

        u16 something[2];
        something[0] = color;
        something[1] = color;

        myprintf(something, *topScreenPtr + x+y*32, c);
}

void nsub_02005EB0()
{
        printAtPos(1, 1, RED, "Hello NSMBHD!");
}
.

The first hook makes the debug screen trigger when pressing Select.
THe second one modifies the text. That function is the function that writes the stuff in the top screen. There's probably a similar one for the bottom screen.

And add this to symbols.x: (damn I need to update that file)
OS_Panic = 0x020045EC; myprintf = 0x02006370;

Posted on 09-25-12, 07:37 pm
Fuzzy
Full mod

Karma: 1183
Posts: 531/785
Since: 06-28-11
Wow, cool

I assume the purpose of this is that you could use it to debug your own ASM hacks? Just modify that function and make it output information relevant to whatever you're working on.
Posted on 09-25-12, 07:58 pm
Super Mario
( ͡° ͜ʖ ͡°)

Karma: 10010
Posts: 2594/4457
Since: 06-08-11
Pretty much yeah.
The only problem is that once the debug screen is triggered, it's impossible to get back to the game, so it's not useful as a logging console.

I was planning to turn it into a RAM viewer or something so I could look at the values of variables in MvsL mode. There are no emulators that can emulate local wifi play.

I was gong to do it from scratch with libnds's console but I was getting some compilation errors about malloc. I guess they're fixable, but I got lazy and then I thought it'd be easier and more fun to look at how's the debug screen made and hax it.

There's also a printf-like function, they use it to write all the hex numbers and all. The one I used just prints a string as-is (I think).



Posted on 09-25-12, 09:06 pm
I am random… very random.

Karma: 750
Posts: 219/682
Since: 01-17-12
This is cool! We might be able to actually try to make the Debug Screen act like a RAM Viewer,or a Filebrowser of NSMBDS & find all sorts of new information! The sad part is that this might take a while...
<Silvreus>It has been 1 month, 4 days, 2 hours, 21 minutes and 3 seconds since I last remember being lazy.

Posted on 09-26-12, 05:51 pm
Shyguy


Karma: 160
Posts: 35/90
Since: 07-10-12
Nice! Maybe you remove the background or something. Then you can see the game, but with the debug information.
Posted on 09-28-12, 02:55 am (rev. 1 by ImageBot on 11-21-16, 02:31 am)
Super Mario
( ͡° ͜ʖ ͡°)

Karma: 10010
Posts: 2596/4457
Since: 06-08-11
And I turned it into a RAM viewer now!


Posted by Gericom
Nice! Maybe you remove the background or something. Then you can see the game, but with the debug information.

That's totally impossible at all. This is a crash screen. When it gets triggered, it changes the video mode, erases stuff in VRAM, and other stuff. It isn't even possible to "go back" to the game once the debug screen is triggered.

(It's triggered with the OS_Panic() function, or with a hardware exception, like accessing bad memory)
Pages: 1