Layer priority

SGDK only sub forum

Moderator: Stef

Post Reply
Boyfinn
Interested
Posts: 49
Joined: Sat Aug 08, 2015 12:12 pm
Location: Lapland, Finland

Layer priority

Post by Boyfinn » Thu Apr 05, 2018 4:00 pm

Is it possible to render both A and B planes before the sprite layer, Or changing said order dynamically?

User avatar
Stef
Very interested
Posts: 2801
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: Layer priority

Post by Stef » Thu Apr 05, 2018 4:11 pm

Yep :
put plan B and plan A in high priority while using low priority sprites.
You can set priority per tile on plan, and per sprite, that offer many possibilities :)

User avatar
Sik
Very interested
Posts: 736
Joined: Thu Apr 10, 2008 3:03 pm
Contact:

Re: Layer priority

Post by Sik » Thu Apr 05, 2018 6:44 pm

And don't forget that the priority bit is per-tile in plane A and B.

But yeah, that's the purpose of the priority bit. In order (from furthest to nearest):
  • Background color
  • Low priority plane B
  • Low priority plane A
  • Low priority sprites
  • High priority plane B
  • High priority plane A
  • High priority sprites
Note: window plane takes up the same layer as plane A.
Sik is pronounced as "seek", not as "sick".

Boyfinn
Interested
Posts: 49
Joined: Sat Aug 08, 2015 12:12 pm
Location: Lapland, Finland

Re: Layer priority

Post by Boyfinn » Thu Apr 05, 2018 9:05 pm

Cool. Any examples how to manipulate the priority in a map?

User avatar
Stef
Very interested
Posts: 2801
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: Layer priority

Post by Stef » Fri Apr 06, 2018 7:59 am

You can update / set TileMap using the VDP_fillTileMapxxx(...) or VDP_setTileMapxxx(...) methods.
Then you can use the TILE_ATTR(..) or TILE_ATTR_FULL(..) macros on any methods (mentioned above) using basetile or baseflags arguments.
But before telling you that, you need to know how work the Megadrive VDP and what is a tilemap ;)

Boyfinn
Interested
Posts: 49
Joined: Sat Aug 08, 2015 12:12 pm
Location: Lapland, Finland

Re: Layer priority

Post by Boyfinn » Tue May 01, 2018 8:46 am

What values do i insert into TILE_ATTR_FULL as layer priority?
Currently im doing this:

Code: Select all

    VDP_drawImageEx(PLAN_A, &plan_a0, TILE_ATTR_FULL(PAL0, 1, FALSE, FALSE, ind), 0, 0, FALSE, TRUE);
    ind += plan_a0.tileset->numTile;
    VDP_drawImageEx(PLAN_B, &plan_b0, TILE_ATTR_FULL(PAL0, 0, FALSE, FALSE, ind), 0, 0, FALSE, TRUE);
    ind += plan_b0.tileset->numTile;
    VDP_drawImageEx(PLAN_A, &plan_a1, TILE_ATTR_FULL(PAL0, 1, FALSE, FALSE, ind), 0, 16, FALSE, TRUE);
    ind += plan_a1.tileset->numTile;
    VDP_drawImageEx(PLAN_B, &plan_b1, TILE_ATTR_FULL(PAL0, 0, FALSE, FALSE, ind), 0, 30, FALSE, TRUE);
    ind += plan_b1.tileset->numTile;
but the order doesnt seem to work how i want it to.
do the layer priorities go through 0 to 1 or something else?

User avatar
Stef
Very interested
Posts: 2801
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: Layer priority

Post by Stef » Tue May 01, 2018 9:36 am

That is the correct way of doing that. What is the result you obtain and what you expected exactly ?

Boyfinn
Interested
Posts: 49
Joined: Sat Aug 08, 2015 12:12 pm
Location: Lapland, Finland

Re: Layer priority

Post by Boyfinn » Tue May 01, 2018 10:24 am

Nevermind, High priority planes seem to work by using the priority numbers 5&6

User avatar
Stef
Very interested
Posts: 2801
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: Layer priority

Post by Stef » Tue May 01, 2018 3:50 pm

priority number 5&6 ??
Normally you should use 0 / 1 values (or FALSE / TRUE) for priority field otherwise you hit other fields (with 5/6 you change palette info as well).

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest