Bitmap ASCII Characters for the BBC Micro

One of the features that made the BBC Micro such a powerful machine for games programming was the ability to redefine characters and turn text into graphics. Many classic BBC Micro games use custom characters to create sprites, icons and simple animations — all without a dedicated graphics engine.

In this post, you will learn:

  • What ASCII characters are on the BBC Micro
  • How characters are stored as 8×8 bitmaps
  • How the VDU 23 command works
  • How colour is applied to custom characters
  • How to design your own characters using an online tool
  • How to test them in a BBC BASIC emulator

By the end, you will be creating your own sprites using text characters — just like programmers did in the 1980s.

ASCII Characters on the BBC Micro

On the BBC Micro, each character you can print to the screen (letters, numbers, symbols) is represented internally as an 8×8 grid of pixels. Each pixel is either On or Off.

That means every character can be thought of as a tiny bitmap image.

Normally, these characters are built into the system ROM. However, BBC BASIC lets us redefine characters so they display any shape we want. (We will find out how later on in this post)

This is how many games created the different sprites for their games (player sprites, spaceships, enemies, aliens, etc…), all using text mode.

The 8×8 Bitmap Grid

Each character uses and 8×8 grid (8 rows, 8 columns)
Each row is stored as a single number between 0 and 255.

Why 255?
Because each row is actually an 8-bit binary number which is calculated by adding the value of each pixel on the row e.g.

So each one of the 8 rows can be replaced with an 8-bit number (value between 0 and 255):

Redefining Characters with VDU 23

BBC BASIC provides a special command for redefining characters:

VDU 23, character_number, row1, row2, row3, row4, row5, row6, row7, row8

For example:
VDU 23,226,66,36,126,219,189,189,36,102
This tells the BBC Micro to redefine the ASCII character 226, using the eight numbers to describe its pixel rows.

Once defined, the character can be printed like any other:
PRINT CHR$(226)

Applying Colour to Characters

On the BBC Micro, colour is controlled separately from the character bitmap.

In MODE 2, colours are set using control codes from 0 to 7 to access the following colours:

We can can define colours within our code as follows

RED$ = CHR$(17) + CHR$(1)
YELLOW$ = CHR$(17) + CHR$(3)

We can then apply these font colours when printing text or ASCII characters, including our custom made ASCII characters:
PRINT RED$ CHR$(226)
This makes it easy to reuse the same character in different colours.

Online BBC Basic ASCII Character Generator

You can generate your own ASCII characters using our online BBC Basic ASCII Character Generator:

Positioning Characters on the Screen

When writing games, you rarely want your character to appear at the top-left of the screen every time. BBC BASIC provides simple ways to position text characters anywhere on the screen, which works perfectly with custom characters. To do so we will use the TAB(X,Y) function:

RED$ = CHR$(17) + CHR$(1)
PRINT TAB(20,10) RED$ CHR$(226)

When using the TAB() function, BBC BASIC counts the columns and rows from the top-left corner of the screen:

  • X: Column numbers increase from left to right
  • Y: Row numbers increase from top to bottom

Screen Size:
In Mode 2 on the BBC Micro, the screen is configured for 16 colours (The 8 colours describe above using colour codes 0 to 7, and their flashing counterparts colour codes 8 to 15) and has the following text and graphics dimensions:

  • Text Columns: 20 characters per line
  • Text Rows: 32 rows
  • Graphics Resolution: 160 × 256 pixels

Using these dimnesions, here the code needed to place our ASCII character in each of the 4 corners of the screen:

RED$ = CHR$(17) + CHR$(1)
YELLOW$ = CHR$(17) + CHR$(3)
GREEN$ = CHR$(17) + CHR$(2)
BLUE$ = CHR$(17) + CHR$(4)
PRINT TAB(0,0) RED$ CHR$(226)       : REM Top-left corner
PRINT TAB(19,0) YELLOW$ CHR$(226)   : REM Top-right corner
PRINT TAB(0,31) GREEN$ CHR$(226)    : REM Bottom-left corner
PRINT TAB(19,31) BLUE$ CHR$(226)    : REM Bottom-right corner

If you try to print outside this range, the character may wrap around or disappear off screen.

The TAB(X,Y) approach is very useful in video games to position sprites and text on the screen and to implement movements of the different sprites in a frame based game.

You Task: Designing Your Own Characters


Create your own ASCII characters using our online BBC Basic ASCII Character Generator.
Use the auto-generated BBC Basic code and test it using an online BBC Basic Emulator.
Position your characters on the screen using the TAB(X,Y) approach.

Did you like this challenge?

Click on a star to rate it!

Average rating 4.3 / 5. Vote count: 3

No votes so far! Be the first to rate this post.

As you found this challenge interesting...

Follow us on social media!

Tagged with: ,