Monday, December 5, 2022

More Retro Computing fun with ESP32 : Meatloaf

I recently stumbled upon a new project which provides an Internet connected file and BBS interface for the Commodore userport. 


The project I'm talking about is MEATLOAF.

A Commodore IEC serial floppy drive, and Wifi modem multi-device emulator by Jaime Idolpx

If you have experience with pi1514 or other modern wifi adapters, you might write this project off as "Yet another modern drive or modem" replacement for the C64, but it has a feature which is definitely worth a look.   It might even be completely game changing by the time the project is complete.

The idea here is a simple file loading system which uses the Internet itself as the 1541 floppy disk.   Meatloaf allows you to skip the downloading of files to your PC, transfer to a USB device and sneaker-net them to Ultimate/pi1541 device on the C64.  Instead, you can simply LOAD the programs directly from their existing download locations.  

The parts for this project are extremely inexpensive, the basic build uses a $6 ESP32 device from Amazon, and a serial IEC cable to the C64.  (I used a DIN45322(6) connector, only to keep from cutting an IEC cable)   If all you have is a Commodore computer C64,C128,VIC20,C16,PLUS/4, and no other hardware, this simple device will get you loading software.

Don't chuck your pi1541 into the bin yet, this project is in Alpha state.   You will experience bugs and minor flaws.   The project is also not intended to be 1541 exact, so while .prg programs will work (and there are thousands of them out there to keep you occupied) you will probably not be loading any copy protected nibble images any time soon.  (Note: This project is developing quickly.  It's possible that some of this information will be inaccurate by the time you read it.)  If you are like myself and have a little hardware in your parts box and enjoy a challenge to play with up and coming technology for your old computers, then meatloaf.cc wants you to participate.

This blog post is intended to document my own experience with getting a very simple Meatloaf up and running with minimal parts.   I'd also recommend watching a couple videos on getting started with both Visual Studio Code and Platform.IO.   Don't worry, I'm a complete rookie on both, and was able to figure it out enough to be compile and upload Meadloaf.  If you have experience with the Arduino, it's an easy enough jump.

You'll need the following:

This parts list is just enough to get you loading programs from the Internet.  We are skipping the userport connector for now which enables the ability both parallel loading (faster) and TelBBS modem.

The first step is solder up and map our your selected DIN cable or connector.  Here's an image from out on the interwebs that will help you out.

 


There are also a couple helpful images on the Commodore Bus Wiki page.



At the moment you'll need to identify four connections: GND, Clock, Data,  & ATN. These are connections 2,4,5, and 3.   While the image doesn't properly show a cable/pin graphic for male, you'll need to use the reversed pin image on the left if you using a cable.

Next install Visual Studio Code and Platform.IO and watch a couple Youtube videos on them.  Dave's Garage has a video that will teach you enough to be dangerous if you have never worked with them before.

Now that you are an "expert" on those, it's time to download the WS-WROOM-32 version of the Meatloaf software from it's github.   Use the basic instructions on the page itself to get started.

https://github.com/idolpx/meatloaf-specialty

(Note: the /meatloaf-specialty project is the version designed for ESP32.)

Make special note to edit and rename the ssid.h and the platformio.ini files as indicated in the instructions.    I won't show you my own ssid.h which contains my Wifi settings, but you are welcome to use my platformio.ini as a reference. 

 

;FujiNet PlatformIO Project Configuration File
;
;   Build options: build flags, source filter
;   Upload options: custom upload port, speed and extra flags
;   Library options: dependencies, extra library storages
;   Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[fujinet]
; Espressif32 PlatformIO Version to use for building
esp32_platform_version = 5.1.0

build_platform = BUILD_CBM
build_bus      = IEC

; Change this to target hardware you use from the list of [env:xxx] sections below
; Commodore IEC using Atari FujiNet

build_board = meatloaf-fujinet-v1.nopsram  ; Board has no SPI PSRAM


flash_filesystem = FLASH_SPIFFS
;flash_filesystem = FLASH_LITTLEFS
flash_size = 4mb    ; 4mb, 8mb, 16mb

[platformio]
description = Meatloaf / FujiNet retro computer to ESP32 WiFi Multifunction Firmware
default_envs = ${fujinet.build_board}
data_dir = $PROJECT_DIR/data/${fujinet.build_platform}


[env]
; Common settings for all enivornments
framework = espidf
extra_scripts = pre:build_version.py
lib_ldf_mode = deep+
upload_speed = 460800 ;921600

upload_port = /dev/ttyUSB0 ; Linux
;upload_port = COM1 ;Windows
monitor_speed = 460800  ;921600
monitor_port = /dev/ttyUSB0 ; Linux
;upload_port = COM1 ;Windows
monitor_filters = esp32_exception_decoder

