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 > Double buffer overwrites sprites ?

#17488 - doudou - Tue Mar 09, 2004 2:36 pm

I am using this code that I found somewhere in a public project :

#define OAMDataStart (u16*) (0x6010000 + (32 * 512))

I looked at sprite chapter in Jonathan Harbour's book and I read that he is starting writing SpriteData at 0x6010000. If I do this, my sprites are a fu&*$% up. So, I need the 32 * 512, but I don't know why and now, when I have a lot of sprites, i have some problems.

#17489 - doudou - Tue Mar 09, 2004 2:48 pm

Another question (which is more in context with the subject of this post)

I read that the sprite memory in mode 4 is half the size of what it is in mode 0. So, my big problem is that I have a game in mode 0 that switches in mode 4 when displaying the game menu. I use a lot of sprite memory (more than the half of the mode 0 sprite mem) so I when I switch in mode 4 I loose some of my sprites data.

I need a clean way to solve this problem. I though of a buffer that keeps the second half of the sprite data of mode 0 while i am in mode 4, but it is a lot of memory (0x4000 bytes if I'm not mistaking) and I want to be sure that it is the right way to do this.

#17492 - poslundc - Tue Mar 09, 2004 4:10 pm

Why not just reload your sprites when switching from the menu mode back to your gameplay mode?

Dan.

#17501 - tepples - Tue Mar 09, 2004 6:31 pm

Here are memory maps:

Mode 0-2:
0x06000000 pattern table 0
0x06004000 pattern table 1
0x06008000 pattern table 2
0x0600C000 pattern table 3
0x06010000 sprite cels
0x06018000 end of vram

Mode 3-5:
0x06000000 page 0
0x0600A000 page 1 (modes 4 and 5 only)
0x06014000 sprite cels
0x06018000 end of vram

Two bitmap pages are larger than four pattern tables; hence, in bitmap modes, the GBA reserves the first half of sprite cel VRAM for the bitmap.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#17508 - doudou - Tue Mar 09, 2004 7:20 pm

Code:
poslundc : Why not just reload your sprites when switching from the menu mode back to your gameplay mode?


I have ~35 sprites using ~350 8x8 blocks...would'nt it be a little heavy ? I do it once at the beggining of the game and I would say that it take ~3 seconds, which is ok in this case, but in the context of a game menu, I don't think that it's acceptable.

#17511 - tepples - Tue Mar 09, 2004 7:35 pm

It's possible to refill all of sprite cel VRAM during one vblank. Are you using some sort of compression that would make it take longer? If so, you may want to cache decompressed cels in EWRAM.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#17513 - poslundc - Tue Mar 09, 2004 7:41 pm

tepples wrote:
It's possible to refill all of sprite cel VRAM during one vblank.


Besides which, usually there is a transition from one screen to the other (fade to black, fade back up, etc.). Just fade your menu screen to black, load your sprites in and fade it back up. Who cares if it takes an entire frame (which is plenty), or even a dozen frames (about 1/5th of a second) for you to set up the new environment?

Dan.

#17515 - doudou - Tue Mar 09, 2004 7:45 pm

It's ok poslundc, I tried it and the result is acceptable. An optimisation I made is to reload only the sprites that are in the second half of the sprite data mem. Since I use ~350 blocks, i reload ~100 blocks instead of 350.

I think this close this topic, thank you.