REFACTOR: All refactor in DiscImageChef.Decoders.

This commit is contained in:
2017-12-22 02:04:18 +00:00
parent 7f829422a8
commit 49144eeb01
148 changed files with 2606 additions and 1939 deletions

View File

@@ -31,10 +31,15 @@
// ****************************************************************************/
using System;
using System.Diagnostics.CodeAnalysis;
using System.Text;
namespace DiscImageChef.Decoders.MMC
{
[SuppressMessage("ReSharper", "InconsistentNaming")]
[SuppressMessage("ReSharper", "MemberCanBeInternal")]
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
[SuppressMessage("ReSharper", "NotAccessedField.Global")]
public class OCR
{
public bool PowerUp;
@@ -58,42 +63,40 @@ namespace DiscImageChef.Decoders.MMC
public bool OneSix;
}
public partial class Decoders
[SuppressMessage("ReSharper", "InconsistentNaming")]
[SuppressMessage("ReSharper", "MemberCanBeInternal")]
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
public static partial class Decoders
{
public static OCR DecodeOCR(uint response)
{
OCR ocr = new OCR();
ocr.PowerUp = (response & 0x80000000) == 0x80000000;
ocr.AccessMode = (byte)((response & 0x60000000) >> 29);
ocr.ThreeFive = (response & 0x00800000) == 0x00800000;
ocr.ThreeFour = (response & 0x00400000) == 0x00400000;
ocr.ThreeThree = (response & 0x00200000) == 0x00200000;
ocr.ThreeTwo = (response & 0x00100000) == 0x00100000;
ocr.ThreeOne = (response & 0x00080000) == 0x00080000;
ocr.ThreeZero = (response & 0x00040000) == 0x00040000;
ocr.TwoNine = (response & 0x00020000) == 0x00020000;
ocr.TwoEight = (response & 0x00010000) == 0x00010000;
ocr.TwoSeven = (response & 0x00008000) == 0x00008000;
ocr.TwoSix = (response & 0x00004000) == 0x00004000;
ocr.TwoFive = (response & 0x00002000) == 0x00002000;
ocr.TwoFour = (response & 0x00001000) == 0x00001000;
ocr.TwoThree = (response & 0x00000800) == 0x00000800;
ocr.TwoTwo = (response & 0x00000400) == 0x00000400;
ocr.TwoOne = (response & 0x00000200) == 0x00000200;
ocr.TwoZero = (response & 0x00000100) == 0x00000100;
ocr.OneSix = (response & 0x00000080) == 0x00000080;
return ocr;
return new OCR
{
PowerUp = (response & 0x80000000) == 0x80000000,
AccessMode = (byte)((response & 0x60000000) >> 29),
ThreeFive = (response & 0x00800000) == 0x00800000,
ThreeFour = (response & 0x00400000) == 0x00400000,
ThreeThree = (response & 0x00200000) == 0x00200000,
ThreeTwo = (response & 0x00100000) == 0x00100000,
ThreeOne = (response & 0x00080000) == 0x00080000,
ThreeZero = (response & 0x00040000) == 0x00040000,
TwoNine = (response & 0x00020000) == 0x00020000,
TwoEight = (response & 0x00010000) == 0x00010000,
TwoSeven = (response & 0x00008000) == 0x00008000,
TwoSix = (response & 0x00004000) == 0x00004000,
TwoFive = (response & 0x00002000) == 0x00002000,
TwoFour = (response & 0x00001000) == 0x00001000,
TwoThree = (response & 0x00000800) == 0x00000800,
TwoTwo = (response & 0x00000400) == 0x00000400,
TwoOne = (response & 0x00000200) == 0x00000200,
TwoZero = (response & 0x00000100) == 0x00000100,
OneSix = (response & 0x00000080) == 0x00000080
};
}
public static OCR DecodeOCR(byte[] response)
{
if(response == null) return null;
if(response.Length != 4) return null;
return DecodeOCR(BitConverter.ToUInt32(response, 0));
return response?.Length != 4 ? null : DecodeOCR(BitConverter.ToUInt32(response, 0));
}
public static string PrettifyOCR(OCR ocr)