General refactor.

This commit is contained in:
2018-06-20 22:22:21 +01:00
parent dc1884f5d8
commit ec8b309670
93 changed files with 850 additions and 1015 deletions

View File

@@ -1283,12 +1283,10 @@ namespace DiscImageChef.Commands
case MediaType.XGD2:
case MediaType.XGD3:
// We need to get INQUIRY to know if it is a Kreon drive
Inquiry.SCSIInquiry? inq;
sense = dev.ScsiInquiry(out byte[] inqBuffer, out senseBuf);
if(!sense)
{
inq = Inquiry.Decode(inqBuffer);
Inquiry.SCSIInquiry? inq = Inquiry.Decode(inqBuffer);
if(inq.HasValue && inq.Value.KreonPresent)
{
sense = dev.KreonExtractSs(out cmdBuf, out senseBuf, dev.Timeout, out _);
@@ -1302,8 +1300,6 @@ namespace DiscImageChef.Commands
if(SS.Decode(cmdBuf).HasValue)
DicConsole.WriteLine("Xbox Security Sector:\n{0}", SS.Prettify(cmdBuf));
ulong l0Video, l1Video, middleZone, gameSize, totalSize, layerBreak;
// Get video partition size
DicConsole.DebugWriteLine("Dump-media command", "Getting video partition size");
sense = dev.KreonLock(out senseBuf, dev.Timeout, out _);
@@ -1320,7 +1316,7 @@ namespace DiscImageChef.Commands
return;
}
totalSize = (ulong)((cmdBuf[0] << 24) + (cmdBuf[1] << 16) + (cmdBuf[2] << 8) + cmdBuf[3]);
ulong totalSize = (ulong)((cmdBuf[0] << 24) + (cmdBuf[1] << 16) + (cmdBuf[2] << 8) + cmdBuf[3]);
sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.PhysicalInformation, 0, 0, out _);
if(sense)
@@ -1331,9 +1327,9 @@ namespace DiscImageChef.Commands
DicConsole.DebugWriteLine("Dump-media command", "Video partition total size: {0} sectors",
totalSize);
l0Video = PFI.Decode(cmdBuf).Value.Layer0EndPSN -
PFI.Decode(cmdBuf).Value.DataAreaStartPSN + 1;
l1Video = totalSize - l0Video + 1;
ulong l0Video = PFI.Decode(cmdBuf).Value.Layer0EndPSN -
PFI.Decode(cmdBuf).Value.DataAreaStartPSN + 1;
ulong l1Video = totalSize - l0Video + 1;
// Get game partition size
DicConsole.DebugWriteLine("Dump-media command", "Getting game partition size");
@@ -1351,8 +1347,8 @@ namespace DiscImageChef.Commands
return;
}
gameSize = (ulong)((cmdBuf[0] << 24) + (cmdBuf[1] << 16) + (cmdBuf[2] << 8) + cmdBuf[3]) +
1;
ulong gameSize = (ulong)((cmdBuf[0] << 24) + (cmdBuf[1] << 16) + (cmdBuf[2] << 8) + cmdBuf[3]) +
1;
DicConsole.DebugWriteLine("Dump-media command", "Game partition total size: {0} sectors",
gameSize);
@@ -1383,13 +1379,12 @@ namespace DiscImageChef.Commands
DicConsole.DebugWriteLine("Dump-media command", "Unlocked total size: {0} sectors",
totalSize);
middleZone =
totalSize -
(PFI.Decode(cmdBuf).Value.Layer0EndPSN -
PFI.Decode(cmdBuf).Value.DataAreaStartPSN + 1) - gameSize + 1;
ulong middleZone = totalSize -
(PFI.Decode(cmdBuf).Value.Layer0EndPSN -
PFI.Decode(cmdBuf).Value.DataAreaStartPSN + 1) - gameSize + 1;
totalSize = l0Video + l1Video + middleZone * 2 + gameSize;
layerBreak = l0Video + middleZone + gameSize / 2;
ulong layerBreak = l0Video + middleZone + gameSize / 2;
DicConsole.WriteLine("Video layer 0 size: {0} sectors", l0Video);
DicConsole.WriteLine("Video layer 1 size: {0} sectors", l1Video);