Complete Rewrite #4 : keep it simple!!!

This commit is contained in:
Rémy GIBERT 2015-11-10 22:47:57 +01:00
parent d3a81e61dc
commit 36027b8d75
7 changed files with 193 additions and 275 deletions

View File

@ -188,9 +188,9 @@ DevMgr.NUL cld
.HS 00.00
.HS 00.00.00.00
*--------------------------------------
DevMgr.SYS cld
DevMgr.SYS cld #S.DEV.F.EVENT
jmp (DevMgr.SYS.Code,x)
.DA #S.DEV.F.INUSE+S.DEV.F.SHARE+S.DEV.F.COUT+S.DEV.F.CHAR
.DA #S.DEV.F.INUSE+S.DEV.F.EVENT+S.DEV.F.SHARE+S.DEV.F.COUT+S.DEV.F.CHAR
>PSTRING "SYS" NAME
.HS 00 NAME must Be 5 bytes long
.HS 00.00
@ -206,7 +206,7 @@ DevMgr.NUL.Code .DA .8 OPEN
rts
*--------------------------------------
DevMgr.SYS.Code .DA .8 OPEN
.DA .8 GETEVENT
.DA DevMgr.SYS.GetEvent
.DA .8 COUT
.DA .8 CLOSE
.DA .8 GETINFO
@ -214,6 +214,19 @@ DevMgr.SYS.Code .DA .8 OPEN
.8 clc
rts
*--------------------------------------
DevMgr.SYS.GetEvent
lda A2osX.ASCREEN
and #A2osX.SCREENS.S is screen active?
beq .9
jsr S.GetKeyboardEvent
bcs .9
rts
.9 lda #0 Error = no event
sec
rts
*--------------------------------------
DevMgr.End .EQ *
MAN
SAVE SYS/KERNEL.S.DEV

View File

@ -152,9 +152,9 @@ S.DupEnvA pha
* Out:
* A = hMem to VALUE (PSTRING) 0,"" if not exist
*--------------------------------------
S.GetEnvVarH jsr S.SelectEnvH
S.GetEnvVarH jsr S.FindVarH
bra S.GetEnvVar
S.GetEnvVarP jsr S.SelectEnvP
S.GetEnvVarP jsr S.FindVarP
S.GetEnvVar bcc .1
>LDYAI 1 not found
>PUSHYA create "" PSTR
@ -211,14 +211,14 @@ S.GetEnvVar bcc .1
* PULLW = PTR To Value (PSTRING)
* Out:
*--------------------------------------
S.SetEnvVarH jsr S.SelectEnvH
S.SetEnvVarH jsr S.FindVarH
php
>PULLA
jsr S.GetMemPtrA
>STYA ZPQuickPtr3 ZPQuickPtr3 = VALUE
bra S.SetEnvVar
S.SetEnvVarP jsr S.SelectEnvP
S.SetEnvVarP jsr S.FindVarP
php
>PULLW ZPQuickPtr3 ZPQuickPtr3 = VALUE
@ -304,14 +304,54 @@ S.SetEnvVar plp
sec
rts
*--------------------------------------
* S.DelEnvVarH
* In:
* PULLB = hENV
* PULLB = hMem To Name (PSTRING)
*--------------------------------------
* S.DelEnvVarP
* In:
* PULLB = hENV
* PULLW = PTR To Name (PSTRING)
* Out:
*--------------------------------------
S.DelEnvVarH jsr S.FindVarH
bra S.DelEnvVar
S.DelEnvVarP jsr S.FindVarP
S.DelEnvVar bcs .8 not found, quit
lda (ZPQuickPtr1) Found, Discard current NAME definition
sec
adc ZPQuickPtr1 add NAME=VALUE len+1 to ZPQuickPtr1
sta ZPQuickPtr4
lda #0
adc ZPQuickPtr1+1 store it in ZPQuickPtr4
sta ZPQuickPtr4+1
.1 lda (ZPQuickPtr4)
sta (ZPQuickPtr1)
beq .8 until we move ending 0
inc ZPQuickPtr1
bne .2
inc ZPQuickPtr1+1
.2 inc ZPQuickPtr4
bne .1
inc ZPQuickPtr4+1
bra .1
.8 clc
rts
*--------------------------------------
* PRIVATE
*--------------------------------------
* S.SelectEnvH
* S.FindVarH
* In:
* PULLB = hENV
* PULLB = hMem to NAME (PSTRING)
*--------------------------------------
* S.SelectEnvP
* S.FindVarP
* In:
* PULLB = hENV
* PULLW = PTR to NAME (PSTRING)
@ -324,20 +364,20 @@ S.SetEnvVar plp
* ZPQuickPtr1 -> PTR to Ending 0
* ZPQuickPtr2 -> NAME
*--------------------------------------
S.SelectEnvH >PULLA get ENV
S.FindVarH >PULLA get ENV
jsr S.GetMemPtrA
>STYA ZPQuickPtr1 Store ENV
>PULLA get NAME
jsr S.GetMemPtrA
>STYA ZPQuickPtr2 Store VAR Name
bra S.SelectEnv
bra S.FindVar
S.SelectEnvP >PULLA get ENV
S.FindVarP >PULLA get ENV
jsr S.GetMemPtrA
>STYA ZPQuickPtr1 Store ENV
>PULLW ZPQuickPtr2 get NAME
S.SelectEnv
S.FindVar
.1 lda (ZPQuickPtr1)
beq .9
ldy #0

