Brian's work....no additional comment required....pfff

This commit is contained in:
burniouf 2021-12-02 22:28:26 +01:00
parent 62ebd7a9f4
commit 27b04e8e44
53 changed files with 8363 additions and 1447 deletions

Binary file not shown.

Binary file not shown.

518
BIN/BF.S.txt Normal file
View File

@ -0,0 +1,518 @@
NEW
AUTO 3,1
.LIST OFF
.OP 65C02
.OR $2000
.TF bin/bf
*--------------------------------------
.INB inc/macros.i
.INB inc/a2osx.i
.INB inc/mli.i
.INB inc/mli.e.i
*--------------------------------------
BF.DATASIZE .EQ 1024
*--------------------------------------
* Zero Page Segment, up to 32 bytes
*--------------------------------------
.DUMMY
.OR ZPBIN
ZS.START
ZPCodePtr .BS 2
ZPDataPtr .BS 2
ZPPtr1 .BS 2
ZPPtr2 .BS 2
ZPPtr3 .BS 2
ArgIndex .BS 1
hFileBuf .BS 1
hDataBuf .BS 1
bDebug .BS 1
bTrace .BS 1
StackCnt .BS 1
ZPCnt .BS 1
ZS.END .ED
*--------------------------------------
* File Header (16 Bytes)
*--------------------------------------
CS.START cld
jmp (.1,x)
.DA #$61 6502,Level 1 (65c02)
.DA #1 BIN Layout Version 1
.DA #0 S.PS.F.EVENT
.DA #0
.DA CS.END-CS.START Code Size (without Constants)
.DA DS.END-DS.START Data SegmentSize
.DA #64 Stack Size
.DA #ZS.END-ZS.START Zero Page Size
.DA 0
*--------------------------------------
* Relocation Table
*--------------------------------------
.1 .DA CS.INIT
.DA CS.RUN
.DA CS.DOEVENT
.DA CS.QUIT
L.MSG.GREETINGS .DA MSG.GREETINGS
L.MSG.USAGE .DA MSG.USAGE
L.MSG.ECHOCRLF .DA MSG.ECHOCRLF
L.MSG.DEBUG .DA MSG.DEBUG
L.MSG.ERR .DA MSG.ERR
J.BF.KW .DA BF.KW.INCPTR
.DA BF.KW.DECPTR
.DA BF.KW.INCDATA
.DA BF.KW.DECDATA
.DA BF.KW.PUTCHAR
.DA BF.KW.GETCHAR
.DA BF.KW.WHILE
.DA BF.KW.END
.DA 0
*--------------------------------------
* Called once at process creation
* Put code for loading LIB here
*--------------------------------------
CS.INIT clc
CS.INIT.RTS rts
*--------------------------------------
* Called until exit with CS
* if RUN exits with CC, RN entered again
*--------------------------------------
CS.RUN >PUSHW L.MSG.GREETINGS
>PUSHW A2osX.KVER
>PUSHBI 2
>SYSCALL PrintF
bcs CS.INIT.RTS
jsr CS.RUN.ARGS
bcs CS.INIT.RTS
jsr BF.Init
bcs CS.INIT.RTS
.1 >SLEEP
>LDA.G bDebug
bpl .2
jsr PrintDebugMsg
.2 >LDA.G bTrace
bpl .3
jsr PrintTraceMsg
.3 jsr BF.Run
bcc .1
cmp #MLI.E.EOF
beq .8
pha
jsr PrintErrMsg
pla
sec
rts
.8 lda #0 Exit Code = Success
sec
rts
*--------------------------------------
CS.RUN.ARGS inc ArgIndex
lda ArgIndex
>SYSCALL ArgV
bcs .7
>STYA ZPPtr1
lda (ZPPtr1)
cmp #'-'
bne .4
ldy #1
lda (ZPPtr1),y
ldx #OptionVars-OptionList-1
.1 cmp OptionList,x
beq .2
dex
bpl .1
bra .90
.2 ldy OptionVars,x
lda #$ff
sta $0,y
bra CS.RUN.ARGS
.4 lda hFileBuf
bne .90
>LDYA ZPPtr1
jsr CS.RUN.LoadFile
bcs .9
>STYA ZPCodePtr
stx hFileBuf
bra CS.RUN.ARGS
.7 lda hFileBuf
beq .90
clc
.9 rts
.90 >PUSHW L.MSG.USAGE
>PUSHBI 0
>SYSCALL PrintF
lda #E.SYN
sec QUIT Process
rts
*--------------------------------------
CS.RUN.LoadFile >SYSCALL LoadTxtFile
bcs .9
phx
txa
>SYSCALL GetMemPtr
plx
.9 rts
*--------------------------------------
BF.Init >LDYAI BF.DATASIZE
>SYSCALL GetMem
bcs .9
>STYA ZPDataPtr
stx hDataBuf
>STYA ZPPtr1
ldx /BF.DATASIZE
lda #0
tay
.1 sta (ZPPtr1),y
iny
bne .1
inc ZPPtr1+1
dex
bne .1
.9 rts
*--------------------------------------
BF.Run jsr BF.GetCodeByte
beq .8
ldx #BF.KW.Cnt-1
.2 cmp BF.KW,x
bne .3
txa
asl
tax
jmp (J.BF.KW,x)
.3 dex
bpl .2
lda #E.CSYN
sec
rts
.8 lda #MLI.E.EOF
sec
rts
*--------------------------------------
BF.KW.INCPTR inc ZPDataPtr
bne .8
inc ZPDataPtr+1
.8 clc
jmp BF.NextCodeByte
*--------------------------------------
BF.KW.DECPTR lda ZPDataPtr
bne .8
dec ZPDataPtr+1
.8 dec ZPDataPtr
clc
jmp BF.NextCodeByte
*--------------------------------------
BF.KW.INCDATA lda (ZPDataPtr)
inc
sta (ZPDataPtr)
clc
jmp BF.NextCodeByte
*--------------------------------------
BF.KW.DECDATA lda (ZPDataPtr)
dec
sta (ZPDataPtr)
clc
jmp BF.NextCodeByte
*--------------------------------------
BF.KW.PUTCHAR lda (ZPDataPtr)
>SYSCALL PutChar
bcs .9
jmp BF.NextCodeByte
.9 rts
*--------------------------------------
BF.KW.GETCHAR >SYSCALL GetChar
bcs .9
sta (ZPDataPtr)
jmp BF.NextCodeByte
.9 rts
*--------------------------------------
BF.KW.WHILE lda (ZPDataPtr)
bne .8
lda #1
sta ZPCnt
.1 jsr BF.NextCodeByte
jsr BF.GetCodeByte
beq .9
cmp #'['
bne .2
inc ZPCnt
bra .1
.2 cmp #']'
bne .1
dec ZPCnt
bne .1
clc
jmp BF.NextCodeByte
.8 >PUSHW ZPCodePtr
inc StackCnt
clc
jmp BF.NextCodeByte
.9 lda #E.ESYN
sec
rts
*--------------------------------------
BF.KW.END lda StackCnt
beq .9
>PULLW ZPCodePtr
dec StackCnt
clc
rts
.9 lda #E.STACKERROR
sec
rts
*--------------------------------------
BF.GetCodeByte lda (ZPCodePtr)
beq .8
cmp #C.SPACE
beq .7
cmp #C.CR
beq .7
cmp #C.LF
beq .7
cmp #'#'
bne .8
.2 jsr BF.NextCodeByte
lda (ZPCodePtr)
beq .8
cmp #C.CR
bne .2
.7 jsr BF.NextCodeByte
bra BF.GetCodeByte
.8 rts
*--------------------------------------
BF.NextCodeByte inc ZPCodePtr
bne .8
inc ZPCodePtr+1
.8 rts
*--------------------------------------
CS.DOEVENT sec
rts
*--------------------------------------
CS.QUIT lda hFileBuf
beq .1
>SYSCALL FreeMem
.1 lda hDataBuf
beq .8
>SYSCALL FreeMem
.8 rts
*--------------------------------------
PrintDebugMsg >LDYA pStack
>STYA ZPPtr2
>PUSHW L.MSG.DEBUG
>PUSHW ZPCodePtr
>PUSHW ZPDataPtr
>PUSHB (ZPDataPtr)
>PUSHW ZPPtr2
>PUSHBI 7
>SYSCALL PrintF
rts
*--------------------------------------
PrintErrMsg >LDA.G bTrace
bmi .5
jsr PrintTraceMsg
.5 lda ZPPtr3
cmp ZPCodePtr
bne .6
lda ZPPtr3+1
cmp ZPCodePtr+1
beq .8
.6 ldy #S.PS.hStdErr
lda (pPS),y
>PUSHA
>PUSHBI '-'
>SYSCALL FPutC
inc ZPPtr3
bne .5
inc ZPPtr3+1
bra .5
.8 ldy #S.PS.hStdErr
lda (pPS),y
>PUSHA
>PUSHW L.MSG.ERR
>PUSHW ZPPtr2 Line counter
>PUSHBI 2
>SYSCALL FPrintF
rts
*--------------------------------------
PrintTraceMsg lda hFileBuf
.12 >SYSCALL GetMemPtr
>STYA ZPPtr1
stz ZPPtr2
stz ZPPtr2+1 Line counter
.1 inc ZPPtr2
bne .2
inc ZPPtr2+1
.2 >LDYA ZPPtr1
>STYA ZPPtr3 save line start
.20 lda (ZPPtr1)
beq .4 EoF
inc ZPPtr1
bne .3
inc ZPPtr1+1
.3 cmp #C.CR
bne .20 Scan until EoL
ldx ZPPtr1
cpx ZPCodePtr
lda ZPPtr1+1
sbc ZPCodePtr+1
bcc .1 not this line....
.4 ldy #S.PS.hStdErr
lda (pPS),y
>PUSHA
>PUSHBI '>'
>SYSCALL FPutC
ldy #$ff
.7 iny
lda (ZPPtr3),y
beq .8
cmp #C.CR
beq .8
phy
pha
ldy #S.PS.hStdErr
lda (pPS),y
>PUSHA
pla
>PUSHA
>SYSCALL FPutC
ply
bra .7
.8 ldy #S.PS.hStdErr
lda (pPS),y
>PUSHA
>PUSHW L.MSG.ECHOCRLF
>PUSHBI 0
>SYSCALL FPrintF
rts
*--------------------------------------
CS.END
*--------------------------------------
* Initialized DATA
*--------------------------------------
MSG.GREETINGS .AZ "\r\nBrainFuck-Shell %d.%d\r\n\r\n"
MSG.USAGE .AS "Usage : BF <option> file\r\n"
.AS " -D : Debug Mode\r\n"
.AS " -T : Trace On"
MSG.ECHOCRLF .AZ "\r\n"
MSG.DEBUG .AZ "pCode=%H, pData=%H(%h), pStack=%H\r\n"
MSG.ERR .AZ "-^\r\nLine #%D:"
*--------------------------------------
OptionList .AS "DdTt"
OptionVars .DA #bDebug,#bDebug,#bTrace,#bTrace
*--------------------------------------
BF.KW .AS "><+-.,[]"
BF.KW.Cnt .EQ *-BF.KW
*--------------------------------------
.DUMMY
.OR 0
DS.START
DS.END .ED
*--------------------------------------
MAN
SAVE usr/src/bin/bf.s
ASM

130
BIN/CC.S.CODE.txt Normal file
View File

@ -0,0 +1,130 @@
NEW
AUTO 3,1
.LIST OFF
*--------------------------------------
CODE.PushXFromYA
jsr CODE.LDXYAI
ldx #PCC.PushXFromYA.L
ldy #0
.1 lda PCC.PushXFromYA,y
jsr CODE.EmitByte
iny
dex
bne .1
rts
*--------------------------------------
CODE.PopXToYA jsr CODE.LDXYAI
ldx #PCC.PopXToYA.L
ldy #0
.1 lda PCC.PopXToYA,y
jsr CODE.EmitByte
iny
dex
bne .1
rts
*--------------------------------------
CODE.PUSHI pha
lda #$A9 LDA #imm
jsr CODE.EmitByte
pla
jsr CODE.EmitByte
bra CODE.PUSHA
*--------------------------------------
CODE.LDXYAI pha
lda #$A2 LDX #imm
jsr CODE.EmitByte
txa
jsr CODE.EmitByte
lda #$A0 LDY #imm
jsr CODE.EmitByte
tya
jsr CODE.EmitByte
lda #$A9 LDA #imm
jsr CODE.EmitByte
pla
bra CODE.EmitByte
*--------------------------------------
CODE.PUSHYA jsr CODE.PUSHA
lda #$AA TYA
jsr CODE.EmitByte
*--------------------------------------
CODE.PUSHA lda #$C6 DEC zp
jsr CODE.EmitByte
lda #pStack
jsr CODE.EmitByte
lda #$92 STA (zp)
jsr CODE.EmitByte
lda #pStack
jmp CODE.EmitByte
*--------------------------------------
CODE.PULLYA jsr CODE.PULLA
lda #$48 PHA
jsr CODE.EmitByte
jsr CODE.PULLA
lda #$7A PLY
bra CODE.EmitByte
*--------------------------------------
CODE.PULLA lda #$B2 LDA (zp)
jsr CODE.EmitByte
lda #pStack
jsr CODE.EmitByte
*--------------------------------------
CODE.INCPSTACK lda #$E6 INC zp
jsr CODE.EmitByte
lda #pStack
bra CODE.EmitByte
*--------------------------------------
CODE.JMPYX lda #$4C
bra CODE.JSRYX.1
*--------------------------------------
CODE.JSRYX lda #$20 JSR
CODE.JSRYX.1 jsr CODE.EmitByte
tya
jsr CODE.EmitByte
txa
bra CODE.EmitByte
*--------------------------------------
CODE.FPUCALL lda #$A2 LDX #imm
jsr CODE.EmitByte
txa
jsr CODE.EmitByte
lda #$20 JSR
jsr CODE.EmitByte
lda #A2osX.FPUCALL
jsr CODE.EmitByte
lda /A2osX.FPUCALL
bra CODE.EmitByte
*--------------------------------------
CODE.SYSCALL lda #$A2 LDX #imm
jsr CODE.EmitByte
txa
jsr CODE.EmitByte
lda #$20 JSR
jsr CODE.EmitByte
lda #A2osX.SYSCALL
jsr CODE.EmitByte
lda /A2osX.SYSCALL
*--------------------------------------
CODE.EmitByte sta (ZPCCCode)
inc ZPCCCode
bne .8
inc ZPCCCode+1
.8 rts
*--------------------------------------
MAN
SAVE usr/src/bin/cc.s.code
LOAD usr/src/bin/cc.s
ASM

1287
BIN/CC.S.CORE.txt Normal file

File diff suppressed because it is too large Load Diff

126
BIN/CC.S.DIR.txt Normal file
View File

@ -0,0 +1,126 @@
NEW
AUTO 3,1
.LIST OFF
*--------------------------------------
CC.DIR jsr CC.GetNextCharNB
bcs .99
cmp #'!' #!/bin/cc
bne .1
jmp CC.SkipLine
.1 >LDYA L.CC.DIRS
jsr CC.LookupID
bcs .91
jmp (J.CC.DIRS,x)
.91 lda #E.CSYN
sec
.99 rts
*--------------------------------------
CC.DIR.DEFINE jsr CC.CheckSpace
bcs .99
jsr CC.IsLetter
bcs .90
>LDA.G CC.hDefines
jsr CC.NewKey
bcs .99
>STYA ZPSymID
jsr CC.CheckSpace
bcs .99
ldy #$ff
.1 iny
lda (ZPLineBufPtr),y
beq .2
cmp #C.CR
bne .1
dey
.2 iny
phy
>PUSHB.G CC.hDefines
>PUSHW ZPSymID
>PUSHW ZPLineBufPtr
ply
lda #0
>PUSHYA DataLen
>SYSCALL SListAddData
bcs .99
jmp CC.SkipLine
.90 lda #E.CSYN
sec
.99 rts
*--------------------------------------
CC.DIR.INCLUDE lda #0 >STZ.G PathBuf
sta (pData)
jsr CC.CheckSpace
bcs .99
cmp #'"'
beq .1
cmp #'<'
bne .90
>PUSHW L.ENV.INCLUDE
>PUSHW pData >PUSHEA.G PathBuf
>SYSCALL GetEnv
bcs .90
lda #'>'
.1 sta ArgIndex
ldy #$ff
.2 iny
lda (pData),y
bne .2
.3 jsr CC.GetNextChar
beq .90
cmp ArgIndex
beq .8
sta (pData),y
iny
cpy #64
bne .3
.90 lda #E.CSYN
sec
.99 rts
.8 lda #0
sta (pData),y terminate string
jsr CC.GetNextChar skip " or >
>LDYA pData
jsr CS.RUN.FOpen
bcs .99
rts
*--------------------------------------
MAN
SAVE usr/src/bin/cc.s.dir
LOAD usr/src/bin/cc.s
ASM

91
BIN/CC.S.EXEC.txt Normal file
View File

@ -0,0 +1,91 @@
NEW
AUTO 3,1
.LIST OFF
*--------------------------------------
CC.BOPS.bMUL
CC.BOPS.cMUL
clc
rts
*--------------------------------------
CC.BOPS.bDIV
CC.BOPS.cDIV
clc
rts
*--------------------------------------
CC.BOPS.bMOD
CC.BOPS.cMOD
clc
rts
*--------------------------------------
CC.BOPS.ADD clc
>PULLA
adc (pStack)
sta (pStack)
clc
rts
*--------------------------------------
CC.BOPS.SUB sec
ldy #1
lda (pStack),y
sbc (pStack)
sta (pStack),y
inc pStack
clc
rts
*--------------------------------------
CC.BOPS.SHL lda (pStack)
tax
beq .8
ldy #1
lda (pStack),y
.1 asl
dex
bne .1
sta (pStack),y
.8 inc pStack
clc
rts
*--------------------------------------
CC.BOPS.SHR lda (pStack)
tax
beq .8
ldy #1
lda (pStack),y
.1 lsr
dex
bne .1
sta (pStack),y
.8 inc pStack
clc
rts
*--------------------------------------
CC.BOPS.L
CC.BOPS.G
CC.BOPS.LE
CC.BOPS.GE
CC.BOPS.EQ
CC.BOPS.NE
CC.BOPS.AND
CC.BOPS.OR
CC.BOPS.EOR
CC.BOPS.LAND
CC.BOPS.LOR
clc
rts
*--------------------------------------
MAN
SAVE usr/src/bin/cc.s.exec
LOAD usr/src/bin/cc.s
ASM

421
BIN/CC.S.EXP.txt Normal file
View File

@ -0,0 +1,421 @@
NEW
AUTO 3,1
.LIST OFF
*--------------------------------------
* Input:
* ZPLineBufPtr, Y,A = Expected type/qual
* Output:
* CS, A = EC
* CC, Y,A = type/qual, Value on Stack
*--------------------------------------
CC.ExpEval ldx ZPPtr1
phx
ldx ZPPtr1+1 local : used by lookup
phx
ldx ZPPtr2 local : expected T/Q
phx
ldx ZPPtr2+1
phx
ldx ZPPtr3 local : BOP
phx
ldx ZPPtr3+1 local : PREOPS
phx
>STYA ZPPtr2
lda #$ff no previous OP
pha
*--------------------------------------
.10 jsr CC.GetCharNB
bcs .19
jsr CC.ExpPreops
bcs .19
.11 cmp #'('
bne .20
jsr CC.GetNextCharNB skip (
bcs .19
>LDYA ZPPtr2 expected T/Q
jsr CC.ExpEval
bcs .19
>STYA ZPPtr2 update T/Q
jsr CC.GetCharNB
bcs .19
cmp #')'
bne .19
jsr CC.GetNextCharNB skip )
bcc .31
.19 jmp .90
*--------------------------------------
.20 jsr CC.IsLetter define, f() or Var ?
bcs .22
jsr CC.GetDefine
bcc .10
jsr CC.SymLookup
bcs .22
>LDA.G CC.VarDef+1 qual
and #CC.Q.FUNC
bne .21
jsr CC.ExpGet Check T/Q & Get value on stack
bcs .29
bra .30
*--------------------------------------
.21 >LDYA ZPPtr2 get expected T/Q
jsr CC.fExecRetV
bcs .29
>STYA ZPPtr2 store real T/Q
bra .30
*--------------------------------------
.22 jsr CC.IsDigit10 number ?
bcs .24
ldy ZPPtr2
bne .23
ldy #CC.T.SINT
sty ZPPtr2
stz ZPPtr2+1
.23 jsr CC.GetNumOnStack
bcs .29
bra .30
.24 cmp #'"' String literal
bne .90
jsr CC.AddContCharP
.29 bcs .99
*--------------------------------------
.30 jsr CC.GetCharNB
bcs .90
.31 cmp #';'
beq .80
cmp #','
beq .80
cmp #')'
beq .80
jsr CC.IsOPChar
bcs .90
>LDYA L.CC.BOPS we are at V1 op1 V2 op2...
jsr CC.LookupOP
bcs .90
stx ZPPtr3 save OP(n)
.32 plx get OP(n-1)
bmi .33 $ff....
cpx ZPPtr3
bcc .33 OP(n) has precedence, on stack : V1,V2
>LDYA ZPPtr2 OP(n-1) has precedence...
jsr CC.ExpBops compute V(n-1) <OP(n-1)> V(n)
bcc .32
bcs .99
.33 phx push back OP(n-1)
lda ZPPtr3 get OP(n)
pha push OP(n) on stack
jmp .10 go check for next token
*--------------------------------------
.80 plx any OP on stack ?
bmi .88
>LDYA ZPPtr2 Var Type
jsr CC.ExpBops
bcc .80
bcs .99
.90 lda #E.ESYN
.99 plx
bpl .99
sec
bra .89
.88 clc
>LDYA ZPPtr2 Type/Qual
.89 plx
stx ZPPtr3+1
plx
stx ZPPtr3
plx
stx ZPPtr2+1
plx
stx ZPPtr2
plx
stx ZPPtr1+1
plx
stx ZPPtr1
rts
*--------------------------------------
CC.ExpPreops >LDYA L.CC.PREOPS
jsr CC.LookupOP
bcc .8
ldx #$ff
.8 stx ZPPtr3+1
jmp CC.GetCharNB
*--------------------------------------
* Y,A = Type/Qual, X = OP
*--------------------------------------
CC.ExpBops cpy #CC.T.UINT
bcs .3
cpy #CC.T.UCHAR
beq .1
cpy #CC.T.SCHAR
beq .2
lda #E.TMISMATCH
sec
rts
.1 ldy J.CC.bBOPS,x
lda J.CC.bBOPS+1,x
tax
jsr CODE.JSRYX
clc
rts
.2 ldy J.CC.cBOPS,x
lda J.CC.cBOPS+1,x
tax
jsr CODE.JSRYX
clc
rts
.3 txa
clc
adc CC.Type2FPU-CC.T.UINT,y
tax
jsr CODE.FPUCALL
clc
rts
*--------------------------------------
CC.AddContCharP
ldy #0
.1 jsr CC.GetNextChar
bcs .9
cmp #C.CR
beq .9
cmp #'"'
beq .2
sta (ZPCCConst),y
iny
bra .1
.2 lda #0
sta (ZPCCConst),y
lda ZPCCConst+1 Push PTR on stack
jsr CODE.PUSHI
lda ZPCCConst
jsr CODE.PUSHI
tya
sec
adc ZPCCConst
sta ZPCCConst
bcc .3
inc ZPCCConst+1
.3 jsr CC.GetNextChar Skip "
clc
rts
.9 lda #E.ESYN
sec
rts
*--------------------------------------
CC.GetNumOnStack
cpy #CC.T.FLOAT
bcc .1
beq .11
lda #E.TMISMATCH
* sec
rts
.11 >PUSHW ZPLineBufPtr
>PUSHWI ZPLineBufPtr
>SYSCALL StrToF
* bcs .9
ldy #4
.10 lda (pStack),y
jsr CODE.PUSHI
dey
bpl .10
>POP 5
clc
rts
*--------------------------------------
.1 >PUSHW ZPLineBufPtr
>PUSHWI ZPLineBufPtr
>PUSHBI 10
lda CC.TYPESIGN-1,y
bmi .2
>SYSCALL StrToUL
bra .3
.2 >SYSCALL StrToL
.3 bcs .9
ldx ZPPtr2
lda CC.TYPESIZE-1,x
dec
tay
.5 lda (pStack),y
jsr CODE.PUSHI
dey
bpl .5
>POP 4
* clc
.9 rts
*--------------------------------------
CC.SymLookup >PUSHB.G CC.hSymbols
>PUSHW ZPLineBufPtr
>SYSCALL SListLookup
bcs .9
phy
pha
txa
* clc
adc ZPLineBufPtr
sta ZPLineBufPtr
bcc .1
inc ZPLineBufPtr+1
.1 >PUSHB.G CC.hSymbols
pla
>PUSHA
pla
>PUSHA KeyID
>PUSHEA.G CC.VarDef
>PUSHWI SYMDEFSIZE
>PUSHWZ From Start
>SYSCALL SListGetData
.9 rts
*--------------------------------------
* ZPPtr2 = expected T/Q
* ZPPtr3+1 = PREOPS
*--------------------------------------
CC.ExpGet ldx ZPPtr3+1
bmi CC.ExpGet2
jmp (J.CC.PREOPS,x)
CC.ExpGet.Ref >LDA.G CC.VarDef+5 DataPtr+1
jsr CODE.PUSHI
>LDA.G CC.VarDef+4 DataPtr
jsr CODE.PUSHI
clc
rts
CC.ExpGet.Deref
clc
rts
CC.ExpGet2 lda ZPPtr2 target type
beq .1
>LDA.G CC.VarDef Type
cmp #CC.T.VOID
beq .11
cmp ZPPtr2
bne .9
.11 lda ZPPtr2+1 qual
>CMP.G CC.VarDef+1
bne .9
.1 >LDA.G CC.VarDef Type
sta ZPPtr2
pha
iny
lda (pData),y
sta ZPPtr2+1 qual
ply
jsr CC.GetVarSize X = size
>LDA.G CC.VarDef+4 DataPtr
pha
iny
lda (pData),y
ply
.3 jsr CODE.PushXFromYA
clc
rts
.9 lda #E.TMISMATCH
sec
rts
*--------------------------------------
MAN
SAVE usr/src/bin/cc.s.exp
LOAD usr/src/bin/cc.s
ASM

339
BIN/CC.S.KW.txt Normal file
View File

@ -0,0 +1,339 @@
NEW
AUTO 3,1
.LIST OFF
*--------------------------------------
* Built in Keywords
*--------------------------------------
CC.KW.JMP txa
>STA.G CC.CmdSave
jmp (J.CC.KW,x)
*--------------------------------------
CC.WHILE jsr CC.PushCS push Test location for WHILE loop
bcc CC.IF
rts
*--------------------------------------
CC.IF jsr CC.GetCharNB
bcs .9
cmp #'('
bne .9
jsr CC.GetNextCharNB
bcs .9
ldy #0 Any var type
lda #0
jsr CC.ExpEval
bcs .99
jsr CC.IsValue0
jsr CC.GetCharNB
bcs .99
cmp #')'
bne .9
jsr CC.GetNextCharNB skip ')'
bcs .9
jsr CC.PushCS push place to set JMP if false
bcs .99
lda ZPCCCode
clc
adc #2
sta ZPCCCode
bcc .5
inc ZPCCCode+1
.5 >LDA.G CC.CmdSave
jsr CC.Push push IF / WHILE
bcs .99
lda #'}' end block expected
jmp CC.Push
.9 lda #E.CSYN
sec
.99 rts
*--------------------------------------
CC.IF.END jsr CC.Pop
bcs .9
sta ZPPtr1
jsr CC.Pop
bcs .9
sta ZPPtr1+1
lda ZPCCCode
sta (ZPPtr1)
ldy #1
lda ZPCCCode+1
sta (ZPPtr1),y
* clc
.9 rts
*--------------------------------------
CC.ELSE
clc
rts
*--------------------------------------
CC.WHILE.END jsr CC.Pop
bcs .9
sta ZPPtr1
jsr CC.Pop
bcs .9
sta ZPPtr1+1
jsr CC.Pop
bcs .9
pha
jsr CC.Pop
bcs .9
tax
ply
jsr CODE.JMPYX
lda ZPCCCode
sta (ZPPtr1)
ldy #1
lda ZPCCCode+1
sta (ZPPtr1),y
clc
.9 rts
*--------------------------------------
CC.DO
CC.FOR
CC.SWITCH
CC.CASE
CC.BREAK
CC.CONTINUE
CC.SIZEOF
*--------------------------------------
CC.TYPEDEF lda #E.CSYN
sec
rts
*--------------------------------------
CC.STRUCT >ENTER 4
jsr CC.GetCharNB
bcs .99
>LDA.G CC.hTags
jsr CC.NewKey
bcs .99
sta (pStack) Y,A = KeyID
tya
ldy #1
sta (pStack),y
jsr CC.GetNextCharNB
bcs .99
cmp #'{'
bne .99
.1 jsr CC.GetNextCharNB
bcs .99
cmp #'}'
bne .1
jsr CC.GetNextCharNB skip }
clc
.99 >LEAVE
rts
*--------------------------------------
* Input : Value on Stack, Y,A = Type/Qual
* Output : CC = true, CS = false
*--------------------------------------
CC.IsValue0 and #CC.Q.PPPOINTER
beq .2
ldx #2
bra .6
.2 cpy #CC.T.FLOAT
bcc .5 char,int,long
ldx #5
*--------------------------------------
.5 jsr CC.GetVarSize
.6 lda #$A2 LDX #imm
jsr CODE.EmitByte
txa
jsr CODE.EmitByte
ldx #PCC.Test0X.L
ldy #0
.7 lda PCC.Test0X,y
jsr CODE.EmitByte
iny
dex
bne .7
clc
rts
*--------------------------------------
* Type Declaration keywords
*--------------------------------------
CC.CONST ldy #1
lda (pStack),y
ora #CC.Q.CONST
sta (pStack),y
jsr CC.CheckSpace
bcs .9
>LDYA L.CC.TMODS2
jsr CC.LookupID
bcs .9
jmp (J.CC.TMODS2,x)
.9 lda #E.CSYN
sec
rts
*--------------------------------------
CC.SIGNED sec
.HS 90 BCC
*--------------------------------------
CC.UNSIGNED clc
php
jsr CC.CheckSpace
bcs .9
>LDYA L.CC.TYPES
jsr CC.LookupID
bcs .9
cpx #CC.T.UCHAR
bcc .9 void
cpx #CC.T.SLONG+1 only char int long allowed
bcs .9
plp
bcs .8
jmp (J.CC.UTYPES-2,x)
.8 jmp (J.CC.STYPES-2,x)
.9 plp
lda #E.CSYN
sec
rts
*--------------------------------------
CC.SHORT jsr CC.CheckSpace
bcs .9
>LDYA L.CC.TYPES
jsr CC.LookupID
bcs CC.UCHAR
cpx #4 only int allowed
beq CC.SCHAR
.9 lda #E.CSYN
sec
rts
*--------------------------------------
CC.VOID lda #CC.T.VOID
bra CC.TYPE
CC.CHAR
CC.UCHAR lda #CC.T.UCHAR
bra CC.TYPE
CC.SCHAR lda #CC.T.SCHAR
bra CC.TYPE
CC.UINT lda #CC.T.UINT
bra CC.TYPE
CC.INT
CC.SINT lda #CC.T.SINT
bra CC.TYPE
CC.ULONG lda #CC.T.ULONG
bra CC.TYPE
CC.LONG
CC.SLONG lda #CC.T.SLONG
bra CC.TYPE
CC.FLOAT lda #CC.T.FLOAT
CC.TYPE sta (pStack)
jsr CC.GetCharNB
bcs .9
ldy #1
.1 cmp #'*'
bne .10
lda (pStack),y
clc
adc #CC.Q.POINTER
bcs .9 more than ***
sta (pStack),y
jsr CC.GetNextCharNB
bcc .1
.9 lda #E.CSYN
sec
.99 rts
.10 jsr CC.IsLetter
bcs .8
>LDYA L.CC.FTYPES
jsr CC.LookupID
bcs .8 next char is an identifier
ldy #1
lda (pStack),y
ora #CC.Q.FUNC+CC.Q.FASTCALL
sta (pStack),y
jsr CC.GetNextCharNB
bcs .9 next char is an identifier, ",", "(",")"
.8 clc
rts
*--------------------------------------
MAN
SAVE usr/src/bin/cc.s.kw
LOAD usr/src/bin/cc.s
ASM

