mirror of
https://github.com/A2osX/A2osX.git
synced 2024-11-23 07:35:19 +00:00
290 lines
5.6 KiB
Plaintext
290 lines
5.6 KiB
Plaintext
NEW
|
||
PREFIX /A2OSX.BUILD
|
||
AUTO 4,1
|
||
.LIST OFF
|
||
.OP 65C02
|
||
.OR $2000
|
||
.TF SBIN/GETTY
|
||
*--------------------------------------
|
||
.INB INC/MACROS.I
|
||
.INB INC/A2OSX.I
|
||
.INB INC/NET.TELNET.I
|
||
*--------------------------------------
|
||
TIMEOUT.MAX .EQ 100 10 sec.
|
||
*--------------------------------------
|
||
* File Header (16 Bytes)
|
||
*--------------------------------------
|
||
CS.START cld
|
||
jmp (.1,x)
|
||
.DA #$61 6502,Level 1 (65c02)
|
||
.DA #1 BIN Layout Version 1
|
||
.DA #S.PS.F.EVENT S.PS.F
|
||
.DA #0
|
||
.DA CS.END-CS.START CS
|
||
.DA DS.END-DS.START DS
|
||
.DA #64 SS
|
||
.DA #0 ZP
|
||
.DA 0
|
||
*--------------------------------------
|
||
* Relocation Table
|
||
*--------------------------------------
|
||
.1 .DA CS.INIT
|
||
.DA CS.RUN
|
||
.DA CS.DOEVENT
|
||
.DA CS.QUIT
|
||
L.MSG.USAGE .DA MSG.USAGE
|
||
L.MSG.GREETINGS .DA MSG.GREETINGS
|
||
L.TELNETOPTS .DA TELNETOPTS
|
||
L.TELNETOPT.TTYPE .DA TELNETOPT.TTYPE
|
||
L.TELNETOPT.LMODE .DA TELNETOPT.LMODE
|
||
L.ENV.TERM .DA ENV.TERM
|
||
L.MSG.DEBUG .DA MSG.DEBUG
|
||
.DA 0 End Of Reloc Table
|
||
*--------------------------------------
|
||
CS.INIT clc
|
||
rts
|
||
*--------------------------------------
|
||
CS.RUN ldy #S.PS.ARGC
|
||
lda (pPs),y
|
||
cmp #3
|
||
|
||
bcc .90
|
||
|
||
>PUSHWI 0 auxtype
|
||
>PUSHBI 0 type
|
||
>PUSHBI O.RDWR
|
||
lda #1
|
||
>SYSCALL ArgV get /dev/xxx
|
||
|
||
>SYSCALL fopen
|
||
bcs .9
|
||
|
||
ldy #S.PS.hStdIn
|
||
sta (pPs),y
|
||
iny #S.PS.hStdOut
|
||
sta (pPs),y
|
||
iny #S.PS.hStdErr
|
||
sta (pPs),y
|
||
|
||
>STA.G hDEV
|
||
bra CS.RUN.LOOP0
|
||
|
||
.90 >LDYA L.MSG.USAGE
|
||
>SYSCALL puts
|
||
lda #E.SYN
|
||
sec
|
||
.9 rts
|
||
|
||
CS.RUN.LOOP0 >LDYA L.ENV.TERM
|
||
>SYSCALL UnSetEnv
|
||
|
||
.1 >PUSHWI TELNETOPTS.LEN
|
||
>PUSHW L.TELNETOPTS
|
||
ldy #S.PS.hStdOut
|
||
lda (pPs),y
|
||
>SYSCALL fwrite
|
||
bcc .2 sent!
|
||
|
||
tay
|
||
bne CS.RUN.9 error ?
|
||
|
||
>SLEEP
|
||
|
||
bra .1 no data sent, loop
|
||
|
||
.2 >PUSHWI K.VER
|
||
>PUSHBI 2
|
||
>LDYA L.MSG.GREETINGS
|
||
>SYSCALL printf
|
||
|
||
bcs CS.RUN.9 unable to send greetings...reset..
|
||
|
||
jsr Init.Timeout
|
||
|
||
CS.RUN.LOOP1 >SLEEP
|
||
|
||
>SYSCALL GetChar
|
||
bcs .1
|
||
|
||
cmp #IAC
|
||
beq CS.RUN.IACMODE
|
||
>SYSCALL PutChar
|
||
bcc .2
|
||
|
||
bra CS.RUN.LOOP1
|
||
|
||
.1 jsr Wait.Timeout
|
||
bcc CS.RUN.LOOP1
|
||
|
||
.2 >PUSHBI S.PS.F.DUPENV+S.PS.F.HOLD
|
||
|
||
lda #2
|
||
>SYSCALL ArgV
|
||
>SYSCALL ExecV
|
||
bcs CS.RUN.9
|
||
|
||
>SLEEP
|
||
|
||
jmp CS.RUN.LOOP0
|
||
|
||
clc
|
||
CS.RUN.9 rts
|
||
*--------------------------------------
|
||
CS.RUN.IACMODE >SLEEP Wait for IAC CMD (or SB)
|
||
>SYSCALL GetChar
|
||
bcs CS.RUN.IACMODE
|
||
|
||
>STA.G IAC.CMD
|
||
|
||
.1 >SLEEP Wait for IAC SUBCMD
|
||
>SYSCALL GetChar
|
||
bcs .1
|
||
|
||
>STA.G IAC.SUBCMD
|
||
tax
|
||
|
||
>LDA.G IAC.CMD
|
||
cmp #SB
|
||
beq CS.RUN.IAC.SB
|
||
*--------------------------------------
|
||
CS.RUN.IAC.CMD cmp #WILL
|
||
bne .8
|
||
|
||
cpx #TELOPT.TTYPE
|
||
bne .2
|
||
|
||
>PUSHWI TELNETOPT.TTYPE.LEN
|
||
>PUSHW L.TELNETOPT.TTYPE
|
||
bra .7
|
||
|
||
.2 cpx #TELOPT.LINEMODE
|
||
bne .8
|
||
|
||
>PUSHWI TELNETOPT.LMODE.LEN
|
||
>PUSHW L.TELNETOPT.LMODE
|
||
|
||
.7 ldy #S.PS.hStdOut
|
||
lda (pPs),y
|
||
>SYSCALL fwrite
|
||
|
||
.8 jmp CS.RUN.LOOP1
|
||
*--------------------------------------
|
||
CS.RUN.IAC.SB
|
||
.1 >SLEEP Wait for IAC SB.IS or SEND
|
||
>SYSCALL GetChar
|
||
bcs .1
|
||
|
||
>STA.G IAC.SB.CMD
|
||
|
||
>STZ.G IAC.SB.LEN
|
||
|
||
.2 >SLEEP
|
||
>SYSCALL GetChar
|
||
bcs .2
|
||
|
||
cmp #IAC
|
||
beq .4 end of DATA, go wait SE
|
||
|
||
pha
|
||
|
||
>LDA.G IAC.SB.LEN
|
||
clc
|
||
adc #IAC.SB.DATA
|
||
tay
|
||
|
||
pla
|
||
sta (pData),y
|
||
iny
|
||
lda #0
|
||
sta (pData),y
|
||
|
||
>INC.G IAC.SB.LEN
|
||
bra .2
|
||
|
||
.4 >SLEEP
|
||
>SYSCALL GetChar
|
||
bcs .4
|
||
|
||
cmp #SE
|
||
bne .8
|
||
|
||
>LDA.G IAC.SUBCMD
|
||
cmp #TELOPT.TTYPE
|
||
bne .8
|
||
|
||
>LDA.G IAC.SB.CMD
|
||
cmp #SB.IS
|
||
bne .8
|
||
|
||
>PUSHEA.G IAC.SB.DATA
|
||
>LDYA L.ENV.TERM
|
||
>SYSCALL SetEnv
|
||
|
||
.8 jmp CS.RUN.LOOP1
|
||
*--------------------------------------
|
||
CS.DOEVENT lda (pEvent)
|
||
bpl .9 is it a TIMER event?
|
||
|
||
>LDA.G TimeOut
|
||
beq .9
|
||
|
||
dec
|
||
sta (pData),y
|
||
|
||
.9 sec do not discard TIMER event
|
||
rts
|
||
*--------------------------------------
|
||
CS.QUIT >LDA.G hDEV
|
||
beq .8
|
||
|
||
>SYSCALL fclose
|
||
|
||
.8 clc
|
||
rts
|
||
*--------------------------------------
|
||
Init.Timeout lda #TIMEOUT.MAX
|
||
>STA.G TimeOut
|
||
rts
|
||
*--------------------------------------
|
||
Wait.TimeOut sec
|
||
>LDA.G TimeOut
|
||
beq .9
|
||
clc
|
||
.9 rts
|
||
*--------------------------------------
|
||
CS.END
|
||
MSG.USAGE .AZ "Usage : GETTY <DEV> <PROGRAM>"
|
||
MSG.GREETINGS .AZ "\r\nA2osX-GeTTY %d.%d\r\n"
|
||
MSG.DEBUG .AZ "{%h}"
|
||
*--------------------------------------
|
||
TELNETOPTS .DA #IAC,#WILL,#TELOPT.BINARY
|
||
.DA #IAC,#WILL,#TELOPT.ECHO
|
||
.DA #IAC,#WILL,#TELOPT.SGA
|
||
.DA #IAC,#DO,#TELOPT.SGA
|
||
.DA #IAC,#DO,#TELOPT.NAWS
|
||
.DA #IAC,#DO,#TELOPT.TTYPE
|
||
.DA #IAC,#DO,#TELOPT.LINEMODE
|
||
TELNETOPTS.LEN .EQ *-TELNETOPTS
|
||
*--------------------------------------
|
||
TELNETOPT.TTYPE .DA #IAC,#SB,#TELOPT.TTYPE,#SB.SEND,#IAC,#SE
|
||
TELNETOPT.TTYPE.LEN .EQ *-TELNETOPT.TTYPE
|
||
*--------------------------------------
|
||
TELNETOPT.LMODE .DA #IAC,#SB,#TELOPT.LINEMODE,#SB.SEND,#0,#IAC,#SE
|
||
TELNETOPT.LMODE.LEN .EQ *-TELNETOPT.LMODE
|
||
ENV.TERM .AZ "TERM"
|
||
*--------------------------------------
|
||
.DUMMY
|
||
.OR 0
|
||
DS.START
|
||
hDEV .BS 1
|
||
TimeOut .BS 1
|
||
IAC.CMD .BS 1
|
||
IAC.SUBCMD .BS 1
|
||
IAC.SB.CMD .BS 1
|
||
IAC.SB.LEN .BS 1
|
||
IAC.SB.DATA .BS 32
|
||
DS.END .ED
|
||
MAN
|
||
SAVE /A2OSX.SRC/SBIN/GETTY.S
|
||
ASM
|