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 > Sprites and OAMEntry

#14502 - LOst? - Wed Jan 07, 2004 5:58 pm

I don't know how many sources I've downloaded, everyone gives the same result. You copy all OAMEntry's at a time, and set all X and Y positions to 240+, 160+ just to hide them. Have you ever looked into a commercial game like Mario Advance? Open OAM viewer in VisualBoyAdvance and you will see you're doing wrong :(

Why do you have to hide your sprites when real commercial games don't need to?

#14503 - tepples - Wed Jan 07, 2004 6:07 pm

Real commercial games seem to write 0x0200 (double-size, 1:1 pixel mapping) to a sprite's Y attribute to hide it. The GBA video hardware treats double-size without rot/scale as a request not to process the sprite.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#14505 - Miked0801 - Wed Jan 07, 2004 6:18 pm

Which is how the Nintendo doc suggest doing it.

#14506 - LOst? - Wed Jan 07, 2004 6:19 pm

tepples wrote:
Real commercial games seem to write 0x0200 (double-size, 1:1 pixel mapping) to a sprite's Y attribute to hide it. The GBA video hardware treats double-size without rot/scale as a request not to process the sprite.


And why doesn't most of you do that aswell?

I would die for a open source game that treats things like a commercial game

#14507 - poslundc - Wed Jan 07, 2004 6:38 pm

And now that we know, we can go about doing that! :)

Not to seem ungrateful, as they were extremely helpful getting started, but it's hard to get through those tutorials without picking up some nasty habits along the way, even if you are an experienced coder.

Dan.

#14508 - DiscoStew - Wed Jan 07, 2004 7:32 pm

This is just my opinion, but I guess the reason why everyone here started doing the +240 +160 to hide a sprite could be because of the hardware sprite rotation/scaling. They figured that they will probably use rotation/scaling, so by doing the +240 +160 would keep the sprite from displaying no matter what happen. If you were using rotation/scaling, you'd have to remove the ROTATION_FLAG from Attribute0 along with adding DOUBLE_SIZE to Attribute1. You'd usually have to call 2 lines of code to do this, but using the +240 +160 can be done with 2 lines of code also. So in this case scenario, doing either one wouldn't make any difference, would it? I understand when not using rotation/scaling that using DOUBLE_SIZE would be more effective.

Perhaps if you were to make an array overlapping the OAMData memory using u32 to combine attribute0 and attribute1 (much like the array used for rotation/scaling from ThePernProject, perhaps just fix up the current array being used), you could set each unused sprite with one line of code, though using either method could be done this way also.
_________________
DS - It's all about DiscoStew

#14510 - tepples - Wed Jan 07, 2004 7:40 pm

LOst? wrote:
tepples wrote:
Real commercial games seem to write 0x0200 (double-size, 1:1 pixel mapping) to a sprite's Y attribute to hide it.

And why doesn't most of you do that aswell?

Probably because some of us have built up habits on older systems whose sprite systems didn't have a "hidden" attribute. On the NES, it was common practice to hide a sprite by putting it at (0, 240).

In pin8gba.h (my GBA header, which consistently spells register names differently from how the purported official docs spell them because I find my names clearer and less "tainted" by trade secrets), I have the following:
Code:
#define OAM_AFFINE      0x0100
#define OAM_HIDDEN      0x0200
#define OAM_AFFINE2X    0x0300

each of which is ORed into the Y attribute when placing each sprite. For sprites that aren't in use, my code just sets their Y attribute to OAM_HIDDEN and leaves it at that.

Quote:
I would die for a open source game that treats things like a commercial game

Free software developers do not have access to trade-secret official docs.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#14511 - LOst? - Wed Jan 07, 2004 7:56 pm

tepples wrote:
LOst? wrote:
tepples wrote:
Real commercial games seem to write 0x0200 (double-size, 1:1 pixel mapping) to a sprite's Y attribute to hide it.

And why doesn't most of you do that aswell?

Probably because some of us have built up habits on older systems whose sprite systems didn't have a "hidden" attribute. On the NES, it was common practice to hide a sprite by putting it at (0, 240).

In pin8gba.h (my GBA header, which consistently spells register names differently from how the purported official docs spell them because I find my names clearer and less "tainted" by trade secrets), I have the following:
Code:
#define OAM_AFFINE      0x0100
#define OAM_HIDDEN      0x0200
#define OAM_AFFINE2X    0x0300

each of which is ORed into the Y attribute when placing each sprite. For sprites that aren't in use, my code just sets their Y attribute to OAM_HIDDEN and leaves it at that.

Quote:
I would die for a open source game that treats things like a commercial game