build_type = debug
build_flags =
    -D ${fujinet.build_platform}
    -D ${fujinet.flash_filesystem}

    ;-D CMAKE_EXPORT_COMPILE_COMMANDS=ON
    -D DEBUG_SPEED=460800  ;921600
    -D NO_PSRAM            ; if your hardware has no psram
    -D NO_BUTTONS          ; if your hardware has no physical buttons
    ;-D LED_STRIP           ; if your hardware has an led strip
    ;-D PIEZO_BUZZER        ; if your hardware has a piezo buzzer
    ;-D PARALLEL_BUS        ; if your hardware has parallel interface
    ;-D JTAG                ; enable use with JTAG debugger
    ;-D BLUETOOTH_SUPPORT   ; enable BlueTooth support
    ;-D VERBOSE_TNFS        ;
    ;-D VERBOSE_DISK        ;
    ;-D VERBOSE_HTTP        ;
    ;-D DEBUG_TIMING
    -D DATA_STREAM
    ;-D NO_VIRTUAL_KEYBOARD
    ;-D DBUG2               ; enable monitor messages for a release build

;debug_tool = esp-prog
;debug_init_break = tbreak setup


[env:meatloaf-fujinet-v1.nopsram]
platform = espressif32@${fujinet.esp32_platform_version}
board = fujinet-v1-${fujinet.flash_size}
build_type = debug
build_flags = ${env.build_flags}


The changes I made "No Buttons", "No PSRAM", and "Data Stream".  I also deleted a few of the remarked/unused items to streamline the file.   If you have "build_board = meatloaf-fujinet-v1.nopsram  ; Board has no SPI PSRAM" and "flash_size = 4mb    ; 4mb, 8mb, 16mb" then you'll probably be in good shape.

(Note: I've used Linux to compile mine, and the example reflects this.   You should be able to change your upload_port and monitor_port settings for both Windows and MAC compatibility as well.  See the platformio.ini.sample included in the package.)

Next, you'll want to open the pinmap.h located in the projects \include folder.  Make sure the bold line is the selected board.

/* FujiNet Hardware Pin Mapping */
#ifndef PINMAP_H
#define PINMAP_H

//#include "pinmap/fujinet-v1.6.h"
//#include "pinmap/lolin-d32-pro.h"
//#include "pinmap/lolin-s2-mini.h"
#include "pinmap/esp-wroom-32.h"
//#include "pinmap/esp32-a1s-audio-kit-v2.2.h"
//#include "pinmap/esp32s3.h"
//#include "pinmap/fujiapple-rev0.h"
//#include "pinmap/fujiloaf-rev0.h"

#endif

Now open up the esp-wroom-32.h file located in \include\pinmap folder.

You want to remark the line with a couple slashes.  It should read:

// Reset line is available
//#define IEC_HAS_RESET

Toward the bottom of the file you'll find the pin-map connections for your ESP32.

// LOLIN D32 PRO
#define PIN_IEC_RESET           GPIO_NUM_34
#define PIN_IEC_ATN           GPIO_NUM_32
#define PIN_IEC_CLK_IN      GPIO_NUM_23

#define PIN_IEC_CLK_OUT      GPIO_NUM_23
#define PIN_IEC_DATA_IN    GPIO_NUM_25
#define PIN_IEC_DATA_OUT    GPIO_NUM_25
#define PIN_IEC_SRQ               GPIO_NUM_26

Remember that we are only interested in ATN, CLK, DATA, and GND.   You can ignore the others for now.   Make the connections you mapped out to GPIO32, GPIO23, GPIO25, and GND TO GND.

The only speed-bump I ran into with this project was the need to disable "Support for External, SPI connected RAM".  You can do this by using the "Run Menuconfig" option in your programs' Project Task's menu.   The option is located in "Component Config" --> "ESP-32 specific".  Just toggle it off and "S"ave the configuration.

 

Also don't forget to "Upload FileSystem Image" so that the LOAD "$",8 has something to find on your Meatloaf.

Hit the -> button at the bottom of your screen.   If all goes well you will be using the Internet as your 1541.  Connect your Meatloaf device to your Commodore computer and try LOAD "$",8.  Once that works, try LOAD "HTTP://C64.MEATLOAF.CC/GOTD/",8.  This will load Meatloaf.cc's Game of the Day.

Ready to load C64 files from other websites?   Time for the "Send to Meatloaf" plug-in for Firefox, Opera, or Chrome

One you have the plug-in installed, go to a website like CSDb and find the link to a .prg file in the Latest Releases section.   Right-click on the link, and select "Send to Meatloaf".  A screen will open with a Command to use on your Commodore computer to load the file directly.  

On your Commodore computer, type LOAD "ML:*",8,1

If you have made it this far, seriously consider joining the Discord channel for the Meatloaf project.   The channel would love to see your build of the device.   I had some initial difficulty getting things up and running.  Jaime as well as other members were quick to assist.  The more feedback and input on this project will improve the final versions hardware and features.

 

Author's very simple 4 wire Meatloaf on a breadboard.

 










 

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.



Sunday, October 2, 2022

The quest for the perfect VT100 terminal for Retrocomputing CP/M Style

Altair Simulator running CP/M
About two months ago, I assembled my own scratch-build version of the Arduino-Altair Simulator project.   This project replicates the Altair computer, complete with CP/M.

My fabrication skills are somewhat primitive, with the bulk of the build being LEDs and switches attached to a piece of sheet metal, then covered with a laminated printout of the original Altair front panel.  

(Thank you Staples print department!)  

For $270+shipping, you can purchase a very authentic looking version of the same system complete with laser-cut plexiglass case.

The stability of my $125 sheet metal, home-brew version, complete with over 150 plug-in jumper wire connections is a testament to the great design of the project by David Hansel. I've left the unit running CP/M and basic for days on end without a single hiccup.

36 2N222s handing the LEDs

 

In keeping with the spirit of the original Altair computer, instead of using LED driver chips, I created an LED driver board using 36 transistor circuits, as the Arduino Due board is unable to provide the current required by all of the LEDs on the front panel.

The end result of my month long assembly adventure is an Altair that behaves like the original in many ways running in either 8008 or Z80 modes.  It's biggest improvement over the real thing is the ability to store an entire CP/M disk library in a SD card with plenty of room to spare.

CP/M 2.2 with Word Star, Super Calc, and most importantly Microsoft BASIC ready to do my bidding, it was time to read that leaflet in the mailbox on ZORK then jump into some old-school Startrek.

The quest for the perfect VT100 terminal begins:

With the home-brew Altair chugging away happily, it was time to turn my attention to creating a stand alone terminal for it so I could quit using putty from my PC.

Geoff Graham's ASCII Terminal

That lovely kit from adwaterandstir.com comes with a version of Geoff Graham's ASCII terminal built in.  This is a PIC32 solution which provides a reasonable VT100 emulation, outputting TV or VGA in red, blue, or green (color selected by jumper).  

PROs: This solution provides some very nice extended VT100 graphics abilities. (more on this later)

CONs: You have to pick a single color to work with and the font isn't exactly easy on the eyes.   That being said, the project is easy to replicate with schematics, and source code freely available.  

Marco Maccaferri's VT100 Terminal
Alternatively, Marco Maccaferri has created a Parallax Propeller VT100 terminal for the RC2014 project which provides easy to read VGA output in 16 colors.  At first glance this terminal looks complicated with all of the pins connecting to the RC2014 board.  In truth it's a simple circuit requiring only four resistors for the USB circuit, and seven resistors for the VGA circuit.  If you wanted to roll you own easily, you could purchase a Protoboard from Parallax, a VGA connector and dig out a USB connector for the keyboard from your junkbox and you are in business.  Once again the schematics, and source code are freely available.  

PROs: This solution are a VT100 terminal which is easy to read, and looks great when surfing ANSI BBS systems from your CP/M box.  The 

CONs: It's very much limited to the VT100 standard.  Outside of the ANSI color characters, graphics are off the table.

Why not have your cake and eat it too?

16 ANSI compatible colors!
Adventuring where no one has gone before and trying to remember how to get the Bablefish into my ear, the Maccaferri's Propeller based VT100 terminal really shines.   I cut my teeth decades ago in MS-DOS and even booting into CP/M, this terminal will makes me feel right at home.

I know.  In the 70's and early 80's, CP/M terminals were usually only GREEN or AMBER.

The VT100 emulation is spot-on even with the more picky applications like Word Star displaying perfectly.

With a little ROGUE-VT under my belt, it was time to turn my attention to some old-school Microsoft BASIC programming.

 

Geoff Graham's ASCII terminal while being single color like those early terminals of the 70's provides an interesting twist:

Archimedes spiral?
It has a handful of special <ESC>Z commands added to the VT100 emulation which permit LINES, CIRCLES, and BOXES to by plotted on the screen.   In addition, if you upgrade the board with a firmware from David Hansel, the USB port on the original design is capable of handling a USB keyboard.   Push the firmware even further with another firmware update from John Galt, you add even more functionality to it's <ESC>Z commands with a PLOT command as well as several erase commands.

At the end of the day, for me me the answer was, 

"Why not have both?"

A Maurer rose
My home-brew Altair has TTL RX/TX lines running to my Propeller terminal with a 14" Dell VGA monitor rendering those lines of Vogon Poetry from Hitchhiker's Guide.  I've split off an additional TX line into the Geoff Graham solution connected to a small 7" VGA monitor I bought off Aliexpress a while back.  This monitor sits happily above the project itself and provides a second-screen solution happy rendering old fashion line graphics from Microsoft BASIC programs

 

At the end of the day, my multi-monitor Altair Simulator has all the switches, blinky lights, and feel of the original Altair, but all the comforts of home.