Garbled GFX when I add sprite

SGDK only sub forum

Moderator: Stef

Post Reply
POLYGAMe
Very interested
Posts: 151
Joined: Sun Apr 14, 2013 1:19 am
Location: Auckland, New Zealand
Contact:

Garbled GFX when I add sprite

Post by POLYGAMe » Mon Mar 28, 2016 3:24 am

Hi again,

I have got to the stage where I want to start adding sprites. I believe the VDP handles the tiles for me and I don't have to allocate tile memory like I do with the backgrounds, right?

Anyway, the game works fine but when I add the car in, it seems part of the tileset on frame four of my road is being written over. How would I fix this? You can see in the bottom corners.

Here's the code for setting up the BG:

Code: Select all

 // DRAW SKY
    u16 iSkyTileSet;
    iSkyTileSet = TILE_USERINDEX;
    VDP_loadTileSet(sky_tropical.tileset, iSkyTileSet, FALSE);
    Map *map = unpackMap(sky_tropical.map, NULL);
    VDP_setMapEx(APLAN, map, TILE_ATTR_FULL(PAL1, FALSE, FALSE, FALSE, iSkyTileSet), 0, 0, 0, 0, 64, 12);

    // DRAW ROAD
    u16 iRoadTileSet;
    iRoadTileSet = TILE_USERINDEX + sky_tropical.tileset->numTile;
    VDP_loadTileSet(road_tropical.tileset, iRoadTileSet, FALSE);
    Map *map2 = unpackMap(road_tropical.map, NULL);
    VDP_setMapEx(BPLAN, map2, TILE_ATTR_FULL(PAL2, FALSE, FALSE, FALSE, iRoadTileSet), 0, 0, 0, 0, 64, 64);
And the code for setting up sprite:

Code: Select all

// Init buggy sprite
    SPR_initSprite(&sprites[0], &sprite_buggy, 128, 170, TILE_ATTR(PAL3, TRUE, FALSE, FALSE));
    SPR_update(sprites, 1);
I'm going off the sprite demo but not entirely sure what's going on under the hood. lol.

EDIT: I have attached a screen print from GENS debug plane B
Attachments
garbled2.png
garbled2.png (23.59 KiB) Viewed 7123 times
garbled.png
garbled.png (12.73 KiB) Viewed 7125 times

POLYGAMe
Very interested
Posts: 151
Joined: Sun Apr 14, 2013 1:19 am
Location: Auckland, New Zealand
Contact:

Re: Garbled GFX when I add sprite

Post by POLYGAMe » Mon Mar 28, 2016 4:03 am

I tried manually allocating but the following didn't work, either:

Code: Select all

   u16 iBuggyTileSet;
    iBuggyTileSet = TILE_USERINDEX + sky_tropical.tileset->numTile + road_tropical.tileset->numTile;
    SPR_setVRAMTileIndex(&sprite_buggy,iBuggyTileSet);
Gave me the same result...

POLYGAMe
Very interested
Posts: 151
Joined: Sun Apr 14, 2013 1:19 am
Location: Auckland, New Zealand
Contact:

Re: Garbled GFX when I add sprite

Post by POLYGAMe » Mon Mar 28, 2016 4:31 am

Ok, it turns out I'm running out of tiles. I'm going to have to optimise my graphics. Might cut cars in half etc and flip the sprites. I also just realised that my road image isn't set up properly so the flipped duplicated tiles won't be detected and utilised...

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

Re: Garbled GFX when I add sprite

Post by Stef » Mon Mar 28, 2016 11:02 am

Yeah i was to propose you to check if you are not running out of VRAM ;) that is the classic issue we have when that is the case.

POLYGAMe
Very interested
Posts: 151
Joined: Sun Apr 14, 2013 1:19 am
Location: Auckland, New Zealand
Contact:

Re: Garbled GFX when I add sprite

Post by POLYGAMe » Mon Mar 28, 2016 6:02 pm

Hehe the joys of classic systems.

Just looking in gens and my flipped tiles are showing up as unique tiles. Is there a way to fix this? By cutting those I'd save half of my VRAM :)

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

Re: Garbled GFX when I add sprite

Post by Stef » Mon Mar 28, 2016 8:45 pm

Try to download the last rescomp tool directly from the github repository, I believe I fixed this issue few time ago !

POLYGAMe
Very interested
Posts: 151
Joined: Sun Apr 14, 2013 1:19 am
Location: Auckland, New Zealand
Contact:

Re: Garbled GFX when I add sprite

Post by POLYGAMe » Mon Mar 28, 2016 9:30 pm

Stef wrote:Try to download the last rescomp tool directly from the github repository, I believe I fixed this issue few time ago !
Will do. Thanks!

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

Re: Garbled GFX when I add sprite

Post by Stef » Sun Apr 03, 2016 4:08 pm

Unlike i said previously, i didn't update the rescomp in github as there are too many changes to commit that will break everything else.
You will have to wait for the next "official" version of SGDK to finally have this fixed, sorry !

ronin68k
Interested
Posts: 29
Joined: Mon Nov 02, 2015 5:28 am
Location: Krasnodar, Russia

Re: Garbled GFX when I add sprite

Post by ronin68k » Mon Jun 20, 2016 5:28 am

Hi, guys! Sorry if i posted it to a wrong place, but i think, i have almost similar problem.
(and i think the problem is me)

Im trying to draw complete Mortal Kombat arena background and it shows me this...
Image

I presume, original Mortal Kombat game uses partical BG drawing, but since im noob, i can't do the same :lol:
is this SGDK problem or just me?

here is the rom with sources

Thank y'all, luw y'all <3

dub
Very interested
Posts: 101
Joined: Thu Mar 19, 2015 1:26 pm

Re: Garbled GFX when I add sprite

Post by dub » Mon Jun 20, 2016 8:36 am

I don't know if you post in the wrong place :mrgreen:

But for your gfx problem. You have by default a plan size of 64 tiles. So your picture must be 64 tiles * 8 pixels = 512 pixels width. So the last pixel will be drawn at the beginning of your plan over the existing image.

You're picture size is 800+ pixels. So you can change the plan size to 128tiles (1024 pixels) with VDP_setPlanSize( 128, 32); You can see the plan (A / B) with gensKMod in CPU -> Debug -> Plan

Code: Select all

int main()
{
    u16 palette[64];

    // disable interrupt when accessing VDP
    SYS_disableInts();
    // initialization
    VDP_setScreenWidth320();
	
	
				VDP_setPlanSize( 128, 32);

    // init sprites engine
    SPR_init(16, 256, 256);

    // set all palette to black
    VDP_setPaletteColors(0, (u16*) palette_black, 64);
    ....
    ....

ronin68k
Interested
Posts: 29
Joined: Mon Nov 02, 2015 5:28 am
Location: Krasnodar, Russia

Re: Garbled GFX when I add sprite

Post by ronin68k » Mon Jun 20, 2016 10:35 am

It solved the problem! :D
Thanks, my friend! <3

Post Reply