Added gzip support to windows and linux version

Renamed linux/winintrf.asm to linux/sdlintrf.asm
This commit is contained in:
teuf
2001-04-24 19:59:35 +00:00
parent 49816e69ee
commit e6896ec9f4
7 changed files with 164 additions and 111 deletions

View File

@@ -568,9 +568,7 @@ GetNormalEntries2:
GUIGetEntry2 GUIsfcfind GUIGetEntry2 GUIsfcfind
GUIGetEntry2 GUIswcfind GUIGetEntry2 GUIswcfind
GUIGetEntry2 GUIfigfind GUIGetEntry2 GUIfigfind
%ifdef __GZIP__
GUIGetEntry2 GUIfindGZIP GUIGetEntry2 GUIfindGZIP
%endif
GUIGetEntry2 GUIfind058 GUIGetEntry2 GUIfind058
GUIGetEntry2 GUIfind078 GUIGetEntry2 GUIfind078
GUIGetEntry2 GUIfindUSA GUIGetEntry2 GUIfindUSA
@@ -594,9 +592,7 @@ GetNormalEntries:
GUIGetEntry GUIsfcfind GUIGetEntry GUIsfcfind
GUIGetEntry GUIswcfind GUIGetEntry GUIswcfind
GUIGetEntry GUIfigfind GUIGetEntry GUIfigfind
%ifdef __GZIP__
GUIGetEntry GUIfindGZIP GUIGetEntry GUIfindGZIP
%endif
GUIGetEntry GUIfind058 GUIGetEntry GUIfind058
GUIGetEntry GUIfind078 GUIGetEntry GUIfind078
GUIGetEntry GUIfindUSA GUIGetEntry GUIfindUSA
@@ -758,9 +754,7 @@ GetLoadLfn:
GUIGetEntryLFN GUIsfcfind GUIGetEntryLFN GUIsfcfind
GUIGetEntryLFN GUIswcfind GUIGetEntryLFN GUIswcfind
GUIGetEntryLFN GUIfigfind GUIGetEntryLFN GUIfigfind
%ifdef __GZIP__
GUIGetEntryLFN GUIfindGZIP GUIGetEntryLFN GUIfindGZIP
%endif
GUIGetEntryLFN GUIfind058 GUIGetEntryLFN GUIfind058
GUIGetEntryLFN GUIfind078 GUIGetEntryLFN GUIfind078
GUIGetEntryLFN GUIfindUSA GUIGetEntryLFN GUIfindUSA

View File

@@ -31,6 +31,7 @@ EXTSYM SnowData,SnowVelDist
EXTSYM cvidmode, newengen, cfgnewgfx, GUI16VID EXTSYM cvidmode, newengen, cfgnewgfx, GUI16VID
EXTSYM NewEngEnForce EXTSYM NewEngEnForce
EXTSYM PrintChar EXTSYM PrintChar
EXTSYM TextFile
EXTSYM mode7tab EXTSYM mode7tab
EXTSYM per2exec EXTSYM per2exec
EXTSYM MovieCounter EXTSYM MovieCounter
@@ -3356,6 +3357,7 @@ NEWSYM SaveCombFile
ret ret
NEWSYM loadfile NEWSYM loadfile
mov byte[TextFile], 0
call GetCurDir call GetCurDir
mov byte[InGUI],0 mov byte[InGUI],0
jmp loadfileGUI.nogui jmp loadfileGUI.nogui
@@ -3547,6 +3549,7 @@ NEWSYM loadfile
je .notfailed je .notfailed
mov byte[yesoutofmemory],1 mov byte[yesoutofmemory],1
.notfailed .notfailed
mov byte[TextFile], 1
call PatchIPS call PatchIPS
ret ret
@@ -3997,19 +4000,19 @@ NEWSYM loadfileGUI
cmp byte[eax],0 cmp byte[eax],0
jne .ziploop jne .ziploop
sub eax,4 sub eax,4
cmp byte[eax+1],'.' ; cmp byte[eax+1],'.'
jne .finishzipd2 ; jne .finishzipd2
cmp byte[eax+2],'g' ; cmp byte[eax+2],'g'
je .zokay4 ; je .zokay4
cmp byte[eax+2],'G' ; cmp byte[eax+2],'G'
jne .finishzipd2 ; jne .finishzipd2
.zokay4 ;.zokay4
cmp byte[eax+3],'z' ; cmp byte[eax+3],'z'
je .zokay5 ; je .zokay5
cmp byte[eax+3],'Z' ; cmp byte[eax+3],'Z'
jne .finishzipd2 ; jne .finishzipd2
.zokay5 ;.zokay5
jmp .zokay3 ; jmp .zokay3
.finishzipd2 .finishzipd2
cmp byte[eax],'.' cmp byte[eax],'.'
jne near .finishzipd jne near .finishzipd
@@ -4040,6 +4043,7 @@ NEWSYM loadfileGUI
.zipfail .zipfail
ret ret
.finishzipd .finishzipd
mov byte[TextFile], 0
mov dword[MessageOn],0 mov dword[MessageOn],0
mov byte[loadedfromgui],1 mov byte[loadedfromgui],1
mov byte[Header512],0 mov byte[Header512],0
@@ -4314,6 +4318,7 @@ NEWSYM loadfileGUI
.nosramtof .nosramtof
cmp byte[IPSPatched],0 cmp byte[IPSPatched],0
jne .patched jne .patched
mov byte[TextFile], 1
call PatchIPS call PatchIPS
.patched .patched
ret ret

