KERNEL: New Event Handler

This commit is contained in:
Rémy GIBERT 2016-03-13 22:47:19 +01:00
parent d1974f0153
commit 625c15c81f
8 changed files with 232 additions and 203 deletions

View File

@ -102,8 +102,7 @@ S.LoadBinA sta S.LoadBinA.hFilename save file path
lda S.LoadBinA.hFilename get back bin path
jsr S.PStrCpyA
bcs .98
pha save copy of bin path
pha
lda S.LoadBinA.hMem
jsr S.GetMemByIDA
@ -112,9 +111,9 @@ S.LoadBinA sta S.LoadBinA.hFilename save file path
lda (ZPQuickPtr1)
ora #S.MEM.F.CODE This is a code segment
sta (ZPQuickPtr1)
pla
ldy #S.MEM.BIN
pla get back copy of bin path
sta (ZPQuickPtr1),y
lda S.LoadBinA.hMem

View File

@ -115,72 +115,8 @@ S.GetDevInfoA jsr S.GetDevByIDA
>STYA ZPQuickPtr1
ldx #DEVMGR.GETINFO
jmp (ZPQuickPtr1)
.9 rts
*--------------------------------------
S.GetDevEvent >LDYAI DevMgr.Table
>STYA pDev
stz DevMgr.DevID
.1 ldy #S.DEV.F
lda (pDev),y get S.DEV.F
and #S.DEV.F.EVENT
beq .2 EVENT enabled ?
ldx #DEVMGR.GETEVENT
jsr pDevJmp Call DRV GetEvent function
bcc .8 Got An Event
.2 lda pDev
clc
adc #S.DEV.SIZE
sta pDev
bcc .3
inc pDev+1
.3 lda DevMgr.DevID
inc DevMgr.DevID
cmp DevMgr.LastDevID
bne .1
lda #0 error code=0,CS=no event
sec
rts
.8 lda DevMgr.DevID Carry is alredy clear
ldy #S.EVT.hDEV
sta (pEvent),y
rts
*--------------------------------------
S.GetKeyboardEvent
lda KBD
bpl .9
sta KBDSTROBE
and #$7F
ldy #S.EVT.DATA
sta (pEvent),y
iny
lda OPENAPPLE
asl
lda SOLIDAPPLE
ror
and #$C0
sta (pEvent),y
lda #S.EVT.F.KEY
sta (pEvent)
clc
rts
.9 inc A2osX.RANDOM16
bne .99
inc A2osX.RANDOM16+1
.99 lda #0 error code=0
sec no event
rts
*--------------------------------------
DevMgr.Free .BS 2
DevMgr.DevID .BS 1
DevMgr.LastDevID .BS 1

View File

