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.

Beginners > 32-bit video buffer writing

#10666 - Burton Radons - Thu Sep 11, 2003 8:26 pm

I noticed that when I wrote a horizontal line segment rendering routine to store u32 instead of u16 that it doubled in speed when using VisualBoy Advance to test. Would this optimisation show up on a real GBA as well, would the 16-bit port size force the same speed, or would it only store the 16-bit and ignore the top half-word? The HLine code is:

Code:
void HLine3 (volatile u16* buffer, int sx, int y, int ex, u16 color)
{
    volatile u32 *b, *e;

    /* Parameter clipping excised. */   
    b = (u32*) (buffer + sx + y * VideoWidth);
    e = b + (ex - sx) / 2;
   
    while (b <= e)
        *b ++ = color | (color << 16);
}


(Yeah, I know that it won't do odd-length lines properly.) If this is a false optimisation, are there any GBA emulators which insert slowdown after every instruction or set of instructions to keep the emulated processor running at the same speed as the physical one?

#10667 - tepples - Thu Sep 11, 2003 9:14 pm

Burton Radons wrote:
I noticed that when I wrote a horizontal line segment rendering routine to store u32 instead of u16 that it doubled in speed when using VisualBoy Advance to test. Would this optimisation show up on a real GBA as well, would the 16-bit port size force the same speed, or would it only store the 16-bit and ignore the top half-word?

A 32-bit write to VRAM works properly, taking only one more cycle than a 16-bit write.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#10668 - Burton Radons - Thu Sep 11, 2003 11:20 pm

So a 32-bit write to the VRAM takes three cycles, while two 16-bit writes to the VRAM takes four? Great, thanks.