View File

View File

@ -1,160 +0,0 @@
PR#3
PREFIX /A2OSX.SRC
NEW
INC 1
AUTO 6
.LIST OFF
.OP 65C02
*--------------------------------------
* S.NewBufRdr
* In :
* PULLB = DATA hMem
* PULLB = Delim Char
* PULLW = Size of DATA
* Out :
* A = hMem To newly created BufRdr
*--------------------------------------
* S.BUFRDR STRUCT
*--------------------------------------
S.BUFRDR.hMEM .EQ 0
S.BUFRDR.DELIM .EQ 1
S.BUFRDR.LEN .EQ 2
S.BUFRDR.IDX .EQ 4
*
S.BUFRDR.SIZE .EQ 6
*--------------------------------------
S.NewBufRdr >PUSHWI S.BUFRDR.SIZE
>PUSHBI 0 0 = no option
jsr S.GetMem
bcs .98
phx save hMem
>STYA ZPQuickPtr1
ldy #S.BUFRDR.hMEM
>PULLB (ZPQuickPtr1),y
ldy #S.BUFRDR.DELIM
>PULLB (ZPQuickPtr1),y
ldy #S.BUFRDR.LEN+1
>PULLB (ZPQuickPtr1),y
dey
>PULLB (ZPQuickPtr1),y
ldy #S.BUFRDR.IDX
lda #0
sta (ZPQuickPtr1),y
iny
sta (ZPQuickPtr1),y
pla
clc
rts
.98 pha
>PULLA
>PULLYA
pla
.99 rts
*--------------------------------------
* S.BufRdrReadA
* In :
* A = hMem To BufRdr
* Out :
* CC: Y,A = PTR to line (PSTR)
* CS: EOF
*--------------------------------------
S.BufRdrReadA jsr S.GetMemPtrA
>STYA ZPQuickPtr1
ldy #S.BUFRDR.hMEM
jsr S.GetMemPtrA
>STYA ZPQuickPtr2 PTR to DATA
ldy #S.BUFRDR.IDX
lda (ZPQuickPtr1),y
sta ZPQuickPtr3 IDX
clc
adc ZPQuickPtr2 PTR=PTR+IDX
sta ZPQuickPtr2
iny
lda (ZPQuickPtr1),y
sta ZPQuickPtr3+1
adc ZPQuickPtr2+1
sta ZPQuickPtr2+1
ldy #S.BUFRDR.LEN
lda (ZPQuickPtr1),y
sta ZPQuickPtr4
iny
lda (ZPQuickPtr1),y
sta ZPQuickPtr4+1
stz TmpBuffer256
ldy #S.BUFRDR.DELIM
.1 lda ZPQuickPtr4
bne .2
lda ZPQuickPtr4
beq .8
dec ZPQuickPtr4+1
.2 dec ZPQuickPtr4
lda (ZPQuickPtr2)
inc ZPQuickPtr2
bne .3
inc ZPQuickPtr2+1
.3 inc ZPQuickPtr3
bne .4
inc ZPQuickPtr3+1
.4 cmp (ZPQuickPtr1),y DELIM
beq .8
inc TmpBuffer256
beq .8
ldx TmpBuffer256
sta TmpBuffer256,x
bra .1
.8 lda TmpBuffer256
bne .81
sec
rts
.81 ldy #S.BUFRDR.IDX
lda ZPQuickPtr3
sta (ZPQuickPtr1),y
iny
lda ZPQuickPtr3+1
sta (ZPQuickPtr1),y
ldy #S.BUFRDR.LEN
lda ZPQuickPtr4
sta (ZPQuickPtr1),y
iny
lda ZPQuickPtr4+1
sta (ZPQuickPtr1),y
>LDYAI TmpBuffer256
clc
rts
*--------------------------------------
* S.BufRdrCloseA
* In :
* A = hMem To BufRdr
*--------------------------------------
S.BufRdrCloseA pha
jsr S.GetMemPtrA
>STYA S.BUFRDR.hMEM
ldy #S.BUFRDR.hMEM
lda (S.BUFRDR.hMEM),y
jsr S.FreeMemA
pla
jsr S.FreeMemA
clc
rts
*--------------------------------------
* PRIVATE
*--------------------------------------
MAN
SAVE SYS/KERNEL.S.RDR
LOAD SYS/KERNEL.S
ASM

