Kernel 0.9.1 : TCPIP, code reorg

This commit is contained in:
Rémy GIBERT 2018-05-22 08:01:05 +02:00
parent f23b7a890a
commit ea26b4cfdc
11 changed files with 157 additions and 155 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -86,11 +86,15 @@ S.MOUSE.S .EQ 8
S.MOUSE.S.UP .EQ %00000001 S.MOUSE.S.UP .EQ %00000001
S.MOUSE.S.DOWN .EQ %00000010 S.MOUSE.S.DOWN .EQ %00000010
S.MOUSE.S.MOVE .EQ %00000100 S.MOUSE.S.MOVE .EQ %00000100
S.MOUSE.S.DRAG .EQ %00001000 S.MOUSE.S.DRAGSTART .EQ %00001000
S.MOUSE.S.CLK .EQ %00010000 S.MOUSE.S.DRAGEND .EQ %00010000
S.MOUSE.S.DCLK .EQ %00100000 S.MOUSE.S.CLK .EQ %00100000
S.MOUSE.S.DCLK .EQ %01000000
S.MOUSE.KEYMOD .EQ 9
S.MOUSE.KEYMOD.OA .EQ %00000001
S.MOUSE.KEYMOD.CA .EQ %00000010
* *
S.MOUSE .EQ 9 S.MOUSE .EQ 10
*-------------------------------------- *--------------------------------------
S.POINT.X .EQ 0 S.POINT.X .EQ 0
S.POINT.Y .EQ 2 S.POINT.Y .EQ 2

View File

@ -8,7 +8,7 @@ AUTO 4,1
K.ENV.SIZE .EQ 256 K.ENV.SIZE .EQ 256
K.FLT.MAX .EQ 4 K.FLT.MAX .EQ 4
K.EVT.MAX .EQ 4 K.EVT.MAX .EQ 4
K.DEV.MAX .EQ 32 K.DEV.MAX .EQ 16
K.PS.MAX .EQ 32 K.PS.MAX .EQ 32
*-------------------------------------- *--------------------------------------
H.BIN.T .EQ 0 H.BIN.T .EQ 0
@ -55,6 +55,8 @@ INDEX .EQ $5E ->$5F
FORPNT .EQ $85 ->$86 FORPNT .EQ $85 ->$86
FAC .EQ $9D ->$A1 FAC .EQ $9D ->$A1
FAC.SIGN .EQ $A2 FAC.SIGN .EQ $A2
ARG .EQ $A5 -> $A9 (5 bytes)
ARG.SIGN .EQ $AA
*FAC.EXTENSION .EQ $AC *FAC.EXTENSION .EQ $AC
TXTPTR .EQ $B8 TXTPTR .EQ $B8
*-------------------------------------- *--------------------------------------
@ -121,6 +123,8 @@ Flt.Table .EQ $0D80 K.FLT.MAX*S.FLT.SIZE=4*32=128b
*-------------------------------------- *--------------------------------------
Dev.Table .EQ $0E00 K.DEV.MAX*S.DEV=32*16=512b Dev.Table .EQ $0E00 K.DEV.MAX*S.DEV=32*16=512b
*-------------------------------------- *--------------------------------------
K.IOBuf .EQ $0F00
*--------------------------------------
*** Z80 Reserved $1000-10FF*** *** Z80 Reserved $1000-10FF***
*-------------------------------------- *--------------------------------------
Z80JMP .EQ $1000 (00000h) Up To $10FF Z80JMP .EQ $1000 (00000h) Up To $10FF

11
LIB/LIBGUI.S.EVT.txt Normal file
View File

@ -0,0 +1,11 @@
NEW
PREFIX /A2OSX.BUILD
AUTO 4,1
*--------------------------------------
EVT.Get
*--------------------------------------
MAN
SAVE /A2OSX.SRC/LIB/LIBGUI.S.EVT
LOAD /A2OSX.SRC/LIB/LIBGUI.S
ASM

View File

@ -75,7 +75,7 @@ MOU.Read >STYA ZPPtr1
>PUSHA >PUSHA
>PUSHBI DEVMGR.READBLOCK >PUSHBI DEVMGR.READBLOCK
>PUSHWI 0 >PUSHW ZPPtr1
>SYSCALL IOCTL >SYSCALL IOCTL
bcs .9 bcs .9

