So my goal here is to make a small Lemmings demo in BBC Basic, party as a – “isn’t that cool” demo, but also as something other people could look at, and possibly understand. Now, I’m still not overly sure on the specifics of how I’ll do this, but one thing I did figure pretty quickly, was trying to load in 153k bitmap in one go, wouldn’t work.

So the first thing I did was look for a one screen level that I could use, and for this the very first level is a pretty good choice. So I chopped it down to 320×160, and then set about making a a set of 50, 32×32 tiles.

This was simply a case of knocking up a quick C# tool that would load in a PNG, and extract a series of 32×32 tiles from it. The loader takes 24 bit RGB values, so I just need to kick that out of the tool into individual files.

With this done, I look at the “sprite.bas” demo that the Agon has to see how I import bitmaps, and copy this over – although this was to bite me in the bum later….

The tool for generating the tiles created a set of 50 files called “back??.spr” where ?? is the number, so I create a string using this name, and then call the bitmap routine.

This is again, much nicer to edit that in a solid white upper case font with line numbers on the Agon itself. While it’s totally possible – many of us did this back in the day, this is much nicer. It’s worth remembering that professional developers did use remote development kits like PDS (Personal Development System), which I used for the C64, and Dave used for the Amiga.

This is the bitmap function from the sprite demo that I copied – well, almost. The sprite demo has a bug in it, the alpha value – that “vdu 255” you can see, was in the wrong place. This lead to funny colours, and transparent rendering etc that took a little bit to figure out. But after messing around, I realised it was wrong and fixed it (shown above). It’s always worth remembering that demo code you copy, isn’t always right, especially on new systems.

Once I’d loaded everything in, I needed to draw these 50 tiles, and that was again simply a another BASIC loop to draw the bitmaps.

Pretty simple stuff. Running this – once all the issue were resolved, gives you exactly what you’d think.

You can find all these VDU instructions on the wiki page.

https://github.com/breakintoprogram/agon-docs/wiki/VDP

So what’s next? Well, getting a Lemming sprite on screen of course! This is basically the same thing, loading in a load of bitmaps, and this time, assigning them to sprites. I’ll fiddle the loading routine to detect a colour, and then convert that to an ALPHA of 0, making it a sprite.

There is a new 2222 format coming, where each channel is just 2 bits. But this format will remove the need of this kind of function, and make the files one third the size. But for now… we’ll fudge it.

The sprite VDU commands allow you to attach bitmaps to a sprite, and then select a frame, so all you need to do is to add all the animations, pick a frame, and set the X,Y. Once you’ve done this, you end up with this…

So there we go…. a Lemming on screen.

Now, it’s not all plain sailing, when running this stuff on the actual hardware, it’s unable to load all the tiles into memory, so I’ll need to address that at some point.

So next time, I’ll take a look at the BASIC generator tool again, as there are issues with variables, but more on that next time….