SGDK VDP_setTileMapXY / sample/sprite

Ask anything your want about Megadrive/Genesis programming.

Moderator: BigEvilCorporation

Post Reply
darkjoy2k2
Interested
Posts: 15
Joined: Tue Nov 13, 2018 8:42 pm
Location: Germany
Contact:

SGDK VDP_setTileMapXY / sample/sprite

Post by darkjoy2k2 » Mon Nov 19, 2018 7:14 am

Hello there!

I try to setup a tilemap engine.


a kind of "splash screen" in "plan a"

Code: Select all

    VDP_drawImageEx(PLAN_A, &bga_image, TILE_ATTR_FULL(PAL1, TRUE, FALSE, FALSE, ind), 0, 0, FALSE, TRUE);
    ind += logo2_image.tileset->numTile;
filling tiles in "plan_b"

Code: Select all

	
for(z=0;z<38;z+=2)
    {
	for(i=0;i<22;i+=2) // when i reaches 42 tiles it stops drawing. it skips 2 tiles (block width)
	{
		 drawBlock(z+1,i+1,4); //Function drawBlock draws block at position horizontal i and vertical 20
	w+=2;
	if (w==41){
        w=81;}
	if (w==121){
        w=161;}
 ind+=4;
	}
	}

Code: Select all

void drawBlock(unsigned int px,unsigned int py, unsigned int tnum) //Function to draw block at px,py
{ //16x16 pixel block = four 8x8 tiles = 2 tile wide and 2 tile high
	VDP_setTileMapXY(PLAN_B, TILE_ATTR_FULL(PAL0, 0, 0, 0, tnum), px, py); //Tile 2 is upper left corner (8x8 tile)
	VDP_setTileMapXY(PLAN_B, TILE_ATTR_FULL(PAL0, 0, 0, 0, tnum)+1, px+1, py); //Tile 3 is upper right corner (8x8 tile)
	VDP_setTileMapXY(PLAN_B, TILE_ATTR_FULL(PAL0, 0, 0, 0, tnum)+40, px, py+1); //Tile 4 is lower left corner
	VDP_setTileMapXY(PLAN_B, TILE_ATTR_FULL(PAL0, 0, 0, 0, tnum)+41, px+1, py+1); //Tile 5 is lower right corner
}
The code works well as long as i dont exceed the 38 tiles per line / 22 lines.

If i try to put more tiles on screen the graphics i put in "PLAN_A" go messy.
(some tiles from "PLAN_A" start looking weird an do some twisting
kind of animation)

Except for

Code: Select all

    VDP_fillTileMapRect(PLAN_B, 1, 0, 0, 50, 38);
which fills the screen but isn´t very creative...



1.
is there a smarter way to fill the screen with "different" tiles?


2.
another thing i saw was that i always have to fill some "IND" value when i draw with VDP_setTileMapXY or VDP_drawImageEx, else everything looks crap too, except for the VDP_fillTileMapRect, which does´nt seem to need that value. ind = TILE_USERINDEX;
can someone explain that a little more?
“No one in the world gets what they want and that is beautiful.” “You'd be amazed how much research you can get done when you have no life whatsoever.” “I created the OASIS because I never felt at home in the real world."
Ernest Cline

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

Re: SGDK VDP_setTileMapXY / sample/sprite

Post by Stef » Mon Nov 19, 2018 10:32 am

I'm not really sure of what you're trying to do but did you had a look on VDP_setMap(..) and VDP_setMapEx(..) methods ? i think that is what you need here.

darkjoy2k2
Interested
Posts: 15
Joined: Tue Nov 13, 2018 8:42 pm
Location: Germany
Contact:

Re: SGDK VDP_setTileMapXY / sample/sprite

Post by darkjoy2k2 » Mon Nov 19, 2018 6:13 pm

The DRAWIMAGEEX already added the "ind"-value and so i set it twice for mistake, everythig is fine now...

the stuff you mentioned really sounds interesting! can i use this to add a textfile or something and feed it as a map?
“No one in the world gets what they want and that is beautiful.” “You'd be amazed how much research you can get done when you have no life whatsoever.” “I created the OASIS because I never felt at home in the real world."
Ernest Cline

Okoboji
Newbie
Posts: 3
Joined: Wed Jan 02, 2019 1:33 am
Location: Kansas

Re: SGDK VDP_setTileMapXY / sample/sprite

Post by Okoboji » Sat Jan 19, 2019 12:32 am

Is it possible to assign color pallets to individual tiles in the Map functions? For example I've noticed that you have VDP_setmap(..) with only a single defined base tile value. What I want to do is have 2 pallets on a background plan_b. where each tile can switch back and forth between PAL 0 and PAL 1. If this is impossible with the current implementation I totally understand. I've actually modified a bit of kcowolfs map example to load in individual pallets. But, it would be nice to use the built in Map functions for compression and such.
If computer Science has taught me anything, it's that the natural state of any machine or system is to be broken. It's really unnatural when things work.

Post Reply