Cleaned up the DOS port a bit.

This commit is contained in:
stainless
2001-08-29 03:39:25 +00:00
parent 85d5849d7e
commit dd8da1dcfd
4 changed files with 1259 additions and 1232 deletions

View File

@@ -1,323 +1,334 @@
//Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com ) //Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com )
// //
//This program is free software; you can redistribute it and/or //This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License //modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either //as published by the Free Software Foundation; either
//version 2 of the License, or (at your option) any later //version 2 of the License, or (at your option) any later
//version. //version.
// //
//This program is distributed in the hope that it will be useful, //This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of //but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details. //GNU General Public License for more details.
// //
//You should have received a copy of the GNU General Public License //You should have received a copy of the GNU General Public License
//along with this program; if not, write to the Free Software //along with this program; if not, write to the Free Software
//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#include <stdio.h> #include <stdio.h>
#include <time.h> #include <time.h>
#include <zlib.h> #include <zlib.h>
#ifdef ZDOS #include <dos.h>
#include <dos.h> #include <fcntl.h>
#endif #include <share.h>
#include <sys/stat.h>
#include <unistd.h>
#define DWORD unsigned int /* #ifdef ZDOS
#define BYTE unsigned char #include <dos.h>
#endif */
FILE *FILEHANDLE[16];
DWORD CurrentHandle=0;
#define DWORD unsigned int
//Indicate whether the file must be opened using #define BYTE unsigned char
//zlib or not (used for gzip support)
BYTE TextFile; FILE *FILEHANDLE[16];
DWORD CurrentHandle=0;
// ZFileSystemInit //Indicate whether the file must be opened using
// return 0 //zlib or not (used for gzip support)
BYTE TextFile;
// ZOpenFile info :
BYTE * ZOpenFileName;
DWORD ZOpenMode; // ZFileSystemInit
// Open modes : 0 read/write in // return 0
// 1 write (create file, overwrite)
// return file handle if success, 0xFFFFFFFF if error // ZOpenFile info :
BYTE * ZOpenFileName;
// ZCloseFile info : DWORD ZOpenMode;
DWORD ZCloseFileHandle; // Open modes : 0 read/write in
// return 0 // 1 write (create file, overwrite)
// return file handle if success, 0xFFFFFFFF if error
// ZFileSeek info :
DWORD ZFileSeekHandle; // ZCloseFile info :
DWORD ZFileSeekPos; DWORD ZCloseFileHandle;
DWORD ZFileSeekMode; // 0 start, 1 end // return 0
// return 0
// ZFileSeek info :
// ZFileReadBlock info : DWORD ZFileSeekHandle;
BYTE * ZFileReadBlock; DWORD ZFileSeekPos;
DWORD ZFileReadSize; DWORD ZFileSeekMode; // 0 start, 1 end
DWORD ZFileReadHandle; // return 0
// return 0
// ZFileReadBlock info :
// ZFileWriteBlock info : BYTE * ZFileReadBlock;
BYTE * ZFileWriteBlock; DWORD ZFileReadSize;
DWORD ZFileWriteSize; DWORD ZFileReadHandle;
DWORD ZFileWriteHandle; // return 0
// return 0
// ZFileWriteBlock info :
// ZFileTell BYTE * ZFileWriteBlock;
DWORD ZFileTellHandle; DWORD ZFileWriteSize;
DWORD ZFileWriteHandle;
// ZFileGetftime // return 0
BYTE * ZFFTimeFName;
DWORD ZFTimeHandle; // ZFileTell
DWORD ZFDate; DWORD ZFileTellHandle;
DWORD ZFTime;
// ZFileGetftime
// MKDir/CHDir BYTE * ZFFTimeFName;
BYTE * MKPath; DWORD ZFTimeHandle;
BYTE * CHPath; DWORD ZFDate;
BYTE * RMPath; DWORD ZFTime;
// GetDir // MKDir/CHDir
BYTE * DirName; BYTE * MKPath;
DWORD DriveNumber; BYTE * CHPath;
BYTE * RMPath;
// ZFileDelete
BYTE * ZFileDelFName; // GetDir
// return current position BYTE * DirName;
DWORD DriveNumber;
DWORD ZFileSystemInit() // ZFileDelete
{ BYTE * ZFileDelFName;
#ifdef __GZIP__ // return current position
TextFile = 0;
#else
TextFile = 1; DWORD ZFileSystemInit()
#endif {
CurrentHandle=0; #ifdef __GZIP__
return(0); TextFile = 0;
} #else
TextFile = 1;
#endif
DWORD ZOpenFile() CurrentHandle=0;
{ return(0);
if(ZOpenMode==0) }
{
if (TextFile)
FILEHANDLE[CurrentHandle]=fopen(ZOpenFileName,"rb"); DWORD ZOpenFile()
else {
FILEHANDLE[CurrentHandle]=(FILE *)gzopen(ZOpenFileName,"rb"); if(ZOpenMode==0)
if(FILEHANDLE[CurrentHandle]!=NULL) {
{ if (TextFile)
CurrentHandle+=1; FILEHANDLE[CurrentHandle]=fopen(ZOpenFileName,"rb");
return(CurrentHandle-1); else
} FILEHANDLE[CurrentHandle]=(FILE *)gzopen(ZOpenFileName,"rb");
return(0xFFFFFFFF); if(FILEHANDLE[CurrentHandle]!=NULL)
} {
if(ZOpenMode==1) CurrentHandle+=1;
{ return(CurrentHandle-1);
if (TextFile) }
FILEHANDLE[CurrentHandle]=fopen(ZOpenFileName,"wb"); return(0xFFFFFFFF);
else }
FILEHANDLE[CurrentHandle]=(FILE *)gzopen(ZOpenFileName,"wb"); if(ZOpenMode==1)
if(FILEHANDLE[CurrentHandle]!=NULL) {
{ if (TextFile)
CurrentHandle+=1; FILEHANDLE[CurrentHandle]=fopen(ZOpenFileName,"wb");
return(CurrentHandle-1); else
} FILEHANDLE[CurrentHandle]=(FILE *)gzopen(ZOpenFileName,"wb");
return(0xFFFFFFFF); if(FILEHANDLE[CurrentHandle]!=NULL)
} {
if(ZOpenMode==2) CurrentHandle+=1;
{ return(CurrentHandle-1);
if (TextFile) }
FILEHANDLE[CurrentHandle]=fopen(ZOpenFileName,"r+b"); return(0xFFFFFFFF);
else }
FILEHANDLE[CurrentHandle]=(FILE *)gzopen(ZOpenFileName,"r+b"); if(ZOpenMode==2)
if(FILEHANDLE[CurrentHandle]!=NULL) {
{ if (TextFile)
CurrentHandle+=1; FILEHANDLE[CurrentHandle]=fopen(ZOpenFileName,"r+b");
return(CurrentHandle-1); else
} FILEHANDLE[CurrentHandle]=(FILE *)gzopen(ZOpenFileName,"r+b");
return(0xFFFFFFFF); if(FILEHANDLE[CurrentHandle]!=NULL)
} {
return(0xFFFFFFFF); CurrentHandle+=1;
} return(CurrentHandle-1);
}
DWORD ZCloseFile() return(0xFFFFFFFF);
{ }
if (TextFile) return(0xFFFFFFFF);
fclose(FILEHANDLE[ZCloseFileHandle]); }
else
gzclose(FILEHANDLE[ZCloseFileHandle]); DWORD ZCloseFile()
CurrentHandle-=1; {
return(0); if (TextFile)
} fclose(FILEHANDLE[ZCloseFileHandle]);
else
DWORD ZFileSeek() gzclose(FILEHANDLE[ZCloseFileHandle]);
{ CurrentHandle-=1;
int res = 0; return(0);
int mode = 0; }
if (ZFileSeekMode==0)
mode = SEEK_SET; DWORD ZFileSeek()
else if (ZFileSeekMode==1) { {
mode = SEEK_END; /*int res = 0;*/
if (TextFile==0) int mode = 0;
printf("Warning : gzseek(SEEK_END) not supported"); if (ZFileSeekMode==0)
} else return (0xFFFFFFFF); mode = SEEK_SET;
else if (ZFileSeekMode==1) {
if (TextFile) { mode = SEEK_END;
fseek(FILEHANDLE[ZFileSeekHandle], ZFileSeekPos, mode); if (TextFile==0)
return 0; printf("Warning : gzseek(SEEK_END) not supported");
} else { } else return (0xFFFFFFFF);
gzseek(FILEHANDLE[ZFileSeekHandle], ZFileSeekPos, mode);
return 0; if (TextFile) {
} fseek(FILEHANDLE[ZFileSeekHandle], ZFileSeekPos, mode);
return(0xFFFFFFFF); return 0;
} } else {
gzseek(FILEHANDLE[ZFileSeekHandle], ZFileSeekPos, mode);
DWORD ZFileRead() return 0;
{ }
if (TextFile) return(0xFFFFFFFF);
return(fread(ZFileReadBlock, }
1,
ZFileReadSize, DWORD ZFileRead()
FILEHANDLE[ZFileReadHandle])); {
else if (TextFile)
return(gzread(FILEHANDLE[ZFileReadHandle], return(fread(ZFileReadBlock,
ZFileReadBlock, 1,
ZFileReadSize)); ZFileReadSize,
} FILEHANDLE[ZFileReadHandle]));
else
return(gzread(FILEHANDLE[ZFileReadHandle],
DWORD ZFileWrite() ZFileReadBlock,
{ ZFileReadSize));
int res=0; }
if (TextFile)
res = fwrite(ZFileWriteBlock,
1, DWORD ZFileWrite()
ZFileWriteSize, {
FILEHANDLE[ZFileWriteHandle]); int res=0;
else if (TextFile)
res = gzwrite(FILEHANDLE[ZFileWriteHandle], res = fwrite(ZFileWriteBlock,
ZFileWriteBlock, 1,
ZFileWriteSize); ZFileWriteSize,
FILEHANDLE[ZFileWriteHandle]);
if (res!=ZFileWriteSize) else
return(0xFFFFFFFF); res = gzwrite(FILEHANDLE[ZFileWriteHandle],
ZFileWriteBlock,
return(0); ZFileWriteSize);
}
if (res!=ZFileWriteSize)
DWORD ZFileTell() return(0xFFFFFFFF);
{
int res = 0; return(0);
if (TextFile) { }
res = ftell(FILEHANDLE[ZFileTellHandle]);
if (res == -1) fprintf(stderr, "Oups!! gzTell\n"); DWORD ZFileTell()
return(res); {
} else return gztell(FILEHANDLE[ZFileTellHandle]); int res = 0;
} if (TextFile) {
res = ftell(FILEHANDLE[ZFileTellHandle]);
DWORD ZFileDelete() if (res == -1) fprintf(stderr, "Oups!! gzTell\n");
{ return(res);
return(remove(ZFileDelFName)); } else return gztell(FILEHANDLE[ZFileTellHandle]);
} }
DWORD ZFileDelete()
DWORD ZFileGetFTime() {
{ return(remove(ZFileDelFName));
_dos_open(ZFFTimeFName, 0,&ZFTimeHandle); }
_dos_getftime(ZFTimeHandle,&ZFDate,&ZFTime);
_dos_close(ZFTimeHandle);
return(0); DWORD ZFileGetFTime()
} {
_dos_open(ZFFTimeFName, 0,&ZFTimeHandle);
DWORD ZFileMKDir() _dos_getftime(ZFTimeHandle,&ZFDate,&ZFTime);
{ _dos_close(ZFTimeHandle);
return(mkdir(MKPath)); return(0);
} }
DWORD ZFileCHDir() DWORD ZFileMKDir()
{ {
return(chdir(CHPath)); /*return(mkdir(MKPath));*/
} return (mkdir(MKPath, S_IWUSR));
}
DWORD ZFileRMDir()
{ DWORD ZFileCHDir()
return(rmdir(RMPath)); {
} return(chdir(CHPath));
}
DWORD ZFileGetDir()
{ DWORD ZFileRMDir()
return(getcwd(DirName,128)); {
} return(rmdir(RMPath));
}
BYTE * ZFileFindPATH;
DWORD ZFileFindATTRIB; DWORD ZFileGetDir()
DWORD DTALocPos; {
/*return(getcwd(DirName,128));*/
//struct _find_t { return(*getcwd(DirName,128));
// char reserved[21] __attribute__((packed)); }
// unsigned char attrib __attribute__((packed));
// unsigned short wr_time __attribute__((packed)); BYTE * ZFileFindPATH;
// unsigned short wr_date __attribute__((packed)); DWORD ZFileFindATTRIB;
// unsigned long size __attribute__((packed)); DWORD DTALocPos;
// char name[256] __attribute__((packed));
//}; //struct _find_t {
// char reserved[21] __attribute__((packed));
DWORD ZFileFindFirst() // unsigned char attrib __attribute__((packed));
{ // unsigned short wr_time __attribute__((packed));
return(_dos_findfirst(ZFileFindPATH,ZFileFindATTRIB,DTALocPos)); // unsigned short wr_date __attribute__((packed));
} // unsigned long size __attribute__((packed));
// char name[256] __attribute__((packed));
DWORD ZFileFindNext() //};
{
return(_dos_findnext(DTALocPos)); DWORD ZFileFindFirst()
} {
/*return(_dos_findfirst(ZFileFindPATH,ZFileFindATTRIB,DTALocPos));*/
DWORD ZFileFindEnd() // for compatibility with windows later return(_dos_findfirst(ZFileFindPATH,ZFileFindATTRIB,((struct find_t *)DTALocPos)));
{
return(0); }
}
DWORD ZFileFindNext()
{
//BYTE * DirName; /*return(_dos_findnext(DTALocPos));*/
//DWORD DriveNumber; return(_dos_findnext(((struct find_t *) DTALocPos)));
}
//unsigned int _dos_findfirst(char *_name, unsigned int _attr, struct _find_t *_result);
//unsigned int _dos_findnext(struct _find_t *_result); DWORD ZFileFindEnd() // for compatibility with windows later
{
return(0);
DWORD GetTime() }
{
DWORD value;
struct tm *newtime; //BYTE * DirName;
time_t long_time; //DWORD DriveNumber;
time( &long_time ); //unsigned int _dos_findfirst(char *_name, unsigned int _attr, struct _find_t *_result);
newtime = localtime( &long_time ); //unsigned int _dos_findnext(struct _find_t *_result);
value = ((newtime->tm_sec) % 10)+((newtime->tm_sec)/10)*16
+((((newtime->tm_min) % 10)+((newtime->tm_min)/10)*16) << 8) DWORD GetTime()
+((((newtime->tm_hour) % 10)+((newtime->tm_hour)/10)*16) << 16); {
return(value); DWORD value;
} struct tm *newtime;
time_t long_time;
DWORD GetDate()
{ time( &long_time );
DWORD value; newtime = localtime( &long_time );
struct tm *newtime;
time_t long_time; value = ((newtime->tm_sec) % 10)+((newtime->tm_sec)/10)*16
+((((newtime->tm_min) % 10)+((newtime->tm_min)/10)*16) << 8)
time( &long_time ); +((((newtime->tm_hour) % 10)+((newtime->tm_hour)/10)*16) << 16);
newtime = localtime( &long_time ); return(value);
value = ((newtime->tm_mday) % 10)+((newtime->tm_mday)/10)*16 }
+(((newtime->tm_mon)+1) << 8)
+((((newtime->tm_year) % 10)+((newtime->tm_year)/10)*16) << 16); DWORD GetDate()
+((newtime->tm_wday) << 28); {
DWORD value;
return(value); struct tm *newtime;
} time_t long_time;
/*time( &long_time );*/
long_time = time (NULL);
newtime = localtime( &long_time );
value = ((newtime->tm_mday) % 10)+((newtime->tm_mday)/10)*16
+(((newtime->tm_mon)+1) << 8)
+((((newtime->tm_year) % 10)+((newtime->tm_year)/10)*16) << 16);
+((newtime->tm_wday) << 28);
return(value);
}

View File

@@ -1,396 +1,401 @@
//Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com ) //Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com )
// //
//This program is free software; you can redistribute it and/or //This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License //modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either //as published by the Free Software Foundation; either
//version 2 of the License, or (at your option) any later //version 2 of the License, or (at your option) any later
//version. //version.
// //
//This program is distributed in the hope that it will be useful, //This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of //but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details. //GNU General Public License for more details.
// //
//You should have received a copy of the GNU General Public License //You should have received a copy of the GNU General Public License
//along with this program; if not, write to the Free Software //along with this program; if not, write to the Free Software
//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#include <stdio.h> #include <stdio.h>
#include <ctype.h> #include <ctype.h>
#include <stdlib.h>
extern void zstart(void); #include <string.h>
extern void DosExit(void);
extern void ConvertJoyMap1(void); int pccmdline(void);
extern void ConvertJoyMap2(void);
extern void displayparams(void); extern void zstart(void);
extern void makeextension(void); extern void DosExit(void);
extern void ConvertJoyMap1(void);
extern unsigned char Palette0, SPC700sh, OffBy1Line, DSPDisable, extern void ConvertJoyMap2(void);
FPUCopy, Force8b, ForcePal, GUIClick, MouseDis, extern void displayparams(void);
MusicRelVol, ScreenScale, SoundCompD, SoundQuality, extern void makeextension(void);
StereoSound, V8Mode, antienab, cvidmode, debugdisble,
debugger, enterpress, finterleave, frameskip, extern unsigned char Palette0, SPC700sh, OffBy1Line, DSPDisable,
gammalevel, guioff, per2exec, pl1contrl, pl2contrl, FPUCopy, Force8b, ForcePal, GUIClick, MouseDis,
romtype, scanlines, showallext, smallscreenon, soundon, MusicRelVol, ScreenScale, SoundCompD, SoundQuality,
spcon, vsyncon, DisplayS, fname, filefound, SnowOn; StereoSound, V8Mode, antienab, cvidmode, debugdisble,
debugger, enterpress, finterleave, frameskip,
void ccmdline(void); gammalevel, guioff, per2exec, pl1contrl, pl2contrl,
romtype, scanlines, showallext, smallscreenon, soundon,
char *ers[] = spcon, vsyncon, DisplayS, fname, filefound, SnowOn;
{
"Frame Skip must be a value of 0 to 9!\n", void ccmdline(void);
"Gamma Correction Level must be a value of 0 to 5!\n",
"Sound Sampling Rate must be a value of 0 to 6!\n", char *ers[] =
"Invalid Video Mode!\n", {
"Percentage of instructions to execute must be a number from 50 to 150!\n", "Frame Skip must be a value of 0 to 9!\n",
"Player Input must be a value from 0 to 6!\n", "Gamma Correction Level must be a value of 0 to 5!\n",
"Volume must be a number from 0 to 100!\n" "Sound Sampling Rate must be a value of 0 to 6!\n",
"Invalid Video Mode!\n",
}; "Percentage of instructions to execute must be a number from 50 to 150!\n",
"Player Input must be a value from 0 to 6!\n",
"Volume must be a number from 0 to 100!\n"
int argc; };
char **argv;
int main(int margc, char **margv)
{
argc=margc; int argc;
argv=margv; char **argv;
zstart(); int main(int margc, char **margv)
} {
argc=margc;
argv=margv;
int my_atoi(char *nptr) zstart();
{ return(0);
int p,c; }
c=0;
for(p=0;nptr[p];p++)
{ int my_atoi(char *nptr)
if( !isdigit(nptr[p]) ) c+=1; {
} int p,c;
if(c) return -1; c=0;
else return atoi(nptr); for(p=0;nptr[p];p++)
{
} if( !isdigit(nptr[p]) ) c+=1;
}
if(c) return -1;
void ccmdline(void) else return atoi(nptr);
{
int p=0; }
p=pccmdline();
if(p == 0) return;
void ccmdline(void)
if(p == 9) {
{ int p=0;
displayparams(); p=pccmdline();
} if(p == 0) return;
if(p == 4)
{ if(p == 9)
// printf("Mangled command line, did you forget a parm?\n"); {
printf("Invalid Commandline!\n"); displayparams();
DosExit(); }
} if(p == 4)
{
if((p > 9) && (p < 17)) // printf("Mangled command line, did you forget a parm?\n");
{ printf("Invalid Commandline!\n");
printf(ers[p-10]); DosExit();
DosExit(); }
}
if(p == 2) if((p > 9) && (p < 17))
{ {
DosExit(); printf(ers[p-10]);
} DosExit();
}
if(p == 2)
printf("cmdline returned %i\n",p); {
DosExit(); DosExit();
}
}
int pccmdline(void) printf("cmdline returned %i\n",p);
{ DosExit();
int p;
int gfnm=0; }
for(p=1;p<argc;p++) int pccmdline(void)
{ {
/* int p;
printf("(%i/%i): %s\n",p,argc,argv[p]); int gfnm=0;
*/
for(p=1;p<argc;p++)
if(argv[p][0] == '-') {
{ /*
int hasroom=0; printf("(%i/%i): %s\n",p,argc,argv[p]);
int pp=1; */
int cp=p;
int nn='_'; if(argv[p][0] == '-')
for(pp=1;argv[cp][pp];pp++) {
{ int hasroom=0;
if( (p+1) < argc) hasroom=1; int pp=1;
nn=tolower(argv[cp][pp+1]); int cp=p;
switch(tolower(argv[cp][pp])) int nn='_';
{ for(pp=1;argv[cp][pp];pp++)
case '1': /* Player 1 Input */ {
{ if( (p+1) < argc) hasroom=1;
if(!hasroom) return 4; nn=tolower(argv[cp][pp+1]);
pl1contrl=my_atoi(argv[p+1]); switch(tolower(argv[cp][pp]))
if(pl1contrl > 6) return 15; {
p++; case '1': /* Player 1 Input */
ConvertJoyMap1(); {
break; if(!hasroom) return 4;
} pl1contrl=my_atoi(argv[p+1]);
case '2': /* Player 2 Input */ if(pl1contrl > 6) return 15;
{ p++;
if(!hasroom) return 4; ConvertJoyMap1();
pl2contrl=my_atoi(argv[p+1]); break;
if(pl2contrl > 6) return 15; }
p++; case '2': /* Player 2 Input */
ConvertJoyMap2(); {
break; if(!hasroom) return 4;
} pl2contrl=my_atoi(argv[p+1]);
case 'f': if(pl2contrl > 6) return 15;
{ p++;
if(!hasroom) return 4; ConvertJoyMap2();
frameskip=my_atoi(argv[p+1]); break;
if(frameskip > 9) return 10; }
frameskip++; case 'f':
p++; {
break; if(!hasroom) return 4;
} frameskip=my_atoi(argv[p+1]);
case 'g': if(frameskip > 9) return 10;
{ frameskip++;
if(!hasroom) return 4; p++;
gammalevel=my_atoi(argv[p+1]); break;
if(gammalevel > 5) return 11; }
p++; case 'g':
break; {
} if(!hasroom) return 4;
case 'p': gammalevel=my_atoi(argv[p+1]);
{ if(gammalevel > 5) return 11;
if(!hasroom) return 4; p++;
per2exec=my_atoi(argv[p+1]); break;
if(per2exec > 150) return 14; }
if(per2exec < 50) return 14; case 'p':
p++; {
break; if(!hasroom) return 4;
} per2exec=my_atoi(argv[p+1]);
case 'r': if(per2exec > 150) return 14;
{ if(per2exec < 50) return 14;
if(!hasroom) return 4; p++;
SoundQuality=my_atoi(argv[p+1]); break;
if(SoundQuality > 6) return 12; }
p++; case 'r':
break; {
} if(!hasroom) return 4;
case 'v': SoundQuality=my_atoi(argv[p+1]);
{ if(SoundQuality > 6) return 12;
if(nn == '8') p++;
{ break;
V8Mode=1; }
pp++; case 'v':
} {
else if(nn == '8')
{ {
if(!hasroom) return 4; V8Mode=1;
cvidmode=my_atoi(argv[p+1]); pp++;
if(cvidmode > 10) return 13; }
p++; else
} {
break; if(!hasroom) return 4;
} cvidmode=my_atoi(argv[p+1]);
case 'k': if(cvidmode > 10) return 13;
{ p++;
if(!hasroom) return 4; }
MusicRelVol=my_atoi(argv[p+1]); break;
if(MusicRelVol > 100) return 16; }
p++; case 'k':
break; {
} if(!hasroom) return 4;
case '8': MusicRelVol=my_atoi(argv[p+1]);
{ if(MusicRelVol > 100) return 16;
Force8b=1; p++;
break; break;
} }
case '0': /* Palette 0 disable */ case '8':
{ {
Palette0=1; Force8b=1;
break; break;
} }
case '7': /* SPC700 speed hack disable */ case '0': /* Palette 0 disable */
{ {
SPC700sh=1; Palette0=1;
break; break;
} }
case '9': /* Off by 1 line */ case '7': /* SPC700 speed hack disable */
{ {
OffBy1Line=1; SPC700sh=1;
break; break;
} }
case 'e': case '9': /* Off by 1 line */
{ {
enterpress=1; OffBy1Line=1;
break; break;
} }
case 'h': case 'e':
{ {
romtype=2; enterpress=1;
break; break;
} }
case 'l': case 'h':
{ {
romtype=1; romtype=2;
break; break;
} }
case 'm': case 'l':
{ {
guioff=1; /* disables GUI */ romtype=1;
break; break;
} }
case 'n': case 'm':
{ {
scanlines=1; guioff=1; /* disables GUI */
break; break;
} }
case 's': case 'n':
{ {
if(nn == 'p') scanlines=1;
{ break;
DisplayS=1; }
pp++; case 's':
} {
else if(nn == 'p')
if(nn == 'a') {
{ DisplayS=1;
showallext=1; pp++;
pp++; }
} else
else if(nn == 'a')
if(nn == 'n') {
{ showallext=1;
SnowOn=1; pp++;
pp++; }
} else
else if(nn == 'n')
{ {
spcon=1; SnowOn=1;
soundon=1; pp++;
} }
break; else
} {
case 't': spcon=1;
{ soundon=1;
ForcePal=1; }
break; break;
} }
case 'u': case 't':
{ {
ForcePal=2; ForcePal=1;
break; break;
} }
case 'w': case 'u':
{ {
vsyncon=1; ForcePal=2;
break; break;
} }
case 'z': case 'w':
{ {
StereoSound=1; vsyncon=1;
break; break;
} }
case 'd': case 'z':
{ {
if(nn == 'd') StereoSound=1;
{ break;
DSPDisable=1; }
pp++; case 'd':
} {
else if(nn == 'd')
{ {
debugger=1; DSPDisable=1;
debugdisble=0; pp++;
} }
break; else
} {
case 'b': debugger=1;
{ debugdisble=0;
SoundCompD=1; }
break; break;
} }
case 'b':
case 'c': {
{ SoundCompD=1;
if(nn == 'c') break;
{ }
smallscreenon=1;
pp++; case 'c':
} {
else if(nn == 'c')
{ {
ScreenScale=1; smallscreenon=1;
} pp++;
break; }
} else
{
case 'y': ScreenScale=1;
{ }
antienab=1; break;
break; }
}
case 'o': case 'y':
{ {
if(nn == 'm') antienab=1;
{ break;
FPUCopy=2; }
pp++; case 'o':
} {
else if(nn == 'm')
{ {
FPUCopy=0; FPUCopy=2;
} pp++;
break; }
} else
case 'i': {
{ FPUCopy=0;
finterleave=1; }
break; break;
} }
case 'j': case 'i':
{ {
GUIClick=0; finterleave=1;
MouseDis=1; break;
break; }
} case 'j':
case '?': {
{ GUIClick=0;
return 9; MouseDis=1;
} break;
} }
case '?':
} {
return 9;
} }
else }
{
if(gfnm > 0) }
{
printf("Limit yourself to one filename\n"); }
return 2; else
} {
else if(gfnm > 0)
{ {
char *fvar; printf("Limit yourself to one filename\n");
fvar=&fname; return 2;
fvar[0] = strlen(argv[p]); }
strncpy(&fvar[1],argv[p],127); else
gfnm++; {
} char *fvar;
} fvar=&fname;
} fvar[0] = strlen(argv[p]);
if(gfnm == 1) strncpy(&fvar[1],argv[p],127);
{ gfnm++;
filefound=0; }
makeextension(); }
} }
return 0; if(gfnm == 1)
} {
filefound=0;
makeextension();
}
return 0;
}

