From c27ae40ca2893aea6402d1abfe56d5993217b103 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nils=20Wallm=C3=A9nius?= Date: Fri, 5 Oct 2007 21:28:43 +0000 Subject: [PATCH] Reduce memory usage so that we can include all messages on all platforms git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14997 a1c6a512-1295-4272-9138-f99709370657 --- apps/plugins/robotfindskitten.c | 56 ++++++++++++------------ apps/plugins/robotfindskitten_messages.h | 3 -- 2 files changed, 28 insertions(+), 31 deletions(-) diff --git a/apps/plugins/robotfindskitten.c b/apps/plugins/robotfindskitten.c index fa0602bdc6..844863a972 100644 --- a/apps/plugins/robotfindskitten.c +++ b/apps/plugins/robotfindskitten.c @@ -127,8 +127,8 @@ const unsigned colors[NUM_COLORS] = { on the screen*/ typedef struct { - int x; - int y; + short x; + short y; int color; bool bold; char character; @@ -139,22 +139,22 @@ typedef struct */ /*Initialization and setup functions*/ -void initialize_arrays(void); -void initialize_robot(void); -void initialize_kitten(void); -void initialize_bogus(void); -void initialize_screen(void); -void instructions(void); -void finish(int sig); +static void initialize_arrays(void); +static void initialize_robot(void); +static void initialize_kitten(void); +static void initialize_bogus(void); +static void initialize_screen(void); +static void instructions(void); +static void finish(int sig); /*Game functions*/ -void play_game(void); -void process_input(int); +static void play_game(void); +static void process_input(int); /*Helper functions*/ -int validchar(char); +static int validchar(char); -void play_animation(int); +static void play_animation(int); /*Global variables. Bite me, it's fun.*/ screen_object robot; @@ -186,14 +186,14 @@ static struct plugin_api* rb; MEM_FUNCTION_WRAPPERS(rb) -void drawchar(int x, int y, char c) +static void drawchar(int x, int y, char c) { char str[2]; rb->snprintf(str, sizeof(str), "%c", c); rb->lcd_putsxy(x*SYSFONT_WIDTH, y*SYSFONT_HEIGHT, str); } -void draw(screen_object o) +static void draw(screen_object o) { #if LCD_DEPTH > 1 unsigned oldforeground; @@ -206,12 +206,12 @@ void draw(screen_object o) #endif } -void message(char * str) +static void message(char * str) { rb->lcd_puts_scroll(0, ADV_ROW, str); } -void refresh(void) +static void refresh(void) { rb->lcd_update(); } @@ -219,7 +219,7 @@ void refresh(void) /* *play_game waits in a loop getting input and sending it to process_input */ -void play_game() +static void play_game() { int old_x = robot.x; int old_y = robot.y; @@ -261,7 +261,7 @@ void play_game() *Given the keyboard input, process_input interprets it in terms of moving, *touching objects, etc. */ -void process_input(int input) +static void process_input(int input) { #ifdef __PLUGINLIB_ACTIONS_H__ const struct button_mapping *plugin_contexts[] = {generic_directions, generic_actions}; @@ -334,7 +334,7 @@ void process_input(int input) } /*finish is called upon signal or progam exit*/ -void finish(int sig) +static void finish(int sig) { (void)sig; exit_rfk = true; @@ -346,7 +346,7 @@ void finish(int sig) * *****************************************************************************/ -int validchar(char a) +static int validchar(char a) { switch(a) { @@ -358,7 +358,7 @@ int validchar(char a) return 1; } -void play_animation(int input) +static void play_animation(int input) { int counter; screen_object left; @@ -403,7 +403,7 @@ void play_animation(int input) * *****************************************************************************/ -void instructions() +static void instructions() { char buf[X_MAX + 5]; rb->snprintf(buf, sizeof(buf), "robotfindskitten %s", RFK_VERSION); @@ -433,7 +433,7 @@ void instructions() #endif } -void initialize_arrays() +static void initialize_arrays() { unsigned int counter, counter2; screen_object empty; @@ -467,7 +467,7 @@ void initialize_arrays() } /*initialize_robot initializes robot.*/ -void initialize_robot() +static void initialize_robot() { /*Assign a position to the player.*/ robot.x = randx(); @@ -480,7 +480,7 @@ void initialize_robot() } /*initialize kitten, well, initializes kitten.*/ -void initialize_kitten() +static void initialize_kitten() { /*Assign the kitten a unique position.*/ do @@ -500,7 +500,7 @@ void initialize_kitten() } /*initialize_bogus initializes all non-kitten objects to be used in this run.*/ -void initialize_bogus() +static void initialize_bogus() { int counter, index; for (counter = 0; counter < num_bogus; counter++) @@ -534,7 +534,7 @@ void initialize_bogus() } /*initialize_screen paints the screen.*/ -void initialize_screen() +static void initialize_screen() { int counter; char buf[40]; diff --git a/apps/plugins/robotfindskitten_messages.h b/apps/plugins/robotfindskitten_messages.h index 685fdf46cd..175c354380 100644 --- a/apps/plugins/robotfindskitten_messages.h +++ b/apps/plugins/robotfindskitten_messages.h @@ -417,8 +417,6 @@ static char* messages[] = "It's the triangle leg adjacent to an angle divided by the leg opposite it.", "It's a bottle of nail polish remover.", "You found netkit! Way to go, robot!", -/* Exclude some messages on targets with less RAM */ -#if PLUGIN_BUFFER_SIZE > 0x8000 "It's the ASCII Floating Head of Seth David Schoen!", "A frosted pink party-cake, half eaten.", "A bitchin' homemade tesla coil.", @@ -449,5 +447,4 @@ static char* messages[] = "The intermission from a 1930s silent movie.", "It's an inverted billiard ball!", "The spectre of Sherlock Holmes wills you onwards.", -#endif };