LinuzCDVDiso: Added the dual layer detection fix already present in the internal iso loader (fixes running some DVD9 games from iso, like God of War 1 and Rogue Galaxy).

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@2524 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
Jake.Stine 2010-01-26 16:28:55 +00:00
parent 2dfad2fb24
commit e2581e5c72
1 changed files with 49 additions and 6 deletions

View File

@ -280,6 +280,21 @@ EXPORT_C_(s32) CDVDgetTD(u8 Track, cdvdTD *Buffer)
}
static s32 layer1start = -1;
static bool testForPartitionInfo( const u8 (&tempbuffer)[CD_FRAMESIZE_RAW] )
{
const int off = iso->blockofs;
// test for: CD001
return (
(tempbuffer[off+1] == 0x43) &&
(tempbuffer[off+2] == 0x44) &&
(tempbuffer[off+3] == 0x30) &&
(tempbuffer[off+4] == 0x30) &&
(tempbuffer[off+5] == 0x31)
);
}
EXPORT_C_(s32) CDVDgetTOC(void* toc)
{
u8 type = CDVDgetDiskType();
@ -296,7 +311,6 @@ EXPORT_C_(s32) CDVDgetTOC(void* toc)
if (layer1start != -2 && iso->blocks >= 0x300000)
{
int off = iso->blockofs;
u8* tempbuffer;
// dual sided
tocBuff[ 0] = 0x24;
@ -317,7 +331,8 @@ EXPORT_C_(s32) CDVDgetTOC(void* toc)
if (layer1start == -1)
{
printf("CDVD: searching for layer1...");
tempbuffer = (u8*)malloc(CD_FRAMESIZE_RAW * 10);
/*tempbuffer = (u8*)malloc(CD_FRAMESIZE_RAW * 10);
for (layer1start = (iso->blocks / 2 - 0x10) & ~0xf; layer1start < 0x200010; layer1start += 16)
{
isoReadBlock(iso, tempbuffer, layer1start);
@ -329,11 +344,39 @@ EXPORT_C_(s32) CDVDgetTOC(void* toc)
tempbuffer[off+5] == 0x31)
break;
}
free(tempbuffer);
free(tempbuffer);*/
uint midsector = (iso->blocks / 2) & ~0xf;
uint deviation = 0;
while( (layer1start == -1) && (deviation < midsector-16) )
{
u8 tempbuffer[CD_FRAMESIZE_RAW];
isoReadBlock(iso, tempbuffer, midsector-deviation);
if(testForPartitionInfo( tempbuffer ))
layer1start = midsector-deviation;
else
{
isoReadBlock(iso, tempbuffer, midsector+deviation);
if( testForPartitionInfo( tempbuffer ) )
layer1start = midsector+deviation;
}
if( layer1start != -1 )
{
if( tempbuffer[iso->blockofs] != 0x01 )
{
fprintf( stderr, "(LinuzCDVDiso): Invalid partition type on layer 1!? (type=0x%x)", tempbuffer[iso->blockofs] );
}
}
deviation += 16;
}
if (layer1start == 0x200010)
if (layer1start == -1)
{
printf("Couldn't find second layer on dual layer... ignoring\n");
printf("(LinuzCDVDiso): Couldn't find second layer on dual layer... ignoring\n");
// fake it
tocBuff[ 0] = 0x04;
tocBuff[ 1] = 0x02;
@ -350,7 +393,7 @@ EXPORT_C_(s32) CDVDgetTOC(void* toc)
return 0;
}
printf("found at 0x%8.8x\n", layer1start);
printf("(LinuzCDVDiso): found at 0x%8.8x\n", layer1start);
layer1start = layer1start + 0x30000 - 1;
}