\r
#include <stdarg.h>\r
\r
-#include "../gp2x/emu.h"\r
-#include "../gp2x/menu.h"\r
#include "../common/arm_utils.h"\r
#include "../common/fonts.h"\r
#include "../common/emu.h"\r
+#include "../common/menu.h"\r
#include "../common/config.h"\r
-#include "../common/common.h"\r
-#include "../linux/usbjoy.h"\r
+#include "../common/input.h"\r
#include "../linux/sndout_oss.h"\r
#include "asm_utils.h"\r
\r
#endif\r
\r
\r
-int engineState;\r
-int select_exits = 0;\r
-\r
-char romFileName[PATH_MAX];\r
-\r
static short __attribute__((aligned(4))) sndBuffer[2*44100/50];\r
static struct timeval noticeMsgTime = { 0, 0 }; // when started showing\r
static int osd_fps_x;\r
\r
#define PICO_PEN_ADJUST_X 4\r
#define PICO_PEN_ADJUST_Y 2\r
-static int pico_pen_x = SCREEN_WIDTH/2, pico_pen_y = 240/2;\r
+static int pico_pen_x = 0, 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
\r
-void emu_noticeMsgUpdated(void)\r
+void plat_status_msg(const char *format, ...)\r
{\r
+ va_list vl;\r
+\r
+ va_start(vl, format);\r
+ vsnprintf(noticeMsg, sizeof(noticeMsg), fmt, vl);\r
+ va_end(vl);\r
+\r
gettimeofday(¬iceMsgTime, 0);\r
}\r
\r
}\r
\r
\r
-static void scaling_update(void)\r
-{\r
- PicoOpt &= ~0x4100;\r
- switch (currentConfig.scaling) {\r
- default: break; // off\r
- case 1: // hw hor\r
- case 2: PicoOpt |= 0x0100; break; // hw hor+vert\r
- case 3: PicoOpt |= 0x4000; break; // sw hor\r
- }\r
-}\r
-\r
-\r
void emu_Deinit(void)\r
{\r
// save SRAM\r
defaultConfig.EmuOpt = 0x8f | 0x00600; // | <- confirm_save, cd_leds\r
defaultConfig.s_PicoOpt = 0x0f | POPT_EXT_FM|POPT_EN_MCD_PCM|POPT_EN_MCD_CDDA|POPT_EN_SVP_DRC;\r
defaultConfig.s_PicoOpt |= POPT_ACC_SPRITES|POPT_EN_MCD_GFX;\r
-// defaultConfig.s_PicoOpt &= ~POPT_EN_SVP_DRC; // crashes :(\r
defaultConfig.EmuOpt &= ~8; // no save gzip\r
defaultConfig.s_PsndRate = 44100;\r
defaultConfig.s_PicoRegion = 0;\r
static void textOut16(int x, int y, const char *text)\r
{\r
int i,l,len=strlen(text);\r
- unsigned int *screen = (unsigned int *)((unsigned short *)SCREEN_BUFFER + (x&~1) + y*SCREEN_WIDTH);\r
+ unsigned int *screen = (unsigned int *)((unsigned short *)g_screen_ptr + (x&~1) + y*g_screen_width);\r
\r
for (i = 0; i < len; i++)\r
{\r
for (l=0;l<16;)\r
{\r
unsigned char fd = fontdata8x8[((text[i])*8)+l/2];\r
- unsigned int *d = &screen[l*SCREEN_WIDTH/2];\r
+ unsigned int *d = &screen[l*g_screen_width/2];\r
if (fd&0x80) d[0]=0xffffffff;\r
if (fd&0x40) d[1]=0xffffffff;\r
if (fd&0x20) d[2]=0xffffffff;\r
if (fd&0x04) d[5]=0xffffffff;\r
if (fd&0x02) d[6]=0xffffffff;\r
if (fd&0x01) d[7]=0xffffffff;\r
- l++; d = &screen[l*SCREEN_WIDTH/2];\r
+ l++; d = &screen[l*g_screen_width/2];\r
if (fd&0x80) d[0]=0xffffffff;\r
if (fd&0x40) d[1]=0xffffffff;\r
if (fd&0x20) d[2]=0xffffffff;\r
}\r
\r
\r
-void osd_text(int x, int y, const char *text)\r
+static void osd_text(int x, int y, const char *text)\r
{\r
int len = strlen(text)*8;\r
\r
x &= ~3; // align x\r
len = (len+3) >> 2;\r
for (h = 0; h < 8; h++) {\r
- p = (int *) ((unsigned char *) gp2x_screen+x+SCREEN_WIDTH*(y+h));\r
+ p = (int *) ((unsigned char *) g_screen_ptr+x+g_screen_width*(y+h));\r
for (i = len; i; i--, p++) *p = 0xe0e0e0e0;\r
}\r
emu_textOut8(x, y, text);\r
x &= ~1; // align x\r
len++;\r
for (h = 0; h < 16; h++) {\r
- p = (int *) ((unsigned short *) gp2x_screen+x+SCREEN_WIDTH*(y+h));\r
+ p = (int *) ((unsigned short *) g_screen_ptr+x+g_screen_width*(y+h));\r
for (i = len; i; i--, p++) *p = 0;//(*p>>2)&0x39e7;\r
}\r
textOut16(x, y, text);\r
// 8-bit modes\r
unsigned int col_g = (old_reg & 2) ? 0xc0c0c0c0 : 0xe0e0e0e0;\r
unsigned int col_r = (old_reg & 1) ? 0xd0d0d0d0 : 0xe0e0e0e0;\r
- *(unsigned int *)((char *)gp2x_screen + SCREEN_WIDTH*2+ 4) =\r
- *(unsigned int *)((char *)gp2x_screen + SCREEN_WIDTH*3+ 4) =\r
- *(unsigned int *)((char *)gp2x_screen + SCREEN_WIDTH*4+ 4) = col_g;\r
- *(unsigned int *)((char *)gp2x_screen + SCREEN_WIDTH*2+12) =\r
- *(unsigned int *)((char *)gp2x_screen + SCREEN_WIDTH*3+12) =\r
- *(unsigned int *)((char *)gp2x_screen + SCREEN_WIDTH*4+12) = col_r;\r
+ *(unsigned int *)((char *)g_screen_ptr + g_screen_width*2+ 4) =\r
+ *(unsigned int *)((char *)g_screen_ptr + g_screen_width*3+ 4) =\r
+ *(unsigned int *)((char *)g_screen_ptr + g_screen_width*4+ 4) = col_g;\r
+ *(unsigned int *)((char *)g_screen_ptr + g_screen_width*2+12) =\r
+ *(unsigned int *)((char *)g_screen_ptr + g_screen_width*3+12) =\r
+ *(unsigned int *)((char *)g_screen_ptr + g_screen_width*4+12) = col_r;\r
} else {\r
// 16-bit modes\r
- unsigned int *p = (unsigned int *)((short *)gp2x_screen + SCREEN_WIDTH*2+4);\r
+ unsigned int *p = (unsigned int *)((short *)g_screen_ptr + g_screen_width*2+4);\r
unsigned int col_g = (old_reg & 2) ? 0x06000600 : 0;\r
unsigned int col_r = (old_reg & 1) ? 0xc000c000 : 0;\r
- *p++ = col_g; *p++ = col_g; p+=2; *p++ = col_r; *p++ = col_r; p += SCREEN_WIDTH/2 - 12/2;\r
- *p++ = col_g; *p++ = col_g; p+=2; *p++ = col_r; *p++ = col_r; p += SCREEN_WIDTH/2 - 12/2;\r
+ *p++ = col_g; *p++ = col_g; p+=2; *p++ = col_r; *p++ = col_r; p += g_screen_width/2 - 12/2;\r
+ *p++ = col_g; *p++ = col_g; p+=2; *p++ = col_r; *p++ = col_r; p += g_screen_width/2 - 12/2;\r
*p++ = col_g; *p++ = col_g; p+=2; *p++ = col_r; *p++ = col_r;\r
}\r
}\r
\r
static void draw_pico_ptr(void)\r
{\r
- unsigned short *p = (unsigned short *)gp2x_screen;\r
+ unsigned short *p = (unsigned short *)g_screen_ptr;\r
\r
// only if pen enabled and for 16bit modes\r
if (pico_inp_mode == 0 || (PicoOpt&0x10) || !(currentConfig.EmuOpt&0x80)) return;\r
if (!(Pico.video.reg[12]&1) && !(PicoOpt&POPT_DIS_32C_BORDER))\r
p += 32;\r
\r
- p += SCREEN_WIDTH * (pico_pen_y + PICO_PEN_ADJUST_Y);\r
+ p += g_screen_width * (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
static int EmuScanBegin16(unsigned int num)\r
{\r
if (!(Pico.video.reg[1]&8)) num += 8;\r
- DrawLineDest = (unsigned short *)gp2x_screen + num*800 + 800/2 - 320/2;\r
+ DrawLineDest = (unsigned short *)g_screen_ptr + num*800 + 800/2 - 320/2;\r
//int w = (Pico.video.reg[12]&1) ? 320 : 256;\r
- //DrawLineDest = (unsigned short *)gp2x_screen + num*w;\r
+ //DrawLineDest = (unsigned short *)g_screen_ptr + num*w;\r
\r
return 0;\r
}\r
int len, mask = 0xff;\r
\r
if (!(Pico.video.reg[1]&8)) num += 8;\r
- pd=(unsigned short *)gp2x_screen + num*800*2 + 800/2 - 320*2/2;\r
+ pd=(unsigned short *)g_screen_ptr + num*800*2 + 800/2 - 320*2/2;\r
\r
if (Pico.m.dirtyPal)\r
PicoDoHighPal555(sh);\r
\r
#endif // USE_320_SCREEN\r
\r
-static int EmuScanBegin8(unsigned int num)\r
-{\r
- if (!(Pico.video.reg[1]&8)) num += 8;\r
- DrawLineDest = (unsigned char *) gp2x_screen + SCREEN_WIDTH * num;\r
-\r
- return 0;\r
-}\r
-\r
int localPal[0x100];\r
static void (*vidCpyM2)(void *dest, void *src) = NULL;\r
\r
Pico.m.dirtyPal = 0;\r
vidConvCpyRGB32(localPal, Pico.cram, 0x40);\r
// feed new palette to our device\r
- gp2x_video_setpalette(localPal, 0x40);\r
+ // gp2x_video_setpalette(localPal, 0x40);\r
}\r
// a hack for VR\r
if (PicoRead16Hook == PicoSVPRead16)\r
memset32((int *)(PicoDraw2FB+328*8+328*223), 0xe0e0e0e0, 328);\r
// do actual copy\r
- vidCpyM2((unsigned char *)gp2x_screen+SCREEN_WIDTH*8, PicoDraw2FB+328*8);\r
+ vidCpyM2((unsigned char *)g_screen_ptr+g_screen_width*8, PicoDraw2FB+328*8);\r
}\r
else if (!(emu_opt&0x80))\r
{\r
localPal[0xe0] = 0x00000000; // reserved pixels for OSD\r
localPal[0xf0] = 0x00ffffff;\r
}\r
- gp2x_video_setpalette(localPal, pallen);\r
+ // gp2x_video_setpalette(localPal, pallen);\r
}\r
}\r
\r
if (notice || (emu_opt & 2)) {\r
- int h = SCREEN_HEIGHT-16;\r
+ int h = g_screen_height-16;\r
if (currentConfig.scaling == 2 && !(Pico.video.reg[1]&8)) h -= 16;\r
if (notice) osd_text(4, h, notice);\r
if (emu_opt & 2)\r
draw_cd_leds();\r
if (PicoAHW & PAHW_PICO)\r
draw_pico_ptr();\r
-{\r
-//static int u=0;\r
-//memset((char *)gp2x_screen+800*471*2, (u++)>>1, 800*9*2);\r
-}\r
\r
//gp2x_video_wait_vsync();\r
- gp2x_video_flip();\r
+ // gp2x_video_flip();\r
}\r
\r
\r
// clears whole screen or just the notice area (in all buffers)\r
static void clearArea(int full)\r
{\r
- if ((PicoOpt&0x10)||!(currentConfig.EmuOpt&0x80)) {\r
- // 8-bit renderers\r
- if (full) gp2x_memset_all_buffers(0, 0xe0, SCREEN_WIDTH*240);\r
- else gp2x_memset_all_buffers(SCREEN_WIDTH*232, 0xe0, SCREEN_WIDTH*8);\r
- } else {\r
- // 16bit accurate renderer\r
- if (full) gp2x_memset_all_buffers(0, 0, SCREEN_WIDTH*SCREEN_HEIGHT*2);\r
- else gp2x_memset_all_buffers(SCREEN_WIDTH*(SCREEN_HEIGHT-16)*2, 0, SCREEN_WIDTH*16*2);\r
- }\r
+ if (full) memset(g_screen_ptr, 0, g_screen_width*g_screen_height*2);\r
+ else memset((short *)g_screen_ptr + g_screen_width * (g_screen_height - 16), 0,\r
+ g_screen_width * 16 * 2);\r
}\r
\r
\r
static void vidResetMode(void)\r
{\r
+#if 0\r
if (PicoOpt&0x10) {\r
gp2x_video_changemode(8);\r
} else if (currentConfig.EmuOpt&0x80) {\r
if (currentConfig.scaling == 2 && !(Pico.video.reg[1]&8))\r
gp2x_video_RGB_setscaling(8, (PicoOpt&0x100)&&!(Pico.video.reg[12]&1) ? 256 : 320, 224);\r
else gp2x_video_RGB_setscaling(0, (PicoOpt&0x100)&&!(Pico.video.reg[12]&1) ? 256 : 320, 240);\r
+#else\r
+#ifdef USE_320_SCREEN\r
+ PicoDrawSetColorFormat(1);\r
+ PicoScanBegin = EmuScanBegin16;\r
+#else\r
+ PicoDrawSetColorFormat(-1);\r
+ PicoScanEnd = EmuScanEnd16;\r
+#endif\r
+#endif\r
}\r
\r
\r
static void emu_msg_cb(const char *msg)\r
{\r
+/*\r
if ((PicoOpt&0x10)||!(currentConfig.EmuOpt&0x80)) {\r
// 8-bit renderers\r
- gp2x_memset_all_buffers(SCREEN_WIDTH*(SCREEN_HEIGHT-16), 0xe0, SCREEN_WIDTH*16);\r
- osd_text(4, SCREEN_HEIGHT-16, msg);\r
- gp2x_memcpy_all_buffers((char *)gp2x_screen+SCREEN_WIDTH*(SCREEN_HEIGHT-16),\r
- SCREEN_WIDTH*(SCREEN_HEIGHT-16), SCREEN_WIDTH*16);\r
+ gp2x_memset_all_buffers(g_screen_width*(g_screen_height-16), 0xe0, g_screen_width*16);\r
+ osd_text(4, g_screen_height-16, msg);\r
+ gp2x_memcpy_all_buffers((char *)g_screen_ptr+g_screen_width*(g_screen_height-16),\r
+ g_screen_width*(g_screen_height-16), g_screen_width*16);\r
} else {\r
// 16bit accurate renderer\r
- gp2x_memset_all_buffers(SCREEN_WIDTH*(SCREEN_HEIGHT-16)*2, 0, SCREEN_WIDTH*16*2);\r
- osd_text(4, SCREEN_HEIGHT-16, msg);\r
- gp2x_memcpy_all_buffers((char *)gp2x_screen+SCREEN_WIDTH*(SCREEN_HEIGHT-16)*2,\r
- SCREEN_WIDTH*(SCREEN_HEIGHT-16)*2, SCREEN_WIDTH*16*2);\r
+ gp2x_memset_all_buffers(g_screen_width*(g_screen_height-16)*2, 0, g_screen_width*16*2);\r
+ osd_text(4, g_screen_height-16, msg);\r
+ gp2x_memcpy_all_buffers((char *)g_screen_ptr+g_screen_width*(g_screen_height-16)*2,\r
+ g_screen_width*(g_screen_height-16)*2, g_screen_width*16*2);\r
}\r
gettimeofday(¬iceMsgTime, 0);\r
noticeMsgTime.tv_sec -= 2;\r
-\r
+*/\r
/* assumption: emu_msg_cb gets called only when something slow is about to happen */\r
reset_timing = 1;\r
}\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
}\r
}\r
\r
-static void RunEvents(unsigned int which)\r
-{\r
- if (which & 0x1800) // save or load (but not both)\r
- {\r
- int do_it = 1;\r
- if ( emu_checkSaveFile(state_slot) &&\r
- (( (which & 0x1000) && (currentConfig.EmuOpt & 0x800)) || // load\r
- (!(which & 0x1000) && (currentConfig.EmuOpt & 0x200))) ) { // save\r
- unsigned long keys;\r
- blit("", (which & 0x1000) ? "LOAD STATE? (Y=yes, X=no)" : "OVERWRITE SAVE? (Y=yes, X=no)");\r
- while ( !((keys = gp2x_joystick_read(1)) & (GP2X_X|GP2X_Y)) )\r
- usleep(50*1024);\r
- if (keys & GP2X_X) do_it = 0;\r
- while ( gp2x_joystick_read(1) & (GP2X_X|GP2X_Y) ) // wait for release\r
- usleep(50*1024);\r
- clearArea(0);\r
- }\r
- if (do_it) {\r
- osd_text(4, SCREEN_HEIGHT-16, (which & 0x1000) ? "LOADING GAME" : "SAVING GAME");\r
- PicoStateProgressCB = emu_state_cb;\r
- gp2x_memcpy_all_buffers(gp2x_screen, 0, SCREEN_WIDTH*SCREEN_HEIGHT*2);\r
- emu_SaveLoadGame((which & 0x1000) >> 12, 0);\r
- PicoStateProgressCB = NULL;\r
- }\r
-\r
- reset_timing = 1;\r
- }\r
- if (which & 0x0400) // switch renderer\r
- {\r
- if ( PicoOpt&0x10) { PicoOpt&=~0x10; currentConfig.EmuOpt |= 0x80; }\r
- else if (!(currentConfig.EmuOpt&0x80)) PicoOpt|= 0x10;\r
- else currentConfig.EmuOpt &= ~0x80;\r
-\r
- vidResetMode();\r
-\r
- if (PicoOpt&0x10) {\r
- strcpy(noticeMsg, " 8bit fast renderer");\r
- } else if (currentConfig.EmuOpt&0x80) {\r
- strcpy(noticeMsg, "16bit accurate renderer");\r
- } else {\r
- strcpy(noticeMsg, " 8bit accurate renderer");\r
- }\r
-\r
- gettimeofday(¬iceMsgTime, 0);\r
- }\r
- if (which & 0x0300)\r
- {\r
- if(which&0x0200) {\r
- state_slot -= 1;\r
- if(state_slot < 0) state_slot = 9;\r
- } else {\r
- state_slot += 1;\r
- if(state_slot > 9) state_slot = 0;\r
- }\r
- sprintf(noticeMsg, "SAVE SLOT %i [%s]", state_slot, emu_checkSaveFile(state_slot) ? "USED" : "FREE");\r
- gettimeofday(¬iceMsgTime, 0);\r
- }\r
- if (which & 0x0080) {\r
- engineState = PGS_Menu;\r
- }\r
-}\r
-\r
-static void updateKeys(void)\r
-{\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
- if (keys & GP2X_SELECT) {\r
- engineState = select_exits ? PGS_Quit : PGS_Menu;\r
- // wait until select is released, so menu would not resume game\r
- while (gp2x_joystick_read(1) & GP2X_SELECT) usleep(50*1000);\r
- }\r
-\r
- keys &= CONFIGURABLE_KEYS;\r
- keys2 = keys;\r
-\r
- for (i = 0; i < 32; i++)\r
- {\r
- if (keys2 & (1 << i))\r
- {\r
- int pl, acts = currentConfig.KeyBinds[i];\r
- if (!acts) continue;\r
- pl = (acts >> 16) & 1;\r
- if (kb_combo_keys & (1 << i))\r
- {\r
- int u = i+1, acts_c = acts & kb_combo_acts;\r
- // let's try to find the other one\r
- if (acts_c) {\r
- for (; u < 32; u++)\r
- if ( (keys2 & (1 << u)) && (currentConfig.KeyBinds[u] & acts_c) ) {\r
- allActions[pl] |= acts_c & currentConfig.KeyBinds[u];\r
- keys2 &= ~((1 << i) | (1 << u));\r
- break;\r
- }\r
- }\r
- // add non-combo actions if combo ones were not found\r
- if (!acts_c || u == 32)\r
- allActions[pl] |= acts & ~kb_combo_acts;\r
- } else {\r
- allActions[pl] |= acts;\r
- }\r
- }\r
- }\r
-\r
- // add joy inputs\r
- if (num_of_joys > 0)\r
- {\r
- usbjoy_update();\r
- for (joy = 0; joy < num_of_joys; joy++) {\r
- int btns = usbjoy_check2(joy);\r
- for (i = 0; i < 32; 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
- }\r
-\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
- // volume is treated in special way and triggered every frame\r
- if (events & 0x6000)\r
- update_volume(1, events & 0x2000);\r
-\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
- prevEvents = (allActions[0] | allActions[1]) >> 16;\r
-}\r
-\r
\r
static void updateSound(int len)\r
{\r
clearArea(1);\r
} else vidCpyM2 = vidCpyM2_40col;\r
\r
- vidCpyM2((unsigned char *)gp2x_screen+SCREEN_WIDTH*8, PicoDraw2FB+328*8);\r
+ vidCpyM2((unsigned char *)g_screen_ptr+g_screen_width*8, PicoDraw2FB+328*8);\r
vidConvCpyRGB32(localPal, Pico.cram, 0x40);\r
gp2x_video_setpalette(localPal, 0x40);\r
*/\r
}\r
}\r
\r
+void emu_startSound(void)\r
+{\r
+ static int PsndRate_old = 0, PicoOpt_old = 0, pal_old = 0;\r
+ int target_fps = Pico.m.pal ? 50 : 60;\r
+\r
+ PsndOut = NULL;\r
+\r
+ if (currentConfig.EmuOpt & 4)\r
+ {\r
+ int snd_excess_add;\r
+ if (PsndRate != PsndRate_old || (PicoOpt&0x20b) != (PicoOpt_old&0x20b) || Pico.m.pal != pal_old)\r
+ PsndRerate(Pico.m.frame_count ? 1 : 0);\r
+\r
+ snd_excess_add = ((PsndRate - PsndLen*target_fps)<<16) / target_fps;\r
+ printf("starting audio: %i len: %i (ex: %04x) stereo: %i, pal: %i\n",\r
+ PsndRate, PsndLen, snd_excess_add, (PicoOpt&8)>>3, Pico.m.pal);\r
+ sndout_oss_start(PsndRate, 16, (PicoOpt&8)>>3);\r
+ sndout_oss_setvol(currentConfig.volume, currentConfig.volume);\r
+ PicoWriteSound = updateSound;\r
+ update_volume(0, 0);\r
+ memset(sndBuffer, 0, sizeof(sndBuffer));\r
+ PsndOut = sndBuffer;\r
+ PsndRate_old = PsndRate;\r
+ PicoOpt_old = PicoOpt;\r
+ pal_old = Pico.m.pal;\r
+ }\r
+}\r
+\r
+void emu_endSound(void)\r
+{\r
+}\r
+\r
+/* wait until we can write more sound */\r
+void emu_waitSound(void)\r
+{\r
+ // don't need to do anything, writes will block by themselves\r
+}\r
\r
void emu_Loop(void)\r
{\r
- static int PsndRate_old = 0, PicoOpt_old = 0, pal_old = 0;\r
char fpsbuff[24]; // fps count c string\r
struct timeval tval; // timing\r
int pframes_done, pframes_shown, pthissec; // "period" frames, used for sync\r
\r
// make sure we are in correct mode\r
vidResetMode();\r
- scaling_update();\r
Pico.m.dirtyPal = 1;\r
oldmodes = ((Pico.video.reg[12]&1)<<2) ^ 0xc;\r
- emu_findKeyBindCombos();\r
\r
// pal/ntsc might have changed, reset related stuff\r
target_fps = Pico.m.pal ? 50 : 60;\r
target_frametime = 1000000/target_fps;\r
reset_timing = 1;\r
\r
- // prepare sound stuff\r
- if (currentConfig.EmuOpt & 4)\r
- {\r
- int snd_excess_add;\r
- if (PsndRate != PsndRate_old || (PicoOpt&0x20b) != (PicoOpt_old&0x20b) || Pico.m.pal != pal_old)\r
- PsndRerate(Pico.m.frame_count ? 1 : 0);\r
-\r
- snd_excess_add = ((PsndRate - PsndLen*target_fps)<<16) / target_fps;\r
- printf("starting audio: %i len: %i (ex: %04x) stereo: %i, pal: %i\n",\r
- PsndRate, PsndLen, snd_excess_add, (PicoOpt&8)>>3, Pico.m.pal);\r
- sndout_oss_start(PsndRate, 16, (PicoOpt&8)>>3);\r
- sndout_oss_setvol(currentConfig.volume, currentConfig.volume);\r
- PicoWriteSound = updateSound;\r
- update_volume(0, 0);\r
- memset(sndBuffer, 0, sizeof(sndBuffer));\r
- PsndOut = sndBuffer;\r
- PsndRate_old = PsndRate;\r
- PicoOpt_old = PicoOpt;\r
- pal_old = Pico.m.pal;\r
- } else {\r
- PsndOut = NULL;\r
- }\r
+ emu_startSound();\r
\r
// prepare CD buffer\r
if (PicoAHW & PAHW_MCD) PicoCDBufferInit();\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
+ //gp2x_video_wait_vsync();\r
gettimeofday(&tval, 0);\r
vsync_offset = tval.tv_usec;\r
while (vsync_offset >= target_frametime)\r
modes = ((Pico.video.reg[12]&1)<<2)|(Pico.video.reg[1]&8);\r
if (modes != oldmodes)\r
{\r
- int scalex = SCREEN_WIDTH;\r
+ int scalex = g_screen_width;\r
osd_fps_x = OSD_FPS_X;\r
if (modes & 4) {\r
vidCpyM2 = vidCpyM2_40col;\r
vidCpyM2 = vidCpyM2_32col;\r
}\r
}\r
- if (currentConfig.scaling == 2 && !(modes&8)) // want vertical scaling and game is not in 240 line mode\r
- gp2x_video_RGB_setscaling(8, scalex, 224);\r
- else gp2x_video_RGB_setscaling(0, scalex, 240);\r
+ //if (currentConfig.scaling == 2 && !(modes&8)) // want vertical scaling and game is not in 240 line mode\r
+ // gp2x_video_RGB_setscaling(8, scalex, 224);\r
+ // else gp2x_video_RGB_setscaling(0, scalex, 240);\r
oldmodes = modes;\r
clearArea(1);\r
}\r
// it is quite common for this implementation to leave 1 fame unfinished\r
// when second changes, but we don't want buffer to starve.\r
if(PsndOut && pframes_done < target_fps && pframes_done > target_fps-5) {\r
- updateKeys();\r
+ emu_update_input();\r
SkipFrame(1); pframes_done++;\r
}\r
\r
if (currentConfig.Frameskip >= 0) // frameskip enabled\r
{\r
for(i = 0; i < currentConfig.Frameskip; i++) {\r
- updateKeys();\r
+ emu_update_input();\r
SkipFrame(1); pframes_done++; frames_done++;\r
if (PsndOut && !reset_timing) { // do framelimitting if sound is enabled\r
gettimeofday(&tval, 0);\r
reset_timing = 1;\r
continue;\r
}\r
- updateKeys();\r
+ emu_update_input();\r
SkipFrame(tval.tv_usec < lim_time+target_frametime*2); pframes_done++; frames_done++;\r
continue;\r
}\r
\r
- updateKeys();\r
+ emu_update_input();\r
PicoFrame();\r
\r
// check time\r
if (vsync_offset) {\r
if (lim_time - tval.tv_usec > target_frametime/2)\r
simpleWait(pthissec, lim_time - target_frametime/4);\r
- gp2x_video_wait_vsync();\r
+ // gp2x_video_wait_vsync();\r
} else {\r
simpleWait(pthissec, lim_time);\r
}\r