View File

@ -71,7 +71,6 @@ CS.START cld
.DA HideCursor .DA HideCursor
.DA ShowCursor .DA ShowCursor
.DA UpdateCursor .DA UpdateCursor
.DA ReadMouse
.DA GetScreenGC .DA GetScreenGC
J.Cmds .DA DrawLine J.Cmds .DA DrawLine
.DA DrawText .DA DrawText
@ -151,17 +150,6 @@ CB.Get >STYA .1+1
rts rts
*-------------------------------------- *--------------------------------------
ReadMouse >PULLYA
ldx hDevMouse Mouse is active ?
beq .9
ldx #DEVMGR.READBLOCK
jmp GoDevMouse
.9 sec
rts
*--------------------------------------
GetScreenGC >LDYA L.GC.Screen GetScreenGC >LDYA L.GC.Screen
rts rts
*-------------------------------------- *--------------------------------------

View File

@ -80,11 +80,6 @@ CS.RUN lda A2osX.ASCREEN GUI screen active ?
.2 >STA.G CUR.T .2 >STA.G CUR.T
>LIBCALL hLIBGUI,LIBGUI.SetCursor.A >LIBCALL hLIBGUI,LIBGUI.SetCursor.A
lda MouseData+S.MOUSE.X1
lda MouseData+S.MOUSE.X1+1
lda MouseData+S.MOUSE.Y1
lda MouseData+S.MOUSE.Y1+1
jsr Destop.Paint jsr Destop.Paint

View File

@ -25,9 +25,10 @@ CS.START cld
.DA #$61 6502,Level 1 (65c02) .DA #$61 6502,Level 1 (65c02)
.DA #1 BIN Layout Version 1 .DA #1 BIN Layout Version 1
.DA 0 .DA 0
.DA CS.END-CS.START Code Length To Relocate .DA CS.END-CS.START CS
.DA DS.END-DS.START Data Segment to Allocate .DA DS.END-DS.START DS
.DA 0 .DA #64 SS
.DA #4 ZP SS
.DA 0 .DA 0
*-------------------------------------- *--------------------------------------
* Relocation Table * Relocation Table
@ -48,7 +49,7 @@ L.MSG.BYTE .DA MSG.BYTE
.DA 0 .DA 0
*-------------------------------------- *--------------------------------------
CS.INIT >LDYA L.LIBTCPIP CS.INIT >LDYA L.LIBTCPIP
>SYSCALL LoadLibYA >SYSCALL LoadLib.YA
sta hLIBTCPIP sta hLIBTCPIP
lda (pPs) lda (pPs)
@ -72,7 +73,7 @@ CS.RUN jsr Init.Timeout
>SLEEP >SLEEP
jsr Wait.Timeout jsr Wait.Timeout
bcc .1 bcc .1
>SYSCALL GetC >SYSCALL GetChar
bcs .1 bcs .1
cmp #$03 cmp #$03
bne .1 bne .1
@ -249,7 +250,7 @@ CS.QUIT ldx #CONN.MAX
>LIBCALL hLIBTCPIP,LIBTCPIP.SKT.CLOSEA >LIBCALL hLIBTCPIP,LIBTCPIP.SKT.CLOSEA
.3 lda hLIBTCPIP .3 lda hLIBTCPIP
>SYSCALL UnloadLibA >SYSCALL UnloadLib.A
clc clc
rts rts
*-------------------------------------- *--------------------------------------
@ -267,7 +268,7 @@ Wait.TimeOut sec
*-------------------------------------- *--------------------------------------
CS.END CS.END
*-------------------------------------- *--------------------------------------
LIBTCPIP >PSTR "libtcpip.o" LIBTCPIP .AZ "libtcpip.o"
MSG.TCPWAIT .AZ "TELNETD:Waiting for TCP/IP initializing...\r\n" MSG.TCPWAIT .AZ "TELNETD:Waiting for TCP/IP initializing...\r\n"
MSG.INITOK .AZ "TELNETD:Init Ok, Listening.\r\n" MSG.INITOK .AZ "TELNETD:Init Ok, Listening.\r\n"
MSG.TCPIPERR .AZ "TELNETD:TCP/IP Not initialized properly\r\n" MSG.TCPIPERR .AZ "TELNETD:TCP/IP Not initialized properly\r\n"

