UIQ3 update, some makefile unification, rm old configs, stuff
[libpicofe.git] / gp2x / emu.c
index 570b0fc..c225f18 100644 (file)
@@ -49,7 +49,6 @@ static short __attribute__((aligned(4))) sndBuffer[2*44100/50];
 static struct timeval noticeMsgTime = { 0, 0 };        // when started showing\r
 static int osd_fps_x;\r
 static int gp2x_old_gamma = 100;\r
-char noticeMsg[64];                    // notice msg to draw\r
 unsigned char *PicoDraw2FB = NULL;  // temporary buffer for alt renderer\r
 int reset_timing = 0;\r
 \r
@@ -66,7 +65,7 @@ void emu_noticeMsgUpdated(void)
        gettimeofday(&noticeMsgTime, 0);\r
 }\r
 \r
-void emu_getMainDir(char *dst, int len)\r
+int emu_getMainDir(char *dst, int len)\r
 {\r
        extern char **g_argv;\r
        int j;\r
@@ -77,6 +76,8 @@ void emu_getMainDir(char *dst, int len)
        dst[len] = 0;\r
        for (j = strlen(dst); j > 0; j--)\r
                if (dst[j] == '/') { dst[j+1] = 0; break; }\r
+\r
+       return j + 1;\r
 }\r
 \r
 void emu_Init(void)\r
@@ -164,16 +165,7 @@ void emu_prepareDefaultConfig(void)
        defaultConfig.KeyBinds[22] = 1<<30; // vol down\r
        defaultConfig.gamma = 100;\r
        defaultConfig.scaling = 0;\r
-}\r
-\r
-void emu_setDefaultConfig(void)\r
-{\r
-       memcpy(&currentConfig, &defaultConfig, sizeof(currentConfig));\r
-       PicoOpt = currentConfig.s_PicoOpt;\r
-       PsndRate = currentConfig.s_PsndRate;\r
-       PicoRegionOverride = currentConfig.s_PicoRegion;\r
-       PicoAutoRgnOrder = currentConfig.s_PicoAutoRgnOrder;\r
-       PicoCDBuffers = currentConfig.s_PicoCDBuffers;\r
+       defaultConfig.turbo_rate = 15;\r
 }\r
 \r
 void osd_text(int x, int y, const char *text)\r
@@ -436,33 +428,19 @@ static void emu_msg_tray_open(void)
 \r
 static void RunEventsPico(unsigned int events, unsigned int gp2x_keys)\r
 {\r
-       int ret, px, py;\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)\r
-       {\r
-               PicoPad[0] &= ~0x0f; // release UDLR\r
-               if (gp2x_keys & GP2X_UP)   { pico_pen_y--; if (pico_pen_y < 8) pico_pen_y = 8; }\r
-               if (gp2x_keys & GP2X_DOWN) { pico_pen_y++; if (pico_pen_y > 224-PICO_PEN_ADJUST_Y) pico_pen_y = 224-PICO_PEN_ADJUST_Y; }\r
-               if (gp2x_keys & GP2X_LEFT) { pico_pen_x--; if (pico_pen_x < 0) pico_pen_x = 0; }\r
-               if (gp2x_keys & GP2X_RIGHT) {\r
-                       int lim = (Pico.video.reg[12]&1) ? 319 : 255;\r
-                       pico_pen_x++;\r
-                       if (pico_pen_x > lim-PICO_PEN_ADJUST_X)\r
-                               pico_pen_x = lim-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
+       if (pico_inp_mode == 0) return;\r
 \r
        // for F200\r
        ret = gp2x_touchpad_read(&px, &py);\r
-       if (ret >= 0) {\r
-               if (ret > 5000) {\r
+       if (ret >= 0)\r
+       {\r
+               if (ret > 35000)\r
+               {\r
                        if (pdown_frames++ > 5)\r
                                PicoPad[0] |= 0x20;\r
 \r
@@ -476,11 +454,28 @@ static void RunEventsPico(unsigned int events, unsigned int gp2x_keys)
                        if (pico_pen_y > 224) pico_pen_y = 224;\r
                }\r
                else\r
-                       pdown_frames= 0;\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
@@ -639,8 +634,11 @@ static void updateKeys(void)
                }\r
        }\r
 \r
-       PicoPad[0] = (unsigned short) allActions[0];\r
-       PicoPad[1] = (unsigned short) allActions[1];\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
@@ -712,6 +710,11 @@ void emu_forcedFrame(int opts)
        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