How Septic works

Because it’s rather simple in the graphical department there aren’t many points of interest to that side of Septic apart from mentioning that the Apple II’s graphics are “backwards” compared to other 8-bits with the lowest used bit of a byte being the leftmost pixel; display RAM is arranged in an “interesting” manner too and it only uses seven bits per byte for pixels as well with the eighth selecting one of two colour pairs for the artifact-powered colour display. I wrote a very cheap and cheerful Windows bitmap to Apple II picture converter a while back which can sort of handle artifacted colour too, but that is currently nowhere near user friendly enough that I’d consider releaseing it for public consumption.

The character set didn’t even need the “specialist” tools though, it was just drawn seven pixels wide with one pixel gaps in reverse order, flipped horizontally in Promotion and shovelled into my regular bitmap to raw binary converter which can, amongst other things, write the data out in rows; the first 64 bytes of the binary file contain the top pixel line of each character in turn, the second 64 are the second line and so on. Look for the partially unrolled bmp_draw in the source code and it should hopefully demonstrate more clearly why having the font in this format is useful.

So having put the minimal graphics code aside we get to the meat of Septic, that one channel music driver. When making sound, the Apple II’s processor has to sit there and click the speaker at regular intervals so one relatively simple-to-follow means of achieving that is a loop along the lines of…

		ldx duration
		ldy pitch
sound_loop	lda speaker
		dey
		bne sound_loop
		dex
		bne sound_loop-$02

…where the LDA makes the speaker click, the Y register is used to time the gap between those clicks and X is a duration counter governing how many times the central loop is executed. The above code will work, but there’s a problem; the higher the pitch, the quicker the central loop runs and the shorter the duration of the note. To make something workable with this method, each possible frequency requires it’s own duration value for one “beat” of the music driver which would in turn be multiplied by the the number of beats that the note is actually going to play for!

So instead the sound loop in Septic was based on a web-found listing that popped up in a discussion at the Atari Age forums which has a better approach. Originally I disassembled the program which was POKEd into memory and meant to be called from BASIC to get some source code, but Anders Carlsson offered up his own, improved version so I migrated my driver over to his instead. That routine, called be_snd_on_play in includes/be_driver.asm, has a central loop which runs for whatever the duration is and within this loop a second timer counts down to zero and, when it hits that value, the speaker is clicked and the timer reset. All my code does after that is wrap a simple, one channel music driver around the sound generator and define a series of labels to make music entry easier. That data looks like this chunk of includes/be_mps.asm:

be_pattn_03	!byte g_2,dur01
		!byte g_1,dur05
		!byte off,dur04
		!byte g_3,dur01
		!byte g_2,dur05
		!byte off,dur04
		!byte g_2,dur01
		!byte g_1,dur05
		!byte off,dur04
		!byte g_3,dur01
		!byte g_2,dur05
		!byte off,dur04
		!byte g_2,dur01
		!byte g_1,dur05
		!byte off,dur04
		!byte g_3,dur01
		!byte g_2,dur05
		!byte off,dur04

		!byte g_2,dur01
		!byte g_1,dur04
		!byte ax2,dur01
		!byte ax1,dur04
		!byte g_3,dur01
		!byte g_2,dur01
		!byte g_2,dur01
		!byte g_1,dur05
		!byte off,dur02
		!byte eod

The label g_3 means a G in octave three, ax1 is an octave one A sharp, off rather unsurprisingly stops the current sound being played, dur04 is a duration of four “beats” (the actual meaning of which can which can be tweaked in the music driver itself) and eod is used to mark the end of the current pattern or track data. Assembling and testing Septic‘s code is more fiddly than the C64 or Atari 8-bit releases I’ve previously pushed to GitHub because the newly assembled binary needs to be manually pushed into a disk image but, in theory at least, it should be possible for someone else to pick up the driver, plug new data into it or possibly expand on what’s there.

There are a metric bucketload of improvements that could be made of course – options like multiple channels or more complex sounds are certainly possible – but I don’t have anywhere near the musical ability to do the required tuning to keep everything sounding right and currently lack the hardware for testing more involved sound engines. More importantly, the “plan” was to provide Apple II folks with something relatively simple to make music with that could perhaps be built upon, so hopefully that slightly tenuous goal was met.

Bah and further humbug!

It’s Christmas…! And I’d just like to wish everybody reading a reasonably sincere “bah, humbug” at this time of overspending, corporate greed and trying to consume far too much in the way of food and drink. On the “plus side”, it’s a reasonable excuse for yet another themed monthly demo from Cosine, so we’ve got MD201512 – Humbug straight from the North Pole (or at least the north of England) to delight and amuse you simply by having snow in the picture and a bit of appropriate-sounding music. There’s a snowman as well and, along with mince pies and certain television programmes, they’re one of the few things I actually like about this time of year!

The font was blagged from Air Rescue on the Master System and the superb collection of pixels were put together by prof4d on the Spectrum and beefed up a bit using AFLI at the C64 end by me. This thing was originally going to be released on Christmas eve in a vague attempt to avoid looking completely Scrooge-like by “working” on Christmas day but, rather than spending the evening hammering out scrolling messages or the text for various websites, I instead chose to plonk myself on the sofa with my Beloved to watch Die Hard.

I’ll try to get around to doing a “how it works” post fairly soon, as well as finishing the one already started for Septic, but MD201601 will, if all goes to “plan”, turn up very early in the month so we’ll have to see how everything pans out… in the meantime, I did release another, much smaller demo through the “side project” called Clonemas which was thrown together in a couple of leisurely hours whilst waiting for the YouTube video of MD201512 to upload and process! It was built as a prezzie to said project’s muse to demonstrate a “point” about not needing mathematics to make curves and looks just like this:

And that’s pretty much covered everything that’s happened apart from quickly mentioning how much I enjoyed the Doctor Who, Strictly and Call The Midwife Christmas specials (there were some tears during two of the three) and wondering where I left the mince pies…?

Workprint – December 2015

After just sliding over the line with a day to spare for October’s Monthly Demo, I started planning a Christmas-ish theme (“bah humbug” and all that) for the December release and considering ideas for January, but November pretty much completely slipped my mind! So MD201511 was literally finished half an hour before midnight on the 30th of November with the main being just seven scanlines high and something I built as a proof of concept after chatting with Sean Connolly about vertically splitting the horizontal scroll register and not being able to explain what happens where things overlap.

As with the previous Monthly Demo releases, the source for this one has been uploaded to GitHub but will probably be a bugger to follow since there’s quite a bit of naughty self-modifying code in there for those six cycle wide splits; I’ll push together a “how it works” post at some point to explain at least some of what’s happening under the hood in more detail, though.

Over at “the blog we don’t speak about” there was a new release as well; Clone Reaction takes elements from two mid 1980s demos (Rob Hubbard’s Zoolook Moozook and W.A.R. by Stoat & Tim, both long-time favourites of mine) and tries to cram everything together onto one screen! I’m quite pleased with the results and it probably turned out better than MD201511 in the long run since the code has been ready and waiting for the “posting schedule” for a while!

After the “festive season” is over and done with there’ll be MD201601 which hasn’t been started yet but should be an Atari 8-bit release if what I’ve got in my head works when pushed into the assembler and I’m aiming for the New Years Disk so it’ll be pushed out the door at the start of the month.