mirror of https://github.com/PCSX2/pcsx2.git
Layer break search works on an inside->out path now (should be a good bit faster for most images).
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@2266 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
fedbb42a96
commit
c2368da81c
|
@ -127,13 +127,26 @@ s32 CALLBACK ISOgetTD(u8 Track, cdvdTD *Buffer)
|
||||||
#include "gui/App.h"
|
#include "gui/App.h"
|
||||||
#include "Utilities/HashMap.h"
|
#include "Utilities/HashMap.h"
|
||||||
|
|
||||||
|
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)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
static bool FindLayer1Start()
|
static bool FindLayer1Start()
|
||||||
{
|
{
|
||||||
if( (layer1start != -1) || (iso->blocks < 0x230540) ) return true;
|
if( (layer1start != -1) || (iso->blocks < 0x230540) ) return true;
|
||||||
|
|
||||||
Console.WriteLn("CDVDiso: searching for layer1...");
|
Console.WriteLn("CDVDiso: searching for layer1...");
|
||||||
|
|
||||||
const int off = iso->blockofs;
|
|
||||||
int blockresult = -1;
|
int blockresult = -1;
|
||||||
|
|
||||||
// Check the ini file cache first:
|
// Check the ini file cache first:
|
||||||
|
@ -152,11 +165,7 @@ static bool FindLayer1Start()
|
||||||
u8 tempbuffer[CD_FRAMESIZE_RAW];
|
u8 tempbuffer[CD_FRAMESIZE_RAW];
|
||||||
isoReadBlock(iso, tempbuffer, blockresult);
|
isoReadBlock(iso, tempbuffer, blockresult);
|
||||||
|
|
||||||
if ((tempbuffer[off+1] == 0x43) &&
|
if( testForPartitionInfo( tempbuffer ) )
|
||||||
(tempbuffer[off+2] == 0x44) &&
|
|
||||||
(tempbuffer[off+3] == 0x30) &&
|
|
||||||
(tempbuffer[off+4] == 0x30) &&
|
|
||||||
(tempbuffer[off+5] == 0x31) )
|
|
||||||
{
|
{
|
||||||
Console.WriteLn( "CDVDiso: loaded second layer from settings cache, sector=0x%8.8x", blockresult );
|
Console.WriteLn( "CDVDiso: loaded second layer from settings cache, sector=0x%8.8x", blockresult );
|
||||||
layer1start = blockresult;
|
layer1start = blockresult;
|
||||||
|
@ -173,42 +182,47 @@ static bool FindLayer1Start()
|
||||||
|
|
||||||
if( layer1start == -1 )
|
if( layer1start == -1 )
|
||||||
{
|
{
|
||||||
// Manual search required. Implementation (should) uses a two-pass search algo. The first
|
|
||||||
// pass looks on 16-sector boundaries of a limited range around the center of the image, and
|
// Layer sizes are arbitrary, and either layer could be the smaller (GoW and Rogue Galaxy
|
||||||
// if that fails a second search of all aligned blocks is performed. Layer sizes are arbitrary,
|
// both have Layer1 larger than Layer0 for example), so we have to brute-force the search
|
||||||
// and either layer could be the smaller (GoW and Rogue Galaxy both have Layer1 larger
|
// from some arbitrary start position.
|
||||||
// than Layer0 for example), so we have to brute-force the search from some arbitrary
|
|
||||||
// start position (I choose 25%)!
|
|
||||||
//
|
//
|
||||||
// [TODO] Currently only the first pass is performed.
|
// Method: Inside->out. We start at the middle of the image and work our way out toward
|
||||||
|
// both the beginning and end of the image at the same time. Most images have the layer
|
||||||
|
// break quite close to the middle of the image, so this should be pretty fast in most cases.
|
||||||
|
|
||||||
// [TODO] Layer searching can be slow, especially for compressed disc images, so it would
|
// [TODO] Layer searching can be slow, especially for compressed disc images, so it would
|
||||||
// be quite courteous to pop up a status dialog bar that lets the user know that it's
|
// be quite courteous to pop up a status dialog bar that lets the user know that it's
|
||||||
// thinking. Since we're not on the GUI thread, we'll need to establish some messages
|
// thinking. Since we're not on the GUI thread, we'll need to establish some messages
|
||||||
// to create the window and pass progress increments back to it.
|
// to create the window and pass progress increments back to it.
|
||||||
|
|
||||||
uint searchstart = (uint)(iso->blocks * 0.25) & ~0xf;
|
|
||||||
uint searchend = (uint)(iso->blocks * 0.75) & ~0xf;
|
|
||||||
|
|
||||||
for( uint sector=searchstart; (layer1start==-1) && (sector<=searchend); sector += 16)
|
uint midsector = (iso->blocks / 2) & ~0xf;
|
||||||
|
uint deviation = 0;
|
||||||
|
|
||||||
|
//for( uint sector=searchstart; (layer1start==-1) && (sector<=searchend); sector += 16)
|
||||||
|
while( (layer1start == -1) && (deviation < midsector-16) )
|
||||||
{
|
{
|
||||||
u8 tempbuffer[CD_FRAMESIZE_RAW];
|
u8 tempbuffer[CD_FRAMESIZE_RAW];
|
||||||
isoReadBlock(iso, tempbuffer, sector);
|
isoReadBlock(iso, tempbuffer, midsector-deviation);
|
||||||
|
|
||||||
// test for: CD001
|
if(testForPartitionInfo( tempbuffer ))
|
||||||
if ((tempbuffer[off+1] == 0x43) &&
|
layer1start = midsector-deviation;
|
||||||
(tempbuffer[off+2] == 0x44) &&
|
else
|
||||||
(tempbuffer[off+3] == 0x30) &&
|
|
||||||
(tempbuffer[off+4] == 0x30) &&
|
|
||||||
(tempbuffer[off+5] == 0x31)
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
if( !pxAssertDev( tempbuffer[off+0] == 0x01, "Layer1-Detect: CD001 tag found, but the partition type is invalid." ) )
|
isoReadBlock(iso, tempbuffer, midsector+deviation);
|
||||||
|
if( testForPartitionInfo( tempbuffer ) )
|
||||||
|
layer1start = midsector+deviation;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( layer1start != -1 )
|
||||||
{
|
{
|
||||||
Console.Error( "CDVDiso: Invalid partition type on layer 1!? (type=0x%x)", tempbuffer[off+0] );
|
if( !pxAssertDev( tempbuffer[iso->blockofs] == 0x01, "Layer1-Detect: CD001 tag found, but the partition type is invalid." ) )
|
||||||
|
{
|
||||||
|
Console.Error( "CDVDiso: Invalid partition type on layer 1!? (type=0x%x)", tempbuffer[iso->blockofs] );
|
||||||
}
|
}
|
||||||
layer1start = sector;
|
|
||||||
}
|
}
|
||||||
|
deviation += 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( layer1start == -1 )
|
if( layer1start == -1 )
|
||||||
|
|
|
@ -91,7 +91,7 @@ IsoDirectory::IsoDirectory(SectorSource& r)
|
||||||
if( !isValid )
|
if( !isValid )
|
||||||
throw Exception::BadStream( "IsoFS", "Root directory not found on ISO image." );
|
throw Exception::BadStream( "IsoFS", "Root directory not found on ISO image." );
|
||||||
|
|
||||||
DevCon.WriteLn( "(IsoFS) Filesystem is %s", FStype_ToString() );
|
DevCon.WriteLn( "(IsoFS) Filesystem is %s", FStype_ToString().c_str() );
|
||||||
Init( rootDirEntry );
|
Init( rootDirEntry );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue