Wednesday, November 2, 2022

Quest for the perfect VT-100 terminal continues...

The quest for the perfect VT-100 terminal, part 2:  (part 1)

Plotting Maurer Roses in single color using Microsoft BASIC from the late 1970's is interesting to me, but as someone who grew up with 16 color computing in the mid 80's, having access to only a single color crayon (green) just isn't enough.

Enter the ESP32 and FabGL library. 

The ESP32 isn't just a chip.  It's a tiny development board.  Think Raspberry PI Pico, only with a bit more horsepower and wifi/bluetooth capability.   At time of this writing, you can have ESP32 boards delivered from Amazon for about $6.00 a piece, cheaper if you are willing to wait for them from sources like Aliexpress.

The two simple circuits for PS/2 keyboard input and VGA output can be created from resistors you probably already have in your workshop.

 


You will need a PS/2 keyboard, or at least an older USB keyboard which has circuitry which switches to PS/2 given the proper adapter is used.

Not having exactly 400ohm or 800ohm resistors in my shop, (or even anything close) I was able to replicate each the required levels by combining resistors of lower values until I got within 5% or so of target.


Not bad for about an hour of time invested, and less than $8 in parts.

You can bypass the entire process of soldering up your own kit with a ready to use ESP32 board from LILYGO China via Aliexpress.  For around $15 it comes complete with onboard ESP32, PS/2 keyboard, mouse, VGA, audio, and SD card connections.   These work extremely well. One word of caution.  The top silkscreen is backward on the 1.4 version of the board.  Use the silkscreen on the bottom to reference your connections.

The FabGL library (created by Fabrizio Di Vittorio) provides the ESP32 with a powerful library capable of emulating entire computers like the VIC-20, ALTAIR, and even a PC running Microsoft Windows.  For our purposes this library will barely break a sweat by providing us an VT100/ANSI compatible terminal complete with 64 colors.   Connecting your favorite Z80 rig to this solution is a like delivering a postcard with a dump truck, but at the price, why not?

With either of these solutions, you'll need to be comfortable with the Arduino IDE.  Once you have the FabGL library added to your Arduino environment, drill into the program examples, VGA, and load the Ansi Terminal.

As stated earlier, Ansi Terminal is a full fledged VT100/ANSI terminal with a boat load of other features.  It has the ability to also emulate terminal types ADM31, Hazeltine 1500, Osborne, Kaypro, and VT51.  It has over 30 built-in fonts, as well as 9 different video mode resolutions.  Baud rates range from 110 to 2000000.

Once you send this code to your ESP32, and connect the RX/TX lines either directly to your rig or via TTL/Serial interface you are in business.

The FabGL Ansi Terminal scores high on the VTTEST VT100/VT102 Compatibility Test.  Programs like Wordstar run perfectly in  640x350, 80 column mode.

The magic happens in FabGL Specific Terminal Sequences which appear to apply to every video mode.  A few of the highlights are:

  • ESC "_B"                     Set Background Color
  • ESC "_F" column ";" row      Set Cursor position 
  • ESC "_S"                     Play Sound
  • ESC "_GBRUSH"                Set graphics brish color
  • ESC "_GPEN"                  Set pen color
  • ESC "_GPIXEL" X ";" Y        Pixel plot
  • ESC "_GLINE"                 Draw a line
  • ESC "_GRECT"                 Draw a rectangle
  • ESC "_GSPRITESET"            Set sprite position   

 The are commands for reading and setting digital states of the open pins on the ESP32, as well as an ADC.   Using the LILYGO board won't leave you many open pins for electronics experimenting, so if this is your goal, you'll want to roll your own board using the two schematics for VGA output and PS/2 keyboard only.

Mandelbrot in 16 colors
These new graphics commands are accessible via Microsoft BASIC-80, BBC BASIC,PASCAL and even C.   Just use the print command.   

  • 10 PRINT CHR$(27)+"[H"+CHR$(26)+"[J";
  • 20 PRINT CHR$(27)+"_GPEN100;128;100$";
  • 30 PRINT CHR$(27)+"_GPIXEL100;100$";

 With a little more effort, I've plotted 64 color pictures in 512x384.