Sunday, 27 September 2020

Lunchtime Coder #2 - BBC Micro Screen Graphics Viewer

After some success with the ZX Spectrum screen buffer interpreter ( See Post Here ) , I decided to have a go at an Acorn BBC Micro (Model B) screen interpreter.

It turned out to be a lot tougher going than I expected..

GOAL - To take a ".uef" BBC Micro Memory snapshot file, and interpret the screen buffer area of the memory into a display screen as would have been seen on the TV / monitor.

Fool that I am, I thought that this would be a reasonably straight forward process as it had been on the ZX spectrum however, the BBC Micro has different screen modes which have different resolutions and different colour depths. Also The start of the screen buffer is user definable and the colours available in that mode are also user definable.

This means that a lot of different values need to be read from the BBC Micro's memory before you can start to interpret the screen buffer into something understandable.

For the table below, the graphic resolutions for modes 3, 6 and 7 can be ignored as they are either text only or teletext based modes. Also there is only 8 colours listed for modes 2 and 7 as even though you can assign them to flash, there is still only 8 base colours.

I'm going to ignore the text only modes (Modes 3, 6 and 7) and concentrate specifically on the graphics screen modes.

A lot of BBC Micro games were done in Mode 2 or Mode 5. The horizontal resolution for those screens is reduced (160 instead of 320) however, each pixel in the screen buffer is drawn two pixels wide on screen, so that the overall picture on screen is still 320 pixels wide, but takes half the memory. The downside of this is that the screen is only half as detailed horizontally.

There are a lot of values in various BBC Micro memory locations that define how the graphics are drawn, and reading all of these is essential to be able to draw the screen correctly.

DEV 001 - A program that skips the ".euf" file header and footer, that reads the bytes from the BBC Micro memory dump part of the file, converts them into bits, writes the bits into an array so that the array is set out like the BBC Micro memory would be, and then reads the values required to draw the screen from the array. The output should be some values read from the array and converted into decimal.

There are three types of value to read and convert to decimal values:
1 - straight forward single Byte values
2 - Higher value spread over two bytes
3 - Higher two byte values with imaginary low byte that is always at 255.

You can see from the values below in DEV 001 that a number of other screen drawing related values can be derived from various BBC Micro memory locations.

DEV 002 - Now that we can read the values from the memory dump, lets try drawing something. The maximum resolution that the BBC micro can draw at is 640 x 256, so if we base the actual output display around a 1280 x 1024 size, this means that:

Mode 0 pixel is 2 x 4 interpreted pixels
Mode 1 Pixel is 4 x 4 interpreted pixels
Mode 2 pixel is 8 x 4 interpreted pixels
Mode 4 pixel is 4 x 4 interpreted pixels
Mode 5 pixel is 8 x 4 interpreted pixels

One thing I cant find in the BBC Micro memory or derive from the values in the memory is how it knows to draw wide pixels for mode 2 and mode 5, other than using a hard coded value of 320 for the screen width and then using the Current Graphics Window Right Column value.

A handy thing that I do remember from my childhood watching BBC micro games load first from tape, and then later on from disk, is that sometimes the loading game ran into the screen buffer and you could see the bits in the memory being loaded.

This would then draw garbage to parts of the screen, character by character, starting at the top left of the screen and working left to right and top to bottom.

When I say "Character by Character", a character is essentially an 8 x 8 square of pixels, and as the bits were drawn, they would again be drawn left to right, and top to bottom. (Later found to be incorrect.. see DEV 003).

With this in mind, the drawing "loop" should be 4 loops inside each other:

