Watching Charlatan (C64)

Since I’m in a demo-ish mood, let’s do something different and watch a demo rather than playing a game! Charlatan by Solomon of the Beyond Force was released in early 1989 and, after the relatively simple intro, launches into a part which was incredibly impressive at the time since it moved a rainbow of colours around in ways that seemed impossible. The heart of this demo is an FLI routine in all but name – Solomon is credited with having pioneered the routine but didn’t christen it, that came later – which forces the VIC-II to fetch colour data on each raster line rather than for every character row. That display routine is paired up with a processor-intensive chunk of code which refreshes the colour data for that part of the screen once per frame.

At the time it was released the results were absolutely stunning and I remember it just leaving me completely gobsmacked; I just about understood how regular vertical colour splits worked enough to realise that it couldn’t be done that way and I was almost fooled by the baloney in the scrolltext since the only other solution would have been characters and the effect was displaying far too much colour to be handled that way. It eventually took my friend Matt who was a far better coder than me prodding around and working out that it relied on VIC-II “features” and, once aware of that, I did produce something similar which worked in a similar way to Charlatan‘s wonderfully hypnotic sort-of-sequel Splitter did.

It could have been a teensy bit tidier around the edges – the timing at the top of the screen isn’t stable and the grey area could have been blanked simply by enabling multicolour mode and changing the bit pattern for the part of the screen where the effect is – but Charlatan was released during the early, “Wild West” era of demo coding when getting an innovative new routine out into the world was as important if not more so than aesthetic concerns. And the movement of both the FLI effect and the animation are still hypnotic after nearly thirty years, which was the primary motivation for my “remaking” the former for MD201509 a few years back…

MD201702 (C64)

Well girls and boys, t’s rather late and I’ve spent most of my free time today getting it ready for release so don’t have many words left for a blog post, but MD201702 for the C64 has just been released. It’s another “look at all the pretty FLI colours” routine similar to the one in MD201509, but writing two independent colour values per byte rather than just one. Oh, and there’s some horizontal scroll register splitting on each scanline during the FLI routine which tilts the entire thing simply because that was fun to put in!

The unrolled code updating the FLI colours takes the majority of the processing power, so the copyright symbols swinging back and forth are handled using a similar trick to the swinging logos in MD201602 but using characters… that one might need a “how it works” with more detail at some point but there’s something of a queue forming again, so in the meantime I’ll just point at the Github repository where the sort-of-human-readable source code can be found.

I’ve been thinking a bit more about the Monthly Demo series as a whole and currently like the idea of “organising” it into seasons like television programmes tend to be arranged; that means I can take a break once in a while without worrying about it.

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!