Pages

Monday, 2 May 2016

Bug fixes that don't!

If there's one thing that I really hate, it's when you finally track down a bug, say to yourself "Ah ha - that would explain it!", duly fix it... and then the bug is still there. Happened to me (again) with the column firing. Having said that, it's better than before (so I did actually fix something) but still not quite right.

And speaking of bugs, in the process of trying to fix the aforementioned, it dawned on me that my shadow Z80 registers - stored in Direct Page memory - weren't preserved when interrupts fired! Fortunately there wasn't much else stored in that memory, so it was a simple matter of changing DP when entering and exiting from an interrupt service routine. Something that wasn't an issue in Knight Lore, for example, as there were no interrupts!

Frustrated with alien firing bugs, I instead implemented the player being destroyed. So now you can start a game that actually does end. At last count there were at least three (3) known bugs - none too major - but at least I've almost ported all the code to 6809. In fact, I'm tempted just to press on and complete the porting process before even attempting to fix any but the most obvious-to-fix bugs...

I've hit 4,000 lines in the source file now, and there really can't be much left; mainly to do with the saucer and I can't think of much else.

Ocne the porting and debugging is done, I need to rotate the screen. That process is going to be a little more involved than I first imagined, but still not too daunting. I am going to attempt to have the screen rotation as a build option, rather than completely abandon the non-rotated screen.

Then there's the issue of 2BPP colour, and then sound & joystick support...

3 comments:

  1. No doubt there's something about your shadow Z-80 (or is that 8080?) registers I don't understand. But since the interrupt only pushes the program counter on the stack you shouldn't have to save registers yourself. It is up to the interrupt service routine to save and restore registers as required.

    ReplyDelete
  2. Yeah I was probably a little vague.

    I use DP to mirror *8080* registers on the odd occasion that they're required - such as intermediate results or parameters & return values from routines - when the original code uses too many registers for the 6809.

    Space Invaders is somewhat unique in that most of the code is actually running in the context of one of two ISRs! On the 8080, each ISR pushes all the registers and then goes about its business. FWIW on the 6809, the CPU does that for you in the event of an IRQ (as opposed to an FIRQ).

    However, if the background code is running and has a 'live' value stored in one of my DP shadow registers, and the interrupt fires, my shadow register wasn't being preserved like the 8080 counterpart. So it was a simple matter of having the ISR switching DP to another page, then switch back when the ISR exits.

    In a few cases, the ISR doesn't exit 'normally', but rather drops out by simply resetting SP and executing EI. Of course I need to restore DP in those cases as well.

    ReplyDelete
  3. That should be, "...On Space Invaders, each ISR pushes..."

    ReplyDelete