A2osX/SYS/KERNEL.S.EVT.txt
2016-03-26 08:28:47 +01:00

190 lines
3.3 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

PR#3
PREFIX /A2OSX.SRC
NEW
INC 1
AUTO 6
.LIST OFF
*--------------------------------------
* S.EvtMgrInit
*--------------------------------------
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
* sta CLRIOUDIS
* sta ENBVBLIIC
.8 lda /EvtMgr.Table
sta pEvent+1
clc
rts
*--------------------------------------
* GETEVENT :
* IN :
* OUT :
* CS = no event, A = ERROR
* CC * event in YA
* (pEvent)
*--------------------------------------
S.GetEvents stz pEvent
stz EVTMGR.COUNT
lda VBL get VLINE status
tax
eor EVTMGR.VBLSTATE
bpl S.GetEvents.DEV no change,no tick
txa
sta EVTMGR.VBLSTATE save new
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 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
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
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
dec A2osX.RANDOM16+1
.99 sec no event
rts
*--------------------------------------
S.DestroyEvent lda (pEvent)
beq .9
bit #S.EVT.F.hMEM1
beq .1
pha
ldy #S.EVT.DATALO
lda (pEvent),y
jsr S.FreeMemA
pla
.1 bit #S.EVT.F.hMEM2
beq .2
ldy #S.EVT.DATAHI
lda (pEvent),y
jsr S.FreeMemA
.2 lda #0
sta (pEvent)
dec EVTMGR.COUNT
.9 rts
*--------------------------------------
EVTMGR.VBLSTATE .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
LOAD SYS/KERNEL.S
ASM