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 ..." ]
}
}
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.
| Machine | Screen | Cell | Model |
|---|---|---|---|
"spectrum" | 32×24 | 8×8 | Per cell |
"c64" | 40×25 | 8×8 | Per cell |
"vga" | 80×25 | 8×16 | Per cell |
"oric" | 40×28 | 6×8 | Inline |
"teletext" | 40×25 | 6×10 | Inline |
Data
The data object carries the machine, mode and screen size, the first character code, and the four lists.
| Field | Type | Description |
|---|---|---|
platform | String | The machine id, for example "spectrum". |
mode | String | The machine's text mode by name, for example "Standard". |
w | Number | The screen width in characters. |
h | Number | The screen height in characters. |
first | Number | The character code of the font's first glyph. A character index i is code point first + i. |
character | Array | The glyph index of each cell. Detailed in Lists below. |
ink | Array | The ink colour of each cell. |
paper | Array | The paper colour of each cell. |
special | Array | The 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.
| List | Entry | Absent |
|---|---|---|
character | The glyph index into the font. | A blank cell, drawn as paper. |
ink | The foreground colour. | The default ink, or on an inline machine the nearest set ink to the left. |
paper | The background colour. | The default paper, or on an inline machine the nearest set paper to the left. |
special | The 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 ]
}