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 > From Mode4 to ... something else?

#58216 - thegamefreak0134 - Fri Oct 21, 2005 6:26 pm

Here's my problem. I need sprites to appear behind part of my background. I want to simply create two backgrounds and put one in front of sprites and one behind. Sounds simple enough. Problem is, I'm only familiar with mode4 backgrounds. I don't want to use tiles, I just need two backgrounds that I can use plain old pictures in. Can someone explain to me the most painfree way to make the switch?

On another note, how does one go about setting the depth of backgrounds?

Thanx in advance.
_________________
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]

#58224 - tepples - Fri Oct 21, 2005 8:18 pm

If you want to stay in mode 4, you'll need to make a pseudo-layer out of sprites that stay in the same position from frame to frame.

You set the z-index of a background in the BGCTRL registers (check GBATEK for which bit you need to set, and gba_video.h if you're using libgba).

You set the z-index of a sprite in attribute 2.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#58304 - Cearn - Sat Oct 22, 2005 1:29 pm

tepples wrote:
If you want to stay in mode 4, you'll need to make a pseudo-layer out of sprites that stay in the same position from frame to frame.

But in order to make a psuedo-lay of sprites, you need to go use tiles anyway, so you might as well do the whole thing in tilemaps anyway.
Is there any reason you don't want to use tiles? It's really not that hard. If you know how to work with sprites, you're halfway to understanding tilemaps anyway. There is no conceptual difference between the two, just where you have to put what.

tepples wrote:
... z-index ...

Also know as priority. High valued priorities are draw first, so are more on the background. If you want to have sprites with different priorities, you need to be aware of this:

GBATek, OAM attributes wrote:
Priority
In case that the 'Priority relative to BG' is the same than the priority of one of the background layers, then the OBJ becomes higher priority and is displayed on top of that BG layer.
Caution: Take care not to mess up BG Priority and OBJ priority. For example, the following would cause garbage to be displayed:
OBJ No. 0 with Priority relative to BG=1 ;hi OBJ prio, lo BG prio
OBJ No. 1 with Priority relative to BG=0 ;lo OBJ prio, hi BG prio


That is, OBJ0 is always having priority above OBJ1-127, so assigning a lower BG Priority to OBJ0 than for OBJ1-127 would be a bad idea.

#58557 - thegamefreak0134 - Mon Oct 24, 2005 4:33 pm

Ok, let me elaborate. I understand priority and such. I simply need to know an easy way to take my fullscreen stills and use them both in the same mode. I tried simply switching modes and pointing my image to a different bg, but I got garbage. I figure the resolution/color-depth was different or something silly like that.

I'm not scared of tiles, it just seems silly to use them when (as of now) my entire program has a whopping 2 backgrounds that are completely different all over.
_________________
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]

#58558 - strager - Mon Oct 24, 2005 4:41 pm

If you need to use tiles, I have to methods in mind.

One is where you use the palette to write a fake bitmap. You have your tile map set up to every line goes 01234567, 89ABCDEF, .... on to 239 (screen width). Since you have two bitmaps, and they probably don't use most of the same colors, this isn't the best way to do it.

The other is using the above but use only 128 indexes for each bitmap, and if you need full color, steal 224 colors of the sprites' palette. This leaves you with only 32 sprite colors to work with, which may be enough, or may not.

Both methods have their ups and downs, but if you have low-color sprites, use the second method for best results.

#58559 - thegamefreak0134 - Mon Oct 24, 2005 4:44 pm

Um... I don't need to use tiles...

I can't use either method because (due to the nature of the game) I need to use ALL of my sprites in 256 color mode. (meaning that the same large amount of colors is shared among sprites.) It simply wouldn't work otherwise.
_________________
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]

#58561 - strager - Mon Oct 24, 2005 4:53 pm

thegamefreak0134 wrote:
Um... I don't need to use tiles...

I can't use either method because (due to the nature of the game) I need to use ALL of my sprites in 256 color mode. (meaning that the same large amount of colors is shared among sprites.) It simply wouldn't work otherwise.


That sucks. I don't know any other method, other than alpha-blending two layers, which would be hard to calculate. Sorry.

#58562 - thegamefreak0134 - Mon Oct 24, 2005 4:56 pm

Why do I need to alpha blend? Why can't I just use two backgrounds with the one on top having a transparent color? Thats all I need. I just need sprites to appear in-between them, thats all. I want to learn the basics first, if thats alright... (:-)) Its a puzzle game.
_________________
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]

#58567 - poslundc - Mon Oct 24, 2005 5:13 pm

