extend mmap wrapper functionality
[libpicofe.git] / linux / emu.c
index 0b4361d..95666ad 100644 (file)
@@ -210,66 +210,40 @@ void plat_update_volume(int has_changed, int is_up)
 \r
 void pemu_forced_frame(int no_scale, int do_emu)\r
 {\r
-       int po_old = PicoOpt;\r
-\r
-       memset32(g_screen_ptr, 0, g_screen_width * g_screen_height * 2 / 4);\r
-\r
-       PicoOpt &= ~POPT_ALT_RENDERER;\r
-       PicoOpt |= POPT_ACC_SPRITES;\r
-       if (!no_scale)\r
-               PicoOpt |= POPT_EN_SOFTSCALE;\r
-\r
-       PicoDrawSetOutFormat(PDF_RGB555, 1);\r
        PicoDrawSetOutBuf(g_screen_ptr, g_screen_width * 2);\r
        PicoDraw32xSetFrameMode(0, 0);\r
-\r
+       PicoDrawSetCallbacks(NULL, NULL);\r
        Pico.m.dirtyPal = 1;\r
-       if (do_emu)\r
-               PicoFrame();\r
-       else\r
-               PicoFrameDrawOnly();\r
+\r
+       emu_cmn_forced_frame(no_scale, do_emu);\r
 \r
        g_menubg_src_ptr = g_screen_ptr;\r
-       PicoOpt = po_old;\r
 }\r
 \r
-static void updateSound(int len)\r
+static void oss_write_nonblocking(int len)\r
 {\r
-       len <<= 1;\r
-       if (PicoOpt & POPT_EN_STEREO)\r
-               len <<= 1;\r
-\r
+       // sndout_oss_can_write() is not reliable, only use with no_frmlimit\r
        if ((currentConfig.EmuOpt & EOPT_NO_FRMLIMIT) && !sndout_oss_can_write(len))\r
                return;\r
 \r
-       /* avoid writing audio when lagging behind to prevent audio lag */\r
-       if (PicoSkipFrame != 2)\r
-               sndout_oss_write(PsndOut, len);\r
+       sndout_oss_write_nb(PsndOut, len);\r
 }\r
 \r
 void pemu_sound_start(void)\r
 {\r
-       int target_fps = Pico.m.pal ? 50 : 60;\r
-\r
        PsndOut = NULL;\r
 \r
        if (currentConfig.EmuOpt & EOPT_EN_SOUND)\r
        {\r
-               int snd_excess_add, frame_samples;\r
                int is_stereo = (PicoOpt & POPT_EN_STEREO) ? 1 : 0;\r
 \r
                PsndRerate(Pico.m.frame_count ? 1 : 0);\r
 \r
-               frame_samples = PsndLen;\r
-               snd_excess_add = ((PsndRate - PsndLen * target_fps)<<16) / target_fps;\r
-               if (snd_excess_add != 0)\r
-                       frame_samples++;\r
-\r
-               printf("starting audio: %i len: %i (ex: %04x) stereo: %i, pal: %i\n",\r
-                       PsndRate, PsndLen, snd_excess_add, is_stereo, Pico.m.pal);\r
-               sndout_oss_start(PsndRate, frame_samples, is_stereo);\r
+               printf("starting audio: %i len: %i stereo: %i, pal: %i\n",\r
+                       PsndRate, PsndLen, is_stereo, Pico.m.pal);\r
+               sndout_oss_start(PsndRate, is_stereo, 1);\r
                sndout_oss_setvol(currentConfig.volume, currentConfig.volume);\r
-               PicoWriteSound = updateSound;\r
+               PicoWriteSound = oss_write_nonblocking;\r
                plat_update_volume(0, 0);\r
                memset(sndBuffer, 0, sizeof(sndBuffer));\r
                PsndOut = sndBuffer;\r
@@ -324,24 +298,3 @@ void plat_wait_till_us(unsigned int us_to)
        }\r
 }\r
 \r
-const char *plat_get_credits(void)\r
-{\r
-       return "PicoDrive v" VERSION " (c) notaz, 2006-2009\n\n\n"\r
-               "Credits:\n"\r
-               "fDave: Cyclone 68000 core,\n"\r
-               "      base code of PicoDrive\n"\r
-               "Reesy & FluBBa: DrZ80 core\n"\r
-               "MAME devs: YM2612 and SN76496 cores\n"\r
-               "rlyeh and others: minimal SDK\n"\r
-               "Squidge: mmuhack\n"\r
-               "Dzz: ARM940 sample\n"\r
-               "GnoStiC / Puck2099: USB joy code\n"\r
-               "craigix: GP2X hardware\n"\r
-               "ketchupgun: skin design\n"\r
-               "\n"\r
-               "special thanks (for docs, ideas):\n"\r
-               " Charles MacDonald, Haze,\n"\r
-               " Stephane Dallongeville,\n"\r
-               " Lordus, Exophase, Rokas,\n"\r
-               " Nemesis, Tasco Deluxe";\r
-}\r