A2osX/SBIN/GETTY.S.txt
2017-02-04 23:07:06 +01:00

160 lines
2.9 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

PR#3
PREFIX /A2OSX.SRC
NEW
INC 1
AUTO 6
.LIST OFF
.OP 65C02
.OR $2000
.TF /A2OSX.BOOT/SBIN/GETTY
*--------------------------------------
.INB /A2OSX.DEV/INC/MACROS.I
.INB /A2OSX.DEV/INC/A2OSX.I
.INB /A2OSX.DEV/INC/NET.TELNET.I
*--------------------------------------
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.TELNETOPT .DA MSG.TELNETOPT
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
txa
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
clc
.9 rts
*--------------------------------------
CS.RUN >LDYA L.MSG.TELNETOPT
>SYSCALL CPrintFYA
bcs .8
.10 >SYSCALL GetC
bcc .10
lda #5 Ctrl-E
>SYSCALL PutCA
bcs .8
.1 >SYSCALL Sleep
>SYSCALL GetC
bcs .2
tax
lda (pData)
cmp #63
beq .2
inc
sta (pData)
tay
txa
sta (pData),y
bra .1
.2 lda (pData)
beq .3
>PUSHW pdata
>PUSHW L.TERM
>SYSCALL SetEnv
.3 >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 sec
rts
*--------------------------------------
CS.QUIT ldy #hBinName
lda (pData),y
beq .1
>SYSCALL FreeMemA
.1 ldx #DEVMGR.CLOSE
* jsr pDevJmp
clc
rts
*--------------------------------------
CS.END
MSG.USAGE >CSTR "GETTY <DEV> <PROGRAM>"
MSG.TELNETOPT .DA #IAC,#WILL,#TELOPT.ECHO
.DA #IAC,#WILL,#TELOPT.SGA
.DA #IAC,#DONT,#TELOPT.LINEMODE
.DA #IAC,#DO,#TELOPT.NAWS
.DA #0
MSG.GREETINGS >CSTR "\nA2osX-GeTTY\n"
TERM >PSTR "TERM"
* \e[12h
*--------------------------------------
.DUMMY
.OR 0
DS.START
InBuf .BS 64
hBinName .BS 1
DS.END .ED
MAN
SAVE SBIN/GETTY.S
ASM