minor cleanup & changes

This commit is contained in:
spacy51 2008-01-10 19:10:28 +00:00
parent 68709753ec
commit 4e6b8196eb
6 changed files with 336 additions and 706 deletions

View File

@ -20,6 +20,8 @@ Important:
Less important: Less important:
- Update 7-Zip code from 4.23 to current (4.57)
- Add documentation for VBA-M (configuration guide) - Add documentation for VBA-M (configuration guide)
- DDraw, D3D, OGL: Add full screen device & frequency selection - DDraw, D3D, OGL: Add full screen device & frequency selection

View File

@ -1300,9 +1300,7 @@ int CPULoadRom(const char *szFile)
return 0; return 0;
} }
u8 *whereToLoad = rom; u8 *whereToLoad = cpuIsMultiBoot ? workRAM : rom;
if(cpuIsMultiBoot)
whereToLoad = workRAM;
if(CPUIsELF(szFile)) { if(CPUIsELF(szFile)) {
FILE *f = fopen(szFile, "rb"); FILE *f = fopen(szFile, "rb");

View File

@ -457,20 +457,6 @@ bool utilIsGBImage(const char * file)
return false; return false;
} }
bool utilIsZipFile(const char *file)
{
if(strlen(file) > 4) {
const char * p = strrchr(file,'.');
if(p != NULL) {
if(_stricmp(p, ".zip") == 0)
return true;
}
}
return false;
}
bool utilIsGzipFile(const char *file) bool utilIsGzipFile(const char *file)
{ {
if(strlen(file) > 3) { if(strlen(file) > 3) {
@ -487,7 +473,8 @@ bool utilIsGzipFile(const char *file)
return false; return false;
} }
void utilGetBaseName(const char *file, char *buffer) // strip .gz or .z off end
void utilStripDoubleExtension(const char *file, char *buffer)
{ {
if(buffer != file) // allows conversion in place if(buffer != file) // allows conversion in place
strcpy(buffer, file); strcpy(buffer, file);
@ -519,7 +506,7 @@ static File_Extractor* scan_arc(const char *file, bool (*accept)(const char *),
strncpy(buffer,fex_name(fe),sizeof buffer); strncpy(buffer,fex_name(fe),sizeof buffer);
buffer [sizeof buffer-1] = '\0'; buffer [sizeof buffer-1] = '\0';
utilGetBaseName(buffer, buffer); // strip .gz or .z off end utilStripDoubleExtension(buffer, buffer);
if(accept(buffer)) { if(accept(buffer)) {
found = true; found = true;
@ -578,7 +565,7 @@ u8 *utilLoad(const char *file,
{ {
// find image file // find image file
char buffer [2048]; char buffer [2048];
File_Extractor* fe = scan_arc(file,accept,buffer); File_Extractor *fe = scan_arc(file,accept,buffer);
if(!fe) if(!fe)
return NULL; return NULL;
@ -590,6 +577,7 @@ u8 *utilLoad(const char *file,
u8 *image = data; u8 *image = data;
if(image == NULL) { if(image == NULL) {
// allocate buffer memory if none was passed to the function
image = (u8 *)malloc(utilGetSize(size)); image = (u8 *)malloc(utilGetSize(size));
if(image == NULL) { if(image == NULL) {
fex_close(fe); fex_close(fe);
@ -601,7 +589,7 @@ u8 *utilLoad(const char *file,
} }
// Read image // Read image
int read = fileSize <= size ? fileSize : size; int read = fileSize <= size ? fileSize : size; // do not read beyond file
fex_err_t err = fex_read_once(fe, image, read); fex_err_t err = fex_read_once(fe, image, read);
fex_close(fe); fex_close(fe);
if(err) { if(err) {

View File

@ -40,10 +40,8 @@ extern bool utilWriteBMPFile(const char *, int, int, u8 *);
extern void utilApplyIPS(const char *ips, u8 **rom, int *size); extern void utilApplyIPS(const char *ips, u8 **rom, int *size);
extern bool utilIsGBAImage(const char *); extern bool utilIsGBAImage(const char *);
extern bool utilIsGBImage(const char *); extern bool utilIsGBImage(const char *);
extern bool utilIsZipFile(const char *);
extern bool utilIsGzipFile(const char *); extern bool utilIsGzipFile(const char *);
extern bool utilIsRarFile(const char *); extern void utilStripDoubleExtension(const char *, char *);
extern void utilGetBaseName(const char *, char *);
extern IMAGE_TYPE utilFindType(const char *); extern IMAGE_TYPE utilFindType(const char *);
extern u8 *utilLoad(const char *, extern u8 *utilLoad(const char *,
bool (*)(const char*), bool (*)(const char*),

View File

@ -483,9 +483,9 @@ bool MainWnd::FileRun()
char tempName[2048]; char tempName[2048];
char file[2048]; char file[2048];
utilGetBaseName(theApp.szFile, tempName); utilStripDoubleExtension(theApp.szFile, tempName);
_fullpath(file, tempName, 1024); _fullpath(file, tempName, 2048);
theApp.filename = file; theApp.filename = file;
int index = theApp.filename.ReverseFind('.'); int index = theApp.filename.ReverseFind('.');
@ -569,7 +569,7 @@ bool MainWnd::FileRun()
strcat(tempName, "\\vba-over.ini"); strcat(tempName, "\\vba-over.ini");
UINT i = GetPrivateProfileInt(buffer, UINT i = GetPrivateProfileInt(buffer,
"rtcEnabled", "rtcEnabled",
-1, -1,
tempName); tempName);
if(i != (UINT)-1) if(i != (UINT)-1)

File diff suppressed because it is too large Load Diff