mirror of
https://github.com/A2osX/A2osX.git
synced 2024-11-26 13:49:18 +00:00
325 lines
5.7 KiB
Plaintext
325 lines
5.7 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 10 1 sec.
|
||
*--------------------------------------
|
||
ZPTmp1 .EQ ZPBIN
|
||
*--------------------------------------
|
||
* 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
|
||
.DA DS.END-DS.START Data Segment to Allocate
|
||
.DA 0
|
||
.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.TELNET.OPT .DA MSG.TELNET.OPT
|
||
L.MSG.GREETINGS .DA MSG.GREETINGS
|
||
L.TERM .DA TERM
|
||
.DA 0 End Of Reloc Table
|
||
*--------------------------------------
|
||
CS.INIT >SYSCALL GetArgC
|
||
cmp #1
|
||
bne .1
|
||
|
||
>LDYA L.MSG.USAGE
|
||
>SYSCALL CPrintFYA
|
||
lda #0
|
||
sec
|
||
rts
|
||
|
||
.1 lda #1
|
||
>SYSCALL GetArgA
|
||
|
||
>SYSCALL MkNodYA
|
||
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 GetArgA
|
||
bcs .9
|
||
|
||
>SYSCALL ExpandPStrYA
|
||
bcs .9
|
||
|
||
txa
|
||
|
||
ldy #hBinName
|
||
sta (pData),y
|
||
|
||
lda (pPs)
|
||
ora #S.PS.F.EVENT Now accept events
|
||
sta (pPs)
|
||
|
||
clc
|
||
.9 rts
|
||
*--------------------------------------
|
||
CS.RUN jsr Init.Timeout
|
||
|
||
.66 >SYSCALL Sleep
|
||
>SYSCALL GetC
|
||
bcc .1
|
||
bcs .66
|
||
* jsr Wait.Timeout
|
||
* bcc .66
|
||
|
||
* jmp .2
|
||
|
||
|
||
.10 >SYSCALL Sleep
|
||
>SYSCALL GetC
|
||
bcs .1
|
||
|
||
|
||
|
||
.1 cmp #IAC
|
||
beq .11
|
||
|
||
jmp .2
|
||
|
||
.11 >SYSCALL Sleep
|
||
>SYSCALL GetC
|
||
bcs .11
|
||
|
||
ldy #IAC.VERB
|
||
sta (pData),y
|
||
|
||
* jsr PRINT.DEBUG
|
||
|
||
.12 >SYSCALL Sleep
|
||
>SYSCALL GetC
|
||
bcs .12
|
||
|
||
ldy #IAC.OPT
|
||
sta (pData),y
|
||
|
||
* jsr PRINT.DEBUG
|
||
|
||
ldy #IAC.VERB
|
||
lda (pData),y
|
||
cmp #SB
|
||
bne .10
|
||
|
||
ldy #IAC.OPT
|
||
lda (pData),y
|
||
cmp #TELOPT.TTYPE
|
||
bne .15 only interested in Term Type, go get IAC,SE
|
||
|
||
.13 >SYSCALL Sleep
|
||
>SYSCALL GetC
|
||
bcs .13
|
||
|
||
cmp #SB.IS not a valid reply, go get IAC,SE
|
||
bne .15
|
||
|
||
lda #0
|
||
sta (pData) reset IAC.TERM
|
||
|
||
.14 >SYSCALL Sleep
|
||
>SYSCALL GetC
|
||
bcs .14
|
||
|
||
cmp #IAC
|
||
beq .16 end of DATA, go wait SE
|
||
|
||
pha
|
||
lda (pData)
|
||
inc
|
||
tay
|
||
sta (pData)
|
||
pla
|
||
|
||
sta (pData),y
|
||
bra .14
|
||
|
||
.15 >SYSCALL Sleep
|
||
>SYSCALL GetC
|
||
bcs .15
|
||
|
||
cmp #IAC
|
||
bne .15
|
||
|
||
.16 >SYSCALL Sleep
|
||
>SYSCALL GetC
|
||
bcs .16
|
||
|
||
cmp #SE
|
||
bne .16
|
||
|
||
|
||
jmp .10
|
||
|
||
.2
|
||
|
||
lda (pData)
|
||
beq .5
|
||
>PUSHW pData
|
||
>PUSHW L.TERM
|
||
>SYSCALL SetEnv
|
||
|
||
.5
|
||
|
||
>LDYA L.MSG.TELNET.OPT
|
||
>SYSCALL CPrintFYA
|
||
bcs *
|
||
|
||
>LDYA L.MSG.GREETINGS
|
||
>SYSCALL CPrintFYA
|
||
|
||
bcs .8 unable to send greetings...loop..
|
||
|
||
ldy #hBinName
|
||
lda (pData),y
|
||
>SYSCALL GetMemPtrA
|
||
>SYSCALL ExecProcessNewEnvYA
|
||
.9 rts
|
||
|
||
.8 clc
|
||
rts
|
||
*--------------------------------------
|
||
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 FreeMemA
|
||
|
||
.1 ldx #DEVMGR.CLOSE
|
||
* jsr pDevJmp
|
||
|
||
clc
|
||
rts
|
||
*--------------------------------------
|
||
PRINT.DEBUG phx
|
||
phy
|
||
pha
|
||
|
||
lda #2
|
||
>SYSCALL GetDevByIDA
|
||
bcs .9
|
||
|
||
>STYA ZPTmp1
|
||
lda (ZPTmp1)
|
||
sta PRINT.DEBUG.JMP+1
|
||
ldy #1
|
||
lda (ZPTmp1),y
|
||
sta PRINT.DEBUG.JMP+2
|
||
|
||
lda #'{'
|
||
ldx #DEVMGR.WRITE
|
||
jsr PRINT.DEBUG.JMP
|
||
|
||
pla
|
||
pha
|
||
lsr
|
||
lsr
|
||
lsr
|
||
lsr
|
||
tax
|
||
lda PRINT.DEBUG.CHAR,x
|
||
|
||
ldx #DEVMGR.WRITE
|
||
jsr PRINT.DEBUG.JMP
|
||
|
||
pla
|
||
pha
|
||
and #$0F
|
||
tax
|
||
lda PRINT.DEBUG.CHAR,x
|
||
|
||
ldx #DEVMGR.WRITE
|
||
jsr PRINT.DEBUG.JMP
|
||
|
||
lda #'}'
|
||
ldx #DEVMGR.WRITE
|
||
jsr PRINT.DEBUG.JMP
|
||
|
||
.9 pla
|
||
ply
|
||
plx
|
||
rts
|
||
PRINT.DEBUG.JMP jmp $ffff
|
||
*--------------------------------------
|
||
Init.Timeout ldy #TimeOut
|
||
lda #TIMEOUT.MAX
|
||
sta (pData),y
|
||
rts
|
||
*--------------------------------------
|
||
Wait.TimeOut sec
|
||
ldy #TimeOut
|
||
lda (pData),y
|
||
beq .9
|
||
clc
|
||
.9 rts
|
||
*--------------------------------------
|
||
CS.END
|
||
PRINT.DEBUG.CHAR .AS "0123456789ABCDEF"
|
||
MSG.USAGE >CSTR "GETTY <DEV> <PROGRAM>\r\n"
|
||
MSG.TELNET.OPT
|
||
* .DA #IAC,#WILL,#TELOPT.BINARY
|
||
* .DA #IAC,#DO,#TELOPT.LINEMODE
|
||
* .DA #IAC,#SB,#TELOPT.LINEMODE,#1,#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
|
||
.DA #0
|
||
MSG.GREETINGS >CSTR "\r\nA2osX-GeTTY\r\n"
|
||
TERM >PSTR "TERM"
|
||
* \e[12h
|
||
*--------------------------------------
|
||
.DUMMY
|
||
.OR 0
|
||
DS.START
|
||
IAC.TERM .BS 64
|
||
hBinName .BS 1
|
||
TimeOut .BS 1
|
||
IAC.VERB .BS 1
|
||
IAC.OPT .BS 1
|
||
DS.END .ED
|
||
MAN
|
||
SAVE /A2OSX.SRC/SBIN/GETTY.S
|
||
ASM
|