View File

@@ -1307,7 +1307,7 @@ db '256X224 R WIN ',0 ;2
db '256x224 R FULL',0 ;3 db '256x224 R FULL',0 ;3
db '512X448 R WIN ',0 ;4 db '512X448 R WIN ',0 ;4
db '512X448 DR WIN ',0 ;5 db '512X448 DR WIN ',0 ;5
db '640x480 S WIN ',0 ;6 ;db '640x480 S WIN ',0 ;6
db '640x480 DR FULL',0 ;7 db '640x480 DR FULL',0 ;7
db '640X480 DS FULL',0 ;8 db '640X480 DS FULL',0 ;8
db '640X480 S FULL',0 ;9 db '640X480 S FULL',0 ;9
@@ -1323,22 +1323,22 @@ db '1024x768 DS FULL',0 ;17
; Video Mode Feature Availability (1 = Available, 0 = Not Available) ; Video Mode Feature Availability (1 = Available, 0 = Not Available)
; Left side starts with Video Mode 0 ; Left side starts with Video Mode 0
NEWSYM GUI16VID, db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 ; 16-bit mode NEWSYM GUI16VID, db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 ; 16-bit mode
NEWSYM GUINGVID, db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ; New Graphics Mode Available NEWSYM GUINGVID, db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ; New Graphics Mode Available
NEWSYM GUISLVID, db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ; Scanlines NEWSYM GUISLVID, db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ; Scanlines
NEWSYM GUIINVID, db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ; Interpolation NEWSYM GUIINVID, db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ; Interpolation
NEWSYM GUII2VID, db 0,0,0,0,0,1,0,1,1,0,0,1,0,1,0,1,0,1 ; Interpolation(w) NEWSYM GUII2VID, db 0,0,0,0,0,1,1,1,0,0,1,0,1,0,1,0,1 ; Interpolation(w)
NEWSYM GUIEAVID, db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ; Eagle NEWSYM GUIEAVID, db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ; Eagle
NEWSYM GUIIEVID, db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ; (Interp | Eagle) NEWSYM GUIIEVID, db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ; (Interp | Eagle)
NEWSYM GUIFSVID, db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ; Full Screen NEWSYM GUIFSVID, db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ; Full Screen
NEWSYM GUISSVID, db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ; Small Screen NEWSYM GUISSVID, db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ; Small Screen
NEWSYM GUITBVID, db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ; Triple Buffering NEWSYM GUITBVID, db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ; Triple Buffering
NEWSYM GUIHSVID, db 0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0 ; Half/Quarter Scanlines NEWSYM GUIHSVID, db 0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0 ; Half/Quarter Scanlines
NEWSYM GUI2xVID, db 0,0,0,0,0,1,0,1,1,0,0,1,0,1,0,1,0,1 ; 2xSaI/Super Eagle Engines NEWSYM GUI2xVID, db 0,0,0,0,0,1,1,1,0,0,1,0,1,0,1,0,1 ; 2xSaI/Super Eagle Engines
NEWSYM GUIM7VID, db 0,0,0,0,0,1,0,1,1,0,0,1,0,1,0,1,0,1 ; ?Mode 7 video thing? NEWSYM GUIM7VID, db 0,0,0,0,0,1,1,1,0,0,1,0,1,0,1,0,1 ; ?Mode 7 video thing?
NEWSYM GUIWFVID, db 0,0,0,1,0,0,0,1,1,1,0,0,1,1,0,0,1,1 ; If Windows Full Screen NEWSYM GUIWFVID, db 0,0,0,1,0,0,1,1,1,0,0,1,1,0,0,1,1 ; If Windows Full Screen
NEWSYM GUIDSIZE, db 0,0,0,0,0,1,0,1,1,0,0,1,0,1,0,1,0,1 NEWSYM GUIDSIZE, db 0,0,0,0,0,1,1,1,0,0,1,0,1,0,1,0,1
NEWSYM GUIRATIO, db 0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0 NEWSYM GUIRATIO, db 0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0
SECTION .text SECTION .text

