bring pandora to buildable state. Some cleanups and fixes along the way.
authornotaz <notasas@gmail.com>
Sun, 8 Mar 2009 22:49:51 +0000 (22:49 +0000)
committernotaz <notasas@gmail.com>
Sun, 8 Mar 2009 22:49:51 +0000 (22:49 +0000)
git-svn-id: file:///home/notaz/opt/svn/PicoDrive/platform@650 be3aeb3a-fb24-0410-a615-afba39da0efa

common/input.c
common/menu.h
gp2x/main.c
pandora/Makefile
pandora/emu.c
pandora/main.c
pandora/pandora.c

index 0f6b6e4..81f6e16 100644 (file)
@@ -257,8 +257,8 @@ int in_update_keycode(int *dev_id_out, int *is_down_out, int timeout_ms)
        int result = -1, dev_id = 0, is_down, result_menu;
        int fds_hnds[IN_MAX_DEVS];
        int i, ret, count = 0;
+       in_drv_t *drv = NULL;
        unsigned int ticks;
-       in_drv_t *drv;
 
        if (in_have_async_devs) {
                result = in_update_kc_async(&dev_id, &is_down, timeout_ms);
index 3f77603..a3625f8 100644 (file)
@@ -156,6 +156,9 @@ void menu_init(void);
 void text_out16(int x, int y, const char *texto, ...);
 void me_update_msg(const char *msg);
 
+void menu_loop(void);
+int  menu_loop_tray(void);
+
 menu_entry *me_list_get_first(void);
 menu_entry *me_list_get_next(void);
 
index 95a181c..1aad15c 100644 (file)
@@ -62,8 +62,8 @@ void parse_cmd_line(int argc, char *argv[])
                } else {\r
                        /* External Frontend: ROM Name */\r
                        FILE *f;\r
-                       strncpy(rom_fname_reload, argv[x], PATH_MAX);\r
-                       rom_fname_reload[PATH_MAX-1] = 0;\r
+                       strncpy(rom_fname_reload, argv[x], sizeof(rom_fname_reload));\r
+                       rom_fname_reload[sizeof(rom_fname_reload) - 1] = 0;\r
                        f = fopen(rom_fname_reload, "rb");\r
                        if (f) fclose(f);\r
                        else unrecognized = 1;\r
index a8f552c..02ef609 100644 (file)
@@ -52,13 +52,13 @@ LD = $(CROSS)ld
 OBJCOPY = $(CROSS)objcopy\r
 \r
 # frontend\r
-OBJS += pandora.o main.o emu.o asm_utils.o platform/gp2x/menu.o\r
+OBJS += pandora.o main.o emu.o asm_utils.o plat.o\r
 \r
 # common\r
 OBJS += platform/common/emu.o platform/common/menu.o platform/common/fonts.o platform/common/config.o \\r
        platform/common/arm_utils.o platform/common/mp3_helix.o platform/common/arm_linux.o \\r
        platform/common/readpng.o platform/common/input.o platform/linux/in_evdev.o \\r
-       platform/linux/sndout_oss.o\r
+       platform/linux/sndout_oss.o platform/linux/plat.o\r
 \r
 # Pico\r
 ifeq "$(amalgamate)" "1"\r
index 673c963..3b9e62c 100644 (file)
 \r
 #include <stdarg.h>\r
 \r
-#include "../gp2x/emu.h"\r
-#include "../gp2x/menu.h"\r
-#include "../gp2x/gp2x.h"\r
 #include "../common/arm_utils.h"\r
 #include "../common/fonts.h"\r
 #include "../common/emu.h"\r
+#include "../common/menu.h"\r
 #include "../common/config.h"\r
 #include "../common/common.h"\r
 #include "../common/input.h"\r
@@ -182,7 +180,7 @@ void osd_text(int x, int y, const char *text)
                x &= ~3; // align x\r
                len = (len+3) >> 2;\r
                for (h = 0; h < 8; h++) {\r
-                       p = (int *) ((unsigned char *) gp2x_screen+x+g_screen_width*(y+h));\r
+                       p = (int *) ((unsigned char *) g_screen_ptr+x+g_screen_width*(y+h));\r
                        for (i = len; i; i--, p++) *p = 0xe0e0e0e0;\r
                }\r
                emu_textOut8(x, y, text);\r
@@ -191,7 +189,7 @@ void osd_text(int x, int y, const char *text)
                x &= ~1; // align x\r
                len++;\r
                for (h = 0; h < 16; h++) {\r
-                       p = (int *) ((unsigned short *) gp2x_screen+x+g_screen_width*(y+h));\r
+                       p = (int *) ((unsigned short *) g_screen_ptr+x+g_screen_width*(y+h));\r
                        for (i = len; i; i--, p++) *p = 0;//(*p>>2)&0x39e7;\r
                }\r
                textOut16(x, y, text);\r
@@ -209,15 +207,15 @@ static void draw_cd_leds(void)
                // 8-bit modes\r
                unsigned int col_g = (old_reg & 2) ? 0xc0c0c0c0 : 0xe0e0e0e0;\r
                unsigned int col_r = (old_reg & 1) ? 0xd0d0d0d0 : 0xe0e0e0e0;\r
-               *(unsigned int *)((char *)gp2x_screen + g_screen_width*2+ 4) =\r
-               *(unsigned int *)((char *)gp2x_screen + g_screen_width*3+ 4) =\r
-               *(unsigned int *)((char *)gp2x_screen + g_screen_width*4+ 4) = col_g;\r
-               *(unsigned int *)((char *)gp2x_screen + g_screen_width*2+12) =\r
-               *(unsigned int *)((char *)gp2x_screen + g_screen_width*3+12) =\r
-               *(unsigned int *)((char *)gp2x_screen + g_screen_width*4+12) = col_r;\r
+               *(unsigned int *)((char *)g_screen_ptr + g_screen_width*2+ 4) =\r
+               *(unsigned int *)((char *)g_screen_ptr + g_screen_width*3+ 4) =\r
+               *(unsigned int *)((char *)g_screen_ptr + g_screen_width*4+ 4) = col_g;\r
+               *(unsigned int *)((char *)g_screen_ptr + g_screen_width*2+12) =\r
+               *(unsigned int *)((char *)g_screen_ptr + g_screen_width*3+12) =\r
+               *(unsigned int *)((char *)g_screen_ptr + g_screen_width*4+12) = col_r;\r
        } else {\r
                // 16-bit modes\r
-               unsigned int *p = (unsigned int *)((short *)gp2x_screen + g_screen_width*2+4);\r
+               unsigned int *p = (unsigned int *)((short *)g_screen_ptr + g_screen_width*2+4);\r
                unsigned int col_g = (old_reg & 2) ? 0x06000600 : 0;\r
                unsigned int col_r = (old_reg & 1) ? 0xc000c000 : 0;\r
                *p++ = col_g; *p++ = col_g; p+=2; *p++ = col_r; *p++ = col_r; p += g_screen_width/2 - 12/2;\r
@@ -228,7 +226,7 @@ static void draw_cd_leds(void)
 \r
 static void draw_pico_ptr(void)\r
 {\r
-       unsigned short *p = (unsigned short *)gp2x_screen;\r
+       unsigned short *p = (unsigned short *)g_screen_ptr;\r
 \r
        // only if pen enabled and for 16bit modes\r
        if (pico_inp_mode == 0 || (PicoOpt&0x10) || !(currentConfig.EmuOpt&0x80)) return;\r
@@ -250,9 +248,9 @@ static void draw_pico_ptr(void)
 static int EmuScanBegin16(unsigned int num)\r
 {\r
        if (!(Pico.video.reg[1]&8)) num += 8;\r
-       DrawLineDest = (unsigned short *)gp2x_screen + num*800 + 800/2 - 320/2;\r
+       DrawLineDest = (unsigned short *)g_screen_ptr + num*800 + 800/2 - 320/2;\r
        //int w = (Pico.video.reg[12]&1) ? 320 : 256;\r
-       //DrawLineDest = (unsigned short *)gp2x_screen + num*w;\r
+       //DrawLineDest = (unsigned short *)g_screen_ptr + num*w;\r
 \r
        return 0;\r
 }\r
@@ -268,7 +266,7 @@ static int EmuScanEnd16(unsigned int num)
        int len, mask = 0xff;\r
 \r
        if (!(Pico.video.reg[1]&8)) num += 8;\r
-       pd=(unsigned short *)gp2x_screen + num*800*2 + 800/2 - 320*2/2;\r
+       pd=(unsigned short *)g_screen_ptr + num*800*2 + 800/2 - 320*2/2;\r
 \r
        if (Pico.m.dirtyPal)\r
                PicoDoHighPal555(sh);\r
@@ -301,14 +299,6 @@ static int EmuScanEnd16(unsigned int num)
 \r
 #endif // USE_320_SCREEN\r
 \r
-static int EmuScanBegin8(unsigned int num)\r
-{\r
-       if (!(Pico.video.reg[1]&8)) num += 8;\r
-       DrawLineDest = (unsigned char *)  gp2x_screen + g_screen_width * num;\r
-\r
-       return 0;\r
-}\r
-\r
 int localPal[0x100];\r
 static void (*vidCpyM2)(void *dest, void *src) = NULL;\r
 \r
@@ -323,13 +313,13 @@ static void blit(const char *fps, const char *notice)
                        Pico.m.dirtyPal = 0;\r
                        vidConvCpyRGB32(localPal, Pico.cram, 0x40);\r
                        // feed new palette to our device\r
-                       gp2x_video_setpalette(localPal, 0x40);\r
+                       // gp2x_video_setpalette(localPal, 0x40);\r
                }\r
                // a hack for VR\r
                if (PicoRead16Hook == PicoSVPRead16)\r
                        memset32((int *)(PicoDraw2FB+328*8+328*223), 0xe0e0e0e0, 328);\r
                // do actual copy\r
-               vidCpyM2((unsigned char *)gp2x_screen+g_screen_width*8, PicoDraw2FB+328*8);\r
+               vidCpyM2((unsigned char *)g_screen_ptr+g_screen_width*8, PicoDraw2FB+328*8);\r
        }\r
        else if (!(emu_opt&0x80))\r
        {\r
@@ -362,7 +352,7 @@ static void blit(const char *fps, const char *notice)
                                localPal[0xe0] = 0x00000000; // reserved pixels for OSD\r
                                localPal[0xf0] = 0x00ffffff;\r
                        }\r
