Added support for gzipped roms. save states and srm files are also automatically compressed. For the moment, this is only available in the linux version, and you must enable it by defining __GZIP__
This commit is contained in:
@@ -27,8 +27,12 @@ EXTSYM StereoSound,antienab,cvidmode,enterpress,frameskip,guioff
|
|||||||
EXTSYM newengen,per2exec,pl1Ak,pl1Bk,pl1Lk,pl1Rk,pl1Xk,pl1Yk
|
EXTSYM newengen,per2exec,pl1Ak,pl1Bk,pl1Lk,pl1Rk,pl1Xk,pl1Yk
|
||||||
EXTSYM pl1contrl,pl1downk,pl1leftk,pl1rightk,scanlines,soundon
|
EXTSYM pl1contrl,pl1downk,pl1leftk,pl1rightk,scanlines,soundon
|
||||||
EXTSYM spcon,vsyncon,Open_File,Read_File
|
EXTSYM spcon,vsyncon,Open_File,Read_File
|
||||||
EXTSYM Create_File,Write_File,Close_File
|
EXTSYM Create_File,Write_File,Close_File
|
||||||
|
%ifdef __LINUX__
|
||||||
|
; if TextFile==0, zlib functions aren't used
|
||||||
|
; useful to save the config file
|
||||||
|
EXTSYM TextFile
|
||||||
|
%endif
|
||||||
|
|
||||||
NEWSYM CfgLoadAsmStart
|
NEWSYM CfgLoadAsmStart
|
||||||
|
|
||||||
@@ -272,6 +276,9 @@ NEWSYM DOScreatenewcfg
|
|||||||
push ecx
|
push ecx
|
||||||
; Save .CFG file
|
; Save .CFG file
|
||||||
mov edx,CMDLineStr
|
mov edx,CMDLineStr
|
||||||
|
%ifdef _GZIP__
|
||||||
|
mov byte[TextFile], 1
|
||||||
|
%endif
|
||||||
call Create_File
|
call Create_File
|
||||||
pop ecx
|
pop ecx
|
||||||
jc .failed
|
jc .failed
|
||||||
@@ -280,6 +287,9 @@ NEWSYM DOScreatenewcfg
|
|||||||
mov edx,mode7tab
|
mov edx,mode7tab
|
||||||
call Write_File
|
call Write_File
|
||||||
call Close_File
|
call Close_File
|
||||||
|
%ifdef __GZIP__
|
||||||
|
mov byte[TextFile], 0
|
||||||
|
%endif
|
||||||
.failed
|
.failed
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|||||||
@@ -566,6 +566,9 @@ GetNormalEntries2:
|
|||||||
GUIGetEntry2 GUIsfcfind
|
GUIGetEntry2 GUIsfcfind
|
||||||
GUIGetEntry2 GUIswcfind
|
GUIGetEntry2 GUIswcfind
|
||||||
GUIGetEntry2 GUIfigfind
|
GUIGetEntry2 GUIfigfind
|
||||||
|
%ifdef __GZIP__
|
||||||
|
GUIGetEntry2 GUIfindGZIP
|
||||||
|
%endif
|
||||||
GUIGetEntry2 GUIfind058
|
GUIGetEntry2 GUIfind058
|
||||||
GUIGetEntry2 GUIfind078
|
GUIGetEntry2 GUIfind078
|
||||||
GUIGetEntry2 GUIfindUSA
|
GUIGetEntry2 GUIfindUSA
|
||||||
@@ -589,6 +592,9 @@ GetNormalEntries:
|
|||||||
GUIGetEntry GUIsfcfind
|
GUIGetEntry GUIsfcfind
|
||||||
GUIGetEntry GUIswcfind
|
GUIGetEntry GUIswcfind
|
||||||
GUIGetEntry GUIfigfind
|
GUIGetEntry GUIfigfind
|
||||||
|
%ifdef __GZIP__
|
||||||
|
GUIGetEntry GUIfindGZIP
|
||||||
|
%endif
|
||||||
GUIGetEntry GUIfind058
|
GUIGetEntry GUIfind058
|
||||||
GUIGetEntry GUIfind078
|
GUIGetEntry GUIfind078
|
||||||
GUIGetEntry GUIfindUSA
|
GUIGetEntry GUIfindUSA
|
||||||
@@ -750,6 +756,9 @@ GetLoadLfn:
|
|||||||
GUIGetEntryLFN GUIsfcfind
|
GUIGetEntryLFN GUIsfcfind
|
||||||
GUIGetEntryLFN GUIswcfind
|
GUIGetEntryLFN GUIswcfind
|
||||||
GUIGetEntryLFN GUIfigfind
|
GUIGetEntryLFN GUIfigfind
|
||||||
|
%ifdef __GZIP__
|
||||||
|
GUIGetEntryLFN GUIfindGZIP
|
||||||
|
%endif
|
||||||
GUIGetEntryLFN GUIfind058
|
GUIGetEntryLFN GUIfind058
|
||||||
GUIGetEntryLFN GUIfind078
|
GUIGetEntryLFN GUIfind078
|
||||||
GUIGetEntryLFN GUIfindUSA
|
GUIGetEntryLFN GUIfindUSA
|
||||||
|
|||||||
@@ -17,6 +17,11 @@
|
|||||||
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#ifdef __GZIP__
|
||||||
|
#include <zlib.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __LINUX__
|
#ifdef __LINUX__
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
@@ -37,7 +42,13 @@
|
|||||||
#define STUB_FUNCTION fprintf(stderr,"STUB: %s at " __FILE__ ", line %d, thread %d\n",__FUNCTION__,__LINE__,getpid())
|
#define STUB_FUNCTION fprintf(stderr,"STUB: %s at " __FILE__ ", line %d, thread %d\n",__FUNCTION__,__LINE__,getpid())
|
||||||
#endif
|
#endif
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
|
#ifdef __GZIP__
|
||||||
|
gzFile *FILEHANDLE[16];
|
||||||
|
#else
|
||||||
FILE *FILEHANDLE[16];
|
FILE *FILEHANDLE[16];
|
||||||
|
#endif
|
||||||
|
|
||||||
DWORD CurrentHandle=0;
|
DWORD CurrentHandle=0;
|
||||||
|
|
||||||
|
|
||||||
@@ -86,7 +97,7 @@ DWORD ZFTime;
|
|||||||
BYTE * MKPath;
|
BYTE * MKPath;
|
||||||
BYTE * CHPath;
|
BYTE * CHPath;
|
||||||
BYTE * RMPath;
|
BYTE * RMPath;
|
||||||
|
BYTE TextFile;
|
||||||
// GetDir
|
// GetDir
|
||||||
BYTE * DirName;
|
BYTE * DirName;
|
||||||
DWORD DriveNumber;
|
DWORD DriveNumber;
|
||||||
@@ -97,79 +108,132 @@ BYTE * ZFileDelFName;
|
|||||||
|
|
||||||
DWORD ZFileSystemInit()
|
DWORD ZFileSystemInit()
|
||||||
{
|
{
|
||||||
CurrentHandle=0;
|
#ifdef __GZIP__
|
||||||
return(0);
|
TextFile = 0;
|
||||||
|
#else
|
||||||
|
TextFile = 1;
|
||||||
|
#endif
|
||||||
|
CurrentHandle=0;
|
||||||
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD ZOpenFile()
|
DWORD ZOpenFile()
|
||||||
{
|
{
|
||||||
if(ZOpenMode==0)
|
if(ZOpenMode==0)
|
||||||
{
|
{
|
||||||
if((FILEHANDLE[CurrentHandle]=fopen(ZOpenFileName,"rb"))!=NULL)
|
if (TextFile)
|
||||||
{
|
FILEHANDLE[CurrentHandle]=fopen(ZOpenFileName,"rb");
|
||||||
CurrentHandle+=1;
|
else
|
||||||
return(CurrentHandle-1);
|
FILEHANDLE[CurrentHandle]=gzopen(ZOpenFileName,"rb");
|
||||||
}
|
if(FILEHANDLE[CurrentHandle]!=NULL)
|
||||||
return(0xFFFFFFFF);
|
{
|
||||||
}
|
CurrentHandle+=1;
|
||||||
if(ZOpenMode==1)
|
return(CurrentHandle-1);
|
||||||
{
|
}
|
||||||
if((FILEHANDLE[CurrentHandle]=fopen(ZOpenFileName,"wb"))!=NULL)
|
return(0xFFFFFFFF);
|
||||||
{
|
}
|
||||||
CurrentHandle+=1;
|
if(ZOpenMode==1)
|
||||||
return(CurrentHandle-1);
|
{
|
||||||
}
|
if (TextFile)
|
||||||
return(0xFFFFFFFF);
|
FILEHANDLE[CurrentHandle]=fopen(ZOpenFileName,"wb");
|
||||||
}
|
else
|
||||||
if(ZOpenMode==2)
|
FILEHANDLE[CurrentHandle]=gzopen(ZOpenFileName,"wb");
|
||||||
{
|
if(FILEHANDLE[CurrentHandle]!=NULL)
|
||||||
if((FILEHANDLE[CurrentHandle]=fopen(ZOpenFileName,"r+b"))!=NULL)
|
{
|
||||||
{
|
CurrentHandle+=1;
|
||||||
CurrentHandle+=1;
|
return(CurrentHandle-1);
|
||||||
return(CurrentHandle-1);
|
}
|
||||||
}
|
return(0xFFFFFFFF);
|
||||||
return(0xFFFFFFFF);
|
}
|
||||||
}
|
if(ZOpenMode==2)
|
||||||
return(0xFFFFFFFF);
|
{
|
||||||
|
if (TextFile)
|
||||||
|
FILEHANDLE[CurrentHandle]=fopen(ZOpenFileName,"r+b");
|
||||||
|
else
|
||||||
|
FILEHANDLE[CurrentHandle]=gzopen(ZOpenFileName,"r+b");
|
||||||
|
if(FILEHANDLE[CurrentHandle]!=NULL)
|
||||||
|
{
|
||||||
|
CurrentHandle+=1;
|
||||||
|
return(CurrentHandle-1);
|
||||||
|
}
|
||||||
|
return(0xFFFFFFFF);
|
||||||
|
}
|
||||||
|
return(0xFFFFFFFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD ZCloseFile()
|
DWORD ZCloseFile()
|
||||||
{
|
{
|
||||||
fclose(FILEHANDLE[ZCloseFileHandle]);
|
if (TextFile)
|
||||||
CurrentHandle-=1;
|
fclose(FILEHANDLE[ZCloseFileHandle]);
|
||||||
return(0);
|
else
|
||||||
|
gzclose(FILEHANDLE[ZCloseFileHandle]);
|
||||||
|
CurrentHandle-=1;
|
||||||
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD ZFileSeek()
|
DWORD ZFileSeek()
|
||||||
{
|
{
|
||||||
if(ZFileSeekMode==0)
|
int res = 0;
|
||||||
{
|
int mode = 0;
|
||||||
fseek(FILEHANDLE[ZFileSeekHandle],ZFileSeekPos,SEEK_SET);
|
if (ZFileSeekMode==0)
|
||||||
return(0);
|
mode = SEEK_SET;
|
||||||
}
|
else if (ZFileSeekMode==1) {
|
||||||
if(ZFileSeekMode==1)
|
mode = SEEK_END;
|
||||||
{
|
if (TextFile==0)
|
||||||
fseek(FILEHANDLE[ZFileSeekHandle],ZFileSeekPos,SEEK_END);
|
printf("Warning : gzseek(SEEK_END) not supported");
|
||||||
return(0);
|
} else return (0xFFFFFFFF);
|
||||||
}
|
|
||||||
return(0xFFFFFFFF);
|
if (TextFile) {
|
||||||
|
fseek(FILEHANDLE[ZFileSeekHandle], ZFileSeekPos, mode);
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
gzseek(FILEHANDLE[ZFileSeekHandle], ZFileSeekPos, mode);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return(0xFFFFFFFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD ZFileRead()
|
DWORD ZFileRead()
|
||||||
{
|
{
|
||||||
return(fread(ZFileReadBlock,1,ZFileReadSize,FILEHANDLE[ZFileReadHandle]));
|
if (TextFile)
|
||||||
|
return(fread(ZFileReadBlock,
|
||||||
|
1,
|
||||||
|
ZFileReadSize,
|
||||||
|
FILEHANDLE[ZFileReadHandle]));
|
||||||
|
else
|
||||||
|
return(gzread(FILEHANDLE[ZFileReadHandle],
|
||||||
|
ZFileReadBlock,
|
||||||
|
ZFileReadSize));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DWORD ZFileWrite()
|
DWORD ZFileWrite()
|
||||||
{
|
{
|
||||||
if((fwrite(ZFileWriteBlock,1,ZFileWriteSize,FILEHANDLE[ZFileWriteHandle]))!=ZFileWriteSize) return(0xFFFFFFFF);
|
int res=0;
|
||||||
return(0);
|
if (TextFile)
|
||||||
|
res = fwrite(ZFileWriteBlock,
|
||||||
|
1,
|
||||||
|
ZFileWriteSize,
|
||||||
|
FILEHANDLE[ZFileWriteHandle]);
|
||||||
|
else
|
||||||
|
res = gzwrite(FILEHANDLE[ZFileWriteHandle],
|
||||||
|
ZFileWriteBlock,
|
||||||
|
ZFileWriteSize);
|
||||||
|
|
||||||
|
if (res!=ZFileWriteSize)
|
||||||
|
return(0xFFFFFFFF);
|
||||||
|
|
||||||
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD ZFileTell()
|
DWORD ZFileTell()
|
||||||
{
|
{
|
||||||
return(ftell(FILEHANDLE[ZFileTellHandle]));
|
int res = 0;
|
||||||
|
if (TextFile) {
|
||||||
|
res = gztell(FILEHANDLE[ZFileTellHandle]);
|
||||||
|
if (res == -1) fprintf(stderr, "Oups!! gzTell\n");
|
||||||
|
return(res);
|
||||||
|
} else return gztell(FILEHANDLE[ZFileTellHandle]);
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD ZFileDelete()
|
DWORD ZFileDelete()
|
||||||
|
|||||||
Reference in New Issue
Block a user