Page 2 of 2

Re: Debugging Advice

Posted: Mon Apr 02, 2018 5:05 pm
by Bosco
CRASH BUG FIXED!! :D

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.

Re: Debugging Advice

Posted: Mon Apr 02, 2018 7:55 pm
by robcfg
Glad you managed to fix the error!

Obviously MAME debugger isn’t perfect, but is one of the best I’ve found.

Re: Debugging Advice

Posted: Mon Apr 02, 2018 8:49 pm
by Bosco
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. :lol:

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

Posted: Mon Apr 02, 2018 9:45 pm
by sorchard
Glad you found it relatively painlessly :)

This should get you a trace file:

Code: Select all

xroar -C -trace >trace.txt
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.

Re: Debugging Advice

Posted: Mon Apr 02, 2018 10:25 pm
by Bosco
Thanks Stew. :D