-                       gp2x_video_setpalette(localPal, pallen);\r
+                       // gp2x_video_setpalette(localPal, pallen);\r
                }\r
        }\r
 \r
@@ -377,33 +367,24 @@ static void blit(const char *fps, const char *notice)
                draw_cd_leds();\r
        if (PicoAHW & PAHW_PICO)\r
                draw_pico_ptr();\r
-{\r
-//static int u=0;\r
-//memset((char *)gp2x_screen+800*471*2, (u++)>>1, 800*9*2);\r
-}\r
 \r
        //gp2x_video_wait_vsync();\r
-       gp2x_video_flip();\r
+       // gp2x_video_flip();\r
 }\r
 \r
 \r
 // clears whole screen or just the notice area (in all buffers)\r
 static void clearArea(int full)\r
 {\r
-       if ((PicoOpt&0x10)||!(currentConfig.EmuOpt&0x80)) {\r
-               // 8-bit renderers\r
-               if (full) gp2x_memset_all_buffers(0, 0xe0, g_screen_width*240);\r
-               else      gp2x_memset_all_buffers(g_screen_width*232, 0xe0, g_screen_width*8);\r
-       } else {\r
-               // 16bit accurate renderer\r
-               if (full) gp2x_memset_all_buffers(0, 0, g_screen_width*g_screen_height*2);\r
-               else      gp2x_memset_all_buffers(g_screen_width*(g_screen_height-16)*2, 0, g_screen_width*16*2);\r
-       }\r
+       if (full) memset(g_screen_ptr, 0, g_screen_width*g_screen_height*2);\r
+       else      memset((short *)g_screen_ptr + g_screen_width * (g_screen_height - 16), 0,\r
+                       g_screen_width * 16 * 2);\r
 }\r
 \r
 \r
 static void vidResetMode(void)\r
 {\r
+#if 0\r
        if (PicoOpt&0x10) {\r
                gp2x_video_changemode(8);\r
        } else if (currentConfig.EmuOpt&0x80) {\r
@@ -435,27 +416,37 @@ static void vidResetMode(void)
        if (currentConfig.scaling == 2 && !(Pico.video.reg[1]&8))\r
             gp2x_video_RGB_setscaling(8, (PicoOpt&0x100)&&!(Pico.video.reg[12]&1) ? 256 : 320, 224);\r
        else gp2x_video_RGB_setscaling(0, (PicoOpt&0x100)&&!(Pico.video.reg[12]&1) ? 256 : 320, 240);\r
+#else\r
+#ifdef USE_320_SCREEN\r
+       PicoDrawSetColorFormat(1);\r
+       PicoScanBegin = EmuScanBegin16;\r
+#else\r
+       PicoDrawSetColorFormat(-1);\r
+       PicoScanEnd = EmuScanEnd16;\r
+#endif\r
+#endif\r
 }\r
 \r
 \r
 static void emu_msg_cb(const char *msg)\r
 {\r
+/*\r
        if ((PicoOpt&0x10)||!(currentConfig.EmuOpt&0x80)) {\r
                // 8-bit renderers\r
                gp2x_memset_all_buffers(g_screen_width*(g_screen_height-16), 0xe0, g_screen_width*16);\r
                osd_text(4, g_screen_height-16, msg);\r
-               gp2x_memcpy_all_buffers((char *)gp2x_screen+g_screen_width*(g_screen_height-16),\r
+               gp2x_memcpy_all_buffers((char *)g_screen_ptr+g_screen_width*(g_screen_height-16),\r
                        g_screen_width*(g_screen_height-16), g_screen_width*16);\r
        } else {\r
                // 16bit accurate renderer\r
                gp2x_memset_all_buffers(g_screen_width*(g_screen_height-16)*2, 0, g_screen_width*16*2);\r
                osd_text(4, g_screen_height-16, msg);\r
-               gp2x_memcpy_all_buffers((char *)gp2x_screen+g_screen_width*(g_screen_height-16)*2,\r
+               gp2x_memcpy_all_buffers((char *)g_screen_ptr+g_screen_width*(g_screen_height-16)*2,\r
                        g_screen_width*(g_screen_height-16)*2, g_screen_width*16*2);\r
        }\r
        gettimeofday(&noticeMsgTime, 0);\r
        noticeMsgTime.tv_sec -= 2;\r
-\r
+*/\r
        /* assumption: emu_msg_cb gets called only when something slow is about to happen */\r
        reset_timing = 1;\r
 }\r
@@ -582,7 +573,7 @@ static void RunEvents(unsigned int which)
                if (do_it) {\r
                        osd_text(4, g_screen_height-16, (which & 0x1000) ? "LOADING GAME" : "SAVING GAME");\r
                        PicoStateProgressCB = emu_state_cb;\r
-                       gp2x_memcpy_all_buffers(gp2x_screen, 0, g_screen_width*g_screen_height*2);\r
+                       //gp2x_memcpy_all_buffers(g_screen_ptr, 0, g_screen_width*g_screen_height*2);\r
                        emu_SaveLoadGame((which & 0x1000) >> 12, 0);\r
                        PicoStateProgressCB = NULL;\r
                }\r
@@ -707,7 +698,7 @@ void emu_forcedFrame(int opts)
                clearArea(1);\r
        } else  vidCpyM2 = vidCpyM2_40col;\r
 \r
