A2osX/SYS/KERNEL.S.EVT.txt

181 lines
3.7 KiB
Plaintext
Raw Normal View History

2015-03-14 21:48:35 +00:00
PR#3
2015-03-15 22:00:40 +00:00
PREFIX /A2OSX.BUILD
2015-03-14 21:48:35 +00:00
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
* (EVTMGR.EVTPTR)
*--------------------------------------
S.GetEvent lda EVTMGR.PENDING Get Pending EVENT hMem if any
beq .1
jsr S.GetMemPtrA
>STYA EVTMGR.EVTPTR
clc
rts
.1 jsr S.CreateEvent
bcs .9
stx EVTMGR.PENDING
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 .2 no change
sta EVTMGR.VBLSTATE save new
dec EVTMGR.FRAMECNT
bne .2
lda #K.TIMER16RESOLUTION
sta EVTMGR.FRAMECNT
inc A2osX.TIMER16
bne .1
inc A2osX.TIMER16+1
.1 lda #S.EVT.F.TIMER
sta (EVTMGR.EVTPTR)
clc
rts
.2 lda KBD
bpl .9
and #$7F
sta KBDSTROBE
ldy #S.EVT.DATA
sta (EVTMGR.EVTPTR),y
iny
lda OPENAPPLE
asl
lda SOLIDAPPLE
ror
and #$C0
sta (EVTMGR.EVTPTR),y
lda #S.EVT.F.KEY
sta (EVTMGR.EVTPTR)
ldy #S.EVT.hDEV
lda #1 Source dev = KBD
sta (EVTMGR.EVTPTR),y
clc
rts
.9 inc A2osX.RANDOM16
bne .99
inc A2osX.RANDOM16+1
.99 lda #0 error code=0
sec no event
rts
*--------------------------------------
S.GetDevEvent >LDYAI DEVMGR.TABLE
>STYA DEVMGR.DEVPTR
ldx #K.DEV.MAX
.1 lda (DEVMGR.DEVPTR) get S.DEV.F
bpl .3 empty ?
and #S.DEV.F.EVENT
beq .3 EVENT enabled ?
ldy #S.DEV.ID
lda (DEVMGR.DEVPTR),y
ldy #S.EVT.hDEV
sta (EVTMGR.EVTPTR),y
ldy #S.DEV.hCS
lda (DEVMGR.DEVPTR),y
jsr S.GetMemPtrA
>STYA Kernel.JMP
phx
>PUSHW EVTMGR.EVTPTR
ldx #DEVMGR.GETEVENT
jsr Kernel.DRVCALL Call DRV GetEvent function
plx
bcc .9 Got An Event
.3 lda DEVMGR.DEVPTR
clc
adc #S.DEV.SIZE
sta DEVMGR.DEVPTR
bcc .4
inc DEVMGR.DEVPTR+1
.4 dex
bne .1
lda #0 error code=0
sec no event
.9 rts
*--------------------------------------
* S.CreateEvent
* OUT :
* X = hMem
* Y,A = PTR to EVENT
*--------------------------------------
S.CreateEvent >PUSHWI S.EVT.SIZE
>PUSHBI 0
jsr S.GetMem
bcs .9
>STYA EVTMGR.EVTPTR
lda #0
ldy #S.EVT.SIZE-1
.1 sta (EVTMGR.EVTPTR),y
dey
bpl .1
clc
.9 rts
*--------------------------------------
S.DestroyEvent lda EVTMGR.PENDING
beq .9
jsr S.DestroyEventA
stz EVTMGR.PENDING
.9 rts
*--------------------------------------
* S.DestroyEvent
* IN :
* A = Event hMem
* OUT :
*--------------------------------------
S.DestroyEventA pha
jsr S.GetMemPtrA
>STYA EVTMGR.EVTPTR
lda (EVTMGR.EVTPTR)
and #S.EVT.F.hMEM1
beq .1
ldy #S.EVT.DATALO
lda (EVTMGR.EVTPTR),y
jsr S.FreeMemA
.1 lda (EVTMGR.EVTPTR)
and #S.EVT.F.hMEM2
beq .2
ldy #S.EVT.DATAHI
lda (EVTMGR.EVTPTR),y
jsr S.FreeMemA
.2 pla
jsr S.FreeMemA
rts
*--------------------------------------
EVTMGR.VBLSTATE .BS 1
EVTMGR.FRAMECNT .BS 1
EVTMGR.PENDING .BS 1
*--------------------------------------
MAN
SAVE SYS/KERNEL.S.EVT
LOAD SYS/KERNEL.S
ASM