Updates Related to new Soket API (coming soon!)

This commit is contained in:
Rémy GIBERT 2016-03-13 22:51:50 +01:00
parent 56e98b1fa3
commit b63c884fbd
5 changed files with 399 additions and 334 deletions

271
BIN/IPCONFIG.S.txt Normal file
View File

@ -0,0 +1,271 @@
PR#3
PREFIX /A2OSX.SRC
NEW
INC 1
AUTO 6
.LIST OFF
.OP 65C02
.OR $2000
.TF /A2OSX.BOOT/BIN/IPCONFIG
*--------------------------------------
.INB INC/MACROS.I
.INB INC/A2OSX.I
.INB INC/LIBSTR.I
.INB INC/LIBTCPIP.I
*--------------------------------------
ZPIPCfgPtr .EQ ZPBIN
ZPDevPtr .EQ ZPBIN+2
ZPDevInfoPtr .EQ ZPBIN+4
*--------------------------------------
* File Header (16 Bytes)
*--------------------------------------
CS.START cld
jmp (.1,x)
.DA #$61 6502,Level 1 (65c02)
.DA #1 BIN Layout Version 1
.DA 0
.DA CS.END-CS.START Code Length To Relocate
.DA 0 Data Segment to Allocate
.DA 0
.DA 0
*--------------------------------------
* Relocation Table
*--------------------------------------
.1 .DA CS.INIT
.DA CS.RUN
.DA CS.DOEVENT
.DA CS.QUIT
L.LIBSTR .DA LIBSTR
L.LIBTCPIP .DA LIBTCPIP
L.MSG0 .DA MSG0
L.MSG0.NL .DA MSG0.NL
L.MSG0.L .DA MSG0.L
L.MSG1.DEV .DA MSG1.DEV
L.MSG1.DEV.ARP .DA MSG1.DEV.ARP
L.MSG1.LINK .DA MSG1.LINK
L.MSG1.LINK.OK .DA MSG1.LINK.OK
L.MSG1.LINK.KO .DA MSG1.LINK.KO
L.MSG1.LINKSPEED .DA MSG1.LINKSPEED
L.MSG1.DPLX.FD .DA MSG1.DPLX.FD
L.MSG1.DPLX.HD .DA MSG1.DPLX.HD
L.MSG2 .DA MSG2
L.MSG2.C .DA MSG2.C
L.MSG2.U .DA MSG2.U
L.MSG2.DHCPSRVR .DA MSG2.DHCPSRVR
L.MSG2.IP .DA MSG2.IP
L.MSG2.GW .DA MSG2.GW
L.MSG2.DNS .DA MSG2.DNS
L.MSG2.HOSTNAME .DA MSG2.HOSTNAME
.DA 0
*--------------------------------------
CS.INIT >LDYA L.LIBSTR
>SYSCALL SYS.LoadLibYA
sta hLIBSTR
>LDYA L.LIBTCPIP
>SYSCALL SYS.LoadLibYA
sta hLIBTCPIP
>PUSHW L.MSG0
>LIBCALL hLIBSTR,LIBSTR.PRINTF
>LIBCALL hLIBTCPIP,LIBTCPIP.GET.IPCFG
>STYA ZPIPCfgPtr
ldy #S.IPCFG.HDEV
lda (ZPIPCfgPtr),y
bne CS.INIT.DUMPDEV
>PUSHW L.MSG0.NL
>LIBCALL hLIBSTR,LIBSTR.PRINTF
jmp CS.INIT.DONE
CS.INIT.DUMPDEV sta DevID
>SYSCALL SYS.GetDevByIDA
>STYA ZPDevPtr
lda DevID
>SYSCALL SYS.GetDevInfoA
>STYA ZPDevInfoPtr
>PUSHW L.MSG0.L
>LIBCALL hLIBSTR,LIBSTR.PRINTF
ldy #S.DEVINFO.NET.MAC+6
.1 dey
>PUSHB (ZPDevInfoPtr),y
cpy #S.DEVINFO.NET.MAC
bne .1
lda ZPDevPtr
clc
adc #S.DEV.NAME
tay
lda ZPDevPtr+1
adc #0
>PUSHYA
>PUSHB DevID
>PUSHW L.MSG1.DEV
>LIBCALL hLIBSTR,LIBSTR.PRINTF
ldy #S.DEVINFO.FLAGS
lda (ZPDevInfoPtr),y
and #S.DEVINFO.NET.FLAGS.ARPOFFLOAD
beq .2
lda #1
.2 >PUSHA
>PUSHW L.MSG1.DEV.ARP
>LIBCALL hLIBSTR,LIBSTR.PRINTF
ldy #S.DEVINFO.NET.STATUS
lda (ZPDevInfoPtr),y
and #S.DEVINFO.NET.STATUS.OK
bne CS.INIT.LINK
>PUSHW L.MSG1.LINK.KO
>PUSHW L.MSG1.LINK
>LIBCALL hLIBSTR,LIBSTR.PRINTF
bra CS.INIT.DUMPIP
CS.INIT.LINK >PUSHW L.MSG1.LINK.OK
>PUSHW L.MSG1.LINK
>LIBCALL hLIBSTR,LIBSTR.PRINTF
>PUSHW L.MSG1.LINKSPEED
>LIBCALL hLIBSTR,LIBSTR.PRINTF
ldy #S.DEVINFO.NET.STATUS
lda (ZPDevInfoPtr),y
and #$0F
tax
.4 phx
lda #'0'
>SYSCALL SYS.COutA
plx
dex
bne .4
ldy #S.DEVINFO.NET.STATUS
lda (ZPDevInfoPtr),y
and #S.DEVINFO.NET.STATUS.FD
bne .5
>PUSHW L.MSG1.DPLX.HD
bra .6
.5 >PUSHW L.MSG1.DPLX.FD
.6 >LIBCALL hLIBSTR,LIBSTR.PRINTF
CS.INIT.DUMPIP >PUSHW L.MSG2
>LIBCALL hLIBSTR,LIBSTR.PRINTF
lda (ZPIPCfgPtr)
and #S.IPCFG.STATUS.OK
beq .11
>LDYA L.MSG2.C
bra .10
.11 >LDYA L.MSG2.U
.10 >PUSHYA
>LIBCALL hLIBSTR,LIBSTR.PRINTF
ldy #S.IPCFG.DHCPSRVR+3
ldx #4
.2 >PUSHB (ZPIPCfgPtr),y
dey
dex
bne .2
>PUSHW L.MSG2.DHCPSRVR
>LIBCALL hLIBSTR,LIBSTR.PRINTF
ldy #S.IPCFG.IP+7 IP/MASK
ldx #8
.3 >PUSHB (ZPIPCfgPtr),y
dey
dex
bne .3
>PUSHW L.MSG2.IP
>LIBCALL hLIBSTR,LIBSTR.PRINTF
ldy #S.IPCFG.GW+3
ldx #4
.4 >PUSHB (ZPIPCfgPtr),y
dey
dex
bne .4
>PUSHW L.MSG2.GW
>LIBCALL hLIBSTR,LIBSTR.PRINTF
ldy #S.IPCFG.DNS1+7
ldx #8
.5 >PUSHB (ZPIPCfgPtr),y
dey
dex
bne .5
>PUSHW L.MSG2.DNS
>LIBCALL hLIBSTR,LIBSTR.PRINTF
lda ZPIPCfgPtr
clc
adc #S.IPCFG.DOMAIN
tay
lda ZPIPCfgPtr+1
adc #0
>PUSHYA
lda ZPIPCfgPtr
clc
adc #S.IPCFG.HOSTNAME
tay
lda ZPIPCfgPtr+1
adc #0
>PUSHYA
>PUSHW L.MSG2.HOSTNAME
>LIBCALL hLIBSTR,LIBSTR.PRINTF
CS.INIT.DONE lda #0 tell TSKMGR that all done ok, but
sec we do not want to stay in memory
rts
*--------------------------------------
CS.RUN
CS.DOEVENT clc
rts
*--------------------------------------
CS.QUIT lda hLIBTCPIP
>SYSCALL SYS.FreeMemA
lda hLIBSTR
>SYSCALL SYS.FreeMemA
clc
rts
*--------------------------------------
CS.END
LIBSTR >PSTRING "libstr.o"
LIBTCPIP >PSTRING "libtcpip.o"
*--------------------------------------
MSG0 >CSTRING "TCP/IP Status : "
MSG0.L >CSTRING "Loaded\n"
MSG0.NL >CSTRING "Not Loaded\n"
*--------------------------------------
MSG1.DEV >CSTRING "\nDevice Configuration :\n DevID : $%h\n Device Name : %s\n HW Address : %02h:%02h:%02h:%02h:%02h:%02h\n"
MSG1.DEV.ARP >CSTRING " ARP Offload : %d\n"
MSG1.LINK >CSTRING " Link Status : %s\n"
MSG1.LINK.OK >CSTRING "OK"
MSG1.LINK.KO >CSTRING "Media Disconnected"
MSG1.LINKSPEED >CSTRING " Link Speed : 1"
MSG1.DPLX.FD >CSTRING " Mbit/s,Full Duplex\n"
MSG1.DPLX.HD >CSTRING " Mbit/s,Half Duplex\n"
*--------------------------------------
MSG2 >CSTRING "\nIP Configuration : "
MSG2.C >CSTRING "Configured\n"
MSG2.U >CSTRING "Not Configured\n"
MSG2.DHCPSRVR >CSTRING " DHCP Server : %d.%d.%d.%d\n"
MSG2.IP >CSTRING " IP/Mask : %d.%d.%d.%d/%d.%d.%d.%d\n"
MSG2.GW >CSTRING " Gateway : %d.%d.%d.%d\n"
MSG2.DNS >CSTRING " DNS : %d.%d.%d.%d,%d.%d.%d.%d\n"
MSG2.HOSTNAME >CSTRING " Hostname : %s.%s\n"
hLIBSTR .BS 1
hLIBTCPIP .BS 1
DevID .BS 1
MAN
SAVE BIN/IPCONFIG.S
ASM

