void emu_Loop(void)\r
{\r
static int gp2x_old_clock = 200;\r
- static int PsndRate_old = 0, PicoOpt_old = 0, PsndLen_real = 0, pal_old = 0;\r
+ static int PsndRate_old = 0, PicoOpt_old = 0, EmuOpt_old = 0, PsndLen_real = 0, pal_old = 0;\r
char fpsbuff[24]; // fps count c string\r
struct timeval tval; // timing\r
int thissec = 0, frames_done = 0, frames_shown = 0, oldmodes = 0;\r
- int target_fps, target_frametime, lim_time, i;\r
+ int target_fps, target_frametime, lim_time, vsync_offset, i;\r
char *notice = 0;\r
\r
printf("entered emu_Loop()\n");\r
printf("updated gamma to %i\n", currentConfig.gamma);\r
}\r
\r
+ if ((EmuOpt_old&0x2000) != (currentConfig.EmuOpt&0x2000)) {\r
+ if (currentConfig.EmuOpt&0x2000)\r
+ set_LCD_custom_rate(Pico.m.pal ? LCDR_100 : LCDR_120);\r
+ else unset_LCD_custom_rate();\r
+ }\r
+\r
+ EmuOpt_old = currentConfig.EmuOpt;\r
fpsbuff[0] = 0;\r
\r
// make sure we are in correct mode\r
// prepare CD buffer\r
if (PicoMCD & 1) PicoCDBufferInit();\r
\r
+ // calc vsync offset to sync timing code with vsync\r
+ if (currentConfig.EmuOpt&0x2000) {\r
+ gettimeofday(&tval, 0);\r
+ gp2x_video_wait_vsync();\r
+ gettimeofday(&tval, 0);\r
+ vsync_offset = tval.tv_usec;\r
+ while (vsync_offset >= target_frametime)\r
+ vsync_offset -= target_frametime;\r
+ if (!vsync_offset) vsync_offset++;\r
+ printf("vsync_offset: %i\n", vsync_offset);\r
+ } else\r
+ vsync_offset = 0;\r
+\r
// loop?\r
while (engineState == PGS_Running)\r
{\r
if (frames_shown > frames_done) frames_shown = frames_done;\r
}\r
}\r
-#if 0\r
- sprintf(fpsbuff, "%05i", Pico.m.frame_count);\r
-#endif\r
- lim_time = (frames_done+1) * target_frametime;\r
+\r
+ lim_time = (frames_done+1) * target_frametime + vsync_offset;\r
if(currentConfig.Frameskip >= 0) { // frameskip enabled\r
for(i = 0; i < currentConfig.Frameskip; i++) {\r
updateKeys();\r
reset_timing = 1;\r
else if (PsndOut != NULL || currentConfig.Frameskip < 0)\r
{\r
- // sleep if we are still too fast\r
+ // sleep or vsync if we are still too fast\r
// usleep sleeps for ~20ms minimum, so it is not a solution here\r
if(tval.tv_usec < lim_time)\r
{\r
// we are too fast\r
- simpleWait(thissec, lim_time);\r
+ if (vsync_offset) {\r
+ if (lim_time - tval.tv_usec > target_frametime/2)\r
+ simpleWait(thissec, lim_time - target_frametime/4);\r
+ gp2x_video_wait_vsync();\r
+ } else {\r
+ simpleWait(thissec, lim_time);\r
+ }\r
}\r
}\r
\r
\r
static int savestate_menu_loop(int is_loading)\r
{\r
- int menu_sel = 10, menu_sel_max = 10;\r
+ static int menu_sel = 10;\r
+ int menu_sel_max = 10;\r
unsigned long inp = 0;\r
\r
state_check_slots();\r
\r
static void cd_menu_loop_options(void)\r
{\r
- int menu_sel = 0, menu_sel_max = 10;\r
+ static int menu_sel = 0;\r
+ int menu_sel_max = 10;\r
unsigned long inp = 0;\r
char bios_us[32], bios_eu[32], bios_jp[32], *bios, *p;\r
\r
\r
static void draw_amenu_options(int menu_sel)\r
{\r
- int tl_x = 25, tl_y = 60, y;\r
+ int tl_x = 25, tl_y = 50, y;\r
char *mms = mmuhack_status ? "active) " : "inactive)";\r
\r
y = tl_y;\r
gp2x_pd_clone_buffer2();\r
\r
gp2x_text_out8(tl_x, y, "Gamma correction %i.%02i", currentConfig.gamma / 100, currentConfig.gamma%100); // 0\r
- gp2x_text_out8(tl_x, (y+=10), "Emulate Z80 %s", (currentConfig.PicoOpt&0x004)?"ON":"OFF"); // 1\r
- gp2x_text_out8(tl_x, (y+=10), "Emulate YM2612 (FM) %s", (currentConfig.PicoOpt&0x001)?"ON":"OFF"); // 2\r
- gp2x_text_out8(tl_x, (y+=10), "Emulate SN76496 (PSG) %s", (currentConfig.PicoOpt&0x002)?"ON":"OFF"); // 3\r
- gp2x_text_out8(tl_x, (y+=10), "gzip savestates %s", (currentConfig.EmuOpt &0x008)?"ON":"OFF"); // 4\r
- gp2x_text_out8(tl_x, (y+=10), "Don't save last used ROM %s", (currentConfig.EmuOpt &0x020)?"ON":"OFF"); // 5\r
+ gp2x_text_out8(tl_x, (y+=10), "A_SN's gamma curve %s", (currentConfig.EmuOpt &0x1000)?"ON":"OFF");\r
+ gp2x_text_out8(tl_x, (y+=10), "Perfecf vsync %s", (currentConfig.EmuOpt &0x2000)?"ON":"OFF");\r
+ gp2x_text_out8(tl_x, (y+=10), "Emulate Z80 %s", (currentConfig.PicoOpt&0x0004)?"ON":"OFF");\r
+ gp2x_text_out8(tl_x, (y+=10), "Emulate YM2612 (FM) %s", (currentConfig.PicoOpt&0x0001)?"ON":"OFF");\r
+ gp2x_text_out8(tl_x, (y+=10), "Emulate SN76496 (PSG) %s", (currentConfig.PicoOpt&0x0002)?"ON":"OFF"); // 5\r
+ gp2x_text_out8(tl_x, (y+=10), "gzip savestates %s", (currentConfig.EmuOpt &0x0008)?"ON":"OFF");\r
+ gp2x_text_out8(tl_x, (y+=10), "Don't save last used ROM %s", (currentConfig.EmuOpt &0x0020)?"ON":"OFF");\r
gp2x_text_out8(tl_x, (y+=10), "needs restart:");\r
- gp2x_text_out8(tl_x, (y+=10), "craigix's RAM timings %s", (currentConfig.EmuOpt &0x100)?"ON":"OFF"); // 7\r
- gp2x_text_out8(tl_x, (y+=10), "squidgehack (now %s %s", mms, (currentConfig.EmuOpt &0x010)?"ON":"OFF"); // 8\r
+ gp2x_text_out8(tl_x, (y+=10), "craigix's RAM timings %s", (currentConfig.EmuOpt &0x0100)?"ON":"OFF");\r
+ gp2x_text_out8(tl_x, (y+=10), "squidgehack (now %s %s", mms, (currentConfig.EmuOpt &0x0010)?"ON":"OFF"); // 10\r
gp2x_text_out8(tl_x, (y+=10), "Done");\r
\r
// draw cursor\r
\r
static void amenu_loop_options(void)\r
{\r
- int menu_sel = 0, menu_sel_max = 9;\r
+ static int menu_sel = 0;\r
+ int menu_sel_max = 11;\r
unsigned long inp = 0;\r
\r
for(;;)\r
if(inp & GP2X_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; }\r
if((inp& GP2X_B)||(inp&GP2X_LEFT)||(inp&GP2X_RIGHT)) { // toggleable options\r
switch (menu_sel) {\r
- case 1: currentConfig.PicoOpt^=0x004; break;\r
- case 2: currentConfig.PicoOpt^=0x001; break;\r
- case 3: currentConfig.PicoOpt^=0x002; break;\r
- case 4: currentConfig.EmuOpt ^=0x008; break;\r
- case 5: currentConfig.EmuOpt ^=0x020; break;\r
- case 7: currentConfig.EmuOpt ^=0x100; break;\r
- case 8: currentConfig.EmuOpt ^=0x010; break;\r
- case 9: return;\r
+ case 1: currentConfig.EmuOpt ^=0x1000; break;\r
+ case 2: currentConfig.EmuOpt ^=0x2000; break;\r
+ case 3: currentConfig.PicoOpt^=0x0004; break;\r
+ case 4: currentConfig.PicoOpt^=0x0001; break;\r
+ case 5: currentConfig.PicoOpt^=0x0002; break;\r
+ case 6: currentConfig.EmuOpt ^=0x0008; break;\r
+ case 7: currentConfig.EmuOpt ^=0x0020; break;\r
+ case 9: currentConfig.EmuOpt ^=0x0100; break;\r
+ case 10: currentConfig.EmuOpt ^=0x0010; break;\r
+ case 11: return;\r
}\r
}\r
if(inp & (GP2X_X|GP2X_A)) return;\r
\r
static int menu_loop_options(void)\r
{\r
- int menu_sel = 0, menu_sel_max = 17;\r
+ static int menu_sel = 0;\r
+ int menu_sel_max = 17;\r
unsigned long inp = 0;\r
\r
if (rom_data) menu_sel_max++;\r