0.4 rel?
[fceu.git] / video.c
diff --git a/video.c b/video.c
index 245a6b1..b4e137f 100644 (file)
--- a/video.c
+++ b/video.c
@@ -30,6 +30,9 @@
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
+#ifdef GP2X
+#include <unistd.h>
+#endif
 
 #include "types.h"
 #include "video.h"
@@ -43,20 +46,18 @@ uint8 *XBuf=NULL;
 
 int InitVirtualVideo(void)
 {
- uint32 m;
-
  if(!XBuf)             /* Some driver code may allocate XBuf externally. */
-  if(!(XBuf = (uint8*) (FCEU_malloc((256+16) * 240 + 8))))
+  if(!(XBuf = (uint8*) (FCEU_malloc(320 * 240))))
    return 0;
-
+/*
  if(sizeof(uint8*)==4)
  {
   m=(uint32) XBuf;
   m+=8;m&=0xFFFFFFF8;
   XBuf=(uint8 *)m;
- } 
-
- memset(XBuf,128,272*240);
+ }
+*/
+ memset(XBuf,0,320*240);
  return 1;
 }
 
@@ -116,7 +117,7 @@ int SaveSnapshot(void)
   fputc(b,pp);
  }
  fclose(pp);
+
  return u+1;
 }
 
@@ -166,7 +167,7 @@ int SaveSnapshot(void)
  int x,u,y;
  FILE *pp=NULL;
  uint8 *compmem=NULL;
- uint32 compmemsize=totallines*263+12;
+ unsigned long compmemsize=totallines*263+12;
 
  if(!(compmem=FCEU_malloc(compmemsize)))
   return 0;
@@ -207,7 +208,7 @@ int SaveSnapshot(void)
 
  {
   char pdata[256*3];
-  
+
   //void FCEUD_GetPalette(uint8 i,uint8 *r, unsigned char *g, unsigned char *b);
   for(x=0;x<256;x++)
    FCEUD_GetPalette(x,(uint8*)(pdata+x*3),(unsigned char*)(pdata+x*3+1),(unsigned char*)(pdata+x*3+2));
@@ -231,7 +232,7 @@ int SaveSnapshot(void)
    *dest=0;                    // No filter.
    dest++;
    for(x=256;x;x--,tmp++,dest++)
-    *dest=*tmp;        
+    *dest=*tmp;
    tmp+=16;
   }
 
@@ -249,6 +250,9 @@ int SaveSnapshot(void)
 
  free(compmem);
  fclose(pp);
+#ifdef GP2X
+ sync();
+#endif
 
  return u+1;