A2osX/SBIN/GETTY.S.txt

305 lines
5.7 KiB
Plaintext
Raw Normal View History

2015-03-14 21:48:35 +00:00
PR#3
2015-03-15 22:00:40 +00:00
PREFIX /A2OSX.BUILD
2015-03-14 21:48:35 +00:00
NEW
INC 1
AUTO 6
.LIST OFF
.OP 65C02
.OR $2000
.TF SBIN/GETTY
*--------------------------------------
.INB INC/MACROS.I
.INB INC/A2OSX.I
*--------------------------------------
* Main entry point
*--------------------------------------
* Code signature and INIT table
*--------------------------------------
* CLD $D8
* JMP (*,x) $7C
* #JMPTABLE
* /JMPTABLE
*--------------------------------------
CS.START cld
jmp (.1,x)
.1 .DA CS.INIT
.DA CS.RUN
.DA CS.DOEVENT
.DA CS.QUIT
L.MSG.GREETINGS .DA MSG.GREETINGS
L.MSG.LOGIN .DA MSG.LOGIN
L.MSG.PASSWORD .DA MSG.PASSWORD
.DA 0
.DA CS.END-CS.START Code Length To Relocate
.DA DS.END-DS.START Data Segment to Allocate
*--------------------------------------
CS.INIT ldy #S.PS.hARGS
lda (pPsContext),y
>PUSHA
>PUSHBI $20 Push SEP=' '
>PUSHBI 1 Push 1 for getting INDEV
>SYSCALL SYS.PStrGetTkn
bcs .9
sta hDEVNAME
>SYSCALL SYS.GetDevByNameA
bcs .8
sta hINDEV
ldy #S.PS.hINDEV
sta (pPsContext),y
lda hDEVNAME
>SYSCALL SYS.FreeMemA
ldy #S.PS.hARGS
lda (pPsContext),y
>PUSHA
>PUSHBI $20 Push SEP=' '
>PUSHBI 2 Push 1 for getting OUTDEV
>SYSCALL SYS.PStrGetTkn
.9 bcs .99
sta hDEVNAME
>SYSCALL SYS.GetDevByNameA
.8 bcs .98
sta hOUTDEV
ldy #S.PS.hOUTDEV
sta (pPsContext),y
ldy #S.PS.hERRDEV
sta (pPsContext),y
lda hDEVNAME
>SYSCALL SYS.FreeMemA
ldy #S.PS.hARGS
lda (pPsContext),y
>PUSHA
>PUSHBI $20 Push SEP=' '
>PUSHBI 3 Push 3 for getting BIN
>SYSCALL SYS.PStrGetTkn
bcs .99
sta BINID
ldy #S.PS.ID
lda (pPsContext),y
* ldy #S.DEV.hOWNERPS
* sta (DEVMGR.DEVPTR),y
>LDYA L.MSG.GREETINGS
jsr PRINT.MSG
lda hOUTDEV
jsr PRBYTE
stz STATUS
lda (pPsContext)
ora #S.PS.F.EVENT Now accept events
sta (pPsContext)
clc Tell TskMgr To stay in memory
rts
.98 pha
lda hDEVNAME
>SYSCALL SYS.FreeMemA
pla
sec
.99 rts
*--------------------------------------
CS.RUN lda STATUS
bne CS.RUN.1
jsr CROUT
jsr CROUT
>LDYA L.MSG.LOGIN
jsr PRINT.MSG
jsr INPUT.INIT
inc STATUS
clc
rts
CS.RUN.1 cmp #1
bne CS.RUN.2
ldx INSTATUS
beq .9
ldx INBUFFER
beq .2
.1 lda INBUFFER,x
sta USERNAME,x
dex
bpl .1
inc STATUS
clc
rts
.2 dec STATUS
.9 clc
rts
CS.RUN.2 cmp #2
bne CS.RUN.3
jsr CROUT
>LDYA L.MSG.PASSWORD
jsr PRINT.MSG
jsr INPUT.INIT
inc STATUS
clc
rts
CS.RUN.3 cmp #3
bne CS.RUN.4
ldx INSTATUS
beq .9
ldx INBUFFER
beq .2
.1 lda INBUFFER,x
sta PASSWORD,x
dex
bpl .1
.2 inc STATUS
.9 clc
rts
CS.RUN.4 cmp #4
bne CS.RUN.5
jsr CROUT
inc STATUS TODO:CHECK USER/PASS
clc
rts
CS.RUN.5 cmp #5
bne CS.RUN.6
lda BINID
ldx pPsContext
stx pPsContext.SAVE
ldx pPsContext+1
stx pPsContext.SAVE+1
>SYSCALL SYS.CreateProcessA
ldx pPsContext.SAVE
stx pPsContext
ldx pPsContext.SAVE+1
stx pPsContext+1
bcs .9
sta CHILDPSID
inc STATUS
clc
rts
.9 jsr PRBYTE
stz STATUS
clc
rts
CS.RUN.6 dec CHILDPSIDPOLL
bne .8
lda CHILDPSID Check for CHILDTSKID
>SYSCALL SYS.GetPSByIDA
bcc .8 Still Alive ?
stz STATUS
stz CHILDPSID
.8 clc
rts
*--------------------------------------
CS.DOEVENT >PULLW pEvent
lda CHILDPSID
bne .99
ldy #S.EVT.hDEV
lda (pEvent),y
cmp hINDEV
bne .99
lda (pEvent)
and #S.EVT.F.KEY
beq .99
ldy #S.EVT.DATAHI
lda (pEvent),y
bne .99
ldy #S.EVT.DATALO
lda (pEvent),y
jsr INPUT.CHARIN
>SYSCALL SYS.DestroyEvent
clc
rts
.99 sec
rts
*--------------------------------------
CS.QUIT clc
rts
*--------------------------------------
* PRIVATE
*--------------------------------------
PRINT.MSG >STYA ZPQuickPtr1
ldy #0
.1 lda (ZPQuickPtr1),y
beq .2
ora #$80
jsr COUT
iny
bne .1
.2 rts
*--------------------------------------
INPUT.INIT stz INSTATUS
stz INBUFFER
rts
*--------------------------------------
INPUT.CHARIN ldx INSTATUS
bne .9
cmp #$20
bcc .1
ldx INBUFFER
inx
cpx #16
beq .9
sta INBUFFER,x
stx INBUFFER
ora #$80
jmp COUT
.1 cmp #$0D
bne .9
inc INSTATUS
.9 rts
*--------------------------------------
PRBYTE pha
lsr
lsr
lsr
lsr
ora #$B0
cmp #$BA
bcc .1
adc #6
.1 jsr COUT
pla
and #$0F
ora #$B0
cmp #$BA
bcc COUT
adc #6
bra COUT
*--------------------------------------
CROUT lda #13
*--------------------------------------
COUT >PUSHA
phx
phy
ldy #S.PS.hOUTDEV
lda (pPsContext),y
>SYSCALL SYS.DevOutA
ply
plx
rts
*--------------------------------------
MSG.GREETINGS >CSTRING "A2osX-GeTTY on Dev="
MSG.LOGIN >CSTRING "login:"
MSG.PASSWORD >CSTRING "password:"
*--------------------------------------
CS.END
DS.START
*--------------------------------------
hDEVNAME .BS 1
hINDEV .BS 1
hOUTDEV .BS 1
BINID .BS 1
STATUS .BS 1
CHILDPSID .BS 1
CHILDPSIDPOLL .BS 1
INSTATUS .BS 1
INBUFFER .BS 16
USERNAME .BS 16
PASSWORD .BS 16
pPsContext.SAVE .BS 2
*--------------------------------------
DS.END
MAN
SAVE SBIN/GETTY.S
ASM