GPU

Frames are displayed by periodically reading the VRAM and translating said VRAM into pixels.

The screen resolution is 640x480. Each pixel takes up 4 bits of VRAM, so VRAM is 153 600 bytes in size.

The MFS-16 has a display of 16 colours. Each pixel's 4 bits in VRAM denotes which palette colour that pixel is.

0x0 is the conventional background colour, and 0xF is the conventional foreground colour.

The 16 colours can be anything, but by convention they map to the 16 standard ANSI terminal colours:

Default Colours

The default MFS-16 palette.

VRAM Pixel ValueANSI Colour
0x0Black
0x1Red
0x2Green
0x3Yellow
0x4Blue
0x5Magenta
0x6Cyan
0x7White
0x8Bright Black
0x9Bright Red
0xABright Green
0xBBright Yellow
0xCBright Blue
0xDBright Magenta
0xEBright Cyan
0xFBright White

Since the VRAM bytes are processed sequentially by the screen, and words are written to memory in little-endian form, programs must account for the little-endian ordering when writing data to VRAM.

For example, to write the first 8 colours in the above table ordered left-to-right horizontally (i.e., black, red, green, ... cyan, white), the following instructions could be executed:

// Note the order of the nibbles!
// This will be written to VRAM as [0x01, 0x23, 0x45, 0x67].
LD BC, 0x67_45_23_01:d;
VLD [DE], BC;