-       vidCpyM2((unsigned char *)gp2x_screen+g_screen_width*8, PicoDraw2FB+328*8);\r
+       vidCpyM2((unsigned char *)g_screen_ptr+g_screen_width*8, PicoDraw2FB+328*8);\r
        vidConvCpyRGB32(localPal, Pico.cram, 0x40);\r
        gp2x_video_setpalette(localPal, 0x40);\r
 */\r
@@ -806,7 +797,7 @@ void emu_Loop(void)
        // calc vsync offset to sync timing code with vsync\r
        if (currentConfig.EmuOpt&0x2000) {\r
                gettimeofday(&tval, 0);\r
-               gp2x_video_wait_vsync();\r
+               //gp2x_video_wait_vsync();\r
                gettimeofday(&tval, 0);\r
                vsync_offset = tval.tv_usec;\r
                while (vsync_offset >= target_frametime)\r
@@ -863,9 +854,9 @@ void emu_Loop(void)
                                        vidCpyM2 = vidCpyM2_32col;\r
                                }\r
                        }\r
-                       if (currentConfig.scaling == 2 && !(modes&8)) // want vertical scaling and game is not in 240 line mode\r
-                            gp2x_video_RGB_setscaling(8, scalex, 224);\r
-                       else gp2x_video_RGB_setscaling(0, scalex, 240);\r
+                       //if (currentConfig.scaling == 2 && !(modes&8)) // want vertical scaling and game is not in 240 line mode\r
+                       //      gp2x_video_RGB_setscaling(8, scalex, 224);\r
+                       // else gp2x_video_RGB_setscaling(0, scalex, 240);\r
                        oldmodes = modes;\r
                        clearArea(1);\r
                }\r