View File

@ -47,70 +47,10 @@ S.SysScrInit stz SYSSCR.CPULOADI
clc
rts
*--------------------------------------
* S.ScreenSelectA
* IN :
* A = Screen to display
*--------------------------------------
S.ScreenSelectA and A2osX.SCREENS Screen is available ?
beq .9 ...not setup up
cmp #A2osX.SCREENS.S
bne .1
sta SETTEXT
sta SET80DISP
sta CLR80STORE
sta SETPAGE2
sta SETALTCHAR
lda #A2osX.SCREENS.S
bra .8
.1 cmp #A2osX.SCREENS.C
bne .2
sta SETTEXT
sta SET80DISP
sta CLR80STORE
sta CLRPAGE2
sta SETALTCHAR
lda #A2osX.SCREENS.C
bra .8
.2 cmp #A2osX.SCREENS.G
bne .9
sta CLRTEXT
sta CLRMIXED
sta SETHIRES
sta CLR80STORE
sta CLRPAGE2
sta SETIOUDIS
sta SETDHIRES
* sta CLR80DISP
* sta SETDHIRES
* sta CLRDHIRES
* sta SET80DISP
* sta SETDHIRES
* sta CLRDHIRES
* sta SETDHIRES
lda #A2osX.SCREENS.G
.8 sta A2osX.ASCREEN
.9 rts
*--------------------------------------
S.SysScrCPULoad ldx SYSSCR.CPULOADI
lda SYSSCR.CPULOADC,x
sta SYSSCR.BASL0+38
dec SYSSCR.CPULOADI
bpl .1
lda #3
sta SYSSCR.CPULOADI
.1 rts
*--------------------------------------
* S.SysScrPRCode
* In:
* CC : Prints [OK]
* CS : [$$] at column 36-39
* CS : [$$] at column 76-79
*--------------------------------------
S.SysScrPRCode php save P to keep carry
bcs .1

View File

