game_status_dirty: only render the status bar when it's "dirty", when a value changes. It helps the FPS

This commit is contained in:
dwsJason 2018-12-07 20:11:00 -05:00
parent a09b3557c1
commit 5b6073e27a
7 changed files with 36 additions and 11 deletions

View File

@ -42,6 +42,7 @@ typedef struct {
U8 name[10];
} hscore_t;
extern U16 game_status_dirty; /* status dirty flag */
extern U8 game_lives; /* lives counter */
extern U8 game_bombs; /* bombs counter */
extern U8 game_bullets; /* bullets counter */

View File

@ -37,6 +37,7 @@ e_bonus_action(ent_t *pEnt)
if (pEnt->seq == 0) {
if (e_rick_boxtest(pEnt)) {
game_score += 500;
game_status_dirty = 1;
#ifdef ENABLE_SOUND
syssnd_play(WAV_BONUS, 1);
#endif

View File

@ -77,6 +77,8 @@ e_box_action(ent_t* pEnt)
game_bombs = GAME_BOMBS_INIT;
else /* 0x11 */
game_bullets = GAME_BULLETS_INIT;
game_status_dirty = 1;
pEnt->n = 0;
map_marks[pEnt->mark].ent |= MAP_MARK_NACT;
}

View File

@ -309,7 +309,10 @@ e_rick_action2(void)
#ifdef ENABLE_CHEATS
if (!game_cheat1)
#endif
game_bullets--;
{
game_bullets--;
game_status_dirty = 1;
}
/* initialize bullet */
e_bullet_init(E_RICK_ENT.x, E_RICK_ENT.y);
return;
@ -328,7 +331,10 @@ e_rick_action2(void)
#ifdef ENABLE_CHEATS
if (!game_cheat1)
#endif
game_bombs--;
{
game_bombs--;
game_status_dirty = 1;
}
/* initialize bomb */
e_bomb_init(E_RICK_ENT.x, E_RICK_ENT.y);
return;

View File

@ -73,6 +73,7 @@ e_sbonus_stop(ent_t* pEnt)
e_sbonus_counting = FALSE; /* stop counting */
pEnt->n = 0; /* deactivate entity */
game_score += e_sbonus_bonus; /* add bonus to score */
game_status_dirty = 1;
#ifdef ENABLE_SOUND
syssnd_play(WAV_SBONUS2, 1);
#endif

View File

@ -81,6 +81,7 @@ e_them_gozombie(ent_t* pEnt)
syssnd_play(WAV_DIE, 1);
#endif
game_score += 50;
game_status_dirty = 1;
if (pEnt->flags & ENT_FLG_ONCE) {
/* make sure entity won't be activated again */
map_marks[pEnt->mark].ent |= MAP_MARK_NACT;

View File

@ -78,6 +78,8 @@ U8 game_cheat1 = 0;
U8 game_cheat2 = 0;
U8 game_cheat3 = 0;
U16 game_status_dirty = 0;
#if defined(GFXST) || defined(GFXGS)
hscore_t game_hscores[8] = {
{ 8000, "SIMES@@@@@" },
@ -183,6 +185,7 @@ game_toggleCheat(U8 nbr)
game_lives = 6;
game_bombs = 6;
game_bullets = 6;
game_status_dirty = 1;
break;
case 2:
game_cheat2 = ~game_cheat2;
@ -497,6 +500,7 @@ frame(void)
} else {
game_state = GAMEOVER;
}
game_status_dirty = 1;
}
else if (game_chsm) /* request to chain to next submap */
game_state = CHAIN_SUBMAP;
@ -516,6 +520,7 @@ frame(void)
if (map_chain())
game_state = CHAIN_END;
else {
game_status_dirty = 1;
game_bullets = 0x06;
game_bombs = 0x06;
game_map++;
@ -578,8 +583,6 @@ frame(void)
}
break;
case SCROLL_DOWN:
switch (scroll_down()) {
case SCROLL_RUNNING:
@ -651,6 +654,7 @@ init(void)
game_bombs = 6;
game_bullets = 6;
game_score = 0;
game_status_dirty = 1;
game_map = sysarg_args_map;
@ -719,13 +723,20 @@ play3(void)
{
static rect_t *r;
draw_clearStatus(); /* clear the status bar */
ent_draw(); /* draw all entities onto the buffer */
/* sound */
draw_drawStatus(); /* draw the status bar onto the buffer*/
r = &draw_STATUSRECT; r->next = ent_rects; /* refresh status bar too */
game_rects = r; /* take care to cleanup draw_STATUSRECT->next later! */
if (game_status_dirty)
{
draw_clearStatus(); /* clear the status bar */
ent_draw(); /* draw all entities onto the buffer */
draw_drawStatus(); /* draw the status bar onto the buffer*/
r = &draw_STATUSRECT; r->next = ent_rects; /* refresh status bar too */
game_rects = r; /* take care to cleanup draw_STATUSRECT->next later! */
game_status_dirty = 0;
}
else
{
ent_draw(); /* draw all entities onto the buffer */
game_rects = ent_rects;
}
if (!E_RICK_STTST(E_RICK_STZOMBIE)) { /* need to scroll ? */
if (ent_ents[1].y >= 0xCC) {
@ -754,6 +765,8 @@ restart(void)
game_bullets = 6;
game_bombs = 6;
game_status_dirty = 1;
ent_ents[1].n = 1;
irestore();