BBC on the BBC

Over the past few days I’ve been converting nitrofurano‘s image filters from stand-alone sdlBasic programs to Python-Fu image filters for The GIMP. But, so far, there has been a particularly noticeable absence – the BBC Micro.

Partly that was because the BBC Micro world has already been utterly spoilt in the image conversion department by Francis G. Loch‘s incredible BBC Micro Image Converter. It’s a highly professional piece of software and does it all. I’ve posted about it many times here and the work I’ve done for Retro Software would have been utterly impossible without it.

BBC Micro Image Converter by Francis G. Loch

But partly it was because Francis’ program had inspired me to try and find out more about the mind-boggling array of dither options he had included in his program. It boasted a host of exotic sounding names like “Floyd-Steinberg”, “Sierra”, “Jarvis, Judice and Ninke” and “Stucki”.

Paulo had used a technique called Bayer ordered dither in his filters, which is similar to the traditional half-toning used in print. It’s very powerful, very fast and gives you a lovely regular patterned effect on the images, which is sometimes just what you’re after.

Naturally, Francis’ BBC Micro Image Converter does this as well. But these exotic sounding names were the inventors of various flavours of another technique: error diffusion.

Error diffusion works by trying to compensate for the colour information lost by turning a pixel into a value from a restricted palette by sharing it out amongst the surrounding pixels.

After looking at the Wikipedia entry for Floyd-Steinberg, it looked like even I could understand how to program it and then after finding an excellent article here I realised that all the other filters did exactly the same thing. They just shared out the lost information (or quantisation error) to different pixels in different proportions.

And, after a couple of hours messing about in Python, I managed to get out a servicable MODE 2 image (click on the images to enlarge):

Floyd-Steinberg error diffusion, 100% strength

You can see just how effective error diffusion is when you compare the results to the same image processed with no error diffusion:

The same image with no error diffusion

Here’s the original image for comparison:

I’m the one on the right

I excitedly added a range of different filters into my BBC Micro image filter:

Take your pick!

There was a problem though. Sierra3 was taking well over 70 seconds. This sluggishness was caused by the inefficient way in which I was checking that a pixel was within a certain range in Python.

Sierra3, 100% Strength – and very slow!

An error message I had been getting during development rather ironically proved to be the key to solving the speed problem. Instead of using time consuming range() functions to see if pixels were inside a particular range, I could use exception handling and check for an IndexError instead. This was very fast – it sped the filter up by a factor of at least four. Mind you, it still crawls along compared to Francis’ version!

The next thing I needed to add to the filter was something called “Serpentine parsing“. This means that instead of processing the image from left to right as it moves down, the computer processes the image backwards and forwards. This helps to stop all the error diffusion going in just one direction – smearing all the errors to the right.

Finally, pinching another one of Francis’ excellent ideas, I added a strength control to the filter to allow you to control how strongly the error diffusion works.

Finished interface

Here is Test Card F with 50% Floyd-Steinberg error diffusion strength:

Floyd-Steinberg error diffusion, 50% strength

And here it is with 25% Floyd-Steinberg error diffusion strength:

Floyd-Steinberg error diffusion, 25% strength

So, a BBC Micro Mode 2 image filter for The GIMP, that can be downloaded from here. However there are numerous refinements that need to be added to it. But they will have to wait for another day.

Test Card F Copyright © 1967 BBC, ITA and BREMA.

Designing Repton’s Lost Realms

If you’ve been here before, you’ll probably already know that this year is Repton‘s 25th anniversary. And, as part of the celebrations, Retro Software is releasing Repton: The Lost Realms for the BBC Micro and Acorn Electron.

I’ve already blogged about creating the cover artwork and the loading screen for the game. However today is the 6th November and Repton: The Lost Realms is being officially launched at R3PLAY in Blackpool. That means I can at last talk about creating the graphics for the game itself.

My cover artwork

I was first approached by Dave Moore about contributing to Repton: The Lost Realms in mid 2008. Peter Edwards had just recovered a load of my old Repton 3 and Repton Infinity screens from some of my 5.25″ floppies and the graphics in them had impressed Peter and Dave enough for them to ask if I would be interested in creating some screens and graphics for Repton: The Lost Realms.

Like Repton 3 before it, Repton: The Lost Realms is a game that allows you to not only edit its levels, but also redefine its graphics. That means that it’s possible to provide a selection of different screens and graphics for players to load into the game.

Lost Realms as I first received it

At this stage, the Repton: The Lost Realms came with only one set of screens. As you can see above, it used the Repton 3 graphics with a few additional graphics for the game’s new elements designed by the game’s original programmer Paras Sidapara.

As there were to be four sets of six screens included in the game, my first idea was to theme each set of graphics around the existing Repton releases. In other words, have a Repton 1 set…

Repton 1 Lost Realm

…a Repton 2 set…

Repton 2 Lost Realm

…a Repton 3 set…

Repton 3 Lost Realm

…and a new set for the final set of screens.

I quickly hacked about and transferred the graphics from these games into Repton: The Lost Realms. At this stage I was designing new characters in the Repton Infinity graphics editor (Film Strip) and then transferring them over to Repton: The Lost Realms by transferring blocks of data between files using the BBC BASIC command line.

Film Strip – An excellent graphics editor

The reason why I preferred Film Strip was that it was designed for use with a keyboard. I didn’t have a real BBC Micro to use so I was using these programs via the excellent emulator BeebEm. In fact, as at that stage there wasn’t a native GNU/Linux emulator for the BBC Micro at the time, I was using BeebEm via WINE.

The Repton 3 and Repton: The Lost Realms editors had adopted the then very fashionable WIMP paradigm. However, using a WIMP interface with a keyboard is very hard going and I found the AMX Mouse option tricky to get working in BeebEm. That meant I couldn’t use these editors with my mouse.

Another problem I had with Repton: The Lost Realms’ editor was the awful yellow and black colour scheme used for the editor’s pointer. It was probably the worst colour scheme you could have picked if you want to design graphics precisely – the outline of the pointer gets lost against black, but most of the graphics have black backgrounds or outlines!

Repton: The Lost Realms’ Editor

After I had designed Repton 1 and Repton 2 themed graphics it soon became obvious that this approach would not work. There were various new elements in Repton: The Lost Realms that were not present in previous Repton games. I wanted to redesign these in each set to match the style of previous Repton releases. However Dave wanted to keep the new game elements that Paras had designed looking the way Paras had designed them. However this would have looked out of place, particularly in Repton 1 which is quite abstract and geometrical in design.

Therefore, after talking it over with Dave and Paras we decided it would be best if I design four completely new sets of graphics for the game, bearing in mind the need to keep the original design of Paras’ new game elements in each set. We would also only vary the game characters that varied in the sets of screens supplied with Repton 3: namely the walls, eggs, monsters and crowns.

I had a few ideas for the graphics having got used to playing the game. I didn’t think that the inverted cage colour scheme for the anti-clockwise spirits worked at all. I needed to find a way to make these cages look a little less incongruous. I wanted to make the graphics look 1988-ish – so I used the style of later BBC games like Richochet and Star Port as inspiration. And I wanted to use stippled colours as much as possible to make the apparent colour palette seem more than the four colours that the game was limited to.

I designed the set of graphics for the final set of levels (PRESTO) first. My inspiration for these were the full-page adverts for Repton 2 and Repton 3 that Superior Software used to run in Acorn magazines at the time. In particular, I wanted to design a set with light mortar between distressed bricks. I’m very proud of this set and I think it’s actually my favourite.

Presto – not for the faint hearted

I got a bit carried away, and I also redesigned Repton to look like he did in Superior’s adverts – this was very quickly and firmly rejected, and rightly so!

My Redrawn Repton went down like a cup of cold sick

I had one set down, three more in front of me and even using FilmStrip on a BBC Micro emulator seemed like very hard going. I really wanted to use The GIMP to design the graphics and suddenly it dawned on me that I could.

I could design the graphics in The GIMP and then transfer them to the BBC Micro emulator using the BBC Micro Image Convertor by Francis G Loch. This is an application written in PureBasic that takes image files (bmp, jpg, etc.) and downconverts them into the native screen display formats of the BBC Micro.

The process has a few stages. First I design all the graphics as separate files in The GIMP:

Completed graphics designed in The GIMP

