Index: apps/plugins/lib/SOURCES =================================================================== --- apps/plugins/lib/SOURCES (Revision 20626) +++ apps/plugins/lib/SOURCES (Arbeitskopie) @@ -5,6 +5,7 @@ playback_control.c rgb_hsv.c buflib.c +text.c #if defined(HAVE_LCD_BITMAP) && (LCD_DEPTH < 4) /* The scaler is not provided in core on mono targets, but is built in Index: apps/plugins/lib/text.c =================================================================== --- apps/plugins/lib/text.c (Revision 0) +++ apps/plugins/lib/text.c (Revision 0) @@ -0,0 +1,116 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id: highscore.c 19776 2009-01-16 10:34:40Z unhelpful $ + * + * Copyright (C) 2009 Johannes Schwarz + * based on Will Robertson code in superdom + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#include "plugin.h" +#include "text.h" +#define MARGIN 5 + +int display_text(short words, char** text, struct style_text *style) +{ +#ifdef HAVE_LCD_COLOR + rb->lcd_set_background(LCD_BLACK); + rb->lcd_set_foreground(LCD_WHITE); +#endif +#ifdef HAVE_LCD_BITMAP + rb->lcd_setfont(FONT_UI); +#endif + int y = MARGIN; + int space_w, width, height; + unsigned short x = MARGIN, i = 0; + int button; + rb->lcd_clear_display(); +#ifdef HAVE_LCD_BITMAP + rb->font_getstringsize(" ", &space_w, &height, FONT_UI); +#else + rb->lcd_getstringsize(" ", &space_w, &height, NULL); +#endif + for (i = 0; i < words; i++) { +#ifdef HAVE_LCD_BITMAP + rb->font_getstringsize(text[i], &width, NULL, FONT_UI); +#else + rb->lcd_getstringsize(text[i], &width, NULL); +#endif + /* Skip to next line if the current one can't fit the word */ + if (x + width > LCD_WIDTH - MARGIN) { + x = MARGIN; + y += height; + } + /* .. or if the word is the empty string */ + if (strcmp(text[i], "") == 0) { + x = MARGIN; + y += height; + continue; + } + /* We filled the screen */ + if (y + height > LCD_HEIGHT - MARGIN) { + y = MARGIN; + rb->lcd_update(); + do { + button = rb->button_get(true); + if (button == SYS_USB_CONNECTED) { + return PLUGIN_USB_CONNECTED; + } + } while( ( button == BUTTON_NONE ) + || ( button & (BUTTON_REL|BUTTON_REPEAT) ) ); + rb->lcd_clear_display(); + } + /* set align */ + if (style[i].center==1) { + x=(LCD_WIDTH/2)-(width/2); + } + /* set colour */ +#ifdef HAVE_LCD_COLOR + switch (style[i].color) { + case C_RED: + rb->lcd_set_foreground(LCD_RGBPACK(255,0,0)); + break; + case C_YELLOW: + rb->lcd_set_foreground(LCD_RGBPACK(255,255,0)); + break; + case C_GREEN: + rb->lcd_set_foreground(LCD_RGBPACK(0,192,0)); + break; + case C_BLUE: + rb->lcd_set_foreground(LCD_RGBPACK(0,0,255)); + break; + case C_ORANGE: + rb->lcd_set_foreground(LCD_RGBPACK(255,192,0)); + break; + case NORMAL: + rb->lcd_set_foreground(LCD_WHITE); + break; + } +#endif + rb->lcd_putsxy(x, y, text[i]); +#ifdef HAVE_LCD_BITMAP + if (style[i].underline==1) { + rb->lcd_set_drawmode(DRMODE_SOLID); + rb->lcd_hline(x, x+width, y+height); + } +#endif + x += width + space_w; + } + rb->lcd_update(); +#ifdef HAVE_LCD_BITMAP + rb->lcd_setfont(FONT_SYSFIXED); +#endif +return 0; +} Index: text.h =================================================================== --- apps/plugins/lib/text.h (Revision 0) +++ apps/plugins/lib/text.h (Revision 0) @@ -0,0 +1,34 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id: highscore.c 19776 2009-01-16 10:34:40Z unhelpful $ + * + * Copyright (C) 2009 Johannes Schwarz + * based on Will Robertson code in superdom + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#include "plugin.h" +/* + * Usage: +*/ + +struct style_text { + enum EColor { NORMAL, C_YELLOW, C_RED, C_BLUE, C_GREEN , C_ORANGE } color; + short center; + short underline; +}; + +/* the struct should be optional */ +int display_text(short words, char** text, struct style_text *style); Index: apps/plugins/brickmania.c =================================================================== --- apps/plugins/brickmania.c (Revision 20639) +++ apps/plugins/brickmania.c (Arbeitskopie) @@ -22,6 +22,7 @@ #include "plugin.h" #include "lib/configfile.h" /* Part of libplugin */ #include "lib/helper.h" +#include "lib/text.h" PLUGIN_HEADER @@ -217,6 +218,15 @@ #define SCROLL_BACK(x) (0) #endif +#if CONFIG_KEYPAD == ONDIO_PAD +#define HELP_SELECT "MENU" +#elif (CONFIG_KEYPAD == RECORDER_PAD) || (CONFIG_KEYPAD == IAUDIO_M3_PAD) +#define HELP_SELECT "PLAY" +#elif CONFIG_KEYPAD == IRIVER_H300_PAD +#define HELP_SELECT "NAVI" +#else +#define HELP_SELECT "SELECT" +#endif enum menu_items { BM_START, @@ -1111,155 +1121,63 @@ int help(int when) { - int w,h; - int button; - int xoffset=0; - int yoffset=0; - /* set the maximum x and y in the helpscreen - dont forget to update, if you change text */ - int maxY=180; - int maxX=215; +#define WORDS (sizeof help_text / sizeof (char*)) + char *help_text[] = { + "Brickmania", "", "Aim", "", "Destroy", "all", "the", "bricks", "by", "bouncing", + "the", "ball", "of", "them", "using", "the", "paddle.", "", "", "Controls", "", + "< & >", "Move", "the", "paddle", "", HELP_SELECT, "Release", "the", "ball/fire!", "", "", + "Specials:", "", "N", "Normal:", "returns", "paddle", "to", "normal", "", "D", "DIE!:", + "loses", "a", "life", "", "L", "Life:", "gains", "a", "life", "up", "", "F", "Fire:", + "allows", "you", "to", "shoot", "bricks", "", "G", "Glue:", "ball", "sticks", "to", + "paddle", "", "B", "Ball:", "generate", "another", "ball", "", "FL", "Flip:", "flips", + "left/right", "movement", + }; + struct style_text formation[WORDS]={}; + formation[0].center=1; + formation[0].underline=1; + formation[2].color=C_RED; + formation[19].color=C_RED; + formation[32].color=C_RED; + formation[34].color=C_BLUE; + formation[41].color=C_RED; + formation[47].color=C_GREEN; + formation[54].color=C_ORANGE; + formation[62].color=C_GREEN; + formation[69].color=C_YELLOW; + formation[75].color=C_RED; + + if (display_text(WORDS, help_text, formation)==PLUGIN_USB_CONNECTED) + return 1; - while(true) { -#ifdef HAVE_LCD_COLOR - rb->lcd_set_background(LCD_BLACK); - rb->lcd_clear_display(); - rb->lcd_set_background(LCD_BLACK); - rb->lcd_set_foreground(LCD_WHITE); -#else - rb->lcd_clear_display(); -#endif - - rb->lcd_getstringsize("BrickMania", &w, &h); - rb->lcd_putsxy(LCD_WIDTH/2-w/2+xoffset, 1+yoffset, "BrickMania"); - -#ifdef HAVE_LCD_COLOR - rb->lcd_set_foreground(LCD_RGBPACK(245,0,0)); - rb->lcd_putsxy(1+xoffset, 1*(h+2)+yoffset,"Aim"); - rb->lcd_set_foreground(LCD_WHITE); -#else - rb->lcd_putsxy(1+xoffset, 1*(h+2)+yoffset,"Aim"); -#endif - rb->lcd_putsxy(1+xoffset, 2*(h+2)+yoffset, - "destroy all the bricks by bouncing"); - rb->lcd_putsxy(1+xoffset, 3*(h+2)+yoffset, - "the ball of them using the paddle."); -#ifdef HAVE_LCD_COLOR - rb->lcd_set_foreground(LCD_RGBPACK(245,0,0)); - rb->lcd_putsxy(1+xoffset, 5*(h+2)+yoffset,"Controls"); - rb->lcd_set_foreground(LCD_WHITE); -#else - rb->lcd_putsxy(1+xoffset, 5*(h+2)+yoffset,"Controls"); -#endif - rb->lcd_putsxy(1+xoffset, 6*(h+2)+yoffset,"< & > Move the paddle"); -#if CONFIG_KEYPAD == ONDIO_PAD - rb->lcd_putsxy(1+xoffset, 7*(h+2)+yoffset, - "MENU Releases the ball/Fire!"); -#elif (CONFIG_KEYPAD == RECORDER_PAD) || (CONFIG_KEYPAD == IAUDIO_M3_PAD) - rb->lcd_putsxy(1+xoffset, 7*(h+2)+yoffset, - "PLAY Releases the ball/Fire!"); -#elif CONFIG_KEYPAD == IRIVER_H300_PAD - rb->lcd_putsxy(1+xoffset, 7*(h+2)+yoffset, - "NAVI Releases the ball/Fire!"); -#else - rb->lcd_putsxy(1+xoffset, 7*(h+2)+yoffset, - "SELECT Releases the ball/Fire!"); -#endif -#if CONFIG_KEYPAD == IAUDIO_M3_PAD - rb->lcd_putsxy(1+xoffset, 8*(h+2)+yoffset, "REC Opens menu/Quit"); -#else - rb->lcd_putsxy(1+xoffset, 8*(h+2)+yoffset, "STOP Opens menu/Quit"); -#endif -#ifdef HAVE_LCD_COLOR - rb->lcd_set_foreground(LCD_RGBPACK(245,0,0)); - rb->lcd_putsxy(1+xoffset, 10*(h+2)+yoffset, "Specials"); - rb->lcd_set_foreground(LCD_WHITE); -#else - rb->lcd_putsxy(1+xoffset, 10*(h+2)+yoffset, "Specials"); -#endif - rb->lcd_putsxy(1+xoffset, 11*(h+2)+yoffset, - "N Normal:returns paddle to normal"); - rb->lcd_putsxy(1+xoffset, 12*(h+2)+yoffset, "D DIE!:loses a life"); - rb->lcd_putsxy(1+xoffset, 13*(h+2)+yoffset, - "L Life:gains a life/power up"); - rb->lcd_putsxy(1+xoffset, 14*(h+2)+yoffset, - "F Fire:allows you to shoot bricks"); - rb->lcd_putsxy(1+xoffset, 15*(h+2)+yoffset, - "G Glue:ball sticks to paddle"); - rb->lcd_putsxy(1+xoffset, 16*(h+2)+yoffset, - "B Ball:generates another ball"); - rb->lcd_putsxy(1+xoffset, 17*(h+2)+yoffset, - "FL Flip:flips left / right movement"); - rb->lcd_update(); - - button=rb->button_get(true); - switch (button) { -#ifdef RC_QUIT - case RC_QUIT: -#endif -#ifdef HAVE_TOUCHSCREEN - case BUTTON_TOUCHSCREEN: -#endif - case QUIT: - switch (game_menu(when)) { - case 0: - cur_level=0; - life=2; - int_game(1); - break; - case 1: - con_game=1; - break; - case 2: - if (help(when)==1) - return 1; - break; - case 3: - return 1; - break; - } - return 0; - break; - case LEFT: - case LEFT | BUTTON_REPEAT: -#ifdef ALTLEFT - case ALTLEFT: - case ALTLEFT | BUTTON_REPEAT: -#endif - if( xoffset<0) - xoffset+=2; - break; - case RIGHT: - case RIGHT | BUTTON_REPEAT: -#ifdef ALTRIGHT - case ALTRIGHT: - case ALTRIGHT | BUTTON_REPEAT: -#endif - if(xoffset+maxX > LCD_WIDTH) - xoffset-=2; - break; - case UP: - case UP | BUTTON_REPEAT: - if(yoffset <0) - yoffset+=2; - break; - case DOWN: - case DOWN | BUTTON_REPEAT: - if(yoffset+maxY > LCD_HEIGHT) - yoffset-=2; - break; - - default: - if(rb->default_event_handler(button) == SYS_USB_CONNECTED) - return 1; - break; + int button; + do { + button = rb->button_get(true); + if (button == SYS_USB_CONNECTED) { + return 1; } - - rb->yield(); + } while( ( button == BUTTON_NONE ) + || ( button & (BUTTON_REL|BUTTON_REPEAT) ) ); + switch (game_menu(when)) { + case 0: + cur_level=0; + life=2; + int_game(1); + break; + case 1: + con_game=1; + break; + case 2: + if (help(when)==1) + return 1; + break; + case 3: + return 1; + break; } return 0; } + int pad_check(int ballxc, int mode, int pon ,int ballnum) { /* pon: positive(1) or negative(0) */