#4937 - redneon - Tue Apr 15, 2003 11:47 am
Hi,
I'm creating a breakout clone (yes, another one) to try and teach myself GBA programming. I've managed to do quite a bit but I have a couple of questions about sprites and colours. First, is it possible to have a colour palette for each sprite or do you have to have one palette for all of them? Second, I am assuming that you have to have one colour palette for all of them and in this case, how do I do this? I did try putting all my sprites in a .pcx file, converting this to a .h file and using that for the colour palette but it hasn't worked.
Please help,
redneon
#4939 - delbogun - Tue Apr 15, 2003 12:46 pm
As far as I know, you can only have one palette for all sprites. But you could use the tile memory and palette for some objects and that way get two palettes.
Make sure the .pcx file is saved as a 256-color image, but that's probably depends on what tool you used for conversion.
#4942 - tepples - Tue Apr 15, 2003 3:03 pm
What delbogun said is true for sprites with 8 bits per pixel, but sprites with 4 bits per pixel can have any of 16 palettes.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#4945 - redneon - Tue Apr 15, 2003 4:01 pm
So you can either have one 256 colour palette or 16 16 colour palettes is that right? How would I set up 16 16 colour palettes?
Darrell
#4956 - tepples - Tue Apr 15, 2003 7:37 pm
redneon wrote: |
So you can either have one 256 colour palette or 16 16 colour palettes is that right? |
Correct.
Quote: |
How would I set up 16 16 colour palettes? |
Load each 16-color palette into an area of palette RAM, and tell each sprite to use a particular palette. See the [url=http://www.cs.rit.edu/~tjh8300/CowBite/CowBiteSpec.htm#OAM%20(sprites)]CowBite Spec[/url].
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#4978 - redneon - Wed Apr 16, 2003 12:30 pm
I'm still having trouble. I was wondering if someone would be kind enough to download my code from http://dazblake.pwp.blueyonder.co.uk/bod.zip and figure out how I can get all the sprites to display correctly? So far all the sprites (the bat, brick and ball) are all using the sprite image from the bat and I can't figure out what I'm doing wrong.
Please help,
Darrell
#6804 - hnager - Tue Jun 03, 2003 1:01 am
Just curious to see if you ever resolved your sprite issues...I think I'm having the same problem with my 16 color sprites and can't figure out what's wrong with it.
#7205 - Daedro - Thu Jun 12, 2003 6:02 am
I am too, 16 colors wont work. But the wierdest thing is my 256 wont either.. it cuts them in half horizontally and puts the pieces together and will not even show the image even cut in half :-/
Any more info in these posts would be greatly appreciated.
#7347 - Ninja - Mon Jun 16, 2003 12:05 am
If someone can post their source code, or a working link, I can try to help you out with this. I used to have a lot of trouble with my sprites back in the day too. :)
#7351 - hnager - Mon Jun 16, 2003 1:21 am
I've since solved the problem - thanks to the forum. But I'm still looking for a smooth way to convert the 16 color sprite data to the properly formatted array (if I'm not mistaken it's in 8x8 quadrents). Any suggestions/?
#7368 - Cyberman - Mon Jun 16, 2003 2:02 pm
Quote: |
I've since solved the problem - thanks to the forum. But I'm still looking for a smooth way to convert the 16 color sprite data to the properly formatted array (if I'm not mistaken it's in 8x8 quadrents). Any suggestions/? |
The color information for sprites can be stored in two ways in the GBA just like that of tiles
Two Dimensional Character Mapping (DISPCNT Bit 6 cleared)
This mapping mode assumes that the 1024 OBJ tiles are arranged as a matrix of 32x32 tiles / 256x256 pixels (In 256 color mode: 16x32 tiles / 128x256 pixels). Ie. the upper row of this matrix contains tiles 00h-1Fh, the next row tiles 20h-3Fh, and so on.
For example, when displaying a 16x16 pixel OBJ, with tile number set to 04h; The upper row of the OBJ will consist of tile 04h and 05h, the next row of 24h and 25h. (In 256 color mode: 04h and 06h, 24h and 26h.)
One Dimensional Character Mapping (DISPCNT Bit 6 set)
In this mode, tiles are mapped each after each other from 00h-3FFh.
Using the same example as above, the upper row of the OBJ will consist of tile 04h and 05h, the next row of tile 06h and 07h. (In 256 color mode: 04h and 06h, 08h and 0Ah.)
This affects how sprites are stored in internal memory.
If you are talking about how you store the sprite data in ROM to load into VRAM The 'bit' organization goes something like this.
Code: |
[h] - high nybble
[l] = low nybble
0 1 2 3
[h][l][h][l][h][l][h][l] 0
[h][l][h][l][h][l][h][l] 4
[h][l][h][l][h][l][h][l] 8
[h][l][h][l][h][l][h][l] 16
[h][l][h][l][h][l][h][l] 20
[h][l][h][l][h][l][h][l] 24
[h][l][h][l][h][l][h][l] 28
|
This should give you an idea <if it's not mangled too much> of the order data is layed out in each tile.
If you selected linear mode then the tile data for a sprite (use a 32x32 pixel on as an example) is thus.
Code: |
[00][01][02][03]
[04][05][06][07]
[08][09][10][11]
[12][13][14][15]
|
Each number being a tile formated as mentioned above.
To create a sprite in rom right GFX2GBA does a pretty good job of meta tiling data from a windows bitmap file.
As for how to make is easier.. create your own utils, like I did? :) Seriously I think someone made a gfx2gba wrapping program to make it easier but still ones own tools seems to be the best way at the moment.
Cyb[/b]
#7387 - hnager - Mon Jun 16, 2003 8:10 pm
Hmmm, I may not have explained exactly where I'm having difficulty - take a look at this long thread:
http://forum.gbadev.org/viewtopic.php?t=1344&highlight=color+colour+sprite
It looks as if 16 color sprites need to be formatted differently (even in a 1d mode) - so a 16x16 sprite would be brought in as if 4 tiles. Getting the array to that point is where I have trouble.