MatrixDisplay

Inputs

PinTypeDescription
DevAddrbus8Device address — 0x1C sets X, 0x1D sets Y, 0x1F sets pixel value
DataInbus8Data — X coordinate, Y coordinate, or pixel value (1 = on, 0 = off)
WEbitWrite enable — must be 1 to write a pixel
IO_SELbitI/O select — must be 1 to activate the display

Outputs

PinTypeDescription

This element has no outputs.

How It Works

The MatrixDisplay is a sheet of graph paper turned into a screen: a matrix of little squares where every square is a separate pixel. You draw the same way you would with a pencil on a grid, only instead of strokes there are writes to I/O ports. Name the device address, the coordinate and what to draw — and a point lights up on the screen.

The key property: any pixel is turned on with three writes. First the X coordinate goes to port 0xFC (DevAddr = 0x1C), then the Y coordinate to port 0xFD (DevAddr = 0x1D), and finally the value to port 0xFF: 1 to light, 0 to clear (DevAddr = 0x1F). Want a dot at (7, 3)? Write 7, then 3, then 1 — one byte per step, using ordinary STA instructions.

Nuances: coordinates run from 0 to 15, and point (0, 0) is the top-left corner of the screen. A pixel changes only during an active write: WE = 1 and IO_SEL = 1. The picture, however, persists between ticks — there is no need to redraw the screen every step. Clearing everything means writing 0 into every pixel.

Examples

ActionWrite to 0xFC (X)Write to 0xFD (Y)Write to 0xFF (pixel)Result
Light up (7, 3)731Pixel at column 7, row 3
Clear (7, 3)730Pixel goes dark
Light corner (0, 0)001Top-left corner
Light corner (15, 15)15151Bottom-right corner

The row order in the table is the protocol itself: coordinates first, value last. The steps cannot be swapped — the display remembers X and Y one after the other.

Usage

The MatrixDisplay is the computer's main graphics device: level 24 (a manual pixel), 27 (working with ports), 28 (a moving dot) and 29 (Snake). In the snake game the screen is the playing field: the program keeps coordinates in RAM and redraws the snake and the food pixel by pixel, checking collisions by comparing coordinates.

A concrete trick — animation: to make a dot "move", the program clears the old pixel (a 0 write), shifts the coordinate by one and lights the new one (a 1 write) — all inside a loop between clock ticks. Text and symbols are drawn the same way: every letter is a set of pixels that the program plots dot by dot.

Build it yourself →

Related components

Related articles

Frequently Asked Questions

How do you light a single pixel?

Write the X coordinate byte to one port, Y to another and 1 to the pixel port — all via OUT instructions.

What happens when writing coordinates outside 0–15?

Such a write is simply ignored: the pixel stays unchanged. Check the coordinate bounds in your program before plotting.

How do you clear the whole screen?

Write 0 into each of the 256 pixels: a loop over Y with a nested loop over X, writing zero to the pixel port on every iteration.