fix DVD/7z

This commit is contained in:
dborth 2008-10-15 18:29:14 +00:00
parent 43c55a17d3
commit 2e3068b28b
3 changed files with 12 additions and 14 deletions

View File

@ -34,8 +34,6 @@ bool isWii = false;
volatile unsigned long *dvd = (volatile unsigned long *) 0xCC006000; volatile unsigned long *dvd = (volatile unsigned long *) 0xCC006000;
#endif #endif
unsigned char dvdbuffer[2048];
/**************************************************************************** /****************************************************************************
* dvd_read * dvd_read
* *
@ -76,16 +74,17 @@ dvd_read (void *dst, unsigned int len, u64 offset)
if (dvd[0] & 0x4) if (dvd[0] & 0x4)
return 0; return 0;
#else #else
off_size = (offset << 2) - ALIGN_BACKWARD((offset << 2),0x800); off_size = offset - ALIGN_BACKWARD(offset,0x800);
if (DI_ReadDVD( if (DI_ReadDVD(
buffer, buffer,
(ALIGN_FORWARD((offset << 2) + len,0x800) - ALIGN_BACKWARD((offset << 2),0x800)) >> 11, (ALIGN_FORWARD(offset + len,0x800) - ALIGN_BACKWARD(offset,0x800)) >> 11,
(u32)(ALIGN_BACKWARD(offset << 2, 0x800) >> 11) (u32)(ALIGN_BACKWARD(offset, 0x800) >> 11)
)) ))
return 0; return 0;
#endif #endif
memcpy (dst, buffer+off_size, len); memcpy (dst, buffer+off_size, len);
free(buffer);
return 1; return 1;
} }
@ -244,6 +243,7 @@ getpvd ()
{ {
int sector = 16; int sector = 16;
u32 rootdir32; u32 rootdir32;
unsigned char dvdbuffer[2048];
dvddir = dvddirlength = 0; dvddir = dvddirlength = 0;
IsJoliet = -1; IsJoliet = -1;
@ -328,7 +328,7 @@ bool TestDVD()
***************************************************************************/ ***************************************************************************/
static int diroffset = 0; static int diroffset = 0;
static int static int
getentry (int entrycount) getentry (int entrycount, unsigned char dvdbuffer[])
{ {
char fname[512]; /* Huge, but experience has determined this */ char fname[512]; /* Huge, but experience has determined this */
char *ptr; char *ptr;
@ -448,6 +448,7 @@ ParseDVDdirectory ()
u64 rdoffset; u64 rdoffset;
int len = 0; int len = 0;
int filecount = 0; int filecount = 0;
unsigned char dvdbuffer[2048];
// initialize selection // initialize selection
selection = offset = 0; selection = offset = 0;
@ -467,7 +468,7 @@ ParseDVDdirectory ()
diroffset = 0; diroffset = 0;
while (getentry (filecount)) while (getentry (filecount, dvdbuffer))
{ {
if(strlen(filelist[filecount].filename) > 0 && filecount < MAXFILES) if(strlen(filelist[filecount].filename) > 0 && filecount < MAXFILES)
filecount++; filecount++;

View File

@ -371,6 +371,7 @@ int FileSelector (int method)
{ {
if(method == METHOD_DVD) if(method == METHOD_DVD)
{ {
// go to directory the 7z was in
dvddir = filelist[0].offset; dvddir = filelist[0].offset;
dvddirlength = filelist[0].length; dvddirlength = filelist[0].length;
} }

View File

@ -436,18 +436,14 @@ int SzParse(char * filepath, int method)
{ {
// Parses the 7z into a full file listing // Parses the 7z into a full file listing
// store the current 7z data
unsigned int oldLength = filelist[selection].length;
u64 oldOffset = filelist[selection].offset;
// erase all previous entries // erase all previous entries
memset(&filelist, 0, sizeof(FILEENTRIES) * MAXFILES); memset(&filelist, 0, sizeof(FILEENTRIES) * MAXFILES);
// add '..' folder // add '..' folder in case the user wants exit the 7z
strncpy(filelist[0].displayname, "..", 2); strncpy(filelist[0].displayname, "..", 2);
filelist[0].flags = 1; filelist[0].flags = 1;
filelist[0].length = oldLength; filelist[0].offset = dvddir;
filelist[0].offset = oldOffset; // in case the user wants exit 7z filelist[0].length = dvddirlength;
// get contents and parse them into file list structure // get contents and parse them into file list structure
unsigned int SzI, SzJ; unsigned int SzI, SzJ;