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 > Silly question about graphics..

#76401 - Issac - Tue Mar 21, 2006 10:33 am

Hello, I've been having some problem with graphics.. or sprites..
I'm using the Webbesen gba tutorial to figure out the sprite usage...
it works with ONE 8x8 square...
but when i try my 32x32 square.. it's all garbled...

Code:
Code:

void maingame(){
  key_poll();
  u16 loop;

  SetMode(MODE_4 | BG2_ENABLE | OBJ_ENABLE | OBJ_MAP_1D);

  for (loop = 0; loop < 256; loop++)
  {
    BG_PaletteMem[loop]=bakgrund01Palette[loop];
  }
  for (loop = 0; loop < (120*160); loop++)
  {
    FrontBuffer[loop] = bakgrund01Data[loop] ;
  }

  for(loop = 0; loop < 256; loop++)
  {
    OBJ_PaletteMem[loop] = shotPalette[loop];
  }

  memcpy( (u16 *)0x06014100, &killerData, sizeof(killerData) );

  sprites[0].attribute0 = COLOR_256 | SQUARE | 50;
  sprites[0].attribute1 = SIZE_32 | 50;
  sprites[0].attribute2 = 512;

while(1)
{
   WaitForVsync();
   CopyOAM();
}
}

Screen:
[Images not permitted - Click here to view it]

If anyone could help me, i'd be VERY grateful!

Ask if anything is unclear!
_________________
yeah, well, maybe... or? anyways.... eh... what was i talking about??

#76437 - tepples - Tue Mar 21, 2006 6:39 pm

What is the bitmap supposed to look like, and what command are you using to convert it from your paint program's format to the GBA's format?
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#76530 - Issac - Wed Mar 22, 2006 2:27 pm

hey,
It's supposed to look like this:
[Images not permitted - Click here to view it]

and im using the pcx2gba tool, just dragging the pcx-file to the program icon, dropping it there.. and i get an output (it says something about 8bits... i think)

and it works with the 8x8 square..

that's what i know for now... does that help or should i check something special?
_________________
yeah, well, maybe... or? anyways.... eh... what was i talking about??

#76536 - Cearn - Wed Mar 22, 2006 3:32 pm

The first problem is that pcx2gba gives bitmap output, but for sprites you need tiles. For that you'd need something like pcx2sprite.

A secondary problem is that you load the sprite to 0x06014100, which is sprite tile index 520, not 512. This will cause the sprite to appear shifted down 16 pixels, with the last 8 tiles simply cut off.

And the obligatory sidenote: the coding standards used in Webbesen's tutorial are little short of atrocious; most of the functions are inefficient (even without falling onder premature optimisation), and sometimes flawed. It's an okay resource to learn the most basic concepts of GBA programming and pong, but if possible stay the %$^& away from the actual code.

#76539 - Issac - Wed Mar 22, 2006 4:25 pm

okay, and, I know i asked this before, but are there any siple ways to insert a tiled sprite?

define simple: as including a bittmapped "sprite"....
_________________
yeah, well, maybe... or? anyways.... eh... what was i talking about??

#76542 - Cearn - Wed Mar 22, 2006 4:41 pm

Yes, use pcx2sprite instead of pcx2gba. This will tile the image for you, which you can then copy to obj VRAM as you're doing now. That is the simplest way. Well, that or using a converter with a graphical user interface, in which you can set the options with buttons instead of command line flags. gfx2gba has a GUI for it, and and the exporter in Usenti is a GUI.

The copy routine is not the problem (well not in this case, but only because you're lucky), the internal format of your sprite graphics array is.

There are ways of performing the conversion in-game (i.e., converting the output of pcx2gba to something pcx2sprite would have given) but that's rather unpleasant business, with lots of offsets and ands. Just use a converter that can tile images.