mirror of
https://github.com/A2osX/A2osX.git
synced 2024-11-26 13:49:18 +00:00
293 lines
5.5 KiB
Plaintext
293 lines
5.5 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 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.LINEMODE .DA TELNETOPT.LINEMODE
|
||
L.ENV.TERM .DA ENV.TERM
|
||
L.MSG.DEBUG .DA MSG.DEBUG
|
||
.DA 0 End Of Reloc Table
|
||
*--------------------------------------
|
||
CS.INIT ldy #S.PS.ARGC
|
||
lda (pPs),y
|
||
cmp #2
|
||
bne .90
|
||
|
||
>PUSHBI 0
|
||
|
||
lda #1
|
||
>SYSCALL GetArg get /dev/xxx
|
||
|
||
>SYSCALL open
|
||
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
|
||
|
||
lda #2
|
||
>SYSCALL GetArg
|
||
bcs .9
|
||
|
||
lda (pPs)
|
||
ora #S.PS.F.EVENT Now accept events
|
||
sta (pPs)
|
||
|
||
clc
|
||
rts
|
||
|
||
.90 >LDYA L.MSG.USAGE
|
||
>SYSCALL puts
|
||
lda #0
|
||
sec
|
||
.9 rts
|
||
*--------------------------------------
|
||
CS.RUN >PUSHWI TELNETOPTS.LEN
|
||
>PUSHW L.TELNETOPTS
|
||
ldy #S.PS.hStdOut
|
||
lda (pPs),y
|
||
>SYSCALL write
|
||
bcs CS.RUN.8
|
||
|
||
>PUSHWI K.VER
|
||
>PUSHBI 2
|
||
>LDYA L.MSG.GREETINGS
|
||
>SYSCALL printf
|
||
|
||
bcs CS.RUN.8 unable to send greetings...reset..
|
||
|
||
jsr Init.Timeout
|
||
|
||
CS.RUN.LOOP
|
||
>SLEEP
|
||
|
||
.1 >SYSCALL GetChar
|
||
bcs .2
|
||
cmp #IAC
|
||
beq CS.RUN.IACMODE
|
||
>SYSCALL PutChar
|
||
bcc .8
|
||
bra CS.RUN.8
|
||
|
||
.2 jsr Wait.Timeout
|
||
bcc CS.RUN.LOOP
|
||
|
||
|
||
.8 lda #2
|
||
>SYSCALL GetArg
|
||
>SYSCALL ExecPS
|
||
|
||
CS.RUN.8 clc
|
||
rts
|
||
*--------------------------------------
|
||
CS.RUN.IACMODE jsr PrintHEX
|
||
|
||
>SLEEP Wait for IAC VERB (or SB)
|
||
>SYSCALL GetChar
|
||
bcs CS.RUN.IACMODE
|
||
|
||
jsr PrintHEX
|
||
|
||
>STA.G IAC.CMD
|
||
|
||
.1 >SLEEP Wait for IAC OPT
|
||
>SYSCALL GetChar
|
||
bcs .1
|
||
|
||
jsr PrintHEX
|
||
|
||
>STA.G IAC.SUBCMD
|
||
tax
|
||
|
||
>LDA.G IAC.CMD
|
||
cmp #SB
|
||
beq CS.RUN.IACSB
|
||
*--------------------------------------
|
||
CS.RUN.IACVERB 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.LINEMODE.LEN
|
||
>PUSHW L.TELNETOPT.LINEMODE
|
||
|
||
.7 ldy #S.PS.hStdOut
|
||
lda (pPs),y
|
||
>SYSCALL write
|
||
|
||
.8 jmp CS.RUN.LOOP
|
||
*--------------------------------------
|
||
CS.RUN.IACSB
|
||
.1 >SLEEP
|
||
>SYSCALL GetChar
|
||
bcs .1
|
||
|
||
jsr PrintHEX
|
||
>STA.G IAC.SB
|
||
|
||
lda #0
|
||
sta (pData) reset IAC.SB.DATA
|
||
|
||
.2 >SLEEP
|
||
>SYSCALL GetChar
|
||
bcs .2
|
||
|
||
jsr PrintHEX
|
||
cmp #IAC
|
||
beq .4 end of DATA, go wait SE
|
||
|
||
pha
|
||
|
||
ldy #IAC.SB.DATA-1
|
||
|
||
.3 iny
|
||
lda (pData),y
|
||
bne .3
|
||
|
||
pla
|
||
sta (pData),y
|
||
iny
|
||
lda #0
|
||
sta (pData),y
|
||
bra .2
|
||
|
||
.4 >SLEEP
|
||
>SYSCALL GetChar
|
||
bcs .4
|
||
|
||
jsr PrintHEX
|
||
|
||
cmp #SE
|
||
bne .8
|
||
|
||
>LDA.G IAC.SUBCMD
|
||
cmp #TELOPT.TTYPE
|
||
bne .8
|
||
|
||
>LDA.G IAC.SB
|
||
cmp #SB.IS
|
||
bne .8
|
||
|
||
>PUSHEA.G IAC.SB.DATA
|
||
>LDYA L.ENV.TERM
|
||
>SYSCALL SetEnv
|
||
|
||
.8 jmp CS.RUN.LOOP
|
||
*--------------------------------------
|
||
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 close
|
||
|
||
.8 clc
|
||
rts
|
||
*--------------------------------------
|
||
Init.Timeout lda #TIMEOUT.MAX
|
||
>STA.G TimeOut
|
||
rts
|
||
*--------------------------------------
|
||
Wait.TimeOut sec
|
||
>LDA.G TimeOut
|
||
beq .9
|
||
clc
|
||
.9 rts
|
||
*--------------------------------------
|
||
PrintHEX pha
|
||
>PUSHA
|
||
>PUSHBI 1
|
||
>LDYA L.MSG.DEBUG
|
||
>SYSCALL printf
|
||
pla
|
||
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.LINEMODE
|
||
.DA #IAC,#SB,#TELOPT.LINEMODE,#SB.SEND,#0,#IAC,#SE
|
||
TELNETOPT.LINEMODE.LEN
|
||
ENV.TERM .AZ "TERM"
|
||
*--------------------------------------
|
||
.DUMMY
|
||
.OR 0
|
||
DS.START
|
||
IAC.SB.DATA .BS 64
|
||
IAC.CMD .BS 1
|
||
IAC.SUBCMD .BS 1
|
||
IAC.SB .BS 1
|
||
hDEV .BS 1
|
||
TimeOut .BS 1
|
||
DS.END .ED
|
||
MAN
|
||
SAVE /A2OSX.SRC/SBIN/GETTY.S
|
||
ASM
|