@ -7,7 +7,13 @@ AUTO 6
*--------------------------------------
* S.EvtMgrInit
*--------------------------------------
S.EvtMgrInit lda MACHID
S.EvtMgrInit lda #10
sta EVTMGR.10TH.CNT
lda A2osX.HZ
sta EVTMGR.HZ.CNT
lda MACHID
and #MACHID.TYPE
cmp #MACHID.TYPE.IIc
bne .8
@ -15,7 +21,8 @@ S.EvtMgrInit lda MACHID
* sta CLRIOUDIS
* sta ENBVBLIIC
.8 stz EVTMGR.PENDING
.8 lda /EvtMgr.Table
sta pEvent+1
clc
rts
*--------------------------------------
@ -26,97 +33,157 @@ S.EvtMgrInit lda MACHID
* CC * event in YA
* (pEvent)
*--------------------------------------
S.GetEvent lda EVTMGR.PENDING Get Pending EVENT hMem if any
beq .1
jsr S.GetMemPtrA
>STYA pEvent
clc
rts
S.GetEvents stz pEvent
stz EVTMGR.COUNT
.1 jsr S.CreateEvent
bcs .9
jsr S.GetSysEvent
bcc .9 got SYS event
jsr S.GetDevEvent
bcc .9 got DEV event
jsr S.DestroyEvent discard empty event
lda #0 error code=0
sec no event
.9 rts
*--------------------------------------
S.GetSysEvent lda VBL get VLINE status
lda VBL get VLINE status
tax
eor EVTMGR.VBLSTATE
bpl .9 no change
bpl S.GetEvents.DEV no change,no tick
txa
sta EVTMGR.VBLSTATE save new
dec EVTMGR.FRAMECNT
bne .9
lda #K.TIMER16RESOLUTION
sta EVTMGR.FRAMECNT
bpl S.GetEvents.DEV Up2down transition,no tick
* sta PDLTRIG clr VBL (IIc)
* lda RDIOUDIS clr VBL (IIc)
inc A2osX.TIMER16
bne .1
inc A2osX.TIMER16+1
.1 lda #S.EVT.F.TIMER
.1 dec EVTMGR.HZ.CNT
bne S.GetEvents.DEV not yet 100ms
ldx A2osX.HZ
stx EVTMGR.HZ.CNT
lda #S.EVT.F.T10TH
dec EVTMGR.10TH.CNT
bne .2
.8 sta (pEvent)
ldx #10
stx EVTMGR.10TH.CNT
ora #S.EVT.F.T1SEC
.2 sta (pEvent)
lda pEvent
clc
adc #S.EVT
sta pEvent
inc EVTMGR.COUNT
S.GetEvents.DEV >LDYAI DevMgr.Table
>STYA pDev
stz DevMgr.DevID
.1 ldy #S.DEV.F
lda (pDev),y get S.DEV.F
and #S.DEV.F.EVENT
beq .2 EVENT enabled ?
lda (pDev)
cmp #H.BIN.HEADER.DRV65
bne *
ldx #DEVMGR.GETEVENT
jsr pDevJmp Call DRV GetEvent function
bcs .2 no event
inc EVTMGR.COUNT
ldy #S.EVT.hDEV
lda DevMgr.DevID
sta (pEvent),y
lda pEvent
adc #S.EVT cc
sta pEvent
bcs .8 Event Q is full!
.2 lda pDev
clc
adc #S.DEV.SIZE
sta pDev
bcc .3
inc pDev+1
.3 lda DevMgr.DevID
inc DevMgr.DevID
cmp DevMgr.LastDevID
bne .1
.8 lda EVTMGR.COUNT
sta EVTMGR.SIZE
beq .9
clc
rts
.9 sec error code=0,CS=no event
rts
*--------------------------------------
S.GetKeyboardEvent
lda KBD
bpl .9
sta KBDSTROBE
sta A2osX.RANDOM16
and #$7F
ldy #S.EVT.DATA
sta (pEvent),y
iny
lda OPENAPPLE
asl
lda SOLIDAPPLE
ror
and #$C0
sta (pEvent),y
lda #S.EVT.F.KEY
sta (pEvent)
clc
rts
.9 sta PDLTRIG clr VBL (IIc)
* lda RDIOUDIS clr VBL (IIc)
lda #0 error code=0
sec no event
rts
.9 inc A2osX.RANDOM16
bne .99
inc A2osX.RANDOM16+1
.99 sec no event
rts
*--------------------------------------
* S.CreateEvent
* OUT :
* X = hMem
* Y,A = PTR to EVENT
*--------------------------------------
S.CreateEvent >PUSHWI S.EVT.SIZE
>PUSHBI S.MEM.F.INIT0
jsr S.GetMem
bcs .9
>STYA pEvent
stx EVTMGR.PENDING
.9 rts
*--------------------------------------
* S.DestroyEvent
* IN :
* A = Event hMem
* OUT :
*--------------------------------------
S.DestroyEvent lda EVTMGR.PENDING
S.DestroyEvent lda (pEvent)
beq .9
lda (pEvent)
and #S.EVT.F.hMEM1
bit #S.EVT.F.hMEM1
beq .1
pha
ldy #S.EVT.DATALO
lda (pEvent),y
jsr S.FreeMemA
pla
.1 lda (pEvent)
and #S.EVT.F.hMEM2
.1 bit #S.EVT.F.hMEM2
beq .2
ldy #S.EVT.DATAHI
lda (pEvent),y
jsr S.FreeMemA
.2 lda EVTMGR.PENDING
jsr S.FreeMemA
stz EVTMGR.PENDING
.2 lda #0
sta (pEvent)
dec EVTMGR.COUNT
.9 rts
*--------------------------------------
EVTMGR.VBLSTATE .BS 1
EVTMGR.FRAMECNT .BS 1
EVTMGR.PENDING .BS 1
EVTMGR.10TH.CNT .BS 1
EVTMGR.HZ.CNT .BS 1
EVTMGR.COUNT .BS 1
EVTMGR.SIZE .BS 1
*--------------------------------------
MAN
SAVE SYS/KERNEL.S.EVT

View File

