summaryrefslogtreecommitdiff
path: root/apps/plugins/minesweeper.c
diff options
context:
space:
mode:
authorAntoine Cellerier <dionoea@videolan.org>2006-07-27 20:53:57 +0000
committerAntoine Cellerier <dionoea@videolan.org>2006-07-27 20:53:57 +0000
commit3e60bc44272883a54f7301d59bfa2a640253b063 (patch)
tree74f168e989acdb05219b9ac4deac826af3f929bc /apps/plugins/minesweeper.c
parent9d8fce9a7d7c66d0a0907790004ae679b9359693 (diff)
downloadrockbox-3e60bc44272883a54f7301d59bfa2a640253b063.tar.gz
rockbox-3e60bc44272883a54f7301d59bfa2a640253b063.zip
* fix "number of mines" display on some target (previously didn't work on iPod 5G). This closes http://www.rockbox.org/tracker/task/5701
* remove trailing spaces git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10341 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/minesweeper.c')
-rw-r--r--apps/plugins/minesweeper.c44
1 files changed, 22 insertions, 22 deletions
diff --git a/apps/plugins/minesweeper.c b/apps/plugins/minesweeper.c
index a549718274..5a47b03292 100644
--- a/apps/plugins/minesweeper.c
+++ b/apps/plugins/minesweeper.c
@@ -7,7 +7,7 @@
7 * \/ \/ \/ \/ \/ 7 * \/ \/ \/ \/ \/
8 * $Id$ 8 * $Id$
9 * 9 *
10 * Copyright (C) 2004 dionoea (Antoine Cellerier) 10 * Copyright (C) 2004-2006 Antoine Cellerier <dionoea -at- videolan -dot- org>
11 * 11 *
12 * All files in this archive are subject to the GNU General Public License. 12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement. 13 * See the file COPYING in the source tree root for full license agreement.
@@ -279,11 +279,11 @@ void push (int *stack, int y, int x){
279 279
280/* Unveil tiles and push them to stack if they are empty. */ 280/* Unveil tiles and push them to stack if they are empty. */
281void unveil(int *stack, int y, int x){ 281void unveil(int *stack, int y, int x){
282 282
283 if(x < c_width() || y < c_height() || x > c_width() + width-1 283 if(x < c_width() || y < c_height() || x > c_width() + width-1
284 || y > c_height() + height-1 || minefield[y][x].known 284 || y > c_height() + height-1 || minefield[y][x].known
285 || minefield[y][x].mine || minefield[y][x].flag) return; 285 || minefield[y][x].mine || minefield[y][x].flag) return;
286 286
287 if(minefield[y][x].neighbors == 0){ 287 if(minefield[y][x].neighbors == 0){
288 minefield[y][x].known = 1; 288 minefield[y][x].known = 1;
289 push(stack, y, x); 289 push(stack, y, x);
@@ -292,20 +292,20 @@ void unveil(int *stack, int y, int x){
292} 292}
293 293
294void discover(int y, int x){ 294void discover(int y, int x){
295 295
296 int stack[height*width]; 296 int stack[height*width];
297 297
298 /* Selected tile. */ 298 /* Selected tile. */
299 if(x < c_width() || y < c_height() || x > c_width() + width-1 299 if(x < c_width() || y < c_height() || x > c_width() + width-1
300 || y > c_height() + height-1 || minefield[y][x].known 300 || y > c_height() + height-1 || minefield[y][x].known
301 || minefield[y][x].mine || minefield[y][x].flag) return; 301 || minefield[y][x].mine || minefield[y][x].flag) return;
302 302
303 minefield[y][x].known = 1; 303 minefield[y][x].known = 1;
304 /* Exit if the tile is not empty. (no mines nearby) */ 304 /* Exit if the tile is not empty. (no mines nearby) */
305 if(minefield[y][x].neighbors) return; 305 if(minefield[y][x].neighbors) return;
306 306
307 push(stack, y, x); 307 push(stack, y, x);
308 308
309 /* Scan all nearby tiles. If we meet a tile with a number we just unveil 309 /* Scan all nearby tiles. If we meet a tile with a number we just unveil
310 it. If we meet an empty tile, we push the location in stack. For each 310 it. If we meet an empty tile, we push the location in stack. For each
311 location in stack we do the same thing. (scan again all nearby tiles) */ 311 location in stack we do the same thing. (scan again all nearby tiles) */
@@ -313,11 +313,11 @@ void discover(int y, int x){
313 /* Retrieve x, y from stack. */ 313 /* Retrieve x, y from stack. */
314 x = stack[stack_pos]; 314 x = stack[stack_pos];
315 y = stack[stack_pos-1]; 315 y = stack[stack_pos-1];
316 316
317 /* Pop. */ 317 /* Pop. */
318 if(stack_pos > 0) stack_pos -= 2; 318 if(stack_pos > 0) stack_pos -= 2;
319 else rb->splash(HZ,true,"ERROR"); 319 else rb->splash(HZ,true,"ERROR");
320 320
321 unveil(stack, y-1, x-1); 321 unveil(stack, y-1, x-1);
322 unveil(stack, y-1, x); 322 unveil(stack, y-1, x);
323 unveil(stack, y-1, x+1); 323 unveil(stack, y-1, x+1);
@@ -326,7 +326,7 @@ void discover(int y, int x){
326 unveil(stack, y+1, x); 326 unveil(stack, y+1, x);
327 unveil(stack, y+1, x-1); 327 unveil(stack, y+1, x-1);
328 unveil(stack, y, x-1); 328 unveil(stack, y, x-1);
329 } 329 }
330} 330}
331 331
332/* Reset the whole board for a new game. */ 332/* Reset the whole board for a new game. */
@@ -364,7 +364,7 @@ void minesweeper_putmines(int p, int x, int y){
364 minefield[i][j].neighbors = 0; 364 minefield[i][j].neighbors = 0;
365 } 365 }
366 } 366 }
367 367
368 /* we need to compute the neighbor element for each tile */ 368 /* we need to compute the neighbor element for each tile */
369 for(i=c_height();i<c_height() + height;i++){ 369 for(i=c_height();i<c_height() + height;i++){
370 for(j=c_width();j<c_width() + width;j++){ 370 for(j=c_width();j<c_width() + width;j++){
@@ -388,7 +388,7 @@ void minesweeper_putmines(int p, int x, int y){
388 } 388 }
389 } 389 }
390 } 390 }
391 391
392 no_mines = false; 392 no_mines = false;
393 /* In case the user is lucky and there are no mines positioned. */ 393 /* In case the user is lucky and there are no mines positioned. */
394 if(!mine_num && height*width != 1) minesweeper_putmines(p, x, y); 394 if(!mine_num && height*width != 1) minesweeper_putmines(p, x, y);
@@ -398,7 +398,7 @@ void minesweeper_putmines(int p, int x, int y){
398 can easily be expanded, (just a call assigned to a button) as a solver. */ 398 can easily be expanded, (just a call assigned to a button) as a solver. */
399void mine_show(void){ 399void mine_show(void){
400 int i, j, button; 400 int i, j, button;
401 401
402 for(i=c_height();i<c_height() + height;i++){ 402 for(i=c_height();i<c_height() + height;i++){
403 for(j=c_width();j<c_width() + width;j++){ 403 for(j=c_width();j<c_width() + width;j++){
404#if LCD_DEPTH > 1 404#if LCD_DEPTH > 1
@@ -410,11 +410,11 @@ void mine_show(void){
410#endif 410#endif
411 if(!minefield[i][j].known){ 411 if(!minefield[i][j].known){
412 if(minefield[i][j].mine){ 412 if(minefield[i][j].mine){
413 rb->lcd_set_drawmode(DRMODE_FG); 413 rb->lcd_set_drawmode(DRMODE_COMPLEMENT);
414 rb->lcd_mono_bitmap(num[9], j*8,i*8,8,8); 414 rb->lcd_mono_bitmap(num[9], j*8,i*8,8,8);
415 rb->lcd_set_drawmode(DRMODE_SOLID); 415 rb->lcd_set_drawmode(DRMODE_SOLID);
416 } else if(minefield[i][j].neighbors){ 416 } else if(minefield[i][j].neighbors){
417 rb->lcd_set_drawmode(DRMODE_FG); 417 rb->lcd_set_drawmode(DRMODE_COMPLEMENT);
418 rb->lcd_mono_bitmap(num[minefield[i][j].neighbors], 418 rb->lcd_mono_bitmap(num[minefield[i][j].neighbors],
419 j*8,i*8,8,8); 419 j*8,i*8,8,8);
420 rb->lcd_set_drawmode(DRMODE_SOLID); 420 rb->lcd_set_drawmode(DRMODE_SOLID);
@@ -423,7 +423,7 @@ void mine_show(void){
423 } 423 }
424 } 424 }
425 rb->lcd_update(); 425 rb->lcd_update();
426 426
427 do 427 do
428 button = rb->button_get(true); 428 button = rb->button_get(true);
429 while ((button == BUTTON_NONE) || (button & (BUTTON_REL|BUTTON_REPEAT))); 429 while ((button == BUTTON_NONE) || (button & (BUTTON_REL|BUTTON_REPEAT)));
@@ -492,7 +492,7 @@ int minesweeper(void)
492 case (BUTTON_LEFT | BUTTON_REPEAT): 492 case (BUTTON_LEFT | BUTTON_REPEAT):
493 width = width%(LCD_WIDTH/8)+1; 493 width = width%(LCD_WIDTH/8)+1;
494 break; 494 break;
495 495
496 case MINESWP_RIGHT: 496 case MINESWP_RIGHT:
497 case (MINESWP_RIGHT | BUTTON_REPEAT): 497 case (MINESWP_RIGHT | BUTTON_REPEAT):
498 height--; 498 height--;
@@ -555,7 +555,7 @@ int minesweeper(void)
555#endif 555#endif
556 if(minefield[i][j].known){ 556 if(minefield[i][j].known){
557 if(minefield[i][j].neighbors){ 557 if(minefield[i][j].neighbors){
558 rb->lcd_set_drawmode(DRMODE_FG); 558 rb->lcd_set_drawmode(DRMODE_COMPLEMENT);
559 rb->lcd_mono_bitmap(num[minefield[i][j].neighbors], 559 rb->lcd_mono_bitmap(num[minefield[i][j].neighbors],
560 j*8,i*8,8,8); 560 j*8,i*8,8,8);
561 rb->lcd_set_drawmode(DRMODE_SOLID); 561 rb->lcd_set_drawmode(DRMODE_SOLID);
@@ -591,7 +591,7 @@ int minesweeper(void)
591#endif 591#endif
592 case MINESWP_QUIT: 592 case MINESWP_QUIT:
593 return MINESWEEPER_QUIT; 593 return MINESWEEPER_QUIT;
594 594
595 /* move cursor left */ 595 /* move cursor left */
596 case BUTTON_LEFT: 596 case BUTTON_LEFT:
597 case (BUTTON_LEFT | BUTTON_REPEAT): 597 case (BUTTON_LEFT | BUTTON_REPEAT):
@@ -630,9 +630,9 @@ int minesweeper(void)
630 /* lose on the first "click" */ 630 /* lose on the first "click" */
631 if(tiles_left == width*height && no_mines) 631 if(tiles_left == width*height && no_mines)
632 minesweeper_putmines(p,x,y); 632 minesweeper_putmines(p,x,y);
633 633
634 discover(y, x); 634 discover(y, x);
635 635
636 if(minefield[y][x].mine){ 636 if(minefield[y][x].mine){
637 return MINESWEEPER_LOSE; 637 return MINESWEEPER_LOSE;
638 } 638 }