improve video-related interrupts and waits
This commit is contained in:
parent
7ccccbc06d
commit
b4f8be199f
2 changed files with 26 additions and 19 deletions
35
main.asm
35
main.asm
|
@ -69,6 +69,9 @@ Test3D:
|
|||
lli s1, 1 // s1: which color buffer we're writing to (1: alt)
|
||||
|
||||
Start3D:
|
||||
mfc0 t0, CP0_Status
|
||||
mtc0 t0, CP0_Status
|
||||
|
||||
lui a0, MAIN_BASE
|
||||
ori a0, MAIN_DLIST
|
||||
jal WriteDList
|
||||
|
@ -76,15 +79,13 @@ Start3D:
|
|||
jal PokeDataCache
|
||||
nop
|
||||
|
||||
ClearIntMask()
|
||||
DisableInt()
|
||||
|
||||
// prepare RSP
|
||||
lui a0, SP_BASE
|
||||
lli t0, SP_INT_ON_BREAK_SET | SP_TASKDONE_CLR | SP_YIELDED_CLR | SP_YIELD_CLR
|
||||
lli t0, SP_TASKDONE_CLR | SP_YIELDED_CLR | SP_YIELD_CLR | SP_HALT_SET
|
||||
sw t0, SP_STATUS(a0)
|
||||
|
||||
SP_HALT_WAIT()
|
||||
|
||||
// set RSP PC to IMEM+$0
|
||||
lui a0, SP_PC_BASE
|
||||
// only the lowest 12 bits are used, so 00000000 is equivalent to 04001000.
|
||||
|
@ -94,32 +95,36 @@ Start3D:
|
|||
jal PushVideoTask
|
||||
ori a0, MAIN_SP_TASK
|
||||
|
||||
SP_DMA_WAIT()
|
||||
|
||||
jal LoadRSPBoot
|
||||
nop
|
||||
|
||||
SP_DMA_WAIT()
|
||||
|
||||
// clear all flags that would halt RSP (i.e. tell it to run!)
|
||||
lui a0, SP_BASE
|
||||
lli t0, SP_INT_ON_BREAK_SET | SP_SINGLE_STEP_CLR | SP_BREAK_CLR | SP_HALT_CLR
|
||||
sw t0, SP_STATUS(a0)
|
||||
|
||||
SetIntMask()
|
||||
EnableInt()
|
||||
|
||||
MainLoop:
|
||||
WriteString(S_SP_Wait)
|
||||
SP_HALT_WAIT()
|
||||
-
|
||||
mfc0 t0, CP0_Status
|
||||
mtc0 t0, CP0_Status
|
||||
//
|
||||
lui a0, SP_BASE
|
||||
lw t0, SP_STATUS(a0)
|
||||
andi t0, SP_HALT
|
||||
beqz t0,-
|
||||
nop
|
||||
|
||||
WriteString(S_VI_Wait)
|
||||
// wait on VI too
|
||||
lui a0, VI_BASE
|
||||
-
|
||||
lui t0, VI_BASE
|
||||
lw t0, VI_V_CURRENT_LINE(t0)
|
||||
// until line <= 10
|
||||
sltiu t0, 10 + 1
|
||||
beqz t0,-
|
||||
lw t0, VI_V_CURRENT_LINE(a0)
|
||||
// until half-line <= 2
|
||||
sltiu at, t0, 2 + 1
|
||||
beqz at,-
|
||||
nop
|
||||
|
||||
WriteString(SNewFrame)
|
||||
|
|
10
task.asm
10
task.asm
|
@ -54,23 +54,25 @@ PushVideoTask:
|
|||
|
||||
PushRSPTask:
|
||||
lli t3, 0x40 - 1 // DMA quirk
|
||||
or t4, a0, r0
|
||||
SP_DMA_WAIT() // clobbers t0, a0
|
||||
or t2, a0, r0
|
||||
SP_DMA_WAIT() // clobbers t0,a0
|
||||
la t1, 0xA4000FC0
|
||||
sw t1, SP_MEM_ADDR(a0)
|
||||
sw t4, SP_DRAM_ADDR(a0)
|
||||
sw t2, SP_DRAM_ADDR(a0)
|
||||
sw t3, SP_RD_LEN(a0) // pull data from RDRAM into DMEM/IMEM
|
||||
SP_DMA_WAIT() // clobbers t0,a0
|
||||
jr ra
|
||||
nop
|
||||
|
||||
LoadRSPBoot:
|
||||
la t2, UCODE_BOOT & ADDR_MASK
|
||||
li t3, UCODE_BOOT.size - 1 // DMA quirk
|
||||
SP_DMA_WAIT() // clobbers t0, a0
|
||||
SP_DMA_WAIT() // clobbers t0,a0
|
||||
la t1, 0xA4001000
|
||||
sw t1, SP_MEM_ADDR(a0)
|
||||
sw t2, SP_DRAM_ADDR(a0)
|
||||
sw t3, SP_RD_LEN(a0) // pull data from RDRAM into DMEM/IMEM
|
||||
SP_DMA_WAIT() // clobbers t0,a0
|
||||
jr ra
|
||||
nop
|
||||
|
||||
|
|
Loading…
Reference in a new issue