BBC Micro Screen Formats

This article was originally published in The Crypt Mag

Introduction

My writing this article all started off as I needed to convert some graphics files from a BBC Micro into something a bit more universal. Just for the fun of it I set about trying to program my own conversion software to accomplish this task.

For those that are unfamiliar with the BBC Micro, it was a computer that was designed and built for the British Broadcasting Corporation (hence the BBC badge) by Acorn Computers Ltd in the early 1980s as part of the BBC’s Computer Literacy Project. I will not go into the full history of the BBC Micro here, but for those that are interested you can look here for more information.

Now the last time I had seriously used a BBC Micro must be around 10 years ago now and although I had spent some 13 years using BBC Micros I was quite amazed at how much I had forgotten regarding how they organised their screen data. A search on the internet to see if I could find any details of the BBC Micro’s screen format did not reveal anything useful. It took a combination of what I could vaguely remember and some experimentation before I eventually had some success.

Screen Modes on the BBC Micro

The BBC Micro has eight standard screen modes. Of these, seven are raster modes (Modes 0-6) and one is a hardware text mode (Mode 7). The properties of each screen mode can be summarised as follows:

Mode Graphics Width Graphics Height Text Columns Text Rows Depth No. of Colours Memory Used
0 640 256 80 32 1 2 20 kB
1 320 256 40 32 2 4 20 kB
2 160 256 20 32 4 16 20 kB
3 80 25 1 2 16 kB
4 320 256 40 32 1 2 10 kB
5 160 256 20 32 2 4 10 kB
6 40 25 1 2 8 kB
7 40 25 8 1 kB

From the table you can see that Modes 3, 6 and 7 do not have any values stated for the graphics width or height. This is because these are not intended as proper graphics modes.

Mode 3 is similar to Mode 0, but uses up 20% less memory by reducing the number of text rows. Likewise, Mode 6 is similar to Mode 4, but again reduces the text rows to reduce the memory consumption. A side effect of the reduced number of text rows is a gap being created between each row. This is not usually noticed as the default colour scheme is white text on a black background, but changing the background to a different colour shows up these gaps as black lines as illustrated in the image below:

Mode 7 is a text only screen mode, but by using special control characters it can be used to create teletext-style graphics. By using this method it means that Mode 7 screens do not have a screen depth per se because the colours and other properties can be altered by the control characters. It also means that Mode 7 screens utilise an absolute minimum of memory, a mere 1k.

An example of a Mode 7 screen (taken from the game Yellow River Kingdom) is shown below:

Colour on the BBC Micro

The BBC Micro uses a digital palette meaning that each colour value can only be fully on or fully off. This limits the BBC Micro’s palette to a total of only eight colours.

Now you may be asking yourself why Mode 2 has sixteen colours specified in the table above when the BBC Micro can only produce eight. The reason is because the last eight colours alternate between two different colours, a feature that was rather unique on the BBC Micro.

The BBC Micro’s default 16 colour palette is shown below:

Converting the Screen Dumps

On the BBC Micro graphics files such as title screens in games were typically saved as a screen dump. A screen dump is where the image is saved directly from the computer’s memory onto disk with no form of encoding or compression.

The first stumbling block I had when trying to convert the screen dumps was my incorrect assumption that the screen data was organised sequentially line by line in a similar manner to most other graphics formats. This approach ended up producing nothing but garbage in the conversion.

After some experimenting I eventually realised (and remembered!) that the way the BBC Micro organises its screen data is in characters or blocks that are 8 pixels wide by 8 pixels high. So rather than reading the screen data line by line it was necessary to read it character by character. The table below illustrates the organisation of the screen data for two characters where each number represents one pixel.

1st Character
2nd Character
0
1
2
3
4
5
6
7
64
65
66
67
68
69
70
71
8
9
10
11
12
13
14
15
72
73
74
75
76
77
78
79
16
17
18
19
20
21
22
23
80
81
82
83
84
85
86
87
24
25
26
27
28
29
30
31
88
89
90
91
92
93
94
95
32
33
34
35
36
37
38
39
96
97
98
99
100
101
102
103
40
41
42
43
44
45
46
47
104
105
106
107
108
109
110
111
48
49
50
51
52
53
54
55
112
113
114
115
116
117
118
119
56
57
58
59
60
61
62
63
120
121
122
123
124
125
126
127

