Page 1 of 1

Clearing plans and texts.

Posted: Mon Oct 12, 2015 6:57 pm
by orlanrod
I'm using VDP_clearPlan and VDP_cleartext, but their seems to be left over text from the title screen.

It clears the Background title, and the title logo. Also clears "Play" text but not "Options"

here is the code.

VDP_clearText(18, 19, 40);
VDP_clearText(16, 20, 40);
VDP_clearPlan(APLAN, TRUE);
VDP_clearPlan(BPLAN, TRUE);

Re: Clearing plans and texts.

Posted: Tue Oct 13, 2015 1:11 pm
by nolddor
How do you print the "options" string?

Re: Clearing plans and texts.

Posted: Tue Oct 13, 2015 5:44 pm
by orlanrod
nolddor wrote:How do you print the "options" string?
Using the function i wrote. The options text is the second vdp_drawtext line in drawGameTxt()

char* getGameTxt(int txtnum, int txtnumtwo)
{
mytxt[0][0] = "PLAY";
mytxt[1][0] = "OPTIONS";
return (mytxt[txtnum][txtnumtwo]);
}

void drawGameTxt()
{
if (loc == 1) VDP_drawText(getGameTxt(0,0), 18, 19); VDP_drawText(getGameTxt(1,0), 16, 20);
}

drawGameTxt is in main like this

while(TRUE)
{
entityInput();
entityAnim();
updateCamera();
drawGameTxt();

VDP_waitVSync();
}

And this is what triggers the events. assetLoader is another one of my functions.

static void joyEvent(u16 joy, u16 changed, u16 state)
{

if (changed & state & BUTTON_START)
{
if (loc == 1) loc++; assetLoader(loc);
}
}


void assetLoader(int pack)
{
if (pack == 1)
{
titlebgmap = unpackMap(titlebg_tiles.map, NULL);
ind = TILE_USERINDEX;
VDP_loadTileSet(titlebg_tiles.tileset, ind, TRUE);
VDP_setMapEx(BPLAN, titlebgmap, TILE_ATTR_FULL(PAL2, FALSE, FALSE, FALSE, ind), PlanXPosInTile, PlanYPosInTile, MapXPosInTile, MapYPosInTile, MapWidthInTile, MapHeightInTile);
ind += titlebg_tiles.tileset->numTile;

titlelogomap = unpackMap(titlelogo_tiles.map, NULL);
VDP_loadTileSet(titlelogo_tiles.tileset, ind, TRUE);
VDP_setMapEx(APLAN, titlelogomap, TILE_ATTR_FULL(PAL3, FALSE, FALSE, FALSE, ind), 10, 1, 0, 0, 20, 17);
ind += titlelogo_tiles.tileset->numTile;
}

if (pack == 2)
{
ind = 0;
SYS_disableInts();
VDP_clearText(18, 19, 40);
VDP_clearText(16, 20, 40);
VDP_clearPlan(APLAN, TRUE);
VDP_clearPlan(BPLAN, TRUE);
SYS_enableInts();
// init jaris sprite
player1.hmirror = 0;
player1.vmirror = 0;
player1.zorder = 0;
player1.x = 150;
player1.y = 150;
player1.current_frame = 0;
player1.current_anim = ANIM_STANDSIDES;
player1.animspeeds[0] = 50;
player1.animspeeds[1] = 20;
player1.animspeeds[2] = 2;
//Citizen vars
cxypos[0][0] = 160;
cxypos[1][0] = 150;
czorder = 1;
VDP_setPalette(PAL0, sjaris_sprite.palette->data);
VDP_setPalette(PAL1, fcitizen_sprite.palette->data);
VDP_setPalette(PAL2, city_tiles.palette->data);
SPR_initSprite(&sprites[player1.zorder], &sjaris_sprite, player1.x, player1.y, TILE_ATTR(PAL0, TRUE, FALSE, FALSE));
SPR_initSprite(&sprites[czorder], &fcitizen_sprite, cxypos[0][0], cxypos[1][0], TILE_ATTR(PAL1, TRUE, FALSE, FALSE));
SPR_update(sprites, 0);
SPR_update(sprites, 1);
citymap = unpackMap(city_tiles.map, NULL);
ind = TILE_USERINDEX;
VDP_loadTileSet(city_tiles.tileset, ind, TRUE);
VDP_setMapEx(BPLAN, citymap, TILE_ATTR_FULL(PAL2, FALSE, FALSE, FALSE, ind), PlanXPosInTile, PlanYPosInTile, MapXPosInTile, MapYPosInTile, MapWidthInTile, MapHeightInTile);
ind += city_tiles.tileset->numTile;
}

}

Re: Clearing plans and texts.

Posted: Tue Oct 13, 2015 5:55 pm
by orlanrod
I have discoverd the issue, and fixed it by dumb luck.

This

if (loc == 1) VDP_drawText(getGameTxt(0,0), 18, 19); VDP_drawText(getGameTxt(1,0), 16, 20);

Was changed to this.

if (loc == 1)
{
VDP_drawText(getGameTxt(0,0), 18, 19);
VDP_drawText(getGameTxt(1,0), 16, 20);
}

Why did it not work the first way?

Re: Clearing plans and texts.

Posted: Tue Oct 13, 2015 8:03 pm
by mikejmoffitt
I'm not sure, but your first syntax was absolute insanity so it's good to see the clean option worked better :P

Re: Clearing plans and texts.

Posted: Tue Oct 13, 2015 9:03 pm
by orlanrod
mikejmoffitt wrote:I'm not sure, but your first syntax was absolute insanity so it's good to see the clean option worked better :P
Yeah, it is strange. Thinking how that would even conflict with the clearing of text.
Usually i see people negate the curly braces if it can run on a single line, so i thought i should do it to.

There is a blog video coming on Saturday. Showing off the progress and a walk through my crap code. 8P

Re: Clearing plans and texts.

Posted: Wed Oct 14, 2015 8:33 am
by Stef
You need braces as soon you have more than 1 "instruction" (or operation) so here :

Code: Select all

if (loc == 1) VDP_drawText(getGameTxt(0,0), 18, 19); VDP_drawText(getGameTxt(1,0), 16, 20);
Only the first VDP_drawText(..) call is affected by the condition, second call is always executed whatever is loc.
As a general good practice is to always use the brace so you know what is affected by condition ;)

Re: Clearing plans and texts.

Posted: Wed Oct 14, 2015 5:54 pm
by orlanrod
Stef wrote:You need braces as soon you have more than 1 "instruction" (or operation) so here :

Code: Select all

if (loc == 1) VDP_drawText(getGameTxt(0,0), 18, 19); VDP_drawText(getGameTxt(1,0), 16, 20);
Only the first VDP_drawText(..) call is affected by the condition, second call is always executed whatever is loc.
As a general good practice is to always use the brace so you know what is affected by condition ;)
Ah okay. Yeah i see that now. Thanks! <8B