[net.sources] vt52 emulator for c128 sources

grwalter@watmath.UUCP (Fred Walter) (01/12/87)

this is the sources for a vt52 emulator for the c128. it was originally
written for the c64 by frank prindle and was converted to the c128 by me.
read 128.doc.
-----------------cut line------------------------------------------------
# This is a shell archive.  Remove anything before this line,
# then unpack it by saving it in a file and typing "sh file".
#
# Wrapped by watmath!grwalter on Sun Jan  4 17:41:10 EST 1987
# Contents:  128.1 128.2 128.doc 128.lables 128.tables
 
echo x - 128.1
sed 's/^@//' > "128.1" <<'@//E*O*F 128.1//'
  100 ;
  110 ; term.plus.128.1
  120 ;
  130 ; last date 870104
  140 ;
  150 ;various scaler variables
  160 char .byte 0 ; character just read
  170 stat .byte 0 ; rs-232 status byte
  180 ndig .byte 0 ; digit counter for downline load
  190 loopcnt .byte 0 ; cursor blink counter
  200 loopmax .byte $00 ; cursor blink loop reset value
  210 control .byte $00 ; rs-232 control reg (1200 baud default)
  220 command .byte $00 ; rs-232 command reg
  230 optbdlo .byte $3c ; kluge value for 1200 baud
  240 optbdhi .byte $01 ; kluge value for 1200 baud
  250 escflag .byte 0 ; escape sequence flag/counter
  260 xcoord .byte 0 ; temp storage for x screen coordinate
  270 ycoord .byte 0 ; temp storage for y screen coordinate
  280 revmask .byte $0 ; reverse video mask ($f=reverse, $0=normal)
  290 cflag .byte $ff ; zero if char under cursor has been reversed
  300 cstate .byte $0 ; top nibble of char under cursor if cflag=0
  310 suspend .byte $0 ; rs-232 reads suspended if non-zero
  320 fxoff .byte $0 ; xoff has been sent if non-zero
  330 commflg .byte $0 ; non-zero if commodore key is depressed
  340 savex .byte 0 ; temp storage for chrout80 subroutine
  350 ;
  360 ; terminal emulator main program
  370 ;
  380 init jsr chrset80 ; set up new characters
  390 jsr openrs ; open rs-232 channel
  400 ldy #0 ; print welcome message
  410 welcome lda welmsg,y
  420 beq tloop
  430 jsr chrout
  440 iny
  450 jmp welcome
  460 ;
  470 welmsg .asc "[HOME][HOME][CLR][ENABLE_CASE_SWITCH][LOWER/UPPER_CASE_MODE][TAB][TAB][TAB]   TERM.PLUS.128"
  480 .byte cr,cr,0
  490 ;
  500 tloop lda ndx ; main terminal loop begins
  510 bne kbd ; keyboard has priority over rs-232
  520 jsr flowcon ; do rs-232 flow control if necessary
  530 jsr getrs ; get an rs-232 byte
  540 bne kbd ; if none available, go check keyboard
  550 jsr unblink ; restore character under cursor
  560 lda escflag ; escape sequence activeprint
  570 beq normal ; no
  580 jsr escseq ; yes - process escape seq.
  590 clc ; then skip printing char
  600 bcc nospec
  610 normal ldx char ; get ascii character read
  620 lda from,x ; get equivalent c128 character to print
  630 jsr chrout ; print it on screen
  640 ldx char ; get ascii again
  650 lda from,x ; get c128 again
  660 cmp #$01 ; code 1 characters are special
  670 bne nospec ; skip if not special
  680 jsr special ; process special rs-232 characters
  690 nospec jsr cleanup ; clean up after print
  700 clc ; repeat
  710 bcc tloop ; main loop
  720 ;
  730 kbd jsr getkb ; get a keyboard byte
  740 beq cursor ; if none available, go generate cursor
  750 ldx #5 ; change kernel output
  760 jsr chkout ; to rs-232
  770 jsr optimum ; wait for optimum time to do rs-232 out
  780 ldx char ; get c128 character read
  790 lda to,x ; get equivalent ascii character to send
  800 jsr chrout ; send it to rs-232
  810 ldx #0 ; return kernel output
  820 jsr chkout ; to screen
  830 cursor jsr docurs ; blink cursor position
  840 clc ; repeat
  850 bcc tloop ; main loop
  860 ;
  870 ; subroutine - open rs-232 as logical device 5
  880 ;
  890 openrs lda #4 ; pass rs-232 parameters as "filename"
  900 ldx #<control
  910 ldy #>control
  920 jsr setnam
  930 lda #5 ; equate logical unit 5 to physical 2 (rs-232)
  940 ldx #2
  950 ldy #0
  960 jsr setlfs
  970 jsr open ; do the open
  980 rts
  990 ;
 1000 ; subroutine - set up the new character codes in the 80 column mode
 1010 ;
 1020 c = $3000 ; base address of lower/upper character set
 1030 ;
 1040 chrset80 ldy #8-1
 1050 ;
 1060 putchr tya ; get character address
 1070 asl
 1080 tax
 1090 lda addrs1,x
 1100 sta putchr1+1
 1110 sta putchr4+1
 1120 lda addrs1+1,x
 1130 sta putchr1+2
 1140 sta putchr4+2
 1150 lda addrs2,x
 1160 sta putchr2l+1
 1170 sta putchr3l+1
 1180 clc
 1190 lda addrs2+1,x
 1200 sta putchr2h+1
 1210 adc #8 ; 2 k offset
 1220 sta putchr3h+1
 1230 ;
 1240 ldx #$12
 1250 putchr2h lda #0
 1260 jsr out80
 1270 inx
 1280 putchr2l lda #0
 1290 jsr out80
 1300 ;
 1310 ldx #0 ; move 1 character
 1320 ;
 1330 putchr1 lda !$0000,x ; get regular character
 1340 stx savex
 1350 ldx #$1f
 1360 jsr out80
 1370 ldx savex
 1380 inx
 1390 cpx #8
 1400 bcc putchr1
 1410 ;
 1420 ldx #$12
 1430 putchr3h lda #0
 1440 jsr out80
 1450 inx
 1460 putchr3l lda #0
 1470 jsr out80
 1480 ;
 1490 ldx #0
 1500 ;
 1510 putchr4 lda !$0000,x ; get regular character
 1520 eor #%11111111 ; reverse field it
 1530 stx savex
 1540 ldx #$1f
 1550 jsr out80
 1560 ldx savex
 1570 inx
 1580 cpx #8
 1590 bcc putchr4
 1600 ;
 1610 dey
 1620 bpl putchr
 1630 ;
 1640 rts
 1650 ;
 1660 ; address tables
 1670 ;
 1680 addrs1 .word c1,c2,c3,c4,c5,c6,c7,c8
 1690 ;
 1700 ; set for use with text-right
 1710 ;
 1720 addrs2 .word $5b*16+c,$5d*16+c,$5e*16+c
 1730 .word $40*16+c,$5c*16+c,$1c*16+c,$1e*16+c
 1740 .word $1f*16+c
 1750 ;
 1760 ; data for characters
 1770 ;
 1780 c1 .byte $0e, $18, $08, $3c, $08, $18, $0e, $00 ; left brace
 1790 c2 .byte $70, $18, $10, $3c, $10, $18, $70, $00 ; right brace
 1800 c3 .byte $00, $00, $3b, $6e, $00, $00, $00, $00 ; tilde
 1810 c4 .byte $30, $18, $0c, $00, $00, $00, $00, $00 ; grave accent
 1820 c5 .byte $18, $18, $18, $00, $18, $18, $18, $00 ; vertical bar
 1830 c6 .byte $00, $60, $30, $18, $0c, $06, $03, $00 ; back slash
 1840 c7 .byte $00, $00, $18, $3c, $66, $00, $00, $00 ; caret
 1850 c8 .byte $00, $00, $00, $00, $00, $00, $00, $7f ; underline
 1860 ;
 1870 ;
 1880 ; subroutine - perform rs-232 flow control
 1890 ;
 1900 flowcon lda shflag ; check commodore key
 1910 and #$02 ; is it depressedprint
 1920 beq nocomm ; no
 1930 lda commflg ; was it depressed before
 1940 bne bufchk ; yes, ignore it
 1950 inc commflg ; set commodore key flag
 1960 lda suspend ; currently suspendedprint
 1970 beq notsus ; no
 1980 lda #0 ; clear suspend flag
 1990 sta suspend
 2000 beq bufchk
 2010 notsus inc suspend ; set suspend flag
 2020 bne bufchk
 2030 nocomm sta commflg ; clear commodore key flag
 2040 bufchk lda ridbe ; compute number of char in rs-232 buffer
 2050 sec
 2060 sbc ridbs
 2070 lsr a ; divide count by 2 for accurate check
 2080 ldx fxoff ; has an xoff already been sent
 2090 bne itsoff ; yes
 2100 cmp #100 ; number chars in buffer reached 200print
 2110 bmi flowret ; no - no flow control necessary yet
 2120 jsr xoff ; send an xoff
 2130 rts ; return
 2140 itsoff cmp #10 ; has backlog dropped to 20 or lessprint
 2150 bpl flowret ; no - leave input suspended
 2160 jsr xon ; send an xon
 2170 flowret rts
 2180 ;
 2190 ; subroutine - try to get a byte from rs-232 channel
 2200 ;
 2210 getrs lda suspend ; is rs-232 reading suspendedprint
 2220 bne rsret ; yes
 2230 ldx #$05 ; change kernel input to rs-232 channel
 2240 jsr chkin
 2250 jsr getin ; get byte
 2260 and #$7f ; remove parity bit
 2270 sta char
 2280 jsr readst ; get status
 2290 sta stat
 2300 lda #0 ; return kernel input to keyboard
 2310 jsr chkin
 2320 jsr rserrs ; check for rs-232 errors
 2330 bne rsret ; if error, return no byte
 2340 lda stat ; check status to see if byte was read
 2350 and #$08
 2360 rsret rts ; return "ne" if no byte read
 2370 ;
 2380 ; subroutine - check for rs-232 errors
 2390 ;
 2400 rserrs lda stat ; check status for error bits
 2410 and #$f7
 2420 beq erret ; no errors, return "eq"
 2430 jsr beeplo ; just beep on error
 2440 lda #1
 2450 erret rts ; return "ne" on errors
 2460 ;
 2470 ; subroutine - restore character under cursor to normal
 2480 ;
 2490 unblink ldx #10
 2500 jsr in80
 2510 and #%10011111
 2520 ora #%00100000
 2530 jmp out80
 2540 ;
 2550 ; subroutine - handle special input characters
 2560 ;
 2570 special lda char ; get ascii character
 2580 cmp #cr ;"carriage return ?
 2590 bne notcr ; no
 2600 sec ; yes, fetch cursor coordinates
 2610 jsr ploth
 2620 ldy #0 ; set column number to 0
 2630 clc ; set cursor coordinates
 2640 jsr ploth
 2650 rts
 2660 notcr cmp #bell ;"bell ?
 2670 bne notbell ; no
 2680 jsr beephi ; beep the tv with high tone
 2690 rts
 2700 notbell cmp #esc ;"^[ (esc) ?
 2710 bne notesc ; no
 2720 sta escflag ; set escape flag
 2730 rts
 2740 notesc brk ; error - there should be no other specials
 2750 ;
 2760 ; subroutine - clean up the c128 text editor flags for clean operation
 2770 ;
 2780 cleanup lda #0 ; make sure quote mode off
 2790 sta qtsw
 2800 rts
 2810 ;
 2820 ; subroutine - try to get a keyboard byte
 2830 ;
 2840 getkb jsr getin ; get a keyboard character
 2850 cmp #0 ;"is there a character ?
 2860 bne kbchar ; yes
 2870 rts ; return "eq" if no character
 2880 kbchar cmp #$83 ;"is it "shift/run/stop" ?
 2890 bne kbret ; no
 2900 jsr end ; yes, terminate program
 2910 kbret sta char ; save in char
 2920 rts
 2930 ;
 2940 ; subroutine - blink the cursor
 2950 ;
 2960 docurs dec loopcnt ; decrement timer
 2970 beq blinkit ;"expired ?
 2980 rts ; no
 2990 blinkit lda loopmax ; reset timer
 3000 sta loopcnt
 3010 lda #0 ; reset sound from beep routine
 3020 sta wave
 3030 ldx #10
 3040 jsr in80
 3050 and #%10011111
 3060 jmp out80
 3070 ;
 3080 ; subroutine - initiate sounds (beeps) - will terminate next cursor blink
 3090 ;
 3100 beeplo lda #$14 ; select low frequency
 3110 bne beep
 3120 beephi lda #$50 ; select high frequency
 3130 beep sta freqhi
 3140 lda #$0f ; select fast attack, slow decay
 3150 sta attdec
 3160 lda #$12 ; select sustain ...
 3170 sta susrel
 3180 lda #6 ; select not-too-loud volume
 3190 sta vol
 3200 lda #$21 ; select sawtooth wave
 3210 sta wave
 3220 lda loopmax ; reset cursor timer for consistent beep time
 3230 sta loopcnt
 3240 rts
 3250 ;
 3260 ; subroutine - downline load output from 6502 assembler until ^^
 3270 ;
 3280 dload lda #0 ; initialize
 3290 sta ndig ; number of digits read
 3300 sta dest ; clear load base address
 3310 sta dest+1
 3320 dget lda ndx ; begin line loop - check keyboard
 3330 bne dbreak ; any key terminates load
 3340 jsr getrs ; get rs-232 byte
 3350 bne dget ; if none, keep waiting
 3360 lda char ; get ascii character
 3370 cmp #$1e ;"^^ (terminate load) ?
 3380 bne noterm ; no
 3390 dbreak rts ; yes, return
 3400 noterm cmp #nl ;"line feed ?
 3410 beq dload ; yes, new line restarts load process
 3420 jsr chekdig ; convert character to digit
 3430 bmi dget ; not a digit, ignore
 3440 inc ndig ; increment digit count
 3450 lda ndig ; check digit count
 3460 cmp #3 ; first or secondprint
 3470 bpl ndlo ; no
 3480 jsr dlo ; yes, update destination low
 3490 clc ; loop for next character
 3500 bcc dget
 3510 ndlo cmp #5 ; third or fourthprint
 3520 bpl ndhi ; no
 3530 jsr dhi ; yes, update destination high
 3540 clc ; loop for next character
 3550 bcc dget
 3560 ndhi jsr putdat ; must be data, go store it
 3570 clc ; loop for next character
 3580 bcc dget
 3590 ;
 3600 ; subroutine - a a hex digit, return binary value (also in char), else -1
 3610 ;
 3620 chekdig sec ; convert decimal digit to binary
 3630 sbc #"0"
 3640 bmi ckbad ; below 0, not a digit
 3650 cmp #9+1 ; is it a decimal digitprint
 3660 bmi ckgood ; yes, return binary
 3670 sec ; convert hex digit to binary
 3680 sbc #"a"-"0"-10
 3690 cmp #$a
 3700 bmi ckbad ; below "A", not a digit
 3710 cmp #$f+1 ; is it a hex digitprint
 3720 bpl ckbad ; no, too high
 3730 ckgood sta char ; return good digit value
 3740 lda char
 3750 rts
 3760 ckbad lda #-1 ; return -1 (not digit)
 3770 rts
 3780 ;
 3790 ; subroutine - dest(low) = 16*dest(low)+char
 3800 ;
 3810 dlo lda dest ; dest low
 3820 asl a ; multiply by 16
 3830 asl a
 3840 asl a
 3850 asl a
 3860 ora char ; combine with char
 3870 sta dest ; update dest low
 3880 rts
 3890 ;
 3900 ; subroutine - dest(high) = 16*dest(high)+char
 3910 ;
 3920 dhi lda dest+1 ; dest high
 3930 asl a ; multiply by 16
 3940 asl a
 3950 asl a
 3960 asl a
 3970 ora char ; combine with char
 3980 sta dest+1 ; update dest high
 3990 rts
 4000 ;
 4010 ; subroutine - put data into memory at dest
 4020 ;
 4030 putdat lda ndig ;"which digit ?
 4040 and #1 ;"odd or even ?
 4050 bne podd ; odd, just go stash char
 4060 lda source ; even, get stashed data
 4070 asl a ; multiply by 16
 4080 asl a
 4090 asl a
 4100 asl a
 4110 ora char ; combine with char
 4120 ldy #0 ; store data into memory
 4130 ldx #dest
 4140 stx $02b9
 4150 ldx #$7f
 4160 jsr $02af
 4170 sta (dest),y
 4180 inc dest ; increment destination
 4190 bne samehi
 4200 inc dest+1
 4210 samehi rts
 4220 podd lda char ; stash char
 4230 sta source ; temporarily in source
 4240 rts
 4250 ;
 4260 .file 08,"0:128.2"
