diff options
-rw-r--r-- | apps/plugins/xobox.c | 62 |
1 files changed, 31 insertions, 31 deletions
diff --git a/apps/plugins/xobox.c b/apps/plugins/xobox.c index 76172ad7ca..4c56a8cf19 100644 --- a/apps/plugins/xobox.c +++ b/apps/plugins/xobox.c | |||
@@ -275,8 +275,8 @@ static void init_board (void) | |||
275 | int i, j; | 275 | int i, j; |
276 | for (j = 0; j < BOARD_H; j++) | 276 | for (j = 0; j < BOARD_H; j++) |
277 | for (i = 0; i < BOARD_W; i++) { /* make a nice cyan frame */ | 277 | for (i = 0; i < BOARD_W; i++) { /* make a nice cyan frame */ |
278 | if ((i == 0) || (j == 1) || (j == 0) || (i == BOARD_W - 1) | 278 | if ((i == 0) || (j <= 1) || (i == BOARD_W - 1) |
279 | || (j == BOARD_H - 1) || (j == BOARD_H - 2)) | 279 | || (j >= BOARD_H - 2)) |
280 | board[j][i] = FILLED; | 280 | board[j][i] = FILLED; |
281 | else | 281 | else |
282 | board[j][i] = EMPTIED; | 282 | board[j][i] = EMPTIED; |
@@ -325,11 +325,25 @@ static void refresh_board (void) | |||
325 | rb->lcd_set_background (LCD_BLACK); | 325 | rb->lcd_set_background (LCD_BLACK); |
326 | rb->lcd_clear_display (); | 326 | rb->lcd_clear_display (); |
327 | for (j = 0; j < BOARD_H; j++) | 327 | for (j = 0; j < BOARD_H; j++) |
328 | for (i = 0; i < BOARD_W; i++) { | 328 | { |
329 | rb->lcd_set_foreground (board[j][i]); | 329 | unsigned last_color = board[j][0]; |
330 | rb->lcd_fillrect (BOARD_X + CUBE_SIZE * i, BOARD_Y + CUBE_SIZE * j, | 330 | int last_i = 0; |
331 | CUBE_SIZE, CUBE_SIZE); | 331 | for (i = 1; i < BOARD_W; i++) { |
332 | if( last_color != board[j][i] ) | ||
333 | { | ||
334 | rb->lcd_set_foreground (last_color); | ||
335 | rb->lcd_fillrect (BOARD_X + CUBE_SIZE * (last_i), | ||
336 | BOARD_Y + CUBE_SIZE * j, | ||
337 | CUBE_SIZE * (i - last_i), CUBE_SIZE ); | ||
338 | last_color = board[j][i]; | ||
339 | last_i = i; | ||
340 | } | ||
332 | } | 341 | } |
342 | rb->lcd_set_foreground (last_color); | ||
343 | rb->lcd_fillrect (BOARD_X + CUBE_SIZE * (last_i), | ||
344 | BOARD_Y + CUBE_SIZE * j, | ||
345 | CUBE_SIZE * (i - last_i), CUBE_SIZE); | ||
346 | } | ||
333 | rb->lcd_set_foreground (LCD_BLACK); | 347 | rb->lcd_set_foreground (LCD_BLACK); |
334 | rb->lcd_set_background (CLR_LTBLUE); | 348 | rb->lcd_set_background (CLR_LTBLUE); |
335 | rb->snprintf (str, sizeof (str), "Level %d", player.level + 1); | 349 | rb->snprintf (str, sizeof (str), "Level %d", player.level + 1); |
@@ -379,23 +393,19 @@ static inline int infested_area (int i, int j) | |||
379 | p3.y = p.y + 1; | 393 | p3.y = p.y + 1; |
380 | p4.x = p.x; | 394 | p4.x = p.x; |
381 | p4.y = p.y - 1; | 395 | p4.y = p.y - 1; |
382 | if ((p1.x < BOARD_W) && (p1.x >= 0) && (p1.y < BOARD_H) && (p1.y >= 0) | 396 | if ((p1.x < BOARD_W) && (testboard[p1.y][p1.x] == UNCHECKED)) |
383 | && (testboard[p1.y][p1.x] == UNCHECKED)) | ||
384 | if (board[p1.y][p1.x] != FILLED) | 397 | if (board[p1.y][p1.x] != FILLED) |
385 | if (!push (&p1)) | 398 | if (!push (&p1)) |
386 | return -1; | 399 | return -1; |
387 | if ((p2.x < BOARD_W) && (p2.x >= 0) && (p2.y < BOARD_H) && (p2.y >= 0) | 400 | if ((p2.x >= 0) && (testboard[p2.y][p2.x] == UNCHECKED)) |
388 | && (testboard[p2.y][p2.x] == UNCHECKED)) | ||
389 | if (board[p2.y][p2.x] != FILLED) | 401 | if (board[p2.y][p2.x] != FILLED) |
390 | if (!push (&p2)) | 402 | if (!push (&p2)) |
391 | return -1; | 403 | return -1; |
392 | if ((p3.x < BOARD_W) && (p3.x >= 0) && (p3.y < BOARD_H) && (p3.y >= 0) | 404 | if ((p3.y < BOARD_H) && (testboard[p3.y][p3.x] == UNCHECKED)) |
393 | && (testboard[p3.y][p3.x] == UNCHECKED)) | ||
394 | if (board[p3.y][p3.x] != FILLED) | 405 | if (board[p3.y][p3.x] != FILLED) |
395 | if (!push (&p3)) | 406 | if (!push (&p3)) |
396 | return -1; | 407 | return -1; |
397 | if ((p4.x < BOARD_W) && (p4.x >= 0) && (p4.y < BOARD_H) && (p4.y >= 0) | 408 | if ((p4.y >= 0) && (testboard[p4.y][p4.x] == UNCHECKED)) |
398 | && (testboard[p4.y][p4.x] == UNCHECKED)) | ||
399 | if (board[p4.y][p4.x] != FILLED) | 409 | if (board[p4.y][p4.x] != FILLED) |
400 | if (!push (&p4)) | 410 | if (!push (&p4)) |
401 | return -1; | 411 | return -1; |
@@ -423,23 +433,19 @@ static inline int fill_area (int i, int j) | |||
423 | p3.y = p.y + 1; | 433 | p3.y = p.y + 1; |
424 | p4.x = p.x; | 434 | p4.x = p.x; |
425 | p4.y = p.y - 1; | 435 | p4.y = p.y - 1; |
426 | if ((p1.x < BOARD_W) && (p1.x >= 0) && (p1.y < BOARD_H) && (p1.y >= 0) | 436 | if ((p1.x < BOARD_W) && (testboard[p1.y][p1.x] == UNCHECKED)) |
427 | && (testboard[p1.y][p1.x] == UNCHECKED)) | ||
428 | if (board[p1.y][p1.x] == EMPTIED) | 437 | if (board[p1.y][p1.x] == EMPTIED) |
429 | if (!push (&p1)) | 438 | if (!push (&p1)) |
430 | return -1; | 439 | return -1; |
431 | if ((p2.x < BOARD_W) && (p2.x >= 0) && (p2.y < BOARD_H) && (p2.y >= 0) | 440 | if ((p2.x >= 0) && (testboard[p2.y][p2.x] == UNCHECKED)) |
432 | && (testboard[p2.y][p2.x] == UNCHECKED)) | ||
433 | if (board[p2.y][p2.x] == EMPTIED) | 441 | if (board[p2.y][p2.x] == EMPTIED) |
434 | if (!push (&p2)) | 442 | if (!push (&p2)) |
435 | return -1; | 443 | return -1; |
436 | if ((p3.x < BOARD_W) && (p3.x >= 0) && (p3.y < BOARD_H) && (p3.y >= 0) | 444 | if ((p3.y < BOARD_H) && (testboard[p3.y][p3.x] == UNCHECKED)) |
437 | && (testboard[p3.y][p3.x] == UNCHECKED)) | ||
438 | if (board[p3.y][p3.x] == EMPTIED) | 445 | if (board[p3.y][p3.x] == EMPTIED) |
439 | if (!push (&p3)) | 446 | if (!push (&p3)) |
440 | return -1; | 447 | return -1; |
441 | if ((p4.x < BOARD_W) && (p4.x >= 0) && (p4.y < BOARD_H) && (p4.y >= 0) | 448 | if ((p4.y >= 0) && (testboard[p4.y][p4.x] == UNCHECKED)) |
442 | && (testboard[p4.y][p4.x] == UNCHECKED)) | ||
443 | if (board[p4.y][p4.x] == EMPTIED) | 449 | if (board[p4.y][p4.x] == EMPTIED) |
444 | if (!push (&p4)) | 450 | if (!push (&p4)) |
445 | return -1; | 451 | return -1; |
@@ -465,21 +471,15 @@ static void complete_trail (int fill) | |||
465 | 471 | ||
466 | if (fill) { | 472 | if (fill) { |
467 | for (i = 0; i < player.level + STARTING_QIXES; i++) /* add qixes to board */ | 473 | for (i = 0; i < player.level + STARTING_QIXES; i++) /* add qixes to board */ |
468 | boardcopy[div (qixes[i].y - BOARD_Y, CUBE_SIZE)][div | 474 | boardcopy[div(qixes[i].y - BOARD_Y, CUBE_SIZE)] |
469 | (qixes[i].x - BOARD_X, | 475 | [div(qixes[i].x - BOARD_X, CUBE_SIZE)] = QIX; |
470 | CUBE_SIZE)] = QIX; | ||
471 | 476 | ||
472 | for (j = 1; j < BOARD_H - 1; j++) | 477 | for (j = 1; j < BOARD_H - 1; j++) |
473 | for (i = 0; i < BOARD_W - 0; i++) | 478 | for (i = 0; i < BOARD_W - 0; i++) |
474 | if (board[j][i] != FILLED) { | 479 | if (board[j][i] != FILLED) { |
475 | ret = infested_area (i, j); | 480 | ret = infested_area (i, j); |
476 | if (ret < 0) | 481 | if (ret < 0 || ( ret == 0 && fill_area (i, j) < 0 ) ) |
477 | quit = true; | 482 | quit = true; |
478 | else if (ret == 0) { | ||
479 | ret = fill_area (i, j); | ||
480 | if (ret < 0) | ||
481 | quit = true; | ||
482 | } | ||
483 | } | 483 | } |
484 | } | 484 | } |
485 | 485 | ||