00010 * KERMIT-COCO: COLOR COMPUTER KERMIT 00020 * VERSION 1.1 : 03/85 00030 * COPYRIGHT (C) 1985 BY WES HUBERT 00040 * 3020 STEVEN DRIVE, LAWRENCE KS 66044 00050 * 00060 * THIS PROGRAM IS BOTH A STAND-ALONE 00070 * TERMINAL PROGRAM AND THE BASE FOR 00080 * A COLOR COMPUTER IMPLEMENTATION OF 00090 * THE KERMIT FILE TRANSFER PROTOCOL. 00100 * 00110 * PERMISSION IS GRANTED FOR NON-PROFIT USE AND 00120 * DISTRIBUTION AS PART OF THE COLOR COMPUTER 00130 * KERMIT SYSTEM PROVIDED THAT THIS NOTICE IS 00140 * NOT REMOVED. 00150 * 00160 * KERMIT IS A FILE TRANSFER PROTOCOL DEVELOPED 00170 * BY FRANK DA CRUZ AND BILL CATCHINGS 00180 * AT THE COLUMBIA UNIVERSITY CENTER FOR 00190 * COMPUTING ACTIVITIES. 00200 * 00210 * THIS PORTION OF KERMIT-C0C0 PROVIDES 00220 * TERMINAL FACILITIES INCLUDING EVEN/NO 00230 * PARITY, LOCAL/REMOTE ECHO, AND SIMPLE 00240 * NO PROTOCOL FILE UPLOAD/DOWNLOAD. 00250 * PARITY IS ALWAYS IGNORED ON INPUT. 00260 * THE PARITY BIT TIME IS USED FOR SCREEN 00270 * SCROLLING WHEN NECESSARY. 00280 * 00290 * CHROUT CODE ADAPTED FROM CC TERM 00300 * BY RICHARD CAMPBELL. 00310 * (COLOR COMPUTER MAGAZINE, MARCH 1984) 00320 * 00330 * DISK OPEN/CLOSE CODE ADAPTED FROM TAPE TO 00340 * DISK FILE TRANSFER BY ROGER SCHRAG. 00350 * (RAINBOW MAGAZINE, JANUARY 1984) 00360 * 00370 * THE CODE FOR KERMIT PROTOCOL TRANSFERS 00380 * IS ASSEMBLED AND LOADED SEPARATELY 00390 * AFTER ASSEMBLY AND LOADING OF THIS 00400 * ROUTINE. SEE THE PROTOCOL CODE FOR 00410 * MORE INFORMATION. 00420 * 00430 * THIS PORTION OF THE CODE RESIDES IN 00440 * (HEX) 2000-27FF, THE PROTOCOL CODE 00450 * FROM 2800-2FFF. MEMORY BELOW 2000 00460 * IS AVAILABLE FOR BASIC PROGRAMS, AND 00470 * MEMORY ABOVE 2FFF IS USED FOR THE 00480 * JOURNALIZATION / RAW ASCII TRANSFER 00490 * BUFFER. 00500 * 00510 * NOTE THAT ALTHOUGH EACH PART IS 00520 * WRITTEN IN POSITION INDEPENDENT FORM 00530 * THE COMBINATION IS NOT POSITION INDEPENDENT 00540 * BECAUSE OF FIXED ADDRESSES USED FOR 00550 * COMMUNICATION BETWEEN THE PROGRAMS. TO 00560 * RELOCATE THE PROGRAM, THESE ADDRESSES 00570 * MUST BE MODIFIED. 00580 * 00590 ORG $2000 00600 TERM BRA START 00610 * 00620 ************************* 00630 * ENTRIES FOR PROTOCOL * 00640 ************************* 00650 * 00660 FDB RS232I 00670 FDB RS232O 00680 FDB KEYIN 00690 FDB OTCHAR 00700 FDB INNAME 00710 FDB OTNAME 00720 FDB FCLOSE 00730 FDB WAIT 00740 FDB QEOF 00750 FILNAM FCC 'KERMIT-COCO ' 00760 FCB 0 (END OF STRING) 00770 FCC 'COPYRIGHT (C) 1985' 00780 * 00790 ******************************************* 00800 * 00810 ************************* 00820 * STANDARD COCO DEFS * 00830 ************************* 00840 * 00850 SYSMEM EQU $74 HIGH MEMORY ADDRESS 00860 SCRPTR EQU $88 SCREEN CURSOR PTR 00870 SCREEN EQU $400 SCREEN MEMORY 00880 FNAME EQU $94C FILE NAME 00890 FTYPE EQU $957 FILE TYPE 00900 TOP EQU $3000 END OF KERMIT 00910 POLCAT EQU $A000 KEYBOARD POLL ROUTNE 00920 PUTCHR EQU $A002 CHARACTER OUTPUT 00930 OUTPIA EQU $FF20 MODEM PIA LOC 00940 INPIA EQU $FF22 IN MODEM PIA 00950 * 00960 ************************* 00970 * DEFAULT CONFIGURATION * 00980 ************************* 00990 * 01000 CAN FCB $18 (XMIT SHFT<- AS CAN) 01010 DEL FCB $08 (XMIT <- AS BKSP) 01020 LECHO FCB 0 (-1=HALF/0=FULL) 01030 PARITY FCB -1 (-1=EVEN/0=NONE) 01040 AUTOLF FCB 0 (-1=YES/0=NO) 01050 CPYMIN FDB TOP (BUFFER ORIGIN) 01060 CPYMAX FDB $7FFF (32K SYSTEM) 01070 CPYPTR FDB TOP (BUFFER POINTER) 01080 COPY FCB 0 (-1=BUFFER/0=DON'T) 01090 SPEED FDB 419 (419=300 BAUD) 01100 DC2 FCB $12 (TURN ON BUFFER) 01110 DC4 FCB $14 (TURN OFF BUFFER) 01120 CURCHR FCB $60 (PLACE FOR CHAR 01130 * UNDER CURSOR) 01140 * 01150 ************************* 01160 * EXECUTION ENTRY * 01170 ************************* 01180 * 01190 START STS ISTACK,PCR 01200 LEAS TOPSTK,PCR 01210 LBSR CLEAR (CLEAR SCREEN) 01220 LBSR MENU (PRINT MENU) 01230 LEAX TOP,PCR (LOCATE BUFFER) 01240 STX CPYMIN,PCR 01250 LDX SYSMEM (SIZE) 01260 STX CPYMAX,PCR (TOP OF BUFFER) 01270 * 01280 ****************************************** 01290 * TOP OF MAIN LOOP * 01300 * ALTERNATELY POLL RS232 INPUT AND * 01310 * KEYBOARD. * 01320 ****************************************** 01330 * 01340 CHKMN BSR RSSYNC (WAIT FOR CARRIER) 01350 CHKRSI LBSR RS232I (POLL RS232 PORT) 01360 BEQ CHKKBI 01370 LBSR OTCHAR 01380 BSR RSSYNC 01390 CHKKBI LBSR KEYIN (POLL KEYBOARD) 01400 BEQ CHKRSI 01410 * 01420 CHKBRK CMPA #$FF (BREAK) 01430 BNE CHKDEL 01440 BSR BREAK 01450 BRA CHKMN 01460 * 01470 CHKDEL CMPA #$FE (LEFT ARROW) 01480 BNE CHKCAN 01490 TST LECHO,PCR 01500 BEQ CHKD2 01510 LDA #08 (PRINT BACKSPACE) 01520 LBSR OTCHAR 01530 CHKD2 LDA DEL,PCR (SEND DELETE CHAR) 01540 BRA CHKOUT 01550 * 01560 CHKCAN CMPA #$FD (SHIFT LEFT ARROW) 01570 BNE CHKDUP 01580 LDA CAN,PCR (SEND LINE DELETE) 01590 BRA CHKOUT 01600 * 01610 CHKDUP TST LECHO,PCR 01620 BEQ CHKOUT 01630 LBSR OTCHAR (ECHO PRINT CHAR) 01640 * 01650 CHKOUT BSR RS232O (TRANSMIT CHAR) 01660 BRA CHKMN 01670 * 01680 ************************* 01690 * WAIT FOR STOP BIT * 01700 ************************* 01710 * 01720 RSSYNC LDA INPIA (READ MODEM) 01730 LSRA 01740 BCC RSSYNC (LOOP UNTIL SET) 01750 RTS 01760 * 01770 ************************ 01780 * SEND LINE BREAK * 01790 ************************ 01800 * 01810 BREAK CLR OUTPIA (SEND ZERO BITS) 01820 LDX #$6100 (ABOUT .25 SECONDS) 01830 BRK2 LEAX -1,X 01840 BNE BRK2 01850 LDA #2 01860 STA OUTPIA (SEND STOP BIT) 01870 RTS 01880 * 01890 ************************ 01900 * PAUSE ABOUT 1 BIT * 01910 ************************ 01920 * 01930 WAIT PSHS D (WAIT BIT TIME) 01940 LDD SPEED,PCR 01950 WT2 SUBD #1 01960 BNE WT2 01970 PULS D,PC 01980 * 01990 ************************ 02000 * SET EVEN PARITY * 02010 ************************ 02020 * 02030 EVEN PSHS X (PRESERVE X) 02040 LDX #7 (SEVEN DATA BITS) 02050 CLRB 02060 EVEN2 RORA 02070 BCC EVEN4 02080 INCB (COUNT 1 BITS) 02090 EVEN4 LEAX -1,X 02100 BNE EVEN2 02110 RORA 02120 RORB (PARITY BIT) 02130 RORA 02140 PULS X (RESTORE X) 02150 RTS 02160 * 02170 ************************ 02180 * READ FROM MODEM * 02190 ************************ 02200 * 02210 RS232I LDA INPIA (READ MODEM) 02220 LSRA 02230 BCC RSI2 (LOOK FOR START BIT) 02240 CLRA 02250 RTS 02260 RSI2 LDD SPEED,PCR 02270 LSRA (HALF BIT) 02280 RORB 02290 RSI4 SUBD #1 (PPAUSE) 02300 BGT RSI4 02310 LDB #7 (7 DATA BITS) 02320 PSHS A,B 02330 RSI5 LDD SPEED,PCR (WAIT FOR NEXT) 02340 RSI6 SUBD #1 02350 BNE RSI6 02360 NOP 02370 LDB INPIA (GET DATA BIT) 02380 LSRB 02390 ROR 0,S 02400 DEC 1,S 02410 BNE RSI5 02420 ROR 0,S 02430 PULS A,B 02440 ANDA #$7F (DROP PARITY) 02450 CMPA #$7F (IGNORE RUBOUT) 02460 BNE RSI7 02470 CLRA 02480 RSI7 RTS 02490 * 02500 ************************ 02510 * WRITE TO MODEM * 02520 ************************ 02530 * 02540 RS232O TST PARITY,PCR 02550 BEQ RSO1 02560 BSR EVEN (SET PARITY BIT) 02570 RSO1 LDB #8 (BIT COUNT) 02580 PSHS A,B (BYTE TO SEND,COUNT) 02590 CLR OUTPIA (START BIT) 02600 RSO2 LDD SPEED,PCR 02610 RSO4 SUBD #1 02620 BNE RSO4 02630 LSR 0,S (GET DATA BIT) 02640 ROLB (SHIFT FOR PIA) 02650 ROLB (BIT TWO) 02660 STB OUTPIA (SEND IT) 02670 DEC 1,S (COUNT THE BIT) 02680 BNE RSO2 02690 LEAS 2,S (DROP WORK/COUNT) 02700 LBSR WAIT 02710 LDB #2 02720 STB OUTPIA (STOP BIT) 02730 LBSR WAIT 02740 LBSR WAIT 02750 RTS 02760 * 02770 ************************ 02780 * READ FROM KEYBOARD * 02790 ************************ 02800 * 02810 KEYIN PSHS B (CHAR FROM SCREEN) 02820 LDB [SCRPTR] 02830 BMI KI0 (SKIP IF CURSOR) 02840 STB CURCHR,PCR (ELSE REMEMBER) 02850 KI0 LDB #$FF (CURSOR CHAR) 02860 STB [SCRPTR] (ONTO SCREEN) 02870 PULS B 02880 JSR [POLCAT] (POLL KEYBOARD) 02890 BNE KI1 02900 RTS (NO INPUT) 02910 * 02920 KI1 CMPA #$03 (BREAK) 02930 BNE KI1A 02940 LDA #$FF (CODE BREAK) 02950 RTS 02960 KI1A CMPA #$08 (BACKSPACE) 02970 BNE KI1B 02980 LDA #$FE 02990 RTS 03000 KI1B CMPA #$15 (SHIFT LEFT ARROW) 03010 BNE KI2 03020 LDA #$FD 03030 RTS 03040 KI2 CMPA #$0C (CLEAR) 03050 BNE KI2A 03060 PSHS X,Y,B 03070 LBSR CLEAR 03080 PULS X,Y,B 03090 CLRA 03100 RTS 03110 KI2A CMPA #$0A (DOWN-ARROW) 03120 BEQ KI3 03130 RTS (NORMAL CHARACTER) 03140 KI3 JSR [POLCAT] (GET CONTROL CHAR) 03150 BEQ KI3 03160 CMPA #$40 (@) 03170 BLO KI4 03180 ANDA #$1F (MAKE CONTROL) 03190 LDB #1 03200 RTS 03210 KI4 CMPA #'? (MENU?) 03220 BNE KI5 03230 LBSR MENU 03240 RTS 03250 KI5 CMPA #'0 (0-9 LOCAL CONTROL 03260 BLO KI6 03270 CMPA #'> 03280 BLE OP0 03290 KI6 PSHS X,B (TRANSLATE 03300 LEAX SPCTAB,PCR 03310 LDB ,X+ 03320 SPC2 CMPA B,X 03330 BEQ SPC4 03340 DECB 03350 BPL SPC2 03360 PULS X,B (LEAVE ASIS) 03370 RTS 03380 SPC4 LEAX OUTTAB,PCR 03390 LDA B,X (CHANGE) 03400 PULS X,B 03410 RTS 03420 SPCTAB FCB 5 (# SPECIAL-1) 03430 FCC /'(!)-#/ 03440 OUTTAB FDB $607B 03450 FDB $7C7D 03460 FDB $7E7F 03470 * 03480 *********************** 03490 * PROCESS OPTIONS * 03500 *********************** 03510 * 03520 OP0 CMPA #$30 0=EXIT 03530 BNE OP1 03540 PULS X (DROP RETURN 03550 LDS ISTACK,PCR 03560 RTS 03570 OP1 CMPA #$31 1=LOCAL ECHO 03580 BNE OP2 03590 COM LECHO,PCR 03600 CLRA 03610 RTS 03620 OP2 CMPA #$32 2=PARITY 03630 BNE OP3 03640 COM PARITY,PCR 03650 CLRA 03660 RTS 03670 OP3 CMPA #$33 3=AUTO L.F. 03680 BNE OP4 03690 COM AUTOLF,PCR 03700 CLRA 03710 RTS 03720 OP4 CMPA #$34 4=BUFFER ON/OFF 03730 BNE OP5 03740 COM COPY,PCR 03750 CLRA 03760 RTS 03770 OP5 CMPA #$35 5=WRITE FILE 03780 BNE OP6 03790 LBSR WRITEF 03800 CLRA 03810 RTS 03820 OP6 CMPA #$36 6=READ FILE 03830 BNE OP7 03840 LBSR READF 03850 CLRA 03860 RTS 03870 OP7 CMPA #$37 7=UPLOAD 03880 BNE OP8 03890 LBSR UPLOAD 03900 CLRA 03910 RTS 03920 OP8 CMPA #$38 8=RESET POINTER 03930 BNE OP9 03940 LDD CPYMIN,PCR 03950 STD CPYPTR,PCR 03960 CLRA 03970 RTS 03980 OP9 CMPA #$39 9=SET DELETE CHARS 03990 BNE OPR 04000 OP91 LBSR KEYIN 04010 BEQ OP91 04020 STA DEL,PCR 04030 OP9A LBSR KEYIN 04040 BEQ OP9A 04050 STA CAN,PCR 04060 CLRA 04070 RTS 04080 OPR CMPA #'< <=KERMIT RECEIVE 04090 BNE OPS 04100 JSR KERMR 04110 RTS 04120 OPS CMPA #'> >=KERMIT SEND 04130 BNE OPT 04140 JSR KERMS 04150 RTS 04160 OPT CMPA #'= ==KERMIT SETUP 04170 BNE OPX 04180 JSR KERMT 04190 RTS 04200 OPX RTS ** NOT SPECIAL 04210 * 04220 ************************* 04230 * PRINT MENU * 04240 ************************* 04250 * 04260 MENU PSHS X,Y,D 04270 LBSR CLEAR 04280 LEAX MCHARS,PCR (SHOW CURRENT STATUS) 04290 LDA LECHO,PCR 04300 INCA 04310 LDA A,X 04320 STA MDUP,PCR 04330 LEAX 2,X 04340 LDA PARITY,PCR 04350 INCA 04360 LDA A,X 04370 STA MPAR,PCR 04380 LEAX 2,X 04390 LDA AUTOLF,PCR 04400 INCA 04410 LDA A,X 04420 STA MLF,PCR 04430 LEAX 2,X 04440 LDA COPY,PCR 04450 INCA 04460 LDA A,X 04470 STA MJRNL,PCR 04480 LDA DEL,PCR 04490 LBSR TOHEX 04500 STD MDEL,PCR 04510 LDA CAN,PCR 04520 LBSR TOHEX 04530 STD MCAN,PCR 04540 LEAX MTEXT,PCR 04550 MEN2 LDD ,X++ 04560 ADDD #SCREEN 04570 STD SEND' 05140 FCB 0 05150 FDB 450 05160 FCC '()!-# BRACES BAR TILDE DEL' 05170 FDB $0DFF 05180 * 05190 ************************* 05200 * SOUND BELL * 05210 ************************* 05220 * 05230 BELL LDA $FF01 (CONFIGURE FOR 05240 ANDA #$F7 05250 STA $FF01 05260 LDA $FF03 SIX BIT 05270 ANDA #$F7 05280 STA $FF03 05290 LDA $FF23 05300 ORA #$08 05310 STA $FF23 SOUND) 05320 LDD #$06F2 (INITIAL TONE) 05330 BELL4 STB OUTPIA (OUTPUT SOUND) 05340 SUBD #$08 (CHANGE TONE) 05350 CMPD #$0002 05360 BNE BELL4 05370 LDA #$07 (RESTORE "BELL") 05380 RTS 05390 * 05400 ************************* 05410 * WRITE TO SCREEN * 05420 ************************* 05430 * 05440 OTCHAR CMPA DC2,PCR (DOWNLOAD FLAG) 05450 BNE OT1 05460 LDA #$FF (SET FLAG) 05470 STA COPY,PCR 05480 OTCX LBSR WAIT 05490 RTS 05500 OT1 CMPA DC4,PCR (END DOWNLOAD) 05510 BNE OT2 05520 CLR COPY,PCR 05530 BRA OTCX 05540 OT2 CMPA #$07 (BELL) 05550 BNE OT2A 05560 BSR BELL 05570 BRA OTX 05580 OT2A CMPA #$0C (CLEAR) 05590 BNE OT3 05600 LBSR CLEAR 05610 LDA #$0C 05620 BRA OTX 05630 OT3 CMPA #$08 (BACKSPACE) 05640 BNE OT4 05650 LDB #$60 05660 STB [SCRPTR] 05670 OT4 CMPA #$0D (RETURN/ENTER) 05680 BNE OT5 05690 TST AUTOLF,PCR 05700 BNE OT6 05710 LDB CURCHR,PCR 05720 STB [SCRPTR] 05730 LDB #$60 05740 STB CURCHR,PCR 05750 LDB SCRPTR+1 05760 ANDB #$E0 05770 STB SCRPTR+1 05780 LBSR WAIT 05790 BRA OTX 05800 OT5 CMPA #$0A (LINE FEED) 05810 BNE OT6 05820 LDB CURCHR,PCR 05830 STB [SCRPTR] 05840 LDB #$60 05850 STB CURCHR,PCR 05860 LDA #$0D (PRINT C.R) 05870 LDB SCRPTR+1 05880 ORB #$1F (AT END OF LINE) 05890 STB SCRPTR+1 05900 LBSR CHROUT 05910 LDA #$0A (RESTORE L.F.) 05920 BRA OTX 05930 OT6 LBSR CHROUT (NORMAL CHAR) 05940 OTX TST COPY,PCR 05950 BNE OTCOPY 05960 RTS 05970 * 05980 ************************ 05990 * "WRITE" TO BUFFER * 06000 ************************ 06010 * 06020 OTCOPY LDX CPYPTR,PCR (BUFFER PTR) 06030 CMPX CPYMAX,PCR 06040 BMI CPY2 06050 CLR COPY,PCR (TURN OFF) 06060 BSR CPYERR 06070 RTS 06080 CPY2 STA ,X+ (STORE CHARACTER) 06090 STX CPYPTR,PCR 06100 RTS 06110 CPYERR PSHS A 06120 LEAX CEM,PCR 06130 CE2 LDA ,X+ 06140 BEQ CEX 06150 LBSR OTCHAR 06160 BRA CE2 06170 CEX LBSR BREAK 06180 PULS A 06190 RTS 06200 CEM FCB $07 06210 FCC 'buffer full' 06220 FDB $0A00 06230 * 06240 ************************ 06250 * UPLOAD FROM BUFFER * 06260 ************************ 06270 * 06280 UPLOAD LDY CPYMIN,PCR 06290 UP2 CMPY CPYPTR,PCR 06300 BEQ UP8 06310 LDA ,Y 06320 LBSR RS232O 06330 LBSR KEYIN (ALLOW BREAK) 06340 BEQ UP4 06350 CMPA #$FF 06360 BEQ UP8 06370 UP4 LDA ,Y+ 06380 LBSR OTCHAR 06390 CMPA #$0D 06400 BNE UP2 06410 LDX #$8000 (PAUSE AFTER LINE) 06420 UP6 LEAX -1,X 06430 BNE UP6 06440 BRA UP2 06450 UP8 LDB #$FF (RESTORE CURSOR) 06460 STB [SCRPTR] 06470 RTS 06480 * 06490 *********************** 06500 * CLEAR SCREEN * 06510 *********************** 06520 * 06530 CLEAR LDD #SCREEN 06540 STD SCRPTR 06550 LDX #SCREEN+$80 06560 LDY #SCREEN+$180 06570 LDD #$6000 06580 CLR2 STA B,X 06590 STA B,Y 06600 INCB 06610 BNE CLR2 06620 RTS 06630 * 06640 ************************ 06650 * DISPLAY CHAR * 06660 ************************ 06670 * 06680 CHROUT PSHS A,B,X 06690 CLRB 06700 LDX