Tuesday 2 June 2020

Leaving behind footsteps

As usual, it's a case of two steps forward, one step backwards.

I've 'improved' the sprite rendering but in the process have discovered a complication that is a direct result of the rotation.

Ordinarily, the invaders march 'across' the screen on a vertical monitor, which means they march 'down' 2 lines in video memory and - importantly - no two invaders share the same video memory byte. Rather than erase the invader before it is moved, the sprite data contains two blank bytes so that the two vacated lines are effectively erased when drawing the updated sprite. Clever.

Having rotated the screen however, invaders now march 'across' the video memory map, moving 2 pixels (bits) each time and the rendering algorithm potentially (usually) writes the same video byte twice. Additionally, adjacent invaders may now simultaneously occupy the same video memory byte. The upshot of all this is; simply writing the sprite data byte to video memory potentially wipes sections of itself and/or adjacent sprites, whilst ORing the sprite data leaves pixels that should otherwise have been overwritten. Catch-22.

The left column of marching invaders show the rendering issue

The solution would likely involve some sort of algoithm and a mask to specifically wipe the leading two columns of pixels. At least that's what I've come up with - in theory. Time will tell.

The original code also has a routine for rendering 'simple sprites' that are always byte-aligned (i.e. the object only moves left/right). A case in point is the player base. After rotating the screen, however, this will not be the case in this example. All that is required for the base, however, is to instead call the more generic sprite rendering routine, so it's an easy fix.

The to-do list also contains; restoring logic to detect edge of screen for the invaders, rendering invader bombs correctly, rendering player lasers correctly and having them not crash the game. And who knows what the saucer/UFO looks like?!?

At this point I'm still looking for 'low-hanging fruit'. In other words, routines that have simple fixes. There are a bunch of sprites that have yet to have their pixel data rotated (the shields being an obvious example in the screenshot above) and that would involve firing up my quick hack rotating software and remembering how it all works...

But all-in-all, it shouldn't be a mammoth task, and I'd like to knock it all off this month!

No comments:

Post a Comment