A2osX/SYS/KERNEL.S.EVT.txt
2016-09-29 17:30:15 +02:00

172 lines
3.0 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
*--------------------------------------
K.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
*--------------------------------------
* EVT.GetEvents :
* IN :
* OUT :
* CS = no event, A = ERROR
* CC * event in YA
* (pEvent)
*--------------------------------------
EVT.GetEvents stz pEvent
stz EVTMGR.COUNT
lda VBL get VLINE status
tax
eor EVTMGR.VBLSTATE
bpl EVT.GetEvents.DEV no change,no tick
txa
sta EVTMGR.VBLSTATE save new
bpl EVT.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 EVT.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
*--------------------------------------
EVT.GetEvents.DEV
>LDYAI DevMgr.Table
>STYA pDev
stz DevMgr.DevID
.1 ldy #S.DEV.F
lda (pDev),y get S.DEV.F
bit #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
*--------------------------------------
EVT.DestroyEvent
lda (pEvent)
beq .9
bit #S.EVT.F.hMEM1
beq .1
pha
ldy #S.EVT.DATALO
lda (pEvent),y
jsr K.FreeMemA
pla
.1 bit #S.EVT.F.hMEM2
beq .2
ldy #S.EVT.DATAHI
lda (pEvent),y
jsr K.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