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 > Debug Output in No$Gba (nds files)

#150095 - RickA - Tue Jan 29, 2008 10:03 pm

Is there any way to use the debug output functionality in No$Gba when developing homebrew DS programs?

#150103 - Dwedit - Wed Jan 30, 2008 12:21 am

I know that some of the devkitpro sample programs emit output to NO$GBA.
_________________
"We are merely sprites that dance at the beck and call of our button pressing overlord."

#150129 - a128 - Wed Jan 30, 2008 9:40 am

Dwedit wrote:
I know that some of the devkitpro sample programs emit output to NO$GBA.


Via iprintf to the console which is on the subscreen by default on most examples

#150207 - eKid - Thu Jan 31, 2008 7:07 am

Here's my routine for no$ debug messages.

Code:

@--------------------------------------------
@ no$gba debug output function
@--------------------------------------------
 
.global nocashMessage
 
.text
.thumb
.align
 
.thumb_func
@--------------------------------------------
nocashMessage:  @ params = { string }
@--------------------------------------------
 
@ max string length == 120 bytes
 
@----------------------------
@ copy string into buffer
@----------------------------
 
        ldr     r1,=1f          @ get buffer address
        mov     r2, #30         @ max length = 120
3:      ldrb    r3, [r0,#0]     @ load character
        strb    r3, [r1,#0]     @ store character
        cmp     r3, #0          @ character == NULL?
        beq     3f              @ yes, send message
        ldrb    r3, [r0,#1]     @ load character
        strb    r3, [r1,#1]     @ store character
        cmp     r3, #0          @ character == NULL?
        beq     3f              @ yes, send message
        ldrb    r3, [r0,#2]     @ load character
        strb    r3, [r1,#2]     @ store character
        cmp     r3, #0          @ character == NULL?
        beq     3f              @ yes, send message
        ldrb    r3, [r0,#3]     @ load character
        strb    r3, [r1,#3]     @ store character
        cmp     r3, #0          @ character == NULL?
        beq     3f              @ yes, send message
        add     r0, #4          @ increment read position
        add     r1, #4          @ increment write position
        sub     r2, #1          @ decrement word counter
        bne     3b              @ loop if < 120 characters
 
@---------------------------
@ send message to no$
@---------------------------
 
3:      mov     r12,r12 @ first ID
        b       2f      @ skip the text section
        .hword  0x6464  @ second ID
        .hword  0       @ flags
1:
        .space  120     @ data
2:      bx      lr      @ exit
 
@--------------------------------------------
.pool


Just put that in a ".s" file and assemble it with the project.
Then from C you can do stuff like:

Code:

extern void nocashMessage( char* );
 
//---------------------------------------------------------------------------------
int main(void) {
//---------------------------------------------------------------------------------
    ...
 
    nocashMessage( "%zeroclks%" );
    consoleInitDefault((u16*)SCREEN_BASE_BLOCK_SUB(31), (u16*)CHAR_BASE_BLOCK_SUB(0), 16);
    nocashMessage( "%lastclks% cycles for console init" );
 
    ...
}


I find the %zeroclks% %lastclks% parameters very useful for profiling. There's a few more parameters you can use too.
http://nocash.emubase.de/gbahlp.htm#debugmessages

#150218 - RickA - Thu Jan 31, 2008 2:32 pm

That works beautifully! Thanks a lot eKid.

#150238 - josath - Thu Jan 31, 2008 9:55 pm

I just tried this, and it doesn't quite work for me. The no$gba window opens when I call it, but it just adds a bunch of blank lines.
Example: http://h.davr.org/nodebug.png

#150254 - eKid - Fri Feb 01, 2008 5:16 am

It might not work with GBA projects because code is usually ran from the cartridge (read only). It will still work if it's a multiboot file though (everything is copied to RAM). The code is kind of self-modifying (it just copies the string content into itself), so it needs to be in a writable memory section. This isn't really a problem with DS since you have to copy all code into memory first.
To fix for GBA you can change
Code:
.text

to
Code:
.section ".iwram", "ax", %progbits

This will put the code in the IWRAM (internal work ram) section so it can modify the string contents.

#150260 - josath - Fri Feb 01, 2008 7:33 am

It was in a DS project that I had the problem...maybe it's my no$gba likes to spit out blank lines?

Could you provide a precompiled .nds which has some no$gba debug messages which I can test? thanks

#150261 - eKid - Fri Feb 01, 2008 8:13 am

Here, http://ekid.nintendev.com/nocashprint.nds
It prints a message from both CPUs.

#150274 - a128 - Fri Feb 01, 2008 12:30 pm

Your are talking about the No$GBA debug version of this great emulator?!

#150275 - RickA - Fri Feb 01, 2008 12:40 pm

a128 wrote:
Your are talking about the No$GBA debug version of this great emulator?!


I was. So not the free version, but the cheap homebrew version with assemblylevel debugging.

#150284 - nipil - Fri Feb 01, 2008 3:11 pm

RickA wrote:
I was. So not the free version, but the cheap homebrew version with assemblylevel debugging.

I ordered the same version on 25/01 via paypal, emailed the author about it too, and haven't received any feedback yet, just the paypal validation email. I'm quite impatient to get my hands on it, and i wonder what's happening... In the meantime, i'm learning to wait ;)

Edit: right after posting this, i took a look at my paypal account, and just saw that the money was removed from my bank account on 29/01. it should arrive soon !
_________________
NDS Lite Gold/Silver, MK5/R4DS, MSI PC54G2, D-Link DI-624

#150483 - nipil - Tue Feb 05, 2008 4:30 pm

Out of topic, but i anwser my previous post.
Martin replied me today about the home-debugger version.
I'll test it asap when i'm back home. Happy happy happy !
Now i "just" have to learn how to use the beast =)
_________________
NDS Lite Gold/Silver, MK5/R4DS, MSI PC54G2, D-Link DI-624