mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
General cleanup and refactor.
This commit is contained in:
@@ -30,11 +30,11 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.Decoders.Floppy;
|
||||
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Aaru.Decoders.Floppy;
|
||||
|
||||
/// <summary>Methods and structures for Commodore Amiga decoding</summary>
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"),
|
||||
SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.Decoders.Floppy;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
@@ -38,8 +40,6 @@ using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using Aaru.Console;
|
||||
|
||||
namespace Aaru.Decoders.Floppy;
|
||||
|
||||
/// <summary>Methods and structures for Apple ][ floppy decoding</summary>
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"),
|
||||
SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
||||
@@ -155,29 +155,29 @@ public static class Apple2
|
||||
data.Length != 410)
|
||||
return null;
|
||||
|
||||
byte[] buffer = new byte[data.Length];
|
||||
byte carry = 0;
|
||||
var buffer = new byte[data.Length];
|
||||
byte carry = 0;
|
||||
|
||||
for(int i = 0; i < data.Length; i++)
|
||||
for(var i = 0; i < data.Length; i++)
|
||||
{
|
||||
carry ^= ReadTable5and3[data[i]];
|
||||
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 b2 = buffer[(51 * 2) - i];
|
||||
byte b1 = buffer[51 * 3 - i];
|
||||
byte b2 = buffer[51 * 2 - i];
|
||||
byte b3 = buffer[51 - i];
|
||||
byte b4 = (byte)((((b1 & 2) << 1) | (b2 & 2) | ((b3 & 2) >> 1)) & 0xFF);
|
||||
byte 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[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[253 - (5 * i)] = (byte)(((buffer[i + (51 * 6) + 1] << 3) | b4) & 0xFF);
|
||||
output[254 - (5 * i)] = (byte)(((buffer[i + (51 * 7) + 1] << 3) | b5) & 0xFF);
|
||||
var b4 = (byte)((((b1 & 2) << 1) | (b2 & 2) | ((b3 & 2) >> 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[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[253 - 5 * i] = (byte)(((buffer[i + 51 * 6 + 1] << 3) | b4) & 0xFF);
|
||||
output[254 - 5 * i] = (byte)(((buffer[i + 51 * 7 + 1] << 3) | b5) & 0xFF);
|
||||
}
|
||||
|
||||
output[255] = (byte)(((buffer[409] << 3) | (buffer[0] & 0x7)) & 0xFF);
|
||||
@@ -193,16 +193,16 @@ public static class Apple2
|
||||
data.Length != 342)
|
||||
return null;
|
||||
|
||||
byte[] buffer = new byte[data.Length];
|
||||
byte carry = 0;
|
||||
var buffer = new byte[data.Length];
|
||||
byte carry = 0;
|
||||
|
||||
for(int i = 0; i < data.Length; i++)
|
||||
for(var i = 0; i < data.Length; i++)
|
||||
{
|
||||
carry ^= ReadTable6and2[data[i]];
|
||||
buffer[i] = carry;
|
||||
}
|
||||
|
||||
byte[] output = new byte[256];
|
||||
var output = new byte[256];
|
||||
|
||||
for(uint i = 0; i < 256; i++)
|
||||
{
|
||||
@@ -220,8 +220,8 @@ public static class Apple2
|
||||
}
|
||||
else
|
||||
{
|
||||
output[i] |= (byte)(((buffer[i - (86 * 2)] & 0x10) >> 3) & 0xFF);
|
||||
output[i] |= (byte)(((buffer[i - (86 * 2)] & 0x20) >> 5) & 0xFF);
|
||||
output[i] |= (byte)(((buffer[i - 86 * 2] & 0x10) >> 3) & 0xFF);
|
||||
output[i] |= (byte)(((buffer[i - 86 * 2] & 0x20) >> 5) & 0xFF);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -326,9 +326,9 @@ public static class Apple2
|
||||
sector.addressField.epilogue[2]);
|
||||
|
||||
position += 14;
|
||||
int syncCount = 0;
|
||||
bool onSync = false;
|
||||
var gaps = new MemoryStream();
|
||||
var syncCount = 0;
|
||||
var onSync = false;
|
||||
var gaps = new MemoryStream();
|
||||
|
||||
while(data[position] == 0xFF)
|
||||
{
|
||||
@@ -471,13 +471,13 @@ public static class Apple2
|
||||
|
||||
public static RawTrack MarshalTrack(byte[] data, out int endOffset, int offset = 0)
|
||||
{
|
||||
int position = offset;
|
||||
bool firstSector = true;
|
||||
bool onSync = false;
|
||||
var gaps = new MemoryStream();
|
||||
int count = 0;
|
||||
List<RawSector> sectors = new List<RawSector>();
|
||||
byte[] trackNumber = new byte[2];
|
||||
int position = offset;
|
||||
var firstSector = true;
|
||||
var onSync = false;
|
||||
var gaps = new MemoryStream();
|
||||
var count = 0;
|
||||
var sectors = new List<RawSector>();
|
||||
var trackNumber = new byte[2];
|
||||
endOffset = offset;
|
||||
|
||||
while(position < data.Length &&
|
||||
@@ -560,8 +560,8 @@ public static class Apple2
|
||||
public static List<RawTrack> MarshalDisk(byte[] data, out int endOffset, int offset = 0)
|
||||
{
|
||||
endOffset = offset;
|
||||
List<RawTrack> tracks = new List<RawTrack>();
|
||||
int position = offset;
|
||||
var tracks = new List<RawTrack>();
|
||||
int position = offset;
|
||||
|
||||
RawTrack track = MarshalTrack(data, out position, position);
|
||||
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.Decoders.Floppy;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
@@ -37,7 +39,6 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Aaru.Decoders.Floppy;
|
||||
// Information from:
|
||||
// Inside Macintosh, Volume II, ISBN 0-201-17732-3
|
||||
|
||||
@@ -53,16 +54,16 @@ public static class AppleSony
|
||||
sector.addressField.prologue[2] != 0x96)
|
||||
return null;
|
||||
|
||||
byte[] bf1 = new byte[175];
|
||||
byte[] bf2 = new byte[175];
|
||||
byte[] bf3 = new byte[175];
|
||||
var bf1 = new byte[175];
|
||||
var bf2 = new byte[175];
|
||||
var bf3 = new byte[175];
|
||||
byte[] nib_data = sector.dataField.data;
|
||||
var ms = new MemoryStream();
|
||||
|
||||
int j = 0;
|
||||
var j = 0;
|
||||
byte w3 = 0;
|
||||
|
||||
for(int i = 0; i <= 174; i++)
|
||||
for(var i = 0; i <= 174; i++)
|
||||
{
|
||||
byte w4 = nib_data[j++];
|
||||
byte w1 = nib_data[j++];
|
||||
@@ -88,7 +89,7 @@ public static class AppleSony
|
||||
if((ck1 & 0x0100) > 0)
|
||||
ck1++;
|
||||
|
||||
byte carry = (byte)((bf1[j] ^ ck1) & 0xFF);
|
||||
var carry = (byte)((bf1[j] ^ ck1) & 0xFF);
|
||||
ck3 += carry;
|
||||
|
||||
if((ck1 & 0x0100) > 0)
|
||||
@@ -179,9 +180,9 @@ public static class AppleSony
|
||||
};
|
||||
|
||||
position += 10;
|
||||
int syncCount = 0;
|
||||
bool onSync = false;
|
||||
var gaps = new MemoryStream();
|
||||
var syncCount = 0;
|
||||
var onSync = false;
|
||||
var gaps = new MemoryStream();
|
||||
|
||||
while(data[position] == 0xFF)
|
||||
{
|
||||
@@ -323,14 +324,14 @@ public static class AppleSony
|
||||
|
||||
public static RawTrack MarshalTrack(byte[] data, out int endOffset, int offset = 0)
|
||||
{
|
||||
int position = offset;
|
||||
bool firstSector = true;
|
||||
bool onSync = false;
|
||||
var gaps = new MemoryStream();
|
||||
int count = 0;
|
||||
List<RawSector> sectors = new List<RawSector>();
|
||||
byte trackNumber = 0;
|
||||
byte sideNumber = 0;
|
||||
int position = offset;
|
||||
var firstSector = true;
|
||||
var onSync = false;
|
||||
var gaps = new MemoryStream();
|
||||
var count = 0;
|
||||
var sectors = new List<RawSector>();
|
||||
byte trackNumber = 0;
|
||||
byte sideNumber = 0;
|
||||
endOffset = offset;
|
||||
|
||||
while(position < data.Length &&
|
||||
@@ -407,8 +408,8 @@ public static class AppleSony
|
||||
public static List<RawTrack> MarshalDisk(byte[] data, out int endOffset, int offset = 0)
|
||||
{
|
||||
endOffset = offset;
|
||||
List<RawTrack> tracks = new List<RawTrack>();
|
||||
int position = offset;
|
||||
var tracks = new List<RawTrack>();
|
||||
int position = offset;
|
||||
|
||||
RawTrack track = MarshalTrack(data, out position, position);
|
||||
|
||||
|
||||
@@ -30,11 +30,11 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.Decoders.Floppy;
|
||||
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Aaru.Decoders.Floppy;
|
||||
|
||||
/// <summary>Methods and structures for Commodore GCR floppy decoding</summary>
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"),
|
||||
SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
||||
|
||||
@@ -30,10 +30,10 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace Aaru.Decoders.Floppy;
|
||||
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
/// <summary>In-sector code for sector size</summary>
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public enum IBMSectorSizeCode : byte
|
||||
@@ -59,7 +59,9 @@ public enum IBMSectorSizeCode : byte
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public enum IBMIdType : byte
|
||||
{
|
||||
IndexMark = 0xFC, AddressMark = 0xFE, DataMark = 0xFB,
|
||||
IndexMark = 0xFC,
|
||||
AddressMark = 0xFE,
|
||||
DataMark = 0xFB,
|
||||
DeletedDataMark = 0xF8
|
||||
}
|
||||
|
||||
|
||||
@@ -30,10 +30,11 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.Decoders.Floppy;
|
||||
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Aaru.Decoders.Floppy;
|
||||
// Information from:
|
||||
// National Semiconductor PC87332VLJ datasheet
|
||||
// SMsC FDC37C78 datasheet
|
||||
|
||||
@@ -30,10 +30,11 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.Decoders.Floppy;
|
||||
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Aaru.Decoders.Floppy;
|
||||
// Information from:
|
||||
// National Semiconductor PC87332VLJ datasheet
|
||||
// SMsC FDC37C78 datasheet
|
||||
|
||||
@@ -30,10 +30,11 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.Decoders.Floppy;
|
||||
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Aaru.Decoders.Floppy;
|
||||
// Information from:
|
||||
// National Semiconductor PC87332VLJ datasheet
|
||||
// SMsC FDC37C78 datasheet
|
||||
|
||||
@@ -30,10 +30,11 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.Decoders.Floppy;
|
||||
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Aaru.Decoders.Floppy;
|
||||
// Information from:
|
||||
// National Semiconductor PC87332VLJ datasheet
|
||||
// SMsC FDC37C78 datasheet
|
||||
|
||||
Reference in New Issue
Block a user