Page 1 of 1

VDP_loadTileSet, problems in console.

Posted: Fri Feb 15, 2019 2:54 pm
by cloudstrifer
Hi!

I have a problem, I want to change tiles in specific positions.
But randomly (~1 in 30), only on Mega Drive shows wrong tile, the last in PLAN_B.

Tests using Mega Drive model 1 and Mega Everdrive v2.

Thank you!

Load full background

Code: Select all

		ind = TILE_USERINDEX;
		VDP_loadTileSet(bgb_image.tileset, ind, TRUE);
		VDP_waitDMACompletion();
		VDP_setMapEx(PLAN_B, bgb_image.map, TILE_ATTR_FULL(PAL0, FALSE, FALSE, FALSE, ind), PlanXPosInTile, PlanYPosInTile, MapXPosInTile, MapYPosInTile, MapWidthInTile, MapHeightInTile);
		ind += bgb_image.tileset->numTile;

		VDP_loadTileSet(bga_image.tileset, ind, TRUE);
		VDP_waitDMACompletion();
		VDP_setMapEx(PLAN_A, bga_image.map, TILE_ATTR_FULL(PAL3, FALSE, FALSE, FALSE, ind), PlanXPosInTile, PlanYPosInTile, MapXPosInTile, MapYPosInTile, MapWidthInTile, MapHeightInTile);
		ind += bga_image.tileset->numTile;

Change tiles, 16 x16, dig1 or dig2.

Code: Select all

	if(digGrid[newPosition.x][newPosition.y] == 1){
		if(digTile1Ind == 0){
			VDP_loadTileSet(dig_1.tileset, ind, TRUE);
			VDP_waitDMACompletion();
			VDP_setMapEx(PLAN_B, dig_1.map, TILE_ATTR_FULL(PAL0, TRUE, FALSE, FALSE, ind), newPosition.x * 2, newPosition.y * 2, 0, 0, 2, 2);
			VDP_waitDMACompletion();
			digTile1Ind = ind;
			ind += dig_1.tileset->numTile;
		}
		else{
			//VDP_loadTileSet(dig_1.tileset, digTile1Ind, TRUE);
			VDP_setMapEx(PLAN_B, dig_1.map, TILE_ATTR_FULL(PAL0, TRUE, FALSE, FALSE, digTile1Ind), newPosition.x * 2, newPosition.y * 2, 0, 0, 2, 2);
		}

		digGrid[newPosition.x][newPosition.y] = 2;
		animDigCount_p1 = 0;
	}
	else if(digGrid[newPosition.x][newPosition.y] == 2){
		if(digTile2Ind == 0){
			VDP_loadTileSet(dig_2.tileset, ind, TRUE);
			VDP_waitDMACompletion();
			VDP_setMapEx(PLAN_B, dig_2.map, TILE_ATTR_FULL(PAL0, TRUE, FALSE, FALSE, ind), newPosition.x * 2, newPosition.y * 2, 0, 0, 2, 2);
			VDP_waitDMACompletion();
			digTile2Ind = ind;
			ind += dig_2.tileset->numTile;
		}
		else{
			//VDP_loadTileSet(dig_2.tileset, digTile2Ind, TRUE);
			VDP_setMapEx(PLAN_B, dig_2.map, TILE_ATTR_FULL(PAL0, TRUE, FALSE, FALSE, digTile2Ind), newPosition.x * 2, newPosition.y * 2, 0, 0, 2, 2);
			VDP_waitDMACompletion();
		}

		digGrid[newPosition.x][newPosition.y] = 3;
		animDigCount_p1 = 0;
		dropItem(newPosition.x, newPosition.y);
	}
Rom Download
rom.rar
(115.58 KiB) Downloaded 236 times

Re: VDP_loadTileSet, problems in console.

Posted: Sat Feb 16, 2019 10:54 am
by Stef
If that is not already the case, it's important to not forget to protect any VDP access from interruption, for that you can use the SYS_disableInts() / SYS_enableInts() methods.

Re: VDP_loadTileSet, problems in console.

Posted: Sat Feb 16, 2019 5:12 pm
by cloudstrifer
I will check that.

Thank you Stef.

Re: VDP_loadTileSet, problems in console.

Posted: Sun Feb 17, 2019 6:25 pm
by cloudstrifer
Hi, using disableInts and enableInts problem not happens, but music freezes for a 1 or 2 / 10 of second.

I dont know how to use XGM_pause or XGM_resume, because when music freezes it holds the current note, and some notes is anoying when it happens.

If someone could help me with some ideas to prevent music to freeze.

Thank you!

Re: VDP_loadTileSet, problems in console.

Posted: Sun Feb 17, 2019 9:03 pm
by Stef
That mean you're disabling interruptions for too long. Check that you're not using VDP_setMapEx(..) with packed map data (unpack it first) or it will be very slow.