View File

@ -617,14 +617,22 @@ K.Rename jsr PFT.CheckPathSTK
>MLICALL MLIRENAME >MLICALL MLIRENAME
rts rts
*--------------------------------------
K.PrintF.PadL .BS 1
K.PrintF.PadC .BS 1
*--------------------------------------
*HEXBUF .BS 4
*BCDBUF .BS 5 5, enough to handle 10 digits (32bits)
HEXBUF .EQ FAC
BCDBUF .EQ ARG
*/-------------------------------------- */--------------------------------------
* # SScanF * # SScanF
* Scan a C-String (in progress) * Scan a C-String (in progress)
* ## In: * ## In:
* PUSHW PTR to target buffer * PUSHW PTR to target buffer
* PUSHW PSTR pattern (ex: "%d.%d.%d.%d") * PUSHW PTR pattern (ex: "%d.%d.%d.%d")
* %d : byte * %d : byte
* PUSHW PSTR to scan (ex: "192.168.1.5") * PUSHW PTR to String to scan (ex: "192.168.1.5")
* ## Out: * ## Out:
*\-------------------------------------- *\--------------------------------------
K.SScanF jsr MEM.PullP1P2P3 K.SScanF jsr MEM.PullP1P2P3
@ -762,7 +770,7 @@ K.SScanF.IncPtr1
*\-------------------------------------- *\--------------------------------------
K.SPrintF.YA K.SPrintF.YA
* >STYA ZPPtr1 * >STYA ZPPtr1
* >PULLW Printf.Cout.Ptr+1 * >PULLW STDIO.COut.Ptr+1
K.FPrintF.YA K.FPrintF.YA
* >STYA ZPPtr1 * >STYA ZPPtr1
@ -777,9 +785,9 @@ K.PrintF.YA >STYA ZPPtr1
cmp #'%' cmp #'%'
bne .10 bne .10
stz PADLEN stz K.PrintF.PadL
lda #' ' lda #' '
sta PADCHAR sta K.PrintF.PadC
.2 ldx #PrintFTBL2-PrintFTBL1-1 .2 ldx #PrintFTBL2-PrintFTBL1-1
lda (ZPPtr1),y lda (ZPPtr1),y
@ -794,11 +802,11 @@ K.PrintF.YA >STYA ZPPtr1
cmp #'0' ...a 0...mmm... padding char? cmp #'0' ...a 0...mmm... padding char?
bne .4 bne .4
ldx PADLEN PADLEN is not nul, so this 0 is second digit ldx K.PrintF.PadL K.PrintF.PadL is not nul, so this 0 is second digit
bne .5 bne .5
* lda #'0' * lda #'0'
sta PADCHAR no, this is the first 0, so make it PADCHAR sta K.PrintF.PadC no, this is the first 0, so make it K.PrintF.PadC
bra .2 bra .2
.4 jsr MEM.IsDigit .4 jsr MEM.IsDigit
@ -806,16 +814,16 @@ K.PrintF.YA >STYA ZPPtr1
.5 and #$0F we have a digit .5 and #$0F we have a digit
pha save it... pha save it...
lda PADLEN starts PADLEN * 10 lda K.PrintF.PadL starts K.PrintF.PadL * 10
asl asl
asl A=times 4 asl A=times 4
adc PADLEN CC by ASL, A=times 5 adc K.PrintF.PadL CC by ASL, A=times 5
asl times 10 asl times 10
sta PADLEN sta K.PrintF.PadL
pla get back digit pla get back digit
adc PADLEN adc K.PrintF.PadL
sta PADLEN sta K.PrintF.PadL
bra .2 go get next char... bra .2 go get next char...
.8 phy .8 phy
@ -843,7 +851,7 @@ K.PrintF.YA >STYA ZPPtr1
.13 lda PrintFTBL2.OUT,x .13 lda PrintFTBL2.OUT,x
.20 jsr Printf.Cout .20 jsr STDIO.COut
bcc .1 bcc .1
.99 rts .99 rts
*-------------------------------------- *--------------------------------------
@ -877,7 +885,7 @@ PrintF.B.1 ldx #8
pha pha
lda #'0' lda #'0'
adc #0 add Carry adc #0 add Carry
jsr Printf.Cout jsr STDIO.COut
pla pla
bcs PrintF.BB.RTS bcs PrintF.BB.RTS
dex dex
@ -918,11 +926,10 @@ PrintF.U clc unsigned long (DWORD)
dey dey
bpl .1 bpl .1
PrintF.U.1 bcc .8 unsigned, nothing to check PrintF.U.1 bcc PrintF.Hex2Dec unsigned, nothing to check
lda HEXBUF,x get sign lda HEXBUF,x get sign
bpl .8 bpl PrintF.Hex2Dec
* sec * sec
@ -937,8 +944,94 @@ PrintF.U.1 bcc .8 unsigned, nothing to check
bpl .1 bpl .1
sec tell to print a "-" sign.... sec tell to print a "-" sign....
*--------------------------------------
* Convert HEXBUF to ASCBUF decimal padded with 0
*--------------------------------------
PrintF.Hex2Dec ror .31+1
ldx #4
.1 stz BCDBUF,x Clear all 5 bytes
dex
bpl .1
.8 jmp HEX2DEC sed switch to BCD mode
ldx #32 let's roll 32 bits
.2 asl HEXBUF
rol HEXBUF+1
rol HEXBUF+2
rol HEXBUF+3
ldy #4
.3 lda BCDBUF,y
adc BCDBUF,y
sta BCDBUF,y
dey
bpl .3
dex
bne .2
cld
.31 bit #$ff SELF MODIFIED -sign to print before digits ?
bpl .9
lda #'-'
jsr STDIO.COut
.9 lda K.PrintF.PadL any Len format ?
beq .4 no
lda #10
sec yes, Print only digits starting at pos 10-K.PrintF.PadL
sbc K.PrintF.PadL
.4 tax x=0 if no K.PrintF.PadL, or x=10-K.PrintF.PadL
.5 txa X range 0 to 9
lsr CS if lo nibble (1,3,5,7,9)
tay
lda BCDBUF,y
bcs .6
lsr
lsr
lsr
lsr
.6 and #$0F
ora #$30
cmp #$30
beq .7 a zero?
inc K.PrintF.PadL found a non zero, Print all digits, even if 0, next time
ldy #'0'
sty K.PrintF.PadC
bra .8
.7 cpx #9 last digit ?
beq .8 Print always
ldy K.PrintF.PadL no pad to fill, do not Print 0
beq .10
lda K.PrintF.PadC fill with K.PrintF.PadC
.8 jsr STDIO.COut
bcs .99
.10 inx
cpx #10
bne .5
clc
.99 rts
*-------------------------------------- *--------------------------------------
* EXP(8) 1(s) 1significants(31) * EXP(8) 1(s) 1significants(31)
* http://apple2.org.za/gswv/a2zine/GS.WorldView/Resources/GS.TECH.INFO/AppleSoft/ * http://apple2.org.za/gswv/a2zine/GS.WorldView/Resources/GS.TECH.INFO/AppleSoft/
@ -958,7 +1051,7 @@ PrintF.F clc
beq .8 beq .8
phx phx
jsr Printf.Cout jsr STDIO.COut
plx plx
inx inx
bne .2 bne .2
@ -993,7 +1086,7 @@ PrintF.NN.2 ora #$30
cmp #$3A cmp #$3A
bcc .1 bcc .1
adc #6 adc #6
.1 jmp Printf.Cout .1 jmp STDIO.COut
*-------------------------------------- *--------------------------------------
PrintF.S ldy #$ff CSTR PrintF.S ldy #$ff CSTR
.HS 2C bit abs .HS 2C bit abs
@ -1018,25 +1111,25 @@ PrintF.SS ldy #$00 PSTR
lda (ZPPtr2),y lda (ZPPtr2),y
beq .2 beq .2
jsr Printf.Cout jsr STDIO.COut
bcs .9 bcs .9
lda PADLEN lda K.PrintF.PadL
beq .1 beq .1
cpy PADLEN cpy K.PrintF.PadL
bne .1 bne .1
clc clc
rts rts
.2 lda PADLEN .2 lda K.PrintF.PadL
beq .8 beq .8
.3 cpy PADLEN .3 cpy K.PrintF.PadL
beq .8 beq .8
lda PADCHAR lda K.PrintF.PadC
jsr Printf.Cout jsr STDIO.COut
bcs .9 bcs .9
iny iny
bne .3 bne .3
@ -1044,9 +1137,9 @@ PrintF.SS ldy #$00 PSTR
.8 clc .8 clc
.9 rts .9 rts
*-------------------------------------- *--------------------------------------
Printf.Cout jmp K.PutChar.A STDIO.COut jmp K.PutChar.A
*Printf.Cout.Ptr sta $ffff Self modified *STDIO.COut.Ptr sta $ffff Self modified
*-------------------------------------- *--------------------------------------
STDIO.PullMLIPath STDIO.PullMLIPath
>PULLYA >PULLYA
@ -1067,7 +1160,7 @@ STDIO.SetMLIPathYA
>STYA K.MLI.PARAMS+1 >STYA K.MLI.PARAMS+1
rts rts
*-------------------------------------- *--------------------------------------
STDIO.SetIOBUF >LDYAI 1024 get a ProDOS IOBUF STDIO.SetIOBUF >LDYAI 1024 get a ProDOS IOBUF
ldx #S.MEM.F.ALIGN+S.MEM.F.NOMOVE ldx #S.MEM.F.ALIGN+S.MEM.F.NOMOVE
jsr MEM.GetMem.YAX jsr MEM.GetMem.YAX
bcs .9 bcs .9
@ -1089,100 +1182,6 @@ STDIO.IOERR lda #MLI.E.IO
sec sec
rts rts
*-------------------------------------- *--------------------------------------
PADLEN .BS 1
PADCHAR .BS 1
*--------------------------------------
HEXBUF .BS 4
BCDBUF .BS 5 5, enough to handle 10 digits (32bits)
*--------------------------------------
* Convert HEXBUF to ASCBUF decimal padded with 0
*--------------------------------------
HEX2DEC ror .31+1
ldx #4
.1 stz BCDBUF,x Clear all 5 bytes
dex
bpl .1
sed switch to BCD mode
ldx #32 let's roll 32 bits
.2 asl HEXBUF
rol HEXBUF+1
rol HEXBUF+2
rol HEXBUF+3
ldy #4
.3 lda BCDBUF,y
adc BCDBUF,y
sta BCDBUF,y
dey
bpl .3
dex
bne .2
cld
.31 bit #$ff SELF MODIFIED -sign to print before digits ?
bpl .9
lda #'-'
jsr Printf.Cout
.9 lda PADLEN any Len format ?
beq .4 no
lda #10
sec yes, Print only digits starting at pos 10-padlen
sbc PADLEN
.4 tax x=0 if no padlen, or x=10-padlen
.5 txa X range 0 to 9
lsr CS if lo nibble (1,3,5,7,9)
tay
lda BCDBUF,y
bcs .6
lsr
lsr
lsr
lsr
.6 and #$0F
ora #$30
cmp #$30
beq .7 a zero?
inc PADLEN found a non zero, Print all digits, even if 0, next time
ldy #'0'
sty PADCHAR
bra .8
.7 cpx #9 last digit ?
beq .8 Print always
ldy PADLEN no pad to fill, do not Print 0
beq .10
lda PADCHAR fill with PADCHAR
.8 jsr Printf.Cout
bcs .99
.10 inx
cpx #10
bne .5
clc
.99 rts
*--------------------------------------
MAN MAN
SAVE /A2OSX.SRC/SYS/KERNEL.S.STDIO SAVE /A2OSX.SRC/SYS/KERNEL.S.STDIO
LOAD /A2OSX.SRC/SYS/KERNEL.S LOAD /A2OSX.SRC/SYS/KERNEL.S