CRASH BUG FIXED!!
Playing with MAME's debugger I could see the program counter was shooting off into BASIC rom when the game crashed. But I could also see using a memory window onto my Sprite data structure that all of the associated sprite pointers looked fine. So I started a trace just before a section of game which was prone to crashing and hit one first attempt. Then just searched backwards through the trace and `bingo' I could see the problem immediately.
An indirect JSR was jumping to address $0000, stumbling through illegal opcodes and eventually jumping into BASIC rom where it looped indefinitely.
The cause of all this was me failing to clear a collision flag byte when sprites are initialised. This occasionally triggered a false collision on a game item which should under normal circumstances not be collidable. The item's collision look-up was null which is why the pc jumped to address $0000 following the bogus collision.
I have to say MAME's debugger has been invaluable on this but I'd still be interested to know how to create a trace file from XRoar. Ctrl+v will output to the console window, albeit XRoar stops responding in the process, but I'd be interested to know how to output to a file?
Cheers, Steve.
Debugging Advice
Re: Debugging Advice
Glad you managed to fix the error!
Obviously MAME debugger isn’t perfect, but is one of the best I’ve found.
Obviously MAME debugger isn’t perfect, but is one of the best I’ve found.
Re: Debugging Advice
Thanks Rob.
A debugger is definitely a valuable tool when staring at your code doesn't yield any results.
It does feel a bit like cheating though, like using reference books to solve a crossword puzzle rather than just what's between your ears.
Btw, do you know if the MAME debugger can be instructed to pause if the pc register exceeds a specified address range? Would be easier than dealing with huge trace files.
A debugger is definitely a valuable tool when staring at your code doesn't yield any results.
It does feel a bit like cheating though, like using reference books to solve a crossword puzzle rather than just what's between your ears.
Btw, do you know if the MAME debugger can be instructed to pause if the pc register exceeds a specified address range? Would be easier than dealing with huge trace files.
Re: Debugging Advice
Glad you found it relatively painlessly
This should get you a trace file:
Not sure if you need the -C or not. (capital C). It starts a console under Windows. The '>' at the end of the command line redirects console output to a file.
This should get you a trace file:
Code: Select all
xroar -C -trace >trace.txt
Stew
Re: Debugging Advice
Thanks Stew.