mugc@utecfa.UUCP (ModemUserGroupChairman) (09/22/85)
Don't flame me for posting here; the issue is debatable.
Compile and enjoy.
This program has some simple ascii capture facilites that
the DA does not have.
--------------- Snip Snip here here ----------------------------------
.TEXT
* =============================================================================
* TERMINAL PROGRAM FOR ST WITH DISK CAPTURE AND FILE SEND
* By Alan Page - August 1985
* Public Domain
* NOTE: THE AUTHOR IS NOT RESPONSIBLE FOR ANY BUGS OR MALFUNCTIONS THAT MAY
* EXIST IN THIS PROGRAM OR ANY LOSS OF DATA THAT MAY RESULT FROM
* SUCH MALFUNCTIONS.
* =============================================================================
* ADMITTEDLY A SLOPPY LOOKING LISTING
* BUT WHAT THE HECK, IT WORKS, AND AS SOON AS
* A DECENT COMMERCIAL PROGRAM IS AVAILABLE, INTO THE TRASH IT GOES!
* -----------------------------------------------------------------------------
* CHANGE NAME TO TERM.S BEFORE ASSEMBLING
* ASSEMBLE WITH AS68 -L -P TERM.S
* LINK WITH LO68 -R -O TERM.68K TERM.O
* THEN RELMOD TERM.68K TERM.TOS
MOVE.L A7,A5 * CODE FROM APSTART.S
MOVE.L #USTK,A7
MOVE.L 4(A5),A5
MOVE.L $C(A5),D0
ADD.L $14(A5),D0
ADD.L $1C(A5),D0
ADD.L #$100,D0
MOVE.L D0,-(SP)
MOVE.L A5,-(SP)
MOVE D0,-(SP)
MOVE #$4A,-(SP)
TRAP #1
ADD.L #12,SP
MOVE.B #$1B,D3 * ESC,$76 SETS UP LINEWRAP ON CONSOLE
BSR SHOWBYTE * SHOWS BYTE ON SCREEN
MOVE.B #$76,D3
BSR SHOWBYTE
LEA HELLO,A0
BSR PSTRING
MOVE.B #0,FLAG * SET ALL FLAGS TO ZERO
MOVE.W #7,D0 * 1200 BAUD DEFAULT
MOVE.W #7,BAUD
BSR SETBAUD
LEA BAUD12,A0
BSR PSTRING
TOP: BSR CKSER * SERIAL STATUS
CMP.W #$FFFF,D0
BNE NOFILE
BSR GETSER * GET A SERIAL BYTE
MOVE.W D0,D3
ANDI.W #$7F,D3 * STRIP 8 TH BIT
BSR SHOWBYTE * THEN SHOW BYTE ON CONSOLE (IN D3)
* BTST #0,FLAG * IS PFLAG SET?
* BEQ NOPRINT
* BSR PRNT * PRINTER OUTPUT
* NOPRINT: * SEE IF FILE OUTPUT
BTST #1,FLAG
BEQ NOFILE
* D3 CONTAINS BYTE TO OUTPUT
* DOESN'T SEND MOST CONTROL CHARACTERS TO FILE
* FOR NEATER DOWNLOADS. OMIT IF YOU WISH
CMP.B #$20,D3
BGE NOCTL2
MULU #2,D3
LEA PTABLE,A0
MOVE.W #0(A0,D3.W),D0
MOVE.W D0,D3
NOCTL2: CMP.B #0,D3 * NO NULLS TO FILE
BEQ NOFILE
LEA BUFFER,A0
MOVE.W BUFFCOUNT,D0 * D0 CONTAINS # OF BYTES IN BUFFER
MOVE.B D3,#0(A0,D0.W)
ADD.W #1,D0
MOVE.W D0,BUFFCOUNT
CMP.W #32000,D0 * IF BUFFER FULL, SEND IT TO FILE
BNE NOFILE
EXT.L D0
BSR SENDBF
NOFILE: BSR CKKB * SEE IF KEYPRESS
CMP.W #$FFFF,D0
BNE TOP
BSR GETKB * GET KEYPRESS
* F1 TOGGLE BAUD RATE
CMP.B #$3B,D0
BNE NOFN1
CMPI.W #9,BAUD
BEQ SPEEDUP
LEA BAUD3,A0
BSR PSTRING
MOVE.W #9,D0
MOVE.W D0,BAUD
BSR SETBAUD
BRA TOP
SPEEDUP:
LEA BAUD12,A0
BSR PSTRING
MOVE.W #7,D0
MOVE.W D0,BAUD
BSR SETBAUD
BRA TOP
* F2 FILE CAPTURE TOGGLE FUNCTION
NOFN1: CMP.B #$3C,D0
BNE NOFN2
BTST #2,FLAG * FILE OPEN?
BNE OKFL
LEA FERROR,A0
BSR PSTRING
BRA TOP * IF FILE NOT OPEN, NO ACTION
OKFL: BCHG #1,FLAG * TOGGLE FLAG
BNE DOFF
LEA STARTF,A0
BSR PSTRING
BRA TOP
DOFF: LEA STOPF,A0
BSR PSTRING
BRA TOP
* UNDO TO EXIT
NOFN2: CMP.B #$61,D0
BNE NOUNDO
BTST #2,FLAG * SEE IF FILE EXISTS TO BE CLOSED
BEQ EXIT
BSR FILEND * OUTPUT LAST OF BUFFER AND CLOSE FILE
EXIT: MOVE.W #0,-(SP)
TRAP #1
* F3 = CREATE AND OPEN FILE FOR INPUT
NOUNDO: CMP.B #$3D,D0
BNE NOFN3
BTST #2,FLAG
BEQ NOTMADE
* A FILE ALREADY EXISTS, CLOSE IT AND CREATE ANOTHER
BSR FILEND
NOTMADE: * ZERO COUNT OF BYTES IN BUFFER
MOVE.W #0,BUFFCOUNT
MOVE.L #0,FPTR
LEA PROMPT,A0
BSR PSTRING
BSR GETFN * GET FILENAME
BSR OPENFR * OPEN IT TO SEE IF ALREADY EXISTS
TST.L D0
BMI NXT1 * DOESN'T EXIST
MOVE.W D0,FHNDL3
LEA WARN,A0
BSR PSTRING
BSR YESNO * ASK IF FILE TO BE DESTROYED BY (RE)CREATION
BRA TOP
NXT1: BSR FILECR * CREATE FILE
TST.L D0
BPL CONTF * IF ERROR IN CREATION, DON'T OPEN FILE, EXIT
BRA TOP
CONTF: BSR OPENFW
TST.L D0
BPL SAVEFH
LEA FERROR2,A0
BSR PSTRING
BRA TOP
SAVEFH: MOVE.W D0,FHNDLE
BSET #2,FLAG
LEA OKMSG,A0
BSR PSTRING
BRA TOP
* F4 GET FILENAME FOR FILE TO BE OUTPUT
NOFN3: CMP.B #$3E,D0
BNE NOFN4
BTST #4,FLAG * IF FILE EXISTS AND HASN'T BEEN SENT POST ERROR3
BEQ OKFL4
LEA FERR3,A0
BSR PSTRING
BRA TOP
OKFL4: LEA PROMPT2,A0
BSR PSTRING
BSR GETFN
BSR OPENFR
TST.L D0
BPL SAVFH2
LEA FERROR2,A0
BSR PSTRING
BRA TOP
SAVFH2: MOVE.W D0,FHNDL2
BSET #4,FLAG
LEA OKMSG2,A0
BSR PSTRING
BRA TOP
* F5 SEND A FILE OUT SERIAL PORT
NOFN4: CMP.B #$3F,D0
BNE NOFN5
BTST #4,FLAG * SEE IF FILE EXISTS TO BE SENT
BNE OKF4
LEA FERROR,A0
BSR PSTRING
BRA TOP
* START SENDING BYTES
OKF4: LEA STARTU,A0
BSR PSTRING
LOOP4: PEA TEMP
MOVE.L #1,-(SP)
MOVE.W FHNDL2,-(SP)
MOVE.W #$3F,-(SP)
TRAP #1
ADDA.L #12,SP
* DID NOT RECEIVE A BYTE IF D0 = 0
* IF NO BYTE RECEIVED, THEN IS EOF.
* SEND RECEIVING COMPUTER AN EOF
CMP.B #0,D0
BEQ ABORT
MOVE.B TEMP,D3
CMP.B #$0A,D3
BNE NOLF
CMP.B #$0D,TEMP2 * CURRENT CHAR IS LF FOLLOWING CR
BNE NOLF * THIS WILL NOT BE SENT
BTST #5,FLAG
BNE CRNOLF *IF SET, WILL NOT SEND LF AFTER CR
NOLF: BSR SENDSR
CRNOLF: BSR CKSER
CMP.W #$FFFF,D0
BNE NOSERL
BSR GETSER
MOVE.W D0,D3
ANDI.W #$7F,D3
BSR SHOWBYTE
NOSERL: BSR CKKB
CMP.W #$FFFF,D0
BNE NOKB
BSR GETKB
* CONTROL-Z ABORTS FILE TRANSFER (AND SENDS CONTROL-Z TO RECEIVING END)
CMP.B #$1A,D3
BEQ SSR
NOKB: MOVE.B TEMP,D3
MOVE.B D3,TEMP2
CMP.B #$1A,D3
BEQ SSR
CMP.B #0,D3
BNE LOOP4
ABORT: CMP.B #$1A,TEMP2
BEQ SSR
MOVE.B #$1A,D3
SSR: BSR SENDSR
MOVE.W FHNDL2,-(SP)
MOVE.W #$3E,-(SP)
TRAP #1
ADDA.L #4,SP
BCLR #4,FLAG
LEA STOPU,A0
BSR PSTRING
BRA TOP
* F6 TOGGLE DUPLEX
NOFN5: CMP.B #$40,D0
BNE NOFN6
BCHG #3,FLAG
BRA TOP
* F7 TOGGLES LF AFTER CR FOR FILE UPLOADS
NOFN6: CMP.B #$41,D0
BNE NOFN7
BCHG #5,FLAG
BEQ LFOFF
LEA MLFON,A0
BSR PSTRING
BRA TOP
LFOFF LEA MLFOFF,A0
BSR PSTRING
BRA TOP
* HELP
NOFN7: CMP.B #$62,D0
BNE NOHELP
LEA HELP,A0
BSR PSTRING
BRA TOP
NOHELP: CMP.W #0,D3
BEQ TOP
BSR SENDSR * SEND KEYPRESS TO SERIAL
BTST #3,FLAG * IF HALP DUPLEX, SHOW KEYPRESS
BEQ TOP
BSR SHOWBYTE
BRA TOP
* NOT SURE WHY, BUT HAVE TO SET FILE POINTER
SENDBF: MOVE.W D0,D5
BSR XOFF
CLR.W -(SP)
MOVE.W FHNDLE,-(SP)
MOVE.L FPTR,-(SP)
MOVE.W #$42,-(SP)
TRAP #1
ADDA.L #10,SP
PEA BUFFER
* MUST HAVE # OF BYTES TO TRANSFER IN D0
MOVE.W D5,D0
MOVE.L D0,-(SP)
MOVE.W FHNDLE,-(SP)
MOVE.W #$40,-(SP)
TRAP #1
ADDA.L #12,SP
MOVE.W #0,BUFFCOUNT
ADD.L D0,FPTR
BSR XON
RTS
* SEND A SERIAL BYTE (IN D3)
SENDSR: MOVE.W D3,-(SP)
MOVE.W #1,-(SP)
MOVE.W #3,-(SP)
TRAP #$D
ADDQ.L #6,SP
RTS
PSTRING: * SEND A STRING TO CONSOLE
MOVE.L A0,-(SP)
MOVE.W #9,-(SP)
TRAP #1
ADDQ.L #6,SP
RTS
SHOWBYTE: * EXPECTS BYTE TO DISPLAY IN D3
MOVE.W D3,-(A7)
MOVE.W #2,-(A7)
MOVE.W #3,-(A7)
TRAP #$D
ADDQ.L #6,A7
RTS
* GET KEYBOARD STATUS
CKKB: MOVE.W #2,-(A7)
MOVE.W #1,-(A7)
TRAP #$D
ADDQ.L #4,A7
RTS
* GET KEYCODE
GETKB: MOVE.W #2,-(A7)
MOVE.W #2,-(A7)
TRAP #$D
ADDQ.L #$4,A7
MOVE.W D0,D3
SWAP D0
RTS
* TRAP TO GET SERIAL STATUS
CKSER: MOVE.W #1,-(A7)
MOVE.W #1,-(A7)
TRAP #$D
ADDQ.L #4,A7
RTS
* TRAP TO GET SERIAL BYTE
GETSER: MOVE.W #1,-(A7)
MOVE.W #2,-(A7)
TRAP #$D
ADDQ.L #4,A7
RTS
* GET FILE NAME IN FNBUFF
GETFN: PEA FNBUFF
MOVE.W #$A,-(SP)
TRAP #1
ADDA.L #6,SP
LEA FNBUFF,A0
CLR.B #2(A0,D0.W) * PUT ZERO AT END OF FILENAME
RTS
YESNO: BSR CKKB
CMP.W #$FFFF,D0
BNE YESNO
BSR GETKB
BSR SHOWBYTE
CMP.B #$59,D3
BEQ NXT1
MOVE.W FHNDL3,-(SP)
MOVE.W #$3E,-(SP)
TRAP #1
ADDA.L #4,SP
RTS
* SUBR TO CREATE A FILE - NAME IN FNBUFF
FILECR: MOVE.W #0,-(SP)
PEA FNBUFF+2
MOVE.W #$3C,-(SP)
TRAP #1
ADDA.L #8,SP
TST.L D0
BPL NOERR
LEA FERROR2,A0
BSR PSTRING
NOERR: RTS
* SUBROUTINE TO SEND BYTE TO PRINTER
* NOTE: THIS TRAPS CONTROL BYTES
* CHECK FOR A CONTROL BYTE < $20
* AT PRESENT NOT USED (NO GOOD AT 1200 BAUD)
PRNT: CMP.B #$20,D3
BGE NOCTL
MULU #2,D3 * MULTIPLY * 2 SINCE TABLE IS IN WORDS
LEA PTABLE,A0
MOVE.W #0(A0,D3.W),D0 * SUBSTITUE A NEW VALUE FOR PRINTER
MOVE.W D0,D3
NOCTL: CMP.B #0,D3
BEQ NONULL * DON'T BOTHER SENDING NULLS TO PRINTER
PRSTATUS: * GET PRINTER STATUS AND LOOP UNTIL READY
MOVE.W #0,-(A7)
MOVE.W #1,-(A7)
TRAP #$D
ADDQ.L #4,A7
CMP.W #$FFFF,D0
BEQ PRSTATUS
* PRINT THE BYTE
MOVE.W D3,-(A7)
MOVE.W #0,-(A7)
MOVE.W #3,-(A7)
TRAP #$D
ADDQ.L #6,A7
NONULL: RTS
XOFF MOVEM.L D0-D3/A0-A3,-(SP)
MOVE.B #$13,D3
BSR SENDSR
MOVEM.L (SP)+,D0-D3/A0-A3
RTS
XON MOVEM.L D0-D3/A0-A3,-(SP)
MOVE.B #$11,D3
BSR SENDSR
MOVEM.L (SP)+,D0-D3/A0-A3
RTS
OPENFR: MOVE.W #0,-(SP) * OPEN FILE - READ ONLY
PEA FNBUFF+2
MOVE.W #$3D,-(SP)
TRAP #1
ADDA.L #8,SP
RTS
* OPEN A FILE FOR WRITING
OPENFW: MOVE.W #1,-(SP) * WRITE ONLY
PEA FNBUFF+2
MOVE.W #$3D,-(SP)
TRAP #1
ADDA.L #8,SP * ROUTINE TO PROPERLY CLOSE FILE
RTS
* DUMP PARTIAL BUFFER
FILEND: LEA BUFFCOUNT,A1
LEA BUFFER,A0
MOVE.W (A1),D0
MOVE.B #$1A,D3 * PUT EOF MARKER
MOVE.B D3,#0(A0,D0.W)
ADD.W #1,D0
MOVE.W D0,BUFFCOUNT
EXT.L D0
BSR SENDBF
* CLOSE FILE BEFORE EXITING
CLOSED: MOVE.W #$0D,-(SP) * FUNCTION NUMBER FOR RESET DISK
TRAP #1
ADDA.L #2,SP
RTS
SETBAUD:
MOVE.W #-1,-(A7)
MOVE.W #-1,-(A7)
MOVE.W #-1,-(A7)
MOVE.W #-1,-(A7)
MOVE.W #-1,-(A7)
MOVE.W D0,-(A7)
MOVE.W #15,-(A7)
TRAP #14
ADDA.L #14,A7
RTS
* ESC CODE SUBSTITUTION TABLE
.DATA
EVEN
PTABLE: DC.W 0,0,0,0,0,0,0,0,127,9,10,10,10,13,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
* MESSAGE SECTION
HELLO: DC.B ' * * * TERMINAL PROGRAM WITH ASCII DOWNLOAD/UPLOAD * * *',$0D,$0A
DC.B ' * * * PUBLIC DOMAIN. By Alan Page - August 1985 * * * ',$0D,$0A
DC.B ' * * * PRESS "HELP" FOR FUNCTION KEY DEFINITIONS * * * ',$0D,$0A
DC.B ' * * * PRESS "UNDO" TO EXIT TO DESKTOP * * * ',$0D,$0A,0
HELP: DC.B $0D,$0A,'<F1> = TOGGLE 300/1200 BAUD <F2> = TOGGLE CAPTURE <F3> = CREATE CAPTURE FILE',$0D,$0A
DC.B '<F4> = OPEN UPLOAD FILE <F5> = UPLOAD TEXT FILE <F6> = TOGGLE DUPLEX',$0D,$0A
DC.B '<F7> = TOGGLES LF AFTER CR RETURN (UPLOADS ONLY) ',$0D,$0A,0
WARN: DC.B $0D,$0A,' * * * THIS FILE ALREADY EXISTS, OPENING IT FOR DOu.LOAD WILL DESTROY IT * * * ',$0D,$0A
DC.B ' PRESS <Y> TO PROCEED, ANY OTHER KEY ABORTS > ',0
STARTF: DC.B $0D,$0A,' * * * START DISK CAPTURE * * * ',$0D,$0A,0
STOPF: DC.B $0D,$0A,' * * * STOP DISK CAPTURE * * * ',$0D,$0A,0
STARTU: DC.B $0D,$0A,' * * * STARTING FILE UPLOAD * * * ',$0D,$0A,0
STOPU: DC.B $0D,$0A,' * * * UPLOAD COMPLETE * * * ',$0D,$0A,0
MLFON: DC.B $0D,$0A,' * * * LF SENT AFTER CR (DURING UPLOADS) * * * ',$0D,$0A,0
MLFOFF: DC.B $0D,$0A,' * * * LF NOT SENT AFTER CR (DURING UPLOADS) * * * ',$0D,$0A,0
FERROR: DC.B $0D,$0A,' * * * FILE NOT OPEN * * * ',$0D,$0A,0
FERROR2: DC.B $0D,$0A,' * * * TOS FILE ERROR * * * ',$0D,$0A,0
FERR3: DC.B $0D,$0A,' * * * AN OUTPUT FILE ALREADY EXISTS! * * * ',$0D,$0A,0
PROMPT: DC.B $0D,$0A,'ENTER FILE NAME (FOR DISK CAPTURE) > ',0
PROMPT2: DC.B $0D,$0A,'ENTER FILE NAME (TO BE TRANSMITTED) > ',0
OKMSG: DC.B $0D,$0A,' * * * FILE CREATED * * * ',$0D,$0A,0
OKMSG2: DC.B $0D,$0A,' * * * FILE OPENED FOR OUTPUT * * * ',$0D,$0A,0
BAUD12: DC.B $0D,$0A,' * * * 1200 BAUD * * * ',$0D,$0A,0
BAUD3: DC.B $0D,$0A,' * * * 300 BAUD * * * ',$0D,$0A,0
FLAG: DC.B 0
EVEN
BAUD: DC.B 7
FPTR: DC.L 0
FHNDLE: DS.W 1
FHNDL2: DS.W 1
FHNDL3: DS.W 1
BUFFCOUNT: DC.W 0
FNBUFF: DC.B 80,0
DS.B 80
EVEN
TEMP: DS.W 1
TEMP2 DS.W 1
.BSS
EVEN
DS.L 256
USTK DS.L 1
BUFFER: DS.B 32000
.END
--------------------------------------------------------------------
--
Anees Munshi
{allegra,ihnp4,linus,decvax}!utzoo!utcsri!utecfa!mugc
{ihnp4|decvax|utzoo|utcsri}!utecfa!mugc
Subject: Subject: Terminal prg for ST (assembler source, long)
Newsgroups: Newsgroups: net.micro.atari