@@ -966,7 +957,7 @@ void emu_Loop(void)
                                if (vsync_offset) {\r
                                        if (lim_time - tval.tv_usec > target_frametime/2)\r
                                                simpleWait(pthissec, lim_time - target_frametime/4);\r
-                                       gp2x_video_wait_vsync();\r
+                                       // gp2x_video_wait_vsync();\r
                                } else {\r
                                        simpleWait(pthissec, lim_time);\r
                                }\r
index 51f7f8e..37a69fe 100644 (file)
 #include <strings.h>\r
 #include <linux/limits.h>\r
 \r
-#include "../gp2x/gp2x.h"\r
-#include "../gp2x/menu.h"\r
+#include "../gp2x/emu.h" // TODO rm\r
 #include "../common/menu.h"\r
 #include "../common/emu.h"\r
 #include "../common/config.h"\r
 #include "../common/input.h"\r
-#include "../gp2x/emu.h"\r
 #include "../gp2x/version.h"\r
+#include "pandora.h"\r
 \r
 \r
-extern int select_exits;\r
 extern char *PicoConfigFile;\r
 static int load_state_slot = -1;\r
-int mmuhack_status = 0; // TODO rm\r
 char **g_argv;\r
 \r
 void parse_cmd_line(int argc, char *argv[])\r
