mirror of
https://github.com/A2osX/A2osX.git
synced 2024-11-22 16:31:07 +00:00
306 lines
5.5 KiB
Plaintext
306 lines
5.5 KiB
Plaintext
PR#3
|
||
PREFIX /A2OSX.BUILD
|
||
NEW
|
||
INC 1
|
||
AUTO 6
|
||
.LIST OFF
|
||
.OP 65C02
|
||
.OR $2000
|
||
.TF /A2OSX.BUILD/SBIN/GETTY
|
||
*--------------------------------------
|
||
.INB /A2OSX.BUILD/INC/MACROS.I
|
||
.INB /A2OSX.BUILD/INC/A2OSX.I
|
||
.INB /A2OSX.BUILD/INC/NET.TELNET.I
|
||
*--------------------------------------
|
||
TIMEOUT.MAX .EQ 100 1 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 #16 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.TELNETOPT .DA MSG.TELNETOPT
|
||
L.MSG.GREETINGS .DA MSG.GREETINGS
|
||
L.ENV.TERM .DA ENV.TERM
|
||
L.HEX .DA HEX
|
||
L.HEX2 .DA HEX2
|
||
.DA 0 End Of Reloc Table
|
||
*--------------------------------------
|
||
CS.INIT ldy #S.PS.ARGC
|
||
lda (pPs),y
|
||
cmp #2
|
||
bne .9
|
||
|
||
lda #1
|
||
>SYSCALL GetArg.A
|
||
|
||
>SYSCALL MkNod.YA
|
||
bcs .9
|
||
|
||
ldy #S.PS.hStdIn
|
||
sta (pPs),y
|
||
ldy #S.PS.hStdOut
|
||
sta (pPs),y
|
||
ldy #S.PS.hStdErr
|
||
sta (pPs),y
|
||
|
||
lda #2
|
||
>SYSCALL GetArg.A
|
||
bcs .9
|
||
|
||
>SYSCALL ExpandStr.YA
|
||
bcs .9
|
||
|
||
txa
|
||
|
||
>STA.G hBinName
|
||
|
||
lda (pPs)
|
||
ora #S.PS.F.EVENT Now accept events
|
||
sta (pPs)
|
||
|
||
clc
|
||
rts
|
||
|
||
>LDYA L.MSG.USAGE
|
||
>SYSCALL PrintF.YA
|
||
lda #0
|
||
sec
|
||
.9 rts
|
||
*--------------------------------------
|
||
CS.RUN >SLEEP
|
||
>SYSCALL GetChar
|
||
bcs CS.RUN
|
||
|
||
.11
|
||
* jsr PRINTA2
|
||
>SLEEP
|
||
>SYSCALL GetChar
|
||
|
||
bcc .11
|
||
|
||
jsr Init.Timeout
|
||
|
||
ldy #0
|
||
|
||
.1 lda MSG.TELNETOPT,y
|
||
phy
|
||
>SYSCALL PutChar.A
|
||
ply
|
||
iny
|
||
cpy #MSG.TELNETOPT.LEN
|
||
bne .1
|
||
|
||
* >LDYA L.MSG.TELNETOPT
|
||
* >SYSCALL PrintF.YA
|
||
* bcs *
|
||
|
||
CS.RUN.LOOP
|
||
|
||
.1 >SLEEP
|
||
>SYSCALL GetChar
|
||
bcs .4
|
||
|
||
* jsr PRINTA
|
||
|
||
cmp #IAC
|
||
beq CS.RUN.IACMODE
|
||
|
||
|
||
|
||
.4 jsr Wait.Timeout
|
||
bcc .1
|
||
|
||
>LDYA L.MSG.GREETINGS
|
||
>SYSCALL PrintF.YA
|
||
|
||
bcs .8 unable to send greetings...reset..
|
||
|
||
ldy #hBinName
|
||
lda (pData),y
|
||
>SYSCALL GetMemPtr.A
|
||
>SYSCALL ExecPS.YA
|
||
.9 rts
|
||
|
||
.8 clc
|
||
rts
|
||
*--------------------------------------
|
||
CS.RUN.IACMODE >SLEEP Wait for IAC VERB (or SB)
|
||
>SYSCALL GetChar
|
||
bcs CS.RUN.IACMODE
|
||
|
||
>STA.G IAC.VERB
|
||
* jsr PRINTA
|
||
|
||
.1 >SLEEP Wait for IAC OPT
|
||
>SYSCALL GetChar
|
||
bcs .1
|
||
|
||
>STA.G IAC.OPT
|
||
* jsr PRINTA
|
||
|
||
>LDA.G IAC.VERB
|
||
cmp #SB
|
||
beq CS.RUN.IACSB
|
||
*--------------------------------------
|
||
CS.RUN.IACVERB
|
||
* lda #'.'
|
||
* >SYSCALL PutChar.A
|
||
jmp CS.RUN.LOOP
|
||
*--------------------------------------
|
||
CS.RUN.IACSB
|
||
.1 >SLEEP
|
||
>SYSCALL GetChar
|
||
bcs .1
|
||
|
||
>STA.G IAC.SB
|
||
|
||
* jsr PRINTA
|
||
|
||
lda #0
|
||
sta (pData) reset IAC.SB.DATA
|
||
|
||
.2 >SLEEP
|
||
>SYSCALL GetChar
|
||
bcs .2
|
||
|
||
cmp #IAC
|
||
beq .4 end of DATA, go wait SE
|
||
|
||
pha
|
||
* jsr PRINTA
|
||
|
||
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
|
||
|
||
cmp #SE
|
||
bne .8
|
||
|
||
>LDA.G IAC.OPT
|
||
cmp #TELOPT.TTYPE
|
||
bne .8
|
||
|
||
>LDA.G IAC.SB
|
||
cmp #SB.IS
|
||
bne .8
|
||
|
||
>PUSHEA.G IAC.SB.DATA
|
||
>PUSHW L.ENV.TERM
|
||
>SYSCALL SetEnv
|
||
|
||
.8
|
||
* lda #':'
|
||
* >SYSCALL PutChar.A
|
||
jmp CS.RUN.LOOP
|
||
*--------------------------------------
|
||
CS.DOEVENT lda (pEvent)
|
||
bpl .9 is it a TIMER event?
|
||
|
||
ldy #TimeOut
|
||
lda (pData),y
|
||
beq .9
|
||
|
||
dec
|
||
sta (pData),y
|
||
|
||
.9 sec do not discard TIMER event
|
||
rts
|
||
*--------------------------------------
|
||
CS.QUIT ldy #hBinName
|
||
lda (pData),y
|
||
beq .1
|
||
>SYSCALL FreeMem.A
|
||
|
||
.1 ldx #DEVMGR.CLOSE
|
||
* jsr pDevJmp
|
||
|
||
clc
|
||
rts
|
||
*--------------------------------------
|
||
Init.Timeout ldy #TimeOut
|
||
lda #TIMEOUT.MAX
|
||
sta (pData),y
|
||
rts
|
||
*--------------------------------------
|
||
Wait.TimeOut sec
|
||
ldy #TimeOut
|
||
lda (pData),y
|
||
beq .9
|
||
clc
|
||
.9 rts
|
||
*--------------------------------------
|
||
PRINTA pha
|
||
>PUSHA
|
||
>LDYA L.HEX
|
||
>SYSCALL PrintF.YA
|
||
pla
|
||
rts
|
||
*--------------------------------------
|
||
PRINTA2 pha
|
||
>PUSHA
|
||
>LDYA L.HEX2
|
||
>SYSCALL PrintF.YA
|
||
pla
|
||
rts
|
||
CS.END
|
||
MSG.USAGE >CSTR "Usage : GETTY <DEV> <PROGRAM>\r\n"
|
||
MSG.TELNETOPT .DA #IAC,#WILL,#TELOPT.BINARY
|
||
.DA #IAC,#DO,#TELOPT.LINEMODE
|
||
.DA #IAC,#SB,#TELOPT.LINEMODE,#SB.SEND,#0,#IAC,#SE
|
||
.DA #IAC,#DONT,#TELOPT.ECHO
|
||
.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,#SB,#TELOPT.TTYPE,#SB.SEND,#IAC,#SE
|
||
MSG.TELNETOPT.LEN .EQ *-MSG.TELNETOPT
|
||
MSG.GREETINGS >CSTR "\r\nA2osX-GeTTY 0.9.1\r\n"
|
||
ENV.TERM >CSTR "TERM"
|
||
HEX >CSTR "[%h]"
|
||
HEX2 >CSTR "{%h}"
|
||
* \e[12h
|
||
*--------------------------------------
|
||
.DUMMY
|
||
.OR 0
|
||
DS.START
|
||
IAC.SB.DATA .BS 64
|
||
hBinName .BS 1
|
||
TimeOut .BS 1
|
||
IAC.VERB .BS 1
|
||
IAC.OPT .BS 1
|
||
IAC.SB .BS 1
|
||
DS.END .ED
|
||
MAN
|
||
SAVE /A2OSX.SRC/SBIN/GETTY.S
|
||
ASM
|