A2osX/SYS/KERNEL.S.CORE.txt

1071 lines
19 KiB
Plaintext
Raw Normal View History

2017-12-22 21:24:30 +00:00
NEW
2019-05-08 19:41:46 +00:00
AUTO 3,1
*--------------------------------------
2023-11-12 13:20:15 +00:00
GP.Sleep php
sei
phy
ldy #S.PS.A
sta (pPS),y
txa
iny #S.PS.X
sta (pPS),y
pla
iny #S.PS.Y
sta (pPS),y
pla
iny #S.PS.P
sta (pPS),y
pla get PC LO
plx get PC HI
inc Advance one byte because of return by RTI
bne GP.Sleep2
inx
GP.Sleep2 ldy #S.PS.PC
sta (pPS),y
txa
iny #S.PS.PC+1
sta (pPS),y
tsx
inx
inx keep PC HI,LO from KERNEL jsr PSExec/PSResume
inx Stack Ptr is $1ff if empty
txa
beq .3
tay Save !Byte count for later
.2 pla
>PUSHA
inx
bne .2
tya
.3 >PUSHA push CPU Stack BC to restore on top of Soft Stack
inc $1fe PC=PC+1
bne .4
inc $1ff because of RTI
.4 lda (pPS)
ora #S.PS.F.SLEEP
sta (pPS)
lda #0 cld,clc,cli
pha
rti exit to kernel with CC
*--------------------------------------
* *** MUST BE REINTRANT ***
*--------------------------------------
GP.SysCall dec IRQ.InKernel
pha
phy
ldy #S.PS.A
sta (pPS),y
txa
iny #S.PS.X
sta (pPS),y
pla
iny #S.PS.Y
sta (pPS),y
tay
pla
jsr JMP.2
bcc .2 no error quit...
tax CS,A=0 ?
beq .3 Yes, BLOCKING I/O
.2 inc IRQ.InKernel
rts Unmodified Carry
.3 sei
inc IRQ.InKernel
GO.Sleep2 pla get PC LO
plx get PC HI
* sec
sbc #2
bcs GP.Sleep2
dex
.1 bra GP.Sleep2
*--------------------------------------
GP.LibCall dec IRQ.InLib
pha
phy
ldy #S.PS.A
sta (pPS),y
txa
iny #S.PS.X
sta (pPS),y
pla
iny #S.PS.Y
sta (pPS),y
jsr K.GetMemPtr Get LIB Code Segment (MemMgr in $E000, no BNK change)
>STYA .1+1
pla
.1 jsr $FFFF SELF MODIFIED
bcc .2
tax
beq .3
.2 inc IRQ.InLib
rts
.3 sei
inc IRQ.InLib
bra GO.Sleep2
*--------------------------------------
GP.AtkCall dec IRQ.InKernel
>STYA .1
jsr GO.MainIC
jsr MLI
.DA #MLI.ATALK
.1 .DA *
jsr GO.AuxLC
inc IRQ.InKernel
rts
*/--------------------------------------
* # Add32,Sub32,Mul32,IMul32,Div32,IDiv32,Mod32,IMod32,Cmp32,ICmp32
* Return X+Y, X-Y, X*Y, X/Y, X mod Y....
* ## ASM
* `>PUSHL X (long)`
* `>PUSHL Y (long)`
* `>FPU add32`
* `...`
* ## RETURN VALUE
* On stack (long)
*\--------------------------------------
GP.FpuCall dec IRQ.InKernel
cpx #FPU.FMUL
bcs .1
jsr MATH math16 & math32, direct JMP
inc IRQ.InKernel
rts
.1 phx
jsr GP.SetFAC Get float from stack
plx
cpx #FPU.PWR+1
bcs GP.GetFAC
*/--------------------------------------
* # FAdd,FSub,FMul,FDiv,FPwr
* Return X*Y, X/Y, X+Y, X-Y
* ## C
* `float pwr ( float x, float y);`
* ## ASM
* `>PUSHF X (float)`
* `>PUSHF Y (float)`
* `>FPU fmul`
* `>FPU fdiv`
* `>FPU fmod` TODO
* `>FPU fadd`
* `>FPU fsub`
* `>FPU fpwr`
* ## RETURN VALUE
* On stack (float)
*\--------------------------------------
lda pStack
clc
adc #5
sta pStack
phx
jsr GP.SetARG
plx
*/--------------------------------------
* # Log,Sqr,Exp,Cos,Sin,Tan,ATan
* Return Log(x), Sqr(x), E^X, Cos(x), Sin(X), Tan(x), ATan(x)
* ## C
* `float log ( float x);`
* `float sqr ( float x);`
* `float exp ( float x);`
* `float cos ( float x);`
* `float sin ( float x);`
* `float tan ( float x);`
* `float atan ( float x);`
* ## ASM
* `>PUSHF x (Float)`
* `>FPU log`
* ## RETURN VALUE
* On stack (Float)
*\--------------------------------------
GP.GetFAC jsr GP.ROMCALL
lda pStack
ldy pStack+1
sta FORPNT Ptr to dst buffer
sty FORPNT+1
ldx #FPU.GETFAC
*--------------------------------------
GP.RomCall phx
ldx $D000
stx .8+1
bit IO.RROMBNK1
plx
jsr MATHF
.8 ldx #$ff
bit $C000,x
* bit $C000,x
rts
*--------------------------------------
GP.SetARG ldx #FPU.SETARG
.HS 2C BIT ABS
GP.SetFAC ldx #FPU.SETFAC
lda pStack
ldy pStack+1
bra GP.RomCall
*/--------------------------------------
* # float
* Return 'floated' long
* ## C
* `float f = (float)l;
* ## ASM
* `>PUSHL l` (long)
* `>FPU float`
* ## RETURN VALUE
* On stack (float)
*\--------------------------------------
GP.Float ldy #3
.1 lda (pStack),y
sta FAC+1,y Reverse Order
dey
bpl .1
dec pStack keep 5 bytes on stack
stz FAC.SIGN
lda #$80+32
sta FAC Positive + Exp=32
ldx #FPU.LTOF
bra GP.GetFAC
*/--------------------------------------
* # lrintf
* Return float rounded into a long
* ## C
* `long int lrintf (float x);`
* ## ASM
* `>PUSHF x`
* `>FPU lrintf`
* ## RETURN VALUE
* On stack (long)
*\--------------------------------------
GP.lrintf jsr GP.SetFAC
inc pStack keep 4 bytes on stack
ldx #FPU.QINT
jsr GP.ROMCALL
ldy #3
.1 lda FAC+1,y
sta (pStack),y
dey
bpl .1
rts
*--------------------------------------
* MLI : From Kernel Aux LC to Main LC
*--------------------------------------
GP.MLICall stx .1
sta K.MLI.PARAMS
jsr GO.MainIC
jsr MLI
.1 .BS 1
.DA K.MLI.PARAMS
jsr GO.AuxLC
rts
*--------------------------------------
GO.MainIC pha
lda $D000 We re coming from AUXLC, saving bank...
sta GO.AuxLC.BNK+1
pla
php
clc
.HS 2C BIT ABS
GO.AuxLC php
sec
sei
sta GO.EXIT.SaveA+1
stx GO.EXIT.SaveX+1
sty GO.EXIT.SaveY+1
pla Restore P in A for later
plx Get PC and add 1 for return
ply
inx
bne .1
iny
.1 stx GO.EXIT.JMP+1
sty GO.EXIT.JMP+2
bcs .2 if CS, go AUXLC
tsx
stx SaveSX
ldx SaveSM
txs
sta IO.CLRALTZP
ldx #IO.RRAMWRAMBNK1 Go MAINLC (ProDOS), always BNK1
bra GO.EXIT
.2 sta IO.SETALTZP
tsx
stx SaveSM
ldx SaveSX
txs
GO.AuxLC.BNK ldx #$FF Self Modified, initialized to BNK1 for INIT3
*--------------------------------------
GO.EXIT bit $C000,x Select Proper LC bank
* bit $C000,x
pha push P on stack
GO.EXIT.SaveY ldy #$ff
GO.EXIT.SaveX ldx #$ff
GO.EXIT.SaveA lda #$ff
plp
GO.EXIT.JMP jmp $FFFF SELF MODIFIED
*--------------------------------------
* Called from ProDOS IRQ Manager (LCBNK1)
* A,X,Y, $FA->$FF Already Saved
* Main RAM,ZP/LC selected
* must begin with CLD
* must exit with RTS
* - CC if IRQ cleared, CS if NOT
*--------------------------------------
GP.IRQ cld
bit IRQ.Skip After A2osX IRQ.H ?
bmi GP.IRQ.Exit
sta IO.SETALTZP switch to aux LC
tsx
stx SaveSM
ldx SaveSX
txs
GP.IRQ.JSR jsr CORE.IRQ.DEV SELF MODIFIED
tsx go back to Main
stx SaveSX
ldx SaveSM
txs
sta IO.CLRALTZP
rts
GP.IRQ.Exit stz IRQ.Skip reset flag
sec
rts
*--------------------------------------
*GO.Reset jsr GO.AuxLC
* jmp CORE.Run
*--------------------------------------
*BrkHandler bra *
*--------------------------------------
2020-09-24 15:31:48 +00:00
CORE.Run ldx #1
2018-10-15 15:39:21 +00:00
2020-09-24 15:31:48 +00:00
bra .80 Skip PS0
2020-09-22 15:34:51 +00:00
2020-09-24 06:24:47 +00:00
.1 stx CORE.PSIndex
2023-10-18 05:41:12 +00:00
lda PSs.hPS,x
beq .8
2020-09-22 15:34:51 +00:00
2018-06-21 15:12:10 +00:00
jsr K.GetMemPtr
>STYA pPs
2020-12-15 13:23:22 +00:00
lda (pPS) get S.PS.F
2019-07-22 16:28:44 +00:00
* bit #S.PS.F.HOLD Waiting for Another Task to Terminate?
* beq .2
bpl .2
2020-09-22 15:34:51 +00:00
ldy #S.PS.CPID
2020-02-28 07:21:46 +00:00
lda (pPS),y
2018-06-22 06:24:35 +00:00
jsr CORE.GetPS
bcc .8 yes, still running....
2020-09-22 15:34:51 +00:00
2020-02-28 07:21:46 +00:00
lda (pPS) get S.PS.F again
eor #S.PS.F.HOLD unmark as HOLD
2020-02-28 07:21:46 +00:00
sta (pPS)
2020-09-24 06:24:47 +00:00
2019-01-21 14:51:10 +00:00
.2 jsr CORE.PSSelect Restore ZP & Ptrs
.3 jsr CORE.PSExec INIT/RUN/QUIT/RESUME
dec IRQ.InKernel
2019-01-24 13:53:29 +00:00
bcc .4 INIT/RUN Exit ?
2021-04-29 11:56:34 +00:00
jsr CORE.UpdPPS Yes, go Update Parent PS
2020-09-22 15:34:51 +00:00
2019-07-22 16:28:44 +00:00
ldy #S.PS.S
2019-10-03 06:25:27 +00:00
lda #S.PS.S.QUIT
2020-02-28 07:21:46 +00:00
sta (pPS),y
2019-01-21 14:51:10 +00:00
bra .3 try executing QUIT now...
2020-09-22 15:34:51 +00:00
2020-02-28 07:21:46 +00:00
.4 lda (pPS)
bit #S.PS.F.SLEEP
bne .7
2020-09-22 15:34:51 +00:00
2019-07-22 16:28:44 +00:00
ldy #S.PS.S
2020-02-28 07:21:46 +00:00
lda (pPS),y
2019-07-22 16:28:44 +00:00
bne .5
2020-09-22 15:34:51 +00:00
2019-10-03 06:25:27 +00:00
lda #S.PS.S.RUN go from INIT to RUN
2020-02-28 07:21:46 +00:00
sta (pPS),y
bra .7
2020-09-22 15:34:51 +00:00
2019-10-03 06:25:27 +00:00
.5 cmp #S.PS.S.QUIT
2020-12-15 13:23:22 +00:00
bne .7
2020-09-22 15:34:51 +00:00
ldy #S.PS.PID
2020-02-28 07:21:46 +00:00
lda (pPS),y
2020-09-24 15:31:48 +00:00
cmp #1 INITD ?
bne .6
jmp CORE.Quit
2020-12-15 13:23:22 +00:00
2021-04-10 17:17:40 +00:00
.6 >PUSHA PID
>PUSHBI 2 SIG
>SYSCALL2 Kill
bra .8
2020-09-22 15:34:51 +00:00
.7 jsr CORE.PSLeave Save ZP & Ptrs
2020-09-22 15:34:51 +00:00
2020-09-24 06:24:47 +00:00
.8 ldx CORE.PSIndex
inx
2020-09-24 15:31:48 +00:00
.80 cpx CORE.PSCount
2019-10-03 06:25:27 +00:00
bne .1
*--------------------------------------
CORE.Events jsr CORE.GetEvents
bcs .4 CS=no event
2017-10-27 14:56:46 +00:00
jsr CORE.Dispatch
bcc .4 CC=All Events Dispatched
2023-10-18 05:41:12 +00:00
lda PSs.PID Select PS0
2019-01-24 13:53:29 +00:00
jsr K.GetMemPtr
>STYA pPs
>LDYAI K.STACKTOP
>STYA pStack
lda #K.S.EVT
sta pEvent
2021-05-14 20:58:20 +00:00
.1 lda (pEvent)
beq .3
2020-09-24 06:24:47 +00:00
2021-05-14 20:58:20 +00:00
bpl .3
2020-09-24 06:24:47 +00:00
2021-05-14 20:58:20 +00:00
jsr CORE.DestroyEvent Discard any timer event
.3 lda pEvent
clc
adc #S.EVT
sta pEvent
lda CORE.EvtCount
bne .1
2020-12-15 13:23:22 +00:00
*--------------------------------------
2023-11-04 14:42:28 +00:00
.4 bit IO.OPENAPPLE
bpl .8
2020-03-11 16:41:45 +00:00
2023-11-04 14:42:28 +00:00
lda IO.KBD
bpl .8
2020-03-11 16:41:45 +00:00
2018-12-10 16:45:37 +00:00
cmp #"0"
bcc .8
2020-03-11 16:41:45 +00:00
cmp #"9"+1
bcs .8
2020-03-11 16:41:45 +00:00
2023-11-04 14:42:28 +00:00
sta IO.KBDSTROBE
2021-07-24 20:42:23 +00:00
2019-04-25 15:33:56 +00:00
and #$0F
2020-03-12 07:46:43 +00:00
cmp A2osX.ASCREEN Same as active screen...nothing to do
2019-04-25 15:33:56 +00:00
beq .8
2020-12-15 13:23:22 +00:00
2021-07-24 20:42:23 +00:00
tax
lda A2osX.SCRNDEVS,x Get DevID
beq .8 No device claimed this screen
2020-02-16 20:45:16 +00:00
>PUSHA
2019-04-25 15:33:56 +00:00
>PUSHBI IOCTL.CONTROL request
2020-02-16 20:45:16 +00:00
>PUSHWZ Param
>SYSCALL2 IOCTL
.8 jmp CORE.Run
*--------------------------------------
2020-11-25 16:29:06 +00:00
CORE.Quit php
sei
jsr CORE.IRQOff
2020-11-25 16:29:06 +00:00
plp
2020-09-24 15:31:48 +00:00
lda IRQ.INTNUM
sta K.MLI.PARAMS+1
2020-12-15 13:23:22 +00:00
2023-11-04 14:42:28 +00:00
>MLICALL MLI.DEALLOCIRQ
2020-09-24 15:31:48 +00:00
2023-11-04 14:42:28 +00:00
bit IO.RDIOUDIS
sta IO.SETIOUDIS
sta IO.CLRDHIRES
bmi .1
2020-09-24 15:31:48 +00:00
2023-11-04 14:42:28 +00:00
sta IO.CLRIOUDIS
.1 ldx #5
.2 stz K.MLI.PARAMS+1,x
2020-09-24 15:31:48 +00:00
dex
bpl .2
2020-12-15 13:23:22 +00:00
2020-09-24 15:31:48 +00:00
lda #4
2023-11-04 14:42:28 +00:00
ldx #MLI.QUIT
2020-09-24 15:31:48 +00:00
jmp GP.MLICall
*--------------------------------------
2021-04-29 11:56:34 +00:00
CORE.UpdPPS tax save RC From INIT or RUN
2019-01-24 13:53:29 +00:00
ldy #S.PS.PPID Notify Parent Process for exit code...
2020-02-28 07:21:46 +00:00
lda (pPS),y
2019-01-24 13:53:29 +00:00
beq .8 no parent process
2020-09-24 06:24:47 +00:00
2019-01-24 13:53:29 +00:00
jsr CORE.GetPSByID X unmodified
bcs .8 parent is dead.....skipping...
>STYA ZPPtr1
2020-12-15 13:23:22 +00:00
lda (ZPPtr1) Parent PS is HOLD?
* bit #S.PS.F.HOLD
* beq .8 no...
bpl .8
2019-01-24 13:53:29 +00:00
ldy #S.PS.CPID
lda (ZPPtr1),y
dey #S.PS.PID
2020-02-28 07:21:46 +00:00
cmp (pPS),y
2019-01-24 13:53:29 +00:00
bne .8 Hold, but not waiting this PS
2020-09-24 06:24:47 +00:00
2019-01-24 13:53:29 +00:00
txa waiting for this PS to terminate....
ldy #S.PS.RC give it RC
sta (ZPPtr1),y
2019-01-24 13:53:29 +00:00
lda (ZPPtr1)
eor #S.PS.F.HOLD release Parent PS HOLD...
sta (ZPPtr1)
2020-09-24 06:24:47 +00:00
2019-10-03 06:25:27 +00:00
* clc
2020-09-24 06:24:47 +00:00
2019-01-24 13:53:29 +00:00
.8 rts
*--------------------------------------
* CORE.GetEvents :
* IN :
2020-12-15 13:23:22 +00:00
* OUT :
* CS = no event, A = ERROR
* CC * event in YA
* (pEvent)
*--------------------------------------
CORE.GetEvents lda #K.S.EVT
sta pEvent point to start of event list
stz CORE.EvtCount reset Size
2020-11-19 15:34:02 +00:00
bit A2osX.IRQMode do we have IRQ enabled for Ticks ?
bpl .1 no, regular poll
2020-11-19 15:34:02 +00:00
lda IRQ.Tick a Tick ?
beq .8 no, no event
2020-11-19 15:34:02 +00:00
dec IRQ.Tick
bra .2
2019-10-03 06:25:27 +00:00
2023-11-04 14:42:28 +00:00
.1 lda IO.VBL get VLINE status
tax
2020-12-15 13:23:22 +00:00
eor CORE.VBLState
bpl .8 no change,no tick
2020-11-19 15:34:02 +00:00
txa
sta CORE.VBLState save new
bpl .8 Up2down transition,no tick
2020-11-19 15:34:02 +00:00
.2 lda #0
dec CORE.TickSec
bne .3 not yet One Sec
2018-12-17 07:02:03 +00:00
lda IRQ.Mode
eor #$C0
2018-12-17 07:02:03 +00:00
sta IRQ.Mode
2021-07-24 20:42:23 +00:00
ldx A2osX.ASCREEN /DEV/CONSOLE
2018-12-17 07:02:03 +00:00
bne .22
2020-11-19 15:34:02 +00:00
sta SYS.BASL0+38
2020-11-19 15:34:02 +00:00
2018-12-17 07:02:03 +00:00
.22 ldx CORE.TickPerSec
stx CORE.TickSec
lda #S.EVT.F.T1SEC
bra .4 Force Resync T1 & T10...
.3 dec CORE.Tick10t
bne .6
2020-12-15 13:23:22 +00:00
2020-01-11 17:13:27 +00:00
.4 inc DevMgr.Timer
2023-11-12 13:20:15 +00:00
inc A2osX.T16
bne .5
2020-11-19 15:34:02 +00:00
2023-11-12 13:20:15 +00:00
inc A2osX.T16+1
.5 ldx CORE.TickPer10t
stx CORE.Tick10t
ora #S.EVT.F.T10TH
.6 tax Finally, do we have an event ?
beq .8 no....
2020-11-19 15:34:02 +00:00
sta (pEvent)
inc CORE.EvtCount Add one event to Queue
* lda pEvent
* clc
* adc #S.EVT
* sta pEvent if CS, EVT queue full!!! ($100)
* MORE EVENT PROCESSING HERE
.8 lda CORE.EvtCount if 0, exit with CS (from cmp), and A=0 "no event"
beq .9
2020-11-19 15:34:02 +00:00
clc
rts
2020-11-19 15:34:02 +00:00
.9 sec
rts
*--------------------------------------
2017-10-27 14:56:46 +00:00
* CORE.Dispatch
2020-12-15 13:23:22 +00:00
* IN:
* OUT:
* CS: Not Dispatched
2020-12-15 13:23:22 +00:00
* CC: Event Cleared
*--------------------------------------
2020-09-24 06:24:47 +00:00
CORE.Dispatch ldx #1 skip PS0
2020-09-24 15:31:48 +00:00
bra .80
2020-12-15 13:23:22 +00:00
2020-09-24 06:24:47 +00:00
.1 stx CORE.PSIndex
2023-10-18 05:41:12 +00:00
lda PSs.hPS,x
beq .5
2020-09-24 06:24:47 +00:00
2018-06-21 15:12:10 +00:00
jsr K.GetMemPtr
>STYA pPS
2020-12-15 13:23:22 +00:00
2020-02-28 07:21:46 +00:00
lda (pPS)
bit #S.PS.F.EVENT Accept Events ?
beq .5
2019-07-22 16:28:44 +00:00
ldy #S.PS.S
2020-02-28 07:21:46 +00:00
lda (pPS),y
2019-10-03 06:25:27 +00:00
cmp #S.PS.S.RUN
2019-07-22 16:28:44 +00:00
bne .5
2019-10-03 06:25:27 +00:00
lda #S.PS.S.DOEVENT Flag this PS for IRQ Mgr
2020-02-28 07:21:46 +00:00
sta (pPS),y
jsr CORE.PSSelect
lda #K.S.EVT
sta pEvent Select first event in list
lda CORE.EvtCount
sta CORE.EvtIndex
.2 lda (pEvent) Empty event, select next
beq .3
2021-02-17 16:15:43 +00:00
ldx #S.PS.S.DOEVENT
jsr CORE.PSExecX
dec IRQ.InKernel
bcs .3 not for this PS, try next event in list
jsr CORE.DestroyEvent this PS handled the EVT, destroy it...
lda CORE.EvtCount
beq .4 no more event, exit
.3 dec CORE.EvtIndex
beq .4 all EVT submitted to this PS, try other PS
2021-02-17 16:15:43 +00:00
lda pEvent try next EVT to this PS
clc
adc #S.EVT
sta pEvent
bra .2
2019-07-22 16:28:44 +00:00
.4 ldy #S.PS.S
2019-10-03 06:25:27 +00:00
lda #S.PS.S.RUN
2020-02-28 07:21:46 +00:00
sta (pPS),y
2019-07-22 16:28:44 +00:00
jsr CORE.PSLeave
2020-12-15 13:23:22 +00:00
2020-09-24 06:24:47 +00:00
.5 ldx CORE.PSIndex
inx
2020-09-24 15:31:48 +00:00
.80 cpx CORE.PSCount
bne .1
2020-12-15 13:23:22 +00:00
2019-04-15 15:29:07 +00:00
* sec
2020-09-24 15:31:48 +00:00
rts
*--------------------------------------
2018-10-15 15:39:21 +00:00
* X unmodified
*--------------------------------------
2019-01-24 13:53:29 +00:00
CORE.GetPSByID jsr CORE.GetPS
2021-05-04 17:31:21 +00:00
bcs .9
2021-04-29 11:56:34 +00:00
2023-10-18 05:41:12 +00:00
lda PSs.hPS,y
2018-06-21 15:12:10 +00:00
jmp K.GetMemPtr
2021-05-04 17:31:21 +00:00
.9 rts
2018-10-17 15:31:29 +00:00
*--------------------------------------
* X,A unmodified
*--------------------------------------
2019-01-24 13:53:29 +00:00
CORE.GetPS tay
2021-04-29 11:56:34 +00:00
beq .8 PS0 requested
2019-01-24 13:53:29 +00:00
ldy #0
bra .2 Skip PS0
2021-04-29 11:56:34 +00:00
2023-10-18 05:41:12 +00:00
.1 cmp PSs.PID,y
2021-04-29 11:56:34 +00:00
beq .8
2019-01-24 13:53:29 +00:00
.2 iny
2018-10-23 15:36:57 +00:00
cpy CORE.PSCount
bne .1
2021-04-29 11:56:34 +00:00
2018-10-21 20:54:07 +00:00
.9 lda #E.NSP
2018-10-15 15:39:21 +00:00
* sec
2019-01-26 14:01:05 +00:00
rts
2021-04-29 11:56:34 +00:00
.8 clc
2021-05-04 17:31:21 +00:00
rts
*--------------------------------------
CORE.DestroyEvent
lda (pEvent)
beq .9
2020-12-15 13:23:22 +00:00
bit #S.EVT.F.hMEM1
beq .1
pha
ldy #S.EVT.B1
lda (pEvent),y
2018-06-21 15:12:10 +00:00
jsr K.FreeMem
pla
.1 bit #S.EVT.F.hMEM2
beq .2
ldy #S.EVT.B2
lda (pEvent),y
2018-06-21 15:12:10 +00:00
jsr K.FreeMem
.2 lda #0
sta (pEvent)
dec CORE.EvtCount
.9 rts
*--------------------------------------
2020-02-04 14:35:48 +00:00
CORE.PSSelect ldy #S.PS.ZP.CODE+PSCTX.SIZE-1
2019-07-18 15:55:43 +00:00
ldx #PSCTX.SIZE-1
2020-02-28 07:21:46 +00:00
.1 lda (pPS),y
2020-02-04 14:35:48 +00:00
sta pCode,x
dey
dex
bpl .1
2020-12-15 13:23:22 +00:00
rts
*--------------------------------------
2020-02-04 14:35:48 +00:00
CORE.PSLeave ldx #PSCTX.SIZE-1
ldy #S.PS.ZP.CODE+PSCTX.SIZE-1
2020-12-15 13:23:22 +00:00
2020-02-04 14:35:48 +00:00
.1 lda pCode,x
2020-02-28 07:21:46 +00:00
sta (pPS),y
dey
dex
bpl .1
2021-01-17 21:48:54 +00:00
rts
*--------------------------------------
2019-01-21 14:51:10 +00:00
CORE.PSExec lda (pPS)
bit #S.PS.F.SLEEP
bne CORE.PSResume
2019-10-03 06:25:27 +00:00
2021-02-17 16:15:43 +00:00
ldy #S.PS.S
2019-07-22 16:28:44 +00:00
lda (pPS),y
tax
2021-02-17 16:15:43 +00:00
CORE.PSExecX lda pCode+1
pha
lda pCode
pha
php
sei
inc IRQ.InKernel
rti
*--------------------------------------
CORE.PSResume sei
eor #S.PS.F.SLEEP unmark as SLEEP
sta (pPS)
2020-12-15 13:23:22 +00:00
>PULLA Get !BC
tax
beq .2
.1 >PULLA
pha
inx
bne .1
2021-01-17 21:48:54 +00:00
.2 ldy #S.PS.PC+1
2020-02-28 07:21:46 +00:00
lda (pPS),y
pha
dey #S.PS.PC
2020-02-28 07:21:46 +00:00
lda (pPS),y
pha
dey #S.PS.P
2020-02-28 07:21:46 +00:00
lda (pPS),y
pha
dey #S.PS.Y
2020-02-28 07:21:46 +00:00
lda (pPS),y
pha
dey #S.PS.X
2020-02-28 07:21:46 +00:00
lda (pPS),y
tax
dey #S.PS.A
2020-02-28 07:21:46 +00:00
lda (pPS),y
ply
inc IRQ.InKernel
rti
*--------------------------------------
2020-02-16 20:45:16 +00:00
CORE.VBLState .BS 1
CORE.TickPerSec .BS 1
CORE.TickPer10t .BS 1
CORE.TickSec .BS 1
CORE.Tick10t .BS 1
CORE.CPUStatCnt .DA #100
CORE.LastPSID .DA #0
*--------------------------------------
2019-04-15 05:40:13 +00:00
CORE.EvtIndex .BS 1
CORE.EvtCount .BS 1
*--------------------------------------
* Called by IIgs formware, Native Mode, 8bits
2020-09-04 15:21:15 +00:00
*--------------------------------------
CORE.IRQGS .OP 65816
pha
phb
phx
phy
phk
plb
2020-12-15 13:23:22 +00:00
2023-11-04 14:42:28 +00:00
stz IO.GS.CLRVBLINT
2020-12-15 13:23:22 +00:00
jsr CORE.IRQ.Switch
ply
plx
plb
pla
* clc
rtl
* bra CORE.IRQ.Switch
.OP 65C02
2020-09-04 15:21:15 +00:00
*--------------------------------------
* Called by :
* - Kernel IRQ Manager (AuxLC)
* - ProDOS IRQ Manager (GP)
*--------------------------------------
CORE.IRQTK ldy IRQ.n0
2020-09-04 15:21:15 +00:00
lda $c080,y
and #$20
2020-09-24 15:31:48 +00:00
beq CORE.IRQ.DEV
2020-09-04 15:21:15 +00:00
lda $c088,y
lda $c080,y
2020-09-24 15:31:48 +00:00
bra CORE.IRQ.Switch
2020-09-04 15:21:15 +00:00
*--------------------------------------
CORE.IRQM jsr $FFFF SELF MODIFIED,SERVEMOUSE
2020-09-24 15:31:48 +00:00
bcs CORE.IRQ.DEV Not From Mouse
2020-09-25 12:05:23 +00:00
ldx IRQ.0n
2020-09-04 15:21:15 +00:00
lda MOUSESTSx,x
and #MOUSESTSx.INTVBL IRQ was caused by VBL ?
2020-09-24 15:31:48 +00:00
beq CORE.IRQ.DEV
ldx CORE.IRQM.2+2 $Cn
2020-09-25 12:05:23 +00:00
ldy IRQ.n0
2020-09-24 15:31:48 +00:00
CORE.IRQM.2 jsr $FFFF SELF MODIFIED,READMOUSE
2020-09-04 15:21:15 +00:00
*--------------------------------------
2020-09-24 15:31:48 +00:00
CORE.IRQ.Switch inc IRQ.Tick
2020-09-04 15:21:15 +00:00
dec CORE.CPUStatCnt
bne .2
lda #100
sta CORE.CPUStatCnt
ldx #K.PS.MAX-1
2023-10-18 05:41:12 +00:00
.1 lda PSs.Hits,x
stz PSs.Hits,x
sta PSs.Stats,x
2020-09-04 15:21:15 +00:00
dex
bpl .1
2020-12-15 13:23:22 +00:00
2020-09-04 15:21:15 +00:00
.2 lda IRQ.InKernel
bpl .3
2020-12-15 13:23:22 +00:00
2023-10-18 05:41:12 +00:00
inc PSs.Hits
2020-09-04 15:21:15 +00:00
.9 clv
clc
rts
.3 ldx CORE.PSIndex
2023-10-18 05:41:12 +00:00
inc PSs.Hits,x
2020-09-04 15:21:15 +00:00
bit A2osX.F A2osX.F.PMODE .EQ %01000000
bvc .8
ldy #S.PS.S
lda (pPS),y
eor #S.PS.S.RUN
bne .9
2021-05-15 14:35:24 +00:00
2020-09-04 15:21:15 +00:00
lda IRQ.InLib
bmi .9 we are in LIB, no switching
.8 clc exit with V flag set
rts
2020-12-15 13:23:22 +00:00
*--------------------------------------
2020-09-24 15:31:48 +00:00
CORE.IRQ.DEV ldx #0
2021-05-15 14:35:24 +00:00
2020-09-04 15:21:15 +00:00
.1 lda IRQ.Vectors+1,x
beq .9
2021-05-15 14:35:24 +00:00
2020-09-04 15:21:15 +00:00
sta .10+2
lda IRQ.Vectors,x
sta .10+1
2021-05-15 14:35:24 +00:00
2020-09-04 15:21:15 +00:00
phx
2021-05-15 14:35:24 +00:00
2020-09-04 15:21:15 +00:00
.10 jsr $ffff SELF MODIFIED
2021-05-15 14:35:24 +00:00
2020-09-04 15:21:15 +00:00
plx
bcc .8 CC, IRQ cleared by device
2021-05-15 14:35:24 +00:00
2020-09-04 15:21:15 +00:00
.2 inx
inx
.3 cpx #K.IRQDEV.MAX*2
bne .1
2021-05-15 14:35:24 +00:00
2020-09-04 15:21:15 +00:00
.9 sec
2021-05-15 14:35:24 +00:00
2020-09-04 15:21:15 +00:00
.8 clv clear V (no task switching)
rts
*--------------------------------------
CORE.IRQGSOff .OP 65816
clc
xce go to native mode
rep #$30 long M,X
pea $0003 Disable vertical blanking interrupts
>TKCALL IntSource
bcs *
pea $000C Vertical blanking interrupt handler
lda IRQ.GSVect+2
pha
lda IRQ.GSVect
pha
>TKCALL SetVector
bcs *
sep #$30 short M,X
sec
xce back to emulation mode
.OP 65C02
2020-09-24 15:31:48 +00:00
rts
2020-11-25 16:29:06 +00:00
*--------------------------------------
CORE.IRQTKOff ldx IRQ.n0
2020-09-24 15:31:48 +00:00
stz $c080,x
2020-12-15 13:23:22 +00:00
lda $c088,x
lda $c080,x
2020-09-25 12:05:23 +00:00
ldx IRQ.0n
2020-11-25 16:29:06 +00:00
stz $478,x
2020-12-15 13:23:22 +00:00
stz $7f8,x
2021-04-29 11:56:34 +00:00
*--------------------------------------
CORE.IRQOff rts
2020-11-25 16:29:06 +00:00
*--------------------------------------
CORE.IRQMOff ldy CORE.IRQMOff.1+2 Cn
2020-09-25 12:05:23 +00:00
ldy IRQ.n0
2020-09-24 15:31:48 +00:00
lda #0
CORE.IRQMOff.1 jmp $ffff SELF MODIFIED
2020-09-24 15:31:48 +00:00
*--------------------------------------
2020-08-23 19:46:37 +00:00
IRQ.InKernel .BS 1
IRQ.InLib .BS 1
2020-09-25 12:05:23 +00:00
IRQ.Skip .BS 1
2020-08-23 19:46:37 +00:00
IRQ.GSVect .BS 4
2020-08-23 19:46:37 +00:00
IRQ.IntNum .BS 1
2020-09-25 12:05:23 +00:00
IRQ.n0 .BS 1
IRQ.0n .BS 1
2020-08-23 19:46:37 +00:00
IRQ.Mode .BS 1
IRQ.Tick .BS 1
*--------------------------------------
2020-09-04 15:21:15 +00:00
IRQ.Vectors .BS K.IRQDEV.MAX*2
*--------------------------------------
MAN
2020-12-15 13:23:22 +00:00
SAVE usr/src/sys/kernel.s.core
LOAD usr/src/sys/kernel.s
ASM