994
BIN/CC.S.txt Normal file
View File

@ -0,0 +1,994 @@
NEW
AUTO 3,1
.LIST OFF
.OP 65C02
.OR $2000
.TF bin/cc
*--------------------------------------
.INB inc/macros.i
.INB inc/a2osx.i
.INB inc/mli.i
.INB inc/mli.e.i
*--------------------------------------
FILES.MAX .EQ 4
*--------------------------------------
CC.T.VOID .EQ 1
CC.T.UCHAR .EQ 2
CC.T.SCHAR .EQ 3
CC.T.UINT .EQ 4
CC.T.SINT .EQ 5
CC.T.ULONG .EQ 6
CC.T.SLONG .EQ 7
CC.T.FLOAT .EQ 8
CC.T.VARIADIC .EQ $FF
*--------------------------------------
CC.Q.POINTER .EQ %01000000
CC.Q.PPOINTER .EQ %10000000
CC.Q.PPPOINTER .EQ %11000000
CC.Q.ARRAY .EQ %00010000
CC.Q.AARRAY .EQ %00100000
CC.Q.AAARRAY .EQ %00110000
*
CC.Q.CONST .EQ %00000100
CC.Q.FUNC .EQ %00000010
CC.Q.FASTCALL .EQ %00000001
*--------------------------------------
* Zero Page Segment, up to 32 bytes
*--------------------------------------
.DUMMY
.OR ZPBIN
ZS.START
ZPCCCode .BS 2
ZPCCConst .BS 2
ZPCCData .BS 2
ZPCCStack .BS 2
ZPCCfDecl .BS 2
ZPLineBufPtr .BS 2
ZPSymID .BS 2
hDefine .BS 1
StackPtr .BS 1
ZPSymDef .EQ *
ZPSymType .BS 1
ZPSymQual .BS 1
ZPSymSizeOf .BS 2
ZPSymDataPtr .BS 2
ZPSymDefPtr .BS 2
SYMDEFSIZE .EQ *-ZPSymDef
ZPPtr1 .BS 2
ZPPtr2 .BS 2
ZPPtr3 .BS 2
ArgIndex .BS 1
ZS.END .ED
*--------------------------------------
* File Header (16 Bytes)
*--------------------------------------
CS.START cld
jmp (.1,x)
.DA #$61 6502,Level 1 (65c02)
.DA #1 BIN Layout Version 1
.DA #0 S.PS.F.EVENT
.DA #0
.DA CS.END-CS.START Code Size (without Constants)
.DA DS.END-DS.START Data SegmentSize
.DA #256 Stack Size
.DA #ZS.END-ZS.START Zero Page Size
.DA 0
*--------------------------------------
* Relocation Table
*--------------------------------------
.1 .DA CS.INIT
.DA CS.RUN
.DA CS.DOEVENT
.DA CS.QUIT
*--------------------------------------
L.MSG.GREETINGS .DA MSG.GREETINGS
L.MSG.USAGE .DA MSG.USAGE
L.MSG.COMPILING .DA MSG.COMPILING
L.MSG.DEBUG .DA MSG.DEBUG
L.MSG.TRACE .DA MSG.TRACE
L.MSG.ERROR .DA MSG.ERROR
L.MSG.RUN .DA MSG.RUN
L.ENV.INCLUDE .DA ENV.INCLUDE
*--------------------------------------
L.CC.PREOPS .DA CC.PREOPS
J.CC.PREOPS .DA CC.ExpGet.Ref
.DA CC.ExpGet.Deref
L.CC.POSTOPS .DA CC.POSTOPS
L.CC.AOPS .DA CC.AOPS
L.CC.BOPS .DA CC.BOPS
J.CC.bBOPS .DA CC.BOPS.bMUL
.DA CC.BOPS.bDIV
.DA CC.BOPS.bMOD
.DA CC.BOPS.ADD
.DA CC.BOPS.SUB
.DA CC.BOPS.SHL
.DA CC.BOPS.SHR
.DA CC.BOPS.L
.DA CC.BOPS.LE
.DA CC.BOPS.G
.DA CC.BOPS.GE
.DA CC.BOPS.EQ
.DA CC.BOPS.NE
.DA CC.BOPS.AND
.DA CC.BOPS.OR
.DA CC.BOPS.EOR
.DA CC.BOPS.LAND
.DA CC.BOPS.LOR
J.CC.cBOPS .DA CC.BOPS.cMUL
.DA CC.BOPS.cDIV
.DA CC.BOPS.cMOD
.DA CC.BOPS.ADD
.DA CC.BOPS.SUB
.DA CC.BOPS.SHL
.DA CC.BOPS.SHR
.DA CC.BOPS.L
.DA CC.BOPS.LE
.DA CC.BOPS.G
.DA CC.BOPS.GE
.DA CC.BOPS.EQ
.DA CC.BOPS.NE
.DA CC.BOPS.AND
.DA CC.BOPS.OR
.DA CC.BOPS.EOR
.DA CC.BOPS.LAND
.DA CC.BOPS.LOR
L.CC.DIRS .DA CC.DIRS
L.CC.KW .DA CC.KW
L.CC.TMODS .DA CC.TMODS
L.CC.TMODS2 .DA CC.TMODS2
L.CC.TYPES .DA CC.TYPES
L.CC.FTYPES .DA CC.FTYPES
J.CC.DIRS .DA CC.DIR.DEFINE
.DA CC.DIR.INCLUDE
J.CC.KW .DA CC.IF
.DA CC.WHILE
.DA CC.ELSE
.DA CC.DO
.DA CC.FOR
.DA CC.SWITCH
.DA CC.CASE
.DA CC.BREAK
.DA CC.CONTINUE
.DA CC.SIZEOF
*--------------------------------------
.DA CC.TYPEDEF
.DA CC.STRUCT
*--------------------------------------
J.CC.TMODS .DA CC.CONST
J.CC.TMODS2 .DA CC.SIGNED
.DA CC.UNSIGNED
.DA CC.SHORT
J.CC.TYPES .DA CC.VOID
.DA CC.CHAR
.DA CC.INT
.DA CC.LONG
.DA CC.FLOAT
J.CC.UTYPES .DA CC.UCHAR
.DA CC.UINT
.DA CC.ULONG
J.CC.STYPES .DA CC.SCHAR
.DA CC.SINT
.DA CC.SLONG
*--------------------------------------
J.CC.KW.END .DA CC.IF.END
.DA CC.WHILE.END
*--------------------------------------
L.CC.LIBC .DA CC.LIBC
.DA 0
*--------------------------------------
* Called once at process creation
* Put code for loading LIB here
*--------------------------------------
CS.INIT clc
CS.INIT.RTS rts
*--------------------------------------
* Called until exit with CS
* if RUN exits with CC, RN entered again
*--------------------------------------
CS.RUN >PUSHW L.MSG.GREETINGS
>PUSHW A2osX.KVER
>PUSHBI 2
>SYSCALL PrintF
bcs CS.INIT.RTS
lda #hFilePtr
>STA.G hFilePtr
lda #LineCntPtr
>STA.G LineCntPtr
>LDYAI 256
>SYSCALL GetMem
bcs CS.INIT.RTS
>STYA.G LineBufPtr
txa
>STA.G hLineBuf
jsr CS.RUN.ARGS
bcs CS.INIT.RTS
jsr CC.Init
bcs CS.INIT.RTS
*--------------------------------------
CS.RUN.LOOP >SLEEP
>LDA.G bDebug
bpl .2
jsr PrintDebugMsg
.2 jsr CS.RUN.FGetS
bcs .4
>LDA.G bTrace
bpl .3
jsr PrintTraceMsg
.3 jsr CC.Run
bcc CS.RUN.LOOP
*--------------------------------------
.4 cmp #MLI.E.EOF
bne .9
.7 jsr CS.RUN.FClose
bne CS.RUN.LOOP
jsr CS.RUN.EXEC
bcs .9
.8 lda #0 Exit Code = Success
sec
rts
.9 pha
jsr PrintErrorMsg
pla
sec
rts
*--------------------------------------
CS.RUN.EXEC lda #$60 RTS
sta (ZPCCCode)
>DEBUG
>LDA.G CC.hCode
>SYSCALL GetMemPtr
>STYA ZPCCCode
jmp (ZPCCCode)
*--------------------------------------
CS.RUN.ARGS inc ArgIndex
lda ArgIndex
>SYSCALL ArgV
bcs .7
>STYA ZPPtr1
lda (ZPPtr1)
cmp #'-'
bne .4
ldy #1
lda (ZPPtr1),y
ldx #OptionVars-OptionList-1
.1 cmp OptionList,x
beq .2
dex
bpl .1
bra .90
.2 ldy OptionVars,x
lda #$ff
sta (pData),y
bra CS.RUN.ARGS
.4 >LDA.G hFilePtr
cmp #hFilePtr
bne .90
>LDYA ZPPtr1
jsr CS.RUN.FOpen
bcc CS.RUN.ARGS
rts
.7 >LDA.G hFilePtr
cmp #hFilePtr
beq .90
clc
.9 rts
.90 >PUSHW L.MSG.USAGE
>PUSHBI 0
>SYSCALL PrintF
lda #E.SYN
sec
rts
*--------------------------------------
CS.RUN.FOpen >PUSHYA
>PUSHBI O.RDONLY
>PUSHBI S.FI.T.TXT
>PUSHWZ Aux type
>SYSCALL FOpen
bcs .9
tax
>LDA.G hFilePtr
inc
sta (pData),y
tay
txa
sta (pData),y
>LDA.G LineCntPtr
inc
inc
sta (pData),y
tay
lda #0
sta (pData),y
iny
sta (pData),y
.9 rts
*--------------------------------------
CS.RUN.FGetS >LDYA.G LineBufPtr
>STYA ZPLineBufPtr
>LDA.G LineCntPtr
tay
lda (pData),y
inc
sta (pData),y
bne .1
iny
lda (pData),y
inc
sta (pData),y
.1 >LDA.G hFilePtr
tay
lda (pData),y
>PUSHA
>PUSHW ZPLineBufPtr
>PUSHWI 255
>SYSCALL FGetS
rts
*--------------------------------------
CS.RUN.FClose >LDA.G hFilePtr
cmp #hFilePtr
beq .8
tay
lda (pData),y
>SYSCALL FClose
>LDA.G hFilePtr
dec
sta (pData),y
cmp #hFilePtr
beq .8
>LDA.G LineCntPtr
dec
dec
sta (pData),y NZ
.8 rts
*--------------------------------------
CS.DOEVENT sec
rts
*--------------------------------------
CS.QUIT jsr CC.Quit
clc
rts
*--------------------------------------
PrintDebugMsg >PUSHW L.MSG.DEBUG
>PUSHW ZPCCCode
>PUSHW ZPCCConst
>PUSHW ZPCCData
lda pStack
clc
adc #8
pha
lda pStack+1
adc #0
>PUSHA
pla
>PUSHA
>PUSHBI 8
>SYSCALL PrintF
>DEBUG
rts
*--------------------------------------
PrintTraceMsg ldy #S.PS.hStdErr
lda (pPS),y
>PUSHA
>PUSHW L.MSG.TRACE
>LDA.G LineCntPtr
inc
tay
lda (pData),y
>PUSHA
dey
lda (pData),y
>PUSHA
>PUSHW.G LineBufPtr
>PUSHBI 4
>SYSCALL FPrintF
rts
*--------------------------------------
PrintErrorMsg lda hDefine
beq .10
>LDYA.G CC.SaveDefine
>STYA ZPLineBufPtr
.10 >LDA.G bTrace
bmi .1
jsr PrintTraceMsg
.1 lda ZPLineBufPtr
sec
>SBC.G LineBufPtr
tax
>LDYA.G LineBufPtr
>STYA ZPLineBufPtr
txa
beq .3
ldy #0
lda #'-'
.2 sta (ZPLineBufPtr),y
iny
dex
bne .2
txa
.3 sta (ZPLineBufPtr),y
.8 ldy #S.PS.hStdErr
lda (pPS),y
>PUSHA
>PUSHW L.MSG.ERROR
>PUSHW ZPLineBufPtr
>PUSHBI 2
>SYSCALL FPrintF
rts
*--------------------------------------
.INB usr/src/bin/cc.s.code
.INB usr/src/bin/cc.s.core
.INB usr/src/bin/cc.s.dir
.INB usr/src/bin/cc.s.kw
.INB usr/src/bin/cc.s.exp
.INB usr/src/bin/cc.s.exec
*--------------------------------------
CS.END
*--------------------------------------
* Initialized DATA
*--------------------------------------
MSG.GREETINGS .AZ "\r\nA2osX C Compiler %d.%d\r\n\r\n"
MSG.USAGE .AS "Usage : CC <option> srcfile\r\n"
.AS " -D : Debug Mode\r\n"
.AS " -T : Trace On"
.AZ "\r\n"
MSG.COMPILING .AZ "***Compiling : %s...\r\n"
MSG.DEBUG .AZ "***pCode=%H, pConst=%H, pData=%H, pStack=%H\r\n"
MSG.TRACE .AZ "%5D> %s\r\n"
MSG.ERROR .AZ " %s^\r\n"
MSG.RUN .AZ "***Code size: %D, Data Size: %D, Running...\r\n"
*--------------------------------------
ENV.INCLUDE .AZ "INCLUDE"
ENV.LIB .AZ "LIB"
*--------------------------------------
OptionList .AS "DdTt"
OptionVars .DA #bDebug,#bDebug,#bTrace,#bTrace
*--------------------------------------
PCC.DEBUG >DEBUG
PCC.DEBUG.L .EQ *-PCC.DEBUG
*--------------------------------------
PCC.SLEEP >SLEEP
PCC.SLEEP.L .EQ *-PCC.SLEEP
*--------------------------------------
PCC.PushXFromYA >STYA ZPPtr1
txa
dec
tay
.1 lda (ZPPtr1),y
>PUSHA
dey
bpl .1
PCC.PushXFromYA.L .EQ *-PCC.PushXFromYA
*--------------------------------------
PCC.PopXToYA >STYA ZPPtr1
ldy #0
.1 >PULLA
sta (ZPPtr1),y
iny
dex
bne .1
PCC.PopXToYA.L .EQ *-PCC.PopXToYA
*--------------------------------------
PCC.Test0X lda #0
.1 ora (pStack)
inc pStack
dex
bne .1
tay
.2 bne .2+5
.HS 4C JMP abs
PCC.Test0X.L .EQ *-PCC.Test0X
*--------------------------------------
CC.OPChars .AS "!~+-*/%=&|^<>"
CC.OPChars.Cnt .EQ *-CC.OPChars
*--------------------------------------
* Pre Operators: & * + - ! ~ ++ --
*--------------------------------------
CC.PREOPS >PSTR "&" ref
>PSTR "*" deref
>PSTR "+" abs
>PSTR "-" change sign
>PSTR "!" logical not
>PSTR "~" bitwise not
>PSTR "++" pre increase
>PSTR "--" pre decrease
* >PSTR "(" type cast
.HS 00
*--------------------------------------
* Post Operators: ++ --
*--------------------------------------
CC.POSTOPS >PSTR "++"
>PSTR "--"
>PSTR "["
>PSTR "."
>PSTR "->"
.HS 00
*--------------------------------------
* Assignment Operators: = += -= *= /= %= <<= >>= &= ^= |=
*--------------------------------------
CC.AOPS >PSTR "="
>PSTR "+="
>PSTR "-="
>PSTR "*="
>PSTR "/="
>PSTR "%="
>PSTR "<<="
>PSTR ">>="
>PSTR "&="
>PSTR "^="
>PSTR "!="
.HS 00
*-- Binary ---- H to L precedence -----
* Arithmetic Operators: * / %
* Arithmetic Operators: + -
* Shift Operators: << >>
* Relational Operators: < > >= < >= == !=
* Bitwise Operators: & | ^ ~
* Logical Operators: && ||
*--------------------------------------
CC.BOPS >PSTR "*"
>PSTR "/"
>PSTR "%"
>PSTR "+"
>PSTR "-"
>PSTR "<<"
>PSTR ">>"
>PSTR "<"
>PSTR "<="
>PSTR ">"
>PSTR ">="
>PSTR "=="
>PSTR "!="
>PSTR "&"
>PSTR "|"
>PSTR "^"
>PSTR "&&"
>PSTR "||"
.HS 00
*--------------------------------------
* Reserved Directives:
*--------------------------------------
CC.DIRS >PSTR "define"
>PSTR "include"
.HS 00
*--------------------------------------
* Reserved Keywords:
*--------------------------------------
CC.KW >PSTR "if"
>PSTR "while"
>PSTR "else"
>PSTR "do"
>PSTR "for"
>PSTR "switch"
>PSTR "case"
>PSTR "break"
>PSTR "continue"
>PSTR "sizeof"
>PSTR "typedef"
>PSTR "struct"
.HS 00
*--------------------------------------
* Type Declaration
*--------------------------------------
CC.TMODS >PSTR "const" ALL
CC.TMODS2 >PSTR "signed" char,int,long
>PSTR "unsigned" char,int,long
>PSTR "short" int
CC.TYPES >PSTR "void"
>PSTR "char"
>PSTR "int"
>PSTR "long"
>PSTR "float"
.HS 00
*--------------------------------------
CC.Type2FPU .DA #FPU.wMUL,#FPU.iMUL,#FPU.uMUL,#FPU.lMUL,#FPU.fMUL
*--------------------------------------
CC.FTYPES >PSTR "fastcall"
* .HS 00
*--------------------------------------
CC.TYPESIZE .HS 0001010202040405
CC.TYPESIGN .HS 0000FF00FF00FFFF
*--------------------------------------
CC.LIBC >PSTR "chtyp"
.DA #2,#0,#SYS.ChTyp
>PSTR "chmod"
.DA #2,#0,#SYS.ChMod
>PSTR "fstat"
.DA #2,#0,#SYS.FStat
>PSTR "stat"
.DA #2,#0,#SYS.Stat
>PSTR "mkdir"
.DA #2,#0,#SYS.MKDir
>PSTR "mknod"
.DA #2,#0,#SYS.MKNod
>PSTR "mkfifo"
.DA #2,#0,#SYS.MKFIFO
>PSTR "pipe"
.DA #2,#0,#SYS.Pipe
>PSTR "opendir"
.DA #2,#0,#SYS.OpenDir
>PSTR "readdir"
.DA #2,#0,#SYS.ReadDir
>PSTR "closedir"
.DA #2,#0,#SYS.CloseDir
>PSTR "open"
.DA #2,#0,#SYS.Open
>PSTR "close"
.DA #2,#0,#SYS.Close
>PSTR "read"
.DA #2,#0,#SYS.Read
>PSTR "write"
.DA #2,#0,#SYS.Write
>PSTR "chown"
.DA #2,#0,#SYS.ChOwn
>PSTR "fputc"
.DA #2,#0,#SYS.FPutC
>PSTR "putchar"
.DA #2,#0,#SYS.PutChar
>PSTR "getc"
.DA #2,#0,#SYS.GetC
>PSTR "getchar"
.DA #2,#0,#SYS.GetChar
>PSTR "fputs"
.DA #2,#0,#SYS.FPutS
>PSTR "puts"
.DA #2,#0,#SYS.PutS
>PSTR "fgets"
.DA #2,#0,#SYS.FGetS
>PSTR "ungetc"
.DA #2,#0,#SYS.UngetC
>PSTR "fopen"
.DA #2,#0,#SYS.FOpen
>PSTR "fclose"
.DA #2,#0,#SYS.FClose
>PSTR "fread"
.DA #2,#0,#SYS.FRead
>PSTR "fwrite"
.DA #2,#0,#SYS.FWrite
>PSTR "fflush"
.DA #2,#0,#SYS.FFlush
>PSTR "fseek"
.DA #2,#0,#SYS.FSeek
>PSTR "ftell"
.DA #2,#0,#SYS.FTell
>PSTR "feof"
.DA #2,#0,#SYS.FEOF
>PSTR "remove"
.DA #2,#0,#SYS.Remove
>PSTR "rename"
.DA #2,#0,#SYS.Rename
>PSTR "printf"
.DA #2,#0,#SYS.PrintF
>PSTR "fprintf"
.DA #2,#0,#SYS.FPrintF
>PSTR "sprintf"
.DA #2,#0,#SYS.SPrintF
>PSTR "scanf"
.DA #2,#0,#SYS.ScanF
>PSTR "fscanf"
.DA #2,#0,#SYS.FScanF
>PSTR "sscanf"
.DA #2,#0,#SYS.SScanF
* >PSTR "$50"
* .DA #2,#0,#0
* >PSTR "$52"
* .DA #2,#0,#0
* >PSTR "$54"
* .DA #2,#0,#0
* >PSTR "$56"
* .DA #2,#0,#0
* >PSTR "$58"
* .DA #2,#0,#0
* >PSTR "$5A"
* .DA #2,#0,#0
* >PSTR "$5C"
* .DA #2,#0,#0
>PSTR "setattr"
.DA #2,#0,#SYS.SetAttr
* >PSTR "mount"
* .DA #2,#0,#0
* >PSTR "umount"
* .DA #2,#0,#0
* >PSTR "online"
* .DA #2,#0,#0
* >PSTR "getstkobj"
* .DA #2,#0,#0
* >PSTR "shift"
* .DA #2,#0,#0
* >PSTR "argv"
* .DA #2,#0,#0
* >PSTR "argvDup"
* .DA #2,#0,#0
* >PSTR "geterrmsg"
* .DA #2,#0,#0
>PSTR "atof"
.DA #2,#0,#SYS.AToF
>PSTR "atoi"
.DA #2,#0,#SYS.AToI
>PSTR "atol"
.DA #2,#0,#SYS.AToL
>PSTR "strtof"
.DA #2,#0,#SYS.StrToF
>PSTR "strtol"
.DA #2,#0,#SYS.StrToL
>PSTR "strtoul"
.DA #2,#0,#SYS.StrToUL
* >PSTR "realpath"
* .DA #2,#0,#0
* >PSTR "expand"
* .DA #2,#0,#0
>PSTR "strlen"
.DA #2,#0,#SYS.StrLen
>PSTR "strcpy"
.DA #2,#0,#SYS.StrCpy
>PSTR "strcat"
.DA #2,#0,#SYS.StrCat
>PSTR "strdup"
.DA #2,#0,#SYS.StrDup
>PSTR "strupr"
.DA #2,#0,#SYS.StrUpr
>PSTR "strlwr"
.DA #2,#0,#SYS.StrLwr
>PSTR "strcmp"
.DA #2,#0,#SYS.StrCmp
>PSTR "strcasecmp"
.DA #2,#0,#SYS.StrCaseCmp
* >PSTR "getdevbyname"
* .DA #2,#0,#0
* >PSTR "getdevstatus"
* .DA #2,#0,#0
* >PSTR "mkdev"
* .DA #2,#0,#0
* >PSTR "ioctl"
* .DA #2,#0,#0
* >PSTR "loadlib"
* .DA #2,#0,#0
* >PSTR "unloadlib"
* .DA #2,#0,#0
* >PSTR "loaddrv"
* .DA #2,#0,#0
* >PSTR "insdrv"
* .DA #2,#0,#0
>PSTR "execl"
.DA #2,#0,#SYS.ExecL
* >PSTR "execv"
* .DA #2,#0,#0
>PSTR "fork"
.DA #2,#0,#SYS.Fork
>PSTR "kill"
.DA #2,#0,#SYS.Kill
* >PSTR "loadfile"
* .DA #2,#0,#0
* >PSTR "loadtxtfile"
* .DA #2,#0,#0
* >PSTR "filesearch"
* .DA #2,#0,#0
* >PSTR "getmemstat"
* .DA #2,#0,#0
* >PSTR "strvnew"
* .DA #2,#0,#0
* >PSTR "strvset"
* .DA #2,#0,#0
* >PSTR "strvget"
* .DA #2,#0,#0
* >PSTR "strvfree"
* .DA #2,#0,#0
>PSTR "putenv"
.DA #2,#0,#SYS.PutEnv
>PSTR "setenv"
.DA #2,#0,#SYS.SetEnv
>PSTR "getenv"
.DA #2,#0,#SYS.GetEnv
>PSTR "unsetenv"
.DA #2,#0,#SYS.UnsetEnv
>PSTR "time"
.DA #2,#0,#SYS.Time
>PSTR "strftime"
.DA #2,#0,#SYS.StrFTime
* >PSTR "ptime2time"
* .DA #2,#0,#0
>PSTR "ctime2time"
.DA #2,#0,#SYS.CTime2Time
>PSTR "md5"
.DA #2,#0,#SYS.MD5
>PSTR "md5init"
.DA #2,#0,#SYS.MD5Init
>PSTR "md5update"
.DA #2,#0,#SYS.MD5Update
>PSTR "md5finalize"
.DA #2,#0,#SYS.MD5Finalize
>PSTR "getpwuid"
.DA #2,#0,#SYS.GetPWUID
>PSTR "getpwname"
.DA #2,#0,#SYS.GetPWName
>PSTR "putpw"
.DA #2,#0,#SYS.PutPW
>PSTR "getgrpgid"
.DA #2,#0,#SYS.GetGRGID
>PSTR "getgrpname"
.DA #2,#0,#SYS.GetGRName
>PSTR "putgr"
.DA #2,#0,#SYS.PutGR
* >PSTR "opensession"
* .DA #2,#0,#0
* >PSTR "closesession"
* .DA #2,#0,#0
* >PSTR "slistgetdata"
* .DA #2,#0,#0
* >PSTR "slistadddata"
* .DA #2,#0,#0
* >PSTR "slistsetdata"
* .DA #2,#0,#0
* >PSTR "slistgetbyid"
* .DA #2,#0,#0
* >PSTR "slistnewkey"
* .DA #2,#0,#0
* >PSTR "slistlookup"
* .DA #2,#0,#0
* >PSTR "slistfree"
* .DA #2,#0,#0
* >PSTR "slistnew"
* .DA #2,#0,#0
>PSTR "malloc"
.DA #2,#0,#SYS.GetMem
>PSTR "realloc"
.DA #2,#0,#SYS.Realloc
* >PSTR "getmemptr"
* .DA #2,#0,#0
>PSTR "free"
.DA #2,#0,#SYS.FreeMem
* >PSTR "newstkobj"
* .DA #2,#0,#0
* >PSTR "loadstkobj"
* .DA #2,#0,#0
* >PSTR "getstkobjptr"
* .DA #2,#0,#0
* >PSTR "freestkobj"
* .DA #2,#0,#0
*--------------------------------------
>PSTR "pwr"
.DA #2,#64,#FPU.PWR
>PSTR "log"
.DA #2,#64,#FPU.LOG
>PSTR "sqr"
.DA #2,#64,#FPU.SQR
>PSTR "exp"
.DA #2,#64,#FPU.EXP
>PSTR "cos"
.DA #2,#64,#FPU.COS
>PSTR "sin"
.DA #2,#64,#FPU.SIN
>PSTR "tan"
.DA #2,#64,#FPU.TAN
>PSTR "atan"
.DA #2,#64,#FPU.ATAN
.HS 00
*--------------------------------------
.DUMMY
.OR 0
DS.START
PathBuf .BS MLI.MAXPATH+1
hFilePtr .BS 1
hFiles .BS FILES.MAX
LineCntPtr .BS 1
.BS 1 for inc inc
LineCnts .BS FILES.MAX+2
hLineBuf .BS 1
LineBufPtr .BS 2
CC.CmdSave .BS 1
CC.hDefines .BS 1
CC.hSymbols .BS 1
CC.hTags .BS 1
CC.hCode .BS 1
CC.hConst .BS 1
CC.hData .BS 1
CC.DataSize .BS 2
CC.hStack .BS 1
CC.hfDecl .BS 1
CC.fDeclBuf .BS 2
CC.SaveDefine .BS 2
CC.VarDef .EQ *
CC.VarType .BS 1
CC.VarQual .BS 1
CC.VarSizeOf .BS 2
CC.VarDataPtr .BS 2
CC.VarDefPtr .BS 2
bDebug .BS 1
bTrace .BS 1
DS.END .ED
*--------------------------------------
MAN
SAVE usr/src/bin/cc.s
ASM

