1) Cosmetic changes. 2) Removed volume from disk settings to simplify *.dsk support - if volume matters use another disk format.

--HG--
extra : convert_revision : svn%3Affd33b8c-2492-42e0-bdc5-587b920b7d6d/trunk%4020423
This commit is contained in:
Sean Fausett 2009-06-01 10:34:24 +00:00
parent 1af55a3406
commit 18ac684607
10 changed files with 17 additions and 31 deletions

View File

@ -14,7 +14,7 @@ public static StringBuilder AppendWithoutGarbage(this StringBuilder builder, int
int index = builder.Length;
do
{
builder.Insert(index, _digits, (number % 10) + 9, 1);
builder.Insert(index, Digits, (number % 10) + 9, 1);
number /= 10;
}
while (number != 0);
@ -22,6 +22,6 @@ public static StringBuilder AppendWithoutGarbage(this StringBuilder builder, int
return builder;
}
private static readonly char[] _digits = new char[] { '9', '8', '7', '6', '5', '4', '3', '2', '1', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };
private static readonly char[] Digits = new char[] { '9', '8', '7', '6', '5', '4', '3', '2', '1', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };
}
}

View File

@ -1,8 +0,0 @@
using System;
namespace Jellyfish.Virtu.Properties
{
public static class Constants
{
}
}

View File

@ -11,8 +11,8 @@ protected Disk525(string name, byte[] data, bool isWriteProtected)
Data = data;
IsWriteProtected = true; // TODO use isWriteProtected
}
public static Disk525 CreateDisk(string name, byte[] data, int volume, bool isWriteProtected)
public static Disk525 CreateDisk(string name, byte[] data, bool isWriteProtected)
{
if (name.EndsWith(".nib", StringComparison.OrdinalIgnoreCase) && (data.Length == TrackCount * TrackSize))
{
@ -20,7 +20,7 @@ public static Disk525 CreateDisk(string name, byte[] data, int volume, bool isWr
}
else if (name.EndsWith(".dsk", StringComparison.OrdinalIgnoreCase) && (data.Length == TrackCount * SectorCount * SectorSize))
{
return new DiskDsk(name, data, volume, isWriteProtected);
return new DiskDsk(name, data, isWriteProtected);
}
return null;

View File

@ -4,10 +4,9 @@ namespace Jellyfish.Virtu
{
public sealed class DiskDsk : Disk525
{
public DiskDsk(string name, byte[] data, int volume, bool isWriteProtected) :
public DiskDsk(string name, byte[] data, bool isWriteProtected) :
base(name, data, isWriteProtected)
{
Volume = volume;
}
public override void ReadTrack(int number, int fraction, byte[] buffer)
@ -22,6 +21,6 @@ public override void WriteTrack(int number, int fraction, byte[] buffer)
throw new NotImplementedException();
}
private int Volume { get; set; }
private const int Volume = 0xFE;
}
}

View File

@ -22,11 +22,11 @@ public override void Initialize()
}
if (settings.Disk1.Name.Length > 0)
{
_drives[0].InsertDisk(settings.Disk1.Name, settings.Disk1.Volume, settings.Disk1.IsWriteProtected);
_drives[0].InsertDisk(settings.Disk1.Name, settings.Disk1.IsWriteProtected);
}
if (settings.Disk2.Name.Length > 0)
{
_drives[1].InsertDisk(settings.Disk2.Name, settings.Disk2.Volume, settings.Disk2.IsWriteProtected);
_drives[1].InsertDisk(settings.Disk2.Name, settings.Disk2.IsWriteProtected);
}
}

View File

@ -22,14 +22,14 @@ public void FlushTrack()
}
}
public void InsertDisk(string fileName, int volume, bool isWriteProtected)
public void InsertDisk(string fileName, bool isWriteProtected)
{
FlushTrack();
// TODO handle null param/empty string for eject, or add Eject()
byte[] fileData = FileHelpers.ReadAllBytes(fileName);
_disk = Disk525.CreateDisk(fileName, fileData, volume, isWriteProtected);
_disk = Disk525.CreateDisk(fileName, fileData, isWriteProtected);
_trackLoaded = false;
}

