Thursday 13 May 2021

My progress has been... interrupted.

After such rapid progress early on it has all come to a crashing halt. I've spent way too much time attempting to get sprites displayed, only to make matters worse. I did, however, manage to fix the background colour and get the tilemap palette working.

Proper tilemap palette

There seems to be either some corruption on the tilemap, or some sprites that haven't been cleared that are causing issues. The attract mode text screens are minimally affected but when the demo/game starts, all hell breaks loose.

Looks OK except the missing '0' in the high score

In theory the sprites should be almost trivial, especially given the tilemap was relatively straightforward. I'm using the same technique I used in Donkey Kong almost a decade ago; the tilemap consists of 32 vertical sprites each 32 tiles high, with sticky bits set. And the sprites are, well, just single-tile Neo Geo sprites.

I have discovered what I strongly believe is a contribuing factor. But right now, I don't know the best way to solve it. It's actually going to be a little horrible, I think.

The Neo Geo has a VRAM address register (REG_VRAMADDR) that determines where in memory you write VRAM data. Routines that update the tilemap and the sprites need to set this register before any VRAM accesses. The trouble is, these routines are called from both the main code, and the NMI, which means the NMI can preempt the call from the main code, changing REG_VRAMADDR and causing the wrong address to be subsequently written.

One fix is to mask the interrupt whenever the code is writing to VRAM, though I'm not sure if it's even possible on the Neo Geo. Another fix would be to shadow all writes to VRAM and have the NMI write them through to the hardware - in fact I think that's what I'm doing on Donkey Kong.

But there also seems to be a similar issue with the command queue - implemented as a circular buffer - which is pushed by the NMI and popped by the main code. I can only foresee an issue though, when the queue is actually full; so maybe right now the background is getting no CPU...

Either way, some ugly issues to solve.

UPDATE: All is not as bad as it seems! I wasn't ACKing the VBLANK interrupt properly! Still some work to do, and still no sprites, but looking much better already!

Coined up and playing the game!


No comments:

Post a Comment