#8584 - abilyk - Tue Jul 15, 2003 8:34 pm
Greetings.
I've been trying to test the speeds of several data copy methods (so far, memcpy & CPUFastSet) to find out the best way to implement a dynamic background-loading engine.
Memcpy certainly didn't give me any problems, but I'm having difficulty with CPUFastSet. I believe I have the asm code set up correctly, but whenever I attempt a copy, it doesn't work. (Note: I've tried using both "swi 0x0C" and "swi 0x0C0000." One doesn't do anything, and the other seems to freeze the system. Though I'm not sure which to use, I do know that there's something else wrong)
I was initially trying to copy from ROM to VRAM. After hours of struggle, it hit me that the registers (r0 and r1) that hold the source and destination addresses are only 32 bit, and because of that the complete address of each wouldn't be able to fit. Hopeful, I then tried to copy from EWRAM to VRAM, and after that, VRAM to VRAM. But neither of these worked.
Could someone more experience help me out? Is it possible to copy from any address to any address with this method, or must they be within a certain distance from each other? Following is the related code I've been using:
// function
void CPUFastSet(void *source, void *dest, u32 length_mode)
{
asm volatile
(
"mov r0, %0\nmov r1, %1\nmov r2, %2\nswi 0x0C0000\n": // asm code
: // function output (none)
"r" (source), "r" (dest), "r" (length_mode) : // function input
"r0", "r1", "r2" //registers destroyed
);
}
// map declaration
const u16 map0[320] __attribute__ ((section(".ewram"))) = {0x0094,0x0094, etc.... )
// function call
CPUFastSet((u32*)map0, VideoBuffer, (u32)20);
Thanks,
Andrew P. Bilyk
P.S. Also, some of you might suggest to just leave the SWI calls alone and use DMA. The reason I'm shying from that is the fact that I'm planning on using the Krawall sound library with my games, and I don't want my DMA use to interfere with Krawall's. Is this a valid concern?
I've been trying to test the speeds of several data copy methods (so far, memcpy & CPUFastSet) to find out the best way to implement a dynamic background-loading engine.
Memcpy certainly didn't give me any problems, but I'm having difficulty with CPUFastSet. I believe I have the asm code set up correctly, but whenever I attempt a copy, it doesn't work. (Note: I've tried using both "swi 0x0C" and "swi 0x0C0000." One doesn't do anything, and the other seems to freeze the system. Though I'm not sure which to use, I do know that there's something else wrong)
I was initially trying to copy from ROM to VRAM. After hours of struggle, it hit me that the registers (r0 and r1) that hold the source and destination addresses are only 32 bit, and because of that the complete address of each wouldn't be able to fit. Hopeful, I then tried to copy from EWRAM to VRAM, and after that, VRAM to VRAM. But neither of these worked.
Could someone more experience help me out? Is it possible to copy from any address to any address with this method, or must they be within a certain distance from each other? Following is the related code I've been using:
// function
void CPUFastSet(void *source, void *dest, u32 length_mode)
{
asm volatile
(
"mov r0, %0\nmov r1, %1\nmov r2, %2\nswi 0x0C0000\n": // asm code
: // function output (none)
"r" (source), "r" (dest), "r" (length_mode) : // function input
"r0", "r1", "r2" //registers destroyed
);
}
// map declaration
const u16 map0[320] __attribute__ ((section(".ewram"))) = {0x0094,0x0094, etc.... )
// function call
CPUFastSet((u32*)map0, VideoBuffer, (u32)20);
Thanks,
Andrew P. Bilyk
P.S. Also, some of you might suggest to just leave the SWI calls alone and use DMA. The reason I'm shying from that is the fact that I'm planning on using the Krawall sound library with my games, and I don't want my DMA use to interfere with Krawall's. Is this a valid concern?