SH2 DMA
Posted: Thu Mar 29, 2007 8:56 am
Hello.
You all know the 32X can perform DMA, either from FIFO port to memory or to PWM. But did you know each CPU could also perform DMA ?
Here's what you need to set (in this example, I'd use DMA1, the 2nd DMA channel) :
SAR1 (FFFF FF90h) : source address, in SH2 memory map
DAR1 (FFFF FF94h) : destination address, in SH2 memory map
TCR1 (FFFF FF98h) : transfer count, in 16-bit words(*) unit
CHCR1 (FFFF FF9Ch) : Channel Control, please don't listen to SEGA and put 56E1h instead (Thank you very much Stef').
Then, start DMA by writing 1 into DMAOR (FFFF FFB0h).
Access all registers in longword units.
* : you can also transfer in byte (useless), longword (32-bits) and 16-byte unit. Set CHCR TS bits.
For example, I want to copy 256 16-bit words from 2200 0814h (814h on the ROM cartridge) to Frame Buffer 0h (right, I want to initialize the line table) :
Stay tuned for speed performance.
You all know the 32X can perform DMA, either from FIFO port to memory or to PWM. But did you know each CPU could also perform DMA ?
Here's what you need to set (in this example, I'd use DMA1, the 2nd DMA channel) :
SAR1 (FFFF FF90h) : source address, in SH2 memory map
DAR1 (FFFF FF94h) : destination address, in SH2 memory map
TCR1 (FFFF FF98h) : transfer count, in 16-bit words(*) unit
CHCR1 (FFFF FF9Ch) : Channel Control, please don't listen to SEGA and put 56E1h instead (Thank you very much Stef').
Then, start DMA by writing 1 into DMAOR (FFFF FFB0h).
Access all registers in longword units.
* : you can also transfer in byte (useless), longword (32-bits) and 16-byte unit. Set CHCR TS bits.
For example, I want to copy 256 16-bit words from 2200 0814h (814h on the ROM cartridge) to Frame Buffer 0h (right, I want to initialize the line table) :
Code: Select all
mov.l LTInit3_DMA1,R1
mov.l LTInit3_Pattern,R0
mov.l R0,@R1 ; SAR1
mov.l LTInit3_FB,R0
mov.l R0,@(4,R1) ; DAR1
mov.w LTInit3_SIZE,R0
mov.l R0,@($8,R1) ; TCR1
mov.w LTInit3_CHCR,R0
mov.l R0,@($C,R1) ; CHCR1
mov.l @R1,R0
mov.l LTInit3_DMAOR,R1
mov #1,R0
mov.l R0,@R1 ; Start DMA
rts
nop
.align 4
LTInit3_DMA1: dc.l $FFFFFF90
LTInit3_DMAOR: dc.l $FFFFFFB0
LTInit3_Pattern: dc.l $22000814
LTInit3_FB: dc.l $24000000
LTInit3_SIZE: dc.w $0100 ; 256 16-bit words
LTInit3_CHCR: dc.w $56E1