Thursday, May 16, 2019

Node-M Terminal Emulator for C128

Node-M is a custom terminal emulator program I created so I could work on my university Computer Information Science assignments from home over 2400 baud modem with my Commodore 128, about 30 years ago 1988-1989.  This article documents the solution, the ADM31 comparable emulation, and provides C128 disk image and UNIX/Linux support files (link to ZIP file).  Source file is included using The Fast Assembler (also source listing).

My favorite features were color, secondary composite graphics screen, full screen editing support (for me that was vi), full ASCII character set (backslash, backquote, caret, curly braces, vertical bar, underscore, tilde), keyboard support, printer support, and interlaced 80-column x 50-line mode (sorry not shown, doesn't work well in VICE).  Notable missing features are flow control and file transfer.








Keyboard changes for ASCII
  • Commodore+Q is Left Brace {
  • Commodore+W is Right Brace }
  • Commodore+E is Tilde ~
  • Commodore+R is Backquote `
  • Commodore Minus is Vertical Bar |
  • British Pound is Backslash \
  • Up Arrow is Caret (Hat) ^
  • Left Arrow is Underscore _

ADM31 terminal emulation, with additions/variations
  • {Ctrl+?} 127 DEL
  • {Ctrl+G} 7 BELL
  • {Ctrl+H} 8 RIGHT
  • {Ctrl+I} 9 TAB
  • {Ctrl+J} 10 LINEFEED
  • {Ctrl+K} 11 UP
  • {Ctrl+L} 12 RIGHT
  • {Ctrl+M} 13 CARRIAGE RETURN
  • {Ctrl+W} 23 CLEAR TO END OF SCREEN
  • {Ctrl+X} 24 CLEAR TO END OF LINE
  • {Ctrl+^} 30 HOME
  • {Ctrl+Z} 26 CLEAR SCREEN / HOME
  • {Ctrl+[} 27 ESC
  • ESC t CLEAR TO END OF LINE (ESC T)
  • ESC y CLEAR TO END OF SCREEN (ESC Y)
  • ESC : CLEAR SCREEN / HOME (ESC *)
  • ESC ) HALF INTENSITY ON
  • ESC ( HALF INTENSITY OFF
  • ESC G 0 CLEAR ATTRIBUTES
  • ESC G 1 ALTERNATE CHARACTER SET ATTRIBUTE
  • ESC G 2 FLASH ATTRIBUTE
  • ESC G 3 UNDERLINE ATTRIBUTE
  • ESC G 4 REVERSE ATTRIBUTE
  • ESC H 2 4 INIT SCREEN 24 LINES
  • ESC H 5 0 INIT SCREEN 50 LINES
  • ESC ESC ESC {32 TO 47} FOREGROUND SCREEN COLOR 0-15
    {space}black !dkgray “blue #ltblue $green %ltgreen &dkcyan 'cyan (red )ltred *dkpurple +purple \dkyellow -yellow ^medgray _white
  • ESC ESC ESC {48 TO 63 or 96 TO 111} BACKGROUND CHARACTER COLOR 0-15
    0black 1dkgray 2blue 3ltblue 4green 5ltgreen 6dkcyan 7cyan 8red 9ltred ;dkpurple :purple <dkyellow =yellow >medgray ?white
    `-black a-dkgray b-blue c-ltblue d-green e-ltgreen f-dkcyan g-cyan h-red i-ltred j-dkpurple k-purple l-dkyellow m-yellow n-medgray o-white
  • ESC = {32 TO 55/81} {32 TO 111} MOVE CURSOR TO ROW (0-23 or 0-49), COLUMN (0-79)
  • ESC E INSERT LINE
  • ESC Q INSERT CHARACTER
  • ESC R DELETE LINE
  • ESC W DELETE CHARACTER
  • ESC L {64 TO 79} {64 TO 79} {64 TO 79} {64 TO 79} PIXEL POSITION XH XL YH YL (X=0 TO 319, Y=0 TO 199), SAVE OLD X,Y
  • ESC M {EVEN/ODD} PIXEL COLOR (0=BACKGROUND, 1=FOREGROUND)
  • ESC P PLOT AT PIXEL POSITION
  • ESC D DRAW LINE BETWEEN OLD AND CURRENT PIXEL POSITION
  • ESC C CLEAR GRAPHIC SCREEN
  • ESC < SLOW, ENABLE GRAPHIC SCREEN
  • ESC > FAST, DISABLE GRAPHIC SCREEN
  • ESC F FILL AT PIXEL POSITION
  • ESC B CLEAR GRAPHIC BLOCK (RECTANGLE DEFINED BY OLD AND CURRENT PIXEL POSITION)
Note: running the C128 in emulation I couldn't quite get the terminal to talk over TCP/IP serial emulation directly to my Linux telnet service, so I ran a shell script in between to do a conversion (from some hints on stack overflow):

#!/bin/sh
mkfifo temp
while true; do nc -l 127.0.0.1 23 < temp | dd bs=1 | nc -t 192.168.56.101 23 | dd bs=1 > temp ; done


Monday, May 6, 2019

40 column RGB screen for Commodore 64 mode on 128

RGB64 is a solution for a problem almost no one has -- use the C128 RGBI screen for C64 mode text programs and editing in 40 columns!  Now you can go back to using one monitor for both, and without using a hardware switch.  Well, as long as you're not using any graphics or pokes to video memory.   If you are editing or running a simple text BASIC program, you can use RGB64 to mirror your screen between both monitors.  As a bonus, you can run in fast mode 2MHz, because the RGBI screen runs independently from the VIC that could only access video memory at 1MHz.  Another bonus is that the extra keys of the C128 keyboard are supported as well.




Your Commodore 128 has an 80-column RGBI screen, and a 40-column Composite screen.  One of the original dual monitor systems!   So you probably prefer the RGBI screen for the C128 mode, and you're usually stuck using composite output (or worse, TV signal) for the C64 mode.  And that means you gotta have one or more monitors that support both.   Well not anymore!   You can now downscale your 80-column monitor to 40-columns for simple Commodore 64 programs.

How does it work?  It copies the C64 ROMs to RAM, and patches them to include routines to initialize and update the RGBI screen with a 40 column image matching the text output to the VIC screen.  It also copies the C64 character ROMs to 8563 VDC RAM.  Then switches to C64 mode.  No going back until you press the Reset switch.

So maybe you didn't know the 8563 VDC could do 40 columns, because hey, it was included in the Commodore 128 to do 80 columns.  Well, you know it can do graphics, and interlaced modes for higher resolutions.  Did you know it can do 50 lines of text?  Did you know it can do 8x16 pixel characters as well?  In addition to all that, it can also double the width of the pixels, so presto, with a few more adjustments it can also do 40 columns instead of 80.

KEYBOARD SUPPORT

  • HELP will copy the VIC Composite screen to the VDC RGBI screen (in case of pokes)
  • ALT will toggle Fast mode (2MHz)
  • C128 extended keys are supported including dedicated cursor keys and numeric keypad, even CAPS LOCK

WARNINGS (Sorry the lawyers in my head make me put these in)

  • Warning!  This code has been tested solely on a NTSC C128D 8563 rev2, and with VICE 3.3.  PAL, rev0, and rev1 chips may not be supported.  I didn't even test with a true Commodore monitor, but a compatible (Thomson 4120 switchable RGBI/Luma+Chroma).
  • Warning! I haven't tested on a real Commodore 128 since 1990 or so.  (But it's only 8 feet away from me, I guess I could plug it in again, but that requires effort.)
  • Warning! And I will not be responsible if this program kills your monitor.  Gee I sure hope it doesn't.
  • Warning! All the ROMs (BASIC and KERNAL) are now in RAM.  One wrong poke, and poof system locks up or worse.   Then again, it's a fun environment to hack the ROMs with.
  • Warning! Uses $991C-$99D2 for RGB64 machine language component.
  • Warning! RGB64 is probably not compatible with the other software you use.
  • Recommend you try RGB64 in Vice (emulation).  Emulation should be easier on your monitor.  And if it doesn't work, those bits can simply be recycled into something else.
The reason I built this was that about 30 years ago my monitor was on the fritz, I sent it for repair, and had no good composite monitor.  I did have an amber monochrome monitor.  My development system relied on The Fast Assembler (Thanks Yves Han!) which ran in C64 mode, so only 40-column mode.  I had been using the 50 line mode of the VDC 8563 and in messing around with the settings, found the 40 column mode too.   Turned out the monitor had an extra circuit board with edge connector that came loose and only needed to be re-plugged into the main circuit board, so the need for this utility was short lived.  But I got a kick out of writing it, and wanted to share it.

The code is mostly original from about 30 years ago except for some updates today to carve my name in it  with URL.  Gotta take credit for the hard work, right?  

Where the magic happened -- my Computer Workstation
Links:
RGB64 Disk image (.D64), mount and type: RUN"RGB" from C128
Source Disk image (.D64) including The Fast Assembler plus ScrollEdit with RGB64 patches.
RGB64 Decompilation, Annotated (.PDF)
Hackaday posted a short article about this project!