gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > I need some input from DS coding gurus;

#153078 - NeX - Mon Mar 24, 2008 8:31 pm

I'm back coding SandScape again. I've decided to move the simulation to the ARM7 because of the reduced memory latencies. I've got a fairly crude system working - is there a quicker/more efficient way of doing this?

ARM7 writes and reads VRAM bank D for high speed, low latency random access.

When it finishes its business, it copies the data to VRAM C.

ARM9 then gets access, and puts it on the screen.

ARM7 continues working on VRAM D, and VRAM C is handed back. Repeat.

The data is roughly 50kb, so I don't think the IPC is really up to this. This would be happening 30 times a second. This looks to be the fastest way, if complicated. I know it's working because I've got some ARM7 code changing the BG palette.
_________________
Strummer or Drummer?.
Or maybe you would rather play with sand? Sandscape is for you in that case.

#153085 - NeX - Mon Mar 24, 2008 9:23 pm

Also, is it possible to multiply a number by 32 using a bitshift? It would really increase the speed referencing the reactions table. I'm accessing my VRAM using a define:

Code:
#define REACT ((u8*)0x0602DE20)


I am finding the entry like this:

Code:
REACT[(MyMaterial*32)+TheirMaterial];


But somehow that seems hacky.
_________________
Strummer or Drummer?.
Or maybe you would rather play with sand? Sandscape is for you in that case.

#153086 - Dwedit - Mon Mar 24, 2008 9:24 pm

Compilers automatically change multiplication by a power of 2 to a bitshift.
_________________
"We are merely sprites that dance at the beck and call of our button pressing overlord."

#153087 - NeX - Mon Mar 24, 2008 9:27 pm

Really? Thanks.

One last question: If I access memory using a boolean, i.e.:

Code:
#define MOVED ((bool*)0x06021800)


Is it placing a bool at every address (and wasting 7 bits per entry) or compacting it quite nicely?
_________________
Strummer or Drummer?.
Or maybe you would rather play with sand? Sandscape is for you in that case.

#153104 - TwentySeven - Mon Mar 24, 2008 11:48 pm

sizeof(bool) == 1

#153107 - strager - Tue Mar 25, 2008 1:21 am

Are you rendering to the VRAM bank as if it were a VRAM bank? An idea: treat each of VRAM bank C and D as a framebuffer (e.g. GBA doublebuffer modes). After each update, give the ARM7 access to one and the ARM9 (thus the GPU) access to the other. No need to copy data or anything; just send a simple "ready" message from the ARM9 to signal the buffer switch.

Unless VRAM data is not maintained when switching CPU access. That would ruin the whole idea. =[

#153159 - Miked0801 - Tue Mar 25, 2008 8:50 pm

Man I wish I could use the ARM7 for stuff.

Bools are usually defined as u32s or u8s. You can manually set them up as bit-fields as needed, but there is a speed hit for doing this. Don't bother unless you have an array.

You are using VRAM as a RAM buffer? Ok.

Yes, compilers will change muls to shifts when it makes sense - but muls are cheap now 2-5 cycles depending on the MSBit of the operands. Muls don't kill on DS, divides memory access, and cache misses do.

BTW, your array define has 2 inherent muls within it (depending on range), which shows just how often you have to multiply.

That's all I got at first glance.