Free software developers do not have access to trade-secret official docs.


Maybe you can give me your source? It would be helpful if you wrote a little sprite test program for me ;)

#14513 - DiscoStew - Wed Jan 07, 2004 9:35 pm

I take that back on what I said. Perhaps I should refer to documentation before posting anything anymore. I always seem to mix things up. Both flags are in attribute0, which makes using DOUBLE_SIZE very reasonable to hide a sprite. My bad.
_________________
DS - It's all about DiscoStew

#14525 - tepples - Thu Jan 08, 2004 12:26 am

Quote:
Maybe you can give me your source? It would be helpful if you wrote a little sprite test program for me ;)

Oh shoot. I just realized that none of the demos I already have on pineight.com use sprites significantly; they use backgrounds for almost everything. What do you want to see done?
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#14527 - dagamer34 - Thu Jan 08, 2004 1:14 am

One reason is because you have to manage the state of sprites when they are in rotation/scaling mode.

If you have a sprite and don't know whether it uses a rotation set or not, you have to keep a temporary copy of the rotation flag globally, then turn on the SIZE_DOUBLE flag, and then turn off the rotation flag. And the exact opposite is for showing a sprite.

We are lazy. I have seen few games worthy of commercial quality. Most of them are demos that show off a feature or effect, so it doesn't matter to them.

Good point anyway. I hide my sprites the official way!!

*wonders how a person like you got their hands on official docs... looks for Nintendo's phone number...*
_________________
Little kids and Playstation 2's don't mix. :(

#14535 - sajiimori - Thu Jan 08, 2004 2:15 am

Quote:

If you have a sprite and don't know whether it uses a rotation set or not, you have to keep a temporary copy of the rotation flag globally, then turn on the SIZE_DOUBLE flag, and then turn off the rotation flag. And the exact opposite is for showing a sprite.

Yet another reason that it's a bad idea to use OAM entries as a storage area for information about your game's actors. Keep your permanent information in seperate data structures, and use OAM to tell the hardware what you want for the current frame.

#14543 - LOst? - Thu Jan 08, 2004 4:40 am

sajiimori wrote:
Quote:

If you have a sprite and don't know whether it uses a rotation set or not, you have to keep a temporary copy of the rotation flag globally, then turn on the SIZE_DOUBLE flag, and then turn off the rotation flag. And the exact opposite is for showing a sprite.

Yet another reason that it's a bad idea to use OAM entries as a storage area for information about your game's actors. Keep your permanent information in seperate data structures, and use OAM to tell the hardware what you want for the current frame.


Yea, I really want sprites to work like the commercial games' ones

Quote:
Oh shoot. I just realized that none of the demos I already have on pineight.com use sprites significantly; they use backgrounds for almost everything. What do you want to see done?


I have a little problem with DMA in the game loop for the moment, but when that's fixed, I want to be able to have 128 sprites whenever I want the game too, not all the time like in the pern project samples

#14654 - LOst? - Sat Jan 10, 2004 6:56 am

tepples wrote:
LOst? wrote:
tepples wrote:
Real commercial games seem to write 0x0200 (double-size, 1:1 pixel mapping) to a sprite's Y attribute to hide it.

And why doesn't most of you do that aswell?

Probably because some of us have built up habits on older systems whose sprite systems didn't have a "hidden" attribute. On the NES, it was common practice to hide a sprite by putting it at (0, 240).

In pin8gba.h (my GBA header, which consistently spells register names differently from how the purported official docs spell them because I find my names clearer and less "tainted" by trade secrets), I have the following:
Code:
#define OAM_AFFINE      0x0100
#define OAM_HIDDEN      0x0200
#define OAM_AFFINE2X    0x0300

each of which is ORed into the Y attribute when placing each sprite. For sprites that aren't in use, my code just sets their Y attribute to OAM_HIDDEN and leaves it at that.

Quote:
I would die for a open source game that treats things like a commercial game

Free software developers do not have access to trade-secret official docs.


Thanks for the info tepples! It really helped. All my sprites work now. I jst spent a few hours making a sprite library, and it's great!

#14658 - CcSoccer881 - Sat Jan 10, 2004 9:24 am

GG Lost.. took me a few days to get mine working but I finally got the sprite management working... lets me add/remove/replace sprites.. if you wanna help each other out, my aim is signetofthetrinity
_________________
www.rsstudios.net

#14693 - LOst? - Sun Jan 11, 2004 5:17 pm

CcSoccer881 wrote:
GG Lost.. took me a few days to get mine working but I finally got the sprite management working... lets me add/remove/replace sprites.. if you wanna help each other out, my aim is signetofthetrinity


We have to see about that :P