PR#3 PREFIX /A2OSX.SRC NEW INC 1 AUTO 6 .LIST OFF .OP 65C02 *-------------------------------------- DevMgr.HiMem .EQ $FFFE Protect IRQ vector in Aux LC *-------------------------------------- * S.DevMgrInit *-------------------------------------- S.DevMgrInit ldx #S.DEV.SIZE*2 .1 lda DevMgr.NUL-1,x sta DevMgr.Table-1,x dex bne .1 stz DevMgr.Table+S.DEV.SIZE*2+1 lda #1 reserve #0=NUL, #1=KBD sta DevMgr.LastDevID >LDYAI DevMgr.End >STYA DevMgr.Free clc rts *-------------------------------------- * S.GetDevByIDA * IN: * A = DevID * OUT: * CC = OK, CS = ERROR * Y,A = devslot * X Unmodified *-------------------------------------- S.GetDevByIDA cmp DevMgr.LastDevID beq .1 bcs .9 .1 stz S.GetDevByIDA.T asl ror S.GetDevByIDA.T asl ror S.GetDevByIDA.T asl ror S.GetDevByIDA.T asl ror S.GetDevByIDA.T adc #DevMgr.Table tay lda S.GetDevByIDA.T adc /DevMgr.Table rts CC .9 lda #DEVMGR.ERRDNF rts CS S.GetDevByIDA.T .BS 1 *-------------------------------------- * GetDevIDByNameA * IN: * A = hPStr * OUT: * CC = OK, CS = ERROR * X = DEVID * Y,A = pDev *-------------------------------------- S.GetDevByNameA jsr S.GetMemPtrA S.GetDevByNameYA >STYA ZPQuickPtr1 >LDYAI DevMgr.Table+S.DEV.NAME >STYA ZPQuickPtr2 ldx #0 .1 lda (ZPQuickPtr1) cmp (ZPQuickPtr2) bne .3 tay .2 lda (ZPQuickPtr1),y cmp (ZPQuickPtr2),y bne .3 dey bne .2 lda ZPQuickPtr2 sec sbc #S.DEV.NAME tay lda ZPQuickPtr2+1 sbc /S.DEV.NAME clc rts .3 lda ZPQuickPtr2 clc adc #S.DEV.SIZE sta ZPQuickPtr2 bcc .4 inc ZPQuickPtr2+1 .4 cpx DevMgr.LastDevID inx bcc .1 .9 lda #DEVMGR.ERRDNF rts *-------------------------------------- S.GetDevEvent >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 ? ldx #DEVMGR.GETEVENT jsr pDevJmp Call DRV GetEvent function bcc .8 Got An Event .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 lda #0 error code=0,CS=no event sec rts .8 lda DevMgr.DevID Carry is alredy clear ldy #S.EVT.hDEV sta (pEvent),y rts *-------------------------------------- DevMgr.Free .BS 2 DevMgr.DevID .BS 1 DevMgr.LastDevID .BS 1 *-------------------------------------- DevMgr.NUL cld jmp (DevMgr.NUL.Code,x) .DA #S.DEV.F.INUSE+S.DEV.F.SHARE+S.DEV.F.COUT+S.DEV.F.CHAR >PSTRING "NUL" NAME .HS 00 NAME must Be 5 bytes long .HS 00.00 .HS 00.00.00.00 *-------------------------------------- DevMgr.KBD cld jmp (DevMgr.KBD.Code,x) .DA #S.DEV.F.INUSE+S.DEV.F.EVENT+S.DEV.F.CHAR >PSTRING "KBD" NAME .HS 00 NAME must Be 5 bytes long .HS 00.00 .HS 00.00.00.00 *-------------------------------------- DevMgr.NUL.Code .DA .8 OPEN .DA .8 GETEVENT .DA .8 COUT .DA .8 CLOSE .DA .8 GETINFO .DA .8 IRQ .8 clc rts *-------------------------------------- DevMgr.KBD.Code .DA .8 OPEN .DA DevMgr.KBD.GETEVENT .DA .8 COUT .DA .8 CLOSE .DA .8 GETINFO .DA .8 IRQ .8 clc rts *-------------------------------------- DevMgr.KBD.GETEVENT 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 inc A2osX.RANDOM16+1 .99 lda #0 error code=0 sec no event rts *-------------------------------------- DevMgr.End .EQ * MAN SAVE SYS/KERNEL.S.DEV LOAD SYS/KERNEL.S ASM