@@ -37,9 +34,6 @@ void parse_cmd_line(int argc, char *argv[])
                        if(strcasecmp(argv[x], "-config") == 0) {\r
                                if(x+1 < argc) { ++x; PicoConfigFile = argv[x]; }\r
                        }\r
-                       else if(strcasecmp(argv[x], "-selectexit") == 0) {\r
-                               select_exits = 1;\r
-                       }\r
                        else if(strcasecmp(argv[x], "-loadstate") == 0) {\r
                                if(x+1 < argc) { ++x; load_state_slot = atoi(argv[x]); }\r
                        }\r
@@ -50,8 +44,8 @@ void parse_cmd_line(int argc, char *argv[])
                } else {\r
                        /* External Frontend: ROM Name */\r
                        FILE *f;\r
-                       strncpy(rom_fname_reload, argv[x], PATH_MAX);\r
-                       rom_fname_reload[PATH_MAX-1] = 0;\r
+                       strncpy(rom_fname_reload, argv[x], sizeof(rom_fname_reload));\r
+                       rom_fname_reload[sizeof(rom_fname_reload) - 1] = 0;\r
                        f = fopen(rom_fname_reload, "rb");\r
                        if (f) fclose(f);\r
                        else unrecognized = 1;\r
@@ -61,14 +55,11 @@ void parse_cmd_line(int argc, char *argv[])
        }\r
 \r
        if (unrecognized) {\r
-               printf("\n\n\nPicoDrive v" VERSION " (c) notaz, 2006-2008\n");\r
+               printf("\n\n\nPicoDrive v" VERSION " (c) notaz, 2006-2009\n");\r
                printf("usage: %s [options] [romfile]\n", argv[0]);\r
                printf( "options:\n"\r
-                               "-menu <menu_path> launch a custom program on exit instead of default gp2xmenu\n"\r
-                               "-state <param>    pass '-state param' to the menu program\n"\r
                                "-config <file>    use specified config file instead of default 'picoconfig.bin'\n"\r
                                "                  see currentConfig_t structure in emu.h for the file format\n"\r
-                               "-selectexit       pressing SELECT will exit the emu and start 'menu_path'\n"\r
                                "-loadstate <num>  if ROM is specified, try loading slot <num>\n");\r
        }\r
 }\r
