#include <stdarg.h>\r
\r
#include "../gp2x/emu.h"\r
-#include "../gp2x/usbjoy.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 "../common/input.h"\r
+#include "../linux/sndout_oss.h"\r
#include "asm_utils.h"\r
\r
-#include <Pico/PicoInt.h>\r
-#include <Pico/Patch.h>\r
-#include <Pico/sound/mix.h>\r
+#include <pico/pico_int.h>\r
+#include <pico/patch.h>\r
+#include <pico/sound/mix.h>\r
#include <zlib/zlib.h>\r
\r
//#define PFRAMES\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.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
len = 256;\r
}\r
\r
- if (!sh && (rendstatus & PDRAW_ACC_SPRITES))\r
- mask=0x3f; // accurate sprites, upper bits are priority stuff\r
+ if (!sh && (rendstatus & PDRAW_SPR_LO_ON_HI))\r
+ mask=0x3f; // messed sprites, upper bits are priority stuff\r
\r
#if 1\r
clut_line(pd, ps, pal, (mask<<16) | len);\r
// 8bit accurate renderer\r
if (Pico.m.dirtyPal)\r
{\r
- int pallen = 0x40;\r
+ int pallen = 0xc0;\r
Pico.m.dirtyPal = 0;\r
if (Pico.video.reg[0xC]&8) // shadow/hilight mode\r
{\r
memcpy32(localPal+0xc0, localPal+0x40, 0x40);\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
}\r
else {\r
vidConvCpyRGB32(localPal, Pico.cram, 0x40);\r
+ memcpy32(localPal+0x80, localPal, 0x40);\r
}\r
if (pallen > 0xc0) {\r
localPal[0xc0] = 0x0000c000;\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 (vol > 0) vol--;\r
}\r
wait_frames = 0;\r
- gp2x_sound_volume(vol, vol);\r
+ sndout_oss_setvol(vol, vol);\r
currentConfig.volume = vol;\r
}\r
sprintf(noticeMsg, "VOL: %02i", vol);\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
- gp2x_usbjoy_update();\r
- for (joy = 0; joy < num_of_joys; joy++) {\r
- int btns = gp2x_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
/* avoid writing audio when lagging behind to prevent audio lag */\r
if (PicoSkipFrame != 2)\r
- gp2x_sound_write(PsndOut, len<<1);\r
+ sndout_oss_write(PsndOut, len<<1);\r
}\r
\r
\r
currentConfig.EmuOpt = eo_old;\r
}\r
\r
+void emu_platformDebugCat(char *str)\r
+{\r
+ // nothing\r
+}\r
+\r
static void simpleWait(int thissec, int lim_time)\r
{\r
struct timeval tval;\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
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
- gp2x_start_sound(PsndRate, 16, (PicoOpt&8)>>3);\r
- gp2x_sound_volume(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
\r
if (currentConfig.Frameskip < 0 && tval.tv_usec - lim_time >= 300000) // slowdown detection\r
reset_timing = 1;\r
-/* else if (PsndOut != NULL || currentConfig.Frameskip < 0)\r
+#if 1\r
+ else if (PsndOut != NULL || currentConfig.Frameskip < 0)\r
{\r
// sleep or vsync if we are still too fast\r
// usleep sleeps for ~20ms minimum, so it is not a solution here\r
}\r
}\r
}\r
-*/\r
+#endif\r
blit(fpsbuff, notice);\r
\r
pframes_done++; pframes_shown++;\r