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.

Graphics > Sprites address 0 has glitch

#177036 - blessingta@hotmail.co.uk - Fri Dec 02, 2011 1:10 am

http://postimage.org/image/e9anr50e9/

Code:

#include"btaLoadSprites.h"

void initialise_sprites()
{
   
   // Graphics mode controls
   //Pointer to area which controls  the graphics modes
   REG_DISPCNT = ((1<<12)|(1<<11)|(1<<10)|(1<<9)|(1<<8)|(1<<6)|(0<<0));
   
   //(1<<12) sprite objects on/off (1 == on| 0 == off)
   //(1<<11) BG3 layer on/off (1 == on| 0 == off)
   //(1<<10) BG2 layer on/off (1 == on| 0 == off)
   //(1<<9) BG1 layer on/off (1 == on| 0 == off)
   //(1<<8) BG0 layer on/off (1 == on| 0 == off)
   //(0<<6) (2bits space)1dimensional buffer data on/off (1 == on| 0 == off)
   //(0<<0) (3bits) graphics mode
   
   
   
   unsigned int * puiMy_Sprites32 = (unsigned int*)0x06010000;
   
   //Extract sprite data
   int iff = 0;
   for (iff = 0;iff< 2048;iff++)
   {
   puiMy_Sprites32[iff] = uisprite_data[iff];
   }
   
   //Blanksprite holder 1, blank screen
   for (iff = 0;iff< 8;iff++)
   {
   puiMy_Sprites32[iff] = 0;
   }
   
   ////////////////////////////////////////////////////
   //SPRITE ODER
   //1 BLANK SPACE 1(8X1) 32lines
   //2 BLUE BALL 2X2 (8TIMES4) 32lines
   //3 RED BALL 2X2 (8TIMES4)lines
   //4 BLUE CURSOR 2X2 (8TIMES4)lines
   //5 ??? RED CURSOR 2X2? (8TIMES4)lines
   //6 WELL COME 4X8
   //7 MAKE LINE 4X8
   ////////////////////////////////////////////////////

}

#177049 - Miked0801 - Fri Dec 02, 2011 4:38 pm

iff is a horrible var name - reads like an if statement. Use something more verbose (or just i as its just an index) and you and your teacher will be much happier.

Can't remember, but I don't believe you are allowed to access VRAM in the GBA 32-bits at a time. The bus I believe is only 16-bits wide. Change your unsigned int * to a unsigned short *, then double your loop lengths.

You also would need to up your second loop to 16 so that it outputs 32 bytes of data. You are aware that the 2nd write is trashing the first 32-bytes of data from your previous right yes? They both start their writing at 0x06010000.

#177051 - Dwedit - Fri Dec 02, 2011 5:19 pm

You are able to access vram 32 bits at a time, that's not a problem. You just get a 1-cycle penalty for going from 16 bits to 32 bits.
_________________
"We are merely sprites that dance at the beck and call of our button pressing overlord."

#177059 - Cearn - Sat Dec 03, 2011 10:41 am

What exactly are you trying to do? Without a picture of what it's supposed to look like, it's difficult to say what the problem is.

One thing you're forgetting here is setting the object attributes. VRAM (0601:0000) is just where the graphics are stored, but the objects themselves are controlled via OAM (0700:0000).

Look at VBA's tile OAM viewers to see what's actually in memory and what VBA thinks you're telling it to do. That's usually a good way to start.

Also, 32-bit copies from ROM to VRAM are fine, and can be about twice as fast as 16-bit copies. Better yet, use DMA.

#177063 - Miked0801 - Sat Dec 03, 2011 10:56 pm

My bad - was thinking of 8-bit copies perhaps :)