(my) Problems with VDP_setMapEx()

SGDK only sub forum

Moderator: Stef

Post Reply
danibus
Very interested
Posts: 135
Joined: Sat Feb 03, 2018 12:41 pm

(my) Problems with VDP_setMapEx()

Post by danibus » Sun Mar 15, 2020 5:40 pm

Good day

I was using VDP_setMapEx() with h.scroll with success, but actually I'm trying to do a different thing and not sure what's happening.

I use VDP_drawImageEx() to draw a background image in PLAN_B (from a PNG file). This one with castle:
fase01_01.png
fase01_01.png (6.08 KiB) Viewed 3791 times
This is ok.

Now I want to draw 2 towers in PLAN_A. I don't want to use sprites to avoid flickering. Towers like this one (72x88px):
fase01_01_torres1A.png
fase01_01_torres1A.png (608 Bytes) Viewed 3791 times
But we will start with only 1 tower, easy way. I want tower to be damaged. So I put 3 different tower desings in one file, and tried to use VDP_setMapEx() to draw it, it depends of the damaged suffered by tower:
fase01_01_torres_destruibles222.png
fase01_01_torres_destruibles222.png (999 Bytes) Viewed 3791 times
This is the code:

Code: Select all

#include <genesis.h>
#include "config.h"
#include "sprite.h"
#include "fondos.h"

//declaracion de variables
static u16 idx_tile_malloc, idx_tile_malloc2;

int main() {

    VDP_setScreenWidth320();
    VDP_setPalette(PAL0,fondo01_01.palette->data);
    //PLAN_B
    VDP_drawImageEx(PLAN_B, &fondo01_01,  TILE_ATTR_FULL(PAL0, FALSE, FALSE, FALSE, 0), 0, 0, FALSE, TRUE);
    idx_tile_malloc += fondo01_01.tileset->numTile;
    //PLAN_A
    Map *mapTorre1 = unpackMap(fondo01_01_T1A.map, NULL);
    VDP_loadTileSet(fondo01_01_T1A.tileset, idx_tile_malloc, CPU);
    VDP_setMapEx(PLAN_A, mapTorre1, TILE_ATTR_FULL(PAL0, FALSE, FALSE, FALSE, idx_tile_malloc), 0, 4, 0, 0, 9, 11);
    idx_tile_malloc2 += fondo01_01.tileset->numTile;

    //BUCLE PRINCIPAL
    while (1) {
        VDP_waitVSync();
    }
	return 0;
}
The problem is this one, PLAN_A is over PLAN_B but no transparency in color 0 tiles (?):

Image
Last edited by danibus on Tue Mar 17, 2020 1:20 pm, edited 1 time in total.

Grind
Very interested
Posts: 69
Joined: Fri Jun 13, 2014 1:26 pm
Location: US
Contact:

Re: Problems with VDP_setMapEx()

Post by Grind » Mon Mar 16, 2020 7:01 pm

It looks like the blue (color index 4 or 13?) is getting drawn instead of the color index 0 (fuchsia in the image). You can see that behind the tower some part of it is transparent. So I think "mapTorre1" has something going on where the unused tiles are not pointing to tile index 0 (which is full transparency by default)

danibus
Very interested
Posts: 135
Joined: Sat Feb 03, 2018 12:41 pm

Re: Problems with VDP_setMapEx()

Post by danibus » Mon Mar 16, 2020 7:18 pm

But see up part of tower (battlements). Also fucsia (color 0) between then but no transparency.
I recheck in GraphicsGale and see no problem in PNGs.

Will try another graphics.

edit: Same problem with another graphics. So I recheck and recheck and problem seems to be in PRIORITY, not in graphics.


//PLAN_B
VDP_drawImageEx(PLAN_B, &fondo01_01, TILE_ATTR_FULL(PAL0, TRUE, FALSE, FALSE, 0), 0, 0, FALSE, TRUE);
idx_tile_malloc += fondo01_01.tileset->numTile;

//PLAN_A
Map *mapTorre1 = unpackMap(fondo01_01_T1A.map, NULL);
VDP_loadTileSet(fondo01_01_T1A.tileset, idx_tile_malloc, CPU);
VDP_setMapEx(PLAN_A, mapTorre1, TILE_ATTR_FULL(PAL0, TRUE, FALSE, FALSE, idx_tile_malloc), 0, 4, 0, 0, 9, 11);
idx_tile_malloc2 += fondo01_01_T1A.tileset->numTile;


Thanks for your help #Grind
My mistake :oops:

Post Reply