Then I use the GIMP to slice them up and put them in rows:

Sliced and Diced in The GIMP

And finally I convert the graphic into BBC Micro format using the BBC Micro Image Convertor:

And converted to BBC Micro format

So, I fired up The GIMP and the next set I designed was for the LARGO set. This is the default set that loads when the game or editor loads, and the levels in this set were the original six levels designed by Paras Sidapara back in 1988.

Largo – the Realm of the Exile

Because I knew Paras was a huge fan of the game Exile, I decided to base the design of the walls on the walls found in Exile. This set looked very nice and thanks to The GIMP I was able to design them very quickly.

Adagio – Exile crossed with Repton 2

The third set I designed was a set for the ADAGIO screens. This set was a kind of cross between the walls found in Exile and the walls found in Repton 2 (my favourite Repton release). It didn’t work as well as I would have liked and I wish I’d done something a bit different.

Allegro – juicy, apparently…

The final set I designed was the ALLEGRO set. It was loosely based on the graphics for the game XOR, which my children were madly into playing at the time. This set has been described as looking “juicy”, whatever that means! Dave Moore accused me of taking a little more care over these graphics than some of the others because I knew I was designing all six levels to go with them. How very dare he!

The work on the graphics Repton: The Lost Realms was very straightforward. I did very little rework once we decided on what we were doing and there were only two real debates about the game characters. The first concerned earth, the second concerned fungus.

As far as the earth is concerned, I wanted to experiment with some dense Ravenskull style earth, whereas Dave Moore preferred the very sparse earth used in the Toccata level set of Repton 3. Dave got his way on that one!

Now that’s what I call fungus!

The fungus debate concerned my preference for fungus that looked like a toadstool rather than the amorphous mould that was presented in Repton 3. In the end, I redesigned the fungus to look slimy rather than mouldy but it’s probably the graphic I am least happy with.

Now that’s what I call fun, Gus!

We also had a discussion about the “freeze pill”. This was a green pill that froze monsters temporarily. What with absorbalene pills and time pills I thought Repton’s drug habit had gone far enough.

Freeze pills – just say no.

 
I wanted to replace it with a Citadel style snowflake. Everyone agreed, and that also involved making changes to the editor and game map graphics which I did by hacking the code about. But, although my snowflake was a good idea, I think the graphic I designed was horrible.

Snow flake – just say yuck.

Once I’d designed all four sets, I thought that that was that – only it wasn’t. By this stage Tom Walker (someone for whom the word genius seems utterly inadequate) had joined the project, and had started work coding an Acorn Electron version.

The Acorn Electron is cruelly afflicted in many ways, but one of the worst is that it has no hardware scrolling. That is terrible news for a game like Repton which relies on scrolling. Acorn Electron scrolling has to be done in software, which eats up the memory available for the game – and its graphics. The graphics in Acorn Electron Repton: The Lost Realms are 12 x 24 instead of 16 x 32 for the BBC Micro version.

Skull (Acorn Electron)

This meant I had to create cut down versions of all of the games’ graphics for the Acorn Electron version, and doing this took as long as it took to create the original graphics. In fact, I put in so much effort I actually prefer some of the Acorn Electron graphics.

Largo – All ready to transfer to Elkulator

Probably the most interesting thing about doing this was the lack of an Acorn Electron editor – or indeed an Acorn Electron version of the game itself! I had actually finished the graphics and put them in game files before Tom had finished coding the Acorn Electron version of the game.

It was quite some time after I had finished the graphics that I was actually able to play with the graphics in the game itself via Tom’s excellent Acorn Electron emulator Elkulator.

 Acorn Electron version

Keen eyed Repton fans will notice that Acorn Electron Repton: The Lost Realms reintroduces Tim Tyler‘s Repton sprite from Repton 2. I think this has much more personality than the one used in Repton 3.

I knew that there was a keen interest in the Repton: The Lost Realms from Acorn Electron enthusiasts so I put an enormous amount of effort in the graphics for the Electron version – I just hope they like them!

And finally –  a word about the design of the crowns. I spent many years living in my wife’s home-town of Mélykút, the birthplace and home of the legendary restorer Szvetnik Joachim. He was famous for supervising the return of the Holy Crown of Hungary from the USA in 1977. I went to his workshop in Mélykút to translate for some tourists from New York State, and enjoyed my visit so much I decided to make the crown in ALLEGRO look like the Holy Crown.

