mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-14 02:27:39 -04:00
A bit of code policing.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19021 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
4cf9b1415b
commit
f06074cd06
1 changed files with 72 additions and 74 deletions
|
@ -455,9 +455,6 @@ static char* messages[] =
|
||||||
"The spectre of Sherlock Holmes wills you onwards.",
|
"The spectre of Sherlock Holmes wills you onwards.",
|
||||||
};
|
};
|
||||||
|
|
||||||
#define TRUE true
|
|
||||||
#define FALSE false
|
|
||||||
|
|
||||||
#define RFK_VERSION "v1.4142135.406"
|
#define RFK_VERSION "v1.4142135.406"
|
||||||
|
|
||||||
/* Button definitions stolen from maze.c */
|
/* Button definitions stolen from maze.c */
|
||||||
|
@ -531,7 +528,7 @@ const unsigned colors[NUM_COLORS] = {
|
||||||
#define randy() (rb->rand() % (Y_MAX-Y_MIN+1))+Y_MIN /*I'm feeling randy()!*/
|
#define randy() (rb->rand() % (Y_MAX-Y_MIN+1))+Y_MIN /*I'm feeling randy()!*/
|
||||||
#define randchar() rb->rand() % (126-'!'+1)+'!';
|
#define randchar() rb->rand() % (126-'!'+1)+'!';
|
||||||
#define randcolor() rb->rand() % NUM_COLORS
|
#define randcolor() rb->rand() % NUM_COLORS
|
||||||
#define randbold() (rb->rand() % 2 ? TRUE:FALSE)
|
#define randbold() (rb->rand() % 2 ? true:false)
|
||||||
|
|
||||||
/*Row constants for the animation*/
|
/*Row constants for the animation*/
|
||||||
#define ADV_ROW 1
|
#define ADV_ROW 1
|
||||||
|
@ -540,14 +537,14 @@ const unsigned colors[NUM_COLORS] = {
|
||||||
|
|
||||||
/*This struct contains all the information we need to display an object
|
/*This struct contains all the information we need to display an object
|
||||||
on the screen*/
|
on the screen*/
|
||||||
typedef struct
|
struct screen_object
|
||||||
{
|
{
|
||||||
short x;
|
short x;
|
||||||
short y;
|
short y;
|
||||||
int color;
|
int color;
|
||||||
bool bold;
|
bool bold;
|
||||||
char character;
|
char character;
|
||||||
} screen_object;
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*Function definitions
|
*Function definitions
|
||||||
|
@ -572,15 +569,15 @@ static int validchar(char);
|
||||||
static void play_animation(int);
|
static void play_animation(int);
|
||||||
|
|
||||||
/*Global variables. Bite me, it's fun.*/
|
/*Global variables. Bite me, it's fun.*/
|
||||||
screen_object robot;
|
struct screen_object robot;
|
||||||
screen_object kitten;
|
struct screen_object kitten;
|
||||||
|
|
||||||
#if X_MAX*Y_MAX < 200
|
#if X_MAX*Y_MAX < 200
|
||||||
#define NUM_BOGUS 15
|
#define NUM_BOGUS 15
|
||||||
#else
|
#else
|
||||||
#define NUM_BOGUS 20
|
#define NUM_BOGUS 20
|
||||||
#endif
|
#endif
|
||||||
screen_object bogus[NUM_BOGUS];
|
struct screen_object bogus[NUM_BOGUS];
|
||||||
unsigned short bogus_messages[NUM_BOGUS];
|
unsigned short bogus_messages[NUM_BOGUS];
|
||||||
bool used_messages[MESSAGES];
|
bool used_messages[MESSAGES];
|
||||||
|
|
||||||
|
@ -612,7 +609,7 @@ static void drawchar(int x, int y, char c)
|
||||||
rb->lcd_putsxy(x*SYSFONT_WIDTH, y*SYSFONT_HEIGHT, str);
|
rb->lcd_putsxy(x*SYSFONT_WIDTH, y*SYSFONT_HEIGHT, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void draw(screen_object o)
|
static void draw(struct screen_object o)
|
||||||
{
|
{
|
||||||
#if LCD_DEPTH > 1
|
#if LCD_DEPTH > 1
|
||||||
unsigned oldforeground;
|
unsigned oldforeground;
|
||||||
|
@ -640,40 +637,40 @@ static void refresh(void)
|
||||||
*/
|
*/
|
||||||
static void play_game()
|
static void play_game()
|
||||||
{
|
{
|
||||||
int old_x = robot.x;
|
int old_x = robot.x;
|
||||||
int old_y = robot.y;
|
int old_y = robot.y;
|
||||||
int input = 0; /* Not sure what a reasonable initial value is */
|
int input = 0; /* Not sure what a reasonable initial value is */
|
||||||
#ifdef __PLUGINLIB_ACTIONS_H__
|
#ifdef __PLUGINLIB_ACTIONS_H__
|
||||||
const struct button_mapping *plugin_contexts[] = {generic_directions, generic_actions};
|
const struct button_mapping *plugin_contexts[] = {generic_directions, generic_actions};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
while (input != RFK_QUIT && exit_rfk == false)
|
while (input != RFK_QUIT && exit_rfk == false)
|
||||||
{
|
{
|
||||||
process_input(input);
|
process_input(input);
|
||||||
|
|
||||||
/*Redraw robot, where applicable. We're your station, robot.*/
|
/*Redraw robot, where applicable. We're your station, robot.*/
|
||||||
if (!(old_x == robot.x && old_y == robot.y))
|
if (!(old_x == robot.x && old_y == robot.y))
|
||||||
{
|
{
|
||||||
/*Get rid of the old robot*/
|
/*Get rid of the old robot*/
|
||||||
drawchar(old_x, old_y, ' ');
|
drawchar(old_x, old_y, ' ');
|
||||||
screen[old_x][old_y] = EMPTY;
|
screen[old_x][old_y] = EMPTY;
|
||||||
|
|
||||||
/*Meet the new robot, same as the old robot.*/
|
/*Meet the new robot, same as the old robot.*/
|
||||||
draw(robot);
|
draw(robot);
|
||||||
refresh();
|
refresh();
|
||||||
screen[robot.x][robot.y] = ROBOT;
|
screen[robot.x][robot.y] = ROBOT;
|
||||||
|
|
||||||
old_x = robot.x;
|
old_x = robot.x;
|
||||||
old_y = robot.y;
|
old_y = robot.y;
|
||||||
}
|
}
|
||||||
#ifdef __PLUGINLIB_ACTIONS_H__
|
#ifdef __PLUGINLIB_ACTIONS_H__
|
||||||
input = pluginlib_getaction(rb, TIMEOUT_BLOCK, plugin_contexts, 2);
|
input = pluginlib_getaction(rb, TIMEOUT_BLOCK, plugin_contexts, 2);
|
||||||
#else
|
#else
|
||||||
input = rb->button_get(true);
|
input = rb->button_get(true);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
message("Bye!");
|
message("Bye!");
|
||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -761,8 +758,9 @@ static void pause()
|
||||||
{
|
{
|
||||||
int button;
|
int button;
|
||||||
rb->lcd_update();
|
rb->lcd_update();
|
||||||
do
|
do {
|
||||||
button = rb->button_get(true);
|
button = rb->button_get(true);
|
||||||
|
}
|
||||||
while( ( button == BUTTON_NONE )
|
while( ( button == BUTTON_NONE )
|
||||||
|| ( button & (BUTTON_REL|BUTTON_REPEAT) ) );
|
|| ( button & (BUTTON_REL|BUTTON_REPEAT) ) );
|
||||||
}
|
}
|
||||||
|
@ -782,12 +780,14 @@ static int validchar(char a)
|
||||||
static void play_animation(int input)
|
static void play_animation(int input)
|
||||||
{
|
{
|
||||||
int counter;
|
int counter;
|
||||||
screen_object left;
|
struct screen_object left;
|
||||||
screen_object right;
|
struct screen_object right;
|
||||||
/*The grand cinema scene.*/
|
/*The grand cinema scene.*/
|
||||||
rb->lcd_puts_scroll(0, ADV_ROW, " ");
|
rb->lcd_puts_scroll(0, ADV_ROW, " ");
|
||||||
|
|
||||||
if (input == RFK_RIGHT || input == RFK_DOWN || input == RFK_RRIGHT || input == RFK_RDOWN) {
|
if (input == RFK_RIGHT || input == RFK_DOWN ||
|
||||||
|
input == RFK_RRIGHT || input == RFK_RDOWN)
|
||||||
|
{
|
||||||
left = robot;
|
left = robot;
|
||||||
right = kitten;
|
right = kitten;
|
||||||
}
|
}
|
||||||
|
@ -871,7 +871,7 @@ static void instructions()
|
||||||
static void initialize_arrays()
|
static void initialize_arrays()
|
||||||
{
|
{
|
||||||
unsigned int counter, counter2;
|
unsigned int counter, counter2;
|
||||||
screen_object empty;
|
struct screen_object empty;
|
||||||
|
|
||||||
/*Initialize the empty object.*/
|
/*Initialize the empty object.*/
|
||||||
empty.x = -1;
|
empty.x = -1;
|
||||||
|
@ -881,7 +881,7 @@ static void initialize_arrays()
|
||||||
#else
|
#else
|
||||||
empty.color = 0;
|
empty.color = 0;
|
||||||
#endif
|
#endif
|
||||||
empty.bold = FALSE;
|
empty.bold = false;
|
||||||
empty.character = ' ';
|
empty.character = ' ';
|
||||||
|
|
||||||
for (counter = 0; counter <= X_MAX; counter++)
|
for (counter = 0; counter <= X_MAX; counter++)
|
||||||
|
@ -913,60 +913,58 @@ static void initialize_robot()
|
||||||
|
|
||||||
robot.character = '#';
|
robot.character = '#';
|
||||||
robot.color = ROBOT_COLOR;
|
robot.color = ROBOT_COLOR;
|
||||||
robot.bold = FALSE;
|
robot.bold = false;
|
||||||
screen[robot.x][robot.y] = ROBOT;
|
screen[robot.x][robot.y] = ROBOT;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*initialize kitten, well, initializes kitten.*/
|
/*initialize kitten, well, initializes kitten.*/
|
||||||
static void initialize_kitten()
|
static void initialize_kitten()
|
||||||
{
|
{
|
||||||
/*Assign the kitten a unique position.*/
|
/*Assign the kitten a unique position.*/
|
||||||
do
|
do {
|
||||||
{
|
kitten.x = randx();
|
||||||
kitten.x = randx();
|
kitten.y = randy();
|
||||||
kitten.y = randy();
|
|
||||||
} while (screen[kitten.x][kitten.y] != EMPTY);
|
} while (screen[kitten.x][kitten.y] != EMPTY);
|
||||||
|
|
||||||
/*Assign the kitten a character and a color.*/
|
/*Assign the kitten a character and a color.*/
|
||||||
do {
|
do {
|
||||||
kitten.character = randchar();
|
kitten.character = randchar();
|
||||||
} while (!(validchar(kitten.character)));
|
} while (!(validchar(kitten.character)));
|
||||||
screen[kitten.x][kitten.y] = KITTEN;
|
screen[kitten.x][kitten.y] = KITTEN;
|
||||||
|
|
||||||
kitten.color = colors[randcolor()];
|
kitten.color = colors[randcolor()];
|
||||||
kitten.bold = randbold();
|
kitten.bold = randbold();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*initialize_bogus initializes all non-kitten objects to be used in this run.*/
|
/*initialize_bogus initializes all non-kitten objects to be used in this run.*/
|
||||||
static void initialize_bogus()
|
static void initialize_bogus()
|
||||||
{
|
{
|
||||||
int counter, index;
|
int counter, index;
|
||||||
for (counter = 0; counter < NUM_BOGUS; counter++)
|
for (counter = 0; counter < NUM_BOGUS; counter++)
|
||||||
{
|
{
|
||||||
/*Give it a color.*/
|
/*Give it a color.*/
|
||||||
bogus[counter].color = colors[randcolor()];
|
bogus[counter].color = colors[randcolor()];
|
||||||
bogus[counter].bold = randbold();
|
bogus[counter].bold = randbold();
|
||||||
|
|
||||||
/*Give it a character.*/
|
/*Give it a character.*/
|
||||||
do {
|
do {
|
||||||
bogus[counter].character = randchar();
|
bogus[counter].character = randchar();
|
||||||
} while (!(validchar(bogus[counter].character)));
|
} while (!(validchar(bogus[counter].character)));
|
||||||
|
|
||||||
/*Give it a position.*/
|
/*Give it a position.*/
|
||||||
do
|
do {
|
||||||
{
|
bogus[counter].x = randx();
|
||||||
bogus[counter].x = randx();
|
bogus[counter].y = randy();
|
||||||
bogus[counter].y = randy();
|
} while (screen[bogus[counter].x][bogus[counter].y] != EMPTY);
|
||||||
} while (screen[bogus[counter].x][bogus[counter].y] != EMPTY);
|
|
||||||
|
|
||||||
screen[bogus[counter].x][bogus[counter].y] = counter+2;
|
screen[bogus[counter].x][bogus[counter].y] = counter+2;
|
||||||
|
|
||||||
/*Find a message for this object.*/
|
/*Find a message for this object.*/
|
||||||
do {
|
do {
|
||||||
index = rb->rand() % MESSAGES;
|
index = rb->rand() % MESSAGES;
|
||||||
} while (used_messages[index] != false);
|
} while (used_messages[index] != false);
|
||||||
bogus_messages[counter] = index;
|
bogus_messages[counter] = index;
|
||||||
used_messages[index] = true;
|
used_messages[index] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue