scroller: optimize scroller, pass one, remove multiplies from array indexes, remove redundant draws, and reduce the size of the blit rect to the actual size of the playfield
This commit is contained in:
parent
59a8a34912
commit
09b04a798e
|
@ -29,6 +29,8 @@ static U8 period;
|
||||||
segment "screen";
|
segment "screen";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
rect_t scroll_SCREENRECT = { 32, 8, 256, SYSVID_HEIGHT-8, NULL };
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Scroll up
|
* Scroll up
|
||||||
*
|
*
|
||||||
|
@ -37,6 +39,9 @@ U8
|
||||||
scroll_up(void)
|
scroll_up(void)
|
||||||
{
|
{
|
||||||
U8 i, j;
|
U8 i, j;
|
||||||
|
ent_t *pEnt;
|
||||||
|
U8* pSrc;
|
||||||
|
U8* pDst;
|
||||||
static U8 n = 0;
|
static U8 n = 0;
|
||||||
|
|
||||||
/* last call: restore */
|
/* last call: restore */
|
||||||
|
@ -53,21 +58,27 @@ scroll_up(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* translate map */
|
/* translate map */
|
||||||
|
pDst = &map_map[MAP_ROW_SCRTOP][0];
|
||||||
|
pSrc = pDst+32;
|
||||||
|
|
||||||
for (i = MAP_ROW_SCRTOP; i < MAP_ROW_HBBOT; i++)
|
for (i = MAP_ROW_SCRTOP; i < MAP_ROW_HBBOT; i++)
|
||||||
for (j = 0x00; j < 0x20; j++)
|
{
|
||||||
map_map[i][j] = map_map[i + 1][j];
|
memcpy(pDst, pSrc, (size_t)32);
|
||||||
|
pDst = pSrc;
|
||||||
|
pSrc += 32;
|
||||||
|
}
|
||||||
|
|
||||||
/* translate entities */
|
/* translate entities */
|
||||||
for (i = 0; ent_ents[i].n != 0xFF; i++) {
|
for (pEnt = ent_ents; pEnt->n != 0xFF; ++pEnt) {
|
||||||
if (ent_ents[i].n) {
|
if (pEnt->n) {
|
||||||
ent_ents[i].ysave -= 8;
|
pEnt->ysave -= 8;
|
||||||
ent_ents[i].trig_y -= 8;
|
pEnt->trig_y -= 8;
|
||||||
ent_ents[i].y -= 8;
|
pEnt->y -= 8;
|
||||||
if (ent_ents[i].y & 0x8000) { /* map coord. from 0x0000 to 0x0140 */
|
if (pEnt->y & 0x8000) { /* map coord. from 0x0000 to 0x0140 */
|
||||||
IFDEBUG_SCROLLER(
|
IFDEBUG_SCROLLER(
|
||||||
sys_printf("xrick/scroller: entity %#04X is gone\n", i);
|
sys_printf("xrick/scroller: entity %#04X is gone\n", i);
|
||||||
);
|
);
|
||||||
ent_ents[i].n = 0;
|
pEnt->n = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -75,7 +86,7 @@ scroll_up(void)
|
||||||
/* display */
|
/* display */
|
||||||
draw_map();
|
draw_map();
|
||||||
ent_draw();
|
ent_draw();
|
||||||
draw_drawStatus();
|
// draw_drawStatus();
|
||||||
map_frow++;
|
map_frow++;
|
||||||
|
|
||||||
/* loop */
|
/* loop */
|
||||||
|
@ -87,12 +98,12 @@ scroll_up(void)
|
||||||
map_expand();
|
map_expand();
|
||||||
|
|
||||||
/* display */
|
/* display */
|
||||||
draw_map();
|
//draw_map();
|
||||||
ent_draw();
|
ent_draw();
|
||||||
draw_drawStatus();
|
// draw_drawStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
game_rects = &draw_SCREENRECT;
|
game_rects = &scroll_SCREENRECT;
|
||||||
|
|
||||||
return SCROLL_RUNNING;
|
return SCROLL_RUNNING;
|
||||||
}
|
}
|
||||||
|
@ -105,6 +116,9 @@ U8
|
||||||
scroll_down(void)
|
scroll_down(void)
|
||||||
{
|
{
|
||||||
U8 i, j;
|
U8 i, j;
|
||||||
|
ent_t *pEnt;
|
||||||
|
U8* pSrc;
|
||||||
|
U8* pDst;
|
||||||
static U8 n = 0;
|
static U8 n = 0;
|
||||||
|
|
||||||
/* last call: restore */
|
/* last call: restore */
|
||||||
|
@ -121,21 +135,26 @@ scroll_down(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* translate map */
|
/* translate map */
|
||||||
|
pDst = &map_map[MAP_ROW_SCRBOT][0];
|
||||||
|
pSrc = pDst+32;
|
||||||
for (i = MAP_ROW_SCRBOT; i > MAP_ROW_HTTOP; i--)
|
for (i = MAP_ROW_SCRBOT; i > MAP_ROW_HTTOP; i--)
|
||||||
for (j = 0x00; j < 0x20; j++)
|
{
|
||||||
map_map[i][j] = map_map[i - 1][j];
|
memcpy(pDst, pSrc, (size_t)32);
|
||||||
|
pDst = pSrc;
|
||||||
|
pSrc -= 32;
|
||||||
|
}
|
||||||
|
|
||||||
/* translate entities */
|
/* translate entities */
|
||||||
for (i = 0; ent_ents[i].n != 0xFF; i++) {
|
for (pEnt = ent_ents; pEnt->n != 0xFF; ++pEnt) {
|
||||||
if (ent_ents[i].n) {
|
if (pEnt->n) {
|
||||||
ent_ents[i].ysave += 8;
|
pEnt->ysave += 8;
|
||||||
ent_ents[i].trig_y += 8;
|
pEnt->trig_y += 8;
|
||||||
ent_ents[i].y += 8;
|
pEnt->y += 8;
|
||||||
if (ent_ents[i].y > 0x0140) { /* map coord. from 0x0000 to 0x0140 */
|
if (pEnt->y > 0x0140) { /* map coord. from 0x0000 to 0x0140 */
|
||||||
IFDEBUG_SCROLLER(
|
IFDEBUG_SCROLLER(
|
||||||
sys_printf("xrick/scroller: entity %#04X is gone\n", i);
|
sys_printf("xrick/scroller: entity %#04X is gone\n", i);
|
||||||
);
|
);
|
||||||
ent_ents[i].n = 0;
|
pEnt->n = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -143,7 +162,7 @@ scroll_down(void)
|
||||||
/* display */
|
/* display */
|
||||||
draw_map();
|
draw_map();
|
||||||
ent_draw();
|
ent_draw();
|
||||||
draw_drawStatus();
|
// draw_drawStatus();
|
||||||
map_frow--;
|
map_frow--;
|
||||||
|
|
||||||
/* loop */
|
/* loop */
|
||||||
|
@ -155,12 +174,12 @@ scroll_down(void)
|
||||||
map_expand();
|
map_expand();
|
||||||
|
|
||||||
/* display */
|
/* display */
|
||||||
draw_map();
|
//draw_map();
|
||||||
ent_draw();
|
ent_draw();
|
||||||
draw_drawStatus();
|
// draw_drawStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
game_rects = &draw_SCREENRECT;
|
game_rects = &scroll_SCREENRECT;
|
||||||
|
|
||||||
return SCROLL_RUNNING;
|
return SCROLL_RUNNING;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue