gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > I need some debugging tips

#42686 - rize - Sat May 14, 2005 12:00 am

I'm driving myself crazy trying to debug some stuff I'm working on.

Between having no ability to step through the code *and* having a console that can only show 25 lines of output at a time this is just all kinds of tedious. And I should also mention emulators that don't necessarily work right (and no pass through just yet).

Are there any techniques for dealing with this other than making sure my error output never exceeds 25 lines?

#42687 - DekuTree64 - Sat May 14, 2005 12:07 am

Not that I know of, but it would be pretty easy to code up a scrolling debug output that sits on the top screen. I might whip one of those up myself tomorrow...
_________________
___________
The best optimization is to do nothing at all.
Therefore a fully optimized program doesn't exist.
-Deku

#42694 - josath - Sat May 14, 2005 1:33 am

if you're using dualis, it supports a debug print function that prints to the dualis console (Ctrl+C to bring it up i think):

Code:
// Outputs a string to the dualis console
void print(char *s) {
    // warning! will crash on hardware (i think)!
    asm volatile ("mov r0, %0;" "swi 0xff0000;":
                  :"r" (s):"r0");
}

#42709 - rize - Sat May 14, 2005 3:36 am

oh man... that rocks

I had just gotten finished deciding to simply tokenize my debug and stop using line breaks to save space

of course, you have to convert vars to strings so it's a little less flexible

#42721 - rize - Sat May 14, 2005 6:25 am

hmm... of all the stupid things I'm having trouble converting standard data types into strings.

ordinarily you'd use consolePrintf("... %d", int);

or

cout << "..." << int << "...";

but I need a string as an argument to the print(*char); function.

naturally I could write some functions to do this for me, but I figure there must be some already. But so far I haven't found any. And the C++ <string> include doesn't seem to give me access to the C++ string class in the DS environment.

#42722 - josath - Sat May 14, 2005 6:40 am

how about this: (this is what i usually do)
Code:

int x=10, y=20;
char buf[1024];
sprintf(buf, "debug position: %d / %d", x, y);
print(buf);

#42723 - rize - Sat May 14, 2005 6:49 am

didn't know that was possible (my c skills aren't up to snuff). Thanks for the tips, this should make life, much, much easier.