View File

@@ -653,58 +653,54 @@ void initwinvideo(void)
case 6: case 6:
WindowWidth=640; WindowWidth=640;
WindowHeight=480; WindowHeight=480;
SurfaceX=640;
SurfaceY=480;
break; break;
case 7: case 7:
WindowWidth=640; WindowWidth=640;
WindowHeight=480; WindowHeight=480;
SurfaceX=640; SurfaceX=512;
SurfaceY=480; SurfaceY=448;
break; break;
case 8: case 8:
WindowWidth=640; WindowWidth=640;
WindowHeight=480; WindowHeight=480;
SurfaceX=512;
SurfaceY=448;
break; break;
case 9: case 9:
WindowWidth=640; WindowWidth=800;
WindowHeight=480; WindowHeight=600;
break; break;
case 10: case 10:
WindowWidth=800; WindowWidth=800;
WindowHeight=600; WindowHeight=600;
SurfaceX=512;
SurfaceY=448;
break; break;
case 11: case 11:
WindowWidth=800; WindowWidth=800;
WindowHeight=600; WindowHeight=600;
SurfaceX=512;
SurfaceY=448;
break; break;
case 12: case 12:
WindowWidth=800;
WindowHeight=600;
break;
case 13:
WindowWidth=800; WindowWidth=800;
WindowHeight=600; WindowHeight=600;
SurfaceX=512; SurfaceX=512;
SurfaceY=448; SurfaceY=448;
break; break;
case 13:
WindowWidth=1024;
WindowHeight=768;
break;
case 14: case 14:
WindowWidth=1024; WindowWidth=1024;
WindowHeight=768; WindowHeight=768;
SurfaceX=512;
SurfaceY=448;
break; break;
case 15: case 15:
WindowWidth=1024; WindowWidth=1024;
WindowHeight=768; WindowHeight=768;
SurfaceX=512;
SurfaceY=448;
break; break;
case 16: case 16:
WindowWidth=1024;
WindowHeight=768;
break;
case 17:
WindowWidth=1024; WindowWidth=1024;
WindowHeight=768; WindowHeight=768;
SurfaceX=512; SurfaceX=512;
@@ -1770,3 +1766,4 @@ void GetLocalTime(void *pointer)
STUB_FUNCTION; STUB_FUNCTION;
} }
#endif #endif

View File

