1
0
Fork 0
forked from len0rd/rockbox

Misc changes to xobox (basically remove some unneed tests and optimise (i hope) the drawing function)

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10973 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Antoine Cellerier 2006-09-17 15:07:11 +00:00
parent a7d9859300
commit ff4867a799

View file

@ -275,8 +275,8 @@ static void init_board (void)
int i, j; int i, j;
for (j = 0; j < BOARD_H; j++) for (j = 0; j < BOARD_H; j++)
for (i = 0; i < BOARD_W; i++) { /* make a nice cyan frame */ for (i = 0; i < BOARD_W; i++) { /* make a nice cyan frame */
if ((i == 0) || (j == 1) || (j == 0) || (i == BOARD_W - 1) if ((i == 0) || (j <= 1) || (i == BOARD_W - 1)
|| (j == BOARD_H - 1) || (j == BOARD_H - 2)) || (j >= BOARD_H - 2))
board[j][i] = FILLED; board[j][i] = FILLED;
else else
board[j][i] = EMPTIED; board[j][i] = EMPTIED;
@ -325,11 +325,25 @@ static void refresh_board (void)
rb->lcd_set_background (LCD_BLACK); rb->lcd_set_background (LCD_BLACK);
rb->lcd_clear_display (); rb->lcd_clear_display ();
for (j = 0; j < BOARD_H; j++) for (j = 0; j < BOARD_H; j++)
for (i = 0; i < BOARD_W; i++) { {
rb->lcd_set_foreground (board[j][i]); unsigned last_color = board[j][0];
rb->lcd_fillrect (BOARD_X + CUBE_SIZE * i, BOARD_Y + CUBE_SIZE * j, int last_i = 0;
CUBE_SIZE, CUBE_SIZE); for (i = 1; i < BOARD_W; i++) {
if( last_color != board[j][i] )
{
rb->lcd_set_foreground (last_color);
rb->lcd_fillrect (BOARD_X + CUBE_SIZE * (last_i),
BOARD_Y + CUBE_SIZE * j,
CUBE_SIZE * (i - last_i), CUBE_SIZE );
last_color = board[j][i];
last_i = i;
}
} }
rb->lcd_set_foreground (last_color);
rb->lcd_fillrect (BOARD_X + CUBE_SIZE * (last_i),
BOARD_Y + CUBE_SIZE * j,
CUBE_SIZE * (i - last_i), CUBE_SIZE);
}
rb->lcd_set_foreground (LCD_BLACK); rb->lcd_set_foreground (LCD_BLACK);
rb->lcd_set_background (CLR_LTBLUE); rb->lcd_set_background (CLR_LTBLUE);
rb->snprintf (str, sizeof (str), "Level %d", player.level + 1); rb->snprintf (str, sizeof (str), "Level %d", player.level + 1);
@ -379,23 +393,19 @@ static inline int infested_area (int i, int j)
p3.y = p.y + 1; p3.y = p.y + 1;
p4.x = p.x; p4.x = p.x;
p4.y = p.y - 1; p4.y = p.y - 1;
if ((p1.x < BOARD_W) && (p1.x >= 0) && (p1.y < BOARD_H) && (p1.y >= 0) if ((p1.x < BOARD_W) && (testboard[p1.y][p1.x] == UNCHECKED))
&& (testboard[p1.y][p1.x] == UNCHECKED))
if (board[p1.y][p1.x] != FILLED) if (board[p1.y][p1.x] != FILLED)
if (!push (&p1)) if (!push (&p1))
return -1; return -1;
if ((p2.x < BOARD_W) && (p2.x >= 0) && (p2.y < BOARD_H) && (p2.y >= 0) if ((p2.x >= 0) && (testboard[p2.y][p2.x] == UNCHECKED))
&& (testboard[p2.y][p2.x] == UNCHECKED))
if (board[p2.y][p2.x] != FILLED) if (board[p2.y][p2.x] != FILLED)
if (!push (&p2)) if (!push (&p2))
return -1; return -1;
if ((p3.x < BOARD_W) && (p3.x >= 0) && (p3.y < BOARD_H) && (p3.y >= 0) if ((p3.y < BOARD_H) && (testboard[p3.y][p3.x] == UNCHECKED))
&& (testboard[p3.y][p3.x] == UNCHECKED))
if (board[p3.y][p3.x] != FILLED) if (board[p3.y][p3.x] != FILLED)
if (!push (&p3)) if (!push (&p3))
return -1; return -1;
if ((p4.x < BOARD_W) && (p4.x >= 0) && (p4.y < BOARD_H) && (p4.y >= 0) if ((p4.y >= 0) && (testboard[p4.y][p4.x] == UNCHECKED))
&& (testboard[p4.y][p4.x] == UNCHECKED))
if (board[p4.y][p4.x] != FILLED) if (board[p4.y][p4.x] != FILLED)
if (!push (&p4)) if (!push (&p4))
return -1; return -1;
@ -423,23 +433,19 @@ static inline int fill_area (int i, int j)
p3.y = p.y + 1; p3.y = p.y + 1;
p4.x = p.x; p4.x = p.x;
p4.y = p.y - 1; p4.y = p.y - 1;
if ((p1.x < BOARD_W) && (p1.x >= 0) && (p1.y < BOARD_H) && (p1.y >= 0) if ((p1.x < BOARD_W) && (testboard[p1.y][p1.x] == UNCHECKED))
&& (testboard[p1.y][p1.x] == UNCHECKED))
if (board[p1.y][p1.x] == EMPTIED) if (board[p1.y][p1.x] == EMPTIED)
if (!push (&p1)) if (!push (&p1))
return -1; return -1;
if ((p2.x < BOARD_W) && (p2.x >= 0) && (p2.y < BOARD_H) && (p2.y >= 0) if ((p2.x >= 0) && (testboard[p2.y][p2.x] == UNCHECKED))
&& (testboard[p2.y][p2.x] == UNCHECKED))
if (board[p2.y][p2.x] == EMPTIED) if (board[p2.y][p2.x] == EMPTIED)
if (!push (&p2)) if (!push (&p2))
return -1; return -1;
if ((p3.x < BOARD_W) && (p3.x >= 0) && (p3.y < BOARD_H) && (p3.y >= 0) if ((p3.y < BOARD_H) && (testboard[p3.y][p3.x] == UNCHECKED))
&& (testboard[p3.y][p3.x] == UNCHECKED))
if (board[p3.y][p3.x] == EMPTIED) if (board[p3.y][p3.x] == EMPTIED)
if (!push (&p3)) if (!push (&p3))
return -1; return -1;
if ((p4.x < BOARD_W) && (p4.x >= 0) && (p4.y < BOARD_H) && (p4.y >= 0) if ((p4.y >= 0) && (testboard[p4.y][p4.x] == UNCHECKED))
&& (testboard[p4.y][p4.x] == UNCHECKED))
if (board[p4.y][p4.x] == EMPTIED) if (board[p4.y][p4.x] == EMPTIED)
if (!push (&p4)) if (!push (&p4))
return -1; return -1;
@ -465,21 +471,15 @@ static void complete_trail (int fill)
if (fill) { if (fill) {
for (i = 0; i < player.level + STARTING_QIXES; i++) /* add qixes to board */ for (i = 0; i < player.level + STARTING_QIXES; i++) /* add qixes to board */
boardcopy[div (qixes[i].y - BOARD_Y, CUBE_SIZE)][div boardcopy[div(qixes[i].y - BOARD_Y, CUBE_SIZE)]
(qixes[i].x - BOARD_X, [div(qixes[i].x - BOARD_X, CUBE_SIZE)] = QIX;
CUBE_SIZE)] = QIX;
for (j = 1; j < BOARD_H - 1; j++) for (j = 1; j < BOARD_H - 1; j++)
for (i = 0; i < BOARD_W - 0; i++) for (i = 0; i < BOARD_W - 0; i++)
if (board[j][i] != FILLED) { if (board[j][i] != FILLED) {
ret = infested_area (i, j); ret = infested_area (i, j);
if (ret < 0) if (ret < 0 || ( ret == 0 && fill_area (i, j) < 0 ) )
quit = true; quit = true;
else if (ret == 0) {
ret = fill_area (i, j);
if (ret < 0)
quit = true;
}
} }
} }