Gameboy Development Forum

Discussion about software development for the old-school Gameboys, ranging from the "Gray brick" to Gameboy Color
(Launched in 2008)

You are not logged in.

#1 2017-03-29 23:59:33

Alexander the bat
Member
Registered: 2017-03-19
Posts: 31

Sprite layering Question about Gameboy and Gameboy Color

I'm reading this just to get an eye on how to do spriting layers http://gbdev.gg8.se/wiki/articles/GBDK_Sprite_Tutorial and the note says: Careful! The DMG and the GBC handle sprite layering differently. The DMG draws whichever sprite has the lowest X value on top, while the GBC draws the sprite with the lowest sprite tile value on top. This will cause inconsistency if you're developing for both.

So what does this mean? I'm basically working on a backwards version of the Gameboy color that is DMG mode and Color Mode I'm basically confused on this note on how the two Gameboys does it differently

how I can avoid this if I'm doing both Gameboys? I'm sure it written differently if I look at the color tutorial.

Offline

 

#2 2017-03-30 00:44:02

ssjason123
Member
Registered: 2017-03-21
Posts: 45

Re: Sprite layering Question about Gameboy and Gameboy Color

It's not something you can avoid. It is simply the way the hardware behaves. It means that on GBC the top level sprite will be based on its entry in the OAM table and on GB the sprite displayed on top will be based on the sprites X-coordinate.

For example if you have two sprites in the OAM:
Sprite 1 is at 30 on the X
Sprite 2 is as 29 on the X

On GBC Sprite 1 will be drawn on top due to the priority of its entry in the OAM table.
On GB Sprite 2 will be drawn on top due to it having a lower X coordinate.

Check out the sprite priorities and conflicts section in the pandocs for more info:
http://bgb.bircd.org/pandocs.htm#vramsp … tetableoam

Offline

 

#3 2017-03-30 01:03:24

Alexander the bat
Member
Registered: 2017-03-19
Posts: 31

Re: Sprite layering Question about Gameboy and Gameboy Color

ssjason123 wrote:

It's not something you can avoid. It is simply the way the hardware behaves. It means that on GBC the top level sprite will be based on its entry in the OAM table and on GB the sprite displayed on top will be based on the sprites X-coordinate.

For example if you have two sprites in the OAM:
Sprite 1 is at 30 on the X
Sprite 2 is as 29 on the X

On GBC Sprite 1 will be drawn on top due to the priority of its entry in the OAM table.
On GB Sprite 2 will be drawn on top due to it having a lower X coordinate.

Check out the sprite priorities and conflicts section in the pandocs for more info:
http://bgb.bircd.org/pandocs.htm#vramsp … tetableoam

That will come in handy also how i can easly make sure my sprites render in the GBC backwards compatibility mode (black carts ones?)

is tha harder to code or it uses the Color's way?

Offline

 

#4 2017-03-30 01:09:09

ssjason123
Member
Registered: 2017-03-21
Posts: 45

Re: Sprite layering Question about Gameboy and Gameboy Color

It's just a matter of managing which OAM index's you assign your sprites to. Assigning sprites you want to display on top to the lower entries in the OAM table will keep them on top for GBC. As for GB there is nothing you can do, once your sprite moves to a higher X coordinate it will pop behind the other sprite.

Offline

 

#5 2017-04-04 19:46:34

Alexander the bat
Member
Registered: 2017-03-19
Posts: 31

Re: Sprite layering Question about Gameboy and Gameboy Color

ssjason123 wrote:

It's just a matter of managing which OAM index's you assign your sprites to. Assigning sprites you want to display on top to the lower entries in the OAM table will keep them on top for GBC. As for GB there is nothing you can do, once your sprite moves to a higher X coordinate it will pop behind the other sprite.

Could you do an example so I know what to program with? that way I can learn from there on how it works and stuff so I can do BGB Debugging and REAL Hardware Testing.

Offline

 

#6 2017-04-05 00:43:59

ssjason123
Member
Registered: 2017-03-21
Posts: 45

Re: Sprite layering Question about Gameboy and Gameboy Color

The tutorial you originally linked provides everything you need to know to draw a sprite to the screen. To test the behavior all you need to do is draw multiple sprites. Leave one sprite at a fixed position and move the other sprite across it on the X-axis. Perform this test for two cases, once where the moving sprite is at a higher index in the OAM table and again where the moving sprite is at a lower index in the OAM table. Observe which sprite is displayed on top of the other.

The first argument in the set_sprite/move_sprite functions defines the index of the sprite entry in the OAM table.

I think this is such a small technical detail that you shouldn't worry about it until you observe an undesired behavior with the sprite render order. Where the fix is just changing the order you assign sprites in the OAM table.

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson