Romhacking => Programming => Topic started by: justin3009 on January 20, 2013, 11:30:26 am

Title: Tracing Crashes?
Post by: justin3009 on January 20, 2013, 11:30:26 am
I'm going through Tales of Phantasia and the game will suddenly crash on Mint's attack because I'm shuffling data around.  It gets to a certain point then.. just blows up.  I've tried tracing it and seeing what could go wrong but it seems everything loads up perfectly fine up until a point and then it just dies.  I can't seem to find anything before or after the initialization or even during it that would cause this crash.

How does one go and find this?
Title: Re: Tracing Crashes?
Post by: tryphon on January 20, 2013, 02:43:48 pm
Your question is too vague to be answered. What did you do precisely ? Just adding datas ? In that case maybe you added too much, or forgot to fix a pointer ?

Did you play with the ASM code ? Which emulator do you use ? Does it crash on others ?
Title: Re: Tracing Crashes?
Post by: Gideon Zhi on January 20, 2013, 02:50:25 pm
In cases where the crash isn't immediately apparent, I often load up a "good" trace, obtained from a working version of the ROM, and a "bad" trace from the bugged version in a text editor, then compare them side-by-side to see where they differ substantially from one another.
Title: Re: Tracing Crashes?
Post by: justin3009 on January 20, 2013, 07:15:03 pm
I moved all data to another bank,  changed all mentions of JSR  to JSL and altered the return byte.  Made sure the branches were updated to.  The code works exactly the same as a good one but  then suddenly after the very last  return byte,  game explodes.
Title: Re: Tracing Crashes?
Post by: LostTemplar on January 21, 2013, 03:57:44 am
Sounds like a problem with the stack. Does it return to the correct address after the last RTL? If yes, does the stack contain the same values as the unchanged game?
Title: Re: Tracing Crashes?
Post by: justin3009 on January 21, 2013, 12:48:35 pm
That's the problem.  Even when stepping slowly into, after it hits the RTL the game just dies.  I can't trace it nor can I see what's going on.  It's very strange but it SHOULD return correctly because it's straight from a regular JSL in the first place that wasn't loaded by me.  Which sends me through a loop.

It's hard to get an exact trace as well since it takes about 10 tries to get the code to load since Mint's AI is horrifyingly annoying and won't attack at the appropriate time.

Edit: Maybe getting closer?  I was able to step through a huge portion this time with the bad log and it.. works up to a point.  I'm not sure which point as it crashed as I tried something near the end of the file.  I'm assuming maybe there's another JSR somewhere in the data that needs to be JSL which is causing a bad return.  I'll see if I can trace it further now.

Edit 2: Fixed it -_-  It ends up being is was right in the code I bumped.  There was a repeated value that screwed up one single jump and bam, fixed the issue.  Haha.  Now THAT'S out of the way!