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 > character memory

#14304 - plasma - Sun Jan 04, 2004 1:59 am

If i were to remove sprite info from the OAMData (character memory), how would it be done in c/c++?

#14306 - yaustar - Sun Jan 04, 2004 2:10 am

interesting question, now that I think about it, i dont know either :/
I would think that the simple answer is not to 'read' from it or reinitialise it with a null value.

That is my guess anyhow...
_________________
[Blog] [Portfolio]

#14311 - sajiimori - Sun Jan 04, 2004 2:38 am

I don't understand the point of the question. You can read and write to character RAM at any time.

"Remove info" doesn't carry any particular meaning (unless you're talking about reducing entropy, which I seriously doubt).

#14312 - plasma - Sun Jan 04, 2004 2:51 am

"info" refers to the sprite's data. I want to know how to get rid of or 'release' it (traces back to shadow OAM) so i don't exceed character memory boundaries. Is that clear? i hope it is... I dont want to download the whole SGADE lib with this slow internet connection

#14313 - poslundc - Sun Jan 04, 2004 2:54 am

If you just don't want one of the 128 objects to display, then set one of its coordinates so that it is off the screen (eg. x = 240 or y = 160).

Dan.

#14314 - plasma - Sun Jan 04, 2004 3:14 am

I know that works with 128 sprites but my problem is i have more than 128. Plus, a few sprites with their animation frames are larger than the 512 8x8 tiles that 0x6010000 can store (256 color sprites).

#14316 - tepples - Sun Jan 04, 2004 3:36 am

What kind of game are you trying to make that needs more than 128 sprites on the screen at once? There are advanced techniques to handle that, but I want to know what you want to do before I explain that.

If you have more than 128 objects in a level, but not all of them will be visible at once, you can do something like this:

Code:
int oam_idx = 0;
for(i = 0; i < n_level_objects && oam_idx < 128; i++)
  if(sprite_is_visible(i))  /* check if it 1. is alive and 2. overlaps the visible area */
  {
    copy_sprite_to_oam(oam_idx, i);  /* copy sprite i's attributes to OAM */
    oam_idx++;
  }
for(; oam_idx < 128; oam_idx++)
  hide_oam_sprite(oam_idx);

_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#14320 - sajiimori - Sun Jan 04, 2004 8:29 am

Maybe I'm way off base here, but it sounds to me like you're thinking of OAM and character RAM as data storage warehouses, when the more appropriate metaphor is a communication channel with the hardware.

Use the OAM to send a message to the GBA about what kind of sprite you want to be displayed, not to store information about all the sprites that might potentially appear.

Use character RAM to tell the GBA what on-screen sprites should look like for the current frame, not to store every frame of every animation for every actor.

Your storage areas are ROM, IWRAM, and EWRAM. Build your own data structures to hold what you need, then upload information to the OAM and character RAM that is relevant to the current frame.

#14322 - RaBBi - Sun Jan 04, 2004 4:00 pm

Sorry to not bring any info or any help for this subject, but I only have qa question.
I have posted it somewhere yet but didn't have a consequent answer.

So I'd like to know what you call "Character Ram", cause I read many times the GBA hardware specifications, and never saw these terms.

Is this the "Tile Data Memory" for Sprite? Or the entire tile data memory ?
What's the adress od this RAM ?

Thank you ^^
_________________
Sorry for my poor english, but it would be worst for you to understand me if I speak in my native language, French ^^

#14323 - jma - Sun Jan 04, 2004 4:48 pm

The difference here is sprite character data and sprite data. The first resides in VRAM after the 4th character block (of tile data). The second resides at 0x7000000 (OAM).

The first is just like character block data -- it tells the GBA what a sprite looks like (pixel colors). The second (OAM) is information that handles displaying a sprite: where it is, what palette it uses, which character data to use, etc.

Jeff
_________________
massung@gmail.com
http://www.retrobyte.org

#14324 - RaBBi - Sun Jan 04, 2004 8:30 pm

Thanks jma ^^

It is exactly what I supposed to be ^^
I just needed confirmation.

But perhaps in the future would be preferable that I use "character" and not "tiles" when I would talk about 8x8 pixels blocs here?
_________________
Sorry for my poor english, but it would be worst for you to understand me if I speak in my native language, French ^^

#14325 - plasma - Sun Jan 04, 2004 9:21 pm

Thanks for all the help (although yaustar's the only one who understood my question), I need as much as I can get.

#14329 - tepples - Mon Jan 05, 2004 3:45 am

RaBBi wrote:
So I'd like to know what you call "Character Ram", cause I read many times the GBA hardware specifications, and never saw these terms.

The term predates the GBA. Some NES carts stored tile and sprite cel data in a "CHR ROM"; other NES carts stored the data in the main program ROM and contained 8 KB of "CHR RAM" that worked much like the original Game Boy's VRAM. Some tutorials written by people with experience on older machines may use the terminology of older machines for analogous part of a newer machine, especially if they aren't licensees and thus haven't seen the official docs.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.