
BBS Terminal Protocol
Overview
This page is for developers who want to write a BBS client for another computer, or understand what the NABU terminal does. The board speaks plain TCP on cloud.nabu.ca port 6502. A client that sends the handshake below gets the graphics protocol; anything else gets ANSI text with telnet negotiation.
The screen is the TMS9918 Graphics II bitmap: 256 x 192 pixels, colors 0 to 15 (0 = transparent, showing the backdrop), with a 40 x 24 text layer drawn in a 6 x 8 font. Text column c starts at pixel x = 8 + 6c, row r at y = 8r. Pictures are placed on the 8 x 8 tile grid (32 x 24 tiles).
Handshake
Right after connecting, the client sends 8 bytes: ESC ! N A B U, then a protocol version byte (currently 1) and a flags byte (0). The board waits up to 1.5 seconds for it.
Text and controls
| Byte | Meaning |
|---|---|
0x20 to 0xFF | Draw that glyph at the cursor. 0x80 to 0xAC are built-in box lines, blocks, shades, card suits, dots, arrows, a degree sign, double lines, check and cross marks, triangles and a star. Codes from 0xB0 up are free for games to define. |
0x07 | Bell |
0x08 | Cursor left |
0x09 | Tab to the next multiple of 8 |
0x0A | Line feed; at the bottom of the scroll region the region scrolls up |
0x0C | Clear the screen and home the cursor |
0x0D | Carriage return |
0x1B | Starts a command (below) |
Printing in column 40 leaves the cursor waiting; the next printable character wraps first (like a VT100).
Commands
ESC, a command letter, then a fixed number of raw argument bytes.
| Command | Arguments | Does |
|---|---|---|
G | col row | Move the cursor |
C | fg bg | Text colors |
B | c | Backdrop (border) color |
K | Clear to end of line | |
E | top bottom | Clear rows |
W | top bottom | Set the scroll region |
Y | 0 or 1 | Cursor off or on |
P | x y c | Plot a pixel |
L | x1 y1 x2 y2 c | Line |
R | x y w h c | Rectangle outline (w 0 = 256) |
F | x y w h c | Filled rectangle: pixels on in color c |
V | x y w h c | Background rectangle: pixels off, strip background c, widened to whole 8 pixel columns |
X | x y w h | Erase rectangle (pixels off) |
O | x y r c | Circle |
Q | x y r c | Filled circle |
T | col row w h, data | Tile image (below) |
D | code, 8 bytes | Define a glyph (bits 7 to 2 are its 6 pixels) |
A | id, 32 bytes | Define a 16 x 16 sprite pattern (id 0 to 63) |
S | slot x y pattern c | Show a sprite (slots 0 to 30) |
M | slot x y | Move a sprite |
H | slot | Hide a sprite |
h | Hide all sprites | |
N | channel note length | Play a note (channel 0 to 2, note 0 to 71) |
Z | effect | Sound effect: 0 beep, 1 click, 2 chomp, 3 die, 4 win, 5 lose, 6 explosion, 7 coin, 8 alert |
U | Open the local program launcher; the client sends ESC when the caller leaves it | |
r | Reset the terminal |
Tile images
ESC T col row w h places a picture w x h tiles big with its top left tile at col, row. A run-length coded stream follows. Decoded, it holds for each tile row w x 8 pattern bytes and then w x 8 color bytes, in TMS9918 order (tile by tile, 8 rows each). A pattern byte's bit 7 is the leftmost pixel; a color byte is (foreground << 4) | background. A full 32 x 24 picture is exactly an SC2 screen.
Run-length coding: a byte n below 0x80 is followed by n + 1 literal bytes; a byte n of 0x80 or more is followed by one byte that repeats (n & 0x7F) + 3 times.
Keys from the client
Send key presses as ASCII. RETURN is 0x0D, backspace 0x08, ESC 0x1B. Arrows are ESC [ A (up), ESC [ B (down), ESC [ C (right), ESC [ D (left); joystick fire is ESC [ F.
Color strips
Each 8 x 1 pixel strip of the bitmap has one foreground and one background color. F turns pixels on, so drawing over a filled area in another color recolors the whole strip. To draw on a colored panel, paint it with V first: lines, circles and text drawn over it keep the panel color behind them.