130
BIN/CSH.S.CODE.txt Normal file
View File

@ -0,0 +1,130 @@
NEW
AUTO 3,1
.LIST OFF
*--------------------------------------
CODE.PushXFromYA
jsr CODE.LDXYAI
ldx #PCC.PushXFromYA.L
ldy #0
.1 lda PCC.PushXFromYA,y
jsr CODE.EmitByte
iny
dex
bne .1
rts
*--------------------------------------
CODE.PopXToYA jsr CODE.LDXYAI
ldx #PCC.PopXToYA.L
ldy #0
.1 lda PCC.PopXToYA,y
jsr CODE.EmitByte
iny
dex
bne .1
rts
*--------------------------------------
CODE.PUSHI pha
lda #$A9 LDA #imm
jsr CODE.EmitByte
pla
jsr CODE.EmitByte
bra CODE.PUSHA
*--------------------------------------
CODE.LDXYAI pha
lda #$A2 LDX #imm
jsr CODE.EmitByte
txa
jsr CODE.EmitByte
lda #$A0 LDY #imm
jsr CODE.EmitByte
tya
jsr CODE.EmitByte
lda #$A9 LDA #imm
jsr CODE.EmitByte
pla
bra CODE.EmitByte
*--------------------------------------
CODE.PUSHYA jsr CODE.PUSHA
lda #$AA TYA
jsr CODE.EmitByte
*--------------------------------------
CODE.PUSHA lda #$C6 DEC zp
jsr CODE.EmitByte
lda #pStack
jsr CODE.EmitByte
lda #$92 STA (zp)
jsr CODE.EmitByte
lda #pStack
jmp CODE.EmitByte
*--------------------------------------
CODE.PULLYA jsr CODE.PULLA
lda #$48 PHA
jsr CODE.EmitByte
jsr CODE.PULLA
lda #$7A PLY
bra CODE.EmitByte
*--------------------------------------
CODE.PULLA lda #$B2 LDA (zp)
jsr CODE.EmitByte
lda #pStack
jsr CODE.EmitByte
*--------------------------------------
CODE.INCPSTACK lda #$E6 INC zp
jsr CODE.EmitByte
lda #pStack
bra CODE.EmitByte
*--------------------------------------
CODE.JMPYX lda #$4C
bra CODE.JSRYX.1
*--------------------------------------
CODE.JSRYX lda #$20 JSR
CODE.JSRYX.1 jsr CODE.EmitByte
tya
jsr CODE.EmitByte
txa
bra CODE.EmitByte
*--------------------------------------
CODE.FPUCALL lda #$A2 LDX #imm
jsr CODE.EmitByte
txa
jsr CODE.EmitByte
lda #$20 JSR
jsr CODE.EmitByte
lda #A2osX.FPUCALL
jsr CODE.EmitByte
lda /A2osX.FPUCALL
bra CODE.EmitByte
*--------------------------------------
CODE.SYSCALL lda #$A2 LDX #imm
jsr CODE.EmitByte
txa
jsr CODE.EmitByte
lda #$20 JSR
jsr CODE.EmitByte
lda #A2osX.SYSCALL
jsr CODE.EmitByte
lda /A2osX.SYSCALL
*--------------------------------------
CODE.EmitByte sta (ZPCSHCode)
inc ZPCSHCode
bne .8
inc ZPCSHCode+1
.8 rts
*--------------------------------------
MAN
SAVE usr/src/bin/csh.s.code
LOAD usr/src/bin/csh.s
ASM

View File

@ -370,7 +370,7 @@ CSH.MainExec lda #0
stz ArgIndex
.1 lda ArgIndex
>SYSCALL ArgC
>SYSCALL ArgV
bcs .2
inc ArgIndex

View File

@ -101,9 +101,13 @@ CS.RUN ldy #S.PS.hStdOut
>SYSCALL GetMemPtr
>STYA ZPPtr1
lda (ZPPtr1)
* cmp #S.FD.T.REG
beq .10
cmp #S.FD.T.PIPE
bne .1
dec bToFile
.10 dec bToFile
.1 inc ArgCount
lda ArgCount

View File

@ -10,7 +10,7 @@ NEW
.INB inc/eth.i
.INB inc/libtcpip.i
*--------------------------------------
TIMEOUT.MAX .EQ 100 10 sec.
TIMEOUT.MAX .EQ 40 4 sec.
*--------------------------------------
.DUMMY
.OR ZPBIN
@ -273,15 +273,28 @@ CS.RUN.WAIT.REPLY
.2 sta hFrame
>SYSCALL GetMemPtr
>STYA ZPTmpPtr
jsr CS.Print.REPLY
ldy #S.ICMP.SEQUENCE
lda (ZPTmpPtr),y
cmp Sequence+1
bne .3
iny
lda (ZPTmpPtr),y
cmp Sequence
beq .4
.3 jsr CS.FrameDiscard
bra CS.RUN.WAIT.REPLY
.4 jsr CS.Print.REPLY
bcs CS.RUN.ERR
lda hFrame
>SYSCALL FreeMem
stz hFrame
jsr CS.FrameDiscard
.7 lda PingCount
beq .8
dec PingCount
dec A=0
beq .80
@ -362,11 +375,9 @@ CS.Print.REPLY lda #TIMEOUT.MAX
>SYSCALL PrintF
rts
*--------------------------------------
CS.QUIT lda hFrame
beq .1
>SYSCALL FreeMem
CS.QUIT jsr CS.FrameDiscard
.1 lda hSocket
lda hSocket
beq .2
>LIBCALL hLIBTCPIP,LIBTCPIP.Shutdown
@ -377,6 +388,15 @@ CS.QUIT lda hFrame
.8 clc
rts
*--------------------------------------
CS.FrameDiscard lda hFrame
beq .1
stz hFrame
>SYSCALL FreeMem
.1 rts
*--------------------------------------
CS.END
LIBTCPIP .AZ "libtcpip"
MSG.IPKO .AZ "TCP/IP Not Loaded/Configured."

View File

@ -124,7 +124,7 @@ CS.RUN
*--- Checking of argument -F ----------
.11 bit bFormat ; did we just see the -f option?
bpl .112 ; no, jump to next arg flag
bpl .12 ; no, jump to next arg flag
lda ArgIndex ; yes, then get the pointer to the arg string
>SYSCALL ArgV ; and set it to the pointer for the -f
>STYA ZPPtrFormat ; string storage
@ -133,8 +133,8 @@ CS.RUN
jmp .1 ; and then go process the next arg
*--- Checking of argument -S ----------
.112 bit bString ; did we just see the -s option?
bpl .113 ; no, jump to next arg flag
.12 bit bString ; did we just see the -s option?
bpl .13 ; no, jump to next arg flag
lda ArgIndex ; yes, then get the pointer to the next arg string
>SYSCALL ArgV ; and set it to the pointer for the -s
>STYA ZPPtrString ; string storage
@ -143,7 +143,7 @@ CS.RUN
jmp .1 ; and then go process the next arg
*--- Checking of argument -T ----------
.113 bit bTerminating ; did we just see the -t option?
.13 bit bTerminating ; did we just see the -t option?
bpl .2 ; no, jump to the next arg flag
lda ArgIndex ; yes, then get the pointer to the arg string
>SYSCALL ArgV ; and set it to the pointer for the -t

View File

@ -302,7 +302,9 @@ MSG.IPKO .AZ "TCP/IP Not Loaded/Configured."
MSG.USAGE .AZ "Usage : TELNET <ip|host> [port]"
MSG.UNKNOWN .AZ "%s: Unknown host\r\n"
MSG.HOSTOK .AZ "Connecting to %d.%d.%d.%d:%D (%s)..."
MSG.SKTOK .AZ "Connected\r\n(Exit key is Ctrl-T)"
MSG.SKTOK .AS "Connected"
.DA #C.CR,#C.LF
.AZ "(Exit key is Ctrl-T)"
MSG.SKTERR .AZ "Socket Error : $%h\r\n"
MSG.IOERR .AZ "I/O Error : $%h\r\n"
MSG.USER .AZ "User interrupt."

View File

@ -8,14 +8,20 @@ NEW
.INB inc/macros.i
.INB inc/a2osx.i
.INB inc/libtui.i
*--------------------------------------
EV.SAVE .EQ $C0
EV.OK .EQ $CE
EV.CANCEL .EQ $CF
*--------------------------------------
.DUMMY
.OR ZPBIN
ZS.START
ZPPtr1 .BS 2
hCTX .BS 1
hSCRN .BS 1
hTBOX1 .BS 1
hLBOX1 .BS 1
hDLGS .BS 1
ZS.END .ED
*--------------------------------------
* File Header (16 Bytes)
@ -40,12 +46,19 @@ L.LIBTUI .DA LIBTUI
*--------------------------------------
L.SCRN.Title .DA SCRN.Title
L.SCRN.Status .DA SCRN.Status
L.CS.SCRN.fResize .DA CS.SCRN.fResize
L.TBOX1 .DA TBOX1
L.TBOX1.Title .DA TBOX1.Title
L.TBOX1.Status .DA TBOX1.Status
L.LBOX1 .DA LBOX1
L.LBOX1.L .DA LBOX1.L
L.LBOX1.List .DA LBOX1.List
L.LABEL.Label .DA LABEL.Label
L.RADIO1.List .DA RADIO1.List
L.CBOX1.Label .DA CBOX1.Label
L.BUTQ.Label .DA BUTQ.Label
L.BUTS.Label .DA BUTS.Label
L.DLGS.Title .DA DLGS.Title
L.BUT.OK .DA BUT.OK
L.BUT.Cancel .DA BUT.Cancel
.DA 0
*--------------------------------------
CS.INIT >LDYA L.LIBTUI
@ -58,25 +71,13 @@ CS.INIT >LDYA L.LIBTUI
CS.INIT.RTS rts
*--------------------------------------
CS.RUN lda #S.OBJ.F.bTITLE+S.OBJ.F.bSTATUS
>LIBCALL hLIBTUI,LIBTUI.Init
bcs CS.INIT.RTS
CS.RUN >LIBCALL hLIBTUI,LIBTUI.Init
bcs CS.RUN.RTS
sta hCTX
sta hSCRN
>PUSHA
>PUSHBI S.OBJ.pTITLE
>PUSHEA.G SCRN.Buf
>LIBCALL hLIBTUI,LIBTUI.SetProp
>PUSHB hSCRN
>PUSHBI S.OBJ.pSTATUS
>PUSHW L.SCRN.Status
>LIBCALL hLIBTUI,LIBTUI.SetProp
>PUSHB hSCRN
>PUSHBI S.OBJ.fRESIZE
>PUSHW L.CS.SCRN.fResize
>LIBCALL hLIBTUI,LIBTUI.SetProp
jsr CS.SCRN.Init
bcs CS.RUN.RTS
jsr CS.TBOX1.Init
bcs CS.RUN.RTS
@ -84,38 +85,93 @@ CS.RUN lda #S.OBJ.F.bTITLE+S.OBJ.F.bSTATUS
jsr CS.LBOX1.Init
bcs CS.RUN.RTS
jsr CS.SCRN.fResize Will Call SCRN.Draw
jsr CS.TLINE.Init
bcs CS.RUN.RTS
jsr CS.RADIO.Init
bcs CS.RUN.RTS
jsr CS.CBOX.Init
bcs CS.RUN.RTS
jsr CS.BUT.Init
bcs CS.RUN.RTS
jsr CS.SCRN.Draw Will Call SCRN.Draw
lda hTBOX1
>LIBCALL hLIBTUI,LIBTUI.Activate
*--------------------------------------
CS.RUN.LOOP >SLEEP
lda hSCRN
>LIBCALL hLIBTUI,LIBTUI.GetEvent
CS.RUN.LOOP lda hSCRN
>LIBCALL hLIBTUI,LIBTUI.Exec
bcs .9
tay
beq CS.RUN.LOOP
>PUSHB hSCRN
tya
>PUSHA
>LIBCALL hLIBTUI,LIBTUI.Dispatch
bcc CS.RUN.LOOP
cmp #EV.RESIZE
bne .1
.9 pha
lda hSCRN
>LIBCALL hLIBTUI,LIBTUI.Close
pla
sec
jsr CS.SCRN.Draw
bcs .9
bra CS.RUN.LOOP
.1 cmp #EV.SAVE
bne .2
jsr CS.RUN.DLGSAVE
bcc CS.RUN.LOOP
.2 cmp #EV.QUIT
bne CS.RUN.LOOP
lda hSCRN
>LIBCALL hLIBTUI,LIBTUI.Destroy
lda #0
sec
.9
CS.RUN.RTS rts
*--------------------------------------
CS.TBOX1.Init >PUSHB hSCRN
>PUSHW L.TBOX1
CS.SCRN.Init >PUSHB hCTX hParent
>PUSHBI S.OBJ.F.bTitle+S.OBJ.F.bStatus
lda #S.OBJ.T.SCRN
>LIBCALL hLIBTUI,LIBTUI.New
bcs .9
sta hSCRN
>PUSHA
>PUSHBI S.OBJ.pTITLE
>PUSHEA.G SCRN.TitleBuf
>LIBCALL hLIBTUI,LIBTUI.SetProp
>PUSHB hSCRN
>PUSHBI S.OBJ.pSTATUS
>PUSHW L.SCRN.Status
>LIBCALL hLIBTUI,LIBTUI.SetProp
.9 rts
*--------------------------------------
CS.TBOX1.Init >LDYAI 1024
>SYSCALL GetMem
bcs CS.RUN.RTS
>STYA ZPPtr1
txa
>STA.G TBOX1.hBuf
lda #0
sta (ZPPtr1)
>PUSHB hSCRN hParent
>PUSHBI 1 X1
>PUSHBI 1 Y1
>PUSHBI 44 W
>PUSHBI 20 H
>PUSHBI S.OBJ.F.bHBorder+S.OBJ.F.bVBorder+S.OBJ.F.bTitle+S.OBJ.F.bStatus
>PUSHB.G TBOX1.hBuf
>PUSHWI 1024
lda #S.OBJ.T.TBOX
>LIBCALL hLIBTUI,LIBTUI.New
bcs .9
@ -133,24 +189,147 @@ CS.TBOX1.Init >PUSHB hSCRN
.9 rts
*--------------------------------------
CS.LBOX1.Init >PUSHB hSCRN
>PUSHW L.LBOX1
CS.LBOX1.Init >PUSHB hSCRN hParent
>PUSHBI 50 X1
>PUSHBI 1 Y1
>PUSHBI 20 W
>PUSHBI 9 H
>PUSHBI S.OBJ.F.bHBorder+S.OBJ.F.bVBorder
>PUSHW L.LBOX1.List
>PUSHEA.G LBOX1.Var
lda #S.OBJ.T.LBOX
>LIBCALL hLIBTUI,LIBTUI.New
rts
*--------------------------------------
CS.TLINE.Init >PUSHB hSCRN hParent
>PUSHBI 50 X1
>PUSHBI 11 Y1
>PUSHW L.LABEL.Label
lda #S.OBJ.T.LABEL
>LIBCALL hLIBTUI,LIBTUI.New
bcs .9
>PUSHB hSCRN hParent
>PUSHBI 50 X1
>PUSHBI 12 Y1
>PUSHBI 25 W
>PUSHEA.G TLINE.Buf
>PUSHBI 65 Len
lda #S.OBJ.T.TLINE
>LIBCALL hLIBTUI,LIBTUI.New
.9 rts
*--------------------------------------
CS.RADIO.Init >PUSHB hSCRN hParent
>PUSHBI 50 X1
>PUSHBI 14 Y1
>PUSHBI 0
>PUSHBI 0
>PUSHW L.RADIO1.List
>PUSHEA.G RADIO1.Var
lda #S.OBJ.T.RADIO
>LIBCALL hLIBTUI,LIBTUI.New
rts
*--------------------------------------
CS.CBOX.Init >PUSHB hSCRN hParent
>PUSHBI 50 X1
>PUSHBI 18 Y1
>PUSHBI 0
>PUSHBI 0
>PUSHW L.CBOX1.Label
>PUSHEA.G CBOX1.Var
lda #S.OBJ.T.CBOX
>LIBCALL hLIBTUI,LIBTUI.New
rts
*--------------------------------------
CS.BUT.Init >PUSHB hSCRN hParent
>PUSHBI 50 X1
>PUSHBI 20 Y1
>PUSHBI 19 Ctrl-S
>PUSHBI EV.SAVE
>PUSHW L.BUTS.Label
lda #S.OBJ.T.BUT
>LIBCALL hLIBTUI,LIBTUI.New
bcs .9
>PUSHB hSCRN hParent
>PUSHBI 65 X1
>PUSHBI 20 Y1
>PUSHBI 17 Ctrl-Q
>PUSHBI EV.QUIT
>PUSHW L.BUTQ.Label
lda #S.OBJ.T.BUT
>LIBCALL hLIBTUI,LIBTUI.New
.9
CS.BUT.Init.RTS rts
*--------------------------------------
CS.RUN.DLGSAVE >PUSHB hCTX hParent
>PUSHBI 70 W
>PUSHBI 11 H
>PUSHW L.DLGS.Title
lda #S.OBJ.T.DLG
>LIBCALL hLIBTUI,LIBTUI.New
bcs CS.BUT.Init.RTS
sta hDLGS
>PUSHB hDLGS hParent
>PUSHBI 50 X1
>PUSHBI 7 Y1
>PUSHBI C.CR
>PUSHBI EV.OK
>PUSHW L.BUT.OK
lda #S.OBJ.T.BUT
>LIBCALL hLIBTUI,LIBTUI.New
bcs .9
sta hLBOX1
sta ZPPtr1
>PUSHA
>PUSHBI S.LBOX.pL
>PUSHW L.LBOX1.L
>LIBCALL hLIBTUI,LIBTUI.SetProp
>PUSHB hDLGS hParent
>PUSHBI 57 X1
>PUSHBI 7 Y1
>PUSHBI 3 Ctrl-C
>PUSHBI EV.CANCEL
>PUSHW L.BUT.Cancel
lda #S.OBJ.T.BUT
>LIBCALL hLIBTUI,LIBTUI.New
bcs .9
.9 rts
lda hDLGS
>LIBCALL hLIBTUI,LIBTUI.Draw
bcs .9
lda ZPPtr1
>LIBCALL hLIBTUI,LIBTUI.Activate
.1 lda hDLGS
>LIBCALL hLIBTUI,LIBTUI.Exec
.9 php
pha
lda hDLGS
>LIBCALL hLIBTUI,LIBTUI.Destroy
lda hSCRN
>LIBCALL hLIBTUI,LIBTUI.Draw
pla
plp
rts
*--------------------------------------
CS.DOEVENT sec do not discard TIMER event
rts
*--------------------------------------
CS.QUIT lda hLIBTUI
CS.QUIT >LDA.G TBOX1.hBuf
beq .1
>SYSCALL FreeMem
.1 lda hCTX
beq .2
>LIBCALL hLIBTUI,LIBTUI.Close
.2 lda hLIBTUI
beq .8
>SYSCALL UnloadLib
@ -158,11 +337,11 @@ CS.QUIT lda hLIBTUI
.8 clc
rts
*--------------------------------------
CS.SCRN.fResize lda hSCRN
CS.SCRN.Draw lda hSCRN
>SYSCALL GetMemPtr
>STYA ZPPtr1
>PUSHEA.G SCRN.Buf
>PUSHEA.G SCRN.TitleBuf
>PUSHW L.SCRN.Title
ldy #S.OBJ.X1
@ -188,24 +367,10 @@ hLIBTUI .BS 1
SCRN.Title .AZ "Window: X1=%d,Y1=%d, W=%d,H=%d, X2=%d,Y2=%d, iX=%d,iY=%d, iW=%d,iH=%d"
SCRN.Status .AZ "Status bar..."
*--------------------------------------
TBOX1 .DA #S.OBJ.T.TBOX T
.DA #S.OBJ.F.bHBorder+S.OBJ.F.bVBorder+S.OBJ.F.bTITLE+S.OBJ.F.bSTATUS
.BS 2
.DA #4 X1
.DA #4 Y1
.DA #40 W
.DA #15 H
TBOX1.Title .AZ "Text Box Title"
TBOX1.Status .AZ "Text Box Status"
*--------------------------------------
LBOX1 .DA #S.OBJ.T.LBOX T
.DA #S.OBJ.F.bHBorder+S.OBJ.F.bVBorder
.BS 2
.DA #50 X1
.DA #4 Y1
.DA #20 W
.DA #10 H
LBOX1.L .AZ "Item 1"
LBOX1.List .AZ "Item 1"
.AZ "Item 2"
.AZ "Item 3"
.AZ "Item 4"
@ -220,11 +385,34 @@ LBOX1.L .AZ "Item 1"
.AZ "Item 13"
.AZ "Item 14 last one"
.DA #0
*--------------------------------------
LABEL.Label .AZ "This is a label."
*--------------------------------------
RADIO1.List .DA #C.ESC
.AZ "[91mRed"
.DA #C.ESC
.AZ "[92mGreen"
.DA #C.ESC
.AZ "[96mBlue"
.DA #0
*--------------------------------------
CBOX1.Label .AZ "Check Me"
*--------------------------------------
BUTS.Label .AZ "(^S)ave..."
BUTQ.Label .AZ "(^Q)uit"
DLGS.Title .AZ "Save As..."
BUT.OK .AZ " OK "
BUT.Cancel .AZ "Cancel"
*--------------------------------------
.DUMMY
.OR 0
DS.START
SCRN.Buf .BS 80
SCRN.TitleBuf .BS 80
CBOX1.Var .BS 1
TLINE.Buf .BS 65
RADIO1.Var .BS 1
LBOX1.Var .BS 1
TBOX1.hBuf .BS 1
DS.END .ED
*--------------------------------------
MAN

View File

@ -66,7 +66,7 @@ CS.RUN.LOOP >SLEEP
>SYSCALL FGetS
bcs .9
.2 jsr CS.RUN.PRINT
.2 jsr CS.RUN.EXEC
bcc CS.RUN.LOOP
rts
@ -105,7 +105,7 @@ CS.RUN.CheckArgs
sta hFile
bra CS.RUN.CheckArgs
*--------------------------------------
.1 ldy #1
lda (ZPPtr1),y
@ -127,7 +127,7 @@ CS.RUN.CheckArgs
lda #$80
sta DashArgs-1,x
bra CS.RUN.CheckArgs
*--------------------------------------
.4 lda hFile
bne .80
@ -194,7 +194,7 @@ CS.RUN.OPEN >PUSHYA
.9 rts
*--------------------------------------
CS.RUN.PRINT >PUSHW ZPCmdBuf
CS.RUN.EXEC >PUSHW ZPCmdBuf
>PUSHW ZPCommandPtr
>SYSCALL StrCpy
@ -207,13 +207,24 @@ CS.RUN.PRINT >PUSHW ZPCmdBuf
>PUSHYA
>SYSCALL StrCat
>LDYA ZPCmdBuf
>SYSCALL PutS
* >LDYA ZPCmdBuf
* >SYSCALL PutS
>PUSHW ZPCmdBuf
>PUSHBI S.PS.F.HOLD
>SYSCALL ExecL
rts
bcs .9
>SLEEP
ldy #S.PS.RC
lda (pPS),y
beq .9
sec
.9 rts
*--------------------------------------
CS.QUIT lda hFile
beq .1

View File

