mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
REFACTOR: All refactor in DiscImageChef.Decoders.
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user