summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2003-07-21 11:03:14 +0000
committerDaniel Stenberg <daniel@haxx.se>2003-07-21 11:03:14 +0000
commite1d5ebd53fcf58a1e57a96205e6b5dd88b0caf9e (patch)
tree5f394121b57bf4c7757a5454a2339dc93f504093
parent754426e11f82eca75bbca302674d4cc92cdf53be (diff)
downloadrockbox-e1d5ebd53fcf58a1e57a96205e6b5dd88b0caf9e.tar.gz
rockbox-e1d5ebd53fcf58a1e57a96205e6b5dd88b0caf9e.zip
minor edits to conform to rockbox standards
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3858 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/plugins/sliding_puzzle.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/apps/plugins/sliding_puzzle.c b/apps/plugins/sliding_puzzle.c
index 73b1ae3b08..790e4ac501 100644
--- a/apps/plugins/sliding_puzzle.c
+++ b/apps/plugins/sliding_puzzle.c
@@ -5,7 +5,7 @@
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/ 7 * \/ \/ \/ \/ \/
8 * $Id: puzzle.c,v 1.1 2003/01/19 00:19:56 8 * $Id$
9 * 9 *
10 * Copyright (C) 2002 Vicentini Martin 10 * Copyright (C) 2002 Vicentini Martin
11 * 11 *
@@ -128,7 +128,8 @@ static unsigned char picture[20][32] = {
128}; 128};
129 129
130/* draws a spot at the coordinates (x,y), range of p is 1-20 */ 130/* draws a spot at the coordinates (x,y), range of p is 1-20 */
131static void draw_spot(int p, int x, int y) { 131static void draw_spot(int p, int x, int y)
132{
132 if (pic || p==20) { 133 if (pic || p==20) {
133 ptr = picture[p-1]; 134 ptr = picture[p-1];
134 rb->lcd_bitmap (ptr, x, y, 16, 8, true); 135 rb->lcd_bitmap (ptr, x, y, 16, 8, true);
@@ -143,7 +144,8 @@ static void draw_spot(int p, int x, int y) {
143} 144}
144 145
145/* check if the puzzle is solved */ 146/* check if the puzzle is solved */
146static bool puzzle_finished(void) { 147static bool puzzle_finished(void)
148{
147 int i; 149 int i;
148 for (i=0; i<20; i++) 150 for (i=0; i<20; i++)
149 if (spots[i] != (i+1)) 151 if (spots[i] != (i+1))
@@ -152,7 +154,8 @@ static bool puzzle_finished(void) {
152} 154}
153 155
154/* move a piece in any direction */ 156/* move a piece in any direction */
155static void move_spot(int x, int y) { 157static void move_spot(int x, int y)
158{
156 int i; 159 int i;
157 spots[hole] = spots[hole-x-5*y]; 160 spots[hole] = spots[hole-x-5*y];
158 hole -= (x+5*y); 161 hole -= (x+5*y);
@@ -169,7 +172,8 @@ static void move_spot(int x, int y) {
169} 172}
170 173
171/* initializes the puzzle */ 174/* initializes the puzzle */
172static void puzzle_init(void) { 175static void puzzle_init(void)
176{
173 int i, r, temp, tsp[20]; 177 int i, r, temp, tsp[20];
174 moves = 0; 178 moves = 0;
175 rb->lcd_clear_display(); 179 rb->lcd_clear_display();
@@ -178,7 +182,7 @@ static void puzzle_init(void) {
178 rb->snprintf(s, sizeof(s), "%d", moves); 182 rb->snprintf(s, sizeof(s), "%d", moves);
179 rb->lcd_putsxy(85, 20, s); 183 rb->lcd_putsxy(85, 20, s);
180 184
181 // shuffle spots 185 /* shuffle spots */
182 for (i=19; i>=0; i--) { 186 for (i=19; i>=0; i--) {
183 r = (*rb->current_tick % (i+1)); 187 r = (*rb->current_tick % (i+1));
184 188
@@ -190,7 +194,7 @@ static void puzzle_init(void) {
190 hole = i; 194 hole = i;
191 } 195 }
192 196
193 // test if the puzzle is solvable 197 /* test if the puzzle is solvable */
194 for (i=0; i<20; i++) 198 for (i=0; i<20; i++)
195 tsp[i] = spots[i]; 199 tsp[i] = spots[i];
196 r=0; 200 r=0;
@@ -205,7 +209,7 @@ static void puzzle_init(void) {
205 } 209 }
206 } 210 }
207 211
208 // if the random puzzle isn't solvable just change two spots 212 /* if the random puzzle isn't solvable just change two spots */
209 if (r%2 == 1) { 213 if (r%2 == 1) {
210 if (spots[0]!=20 && spots[1]!=20) { 214 if (spots[0]!=20 && spots[1]!=20) {
211 temp = spots[0]; 215 temp = spots[0];
@@ -218,14 +222,15 @@ static void puzzle_init(void) {
218 } 222 }
219 } 223 }
220 224
221 // draw spots to the lcd 225 /* draw spots to the lcd */
222 for (i=0; i<20; i++) 226 for (i=0; i<20; i++)
223 draw_spot(spots[i], (i%5)*16, (i/5)*16); 227 draw_spot(spots[i], (i%5)*16, (i/5)*16);
224 rb->lcd_update(); 228 rb->lcd_update();
225} 229}
226 230
227/* the main game loop */ 231/* the main game loop */
228static int puzzle_loop(void) { 232static int puzzle_loop(void)
233{
229 int i; 234 int i;
230 puzzle_init(); 235 puzzle_init();
231 while(true) { 236 while(true) {