blackdroid wrote:
GIF Fifo isnt really documented in detail, it could be a memmapped dma register, that when gets written to the dmac takes the value and sends it to GIF.
At least I've found the address documented in the eeuser_e.pdf at page 23. But if you write to fast to the GIF_FIFO, the internal buffer (16x16 qwords) can overflow, with the result that additional writes are ignored. I've written a small assembler function, which checks this and with which you can write all GS registers very easy without DMA transfer or thinking about how to setup the right GIF tag:
Code: Select all
.globl SetGSReg
#------------------------------------------------------------------------
# void SetGSReg(u16 reg, u64 data);
#------------------------------------------------------------------------
.align 7
.ent SetGSReg
SetGSReg:
# wait for empty FIFO
lui v1, 0x1000
lui a3, 0x1f00
ori v1, v1, 0x3020
nop
WaitF: lw v0, 0x0000(v1)
and v0, v0, a3
nop # filling with nops to avoid
nop # "Loop length is too short for r5900."
nop # warning
bne v0, zero, WaitF
nop # branch delay slot command
# load GIF tag: 0x000000000000000e 1000000000008001: NLOOP=1, EOP=1, NREG=1, REGS0=GIF_AD
li v1, 0x000e
lui v0, 0x1000
dsll32 v0, v0, 0
ori v0, v0, 0x8001
pcpyld v1, v1, v0
# load GIF_FIFO (0x10006000) register
lui v0, 0x1000
ori v0, v0, 0x6000
# save GIF tag
sq v1, 0x0000(v0)
# save reg and data
pcpyld v1, a0, a1
sq v1, 0x0000(v0)
jr ra
nop
.end SetGSReg
Of course, this is not a good idea, if you want to show millions of triangles, but I've
changed the starsim program and drawing the stars 50 times needs only 55 ms, so it is fast enough for simple applications and the code is much easier to understand without all the optimizations for newbies like me :-)