class BBS::Petscii::Canvas

The C64 screen as a grid of 40×25 cells in the uppercase/graphics character set, where the card suits, the balls, the rounded corners, the diagonals and the quarter blocks live. It turns into raw PETSCII: the whole screen once (frame), then only what changes (span, patch, update), because a C64 line behind a modem is slow.

It bypasses the PETSCII Encoder of the session, which speaks the lowercase set: send its bytes with session.write_raw. Its constants are the codes of BBS::Petscii as Integers (there they are Strings, for the Encoder): one code table for both.

A cell is drawn by text from a Unicode string: letters, digits and signs as they are (letters in capitals), and the graphics of GLYPHS and GLYPHS_REVERSED by the character they look like. Colours are the codes (GREEN …) or their names in COLOR_NAMES (:green, +‘light grey’+).

canvas = BBS::Petscii::Canvas.new
canvas.text(0, 1, 'TTG CLUBHOUSE', :yellow)
canvas.text(2, 1, '╭──╮', :light_blue)
session.write_raw(canvas.frame)           # the whole screen, once

before = canvas.dup
canvas.text(2, 2, '●', :red)
session.write_raw(canvas.update(before))  # only the changed cell

Byte sizes to aim for on a slow line: a whole screen of art about 1.2 KB, one step of an animation under 200 bytes (update picks the cheaper of a patch and a frame).