@@ -18,9 +18,7 @@
#include <stdio.h> #include <stdio.h>
#ifdef __GZIP__
#include <zlib.h> #include <zlib.h>
#endif
#ifdef __LINUX__ #ifdef __LINUX__
#include <sys/types.h> #include <sys/types.h>
@@ -43,11 +41,7 @@
#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;
@@ -97,7 +91,11 @@ DWORD ZFTime;
BYTE * MKPath; BYTE * MKPath;
BYTE * CHPath; BYTE * CHPath;
BYTE * RMPath; BYTE * RMPath;
//Indicate whether the file must be opened using
//zlib or not (used for gzip support)
BYTE TextFile; BYTE TextFile;
// GetDir // GetDir
BYTE * DirName; BYTE * DirName;
DWORD DriveNumber; DWORD DriveNumber;
@@ -124,7 +122,7 @@ DWORD ZOpenFile()
if (TextFile) if (TextFile)
FILEHANDLE[CurrentHandle]=fopen(ZOpenFileName,"rb"); FILEHANDLE[CurrentHandle]=fopen(ZOpenFileName,"rb");
else else
FILEHANDLE[CurrentHandle]=gzopen(ZOpenFileName,"rb"); FILEHANDLE[CurrentHandle]=(FILE *)gzopen(ZOpenFileName,"rb");
if(FILEHANDLE[CurrentHandle]!=NULL) if(FILEHANDLE[CurrentHandle]!=NULL)
{ {
CurrentHandle+=1; CurrentHandle+=1;
@@ -137,7 +135,7 @@ DWORD ZOpenFile()
if (TextFile) if (TextFile)
FILEHANDLE[CurrentHandle]=fopen(ZOpenFileName,"wb"); FILEHANDLE[CurrentHandle]=fopen(ZOpenFileName,"wb");
else else
FILEHANDLE[CurrentHandle]=gzopen(ZOpenFileName,"wb"); FILEHANDLE[CurrentHandle]=(FILE *)gzopen(ZOpenFileName,"wb");
if(FILEHANDLE[CurrentHandle]!=NULL) if(FILEHANDLE[CurrentHandle]!=NULL)
{ {
CurrentHandle+=1; CurrentHandle+=1;

View File

@@ -43,7 +43,7 @@ VIDEOBJ=${VIDEODIR}/makev16b.o ${VIDEODIR}/makev16t.o ${VIDEODIR}/makevid.o\
${VIDEODIR}/m716text.o ${VIDEODIR}/2xsaiw.o\ ${VIDEODIR}/m716text.o ${VIDEODIR}/2xsaiw.o\
${VIDEODIR}/procvid.o ${VIDEODIR}/procvid.o
WINOBJ=${WINDIR}/copyvwin.o ${WINDIR}/winintrf.o ${WINDIR}/sdllink.o\ WINOBJ=${WINDIR}/copyvwin.o ${WINDIR}/sdlintrf.o ${WINDIR}/sdllink.o\
${WINDIR}/zloaderw.o ${WINDIR}/ztcp.o ${WINDIR}/zipxw.o\ ${WINDIR}/zloaderw.o ${WINDIR}/ztcp.o ${WINDIR}/zipxw.o\
${WINDIR}/zfilew.o ${WINDIR}/protect.o ${WINDIR}/zfilew.o ${WINDIR}/protect.o

View File

@@ -21,6 +21,7 @@
#include <io.h> #include <io.h>
#include <direct.h> #include <direct.h>
#include <string.h> #include <string.h>
#include <zlib.h>
#define DWORD unsigned int #define DWORD unsigned int
#define BYTE unsigned char #define BYTE unsigned char
@@ -28,6 +29,9 @@
FILE *FILEHANDLE[16]; FILE *FILEHANDLE[16];
DWORD CurrentHandle=0; DWORD CurrentHandle=0;
//Indicate whether the file must be opened using
//zlib or not (used for gzip support)
BYTE TextFile;
// ZFileSystemInit // ZFileSystemInit
@@ -84,83 +88,138 @@ DWORD DriveNumber;
BYTE * ZFileDelFName; BYTE * ZFileDelFName;
// return current position // return current position
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]=(FILE *)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]=(FILE *)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 = ftell(FILEHANDLE[ZFileTellHandle]);
if (res == -1) fprintf(stderr, "Oups!! gzTell\n");
return(res);
} else return gztell(FILEHANDLE[ZFileTellHandle]);
} }
DWORD ZFileDelete() DWORD ZFileDelete()
{ {
return(remove(ZFileDelFName)); return(remove(ZFileDelFName));