ZX Spectrum – Graphics characters

Overview

The ZX Spectrum had two types of graphics characters; block graphics and user-defined graphics (UDG). The method for entering them into ZX BASIC is the same as that found in the .bas file format created by Paul Dunn for his BASin BASIC IDE.

Block graphics characters can be entered into code with an escape sequence. The \ is used to escape the characters and a combination of the characters : (colon), ‘ (apostrophe) and . (dot) are used to represent the blocks.

So a full solid block would be \:: An “L” shaped block would be \:. and an “r” shaped one would be \:’. The system is fairly intuitive when you see how it works.

To put it another way, a block graphic is an escape ( \ ) followed by two characters. The : represents both top and bottom as ink; ‘ represents top only, and . represents bottom only. A blank space represents both blocks blank or paper.

The complete list of possibilities are as follows:

  •  \·· (Space, Space)             CHR$(128)
  •  \·’ (Space, Apostrophe)        CHR$(129)
  •  \’· (Apostrophe, Space)        CHR$(130)
  •  \” (Apostrophe, Apostrophe)   CHR$(131)
  •  \·. (Space, Period)            CHR$(132)
  •  \·: (Space, Colon)             CHR$(133)
  •  \’. (Apostrophe, Period)       CHR$(134)
  •  \’: (Apostrophe, Period)       CHR$(135)
  •  \.· (Period, Space)            CHR$(136)
  •  \.’ (Period, Apostrophe)       CHR$(137)
  •  \:· (Colon, Space)             CHR$(138)
  •  \:’ (Colon, Apostrophe)        CHR$(139)
  •  \.. (Period, Period)           CHR$(140)
  •  \.: (Period, Colon)            CHR$(141)
  •  \:. (Colon, Period)            CHR$(142)
  •  \:: (Colon, Colon)             CHR$(143)

Other escaped characters

  •  \\ The \ backslash symbol.
  •  \` The £ pound sterling symbol. (Just backtick ` works too)
  •  \#nnn Any character, where nnn is a decimal number in the range 000 to 255.
  •  \* The (C) Copyright Symbol.

(Note: The above was lifted from Wikipedia)

Embedded color control codes

Sometimes, in a program, one might wish to embed colour control codes into strings for printing. This is possible using the same schema as Paul Dunn’s BASIC IDE BASin.

The escape sequences for control characters are as follows:

  • \{iN} Ink colour n, where n is in the range 0 to 8.
  • \{pN} Paper colour n, where n is in the range 0 to 8.
  • \{bN} Bright n, where N is 0 or 1.
  • \{fN} Flash n, where N is 0 or 1.

So, for example, an embedded control code for red ink would be \{i2}. 8 is used to signify “transparent” – i.e. do not change the ink/paper value in the square being printed.

(Note: The above was lifted from the Boriel ZX BASIC Wiki)

User Defined Graphics

Each UDG can be entered into the code with an escape character inserted before the letter that corresponds to the UDG. In all of the listings on this page, you will see them show as ‘\a’ onwards until the letter ‘\u’.

The listings available will either POKE the UDGs into memory using DATA statements – which will consist of BINary data or decimal numbers.

Alternatively they will load in the UDGs from the .TAP/.TZX image. You will need to extract this data if you want to alter anything.

Note: On the Spectrum 128K models, the last two available UDGs (letters ‘\t’ & ‘\u’) were removed to make room for the extra functionality/commands in the ROM. You will need to replace these graphics with a new font which has these graphic alterations within them stored under a not-used-very-often symbol.

Back to ZX Spectrum – BASIC