BBS Terminal Protocol

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

ByteMeaning
0x20 to 0xFFDraw 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.
0x07Bell
0x08Cursor left
0x09Tab to the next multiple of 8
0x0ALine feed; at the bottom of the scroll region the region scrolls up
0x0CClear the screen and home the cursor
0x0DCarriage return
0x1BStarts 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.

CommandArgumentsDoes
Gcol rowMove the cursor
Cfg bgText colors
BcBackdrop (border) color
KClear to end of line
Etop bottomClear rows
Wtop bottomSet the scroll region
Y0 or 1Cursor off or on
Px y cPlot a pixel
Lx1 y1 x2 y2 cLine
Rx y w h cRectangle outline (w 0 = 256)
Fx y w h cFilled rectangle: pixels on in color c
Vx y w h cBackground rectangle: pixels off, strip background c, widened to whole 8 pixel columns
Xx y w hErase rectangle (pixels off)
Ox y r cCircle
Qx y r cFilled circle
Tcol row w h, dataTile image (below)
Dcode, 8 bytesDefine a glyph (bits 7 to 2 are its 6 pixels)
Aid, 32 bytesDefine a 16 x 16 sprite pattern (id 0 to 63)
Sslot x y pattern cShow a sprite (slots 0 to 30)
Mslot x yMove a sprite
HslotHide a sprite
hHide all sprites
Nchannel note lengthPlay a note (channel 0 to 2, note 0 to 71)
ZeffectSound effect: 0 beep, 1 click, 2 chomp, 3 die, 4 win, 5 lose, 6 explosion, 7 coin, 8 alert
UOpen the local program launcher; the client sends ESC when the caller leaves it
rReset 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

Good to know

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.

An unhandled error has occurred. Reload 🗙

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please retry or reload the page.