@ -147,6 +147,10 @@ S.LoadFileYA jsr S.ExpandPStrYA
lda S.LoadFile.hBuf
jsr S.FreeMemA Discard ProDOS IO Buffer
lda S.LoadFile.hExp Discard Expanded String
jsr S.FreeMemA
>LDYA S.LoadFile.Len Return File Length...
ldx S.LoadFile.hMem ...and hMem to Caller
clc

View File

@ -11,22 +11,24 @@ AUTO 6
* Setup AuxLC $FFFE->Kernel IRQ Handler
* if irq not handled, jmp (S.IrqMgrOldFFFE)
*--------------------------------------
S.IrqMgrInit >LDYA $FFFE
S.IrqMgrInit php
sei
>LDYA $FFFE
cpy #S.IrqHandlerAuxLC
bne .1
cmp /S.IrqHandlerAuxLC
beq .8
beq .2
.1 php
sei
>STYA S.IrqMgrOldFFFE
.1 >STYA S.IrqMgrOldFFFE
>LDYAI S.IrqHandlerAuxLC
>STYA $FFFE
plp
.8 clc
.9 rts
.2 >LDYAI $BE0C
>STYA $3F0
plp
clc
rts
*--------------------------------------
S.IrqMgrQuit php
sei
@ -36,7 +38,8 @@ S.IrqMgrQuit php
cli
.8 rts
*--------------------------------------
S.BrkHandlerAuxLC
bra *
*--------------------------------------
* called directly by IRQ Vector $FFFE in AuxLC
* Must keep:

View File

@ -14,7 +14,6 @@ S.MLICreateFile >PULLW MLICALL.PARAMS+1
lda #$01
sta MLICALL.PARAMS+7 Storage=Standard Files
>MLICALL MLICREATE
clc
rts
*--------------------------------------
S.MLICreateDirA jsr S.GetMemPtrA

View File

@ -137,7 +137,11 @@ S.TskMgrRun >LDYAI TskMgr.Table+S.PS.SIZE
jsr S.TskMgrRunJmp
bra .4
.3 ldx #TSKMGR.RUN
.3 lda (pCode)
cmp #H.BIN.HEADER.BIN65
bne *
ldx #TSKMGR.RUN
jsr pCodeJmp Call RUN function
.4 bcc .5 RUN said CS=QUIT?
@ -173,7 +177,8 @@ S.TskMgrRunJmp jmp $FFFF
* CS: Not Dispatched
* CC: Event Cleared
*--------------------------------------
S.DispatchEvent >LDYAI TskMgr.Table+S.PS.SIZE
S.DispatchEvents
>LDYAI TskMgr.Table+S.PS.SIZE
>STYA pPs
lda #1
@ -181,42 +186,63 @@ S.DispatchEvent >LDYAI TskMgr.Table+S.PS.SIZE
.1 lda (pPs) get S.PS.F
and #S.PS.F.INUSE In use ?
beq .3
beq .4
lda (pPs) get S.PS.F
and #S.PS.F.HOLD Waiting for Another Task to Terminate?
bne .3
bne .4
lda (pPs) get S.PS.F
and #S.PS.F.EVENT Accept Events ?
beq .3
beq .4
jsr S.SelectProcess
stz pEvent
lda EVTMGR.SIZE
sta TSKMGR.EVENTCNT
.2 lda (pEvent)
beq .3
lda (pCode)
cmp #H.BIN.HEADER.BIN65
bne *
ldx #TSKMGR.DOEVENT
jsr pCodeJmp Call DOEVENT function
bcc .8
bcs .3
jsr S.DestroyEvent
lda EVTMGR.COUNT
beq .8
.3 dec TSKMGR.EVENTCNT
beq .4
lda pEvent
clc
adc #S.EVT
sta pEvent
bra .2
.3 lda pPs
.4 lda pPs
clc
adc #S.PS.SIZE
sta pPs
bcc .4
bcc .5
inc pPs+1
.4 lda TSKMGR.COUNT
.5 lda TSKMGR.COUNT
inc TSKMGR.COUNT
cmp TSKMGR.SIZE
bne .1
sec
rts
.8 jsr S.DestroyEvent
clc
.8 clc
rts
*--------------------------------------
* S.TskMgrQuit
*--------------------------------------
S.TskMgrQuit clc
rts
*--------------------------------------
@ -258,20 +284,6 @@ S.CreateProcessYA
S.CreateProcess stx S.CreateChildProcess.Flags
sta S.CreateProcessA.Cmd
sty S.CreateProcessA.Args
* lda #'|'
* jsr S.CoutA
* lda S.CreateProcessA.Cmd
* jsr S.PSTROutA
* lda #'|'
* jsr S.CoutA
* lda S.CreateProcessA.Args
* beq .1
* jsr S.PSTROutA
*.1 lda #'|'
* jsr S.CoutA
* lda #13
* jsr S.CoutA
jsr S.CreateChildProcess
bcs .99
@ -535,7 +547,11 @@ S.InitProcess lda S.CreateProcessA.Args
ldy #S.PS.hDS
sta (pPs),y save DS hMem in TSKSLOT
.2 ldx #TSKMGR.INIT
.2 lda (pCode)
cmp #H.BIN.HEADER.BIN65
bne *
ldx #TSKMGR.INIT
jsr pCodeJmp Call INIT function
.99 rts
@ -632,6 +648,7 @@ S.FreeProcessA jsr S.GetPSByIDA
*--------------------------------------
TSKMGR.SIZE .BS 1
TSKMGR.COUNT .BS 1
TSKMGR.EVENTCNT .BS 1
TSKMGR.LASTID .BS 1
*--------------------------------------
MAN

