#include "gp2x.h"\r
#include "emu.h"\r
#include "menu.h"\r
+#include "fonts.h"\r
#include "usbjoy.h"\r
#include "version.h"\r
\r
char menuErrorMsg[40] = {0, };\r
\r
\r
-static unsigned char fontdata8x8[] =\r
-{\r
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\r
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\r
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\r
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\r
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\r
- 0x3C,0x42,0x99,0xBD,0xBD,0x99,0x42,0x3C,0x3C,0x42,0x81,0x81,0x81,0x81,0x42,0x3C,\r
- 0xFE,0x82,0x8A,0xD2,0xA2,0x82,0xFE,0x00,0xFE,0x82,0x82,0x82,0x82,0x82,0xFE,0x00,\r
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x64,0x74,0x7C,0x38,0x00,0x00,\r
- 0x80,0xC0,0xF0,0xFC,0xF0,0xC0,0x80,0x00,0x01,0x03,0x0F,0x3F,0x0F,0x03,0x01,0x00,\r
- 0x18,0x3C,0x7E,0x18,0x7E,0x3C,0x18,0x00,0xEE,0xEE,0xEE,0xCC,0x00,0xCC,0xCC,0x00,\r
- 0x00,0x00,0x30,0x68,0x78,0x30,0x00,0x00,0x00,0x38,0x64,0x74,0x7C,0x38,0x00,0x00,\r
- 0x3C,0x66,0x7A,0x7A,0x7E,0x7E,0x3C,0x00,0x0E,0x3E,0x3A,0x22,0x26,0x6E,0xE4,0x40,\r
- 0x18,0x3C,0x7E,0x3C,0x3C,0x3C,0x3C,0x00,0x3C,0x3C,0x3C,0x3C,0x7E,0x3C,0x18,0x00,\r
- 0x08,0x7C,0x7E,0x7E,0x7C,0x08,0x00,0x00,0x10,0x3E,0x7E,0x7E,0x3E,0x10,0x00,0x00,\r
- 0x58,0x2A,0xDC,0xC8,0xDC,0x2A,0x58,0x00,0x24,0x66,0xFF,0xFF,0x66,0x24,0x00,0x00,\r
- 0x00,0x10,0x10,0x38,0x38,0x7C,0xFE,0x00,0xFE,0x7C,0x38,0x38,0x10,0x10,0x00,0x00,\r
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x1C,0x1C,0x18,0x00,0x18,0x18,0x00,\r
- 0x6C,0x6C,0x24,0x00,0x00,0x00,0x00,0x00,0x00,0x28,0x7C,0x28,0x7C,0x28,0x00,0x00,\r
- 0x10,0x38,0x60,0x38,0x0C,0x78,0x10,0x00,0x40,0xA4,0x48,0x10,0x24,0x4A,0x04,0x00,\r
- 0x18,0x34,0x18,0x3A,0x6C,0x66,0x3A,0x00,0x18,0x18,0x20,0x00,0x00,0x00,0x00,0x00,\r
- 0x30,0x60,0x60,0x60,0x60,0x60,0x30,0x00,0x0C,0x06,0x06,0x06,0x06,0x06,0x0C,0x00,\r
- 0x10,0x54,0x38,0x7C,0x38,0x54,0x10,0x00,0x00,0x18,0x18,0x7E,0x18,0x18,0x00,0x00,\r
- 0x00,0x00,0x00,0x00,0x18,0x18,0x30,0x00,0x00,0x00,0x00,0x00,0x3E,0x00,0x00,0x00,\r
- 0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x04,0x08,0x10,0x20,0x40,0x00,0x00,\r
- 0x38,0x4C,0xC6,0xC6,0xC6,0x64,0x38,0x00,0x18,0x38,0x18,0x18,0x18,0x18,0x7E,0x00,\r
- 0x7C,0xC6,0x0E,0x3C,0x78,0xE0,0xFE,0x00,0x7E,0x0C,0x18,0x3C,0x06,0xC6,0x7C,0x00,\r
- 0x1C,0x3C,0x6C,0x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E,0xC6,0x00,0x7C,0xC6,0xC6,0xC6,0xC6,0xC6,0x7C,0x00,\r
- 0xFC,0xC6,0xC6,0xC6,0xFC,0xC0,0xC0,0x00,0x7C,0xC6,0xC6,0xC6,0xDE,0xCC,0x7A,0x00,\r
- 0xFC,0xC6,0xC6,0xCE,0xF8,0xDC,0xCE,0x00,0x78,0xCC,0xC0,0x7C,0x06,0xC6,0x7C,0x00,\r
- 0x7E,0x18,0x18,0x18,0x18,0x18,0x18,0x00,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0x7C,0x00,\r
- 0xC6,0xC6,0xC6,0xEE,0x7C,0x38,0x10,0x00,0xC6,0xC6,0xD6,0xFE,0xFE,0xEE,0xC6,0x00,\r
- 0xC6,0xEE,0x3C,0x38,0x7C,0xEE,0xC6,0x00,0x66,0x66,0x66,0x3C,0x18,0x18,0x18,0x00,\r
- 0xFE,0x0E,0x1C,0x38,0x70,0xE0,0xFE,0x00,0x3C,0x30,0x30,0x30,0x30,0x30,0x3C,0x00,\r
- 0x60,0x60,0x30,0x18,0x0C,0x06,0x06,0x00,0x3C,0x0C,0x0C,0x0C,0x0C,0x0C,0x3C,0x00,\r
- 0x18,0x3C,0x66,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,\r
- 0x30,0x30,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x06,0x3E,0x66,0x66,0x3C,0x00,\r
- 0x60,0x7C,0x66,0x66,0x66,0x66,0x7C,0x00,0x00,0x3C,0x66,0x60,0x60,0x66,0x3C,0x00,\r
- 0x06,0x3E,0x66,0x66,0x66,0x66,0x3E,0x00,0x00,0x3C,0x66,0x66,0x7E,0x60,0x3C,0x00,\r
- 0x1C,0x30,0x78,0x30,0x30,0x30,0x30,0x00,0x00,0x3E,0x66,0x66,0x66,0x3E,0x06,0x3C,\r
- 0x60,0x7C,0x76,0x66,0x66,0x66,0x66,0x00,0x18,0x00,0x38,0x18,0x18,0x18,0x18,0x00,\r
- 0x0C,0x00,0x1C,0x0C,0x0C,0x0C,0x0C,0x38,0x60,0x60,0x66,0x6C,0x78,0x6C,0x66,0x00,\r
- 0x38,0x18,0x18,0x18,0x18,0x18,0x18,0x00,0x00,0xEC,0xFE,0xFE,0xFE,0xD6,0xC6,0x00,\r
- 0x00,0x7C,0x76,0x66,0x66,0x66,0x66,0x00,0x00,0x3C,0x66,0x66,0x66,0x66,0x3C,0x00,\r
- 0x00,0x7C,0x66,0x66,0x66,0x7C,0x60,0x60,0x00,0x3E,0x66,0x66,0x66,0x3E,0x06,0x06,\r
- 0x00,0x7E,0x70,0x60,0x60,0x60,0x60,0x00,0x00,0x3C,0x60,0x3C,0x06,0x66,0x3C,0x00,\r
- 0x30,0x78,0x30,0x30,0x30,0x30,0x1C,0x00,0x00,0x66,0x66,0x66,0x66,0x6E,0x3E,0x00,\r
- 0x00,0x66,0x66,0x66,0x66,0x3C,0x18,0x00,0x00,0xC6,0xD6,0xFE,0xFE,0x7C,0x6C,0x00,\r
- 0x00,0x66,0x3C,0x18,0x3C,0x66,0x66,0x00,0x00,0x66,0x66,0x66,0x66,0x3E,0x06,0x3C,\r
- 0x00,0x7E,0x0C,0x18,0x30,0x60,0x7E,0x00,0x0E,0x18,0x0C,0x38,0x0C,0x18,0x0E,0x00,\r
- 0x18,0x18,0x18,0x00,0x18,0x18,0x18,0x00,0x70,0x18,0x30,0x1C,0x30,0x18,0x70,0x00,\r
- 0x00,0x00,0x76,0xDC,0x00,0x00,0x00,0x00,0x10,0x28,0x10,0x54,0xAA,0x44,0x00,0x00,\r
-};\r
-\r
-static void gp2x_text(unsigned char *screen, int x, int y, char *text, int color)\r
+static void gp2x_text(unsigned char *screen, int x, int y, const char *text, int color)\r
{\r
int i,l;\r
\r
}\r
\r
// draws white text to current bbp15 screen\r
-void gp2x_text_out15(int x, int y, char *text)\r
+void gp2x_text_out15(int x, int y, const char *text)\r
{\r
int i,l;\r
unsigned short *screen = gp2x_screen;\r
}\r
\r
\r
-void gp2x_text_out8(int x, int y, char *texto, ...)\r
+void gp2x_text_out8(int x, int y, const char *texto, ...)\r
{\r
va_list args;\r
char buffer[512];\r
vsprintf(buffer,texto,args);\r
va_end(args);\r
\r
- gp2x_text(gp2x_screen,x,y,buffer,1);\r
+ gp2x_text(gp2x_screen,x,y,buffer,0xf0);\r
}\r
\r
\r
-void gp2x_text_out8_2(int x, int y, char *texto, int color)\r
+void gp2x_text_out8_2(int x, int y, const char *texto, int color)\r
{\r
gp2x_text(gp2x_screen, x, y, texto, color);\r
}\r
\r
-void gp2x_text_out8_lim(int x, int y, char *texto, int max)\r
+void gp2x_text_out8_lim(int x, int y, const char *texto, int max)\r
{\r
char buffer[320/8+1];\r
\r
if (max < 0) max = 0;\r
buffer[max] = 0;\r
\r
- gp2x_text(gp2x_screen,x,y,buffer,1);\r
+ gp2x_text(gp2x_screen,x,y,buffer,0xf0);\r
+}\r
+\r
+static void gp2x_smalltext8(int x, int y, const char *texto)\r
+{\r
+ int i;\r
+ unsigned char *src, *dst;\r
+\r
+ for (i = 0;; i++, x += 6)\r
+ {\r
+ unsigned char c = (unsigned char) texto[i];\r
+ int h = 8;\r
+\r
+ if (!c) break;\r
+\r
+ src = fontdata6x8[c];\r
+ dst = (unsigned char *)gp2x_screen + x + y*320;\r
+\r
+ while (h--)\r
+ {\r
+ int w = 0x20;\r
+ while (w)\r
+ {\r
+ if( *src & w ) *dst = 0xf0;\r
+ dst++;\r
+ w>>=1;\r
+ }\r
+ src++;\r
+\r
+ dst += 320-6;\r
+ }\r
+ }\r
+}\r
+\r
+static void gp2x_smalltext8_lim(int x, int y, const char *texto, int max)\r
+{\r
+ char buffer[320/6+1];\r
+\r
+ strncpy(buffer, texto, 320/6);\r
+ if (max > 320/6) max = 320/6;\r
+ if (max < 0) max = 0;\r
+ buffer[max] = 0;\r
+\r
+ gp2x_smalltext8(x, y, buffer);\r
}\r
\r
\r
start = 12 - sel;\r
n--; // exclude current dir (".")\r
\r
- memset(gp2x_screen, 0, 320*240);\r
+ //memset(gp2x_screen, 0, 320*240);\r
+ gp2x_pd_clone_buffer2();\r
\r
if(start - 2 >= 0)\r
- gp2x_text_out8_lim(14, (start - 2)*10, curdir, 38);\r
+ gp2x_smalltext8_lim(14, (start - 2)*10, curdir, 53-2);\r
for (i = 0; i < n; i++) {\r
pos = start + i;\r
if (pos < 0) continue;\r
if (pos > 23) break;\r
if (namelist[i+1]->d_type == DT_DIR) {\r
- gp2x_text_out8_lim(14, pos*10, "/", 1);\r
- gp2x_text_out8_lim(14+8, pos*10, namelist[i+1]->d_name, 37);\r
+ gp2x_smalltext8_lim(14, pos*10, "/", 1);\r
+ gp2x_smalltext8_lim(14+6, pos*10, namelist[i+1]->d_name, 53-3);\r
} else {\r
- gp2x_text_out8_lim(14, pos*10, namelist[i+1]->d_name, 38);\r
+ gp2x_smalltext8_lim(14, pos*10, namelist[i+1]->d_name, 53-2);\r
}\r
}\r
gp2x_text_out8(5, 120, ">");\r
- gp2x_video_flip();\r
+ gp2x_video_flip2();\r
}\r
\r
static int scandir_cmp(const void *p1, const void *p2)\r
}\r
}\r
\r
- memset(gp2x_screen, 0, 320*240);\r
+ //memset(gp2x_screen, 0, 320*240);\r
+ gp2x_pd_clone_buffer2();\r
gp2x_text_out8(60, 40, "Action: %s", actionNames[curr_act]);\r
gp2x_text_out8(60, 60, "Keys: %s", strkeys);\r
\r
gp2x_text_out8(30, 190, "Press a key to bind/unbind");\r
gp2x_text_out8(30, 200, "Select \"Done\" action and");\r
gp2x_text_out8(30, 210, " press any key to finish");\r
- gp2x_video_flip();\r
+ gp2x_video_flip2();\r
}\r
\r
static void key_config_loop(int is_p2)\r
char joyname[36];\r
\r
y = tl_y;\r
- memset(gp2x_screen, 0, 320*240);\r
+ //memset(gp2x_screen, 0, 320*240);\r
+ gp2x_pd_clone_buffer2();\r
gp2x_text_out8(tl_x, y, "Player 1");\r
gp2x_text_out8(tl_x, (y+=10), "Player 2");\r
gp2x_text_out8(tl_x, (y+=10), "Done");\r
}\r
\r
\r
- gp2x_video_flip();\r
+ gp2x_video_flip2();\r
}\r
\r
static void kc_sel_loop(void)\r
int tl_x = 25, tl_y = 60, y;\r
\r
y = tl_y;\r
- memset(gp2x_screen, 0, 320*240);\r
+ //memset(gp2x_screen, 0, 320*240);\r
+ gp2x_pd_clone_buffer2();\r
+\r
gp2x_text_out8(tl_x, y, "USA BIOS: %s", b_us); // 0\r
gp2x_text_out8(tl_x, (y+=10), "EUR BIOS: %s", b_eu); // 1\r
gp2x_text_out8(tl_x, (y+=10), "JAP BIOS: %s", b_jp); // 2\r
gp2x_text_out8(tl_x, (y+=10), "CD LEDs %s", (currentConfig.EmuOpt &0x400)?"ON":"OFF"); // 3\r
- gp2x_text_out8(tl_x, (y+=10), "CDDA audio (using mp3s) %s", (currentConfig.EmuOpt &0x800)?"ON":"OFF"); // 4\r
+ gp2x_text_out8(tl_x, (y+=10), "CDDA audio (using mp3s) %s", (currentConfig.PicoOpt&0x800)?"ON":"OFF"); // 4\r
+ gp2x_text_out8(tl_x, (y+=10), "PCM audio %s", (currentConfig.PicoOpt&0x400)?"ON":"OFF"); // 5\r
gp2x_text_out8(tl_x, (y+=10), "Done");\r
\r
// draw cursor\r
(menu_sel == 2 && strcmp(b_jp, "NOT FOUND")))\r
gp2x_text_out8(tl_x, 220, "Press start to test selected BIOS");\r
\r
- gp2x_video_flip();\r
+ gp2x_video_flip2();\r
}\r
\r
static void cd_menu_loop_options(void)\r
{\r
- int menu_sel = 0, menu_sel_max = 5;\r
+ int menu_sel = 0, menu_sel_max = 6;\r
unsigned long inp = 0;\r
char bios_us[32], bios_eu[32], bios_jp[32], *bios, *p;\r
\r
if((inp& GP2X_B)||(inp&GP2X_LEFT)||(inp&GP2X_RIGHT)) { // toggleable options\r
switch (menu_sel) {\r
case 3: currentConfig.EmuOpt ^=0x400; break;\r
- case 4: currentConfig.EmuOpt ^=0x800; break;\r
- case 5: return;\r
+ case 4: currentConfig.PicoOpt^=0x800; break;\r
+ case 5: currentConfig.PicoOpt^=0x400; break;\r
+ case 6: return;\r
}\r
}\r
if(inp & (GP2X_X|GP2X_A)) return;\r
char *mms = mmuhack_status ? "active) " : "inactive)";\r
\r
y = tl_y;\r
- memset(gp2x_screen, 0, 320*240);\r
+ //memset(gp2x_screen, 0, 320*240);\r
+ gp2x_pd_clone_buffer2();\r
+\r
gp2x_text_out8(tl_x, y, "Scale 32 column mode %s", (currentConfig.PicoOpt&0x100)?"ON":"OFF"); // 0\r
gp2x_text_out8(tl_x, (y+=10), "Gamma correction %i.%02i", currentConfig.gamma / 100, currentConfig.gamma%100); // 1\r
gp2x_text_out8(tl_x, (y+=10), "Emulate Z80 %s", (currentConfig.PicoOpt&0x004)?"ON":"OFF"); // 2\r
// draw cursor\r
gp2x_text_out8(tl_x - 16, tl_y + menu_sel*10, ">");\r
\r
- gp2x_video_flip();\r
+ gp2x_video_flip2();\r
}\r
\r
static void amenu_loop_options(void)\r
}\r
\r
y = tl_y;\r
- memset(gp2x_screen, 0, 320*240);\r
+ //memset(gp2x_screen, 0, 320*240);\r
+ gp2x_pd_clone_buffer2();\r
+\r
gp2x_text_out8(tl_x, y, "Renderer: %s", strrend); // 0\r
gp2x_text_out8(tl_x, (y+=10), "Accurate timing (slower) %s", (currentConfig.PicoOpt&0x040)?"ON":"OFF"); // 1\r
gp2x_text_out8(tl_x, (y+=10), "Accurate sprites (slower) %s", (currentConfig.PicoOpt&0x080)?"ON":"OFF"); // 2\r
// draw cursor\r
gp2x_text_out8(tl_x - 16, tl_y + menu_sel*10, ">");\r
\r
- gp2x_video_flip();\r
+ gp2x_video_flip2();\r
}\r
\r
static int sndrate_prevnext(int rate, int dir)\r
static void draw_menu_credits(void)\r
{\r
int tl_x = 15, tl_y = 70, y;\r
- memset(gp2x_screen, 0, 320*240);\r
+ //memset(gp2x_screen, 0, 320*240);\r
+ gp2x_pd_clone_buffer2();\r
\r
gp2x_text_out8(tl_x, 20, "PicoDrive v" VERSION " (c) notaz, 2006,2007");\r
y = tl_y;\r
gp2x_text_out8(tl_x, (y+=10), "GnoStiC / Puck2099: USB joystick");\r
gp2x_text_out8(tl_x, (y+=10), "craigix: GP2X hardware");\r
\r
- gp2x_video_flip();\r
+ gp2x_video_flip2();\r
}\r
\r
\r
static void draw_menu_root(int menu_sel)\r
{\r
int tl_x = 70, tl_y = 70, y;\r
- memset(gp2x_screen, 0, 320*240);\r
+ //memset(gp2x_screen, 0, 320*240);\r
+ gp2x_pd_clone_buffer2();\r
\r
gp2x_text_out8(tl_x, 20, "PicoDrive v" VERSION);\r
\r
gp2x_text_out8(tl_x - 16, tl_y + menu_sel*10, ">");\r
// error\r
if (menuErrorMsg[0]) gp2x_text_out8(5, 226, menuErrorMsg);\r
- gp2x_video_flip();\r
+ gp2x_video_flip2();\r
}\r
\r
\r
}\r
\r
\r
-void menu_loop(void)\r
+static void menu_gfx_prepare(void)\r
{\r
- int pal[2];\r
+ extern int localPal[0x100];\r
+ int i;\r
+\r
+ // don't clear old palette just for fun (but make it dark)\r
+ for (i = 0x100-1; i >= 0; i--)\r
+ localPal[i] = (localPal[i] >> 2) & 0x003f3f3f;\r
+ localPal[0xe0] = 0x00000000; // reserved pixels for OSD\r
+ localPal[0xf0] = 0x00ffffff;\r
\r
// switch to 8bpp\r
- gp2x_video_changemode(8);\r
+ gp2x_video_changemode2(8);\r
gp2x_video_RGB_setscaling(320, 240);\r
- // set pal\r
- pal[0] = 0;\r
- pal[1] = 0x00ffffff;\r
- gp2x_video_setpalette(pal, 2);\r
+ gp2x_video_setpalette(localPal, 0x100);\r
+ gp2x_video_flip2();\r
+}\r
+\r
+\r
+void menu_loop(void)\r
+{\r
+ menu_gfx_prepare();\r
\r
menu_loop_root();\r
\r