arm_linux.S for cache ops and random fixes
[picodrive.git] / platform / gp2x / gp2x.c
index 78e8561..0276038 100644 (file)
@@ -36,6 +36,7 @@
 #include "gp2x.h"\r
 #include "usbjoy.h"\r
 #include "../common/arm_utils.h"\r
+#include "../common/arm_linux.h"\r
 \r
 volatile unsigned short *gp2x_memregs;\r
 //static\r
@@ -162,9 +163,7 @@ void gp2x_video_wait_vsync(void)
 void gp2x_video_flush_cache(void)\r
 {\r
        // since we are using the mmu hack, we must flush the cache first\r
-       // (the params are most likely wrong, but they seem to work somehow)\r
-       //flushcache(addr, addr + 320*240*2, 0);\r
-       flushcache(gp2x_screen, (char *)gp2x_screen + 320*240*2, 0);\r
+       cache_flush_d_inval_i(gp2x_screen, (char *)gp2x_screen + 320*240*2);\r
 }\r
 \r
 \r
@@ -231,21 +230,24 @@ typedef struct ucb1x00_ts_event
 int gp2x_touchpad_read(int *x, int *y)\r
 {\r
        UCB1X00_TS_EVENT event;\r
+       static int zero_seen = 0;\r
        int retval;\r
 \r
        if (touchdev < 0) return -1;\r
 \r
        retval = read(touchdev, &event, sizeof(event));\r
-       if (retval < 0) {\r
+       if (retval <= 0) {\r
                printf("touch read failed %i %i\n", retval, errno);\r
                return -1;\r
        }\r
+       // this is to ignore the messed-up 4.1.x driver\r
+       if (event.pressure == 0) zero_seen = 1;\r
 \r
        if (x) *x = (event.x * touchcal[0] + touchcal[2]) >> 16;\r
        if (y) *y = (event.y * touchcal[4] + touchcal[5]) >> 16;\r
        // printf("read %i %i %i\n", event.pressure, *x, *y);\r
 \r
-       return event.pressure;\r
+       return zero_seen ? event.pressure : 0;\r
 }\r
 \r
 \r