minor edits to conform to rockbox standards
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3858 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
754426e11f
commit
e1d5ebd53f
1 changed files with 15 additions and 10 deletions
|
@ -5,7 +5,7 @@
|
||||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||||
* \/ \/ \/ \/ \/
|
* \/ \/ \/ \/ \/
|
||||||
* $Id: puzzle.c,v 1.1 2003/01/19 00:19:56
|
* $Id$
|
||||||
*
|
*
|
||||||
* Copyright (C) 2002 Vicentini Martin
|
* Copyright (C) 2002 Vicentini Martin
|
||||||
*
|
*
|
||||||
|
@ -128,7 +128,8 @@ static unsigned char picture[20][32] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
/* draws a spot at the coordinates (x,y), range of p is 1-20 */
|
/* draws a spot at the coordinates (x,y), range of p is 1-20 */
|
||||||
static void draw_spot(int p, int x, int y) {
|
static void draw_spot(int p, int x, int y)
|
||||||
|
{
|
||||||
if (pic || p==20) {
|
if (pic || p==20) {
|
||||||
ptr = picture[p-1];
|
ptr = picture[p-1];
|
||||||
rb->lcd_bitmap (ptr, x, y, 16, 8, true);
|
rb->lcd_bitmap (ptr, x, y, 16, 8, true);
|
||||||
|
@ -143,7 +144,8 @@ static void draw_spot(int p, int x, int y) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check if the puzzle is solved */
|
/* check if the puzzle is solved */
|
||||||
static bool puzzle_finished(void) {
|
static bool puzzle_finished(void)
|
||||||
|
{
|
||||||
int i;
|
int i;
|
||||||
for (i=0; i<20; i++)
|
for (i=0; i<20; i++)
|
||||||
if (spots[i] != (i+1))
|
if (spots[i] != (i+1))
|
||||||
|
@ -152,7 +154,8 @@ static bool puzzle_finished(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* move a piece in any direction */
|
/* move a piece in any direction */
|
||||||
static void move_spot(int x, int y) {
|
static void move_spot(int x, int y)
|
||||||
|
{
|
||||||
int i;
|
int i;
|
||||||
spots[hole] = spots[hole-x-5*y];
|
spots[hole] = spots[hole-x-5*y];
|
||||||
hole -= (x+5*y);
|
hole -= (x+5*y);
|
||||||
|
@ -169,7 +172,8 @@ static void move_spot(int x, int y) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* initializes the puzzle */
|
/* initializes the puzzle */
|
||||||
static void puzzle_init(void) {
|
static void puzzle_init(void)
|
||||||
|
{
|
||||||
int i, r, temp, tsp[20];
|
int i, r, temp, tsp[20];
|
||||||
moves = 0;
|
moves = 0;
|
||||||
rb->lcd_clear_display();
|
rb->lcd_clear_display();
|
||||||
|
@ -178,7 +182,7 @@ static void puzzle_init(void) {
|
||||||
rb->snprintf(s, sizeof(s), "%d", moves);
|
rb->snprintf(s, sizeof(s), "%d", moves);
|
||||||
rb->lcd_putsxy(85, 20, s);
|
rb->lcd_putsxy(85, 20, s);
|
||||||
|
|
||||||
// shuffle spots
|
/* shuffle spots */
|
||||||
for (i=19; i>=0; i--) {
|
for (i=19; i>=0; i--) {
|
||||||
r = (*rb->current_tick % (i+1));
|
r = (*rb->current_tick % (i+1));
|
||||||
|
|
||||||
|
@ -190,7 +194,7 @@ static void puzzle_init(void) {
|
||||||
hole = i;
|
hole = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
// test if the puzzle is solvable
|
/* test if the puzzle is solvable */
|
||||||
for (i=0; i<20; i++)
|
for (i=0; i<20; i++)
|
||||||
tsp[i] = spots[i];
|
tsp[i] = spots[i];
|
||||||
r=0;
|
r=0;
|
||||||
|
@ -205,7 +209,7 @@ static void puzzle_init(void) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if the random puzzle isn't solvable just change two spots
|
/* if the random puzzle isn't solvable just change two spots */
|
||||||
if (r%2 == 1) {
|
if (r%2 == 1) {
|
||||||
if (spots[0]!=20 && spots[1]!=20) {
|
if (spots[0]!=20 && spots[1]!=20) {
|
||||||
temp = spots[0];
|
temp = spots[0];
|
||||||
|
@ -218,14 +222,15 @@ static void puzzle_init(void) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// draw spots to the lcd
|
/* draw spots to the lcd */
|
||||||
for (i=0; i<20; i++)
|
for (i=0; i<20; i++)
|
||||||
draw_spot(spots[i], (i%5)*16, (i/5)*16);
|
draw_spot(spots[i], (i%5)*16, (i/5)*16);
|
||||||
rb->lcd_update();
|
rb->lcd_update();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* the main game loop */
|
/* the main game loop */
|
||||||
static int puzzle_loop(void) {
|
static int puzzle_loop(void)
|
||||||
|
{
|
||||||
int i;
|
int i;
|
||||||
puzzle_init();
|
puzzle_init();
|
||||||
while(true) {
|
while(true) {
|
||||||
|
|
Loading…
Reference in a new issue