@ -37,6 +37,15 @@ S.TskMgrInit stz TSKMGR.LASTID
>LDYAI TskMgr.Table Make PS #0 as current process
>STYA pPs
lda #0
ldy #S.PS.hINDEV
sta TskMgr.Table,y Make In DEV = NUL
inc
ldy #S.PS.hOUTDEV
sta TskMgr.Table,y Make OUT DEV = SYS
ldy #S.PS.hERRDEV
sta TskMgr.Table,y Make ERR DEV = SYS
jsr S.CreateEnv
bcs *
@ -322,6 +331,29 @@ S.GetPSByIDA sta S.GetPSByIDA.PS
*--------------------------------------
S.GetPSByIDA.PS .BS 1
*--------------------------------------
S.Sleep ldy #S.PS.hCS
lda (pPs),y
>SYSCALL SYS.GetMemPtrA
>STYA S.Sleep.SaveCS
ldy #S.PS.PC
pla get PC LO
plx get PC HI
inc Advance PC one Byte
bne .1
inx
.1 sec
sbc S.Sleep.SaveCS
sta (pPs),y
iny
txa
sbc S.Sleep.SaveCS+1
sta (pPs),y
clc No error,
rts back to Kernel
*--------------------------------------
S.Sleep.SaveCS .BS 2
*--------------------------------------
* PRIVATE
*--------------------------------------
* S.CreateChildProcess
@ -589,7 +621,7 @@ S.FreeProcessA jsr S.GetPSByIDA
jsr S.FreeMemA
lda (ZPQuickPtr1) get S.PS.F
and #S.PS.F.ENV do we have to dscard duplicated env & prefix ?
and #S.PS.F.ENV do we have to discard duplicated env & prefix ?
beq .4
.2 ldy #S.PS.hENV

View File

