A2osX/SYS/KERNEL.S.EVT.txt
2015-06-03 20:30:57 +02:00

116 lines
2.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
.OP 65C02
*--------------------------------------
* S.EvtMgrInit
*--------------------------------------
S.EvtMgrInit stz EVTMGR.PENDING
clc
rts
*--------------------------------------
* GETEVENT :
* IN :
* OUT :
* CS = no event, A = ERROR
* 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
.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
eor EVTMGR.VBLSTATE
bpl .9 no change
sta EVTMGR.VBLSTATE save new
dec EVTMGR.FRAMECNT
bne .9
lda #K.TIMER16RESOLUTION
sta EVTMGR.FRAMECNT
inc A2osX.TIMER16
bne .1
inc A2osX.TIMER16+1
.1 lda #S.EVT.F.TIMER
.8 sta (pEvent)
clc
rts
.9 lda #0 error code=0
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
beq .9
lda (pEvent)
and #S.EVT.F.hMEM1
beq .1
ldy #S.EVT.DATALO
lda (pEvent),y
jsr S.FreeMemA
.1 lda (pEvent)
and #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
.9 rts
*--------------------------------------
EVTMGR.VBLSTATE .BS 1
EVTMGR.FRAMECNT .BS 1
EVTMGR.PENDING .BS 1
*--------------------------------------
MAN
SAVE SYS/KERNEL.S.EVT
LOAD SYS/KERNEL.S
ASM