Displaying the titlescreen corruption

SGDK only sub forum

Moderator: Stef

Post Reply
orlanrod
Very interested
Posts: 99
Joined: Fri Sep 25, 2015 7:46 pm

Displaying the titlescreen corruption

Post by orlanrod » Sun Oct 11, 2015 8:07 pm

I think one is overriding another in memory, but not sure. This is what is happening on screen.

titlebg_tiles in BPLAN is corrupted.
The titlelogo_tiles in APLAN is displaying correctly.
sjaris_sprite is displaying correctly.
fcitizen_sprite is displaying with a green colors, rather then its own red colors in its palette.

Here is the code.

u16 palette[96];

VDP_setPaletteColors(0, palette_black, 96);

titlebgmap = unpackMap(titlebg_tiles.map, NULL);
indb = TILE_USERINDEX;
VDP_loadTileSet(titlebg_tiles.tileset, indb, TRUE);
VDP_setMapEx(BPLAN, titlebgmap, TILE_ATTR_FULL(PAL0, FALSE, FALSE, FALSE, indb), PlanXPosInTile, PlanYPosInTile, MapXPosInTile, MapYPosInTile, MapWidthInTile, MapHeightInTile);
indb += titlebg_tiles.tileset->numTile;

titlelogomap = unpackMap(titlelogo_tiles.map, NULL);
inda = TILE_USERINDEX;
VDP_loadTileSet(titlelogo_tiles.tileset, inda, TRUE);
VDP_setMapEx(APLAN, titlelogomap, TILE_ATTR_FULL(PAL1, FALSE, FALSE, FALSE, inda), 9, 1, 0, 0, 20, 17);
inda += titlelogo_tiles.tileset->numTile;

memcpy(&palette[0], titlebg_tiles.palette->data, 16 * 2);
memcpy(&palette[16], titlelogo_tiles.palette->data, 16 * 2);
memcpy(&palette[32], sjaris_sprite.palette->data, 16 * 2);
memcpy(&palette[64], fcitizen_sprite.palette->data, 16 * 2);

VDP_fadeIn(0, (3 * 16) - 1, palette, 20, FALSE);

orlanrod
Very interested
Posts: 99
Joined: Fri Sep 25, 2015 7:46 pm

Re: Displaying the titlescreen corruption

Post by orlanrod » Sun Oct 11, 2015 10:00 pm

Apparently using TILEUSERINDEX to load the next tilemap is what was causing that problem. i just use indb = 0; for one map and it works.

But now i need to fix why the fcitizen sprite is not showing its colors right.

orlanrod
Very interested
Posts: 99
Joined: Fri Sep 25, 2015 7:46 pm

Re: Displaying the titlescreen corruption

Post by orlanrod » Sun Oct 11, 2015 10:18 pm

So i stop using the fade in with the palette array, since apparently i do not know how to use it yet.
Now i just use VDP_setPalette(PAL(0,1,2...), sprite.palette->data); for each tilemap and sprite. That works fine.

I'll leave this post unsolved for now, but if you want to tell me how to use it go ahead and post, and i'll redo it.
moving onto the next thing for now.

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

Re: Displaying the titlescreen corruption

Post by Stef » Mon Oct 12, 2015 9:27 am

You should not have separate indb and inda, background plan share the same memory for their tiles.
So basically here by doing that :

Code: Select all

inda = TILE_USERINDEX;
VDP_loadTileSet(titlelogo_tiles.tileset, inda, TRUE);
you are overriding tiles from plan B by the tiles from plan A.

Just use :

Code: Select all

VDP_loadTileSet(titlelogo_tiles.tileset, ind, TRUE);
You just need to save in separate variable position of indb and inda for future reference in the setMapEx(..) methods but definitely you should keep tiles of both plan in different VRAM area.

orlanrod
Very interested
Posts: 99
Joined: Fri Sep 25, 2015 7:46 pm

Re: Displaying the titlescreen corruption

Post by orlanrod » Mon Oct 12, 2015 4:20 pm

Stef wrote:You should not have separate indb and inda, background plan share the same memory for their tiles.
So basically here by doing that :

Code: Select all

inda = TILE_USERINDEX;
VDP_loadTileSet(titlelogo_tiles.tileset, inda, TRUE);
you are overriding tiles from plan B by the tiles from plan A.

Just use :

Code: Select all

VDP_loadTileSet(titlelogo_tiles.tileset, ind, TRUE);
You just need to save in separate variable position of indb and inda for future reference in the setMapEx(..) methods but definitely you should keep tiles of both plan in different VRAM area.
Ah i see. I have corrected it now, and now using one var.

Post Reply