Sprites Text Media Storage

A text screen lives in the data store as one record with two fields: its id and a data object. The metadata is the meta record beside it under the same id. The data object holds the screen: its machine, mode and size, and four flat lists over the cells, character, ink, paper and special. The screen draws from a font, kept apart as a font record; the screen stores a character index per cell, not the glyph.

{
  "id": "7c1b90a34e6d41f0a2b8c5e7d9f01234",
  "data": {
    "platform": "spectrum",
    "mode": "Standard",
    "w": 32,
    "h": 24,
    "first": 32,
    "character": [ "... 768 glyph indices ..." ],
    "ink": [ "... 768 colours or nulls ..." ],
    "paper": [ "... 768 colours or nulls ..." ],
    "special": [ "... 768 flags or nulls ..." ]
  }
}
The whole data record: the id and the data object. The four lists each hold w times h entries in row order.

Two attribute models

The machines split by how they colour a cell. A per cell machine gives each cell its own ink and paper. An inline machine lets an attribute take a whole cell and hold along the row until another overrides it, so a cell reads the nearest set value to its left. The stored lists are the same shape for both; the model lives on the machine's text page and decides how a reader resolves an absent cell.

MachineScreenCellModel
"spectrum"32×248×8Per cell
"c64"40×258×8Per cell
"vga"80×258×16Per cell
"oric"40×286×8Inline
"teletext"40×256×10Inline

Data

The data object carries the machine, mode and screen size, the first character code, and the four lists.

FieldTypeDescription
platformStringThe machine id, for example "spectrum".
modeStringThe machine's text mode by name, for example "Standard".
wNumberThe screen width in characters.
hNumberThe screen height in characters.
firstNumberThe character code of the font's first glyph. A character index i is code point first + i.
characterArrayThe glyph index of each cell. Detailed in Lists below.
inkArrayThe ink colour of each cell.
paperArrayThe paper colour of each cell.
specialArrayThe special attribute flags of each cell.

Lists

Each of character, ink, paper and special is a flat list of w times h entries in row order. The entry for the cell at column c, row r is at index r × w + c. An entry is one integer, or absent.

ListEntryAbsent
characterThe glyph index into the font.A blank cell, drawn as paper.
inkThe foreground colour.The default ink, or on an inline machine the nearest set ink to the left.
paperThe background colour.The default paper, or on an inline machine the nearest set paper to the left.
specialThe machine's special flags, flashing, double height, alternate set.No special attribute.

An absent entry is undefined in the running editor, written as null in JSON.

Colour encoding

An ink or paper entry is one integer. On an indexed machine it is the index of a colour in the machine's palette, kept on the machine's text page. On a free machine it is a 32 bit RGBA colour packed into one integer, as for a freeform image cell. The screen names its machine in platform, so a reader knows which to expect.

Full example

A tiny 2×1 Spectrum screen: the letter A on cell 0 in black ink on white paper, a blank cell 1. Codes count from first, so the letter A, code 65, is index 33.

{
  "platform": "spectrum",
  "mode": "Standard",
  "w": 2,
  "h": 1,
  "first": 32,
  "character": [ 33, null ],
  "ink": [ 0, null ],
  "paper": [ 7, null ],
  "special": [ null, null ]
}
Cell 0 holds glyph 33 with ink 0 and paper 7, the Spectrum's black and white. Cell 1 is blank and reads the default colours.