mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
[Aaru.Core] Reformat and cleanup.
This commit is contained in:
@@ -80,16 +80,10 @@ public static class MMC
|
||||
0x50, 0x6C, 0x61, 0x79, 0x53, 0x74, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x35, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
static readonly byte[] _operaId =
|
||||
{
|
||||
0x01, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x01
|
||||
};
|
||||
static readonly byte[] _operaId = { 0x01, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x01 };
|
||||
|
||||
// Only present on bootable CDs, but those make more than 99% of all available
|
||||
static readonly byte[] _fmTownsBootId =
|
||||
{
|
||||
0x49, 0x50, 0x4C, 0x34, 0xEB, 0x55, 0x06
|
||||
};
|
||||
static readonly byte[] _fmTownsBootId = { 0x49, 0x50, 0x4C, 0x34, 0xEB, 0x55, 0x06 };
|
||||
|
||||
/// <summary>Present on first two seconds of second track, says "COPYRIGHT BANDAI"</summary>
|
||||
static readonly byte[] _playdiaCopyright = "COPYRIGHT BANDAI"u8.ToArray();
|
||||
@@ -131,12 +125,9 @@ public static class MMC
|
||||
if(sector?.Length != 2352)
|
||||
return false;
|
||||
|
||||
byte[] syncMark =
|
||||
{
|
||||
0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00
|
||||
};
|
||||
byte[] syncMark = { 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00 };
|
||||
|
||||
byte[] testMark = new byte[12];
|
||||
var testMark = new byte[12];
|
||||
Array.Copy(sector, 0, testMark, 0, 12);
|
||||
|
||||
return syncMark.SequenceEqual(testMark) && (sector[0xF] == 0 || sector[0xF] == 1 || sector[0xF] == 2);
|
||||
@@ -149,19 +140,16 @@ public static class MMC
|
||||
if(sector?.Length != 2352)
|
||||
return false;
|
||||
|
||||
byte[] syncMark =
|
||||
{
|
||||
0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00
|
||||
};
|
||||
byte[] syncMark = { 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00 };
|
||||
|
||||
byte[] testMark = new byte[12];
|
||||
var testMark = new byte[12];
|
||||
|
||||
for(int i = 0; i <= 2336; i++)
|
||||
for(var i = 0; i <= 2336; i++)
|
||||
{
|
||||
Array.Copy(sector, i, testMark, 0, 12);
|
||||
|
||||
if(!syncMark.SequenceEqual(testMark) ||
|
||||
(sector[i + 0xF] != 0x60 && sector[i + 0xF] != 0x61 && sector[i + 0xF] != 0x62))
|
||||
sector[i + 0xF] != 0x60 && sector[i + 0xF] != 0x61 && sector[i + 0xF] != 0x62)
|
||||
continue;
|
||||
|
||||
// De-scramble M and S
|
||||
@@ -170,17 +158,17 @@ public static class MMC
|
||||
int frame = sector[i + 14];
|
||||
|
||||
// Convert to binary
|
||||
minute = (minute / 16 * 10) + (minute & 0x0F);
|
||||
second = (second / 16 * 10) + (second & 0x0F);
|
||||
frame = (frame / 16 * 10) + (frame & 0x0F);
|
||||
minute = minute / 16 * 10 + (minute & 0x0F);
|
||||
second = second / 16 * 10 + (second & 0x0F);
|
||||
frame = frame / 16 * 10 + (frame & 0x0F);
|
||||
|
||||
// Calculate the first found LBA
|
||||
int lba = (minute * 60 * 75) + (second * 75) + frame - 150;
|
||||
int lba = minute * 60 * 75 + second * 75 + frame - 150;
|
||||
|
||||
// Calculate the difference between the found LBA and the requested one
|
||||
int diff = wantedLba - lba;
|
||||
|
||||
offset = i + (2352 * diff);
|
||||
offset = i + 2352 * diff;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -190,9 +178,9 @@ public static class MMC
|
||||
|
||||
static byte[] DescrambleAndFixOffset(byte[] sector, int offsetBytes, int sectorsForOffset)
|
||||
{
|
||||
byte[] descrambled = new byte[2352];
|
||||
var descrambled = new byte[2352];
|
||||
|
||||
int offsetFix = offsetBytes < 0 ? (2352 * sectorsForOffset) + offsetBytes : offsetBytes;
|
||||
int offsetFix = offsetBytes < 0 ? 2352 * sectorsForOffset + offsetBytes : offsetBytes;
|
||||
|
||||
Array.Copy(sector, offsetFix, descrambled, 0, 2352);
|
||||
|
||||
@@ -208,18 +196,15 @@ public static class MMC
|
||||
if(sector16?.Length != 2352)
|
||||
return false;
|
||||
|
||||
byte[] cdiMark =
|
||||
{
|
||||
0x01, 0x43, 0x44, 0x2D
|
||||
};
|
||||
byte[] cdiMark = { 0x01, 0x43, 0x44, 0x2D };
|
||||
|
||||
bool isData = IsData(sector0);
|
||||
|
||||
if(!isData ||
|
||||
(sector0[0xF] != 2 && sector0[0xF] != 1))
|
||||
sector0[0xF] != 2 && sector0[0xF] != 1)
|
||||
return false;
|
||||
|
||||
byte[] testMark = new byte[4];
|
||||
var testMark = new byte[4];
|
||||
Array.Copy(sector16, 24, testMark, 0, 4);
|
||||
|
||||
return cdiMark.SequenceEqual(testMark);
|
||||
@@ -231,13 +216,13 @@ public static class MMC
|
||||
videoFrame.Length < _videoNowColorFrameMarker.Length)
|
||||
return false;
|
||||
|
||||
byte[] buffer = new byte[_videoNowColorFrameMarker.Length];
|
||||
var buffer = new byte[_videoNowColorFrameMarker.Length];
|
||||
|
||||
for(int framePosition = 0; framePosition + buffer.Length < videoFrame.Length; framePosition++)
|
||||
for(var framePosition = 0; framePosition + buffer.Length < videoFrame.Length; framePosition++)
|
||||
{
|
||||
Array.Copy(videoFrame, framePosition, buffer, 0, buffer.Length);
|
||||
|
||||
for(int ab = 9; ab < buffer.Length; ab += 10)
|
||||
for(var ab = 9; ab < buffer.Length; ab += 10)
|
||||
buffer[ab] = 0;
|
||||
|
||||
if(!_videoNowColorFrameMarker.SequenceEqual(buffer))
|
||||
@@ -251,13 +236,13 @@ public static class MMC
|
||||
|
||||
internal static int GetVideoNowColorOffset(byte[] data)
|
||||
{
|
||||
byte[] buffer = new byte[_videoNowColorFrameMarker.Length];
|
||||
var buffer = new byte[_videoNowColorFrameMarker.Length];
|
||||
|
||||
for(int framePosition = 0; framePosition + buffer.Length < data.Length; framePosition++)
|
||||
for(var framePosition = 0; framePosition + buffer.Length < data.Length; framePosition++)
|
||||
{
|
||||
Array.Copy(data, framePosition, buffer, 0, buffer.Length);
|
||||
|
||||
for(int ab = 9; ab < buffer.Length; ab += 10)
|
||||
for(var ab = 9; ab < buffer.Length; ab += 10)
|
||||
buffer[ab] = 0;
|
||||
|
||||
if(!_videoNowColorFrameMarker.SequenceEqual(buffer))
|
||||
@@ -270,8 +255,8 @@ public static class MMC
|
||||
}
|
||||
|
||||
internal static void DetectDiscType(ref MediaType mediaType, int sessions, FullTOC.CDFullTOC? decodedToc,
|
||||
Device dev, out bool hiddenTrack, out bool hiddenData,
|
||||
int firstTrackLastSession, ulong blocks)
|
||||
Device dev, out bool hiddenTrack, out bool hiddenData,
|
||||
int firstTrackLastSession, ulong blocks)
|
||||
{
|
||||
uint startOfFirstDataTrack = uint.MaxValue;
|
||||
DI.DiscInformation? blurayDi = null;
|
||||
@@ -420,8 +405,10 @@ public static class MMC
|
||||
}
|
||||
|
||||
if(decodedToc?.TrackDescriptors.Any(t => t.SessionNumber == 2) == true)
|
||||
{
|
||||
secondSessionFirstTrack = decodedToc.Value.TrackDescriptors.Where(t => t.SessionNumber == 2).
|
||||
Min(t => t.POINT);
|
||||
}
|
||||
|
||||
if(mediaType is MediaType.CD or MediaType.CDROMXA or MediaType.CDI)
|
||||
{
|
||||
@@ -440,10 +427,10 @@ public static class MMC
|
||||
|
||||
if(mediaType is MediaType.CD or MediaType.CDROMXA)
|
||||
{
|
||||
bool hasDataTrack = false;
|
||||
bool hasAudioTrack = false;
|
||||
bool allFirstSessionTracksAreAudio = true;
|
||||
bool hasVideoTrack = false;
|
||||
var hasDataTrack = false;
|
||||
var hasAudioTrack = false;
|
||||
var allFirstSessionTracksAreAudio = true;
|
||||
var hasVideoTrack = false;
|
||||
|
||||
if(decodedToc.HasValue)
|
||||
{
|
||||
@@ -451,6 +438,7 @@ public static class MMC
|
||||
decodedToc.Value.TrackDescriptors.FirstOrDefault(t => t is { POINT: 0xA0, ADR: 1 });
|
||||
|
||||
if(a0Track.POINT == 0xA0)
|
||||
{
|
||||
switch(a0Track.PSEC)
|
||||
{
|
||||
case 0x10:
|
||||
@@ -466,6 +454,7 @@ public static class MMC
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
foreach(FullTOC.TrackDataDescriptor track in
|
||||
decodedToc.Value.TrackDescriptors.Where(t => t.POINT is > 0 and <= 0x99))
|
||||
@@ -478,8 +467,8 @@ public static class MMC
|
||||
if((TocControl)(track.CONTROL & 0x0D) == TocControl.DataTrack ||
|
||||
(TocControl)(track.CONTROL & 0x0D) == TocControl.DataTrackIncremental)
|
||||
{
|
||||
uint startAddress = (uint)((track.PHOUR * 3600 * 75) + (track.PMIN * 60 * 75) +
|
||||
(track.PSEC * 75) + track.PFRAME - 150);
|
||||
var startAddress = (uint)(track.PHOUR * 3600 * 75 + track.PMIN * 60 * 75 +
|
||||
track.PSEC * 75 + track.PFRAME - 150);
|
||||
|
||||
if(startAddress < startOfFirstDataTrack)
|
||||
startOfFirstDataTrack = startAddress;
|
||||
@@ -536,15 +525,16 @@ public static class MMC
|
||||
}
|
||||
|
||||
if(mediaType is MediaType.CD or MediaType.CDROM && hasDataTrack)
|
||||
{
|
||||
foreach(uint startAddress in decodedToc.Value.TrackDescriptors.
|
||||
Where(t => t.POINT is > 0 and <= 0x99 &&
|
||||
((TocControl)(t.CONTROL & 0x0D) ==
|
||||
TocControl.DataTrack ||
|
||||
(TocControl)(t.CONTROL & 0x0D) ==
|
||||
TocControl.DataTrackIncremental)).
|
||||
Select(track => (uint)((track.PHOUR * 3600 * 75) +
|
||||
(track.PMIN * 60 * 75) +
|
||||
(track.PSEC * 75) + track.PFRAME - 150) +
|
||||
Select(track => (uint)(track.PHOUR * 3600 * 75 +
|
||||
track.PMIN * 60 * 75 +
|
||||
track.PSEC * 75 + track.PFRAME - 150) +
|
||||
16))
|
||||
{
|
||||
sense = dev.ReadCd(out cmdBuf, out _, startAddress, 2352, 1, MmcSectorTypes.AllTypes, false, false,
|
||||
@@ -576,6 +566,7 @@ public static class MMC
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(secondSessionFirstTrack != 0 &&
|
||||
@@ -584,10 +575,10 @@ public static class MMC
|
||||
FullTOC.TrackDataDescriptor secondSessionFirstTrackTrack =
|
||||
decodedToc.Value.TrackDescriptors.First(t => t.POINT == secondSessionFirstTrack);
|
||||
|
||||
uint firstSectorSecondSessionFirstTrack = (uint)((secondSessionFirstTrackTrack.PHOUR * 3600 * 75) +
|
||||
(secondSessionFirstTrackTrack.PMIN * 60 * 75) +
|
||||
(secondSessionFirstTrackTrack.PSEC * 75) +
|
||||
secondSessionFirstTrackTrack.PFRAME - 150);
|
||||
var firstSectorSecondSessionFirstTrack = (uint)(secondSessionFirstTrackTrack.PHOUR * 3600 * 75 +
|
||||
secondSessionFirstTrackTrack.PMIN * 60 * 75 +
|
||||
secondSessionFirstTrackTrack.PSEC * 75 +
|
||||
secondSessionFirstTrackTrack.PFRAME - 150);
|
||||
|
||||
sense = dev.ReadCd(out cmdBuf, out _, firstSectorSecondSessionFirstTrack, 2352, 1, MmcSectorTypes.AllTypes,
|
||||
false, false, true, MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None,
|
||||
@@ -628,7 +619,7 @@ public static class MMC
|
||||
|
||||
videoNowColorFrame = new byte[9 * 2352];
|
||||
|
||||
for(int i = 0; i < 9; i++)
|
||||
for(var i = 0; i < 9; i++)
|
||||
{
|
||||
sense = dev.ReadCd(out cmdBuf, out _, (uint)i, 2352, 1, MmcSectorTypes.AllTypes, false, false, true,
|
||||
MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, MmcSubchannel.None,
|
||||
@@ -657,8 +648,8 @@ public static class MMC
|
||||
|
||||
if(firstTrack?.POINT is >= 1 and < 0xA0)
|
||||
{
|
||||
uint firstTrackSector = (uint)((firstTrack.Value.PHOUR * 3600 * 75) + (firstTrack.Value.PMIN * 60 * 75) +
|
||||
(firstTrack.Value.PSEC * 75) + firstTrack.Value.PFRAME - 150);
|
||||
var firstTrackSector = (uint)(firstTrack.Value.PHOUR * 3600 * 75 + firstTrack.Value.PMIN * 60 * 75 +
|
||||
firstTrack.Value.PSEC * 75 + firstTrack.Value.PFRAME - 150);
|
||||
|
||||
// Check for hidden data before start of track 1
|
||||
if(firstTrackSector > 0)
|
||||
@@ -705,8 +696,8 @@ public static class MMC
|
||||
if(combinedOffset % 2352 != 0)
|
||||
sectorsForOffset++;
|
||||
|
||||
int lba0 = 0;
|
||||
int lba16 = 16;
|
||||
var lba0 = 0;
|
||||
var lba16 = 16;
|
||||
|
||||
if(combinedOffset < 0)
|
||||
{
|
||||
@@ -988,7 +979,8 @@ public static class MMC
|
||||
}
|
||||
|
||||
// TODO: Check for CD-i Ready
|
||||
case MediaType.CDI: break;
|
||||
case MediaType.CDI:
|
||||
break;
|
||||
case MediaType.DVDROM:
|
||||
case MediaType.HDDVDROM:
|
||||
case MediaType.BDROM:
|
||||
@@ -1111,24 +1103,31 @@ public static class MMC
|
||||
PFI.PhysicalFormatInformation? pfi = PFI.Decode(cmdBuf, mediaType);
|
||||
|
||||
if(pfi != null)
|
||||
{
|
||||
mediaType = pfi.Value.DiskCategory switch
|
||||
{
|
||||
DiskCategory.DVDPR => MediaType.DVDPR,
|
||||
DiskCategory.DVDPRDL => MediaType.DVDPRDL,
|
||||
DiskCategory.DVDPRW => MediaType.DVDPRW,
|
||||
DiskCategory.DVDPRWDL => MediaType.DVDPRWDL,
|
||||
DiskCategory.DVDR => pfi.Value.PartVersion >= 6 ? MediaType.DVDRDL : MediaType.DVDR,
|
||||
DiskCategory.DVDRAM => MediaType.DVDRAM,
|
||||
DiskCategory.DVDRW => pfi.Value.PartVersion >= 15 ? MediaType.DVDRWDL : MediaType.DVDRW,
|
||||
DiskCategory.HDDVDR => MediaType.HDDVDR,
|
||||
DiskCategory.HDDVDRAM => MediaType.HDDVDRAM,
|
||||
DiskCategory.HDDVDROM => MediaType.HDDVDROM,
|
||||
DiskCategory.HDDVDRW => MediaType.HDDVDRW,
|
||||
DiskCategory.Nintendo => pfi.Value.DiscSize == DVDSize.Eighty ? MediaType.GOD
|
||||
: MediaType.WOD,
|
||||
DiskCategory.UMD => MediaType.UMD,
|
||||
_ => mediaType
|
||||
};
|
||||
{
|
||||
DiskCategory.DVDPR => MediaType.DVDPR,
|
||||
DiskCategory.DVDPRDL => MediaType.DVDPRDL,
|
||||
DiskCategory.DVDPRW => MediaType.DVDPRW,
|
||||
DiskCategory.DVDPRWDL => MediaType.DVDPRWDL,
|
||||
DiskCategory.DVDR => pfi.Value.PartVersion >= 6
|
||||
? MediaType.DVDRDL
|
||||
: MediaType.DVDR,
|
||||
DiskCategory.DVDRAM => MediaType.DVDRAM,
|
||||
DiskCategory.DVDRW => pfi.Value.PartVersion >= 15
|
||||
? MediaType.DVDRWDL
|
||||
: MediaType.DVDRW,
|
||||
DiskCategory.HDDVDR => MediaType.HDDVDR,
|
||||
DiskCategory.HDDVDRAM => MediaType.HDDVDRAM,
|
||||
DiskCategory.HDDVDROM => MediaType.HDDVDROM,
|
||||
DiskCategory.HDDVDRW => MediaType.HDDVDRW,
|
||||
DiskCategory.Nintendo => pfi.Value.DiscSize == DVDSize.Eighty
|
||||
? MediaType.GOD
|
||||
: MediaType.WOD,
|
||||
DiskCategory.UMD => MediaType.UMD,
|
||||
_ => mediaType
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
sense = dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Dvd, 0, 0,
|
||||
@@ -1224,8 +1223,8 @@ public static class MMC
|
||||
isoSector[5] != 0x31)
|
||||
return;
|
||||
|
||||
uint rootStart = BitConverter.ToUInt32(isoSector, 158);
|
||||
uint rootLength = BitConverter.ToUInt32(isoSector, 166);
|
||||
var rootStart = BitConverter.ToUInt32(isoSector, 158);
|
||||
var rootLength = BitConverter.ToUInt32(isoSector, 166);
|
||||
|
||||
if(rootStart == 0 ||
|
||||
rootLength == 0)
|
||||
@@ -1258,7 +1257,7 @@ public static class MMC
|
||||
if(isoSector.Length < 2048)
|
||||
return;
|
||||
|
||||
int rootPos = 0;
|
||||
var rootPos = 0;
|
||||
uint pcdStart = 0;
|
||||
uint pcdLength = 0;
|
||||
|
||||
@@ -1266,8 +1265,8 @@ public static class MMC
|
||||
rootPos < isoSector.Length &&
|
||||
rootPos + isoSector[rootPos] <= isoSector.Length)
|
||||
{
|
||||
int nameLen = isoSector[rootPos + 32];
|
||||
byte[] tmpName = new byte[nameLen];
|
||||
int nameLen = isoSector[rootPos + 32];
|
||||
var tmpName = new byte[nameLen];
|
||||
Array.Copy(isoSector, rootPos + 33, tmpName, 0, nameLen);
|
||||
string name = StringHandlers.CToString(tmpName).ToUpperInvariant();
|
||||
|
||||
@@ -1311,7 +1310,7 @@ public static class MMC
|
||||
if(isoSector.Length < 2048)
|
||||
return;
|
||||
|
||||
for(int pi = 0; pi < pcdLength; pi++)
|
||||
for(var pi = 0; pi < pcdLength; pi++)
|
||||
{
|
||||
int pcdPos = pi * 2048;
|
||||
uint infoPos = 0;
|
||||
@@ -1320,8 +1319,8 @@ public static class MMC
|
||||
pcdPos < isoSector.Length &&
|
||||
pcdPos + isoSector[pcdPos] <= isoSector.Length)
|
||||
{
|
||||
int nameLen = isoSector[pcdPos + 32];
|
||||
byte[] tmpName = new byte[nameLen];
|
||||
int nameLen = isoSector[pcdPos + 32];
|
||||
var tmpName = new byte[nameLen];
|
||||
Array.Copy(isoSector, pcdPos + 33, tmpName, 0, nameLen);
|
||||
string name = StringHandlers.CToString(tmpName).ToUpperInvariant();
|
||||
|
||||
@@ -1346,7 +1345,7 @@ public static class MMC
|
||||
if(sense)
|
||||
break;
|
||||
|
||||
byte[] systemId = new byte[8];
|
||||
var systemId = new byte[8];
|
||||
Array.Copy(isoSector, 0, systemId, 0, 8);
|
||||
|
||||
string id = StringHandlers.CToString(systemId).TrimEnd();
|
||||
@@ -1390,7 +1389,8 @@ public static class MMC
|
||||
case MediaType.BDR:
|
||||
case MediaType.BDRE:
|
||||
case MediaType.BDRXL:
|
||||
case MediaType.BDREXL: return;
|
||||
case MediaType.BDREXL:
|
||||
return;
|
||||
}
|
||||
|
||||
if(sector0 == null)
|
||||
@@ -1438,7 +1438,7 @@ public static class MMC
|
||||
// The decryption key is applied as XOR. As first byte is originally always NULL, it gives us the key :)
|
||||
byte decryptByte = ps2BootSectors[0];
|
||||
|
||||
for(int i = 0; i < 0x6000; i++)
|
||||
for(var i = 0; i < 0x6000; i++)
|
||||
ps2BootSectors[i] ^= decryptByte;
|
||||
|
||||
string ps2BootSectorsHash = Sha256Context.Data(ps2BootSectors, out _);
|
||||
@@ -1460,7 +1460,7 @@ public static class MMC
|
||||
|
||||
if(sector0 != null)
|
||||
{
|
||||
byte[] syncBytes = new byte[7];
|
||||
var syncBytes = new byte[7];
|
||||
Array.Copy(sector0, 0, syncBytes, 0, 7);
|
||||
|
||||
if(_operaId.SequenceEqual(syncBytes))
|
||||
@@ -1485,11 +1485,11 @@ public static class MMC
|
||||
if(playdia1 != null &&
|
||||
playdia2 != null)
|
||||
{
|
||||
byte[] pd1 = new byte[_playdiaCopyright.Length];
|
||||
byte[] pd2 = new byte[_playdiaCopyright.Length];
|
||||
var pd1 = new byte[_playdiaCopyright.Length];
|
||||
var pd2 = new byte[_playdiaCopyright.Length];
|
||||
|
||||
Array.Copy(playdia1, 38, pd1, 0, pd1.Length);
|
||||
Array.Copy(playdia2, 0, pd2, 0, pd1.Length);
|
||||
Array.Copy(playdia2, 0, pd2, 0, pd1.Length);
|
||||
|
||||
if(_playdiaCopyright.SequenceEqual(pd1) &&
|
||||
_playdiaCopyright.SequenceEqual(pd2))
|
||||
@@ -1504,7 +1504,7 @@ public static class MMC
|
||||
|
||||
if(secondDataSectorNotZero != null)
|
||||
{
|
||||
byte[] pce = new byte[_pcEngineSignature.Length];
|
||||
var pce = new byte[_pcEngineSignature.Length];
|
||||
Array.Copy(secondDataSectorNotZero, 32, pce, 0, pce.Length);
|
||||
|
||||
if(_pcEngineSignature.SequenceEqual(pce))
|
||||
@@ -1519,7 +1519,7 @@ public static class MMC
|
||||
|
||||
if(firstDataSectorNotZero != null)
|
||||
{
|
||||
byte[] pcfx = new byte[_pcFxSignature.Length];
|
||||
var pcfx = new byte[_pcFxSignature.Length];
|
||||
Array.Copy(firstDataSectorNotZero, 0, pcfx, 0, pcfx.Length);
|
||||
|
||||
if(_pcFxSignature.SequenceEqual(pcfx))
|
||||
@@ -1534,9 +1534,9 @@ public static class MMC
|
||||
|
||||
if(firstTrackSecondSessionAudio != null)
|
||||
{
|
||||
byte[] jaguar = new byte[_atariSignature.Length];
|
||||
var jaguar = new byte[_atariSignature.Length];
|
||||
|
||||
for(int i = 0; i + jaguar.Length <= firstTrackSecondSessionAudio.Length; i += 2)
|
||||
for(var i = 0; i + jaguar.Length <= firstTrackSecondSessionAudio.Length; i += 2)
|
||||
{
|
||||
Array.Copy(firstTrackSecondSessionAudio, i, jaguar, 0, jaguar.Length);
|
||||
|
||||
@@ -1553,7 +1553,7 @@ public static class MMC
|
||||
|
||||
if(firstTrackSecondSession?.Length >= 2336)
|
||||
{
|
||||
byte[] milcd = new byte[2048];
|
||||
var milcd = new byte[2048];
|
||||
Array.Copy(firstTrackSecondSession, 24, milcd, 0, 2048);
|
||||
|
||||
if(Dreamcast.DecodeIPBin(milcd).HasValue)
|
||||
@@ -1587,13 +1587,13 @@ public static class MMC
|
||||
|
||||
if(!sense)
|
||||
{
|
||||
bool cdg = false;
|
||||
bool cdeg = false;
|
||||
bool cdmidi = false;
|
||||
var cdg = false;
|
||||
var cdeg = false;
|
||||
var cdmidi = false;
|
||||
|
||||
for(int i = 0; i < 8; i++)
|
||||
for(var i = 0; i < 8; i++)
|
||||
{
|
||||
byte[] tmpSub = new byte[96];
|
||||
var tmpSub = new byte[96];
|
||||
Array.Copy(subBuf, i * 96, tmpSub, 0, 96);
|
||||
DetectRwPackets(tmpSub, out bool cdgPacket, out bool cdegPacket, out bool cdmidiPacket);
|
||||
|
||||
@@ -1638,7 +1638,7 @@ public static class MMC
|
||||
}
|
||||
|
||||
// If it has a PS2 boot area it can still be PS1, so check for SYSTEM.CNF below
|
||||
hasPs2CdBoot:
|
||||
hasPs2CdBoot:
|
||||
|
||||
// Check if ISO9660
|
||||
sense = dev.Read12(out byte[] isoSector, out _, 0, false, false, false, false, 16, 2048, 0, 1, false,
|
||||
@@ -1690,8 +1690,8 @@ public static class MMC
|
||||
isoSector[5] != 0x31)
|
||||
return;
|
||||
|
||||
uint rootStart = BitConverter.ToUInt32(isoSector, 158);
|
||||
uint rootLength = BitConverter.ToUInt32(isoSector, 166);
|
||||
var rootStart = BitConverter.ToUInt32(isoSector, 158);
|
||||
var rootLength = BitConverter.ToUInt32(isoSector, 166);
|
||||
|
||||
if(rootStart == 0 ||
|
||||
rootLength == 0)
|
||||
@@ -1734,7 +1734,7 @@ public static class MMC
|
||||
uint ps1Start = 0;
|
||||
uint ps1Length = 0;
|
||||
|
||||
for(int ri = 0; ri < rootLength; ri++)
|
||||
for(var ri = 0; ri < rootLength; ri++)
|
||||
{
|
||||
int rootPos = ri * 2048;
|
||||
|
||||
@@ -1742,8 +1742,8 @@ public static class MMC
|
||||
isoSector[rootPos] > 0 &&
|
||||
rootPos + isoSector[rootPos] <= isoSector.Length)
|
||||
{
|
||||
int nameLen = isoSector[rootPos + 32];
|
||||
byte[] tmpName = new byte[nameLen];
|
||||
int nameLen = isoSector[rootPos + 32];
|
||||
var tmpName = new byte[nameLen];
|
||||
Array.Copy(isoSector, rootPos + 33, tmpName, 0, nameLen);
|
||||
string name = StringHandlers.CToString(tmpName).ToUpperInvariant();
|
||||
|
||||
@@ -1843,8 +1843,8 @@ public static class MMC
|
||||
{
|
||||
using var sr = new StringReader(iplTxt);
|
||||
|
||||
bool correctNeoGeoCd = true;
|
||||
int lineNumber = 0;
|
||||
var correctNeoGeoCd = true;
|
||||
var lineNumber = 0;
|
||||
|
||||
while(sr.Peek() > 0)
|
||||
{
|
||||
@@ -1977,7 +1977,7 @@ public static class MMC
|
||||
|
||||
uint infoPos = 0;
|
||||
|
||||
for(int vi = 0; vi < vcdLength; vi++)
|
||||
for(var vi = 0; vi < vcdLength; vi++)
|
||||
{
|
||||
int vcdPos = vi * 2048;
|
||||
|
||||
@@ -1985,8 +1985,8 @@ public static class MMC
|
||||
isoSector[vcdPos] > 0 &&
|
||||
vcdPos + isoSector[vcdPos] <= isoSector.Length)
|
||||
{
|
||||
int nameLen = isoSector[vcdPos + 32];
|
||||
byte[] tmpName = new byte[nameLen];
|
||||
int nameLen = isoSector[vcdPos + 32];
|
||||
var tmpName = new byte[nameLen];
|
||||
Array.Copy(isoSector, vcdPos + 33, tmpName, 0, nameLen);
|
||||
string name = StringHandlers.CToString(tmpName).ToUpperInvariant();
|
||||
|
||||
@@ -2012,7 +2012,7 @@ public static class MMC
|
||||
if(sense)
|
||||
break;
|
||||
|
||||
byte[] systemId = new byte[8];
|
||||
var systemId = new byte[8];
|
||||
Array.Copy(isoSector, 0, systemId, 0, 8);
|
||||
|
||||
string id = StringHandlers.CToString(systemId).TrimEnd();
|
||||
@@ -2073,7 +2073,7 @@ public static class MMC
|
||||
|
||||
uint infoPos = 0;
|
||||
|
||||
for(int pi = 0; pi < pcdLength; pi++)
|
||||
for(var pi = 0; pi < pcdLength; pi++)
|
||||
{
|
||||
int pcdPos = pi * 2048;
|
||||
|
||||
@@ -2081,8 +2081,8 @@ public static class MMC
|
||||
isoSector[pcdPos] > 0 &&
|
||||
pcdPos + isoSector[pcdPos] <= isoSector.Length)
|
||||
{
|
||||
int nameLen = isoSector[pcdPos + 32];
|
||||
byte[] tmpName = new byte[nameLen];
|
||||
int nameLen = isoSector[pcdPos + 32];
|
||||
var tmpName = new byte[nameLen];
|
||||
Array.Copy(isoSector, pcdPos + 33, tmpName, 0, nameLen);
|
||||
string name = StringHandlers.CToString(tmpName).ToUpperInvariant();
|
||||
|
||||
@@ -2108,7 +2108,7 @@ public static class MMC
|
||||
if(sense)
|
||||
break;
|
||||
|
||||
byte[] systemId = new byte[8];
|
||||
var systemId = new byte[8];
|
||||
Array.Copy(isoSector, 0, systemId, 0, 8);
|
||||
|
||||
string id = StringHandlers.CToString(systemId).TrimEnd();
|
||||
@@ -2230,7 +2230,8 @@ public static class MMC
|
||||
}
|
||||
|
||||
// TODO: Check for CD-i Ready
|
||||
case MediaType.CDI: break;
|
||||
case MediaType.CDI:
|
||||
break;
|
||||
case MediaType.DVDROM:
|
||||
case MediaType.HDDVDROM:
|
||||
case MediaType.BDROM:
|
||||
@@ -2242,7 +2243,7 @@ public static class MMC
|
||||
// The decryption key is applied as XOR. As first byte is originally always NULL, it gives us the key :)
|
||||
byte decryptByte = ps2BootSectors[0];
|
||||
|
||||
for(int i = 0; i < 0x6000; i++)
|
||||
for(var i = 0; i < 0x6000; i++)
|
||||
ps2BootSectors[i] ^= decryptByte;
|
||||
|
||||
string ps2BootSectorsHash = Sha256Context.Data(ps2BootSectors, out _);
|
||||
@@ -2262,10 +2263,11 @@ public static class MMC
|
||||
|
||||
if(sector1 != null)
|
||||
{
|
||||
byte[] tmp = new byte[_ps3Id.Length];
|
||||
var tmp = new byte[_ps3Id.Length];
|
||||
Array.Copy(sector1, 0, tmp, 0, tmp.Length);
|
||||
|
||||
if(tmp.SequenceEqual(_ps3Id))
|
||||
{
|
||||
switch(mediaType)
|
||||
{
|
||||
case MediaType.BDROM:
|
||||
@@ -2283,6 +2285,7 @@ public static class MMC
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
tmp = new byte[_ps4Id.Length];
|
||||
Array.Copy(sector1, 512, tmp, 0, tmp.Length);
|
||||
@@ -2316,7 +2319,7 @@ public static class MMC
|
||||
case "BDU":
|
||||
if(sector1 != null)
|
||||
{
|
||||
byte[] tmp = new byte[_ps5Id.Length];
|
||||
var tmp = new byte[_ps5Id.Length];
|
||||
Array.Copy(sector1, 1024, tmp, 0, tmp.Length);
|
||||
|
||||
if(tmp.SequenceEqual(_ps5Id))
|
||||
@@ -2349,23 +2352,23 @@ public static class MMC
|
||||
cdegPacket = false;
|
||||
cdmidiPacket = false;
|
||||
|
||||
byte[] cdSubRwPack1 = new byte[24];
|
||||
byte[] cdSubRwPack2 = new byte[24];
|
||||
byte[] cdSubRwPack3 = new byte[24];
|
||||
byte[] cdSubRwPack4 = new byte[24];
|
||||
var cdSubRwPack1 = new byte[24];
|
||||
var cdSubRwPack2 = new byte[24];
|
||||
var cdSubRwPack3 = new byte[24];
|
||||
var cdSubRwPack4 = new byte[24];
|
||||
|
||||
int i = 0;
|
||||
var i = 0;
|
||||
|
||||
for(int j = 0; j < 24; j++)
|
||||
for(var j = 0; j < 24; j++)
|
||||
cdSubRwPack1[j] = (byte)(subchannel[i++] & 0x3F);
|
||||
|
||||
for(int j = 0; j < 24; j++)
|
||||
for(var j = 0; j < 24; j++)
|
||||
cdSubRwPack2[j] = (byte)(subchannel[i++] & 0x3F);
|
||||
|
||||
for(int j = 0; j < 24; j++)
|
||||
for(var j = 0; j < 24; j++)
|
||||
cdSubRwPack3[j] = (byte)(subchannel[i++] & 0x3F);
|
||||
|
||||
for(int j = 0; j < 24; j++)
|
||||
for(var j = 0; j < 24; j++)
|
||||
cdSubRwPack4[j] = (byte)(subchannel[i++] & 0x3F);
|
||||
|
||||
switch(cdSubRwPack1[0])
|
||||
|
||||
Reference in New Issue
Block a user