@@ -85,7 +76,7 @@ int main(int argc, char *argv[])
 \r
        in_probe();\r
        in_debug_dump();\r
-       gp2x_init();\r
+       pnd_init();\r
        emu_Init();\r
        menu_init();\r
 \r
@@ -141,6 +132,7 @@ int main(int argc, char *argv[])
        endloop:\r
 \r
        emu_Deinit();\r
+       pnd_exit();\r
 \r
        return 0;\r
 }\r
index 6c33e6c..ce9fac6 100644 (file)
@@ -1,4 +1,3 @@
-\r
 #include <stdio.h>\r
 #include <stdlib.h>\r
 #include <stdarg.h>\r
 #include <fcntl.h>\r
 #include <errno.h>\r
 \r
-#include "../gp2x/gp2x.h"\r
 #include "../linux/sndout_oss.h"\r
 #include "../common/arm_linux.h"\r
+#include "../common/emu.h"\r
+#include "pandora.h"\r
 \r
-static volatile unsigned int *memregs = MAP_FAILED;\r
-//static\r
-int memdev = 0;\r
 static int fbdev = -1;\r
 \r
 #define SCREEN_MAP_SIZE (800*480*2)\r
 static void *screen = MAP_FAILED;\r
-void *gp2x_screen;\r
-\r
-\r
-/* video stuff */\r
-void gp2x_video_flip(void)\r
-{\r
-}\r
-\r
-/* doulblebuffered flip */\r
-void gp2x_video_flip2(void)\r
-{\r
-}\r
-\r
-\r
-void gp2x_video_changemode2(int bpp)\r
-{\r
-}\r
-\r
-\r
-void gp2x_video_changemode(int bpp)\r
-{\r
-}\r
-\r
-\r
-void gp2x_video_setpalette(int *pal, int len)\r
-{\r
-}\r
-\r
-\r
-void gp2x_video_RGB_setscaling(int ln_offs, int W, int H)\r
-{\r
-}\r
-\r
-\r
-void gp2x_video_wait_vsync(void)\r
-{\r
-}\r
-\r
-void gp2x_video_flush_cache(void)\r
-{\r
-//     cache_flush_d_inval_i(gp2x_screen, (char *)gp2x_screen + 320*240*2, 0);\r
-}\r
-\r
-void gp2x_memcpy_buffers(int buffers, void *data, int offset, int len)\r
-{\r
-}\r
-\r
-\r
-void gp2x_memcpy_all_buffers(void *data, int offset, int len)\r
-{\r
-}\r
-\r
-\r
-void gp2x_memset_all_buffers(int offset, int byte, int len)\r
-{\r
-       memset((char *)gp2x_screen + offset, byte, len);\r
-}\r
-\r
-\r
-void gp2x_pd_clone_buffer2(void)\r
-{\r
-       memset(gp2x_screen, 0, 800*480*2);\r
-}\r
-\r
-// FIXME\r
-#if 0\r
-static int touchcal[7] = { 6203, 0, -1501397, 0, -4200, 16132680, 65536 };\r
-\r
-typedef struct ucb1x00_ts_event\r
-{\r
-       unsigned short pressure;\r
-       unsigned short x;\r
-       unsigned short y;\r
-       unsigned short pad;\r
-       struct timeval stamp;\r
-} UCB1X00_TS_EVENT;\r
-\r
-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
-               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 zero_seen ? event.pressure : 0;\r
-}\r
-#else\r
-int gp2x_touchpad_read(int *x, int *y) { return -1; }\r
-#endif\r
 \r
 /* common */\r