View File

@ -13,8 +13,8 @@ public MachineSettings()
Cpu = new CpuSettings { Is65C02 = true, IsThrottled = true };
DiskII = new DiskIISettings
{
Disk1 = new DiskSettings { Name = string.Empty, Volume = 0xFE, IsWriteProtected = false },
Disk2 = new DiskSettings { Name = string.Empty, Volume = 0xFE, IsWriteProtected = false }
Disk1 = new DiskSettings { Name = string.Empty, IsWriteProtected = false },
Disk2 = new DiskSettings { Name = string.Empty, IsWriteProtected = false }
};
Keyboard = new KeyboardSettings
{
@ -85,13 +85,11 @@ public void Deserialize(Stream stream)
Disk1 = new DiskSettings
{
Name = (string)disk1.Attribute("Name") ?? string.Empty,
Volume = (int)disk1.Attribute("Volume"),
IsWriteProtected = (bool)disk1.Attribute("IsWriteProtected")
},
Disk2 = new DiskSettings
{
Name = (string)disk2.Attribute("Name") ?? string.Empty,
Volume = (int)disk2.Attribute("Volume"),
IsWriteProtected = (bool)disk2.Attribute("IsWriteProtected")
},
};
@ -214,11 +212,9 @@ public void Serialize(Stream stream)
new XElement(ns + "DiskII",
new XElement(ns + "Disk1",
new XAttribute("Name", DiskII.Disk1.Name),
new XAttribute("Volume", DiskII.Disk1.Volume),
new XAttribute("IsWriteProtected", DiskII.Disk1.IsWriteProtected)),
new XElement(ns + "Disk2",
new XAttribute("Name", DiskII.Disk2.Name),
new XAttribute("Volume", DiskII.Disk2.Volume),
new XAttribute("IsWriteProtected", DiskII.Disk2.IsWriteProtected))),
new XElement(ns + "Keyboard",
new XAttribute("UseGamePort", Keyboard.UseGamePort),
@ -318,7 +314,6 @@ public class CpuSettings
public class DiskSettings
{
public string Name { get; set; }
public int Volume { get; set; }
public bool IsWriteProtected { get; set; }
};

View File

@ -91,8 +91,8 @@ private void Page_KeyUp(object sender, KeyEventArgs e)
private int GetAsciiKey(Key key, int platformKeyCode)
{
ModifierKeys modifiers = System.Windows.Input.Keyboard.Modifiers;
bool control = ((modifiers & ModifierKeys.Control) == ModifierKeys.Control);
bool shift = ((modifiers & ModifierKeys.Shift) == ModifierKeys.Shift);
bool control = ((modifiers & ModifierKeys.Control) != 0);
bool shift = ((modifiers & ModifierKeys.Shift) != 0);
bool capsLock = shift ^ _capsLock;
switch (key)

View File

@ -25,7 +25,7 @@ public override string GetDiskFile()
// try
// {
// OpenFileDialog dialog = new OpenFileDialog(); // SL expects all dialogs to be user initiated, ie from within an event handler.
// dialog.Filter = "Disk Files (*.nib)|*.nib|All Files (*.*)|*.*";
// dialog.Filter = "Disk Files (*.dsk;*.nib)|*.dsk;*.nib|All Files (*.*)|*.*";
// bool? result = dialog.ShowDialog();
// if (result.HasValue && result.Value)
// {

View File

@ -16,7 +16,7 @@ public override string GetDiskFile()
Application.Current.Dispatcher.Invoke(new Action(() =>
{
OpenFileDialog dialog = new OpenFileDialog();
dialog.Filter = "Disk Files (*.nib)|*.nib|All Files (*.*)|*.*";
dialog.Filter = "Disk Files (*.dsk;*.nib)|*.dsk;*.nib|All Files (*.*)|*.*";
bool? result = dialog.ShowDialog();
if (result.HasValue && result.Value)
{