gba: add support for mGBA debugging#5443
Conversation
Implements `putchar` when `mgbadebug` build tag is set which outputs text through the mGBA debugging output interface. mGBA allows the games running in the emulator to output debug text the process to do so is: 1. set 0x4FFF780 to value of 0xC0DE 2. write text in memory 0x4FFF600 to 0x4FFF700 3. set 0x4FFF700 to the desired log level value from 0x100 (fatal) to 0x104 (debug) Once this is done mGBA will output the text in its logs view as well as through stdout. (Setting the log level to fatal also produces a dialog box with the text) The text output in the CLI is prefixed with `[DEBUG] GBA Debug: ` so I modified the regex used for address matching in panic messages to be able to read the address when the output line doesn't start with `panic`.
|
Nice! I was looking at adding this too except I was going to add it to https://github.com/tinygo-org/tinygba . I like the ability to just use |
|
Hmm I didn't realize I've had the code for mGBA debug printing in my code for at least 2 years as a custom log package. Eventually as the scale grew I started running into mysterious crashes very often that were really annoying to debug without seeing runtime panics, so having this code in the actual runtime has been pretty helpful. |
|
@zowhoey do please publish whatever code you have for gba. It would be amazing to have more support implemented, however we get it out there. If we can merge some of that into tinygba, great. If not, also fine. Just having a way to see working code that does things will be very helpful I'm sure! |
Implements
putcharwhenmgbadebugbuild tag is set which outputstext through the mGBA debugging output interface.
mGBA allows the games running in the emulator to output debug text
The process to do so is:
0x104 (debug)
Once this is done mGBA will output the text in its logs view as well as
through stdout. (Setting the log level to fatal also produces a dialog
box with the text)
The text output in the CLI is prefixed with
[DEBUG] GBA Debug:so Imodified the regex used for address matching in panic messages to be
able to read the address when the output line doesn't start with
panic.After the change
results in output such as:

This makes debugging much easier as panic messages are shown and we can also do
debug prints.