From f50bbce43867ddc285823c0d2c65bc42b1d8d161 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 18 Aug 2004 12:06:10 +0000 Subject: fixed comments, added linefeeds to chop some of the longest lines git-svn-id: svn://svn.rockbox.org/rockbox/trunk@5000 a1c6a512-1295-4272-9138-f99709370657 --- apps/plugins/minesweeper.c | 264 ++++++++++--------- apps/plugins/solitaire.c | 635 ++++++++++++++++++++++++--------------------- 2 files changed, 475 insertions(+), 424 deletions(-) diff --git a/apps/plugins/minesweeper.c b/apps/plugins/minesweeper.c index b155c3fbad..127d96d3d5 100644 --- a/apps/plugins/minesweeper.c +++ b/apps/plugins/minesweeper.c @@ -45,8 +45,8 @@ use F3 to see how many mines are left (supposing all your flags are correct) static struct plugin_api* rb; -//define how numbers are displayed (that way we don't have to -//worry about fonts) +/* define how numbers are displayed (that way we don't have to */ +/* worry about fonts) */ static unsigned char num[9][8] = { /*reading the sprites: on screen f123 @@ -60,87 +60,87 @@ static unsigned char num[9][8] = { ea73 */ - //0 - {0x00, //........ - 0x00, //........ - 0x00, //........ - 0x00, //........ - 0x00, //........ - 0x00, //........ - 0x00, //........ - 0x00},//........ - //1 - {0x00, //........ - 0x00, //........ - 0x00, //...OO... - 0x44, //....O... - 0x7c, //....O... - 0x40, //....O... - 0x00, //...OOO.. - 0x00},//........ - //2 - {0x00, //........ - 0x00, //........ - 0x48, //...OO... - 0x64, //..O..O.. - 0x54, //....O... - 0x48, //...O.... - 0x00, //..OOOO.. - 0x00},//........ - //3 - {0x00, //........ - 0x00, //........ - 0x44, //..OOO... - 0x54, //.....O.. - 0x54, //...OO... - 0x28, //.....O.. - 0x00, //..OOO... - 0x00},//........ - //4 - {0x00, //........ - 0x00, //........ - 0x1c, //..O..... - 0x10, //..O..... - 0x70, //..OOOO.. - 0x10, //....O... - 0x00, //....O... - 0x00},//........ - //5 - {0x00, //........ - 0x00, //........ - 0x5c, //..OOOO.. - 0x54, //..O..... - 0x54, //..OOO... - 0x24, //.....O.. - 0x00, //..OOO... - 0x00},//........ - //6 - {0x00, //........ - 0x00, //........ - 0x38, //...OOO.. - 0x54, //..O..... - 0x54, //..OOO... - 0x24, //..O..O.. - 0x00, //...OO... - 0x00},//........ - //7 - {0x00, //........ - 0x00, //........ - 0x44, //..OOOO.. - 0x24, //.....O.. - 0x14, //....O... - 0x0c, //...O.... - 0x00, //..O..... - 0x00},//........ - //8 - {0x00, //........ - 0x00, //........ - 0x28, //...OO... - 0x54, //..O..O.. - 0x54, //...OO... - 0x28, //..O..O.. - 0x00, //...OO... - 0x00},//........ + /* 0 */ + {0x00, /* ........ */ + 0x00, /* ........ */ + 0x00, /* ........ */ + 0x00, /* ........ */ + 0x00, /* ........ */ + 0x00, /* ........ */ + 0x00, /* ........ */ + 0x00},/* ........ */ + /* 1 */ + {0x00, /* ........ */ + 0x00, /* ........ */ + 0x00, /* ...OO... */ + 0x44, /* ....O... */ + 0x7c, /* ....O... */ + 0x40, /* ....O... */ + 0x00, /* ...OOO.. */ + 0x00},/* ........ */ + /* 2 */ + {0x00, /* ........ */ + 0x00, /* ........ */ + 0x48, /* ...OO... */ + 0x64, /* ..O..O.. */ + 0x54, /* ....O... */ + 0x48, /* ...O.... */ + 0x00, /* ..OOOO.. */ + 0x00},/* ........ */ + /* 3 */ + {0x00, /* ........ */ + 0x00, /* ........ */ + 0x44, /* ..OOO... */ + 0x54, /* .....O.. */ + 0x54, /* ...OO... */ + 0x28, /* .....O.. */ + 0x00, /* ..OOO... */ + 0x00},/* ........ */ + /* 4 */ + {0x00, /* ........ */ + 0x00, /* ........ */ + 0x1c, /* ..O..... */ + 0x10, /* ..O..... */ + 0x70, /* ..OOOO.. */ + 0x10, /* ....O... */ + 0x00, /* ....O... */ + 0x00},/* ........ */ + /* 5 */ + {0x00, /* ........ */ + 0x00, /* ........ */ + 0x5c, /* ..OOOO.. */ + 0x54, /* ..O..... */ + 0x54, /* ..OOO... */ + 0x24, /* .....O.. */ + 0x00, /* ..OOO... */ + 0x00},/* ........ */ + /* 6 */ + {0x00, /* ........ */ + 0x00, /* ........ */ + 0x38, /* ...OOO.. */ + 0x54, /* ..O..... */ + 0x54, /* ..OOO... */ + 0x24, /* ..O..O.. */ + 0x00, /* ...OO... */ + 0x00},/* ........ */ + /* 7 */ + {0x00, /* ........ */ + 0x00, /* ........ */ + 0x44, /* ..OOOO.. */ + 0x24, /* .....O.. */ + 0x14, /* ....O... */ + 0x0c, /* ...O.... */ + 0x00, /* ..O..... */ + 0x00},/* ........ */ + /* 8 */ + {0x00, /* ........ */ + 0x00, /* ........ */ + 0x28, /* ...OO... */ + 0x54, /* ..O..O.. */ + 0x54, /* ...OO... */ + 0x28, /* ..O..O.. */ + 0x00, /* ...OO... */ + 0x00},/* ........ */ }; /* the tile struct @@ -156,20 +156,20 @@ typedef struct tile { unsigned char neighbors : 4; } tile; -//the height and width of the field -//could be variable if malloc worked in the API :) +/* the height and width of the field */ +/* could be variable if malloc worked in the API :) */ const int height = LCD_HEIGHT/8; const int width = LCD_WIDTH/8; -//the minefield +/* the minefield */ tile minefield[LCD_HEIGHT/8][LCD_WIDTH/8]; -//total number of mines on the game +/* total number of mines on the game */ int mine_num = 0; -//discovers the tile when player clears one of them -//a chain reaction (of discovery) occurs if tile has no mines -//as neighbors +/* discovers the tile when player clears one of them */ +/* a chain reaction (of discovery) occurs if tile has no mines */ +/* as neighbors */ void discover(int, int); void discover(int x, int y){ @@ -194,7 +194,7 @@ void discover(int x, int y){ } -//init not mine related elements of the mine field +/* init not mine related elements of the mine field */ void minesweeper_init(void){ int i,j; @@ -207,9 +207,9 @@ void minesweeper_init(void){ } -//put mines on the mine field -//there is p% chance that a tile is a mine -//if the tile has coordinates (x,y), then it can't be a mine +/* put mines on the mine field */ +/* there is p% chance that a tile is a mine */ +/* if the tile has coordinates (x,y), then it can't be a mine */ void minesweeper_putmines(int p, int x, int y){ int i,j; @@ -225,44 +225,49 @@ void minesweeper_putmines(int p, int x, int y){ } } - //we need to compute the neighbor element for each tile + /* we need to compute the neighbor element for each tile */ for(i=0;i0){ - if(j>0) minefield[i][j].neighbors += minefield[i-1][j-1].mine; + if(j>0) + minefield[i][j].neighbors += minefield[i-1][j-1].mine; minefield[i][j].neighbors += minefield[i-1][j].mine; - if(j0) minefield[i][j].neighbors += minefield[i][j-1].mine; - if(j0) + minefield[i][j].neighbors += minefield[i][j-1].mine; + if(j0) minefield[i][j].neighbors += minefield[i+1][j-1].mine; + if(j>0) + minefield[i][j].neighbors += minefield[i+1][j-1].mine; minefield[i][j].neighbors += minefield[i+1][j].mine; - if(jlcd_clear_display(); @@ -288,14 +293,15 @@ int minesweeper(void){ p = (p + 2)%100; break; - case BUTTON_ON://start playing + case BUTTON_ON:/* start playing */ i = 1; break; - case BUTTON_OFF://quit program + case BUTTON_OFF:/* quit program */ return MINESWEEPER_QUIT; } - if(i==1) break; + if(i==1) + break; } @@ -333,43 +339,43 @@ int minesweeper(void){ } } - //display the cursor + /* display the cursor */ rb->lcd_invertrect(x*8,y*8,8,8); - //update the screen + /* update the screen */ rb->lcd_update(); switch(rb->button_get(true)){ - //quit minesweeper (you really shouldn't use this button ...) + /* quit minesweeper (you really shouldn't use this button ...) */ case BUTTON_OFF: return MINESWEEPER_QUIT; - //move cursor left + /* move cursor left */ case BUTTON_LEFT: x = (x + width - 1)%width; break; - //move cursor right + /* move cursor right */ case BUTTON_RIGHT: x = (x + 1)%width; break; - //move cursor down + /* move cursor down */ case BUTTON_DOWN: y = (y + 1)%height; break; - //move cursor up + /* move cursor up */ case BUTTON_UP: y = (y + height - 1)%height; break; - //discover a tile (and it's neighbors if .neighbors == 0) + /* discover a tile (and it's neighbors if .neighbors == 0) */ case BUTTON_ON: case BUTTON_F2: if(minefield[y][x].flag) break; - //we put the mines on the first "click" so that you don't - //lose on the first "click" + /* we put the mines on the first "click" so that you don't */ + /* lose on the first "click" */ if(tiles_left == width*height) minesweeper_putmines(p,x,y); discover(x,y); if(minefield[y][x].mine){ @@ -386,14 +392,14 @@ int minesweeper(void){ } break; - //toggle flag under cursor + /* toggle flag under cursor */ case BUTTON_PLAY: case BUTTON_F1: minefield[y][x].flag = (minefield[y][x].flag + 1)%2; break; - //show how many mines you think you have found and how many - //there really are on the game + /* show how many mines you think you have found and how many */ + /* there really are on the game */ case BUTTON_F3: tiles_left = 0; for(i=0;i