@ -4,15 +4,17 @@ NEW
*--------------------------------------
* Driver Code
*--------------------------------------
INBUF.SIZE .EQ 4096
*--------------------------------------
ZPIOCTL .EQ ZPDRV
ZPBufPtr .EQ ZPDRV+2
ZPCount .EQ ZPDRV+4
ZPnCount .EQ ZPDRV+6
ZPFCS .EQ ZPDRV+8
ZPb7D .EQ ZPDRV+10
.DO DBG=1
TempB .EQ ZPDRV+11
.FIN
*--------------------------------------
DRV.CS.START cld
DRV.CS.START cld!
jmp (.1,x)
.1 .DA STATUS
.DA A2osX.BADCALL
@ -109,11 +111,12 @@ OPEN.1 >LDYAI INBUF.SIZE
bcs .9
stx hINBUF
sta INBUF.BASEH
>STYA READ.BUF+1
>STYA READ.GetByte.BUF+1
>STYA READ.SSC.BUF+1
sta INBUF.BASEH
stz INBUF.TAIL
stz INBUF.TAIL+1
stz INBUF.HEAD
@ -121,10 +124,6 @@ OPEN.1 >LDYAI INBUF.SIZE
stz INBUF.CNT
stz INBUF.CNT+1
ldx DEVSLOTn08F
lda #C.XOFF
jsr WRITE.Byte
lda #S.DIB.S.OPENED
tsb DIB+S.DIB.S
@ -136,6 +135,10 @@ CLOSE php
sei
ldx DEVSLOTn08F
lda #SSC.CMD.RIRQDIS
sta SSC.CMD-$8F,x Applewin Bug ???
stz SSC.RESET-$8F,x
lda #S.DIB.S.OPENED
@ -150,35 +153,38 @@ CLOSE php
*--------------------------------------
READ >STYA ZPIOCTL
jsr READ.SSC
.1 jsr READ.SSC
bcs .99
.1 jsr READ.Sync
.2 bit INBUF.MidFrame
bmi .97
jsr READ.Sync
bcs .98
cmp #$C0 C021 = LCP
beq .6
tay 0021 = IP
bne .1
bne .2
jsr READ.GetByteEsc
bcs .98
cmp #$21
bne .1
bne .2
jsr READ.GetByteEsc
bcs .98
cmp #$45 45 = S.IP.V.IHL
bne .1
bne .2
jsr READ.GetByteEsc
bcs .98
* tay ignore DSCP.ECN
* bne .1
* bne .2
jsr READ.GetByteEsc HHLL = S.IP.TOTAL.LENGTH
bcs .98
@ -195,11 +201,11 @@ READ >STYA ZPIOCTL
* clc
adc #4 already 4 bytes read
sta ZPnCount
bcc .2
bcc .3
inc ZPnCount+1
.2 jsr READ.NewFrame
.3 jsr READ.NewFrame
bcs .99
phx hFrame
@ -213,57 +219,199 @@ READ >STYA ZPIOCTL
lda #MLI.E.IO
sec
rts
.99 rts
*--------------------------------------
.6 jsr READ.GetByteEsc
bcs .98
cmp #$21
bne .1
cmp #$21 C021 = LCP
bne .2
jsr READ.GetByteEsc
bcs .98
cmp #$09
bne .1
cmp #$09 EchoReq ?
bne .2
ldy #7
.7 jsr READ.GetByteEsc
dey
bne .7
jsr READ.GetFrameTail
bcs .98
jsr READ.SendEchoRep
bra .1
jmp .2
.97 sec
.98 lda #E.NODATA
.99 rts
rts
*--------------------------------------
READ.SSC php
sei
stz INBUF.LastByte
.DO DBG=1
stz INBUF.FirstByte
stz TempB
.FIN
ldx DEVSLOTn08F
lda SSC.STATUS-$8F,x
bit #SSC.STATUS.nDCD true when 0
bne READ.SSC.98
bne .9
.DO SWFC=1
lda #C.XON
jsr WRITE.Byte
sta SSC.DATA-$8F,x
.FIN
READ.SSC.1 ldy #0
.DO HWFC=1
lda #SSC.CMD.NOP+SSC.CMD.TE+SSC.CMD.RIRQDIS+SSC.CMD.DTR
sta SSC.CMD-$8F,x
.FIN
READ.SSC.2 lda SSC.STATUS-$8F,x
ldy #0
.2 lda SSC.STATUS-$8F,x
and #SSC.STATUS.RDRF
bne READ.SSC.3
iny
bne READ.SSC.2
bne .3
iny
bne .2
.DO SWFC=1
lda #C.XOFF
jsr WRITE.Byte
sta SSC.DATA-$8F,x
.FIN
.DO HWFC=1
lda #SSC.CMD.NOP+SSC.CMD.RIRQDIS+SSC.CMD.DTR
sta SSC.CMD-$8F,x
.FIN
plp
clc
rts
READ.SSC.3 lda SSC.DATA-$8F,x
.3 lda SSC.DATA-$8F,x
cmp #$7E
beq .4
cmp #$FF
bne .4
lda #$7E
jsr READ.SSC.StoreByte
lda #$ff
.4
.DO DBG=1
sta INBUF.FirstByte
inc TempB
.FIN
jsr READ.SSC.StoreByte
.40 ldy #0
.5 lda SSC.STATUS-$8F,x
and #SSC.STATUS.RDRF
beq .6
lda SSC.DATA-$8F,x
sta INBUF.LastByte
jsr READ.SSC.StoreByte
.DO DBG=1
inc TempB
.FIN
bra .40
.6 iny
bne .5
.DO SWFC=1
lda #C.XOFF
sta SSC.DATA-$8F,x
.FIN
.DO HWFC=1
lda #SSC.CMD.NOP+SSC.CMD.RIRQDIS+SSC.CMD.DTR
sta SSC.CMD-$8F,x
.FIN
.DO DBG=1
lda TempB
beq .7
ldy #34
jsr READ.SCC.PrintAy
lda INBUF.FirstByte
jsr READ.SCC.PrintAy
lda INBUF.LastByte
jsr READ.SCC.PrintAy
.FIN
.7 sec
lda INBUF.LastByte
eor #$7E
bne .8
clc
.8 ror INBUF.MidFrame
plp
clc
rts
.9 lda #MLI.E.IO
plp
sec
.99 rts
*--------------------------------------
.DO DBG=1
READ.SCC.PrintAy
pha
lsr
lsr
lsr
lsr
jsr .1
pla
and #$0F
.1 ora #$B0
cmp #"9"+1
bcc .2
adc #6
.2 sta $7D0,y
iny
rts
.FIN
*--------------------------------------
READ.SSC.StoreByte
READ.SSC.BUF sta $FFFF SELF MODIFIED
inc READ.SSC.BUF+1
@ -277,23 +425,19 @@ READ.SSC.BUF sta $FFFF SELF MODIFIED
inc INBUF.CNT+1
.2 inc INBUF.HEAD
bne READ.SSC.1
bne .8
inc INBUF.HEAD+1
lda INBUF.HEAD+1
cmp /INBUF.SIZE
bne READ.SSC.1
eor /INBUF.SIZE
bne .8
stz INBUF.HEAD+1
lda INBUF.BASEH
sta READ.SSC.BUF+2
bra READ.SSC.1
READ.SSC.98 lda #MLI.E.IO
plp
sec
rts
.8 rts
*--------------------------------------
READ.NewFrame lda ZPCount
clc
@ -322,6 +466,13 @@ READ.NewFrame lda ZPCount
pla
sta (ZPIOCTL),y
ldy #S.ETH.EII.TYPE-1
lda #0
.1 sta (ZPBufPtr),y Zero Src/Dst MAC
dey
bpl .1
ldy #S.ETH.EII.TYPE
lda /S.ETH.EII.TYPE.IP
sta (ZPBufPtr),y
@ -331,7 +482,7 @@ READ.NewFrame lda ZPCount
lda #S.ETH.EII.TYPE.IP
sta (ZPBufPtr),y
ldy #S.IP.V.IHL.DSCP.ECN
ldy #S.IP.V.IHL
lda #$45
sta (ZPBufPtr),y
@ -369,19 +520,21 @@ READ.GetFrame inc ZPnCount
bne .1
inc ZPnCount+1
beq .2
beq READ.GetFrameTail
.1 jsr READ.GetByteEsc
bcs .9
bcs READ.GetFrame.RTS
sta (ZPBufPtr)
inc ZPBufPtr
bne READ.GetFrame
inc ZPBufPtr+1
bra READ.GetFrame
.2 jsr READ.GetByteEsc skip FCS HI
READ.GetFrameTail
jsr READ.GetByteEsc skip FCS HI
bcs .9
jsr READ.GetByteEsc skip FCS LO
@ -394,8 +547,10 @@ READ.GetFrame inc ZPnCount
beq .9
sec
.9
.9 rts
READ.GetFrame.RTS
rts
*--------------------------------------
READ.Sync jsr READ.GetByte
bcs READ.GetByte.RTS
@ -403,7 +558,7 @@ READ.Sync jsr READ.GetByte
.1 cmp #$7E
bne READ.Sync
jsr READ.GetByte
jsr READ.GetByteEsc
bcs READ.GetByte.RTS
cmp #$FF
@ -416,13 +571,13 @@ READ.Sync jsr READ.GetByte
bne .1
*--------------------------------------
READ.GetByteEsc jsr READ.GetByte
bcs READ.GetByte.9
bcs READ.GetByte.RTS
cmp #$7D
bne READ.GetByte.8
jsr READ.GetByte
bcs READ.GetByte.9
bcs READ.GetByte.RTS
eor #%00100000
* clc
@ -438,20 +593,30 @@ READ.GetByte lda INBUF.CNT
READ.GetByte.1 dec INBUF.CNT
READ.BUF lda $FFFF SELF MODIFIED
inc READ.BUF+1
bne READ.GetByte.8
READ.GetByte.BUF
lda $FFFF SELF MODIFIED
inc READ.BUF+2
inc READ.GetByte.BUF+1
bne .1
inc READ.GetByte.BUF+2
.1 inc INBUF.TAIL
bne READ.GetByte.8
inc INBUF.TAIL+1
phy
ldy INBUF.TAIL+1
cpy /INBUF.SIZE
bne READ.GetByte.8
bne .7
stz INBUF.TAIL+1
ldy INBUF.BASEH
sty READ.BUF+2
sty READ.GetByte.BUF+2
.7 ply
READ.GetByte.8 clc
rts
@ -461,23 +626,44 @@ READ.GetByte.RTS
rts
*--------------------------------------
READ.SendEchoRep
.DO DBG=1
lda #"P"
sta $7D0+33
.FIN
ldx DEVSLOTn08F
.DO HWFC=1
lda #SSC.CMD.NOP+SSC.CMD.TE+SSC.CMD.RIRQDIS+SSC.CMD.DTR
sta SSC.CMD-$8F,x
.FIN
lda #$7E
jsr WRITE.Byte
ldy #0
.1 lda PPP.EchoRep,y
phy
.1 lda LCP.EchoRep,y
jsr WRITE.ByteEsc
ply
iny
cpy #PPP.EchoRep.TOTAL
cpy #LCP.EchoRep.TOTAL
bne .1
lda #$7E
jmp WRITE.Byte
jsr WRITE.Byte
.2 lda SSC.STATUS-$8F,x
bit #SSC.STATUS.TDRE Register Empty ?
beq .2
.DO HWFC=1
lda #SSC.CMD.NOP+SSC.CMD.RIRQDIS+SSC.CMD.DTR
sta SSC.CMD-$8F,x
.FIN
rts
*--------------------------------------
* 7E FF 03 00 21 ... FCS FCS 7E
*--------------------------------------
@ -519,6 +705,11 @@ WRITE >STYA ZPIOCTL
bit #SSC.STATUS.nDCD true when 0
bne .9
.DO HWFC=1
lda #SSC.CMD.NOP+SSC.CMD.TE+SSC.CMD.RIRQDIS+SSC.CMD.DTR
sta SSC.CMD-$8F,x
.FIN
lda #$ff
sta ZPFCS
sta ZPFCS+1
@ -564,6 +755,11 @@ WRITE >STYA ZPIOCTL
lda #$7E
jsr WRITE.Byte
.DO HWFC=1
lda #SSC.CMD.NOP+SSC.CMD.RIRQDIS+SSC.CMD.DTR
sta SSC.CMD-$8F,x
.FIN
plp
clc
rts
@ -592,27 +788,15 @@ WRITE.ByteEsc cmp #$7D
cmp #$7E
beq .1
cmp #$20
cmp #32
bcs WRITE.Byte
* pha
* and #7
* tay bit mask
* lda ACCM.BIT2MASK,y
* sta .10+1
* pla
* pha
* lsr
* lsr
* lsr
* tay
* lda ACCM.OUT,y
*.10 and #$FF SELF MODIFIED
* beq WRITE.Byte.1
* pla
tax
bit ACCM.OUT,x
php
ldx DEVSLOTn08F
plp
bpl WRITE.Byte
.1 eor #%00100000
pha
@ -624,9 +808,9 @@ WRITE.ByteEsc cmp #$7D
WRITE.Byte pha
WRITE.Byte.1 lda SSC.STATUS-$8F,x
.1 lda SSC.STATUS-$8F,x
bit #SSC.STATUS.TDRE Register Empty ?
beq WRITE.Byte.1
beq .1
pla
sta SSC.DATA-$8F,x
@ -651,6 +835,11 @@ INBUF.BASEH .BS 1
INBUF.TAIL .BS 2
INBUF.HEAD .BS 2
INBUF.CNT .BS 2
.DO DBG=1
INBUF.FirstByte .BS 1
.FIN
INBUF.LastByte .BS 1
INBUF.MidFrame .BS 1
*--------------------------------------
DIB .DA #0
.DA #0,#0,#0 size
@ -668,21 +857,22 @@ DCB.IP .BS 4
DCB.MASK .HS FF.FF.FF.FF
DCB.GW .BS 4
*--------------------------------------
ACCM.IN .HS 000A0000
ACCM.OUT .HS FFFFFFFF
ACCM.OUT .HS 8080808080808080 Default = FFFFFFFF
.HS 8080808080808080
.HS 8080808080808080
.HS 8080808080808080
*--------------------------------------
ACCM.BIT2MASK .HS 0102040810204080
*--------------------------------------
PPP.EchoRep .HS FF03
FRAME.HEADER .HS 7E 7EFF03
LCP.EchoRep .HS FF03
.HS C021 LCP
PPP.EchoRep.DATA
LCP.EchoRep.DATA
.HS 0A Echo-Reply
.HS FF ID
.DA /PPP.EchoRep.LEN,#PPP.EchoRep.LEN
.DA /LCP.EchoRep.LEN,#LCP.EchoRep.LEN
.HS 05.06.EA4C2B41 MAGIC
PPP.EchoRep.LEN .EQ *-PPP.EchoRep.DATA
LCP.EchoRep.LEN .EQ *-LCP.EchoRep.DATA
.BS 2 FCS
PPP.EchoRep.TOTAL .EQ *-PPP.EchoRep
LCP.EchoRep.TOTAL .EQ *-LCP.EchoRep
*--------------------------------------
FCS.LO .DA #$0000,#$1189,#$2312,#$329b,#$4624,#$57ad,#$6536,#$74bf
.DA #$8c48,#$9dc1,#$af5a,#$bed3,#$ca6c,#$dbe5,#$e97e,#$f8f7

View File

@ -5,7 +5,10 @@ NEW
.OR $2000
.TF drv/pppssc.drv
*--------------------------------------
DBG .EQ 0
DBG .EQ 1
HWFC .EQ 0
SWFC .EQ 1
INBUF.SIZE .EQ 2048
*--------------------------------------
.INB inc/macros.i
.INB inc/a2osx.i
@ -26,12 +29,16 @@ ZPPtr2 .BS 2
ZPPtr3 .BS 2
ZPBufLen .BS 2
FCS .BS 2
DWORD .BS 4
hETCFILE .BS 1
b7D .BS 1
bLCP .BS 1
bIPCP .BS 1
Len .BS 1
bConfigured .BS 1
ZS.END .ED
*--------------------------------------
* File Header (16 Bytes)
@ -58,7 +65,9 @@ L.ETCFILE .DA ETCFILE
L.MSG.ETCFILE .DA MSG.ETCFILE
L.MSG.UNEXPECTED .DA MSG.UNEXPECTED
L.MSG.SYNTAX .DA MSG.SYNTAX
L.MSG.SSCInit .DA MSG.SSCInit
L.MSG.LCPInit .DA MSG.LCPInit
L.MSG.IPCPInit .DA MSG.IPCPInit
L.MSG.LocalIP .DA MSG.LocalIP
L.MSG.RemoteIP .DA MSG.RemoteIP
.DO DBG=1
@ -66,30 +75,30 @@ L.MSG.DUMPBUF .DA MSG.DUMPBUFS
.DA MSG.DUMPBUFR
L.MSG.HEXDUMP .DA MSG.HEXDUMP
.FIN
L.PPP.ConfReq .DA PPP.ConfReq
L.PPP.EchoRep .DA PPP.EchoRep
L.PPP.IPCPReq .DA PPP.IPCPReq
L.LCP.ConfReq .DA LCP.ConfReq
L.LCP.EchoRep .DA LCP.EchoRep
L.IPCP.ConfReq .DA IPCP.ConfReq
L.IN.Buf .DA IN.Buf
L.IN.Bufp1 .DA IN.Buf+1
L.OUT.Buf .DA OUT.Buf
J.LCP .DA LCP.ConfReq
.DA LCP.ConfAck
.DA LCP.ConfNak
J.LCP .DA LCP.IN.ConfReq
.DA LCP.IN.ConfAck
.DA LCP.IN.ConfNak
.DA LCP.Discard
.DA LCP.Discard
.DA LCP.Discard
.DA LCP.Discard
.DA LCP.Discard
.DA LCP.EchoReq
.DA LCP.IN.EchoReq
.DA LCP.Discard
.DA LCP.Discard
.DA LCP.Discard
.DA LCP.Discard
.DA LCP.Discard
.DA LCP.Discard
J.IPCP .DA IPCP.ConfReq
.DA IPCP.ConfAck
.DA IPCP.ConfNak
J.IPCP .DA IPCP.IN.ConfReq
.DA IPCP.IN.ConfAck
.DA IPCP.IN.ConfNak
.DA IPCP.Discard
.DA IPCP.Discard
.DA IPCP.Discard
@ -145,11 +154,12 @@ Dev.Detect >STYA ZPArgsPtr
sta DEVSLOTn08F
*--------------------------------------
jsr SSC.Init
bcs .9
jsr PPP.ETCFILE
bcs .9
jsr PPP.LCPInit
jsr PPP.Init
bcs .9
>PUSHW L.MSG.DETECT.OK
@ -182,27 +192,30 @@ Dev.Detect >STYA ZPArgsPtr
rts
.99 ldx DEVSLOTn08F
stz SSC.RESET-$8F,x
.99 pha
jsr SSC.Close
pla
* sec
Dev.Detect.RTS rts
*--------------------------------------
PPP.LCPInit >LDYA L.MSG.LCPInit
PPP.Init >LDYA L.MSG.LCPInit
>SYSCALL PutS
>LDYA L.PPP.EchoRep Pre calculate EchoRep FCS
>LDYA L.LCP.EchoRep Pre calculate EchoRep FCS
jsr PPP.FCS16.Set
>LDYA L.PPP.ConfReq
>LDYA L.LCP.ConfReq
jsr PPP.FCS16.Set
.DO DBG=1
>LDYA L.PPP.ConfReq
>LDYA L.LCP.ConfReq
ldx #0
jsr DumpBuf.PPP
.FIN
>LDYA L.PPP.ConfReq
>LDYA L.LCP.ConfReq
jsr SSC.WritePPP
bcs .9
@ -221,19 +234,49 @@ PPP.LCPInit >LDYA L.MSG.LCPInit
jsr DumpBuf.PPP
.FIN
jsr LCP.IN.JUMP
jsr PPP.IN.JUMP
bcs .9
bit bConfigured
bit bLCP
bpl .1
>LDYA L.MSG.IPCPInit
>SYSCALL PutS
jsr IPCP.OUT.ConfReq
bcs .9
.2 jsr SSC.ReadPPP
bcs .9
tya
beq .2
sty ZPBufLen
stz ZPBufLen+1
.DO DBG=1
>LDYA L.IN.Buf
ldx #2
jsr DumpBuf.PPP
.FIN
jsr PPP.IN.JUMP
bcs .9
bit bIPCP
bpl .2
* clc
rts
.9 lda #MLI.E.IO
.9 jsr SSC.Close
lda #MLI.E.IO
* sec
rts
*--------------------------------------
LCP.IN.JUMP lda IN.Buf+3
PPP.IN.JUMP lda IN.Buf+3
cmp #$21
bne LCP.Discard
@ -269,7 +312,7 @@ IPCP.Discard
clc
rts
*--------------------------------------
LCP.ConfReq ldy #0
LCP.IN.ConfReq ldy #0
.1 lda IN.Buf,y FF03C021
sta OUT.Buf,y
@ -310,13 +353,33 @@ LCP.ConfReq ldy #0
phy
phx
ldx #3
ldx #4
.3 lda IN.Buf+2,y
sta ACCM.OUT,x
sta DWORD-1,x
iny
dex
bpl .3
bne .3
* ldx #0
ldy #0
.4 lda #1
.5 and DWORD,y
bne .6
stz ACCM.OUT,x
.6 inx
asl
bne .5
iny
cpy #4
bne .4
plx
ply
@ -373,33 +436,27 @@ LCP.Ack.Next txa
rts
*--------------------------------------
LCP.ConfAck >LDYA L.PPP.IPCPReq
jsr PPP.FCS16.Set
.DO DBG=1
>LDYA L.PPP.IPCPReq
ldx #0
jsr DumpBuf.PPP
.FIN
>LDYA L.PPP.IPCPReq
jmp SSC.WritePPP
*--------------------------------------
LCP.ConfNak
LCP.IN.ConfAck sec
ror bLCP
clc
rts
*--------------------------------------
LCP.EchoReq .DO DBG=1
>LDYA L.PPP.EchoRep
LCP.IN.ConfNak
clc
rts
*--------------------------------------
LCP.IN.EchoReq .DO DBG=1
>LDYA L.LCP.EchoRep
ldx #0
jsr DumpBuf.PPP
.FIN
>LDYA L.PPP.EchoRep
>LDYA L.LCP.EchoRep
jmp SSC.WritePPP
*--------------------------------------
IPCP.ConfReq ldy #0
IPCP.IN.ConfReq ldy #0
.1 lda IN.Buf,y FF038021
sta OUT.Buf,y
@ -481,19 +538,19 @@ IPCP.ConfReq ldy #0
>LDYA L.OUT.Buf
jmp SSC.WritePPP
*--------------------------------------
IPCP.ConfAck sec
ror bConfigured
IPCP.IN.ConfAck sec
ror bIPCP
* clc
rts
*--------------------------------------
IPCP.ConfNak ldy #10
IPCP.IN.ConfNak ldy #10
ldx #0
>PUSHW L.MSG.LocalIP
.1 lda IN.Buf,y
sta PPP.IPCPReq,y
sta IPCP.ConfReq,y
sta DCB.IP,x
>PUSHA
inx
@ -503,143 +560,98 @@ IPCP.ConfNak ldy #10
>PUSHBI 4
>SYSCALL PrintF
jmp LCP.ConfAck
*--------------------------------------
SSC.Init ldx DEVSLOTn08F
stz SSC.RESET-$8F,x
IPCP.OUT.ConfReq
>LDYA L.IPCP.ConfReq
jsr PPP.FCS16.Set
lda #SSC.CTL.1S+SSC.CTL.8D+SSC.CTL.CLKINT+SSC.CTL.B115200
.DO DBG=1
>LDYA L.IPCP.ConfReq
ldx #0
jsr DumpBuf.PPP
.FIN
>LDYA L.IPCP.ConfReq
jmp SSC.WritePPP
*--------------------------------------
SSC.Init >LDYA L.MSG.SSCInit
>SYSCALL PutS
jsr SSC.Close
ldy #0
.10 lda SSC.STATUS-$8F,x
bit #SSC.STATUS.nDCD+SSC.STATUS.nDSR true when 0
bne .20
iny
bne .10
* bra .9
.20 lda #SSC.CTL.1S+SSC.CTL.8D+SSC.CTL.CLKINT+SSC.CTL.B115200
sta SSC.CTL-$8F,x
lda #SSC.CMD.NOP+SSC.CMD.TE+SSC.CMD.RIRQDIS+SSC.CMD.DTR
sta SSC.CMD-$8F,x
lda SSC.DATA-$8F,x discard any garbage byte
lda SSC.STATUS-$8F,x clear any IRQ pending
rts
*--------------------------------------
SSC.WritePPP >STYA ZPPtr1
ldy #7
lda (ZPPtr1),y Len LO
clc
adc #6
eor #$ff
sta ZPPtr3
dey
lda (ZPPtr1),y Len HI
adc #0
eor #$ff
sta ZPPtr3+1
php
sei
ldx DEVSLOTn08F
ldy #0
.1 lda SSC.STATUS-$8F,x
bit #SSC.STATUS.nDCD true when 0
bne .9
bit #SSC.STATUS.TDRE Register Empty ?
bne .2
bit #SSC.STATUS.nDCD+SSC.STATUS.nDSR true when 0
beq .2
iny
bne .1
.9 lda #MLI.E.IO
plp
.9 lda #MLI.E.IO
sec
rts
.2 lda #$7E
.2 lda SSC.DATA-$8F,x discard any garbage byte
.DO SWFC=1
lda #C.XOFF
sta SSC.DATA-$8F,x
.FIN
.3 inc ZPPtr3
bne .31
.DO HWFC=1
lda #SSC.CMD.NOP+SSC.CMD.RIRQDIS+SSC.CMD.DTR
sta SSC.CMD-$8F,x
.FIN
inc ZPPtr3+1
beq .8
.31 lda SSC.STATUS-$8F,x
bit #SSC.STATUS.TDRE
beq .3
lda (ZPPtr1),y
cmp #$7D
beq .4
cmp #$7E
beq .4
cmp #$20
bcs .6
phx
phy
and #7
tax bit in byte
lda (ZPPtr1),y
lsr
lsr
lsr
tay
lda ACCM.OUT,y
and ACCM.BIT2MASK,x
cmp #1
ply
plx
lda (ZPPtr1),y
bcc .6
.4 lda #$7D
sta SSC.DATA-$8F,x
.5 lda SSC.STATUS-$8F,x
bit #SSC.STATUS.TDRE
beq .5
lda (ZPPtr1),y
eor #%00100000
.6 sta SSC.DATA-$8F,x
iny
bne .3
inc ZPPtr1+1
bra .3
.8 lda SSC.STATUS-$8F,x
bit #SSC.STATUS.TDRE
beq .8
lda #$7E
sta SSC.DATA-$8F,x
plp
clc
rts
*--------------------------------------
SSC.Close ldx DEVSLOTn08F
stz SSC.RESET-$8F,x
lda #SSC.CMD.RIRQDIS
sta SSC.CMD-$8F,x Applewin Bug ???
rts
*--------------------------------------
SSC.ReadPPP php
sei
ldx DEVSLOTn08F
.1 stz b7D
.DO SWFC=1
lda #C.XON
sta SSC.DATA-$8F,x
.FIN
ldy #0
.DO HWFC=1
lda #SSC.CMD.NOP+SSC.CMD.TE+SSC.CMD.RIRQDIS+SSC.CMD.DTR
sta SSC.CMD-$8F,x
.FIN
.2 lda SSC.STATUS-$8F,x
stz b7D
.10 ldy #0
.1 lda SSC.STATUS-$8F,x
bit #SSC.STATUS.nDCD true when 0
bne .9
@ -647,35 +659,49 @@ SSC.ReadPPP php
bne .3
iny
bne .2
bne .1
.8 plp
.8
.DO SWFC=1
lda #C.XOFF
sta SSC.DATA-$8F,x
.FIN
.DO HWFC=1
lda #SSC.CMD.NOP+SSC.CMD.RIRQDIS+SSC.CMD.DTR
sta SSC.CMD-$8F,x
.FIN
plp
clc
rts
.3 lda SSC.DATA-$8F,x
bit b7D
bmi .4
cmp #$7E
bne .4
cmp #$7D
bne .40
ror b7D
bra .1
.4 cmp #$FF
bne .1
.4 stz b7D
eor #%00100000
.40 cmp #$FF
bne .10
sta IN.Buf
ldy #1
stz b7D
.5 lda SSC.STATUS-$8F,x
bit #SSC.STATUS.nDCD true when 0
bne .9
.5 lda #SSC.STATUS.RDRF
bit #SSC.STATUS.RDRF incoming char?
beq .5
.50 bit SSC.STATUS-$8F,x incoming char?
beq .50
lda SSC.DATA-$8F,x
bit b7D
@ -689,6 +715,7 @@ SSC.ReadPPP php
.6 stz b7D
eor #%00100000
sta IN.Buf,y
iny
bra .5
@ -698,11 +725,113 @@ SSC.ReadPPP php
sta IN.Buf,y
iny
bra .5
bne .5
.9 lda #MLI.E.IO
plp
sec
.99 rts
*--------------------------------------
SSC.WritePPP >STYA ZPPtr1
ldy #7
lda (ZPPtr1),y Len LO
clc
adc #6
sta ZPPtr3
php
sei
ldx DEVSLOTn08F
lda SSC.STATUS-$8F,x
bit #SSC.STATUS.nDCD true when 0
bne .9
.DO HWFC=1
lda #SSC.CMD.NOP+SSC.CMD.TE+SSC.CMD.RIRQDIS+SSC.CMD.DTR
sta SSC.CMD-$8F,x
.FIN
lda #SSC.STATUS.TDRE
.1 bit SSC.STATUS-$8F,x Register Empty ?
beq .1
lda #$7E
sta SSC.DATA-$8F,x
.2 lda (ZPPtr1)
cmp #$7D
beq .5
cmp #$7E
beq .5
cmp #32
bcs .6
tay
lda ACCM.OUT,y
beq .53
.5 lda #SSC.STATUS.TDRE
.51 bit SSC.STATUS-$8F,x Register Empty ?
beq .51
lda #$7D
sta SSC.DATA-$8F,x
lda #SSC.STATUS.TDRE
.52 bit SSC.STATUS-$8F,x Register Empty ?
beq .52
lda (ZPPtr1)
eor #%00100000
bra .6
.53 lda (ZPPtr1)
.6 sta SSC.DATA-$8F,x
inc ZPPtr1
bne .60
inc ZPPtr1+1
.60 dec ZPPtr3
bne .2
lda #SSC.STATUS.TDRE
.7 bit SSC.STATUS-$8F,x Register Empty ?
beq .7
lda #$7E
sta SSC.DATA-$8F,x
lda #SSC.STATUS.TDRE
.8 bit SSC.STATUS-$8F,x Register Empty ?
beq .8
.DO HWFC=1
lda #SSC.CMD.NOP+SSC.CMD.RIRQDIS+SSC.CMD.DTR
sta SSC.CMD-$8F,x
.FIN
plp
clc
rts
.9 lda #MLI.E.IO
plp
sec
rts
*--------------------------------------
.DO DBG=1
@ -752,6 +881,7 @@ DumpBuf.PPP >STYA ZPPtr1
lda ZPPtr2
adc #16
sta ZPPtr2
bcs .8
lda ZPPtr2+1
adc #0
sta ZPPtr2+1
@ -768,7 +898,7 @@ DumpBuf.PPP >STYA ZPPtr1
ora ZPPtr3
bne .1
clc
.8 clc
.9 rts
.FIN
@ -868,7 +998,9 @@ ETCFILE .AZ "${ROOT}etc/ppp.conf"
MSG.ETCFILE .AZ "Executing %s File...\r\n"
MSG.UNEXPECTED .AZ "\r\nERR:Unexpected reply From Modem\r\n{%s}\r\n"
MSG.SYNTAX .AZ "\r\nERR:Bad Syntax In ppp.conf\r\n{%s}\r\n"
MSG.LCPInit .AZ "LCP/IPCP Negotiation..."
MSG.SSCInit .AZ "Connecting..."
MSG.LCPInit .AZ "LCP Negotiation..."
MSG.IPCPInit .AZ "IPCP Negotiation..."
MSG.LocalIP .AZ "Local IP is %d.%d.%d.%d\r\n"
MSG.RemoteIP .AZ "Remote IP is %d.%d.%d.%d\r\n"
.DO DBG=1
@ -887,30 +1019,34 @@ FD.DEV .DA #S.FD.T.CDEV
.DA 0 BUFPTR
FD.DEV.NAME .AZ "eth1"
*--------------------------------------
PPP.ConfReq .HS FF03
LCP.ConfReq .HS FF03
.HS C021 LCP
PPP.ConfReq.DATA
LCP.ConfReq.DATA
.HS 01 Configure-Request
.HS FF ID
.DA /PPP.ConfReq.LEN,#PPP.ConfReq.LEN
.DA /LCP.ConfReq.LEN,#LCP.ConfReq.LEN
* .HS 01.04 MRU
* .DA /1400,#1400
.DO SWFC=1
.HS 02.06.000A0000 ACCM
.ELSE
.HS 02.06.00000000 ACCM
.FIN
.HS 05.06.EA4C2B41 MAGIC
* .HS 07.02
* .HS 08.02
PPP.ConfReq.LEN .EQ *-PPP.ConfReq.DATA
LCP.ConfReq.LEN .EQ *-LCP.ConfReq.DATA
.BS 2 FCS
*--------------------------------------
PPP.IPCPReq .HS FF03
IPCP.ConfReq .HS FF03
.HS 8021 IPCP
PPP.IPCPReq.DATA
IPCP.ConfReq.DATA
.HS 01 Configure-Request
.HS FF ID
.DA /PPP.IPCPReq.LEN,#PPP.IPCPReq.LEN
.DA /IPCP.ConfReq.LEN,#IPCP.ConfReq.LEN
* .HS 02.06.00.2D.0F.00 VJ
.HS 03.06.00.00.00.00 IP Address
PPP.IPCPReq.LEN .EQ *-PPP.IPCPReq.DATA
IPCP.ConfReq.LEN .EQ *-IPCP.ConfReq.DATA
.BS 2 FCS
*--------------------------------------
IN.Buf .BS 256

View File

@ -212,7 +212,8 @@ S.ARP.TPA .EQ S.ETH.EII+24 Target IP
*
S.ARP .EQ S.ETH.EII+28
*--------------------------------------
S.IP.V.IHL.DSCP.ECN .EQ S.ETH.EII+0 $0045, IPV4,HDR=5DWORDs
S.IP.V.IHL .EQ S.ETH.EII+0 $45, IPV4,HDR=5DWORDs
S.IP.DSCP.ECN .EQ S.ETH.EII+1
S.IP.TOTAL.LENGTH .EQ S.ETH.EII+2
S.IP.IDENTIFICATION .EQ S.ETH.EII+4
S.IP.FRAGMENT.FLAGS .EQ S.ETH.EII+6

View File

