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!

Thursday, April 25, 2019

C64: Scrolling Editor for The Fast Assembler, 31 years late

Starting just today you can write Commodore 64 assembly language programs compiled for 6502 with The Fast Assembler and scroll up and down through them with just a touch of a function key. No more need to rely solely on the LIST keyword.  This tool has been available for BASIC programmers for quite a while.  But now it is also available for 6502 assembly language programmers too.






Key Description
F1 Scroll up
F3 Beginning of line
F5 End of line
F7 Scroll down
Ctrl+Down Bottom of screen
Ctrl+Ins Insert Line
Ctrl+Shift+Commodore Renumber lines
Ctrl+Return Toggle Scroll Edit Keys On/Off
Stop+Restore Restore screen and program (unnew)

I wrote the scrolling extension for The Fast Assembler way back in the summer of 1987 and submitted it to Compute! magazine for publishing.  Yet only my Scrolling BASIC Editor for Commodore 64 was published in their magazine and distributed on their floppy disk.  No one had seen the extension version since and the code has been sitting dormant in storage for a long time.

Yves Han wrote The Fast Assembler and it was published in January 1986 Compute!'s Gazette.  When I went about to write the original Scrolling BASIC Editor, I used The Fast Assembler to write the source code and assemble into machine code.  I felt this was the perfect tool for writing machine language programs, so I proceeded to integrate it into his solution as well.

Also added to The Fast Assembler with this extension are low byte < and high byte > operators similar to one or more assemblers of the era.

Fast forward over 31 years to today when writing this article, and I've got the retro hardware bug and retrieved the data from some of my old Commodore floppy disks using ZoomFloppy.   Add in a dash of Commodore emulators, archived magazines and disks, blogs, and electronic mail, and we've got new interest, and new means of self publishing and distributing information.  And I just recently changed my credits to my website URL (no we did not have those prior to 1990), otherwise no logic was changed in the last many decades.

Thanks to Tiaan Geldenhuys I saw this great blog post about The Fast Assembler.  Also thanks to email I was able to contact Yves Han, the author of The Fast Assembler.

Below are some resources.  Recommend you grab the floppy disk images instead of typing in the programs from the magazines.  The integrated version is available ready to use as FA+SCRLEDIT.



If you want to recreate from source you can because all source is available.  And/or if you wish to create the patched integration from compiled versions, instructions can be listed from  README.BASIC.


These are links:
• SCRLEDIT extension for The Fast Assembler C64 Disk Image (FA+SCRLEDIT) [1987, 2019]
• Compute's Gazette January 1988 Scrolling BASIC Editor Article
• Compute's Gazette January 1988 Floppy Disk Image (SCROLLEDIT) [BASIC]
• Compute's Gazette January 1986 Floppy Disk Image (ASSEMBLER) [original]