View File

@ -13,10 +13,10 @@ AUTO 6
.INB INC/IO.I
.INB INC/PRODOS.I
*--------------------------------------
ZPQuickPtr1 .EQ $0 Temp Ptrs for use in very limited scope
ZPQuickPtr2 .EQ $2 (could be trashed by any JSR)
ZPQuickPtr3 .EQ $4
ZPQuickPtr4 .EQ $6
ZPQuickPtr1 .EQ ZPKERNEL Temp Ptrs for use in very limited scope
ZPQuickPtr2 .EQ ZPKERNEL+2 (could be trashed by any JSR)
ZPQuickPtr3 .EQ ZPKERNEL+4
ZPQuickPtr4 .EQ ZPKERNEL+6
*--------------------------------------
* $D000-D0FF KERNEL.SYSCALL Jmp Table
*--------------------------------------
@ -210,11 +210,11 @@ Kernel.Init sei
>LDYAI STARTUP.ARGS Get A2osX.STARTUP full path...
jsr S.NewPStrYA
pha
>LDYAI STARTUP.CMD Get A2osX.STARTUP full path...
>LDYAI STARTUP.CMD Get SHELL full path...
jsr S.NewPStrYA
ply get back ARGS in Y
phy
pha A=CMH, save for discard
pha A=CMD, save for discard
jsr S.CreateProcessYA
bcs *
@ -228,29 +228,34 @@ Kernel.Init sei
jsr S.PSTROutYA
*--------------------------------------
S.KernelRun jsr S.TskMgrRun
bcs .98
bcc S.KernelRun.EVT
lda #A2osX.SCREENS.S
jsr S.ScreenSelectA
>LDYAI MSG.KRNLPANIC
jsr S.PSTROutYA
bra *
jsr S.GetEvent
S.KernelRun.EVT
jsr S.GetEvents
bcs S.KernelRun CS=no event
jsr S.DispatchEvent
bcc S.KernelRun CC=Event Dispatched
jsr S.DispatchEvents
bcc S.KernelRun CC=All Events Dispatched
lda (pEvent)
and #S.EVT.F.TIMER Discard any TIMER event
beq .1
jsr S.DestroyEvent
bra S.KernelRun
jsr S.SelectProcess0
stz pEvent
.1 jsr S.SelectProcess0
lda (pEvent)
and #S.EVT.F.KEY any special key?
beq .99
.1 lda (pEvent)
beq .81
bmi .8 Discard any timer eventa
bit #S.EVT.F.KEY any special key?
beq .7
ldy #S.EVT.DATAHI Open-Apple?
lda (pEvent),y
bpl .99
bpl .7
ldy #S.EVT.DATALO
lda (pEvent),y
@ -268,22 +273,21 @@ S.KernelRun jsr S.TskMgrRun
bra .8
.3 cmp #$33
bne .8
bne .7
lda #A2osX.SCREENS.G
jsr S.ScreenSelectA
bra .8
.7 jsr S.DumpEvent
.8 jsr S.DestroyEvent
bra S.KernelRun
.98 lda #A2osX.SCREENS.S
jsr S.ScreenSelectA
>LDYAI MSG.KRNLPANIC
jsr S.PSTROutYA
bra *
.99 jsr S.DumpEvent
jsr S.DestroyEvent
.81 lda pEvent
clc
adc #S.EVT
sta pEvent
lda EVTMGR.COUNT
bne .1
jmp S.KernelRun
*--------------------------------------
S.DumpEvent ldy #S.EVT.DATAW2+1