mirror of
https://github.com/dborth/snes9xgx.git
synced 2024-11-01 00:15:14 +01:00
fix DVD loading
This commit is contained in:
parent
bab9a078a5
commit
0aabe352af
@ -432,7 +432,7 @@ getentry (int entrycount, unsigned char dvdbuffer[])
|
||||
if(dvddir == dvdrootdir) // at root already, don't show ..
|
||||
fname[0] = 0;
|
||||
else
|
||||
strcpy (fname, "Up One Level");
|
||||
strcpy (fname, "..");
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -463,8 +463,16 @@ getentry (int entrycount, unsigned char dvdbuffer[])
|
||||
memset(&(browserList[entrycount]), 0, sizeof(BROWSERENTRY)); // clear the new entry
|
||||
|
||||
strncpy (browserList[entrycount].filename, fname, MAXJOLIET);
|
||||
|
||||
if(strcmp(fname,"..") == 0)
|
||||
{
|
||||
sprintf(browserList[entrycount].displayname, "Up One Level");
|
||||
}
|
||||
else
|
||||
{
|
||||
StripExt(tmpname, fname); // hide file extension
|
||||
strncpy (browserList[entrycount].displayname, tmpname, MAXDISPLAY);
|
||||
}
|
||||
|
||||
memcpy (&offset32, &dvdbuffer[diroffset + EXTENT], 4);
|
||||
|
||||
@ -588,13 +596,18 @@ static bool SwitchDVDFolderR(char * dir, int maxDepth)
|
||||
|
||||
if(dirindex >= 0)
|
||||
{
|
||||
dvddir = browserList[dirindex].offset;
|
||||
dvddirlength = browserList[dirindex].length;
|
||||
browser.selIndex = dirindex;
|
||||
UpdateDirName(METHOD_DVD);
|
||||
|
||||
if(browserList[dirindex].isdir) // only parse directories
|
||||
{
|
||||
UpdateDirName(METHOD_DVD);
|
||||
ParseDVDdirectory();
|
||||
}
|
||||
else
|
||||
{
|
||||
dvddir = browserList[dirindex].offset;
|
||||
dvddirlength = browserList[dirindex].length;
|
||||
}
|
||||
|
||||
if(lastdir)
|
||||
return true;
|
||||
@ -709,16 +722,27 @@ done:
|
||||
int
|
||||
LoadDVDFile(char * buffer, char *filepath, int datasize, bool silent)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
// retain original browser information
|
||||
char origDir[MAXPATHLEN];
|
||||
memset(origDir, 0, MAXPATHLEN);
|
||||
strncpy(origDir, browser.dir, MAXPATHLEN);
|
||||
int origSelIndex = browser.selIndex;
|
||||
int origPageIndex = browser.selIndex;
|
||||
|
||||
if(SwitchDVDFolder(filepath))
|
||||
{
|
||||
return LoadDVDFileOffset ((unsigned char *)buffer, datasize);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!silent)
|
||||
ret = LoadDVDFileOffset ((unsigned char *)buffer, datasize);
|
||||
else if(!silent)
|
||||
ErrorPrompt("Error loading file!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
// restore browser information
|
||||
memset(browser.dir, 0, MAXPATHLEN);
|
||||
strncpy(browser.dir, origDir, MAXPATHLEN);
|
||||
browser.selIndex = origSelIndex;
|
||||
browser.pageIndex = origPageIndex;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -390,39 +390,6 @@ FreeSaveBuffer ()
|
||||
savebuffer = NULL;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* FindBufferSize()
|
||||
* Finds the position of the last bit written to the buffer
|
||||
* This function isn't perfect, but it should get the job done
|
||||
***************************************************************************/
|
||||
int FindBufferSize(char * buffer, int maxsize)
|
||||
{
|
||||
int datasize = maxsize; // we'll start at the max size
|
||||
|
||||
char check = buffer[datasize];
|
||||
while(check == 0)
|
||||
{
|
||||
datasize -= 16384;
|
||||
check = buffer[datasize];
|
||||
}
|
||||
datasize += 16384;
|
||||
check = buffer[datasize];
|
||||
while(check == 0)
|
||||
{
|
||||
datasize -= 1024;
|
||||
check = buffer[datasize];
|
||||
}
|
||||
datasize += 1024;
|
||||
check = buffer[datasize];
|
||||
while(check == 0)
|
||||
{
|
||||
datasize -= 1;
|
||||
check = buffer[datasize];
|
||||
}
|
||||
datasize += 2; // include last byte AND a null byte
|
||||
return datasize;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* LoadSzFile
|
||||
* Loads the selected file # from the specified 7z into rbuffer
|
||||
|
@ -30,7 +30,6 @@ bool ChangeInterface(int method, bool silent);
|
||||
int ParseDirectory();
|
||||
void AllocSaveBuffer();
|
||||
void FreeSaveBuffer();
|
||||
int FindBufferSize(char * buffer, int maxsize);
|
||||
u32 LoadFile(char * rbuffer, char *filepath, u32 length, int method, bool silent);
|
||||
u32 LoadFile(char * filepath, int method, bool silent);
|
||||
u32 LoadSzFile(char * filepath, unsigned char * rbuffer);
|
||||
|
@ -211,7 +211,7 @@ WindowPrompt(const char *title, const char *msg, const char *btn1Label, const ch
|
||||
/*static u32 arena1mem = 0;
|
||||
static u32 arena2mem = 0;
|
||||
static char mem[150] = { 0 };
|
||||
static GuiText * memTxt;*/
|
||||
static GuiText * memTxt = NULL;*/
|
||||
|
||||
static void *
|
||||
UpdateGUI (void *arg)
|
||||
@ -229,7 +229,7 @@ UpdateGUI (void *arg)
|
||||
arena2mem = (u32)SYS_GetArena2Hi() - (u32)SYS_GetArena2Lo();
|
||||
#endif
|
||||
sprintf(mem, "A1: %u / A2: %u", arena1mem, arena2mem);
|
||||
memTxt->SetText(mem);*/
|
||||
if(memTxt) memTxt->SetText(mem);*/
|
||||
|
||||
mainWindow->Draw();
|
||||
|
||||
@ -3276,6 +3276,12 @@ MainMenu (int menu)
|
||||
mainWindow->Append(bgBottomImg);
|
||||
mainWindow->Append(btnLogo);
|
||||
|
||||
/*// memory usage - for debugging
|
||||
memTxt = new GuiText(NULL, 18, (GXColor){255, 255, 255, 255});
|
||||
memTxt->SetAlignment(ALIGN_LEFT, ALIGN_TOP);
|
||||
memTxt->SetPosition(20, 20);
|
||||
mainWindow->Append(memTxt);*/
|
||||
|
||||
if(currentMenu == MENU_GAMESELECTION)
|
||||
ResumeGui();
|
||||
|
||||
@ -3284,20 +3290,11 @@ MainMenu (int menu)
|
||||
SavePrefs(SILENT);
|
||||
|
||||
#ifndef NO_SOUND
|
||||
if(currentMenu == MENU_GAMESELECTION)
|
||||
{
|
||||
bgMusic = new GuiSound(bg_music_ogg, bg_music_ogg_size, SOUND_OGG);
|
||||
bgMusic->SetVolume(GCSettings.MusicVolume);
|
||||
bgMusic->Play(); // startup music
|
||||
}
|
||||
if(currentMenu == MENU_GAMESELECTION) bgMusic->Play(); // startup music
|
||||
#endif
|
||||
|
||||
// memory usage - for debugging
|
||||
/*memTxt = new GuiText(NULL, 18, (GXColor){255, 255, 255, 255});
|
||||
memTxt->SetAlignment(ALIGN_RIGHT, ALIGN_TOP);
|
||||
memTxt->SetPosition(-20, 40);
|
||||
mainWindow->Append(memTxt);*/
|
||||
|
||||
while(currentMenu != MENU_EXIT || SNESROMSize <= 0)
|
||||
{
|
||||
switch (currentMenu)
|
||||
|
Loading…
Reference in New Issue
Block a user