View File

@@ -1,188 +1,188 @@
#Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com ) #Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com )
# #
#This program is free software; you can redistribute it and/or #This program is free software; you can redistribute it and/or
#modify it under the terms of the GNU General Public License #modify it under the terms of the GNU General Public License
#as published by the Free Software Foundation; either #as published by the Free Software Foundation; either
#version 2 of the License, or (at your option) any later #version 2 of the License, or (at your option) any later
#version. #version.
# #
#This program is distributed in the hope that it will be useful, #This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of #but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU General Public License for more details. #GNU General Public License for more details.
# #
#You should have received a copy of the GNU General Public License #You should have received a copy of the GNU General Public License
#along with this program; if not, write to the Free Software #along with this program; if not, write to the Free Software
#Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
CHIPDIR=chips CHIPDIR=chips
CPUDIR=cpu CPUDIR=cpu
DOSDIR=dos DOSDIR=dos
GUIDIR=gui GUIDIR=gui
VIDEODIR=video VIDEODIR=video
WINDIR=win WINDIR=win
OBJDIR=obj OBJDIR=obj
ZIPDIR=zip ZIPDIR=zip
CHIPSOBJ=${CHIPDIR}/dsp1emu.o ${CHIPDIR}/fxemu2.o ${CHIPDIR}/sfxproc.o\ CHIPSOBJ=${CHIPDIR}/dsp1emu.o ${CHIPDIR}/fxemu2.o ${CHIPDIR}/sfxproc.o\
${CHIPDIR}/fxemu2b.o ${CHIPDIR}/fxemu2c.o ${CHIPDIR}/fxtable.o\ ${CHIPDIR}/fxemu2b.o ${CHIPDIR}/fxemu2c.o ${CHIPDIR}/fxtable.o\
${CHIPDIR}/sa1proc.o ${CHIPDIR}/sa1regs.o ${CHIPDIR}/dsp1proc.o ${CHIPDIR}/sa1proc.o ${CHIPDIR}/sa1regs.o ${CHIPDIR}/dsp1proc.o
CPUOBJ=${CPUDIR}/addrni.o ${CPUDIR}/dma.o ${CPUDIR}/dsp.o ${CPUDIR}/dspproc.o\ CPUOBJ=${CPUDIR}/addrni.o ${CPUDIR}/dma.o ${CPUDIR}/dsp.o ${CPUDIR}/dspproc.o\
${CPUDIR}/execute.o ${CPUDIR}/irq.o ${CPUDIR}/memory.o\ ${CPUDIR}/execute.o ${CPUDIR}/irq.o ${CPUDIR}/memory.o\
${CPUDIR}/spc700.o ${CPUDIR}/stable.o ${CPUDIR}/table.o\ ${CPUDIR}/spc700.o ${CPUDIR}/stable.o ${CPUDIR}/table.o\
${CPUDIR}/tableb.o ${CPUDIR}/tablec.o ${CPUDIR}/tableb.o ${CPUDIR}/tablec.o
GUIOBJ=${GUIDIR}/gui.o ${GUIDIR}/menu.o GUIOBJ=${GUIDIR}/gui.o ${GUIDIR}/menu.o
VIDEOBJ=${VIDEODIR}/makev16b.o ${VIDEODIR}/makev16t.o ${VIDEODIR}/makevid.o\ VIDEOBJ=${VIDEODIR}/makev16b.o ${VIDEODIR}/makev16t.o ${VIDEODIR}/makevid.o\
${VIDEODIR}/mode716.o ${VIDEODIR}/mode716b.o ${VIDEODIR}/mode716d.o\ ${VIDEODIR}/mode716.o ${VIDEODIR}/mode716b.o ${VIDEODIR}/mode716d.o\
${VIDEODIR}/mode716e.o ${VIDEODIR}/mode716t.o ${VIDEODIR}/mode7.o\ ${VIDEODIR}/mode716e.o ${VIDEODIR}/mode716t.o ${VIDEODIR}/mode7.o\
${VIDEODIR}/mode7ext.o ${VIDEODIR}/mv16tms.o ${VIDEODIR}/newg162.o\ ${VIDEODIR}/mode7ext.o ${VIDEODIR}/mv16tms.o ${VIDEODIR}/newg162.o\
${VIDEODIR}/newgfx16.o ${VIDEODIR}/newgfx2.o ${VIDEODIR}/newgfx.o\ ${VIDEODIR}/newgfx16.o ${VIDEODIR}/newgfx2.o ${VIDEODIR}/newgfx.o\
${VIDEODIR}/m716text.o ${VIDEODIR}/procvid.o ${VIDEODIR}/m716text.o ${VIDEODIR}/procvid.o
DOSOBJ= ${DOSDIR}/dosintrf.o ${DOSDIR}/gppro.o ${DOSDIR}/debug.o\ DOSOBJ= ${DOSDIR}/dosintrf.o ${DOSDIR}/gppro.o ${DOSDIR}/debug.o\
${DOSDIR}/initvid.o ${DOSDIR}/modemrtn.o ${DOSDIR}/sw32.o\ ${DOSDIR}/initvid.o ${DOSDIR}/modemrtn.o ${DOSDIR}/sw32.o\
${DOSDIR}/joy.o ${DOSDIR}/sw.o ${DOSDIR}/vesa12.o ${DOSDIR}/vesa2.o\ ${DOSDIR}/joy.o ${DOSDIR}/sw.o ${DOSDIR}/vesa12.o ${DOSDIR}/vesa2.o\
${DOSDIR}/zloader.o ${DOSDIR}/zsipx.o ${DOSDIR}/zfile.o ${DOSDIR}/zloader.o ${DOSDIR}/zsipx.o ${DOSDIR}/zfile.o
WINOBJ=${WINDIR}/copywin.o ${WINDIR}/winintrf.o ${WINDIR}/winlink.o\ WINOBJ=${WINDIR}/copywin.o ${WINDIR}/winintrf.o ${WINDIR}/winlink.o\
${WINDIR}/zloaderw.o ${WINDIR}/ztcp.o ${WINDIR}/zipxw.o ${WINDIR}/zloaderw.o ${WINDIR}/ztcp.o ${WINDIR}/zipxw.o
PREOBJ=${OBJDIR}/dosbuff.o ${OBJDIR}/ipx.o ${OBJDIR}/zipx.o PREOBJ=${OBJDIR}/dosbuff.o ${OBJDIR}/ipx.o ${OBJDIR}/zipx.o
ZIPOBJ=${ZIPDIR}/zzip.o ${ZIPDIR}/unzip.o ${ZIPDIR}/zpng.o ZIPOBJ=${ZIPDIR}/zzip.o ${ZIPDIR}/unzip.o ${ZIPDIR}/zpng.o
MAINOBJ=cfgload.o endmem.o fixsin.o init.o ui.o vcache.o water.o MAINOBJ=cfgload.o endmem.o fixsin.o init.o ui.o vcache.o water.o
OBJS=${CHIPSOBJ} ${CPUOBJ} ${DOSOBJ} ${GUIOBJ} ${VIDEOBJ} ${PREOBJ} ${MAINOBJ} ${ZIPOBJ} OBJS=${CHIPSOBJ} ${CPUOBJ} ${DOSOBJ} ${GUIOBJ} ${VIDEOBJ} ${PREOBJ} ${MAINOBJ} ${ZIPOBJ}
LIBS=-lz -lgcc -lm -lpng LIBS=-lz -lgcc -lm -lpng
CFLAGS=-D__MSDOS__ -O2 CFLAGS=-O2 -fomit-frame-pointer -Wall -D__MSDOS__
ASM=nasm ASM=nasm
ASMFLAGS=-f coff -D__MSDOS__ ASMFLAGS=-f coff -D__MSDOS__
CC=gcc CC=gcc
PP=gpp PP=gpp
.SUFFIXES: .c .cpp .asm .SUFFIXES: .c .cpp .asm
%.o: %.c %.o: %.c
${CC} ${CFLAGS} -o $@ -c $< ${CC} ${CFLAGS} -o $@ -c $<
%.o: %.cpp %.o: %.cpp
${PP} ${CFLAGS} -o $@ -c $< ${PP} ${CFLAGS} -o $@ -c $<
%.o: %.asm %.o: %.asm
${ASM} ${ASMFLAGS} -o $@ $< ${ASM} ${ASMFLAGS} -o $@ $<
ALL: zsnes.exe ALL: zsnes.exe
zsnes.exe: ${OBJS} zsnes.exe: ${OBJS}
${CC} -Ws -L./obj -s -o zsnes.exe ${OBJS} ${LIBS} ${CC} -Ws -L./obj -s -o zsnes.exe ${OBJS} ${LIBS}
${DOSDIR}/zloader.o: ${DOSDIR}/zloader.c ${DOSDIR}/zloader.o: ${DOSDIR}/zloader.c
fixsin.o: fixsin.c fixsin.o: fixsin.c
water.o: water.c water.o: water.c
${DOSDIR}/zfile.o: ${DOSDIR}/zfile.c ${DOSDIR}/zfile.o: ${DOSDIR}/zfile.c
${ZIPDIR}/unzip.o: ${ZIPDIR}/unzip.c ${ZIPDIR}/unzip.h ${ZIPDIR}/unzip.o: ${ZIPDIR}/unzip.c ${ZIPDIR}/unzip.h
${ZIPDIR}/zzip.o: ${ZIPDIR}/zzip.c ${ZIPDIR}/unzip.h ${ZIPDIR}/zzip.o: ${ZIPDIR}/zzip.c ${ZIPDIR}/unzip.h
${ZIPDIR}/zpng.o: ${ZIPDIR}/zpng.c ${ZIPDIR}/zpng.h ${ZIPDIR}/png.h ${ZIPDIR}/zpng.o: ${ZIPDIR}/zpng.c ${ZIPDIR}/zpng.h ${ZIPDIR}/png.h
${VIDEODIR}/procvid.o: ${VIDEODIR}/procvid.asm macros.mac ${VIDEODIR}/copyvid.inc ${VIDEODIR}/2xSaImmx.inc ${VIDEODIR}/procvid.o: ${VIDEODIR}/procvid.asm macros.mac ${VIDEODIR}/copyvid.inc ${VIDEODIR}/2xSaImmx.inc
${CHIPDIR}/dsp1proc.o: ${CHIPDIR}/dsp1proc.asm macros.mac ${CHIPDIR}/dsp1proc.o: ${CHIPDIR}/dsp1proc.asm macros.mac
${CHIPDIR}/sa1regs.o: ${CHIPDIR}/sa1regs.asm macros.mac\ ${CHIPDIR}/sa1regs.o: ${CHIPDIR}/sa1regs.asm macros.mac\
${CPUDIR}/regs.mac ${CPUDIR}/regsw.mac ${CPUDIR}/regs.mac ${CPUDIR}/regsw.mac
${CHIPDIR}/sfxproc.o: ${CHIPDIR}/sfxproc.asm macros.mac\ ${CHIPDIR}/sfxproc.o: ${CHIPDIR}/sfxproc.asm macros.mac\
${CPUDIR}/regs.mac ${CPUDIR}/regsw.mac ${CPUDIR}/regs.mac ${CPUDIR}/regsw.mac
${CHIPDIR}/dsp1emu.o: ${CHIPDIR}/dsp1emu.c betauser.mac ${CHIPDIR}/dsp1emu.o: ${CHIPDIR}/dsp1emu.c betauser.mac
ui.o: ui.asm macros.mac betauser.mac ui.o: ui.asm macros.mac betauser.mac
cfgload.o:cfgload.asm macros.mac cfgload.o:cfgload.asm macros.mac
init.o:init.asm macros.mac init.o:init.asm macros.mac
${DOSDIR}/debug.o: ${DOSDIR}/debug.asm macros.mac ${DOSDIR}/debug.o: ${DOSDIR}/debug.asm macros.mac
${CPUDIR}/execute.o: ${CPUDIR}/execute.asm macros.mac ${CPUDIR}/execute.o: ${CPUDIR}/execute.asm macros.mac
${CPUDIR}/table.o: ${CPUDIR}/table.asm ${CPUDIR}/65816d.inc\ ${CPUDIR}/table.o: ${CPUDIR}/table.asm ${CPUDIR}/65816d.inc\
${CPUDIR}/address.inc ${CPUDIR}/addrni.inc ${CPUDIR}/e65816.inc\ ${CPUDIR}/address.inc ${CPUDIR}/addrni.inc ${CPUDIR}/e65816.inc\
${CPUDIR}/regs.mac ${CPUDIR}/regs.inc ${CPUDIR}/regsw.mac\ ${CPUDIR}/regs.mac ${CPUDIR}/regs.inc ${CPUDIR}/regsw.mac\
${CPUDIR}/regsw.inc macros.mac ${CPUDIR}/regsw.inc macros.mac
${CPUDIR}/tableb.o: ${CPUDIR}/tableb.asm ${CPUDIR}/65816db.inc\ ${CPUDIR}/tableb.o: ${CPUDIR}/tableb.asm ${CPUDIR}/65816db.inc\
${CPUDIR}/address.inc ${CPUDIR}/addrni.inc ${CPUDIR}/e65816b.inc\ ${CPUDIR}/address.inc ${CPUDIR}/addrni.inc ${CPUDIR}/e65816b.inc\
${CPUDIR}/regs.mac macros.mac ${CPUDIR}/regs.mac macros.mac
${CPUDIR}/tablec.o: ${CPUDIR}/tablec.asm ${CPUDIR}/65816dc.inc\ ${CPUDIR}/tablec.o: ${CPUDIR}/tablec.asm ${CPUDIR}/65816dc.inc\
${CPUDIR}/address.inc ${CPUDIR}/addrni.inc ${CPUDIR}/e65816c.inc\ ${CPUDIR}/address.inc ${CPUDIR}/addrni.inc ${CPUDIR}/e65816c.inc\
${CPUDIR}/regs.mac macros.mac ${CPUDIR}/regs.mac macros.mac
${CPUDIR}/stable.o: ${CPUDIR}/stable.asm ${CPUDIR}/s65816d.inc\ ${CPUDIR}/stable.o: ${CPUDIR}/stable.asm ${CPUDIR}/s65816d.inc\
${CPUDIR}/saddress.inc ${CPUDIR}/saddrni.inc ${CPUDIR}/se65816.inc\ ${CPUDIR}/saddress.inc ${CPUDIR}/saddrni.inc ${CPUDIR}/se65816.inc\
macros.mac macros.mac
${CPUDIR}/memory.o: ${CPUDIR}/memory.asm macros.mac ${CPUDIR}/memory.o: ${CPUDIR}/memory.asm macros.mac
${CPUDIR}/dma.o: ${CPUDIR}/dma.asm macros.mac ${CPUDIR}/dma.o: ${CPUDIR}/dma.asm macros.mac
${DOSDIR}/dosintrf.o: ${DOSDIR}/dosintrf.asm macros.mac ${DOSDIR}/dosintrf.o: ${DOSDIR}/dosintrf.asm macros.mac
vcache.o:vcache.asm macros.mac vcache.o:vcache.asm macros.mac
${DOSDIR}/initvid.o:${DOSDIR}/initvid.asm macros.mac ${DOSDIR}/initvid.o:${DOSDIR}/initvid.asm macros.mac
${VIDEODIR}/makevid.o: ${VIDEODIR}/makevid.asm ${VIDEODIR}/vidmacro.mac\ ${VIDEODIR}/makevid.o: ${VIDEODIR}/makevid.asm ${VIDEODIR}/vidmacro.mac\
macros.mac macros.mac
${VIDEODIR}/makev16b.o: ${VIDEODIR}/makev16b.asm ${VIDEODIR}/vidmacro.mac\ ${VIDEODIR}/makev16b.o: ${VIDEODIR}/makev16b.asm ${VIDEODIR}/vidmacro.mac\
macros.mac macros.mac
${VIDEODIR}/makev16t.o: ${VIDEODIR}/makev16t.asm ${VIDEODIR}/vidmacro.mac\ ${VIDEODIR}/makev16t.o: ${VIDEODIR}/makev16t.asm ${VIDEODIR}/vidmacro.mac\
macros.mac macros.mac
${VIDEODIR}/mv16tms.o: ${VIDEODIR}/mv16tms.asm ${VIDEODIR}/vidmacro.mac\ ${VIDEODIR}/mv16tms.o: ${VIDEODIR}/mv16tms.asm ${VIDEODIR}/vidmacro.mac\
macros.mac macros.mac
${VIDEODIR}/mode7.o: ${VIDEODIR}/mode7.asm ${VIDEODIR}/mode7.mac\ ${VIDEODIR}/mode7.o: ${VIDEODIR}/mode7.asm ${VIDEODIR}/mode7.mac\
macros.mac macros.mac
${VIDEODIR}/mode716.o: ${VIDEODIR}/mode716.asm ${VIDEODIR}/mode716.mac\ ${VIDEODIR}/mode716.o: ${VIDEODIR}/mode716.asm ${VIDEODIR}/mode716.mac\
macros.mac macros.mac
${VIDEODIR}/mode716b.o:${VIDEODIR}/mode716b.asm ${VIDEODIR}/mode7.mac\ ${VIDEODIR}/mode716b.o:${VIDEODIR}/mode716b.asm ${VIDEODIR}/mode7.mac\
macros.mac macros.mac
${VIDEODIR}/mode716t.o:${VIDEODIR}/mode716t.asm ${VIDEODIR}/mode7.mac\ ${VIDEODIR}/mode716t.o:${VIDEODIR}/mode716t.asm ${VIDEODIR}/mode7.mac\
macros.mac macros.mac
${VIDEODIR}/mode716d.o:${VIDEODIR}/mode716d.asm ${VIDEODIR}/mode7.mac\ ${VIDEODIR}/mode716d.o:${VIDEODIR}/mode716d.asm ${VIDEODIR}/mode7.mac\
macros.mac macros.mac
${VIDEODIR}/mode7ext.o:${VIDEODIR}/mode7ext.asm macros.mac ${VIDEODIR}/mode7ext.o:${VIDEODIR}/mode7ext.asm macros.mac
${VIDEODIR}/mode716e.o:${VIDEODIR}/mode716e.asm macros.mac ${VIDEODIR}/mode716e.o:${VIDEODIR}/mode716e.asm macros.mac
${VIDEODIR}/m716text.o:${VIDEODIR}/m716text.asm ${VIDEODIR}/mode7.mac\ ${VIDEODIR}/m716text.o:${VIDEODIR}/m716text.asm ${VIDEODIR}/mode7.mac\
macros.mac macros.mac
${CPUDIR}/irq.o: ${CPUDIR}/irq.asm macros.mac ${CPUDIR}/irq.o: ${CPUDIR}/irq.asm macros.mac
${CPUDIR}/dspproc.o: ${CPUDIR}/dspproc.asm macros.mac ${CPUDIR}/dspproc.o: ${CPUDIR}/dspproc.asm macros.mac
${CPUDIR}/spc700.o:${CPUDIR}/spc700.asm macros.mac\ ${CPUDIR}/spc700.o:${CPUDIR}/spc700.asm macros.mac\
${CPUDIR}/regsw.mac ${CPUDIR}/spcdef.inc ${CPUDIR}/spcaddr.inc ${CPUDIR}/regsw.mac ${CPUDIR}/spcdef.inc ${CPUDIR}/spcaddr.inc
${CPUDIR}/dsp.o: ${CPUDIR}/dsp.asm macros.mac ${CPUDIR}/dsp.o: ${CPUDIR}/dsp.asm macros.mac
${DOSDIR}/vesa2.o: ${DOSDIR}/vesa2.asm macros.mac ${DOSDIR}/vesa2.o: ${DOSDIR}/vesa2.asm macros.mac
${DOSDIR}/vesa12.o: ${DOSDIR}/vesa12.asm macros.mac ${DOSDIR}/vesa12.o: ${DOSDIR}/vesa12.asm macros.mac
${DOSDIR}/joy.o: ${DOSDIR}/joy.asm macros.mac ${DOSDIR}/joy.o: ${DOSDIR}/joy.asm macros.mac
${DOSDIR}/sw.o: ${DOSDIR}/sw.asm macros.mac ${DOSDIR}/sw.o: ${DOSDIR}/sw.asm macros.mac
${GUIDIR}/gui.o: ${GUIDIR}/gui.asm ${GUIDIR}/guitools.inc\ ${GUIDIR}/gui.o: ${GUIDIR}/gui.asm ${GUIDIR}/guitools.inc\
${GUIDIR}/guimisc.inc ${GUIDIR}/guimouse.inc ${GUIDIR}/guiwindp.inc\ ${GUIDIR}/guimisc.inc ${GUIDIR}/guimouse.inc ${GUIDIR}/guiwindp.inc\
${GUIDIR}/guinetpl.inc ${GUIDIR}/guikeys.inc ${GUIDIR}/guicheat.inc\ ${GUIDIR}/guinetpl.inc ${GUIDIR}/guikeys.inc ${GUIDIR}/guicheat.inc\
${GUIDIR}/guicombo.inc ${GUIDIR}/guiload.inc macros.mac ${GUIDIR}/guicombo.inc ${GUIDIR}/guiload.inc macros.mac
${GUIDIR}/menu.o: ${GUIDIR}/menu.asm macros.mac ${GUIDIR}/menu.o: ${GUIDIR}/menu.asm macros.mac
${VIDEODIR}/newgfx.o:${VIDEODIR}/newgfx.asm ${VIDEODIR}/vidmacro.mac\ ${VIDEODIR}/newgfx.o:${VIDEODIR}/newgfx.asm ${VIDEODIR}/vidmacro.mac\
${VIDEODIR}/newgfx2.mac ${VIDEODIR}/newgfx.mac macros.mac ${VIDEODIR}/newgfx2.mac ${VIDEODIR}/newgfx.mac macros.mac
${VIDEODIR}/newgfx2.o:${VIDEODIR}/newgfx2.asm ${VIDEODIR}/newgfxwn.mac\ ${VIDEODIR}/newgfx2.o:${VIDEODIR}/newgfx2.asm ${VIDEODIR}/newgfxwn.mac\
${VIDEODIR}/newgfx.mac macros.mac ${VIDEODIR}/newgfx.mac macros.mac
${VIDEODIR}/newgfx16.o: ${VIDEODIR}/newgfx16.asm macros.mac ${VIDEODIR}/vidmacro.mac\ ${VIDEODIR}/newgfx16.o: ${VIDEODIR}/newgfx16.asm macros.mac ${VIDEODIR}/vidmacro.mac\
${VIDEODIR}/newgfx16.mac ${VIDEODIR}/newg162.mac ${VIDEODIR}/newgfx16.mac ${VIDEODIR}/newg162.mac
${VIDEODIR}/newg162.o: macros.mac ${VIDEODIR}/newg162.asm ${VIDEODIR}/newg162.mac\ ${VIDEODIR}/newg162.o: macros.mac ${VIDEODIR}/newg162.asm ${VIDEODIR}/newg162.mac\
${VIDEODIR}/vidmacro.mac ${VIDEODIR}/newg16wn.mac ${VIDEODIR}/vidmacro.mac ${VIDEODIR}/newg16wn.mac
${CHIPDIR}/fxemu2.o: ${CHIPDIR}/fxemu2.asm ${CHIPDIR}/fxemu2.mac\ ${CHIPDIR}/fxemu2.o: ${CHIPDIR}/fxemu2.asm ${CHIPDIR}/fxemu2.mac\
macros.mac macros.mac
${CHIPSDIR}/fxemu2b.o: ${CHIPDIR}/fxemu2b.asm ${CHIPDIR}/fxemu2.mac\ ${CHIPSDIR}/fxemu2b.o: ${CHIPDIR}/fxemu2b.asm ${CHIPDIR}/fxemu2.mac\
${CHIPDIR}/fxemu2b.mac ${CHIPDIR}/fxemu2b.mac
${CHIPSDIR}/fxemu2c.o: ${CHIPDIR}/fxemu2c.asm macros.mac ${CHIPDIR}/fxemu2.mac\ ${CHIPSDIR}/fxemu2c.o: ${CHIPDIR}/fxemu2c.asm macros.mac ${CHIPDIR}/fxemu2.mac\
${CHIPDIR}/fxemu2b.mac ${CHIPDIR}/fxemu2c.mac ${CHIPDIR}/fxemu2b.mac ${CHIPDIR}/fxemu2c.mac
${CHIPDIR}/fxtable.o: ${CHIPDIR}/fxtable.asm macros.mac ${CHIPDIR}/fxtable.o: ${CHIPDIR}/fxtable.asm macros.mac
${DOSDIR}/gppro.o: ${DOSDIR}/gppro.asm macros.mac ${DOSDIR}/gppro.o: ${DOSDIR}/gppro.asm macros.mac
${DOSDIR}/zsipx.o: ${DOSDIR}/zsipx.asm ${DOSDIR}/zsipx.o: ${DOSDIR}/zsipx.asm
${CHIPDIR}/sa1proc.o: ${CHIPDIR}/sa1proc.asm macros.mac ${CHIPDIR}/sa1proc.o: ${CHIPDIR}/sa1proc.asm macros.mac
endmem.o: endmem.asm macros.mac endmem.o: endmem.asm macros.mac
${DOSDIR}/modemrtn.o: ${DOSDIR}/modemrtn.asm macros.mac ${DOSDIR}/modemrtn.o: ${DOSDIR}/modemrtn.asm macros.mac
clean: clean:
del *.o del *.o
del ${CHIPDIR}\*.o del ${CHIPDIR}\*.o
del ${CPUDIR}\*.o del ${CPUDIR}\*.o
del ${VIDEODIR}\*.o del ${VIDEODIR}\*.o
del ${GUIDIR}\*.o del ${GUIDIR}\*.o
del ${DOSDIR}\*.o del ${DOSDIR}\*.o
del ${ZIPDIR}\*.o del ${ZIPDIR}\*.o
del zsnes.exe del zsnes.exe

