\r
#include "../gp2x/emu.h"\r
#include "../gp2x/menu.h"\r
+#include "../gp2x/gp2x.h"\r
#include "../common/arm_utils.h"\r
#include "../common/fonts.h"\r
#include "../common/emu.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
gettimeofday(¬iceMsgTime, 0);\r
}\r
\r
+#if 0\r
static void RunEventsPico(unsigned int events, unsigned int gp2x_keys)\r
{\r
int ret, px, py, lim_x;\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
+#endif\r
\r
static void update_volume(int has_changed, int is_up)\r
{\r
if ( emu_checkSaveFile(state_slot) &&\r
(( (which & 0x1000) && (currentConfig.EmuOpt & 0x800)) || // load\r
(!(which & 0x1000) && (currentConfig.EmuOpt & 0x200))) ) { // save\r
+#if 0\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
while ( gp2x_joystick_read(1) & (GP2X_X|GP2X_Y) ) // wait for release\r
usleep(50*1024);\r
clearArea(0);\r
+#endif\r
}\r
if (do_it) {\r
osd_text(4, SCREEN_HEIGHT-16, (which & 0x1000) ? "LOADING GAME" : "SAVING GAME");\r
\r
static void updateKeys(void)\r
{\r
- unsigned int keys, keys2, allActions[2] = { 0, 0 }, events;\r
+ unsigned int 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
+ /* FIXME: combos, player2 */\r
+ allActions[0] = in_update();\r
\r
PicoPad[0] = allActions[0] & 0xfff;\r
PicoPad[1] = allActions[1] & 0xfff;\r
\r
events &= ~prevEvents;\r
\r
+/*\r
if (PicoAHW == PAHW_PICO)\r
RunEventsPico(events, keys);\r
+*/\r
if (events) RunEvents(events);\r
if (movie_data) emu_updateMovie();\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
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