Language…
14 users online: bald_ridge, DimeR, flips_bad, JPhanto, l44l, Mad Lad, metabrawler87, Picayune, sdace, TheKazooBloccGosh, TheMorganah, tired_ideabox, Win72010, wye - Guests: 57 - Bots: 266
Users: 65,954 (2,179 active)
Latest user: tails23912

BRK Exception Handler

SMW Patches → BRK Exception Handler

Submission Details

Name: BRK Exception Handler
Author: p4plus2
Added:
Version History: View
Tool: Asar
Requires Free Space: Yes
Bug Fix: No
Featured: No
Description: This patch is pretty useful for those of you who are working with ASM in some way. If your code crashes and triggers a BRK (which happens reasonably often of all the potential crashes), this will display a bunch of debug info. The printed debug info is: registers(PC, D, B, A, X, Y, P, S), layer 1-3 positions, powerup status, and a full stack dump. It can also dump special message based on the BRK number. To add custom exception messages (for example for brk #$02) you would need to add the following line to the exception list:
%exception($02, "Something broke", "FIX IT")

Pretty sure this patch is 100% stable, Enjoy!

v1.1 (Erik and MarioFanGamer)
-----------
- Fixed the Free RAM defines as they weren't being used properly.
- Added a !snes9x define which replaces the STP with an infinite loop (as snes9x crashes with STP still to this day and I have no idea how to detect the emulator automatically).
- Fixed an oversight where garbage appears on the debug screen (didn't affect the text).
Tags: debug lorom
Comments: 5 (jump to comments)
Download 5.88 KiB | 289 downloads

Screenshots

View all

Comments (5)

 MarioFanGamer Link
Moderated with:
  • Asar v1.71
  • Lunar Magic 3.4
  • bsnes-plus v073
  • SNES9x 1.60

Fixed an oversight where two labels were swapped which shouldn't be swapped (for this reason, garbage appeared in the original version and the unmoderated remoderated version). No issues otherwise.

Other then that, there are uses in it if you test ASM stuff and things are likely to break (after all, that's what BRK is originally used for debugging when the 6508 was created) but as mentioned by the moderator for the original version, you still should avoid accidental triggers of BRK (at the same time, BRK is much safer to trigger).
Knucklesfan Link
Could SA-1 support be implemented? This actually would be really helpful
 Erik Link
Remoderated.
Tested with: Asar v1.71; Lunar Magic 3.04; bsnes-plus v073+3a; snes9x 1.60
I didn't add SA-1 compatibility as I feared the patch wouldn't output accurate values for debugging should the game crash while the SA-1 is executing.
trillian From older version: BRK exception handler Link
Slight bug or something: the freeram defines !brk_triggered and !brk_old_stack aren't actually used, but their default values are hardcoded into the code.
Vitor Vilela From older version: BRK exception handler Link
This patch is pretty useful for whoever is trying to catch a ROM crash but the trace logs aren't showing properly the source of the problem or can't use them at all.

Of course it won't work on all cases, some crashes will soft-lock the CPU (though infinite loop or STP) and other will crash so hard that the BRK handler won't work at all, but it should work with like, 97% of the crashes at average.

I don't really recommend sticking with the patch on a ROM; this is just for testing/debugging purposes and putting the screen won't stop your hack from being rejected or something in case of a obvious game crash.