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.

Coding > printf output

#3467 - mantrid - Tue Feb 25, 2003 4:06 pm

I called this using devkitadv, where does it output go, if anywhere?

#3469 - peebrain - Tue Feb 25, 2003 4:28 pm

Umm... who cares?

If you want to use the formatting of printf, just use sprintf((char*)buffer, "whatever", ...);

Fill in "whatever" with whatever you want and the string will be sent into buffer. So for example:

char test[100];
int i = 100;
sprintf(test, "hello %d", i);

Now test (null-terminated) will contain: "hello 100".

~Sean
_________________
http://www.pbwhere.com

#3470 - mantrid - Tue Feb 25, 2003 4:49 pm

Yes I know how to use sprintf thanks. And I care becuase I want logging information.

#3478 - dragor - Tue Feb 25, 2003 6:14 pm

The gba doesn't have the capabilities to printf to a file or stdout. You'll have to make your own system to view debug/log messages. I would suggest reserving some memory for log information. Write log messages to that memory, maybe by using a circular queue method. Then when you want to view the log, use a special key sequence to switch your game into "log viewing mode". This mode can display the log information to the screen using a font library. This is just one suggestion. There are other ways of getting log information out of a gba.
_________________
Sum Ergo Cogito

#3480 - mantrid - Tue Feb 25, 2003 6:28 pm

Right ok. What I really wanted to know is what printf does under the devkitadv. It's there, it gets linked, but what does it do?

#3483 - Torlus - Tue Feb 25, 2003 7:48 pm

I use devkitadv and VisualBoyAdvance. In this configuration you can print messages to stdout by calling SWI 0xFF, what is useful for debugging purposes. There's a post on the forum showing how to use it with devkitadv (inline asm)

#3484 - mantrid - Tue Feb 25, 2003 8:06 pm

OK thanks folks. I'll have to dig an see what prinf does. I am curious I need to know you see!