PR#3
PREFIX /A2OSX.SRC
NEW
INC 1
AUTO 6
				.LIST OFF
*--------------------------------------
K.KernelRun		jsr TSK.TskMgrRun
				bcs .9

				jsr EVT.GetEvents
				bcs K.KernelRun			CS=no event

				jsr TSK.DispatchEvents
				bcc .4					CC=All Events Dispatched

				jsr PS.Select0

				stz pEvent
				
.1				lda (pEvent)
				beq .3
				
				bmi .2					Ignore & Discard any timer event
				
				ldy #S.EVT-1
				
.10				lda (pEvent),y
				>PUSHA
				dey
				bpl .10
				
				>LDYAI MSG.DumpEvent
				jsr K.PrintFYA

.2				jsr EVT.DestroyEvent

.3				lda pEvent
				clc
				adc #S.EVT
				sta pEvent
				lda EVTMGR.COUNT
				bne .1
				
.4				bit OPENAPPLE
				bpl K.KernelRun
				
				lda KBD
				inc A2osX.RANDOM16
				sta A2osX.RANDOM16+1
				
				bpl K.KernelRun
				
				cmp #"1"
				bcc K.KernelRun
				cmp #"5"
				bcs K.KernelRun
				
				sta KBDSTROBE

				and #$0F
				cmp A2osX.ASCREEN		Same as active screen...nothing to do
				beq K.KernelRun
				
				tax
				lda A2osX.SCRNDEVS-1,x	No device claimed this screen
				beq K.KernelRun

				jsr K.GetDevByIDA		x unmodified.....
				bcs K.KernelRun			??? 
				
				stx A2osX.ASCREEN
				
				>STYA pDev
				ldx #DEVMGR.SELECT
				jsr pDevJmp
				bra K.KernelRun
*--------------------------------------				
.9				jsr DevMgr.SYS.Select
				>LDYAI MSG.KRNLPANIC
				jsr	K.PrintFYA
				bra *
*--------------------------------------
MSG.DumpEvent	>CSTRING "!Unhandled Evt:F=%b,DevID=$%h,DATALO=$%h,DATAHI=$%h,W1=$%H,W2=$%H\n"
MSG.KRNLPANIC	>CSTRING "\n!!!Kernel Panic!!!\n"
*--------------------------------------
MAN
SAVE SYS/KERNEL.S.RUN
LOAD SYS/KERNEL.S
ASM
