perfect vsync
[picodrive.git] / platform / gp2x / gp2x.c
index f138be6..d6a701c 100644 (file)
@@ -34,6 +34,7 @@
 \r
 #include "gp2x.h"\r
 #include "usbjoy.h"\r
+#include "asmutils.h"\r
 \r
 volatile unsigned short *gp2x_memregs;\r
 //static\r
@@ -149,11 +150,10 @@ void gp2x_video_RGB_setscaling(int ln_offs, int W, int H)
 }\r
 \r
 \r
-/* LCD updates @ 80Hz? */\r
 void gp2x_video_wait_vsync(void)\r
 {\r
-       gp2x_memregs[0x2846>>1] = 0x20|2; //(gp2x_memregs[0x2846>>1] | 0x20) & ~2;\r
-       while(!(gp2x_memregs[0x2846>>1] & 2));// usleep(1);\r
+       unsigned short v = gp2x_memregs[0x1182>>1];\r
+       while (!((v ^ gp2x_memregs[0x1182>>1]) & 0x10)) spend_cycles(1024);\r
 }\r
 \r
 \r