Workprint – September 2017

The lack of releases means this blog has been even quieter than usual… but things continue to happen in the background. For example, the rewrite of the Hex Files is still in the “exploratory stage” as I settle on an assembler and IDE to target, rethink the running order and actually start doing a bit of writing. CBM prg Studio initially looked promising but I really didn’t like the way it converts tabs to spaces in the source code; I’m used to whizzing around with the cursor keys so it feels somewhat stodgy. A few other options have popped up (feel free to insert a Finbarr Saunders reference here both for “popped up” and “insert”) so I’ll have to see if they feel any more comfortable.

Last month’s post also received a slightly less than subtle comment about Vallation. I forgot to mention it in said post, but it was the first piece of game code I started prodding around and a few changes have been made. The problem is that they’re not exciting enough to write about, essentially boiling down to just reorganising the memory layout to shift all of the graphics from bank 1 to bank 3 which makes space for extra level data required to expand the game out. At the moment this is all pretty much irrelevant until the end of game code is properly repurposed to act as an end of world event (each world is planned to be three levels sharing a graphical theme and, hopefully, some bespoke enemies) because it still stops after the original three levels unless I remove the checks, in which case the player instead gets deliberately stuck on the first screen of level 5’s map because it’s not done yet!

How MD201509 works

This post has come a little later than expected, but a few people have asked about it so lets have a quick prod around behind the scenes of MD201509. There are two parts so, unsurprisingly, we’ll start with the intro.

This part is more complex than it initially appears, using cycle-accurate splits for the colour for each letter in the logo; the diagonal tilt comes from a split on each scanline that writes to the horizontal scroll register but it’s not possible to change colours midway across a badline… but that line is where the top bevel of the little bias relief tiles sit so the colour changes wouldn’t be visible anyway! Instead the routine pushes out new colour values six times per scanline for six of the eight lines (since the lower bevel doesn’t need a split either) and sets the colour to grey for the other two.

The same basic technique is used for the colour splits under the scroller and swinging text line, with the routine loading two registers with colour values at the start of each scanline and alternating between writing them across the screen. The badline here just happens to be where both colour gradients are white, so a single change is needed at the start of that line rather than multiple writes during it. Both split routines are unrolled code and built as subroutines so they can be called twice per frame.

In the main part, thirty seven of the colour splits aren’t actually colour splits! The first column is done traditionally by changing the background colour once per scanline with a sprite masking the two character columns to the left of it, but the rest are FLI with a memory- and processor-intensive, unrolled routine rewriting all of the colour data for them once per frame; this routine was what the entire demo was built around so everything else is pushed into the gaps it leaves and there are even a couple of changes for the masking sprites during the bitmap embedded within that chunk of code. A simple bitmap dissolve changes the FLI area back and forth between $55 and $aa (the colour data has a blue gradient value in one nybble and its equivalent from the brown gradient in the other), executing on runtime wherever the interrupts aren’t hogging the processor.

There are a few more colour splits under the scroller which are only slightly different to the ones in the intro and the badline is avoided completely so they’re just seven pixels high. There’s also a hardware sprite at the left side of the scroller because the entire screen is in forty column mode and there would be a character wide gap there without it.

Finally we get to the bitmap filling the majority of the screen. There’s been some talk on MD201509‘s CSDb entry about how it was done that make it seem complicated, but the black parts of the image are just set bits in the bitmap whilst all of the coloured areas are unset. Move some sprites around with the priority set so they’re behind the picture and they’ll only appear over the coloured parts; there are a few more sprites underlaid to add colour where it wasn’t possible to use attributes due to clash, but those are the higher-numbered sprites so the moving ones have priority. The only remaining feature is another routine on runtime that goes through the circles in “random” order, fading them to white and back down to one of the darker colours in the palette, this uses a subroutine for each circle and a jump table to select which is currently being called.

So there we go, the basics of how MD201509 works… if anyone wants to ask questions just fire away and I’ll do my best to answer. If there’s enough interest I might be brave enough to open a Github repository to publicly display my spaghetti-like source code!

Workprint – September 2015

As mentioned previously, the workprint posts will probably be more sparse since I’m concentrating on demo code but things are still happening… in fact there should be the first monthly demo from Cosine to announce at some point during this coming week. There might be news from another front in the near future and I apologise for being so infuriatingly vague but things on that front are still being discussed “behind closed doors” and not suitably advanced to blab about right now.

But in less annoyingly worded news I’ve spent most of today reorganising our spare room to make myself a new work space; here’s what it currently looks like…

…complete with a likkle sixth Doctor stood by the monitor. This setup is almost ready to use except that the desktop doesn’t currently have a connection to the network, but an el cheapo USB wireless adapter was ordered from t’interwebs yesterday to deal with that and, eventually, there’ll hopefully be a run of CAT5E coming up from the main switch. I should be up and running by the middle of the coming week, fingers and probably other extremities crossed