Page 1 of 1

Layer priority

Posted: Thu Apr 05, 2018 4:00 pm
by Boyfinn
Is it possible to render both A and B planes before the sprite layer, Or changing said order dynamically?

Re: Layer priority

Posted: Thu Apr 05, 2018 4:11 pm
by Stef
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 :)

Re: Layer priority

Posted: Thu Apr 05, 2018 6:44 pm
by Sik
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.

Re: Layer priority

Posted: Thu Apr 05, 2018 9:05 pm
by Boyfinn
Cool. Any examples how to manipulate the priority in a map?

Re: Layer priority

Posted: Fri Apr 06, 2018 7:59 am
by Stef
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 ;)

Re: Layer priority

Posted: Tue May 01, 2018 8:46 am
by Boyfinn
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?

Re: Layer priority

Posted: Tue May 01, 2018 9:36 am
by Stef
That is the correct way of doing that. What is the result you obtain and what you expected exactly ?

Re: Layer priority

Posted: Tue May 01, 2018 10:24 am
by Boyfinn
Nevermind, High priority planes seem to work by using the priority numbers 5&6

Re: Layer priority

Posted: Tue May 01, 2018 3:50 pm
by Stef
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).