vt52 emulator for c64 sources
Fred Walter
grwalter at watmath.UUCP
Tue Jan 13 05:55:18 AEST 1987
this is the source for a vt52 emulator for the c64 written by frank
prindle and played with by me. read term.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 Mon Jan 5 19:38:02 EST 1987
# Contents: term.1 term.2 term.doc term.end term.font term.lables
# term.plus.bas term.tables
echo x - term.1
sed 's/^@//' > "term.1" <<'@//E*O*F term.1//'
100 ;
110 ; term.plus.64.1
120 ;
130 ; last date 870102
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 $06 ; rs-232 control reg (300 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 fgbg8 .byte $bf ; 80 col fgnd/bgnd colors (gray1/gray3)
260 fgbg4 .byte $1b ; 40 col fgnd/bgnd colors (white/gray1)
270 escflag .byte 0 ; escape sequence flag/counter
280 xcoord .byte 0 ; temp storage for x screen coordinate
290 ycoord .byte 0 ; temp storage for y screen coordinate
300 lineh .byte 0 ; hires cursor line number
310 colh .byte 0 ; hires cursor column number
320 hilo .byte $f0 ; hires nibble mask
330 revmask .byte $0 ; reverse video mask ($f=reverse, $0=normal)
340 cflag .byte $ff ; zero if char under cursor has been reversed
350 cstate .byte $0 ; top nibble of char under cursor if cflag=0
360 flag79 .byte $0 ; non-zero if previous char printed in column 79
370 flag79t .byte $0 ; one shot copy of previous flag79
380 ccode .byte $0 ; temporary character storage for chrouth
390 suspend .byte $0 ; rs-232 reads suspended if non-zero
400 fxoff .byte $0 ; xoff has been sent if non-zero
410 commflg .byte $0 ; non-zero if commodore key is depressed
420 flag80 .byte $0 ; non-zero if 80 column mode
430 ;
440 ; terminal emulator reloacation from "here" to "there"
450 ;
460 *=there+$280
470 ;
480 movterm lda #<here ; set up source and dest to point
490 sta source ; to "here" and "there" respectively
500 lda #>here
510 sta source+1
520 lda #<there
530 sta dest
540 lda #>there
550 sta dest+1
560 ldx #$10 ; $1000 bytes will be moved
570 ldy #$00
580 lp lda (source),y ; beginning of outer and inner move loops
590 sta (dest),y
600 iny
610 bne lp ; end inner loop to move $100 bytes
620 inc source+1
630 inc dest+1
640 dex
650 bne lp ; end outer loop to do inner loop 16 times
660 beq renter ; skip around termination code
670 term lda r6510 ; prepare to terminate
680 ora #1 ; by paging basic rom in
690 sta r6510
700 brk ; terminate
710 renter lda r6510 ; reenter here
720 and #$fe ; page out basic rom
730 sta r6510
740 jmp init ; branch to init "there"
750 ;
760 ; terminal emulator main program
770 ;
780 init jsr revic ; set up vic chip bank and addresses
790 jsr movechr ; move 40 col char set from rom to ram
800 jsr replchr ; mod 40 col char set for full ascii
810 jsr screen ; set up screen attributes
820 jsr openrs ; open rs-232 channel
830 jsr welcome ; write initial message to screen
840 ;
850 tloop lda ndx ; main terminal loop begins
860 bne kbd ; keyboard has priority over rs-232
870 jsr flowcon ; do rs-232 flow control if necessary
880 jsr getrs ; get an rs-232 byte
890 bne kbd ; if none available, go check keyboard
900 jsr unblink ; restore character under cursor
910 lda escflag ; escape sequence activeprint
920 beq normal ; no
930 jsr escseq ; yes - process escape seq.
940 clc ; then skip printing char
950 bcc nospec
960 normal ldx char ; get ascii character read
970 lda from,x ; get equivalent c64 character to print
980 jsr chrouth ; print it on screen
990 ldx char ; get ascii again
1000 lda from,x ; get c64 again
1010 cmp #$01 ; code 1 characters are special
1020 bne nospec ; skip if not special
1030 jsr special ; process special rs-232 characters
1040 nospec jsr cleanup ; clean up after 40 col screen print
1050 clc ; repeat
1060 bcc tloop ; main loop
1070 ;
1080 kbd jsr getkb ; get a keyboard byte
1090 beq cursor ; if none available, go generate cursor
1100 ldx #5 ; change kernel output
1110 jsr chkout ; to rs-232
1120 jsr optimum ; wait for optimum time to do rs-232 out
1130 ldx char ; get c64 character read
1140 lda to,x ; get equivalent ascii character to send
1150 jsr chrout ; send it to rs-232
1160 ldx #0 ; return kernel output
1170 jsr chkout ; to screen
1180 cursor jsr docurs ; blink cursor position
1190 clc ; repeat
1200 bcc tloop ; main loop
1210 ;
1220 ; subroutine - open rs-232 as logical device 5
1230 ;
1240 openrs lda #<rsout ; allocate the rs-232 buffers
1250 sta robuf
1260 lda #>rsout
1270 sta robuf+1
1280 lda #<rsin
1290 sta ribuf
1300 lda #>rsin
1310 sta ribuf+1
1320 lda #4 ; pass rs-232 parameters as "filename"
1330 ldx #<control
1340 ldy #>control
1350 jsr setnam
1360 lda #5 ; equate logical unit 5 to physical 2 (rs-232)
1370 ldx #2
1380 ldy #0
1390 jsr setlfs
1400 jsr open ; do the open
1410 rts
1420 ;
1430 ; subroutine - move character set 2 from rom into ram as set 1
1440 ;
1450 movechr lda #$8e ; switch to character set 1
1460 jsr chrout
1470 lda vmcr ; set low 4 bits of vic memory control register
1480 and #$f0 ; to $0c so vic will fetch character patterns
1490 ora #$0e ; from $b800
1500 sta vmcr
1510 lda ccra ; clear bit 0 of cia control register a to stop
1520 and #$fe ; keyboard scan
1530 sta ccra
1540 lda r6510 ; page in character rom at $d000
1550 and #$fb
1560 sta r6510
1570 lda #$00 ; set up source to $d800 (rom set 2)
1580 sta source ; and dest to $b800 (ram set 1)
1590 sta dest
1600 lda #$d8
1610 sta source+1
1620 lda #$b8
1630 sta dest+1
1640 ldx #$08 ; $0800 bytes need to be moved
1650 ldy #$00
1660 mloop lda (source),y ; beginning of both outer and inner move loops
1670 sta (dest),y
1680 iny
1690 bne mloop ; end inner loop to move $100 bytes
1700 inc source+1
1710 inc dest+1
1720 dex
1730 bne mloop ; end outer loop to do inner loop 8 times
1740 lda r6510 ; page out character rom
1750 ora #$04
1760 sta r6510
1770 lda ccra ; resume keyboard scan
1780 ora #$01
1790 sta ccra
1800 rts
1810 ;
1820 ; subroutine - replace the bit patterns for 8 characters to attain full asc
1830 ;
1840 replchr lda #<newchar ; set up source to point to newchar
1850 sta source
1860 lda #>newchar
1870 sta source+1
1880 ldx #0 ; x always 0, y indexes through newchar
1890 ldy #0
1900 rloop1 lda (source),y ; begin outer loop - fetch screen code and
1910 lsr a ; compute dest as $b800 + screen code*8
1920 lsr a
1930 lsr a
1940 lsr a
1950 lsr a
1960 clc
1970 adc #$b8
1980 sta dest+1
1990 lda (source),y
2000 asl a
2010 asl a
2020 asl a
2030 sta dest
2040 lda #8 ; set inner loop counter to 8
2050 sta loopcnt
2060 iny ; index to first pattern byte
2070 rloop2 lda (source),y ; begin inner loop - move bit pattern for 1 chr
2080 sta (dest,x)
2090 lda dest+1 ; switch dest to reversed character area
2100 ora #$04
2110 sta dest+1
2120 lda (source),y ; move reversed bit pattern
2130 eor #$ff
2140 sta (dest,x)
2150 lda dest+1 ; switch dest back to normal characters
2160 eor #$04
2170 sta dest+1
2180 iny ; index to next bit pattern
2190 inc dest
2200 dec loopcnt
2210 bne rloop2 ; end inner loop to move 8 bytes
2220 cpy #$40
2230 bmi rloop1 ; end outer loop to modify 8 characters
2240 rts
2250 ;
2260 ; subroutine - perform rs-232 flow control
2270 ;
2280 flowcon lda shflag ; check commodore key
2290 and #$02 ; is it depressedprint
2300 beq nocomm ; no
2310 lda commflg ; was it depressed before
2320 bne bufchk ; yes, ignore it
2330 inc commflg ; set commodore key flag
2340 lda suspend ; currently suspendedprint
2350 beq notsus ; no
2360 lda #0 ; clear suspend flag
2370 sta suspend
2380 beq bufchk
2390 notsus inc suspend ; set suspend flag
2400 bne bufchk
2410 nocomm sta commflg ; clear commodore key flag
2420 bufchk lda ridbe ; compute number of char in rs-232 buffer
2430 sec
2440 sbc ridbs
2450 lsr a ; divide count by 2 for accurate check
2460 ldx fxoff ; has an xoff already been sent
2470 bne itsoff ; yes
2480 cmp #100 ; number chars in buffer reached 200print
2490 bmi flowret ; no - no flow control necessary yet
2500 jsr xoff ; send an xoff
2510 rts ; return
2520 itsoff cmp #10 ; has backlog dropped to 20 or lessprint
2530 bpl flowret ; no - leave input suspended
2540 jsr xon ; send an xon
2550 flowret rts
2560 ;
2570 ; subroutine - set border, background, and text colors, then clear screen
2580 ;
2590 screen lda #$0c ; set border to gray 2
2600 sta bord
2610 lda flag80 ; 80 column modeprint
2620 beq s40 ; no
2630 ;
2640 lda #<vidmat ; set up hires bgnd and fgnd colors
2650 sta dest
2660 lda #>vidmat
2670 sta dest+1
2680 ldx #$04 ; $0400 bytes need to be set
2690 ldy #0
2700 lda fgbg8 ; foreground/background colors
2710 sloop sta (dest),y ; begin both outer and inner set loops
2720 iny
2730 bne sloop ; end inner loop to set $100 bytes
2740 inc dest+1
2750 dex
2760 bne sloop ; end outer loop to do inner loop 4 times
2770 beq scom ; now go to common code
2780 ;
2790 s40 lda fgbg4 ; set 40 col bgnd color
2800 and #$0f
2810 sta bgnd
2820 lda fgbg4 ; set 40 col foreground color
2830 lsr a
2840 lsr a
2850 lsr a
2860 lsr a
2870 sta color ; continue into common code
2880 ;
2890 scom lda #$93 ; clear screen
2900 jsr chrouth
2910 rts
2920 ;
2930 ; subroutine - try to get a byte from rs-232 channel
2940 ;
2950 getrs lda suspend ; is rs-232 reading suspendedprint
2960 bne rsret ; yes
2970 ldx #$05 ; change kernel input to rs-232 channel
2980 jsr chkin
2990 jsr getin ; get byte
3000 and #$7f ; remove parity bit
3010 sta char
3020 jsr readst ; get status
3030 sta stat
3040 lda #0 ; return kernel input to keyboard
3050 jsr chkin
3060 jsr rserrs ; check for rs-232 errors
3070 bne rsret ; if error, return no byte
3080 lda stat ; check status to see if byte was read
3090 and #$08
3100 rsret rts ; return "ne" if no byte read
3110 ;
3120 ; subroutine - check for rs-232 errors
3130 ;
3140 rserrs lda stat ; check status for error bits
3150 and #$f7
3160 beq erret ; no errors, return "eq"
3170 jsr beeplo ; just beep on error
3180 lda #1
3190 erret rts ; return "ne" on errors
3200 ;
3210 ; subroutine - restore character under cursor to normal
3220 ;
3230 unblink lda flag80 ; 80 column modeprint
3240 beq u40 ; no
3250 ;
3260 lda cflag ; has cursor been blinked at this positionprint
3270 bne noneed ; no - char must still be in original state
3280 ldy #0 ; fetch top byte of character
3290 lda (pnth),y
3300 and hilo ; isolate nibble under cursor
3310 cmp cstate ; is character in original stateprint
3320 beq noneed ; yes
3330 ldy #8-1 ; must restore 8 bytes
3340 uloop lda (pnth),y ; fetch hires byte
3350 eor hilo ; reverse nibble under cursor
3360 sta (pnth),y ; replace hires byte
3370 dey ; decrement counter
3380 bpl uloop ; loop 8 times
3390 noneed ldy #$ff ; flag that char under cursor is restored
3400 sty cflag
3410 rts
3420 ;
3430 u40 ldy pntr ; fetch column displacement of cursor
3440 lda (pnt),y ; fetch screen byte under cursor
3450 and #$7f ; ensure non reversed character
3460 sta (pnt),y ; store back in screen
3470 rts
3480 ;
3490 ; subroutine - handle special input characters
3500 ;
3510 special lda char ; get ascii character
3520 cmp #$0d ; carriage returnprint
3530 bne notcr ; no
3540 sec ; yes, fetch cursor coordinates
3550 jsr ploth
3560 ldy #0 ; set column number to 0
3570 clc ; set cursor coordinates
3580 jsr ploth
3590 rts
3600 notcr cmp #$07 ; bellprint
3610 bne notbell ; no
3620 jsr beephi ; beep the tv with high tone
3630 rts
3640 notbell cmp #$1b ; ^[ (esc)print
3650 bne notesc ; no
3660 sta escflag ; set escape flag
3670 rts
3680 notesc cmp #$09 ; ^i (tab)print
3690 bne nottab ; no
3700 sec ; fetch cursor coordinates
3710 jsr ploth
3720 tya
3730 lsr a ; divide column by 8
3740 lsr a
3750 lsr a
3760 tay ; add one
3770 iny
3780 tya
3790 asl a ; multiply by 8
3800 asl a
3810 asl a
3820 tay
3830 lda flag80 ; 80 column modeprint
3840 bne nowrap ; yes
3850 cpy #40 ; is new column number 40print
3860 bne nowrap ; no
3870 ldy #0 ; column=0
3880 inx ; line=line+1
3890 cpx #25 ; does screen need to be rolled upprint
3900 bne nowrap ; no
3910 sty char ; zero char as a rollup flag
3920 nowrap clc ; reset column to new tab stop
3930 jsr ploth
3940 lda char ; is char zero (rollup required)print
3950 bne tabret ; no
3960 lda #$11 ; print cursor down to do rollup
3970 jsr chrouth
3980 tabret rts
3990 nottab brk ; error - there should be no other specials
4000 ;
4010 ; subroutine - clean up the c64 text editor flags for clean operation
4020 ;
4030 cleanup lda #$84 ; flag 2nd line as unlinked for good rollup
4040 sta ldtb1+1
4050 lda #$00 ; flag no-quote mode
4060 sta qtsw
4070 rts
4080 ;
4090 ; subroutine - try to get a keyboard byte
4100 ;
4110 getkb jsr getin ; get a keyboard character
4120 cmp #0 ;"is there a character ?
4130 bne kbchar ; yes
4140 rts ; return "eq" if no character
4150 kbchar cmp #$83 ;"is it "shift/run/stop" ?
4160 bne kbsw ; no
4170 jsr end ; yes, terminate program
4180 kbsw cmp #$9e ;"is it ^8 ?
4190 bne kbsw2 ; no
4200 jsr restore ; restore everything
4210 lda #"8" ; set 80 column flag
4220 sta digcol ; and 80 column message digit
4230 kbsw1 sta flag80
4240 pla ; fix stack pointer
4250 pla
4260 jmp init ; restart program in new mode
4270 kbsw2 cmp #$9f ;"is it ^4 ?
4280 bne kbret ; no
4290 jsr restore ; restore everything
4300 lda #"4" ; set 40 column message digit
4310 sta digcol
4320 lda #0 ; clear 80 column flag
4330 beq kbsw1 ; via common code
4340 kbret sta char ; save in char
4350 rts
4360 ;
4370 ; subroutine - blink the cursor
4380 ;
4390 docurs dec loopcnt ; decrement timer
4400 beq blinkit ;"expired ?
4410 rts ; no
4420 blinkit lda flag80 ;"80 column mode ?
4430 beq b40 ; no
4440 ;
4450 lda cflag ;"must we save state of current character ?
4460 beq nosave ; no
4470 ldy #0 ; fetch top byte of char
4480 lda (pnth),y
4490 and hilo ; isolate nibble under cursor
4500 sta cstate ; save this state
4510 sty cflag ; clear flag
4520 nosave ldy #8-1 ; must reverse 8 bytes
4530 bloop lda (pnth),y ; fetch hires byte
4540 eor hilo ; reverse nibble under cursor
4550 sta (pnth),y ; replace hires byte
4560 dey
4570 bpl bloop ; loop 8 times
4580 bmi bcom ; go to common code
4590 ;
4600 b40 ldy pntr ; fetch column displacement of cursor
4610 lda (pnt),y ; fetch screen byte under cursor
4620 eor #$80 ; reverse it's current state
4630 sta (pnt),y ; store back in screen
4640 clc ; compute corresponding color ram address
4650 lda pnt+1 ; because c64 "user" is unreliable
4660 adc #>(colram-vidmat4)
4670 sta source+1
4680 lda pnt
4690 sta source
4700 lda fgbg4 ; get color code for fgnd
4710 lsr a
4720 lsr a
4730 lsr a
4740 lsr a
4750 sta (source),y ; into color ram
4760 ;
4770 bcom lda loopmax ; reset timer
4780 sta loopcnt
4790 lda #0 ; reset sound from beep routine
4800 sta wave
4810 rts
4820 ;
4830 ; subroutine - initiate sounds (beeps) - will be terminated next cursor bl
4840 ;
4850 beeplo lda #$14 ; select low frequency
4860 bne beep
4870 beephi lda #$50 ; select high frequency
4880 beep sta freqhi
4890 lda #$0f ; select fast attack, slow decay
4900 sta attdec
4910 lda #$12 ; select sustain ...
4920 sta susrel
4930 lda #6 ; select not-too-loud volume
4940 sta vol
4950 lda #$21 ; select sawtooth wave
4960 sta wave
4970 lda loopmax ; reset cursor timer for consistent beep time
4980 sta loopcnt
4990 rts
5000 ;
5010 ; subroutine - downline load output from 6502 assembler until ^^
5020 ;
5030 dload lda #0 ; initialize
5040 sta ndig ; number of digits read
5050 sta dest ; clear load base address
5060 sta dest+1
5070 dget lda ndx ; begin line loop - check keyboard
5080 bne dbreak ; any key terminates load
5090 jsr getrs ; get rs-232 byte
5100 bne dget ; if none, keep waiting
5110 lda char ; get ascii character
5120 cmp #$1e ; ^^ (terminate load)print
5130 bne noterm ; no
5140 dbreak rts ; yes, return
5150 noterm cmp #$0a ; line feedprint
5160 beq dload ; yes, new line restarts load process
5170 jsr chekdig ; convert character to digit
5180 bmi dget ; not a digit, ignore
5190 inc ndig ; increment digit count
5200 lda ndig ; check digit count
5210 cmp #3 ; first or secondprint
5220 bpl ndlo ; no
5230 jsr dlo ; yes, update destination low
5240 clc ; loop for next character
5250 bcc dget
5260 ndlo cmp #5 ; third or fourthprint
5270 bpl ndhi ; no
5280 jsr dhi ; yes, update destination high
5290 clc ; loop for next character
5300 bcc dget
5310 ndhi jsr putdat ; must be data, go store it
5320 clc ; loop for next character
5330 bcc dget
5340 ;
5350 ; subroutine - a a hex digit, return binary value (also in char), else -1
5360 ;
5370 chekdig sec ; convert decimal digit to binary
5380 sbc #"0"
5390 bmi ckbad ; below 0, not a digit
5400 cmp #9+1 ; is it a decimal digitprint
5410 bmi ckgood ; yes, return binary
5420 sec ; convert hex digit to binary
5430 sbc #"a"-"0"-10
5440 cmp #$a
5450 bmi ckbad ; below "A", not a digit
5460 cmp #$f+1 ; is it a hex digitprint
5470 bpl ckbad ; no, too high
5480 ckgood sta char ; return good digit value
5490 lda char
5500 rts
5510 ckbad lda #-1 ; return -1 (not digit)
5520 rts
5530 ;
5540 ; subroutine - dest(low) = 16*dest(low)+char
5550 ;
5560 dlo lda dest ; dest low
5570 asl a ; multiply by 16
5580 asl a
5590 asl a
5600 asl a
5610 ora char ; combine with char
5620 sta dest ; update dest low
5630 rts
5640 ;
5650 ; subroutine - dest(high) = 16*dest(high)+char
5660 ;
5670 dhi lda dest+1 ; dest high
5680 asl a ; multiply by 16
5690 asl a
5700 asl a
5710 asl a
5720 ora char ; combine with char
5730 sta dest+1 ; update dest high
5740 rts
5750 ;
5760 ; subroutine - put data into memory at dest
5770 ;
5780 putdat lda ndig ; which digitprint
5790 and #1 ; odd or evenprint
5800 bne podd ; odd, just go stash char
5810 lda source ; even, get stashed data
5820 asl a ; multiply by 16
5830 asl a
5840 asl a
5850 asl a
5860 ora char ; combine with char
5870 ldy #0 ; store data into memory
5880 sta (dest),y
5890 inc dest ; increment destination
5900 bne samehi
5910 inc dest+1
5920 samehi rts
5930 podd lda char ; stash char
5940 sta source ; temporarily in source
5950 rts
5960 ;
5970 .file 08,"0:term.2"
@//E*O*F term.1//
chmod u=rw,g=,o= term.1
echo x - term.2
sed 's/^@//' > "term.2" <<'@//E*O*F term.2//'
100 ;
110 ; term.plus.64.2
120 ;
130 ; last date 870102
140 ;
150 ; subroutine - map vic into appropriate bank and set up addresses
160 ;
170 revic lda ddrpa2 ; ensure bank select bits are outputs
180 ora #$03
190 sta ddrpa2
200 lda flag80 ; 80 column modeprint
210 beq re40 ; no
220 ;
230 lda dpa2 ; set vic bank to 1
240 and #$fc
250 ora #$02
260 sta dpa2
270 lda #$78 ; set vic screen to $5c00, hires to $6000
280 sta vmcr
290 lda vcr ; turn on hires mode
300 ora #$20
310 sta vcr
320 rts
330 ;
340 re40 lda dpa2 ; set vic bank to 2
350 and #$fc
360 ora #$01
370 sta dpa2
380 lda vmcr ; set vic screen to $b400
390 and #$0f
400 ora #$d0
410 sta vmcr
420 lda #$b4 ; tell kernel screen is at $b400
430 sta hibase
440 rts
450 ;
460 ; subroutine - restore everything and terminate program
470 ;
480 end jsr restore ; restore everything to default state
490 pla ; fix up stack pointer
500 pla
510 pla
520 pla
530 ldx #16 ; move 16 byte term/reentry code to $2a7
540 eloop lda term-1,x
550 sta unused-1,x
560 dex
570 bne eloop
580 jmp unused ; exit now through term code at $2a7
590 ;
600 ; subroutine - restore everything to default state
610 ;
620 restore lda #5 ; close rs-232 channel
630 jsr close
640 lda vcr ; turn off hires mode if on
650 and #$df
660 sta vcr
670 lda #$14 ; set vic memory control reg to default
680 sta vmcr
690 lda dpa2 ; map vic back to bank 0
700 ora #$03
710 sta dpa2
720 lda #$04 ; tell kernel screen is at $0400
730 sta hibase
740 lda #$93 ; clear the screen
750 jsr chrouth
760 ldx #0
770 stx flag79 ; restore flags to their initial state
780 stx suspend
790 stx fxoff
800 dex
810 stx cflag
820 rts
830 ;
840 ; subroutine - process escape sequences
850 ;
860 escseq sec ; get cursor coordinates
870 jsr ploth
880 sty xcoord
890 stx ycoord
900 lda escflag ; if escflag still esc, char is
910 cmp #$1b ; a function code
920 beq fcode
930 ;
940 ; process cursor coordinates following ^[y
950 ;
960 lda char ; put char-$20 into y coordinate if
970 sec ; escflag=2, x coordinate if
980 sbc #$20 ; escflag=1
990 dec escflag
1000 ldy escflag
1010 sta xcoord,y
1020 ldy xcoord ; move cursor to new position
1030 ldx ycoord
1040 clc
1050 jsr ploth
1060 rts
1070 ;
1080 ; process ^[a (cursor up)
1090 ;
1100 fcode lda char ; process escape function codes
1110 cmp #"a" ;"cursor up ?
1120 bne notup ; no
1130 up lda #$91 ; yes - print cursor up
1140 print jsr chrouth
1150 return lda #0 ; reset escape flag
1160 sta escflag
1170 rts
1180 ;
1190 ; process ^[b (cursor down)
1200 ;
1210 notup cmp #"b" ;"cursor down ?
1220 bne notdn ; no
1230 cpx #24 ; at bottom marginprint
1240 beq return ; yes
1250 lda #$11 ; print cursor down
1260 bne print
1270 ;
1280 ; process ^[c (cursor right)
1290 ;
1300 notdn cmp #"c" ;"cursor right ?
1310 bne notrt ; no
1320 lda flag80 ; 80 column mode
1330 bne rt80 ; yes, skip next check
1340 cpy #39 ; at right margin
1350 beq return ; yes
1360 rt80 cpy #79 ; at right marginprint
1370 beq return ; yes
1380 lda #$1d ; print cursor right
1390 bne print
1400 ;
1410 ; process ^[d (cursor left)
1420 ;
1430 notrt cmp #"d" ;"cursor left ?
1440 bne notlft ; no
1450 cpy #0 ;"at left margin ?
1460 beq return ; yes
1470 lf80 lda #$9d ; print cursor left
1480 bne print
1490 ;
1500 ; process ^[h (cursor home)
1510 ;
1520 notlft cmp #"h" ;"cursor home ?
1530 bne nothome ; no
1540 lda #$13 ; print cursor home
1550 bne print
1560 ;
1570 ; process ^[o (reverse video)
1580 ;
1590 nothome cmp #"o"+$20 ;"reverse video ?
1600 bne notrev ; no
1610 lda #$12 ; print reverse on
1620 bne print
1630 ;
1640 ; process ^[n (normal video)
1650 ;
1660 notrev cmp #"n"+$20 ;"normal video ?
1670 bne notnorm ; no
1680 lda #$92 ; print reverse off
1690 bne print
1700 ;
1710 ; process ^[i (reverse line feed)
1720 ;
1730 notnorm cmp #"i" ;"reverse line feed ?
1740 beq yesrlf ; yes
1750 jmp notrlf ; no
1760 yesrlf cpx #0 ; at top marginprint
1770 bne up ; no - use normal cursor up
1780 lda flag80 ; 80 column modeprint
1790 beq rlf40 ; no
1800 ;
1810 lda #<(hires+$1e00-$100) ; source pointer
1820 sta source
1830 lda #>(hires+$1e00-$100)
1840 sta source+1
1850 lda #<(hires+$1f40-$100) ; destination pointer
1860 sta dest
1870 lda #>(hires+$1f40-$100)
1880 sta dest+1
1890 ldx #$1e ; 1e00 bytes must be moved
1900 ldy #0
1910 rfloop1 lda (source),y ; begin both outer and inner move loops
1920 sta (dest),y
1930 iny
1940 lda (source),y ; this is replicated to gain speed
1950 sta (dest),y
1960 iny
1970 lda (source),y ; this is replicated to gain speed
1980 sta (dest),y
1990 iny
2000 lda (source),y ; this is replicated to gain speed
2010 sta (dest),y
2020 iny
2030 bne rfloop1 ; end inner loop to move $100 bytes
2040 dec source+1
2050 dec dest+1
2060 dex
2070 bne rfloop1 ; end outer loop to do inner loop $1e times
2080 tya
2090 rfloop2 sta (dest),y ; now clear next 256 bytes back
2100 iny
2110 bne rfloop2
2120 dec dest+1
2130 ldy #$c0 ; last, clear first 64 hires bytes
2140 rfloop3 sta (dest),y
2150 iny
2160 bne rfloop3
2170 jmp retesc
2180 ;
2190 rlf40 lda #<(vidmat4+999-40)
2200 sta source ; source = address of last byte to move
2210 sta dest ; dest = corresponding color ram address
2220 lda #>(vidmat4+999-40)
2230 sta source+1
2240 lda #>(colram+999-40)
2250 sta dest+1
2260 ldy #40 ; distance to be moved
2270 ldx #0 ; inhibit x indexing
2280 rlfloop lda (source,x) ; move a character to next line
2290 sta (source),y
2300 lda #$01 ; color code for white
2310 sta (dest),y ; into corresponding color ram addr
2320 dec source ; decrement source addresses
2330 dec dest
2340 lda source
2350 cmp #$ff
2360 bne rlf1
2370 dec source+1
2380 dec dest+1
2390 rlf1 lda source ; screen all movedprint
2400 cmp #<(vidmat4-1)
2410 bne rlfloop ; no
2420 lda source+1 ; screen all movedprint
2430 cmp #>(vidmat4-1)
2440 bne rlfloop ; no
2450 lda #$20 ; screen code for space
2460 bfloop sta vidmat4-1,y ; set first line to all spaces
2470 dey
2480 bne bfloop
2490 jmp retesc
2500 ;
2510 ; process ^[k (clear to end of line)
2520 ;
2530 notrlf cmp #"k" ;"clear to end of line ?
2540 bne noteol ; no
2550 lda flag80 ;"80 column mode ?
2560 beq eol40 ; no
2570 ;
2580 jsr hceol ; do the clear
2590 jmp retesc
2600 ;
2610 eol40 lda #$20 ; screen code for space
2620 ldy pntr ; get displacement from pnt
2630 eoloop sta (pnt),y ; store a space
2640 iny ; next logical column
2650 cpy #40 ; end of physical lineprint
2660 beq retesc ; yes
2670 cpy #80 ; end of physical lineprint
2680 beq retesc ; yes
2690 bne eoloop ; no, keep clearing
2700 ;
2710 ; process ^[j (clear to end of screen)
2720 ;
2730 noteol cmp #"j" ;"clear to end of screen ?
2740 bne noteos ; no
2750 lda flag80 ;"80 column mode ?
2760 beq eos40 ; no
2770 ;
2780 jsr hclear ; clear to end of screen
2790 jmp retesc
2800 ;
2810 eos40 lda pntr ; put cursor screen memory address
2820 clc ; (pnt+pntr) into dest
2830 adc pnt
2840 sta dest
2850 lda #0
2860 adc pnt+1
2870 sta dest+1
2880 lda #$20 ; screen code for space
2890 ldy #0 ; inhibit indexing
2900 eosloop sta (dest),y ; store a space
2910 inc dest ; increment screen address
2920 bne eos1
2930 inc dest+1
2940 eos1 ldx dest ; end of screenprint
2950 cpx #<(vidmat4+1000)
2960 bne eosloop ; no
2970 ldx dest+1 ; end of screenprint
2980 cpx #>(vidmat4+1000)
2990 bne eosloop ; no
3000 beq retesc
3010 ;
3020 ; process ^[y (cursor motion initiate)
3030 ;
3040 noteos cmp #"y" ;"cursor motion ?
3050 bne notcm ; no
3060 lda #2 ; set escflag to 2 so next 2
3070 sta escflag ; chars will be processed as
3080 rts ; coordinates
3090 ;
3100 ; process ^[z (identify <vt-52> terminal)
3110 ;
3120 notcm cmp #"z" ;"identify terminal ?
3130 bne notid ; no
3140 ldx #5 ; change kernel output
3150 jsr chkout ; to rs-232
3160 lda #$1b ; output esc
3170 jsr chrout
3180 lda #"/" ; output /
3190 jsr chrout
3200 lda #"z" ; output z
3210 jsr chrout
3220 ldx #0 ; restore kernel output
3230 jsr chkout ; to screen
3240 clc
3250 bcc retesc
3260 ;
3270 ; process ^[^\ (initiate downline load)
3280 ;
3290 notid cmp #$1c ; downline loadprint
3300 bne retesc ; no
3310 jsr dload ; do download
3320 retesc lda #0 ; no other functions
3330 sta escflag ; clear escape flag
3340 rts
3350 ;
3360 ; subroutine - hires screen print (but use chrout if 40 column mode)
3370 ;
3380 chrouth ldx flag80 ;"80 column mode ?
3390 bne cho80 ; yes
3400 jsr chrout
3410 rts
3420 cho80 cmp #$00 ; no-ops (0,1) are ignored
3430 beq hret4
3440 cmp #$01
3450 beq hret4
3460 ldy flag79 ; copy special column 79 flag to one-shot
3470 sty flag79t
3480 ldy #0 ; then clear the main flag
3490 sty flag79
3500 cmp #$13 ; cursor homeprint
3510 bne hnhome ; no
3520 ;
3530 ; process home code
3540 ;
3550 hhome lda #<hires ; reset cursor variables to home position
3560 sta pnth
3570 lda #>hires
3580 sta pnth+1
3590 lda #$f0
3600 sta hilo
3610 lda #0
3620 sta lineh
3630 sta colh
3640 hret4 rts
3650 ;
3660 ; process clear code
3670 ;
3680 hnhome cmp #$93 ; clear screenprint
3690 bne hnclear ; no
3700 jsr hhome ; first home the cursor
3710 jsr hclear ; then clear to end of screen
3720 rts
3730 ;
3740 ; process cursor left code
3750 ;
3760 hnclear cmp #$9d ; cursor leftprint
3770 bne hnleft ; no
3780 lda colh ; get column
3790 bne hncol0 ; column zero check
3800 lda lineh ; column zero case, get line
3810 beq hret1 ; line zero also so it's a no-op
3820 dec lineh ; decrement line
3830 lda #79 ; column=79
3840 sta colh
3850 bne hcom1
3860 hncol0 dec colh ; not column zero, just decrement column
3870 hcom1 lda hilo ; get hilo mask
3880 eor #$ff ; reverse it
3890 sta hilo
3900 cmp #$0f ; previous hires byteprint
3910 bne hret1 ; no
3920 lda pnth ; decrement hires pointer by 8
3930 sec
3940 sbc #8
3950 sta pnth
3960 lda pnth+1
3970 sbc #0
3980 sta pnth+1
3990 hret1 rts
4000 ;
4010 ; process cursor up code
4020 ;
4030 hnleft cmp #$91 ; cursor upprint
4040 bne hnup ; no
4050 lda lineh ; get line
4060 beq hret2 ; line zero is no-op
4070 dec lineh ; decrement line
4080 lda pnth ; decrement hires pointer by 320
4090 sec
4100 sbc #$40
4110 sta pnth
4120 lda pnth+1
4130 sbc #$01
4140 sta pnth+1
4150 hret2 rts
4160 ;
4170 ; process cursor down code
4180 ;
4190 hnup cmp #$11 ; cursor downprint
4200 bne hndown ; no
4210 lda lineh ; get line
4220 cmp #24 ; bottom lineprint
4230 beq hrollup ; yes, rollup required
4240 inc lineh ; increment line
4250 lda pnth ; increment hires pointer by 320
4260 clc
4270 adc #$40
4280 sta pnth
4290 lda pnth+1
4300 adc #$01
4310 sta pnth+1
4320 rts
4330 hrollup lda #<(hires+$140) ; source points to hires line 1
4340 sta source
4350 lda #>(hires+$140)
4360 sta source+1
4370 lda #<hires ; dest points to hires line 0
4380 sta dest
4390 lda #>hires
4400 sta dest+1
4410 ldx #$1e ; 1e0 bytes must be moved
4420 ldy #0
4430 hloop1 lda (source),y ; begin both outer and inner move loops
4440 sta (dest),y
4450 iny
4460 lda (source),y
4470 sta (dest),y
4480 iny
4490 lda (source),y
4500 sta (dest),y
4510 iny
4520 lda (source),y
4530 sta (dest),y
4540 iny
4550 bne hloop1 ; end inner loop to move $100 bytes
4560 inc source+1
4570 inc dest+1
4580 dex
4590 bne hloop1 ; end outer loop to do inner loop $1e times
4600 tya ; now clear next 256 hires bytes
4610 hloop2 sta (dest),y
4620 iny
4630 bne hloop2
4640 inc dest+1
4650 hloop3 sta (dest),y ; then the last 64 bytes
4660 iny
4670 cpy #$41
4680 bne hloop3
4690 rts
4700 ;
4710 ; process cursor right code
4720 ;
4730 hndown cmp #$1d ; cursor rightprint
4740 bne hnrt ; no
4750 hright lda colh ; get column
4760 cmp #79 ; at column 79print
4770 bne hncol79 ; no
4780 lda lineh ; get line
4790 cmp #24 ; at line 24print
4800 beq heos ; yes, treat end of screen special
4810 inc lineh ; increment line
4820 lda #0 ; column=0
4830 sta colh
4840 beq hcom2
4850 hncol79 inc colh ; not column 79, just increment column
4860 hcom2 lda hilo ; get hilo mask
4870 eor #$ff ; reverse it
4880 sta hilo
4890 cmp #$f0 ; next hires byteprint
4900 bne hret3 ; no
4910 lda pnth ; increment hires pointer by 8
4920 clc
4930 adc #8
4940 sta pnth
4950 lda pnth+1
4960 adc #0
4970 sta pnth+1
4980 hret3 rts
4990 heos lda #0 ; set column to zero
5000 sta colh
5010 lda #$f0 ; set hilo mask to upper nibble
5020 sta hilo
5030 lda pnth ; decrement hires pointer by $138
5040 sec
5050 sbc #$38
5060 sta pnth
5070 lda pnth+1
5080 sbc #$01
5090 sta pnth+1
5100 jmp hrollup ; complete by rolling up
5110 ;
5120 ; process reverse on code
5130 ;
5140 hnrt cmp #$12 ; reverse videoprint
5150 bne hnrev ; no
5160 lda #$0f ; set reverse mask
5170 sta revmask
5180 rts
5190 ;
5200 ; process reverse off code
5210 ;
5220 hnrev cmp #$92 ; normal videoprint
5230 bne hnnorm ; no
5240 lda #0 ; clear reverse mask
5250 sta revmask
5260 rts
5270 ;
5280 ; process printing character codes
5290 ;
5300 hnnorm sta ccode ; stash character code for later
5310 lda colh ; special column 79 treatment
5320 cmp #79 ; at column 79print
5330 bne not79 ; no
5340 lda flag79t ; was previous char printed at col 79print
5350 beq notf79 ; no
5360 jsr hright ; move cursor right to col 0 of next line
5370 clc
5380 bcc not79
5390 notf79 inc flag79 ; set flag, this char will print at 79
5400 not79 lda ccode ; get character code previously saved
5410 sec ; subtract $20 from character code
5420 sbc #$20
5430 sta source ; temporarily save code
5440 lsr a ; high of (code*8)
5450 lsr a
5460 lsr a
5470 lsr a
5480 lsr a
5490 sta source+1 ; source+1=high font displacement
5500 lda source ; low of (code*8)
5510 asl a
5520 asl a
5530 asl a
5540 clc
5550 adc #<font ; set source=desired font address
5560 sta source
5570 lda source+1
5580 adc #>font
5590 sta source+1
5600 ldy #8-1 ; move the font into a hires nibble
5610 hxloop lda (source),y
5620 eor revmask ; reverse font pattern if necessary
5630 tax
5640 lda hilo ; test to see which nibble
5650 cmp #$f0 ; upper nibbleprint
5660 bne hnoshft ; no
5670 txa
5680 asl a ; shift font byte into high nibble
5690 asl a
5700 asl a
5710 asl a
5720 tax
5730 hnoshft lda hilo ; change hilo mask
5740 eor #$ff ; into a mask to preserve other nibble
5750 and (pnth),y ; now preserve that nibble
5760 sta dest ; and temporarily save
5770 txa ; get new font nibble
5780 ora dest ; combine with other nibble
5790 sta (pnth),y ; replace hires screen byte
5800 dey
5810 bpl hxloop ; repeat for 8 bytes
5820 lda flag79 ; should cursor be moved right 1print
5830 bne skiprt ; no, column 79 just printed
5840 jmp hright ; finish by moving right 1 column
5850 skiprt rts
5860 ;
5870 ; subroutine - clear from cursor to end of hires screen
5880 ;
5890 hclear jsr hclunc ; first clear under cursor if necessary
5900 lda #<(hires+$1f40) ; compute number of bytes to clear
5910 sec
5920 sbc dest
5930 sta source ; temp save low byte of count
5940 lda #>(hires+$1f40)
5950 sbc dest+1 ; high byte of count=0print
5960 hclr2 beq lastfew ; yes
5970 tax ; x*$100 bytes need to be cleared first
5980 lda #0
5990 tay
6000 hcloop2 sta (dest),y ; begin both outer and inner clear loops
6010 iny
6020 bne hcloop2 ; end inner loop to clear $100 bytes
6030 inc dest+1
6040 dex
6050 bne hcloop2 ; end outer loop to do inner loop x times
6060 lastfew ldy source ; lastly, clear "low count byte" bytes
6070 beq hclret ; really nothing more to clear!
6080 dey
6090 hcloop3 sta (dest),y ; begin clear loop for all but 1 byte
6100 dey
6110 bne hcloop3 ; end clear loop for all but 1 byte
6120 sta (dest),y ; clear the remaining byte
6130 hclret rts
6140 ;
6150 ; subroutine - hires clear from cursor to end of line
6160 ;
6170 hceol jsr hclunc ; clear under cursor if necessary
6180 ldx colh ; compute 40-((colh+1)/2)
6190 inx
6200 txa
6210 lsr a
6220 sta source ; temp save
6230 lda #40
6240 sec
6250 sbc source
6260 sta source+1 ; temp save result of calculation
6270 asl a
6280 asl a
6290 asl a
6300 sta source ; source=low byte of count to be cleared
6310 lda source+1
6320 lsr a ; compute high byte of count to be cleared
6330 lsr a
6340 lsr a
6350 lsr a
6360 lsr a
6370 clc
6380 bcc hclr2 ; share code in hclear from here on
6390 ;
6400 ; subroutine - hires clear under cursor if cursor in odd column
6410 ;
6420 hclunc lda pnth ; make dest point to current byte
6430 sta dest
6440 lda pnth+1
6450 sta dest+1
6460 lda colh ; is the column number
6470 and #1 ; evenprint
6480 beq evencol ; yes
6490 ldx #8 ; clear low nibble of 8 bytes under cursor
6500 ldy #0 ; while incrementing dest by 8
6510 hcloop1 lda (dest),y ; begin 8 byte clear loop
6520 and #$f0
6530 sta (dest),y
6540 inc dest
6550 bne hc1
6560 inc dest+1
6570 hc1 dex
6580 bne hcloop1 ; end of 8 byte clear loop
6590 evencol rts
6600 ;
6610 ; subroutine - hires plot (but use plot if 40 column mode)
6620 ;
6630 ploth bcc pset ; carry clear means go set coordinates
6640 lda flag80 ; 80 column modeprint
6650 bne fetch80 ; yes
6660 jsr plot ; use commodore plot function
6670 tya
6680 cmp #40 ; is column >= 40print
6690 bmi plret ; no
6700 sec ; subtract 40
6710 sbc #40
6720 plret tay ; return the 40 column coordinates
6730 rts
6740 fetch80 ldx lineh ; fetch 80 column coordinates
6750 ldy colh
6760 rts
6770 pset cpx #0 ; line < 0print
6780 bpl ps1 ; no
6790 ldx #0 ; set line to 0
6800 ps1 cpx #25 ; line >= 25print
6810 bmi ps2 ; no
6820 ldx #24 ; set line to 24
6830 ps2 cpy #0 ; column < 0print
6840 bpl ps3 ; no
6850 ldy #0 ; set column to 0
6860 ps3 lda flag80 ; 80 column modeprint
6870 bne test80 ; yes
6880 cpy #40 ; column >= 40print
6890 bmi ps4 ; no
6900 ldy #39 ; set column to 39
6910 ps4 clc ; set cursor coordinates
6920 jsr plot ; using commodore plot
6930 rts
6940 test80 cpy #80 ; column >= 80print
6950 bmi hset ; no
6960 ldy #79 ; set column to 79
6970 hset stx lineh ; set cursor position
6980 sty colh
6990 tya ; derive new hilo mask
7000 ldy #$f0 ; hilo mask for upper nibble
7010 and #1 ; check low column bit
7020 beq hupper ; even columns use high nibble
7030 ldy #$0f ; hilo mask for lower nibble
7040 hupper sty hilo ; set up hilo
7050 lda #<hires ; compute new hires screen pointer
7060 sta pnth ; assume home position
7070 lda #>hires
7080 sta pnth+1
7090 cpx #0 ; line zeroprint
7100 beq hatline ; yes
7110 hploop lda pnth ; add $140 to pointer once for each line
7120 clc
7130 adc #$40
7140 sta pnth
7150 lda pnth+1
7160 adc #$01
7170 sta pnth+1
7180 dex
7190 bne hploop ; loop for all lines
7200 hatline lda colh ; get column
7210 lsr a ; divide by 2
7220 asl a ; multiply by 8
7230 asl a
7240 asl a
7250 bcc nocarry ; carry from shiftsprint
7260 inc pnth+1 ; yes, propogate the carry
7270 nocarry clc ; add rest of col/2*8 to pointer
7280 adc pnth
7290 sta pnth
7300 lda pnth+1
7310 adc #0
7320 sta pnth+1
7330 lda #0 ; clear column 79 flag
7340 sta flag79
7350 rts
7360 ;
7370 ; subroutine - send out ^s (xoff) to remote host
7380 ;
7390 xoff ldx #5 ; switch kernel to rs-232 output
7400 stx fxoff ; set xoff flag
7410 jsr chkout
7420 jsr optimum ; wait until optimum time
7430 lda #$13 ; then, transmit ^s
7440 xcom jsr chrout
7450 ldx #0 ; restore kernel output to screen
7460 jsr chkout
7470 rts
7480 ;
7490 ; subroutine - send out ^q (xon) to remote host
7500 ;
7510 xon lda #0 ; clear xoff flag
7520 sta fxoff
7530 ldx #5 ; switch kernel to rs-232 output
7540 jsr chkout
7550 lda #$11 ; transmit ^q
7560 bne xcom
7570 ;
7580 ; subroutine - wait for optimum time to transmit an rs-232 character
7590 ;
7600 optimum lda bitci ; rs-232 input bit count
7610 cmp #7 ; wait until count is not 7
7620 beq optimum
7630 ldx time+2 ; set x to 2 jiffys in the future
7640 inx
7650 inx
7660 opti2 lda bitci ; wait until rs-232 bit count
7670 cmp #7 ; equals 7
7680 beq optiret
7690 cpx time+2 ; or until 2 jiffys have expired
7700 bne opti2
7710 optiret rts
7720 ;
7730 ; subroutine - write initial message to screen
7740 ;
7750 welcome lda flag80 ; 80 column modeprint
7760 beq welprnt ; no
7770 ldy #20 ; write 20 extra spaces to screen
7780 sty welcnt
7790 padloop lda #" " ; this padding will center message
7800 jsr chrouth
7810 dec welcnt
7820 bne padloop
7830 welprnt ldy #0 ; initial message index
7840 weloop sty welcnt ; save message counter
7850 lda welmsg,y ; get message character
7860 beq welret ; done when 0 character found
7870 jsr chrouth ; output the character
7880 ldy welcnt ; retrieve counter
7890 iny ; increment to get next char index
7900 bne weloop ; loop for more characters
7910 welret clc ; now move cursor to line 3, col 0
7920 ldy #0
7930 ldx #3
7940 jsr ploth
7950 rts ; all done
7960 ;
7970 .file 08,"0:term.font"
@//E*O*F term.2//
chmod u=rw,g=,o= term.2
echo x - term.doc
sed 's/^@//' > "term.doc" <<'@//E*O*F term.doc//'
100 n$="0:term.plus.o":open 15,8,15,"s"+n$:close 15:open 1,8,1,n$
110 sys 1000
120 .opt o1
130 ;
140 ; term.plus.64.doc
150 ;
160 ; origion version by frank prindle using the cbm assembler.
170 ; converted by g. r. (fred) walter to assemble using pal.
180 ;
190 ; last date 870102
200 ;
210 ;"This program makes the Commodore 64 operate like a semi-
220 ;"intellegent 40 or 80 column ascii terminal. It supports input
230 ;"and display of all the ASCII characters, and beeps when the BEL
240 ;"character is received. Beware that the 80 column display mode
250 ;"will probably require a monitor unless you are using a B/W
260 ;"TV set with outstanding sharpness and video bandwidth.
270 ;
280 ;"The communication protocol is full duplex, 8 bits, no
290 ;"parity, 1 stop bit, 300 or 1200 baud, with XON/XOFF (DC1/
300 ;"DC3) host flow control protocol -- this should satisfy most
310 ;"host computers. The display screen is 40 columns X 25 lines
320 ;"or 80 columns X 25 lines.
330 ;
340 ;"Because of the unusual layout of the C64 keyboard, the
350 ;"desire to support all ascii characters, and a personal
360 ;"need to find the ESC and BS keys in their usual positions,
370 ;"the following key substitutions apply (note- ^x is short-
380 ;"hand for CONTROL-x):
390 ;
400 ;" TO SEND TYPE really is
410 ;" ------- ---- ---------
420 ;" \ BRITISH-POUND backslash
430 ;" ^\ ^BRITISH-POUND ctrl backslash
440 ;" ^[164] ^= ctrl underscore
450 ;" ^ UP-ARROW up-arrow
460 ;" ^^ ^UP-ARROW ctrl up-arrow
470 ;" ^[ (ESC) ^[ or BACK-ARROW escape
480 ;" [164] f1 underscore
490 ;" [C=*] f2 pipe
500 ;" [SHIFT_@] f3 backwards '
510 ;" [175] f4 tilde
520 ;" [SHIFT_+] f5 left curly bracket
530 ;" [SHIFT_-] f6 right curly bracket
540 ;" DEL (RUB) f7 delete
550 ;" ^T f8 ctrl t
560 ;" ^H (BS) DEL, ^H, or ^T backspace
570 ;" ^J (NL) SHIFT/RETURN or ^J newline
580 ;" ^S (DC3) ^S or HOME
590 ;" ^Q (DC1) ^Q or CURSOR DOWN
600 ;" ^I (TAB) ^I (ie. No separate TAB key)
610 ;
620 ;"The CONTROL-8 key is used to switch the program from 40 column
630 ;"to 80 column mode. The CONTROL-4 key is used to switch the
640 ;"program back from 80 column to 40 column mode. Depressing one
650 ;"of these keys when already in the corresponding mode will simply
660 ;"clear the screen (as it does when switching modes).
670 ;
680 ;"Note that pressing the COMMODORE key will place the terminal
690 ;"program in a suspended display mode (ie. the cursor will freeze
700 ;"at it's current position), and ^S will be sent to the host
710 ;"computer when the RS-232 input buffer fills up. Similarly,
720 ;"pressing the COMMODORE key will remove the terminal from the
730 ;"suspended display mode and send a ^Q to the host computer only
740 ;"if a ^S had previously been sent and the buffer has become nearly
750 ;"empty. This enables the COMMODORE key to be used like the SCROLL/
760 ;"NO-SCROLL key on DEC terminals. Suspended display mode is
770 ;"indicated to the user by the cursor blinking much faster than
780 ;"normal, an indication that the COMMODORE key must be pressed to
790 ;"resume displaying the received text. The program may also send
800 ;"^S and ^Q to the host computer on it's own from time to time if
810 ;"it detects an impending RS-232 buffer overflow condition - this
820 ;"normally will only occur while printing a number of short or blank
830 ;"lines while scrolling the screen up (or down), since 4 to 15 char-
840 ;"acters are received into the RS-232 buffer during the time it
850 ;"takes to scroll the whole screen. In any case, this automatic
860 ;"flow control is fully synchronized with the flow control
870 ;"necessitated by the use of the COMMODORE key to suspend and resume
880 ;"the display of received text. Depressing the ^S and ^Q keys (or
890 ;"their substitutes indicated above) unconditionally sends those
900 ;"ASCII characters to the remote host computer without any local
910 ;"effect.
920 ;
930 ;"This terminal program does 'not' support flow control in the
940 ;"opposite direction - receiving ^S from the host computer will not
950 ;"lock the keyboard or have any other effect, nor will ^Q.
960 ;
970 ;"Also note that pressing the RUN/STOP key with SHIFT depres-
980 ;"sed will cleanly terminate the terminal emulator program,
990 ;"and generate the BRK interrupt to send the C64 back
1000 ;"to whoever is servicing those interrupts (BASIC,
1010 ;"SUPERMON64,etc).
1020 ;
1030 ;"All 94 printable ascii characters and the space will
1040 ;"be displayed on the screen as received over the RS-232
1050 ;"channel. Most of the remaining (control) characters are
1060 ;"not displayed- however the following control characters
1070 ;"and escape sequences have special effects:
1080 ;"
1090 ;" CHARACTER EFFECT
1100 ;" --------- ------
1110 ;" ^G (BEL) beeps the TV
1120 ;" ^H (BS) cursor backspaces
1130 ;" ^I (TAB) cursor moves right to next tab stop
1140 ;" ^J (NL) cursor moves down one line with scrolling
1150 ;" ^M (CR) cursor moves to start of line
1160 ;" ^[A cursor moves up one line
1170 ;" ^[B cursor moves down
1180 ;" ^[C cursor moves right one char.
1190 ;" ^[D cursor moves left one char.
1200 ;" ^[H cursor homes
1210 ;" ^[I cursor moves up one line with scrolling
1220 ;" ^[J clears from cursor to end of screen
1230 ;" ^[K clears from cursor to end of line
1240 ;" ^[Ylc cursor moves to line l-$20, col c-$20
1250 ;" ^[Z sends DEC VT-52 terminal id string
1260 ;" ^[n (lowercase n) turns off reverse video
1270 ;" ^[o (lowercase o) turns on reverse video
1280 ;" ^[^\ initiates downline load
1290 ;
1300 ;"Tab stops are pre-defined and fixed at every 8 columns
1310 ;"beginning with column 0 (ie. 0, 8, 16, 24, ...).
1320 ;
1330 ;"The rest should all be pretty much self explanatory except
1340 ;"for "downline load". Once the ^[^\ sequence has been re-
1350 ;"ceived, the program expects lines to come in over the RS-
1360 ;"232 channel of the form:
1370 ;
1380 ;" ;llhhdddddddddd...
1390 ;
1400 ;"where "llhh" is the address for the first byte of data
1410 ;"on the line (in 6502 low/high format), and "dddddd.."
1420 ;"are the data bytes themselves - note that the address
1430 ;"must be 4 hexadecimal digits and each data byte must
1440 ;"be 2 hexadecimal digits. The load is terminated normally
1450 ;"by reception of the control character ^^, or abnormally
1460 ;"if the user hits a key on the C64 keyboard during the
1470 ;"load. In the 40 column mode, It is possible to load anywhere
1480 ;"in the address ranges $0800 through $9fff and $c000 through
1490 ;"$cfff since the terminal program itself hides under the BASIC
1500 ;"ROM (from $a000 through $bfff). 80 column mode should not
1510 ;"be used to download into the address range $5c00 through
1520 ;"$7fff because that is where the high resolution video matrix
1530 ;"and screen image reside in that mode.
1540 ;
1550 ;"VAX UNIX users (Berkeley 4.1bsd) will find that the following
1560 ;""termcap" entries effectively describe this terminal program
1570 ;"for use with the terminal dependent UNIX programs (eg. vi,
1580 ;"emacs, more, rogue, etc.):
1590 ;
1600 ;" qc[C=*]c64[C=*]C64[C=*]Commodore 64:co#40:li#25:\
1610 ;" :up=\EA:do=\EB:cl=\EH\EJ:am:bs:\
1620 ;" :bw:ho=\EH:nd=\EC:so=\Eo:\
1630 ;" :se=\En:cm=\EY%+ %+ :\
1640 ;" :ce=\EK:sr=\EI:pt:
1650 ;
1660 ;" qd[C=*]c64w[C=*]C64W[C=*]Commodore 64 80 Col X 25 Lin:co#80:li#25:\
1670 ;" :up=\EA:do=\EB:cl=\EH\EJ:bs:\
1680 ;" :bw:ho=\EH:nd=\EC:so=\Eo:\
1690 ;" :se=\En:cm=\EY%+ %+ :\
1700 ;" :ce=\EK:sr=\EI:pt:
1710 ;
1720 ;"VAX VMS users can probably get away with the following (although
1730 ;"some VMS programs [eg. edt] require an auxilliary keypad, and do
1740 ;"not work especially well in 40 column mode):
1750 ;
1760 ;" set term /dev=vt52
1770 ;" set term /pag=25
1780 ;" set term /wid=80 [or 40, as the case may be]
1790 ;
1800 ;"TOPS-20 users can run "emacs" and the like after the following:
1810 ;
1820 ;" term vt52
1830 ;" term length 25
1840 ;" term width 80 [or 40, as the case may be]
1850 ;" term pause com
1860 ;
1870 ;"A low pitched beep (much lower than that generated by
1880 ;"receipt of the BEL character) indicates an error on the
1890 ;"RS-232 channel (a hit, lost data, etc).
1900 ;
1910 ;"Of course, this program assumes you have been able
1920 ;"to connect a modem (or null modem) to the C64 user
1930 ;"port, which may or may not be trivial!
1940 ;
1950 ;"To run the terminal program, just load it like any BASIC
1960 ;"program and RUN it. You will be prompted for the baud
1970 ;"rate. Enter either 3 or 300 for 300 baud, 12 or 1200
1980 ;"for 1200 baud, or just a carriage return for the default
1990 ;"(300 baud). If you find communications shaky or impos-
2000 ;"sible at 1200 baud, you may have to change the poke in
2010 ;"basic which pokes 0 to poke 8 instead. If this fails to
2020 ;"help, try tuning the optional baud rate constants in 0a4f
2030 ;"and 0a50 for your system clock as described in ref. guide
2040 ;"page 350 (use poke of 0 into 0a4d in this case).
2050 ;
2060 ;"Once it has been run, the terminal program moves itself
2070 ;"under the BASIC ROM and runs there (although the original
2080 ;"copy remains where it was loaded and can be re-run as long
2090 ;"as it remains intact). The memory map at run time is:
2100 ;
2110 ;" $a080-$afff The program area
2120 ;" $b000-$b1ff Unused
2130 ;" $b200-$b2ff RS-232 output buffer
2140 ;" $b300-$b3ff RS-232 input buffer
2150 ;" $b400-$b7ff Video matrix (the 40 column screen)
2160 ;" $b800-$bfff Character set for 40 column mode
2170 ;" $02a7-$02b6 Termination/Restart code
2180 ;
2190 ;"In addition, the following memory areas are used only while the
2200 ;"program is in the 80 column mode:
2210 ;
2220 ;" $5c00-$5fff Video matrix (the 80 column color memory)
2230 ;" $6000-$7fff Hires screen (the 80 column screen)
2240 ;
2250 ;"Once the terminal program has been terminated (with SHIFT/
2260 ;"RUN/STOP), it may be re-started by re-running the original
2270 ;"BASIC program. However, if the BASIC program area has been
2280 ;"over-written during downloading, the terminal program can
2290 ;"still be restarted (at the same baud rate as before) with
2300 ;"the BASIC direct command "(686)" ; this command will
2310 ;"restart the terminal program at any time, even after running
2320 ;"other programs, unless some program is run which pokes
2330 ;"into the areas shown in the first map above.
2340 ;
2350 ;"One last warning: this program is not relocatable - do
2360 ;"not change the *length* of the BASIC program or nothing
2370 ;"will work!
2380 ;
2390 ;"Good Luck and Enjoy....
2400 ;" Frank Prindle
2410 ;
2420 .file 08,"0:term.lables"
@//E*O*F term.doc//
chmod u=rw,g=,o= term.doc
echo x - term.end
sed 's/^@//' > "term.end" <<'@//E*O*F term.end//'
100 ;
110 ; term.plus.64.end
120 ;
130 ; last date 870102
140 ;
150 ; initial message and counter
160 ;
170 welcnt .byte 0 ; counter used for welcome message below
180 welmsg .byte $11:.asc " "
190 .byte "t"+32,"e"+32,"r"+32,"m"+32,"."
200 .byte "p"+32,"l"+32,"u"+32,"s"+32," ","-"," "
210 digcol .byte "4","0"," "
220 .byte "c"+32:.asc "olumn "
230 .byte "m"+32:.asc "ode"
240 .byte 0
250 ;
260 .end 08,"0:term.doc"
@//E*O*F term.end//
chmod u=rw,g=,o= term.end
echo x - term.font
sed 's/^@//' > "term.font" <<'@//E*O*F term.font//'
100 ;
110 ; term.plus.64.font
120 ;
130 ; last date 870102
140 ;
150 ; 80 column font for the 95 printing characters (in c64 ascii order)
160 ;
170 font .byte $0, $0, $0, $0, $0, $0, $0, $0 ; " "
180 .byte $0, $4, $4, $4, $4, $0, $4, $0 ; "!"
190 .byte $0, $a, $a, $0, $0, $0, $0, $0 ; """
200 .byte $0, $2, $a, $e, $a, $e, $a, $8 ; "#"
210 .byte $0, $4, $e, $c, $6, $e, $4, $0 ; "$"
220 .byte $0, $0, $8, $2, $4, $8, $2, $0 ; "%"
230 .byte $0, $4, $a, $a, $4, $a, $5, $0 ; "&"
240 .byte $0, $2, $4, $0, $0, $0, $0, $0 ; "'"
250 .byte $0, $2, $4, $4, $4, $4, $2, $0 ; "("
260 .byte $0, $8, $4, $4, $4, $4, $8, $0 ; ")"
270 .byte $0, $0, $a, $4, $e, $4, $a, $0 ; "*"
280 .byte $0, $0, $0, $4, $e, $4, $0, $0 ; "+"
290 .byte $0, $0, $0, $0, $0, $0, $4, $8 ; ","
300 .byte $0, $0, $0, $0, $e, $0, $0, $0 ; "-"
310 .byte $0, $0, $0, $0, $0, $0, $4, $0 ; "."
320 .byte $0, $2, $2, $4, $4, $8, $8, $0 ; "/"
330 .byte $0, $0, $4, $a, $a, $a, $4, $0 ; "0"
340 .byte $0, $0, $4, $c, $4, $4, $4, $0 ; "1"
350 .byte $0, $0, $c, $2, $4, $8, $e, $0 ; "2"
360 .byte $0, $0, $e, $2, $6, $2, $e, $0 ; "3"
370 .byte $0, $0, $a, $a, $e, $2, $2, $0 ; "4"
380 .byte $0, $0, $e, $8, $c, $2, $e, $0 ; "5"
390 .byte $0, $0, $e, $8, $e, $a, $e, $0 ; "6"
400 .byte $0, $0, $e, $2, $4, $8, $8, $0 ; "7"
410 .byte $0, $0, $e, $a, $e, $a, $e, $0 ; "8"
420 .byte $0, $0, $e, $a, $e, $2, $e, $0 ; "9"
430 .byte $0, $0, $0, $4, $0, $4, $0, $0 ; ":"
440 .byte $0, $0, $0, $4, $0, $4, $8, $0 ; ";"
450 .byte $0, $0, $2, $4, $8, $4, $2, $0 ; "<"
460 .byte $0, $0, $0, $e, $0, $e, $0, $0 ; "="
470 .byte $0, $0, $8, $4, $2, $4, $8, $0 ; ">"
480 .byte $0, $e, $2, $6, $4, $0, $4, $0 ; "?"
490 .byte $0, $4, $a, $e, $a, $8, $6, $0 ; "@"
500 .byte $0, $0, $0, $e, $2, $e, $e, $0 ; "a"
510 .byte $0, $0, $8, $e, $a, $a, $e, $0 ; "b"
520 .byte $0, $0, $0, $6, $8, $8, $6, $0 ; "c"
530 .byte $0, $0, $2, $e, $a, $a, $e, $0 ; "d"
540 .byte $0, $0, $0, $6, $a, $c, $6, $0 ; "e"
550 .byte $0, $0, $4, $a, $c, $8, $8, $0 ; "f"
560 .byte $0, $0, $0, $e, $a, $e, $2, $6 ; "g"
570 .byte $0, $0, $8, $c, $a, $a, $a, $0 ; "h"
580 .byte $0, $0, $4, $0, $4, $4, $4, $0 ; "i"
590 .byte $0, $0, $4, $0, $4, $4, $4, $c ; "j"
600 .byte $0, $0, $8, $a, $c, $a, $a, $0 ; "k"
610 .byte $0, $0, $4, $4, $4, $4, $6, $0 ; "l"
620 .byte $0, $0, $0, $e, $e, $e, $a, $0 ; "m"
630 .byte $0, $0, $0, $c, $a, $a, $a, $0 ; "n"
640 .byte $0, $0, $0, $e, $a, $a, $e, $0 ; "o"
650 .byte $0, $0, $0, $e, $a, $e, $8, $8 ; "p"
660 .byte $0, $0, $0, $e, $a, $e, $2, $3 ; "q"
670 .byte $0, $0, $0, $e, $a, $8, $8, $0 ; "r"
680 .byte $0, $0, $0, $e, $8, $2, $e, $0 ; "s"
690 .byte $0, $0, $4, $e, $4, $4, $6, $0 ; "t"
700 .byte $0, $0, $0, $a, $a, $a, $e, $0 ; "u"
710 .byte $0, $0, $0, $a, $a, $a, $4, $0 ; "v"
720 .byte $0, $0, $0, $a, $e, $e, $e, $0 ; "w"
730 .byte $0, $0, $0, $a, $4, $a, $a, $0 ; "x"
740 .byte $0, $0, $0, $a, $a, $4, $4, $c ; "y"
750 .byte $0, $0, $0, $e, $2, $8, $e, $0 ; "z"
760 .byte $0, $6, $4, $4, $4, $4, $6, $0 ; "["
770 .byte $0, $8, $8, $4, $4, $2, $2, $0 ; "\"
780 .byte $0, $c, $4, $4, $4, $4, $c, $0 ; "]"
790 .byte $0, $0, $4, $a, $0, $0, $0, $0 ; "^"
800 .byte $0, $0, $0, $0, $0, $0, $0, $e ; "[164]"
810 .byte $0, $8, $4, $0, $0, $0, $0, $0 ; "[SHIFT_@]"
820 .byte $0, $4, $e, $a, $e, $a, $a, $0 ; "A"
830 .byte $0, $c, $a, $c, $a, $a, $c, $0 ; "B"
840 .byte $0, $6, $8, $8, $8, $8, $6, $0 ; "C"
850 .byte $0, $c, $a, $a, $a, $a, $c, $0 ; "D"
860 .byte $0, $e, $8, $c, $8, $8, $e, $0 ; "E"
870 .byte $0, $e, $8, $c, $8, $8, $8, $0 ; "F"
880 .byte $0, $e, $8, $8, $a, $a, $e, $0 ; "G"
890 .byte $0, $a, $a, $e, $a, $a, $a, $0 ; "H"
900 .byte $0, $e, $4, $4, $4, $4, $e, $0 ; "I"
910 .byte $0, $2, $2, $2, $2, $a, $e, $0 ; "J"
920 .byte $0, $a, $a, $c, $a, $a, $a, $0 ; "K"
930 .byte $0, $8, $8, $8, $8, $8, $e, $0 ; "L"
940 .byte $0, $a, $e, $e, $e, $a, $a, $0 ; "M"
950 .byte $0, $2, $a, $e, $e, $a, $8, $0 ; "N"
960 .byte $0, $e, $a, $a, $a, $a, $e, $0 ; "O"
970 .byte $0, $e, $a, $a, $e, $8, $8, $0 ; "P"
980 .byte $0, $e, $a, $a, $a, $a, $e, $6 ; "Q"
990 .byte $0, $c, $a, $a, $c, $a, $a, $0 ; "R"
1000 .byte $0, $e, $8, $c, $6, $2, $e, $0 ; "S"
1010 .byte $0, $e, $4, $4, $4, $4, $4, $0 ; "T"
1020 .byte $0, $a, $a, $a, $a, $a, $e, $0 ; "U"
1030 .byte $0, $a, $a, $a, $a, $a, $4, $0 ; "V"
1040 .byte $0, $a, $a, $a, $e, $e, $a, $0 ; "W"
1050 .byte $0, $a, $a, $4, $a, $a, $a, $0 ; "X"
1060 .byte $0, $a, $a, $e, $4, $4, $4, $0 ; "Y"
1070 .byte $0, $e, $2, $4, $8, $8, $e, $0 ; "Z"
1080 .byte $0, $2, $4, $2, $2, $4, $2, $0 ; "[SHIFT_+]" left curly bracket
1090 .byte $0, $4, $4, $4, $0, $4, $4, $4 ; "[C=*]" pipe
1100 .byte $0, $8, $4, $8, $8, $4, $8, $0 ; "[SHIFT_-]" right curly bracket
1110 .byte $0, $0, $5, $a, $0, $0, $0, $0 ; "[175]" tilde
1120 ;
1130 .file 08,"0:term.end"
@//E*O*F term.font//
chmod u=rw,g=,o= term.font
echo x - term.lables
sed 's/^@//' > "term.lables" <<'@//E*O*F term.lables//'
100 ;
110 ; term.plus.64.lables
120 ;
130 ; last date 870102
140 ;
150 ; constant declarations
160 ;
170 ;kernel entry points
180 setnam = $ffbd ; set filename
190 setlfs = $ffba ; set open parameters
200 chkout = $ffc9 ; change kernel output channel
210 chrout = $ffd2 ; output a character
220 chkin = $ffc6 ; change kernel input channel
230 getin = $ffe4 ; input a character
240 readst = $ffb7 ; read i/o status
250 open = $ffc0 ; open a channel
260 close = $ffc3 ; close a channel
270 plot = $fff0 ; fetch/set cursor position (40 col)
280 ;commodore page zero variables
290 ndx = $c6 ; number of keyboard bytes pending
300 r6510 = $01 ; memory control register for 6510
310 ribuf = $f7 ; rs-232 input buffer pointer (2-byte)
320 robuf = $f9 ; rs-232 output buffer pointer (2-byte)
330 bitci = $a8 ; rs-232 input bit count
340 time = $a0 ; jiffy clock (3-byte)
350 pntr = $d3 ; cursor column displacement (40 col)
360 pnt = $d1 ; video matrix address of cursor line (40 col)
370 ldtb1 = $d9 ; editor line link table (40 col)
380 qtsw = $d4 ; quote-mode switch (40 col)
390 ;other commodore variables
400 ridbe = $29b ; rs-232 index to end of input buffer
410 ridbs = $29c ; rs-232 index to start of input buffer
420 shflag = $28d ; shift key flags (commodore key = bit 1)
430 hibase = $288 ; video matrix page number (40 col)
440 color = $286 ; 40 column foreground color
450 ;
460 ;page zero temporaries
470 source = $fb ; indirect address to be read
480 dest = $fd ; indirect address to be stored
490 pnth = $a3 ; hires screen pointer (basic temp data area)
500 ;commodore i/o addresses
510 vcr = $d011 ; vic control register
520 vmcr = $d018 ; vic memory control register
530 ccra = $dc0e ; cia control register a
540 bgnd = $d021 ; 40 column background color
550 bord = $d020 ; border color
560 freqhi = $d401 ; sid frequency (high byte)
570 attdec = $d405 ; sid attack/decay
580 susrel = $d406 ; sid sustain/release
590 vol = $d418 ; sid volume
600 wave = $d404 ; sid waveform select
610 ddrpa2 = $dd02 ; cia-2 data direction reg (port a)
620 dpa2 = $dd00 ; cia-2 data port a
630 ;color ram, hires screen, and video matrix addresses
640 colram = $d800 ; color ram address (40 col)
650 hires = $6000 ; hires screen address
660 vidmat = $5c00 ; video matrix address (80 col)
670 vidmat4 = $b400 ; video matrix address (40 col)
680 ;low memory area unused by basic
690 unused = $02a7 ; 16 byte termination/reentry area
700 ;terminal program load and run addresses
710 here = $0800 ; address where terminal program loaded
720 there = $a000 ; address where terminal program runs
730 ;relocated rs-232 buffer addresses
740 rsout = $b200 ; address of rs-232 output buffer
750 rsin = $b300 ; address of rs-232 input buffer
760 ;
770 .file 08,"0:term.tables"
@//E*O*F term.lables//
chmod u=rw,g=,o= term.lables
echo x - term.plus.bas
sed 's/^@//' > "term.plus.bas" <<'@//E*O*F term.plus.bas//'
100 print " [CLR]"
110 input "baud";b$
120 if left$(b$,2)="12"then poke 2637,0
130 if left$(b$,1)="3" then poke 2637,6
140 sys(2688)
@//E*O*F term.plus.bas//
chmod u=rw,g=,o= term.plus.bas
echo x - term.tables
sed 's/^@//' > "term.tables" <<'@//E*O*F term.tables//'
100 ;
110 ; term.plus.64.tables
120 ;
130 ; last date 870102
140 ;
150 ;**************************************************************************
160 ;note - this program is assembled to run in the address space beginning at
170 ;$a080 but should be loaded at $0880. the space from $a000-$a080 (really
180 ;$0800-$0880) is reserved for a small basic program which queries for baud
190 ;rate, pokes "control" as appropriate, and calls "movterm".
200 ;**************************************************************************
210 ;
220 ; table declarations
230 ;
240 *=there+$80
250 ;
260 ;table "to" translates c64 to ascii
270 to .byte $00 ; cannot transmit null
280 .byte $01 ;"^A from ^A key
290 .byte $02 ;"^B from ^B key
300 .byte $03 ;"^C from ^C key
310 .byte $04 ;"^D from ^D key
320 .byte $05 ;"^E from ^E key
330 .byte $06 ;"^F from ^F key
340 .byte $07 ;"^G from ^G key
350 .byte $08 ;"^H from ^H key
360 .byte $09 ;"^I from ^I key
370 .byte $0a ;"^J from ^J key
380 .byte $0b ;"^K from ^K key
390 .byte $0c ;"^L from ^L key
400 .byte $0d ;"^M from ^M and RETURN keys
410 .byte $0e ;"^N from ^N key
420 .byte $0f ;"^O from ^O key
430 .byte $10 ;"^P from ^P key
440 .byte $11 ;"^Q from ^Q and CURS DOWN keys
450 .byte $12 ;"^R from ^R key
460 .byte $13 ;"^S from ^S and HOME keys
470 .byte $08 ;"^H from ^T and DEL keys
480 .byte $15 ;"^U from ^U key
490 .byte $16 ;"^V from ^V key
500 .byte $17 ;"^W from ^W key
510 .byte $18 ;"^X from ^X key
520 .byte $19 ;"^Y from ^Y key
530 .byte $1a ;"^Z from ^Z key
540 .byte $1b ;"^[ from ^[ key
550 .byte $1c ;"^\ from ^POUND key
560 .byte $1d ;"^] from ^] key
570 .byte $1e ;"^^ from ^^ key
580 .byte $1f ;"^[164] from ^= key
590 .byte $20 ;"SPACE from SPACE bar
600 .byte "!" ;"! from ! key
610 .byte $22 ;"" from " key
620 .byte "#" ;"# from # key
630 .byte "$" ;"$ from $ key
640 .byte "%" ;"% from % key
650 .byte "&" ;"& from & key
660 .byte "'" ;"' from ' key
670 .byte "(" ;"( from ( key
680 .byte ")" ;") from ) key
690 .byte "*" ;"* from * key
700 .byte "+" ;"+ from + key
710 .byte "," ;", from , key
720 .byte "-" ;"- from - key
730 .byte "." ;". from . key
740 .byte "/" ;"/ from / key
750 .byte "0" ;"0 from 0 key
760 .byte "1" ;"1 from 1 key
770 .byte "2" ;"2 from 2 key
780 .byte "3" ;"3 from 3 key
790 .byte "4" ;"4 from 4 key
800 .byte "5" ;"5 from 5 key
810 .byte "6" ;"6 from 6 key
820 .byte "7" ;"7 from 7 key
830 .byte "8" ;"8 from 8 key
840 .byte "9" ;"9 from 9 key
850 .byte ":" ;": from : key
860 .byte ";" ;"; from ; key
870 .byte "<" ;"< from < key
880 .byte "=" ;"= from = key
890 .byte ">" ;"> from > key
900 .byte "?" ;"? from ? key
910 .byte "@" ;"@ from @ key
920 .byte "a"+$20 ;"a from a key
930 .byte "b"+$20 ;"b from b key
940 .byte "c"+$20 ;"c from c key
950 .byte "d"+$20 ;"d from d key
960 .byte "e"+$20 ;"e from e key
970 .byte "f"+$20 ;"f from f key
980 .byte "g"+$20 ;"g from g key
990 .byte "h"+$20 ;"h from h key
1000 .byte "i"+$20 ;"i from i key
1010 .byte "j"+$20 ;"j from j key
1020 .byte "k"+$20 ;"k from k key
1030 .byte "l"+$20 ;"l from l key
1040 .byte "m"+$20 ;"m from m key
1050 .byte "n"+$20 ;"n from n key
1060 .byte "o"+$20 ;"o from o key
1070 .byte "p"+$20 ;"p from p key
1080 .byte "q"+$20 ;"q from q key
1090 .byte "r"+$20 ;"r from r key
1100 .byte "s"+$20 ;"s from s key
1110 .byte "t"+$20 ;"t from t key
1120 .byte "u"+$20 ;"u from u key
1130 .byte "v"+$20 ;"v from v key
1140 .byte "w"+$20 ;"w from w key
1150 .byte "x"+$20 ;"x from x key
1160 .byte "y"+$20 ;"y from y key
1170 .byte "z"+$20 ;"z from z key
1180 .byte "[" ;"[ from [ key
1190 .byte "\" ;"\ from POUND key
1200 .byte "]" ;"] from ] key
1210 .byte "^" ;"^ from ^ key (really UP ARROW)
1220 .byte $1b ;"^[ from [164] key ([164] means ESC)
1230 .byte "@"+$20 ;"[SHIFT_@] from SHIFT/* key
1240 .byte "a" ;"A from A key
1250 .byte "b" ;"B from B key
1260 .byte "c" ;"C from C key
1270 .byte "d" ;"D from D key
1280 .byte "e" ;"E from E key
1290 .byte "f" ;"F from F key
1300 .byte "g" ;"G from G key
1310 .byte "h" ;"H from H key
1320 .byte "i" ;"I from I key
1330 .byte "j" ;"J from J key
1340 .byte "k" ;"K from K key
1350 .byte "l" ;"L from L key
1360 .byte "m" ;"M from M key
1370 .byte "n" ;"N from N key
1380 .byte "o" ;"O from O key
1390 .byte "p" ;"P from P key
1400 .byte "q" ;"Q from Q key
1410 .byte "r" ;"R from R key
1420 .byte "s" ;"S from S key
1430 .byte "t" ;"T from T key
1440 .byte "u" ;"U from U key
1450 .byte "v" ;"V from V key
1460 .byte "w" ;"W from W key
1470 .byte "x" ;"X from X key
1480 .byte "y" ;"Y from Y key
1490 .byte "z" ;"Z from Z key
1500 .byte $7b ;"[SHIFT_+] from SHIFT/+ key
1510 .byte $7c ;"[C=*] from ?????
1520 .byte $7d ;"[SHIFT_-] from SHIFT/- key
1530 .byte $7e ;"[175] from SHIFT/^ key
1540 .byte $7f ;"DEL from ?????
1550 .byte "?" ;"illegal key
1560 .byte "?" ;"illegal key
1570 .byte "?" ;"illegal key
1580 .byte "?" ;"illegal key
1590 .byte "?" ;"illegal key
1600 .byte $5f ;"[164] from F1 key
1610 .byte $60 ;"[SHIFT_@] from F3 key
1620 .byte $7b ;"[SHIFT_+] from F5 key
1630 .byte $7f ;"DEL from F7 key
1640 .byte $7c ;"[C=*] from F2 key
1650 .byte $7e ;"[175] from F4 key
1660 .byte $7d ;"[SHIFT_-] from F6 key
1670 .byte $14 ;"^T from F8 key
1680 .byte $0a ;"NL from SHIFT/CR key
1690 .byte "?" ;"illegal key
1700 .byte "?" ;"illegal key
1710 .byte "?" ;"illegal key
1720 .byte "?" ;"illegal key
1730 .byte "?" ;"illegal key
1740 .byte "?" ;"illegal key
1750 .byte "?" ;"illegal key
1760 .byte "?" ;"illegal key
1770 .byte "?" ;"illegal key
1780 .byte "?" ;"illegal key
1790 .byte "?" ;"illegal key
1800 .byte "?" ;"illegal key
1810 .byte "?" ;"illegal key
1820 .byte "?" ;"illegal key
1830 .byte "?" ;"illegal key
1840 .byte "?" ;"illegal key
1850 .byte "?" ;"illegal key
1860 .byte "?" ;"illegal key
1870 .byte $20 ;"SPACE from SHIFT/SPACE key
1880 .byte "?" ;"illegal key
1890 .byte "?" ;"illegal key
1900 .byte "?" ;"illegal key
1910 .byte "?" ;"illegal key
1920 .byte "?" ;"illegal key
1930 .byte "?" ;"illegal key
1940 .byte "?" ;"illegal key
1950 .byte "?" ;"illegal key
1960 .byte "?" ;"illegal key
1970 .byte "?" ;"illegal key
1980 .byte "?" ;"illegal key
1990 .byte "?" ;"illegal key
2000 .byte "?" ;"illegal key
2010 .byte "?" ;"illegal key
2020 .byte "?" ;"illegal 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 "@"+$20 ;"[SHIFT_@] from SHIFT/* key (dup)
2200 .byte "a" ;"A from A key (dup)
2210 .byte "b" ;"B from B key (dup)
2220 .byte "c" ;"C from C key (dup)
2230 .byte "d" ;"D from D key (dup)
2240 .byte "e" ;"E from E key (dup)
2250 .byte "f" ;"F from F key (dup)
2260 .byte "g" ;"G from G key (dup)
2270 .byte "h" ;"H from H key (dup)
2280 .byte "i" ;"I from I key (dup)
2290 .byte "j" ;"J from J key (dup)
2300 .byte "k" ;"K from K key (dup)
2310 .byte "l" ;"L from L key (dup)
2320 .byte "m" ;"M from M key (dup)
2330 .byte "n" ;"N from N key (dup)
2340 .byte "o" ;"O from O key (dup)
2350 .byte "p" ;"P from P key (dup)
2360 .byte "q" ;"Q from Q key (dup)
2370 .byte "r" ;"R from R key (dup)
2380 .byte "s" ;"S from S key (dup)
2390 .byte "t" ;"T from T key (dup)
2400 .byte "u" ;"U from U key (dup)
2410 .byte "v" ;"V from V key (dup)
2420 .byte "w" ;"W from W key (dup)
2430 .byte "x" ;"X from X key (dup)
2440 .byte "y" ;"Y from Y key (dup)
2450 .byte "z" ;"Z from Z key (dup)
2460 .byte $7b ;"[SHIFT_+] from SHIFT/+ key (dup)
2470 .byte $7c ;"[C=*] from ????? (dup)
2480 .byte $7d ;"[SHIFT_-] from SHIFT/- key (dup)
2490 .byte $7e ;"[175] from SHIFT/^ key (dup)
2500 .byte $7f ;"DEL from ?????
2510 .byte $20 ;"SPACE from SHIFT/SPACE key (dup)
2520 .byte "?" ;"illegal key
2530 .byte "?" ;"illegal key
2540 .byte "?" ;"illegal key
2550 .byte "?" ;"illegal key
2560 .byte "?" ;"illegal key
2570 .byte "?" ;"illegal key
2580 .byte "?" ;"illegal key
2590 .byte "?" ;"illegal key
2600 .byte "?" ;"illegal key
2610 .byte "?" ;"illegal key
2620 .byte "?" ;"illegal key
2630 .byte "?" ;"illegal key
2640 .byte "?" ;"illegal key
2650 .byte "?" ;"illegal key
2660 .byte "?" ;"illegal key
2670 .byte "?" ;"illegal key
2680 .byte "?" ;"illegal key
2690 .byte "?" ;"illegal key
2700 .byte "?" ;"illegal key
2710 .byte "?" ;"illegal key
2720 .byte "?" ;"illegal key
2730 .byte "?" ;"illegal key
2740 .byte "?" ;"illegal key
2750 .byte "?" ;"illegal key
2760 .byte "?" ;"illegal key
2770 .byte "?" ;"illegal key
2780 .byte "?" ;"illegal key
2790 .byte "?" ;"illegal key
2800 .byte "?" ;"illegal key
2810 .byte "?" ;"illegal key
2820 .byte $7e ;"[175] from SHIFT/^ key (dup)
2830 ;
2840 ;table "from" translates ascii to c64
2850 from .byte $00 ;"NUL doesn't print
2860 .byte $00 ;"^A doesn't print
2870 .byte $00 ;"^B doesn't print
2880 .byte $00 ;"^C doesn't print
2890 .byte $00 ;"^D doesn't print
2900 .byte $00 ;"^E doesn't print
2910 .byte $00 ;"^F doesn't print
2920 .byte $01 ;"BEL is special
2930 .byte $9d ;"BS prints as CURSOR LEFT
2940 .byte $01 ;"TAB is special
2950 .byte $11 ;"NL prints as CURSOR DOWN
2960 .byte $00 ;"^K doesn't print
2970 .byte $00 ;"^L doesn't print
2980 .byte $01 ;"CR is special
2990 .byte $00 ;"^N doesn't print
3000 .byte $00 ;"^O doesn't print
3010 .byte $00 ;"^P doesn't print
3020 .byte $00 ;"^Q doesn't print
3030 .byte $00 ;"^R doesn't print
3040 .byte $00 ;"^S doesn't print
3050 .byte $00 ;"^T doesn't print
3060 .byte $00 ;"^U doesn't print
3070 .byte $00 ;"^V doesn't print
3080 .byte $00 ;"^W doesn't print
3090 .byte $00 ;"^X doesn't print
3100 .byte $00 ;"^Y doesn't print
3110 .byte $00 ;"^Z doesn't print
3120 .byte $01 ;"^[ is special
3130 .byte $00 ;"^\ doesn't print
3140 .byte $00 ;"^] doesn't print
3150 .byte $00 ;"^^ doesn't print
3160 .byte $00 ;"^[164] doesn't print
3170 .byte $20 ;"SPACE prints as SPACE
3180 .byte $21 ;"! prints as !
3190 .byte $22 ;"" prints as "
3200 .byte $23 ;"# prints as #
3210 .byte $24 ;"$ prints as $
3220 .byte $25 ;"% prints as %
3230 .byte $26 ;"& prints as &
3240 .byte $27 ;"' prints as '
3250 .byte $28 ;"( prints as (
3260 .byte $29 ;") prints as )
3270 .byte $2a ;"* prints as *
3280 .byte $2b ;"+ prints as +
3290 .byte $2c ;", prints as ,
3300 .byte $2d ;"- prints as -
3310 .byte $2e ;". prints as .
3320 .byte $2f ;"/ prints as /
3330 .byte $30 ;"0 prints as 0
3340 .byte $31 ;"1 prints as 1
3350 .byte $32 ;"2 prints as 2
3360 .byte $33 ;"3 prints as 3
3370 .byte $34 ;"4 prints as 4
3380 .byte $35 ;"5 prints as 5
3390 .byte $36 ;"6 prints as 6
3400 .byte $37 ;"7 prints as 7
3410 .byte $38 ;"8 prints as 8
3420 .byte $39 ;"9 prints as 9
3430 .byte $3a ;": prints as :
3440 .byte $3b ;"; prints as ;
3450 .byte $3c ;"< prints as <
3460 .byte $3d ;"= prints as =
3470 .byte $3e ;"> prints as >
3480 .byte $3f ;"? prints as ?
3490 .byte $40 ;"@ prints as @
3500 .byte $61 ;"A prints as A
3510 .byte $62 ;"B prints as B
3520 .byte $63 ;"C prints as C
3530 .byte $64 ;"D prints as D
3540 .byte $65 ;"E prints as E
3550 .byte $66 ;"F prints as F
3560 .byte $67 ;"G prints as G
3570 .byte $68 ;"H prints as H
3580 .byte $69 ;"I prints as I
3590 .byte $6a ;"J prints as J
3600 .byte $6b ;"K prints as K
3610 .byte $6c ;"L prints as L
3620 .byte $6d ;"M prints as M
3630 .byte $6e ;"N prints as N
3640 .byte $6f ;"O prints as O
3650 .byte $70 ;"P prints as P
3660 .byte $71 ;"Q prints as Q
3670 .byte $72 ;"R prints as R
3680 .byte $73 ;"S prints as S
3690 .byte $74 ;"T prints as T
3700 .byte $75 ;"U prints as U
3710 .byte $76 ;"V prints as V
3720 .byte $77 ;"W prints as W
3730 .byte $78 ;"X prints as X
3740 .byte $79 ;"Y prints as Y
3750 .byte $7a ;"Z prints as Z
3760 .byte $5b ;"[ prints as [
3770 .byte $5c ;"\ prints as \
3780 .byte $5d ;"] prints as ]
3790 .byte $5e ;"^ prints as ^
3800 .byte $5f ;"[164] prints as [164]
3810 .byte $60 ;"[SHIFT_@] prints as [SHIFT_@]
3820 .byte $41 ;"a prints as a
3830 .byte $42 ;"b prints as b
3840 .byte $43 ;"c prints as c
3850 .byte $44 ;"d prints as d
3860 .byte $45 ;"e prints as e
3870 .byte $46 ;"f prints as f
3880 .byte $47 ;"g prints as g
3890 .byte $48 ;"h prints as h
3900 .byte $49 ;"i prints as i
3910 .byte $4a ;"j prints as j
3920 .byte $4b ;"k prints as k
3930 .byte $4c ;"l prints as l
3940 .byte $4d ;"m prints as m
3950 .byte $4e ;"n prints as n
3960 .byte $4f ;"o prints as o
3970 .byte $50 ;"p prints as p
3980 .byte $51 ;"q prints as q
3990 .byte $52 ;"r prints as r
4000 .byte $53 ;"s prints as s
4010 .byte $54 ;"t prints as t
4020 .byte $55 ;"u prints as u
4030 .byte $56 ;"v prints as v
4040 .byte $57 ;"w prints as w
4050 .byte $58 ;"x prints as x
4060 .byte $59 ;"y prints as y
4070 .byte $5a ;"z prints as z
4080 .byte $7b ;"[SHIFT_+] prints as [SHIFT_+]
4090 .byte $7c ;"[C=*] prints as [C=*]
4100 .byte $7d ;"[SHIFT_-] prints as [SHIFT_-]
4110 .byte $7e ;"[175] prints as [175]
4120 .byte $00 ;"DEL doesn't print
4130 ;
4140 ;table "newchar" defines 8 substitute screen
4150 ;graphics, 9 bytes each - first byte is screen
4160 ;code for graphic, next 8 are bit pattern
4170 newchar .byte $5b, $0e, $18, $08, $3c, $08, $18, $0e, $00 ; left brace
4180 .byte $5d, $70, $18, $10, $3c, $10, $18, $70, $00 ; right brace
4190 .byte $5e, $00, $00, $3b, $6e, $00, $00, $00, $00 ; tilde
4200 .byte $40, $30, $18, $0c, $00, $00, $00, $00, $00 ; grave accent
4210 .byte $5c, $18, $18, $18, $00, $18, $18, $18, $00 ; vertical bar
4220 .byte $1c, $00, $60, $30, $18, $0c, $06, $03, $00 ; back slash
4230 .byte $1e, $00, $00, $18, $3c, $66, $00, $00, $00 ; caret
4240 .byte $1f, $00, $00, $00, $00, $00, $00, $00, $7f ; underline
4250 ;
4260 .file 08,"0:term.1"
@//E*O*F term.tables//
chmod u=rw,g=,o= term.tables
exit 0
More information about the Comp.sources.unix
mailing list