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.

Coding > cloning sprites?

#6029 - marky - Thu May 15, 2003 6:10 pm

I am new to GBA programming and I don't know anything about the architecture other than what I read in the Pern Project (which is excellent and bootstrapped me a long way). But I just encountered a limitation of the sprite architecture that surprises me.

I (naively?) thought that if I had 2 separate sprite objects (different sets of registers in OAM) pointing to the same tile sequences in character memory (not duplicated), the sprites could animate independently. But I'm finding (at least with 2 different emulators) that sprites that point to the same tile sequences cannot animate indepently. They can have independent screen positions but they cannot display different frames, different zooms, etc. Is this right or should I hunt harder for bugs in my code?

If sprites are limited in this way, is there any way to clone sprites without duplicating images in character memory.

Regards,
Mark

p.s. Here's my work-in-progress http://www.vizmo.com/bin/dragonVsPawn.gba (103kb). No gameplay or battle yet - just dragon flying with the D-pad, fireballs with A-button and enemy who comes out when you fly over one of the skull towers.

#6033 - tepples - Thu May 15, 2003 6:25 pm

marky wrote:
But I'm finding (at least with 2 different emulators) that sprites that point to the same tile sequences cannot animate indepently. They can have independent screen positions but they cannot display different frames, different zooms, etc. Is this right or should I hunt harder for bugs in my code?

Short answer: It's your code.

Long answer: Each sprite can point to a different tile number for its cel data. The GBA has no concept of "sequences" in cel data. Each sprite can also point to a separate zoom register. There are 32 different zoom registers.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#6035 - DekuTree64 - Thu May 15, 2003 6:31 pm

Well if both sprites point to the same tile, of course they will always be the same. You can load in the whole animation sequence though, and then you can have each sprite point to the frame in the sequence that they're currently using. That way, if say you have 100 different sprites that all look the same with a 2-frame walking animation, you just load in the 2 frames, and have each sprite point to the one they're currently on.Of course you'll probably have more frames than that, and more directions too, so it might be better to just have each sprite with its own block of VRAM to update whenever it changes frames, even though you might have multiple copies sometimes.

#6041 - marky - Thu May 15, 2003 7:36 pm

Thanks for sobering me up and reminding me that OAM only points to one tile. I'm confusing my API with the architecture. Gracias.
mark

tepples wrote:
marky wrote:
But I'm finding (at least with 2 different emulators) that sprites that point to the same tile sequences cannot animate indepently. They can have independent screen positions but they cannot display different frames, different zooms, etc. Is this right or should I hunt harder for bugs in my code?

Short answer: It's your code.

Long answer: Each sprite can point to a different tile number for its cel data. The GBA has no concept of "sequences" in cel data. Each sprite can also point to a separate zoom register. There are 32 different zoom registers.

#6044 - niltsair - Thu May 15, 2003 7:49 pm

Yeah, you just have to basicly think of sprites as 2 entity:
-OAM : Object that tells the attribute of each sprite (pos, palette, rot/size, tile to use, etc..)
-Tiles : The tiles that each OAM Object can use. Shared by all OAM.