partial gmv implementation
authornotaz <notasas@gmail.com>
Mon, 25 Dec 2006 15:17:54 +0000 (15:17 +0000)
committernotaz <notasas@gmail.com>
Mon, 25 Dec 2006 15:17:54 +0000 (15:17 +0000)
git-svn-id: file:///home/notaz/opt/svn/PicoDrive/platform@6 be3aeb3a-fb24-0410-a615-afba39da0efa

gp2x/emu.c
gp2x/menu.c
linux/port_config.h

index 14eadeb..d84b053 100644 (file)
@@ -55,7 +55,6 @@ static int combo_keys = 0, combo_acts = 0;    // keys and actions which need button
 static int gp2x_old_gamma = 100;\r
 static unsigned char *movie_data = NULL;\r
 static int movie_size = 0;\r
-int frame_count = 0;\r
 unsigned char *framebuff = 0;  // temporary buffer for alt renderer\r
 int state_slot = 0;\r
 \r
@@ -246,7 +245,7 @@ int emu_ReloadRom(void)
        if(currentConfig.EmuOpt & 1)\r
                emu_SaveLoadGame(1, 1);\r
 \r
-       frame_count = 0;\r
+       Pico.m.frame_count = 0;\r
 \r
        return 1;\r
 }\r
@@ -713,7 +712,7 @@ static void updateKeys(void)
 \r
        if(movie_data)\r
        {\r
-               int offs = frame_count*3 + 0x40;\r
+               int offs = Pico.m.frame_count*3 + 0x40;\r
                if (offs+3 > movie_size) {\r
                        free(movie_data);\r
                        movie_data = 0;\r
@@ -736,8 +735,6 @@ static void updateKeys(void)
                        PicoPad[1] |= (~movie_data[offs+2] & 0xA0) << 4; // ! MZYX\r
                        if(!(movie_data[offs+2] & 0x10)) PicoPad[1] |= 0x0400; // X\r
                        if(!(movie_data[offs+2] & 0x40)) PicoPad[1] |= 0x0100; // Z\r
-                       if ((PicoPad[0] & 0x80) || (PicoPad[1] & 0x80))\r
-                               printf("%d: start\n", frame_count);\r
                }\r
        }\r
        else\r
@@ -745,7 +742,7 @@ static void updateKeys(void)
                PicoPad[0] = (unsigned short) allActions[0];\r
                PicoPad[1] = (unsigned short) allActions[1];\r
        }\r
-       frame_count++;\r
+       Pico.m.frame_count++;\r
 \r
        events = (allActions[0] | allActions[1]) >> 16;\r
 \r
@@ -995,21 +992,59 @@ void emu_Loop(void)
                updateKeys();\r
                PicoFrame();\r
 \r
+#if 0\r
+if (Pico.m.frame_count == 31563) {\r
+       FILE *f;\r
+       f = fopen("ram_p.bin", "wb");\r
+       if (!f) { printf("!f\n"); exit(1); }\r
+       fwrite(Pico.ram, 1, 0x10000, f);\r
+       fclose(f);\r
+       exit(0);\r
+}\r
+#endif\r
 #if 0\r
                // debug\r
                {\r
-                       static unsigned char oldscr[320*240*2];\r
+                       #define BYTE unsigned char\r
+                       #define WORD unsigned short\r
+                       struct\r
+                       {\r
+                               BYTE IDLength;        /* 00h  Size of Image ID field */\r
+                               BYTE ColorMapType;    /* 01h  Color map type */\r
+                               BYTE ImageType;       /* 02h  Image type code */\r
+                               WORD CMapStart;       /* 03h  Color map origin */\r
+                               WORD CMapLength;      /* 05h  Color map length */\r
+                               BYTE CMapDepth;       /* 07h  Depth of color map entries */\r
+                               WORD XOffset;         /* 08h  X origin of image */\r
+                               WORD YOffset;         /* 0Ah  Y origin of image */\r
+                               WORD Width;           /* 0Ch  Width of image */\r
+                               WORD Height;          /* 0Eh  Height of image */\r
+                               BYTE PixelDepth;      /* 10h  Image pixel size */\r
+                               BYTE ImageDescriptor; /* 11h  Image descriptor byte */\r
+                       } __attribute__((packed)) TGAHEAD;\r
+                       static unsigned short oldscr[320*240];\r
                        FILE *f; char name[128]; int i;\r
-                       for (i = 0; i < 320*240*2; i++)\r
-                               if(oldscr[i] != ((unsigned char *)gp2x_screen)[i]) break;\r
-                       if (i < 320*240*2)\r
+\r
+                       memset(&TGAHEAD, 0, sizeof(TGAHEAD));\r
+                       TGAHEAD.ImageType = 2;\r
+                       TGAHEAD.Width = 320;\r
+                       TGAHEAD.Height = 240;\r
+                       TGAHEAD.PixelDepth = 16;\r
+                       TGAHEAD.ImageDescriptor = 2<<4; // image starts at top-left\r
+\r
+                       #define CONV(X) (((X>>1)&0x7fe0)|(X&0x1f)) // 555?\r
+\r
+                       for (i = 0; i < 320*240; i++)\r
+                               if(oldscr[i] != CONV(((unsigned short *)gp2x_screen)[i])) break;\r
+                       if (i < 320*240)\r
                        {\r
-                               for (i = 0; i < 320*240*2; i++)\r
-                                       oldscr[i] = ((unsigned char *)gp2x_screen)[i];\r
-                               sprintf(name, "%05i.raw", frame_count);\r
+                               for (i = 0; i < 320*240; i++)\r
+                                       oldscr[i] = CONV(((unsigned short *)gp2x_screen)[i]);\r
+                               sprintf(name, "%05i.tga", Pico.m.frame_count);\r
                                f = fopen(name, "wb");\r
                                if (!f) { printf("!f\n"); exit(1); }\r
-                               fwrite(gp2x_screen, 1, 320*240*2, f);\r
+                               fwrite(&TGAHEAD, 1, sizeof(TGAHEAD), f);\r
+                               fwrite(oldscr, 1, 320*240*2, f);\r
                                fclose(f);\r
                        }\r
                }\r
index 6336126..588e0c9 100644 (file)
@@ -603,7 +603,7 @@ static void draw_amenu_options(int menu_sel)
 \r
 static void amenu_loop_options(void)\r
 {\r
-       int menu_sel = 0, menu_sel_max = 11;\r
+       int menu_sel = 0, menu_sel_max = 10;\r
        unsigned long inp = 0;\r
 \r
        for(;;)\r
index b679bab..be76af4 100644 (file)
@@ -12,9 +12,7 @@
 // pico.c
 #define CAN_HANDLE_240_LINES   1
 
-extern int frame_count;
-
-#define dprintf(f,...) printf("%05i: " f "\n",frame_count,##__VA_ARGS__)
+#define dprintf(f,...) printf("%05i: " f "\n",Pico.m.frame_count,##__VA_ARGS__)
 //#define dprintf(x...)
 
 #endif //PORT_CONFIG_H