-void gp2x_init(void)\r
+void pnd_init(void)\r
 {\r
        printf("entering init()\n"); fflush(stdout);\r
 \r
-       memdev = open("/dev/mem", O_RDWR);\r
-       if (memdev == -1)\r
-       {\r
-               perror("open(\"/dev/mem\")");\r
-               exit(1);\r
-       }\r
-/*\r
-       memregs = mmap(0, 0x01000000, PROT_READ|PROT_WRITE, MAP_SHARED, memdev, 0x48000000);\r
-       if (memregs == MAP_FAILED)\r
-       {\r
-               printf("mmap(memregs) failed with %i\n", errno);\r
-               exit(1);\r
-       }\r
-*/\r
        fbdev = open("/dev/fb0", O_RDWR);\r
        if (fbdev == -1)\r
        {\r
@@ -158,7 +39,7 @@ void gp2x_init(void)
                exit(1);\r
        }\r
        printf("fbptr %p\n", screen);\r
-       gp2x_screen = screen;\r
+       g_screen_ptr = screen;\r
 \r
        // snd\r
        sndout_oss_init();\r
@@ -166,14 +47,12 @@ void gp2x_init(void)
        printf("exitting init()\n"); fflush(stdout);\r
 }\r
 \r
-void gp2x_deinit(void)\r
+void pnd_exit(void)\r
 {\r
        if (screen != MAP_FAILED)\r
                munmap(screen, SCREEN_MAP_SIZE);\r
-       if (memregs != MAP_FAILED)\r
-               munmap((void *)memregs, 0x10000);\r
-       close(memdev);\r
-       if (fbdev >= 0)    close(fbdev);\r
+       if (fbdev >= 0)\r
+               close(fbdev);\r
 \r
        sndout_oss_exit();\r
 \r
@@ -192,12 +71,11 @@ void lprintf(const char *fmt, ...)
 \r
 \r
 /* fake GP2X */\r
-int crashed_940 = 0;\r
-\r
+/*\r
 void set_gamma(int g100, int A_SNs_curve) {}\r
 void set_FCLK(unsigned MHZ) {}\r
 void set_LCD_custom_rate(int rate) {}\r
 void unset_LCD_custom_rate(void) {}\r
 void Pause940(int yes) {}\r
 void Reset940(int yes, int bank) {}\r
-\r
+*/\r