#include "menu.h"\r
#include "asmutils.h"\r
#include "cpuctrl.h"\r
+#include "fonts.h"\r
\r
#include <Pico/PicoInt.h>\r
#include <Pico/Patch.h>\r
#define OSD_FPS_X 260\r
#endif\r
\r
-// PicoPad[] format: SACB RLDU\r
-char *actionNames[] = {\r
- "UP", "DOWN", "LEFT", "RIGHT", "B", "C", "A", "START",\r
- 0, 0, 0, 0, 0, 0, 0, 0, // Z, Y, X, MODE (enabled only when needed), ?, ?, ?, ?\r
- 0, 0, 0, 0, 0, 0, 0, "ENTER MENU", // player2_flag, ?, ?, ?, ?, ?, ?, menu\r
- "NEXT SAVE SLOT", "PREV SAVE SLOT", "SWITCH RENDERER", "SAVE STATE",\r
- "LOAD STATE", "VOLUME UP", "VOLUME DOWN", "DONE"\r
-};\r
\r
int engineState;\r
int select_exits = 0;\r
unsigned char *framebuff = 0; // temporary buffer for alt renderer\r
int state_slot = 0;\r
int reset_timing = 0;\r
+int config_slot = 0, config_slot_current = 0;\r
\r
\r
// utilities\r
return 0;\r
}\r
\r
+ menu_romload_prepare(used_rom_name);\r
+\r
if(rom_data) {\r
free(rom_data);\r
rom_data = 0;\r
sprintf(menuErrorMsg, "PicoCartLoad() failed.");\r
printf("%s\n", menuErrorMsg);\r
pm_close(rom);\r
+ menu_romload_end();\r
return 0;\r
}\r
pm_close(rom);\r
+ menu_romload_end();\r
\r
// detect wrong files (Pico crashes on very small files), also see if ROM EP is good\r
if(rom_size <= 0x200 || strncmp((char *)rom_data, "Pico", 4) == 0 ||\r
}\r
\r
// load config for this ROM (do this before insert to get correct region)\r
- ret = emu_ReadConfig(1);\r
+ ret = emu_ReadConfig(1, 1);\r
if (!ret)\r
- emu_ReadConfig(0);\r
+ emu_ReadConfig(0, 1);\r
\r
printf("PicoCartInsert(%p, %d);\n", rom_data, rom_size);\r
if(PicoCartInsert(rom_data, rom_size)) {\r
}\r
\r
\r
-int emu_ReadConfig(int game)\r
+int emu_ReadConfig(int game, int no_defaults)\r
{\r
FILE *f;\r
- char cfg[512];\r
+ char cfg[512], extbuf[16];\r
int bread = 0;\r
\r
if (!game)\r
{\r
- // set default config\r
- memset(¤tConfig, 0, sizeof(currentConfig));\r
- currentConfig.lastRomFile[0] = 0;\r
- currentConfig.EmuOpt = 0x1f | 0x600; // | confirm_save, cd_leds\r
- currentConfig.PicoOpt = 0x0f | 0xe00; // | use_940, cd_pcm, cd_cdda\r
- currentConfig.PsndRate = 22050; // 44100;\r
- currentConfig.PicoRegion = 0; // auto\r
- currentConfig.PicoAutoRgnOrder = 0x184; // US, EU, JP\r
- currentConfig.Frameskip = -1; // auto\r
- currentConfig.CPUclock = 200;\r
- currentConfig.volume = 50;\r
- currentConfig.KeyBinds[ 0] = 1<<0; // SACB RLDU\r
- currentConfig.KeyBinds[ 4] = 1<<1;\r
- currentConfig.KeyBinds[ 2] = 1<<2;\r
- currentConfig.KeyBinds[ 6] = 1<<3;\r
- currentConfig.KeyBinds[14] = 1<<4;\r
- currentConfig.KeyBinds[13] = 1<<5;\r
- currentConfig.KeyBinds[12] = 1<<6;\r
- currentConfig.KeyBinds[ 8] = 1<<7;\r
- currentConfig.KeyBinds[15] = 1<<26; // switch rend\r
- currentConfig.KeyBinds[10] = 1<<27; // save state\r
- currentConfig.KeyBinds[11] = 1<<28; // load state\r
- currentConfig.KeyBinds[23] = 1<<29; // vol up\r
- currentConfig.KeyBinds[22] = 1<<30; // vol down\r
- currentConfig.gamma = 100;\r
- currentConfig.PicoCDBuffers = 64;\r
- currentConfig.scaling = 0;\r
+ if (!no_defaults)\r
+ {\r
+ // set default config\r
+ memset(¤tConfig, 0, sizeof(currentConfig));\r
+ currentConfig.lastRomFile[0] = 0;\r
+ currentConfig.EmuOpt = 0x1f | 0x600; // | confirm_save, cd_leds\r
+ currentConfig.PicoOpt = 0x0f | 0xe00; // | use_940, cd_pcm, cd_cdda\r
+ currentConfig.PsndRate = 22050; // 44100;\r
+ currentConfig.PicoRegion = 0; // auto\r
+ currentConfig.PicoAutoRgnOrder = 0x184; // US, EU, JP\r
+ currentConfig.Frameskip = -1; // auto\r
+ currentConfig.CPUclock = 200;\r
+ currentConfig.volume = 50;\r
+ currentConfig.KeyBinds[ 0] = 1<<0; // SACB RLDU\r
+ currentConfig.KeyBinds[ 4] = 1<<1;\r
+ currentConfig.KeyBinds[ 2] = 1<<2;\r
+ currentConfig.KeyBinds[ 6] = 1<<3;\r
+ currentConfig.KeyBinds[14] = 1<<4;\r
+ currentConfig.KeyBinds[13] = 1<<5;\r
+ currentConfig.KeyBinds[12] = 1<<6;\r
+ currentConfig.KeyBinds[ 8] = 1<<7;\r
+ currentConfig.KeyBinds[15] = 1<<26; // switch rend\r
+ currentConfig.KeyBinds[10] = 1<<27; // save state\r
+ currentConfig.KeyBinds[11] = 1<<28; // load state\r
+ currentConfig.KeyBinds[23] = 1<<29; // vol up\r
+ currentConfig.KeyBinds[22] = 1<<30; // vol down\r
+ currentConfig.gamma = 100;\r
+ currentConfig.PicoCDBuffers = 64;\r
+ currentConfig.scaling = 0;\r
+ }\r
strncpy(cfg, PicoConfigFile, 511);\r
+ if (config_slot != 0)\r
+ {\r
+ char *p = strrchr(cfg, '.');\r
+ if (p == NULL) p = cfg + strlen(cfg);\r
+ sprintf(extbuf, ".%i.pbcfg", config_slot);\r
+ strncpy(p, extbuf, 511 - (p - cfg));\r
+ }\r
cfg[511] = 0;\r
} else {\r
- romfname_ext(cfg, "cfg/", ".pbcfg");\r
+ if (config_slot != 0)\r
+ sprintf(extbuf, ".%i.pbcfg", config_slot);\r
+ else strcpy(extbuf, ".pbcfg");\r
+ romfname_ext(cfg, "cfg/", extbuf);\r
f = fopen(cfg, "rb");\r
if (!f) romfname_ext(cfg, NULL, ".pbcfg");\r
else fclose(f);\r
PicoRegionOverride = currentConfig.PicoRegion;\r
PicoAutoRgnOrder = currentConfig.PicoAutoRgnOrder;\r
PicoCDBuffers = currentConfig.PicoCDBuffers;\r
- if (PicoOpt & 0x20) {\r
- actionNames[ 8] = "Z"; actionNames[ 9] = "Y";\r
- actionNames[10] = "X"; actionNames[11] = "MODE";\r
- }\r
scaling_update();\r
// some sanity checks\r
if (currentConfig.CPUclock < 10 || currentConfig.CPUclock > 4096) currentConfig.CPUclock = 200;\r
currentConfig.KeyBinds[22] = 1<<30; // vol down\r
}\r
\r
+ if (bread > 0) config_slot_current = config_slot;\r
return (bread > 0); // == sizeof(currentConfig));\r
}\r
\r
int emu_WriteConfig(int game)\r
{\r
FILE *f;\r
- char cfg[512];\r
+ char cfg[512], extbuf[16];\r
int bwrite = 0;\r
\r
if (!game)\r
{\r
strncpy(cfg, PicoConfigFile, 511);\r
+ if (config_slot != 0)\r
+ {\r
+ char *p = strrchr(cfg, '.');\r
+ if (p == NULL) p = cfg + strlen(cfg);\r
+ sprintf(extbuf, ".%i.pbcfg", config_slot);\r
+ strncpy(p, extbuf, 511 - (p - cfg));\r
+ }\r
cfg[511] = 0;\r
} else {\r
- romfname_ext(cfg, "cfg/", ".pbcfg");\r
+ if (config_slot != 0)\r
+ sprintf(extbuf, ".%i.pbcfg", config_slot);\r
+ else strcpy(extbuf, ".pbcfg");\r
+ romfname_ext(cfg, "cfg/", extbuf);\r
}\r
\r
printf("emu_WriteConfig: %s ", cfg);\r
}\r
printf((bwrite == sizeof(currentConfig)) ? "(ok)\n" : "(failed)\n");\r
\r
+ if (bwrite == sizeof(currentConfig)) config_slot_current = config_slot;\r
return (bwrite == sizeof(currentConfig));\r
}\r
\r
set_gamma(100, 0);\r
}\r
\r
+static void text_out8_builtin(int x, int y, const char *text)\r
+{\r
+ int i,l,len=strlen(text);\r
+ unsigned char *screen = (unsigned char *)gp2x_screen + x + y*320;\r
+\r
+ /* always using built-in font */\r
+ for (i = 0; i < len; i++)\r
+ {\r
+ for (l=0;l<8;l++)\r
+ {\r
+ unsigned char fd = fontdata8x8[((text[i])*8)+l];\r
+ if (fd&0x80) screen[l*320+0]=0xf0;\r
+ if (fd&0x40) screen[l*320+1]=0xf0;\r
+ if (fd&0x20) screen[l*320+2]=0xf0;\r
+ if (fd&0x10) screen[l*320+3]=0xf0;\r
+ if (fd&0x08) screen[l*320+4]=0xf0;\r
+ if (fd&0x04) screen[l*320+5]=0xf0;\r
+ if (fd&0x02) screen[l*320+6]=0xf0;\r
+ if (fd&0x01) screen[l*320+7]=0xf0;\r
+ }\r
+ screen += 8;\r
+ }\r
+}\r
+\r
+static void text_out16_builtin(int x, int y, const char *text)\r
+{\r
+ int i,l,len=strlen(text);\r
+ unsigned short *screen = (unsigned short *)gp2x_screen + x + y*320;\r
+\r
+ for (i = 0; i < len; i++)\r
+ {\r
+ for (l=0;l<8;l++)\r
+ {\r
+ unsigned char fd = fontdata8x8[((text[i])*8)+l];\r
+ if(fd&0x80) screen[l*320+0]=0xffff;\r
+ if(fd&0x40) screen[l*320+1]=0xffff;\r
+ if(fd&0x20) screen[l*320+2]=0xffff;\r
+ if(fd&0x10) screen[l*320+3]=0xffff;\r
+ if(fd&0x08) screen[l*320+4]=0xffff;\r
+ if(fd&0x04) screen[l*320+5]=0xffff;\r
+ if(fd&0x02) screen[l*320+6]=0xffff;\r
+ if(fd&0x01) screen[l*320+7]=0xffff;\r
+ }\r
+ screen += 8;\r
+ }\r
+}\r
+\r
\r
void osd_text(int x, int y, const char *text)\r
{\r
p = (int *) ((unsigned char *) gp2x_screen+x+320*(y+h));\r
for (i = len; i; i--, p++) *p = 0xe0e0e0e0;\r
}\r
- gp2x_text_out8_2(x, y, text, 0xf0);\r
+ text_out8_builtin(x, y, text);\r
} else {\r
int *p, i, h;\r
x &= ~1; // align x\r
p = (int *) ((unsigned short *) gp2x_screen+x+320*(y+h));\r
for (i = len; i; i--, p++) *p = (*p>>2)&0x39e7;\r
}\r
- gp2x_text_out15(x, y, text);\r
+ text_out16_builtin(x, y, text);\r
}\r
}\r
\r
if (PicoOpt&0x10) {\r
gp2x_video_changemode(8);\r
} else if (currentConfig.EmuOpt&0x80) {\r
- gp2x_video_changemode(15);\r
+ gp2x_video_changemode(16);\r
PicoDrawSetColorFormat(1);\r
PicoScan = EmuScan16;\r
PicoScan(0, 0);\r
void emu_forced_frame(void)\r
{\r
int po_old = PicoOpt;\r
+ int eo_old = currentConfig.EmuOpt;\r
\r
- PicoOpt |= 0x10;\r
- PicoFrameFull();\r
+ PicoOpt &= ~0x0010;\r
+ PicoOpt |= 0x4080; // soft_scale | acc_sprites\r
+ currentConfig.EmuOpt |= 0x80;\r
\r
+ //vidResetMode();\r
+ PicoDrawSetColorFormat(1);\r
+ PicoScan = EmuScan16;\r
+ PicoScan(0, 0);\r
+ Pico.m.dirtyPal = 1;\r
+ PicoFrameDrawOnly();\r
+\r
+/*\r
if (!(Pico.video.reg[12]&1)) {\r
vidCpyM2 = vidCpyM2_32col;\r
clearArea(1);\r
vidCpyM2((unsigned char *)gp2x_screen+320*8, framebuff+328*8);\r
vidConvCpyRGB32(localPal, Pico.cram, 0x40);\r
gp2x_video_setpalette(localPal, 0x40);\r
-\r
+*/\r
PicoOpt = po_old;\r
+ currentConfig.EmuOpt = eo_old;\r
}\r
\r
static void simpleWait(int thissec, int lim_time)\r
SRam.changed = 0;\r
}\r
\r
- // if in 16bit mode, generate 8it image for menu background\r
- if (!(PicoOpt&0x10) && (currentConfig.EmuOpt&0x80))\r
+ // if in 8bit mode, generate 16bit image for menu background\r
+ if ((PicoOpt&0x10) || !(currentConfig.EmuOpt&0x80))\r
emu_forced_frame();\r
-\r
- // for menu bg\r
- gp2x_memcpy_buffers((1<<2), gp2x_screen, 0, 320*240*2);\r
}\r
\r
\r