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 > multiple sprites in mode 0 / 1

#17145 - darknet - Tue Mar 02, 2004 10:50 am

I have read most of the forum posts and was in the middle of the pern project and gbajunkies tutorial.

Is there a particular way one should go about taking their individual sprites and putting them on one .bmp (so I can have one sprite palette)? My method has been failing by always displaying the second (of 2) sprite as junk..

Here's what I do

1. Create individual sprites
2. Convert them using pcx2sprite
3. Create a new image that is twice as wide or high as the two individual sprite images (for example, I have 2 16x16 sprites, so the new bitmap is 16x32 and I just put one sprite above the other)
4. Convert the new bitmap with pcx2sprite
5. include the combined palette and the two individual data sections that were converted earlier
6. Stick it in the following code:

Code:

 int xOne = 8;
   int yOne = 30;
   int xTwo = 8;
   int yTwo = 50;

   //load sprite Palette
   for(int x=0; x<256; x++) {
     SpritePal[x] = bothPalette[x];
   }

   initializeSprites();

   //set the attributes.
   sprites[0].attr0 = COLOR_256 | SQUARE | yOne;
   sprites[0].attr1 = SIZE_16 | xOne;
   sprites[0].attr2 = 0;

     //load the particular sprite data
     for(int i = 0; i<128; i++) {
      SpriteData[i] = ballData[i];
      }
     

   sprites[1].attr0 = COLOR_256 | SQUARE | yTwo;
   sprites[1].attr1 = SIZE_16 | xTwo;
   sprites[1].attr2 = 8;

   for(int j = 128; j<256; j++) {
      SpriteData[j] = ballYData[j-128];
   }


This is pretty much a direct translation of GBAJunkie's chapter 4 tutorial and I always get crap for the second image I plugged in his sprite data files into my project and they worked fine...so the only thing i can assume is that I am making an error in the way I am combining sprites.

pcx2sprite has been reliable otherwise in my project as well...

Any help or insight would be greatly greatly appreciated...

thanks,
-Mike

#17150 - yaustar - Tue Mar 02, 2004 1:15 pm

I cant see anything wrong, could be a conversion error...
On a side note, the gba can handle a 32x16 sprite which saves you making two (check the cowbite Spec)
_________________
[Blog] [Portfolio]

#17151 - Cearn - Tue Mar 02, 2004 3:05 pm

Have you checked the tile and OAM viewers of your emulator? These are often a great help in figuring out what's wrong if you get crap. It might also help if you describe "crap". Do you have any screen shots and/or data-code? That might help.

darknet wrote:

Is there a particular way one should go about taking their individual sprites and putting them on one .bmp (so I can have one sprite palette)?

Are you talking about making all sprites separately and then combining them, or using one big bitmap fom the start? It seems like you're referring to the former, but I see little point in combining them afterwards. If you are talking about the latter, well, my own bitmap editor Usenti lets you convert to a bitmap with multiple sprites in one go. I'm sure other converters like CoG and gfx2gba can do this as well.

#17167 - Paul Shirley - Tue Mar 02, 2004 7:51 pm

removed

Last edited by Paul Shirley on Sun Mar 28, 2004 9:04 pm; edited 1 time in total

#17180 - darknet - Wed Mar 03, 2004 12:06 am

That is interesting.

I took your suggestion Paul, and two sprites indeed showed up in their proper places. However, the same sprite showed up, not two different ones.


The code has remained unchanged, in particular the effect I want is I have one bitmap that says "TXT" in two different colors. Then the individual images contain the individual "txt" message in one color.

When converted and all is said and done, only one of the images shows up twice, i.e. two blue "TXT" sprites. I made sure everything converted was included and the data copying in my menu method was actually using different data sets.

Any reason that would happen?

Any advice is greatly appreciated,
-Mike

#17181 - Paul Shirley - Wed Mar 03, 2004 12:38 am

removed

Last edited by Paul Shirley on Sun Mar 28, 2004 9:04 pm; edited 1 time in total

#17185 - yaustar - Wed Mar 03, 2004 1:59 am

pcx2sprite is not very good for converting multiple sprites..I would reccomend using gif2sprite which is very simple and quick

I have a feeling that both of the pics (on PC) have the 'TXT' pixels pointing to the same palette index (eg 0x0001 or 1) although there may be another colour in the GBA palette the sprites are just using the same two colours.
_________________
[Blog] [Portfolio]

#17221 - darknet - Thu Mar 04, 2004 8:58 am

Thanks for the suggestion yaustar. They do convert more or less properly...

I looked at the generated file and noticed that some values were not 16 bits? i.e. every now and again the file there was a value like 0xffffffe (28 bits). I don't know why it did this, but it did have a slight effect I believe on the conversion.

In both sprites that show up, there is a bit chopped off of each. To be specific, each sprite shows "TXT," with each being a different color.

They displayed in their proper colors + positions, yet in both the last 'T' was truncated a bit, as if it couldnt read all of the header file?

hmmm...
-Mike

#17225 - yaustar - Thu Mar 04, 2004 1:10 pm

The only other thing I can suggest without seeing your project is to make sure that the image are 16x16 before conversion...
_________________
[Blog] [Portfolio]