screen ptr/size unification, major cleanups
[libpicofe.git] / gp2x / gp2x.c
index 89505a0..e0aa296 100644 (file)
@@ -32,7 +32,6 @@
 #include <errno.h>\r
 \r
 #include "gp2x.h"\r
-#include "../linux/usbjoy.h"\r
 #include "../linux/sndout_oss.h"\r
 #include "../common/arm_utils.h"\r
 #include "../common/arm_linux.h"\r
@@ -47,8 +46,6 @@ int memdev = 0;
 static int touchdev = -1;\r
 static int touchcal[7] = { 6203, 0, -1501397, 0, -4200, 16132680, 65536 };\r
 \r
-void *gp2x_screen;\r
-\r
 #define FRAMEBUFF_WHOLESIZE (0x30000*4) // 320*240*2 + some more\r
 #define FRAMEBUFF_ADDR0 (0x4000000-FRAMEBUFF_WHOLESIZE)\r
 #define FRAMEBUFF_ADDR1 (FRAMEBUFF_ADDR0+0x30000)\r
@@ -72,7 +69,7 @@ void gp2x_video_flip(void)
        gp2x_memregs[0x2912>>1] = lsw;\r
 \r
        // jump to other buffer:\r
-       gp2x_screen = gp2x_screens[++screensel&3];\r
+       g_screen_ptr = gp2x_screens[++screensel&3];\r
 }\r
 \r
 /* doulblebuffered flip */\r
@@ -86,7 +83,7 @@ void gp2x_video_flip2(void)
        gp2x_memregs[0x2912>>1] = 0;\r
 \r
        // jump to other buffer:\r
-       gp2x_screen = gp2x_screens[++screensel&1];\r
+       g_screen_ptr = gp2x_screens[++screensel&1];\r
 }\r
 \r
 \r
@@ -162,7 +159,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
-       cache_flush_d_inval_i(gp2x_screen, (char *)gp2x_screen + 320*240*2);\r
+       cache_flush_d_inval_i(g_screen_ptr, (char *)g_screen_ptr + 320*240*2);\r
 }\r
 \r
 \r
@@ -193,11 +190,11 @@ void gp2x_memset_all_buffers(int offset, int byte, int len)
 \r
 void gp2x_pd_clone_buffer2(void)\r
 {\r
-       memcpy(gp2x_screen, gp2x_screens[2], 320*240*2);\r
+       memcpy(g_screen_ptr, gp2x_screens[2], 320*240*2);\r
 }\r
 \r
 \r
-unsigned long gp2x_joystick_read(int allow_usb_joy)\r
+unsigned long gp2x_joystick_read(int unused)\r
 {\r
        int i;\r
        unsigned long value=(gp2x_memregs[0x1198>>1] & 0x00FF); // GPIO M\r
@@ -207,13 +204,6 @@ unsigned long gp2x_joystick_read(int allow_usb_joy)
        if(value==0x7F) value=0xBE;\r
        value = ~((gp2x_memregs[0x1184>>1] & 0xFF00) | value | (gp2x_memregs[0x1186>>1] << 16)); // C D\r
 \r
-       if (allow_usb_joy && num_of_joys > 0) {\r
-               // check the usb joy as well..\r
-               usbjoy_update();\r
-               for (i = 0; i < num_of_joys; i++)\r
-                       value |= usbjoy_check(i);\r
-       }\r
-\r
        return value;\r
 }\r
 \r
@@ -318,7 +308,7 @@ void gp2x_init(void)
        gp2x_screens[0] = mmap(0, FRAMEBUFF_WHOLESIZE, PROT_WRITE, MAP_SHARED, memdev, FRAMEBUFF_ADDR0);\r
        if(gp2x_screens[0] == MAP_FAILED)\r
        {\r
-               perror("mmap(gp2x_screen)");\r
+               perror("mmap(g_screen_ptr)");\r
                exit(1);\r
        }\r
        printf("framebuffers point to %p\n", gp2x_screens[0]);\r
@@ -326,7 +316,7 @@ void gp2x_init(void)
        gp2x_screens[2] = (char *) gp2x_screens[1]+0x30000;\r
        gp2x_screens[3] = (char *) gp2x_screens[2]+0x30000;\r
 \r
-       gp2x_screen = gp2x_screens[0];\r
+       g_screen_ptr = gp2x_screens[0];\r
        screensel = 0;\r
 \r
        gp2x_screenaddr_old[0] = gp2x_memregs[0x290E>>1];\r
@@ -340,9 +330,6 @@ void gp2x_init(void)
        // snd\r
        sndout_oss_init();\r
 \r
-       /* init usb joys -GnoStiC */\r
-       usbjoy_init();\r
-\r
        // touchscreen\r
        touchdev = open("/dev/touchscreen/wm97xx", O_RDONLY);\r
        if (touchdev >= 0) {\r
@@ -381,7 +368,6 @@ void gp2x_deinit(void)
        if (touchdev >= 0) close(touchdev);\r
 \r
        sndout_oss_exit();\r
-       usbjoy_deinit();\r
 \r
        printf("all done, running ");\r
 \r