@ -2,35 +2,53 @@ NEW
AUTO 3,1
*--------------------------------------
LIBTUI.Init .EQ 4
LIBTUI.GetEvent .EQ 6
LIBTUI.Dispatch .EQ 8
LIBTUI.Close .EQ 10
LIBTUI.New .EQ 12
LIBTUI.Destroy .EQ 14
LIBTUI.Run .EQ 16
LIBTUI.Draw .EQ 18
LIBTUI.GetProp .EQ 20
LIBTUI.SetProp .EQ 22
LIBTUI.Activate .EQ 24
LIBTUI.Deactivate .EQ 26
LIBTUI.Close .EQ 6
LIBTUI.New .EQ 8
LIBTUI.Exec .EQ 10
LIBTUI.Destroy .EQ 12
LIBTUI.Run .EQ 14
LIBTUI.Draw .EQ 16
LIBTUI.GetProp .EQ 18
LIBTUI.SetProp .EQ 20
LIBTUI.Activate .EQ 22
LIBTUI.Deactivate .EQ 24
*--------------------------------------
S.CTX.hSCRN .EQ 0
S.CTX.hClipBrd .EQ 1
S.CTX.W .EQ 2
S.CTX.H .EQ 3
S.CTX.bEscMode .EQ 14
S.CTX.InBufPtr .EQ 15
*
S.CTX.InBuf .EQ 16
S.CTX.EndBuf .EQ 31
*
S.CTX .EQ 32
*--------------------------------------
S.OBJ.T .EQ 0
S.OBJ.T.SCRN .EQ 0
S.OBJ.T.TBOX .EQ 2
S.OBJ.T.LBOX .EQ 4
S.OBJ.T.DLG .EQ 2
S.OBJ.T.LABEL .EQ 4
S.OBJ.T.TLINE .EQ 6
S.OBJ.T.TBOX .EQ 8
S.OBJ.T.LBOX .EQ 10
S.OBJ.T.CBOX .EQ 12
S.OBJ.T.BUT .EQ 14
S.OBJ.T.RADIO .EQ 16
S.OBJ.F .EQ 1
S.OBJ.F.bTITLE .EQ %10000000
S.OBJ.F.bMENU .EQ %01000000
S.OBJ.F.bSTATUS .EQ %00100000
S.OBJ.F.bTitle .EQ %10000000
S.OBJ.F.bMenu .EQ %01000000
S.OBJ.F.bStatus .EQ %00100000
S.OBJ.F.bHBorder .EQ %00010000
S.OBJ.F.bVBorder .EQ %00001000
S.OBJ.F.bHScroll .EQ %00000100
S.OBJ.F.bVScroll .EQ %00000010
S.OBJ.F.bCursor .EQ %00000001
S.OBJ.P .EQ 2
S.OBJ.S .EQ 3
S.OBJ.S.bACTIVE .EQ %10000000
S.OBJ.S.bVISIBLE .EQ %01000000
S.OBJ.S .EQ 2
S.OBJ.S.bActive .EQ %10000000
S.OBJ.S.bDisabled .EQ %01000000
S.OBJ.S.bCurOn .EQ %00000001
S.OBJ.hParent .EQ 3
S.OBJ.X1 .EQ 4
S.OBJ.Y1 .EQ 5
S.OBJ.W .EQ 6
@ -42,44 +60,79 @@ S.OBJ.InnerX .EQ 10
S.OBJ.InnerY .EQ 11
S.OBJ.InnerW .EQ 12
S.OBJ.InnerH .EQ 13
S.OBJ.ActChild .EQ 14
*
S.OBJ.CurX .EQ 14
S.OBJ.CurY .EQ 15
*--------------------------------------
S.OBJ.pTITLE .EQ 16
S.OBJ.pMENU .EQ 18
S.OBJ.pSTATUS .EQ 20
S.OBJ.fRESIZE .EQ 22
*
*
*--------------------------------------
S.OBJ.Childs .EQ 32
*
S.OBJ .EQ 48
*--------------------------------------
S.SCRN.bEscMode .EQ S.OBJ
S.SCRN.InBufPtr .EQ S.OBJ+1
S.SCRN.InBuf .EQ S.OBJ+2
S.SCRN.EndBuf .EQ S.OBJ+15
S.SCRN .EQ S.OBJ
*--------------------------------------
S.DLG .EQ S.OBJ
*--------------------------------------
S.LABEL.pLabel .EQ S.OBJ+0
*
S.SCRN .EQ S.OBJ+16
S.LABEL .EQ S.OBJ+2
*--------------------------------------
S.TLINE.pBuf .EQ S.OBJ+0
S.TLINE.Ptr .EQ S.OBJ+2
S.TLINE.Len .EQ S.OBJ+3
S.TLINE.MaxLen .EQ S.OBJ+4
S.TLINE.HScroll .EQ S.OBJ+5
*
S.TLINE .EQ S.OBJ+6
*--------------------------------------
S.TBOX.hBuf .EQ S.OBJ+0
*
S.TBOX.CurX .EQ S.OBJ+2
S.TBOX.CurY .EQ S.OBJ+3
S.TBOX.BufSize .EQ S.OBJ+2
S.TBOX.DocX .EQ S.OBJ+4
S.TBOX.DocY .EQ S.OBJ+6
S.TBOX.HScroll .EQ S.OBJ+8
S.TBOX.VScroll .EQ S.OBJ+10
S.TBOX.BufPtr .EQ S.OBJ+12
S.TBOX.BufCnt .EQ S.OBJ+14
S.TBOX.SelBegin .EQ S.OBJ+16
S.TBOX.SelEnd .EQ S.OBJ+18
S.TBOX.bSelect .EQ S.OBJ+20
*
S.TBOX .EQ S.OBJ+16
S.TBOX .EQ S.OBJ+21
*--------------------------------------
S.LBOX.pL .EQ S.OBJ+0
S.LBOX.Idx .EQ S.OBJ+2
S.LBOX.VScroll .EQ S.OBJ+3
S.LBOX.Idx .EQ S.OBJ+0
S.LBOX.VScroll .EQ S.OBJ+1
S.LBOX.pList .EQ S.OBJ+2
S.LBOX.pVar .EQ S.OBJ+4
*
S.LBOX .EQ S.OBJ+16
S.LBOX .EQ S.OBJ+6
*--------------------------------------
S.CBOX.HotKey .EQ S.OBJ+0
S.CBOX.EV .EQ S.OBJ+1
S.CBOX.pLabel .EQ S.OBJ+2
S.CBOX.pVar .EQ S.OBJ+4
*
S.CBOX .EQ S.OBJ+6
*--------------------------------------
S.BUT.HotKey .EQ S.OBJ+0
S.BUT.EV .EQ S.OBJ+1
S.BUT.pLabel .EQ S.OBJ+2
*
S.BUT .EQ S.OBJ+4
*--------------------------------------
S.RADIO.HotKey .EQ S.OBJ+0
S.RADIO.EV .EQ S.OBJ+1
S.RADIO.pList .EQ S.OBJ+2
S.RADIO.pVar .EQ S.OBJ+4
S.RADIO.Idx .EQ S.OBJ+6
*
S.RADIO .EQ S.OBJ+8
*--------------------------------------
EV.RESIZE .EQ $80
EV.QUIT .EQ $81
*--------------------------------------
MAN
SAVE inc/libtui.i

11
INCLUDE/libtui.h.txt Normal file
View File

@ -0,0 +1,11 @@
NEW
AUTO 3,1
short int tuiInit();
int fastcall tuiClose(short int);
short int tuiNew(short int,...);
short int tuiRun(short int);
short int tuiClose(short int);
MAN
TEXT include/libtui.h

10
INCLUDE/md5.h.txt Normal file
View File

@ -0,0 +1,10 @@
NEW
AUTO 3,1
void md5(const char*, char*);
short int md5init();
void md5update(short int, char* ,int);
void md5finalize(short int, char*);
MAN
TEXT include/md5.h

View File

@ -1,6 +1,8 @@
NEW
AUTO 3,1
#define NULL 0
#define O_RDONLY 1
#define O_WRONLY 2
#define O_RDWR 3
@ -31,8 +33,8 @@ int fastcall puts(const char*);
int fputs(short int,const char*);
char* fgets(short int,char*,int);
short int getchar();
short int fastcall getc(short int);
char getchar();
char fastcall getc(short int);
// short int ungetc(short int c, short int );
int printf(const char*,...);

View File

@ -1,8 +1,9 @@
NEW
AUTO 3,1
// void* malloc(int);
// void free(void*);
void* fastcall malloc(int);
void* realloc(void*,int);
void fastcall free(void*);
float strtof(const char*,char**);
float atof(const char*);

View File

@ -7,6 +7,8 @@ int read(short int, void*, int);
int write(short int, const void*, int);
// int lseek(short int,long,short int);
short int execl(const char, short int);
short int chown(const char*, short int, short int);
MAN

View File

@ -101,7 +101,7 @@ FRM.NewIP stx .8+1
lda #S.ETH.EII.TYPE.IP
sta (ZPFrameOutPtr),y
ldy #S.IP.V.IHL.DSCP.ECN
ldy #S.IP.V.IHL
lda #$45
sta (ZPFrameOutPtr),y
* iny
@ -174,7 +174,7 @@ FRM.SendIP php
clc
ldy #S.IP.V.IHL.DSCP.ECN
ldy #S.IP.V.IHL
ldx #10 10 words for IP Header
@ -288,6 +288,7 @@ FRM.Retry ldx FRM.QUEUE.Tail
.1 cpx FRM.QUEUE.Head
beq .8 Queue is empty, exit...
lda FRM.QUEUE.LenL,x
sta ZPFrameOutLen
lda FRM.QUEUE.LenH,x
@ -303,6 +304,7 @@ FRM.Retry ldx FRM.QUEUE.Tail
jsr IP.SetDestMAC Err is ARP or higher, retry getting MAC
bcs .3 still error getting dest MAC
.2 jsr FRM.Send try sending again to DRV
bcc .4
@ -339,9 +341,11 @@ FRM.Send.IOCTL >PUSHB IPCFG+S.NETCFG.DevID
*--------------------------------------
FRM.DiscardIn lda hFrameIn
beq .8
stz hFrameIn
>SYSCALL2 FreeMem
.8 clc
rts
*--------------------------------------

View File

@ -324,20 +324,26 @@ SKT.shutdown pha
ldy #S.SOCKET.O
lda (ZPPtrSKT),y
and #S.SOCKET.O.ACCEPTCONN
bne SKT.shutdown.LISTEN
bne SKT.shutdown.HQ
ldy #S.SOCKET.T
lda (ZPPtrSKT),y
cmp #S.SOCKET.T.SEQPKT
bcc SKT.shutdown.DGRAM
bcc SKT.shutdown.HQ
ldy #S.SOCKET.TCP.S
lda (ZPPtrSKT),y
cmp #S.SOCKET.TCP.S.TIMEWT
bcs .7
cmp #S.SOCKET.TCP.S.CLOSING
bne .10
inc S.SOCKET.TCP.S.TIMEWT
sta (ZPPtrSKT),y
pla
clc
rts
.10 pla
jsr SKT.GetTCB
ldy #S.SOCKET.TCP.S
lda (ZPPtrSKT),y
@ -346,7 +352,6 @@ SKT.shutdown pha
lda #S.TCP.OPTIONS.FIN+S.TCP.OPTIONS.ACK
jsr TCP.OUT.SendOptA Send FIN/ACK
bcs .9
lda #S.SOCKET.TCP.S.FINWT1
jmp SKT.StoreTCB.S
@ -359,18 +364,12 @@ SKT.shutdown pha
.3 lda #S.SOCKET.TCP.S.TIMEWT
jmp SKT.StoreTCB.S
.7 pla
.8 clc
.9 rts
*--------------------------------------
SKT.shutdown.LISTEN
SKT.shutdown.DGRAM
.1 jsr SKT.GetFromQueue
SKT.shutdown.HQ jsr SKT.GetFromQueue
bcs .3
>SYSCALL2 FreeMem
bra .1
bra SKT.shutdown.HQ
.3 pla get hFD...
@ -386,7 +385,6 @@ SKT.shutdown.DGRAM
.5 stz SKT.TABLE,x
>SYSCALL2 freemem
* clc
SKT.shutdown.RTS
rts
*/--------------------------------------
* # Read (STREAM)
@ -489,6 +487,7 @@ SKT.GetDataFromSktIn
sbc /K.TCP.WSIZE
sta ZPTmpPtr1+1
bra .1
.8 sty SKT.Cache+S.SOCKET.TCP.INTAIL
* >ADC16 SKT.Cache+S.SOCKET.TCP.INFREE,ZPDataInLen
@ -1199,10 +1198,10 @@ SKT.FindMatchingLocRem
lda (ZPFrameInPtr),y
cmp #S.TCP.OPTIONS.SYN
beq .7 SYN received on a LISTEN socket, ok
bne .8 bad packet for this listening
.6 lda SKT.REM.ADDR+S.SOCKADDR.ADDR
cmp #$ff incoming frame is FF.FF.FF.FF, Broadcast ?
bne .41
@ -1229,8 +1228,7 @@ SKT.FindMatchingLocRem
cpy #S.SOCKET.REM.PORT+2
bne .42
.7 stx SKT.Index x = SKT.TABLE index
clc
.7 clc x = SKT.TABLE index
rts
.8 inx
@ -1397,10 +1395,12 @@ SKT.SetFrameOutTCPUDPPorts
ldy #S.SOCKET.REM.PORT
lda (ZPPtrSKT),y
beq .1
tax
iny
lda (ZPPtrSKT),y
bra .2
.1 lda SKT.REM.ADDR+S.SOCKADDR.PORT+1
ldx SKT.REM.ADDR+S.SOCKADDR.PORT
@ -1430,11 +1430,14 @@ SKT.CopyDataInToOut
jsr SKT.GetNotDataInLen
pha
ldy #0
.1 inx
bne .2
pla
inc
beq .9
pha
.2 lda (ZPDataInPtr),y
@ -1458,6 +1461,7 @@ SKT.SetupZPCode ldy #ZP.CODE.Len-1
sta ZPCode,y
dey
bpl .1
rts
.FIN
*--------------------------------------

View File

@ -16,17 +16,15 @@ TCP.IN jsr FRM.GetTargetSKT.TCPUDP
tax
jmp (J.TCP.IN,x)
*--------------------------------------
TCP.IN.RST lda #S.SOCKET.TCP.S.CLWAIT
TCP.IN.RST lda #S.SOCKET.TCP.S.CLOSING
ldy #S.SOCKET.TCP.S
sta (ZPPtrSKT),y
* lda SKT.TABLE,x
* jsr SKT.shutdown
*--------------------------------------
TCP.IN.JMP.OPENED
TCP.IN.JMP.CLOSED
TCP.IN.JMP.OPENED
TCP.IN.JMP.DISCARD
jmp FRM.DiscardIn
clc
rts
*--------------------------------------
TCP.IN.JMP.LISTEN
ldy #S.SOCKET.T Create a new client socket
@ -84,6 +82,7 @@ TCP.IN.JMP.SYNSENT
sta SKT.Cache+S.SOCKET.TCP.OUTNEXTSEQ,x
eor (ZPFrameInPtr),y
bne .9
dey
dex
bpl .1
@ -98,9 +97,8 @@ TCP.IN.JMP.SYNSENT
.9 lda #S.TCP.OPTIONS.RST
jsr TCP.OUT.SendOptA Send RST
ldx SKT.Index
lda SKT.TABLE,x
jmp SKT.shutdown
jmp TCP.IN.RST
*--------------------------------------
TCP.IN.JMP.SYNRCVD
ldy #S.TCP.OPTIONS SYN Received, SYN.ACK Sent, only accept ACK packet
@ -269,10 +267,10 @@ TCP.IN.JMP.LASTACK
bit #S.TCP.OPTIONS.ACK
beq .8
jsr TCP.OUT.SendACK
* jsr TCP.OUT.SendACK
ldy #S.SOCKET.TCP.S
lda #S.SOCKET.TCP.S.TIMEWT
lda #S.SOCKET.TCP.S.CLOSING
sta (ZPPtrSKT),y
.8
*--------------------------------------
@ -317,23 +315,25 @@ TCP.IN.JMP.FINWT2
jsr TCP.OUT.SendACK FIN received, Send ACK
bcs TCP.IN.JMP.TIMEWT.RTS
lda #S.SOCKET.TCP.S.TIMEWT
lda #S.SOCKET.TCP.S.CLOSING
jmp SKT.StoreTCB.S
*--------------------------------------
TCP.IN.JMP.CLOSING
ldy #S.TCP.OPTIONS only accept ACK packet
lda (ZPFrameInPtr),y
bit #S.TCP.OPTIONS.ACK
beq .1
ldy #S.SOCKET.TCP.S
lda #S.SOCKET.TCP.S.TIMEWT
sta (ZPPtrSKT),y
.1
* Wait for SKT.Shutdown
* ldy #S.TCP.OPTIONS only accept ACK packet
* lda (ZPFrameInPtr),y
* bit #S.TCP.OPTIONS.ACK
* beq .1
* ldy #S.SOCKET.TCP.S
* lda #S.SOCKET.TCP.S.TIMEWT
* sta (ZPPtrSKT),y
*.1
* clc
* rts
*--------------------------------------
TCP.IN.JMP.TIMEWT
clc Wait for TCP.Close
clc Wait for TCP.SendClose
TCP.IN.JMP.TIMEWT.RTS
rts
*--------------------------------------
@ -357,6 +357,7 @@ TCP.IN.ACKTheFIN
.1 inc SKT.Cache+S.SOCKET.TCP.INSEQNUM,x
bne .8
dex
bpl .1
@ -385,7 +386,9 @@ TCP.IN.SetDataInPtrAndLen
sbc ZPDataInPtr TMP Storage
sta ZPDataInLen
bcs .1
dec ZPDataInLen+1
.1 lda ZPFrameInPtr
clc
adc #S.IP
@ -397,7 +400,9 @@ TCP.IN.SetDataInPtrAndLen
clc
adc ZPDataInPtr TMP Storage
bcc .2
inx
.2 sta ZPDataInPtr
stx ZPDataInPtr+1
TCP.IN.RTS rts
@ -466,11 +471,13 @@ TCP.SENDCLOSE ldx #0
.7 plx
phx
lda SKT.TABLE,x
stz SKT.TABLE,x
>SYSCALL2 freemem
.8 plx
inx
cpx #K.SKTTABLE.SIZE
bne .1

View File

@ -197,6 +197,7 @@ LIB.UNLOAD dec RefCount
lda hDNSSocket
beq .1
jsr SKT.Shutdown
.1 lda hARPCache
@ -388,7 +389,6 @@ hDNSSocket .BS 1
DNS.TmpCache .BS S.DNSCACHE
ARP.TmpCache .BS S.ARPCACHE
*--------------------------------------
SKT.Index .BS 1
SKT.TABLE .BS K.SKTTABLE.SIZE
SKT.LOC.ADDR .BS S.SOCKADDR
SKT.REM.ADDR .BS S.SOCKADDR

140
LIB/LIBTUI.S.BUT.txt Normal file
View File

@ -0,0 +1,140 @@
NEW
AUTO 3,1
.LIST OFF
*--------------------------------------
* BUT.New hParent,X1,Y1,HK,EV,pLabel 7
*--------------------------------------
BUT.New jsr OBJ.Create a = Class
bcs .9
ldy #S.BUT.pLabel
jsr OBJ.PullWordY
stx ZPPtr1
sta ZPPtr1+1
ldy #$ff
.1 iny
lda (ZPPtr1),y
bne .1
tya
inc
inc
ldy #S.OBJ.W
sta (ZPObjPtr),y
ldy #S.OBJ.H
lda #1
sta (ZPObjPtr),y
>PULLA
ldy #S.BUT.EV
sta (ZPObjPtr),y
>PULLA
ldy #S.BUT.HotKey
sta (ZPObjPtr),y
jsr OBJ.PullY1X1hParent
jmp OBJ.Insert
.9 >POP 7
.99 rts
*--------------------------------------
BUT.Destroy clc
rts
*--------------------------------------
BUT.Run lda (pStack) Event
ldy #S.BUT.HotKey
cmp (ZPObjPtr),y
beq .8
ldy #S.OBJ.S
lda (ZPObjPtr),y
bpl .9
lda (pStack) Event
cmp #C.SPACE
bne .9
.8 ldy #S.BUT.EV
lda (ZPObjPtr),y
clc
rts
.9 lda #0
sec
rts
*--------------------------------------
BUT.Draw ldy #S.BUT.pLabel
lda (ZPObjPtr),y
sta ZPPtr1
iny
lda (ZPObjPtr),y
sta ZPPtr1+1
ldx #SEQ.INVERSE-SEQS
jsr LB.SeqOut
ldx #C.SPACE
ldy #S.OBJ.S
lda (ZPObjPtr),y
bpl .1
ldx #'['
.1 txa
jsr LB.COut
ldy #S.OBJ.InnerW
lda (ZPObjPtr),y
tax
dex
dex
ldy #0
.2 lda (ZPPtr1),y
beq .3
jsr LB.COut
iny
dex
bne .2
.3 txa
beq .5
lda #C.SPACE
.4 jsr LB.COut
dex
bne .4
.5 ldx #C.SPACE
ldy #S.OBJ.S
lda (ZPObjPtr),y
bpl .20
ldx #']'
.20 txa
jsr LB.COut
.8 clc
rts
*--------------------------------------
BUT.Activate
BUT.Deactivate jmp OBJ.Draw.Body
*--------------------------------------
MAN
SAVE usr/src/lib/libtui.s.but
LOAD usr/src/lib/libtui.s
ASM

186
LIB/LIBTUI.S.CBOX.txt Normal file
View File

@ -0,0 +1,186 @@
NEW
AUTO 3,1
.LIST OFF
*--------------------------------------
* CBOX.New hParent,X1,Y1,HK,EV,pLabel,pVar 9
*--------------------------------------
CBOX.New jsr OBJ.Create a = Class
bcs .9
ldy #S.CBOX.pVar
jsr OBJ.PullWordY
ldy #S.CBOX.pLabel
jsr OBJ.PullWordY
stx ZPPtr1
sta ZPPtr1+1
>PULLA
ldy #S.CBOX.EV
sta (ZPObjPtr),y
>PULLA
ldy #S.CBOX.HotKey
sta (ZPObjPtr),y
ldy #$ff
.1 iny
lda (ZPPtr1),y
bne .1
tya
inc
inc
inc
inc
inc
ldy #S.OBJ.W
sta (ZPObjPtr),y
ldy #S.OBJ.H
lda #1
sta (ZPObjPtr),y
jsr OBJ.PullY1X1hParent
jmp OBJ.Insert
.9 >POP 9
rts
*--------------------------------------
CBOX.Destroy clc
rts
*--------------------------------------
CBOX.Run ldy #S.BUT.HotKey
cmp (ZPObjPtr),y
beq .8
ldy #S.OBJ.S
lda (ZPObjPtr),y
bpl .9
lda (pStack) Event
cmp #C.SPACE
bne .9
.8 ldy #S.CBOX.pVar
lda (ZPObjPtr),y
sta ZPPtr1
iny
lda (ZPObjPtr),y
sta ZPPtr1+1
lda (ZPPtr1)
eor #$ff
sta (ZPPtr1)
ldy #1 hObj
lda (pStack),y
>PUSHA
jsr OBJ.Draw.Body
inc pStack
rts
.9 lda #0
sec
rts
*--------------------------------------
CBOX.Draw ldx #'('
ldy #S.OBJ.S
lda (ZPObjPtr),y
php
bpl .10
ldx #'['
.10 txa
jsr LB.COut
ldy #S.CBOX.pVar
lda (ZPObjPtr),y
sta ZPPtr1
iny
lda (ZPObjPtr),y
sta ZPPtr1+1
ldx #C.SPACE
lda (ZPPtr1)
bpl .11
ldx #'X'
.11 txa
jsr LB.COut
ldx #')'
plp
bpl .12
ldx #']'
.12 txa
jsr LB.COut
lda #C.SPACE
jsr LB.COut
ldy #S.BUT.pLabel
lda (ZPObjPtr),y
sta ZPPtr1
iny
lda (ZPObjPtr),y
sta ZPPtr1+1
.1 ldy #S.OBJ.InnerW
lda (ZPObjPtr),y
tax
dex
dex
dex
dex
ldy #0
.2 lda (ZPPtr1),y
beq .3
jsr LB.COut
iny
dex
bne .2
.3 txa
beq .8
bra .6
.5 ldy #S.OBJ.InnerW
lda (ZPObjPtr),y
tax
.6 lda #C.SPACE
.7 jsr LB.COut
dex
bne .7
.8 clc
rts
*--------------------------------------
CBOX.Activate
*--------------------------------------
CBOX.Deactivate jmp OBJ.Draw.Body
*--------------------------------------
MAN
SAVE usr/src/lib/libtui.s.cbox
LOAD usr/src/lib/libtui.s
ASM

121
LIB/LIBTUI.S.CONT.txt Normal file
View File

@ -0,0 +1,121 @@
NEW
AUTO 3,1
.LIST OFF
*--------------------------------------
* CONT.New hCTX,F 2
*--------------------------------------
CONT.New jsr OBJ.Create A = Class
bcs .9
>PULLA
ldy #S.OBJ.F
sta (ZPObjPtr),y
>PULLA
ldy #S.OBJ.hParent
sta (ZPObjPtr),y
>SYSCALL2 GetMemPtr
>STYA ZPPtr2
ldy #S.CTX.W
lda (ZPPtr2),y
ldy #S.OBJ.W
sta (ZPObjPtr),y
ldy #S.CTX.H
lda (ZPPtr2),y
ldy #S.OBJ.H
sta (ZPObjPtr),y
jmp OBJ.SetX2Y2
.9 >POP 2
rts
*--------------------------------------
CONT.Destroy clc
rts
*--------------------------------------
CONT.Run lda (pStack) Event
cmp #C.TAB
bne .9
ldy #1
lda (pStack),y hObj
jsr OBJ.FindActive
bcs .9
>PUSHA hActive
phy index
ldy #2
lda (pStack),y hObj
>SYSCALL2 GetMemPtr
>STYA ZPPtr1
.10 ply
.1 iny
cpy #S.OBJ
bne .2
ldy #S.OBJ.Childs
.2 lda (ZPPtr1),y
beq .1
cmp (pStack) same as hActive ?
beq .8
phy
>SYSCALL2 GetMemPtr
>STYA ZPPtr2
ldy #S.OBJ.S
lda (ZPPtr2),y
and #S.OBJ.S.bDisabled
bne .10
ply
lda (ZPPtr1),y
pha
.3 lda (pStack)
jsr OBJ.Deactivate
inc pStack discard old hActive
pla
>PUSHA new hActive
jsr OBJ.Activate2
.8 inc pStack discard hActive
clc
rts
.9 lda #0
sec
rts
*--------------------------------------
CONT.Draw ldy #S.OBJ.InnerW
lda (ZPObjPtr),y
tax
lda #C.SPACE
.1 jsr LB.COut
dex
bne .1
*--------------------------------------
CONT.Activate
*--------------------------------------
CONT.Deactivate
clc
rts
*--------------------------------------
MAN
SAVE usr/src/lib/libtui.s.cont
LOAD usr/src/lib/libtui.s
ASM

351
LIB/LIBTUI.S.CTX.txt Normal file
View File

