\r
#include <Pico/PicoInt.h>\r
#include <Pico/Patch.h>\r
+#include <Pico/cd/cue.h>\r
#include <zlib/zlib.h>\r
\r
#if defined(__GP2X__)\r
int config_slot = 0, config_slot_current = 0;\r
char lastRomFile[512];\r
int kb_combo_keys = 0, kb_combo_acts = 0; // keys and actions which need button combos\r
+int pico_inp_mode = 0;\r
\r
unsigned char *movie_data = NULL;\r
static int movie_size = 0;\r
{\r
unsigned char buf[32];\r
pm_file *cd_f;\r
- int type = 0, region = 4; // 1: Japan, 4: US, 8: Europe\r
+ int region = 4; // 1: Japan, 4: US, 8: Europe\r
+ char ext[5], *fname = romFileName;\r
+ cue_track_type type = CT_UNKNOWN;\r
+ cue_data_t *cue_data = NULL;\r
+\r
+ get_ext(romFileName, ext);\r
+ if (strcasecmp(ext, ".cue") == 0) {\r
+ cue_data = cue_parse(romFileName);\r
+ if (cue_data != NULL) {\r
+ fname = cue_data->tracks[1].fname;\r
+ type = cue_data->tracks[1].type;\r
+ }\r
+ }\r
+\r
+ cd_f = pm_open(fname);\r
+ if (cue_data != NULL)\r
+ cue_destroy(cue_data);\r
\r
- cd_f = pm_open(romFileName);\r
if (!cd_f) return 0; // let the upper level handle this\r
\r
if (pm_read(buf, 32, cd_f) != 32) {\r
return 0;\r
}\r
\r
- if (!strncasecmp("SEGADISCSYSTEM", (char *)buf+0x00, 14)) type = 1; // Sega CD (ISO)\r
- if (!strncasecmp("SEGADISCSYSTEM", (char *)buf+0x10, 14)) type = 2; // Sega CD (BIN)\r
- if (type == 0) {\r
+ if (!strncasecmp("SEGADISCSYSTEM", (char *)buf+0x00, 14)) {\r
+ if (type && type != CT_ISO)\r
+ elprintf(EL_STATUS, ".cue has wrong type: %i", type);\r
+ type = CT_ISO; // Sega CD (ISO)\r
+ }\r
+ if (!strncasecmp("SEGADISCSYSTEM", (char *)buf+0x10, 14)) {\r
+ if (type && type != CT_BIN)\r
+ elprintf(EL_STATUS, ".cue has wrong type: %i", type);\r
+ type = CT_BIN; // Sega CD (BIN)\r
+ }\r
+\r
+ if (type == CT_UNKNOWN) {\r
pm_close(cd_f);\r
return 0;\r
}\r
\r
- pm_seek(cd_f, (type == 1) ? 0x100 : 0x110, SEEK_SET);\r
+ pm_seek(cd_f, (type == CT_ISO) ? 0x100 : 0x110, SEEK_SET);\r
pm_read(id_header, sizeof(id_header), cd_f);\r
\r
/* it seems we have a CD image here. Try to detect region now.. */\r
- pm_seek(cd_f, (type == 1) ? 0x100+0x10B : 0x110+0x10B, SEEK_SET);\r
+ pm_seek(cd_f, (type == CT_ISO) ? 0x100+0x10B : 0x110+0x10B, SEEK_SET);\r
pm_read(buf, 1, cd_f);\r
pm_close(cd_f);\r
\r
if (buf[0] == 0xa1) region = 1; // JAP\r
\r
lprintf("detected %s Sega/Mega CD image with %s region\n",\r
- type == 2 ? "BIN" : "ISO", region != 4 ? (region == 8 ? "EU" : "JAP") : "USA");\r
+ type == CT_BIN ? "BIN" : "ISO", region != 4 ? (region == 8 ? "EU" : "JAP") : "USA");\r
\r
if (pregion != NULL) *pregion = region;\r
\r
return type;\r
}\r
\r
-static int extract_text(char *dest, unsigned char *src, int len, int swab)\r
+static int extract_text(char *dest, const unsigned char *src, int len, int swab)\r
{\r
char *p = dest;\r
int i;\r
\r
// check for MegaCD image\r
cd_state = emu_cdCheck(&cd_region);\r
- if (cd_state > 0)\r
+ if (cd_state != CIT_NOT_CD)\r
{\r
PicoAHW |= PAHW_MCD;\r
// valid CD image, check for BIOS..\r
return 0;\r
}\r
\r
- Pico.m.frame_count = 0;\r
-\r
// insert CD if it was detected\r
- if (cd_state > 0) {\r
- ret = Insert_CD(romFileName, cd_state == 2);\r
+ if (cd_state != CIT_NOT_CD) {\r
+ ret = Insert_CD(romFileName, cd_state);\r
if (ret != 0) {\r
sprintf(menuErrorMsg, "Insert_CD() failed, invalid CD image?");\r
lprintf("%s\n", menuErrorMsg);\r
if(movie_data[0x14] == '6')\r
PicoOpt |= POPT_6BTN_PAD; // 6 button pad\r
else PicoOpt &= ~POPT_6BTN_PAD;\r
- PicoOpt |= POPT_DIS_VDP_FIFO|POPT_ACC_TIMING; // accurate timing, no VDP fifo timing\r
+ PicoOpt |= POPT_DIS_VDP_FIFO; // no VDP fifo timing\r
if(movie_data[0xF] >= 'A') {\r
if(movie_data[0x16] & 0x80) {\r
PicoRegionOverride = 8;\r
if (currentConfig.CPUclock < 10 || currentConfig.CPUclock > 4096) currentConfig.CPUclock = 200;\r
#ifdef PSP\r
if (currentConfig.gamma < -4 || currentConfig.gamma > 16) currentConfig.gamma = 0;\r
+ if (currentConfig.gamma2 < 0 || currentConfig.gamma2 > 2) currentConfig.gamma2 = 0;\r
#else\r
if (currentConfig.gamma < 10 || currentConfig.gamma > 300) currentConfig.gamma = 100;\r
#endif\r
}\r
}\r
\r
+#ifdef PSP\r
+#define MAX_COMBO_KEY 23\r
+#else\r
+#define MAX_COMBO_KEY 31\r
+#endif\r
+\r
void emu_findKeyBindCombos(void)\r
{\r
int act, u;\r
if (act == 16 || act == 17) continue; // player2 flag\r
if (act > 17)\r
{\r
- for (u = 0; u < 32; u++)\r
+ for (u = 0; u <= MAX_COMBO_KEY; u++)\r
if (currentConfig.KeyBinds[u] & (1 << act)) keyc++;\r
}\r
else\r
{\r
- for (u = 0; u < 32; u++)\r
+ for (u = 0; u <= MAX_COMBO_KEY; u++)\r
if ((currentConfig.KeyBinds[u] & 0x30000) == 0 && // pl. 1\r
(currentConfig.KeyBinds[u] & (1 << act))) keyc++;\r
- for (u = 0; u < 32; u++)\r
+ for (u = 0; u <= MAX_COMBO_KEY; u++)\r
if ((currentConfig.KeyBinds[u] & 0x30000) == 1 && // pl. 2\r
(currentConfig.KeyBinds[u] & (1 << act))) keyc2++;\r
if (keyc2 > keyc) keyc = keyc2;\r
if (keyc > 1)\r
{\r
// loop again and mark those keys and actions as combo\r
- for (u = 0; u < 32; u++)\r
+ for (u = 0; u <= MAX_COMBO_KEY; u++)\r
{\r
if (currentConfig.KeyBinds[u] & (1 << act)) {\r
kb_combo_keys |= 1 << u;\r
}\r
else ret = -1;\r
if (!ret)\r
- strcpy(noticeMsg, load ? "GAME LOADED " : "GAME SAVED ");\r
+ strcpy(noticeMsg, load ? "GAME LOADED " : "GAME SAVED ");\r
else\r
{\r
- strcpy(noticeMsg, load ? "LOAD FAILED " : "SAVE FAILED ");\r
+ strcpy(noticeMsg, load ? "LOAD FAILED " : "SAVE FAILED ");\r
ret = -1;\r
}\r
\r
}\r
}\r
\r
+void emu_changeFastForward(int set_on)\r
+{\r
+ static void *set_PsndOut = NULL;\r
+ static int set_Frameskip, set_EmuOpt, is_on = 0;\r
+\r
+ if (set_on && !is_on) {\r
+ set_PsndOut = PsndOut;\r
+ set_Frameskip = currentConfig.Frameskip;\r
+ set_EmuOpt = currentConfig.EmuOpt;\r
+ PsndOut = NULL;\r
+ currentConfig.Frameskip = 8;\r
+ currentConfig.EmuOpt &= ~4;\r
+ currentConfig.EmuOpt |= 0x40000;\r
+ is_on = 1;\r
+ strcpy(noticeMsg, "FAST FORWARD ");\r
+ emu_noticeMsgUpdated();\r
+ }\r
+ else if (!set_on && is_on) {\r
+ PsndOut = set_PsndOut;\r
+ currentConfig.Frameskip = set_Frameskip;\r
+ currentConfig.EmuOpt = set_EmuOpt;\r
+ PsndRerate(1);\r
+ is_on = 0;\r
+ }\r
+}\r
+\r
+void emu_RunEventsPico(unsigned int events)\r
+{\r
+ if (events & (1 << 3)) {\r
+ pico_inp_mode++;\r
+ if (pico_inp_mode > 2) pico_inp_mode = 0;\r
+ switch (pico_inp_mode) {\r
+ case 2: strcpy(noticeMsg, "Input: Pen on Pad "); break;\r
+ case 1: strcpy(noticeMsg, "Input: Pen on Storyware"); break;\r
+ case 0: strcpy(noticeMsg, "Input: Joytick ");\r
+ PicoPicohw.pen_pos[0] = PicoPicohw.pen_pos[1] = 0x8000;\r
+ break;\r
+ }\r
+ emu_noticeMsgUpdated();\r
+ }\r
+ if (events & (1 << 4)) {\r
+ PicoPicohw.page--;\r
+ if (PicoPicohw.page < 0) PicoPicohw.page = 0;\r
+ sprintf(noticeMsg, "Page %i ", PicoPicohw.page);\r
+ emu_noticeMsgUpdated();\r
+ }\r
+ if (events & (1 << 5)) {\r
+ PicoPicohw.page++;\r
+ if (PicoPicohw.page > 6) PicoPicohw.page = 6;\r
+ sprintf(noticeMsg, "Page %i ", PicoPicohw.page);\r
+ emu_noticeMsgUpdated();\r
+ }\r
+}\r
+\r
+void emu_DoTurbo(int *pad, int acts)\r
+{\r
+ static int turbo_pad = 0;\r
+ static unsigned char turbo_cnt[3] = { 0, 0, 0 };\r
+ int inc = currentConfig.turbo_rate * 2;\r
+\r
+ if (acts & 0x1000) {\r
+ turbo_cnt[0] += inc;\r
+ if (turbo_cnt[0] >= 60)\r
+ turbo_pad ^= 0x10, turbo_cnt[0] = 0;\r
+ }\r
+ if (acts & 0x2000) {\r
+ turbo_cnt[1] += inc;\r
+ if (turbo_cnt[1] >= 60)\r
+ turbo_pad ^= 0x20, turbo_cnt[1] = 0;\r
+ }\r
+ if (acts & 0x4000) {\r
+ turbo_cnt[2] += inc;\r
+ if (turbo_cnt[2] >= 60)\r
+ turbo_pad ^= 0x40, turbo_cnt[2] = 0;\r
+ }\r
+ *pad |= turbo_pad & (acts >> 8);\r
+}\r
+\r