Skip to content

BBC escape codes ​

Every escape that can be typed in BBC BASIC source (Micro and Master share the notation), and the byte it stores. Escapes are recognised in string literals, REM and DATA bodies and *-command lines - the contexts where raw bytes live in a real program. On a MODE 7 screen the named teletext escapes are the colour/effect control bytes. Filters can be prefilled with ?q= and ?cat= query parameters.

See also the BBC BASIC reference and file formats.

MODE 7: turn graphics on first ​

A mosaic character is not a shape the teletext chip always draws. Every screen line starts in text mode, and the chip only has seven bits of each stored byte to work with β€” so a mosaic printed with nothing in front of it comes out as the character its low seven bits name. PRINT CHR$(161) on its own gives !, not a block.

What makes it a block is a graphics colour earlier on the same line:

basic
10 MODE 7
20 PRINT "{GRAPHICS WHITE}πŸ¬‚πŸ¬ŽπŸ¬‚"
30 PRINT "{GRAPHICS YELLOW}πŸ¬€πŸ¬πŸ¬‚"

Three things follow from that, and all three bite:

  • It resets every line. A graphics colour holds only to the end of the screen line it is on. The next line starts in text mode again and needs its own.
  • The plain colours turn graphics off. {RED}, {WHITE} and the rest are text colours: they change the colour and go back to letters. Use {GRAPHICS RED} … {GRAPHICS WHITE} to change colour and stay in graphics.
  • A control code takes a character cell, showing as a space. That is what {HOLD GRAPHICS} is for: it repeats the last mosaic under the next control code, so a colour change mid-picture does not punch a hole in it.

The on-screen keyboard's GRAPHICS palette offers the graphics colours ahead of the mosaics for this reason β€” take a colour first, then the shapes.

In the editor these control codes are drawn rather than spelled out: a small box in the colour the code selects, carrying a symbol for what it does β€” a mosaic cell for the graphics colours, an A for the text colours, and a matching mark for the rest. Hover one to see its name and character code. It is only the drawing that changes: the program still holds the escape exactly as written, it still exports byte-for-byte, and one delete removes the whole code.

Description
{0xNN}anyAny raw byte as two hex digits - VDU control codes 0x00–0x1F, delete (0x7F), the unnamed teletext slots (0x80, 0x8E–0x90, 0x9B), the blank mosaic (0xA0) and the top-bit capitals 0xC0–0xDF. The MODE 7 mosaics 0xA1–0xBF and 0xE0–0xFF are written as their block-graphics characters instead, though {0xNN} still loads. Recognised in strings, REM, DATA and *-command lines.
{RED}0x81Teletext: red text from here.
{GREEN}0x82Teletext: green text from here.
{YELLOW}0x83Teletext: yellow text from here.
{BLUE}0x84Teletext: blue text from here.
{MAGENTA}0x85Teletext: magenta text from here.
{CYAN}0x86Teletext: cyan text from here.
{WHITE}0x87Teletext: white text from here.
{FLASH}0x88Teletext: flashing text on.
{STEADY}0x89Teletext: flashing text off.
{END BOX}0x8ATeletext: end of boxed text.
{START BOX}0x8BTeletext: start of boxed text.
{NORMAL HEIGHT}0x8CTeletext: back to single-height text.
{DOUBLE HEIGHT}0x8DTeletext: double-height text (print the line twice). Outside a string 0x8D is the tokenized line-number marker - the context-aware importer keeps the two apart.
{GRAPHICS RED}0x91Teletext: red block graphics from here.
{GRAPHICS GREEN}0x92Teletext: green block graphics from here.
{GRAPHICS YELLOW}0x93Teletext: yellow block graphics from here.
{GRAPHICS BLUE}0x94Teletext: blue block graphics from here.
{GRAPHICS MAGENTA}0x95Teletext: magenta block graphics from here.
{GRAPHICS CYAN}0x96Teletext: cyan block graphics from here.
{GRAPHICS WHITE}0x97Teletext: white block graphics from here.
{CONCEAL}0x98Teletext: conceal text until a colour change.
{CONTIGUOUS}0x99Teletext: contiguous block graphics.
{SEPARATED}0x9ATeletext: separated block graphics.
{BLACK BACKGROUND}0x9CTeletext: black background from here.
{NEW BACKGROUND}0x9DTeletext: current foreground colour becomes the background.
{HOLD GRAPHICS}0x9ETeletext: hold graphics (repeat the last graphics character under controls).
{RELEASE GRAPHICS}0x9FTeletext: release held graphics.

Showing 28 of 28 escape codes

Released under GNU GPL v3.0. Some ROM images are third-party copyrighted works, separate to this project, strictly for personal/educational purposes.