#56777 - thegamefreak0134 - Tue Oct 11, 2005 1:42 pm
I've been working really hard on my port of bejeweled to the GBA. I am storing all of my sprite data (the actual pictures) starting at 512. When I look at this in VBA, I notice that that starts at the bottom half of the last tile set. I also notice that if I add too many sprites (more that 512 + (8*63) ) the new sprites appear at the top of this tileset, but when I try to use them by calling what I stored them as or by starting with zero, they appear in the VBA "OAM viewer", but not on the screen. Whats the deal?
BTW, I'm using mode 3 as I don't exactly know how to use the others yet.
I suspect that whats happening is the sprites placed in memory behind 512 are appearing behind the map. If this is not the case, please by all means laugh at me for being wierd, but if it is, there is a possible solution. Can you have transparent maps? How? If not, why?
If thats not the case, does anyone know where else I can store sprite data and how to accecss it after that?
This is really tickinig me off here. The game itself works fine to a point, but I cannot add a scoring system because I have no sprites left and do not know how to use tiles yet. Please if at all possible help me out. Thanks soo much in advance!
PS: If you'll care to let me know how, I can post the .bin file of the game and the source. Just don't laugh at my pitiful attempt at source code, i'm still learning...
_________________
What if the hokey-pokey really is what it's all about?
[url=http:/www.darknovagames.com/index.php?action=recruit&clanid=1]Support Zeta on DarkNova![/url]
#56792 - cosmic4z - Tue Oct 11, 2005 4:30 pm
Sounds like your sprites may be wrapping around because the upper bits of the address space for sprite VRAM are ignored.
Am sure someone on here will have a better idea and can give you more specific details.
Also, if you're using mode 3, be aware that you're only going to have half the amount of VRAM available for sprites that you'd get with modes 0,1 and 2.
Consider using one of these modes, they're pretty good, and am sure it's worth while learning how they work.
Also, if you're still running out of sprites VRAM, consider dynamically uploading data to VRAM as and when you need it, rather than just at the start of your game loop etc.
Hope some of that helps.
_________________
Qwak - www.qwak.co.uk | Forum - www.qwak.co.uk/forum/
#56800 - poslundc - Tue Oct 11, 2005 5:40 pm
You have 32K of VRAM dedicated to sprites (which translates to 1024 tiles in 16-colour mode, or half that in 256-colour mode). In modes 3-5, however, you lose the first half of that to the extra VRAM needed to render the background. This means in modes 3-5 you only get 512 tiles of sprite data, which is the ceiling you're running into.
If you're being sub-optimal with your tile data - for example, having multiple copies of the same sprite in VRAM when you could simply have multiple OAM entries reference the same set of tiles, or if you could simply H- or V-flip the original sprite to get the new one - now would be a good time to optimize that sort of thing.
Alternatively, you're going to have to learn to use the tile modes, which is the preferred mode for probably over 95% of GBA games.
Dan.
#56813 - thegamefreak0134 - Tue Oct 11, 2005 7:47 pm
I have to have all of the sprites in memory that I use. The tiles are 7 jewel pictures and then 6 or seven animation tiles for those seven jewels. My code quickly animates each jewel by increasing it's reference to what it's already pointing at + (8*7) which gives it the next frame of animation.
The cieling thing makes sooo much more sense now, thank you so much. I only need to add like 10 more sprites anyway. Can I easily switch to mode 0, 1, or 2 and still keep a single background with the sprites all in front of it?
Interestingly enough, My individual sprites are in fact one picture. I chopped up the images myself and combined it into one image. That way, I don't go about getting confused with my sprite palletes being different.
Thanks for the help on this so far. I'm going to grab a background tutorial and see what I can do.
_________________
What if the hokey-pokey really is what it's all about?
[url=http:/www.darknovagames.com/index.php?action=recruit&clanid=1]Support Zeta on DarkNova![/url]
#56821 - poslundc - Tue Oct 11, 2005 8:24 pm
A couple of ideas:
- If the jewels all have the same shape but use different colours, then just have ONE image of the jewels in VRAM for each animation stage, and use 7 different palette ramps (which you have 16 of) to apply a different colour set to the image. This is a highly recommendable way of doing things.
- Swap in VRAM as necessary from one frame to the next during VBlank so that you aren't wasting VRAM on animation frames you aren't actually displaying. Tepples' paper on this topic
Quote: |
Can I easily switch to mode 0, 1, or 2 and still keep a single background with the sprites all in front of it? |
You can "paint" a background into tiles by using a text background and numbering the map entries sequentially. An entire screen's worth will consume 600 tiles, or a little more than 1 character-base block. You will need to either find or write a utility to convert your image into a tileset.
Dan.
#56831 - thegamefreak0134 - Tue Oct 11, 2005 9:29 pm
You are a mind reader. Yes, it looks cool, but the images retain their original shape except for colors. However, since all of the sprites use the same color pallette, I need to be able to differentiate one from the other. (I don't want all of the red jewels to disappear when only three are lined up.) The re-loading of the sprites is a good itea though, I'll look into that. Thanks again!
_________________
What if the hokey-pokey really is what it's all about?
[url=http:/www.darknovagames.com/index.php?action=recruit&clanid=1]Support Zeta on DarkNova![/url]
#56836 - poslundc - Tue Oct 11, 2005 9:50 pm
thegamefreak0134 wrote: |
You are a mind reader. Yes, it looks cool, but the images retain their original shape except for colors. However, since all of the sprites use the same color pallette, I need to be able to differentiate one from the other. |
So what you do is instead of making them all use the same palette, have them use 7 different palettes, but with matching palette entries in each version (so bright green in one is bright red in the other, dark green in one is dark red in the other, etc.).
Then you only need one copy of the jewel's frames in VRAM for all of your sprites to share, and you just specify a different palette number in the OAM entry when you want to display a jewel of a different colour.
This is the way to go; trust me!
Dan.
#56837 - thegamefreak0134 - Tue Oct 11, 2005 9:55 pm
Wow. That is, like, so cool. I could kill the evil writer of the Pong Tutorial for leaving such important and highly useful details out.
How do you specify palette entries? First. how does one go about loading different ones, and second how does one specify in the OAM which one to use? (like, which attribute and where and so on and so forth?)
You have no idea how helpful all of this really is. I'm learning so much, it's overwhelming!
_________________
What if the hokey-pokey really is what it's all about?
[url=http:/www.darknovagames.com/index.php?action=recruit&clanid=1]Support Zeta on DarkNova![/url]
#56844 - poslundc - Tue Oct 11, 2005 10:27 pm
thegamefreak0134 wrote: |
How do you specify palette entries? First. how does one go about loading different ones, and second how does one specify in the OAM which one to use? (like, which attribute and where and so on and so forth?) |
The sprite palette entries begin at 0x05000200. There are 256 entries with 2 bytes (16 bits) per entry. If you are using 16-colour sprites, then these 256 entires are divided into 16 separate palettes, which are controlled through OAM attribute 2.
This means if I put red at palette entry 1 and green at palette entry 17, if I say a sprite uses palette 0, then every occurrence in VRAM of colour 1 will be rendered as red, but if I say it uses palette 1, then every occurrence of colour 1 will be rendered as green.
See TONC for more information on sprites.
Dan.
#56867 - tepples - Wed Oct 12, 2005 1:41 am
To load different palettes, first make sure you're using 16-color (4-bit) tiles. Then entries 256 through 511 become sixteen different 16-color palettes. For instance, palette 11 is (256 + 11 * 16 = ) 432 through 447. To specify which palette a sprite uses, load it into the upper 4 bits of OAM attribute 2.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#56961 - thegamefreak0134 - Wed Oct 12, 2005 5:27 pm
OK, does that mean that I could (for instance) create a 256 color image of all my sprites (I have one already) and make sure that each sprite uses olny the colors from one 16-color section of the palette? (one "row" in adobe) That would lighten my workload considerably. I would just have to respecify all of my sprites in code as 16 color and offset their palletes to match the appropriate positions.
Using the standard method of defining sprites, what keyword would I use for loading the sprite pallete into the OAM entry? Right now it's :
sprites[0].attribute0 = COLOR_256 | SQUARE | 0;
sprites[0].attribute1 = SIZE_16 | 0;
sprites[0].attribute2 = 512; //I would add the palette here right? How?
_________________
What if the hokey-pokey really is what it's all about?
[url=http:/www.darknovagames.com/index.php?action=recruit&clanid=1]Support Zeta on DarkNova![/url]
#56963 - poslundc - Wed Oct 12, 2005 5:49 pm
thegamefreak0134 wrote: |
OK, does that mean that I could (for instance) create a 256 color image of all my sprites (I have one already) and make sure that each sprite uses olny the colors from one 16-color section of the palette? (one "row" in adobe) That would lighten my workload considerably. I would just have to respecify all of my sprites in code as 16 color and offset their palletes to match the appropriate positions. |
If your sprite-processing tool is exporting your sprites as 256-colour then you're already being incredibly wasteful, since 256-colour sprites take twice as much space as 16-colour sprites.
You will have to read the documentation of your tool to see what kinds of options it has for processing your images. Or, conversely, you can write your own tool (which most of us do at one point or another).
Quote: |
Using the standard method of defining sprites, what keyword would I use for loading the sprite pallete into the OAM entry? Right now it's :
sprites[0].attribute0 = COLOR_256 | SQUARE | 0;
sprites[0].attribute1 = SIZE_16 | 0;
sprites[0].attribute2 = 512; //I would add the palette here right? How? |
The palette row is defined in the upper four bits of attribute two. So you would specify it as (P << 12), where P is the palette row you want to use. This gets bitwise-or'ed with the remaining bits.
Dan.
#56967 - thegamefreak0134 - Wed Oct 12, 2005 6:50 pm
OK, I think I've got it. (Yes, I will prolly convert the images myself later, but this will get it running for now so i can do more coding.) I should change the last line, say if I wanted to use the 3rd pallete, to this:
sptires[0].attrubite2 = 512 | (3<<12);
Is that what you meant?
BTW, you guys are being so helpful right now. Thanks again sooooo much!
_________________
What if the hokey-pokey really is what it's all about?
[url=http:/www.darknovagames.com/index.php?action=recruit&clanid=1]Support Zeta on DarkNova![/url]
#56970 - Fatnickc - Wed Oct 12, 2005 7:29 pm
thegamefreak0134 wrote: |
Wow. That is, like, so cool. I could kill the evil writer of the Pong Tutorial for leaving such important and highly useful details out. |
Important? Yes.
Something you couldn't have worked out (possibly with a little help from here)? No.
Webbesen's tutorial does what it aims to do - guides the user through creating a simple game, from which they should be able to make a few other simple games. However, the tutorial also claims that it has set you up for a long time so that you can make most games with relative ease.
This is wrong, but you can make a good few games with Mode 4 and what you've learnt, provided you look for other things to help you.
Does that tutorial mention fading (or many other things)? Nope.
Will you want to use fading (or many other things)? Yep.
What do you do? Search.
#56971 - poslundc - Wed Oct 12, 2005 7:49 pm
It's also worth mentioning that if you only read one tutorial, you are shortchanging yourself. None of the tutorials out there are either complete or all-encompassing. Cearn's TONC is probably the most complete and accurate one I've seen, but doesn't hold your hand as much as some of the other ones do.
You clearly need to get more exposure to GBA programming fundamentals, so go read/do more tutorials. You can find them off the site or by googling them.
Dan.
#56986 - thegamefreak0134 - Wed Oct 12, 2005 10:19 pm
I understand this, but you even posted again and forgot to answer my question...
No sweat. That's the main reason I like to ask things here. You seem to take pride in proving other people wrong (Yes, i put myself down) and I seem to learn best that way.
Lets assume for a moment that I know nothing about the bits in the memory. How would I write definitions in C++ that I cound use to easily specify palette?
_________________
What if the hokey-pokey really is what it's all about?
[url=http:/www.darknovagames.com/index.php?action=recruit&clanid=1]Support Zeta on DarkNova![/url]
#56993 - poslundc - Wed Oct 12, 2005 11:15 pm
Quote: |
You seem to take pride in proving other people wrong |
I hope the irony of me proving you wrong by choosing not to answer your questions any further doesn't escape you.
Good luck,
Dan.
#57665 - Miked0801 - Mon Oct 17, 2005 6:02 pm
Hint: &^|~!
#58004 - ScottLininger - Wed Oct 19, 2005 10:57 pm
One (kludgy) way to build out multiple 16-color palettes in photoshop:
1. Draw your jewel. Use transparent for the transparent pixels if you need those.
2. Convert the thing to a 16-color indexed color image.(Image > Mode > Indexed Color, then select adaptive at 16 colors, with the Transparency box checked.)
3. Save it out as a GIF or PCX or whatever your image converter reads, and convert it. If all went well, only the 1st 16 palette entries should have colors in them (this depends on your tool, of course.) If your tool outputs to a text file, then all we need to do now is create your other palettes and copy/paste them over the unused color blocks.
4. Back in photoshop, go Image > Adjustments > Hue/Saturation. The sliders will let you change from blue to red, or whatever. (You can also use levels, brightness/sat, etc. - so long as you're still in Indexed color mode, photoshop will make these adjustment to your palette without altering the actual pixel data.)
5. Save your new colored jewel as a fresh GIF. Covert the thing, and then cut and paste your *new* 16 colors into the 2nd 16-color block of the original palette file (indexes 16-31). The actual image data should be identical... so you don't need to copy that again. You're just overwriting your 2nd 16-color palette.
6. Repeat up to 14 more times... You can have up to 16 "mini palettes" within your 256 color palette.
7. When you use your jewel in 16-color sprite mode, you can select a different palette for each sprite instance, while using the same image data. This should totally remove your memory limit problem.
Perhaps you figured that out already from the earlier posts, but I thought I'd throw it into the mix, since Photoshop is not good at these sorts of palette manipulations.
But to answer your question... Yes, you could manage your entire 256 palette manually in Photoshop, one "row" per mini-palette. The only trick is to make sure that your image/palette conversion tool actually outputs the palette in the correct order. I've used some tools that seem to scramble the palette order in a seemingly random fashion.
-Scott
#58192 - thegamefreak0134 - Fri Oct 21, 2005 4:00 pm
Thanks for all the info. For now, I have the game to a working point on one of the earlier mentioned solutions. I reduced my copy of jewels in the tile to 2 sets. The first has the normal jewel and the second has the first frame of the animation. When a jewel needs to be animated, I switch it to the second set, then another function swaps out the images in the second set for the animation. It works really well suprisingly. However, the palette trick looks much much more efficient and I will probably implement that in the future once I have a firm grasp on the subject. Yay! Now all I have to add is highscores, levels, time, sound, etc... Thanks again for all the help on this issue.
I submitted a working bersion of my demo to the demos section. From what I'm told, it should be up as soon as the updaters feel like getting around to it, so keep an eye out for it. If you would really like to see it that badly, PM me with your e-mail adress and I'll sent it to you. You can then laugh at my pitiful attempt at source code.
_________________
What if the hokey-pokey really is what it's all about?
[url=http:/www.darknovagames.com/index.php?action=recruit&clanid=1]Support Zeta on DarkNova![/url]