Game Boy breakpoints and debug messages in NO$GMB
The first thing you need to do is to turn on both breakpoints and debug messages inside of NO$GMB. To do this, open NO$GMB (a game does not need to be loaded) and then select Options
in the top bar, then select Debug eXception Setup
option. You will see the below window (mostly grayed out). Just select the following checkboxes to turn enable them:
- Enable User Settings
- Halt on 40h (ld b, b) (inside of “Source Code Breakpoints” area)
- Write to Message Window (inside of “Debug Messages 52h (ld d, d)” area)
Below is the MACRO
for the RGBDS assembler for being able to print debug messages to teh NO$GMB Game Boy emulator/debugger.
IF !DEF(DEBUG_INC)
DEBUG_INC SET 1
; Prints a message to the no$gmb / bgb debugger
; Accepts a string as input, see emulator doc for support
DBGMSG: MACRO
ld d, d
jr .end\@
DB $64, $64, $00, $00
DB \1
.end\@:
ENDM
ENDC ; DEBUG_INC
Below is an example of how you can print a message and then trigger a breakpoint after the message prints.
DBGMSG "This will print to a debug window"
ld b, b ; Triggers a breakpoint