Saturday, 23 January 2016

C implementation of Knight Lore complete!

As the new year kicks into gear it has been difficult to find much time to work on Knight Lore. Whilst I admit the subtleties of the Z-order algorithm continue to elude me, I have managed to port it to C and have what is now a complete, if not fully debugged, C implementation.


No Z-ordering implemented
Z-ordering fully implemented














 
I decided that implementing the algorithm in C would only assist in my understanding of it; and it was definitely true to an extent. Whilst the algorithm is somewhat recursive, ultimately the entire scene is re-processed from the start each time a sprite is ordered and rendered.
 
Surprisingly I managed to implement the algorithm itself correctly pretty much on the initial attempt. However, a few graphics glitches remained and hunting them down has taken longer than the above-mentioned implementation. Two of those glitches were the result not of bugs per se, but rather code that I hadn't yet implemented. Most difficult to track down - I implemented the sprite flip routines quite early on in the piece (as they are used on the main menu screen) and had at the time neglected to flip the sprite mask data as I wasn't using it.

Whilst strictly speaking there's no need for me to understand the Z-order algorithm in any more detail than I do right now for the purposes of reverse-engineering or porting the game, it's gnawing at me. I won't release the source until I understand it fully.

That aside, my next tasks are to give the Z80 listing a final once-over before releasing it and spend a bit more time play-testing the port, ideally completing a game or two. It really will be the first time I'll actually sit down and play through the game just for the sake of playing it.

I've been thinking more about the Neo Geo port and I still haven't convinced myself that it's possible. Then again, the rendering may simply involve a completely different approach as there's no need to wipe and draw, but rather simply (re)assign sprites in the correct priority order. I'm sure I can get something running though as I went through a similar exercise with Lode Runner.

Of course the Amiga port beckons and I'll probably tackle that sooner rather than later as I've yet to develop anything through to completion on the Amiga. It really shouldn't take much effort now that I've laid the groundwork.

I'm also thinking of releasing a somewhat cryptic teaser for the Coco3 port...

No comments:

Post a Comment