mirror of
https://github.com/dborth/fceugx.git
synced 2025-01-07 14:28:18 +01:00
change to -O3, add file size/type check, increase max rom size to 3MB
This commit is contained in:
parent
f3956490f0
commit
20a3749909
@ -29,7 +29,7 @@ LANG := ENGLISH # Supported languages: ENGLISH
|
|||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
# options for code generation
|
# options for code generation
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
CFLAGS = -g -O2 -Wall $(MACHDEP) $(INCLUDE) -DNGC \
|
CFLAGS = -g -O3 -Wall $(MACHDEP) $(INCLUDE) -DNGC \
|
||||||
-DHAVE_ASPRINTF -DSTDC -DFCEU_VERSION_NUMERIC=9812 \
|
-DHAVE_ASPRINTF -DSTDC -DFCEU_VERSION_NUMERIC=9812 \
|
||||||
-D_SZ_ONE_DIRECTORY -D_LZMA_IN_CB -D_LZMA_OUT_READ \
|
-D_SZ_ONE_DIRECTORY -D_LZMA_IN_CB -D_LZMA_OUT_READ \
|
||||||
-DLANG_$(LANG)
|
-DLANG_$(LANG)
|
||||||
@ -40,7 +40,7 @@ LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map -Wl,--cref
|
|||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
# any extra libraries we wish to link with the project
|
# any extra libraries we wish to link with the project
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
LIBS := -lpng -lmxml -lbba -ltinysmb -lfat -lz -logc -lm -lfreetype
|
LIBS := -lmxml -lbba -ltinysmb -lfat -lz -logc -lm -lfreetype
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
# list of directories containing libraries, this must be the top level containing
|
# list of directories containing libraries, this must be the top level containing
|
||||||
|
@ -29,7 +29,7 @@ LANG := ENGLISH # Supported languages: ENGLISH
|
|||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
# options for code generation
|
# options for code generation
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
CFLAGS = -g -O2 -Wall $(MACHDEP) $(INCLUDE) -DNGC -DWII_DVD \
|
CFLAGS = -g -O3 -Wall $(MACHDEP) $(INCLUDE) -DNGC -DWII_DVD \
|
||||||
-DHAVE_ASPRINTF -DSTDC -DFCEU_VERSION_NUMERIC=9812 \
|
-DHAVE_ASPRINTF -DSTDC -DFCEU_VERSION_NUMERIC=9812 \
|
||||||
-D_SZ_ONE_DIRECTORY -D_LZMA_IN_CB -D_LZMA_OUT_READ \
|
-D_SZ_ONE_DIRECTORY -D_LZMA_IN_CB -D_LZMA_OUT_READ \
|
||||||
-DLANG_$(LANG)
|
-DLANG_$(LANG)
|
||||||
@ -40,7 +40,7 @@ LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map -Wl,--cref
|
|||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
# any extra libraries we wish to link with the project
|
# any extra libraries we wish to link with the project
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
LIBS := -ldi -lpng -lmxml -lfat -lwiiuse -lz -lbte -logc -lm -lfreetype -ltinysmb
|
LIBS := -ldi -lmxml -lfat -lwiiuse -lz -lbte -logc -lm -lfreetype -ltinysmb
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
# list of directories containing libraries, this must be the top level containing
|
# list of directories containing libraries, this must be the top level containing
|
||||||
|
@ -353,7 +353,8 @@ ParseDVDdirectory ()
|
|||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
int DirectorySearch(char dir[512])
|
int DirectorySearch(char dir[512])
|
||||||
{
|
{
|
||||||
for (int i = 0; i < maxfiles; i++ )
|
int i;
|
||||||
|
for (i = 0; i < maxfiles; i++ )
|
||||||
if (strcmp(filelist[i].filename, dir) == 0)
|
if (strcmp(filelist[i].filename, dir) == 0)
|
||||||
return i;
|
return i;
|
||||||
return -1;
|
return -1;
|
||||||
@ -366,7 +367,7 @@ int DirectorySearch(char dir[512])
|
|||||||
* Also loads the directory contents via ParseDVDdirectory()
|
* Also loads the directory contents via ParseDVDdirectory()
|
||||||
* It relies on dvddir, dvddirlength, and filelist being pre-populated
|
* It relies on dvddir, dvddirlength, and filelist being pre-populated
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
bool SwitchDVDFolder(char * dir, int maxDepth)
|
bool SwitchDVDFolderR(char * dir, int maxDepth)
|
||||||
{
|
{
|
||||||
if(maxDepth > 8) // only search to a max depth of 8 levels
|
if(maxDepth > 8) // only search to a max depth of 8 levels
|
||||||
return false;
|
return false;
|
||||||
@ -393,7 +394,7 @@ bool SwitchDVDFolder(char * dir, int maxDepth)
|
|||||||
if(lastdir)
|
if(lastdir)
|
||||||
return true;
|
return true;
|
||||||
else
|
else
|
||||||
return SwitchDVDFolder(nextdir, maxDepth++);
|
return SwitchDVDFolderR(nextdir, maxDepth++);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -413,20 +414,20 @@ bool SwitchDVDFolder(char origdir[])
|
|||||||
if(dir[strlen(dir)-1] == '/')
|
if(dir[strlen(dir)-1] == '/')
|
||||||
dir[strlen(dir)-1] = 0;
|
dir[strlen(dir)-1] = 0;
|
||||||
|
|
||||||
return SwitchDVDFolder(dirptr, 0);
|
return SwitchDVDFolderR(dirptr, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* LoadDVDFile
|
* LoadDVDFile
|
||||||
* This function will load a file from DVD.
|
* This function will load a file from DVD
|
||||||
* The values for offset and length are inherited from dvddir and
|
* The values for offset and length are inherited from dvddir and
|
||||||
* dvddirlength.
|
* dvddirlength.
|
||||||
*
|
*
|
||||||
* The buffer parameter should re-use the initial ROM buffer.
|
* The buffer parameter should re-use the initial ROM buffer
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
int
|
int
|
||||||
LoadDVDFile (unsigned char *buffer)
|
LoadDVDFile (unsigned char *buffer, int length)
|
||||||
{
|
{
|
||||||
int offset;
|
int offset;
|
||||||
int blocks;
|
int blocks;
|
||||||
@ -439,36 +440,36 @@ LoadDVDFile (unsigned char *buffer)
|
|||||||
offset = 0;
|
offset = 0;
|
||||||
discoffset = dvddir;
|
discoffset = dvddir;
|
||||||
ShowAction ((char*) "Loading...");
|
ShowAction ((char*) "Loading...");
|
||||||
dvd_read (readbuffer, 2048, discoffset);
|
|
||||||
|
|
||||||
int r = IsZipFile (readbuffer);
|
if(length > 0) // do a partial read (eg: to check file header)
|
||||||
|
|
||||||
if(r == 2) // 7z
|
|
||||||
{
|
{
|
||||||
WaitPrompt ((char *)"7z files are not supported!");
|
dvd_read (buffer, length, discoffset);
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
else // load whole file
|
||||||
|
{
|
||||||
|
dvd_read (readbuffer, 2048, discoffset);
|
||||||
|
|
||||||
if (r)
|
if (!IsZipFile (readbuffer))
|
||||||
{
|
|
||||||
return UnZipDVDFile (buffer, discoffset); // unzip from dvd
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (i = 0; i < blocks; i++)
|
|
||||||
{
|
{
|
||||||
dvd_read (readbuffer, 2048, discoffset);
|
for (i = 0; i < blocks; i++)
|
||||||
memcpy (buffer + offset, readbuffer, 2048);
|
{
|
||||||
offset += 2048;
|
dvd_read (readbuffer, 2048, discoffset);
|
||||||
discoffset += 2048;
|
memcpy (buffer + offset, readbuffer, 2048);
|
||||||
|
offset += 2048;
|
||||||
|
discoffset += 2048;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*** And final cleanup ***/
|
||||||
|
if (dvddirlength % 2048)
|
||||||
|
{
|
||||||
|
i = dvddirlength % 2048;
|
||||||
|
dvd_read (readbuffer, 2048, discoffset);
|
||||||
|
memcpy (buffer + offset, readbuffer, i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
/*** And final cleanup ***/
|
|
||||||
if (dvddirlength % 2048)
|
|
||||||
{
|
{
|
||||||
i = dvddirlength % 2048;
|
return UnZipDVDFile (buffer, discoffset); // unzip from dvd
|
||||||
dvd_read (readbuffer, 2048, discoffset);
|
|
||||||
memcpy (buffer + offset, readbuffer, i);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return dvddirlength;
|
return dvddirlength;
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
int getpvd ();
|
int getpvd ();
|
||||||
int ParseDVDdirectory ();
|
int ParseDVDdirectory ();
|
||||||
int LoadDVDFile (unsigned char *buffer);
|
int LoadDVDFile (unsigned char *buffer, int length);
|
||||||
bool TestDVD();
|
bool TestDVD();
|
||||||
int dvd_read (void *dst, unsigned int len, u64 offset);
|
int dvd_read (void *dst, unsigned int len, u64 offset);
|
||||||
bool SwitchDVDFolder(char dir[]);
|
bool SwitchDVDFolder(char dir[]);
|
||||||
|
@ -78,7 +78,7 @@ int main(int argc, char *argv[])
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// allocate memory to store rom
|
// allocate memory to store rom
|
||||||
nesrom = (unsigned char *)malloc(1024*1024*2); // 2 MB should be plenty
|
nesrom = (unsigned char *)malloc(1024*1024*3); // 3 MB should be plenty
|
||||||
|
|
||||||
/*** Minimal Emulation Loop ***/
|
/*** Minimal Emulation Loop ***/
|
||||||
if ( !FCEUI_Initialize() ) {
|
if ( !FCEUI_Initialize() ) {
|
||||||
|
@ -128,7 +128,7 @@ int GCMemROM(int method, int size)
|
|||||||
break;
|
break;
|
||||||
case METHOD_SMB:
|
case METHOD_SMB:
|
||||||
sprintf(filepath, "%s/disksys.rom", GCSettings.LoadFolder);
|
sprintf(filepath, "%s/disksys.rom", GCSettings.LoadFolder);
|
||||||
biosSize = LoadBufferFromSMB(tmpbuffer, filepath, NOTSILENT);
|
biosSize = LoadBufferFromSMB(tmpbuffer, filepath, 0, NOTSILENT);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,7 +162,7 @@ ParseFATdirectory(int method)
|
|||||||
* LoadFATFile
|
* LoadFATFile
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
int
|
int
|
||||||
LoadFATFile ()
|
LoadFATFile (char * rbuffer, int length)
|
||||||
{
|
{
|
||||||
char zipbuffer[2048];
|
char zipbuffer[2048];
|
||||||
char filepath[MAXPATHLEN];
|
char filepath[MAXPATHLEN];
|
||||||
@ -181,28 +181,28 @@ LoadFATFile ()
|
|||||||
handle = fopen (filepath, "rb");
|
handle = fopen (filepath, "rb");
|
||||||
if (handle > 0)
|
if (handle > 0)
|
||||||
{
|
{
|
||||||
fread (zipbuffer, 1, 2048, handle);
|
if(length > 0) // do a partial read (eg: to check file header)
|
||||||
|
|
||||||
int r = IsZipFile (zipbuffer);
|
|
||||||
|
|
||||||
if(r == 2) // 7z
|
|
||||||
{
|
{
|
||||||
WaitPrompt ((char *)"7z files are not supported!");
|
fread (rbuffer, 1, length, handle);
|
||||||
return 0;
|
size = length;
|
||||||
}
|
}
|
||||||
|
else // load whole file
|
||||||
|
{
|
||||||
|
fread (zipbuffer, 1, 2048, handle);
|
||||||
|
|
||||||
if (r)
|
if (IsZipFile (zipbuffer))
|
||||||
{
|
{
|
||||||
size = UnZipFATFile (nesrom, handle); // unzip from FAT
|
size = UnZipFATFile ((unsigned char *)rbuffer, handle); // unzip from FAT
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Just load the file up
|
// Just load the file up
|
||||||
fseek(handle, 0, SEEK_END);
|
fseek(handle, 0, SEEK_END);
|
||||||
size = ftell(handle); // get filesize
|
size = ftell(handle); // get filesize
|
||||||
fseek(handle, 2048, SEEK_SET); // seek back to point where we left off
|
fseek(handle, 2048, SEEK_SET); // seek back to point where we left off
|
||||||
memcpy (nesrom, zipbuffer, 2048); // copy what we already read
|
memcpy (rbuffer, zipbuffer, 2048); // copy what we already read
|
||||||
fread (nesrom + 2048, 1, size - 2048, handle);
|
fread (rbuffer + 2048, 1, size - 2048, handle);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fclose (handle);
|
fclose (handle);
|
||||||
return size;
|
return size;
|
||||||
@ -212,8 +212,6 @@ LoadFATFile ()
|
|||||||
WaitPrompt((char*) "Error opening file");
|
WaitPrompt((char*) "Error opening file");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
bool ChangeFATInterface(int method, bool silent);
|
bool ChangeFATInterface(int method, bool silent);
|
||||||
int ParseFATdirectory(int method);
|
int ParseFATdirectory(int method);
|
||||||
int LoadFATFile ();
|
int LoadFATFile (char * fbuffer, int length);
|
||||||
int SaveBufferToFAT (char *filepath, int datasize, bool silent);
|
int SaveBufferToFAT (char *filepath, int datasize, bool silent);
|
||||||
int LoadSaveBufferFromFAT (char *filepath, bool silent);
|
int LoadSaveBufferFromFAT (char *filepath, bool silent);
|
||||||
int LoadBufferFromFAT (char * buffer, char *filepath, bool silent);
|
int LoadBufferFromFAT (char * buffer, char *filepath, bool silent);
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
#include "memcardop.h"
|
#include "memcardop.h"
|
||||||
#include "pad.h"
|
#include "pad.h"
|
||||||
#include "fceuload.h"
|
#include "fceuload.h"
|
||||||
|
#include "gcunzip.h"
|
||||||
|
|
||||||
int offset;
|
int offset;
|
||||||
int selection;
|
int selection;
|
||||||
@ -190,6 +191,62 @@ int FileSortCallback(const void *f1, const void *f2)
|
|||||||
return stricmp(((FILEENTRIES *)f1)->filename, ((FILEENTRIES *)f2)->filename);
|
return stricmp(((FILEENTRIES *)f1)->filename, ((FILEENTRIES *)f2)->filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* IsValidROM
|
||||||
|
*
|
||||||
|
* Checks if the specified file is a valid ROM
|
||||||
|
* For now we will just check the file extension and file size
|
||||||
|
* If the file is a zip, we will check the file extension / file size of the
|
||||||
|
* first file inside
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
bool IsValidROM(int method)
|
||||||
|
{
|
||||||
|
// file size should be between 10K and 3MB
|
||||||
|
if(filelist[selection].length < (1024*10) ||
|
||||||
|
filelist[selection].length > (1024*1024*3))
|
||||||
|
{
|
||||||
|
WaitPrompt((char *)"Invalid file size!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strlen(filelist[selection].filename) > 4)
|
||||||
|
{
|
||||||
|
char * p = strrchr(filelist[selection].filename, '.');
|
||||||
|
|
||||||
|
if (p != NULL)
|
||||||
|
{
|
||||||
|
if(stricmp(p, ".zip") == 0)
|
||||||
|
{
|
||||||
|
// we need to check the file extension of the first file in the archive
|
||||||
|
char * zippedFilename = GetFirstZipFilename (method);
|
||||||
|
|
||||||
|
if(strlen(zippedFilename) > 4)
|
||||||
|
p = strrchr(zippedFilename, '.');
|
||||||
|
else
|
||||||
|
p = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(p != NULL)
|
||||||
|
{
|
||||||
|
if (
|
||||||
|
stricmp(p, ".nes") == 0 ||
|
||||||
|
stricmp(p, ".fds") == 0 ||
|
||||||
|
stricmp(p, ".nsf") == 0 ||
|
||||||
|
stricmp(p, ".unf") == 0 ||
|
||||||
|
stricmp(p, ".nez") == 0 ||
|
||||||
|
stricmp(p, ".unif") == 0
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
WaitPrompt((char *)"Unknown file type!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* StripExt
|
* StripExt
|
||||||
*
|
*
|
||||||
@ -307,17 +364,17 @@ int FileSelector (int method)
|
|||||||
{
|
{
|
||||||
case METHOD_SD:
|
case METHOD_SD:
|
||||||
case METHOD_USB:
|
case METHOD_USB:
|
||||||
size = LoadFATFile();
|
size = LoadFATFile((char *)nesrom, 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case METHOD_DVD:
|
case METHOD_DVD:
|
||||||
dvddir = filelist[selection].offset;
|
dvddir = filelist[selection].offset;
|
||||||
dvddirlength = filelist[selection].length;
|
dvddirlength = filelist[selection].length;
|
||||||
size = LoadDVDFile(nesrom);
|
size = LoadDVDFile(nesrom, 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case METHOD_SMB:
|
case METHOD_SMB:
|
||||||
size = LoadSMBFile();
|
size = LoadSMBFile((char *)nesrom, 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,11 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <zlib.h>
|
#include <zlib.h>
|
||||||
|
|
||||||
|
#include "fceuconfig.h"
|
||||||
#include "dvd.h"
|
#include "dvd.h"
|
||||||
|
#include "smbop.h"
|
||||||
|
#include "fileop.h"
|
||||||
#include "menudraw.h"
|
#include "menudraw.h"
|
||||||
#include "gcunzip.h"
|
#include "gcunzip.h"
|
||||||
|
|
||||||
@ -233,9 +237,47 @@ UnZipSMBFile (unsigned char *outbuffer, SMBFILE infile)
|
|||||||
return UnZipBuffer(outbuffer, 2);
|
return UnZipBuffer(outbuffer, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* GetFirstZipFilename
|
||||||
|
*
|
||||||
|
* Returns the filename of the first file in the zipped archive
|
||||||
|
* The idea here is to do the least amount of work required
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
char *
|
||||||
|
GetFirstZipFilename (int method)
|
||||||
|
{
|
||||||
|
char testbuffer[ZIPCHUNK];
|
||||||
|
|
||||||
|
// read start of ZIP
|
||||||
|
switch (method)
|
||||||
|
{
|
||||||
|
case METHOD_SD: // SD Card
|
||||||
|
case METHOD_USB: // USB
|
||||||
|
LoadFATFile (testbuffer, ZIPCHUNK);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case METHOD_DVD: // DVD
|
||||||
|
LoadDVDFile ((unsigned char *)testbuffer, ZIPCHUNK);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case METHOD_SMB: // From SMB
|
||||||
|
LoadSMBFile (testbuffer, ZIPCHUNK);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
testbuffer[28] = 0; // truncate - filename length is 2 bytes long (bytes 26-27)
|
||||||
|
int namelength = testbuffer[26]; // filename length starts 26 bytes in
|
||||||
|
|
||||||
|
char * firstFilename = &testbuffer[30]; // first filename of a ZIP starts 31 bytes in
|
||||||
|
firstFilename[namelength] = 0; // truncate at filename length
|
||||||
|
|
||||||
|
return firstFilename;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 7-zip functions are below. Have to be written to work with above.
|
* 7-zip functions are below. Have to be written to work with above.
|
||||||
*
|
*
|
||||||
else if (selection == 0 && inSz == true) {
|
else if (selection == 0 && inSz == true) {
|
||||||
rootdir = filelist[1].offset;
|
rootdir = filelist[1].offset;
|
||||||
rootdirlength = filelist[1].length;
|
rootdirlength = filelist[1].length;
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
#include <smb.h>
|
#include <smb.h>
|
||||||
|
|
||||||
extern int IsZipFile (char *buffer);
|
extern int IsZipFile (char *buffer);
|
||||||
|
char * GetFirstZipFilename(int method);
|
||||||
int UnZipFATFile (unsigned char *outbuffer, FILE* infile); // Reading from FAT
|
int UnZipFATFile (unsigned char *outbuffer, FILE* infile); // Reading from FAT
|
||||||
int UnZipDVDFile (unsigned char *outbuffer, u64 inoffset); // Reading from DVD
|
int UnZipDVDFile (unsigned char *outbuffer, u64 inoffset); // Reading from DVD
|
||||||
int UnZipSMBFile (unsigned char *outbuffer, SMBFILE infile); // Reading from SMB
|
int UnZipSMBFile (unsigned char *outbuffer, SMBFILE infile); // Reading from SMB
|
||||||
|
@ -216,9 +216,11 @@ ParseSMBdirectory ()
|
|||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Load SMB file
|
* Load SMB file
|
||||||
|
* rom - pointer to memory where ROM will be stored
|
||||||
|
* length - # bytes to read (0 for all)
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
int
|
int
|
||||||
LoadSMBFile ()
|
LoadSMBFile (char * rom, int length)
|
||||||
{
|
{
|
||||||
char filepath[MAXPATHLEN];
|
char filepath[MAXPATHLEN];
|
||||||
|
|
||||||
@ -230,8 +232,7 @@ LoadSMBFile ()
|
|||||||
WaitPrompt((char*) "Maximum filepath length reached!");
|
WaitPrompt((char*) "Maximum filepath length reached!");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
return LoadBufferFromSMB(rom, SMBPath(filepath), length, NOTSILENT);
|
||||||
return LoadBufferFromSMB((char *)nesrom, SMBPath(filepath), NOTSILENT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -287,11 +288,11 @@ SaveBufferToSMB (char *filepath, int datasize, bool silent)
|
|||||||
int
|
int
|
||||||
LoadSaveBufferFromSMB (char *filepath, bool silent)
|
LoadSaveBufferFromSMB (char *filepath, bool silent)
|
||||||
{
|
{
|
||||||
return LoadBufferFromSMB((char *)savebuffer, filepath, silent);
|
return LoadBufferFromSMB((char *)savebuffer, filepath, 0, silent);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
LoadBufferFromSMB (char * sbuffer, char *filepath, bool silent)
|
LoadBufferFromSMB (char * sbuffer, char *filepath, int length, bool silent)
|
||||||
{
|
{
|
||||||
if(!ConnectShare (NOTSILENT))
|
if(!ConnectShare (NOTSILENT))
|
||||||
return 0;
|
return 0;
|
||||||
@ -314,25 +315,24 @@ LoadBufferFromSMB (char * sbuffer, char *filepath, bool silent)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = SMB_ReadFile (sbuffer, 1024, boffset, smbfile);
|
if(length > 0) // do a partial read (eg: to check file header)
|
||||||
|
|
||||||
int r = IsZipFile (sbuffer);
|
|
||||||
|
|
||||||
if(r == 2) // 7z
|
|
||||||
{
|
{
|
||||||
WaitPrompt ((char *)"7z files are not supported!");
|
boffset = SMB_ReadFile (sbuffer, length, 0, smbfile);
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
else // load whole file
|
||||||
|
{
|
||||||
|
ret = SMB_ReadFile (sbuffer, 1024, boffset, smbfile);
|
||||||
|
|
||||||
if (r)
|
if (IsZipFile (sbuffer))
|
||||||
{
|
{
|
||||||
boffset = UnZipSMBFile ((unsigned char *)sbuffer, smbfile); // unzip from SMB
|
boffset = UnZipSMBFile ((unsigned char *)sbuffer, smbfile); // unzip from SMB
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Just load the file up
|
// Just load the file up
|
||||||
while ((ret = SMB_ReadFile (sbuffer + boffset, 1024, boffset, smbfile)) > 0)
|
while ((ret = SMB_ReadFile (sbuffer + boffset, 1024, boffset, smbfile)) > 0)
|
||||||
boffset += ret;
|
boffset += ret;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
SMB_CloseFile (smbfile);
|
SMB_CloseFile (smbfile);
|
||||||
|
|
||||||
|
@ -18,9 +18,9 @@ bool ConnectShare (bool silent);
|
|||||||
char * SMBPath(char * path);
|
char * SMBPath(char * path);
|
||||||
int UpdateSMBdirname();
|
int UpdateSMBdirname();
|
||||||
int ParseSMBdirectory ();
|
int ParseSMBdirectory ();
|
||||||
int LoadSMBFile ();
|
int LoadSMBFile (char * fbuffer, int length);
|
||||||
int LoadSaveBufferFromSMB (char *filepath, bool silent);
|
int LoadSaveBufferFromSMB (char *filepath, bool silent);
|
||||||
int LoadBufferFromSMB (char * sbuffer, char *filepath, bool silent);
|
int LoadBufferFromSMB (char * sbuffer, char *filepath, int length, bool silent);
|
||||||
int SaveBufferToSMB (char *filepath, int datasize, bool silent);
|
int SaveBufferToSMB (char *filepath, int datasize, bool silent);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user