Outer loop 1 - Character Y position (derived from current text window top and bottom row
Outer Loop 2 - Character X psoition (derived from current text window left and right column)
Inner Loop 1 - Inside Character Pixel Y position ( 0 to 7 )
Inner Loop 2 - Inside Character Pixel X position ( 0 to 7 )

Then an x and y multiplication factor will be needed to draw the correct pixel size, depending on the mode being drawn.

Inside the four loops is the drawing program in four parts. Read from the screen display start memory location (adding an offset as you read and draw the bits) and decide what value the pixel is. Check what colour corresponds to that value. Draw the pixel. Update the offset to read the next pixels data.

Lets see how it looks:

What I've Got

What it should look like..

Obviously there is some issues here. Apart from the pixels being all over the place, there is also colour issues but.. I seem to have picked an odd one to start anyway as the screen mode is 1 (4 colours) and yet I can see 6 colours on screen on the proper one ?!

This routine works fine with mode 0, but mode 0 is simple to draw; 1 bit=1 pixel so read the bit and draw the pixel. Mode 1 and 4 have 2 bits per pixel, and to complicate this, the two associated bits are 3 bits apart. Four pixels per byte. Pixel 1 is bit 0 and 4, Pixel 2 is bit 1 and 5. Pixel 3 is bit 2 and 6 and Pixel 4 is bit 3 and 7.

Mode 0 - Works perfectly but is somewhat easier to draw than other modes; 1 bit per pixel

DEV 003 - After a lot of head scratching and staring at what I was drawing compared to what it should look like, I had a lightbulb moment!

I assumed that the pixels were drawn for evert mode as 8 pixels in a row before going to next row, and this is why Mode 0 worked, however I was wrong. Mode 0 works that way because it has 8 pixels per byte. What actually happens is a bytes worth of pixels is drawn (8, 4 or 2 pixels) and then you drop a row and draw the next byte and so on. So for mode 0, it will be draw 8 pixels then start the next row. For mode 1 and 4, it will draw 4 pixels and then start the next row and for mode 2 and 5, it will draw two pixels and start the next row.

This means that the amount of columns drawn is the difference between current text window left column and current text window right column but then multiplied by Bit Depth or Bits per pixel.

Bingo! Now we have something that looks a bit more like a BBC Micro screen.

However, While this looks good, It doesn't always work.

Case 1 - Citadel

Garbage and squished to the bottom of the display
Should be no garbage, and vertically central

There are two things wrong with this image;

1. You can see some garbage at the top of the screen. 2. The image is at the bottom of the screen, not centred as it should be.

The garbage at the top of the screen (The Top 8 rows of characters or top 64 rows of pixels) is because part of the screen buffer memory has been used as general memory.

You can also see from the values at the left that "Current Text Window Top Row" is set to 8, not 0. You can also see that the "Current Graphics Window Top Row" is set to 176, not 255

So its plausable that because the "Current Text Window Top Row" is set to 8, and the top 8 rows of characters are garbage, that the top 8 rows shouldn't be drawn. Thats pretty easy to fix.

There is also an offset for the picture of 24 pixels from the top, and 40 pixels from the bottom. Where that comes from, I do not know.. And what part the "Current Graphics Window Top Row" is set to 176, not 255 plays, again I do not know. None of these numbers leave you with 24 rows of pixels at the top.

Case 2 - Ultimate Title Screens

Whats in the screen buffer
What it Should look like

All of the screen data is there, but clearly the picture is narrower than the screen, although the current text window and current graphics window width settings are all set to max.

I guess that there is some different trickery going on here that doesn't conform to standard screen displaying, or some additional memory locations with settings that I should have included in the program.

Final Thought:

The BBC Micro used to get seriously knocked when compared to the ZX Spectrum and the Commodore 64 because of its limitations, however if you take a look at the screen shots below, you can see that this wasn't always deserved.

ZX Spectrum Atic Atac Start Screen
BBC Micro Atic Atac Start Screen

Lunchtime Coder #1 - Sinclair ZX Spectrum Bitmap and Graphics Buffer Viewer / Editor

As a small lunchtime coding project, I decided to write a ZX Spectrum bitmap viewer.

The idea of this was to arrange the bits in a ZX Spectrum ".sna", ".tzx", ".z80" or ".tap" file into columns of 8, 16, 24 or 32 bits wide in order to be able to view the game bitmaps.

The bits could be stepped through bit by bit or in larger steps and the display flipped upside down if required and if the bitmaps were upside down. When you found some interesting ones, you could snap them or if you wanted to, edit the bits to create custom game files.

The Viewer - Taking a Look at UPTG's "Underwurlde" Bitmaps.

The Snapshot Output.

With this done, I decided to add an extra mode; Screen Buffer Interpreter or TV Screen mode; A mode that would read the Screen Buffer part of the memory, and interpret it into what would actually be displayed on the TV / Monitor screen.

The ZX spectrum is pretty nifty when it comes to storing 16 colour graphics in a small amount of memory.

It has a single screen mode with a resolution of 256 x 192.

It could display 16 colours (well 15 really as two of the colours are Black). It achieved this by having a standard 8 colour pallette: Black, White, Red, Yellow, Green, Blue, Cyan and Magenta, and then having a brightnesses bit that allowed each of the colours to be displayed at two different brightness settings, with the exception of the previously mentioned Black colour. e.g. Red with Brightness bit set to 1 would have an RGB value of 255,0,0 whereas Red with Brightness bit set to 0 would have an RGB value of 215,0,0.

In normal screen buffer terms, If each pixel could be one of 15 colours, each pixel would need 4 bits to describe its colour. If that were the case with the ZX Spectrum, then 49,152 pixels at 4 bits per pixel would need 196,608 bits or 24,576 bytes or 24.5 kB of memory just for the screen buffer.

In a 48 kB ZX spectrum, that would leave you just 23.5 kB for the programing, and in a 16 kB ZX Spectrum, that would leave you no room for programing, and only half of the screen displayed.

Fortunately, Sinclair came up with a way of displaying 16 colours on screen but using considerably less memory, although this did have some limitations and lead to the infamous ZX Spectrum colour clash phenomenon.

Firstly, the actual graphics on screen are stored in just black and white, so that each pixel needs just one bit of memory; either 0 for black or 1 for white.

Then each 8 x 8 pixel square has an attribute byte. This byte has 3 bits for the foreground colour (Ink) and 3 bits for the background colour (Paper). There is then a Bright bit which if set to 1 makes both ink and paper as the brighter colour, rather than the darker colour, and then a flash bit that when set to 1, flashes the colour.

The total memory now used is 49,152 bits or 6 kB for the actual screen pixels, and then 768 bytes for the attributes (32 columns of 24 rows of 8 by 8 pixel squares).

So the whole screen fits in to less than 7 kB. Pretty clever, but comes with limitations. If you have two characters on screen of different colours, and they get close to each other, they will overlap onto each others Ink and Paper attributes, and this is where the infamous ZX Spectrum "Colour Clash" happens.

Note: The only other system I can think of with Colour Clash is the Arcade machine "Berzerk" by STERN, but the colour clash issue with Berzerk is for very different reasons.

The screen buffer part of the memory draws to the screen in a very specific way.
If you imagine the screen as an Excel spreadsheet with 192 rows and 256 columns, with each cell representing an on screen pixel.
To draw the screen, the bits are streamed from the memory to draw in black and white, firstly the whole of row 1, then row 9, then row 17, then row 25 and continuing to draw every eigth row for the top third of the screen.
The process is then repeated only this time starting at row 2, and every eighth row after for top half of screen, then starting at row 3, row 4 etc until you have drawn the whole top third of the screen in black and white.

Now the process is repeated only this time starting at row 65 to draw the middle third of the screen.

Finally the process repeated only this time starting at row 129 to draw the bottom third of the screen.

Once the whole screen is drawn in black and white, the screen attribute bytes are read and the Ink and Paint colours are applied, starting at the top left side of the screen and colouring each 8 x 8 square of pixels.

Screen Buffer in 8 bit width columns - Screen Attribute Bytes on RH side of Highlighted Square

Screen Buffer in 256 bit width - Screen Attribute Bytes at bottom of Highlighted Square
Screen Buffer Interpreted into Screen Display

This method of drawing the screen shouldn't be strange to anyone who owned a ZX Spectrum back in the day, as this is the order that the loading screens drew themselves when loading a game from tape. The bits were streamed from the tape into the first part of the ram, which was the screen buffer, and as they went into the memory, they started to slowly draw the loading screen in this secific order, as the video below shows.

Not exactly cutting edge, but a fun brain exercise for some boring lunchtimes.

Thursday, 24 September 2020

My Top 10 Arcade Classics - Can I Play All Of Them on the Sony PlayStation / PSOne / PS1 / PSX ??

As a purebred Generation-X, I was lucky enough to witness first hand the boon of video gaming from Arcade games (Space Invaders onwards) to Home computer gaming (ZX81 onwards) to home video game consoles (Atari 2600 onwards).

During those years, arcade machines were everywhere! Cafe's, Swimming pools, holiday camps, takeaways, youth clubs, pubs, clubs and of course Amusement arcades. It was almost impossible to avoid arcade games at this time.

But.. Making a top 10 list isn't always easy. There is so many beloved classic games to choose from, and trying to remember back 30 or 40 years to what were my first early favourites can be a challenge. Come to think of it, I had my first PS1 in 1995...25 Years ago!

To assist in making a list like this, it always helps to have a clear goal, and some rules.

So, the goal is to identify my favourite top 10 Arcade CLASSIC games. I will start at the beginning of my gaming life and work forwards from there. As I am looking for classics, I will only consider pre 1990s games, and as I was born in 1972, and the first arcade game I remember is Space Invaders, I won't got pre 1978.

For the game to be selected, I have to have played it a reasonable amount of times on an arcade machine at the time. I can also count additional play time if I played it on home arcade conversion. As I had an Acorn BBC Micro during the 80s, I got to play a number of spot on classic arcade conversions written by Acornsoft and other software houses. What the BBC Micro lacked in complex arcade adventure style games, it more than made up for in classic coin op conversions.

The " Is it playable on the PS1 " part will not bias my choices, and for the playable on the PS1 part, I will consider both official releases and homebrew options, although i won't include PS1 MAME as the "playable on the PS1" part should be considered as fully playable at the correct speed as you would have played it on the arcade original. I also won't include remakes, as this isn't an arcade original version.

And with the goal and rules in place, lets get on with the nostalgia trip!

1. Super Earth Invasion (Space Invaders Clone)

I played a lot of different variants of Space Invaders as a kid. I even remember one of them having the cellophane colour screen mod and even as a kid thinking "Well that's a cheat!".

I also remember playing two versions on the BBC Micro; Acornsoft's "Space Invaders" and "Super Invaders".

The specific version that sticks out to me the most had houses instead of shields. Over the years, I thought that I had imagined this but after some research, I found that the version that I remembered playing most clearly was Super Earth Invasion, a Space Invaders clone.

Can you play Super Earth Invasion or Space Invaders on the Sony PS1?... YES, in fact you can play both!

You can play Space Invaders (the original) on a number of releases for the PS1. I reviewed all of the releases on this post HERE!

But better than this, you can actually play Super Earth Invasion on the PS1 via the gift of Homebrew using Anthony Ball's excellent RetroCoder Invaders Emulator / The Space Invaders Project. There is a review of the emulator on this post HERE at the bottom of the page.

Not bad! One down, nine to go, and currently we are 1 - 0 up!

2. Pac-Man

Ah, the classic pill popping, Ghost Busting beach ball with a mouth. Hours of my childhood family holidays spent hanging around shady amusement arcades on holiday camps plugging in 10p coins in the hope of clearing at least two levels and getting the bonus animated sequence and music, or just loitering around the machine egging other players on.

I was also able to play the game on the BBC Micro in the form of Acornsoft's "Snapper", a Pac-Man clone. Initially Snapper was identical to Pac-Man, but after some legal threats, the graphics were reskinned to turn the ghosts into menacing looking bipeds and Pac-Man into a hat wearing walking Grapefruit... or something similar... I've never been really sure what Snapper was meant to be ?

Can you play Pac-Man on the Sony PS1?... OF BLOODY COURSE YOU CAN ! And I've banged on and on about it for quite long enough on this post HERE!

2 - 0 up, 8 to go and going strong.

3. Berzerk

Alan McNeils absolute classic robot run 'n' gun, with creepy robot speech included. This game accounted for an awful lot of my missing pocket money, and I regret nothing !

The BBC Micro had no real Berzerk equivalent, although I always felt that "Cybertron Mission" was heavily Berzerk influenced.

Can you play Berzerk on the Sony PS1 ?... No. Unfortunately not.

Still.. 2-1 up, 7 to go.. Could do with popping another one in before half time though..

4. Moon Patrol

More absolute childhood magic. I bloody loved this game! I think that maybe I have a particular soft spot for this game as there was no real equivalent on my BBC Micro, and therefore it was an absolute unique experience playing it in the arcade.

The closest I could get on the BBC Micro was either "Spaceman Sid" by English Software or "BMX On The Moon" by Superior Software, but whilst both of these games were fun to play, neither of them really captured the essence of Moon Patrol.

Can you play Moon Patrol on the Sony PS1 ?... Hell YES!!

Moon Patrol is available on Arcade's Greatest Hits: The Midway Collection 2.

For a list of the games included on this compilation, take a look on this post HERE.

3 - 1 up, and still not half time. 6 to go..

5. Scramble

Another superb classic that I couldn't get enough of ! I played the cocktail cabinet version of this one so many times, eventually slipping through all of the tight passages (ooer!) and getting to the end of stage 6.

I was spoilt for choice on the BBC Micro: Both "Rocket Raid" by Acornsoft and "Moon Raider" by Micro Power (Program Power) were able conversions of this horizontal shmup coin-op original.

Can you play Scramble on the Sony PS1 ?... You bet your ass you can !

Scramble is available on Konami Arcade Classics aka Konami 80's Arcade Gallery.

For a list of the games included on this compilation, take a look on this post HERE.

Scramble is also available on Homebrew using RetroCoder Galaxian Emulator / The Galaxian Project.

For more information on this multi-arcade game emulator, take a look on this post HERE.

4 - 1 up ! I've had worse half time scores … (Being a Pompey fan, a lot worse!)

6. Defender

I always kind of considered Defender as Scramble on acid. Fast and frantic, flipping left and right and what a trip when all your planetary wanderers die. I am pretty sure that I used to play on a clone version back in the day, as the cabinet was plain black with no d├ęcor.

The BBC Micro served up an admirable conversion in the form of "Planetoid" by Acornsoft. I also remember playing a second conversion but the name eludes me.

Can you play Defender on the Sony PS1 ?... You certainly can !

Defender is available on Williams Arcade Greatest Hits.

For a list of the games included on this compilation, take a look on this post HERE.

5 - 1 ! We are cleaning up!

7. Frogger

Well I liked ponds and what lived in them as a kid, so I was bound to be drawn to Frogger. The arcade version, the hand held version that my mate owned, the home computer conversions. It was all good amphibious fun! Throw in some crocs (or were they alligators?), some snakes, some turtles (or were they terrapins?) some dragon flies and a busy road, and you have got yourself hours and hours of arcade fun.

And on the BBC Micro, the fun continued with Acornsoft's "Hopper" and Superior Soft's "Froggy".

Can you play Frogger on the Sony PS1 ?... Nope. Not on here !

Yes there is a PS1 game released entitled "Frogger" aka "Frogger: He's Back", and yes, level 1 of this game is a low poly count 3D REMAKE of the original frogger game, however it is not Arcade Original Frogger, and Arcade Original Frogger is not an unlockable in this game or its sequel, "Frogger 2: Swampys Revenge", so the answer to this one is no.

5 - 2 ! Still a convincing lead!

8. Asteroids

Loved the game. Loved the vector graphics. (Hated the hyperspace..) Never worked out why there wasn't a Left-Right Joystick for rotation, or a four direction joystick for Left, Right, thrust and... I dunno.. Reverse Gear? (I guess buttons were cheaper). An all round fab game with many variants but as long as you can spin, shoot and thrust (ooer..) it still keeps me happy to this day.

Yet again, BBC Micro owners were spoilt for choice with piles of different ports of Asteroids, the best two probably being Acornsoft's "Meteors" and Atarisofts "Asteroids Deluxe" .

Can you play Asteroids on the Sony PS1 ?... Yes. Yes you can.

And I banged on about this very fact on this post HERE! Have a read.

6 - 2 ! C'mon Ref, Blow the whistle!

9. Time Pilot

Yay lets travel back in time, meet interesting people from that time period, and then shoot them down! I was never brilliant at this. I could get to the jet planes level, but I saw people get to the flying saucers level and was always envious..

BBC Micro owners were treated to the rip off that was Superior Software's "Space Pilot". An admirable conversion of the arcade treat.

Can you play Time Pilot on the Sony PS1 ?... That's an affirmative.

Time Pilot is available on Konami Arcade Classics aka Konami 80's Arcade Gallery.

For a list of the games included on this compilation, take a look on this post HERE.

7 - 2.. and into stoppage time

10. Phoenix

Ha! Space Eagles ?! AS IF !! But all the while that Space Eagles can create this much frantic shoot em up fun, then they are welcome in this fantasy world, including the annoying ones that perch just under your ship and need to be dispatched using your shield.

I had "Eagle Empire" by Alligata Software. It was an OK conversion up until the mothership level where you were fighting just the mothership, not the mothership and a wave of space eagles. It was still pretty good for the time.

Can you play Phoenix on the Sony PS1 ?... Yes! In all of its original arcade glory!

Phoenix can be played on PS1 homebrew using RetroCoder Phoenix/Pleiads Emulator / The Phoenix Project.

For more information on this multi-arcade game emulator, take a look on this post HERE.

So full time, and the final score is 8 - 2. (and that 9th one was never offside!)

But, I couldn't leave without giving some honourable mentions to the games that just missed out on the top 10 spots..

BBC Micro
Available on
Sony PS1?
Galaxian Acornsoft
Namco Museum Volume 3
Mini version on Ridge Racer
Star Wars Domark
"Star Wars"
Galaga Aardvark Software
Namco Museum Volume 1
Mini version on Tekken
Star Castle None No
Crystal Castles US Gold
"Crystal Castles"
MRM Software
"Castle Of Gems"
Arcade Greatest Hits: The Atari Collection 2
Space Duel None Atari Anniversary Edition Redux
Tempest Superior Software
Arcade's Greatest Hits: The Atari Collection 2
Atari Anniversary Edition Redux
Pole Position Atarisoft
"Pole Position"
Namco Museum Volume 1
Donkey Kong Micropower
"Killer Gorilla"
Solar Soft
"Zany Kong"
No. Read More HERE !
Donkey Kong Jr Superior Software
"Killer Gorilla 2"
"Donkey Kong Jnr"
Time Pilot '84 None No
Uniwars None No
Mr. Do! Superior Software
"Mr. Wiz!"
Micro Power
"Mr. Ee"
8-Bit Software
"Mr. Do"
Gorf Doctor Soft
Amidar Acornsoft
"Crazy Tracer"
Superior Software
"Crazy Painter"
Battlezone Software Invasion
"3D Tank Zone"
Superior Software
"Battle Tank"
Arcade's Greatest Hits: The Atari Collection 1
Bombjack None No.
Bubble Bobble None Bubble Bobble and Rainbow Islands
Centipede Bloody Loads! Arcade's Greatest Hits: The Atari Collection 1
Centipede (Remake)
Donkey Kong 3 None No
Gaplus / Galaga 3 None Namco Museum Volume 2
Millipede A whole bunch! Arcade's Greatest Hits: The Atari Collection 2
Halleys Comet None No
Missile Command Loads and Loads! Arcade Greatest Hits - The Atari Collection 1
Atari Anniversary Edition Redux
Missile Command (Remake)
Moon Cresta Alternative Software
"Moon Cresta"
Superior Software
"Star Striker"
Nichibutsu Arcade Classics
Ms Pac-Man None Namco Museum Volume 3
Ms Pac-Man Maze Madness (Remake)
Qbert Loads and Loads! Qbert (Remake)
Sinistar Superior Software
"Death Star"
Williams Arcade's Greatest Hits
Xevious Superior Software
Namco Museum Volume 2
Xevious 3D/G+