View File

@ -1,187 +0,0 @@
PR#3
PREFIX /A2OSX.SRC
NEW
INC 1
AUTO 6
.LIST OFF
.OP 65C02
.OR $2000
.TF /A2OSX.BOOT/BIN/NETINFO
*--------------------------------------
.INB INC/MACROS.I
.INB INC/A2OSX.I
.INB INC/LIBSTR.I
.INB INC/LIBTCPIP.I
*--------------------------------------
ZPIPCfgPtr .EQ ZPBIN
ZPDevInfoPtr .EQ ZPBIN+2
*--------------------------------------
* File Header (16 Bytes)
*--------------------------------------
CS.START cld
jmp (.1,x)
.DA #$61 6502,Level 1 (65c02)
.DA #1 BIN Layout Version 1
.DA 0
.DA CS.END-CS.START Code Length To Relocate
.DA 0 Data Segment to Allocate
.DA 0
.DA 0
*--------------------------------------
* Relocation Table
*--------------------------------------
.1 .DA CS.INIT
.DA CS.RUN
.DA CS.DOEVENT
.DA CS.QUIT
L.LIBSTR .DA LIBSTR
L.LIBTCPIP .DA LIBTCPIP
L.MSG0 .DA MSG0
L.MSG0.C .DA MSG0.C
L.MSG0.U .DA MSG0.U
L.MSG1.DEV .DA MSG1.DEV
L.MSG1.DHCPSRVR .DA MSG1.DHCPSRVR
L.MSG1.IP .DA MSG1.IP
L.MSG1.GW .DA MSG1.GW
L.MSG1.DNS .DA MSG1.DNS
L.MSG1.HOSTNAME .DA MSG1.HOSTNAME
L.MSG1.DOMAIN .DA MSG1.DOMAIN
.DA 0
*--------------------------------------
CS.INIT >LDYA L.LIBSTR
>SYSCALL SYS.LoadLibYA
sta hLIBSTR
>LDYA L.LIBTCPIP
>SYSCALL SYS.LoadLibYA
sta hLIBTCPIP
>PUSHW L.MSG0
>LIBCALL hLIBSTR,LIBSTR.PRINTF
>LIBCALL hLIBTCPIP,LIBTCPIP.GET.IPCFG
>STYA ZPIPCfgPtr
lda (ZPIPCfgPtr)
and #S.IPCFG.STATUS.OK
beq .11
>LDYA L.MSG0.C
bra .10
.11 >LDYA L.MSG0.U
.10 >PUSHYA
>LIBCALL hLIBSTR,LIBSTR.PRINTF
CS.INIT.PRINT ldy #S.IPCFG.MAC+6
.1 dey
>PUSHB (ZPIPCfgPtr),y
cpy #S.IPCFG.MAC
bne .1
ldy #S.IPCFG.hDEV
lda (ZPIPCfgPtr),y
>SYSCALL SYS.GetDevInfoA
>STYA ZPDevInfoPtr
ldy #S.DEVINFO.NET.STATUS
>PUSHB (ZPDevInfoPtr),y
ldy #S.IPCFG.hDEV
>PUSHB (ZPIPCfgPtr),y
>PUSHW L.MSG1.DEV
>LIBCALL hLIBSTR,LIBSTR.PRINTF
ldy #S.IPCFG.DHCPSRVR+3
ldx #4
.2 >PUSHB (ZPIPCfgPtr),y
dey
dex
bne .2
>PUSHW L.MSG1.DHCPSRVR
>LIBCALL hLIBSTR,LIBSTR.PRINTF
ldy #S.IPCFG.IP+7 IP/MASK
ldx #8
.3 >PUSHB (ZPIPCfgPtr),y
dey
dex
bne .3
>PUSHW L.MSG1.IP
>LIBCALL hLIBSTR,LIBSTR.PRINTF
ldy #S.IPCFG.GW+3
ldx #4
.4 >PUSHB (ZPIPCfgPtr),y
dey
dex
bne .4
>PUSHW L.MSG1.GW
>LIBCALL hLIBSTR,LIBSTR.PRINTF
ldy #S.IPCFG.DNS1+7
ldx #8
.5 >PUSHB (ZPIPCfgPtr),y
dey
dex
bne .5
>PUSHW L.MSG1.DNS
>LIBCALL hLIBSTR,LIBSTR.PRINTF
lda ZPIPCfgPtr
clc
adc #S.IPCFG.HOSTNAME
tay
lda ZPIPCfgPtr+1
adc #0
>PUSHYA
>PUSHW L.MSG1.HOSTNAME
>LIBCALL hLIBSTR,LIBSTR.PRINTF
ldy #S.IPCFG.DOMAIN
lda (ZPIPCfgPtr),y
beq CS.INIT.DONE
lda ZPIPCfgPtr
clc
adc #S.IPCFG.DOMAIN
tay
lda ZPIPCfgPtr+1
adc #0
>PUSHYA
>PUSHW L.MSG1.DOMAIN
>LIBCALL hLIBSTR,LIBSTR.PRINTF
CS.INIT.DONE lda #0 tell TSKMGR that all done ok, but
sec we do not want to stay in memory
rts
*--------------------------------------
CS.RUN
CS.DOEVENT clc
rts
*--------------------------------------
CS.QUIT lda hLIBTCPIP
>SYSCALL SYS.FreeMemA
lda hLIBSTR
>SYSCALL SYS.FreeMemA
clc
rts
*--------------------------------------
CS.END
LIBSTR >PSTRING "libstr.o"
LIBTCPIP >PSTRING "libtcpip.o"
MSG0 >CSTRING "TCP/IP Status: "
MSG0.C >CSTRING "Configured.\n"
MSG0.U >CSTRING "Not Configured.\n"
MSG1.DEV >CSTRING " DeviceID : %h,%b,MAC=%02h:%02h:%02h:%02h:%02h:%02h\n"
MSG1.DHCPSRVR >CSTRING " DHCP Server : %d.%d.%d.%d\n"
MSG1.IP >CSTRING " IP/Mask : %d.%d.%d.%d/%d.%d.%d.%d\n"
MSG1.GW >CSTRING " Gateway : %d.%d.%d.%d\n"
MSG1.DNS >CSTRING " DNS : %d.%d.%d.%d,%d.%d.%d.%d\n"
MSG1.HOSTNAME >CSTRING " Hostname : %s"
MSG1.DOMAIN >CSTRING ".%s\n"
hLIBSTR .BS 1
hLIBTCPIP .BS 1
MAN
SAVE BIN/NETINFO.S
ASM

View File

@ -13,7 +13,7 @@ AUTO 6
.INB INC/LIBSTR.I
.INB INC/LIBTCPIP.I
*--------------------------------------
PING.TIMEOUT .EQ 40 40*100ms = 4 sec.
TIMEOUT.MAX .EQ 50 5 sec.
*--------------------------------------
ZPFrameBase1 .EQ ZPBIN
ZPFrameLen1 .EQ ZPBIN+2
@ -38,7 +38,6 @@ CS.START cld
.DA CS.QUIT
L.LIBSTR .DA LIBSTR
L.LIBTCPIP .DA LIBTCPIP
L.SSCANF.IP .DA SSCANF.IP
L.MSG0 .DA MSG0
L.MSG1 .DA MSG1
L.MSG2 .DA MSG2
@ -91,31 +90,18 @@ CS.INIT ldy #S.PS.hARGS
.9 rts
*--------------------------------------
CS.RUN >PUSHW pData DST.IP
>PUSHW L.SSCANF.IP
CS.RUN jsr Init.Timeout
.1 >PUSHW pData DST.IP
ldy #S.PS.hARGS
lda (pPs),y
>SYSCALL SYS.GetMemPtrA
>PUSHYA
>LIBCALL hLIBSTR,LIBSTR.SSCANF
bcc CS.RUN.IPOK
lda #PING.TIMEOUT
ldy #TimeOut
sta (pData),y
CS.RUN.DNSQUERY >PUSHW pData DST.IP
ldy #S.PS.hARGS
lda (pPs),y
>SYSCALL SYS.GetMemPtrA
>PUSHYA
>LIBCALL hLIBTCPIP,LIBTCPIP.DNS.QUERY
bcc CS.RUN.IPOK
>LIBCALL hLIBTCPIP,LIBTCPIP.HST.GETBYNAME
bcc .2
>SYSCALL SYS.Sleep
ldy #TimeOut
lda (pData),y
bne CS.RUN.DNSQUERY
jsr Wait.Timeout
bcc .1
ldy #S.PS.hARGS
lda (pPs),y
@ -123,14 +109,15 @@ CS.RUN.DNSQUERY >PUSHW pData DST.IP
>PUSHYA
>PUSHW L.MSG0
>LIBCALL hLIBSTR,LIBSTR.PRINTF
lda #1
sec
CS.RUN.RTS rts
rts
CS.RUN.IPOK ldy #S.PS.hARGS
.2 ldy #S.PS.hARGS
lda (pPs),y
>SYSCALL SYS.GetMemPtrA
>PUSHYA
ldy #3
>PUSHB (pData),y DST.IP+3
dey
@ -142,12 +129,17 @@ CS.RUN.IPOK ldy #S.PS.hARGS
>LIBCALL hLIBSTR,LIBSTR.PRINTF
CS.RUN.ECHO >LIBCALL hLIBTCPIP,LIBTCPIP.NEW.ICMP.FRAME
bcs CS.RUN.RTS
>STYA ZPFrameBase1
txa
ldy #hFrame
sta (pData),y
lda #S.ICMP+32-2
sta (ZPFrameBase1)
lda /S.ICMP+32-2
ldy #1
sta (ZPFrameBase1),y
ldx #3
ldy #0
.10 lda (pData),y
@ -200,21 +192,28 @@ CS.RUN.ECHO >LIBCALL hLIBTCPIP,LIBTCPIP.NEW.ICMP.FRAME
txa
sta (ZPFrameBase1),y
lda #PING.TIMEOUT
ldy #TimeOut
sta (pData),y
ldx #31
ldy #S.ICMP+31
.21 txa
and #$0f
ora #$60
sta (ZPFrameBase1),y
dey
dex
bpl .21
.3 >PUSHWI S.ICMP+32
ldy #hFrame
jsr Init.Timeout
.3 ldy #hFrame
lda (pData),y
>SYSCALL SYS.GetMemPtrA
>PUSHYA
>LIBCALL hLIBTCPIP,LIBTCPIP.SEND.ICMP.FRAME
bcc .4
>SYSCALL SYS.Sleep
ldy #TimeOut
lda (pData),y
bne .3
jsr Wait.Timeout
bcc .3
.4 ldy #hFrame
lda (pData),y
@ -223,9 +222,8 @@ CS.RUN.ECHO >LIBCALL hLIBTCPIP,LIBTCPIP.NEW.ICMP.FRAME
ldy #bReply
lda #0
sta (pData),y
lda #PING.TIMEOUT
ldy #TimeOut
sta (pData),y
jsr Init.Timeout
CS.RUN.WAIT >SYSCALL SYS.Sleep
ldy #bReply
@ -235,9 +233,9 @@ CS.RUN.WAIT >SYSCALL SYS.Sleep
ldy #bCTRLC
lda (pData),y
bne CS.RUN.ERROR
ldy #TimeOut
lda (pData),y
bne CS.RUN.WAIT
jsr Wait.Timeout
bcc CS.RUN.WAIT
ldy #3
>PUSHB (pData),y DST.IP+3
@ -265,16 +263,15 @@ CS.RUN.ERROR sec
rts
*--------------------------------------
CS.DOEVENT lda (pEvent)
and #S.EVT.F.TIMER is it a TIMER event?
beq .1 no....
bpl .1 is it a TIMER event?
ldy #TimeOut
lda (pData),y
beq .10
beq .9
dec
sta (pData),y
.10 sec do not discard TIMER event
sec do not discard TIMER event
rts
.1 lda (pEvent)
@ -346,9 +343,10 @@ CS.DOEVENT lda (pEvent)
.9 sec
rts
*--------------------------------------
CS.EVENT.REPLY lda #PING.TIMEOUT
CS.EVENT.REPLY lda #TIMEOUT.MAX
sec
sbc TimeOut
ldy #TimeOut
sbc (pData),y
stz TimeOut.ms
stz TimeOut.ms+1
@ -358,7 +356,7 @@ CS.EVENT.REPLY lda #PING.TIMEOUT
.1 lda TimeOut.ms
clc
adc #K.TIMER16RESOLUTION*20
adc #100
sta TimeOut.ms
bcc .2
inc TimeOut
@ -399,10 +397,24 @@ CS.QUIT lda hLIBTCPIP
clc
rts
*--------------------------------------
Init.Timeout ldy #TimeOut
lda #TIMEOUT.MAX
sta (pData),y
rts
*--------------------------------------
Wait.TimeOut sec
ldy #TimeOut
lda (pData),y
beq .9
ldy #bCTRLC
lda (pData),y
bmi .9
clc
.9 rts
*--------------------------------------
CS.END
LIBSTR >PSTRING "libstr.o"
LIBTCPIP >PSTRING "libtcpip.o"
SSCANF.IP >PSTRING "%d.%d.%d.%d"
MSG0 >CSTRING "%S: Unknown host\n"
MSG1 >CSTRING "PING %d.%d.%d.%d (%S)\n"
MSG2 >CSTRING "%d.%d.%d.%d: TimeOut/Host unreachable\n"

View File

@ -6,7 +6,7 @@ AUTO 6
.LIST OFF
.OP 65C02
.OR $2000
.TF /A2OSX.BOOT/BIN/RPCINFO
.TF /A2OSX.BOOT/BIN/RPCDUMP
*--------------------------------------
.INB INC/MACROS.I
.INB INC/A2OSX.I
@ -135,7 +135,7 @@ CS.RUN jsr Init.Timeout
.5 ldy #hSocket
lda (pData),y
>LIBCALL hLIBTCPIP,LIBTCPIP.SKT.RCVD
>LIBCALL hLIBTCPIP,LIBTCPIP.SKT.RCVDA
bcc .6
>SYSCALL SYS.Sleep
@ -168,8 +168,7 @@ CS.RUN jsr Init.Timeout
rts
*--------------------------------------
CS.DOEVENT lda (pEvent)
bit #S.EVT.F.TIMER is it a TIMER event?
beq .1 no....
bpl .1 is it a TIMER event?
ldy #TimeOut
lda (pData),y
@ -321,5 +320,5 @@ DS.END
.ED
*--------------------------------------
MAN
SAVE BIN/RPCINFO.S
SAVE BIN/RPCDUMP.S
ASM

View File

@ -12,6 +12,8 @@ AUTO 6
.INB INC/A2OSX.I
.INB INC/LIBSTR.I
*--------------------------------------
ZPPTR1 .EQ ZPBIN
*--------------------------------------
* File Header (16 Bytes)
*--------------------------------------
CS.START cld
@ -20,7 +22,7 @@ CS.START cld
.DA #1 BIN Layout Version 1
.DA 0
.DA CS.END-CS.START Code Length To Relocate
.DA 0
.DA DS.END-DS.START Data Segment to Allocate
.DA 0
.DA 0
*--------------------------------------
@ -28,19 +30,13 @@ CS.START cld
*--------------------------------------
.1 .DA CS.INIT
.DA CS.RUN
.DA CS.EVENT
.DA CS.DOEVENT
.DA CS.QUIT
L.LIBSTR .DA LIBSTR
L.MSG0 .DA MSG0
L.MSG1 .DA MSG1
L.MSG2 .DA MSG2
L.MSG3 .DA MSG3
L.SSCANF.IP .DA SSCANF.IP
L.PRINTF.IP .DA PRINTF.IP
L.DST.IP .DA DST.IP
L.TEST1 .DA TEST1
L.TEST2 .DA TEST2
L.TEST3 .DA TEST3
.DA 0
*--------------------------------------
CS.INIT >LDYA L.LIBSTR
@ -57,9 +53,9 @@ CS.INIT >LDYA L.LIBSTR
ldy #S.PS.hCS
lda (pPs),y
>SYSCALL SYS.GetMemByIDA
>STYA ZPQuickPtr1
>STYA ZPPTR1
ldy #S.MEM.BIN
lda (ZPQuickPtr1),y
lda (ZPPTR1),y
>SYSCALL SYS.GetMemPtrA
>PUSHYA
>PUSHW L.MSG1
@ -79,63 +75,67 @@ CS.INIT >LDYA L.LIBSTR
ldy #S.PS.hENV
lda (pPs),y
>SYSCALL SYS.GetMemPtrA
>STYA ZPBIN
>STYA ZPPTR1
.1 lda (ZPBIN)
.1 lda (ZPPTR1)
beq .2
>PUSHW ZPBIN
>PUSHW ZPPTR1
>PUSHW L.MSG3
>LIBCALL hLIBSTR,LIBSTR.PRINTF
lda (ZPBIN)
lda (ZPPTR1)
sec
adc ZPBIN
sta ZPBIN
adc ZPPTR1
sta ZPPTR1
bcc .1
inc ZPBIN+1
inc ZPPTR1+1
bra .1
.2 >PUSHW L.DST.IP
>PUSHW L.SSCANF.IP
>PUSHW L.TEST1
>LIBCALL hLIBSTR,LIBSTR.SSCANF
.2 ldy #bCTRLC
lda #0
sta (pData),y
>PUSHB DST.IP+3
>PUSHB DST.IP+2
>PUSHB DST.IP+1
>PUSHB DST.IP
>PUSHW L.PRINTF.IP
>LIBCALL hLIBSTR,LIBSTR.PRINTF
>PUSHW L.DST.IP
>PUSHW L.SSCANF.IP
>PUSHW L.TEST2
>LIBCALL hLIBSTR,LIBSTR.SSCANF
>PUSHB DST.IP+3
>PUSHB DST.IP+2
>PUSHB DST.IP+1
>PUSHB DST.IP
>PUSHW L.PRINTF.IP
>LIBCALL hLIBSTR,LIBSTR.PRINTF
>PUSHW L.DST.IP
>PUSHW L.SSCANF.IP
>PUSHW L.TEST3
>LIBCALL hLIBSTR,LIBSTR.SSCANF
>PUSHB DST.IP+3
>PUSHB DST.IP+2
>PUSHB DST.IP+1
>PUSHB DST.IP
>PUSHW L.PRINTF.IP
>LIBCALL hLIBSTR,LIBSTR.PRINTF
lda #0 tell TSKMGR that all done ok, but
sec we do not want to stay in memory
clc
rts
*--------------------------------------
CS.RUN
CS.EVENT clc
CS.RUN ldy #bCTRLC
lda (pData),y
beq .1
sec
rts
.1 clc
rts
*--------------------------------------
CS.DOEVENT lda (pEvent)
>DEBUG
bpl .1 is it a TIMER event?
ora #'T'
>SYSCALL SYS.COutA
bra .9
.1 bit #S.EVT.F.KEY is it a KEY event?
beq .9
ldy #S.EVT.DATAHI is it an O or SAPPLE key ?
lda (pEvent),y
bne .9
ldy #S.EVT.DATALO
lda (pEvent),y
cmp #$03 Ctrl-C
bne .8
lda #$FF
ldy #bCTRLC
sta (pData),y
.8 clc
rts
.9 sec
rts
*--------------------------------------
CS.QUIT lda hLIBSTR
@ -143,34 +143,6 @@ CS.QUIT lda hLIBSTR
clc
rts
*--------------------------------------
PRBYTE pha
lsr
lsr
lsr
lsr
ora #$B0
cmp #$BA
bcc .1
adc #6
.1 jsr COUT
pla
PRHEX and #$0F
ora #$B0
cmp #$BA
bcc COUT
adc #6
bra COUT
*--------------------------------------
CROUT lda #13
*--------------------------------------
COUT phx
phy
ldx #DEVMGR.COUT
jsr pDevJmp
ply
plx
rts
*--------------------------------------
CS.END
hLIBSTR .BS 1
LIBSTR >PSTRING "libstr.o"
@ -178,12 +150,10 @@ MSG0 >CSTRING "PREFIX=%S\n"
MSG1 >CSTRING "BIN={%S}\n"
MSG2 >CSTRING "CMD={%S},ARGS={%S}\nENV:\n"
MSG3 >CSTRING " %S\n"
TEST1 >PSTRING "198.168.1.1"
TEST2 >PSTRING "198.168.1.23"
TEST3 >PSTRING "198.168.1.4"
SSCANF.IP >PSTRING "%d.%d.%d.%d"
PRINTF.IP >CSTRING "IP=%d.%d.%d.%d\n"
DST.IP .BS 4
*--------------------------------------
DS.START
bCTRLC .BS 1
DS.END
*--------------------------------------
MAN
SAVE BIN/TEST.S