At this point my conversion software worked great on images that only had a colour depth of 1 bit (two colours). The reason for this is each bit represents each individual pixel and therefore does not require any further decoding.

Images with more than two colours require that each pixel is made up of more than 1 bit. The depth of a screen dictates how many bits each pixel is made up of. The table below shows how the bits relate to the colour for the various screen depths.

Screen Depth Bit 3 Bit 2 Bit 1 Bit 0 Colour No. Default Colour
1 bit 0 0 Black
1 1 White
2 bits 0 0 0 Black
0 1 1 Red
1 0 2 Yellow
1 1 3 White
4 bits 0 0 0 0 0 Black
0 0 0 1 1 Red
0 0 1 0 2 Green
0 0 1 1 3 Yellow
0 1 0 0 4 Blue
0 1 0 1 5 Magenta
0 1 1 0 6 Cyan
0 1 1 1 7 White
1 0 0 0 8 Flashing Black / White
1 0 0 1 9 Flashing Red / Cyan
1 0 1 0 10 Flashing Green / Magenta
1 0 1 1 11 Flashing Yellow / Blue
1 1 0 0 12 Flashing Blue / Yellow
1 1 0 1 13 Flashing Magenta / Green
1 1 1 0 14 Flashing Cyan / Red
1 1 1 1 15 Flashing White / Black

Although I have specified the default colours for each screen depth, these are programmable (in the same way as the Mode 6 screenshot above) to any of the 8 solid or 8 flashing colours that the BBC Micro can display.

Below is one of my early attempts at converting the title screen for the game Codename: Droid – Stryker’s Run Part 2:

As you can see it was not quite right yet! The problem here was that the colour information for the pixels was not being decoded correctly.

As already stated 1 bit images are nice and simple since there is no colour information to really decode. Take for example a byte with the bits 011001012. The pixel colour information for this would be:

Pixel No.
Bit
Colour No.
1
0
0
2
1
1
3
1
1
4
0
0
5
0
0
6
1
1
7
0
0
8
1
1

As you can see 1 bit images are child’s play! But what about images with screen depths greater than 1 bit?

I had originally assumed that the colour information would be stored in each byte in sequential order, so using the same bit sequence as before I thought that a 2 bit image would give four pixels of:

012, 102, 012 and 012

Likewise I thought that a 4 bit image would give two pixels of:

01102 and 01012

Not so!

After some more experimentation I discovered that for a 2 bit image you actually need to take the 1st and 5th bits for the first pixel, the 2nd and 6th bits for the second pixel, etc. to give you your 2 bit colour information. Using the same bit sequence as before the table below shows us what the correct pixel colour information would be for the 2 bit image:

Pixel No.
Bit 1
Bit 0
Colour No.
1
0
0
0
2
1
1
3
3
1
0
2
4
0
1
1

For 4 bit images you need to take the 1st, 3rd, 5th and 7th bits to give you the colour information for the first pixel and the 2nd, 4th, 6th and 8th bits for the second pixel. The table below shows what the correct pixel colour information would be for the 4 bit image.

Pixel No.
Bit 3
Bit 2
Bit 1
Bit 0
Colour No.
1
0
1
0
0
4
2
1
0
1
1
11

Now that the colour information is finally being properly decoded here is the Codename: Droid – Stryker’s Run Part 2 title screen again converted properly in all its glory!

Conclusion

And there you have it! I hope that this article fills in some of the gaps that I have found regarding the BBC Micro’s screen format.

If you would like to try out the BBC Micro Image Converter program that I wrote you can download it from my personal website by clicking on the screenshot below:

If you feel that you would like to have a play about with the BBC Micro there are a number of emulators available for numerous platforms including Amiga, Apple Mac, Linux, Windows and handheld systems such as the PlayStation PSP. My personal favourite is one called BeebEm which is freely available and can be obtained by clicking on the screenshot below:

Article copyright © 2006, 2014 Francis G. Loch

Leave a Reply

Homepage of Francis G. Loch's various projects

%d bloggers like this: