kieranhj / pop-beeb

Prince of Persia port to BBC Master
45 stars 2 forks source link

Crash when exiting to winning cutscene #225

Closed kieranhj closed 6 years ago

kieranhj commented 6 years ago

Reported by Diminished on Stardot.

Stack looks very suspiciously like an infinite loop:

01d0 21 8e 22 dc 21 44 21 8e !.".!D!. 01d8 22 dc 21 44 21 8e 22 dc ".!D!.". 01e0 21 44 21 8e 22 dc 21 44 !D!.".!D

&21DC is the return address from JSR DoKid in NextFrame in topctrl.asm &228E is the return address from JSR ctrlplayer in DoKid in topctrl.asm &2144 is the return address from JSR NextFrame in MainLoop in topctrl.asm !!

This would suggest that ctrlplayer never returned by probably hit a BRK causing the error handler to be called. But the only reason it would go back into the MainLoop is if it thought we were trying to save the game (to recover from write protect errors.) Weird.

kieranhj commented 6 years ago

I noticed that when I was fighting Jaffar on level 12b, during the short musical sting that plays when he appears, the game slowed down a lot for the duration of the music. I died during the fight a few times, and once this slowdown started happening it occurred every time I fought him. The finger may therefore point at the music decompression codec, but I don't know.

I beat him eventually and the game let me exit the level and loaded the epilogue, and then it crashed when I ran through the door that triggers the ending cinematic.

kieranhj commented 6 years ago

Looking at the bottom of the stack: 0128 48 18 5b 18 df 28 04 a7 H.[..(.. This is the call to beeb_load_audio_bank which goes into disksys and eventually calls OSFILE. Stepping through the MOS call in b-em the stack can get at least &2E deeper than entry so would overflow in this case (and presumably the load fails.)

Problem must be higher up with the looping entry to MainLoop...

kieranhj commented 6 years ago

Stack overflow issue now fixed with stack reset in RESTART.