tidy up some functions

This commit is contained in:
dborth 2008-09-26 22:28:57 +00:00
parent dfc7ddd8e3
commit 7f9f088ef3
7 changed files with 24 additions and 26 deletions

View File

@ -22,6 +22,8 @@ extern "C" {
}
#endif
#include "memmap.h"
#include "menudraw.h"
#include "snes9xGX.h"
#include "unzip.h"
@ -436,13 +438,14 @@ bool SwitchDVDFolder(char origdir[])
***************************************************************************/
int
LoadDVDFile (unsigned char *buffer)
LoadDVDFile ()
{
int offset;
int blocks;
int i;
u64 discoffset;
char readbuffer[2048];
unsigned char *rbuffer = (unsigned char *) Memory.ROM;
// How many 2k blocks to read
blocks = dvddirlength / 2048;
@ -456,7 +459,7 @@ LoadDVDFile (unsigned char *buffer)
for (i = 0; i < blocks; i++)
{
dvd_read (readbuffer, 2048, discoffset);
memcpy (buffer + offset, readbuffer, 2048);
memcpy (rbuffer + offset, readbuffer, 2048);
offset += 2048;
discoffset += 2048;
}
@ -466,12 +469,12 @@ LoadDVDFile (unsigned char *buffer)
{
i = dvddirlength % 2048;
dvd_read (readbuffer, 2048, discoffset);
memcpy (buffer + offset, readbuffer, i);
memcpy (rbuffer + offset, readbuffer, i);
}
}
else
{
return UnZipFile (buffer, discoffset); // unzip from dvd
return UnZipFile (rbuffer, discoffset); // unzip from dvd
}
return dvddirlength;
}

View File

@ -15,7 +15,7 @@
int getpvd ();
int ParseDVDdirectory ();
int LoadDVDFile (unsigned char *buffer);
int LoadDVDFile ();
bool TestDVD();
int dvd_read (void *dst, unsigned int len, u64 offset);
bool SwitchDVDFolder(char dir[]);

View File

@ -166,16 +166,14 @@ ParseFATdirectory(int method)
* LoadFATFile
***************************************************************************/
int
LoadFATFile (char *filename, int length)
LoadFATFile ()
{
char zipbuffer[2048];
char filepath[MAXPATHLEN];
FILE *handle;
unsigned char *rbuffer;
unsigned char *rbuffer = (unsigned char *) Memory.ROM;
u32 size;
rbuffer = (unsigned char *) Memory.ROM;
/* Check filename length */
if ((strlen(currentdir)+1+strlen(filelist[selection].filename)) < MAXPATHLEN)
sprintf(filepath, "%s/%s",currentdir,filelist[selection].filename);
@ -198,11 +196,10 @@ LoadFATFile (char *filename, int length)
{
// Just load the file up
fseek(handle, 0, SEEK_END);
length = ftell(handle); // get filesize
size = ftell(handle); // get filesize
fseek(handle, 2048, SEEK_SET); // seek back to point where we left off
memcpy (rbuffer, zipbuffer, 2048); // copy what we already read
fread (rbuffer + 2048, 1, length - 2048, handle);
size = length;
fread (rbuffer + 2048, 1, size - 2048, handle);
}
fclose (handle);
return size;

View File

@ -26,7 +26,7 @@
bool ChangeFATInterface(int method, bool silent);
int ParseFATdirectory(int method);
int LoadFATFile (char *filename, int length);
int LoadFATFile ();
int SaveBufferToFAT (char *filepath, int datasize, bool silent);
int LoadBufferFromFAT (char *filepath, bool silent);

View File

@ -322,20 +322,18 @@ int FileSelector (int method)
{
case METHOD_SD:
case METHOD_USB:
ARAM_ROMSIZE = LoadFATFile (filelist[selection].filename,
filelist[selection].length);
ARAM_ROMSIZE = LoadFATFile ();
break;
case METHOD_DVD:
dvddir = filelist[selection].offset;
dvddirlength = filelist[selection].length;
ARAM_ROMSIZE = LoadDVDFile (Memory.ROM);
ARAM_ROMSIZE = LoadDVDFile ();
break;
case METHOD_SMB:
ARAM_ROMSIZE =
LoadSMBFile (filelist[selection].filename,
filelist[selection].length);
LoadSMBFile ();
break;
}

View File

@ -216,7 +216,7 @@ ParseSMBdirectory ()
* Load SMB file
****************************************************************************/
int
LoadSMBFile (char *filename, int length)
LoadSMBFile ()
{
char filepath[MAXPATHLEN];
@ -236,7 +236,7 @@ LoadSMBFile (char *filename, int length)
* Write savebuffer to SMB file
****************************************************************************/
int
SaveBufferToSMB (char *filepath, int datasize, bool8 silent)
SaveBufferToSMB (char *filepath, int datasize, bool silent)
{
if(!ConnectShare (NOTSILENT))
return 0;
@ -282,14 +282,14 @@ SaveBufferToSMB (char *filepath, int datasize, bool8 silent)
// no buffer is specified - so use savebuffer
int
LoadBufferFromSMB (char *filepath, bool8 silent)
LoadBufferFromSMB (char *filepath, bool silent)
{
ClearSaveBuffer ();
return LoadBufferFromSMB((char *)savebuffer, filepath, silent);
}
int
LoadBufferFromSMB (char * sbuffer, char *filepath, bool8 silent)
LoadBufferFromSMB (char * sbuffer, char *filepath, bool silent)
{
if(!ConnectShare (NOTSILENT))
return 0;

View File

@ -19,9 +19,9 @@ bool ConnectShare (bool silent);
char * SMBPath(char * path);
int UpdateSMBdirname();
int ParseSMBdirectory ();
int LoadSMBFile (char *filename, int length);
int LoadBufferFromSMB (char *filepath, bool8 silent);
int LoadBufferFromSMB (char * sbuffer, char *filepath, bool8 silent);
int SaveBufferToSMB (char *filepath, int datasize, bool8 silent);
int LoadSMBFile ();
int LoadBufferFromSMB (char *filepath, bool silent);
int LoadBufferFromSMB (char * sbuffer, char *filepath, bool silent);
int SaveBufferToSMB (char *filepath, int datasize, bool silent);
#endif