Allegro Crown (BBC Micro version)

The other crowns in Repton: The Lost Realms are also based upon real crowns – I wonder if you can work out which ones?

Repton: The Lost Realms loading screen

After I created the artwork for “Repton: The Lost Realms“, Dave Moore of Retro Software asked me if I would create a loading screen for the BBC Micro and Acorn Electron versions of the game. Initially the brief was quite loose – he thought we needed a Mode 5 screen for the cassette versions and a Mode 1 screen for the disc versions.

My cover artwork for Repton: The Lost Realms

On a BBC Micro or Electron, Mode 1 and Mode 5 are both four colour screen modes. The difference is that in Mode 1 the resolution is 320 x 256, whereas in Mode 5 the resolution is 160 x 256. However, both images are the same size because in Mode 5 the pixels are twice as wide as they are high. Due to its lower resolution, Mode 5 uses half the memory of Mode 1 so will load far more quickly for those using cassette recorders.

My first thought was to create the Mode 1 screen, and to use the excellent BBC Micro Image Converter software by Francis G Loch. This is an application written in PureBasic that takes image files (bmp, jpg, etc.) and downconverts them into the native screen display formats of the BBC Micro. To aid you in doing this it offers an almost bewildering array of image processing options specifically tailored for getting modern images into BBC Micro format. It can  also takes BBC Micro screen dumps and convert them to modern image formats.

BBC Micro Image Converter copes with anything

I use Ubuntu Linux, which means I have to run the Windows binary of the BBC Image Converter under WINE. I’ve found the operation of the program under WINE to be problematic if you don’t export import and output images from and to the WINE “C:Program Files” folder. It also seems happier with being fed bmp files than pngs under WINE.

Inspired by Michael “Mic” Hutchinson’s excellent loading screen for the disc version of Repton Inifinity, I decided to use the same Red, Black, White Green palette. I was very pleased by my early results – particularly the way the brown came out on the safe. However I hadn’t left any room for branding and so on.

My first try in BBC Image Converter

So I decided to create a version that had an area at the bottom that could be removed in the same way as the version on Repton Infinity disc for loading messages etc.

My rejected disc loading screen

I showed Dave this version and he had a number of reservations – the main one being that the loading screen in Mode 1 didn’t really grab him at all. He wanted something more colourful for the disc version, and he suggested trying Mode 2. Mode 2 is identical to Mode 5, apart from the fact you can use eight colours.

The first thing I did was to create a screen in Inkscape that was 320 x 256 pixels that was set out exactly as I wanted to my loading screen to look. I would use this to feed into the BBC Micro Image Converter.

The image I made to feed into the BBC Micro Image Converter

When I imported it, the results were excellent. In fact, the results were too good. Although obviously I needed to retouch here and there to tidy up the writing and the balloon strings I was overwhelmed by the feeling that really I should be producing something that was done by hand on a pixel editor – not put through some ingenious image processing we could only dream of in 1987.

All it needs now is for me to make it a bit rubbish

Therefore I fired up “The GIMP” and tried to add a sort of “hand designed” feel a pixel at a time. I was quite aware that what I was doing wasn’t as good as what the BBC Image Converter could produce, but the idea was to get a “retro” feel.

Final image after I gave it a “hand made” feel in The GIMP

I showed Dave Moore and he was happy with the Mode 2 screen, so the next job was to produce the cassette loading screen in Mode 5.

When it came to creating a Mode 5 screen, I decided to convert the eight colour Mode 2 screen to a four colour Mode 5 screen by hand, instead of running through the BBC Image Convertor again. This was because I wanted to keep the two loading screens as close as possible to each other in appearance.

I reduced the colour depth by hand in The GIMP

Dave was happy, so that was my first two loading screens for Retro Software done and dusted.

Repton: The Lost Realms is under development by Retro Software. Repton name used by permission of Superior Interactive.

The BBC Image Converter is currently released under a non-free licence but it’s free as in beer to use for commercial or non commercial uses. You can look at a number of the PureBasic routines Francis wrote for it here.