unsigned char *PicoDraw2FB = NULL; // temporary buffer for alt renderer\r
int reset_timing = 0;\r
\r
+#define PICO_PEN_ADJUST_X 4\r
+#define PICO_PEN_ADJUST_Y 2\r
+static int pico_pen_x = 320/2, pico_pen_y = 240/2;\r
+\r
static void emu_msg_cb(const char *msg);\r
static void emu_msg_tray_open(void);\r
\r
void emu_prepareDefaultConfig(void)\r
{\r
memset(&defaultConfig, 0, sizeof(defaultConfig));\r
- defaultConfig.EmuOpt = 0x1d | 0x00700; // | <- ram_tmng, confirm_save, cd_leds\r
- defaultConfig.s_PicoOpt = 0x0f | 0x20e00; // | <- use_940, cd_pcm, cd_cdda, svp drc\r
+ defaultConfig.EmuOpt = 0x9d | 0x00700; // | <- ram_tmng, confirm_save, cd_leds\r
+ defaultConfig.s_PicoOpt = 0x0f | POPT_EXT_FM|POPT_EN_MCD_PCM|POPT_EN_MCD_CDDA|POPT_EN_SVP_DRC|POPT_ACC_SPRITES;\r
defaultConfig.s_PsndRate = 44100;\r
defaultConfig.s_PicoRegion = 0; // auto\r
defaultConfig.s_PicoAutoRgnOrder = 0x184; // US, EU, JP\r
defaultConfig.KeyBinds[22] = 1<<30; // vol down\r
defaultConfig.gamma = 100;\r
defaultConfig.scaling = 0;\r
+ defaultConfig.turbo_rate = 15;\r
}\r
\r
void emu_setDefaultConfig(void)\r
}\r
}\r
\r
-static void cd_leds(void)\r
+static void draw_cd_leds(void)\r
{\r
// static\r
int old_reg;\r
}\r
}\r
\r
+static void draw_pico_ptr(void)\r
+{\r
+ unsigned short *p = (unsigned short *)gp2x_screen;\r
+\r
+ // only if pen enabled and for 16bit modes\r
+ if (pico_inp_mode == 0 || (PicoOpt&0x10) || !(currentConfig.EmuOpt&0x80)) return;\r
+\r
+ if (!(Pico.video.reg[12]&1) && !(PicoOpt&POPT_DIS_32C_BORDER))\r
+ p += 32;\r
+\r
+ p += 320 * (pico_pen_y + PICO_PEN_ADJUST_Y);\r
+ p += pico_pen_x + PICO_PEN_ADJUST_X;\r
+ p[0] ^= 0xffff;\r
+ p[319] ^= 0xffff;\r
+ p[320] ^= 0xffff;\r
+ p[321] ^= 0xffff;\r
+ p[640] ^= 0xffff;\r
+}\r
+\r
static int EmuScanBegin16(unsigned int num)\r
{\r
if (!(Pico.video.reg[1]&8)) num += 8;\r
// 8bit accurate renderer\r
if (Pico.m.dirtyPal)\r
{\r
+ int pallen = 0x40;\r
Pico.m.dirtyPal = 0;\r
- if(Pico.video.reg[0xC]&8) { // shadow/hilight mode\r
+ if (Pico.video.reg[0xC]&8) // shadow/hilight mode\r
+ {\r
vidConvCpyRGB32(localPal, Pico.cram, 0x40);\r
vidConvCpyRGB32sh(localPal+0x40, Pico.cram, 0x40);\r
vidConvCpyRGB32hi(localPal+0x80, Pico.cram, 0x40);\r
memcpy32(localPal+0xc0, localPal+0x40, 0x40);\r
- localPal[0xc0] = 0x0000c000;\r
- localPal[0xd0] = 0x00c00000;\r
- localPal[0xe0] = 0x00000000; // reserved pixels for OSD\r
- localPal[0xf0] = 0x00ffffff;\r
- gp2x_video_setpalette(localPal, 0x100);\r
- } else if (rendstatus & PDRAW_SONIC_MODE) { // mid-frame palette changes\r
+ pallen = 0x100;\r
+ }\r
+ else if (rendstatus & PDRAW_ACC_SPRITES) {\r
+ vidConvCpyRGB32(localPal, Pico.cram, 0x40);\r
+ memcpy32(localPal+0x40, localPal, 0x40);\r
+ memcpy32(localPal+0x80, localPal, 0x40);\r
+ memcpy32(localPal+0xc0, localPal, 0x40);\r
+ pallen = 0x100;\r
+ }\r
+ else if (rendstatus & PDRAW_SONIC_MODE) { // mid-frame palette changes\r
vidConvCpyRGB32(localPal, Pico.cram, 0x40);\r
vidConvCpyRGB32(localPal+0x40, HighPal, 0x40);\r
vidConvCpyRGB32(localPal+0x80, HighPal+0x40, 0x40);\r
- gp2x_video_setpalette(localPal, 0xc0);\r
- } else {\r
+ pallen = 0xc0;\r
+ }\r
+ else {\r
vidConvCpyRGB32(localPal, Pico.cram, 0x40);\r
- gp2x_video_setpalette(localPal, 0x40);\r
}\r
+ if (pallen > 0xc0) {\r
+ localPal[0xc0] = 0x0000c000;\r
+ localPal[0xd0] = 0x00c00000;\r
+ localPal[0xe0] = 0x00000000; // reserved pixels for OSD\r
+ localPal[0xf0] = 0x00ffffff;\r
+ }\r
+ gp2x_video_setpalette(localPal, pallen);\r
}\r
}\r
\r
osd_text(osd_fps_x, h, fps);\r
}\r
if ((emu_opt & 0x400) && (PicoAHW & PAHW_MCD))\r
- cd_leds();\r
+ draw_cd_leds();\r
+ if (PicoAHW & PAHW_PICO)\r
+ draw_pico_ptr();\r
\r
//gp2x_video_wait_vsync();\r
gp2x_video_flip();\r
gettimeofday(¬iceMsgTime, 0);\r
}\r
\r
+static void RunEventsPico(unsigned int events, unsigned int gp2x_keys)\r
+{\r
+ int ret, px, py, lim_x;\r
+ static int pdown_frames = 0;\r
+\r
+ emu_RunEventsPico(events);\r
+\r
+ if (pico_inp_mode == 0) return;\r
+\r
+ // for F200\r
+ ret = gp2x_touchpad_read(&px, &py);\r
+ if (ret >= 0)\r
+ {\r
+ if (ret > 35000)\r
+ {\r
+ if (pdown_frames++ > 5)\r
+ PicoPad[0] |= 0x20;\r
+\r
+ pico_pen_x = px;\r
+ pico_pen_y = py;\r
+ if (!(Pico.video.reg[12]&1)) {\r
+ pico_pen_x -= 32;\r
+ if (pico_pen_x < 0) pico_pen_x = 0;\r
+ if (pico_pen_x > 248) pico_pen_x = 248;\r
+ }\r
+ if (pico_pen_y > 224) pico_pen_y = 224;\r
+ }\r
+ else\r
+ pdown_frames = 0;\r
+\r
+ //if (ret == 0)\r
+ // PicoPicohw.pen_pos[0] = PicoPicohw.pen_pos[1] = 0x8000;\r
+ }\r
+\r
+ PicoPad[0] &= ~0x0f; // release UDLR\r
+ if (gp2x_keys & GP2X_UP) pico_pen_y--;\r
+ if (gp2x_keys & GP2X_DOWN) pico_pen_y++;\r
+ if (gp2x_keys & GP2X_LEFT) pico_pen_x--;\r
+ if (gp2x_keys & GP2X_RIGHT) pico_pen_x++;\r
+\r
+ lim_x = (Pico.video.reg[12]&1) ? 319 : 255;\r
+ if (pico_pen_y < 8) pico_pen_y = 8;\r
+ if (pico_pen_y > 224-PICO_PEN_ADJUST_Y) pico_pen_y = 224-PICO_PEN_ADJUST_Y;\r
+ if (pico_pen_x < 0) pico_pen_x = 0;\r
+ if (pico_pen_x > lim_x-PICO_PEN_ADJUST_X) pico_pen_x = lim_x-PICO_PEN_ADJUST_X;\r
+\r
+ PicoPicohw.pen_pos[0] = pico_pen_x;\r
+ if (!(Pico.video.reg[12]&1)) PicoPicohw.pen_pos[0] += pico_pen_x/4;\r
+ PicoPicohw.pen_pos[0] += 0x3c;\r
+ PicoPicohw.pen_pos[1] = pico_inp_mode == 1 ? (0x2f8 + pico_pen_y) : (0x1fc + pico_pen_y);\r
+}\r
+\r
static void update_volume(int has_changed, int is_up)\r
{\r
static int prev_frame = 0, wait_frames = 0;\r
}\r
}\r
\r
-static void change_fast_forward(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
- is_on = 1;\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
- update_volume(0, 0);\r
- reset_timing = 1;\r
- is_on = 0;\r
- }\r
-}\r
-\r
static void RunEvents(unsigned int which)\r
{\r
if (which & 0x1800) // save or load (but not both)\r
}\r
}\r
\r
-\r
static void updateKeys(void)\r
{\r
- unsigned long keys, allActions[2] = { 0, 0 }, events;\r
- static unsigned long prevEvents = 0;\r
+ unsigned int keys, keys2, allActions[2] = { 0, 0 }, events;\r
+ static unsigned int prevEvents = 0;\r
int joy, i;\r
\r
keys = gp2x_joystick_read(0);\r
}\r
\r
keys &= CONFIGURABLE_KEYS;\r
+ keys2 = keys;\r
\r
for (i = 0; i < 32; i++)\r
{\r
- if (keys & (1 << i))\r
+ if (keys2 & (1 << i))\r
{\r
int pl, acts = currentConfig.KeyBinds[i];\r
if (!acts) continue;\r
// let's try to find the other one\r
if (acts_c) {\r
for (; u < 32; u++)\r
- if ( (keys & (1 << u)) && (currentConfig.KeyBinds[u] & acts_c) ) {\r
+ if ( (keys2 & (1 << u)) && (currentConfig.KeyBinds[u] & acts_c) ) {\r
allActions[pl] |= acts_c & currentConfig.KeyBinds[u];\r
- keys &= ~((1 << i) | (1 << u));\r
+ keys2 &= ~((1 << i) | (1 << u));\r
break;\r
}\r
}\r
{\r
gp2x_usbjoy_update();\r
for (joy = 0; joy < num_of_joys; joy++) {\r
- int keys = gp2x_usbjoy_check2(joy);\r
+ int btns = gp2x_usbjoy_check2(joy);\r
for (i = 0; i < 32; i++) {\r
- if (keys & (1 << i)) {\r
+ if (btns & (1 << i)) {\r
int acts = currentConfig.JoyBinds[joy][i];\r
int pl = (acts >> 16) & 1;\r
allActions[pl] |= acts;\r
}\r
}\r
\r
- PicoPad[0] = (unsigned short) allActions[0];\r
- PicoPad[1] = (unsigned short) allActions[1];\r
+ PicoPad[0] = allActions[0] & 0xfff;\r
+ PicoPad[1] = allActions[1] & 0xfff;\r
+\r
+ if (allActions[0] & 0x7000) emu_DoTurbo(&PicoPad[0], allActions[0]);\r
+ if (allActions[1] & 0x7000) emu_DoTurbo(&PicoPad[1], allActions[1]);\r
\r
events = (allActions[0] | allActions[1]) >> 16;\r
\r
if (events & 0x6000)\r
update_volume(1, events & 0x2000);\r
\r
- if ((events ^ prevEvents) & 0x40)\r
- change_fast_forward(events & 0x40);\r
+ if ((events ^ prevEvents) & 0x40) {\r
+ emu_changeFastForward(events & 0x40);\r
+ update_volume(0, 0);\r
+ reset_timing = 1;\r
+ }\r
\r
events &= ~prevEvents;\r
+\r
+ if (PicoAHW == PAHW_PICO)\r
+ RunEventsPico(events, keys);\r
if (events) RunEvents(events);\r
if (movie_data) emu_updateMovie();\r
\r
}\r
\r
\r
-void emu_forcedFrame(void)\r
+void emu_forcedFrame(int opts)\r
{\r
int po_old = PicoOpt;\r
int eo_old = currentConfig.EmuOpt;\r
\r
- PicoOpt &= ~0x0010;\r
- PicoOpt |= 0x4080; // soft_scale | acc_sprites\r
+ PicoOpt &= ~0x10;\r
+ PicoOpt |= opts|POPT_ACC_SPRITES; // acc_sprites\r
currentConfig.EmuOpt |= 0x80;\r
\r
//vidResetMode();\r
frames_done++; frames_shown++;\r
}\r
\r
- change_fast_forward(0);\r
+ emu_changeFastForward(0);\r
\r
if (PicoAHW & PAHW_MCD) PicoCDBufferFree();\r
\r
\r
// if in 8bit mode, generate 16bit image for menu background\r
if ((PicoOpt&0x10) || !(currentConfig.EmuOpt&0x80))\r
- emu_forcedFrame();\r
+ emu_forcedFrame(POPT_EN_SOFTSCALE);\r
}\r
\r
\r