thegamefreak0134 wrote:
Ok, let me elaborate. I understand priority and such. I simply need to know an easy way to take my fullscreen stills and use them both in the same mode. I tried simply switching modes and pointing my image to a different bg, but I got garbage. I figure the resolution/color-depth was different or something silly like that.


Or maybe tile modes interpret data differently from bitmap modes. You've been posting here since April; it's high time you read a tutorial already.

Quote:
I'm not scared of tiles, it just seems silly to use them when (as of now) my entire program has a whopping 2 backgrounds that are completely different all over.


It seems a lot less silly when you consider the fact that you can't have multiple backgrounds in the bitmap modes. Which, as any tutorial will tell you, is why most games don't use the bitmap modes.

Dan.

#58585 - Miked0801 - Mon Oct 24, 2005 7:01 pm

Ok, all Bitmap modes on the GBA are hacks. The hardware doesn't like it, and for the most part, developers don't use it. Why? It takes too much away from the video hardware for almost no gain. For the ability to use a flat bitmap as a picture you lose:
* 1/2 of your sprite vram
* Wrapping of bgs
* Multiple bg layers with seperate scrolling
* Much more BG VRAM than you should for the given graphics.
* 4-bit graphics which 99% of the time easily suffice
* Windowing (as no layers)

Take the time (a day or two at most) to learn tile modes. You'll be much more effective.

#58589 - Cearn - Mon Oct 24, 2005 7:34 pm

yeah, yeah, crosspost. And sorry to pile up on you like this, but it needs to be said

thegamefreak0134 wrote:
Why do I need to alpha blend? Why can't I just use two backgrounds with the one on top having a transparent color? Thats all I need. I just need sprites to appear in-between them, thats all.

But you can only have one background in the bitmap modes; if you need to, you have to use tile-modes. (Or use a fake bg made from sprites, or do everything in software which is going to kill you.r performance; but these would still use only one real bg.)

All paletted bgs are transparent for 0-valued pixels; but in mode 4 you usually don't notice because there's nothing to show behind it except the backdrop. In tile modes you can see the transparency more clearly because you have 4 backgrounds. Anyway, to have sprites between two backgrounds you don't need alpha blend, just 2 backgrounds and sprites with the right priorities set.

poslundc wrote:
thegamefreak0134 wrote:

I'm not scared of tiles, it just seems silly to use them when (as of now) my entire program has a whopping 2 backgrounds that are completely different all over.

It seems a lot less silly when you consider the fact that you can't have multiple backgrounds in the bitmap modes.

And that you have only half the number of sprite tiles in bitmap modes.

I recently added some tile-map functionality in usenti's GBA exporter. Open the two images you have, export with a map (preferably with tile reduction) and you'll have a palette, a tileset and a map, ready and formatted for the tile-modes in only a few clicks.

thegamefreak0134 wrote:
I tried simply switching modes and pointing my image to a different bg, but I got garbage. I figure the resolution/color-depth was different or something silly like that.

There is no reason to expect this would have worked. They're called different modes because they act in completely different ways. That's not silly, that's exactly the point of having different modes. Remember, computers do exactly what you tell them to do; if you don't know what you're doing, how could they?

#58595 - thegamefreak0134 - Mon Oct 24, 2005 7:50 pm

I love being a newbie. It's so fun to post a question and have 17 different people give you ways to solve it. It's even more fun to try to figure out what the heck you're talking about. However, the feeling you get when it actually works right is quite astounding and cannot be replaced. You guys are all wonderful, and without you my life would be far from complete.

[/sappiness] That having been said, does this tool you recommended mean I can follow any standard tutorial on tile maps and the resultant tile map will be (look, rather) just as if I had used a Bitmapped mode? (well, kind of?)
_________________
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]

#58598 - Cearn - Mon Oct 24, 2005 8:08 pm

We've all been there I suppose :P But generally speaking, it's wise to look at tutorials (and the FAQ!) before you start posting.

Quote:
[/sappiness] That having been said, does this tool you recommended mean I can follow any standard tutorial on tile maps and the resultant tile map will be (look, rather) just as if I had used a Bitmapped mode? (well, kind of?)

Should work, yeah ... if you use the right setting, of course. Strictly Garbage In, Garbage Out principle. Screenblocks are 32 tiles wide while the screen, and the pictures are probably 240 pixels (30 tiles) wide, which has to be accounted for somehow. And you have to set the bitdepth and such. I'm sorry that I don't have an example worked out for it yet, I will when I have the time. But make sure you have some understanding of how tile-modes work before you start fooling around.

And in case you haven't got them already, get Cowbite spec and GBATek. And the FAQ.