@//E*O*F 128.1//
chmod u=rw,g=,o= 128.1
 
echo x - 128.2
sed 's/^@//' > "128.2" <<'@//E*O*F 128.2//'
  100 ;
  110 ; term.plus.128.2
  120 ;
  130 ; last date 870104
  140 ;
  150 ; subroutine - restore everything and terminate program
  160 ;
  170 end jsr restore ; restore everything to default state
  180 pla ; fix up stack pointer
  190 pla
  200 pla
  210 pla
  220 lda #0 ; clear keyboard buffer
  230 sta ndx
  240 rts
  250 ;
  260 ; subroutine - restore everything to default state
  270 ;
  280 restore lda #5 ; close rs-232 channel
  290 jsr close
  300 lda #$93 ; clear the screen
  310 jsr chrout
  320 ldx #0
  330 stx suspend
  340 stx fxoff
  350 dex
  360 stx cflag
  370 rts
  380 ;
  390 ; subroutine - process escape sequences
  400 ;
  410 escseq sec ; get cursor coordinates
  420 jsr ploth
  430 sty xcoord
  440 stx ycoord
  450 lda escflag ; if escflag still esc, char is
  460 cmp #$1b ; a function code
  470 beq fcode
  480 ;
  490 ; process cursor coordinates following ^[y
  500 ;
  510 lda char ; put char-$20 into y coordinate if
  520 sec ; escflag=2, x coordinate if
  530 sbc #$20 ; escflag=1
  540 dec escflag
  550 ldy escflag
  560 sta xcoord,y
  570 ldy xcoord ; move cursor to new position
  580 ldx ycoord
  590 clc
  600 jsr ploth
  610 rts
  620 ;
  630 ; process ^[a (cursor up)
  640 ;
  650 fcode lda char ; process escape function codes
  660 cmp #"a" ;"cursor up ?
  670 bne notup ; no
  680 up lda #$91 ; yes - print cursor up
  690 print jsr chrout
  700 return lda #0 ; reset escape flag
  710 sta escflag
  720 rts
  730 ;
  740 ; process ^[b (cursor down)
  750 ;
  760 notup cmp #"b" ;"cursor down ?
  770 bne notdn ; no
  780 cpx #24 ; at bottom marginprint
  790 beq return ; yes
  800 lda #$11 ; print cursor down
  810 bne print
  820 ;
  830 ; process ^[c (cursor right)
  840 ;
  850 notdn cmp #"c" ;"cursor right ?
  860 bne notrt ; no
  870 cpy #79 ; at right margin
  880 beq return ; yes
  890 lda #$1d ; print cursor right
  900 bne print
  910 ;
  920 ; process ^[d (cursor left)
  930 ;
  940 notrt cmp #"d" ;"cursor left ?
  950 bne notlft ; no
  960 cpy #0 ;"at left margin ?
  970 beq return ; yes
  980 lf80 lda #$9d ; print cursor left
  990 bne print
 1000 ;
 1010 ; process ^[h (cursor home)
 1020 ;
 1030 notlft cmp #"h" ;"cursor home ?
 1040 bne nothome ; no
 1050 lda #$13 ; print cursor home
 1060 bne print
 1070 ;
 1080 ; process ^[o (reverse video)
 1090 ;
 1100 nothome cmp #"o"+$20 ;"reverse video ?
 1110 bne notrev ; no
 1120 lda #$12 ; print reverse on
 1130 bne print
 1140 ;
 1150 ; process ^[n (normal video)
 1160 ;
 1170 notrev cmp #"n"+$20 ;"normal video ?
 1180 bne notnorm ; no
 1190 lda #$92 ; print reverse off
 1200 bne print
 1210 ;
 1220 ; process ^[i (reverse line feed)
 1230 ;
 1240 notnorm cmp #"i" ;"reverse line feed ?
 1250 beq yesrlf ; yes
 1260 jmp notrlf ; no
 1270 yesrlf cpx #0 ; at top marginprint
 1280 bne up ; no - use normal cursor up
 1290 lda #esc
 1300 jsr chrout
 1310 lda #"w"
 1320 jsr chrout
 1330 jmp retesc
 1340 ;
 1350 ; process ^[k (clear to end of line)
 1360 ;
 1370 notrlf cmp #"k" ;"clear to end of line ?
 1380 bne noteol ; no
 1390 lda #esc
 1400 jsr chrout
 1410 lda #"q"
 1420 jsr chrout
 1430 jmp retesc
 1440 ;
 1450 ; process ^[j (clear to end of screen)
 1460 ;
 1470 noteol cmp #"j" ;"clear to end of screen ?
 1480 bne noteos ; no
 1490 lda #esc
 1500 jsr chrout
 1510 lda #"@"
 1520 jsr chrout
 1530 jmp retesc
 1540 ;
 1550 ; process ^[y (cursor motion initiate)
 1560 ;
 1570 noteos cmp #"y" ;"cursor motion ?
 1580 bne notcm ; no
 1590 lda #2 ; set escflag to 2 so next 2
 1600 sta escflag ; chars will be processed as
 1610 rts ; coordinates
 1620 ;
 1630 ; process ^[z (identify <vt-52> terminal)
 1640 ;
 1650 notcm cmp #"z" ;"identify terminal ?
 1660 bne notid ; no
 1670 ldx #5 ; change kernel output
 1680 jsr chkout ; to rs-232
 1690 lda #$1b ; output esc
 1700 jsr chrout
 1710 lda #"/" ; output /
 1720 jsr chrout
 1730 lda #"z" ; output z
 1740 jsr chrout
 1750 ldx #0 ; restore kernel output
 1760 jsr chkout ; to screen
 1770 clc
 1780 bcc retesc
 1790 ;
 1800 ; process ^[^\ (initiate downline load)
 1810 ;
 1820 notid cmp #$1c ; downline loadprint
 1830 bne retesc ; no
 1840 jsr dload ; do download
 1850 retesc lda #0 ; no other functions
 1860 sta escflag ; clear escape flag
 1870 rts
 1880 ;
 1890 ; subroutine - hires plot (but use plot if 40 column mode)
 1900 ;
 1910 ploth bcc pset ; carry clear means go set coordinates
 1920 jsr plot ; use commodore plot function
 1930 rts
 1940 pset cpx #0 ;"line < 0 ?
 1950 bpl ps1 ; no
 1960 ldx #0 ; set line to 0
 1970 ps1 cpx #25 ;"line >= 25 ?
 1980 bmi ps2 ; no
 1990 ldx #24 ; set line to 24
 2000 ps2 cpy #0 ;"column < 0 ?
 2010 bpl ps3 ; no
 2020 ldy #0 ; set column to 0
 2030 ps3 cpy #80 ;"column >= 80 ?
 2040 bmi ps4 ; no
 2050 ldy #79 ; set column to 79
 2060 ps4 clc ; set cursor coordinates
 2070 jsr plot ; using commodore plot
 2080 rts
 2090 ;
 2100 ; subroutine - send out ^s (xoff) to remote host
 2110 ;
 2120 xoff ldx #5 ; switch kernel to rs-232 output
 2130 stx fxoff ; set xoff flag
 2140 jsr chkout
 2150 jsr optimum ; wait until optimum time
 2160 lda #$13 ; then, transmit ^s
 2170 xcom jsr chrout
 2180 ldx #0 ; restore kernel output to screen
 2190 jsr chkout
 2200 rts
 2210 ;
 2220 ; subroutine - send out ^q (xon) to remote host
 2230 ;
 2240 xon lda #0 ; clear xoff flag
 2250 sta fxoff
 2260 ldx #5 ; switch kernel to rs-232 output
 2270 jsr chkout
 2280 lda #$11 ; transmit ^q
 2290 bne xcom
 2300 ;
 2310 ; subroutine - wait for optimum time to transmit an rs-232 character
 2320 ;
 2330 optimum lda bitci ; rs-232 input bit count
 2340 cmp #7 ; wait until count is not 7
 2350 beq optimum
 2360 ldx time+2 ; set x to 2 jiffys in the future
 2370 inx
 2380 inx
 2390 opti2 lda bitci ; wait until rs-232 bit count
 2400 cmp #7 ; equals 7
 2410 beq optiret
 2420 cpx time+2 ; or until 2 jiffys have expired
 2430 bne opti2
 2440 optiret rts
 2450 ;
 2460 .end 08,"0:128.doc"
@//E*O*F 128.2//
chmod u=rw,g=,o= 128.2
 
echo x - 128.doc
sed 's/^@//' > "128.doc" <<'@//E*O*F 128.doc//'
  100 n$="0:vt52-128":open 15,8,15,"s"+n$:close 15:open 1,8,1,n$
  110 sys 1000
  120 .opt o1
  130 ;
  140 ; term.plus.128.doc
  150 ;
  160 ; origion version by frank prindle for the 64.
  170 ; converted by g. r. (fred) walter to the 128.
  180 ;
  190 ; last date 870103
  200 ;
  210 ;"This program makes the Commodore 128 operate like a semi-
  220 ;"intellegent 80 column ascii terminal.  It supports input
  230 ;"and display of all the ASCII characters, and beeps when the BEL
  240 ;"character is received.
  250 ;
  260 ;"The communication protocol is full duplex, 8 bits, no
  270 ;"parity, 1 stop bit, 300 or 1200 baud, with XON/XOFF (DC1/
  280 ;"DC3) host flow control protocol -- this should satisfy most
  290 ;"host computers.  The display screen is 80 columns X 25 lines.
  300 ;
  310 ;"need to find the ESC and BS keys in their usual positions,
  320 ;"The following key substitutions apply (note- ^x is short-
  330 ;"hand for CONTROL-x):
  340 ;
  350 ;"       TO SEND         TYPE
  360 ;"       -------         ----
  370 ;"       backslash       BRITISH-POUND
  380 ;"       ^backslash      ^BRITISH-POUND
  390 ;"       ^underscore     ^=
  400 ;"       ^               UP-ARROW
  410 ;"       ^^              ^UP-ARROW
  420 ;"       ^[ (ESC)        ^[ or BACK-ARROW
  430 ;"       underscore      f1
  440 ;"       pipe            f2
  450 ;"       backwards '     f3
  460 ;"       tilde           f4
  470 ;"       left curly [    f5
  480 ;"       right curly ]   f6
  490 ;"       DEL (RUB)       f7
  500 ;"       ^T              f8
  510 ;"       ^H (BS)         DEL, ^H, or ^T
  520 ;"       ^J (NL)         SHIFT/RETURN or ^J or LINEFEED
  530 ;"       ^S (DC3)        ^S or HOME
  540 ;"       ^Q (DC1)        ^Q or CURSOR DOWN
  550 ;
  560 ;"Note that pressing the COMMODORE key will place the terminal
  570 ;"program in a suspended display mode (ie. the cursor will freeze
  580 ;"at it's current position), and ^S will be sent to the host
  590 ;"computer when the RS-232 input buffer fills up.  Similarly,
  600 ;"pressing the COMMODORE key will remove the terminal from the
  610 ;"suspended display mode and send a ^Q to the host computer only
  620 ;"if a ^S had previously been sent and the buffer has become nearly
  630 ;"empty.  This enables the COMMODORE key to be used like the SCROLL/
  640 ;"NO-SCROLL key on DEC terminals.  Suspended display mode is
  650 ;"indicated to the user by the cursor blinking faster than normal,
  660 ;"an indication that the COMMODORE key must be pressed to
  670 ;"resume displaying the received text.  The program may also send
  680 ;"^S and ^Q to the host computer on it's own from time to time if
  690 ;"it detects an impending RS-232 buffer overflow condition - this
  700 ;"normally will only occur while printing a number of short or blank
  710 ;"lines while scrolling the screen up (or down), since 4 to 15 char-
  720 ;"acters are received into the RS-232 buffer during the time it
  730 ;"takes to scroll the whole screen.  In any case, this automatic
  740 ;"flow control is fully synchronized with the flow control
  750 ;"necessitated by the use of the COMMODORE key to suspend and resume
  760 ;"the display of received text.  Depressing the ^S and ^Q keys (or
  770 ;"their substitutes indicated above) unconditionally sends those
  780 ;"ASCII characters to the remote host computer without any local
  790 ;"effect.
  800 ;
  810 ;"This terminal program does 'not' support flow control in the
  820 ;"opposite direction - receiving ^S from the host computer will not
  830 ;"lock the keyboard or have any other effect, nor will ^Q.
  840 ;
  850 ;"Also note that pressing the RUN/STOP key with SHIFT depres-
  860 ;"sed will cleanly terminate the terminal emulator program,
  870 ;"and return to BASIC.
  880 ;
  890 ;"All 94 printable ascii characters and the space will
  900 ;"be displayed on the screen as received over the RS-232
  910 ;"channel.  Most of the remaining (control) characters are
  920 ;"not displayed- however the following control characters
  930 ;"and escape sequences have special effects:
  940 ;"
  950 ;"       CHARACTER       EFFECT
  960 ;"       ---------       ------
  970 ;"       ^G (BEL)        beeps the TV
  980 ;"       ^H (BS)         cursor backspaces
  990 ;"       ^I (TAB)        cursor moves right to next tab stop
 1000 ;"       ^J (NL)         cursor moves down one line with scrolling
 1010 ;"       ^M (CR)         cursor moves to start of line
 1020 ;"       ^[A             cursor moves up one line
 1030 ;"       ^[B             cursor moves down
 1040 ;"       ^[C             cursor moves right one char.
 1050 ;"       ^[D             cursor moves left one char.
 1060 ;"       ^[H             cursor homes
 1070 ;"       ^[I             cursor moves up one line with scrolling
 1080 ;"       ^[J             clears from cursor to end of screen
 1090 ;"       ^[K             clears from cursor to end of line
 1100 ;"       ^[Ylc           cursor moves to line l-$20, col c-$20
 1110 ;"       ^[Z             sends DEC VT-52 terminal id string
 1120 ;"       ^[n             (lowercase n) turns off reverse video
 1130 ;"       ^[o             (lowercase o) turns on reverse video
 1140 ;"       ^[^backslash    initiates downline load
 1150 ;
 1160 ;"Tab stops are pre-defined and fixed at every 8 columns
 1170 ;"beginning with column 0 (ie. 0, 8, 16, 24, ...).
 1180 ;
 1190 ;"The rest should all be pretty much self explanatory except
 1200 ;"for "downline load".  Once the ^[^backslash sequence has been re-
 1210 ;"ceived, the program expects lines to come in over the RS-
 1220 ;"232 channel of the form:
 1230 ;
 1240 ;"            ;llhhdddddddddd...
 1250 ;
 1260 ;"where "llhh" is the address for the first byte of data
 1270 ;"on the line (in 6502 low/high format), and "dddddd.."
 1280 ;"are the data bytes themselves - note that the address
 1290 ;"must be 4 hexadecimal digits and each data byte must
 1300 ;"be 2 hexadecimal digits.  The load is terminated normally
 1310 ;"by reception of the control character ^^, or abnormally
 1320 ;"if the user hits a key on the C128 keyboard during the
 1330 ;"load. The data itself is stored in bank 1, where it can be
 1340 ;"saved using the monitor.
 1350 ;
 1360 ;"VAX UNIX users (Berkeley 4.1bsd) will find that the following
 1370 ;""termcap" entries effectively describe this terminal program
 1380 ;"for use with the terminal dependent UNIX programs (eg. vi,
 1390 ;"emacs, more, rogue, etc.): (note: read ! as pipe, / as backslash)
 1400 ;
 1410 ;" qc!c128!C128!Commodore 128:co#80:li#25:/
 1420 ;"         :up=/EA:do=/EB:cl=/EH/EJ:bs:/
 1430 ;"         :bw:ho=/EH:nd=/EC:so=/Eo:/
 1440 ;"         :se=/En:cm=/EY%+ %+ :/
 1450 ;"         :ce=/EK:sr=/EI:pt:
 1460 ;
 1470 ;"VAX VMS users can probably get away with the following (although
 1480 ;"some VMS programs [eg. edt] require an auxilliary keypad).
 1490 ;
 1500 ;"         set term /dev=vt52
 1510 ;"         set term /pag=25
 1520 ;"         set term /wid=80
 1530 ;
 1540 ;"TOPS-20 users can run "emacs" and the like after the following:
 1550 ;
 1560 ;"         term vt52
 1570 ;"         term length 25
 1580 ;"         term width 80
 1590 ;"         term pause com
 1600 ;
 1610 ;"A low pitched beep (much lower than that generated by
 1620 ;"receipt of the BEL character) indicates an error on the
 1630 ;"RS-232 channel (a hit, lost data, etc).
 1640 ;
 1650 ;"Of course, this program assumes you have been able
 1660 ;"to connect a modem (or null modem) to the C128 user
 1670 ;"port, which may or may not be trivial!
 1680 ;
 1690 ;"To run the terminal program, just load it like any BASIC
 1700 ;"program and RUN it.  You will be prompted for the baud
 1710 ;"rate.  Enter either 3 or 300 for 300 baud, 12 or 1200
 1720 ;"for 1200 baud, or just a carriage return for the default
 1730 ;"(1200 baud).  If you find communications shaky or impos-
 1740 ;"sible at 1200 baud, you may have to change the poke in
 1750 ;"basic which pokes 0 to poke 8 instead.  If this fails to
 1760 ;"help, try tuning the optional baud rate constants in 20ce
 1770 ;"and 20d0 for your system clock.
 1780 ;"(Use poke of 0 in the basic program in this case).
 1790 ;
 1800 ;"One last warning: this program is not relocatable - do
 1810 ;"not change the *length* of the BASIC program or nothing
 1820 ;"will work!
 1830 ;
 1840 ;"Good Luck and Enjoy....
 1850 ;"               Frank Prindle
 1860 ;"               G. R. Walter
 1870 ;
 1880 .file 08,"0:128.lables"
@//E*O*F 128.doc//
chmod u=rw,g=,o= 128.doc
 
echo x - 128.lables
sed 's/^@//' > "128.lables" <<'@//E*O*F 128.lables//'
  100 ;
  110 ; term.plus.128.lables
  120 ;
  130 ; last date 870103
  140 ;
  150 ; constant declarations
  160 ;
  170 out80 = $cdcc ; x-d600, acc-d601 (communicate with 80 column chip)
  180 in80 = $cdda ; x-d600, acc-d601 (communicate with 80 column chip)
  190 mmu = $ff00 ; memory management unit
  200 ;
  210 ;kernel entry points
  220 setnam = $ffbd ; set filename
  230 setlfs = $ffba ; set open parameters
  240 chkout = $ffc9 ; change kernel output channel
  250 chrout = $ffd2 ; output a character
  260 chkin = $ffc6 ; change kernel input channel
  270 getin = $ffe4 ; input a character
  280 readst = $ffb7 ; read i/o status
  290 open = $ffc0 ; open a channel
  300 close = $ffc3 ; close a channel
  310 plot = $fff0 ; fetch/set cursor position (40 col)
  320 ;commodore page zero variables
  330 ndx = $d0 ; number of keyboard bytes pending
  340 bitci = $a8 ; rs-232 input bit count
  350 time = $a0 ; jiffy clock (3-byte)
  360 pntr = $ec ; cursor column displacement (40 col)
  370 pnt = $e0 ; video matrix address of cursor line (40 col)
  380 qtsw = $f4 ; quote-mode switch (40 col)
  390 ;other commodore variables
  400 ridbe = $a18 ; rs-232 index to end of input buffer
  410 ridbs = $a19 ; rs-232 index to start of input buffer
  420 shflag = $d3 ; shift key flags (commodore key = bit 1)
  430 ;
  440 ;page zero temporaries
  450 source = $fb ; indirect address to be read
  460 dest = $fd ; indirect address to be stored
  470 ;commodore i/o addresses
  480 vcr = $d011 ; vic control register
  490 vmcr = $d018 ; vic memory control register
  500 ccra = $dc0e ; cia control register a
  510 bgnd = $d021 ; 40 column background color
  520 bord = $d020 ; border color
  530 freqhi = $d401 ; sid frequency (high byte)
  540 attdec = $d405 ; sid attack/decay
  550 susrel = $d406 ; sid sustain/release
  560 vol = $d418 ; sid volume
  570 wave = $d404 ; sid waveform select
  580 ddrpa2 = $dd02 ; cia-2 data direction reg (port a)
  590 dpa2 = $dd00 ; cia-2 data port a
  600 ;
  610 ; character codes
  620 bell = 7
  630 tab = 9
  640 nl = 10
  650 cr = 13
  660 crsrd = 17
  670 home = 19
  680 esc = 27
  690 crsrr = 29
  700 crsru = 145
  710 clr = 147
  720 crsrl = 157
  730 ;
  740 .file 08,"0:128.tables"
@//E*O*F 128.lables//
chmod u=rw,g=,o= 128.lables
 
echo x - 128.tables
sed 's/^@//' > "128.tables" <<'@//E*O*F 128.tables//'
  100 ;
  110 ; term.plus.128.tables
  120 ;
  130 ; last date 870104
  140 ;
  150 .bas
  160 bank 15
  170 if rgr(0)=5 then fast
  180 print "[HOME][HOME][CLR][ENABLE_CASE_SWITCH][LOWER/UPPER_CASE_MODE][TAB][
TAB][TAB]   TERM.PLUS.128"
  190 print "[TAB][TAB][TAB]   VT52 EMULATOR"
  200 print "[DOWN]Originally by Frank Prindle for the C64."
  210 print "Converted to the C128 by G. R. Walter."
  220 gosub 460
  230 poke dec("1008"),1
  240 poke dec("1009"),1
  250 poke dec("103f"),131
  260 poke dec("1040"),132
  270 key 1,chr$(133)
  280 key 2,chr$(137)
  290 key 3,chr$(134)
  300 key 4,chr$(138)
  310 key 5,chr$(135)
  320 key 6,chr$(139)
  330 key 7,chr$(136)
  340 key 8,chr$(140)
  350 input "[DOWN]Baud (default 1200) ";b$
  360 if left$(b$,2)="24"then poke dec("20ce"),10
  370 if left$(b$,2)="12"then poke dec("20ce"),0
  380 if left$(b$,1)="3" then poke dec("20ce"),6
  390 sys"init"
  400 gosub 460
  410 poke dec("1008"),9
  420 poke dec("1009"),5
  430 poke dec("103f"),68
  440 poke dec("1040"),204
  450 goto 550
  460 key 1,"graphic"
  470 key 2,"dload"+chr$(34)
  480 key 3,"directory"+chr$(13)
  490 key 4,"scnclr"+chr$(13)
  500 key 5,"dsave"+chr$(34)
  510 key 6,"run"+chr$(13)
  520 key 7,"list"+chr$(13)
  530 key 8,"monitor"+chr$(13)
  540 return
  550 poke dec("d0"),0
  560 end
  570 ;
  580 ; table declarations
  590 ;
  600 ;table "to" translates c128 to ascii
  610 to .byte $00 ; cannot transmit null
  620 .byte $01 ;"^A from ^A key
  630 .byte $02 ;"^B from ^B key
  640 .byte $03 ;"^C from ^C key
  650 .byte $04 ;"^D from ^D key
  660 .byte $05 ;"^E from ^E key
  670 .byte $06 ;"^F from ^F key
  680 .byte $07 ;"^G from ^G key
  690 .byte $08 ;"^H from ^H key
  700 .byte $09 ;"^I from ^I key
  710 .byte nl ;"^J from ^J and LINEFEED keys
  720 .byte $0b ;"^K from ^K key
  730 .byte $0c ;"^L from ^L key
  740 .byte cr ;"^M from ^M and RETURN keys
  750 .byte $0e ;"^N from ^N key
  760 .byte $0f ;"^O from ^O key
  770 .byte $10 ;"^P from ^P key
  780 .byte $11 ;"^Q from ^Q and CURS DOWN keys
  790 .byte $12 ;"^R from ^R key
  800 .byte $13 ;"^S from ^S and HOME keys
  810 .byte $08 ;"^H from ^T and DEL keys
  820 .byte $15 ;"^U from ^U key
  830 .byte $16 ;"^V from ^V key
  840 .byte $17 ;"^W from ^W key
  850 .byte $18 ;"^X from ^X key
  860 .byte $19 ;"^Y from ^Y key
  870 .byte $1a ;"^Z from ^Z key
  880 .byte esc ;"^[ from ^[ key
  890 .byte $1c ;"^backslash from ^POUND key
  900 .byte $1d ;"^] from ^] key
  910 .byte $1e ;"^^ from ^^ key
  920 .byte $1f ;"^underscore from ^= key
  930 .byte $20 ;"SPACE from SPACE bar
  940 .byte "!" ;"! from ! key
  950 .byte $22 ;"" from " key
  960 .byte "#" ;"# from # key
  970 .byte "$" ;"$ from $ key
  980 .byte "%" ;"% from % key
  990 .byte "&" ;"& from & key
 1000 .byte "'" ;"' from ' key
 1010 .byte "(" ;"( from ( key
 1020 .byte ")" ;") from ) key
 1030 .byte "*" ;"* from * key
 1040 .byte "+" ;"+ from + key
 1050 .byte "," ;", from , key
 1060 .byte "-" ;"- from - key
 1070 .byte "." ;". from . key
 1080 .byte "/" ;"/ from / key
 1090 .byte "0" ;"0 from 0 key
 1100 .byte "1" ;"1 from 1 key
 1110 .byte "2" ;"2 from 2 key
 1120 .byte "3" ;"3 from 3 key
 1130 .byte "4" ;"4 from 4 key
 1140 .byte "5" ;"5 from 5 key
 1150 .byte "6" ;"6 from 6 key
 1160 .byte "7" ;"7 from 7 key
 1170 .byte "8" ;"8 from 8 key
 1180 .byte "9" ;"9 from 9 key
 1190 .byte ":" ;": from : key
 1200 .byte ";" ;"; from ; key
 1210 .byte "<" ;"< from < key
 1220 .byte "=" ;"= from = key
 1230 .byte ">" ;"> from > key
 1240 .byte "?" ;"? from ? key
 1250 .byte "@" ;"@ from @ key
 1260 .byte "a"+$20 ;"a from a key
 1270 .byte "b"+$20 ;"b from b key
 1280 .byte "c"+$20 ;"c from c key
 1290 .byte "d"+$20 ;"d from d key
 1300 .byte "e"+$20 ;"e from e key
 1310 .byte "f"+$20 ;"f from f key
 1320 .byte "g"+$20 ;"g from g key
 1330 .byte "h"+$20 ;"h from h key
 1340 .byte "i"+$20 ;"i from i key
 1350 .byte "j"+$20 ;"j from j key
 1360 .byte "k"+$20 ;"k from k key
 1370 .byte "l"+$20 ;"l from l key
 1380 .byte "m"+$20 ;"m from m key
 1390 .byte "n"+$20 ;"n from n key
 1400 .byte "o"+$20 ;"o from o key
 1410 .byte "p"+$20 ;"p from p key
 1420 .byte "q"+$20 ;"q from q key
 1430 .byte "r"+$20 ;"r from r key
 1440 .byte "s"+$20 ;"s from s key
 1450 .byte "t"+$20 ;"t from t key
 1460 .byte "u"+$20 ;"u from u key
 1470 .byte "v"+$20 ;"v from v key
 1480 .byte "w"+$20 ;"w from w key
 1490 .byte "x"+$20 ;"x from x key
 1500 .byte "y"+$20 ;"y from y key
 1510 .byte "z"+$20 ;"z from z key
 1520 .byte "[" ;"[ from [ key
 1530 .byte "\" ;"backslash from POUND key
 1540 .byte "]" ;"] from ] key
 1550 .byte "^" ;"^ from ^ key (really UP ARROW)
 1560 .byte esc ;"^[ from backarrow key
 1570 .byte "@"+$20 ;"backwards ' from SHIFT/* key
 1580 .byte "a" ;"A from A key
 1590 .byte "b" ;"B from B key
 1600 .byte "c" ;"C from C key
 1610 .byte "d" ;"D from D key
 1620 .byte "e" ;"E from E key
 1630 .byte "f" ;"F from F key
 1640 .byte "g" ;"G from G key
 1650 .byte "h" ;"H from H key
 1660 .byte "i" ;"I from I key
 1670 .byte "j" ;"J from J key
 1680 .byte "k" ;"K from K key
 1690 .byte "l" ;"L from L key
 1700 .byte "m" ;"M from M key
 1710 .byte "n" ;"N from N key
 1720 .byte "o" ;"O from O key
 1730 .byte "p" ;"P from P key
 1740 .byte "q" ;"Q from Q key
 1750 .byte "r" ;"R from R key
 1760 .byte "s" ;"S from S key
 1770 .byte "t" ;"T from T key
 1780 .byte "u" ;"U from U key
 1790 .byte "v" ;"V from V key
 1800 .byte "w" ;"W from W key
 1810 .byte "x" ;"X from X key
 1820 .byte "y" ;"Y from Y key
 1830 .byte "z" ;"Z from Z key
 1840 .byte $7b ;"left curly [ from SHIFT/+ key
 1850 .byte $7c ;"pipe from ?????
 1860 .byte $7d ;"right curly [ from SHIFT/- key
 1870 .byte $7e ;"tilde from SHIFT/^ key
 1880 .byte $7f ;"DEL from ?????
 1890 .byte "?" ;"illegal key
 1900 .byte "?" ;"illegal key
 1910 .byte "?" ;"illegal key
 1920 .byte "?" ;"illegal key
 1930 .byte "?" ;"illegal key
 1940 .byte $5f ;"underscore from F1 key
 1950 .byte $60 ;"backwards ' from F3 key
 1960 .byte $7b ;"left curly [ from F5 key
 1970 .byte $7f ;"DEL from F7 key
 1980 .byte $7c ;"pipe from F2 key
 1990 .byte $7e ;"tilde from F4 key
 2000 .byte $7d ;"right curly ] from F6 key
 2010 .byte $14 ;"^T from F8 key
 2020 .byte $0a ;"NL from SHIFT/RETURN key
 2030 .byte "?" ;"illegal key
 2040 .byte "?" ;"illegal key
 2050 .byte "?" ;"illegal key
 2060 .byte "?" ;"illegal key
 2070 .byte "?" ;"illegal key
 2080 .byte "?" ;"illegal key
 2090 .byte "?" ;"illegal key
 2100 .byte "?" ;"illegal key
 2110 .byte "?" ;"illegal key
 2120 .byte "?" ;"illegal key
 2130 .byte "?" ;"illegal key
 2140 .byte "?" ;"illegal key
 2150 .byte "?" ;"illegal key
 2160 .byte "?" ;"illegal key
 2170 .byte "?" ;"illegal key
 2180 .byte "?" ;"illegal key
 2190 .byte "?" ;"illegal key
 2200 .byte "?" ;"illegal key
 2210 .byte $20 ;"SPACE from SHIFT/SPACE key
 2220 .byte "?" ;"illegal key
 2230 .byte "?" ;"illegal key
 2240 .byte "?" ;"illegal key
 2250 .byte "?" ;"illegal key
 2260 .byte "?" ;"illegal key
 2270 .byte "?" ;"illegal key
 2280 .byte "?" ;"illegal key
 2290 .byte "?" ;"illegal key
 2300 .byte "?" ;"illegal key
 2310 .byte "?" ;"illegal key
 2320 .byte "?" ;"illegal key
 2330 .byte "?" ;"illegal key
 2340 .byte "?" ;"illegal key
 2350 .byte "?" ;"illegal key
 2360 .byte "?" ;"illegal key
 2370 .byte "?" ;"illegal key
 2380 .byte "?" ;"illegal key
 2390 .byte "?" ;"illegal key
 2400 .byte "?" ;"illegal key
 2410 .byte "?" ;"illegal key
 2420 .byte "?" ;"illegal key
 2430 .byte "?" ;"illegal key
 2440 .byte "?" ;"illegal key
 2450 .byte "?" ;"illegal key
 2460 .byte "?" ;"illegal key
 2470 .byte "?" ;"illegal key
 2480 .byte "?" ;"illegal key
 2490 .byte "?" ;"illegal key
 2500 .byte "?" ;"illegal key
 2510 .byte "?" ;"illegal key
 2520 .byte "?" ;"illegal key
 2530 .byte "@"+$20 ;"backwards ' from SHIFT/* key (dup)
 2540 .byte "a" ;"A from A key (dup)
 2550 .byte "b" ;"B from B key (dup)
 2560 .byte "c" ;"C from C key (dup)
 2570 .byte "d" ;"D from D key (dup)
 2580 .byte "e" ;"E from E key (dup)
 2590 .byte "f" ;"F from F key (dup)
 2600 .byte "g" ;"G from G key (dup)
 2610 .byte "h" ;"H from H key (dup)
 2620 .byte "i" ;"I from I key (dup)
 2630 .byte "j" ;"J from J key (dup)
 2640 .byte "k" ;"K from K key (dup)
 2650 .byte "l" ;"L from L key (dup)
 2660 .byte "m" ;"M from M key (dup)
 2670 .byte "n" ;"N from N key (dup)
 2680 .byte "o" ;"O from O key (dup)
 2690 .byte "p" ;"P from P key (dup)
 2700 .byte "q" ;"Q from Q key (dup)
 2710 .byte "r" ;"R from R key (dup)
 2720 .byte "s" ;"S from S key (dup)
 2730 .byte "t" ;"T from T key (dup)
 2740 .byte "u" ;"U from U key (dup)
 2750 .byte "v" ;"V from V key (dup)
 2760 .byte "w" ;"W from W key (dup)
 2770 .byte "x" ;"X from X key (dup)
 2780 .byte "y" ;"Y from Y key (dup)
 2790 .byte "z" ;"Z from Z key (dup)
 2800 .byte $7b ;"left curly [ from SHIFT/+ key (dup)
 2810 .byte $7c ;"pipe from ????? (dup)
 2820 .byte $7d ;"right curly ] from SHIFT/- key (dup)
 2830 .byte $7e ;"tilde from SHIFT/^ key (dup)
 2840 .byte $7f ;"DEL from ?????
 2850 .byte $20 ;"SPACE from SHIFT/SPACE key (dup)
 2860 .byte "?" ;"illegal key
 2870 .byte "?" ;"illegal key
 2880 .byte "?" ;"illegal key
 2890 .byte "?" ;"illegal key
 2900 .byte "?" ;"illegal key
 2910 .byte "?" ;"illegal key
 2920 .byte "?" ;"illegal key
 2930 .byte "?" ;"illegal key
 2940 .byte "?" ;"illegal key
 2950 .byte "?" ;"illegal key
 2960 .byte "?" ;"illegal key
 2970 .byte "?" ;"illegal key
 2980 .byte "?" ;"illegal key
 2990 .byte "?" ;"illegal key
 3000 .byte "?" ;"illegal key
 3010 .byte "?" ;"illegal key
 3020 .byte "?" ;"illegal key
 3030 .byte "?" ;"illegal key
 3040 .byte "?" ;"illegal key
 3050 .byte "?" ;"illegal key
 3060 .byte "?" ;"illegal key
 3070 .byte "?" ;"illegal key
 3080 .byte "?" ;"illegal key
 3090 .byte "?" ;"illegal key
 3100 .byte "?" ;"illegal key
 3110 .byte "?" ;"illegal key
 3120 .byte "?" ;"illegal key
 3130 .byte "?" ;"illegal key
 3140 .byte "?" ;"illegal key
 3150 .byte "?" ;"illegal key
 3160 .byte $7e ;"tilde from SHIFT/^ key (dup)
 3170 ;
 3180 ;table "from" translates ascii to c64
 3190 from .byte $00 ;"NUL doesn't print
 3200 .byte $00 ;"^A doesn't print
 3210 .byte $00 ;"^B doesn't print
 3220 .byte $00 ;"^C doesn't print
 3230 .byte $00 ;"^D doesn't print
 3240 .byte $00 ;"^E doesn't print
 3250 .byte $00 ;"^F doesn't print
 3260 .byte $01 ;"BEL is special
 3270 .byte $9d ;"BS prints as CURSOR LEFT
 3280 .byte tab ;"TAB
 3290 .byte $11 ;"NL prints as CURSOR DOWN
 3300 .byte $00 ;"^K doesn't print
 3310 .byte $00 ;"^L doesn't print
 3320 .byte $01 ;"CR is special
 3330 .byte $00 ;"^N doesn't print
 3340 .byte $00 ;"^O doesn't print
 3350 .byte $00 ;"^P doesn't print
 3360 .byte $00 ;"^Q doesn't print
 3370 .byte $00 ;"^R doesn't print
 3380 .byte $00 ;"^S doesn't print
 3390 .byte $00 ;"^T doesn't print
 3400 .byte $00 ;"^U doesn't print
 3410 .byte $00 ;"^V doesn't print
 3420 .byte $00 ;"^W doesn't print
 3430 .byte $00 ;"^X doesn't print
 3440 .byte $00 ;"^Y doesn't print
 3450 .byte $00 ;"^Z doesn't print
 3460 .byte $01 ;"^[ is special
 3470 .byte $00 ;"^\ doesn't print
 3480 .byte $00 ;"^] doesn't print
 3490 .byte $00 ;"^^ doesn't print
 3500 .byte $00 ;"^underscore doesn't print
 3510 .byte $20 ;"SPACE prints as SPACE
 3520 .byte $21 ;"! prints as !
 3530 .byte $22 ;"" prints as "
 3540 .byte $23 ;"# prints as #
 3550 .byte $24 ;"$ prints as $
 3560 .byte $25 ;"% prints as %
 3570 .byte $26 ;"& prints as &
 3580 .byte $27 ;"' prints as '
 3590 .byte $28 ;"( prints as (
 3600 .byte $29 ;") prints as )
 3610 .byte $2a ;"* prints as *
 3620 .byte $2b ;"+ prints as +
 3630 .byte $2c ;", prints as ,
 3640 .byte $2d ;"- prints as -
 3650 .byte $2e ;". prints as .
 3660 .byte $2f ;"/ prints as /
 3670 .byte $30 ;"0 prints as 0
 3680 .byte $31 ;"1 prints as 1
 3690 .byte $32 ;"2 prints as 2
 3700 .byte $33 ;"3 prints as 3
 3710 .byte $34 ;"4 prints as 4
 3720 .byte $35 ;"5 prints as 5
 3730 .byte $36 ;"6 prints as 6
 3740 .byte $37 ;"7 prints as 7
 3750 .byte $38 ;"8 prints as 8
 3760 .byte $39 ;"9 prints as 9
 3770 .byte $3a ;": prints as :
 3780 .byte $3b ;"; prints as ;
 3790 .byte $3c ;"< prints as <
 3800 .byte $3d ;"= prints as =
 3810 .byte $3e ;"> prints as >
 3820 .byte $3f ;"? prints as ?
 3830 .byte $40 ;"@ prints as @
 3840 .byte $61 ;"A prints as A
 3850 .byte $62 ;"B prints as B
 3860 .byte $63 ;"C prints as C
 3870 .byte $64 ;"D prints as D
 3880 .byte $65 ;"E prints as E
 3890 .byte $66 ;"F prints as F
 3900 .byte $67 ;"G prints as G
 3910 .byte $68 ;"H prints as H
 3920 .byte $69 ;"I prints as I
 3930 .byte $6a ;"J prints as J
 3940 .byte $6b ;"K prints as K
 3950 .byte $6c ;"L prints as L
 3960 .byte $6d ;"M prints as M
 3970 .byte $6e ;"N prints as N
 3980 .byte $6f ;"O prints as O
 3990 .byte $70 ;"P prints as P
 4000 .byte $71 ;"Q prints as Q
 4010 .byte $72 ;"R prints as R
 4020 .byte $73 ;"S prints as S
 4030 .byte $74 ;"T prints as T
 4040 .byte $75 ;"U prints as U
 4050 .byte $76 ;"V prints as V
 4060 .byte $77 ;"W prints as W
 4070 .byte $78 ;"X prints as X
 4080 .byte $79 ;"Y prints as Y
 4090 .byte $7a ;"Z prints as Z
 4100 .byte $5b ;"[ prints as [
 4110 .byte $5c ;"\ prints as \
 4120 .byte $5d ;"] prints as ]
 4130 .byte $5e ;"^ prints as ^
 4140 .byte $5f ;"underscore prints as C=@
 4150 .byte $60 ;"backwards ' prints as SHIFT/*
 4160 .byte $41 ;"a prints as a
 4170 .byte $42 ;"b prints as b
 4180 .byte $43 ;"c prints as c
 4190 .byte $44 ;"d prints as d
 4200 .byte $45 ;"e prints as e
 4210 .byte $46 ;"f prints as f
 4220 .byte $47 ;"g prints as g
 4230 .byte $48 ;"h prints as h
 4240 .byte $49 ;"i prints as i
 4250 .byte $4a ;"j prints as j
 4260 .byte $4b ;"k prints as k
 4270 .byte $4c ;"l prints as l
 4280 .byte $4d ;"m prints as m
 4290 .byte $4e ;"n prints as n
 4300 .byte $4f ;"o prints as o
 4310 .byte $50 ;"p prints as p
 4320 .byte $51 ;"q prints as q
 4330 .byte $52 ;"r prints as r
 4340 .byte $53 ;"s prints as s
 4350 .byte $54 ;"t prints as t
 4360 .byte $55 ;"u prints as u
 4370 .byte $56 ;"v prints as v
 4380 .byte $57 ;"w prints as w
 4390 .byte $58 ;"x prints as x
 4400 .byte $59 ;"y prints as y
 4410 .byte $5a ;"z prints as z
 4420 .byte $7b ;"left curly [ prints as SHIFT/+
 4430 .byte $7c ;"pipe prints as C=*
 4440 .byte $7d ;"right curly ] prints as SHIFT/-
 4450 .byte $7e ;"tilde prints as C=p
 4460 .byte $00 ;"DEL doesn't print
 4470 ;
 4480 .file 08,"0:128.1"
@//E*O*F 128.tables//
chmod u=rw,g=,o= 128.tables
 
exit 0