A2osX/SBIN/GETTY.S.txt

325 lines
5.7 KiB
Plaintext
Raw Normal View History

2015-03-14 21:48:35 +00:00
PR#3
PREFIX /A2OSX.BUILD
2015-03-14 21:48:35 +00:00
NEW
INC 1
AUTO 6
.LIST OFF
.OP 65C02
.OR $2000
.TF /A2OSX.BUILD/SBIN/GETTY
2015-03-14 21:48:35 +00:00
*--------------------------------------
.INB /A2OSX.BUILD/INC/MACROS.I
.INB /A2OSX.BUILD/INC/A2OSX.I
.INB /A2OSX.BUILD/INC/NET.TELNET.I
2015-03-14 21:48:35 +00:00
*--------------------------------------
TIMEOUT.MAX .EQ 10 1 sec.
*--------------------------------------
2015-06-03 18:30:57 +00:00
ZPTmp1 .EQ ZPBIN
2015-03-14 21:48:35 +00:00
*--------------------------------------
2015-06-03 18:30:57 +00:00
* File Header (16 Bytes)
2015-03-14 21:48:35 +00:00
*--------------------------------------
CS.START cld
jmp (.1,x)
2015-06-03 18:30:57 +00:00
.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
*--------------------------------------
2015-03-14 21:48:35 +00:00
.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
2015-06-03 18:30:57 +00:00
.DA 0 End Of Reloc Table
2015-03-14 21:48:35 +00:00
*--------------------------------------
CS.INIT >SYSCALL GetArgC
2016-08-17 06:25:58 +00:00
cmp #1
bne .1
>LDYA L.MSG.USAGE
>SYSCALL PrintFYA
lda #0
sec
rts
2016-08-17 06:25:58 +00:00
.1 lda #1
>SYSCALL GetArgA
2016-06-07 06:10:18 +00:00
2017-01-12 17:43:45 +00:00
>SYSCALL MkNodYA
bcs .9
ldy #S.PS.hStdIn
2015-06-03 18:30:57 +00:00
sta (pPs),y
2017-01-12 17:43:45 +00:00
ldy #S.PS.hStdOut
2015-06-03 18:30:57 +00:00
sta (pPs),y
2017-01-12 17:43:45 +00:00
ldy #S.PS.hStdErr
2015-06-03 18:30:57 +00:00
sta (pPs),y
2015-10-19 20:35:00 +00:00
2016-08-17 06:25:58 +00:00
lda #2
>SYSCALL GetArgA
2017-01-12 17:43:45 +00:00
bcs .9
2015-03-14 21:48:35 +00:00
>SYSCALL ExpandPStrYA
2017-01-12 17:43:45 +00:00
bcs .9
2016-08-17 06:25:58 +00:00
txa
2015-06-03 18:30:57 +00:00
ldy #hBinName
sta (pData),y
lda (pPs)
ora #S.PS.F.EVENT Now accept events
sta (pPs)
2016-06-07 06:10:18 +00:00
clc
2017-01-12 17:43:45 +00:00
.9 rts
2015-03-14 21:48:35 +00:00
*--------------------------------------
CS.RUN jsr Init.Timeout
.66 >SYSCALL Sleep
>SYSCALL GetC
bcc .1
bcs .66
* jsr Wait.Timeout
* bcc .66
* jmp .2
2017-02-04 22:07:06 +00:00
.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
2017-02-04 22:07:06 +00:00
>PUSHW L.TERM
>SYSCALL SetEnv
.5
>LDYA L.MSG.TELNET.OPT
>SYSCALL PrintFYA
bcs *
>LDYA L.MSG.GREETINGS
>SYSCALL PrintFYA
2015-06-03 18:30:57 +00:00
bcs .8 unable to send greetings...loop..
2015-06-03 18:30:57 +00:00
ldy #hBinName
lda (pData),y
>SYSCALL GetMemPtrA
>SYSCALL ExecProcessNewEnvYA
2015-06-03 18:30:57 +00:00
.9 rts
.8 clc
rts
2015-03-14 21:48:35 +00:00
*--------------------------------------
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
2015-03-14 21:48:35 +00:00
*--------------------------------------
2015-06-03 18:30:57 +00:00
CS.QUIT ldy #hBinName
lda (pData),y
beq .1
>SYSCALL FreeMemA
2015-06-03 18:30:57 +00:00
.1 ldx #DEVMGR.CLOSE
2016-06-07 06:10:18 +00:00
* jsr pDevJmp
2015-06-03 18:30:57 +00:00
clc
2015-03-14 21:48:35 +00:00
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
*--------------------------------------
2015-03-14 21:48:35 +00:00
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
2015-03-14 21:48:35 +00:00
*--------------------------------------
2015-06-03 18:30:57 +00:00
.DUMMY
.OR 0
DS.START
IAC.TERM .BS 64
2015-06-03 18:30:57 +00:00
hBinName .BS 1
TimeOut .BS 1
IAC.VERB .BS 1
IAC.OPT .BS 1
2015-06-03 18:30:57 +00:00
DS.END .ED
2015-03-14 21:48:35 +00:00
MAN
SAVE /A2OSX.SRC/SBIN/GETTY.S
2015-03-14 21:48:35 +00:00
ASM