View File

@@ -1,325 +1,336 @@
//Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com ) //Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com )
// //
//This program is free software; you can redistribute it and/or //This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License //modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either //as published by the Free Software Foundation; either
//version 2 of the License, or (at your option) any later //version 2 of the License, or (at your option) any later
//version. //version.
// //
//This program is distributed in the hope that it will be useful, //This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of //but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details. //GNU General Public License for more details.
// //
//You should have received a copy of the GNU General Public License //You should have received a copy of the GNU General Public License
//along with this program; if not, write to the Free Software //along with this program; if not, write to the Free Software
//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#ifdef __LINUX__ #ifdef __LINUX__
#include "../gblhdr.h" #include "../gblhdr.h"
#else #else
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <time.h> #include <time.h>
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#endif #include <utime.h>
#endif
#include "unzip.h"
#ifdef __MSDOS__
#define CASESENSITIVITY (0) #include <sys/stat.h>
#define WRITEBUFFERSIZE (8192) #endif
#include "unzip.h"
unsigned int ZipError=0;
// 1 : Cannot open file #define CASESENSITIVITY (0)
// 2 : Could not create directory #define WRITEBUFFERSIZE (8192)
// 3 : Zip error
// 4 : Memory error
// 5 : Error opening file unsigned int ZipError=0;
// 6 : Error Writing file // 1 : Cannot open file
// 2 : Could not create directory
#ifndef __LINUX__ // 3 : Zip error
struct utimbuf { // 4 : Memory error
time_t actime; // 5 : Error opening file
time_t modtime; // 6 : Error Writing file
};
#endif #ifndef __LINUX__
#ifndef __MSDOS__
void change_file_date(const char *filename,uLong dosdate,tm_unz tmu_date) struct utimbuf {
{ time_t actime;
struct utimbuf ut; time_t modtime;
struct tm newdate; };
newdate.tm_sec = tmu_date.tm_sec; #endif
newdate.tm_min=tmu_date.tm_min; #endif
newdate.tm_hour=tmu_date.tm_hour;
newdate.tm_mday=tmu_date.tm_mday; void change_file_date(const char *filename,uLong dosdate,tm_unz tmu_date)
newdate.tm_mon=tmu_date.tm_mon; {
if (tmu_date.tm_year > 1900) struct utimbuf ut;
newdate.tm_year=tmu_date.tm_year - 1900; struct tm newdate;
else newdate.tm_sec = tmu_date.tm_sec;
newdate.tm_year=tmu_date.tm_year ; newdate.tm_min=tmu_date.tm_min;
newdate.tm_isdst=-1; newdate.tm_hour=tmu_date.tm_hour;
newdate.tm_mday=tmu_date.tm_mday;
ut.actime=ut.modtime=mktime(&newdate); newdate.tm_mon=tmu_date.tm_mon;
utime(filename,&ut); if (tmu_date.tm_year > 1900)
} newdate.tm_year=tmu_date.tm_year - 1900;
else
newdate.tm_year=tmu_date.tm_year ;
int mymkdir(const char *dirname) newdate.tm_isdst=-1;
{
#ifdef __LINUX__ ut.actime=ut.modtime=mktime(&newdate);
return(mkdir(dirname, (S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH))); utime(filename,&ut);
#else }
return(mkdir(dirname));
#endif
} int mymkdir(const char *dirname)
{
int makedir (char *newdir) #ifdef __LINUX__
{ return(mkdir(dirname, (S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)));
char *buffer ; #else
char *p; #ifdef __MSDOS__
int len = strlen(newdir); return(mkdir(dirname, (S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)));
#else
if (len <= 0) return(mkdir(dirname));
return 0; #endif
#endif
buffer = (char*)malloc(len+1); }
strcpy(buffer,newdir);
int makedir (char *newdir)
if (buffer[len-1] == '/') { {
buffer[len-1] = '\0'; char *buffer ;
} char *p;
if (mymkdir(buffer) == 0) int len = strlen(newdir);
{
free(buffer); if (len <= 0)
return 1; return 0;
}
buffer = (char*)malloc(len+1);
p = buffer+1; strcpy(buffer,newdir);
while (1)
{ if (buffer[len-1] == '/') {
char hold; buffer[len-1] = '\0';
}
while(*p && *p != '\\' && *p != '/') if (mymkdir(buffer) == 0)
p++; {
hold = *p; free(buffer);
*p = 0; return 1;
if ((mymkdir(buffer) == -1) && (errno == ENOENT)) }
{
ZipError=2; p = buffer+1;
free(buffer); while (1)
return 0; {
} char hold;
if (hold == 0)
break; while(*p && *p != '\\' && *p != '/')
*p++ = hold; p++;
} hold = *p;
free(buffer); *p = 0;
return 1; if ((mymkdir(buffer) == -1) && (errno == ENOENT))
} {
ZipError=2;
free(buffer);
return 0;
}
int do_extract_currentfile(unzFile uf, if (hold == 0)
const int* popt_extract_without_path, break;
int *popt_overwrite) *p++ = hold;
{ }
char filename_inzip[256]; free(buffer);
char* filename_withoutpath; return 1;
char* p; }
int err=UNZ_OK;
FILE *fout=NULL;
void* buf;
uInt size_buf;
int do_extract_currentfile(unzFile uf,
unz_file_info file_info; const int* popt_extract_without_path,
err = unzGetCurrentFileInfo(uf,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0); int *popt_overwrite)
{
if (err!=UNZ_OK) char filename_inzip[256];
{ char* filename_withoutpath;
ZipError=3; char* p;
return err; int err=UNZ_OK;
} FILE *fout=NULL;
void* buf;
size_buf = WRITEBUFFERSIZE; uInt size_buf;
buf = (void*)malloc(size_buf);
if (buf==NULL) unz_file_info file_info;
{ err = unzGetCurrentFileInfo(uf,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0);
ZipError=4;
return UNZ_INTERNALERROR; if (err!=UNZ_OK)
} {
ZipError=3;
p = filename_withoutpath = filename_inzip; return err;
while ((*p) != '\0') }
{
if (((*p)=='/') || ((*p)=='\\')) size_buf = WRITEBUFFERSIZE;
filename_withoutpath = p+1; buf = (void*)malloc(size_buf);
p++; if (buf==NULL)
} {
ZipError=4;
if ((*filename_withoutpath)=='\0') return UNZ_INTERNALERROR;
{ }
if ((*popt_extract_without_path)==0)
{ p = filename_withoutpath = filename_inzip;
mymkdir(filename_inzip); while ((*p) != '\0')
} {
} if (((*p)=='/') || ((*p)=='\\'))
else filename_withoutpath = p+1;
{ p++;
char* write_filename; }
int skip=0;
if ((*filename_withoutpath)=='\0')
if ((*popt_extract_without_path)==0) {
write_filename = filename_inzip; if ((*popt_extract_without_path)==0)
else {
write_filename = filename_withoutpath; mymkdir(filename_inzip);
}
err = unzOpenCurrentFile(uf); }
if (err!=UNZ_OK) else
{ {
ZipError=4; char* write_filename;
} int skip=0;
if (((*popt_overwrite)==0) && (err==UNZ_OK)) if ((*popt_extract_without_path)==0)
{ write_filename = filename_inzip;
char rep='A'; else
FILE* ftestexist; write_filename = filename_withoutpath;
ftestexist = fopen(write_filename,"rb");
if (ftestexist!=NULL) err = unzOpenCurrentFile(uf);
{ if (err!=UNZ_OK)
fclose(ftestexist); {
rep='N'; ZipError=4;
} }
if (rep == 'N') if (((*popt_overwrite)==0) && (err==UNZ_OK))
skip = 1; {
char rep='A';
if (rep == 'A') FILE* ftestexist;
*popt_overwrite=1; ftestexist = fopen(write_filename,"rb");
} if (ftestexist!=NULL)
{
if ((skip==0) && (err==UNZ_OK)) fclose(ftestexist);
{ rep='N';
fout=fopen(write_filename,"wb"); }
/* some zipfile don't contain directory alone before file */ if (rep == 'N')
if ((fout==NULL) && ((*popt_extract_without_path)==0) && skip = 1;
(filename_withoutpath!=(char*)filename_inzip))
{ if (rep == 'A')
char c=*(filename_withoutpath-1); *popt_overwrite=1;
*(filename_withoutpath-1)='\0'; }
makedir(write_filename);
*(filename_withoutpath-1)=c; if ((skip==0) && (err==UNZ_OK))
fout=fopen(write_filename,"wb"); {
} fout=fopen(write_filename,"wb");
if (fout==NULL) /* some zipfile don't contain directory alone before file */
{ if ((fout==NULL) && ((*popt_extract_without_path)==0) &&
ZipError=5; (filename_withoutpath!=(char*)filename_inzip))
} {
} char c=*(filename_withoutpath-1);
*(filename_withoutpath-1)='\0';
if (fout!=NULL) makedir(write_filename);
{ *(filename_withoutpath-1)=c;
do fout=fopen(write_filename,"wb");
{ }
err = unzReadCurrentFile(uf,buf,size_buf);
if (err<0) if (fout==NULL)
{ {
ZipError=4; ZipError=5;
break; }
} }
if (err>0)
if (fwrite(buf,err,1,fout)!=1) if (fout!=NULL)
{ {
ZipError=6; do
err=UNZ_ERRNO; {
break; err = unzReadCurrentFile(uf,buf,size_buf);
} if (err<0)
} {
while (err>0); ZipError=4;
fclose(fout); break;
if (err==0) }
change_file_date(write_filename,file_info.dosDate, if (err>0)
file_info.tmu_date); if (fwrite(buf,err,1,fout)!=1)
} {
ZipError=6;
if (err==UNZ_OK) err=UNZ_ERRNO;
{ break;
err = unzCloseCurrentFile (uf); }
if (err!=UNZ_OK) }
{ while (err>0);
ZipError=4; fclose(fout);
} if (err==0)
} change_file_date(write_filename,file_info.dosDate,
else file_info.tmu_date);
unzCloseCurrentFile(uf); /* don't lose the error */ }
}
if (err==UNZ_OK)
free(buf); {
return err; err = unzCloseCurrentFile (uf);
} if (err!=UNZ_OK)
{
ZipError=4;
int do_extract(unzFile uf,int opt_extract_without_path,int opt_overwrite) }
{ }
uLong i; else
unz_global_info gi; unzCloseCurrentFile(uf); /* don't lose the error */
int err; }
err = unzGetGlobalInfo (uf,&gi); free(buf);
if (err!=UNZ_OK) return err;
ZipError=4; }
for (i=0;i<gi.number_entry;i++)
{ int do_extract(unzFile uf,int opt_extract_without_path,int opt_overwrite)
if (do_extract_currentfile(uf,&opt_extract_without_path, {
&opt_overwrite) != UNZ_OK) uLong i;
break; unz_global_info gi;
int err;
if ((i+1)<gi.number_entry)
{ err = unzGetGlobalInfo (uf,&gi);
err = unzGoToNextFile(uf); if (err!=UNZ_OK)
if (err!=UNZ_OK) ZipError=4;
{
ZipError=4; for (i=0;i<gi.number_entry;i++)
break; {
} if (do_extract_currentfile(uf,&opt_extract_without_path,
} &opt_overwrite) != UNZ_OK)
} break;
return 0; if ((i+1)<gi.number_entry)
} {
err = unzGoToNextFile(uf);
if (err!=UNZ_OK)
void extractzip(char *FileToExtract) {
{ ZipError=4;
unzFile uf=NULL; break;
// I really don't like hardcoding these sizes... }
char oldpath[128]; }
}
#ifdef __LINUX__
extern char InitDir; return 0;
}
getcwd(oldpath, 128);
chdir(&InitDir);
#endif void extractzip(char *FileToExtract)
uf = unzOpen(FileToExtract); {
#ifdef __LINUX__ unzFile uf=NULL;
chdir(oldpath); // I really don't like hardcoding these sizes...
#endif char oldpath[128];
if (uf==NULL) #ifdef __LINUX__
{ extern char InitDir;
ZipError=1;
return; getcwd(oldpath, 128);
} chdir(&InitDir);
ZipError=0; #endif
do_extract(uf,0,0); uf = unzOpen(FileToExtract);
} #ifdef __LINUX__
chdir(oldpath);
#endif
if (uf==NULL)
{
ZipError=1;
return;
}
ZipError=0;
do_extract(uf,0,0);
}