GGLABS Terminal V0.12f

Submitted by GG on Tue, 12/17/2019 - 18:27

A new version of GTERM is available here

GTERMGTERM is a newly developed VT100 terminal emulator for the Commodore 64. GTERM supports the GLINK232/swiftlink and the GLINK232T/Turbo232 UART cartridges. It features a custom monochrome software 80 columns display and supports serial speeds up to 115200 bauds on a stock c64.

Design Goals

  • Support for the GGLABS GLINK232 and GLINK232T cartridges
  • compact code that can fit in a standard 16K cartridge
  • reasonably large subset of VT100 features to be useful
  • optimized for speed (mixed C and assembly)

VT100 Emulation

GTERM VT100 emulation aims to be as complete as possible in order to be useful.
A few features are not implemented because of the hardware limitations or the rare use of the features.
The known missing features are listed below:

  • Missing 132 column support (the C64 hardware is not capable of a legible 132 column display)
  • Missing support for double wide and double height characters. This could be implemented but I have not seen any software that uses this feature. (MATE term also seems to not implement this feature)
  • VT52 emulation
  • Request Terminal Parameters Feature (planned for a future version)
  • bold is ignored (not possible with 3 pixel wide characters)
  • blink is also ignored (possible but requires a character attributes buffer which is not implemented by design)

The GTERM VT100 emulation has been extensively tested using vttest 2.7.
All 80 columns test pass without any issues. There are some graphical glitches in dselect and nano.

Test Program Rating Notes
vttest 2.7 A- All 80 Columns test pass. two spurious characters in font test
nano C Seems to work fine. Spurious characters if cursor keys are pressed while the display is scrolling
emacs A  
dselect B- Screen corruption when scrolling package list backwards. Seems related to RI code.
top A  
htop A  

Soft-80 Implementation

To maximize speed the GTERM soft-80 implementation is monochrome only. There is no ASCII screen buffer. The character set was drawn using vchar64 exported as a bin file and then reordered with a custom utility to improve the character drawing performance.
A few important functions have special case implementation for common cases. I.e. character drawing in pairs, scrolling and clearing the entire screen.

For more information about various soft-80 implementations check out the article on and the cc65 soft-80 driver source.

Support for 115200 baud

Receiving data with a Turbo232 at 115200 is quite challenging on a stock c64. The 6551 ACIA has only a one byte receive buffer (no FIFO). The CPU must respond and complete the ISR within one byte time (~86uS which on the c64 is 1MHz is approximately 86 cycles). The ISR is 69 cycles + the NMI entry latency. This is just enough to receive the characters during a normal scanline. Unfortunately when a bad line occurs the CPU is stopped for 40 cycles and there is a high probability to overrun the single byte buffer of the 6551.

pha ; 3
tya ; 2
pha ; 3
ldy _put ; 3
;; receive a char
lda ACIA_DATA ; 4
sta _SER_BUF,y ; 4
iny ; 2
sty _put ; 3
;; check for buffer full
;; clc ; 2 - this is not exact as it might be 1 off but it's 2 cycles faster
tya ; 2
sbc _get ; 3
cmp #$F0 ; 2
bpl end_nmi ; 2-4
;; clear RTS
lda #$01 ; 2
lda #$05 ; 2
sta _SCR_BASE-$400+38 ; 4
pla ; 4
tay ; 2
pla ; 4
rti ; 6

The interrupt code above is used for all speeds up to 57600. At 115200 the ACIA interrupt is disabled and a the incoming characters are received using a very tight polling loop.
;; read loop
;; 23-24 cycles for 1 char receive
and #$08 ; 2
beq no_recv ; 2-4
;; receive a char
lda ACIA_DATA ; 4
sta _SER_BUF,y ; 4
iny ; 2
dex ; 2
bne loop ; 2-4

To keep the loop as short as possible the buffer check is done outside the loop. Using this code GTERM can reliably receive at 115200. Actual speed however is usually limited by the speed of screen updates.

Attachment Size
gterm-0.12f_bin.tar.gz 10.74 KB
gterm-0.12f_src.tar.gz 30.28 KB
Filed under