Skip to content

Commit

Permalink
Fixed detection of dodgy Japan PSX games that have no SYSTEM.CNF file
Browse files Browse the repository at this point in the history
  • Loading branch information
Asnivor committed Oct 13, 2017
1 parent e61a4f7 commit 73d2870
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 10 deletions.
8 changes: 6 additions & 2 deletions DiscTools/Inspection/InterroAll.cs
Original file line number Diff line number Diff line change
Expand Up @@ -220,13 +220,15 @@ public DetectedDiscType InterrogateALL()
currSector = data;
string dataStr = System.Text.Encoding.Default.GetString(data);

// psx
// psx - dont bother
/*
if (GetPSXData(dataStr))
return DiscSubType;
if (GetPSPData(dataStr))
return DetectedDiscType.SonyPSP;

*/
// saturn
if (GetSaturnData(dataStr))
return DetectedDiscType.SegaSaturn;
Expand Down Expand Up @@ -293,12 +295,14 @@ public DetectedDiscType InterrogateALL()
currSector = data;
string dataStr = System.Text.Encoding.Default.GetString(data);

/*
// psx
if (GetPSXData(dataStr))
return DiscSubType;
if (GetPSPData(dataStr))
return DetectedDiscType.SonyPSP;
*/

// saturn
if (GetSaturnData(dataStr))
Expand Down
55 changes: 50 additions & 5 deletions DiscTools/Inspection/InterroPSX.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ public partial class Interrogator
public bool ScanISOPSX()
{
if (discI.Data._ISOData.ApplicationIdentifier == "PLAYSTATION")
{
{
// store lba for SYSTEM.CNF
var cnf = discI.Data._ISOData.ISOFiles.Where(a => a.Key.Contains("SYSTEM.CNF")).FirstOrDefault();
if (cnf.Key.Contains("SYSTEM.CNF"))
KeyValuePair<string, ISO.ISONode> cnf = discI.Data._ISOData.ISOFiles.Where(a => a.Key.Contains("SYSTEM.CNF")).FirstOrDefault();
if (cnf.Key != null && cnf.Key.Contains("SYSTEM.CNF"))
{
ifn = cnf.Value;
CurrentLBA = Convert.ToInt32(ifn.Offset);
Expand All @@ -25,7 +25,50 @@ public bool ScanISOPSX()
CurrentLBA = 23;
}

return GetPSXData();
if (GetPSXData())
return true;

// some jap discs (thunder storm and road blaster) appear not to even have a SYSTEM.CNF
// detect whether PSX.EXE exists, and if so try and parse this first
KeyValuePair<string, ISO.ISONode> psx = discI.Data._ISOData.ISOFiles.Where(a => a.Key.Contains("PSX.EXE")).FirstOrDefault();
if (psx.Key != null && psx.Key.Contains("PSX.EXE"))
{
ifn = psx.Value;
CurrentLBA = Convert.ToInt32(ifn.Offset);

byte[] data = di.ReadData(CurrentLBA, 2048);
byte[] data32 = data.ToList().ToArray();

string sS = System.Text.Encoding.Default.GetString(data32);

if (sS.Contains("Sony Computer Entertainment Inc. for Japan"))
{
// it is PSX - try and get the serial - may need to seek forward a bit
for (int i = CurrentLBA; i < CurrentLBA + ifn.Length; i++)
{
byte[] d = di.ReadData(i, 2048);
string s = System.Text.Encoding.Default.GetString(d);

if (s.ToUpper().Contains("SLPS"))
{
int ind = s.IndexOf("SLPS");
char[] serialChars = s.Substring(s.IndexOf("SLPS")).Take(10).ToArray();
string serial = new string(serialChars).Trim();
discI.Data.SerialNumber = serial;
discI.Data.GameTitle = discI.Data._ISOData.VolumeIdentifier;
discI.Data.Publisher = discI.Data._ISOData.PublisherIdentifier;
discI.Data.Developer = discI.Data._ISOData.DataPreparerIdentifier;
discI.Data.AreaCodes = "JAPAN";
break;
}
}
DiscSubType = DetectedDiscType.SonyPSX;
return true;
}

//if (GetPSXData())
return true;
}
}

return false;
Expand All @@ -34,7 +77,7 @@ public bool ScanISOPSX()
public bool GetPSXData()
{
byte[] data = di.GetPSXSerialNumber(CurrentLBA);
byte[] data32 = data.ToList().Take(200).ToArray();
byte[] data32 = data.ToList().ToArray();

string sS = System.Text.Encoding.Default.GetString(data32);

Expand Down Expand Up @@ -118,6 +161,8 @@ public bool GetPSXData(string lbaString)





return false;
}
}
Expand Down
8 changes: 6 additions & 2 deletions DiscTools/Inspection/InterroSpecific.cs
Original file line number Diff line number Diff line change
Expand Up @@ -300,9 +300,10 @@ public DetectedDiscType InterrogateSpecific(DetectedDiscType systemType)
for (int i = 0; i < 10000; i++)
{
byte[] data = di.ReadData(i, 2048);
CurrentLBA = i;
currSector = data;
string dataStr = System.Text.Encoding.Default.GetString(data);

/*
// psx
if (systemType == DetectedDiscType.SonyPSX)
{
Expand All @@ -316,6 +317,7 @@ public DetectedDiscType InterrogateSpecific(DetectedDiscType systemType)
if (GetPSXData(dataStr))
return DetectedDiscType.SonyPSP;
}
*/

// saturn
if (systemType == DetectedDiscType.SegaSaturn)
Expand Down Expand Up @@ -410,8 +412,9 @@ public DetectedDiscType InterrogateSpecific(DetectedDiscType systemType)
{
byte[] data = di.ReadData(i, 2048);
currSector = data;
CurrentLBA = i;
string dataStr = System.Text.Encoding.Default.GetString(data);

/*
// psx
if (systemType == DetectedDiscType.SonyPSX)
{
Expand All @@ -425,6 +428,7 @@ public DetectedDiscType InterrogateSpecific(DetectedDiscType systemType)
if (GetPSXData(dataStr))
return DetectedDiscType.SonyPSP;
}
*/

// saturn
if (systemType == DetectedDiscType.SegaSaturn)
Expand Down
4 changes: 3 additions & 1 deletion TestAppNET20/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,10 @@ static void Main(string[] args)


//string dcPath = @"G:\_Emulation\FM Towns\marty\Dungeon Master II for FM-Towns.cue";
string dcPath = @"G:\_Emulation\FM Towns\marty\Dungeon.Master.ISO.FM-Towns-OpTiMaL.cue";
//string dcPath = @"G:\_Emulation\FM Towns\marty\Dungeon.Master.ISO.FM-Towns-OpTiMaL.cue";

string dcPath = @"G:\_Emulation\PSX\iso\Thunder Storm & Road Blaster (Japan) (Disc 1) (Thunder Storm).cue";
//var psx = DiscInspector.ScanPSX(dcPath);
var dc = DiscInspector.ScanDisc(dcPath);

string stop = "";
Expand Down

0 comments on commit 73d2870

Please sign in to comment.