Today I had the chance to review the collision-detection code. The bad news is that I couldn't see anything amiss. I did find a few minor issues to do with ADC/ADD but they don't appear to be the cause of the bug. I also managed to effect a few minor optimisations.
I'm still hanging my hat on an issue with the core code, rather than the display mapping. I say that because a lot of the time the shots and objects are spot-on - even the small asteroids and small saucer - but then a shot will pass right through the middle of the large saucer. That's not just a few pixels off... more like a logic bug.
Aside from revisiting the collision-detection code again, I don't have any further theories on the matter. This might turn out to be a tough one.
I've been holding off on the optimisations up until now for a few reasons. One, it's simply nice to have the rest of the porting 100% complete. Two, it's easier to tweak things like display mapping with brain-dead code. And finally, I didn't want to find myself in the situation where I had to re-optimise certain routines because something fundamental wasn't quite right.
Having said all that, I'm wondering whether it is actually safe to press on with the optimisations now and revisit this issue down the track - assuming it doesn't have anything to do with display mapping. I don't want to get bogged down debugging this and lose momentum (again).
At least part of the optimisation - double buffering - won't be affected either way and should be relatively straight-forward. From there it gets more involved with compiled sprites, but I could get a start on objects such as text and the copyright message.
Have to think about it...
Best to get the bug fixed -- don't build (optimization) castles on sand.
ReplyDeleteMAME can save and replay input traces. Should be pretty easy to find the problem if you debug an input replay so you can see exactly what goes wrong.
On the random guess front, I wonder if the collision detection math is OK but objects are sometimes skipped due to an off-by-one or something in iterating.
Good guess! Unfortunately looking at it again in light of your comment I still can't see anything wrong.
DeleteThanks for the tip on input replay - I forgot all about that! It'll be a bit of work to zero in on the exact moment something goes wrong - especially in light of MAME's seemingly async video refreshes - but it's worth a shot!