[Refactor] Fix indentation issues.

This commit is contained in:
2025-11-24 19:38:40 +00:00
parent 5774885431
commit 8331fba1e4
43 changed files with 1700 additions and 1751 deletions

View File

@@ -51,15 +51,11 @@ public sealed partial class Symbian
if(currentFile > maxFiles) return; if(currentFile > maxFiles) return;
char[] tabulationChars = new char[conditionLevel]; var tabulationChars = new char[conditionLevel];
for(int i = 0; i < conditionLevel; i++) tabulationChars[i] = '\t'; for(var i = 0; i < conditionLevel; i++) tabulationChars[i] = '\t';
string tabulation = new(tabulationChars); string tabulation = new(tabulationChars);
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME, "Seeking to {0} for parsing of file {1} of {2}", offset, currentFile, maxFiles);
"Seeking to {0} for parsing of file {1} of {2}",
offset,
currentFile,
maxFiles);
br.BaseStream.Seek(offset, SeekOrigin.Begin); br.BaseStream.Seek(offset, SeekOrigin.Begin);
var recordType = (FileRecordType)br.ReadUInt32(); var recordType = (FileRecordType)br.ReadUInt32();
@@ -323,7 +319,7 @@ public sealed partial class Symbian
var decodedFileRecords = new DecodedFileRecord[languages.Count]; var decodedFileRecords = new DecodedFileRecord[languages.Count];
for(int i = 0; i < languages.Count; i++) for(var i = 0; i < languages.Count; i++)
{ {
decodedFileRecords[i].type = multipleFileRecord.record.type; decodedFileRecords[i].type = multipleFileRecord.record.type;
decodedFileRecords[i].details = multipleFileRecord.record.details; decodedFileRecords[i].details = multipleFileRecord.record.details;
@@ -488,7 +484,7 @@ public sealed partial class Symbian
optionsLineRecord.options = new OptionRecord[(int)optionsLineRecord.numberOfOptions]; optionsLineRecord.options = new OptionRecord[(int)optionsLineRecord.numberOfOptions];
for(int i = 0; i < optionsLineRecord.numberOfOptions; i++) for(var i = 0; i < optionsLineRecord.numberOfOptions; i++)
{ {
optionsLineRecord.options[i] = new OptionRecord(); optionsLineRecord.options[i] = new OptionRecord();
@@ -508,7 +504,7 @@ public sealed partial class Symbian
offset = (uint)br.BaseStream.Position; offset = (uint)br.BaseStream.Position;
for(int j = 0; j < languages.Count; j++) for(var j = 0; j < languages.Count; j++)
{ {
br.BaseStream.Seek(optionsLineRecord.options[i].pointers[j], SeekOrigin.Begin); br.BaseStream.Seek(optionsLineRecord.options[i].pointers[j], SeekOrigin.Begin);
buffer = br.ReadBytes((int)optionsLineRecord.options[i].lengths[j]); buffer = br.ReadBytes((int)optionsLineRecord.options[i].lengths[j]);
@@ -527,7 +523,7 @@ public sealed partial class Symbian
conditionLevel--; conditionLevel--;
tabulationChars = new char[conditionLevel]; tabulationChars = new char[conditionLevel];
for(int i = 0; i < conditionLevel; i++) tabulationChars[i] = '\t'; for(var i = 0; i < conditionLevel; i++) tabulationChars[i] = '\t';
tabulation = new string(tabulationChars); tabulation = new string(tabulationChars);
conditionalRecord = new ConditionalRecord conditionalRecord = new ConditionalRecord
@@ -552,7 +548,7 @@ public sealed partial class Symbian
break; break;
case FileRecordType.ElseIf: case FileRecordType.ElseIf:
tabulationChars = new char[conditionLevel - 1]; tabulationChars = new char[conditionLevel - 1];
for(int i = 0; i < conditionLevel - 1; i++) tabulationChars[i] = '\t'; for(var i = 0; i < conditionLevel - 1; i++) tabulationChars[i] = '\t';
tabulation = new string(tabulationChars); tabulation = new string(tabulationChars);
conditionalRecord = new ConditionalRecord conditionalRecord = new ConditionalRecord
@@ -577,7 +573,7 @@ public sealed partial class Symbian
break; break;
case FileRecordType.Else: case FileRecordType.Else:
tabulationChars = new char[conditionLevel - 1]; tabulationChars = new char[conditionLevel - 1];
for(int i = 0; i < conditionLevel - 1; i++) tabulationChars[i] = '\t'; for(var i = 0; i < conditionLevel - 1; i++) tabulationChars[i] = '\t';
tabulation = new string(tabulationChars); tabulation = new string(tabulationChars);
offset = (uint)(br.BaseStream.Position + Marshal.SizeOf<ConditionalEndRecord>()); offset = (uint)(br.BaseStream.Position + Marshal.SizeOf<ConditionalEndRecord>());

View File

@@ -82,8 +82,8 @@ public static class CdChecksums
{ {
case 2448: case 2448:
{ {
byte[] subchannel = new byte[96]; var subchannel = new byte[96];
byte[] channel = new byte[2352]; var channel = new byte[2352];
Array.Copy(buffer, 0, channel, 0, 2352); Array.Copy(buffer, 0, channel, 0, 2352);
Array.Copy(buffer, 2352, subchannel, 0, 96); Array.Copy(buffer, 2352, subchannel, 0, 96);
@@ -121,7 +121,7 @@ public static class CdChecksums
for(uint i = 0; i < 256; i++) for(uint i = 0; i < 256; i++)
{ {
uint edc = i; uint edc = i;
uint j = (uint)(i << 1 ^ ((i & 0x80) == 0x80 ? 0x11D : 0)); var j = (uint)(i << 1 ^ ((i & 0x80) == 0x80 ? 0x11D : 0));
_eccFTable[i] = (byte)j; _eccFTable[i] = (byte)j;
_eccBTable[i ^ j] = (byte)i; _eccBTable[i ^ j] = (byte)i;
@@ -197,7 +197,7 @@ public static class CdChecksums
{ {
//AaruLogging.DebugWriteLine(MODULE_NAME, "Mode 0 sector at address {0:X2}:{1:X2}:{2:X2}", //AaruLogging.DebugWriteLine(MODULE_NAME, "Mode 0 sector at address {0:X2}:{1:X2}:{2:X2}",
// channel[0x00C], channel[0x00D], channel[0x00E]); // channel[0x00C], channel[0x00D], channel[0x00E]);
for(int i = 0x010; i < 0x930; i++) for(var i = 0x010; i < 0x930; i++)
{ {
if(channel[i] == 0x00) continue; if(channel[i] == 0x00) continue;
@@ -233,11 +233,11 @@ public static class CdChecksums
return false; return false;
case 0x01: case 0x01:
{ {
byte[] address = new byte[4]; var address = new byte[4];
byte[] data = new byte[2060]; var data = new byte[2060];
byte[] data2 = new byte[2232]; var data2 = new byte[2232];
byte[] eccP = new byte[172]; var eccP = new byte[172];
byte[] eccQ = new byte[104]; var eccQ = new byte[104];
Array.Copy(channel, 0x0C, address, 0, 4); Array.Copy(channel, 0x0C, address, 0, 4);
Array.Copy(channel, 0x10, data, 0, 2060); Array.Copy(channel, 0x10, data, 0, 2060);
@@ -269,7 +269,7 @@ public static class CdChecksums
channel[0x00E]); channel[0x00E]);
} }
uint storedEdc = BitConverter.ToUInt32(channel, 0x810); var storedEdc = BitConverter.ToUInt32(channel, 0x810);
uint calculatedEdc = ComputeEdc(0, channel, 0x810); uint calculatedEdc = ComputeEdc(0, channel, 0x810);
correctEdc = calculatedEdc == storedEdc; correctEdc = calculatedEdc == storedEdc;
@@ -292,7 +292,7 @@ public static class CdChecksums
{ {
//AaruLogging.DebugWriteLine(MODULE_NAME, "Mode 2 sector at address {0:X2}:{1:X2}:{2:X2}", //AaruLogging.DebugWriteLine(MODULE_NAME, "Mode 2 sector at address {0:X2}:{1:X2}:{2:X2}",
// channel[0x00C], channel[0x00D], channel[0x00E]); // channel[0x00C], channel[0x00D], channel[0x00E]);
byte[] mode2Sector = new byte[channel.Length - 0x10]; var mode2Sector = new byte[channel.Length - 0x10];
Array.Copy(channel, 0x10, mode2Sector, 0, mode2Sector.Length); Array.Copy(channel, 0x10, mode2Sector, 0, mode2Sector.Length);
if((channel[0x012] & 0x20) == 0x20) // mode 2 form 2 if((channel[0x012] & 0x20) == 0x20) // mode 2 form 2
@@ -309,7 +309,7 @@ public static class CdChecksums
channel[0x00E]); channel[0x00E]);
} }
uint storedEdc = BitConverter.ToUInt32(mode2Sector, 0x91C); var storedEdc = BitConverter.ToUInt32(mode2Sector, 0x91C);
// No CRC stored! // No CRC stored!
if(storedEdc == 0x00000000) return true; if(storedEdc == 0x00000000) return true;
@@ -344,9 +344,9 @@ public static class CdChecksums
channel[0x00E]); channel[0x00E]);
} }
byte[] address = new byte[4]; var address = new byte[4];
byte[] eccP = new byte[172]; var eccP = new byte[172];
byte[] eccQ = new byte[104]; var eccQ = new byte[104];
Array.Copy(mode2Sector, 0x80C, eccP, 0, 172); Array.Copy(mode2Sector, 0x80C, eccP, 0, 172);
Array.Copy(mode2Sector, 0x8B8, eccQ, 0, 104); Array.Copy(mode2Sector, 0x8B8, eccQ, 0, 104);
@@ -375,7 +375,7 @@ public static class CdChecksums
channel[0x00E]); channel[0x00E]);
} }
uint storedEdc = BitConverter.ToUInt32(mode2Sector, 0x808); var storedEdc = BitConverter.ToUInt32(mode2Sector, 0x808);
uint calculatedEdc = ComputeEdc(0, mode2Sector, 0x808); uint calculatedEdc = ComputeEdc(0, mode2Sector, 0x808);
correctEdc = calculatedEdc == storedEdc; correctEdc = calculatedEdc == storedEdc;
@@ -407,7 +407,7 @@ public static class CdChecksums
static uint ComputeEdc(uint edc, IReadOnlyList<byte> src, int size) static uint ComputeEdc(uint edc, IReadOnlyList<byte> src, int size)
{ {
int pos = 0; var pos = 0;
for(; size > 0; size--) edc = edc >> 8 ^ _edcTable[(edc ^ src[pos++]) & 0xFF]; for(; size > 0; size--) edc = edc >> 8 ^ _edcTable[(edc ^ src[pos++]) & 0xFF];
@@ -417,21 +417,21 @@ public static class CdChecksums
static bool? CheckCdSectorSubChannel(IReadOnlyList<byte> subchannel) static bool? CheckCdSectorSubChannel(IReadOnlyList<byte> subchannel)
{ {
bool? status = true; bool? status = true;
byte[] qSubChannel = new byte[12]; var qSubChannel = new byte[12];
byte[] cdTextPack1 = new byte[18]; var cdTextPack1 = new byte[18];
byte[] cdTextPack2 = new byte[18]; var cdTextPack2 = new byte[18];
byte[] cdTextPack3 = new byte[18]; var cdTextPack3 = new byte[18];
byte[] cdTextPack4 = new byte[18]; var cdTextPack4 = new byte[18];
byte[] cdSubRwPack1 = new byte[24]; var cdSubRwPack1 = new byte[24];
byte[] cdSubRwPack2 = new byte[24]; var cdSubRwPack2 = new byte[24];
byte[] cdSubRwPack3 = new byte[24]; var cdSubRwPack3 = new byte[24];
byte[] cdSubRwPack4 = new byte[24]; var cdSubRwPack4 = new byte[24];
int i = 0; var i = 0;
for(int j = 0; j < 12; j++) qSubChannel[j] = 0; for(var j = 0; j < 12; j++) qSubChannel[j] = 0;
for(int j = 0; j < 18; j++) for(var j = 0; j < 18; j++)
{ {
cdTextPack1[j] = 0; cdTextPack1[j] = 0;
cdTextPack2[j] = 0; cdTextPack2[j] = 0;
@@ -439,7 +439,7 @@ public static class CdChecksums
cdTextPack4[j] = 0; cdTextPack4[j] = 0;
} }
for(int j = 0; j < 24; j++) for(var j = 0; j < 24; j++)
{ {
cdSubRwPack1[j] = 0; cdSubRwPack1[j] = 0;
cdSubRwPack2[j] = 0; cdSubRwPack2[j] = 0;
@@ -447,7 +447,7 @@ public static class CdChecksums
cdSubRwPack4[j] = 0; cdSubRwPack4[j] = 0;
} }
for(int j = 0; j < 12; j++) for(var j = 0; j < 12; j++)
{ {
qSubChannel[j] = (byte)(qSubChannel[j] | (subchannel[i++] & 0x40) << 1); qSubChannel[j] = (byte)(qSubChannel[j] | (subchannel[i++] & 0x40) << 1);
qSubChannel[j] = (byte)(qSubChannel[j] | subchannel[i++] & 0x40); qSubChannel[j] = (byte)(qSubChannel[j] | subchannel[i++] & 0x40);
@@ -461,7 +461,7 @@ public static class CdChecksums
i = 0; i = 0;
for(int j = 0; j < 18; j++) for(var j = 0; j < 18; j++)
{ {
cdTextPack1[j] = (byte)(cdTextPack1[j] | (subchannel[i++] & 0x3F) << 2); cdTextPack1[j] = (byte)(cdTextPack1[j] | (subchannel[i++] & 0x3F) << 2);
@@ -476,7 +476,7 @@ public static class CdChecksums
cdTextPack1[j] = (byte)(cdTextPack1[j] | subchannel[i++] & 0x3F); cdTextPack1[j] = (byte)(cdTextPack1[j] | subchannel[i++] & 0x3F);
} }
for(int j = 0; j < 18; j++) for(var j = 0; j < 18; j++)
{ {
cdTextPack2[j] = (byte)(cdTextPack2[j] | (subchannel[i++] & 0x3F) << 2); cdTextPack2[j] = (byte)(cdTextPack2[j] | (subchannel[i++] & 0x3F) << 2);
@@ -491,7 +491,7 @@ public static class CdChecksums
cdTextPack2[j] = (byte)(cdTextPack2[j] | subchannel[i++] & 0x3F); cdTextPack2[j] = (byte)(cdTextPack2[j] | subchannel[i++] & 0x3F);
} }
for(int j = 0; j < 18; j++) for(var j = 0; j < 18; j++)
{ {
cdTextPack3[j] = (byte)(cdTextPack3[j] | (subchannel[i++] & 0x3F) << 2); cdTextPack3[j] = (byte)(cdTextPack3[j] | (subchannel[i++] & 0x3F) << 2);
@@ -506,7 +506,7 @@ public static class CdChecksums
cdTextPack3[j] = (byte)(cdTextPack3[j] | subchannel[i++] & 0x3F); cdTextPack3[j] = (byte)(cdTextPack3[j] | subchannel[i++] & 0x3F);
} }
for(int j = 0; j < 18; j++) for(var j = 0; j < 18; j++)
{ {
cdTextPack4[j] = (byte)(cdTextPack4[j] | (subchannel[i++] & 0x3F) << 2); cdTextPack4[j] = (byte)(cdTextPack4[j] | (subchannel[i++] & 0x3F) << 2);
@@ -523,13 +523,13 @@ public static class CdChecksums
i = 0; i = 0;
for(int j = 0; j < 24; j++) cdSubRwPack1[j] = (byte)(subchannel[i++] & 0x3F); for(var j = 0; j < 24; j++) cdSubRwPack1[j] = (byte)(subchannel[i++] & 0x3F);
for(int j = 0; j < 24; j++) cdSubRwPack2[j] = (byte)(subchannel[i++] & 0x3F); for(var j = 0; j < 24; j++) cdSubRwPack2[j] = (byte)(subchannel[i++] & 0x3F);
for(int j = 0; j < 24; j++) cdSubRwPack3[j] = (byte)(subchannel[i++] & 0x3F); for(var j = 0; j < 24; j++) cdSubRwPack3[j] = (byte)(subchannel[i++] & 0x3F);
for(int j = 0; j < 24; j++) cdSubRwPack4[j] = (byte)(subchannel[i++] & 0x3F); for(var j = 0; j < 24; j++) cdSubRwPack4[j] = (byte)(subchannel[i++] & 0x3F);
switch(cdSubRwPack1[0]) switch(cdSubRwPack1[0])
{ {
@@ -570,25 +570,22 @@ public static class CdChecksums
break; break;
} }
ushort qSubChannelCrc = BigEndianBitConverter.ToUInt16(qSubChannel, 10); var qSubChannelCrc = BigEndianBitConverter.ToUInt16(qSubChannel, 10);
byte[] qSubChannelForCrc = new byte[10]; var qSubChannelForCrc = new byte[10];
Array.Copy(qSubChannel, 0, qSubChannelForCrc, 0, 10); Array.Copy(qSubChannel, 0, qSubChannelForCrc, 0, 10);
ushort calculatedQcrc = CRC16CcittContext.Calculate(qSubChannelForCrc); ushort calculatedQcrc = CRC16CcittContext.Calculate(qSubChannelForCrc);
if(qSubChannelCrc != calculatedQcrc) if(qSubChannelCrc != calculatedQcrc)
{ {
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME, Localization.Q_subchannel_CRC_0_expected_1, calculatedQcrc, qSubChannelCrc);
Localization.Q_subchannel_CRC_0_expected_1,
calculatedQcrc,
qSubChannelCrc);
status = false; status = false;
} }
if((cdTextPack1[0] & 0x80) == 0x80) if((cdTextPack1[0] & 0x80) == 0x80)
{ {
ushort cdTextPack1Crc = BigEndianBitConverter.ToUInt16(cdTextPack1, 16); var cdTextPack1Crc = BigEndianBitConverter.ToUInt16(cdTextPack1, 16);
byte[] cdTextPack1ForCrc = new byte[16]; var cdTextPack1ForCrc = new byte[16];
Array.Copy(cdTextPack1, 0, cdTextPack1ForCrc, 0, 16); Array.Copy(cdTextPack1, 0, cdTextPack1ForCrc, 0, 16);
ushort calculatedCdtp1Crc = CRC16CcittContext.Calculate(cdTextPack1ForCrc); ushort calculatedCdtp1Crc = CRC16CcittContext.Calculate(cdTextPack1ForCrc);
@@ -605,8 +602,8 @@ public static class CdChecksums
if((cdTextPack2[0] & 0x80) == 0x80) if((cdTextPack2[0] & 0x80) == 0x80)
{ {
ushort cdTextPack2Crc = BigEndianBitConverter.ToUInt16(cdTextPack2, 16); var cdTextPack2Crc = BigEndianBitConverter.ToUInt16(cdTextPack2, 16);
byte[] cdTextPack2ForCrc = new byte[16]; var cdTextPack2ForCrc = new byte[16];
Array.Copy(cdTextPack2, 0, cdTextPack2ForCrc, 0, 16); Array.Copy(cdTextPack2, 0, cdTextPack2ForCrc, 0, 16);
ushort calculatedCdtp2Crc = CRC16CcittContext.Calculate(cdTextPack2ForCrc); ushort calculatedCdtp2Crc = CRC16CcittContext.Calculate(cdTextPack2ForCrc);
@@ -628,8 +625,8 @@ public static class CdChecksums
if((cdTextPack3[0] & 0x80) == 0x80) if((cdTextPack3[0] & 0x80) == 0x80)
{ {
ushort cdTextPack3Crc = BigEndianBitConverter.ToUInt16(cdTextPack3, 16); var cdTextPack3Crc = BigEndianBitConverter.ToUInt16(cdTextPack3, 16);
byte[] cdTextPack3ForCrc = new byte[16]; var cdTextPack3ForCrc = new byte[16];
Array.Copy(cdTextPack3, 0, cdTextPack3ForCrc, 0, 16); Array.Copy(cdTextPack3, 0, cdTextPack3ForCrc, 0, 16);
ushort calculatedCdtp3Crc = CRC16CcittContext.Calculate(cdTextPack3ForCrc); ushort calculatedCdtp3Crc = CRC16CcittContext.Calculate(cdTextPack3ForCrc);
@@ -651,15 +648,12 @@ public static class CdChecksums
if((cdTextPack4[0] & 0x80) != 0x80) return status; if((cdTextPack4[0] & 0x80) != 0x80) return status;
ushort cdTextPack4Crc = BigEndianBitConverter.ToUInt16(cdTextPack4, 16); var cdTextPack4Crc = BigEndianBitConverter.ToUInt16(cdTextPack4, 16);
byte[] cdTextPack4ForCrc = new byte[16]; var cdTextPack4ForCrc = new byte[16];
Array.Copy(cdTextPack4, 0, cdTextPack4ForCrc, 0, 16); Array.Copy(cdTextPack4, 0, cdTextPack4ForCrc, 0, 16);
ushort calculatedCdtp4Crc = CRC16CcittContext.Calculate(cdTextPack4ForCrc); ushort calculatedCdtp4Crc = CRC16CcittContext.Calculate(cdTextPack4ForCrc);
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME, Localization.Cyclic_CDTP4_0_Calc_CDTP4_1, cdTextPack4Crc, calculatedCdtp4Crc);
Localization.Cyclic_CDTP4_0_Calc_CDTP4_1,
cdTextPack4Crc,
calculatedCdtp4Crc);
if(cdTextPack4Crc == calculatedCdtp4Crc || cdTextPack4Crc == 0) return status; if(cdTextPack4Crc == calculatedCdtp4Crc || cdTextPack4Crc == 0) return status;

View File

@@ -194,7 +194,7 @@ public class ReedSolomon
{ {
int i; int i;
int mask = 1; var mask = 1;
_alphaTo[_mm] = 0; _alphaTo[_mm] = 0;
for(i = 0; i < _mm; i++) for(i = 0; i < _mm; i++)
@@ -299,9 +299,8 @@ public class ReedSolomon
for(i = _kk - 1; i >= 0; i--) for(i = _kk - 1; i >= 0; i--)
{ {
if(_mm != 8) if(_mm != 8)
{ if(data[i] > _nn)
if(data[i] > _nn) return -1; /* Illegal symbol */ return -1; /* Illegal symbol */
}
int feedback = _indexOf[data[i] ^ bb[_nn - _kk - 1]]; int feedback = _indexOf[data[i] ^ bb[_nn - _kk - 1]];
@@ -357,24 +356,23 @@ public class ReedSolomon
erasPos = new int[_nn - _kk]; erasPos = new int[_nn - _kk];
int i, j; int i, j;
int q, tmp; int q, tmp;
int[] recd = new int[_nn]; var recd = new int[_nn];
int[] lambda = new int[_nn - _kk + 1]; /* Err+Eras Locator poly */ var lambda = new int[_nn - _kk + 1]; /* Err+Eras Locator poly */
int[] s = new int[_nn - _kk + 1]; /* syndrome poly */ var s = new int[_nn - _kk + 1]; /* syndrome poly */
int[] b = new int[_nn - _kk + 1]; var b = new int[_nn - _kk + 1];
int[] t = new int[_nn - _kk + 1]; var t = new int[_nn - _kk + 1];
int[] omega = new int[_nn - _kk + 1]; var omega = new int[_nn - _kk + 1];
int[] root = new int[_nn - _kk]; var root = new int[_nn - _kk];
int[] reg = new int[_nn - _kk + 1]; var reg = new int[_nn - _kk + 1];
int[] loc = new int[_nn - _kk]; var loc = new int[_nn - _kk];
int count; int count;
/* data[] is in polynomial form, copy and convert to index form */ /* data[] is in polynomial form, copy and convert to index form */
for(i = _nn - 1; i >= 0; i--) for(i = _nn - 1; i >= 0; i--)
{ {
if(_mm != 8) if(_mm != 8)
{ if(data[i] > _nn)
if(data[i] > _nn) return -1; /* Illegal symbol */ return -1; /* Illegal symbol */
}
recd[i] = _indexOf[data[i]]; recd[i] = _indexOf[data[i]];
} }
@@ -382,16 +380,15 @@ public class ReedSolomon
/* first form the syndromes; i.e., evaluate recd(x) at roots of g(x) /* first form the syndromes; i.e., evaluate recd(x) at roots of g(x)
* namely @**(B0+i), i = 0, ... ,(NN-KK-1) * namely @**(B0+i), i = 0, ... ,(NN-KK-1)
*/ */
int synError = 0; var synError = 0;
for(i = 1; i <= _nn - _kk; i++) for(i = 1; i <= _nn - _kk; i++)
{ {
tmp = 0; tmp = 0;
for(j = 0; j < _nn; j++) for(j = 0; j < _nn; j++)
{ if(recd[j] != _a0) /* recd[j] in index form */
if(recd[j] != _a0) /* recd[j] in index form */ tmp ^= _alphaTo[Modnn(recd[j] + (B0 + i - 1) * j)]; tmp ^= _alphaTo[Modnn(recd[j] + (B0 + i - 1) * j)];
}
synError |= tmp; /* set flag if non-zero syndrome => synError |= tmp; /* set flag if non-zero syndrome =>
* error */ * error */
@@ -457,8 +454,7 @@ public class ReedSolomon
return -1; return -1;
} }
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME, Localization.Erasure_positions_as_determined_by_roots_of_Eras_Loc_Poly);
Localization.Erasure_positions_as_determined_by_roots_of_Eras_Loc_Poly);
for(i = 0; i < count; i++) AaruLogging.Debug(MODULE_NAME, "{0} ", loc[i]); for(i = 0; i < count; i++) AaruLogging.Debug(MODULE_NAME, "{0} ", loc[i]);
@@ -479,12 +475,11 @@ public class ReedSolomon
{ {
/* r is the step number */ /* r is the step number */
/* Compute discrepancy at the r-th step in poly-form */ /* Compute discrepancy at the r-th step in poly-form */
int discrR = 0; var discrR = 0;
for(i = 0; i < r; i++) for(i = 0; i < r; i++)
{ if(lambda[i] != 0 && s[r - i] != _a0)
if(lambda[i] != 0 && s[r - i] != _a0) discrR ^= _alphaTo[Modnn(_indexOf[lambda[i]] + s[r - i])]; discrR ^= _alphaTo[Modnn(_indexOf[lambda[i]] + s[r - i])];
}
discrR = _indexOf[discrR]; /* Index form */ discrR = _indexOf[discrR]; /* Index form */
@@ -530,7 +525,7 @@ public class ReedSolomon
} }
/* Convert lambda to index form and compute deg(lambda(x)) */ /* Convert lambda to index form and compute deg(lambda(x)) */
int degLambda = 0; var degLambda = 0;
for(i = 0; i < _nn - _kk + 1; i++) for(i = 0; i < _nn - _kk + 1; i++)
{ {
@@ -582,7 +577,7 @@ public class ReedSolomon
* Compute err+eras evaluator poly omega(x) = s(x)*lambda(x) (modulo * Compute err+eras evaluator poly omega(x) = s(x)*lambda(x) (modulo
* x**(NN-KK)). in index form. Also find deg(omega). * x**(NN-KK)). in index form. Also find deg(omega).
*/ */
int degOmega = 0; var degOmega = 0;
for(i = 0; i < _nn - _kk; i++) for(i = 0; i < _nn - _kk; i++)
{ {
@@ -590,9 +585,8 @@ public class ReedSolomon
j = degLambda < i ? degLambda : i; j = degLambda < i ? degLambda : i;
for(; j >= 0; j--) for(; j >= 0; j--)
{ if(s[i + 1 - j] != _a0 && lambda[j] != _a0)
if(s[i + 1 - j] != _a0 && lambda[j] != _a0) tmp ^= _alphaTo[Modnn(s[i + 1 - j] + lambda[j])]; tmp ^= _alphaTo[Modnn(s[i + 1 - j] + lambda[j])];
}
if(tmp != 0) degOmega = i; if(tmp != 0) degOmega = i;
@@ -607,21 +601,19 @@ public class ReedSolomon
*/ */
for(j = count - 1; j >= 0; j--) for(j = count - 1; j >= 0; j--)
{ {
int num1 = 0; var num1 = 0;
for(i = degOmega; i >= 0; i--) for(i = degOmega; i >= 0; i--)
{ if(omega[i] != _a0)
if(omega[i] != _a0) num1 ^= _alphaTo[Modnn(omega[i] + i * root[j])]; num1 ^= _alphaTo[Modnn(omega[i] + i * root[j])];
}
int num2 = _alphaTo[Modnn(root[j] * (B0 - 1) + _nn)]; int num2 = _alphaTo[Modnn(root[j] * (B0 - 1) + _nn)];
int den = 0; var den = 0;
/* lambda[i+1] for i even is the formal derivative lambda_pr of lambda[i] */ /* lambda[i+1] for i even is the formal derivative lambda_pr of lambda[i] */
for(i = Min(degLambda, _nn - _kk - 1) & ~1; i >= 0; i -= 2) for(i = Min(degLambda, _nn - _kk - 1) & ~1; i >= 0; i -= 2)
{ if(lambda[i + 1] != _a0)
if(lambda[i + 1] != _a0) den ^= _alphaTo[Modnn(lambda[i + 1] + i * root[j])]; den ^= _alphaTo[Modnn(lambda[i + 1] + i * root[j])];
}
if(den == 0) if(den == 0)
{ {

View File

@@ -94,8 +94,7 @@ public static partial class MediaTypeFromDevice
case 0x02: case 0x02:
case 0x06: case 0x06:
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization Localization.SCSI_medium_type_is_0_setting_media_type_to_Compact_Disc_Digital_Audio,
.SCSI_medium_type_is_0_setting_media_type_to_Compact_Disc_Digital_Audio,
mediumType); mediumType);
return MediaType.CDDA; return MediaType.CDDA;

View File

@@ -446,9 +446,7 @@ public static partial class MediaTypeFromDevice
case 39168 when vendor.StartsWith("iomega", StringComparison.OrdinalIgnoreCase): case 39168 when vendor.StartsWith("iomega", StringComparison.OrdinalIgnoreCase):
case 41004 when vendor.StartsWith("iomega", StringComparison.OrdinalIgnoreCase): case 41004 when vendor.StartsWith("iomega", StringComparison.OrdinalIgnoreCase):
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME, Localization.SCSI_Media_Type_Description_Bernoulli10, blocks);
Localization.SCSI_Media_Type_Description_Bernoulli10,
blocks);
return MediaType.Bernoulli10; return MediaType.Bernoulli10;
case 46956: case 46956:
@@ -713,8 +711,7 @@ public static partial class MediaTypeFromDevice
return MediaType.EZ135; return MediaType.EZ135;
case 294918 when vendor.StartsWith("iomega", StringComparison.OrdinalIgnoreCase): case 294918 when vendor.StartsWith("iomega", StringComparison.OrdinalIgnoreCase):
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME, Localization.SCSI_Media_Type_Description_Bernoulli2_150);
Localization.SCSI_Media_Type_Description_Bernoulli2_150);
return MediaType.Bernoulli150; return MediaType.Bernoulli150;
case 390696 when vendor.Equals("syquest", StringComparison.InvariantCultureIgnoreCase): case 390696 when vendor.Equals("syquest", StringComparison.InvariantCultureIgnoreCase):

View File

@@ -800,8 +800,7 @@ public static class Identify
if(IdentifyDeviceResponse.Length != 512) if(IdentifyDeviceResponse.Length != 512)
{ {
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME, Localization.IDENTIFY_response_is_different_than_512_bytes_not_decoding);
Localization.IDENTIFY_response_is_different_than_512_bytes_not_decoding);
return null; return null;
} }
@@ -833,7 +832,7 @@ public static class Identify
ataId.WWN = DescrambleWWN(ataId.WWN); ataId.WWN = DescrambleWWN(ataId.WWN);
ataId.WWNExtension = DescrambleWWN(ataId.WWNExtension); ataId.WWNExtension = DescrambleWWN(ataId.WWNExtension);
byte[] buf = new byte[512]; var buf = new byte[512];
nint ptr = System.Runtime.InteropServices.Marshal.AllocHGlobal(512); nint ptr = System.Runtime.InteropServices.Marshal.AllocHGlobal(512);
System.Runtime.InteropServices.Marshal.StructureToPtr(ataId, ptr, false); System.Runtime.InteropServices.Marshal.StructureToPtr(ataId, ptr, false);
System.Runtime.InteropServices.Marshal.Copy(ptr, buf, 0, 512); System.Runtime.InteropServices.Marshal.Copy(ptr, buf, 0, 512);
@@ -858,7 +857,7 @@ public static class Identify
static ulong DescrambleWWN(ulong WWN) static ulong DescrambleWWN(ulong WWN)
{ {
byte[] qwb = BitConverter.GetBytes(WWN); byte[] qwb = BitConverter.GetBytes(WWN);
byte[] qword = new byte[8]; var qword = new byte[8];
qword[7] = qwb[1]; qword[7] = qwb[1];
qword[6] = qwb[0]; qword[6] = qwb[0];
@@ -876,7 +875,7 @@ public static class Identify
{ {
byte[] outbuf = buffer[offset + length - 1] != 0x00 ? new byte[length + 1] : new byte[length]; byte[] outbuf = buffer[offset + length - 1] != 0x00 ? new byte[length + 1] : new byte[length];
for(int i = 0; i < length; i += 2) for(var i = 0; i < length; i += 2)
{ {
outbuf[i] = buffer[offset + i + 1]; outbuf[i] = buffer[offset + i + 1];
outbuf[i + 1] = buffer[offset + i]; outbuf[i + 1] = buffer[offset + i];
@@ -889,9 +888,9 @@ public static class Identify
static byte[] ScrambleATAString(string str, int length) static byte[] ScrambleATAString(string str, int length)
{ {
byte[] buf = new byte[length]; var buf = new byte[length];
for(int i = 0; i < length; i++) buf[i] = 0x20; for(var i = 0; i < length; i++) buf[i] = 0x20;
if(str is null) return buf; if(str is null) return buf;
@@ -899,13 +898,13 @@ public static class Identify
if(bytes.Length % 2 != 0) if(bytes.Length % 2 != 0)
{ {
byte[] tmp = new byte[bytes.Length + 1]; var tmp = new byte[bytes.Length + 1];
tmp[^1] = 0x20; tmp[^1] = 0x20;
Array.Copy(bytes, 0, tmp, 0, bytes.Length); Array.Copy(bytes, 0, tmp, 0, bytes.Length);
bytes = tmp; bytes = tmp;
} }
for(int i = 0; i < bytes.Length; i += 2) for(var i = 0; i < bytes.Length; i += 2)
{ {
buf[i] = bytes[i + 1]; buf[i] = bytes[i + 1];
buf[i + 1] = bytes[i]; buf[i + 1] = bytes[i];

View File

@@ -38,7 +38,6 @@
using System; using System;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.Linq;
using Aaru.Logging; using Aaru.Logging;
namespace Aaru.CommonTypes.Structs.Devices.SCSI; namespace Aaru.CommonTypes.Structs.Devices.SCSI;
@@ -286,8 +285,7 @@ public struct Inquiry
SCSIInquiryResponse.Length != SCSIInquiryResponse[4]) SCSIInquiryResponse.Length != SCSIInquiryResponse[4])
{ {
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization Localization.INQUIRY_response_length_0_bytes_is_different_than_specified_in_length_field,
.INQUIRY_response_length_0_bytes_is_different_than_specified_in_length_field,
SCSIInquiryResponse.Length, SCSIInquiryResponse.Length,
SCSIInquiryResponse[4] + 4); SCSIInquiryResponse[4] + 4);
@@ -477,7 +475,7 @@ public struct Inquiry
decoded.VersionDescriptors = new ushort[descriptorsNo]; decoded.VersionDescriptors = new ushort[descriptorsNo];
for(int i = 0; i < descriptorsNo; i++) for(var i = 0; i < descriptorsNo; i++)
decoded.VersionDescriptors[i] = BitConverter.ToUInt16(SCSIInquiryResponse, 58 + i * 2); decoded.VersionDescriptors[i] = BitConverter.ToUInt16(SCSIInquiryResponse, 58 + i * 2);
} }
@@ -528,7 +526,7 @@ public struct Inquiry
Inquiry decoded = inq.Value; Inquiry decoded = inq.Value;
byte[] buffer = new byte[512]; var buffer = new byte[512];
byte length = 0; byte length = 0;
buffer[0] = (byte)(decoded.PeripheralQualifier << 5); buffer[0] = (byte)(decoded.PeripheralQualifier << 5);
@@ -729,7 +727,7 @@ public struct Inquiry
{ {
length = (byte)(58 + decoded.VersionDescriptors.Length * 2); length = (byte)(58 + decoded.VersionDescriptors.Length * 2);
for(int i = 0; i < decoded.VersionDescriptors.Length; i++) for(var i = 0; i < decoded.VersionDescriptors.Length; i++)
Array.Copy(BitConverter.GetBytes(decoded.VersionDescriptors[i]), 0, buffer, 56 + i * 2, 2); Array.Copy(BitConverter.GetBytes(decoded.VersionDescriptors[i]), 0, buffer, 56 + i * 2, 2);
} }
@@ -758,7 +756,7 @@ public struct Inquiry
} }
buffer[4] = length; buffer[4] = length;
byte[] dest = new byte[length]; var dest = new byte[length];
Array.Copy(buffer, 0, dest, 0, length); Array.Copy(buffer, 0, dest, 0, length);
return dest; return dest;

View File

@@ -46,7 +46,7 @@ public sealed partial class DeviceReport
/// <returns>Media report</returns> /// <returns>Media report</returns>
public TestedMedia ReportAtaMedia() public TestedMedia ReportAtaMedia()
{ {
bool sense = true; var sense = true;
AtaErrorRegistersChs errorChs = new(); AtaErrorRegistersChs errorChs = new();
AtaErrorRegistersLba28 errorLba = new(); AtaErrorRegistersLba28 errorLba = new();
AtaErrorRegistersLba48 errorLba48 = new(); AtaErrorRegistersLba48 errorLba48 = new();
@@ -181,7 +181,7 @@ public sealed partial class DeviceReport
mediaTest.Manufacturer = ataId.MediaManufacturer; mediaTest.Manufacturer = ataId.MediaManufacturer;
} }
ulong checkCorrectRead = BitConverter.ToUInt64(buffer, 0); var checkCorrectRead = BitConverter.ToUInt64(buffer, 0);
Spectre.ProgressSingleSpinner(ctx => Spectre.ProgressSingleSpinner(ctx =>
{ {
@@ -535,7 +535,7 @@ public sealed partial class DeviceReport
/// <summary>Creates a report of an ATA device</summary> /// <summary>Creates a report of an ATA device</summary>
public TestedMedia ReportAta(Identify.IdentifyDevice ataId) public TestedMedia ReportAta(Identify.IdentifyDevice ataId)
{ {
bool sense = true; var sense = true;
byte[] readBuf = []; byte[] readBuf = [];
AtaErrorRegistersChs errorChs = new(); AtaErrorRegistersChs errorChs = new();
AtaErrorRegistersLba28 errorLba = new(); AtaErrorRegistersLba28 errorLba = new();
@@ -998,7 +998,7 @@ public sealed partial class DeviceReport
/// <returns>IDENTIFY ATA DEVICE response without the private fields</returns> /// <returns>IDENTIFY ATA DEVICE response without the private fields</returns>
public static byte[] ClearIdentify(byte[] buffer) public static byte[] ClearIdentify(byte[] buffer)
{ {
byte[] empty = new byte[512]; var empty = new byte[512];
Array.Copy(empty, 0, buffer, 20, 20); Array.Copy(empty, 0, buffer, 20, 20);
Array.Copy(empty, 0, buffer, 216, 8); Array.Copy(empty, 0, buffer, 216, 8);

View File

@@ -624,6 +624,7 @@ public sealed partial class MediaScan
} }
if(accumulatedSpeedMs < 100) continue; if(accumulatedSpeedMs < 100) continue;
currentSpeed = accumulatedSpeedSectors * blockSize / (1048576 * (accumulatedSpeedMs / 1000.0)); currentSpeed = accumulatedSpeedSectors * blockSize / (1048576 * (accumulatedSpeedMs / 1000.0));
ScanSpeed?.Invoke(i, currentSpeed * 1024); ScanSpeed?.Invoke(i, currentSpeed * 1024);
accumulatedSpeedMs = 0; accumulatedSpeedMs = 0;

View File

@@ -66,14 +66,11 @@ public static class MMC
const string PS2_JAPANESE_HASH = "b82bffb809070d61fe050b7e1545df53d8f3cc648257cdff7502bc0ba6b38870"; const string PS2_JAPANESE_HASH = "b82bffb809070d61fe050b7e1545df53d8f3cc648257cdff7502bc0ba6b38870";
const string MODULE_NAME = "Media detection"; const string MODULE_NAME = "Media detection";
static readonly byte[] _ps3Id = static readonly byte[] _ps3Id = "PlayStation3\0\0\0\0"u8.ToArray();
"PlayStation3\0\0\0\0"u8.ToArray();
static readonly byte[] _ps4Id = static readonly byte[] _ps4Id = "PlayStation4\0\0\0\0"u8.ToArray();
"PlayStation4\0\0\0\0"u8.ToArray();
static readonly byte[] _ps5Id = static readonly byte[] _ps5Id = "PlayStation5\0\0\0\0"u8.ToArray();
"PlayStation5\0\0\0\0"u8.ToArray();
static readonly byte[] _operaId = [0x01, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x01]; static readonly byte[] _operaId = [0x01, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x01];

View File

@@ -88,9 +88,7 @@ public static class BCA
if(BCAResponse.Length != 68) if(BCAResponse.Length != 68)
{ {
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME, Localization.Found_incorrect_Blu_ray_BCA_size_0_bytes, BCAResponse.Length);
Localization.Found_incorrect_Blu_ray_BCA_size_0_bytes,
BCAResponse.Length);
return null; return null;
} }

View File

@@ -91,8 +91,7 @@ public static class Spare
if(SAIResponse.Length != 16) if(SAIResponse.Length != 16)
{ {
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization Localization.Spare_Decode_Found_incorrect_Blu_ray_Spare_Area_Information_size_0_bytes,
.Spare_Decode_Found_incorrect_Blu_ray_Spare_Area_Information_size_0_bytes,
SAIResponse.Length); SAIResponse.Length);
return null; return null;

View File

@@ -68,8 +68,7 @@ public static class ATIP
if(CDATIPResponse.Length != 32 && CDATIPResponse.Length != 28) if(CDATIPResponse.Length != 32 && CDATIPResponse.Length != 28)
{ {
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization Localization.Expected_CD_ATIP_size_32_bytes_is_not_received_size_0_bytes_not_decoding,
.Expected_CD_ATIP_size_32_bytes_is_not_received_size_0_bytes_not_decoding,
CDATIPResponse.Length); CDATIPResponse.Length);
return null; return null;

View File

@@ -119,15 +119,14 @@ public static class CDTextOnLeadIn
if(decoded.DataLength + 2 != CDTextResponse.Length) if(decoded.DataLength + 2 != CDTextResponse.Length)
{ {
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization Localization.Expected_CD_TEXT_size_0_bytes_is_not_received_size_1_bytes_not_decoding,
.Expected_CD_TEXT_size_0_bytes_is_not_received_size_1_bytes_not_decoding,
decoded.DataLength + 2, decoded.DataLength + 2,
CDTextResponse.Length); CDTextResponse.Length);
return null; return null;
} }
for(int i = 0; i < (decoded.DataLength - 2) / 18; i++) for(var i = 0; i < (decoded.DataLength - 2) / 18; i++)
{ {
decoded.DataPacks[i].HeaderID1 = CDTextResponse[0 + i * 18 + 4]; decoded.DataPacks[i].HeaderID1 = CDTextResponse[0 + i * 18 + 4];
decoded.DataPacks[i].HeaderID2 = CDTextResponse[1 + i * 18 + 4]; decoded.DataPacks[i].HeaderID2 = CDTextResponse[1 + i * 18 + 4];

View File

@@ -80,7 +80,7 @@ public static class Session
return null; return null;
} }
for(int i = 0; i < (decoded.DataLength - 2) / 8; i++) for(var i = 0; i < (decoded.DataLength - 2) / 8; i++)
{ {
decoded.TrackDescriptors[i].Reserved1 = CDSessionInfoResponse[0 + i * 8 + 4]; decoded.TrackDescriptors[i].Reserved1 = CDSessionInfoResponse[0 + i * 8 + 4];
decoded.TrackDescriptors[i].ADR = (byte)((CDSessionInfoResponse[1 + i * 8 + 4] & 0xF0) >> 4); decoded.TrackDescriptors[i].ADR = (byte)((CDSessionInfoResponse[1 + i * 8 + 4] & 0xF0) >> 4);

View File

@@ -75,15 +75,14 @@ public static class TOC
if(decoded.DataLength + 2 != CDTOCResponse.Length) if(decoded.DataLength + 2 != CDTOCResponse.Length)
{ {
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization Localization.Expected_CD_TOC_size_0_bytes_is_not_received_size_1_bytes_not_decoding,
.Expected_CD_TOC_size_0_bytes_is_not_received_size_1_bytes_not_decoding,
decoded.DataLength + 2, decoded.DataLength + 2,
CDTOCResponse.Length); CDTOCResponse.Length);
return null; return null;
} }
for(int i = 0; i < (decoded.DataLength - 2) / 8; i++) for(var i = 0; i < (decoded.DataLength - 2) / 8; i++)
{ {
decoded.TrackDescriptors[i].Reserved1 = CDTOCResponse[0 + i * 8 + 4]; decoded.TrackDescriptors[i].Reserved1 = CDTOCResponse[0 + i * 8 + 4];
decoded.TrackDescriptors[i].ADR = (byte)((CDTOCResponse[1 + i * 8 + 4] & 0xF0) >> 4); decoded.TrackDescriptors[i].ADR = (byte)((CDTOCResponse[1 + i * 8 + 4] & 0xF0) >> 4);

View File

@@ -158,24 +158,24 @@ public static class Apple2
{ {
if(data is not { Length: 410 }) return null; if(data is not { Length: 410 }) return null;
byte[] buffer = new byte[data.Length]; var buffer = new byte[data.Length];
byte carry = 0; byte carry = 0;
for(int i = 0; i < data.Length; i++) for(var i = 0; i < data.Length; i++)
{ {
carry ^= ReadTable5and3[data[i]]; carry ^= ReadTable5and3[data[i]];
buffer[i] = carry; buffer[i] = carry;
} }
byte[] output = new byte[256]; var output = new byte[256];
for(int i = 0; i < 51; i++) for(var i = 0; i < 51; i++)
{ {
byte b1 = buffer[51 * 3 - i]; byte b1 = buffer[51 * 3 - i];
byte b2 = buffer[51 * 2 - i]; byte b2 = buffer[51 * 2 - i];
byte b3 = buffer[51 - i]; byte b3 = buffer[51 - i];
byte b4 = (byte)(((b1 & 2) << 1 | b2 & 2 | (b3 & 2) >> 1) & 0xFF); var b4 = (byte)(((b1 & 2) << 1 | b2 & 2 | (b3 & 2) >> 1) & 0xFF);
byte b5 = (byte)(((b1 & 1) << 2 | (b2 & 1) << 1 | b3 & 1) & 0xFF); var b5 = (byte)(((b1 & 1) << 2 | (b2 & 1) << 1 | b3 & 1) & 0xFF);
output[250 - 5 * i] = (byte)((buffer[i + 51 * 3 + 1] << 3 | b1 >> 2 & 0x7) & 0xFF); output[250 - 5 * i] = (byte)((buffer[i + 51 * 3 + 1] << 3 | b1 >> 2 & 0x7) & 0xFF);
output[251 - 5 * i] = (byte)((buffer[i + 51 * 4 + 1] << 3 | b2 >> 2 & 0x7) & 0xFF); output[251 - 5 * i] = (byte)((buffer[i + 51 * 4 + 1] << 3 | b2 >> 2 & 0x7) & 0xFF);
output[252 - 5 * i] = (byte)((buffer[i + 51 * 5 + 1] << 3 | b3 >> 2 & 0x7) & 0xFF); output[252 - 5 * i] = (byte)((buffer[i + 51 * 5 + 1] << 3 | b3 >> 2 & 0x7) & 0xFF);
@@ -194,16 +194,16 @@ public static class Apple2
{ {
if(data is not { Length: 342 }) return null; if(data is not { Length: 342 }) return null;
byte[] buffer = new byte[data.Length]; var buffer = new byte[data.Length];
byte carry = 0; byte carry = 0;
for(int i = 0; i < data.Length; i++) for(var i = 0; i < data.Length; i++)
{ {
carry ^= ReadTable6and2[data[i]]; carry ^= ReadTable6and2[data[i]];
buffer[i] = carry; buffer[i] = carry;
} }
byte[] output = new byte[256]; var output = new byte[256];
for(uint i = 0; i < 256; i++) for(uint i = 0; i < 256; i++)
{ {
@@ -314,8 +314,8 @@ public static class Apple2
sector.addressField.epilogue[2]); sector.addressField.epilogue[2]);
position += 14; position += 14;
int syncCount = 0; var syncCount = 0;
bool onSync = false; var onSync = false;
var gaps = new MemoryStream(); var gaps = new MemoryStream();
while(data[position] == 0xFF) while(data[position] == 0xFF)
@@ -358,9 +358,7 @@ public static class Apple2
sector.dataField.data = gaps.ToArray(); sector.dataField.data = gaps.ToArray();
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME, Localization.Data_has_0_bytes, sector.dataField.data.Length);
Localization.Data_has_0_bytes,
sector.dataField.data.Length);
sector.dataField.checksum = data[position]; sector.dataField.checksum = data[position];
sector.dataField.epilogue = new byte[3]; sector.dataField.epilogue = new byte[3];
@@ -454,12 +452,12 @@ public static class Apple2
public static RawTrack MarshalTrack(byte[] data, out int endOffset, int offset = 0) public static RawTrack MarshalTrack(byte[] data, out int endOffset, int offset = 0)
{ {
int position = offset; int position = offset;
bool firstSector = true; var firstSector = true;
bool onSync = false; var onSync = false;
var gaps = new MemoryStream(); var gaps = new MemoryStream();
int count = 0; var count = 0;
List<RawSector> sectors = []; List<RawSector> sectors = [];
byte[] trackNumber = new byte[2]; var trackNumber = new byte[2];
endOffset = offset; endOffset = offset;
while(position < data.Length && data[position] == 0xFF) while(position < data.Length && data[position] == 0xFF)
@@ -497,11 +495,9 @@ public static class Apple2
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization.Adding_sector_0_of_track_1, Localization.Adding_sector_0_of_track_1,
((sector.addressField.sector[0] & 0x55) << 1 | ((sector.addressField.sector[0] & 0x55) << 1 | sector.addressField.sector[1] & 0x55) &
sector.addressField.sector[1] & 0x55) &
0xFF, 0xFF,
((sector.addressField.track[0] & 0x55) << 1 | ((sector.addressField.track[0] & 0x55) << 1 | sector.addressField.track[1] & 0x55) &
sector.addressField.track[1] & 0x55) &
0xFF); 0xFF);
sectors.Add(sector); sectors.Add(sector);

View File

@@ -119,7 +119,8 @@ public static partial class Modes
{ {
if(header.Value.MediumType != MediumTypes.Default) if(header.Value.MediumType != MediumTypes.Default)
{ {
sb.AppendFormat($"\t[slateblue1]{Localization.Medium_is_0}[/]", $"[italic][fuchsia]{GetMediumTypeDescription(header.Value.MediumType)}[/][/]") sb.AppendFormat($"\t[slateblue1]{Localization.Medium_is_0}[/]",
$"[italic][fuchsia]{GetMediumTypeDescription(header.Value.MediumType)}[/][/]")
.AppendLine(); .AppendLine();
} }
@@ -160,14 +161,16 @@ public static partial class Modes
{ {
if(descriptor.Blocks == 0) if(descriptor.Blocks == 0)
{ {
sb.AppendFormat($"\t[slateblue1]{Localization.All_remaining_blocks_have_0_and_are_1_bytes_each}[/]", sb
.AppendFormat($"\t[slateblue1]{Localization.All_remaining_blocks_have_0_and_are_1_bytes_each}[/]",
$"[lime]{density}[/]", $"[lime]{density}[/]",
$"[lime]{descriptor.BlockLength}[/]") $"[lime]{descriptor.BlockLength}[/]")
.AppendLine(); .AppendLine();
} }
else else
{ {
sb.AppendFormat($"\t[slateblue1]{Localization._0_blocks_have_1_and_are_2_bytes_each}[/]", sb
.AppendFormat($"\t[slateblue1]{Localization._0_blocks_have_1_and_are_2_bytes_each}[/]",
$"[lime]{descriptor.Blocks}[/]", $"[lime]{descriptor.Blocks}[/]",
$"[lime]{density}[/]", $"[lime]{density}[/]",
$"[lime{descriptor.BlockLength}[/]") $"[lime{descriptor.BlockLength}[/]")
@@ -215,7 +218,8 @@ public static partial class Modes
break; break;
default: default:
sb.AppendFormat($"\t[green]{Localization.Unknown_buffered_mode_code_0}[/]", $"[teal]{header.Value.BufferedMode}[/]") sb.AppendFormat($"\t[green]{Localization.Unknown_buffered_mode_code_0}[/]",
$"[teal]{header.Value.BufferedMode}[/]")
.AppendLine(); .AppendLine();
break; break;
@@ -224,7 +228,8 @@ public static partial class Modes
if(header.Value.Speed == 0) if(header.Value.Speed == 0)
sb.AppendLine($"\t[green]{Localization.Device_uses_default_speed}[/]"); sb.AppendLine($"\t[green]{Localization.Device_uses_default_speed}[/]");
else else
sb.AppendFormat($"\t[green]{Localization.Device_uses_speed_0}[/]", $"[teal]{header.Value.Speed}[/]").AppendLine(); sb.AppendFormat($"\t[green]{Localization.Device_uses_speed_0}[/]", $"[teal]{header.Value.Speed}[/]")
.AppendLine();
if(header.Value.WriteProtected) sb.AppendLine($"\t[red]{Localization.Medium_is_write_protected}[/]"); if(header.Value.WriteProtected) sb.AppendLine($"\t[red]{Localization.Medium_is_write_protected}[/]");
@@ -1102,14 +1107,16 @@ public static partial class Modes
} }
else if(descriptor.BlockLength == 0) else if(descriptor.BlockLength == 0)
{ {
sb.AppendFormat($"\t[slateblue1]{Localization._0_blocks_conform_to_1_and_have_a_variable_length}[/]", sb
.AppendFormat($"\t[slateblue1]{Localization._0_blocks_conform_to_1_and_have_a_variable_length}[/]",
$"[teal]{descriptor.Blocks}[/]", $"[teal]{descriptor.Blocks}[/]",
$"[fuchsia]{density}[/]") $"[fuchsia]{density}[/]")
.AppendLine(); .AppendLine();
} }
else else
{ {
sb.AppendFormat($"\t[slateblue1]{Localization._0_blocks_conform_to_1_and_are_2_bytes_each}[/]", sb
.AppendFormat($"\t[slateblue1]{Localization._0_blocks_conform_to_1_and_are_2_bytes_each}[/]",
$"[teal]{descriptor.Blocks}[/]", $"[teal]{descriptor.Blocks}[/]",
$"[fuchsia]{density}[/]", $"[fuchsia]{density}[/]",
$"[teal]{descriptor.BlockLength}[/]") $"[teal]{descriptor.BlockLength}[/]")
@@ -1120,19 +1127,22 @@ public static partial class Modes
{ {
if(descriptor.BlockLength == 0) if(descriptor.BlockLength == 0)
{ {
sb.AppendFormat($"\t[slateblue1]{Localization.All_remaining_blocks_have_a_variable_length}[/]") sb
.AppendFormat($"\t[slateblue1]{Localization.All_remaining_blocks_have_a_variable_length}[/]")
.AppendLine(); .AppendLine();
} }
else else
{ {
sb.AppendFormat($"\t[slateblue1]{Localization.All_remaining_blocks_are_0_bytes_each}[/]", sb
.AppendFormat($"\t[slateblue1]{Localization.All_remaining_blocks_are_0_bytes_each}[/]",
$"[teal]{descriptor.BlockLength}[/]") $"[teal]{descriptor.BlockLength}[/]")
.AppendLine(); .AppendLine();
} }
} }
else if(descriptor.BlockLength == 0) else if(descriptor.BlockLength == 0)
{ {
sb.AppendFormat($"\t[slateblue1]{Localization._0_blocks_have_a_variable_length}[/]", $"[teal]{descriptor.Blocks}[/]") sb.AppendFormat($"\t[slateblue1]{Localization._0_blocks_have_a_variable_length}[/]",
$"[teal]{descriptor.Blocks}[/]")
.AppendLine(); .AppendLine();
} }
else else
@@ -1165,7 +1175,8 @@ public static partial class Modes
break; break;
default: default:
sb.AppendFormat($"\t[red]{Localization.Unknown_buffered_mode_code_0}[/]", $"[teal]{header.Value.BufferedMode}[/]") sb.AppendFormat($"\t[red]{Localization.Unknown_buffered_mode_code_0}[/]",
$"[teal]{header.Value.BufferedMode}[/]")
.AppendLine(); .AppendLine();
break; break;
@@ -1215,7 +1226,8 @@ public static partial class Modes
break; break;
default: default:
sb.AppendFormat(Localization.an_unknown_medium_type_0, $"[teal]{(byte)header.Value.MediumType}[/]"); sb.AppendFormat(Localization.an_unknown_medium_type_0,
$"[teal]{(byte)header.Value.MediumType}[/]");
break; break;
} }
@@ -1225,7 +1237,8 @@ public static partial class Modes
if(header.Value.WriteProtected) sb.AppendLine($"\t[red]{Localization.Medium_is_write_protected}[/]"); if(header.Value.WriteProtected) sb.AppendLine($"\t[red]{Localization.Medium_is_write_protected}[/]");
if(header.Value.EBC) sb.AppendLine($"\t[green]{Localization.Blank_checking_during_write_is_enabled}[/]"); if(header.Value.EBC)
sb.AppendLine($"\t[green]{Localization.Blank_checking_during_write_is_enabled}[/]");
if(header.Value.DPOFUA) sb.AppendLine($"\t[green]{Localization.Drive_supports_DPO_and_FUA_bits}[/]"); if(header.Value.DPOFUA) sb.AppendLine($"\t[green]{Localization.Drive_supports_DPO_and_FUA_bits}[/]");
@@ -1294,7 +1307,8 @@ public static partial class Modes
} }
else else
{ {
sb.AppendFormat($"\t[slateblue1]{Localization.All_remaining_blocks_are_0_and_are_1_bytes_each}[/]", sb
.AppendFormat($"\t[slateblue1]{Localization.All_remaining_blocks_are_0_and_are_1_bytes_each}[/]",
$"[fuchsia]{density}[/]", $"[fuchsia]{density}[/]",
$"[teal]{descriptor.BlockLength}[/]") $"[teal]{descriptor.BlockLength}[/]")
.AppendLine(); .AppendLine();
@@ -1302,7 +1316,8 @@ public static partial class Modes
} }
else if(descriptor.BlockLength == 0) else if(descriptor.BlockLength == 0)
{ {
sb.AppendFormat($"\t[slateblue1]{Localization._0_blocks_are_1_and_have_a_variable_length}[/]", sb
.AppendFormat($"\t[slateblue1]{Localization._0_blocks_are_1_and_have_a_variable_length}[/]",
$"[teal]{descriptor.Blocks}[/]", $"[teal]{descriptor.Blocks}[/]",
$"[fuchsia]{density}[/]") $"[fuchsia]{density}[/]")
.AppendLine(); .AppendLine();
@@ -1320,19 +1335,22 @@ public static partial class Modes
{ {
if(descriptor.BlockLength == 0) if(descriptor.BlockLength == 0)
{ {
sb.AppendFormat($"\t[slateblue1]{Localization.All_remaining_blocks_have_a_variable_length}[/]") sb
.AppendFormat($"\t[slateblue1]{Localization.All_remaining_blocks_have_a_variable_length}[/]")
.AppendLine(); .AppendLine();
} }
else else
{ {
sb.AppendFormat($"\t[slateblue1]{Localization.All_remaining_blocks_are_0_bytes_each}[/]", sb
.AppendFormat($"\t[slateblue1]{Localization.All_remaining_blocks_are_0_bytes_each}[/]",
$"[teal]{descriptor.BlockLength}[/]") $"[teal]{descriptor.BlockLength}[/]")
.AppendLine(); .AppendLine();
} }
} }
else if(descriptor.BlockLength == 0) else if(descriptor.BlockLength == 0)
{ {
sb.AppendFormat($"\t[slateblue1]{Localization._0_blocks_have_a_variable_length}[/]", $"[teal]{descriptor.Blocks}[/]") sb.AppendFormat($"\t[slateblue1]{Localization._0_blocks_have_a_variable_length}[/]",
$"[teal]{descriptor.Blocks}[/]")
.AppendLine(); .AppendLine();
} }
else else
@@ -1503,7 +1521,8 @@ public static partial class Modes
break; break;
default: default:
sb.AppendFormat(Localization.Unknown_medium_type_0, $"[teal]{(byte)header.Value.MediumType}[/]"); sb.AppendFormat(Localization.Unknown_medium_type_0,
$"[teal]{(byte)header.Value.MediumType}[/]");
break; break;
} }
@@ -1567,14 +1586,16 @@ public static partial class Modes
{ {
if(descriptor.Blocks == 0) if(descriptor.Blocks == 0)
{ {
sb.AppendFormat($"\t[slateblue1]{Localization.All_remaining_blocks_have_0_and_are_1_bytes_each}[/]", sb
.AppendFormat($"\t[slateblue1]{Localization.All_remaining_blocks_have_0_and_are_1_bytes_each}[/]",
$"[fuchsia]{density}[/]", $"[fuchsia]{density}[/]",
$"[teal]{descriptor.BlockLength}[/]") $"[teal]{descriptor.BlockLength}[/]")
.AppendLine(); .AppendLine();
} }
else else
{ {
sb.AppendFormat($"\t[slateblue1]{Localization._0_blocks_have_1_and_are_2_bytes_each}[/]", sb
.AppendFormat($"\t[slateblue1]{Localization._0_blocks_have_1_and_are_2_bytes_each}[/]",
$"[teal]{descriptor.Blocks}[/]", $"[teal]{descriptor.Blocks}[/]",
$"[fuchsia]{density}[/]", $"[fuchsia]{density}[/]",
$"[teal]{descriptor.BlockLength}[/]") $"[teal]{descriptor.BlockLength}[/]")

View File

@@ -59,9 +59,7 @@ public static class Dreamcast
IPBin ipbin = Marshal.ByteArrayToStructureLittleEndian<IPBin>(ipbin_sector); IPBin ipbin = Marshal.ByteArrayToStructureLittleEndian<IPBin>(ipbin_sector);
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME, "dreamcast_ipbin.maker_id = \"{0}\"", Encoding.ASCII.GetString(ipbin.maker_id));
"dreamcast_ipbin.maker_id = \"{0}\"",
Encoding.ASCII.GetString(ipbin.maker_id));
AaruLogging.Debug(MODULE_NAME, "dreamcast_ipbin.spare_space1 = \"{0}\"", (char)ipbin.spare_space1); AaruLogging.Debug(MODULE_NAME, "dreamcast_ipbin.spare_space1 = \"{0}\"", (char)ipbin.spare_space1);
@@ -71,9 +69,7 @@ public static class Dreamcast
AaruLogging.Debug(MODULE_NAME, "dreamcast_ipbin.disc_no = {0}", (char)ipbin.disc_no); AaruLogging.Debug(MODULE_NAME, "dreamcast_ipbin.disc_no = {0}", (char)ipbin.disc_no);
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME, "dreamcast_ipbin.disc_no_separator = \"{0}\"", (char)ipbin.disc_no_separator);
"dreamcast_ipbin.disc_no_separator = \"{0}\"",
(char)ipbin.disc_no_separator);
AaruLogging.Debug(MODULE_NAME, "dreamcast_ipbin.disc_total_nos = \"{0}\"", (char)ipbin.disc_total_nos); AaruLogging.Debug(MODULE_NAME, "dreamcast_ipbin.disc_total_nos = \"{0}\"", (char)ipbin.disc_total_nos);
@@ -107,9 +103,7 @@ public static class Dreamcast
"dreamcast_ipbin.boot_filename = \"{0}\"", "dreamcast_ipbin.boot_filename = \"{0}\"",
Encoding.ASCII.GetString(ipbin.boot_filename)); Encoding.ASCII.GetString(ipbin.boot_filename));
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME, "dreamcast_ipbin.producer = \"{0}\"", Encoding.ASCII.GetString(ipbin.producer));
"dreamcast_ipbin.producer = \"{0}\"",
Encoding.ASCII.GetString(ipbin.producer));
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
"dreamcast_ipbin.product_name = \"{0}\"", "dreamcast_ipbin.product_name = \"{0}\"",
@@ -199,7 +193,7 @@ public static class Dreamcast
} }
} }
int iPeripherals = int.Parse(Encoding.ASCII.GetString(ipbin.peripherals), NumberStyles.HexNumber); var iPeripherals = int.Parse(Encoding.ASCII.GetString(ipbin.peripherals), NumberStyles.HexNumber);
if((iPeripherals & 0x00000001) == 0x00000001) IPBinInformation.AppendLine(Localization.Game_uses_Windows_CE); if((iPeripherals & 0x00000001) == 0x00000001) IPBinInformation.AppendLine(Localization.Game_uses_Windows_CE);

View File

@@ -59,13 +59,9 @@ public static class Saturn
IPBin ipbin = Marshal.ByteArrayToStructureLittleEndian<IPBin>(ipbin_sector); IPBin ipbin = Marshal.ByteArrayToStructureLittleEndian<IPBin>(ipbin_sector);
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME, "saturn_ipbin.maker_id = \"{0}\"", Encoding.ASCII.GetString(ipbin.maker_id));
"saturn_ipbin.maker_id = \"{0}\"",
Encoding.ASCII.GetString(ipbin.maker_id));
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME, "saturn_ipbin.product_no = \"{0}\"", Encoding.ASCII.GetString(ipbin.product_no));
"saturn_ipbin.product_no = \"{0}\"",
Encoding.ASCII.GetString(ipbin.product_no));
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
"saturn_ipbin.product_version = \"{0}\"", "saturn_ipbin.product_version = \"{0}\"",
@@ -81,9 +77,7 @@ public static class Saturn
AaruLogging.Debug(MODULE_NAME, "saturn_ipbin.disc_no = {0}", (char)ipbin.disc_no); AaruLogging.Debug(MODULE_NAME, "saturn_ipbin.disc_no = {0}", (char)ipbin.disc_no);
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME, "saturn_ipbin.disc_no_separator = \"{0}\"", (char)ipbin.disc_no_separator);
"saturn_ipbin.disc_no_separator = \"{0}\"",
(char)ipbin.disc_no_separator);
AaruLogging.Debug(MODULE_NAME, "saturn_ipbin.disc_total_nos = {0}", (char)ipbin.disc_total_nos); AaruLogging.Debug(MODULE_NAME, "saturn_ipbin.disc_total_nos = {0}", (char)ipbin.disc_total_nos);

View File

@@ -206,7 +206,7 @@ public partial class Device
public bool Read(out byte[] buffer, out uint[] response, uint lba, uint blockSize, ushort transferLength, public bool Read(out byte[] buffer, out uint[] response, uint lba, uint blockSize, ushort transferLength,
bool byteAddressed, uint timeout, out double duration) bool byteAddressed, uint timeout, out double duration)
{ {
bool sense = true; var sense = true;
buffer = null; buffer = null;
response = null; response = null;
duration = -1; duration = -1;
@@ -342,9 +342,9 @@ public partial class Device
ushort transferLength, bool byteAddressed, uint timeout, out double duration) ushort transferLength, bool byteAddressed, uint timeout, out double duration)
{ {
buffer = new byte[transferLength * blockSize]; buffer = new byte[transferLength * blockSize];
byte[] blockBuffer = new byte[blockSize]; var blockBuffer = new byte[blockSize];
duration = 0; duration = 0;
bool sense = true; var sense = true;
response = null; response = null;
for(uint i = 0; i < transferLength; i++) for(uint i = 0; i < transferLength; i++)

View File

@@ -53,9 +53,7 @@ public sealed partial class ISO9660
while(off < data.Length) while(off < data.Length)
{ {
entry = Marshal.ByteArrayToStructureBigEndian<PathTableEntry>(data, entry = Marshal.ByteArrayToStructureBigEndian<PathTableEntry>(data, off, Marshal.SizeOf<PathTableEntry>());
off,
Marshal.SizeOf<PathTableEntry>());
if(entry.name_len == 0) break; if(entry.name_len == 0) break;
@@ -92,7 +90,9 @@ public sealed partial class ISO9660
HighSierraPathTableEntry entry = HighSierraPathTableEntry entry =
Marshal.ByteArrayToStructureBigEndian<HighSierraPathTableEntry>(data, Marshal.ByteArrayToStructureBigEndian<HighSierraPathTableEntry>(data,
off, off,
Marshal.SizeOf<HighSierraPathTableEntry>()); Marshal
.SizeOf<
HighSierraPathTableEntry>());
if(entry.name_len == 0) break; if(entry.name_len == 0) break;

View File

@@ -36,6 +36,5 @@ namespace Aaru.Filesystems;
public sealed partial class QNX4 public sealed partial class QNX4
{ {
const string FS_TYPE = "qnx4"; const string FS_TYPE = "qnx4";
readonly byte[] _rootDirFname = readonly byte[] _rootDirFname = "/\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"u8.ToArray();
"/\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"u8.ToArray();
} }

View File

@@ -36,6 +36,5 @@ public sealed partial class Reiser4
const string FS_TYPE = "reiser4"; const string FS_TYPE = "reiser4";
readonly byte[] _magic = readonly byte[] _magic = "ReIsEr4\0\0\0\0\0\0\0\0\0"u8.ToArray();
"ReIsEr4\0\0\0\0\0\0\0\0\0"u8.ToArray();
} }

View File

@@ -37,6 +37,5 @@ namespace Aaru.Filesystems;
public sealed partial class UDF public sealed partial class UDF
{ {
const string FS_TYPE = "udf"; const string FS_TYPE = "udf";
readonly byte[] _magic = readonly byte[] _magic = "*OSTA UDF Compliant\0\0\0\0"u8.ToArray();
"*OSTA UDF Compliant\0\0\0\0"u8.ToArray();
} }

View File

@@ -91,7 +91,7 @@ public static class DateHandlers
/// <returns>.NET DateTime</returns> /// <returns>.NET DateTime</returns>
public static DateTime HighSierraToDateTime(byte[] vdDateTime) public static DateTime HighSierraToDateTime(byte[] vdDateTime)
{ {
byte[] isoTime = new byte[17]; var isoTime = new byte[17];
Array.Copy(vdDateTime, 0, isoTime, 0, 16); Array.Copy(vdDateTime, 0, isoTime, 0, 16);
return Iso9660ToDateTime(isoTime); return Iso9660ToDateTime(isoTime);
@@ -103,8 +103,8 @@ public static class DateHandlers
/// <returns>.NET DateTime</returns> /// <returns>.NET DateTime</returns>
public static DateTime Iso9660ToDateTime(byte[] vdDateTime) public static DateTime Iso9660ToDateTime(byte[] vdDateTime)
{ {
byte[] twoCharValue = new byte[2]; var twoCharValue = new byte[2];
byte[] fourCharValue = new byte[4]; var fourCharValue = new byte[4];
fourCharValue[0] = vdDateTime[0]; fourCharValue[0] = vdDateTime[0];
fourCharValue[1] = vdDateTime[1]; fourCharValue[1] = vdDateTime[1];
@@ -129,9 +129,7 @@ public static class DateHandlers
twoCharValue[0] = vdDateTime[6]; twoCharValue[0] = vdDateTime[6];
twoCharValue[1] = vdDateTime[7]; twoCharValue[1] = vdDateTime[7];
AaruLogging.Debug(ISO9660_MODULE_NAME, AaruLogging.Debug(ISO9660_MODULE_NAME, "day = \"{0}\"", StringHandlers.CToString(twoCharValue, Encoding.ASCII));
"day = \"{0}\"",
StringHandlers.CToString(twoCharValue, Encoding.ASCII));
if(!int.TryParse(StringHandlers.CToString(twoCharValue, Encoding.ASCII), out int day)) day = 0; if(!int.TryParse(StringHandlers.CToString(twoCharValue, Encoding.ASCII), out int day)) day = 0;
@@ -181,7 +179,7 @@ public static class DateHandlers
second, second,
hundredths * 10); hundredths * 10);
sbyte difference = (sbyte)vdDateTime[16]; var difference = (sbyte)vdDateTime[16];
var decodedDt = new DateTime(year, month, day, hour, minute, second, hundredths * 10, DateTimeKind.Utc); var decodedDt = new DateTime(year, month, day, hour, minute, second, hundredths * 10, DateTimeKind.Utc);
@@ -277,7 +275,7 @@ public static class DateHandlers
/// <returns>.NET DateTime</returns> /// <returns>.NET DateTime</returns>
public static DateTime CpmToDateTime(byte[] timestamp) public static DateTime CpmToDateTime(byte[] timestamp)
{ {
ushort days = BitConverter.ToUInt16(timestamp, 0); var days = BitConverter.ToUInt16(timestamp, 0);
int hours = timestamp[2]; int hours = timestamp[2];
int minutes = timestamp[3]; int minutes = timestamp[3];
@@ -304,14 +302,14 @@ public static class DateHandlers
byte minute, byte second, byte centiseconds, byte hundredsOfMicroseconds, byte minute, byte second, byte centiseconds, byte hundredsOfMicroseconds,
byte microseconds) byte microseconds)
{ {
byte specification = (byte)((typeAndTimeZone & 0xF000) >> 12); var specification = (byte)((typeAndTimeZone & 0xF000) >> 12);
long ticks = (long)centiseconds * 100000 + (long)hundredsOfMicroseconds * 1000 + (long)microseconds * 10; long ticks = (long)centiseconds * 100000 + (long)hundredsOfMicroseconds * 1000 + (long)microseconds * 10;
if(specification == 0) if(specification == 0)
return new DateTime(year, month, day, hour, minute, second, DateTimeKind.Utc).AddTicks(ticks); return new DateTime(year, month, day, hour, minute, second, DateTimeKind.Utc).AddTicks(ticks);
ushort preOffset = (ushort)(typeAndTimeZone & 0xFFF); var preOffset = (ushort)(typeAndTimeZone & 0xFFF);
short offset; short offset;
if((preOffset & 0x800) == 0x800) if((preOffset & 0x800) == 0x800)

View File

@@ -54,16 +54,14 @@ public sealed partial class D88
if(stream.Length < Marshal.SizeOf<Header>()) return false; if(stream.Length < Marshal.SizeOf<Header>()) return false;
byte[] hdrB = new byte[Marshal.SizeOf<Header>()]; var hdrB = new byte[Marshal.SizeOf<Header>()];
stream.EnsureRead(hdrB, 0, hdrB.Length); stream.EnsureRead(hdrB, 0, hdrB.Length);
Header hdr = Marshal.ByteArrayToStructureLittleEndian<Header>(hdrB); Header hdr = Marshal.ByteArrayToStructureLittleEndian<Header>(hdrB);
AaruLogging.Debug(MODULE_NAME, "d88hdr.name = \"{0}\"", StringHandlers.CToString(hdr.name, shiftjis)); AaruLogging.Debug(MODULE_NAME, "d88hdr.name = \"{0}\"", StringHandlers.CToString(hdr.name, shiftjis));
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME, "d88hdr.reserved is empty? = {0}", hdr.reserved.SequenceEqual(_reservedEmpty));
"d88hdr.reserved is empty? = {0}",
hdr.reserved.SequenceEqual(_reservedEmpty));
AaruLogging.Debug(MODULE_NAME, "d88hdr.write_protect = 0x{0:X2}", hdr.write_protect); AaruLogging.Debug(MODULE_NAME, "d88hdr.write_protect = 0x{0:X2}", hdr.write_protect);
@@ -77,7 +75,7 @@ public sealed partial class D88
if(!hdr.reserved.SequenceEqual(_reservedEmpty)) return false; if(!hdr.reserved.SequenceEqual(_reservedEmpty)) return false;
int counter = 0; var counter = 0;
foreach(int t in hdr.track_table) foreach(int t in hdr.track_table)
{ {

View File

@@ -48,8 +48,8 @@ public sealed partial class DiskCopy42
{ {
Stream stream = imageFilter.GetDataForkStream(); Stream stream = imageFilter.GetDataForkStream();
stream.Seek(0, SeekOrigin.Begin); stream.Seek(0, SeekOrigin.Begin);
byte[] buffer = new byte[0x58]; var buffer = new byte[0x58];
byte[] pString = new byte[64]; var pString = new byte[64];
stream.EnsureRead(buffer, 0, 0x58); stream.EnsureRead(buffer, 0, 0x58);
// Incorrect pascal string length, not DC42 // Incorrect pascal string length, not DC42
@@ -103,9 +103,7 @@ public sealed partial class DiskCopy42
tmpHeader.Format != kSigmaFormatTwiggy && tmpHeader.Format != kSigmaFormatTwiggy &&
tmpHeader.Format != kNotStandardFormat) tmpHeader.Format != kNotStandardFormat)
{ {
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME, Localization.Unknown_tmp_header_format_equals_0_value, tmpHeader.Format);
Localization.Unknown_tmp_header_format_equals_0_value,
tmpHeader.Format);
return false; return false;
} }
@@ -119,9 +117,7 @@ public sealed partial class DiskCopy42
tmpHeader.FmtByte != kFmtNotStandard && tmpHeader.FmtByte != kFmtNotStandard &&
tmpHeader.FmtByte != kMacOSXFmtByte) tmpHeader.FmtByte != kMacOSXFmtByte)
{ {
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME, Localization.Unknown_tmp_header_fmtByte_equals_0_value, tmpHeader.FmtByte);
Localization.Unknown_tmp_header_fmtByte_equals_0_value,
tmpHeader.FmtByte);
return false; return false;
} }

View File

@@ -42,7 +42,7 @@ public sealed partial class DiskDupe
{ {
bool TryReadHeader(Stream stream, ref FileHeader fhdr, ref TrackInfo[] tmap, ref long[] toffsets) bool TryReadHeader(Stream stream, ref FileHeader fhdr, ref TrackInfo[] tmap, ref long[] toffsets)
{ {
byte[] buffer = new byte[6]; var buffer = new byte[6];
FileHeader fHeader; FileHeader fHeader;
stream.Seek(0, SeekOrigin.Begin); stream.Seek(0, SeekOrigin.Begin);
@@ -65,7 +65,7 @@ public sealed partial class DiskDupe
int numTracks = _diskTypes[fHeader.diskType].cyl * _diskTypes[fHeader.diskType].hd; int numTracks = _diskTypes[fHeader.diskType].cyl * _diskTypes[fHeader.diskType].hd;
int trackLen = 512 * _diskTypes[fHeader.diskType].spt; // the length of a single track, in bytes int trackLen = 512 * _diskTypes[fHeader.diskType].spt; // the length of a single track, in bytes
var trackMap = new TrackInfo[numTracks]; var trackMap = new TrackInfo[numTracks];
long[] trackOffsets = new long[numTracks]; var trackOffsets = new long[numTracks];
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization.Identified_image_with_CHS_equals_0_1_2, Localization.Identified_image_with_CHS_equals_0_1_2,
@@ -74,7 +74,7 @@ public sealed partial class DiskDupe
_diskTypes[fHeader.diskType].spt); _diskTypes[fHeader.diskType].spt);
// read the trackmap and store the track offsets // read the trackmap and store the track offsets
for(int i = 0; i < numTracks; i++) for(var i = 0; i < numTracks; i++)
{ {
stream.EnsureRead(buffer, 0, 6); stream.EnsureRead(buffer, 0, 6);
trackMap[i] = Marshal.ByteArrayToStructureLittleEndian<TrackInfo>(buffer); trackMap[i] = Marshal.ByteArrayToStructureLittleEndian<TrackInfo>(buffer);

View File

@@ -34,6 +34,5 @@ namespace Aaru.Images;
public sealed partial class Nhdr0 public sealed partial class Nhdr0
{ {
readonly byte[] _signature = readonly byte[] _signature = "T98HDDIMAGE.R0\0"u8.ToArray();
"T98HDDIMAGE.R0\0"u8.ToArray();
} }

View File

@@ -54,7 +54,7 @@ public sealed partial class Nhdr0
if(stream.Length < Marshal.SizeOf<Header>()) return false; if(stream.Length < Marshal.SizeOf<Header>()) return false;
byte[] hdrB = new byte[Marshal.SizeOf<Header>()]; var hdrB = new byte[Marshal.SizeOf<Header>()];
stream.EnsureRead(hdrB, 0, hdrB.Length); stream.EnsureRead(hdrB, 0, hdrB.Length);
_nhdhdr = Marshal.ByteArrayToStructureLittleEndian<Header>(hdrB); _nhdhdr = Marshal.ByteArrayToStructureLittleEndian<Header>(hdrB);

View File

@@ -66,6 +66,5 @@ public sealed partial class Partimage
const string MAGIC_BEGIN_VOLUME = "PaRtImAgE-VoLuMe"; const string MAGIC_BEGIN_VOLUME = "PaRtImAgE-VoLuMe";
const uint MAX_CACHE_SIZE = 16777216; const uint MAX_CACHE_SIZE = 16777216;
const uint MAX_CACHED_SECTORS = MAX_CACHE_SIZE / 512; const uint MAX_CACHED_SECTORS = MAX_CACHE_SIZE / 512;
readonly byte[] _partimageMagic = readonly byte[] _partimageMagic = "PaRtImAgE-VoLuMe\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"u8.ToArray();
"PaRtImAgE-VoLuMe\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"u8.ToArray();
} }

View File

@@ -42,22 +42,22 @@ public sealed partial class TeleDisk
{ {
(ushort cylinder, byte head, byte sector) LbaToChs(ulong lba) (ushort cylinder, byte head, byte sector) LbaToChs(ulong lba)
{ {
ushort cylinder = (ushort)(lba / (_imageInfo.Heads * _imageInfo.SectorsPerTrack)); var cylinder = (ushort)(lba / (_imageInfo.Heads * _imageInfo.SectorsPerTrack));
byte head = (byte)(lba / _imageInfo.SectorsPerTrack % _imageInfo.Heads); var head = (byte)(lba / _imageInfo.SectorsPerTrack % _imageInfo.Heads);
byte sector = (byte)(lba % _imageInfo.SectorsPerTrack + 1); var sector = (byte)(lba % _imageInfo.SectorsPerTrack + 1);
return (cylinder, head, sector); return (cylinder, head, sector);
} }
static ushort TeleDiskCrc(ushort crc, byte[] buffer) static ushort TeleDiskCrc(ushort crc, byte[] buffer)
{ {
int counter = 0; var counter = 0;
while(counter < buffer.Length) while(counter < buffer.Length)
{ {
crc ^= (ushort)((buffer[counter] & 0xFF) << 8); crc ^= (ushort)((buffer[counter] & 0xFF) << 8);
for(int i = 0; i < 8; i++) for(var i = 0; i < 8; i++)
{ {
if((crc & 0x8000) > 0) if((crc & 0x8000) > 0)
crc = (ushort)(crc << 1 ^ TELE_DISK_CRC_POLY); crc = (ushort)(crc << 1 ^ TELE_DISK_CRC_POLY);
@@ -120,16 +120,16 @@ public sealed partial class TeleDisk
break; break;
case DATA_BLOCK_PATTERN: case DATA_BLOCK_PATTERN:
{ {
int ins = 0; var ins = 0;
int outs = 0; var outs = 0;
while(ins < encodedData.Length) while(ins < encodedData.Length)
{ {
byte[] repeatValue = new byte[2]; var repeatValue = new byte[2];
ushort repeatNumber = BitConverter.ToUInt16(encodedData, ins); var repeatNumber = BitConverter.ToUInt16(encodedData, ins);
Array.Copy(encodedData, ins + 2, repeatValue, 0, 2); Array.Copy(encodedData, ins + 2, repeatValue, 0, 2);
byte[] decodedPiece = new byte[repeatNumber * 2]; var decodedPiece = new byte[repeatNumber * 2];
ArrayHelpers.ArrayFill(decodedPiece, repeatValue); ArrayHelpers.ArrayFill(decodedPiece, repeatValue);
Array.Copy(decodedPiece, 0, decodedData, outs, decodedPiece.Length); Array.Copy(decodedPiece, 0, decodedData, outs, decodedPiece.Length);
ins += 4; ins += 4;
@@ -140,24 +140,20 @@ public sealed partial class TeleDisk
Localization.Block_pattern_decoder_Input_data_size_0_bytes, Localization.Block_pattern_decoder_Input_data_size_0_bytes,
encodedData.Length); encodedData.Length);
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME, Localization.Block_pattern_decoder_Processed_input_0_bytes, ins);
Localization.Block_pattern_decoder_Processed_input_0_bytes,
ins);
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization.Block_pattern_decoder_Output_data_size_0_bytes, Localization.Block_pattern_decoder_Output_data_size_0_bytes,
decodedData.Length); decodedData.Length);
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME, Localization.Block_pattern_decoder_Processed_Output_0_bytes, outs);
Localization.Block_pattern_decoder_Processed_Output_0_bytes,
outs);
break; break;
} }
case DATA_BLOCK_RLE: case DATA_BLOCK_RLE:
{ {
int ins = 0; var ins = 0;
int outs = 0; var outs = 0;
while(ins < encodedData.Length) while(ins < encodedData.Length)
{ {
@@ -176,9 +172,9 @@ public sealed partial class TeleDisk
{ {
length = (byte)(encoding * 2); length = (byte)(encoding * 2);
byte run = encodedData[ins + 1]; byte run = encodedData[ins + 1];
byte[] part = new byte[length]; var part = new byte[length];
Array.Copy(encodedData, ins + 2, part, 0, length); Array.Copy(encodedData, ins + 2, part, 0, length);
byte[] piece = new byte[length * run]; var piece = new byte[length * run];
ArrayHelpers.ArrayFill(piece, part); ArrayHelpers.ArrayFill(piece, part);
Array.Copy(piece, 0, decodedData, outs, piece.Length); Array.Copy(piece, 0, decodedData, outs, piece.Length);
ins += 2 + length; ins += 2 + length;
@@ -186,15 +182,11 @@ public sealed partial class TeleDisk
} }
} }
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME, Localization.RLE_decoder_Input_data_size_0_bytes, encodedData.Length);
Localization.RLE_decoder_Input_data_size_0_bytes,
encodedData.Length);
AaruLogging.Debug(MODULE_NAME, Localization.RLE_decoder_Processed_input_0_bytes, ins); AaruLogging.Debug(MODULE_NAME, Localization.RLE_decoder_Processed_input_0_bytes, ins);
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME, Localization.RLE_decoder_Output_data_size_0_bytes, decodedData.Length);
Localization.RLE_decoder_Output_data_size_0_bytes,
decodedData.Length);
AaruLogging.Debug(MODULE_NAME, Localization.RLE_decoder_Processed_Output_0_bytes, outs); AaruLogging.Debug(MODULE_NAME, Localization.RLE_decoder_Processed_Output_0_bytes, outs);

View File

@@ -54,7 +54,7 @@ public sealed partial class Virtual98
if(stream.Length < Marshal.SizeOf<Virtual98Header>()) return false; if(stream.Length < Marshal.SizeOf<Virtual98Header>()) return false;
byte[] hdrB = new byte[Marshal.SizeOf<Virtual98Header>()]; var hdrB = new byte[Marshal.SizeOf<Virtual98Header>()];
stream.EnsureRead(hdrB, 0, hdrB.Length); stream.EnsureRead(hdrB, 0, hdrB.Length);
_v98Hdr = Marshal.ByteArrayToStructureLittleEndian<Virtual98Header>(hdrB); _v98Hdr = Marshal.ByteArrayToStructureLittleEndian<Virtual98Header>(hdrB);
@@ -65,9 +65,7 @@ public sealed partial class Virtual98
"v98hdr.signature = \"{0}\"", "v98hdr.signature = \"{0}\"",
StringHandlers.CToString(_v98Hdr.signature, shiftjis)); StringHandlers.CToString(_v98Hdr.signature, shiftjis));
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME, "v98hdr.comment = \"{0}\"", StringHandlers.CToString(_v98Hdr.comment, shiftjis));
"v98hdr.comment = \"{0}\"",
StringHandlers.CToString(_v98Hdr.comment, shiftjis));
AaruLogging.Debug(MODULE_NAME, "v98hdr.padding = {0}", _v98Hdr.padding); AaruLogging.Debug(MODULE_NAME, "v98hdr.padding = {0}", _v98Hdr.padding);
AaruLogging.Debug(MODULE_NAME, "v98hdr.mbsize = {0}", _v98Hdr.mbsize); AaruLogging.Debug(MODULE_NAME, "v98hdr.mbsize = {0}", _v98Hdr.mbsize);