@ -9,17 +9,13 @@ AUTO 6
.TF /A2OSX.BOOT/SYS/KERNEL
*--------------------------------------
.INB INC/MACROS.I
.INB INC/KERNEL.I
.INB INC/A2OSX.I
.INB INC/A2OSX.API.I
.INB INC/IO.I
.INB INC/PRODOS.I
*--------------------------------------
KERNEL jmp S.KernelInit KERNEL.COLDBOOT
* $D000-D0FF KERNEL.SYSCALL Jmp Table
*--------------------------------------
jmp (.1,x) KERNEL.SYSCALL
*--------------------------------------
.1 .DA S.GetMem $00
.DA S.GetMem $00
.DA S.FreeMemA
.DA S.GetMemPtrA
.DA S.GetMemByIDA
@ -56,8 +52,8 @@ KERNEL jmp S.KernelInit KERNEL.COLDBOOT
.DA S.SetEnvVarH
.DA S.SetEnvVarP
.DA 0
.DA 0
.DA S.DelEnvVarH
.DA S.DelEnvVarP
*--------------------------------------
.DA S.MLICreateFile $40
.DA S.MLICreateDirA
@ -116,7 +112,7 @@ KERNEL jmp S.KernelInit KERNEL.COLDBOOT
.DA S.GetPSByIDA
.DA 0
.DA 0
.DA S.Sleep
.DA 0
*--------------------------------------
.DA S.CheckPrefixA $A0
@ -143,8 +139,40 @@ KERNEL jmp S.KernelInit KERNEL.COLDBOOT
.DA 0
.DA S.SysScrPPSTRA
.DA S.SysScrPPSTRYA
.DA 0
.DA 0
.DA 0
.DA 0
*--------------------------------------
S.KernelInit sei
.DA 0 $D0
.DA 0
.DA 0
.DA 0
.DA 0
.DA 0
.DA 0
.DA 0
*--------------------------------------
.DA 0 $E0
.DA 0
.DA 0
.DA 0
.DA 0
.DA 0
.DA 0
.DA 0
*--------------------------------------
.DA 0 $F0
.DA 0
.DA 0
.DA 0
.DA 0
.DA 0
.DA 0
.DA 0
*--------------------------------------
Kernel.Init sei
ldx #$FF init 6502 stack to highest
txs
stx A2osX.SaveSM
@ -157,9 +185,6 @@ S.KernelInit sei
stz A2osX.SCREENS
stz A2osX.ASCREEN
stz A2osX.CSCREEN.DEV
stz A2osX.GSCREEN.DEV
jsr S.SysScrInit
>LDYAI MSG.Init
@ -218,11 +243,6 @@ S.KernelInit sei
pla
jsr S.FreeMemA
>LDYAI MSG.Init.SysEnv
jsr S.SysScrPPSTRYA
jsr S.PrintSysEnv
.99 bcs *
>LDYAI MSG.Init.OK
@ -288,27 +308,61 @@ S.KernelRun jsr S.TskMgrRun
jsr S.DestroyEvent
jmp S.KernelRun
*--------------------------------------
S.PrintSysEnv ldy #S.PS.hENV
lda TskMgr.Table,y Get PS #0 ENV
jsr S.GetMemPtrA
>STYA R.AX
.1 lda (R.AX)
beq .8 Ending 0 ?
>LDYA R.AX
jsr S.SysScrPPSTRYA
jsr S.SysScrCROUT
lda R.AL
sec
adc (R.AX) Add len+1 to PTR
sta R.AL
bcc .1
inc R.AH
bra .1
.8 rts
* S.ScreenSelectA
* IN :
* A = Screen to display
*--------------------------------------
pDevJmp jmp (pDev)
pCodeJmp jmp (pCode)
pLibJmp jmp (pLib)
S.ScreenSelectA and A2osX.SCREENS Screen is available ?
beq .9 ...not setup up
cmp #A2osX.SCREENS.S
bne .1
sta SETTEXT
sta SET80DISP
sta CLR80STORE
sta SETPAGE2
sta SETALTCHAR
bra .8
.1 cmp #A2osX.SCREENS.C
bne .2
sta SETTEXT
sta SET80DISP
sta CLR80STORE
sta CLRPAGE2
sta SETALTCHAR
bra .8
.2 cmp #A2osX.SCREENS.G
bne .9
sta CLRTEXT
sta CLRMIXED
sta SETHIRES
sta CLR80STORE
sta CLRPAGE2
sta SETIOUDIS
sta SETDHIRES
* sta CLR80DISP
* sta SETDHIRES
* sta CLRDHIRES
* sta SET80DISP
* sta SETDHIRES
* sta CLRDHIRES
* sta SETDHIRES
.8 sta A2osX.ASCREEN
.9 rts
*--------------------------------------
S.SysScrCPULoad ldx SYSSCR.CPULOADI
lda SYSSCR.CPULOADC,x
sta SYSSCR.BASL0+38
dec SYSSCR.CPULOADI
bpl .1
lda #3
sta SYSSCR.CPULOADI
.1 rts
*--------------------------------------
MSG.Init >PSTRING "A2osX[Stage2]:Init\n"
MSG.Init.MemMgr >PSTRING "->MemMgr Init"
@ -316,7 +370,6 @@ MSG.Init.TskMgr >PSTRING "->TskMgr Init"
MSG.Init.DevMgr >PSTRING "->DevMgr Init"
MSG.Init.EvtMgr >PSTRING "->EvtMgr Init"
MSG.Init.Startup >PSTRING "EXEC A2osX.Startup...\n"
MSG.Init.SysEnv >PSTRING "SYS ENV:\n"
MSG.Init.OK >PSTRING "A2osX[Stage2]:Complete."
MSG.EVNTPANIC >PSTRING "\nEVT:F/hDev/DATA/W1/W2="
@ -337,7 +390,7 @@ ENV.LIB >PSTRING "LIB"
.INB SYS/KERNEL.S.DRV
.INB SYS/KERNEL.S.LIB
.INB SYS/KERNEL.S.NET
.INB SYS/KERNEL.S.RDR
* .INB SYS/KERNEL.S.RDR
.INB SYS/KERNEL.S.ENV
.INB SYS/KERNEL.S.TSK
.INB SYS/KERNEL.S.EVT