Virtu core - remove SupressMessage attributes, also change tabs to spaces in files I touched

This commit is contained in:
adelikat 2015-05-20 01:28:50 +00:00
parent edbb7508b5
commit f5daee2623
5 changed files with 5407 additions and 4977 deletions

File diff suppressed because it is too large Load Diff

View File

@ -8,236 +8,249 @@ using System.Collections.Generic;
namespace Jellyfish.Virtu
{
public sealed class DiskIIController : PeripheralCard
{
public sealed class DiskIIController : PeripheralCard
{
public DiskIIController() { }
public DiskIIController(Machine machine, byte[] diskIIRom) :
base(machine)
{
public DiskIIController(Machine machine, byte[] diskIIRom) :
base(machine)
{
_romRegionC1C7 = diskIIRom;
Drive1 = new DiskIIDrive(machine);
Drive2 = new DiskIIDrive(machine);
Drive2 = new DiskIIDrive(machine);
Drives = new List<DiskIIDrive> { Drive1, Drive2 };
Drives = new List<DiskIIDrive> { Drive1, Drive2 };
BootDrive = Drive1;
}
BootDrive = Drive1;
}
public override void Initialize() { }
public override void Initialize() { }
public override void Reset()
{
_phaseStates = 0;
SetMotorOn(false);
SetDriveNumber(0);
_loadMode = false;
_writeMode = false;
}
public override void Reset()
{
_phaseStates = 0;
SetMotorOn(false);
SetDriveNumber(0);
_loadMode = false;
_writeMode = false;
}
[SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
public override int ReadIoRegionC0C0(int address)
{
switch (address & 0xF)
{
case 0x0: case 0x1: case 0x2: case 0x3: case 0x4: case 0x5: case 0x6: case 0x7:
SetPhase(address);
break;
public override int ReadIoRegionC0C0(int address)
{
switch (address & 0xF)
{
case 0x0:
case 0x1:
case 0x2:
case 0x3:
case 0x4:
case 0x5:
case 0x6:
case 0x7:
SetPhase(address);
break;
case 0x8:
SetMotorOn(false);
break;
case 0x8:
SetMotorOn(false);
break;
case 0x9:
SetMotorOn(true);
break;
case 0x9:
SetMotorOn(true);
break;
case 0xA:
SetDriveNumber(0);
break;
case 0xA:
SetDriveNumber(0);
break;
case 0xB:
SetDriveNumber(1);
break;
case 0xB:
SetDriveNumber(1);
break;
case 0xC:
_loadMode = false;
if (_motorOn)
{
if (!_writeMode)
{
return _latch = Drives[_driveNumber].Read();
}
else
{
WriteLatch();
}
}
break;
case 0xC:
_loadMode = false;
if (_motorOn)
{
if (!_writeMode)
{
return _latch = Drives[_driveNumber].Read();
}
else
{
WriteLatch();
}
}
break;
case 0xD:
_loadMode = true;
if (_motorOn && !_writeMode)
{
// write protect is forced if phase 1 is on [F9.7]
_latch &= 0x7F;
if (Drives[_driveNumber].IsWriteProtected ||
(_phaseStates & Phase1On) != 0)
{
_latch |= 0x80;
}
}
break;
case 0xD:
_loadMode = true;
if (_motorOn && !_writeMode)
{
// write protect is forced if phase 1 is on [F9.7]
_latch &= 0x7F;
if (Drives[_driveNumber].IsWriteProtected ||
(_phaseStates & Phase1On) != 0)
{
_latch |= 0x80;
}
}
break;
case 0xE:
_writeMode = false;
break;
case 0xE:
_writeMode = false;
break;
case 0xF:
_writeMode = true;
break;
}
case 0xF:
_writeMode = true;
break;
}
if ((address & 1) == 0)
{
// only even addresses return the latch
if (_motorOn)
{
return _latch;
}
if ((address & 1) == 0)
{
// only even addresses return the latch
if (_motorOn)
{
return _latch;
}
// simple hack to fool DOS SAMESLOT drive spin check (usually at $BD34)
_driveSpin = !_driveSpin;
return _driveSpin ? 0x7E : 0x7F;
}
// simple hack to fool DOS SAMESLOT drive spin check (usually at $BD34)
_driveSpin = !_driveSpin;
return _driveSpin ? 0x7E : 0x7F;
}
return ReadFloatingBus();
}
return ReadFloatingBus();
}
public override int ReadIoRegionC1C7(int address)
{
return _romRegionC1C7[address & 0xFF];
}
public override int ReadIoRegionC1C7(int address)
{
return _romRegionC1C7[address & 0xFF];
}
public override void WriteIoRegionC0C0(int address, int data)
{
switch (address & 0xF)
{
case 0x0: case 0x1: case 0x2: case 0x3: case 0x4: case 0x5: case 0x6: case 0x7:
SetPhase(address);
break;
public override void WriteIoRegionC0C0(int address, int data)
{
switch (address & 0xF)
{
case 0x0:
case 0x1:
case 0x2:
case 0x3:
case 0x4:
case 0x5:
case 0x6:
case 0x7:
SetPhase(address);
break;
case 0x8:
SetMotorOn(false);
break;
case 0x8:
SetMotorOn(false);
break;
case 0x9:
SetMotorOn(true);
break;
case 0x9:
SetMotorOn(true);
break;
case 0xA:
SetDriveNumber(0);
break;
case 0xA:
SetDriveNumber(0);
break;
case 0xB:
SetDriveNumber(1);
break;
case 0xB:
SetDriveNumber(1);
break;
case 0xC:
_loadMode = false;
if (_writeMode)
{
WriteLatch();
}
break;
case 0xC:
_loadMode = false;
if (_writeMode)
{
WriteLatch();
}
break;
case 0xD:
_loadMode = true;
break;
case 0xD:
_loadMode = true;
break;
case 0xE:
_writeMode = false;
break;
case 0xE:
_writeMode = false;
break;
case 0xF:
_writeMode = true;
break;
}
case 0xF:
_writeMode = true;
break;
}
if (_motorOn && _writeMode)
{
if (_loadMode)
{
// any address writes latch for sequencer LD; OE1/2 irrelevant ['323 datasheet]
_latch = data;
}
}
}
if (_motorOn && _writeMode)
{
if (_loadMode)
{
// any address writes latch for sequencer LD; OE1/2 irrelevant ['323 datasheet]
_latch = data;
}
}
}
private void WriteLatch()
{
// write protect is forced if phase 1 is on [F9.7]
if ((_phaseStates & Phase1On) == 0)
{
Drives[_driveNumber].Write(_latch);
}
}
private void WriteLatch()
{
// write protect is forced if phase 1 is on [F9.7]
if ((_phaseStates & Phase1On) == 0)
{
Drives[_driveNumber].Write(_latch);
}
}
private void Flush()
{
Drives[_driveNumber].FlushTrack();
}
private void Flush()
{
Drives[_driveNumber].FlushTrack();
}
private void SetDriveNumber(int driveNumber)
{
if (_driveNumber != driveNumber)
{
Flush();
_driveNumber = driveNumber;
}
}
private void SetDriveNumber(int driveNumber)
{
if (_driveNumber != driveNumber)
{
Flush();
_driveNumber = driveNumber;
}
}
private void SetMotorOn(bool state)
{
if (_motorOn && !state)
{
Flush();
}
_motorOn = state;
}
private void SetMotorOn(bool state)
{
if (_motorOn && !state)
{
Flush();
}
_motorOn = state;
}
private void SetPhase(int address)
{
int phase = (address >> 1) & 0x3;
int state = address & 1;
_phaseStates &= ~(1 << phase);
_phaseStates |= (state << phase);
private void SetPhase(int address)
{
int phase = (address >> 1) & 0x3;
int state = address & 1;
_phaseStates &= ~(1 << phase);
_phaseStates |= (state << phase);
if (_motorOn)
{
Drives[_driveNumber].ApplyPhaseChange(_phaseStates);
}
}
if (_motorOn)
{
Drives[_driveNumber].ApplyPhaseChange(_phaseStates);
}
}
public DiskIIDrive Drive1 { get; private set; }
public DiskIIDrive Drive2 { get; private set; }
public DiskIIDrive Drive1 { get; private set; }
public DiskIIDrive Drive2 { get; private set; }
public List<DiskIIDrive> Drives { get; private set; }
public List<DiskIIDrive> Drives { get; private set; }
public DiskIIDrive BootDrive { get; private set; }
public DiskIIDrive BootDrive { get; private set; }
private const int Phase0On = 1 << 0;
private const int Phase1On = 1 << 1;
private const int Phase2On = 1 << 2;
private const int Phase3On = 1 << 3;
private const int Phase0On = 1 << 0;
private const int Phase1On = 1 << 1;
private const int Phase2On = 1 << 2;
private const int Phase3On = 1 << 3;
private int _latch;
private int _phaseStates;
private bool _motorOn;
private int _driveNumber;
private bool _loadMode;
private bool _writeMode;
private bool _driveSpin;
private int _latch;
private int _phaseStates;
private bool _motorOn;
private int _driveNumber;
private bool _loadMode;
private bool _writeMode;
private bool _driveSpin;
private byte[] _romRegionC1C7 = new byte[0x0100];
}
private byte[] _romRegionC1C7 = new byte[0x0100];
}
}

View File

@ -4,91 +4,88 @@ using System.IO;
namespace Jellyfish.Library
{
public static class StreamExtensions
{
[SuppressMessage("Microsoft.Design", "CA1045:DoNotPassTypesByReference", MessageId = "3#")]
public static int ReadBlock(this Stream stream, byte[] buffer, int offset, ref int count)
{
int read = ReadBlock(stream, buffer, offset, count, count);
count -= read;
return read;
}
public static class StreamExtensions
{
public static int ReadBlock(this Stream stream, byte[] buffer, int offset, ref int count)
{
int read = ReadBlock(stream, buffer, offset, count, count);
count -= read;
return read;
}
[SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed")]
public static int ReadBlock(this Stream stream, byte[] buffer, int offset = 0, int count = int.MaxValue, int minCount = int.MaxValue)
{
if (stream == null)
{
throw new ArgumentNullException("stream");
}
if (buffer == null)
{
throw new ArgumentNullException("buffer");
}
public static int ReadBlock(this Stream stream, byte[] buffer, int offset = 0, int count = int.MaxValue, int minCount = int.MaxValue)
{
if (stream == null)
{
throw new ArgumentNullException("stream");
}
if (buffer == null)
{
throw new ArgumentNullException("buffer");
}
count = Math.Min(count, buffer.Length - offset);
minCount = Math.Min(minCount, buffer.Length - offset);
count = Math.Min(count, buffer.Length - offset);
minCount = Math.Min(minCount, buffer.Length - offset);
int total = 0;
int read;
do
{
total += read = stream.Read(buffer, offset + total, count - total);
}
while ((read > 0) && (total < count));
int total = 0;
int read;
do
{
total += read = stream.Read(buffer, offset + total, count - total);
}
while ((read > 0) && (total < count));
if (total < minCount)
{
throw new EndOfStreamException();
}
if (total < minCount)
{
throw new EndOfStreamException();
}
return total;
}
return total;
}
[SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed")]
public static int ReadWord(this Stream stream, bool optional = false)
{
if (stream == null)
{
throw new ArgumentNullException("stream");
}
public static int ReadWord(this Stream stream, bool optional = false)
{
if (stream == null)
{
throw new ArgumentNullException("stream");
}
int lowByte = stream.ReadByte();
int highByte = stream.ReadByte();
int word = lowByte | (highByte << 8);
if ((word < 0) && !optional)
{
throw new EndOfStreamException();
}
int lowByte = stream.ReadByte();
int highByte = stream.ReadByte();
int word = lowByte | (highByte << 8);
if ((word < 0) && !optional)
{
throw new EndOfStreamException();
}
return word;
}
return word;
}
public static void SkipBlock(this Stream stream, int count)
{
if (stream == null)
{
throw new ArgumentNullException("stream");
}
public static void SkipBlock(this Stream stream, int count)
{
if (stream == null)
{
throw new ArgumentNullException("stream");
}
if (stream.CanSeek)
{
stream.Seek(count, SeekOrigin.Current);
}
else
{
int total = 0;
int read;
do
{
total += read = stream.Read(_skipBuffer, 0, Math.Min(count - total, SkipBufferSize));
}
while ((read > 0) && (total < count));
}
}
if (stream.CanSeek)
{
stream.Seek(count, SeekOrigin.Current);
}
else
{
int total = 0;
int read;
do
{
total += read = stream.Read(_skipBuffer, 0, Math.Min(count - total, SkipBufferSize));
}
while ((read > 0) && (total < count));
}
}
private const int SkipBufferSize = 1024;
private const int SkipBufferSize = 1024;
private static byte[] _skipBuffer = new byte[SkipBufferSize];
}
private static byte[] _skipBuffer = new byte[SkipBufferSize];
}
}

File diff suppressed because it is too large Load Diff

Binary file not shown.