@ -0,0 +1,351 @@
NEW
AUTO 3,1
.LIST OFF
*--------------------------------------
CTX.Init >LDYA L.SEQ.INIT
jsr CTX.fputs
bcs .99
>LDYAI S.CTX
>SYSCALL2 GetMem
bcs .99
>STYA ZPCtxPtr
txa
>PUSHA hCTX
lda #0
>PUSHA Init Counter
ldy #S.CTX-1
.10 sta (ZPCtxPtr),y
dey
bpl .10
jsr CTX.GetC.Reset
.1 >SLEEP
jsr CTX.GetC
bcs .98
beq .2
jsr CTX.PutC
bcs .98
.2 ldy #S.CTX.W
lda (ZPCtxPtr),y
bne .8
lda (pStack)
dec
sta (pStack)
bne .1
lda #80
ldy #S.CTX.W
sta (ZPCtxPtr),y
lda #24
iny S.CTX.H
sta (ZPCtxPtr),y
.8 inc pStack Discard counter
>PULLA hCTX
clc
.99 rts
.98 pha
inc pStack Discard counter
>PULLA hCTX
>SYSCALL2 FreeMem
pla
sec
rts
*--------------------------------------
CTX.Close >SYSCALL2 FreeMem
>LDYA L.SEQ.CLOSE
jsr CTX.fputs
clc
CTX.Close.RTS rts
*--------------------------------------
CTX.GetC ldx ZPCtxPtr
phx
ldx ZPCtxPtr+1
phx
ldx ZPObjPtr
phx
ldx ZPObjPtr+1
phx
>SYSCALL GetChar
plx
stx ZPObjPtr+1
plx
stx ZPObjPtr
plx
stx ZPCtxPtr+1
plx
stx ZPCtxPtr
bcs CTX.Close.RTS
tax
ldy #S.CTX.bEscMode
lda (ZPCtxPtr),y
beq .20
bmi .40 IAC mode
iny S.CTX.InBufPtr
lda (ZPCtxPtr),y
cpx #'[' CSI ?
bne .12
cmp #S.CTX.InBufPtr
bne .49 buffer not empty...bad SEQ
.12 jsr CTX.GetC.ToBuf
bcs .49 Buffer Full
cpx #'['
beq .18
cpx #64
bcs CTX.GetC.ESCSEQ if CC, not a letter...SEQ is incomplete
.18 lda #0
clc
rts
*--------------------------------------
.20 cpx #C.ESC
bne .30
inc A = $01
bra .31
*--------------------------------------
.30 cpx #IAC
bne .38
dec A = $FF
.31 jsr CTX.GetC.SetMode
lda #0
clc
rts
*--------------------------------------
.38 txa
clc
.39 rts
*--------------------------------------
.40 jsr CTX.GetC.ToBuf
bcs .49 Buffer Full
cpy #S.CTX.InBuf First char...
beq .48
ldy #S.CTX.InBuf
lda (ZPCtxPtr),y
cmp #SB First char is SB ?
bne CTX.GetC.IACSEQ no ...
cpx #SE is SE after SB ..... ?
bne .48
bra CTX.GetC.IACSEQ yes, we have IAC SB .....SE
.49 jsr CTX.GetC.Reset
.48 lda #0
clc
rts
*--------------------------------------
CTX.GetC.ESCSEQ cmp #S.CTX.InBuf+2
bcs .2
ldy #ESC.Out-ESC.In-1
txa
.1 cmp ESC.In,y
beq .7
dey
bpl .1
bra .6
*--------------------------------------
* \e[xxx;yyyR
*--------------------------------------
.2 cpx #'R' Response to cursor position query?
bne .6
lda #S.CTX.InBuf+1 skip ESC [
jsr CTX.GetC.GetCtxEA
>PUSHYA
>PUSHW L.FMT.ESCCSI.R
lda #S.CTX.H
jsr CTX.GetC.GetCtxEA
>PUSHYA
lda #S.CTX.W
jsr CTX.GetC.GetCtxEA
>PUSHYA
>PUSHBI 4 2 pointers
>SYSCALL2 sscanf
.6 ldx #0
bra .8
.7 ldx ESC.Out,y
.8 jsr CTX.GetC.Reset
txa
clc
rts
*--------------------------------------
* IAC SB TN.O.NAWS ww ww hh hh IAC SE
*--------------------------------------
CTX.GetC.IACSEQ ldy #S.CTX.InBuf
lda (ZPCtxPtr),y
cmp #SB
bne .8
iny
lda (ZPCtxPtr),y
cmp #TN.O.NAWS
bne .8
iny
lda (ZPCtxPtr),y
bne .8
iny
lda (ZPCtxPtr),y
cmp #80
bcs .1
lda #80
.1 tax
iny
lda (ZPCtxPtr),y
bne .8
iny
lda (ZPCtxPtr),y
cmp #24
bcs .2
lda #24
.2 ldy #S.CTX.H
sta (ZPCtxPtr),y
dey S.CTX.W
txa
sta (ZPCtxPtr),y
jsr CTX.GetC.Reset
lda #EV.RESIZE
clc
rts
.8 jsr CTX.GetC.Reset
lda #0
clc
rts
*--------------------------------------
CTX.GetC.Reset lda #0
CTX.GetC.SetMode
ldy #S.CTX.bEscMode
sta (ZPCtxPtr),y
iny Y = S.CTX.InBufPtr
tya
sta (ZPCtxPtr),y
rts
*--------------------------------------
CTX.GetC.GetCtxEA
clc
adc ZPCtxPtr
tay
lda ZPCtxPtr+1
adc #0
.9 rts
*--------------------------------------
CTX.GetC.ToBuf ldy #S.CTX.InBufPtr
lda (ZPCtxPtr),y
cmp #S.CTX.EndBuf buffer full
bcs .9
phy
inc
tay
txa
sta (ZPCtxPtr),y
tya
ply
sta (ZPCtxPtr),y
* clc
.9 rts
*--------------------------------------
CTX.PutC ldx ZPCtxPtr
phx
ldx ZPCtxPtr+1
phx
ldx ZPObjPtr
phx
ldx ZPObjPtr+1
phx
>SYSCALL PutChar
plx
stx ZPObjPtr+1
plx
stx ZPObjPtr
plx
stx ZPCtxPtr+1
plx
stx ZPCtxPtr
rts
*--------------------------------------
CTX.fputs dec pStack
>PUSHYA
ldy #S.PS.hStdOut
lda (pPS),y
ldy #2
sta (pStack),y
>SYSCALL fputs
rts
*--------------------------------------
MAN
SAVE usr/src/lib/libtui.s.ctx
LOAD usr/src/lib/libtui.s
ASM

63
LIB/LIBTUI.S.DLG.txt Normal file
View File

@ -0,0 +1,63 @@
NEW
AUTO 3,1
.LIST OFF
*--------------------------------------
* DLG.New hParent,W,H,pTitle 5
*--------------------------------------
DLG.New jsr OBJ.Create A = Class
bcs .9
ldy #S.OBJ.pTitle
jsr OBJ.PullWordY
jsr OBJ.PullHW
lda #S.OBJ.F.bTitle+S.OBJ.F.bHBorder+S.OBJ.F.bVBorder
ldy #S.OBJ.F
sta (ZPObjPtr),y
>PULLA
ldy #S.OBJ.hParent
sta (ZPObjPtr),y
>SYSCALL2 GetMemPtr
>STYA ZPPtr2
ldy #S.CTX.W
lda (ZPPtr2),y
sec
ldy #S.OBJ.W
sbc (ZPObjPtr),y
lsr
ldy #S.OBJ.X1
sta (ZPObjPtr),y
ldy #S.CTX.H
lda (ZPPtr2),y
sec
ldy #S.OBJ.H
sbc (ZPObjPtr),y
lsr
ldy #S.OBJ.Y1
sta (ZPObjPtr),y
jmp OBJ.SetX2Y2
.9 >POP 5
rts
*--------------------------------------
DLG.Destroy clc
rts
*--------------------------------------
DLG.Run .EQ CONT.Run
*--------------------------------------
DLG.Draw .EQ CONT.Draw
*--------------------------------------
DLG.Activate .EQ CONT.Activate
*--------------------------------------
DLG.Deactivate .EQ CONT.Deactivate
*--------------------------------------
MAN
SAVE usr/src/lib/libtui.s.dlg
LOAD usr/src/lib/libtui.s
ASM

59
LIB/LIBTUI.S.LABEL.txt Normal file
View File

@ -0,0 +1,59 @@
NEW
AUTO 3,1
.LIST OFF
*--------------------------------------
* LABEL.New hParent,X1,Y1,pLabel 5
*--------------------------------------
LABEL.New jsr OBJ.Create A = Class
bcs .9
ldy #S.OBJ.S
lda #S.OBJ.S.bDisabled
sta (ZPObjPtr),y
ldy #S.LABEL.pLabel
jsr OBJ.PullWordY
ldy #S.OBJ.H
lda #1
sta (ZPObjPtr),y
jsr OBJ.PullY1X1hParent
jmp OBJ.Insert
.9 >POP 5
rts
*--------------------------------------
LABEL.Draw ldy #S.LABEL.pLabel
lda (ZPObjPtr),y
sta ZPPtr1
iny
lda (ZPObjPtr),y
sta ZPPtr1+1
ldy #0
.1 lda (ZPPtr1),y
beq .8
jsr LB.COut
iny
bne .1
.8
*--------------------------------------
LABEL.Destroy
*--------------------------------------
LABEL.Run
*--------------------------------------
LABEL.Activate
*--------------------------------------
LABEL.Deactivate
clc
rts
*--------------------------------------
MAN
SAVE usr/src/lib/libtui.s.label
LOAD usr/src/lib/libtui.s
ASM

154
LIB/LIBTUI.S.LB.txt Normal file
View File

@ -0,0 +1,154 @@
NEW
AUTO 3,1
.LIST OFF
*--------------------------------------
LB.Init >LDYA LineBuf
>STYA ZPLineBufPtr
stz ZPLineBufCnt
stz ZPLineBufCnt+1
rts
*--------------------------------------
LB.SeqOut lda SEQS,x
beq .8
jsr LB.COut
inx
bra LB.SeqOut
.8 rts
*--------------------------------------
LB.GotoXY >PUSHW ZPLineBufPtr
>PUSHW L.SEQ.GOTOXY
tya
inc
>PUSHA
txa
inc
>PUSHA
>PUSHBI 2
jmp LB.PrintF
*--------------------------------------
LB.SetColor >PUSHW ZPLineBufPtr
>PUSHW L.SEQ.COLOR
lda (ZPObjPtr)
tax
>PUSHB OBJ.COLORS,x
lda OBJ.COLORS+1,x
bne .7
ldy #S.OBJ.hParent
lda (ZPObjPtr),y
beq .7
>SYSCALL2 GetMemPtr
>STYA ZPPtr1
lda (ZPPtr1)
tax
lda OBJ.COLORS+1,x
.7 >PUSHA
>PUSHBI 2
jmp LB.PrintF
*--------------------------------------
LB.YAOut ldx #0
*--------------------------------------
LB.YAOutX >STYA ZPPtr1 X = MaxLen
ldy #$ff
.1 iny
lda (ZPPtr1),y
beq .8
jsr LB.COut
dex
bne .1
.8 rts
*--------------------------------------
LB.PrintF >SYSCALL2 SPrintF
tya
clc
adc ZPLineBufPtr
sta ZPLineBufPtr
bcc .1
inc ZPLineBufPtr+1
clc
.1 tya
adc ZPLineBufCnt
sta ZPLineBufCnt
bcc .8
inc ZPLineBufCnt+1
clc
.8 rts
*--------------------------------------
LB.HexOut pha
lsr
lsr
lsr
lsr
jsr .1
pla
and #$0F
.1 ora #$30
cmp #'9'+1
bcc LB.COut
adc #6
*--------------------------------------
LB.COut sta (ZPLineBufPtr)
inc ZPLineBufPtr
bne .1
inc ZPLineBufPtr+1
.1 inc ZPLineBufCnt
bne .8
inc ZPLineBufCnt+1
.8 rts
*--------------------------------------
LB.Out ldx ZPCtxPtr
phx
ldx ZPCtxPtr+1
phx
ldx ZPObjPtr
phx
ldx ZPObjPtr+1
phx
ldy #S.PS.hStdOut
lda (pPS),y
>PUSHA
>PUSHW LineBuf
>PUSHW ZPLineBufCnt
>SYSCALL fwrite
plx
stx ZPObjPtr+1
plx
stx ZPObjPtr
plx
stx ZPCtxPtr+1
plx
stx ZPCtxPtr
rts
*--------------------------------------
MAN
SAVE usr/src/lib/libtui.s.lb
LOAD usr/src/lib/libtui.s
ASM

View File

@ -2,39 +2,114 @@ NEW
AUTO 3,1
.LIST OFF
*--------------------------------------
LBOX.New
clc
* LBOX.New hParent,X1,Y1,W,H,F,pList,pVar 10
*--------------------------------------
LBOX.New jsr OBJ.Create A = Class
bcs .9
ldy #S.LBOX.pVar
jsr OBJ.PullWordY
ldy #S.LBOX.pList
jsr OBJ.PullWordY
>PULLA
ldy #S.OBJ.F
sta (ZPObjPtr),y
jsr OBJ.PullHW
jsr OBJ.PullY1X1hParent
jmp OBJ.Insert
.9 >POP 10
rts
*--------------------------------------
LBOX.Destroy
clc
rts
*--------------------------------------
LBOX.Run lda (pStack) Event
LBOX.Run ldy #S.OBJ.S
lda (ZPObjPtr),y
bpl .9
lda (pStack) Event
cmp #C.LF
bne .5
bne .2
ldy #S.LBOX.Idx
lda (ZPObjPtr),y
inc
tax
ldy #S.LBOX.pList
jsr OBJ.GetLineXAtY
bcs .8
ldy #S.LBOX.Idx
lda (ZPObjPtr),y
inc
sta (ZPObjPtr),y
clc
rts
ldy #S.LBOX.VScroll
adc (ZPObjPtr),y
ldy #S.OBJ.InnerH
cmp (ZPObjPtr),y
bcc .7
.5 cmp #C.VT
ldy #S.LBOX.VScroll
lda (ZPObjPtr),y
inc
sta (ZPObjPtr),y
bra .7
.2 cmp #C.VT
bne .9
ldy #S.LBOX.Idx
lda (ZPObjPtr),y
beq .8
clc
dec
sta (ZPObjPtr),y
ldy #S.LBOX.VScroll
cmp (ZPObjPtr),y
bcs .7
ldy #S.LBOX.VScroll
lda (ZPObjPtr),y
dec
sta (ZPObjPtr),y
.7 ldy #1 hObj
lda (pStack),y
>PUSHA
jsr OBJ.Draw.Body
inc pStack
rts
.9 sec
.8 clc
rts
.9 lda #0
sec
rts
*--------------------------------------
LBOX.Draw ldy #S.LBOX.VScroll
lda (ZPObjPtr),y
clc
adc (pStack) Relative Y
tax
jsr LBOX.GetLineX
ldy #S.LBOX.pList
jsr OBJ.GetLineXAtY
bcs .5
txa
@ -42,8 +117,12 @@ LBOX.Draw ldy #S.LBOX.VScroll
cmp (ZPObjPtr),y
bne .1
ldy #S.OBJ.S
lda (ZPObjPtr),y S.OBJ.S.bActive
bpl .1
ldx #SEQ.INVERSE-SEQS
jsr LIB.LineBufSeqOut
jsr LB.SeqOut
.1 ldy #S.OBJ.InnerW
lda (ZPObjPtr),y
@ -54,7 +133,7 @@ LBOX.Draw ldy #S.LBOX.VScroll
.2 lda (ZPPtr1),y
beq .3
jsr LIB.LineBufCOut
jsr LB.COut
iny
dex
bne .2
@ -71,57 +150,16 @@ LBOX.Draw ldy #S.LBOX.VScroll
.6 lda #C.SPACE
.7 jsr LIB.LineBufCOut
.7 jsr LB.COut
dex
bne .7
.8 clc
rts
*--------------------------------------
LBOX.GetLineX stz TempI
ldy #S.LBOX.pL
lda (ZPObjPtr),y
sta ZPPtr1
iny
lda (ZPObjPtr),y
sta ZPPtr1+1
.1 cpx TempI
beq .8
.2 inc TempI
ldy #$ff
.4 iny
lda (ZPPtr1),y
bne .4
tya
beq .9
sec
adc ZPPtr1
sta ZPPtr1
bcc .1
inc ZPPtr1+1
bra .1
.8 clc
rts
.9 sec
rts
*--------------------------------------
LBOX.Activate
clc
rts
*--------------------------------------
LBOX.Deactivate
clc
rts
jmp OBJ.Draw.Body
*--------------------------------------
MAN
SAVE usr/src/lib/libtui.s.lbox

View File

@ -2,88 +2,248 @@ NEW
AUTO 3,1
.LIST OFF
*--------------------------------------
OBJ.New >PULLW ZPPtr1 Params
>PULLB TempW hParent
>SYSCALL2 GetMemPtr
>STYA ZPPtr2
ldy #S.OBJ.Childs
.10 lda (ZPPtr2),y
beq .11
iny
cpy #S.OBJ
bcc .10
lda #E.OOH
* sec
rts
.11 sty TempW+1
lda (ZPPtr1) S.OBJ.T
OBJ.New tax
jmp (J.ObjNew,x)
*--------------------------------------
OBJ.Create pha Type
tax
ldy OBJ.SIZES,x
lda #0
>SYSCALL2 GetMem
bcs .9
>STYA ZPObjPtr
stx hObj
phx
ldy #0
.1 lda (ZPPtr1),y
sta (ZPObjPtr),y
iny
cpy #S.OBJ.H+1
bne .1
lda (ZPPtr1) S.OBJ.T
pla
sta (ZPObjPtr)
tax
ldy OBJ.SIZES,x
lda #0
.2 dey
sta (ZPObjPtr),y
cpy #S.OBJ.pTITLE
bne .2
lda TempW
ldy #S.OBJ.P
sta (ZPObjPtr),y
>LDYA ZPObjPtr
jsr LIB.SetObjX2Y2
pla
ldy TempW+1
sta (ZPPtr2),y
pha
jsr .7
bcs .99
pla
dey
.1 sta (ZPObjPtr),y
dey
bne .1
lda hObj
* clc
rts
.7 lda (ZPObjPtr) S.OBJ.T
.9 plx
rts
*--------------------------------------
OBJ.PullWordY >PULLA
sta (ZPObjPtr),y
tax
jmp (J.ObjNew,x)
iny
>PULLA
sta (ZPObjPtr),y
.99 plx
rts
*--------------------------------------
OBJ.PullHW ldy #S.OBJ.H
>PULLA
sta (ZPObjPtr),y
.9 rts
dey
>PULLA
sta (ZPObjPtr),y
rts
*--------------------------------------
OBJ.PullY1X1hParent
>PULLA
ldy #S.OBJ.Y1
sta (ZPObjPtr),y
dey S.OBJ.X1
>PULLA
sta (ZPObjPtr),y
dey S.OBJ.hParent
>PULLA
sta (ZPObjPtr),y
rts
*--------------------------------------
OBJ.Insert >SYSCALL2 GetMemPtr A = hParent
>STYA ZPPtr2
ldy #S.OBJ.Childs
.1 lda (ZPPtr2),y
beq .2
iny
cpy #S.OBJ
bcc .1
lda #E.OOH
* sec
rts
.2 lda hObj
sta (ZPPtr2),y
ldy #S.OBJ.InnerX
lda (ZPPtr2),y
ldy #S.OBJ.X1
clc
adc (ZPObjPtr),y
sta (ZPObjPtr),y
ldy #S.OBJ.InnerY
lda (ZPPtr2),y
ldy #S.OBJ.Y1
clc
adc (ZPObjPtr),y
sta (ZPObjPtr),y
*--------------------------------------
OBJ.SetX2Y2 ldy #S.OBJ.X1
jsr .7
ldy #S.OBJ.Y1
jsr .7
ldy #S.OBJ.F
lda (ZPObjPtr),y
and #S.OBJ.F.bHBorder
beq .1
ldy #S.OBJ.InnerX
lda (ZPObjPtr),y
inc
sta (ZPObjPtr),y
iny
iny
lda (ZPObjPtr),y S.OBJ.InnerW
dec
dec
sta (ZPObjPtr),y
.1 ldx #0
ldy #S.OBJ.F
lda (ZPObjPtr),y
bit #S.OBJ.F.bVBorder+S.OBJ.F.bTITLE
beq .2
dex
.2 bit #S.OBJ.F.bVBorder+S.OBJ.F.bSTATUS
beq .3
dex
.3 txa
beq .4
ldy #S.OBJ.InnerY
lda (ZPObjPtr),y
inc
sta (ZPObjPtr),y
txa
iny
iny
clc
adc (ZPObjPtr),y S.OBJ.InnerH
sta (ZPObjPtr),y
.4 ldy #S.OBJ.F
lda (ZPObjPtr),y
bit #S.OBJ.F.bMENU
beq .8
ldy #S.OBJ.InnerY
lda (ZPObjPtr),y
inc
sta (ZPObjPtr),y
iny
iny
lda (ZPObjPtr),y S.OBJ.InnerH
dec
sta (ZPObjPtr),y
.8 lda hOBJ
clc
rts
*--------------------------------------
.7 lda (ZPObjPtr),y S.OBJ.X1/Y1
tax
iny
iny S.OBJ.W/H
phy
clc
adc (ZPObjPtr),y
dec
iny
iny S.OBJ.X2/Y2
sta (ZPObjPtr),y
iny
iny
txa
sta (ZPObjPtr),y S.OBJ.InnerX/Y
ply S.OBJ.W/H
lda (ZPObjPtr),y
iny
iny
iny
iny
iny
iny
sta (ZPObjPtr),y S.OBJ.InnerW/H
rts
*--------------------------------------
OBJ.Exec >PUSHA hOBJ
jsr LIB.GetOBJ
ldy #S.OBJ.hParent
lda (ZPObjPtr),y
jsr LIB.GetCTX
.1 jsr CTX.GetC
bcs .9
cmp #EV.RESIZE
clc
beq .99
tay
beq .1
>PUSHA
jsr OBJ.Run
inc pStack
tay
beq .1 no event, no error
.9 inc pStack
.99 rts
*--------------------------------------
OBJ.Destroy ldx ZPObjPtr
phx
@ -91,7 +251,7 @@ OBJ.Destroy ldx ZPObjPtr
phx
pha
jsr LIB.GetObj
jsr LIB.GetOBJ
ldy #S.OBJ.Childs
@ -108,7 +268,7 @@ OBJ.Destroy ldx ZPObjPtr
pla
pha
jsr LIB.GetObj
jsr LIB.GetOBJ
jsr .7
@ -133,12 +293,13 @@ OBJ.Run ldx ZPObjPtr
ldy #1
lda (pStack),y
jsr LIB.GetObj
jsr LIB.GetOBJ
ldy #S.OBJ.S
lda (ZPObjPtr),y
bpl .9 S.OBJ.S.bACTIVE
and #S.OBJ.S.bDisabled
bne .9
ldy #1
lda (pStack),y hOBJ
>PUSHA
@ -146,6 +307,12 @@ OBJ.Run ldx ZPObjPtr
>PUSHA
jsr .80
inc pStack
inc pStack
tax
bne .8 error / event
bcc .8
ldy #S.OBJ.Childs
@ -154,6 +321,7 @@ OBJ.Run ldx ZPObjPtr
beq .5
phy
>PUSHA hChild
ldy #1
lda (pStack),y Event
@ -162,13 +330,20 @@ OBJ.Run ldx ZPObjPtr
ply
inc pStack
inc pStack
bcc .8
tax
bne .8
.5 iny
cpy #S.OBJ
bne .1
.9 sec
lda #0
.8 plx
stx ZPObjPtr+1
@ -197,7 +372,7 @@ OBJ.Draw >PUSHA hObj
.6 ldy #1
lda (pStack),y
jsr LIB.GetObj
jsr LIB.GetOBJ
lda (pStack)
tay
@ -222,7 +397,7 @@ OBJ.Draw >PUSHA hObj
OBJ.Draw.RTS rts
*--------------------------------------
OBJ.Draw.Top lda (pStack)
jsr LIB.GetObj
jsr LIB.GetOBJ
ldy #S.OBJ.F
lda (ZPObjPtr),y
@ -230,7 +405,7 @@ OBJ.Draw.Top lda (pStack)
* clc
beq OBJ.Draw.RTS
jsr LIB.LineBufInit
jsr LB.Init
ldy #S.OBJ.X1
lda (ZPObjPtr),y
@ -238,25 +413,24 @@ OBJ.Draw.Top lda (pStack)
ldy #S.OBJ.Y1
lda (ZPObjPtr),y
tay
jsr LIB.GotoXY
jsr LB.GotoXY
ldy #S.OBJ.F
lda (ZPObjPtr),y
and #S.OBJ.F.bVBorder
beq .1
lda (ZPObjPtr)
jsr LIB.SetColor
jsr LB.SetColor
ldx #SEQ.BORDERTL-SEQS
jsr LIB.LineBufSeqOut
jsr LB.SeqOut
.1 ldy #S.OBJ.F
lda (ZPObjPtr),y
bpl .4
bpl .4 S.OBJ.F.bTITLE
ldx #SEQ.BAR-SEQS
jsr LIB.LineBufSeqOut
jsr LB.SeqOut
ldy #S.OBJ.InnerW
lda (ZPObjPtr),y
@ -271,14 +445,14 @@ OBJ.Draw.Top lda (pStack)
beq .3
lda #C.SI
jsr LIB.LineBufCOut
jsr LB.COut
ldy #0
.2 lda (ZPPtr1),y
beq .3
jsr LIB.LineBufCOut
jsr LB.COut
iny
dex
bne .2
@ -288,12 +462,12 @@ OBJ.Draw.Top lda (pStack)
lda #C.SPACE
.30 jsr LIB.LineBufCOut
.30 jsr LB.COut
dex
bne .30
.31 ldx #SEQ.BAREND-SEQS
jsr LIB.LineBufSeqOut
jsr LB.SeqOut
bra .6
.4 ldy #S.OBJ.InnerW
@ -302,7 +476,7 @@ OBJ.Draw.Top lda (pStack)
lda #'q'
.5 jsr LIB.LineBufCOut
.5 jsr LB.COut
dex
bne .5
@ -311,20 +485,21 @@ OBJ.Draw.Top lda (pStack)
and #S.OBJ.F.bVBorder
beq .7
lda (ZPObjPtr)
jsr LIB.SetColor
jsr LB.SetColor
ldx #SEQ.BORDERTR-SEQS
jsr LIB.LineBufSeqOut
jsr LB.SeqOut
.7 jmp LIB.LineBufOut
.7 jmp LB.Out
*--------------------------------------
OBJ.Draw.Body lda (pStack)
jsr LIB.GetObj
jsr LIB.GetOBJ
jsr OBJ.CurOff
ldy #S.OBJ.InnerY
lda (ZPObjPtr),y
>PUSHA
>PUSHA Start
ldy #S.OBJ.InnerH
lda (ZPObjPtr),y
@ -332,11 +507,7 @@ OBJ.Draw.Body lda (pStack)
>PUSHBI 0 Relative Y
.1 jsr LIB.LineBufInit
ldy #3 hObj
lda (pStack),y
jsr LIB.GetObj
.1 jsr LB.Init
ldy #S.OBJ.X1
lda (ZPObjPtr),y
@ -345,10 +516,9 @@ OBJ.Draw.Body lda (pStack)
ldy #2 InnerY
lda (pStack),y
tay
jsr LIB.GotoXY
jsr LB.GotoXY
lda (ZPObjPtr)
jsr LIB.SetColor
jsr LB.SetColor
ldy #S.OBJ.F
lda (ZPObjPtr),y
@ -357,12 +527,12 @@ OBJ.Draw.Body lda (pStack)
beq .2
ldx #SEQ.BORDERV-SEQS
jsr LIB.LineBufSeqOut
jsr LB.SeqOut
.2 jsr OBJ.Draw.Body.JMP
ldx #SEQ.NORMAL-SEQS
jsr LIB.LineBufSeqOut
jsr LB.SeqOut
plp
beq .4
@ -374,15 +544,14 @@ OBJ.Draw.Body lda (pStack)
ldy #2 InnerY
lda (pStack),y
tay
jsr LIB.GotoXY
jsr LB.GotoXY
lda (ZPObjPtr)
jsr LIB.SetColor
jsr LB.SetColor
ldx #SEQ.BORDERV-SEQS
jsr LIB.LineBufSeqOut
jsr LB.SeqOut
.4 jsr LIB.LineBufOut
.4 jsr LB.Out
bcs .9
lda (pStack) Relative Y
@ -401,7 +570,7 @@ OBJ.Draw.Body lda (pStack)
sta (pStack),y
bne .1
* clc
jsr OBJ.CurOn
.9 >POP 3
@ -414,7 +583,7 @@ OBJ.Draw.Body.JMP
jmp (J.ObjDraw,x)
*--------------------------------------
OBJ.Draw.Bottom lda (pStack)
jsr LIB.GetObj
jsr LIB.GetOBJ
ldy #S.OBJ.F
lda (ZPObjPtr),y
@ -422,7 +591,7 @@ OBJ.Draw.Bottom lda (pStack)
* clc
beq OBJ.Draw.Body.RTS
jsr LIB.LineBufInit
jsr LB.Init
ldy #S.OBJ.X1
lda (ZPObjPtr),y
@ -430,18 +599,17 @@ OBJ.Draw.Bottom lda (pStack)
ldy #S.OBJ.Y2
lda (ZPObjPtr),y
tay
jsr LIB.GotoXY
jsr LB.GotoXY
ldy #S.OBJ.F
lda (ZPObjPtr),y
and #S.OBJ.F.bVBorder
beq .1
lda (ZPObjPtr)
jsr LIB.SetColor
jsr LB.SetColor
ldx #SEQ.BORDERBL-SEQS
jsr LIB.LineBufSeqOut
jsr LB.SeqOut
.1 ldy #S.OBJ.F
lda (ZPObjPtr),y
@ -449,7 +617,7 @@ OBJ.Draw.Bottom lda (pStack)
beq .4
ldx #SEQ.BAR-SEQS
jsr LIB.LineBufSeqOut
jsr LB.SeqOut
ldy #S.OBJ.InnerW
lda (ZPObjPtr),y
@ -464,14 +632,14 @@ OBJ.Draw.Bottom lda (pStack)
beq .3
lda #C.SI
jsr LIB.LineBufCOut
jsr LB.COut
ldy #0
.2 lda (ZPPtr1),y
beq .3
jsr LIB.LineBufCOut
jsr LB.COut
iny
dex
bne .2
@ -481,12 +649,12 @@ OBJ.Draw.Bottom lda (pStack)
lda #C.SPACE
.30 jsr LIB.LineBufCOut
.30 jsr LB.COut
dex
bne .30
.31 ldx #SEQ.BAREND-SEQS
jsr LIB.LineBufSeqOut
jsr LB.SeqOut
bra .6
.4 ldy #S.OBJ.InnerW
@ -495,7 +663,7 @@ OBJ.Draw.Bottom lda (pStack)
lda #'q'
.5 jsr LIB.LineBufCOut
.5 jsr LB.COut
dex
bne .5
@ -504,17 +672,16 @@ OBJ.Draw.Bottom lda (pStack)
and #S.OBJ.F.bVBorder
beq .7
lda (ZPObjPtr)
jsr LIB.SetColor
jsr LB.SetColor
ldx #SEQ.BORDERBR-SEQS
jsr LIB.LineBufSeqOut
jsr LB.SeqOut
.7 jmp LIB.LineBufOut
.7 jmp LB.Out
*--------------------------------------
OBJ.GetProp ldy #1 hObj
lda (pStack),y
jsr LIB.GetObj
jsr LIB.GetOBJ
>PULLA
tay prop
@ -531,7 +698,7 @@ OBJ.GetProp ldy #1 hObj
*--------------------------------------
OBJ.SetProp ldy #3 hObj
lda (pStack),y
jsr LIB.GetObj
jsr LIB.GetOBJ
ldy #2
lda (pStack),y
@ -548,37 +715,220 @@ OBJ.SetProp ldy #3 hObj
* clc
rts
*--------------------------------------
OBJ.Activate pha
jsr LIB.FindActive
OBJ.Activate >PUSHA hObj
jsr OBJ.FindActive
bcs .1
jsr OBJ.Deactivate
>PUSHA hObj
.1 pla
jsr OBJ.Deactivate
inc pStack
.1 lda (pStack)
jsr OBJ.Activate2
inc pStack
clc
rts
*--------------------------------------
OBJ.Activate2 jsr LIB.GetObj
OBJ.Activate2 jsr LIB.GetOBJ
ldy #S.OBJ.S
lda (ZPObjPtr),y
ora #S.OBJ.S.bACTIVE
ora #S.OBJ.S.bActive
sta (ZPObjPtr),y
lda (ZPObjPtr)
jsr .1
jmp OBJ.CurOn
.1 lda (ZPObjPtr)
tax
jmp (J.ObjActivate,x)
*--------------------------------------
OBJ.Deactivate jsr LIB.GetObj
OBJ.Deactivate jsr LIB.GetOBJ
jsr OBJ.CurOff
ldy #S.OBJ.S
lda (ZPObjPtr),y
and #S.OBJ.S.bACTIVE^$ff
and #S.OBJ.S.bActive^$ff
sta (ZPObjPtr),y
lda (ZPObjPtr)
tax
jmp (J.ObjDeactivate,x)
*--------------------------------------
OBJ.FindActive ldx ZPObjPtr
phx
ldx ZPObjPtr+1
phx
jsr LIB.GetOBJ
ldy #S.OBJ.Childs
.1 phy
lda (ZPObjPtr),y
beq .7
pha
>SYSCALL2 GetMemPtr
>STYA ZPPtr1
ldy #S.OBJ.S
lda (ZPPtr1),y S.OBJ.S.bActive
bmi .8
pla
.7 ply
iny
cpy #S.OBJ
bne .1
* sec
bra .80
.8 pla
ply
clc
.80 plx
stx ZPObjPtr+1
plx
stx ZPObjPtr
rts
*--------------------------------------
OBJ.CurOn ldy #S.OBJ.F
lda (ZPObjPtr),y
and #S.OBJ.F.bCursor
beq .8
ldy #S.OBJ.S
lda (ZPObjPtr),y S.OBJ.S.bActive
bpl .8
bit #S.OBJ.S.bCurOn
bne .8
ora #S.OBJ.S.bCurOn
sta (ZPObjPtr),y
jsr LB.Init
ldy #S.OBJ.InnerX
lda (ZPObjPtr),y
clc
ldy #S.OBJ.CurX
adc (ZPObjPtr),y
tax
ldy #S.OBJ.InnerY
lda (ZPObjPtr),y
clc
ldy #S.OBJ.CurY
adc (ZPObjPtr),y
tay
jsr LB.GotoXY
ldx #SEQ.CURON-SEQS
jsr LB.SeqOut
jsr LB.Out
.8 lda #0
clc
rts
*--------------------------------------
OBJ.CurOff ldy #S.OBJ.F
lda (ZPObjPtr),y
and #S.OBJ.F.bCursor
beq .8
ldy #S.OBJ.S
lda (ZPObjPtr),y S.OBJ.S.bActive
bpl .8
bit #S.OBJ.S.bCurOn
beq .8
eor #S.OBJ.S.bCurOn
sta (ZPObjPtr),y
jsr LB.Init
ldx #SEQ.CUROFF-SEQS
jsr LB.SeqOut
jmp LB.Out
.8 lda #0
clc
rts
*--------------------------------------
OBJ.IncWordAtY lda (ZPObjPtr),y
inc
sta (ZPObjPtr),y
bne .8
iny
lda (ZPObjPtr),y
inc
sta (ZPObjPtr),y
.8 rts
*--------------------------------------
OBJ.DecWordAtY clc
lda (ZPObjPtr),y
sbc #0
sta (ZPObjPtr),y
iny
lda (ZPObjPtr),y
sbc #0
sta (ZPObjPtr),y
rts
*--------------------------------------
OBJ.GetLineXAtY lda (ZPObjPtr),y
sta ZPPtr1
iny
lda (ZPObjPtr),y
sta ZPPtr1+1
stz TempI
.1 lda (ZPPtr1)
beq .9
cpx TempI
beq .8
.2 inc TempI
ldy #$ff
.4 iny
lda (ZPPtr1),y
bne .4
tya
sec
adc ZPPtr1
sta ZPPtr1
bcc .1
inc ZPPtr1+1
bra .1
.8 clc
rts
.9 sec
rts
*--------------------------------------
MAN
SAVE usr/src/lib/libtui.s.obj
LOAD usr/src/lib/libtui.s

251
LIB/LIBTUI.S.RADIO.txt Normal file
View File

@ -0,0 +1,251 @@
NEW
AUTO 3,1
.LIST OFF
*--------------------------------------
* RADIO.New hParent,X1,Y1,HK,EV,pList,pVar 9
*--------------------------------------
RADIO.New jsr OBJ.Create A = Class
bcs .9
ldy #S.RADIO.pVar
jsr OBJ.PullWordY
ldy #S.RADIO.pList
jsr OBJ.PullWordY
stx ZPPtr1
sta ZPPtr1+1
>PULLA
ldy #S.RADIO.EV
sta (ZPObjPtr),y
>PULLA
ldy #S.RADIO.HotKey
sta (ZPObjPtr),y
ldx #0
.1 ldy #$ff
.2 iny
lda (ZPPtr1),y
bne .2
tya
sec
adc ZPPtr1
sta ZPPtr1
bcc .3
inc ZPPtr1+1
.3 tya
inc
inc
inc
inc
inc
ldy #S.OBJ.W
cmp (ZPObjPtr),y
bcc .4
sta (ZPObjPtr),y
.4 inx
lda (ZPPtr1)
bne .1
ldy #S.OBJ.H
txa
sta (ZPObjPtr),y
jsr OBJ.PullY1X1hParent
jmp OBJ.Insert
.9 >POP 9
rts
*--------------------------------------
RADIO.Destroy clc
rts
*--------------------------------------
RADIO.Run ldy #S.OBJ.S
lda (ZPObjPtr),y
bpl .9
lda (pStack) Event
cmp #C.SPACE
bne .2
ldy #S.RADIO.pVar
lda (ZPObjPtr),y
sta ZPPtr1
iny
lda (ZPObjPtr),y
sta ZPPtr1+1
ldy #S.RADIO.Idx
lda (ZPObjPtr),y
sta (ZPPtr1)
bra .7
.2 cmp #C.LF
bne .5
ldy #S.RADIO.Idx
lda (ZPObjPtr),y
inc
ldy #S.OBJ.InnerH
cmp (ZPObjPtr),y
bne .3
lda #0
.3 ldy #S.RADIO.Idx
sta (ZPObjPtr),y
bra .7
.5 cmp #C.VT
bne .9
ldy #S.RADIO.Idx
lda (ZPObjPtr),y
bne .6
ldy #S.OBJ.InnerH
lda (ZPObjPtr),y
.6 dec
ldy #S.RADIO.Idx
sta (ZPObjPtr),y
.7 ldy #1 hObj
lda (pStack),y
>PUSHA
jsr OBJ.Draw.Body
inc pStack
.8 clc
rts
.9 lda #0
sec
rts
*--------------------------------------
RADIO.Draw lda (pStack) Relative Y
tax
ldy #S.RADIO.pList
jsr OBJ.GetLineXAtY
bcs .8
ldy #S.RADIO.pVar
lda (ZPObjPtr),y
sta ZPPtr2
iny
lda (ZPObjPtr),y
sta ZPPtr2+1
clc
ldx #'('
ldy #S.OBJ.S
lda (ZPObjPtr),y
bpl .10
ldy #S.RADIO.Idx
lda (ZPObjPtr),y
eor (pStack) Relative Y
bne .10
ldx #'['
sec
.10 php
txa
jsr LB.COut
lda (pStack)
cmp (ZPPtr2)
bne .11
lda #C.SO
jsr LB.COut
lda #'`'
jsr LB.COut
lda #C.SI
bra .13
.11 lda #C.SPACE
.13 jsr LB.COut
ldx #')'
plp
bcc .12
ldx #']'
.12 txa
jsr LB.COut
lda #C.SPACE
jsr LB.COut
.1 ldy #S.OBJ.InnerW
lda (ZPObjPtr),y
tax
dex
dex
dex
dex
ldy #0
.2 lda (ZPPtr1),y
beq .3
jsr LB.COut
iny
dex
bne .2
.3 txa
beq .8
bra .6
.5 ldy #S.OBJ.InnerW
lda (ZPObjPtr),y
tax
.6 lda #C.SPACE
.7 jsr LB.COut
dex
bne .7
.8 clc
rts
*--------------------------------------
RADIO.Activate
*--------------------------------------
RADIO.Deactivate
jmp OBJ.Draw.Body
*--------------------------------------
MAN
SAVE usr/src/lib/libtui.s.radio
LOAD usr/src/lib/libtui.s
ASM

View File

@ -2,79 +2,47 @@ NEW
AUTO 3,1
.LIST OFF
*--------------------------------------
SCRN.New
clc
rts
* SCRN.New hCTX,F 2
*--------------------------------------
SCRN.Destroy
clc
rts
*--------------------------------------
SCRN.Run lda (pStack) Event
cmp #C.TAB
bne .9
ldy #1
lda (pStack),y hObj
jsr LIB.FindActive
SCRN.New jsr OBJ.Create A = Class
bcs .9
>PUSHA hActive
phy index
ldy #2
lda (pStack),y hObj
>PULLA
ldy #S.OBJ.F
sta (ZPObjPtr),y
>PULLA
ldy #S.OBJ.hParent
sta (ZPObjPtr),y
>SYSCALL2 GetMemPtr
>STYA ZPPtr1
ply
>STYA ZPPtr2
.1 iny
cpy #S.OBJ
bne .2
ldy #S.OBJ.Childs
ldy #S.CTX.W
lda (ZPPtr2),y
ldy #S.OBJ.W
sta (ZPObjPtr),y
.2 lda (ZPPtr1),y
beq .1
ldy #S.CTX.H
lda (ZPPtr2),y
ldy #S.OBJ.H
sta (ZPObjPtr),y
cmp (pStack)
beq .8
jmp OBJ.SetX2Y2
jsr OBJ.Activate2
lda (pStack)
jsr OBJ.Deactivate
.8 inc pStack discard hActive
clc
rts
.9 sec
.9 >POP 2
rts
*--------------------------------------
SCRN.Draw ldy #S.OBJ.InnerW
lda (ZPObjPtr),y
tax
lda #C.SPACE
.1 jsr LIB.LineBufCOut
dex
bne .1
clc
SCRN.Destroy clc
rts
*--------------------------------------
SCRN.Activate
clc
rts
SCRN.Run .EQ CONT.Run
*--------------------------------------
SCRN.Deactivate
clc
rts
SCRN.Draw .EQ CONT.Draw
*--------------------------------------
SCRN.Activate .EQ CONT.Activate
*--------------------------------------
SCRN.Deactivate .EQ CONT.Deactivate
*--------------------------------------
MAN
SAVE usr/src/lib/libtui.s.scrn

View File

@ -2,90 +2,861 @@ NEW
AUTO 3,1
.LIST OFF
*--------------------------------------
TBOX.New >LDYAI 1024
>SYSCALL2 GetMem
* TBOX.New hParent,X1,Y1,W,H,F,hBuf,BufSize 9
*--------------------------------------
TBOX.New jsr OBJ.Create A = Class
bcs .9
>STYA ZPPtr1
txa
ldy #S.TBOX.BufSize
jsr OBJ.PullWordY
>PULLA
ldy #S.TBOX.hBuf
sta (ZPObjPtr),y
lda #0
sta (ZPPtr1)
ldy #S.TBOX.CurX
.1 sta (ZPObjPtr),y
iny
cpy #S.TBOX.DocY+1
bne .1
clc
>PULLA
ora #S.OBJ.F.bCursor
ldy #S.OBJ.F
sta (ZPObjPtr),y
.9 rts
jsr OBJ.PullHW
jsr OBJ.PullY1X1hParent
jmp OBJ.Insert
.9 >POP 9
rts
*--------------------------------------
TBOX.Destroy ldy #S.TBOX.hBuf
TBOX.Destroy clc
rts
*--------------------------------------
TBOX.Run ldy #S.OBJ.S
lda (ZPObjPtr),y
bpl TBOX.RUN.Ignore
lda (pStack) Event
cmp #C.SPACE
bcs .2
asl
tax
jsr .1
bcc TBOX.RUN.7
rts
.1 jmp (J.TBOX.RUN,x)
.2 cmp #C.DEL
bne TBOX.RUN.CR
jsr TBOX.GetBuf
jsr TBOX.Delete1
bra TBOX.RUN.7
*--------------------------------------
TBOX.RUN.Ignore lda #0
sec
rts
*--------------------------------------
TBOX.RUN.CR jsr TBOX.GetBuf
jsr TBOX.ToBuf1
bcs TBOX.RUN.8 Buffer full
jsr TBOX.RUN.FS1
TBOX.RUN.7 ldy #1 hObj
lda (pStack),y
>PUSHA
jsr OBJ.Draw.Body
inc pStack
TBOX.RUN.8 clc
rts
*--------------------------------------
TBOX.RUN.SelBegin
ldy #S.TBOX.BufPtr
lda (ZPObjPtr),y
tax
iny
lda (ZPObjPtr),y
ldy #S.TBOX.SelBegin+1
sta (ZPObjPtr),y
txa
dey
sta (ZPObjPtr),y
bra TBOX.RUN.Sel
*--------------------------------------
TBOX.RUN.SelEnd ldy #S.TBOX.BufPtr
lda (ZPObjPtr),y
tax
iny
lda (ZPObjPtr),y
ldy #S.TBOX.SelEnd+1
sta (ZPObjPtr),y
txa
dey
sta (ZPObjPtr),y
TBOX.RUN.Sel ldy #S.TBOX.SelEnd
lda (ZPObjPtr),y
ldy #S.TBOX.SelBegin
cmp (ZPObjPtr),y
ldy #S.TBOX.SelEnd+1
lda (ZPObjPtr),y
ldy #S.TBOX.SelBegin+1
sbc (ZPObjPtr),y
ldy #S.TBOX.bSelect
lda #0
ror
pha
eor (ZPObjPtr),y
bpl .1
pla
sta (ZPObjPtr),y
jmp TBOX.SetViewPort
.1 pla
clc
rts
*--------------------------------------
TBOX.RUN.BS ldy #S.TBOX.BufPtr+1
lda (ZPObjPtr),y
dey
ora (ZPObjPtr),y
beq .9
jsr OBJ.DecWordAtY
jsr TBOX.GetBuf
lda (ZPPtr2)
cmp #C.CR
beq .1
ldy #S.TBOX.DocX
jsr OBJ.DecWordAtY
jmp TBOX.SetViewPort
.1 ldy #S.TBOX.DocY
jsr OBJ.DecWordAtY
jmp TBOX.RUN.EOL
.9 sec
rts
*--------------------------------------
TBOX.RUN.LF jsr TBOX.GetBuf
jsr TBOX.GetCurlineInAX
inx
bne .1
inc
.1 jsr TBOX.GetLineAX
bcs TBOX.RUN.VT.8
ldy #S.TBOX.DocY
jsr OBJ.IncWordAtY
bra TBOX.RUN.VT1
*--------------------------------------
TBOX.RUN.VT jsr TBOX.GetBuf
ldy #S.TBOX.DocY+1
lda (ZPObjPtr),y
dey
ora (ZPObjPtr),y
beq TBOX.RUN.VT.8
jsr OBJ.DecWordAtY
TBOX.RUN.VT1 jsr TBOX.GetCurlineInAX
jsr TBOX.GetLineAX
jsr TBOX.GetLineLenInAXC
sta TempW
stx TempW+1
ldy #S.TBOX.DocX
cmp (ZPObjPtr),y
txa
iny
sbc (ZPObjPtr),y
bcs .1
lda TempW+1
sta (ZPObjPtr),y
dey
lda TempW
sta (ZPObjPtr),y
.1 ldy #S.TBOX.DocX
lda TempC
clc
adc (ZPObjPtr),y
tax
iny
lda TempC+1
adc (ZPObjPtr),y
ldy #S.TBOX.BufPtr+1
sta (ZPObjPtr),y
dey
txa
sta (ZPObjPtr),y
jmp TBOX.SetViewPort
TBOX.RUN.VT.8 clc
rts
*--------------------------------------
TBOX.RUN.FS jsr TBOX.GetBuf
TBOX.RUN.FS1 lda (ZPPtr2)
beq .8
>SYSCALL2 FreeMem
tax
ldy #S.TBOX.BufPtr
jsr OBJ.IncWordAtY
cpx #C.CR
beq .1
ldy #S.TBOX.DocX
bra .7
.1 lda #0
ldy #S.TBOX.DocX
sta (ZPObjPtr),y
iny
sta (ZPObjPtr),y
ldy #S.TBOX.DocY
.7 jsr OBJ.IncWordAtY
jsr TBOX.SetViewPort
.8 clc
rts
*--------------------------------------
TBOX.Run lda (pStack) Event
cmp #C.SPACE
bcc .8
TBOX.RUN.SOL lda #0
ldy #S.TBOX.DocX
sta (ZPObjPtr),y
iny
sta (ZPObjPtr),y
jsr TBOX.GetCurlineInAX
jsr TBOX.GetLineAX
ldy #S.TBOX.BufPtr
lda TempC BufPtr at SOL
sta (ZPObjPtr),y
iny
lda TempC+1
sta (ZPObjPtr),y
jmp TBOX.SetViewPort
*--------------------------------------
TBOX.RUN.EOL jsr TBOX.GetCurlineInAX
jsr TBOX.GetLineAX
jsr TBOX.GetLineLenInAXC
pha
.9 sec
ldy #S.TBOX.BufPtr
clc
adc TempC BufPtr at SOL
sta (ZPObjPtr),y
iny
txa
adc TempC+1
sta (ZPObjPtr),y
.8
pla
ldy #S.TBOX.DocX
sta (ZPObjPtr),y
iny
txa
sta (ZPObjPtr),y
jmp TBOX.SetViewPort
*--------------------------------------
TBOX.RUN.PGUP clc
rts
*--------------------------------------
TBOX.Draw ldy #S.OBJ.InnerW
lda (ZPObjPtr),y
TBOX.RUN.PGDN clc
rts
*--------------------------------------
TBOX.RUN.Home ldy #S.TBOX.DocX
tax
lda #C.SPACE
ldx #4 DocX + DocY
.1 jsr LIB.LineBufCOut
lda #0
.1 sta (ZPObjPtr),y
iny
dex
bne .1
clc
rts
ldy #S.TBOX.BufPtr
sta (ZPObjPtr),y
iny
sta (ZPObjPtr),y
jmp TBOX.SetViewPort
*--------------------------------------
TBOX.Activate jsr LIB.LineBufInit
TBOX.RUN.EraseCL
jsr TBOX.GetCurlineInAX
jsr TBOX.GetLineAX
jsr TBOX.GetLineLenInAXC
jsr TBOX.DeleteAXC
ldy #S.OBJ.InnerX
jmp TBOX.RUN.VT1
*--------------------------------------
TBOX.RUN.EOF lda #$ff
tax
jsr TBOX.GetLineAX
ldy #S.TBOX.DocY
lda TempI
sta (ZPObjPtr),y
tax
lda TempI+1
iny
sta (ZPObjPtr),y
jsr TBOX.GetLineAX
jsr TBOX.GetLineLenInAXC
ldy #S.TBOX.DocX
sta (ZPObjPtr),y
iny
txa
sta (ZPObjPtr),y
ldy #S.TBOX.BufCnt+1
lda (ZPObjPtr),y
tax
dey
lda (ZPObjPtr),y
ldy #S.TBOX.BufPtr
sta (ZPObjPtr),y
iny
txa
sta (ZPObjPtr),y
jmp TBOX.SetViewPort
*--------------------------------------
TBOX.Draw ldy #S.TBOX.VScroll
lda (ZPObjPtr),y
clc
ldy #S.TBOX.CurX
adc (ZPObjPtr),y
adc (pStack) Relative Y
tax
ldy #S.OBJ.InnerY
iny
lda (ZPObjPtr),y
adc #0
jsr TBOX.GetLineAX
bcs .5
ldy #S.TBOX.HScroll
lda (ZPObjPtr),y
tax
beq .12
.1 jsr TBOX.GetLineChar
beq .12
cmp #C.CR
beq .12
dex
bne .1
.12 ldy #S.OBJ.InnerW
lda (ZPObjPtr),y
tax
.2 jsr TBOX.GetLineChar
beq .3
cmp #C.CR
beq .3
jsr LB.COut
dex
bne .2
.3 txa
bne .6
clc
ldy #S.TBOX.CurY
adc (ZPObjPtr),y
tay
jsr LIB.GotoXY
rts
ldx #SEQ.CURON-SEQS
jsr LIB.LineBufSeqOut
jmp LIB.LineBufOut
.5 ldy #S.OBJ.InnerW
lda (ZPObjPtr),y
tax
.6 lda #C.SPACE
.7 jsr LB.COut
dex
bne .7
.8
*--------------------------------------
TBOX.Deactivate jsr LIB.LineBufInit
TBOX.Activate
*--------------------------------------
TBOX.Deactivate clc
rts
*--------------------------------------
TBOX.GetBuf ldy #S.TBOX.hBuf
lda (ZPObjPtr),y
>SYSCALL2 GetMemPtr
>STYA ZPPtr1
ldx #SEQ.CUROFF-SEQS
jsr LIB.LineBufSeqOut
pha
tya
ldy #S.TBOX.BufPtr
clc
adc (ZPObjPtr),y
sta ZPPtr2
pla
iny
adc (ZPObjPtr),y
sta ZPPtr2+1
rts
*--------------------------------------
TBOX.GetCurlineInAX
ldy #S.TBOX.DocY
lda (ZPObjPtr),y
tax
iny
lda (ZPObjPtr),y
rts
*--------------------------------------
TBOX.GetLineAX stx TempW
sta TempW+1 Req Line Num
ldy #S.TBOX.hBuf
lda (ZPObjPtr),y
>SYSCALL2 GetMemPtr
>STYA ZPPtr1
stz TempI Current Line Num
stz TempI+1
stz TempC Buffer Ofs
stz TempC+1
.1 lda TempI
eor TempW
bne .2
lda TempI+1
eor TempW+1
beq .8
.2 lda (ZPPtr1)
beq .9
jsr TBOX.GetLineLenInAXC
bcc .9
jmp LIB.LineBufOut
php
pha
adc TempC
sta TempC
txa
adc TempC+1
sta TempC+1
pla
plp
adc ZPPtr1
sta ZPPtr1
txa
adc ZPPtr1+1
sta ZPPtr1+1
inc TempI
bne .1
inc TempI+1
bra .1
.9 sec
rts
.8 clc
rts
*--------------------------------------
TBOX.GetLineChar
ldy #S.TBOX.bSelect
lda (ZPObjPtr),y
bpl .5
.5 clc
.HS B0 BCS
.6 sec
lda (ZPPtr1)
beq .8
inc ZPPtr1
bne .7
inc ZPPtr1+1
.7 inc TempC
bne .8
inc TempC+1
.8 rts
*--------------------------------------
TBOX.GetLineLenInAXC
lda ZPPtr1+1
pha
clc
ldy #0
ldx #0
.1 lda (ZPPtr1),y
beq .8
eor #C.CR
beq .7
iny
bne .1
inx
bra .1
.7 sec to skip CR
.8 pla
sta ZPPtr1+1
tya AX = len, CS if CR ended
rts
*--------------------------------------
TBOX.ToBuf1 ldy #S.TBOX.BufCnt
lda (ZPObjPtr),y
ldy #S.TBOX.BufSize
cmp (ZPObjPtr),y
ldy #S.TBOX.BufCnt+1
lda (ZPObjPtr),y
ldy #S.TBOX.BufSize+1
sbc (ZPObjPtr),y
bcs .9
dey ldy #S.TBOX.BufCnt
jsr OBJ.IncWordAtY
.1 jsr TBOX.GetBuf
jsr TBOX.Insert1
lda (pStack)
sta (ZPPtr2)
.8 clc
.9 rts
*--------------------------------------
TBOX.Insert1 lda #1
ldx #0
TBOX.InsertAX clc
adc ZPPtr2
sta ZPPtr3
txa
adc ZPPtr2+1
sta ZPPtr3+1
ldy #0
ldx #0
.1 lda (ZPPtr2),y
beq .4
iny
bne .1
inx
inc ZPPtr2+1
inc ZPPtr3+1
bra .1
.2 dex
.3 dey
lda (ZPPtr2),y
.4 sta (ZPPtr3),y
tya
bne .3
txa
bne .2
.8 rts
*--------------------------------------
TBOX.Delete1 lda #1
ldx #0
*--------------------------------------
TBOX.DeleteAX clc
TBOX.DeleteAXC adc ZPPtr2
sta ZPPtr3
txa
adc ZPPtr2+1
sta ZPPtr3+1
ldy #0
.1 lda (ZPPtr3),y
sta (ZPPtr2),y
beq .8
iny
bne .1
inc ZPPtr3+1
inc ZPPtr2+1
bra .1
.8 rts
*--------------------------------------
TBOX.SetViewPort
ldy #S.TBOX.DocX+1
lda (ZPObjPtr),y
tax
dey
lda (ZPObjPtr),y
ldy #S.TBOX.HScroll
sec
sbc (ZPObjPtr),y
ldy #S.OBJ.CurX set CurX = DocX - HScroll
sta (ZPObjPtr),y
ldy #S.TBOX.HScroll+1
txa
sbc (ZPObjPtr),y DocX => HScroll ?
bcs .10 yes..
ldy #S.TBOX.DocX+1 no, set HScroll = DocX
lda (ZPObjPtr),y
tax
dey
lda (ZPObjPtr),y
ldy #S.TBOX.HScroll
sta (ZPObjPtr),y
iny
txa
sta (ZPObjPtr),y
lda #0 set CurX = 0
bra .20
*--------------------------------------
.10 ldy #S.TBOX.HScroll+1
lda (ZPObjPtr),y
tax
dey
lda (ZPObjPtr),y
ldy #S.OBJ.InnerW
clc
adc (ZPObjPtr),y
bcc .11
inx
.11 ldy #S.TBOX.DocX (HScroll + InnerW) > (DocX + 1) ?
clc DocX+1
sbc (ZPObjPtr),y
iny
txa
sbc (ZPObjPtr),y
bcs .21 no...
ldy #S.OBJ.InnerW yes, set HScroll = DocX - (InnerW - 1)
lda (ZPObjPtr),y
dec
sta TempW (InnerW - 1)
ldy #S.TBOX.DocX
lda (ZPObjPtr),y
sec
sbc TempW
tax
iny
lda (ZPObjPtr),y
sbc #0
bcc .12 DocX - (InnerW - 1) < 0
ldy #S.TBOX.HScroll+1
sta (ZPObjPtr),y
dey
txa
sta (ZPObjPtr),y
lda TempW set CurX = (InnerW - 1)
bra .20
.12 lda #0
ldy #S.TBOX.HScroll+1
sta (ZPObjPtr),y
dey
sta (ZPObjPtr),y
.20 ldy #S.OBJ.CurX
sta (ZPObjPtr),y
sec
ror bRepaintAll
*--------------------------------------
.21 ldy #S.TBOX.DocY+1
lda (ZPObjPtr),y
tax
dey
lda (ZPObjPtr),y
ldy #S.TBOX.VScroll
sec
sbc (ZPObjPtr),y
ldy #S.OBJ.CurY set CurY = DocY - VScroll
sta (ZPObjPtr),y
ldy #S.TBOX.VScroll+1
txa
sbc (ZPObjPtr),y DocY => VScroll ?
bcs .30 yes..
ldy #S.TBOX.DocY+1 no, set VScroll = DocY
lda (ZPObjPtr),y
tax
dey
lda (ZPObjPtr),y
ldy #S.TBOX.VScroll
sta (ZPObjPtr),y
iny
txa
sta (ZPObjPtr),y
lda #0 set CurY = 0
bra .40
*--------------------------------------
.30 ldy #S.TBOX.VScroll+1
lda (ZPObjPtr),y
tax
dey
lda (ZPObjPtr),y
ldy #S.OBJ.InnerH
clc
adc (ZPObjPtr),y
bcc .31
inx
.31 ldy #S.TBOX.DocY (VScroll + InnerH) > (DocY + 1) ?
clc DocY+1
sbc (ZPObjPtr),y
iny
txa
sbc (ZPObjPtr),y
bcs .41 no...
ldy #S.OBJ.InnerH yes, set VScroll = DocY - (InnerH - 1)
lda (ZPObjPtr),y
dec
sta TempW (InnerH - 1)
ldy #S.TBOX.DocY
lda (ZPObjPtr),y
sec
sbc TempW
tax
iny
lda (ZPObjPtr),y
sbc #0
bcc .32 DocY - (InnerH - 1) < 0
ldy #S.TBOX.VScroll+1
sta (ZPObjPtr),y
dey
txa
sta (ZPObjPtr),y
lda TempW set CurY = (InnerH - 1)
bra .40
.32 lda #0
ldy #S.TBOX.VScroll+1
sta (ZPObjPtr),y
dey
sta (ZPObjPtr),y
ldy #S.TBOX.DocY
lda (ZPObjPtr),y
.40 ldy #S.OBJ.CurY
sta (ZPObjPtr),y
sec
ror bRepaintAll
.41 clc CLC RTS to jmp to
rts
*--------------------------------------
MAN
SAVE usr/src/lib/libtui.s.tbox

329
LIB/LIBTUI.S.TLINE.txt Normal file
View File

@ -0,0 +1,329 @@
NEW
AUTO 3,1
.LIST OFF
*--------------------------------------
* TLINE.New hParent,X1,Y1,W,pBuf,MaxLen 7
*--------------------------------------
TLINE.New jsr OBJ.Create A = Class
bcs .9
>PULLA
ldy #S.TLINE.MaxLen
sta (ZPObjPtr),y
ldy #S.TLINE.pBuf
jsr OBJ.PullWordY
stx ZPPtr1
sta ZPPtr1+1
ldy #S.OBJ.F
lda #S.OBJ.F.bHScroll+S.OBJ.F.bCursor
sta (ZPObjPtr),y
>PULLA
ldy #S.OBJ.W
sta (ZPObjPtr),y
iny S.OBJ.H
lda #1
sta (ZPObjPtr),y
ldy #S.OBJ.CurX
sta (ZPObjPtr),y
jsr OBJ.PullY1X1hParent
jmp OBJ.Insert
.9 >POP 7
rts
*--------------------------------------
TLINE.Destroy clc
rts
*--------------------------------------
TLINE.Run ldy #S.OBJ.S
lda (ZPObjPtr),y
bpl .9 S.OBJ.S.bActive
jsr TLINE.GetBuf
lda (pStack) Event
cmp #C.DEL
beq TLINE.RUN.DEL
cmp #C.SPACE
bcs .2
cmp #C.BS
beq TLINE.RUN.BS
cmp #C.FS
beq TLINE.RUN.FS
.9 lda #0
sec
rts
*--------------------------------------
.2 ldy #S.TLINE.MaxLen
lda (ZPObjPtr),y
ldy #S.TLINE.Len
cmp (ZPObjPtr),y
beq .8
lda (ZPObjPtr),y
inc
sta (ZPObjPtr),y
pha
ldy #S.TLINE.Ptr
lda (ZPObjPtr),y
sta TempW
inc
sta (ZPObjPtr),y
ply
.1 dey
lda (ZPPtr1),y
iny
sta (ZPPtr1),y
dey
cpy TempW
bne .1
lda (pStack)
ldy TempW
sta (ZPPtr1),y
jmp TLINE.SetViewPort
.8 lda #0
clc
rts
*--------------------------------------
TLINE.RUN.BS ldy #S.TLINE.Ptr
lda (ZPObjPtr),y
beq .8
dec
sta (ZPObjPtr),y
jmp TLINE.SetViewPort
.8 clc
rts
*--------------------------------------
TLINE.RUN.FS ldy #S.TLINE.Len
lda (ZPObjPtr),y
ldy #S.TLINE.Ptr
eor (ZPObjPtr),y
beq .8
lda (ZPObjPtr),y
inc
sta (ZPObjPtr),y
jmp TLINE.SetViewPort
.8 clc
rts
*--------------------------------------
TLINE.RUN.DEL ldy #S.TLINE.Ptr
lda (ZPObjPtr),y
beq .8
tay
.1 lda (ZPPtr1),y
dey
sta (ZPPtr1),y
tax
beq .2
iny
iny
bra .1
.2 ldy #S.TLINE.Len
lda (ZPObjPtr),y
dec
sta (ZPObjPtr),y
jmp TLINE.RUN.BS
.8 clc
rts
*--------------------------------------
TLINE.Draw jsr TLINE.GetBuf
ldx #C.SPACE
ldy #S.OBJ.S
lda (ZPObjPtr),y S.OBJ.S.bActive
bpl .1
ldx #'['
.1 txa
jsr LB.COut
ldy #S.TLINE.HScroll
lda (ZPObjPtr),y
beq .12
tax
.11 jsr TLINE.GetLineChar
beq .12
dex
bne .11
.12 ldy #S.OBJ.InnerW
lda (ZPObjPtr),y
tax
dex
dex
.2 jsr TLINE.GetLineChar
beq .3
jsr LB.COut
dex
bne .2
.3 txa
beq .5
lda #C.SPACE
.4 jsr LB.COut
dex
bne .4
.5 ldx #C.SPACE
ldy #S.OBJ.S
lda (ZPObjPtr),y S.OBJ.S.bActive
bpl .6
ldx #']'
.6 txa
jsr LB.COut
.8 clc
rts
*--------------------------------------
TLINE.Activate
TLINE.Deactivate
jmp OBJ.Draw.Body
*--------------------------------------
TLINE.GetBuf ldy #S.TLINE.pBuf
lda (ZPObjPtr),y
sta ZPPtr1
iny
lda (ZPObjPtr),y
sta ZPPtr1+1
rts
*--------------------------------------
TLINE.GetLineChar
lda (ZPPtr1)
beq .8
inc ZPPtr1
bne .8
inc ZPPtr1+1
.8 rts
*--------------------------------------
TLINE.SetViewPort
ldy #S.TLINE.Ptr
lda (ZPObjPtr),y
ldy #S.TLINE.HScroll
sec
sbc (ZPObjPtr),y
ldy #S.OBJ.CurX set CurX = Ptr - HScroll
inc +1
sta (ZPObjPtr),y
bcs .10 yes..
ldy #S.TLINE.Ptr no, set HScroll = Ptr
lda (ZPObjPtr),y
ldy #S.TLINE.HScroll
sta (ZPObjPtr),y
lda #0 set CurX = 0+1
bra .20
*--------------------------------------
.10 ldy #S.TLINE.HScroll
lda (ZPObjPtr),y
ldy #S.OBJ.InnerW
clc
adc (ZPObjPtr),y
dec
dec
ldy #S.TLINE.Ptr (HScroll + InnerW-2) > (Ptr + 1) ?
clc Ptr+1
sbc (ZPObjPtr),y
bcs .8 no...
ldy #S.OBJ.InnerW yes, set HScroll = Ptr - (InnerW - 1)
lda (ZPObjPtr),y
dec
dec
dec
sta TempW (InnerW - 1)
ldy #S.TLINE.Ptr
lda (ZPObjPtr),y
sec
sbc TempW
bcc .12 Ptr - (InnerW - 1) < 0
ldy #S.TLINE.HScroll
sta (ZPObjPtr),y
lda TempW set CurX = (InnerW - 1)
bra .20
.12 lda #0
ldy #S.TLINE.HScroll
sta (ZPObjPtr),y
.20 inc
ldy #S.OBJ.CurX
sta (ZPObjPtr),y
sec
ror bRepaintAll
.8 ldy #1 hObj
lda (pStack),y
>PUSHA
jsr OBJ.Draw.Body
inc pStack
bcs .9
lda #0
* clc
.9 rts
*--------------------------------------
MAN
SAVE usr/src/lib/libtui.s.tline
LOAD usr/src/lib/libtui.s
ASM

View File

@ -7,13 +7,14 @@ NEW
*--------------------------------------
.INB inc/macros.i
.INB inc/a2osx.i
.INB inc/kernel.i
.INB inc/net.telnet.i
.INB inc/libtui.i
*--------------------------------------
.DUMMY
.OR ZPLIB
ZPScrnPtr .BS 2
ZPCtxPtr .BS 2
ZPObjPtr .BS 2
ZPLineBufPtr .BS 2
@ -21,10 +22,14 @@ ZPLineBufCnt .BS 2
ZPPtr1 .BS 2
ZPPtr2 .BS 2
ZPPtr3 .BS 2
TempW .BS 2
TempC .BS 2
TempI .BS 2
bResize .BS 1
bRepaintAll .BS 1
hObj .BS 1
.ED
*--------------------------------------
@ -44,11 +49,11 @@ CS.START cld
*--------------------------------------
.1 .DA LIB.LOAD
.DA LIB.UNLOAD
.DA LIB.Init
.DA LIB.GetEvent
.DA LIB.Dispatch
.DA LIB.Close
.DA CTX.Init
.DA CTX.Close
*--------------------------------------
.DA OBJ.New
.DA OBJ.Exec
.DA OBJ.Destroy
.DA OBJ.Run
.DA OBJ.Draw
@ -58,28 +63,97 @@ CS.START cld
.DA OBJ.Deactivate
*--------------------------------------
J.ObjNew .DA SCRN.New
.DA DLG.New
.DA LABEL.New
.DA TLINE.New
.DA TBOX.New
.DA LBOX.New
.DA CBOX.New
.DA BUT.New
.DA RADIO.New
*--------------------------------------
J.ObjDestroy .DA SCRN.Destroy
.DA DLG.Destroy
.DA LABEL.Destroy
.DA TLINE.Destroy
.DA TBOX.Destroy
.DA LBOX.Destroy
.DA CBOX.Destroy
.DA BUT.Destroy
.DA RADIO.Destroy
*--------------------------------------
J.ObjRun .DA SCRN.Run
.DA DLG.Run
.DA LABEL.Run
.DA TLINE.Run
.DA TBOX.Run
.DA LBOX.Run
.DA CBOX.Run
.DA BUT.Run
.DA RADIO.Run
*--------------------------------------
J.ObjDraw .DA SCRN.Draw
.DA DLG.Draw
.DA LABEL.Draw
.DA TLINE.Draw
.DA TBOX.Draw
.DA LBOX.Draw
.DA CBOX.Draw
.DA BUT.Draw
.DA RADIO.Draw
*--------------------------------------
J.ObjActivate .DA SCRN.Activate
.DA DLG.Activate
.DA LABEL.Activate
.DA TLINE.Activate
.DA TBOX.Activate
.DA LBOX.Activate
.DA CBOX.Activate
.DA BUT.Activate
.DA RADIO.Activate
*--------------------------------------
J.ObjDeactivate .DA SCRN.Deactivate
.DA DLG.Deactivate
.DA LABEL.Deactivate
.DA TLINE.Deactivate
.DA TBOX.Deactivate
.DA LBOX.Deactivate
.DA CBOX.Deactivate
.DA BUT.Deactivate
.DA RADIO.Deactivate
*--------------------------------------
J.TBOX.RUN .DA TBOX.RUN.Ignore
.DA TBOX.RUN.Ignore
.DA TBOX.RUN.SelBegin Ctrl-B
.DA TBOX.RUN.Ignore Ctrl-C
.DA TBOX.RUN.Ignore
.DA TBOX.RUN.SelEnd Ctrl-E
.DA TBOX.RUN.Ignore
.DA TBOX.RUN.SOL Ctrl-G
.DA TBOX.RUN.BS
.DA TBOX.RUN.Ignore TAB
.DA TBOX.RUN.LF
.DA TBOX.RUN.VT
.DA TBOX.RUN.EOL Ctrl-L
.DA TBOX.RUN.CR
.DA TBOX.RUN.Ignore
.DA TBOX.RUN.PGUP Ctrl-O
.DA TBOX.RUN.PGDN Ctrl-P
.DA TBOX.RUN.Ignore
.DA TBOX.RUN.Ignore
.DA TBOX.RUN.Ignore
.DA TBOX.RUN.Home Ctrl-T
.DA TBOX.RUN.FS
.DA TBOX.RUN.Ignore
.DA TBOX.RUN.EraseCL Ctrl-W
.DA TBOX.RUN.Ignore
.DA TBOX.RUN.EOF Ctrl-Y
.DA TBOX.RUN.Ignore
.DA TBOX.RUN.Ignore
.DA TBOX.RUN.Ignore
.DA TBOX.RUN.Ignore
.DA TBOX.RUN.Ignore
.DA TBOX.RUN.Ignore
*--------------------------------------
L.SEQ.INIT .DA SEQ.INIT
L.SEQ.GOTOXY .DA SEQ.GOTOXY
@ -113,683 +187,27 @@ LIB.UNLOAD dec LibCnt
.8 clc
rts
*--------------------------------------
LIB.Init sta TempW F
>LDYAI S.SCRN
>SYSCALL2 GetMem
bcs .99
>STYA ZPScrnPtr
txa
>PUSHA hScrn
lda #0
>PUSHA Init Counter
ldy #S.SCRN-1
.10 sta (ZPScrnPtr),y
dey
bpl .10
lda TempW
ldy #S.OBJ.F
sta (ZPScrnPtr),y
jsr LIB.GetC.Reset
>LDYA L.SEQ.INIT
jsr LIB.YAOut
bcs .98
.1 >SLEEP
ldy #1 hScrn
lda (pStack),y
jsr LIB.GetC
bcs .98
beq .2
>SYSCALL PutChar
bcs .98
ldy #1 hScrn
lda (pStack),y
jsr LIB.GetScrn
.2 ldy #S.OBJ.W
lda (ZPScrnPtr),y
bne .8
lda (pStack)
dec
sta (pStack)
bne .1
lda #80
ldy #S.OBJ.W
sta (ZPScrnPtr),y
lda #24
iny S.OBJ.H
sta (ZPScrnPtr),y
.8 >LDYA ZPScrnPtr
jsr LIB.SetObjX2Y2
ldy #S.OBJ.S
lda #S.OBJ.S.bACTIVE
sta (ZPScrnPtr),y
inc pStack Discard counter
>PULLA hScrn
clc
.99 rts
.98 pha
inc pStack Discard counter
>PULLA hScrn
>SYSCALL2 FreeMem
pla
sec
LIB.GetCTX >SYSCALL2 GetMemPtr
>STYA ZPCtxPtr
rts
*--------------------------------------
LIB.GetEvent stz bResize
>PUSHA hScrn
jsr LIB.GetC
bcs .9
bit bResize
bpl .8
lda (pStack)
jsr LIB.GetScrn
ldy #S.OBJ.fRESIZE
lda (ZPScrnPtr),y
sta ZPPtr1
iny
lda (ZPScrnPtr),y
sta ZPPtr1+1
jsr .10
stz bResize
lda #0
clc
.8
.9 inc pStack
rts
.10 jmp (ZPPtr1)
*--------------------------------------
LIB.Dispatch jsr OBJ.Run
bcc .8
lda (pStack)
cmp #3 Ctrl-C
beq .9
clc
.8
.9 inc pStack Destroy Event
inc pStack on Stack
rts
*--------------------------------------
LIB.Close jsr OBJ.Destroy
>LDYA L.SEQ.CLOSE
jsr LIB.YAOut
clc
rts
*--------------------------------------
LIB.FindActive ldx ZPObjPtr
phx
ldx ZPObjPtr+1
phx
jsr LIB.GetObj
* ldy #S.OBJ.P
* lda (ZPObjPtr),y
* sec
* beq .80
ldy #S.OBJ.Childs
.1 phy
lda (ZPObjPtr),y
beq .7
pha
>SYSCALL2 GetMemPtr
>STYA ZPPtr1
ldy #S.OBJ.S
lda (ZPPtr1),y
and #S.OBJ.S.bACTIVE
bne .8
pla
.7 ply
iny
cpy #S.OBJ
bne .1
* sec
bra .80
.8 pla
ply
clc
.80 plx
stx ZPObjPtr+1
plx
stx ZPObjPtr
rts
*--------------------------------------
LIB.GotoXY >PUSHW ZPLineBufPtr
>PUSHW L.SEQ.GOTOXY
tya
inc
>PUSHA
txa
inc
>PUSHA
>PUSHBI 2
jmp LIB.LineBufPrintF
*--------------------------------------
LIB.SetColor tax
>PUSHW ZPLineBufPtr
>PUSHW L.SEQ.COLOR
>PUSHB OBJ.COLORS,x
>PUSHB OBJ.COLORS+1,x
>PUSHBI 2
jmp LIB.LineBufPrintF
*--------------------------------------
LIB.GetScrn >SYSCALL2 GetMemPtr
>STYA ZPScrnPtr
rts
*--------------------------------------
LIB.GetObj >SYSCALL2 GetMemPtr
LIB.GetOBJ >SYSCALL2 GetMemPtr
>STYA ZPObjPtr
rts
*--------------------------------------
LIB.SetObjX2Y2 >STYA ZPPtr1
ldy #S.OBJ.X1
jsr .7
ldy #S.OBJ.Y1
jsr .7
ldy #S.OBJ.F
lda (ZPPtr1),y
and #S.OBJ.F.bHBorder
beq .1
ldy #S.OBJ.InnerX
lda (ZPPtr1),y
inc
sta (ZPPtr1),y
iny
iny
lda (ZPPtr1),y S.OBJ.InnerW
dec
dec
sta (ZPPtr1),y
.1 ldx #0
ldy #S.OBJ.F
lda (ZPPtr1),y
bit #S.OBJ.F.bVBorder+S.OBJ.F.bTITLE
beq .2
dex
.2 bit #S.OBJ.F.bVBorder+S.OBJ.F.bSTATUS
beq .3
dex
.3 txa
beq .4
ldy #S.OBJ.InnerY
lda (ZPPtr1),y
inc
sta (ZPPtr1),y
txa
iny
iny
clc
adc (ZPPtr1),y S.OBJ.InnerH
sta (ZPPtr1),y
.4 ldy #S.OBJ.F
lda (ZPPtr1),y
bit #S.OBJ.F.bMENU
beq .5
ldy #S.OBJ.InnerY
lda (ZPPtr1),y
inc
sta (ZPPtr1),y
iny
iny
lda (ZPPtr1),y S.OBJ.InnerH
dec
sta (ZPPtr1),y
.5 rts
*--------------------------------------
.7 lda (ZPPtr1),y S.OBJ.X1/Y1
tax
iny
iny S.OBJ.W/H
phy
clc
adc (ZPPtr1),y
dec
iny
iny S.OBJ.X2/Y2
sta (ZPPtr1),y
iny
iny
txa
sta (ZPPtr1),y S.OBJ.InnerX/Y
ply S.OBJ.W/H
lda (ZPPtr1),y
iny
iny
iny
iny
iny
iny
sta (ZPPtr1),y S.OBJ.InnerW/H
rts
*--------------------------------------
LIB.GetC >PUSHA hScrn
ldy #S.PS.hStdIn
lda (pPS),y
>SYSCALL2 FEOF
bcs .9
tay
beq .10
inc pStack
bra .18
.10 >SYSCALL2 GetChar
bcc .11
.9 inc pStack
rts
.11 pha
>PULLA
jsr LIB.GetScrn
plx
ldy #S.SCRN.bEscMode
lda (ZPScrnPtr),y
beq .20
bmi .40 IAC mode
iny S.SCRN.InBufPtr
lda (ZPScrnPtr),y
cpx #'[' CSI ?
bne .12
cmp #S.SCRN.InBufPtr
bne .49 buffer not empty...bad SEQ
.12 jsr LIB.GetC.ToBuf
bcs .49 Buffer Full
cpx #'['
beq .18
cpx #64
bcs LIB.GetC.ESCSEQ if CC, not a letter...SEQ is incomplete
.18 lda #0
clc
rts
*--------------------------------------
.20 cpx #C.ESC
bne .30
inc A = $01
bra .31
*--------------------------------------
.30 cpx #IAC
bne .38
dec A = $FF
.31 jsr LIB.GetC.SetMode
lda #0
clc
rts
*--------------------------------------
.38 txa
clc
.39 rts
*--------------------------------------
.40 jsr LIB.GetC.ToBuf
bcs .49 Buffer Full
cpy #S.SCRN.InBuf First char...
beq .48
ldy #S.SCRN.InBuf
lda (ZPScrnPtr),y
cmp #SB First char is SB ?
bne LIB.GetC.IACSEQ no ...
cpx #SE is SE after SB ..... ?
bne .48
bra LIB.GetC.IACSEQ yes, we have IAC SB .....SE
.49 jsr LIB.GetC.Reset
.48 lda #0
clc
rts
*--------------------------------------
LIB.GetC.ESCSEQ cmp #S.SCRN.InBuf+2
bcs .2
ldy #ESC.Out-ESC.In-1
txa
.1 cmp ESC.In,y
beq .7
dey
bpl .1
bra .6
*--------------------------------------
* \e[xxx;yyyR
*--------------------------------------
.2 cpx #'R' Response to cursor position query?
bne .6
lda #S.SCRN.InBuf+1 skip ESC [
jsr LIB.GetC.GetScrnOfs
>PUSHYA
>PUSHW L.FMT.ESCCSI.R
lda #S.OBJ.H
jsr LIB.GetC.GetScrnOfs
>PUSHYA
lda #S.OBJ.W
jsr LIB.GetC.GetScrnOfs
>PUSHYA
>PUSHBI 4 2 pointers
>SYSCALL2 sscanf
.6 ldx #0
bra .8
.7 ldx ESC.Out,y
.8 jsr LIB.GetC.Reset
txa
clc
rts
*--------------------------------------
* IAC SB TN.O.NAWS ww ww hh hh IAC SE
*--------------------------------------
LIB.GetC.IACSEQ ldy #S.SCRN.InBuf
lda (ZPScrnPtr),y
cmp #SB
bne .8
iny
lda (ZPScrnPtr),y
cmp #TN.O.NAWS
bne .8
iny
lda (ZPScrnPtr),y
bne .8
iny
lda (ZPScrnPtr),y
cmp #80
bcs .1
lda #80
.1 tax
iny
lda (ZPScrnPtr),y
bne .8
iny
lda (ZPScrnPtr),y
cmp #24
bcs .2
lda #24
.2 ldy #S.OBJ.H
sta (ZPScrnPtr),y
dey S.OBJ.W
txa
sta (ZPScrnPtr),y
>LDYA ZPScrnPtr
jsr LIB.SetObjX2Y2
sec
ror bResize
.8 jsr LIB.GetC.Reset
lda #0
clc
rts
*--------------------------------------
LIB.GetC.Reset lda #0
LIB.GetC.SetMode
ldy #S.SCRN.bEscMode
sta (ZPScrnPtr),y
iny Y = S.SCRN.InBufPtr
tya
sta (ZPScrnPtr),y
rts
*--------------------------------------
LIB.GetC.GetScrnOfs
clc
adc ZPScrnPtr
tay
lda ZPScrnPtr+1
adc #0
.9 rts
*--------------------------------------
LIB.GetC.ToBuf ldy #S.SCRN.InBufPtr
lda (ZPScrnPtr),y
cmp #S.SCRN.EndBuf buffer full
bcs .9
phy
inc
tay
txa
sta (ZPScrnPtr),y
tya
ply
sta (ZPScrnPtr),y
* clc
.9 rts
*--------------------------------------
LIB.LineBufInit >LDYA LineBuf
>STYA ZPLineBufPtr
stz ZPLineBufCnt
stz ZPLineBufCnt+1
rts
*--------------------------------------
LIB.LineBufSeqOut
.1 lda SEQS,x
beq .8
jsr LIB.LineBufCOut
inx
bra .1
.8 rts
*--------------------------------------
LIB.LineBufYAOut
ldx #0
*--------------------------------------
LIB.LineBufYAOutX
>STYA ZPPtr1 X = MaxLen
ldy #$ff
.1 iny
lda (ZPPtr1),y
beq .8
jsr LIB.LineBufCOut
dex
bne .1
.8 rts
*--------------------------------------
LIB.LineBufPrintF
>SYSCALL2 SPrintF
tya
clc
adc ZPLineBufPtr
sta ZPLineBufPtr
bcc .1
inc ZPLineBufPtr+1
clc
.1 tya
adc ZPLineBufCnt
sta ZPLineBufCnt
bcc .8
inc ZPLineBufCnt+1
clc
.8 rts
*--------------------------------------
LIB.LineBufHOut pha
lsr
lsr
lsr
lsr
jsr .1
pla
and #$0F
.1 ora #$30
cmp #'9'+1
bcc LIB.LineBufCOut
adc #6
*--------------------------------------
LIB.LineBufCOut sta (ZPLineBufPtr)
inc ZPLineBufPtr
bne .1
inc ZPLineBufPtr+1
.1 inc ZPLineBufCnt
bne .8
inc ZPLineBufCnt+1
.8 rts
*--------------------------------------
LIB.LineBufOut ldy #S.PS.hStdOut
lda (pPS),y
>PUSHA
>PUSHW LineBuf
>PUSHW ZPLineBufCnt
>SYSCALL fwrite
rts
*--------------------------------------
LIB.YAOut dec pStack
>PUSHYA
ldy #S.PS.hStdOut
lda (pPS),y
ldy #2
sta (pStack),y
>SYSCALL fputs
rts
*--------------------------------------
.INB usr/src/lib/libtui.s.lb
.INB usr/src/lib/libtui.s.ctx
.INB usr/src/lib/libtui.s.cont
.INB usr/src/lib/libtui.s.obj
.INB usr/src/lib/libtui.s.lbox
.INB usr/src/lib/libtui.s.scrn
.INB usr/src/lib/libtui.s.dlg
.INB usr/src/lib/libtui.s.label
.INB usr/src/lib/libtui.s.tline
.INB usr/src/lib/libtui.s.tbox
.INB usr/src/lib/libtui.s.lbox
.INB usr/src/lib/libtui.s.cbox
.INB usr/src/lib/libtui.s.but
.INB usr/src/lib/libtui.s.radio
*--------------------------------------
CS.END
*--------------------------------------
@ -802,11 +220,17 @@ ESC.Out .DA #C.BS,#C.LF,#C.VT,#C.FS
*--------------------------------------
FMT.ESCCSI.R .AZ "%d;%d"
*--------------------------------------
OBJ.SIZES .DA S.SCRN,S.TBOX,S.LBOX
OBJ.SIZES .DA S.SCRN,S.DLG,S.LABEL,S.TLINE,S.TBOX,S.LBOX,S.CBOX,S.BUT,S.RADIO
*--------------------------------------
OBJ.COLORS .DA #93,#44 SCRN
.DA #93,#46 DLG
.DA #93,#0 LABEL
.DA #93,#104 TLINE
.DA #93,#104 TBOX
.DA #93,#104 LBOX
.DA #93,#0 CBOX
.DA #92,#100 BUT
.DA #93,#0 RADIO
*--------------------------------------
SEQ.INIT .DA #C.ESC
.AS "c" FF

View File

@ -274,7 +274,7 @@ LDR.Common jsr LDR.BlkDevScan
lda LDR.BootFlag get setup entry point flag
beq LDR.ReadRoot taken if normal boot.
lda RROMBNK2
bit RROMBNK2
rts return to caller at setup entry point.
*--------------------------------------
LDR.ReadRoot lda LDR.MLIOL.P+1 place boot devnum in globals
@ -629,7 +629,9 @@ LDR.SetupRAM lda DEVCNT
* find all disk devices in system slots and set up address
* and device table in prodos global page.
*--------------------------------------
LDR.BlkDevScan stz idxl
LDR.BlkDevScan bit RROMBNK2 write protect lc ram.
stz idxl
lda #$C7 search slots from high to low
sta idxl+1
@ -907,7 +909,7 @@ LDR.MountSPDevs ldx #LDR.DEVPTRS.CNT-1
lda LDR.SPVect+2
sta XDOS.SPVectHi-1,x
lda RROMBNK2 write protect lc ram.
bit RROMBNK2 write protect lc ram.
inc DEVCNT
ldx DEVCNT

View File

@ -130,7 +130,7 @@ CS.RUN.LOOP0 >SLEEP
>PUSHW L.ENV.TERM
>SYSCALL UnsetEnv
.1 ldy #S.PS.hStdOut
ldy #S.PS.hStdOut
lda (pPS),y
>PUSHA
>PUSHW L.TELNETOPTS

View File

@ -84,16 +84,14 @@ CS.RUN >LDYA L.ETCISSUE
*--------------------------------------
>LDYA L.ETCNOAUTH
jsr CS.RUN.DumpFile
*--------------------------------------
CS.RUN.EXECPS >LDYA L.ETCMOTD
jsr CS.RUN.DumpFile
>PUSHW L.SHELL
>PUSHBI S.PS.F.HOLD
>SYSCALL ExecL
jsr CS.RUN.EXECPS
bcs .9
ldy #S.PS.RC
lda (pPS),y
>SLEEP
sec
.9 rts
*--------------------------------------
@ -195,7 +193,23 @@ CS.RUN.EXEC >PUSHEA.G Username
lda ZPOldSession
sta (pPS),y
clc
ldy #S.PS.RC
lda (pPS),y
sec
.9 rts
*--------------------------------------
CS.RUN.EXECPS >LDYA L.ETCMOTD
jsr CS.RUN.DumpFile
>PUSHW L.SHELL
>PUSHBI S.PS.F.HOLD
>SYSCALL ExecL
bcs .9
>SLEEP
* clc
.9 rts
*--------------------------------------
CS.RUN.GetLine >STYA ZPGetLinePtr

View File

@ -20,7 +20,7 @@ K.MD5 .EQ K.SYSCALL.JMPX2
* ## MD5Init
* Initialize a MD5 computation
* # C
* `hMD5 md5init ();`
* `short int md5init();`
* # ASM
* `>SYSCALL MD5Init`
* ## RETURN VALUE

View File

@ -3,7 +3,7 @@ NEW
*/--------------------------------------
* # ExecL
* ## C / CSH
* `int execl(const char *cmdline, short int flags);`
* `short int execl(const char *cmdline, short int flags);`
* ## ASM
* `>PUSHW cmdline`
* `>PUSHB flags`
@ -16,7 +16,7 @@ K.ExecL clc
*/--------------------------------------
* # ExecV
* ## C / CSH
* `int execv(const char* argv[], short int flags);`
* `short int execv(const char* argv[], short int flags);`
* ## ASM
* `>PUSHW argv`
* `>PUSHB flags`

View File

@ -424,10 +424,21 @@ K.FClose jsr PFT.CheckNodeA
jsr K.FreeMem
lda (pFD)
tay
ldx IO.hFILE
lda hFDs-1,x
beq .8
stz hFDs-1,x
cpy #S.FD.T.DSOCK SOCKS will free FDs
beq .8
cpy #S.FD.T.SSOCK
beq .8
jmp K.FreeMem
.8 clc

View File

@ -1544,7 +1544,7 @@ TERMX.DIB .DA #S.DIB.S.WRITE+S.DIB.S.READ
.DA K.VER
*--------------------------------------
* ` a b c d e f g h i j k l m n o
REMAP.E0.FF .HS 5B.41.42.43.44.45.46.47.48.49.20.5e.5a.5a.4e.4f
REMAP.E0.FF .HS 5b.41.42.43.44.45.46.47.48.49.20.5e.5a.5a.4e.4f
* p q r s t u v w x y z { | } ~ DEL
.HS 50.5c.52.53.54.55.56.57.5a.59.5a.5b.5c.5d.5e.5f
*--------------------------------------

View File

@ -194,8 +194,10 @@ VSDRIVE.Ping lda TmpPtr1+1 A=SlotCN
tya
.9 stz SSC.RESET-$8F,x
stz SSC.CMD-$8F,x Applewin Bug ???
.9 stz SSC.CMD-$8F,x Applewin Bug ???
stz SSC.RESET-$8F,x
plp
sec
rts