diff --git a/BizHawk.Client.Common/BinarySaveStates.cs b/BizHawk.Client.Common/BinarySaveStates.cs
index 6cbb5dda668..28246743072 100644
--- a/BizHawk.Client.Common/BinarySaveStates.cs
+++ b/BizHawk.Client.Common/BinarySaveStates.cs
@@ -264,13 +264,14 @@ private static void WriteVersion(Stream s)
}
- public BinaryStateSaver(string path, bool stateVersionTag = true) // stateVersionTag is a hack for reusing this for movie code
+ public BinaryStateSaver(string path, bool notamovie = true) // notamovie is hack, really should have separate something
{
- _zip = new IonicZipWriter(path, Global.Config.SaveStateCompressionLevelNormal);
+ _zip = new IonicZipWriter(path, notamovie ? Global.Config.SaveStateCompressionLevelNormal
+ : Global.Config.MovieCompressionLevel);
//_zip = new SharpZipWriter(path, Global.Config.SaveStateCompressionLevelNormal);
//_zip = new SevenZipWriter(path, Global.Config.SaveStateCompressionLevelNormal);
- if (stateVersionTag)
+ if (notamovie)
{
PutLump(BinaryStateLump.Versiontag, WriteVersion);
}
diff --git a/BizHawk.Client.Common/BizHawk.Client.Common.csproj b/BizHawk.Client.Common/BizHawk.Client.Common.csproj
index 04447545af4..f4b3331a922 100644
--- a/BizHawk.Client.Common/BizHawk.Client.Common.csproj
+++ b/BizHawk.Client.Common/BizHawk.Client.Common.csproj
@@ -142,6 +142,7 @@
+
diff --git a/BizHawk.Client.Common/CoreFileProvider.cs b/BizHawk.Client.Common/CoreFileProvider.cs
index 5c96ec540f6..5a3c23f987a 100644
--- a/BizHawk.Client.Common/CoreFileProvider.cs
+++ b/BizHawk.Client.Common/CoreFileProvider.cs
@@ -19,7 +19,7 @@ public CoreFileProvider(Action showWarning)
public string PathSubfile(string fname)
{
- return Path.Combine(Path.GetDirectoryName(SubfileDirectory) ?? String.Empty, fname);
+ return Path.Combine(SubfileDirectory ?? String.Empty, fname);
}
public string DllPath()
@@ -110,7 +110,11 @@ public byte[] GetFirmwareWithGameInfo(string sysID, string firmwareID, bool requ
// this should go away now
public static void SyncCoreCommInputSignals(CoreComm target)
{
+ string superhack = null;
+ if (target.CoreFileProvider != null && target.CoreFileProvider is CoreFileProvider)
+ superhack = ((CoreFileProvider)target.CoreFileProvider ).SubfileDirectory;
var cfp = new CoreFileProvider(target.ShowMessage);
+ cfp.SubfileDirectory = superhack;
target.CoreFileProvider = cfp;
cfp.FirmwareManager = Global.FirmwareManager;
}
diff --git a/BizHawk.Client.Common/IPS.cs b/BizHawk.Client.Common/IPS.cs
index 621ebe6a407..ccc9122b4fb 100644
--- a/BizHawk.Client.Common/IPS.cs
+++ b/BizHawk.Client.Common/IPS.cs
@@ -5,7 +5,7 @@ namespace BizHawk.Client.Common
{
public static class IPS
{
- public static void Patch(byte[] rom, Stream patch)
+ public static byte[] Patch(byte[] rom, Stream patch)
{
var ipsHeader = new byte[5];
patch.Read(ipsHeader, 0, 5);
@@ -16,32 +16,40 @@ public static void Patch(byte[] rom, Stream patch)
if (ipsHeader[i] != header[i])
{
Console.WriteLine("Patch file specified is invalid.");
- return;
+ return null;
}
}
// header verified, loop over patch entries
uint EOF = ('E' * 0x10000 + 'O' * 0x100 + 'F');
+ var ret = new MemoryStream(rom.Length);
+ ret.Write(rom, 0, rom.Length);
+
while (true)
{
uint offset = Read24(patch);
- if (offset == EOF) return;
+ if (offset == EOF)
+ return ret.ToArray();
ushort size = Read16(patch);
+ ret.Seek(offset, SeekOrigin.Begin);
+
if (size != 0) // non-RLE patch
{
var patchData = new byte[size];
patch.Read(patchData, 0, size);
- for (int i = 0; i < size; i++)
- rom[offset++] = patchData[i];
+
+ ret.Write(patchData, 0, patchData.Length);
}
else // RLE patch
{
size = Read16(patch);
byte value = (byte)patch.ReadByte();
for (int i = 0; i < size; i++)
- rom[offset++] = value;
+ {
+ ret.WriteByte(value);
+ }
}
}
}
diff --git a/BizHawk.Client.Common/PathManager.cs b/BizHawk.Client.Common/PathManager.cs
index ec4293a7546..b70c3221213 100644
--- a/BizHawk.Client.Common/PathManager.cs
+++ b/BizHawk.Client.Common/PathManager.cs
@@ -309,6 +309,11 @@ public static string SaveStatePrefix(GameInfo game)
name += "." + (Global.Emulator as LibsnesCore).CurrentProfile;
}
+ if (Global.Emulator.SystemId == "GBA")
+ {
+ name += "." + Global.Emulator.Attributes().CoreName;
+ }
+
if (Global.MovieSession.Movie.IsActive)
{
name += "." + Path.GetFileNameWithoutExtension(Global.MovieSession.Movie.Filename);
diff --git a/BizHawk.Client.Common/RomGame.cs b/BizHawk.Client.Common/RomGame.cs
index 8c526cb2fda..165caf8f9e9 100644
--- a/BizHawk.Client.Common/RomGame.cs
+++ b/BizHawk.Client.Common/RomGame.cs
@@ -51,6 +51,7 @@ public RomGame(HawkFile file, string patch)
// read the entire file into FileData.
FileData = new byte[fileLength];
+ stream.Position = 0;
stream.Read(FileData, 0, fileLength);
// if there was no header offset, RomData is equivalent to FileData
@@ -90,7 +91,7 @@ public RomGame(HawkFile file, string patch)
patchFile.BindFirstOf("IPS");
if (patchFile.IsBound)
{
- IPS.Patch(RomData, patchFile.GetStream());
+ RomData = IPS.Patch(RomData, patchFile.GetStream());
}
}
}
diff --git a/BizHawk.Client.Common/RomLoader.cs b/BizHawk.Client.Common/RomLoader.cs
index 2bcf2858edf..3c221c669fd 100644
--- a/BizHawk.Client.Common/RomLoader.cs
+++ b/BizHawk.Client.Common/RomLoader.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Linq;
using System.IO;
using BizHawk.Common;
using BizHawk.Emulation.Common;
@@ -159,8 +160,15 @@ private bool PreferredPlatformIsDefined(string extension)
return false;
}
- public bool LoadRom(string path, CoreComm nextComm, bool forceAccurateCore = false) // forceAccurateCore is currently just for Quicknes vs Neshawk but could be used for other situations
+ public bool LoadRom(string path, CoreComm nextComm, bool forceAccurateCore = false,
+ int recursiveCount = 0) // forceAccurateCore is currently just for Quicknes vs Neshawk but could be used for other situations
{
+ if (recursiveCount > 1) // hack to stop recursive calls from endlessly rerunning if we can't load it
+ {
+ DoLoadErrorCallback("Failed multiple attempts to load ROM.", "");
+ return false;
+ }
+
bool cancel = false;
if (path == null)
@@ -322,29 +330,59 @@ private bool PreferredPlatformIsDefined(string extension)
switch (game.System)
{
+ case "GB":
case "DGB":
- var left = Database.GetGameInfo(xmlGame.Assets["LeftRom"], "left.gb");
- var right = Database.GetGameInfo(xmlGame.Assets["RightRom"], "right.gb");
+ // adelikat: remove need for tags to be hardcoded to left and right, we should clean this up, also maybe the DGB core should just take the xml file and handle it itself
+ var leftBytes = xmlGame.Assets.First().Value;
+ var rightBytes = xmlGame.Assets.Skip(1).First().Value;
+
+ var left = Database.GetGameInfo(leftBytes, "left.gb");
+ var right = Database.GetGameInfo(rightBytes, "right.gb");
nextEmulator = new GambatteLink(
nextComm,
left,
- xmlGame.Assets["LeftRom"],
+ leftBytes,
right,
- xmlGame.Assets["RightRom"],
+ rightBytes,
GetCoreSettings(),
GetCoreSyncSettings(),
Deterministic);
// other stuff todo
break;
+ case "AppleII":
+ var assets = xmlGame.Assets.Select(a => Database.GetGameInfo(a.Value, a.Key));
+ var roms = xmlGame.Assets.Select(a => a.Value);
+ nextEmulator = new AppleII(
+ nextComm,
+ assets,
+ roms);
+ break;
default:
return false;
}
}
catch (Exception ex)
{
- DoLoadErrorCallback(ex.ToString(), "DGB", LoadErrorType.XML);
- return false;
+ try
+ {
+ // need to get rid of this hack at some point
+ rom = new RomGame(file);
+ ((CoreFileProvider)nextComm.CoreFileProvider).SubfileDirectory = Path.GetDirectoryName(path.Replace("|", String.Empty)); // Dirty hack to get around archive filenames (since we are just getting the directory path, it is safe to mangle the filename
+ byte[] romData = null;
+ byte[] xmlData = rom.FileData;
+
+ game = rom.GameInfo;
+ game.System = "SNES";
+
+ var snes = new LibsnesCore(game, romData, Deterministic, xmlData, nextComm, GetCoreSettings(), GetCoreSyncSettings());
+ nextEmulator = snes;
+ }
+ catch
+ {
+ DoLoadErrorCallback(ex.ToString(), "DGB", LoadErrorType.XML);
+ return false;
+ }
}
}
else // most extensions
@@ -369,7 +407,7 @@ private bool PreferredPlatformIsDefined(string extension)
var result = ChoosePlatform(rom);
if (!string.IsNullOrEmpty(result))
{
- rom.GameInfo.System = ChoosePlatform(rom);
+ rom.GameInfo.System = result;
}
else
{
@@ -473,13 +511,16 @@ private bool PreferredPlatformIsDefined(string extension)
var c64 = new C64(nextComm, game, rom.RomData, rom.Extension);
nextEmulator = c64;
break;
- case "AppleII":
- var appleII = new AppleII(nextComm, game, rom.RomData, rom.Extension);
- nextEmulator = appleII;
- break;
case "GBA":
//core = CoreInventory.Instance["GBA", "Meteor"];
- core = CoreInventory.Instance["GBA", "VBA-Next"];
+ if (Global.Config.GBA_UsemGBA)
+ {
+ core = CoreInventory.Instance["GBA", "mGBA"];
+ }
+ else
+ {
+ core = CoreInventory.Instance["GBA", "VBA-Next"];
+ }
break;
case "PSX":
nextEmulator = new Octoshock(nextComm, null, null, rom.FileData, GetCoreSettings(), GetCoreSyncSettings());
@@ -526,7 +567,12 @@ private bool PreferredPlatformIsDefined(string extension)
// Specific hack here, as we get more cores of the same system, this isn't scalable
if (ex is UnsupportedGameException)
{
- return LoadRom(path, nextComm, forceAccurateCore: true);
+ if (system == "NES")
+ {
+ DoMessageCallback("Unable to use quicknes, using NESHawk instead");
+ }
+
+ return LoadRom(path, nextComm, true, recursiveCount + 1);
}
else if (ex is MissingFirmwareException)
{
@@ -536,7 +582,7 @@ private bool PreferredPlatformIsDefined(string extension)
{
// Note: GB as SGB was set to false by this point, otherwise we would want to do it here
DoMessageCallback("Failed to load a GB rom in SGB mode. Disabling SGB Mode.");
- return LoadRom(path, nextComm);
+ return LoadRom(path, nextComm, false, recursiveCount + 1);
}
else
{
diff --git a/BizHawk.Client.Common/XmlGame.cs b/BizHawk.Client.Common/XmlGame.cs
index d99ece5dd24..1b751865781 100644
--- a/BizHawk.Client.Common/XmlGame.cs
+++ b/BizHawk.Client.Common/XmlGame.cs
@@ -13,9 +13,15 @@ namespace BizHawk.Client.Common
{
public class XmlGame
{
+ public XmlGame()
+ {
+ Assets = new List>();
+ GI = new GameInfo();
+ }
+
public XmlDocument Xml { get; set; }
- public GameInfo GI = new GameInfo();
- public Dictionary Assets = new Dictionary();
+ public GameInfo GI { get; set; }
+ public IList> Assets { get; set; }
public static XmlGame Create(HawkFile f)
{
@@ -48,9 +54,8 @@ public static XmlGame Create(HawkFile f)
foreach (XmlNode a in n.ChildNodes)
{
- string name = a.Name;
string filename = a.Attributes["FileName"].Value;
- byte[] data;
+ byte[] data = new byte[0];
if (filename[0] == '|')
{
// in same archive
@@ -68,7 +73,7 @@ public static XmlGame Create(HawkFile f)
}
else
{
- throw new Exception("Couldn't load XMLGame LoadAsset \"" + name + "\"");
+ throw new Exception("Couldn't load XMLGame Asset \"" + filename + "\"");
}
}
else
@@ -78,15 +83,30 @@ public static XmlGame Create(HawkFile f)
fullpath = Path.Combine(fullpath, filename.Split('|').First());
try
{
- data = File.ReadAllBytes(fullpath.Split('|').First());
+ using (var hf = new HawkFile(fullpath))
+ {
+ if (hf.IsArchive)
+ {
+ var archiveItem = hf.ArchiveItems.First(ai => ai.Name == filename.Split('|').Skip(1).First());
+ hf.Unbind();
+ hf.BindArchiveMember(archiveItem);
+ data = hf.GetStream().ReadAllBytes();
+ }
+ else
+ {
+ data = File.ReadAllBytes(fullpath.Split('|').First());
+ }
+ }
+
+
}
catch
{
- throw new Exception("Couldn't load XMLGame LoadAsset \"" + name + "\"");
+ throw new Exception("Couldn't load XMLGame LoadAsset \"" + filename + "\"");
}
}
- ret.Assets[name] = data;
+ ret.Assets.Add(new KeyValuePair(filename, data));
using (var sha1 = System.Security.Cryptography.SHA1.Create())
{
diff --git a/BizHawk.Client.Common/config/Config.cs b/BizHawk.Client.Common/config/Config.cs
index 03b572dbe82..aa462e3dcc8 100644
--- a/BizHawk.Client.Common/config/Config.cs
+++ b/BizHawk.Client.Common/config/Config.cs
@@ -167,6 +167,7 @@ public enum ClientProfile
public int SaveStateCompressionLevelNormal = DefaultSaveStateCompressionLevelNormal;
public const int DefaultSaveStateCompressionLevelRewind = 0;//this isnt actually used yet
public int SaveStateCompressionLevelRewind = DefaultSaveStateCompressionLevelRewind;//this isnt actually used yet
+ public int MovieCompressionLevel = 2;
/// use vsync. if VSyncThrottle = false, this will try to use vsync without throttling to it
public bool VSync = false;
@@ -410,6 +411,7 @@ public AnalogBind(string Value, float Mult, float Deadzone)
public bool GB_AsSGB = false;
public bool NES_InQuickNES = true;
public bool SNES_InSnes9x = false;
+ public bool GBA_UsemGBA = false;
}
// These are used in the defctrl.json or wherever
diff --git a/BizHawk.Client.Common/config/PathEntry.cs b/BizHawk.Client.Common/config/PathEntry.cs
index b17ca54f68c..7b63e2dd29c 100644
--- a/BizHawk.Client.Common/config/PathEntry.cs
+++ b/BizHawk.Client.Common/config/PathEntry.cs
@@ -151,11 +151,12 @@ public static List DefaultValues
new PathEntry { System = "Global_NULL", SystemDisplayName="Global", Type = "Movies", Path = Path.Combine(".", "Movies"), Ordinal = 4 },
new PathEntry { System = "Global_NULL", SystemDisplayName="Global", Type = "Movie backups", Path = Path.Combine(".", "Movies", "backup"), Ordinal = 5 },
new PathEntry { System = "Global_NULL", SystemDisplayName="Global", Type = "Lua", Path = Path.Combine(".", "Lua"), Ordinal = 6 },
- new PathEntry { System = "Global_NULL", SystemDisplayName="Global", Type = "Watch (.wch)", Path = ".", Ordinal = 7 },
+ new PathEntry { System = "Global_NULL", SystemDisplayName="Global", Type = "Watch (.wch)", Path = Path.Combine(".", "Tools"), Ordinal = 7 },
new PathEntry { System = "Global_NULL", SystemDisplayName="Global", Type = "A/V Dumps", Path = ".", Ordinal = 8 },
- new PathEntry { System = "Global_NULL", SystemDisplayName="Global", Type = "Debug Logs", Path = ".", Ordinal = 9 },
+ new PathEntry { System = "Global_NULL", SystemDisplayName="Global", Type = "Debug Logs", Path = Path.Combine(".", "Tools"), Ordinal = 9 },
new PathEntry { System = "Global_NULL", SystemDisplayName="Global", Type = "Macros", Path = Path.Combine(".", "Movies", "Macros"), Ordinal = 10 },
new PathEntry { System = "Global_NULL", SystemDisplayName="Global", Type = "TAStudio states", Path = Path.Combine(".", "Movies", "TAStudio states"), Ordinal = 11 },
+ new PathEntry { System = "Global_NULL", SystemDisplayName="Global", Type = "Multi-Disk Bundles", Path = Path.Combine(".", "Tools"), Ordinal = 12 },
new PathEntry { System = "INTV", SystemDisplayName="Intellivision", Type = "Base", Path = Path.Combine(".", "Intellivision"), Ordinal = 0 },
new PathEntry { System = "INTV", SystemDisplayName="Intellivision", Type = "ROM", Path = ".", Ordinal = 1 },
@@ -304,6 +305,12 @@ public static List DefaultValues
new PathEntry { System = "Lynx", SystemDisplayName = "Lynx", Type = "Save RAM", Path = Path.Combine(".", "SaveRAM"), Ordinal = 3 },
new PathEntry { System = "Lynx", SystemDisplayName = "Lynx", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 },
new PathEntry { System = "Lynx", SystemDisplayName = "Lynx", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 },
+
+ new PathEntry { System = "AppleII", SystemDisplayName = "Apple II", Type = "Base", Path = Path.Combine(".", "Lynx"), Ordinal = 0 },
+ new PathEntry { System = "AppleII", SystemDisplayName = "Apple II", Type = "ROM", Path = ".", Ordinal = 1 },
+ new PathEntry { System = "AppleII", SystemDisplayName = "Apple II", Type = "Savestates", Path= Path.Combine(".", "State"), Ordinal = 2 },
+ new PathEntry { System = "AppleII", SystemDisplayName = "Apple II", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 },
+ new PathEntry { System = "AppleII", SystemDisplayName = "Apple II", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 },
};
}
}
diff --git a/BizHawk.Client.Common/lua/LuaHelper.cs b/BizHawk.Client.Common/lua/LuaHelper.cs
new file mode 100644
index 00000000000..9180ec421f8
--- /dev/null
+++ b/BizHawk.Client.Common/lua/LuaHelper.cs
@@ -0,0 +1,30 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using LuaInterface;
+using System.Reflection;
+
+namespace BizHawk.Client.Common
+{
+ public static class LuaHelper
+ {
+ public static LuaTable ToLuaTable(Lua lua, object obj)
+ {
+ var table = lua.NewTable();
+
+ var type = obj.GetType();
+
+ var methods = type.GetMethods();
+ foreach (var method in methods)
+ {
+ if (method.IsPublic)
+ {
+ table[method.Name] = lua.RegisterFunction("", obj, method);
+ }
+ }
+
+ return table;
+ }
+ }
+}
diff --git a/BizHawk.Client.Common/movie/MovieService.cs b/BizHawk.Client.Common/movie/MovieService.cs
index 16aa964003a..981cd68cd4e 100644
--- a/BizHawk.Client.Common/movie/MovieService.cs
+++ b/BizHawk.Client.Common/movie/MovieService.cs
@@ -20,6 +20,13 @@ public static IMovie Get(string path)
{
var bkm = new BkmMovie(path);
bkm.Load();
+
+ // Hackery to fix how things used to work
+ if (bkm.SystemID == "GBC")
+ {
+ bkm.SystemID = "GB";
+ }
+
return bkm.ToBk2();
}
diff --git a/BizHawk.Client.Common/movie/MovieSession.cs b/BizHawk.Client.Common/movie/MovieSession.cs
index b1aa69268aa..3370a2719e5 100644
--- a/BizHawk.Client.Common/movie/MovieSession.cs
+++ b/BizHawk.Client.Common/movie/MovieSession.cs
@@ -136,9 +136,16 @@ public void LatchInputFromLog()
{
var input = Movie.GetInputState(Global.Emulator.Frame);
+ // adelikat: TODO: this is likely the source of frame 0 TAStudio bugs, I think the intent is to check if the movie is 0 length?
if (Global.Emulator.Frame == 0) // Hacky
HandleMovieAfterFrameLoop(); // Frame 0 needs to be handled.
+ if (input == null)
+ {
+ HandleMovieAfterFrameLoop();
+ return;
+ }
+
MovieControllerAdapter.LatchFromSource(input);
if (MultiTrack.IsActive)
{
diff --git a/BizHawk.Client.Common/movie/bk2/Bk2MnemonicConstants.cs b/BizHawk.Client.Common/movie/bk2/Bk2MnemonicConstants.cs
index 695463199c4..36aa569cb05 100644
--- a/BizHawk.Client.Common/movie/bk2/Bk2MnemonicConstants.cs
+++ b/BizHawk.Client.Common/movie/bk2/Bk2MnemonicConstants.cs
@@ -255,7 +255,25 @@ public char this[string button]
{ "Option 1", '1' },
{ "Option 2", '2' }
}
- }
+ },
+ {
+ "AppleII",
+ new Dictionary
+ {
+ { "Tab", 't' },
+ { "Return", 'e' },
+ { "Escape", 'x' },
+ { "Delete", 'b' },
+ { "Space", 's' },
+ { "Control", 'c' },
+ { "Shift", '^' },
+ { "Caps Lock", 'C' },
+ { "Next Disk", '>' },
+ { "Previous Disk", '<' },
+ { "White Apple", 'w' },
+ { "Black Apple", 'b' }
+ }
+ }
};
}
}
diff --git a/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj b/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj
index 678fcc96493..436419eb24d 100644
--- a/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj
+++ b/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj
@@ -283,12 +283,6 @@
DGBPrefs.cs
-
- UserControl
-
-
- DualGBFileSelector.cs
-
UserControl
@@ -708,12 +702,6 @@
MobileDetailView.cs
-
- Form
-
-
- DualGBXMLCreator.cs
-
Form
@@ -771,6 +759,12 @@
+
+ Form
+
+
+ LuaCanvas.cs
+
Component
@@ -820,6 +814,18 @@
MacroInput.cs
+
+ UserControl
+
+
+ MultiDiskFileSelector.cs
+
+
+ Form
+
+
+ MultiDiskBundler.cs
+
Form
@@ -835,6 +841,12 @@
NESGameGenie.cs
+
+ Form
+
+
+ NESMusicRipper.cs
+
Form
@@ -1035,6 +1047,7 @@
+
@@ -1152,9 +1165,6 @@
DGBPrefs.cs
-
- DualGBFileSelector.cs
-
GBPrefControl.cs
@@ -1303,9 +1313,6 @@
MobileDetailView.cs
-
- DualGBXMLCreator.cs
-
GBGameGenie.cs
@@ -1330,6 +1337,9 @@
HexFind.cs
+
+ LuaCanvas.cs
+
LuaConsole.cs
@@ -1345,12 +1355,21 @@
MacroInput.cs
+
+ MultiDiskFileSelector.cs
+
+
+ MultiDiskBundler.cs
+
BarcodeEntry.cs
NESGameGenie.cs
+
+ NESMusicRipper.cs
+
NESNameTableViewer.cs
@@ -1883,6 +1902,7 @@
+
diff --git a/BizHawk.Client.EmuHawk/MainForm.Designer.cs b/BizHawk.Client.EmuHawk/MainForm.Designer.cs
index 57a88558683..566c7e84705 100644
--- a/BizHawk.Client.EmuHawk/MainForm.Designer.cs
+++ b/BizHawk.Client.EmuHawk/MainForm.Designer.cs
@@ -193,17 +193,23 @@ private void InitializeComponent()
this.TraceLoggerMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.DebuggerMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.TAStudioMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.MacroToolMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.VirtualPadMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator11 = new System.Windows.Forms.ToolStripSeparator();
this.CheatsMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.LuaConsoleMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator29 = new System.Windows.Forms.ToolStripSeparator();
- this.CreateDualGbXmlMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.MultiDiskBundlerFileMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.batchRunnerToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.NESSubMenu = new System.Windows.Forms.ToolStripMenuItem();
+ this.coreToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.quickNESToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.nesHawkToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.toolStripSeparator34 = new System.Windows.Forms.ToolStripSeparator();
this.NESPPUViewerMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.NESNametableViewerMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.NESGameGenieCodesMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.musicRipperToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator17 = new System.Windows.Forms.ToolStripSeparator();
this.NesControllerSettingsMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.NESGraphicSettingsMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@@ -262,9 +268,12 @@ private void InitializeComponent()
this.GBGPUViewerMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.GBGameGenieMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.GBASubMenu = new System.Windows.Forms.ToolStripMenuItem();
- this.GbaGpuViewerMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.toolStripSeparator33 = new System.Windows.Forms.ToolStripSeparator();
+ this.GBACoreSelectionSubMenu = new System.Windows.Forms.ToolStripMenuItem();
+ this.GBAmGBAMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.GBAVBANextMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.GBAcoresettingsToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
+ this.toolStripSeparator33 = new System.Windows.Forms.ToolStripSeparator();
+ this.GbaGpuViewerMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.PSXSubMenu = new System.Windows.Forms.ToolStripMenuItem();
this.PSXControllerSettingsMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.PSXOptionsMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@@ -304,6 +313,9 @@ private void InitializeComponent()
this.GenesisSettingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.wonderSwanToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.settingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.AppleSubMenu = new System.Windows.Forms.ToolStripMenuItem();
+ this.AppleDisksSubMenu = new System.Windows.Forms.ToolStripMenuItem();
+ this.toolStripSeparator31 = new System.Windows.Forms.ToolStripSeparator();
this.HelpSubMenu = new System.Windows.Forms.ToolStripMenuItem();
this.OnlineHelpMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ForumsMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@@ -381,7 +393,7 @@ private void InitializeComponent()
this.ClearSRAMContextMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ShowMenuContextMenuSeparator = new System.Windows.Forms.ToolStripSeparator();
this.ShowMenuContextMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.MacroToolMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.gBAWithMGBAToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.MainformMenu.SuspendLayout();
this.MainStatusBar.SuspendLayout();
this.MainFormContextMenu.SuspendLayout();
@@ -411,6 +423,7 @@ private void InitializeComponent()
this.DGBSubMenu,
this.GenesisSubMenu,
this.wonderSwanToolStripMenuItem,
+ this.AppleSubMenu,
this.HelpSubMenu});
this.MainformMenu.LayoutStyle = System.Windows.Forms.ToolStripLayoutStyle.Flow;
this.MainformMenu.Location = new System.Drawing.Point(0, 0);
@@ -1680,6 +1693,7 @@ private void InitializeComponent()
this.GBInSGBMenuItem,
this.NesInQuickNESMenuItem,
this.SnesWithSnes9xMenuItem,
+ this.gBAWithMGBAToolStripMenuItem,
this.toolStripSeparator8,
this.N64VideoPluginSettingsMenuItem});
this.CoresSubMenu.Name = "CoresSubMenu";
@@ -1759,7 +1773,7 @@ private void InitializeComponent()
this.CheatsMenuItem,
this.LuaConsoleMenuItem,
this.toolStripSeparator29,
- this.CreateDualGbXmlMenuItem,
+ this.MultiDiskBundlerFileMenuItem,
this.batchRunnerToolStripMenuItem});
this.ToolsSubMenu.Name = "ToolsSubMenu";
this.ToolsSubMenu.Size = new System.Drawing.Size(48, 19);
@@ -1770,20 +1784,20 @@ private void InitializeComponent()
//
this.ToolBoxMenuItem.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.ToolBox;
this.ToolBoxMenuItem.Name = "ToolBoxMenuItem";
- this.ToolBoxMenuItem.Size = new System.Drawing.Size(183, 22);
+ this.ToolBoxMenuItem.Size = new System.Drawing.Size(172, 22);
this.ToolBoxMenuItem.Text = "&Tool Box";
this.ToolBoxMenuItem.Click += new System.EventHandler(this.ToolBoxMenuItem_Click);
//
// toolStripSeparator12
//
this.toolStripSeparator12.Name = "toolStripSeparator12";
- this.toolStripSeparator12.Size = new System.Drawing.Size(180, 6);
+ this.toolStripSeparator12.Size = new System.Drawing.Size(169, 6);
//
// RamWatchMenuItem
//
this.RamWatchMenuItem.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.watch;
this.RamWatchMenuItem.Name = "RamWatchMenuItem";
- this.RamWatchMenuItem.Size = new System.Drawing.Size(183, 22);
+ this.RamWatchMenuItem.Size = new System.Drawing.Size(172, 22);
this.RamWatchMenuItem.Text = "RAM &Watch";
this.RamWatchMenuItem.Click += new System.EventHandler(this.RamWatchMenuItem_Click);
//
@@ -1791,7 +1805,7 @@ private void InitializeComponent()
//
this.RamSearchMenuItem.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.search;
this.RamSearchMenuItem.Name = "RamSearchMenuItem";
- this.RamSearchMenuItem.Size = new System.Drawing.Size(183, 22);
+ this.RamSearchMenuItem.Size = new System.Drawing.Size(172, 22);
this.RamSearchMenuItem.Text = "RAM &Search";
this.RamSearchMenuItem.Click += new System.EventHandler(this.RamSearchMenuItem_Click);
//
@@ -1799,7 +1813,7 @@ private void InitializeComponent()
//
this.HexEditorMenuItem.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.poke;
this.HexEditorMenuItem.Name = "HexEditorMenuItem";
- this.HexEditorMenuItem.Size = new System.Drawing.Size(183, 22);
+ this.HexEditorMenuItem.Size = new System.Drawing.Size(172, 22);
this.HexEditorMenuItem.Text = "&Hex Editor";
this.HexEditorMenuItem.Click += new System.EventHandler(this.HexEditorMenuItem_Click);
//
@@ -1807,7 +1821,7 @@ private void InitializeComponent()
//
this.TraceLoggerMenuItem.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.pencil;
this.TraceLoggerMenuItem.Name = "TraceLoggerMenuItem";
- this.TraceLoggerMenuItem.Size = new System.Drawing.Size(183, 22);
+ this.TraceLoggerMenuItem.Size = new System.Drawing.Size(172, 22);
this.TraceLoggerMenuItem.Text = "Trace &Logger";
this.TraceLoggerMenuItem.Click += new System.EventHandler(this.TraceLoggerMenuItem_Click);
//
@@ -1815,7 +1829,7 @@ private void InitializeComponent()
//
this.DebuggerMenuItem.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.Bug;
this.DebuggerMenuItem.Name = "DebuggerMenuItem";
- this.DebuggerMenuItem.Size = new System.Drawing.Size(183, 22);
+ this.DebuggerMenuItem.Size = new System.Drawing.Size(172, 22);
this.DebuggerMenuItem.Text = "&Debugger";
this.DebuggerMenuItem.Click += new System.EventHandler(this.DebuggerMenuItem_Click);
// DebuggerMenuItem.
@@ -1823,28 +1837,35 @@ private void InitializeComponent()
//
this.TAStudioMenuItem.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.TAStudio;
this.TAStudioMenuItem.Name = "TAStudioMenuItem";
- this.TAStudioMenuItem.Size = new System.Drawing.Size(183, 22);
+ this.TAStudioMenuItem.Size = new System.Drawing.Size(172, 22);
this.TAStudioMenuItem.Text = "&TAStudio";
this.TAStudioMenuItem.Click += new System.EventHandler(this.TAStudioMenuItem_Click);
//
+ // MacroToolMenuItem
+ //
+ this.MacroToolMenuItem.Name = "MacroToolMenuItem";
+ this.MacroToolMenuItem.Size = new System.Drawing.Size(172, 22);
+ this.MacroToolMenuItem.Text = "&Macro Tool";
+ this.MacroToolMenuItem.Click += new System.EventHandler(this.MacroToolMenuItem_Click);
+ //
// VirtualPadMenuItem
//
this.VirtualPadMenuItem.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.GameController;
this.VirtualPadMenuItem.Name = "VirtualPadMenuItem";
- this.VirtualPadMenuItem.Size = new System.Drawing.Size(183, 22);
+ this.VirtualPadMenuItem.Size = new System.Drawing.Size(172, 22);
this.VirtualPadMenuItem.Text = "Virtual Pad";
this.VirtualPadMenuItem.Click += new System.EventHandler(this.VirtualPadMenuItem_Click);
//
// toolStripSeparator11
//
this.toolStripSeparator11.Name = "toolStripSeparator11";
- this.toolStripSeparator11.Size = new System.Drawing.Size(180, 6);
+ this.toolStripSeparator11.Size = new System.Drawing.Size(169, 6);
//
// CheatsMenuItem
//
this.CheatsMenuItem.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.Freeze;
this.CheatsMenuItem.Name = "CheatsMenuItem";
- this.CheatsMenuItem.Size = new System.Drawing.Size(183, 22);
+ this.CheatsMenuItem.Size = new System.Drawing.Size(172, 22);
this.CheatsMenuItem.Text = "Cheats";
this.CheatsMenuItem.Click += new System.EventHandler(this.CheatsMenuItem_Click);
//
@@ -1852,27 +1873,27 @@ private void InitializeComponent()
//
this.LuaConsoleMenuItem.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.Lua;
this.LuaConsoleMenuItem.Name = "LuaConsoleMenuItem";
- this.LuaConsoleMenuItem.Size = new System.Drawing.Size(183, 22);
+ this.LuaConsoleMenuItem.Size = new System.Drawing.Size(172, 22);
this.LuaConsoleMenuItem.Text = "Lua Console";
this.LuaConsoleMenuItem.Click += new System.EventHandler(this.LuaConsoleMenuItem_Click);
//
// toolStripSeparator29
//
this.toolStripSeparator29.Name = "toolStripSeparator29";
- this.toolStripSeparator29.Size = new System.Drawing.Size(180, 6);
+ this.toolStripSeparator29.Size = new System.Drawing.Size(169, 6);
//
- // CreateDualGbXmlMenuItem
+ // MultiDiskBundlerFileMenuItem
//
- this.CreateDualGbXmlMenuItem.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.dual;
- this.CreateDualGbXmlMenuItem.Name = "CreateDualGbXmlMenuItem";
- this.CreateDualGbXmlMenuItem.Size = new System.Drawing.Size(183, 22);
- this.CreateDualGbXmlMenuItem.Text = "Create Dual GB File...";
- this.CreateDualGbXmlMenuItem.Click += new System.EventHandler(this.CreateDualGbXmlMenuItem_Click);
+ this.MultiDiskBundlerFileMenuItem.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.SaveConfig;
+ this.MultiDiskBundlerFileMenuItem.Name = "MultiDiskBundlerFileMenuItem";
+ this.MultiDiskBundlerFileMenuItem.Size = new System.Drawing.Size(172, 22);
+ this.MultiDiskBundlerFileMenuItem.Text = "Multi-disk Bundler";
+ this.MultiDiskBundlerFileMenuItem.Click += new System.EventHandler(this.CreateMultigameFileMenuItem_Click);
//
// batchRunnerToolStripMenuItem
//
this.batchRunnerToolStripMenuItem.Name = "batchRunnerToolStripMenuItem";
- this.batchRunnerToolStripMenuItem.Size = new System.Drawing.Size(183, 22);
+ this.batchRunnerToolStripMenuItem.Size = new System.Drawing.Size(172, 22);
this.batchRunnerToolStripMenuItem.Text = "Batch Runner";
this.batchRunnerToolStripMenuItem.Visible = false;
this.batchRunnerToolStripMenuItem.Click += new System.EventHandler(this.batchRunnerToolStripMenuItem_Click);
@@ -1880,9 +1901,12 @@ private void InitializeComponent()
// NESSubMenu
//
this.NESSubMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.coreToolStripMenuItem,
+ this.toolStripSeparator34,
this.NESPPUViewerMenuItem,
this.NESNametableViewerMenuItem,
this.NESGameGenieCodesMenuItem,
+ this.musicRipperToolStripMenuItem,
this.toolStripSeparator17,
this.NesControllerSettingsMenuItem,
this.NESGraphicSettingsMenuItem,
@@ -1896,6 +1920,35 @@ private void InitializeComponent()
this.NESSubMenu.Text = "&NES";
this.NESSubMenu.DropDownOpened += new System.EventHandler(this.NESSubMenu_DropDownOpened);
//
+ // coreToolStripMenuItem
+ //
+ this.coreToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.quickNESToolStripMenuItem,
+ this.nesHawkToolStripMenuItem});
+ this.coreToolStripMenuItem.Name = "coreToolStripMenuItem";
+ this.coreToolStripMenuItem.Size = new System.Drawing.Size(233, 22);
+ this.coreToolStripMenuItem.Text = "&Core";
+ this.coreToolStripMenuItem.DropDownOpened += new System.EventHandler(this.coreToolStripMenuItem_DropDownOpened);
+ //
+ // quickNESToolStripMenuItem
+ //
+ this.quickNESToolStripMenuItem.Name = "quickNESToolStripMenuItem";
+ this.quickNESToolStripMenuItem.Size = new System.Drawing.Size(125, 22);
+ this.quickNESToolStripMenuItem.Text = "&QuickNes";
+ this.quickNESToolStripMenuItem.Click += new System.EventHandler(this.quickNESToolStripMenuItem_Click);
+ //
+ // nesHawkToolStripMenuItem
+ //
+ this.nesHawkToolStripMenuItem.Name = "nesHawkToolStripMenuItem";
+ this.nesHawkToolStripMenuItem.Size = new System.Drawing.Size(125, 22);
+ this.nesHawkToolStripMenuItem.Text = "&NesHawk";
+ this.nesHawkToolStripMenuItem.Click += new System.EventHandler(this.nesHawkToolStripMenuItem_Click);
+ //
+ // toolStripSeparator34
+ //
+ this.toolStripSeparator34.Name = "toolStripSeparator34";
+ this.toolStripSeparator34.Size = new System.Drawing.Size(230, 6);
+ //
// NESPPUViewerMenuItem
//
this.NESPPUViewerMenuItem.Name = "NESPPUViewerMenuItem";
@@ -1917,6 +1970,13 @@ private void InitializeComponent()
this.NESGameGenieCodesMenuItem.Text = "&Game Genie Encoder/Decoder";
this.NESGameGenieCodesMenuItem.Click += new System.EventHandler(this.NESGameGenieCodesMenuItem_Click);
//
+ // musicRipperToolStripMenuItem
+ //
+ this.musicRipperToolStripMenuItem.Name = "musicRipperToolStripMenuItem";
+ this.musicRipperToolStripMenuItem.Size = new System.Drawing.Size(233, 22);
+ this.musicRipperToolStripMenuItem.Text = "Music Ripper";
+ this.musicRipperToolStripMenuItem.Click += new System.EventHandler(this.musicRipperToolStripMenuItem_Click);
+ //
// toolStripSeparator17
//
this.toolStripSeparator17.Name = "toolStripSeparator17";
@@ -2361,24 +2421,37 @@ private void InitializeComponent()
// GBASubMenu
//
this.GBASubMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
- this.GbaGpuViewerMenuItem,
+ this.GBACoreSelectionSubMenu,
+ this.GBAcoresettingsToolStripMenuItem1,
this.toolStripSeparator33,
- this.GBAcoresettingsToolStripMenuItem1});
+ this.GbaGpuViewerMenuItem});
this.GBASubMenu.Name = "GBASubMenu";
this.GBASubMenu.Size = new System.Drawing.Size(42, 19);
this.GBASubMenu.Text = "GBA";
//
- // GbaGpuViewerMenuItem
+ // GBACoreSelectionSubMenu
//
- this.GbaGpuViewerMenuItem.Name = "GbaGpuViewerMenuItem";
- this.GbaGpuViewerMenuItem.Size = new System.Drawing.Size(135, 22);
- this.GbaGpuViewerMenuItem.Text = "GPU Viewer";
- this.GbaGpuViewerMenuItem.Click += new System.EventHandler(this.GbaGpuViewerMenuItem_Click);
+ this.GBACoreSelectionSubMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.GBAmGBAMenuItem,
+ this.GBAVBANextMenuItem});
+ this.GBACoreSelectionSubMenu.Name = "GBACoreSelectionSubMenu";
+ this.GBACoreSelectionSubMenu.Size = new System.Drawing.Size(135, 22);
+ this.GBACoreSelectionSubMenu.Text = "&Core";
+ this.GBACoreSelectionSubMenu.DropDownOpened += new System.EventHandler(this.GBACoreSelectionSubMenu_DropDownOpened);
//
- // toolStripSeparator33
+ // GBAmGBAMenuItem
//
- this.toolStripSeparator33.Name = "toolStripSeparator33";
- this.toolStripSeparator33.Size = new System.Drawing.Size(132, 6);
+ this.GBAmGBAMenuItem.Name = "GBAmGBAMenuItem";
+ this.GBAmGBAMenuItem.Size = new System.Drawing.Size(125, 22);
+ this.GBAmGBAMenuItem.Text = "mGBA";
+ this.GBAmGBAMenuItem.Click += new System.EventHandler(this.GBAmGBAMenuItem_Click);
+ //
+ // GBAVBANextMenuItem
+ //
+ this.GBAVBANextMenuItem.Name = "GBAVBANextMenuItem";
+ this.GBAVBANextMenuItem.Size = new System.Drawing.Size(125, 22);
+ this.GBAVBANextMenuItem.Text = "&VBA-Next";
+ this.GBAVBANextMenuItem.Click += new System.EventHandler(this.GBAVBANextMenuItem_Click);
//
// GBAcoresettingsToolStripMenuItem1
//
@@ -2387,6 +2460,18 @@ private void InitializeComponent()
this.GBAcoresettingsToolStripMenuItem1.Text = "&Settings...";
this.GBAcoresettingsToolStripMenuItem1.Click += new System.EventHandler(this.GBAcoresettingsToolStripMenuItem1_Click);
//
+ // toolStripSeparator33
+ //
+ this.toolStripSeparator33.Name = "toolStripSeparator33";
+ this.toolStripSeparator33.Size = new System.Drawing.Size(132, 6);
+ //
+ // GbaGpuViewerMenuItem
+ //
+ this.GbaGpuViewerMenuItem.Name = "GbaGpuViewerMenuItem";
+ this.GbaGpuViewerMenuItem.Size = new System.Drawing.Size(135, 22);
+ this.GbaGpuViewerMenuItem.Text = "GPU Viewer";
+ this.GbaGpuViewerMenuItem.Click += new System.EventHandler(this.GbaGpuViewerMenuItem_Click);
+ //
// PSXSubMenu
//
this.PSXSubMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
@@ -2694,6 +2779,29 @@ private void InitializeComponent()
this.settingsToolStripMenuItem.Text = "&Settings...";
this.settingsToolStripMenuItem.Click += new System.EventHandler(this.WondersawnSettingsMenuItem_Click);
//
+ // AppleSubMenu
+ //
+ this.AppleSubMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.AppleDisksSubMenu});
+ this.AppleSubMenu.Name = "AppleSubMenu";
+ this.AppleSubMenu.Size = new System.Drawing.Size(50, 19);
+ this.AppleSubMenu.Text = "Apple";
+ this.AppleSubMenu.DropDownOpened += new System.EventHandler(this.AppleSubMenu_DropDownOpened);
+ //
+ // AppleDisksSubMenu
+ //
+ this.AppleDisksSubMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.toolStripSeparator31});
+ this.AppleDisksSubMenu.Name = "AppleDisksSubMenu";
+ this.AppleDisksSubMenu.Size = new System.Drawing.Size(101, 22);
+ this.AppleDisksSubMenu.Text = "Disks";
+ this.AppleDisksSubMenu.DropDownOpened += new System.EventHandler(this.AppleDisksSubMenu_DropDownOpened);
+ //
+ // toolStripSeparator31
+ //
+ this.toolStripSeparator31.Name = "toolStripSeparator31";
+ this.toolStripSeparator31.Size = new System.Drawing.Size(57, 6);
+ //
// HelpSubMenu
//
this.HelpSubMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
@@ -3364,12 +3472,12 @@ private void InitializeComponent()
this.ShowMenuContextMenuItem.Text = "Show Menu";
this.ShowMenuContextMenuItem.Click += new System.EventHandler(this.ShowMenuContextMenuItem_Click);
//
- // MacroToolMenuItem
+ // gBAWithMGBAToolStripMenuItem
//
- this.MacroToolMenuItem.Name = "MacroToolMenuItem";
- this.MacroToolMenuItem.Size = new System.Drawing.Size(183, 22);
- this.MacroToolMenuItem.Text = "&Macro Tool";
- this.MacroToolMenuItem.Click += new System.EventHandler(this.MacroToolMenuItem_Click);
+ this.gBAWithMGBAToolStripMenuItem.Name = "gBAWithMGBAToolStripMenuItem";
+ this.gBAWithMGBAToolStripMenuItem.Size = new System.Drawing.Size(210, 22);
+ this.gBAWithMGBAToolStripMenuItem.Text = "GBA with mGBA";
+ this.gBAWithMGBAToolStripMenuItem.Click += new System.EventHandler(this.gBAWithMGBAToolStripMenuItem_Click);
//
// MainForm
//
@@ -3657,7 +3765,6 @@ private void InitializeComponent()
private System.Windows.Forms.ToolStripMenuItem GBGameGenieMenuItem;
private System.Windows.Forms.ToolStripMenuItem GGGameGenieMenuItem;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator29;
- private System.Windows.Forms.ToolStripMenuItem CreateDualGbXmlMenuItem;
private System.Windows.Forms.ToolStripMenuItem N64SubMenu;
private System.Windows.Forms.ToolStripMenuItem N64PluginSettingsMenuItem;
private System.Windows.Forms.ToolStripMenuItem SaturnSubMenu;
@@ -3763,6 +3870,19 @@ private void InitializeComponent()
private System.Windows.Forms.ToolStripStatusLabel UpdateNotification;
private System.Windows.Forms.ToolStripMenuItem PSXControllerSettingsMenuItem;
private System.Windows.Forms.ToolStripMenuItem MacroToolMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem AppleSubMenu;
+ private System.Windows.Forms.ToolStripMenuItem AppleDisksSubMenu;
+ private System.Windows.Forms.ToolStripSeparator toolStripSeparator31;
+ private System.Windows.Forms.ToolStripMenuItem MultiDiskBundlerFileMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem musicRipperToolStripMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem coreToolStripMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem quickNESToolStripMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem nesHawkToolStripMenuItem;
+ private System.Windows.Forms.ToolStripSeparator toolStripSeparator34;
+ private System.Windows.Forms.ToolStripMenuItem GBACoreSelectionSubMenu;
+ private System.Windows.Forms.ToolStripMenuItem GBAmGBAMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem GBAVBANextMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem gBAWithMGBAToolStripMenuItem;
}
}
diff --git a/BizHawk.Client.EmuHawk/MainForm.Events.cs b/BizHawk.Client.EmuHawk/MainForm.Events.cs
index bc8e922b0a2..6bc1c7d565e 100644
--- a/BizHawk.Client.EmuHawk/MainForm.Events.cs
+++ b/BizHawk.Client.EmuHawk/MainForm.Events.cs
@@ -20,6 +20,7 @@
using BizHawk.Client.EmuHawk.CustomControls;
using BizHawk.Client.EmuHawk.WinFormExtensions;
using BizHawk.Client.EmuHawk.ToolExtensions;
+using BizHawk.Emulation.Cores.Computers.AppleII;
namespace BizHawk.Client.EmuHawk
{
@@ -747,7 +748,11 @@ private void DisplaySubtitlesMenuItem_Click(object sender, EventArgs e)
private void DisplayStatusBarMenuItem_Click(object sender, EventArgs e)
{
Global.Config.DisplayStatusBar ^= true;
+ SetStatusBar();
+ }
+ private void SetStatusBar()
+ {
if (!_inFullscreen)
{
MainStatusBar.Visible = Global.Config.DisplayStatusBar;
@@ -849,6 +854,8 @@ private void CoresSubMenu_DropDownOpened(object sender, EventArgs e)
NesInQuickNESMenuItem.Checked = Global.Config.NES_InQuickNES;
SnesWithSnes9xMenuItem.Checked = Global.Config.SNES_InSnes9x;
+ gBAWithMGBAToolStripMenuItem.Checked = Global.Config.GBA_UsemGBA;
+
SnesWithSnes9xMenuItem.Visible = VersionInfo.DeveloperBuild;
}
@@ -1167,25 +1174,6 @@ private void LuaConsoleMenuItem_Click(object sender, EventArgs e)
OpenLuaConsole();
}
- private void CreateDualGbXmlMenuItem_Click(object sender, EventArgs e)
- {
- GlobalWin.Sound.StopSound();
- using (var dlg = new DualGBXMLCreator())
- {
- var result = dlg.ShowDialog(this);
- if (result == DialogResult.OK)
- {
- GlobalWin.OSD.AddMessage("XML File saved");
- }
- else
- {
- GlobalWin.OSD.AddMessage("Dual GB creator aborted");
- }
- }
-
- GlobalWin.Sound.StartSound();
- }
-
private void batchRunnerToolStripMenuItem_Click(object sender, EventArgs e)
{
new BatchRun().ShowDialog();
@@ -1200,8 +1188,7 @@ private void NESSubMenu_DropDownOpened(object sender, EventArgs e)
FDSControlsMenuItem.Enabled = Global.Emulator.BoardName == "FDS";
NESSoundChannelsMenuItem.Enabled = GlobalWin.Tools.IsAvailable();
- MovieSettingsMenuItem.Enabled = GlobalWin.Tools.IsAvailable()
- && !Global.MovieSession.Movie.IsActive;
+ MovieSettingsMenuItem.Enabled = Global.Emulator is NES && !Global.MovieSession.Movie.IsActive;
NesControllerSettingsMenuItem.Enabled = GlobalWin.Tools.IsAvailable()
&& !Global.MovieSession.Movie.IsActive;
@@ -1238,6 +1225,11 @@ private void NESNametableViewerMenuItem_Click(object sender, EventArgs e)
GlobalWin.Tools.Load();
}
+ private void musicRipperToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ GlobalWin.Tools.Load();
+ }
+
private void NESGameGenieCodesMenuItem_Click(object sender, EventArgs e)
{
GlobalWin.Tools.LoadGameGenieEc();
@@ -1936,6 +1928,46 @@ private void WondersawnSettingsMenuItem_Click(object sender, EventArgs e)
#endregion
+ #region Apple II
+
+
+ private void AppleSubMenu_DropDownOpened(object sender, EventArgs e)
+ {
+ if (Global.Emulator is AppleII)
+ {
+ AppleDisksSubMenu.Enabled = (Global.Emulator as AppleII).DiskCount > 1;
+ }
+ }
+
+ private void AppleDisksSubMenu_DropDownOpened(object sender, EventArgs e)
+ {
+ AppleDisksSubMenu.DropDownItems.Clear();
+
+ if (Global.Emulator is AppleII)
+ {
+ var appleII = Global.Emulator as AppleII;
+ for (int i = 0; i < appleII.DiskCount; i++)
+ {
+ var menuItem = new ToolStripMenuItem
+ {
+ Name = "Disk" + (i + 1),
+ Text = "Disk" + (i + 1),
+ Checked = appleII.CurrentDisk == i
+ };
+
+ int dummy = i;
+ menuItem.Click += (o, ev) =>
+ {
+ appleII.SetDisk(dummy);
+ };
+
+ AppleDisksSubMenu.DropDownItems.Add(menuItem);
+ }
+ }
+ }
+
+ #endregion
+
#region Help
private void OnlineHelpMenuItem_Click(object sender, EventArgs e)
diff --git a/BizHawk.Client.EmuHawk/MainForm.cs b/BizHawk.Client.EmuHawk/MainForm.cs
index 95249115948..ae41939cb91 100644
--- a/BizHawk.Client.EmuHawk/MainForm.cs
+++ b/BizHawk.Client.EmuHawk/MainForm.cs
@@ -64,6 +64,7 @@ private void MainForm_Load(object sender, EventArgs e)
}
HandleToggleLightAndLink();
+ SetStatusBar();
// New version notification
UpdateChecker.CheckComplete += (s2, e2) =>
@@ -1393,7 +1394,7 @@ private static void LoadSaveRam()
// GBA meteor core might not know how big the saveram ought to be, so just send it the whole file
// GBA vba-next core will try to eat anything, regardless of size
- if (Global.Emulator is GBA || Global.Emulator is VBANext)
+ if (Global.Emulator is GBA || Global.Emulator is VBANext || Global.Emulator is MGBAHawk)
{
sram = File.ReadAllBytes(PathManager.SaveRamPath(Global.Game));
}
@@ -1510,6 +1511,7 @@ private void HandlePlatformMenus()
DGBSubMenu.Visible = false;
GenesisSubMenu.Visible = false;
wonderSwanToolStripMenuItem.Visible = false;
+ AppleSubMenu.Visible = false;
switch (system)
{
@@ -1587,6 +1589,9 @@ private void HandlePlatformMenus()
case "WSWAN":
wonderSwanToolStripMenuItem.Visible = true;
break;
+ case "AppleII":
+ AppleSubMenu.Visible = true;
+ break;
}
}
@@ -1846,44 +1851,43 @@ private static string FormatFilter(params string[] args)
return str;
}
- private void OpenRom()
+ public static string RomFilter
{
- var ofd = new OpenFileDialog { InitialDirectory = PathManager.GetRomsPath(Global.Emulator.SystemId) };
-
- // adelikat: ugly design for this, I know
- if (VersionInfo.DeveloperBuild)
- {
- ofd.Filter = FormatFilter(
- "Rom Files", "*.nes;*.fds;*.sms;*.gg;*.sg;*.pce;*.sgx;*.bin;*.smd;*.rom;*.a26;*.a78;*.lnx;*.m3u;*.cue;*.ccd;*.exe;*.gb;*.gbc;*.gba;*.gen;*.md;*.col;.int;*.smc;*.sfc;*.prg;*.d64;*.g64;*.crt;*.sgb;*.xml;*.z64;*.v64;*.n64;*.ws;*.wsc;%ARCH%",
- "Music Files", "*.psf;*.sid;*.nsf",
- "Disc Images", "*.cue;*.ccd;*.m3u",
- "NES", "*.nes;*.fds;*.nsf;%ARCH%",
- "Super NES", "*.smc;*.sfc;*.xml;%ARCH%",
- "Master System", "*.sms;*.gg;*.sg;%ARCH%",
- "PC Engine", "*.pce;*.sgx;*.cue;*.ccd;%ARCH%",
- "TI-83", "*.rom;%ARCH%",
- "Archive Files", "%ARCH%",
- "Savestate", "*.state",
- "Atari 2600", "*.a26;*.bin;%ARCH%",
- "Atari 7800", "*.a78;*.bin;%ARCH%",
- "Atari Lynx", "*.lnx;%ARCH%",
- "Genesis", "*.gen;*.smd;*.bin;*.md;*.cue;*.ccd;%ARCH%",
- "Gameboy", "*.gb;*.gbc;*.sgb;%ARCH%",
- "Gameboy Advance", "*.gba;%ARCH%",
- "Colecovision", "*.col;%ARCH%",
- "Intellivision (very experimental)", "*.int;*.bin;*.rom;%ARCH%",
- "PSX Executables (experimental)", "*.exe",
- "PSF Playstation Sound File (not supported)", "*.psf",
- "Commodore 64 (experimental)", "*.prg; *.d64, *.g64; *.crt;%ARCH%",
- "SID Commodore 64 Music File", "*.sid;%ARCH%",
- "Nintendo 64", "*.z64;*.v64;*.n64",
- "WonderSwan", "*.ws;*.wsc;%ARCH%",
- "All Files", "*.*");
- }
- else
+ get
{
- ofd.Filter = FormatFilter(
- "Rom Files", "*.nes;*.fds;*.sms;*.gg;*.sg;*.gb;*.gbc;*.gba;*.pce;*.sgx;*.bin;*.smd;*.gen;*.md;*.smc;*.sfc;*.a26;*.a78;*.lnx;*.col;*.rom;*.cue;*.ccd;*.sgb;*.z64;*.v64;*.n64;*.ws;*.wsc;*.xml;%ARCH%",
+ if (VersionInfo.DeveloperBuild)
+ {
+ return FormatFilter(
+ "Rom Files", "*.nes;*.fds;*.sms;*.gg;*.sg;*.pce;*.sgx;*.bin;*.smd;*.rom;*.a26;*.a78;*.lnx;*.m3u;*.cue;*.ccd;*.exe;*.gb;*.gbc;*.gba;*.gen;*.md;*.col;.int;*.smc;*.sfc;*.prg;*.d64;*.g64;*.crt;*.sgb;*.xml;*.z64;*.v64;*.n64;*.ws;*.wsc;*.dsk;*.do;*.po;%ARCH%",
+ "Music Files", "*.psf;*.sid;*.nsf",
+ "Disc Images", "*.cue;*.ccd;*.m3u",
+ "NES", "*.nes;*.fds;*.nsf;%ARCH%",
+ "Super NES", "*.smc;*.sfc;*.xml;%ARCH%",
+ "Master System", "*.sms;*.gg;*.sg;%ARCH%",
+ "PC Engine", "*.pce;*.sgx;*.cue;*.ccd;%ARCH%",
+ "TI-83", "*.rom;%ARCH%",
+ "Archive Files", "%ARCH%",
+ "Savestate", "*.state",
+ "Atari 2600", "*.a26;*.bin;%ARCH%",
+ "Atari 7800", "*.a78;*.bin;%ARCH%",
+ "Atari Lynx", "*.lnx;%ARCH%",
+ "Genesis", "*.gen;*.smd;*.bin;*.md;*.cue;*.ccd;%ARCH%",
+ "Gameboy", "*.gb;*.gbc;*.sgb;%ARCH%",
+ "Gameboy Advance", "*.gba;%ARCH%",
+ "Colecovision", "*.col;%ARCH%",
+ "Intellivision (very experimental)", "*.int;*.bin;*.rom;%ARCH%",
+ "PSX Executables (experimental)", "*.exe",
+ "PSF Playstation Sound File (not supported)", "*.psf",
+ "Commodore 64 (experimental)", "*.prg; *.d64, *.g64; *.crt;%ARCH%",
+ "SID Commodore 64 Music File", "*.sid;%ARCH%",
+ "Nintendo 64", "*.z64;*.v64;*.n64",
+ "WonderSwan", "*.ws;*.wsc;%ARCH%",
+ "Apple II", "*.dsk;*.do;*.po;%ARCH%",
+ "All Files", "*.*");
+ }
+
+ return FormatFilter(
+ "Rom Files", "*.nes;*.fds;*.sms;*.gg;*.sg;*.gb;*.gbc;*.gba;*.pce;*.sgx;*.bin;*.smd;*.gen;*.md;*.smc;*.sfc;*.a26;*.a78;*.lnx;*.col;*.rom;*.cue;*.ccd;*.sgb;*.z64;*.v64;*.n64;*.ws;*.wsc;*.xml;*.dsk;*.do;*.po;%ARCH%",
"Disc Images", "*.cue;*.ccd;*.m3u",
"NES", "*.nes;*.fds;*.nsf;%ARCH%",
"Super NES", "*.smc;*.sfc;*.xml;%ARCH%",
@@ -1901,11 +1905,20 @@ private void OpenRom()
"Savestate", "*.state",
"Genesis", "*.gen;*.md;*.smd;*.bin;*.cue;*.ccd;%ARCH%",
"WonderSwan", "*.ws;*.wsc;%ARCH%",
+ "Apple II", "*.dsk;*.do;*.po;%ARCH%",
"All Files", "*.*");
}
+ }
- ofd.RestoreDirectory = false;
- ofd.FilterIndex = _lastOpenRomFilter;
+ private void OpenRom()
+ {
+ var ofd = new OpenFileDialog
+ {
+ InitialDirectory = PathManager.GetRomsPath(Global.Emulator.SystemId),
+ Filter = RomFilter,
+ RestoreDirectory = false,
+ FilterIndex = _lastOpenRomFilter
+ };
var result = ofd.ShowHawkDialog();
if (result != DialogResult.OK)
@@ -3712,5 +3725,52 @@ private void HelpSubMenu_DropDownOpened(object sender, EventArgs e)
{
FeaturesMenuItem.Visible = VersionInfo.DeveloperBuild;
}
+
+ private void CreateMultigameFileMenuItem_Click(object sender, EventArgs e)
+ {
+ GlobalWin.Tools.Load();
+ }
+
+ private void coreToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
+ {
+ quickNESToolStripMenuItem.Checked = Global.Config.NES_InQuickNES == true;
+ nesHawkToolStripMenuItem.Checked = Global.Config.NES_InQuickNES == false;
+ }
+
+ private void quickNESToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ Global.Config.NES_InQuickNES = true;
+ FlagNeedsReboot();
+ }
+
+ private void nesHawkToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ Global.Config.NES_InQuickNES = false;
+ FlagNeedsReboot();
+ }
+
+ private void GBAmGBAMenuItem_Click(object sender, EventArgs e)
+ {
+ Global.Config.GBA_UsemGBA = true;
+ FlagNeedsReboot();
+ }
+
+ private void GBAVBANextMenuItem_Click(object sender, EventArgs e)
+ {
+ Global.Config.GBA_UsemGBA = false;
+ FlagNeedsReboot();
+ }
+
+ private void GBACoreSelectionSubMenu_DropDownOpened(object sender, EventArgs e)
+ {
+ GBAmGBAMenuItem.Checked = Global.Config.GBA_UsemGBA == true;
+ GBAVBANextMenuItem.Checked = Global.Config.GBA_UsemGBA == false;
+ }
+
+ private void gBAWithMGBAToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ Global.Config.GBA_UsemGBA ^= true;
+ FlagNeedsReboot();
+ }
}
}
diff --git a/BizHawk.Client.EmuHawk/Properties/Resources.Designer.cs b/BizHawk.Client.EmuHawk/Properties/Resources.Designer.cs
index a7428f7ac50..eca6ee3edb3 100644
--- a/BizHawk.Client.EmuHawk/Properties/Resources.Designer.cs
+++ b/BizHawk.Client.EmuHawk/Properties/Resources.Designer.cs
@@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
//
// This code was generated by a tool.
-// Runtime Version:4.0.30319.34209
+// Runtime Version:4.0.30319.0
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@@ -100,6 +100,16 @@ internal static System.Drawing.Bitmap alt_about_image {
}
}
+ ///
+ /// Looks up a localized resource of type System.Drawing.Bitmap.
+ ///
+ internal static System.Drawing.Bitmap AppleIIKeyboard {
+ get {
+ object obj = ResourceManager.GetObject("AppleIIKeyboard", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
///
/// Looks up a localized resource of type System.Drawing.Bitmap.
///
diff --git a/BizHawk.Client.EmuHawk/Properties/Resources.resx b/BizHawk.Client.EmuHawk/Properties/Resources.resx
index cd949e296c2..1694f478580 100644
--- a/BizHawk.Client.EmuHawk/Properties/Resources.resx
+++ b/BizHawk.Client.EmuHawk/Properties/Resources.resx
@@ -1491,4 +1491,7 @@
..\images\HawkInLove.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+ ..\images\ControllerImages\AppleIIKeyboard.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
\ No newline at end of file
diff --git a/BizHawk.Client.EmuHawk/config/ControllerConfig.cs b/BizHawk.Client.EmuHawk/config/ControllerConfig.cs
index 1718b59d062..c444df97599 100644
--- a/BizHawk.Client.EmuHawk/config/ControllerConfig.cs
+++ b/BizHawk.Client.EmuHawk/config/ControllerConfig.cs
@@ -44,6 +44,7 @@ static ControllerConfig()
ControllerImages.Add("Lynx Controller", Properties.Resources.Lynx);
ControllerImages.Add("PSX Gamepad Controller", Properties.Resources.PSX_Original_Controller);
ControllerImages.Add("PSX DualShock Controller", Properties.Resources.psx_dualshock);
+ ControllerImages.Add("Apple IIe Keyboard", Properties.Resources.AppleIIKeyboard);
}
diff --git a/BizHawk.Client.EmuHawk/config/FirmwaresConfig.cs b/BizHawk.Client.EmuHawk/config/FirmwaresConfig.cs
index e3cdf32cfdf..e4d783cf263 100644
--- a/BizHawk.Client.EmuHawk/config/FirmwaresConfig.cs
+++ b/BizHawk.Client.EmuHawk/config/FirmwaresConfig.cs
@@ -48,6 +48,7 @@ public partial class FirmwaresConfig : Form
{ "SMS", "Sega Master System" },
{ "PSX", "Sony PlayStation" },
{ "Lynx", "Atari Lynx" },
+ { "AppleII", "Apple II" }
};
public string TargetSystem = null;
diff --git a/BizHawk.Client.EmuHawk/images/ControllerImages/AppleIIKeyboard.png b/BizHawk.Client.EmuHawk/images/ControllerImages/AppleIIKeyboard.png
new file mode 100644
index 00000000000..519910281d6
Binary files /dev/null and b/BizHawk.Client.EmuHawk/images/ControllerImages/AppleIIKeyboard.png differ
diff --git a/BizHawk.Client.EmuHawk/tools/GB/DualGBXMLCreator.Designer.cs b/BizHawk.Client.EmuHawk/tools/GB/DualGBXMLCreator.Designer.cs
deleted file mode 100644
index 1cc066773f4..00000000000
--- a/BizHawk.Client.EmuHawk/tools/GB/DualGBXMLCreator.Designer.cs
+++ /dev/null
@@ -1,251 +0,0 @@
-namespace BizHawk.Client.EmuHawk
-{
- partial class DualGBXMLCreator
- {
- ///
- /// Required designer variable.
- ///
- private System.ComponentModel.IContainer components = null;
-
- ///
- /// Clean up any resources being used.
- ///
- /// true if managed resources should be disposed; otherwise, false.
- protected override void Dispose(bool disposing)
- {
- if (disposing && (components != null))
- {
- components.Dispose();
- }
- base.Dispose(disposing);
- }
-
- #region Windows Form Designer generated code
-
- ///
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- ///
- private void InitializeComponent()
- {
- System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(DualGBXMLCreator));
- this.groupBox1 = new System.Windows.Forms.GroupBox();
- this.groupBox2 = new System.Windows.Forms.GroupBox();
- this.groupBox3 = new System.Windows.Forms.GroupBox();
- this.textBoxName = new System.Windows.Forms.TextBox();
- this.buttonCancel = new System.Windows.Forms.Button();
- this.groupBox4 = new System.Windows.Forms.GroupBox();
- this.textBoxOutputDir = new System.Windows.Forms.TextBox();
- this.groupBox5 = new System.Windows.Forms.GroupBox();
- this.textBoxXML = new System.Windows.Forms.TextBox();
- this.SaveRunButton = new System.Windows.Forms.Button();
- this.CurrentForAllButton = new System.Windows.Forms.Button();
- this.dualGBFileSelector2 = new BizHawk.Client.EmuHawk.DualGBFileSelector();
- this.dualGBFileSelector1 = new BizHawk.Client.EmuHawk.DualGBFileSelector();
- this.groupBox1.SuspendLayout();
- this.groupBox2.SuspendLayout();
- this.groupBox3.SuspendLayout();
- this.groupBox4.SuspendLayout();
- this.groupBox5.SuspendLayout();
- this.SuspendLayout();
- //
- // groupBox1
- //
- this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.groupBox1.Controls.Add(this.dualGBFileSelector1);
- this.groupBox1.Location = new System.Drawing.Point(12, 12);
- this.groupBox1.Name = "groupBox1";
- this.groupBox1.Size = new System.Drawing.Size(432, 54);
- this.groupBox1.TabIndex = 0;
- this.groupBox1.TabStop = false;
- this.groupBox1.Text = "Left Rom";
- //
- // groupBox2
- //
- this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.groupBox2.Controls.Add(this.dualGBFileSelector2);
- this.groupBox2.Location = new System.Drawing.Point(12, 72);
- this.groupBox2.Name = "groupBox2";
- this.groupBox2.Size = new System.Drawing.Size(432, 54);
- this.groupBox2.TabIndex = 1;
- this.groupBox2.TabStop = false;
- this.groupBox2.Text = "Right Rom";
- //
- // groupBox3
- //
- this.groupBox3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.groupBox3.Controls.Add(this.textBoxName);
- this.groupBox3.Location = new System.Drawing.Point(12, 132);
- this.groupBox3.Name = "groupBox3";
- this.groupBox3.Size = new System.Drawing.Size(432, 45);
- this.groupBox3.TabIndex = 3;
- this.groupBox3.TabStop = false;
- this.groupBox3.Text = "Name";
- //
- // textBoxName
- //
- this.textBoxName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.textBoxName.Location = new System.Drawing.Point(6, 19);
- this.textBoxName.Name = "textBoxName";
- this.textBoxName.Size = new System.Drawing.Size(420, 20);
- this.textBoxName.TabIndex = 0;
- this.textBoxName.TextChanged += new System.EventHandler(this.textBoxName_TextChanged);
- //
- // buttonCancel
- //
- this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
- this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
- this.buttonCancel.Location = new System.Drawing.Point(384, 477);
- this.buttonCancel.Name = "buttonCancel";
- this.buttonCancel.Size = new System.Drawing.Size(60, 23);
- this.buttonCancel.TabIndex = 7;
- this.buttonCancel.Text = "&Cancel";
- this.buttonCancel.UseVisualStyleBackColor = true;
- this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
- //
- // groupBox4
- //
- this.groupBox4.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.groupBox4.Controls.Add(this.textBoxOutputDir);
- this.groupBox4.Location = new System.Drawing.Point(12, 183);
- this.groupBox4.Name = "groupBox4";
- this.groupBox4.Size = new System.Drawing.Size(432, 45);
- this.groupBox4.TabIndex = 5;
- this.groupBox4.TabStop = false;
- this.groupBox4.Text = "Output Directory";
- //
- // textBoxOutputDir
- //
- this.textBoxOutputDir.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.textBoxOutputDir.Location = new System.Drawing.Point(6, 19);
- this.textBoxOutputDir.Name = "textBoxOutputDir";
- this.textBoxOutputDir.ReadOnly = true;
- this.textBoxOutputDir.Size = new System.Drawing.Size(420, 20);
- this.textBoxOutputDir.TabIndex = 4;
- //
- // groupBox5
- //
- this.groupBox5.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
- | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.groupBox5.Controls.Add(this.textBoxXML);
- this.groupBox5.Location = new System.Drawing.Point(12, 234);
- this.groupBox5.Name = "groupBox5";
- this.groupBox5.Size = new System.Drawing.Size(432, 237);
- this.groupBox5.TabIndex = 6;
- this.groupBox5.TabStop = false;
- this.groupBox5.Text = "XML Preview";
- //
- // textBoxXML
- //
- this.textBoxXML.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
- | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.textBoxXML.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
- this.textBoxXML.Location = new System.Drawing.Point(6, 19);
- this.textBoxXML.Multiline = true;
- this.textBoxXML.Name = "textBoxXML";
- this.textBoxXML.ReadOnly = true;
- this.textBoxXML.ScrollBars = System.Windows.Forms.ScrollBars.Both;
- this.textBoxXML.Size = new System.Drawing.Size(420, 212);
- this.textBoxXML.TabIndex = 5;
- this.textBoxXML.WordWrap = false;
- //
- // SaveRunButton
- //
- this.SaveRunButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
- this.SaveRunButton.Enabled = false;
- this.SaveRunButton.Location = new System.Drawing.Point(293, 477);
- this.SaveRunButton.Name = "SaveRunButton";
- this.SaveRunButton.Size = new System.Drawing.Size(85, 23);
- this.SaveRunButton.TabIndex = 8;
- this.SaveRunButton.Text = "&Save and Run";
- this.SaveRunButton.UseVisualStyleBackColor = true;
- this.SaveRunButton.Click += new System.EventHandler(this.SaveRunButton_Click);
- //
- // CurrentForAllButton
- //
- this.CurrentForAllButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
- this.CurrentForAllButton.Location = new System.Drawing.Point(12, 477);
- this.CurrentForAllButton.Name = "CurrentForAllButton";
- this.CurrentForAllButton.Size = new System.Drawing.Size(128, 23);
- this.CurrentForAllButton.TabIndex = 9;
- this.CurrentForAllButton.Text = "Use Current Rom for All";
- this.CurrentForAllButton.UseVisualStyleBackColor = true;
- this.CurrentForAllButton.Click += new System.EventHandler(this.CurrentForAllButton_Click);
- //
- // dualGBFileSelector2
- //
- this.dualGBFileSelector2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.dualGBFileSelector2.Location = new System.Drawing.Point(6, 19);
- this.dualGBFileSelector2.Name = "dualGBFileSelector2";
- this.dualGBFileSelector2.Size = new System.Drawing.Size(420, 29);
- this.dualGBFileSelector2.TabIndex = 1;
- this.dualGBFileSelector2.NameChanged += new System.EventHandler(this.dualGBFileSelector2_NameChanged);
- //
- // dualGBFileSelector1
- //
- this.dualGBFileSelector1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.dualGBFileSelector1.Location = new System.Drawing.Point(6, 19);
- this.dualGBFileSelector1.Name = "dualGBFileSelector1";
- this.dualGBFileSelector1.Size = new System.Drawing.Size(420, 29);
- this.dualGBFileSelector1.TabIndex = 0;
- this.dualGBFileSelector1.NameChanged += new System.EventHandler(this.dualGBFileSelector1_NameChanged);
- //
- // DualGBXMLCreator
- //
- this.AcceptButton = this.SaveRunButton;
- this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.CancelButton = this.buttonCancel;
- this.ClientSize = new System.Drawing.Size(456, 512);
- this.Controls.Add(this.CurrentForAllButton);
- this.Controls.Add(this.SaveRunButton);
- this.Controls.Add(this.groupBox5);
- this.Controls.Add(this.groupBox4);
- this.Controls.Add(this.buttonCancel);
- this.Controls.Add(this.groupBox3);
- this.Controls.Add(this.groupBox2);
- this.Controls.Add(this.groupBox1);
- this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
- this.Name = "DualGBXMLCreator";
- this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
- this.Text = "Create Dual Gameboy XML";
- this.Load += new System.EventHandler(this.DualGBXMLCreator_Load);
- this.groupBox1.ResumeLayout(false);
- this.groupBox2.ResumeLayout(false);
- this.groupBox3.ResumeLayout(false);
- this.groupBox3.PerformLayout();
- this.groupBox4.ResumeLayout(false);
- this.groupBox4.PerformLayout();
- this.groupBox5.ResumeLayout(false);
- this.groupBox5.PerformLayout();
- this.ResumeLayout(false);
-
- }
-
- #endregion
-
- private System.Windows.Forms.GroupBox groupBox1;
- private DualGBFileSelector dualGBFileSelector1;
- private System.Windows.Forms.GroupBox groupBox2;
- private DualGBFileSelector dualGBFileSelector2;
- private System.Windows.Forms.GroupBox groupBox3;
- private System.Windows.Forms.TextBox textBoxName;
- private System.Windows.Forms.Button buttonCancel;
- private System.Windows.Forms.GroupBox groupBox4;
- private System.Windows.Forms.TextBox textBoxOutputDir;
- private System.Windows.Forms.GroupBox groupBox5;
- private System.Windows.Forms.TextBox textBoxXML;
- private System.Windows.Forms.Button SaveRunButton;
- private System.Windows.Forms.Button CurrentForAllButton;
- }
-}
\ No newline at end of file
diff --git a/BizHawk.Client.EmuHawk/tools/GB/DualGBXMLCreator.cs b/BizHawk.Client.EmuHawk/tools/GB/DualGBXMLCreator.cs
deleted file mode 100644
index e16bf5a50bc..00000000000
--- a/BizHawk.Client.EmuHawk/tools/GB/DualGBXMLCreator.cs
+++ /dev/null
@@ -1,194 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Windows.Forms;
-using System.IO;
-using BizHawk.Client.Common;
-using BizHawk.Emulation.Cores.Nintendo.Gameboy;
-
-namespace BizHawk.Client.EmuHawk
-{
- public partial class DualGBXMLCreator : Form
- {
- private bool _suspendRecalculate = false;
-
- public DualGBXMLCreator()
- {
- InitializeComponent();
- }
-
- // http://stackoverflow.com/questions/275689/how-to-get-relative-path-from-absolute-path
- public static string GetRelativePath(string fromPath, string toPath)
- {
- Win32.FileAttributes fromAttr = GetPathAttribute(fromPath);
- Win32.FileAttributes toAttr = GetPathAttribute(toPath);
-
- var path = new StringBuilder(260); // MAX_PATH
- if (Win32.PathRelativePathTo(
- path,
- fromPath,
- fromAttr,
- toPath,
- toAttr) == false)
- {
- throw new ArgumentException("Paths must have a common prefix");
- }
-
- return path.ToString();
- }
-
- private static Win32.FileAttributes GetPathAttribute(string path)
- {
- var di = new DirectoryInfo(path.Split('|').First());
- if (di.Exists)
- {
- return Win32.FileAttributes.Directory;
- }
-
- var fi = new FileInfo(path.Split('|').First());
- if (fi.Exists)
- {
- return Win32.FileAttributes.Normal;
- }
-
- throw new FileNotFoundException();
- }
-
- private bool Recalculate()
- {
- if (_suspendRecalculate)
- {
- return false;
- }
-
- try
- {
- var PathLeft = dualGBFileSelector1.GetName();
- var PathRight = dualGBFileSelector2.GetName();
- var Name = textBoxName.Text;
-
- if (string.IsNullOrWhiteSpace(PathLeft) ||
- string.IsNullOrWhiteSpace(PathRight) ||
- string.IsNullOrWhiteSpace(Name))
- {
- throw new Exception("Blank Names");
- }
-
- var NewPathL = new List();
-
- for (int i = 0; i < PathLeft.Length && i < PathRight.Length; i++)
- {
- if (PathLeft[i] == PathRight[i])
- {
- NewPathL.Add(PathLeft[i]);
- }
- else
- {
- break;
- }
- }
-
- var BasePath = new string(NewPathL.ToArray());
- if (string.IsNullOrWhiteSpace(BasePath))
- {
- throw new Exception("Common path?");
- }
-
- BasePath = Path.GetDirectoryName(BasePath.Split('|').First());
- PathLeft = GetRelativePath(BasePath, PathLeft);
- PathRight = GetRelativePath(BasePath, PathRight);
-
- BasePath = Path.Combine(BasePath, Name) + ".xml";
-
- var XML = new StringWriter();
- XML.WriteLine("");
- XML.WriteLine("", Name);
- XML.WriteLine(" ");
- XML.WriteLine(" ", PathLeft);
- XML.WriteLine(" ", PathRight);
- XML.WriteLine(" ");
- XML.WriteLine("");
-
- textBoxOutputDir.Text = BasePath;
- textBoxXML.Text = XML.ToString();
- SaveRunButton.Enabled = true;
- return true;
- }
- catch (Exception e)
- {
- textBoxOutputDir.Text = string.Empty;
- textBoxXML.Text = "Failed!\n" + e;
- SaveRunButton.Enabled = false;
- return false;
- }
- }
-
- private void textBoxName_TextChanged(object sender, EventArgs e)
- {
- Recalculate();
- }
-
- private void dualGBFileSelector1_NameChanged(object sender, EventArgs e)
- {
- Recalculate();
- }
-
- private void dualGBFileSelector2_NameChanged(object sender, EventArgs e)
- {
- Recalculate();
- }
-
- private void DualGBXMLCreator_Load(object sender, EventArgs e)
- {
- CurrentForAllButton.Enabled = Global.Emulator != null && // For the designer
- (Global.Emulator is Gameboy) &&
- !string.IsNullOrEmpty(GlobalWin.MainForm.CurrentlyOpenRom) &&
- !GlobalWin.MainForm.CurrentlyOpenRom.Contains('|') && // Can't be archive
- !GlobalWin.MainForm.CurrentlyOpenRom.Contains(".xml"); // Can't already be an xml
- }
-
- private void SaveRunButton_Click(object sender, EventArgs e)
- {
- if (Recalculate())
- {
- var fileInfo = new FileInfo(textBoxOutputDir.Text);
-
- if (fileInfo.Exists)
- {
- var result = MessageBox.Show(this, "File already exists, overwrite?", "File exists", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
- if (result != DialogResult.OK)
- {
- return;
- }
- }
- using (var sw = new StreamWriter(textBoxOutputDir.Text))
- {
- sw.Write(textBoxXML.Text);
- }
-
- DialogResult = DialogResult.OK;
- Close();
- GlobalWin.MainForm.LoadRom(textBoxOutputDir.Text);
- }
- }
-
- private void CurrentForAllButton_Click(object sender, EventArgs e)
- {
- _suspendRecalculate = true;
- dualGBFileSelector1.SetName(GlobalWin.MainForm.CurrentlyOpenRom);
- dualGBFileSelector2.SetName(GlobalWin.MainForm.CurrentlyOpenRom);
-
- textBoxName.Text = Path.GetFileNameWithoutExtension(GlobalWin.MainForm.CurrentlyOpenRom);
- _suspendRecalculate = false;
-
- Recalculate();
- }
-
- private void buttonCancel_Click(object sender, EventArgs e)
- {
- DialogResult = DialogResult.Cancel;
- Close();
- }
- }
-}
diff --git a/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Client.cs b/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Client.cs
index 4a83c02ddec..ceb3afa6974 100644
--- a/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Client.cs
+++ b/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Client.cs
@@ -1,11 +1,14 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
+using System.Linq;
using LuaInterface;
+using BizHawk.Common;
using BizHawk.Emulation.Common;
using BizHawk.Client.Common;
+
namespace BizHawk.Client.EmuHawk
{
[Description("A library for manipulating the EmuHawk client UI")]
@@ -415,5 +418,63 @@ public static int Ypos()
{
return GlobalWin.MainForm.DesktopLocation.Y;
}
+
+ [LuaMethodAttributes(
+ "getavailabletools",
+ "Returns a list of the tools currently open"
+ )]
+ public LuaTable GetAvailableTools()
+ {
+ var t = Lua.NewTable();
+ var tools = GlobalWin.Tools.AvailableTools.ToList();
+ for (int i = 0; i < tools.Count; i++)
+ {
+ t[i] = tools[i].Name.ToLower();
+ }
+
+ return t;
+ }
+
+ [LuaMethodAttributes(
+ "gettool",
+ "Returns an object that represents a tool of the given name (not case sensitive). If the tool is not open, it will be loaded if available. Use gettools to get a list of names"
+ )]
+ public LuaTable GetTool(string name)
+ {
+ var toolType = ReflectionUtil.GetTypeByName(name)
+ .FirstOrDefault(x => typeof(IToolForm).IsAssignableFrom(x) && !x.IsInterface);
+
+ if (toolType != null)
+ {
+ GlobalWin.Tools.Load(toolType);
+ }
+
+ var selectedTool = GlobalWin.Tools.AvailableTools
+ .FirstOrDefault(tool => tool.GetType().Name.ToLower() == name.ToLower());
+
+ if (selectedTool != null)
+ {
+ return LuaHelper.ToLuaTable(Lua, selectedTool);
+ }
+
+ return null;
+ }
+
+ [LuaMethodAttributes(
+ "createinstance",
+ "returns a default instance of the given type of object if it exists (not case sensitive). Note: This will only work on objects which have a parameterless constructor. If no suitable type is found, or the type does not have a parameterless constructor, then nil is returned"
+ )]
+ public LuaTable CreateInstance(string name)
+ {
+ var possibleTypes = ReflectionUtil.GetTypeByName(name);
+
+ if (possibleTypes.Any())
+ {
+ var instance = Activator.CreateInstance(possibleTypes.First());
+ return LuaHelper.ToLuaTable(Lua, instance);
+ }
+
+ return null;
+ }
}
}
diff --git a/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Gui.cs b/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Gui.cs
index a991a4be3de..d6d71faa468 100644
--- a/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Gui.cs
+++ b/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Gui.cs
@@ -596,5 +596,16 @@ public void Text(
GlobalWin.OSD.AddGUIText(message, x, y, background ?? Color.Black, forecolor ?? Color.White, a);
}
+
+ [LuaMethodAttributes(
+ "createcanvas",
+ "Creates a canvas of the given size."
+ )]
+ public LuaTable Text(int width, int height)
+ {
+ var canvas = new LuaCanvas(width, height);
+ canvas.Show();
+ return LuaHelper.ToLuaTable(Lua, canvas);
+ }
}
}
diff --git a/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Savestate.cs b/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Savestate.cs
index ce23c97d81c..f1aaec75a10 100644
--- a/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Savestate.cs
+++ b/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Savestate.cs
@@ -22,7 +22,14 @@ public SavestateLuaLibrary(Lua lua, Action logOutputCallback)
)]
public void Load(string path)
{
- GlobalWin.MainForm.LoadState(path, Path.GetFileName(path), true);
+ if (!File.Exists(path))
+ {
+ Log(string.Format("could not find file: {0}", path));
+ }
+ else
+ {
+ GlobalWin.MainForm.LoadState(path, Path.GetFileName(path), true);
+ }
}
[LuaMethodAttributes(
diff --git a/BizHawk.Client.EmuHawk/tools/Lua/LuaCanvas.Designer.cs b/BizHawk.Client.EmuHawk/tools/Lua/LuaCanvas.Designer.cs
new file mode 100644
index 00000000000..5e893f83a2f
--- /dev/null
+++ b/BizHawk.Client.EmuHawk/tools/Lua/LuaCanvas.Designer.cs
@@ -0,0 +1,66 @@
+namespace BizHawk.Client.EmuHawk
+{
+ partial class LuaCanvas
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.pictureBox = new System.Windows.Forms.PictureBox();
+ ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
+ this.SuspendLayout();
+ //
+ // pictureBox
+ //
+ this.pictureBox.Location = new System.Drawing.Point(0, 0);
+ this.pictureBox.Margin = new System.Windows.Forms.Padding(0);
+ this.pictureBox.Name = "pictureBox";
+ this.pictureBox.Size = new System.Drawing.Size(282, 260);
+ this.pictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
+ this.pictureBox.TabIndex = 0;
+ this.pictureBox.TabStop = false;
+ //
+ // LuaCanvas
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.AutoSize = true;
+ this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
+ this.ClientSize = new System.Drawing.Size(284, 261);
+ this.Controls.Add(this.pictureBox);
+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
+ this.Name = "LuaCanvas";
+ this.Text = "LuaCanvas";
+ ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.PictureBox pictureBox;
+ }
+}
\ No newline at end of file
diff --git a/BizHawk.Client.EmuHawk/tools/Lua/LuaCanvas.cs b/BizHawk.Client.EmuHawk/tools/Lua/LuaCanvas.cs
new file mode 100644
index 00000000000..0e15cfa72c1
--- /dev/null
+++ b/BizHawk.Client.EmuHawk/tools/Lua/LuaCanvas.cs
@@ -0,0 +1,88 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Windows.Forms;
+
+namespace BizHawk.Client.EmuHawk
+{
+ public partial class LuaCanvas : Form
+ {
+ private Graphics graphics;
+
+ public LuaCanvas(int width, int height)
+ {
+ InitializeComponent();
+ pictureBox.Width = width;
+ pictureBox.Height = height;
+ pictureBox.Image = new Bitmap(width, height);
+ graphics = Graphics.FromImage(pictureBox.Image);
+ }
+
+ public void SetTitle(string title)
+ {
+ this.Text = title;
+ }
+
+ public void Clear(Color color)
+ {
+ graphics.Clear(color);
+ }
+
+ public new void Refresh()
+ {
+ pictureBox.Refresh();
+ }
+
+ public void DrawRectangle(int x, int y, int width, int height, Color? outline = null, Color? fill = null)
+ {
+ if (fill.HasValue)
+ {
+ var brush = new SolidBrush(fill.Value);
+ graphics.FillRectangle(brush, x, y, width, height);
+ }
+
+ var pen = new Pen(outline.HasValue ? outline.Value : Color.Black);
+ graphics.DrawRectangle(pen, x, y, width, height);
+ }
+
+ public void DrawText(int x, int y, string message, Color? color = null, int? fontsize = null, string fontfamily = null, string fontstyle = null)
+ {
+ var family = FontFamily.GenericMonospace;
+ if (fontfamily != null)
+ {
+ family = new FontFamily(fontfamily);
+ }
+
+ var fstyle = FontStyle.Regular;
+ if (fontstyle != null)
+ {
+ switch (fontstyle.ToLower())
+ {
+ default:
+ case "regular":
+ break;
+ case "bold":
+ fstyle = FontStyle.Bold;
+ break;
+ case "italic":
+ fstyle = FontStyle.Italic;
+ break;
+ case "strikethrough":
+ fstyle = FontStyle.Strikeout;
+ break;
+ case "underline":
+ fstyle = FontStyle.Underline;
+ break;
+ }
+ }
+
+ var font = new Font(family, fontsize ?? 12, fstyle, GraphicsUnit.Pixel);
+ graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit;
+ graphics.DrawString(message, font, new SolidBrush(color ?? Color.White), x, y);
+ }
+ }
+}
diff --git a/BizHawk.Client.EmuHawk/config/GB/DualGBFileSelector.resx b/BizHawk.Client.EmuHawk/tools/Lua/LuaCanvas.resx
similarity index 100%
rename from BizHawk.Client.EmuHawk/config/GB/DualGBFileSelector.resx
rename to BizHawk.Client.EmuHawk/tools/Lua/LuaCanvas.resx
diff --git a/BizHawk.Client.EmuHawk/tools/MultiDiskBundler/MultiDiskBundler.Designer.cs b/BizHawk.Client.EmuHawk/tools/MultiDiskBundler/MultiDiskBundler.Designer.cs
new file mode 100644
index 00000000000..77c8bcaf35b
--- /dev/null
+++ b/BizHawk.Client.EmuHawk/tools/MultiDiskBundler/MultiDiskBundler.Designer.cs
@@ -0,0 +1,196 @@
+namespace BizHawk.Client.EmuHawk
+{
+ partial class MultiDiskBundler
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MultiDiskBundler));
+ this.MultiDiskMenuStrip = new System.Windows.Forms.MenuStrip();
+ this.SaveRunButton = new System.Windows.Forms.Button();
+ this.CancelBtn = new System.Windows.Forms.Button();
+ this.groupBox3 = new System.Windows.Forms.GroupBox();
+ this.BrowseBtn = new System.Windows.Forms.Button();
+ this.NameBox = new System.Windows.Forms.TextBox();
+ this.FileSelectorPanel = new System.Windows.Forms.Panel();
+ this.AddButton = new System.Windows.Forms.Button();
+ this.SystemDropDown = new System.Windows.Forms.ComboBox();
+ this.SystemLabel = new System.Windows.Forms.Label();
+ this.groupBox3.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // MultiDiskMenuStrip
+ //
+ this.MultiDiskMenuStrip.Location = new System.Drawing.Point(0, 0);
+ this.MultiDiskMenuStrip.Name = "MultiDiskMenuStrip";
+ this.MultiDiskMenuStrip.Size = new System.Drawing.Size(506, 24);
+ this.MultiDiskMenuStrip.TabIndex = 0;
+ this.MultiDiskMenuStrip.Text = "menuStrip1";
+ //
+ // SaveRunButton
+ //
+ this.SaveRunButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.SaveRunButton.Enabled = false;
+ this.SaveRunButton.Location = new System.Drawing.Point(343, 329);
+ this.SaveRunButton.Name = "SaveRunButton";
+ this.SaveRunButton.Size = new System.Drawing.Size(85, 23);
+ this.SaveRunButton.TabIndex = 9;
+ this.SaveRunButton.Text = "&Save and Run";
+ this.SaveRunButton.UseVisualStyleBackColor = true;
+ this.SaveRunButton.Click += new System.EventHandler(this.SaveRunButton_Click);
+ //
+ // CancelBtn
+ //
+ this.CancelBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.CancelBtn.DialogResult = System.Windows.Forms.DialogResult.Cancel;
+ this.CancelBtn.Location = new System.Drawing.Point(434, 329);
+ this.CancelBtn.Name = "CancelBtn";
+ this.CancelBtn.Size = new System.Drawing.Size(60, 23);
+ this.CancelBtn.TabIndex = 10;
+ this.CancelBtn.Text = "&Cancel";
+ this.CancelBtn.UseVisualStyleBackColor = true;
+ this.CancelBtn.Click += new System.EventHandler(this.CancelBtn_Click);
+ //
+ // groupBox3
+ //
+ this.groupBox3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.groupBox3.Controls.Add(this.BrowseBtn);
+ this.groupBox3.Controls.Add(this.NameBox);
+ this.groupBox3.Location = new System.Drawing.Point(8, 28);
+ this.groupBox3.Name = "groupBox3";
+ this.groupBox3.Size = new System.Drawing.Size(486, 45);
+ this.groupBox3.TabIndex = 11;
+ this.groupBox3.TabStop = false;
+ this.groupBox3.Text = "Name";
+ //
+ // BrowseBtn
+ //
+ this.BrowseBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
+ this.BrowseBtn.Location = new System.Drawing.Point(417, 18);
+ this.BrowseBtn.Name = "BrowseBtn";
+ this.BrowseBtn.Size = new System.Drawing.Size(63, 23);
+ this.BrowseBtn.TabIndex = 14;
+ this.BrowseBtn.Text = "Browse...";
+ this.BrowseBtn.UseVisualStyleBackColor = true;
+ this.BrowseBtn.Click += new System.EventHandler(this.BrowseBtn_Click);
+ //
+ // NameBox
+ //
+ this.NameBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.NameBox.Location = new System.Drawing.Point(6, 19);
+ this.NameBox.Name = "NameBox";
+ this.NameBox.Size = new System.Drawing.Size(405, 20);
+ this.NameBox.TabIndex = 0;
+ this.NameBox.TextChanged += new System.EventHandler(this.NameBox_TextChanged);
+ //
+ // FileSelectorPanel
+ //
+ this.FileSelectorPanel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.FileSelectorPanel.AutoScroll = true;
+ this.FileSelectorPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
+ this.FileSelectorPanel.Location = new System.Drawing.Point(8, 101);
+ this.FileSelectorPanel.Name = "FileSelectorPanel";
+ this.FileSelectorPanel.Size = new System.Drawing.Size(486, 222);
+ this.FileSelectorPanel.TabIndex = 12;
+ //
+ // AddButton
+ //
+ this.AddButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
+ this.AddButton.Location = new System.Drawing.Point(8, 329);
+ this.AddButton.Name = "AddButton";
+ this.AddButton.Size = new System.Drawing.Size(60, 23);
+ this.AddButton.TabIndex = 13;
+ this.AddButton.Text = "Add";
+ this.AddButton.UseVisualStyleBackColor = true;
+ this.AddButton.Click += new System.EventHandler(this.AddButton_Click);
+ //
+ // SystemDropDown
+ //
+ this.SystemDropDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
+ this.SystemDropDown.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+ this.SystemDropDown.FormattingEnabled = true;
+ this.SystemDropDown.Items.AddRange(new object[] {
+ "GB",
+ "Apple II"});
+ this.SystemDropDown.Location = new System.Drawing.Point(425, 75);
+ this.SystemDropDown.Name = "SystemDropDown";
+ this.SystemDropDown.Size = new System.Drawing.Size(69, 21);
+ this.SystemDropDown.TabIndex = 14;
+ //
+ // SystemLabel
+ //
+ this.SystemLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
+ this.SystemLabel.AutoSize = true;
+ this.SystemLabel.Location = new System.Drawing.Point(375, 78);
+ this.SystemLabel.Name = "SystemLabel";
+ this.SystemLabel.Size = new System.Drawing.Size(44, 13);
+ this.SystemLabel.TabIndex = 15;
+ this.SystemLabel.Text = "System:";
+ //
+ // MultiDiskBundler
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(506, 364);
+ this.Controls.Add(this.SystemLabel);
+ this.Controls.Add(this.SystemDropDown);
+ this.Controls.Add(this.AddButton);
+ this.Controls.Add(this.FileSelectorPanel);
+ this.Controls.Add(this.groupBox3);
+ this.Controls.Add(this.CancelBtn);
+ this.Controls.Add(this.SaveRunButton);
+ this.Controls.Add(this.MultiDiskMenuStrip);
+ this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
+ this.MainMenuStrip = this.MultiDiskMenuStrip;
+ this.Name = "MultiDiskBundler";
+ this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
+ this.Text = "Multi-disk Bundler";
+ this.Load += new System.EventHandler(this.MultiGameCreator_Load);
+ this.groupBox3.ResumeLayout(false);
+ this.groupBox3.PerformLayout();
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.MenuStrip MultiDiskMenuStrip;
+ private System.Windows.Forms.Button SaveRunButton;
+ private System.Windows.Forms.Button CancelBtn;
+ private System.Windows.Forms.GroupBox groupBox3;
+ private System.Windows.Forms.TextBox NameBox;
+ private System.Windows.Forms.Panel FileSelectorPanel;
+ private System.Windows.Forms.Button AddButton;
+ private System.Windows.Forms.Button BrowseBtn;
+ private System.Windows.Forms.ComboBox SystemDropDown;
+ private System.Windows.Forms.Label SystemLabel;
+ }
+}
\ No newline at end of file
diff --git a/BizHawk.Client.EmuHawk/tools/MultiDiskBundler/MultiDiskBundler.cs b/BizHawk.Client.EmuHawk/tools/MultiDiskBundler/MultiDiskBundler.cs
new file mode 100644
index 00000000000..584b468d03f
--- /dev/null
+++ b/BizHawk.Client.EmuHawk/tools/MultiDiskBundler/MultiDiskBundler.cs
@@ -0,0 +1,285 @@
+using BizHawk.Client.Common;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Text.RegularExpressions;
+using System.Windows.Forms;
+using System.Xml.Linq;
+using BizHawk.Client.EmuHawk.WinFormExtensions;
+using BizHawk.Emulation.Common;
+
+namespace BizHawk.Client.EmuHawk
+{
+ public partial class MultiDiskBundler : Form, IToolFormAutoConfig
+ {
+ private XElement _currentXml = null;
+
+ public MultiDiskBundler()
+ {
+ InitializeComponent();
+ }
+
+ private void MultiGameCreator_Load(object sender, EventArgs e)
+ {
+ AddButton_Click(null, null);
+ AddButton_Click(null, null);
+
+ if (!Global.Game.IsNullInstance && !GlobalWin.MainForm.CurrentlyOpenRom.EndsWith(".xml"))
+ {
+ string currentRom = GlobalWin.MainForm.CurrentlyOpenRom;
+ if (GlobalWin.MainForm.CurrentlyOpenRom.Contains("|"))
+ {
+ var pieces = GlobalWin.MainForm.CurrentlyOpenRom.Split('|');
+
+ var directory = Path.GetDirectoryName(pieces[0]);
+ var filename = Path.ChangeExtension(pieces[1], ".xml");
+
+ NameBox.Text = Path.Combine(directory, filename);
+ }
+ else
+ {
+ NameBox.Text = Path.ChangeExtension(GlobalWin.MainForm.CurrentlyOpenRom, ".xml");
+ }
+
+ if (SystemDropDown.Items.Contains(Global.Emulator.SystemId))
+ {
+ SystemDropDown.SelectedItem = Global.Emulator.SystemId;
+ }
+
+ FileSelectors.First().SetName(GlobalWin.MainForm.CurrentlyOpenRom);
+ }
+ }
+
+ #region IToolForm
+
+ public void UpdateValues()
+ {
+
+ }
+
+ public void FastUpdate()
+ {
+
+ }
+
+ public void Restart()
+ {
+
+ }
+
+ public bool AskSaveChanges()
+ {
+ return true;
+ }
+
+ public bool UpdateBefore
+ {
+ get { return true; }
+ }
+
+ #endregion
+
+ private void CancelBtn_Click(object sender, EventArgs e)
+ {
+ DialogResult = DialogResult.Cancel;
+ Close();
+ }
+
+ private void SaveRunButton_Click(object sender, EventArgs e)
+ {
+ if (Recalculate())
+ {
+ var fileInfo = new FileInfo(NameBox.Text);
+ if (fileInfo.Exists)
+ {
+ var result = MessageBox.Show(this, "File already exists, overwrite?", "File exists", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
+ if (result != DialogResult.OK)
+ {
+ return;
+ }
+ }
+
+ File.WriteAllText(fileInfo.FullName, _currentXml.ToString());
+
+ DialogResult = DialogResult.OK;
+ Close();
+
+ GlobalWin.MainForm.LoadRom(fileInfo.FullName);
+ }
+ }
+
+ private void AddButton_Click(object sender, EventArgs e)
+ {
+ int start = 5 + (FileSelectorPanel.Controls.Count * 43);
+
+ var groupBox = new GroupBox
+ {
+ Text = "",
+ Location = new Point(5, start),
+ Size = new Size(435, 38),
+ Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top
+ };
+
+ var mdf = new MultiDiskFileSelector
+ {
+ Location = new Point(5, 8),
+ Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top
+ };
+
+ mdf.NameChanged += FileSelector_NameChanged;
+
+ groupBox.Controls.Add(mdf);
+
+ FileSelectorPanel.Controls.Add(groupBox);
+ }
+
+ private void FileSelector_NameChanged(object sender, EventArgs e)
+ {
+ Recalculate();
+ }
+
+
+ private IEnumerable FileSelectors
+ {
+ get
+ {
+ return FileSelectorPanel.Controls
+ .OfType()
+ .SelectMany(g => g.Controls.OfType());
+ }
+ }
+
+ private bool Recalculate()
+ {
+ try
+ {
+ var fileSelectors = FileSelectors.ToList();
+
+ var names = fileSelectors.Select(f => f.GetName());
+
+ var name = NameBox.Text;
+
+ if (string.IsNullOrWhiteSpace(name))
+ {
+ throw new Exception("Blank Names");
+ }
+
+ if (names.Any(n => string.IsNullOrWhiteSpace(n)))
+ {
+ throw new Exception("Blank Names");
+ }
+
+ var system = SystemDropDown.SelectedItem.ToString();
+
+ if (system == null)
+ {
+ throw new Exception("Blank System Id");
+ }
+
+ var basePath = Path.GetDirectoryName(name.Split('|').First());
+
+ _currentXml = new XElement("BizHawk-XMLGame",
+ new XAttribute("System", system),
+ new XAttribute("Name", name),
+ new XElement("LoadAssets",
+ names.Select(n => new XElement(
+ "Asset",
+ new XAttribute("FileName", GetRelativePath(basePath, n))
+ ))
+ )
+ );
+
+ SaveRunButton.Enabled = true;
+ return true;
+ }
+ catch (Exception)
+ {
+ _currentXml = null;
+ SaveRunButton.Enabled = false;
+ return false;
+ }
+ }
+
+ private static string ConvertToTag(string name)
+ {
+ return new Regex("[^A-Za-z0-9]").Replace(name, string.Empty);
+ }
+
+ private void NameBox_TextChanged(object sender, EventArgs e)
+ {
+ Recalculate();
+ }
+
+ private void BrowseBtn_Click(object sender, EventArgs e)
+ {
+ string filename = string.Empty;
+ string initialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries["Global_NULL", "Multi-Disk Bundles"].Path, "Global_NULL");
+
+ if (!Global.Game.IsNullInstance)
+ {
+ filename = NameBox.Text;
+ if (string.IsNullOrWhiteSpace(filename))
+ {
+ filename = Path.ChangeExtension(PathManager.FilesystemSafeName(Global.Game), ".xml");
+ }
+
+ initialDirectory = Path.GetDirectoryName(filename);
+ }
+
+ var sfd = new SaveFileDialog
+ {
+ FileName = filename,
+ InitialDirectory = initialDirectory,
+ Filter = "xml (*.xml)|*.xml|All Files|*.*"
+ };
+
+ var result = sfd.ShowHawkDialog();
+ if (result != DialogResult.Cancel)
+ {
+ NameBox.Text = sfd.FileName;
+ }
+ }
+
+ // http://stackoverflow.com/questions/275689/how-to-get-relative-path-from-absolute-path
+ public static string GetRelativePath(string fromPath, string toPath)
+ {
+ Win32.FileAttributes fromAttr = GetPathAttribute(fromPath);
+ Win32.FileAttributes toAttr = GetPathAttribute(toPath);
+
+ var path = new StringBuilder(260); // MAX_PATH
+ if (Win32.PathRelativePathTo(
+ path,
+ fromPath,
+ fromAttr,
+ toPath,
+ toAttr) == false)
+ {
+ throw new ArgumentException("Paths must have a common prefix");
+ }
+
+ return path.ToString();
+ }
+
+ private static Win32.FileAttributes GetPathAttribute(string path)
+ {
+ var di = new DirectoryInfo(path.Split('|').First());
+ if (di.Exists)
+ {
+ return Win32.FileAttributes.Directory;
+ }
+
+ var fi = new FileInfo(path.Split('|').First());
+ if (fi.Exists)
+ {
+ return Win32.FileAttributes.Normal;
+ }
+
+ throw new FileNotFoundException();
+ }
+ }
+}
diff --git a/BizHawk.Client.EmuHawk/tools/GB/DualGBXMLCreator.resx b/BizHawk.Client.EmuHawk/tools/MultiDiskBundler/MultiDiskBundler.resx
similarity index 98%
rename from BizHawk.Client.EmuHawk/tools/GB/DualGBXMLCreator.resx
rename to BizHawk.Client.EmuHawk/tools/MultiDiskBundler/MultiDiskBundler.resx
index d794d13b510..da41b4f9527 100644
--- a/BizHawk.Client.EmuHawk/tools/GB/DualGBXMLCreator.resx
+++ b/BizHawk.Client.EmuHawk/tools/MultiDiskBundler/MultiDiskBundler.resx
@@ -117,6 +117,9 @@
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+ 17, 17
+
diff --git a/BizHawk.Client.EmuHawk/config/GB/DualGBFileSelector.Designer.cs b/BizHawk.Client.EmuHawk/tools/MultiDiskBundler/MultiDiskFileSelector.Designer.cs
similarity index 67%
rename from BizHawk.Client.EmuHawk/config/GB/DualGBFileSelector.Designer.cs
rename to BizHawk.Client.EmuHawk/tools/MultiDiskBundler/MultiDiskFileSelector.Designer.cs
index 9edb49e3d66..007a9a74784 100644
--- a/BizHawk.Client.EmuHawk/config/GB/DualGBFileSelector.Designer.cs
+++ b/BizHawk.Client.EmuHawk/tools/MultiDiskBundler/MultiDiskFileSelector.Designer.cs
@@ -1,6 +1,6 @@
namespace BizHawk.Client.EmuHawk
{
- partial class DualGBFileSelector
+ partial class MultiDiskFileSelector
{
///
/// Required designer variable.
@@ -29,14 +29,14 @@ protected override void Dispose(bool disposing)
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
- this.textBox1 = new System.Windows.Forms.TextBox();
+ this.PathBox = new System.Windows.Forms.TextBox();
this.UseCurrentRomButton = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// button1
//
this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
- this.button1.Location = new System.Drawing.Point(362, 3);
+ this.button1.Location = new System.Drawing.Point(290, 3);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(60, 23);
this.button1.TabIndex = 2;
@@ -44,36 +44,37 @@ private void InitializeComponent()
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
- // textBox1
+ // PathBox
//
- this.textBox1.AllowDrop = true;
- this.textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
+ this.PathBox.AllowDrop = true;
+ this.PathBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
- this.textBox1.Location = new System.Drawing.Point(3, 5);
- this.textBox1.Name = "textBox1";
- this.textBox1.Size = new System.Drawing.Size(270, 20);
- this.textBox1.TabIndex = 1;
- this.textBox1.DragDrop += new System.Windows.Forms.DragEventHandler(this.textBox1_DragDrop);
- this.textBox1.DragEnter += new System.Windows.Forms.DragEventHandler(this.textBox1_DragEnter);
+ this.PathBox.Location = new System.Drawing.Point(3, 5);
+ this.PathBox.Name = "PathBox";
+ this.PathBox.Size = new System.Drawing.Size(285, 20);
+ this.PathBox.TabIndex = 1;
+ this.PathBox.TextChanged += new System.EventHandler(this.PathBox_TextChanged);
+ this.PathBox.DragDrop += new System.Windows.Forms.DragEventHandler(this.textBox1_DragDrop);
+ this.PathBox.DragEnter += new System.Windows.Forms.DragEventHandler(this.textBox1_DragEnter);
//
// UseCurrentRomButton
//
this.UseCurrentRomButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
- this.UseCurrentRomButton.Location = new System.Drawing.Point(279, 3);
+ this.UseCurrentRomButton.Location = new System.Drawing.Point(357, 3);
this.UseCurrentRomButton.Name = "UseCurrentRomButton";
- this.UseCurrentRomButton.Size = new System.Drawing.Size(83, 23);
+ this.UseCurrentRomButton.Size = new System.Drawing.Size(62, 23);
this.UseCurrentRomButton.TabIndex = 3;
- this.UseCurrentRomButton.Text = "Current Rom";
+ this.UseCurrentRomButton.Text = "Current";
this.UseCurrentRomButton.UseVisualStyleBackColor = true;
this.UseCurrentRomButton.Click += new System.EventHandler(this.UseCurrentRomButton_Click);
//
- // DualGBFileSelector
+ // MultiDiskFileSelector
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
this.Controls.Add(this.UseCurrentRomButton);
this.Controls.Add(this.button1);
- this.Controls.Add(this.textBox1);
- this.Name = "DualGBFileSelector";
+ this.Controls.Add(this.PathBox);
+ this.Name = "MultiDiskFileSelector";
this.Size = new System.Drawing.Size(425, 29);
this.Load += new System.EventHandler(this.DualGBFileSelector_Load);
this.ResumeLayout(false);
@@ -84,7 +85,7 @@ private void InitializeComponent()
#endregion
private System.Windows.Forms.Button button1;
- private System.Windows.Forms.TextBox textBox1;
+ private System.Windows.Forms.TextBox PathBox;
private System.Windows.Forms.Button UseCurrentRomButton;
}
diff --git a/BizHawk.Client.EmuHawk/config/GB/DualGBFileSelector.cs b/BizHawk.Client.EmuHawk/tools/MultiDiskBundler/MultiDiskFileSelector.cs
similarity index 52%
rename from BizHawk.Client.EmuHawk/config/GB/DualGBFileSelector.cs
rename to BizHawk.Client.EmuHawk/tools/MultiDiskBundler/MultiDiskFileSelector.cs
index 0728b22a5ce..26fa36ce652 100644
--- a/BizHawk.Client.EmuHawk/config/GB/DualGBFileSelector.cs
+++ b/BizHawk.Client.EmuHawk/tools/MultiDiskBundler/MultiDiskFileSelector.cs
@@ -10,19 +10,20 @@
using BizHawk.Client.Common;
using BizHawk.Emulation.Common;
using BizHawk.Emulation.Cores.Nintendo.Gameboy;
+using BizHawk.Client.EmuHawk.WinFormExtensions;
namespace BizHawk.Client.EmuHawk
{
- public partial class DualGBFileSelector : UserControl
+ public partial class MultiDiskFileSelector : UserControl
{
public string GetName()
{
- return textBox1.Text;
+ return PathBox.Text;
}
public void SetName(string val)
{
- textBox1.Text = val;
+ PathBox.Text = val;
}
public event EventHandler NameChanged;
@@ -32,10 +33,10 @@ private void HandleLabelTextChanged(object sender, EventArgs e)
this.OnNameChanged(EventArgs.Empty);
}
- public DualGBFileSelector()
+ public MultiDiskFileSelector()
{
InitializeComponent();
- textBox1.TextChanged += this.HandleLabelTextChanged;
+ PathBox.TextChanged += this.HandleLabelTextChanged;
}
protected virtual void OnNameChanged(EventArgs e)
@@ -67,32 +68,31 @@ private void textBox1_DragDrop(object sender, DragEventArgs e)
var ff = (string[])e.Data.GetData(DataFormats.FileDrop);
if (ff.Length == 1)
{
- textBox1.Text = ff[0];
+ PathBox.Text = ff[0];
}
- }
+ }
}
private void button1_Click(object sender, EventArgs e)
{
- using (var ofd = new OpenFileDialog())
+ using (var ofd = new OpenFileDialog
+ {
+ InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries["Global_NULL", "ROM"].Path, "Global_NULL"),
+ Filter = MainForm.RomFilter,
+ RestoreDirectory = true
+ })
{
- //Lets use the Dual Gameboy ROM path then the Global ROM path for this. Disabled due to errors in handling an invalid path.
- //ofd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries["DGB", "ROM"].Path, "DGB") ?? PathManager.MakeAbsolutePath(Global.Config.PathEntries["Global_NULL", "ROM"].Path, "Global_NULL");
- //Global ROM Path Only
- ofd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries["Global_NULL", "ROM"].Path, "Global_NULL");
- ofd.Filter = "GB Roms (*.gb,*.gbc)|*.gb;*.gbc|All Files|*.*";
- ofd.RestoreDirectory = true;
- var result = ofd.ShowDialog(this);
+ var result = ofd.ShowHawkDialog();
if (result == DialogResult.OK)
{
- textBox1.Text = ofd.FileName;
+ PathBox.Text = ofd.FileName;
}
}
}
private void UseCurrentRomButton_Click(object sender, EventArgs e)
{
- textBox1.Text = GlobalWin.MainForm.CurrentlyOpenRom;
+ PathBox.Text = GlobalWin.MainForm.CurrentlyOpenRom;
}
private void DualGBFileSelector_Load(object sender, EventArgs e)
@@ -102,11 +102,14 @@ private void DualGBFileSelector_Load(object sender, EventArgs e)
public void UpdateValues()
{
- UseCurrentRomButton.Enabled = Global.Emulator != null && // For the designer
- (Global.Emulator is Gameboy) &&
- !string.IsNullOrEmpty(GlobalWin.MainForm.CurrentlyOpenRom) &&
- !GlobalWin.MainForm.CurrentlyOpenRom.Contains('|') && // Can't be archive
- !GlobalWin.MainForm.CurrentlyOpenRom.Contains(".xml"); // Can't already be an xml
+ UseCurrentRomButton.Enabled = Global.Emulator != null // For the designer
+ && !string.IsNullOrEmpty(GlobalWin.MainForm.CurrentlyOpenRom)
+ && !GlobalWin.MainForm.CurrentlyOpenRom.Contains(".xml"); // Can't already be an xml
+ }
+
+ private void PathBox_TextChanged(object sender, EventArgs e)
+ {
+ OnNameChanged(e);
}
}
}
diff --git a/BizHawk.Client.EmuHawk/tools/MultiDiskBundler/MultiDiskFileSelector.resx b/BizHawk.Client.EmuHawk/tools/MultiDiskBundler/MultiDiskFileSelector.resx
new file mode 100644
index 00000000000..29dcb1b3a35
--- /dev/null
+++ b/BizHawk.Client.EmuHawk/tools/MultiDiskBundler/MultiDiskFileSelector.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/BizHawk.Client.EmuHawk/tools/NES/NESMusicRipper.Designer.cs b/BizHawk.Client.EmuHawk/tools/NES/NESMusicRipper.Designer.cs
new file mode 100644
index 00000000000..35507aecf6f
--- /dev/null
+++ b/BizHawk.Client.EmuHawk/tools/NES/NESMusicRipper.Designer.cs
@@ -0,0 +1,223 @@
+namespace BizHawk.Client.EmuHawk
+{
+ partial class NESMusicRipper
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(NESMusicRipper));
+ this.btnControl = new System.Windows.Forms.Button();
+ this.txtDivider = new System.Windows.Forms.TextBox();
+ this.label1 = new System.Windows.Forms.Label();
+ this.btnExport = new System.Windows.Forms.Button();
+ this.lblContents = new System.Windows.Forms.Label();
+ this.textBox1 = new System.Windows.Forms.TextBox();
+ this.txtPatternLength = new System.Windows.Forms.TextBox();
+ this.groupBox1 = new System.Windows.Forms.GroupBox();
+ this.label2 = new System.Windows.Forms.Label();
+ this.groupBox2 = new System.Windows.Forms.GroupBox();
+ this.menuStrip1 = new MenuStripEx();
+ this.FileSubMenu = new System.Windows.Forms.ToolStripMenuItem();
+ this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
+ this.ExitMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.groupBox1.SuspendLayout();
+ this.groupBox2.SuspendLayout();
+ this.menuStrip1.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // btnControl
+ //
+ this.btnControl.Location = new System.Drawing.Point(6, 57);
+ this.btnControl.Name = "btnControl";
+ this.btnControl.Size = new System.Drawing.Size(75, 23);
+ this.btnControl.TabIndex = 0;
+ this.btnControl.Text = "Start";
+ this.btnControl.UseVisualStyleBackColor = true;
+ this.btnControl.Click += new System.EventHandler(this.btnControl_Click);
+ //
+ // txtDivider
+ //
+ this.txtDivider.Location = new System.Drawing.Point(9, 32);
+ this.txtDivider.Name = "txtDivider";
+ this.txtDivider.Size = new System.Drawing.Size(100, 20);
+ this.txtDivider.TabIndex = 1;
+ this.txtDivider.Text = "29824";
+ //
+ // label1
+ //
+ this.label1.AutoSize = true;
+ this.label1.Location = new System.Drawing.Point(6, 16);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(135, 13);
+ this.label1.TabIndex = 2;
+ this.label1.Text = "APU Divider (trace interval)";
+ //
+ // btnExport
+ //
+ this.btnExport.AutoSize = true;
+ this.btnExport.Location = new System.Drawing.Point(6, 118);
+ this.btnExport.Name = "btnExport";
+ this.btnExport.Size = new System.Drawing.Size(100, 23);
+ this.btnExport.TabIndex = 3;
+ this.btnExport.Text = "Export XRNS File";
+ this.btnExport.UseVisualStyleBackColor = true;
+ this.btnExport.Click += new System.EventHandler(this.btnExport_Click);
+ //
+ // lblContents
+ //
+ this.lblContents.AutoSize = true;
+ this.lblContents.Location = new System.Drawing.Point(6, 102);
+ this.lblContents.Name = "lblContents";
+ this.lblContents.Size = new System.Drawing.Size(55, 13);
+ this.lblContents.TabIndex = 4;
+ this.lblContents.Text = "(Contents)";
+ //
+ // textBox1
+ //
+ this.textBox1.Location = new System.Drawing.Point(12, 211);
+ this.textBox1.Multiline = true;
+ this.textBox1.Name = "textBox1";
+ this.textBox1.ReadOnly = true;
+ this.textBox1.Size = new System.Drawing.Size(390, 80);
+ this.textBox1.TabIndex = 6;
+ this.textBox1.Text = resources.GetString("textBox1.Text");
+ //
+ // txtPatternLength
+ //
+ this.txtPatternLength.Location = new System.Drawing.Point(12, 37);
+ this.txtPatternLength.Name = "txtPatternLength";
+ this.txtPatternLength.Size = new System.Drawing.Size(100, 20);
+ this.txtPatternLength.TabIndex = 7;
+ this.txtPatternLength.Text = "512";
+ //
+ // groupBox1
+ //
+ this.groupBox1.Controls.Add(this.label2);
+ this.groupBox1.Controls.Add(this.txtPatternLength);
+ this.groupBox1.Location = new System.Drawing.Point(0, 27);
+ this.groupBox1.Name = "groupBox1";
+ this.groupBox1.Size = new System.Drawing.Size(200, 156);
+ this.groupBox1.TabIndex = 8;
+ this.groupBox1.TabStop = false;
+ this.groupBox1.Text = "Config";
+ //
+ // label2
+ //
+ this.label2.AutoSize = true;
+ this.label2.Location = new System.Drawing.Point(12, 21);
+ this.label2.Name = "label2";
+ this.label2.Size = new System.Drawing.Size(126, 13);
+ this.label2.TabIndex = 8;
+ this.label2.Text = "Pattern Length (512 max)";
+ //
+ // groupBox2
+ //
+ this.groupBox2.Controls.Add(this.btnControl);
+ this.groupBox2.Controls.Add(this.txtDivider);
+ this.groupBox2.Controls.Add(this.btnExport);
+ this.groupBox2.Controls.Add(this.lblContents);
+ this.groupBox2.Controls.Add(this.label1);
+ this.groupBox2.Location = new System.Drawing.Point(206, 32);
+ this.groupBox2.Name = "groupBox2";
+ this.groupBox2.Size = new System.Drawing.Size(200, 151);
+ this.groupBox2.TabIndex = 9;
+ this.groupBox2.TabStop = false;
+ this.groupBox2.Text = "Log Control";
+ //
+ // menuStrip1
+ //
+ this.menuStrip1.ClickThrough = true;
+ this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.FileSubMenu});
+ this.menuStrip1.Location = new System.Drawing.Point(0, 0);
+ this.menuStrip1.Name = "menuStrip1";
+ this.menuStrip1.Size = new System.Drawing.Size(437, 24);
+ this.menuStrip1.TabIndex = 5;
+ this.menuStrip1.Text = "menuStrip1";
+ //
+ // FileSubMenu
+ //
+ this.FileSubMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.toolStripSeparator2,
+ this.ExitMenuItem});
+ this.FileSubMenu.Name = "FileSubMenu";
+ this.FileSubMenu.Size = new System.Drawing.Size(35, 20);
+ this.FileSubMenu.Text = "&File";
+ //
+ // toolStripSeparator2
+ //
+ this.toolStripSeparator2.Name = "toolStripSeparator2";
+ this.toolStripSeparator2.Size = new System.Drawing.Size(129, 6);
+ //
+ // ExitMenuItem
+ //
+ this.ExitMenuItem.Name = "ExitMenuItem";
+ this.ExitMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Alt | System.Windows.Forms.Keys.F4)));
+ this.ExitMenuItem.Size = new System.Drawing.Size(132, 22);
+ this.ExitMenuItem.Text = "E&xit";
+ this.ExitMenuItem.Click += new System.EventHandler(this.ExitMenuItem_Click);
+ //
+ // NESMusicRipper
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(437, 305);
+ this.Controls.Add(this.groupBox2);
+ this.Controls.Add(this.groupBox1);
+ this.Controls.Add(this.textBox1);
+ this.Controls.Add(this.menuStrip1);
+ this.Name = "NESMusicRipper";
+ this.Text = "NESMusicRipper";
+ this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.NESMusicRipper_FormClosed);
+ this.groupBox1.ResumeLayout(false);
+ this.groupBox1.PerformLayout();
+ this.groupBox2.ResumeLayout(false);
+ this.groupBox2.PerformLayout();
+ this.menuStrip1.ResumeLayout(false);
+ this.menuStrip1.PerformLayout();
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.Button btnControl;
+ private System.Windows.Forms.TextBox txtDivider;
+ private System.Windows.Forms.Label label1;
+ private System.Windows.Forms.Button btnExport;
+ private System.Windows.Forms.Label lblContents;
+ private MenuStripEx menuStrip1;
+ private System.Windows.Forms.ToolStripMenuItem FileSubMenu;
+ private System.Windows.Forms.ToolStripSeparator toolStripSeparator2;
+ private System.Windows.Forms.ToolStripMenuItem ExitMenuItem;
+ private System.Windows.Forms.TextBox textBox1;
+ private System.Windows.Forms.TextBox txtPatternLength;
+ private System.Windows.Forms.GroupBox groupBox1;
+ private System.Windows.Forms.Label label2;
+ private System.Windows.Forms.GroupBox groupBox2;
+ }
+}
\ No newline at end of file
diff --git a/BizHawk.Client.EmuHawk/tools/NES/NESMusicRipper.cs b/BizHawk.Client.EmuHawk/tools/NES/NESMusicRipper.cs
new file mode 100644
index 00000000000..cf058b67da7
--- /dev/null
+++ b/BizHawk.Client.EmuHawk/tools/NES/NESMusicRipper.cs
@@ -0,0 +1,523 @@
+using System;
+using System.Xml;
+using System.Xml.XPath;
+using System.Xml.Linq;
+using System.Linq;
+using System.IO;
+using System.Text;
+using System.Collections.Generic;
+using System.Drawing;
+using System.Drawing.Imaging;
+using System.Windows.Forms;
+using BizHawk.Client.Common;
+using BizHawk.Emulation.Cores.Nintendo.NES;
+using BizHawk.Emulation.Common;
+
+namespace BizHawk.Client.EmuHawk
+{
+ public partial class NESMusicRipper : Form, IToolFormAutoConfig
+ {
+ [RequiredService]
+ private IEmulator _emu { get; set; }
+
+ public NESMusicRipper()
+ {
+ InitializeComponent();
+ SyncContents();
+ }
+
+ public bool AskSaveChanges() { return true; }
+ public bool UpdateBefore { get { return true; } }
+
+ public void Restart()
+ {
+ }
+
+ public void UpdateValues()
+ {
+ }
+
+ public void FastUpdate()
+ {
+ // Do nothing
+ }
+
+ private void RefreshFloatingWindowControl()
+ {
+ }
+
+ bool IsRunning;
+
+ protected override void OnShown(EventArgs e)
+ {
+ RefreshFloatingWindowControl();
+ base.OnShown(e);
+ }
+
+ //http://www.phy.mtu.edu/~suits/notefreqs.html
+ //begins at C0. ends at B8
+ static readonly float[] freqtbl = new[] {0,
+ 16.35f,17.32f,18.35f,19.45f,20.6f,21.83f,23.12f,24.5f,25.96f,27.5f,29.14f,30.87f,32.7f,34.65f,36.71f,38.89f,41.2f,43.65f,46.25f,49f,51.91f,55f,58.27f,61.74f,65.41f,69.3f,73.42f,77.78f,82.41f,87.31f,92.5f,98f,103.83f,110f,116.54f,123.47f,130.81f,138.59f,146.83f,155.56f,164.81f,174.61f,185f,196f,207.65f,220f,233.08f,246.94f,261.63f,277.18f,293.66f,311.13f,329.63f,349.23f,369.99f,392f,415.3f,440f,466.16f,493.88f,523.25f,554.37f,587.33f,622.25f,659.25f,698.46f,739.99f,783.99f,830.61f,880f,932.33f,987.77f,1046.5f,1108.73f,1174.66f,1244.51f,1318.51f,1396.91f,1479.98f,1567.98f,1661.22f,1760f,1864.66f,1975.53f,2093f,2217.46f,2349.32f,2489.02f,2637.02f,2793.83f,2959.96f,3135.96f,3322.44f,3520f,3729.31f,3951.07f,4186.01f,4434.92f,4698.63f,4978.03f,5274.04f,5587.65f,5919.91f,6271.93f,6644.88f,7040f,7458.62f,7902.13f,
+ 1000000
+ };
+
+ static readonly string[] noteNames = new[] { "C-", "C#", "D-", "D#", "E-", "F-", "F#", "G-", "G#", "A-", "A#", "B-" };
+
+ string NameForNote(int note)
+ {
+ int tone = note % 12;
+ int octave = note / 12;
+ return string.Format("{0}{1}", noteNames[tone], octave);
+ }
+
+ //this isnt thoroughly debugged but it seems to work OK
+ //pitch bends are massively broken anyway
+ int FindNearestNote(float freq)
+ {
+ for (int i = 1; i < freqtbl.Length; i++)
+ {
+ float a = freqtbl[i - 1];
+ float b = freqtbl[i];
+ float c = freqtbl[i + 1];
+ float min = (a + b) / 2;
+ float max = (b + c) / 2;
+ if (freq >= min && freq <= max)
+ return i - 1;
+ }
+ return 95; //I guess?
+ }
+
+ struct PulseState
+ {
+ public bool en;
+ public byte vol, type;
+ public int note;
+ }
+
+ struct TriangleState
+ {
+ public bool en;
+ public int note;
+ }
+
+ struct NoiseState
+ {
+ public bool en;
+ public byte vol;
+ public int note;
+ }
+
+ class ApuState
+ {
+ public PulseState pulse0, pulse1;
+ public TriangleState triangle;
+ public NoiseState noise;
+ }
+
+ class Stupid : ICSharpCode.SharpZipLib.Zip.IStaticDataSource
+ {
+ public Stream stream;
+ public Stream GetSource() { return stream; }
+ }
+
+ private void btnExport_Click(object sender, EventArgs e)
+ {
+ //acquire target
+ var sfd = new SaveFileDialog();
+ sfd.Filter = "XRNS (*.xrns)|*.xrns";
+ if (sfd.ShowDialog() != System.Windows.Forms.DialogResult.OK)
+ return;
+
+ //configuration:
+ var outPath = sfd.FileName;
+ string templatePath = Path.Combine(Path.GetDirectoryName(outPath), "template.xrns");
+ int configuredPatternLength = int.Parse(txtPatternLength.Text);
+
+
+ //load template
+ MemoryStream msSongXml = new MemoryStream();
+ var zfTemplate = new ICSharpCode.SharpZipLib.Zip.ZipFile(templatePath);
+ {
+ int zfSongXmlIndex = zfTemplate.FindEntry("Song.xml", true);
+ using (var zis = zfTemplate.GetInputStream(zfTemplate.GetEntry("Song.xml")))
+ {
+ byte[] buffer = new byte[4096]; // 4K is optimum
+ ICSharpCode.SharpZipLib.Core.StreamUtils.Copy(zis, msSongXml, buffer);
+ }
+ }
+ XElement templateRoot = XElement.Parse(System.Text.Encoding.UTF8.GetString(msSongXml.ToArray()));
+
+ //get the pattern pool, and whack the child nodes
+ var xPatterns = templateRoot.XPathSelectElement("//Patterns");
+ var xPatternPool = xPatterns.Parent;
+ xPatterns.Remove();
+
+ var writer = new StringWriter();
+ writer.WriteLine("");
+
+
+ int pulse0_lastNote = -1;
+ int pulse0_lastType = -1;
+ int pulse1_lastNote = -1;
+ int pulse1_lastType = -1;
+ int tri_lastNote = -1;
+ int noise_lastNote = -1;
+
+ int patternCount = 0;
+ int time = 0;
+ while (time < Log.Count)
+ {
+ patternCount++;
+
+ //begin writing pattern: open the tracks list
+ writer.WriteLine("");
+ writer.WriteLine("{0}", configuredPatternLength);
+ writer.WriteLine("");
+
+ //write the pulse tracks
+ for (int TRACK = 0; TRACK < 2; TRACK++)
+ {
+ writer.WriteLine("");
+ writer.WriteLine("");
+
+ int lastNote = TRACK == 0 ? pulse0_lastNote : pulse1_lastNote;
+ int lastType = TRACK == 0 ? pulse0_lastType : pulse1_lastType;
+ for (int i = 0; i < configuredPatternLength; i++)
+ {
+ int patLine = i;
+
+ int index = i + time;
+ if (index >= Log.Count) continue;
+
+ var rec = Log[index];
+
+ PulseState pulse = new PulseState();
+ if (TRACK == 0) pulse = rec.pulse0;
+ if (TRACK == 1) pulse = rec.pulse1;
+
+ //transform quieted notes to dead notes
+ //blech its buggy, im tired
+ //if (pulse.vol == 0)
+ // pulse.en = false;
+
+ bool keyoff = false, keyon = false;
+ if (lastNote != -1 && !pulse.en)
+ {
+ lastNote = -1;
+ lastType = -1;
+ keyoff = true;
+ }
+ else if (lastNote != pulse.note && pulse.en)
+ keyon = true;
+
+ if (lastType != pulse.type && pulse.note != -1)
+ keyon = true;
+
+ if (pulse.en)
+ {
+ lastNote = pulse.note;
+ lastType = pulse.type;
+ }
+
+ writer.WriteLine("", patLine);
+ writer.WriteLine("");
+ writer.WriteLine("");
+ if (keyon)
+ {
+ writer.WriteLine("{0}", NameForNote(pulse.note));
+ writer.WriteLine("{0:X2}", pulse.type);
+ }
+ else if (keyoff) writer.WriteLine("OFF");
+
+ if(lastNote != -1)
+ writer.WriteLine("{0:X2}", pulse.vol * 8);
+
+ writer.WriteLine("");
+ writer.WriteLine("");
+ writer.WriteLine("");
+ }
+
+ //close PatternTrack
+ writer.WriteLine("");
+ writer.WriteLine("");
+
+ if (TRACK == 0)
+ {
+ pulse0_lastNote = lastNote;
+ pulse0_lastType = lastType;
+ }
+ else
+ {
+ pulse1_lastNote = lastNote;
+ pulse1_lastType = lastType;
+ }
+
+ } //pulse tracks loop
+
+ //triangle track generation
+ {
+ writer.WriteLine("");
+ writer.WriteLine("");
+
+ for (int i = 0; i < configuredPatternLength; i++)
+ {
+ int patLine = i;
+
+ int index = i + time;
+ if (index >= Log.Count) continue;
+
+ var rec = Log[index];
+
+ TriangleState tri = rec.triangle;
+
+ {
+ bool keyoff = false, keyon = false;
+ if (tri_lastNote != -1 && !tri.en)
+ {
+ tri_lastNote = -1;
+ keyoff = true;
+ }
+ else if (tri_lastNote != tri.note && tri.en)
+ keyon = true;
+
+ if(tri.en)
+ tri_lastNote = tri.note;
+
+ writer.WriteLine("", patLine);
+ writer.WriteLine("");
+ writer.WriteLine("");
+ if (keyon)
+ {
+ writer.WriteLine("{0}", NameForNote(tri.note));
+ writer.WriteLine("08");
+ }
+ else if (keyoff) writer.WriteLine("OFF");
+
+ //no need for tons of these
+ //if(keyon) writer.WriteLine("80");
+
+ writer.WriteLine("");
+ writer.WriteLine("");
+ writer.WriteLine("");
+ }
+ }
+
+ //close PatternTrack
+ writer.WriteLine("");
+ writer.WriteLine("");
+ }
+
+ //noise track generation
+ {
+ writer.WriteLine("");
+ writer.WriteLine("");
+
+ for (int i = 0; i < configuredPatternLength; i++)
+ {
+ int patLine = i;
+
+ int index = i + time;
+ if (index >= Log.Count) continue;
+
+ var rec = Log[index];
+
+ NoiseState noise = rec.noise;
+
+ //transform quieted notes to dead notes
+ //blech its buggy, im tired
+ //if (noise.vol == 0)
+ // noise.en = false;
+
+ {
+ bool keyoff = false, keyon = false;
+ if (noise_lastNote != -1 && !noise.en)
+ {
+ noise_lastNote = -1;
+ keyoff = true;
+ }
+ else if (noise_lastNote != noise.note && noise.en)
+ keyon = true;
+
+ if (noise.en)
+ noise_lastNote = noise.note;
+
+ writer.WriteLine("", patLine);
+ writer.WriteLine("");
+ writer.WriteLine("");
+ if (keyon)
+ {
+ writer.WriteLine("{0}", NameForNote(noise.note));
+ writer.WriteLine("04");
+ }
+ else if (keyoff) writer.WriteLine("OFF");
+
+ if (noise_lastNote != -1)
+ writer.WriteLine("{0:X2}", noise.vol * 8);
+
+ writer.WriteLine("");
+ writer.WriteLine("");
+ writer.WriteLine("");
+ }
+ }
+
+ //close PatternTrack
+ writer.WriteLine("");
+ writer.WriteLine("");
+ } //noise track generation
+
+ //write empty track for now for pcm
+ for (int TRACK = 4; TRACK < 5; TRACK++)
+ {
+ writer.WriteLine("");
+ writer.WriteLine("");
+ writer.WriteLine("");
+ writer.WriteLine("");
+ }
+
+ //we definitely need a dummy master track now
+ writer.WriteLine("");
+ writer.WriteLine("");
+
+ //close tracks
+ writer.WriteLine("");
+
+ //close pattern
+ writer.WriteLine("");
+
+ time += configuredPatternLength;
+
+ } //main pattern loop
+
+ writer.WriteLine("");
+ writer.Flush();
+
+ var xNewPatternList = XElement.Parse(writer.ToString());
+ xPatternPool.Add(xNewPatternList);
+
+ //write pattern sequence
+ writer = new StringWriter();
+ writer.WriteLine("");
+ for (int i = 0; i < patternCount; i++)
+ {
+ writer.WriteLine("");
+ writer.WriteLine("false");
+ writer.WriteLine("{0}", i);
+ writer.WriteLine("");
+ }
+ writer.WriteLine("");
+
+ var xPatternSequence = templateRoot.XPathSelectElement("//PatternSequence");
+ xPatternSequence.XPathSelectElement("SequenceEntries").Remove();
+ xPatternSequence.Add(XElement.Parse(writer.ToString()));
+
+ //copy template file to target
+ File.Delete(outPath);
+ File.Copy(templatePath, outPath);
+
+ var msOutXml = new MemoryStream();
+ templateRoot.Save(msOutXml);
+ msOutXml.Flush();
+ msOutXml.Position = 0;
+ var zfOutput = new ICSharpCode.SharpZipLib.Zip.ZipFile(outPath);
+ zfOutput.BeginUpdate();
+ zfOutput.Add(new Stupid { stream = msOutXml }, "Song.xml");
+ zfOutput.CommitUpdate();
+ zfOutput.Close();
+
+ //for easier debugging, write patterndata XML
+ //DUMP_TO_DISK(msOutXml.ToArray())
+ }
+
+
+ List Log = new List();
+
+ void DebugCallback()
+ {
+ //fpulse = fCPU/(16*(t+1)) (where fCPU is 1.789773 MHz for NTSC, 1.662607 MHz for PAL, and 1.773448 MHz for Dendy)
+ //ftriangle = fCPU/(32*(tval + 1))
+
+ var nes = _emu as NES;
+ var apu = nes.apu;
+
+ //evaluate the pitches
+ int pulse0_period = apu.pulse[0].timer_reload_value;
+ float pulse0_freq = 1789773.0f / (16.0f * (pulse0_period + 1));
+ int pulse0_note = FindNearestNote(pulse0_freq);
+
+ int pulse1_period = apu.pulse[1].timer_reload_value;
+ float pulse1_freq = 1789773.0f / (16.0f * (pulse1_period + 1));
+ int pulse1_note = FindNearestNote(pulse1_freq);
+
+ int tri_period = apu.triangle.Debug_PeriodValue;
+ float tri_freq = 1789773.0f / (32.0f * (tri_period + 1));
+ int tri_note = FindNearestNote(tri_freq);
+
+ //uncertain
+ int noise_period = apu.noise.Debug_Period;
+ float noise_freq = 1789773.0f / (16.0f * (noise_period + 1));
+ int noise_note = FindNearestNote(noise_freq);
+
+ //create the record
+ ApuState rec = new ApuState();
+ rec.pulse0.en = !apu.pulse[0].Debug_IsSilenced;
+ rec.pulse0.vol = (byte)apu.pulse[0].Debug_Volume;
+ rec.pulse0.note = pulse0_note;
+ rec.pulse0.type = (byte)apu.pulse[0].Debug_DutyType;
+ rec.pulse1.en = !apu.pulse[1].Debug_IsSilenced;
+ rec.pulse1.vol = (byte)apu.pulse[1].Debug_Volume;
+ rec.pulse1.note = pulse1_note;
+ rec.pulse1.type = (byte)apu.pulse[1].Debug_DutyType;
+ rec.triangle.en = !apu.triangle.Debug_IsSilenced;
+ rec.triangle.note = tri_note;
+ rec.noise.en = !apu.noise.Debug_IsSilenced;
+ rec.noise.vol = (byte)apu.noise.Debug_Volume;
+ rec.noise.note = noise_note;
+
+ Log.Add(rec);
+
+ SyncContents();
+ }
+
+ void SyncContents()
+ {
+ lblContents.Text = string.Format("{0} Rows", Log.Count);
+ }
+
+ private void btnControl_Click(object sender, EventArgs e)
+ {
+ var nes = _emu as NES;
+
+ if(IsRunning)
+ {
+ SyncContents();
+ nes.apu.DebugCallback = null;
+ nes.apu.DebugCallbackDivider = 0;
+ IsRunning = false;
+ btnControl.Text = "Start";
+ }
+ else
+ {
+ Log.Clear();
+ nes.apu.DebugCallback = DebugCallback;
+ nes.apu.DebugCallbackDivider = int.Parse(txtDivider.Text);
+ IsRunning = true;
+ btnControl.Text = "Stop";
+ }
+ }
+
+ private void ExitMenuItem_Click(object sender, EventArgs e)
+ {
+ Close();
+ }
+
+ private void NESMusicRipper_FormClosed(object sender, FormClosedEventArgs e)
+ {
+ var nes = _emu as NES;
+ var apu = nes.apu;
+ apu.DebugCallbackDivider = 0;
+ apu.DebugCallbackTimer = 0;
+ apu.DebugCallback = null;
+ }
+
+ }
+}
diff --git a/BizHawk.Client.EmuHawk/tools/NES/NESMusicRipper.resx b/BizHawk.Client.EmuHawk/tools/NES/NESMusicRipper.resx
new file mode 100644
index 00000000000..803443a4c17
--- /dev/null
+++ b/BizHawk.Client.EmuHawk/tools/NES/NESMusicRipper.resx
@@ -0,0 +1,128 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ How to use:
+Create a file called template.xrns in the directory you are going to export to. This tool will load that and replace the patterns with the logged data.
+Make sure the template has 5 tracks. There should be pulse waveforms in instruments (0,1,2,3), noise in instrument 4, and a triangle in instrument 8.
+
+
+ 17, 17
+
+
\ No newline at end of file
diff --git a/BizHawk.Client.EmuHawk/tools/SNES/SNESGameGenie.cs b/BizHawk.Client.EmuHawk/tools/SNES/SNESGameGenie.cs
index 1ed8e904829..7572eef6d9c 100644
--- a/BizHawk.Client.EmuHawk/tools/SNES/SNESGameGenie.cs
+++ b/BizHawk.Client.EmuHawk/tools/SNES/SNESGameGenie.cs
@@ -211,7 +211,7 @@ private void AddCheat_Click(object sender, EventArgs e)
}
var watch = Watch.GenerateWatch(
- MemoryDomains["BUS"],
+ MemoryDomains["System Bus"],
address,
Watch.WatchSize.Byte,
Watch.DisplayType.Hex,
diff --git a/BizHawk.Client.EmuHawk/tools/ToolManager.cs b/BizHawk.Client.EmuHawk/tools/ToolManager.cs
index 7834fd95eee..0f7984e8644 100644
--- a/BizHawk.Client.EmuHawk/tools/ToolManager.cs
+++ b/BizHawk.Client.EmuHawk/tools/ToolManager.cs
@@ -319,6 +319,20 @@ public IToolForm Get() where T : IToolForm
return Load(false);
}
+ public IEnumerable AvailableTools
+ {
+ get
+ {
+ //return _tools.Where(t => !t.IsDisposed);
+ return Assembly
+ .GetAssembly(typeof(IToolForm))
+ .GetTypes()
+ .Where(t => typeof(IToolForm).IsAssignableFrom(t))
+ .Where(t => !t.IsInterface)
+ .Where(t => IsAvailable(t));
+ }
+ }
+
public void UpdateBefore()
{
var beforeList = _tools.Where(x => x.UpdateBefore);
@@ -548,7 +562,12 @@ public void FastUpdateAfter()
public bool IsAvailable()
{
- return ServiceInjector.IsAvailable(Global.Emulator.ServiceProvider, typeof(T));
+ return IsAvailable(typeof(T));
+ }
+
+ public bool IsAvailable(Type t)
+ {
+ return ServiceInjector.IsAvailable(Global.Emulator.ServiceProvider, t);
}
// Eventually we want a single game genie tool, then this mess goes away
diff --git a/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/AppleIISchema.cs b/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/AppleIISchema.cs
new file mode 100644
index 00000000000..ec9bf15be82
--- /dev/null
+++ b/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/AppleIISchema.cs
@@ -0,0 +1,512 @@
+using System.Collections.Generic;
+using System.Drawing;
+
+namespace BizHawk.Client.EmuHawk
+{
+ [SchemaAttributes("AppleII")]
+ public class AppleIISchema : IVirtualPadSchema
+ {
+ public IEnumerable GetPadSchemas()
+ {
+ yield return Keyboard();
+ yield return DiskSelection();
+ }
+
+ private static PadSchema Keyboard()
+ {
+ return new PadSchema
+ {
+ DisplayName = "Keyboard",
+ IsConsole = false,
+ DefaultSize = new Size(390, 150),
+ Buttons = new[]
+ {
+ /************************** Row 1 **************************/
+ new PadSchema.ButtonScema
+ {
+ Name = "Escape",
+ DisplayName = "Esc",
+ Location = new Point(10, 18),
+ Type = PadSchema.PadInputType.Boolean
+ },
+ new PadSchema.ButtonScema
+ {
+ Name = "1",
+ DisplayName = "1",
+ Location = new Point(46, 18),
+ Type = PadSchema.PadInputType.Boolean
+ },
+ new PadSchema.ButtonScema
+ {
+ Name = "2",
+ DisplayName = "2",
+ Location = new Point(70, 18),
+ Type = PadSchema.PadInputType.Boolean
+ },
+ new PadSchema.ButtonScema
+ {
+ Name = "3",
+ DisplayName = "3",
+ Location = new Point(94, 18),
+ Type = PadSchema.PadInputType.Boolean
+ },
+ new PadSchema.ButtonScema
+ {
+ Name = "4",
+ DisplayName = "4",
+ Location = new Point(118, 18),
+ Type = PadSchema.PadInputType.Boolean
+ },
+ new PadSchema.ButtonScema
+ {
+ Name = "5",
+ DisplayName = "5",
+ Location = new Point(142, 18),
+ Type = PadSchema.PadInputType.Boolean
+ },
+ new PadSchema.ButtonScema
+ {
+ Name = "6",
+ DisplayName = "6",
+ Location = new Point(166, 18),
+ Type = PadSchema.PadInputType.Boolean
+ },
+ new PadSchema.ButtonScema
+ {
+ Name = "7",
+ DisplayName = "7",
+ Location = new Point(190, 18),
+ Type = PadSchema.PadInputType.Boolean
+ },
+ new PadSchema.ButtonScema
+ {
+ Name = "8",
+ DisplayName = "8",
+ Location = new Point(214, 18),
+ Type = PadSchema.PadInputType.Boolean
+ },
+ new PadSchema.ButtonScema
+ {
+ Name = "9",
+ DisplayName = "9",
+ Location = new Point(238, 18),
+ Type = PadSchema.PadInputType.Boolean
+ },
+ new PadSchema.ButtonScema
+ {
+ Name = "0",
+ DisplayName = "0",
+ Location = new Point(262, 18),
+ Type = PadSchema.PadInputType.Boolean
+ },
+ new PadSchema.ButtonScema
+ {
+ Name = "-",
+ DisplayName = "-",
+ Location = new Point(286, 18),
+ Type = PadSchema.PadInputType.Boolean
+ },
+ new PadSchema.ButtonScema
+ {
+ Name = "=",
+ DisplayName = "=",
+ Location = new Point(307, 18),
+ Type = PadSchema.PadInputType.Boolean
+ },
+ new PadSchema.ButtonScema
+ {
+ Name = "Delete",
+ DisplayName = "Delete",
+ Location = new Point(331, 18),
+ Type = PadSchema.PadInputType.Boolean
+ },
+
+ /************************** Row 2 **************************/
+ new PadSchema.ButtonScema
+ {
+ Name = "Tab",
+ DisplayName = " Tab ",
+ Location = new Point(10, 42),
+ Type = PadSchema.PadInputType.Boolean
+ },
+ new PadSchema.ButtonScema
+ {
+ Name = "Q",
+ DisplayName = "Q",
+ Location = new Point(52, 42),
+ Type = PadSchema.PadInputType.Boolean
+ },
+
+ new PadSchema.ButtonScema
+ {
+ Name = "W",
+ DisplayName = "W",
+ Location = new Point(78, 42),
+ Type = PadSchema.PadInputType.Boolean
+ },
+ new PadSchema.ButtonScema
+ {
+ Name = "E",
+ DisplayName = "E",
+ Location = new Point(106, 42),
+ Type = PadSchema.PadInputType.Boolean
+ },
+ new PadSchema.ButtonScema
+ {
+ Name = "R",
+ DisplayName = "R",
+ Location = new Point(130, 42),
+ Type = PadSchema.PadInputType.Boolean
+ },
+ new PadSchema.ButtonScema
+ {
+ Name = "T",
+ DisplayName = "T",
+ Location = new Point(156, 42),
+ Type = PadSchema.PadInputType.Boolean
+ },
+ new PadSchema.ButtonScema
+ {
+ Name = "Y",
+ DisplayName = "Y",
+ Location = new Point(180, 42),
+ Type = PadSchema.PadInputType.Boolean
+ },
+ new PadSchema.ButtonScema
+ {
+ Name = "U",
+ DisplayName = "U",
+ Location = new Point(204, 42),
+ Type = PadSchema.PadInputType.Boolean
+ },
+ new PadSchema.ButtonScema
+ {
+ Name = "I",
+ DisplayName = "I",
+ Location = new Point(230, 42),
+ Type = PadSchema.PadInputType.Boolean
+ },
+ new PadSchema.ButtonScema
+ {
+ Name = "O",
+ DisplayName = "O",
+ Location = new Point(250, 42),
+ Type = PadSchema.PadInputType.Boolean
+ },
+ new PadSchema.ButtonScema
+ {
+ Name = "P",
+ DisplayName = "P",
+ Location = new Point(276, 42),
+ Type = PadSchema.PadInputType.Boolean
+ },
+ new PadSchema.ButtonScema
+ {
+ Name = "[",
+ DisplayName = "[",
+ Location = new Point(302, 42),
+ Type = PadSchema.PadInputType.Boolean
+ },
+ new PadSchema.ButtonScema
+ {
+ Name = "]",
+ DisplayName = "]",
+ Location = new Point(325, 42),
+ Type = PadSchema.PadInputType.Boolean
+ },
+ new PadSchema.ButtonScema
+ {
+ Name = "\\",
+ DisplayName = " \\ ",
+ Location = new Point(349, 42),
+ Type = PadSchema.PadInputType.Boolean
+ },
+
+ /************************** Row 3 **************************/
+ new PadSchema.ButtonScema
+ {
+ Name = "Control",
+ DisplayName = " Control ",
+ Location = new Point(10, 66),
+ Type = PadSchema.PadInputType.Boolean
+ },
+ new PadSchema.ButtonScema
+ {
+ Name = "A",
+ DisplayName = "A",
+ Location = new Point(66, 66),
+ Type = PadSchema.PadInputType.Boolean
+ },
+ new PadSchema.ButtonScema
+ {
+ Name = "S",
+ DisplayName = "S",
+ Location = new Point(90, 66),
+ Type = PadSchema.PadInputType.Boolean
+ },
+ new PadSchema.ButtonScema
+ {
+ Name = "D",
+ DisplayName = "D",
+ Location = new Point(114, 66),
+ Type = PadSchema.PadInputType.Boolean
+ },
+ new PadSchema.ButtonScema
+ {
+ Name = "F",
+ DisplayName = "F",
+ Location = new Point(140, 66),
+ Type = PadSchema.PadInputType.Boolean
+ },
+ new PadSchema.ButtonScema
+ {
+ Name = "G",
+ DisplayName = "G",
+ Location = new Point(164, 66),
+ Type = PadSchema.PadInputType.Boolean
+ },
+ new PadSchema.ButtonScema
+ {
+ Name = "H",
+ DisplayName = "H",
+ Location = new Point(190, 66),
+ Type = PadSchema.PadInputType.Boolean
+ },
+ new PadSchema.ButtonScema
+ {
+ Name = "J",
+ DisplayName = "J",
+ Location = new Point(216, 66),
+ Type = PadSchema.PadInputType.Boolean
+ },
+ new PadSchema.ButtonScema
+ {
+ Name = "K",
+ DisplayName = "K",
+ Location = new Point(238, 66),
+ Type = PadSchema.PadInputType.Boolean
+ },
+ new PadSchema.ButtonScema
+ {
+ Name = "L",
+ DisplayName = "L",
+ Location = new Point(262, 66),
+ Type = PadSchema.PadInputType.Boolean
+ },
+ new PadSchema.ButtonScema
+ {
+ Name = ";",
+ DisplayName = ";",
+ Location = new Point(286, 66),
+ Type = PadSchema.PadInputType.Boolean
+ },
+ new PadSchema.ButtonScema
+ {
+ Name = "'",
+ DisplayName = "'",
+ Location = new Point(307, 66),
+ Type = PadSchema.PadInputType.Boolean
+ },
+ new PadSchema.ButtonScema
+ {
+ Name = "Return",
+ DisplayName = "Return",
+ Location = new Point(328, 66),
+ Type = PadSchema.PadInputType.Boolean
+ },
+
+ /************************** Row 4 **************************/
+ new PadSchema.ButtonScema
+ {
+ Name = "Shift",
+ DisplayName = " Shift ",
+ Location = new Point(10, 90),
+ Type = PadSchema.PadInputType.Boolean
+ },
+ new PadSchema.ButtonScema
+ {
+ Name = "Z",
+ DisplayName = "Z",
+ Location = new Point(80, 90),
+ Type = PadSchema.PadInputType.Boolean
+ },
+ new PadSchema.ButtonScema
+ {
+ Name = "X",
+ DisplayName = "X",
+ Location = new Point(106, 90),
+ Type = PadSchema.PadInputType.Boolean
+ },
+ new PadSchema.ButtonScema
+ {
+ Name = "C",
+ DisplayName = "C",
+ Location = new Point(130, 90),
+ Type = PadSchema.PadInputType.Boolean
+ },
+ new PadSchema.ButtonScema
+ {
+ Name = "V",
+ DisplayName = "V",
+ Location = new Point(154, 90),
+ Type = PadSchema.PadInputType.Boolean
+ },
+ new PadSchema.ButtonScema
+ {
+ Name = "B",
+ DisplayName = "B",
+ Location = new Point(178, 90),
+ Type = PadSchema.PadInputType.Boolean
+ },
+ new PadSchema.ButtonScema
+ {
+ Name = "N",
+ DisplayName = "N",
+ Location = new Point(202, 90),
+ Type = PadSchema.PadInputType.Boolean
+ },
+ new PadSchema.ButtonScema
+ {
+ Name = "M",
+ DisplayName = "M",
+ Location = new Point(226, 90),
+ Type = PadSchema.PadInputType.Boolean
+ },
+ new PadSchema.ButtonScema
+ {
+ Name = ",",
+ DisplayName = ",",
+ Location = new Point(252, 90),
+ Type = PadSchema.PadInputType.Boolean
+ },
+ new PadSchema.ButtonScema
+ {
+ Name = ".",
+ DisplayName = ".",
+ Location = new Point(272, 90),
+ Type = PadSchema.PadInputType.Boolean
+ },
+ new PadSchema.ButtonScema
+ {
+ Name = "/",
+ DisplayName = "/",
+ Location = new Point(292, 90),
+ Type = PadSchema.PadInputType.Boolean
+ },
+ new PadSchema.ButtonScema
+ {
+ Name = "Shift",
+ DisplayName = " Shift ",
+ Location = new Point(315, 90),
+ Type = PadSchema.PadInputType.Boolean
+ },
+
+
+ /************************** Row 5 **************************/
+
+ new PadSchema.ButtonScema
+ {
+ Name = "Caps Lock",
+ DisplayName = "Caps",
+ Location = new Point(10, 114),
+ Type = PadSchema.PadInputType.Boolean
+ },
+ new PadSchema.ButtonScema
+ {
+ Name = "`",
+ DisplayName = "~",
+ Location = new Point(52, 114),
+ Type = PadSchema.PadInputType.Boolean
+ },
+ new PadSchema.ButtonScema
+ {
+ Name = "White Apple",
+ DisplayName = "<",
+ Location = new Point(96, 114),
+ Type = PadSchema.PadInputType.Boolean
+ },
+
+
+ new PadSchema.ButtonScema
+ {
+ Name = "Space",
+ DisplayName = " Space ",
+ Location = new Point(120, 114),
+ Type = PadSchema.PadInputType.Boolean
+ },
+
+ new PadSchema.ButtonScema
+ {
+ Name = "Black Apple",
+ DisplayName = ">",
+ Location = new Point(265, 114),
+ Type = PadSchema.PadInputType.Boolean
+ },
+
+ new PadSchema.ButtonScema
+ {
+ Name = "Left",
+ DisplayName = "",
+ Icon = Properties.Resources.Back,
+ Location = new Point(289, 114),
+ Type = PadSchema.PadInputType.Boolean
+ },
+
+ new PadSchema.ButtonScema
+ {
+ Name = "Right",
+ DisplayName = "",
+ Icon = Properties.Resources.Forward,
+ Location = new Point(311, 114),
+ Type = PadSchema.PadInputType.Boolean
+ },
+
+ new PadSchema.ButtonScema
+ {
+ Name = "Down",
+ DisplayName = "",
+ Icon = Properties.Resources.BlueDown,
+ Location = new Point(333, 114),
+ Type = PadSchema.PadInputType.Boolean
+ },
+
+ new PadSchema.ButtonScema
+ {
+ Name = "Up",
+ DisplayName = "",
+ Icon = Properties.Resources.BlueUp,
+ Location = new Point(355, 114),
+ Type = PadSchema.PadInputType.Boolean
+ }
+ }
+ };
+ }
+
+ private static PadSchema DiskSelection()
+ {
+ return new PadSchema
+ {
+ DisplayName = "Disk Selection",
+ IsConsole = false,
+ DefaultSize = new Size(120, 50),
+ Buttons = new[]
+ {
+ new PadSchema.ButtonScema
+ {
+ Name = "Next Disk",
+ DisplayName = "Next",
+ Location = new Point(10, 18),
+ Type = PadSchema.PadInputType.Boolean
+ },
+ new PadSchema.ButtonScema
+ {
+ Name = "Previous Disk",
+ DisplayName = "Previous",
+ Location = new Point(50, 18),
+ Type = PadSchema.PadInputType.Boolean
+ },
+ }
+ };
+ }
+ }
+}
diff --git a/BizHawk.Client.EmuHawk/tools/Watch/RamSearch.cs b/BizHawk.Client.EmuHawk/tools/Watch/RamSearch.cs
index df0b5bbcc75..3a407529ec4 100644
--- a/BizHawk.Client.EmuHawk/tools/Watch/RamSearch.cs
+++ b/BizHawk.Client.EmuHawk/tools/Watch/RamSearch.cs
@@ -70,7 +70,7 @@ public RamSearch()
[RequiredService]
public IEmulator Emu { get; set; }
- [RequiredService]
+ [OptionalService]
public IInputPollable InputPollableCore { get; set; }
[ConfigPersist]
@@ -270,7 +270,7 @@ public void UpdateValues()
if (_autoSearch)
{
- if (Settings.AutoSearchTakeLagFramesIntoAccount && InputPollableCore.IsLagFrame)
+ if (InputPollableCore != null && Settings.AutoSearchTakeLagFramesIntoAccount && InputPollableCore.IsLagFrame)
{
// Do nothing
}
diff --git a/BizHawk.Common/Extensions/BufferExtensions.cs b/BizHawk.Common/Extensions/BufferExtensions.cs
index fde22c76ee5..eeec0f2ce39 100644
--- a/BizHawk.Common/Extensions/BufferExtensions.cs
+++ b/BizHawk.Common/Extensions/BufferExtensions.cs
@@ -18,18 +18,22 @@ public static void SaveAsHex(this byte[] buffer, TextWriter writer)
writer.WriteLine();
}
+ private static readonly char[] HexConvArr = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
+
public unsafe static void SaveAsHexFast(this byte[] buffer, TextWriter writer)
{
- char* table = Util.HexConvPtr;
- if (buffer.Length > 0)
+ fixed (char* table = HexConvArr)
{
- int len = buffer.Length;
- fixed (byte* src = &buffer[0])
- for (int i = 0; i < len; i++)
- {
- writer.Write(table[src[i] >> 4]);
- writer.Write(table[src[i] & 15]);
- }
+ if (buffer.Length > 0)
+ {
+ int len = buffer.Length;
+ fixed (byte* src = buffer)
+ for (int i = 0; i < len; i++)
+ {
+ writer.Write(table[src[i] >> 4]);
+ writer.Write(table[src[i] & 15]);
+ }
+ }
}
writer.WriteLine();
}
diff --git a/BizHawk.Common/Util.cs b/BizHawk.Common/Util.cs
index fc87baa6e88..58be27a1d2d 100644
--- a/BizHawk.Common/Util.cs
+++ b/BizHawk.Common/Util.cs
@@ -4,20 +4,12 @@
using System.Text;
using BizHawk.Common.BufferExtensions;
+using System.Reflection;
namespace BizHawk.Common
{
public static unsafe class Util
{
- private static readonly char[] HexConvArr = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
- private static System.Runtime.InteropServices.GCHandle HexConvHandle;
-
- static Util()
- {
- HexConvHandle = System.Runtime.InteropServices.GCHandle.Alloc(HexConvArr, System.Runtime.InteropServices.GCHandleType.Pinned);
- HexConvPtr = (char*)HexConvHandle.AddrOfPinnedObject().ToPointer();
- }
-
public static void CopyStream(Stream src, Stream dest, long len)
{
const int size = 0x2000;
@@ -32,8 +24,6 @@ public static void CopyStream(Stream src, Stream dest, long len)
}
}
- public static char* HexConvPtr { get; set; }
-
public static bool IsPowerOfTwo(int x)
{
if (x == 0 || x == 1)
@@ -449,4 +439,32 @@ public static string Next()
return StaticPart + "-" + myctr;
}
}
+
+ public static class ReflectionUtil
+ {
+ // http://stackoverflow.com/questions/9273629/avoid-giving-namespace-name-in-type-gettype
+ ///
+ /// Gets a all Type instances matching the specified class name with just non-namespace qualified class name.
+ ///
+ /// Name of the class sought.
+ /// Types that have the class name specified. They may not be in the same namespace.
+ public static Type[] GetTypeByName(string className)
+ {
+ var returnVal = new List();
+
+ foreach (Assembly a in AppDomain.CurrentDomain.GetAssemblies())
+ {
+ Type[] assemblyTypes = a.GetTypes();
+ for (int j = 0; j < assemblyTypes.Length; j++)
+ {
+ if (assemblyTypes[j].Name.ToLower() == className.ToLower())
+ {
+ returnVal.Add(assemblyTypes[j]);
+ }
+ }
+ }
+
+ return returnVal.ToArray();
+ }
+ }
}
diff --git a/BizHawk.Emulation.Common/Base Implementations/NullEmulator.cs b/BizHawk.Emulation.Common/Base Implementations/NullEmulator.cs
index 67c1b26eacc..3e33d65aeee 100644
--- a/BizHawk.Emulation.Common/Base Implementations/NullEmulator.cs
+++ b/BizHawk.Emulation.Common/Base Implementations/NullEmulator.cs
@@ -120,7 +120,7 @@ public int MaxVolume
public class NullEmulatorSettings
{
- [DefaultValue(true)]
+ [DefaultValue(false)]
public bool SnowyDisplay { get; set; }
public NullEmulatorSettings()
diff --git a/BizHawk.Emulation.Common/Database/Database.cs b/BizHawk.Emulation.Common/Database/Database.cs
index 5f28d9fb1f9..44f9035e4ec 100644
--- a/BizHawk.Emulation.Common/Database/Database.cs
+++ b/BizHawk.Emulation.Common/Database/Database.cs
@@ -341,6 +341,8 @@ public static GameInfo GetGameInfo(byte[] romData, string fileName)
break;
case ".DSK":
+ case ".PO":
+ case ".DO":
game.System = "AppleII";
break;
}
diff --git a/BizHawk.Emulation.Common/Database/FirmwareDatabase.cs b/BizHawk.Emulation.Common/Database/FirmwareDatabase.cs
index 4d42d3c96f1..fd841ef1c09 100644
--- a/BizHawk.Emulation.Common/Database/FirmwareDatabase.cs
+++ b/BizHawk.Emulation.Common/Database/FirmwareDatabase.cs
@@ -191,6 +191,14 @@ static FirmwareDatabase()
Option("PSX", "U", psone_45a, FirmwareOptionStatus.Unacceptable);
Option("PSX", "E", psone_r5e, FirmwareOptionStatus.Unacceptable);
Option("PSX", "J", ps2_50j, FirmwareOptionStatus.Unacceptable);
+
+ Firmware("AppleII", "AppleIIe", "AppleIIe.rom");
+ var appleII_AppleIIe = File("B8EA90ABE135A0031065E01697C4A3A20D51198B", 16384, "AppleIIe.rom", "Apple II e");
+ Option("AppleII", "AppleIIe", appleII_AppleIIe, FirmwareOptionStatus.Acceptable);
+
+ Firmware("AppleII", "DiskII", "DiskII.rom");
+ var appleII_DiskII = File("D4181C9F046AAFC3FB326B381BAAC809D9E38D16", 256, "DiskII.rom", "Disk II");
+ Option("AppleII", "DiskII", appleII_DiskII, FirmwareOptionStatus.Acceptable);
}
//adds a defined firmware ID to the database
diff --git a/BizHawk.Emulation.Common/Interfaces/IInputPollable.cs b/BizHawk.Emulation.Common/Interfaces/IInputPollable.cs
index 54a3ef5f508..6e8599e9fb5 100644
--- a/BizHawk.Emulation.Common/Interfaces/IInputPollable.cs
+++ b/BizHawk.Emulation.Common/Interfaces/IInputPollable.cs
@@ -5,7 +5,7 @@ public interface IInputPollable : IEmulatorService
///
/// The lag count.
///
- int LagCount { get; set; }
+ int LagCount { get; }
///
/// If the current frame is a lag frame.
diff --git a/BizHawk.Emulation.Common/SystemLookup.cs b/BizHawk.Emulation.Common/SystemLookup.cs
index a079f690f6b..b60b187d495 100644
--- a/BizHawk.Emulation.Common/SystemLookup.cs
+++ b/BizHawk.Emulation.Common/SystemLookup.cs
@@ -33,7 +33,8 @@ public class SystemLookup
new SystemInfo { SystemId = "TI83", FullName = "TI-83 Calculator" },
new SystemInfo { SystemId = "WSWAN", FullName = "WonderSwan" },
- new SystemInfo { SystemId = "C64", FullName = "Commodore 64" }
+ new SystemInfo { SystemId = "C64", FullName = "Commodore 64" },
+ new SystemInfo { SystemId = "AppleII", FullName = "Apple II" }
};
public SystemInfo this[string systemId]
diff --git a/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj b/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj
index b2ae4a472fb..6d83c6304ad 100644
--- a/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj
+++ b/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj
@@ -84,6 +84,9 @@
+
+ ..\References\Virtu.dll
+
@@ -116,48 +119,31 @@
-
+
+ AppleII.cs
+
+
AppleII.cs
+
+ AppleII.cs
+
+
+ AppleII.cs
+
+
+ AppleII.cs
+
+
+ AppleII.cs
+
- AppleII.cs
+ AppleII.cs
- AppleII.cs
+ AppleII.cs
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
C64.cs
@@ -398,6 +384,7 @@
+
@@ -415,6 +402,7 @@
Meteor.cs
+
VBANext.cs
diff --git a/BizHawk.Emulation.Cores/Calculator/TI83.IInputPollable.cs b/BizHawk.Emulation.Cores/Calculator/TI83.IInputPollable.cs
index 22927c62ee3..b89f08d9f85 100644
--- a/BizHawk.Emulation.Cores/Calculator/TI83.IInputPollable.cs
+++ b/BizHawk.Emulation.Cores/Calculator/TI83.IInputPollable.cs
@@ -11,7 +11,6 @@ public partial class TI83 : IInputPollable
public int LagCount
{
get { return _lagCount; }
- set { _lagCount = value; }
}
public IInputCallbackSystem InputCallbacks { get; private set; }
diff --git a/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IAudioProvider.cs b/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IAudioProvider.cs
new file mode 100644
index 00000000000..c22f997767f
--- /dev/null
+++ b/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IAudioProvider.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using BizHawk.Emulation.Common;
+
+namespace BizHawk.Emulation.Cores.Computers.AppleII
+{
+ partial class AppleII : ISyncSoundProvider
+ {
+ void ISyncSoundProvider.GetSamples(out short[] samples, out int nsamp)
+ {
+ _machine.Speaker.AudioService.GetSamples(out samples, out nsamp);
+ }
+
+ void ISyncSoundProvider.DiscardSamples()
+ {
+ _machine.Speaker.AudioService.Clear();
+ }
+ }
+}
diff --git a/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IDebuggable.cs b/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IDebuggable.cs
new file mode 100644
index 00000000000..8596f894c48
--- /dev/null
+++ b/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IDebuggable.cs
@@ -0,0 +1,47 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+using BizHawk.Emulation.Common;
+
+namespace BizHawk.Emulation.Cores.Computers.AppleII
+{
+ public partial class AppleII : IDebuggable
+ {
+ [FeatureNotImplemented]
+ public IDictionary GetCpuFlagsAndRegisters()
+ {
+ var regs = _machine.GetCpuFlagsAndRegisters();
+
+ var dic = new Dictionary();
+
+ foreach (var reg in regs)
+ {
+ dic.Add(
+ reg.Key,
+ reg.Key.Contains("Flag")
+ ? reg.Value > 0
+ : (RegisterValue)reg.Value);
+ }
+
+ return dic;
+ }
+
+ [FeatureNotImplemented]
+ public void SetCpuRegister(string register, int value)
+ {
+ throw new NotImplementedException();
+ }
+
+ public bool CanStep(StepType type) { return false; }
+
+ [FeatureNotImplemented]
+ public void Step(StepType type) { throw new NotImplementedException(); }
+
+ public IMemoryCallbackSystem MemoryCallbacks
+ {
+ [FeatureNotImplemented]
+ get { throw new NotImplementedException(); }
+ }
+ }
+}
diff --git a/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IDisassembler.cs b/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IDisassembler.cs
new file mode 100644
index 00000000000..2766a460e10
--- /dev/null
+++ b/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IDisassembler.cs
@@ -0,0 +1,38 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+using BizHawk.Emulation.Common;
+using BizHawk.Emulation.Cores.Components.M6502;
+
+namespace BizHawk.Emulation.Cores.Computers.AppleII
+{
+ public partial class AppleII : IDisassemblable
+ {
+ public string Cpu
+ {
+ get
+ {
+ return "6502";
+ }
+ set
+ {
+ }
+ }
+
+ public string PCRegisterName
+ {
+ get { return "PC"; }
+ }
+
+ public IEnumerable AvailableCpus
+ {
+ get { yield return "6502"; }
+ }
+
+ public string Disassemble(MemoryDomain m, uint addr, out int length)
+ {
+ return MOS6502X.Disassemble((ushort)addr, out length, (a) => m.PeekByte(a));
+ }
+ }
+}
diff --git a/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IEmulator.cs b/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IEmulator.cs
index cf07fe2e335..bf871b57ab5 100644
--- a/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IEmulator.cs
+++ b/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IEmulator.cs
@@ -15,7 +15,7 @@ public ISoundProvider SoundProvider
[FeatureNotImplemented]
public ISyncSoundProvider SyncSoundProvider
{
- get { return _soundService; }
+ get { return this; }
}
[FeatureNotImplemented]
@@ -34,7 +34,6 @@ public ControllerDefinition ControllerDefinition
public IController Controller { get; set; }
-
public int Frame { get; set; }
public string SystemId { get { return "AppleII"; } }
@@ -51,6 +50,8 @@ public void FrameAdvance(bool render, bool rendersound)
public void ResetCounters()
{
Frame = 0;
+ LagCount = 0;
+ IsLagFrame = false;
}
public CoreComm CoreComm { get; private set; }
diff --git a/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IInputPollable.cs b/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IInputPollable.cs
new file mode 100644
index 00000000000..19c29a7f163
--- /dev/null
+++ b/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IInputPollable.cs
@@ -0,0 +1,17 @@
+using BizHawk.Emulation.Common;
+
+namespace BizHawk.Emulation.Cores.Computers.AppleII
+{
+ public partial class AppleII : IInputPollable
+ {
+ public int LagCount { get; private set; }
+
+ public bool IsLagFrame
+ {
+ get { return _machine.Lagged; }
+ private set { _machine.Lagged = value; }
+ }
+
+ public IInputCallbackSystem InputCallbacks { [FeatureNotImplemented]get; private set; }
+ }
+}
diff --git a/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IMemoryDomains.cs b/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IMemoryDomains.cs
new file mode 100644
index 00000000000..623e46e1c40
--- /dev/null
+++ b/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IMemoryDomains.cs
@@ -0,0 +1,52 @@
+using System;
+using System.Collections.Generic;
+
+using BizHawk.Emulation.Common;
+
+namespace BizHawk.Emulation.Cores.Computers.AppleII
+{
+ public partial class AppleII
+ {
+ private void SetupMemoryDomains()
+ {
+ var domains = new List();
+
+ var mainRamDomain = new MemoryDomain("Main Ram", 0xC000, MemoryDomain.Endian.Little,
+ (addr) =>
+ {
+ if (addr < 0 || addr >= 0xC000)
+ throw new ArgumentOutOfRangeException();
+ return (byte)_machine.Memory.Read((int)addr);
+ },
+ (addr, value) =>
+ {
+ if (addr < 0 || addr >= 0xC000)
+ throw new ArgumentOutOfRangeException();
+ _machine.Memory.Write((int)addr, value);
+ });
+
+ domains.Add(mainRamDomain);
+
+ var systemBusDomain = new MemoryDomain("System Bus", 0x10000, MemoryDomain.Endian.Little,
+ (addr) =>
+ {
+ if (addr < 0 || addr >= 65536)
+ throw new ArgumentOutOfRangeException();
+ return (byte)_machine.Memory.Read((int)addr);
+ },
+ (addr, value) =>
+ {
+ if (addr < 0 || addr >= 65536)
+ throw new ArgumentOutOfRangeException();
+ _machine.Memory.Write((int)addr, value);
+ });
+
+ domains.Add(systemBusDomain);
+
+ _memoryDomains = new MemoryDomainList(domains);
+ (ServiceProvider as BasicServiceProvider).Register(_memoryDomains);
+ }
+
+ private IMemoryDomains _memoryDomains;
+ }
+}
diff --git a/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IStatable.cs b/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IStatable.cs
index 6e380cb67f1..8c2bf5ff848 100644
--- a/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IStatable.cs
+++ b/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IStatable.cs
@@ -1,55 +1,152 @@
using BizHawk.Emulation.Common;
using System.IO;
+using System;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+using Jellyfish.Virtu;
+using Newtonsoft.Json.Bson;
namespace BizHawk.Emulation.Cores.Computers.AppleII
{
public partial class AppleII : IStatable
{
+ private class CoreConverter : JsonConverter
+ {
+ public override bool CanConvert(Type objectType)
+ {
+ return objectType == typeof(Machine);
+ }
+
+ public override bool CanRead { get { return true; } }
+ public override bool CanWrite { get { return false; } }
+
+ public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
+ {
+ // uses its own serialization context: intentional
+ return Machine.Deserialize(reader);
+ }
+
+ public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
+ {
+ throw new NotImplementedException();
+ }
+ }
+
public bool BinarySaveStatesPreferred { get { return true; } }
- [FeatureNotImplemented]
- public void SaveStateText(TextWriter writer)
+ private void SerializeEverything(JsonWriter w)
+ {
+ // this is much faster than other possibilities for serialization
+ w.WriteStartObject();
+ w.WritePropertyName("Frame");
+ w.WriteValue(Frame);
+ w.WritePropertyName("LagCount");
+ w.WriteValue(LagCount);
+ w.WritePropertyName("IsLagFrame");
+ w.WriteValue(IsLagFrame);
+ w.WritePropertyName("CurrentDisk");
+ w.WriteValue(CurrentDisk);
+ w.WritePropertyName("PreviousDiskPressed");
+ w.WriteValue(_prevPressed);
+ w.WritePropertyName("NextDiskPressed");
+ w.WriteValue(_nextPressed);
+ w.WritePropertyName("Core");
+ _machine.Serialize(w);
+ w.WriteEndObject();
+ }
+
+ private void DeserializeEverything(JsonReader r)
+ {
+ var o = (OtherData)ser.Deserialize(r, typeof(OtherData));
+ Frame = o.Frame;
+ LagCount = o.LagCount;
+ IsLagFrame = o.IsLagFrame;
+ CurrentDisk = o.CurrentDisk;
+ _machine = o.Core;
+ _prevPressed = o.PreviousDiskPressed;
+ _nextPressed = o.NextDiskPressed;
+ }
+
+ public class OtherData
+ {
+ public int Frame;
+ public int LagCount;
+ public bool IsLagFrame;
+ public int CurrentDisk;
+ public bool PreviousDiskPressed;
+ public bool NextDiskPressed;
+ public Machine Core;
+ }
+
+ private void InitSaveStates()
{
+ ser.Converters.Add(new CoreConverter());
+ }
+
+ private JsonSerializer ser = new JsonSerializer();
+ public void SaveStateText(TextWriter writer)
+ {
+ SerializeEverything(new JsonTextWriter(writer) { Formatting = Formatting.None });
}
- [FeatureNotImplemented]
public void LoadStateText(TextReader reader)
{
+ DeserializeEverything(new JsonTextReader(reader));
+ }
+ /*
+ * These are horrible; the LoadStateBinary() takes over 10x as long as LoadStateText()
+ * Until we figure out why JSON.NET's BSONwriter sucks and how to fix it, stick with text-as-binary
+ public void SaveStateBinary(BinaryWriter writer)
+ {
+ SerializeEverything(new BsonWriter(writer));
+ }
+
+ public void LoadStateBinary(BinaryReader reader)
+ {
+ DeserializeEverything(new BsonReader(reader));
}
+ */
+ /*
+ public void SaveStateBinary(BinaryWriter writer)
+ {
+ var tw = new StreamWriter(writer.BaseStream, new System.Text.UTF8Encoding(false));
+ SaveStateText(tw);
+ tw.Flush();
+ }
+
+ public void LoadStateBinary(BinaryReader reader)
+ {
+ var tr = new StreamReader(reader.BaseStream, System.Text.Encoding.UTF8);
+ LoadStateText(tr);
+ }*/
+ // these homemade classes edge out the stock ones slightly, but need BufferedStream to not be bad
public void SaveStateBinary(BinaryWriter writer)
{
- _machine.SaveState(writer);
+ var buffer = new BufferedStream(writer.BaseStream, 16384);
+ var bw2 = new BinaryWriter(buffer);
+ SerializeEverything(new LBW(bw2));
+ bw2.Flush();
+ buffer.Flush();
}
public void LoadStateBinary(BinaryReader reader)
{
- _machine.LoadState(reader);
+ var buffer = new BufferedStream(reader.BaseStream, 16384);
+ var br2 = new BinaryReader(buffer);
+ DeserializeEverything(new LBR(br2));
}
public byte[] SaveStateBinary()
{
- if (_stateBuffer == null)
- {
- var stream = new MemoryStream();
- var writer = new BinaryWriter(stream);
- SaveStateBinary(writer);
- _stateBuffer = stream.ToArray();
- writer.Close();
- return _stateBuffer;
- }
- else
- {
- var stream = new MemoryStream(_stateBuffer);
- var writer = new BinaryWriter(stream);
- SaveStateBinary(writer);
- writer.Close();
- return _stateBuffer;
- }
+ // our savestate array can be of varying sizes, so this can't be too clever
+ var stream = new MemoryStream();
+ var writer = new BinaryWriter(stream);
+ SaveStateBinary(writer);
+ writer.Flush();
+ return stream.ToArray();
}
-
- private byte[] _stateBuffer;
}
}
diff --git a/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IVideoProvider.cs b/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IVideoProvider.cs
index ea2041f74e7..3de60f4e10d 100644
--- a/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IVideoProvider.cs
+++ b/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IVideoProvider.cs
@@ -3,45 +3,23 @@
namespace BizHawk.Emulation.Cores.Computers.AppleII
{
- public partial class AppleII
+ public partial class AppleII : IVideoProvider
{
- public class BizVideoService : Jellyfish.Virtu.Services.VideoService, IVideoProvider
- {
- public int[] fb;
+ private Jellyfish.Virtu.Services.VideoService _V
+ { get { return _machine.Video.VideoService; } }
- int[] IVideoProvider.GetVideoBuffer() { return fb; }
+ int[] IVideoProvider.GetVideoBuffer() { return _V.fb; }
- // put together, these describe a metric on the screen
- // they should define the smallest size that the buffer can be placed inside such that:
- // 1. no actual pixel data is lost
- // 2. aspect ratio is accurate
- int IVideoProvider.VirtualWidth { get { return 560; } }
- int IVideoProvider.VirtualHeight { get { return 384; } }
+ // put together, these describe a metric on the screen
+ // they should define the smallest size that the buffer can be placed inside such that:
+ // 1. no actual pixel data is lost
+ // 2. aspect ratio is accurate
+ int IVideoProvider.VirtualWidth { get { return 560; } }
+ int IVideoProvider.VirtualHeight { get { return 384; } }
- int IVideoProvider.BufferWidth { get { return 560; } }
- int IVideoProvider.BufferHeight { get { return 384; } }
- int IVideoProvider.BackgroundColor { get { return 0; } }
+ int IVideoProvider.BufferWidth { get { return 560; } }
+ int IVideoProvider.BufferHeight { get { return 384; } }
+ int IVideoProvider.BackgroundColor { get { return 0; } }
- public BizVideoService(Machine machine) :
- base(machine)
- {
- fb = new int[560 * 384];
- }
-
- public override void SetFullScreen(bool isFullScreen)
- {
-
- }
-
- public override void SetPixel(int x, int y, uint color)
- {
- int i = 560 * y + x;
- fb[i] = fb[i + 560] = (int)color;
- }
- public override void Update()
- {
-
- }
- }
}
}
diff --git a/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.cs b/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.cs
index 6a5ee6e9b4b..d08316861a6 100644
--- a/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.cs
+++ b/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.cs
@@ -4,159 +4,160 @@
using Jellyfish.Virtu;
using Jellyfish.Virtu.Services;
using System;
+using System.Collections.Generic;
namespace BizHawk.Emulation.Cores.Computers.AppleII
{
[CoreAttributes(
"Virtu",
- "TODO",
+ "fool",
isPorted: true,
- isReleased: false
+ isReleased: true
)]
- public partial class AppleII : IEmulator, IStatable
+ public partial class AppleII : IEmulator, IDriveLight
{
+ public AppleII(CoreComm comm, IEnumerable gameInfoSet, IEnumerable romSet)
+ : this(comm, gameInfoSet.First(), romSet.First())
+ {
+ GameInfoSet = gameInfoSet.ToList();
+ RomSet = romSet.ToList();
+ }
+
[CoreConstructor("AppleII")]
- public AppleII(CoreComm comm, GameInfo game, byte[] rom, object Settings)
+ public AppleII(CoreComm comm, GameInfo game, byte[] rom)
{
+ GameInfoSet = new List();
+
var ser = new BasicServiceProvider(this);
ServiceProvider = ser;
CoreComm = comm;
_disk1 = rom;
+ RomSet.Add(rom);
- // TODO: get from Firmware provider
- _appleIIRom = File.ReadAllBytes("C:\\apple\\AppleIIe.rom");
- _diskIIRom = File.ReadAllBytes("C:\\apple\\DiskII.rom");
+ _appleIIRom = comm.CoreFileProvider.GetFirmware(
+ SystemId, "AppleIIe", true, "The Apple IIe BIOS firmware is required");
+ _diskIIRom = comm.CoreFileProvider.GetFirmware(
+ SystemId, "DiskII", true, "The DiskII firmware is required");
-
- _machine = new Machine();
+ _machine = new Machine(_appleIIRom, _diskIIRom);
- var vidService = new BizVideoService(_machine);
- _soundService = new BizAudioService(_machine);
- var gpService = new Jellyfish.Virtu.Services.GamePortService(_machine);
- var kbService = new BizKeyboardService(_machine);
-
- _machine.Services.AddService(typeof(Jellyfish.Virtu.Services.DebugService), new Jellyfish.Virtu.Services.DebugService(_machine));
- _machine.Services.AddService(typeof(Jellyfish.Virtu.Services.AudioService), _soundService);
- _machine.Services.AddService(typeof(Jellyfish.Virtu.Services.VideoService), vidService);
- _machine.Services.AddService(typeof(Jellyfish.Virtu.Services.GamePortService), gpService);
- _machine.Services.AddService(typeof(Jellyfish.Virtu.Services.KeyboardService), kbService);
_machine.BizInitialize();
- (ServiceProvider as BasicServiceProvider).Register(vidService);
-
//make a writeable memory stream cloned from the rom.
//for junk.dsk the .dsk is important because it determines the format from that
- var ms = new MemoryStream();
- ms.Write(rom,0,rom.Length);
- ms.Position = 0;
- bool writeProtected = false; //!!!!!!!!!!!!!!!!!!!
- Jellyfish.Virtu.Services.StorageService.LoadFile(ms, stream => _machine.BootDiskII.Drives[0].InsertDisk("junk.dsk", stream, writeProtected));
+ InitDisk();
+
+ InitSaveStates();
+ SetupMemoryDomains();
}
- private readonly Machine _machine;
- private readonly byte[] _disk1;
- private readonly byte[] _appleIIRom;
- private readonly byte[] _diskIIRom;
- private readonly BizAudioService _soundService;
+ public List GameInfoSet { get; private set; }
+ private readonly List RomSet = new List();
- private static readonly ControllerDefinition AppleIIController =
- new ControllerDefinition
- {
- Name = "Apple II Keyboard",
- BoolButtons =
- {
- "Up", "Down", "Left", "Right",
- "Tab", "Enter", "Escape", "Back", "Space",
- "Ctrl", "Shift", "Caps",
- "1", "2", "3", "4", "5", "6", "7", "8", "9", "0",
- "A", "B", "C", "D", "E", "F", "G", "H", "I",
- "J", "K", "L", "M", "N", "O", "P", "Q", "R",
- "S", "T", "U", "V", "W", "X", "Y", "Z"
- }
- };
-
- private class BizKeyboardService : KeyboardService
+ public int CurrentDisk { get; private set; }
+ public int DiskCount { get { return RomSet.Count; } }
+
+ public void SetDisk(int discNum)
{
- public BizKeyboardService(Machine _machine) : base(_machine) { }
- public override bool IsKeyDown(int key)
- {
- return key > 0;
- }
+ CurrentDisk = discNum;
+ InitDisk();
}
- private class BizAudioService : AudioService, ISyncSoundProvider
+ private void IncrementDisk()
{
- public BizAudioService(Machine _machine) : base(_machine) { }
- public override void SetVolume(float volume)
+ CurrentDisk++;
+ if (CurrentDisk >= RomSet.Count)
{
+ CurrentDisk = 0;
}
- public void DiscardSamples()
+
+ InitDisk();
+ }
+
+ private void DecrementDisk()
+ {
+ CurrentDisk--;
+ if (CurrentDisk < 0)
{
- Reset();
+ CurrentDisk = RomSet.Count - 1;
}
+
+ InitDisk();
}
- private void FrameAdv(bool render, bool rendersound)
+
+ private void InitDisk()
{
- _machine.Buttons = GetButtons();
- _machine.BizFrameAdvance();
- Frame++;
+ _disk1 = RomSet[CurrentDisk];
+
+ //make a writeable memory stream cloned from the rom.
+ //for junk.dsk the .dsk is important because it determines the format from that
+ _machine.BootDiskII.Drives[0].InsertDisk("junk.dsk", (byte[])_disk1.Clone(), false);
}
- private Buttons GetButtons()
+ private Machine _machine;
+ private byte[] _disk1;
+ private readonly byte[] _appleIIRom;
+ private readonly byte[] _diskIIRom;
+
+ private static readonly ControllerDefinition AppleIIController;
+
+ private static readonly List RealButtons = new List(Keyboard.GetKeyNames()
+ .Where(k => k != "White Apple") // Hack because these buttons aren't wired up yet
+ .Where(k => k != "Black Apple")
+ .Where(k => k != "Reset"));
+
+ private static readonly List ExtraButtons = new List
+ {
+ "Previous Disk",
+ "Next Disk",
+ };
+
+ static AppleII()
{
- Jellyfish.Virtu.Buttons ret = 0;
- if (Controller["Up"]) ret |= Jellyfish.Virtu.Buttons.Up;
- if (Controller["Down"]) ret |= Jellyfish.Virtu.Buttons.Down;
- if (Controller["Left"]) ret |= Jellyfish.Virtu.Buttons.Left;
- if (Controller["Right"]) ret |= Jellyfish.Virtu.Buttons.Right;
- if (Controller["Tab"]) ret |= Jellyfish.Virtu.Buttons.Tab;
- if (Controller["Enter"]) ret |= Jellyfish.Virtu.Buttons.Enter;
- if (Controller["Escape"]) ret |= Jellyfish.Virtu.Buttons.Escape;
- if (Controller["Back"]) ret |= Jellyfish.Virtu.Buttons.Back;
- if (Controller["Space"]) ret |= Jellyfish.Virtu.Buttons.Space;
- if (Controller["Ctrl"]) ret |= Jellyfish.Virtu.Buttons.Ctrl;
- if (Controller["Shift"]) ret |= Jellyfish.Virtu.Buttons.Shift;
- if (Controller["Caps"]) ret |= Jellyfish.Virtu.Buttons.Caps;
- if (Controller["1"]) ret |= Jellyfish.Virtu.Buttons.Key1;
- if (Controller["2"]) ret |= Jellyfish.Virtu.Buttons.Key2;
- if (Controller["3"]) ret |= Jellyfish.Virtu.Buttons.Key3;
- if (Controller["4"]) ret |= Jellyfish.Virtu.Buttons.Key4;
- if (Controller["5"]) ret |= Jellyfish.Virtu.Buttons.Key5;
- if (Controller["6"]) ret |= Jellyfish.Virtu.Buttons.Key6;
- if (Controller["7"]) ret |= Jellyfish.Virtu.Buttons.Key7;
- if (Controller["8"]) ret |= Jellyfish.Virtu.Buttons.Key8;
- if (Controller["9"]) ret |= Jellyfish.Virtu.Buttons.Key9;
- if (Controller["0"]) ret |= Jellyfish.Virtu.Buttons.Key0;
- if (Controller["A"]) ret |= Jellyfish.Virtu.Buttons.KeyA;
- if (Controller["B"]) ret |= Jellyfish.Virtu.Buttons.KeyB;
- if (Controller["C"]) ret |= Jellyfish.Virtu.Buttons.KeyC;
- if (Controller["D"]) ret |= Jellyfish.Virtu.Buttons.KeyD;
- if (Controller["E"]) ret |= Jellyfish.Virtu.Buttons.KeyE;
- if (Controller["F"]) ret |= Jellyfish.Virtu.Buttons.KeyF;
- if (Controller["G"]) ret |= Jellyfish.Virtu.Buttons.KeyG;
- if (Controller["H"]) ret |= Jellyfish.Virtu.Buttons.KeyH;
- if (Controller["I"]) ret |= Jellyfish.Virtu.Buttons.KeyI;
- if (Controller["J"]) ret |= Jellyfish.Virtu.Buttons.KeyJ;
- if (Controller["K"]) ret |= Jellyfish.Virtu.Buttons.KeyK;
- if (Controller["L"]) ret |= Jellyfish.Virtu.Buttons.KeyL;
- if (Controller["M"]) ret |= Jellyfish.Virtu.Buttons.KeyM;
- if (Controller["N"]) ret |= Jellyfish.Virtu.Buttons.KeyN;
- if (Controller["O"]) ret |= Jellyfish.Virtu.Buttons.KeyO;
- if (Controller["P"]) ret |= Jellyfish.Virtu.Buttons.KeyP;
- if (Controller["Q"]) ret |= Jellyfish.Virtu.Buttons.KeyQ;
- if (Controller["R"]) ret |= Jellyfish.Virtu.Buttons.KeyR;
- if (Controller["S"]) ret |= Jellyfish.Virtu.Buttons.KeyS;
- if (Controller["T"]) ret |= Jellyfish.Virtu.Buttons.KeyT;
- if (Controller["U"]) ret |= Jellyfish.Virtu.Buttons.KeyU;
- if (Controller["V"]) ret |= Jellyfish.Virtu.Buttons.KeyV;
- if (Controller["W"]) ret |= Jellyfish.Virtu.Buttons.KeyW;
- if (Controller["X"]) ret |= Jellyfish.Virtu.Buttons.KeyX;
- if (Controller["Y"]) ret |= Jellyfish.Virtu.Buttons.KeyY;
- if (Controller["Z"]) ret |= Jellyfish.Virtu.Buttons.KeyZ;
-
- return ret;
+ AppleIIController = new ControllerDefinition { Name = "Apple IIe Keyboard" };
+ AppleIIController.BoolButtons.AddRange(RealButtons);
+ AppleIIController.BoolButtons.AddRange(ExtraButtons);
+ }
+
+ public bool DriveLightEnabled { get { return true; } }
+ public bool DriveLightOn { get { return _machine.DriveLight; } }
+
+ private bool _nextPressed = false;
+ private bool _prevPressed = false;
+
+ private void FrameAdv(bool render, bool rendersound)
+ {
+ if (Controller["Next Disk"] && !_nextPressed)
+ {
+ _nextPressed = true;
+ IncrementDisk();
+ }
+ else if (Controller["Previous Disk"] && !_prevPressed)
+ {
+ _prevPressed = true;
+ DecrementDisk();
+ }
+
+ if (!Controller["Next Disk"])
+ {
+ _nextPressed = false;
+ }
+
+ if (!Controller["Previous Disk"])
+ {
+ _prevPressed = false;
+ }
+
+ _machine.BizFrameAdvance(RealButtons.Where(b => Controller[b]));
+ if (IsLagFrame)
+ {
+ LagCount++;
+ }
+
+ Frame++;
}
+
}
}
diff --git a/BizHawk.Emulation.Cores/Computers/AppleII/LBSON.cs b/BizHawk.Emulation.Cores/Computers/AppleII/LBSON.cs
new file mode 100644
index 00000000000..2265df2788a
--- /dev/null
+++ b/BizHawk.Emulation.Cores/Computers/AppleII/LBSON.cs
@@ -0,0 +1,227 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Serialization;
+using System.IO;
+using Newtonsoft.Json.Linq;
+
+namespace BizHawk.Emulation.Cores.Computers.AppleII
+{
+ // barebones classes for writing and reading a simple bson-like format, used to gain a bit of speed in Apple II savestates
+
+ internal enum LBTOK : byte
+ {
+ Null,
+ Undefined,
+ StartArray,
+ EndArray,
+ StartObject,
+ EndObject,
+ Property,
+ S8,
+ U8,
+ S16,
+ U16,
+ S32,
+ U32,
+ S64,
+ U64,
+ False,
+ True,
+ String,
+ F32,
+ F64,
+ ByteArray,
+ }
+
+ public class LBR : JsonReader
+ {
+ public LBR(BinaryReader r)
+ {
+ this.r = r;
+ }
+ private BinaryReader r;
+ public override void Close()
+ {
+ }
+ // as best as I can tell, the serializers refer to depth, but don't actually need to work except when doing certain error recovery
+ public override int Depth { get { return 0; } }
+ public override string Path { get { throw new NotImplementedException(); } }
+ public override Type ValueType { get { return v != null ? v.GetType() : null; } }
+ public override JsonToken TokenType { get { return t; } }
+ public override object Value { get { return v; } }
+ private object v;
+ private JsonToken t;
+
+ public override bool Read()
+ {
+ LBTOK l = (LBTOK)r.ReadByte();
+ switch (l)
+ {
+ case LBTOK.StartArray: t = JsonToken.StartArray; v = null; break;
+ case LBTOK.EndArray: t = JsonToken.EndArray; v = null; break;
+ case LBTOK.StartObject: t = JsonToken.StartObject; v = null; break;
+ case LBTOK.EndObject: t = JsonToken.EndObject; v = null; break;
+ case LBTOK.Null: t = JsonToken.Null; v = null; break;
+ case LBTOK.False: t = JsonToken.Boolean; v = false; break;
+ case LBTOK.True: t = JsonToken.Boolean; v = true; break;
+ case LBTOK.Property: t = JsonToken.PropertyName; v = r.ReadString(); break;
+ case LBTOK.Undefined: t = JsonToken.Undefined; v = null; break;
+ case LBTOK.S8: t = JsonToken.Integer; v = r.ReadSByte(); break;
+ case LBTOK.U8: t = JsonToken.Integer; v = r.ReadByte(); break;
+ case LBTOK.S16: t = JsonToken.Integer; v = r.ReadInt16(); break;
+ case LBTOK.U16: t = JsonToken.Integer; v = r.ReadUInt16(); break;
+ case LBTOK.S32: t = JsonToken.Integer; v = r.ReadInt32(); break;
+ case LBTOK.U32: t = JsonToken.Integer; v = r.ReadUInt32(); break;
+ case LBTOK.S64: t = JsonToken.Integer; v = r.ReadInt64(); break;
+ case LBTOK.U64: t = JsonToken.Integer; v = r.ReadUInt64(); break;
+ case LBTOK.String: t = JsonToken.String; v = r.ReadString(); break;
+ case LBTOK.F32: t = JsonToken.Float; v = r.ReadSingle(); break;
+ case LBTOK.F64: t = JsonToken.Float; v = r.ReadDouble(); break;
+ case LBTOK.ByteArray: t = JsonToken.Bytes; v = r.ReadBytes(r.ReadInt32()); break;
+
+ default:
+ throw new InvalidOperationException();
+ }
+ return true;
+ }
+
+ public override byte[] ReadAsBytes()
+ {
+ if (!Read() || t != JsonToken.Bytes)
+ return null;
+ return (byte[])v;
+ }
+
+ public override DateTime? ReadAsDateTime()
+ {
+ throw new NotImplementedException();
+ }
+
+ public override DateTimeOffset? ReadAsDateTimeOffset()
+ {
+ throw new NotImplementedException();
+ }
+
+ public override decimal? ReadAsDecimal()
+ {
+ throw new NotImplementedException();
+ }
+
+ public override int? ReadAsInt32()
+ {
+ // TODO: speed this up if needed
+ if (!Read())
+ return null;
+
+ switch (t)
+ {
+ case JsonToken.Null:
+ return null;
+ case JsonToken.Integer:
+ case JsonToken.Float:
+ return Convert.ToInt32(v);
+ case JsonToken.String:
+ int i;
+ if (int.TryParse(v.ToString(), out i))
+ return i;
+ else
+ return null;
+ default:
+ return null;
+ }
+ }
+
+ public override string ReadAsString()
+ {
+ if (!Read())
+ return null;
+
+ switch (t)
+ {
+ case JsonToken.Null:
+ return null;
+ case JsonToken.Float:
+ case JsonToken.Integer:
+ case JsonToken.Boolean:
+ case JsonToken.String:
+ return v.ToString();
+ default:
+ return null;
+ }
+ }
+ }
+
+ public class LBW : JsonWriter
+ {
+ private void WT(LBTOK t)
+ {
+ w.Write((byte)t);
+ }
+
+ public LBW(BinaryWriter w)
+ {
+ this.w = w;
+ }
+ private BinaryWriter w;
+
+ public override void Flush()
+ {
+ w.Flush();
+ }
+
+ public override void Close()
+ {
+ }
+
+ public override void WriteValue(bool value) { WT(value ? LBTOK.True : LBTOK.False); }
+
+ public override void WriteValue(sbyte value) { WT(LBTOK.S8); w.Write(value); }
+ public override void WriteValue(byte value) { WT(LBTOK.U8); w.Write(value); }
+ public override void WriteValue(short value) { WT(LBTOK.S16); w.Write(value); }
+ public override void WriteValue(ushort value) { WT(LBTOK.U16); w.Write(value); }
+ public override void WriteValue(int value) { WT(LBTOK.S32); w.Write(value); }
+ public override void WriteValue(uint value) { WT(LBTOK.U32); w.Write(value); }
+ public override void WriteValue(long value) { WT(LBTOK.S64); w.Write(value); }
+ public override void WriteValue(ulong value) { WT(LBTOK.U64); w.Write(value); }
+
+ public override void WriteStartArray() { WT(LBTOK.StartArray); }
+ public override void WriteEndArray() { WT(LBTOK.EndArray); }
+ public override void WriteStartObject() { WT(LBTOK.StartObject); }
+ public override void WriteEndObject() { WT(LBTOK.EndObject); }
+ public override void WriteNull() { WT(LBTOK.Null); }
+ public override void WriteUndefined() { WT(LBTOK.Undefined); }
+
+ public override void WriteValue(float value) { WT(LBTOK.F32); w.Write(value); }
+ public override void WriteValue(double value) { WT(LBTOK.F64); w.Write(value); }
+
+ public override void WriteValue(byte[] value) { WT(LBTOK.ByteArray); w.Write(value.Length); w.Write(value); }
+
+ public override void WriteComment(string text) { throw new NotImplementedException(); }
+ public override void WriteWhitespace(string ws) { throw new NotImplementedException(); }
+ protected override void WriteIndent() { throw new NotImplementedException(); }
+ protected override void WriteIndentSpace() { throw new NotImplementedException(); }
+ public override void WriteEnd() { throw new NotImplementedException(); }
+ protected override void WriteEnd(JsonToken token) { throw new NotImplementedException(); }
+ public override void WriteRaw(string json) { throw new NotImplementedException(); }
+ public override void WriteRawValue(string json) { throw new NotImplementedException(); }
+ public override void WriteStartConstructor(string name) { throw new NotImplementedException(); }
+ public override void WriteEndConstructor() { throw new NotImplementedException(); }
+ protected override void WriteValueDelimiter() { throw new NotImplementedException(); }
+
+ public override void WritePropertyName(string name) { WT(LBTOK.Property); w.Write(name); }
+ public override void WriteValue(string value) { WT(LBTOK.String); w.Write(value); }
+ public override void WritePropertyName(string name, bool escape) { WT(LBTOK.Property); w.Write(name); } // no escaping required
+
+ public override void WriteValue(char value) { throw new NotImplementedException(); }
+ public override void WriteValue(DateTime value) { throw new NotImplementedException(); }
+ public override void WriteValue(DateTimeOffset value) { throw new NotImplementedException(); }
+ public override void WriteValue(decimal value) { throw new NotImplementedException(); }
+ public override void WriteValue(Guid value) { throw new NotImplementedException(); }
+ public override void WriteValue(TimeSpan value) { throw new NotImplementedException(); }
+ public override void WriteValue(Uri value) { throw new NotImplementedException(); }
+ }
+
+}
diff --git a/BizHawk.Emulation.Cores/Computers/AppleII/Virtu/Cpu.cs b/BizHawk.Emulation.Cores/Computers/AppleII/Virtu/Cpu.cs
deleted file mode 100644
index 816908ae257..00000000000
--- a/BizHawk.Emulation.Cores/Computers/AppleII/Virtu/Cpu.cs
+++ /dev/null
@@ -1,3261 +0,0 @@
-using System;
-using System.Diagnostics.CodeAnalysis;
-using System.Globalization;
-using System.IO;
-
-namespace Jellyfish.Virtu
-{
- public sealed partial class Cpu : MachineComponent
- {
- public Cpu(Machine machine) :
- base(machine)
- {
- ExecuteOpCode65N02 = new Action[OpCodeCount]
- {
- Execute65X02Brk00, Execute65X02Ora01, Execute65N02Nop02, Execute65N02Nop03,
- Execute65N02Nop04, Execute65X02Ora05, Execute65X02Asl06, Execute65N02Nop07,
- Execute65X02Php08, Execute65X02Ora09, Execute65X02Asl0A, Execute65N02Nop0B,
- Execute65N02Nop0C, Execute65X02Ora0D, Execute65X02Asl0E, Execute65N02Nop0F,
- Execute65X02Bpl10, Execute65X02Ora11, Execute65N02Nop12, Execute65N02Nop13,
- Execute65N02Nop14, Execute65X02Ora15, Execute65X02Asl16, Execute65N02Nop17,
- Execute65X02Clc18, Execute65X02Ora19, Execute65N02Nop1A, Execute65N02Nop1B,
- Execute65N02Nop1C, Execute65X02Ora1D, Execute65N02Asl1E, Execute65N02Nop1F,
- Execute65X02Jsr20, Execute65X02And21, Execute65N02Nop22, Execute65N02Nop23,
- Execute65X02Bit24, Execute65X02And25, Execute65X02Rol26, Execute65N02Nop27,
- Execute65X02Plp28, Execute65X02And29, Execute65X02Rol2A, Execute65N02Nop2B,
- Execute65X02Bit2C, Execute65X02And2D, Execute65X02Rol2E, Execute65N02Nop2F,
- Execute65X02Bmi30, Execute65X02And31, Execute65N02Nop32, Execute65N02Nop33,
- Execute65N02Nop34, Execute65X02And35, Execute65X02Rol36, Execute65N02Nop37,
- Execute65X02Sec38, Execute65X02And39, Execute65N02Nop3A, Execute65N02Nop3B,
- Execute65N02Nop3C, Execute65X02And3D, Execute65N02Rol3E, Execute65N02Nop3F,
- Execute65X02Rti40, Execute65X02Eor41, Execute65N02Nop42, Execute65N02Nop43,
- Execute65N02Nop44, Execute65X02Eor45, Execute65X02Lsr46, Execute65N02Nop47,
- Execute65X02Pha48, Execute65X02Eor49, Execute65X02Lsr4A, Execute65N02Nop4B,
- Execute65X02Jmp4C, Execute65X02Eor4D, Execute65X02Lsr4E, Execute65N02Nop4F,
- Execute65X02Bvc50, Execute65X02Eor51, Execute65N02Nop52, Execute65N02Nop53,
- Execute65N02Nop54, Execute65X02Eor55, Execute65X02Lsr56, Execute65N02Nop57,
- Execute65X02Cli58, Execute65X02Eor59, Execute65N02Nop5A, Execute65N02Nop5B,
- Execute65N02Nop5C, Execute65X02Eor5D, Execute65N02Lsr5E, Execute65N02Nop5F,
- Execute65X02Rts60, Execute65N02Adc61, Execute65N02Nop62, Execute65N02Nop63,
- Execute65N02Nop64, Execute65N02Adc65, Execute65X02Ror66, Execute65N02Nop67,
- Execute65X02Pla68, Execute65N02Adc69, Execute65X02Ror6A, Execute65N02Nop6B,
- Execute65N02Jmp6C, Execute65N02Adc6D, Execute65X02Ror6E, Execute65N02Nop6F,
- Execute65X02Bvs70, Execute65N02Adc71, Execute65N02Nop72, Execute65N02Nop73,
- Execute65N02Nop74, Execute65N02Adc75, Execute65X02Ror76, Execute65N02Nop77,
- Execute65X02Sei78, Execute65N02Adc79, Execute65N02Nop7A, Execute65N02Nop7B,
- Execute65N02Nop7C, Execute65N02Adc7D, Execute65N02Ror7E, Execute65N02Nop7F,
- Execute65N02Nop80, Execute65X02Sta81, Execute65N02Nop82, Execute65N02Nop83,
- Execute65X02Sty84, Execute65X02Sta85, Execute65X02Stx86, Execute65N02Nop87,
- Execute65X02Dey88, Execute65N02Nop89, Execute65X02Txa8A, Execute65N02Nop8B,
- Execute65X02Sty8C, Execute65X02Sta8D, Execute65X02Stx8E, Execute65N02Nop8F,
- Execute65X02Bcc90, Execute65X02Sta91, Execute65N02Nop92, Execute65N02Nop93,
- Execute65X02Sty94, Execute65X02Sta95, Execute65X02Stx96, Execute65N02Nop97,
- Execute65X02Tya98, Execute65X02Sta99, Execute65X02Txs9A, Execute65N02Nop9B,
- Execute65N02Nop9C, Execute65X02Sta9D, Execute65N02Nop9E, Execute65N02Nop9F,
- Execute65X02LdyA0, Execute65X02LdaA1, Execute65X02LdxA2, Execute65N02NopA3,
- Execute65X02LdyA4, Execute65X02LdaA5, Execute65X02LdxA6, Execute65N02NopA7,
- Execute65X02TayA8, Execute65X02LdaA9, Execute65X02TaxAA, Execute65N02NopAB,
- Execute65X02LdyAC, Execute65X02LdaAD, Execute65X02LdxAE, Execute65N02NopAF,
- Execute65X02BcsB0, Execute65X02LdaB1, Execute65N02NopB2, Execute65N02NopB3,
- Execute65X02LdyB4, Execute65X02LdaB5, Execute65X02LdxB6, Execute65N02NopB7,
- Execute65X02ClvB8, Execute65X02LdaB9, Execute65X02TsxBA, Execute65N02NopBB,
- Execute65X02LdyBC, Execute65X02LdaBD, Execute65X02LdxBE, Execute65N02NopBF,
- Execute65X02CpyC0, Execute65X02CmpC1, Execute65N02NopC2, Execute65N02NopC3,
- Execute65X02CpyC4, Execute65X02CmpC5, Execute65X02DecC6, Execute65N02NopC7,
- Execute65X02InyC8, Execute65X02CmpC9, Execute65X02DexCA, Execute65N02NopCB,
- Execute65X02CpyCC, Execute65X02CmpCD, Execute65X02DecCE, Execute65N02NopCF,
- Execute65X02BneD0, Execute65X02CmpD1, Execute65N02NopD2, Execute65N02NopD3,
- Execute65N02NopD4, Execute65X02CmpD5, Execute65X02DecD6, Execute65N02NopD7,
- Execute65X02CldD8, Execute65X02CmpD9, Execute65N02NopDA, Execute65N02NopDB,
- Execute65N02NopDC, Execute65X02CmpDD, Execute65N02DecDE, Execute65N02NopDF,
- Execute65X02CpxE0, Execute65N02SbcE1, Execute65N02NopE2, Execute65N02NopE3,
- Execute65X02CpxE4, Execute65N02SbcE5, Execute65X02IncE6, Execute65N02NopE7,
- Execute65X02InxE8, Execute65N02SbcE9, Execute65X02NopEA, Execute65N02NopEB,
- Execute65X02CpxEC, Execute65N02SbcED, Execute65X02IncEE, Execute65N02NopEF,
- Execute65X02BeqF0, Execute65N02SbcF1, Execute65N02NopF2, Execute65N02NopF3,
- Execute65N02NopF4, Execute65N02SbcF5, Execute65X02IncF6, Execute65N02NopF7,
- Execute65X02SedF8, Execute65N02SbcF9, Execute65N02NopFA, Execute65N02NopFB,
- Execute65N02NopFC, Execute65N02SbcFD, Execute65N02IncFE, Execute65N02NopFF
- };
-
- ExecuteOpCode65C02 = new Action[OpCodeCount]
- {
- Execute65X02Brk00, Execute65X02Ora01, Execute65C02Nop02, Execute65C02Nop03,
- Execute65C02Tsb04, Execute65X02Ora05, Execute65X02Asl06, Execute65C02Nop07,
- Execute65X02Php08, Execute65X02Ora09, Execute65X02Asl0A, Execute65C02Nop0B,
- Execute65C02Tsb0C, Execute65X02Ora0D, Execute65X02Asl0E, Execute65C02Nop0F,
- Execute65X02Bpl10, Execute65X02Ora11, Execute65C02Ora12, Execute65C02Nop13,
- Execute65C02Trb14, Execute65X02Ora15, Execute65X02Asl16, Execute65C02Nop17,
- Execute65X02Clc18, Execute65X02Ora19, Execute65C02Ina1A, Execute65C02Nop1B,
- Execute65C02Trb1C, Execute65X02Ora1D, Execute65C02Asl1E, Execute65C02Nop1F,
- Execute65X02Jsr20, Execute65X02And21, Execute65C02Nop22, Execute65C02Nop23,
- Execute65X02Bit24, Execute65X02And25, Execute65X02Rol26, Execute65C02Nop27,
- Execute65X02Plp28, Execute65X02And29, Execute65X02Rol2A, Execute65C02Nop2B,
- Execute65X02Bit2C, Execute65X02And2D, Execute65X02Rol2E, Execute65C02Nop2F,
- Execute65X02Bmi30, Execute65X02And31, Execute65C02And32, Execute65C02Nop33,
- Execute65C02Bit34, Execute65X02And35, Execute65X02Rol36, Execute65C02Nop37,
- Execute65X02Sec38, Execute65X02And39, Execute65C02Dea3A, Execute65C02Nop3B,
- Execute65C02Bit3C, Execute65X02And3D, Execute65C02Rol3E, Execute65C02Nop3F,
- Execute65X02Rti40, Execute65X02Eor41, Execute65C02Nop42, Execute65C02Nop43,
- Execute65C02Nop44, Execute65X02Eor45, Execute65X02Lsr46, Execute65C02Nop47,
- Execute65X02Pha48, Execute65X02Eor49, Execute65X02Lsr4A, Execute65C02Nop4B,
- Execute65X02Jmp4C, Execute65X02Eor4D, Execute65X02Lsr4E, Execute65C02Nop4F,
- Execute65X02Bvc50, Execute65X02Eor51, Execute65C02Eor52, Execute65C02Nop53,
- Execute65C02Nop54, Execute65X02Eor55, Execute65X02Lsr56, Execute65C02Nop57,
- Execute65X02Cli58, Execute65X02Eor59, Execute65C02Phy5A, Execute65C02Nop5B,
- Execute65C02Nop5C, Execute65X02Eor5D, Execute65C02Lsr5E, Execute65C02Nop5F,
- Execute65X02Rts60, Execute65C02Adc61, Execute65C02Nop62, Execute65C02Nop63,
- Execute65C02Stz64, Execute65C02Adc65, Execute65X02Ror66, Execute65C02Nop67,
- Execute65X02Pla68, Execute65C02Adc69, Execute65X02Ror6A, Execute65C02Nop6B,
- Execute65C02Jmp6C, Execute65C02Adc6D, Execute65X02Ror6E, Execute65C02Nop6F,
- Execute65X02Bvs70, Execute65C02Adc71, Execute65C02Adc72, Execute65C02Nop73,
- Execute65C02Stz74, Execute65C02Adc75, Execute65X02Ror76, Execute65C02Nop77,
- Execute65X02Sei78, Execute65C02Adc79, Execute65C02Ply7A, Execute65C02Nop7B,
- Execute65C02Jmp7C, Execute65C02Adc7D, Execute65C02Ror7E, Execute65C02Nop7F,
- Execute65C02Bra80, Execute65X02Sta81, Execute65C02Nop82, Execute65C02Nop83,
- Execute65X02Sty84, Execute65X02Sta85, Execute65X02Stx86, Execute65C02Nop87,
- Execute65X02Dey88, Execute65C02Bit89, Execute65X02Txa8A, Execute65C02Nop8B,
- Execute65X02Sty8C, Execute65X02Sta8D, Execute65X02Stx8E, Execute65C02Nop8F,
- Execute65X02Bcc90, Execute65X02Sta91, Execute65C02Sta92, Execute65C02Nop93,
- Execute65X02Sty94, Execute65X02Sta95, Execute65X02Stx96, Execute65C02Nop97,
- Execute65X02Tya98, Execute65X02Sta99, Execute65X02Txs9A, Execute65C02Nop9B,
- Execute65C02Stz9C, Execute65X02Sta9D, Execute65C02Stz9E, Execute65C02Nop9F,
- Execute65X02LdyA0, Execute65X02LdaA1, Execute65X02LdxA2, Execute65C02NopA3,
- Execute65X02LdyA4, Execute65X02LdaA5, Execute65X02LdxA6, Execute65C02NopA7,
- Execute65X02TayA8, Execute65X02LdaA9, Execute65X02TaxAA, Execute65C02NopAB,
- Execute65X02LdyAC, Execute65X02LdaAD, Execute65X02LdxAE, Execute65C02NopAF,
- Execute65X02BcsB0, Execute65X02LdaB1, Execute65C02LdaB2, Execute65C02NopB3,
- Execute65X02LdyB4, Execute65X02LdaB5, Execute65X02LdxB6, Execute65C02NopB7,
- Execute65X02ClvB8, Execute65X02LdaB9, Execute65X02TsxBA, Execute65C02NopBB,
- Execute65X02LdyBC, Execute65X02LdaBD, Execute65X02LdxBE, Execute65C02NopBF,
- Execute65X02CpyC0, Execute65X02CmpC1, Execute65C02NopC2, Execute65C02NopC3,
- Execute65X02CpyC4, Execute65X02CmpC5, Execute65X02DecC6, Execute65C02NopC7,
- Execute65X02InyC8, Execute65X02CmpC9, Execute65X02DexCA, Execute65C02NopCB,
- Execute65X02CpyCC, Execute65X02CmpCD, Execute65X02DecCE, Execute65C02NopCF,
- Execute65X02BneD0, Execute65X02CmpD1, Execute65C02CmpD2, Execute65C02NopD3,
- Execute65C02NopD4, Execute65X02CmpD5, Execute65X02DecD6, Execute65C02NopD7,
- Execute65X02CldD8, Execute65X02CmpD9, Execute65C02PhxDA, Execute65C02NopDB,
- Execute65C02NopDC, Execute65X02CmpDD, Execute65C02DecDE, Execute65C02NopDF,
- Execute65X02CpxE0, Execute65C02SbcE1, Execute65C02NopE2, Execute65C02NopE3,
- Execute65X02CpxE4, Execute65C02SbcE5, Execute65X02IncE6, Execute65C02NopE7,
- Execute65X02InxE8, Execute65C02SbcE9, Execute65X02NopEA, Execute65C02NopEB,
- Execute65X02CpxEC, Execute65C02SbcED, Execute65X02IncEE, Execute65C02NopEF,
- Execute65X02BeqF0, Execute65C02SbcF1, Execute65C02SbcF2, Execute65C02NopF3,
- Execute65C02NopF4, Execute65C02SbcF5, Execute65X02IncF6, Execute65C02NopF7,
- Execute65X02SedF8, Execute65C02SbcF9, Execute65C02PlxFA, Execute65C02NopFB,
- Execute65C02NopFC, Execute65C02SbcFD, Execute65C02IncFE, Execute65C02NopFF
- };
- }
-
- public override void Initialize()
- {
- _memory = Machine.Memory;
-
- Is65C02 = true;
- IsThrottled = false;
- Multiplier = 1;
-
- RS = 0xFF;
- }
-
- public override void Reset()
- {
- RS = (RS - 3) & 0xFF; // [4-14]
- RPC = _memory.ReadRomRegionE0FF(0xFFFC) | (_memory.ReadRomRegionE0FF(0xFFFD) << 8);
- RP |= (PB | PI);
- if (Is65C02) // [C-10]
- {
- RP &= ~PD;
- }
- }
-
- public override void LoadState(BinaryReader reader, Version version)
- {
- if (reader == null)
- {
- throw new ArgumentNullException("reader");
- }
-
- Is65C02 = reader.ReadBoolean();
- IsThrottled = reader.ReadBoolean();
- Multiplier = reader.ReadInt32();
-
- RA = reader.ReadInt32();
- RX = reader.ReadInt32();
- RY = reader.ReadInt32();
- RS = reader.ReadInt32();
- RP = reader.ReadInt32();
- RPC = reader.ReadInt32();
- }
-
- public override void SaveState(BinaryWriter writer)
- {
- if (writer == null)
- {
- throw new ArgumentNullException("writer");
- }
-
- writer.Write(Is65C02);
- writer.Write(IsThrottled);
- writer.Write(Multiplier);
-
- writer.Write(RA);
- writer.Write(RX);
- writer.Write(RY);
- writer.Write(RS);
- writer.Write(RP);
- writer.Write(RPC);
- }
-
- public override string ToString()
- {
- return string.Format(CultureInfo.InvariantCulture, "A = 0x{0:X2} X = 0x{1:X2} Y = 0x{2:X2} P = 0x{3:X2} S = 0x01{4:X2} PC = 0x{5:X4} EA = 0x{6:X4} CC = {7}",
- RA, RX, RY, RP, RS, RPC, EA, CC);
- }
-
- public int Execute()
- {
- CC = 0;
- OpCode = _memory.Read(RPC);
- RPC = (RPC + 1) & 0xFFFF;
- _executeOpCode[OpCode]();
- Cycles += CC;
-
- return CC;
- }
-
- #region Core Operand Actions
- private void GetAddressAbs() // abs
- {
- EA = _memory.Read(RPC) | (_memory.Read(RPC + 1) << 8);
- RPC = (RPC + 2) & 0xFFFF;
- }
-
- private void GetAddressAbsX() // abs, x
- {
- EA = (_memory.Read(RPC) + RX + (_memory.Read(RPC + 1) << 8)) & 0xFFFF;
- RPC = (RPC + 2) & 0xFFFF;
- }
-
- private void GetAddressAbsXCC() // abs, x
- {
- int ea = _memory.Read(RPC) + RX;
- EA = (ea + (_memory.Read(RPC + 1) << 8)) & 0xFFFF;
- RPC = (RPC + 2) & 0xFFFF;
- CC += (ea >> 8);
- }
-
- private void GetAddressAbsY() // abs, y
- {
- EA = (_memory.Read(RPC) + RY + (_memory.Read(RPC + 1) << 8)) & 0xFFFF;
- RPC = (RPC + 2) & 0xFFFF;
- }
-
- private void GetAddressAbsYCC() // abs, y
- {
- int ea = _memory.Read(RPC) + RY;
- EA = (ea + (_memory.Read(RPC + 1) << 8)) & 0xFFFF;
- RPC = (RPC + 2) & 0xFFFF;
- CC += (ea >> 8);
- }
-
- private void GetAddressZpg() // zpg
- {
- EA = _memory.Read(RPC);
- RPC = (RPC + 1) & 0xFFFF;
- }
-
- private void GetAddressZpgInd() // (zpg)
- {
- int zp = _memory.Read(RPC);
- EA = _memory.ReadZeroPage(zp) | (_memory.ReadZeroPage((zp + 1) & 0xFF) << 8);
- RPC = (RPC + 1) & 0xFFFF;
- }
-
- private void GetAddressZpgIndX() // (zpg, x)
- {
- int zp = (_memory.Read(RPC) + RX) & 0xFF;
- EA = _memory.ReadZeroPage(zp) | (_memory.ReadZeroPage((zp + 1) & 0xFF) << 8);
- RPC = (RPC + 1) & 0xFFFF;
- }
-
- private void GetAddressZpgIndY() // (zpg), y
- {
- int zp = _memory.Read(RPC);
- EA = (_memory.ReadZeroPage(zp) + RY + (_memory.ReadZeroPage((zp + 1) & 0xFF) << 8)) & 0xFFFF;
- RPC = (RPC + 1) & 0xFFFF;
- }
-
- private void GetAddressZpgIndYCC() // (zpg), y
- {
- int zp = _memory.Read(RPC);
- int ea = _memory.ReadZeroPage(zp) + RY;
- EA = (ea + (_memory.ReadZeroPage((zp + 1) & 0xFF) << 8)) & 0xFFFF;
- RPC = (RPC + 1) & 0xFFFF;
- CC += (ea >> 8);
- }
-
- private void GetAddressZpgX() // zpg, x
- {
- EA = (_memory.Read(RPC) + RX) & 0xFF;
- RPC = (RPC + 1) & 0xFFFF;
- }
-
- private void GetAddressZpgY() // zpg, y
- {
- EA = (_memory.Read(RPC) + RY) & 0xFF;
- RPC = (RPC + 1) & 0xFFFF;
- }
-
- private int Pull()
- {
- RS = (RS + 1) & 0xFF;
-
- return _memory.ReadZeroPage(0x0100 + RS);
- }
-
- private void Push(int data)
- {
- _memory.WriteZeroPage(0x0100 + RS, data);
- RS = (RS - 1) & 0xFF;
- }
-
- private int ReadAbs() // abs
- {
- return _memory.Read(EA);
- }
-
- private int ReadAbsX() // abs, x
- {
- return _memory.Read(EA);
- }
-
- private int ReadAbsY() // abs, y
- {
- return _memory.Read(EA);
- }
-
- private int ReadImm() // imm
- {
- int data = _memory.Read(RPC);
- RPC = (RPC + 1) & 0xFFFF;
-
- return data;
- }
-
- private int ReadZpg() // zpg
- {
- return _memory.ReadZeroPage(EA);
- }
-
- private int ReadZpgInd() // (zpg)
- {
- return _memory.Read(EA);
- }
-
- private int ReadZpgIndX() // (zpg, x)
- {
- return _memory.Read(EA);
- }
-
- private int ReadZpgIndY() // (zpg), y
- {
- return _memory.Read(EA);
- }
-
- private int ReadZpgX() // zpg, x
- {
- return _memory.ReadZeroPage(EA);
- }
-
- private int ReadZpgY() // zpg, y
- {
- return _memory.ReadZeroPage(EA);
- }
-
- private void WriteAbs(int data) // abs
- {
- _memory.Write(EA, data);
- }
-
- private void WriteAbsX(int data) // abs, x
- {
- _memory.Write(EA, data);
- }
-
- private void WriteAbsY(int data) // abs, y
- {
- _memory.Write(EA, data);
- }
-
- private void WriteZpg(int data) // zpg
- {
- _memory.WriteZeroPage(EA, data);
- }
-
- private void WriteZpgInd(int data) // (zpg)
- {
- _memory.Write(EA, data);
- }
-
- private void WriteZpgIndX(int data) // (zpg, x)
- {
- _memory.Write(EA, data);
- }
-
- private void WriteZpgIndY(int data) // (zpg), y
- {
- _memory.Write(EA, data);
- }
-
- private void WriteZpgX(int data) // zpg, x
- {
- _memory.WriteZeroPage(EA, data);
- }
-
- private void WriteZpgY(int data) // zpg, y
- {
- _memory.WriteZeroPage(EA, data);
- }
- #endregion
-
- #region Core OpCode Actions
- private void ExecuteAdc65N02(int data, int cc)
- {
- if ((RP & PD) == 0x0)
- {
- int ra = RA + data + (RP & PC);
- RP = RP & ~(PC | PN | PV | PZ) | ((ra >> 8) & PC) | DataPNZ[ra & 0xFF] | (((~(RA ^ data) & (RA ^ (ra & 0xFF))) >> 1) & PV);
- RA = ra & 0xFF;
- CC += cc;
- }
- else // decimal
- {
- int ral = (RA & 0x0F) + (data & 0x0F) + (RP & PC);
- int rah = (RA >> 4) + (data >> 4);
- if (ral >= 10)
- {
- ral -= 10;
- rah++;
- }
- int ra = (ral | (rah << 4)) & 0xFF;
- RP = RP & ~(PC | PN | PV | PZ) | DataPN[ra] | (((~(RA ^ data) & (RA ^ ra)) >> 1) & PV) | DataPZ[(RA + data + (RP & PC)) & 0xFF];
- if (rah >= 10)
- {
- rah -= 10;
- RP |= PC;
- }
- RA = (ral | (rah << 4)) & 0xFF;
- CC += cc;
- }
- }
-
- private void ExecuteAdc65C02(int data, int cc)
- {
- if ((RP & PD) == 0x0)
- {
- int ra = RA + data + (RP & PC);
- RP = RP & ~(PC | PN | PV | PZ) | ((ra >> 8) & PC) | DataPNZ[ra & 0xFF] | (((~(RA ^ data) & (RA ^ (ra & 0xFF))) >> 1) & PV);
- RA = ra & 0xFF;
- CC += cc;
- }
- else // decimal
- {
- int ral = (RA & 0x0F) + (data & 0x0F) + (RP & PC);
- int rah = (RA >> 4) + (data >> 4);
- if (ral >= 10)
- {
- ral -= 10;
- rah++;
- }
- RP &= ~PC;
- if (rah >= 10)
- {
- rah -= 10;
- RP |= PC;
- }
- int ra = (ral | (rah << 4)) & 0xFF;
- RP = RP & ~(PN | PV | PZ) | DataPNZ[ra] | (((~(RA ^ data) & (RA ^ ra)) >> 1) & PV);
- RA = ra;
- CC += cc + 1;
- }
- }
-
- private void ExecuteAnd(int data, int cc)
- {
- RA &= data;
- RP = RP & ~(PN | PZ) | DataPNZ[RA];
- CC += cc;
- }
-
- private int ExecuteAsl(int data, int cc)
- {
- RP = RP & ~PC | ((data >> 7) & PC);
- data = (data << 1) & 0xFF;
- RP = RP & ~(PN | PZ) | DataPNZ[data];
- CC += cc;
-
- return data;
- }
-
- private void ExecuteAslImp(int cc)
- {
- RP = RP & ~PC | ((RA >> 7) & PC);
- RA = (RA << 1) & 0xFF;
- RP = RP & ~(PN | PZ) | DataPNZ[RA];
- CC += cc;
- }
-
- private void ExecuteBcc(int cc)
- {
- if ((RP & PC) == 0x0)
- {
- int rpc = (RPC + 1) & 0xFFFF;
- RPC = (RPC + 1 + (sbyte)_memory.Read(RPC)) & 0xFFFF;
- CC += cc + 1 + (((RPC ^ rpc) >> 8) & 0x01);
- }
- else
- {
- RPC = (RPC + 1) & 0xFFFF;
- CC += cc;
- }
- }
-
- private void ExecuteBcs(int cc)
- {
- if ((RP & PC) != 0x0)
- {
- int rpc = (RPC + 1) & 0xFFFF;
- RPC = (RPC + 1 + (sbyte)_memory.Read(RPC)) & 0xFFFF;
- CC += cc + 1 + (((RPC ^ rpc) >> 8) & 0x01);
- }
- else
- {
- RPC = (RPC + 1) & 0xFFFF;
- CC += cc;
- }
- }
-
- private void ExecuteBeq(int cc)
- {
- if ((RP & PZ) != 0x0)
- {
- int rpc = (RPC + 1) & 0xFFFF;
- RPC = (RPC + 1 + (sbyte)_memory.Read(RPC)) & 0xFFFF;
- CC += cc + 1 + (((RPC ^ rpc) >> 8) & 0x01);
- }
- else
- {
- RPC = (RPC + 1) & 0xFFFF;
- CC += cc;
- }
- }
-
- private void ExecuteBit(int data, int cc)
- {
- RP = RP & ~(PN | PV | PZ) | (data & (PN | PV)) | DataPZ[RA & data];
- CC += cc;
- }
-
- private void ExecuteBitImm(int data, int cc)
- {
- RP = RP & ~PZ | DataPZ[RA & data];
- CC += cc;
- }
-
- private void ExecuteBmi(int cc)
- {
- if ((RP & PN) != 0x0)
- {
- int rpc = (RPC + 1) & 0xFFFF;
- RPC = (RPC + 1 + (sbyte)_memory.Read(RPC)) & 0xFFFF;
- CC += cc + 1 + (((RPC ^ rpc) >> 8) & 0x01);
- }
- else
- {
- RPC = (RPC + 1) & 0xFFFF;
- CC += cc;
- }
- }
-
- private void ExecuteBne(int cc)
- {
- if ((RP & PZ) == 0x0)
- {
- int rpc = (RPC + 1) & 0xFFFF;
- RPC = (RPC + 1 + (sbyte)_memory.Read(RPC)) & 0xFFFF;
- CC += cc + 1 + (((RPC ^ rpc) >> 8) & 0x01);
- }
- else
- {
- RPC = (RPC + 1) & 0xFFFF;
- CC += cc;
- }
- }
-
- private void ExecuteBpl(int cc)
- {
- if ((RP & PN) == 0x0)
- {
- int rpc = (RPC + 1) & 0xFFFF;
- RPC = (RPC + 1 + (sbyte)_memory.Read(RPC)) & 0xFFFF;
- CC += cc + 1 + (((RPC ^ rpc) >> 8) & 0x01);
- }
- else
- {
- RPC = (RPC + 1) & 0xFFFF;
- CC += cc;
- }
- }
-
- private void ExecuteBra(int cc)
- {
- int rpc = (RPC + 1) & 0xFFFF;
- RPC = (RPC + 1 + (sbyte)_memory.Read(RPC)) & 0xFFFF;
- CC += cc + 1 + (((RPC ^ rpc) >> 8) & 0x01);
- }
-
- private void ExecuteBrk(int cc)
- {
- int rpc = (RPC + 1) & 0xFFFF; // [4-18]
- Push(rpc >> 8);
- Push(rpc & 0xFF);
- Push(RP | PB);
- RP |= PI;
- RPC = _memory.Read(0xFFFE) | (_memory.Read(0xFFFF) << 8);
- CC += cc;
- }
-
- private void ExecuteBvc(int cc)
- {
- if ((RP & PV) == 0x0)
- {
- int rpc = (RPC + 1) & 0xFFFF;
- RPC = (RPC + 1 + (sbyte)_memory.Read(RPC)) & 0xFFFF;
- CC += cc + 1 + (((RPC ^ rpc) >> 8) & 0x01);
- }
- else
- {
- RPC = (RPC + 1) & 0xFFFF;
- CC += cc;
- }
- }
-
- private void ExecuteBvs(int cc)
- {
- if ((RP & PV) != 0x0)
- {
- int rpc = (RPC + 1) & 0xFFFF;
- RPC = (RPC + 1 + (sbyte)_memory.Read(RPC)) & 0xFFFF;
- CC += cc + 1 + (((RPC ^ rpc) >> 8) & 0x01);
- }
- else
- {
- RPC = (RPC + 1) & 0xFFFF;
- CC += cc;
- }
- }
-
- private void ExecuteClc(int cc)
- {
- RP &= ~PC;
- CC += cc;
- }
-
- private void ExecuteCld(int cc)
- {
- RP &= ~PD;
- CC += cc;
- }
-
- private void ExecuteCli(int cc)
- {
- RP &= ~PI;
- CC += cc;
- }
-
- private void ExecuteClv(int cc)
- {
- RP &= ~PV;
- CC += cc;
- }
-
- private void ExecuteCmp(int data, int cc)
- {
- int diff = RA - data;
- RP = RP & ~(PC | PN | PZ) | ((~diff >> 8) & PC) | DataPNZ[diff & 0xFF];
- CC += cc;
- }
-
- private void ExecuteCpx(int data, int cc)
- {
- int diff = RX - data;
- RP = RP & ~(PC | PN | PZ) | ((~diff >> 8) & PC) | DataPNZ[diff & 0xFF];
- CC += cc;
- }
-
- private void ExecuteCpy(int data, int cc)
- {
- int diff = RY - data;
- RP = RP & ~(PC | PN | PZ) | ((~diff >> 8) & PC) | DataPNZ[diff & 0xFF];
- CC += cc;
- }
-
- private void ExecuteDea(int cc)
- {
- RA = (RA - 1) & 0xFF;
- RP = RP & ~(PN | PZ) | DataPNZ[RA];
- CC += cc;
- }
-
- private int ExecuteDec(int data, int cc)
- {
- data = (data - 1) & 0xFF;
- RP = RP & ~(PN | PZ) | DataPNZ[data];
- CC += cc;
-
- return data;
- }
-
- private void ExecuteDex(int cc)
- {
- RX = (RX - 1) & 0xFF;
- RP = RP & ~(PN | PZ) | DataPNZ[RX];
- CC += cc;
- }
-
- private void ExecuteDey(int cc)
- {
- RY = (RY - 1) & 0xFF;
- RP = RP & ~(PN | PZ) | DataPNZ[RY];
- CC += cc;
- }
-
- private void ExecuteEor(int data, int cc)
- {
- RA ^= data;
- RP = RP & ~(PN | PZ) | DataPNZ[RA];
- CC += cc;
- }
-
- private void ExecuteIna(int cc)
- {
- RA = (RA + 1) & 0xFF;
- RP = RP & ~(PN | PZ) | DataPNZ[RA];
- CC += cc;
- }
-
- private int ExecuteInc(int data, int cc)
- {
- data = (data + 1) & 0xFF;
- RP = RP & ~(PN | PZ) | DataPNZ[data];
- CC += cc;
-
- return data;
- }
-
- private void ExecuteInx(int cc)
- {
- RX = (RX + 1) & 0xFF;
- RP = RP & ~(PN | PZ) | DataPNZ[RX];
- CC += cc;
- }
-
- private void ExecuteIny(int cc)
- {
- RY = (RY + 1) & 0xFF;
- RP = RP & ~(PN | PZ) | DataPNZ[RY];
- CC += cc;
- }
-
- [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
- private void ExecuteIrq(int cc)
- {
- Push(RPC >> 8);
- Push(RPC & 0xFF);
- Push(RP & ~PB);
- RP |= PI;
- if (Is65C02) // [C-10]
- {
- RP &= ~PD;
- }
- RPC = _memory.Read(0xFFFE) | (_memory.Read(0xFFFF) << 8);
- CC += cc;
- }
-
- private void ExecuteJmpAbs(int cc) // jmp abs
- {
- RPC = _memory.Read(RPC) | (_memory.Read(RPC + 1) << 8);
- CC += cc;
- }
-
- private void ExecuteJmpAbsInd65N02(int cc) // jmp (abs)
- {
- int ea = _memory.Read(RPC) | (_memory.Read(RPC + 1) << 8);
- RPC = _memory.Read(ea) | (_memory.Read((ea & 0xFF00) | ((ea + 1) & 0x00FF)) << 8);
- CC += cc;
- }
-
- private void ExecuteJmpAbsInd65C02(int cc) // jmp (abs)
- {
- int ea = _memory.Read(RPC) | (_memory.Read(RPC + 1) << 8);
- RPC = _memory.Read(ea) | (_memory.Read(ea + 1) << 8);
- CC += cc;
- }
-
- private void ExecuteJmpAbsIndX(int cc) // jmp (abs, x)
- {
- int ea = (_memory.Read(RPC) + RX + (_memory.Read(RPC + 1) << 8)) & 0xFFFF;
- RPC = _memory.Read(ea) | (_memory.Read(ea + 1) << 8);
- CC += cc;
- }
-
- private void ExecuteJsr(int cc) // jsr abs
- {
- int rpc = (RPC + 1) & 0xFFFF;
- RPC = _memory.Read(RPC) | (_memory.Read(RPC + 1) << 8);
- Push(rpc >> 8);
- Push(rpc & 0xFF);
- CC += cc;
- }
-
- private void ExecuteLda(int data, int cc)
- {
- RA = data;
- RP = RP & ~(PN | PZ) | DataPNZ[RA];
- CC += cc;
- }
-
- private void ExecuteLdx(int data, int cc)
- {
- RX = data;
- RP = RP & ~(PN | PZ) | DataPNZ[RX];
- CC += cc;
- }
-
- private void ExecuteLdy(int data, int cc)
- {
- RY = data;
- RP = RP & ~(PN | PZ) | DataPNZ[RY];
- CC += cc;
- }
-
- private int ExecuteLsr(int data, int cc)
- {
- RP = RP & ~PC | (data & PC);
- data >>= 1;
- RP = RP & ~(PN | PZ) | DataPNZ[data];
- CC += cc;
-
- return data;
- }
-
- private void ExecuteLsrImp(int cc)
- {
- RP = RP & ~PC | (RA & PC);
- RA >>= 1;
- RP = RP & ~(PN | PZ) | DataPNZ[RA];
- CC += cc;
- }
-
- [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
- private void ExecuteNmi(int cc)
- {
- Push(RPC >> 8);
- Push(RPC & 0xFF);
- Push(RP & ~PB);
- RP |= PI;
- if (Is65C02) // [C-10]
- {
- RP &= ~PD;
- }
- RPC = _memory.Read(0xFFFA) | (_memory.Read(0xFFFB) << 8);
- CC += cc;
- }
-
- private void ExecuteNop(int cc)
- {
- CC += cc;
- }
-
- private void ExecuteNop(int data, int cc)
- {
- RPC = (RPC + data) & 0xFFFF;
- CC += cc;
- }
-
- private void ExecuteOra(int data, int cc)
- {
- RA |= data;
- RP = RP & ~(PN | PZ) | DataPNZ[RA];
- CC += cc;
- }
-
- private void ExecutePha(int cc)
- {
- Push(RA);
- CC += cc;
- }
-
- private void ExecutePhp(int cc)
- {
- Push(RP | PB); // [4-18]
- CC += cc;
- }
-
- private void ExecutePhx(int cc)
- {
- Push(RX);
- CC += cc;
- }
-
- private void ExecutePhy(int cc)
- {
- Push(RY);
- CC += cc;
- }
-
- private void ExecutePla(int cc)
- {
- RA = Pull();
- RP = RP & ~(PN | PZ) | DataPNZ[RA];
- CC += cc;
- }
-
- private void ExecutePlp(int cc)
- {
- RP = Pull();
- CC += cc;
- }
-
- private void ExecutePlx(int cc)
- {
- RX = Pull();
- RP = RP & ~(PN | PZ) | DataPNZ[RX];
- CC += cc;
- }
-
- private void ExecutePly(int cc)
- {
- RY = Pull();
- RP = RP & ~(PN | PZ) | DataPNZ[RY];
- CC += cc;
- }
-
- private int ExecuteRol(int data, int cc)
- {
- int c = RP & PC;
- RP = RP & ~PC | ((data >> 7) & PC);
- data = ((data << 1) | c) & 0xFF;
- RP = RP & ~(PN | PZ) | DataPNZ[data];
- CC += cc;
-
- return data;
- }
-
- private void ExecuteRolImp(int cc)
- {
- int c = RP & PC;
- RP = RP & ~PC | ((RA >> 7) & PC);
- RA = ((RA << 1) | c) & 0xFF;
- RP = RP & ~(PN | PZ) | DataPNZ[RA];
- CC += cc;
- }
-
- private int ExecuteRor(int data, int cc)
- {
- int c = RP & PC;
- RP = RP & ~PC | (data & PC);
- data = (c << 7) | (data >> 1);
- RP = RP & ~(PN | PZ) | DataPNZ[data];
- CC += cc;
-
- return data;
- }
-
- private void ExecuteRorImp(int cc)
- {
- int c = RP & PC;
- RP = RP & ~PC | (RA & PC);
- RA = (c << 7) | (RA >> 1);
- RP = RP & ~(PN | PZ) | DataPNZ[RA];
- CC += cc;
- }
-
- private void ExecuteRti(int cc)
- {
- RP = Pull();
- int rpc = Pull();
- RPC = rpc | (Pull() << 8);
- CC += cc;
- }
-
- private void ExecuteRts(int cc)
- {
- int rpc = Pull();
- RPC = (rpc + 1 + (Pull() << 8)) & 0xFFFF;
- CC += cc;
- }
-
- private void ExecuteSbc65N02(int data, int cc)
- {
- if ((RP & PD) == 0x0)
- {
- int ra = RA - data - (~RP & PC);
- RP = RP & ~(PC | PN | PV | PZ) | ((~ra >> 8) & PC) | DataPNZ[ra & 0xFF] | ((((RA ^ data) & (RA ^ (ra & 0xFF))) >> 1) & PV);
- RA = ra & 0xFF;
- CC += cc;
- }
- else // decimal
- {
- int ral = (RA & 0x0F) - (data & 0x0F) - (~RP & PC);
- int rah = (RA >> 4) - (data >> 4);
- if (ral < 0)
- {
- ral += 10;
- rah--;
- }
- int ra = (ral | (rah << 4)) & 0xFF;
- RP = RP & ~(PN | PV | PZ) | PC | DataPN[ra] | ((((RA ^ data) & (RA ^ ra)) >> 1) & PV) | DataPZ[(RA - data - (~RP & PC)) & 0xFF];
- if (rah < 0)
- {
- rah += 10;
- RP &= ~PC;
- }
- RA = (ral | (rah << 4)) & 0xFF;
- CC += cc;
- }
- }
-
- private void ExecuteSbc65C02(int data, int cc)
- {
- if ((RP & PD) == 0x0)
- {
- int ra = RA - data - (~RP & PC);
- RP = RP & ~(PC | PN | PV | PZ) | ((~ra >> 8) & PC) | DataPNZ[ra & 0xFF] | ((((RA ^ data) & (RA ^ (ra & 0xFF))) >> 1) & PV);
- RA = ra & 0xFF;
- CC += cc;
- }
- else // decimal
- {
- int ral = (RA & 0x0F) - (data & 0x0F) - (~RP & PC);
- int rah = (RA >> 4) - (data >> 4);
- if (ral < 0)
- {
- ral += 10;
- rah--;
- }
- RP |= PC;
- if (rah < 0)
- {
- rah += 10;
- RP &= ~PC;
- }
- int ra = (ral | (rah << 4)) & 0xFF;
- RP = RP & ~(PN | PV | PZ) | DataPNZ[ra] | ((((RA ^ data) & (RA ^ ra)) >> 1) & PV);
- RA = ra;
- CC += cc + 1;
- }
- }
-
- private void ExecuteSec(int cc)
- {
- RP |= PC;
- CC += cc;
- }
-
- private void ExecuteSed(int cc)
- {
- RP |= PD;
- CC += cc;
- }
-
- private void ExecuteSei(int cc)
- {
- RP |= PI;
- CC += cc;
- }
-
- private void ExecuteSta(int cc)
- {
- CC += cc;
- }
-
- private void ExecuteStx(int cc)
- {
- CC += cc;
- }
-
- private void ExecuteSty(int cc)
- {
- CC += cc;
- }
-
- private void ExecuteStz(int cc)
- {
- CC += cc;
- }
-
- private void ExecuteTax(int cc)
- {
- RX = RA;
- RP = RP & ~(PN | PZ) | DataPNZ[RX];
- CC += cc;
- }
-
- private void ExecuteTay(int cc)
- {
- RY = RA;
- RP = RP & ~(PN | PZ) | DataPNZ[RY];
- CC += cc;
- }
-
- private int ExecuteTrb(int data, int cc)
- {
- RP = RP & ~PZ | DataPZ[RA & data];
- data &= ~RA;
- CC += cc;
-
- return data;
- }
-
- private int ExecuteTsb(int data, int cc)
- {
- RP = RP & ~PZ | DataPZ[RA & data];
- data |= RA;
- CC += cc;
-
- return data;
- }
-
- private void ExecuteTsx(int cc)
- {
- RX = RS;
- RP = RP & ~(PN | PZ) | DataPNZ[RX];
- CC += cc;
- }
-
- private void ExecuteTxa(int cc)
- {
- RA = RX;
- RP = RP & ~(PN | PZ) | DataPNZ[RA];
- CC += cc;
- }
-
- private void ExecuteTxs(int cc)
- {
- RS = RX;
- CC += cc;
- }
-
- private void ExecuteTya(int cc)
- {
- RA = RY;
- RP = RP & ~(PN | PZ) | DataPNZ[RA];
- CC += cc;
- }
- #endregion
-
- #region 6502 OpCode Actions
- private void Execute65X02And21() // and (zpg, x)
- {
- GetAddressZpgIndX();
- ExecuteAnd(ReadZpgIndX(), 6);
- }
-
- private void Execute65X02And25() // and zpg
- {
- GetAddressZpg();
- ExecuteAnd(ReadZpg(), 3);
- }
-
- private void Execute65X02And29() // and imm
- {
- ExecuteAnd(ReadImm(), 2);
- }
-
- private void Execute65X02And2D() // and abs
- {
- GetAddressAbs();
- ExecuteAnd(ReadAbs(), 4);
- }
-
- private void Execute65X02And31() // and (zpg), y
- {
- GetAddressZpgIndYCC();
- ExecuteAnd(ReadZpgIndY(), 5);
- }
-
- private void Execute65X02And35() // and zpg, x
- {
- GetAddressZpgX();
- ExecuteAnd(ReadZpgX(), 4);
- }
-
- private void Execute65X02And39() // and abs, y
- {
- GetAddressAbsYCC();
- ExecuteAnd(ReadAbsY(), 4);
- }
-
- private void Execute65X02And3D() // and abs, x
- {
- GetAddressAbsXCC();
- ExecuteAnd(ReadAbsX(), 4);
- }
-
- private void Execute65X02Asl06() // asl zpg
- {
- GetAddressZpg();
- WriteZpg(ExecuteAsl(ReadZpg(), 5));
- }
-
- private void Execute65X02Asl0A() // asl imp
- {
- ExecuteAslImp(2);
- }
-
- private void Execute65X02Asl0E() // asl abs
- {
- GetAddressAbs();
- WriteAbs(ExecuteAsl(ReadAbs(), 6));
- }
-
- private void Execute65X02Asl16() // asl zpg, x
- {
- GetAddressZpgX();
- WriteZpgX(ExecuteAsl(ReadZpgX(), 6));
- }
-
- private void Execute65X02Bcc90() // bcc rel
- {
- ExecuteBcc(2);
- }
-
- private void Execute65X02BcsB0() // bcs rel
- {
- ExecuteBcs(2);
- }
-
- private void Execute65X02BeqF0() // beq rel
- {
- ExecuteBeq(2);
- }
-
- private void Execute65X02Bit24() // bit zpg
- {
- GetAddressZpg();
- ExecuteBit(ReadZpg(), 3);
- }
-
- private void Execute65X02Bit2C() // bit abs
- {
- GetAddressAbs();
- ExecuteBit(ReadAbs(), 4);
- }
-
- private void Execute65X02Bmi30() // bmi rel
- {
- ExecuteBmi(2);
- }
-
- private void Execute65X02BneD0() // bne rel
- {
- ExecuteBne(2);
- }
-
- private void Execute65X02Bpl10() // bpl rel
- {
- ExecuteBpl(2);
- }
-
- private void Execute65X02Brk00() // brk imp
- {
- ExecuteBrk(7);
- }
-
- private void Execute65X02Bvc50() // bvc rel
- {
- ExecuteBvc(2);
- }
-
- private void Execute65X02Bvs70() // bvs rel
- {
- ExecuteBvs(2);
- }
-
- private void Execute65X02Clc18() // clc imp
- {
- ExecuteClc(2);
- }
-
- private void Execute65X02CldD8() // cld imp
- {
- ExecuteCld(2);
- }
-
- private void Execute65X02Cli58() // cli imp
- {
- ExecuteCli(2);
- }
-
- private void Execute65X02ClvB8() // clv imp
- {
- ExecuteClv(2);
- }
-
- private void Execute65X02CmpC1() // cmp (zpg, x)
- {
- GetAddressZpgIndX();
- ExecuteCmp(ReadZpgIndX(), 6);
- }
-
- private void Execute65X02CmpC5() // cmp zpg
- {
- GetAddressZpg();
- ExecuteCmp(ReadZpg(), 3);
- }
-
- private void Execute65X02CmpC9() // cmp imm
- {
- ExecuteCmp(ReadImm(), 2);
- }
-
- private void Execute65X02CmpCD() // cmp abs
- {
- GetAddressAbs();
- ExecuteCmp(ReadAbs(), 4);
- }
-
- private void Execute65X02CmpD1() // cmp (zpg), y
- {
- GetAddressZpgIndYCC();
- ExecuteCmp(ReadZpgIndY(), 5);
- }
-
- private void Execute65X02CmpD5() // cmp zpg, x
- {
- GetAddressZpgX();
- ExecuteCmp(ReadZpgX(), 4);
- }
-
- private void Execute65X02CmpD9() // cmp abs, y
- {
- GetAddressAbsYCC();
- ExecuteCmp(ReadAbsY(), 4);
- }
-
- private void Execute65X02CmpDD() // cmp abs, x
- {
- GetAddressAbsXCC();
- ExecuteCmp(ReadAbsX(), 4);
- }
-
- private void Execute65X02CpxE0() // cpx imm
- {
- ExecuteCpx(ReadImm(), 2);
- }
-
- private void Execute65X02CpxE4() // cpx zpg
- {
- GetAddressZpg();
- ExecuteCpx(ReadZpg(), 3);
- }
-
- private void Execute65X02CpxEC() // cpx abs
- {
- GetAddressAbs();
- ExecuteCpx(ReadAbs(), 4);
- }
-
- private void Execute65X02CpyC0() // cpy imm
- {
- ExecuteCpy(ReadImm(), 2);
- }
-
- private void Execute65X02CpyC4() // cpy zpg
- {
- GetAddressZpg();
- ExecuteCpy(ReadZpg(), 3);
- }
-
- private void Execute65X02CpyCC() // cpy abs
- {
- GetAddressAbs();
- ExecuteCpy(ReadAbs(), 4);
- }
-
- private void Execute65X02DecC6() // dec zpg
- {
- GetAddressZpg();
- WriteZpg(ExecuteDec(ReadZpg(), 5));
- }
-
- private void Execute65X02DecCE() // dec abs
- {
- GetAddressAbs();
- WriteAbs(ExecuteDec(ReadAbs(), 6));
- }
-
- private void Execute65X02DecD6() // dec zpg, x
- {
- GetAddressZpgX();
- WriteZpgX(ExecuteDec(ReadZpgX(), 6));
- }
-
- private void Execute65X02DexCA() // dex imp
- {
- ExecuteDex(2);
- }
-
- private void Execute65X02Dey88() // dey imp
- {
- ExecuteDey(2);
- }
-
- private void Execute65X02Eor41() // eor (zpg, x)
- {
- GetAddressZpgIndX();
- ExecuteEor(ReadZpgIndX(), 6);
- }
-
- private void Execute65X02Eor45() // eor zpg
- {
- GetAddressZpg();
- ExecuteEor(ReadZpg(), 3);
- }
-
- private void Execute65X02Eor49() // eor imm
- {
- ExecuteEor(ReadImm(), 2);
- }
-
- private void Execute65X02Eor4D() // eor abs
- {
- GetAddressAbs();
- ExecuteEor(ReadAbs(), 4);
- }
-
- private void Execute65X02Eor51() // eor (zpg), y
- {
- GetAddressZpgIndYCC();
- ExecuteEor(ReadZpgIndY(), 5);
- }
-
- private void Execute65X02Eor55() // eor zpg, x
- {
- GetAddressZpgX();
- ExecuteEor(ReadZpgX(), 4);
- }
-
- private void Execute65X02Eor59() // eor abs, y
- {
- GetAddressAbsYCC();
- ExecuteEor(ReadAbsY(), 4);
- }
-
- private void Execute65X02Eor5D() // eor abs, x
- {
- GetAddressAbsXCC();
- ExecuteEor(ReadAbsX(), 4);
- }
-
- private void Execute65X02IncE6() // inc zpg
- {
- GetAddressZpg();
- WriteZpg(ExecuteInc(ReadZpg(), 5));
- }
-
- private void Execute65X02IncEE() // inc abs
- {
- GetAddressAbs();
- WriteAbs(ExecuteInc(ReadAbs(), 6));
- }
-
- private void Execute65X02IncF6() // inc zpg, x
- {
- GetAddressZpgX();
- WriteZpgX(ExecuteInc(ReadZpgX(), 6));
- }
-
- private void Execute65X02InxE8() // inx imp
- {
- ExecuteInx(2);
- }
-
- private void Execute65X02InyC8() // iny imp
- {
- ExecuteIny(2);
- }
-
- private void Execute65X02Jmp4C() // jmp abs
- {
- ExecuteJmpAbs(3);
- }
-
- private void Execute65X02Jsr20() // jsr abs
- {
- ExecuteJsr(6);
- }
-
- private void Execute65X02LdaA1() // lda (zpg, x)
- {
- GetAddressZpgIndX();
- ExecuteLda(ReadZpgIndX(), 6);
- }
-
- private void Execute65X02LdaA5() // lda zpg
- {
- GetAddressZpg();
- ExecuteLda(ReadZpg(), 3);
- }
-
- private void Execute65X02LdaA9() // lda imm
- {
- ExecuteLda(ReadImm(), 2);
- }
-
- private void Execute65X02LdaAD() // lda abs
- {
- GetAddressAbs();
- ExecuteLda(ReadAbs(), 4);
- }
-
- private void Execute65X02LdaB1() // lda (zpg), y
- {
- GetAddressZpgIndYCC();
- ExecuteLda(ReadZpgIndY(), 5);
- }
-
- private void Execute65X02LdaB5() // lda zpg, x
- {
- GetAddressZpgX();
- ExecuteLda(ReadZpgX(), 4);
- }
-
- private void Execute65X02LdaB9() // lda abs, y
- {
- GetAddressAbsYCC();
- ExecuteLda(ReadAbsY(), 4);
- }
-
- private void Execute65X02LdaBD() // lda abs, x
- {
- GetAddressAbsXCC();
- ExecuteLda(ReadAbsX(), 4);
- }
-
- private void Execute65X02LdxA2() // ldx imm
- {
- ExecuteLdx(ReadImm(), 2);
- }
-
- private void Execute65X02LdxA6() // ldx zpg
- {
- GetAddressZpg();
- ExecuteLdx(ReadZpg(), 3);
- }
-
- private void Execute65X02LdxAE() // ldx abs
- {
- GetAddressAbs();
- ExecuteLdx(ReadAbs(), 4);
- }
-
- private void Execute65X02LdxB6() // ldx zpg, y
- {
- GetAddressZpgY();
- ExecuteLdx(ReadZpgY(), 4);
- }
-
- private void Execute65X02LdxBE() // ldx abs, y
- {
- GetAddressAbsYCC();
- ExecuteLdx(ReadAbsY(), 4);
- }
-
- private void Execute65X02LdyA0() // ldy imm
- {
- ExecuteLdy(ReadImm(), 2);
- }
-
- private void Execute65X02LdyA4() // ldy zpg
- {
- GetAddressZpg();
- ExecuteLdy(ReadZpg(), 3);
- }
-
- private void Execute65X02LdyAC() // ldy abs
- {
- GetAddressAbs();
- ExecuteLdy(ReadAbs(), 4);
- }
-
- private void Execute65X02LdyB4() // ldy zpg, x
- {
- GetAddressZpgX();
- ExecuteLdy(ReadZpgX(), 4);
- }
-
- private void Execute65X02LdyBC() // ldy abs, x
- {
- GetAddressAbsXCC();
- ExecuteLdy(ReadAbsX(), 4);
- }
-
- private void Execute65X02Lsr46() // lsr zpg
- {
- GetAddressZpg();
- WriteZpg(ExecuteLsr(ReadZpg(), 5));
- }
-
- private void Execute65X02Lsr4A() // lsr imp
- {
- ExecuteLsrImp(2);
- }
-
- private void Execute65X02Lsr4E() // lsr abs
- {
- GetAddressAbs();
- WriteAbs(ExecuteLsr(ReadAbs(), 6));
- }
-
- private void Execute65X02Lsr56() // lsr zpg, x
- {
- GetAddressZpgX();
- WriteZpgX(ExecuteLsr(ReadZpgX(), 6));
- }
-
- private void Execute65X02NopEA() // nop imp
- {
- ExecuteNop(2);
- }
-
- private void Execute65X02Ora01() // ora (zpg, x)
- {
- GetAddressZpgIndX();
- ExecuteOra(ReadZpgIndX(), 6);
- }
-
- private void Execute65X02Ora05() // ora zpg
- {
- GetAddressZpg();
- ExecuteOra(ReadZpg(), 3);
- }
-
- private void Execute65X02Ora09() // ora imm
- {
- ExecuteOra(ReadImm(), 2);
- }
-
- private void Execute65X02Ora0D() // ora abs
- {
- GetAddressAbs();
- ExecuteOra(ReadAbs(), 4);
- }
-
- private void Execute65X02Ora11() // ora (zpg), y
- {
- GetAddressZpgIndYCC();
- ExecuteOra(ReadZpgIndY(), 5);
- }
-
- private void Execute65X02Ora15() // ora zpg, x
- {
- GetAddressZpgX();
- ExecuteOra(ReadZpgX(), 4);
- }
-
- private void Execute65X02Ora19() // ora abs, y
- {
- GetAddressAbsYCC();
- ExecuteOra(ReadAbsY(), 4);
- }
-
- private void Execute65X02Ora1D() // ora abs, x
- {
- GetAddressAbsXCC();
- ExecuteOra(ReadAbsX(), 4);
- }
-
- private void Execute65X02Pha48() // pha imp
- {
- ExecutePha(3);
- }
-
- private void Execute65X02Php08() // php imp
- {
- ExecutePhp(3);
- }
-
- private void Execute65X02Pla68() // pla imp
- {
- ExecutePla(4);
- }
-
- private void Execute65X02Plp28() // plp imp
- {
- ExecutePlp(4);
- }
-
- private void Execute65X02Rol26() // rol zpg
- {
- GetAddressZpg();
- WriteZpg(ExecuteRol(ReadZpg(), 5));
- }
-
- private void Execute65X02Rol2A() // rol imp
- {
- ExecuteRolImp(2);
- }
-
- private void Execute65X02Rol2E() // rol abs
- {
- GetAddressAbs();
- WriteAbs(ExecuteRol(ReadAbs(), 6));
- }
-
- private void Execute65X02Rol36() // rol zpg, x
- {
- GetAddressZpgX();
- WriteZpgX(ExecuteRol(ReadZpgX(), 6));
- }
-
- private void Execute65X02Ror66() // ror zpg
- {
- GetAddressZpg();
- WriteZpg(ExecuteRor(ReadZpg(), 5));
- }
-
- private void Execute65X02Ror6A() // ror imp
- {
- ExecuteRorImp(2);
- }
-
- private void Execute65X02Ror6E() // ror abs
- {
- GetAddressAbs();
- WriteAbs(ExecuteRor(ReadAbs(), 6));
- }
-
- private void Execute65X02Ror76() // ror zpg, x
- {
- GetAddressZpgX();
- WriteZpgX(ExecuteRor(ReadZpgX(), 6));
- }
-
- private void Execute65X02Rti40() // rti imp
- {
- ExecuteRti(6);
- }
-
- private void Execute65X02Rts60() // rts imp
- {
- ExecuteRts(6);
- }
-
- private void Execute65X02Sec38() // sec imp
- {
- ExecuteSec(2);
- }
-
- private void Execute65X02SedF8() // sed imp
- {
- ExecuteSed(2);
- }
-
- private void Execute65X02Sei78() // sei imp
- {
- ExecuteSei(2);
- }
-
- private void Execute65X02Sta81() // sta (zpg, x)
- {
- GetAddressZpgIndX();
- WriteZpgIndX(RA);
- ExecuteSta(6);
- }
-
- private void Execute65X02Sta85() // sta zpg
- {
- GetAddressZpg();
- WriteZpg(RA);
- ExecuteSta(3);
- }
-
- private void Execute65X02Sta8D() // sta abs
- {
- GetAddressAbs();
- WriteAbs(RA);
- ExecuteSta(4);
- }
-
- private void Execute65X02Sta91() // sta (zpg), y
- {
- GetAddressZpgIndY();
- WriteZpgIndY(RA);
- ExecuteSta(6);
- }
-
- private void Execute65X02Sta95() // sta zpg, x
- {
- GetAddressZpgX();
- WriteZpgX(RA);
- ExecuteSta(4);
- }
-
- private void Execute65X02Sta99() // sta abs, y
- {
- GetAddressAbsY();
- WriteAbsY(RA);
- ExecuteSta(5);
- }
-
- private void Execute65X02Sta9D() // sta abs, x
- {
- GetAddressAbsX();
- WriteAbsX(RA);
- ExecuteSta(5);
- }
-
- private void Execute65X02Stx86() // stx zpg
- {
- GetAddressZpg();
- WriteZpg(RX);
- ExecuteStx(3);
- }
-
- private void Execute65X02Stx8E() // stx abs
- {
- GetAddressAbs();
- WriteAbs(RX);
- ExecuteStx(4);
- }
-
- private void Execute65X02Stx96() // stx zpg, y
- {
- GetAddressZpgY();
- WriteZpgY(RX);
- ExecuteStx(4);
- }
-
- private void Execute65X02Sty84() // sty zpg
- {
- GetAddressZpg();
- WriteZpg(RY);
- ExecuteSty(3);
- }
-
- private void Execute65X02Sty8C() // sty abs
- {
- GetAddressAbs();
- WriteAbs(RY);
- ExecuteSty(4);
- }
-
- private void Execute65X02Sty94() // sty zpg, x
- {
- GetAddressZpgX();
- WriteZpgX(RY);
- ExecuteSty(4);
- }
-
- private void Execute65X02TaxAA() // tax imp
- {
- ExecuteTax(2);
- }
-
- private void Execute65X02TayA8() // tay imp
- {
- ExecuteTay(2);
- }
-
- private void Execute65X02TsxBA() // tsx imp
- {
- ExecuteTsx(2);
- }
-
- private void Execute65X02Txa8A() // txa imp
- {
- ExecuteTxa(2);
- }
-
- private void Execute65X02Txs9A() // txs imp
- {
- ExecuteTxs(2);
- }
-
- private void Execute65X02Tya98() // tya imp
- {
- ExecuteTya(2);
- }
- #endregion
-
- #region 65N02 OpCode Actions
- private void Execute65N02Adc61() // adc (zpg, x)
- {
- GetAddressZpgIndX();
- ExecuteAdc65N02(ReadZpgIndX(), 6);
- }
-
- private void Execute65N02Adc65() // adc zpg
- {
- GetAddressZpg();
- ExecuteAdc65N02(ReadZpg(), 3);
- }
-
- private void Execute65N02Adc69() // adc imm
- {
- ExecuteAdc65N02(ReadImm(), 2);
- }
-
- private void Execute65N02Adc6D() // adc abs
- {
- GetAddressAbs();
- ExecuteAdc65N02(ReadAbs(), 4);
- }
-
- private void Execute65N02Adc71() // adc (zpg), y
- {
- GetAddressZpgIndYCC();
- ExecuteAdc65N02(ReadZpgIndY(), 5);
- }
-
- private void Execute65N02Adc75() // adc zpg, x
- {
- GetAddressZpgX();
- ExecuteAdc65N02(ReadZpgX(), 4);
- }
-
- private void Execute65N02Adc79() // adc abs, y
- {
- GetAddressAbsYCC();
- ExecuteAdc65N02(ReadAbsY(), 4);
- }
-
- private void Execute65N02Adc7D() // adc abs, x
- {
- GetAddressAbsXCC();
- ExecuteAdc65N02(ReadAbsX(), 4);
- }
-
- private void Execute65N02Asl1E() // asl abs, x
- {
- GetAddressAbsX();
- WriteAbsX(ExecuteAsl(ReadAbsX(), 7));
- }
-
- private void Execute65N02DecDE() // dec abs, x
- {
- GetAddressAbsX();
- WriteAbsX(ExecuteDec(ReadAbsX(), 7));
- }
-
- private void Execute65N02IncFE() // inc abs, x
- {
- GetAddressAbsX();
- WriteAbsX(ExecuteInc(ReadAbsX(), 7));
- }
-
- private void Execute65N02Jmp6C() // jmp (abs)
- {
- ExecuteJmpAbsInd65N02(5);
- }
-
- private void Execute65N02Lsr5E() // lsr abs, x
- {
- GetAddressAbsX();
- WriteAbsX(ExecuteLsr(ReadAbsX(), 7));
- }
-
- private void Execute65N02Nop02() // nop imp0
- {
- ExecuteNop(0, 2);
- }
-
- private void Execute65N02Nop03() // nop imp1
- {
- ExecuteNop(1, 6);
- }
-
- private void Execute65N02Nop04() // nop imp1
- {
- ExecuteNop(1, 2);
- }
-
- private void Execute65N02Nop07() // nop imp1
- {
- ExecuteNop(1, 5);
- }
-
- private void Execute65N02Nop0B() // nop imp1
- {
- ExecuteNop(1, 2);
- }
-
- private void Execute65N02Nop0C() // nop imp2
- {
- ExecuteNop(2, 4);
- }
-
- private void Execute65N02Nop0F() // nop imp2
- {
- ExecuteNop(2, 6);
- }
-
- private void Execute65N02Nop12() // nop imp0
- {
- ExecuteNop(0, 2);
- }
-
- private void Execute65N02Nop13() // nop imp1
- {
- ExecuteNop(1, 6);
- }
-
- private void Execute65N02Nop14() // nop imp1
- {
- ExecuteNop(1, 2);
- }
-
- private void Execute65N02Nop17() // nop imp1
- {
- ExecuteNop(1, 6);
- }
-
- private void Execute65N02Nop1A() // nop imp0
- {
- ExecuteNop(0, 2);
- }
-
- private void Execute65N02Nop1B() // nop imp2
- {
- ExecuteNop(2, 6);
- }
-
- private void Execute65N02Nop1C() // nop imp2
- {
- ExecuteNop(2, 4);
- }
-
- private void Execute65N02Nop1F() // nop imp2
- {
- ExecuteNop(2, 6);
- }
-
- private void Execute65N02Nop22() // nop imp0
- {
- ExecuteNop(0, 2);
- }
-
- private void Execute65N02Nop23() // nop imp1
- {
- ExecuteNop(1, 6);
- }
-
- private void Execute65N02Nop27() // nop imp1
- {
- ExecuteNop(1, 3);
- }
-
- private void Execute65N02Nop2B() // nop imp1
- {
- ExecuteNop(1, 2);
- }
-
- private void Execute65N02Nop2F() // nop imp2
- {
- ExecuteNop(2, 4);
- }
-
- private void Execute65N02Nop32() // nop imp0
- {
- ExecuteNop(0, 2);
- }
-
- private void Execute65N02Nop33() // nop imp1
- {
- ExecuteNop(1, 5);
- }
-
- private void Execute65N02Nop34() // nop imp1
- {
- ExecuteNop(1, 2);
- }
-
- private void Execute65N02Nop37() // nop imp1
- {
- ExecuteNop(1, 4);
- }
-
- private void Execute65N02Nop3A() // nop imp0
- {
- ExecuteNop(0, 2);
- }
-
- private void Execute65N02Nop3B() // nop imp2
- {
- ExecuteNop(2, 4);
- }
-
- private void Execute65N02Nop3C() // nop imp2
- {
- ExecuteNop(2, 4);
- }
-
- private void Execute65N02Nop3F() // nop imp2
- {
- ExecuteNop(2, 4);
- }
-
- private void Execute65N02Nop42() // nop imp0
- {
- ExecuteNop(0, 2);
- }
-
- private void Execute65N02Nop43() // nop imp1
- {
- ExecuteNop(1, 6);
- }
-
- private void Execute65N02Nop44() // nop imp1
- {
- ExecuteNop(1, 2);
- }
-
- private void Execute65N02Nop47() // nop imp1
- {
- ExecuteNop(1, 3);
- }
-
- private void Execute65N02Nop4B() // nop imp1
- {
- ExecuteNop(1, 2);
- }
-
- private void Execute65N02Nop4F() // nop imp2
- {
- ExecuteNop(2, 4);
- }
-
- private void Execute65N02Nop52() // nop imp0
- {
- ExecuteNop(0, 2);
- }
-
- private void Execute65N02Nop53() // nop imp1
- {
- ExecuteNop(1, 5);
- }
-
- private void Execute65N02Nop54() // nop imp1
- {
- ExecuteNop(1, 2);
- }
-
- private void Execute65N02Nop57() // nop imp1
- {
- ExecuteNop(1, 4);
- }
-
- private void Execute65N02Nop5A() // nop imp0
- {
- ExecuteNop(0, 2);
- }
-
- private void Execute65N02Nop5B() // nop imp2
- {
- ExecuteNop(2, 4);
- }
-
- private void Execute65N02Nop5C() // nop imp2
- {
- ExecuteNop(2, 4);
- }
-
- private void Execute65N02Nop5F() // nop imp2
- {
- ExecuteNop(2, 4);
- }
-
- private void Execute65N02Nop62() // nop imp0
- {
- ExecuteNop(0, 2);
- }
-
- private void Execute65N02Nop63() // nop imp1
- {
- ExecuteNop(1, 6);
- }
-
- private void Execute65N02Nop64() // nop imp1
- {
- ExecuteNop(1, 2);
- }
-
- private void Execute65N02Nop67() // nop imp1
- {
- ExecuteNop(1, 3);
- }
-
- private void Execute65N02Nop6B() // nop imp1
- {
- ExecuteNop(1, 2);
- }
-
- private void Execute65N02Nop6F() // nop imp2
- {
- ExecuteNop(2, 4);
- }
-
- private void Execute65N02Nop72() // nop imp0
- {
- ExecuteNop(0, 2);
- }
-
- private void Execute65N02Nop73() // nop imp1
- {
- ExecuteNop(1, 5);
- }
-
- private void Execute65N02Nop74() // nop imp1
- {
- ExecuteNop(1, 2);
- }
-
- private void Execute65N02Nop77() // nop imp1
- {
- ExecuteNop(1, 4);
- }
-
- private void Execute65N02Nop7A() // nop imp0
- {
- ExecuteNop(0, 2);
- }
-
- private void Execute65N02Nop7B() // nop imp2
- {
- ExecuteNop(2, 4);
- }
-
- private void Execute65N02Nop7C() // nop imp2
- {
- ExecuteNop(2, 4);
- }
-
- private void Execute65N02Nop7F() // nop imp2
- {
- ExecuteNop(2, 4);
- }
-
- private void Execute65N02Nop80() // nop imp1
- {
- ExecuteNop(1, 2);
- }
-
- private void Execute65N02Nop82() // nop imp1
- {
- ExecuteNop(1, 2);
- }
-
- private void Execute65N02Nop83() // nop imp1
- {
- ExecuteNop(1, 4);
- }
-
- private void Execute65N02Nop87() // nop imp1
- {
- ExecuteNop(1, 3);
- }
-
- private void Execute65N02Nop89() // nop imp1
- {
- ExecuteNop(1, 2);
- }
-
- private void Execute65N02Nop8B() // nop imp1
- {
- ExecuteNop(1, 2);
- }
-
- private void Execute65N02Nop8F() // nop imp2
- {
- ExecuteNop(2, 4);
- }
-
- private void Execute65N02Nop92() // nop imp0
- {
- ExecuteNop(0, 2);
- }
-
- private void Execute65N02Nop93() // nop imp1
- {
- ExecuteNop(1, 6);
- }
-
- private void Execute65N02Nop97() // nop imp1
- {
- ExecuteNop(1, 4);
- }
-
- private void Execute65N02Nop9B() // nop imp2
- {
- ExecuteNop(2, 5);
- }
-
- private void Execute65N02Nop9C() // nop imp2
- {
- ExecuteNop(2, 5);
- }
-
- private void Execute65N02Nop9E() // nop imp2
- {
- ExecuteNop(2, 5);
- }
-
- private void Execute65N02Nop9F() // nop imp2
- {
- ExecuteNop(2, 5);
- }
-
- private void Execute65N02NopA3() // nop imp1
- {
- ExecuteNop(1, 6);
- }
-
- private void Execute65N02NopA7() // nop imp1
- {
- ExecuteNop(1, 3);
- }
-
- private void Execute65N02NopAB() // nop imp1
- {
- ExecuteNop(1, 2);
- }
-
- private void Execute65N02NopAF() // nop imp2
- {
- ExecuteNop(2, 4);
- }
-
- private void Execute65N02NopB2() // nop imp0
- {
- ExecuteNop(0, 2);
- }
-
- private void Execute65N02NopB3() // nop imp1
- {
- ExecuteNop(1, 5);
- }
-
- private void Execute65N02NopB7() // nop imp1
- {
- ExecuteNop(1, 4);
- }
-
- private void Execute65N02NopBB() // nop imp2
- {
- ExecuteNop(2, 4);
- }
-
- private void Execute65N02NopBF() // nop imp2
- {
- ExecuteNop(2, 4);
- }
-
- private void Execute65N02NopC2() // nop imp1
- {
- ExecuteNop(1, 2);
- }
-
- private void Execute65N02NopC3() // nop imp1
- {
- ExecuteNop(1, 6);
- }
-
- private void Execute65N02NopC7() // nop imp1
- {
- ExecuteNop(1, 5);
- }
-
- private void Execute65N02NopCB() // nop imp1
- {
- ExecuteNop(1, 2);
- }
-
- private void Execute65N02NopCF() // nop imp2
- {
- ExecuteNop(2, 6);
- }
-
- private void Execute65N02NopD2() // nop imp0
- {
- ExecuteNop(0, 2);
- }
-
- private void Execute65N02NopD3() // nop imp1
- {
- ExecuteNop(1, 6);
- }
-
- private void Execute65N02NopD4() // nop imp1
- {
- ExecuteNop(1, 2);
- }
-
- private void Execute65N02NopD7() // nop imp1
- {
- ExecuteNop(1, 6);
- }
-
- private void Execute65N02NopDA() // nop imp0
- {
- ExecuteNop(0, 2);
- }
-
- private void Execute65N02NopDB() // nop imp2
- {
- ExecuteNop(2, 6);
- }
-
- private void Execute65N02NopDC() // nop imp2
- {
- ExecuteNop(2, 4);
- }
-
- private void Execute65N02NopDF() // nop imp2
- {
- ExecuteNop(2, 6);
- }
-
- private void Execute65N02NopE2() // nop imp1
- {
- ExecuteNop(1, 2);
- }
-
- private void Execute65N02NopE3() // nop imp1
- {
- ExecuteNop(1, 6);
- }
-
- private void Execute65N02NopE7() // nop imp1
- {
- ExecuteNop(1, 5);
- }
-
- private void Execute65N02NopEB() // nop imp1
- {
- ExecuteNop(1, 2);
- }
-
- private void Execute65N02NopEF() // nop imp2
- {
- ExecuteNop(2, 6);
- }
-
- private void Execute65N02NopF2() // nop imp0
- {
- ExecuteNop(0, 2);
- }
-
- private void Execute65N02NopF3() // nop imp1
- {
- ExecuteNop(1, 6);
- }
-
- private void Execute65N02NopF4() // nop imp1
- {
- ExecuteNop(1, 2);
- }
-
- private void Execute65N02NopF7() // nop imp1
- {
- ExecuteNop(1, 6);
- }
-
- private void Execute65N02NopFA() // nop imp0
- {
- ExecuteNop(0, 2);
- }
-
- private void Execute65N02NopFB() // nop imp2
- {
- ExecuteNop(2, 6);
- }
-
- private void Execute65N02NopFC() // nop imp2
- {
- ExecuteNop(2, 4);
- }
-
- private void Execute65N02NopFF() // nop imp2
- {
- ExecuteNop(2, 6);
- }
-
- private void Execute65N02Rol3E() // rol abs, x
- {
- GetAddressAbsX();
- WriteAbsX(ExecuteRol(ReadAbsX(), 7));
- }
-
- private void Execute65N02Ror7E() // ror abs, x
- {
- GetAddressAbsX();
- WriteAbsX(ExecuteRor(ReadAbsX(), 7));
- }
-
- private void Execute65N02SbcE1() // sbc (zpg, x)
- {
- GetAddressZpgIndX();
- ExecuteSbc65N02(ReadZpgIndX(), 6);
- }
-
- private void Execute65N02SbcE5() // sbc zpg
- {
- GetAddressZpg();
- ExecuteSbc65N02(ReadZpg(), 3);
- }
-
- private void Execute65N02SbcE9() // sbc imm
- {
- ExecuteSbc65N02(ReadImm(), 2);
- }
-
- private void Execute65N02SbcED() // sbc abs
- {
- GetAddressAbs();
- ExecuteSbc65N02(ReadAbs(), 4);
- }
-
- private void Execute65N02SbcF1() // sbc (zpg), y
- {
- GetAddressZpgIndYCC();
- ExecuteSbc65N02(ReadZpgIndY(), 5);
- }
-
- private void Execute65N02SbcF5() // sbc zpg, x
- {
- GetAddressZpgX();
- ExecuteSbc65N02(ReadZpgX(), 4);
- }
-
- private void Execute65N02SbcF9() // sbc abs, y
- {
- GetAddressAbsYCC();
- ExecuteSbc65N02(ReadAbsY(), 4);
- }
-
- private void Execute65N02SbcFD() // sbc abs, x
- {
- GetAddressAbsXCC();
- ExecuteSbc65N02(ReadAbsX(), 4);
- }
- #endregion
-
- #region 65C02 OpCode Actions
- private void Execute65C02Adc61() // adc (zpg, x)
- {
- GetAddressZpgIndX();
- ExecuteAdc65C02(ReadZpgIndX(), 6);
- }
-
- private void Execute65C02Adc65() // adc zpg
- {
- GetAddressZpg();
- ExecuteAdc65C02(ReadZpg(), 3);
- }
-
- private void Execute65C02Adc69() // adc imm
- {
- ExecuteAdc65C02(ReadImm(), 2);
- }
-
- private void Execute65C02Adc6D() // adc abs
- {
- GetAddressAbs();
- ExecuteAdc65C02(ReadAbs(), 4);
- }
-
- private void Execute65C02Adc71() // adc (zpg), y
- {
- GetAddressZpgIndYCC();
- ExecuteAdc65C02(ReadZpgIndY(), 5);
- }
-
- private void Execute65C02Adc72() // adc (zpg)
- {
- GetAddressZpgInd();
- ExecuteAdc65C02(ReadZpgInd(), 5);
- }
-
- private void Execute65C02Adc75() // adc zpg, x
- {
- GetAddressZpgX();
- ExecuteAdc65C02(ReadZpgX(), 4);
- }
-
- private void Execute65C02Adc79() // adc abs, y
- {
- GetAddressAbsYCC();
- ExecuteAdc65C02(ReadAbsY(), 4);
- }
-
- private void Execute65C02Adc7D() // adc abs, x
- {
- GetAddressAbsXCC();
- ExecuteAdc65C02(ReadAbsX(), 4);
- }
-
- private void Execute65C02And32() // and (zpg)
- {
- GetAddressZpgInd();
- ExecuteAnd(ReadZpgInd(), 5);
- }
-
- private void Execute65C02Asl1E() // asl abs, x
- {
- GetAddressAbsXCC();
- WriteAbsX(ExecuteAsl(ReadAbsX(), 6));
- }
-
- private void Execute65C02Bit34() // bit zpg, x
- {
- GetAddressZpgX();
- ExecuteBit(ReadZpgX(), 4);
- }
-
- private void Execute65C02Bit3C() // bit abs, x
- {
- GetAddressAbsXCC();
- ExecuteBit(ReadAbsX(), 4);
- }
-
- private void Execute65C02Bit89() // bit imm
- {
- ExecuteBitImm(ReadImm(), 2);
- }
-
- private void Execute65C02Bra80() // bra rel
- {
- ExecuteBra(2);
- }
-
- private void Execute65C02CmpD2() // cmp (zpg)
- {
- GetAddressZpgInd();
- ExecuteCmp(ReadZpgInd(), 5);
- }
-
- private void Execute65C02Dea3A() // dea imp
- {
- ExecuteDea(2);
- }
-
- private void Execute65C02DecDE() // dec abs, x
- {
- GetAddressAbsXCC();
- WriteAbsX(ExecuteDec(ReadAbsX(), 6));
- }
-
- private void Execute65C02Eor52() // eor (zpg)
- {
- GetAddressZpgInd();
- ExecuteEor(ReadZpgInd(), 5);
- }
-
- private void Execute65C02Ina1A() // ina imp
- {
- ExecuteIna(2);
- }
-
- private void Execute65C02IncFE() // inc abs, x
- {
- GetAddressAbsXCC();
- WriteAbsX(ExecuteInc(ReadAbsX(), 6));
- }
-
- private void Execute65C02Jmp6C() // jmp (abs)
- {
- ExecuteJmpAbsInd65C02(6);
- }
-
- private void Execute65C02Jmp7C() // jmp (abs, x)
- {
- ExecuteJmpAbsIndX(6);
- }
-
- private void Execute65C02LdaB2() // lda (zpg)
- {
- GetAddressZpgInd();
- ExecuteLda(ReadZpgInd(), 5);
- }
-
- private void Execute65C02Lsr5E() // lsr abs, x
- {
- GetAddressAbsXCC();
- WriteAbsX(ExecuteLsr(ReadAbsX(), 6));
- }
-
- private void Execute65C02Nop02() // nop imp1
- {
- ExecuteNop(1, 2);
- }
-
- private void Execute65C02Nop03() // nop imp0
- {
- ExecuteNop(0, 1);
- }
-
- private void Execute65C02Nop07() // nop imp0
- {
- ExecuteNop(0, 1);
- }
-
- private void Execute65C02Nop0B() // nop imp0
- {
- ExecuteNop(0, 1);
- }
-
- private void Execute65C02Nop0F() // nop imp0
- {
- ExecuteNop(0, 1);
- }
-
- private void Execute65C02Nop13() // nop imp0
- {
- ExecuteNop(0, 1);
- }
-
- private void Execute65C02Nop17() // nop imp0
- {
- ExecuteNop(0, 1);
- }
-
- private void Execute65C02Nop1B() // nop imp0
- {
- ExecuteNop(0, 1);
- }
-
- private void Execute65C02Nop1F() // nop imp0
- {
- ExecuteNop(0, 1);
- }
-
- private void Execute65C02Nop22() // nop imp1
- {
- ExecuteNop(1, 2);
- }
-
- private void Execute65C02Nop23() // nop imp0
- {
- ExecuteNop(0, 1);
- }
-
- private void Execute65C02Nop27() // nop imp0
- {
- ExecuteNop(0, 1);
- }
-
- private void Execute65C02Nop2B() // nop imp0
- {
- ExecuteNop(0, 1);
- }
-
- private void Execute65C02Nop2F() // nop imp0
- {
- ExecuteNop(0, 1);
- }
-
- private void Execute65C02Nop33() // nop imp0
- {
- ExecuteNop(0, 1);
- }
-
- private void Execute65C02Nop37() // nop imp0
- {
- ExecuteNop(0, 1);
- }
-
- private void Execute65C02Nop3B() // nop imp0
- {
- ExecuteNop(0, 1);
- }
-
- private void Execute65C02Nop3F() // nop imp0
- {
- ExecuteNop(0, 1);
- }
-
- private void Execute65C02Nop42() // nop imp1
- {
- ExecuteNop(1, 2);
- }
-
- private void Execute65C02Nop43() // nop imp0
- {
- ExecuteNop(0, 1);
- }
-
- private void Execute65C02Nop44() // nop imp1
- {
- ExecuteNop(1, 3);
- }
-
- private void Execute65C02Nop47() // nop imp0
- {
- ExecuteNop(0, 1);
- }
-
- private void Execute65C02Nop4B() // nop imp0
- {
- ExecuteNop(0, 1);
- }
-
- private void Execute65C02Nop4F() // nop imp0
- {
- ExecuteNop(0, 1);
- }
-
- private void Execute65C02Nop53() // nop imp0
- {
- ExecuteNop(0, 1);
- }
-
- private void Execute65C02Nop54() // nop imp1
- {
- ExecuteNop(1, 4);
- }
-
- private void Execute65C02Nop57() // nop imp0
- {
- ExecuteNop(0, 1);
- }
-
- private void Execute65C02Nop5B() // nop imp0
- {
- ExecuteNop(0, 1);
- }
-
- private void Execute65C02Nop5C() // nop imp2
- {
- ExecuteNop(2, 8);
- }
-
- private void Execute65C02Nop5F() // nop imp0
- {
- ExecuteNop(0, 1);
- }
-
- private void Execute65C02Nop62() // nop imp1
- {
- ExecuteNop(1, 2);
- }
-
- private void Execute65C02Nop63() // nop imp0
- {
- ExecuteNop(0, 1);
- }
-
- private void Execute65C02Nop67() // nop imp0
- {
- ExecuteNop(0, 1);
- }
-
- private void Execute65C02Nop6B() // nop imp0
- {
- ExecuteNop(0, 1);
- }
-
- private void Execute65C02Nop6F() // nop imp0
- {
- ExecuteNop(0, 1);
- }
-
- private void Execute65C02Nop73() // nop imp0
- {
- ExecuteNop(0, 1);
- }
-
- private void Execute65C02Nop77() // nop imp0
- {
- ExecuteNop(0, 1);
- }
-
- private void Execute65C02Nop7B() // nop imp0
- {
- ExecuteNop(0, 1);
- }
-
- private void Execute65C02Nop7F() // nop imp0
- {
- ExecuteNop(0, 1);
- }
-
- private void Execute65C02Nop82() // nop imp1
- {
- ExecuteNop(1, 2);
- }
-
- private void Execute65C02Nop83() // nop imp0
- {
- ExecuteNop(0, 1);
- }
-
- private void Execute65C02Nop87() // nop imp0
- {
- ExecuteNop(0, 1);
- }
-
- private void Execute65C02Nop8B() // nop imp0
- {
- ExecuteNop(0, 1);
- }
-
- private void Execute65C02Nop8F() // nop imp0
- {
- ExecuteNop(0, 1);
- }
-
- private void Execute65C02Nop93() // nop imp0
- {
- ExecuteNop(0, 1);
- }
-
- private void Execute65C02Nop97() // nop imp0
- {
- ExecuteNop(0, 1);
- }
-
- private void Execute65C02Nop9B() // nop imp0
- {
- ExecuteNop(0, 1);
- }
-
- private void Execute65C02Nop9F() // nop imp0
- {
- ExecuteNop(0, 1);
- }
-
- private void Execute65C02NopA3() // nop imp0
- {
- ExecuteNop(0, 1);
- }
-
- private void Execute65C02NopA7() // nop imp0
- {
- ExecuteNop(0, 1);
- }
-
- private void Execute65C02NopAB() // nop imp0
- {
- ExecuteNop(0, 1);
- }
-
- private void Execute65C02NopAF() // nop imp0
- {
- ExecuteNop(0, 1);
- }
-
- private void Execute65C02NopB3() // nop imp0
- {
- ExecuteNop(0, 1);
- }
-
- private void Execute65C02NopB7() // nop imp0
- {
- ExecuteNop(0, 1);
- }
-
- private void Execute65C02NopBB() // nop imp0
- {
- ExecuteNop(0, 1);
- }
-
- private void Execute65C02NopBF() // nop imp0
- {
- ExecuteNop(0, 1);
- }
-
- private void Execute65C02NopC2() // nop imp1
- {
- ExecuteNop(1, 2);
- }
-
- private void Execute65C02NopC3() // nop imp0
- {
- ExecuteNop(0, 1);
- }
-
- private void Execute65C02NopC7() // nop imp0
- {
- ExecuteNop(0, 1);
- }
-
- private void Execute65C02NopCB() // nop imp0
- {
- ExecuteNop(0, 1);
- }
-
- private void Execute65C02NopCF() // nop imp0
- {
- ExecuteNop(0, 1);
- }
-
- private void Execute65C02NopD3() // nop imp0
- {
- ExecuteNop(0, 1);
- }
-
- private void Execute65C02NopD4() // nop imp1
- {
- ExecuteNop(1, 4);
- }
-
- private void Execute65C02NopD7() // nop imp0
- {
- ExecuteNop(0, 1);
- }
-
- private void Execute65C02NopDB() // nop imp0
- {
- ExecuteNop(0, 1);
- }
-
- private void Execute65C02NopDC() // nop imp2
- {
- ExecuteNop(2, 4);
- }
-
- private void Execute65C02NopDF() // nop imp0
- {
- ExecuteNop(0, 1);
- }
-
- private void Execute65C02NopE2() // nop imp1
- {
- ExecuteNop(1, 2);
- }
-
- private void Execute65C02NopE3() // nop imp0
- {
- ExecuteNop(0, 1);
- }
-
- private void Execute65C02NopE7() // nop imp0
- {
- ExecuteNop(0, 1);
- }
-
- private void Execute65C02NopEB() // nop imp0
- {
- ExecuteNop(0, 1);
- }
-
- private void Execute65C02NopEF() // nop imp0
- {
- ExecuteNop(0, 1);
- }
-
- private void Execute65C02NopF3() // nop imp0
- {
- ExecuteNop(0, 1);
- }
-
- private void Execute65C02NopF4() // nop imp1
- {
- ExecuteNop(1, 4);
- }
-
- private void Execute65C02NopF7() // nop imp0
- {
- ExecuteNop(0, 1);
- }
-
- private void Execute65C02NopFB() // nop imp0
- {
- ExecuteNop(0, 1);
- }
-
- private void Execute65C02NopFC() // nop imp2
- {
- ExecuteNop(2, 4);
- }
-
- private void Execute65C02NopFF() // nop imp0
- {
- ExecuteNop(0, 1);
- }
-
- private void Execute65C02Ora12() // ora (zpg)
- {
- GetAddressZpgInd();
- ExecuteOra(ReadZpgInd(), 5);
- }
-
- private void Execute65C02PhxDA() // phx imp
- {
- ExecutePhx(3);
- }
-
- private void Execute65C02Phy5A() // phy imp
- {
- ExecutePhy(3);
- }
-
- private void Execute65C02PlxFA() // plx imp
- {
- ExecutePlx(4);
- }
-
- private void Execute65C02Ply7A() // ply imp
- {
- ExecutePly(4);
- }
-
- private void Execute65C02Rol3E() // rol abs, x
- {
- GetAddressAbsXCC();
- WriteAbsX(ExecuteRol(ReadAbsX(), 6));
- }
-
- private void Execute65C02Ror7E() // ror abs, x
- {
- GetAddressAbsXCC();
- WriteAbsX(ExecuteRor(ReadAbsX(), 6));
- }
-
- private void Execute65C02SbcE1() // sbc (zpg, x)
- {
- GetAddressZpgIndX();
- ExecuteSbc65C02(ReadZpgIndX(), 6);
- }
-
- private void Execute65C02SbcE5() // sbc zpg
- {
- GetAddressZpg();
- ExecuteSbc65C02(ReadZpg(), 3);
- }
-
- private void Execute65C02SbcE9() // sbc imm
- {
- ExecuteSbc65C02(ReadImm(), 2);
- }
-
- private void Execute65C02SbcED() // sbc abs
- {
- GetAddressAbs();
- ExecuteSbc65C02(ReadAbs(), 4);
- }
-
- private void Execute65C02SbcF1() // sbc (zpg), y
- {
- GetAddressZpgIndYCC();
- ExecuteSbc65C02(ReadZpgIndY(), 5);
- }
-
- private void Execute65C02SbcF2() // sbc (zpg)
- {
- GetAddressZpgInd();
- ExecuteSbc65C02(ReadZpgInd(), 5);
- }
-
- private void Execute65C02SbcF5() // sbc zpg, x
- {
- GetAddressZpgX();
- ExecuteSbc65C02(ReadZpgX(), 4);
- }
-
- private void Execute65C02SbcF9() // sbc abs, y
- {
- GetAddressAbsYCC();
- ExecuteSbc65C02(ReadAbsY(), 4);
- }
-
- private void Execute65C02SbcFD() // sbc abs, x
- {
- GetAddressAbsXCC();
- ExecuteSbc65C02(ReadAbsX(), 4);
- }
-
- private void Execute65C02Sta92() // sta (zpg)
- {
- GetAddressZpgInd();
- WriteZpgInd(RA);
- ExecuteSta(5);
- }
-
- private void Execute65C02Stz64() // stz zpg
- {
- GetAddressZpg();
- WriteZpg(0x00);
- ExecuteStz(3);
- }
-
- private void Execute65C02Stz74() // stz zpg, x
- {
- GetAddressZpgX();
- WriteZpgX(0x00);
- ExecuteStz(4);
- }
-
- private void Execute65C02Stz9C() // stz abs
- {
- GetAddressAbs();
- WriteAbs(0x00);
- ExecuteStz(4);
- }
-
- private void Execute65C02Stz9E() // stz abs, x
- {
- GetAddressAbsX();
- WriteAbsX(0x00);
- ExecuteStz(5);
- }
-
- private void Execute65C02Trb14() // trb zpg
- {
- GetAddressZpg();
- WriteZpg(ExecuteTrb(ReadZpg(), 5));
- }
-
- private void Execute65C02Trb1C() // trb abs
- {
- GetAddressAbs();
- WriteAbs(ExecuteTrb(ReadAbs(), 6));
- }
-
- private void Execute65C02Tsb04() // tsb zpg
- {
- GetAddressZpg();
- WriteZpg(ExecuteTsb(ReadZpg(), 5));
- }
-
- private void Execute65C02Tsb0C() // tsb abs
- {
- GetAddressAbs();
- WriteAbs(ExecuteTsb(ReadAbs(), 6));
- }
- #endregion
-
- public bool Is65C02 { get { return _is65C02; } set { _is65C02 = value; _executeOpCode = _is65C02 ? ExecuteOpCode65C02 : ExecuteOpCode65N02; } }
- public bool IsThrottled { get; set; }
- public int Multiplier { get; set; }
-
- public int RA { get; private set; }
- public int RX { get; private set; }
- public int RY { get; private set; }
- public int RS { get; private set; }
- public int RP { get; private set; }
- public int RPC { get; private set; }
- public int EA { get; private set; }
- public int CC { get; private set; }
- public int OpCode { get; private set; }
- public long Cycles { get; private set; }
-
- private Memory _memory;
-
- private bool _is65C02;
- private Action[] _executeOpCode;
- }
-}
diff --git a/BizHawk.Emulation.Cores/Computers/AppleII/Virtu/Disk525.cs b/BizHawk.Emulation.Cores/Computers/AppleII/Virtu/Disk525.cs
deleted file mode 100644
index 888a536813c..00000000000
--- a/BizHawk.Emulation.Cores/Computers/AppleII/Virtu/Disk525.cs
+++ /dev/null
@@ -1,98 +0,0 @@
-using System;
-using System.Diagnostics.CodeAnalysis;
-using System.IO;
-using System.Text.RegularExpressions;
-using Jellyfish.Library;
-
-namespace Jellyfish.Virtu
-{
- public abstract class Disk525
- {
- protected Disk525(string name, byte[] data, bool isWriteProtected)
- {
- Name = name;
- Data = data;
- IsWriteProtected = isWriteProtected;
- }
-
- public static Disk525 CreateDisk(string name, Stream stream, bool isWriteProtected)
- {
- if (name == null)
- {
- throw new ArgumentNullException("name");
- }
-
- if (name.EndsWith(".do", StringComparison.OrdinalIgnoreCase) ||
- name.EndsWith(".dsk", StringComparison.OrdinalIgnoreCase)) // assumes dos sector skew
- {
- return new DiskDsk(name, stream, isWriteProtected, SectorSkew.Dos);
- }
- else if (name.EndsWith(".nib", StringComparison.OrdinalIgnoreCase))
- {
- return new DiskNib(name, stream, isWriteProtected);
- }
- else if (name.EndsWith(".po", StringComparison.OrdinalIgnoreCase))
- {
- return new DiskDsk(name, stream, isWriteProtected, SectorSkew.ProDos);
- }
-
- return null;
- }
-
- [SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "version")]
- public static Disk525 LoadState(BinaryReader reader, Version version)
- {
- if (reader == null)
- {
- throw new ArgumentNullException("reader");
- }
-
- string name = reader.ReadString();
- var dataSize = reader.ReadInt32();
- var data = reader.ReadBytes(dataSize);
- bool isWriteProtected = reader.ReadBoolean();
-
- if (name.EndsWith(".do", StringComparison.OrdinalIgnoreCase) ||
- name.EndsWith(".dsk", StringComparison.OrdinalIgnoreCase)) // assumes dos sector skew
- {
- return new DiskDsk(name, data, isWriteProtected, SectorSkew.Dos);
- }
- else if (name.EndsWith(".nib", StringComparison.OrdinalIgnoreCase))
- {
- return new DiskNib(name, data, isWriteProtected);
- }
- else if (name.EndsWith(".po", StringComparison.OrdinalIgnoreCase))
- {
- return new DiskDsk(name, data, isWriteProtected, SectorSkew.ProDos);
- }
-
- return null;
- }
-
- public void SaveState(BinaryWriter writer)
- {
- if (writer == null)
- {
- throw new ArgumentNullException("writer");
- }
-
- writer.Write(Name);
- writer.Write(Data.Length);
- writer.Write(Data);
- writer.Write(IsWriteProtected);
- }
-
- public abstract void ReadTrack(int number, int fraction, byte[] buffer);
- public abstract void WriteTrack(int number, int fraction, byte[] buffer);
-
- public string Name { get; private set; }
- [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
- public byte[] Data { get; protected set; }
- public bool IsWriteProtected { get; private set; }
-
- public const int SectorCount = 16;
- public const int SectorSize = 0x100;
- public const int TrackCount = 35;
- public const int TrackSize = 0x1A00;
- }
-}
diff --git a/BizHawk.Emulation.Cores/Computers/AppleII/Virtu/DiskIIController.cs b/BizHawk.Emulation.Cores/Computers/AppleII/Virtu/DiskIIController.cs
deleted file mode 100644
index d64b426399c..00000000000
--- a/BizHawk.Emulation.Cores/Computers/AppleII/Virtu/DiskIIController.cs
+++ /dev/null
@@ -1,288 +0,0 @@
-using System;
-using System.Collections.ObjectModel;
-using System.Diagnostics.CodeAnalysis;
-using System.IO;
-using Jellyfish.Library;
-using Jellyfish.Virtu.Services;
-
-namespace Jellyfish.Virtu
-{
- public sealed class DiskIIController : PeripheralCard
- {
- public DiskIIController(Machine machine) :
- base(machine)
- {
- Drive1 = new DiskIIDrive(machine);
- Drive2 = new DiskIIDrive(machine);
-
- Drives = new Collection { Drive1, Drive2 };
-
- BootDrive = Drive1;
- }
-
- public override void Initialize()
- {
- //TODO lol!!
- StorageService.LoadResource("c:\\apple\\DiskII.rom", stream => stream.ReadBlock(_romRegionC1C7));
- }
-
- public override void Reset()
- {
- _phaseStates = 0;
- SetMotorOn(false);
- SetDriveNumber(0);
- _loadMode = false;
- _writeMode = false;
- }
-
- public override void LoadState(BinaryReader reader, Version version)
- {
- if (reader == null)
- {
- throw new ArgumentNullException("reader");
- }
-
- _latch = reader.ReadInt32();
- _phaseStates = reader.ReadInt32();
- _motorOn = reader.ReadBoolean();
- _driveNumber = reader.ReadInt32();
- _loadMode = reader.ReadBoolean();
- _writeMode = reader.ReadBoolean();
- _driveSpin = reader.ReadBoolean();
- foreach (var drive in Drives)
- {
- DebugService.WriteMessage("Loading machine '{0}'", drive.GetType().Name);
- drive.LoadState(reader, version);
- //DebugService.WriteMessage("Loaded machine '{0}'", drive.GetType().Name);
- }
- }
-
- public override void SaveState(BinaryWriter writer)
- {
- if (writer == null)
- {
- throw new ArgumentNullException("writer");
- }
-
- writer.Write(_latch);
- writer.Write(_phaseStates);
- writer.Write(_motorOn);
- writer.Write(_driveNumber);
- writer.Write(_loadMode);
- writer.Write(_writeMode);
- writer.Write(_driveSpin);
- foreach (var drive in Drives)
- {
- DebugService.WriteMessage("Saving machine '{0}'", drive.GetType().Name);
- drive.SaveState(writer);
- //DebugService.WriteMessage("Saved machine '{0}'", drive.GetType().Name);
- }
- }
-
- [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;
-
- case 0x8:
- SetMotorOn(false);
- break;
-
- case 0x9:
- SetMotorOn(true);
- break;
-
- case 0xA:
- SetDriveNumber(0);
- break;
-
- case 0xB:
- SetDriveNumber(1);
- 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 0xE:
- _writeMode = false;
- break;
-
- case 0xF:
- _writeMode = true;
- break;
- }
-
- 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;
- }
-
- return ReadFloatingBus();
- }
-
- 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;
-
- case 0x8:
- SetMotorOn(false);
- break;
-
- case 0x9:
- SetMotorOn(true);
- break;
-
- case 0xA:
- SetDriveNumber(0);
- break;
-
- case 0xB:
- SetDriveNumber(1);
- break;
-
- case 0xC:
- _loadMode = false;
- if (_writeMode)
- {
- WriteLatch();
- }
- break;
-
- case 0xD:
- _loadMode = true;
- break;
-
- case 0xE:
- _writeMode = false;
- 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;
- }
- }
- }
-
- 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 SetDriveNumber(int driveNumber)
- {
- if (_driveNumber != driveNumber)
- {
- Flush();
- _driveNumber = driveNumber;
- }
- }
-
- 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);
-
- if (_motorOn)
- {
- Drives[_driveNumber].ApplyPhaseChange(_phaseStates);
- }
- }
-
- public DiskIIDrive Drive1 { get; private set; }
- public DiskIIDrive Drive2 { get; private set; }
-
- public Collection Drives { 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 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];
- }
-}
diff --git a/BizHawk.Emulation.Cores/Computers/AppleII/Virtu/Keyboard.cs b/BizHawk.Emulation.Cores/Computers/AppleII/Virtu/Keyboard.cs
deleted file mode 100644
index dd54a83b530..00000000000
--- a/BizHawk.Emulation.Cores/Computers/AppleII/Virtu/Keyboard.cs
+++ /dev/null
@@ -1,122 +0,0 @@
-using System;
-using System.IO;
-using Jellyfish.Virtu.Services;
-
-namespace Jellyfish.Virtu
-{
- public sealed class Keyboard : MachineComponent
- {
- public Keyboard(Machine machine) :
- base(machine)
- {
- }
-
- public override void Initialize()
- {
- _keyboardService = Machine.Services.GetService();
-
- UseGamePort = true; // Raster Blaster
- Button2Key = ' ';
- }
-
- public override void LoadState(BinaryReader reader, Version version)
- {
- if (reader == null)
- {
- throw new ArgumentNullException("reader");
- }
-
- DisableResetKey = reader.ReadBoolean();
-
- UseGamePort = reader.ReadBoolean();
- Joystick0UpLeftKey = reader.ReadInt32();
- Joystick0UpKey = reader.ReadInt32();
- Joystick0UpRightKey = reader.ReadInt32();
- Joystick0LeftKey = reader.ReadInt32();
- Joystick0RightKey = reader.ReadInt32();
- Joystick0DownLeftKey = reader.ReadInt32();
- Joystick0DownKey = reader.ReadInt32();
- Joystick0DownRightKey = reader.ReadInt32();
- Joystick1UpLeftKey = reader.ReadInt32();
- Joystick1UpKey = reader.ReadInt32();
- Joystick1UpRightKey = reader.ReadInt32();
- Joystick1LeftKey = reader.ReadInt32();
- Joystick1RightKey = reader.ReadInt32();
- Joystick1DownLeftKey = reader.ReadInt32();
- Joystick1DownKey = reader.ReadInt32();
- Joystick1DownRightKey = reader.ReadInt32();
- Button0Key = reader.ReadUInt64();
- Button1Key = reader.ReadInt32();
- Button2Key = reader.ReadInt32();
- }
-
- public override void SaveState(BinaryWriter writer)
- {
- if (writer == null)
- {
- throw new ArgumentNullException("writer");
- }
-
- writer.Write(DisableResetKey);
-
- writer.Write(UseGamePort);
- writer.Write(Joystick0UpLeftKey);
- writer.Write(Joystick0UpKey);
- writer.Write(Joystick0UpRightKey);
- writer.Write(Joystick0LeftKey);
- writer.Write(Joystick0RightKey);
- writer.Write(Joystick0DownLeftKey);
- writer.Write(Joystick0DownKey);
- writer.Write(Joystick0DownRightKey);
- writer.Write(Joystick1UpLeftKey);
- writer.Write(Joystick1UpKey);
- writer.Write(Joystick1UpRightKey);
- writer.Write(Joystick1LeftKey);
- writer.Write(Joystick1RightKey);
- writer.Write(Joystick1DownLeftKey);
- writer.Write(Joystick1DownKey);
- writer.Write(Joystick1DownRightKey);
- writer.Write(Button0Key);
- writer.Write(Button1Key);
- writer.Write(Button2Key);
- }
-
- public void ResetStrobe()
- {
- Strobe = false;
- }
-
- public bool DisableResetKey { get; set; }
-
- public bool UseGamePort { get; set; }
- public int Joystick0UpLeftKey { get; set; }
- public int Joystick0UpKey { get; set; }
- public int Joystick0UpRightKey { get; set; }
- public int Joystick0LeftKey { get; set; }
- public int Joystick0RightKey { get; set; }
- public int Joystick0DownLeftKey { get; set; }
- public int Joystick0DownKey { get; set; }
- public int Joystick0DownRightKey { get; set; }
- public int Joystick1UpLeftKey { get; set; }
- public int Joystick1UpKey { get; set; }
- public int Joystick1UpRightKey { get; set; }
- public int Joystick1LeftKey { get; set; }
- public int Joystick1RightKey { get; set; }
- public int Joystick1DownLeftKey { get; set; }
- public int Joystick1DownKey { get; set; }
- public int Joystick1DownRightKey { get; set; }
- public ulong Button0Key { get; set; }
- public int Button1Key { get; set; }
- public int Button2Key { get; set; }
-
- public bool IsAnyKeyDown { get { return _keyboardService.IsAnyKeyDown; } }
- public bool IsShiftKeyDown { get { return _keyboardService.IsShiftKeyDown; } }
- public bool IsControlKeyDown { get { return _keyboardService.IsControlKeyDown; } }
- public int Latch { get { return _latch; } set { _latch = value; Strobe = true; } }
- public bool Strobe { get; private set; }
-
- private KeyboardService _keyboardService;
-
- private int _latch;
- }
-}
diff --git a/BizHawk.Emulation.Cores/Computers/AppleII/Virtu/Library/StreamExtensions.cs b/BizHawk.Emulation.Cores/Computers/AppleII/Virtu/Library/StreamExtensions.cs
deleted file mode 100644
index e55767f4978..00000000000
--- a/BizHawk.Emulation.Cores/Computers/AppleII/Virtu/Library/StreamExtensions.cs
+++ /dev/null
@@ -1,94 +0,0 @@
-using System;
-using System.Diagnostics.CodeAnalysis;
-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;
- }
-
- [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");
- }
-
- 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));
-
- if (total < minCount)
- {
- throw new EndOfStreamException();
- }
-
- return total;
- }
-
- [SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed")]
- 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();
- }
-
- return word;
- }
-
- 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));
- }
- }
-
- private const int SkipBufferSize = 1024;
-
- private static byte[] _skipBuffer = new byte[SkipBufferSize];
- }
-}
diff --git a/BizHawk.Emulation.Cores/Computers/AppleII/Virtu/Library/Strings.cs b/BizHawk.Emulation.Cores/Computers/AppleII/Virtu/Library/Strings.cs
deleted file mode 100644
index 400fb73e0c0..00000000000
--- a/BizHawk.Emulation.Cores/Computers/AppleII/Virtu/Library/Strings.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace Jellyfish.Virtu.Properties
-{
- public static class Strings // Hack because we don't want resources in the core
- {
- public static string InvalidAddressRange
- {
- get
- {
- return "Invalid address range ${0:X04}-${1:X04}.";
- }
- }
-
- public static string MarkerNotFound
- {
- get
- {
- return "Marker ${0:X04} not found.";
- }
- }
-
- public static string ResourceNotFound
- {
- get
- {
- return "Resource '{0}' not found.";
- }
- }
-
- public static string ServiceAlreadyPresent
- {
- get
- {
- return "Service type '{0}' already present.";
- }
- }
-
- public static string ServiceMustBeAssignable
- {
- get
- {
- return "Service type '{0}' must be assignable from service provider '{1}'.";
- }
- }
- }
-}
diff --git a/BizHawk.Emulation.Cores/Computers/AppleII/Virtu/Machine.cs b/BizHawk.Emulation.Cores/Computers/AppleII/Virtu/Machine.cs
deleted file mode 100644
index 99f9d592072..00000000000
--- a/BizHawk.Emulation.Cores/Computers/AppleII/Virtu/Machine.cs
+++ /dev/null
@@ -1,383 +0,0 @@
-using System;
-using System.Collections.ObjectModel;
-using System.Diagnostics.CodeAnalysis;
-using System.IO;
-using System.Linq;
-using System.Threading;
-using Jellyfish.Virtu.Services;
-
-namespace Jellyfish.Virtu
-{
- public enum MachineState { Stopped = 0, Starting, Running, Pausing, Paused, Stopping }
-
- public enum Buttons : ulong
- {
- Up = 0x0000000000001,
- Down = 0x0000000000002,
- Left = 0x0000000000004,
- Right = 0x0000000000008,
- Tab = 0x0000000000010,
- Enter = 0x0000000000020,
- Escape = 0x0000000000040,
- Back = 0x0000000000080,
- Space = 0x0000000000100,
- Ctrl = 0x0000000000200,
- Shift = 0x0000000000400,
- Caps = 0x0000000000800,
- Key1 = 0x0000000001000,
- Key2 = 0x0000000002000,
- Key3 = 0x0000000004000,
- Key4 = 0x0000000008000,
- Key5 = 0x0000000010000,
- Key6 = 0x0000000020000,
- Key7 = 0x0000000040000,
- Key8 = 0x0000000080000,
- Key9 = 0x0000000100000,
- Key0 = 0x0000000200000,
- KeyA = 0x0000001000000,
- KeyB = 0x0000002000000,
- KeyC = 0x0000004000000,
- KeyD = 0x0000008000000,
- KeyE = 0x0000010000000,
- KeyF = 0x0000020000000,
- KeyG = 0x0000040000000,
- KeyH = 0x0000080000000,
- KeyI = 0x0000100000000,
- KeyJ = 0x0000200000000,
- KeyK = 0x0000400000000,
- KeyL = 0x0000800000000,
- KeyM = 0x0001000000000,
- KeyN = 0x0002000000000,
- KeyO = 0x0004000000000,
- KeyP = 0x0008000000000,
- KeyQ = 0x0010000000000,
- KeyR = 0x0020000000000,
- KeyS = 0x0040000000000,
- KeyT = 0x0080000000000,
- KeyU = 0x0100000000000,
- KeyV = 0x0200000000000,
- KeyW = 0x0400000000000,
- KeyX = 0x0800000000000,
- KeyY = 0x1000000000000,
- KeyZ = 0x2000000000000
- }
-
- public sealed class Machine : IDisposable
- {
- public Machine()
- {
- Events = new MachineEvents();
- Services = new MachineServices();
-
- Cpu = new Cpu(this);
- Memory = new Memory(this);
- Keyboard = new Keyboard(this);
- GamePort = new GamePort(this);
- Cassette = new Cassette(this);
- Speaker = new Speaker(this);
- Video = new Video(this);
- NoSlotClock = new NoSlotClock(this);
-
- var emptySlot = new PeripheralCard(this);
- Slot1 = emptySlot;
- Slot2 = emptySlot;
- Slot3 = emptySlot;
- Slot4 = emptySlot;
- Slot5 = emptySlot;
- Slot6 = new DiskIIController(this);
- Slot7 = emptySlot;
-
- Slots = new Collection { null, Slot1, Slot2, Slot3, Slot4, Slot5, Slot6, Slot7 };
- Components = new Collection { Cpu, Memory, Keyboard, GamePort, Cassette, Speaker, Video, NoSlotClock, Slot1, Slot2, Slot3, Slot4, Slot5, Slot6, Slot7 };
-
- BootDiskII = Slots.OfType().Last();
-
- //Thread = new Thread(Run) { Name = "Machine" };
- }
-
- public void Dispose()
- {
- _pauseEvent.Close();
- _unpauseEvent.Close();
- }
-
- public void Reset()
- {
- foreach (var component in Components)
- {
- _debugService.WriteMessage("Resetting machine '{0}'", component.GetType().Name);
- component.Reset();
- //_debugService.WriteMessage("Reset machine '{0}'", component.GetType().Name);
- }
- }
-
- //[SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "Jellyfish.Virtu.Services.DebugService.WriteMessage(System.String)")]
- //public void Start()
- //{
- // _debugService = Services.GetService();
- // _storageService = Services.GetService();
-
- // _debugService.WriteMessage("Starting machine");
- // State = MachineState.Starting;
- // Thread.Start();
- //}
-
- //[SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "Jellyfish.Virtu.Services.DebugService.WriteMessage(System.String)")]
- //public void Pause()
- //{
- // _debugService.WriteMessage("Pausing machine");
- // State = MachineState.Pausing;
- // _pauseEvent.WaitOne();
- // State = MachineState.Paused;
- // _debugService.WriteMessage("Paused machine");
- //}
-
- //[SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "Jellyfish.Virtu.Services.DebugService.WriteMessage(System.String)")]
- //public void Unpause()
- //{
- // _debugService.WriteMessage("Running machine");
- // State = MachineState.Running;
- // _unpauseEvent.Set();
- //}
-
- //[SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "Jellyfish.Virtu.Services.DebugService.WriteMessage(System.String)")]
- //public void Stop()
- //{
- // _debugService.WriteMessage("Stopping machine");
- // State = MachineState.Stopping;
- // _unpauseEvent.Set();
- // if (Thread.IsAlive)
- // {
- // Thread.Join();
- // }
- // State = MachineState.Stopped;
- // _debugService.WriteMessage("Stopped machine");
- //}
-
- private void Initialize()
- {
- foreach (var component in Components)
- {
- _debugService.WriteMessage("Initializing machine '{0}'", component.GetType().Name);
- component.Initialize();
- //_debugService.WriteMessage("Initialized machine '{0}'", component.GetType().Name);
- }
- }
-
- private void LoadState()
- {
-#if WINDOWS
- var args = Environment.GetCommandLineArgs();
- if (args.Length > 1)
- {
- string name = args[1];
- Func, bool> loader = StorageService.LoadFile;
-
- if (name.StartsWith("res://", StringComparison.OrdinalIgnoreCase))
- {
- name = name.Substring(6);
- loader = StorageService.LoadResource;
- }
-
- if (name.EndsWith(".bin", StringComparison.OrdinalIgnoreCase))
- {
- loader(name, stream => LoadState(stream));
- }
- else if (name.EndsWith(".prg", StringComparison.OrdinalIgnoreCase))
- {
- loader(name, stream => Memory.LoadPrg(stream));
- }
- else if (name.EndsWith(".xex", StringComparison.OrdinalIgnoreCase))
- {
- loader(name, stream => Memory.LoadXex(stream));
- }
- else
- {
- loader(name, stream => BootDiskII.BootDrive.InsertDisk(name, stream, false));
- }
- }
- else
-#endif
- if (!_storageService.Load(Machine.StateFileName, stream => LoadState(stream)))
- {
- StorageService.LoadResource("Disks/Default.dsk", stream => BootDiskII.BootDrive.InsertDisk("Default.dsk", stream, false));
- }
- }
-
- // TODO: don't copy paste
- public void LoadState(BinaryReader reader)
- {
- string signature = reader.ReadString();
- var version = new Version(reader.ReadString());
- if ((signature != StateSignature) || (version != new Version(Machine.Version))) // avoid state version mismatch (for now)
- {
- throw new InvalidOperationException();
- }
- foreach (var component in Components)
- {
- _debugService.WriteMessage("Loading machine '{0}'", component.GetType().Name);
- component.LoadState(reader, version);
- //_debugService.WriteMessage("Loaded machine '{0}'", component.GetType().Name);
- }
- }
-
- private void LoadState(Stream stream)
- {
- using (var reader = new BinaryReader(stream))
- {
- string signature = reader.ReadString();
- var version = new Version(reader.ReadString());
- if ((signature != StateSignature) || (version != new Version(Machine.Version))) // avoid state version mismatch (for now)
- {
- throw new InvalidOperationException();
- }
- foreach (var component in Components)
- {
- _debugService.WriteMessage("Loading machine '{0}'", component.GetType().Name);
- component.LoadState(reader, version);
- //_debugService.WriteMessage("Loaded machine '{0}'", component.GetType().Name);
- }
- }
- }
-
- private void SaveState()
- {
- _storageService.Save(Machine.StateFileName, stream => SaveState(stream));
- }
-
- public void SaveState(BinaryWriter writer)
- {
- writer.Write(StateSignature);
- writer.Write(Machine.Version);
- foreach (var component in Components)
- {
- _debugService.WriteMessage("Saving machine '{0}'", component.GetType().Name);
- component.SaveState(writer);
- //_debugService.WriteMessage("Saved machine '{0}'", component.GetType().Name);
- }
- }
-
- private void SaveState(Stream stream)
- {
- using (var writer = new BinaryWriter(stream))
- {
- writer.Write(StateSignature);
- writer.Write(Machine.Version);
- foreach (var component in Components)
- {
- _debugService.WriteMessage("Saving machine '{0}'", component.GetType().Name);
- component.SaveState(writer);
- //_debugService.WriteMessage("Saved machine '{0}'", component.GetType().Name);
- }
- }
- }
-
- private void Uninitialize()
- {
- foreach (var component in Components)
- {
- _debugService.WriteMessage("Uninitializing machine '{0}'", component.GetType().Name);
- component.Uninitialize();
- //_debugService.WriteMessage("Uninitialized machine '{0}'", component.GetType().Name);
- }
- }
-
- //[SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "Jellyfish.Virtu.Services.DebugService.WriteMessage(System.String)")]
- //private void Run() // machine thread
- //{
- // Initialize();
- // Reset();
- // LoadState();
- //
- // _debugService.WriteMessage("Running machine");
- // State = MachineState.Running;
- // do
- // {
- // do
- // {
- // Events.HandleEvents(Cpu.Execute());
- // }
- // while (State == MachineState.Running);
- //
- // if (State == MachineState.Pausing)
- // {
- // _pauseEvent.Set();
- // _unpauseEvent.WaitOne();
- // }
- // }
- // while (State != MachineState.Stopping);
- //
- // SaveState();
- // Uninitialize();
- //}
-
- public void BizInitialize()
- {
- _debugService = Services.GetService();
- _storageService = Services.GetService();
-
- Initialize();
- Reset();
- }
-
- public void BizFrameAdvance()
- {
- Services.GetService().Update();
- Services.GetService().Update();
- //frame begins at vsync.. beginning of vblank
- while (Video.IsVBlank)
- Events.HandleEvents(Cpu.Execute());
- //now, while not vblank, we're in a frame
- while (!Video.IsVBlank)
- Events.HandleEvents(Cpu.Execute());
-
- }
-
- public void BizShutdown()
- {
- Uninitialize();
- }
-
- public const string Version = "0.9.4.0";
-
- public MachineEvents Events { get; private set; }
- public MachineServices Services { get; private set; }
- public MachineState State { get { return _state; } private set { _state = value; } }
-
- public Cpu Cpu { get; private set; }
- public Memory Memory { get; private set; }
- public Keyboard Keyboard { get; private set; }
- public GamePort GamePort { get; private set; }
- public Cassette Cassette { get; private set; }
- public Speaker Speaker { get; private set; }
- public Video Video { get; private set; }
- public NoSlotClock NoSlotClock { get; private set; }
-
- public PeripheralCard Slot1 { get; private set; }
- public PeripheralCard Slot2 { get; private set; }
- public PeripheralCard Slot3 { get; private set; }
- public PeripheralCard Slot4 { get; private set; }
- public PeripheralCard Slot5 { get; private set; }
- public PeripheralCard Slot6 { get; private set; }
- public PeripheralCard Slot7 { get; private set; }
-
- public Collection Slots { get; private set; }
- public Collection Components { get; private set; }
-
- public DiskIIController BootDiskII { get; private set; }
-
- public Thread Thread { get; private set; }
-
- public Buttons Buttons;
-
- private const string StateFileName = "State.bin";
- private const string StateSignature = "Virtu";
-
- private DebugService _debugService;
- private StorageService _storageService;
- private volatile MachineState _state;
-
- private AutoResetEvent _pauseEvent = new AutoResetEvent(false);
- private AutoResetEvent _unpauseEvent = new AutoResetEvent(false);
- }
-}
diff --git a/BizHawk.Emulation.Cores/Computers/AppleII/Virtu/MachineComponent.cs b/BizHawk.Emulation.Cores/Computers/AppleII/Virtu/MachineComponent.cs
deleted file mode 100644
index 195b8ed3fb1..00000000000
--- a/BizHawk.Emulation.Cores/Computers/AppleII/Virtu/MachineComponent.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-using System;
-using System.IO;
-using Jellyfish.Library;
-using Jellyfish.Virtu.Services;
-
-namespace Jellyfish.Virtu
-{
- public abstract class MachineComponent
- {
- protected MachineComponent(Machine machine)
- {
- Machine = machine;
-
- _debugService = new Lazy(() => Machine.Services.GetService());
- }
-
- public virtual void Initialize()
- {
- }
-
- public virtual void Reset()
- {
- }
-
- public virtual void LoadState(BinaryReader reader, Version version)
- {
- }
-
- public virtual void Uninitialize()
- {
- }
-
- public virtual void SaveState(BinaryWriter writer)
- {
- }
-
- protected Machine Machine { get; private set; }
- protected DebugService DebugService { get { return _debugService.Value; } }
-
- private Lazy _debugService;
- }
-}
diff --git a/BizHawk.Emulation.Cores/Computers/AppleII/Virtu/Memory.cs b/BizHawk.Emulation.Cores/Computers/AppleII/Virtu/Memory.cs
deleted file mode 100644
index 6b1498fac0c..00000000000
--- a/BizHawk.Emulation.Cores/Computers/AppleII/Virtu/Memory.cs
+++ /dev/null
@@ -1,1739 +0,0 @@
-using System;
-using System.Diagnostics.CodeAnalysis;
-using System.Globalization;
-using System.IO;
-using Jellyfish.Library;
-using Jellyfish.Virtu.Properties;
-using Jellyfish.Virtu.Services;
-
-namespace Jellyfish.Virtu
-{
- public enum MonitorType { Unknown, Standard, Enhanced };
-
- public sealed partial class Memory : MachineComponent
- {
- public Memory(Machine machine) :
- base(machine)
- {
- WriteRamModeBankRegion = new Action[Video.ModeCount][][];
- for (int mode = 0; mode < Video.ModeCount; mode++)
- {
- WriteRamModeBankRegion[mode] = new Action[BankCount][]
- {
- new Action[RegionCount], new Action[RegionCount]
- };
- }
- WriteRamModeBankRegion[Video.Mode0][BankMain][Region0407] = WriteRamMode0MainRegion0407;
- WriteRamModeBankRegion[Video.Mode0][BankMain][Region080B] = WriteRamMode0MainRegion080B;
- WriteRamModeBankRegion[Video.Mode1][BankMain][Region0407] = WriteRamMode1MainRegion0407;
- WriteRamModeBankRegion[Video.Mode1][BankMain][Region080B] = WriteRamMode1MainRegion080B;
- WriteRamModeBankRegion[Video.Mode2][BankMain][Region0407] = WriteRamMode2MainRegion0407;
- WriteRamModeBankRegion[Video.Mode2][BankMain][Region080B] = WriteRamMode2MainRegion080B;
- WriteRamModeBankRegion[Video.Mode2][BankAux][Region0407] = WriteRamMode2AuxRegion0407;
- WriteRamModeBankRegion[Video.Mode2][BankAux][Region080B] = WriteRamMode2AuxRegion080B;
- WriteRamModeBankRegion[Video.Mode3][BankMain][Region0407] = WriteRamMode3MainRegion0407;
- WriteRamModeBankRegion[Video.Mode3][BankMain][Region080B] = WriteRamMode3MainRegion080B;
- WriteRamModeBankRegion[Video.Mode4][BankMain][Region0407] = WriteRamMode4MainRegion0407;
- WriteRamModeBankRegion[Video.Mode4][BankMain][Region080B] = WriteRamMode4MainRegion080B;
- WriteRamModeBankRegion[Video.Mode4][BankAux][Region0407] = WriteRamMode4AuxRegion0407;
- WriteRamModeBankRegion[Video.Mode4][BankAux][Region080B] = WriteRamMode4AuxRegion080B;
- WriteRamModeBankRegion[Video.Mode5][BankMain][Region203F] = WriteRamMode5MainRegion203F;
- WriteRamModeBankRegion[Video.Mode5][BankMain][Region405F] = WriteRamMode5MainRegion405F;
- WriteRamModeBankRegion[Video.Mode6][BankMain][Region0407] = WriteRamMode6MainRegion0407;
- WriteRamModeBankRegion[Video.Mode6][BankMain][Region080B] = WriteRamMode6MainRegion080B;
- WriteRamModeBankRegion[Video.Mode6][BankMain][Region203F] = WriteRamMode6MainRegion203F;
- WriteRamModeBankRegion[Video.Mode6][BankMain][Region405F] = WriteRamMode6MainRegion405F;
- WriteRamModeBankRegion[Video.Mode7][BankMain][Region0407] = WriteRamMode7MainRegion0407;
- WriteRamModeBankRegion[Video.Mode7][BankMain][Region080B] = WriteRamMode7MainRegion080B;
- WriteRamModeBankRegion[Video.Mode7][BankMain][Region203F] = WriteRamMode7MainRegion203F;
- WriteRamModeBankRegion[Video.Mode7][BankMain][Region405F] = WriteRamMode7MainRegion405F;
- WriteRamModeBankRegion[Video.Mode7][BankAux][Region0407] = WriteRamMode7AuxRegion0407;
- WriteRamModeBankRegion[Video.Mode7][BankAux][Region080B] = WriteRamMode7AuxRegion080B;
- WriteRamModeBankRegion[Video.Mode8][BankMain][Region0407] = WriteRamMode8MainRegion0407;
- WriteRamModeBankRegion[Video.Mode8][BankMain][Region080B] = WriteRamMode8MainRegion080B;
- WriteRamModeBankRegion[Video.Mode9][BankMain][Region0407] = WriteRamMode9MainRegion0407;
- WriteRamModeBankRegion[Video.Mode9][BankMain][Region080B] = WriteRamMode9MainRegion080B;
- WriteRamModeBankRegion[Video.Mode9][BankAux][Region0407] = WriteRamMode9AuxRegion0407;
- WriteRamModeBankRegion[Video.Mode9][BankAux][Region080B] = WriteRamMode9AuxRegion080B;
- WriteRamModeBankRegion[Video.ModeA][BankMain][Region0407] = WriteRamModeAMainRegion0407;
- WriteRamModeBankRegion[Video.ModeA][BankMain][Region080B] = WriteRamModeAMainRegion080B;
- WriteRamModeBankRegion[Video.ModeB][BankMain][Region0407] = WriteRamModeBMainRegion0407;
- WriteRamModeBankRegion[Video.ModeB][BankMain][Region080B] = WriteRamModeBMainRegion080B;
- WriteRamModeBankRegion[Video.ModeB][BankAux][Region0407] = WriteRamModeBAuxRegion0407;
- WriteRamModeBankRegion[Video.ModeB][BankAux][Region080B] = WriteRamModeBAuxRegion080B;
- WriteRamModeBankRegion[Video.ModeC][BankMain][Region203F] = WriteRamModeCMainRegion203F;
- WriteRamModeBankRegion[Video.ModeC][BankMain][Region405F] = WriteRamModeCMainRegion405F;
- WriteRamModeBankRegion[Video.ModeD][BankMain][Region203F] = WriteRamModeDMainRegion203F;
- WriteRamModeBankRegion[Video.ModeD][BankMain][Region405F] = WriteRamModeDMainRegion405F;
- WriteRamModeBankRegion[Video.ModeD][BankAux][Region203F] = WriteRamModeDAuxRegion203F;
- WriteRamModeBankRegion[Video.ModeD][BankAux][Region405F] = WriteRamModeDAuxRegion405F;
- WriteRamModeBankRegion[Video.ModeE][BankMain][Region0407] = WriteRamModeEMainRegion0407;
- WriteRamModeBankRegion[Video.ModeE][BankMain][Region080B] = WriteRamModeEMainRegion080B;
- WriteRamModeBankRegion[Video.ModeE][BankMain][Region203F] = WriteRamModeEMainRegion203F;
- WriteRamModeBankRegion[Video.ModeE][BankMain][Region405F] = WriteRamModeEMainRegion405F;
- WriteRamModeBankRegion[Video.ModeF][BankMain][Region0407] = WriteRamModeFMainRegion0407;
- WriteRamModeBankRegion[Video.ModeF][BankMain][Region080B] = WriteRamModeFMainRegion080B;
- WriteRamModeBankRegion[Video.ModeF][BankMain][Region203F] = WriteRamModeFMainRegion203F;
- WriteRamModeBankRegion[Video.ModeF][BankMain][Region405F] = WriteRamModeFMainRegion405F;
- WriteRamModeBankRegion[Video.ModeF][BankAux][Region0407] = WriteRamModeFAuxRegion0407;
- WriteRamModeBankRegion[Video.ModeF][BankAux][Region080B] = WriteRamModeFAuxRegion080B;
- WriteRamModeBankRegion[Video.ModeF][BankAux][Region203F] = WriteRamModeFAuxRegion203F;
- WriteRamModeBankRegion[Video.ModeF][BankAux][Region405F] = WriteRamModeFAuxRegion405F;
-
- _writeIoRegionC0C0 = WriteIoRegionC0C0; // cache delegates; avoids garbage
- _writeIoRegionC1C7 = WriteIoRegionC1C7;
- _writeIoRegionC3C3 = WriteIoRegionC3C3;
- _writeIoRegionC8CF = WriteIoRegionC8CF;
- _writeRomRegionD0FF = WriteRomRegionD0FF;
- }
-
- public override void Initialize()
- {
- _keyboard = Machine.Keyboard;
- _gamePort = Machine.GamePort;
- _cassette = Machine.Cassette;
- _speaker = Machine.Speaker;
- _video = Machine.Video;
- _noSlotClock = Machine.NoSlotClock;
-
- //TODO lol!!
- StorageService.LoadResource("c:\\apple\\AppleIIe.rom", stream =>
- {
- stream.SkipBlock(0x0100);
- stream.ReadBlock(_romInternalRegionC1CF);
- stream.ReadBlock(_romRegionD0DF);
- stream.ReadBlock(_romRegionE0FF);
- });
-
- if ((ReadRomRegionE0FF(0xFBB3) == 0x06) && (ReadRomRegionE0FF(0xFBBF) == 0xC1))
- {
- Monitor = MonitorType.Standard;
- }
- else if ((ReadRomRegionE0FF(0xFBB3) == 0x06) && (ReadRomRegionE0FF(0xFBBF) == 0x00) && (ReadRomRegionE0FF(0xFBC0) == 0xE0))
- {
- Monitor = MonitorType.Enhanced;
- }
- }
-
- public override void Reset() // [7-3]
- {
- ResetState(State80Col | State80Store | StateAltChrSet | StateAltZP | StateBank1 | StateHRamRd | StateHRamPreWrt | StateHRamWrt | // HRamWrt' [5-23]
- StateHires | StatePage2 | StateRamRd | StateRamWrt | StateIntCXRom | StateSlotC3Rom | StateIntC8Rom | StateAn0 | StateAn1 | StateAn2 | StateAn3);
- SetState(StateDRes); // An3' -> DRes [8-20]
-
- MapRegion0001();
- MapRegion02BF();
- MapRegionC0CF();
- MapRegionD0FF();
- }
-
- public override void LoadState(BinaryReader reader, Version version)
- {
- if (reader == null)
- {
- throw new ArgumentNullException("reader");
- }
-
- _state = reader.ReadInt32();
- _slotRegionC8CF = reader.ReadInt32();
-
- reader.Read(_ramMainRegion0001, 0, _ramMainRegion0001.Length);
- reader.Read(_ramMainRegion02BF, 0, _ramMainRegion02BF.Length);
- reader.Read(_ramMainBank1RegionD0DF, 0, _ramMainBank1RegionD0DF.Length);
- reader.Read(_ramMainBank2RegionD0DF, 0, _ramMainBank2RegionD0DF.Length);
- reader.Read(_ramMainRegionE0FF, 0, _ramMainRegionE0FF.Length);
- reader.Read(_ramAuxRegion0001, 0, _ramAuxRegion0001.Length);
- reader.Read(_ramAuxRegion02BF, 0, _ramAuxRegion02BF.Length);
- reader.Read(_ramAuxBank1RegionD0DF, 0, _ramAuxBank1RegionD0DF.Length);
- reader.Read(_ramAuxBank2RegionD0DF, 0, _ramAuxBank2RegionD0DF.Length);
- reader.Read(_ramAuxRegionE0FF, 0, _ramAuxRegionE0FF.Length);
-
- MapRegion0001();
- MapRegion02BF();
- MapRegionC0CF();
- MapRegionD0FF();
- }
-
- public override void SaveState(BinaryWriter writer)
- {
- if (writer == null)
- {
- throw new ArgumentNullException("writer");
- }
-
- writer.Write(_state);
- writer.Write(_slotRegionC8CF);
-
- writer.Write(_ramMainRegion0001);
- writer.Write(_ramMainRegion02BF);
- writer.Write(_ramMainBank1RegionD0DF);
- writer.Write(_ramMainBank2RegionD0DF);
- writer.Write(_ramMainRegionE0FF);
- writer.Write(_ramAuxRegion0001);
- writer.Write(_ramAuxRegion02BF);
- writer.Write(_ramAuxBank1RegionD0DF);
- writer.Write(_ramAuxBank2RegionD0DF);
- writer.Write(_ramAuxRegionE0FF);
- }
-
- public void LoadPrg(Stream stream)
- {
- if (stream == null)
- {
- throw new ArgumentNullException("stream");
- }
-
- int startAddress = stream.ReadWord();
- SetWarmEntry(startAddress); // assumes autostart monitor
- Load(stream, startAddress);
- }
-
- public void LoadXex(Stream stream)
- {
- if (stream == null)
- {
- throw new ArgumentNullException("stream");
- }
-
- const int Marker = 0xFFFF;
- int marker = stream.ReadWord(); // mandatory marker
- if (marker != Marker)
- {
- throw new InvalidOperationException(string.Format(CultureInfo.CurrentUICulture, Strings.MarkerNotFound, Marker));
- }
- int startAddress = stream.ReadWord();
- int endAddress = stream.ReadWord();
- SetWarmEntry(startAddress); // assumes autostart monitor
-
- do
- {
- if (startAddress > endAddress)
- {
- throw new InvalidOperationException(string.Format(CultureInfo.CurrentUICulture, Strings.InvalidAddressRange, startAddress, endAddress));
- }
- Load(stream, startAddress, endAddress - startAddress + 1);
- marker = stream.ReadWord(optional: true); // optional marker
- startAddress = (marker != Marker) ? marker : stream.ReadWord(optional: true);
- endAddress = stream.ReadWord(optional: true);
- }
- while ((startAddress >= 0) && (endAddress >= 0));
- }
-
- #region Core Read & Write
- public int Read(int address)
- {
- int region = PageRegion[address >> 8];
- return ((address & 0xF000) != 0xC000) ? _regionRead[region][address - RegionBaseAddress[region]] : ReadIoRegionC0CF(address);
- }
-
- public int ReadZeroPage(int address)
- {
- return _zeroPage[address];
- }
-
- public void Write(int address, int data)
- {
- int region = PageRegion[address >> 8];
- if (_writeRegion[region] == null)
- {
- _regionWrite[region][address - RegionBaseAddress[region]] = (byte)data;
- }
- else
- {
- _writeRegion[region](address, (byte)data);
- }
- }
-
- public void WriteZeroPage(int address, int data)
- {
- _zeroPage[address] = (byte)data;
- }
- #endregion
-
- #region Read Actions
- private int ReadIoRegionC0CF(int address)
- {
- switch (address & 0xFF00)
- {
- case 0xC000:
- return ReadIoRegionC0C0(address);
-
- case 0xC100: case 0xC200: case 0xC400: case 0xC500: case 0xC600: case 0xC700:
- return ReadIoRegionC1C7(address);
-
- case 0xC300:
- return ReadIoRegionC3C3(address);
-
- case 0xC800: case 0xC900: case 0xCA00: case 0xCB00: case 0xCC00: case 0xCD00: case 0xCE00: case 0xCF00:
- return ReadIoRegionC8CF(address);
- }
-
- return _video.ReadFloatingBus();
- }
-
- [SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
- [SuppressMessage("Microsoft.Maintainability", "CA1505:AvoidUnmaintainableCode")]
- private int ReadIoRegionC0C0(int address)
- {
- switch (address)
- {
- case 0xC000: case 0xC001: case 0xC002: case 0xC003: case 0xC004: case 0xC005: case 0xC006: case 0xC007: // [7-15]
- case 0xC008: case 0xC009: case 0xC00A: case 0xC00B: case 0xC00C: case 0xC00D: case 0xC00E: case 0xC00F:
- return SetBit7(_keyboard.Latch, _keyboard.Strobe);
-
- case 0xC010:
- _keyboard.ResetStrobe();
- return SetBit7(_keyboard.Latch, _keyboard.IsAnyKeyDown);
-
- case 0xC011:
- return SetBit7(_keyboard.Latch, !IsHighRamBank1); // Bank1' [5-22]
-
- case 0xC012:
- return SetBit7(_keyboard.Latch, IsHighRamRead);
-
- case 0xC013:
- return SetBit7(_keyboard.Latch, IsRamReadAux);
-
- case 0xC014:
- return SetBit7(_keyboard.Latch, IsRamWriteAux);
-
- case 0xC015:
- return SetBit7(_keyboard.Latch, IsRomC1CFInternal);
-
- case 0xC016:
- return SetBit7(_keyboard.Latch, IsZeroPageAux);
-
- case 0xC017:
- return SetBit7(_keyboard.Latch, IsRomC3C3External);
-
- case 0xC018:
- return SetBit7(_keyboard.Latch, Is80Store);
-
- case 0xC019:
- return SetBit7(_keyboard.Latch, !_video.IsVBlank); // Vbl' [7-5]
-
- case 0xC01A:
- return SetBit7(_keyboard.Latch, IsText);
-
- case 0xC01B:
- return SetBit7(_keyboard.Latch, IsMixed);
-
- case 0xC01C:
- return SetBit7(_keyboard.Latch, IsPage2);
-
- case 0xC01D:
- return SetBit7(_keyboard.Latch, IsHires);
-
- case 0xC01E:
- return SetBit7(_keyboard.Latch, IsCharSetAlternate);
-
- case 0xC01F:
- return SetBit7(_keyboard.Latch, Is80Columns);
-
- case 0xC020: case 0xC021: case 0xC022: case 0xC023: case 0xC024: case 0xC025: case 0xC026: case 0xC027: // [7-8]
- case 0xC028: case 0xC029: case 0xC02A: case 0xC02B: case 0xC02C: case 0xC02D: case 0xC02E: case 0xC02F:
- _cassette.ToggleOutput();
- break;
-
- case 0xC030: case 0xC031: case 0xC032: case 0xC033: case 0xC034: case 0xC035: case 0xC036: case 0xC037: // [7-9]
- case 0xC038: case 0xC039: case 0xC03A: case 0xC03B: case 0xC03C: case 0xC03D: case 0xC03E: case 0xC03F:
- _speaker.ToggleOutput();
- break;
-
- case 0xC040: case 0xC041: case 0xC042: case 0xC043: case 0xC044: case 0xC045: case 0xC046: case 0xC047: // [2-18]
- case 0xC048: case 0xC049: case 0xC04A: case 0xC04B: case 0xC04C: case 0xC04D: case 0xC04E: case 0xC04F:
- break;
-
- case 0xC050: case 0xC051:
- SetText(TestBit(address, 0));
- break;
-
- case 0xC052: case 0xC053:
- SetMixed(TestBit(address, 0));
- break;
-
- case 0xC054: case 0xC055:
- SetPage2(TestBit(address, 0));
- break;
-
- case 0xC056: case 0xC057:
- SetHires(TestBit(address, 0));
- break;
-
- case 0xC058: case 0xC059:
- SetAnnunciator0(TestBit(address, 0));
- break;
-
- case 0xC05A: case 0xC05B:
- SetAnnunciator1(TestBit(address, 0));
- break;
-
- case 0xC05C: case 0xC05D:
- SetAnnunciator2(TestBit(address, 0));
- break;
-
- case 0xC05E: case 0xC05F:
- SetAnnunciator3(TestBit(address, 0));
- SetDoubleRes(!TestBit(address, 0));
- break;
-
- case 0xC060: case 0xC068: // [2-18, 7-5]
- return SetBit7(_video.ReadFloatingBus(), _cassette.ReadInput()); // [7-8]
-
- case 0xC061: case 0xC069:
- return SetBit7(_video.ReadFloatingBus(), _gamePort.ReadButton0());
-
- case 0xC062: case 0xC06A:
- return SetBit7(_video.ReadFloatingBus(), _gamePort.ReadButton1());
-
- case 0xC063: case 0xC06B:
- return SetBit7(_video.ReadFloatingBus(), _gamePort.ReadButton2());
-
- case 0xC064: case 0xC06C:
- return SetBit7(_video.ReadFloatingBus(), _gamePort.Paddle0Strobe);
-
- case 0xC065: case 0xC06D:
- return SetBit7(_video.ReadFloatingBus(), _gamePort.Paddle1Strobe);
-
- case 0xC066: case 0xC06E:
- return SetBit7(_video.ReadFloatingBus(), _gamePort.Paddle2Strobe);
-
- case 0xC067: case 0xC06F:
- return SetBit7(_video.ReadFloatingBus(), _gamePort.Paddle3Strobe);
-
- case 0xC070: case 0xC071: case 0xC072: case 0xC073: case 0xC074: case 0xC075: case 0xC076: case 0xC077:
- case 0xC078: case 0xC079: case 0xC07A: case 0xC07B: case 0xC07C: case 0xC07D: case 0xC07E: case 0xC07F:
- _gamePort.TriggerTimers();
- break;
-
- case 0xC080: case 0xC081: case 0xC082: case 0xC083: case 0xC084: case 0xC085: case 0xC086: case 0xC087: // slot0 [5-23]
- case 0xC088: case 0xC089: case 0xC08A: case 0xC08B: case 0xC08C: case 0xC08D: case 0xC08E: case 0xC08F:
- SetHighRam(address, true);
- break;
-
- case 0xC090: case 0xC091: case 0xC092: case 0xC093: case 0xC094: case 0xC095: case 0xC096: case 0xC097: // slot1
- case 0xC098: case 0xC099: case 0xC09A: case 0xC09B: case 0xC09C: case 0xC09D: case 0xC09E: case 0xC09F:
- return Machine.Slot1.ReadIoRegionC0C0(address);
-
- case 0xC0A0: case 0xC0A1: case 0xC0A2: case 0xC0A3: case 0xC0A4: case 0xC0A5: case 0xC0A6: case 0xC0A7: // slot2
- case 0xC0A8: case 0xC0A9: case 0xC0AA: case 0xC0AB: case 0xC0AC: case 0xC0AD: case 0xC0AE: case 0xC0AF:
- return Machine.Slot2.ReadIoRegionC0C0(address);
-
- case 0xC0B0: case 0xC0B1: case 0xC0B2: case 0xC0B3: case 0xC0B4: case 0xC0B5: case 0xC0B6: case 0xC0B7: // slot3
- case 0xC0B8: case 0xC0B9: case 0xC0BA: case 0xC0BB: case 0xC0BC: case 0xC0BD: case 0xC0BE: case 0xC0BF:
- return Machine.Slot3.ReadIoRegionC0C0(address);
-
- case 0xC0C0: case 0xC0C1: case 0xC0C2: case 0xC0C3: case 0xC0C4: case 0xC0C5: case 0xC0C6: case 0xC0C7: // slot4
- case 0xC0C8: case 0xC0C9: case 0xC0CA: case 0xC0CB: case 0xC0CC: case 0xC0CD: case 0xC0CE: case 0xC0CF:
- return Machine.Slot4.ReadIoRegionC0C0(address);
-
- case 0xC0D0: case 0xC0D1: case 0xC0D2: case 0xC0D3: case 0xC0D4: case 0xC0D5: case 0xC0D6: case 0xC0D7: // slot5
- case 0xC0D8: case 0xC0D9: case 0xC0DA: case 0xC0DB: case 0xC0DC: case 0xC0DD: case 0xC0DE: case 0xC0DF:
- return Machine.Slot5.ReadIoRegionC0C0(address);
-
- case 0xC0E0: case 0xC0E1: case 0xC0E2: case 0xC0E3: case 0xC0E4: case 0xC0E5: case 0xC0E6: case 0xC0E7: // slot6
- case 0xC0E8: case 0xC0E9: case 0xC0EA: case 0xC0EB: case 0xC0EC: case 0xC0ED: case 0xC0EE: case 0xC0EF:
- return Machine.Slot6.ReadIoRegionC0C0(address);
-
- case 0xC0F0: case 0xC0F1: case 0xC0F2: case 0xC0F3: case 0xC0F4: case 0xC0F5: case 0xC0F6: case 0xC0F7: // slot7
- case 0xC0F8: case 0xC0F9: case 0xC0FA: case 0xC0FB: case 0xC0FC: case 0xC0FD: case 0xC0FE: case 0xC0FF:
- return Machine.Slot7.ReadIoRegionC0C0(address);
-
- default:
- throw new ArgumentOutOfRangeException("address");
- }
-
- return _video.ReadFloatingBus();
- }
-
- private int ReadIoRegionC1C7(int address)
- {
- _slotRegionC8CF = (address >> 8) & 0x07;
- return IsRomC1CFInternal ? _romInternalRegionC1CF[address - 0xC100] : Machine.Slots[_slotRegionC8CF].ReadIoRegionC1C7(address);
- }
-
- private int ReadIoRegionC3C3(int address)
- {
- _slotRegionC8CF = 3;
- if (!IsRomC3C3External)
- {
- SetRomC8CF(true); // $C3XX sets IntC8Rom; inhibits I/O Strobe' [5-28, 7-21]
- }
- return (IsRomC1CFInternal || !IsRomC3C3External) ? _noSlotClock.Read(address, _romInternalRegionC1CF[address - 0xC100]) : Machine.Slot3.ReadIoRegionC1C7(address);
- }
-
- private int ReadIoRegionC8CF(int address)
- {
- if (address == 0xCFFF)
- {
- SetRomC8CF(false); // $CFFF resets IntC8Rom [5-28, 7-21]
- }
- return (IsRomC1CFInternal || IsRomC8CFInternal) ? _noSlotClock.Read(address, _romInternalRegionC1CF[address - 0xC100]) : Machine.Slots[_slotRegionC8CF].ReadIoRegionC8CF(address);
- }
-
- [SuppressMessage("Microsoft.Usage", "CA2233:OperationsShouldNotOverflow", MessageId = "address-512")]
- public int ReadRamMainRegion02BF(int address)
- {
- return _ramMainRegion02BF[address - 0x0200];
- }
-
- [SuppressMessage("Microsoft.Usage", "CA2233:OperationsShouldNotOverflow", MessageId = "address-512")]
- public int ReadRamAuxRegion02BF(int address)
- {
- return _ramAuxRegion02BF[address - 0x0200];
- }
-
- [SuppressMessage("Microsoft.Usage", "CA2233:OperationsShouldNotOverflow", MessageId = "address-57344")]
- public int ReadRomRegionE0FF(int address)
- {
- return _romRegionE0FF[address - 0xE000];
- }
- #endregion
-
- #region Write Actions
- [SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
- [SuppressMessage("Microsoft.Maintainability", "CA1505:AvoidUnmaintainableCode")]
- private void WriteIoRegionC0C0(int address, byte data)
- {
- switch (address)
- {
- case 0xC000: case 0xC001: // [5-22]
- Set80Store(TestBit(address, 0));
- break;
-
- case 0xC002: case 0xC003:
- SetRamRead(TestBit(address, 0));
- break;
-
- case 0xC004: case 0xC005:
- SetRamWrite(TestBit(address, 0));
- break;
-
- case 0xC006: case 0xC007:
- SetRomC1CF(TestBit(address, 0));
- break;
-
- case 0xC008: case 0xC009:
- SetZeroPage(TestBit(address, 0));
- break;
-
- case 0xC00A: case 0xC00B:
- SetRomC3C3(TestBit(address, 0));
- break;
-
- case 0xC00C: case 0xC00D: // [7-5]
- Set80Columns(TestBit(address, 0));
- break;
-
- case 0xC00E: case 0xC00F:
- SetCharSet(TestBit(address, 0));
- break;
-
- case 0xC010: case 0xC011: case 0xC012: case 0xC013: case 0xC014: case 0xC015: case 0xC016: case 0xC017: // [7-15]
- case 0xC018: case 0xC019: case 0xC01A: case 0xC01B: case 0xC01C: case 0xC01D: case 0xC01E: case 0xC01F:
- _keyboard.ResetStrobe();
- break;
-
- case 0xC020: case 0xC021: case 0xC022: case 0xC023: case 0xC024: case 0xC025: case 0xC026: case 0xC027: // [7-8]
- case 0xC028: case 0xC029: case 0xC02A: case 0xC02B: case 0xC02C: case 0xC02D: case 0xC02E: case 0xC02F:
- _cassette.ToggleOutput();
- break;
-
- case 0xC030: case 0xC031: case 0xC032: case 0xC033: case 0xC034: case 0xC035: case 0xC036: case 0xC037: // [7-9]
- case 0xC038: case 0xC039: case 0xC03A: case 0xC03B: case 0xC03C: case 0xC03D: case 0xC03E: case 0xC03F:
- _speaker.ToggleOutput();
- break;
-
- case 0xC040: case 0xC041: case 0xC042: case 0xC043: case 0xC044: case 0xC045: case 0xC046: case 0xC047: // [2-18]
- case 0xC048: case 0xC049: case 0xC04A: case 0xC04B: case 0xC04C: case 0xC04D: case 0xC04E: case 0xC04F:
- break;
-
- case 0xC050: case 0xC051:
- SetText(TestBit(address, 0));
- break;
-
- case 0xC052: case 0xC053:
- SetMixed(TestBit(address, 0));
- break;
-
- case 0xC054: case 0xC055:
- SetPage2(TestBit(address, 0));
- break;
-
- case 0xC056: case 0xC057:
- SetHires(TestBit(address, 0));
- break;
-
- case 0xC058: case 0xC059:
- SetAnnunciator0(TestBit(address, 0));
- break;
-
- case 0xC05A: case 0xC05B:
- SetAnnunciator1(TestBit(address, 0));
- break;
-
- case 0xC05C: case 0xC05D:
- SetAnnunciator2(TestBit(address, 0));
- break;
-
- case 0xC05E: case 0xC05F:
- SetAnnunciator3(TestBit(address, 0));
- SetDoubleRes(!TestBit(address, 0));
- break;
-
- case 0xC060: case 0xC061: case 0xC062: case 0xC063: case 0xC064: case 0xC065: case 0xC066: case 0xC067: // [2-18, 7-5]
- case 0xC068: case 0xC069: case 0xC06A: case 0xC06B: case 0xC06C: case 0xC06D: case 0xC06E: case 0xC06F:
- break;
-
- case 0xC070: case 0xC071: case 0xC072: case 0xC073: case 0xC074: case 0xC075: case 0xC076: case 0xC077:
- case 0xC078: case 0xC079: case 0xC07A: case 0xC07B: case 0xC07C: case 0xC07D: case 0xC07E: case 0xC07F:
- _gamePort.TriggerTimers();
- break;
-
- case 0xC080: case 0xC081: case 0xC082: case 0xC083: case 0xC084: case 0xC085: case 0xC086: case 0xC087: // slot0 [5-23]
- case 0xC088: case 0xC089: case 0xC08A: case 0xC08B: case 0xC08C: case 0xC08D: case 0xC08E: case 0xC08F:
- SetHighRam(address, false);
- break;
-
- case 0xC090: case 0xC091: case 0xC092: case 0xC093: case 0xC094: case 0xC095: case 0xC096: case 0xC097: // slot1
- case 0xC098: case 0xC099: case 0xC09A: case 0xC09B: case 0xC09C: case 0xC09D: case 0xC09E: case 0xC09F:
- Machine.Slot1.WriteIoRegionC0C0(address, data);
- break;
-
- case 0xC0A0: case 0xC0A1: case 0xC0A2: case 0xC0A3: case 0xC0A4: case 0xC0A5: case 0xC0A6: case 0xC0A7: // slot2
- case 0xC0A8: case 0xC0A9: case 0xC0AA: case 0xC0AB: case 0xC0AC: case 0xC0AD: case 0xC0AE: case 0xC0AF:
- Machine.Slot2.WriteIoRegionC0C0(address, data);
- break;
-
- case 0xC0B0: case 0xC0B1: case 0xC0B2: case 0xC0B3: case 0xC0B4: case 0xC0B5: case 0xC0B6: case 0xC0B7: // slot3
- case 0xC0B8: case 0xC0B9: case 0xC0BA: case 0xC0BB: case 0xC0BC: case 0xC0BD: case 0xC0BE: case 0xC0BF:
- Machine.Slot3.WriteIoRegionC0C0(address, data);
- break;
-
- case 0xC0C0: case 0xC0C1: case 0xC0C2: case 0xC0C3: case 0xC0C4: case 0xC0C5: case 0xC0C6: case 0xC0C7: // slot4
- case 0xC0C8: case 0xC0C9: case 0xC0CA: case 0xC0CB: case 0xC0CC: case 0xC0CD: case 0xC0CE: case 0xC0CF:
- Machine.Slot4.WriteIoRegionC0C0(address, data);
- break;
-
- case 0xC0D0: case 0xC0D1: case 0xC0D2: case 0xC0D3: case 0xC0D4: case 0xC0D5: case 0xC0D6: case 0xC0D7: // slot5
- case 0xC0D8: case 0xC0D9: case 0xC0DA: case 0xC0DB: case 0xC0DC: case 0xC0DD: case 0xC0DE: case 0xC0DF:
- Machine.Slot5.WriteIoRegionC0C0(address, data);
- break;
-
- case 0xC0E0: case 0xC0E1: case 0xC0E2: case 0xC0E3: case 0xC0E4: case 0xC0E5: case 0xC0E6: case 0xC0E7: // slot6
- case 0xC0E8: case 0xC0E9: case 0xC0EA: case 0xC0EB: case 0xC0EC: case 0xC0ED: case 0xC0EE: case 0xC0EF:
- Machine.Slot6.WriteIoRegionC0C0(address, data);
- break;
-
- case 0xC0F0: case 0xC0F1: case 0xC0F2: case 0xC0F3: case 0xC0F4: case 0xC0F5: case 0xC0F6: case 0xC0F7: // slot7
- case 0xC0F8: case 0xC0F9: case 0xC0FA: case 0xC0FB: case 0xC0FC: case 0xC0FD: case 0xC0FE: case 0xC0FF:
- Machine.Slot7.WriteIoRegionC0C0(address, data);
- break;
-
- default:
- throw new ArgumentOutOfRangeException("address");
- }
- }
-
- private void WriteIoRegionC1C7(int address, byte data)
- {
- _slotRegionC8CF = (address >> 8) & 0x07;
- if (!IsRomC1CFInternal)
- {
- Machine.Slots[_slotRegionC8CF].WriteIoRegionC1C7(address, data);
- }
- }
-
- private void WriteIoRegionC3C3(int address, byte data)
- {
- _slotRegionC8CF = 3;
- if (!IsRomC3C3External)
- {
- SetRomC8CF(true); // $C3XX sets IntC8Rom; inhibits I/O Strobe' [5-28, 7-21]
- }
- if (IsRomC1CFInternal || !IsRomC3C3External)
- {
- _noSlotClock.Write(address);
- }
- else
- {
- Machine.Slot3.WriteIoRegionC1C7(address, data);
- }
- }
-
- private void WriteIoRegionC8CF(int address, byte data)
- {
- if (address == 0xCFFF)
- {
- SetRomC8CF(false); // $CFFF resets IntC8Rom [5-28, 7-21]
- }
- if (IsRomC1CFInternal || IsRomC8CFInternal)
- {
- _noSlotClock.Write(address);
- }
- else
- {
- Machine.Slots[_slotRegionC8CF].WriteIoRegionC8CF(address, data);
- }
- }
-
- private void WriteRamMode0MainRegion0407(int address, byte data)
- {
- if (_ramMainRegion02BF[address - 0x0200] != data)
- {
- _ramMainRegion02BF[address - 0x0200] = data;
- _video.DirtyCell(address - 0x0400); // lores page1
- }
- }
-
- private void WriteRamMode0MainRegion080B(int address, byte data)
- {
- if (_ramMainRegion02BF[address - 0x0200] != data)
- {
- _ramMainRegion02BF[address - 0x0200] = data;
- _video.DirtyCell(address - 0x0800); // lores page2
- }
- }
-
- private void WriteRamMode1MainRegion0407(int address, byte data)
- {
- if (_ramMainRegion02BF[address - 0x0200] != data)
- {
- _ramMainRegion02BF[address - 0x0200] = data;
- _video.DirtyCell(address - 0x0400); // text40 page1
- }
- }
-
- private void WriteRamMode1MainRegion080B(int address, byte data)
- {
- if (_ramMainRegion02BF[address - 0x0200] != data)
- {
- _ramMainRegion02BF[address - 0x0200] = data;
- _video.DirtyCell(address - 0x0800); // text40 page2
- }
- }
-
- private void WriteRamMode2MainRegion0407(int address, byte data)
- {
- if (_ramMainRegion02BF[address - 0x0200] != data)
- {
- _ramMainRegion02BF[address - 0x0200] = data;
- _video.DirtyCell(address - 0x0400); // text80 page1
- }
- }
-
- private void WriteRamMode2MainRegion080B(int address, byte data)
- {
- if (_ramMainRegion02BF[address - 0x0200] != data)
- {
- _ramMainRegion02BF[address - 0x0200] = data;
- _video.DirtyCell(address - 0x0800); // text80 page2
- }
- }
-
- private void WriteRamMode2AuxRegion0407(int address, byte data)
- {
- if (_ramAuxRegion02BF[address - 0x0200] != data)
- {
- _ramAuxRegion02BF[address - 0x0200] = data;
- _video.DirtyCell(address - 0x0400); // text80 page1
- }
- }
-
- private void WriteRamMode2AuxRegion080B(int address, byte data)
- {
- if (_ramAuxRegion02BF[address - 0x0200] != data)
- {
- _ramAuxRegion02BF[address - 0x0200] = data;
- _video.DirtyCell(address - 0x0800); // text80 page2
- }
- }
-
- private void WriteRamMode3MainRegion0407(int address, byte data)
- {
- if (_ramMainRegion02BF[address - 0x0200] != data)
- {
- _ramMainRegion02BF[address - 0x0200] = data;
- _video.DirtyCell(address - 0x0400); // lores & text40 page1
- }
- }
-
- private void WriteRamMode3MainRegion080B(int address, byte data)
- {
- if (_ramMainRegion02BF[address - 0x0200] != data)
- {
- _ramMainRegion02BF[address - 0x0200] = data;
- _video.DirtyCell(address - 0x0800); // lores & text40 page2
- }
- }
-
- private void WriteRamMode4MainRegion0407(int address, byte data)
- {
- if (_ramMainRegion02BF[address - 0x0200] != data)
- {
- _ramMainRegion02BF[address - 0x0200] = data;
- _video.DirtyCell(address - 0x0400); // lores & text80 page1
- }
- }
-
- private void WriteRamMode4MainRegion080B(int address, byte data)
- {
- if (_ramMainRegion02BF[address - 0x0200] != data)
- {
- _ramMainRegion02BF[address - 0x0200] = data;
- _video.DirtyCell(address - 0x0800); // lores & text80 page2
- }
- }
-
- private void WriteRamMode4AuxRegion0407(int address, byte data)
- {
- if (_ramAuxRegion02BF[address - 0x0200] != data)
- {
- _ramAuxRegion02BF[address - 0x0200] = data;
- _video.DirtyCellMixedText(address - 0x0400); // [lores &] text80 page1
- }
- }
-
- private void WriteRamMode4AuxRegion080B(int address, byte data)
- {
- if (_ramAuxRegion02BF[address - 0x0200] != data)
- {
- _ramAuxRegion02BF[address - 0x0200] = data;
- _video.DirtyCellMixedText(address - 0x0800); // [lores &] text80 page2
- }
- }
-
- private void WriteRamMode5MainRegion203F(int address, byte data)
- {
- if (_ramMainRegion02BF[address - 0x0200] != data)
- {
- _ramMainRegion02BF[address - 0x0200] = data;
- _video.DirtyCell(address - 0x2000); // hires page1
- }
- }
-
- private void WriteRamMode5MainRegion405F(int address, byte data)
- {
- if (_ramMainRegion02BF[address - 0x0200] != data)
- {
- _ramMainRegion02BF[address - 0x0200] = data;
- _video.DirtyCell(address - 0x4000); // hires page2
- }
- }
-
- private void WriteRamMode6MainRegion0407(int address, byte data)
- {
- if (_ramMainRegion02BF[address - 0x0200] != data)
- {
- _ramMainRegion02BF[address - 0x0200] = data;
- _video.DirtyCellMixedText(address - 0x0400); // [hires &] text40 page1
- }
- }
-
- private void WriteRamMode6MainRegion080B(int address, byte data)
- {
- if (_ramMainRegion02BF[address - 0x0200] != data)
- {
- _ramMainRegion02BF[address - 0x0200] = data;
- _video.DirtyCellMixedText(address - 0x0800); // [hires &] text40 page2
- }
- }
-
- private void WriteRamMode6MainRegion203F(int address, byte data)
- {
- if (_ramMainRegion02BF[address - 0x0200] != data)
- {
- _ramMainRegion02BF[address - 0x0200] = data;
- _video.DirtyCellMixed(address - 0x2000); // hires [& text40] page1
- }
- }
-
- private void WriteRamMode6MainRegion405F(int address, byte data)
- {
- if (_ramMainRegion02BF[address - 0x0200] != data)
- {
- _ramMainRegion02BF[address - 0x0200] = data;
- _video.DirtyCellMixed(address - 0x4000); // hires [& text40] page2
- }
- }
-
- private void WriteRamMode7MainRegion0407(int address, byte data)
- {
- if (_ramMainRegion02BF[address - 0x0200] != data)
- {
- _ramMainRegion02BF[address - 0x0200] = data;
- _video.DirtyCellMixedText(address - 0x0400); // [hires &] text80 page1
- }
- }
-
- private void WriteRamMode7MainRegion080B(int address, byte data)
- {
- if (_ramMainRegion02BF[address - 0x0200] != data)
- {
- _ramMainRegion02BF[address - 0x0200] = data;
- _video.DirtyCellMixedText(address - 0x0800); // [hires &] text80 page2
- }
- }
-
- private void WriteRamMode7MainRegion203F(int address, byte data)
- {
- if (_ramMainRegion02BF[address - 0x0200] != data)
- {
- _ramMainRegion02BF[address - 0x0200] = data;
- _video.DirtyCellMixed(address - 0x2000); // hires [& text80] page1
- }
- }
-
- private void WriteRamMode7MainRegion405F(int address, byte data)
- {
- if (_ramMainRegion02BF[address - 0x0200] != data)
- {
- _ramMainRegion02BF[address - 0x0200] = data;
- _video.DirtyCellMixed(address - 0x4000); // hires [& text80] page2
- }
- }
-
- private void WriteRamMode7AuxRegion0407(int address, byte data)
- {
- if (_ramAuxRegion02BF[address - 0x0200] != data)
- {
- _ramAuxRegion02BF[address - 0x0200] = data;
- _video.DirtyCellMixedText(address - 0x0400); // [hires &] text80 page1
- }
- }
-
- private void WriteRamMode7AuxRegion080B(int address, byte data)
- {
- if (_ramAuxRegion02BF[address - 0x0200] != data)
- {
- _ramAuxRegion02BF[address - 0x0200] = data;
- _video.DirtyCellMixedText(address - 0x0800); // [hires &] text80 page2
- }
- }
-
- private void WriteRamMode8MainRegion0407(int address, byte data)
- {
- if (_ramMainRegion02BF[address - 0x0200] != data)
- {
- _ramMainRegion02BF[address - 0x0200] = data;
- _video.DirtyCell(address - 0x0400); // 7mlores page1
- }
- }
-
- private void WriteRamMode8MainRegion080B(int address, byte data)
- {
- if (_ramMainRegion02BF[address - 0x0200] != data)
- {
- _ramMainRegion02BF[address - 0x0200] = data;
- _video.DirtyCell(address - 0x0800); // 7mlores page2
- }
- }
-
- private void WriteRamMode9MainRegion0407(int address, byte data)
- {
- if (_ramMainRegion02BF[address - 0x0200] != data)
- {
- _ramMainRegion02BF[address - 0x0200] = data;
- _video.DirtyCell(address - 0x0400); // dlores page1
- }
- }
-
- private void WriteRamMode9MainRegion080B(int address, byte data)
- {
- if (_ramMainRegion02BF[address - 0x0200] != data)
- {
- _ramMainRegion02BF[address - 0x0200] = data;
- _video.DirtyCell(address - 0x0800); // dlores page2
- }
- }
-
- private void WriteRamMode9AuxRegion0407(int address, byte data)
- {
- if (_ramAuxRegion02BF[address - 0x0200] != data)
- {
- _ramAuxRegion02BF[address - 0x0200] = data;
- _video.DirtyCell(address - 0x0400); // dlores page1
- }
- }
-
- private void WriteRamMode9AuxRegion080B(int address, byte data)
- {
- if (_ramAuxRegion02BF[address - 0x0200] != data)
- {
- _ramAuxRegion02BF[address - 0x0200] = data;
- _video.DirtyCell(address - 0x0800); // dlores page2
- }
- }
-
- private void WriteRamModeAMainRegion0407(int address, byte data)
- {
- if (_ramMainRegion02BF[address - 0x0200] != data)
- {
- _ramMainRegion02BF[address - 0x0200] = data;
- _video.DirtyCell(address - 0x0400); // 7mlores & text40 page1
- }
- }
-
- private void WriteRamModeAMainRegion080B(int address, byte data)
- {
- if (_ramMainRegion02BF[address - 0x0200] != data)
- {
- _ramMainRegion02BF[address - 0x0200] = data;
- _video.DirtyCell(address - 0x0800); // 7mlores & text40 page2
- }
- }
-
- private void WriteRamModeBMainRegion0407(int address, byte data)
- {
- if (_ramMainRegion02BF[address - 0x0200] != data)
- {
- _ramMainRegion02BF[address - 0x0200] = data;
- _video.DirtyCell(address - 0x0400); // dlores & text80 page1
- }
- }
-
- private void WriteRamModeBMainRegion080B(int address, byte data)
- {
- if (_ramMainRegion02BF[address - 0x0200] != data)
- {
- _ramMainRegion02BF[address - 0x0200] = data;
- _video.DirtyCell(address - 0x0800); // dlores & text80 page2
- }
- }
-
- private void WriteRamModeBAuxRegion0407(int address, byte data)
- {
- if (_ramAuxRegion02BF[address - 0x0200] != data)
- {
- _ramAuxRegion02BF[address - 0x0200] = data;
- _video.DirtyCell(address - 0x0400); // dlores & text80 page1
- }
- }
-
- private void WriteRamModeBAuxRegion080B(int address, byte data)
- {
- if (_ramAuxRegion02BF[address - 0x0200] != data)
- {
- _ramAuxRegion02BF[address - 0x0200] = data;
- _video.DirtyCell(address - 0x0800); // dlores & text80 page2
- }
- }
-
- private void WriteRamModeCMainRegion203F(int address, byte data)
- {
- if (_ramMainRegion02BF[address - 0x0200] != data)
- {
- _ramMainRegion02BF[address - 0x0200] = data;
- _video.DirtyCell(address - 0x2000); // ndhires page1
- }
- }
-
- private void WriteRamModeCMainRegion405F(int address, byte data)
- {
- if (_ramMainRegion02BF[address - 0x0200] != data)
- {
- _ramMainRegion02BF[address - 0x0200] = data;
- _video.DirtyCell(address - 0x4000); // ndhires page2
- }
- }
-
- private void WriteRamModeDMainRegion203F(int address, byte data)
- {
- if (_ramMainRegion02BF[address - 0x0200] != data)
- {
- _ramMainRegion02BF[address - 0x0200] = data;
- _video.DirtyCell(address - 0x2000); // dhires page1
- }
- }
-
- private void WriteRamModeDMainRegion405F(int address, byte data)
- {
- if (_ramMainRegion02BF[address - 0x0200] != data)
- {
- _ramMainRegion02BF[address - 0x0200] = data;
- _video.DirtyCell(address - 0x4000); // dhires page2
- }
- }
-
- private void WriteRamModeDAuxRegion203F(int address, byte data)
- {
- if (_ramAuxRegion02BF[address - 0x0200] != data)
- {
- _ramAuxRegion02BF[address - 0x0200] = data;
- _video.DirtyCell(address - 0x2000); // dhires page1
- }
- }
-
- private void WriteRamModeDAuxRegion405F(int address, byte data)
- {
- if (_ramAuxRegion02BF[address - 0x0200] != data)
- {
- _ramAuxRegion02BF[address - 0x0200] = data;
- _video.DirtyCell(address - 0x4000); // dhires page2
- }
- }
-
- private void WriteRamModeEMainRegion0407(int address, byte data)
- {
- if (_ramMainRegion02BF[address - 0x0200] != data)
- {
- _ramMainRegion02BF[address - 0x0200] = data;
- _video.DirtyCellMixedText(address - 0x0400); // [ndhires &] text40 page1
- }
- }
-
- private void WriteRamModeEMainRegion080B(int address, byte data)
- {
- if (_ramMainRegion02BF[address - 0x0200] != data)
- {
- _ramMainRegion02BF[address - 0x0200] = data;
- _video.DirtyCellMixedText(address - 0x0800); // [ndhires &] text40 page2
- }
- }
-
- private void WriteRamModeEMainRegion203F(int address, byte data)
- {
- if (_ramMainRegion02BF[address - 0x0200] != data)
- {
- _ramMainRegion02BF[address - 0x0200] = data;
- _video.DirtyCellMixed(address - 0x2000); // ndhires [& text40] page1
- }
- }
-
- private void WriteRamModeEMainRegion405F(int address, byte data)
- {
- if (_ramMainRegion02BF[address - 0x0200] != data)
- {
- _ramMainRegion02BF[address - 0x0200] = data;
- _video.DirtyCellMixed(address - 0x4000); // ndhires [& text40] page2
- }
- }
-
- private void WriteRamModeFMainRegion0407(int address, byte data)
- {
- if (_ramMainRegion02BF[address - 0x0200] != data)
- {
- _ramMainRegion02BF[address - 0x0200] = data;
- _video.DirtyCellMixedText(address - 0x0400); // [dhires &] text80 page1
- }
- }
-
- private void WriteRamModeFMainRegion080B(int address, byte data)
- {
- if (_ramMainRegion02BF[address - 0x0200] != data)
- {
- _ramMainRegion02BF[address - 0x0200] = data;
- _video.DirtyCellMixedText(address - 0x0800); // [dhires &] text80 page2
- }
- }
-
- private void WriteRamModeFMainRegion203F(int address, byte data)
- {
- if (_ramMainRegion02BF[address - 0x0200] != data)
- {
- _ramMainRegion02BF[address - 0x0200] = data;
- _video.DirtyCellMixed(address - 0x2000); // dhires [& text80] page1
- }
- }
-
- private void WriteRamModeFMainRegion405F(int address, byte data)
- {
- if (_ramMainRegion02BF[address - 0x0200] != data)
- {
- _ramMainRegion02BF[address - 0x0200] = data;
- _video.DirtyCellMixed(address - 0x4000); // dhires [& text80] page2
- }
- }
-
- private void WriteRamModeFAuxRegion0407(int address, byte data)
- {
- if (_ramAuxRegion02BF[address - 0x0200] != data)
- {
- _ramAuxRegion02BF[address - 0x0200] = data;
- _video.DirtyCellMixedText(address - 0x0400); // [dhires &] text80 page1
- }
- }
-
- private void WriteRamModeFAuxRegion080B(int address, byte data)
- {
- if (_ramAuxRegion02BF[address - 0x0200] != data)
- {
- _ramAuxRegion02BF[address - 0x0200] = data;
- _video.DirtyCellMixedText(address - 0x0800); // [dhires &] text80 page2
- }
- }
-
- private void WriteRamModeFAuxRegion203F(int address, byte data)
- {
- if (_ramAuxRegion02BF[address - 0x0200] != data)
- {
- _ramAuxRegion02BF[address - 0x0200] = data;
- _video.DirtyCellMixed(address - 0x2000); // dhires [& text80] page1
- }
- }
-
- private void WriteRamModeFAuxRegion405F(int address, byte data)
- {
- if (_ramAuxRegion02BF[address - 0x0200] != data)
- {
- _ramAuxRegion02BF[address - 0x0200] = data;
- _video.DirtyCellMixed(address - 0x4000); // dhires [& text80] page2
- }
- }
-
- private void WriteRomRegionD0FF(int address, byte data)
- {
- }
- #endregion
-
- #region Softswitch Actions
- private void MapRegion0001()
- {
- if (!IsZeroPageAux)
- {
- _regionRead[Region0001] = _ramMainRegion0001;
- _regionWrite[Region0001] = _ramMainRegion0001;
- _zeroPage = _ramMainRegion0001;
- }
- else
- {
- _regionRead[Region0001] = _ramAuxRegion0001;
- _regionWrite[Region0001] = _ramAuxRegion0001;
- _zeroPage = _ramAuxRegion0001;
- }
- _writeRegion[Region0001] = null;
- }
-
- private void MapRegion02BF()
- {
- if (!IsRamReadAux)
- {
- _regionRead[Region02BF] = _ramMainRegion02BF;
- _regionRead[Region080B] = _ramMainRegion02BF;
- _regionRead[Region405F] = _ramMainRegion02BF;
- }
- else
- {
- _regionRead[Region02BF] = _ramAuxRegion02BF;
- _regionRead[Region080B] = _ramAuxRegion02BF;
- _regionRead[Region405F] = _ramAuxRegion02BF;
- }
- int mode = VideoMode;
- if (!IsRamWriteAux)
- {
- _regionWrite[Region02BF] = _ramMainRegion02BF;
- _regionWrite[Region080B] = _ramMainRegion02BF;
- _regionWrite[Region405F] = _ramMainRegion02BF;
- _writeRegion[Region02BF] = null;
- _writeRegion[Region080B] = WriteRamModeBankRegion[mode][BankMain][Region080B];
- _writeRegion[Region405F] = WriteRamModeBankRegion[mode][BankMain][Region405F];
- }
- else
- {
- _regionWrite[Region02BF] = _ramAuxRegion02BF;
- _regionWrite[Region080B] = _ramAuxRegion02BF;
- _regionWrite[Region405F] = _ramAuxRegion02BF;
- _writeRegion[Region02BF] = null;
- _writeRegion[Region080B] = WriteRamModeBankRegion[mode][BankAux][Region080B];
- _writeRegion[Region405F] = WriteRamModeBankRegion[mode][BankAux][Region405F];
- }
- MapRegion0407();
- MapRegion203F();
- }
-
- private void MapRegion0407()
- {
- if (!IsRamReadAuxRegion0407)
- {
- _regionRead[Region0407] = _ramMainRegion02BF;
- }
- else
- {
- _regionRead[Region0407] = _ramAuxRegion02BF;
- }
- int mode = VideoMode;
- if (!IsRamWriteAuxRegion0407)
- {
- _regionWrite[Region0407] = _ramMainRegion02BF;
- _writeRegion[Region0407] = WriteRamModeBankRegion[mode][BankMain][Region0407];
- }
- else
- {
- _regionWrite[Region0407] = _ramAuxRegion02BF;
- _writeRegion[Region0407] = WriteRamModeBankRegion[mode][BankAux][Region0407];
- }
- }
-
- private void MapRegion203F()
- {
- if (!IsRamReadAuxRegion203F)
- {
- _regionRead[Region203F] = _ramMainRegion02BF;
- }
- else
- {
- _regionRead[Region203F] = _ramAuxRegion02BF;
- }
- int mode = VideoMode;
- if (!IsRamWriteAuxRegion203F)
- {
- _regionWrite[Region203F] = _ramMainRegion02BF;
- _writeRegion[Region203F] = WriteRamModeBankRegion[mode][BankMain][Region203F];
- }
- else
- {
- _regionWrite[Region203F] = _ramAuxRegion02BF;
- _writeRegion[Region203F] = WriteRamModeBankRegion[mode][BankAux][Region203F];
- }
- }
-
- private void MapRegionC0CF()
- {
- _regionRead[RegionC0C0] = null;
- if (IsRomC1CFInternal)
- {
- _regionRead[RegionC1C7] = _romInternalRegionC1CF;
- _regionRead[RegionC3C3] = _romInternalRegionC1CF;
- _regionRead[RegionC8CF] = _romInternalRegionC1CF;
- }
- else
- {
- _regionRead[RegionC1C7] = _romExternalRegionC1CF;
- _regionRead[RegionC3C3] = IsRomC3C3External ? _romExternalRegionC1CF : _romInternalRegionC1CF;
- _regionRead[RegionC8CF] = !IsRomC8CFInternal ? _romExternalRegionC1CF : _romInternalRegionC1CF;
- }
- _regionWrite[RegionC0C0] = null;
- _regionWrite[RegionC1C7] = null;
- _regionWrite[RegionC3C3] = null;
- _regionWrite[RegionC8CF] = null;
- _writeRegion[RegionC0C0] = _writeIoRegionC0C0;
- _writeRegion[RegionC1C7] = _writeIoRegionC1C7;
- _writeRegion[RegionC3C3] = _writeIoRegionC3C3;
- _writeRegion[RegionC8CF] = _writeIoRegionC8CF;
- }
-
- private void MapRegionD0FF()
- {
- if (IsHighRamRead)
- {
- if (!IsHighRamAux)
- {
- _regionRead[RegionD0DF] = IsHighRamBank1 ? _ramMainBank1RegionD0DF : _ramMainBank2RegionD0DF;
- _regionRead[RegionE0FF] = _ramMainRegionE0FF;
- }
- else
- {
- _regionRead[RegionD0DF] = IsHighRamBank1 ? _ramAuxBank1RegionD0DF : _ramAuxBank2RegionD0DF;
- _regionRead[RegionE0FF] = _ramAuxRegionE0FF;
- }
- }
- else
- {
- _regionRead[RegionD0DF] = _romRegionD0DF;
- _regionRead[RegionE0FF] = _romRegionE0FF;
- }
- if (IsHighRamWrite)
- {
- if (!IsHighRamAux)
- {
- _regionWrite[RegionD0DF] = IsHighRamBank1 ? _ramMainBank1RegionD0DF : _ramMainBank2RegionD0DF;
- _regionWrite[RegionE0FF] = _ramMainRegionE0FF;
- }
- else
- {
- _regionWrite[RegionD0DF] = IsHighRamBank1 ? _ramAuxBank1RegionD0DF : _ramAuxBank2RegionD0DF;
- _regionWrite[RegionE0FF] = _ramAuxRegionE0FF;
- }
- _writeRegion[RegionD0DF] = null;
- _writeRegion[RegionE0FF] = null;
- }
- else
- {
- _regionWrite[RegionD0DF] = null;
- _regionWrite[RegionE0FF] = null;
- _writeRegion[RegionD0DF] = _writeRomRegionD0FF;
- _writeRegion[RegionE0FF] = _writeRomRegionD0FF;
- }
- }
-
- private void Set80Columns(bool value)
- {
- if (!TestState(State80Col, value))
- {
- SetState(State80Col, value);
- MapRegion02BF();
- _video.DirtyScreen();
- }
- }
-
- private void Set80Store(bool value)
- {
- if (!TestState(State80Store, value))
- {
- SetState(State80Store, value);
- if (IsPage2) // [5-7, 8-19]
- {
- MapRegion02BF();
- _video.DirtyScreen();
- }
- else
- {
- MapRegion0407();
- MapRegion203F();
- }
- }
- }
-
- private void SetAnnunciator0(bool value)
- {
- SetState(StateAn0, value);
- }
-
- private void SetAnnunciator1(bool value)
- {
- SetState(StateAn1, value);
- }
-
- private void SetAnnunciator2(bool value)
- {
- SetState(StateAn2, value);
- }
-
- private void SetAnnunciator3(bool value)
- {
- SetState(StateAn3, value);
- }
-
- private void SetCharSet(bool value)
- {
- if (!TestState(StateAltChrSet, value))
- {
- SetState(StateAltChrSet, value);
- _video.SetCharSet();
- }
- }
-
- private void SetDoubleRes(bool value)
- {
- if (!TestState(StateDRes, value))
- {
- SetState(StateDRes, value);
- MapRegion02BF();
- _video.DirtyScreen();
- }
- }
-
- private void SetHighRam(int address, bool isRead)
- {
- SetState(StateBank1, TestBit(address, 3)); // A3 [5-22]
- SetState(StateHRamRd, TestMask(address, 0x3, 0x3) || TestMask(address, 0x3, 0x0)); // A0.A1+A0'.A1' [5-23] (5-22 misprint)
- if (TestBit(address, 0)) // A0 [5-23]
- {
- if (isRead && TestState(StateHRamPreWrt))
- {
- ResetState(StateHRamWrt); // HRamWrt' [5-23]
- }
- }
- else
- {
- SetState(StateHRamWrt);
- }
- SetState(StateHRamPreWrt, isRead && TestBit(address, 0)); // A0.R/W' [5-22]
- MapRegionD0FF();
- }
-
- private void SetHires(bool value)
- {
- if (!TestState(StateHires, value))
- {
- SetState(StateHires, value);
- if (!Is80Store) // [5-7, 8-19]
- {
- MapRegion02BF();
- _video.DirtyScreen();
- }
- else
- {
- MapRegion203F();
- }
- }
- }
-
- private void SetMixed(bool value)
- {
- if (!TestState(StateMixed, value))
- {
- SetState(StateMixed, value);
- MapRegion02BF();
- _video.DirtyScreen();
- }
- }
-
- private void SetPage2(bool value)
- {
- if (!TestState(StatePage2, value))
- {
- SetState(StatePage2, value);
- if (!Is80Store) // [5-7, 8-19]
- {
- MapRegion02BF();
- _video.DirtyScreen();
- }
- else
- {
- MapRegion0407();
- MapRegion203F();
- }
- }
- }
-
- private void SetRamRead(bool value)
- {
- if (!TestState(StateRamRd, value))
- {
- SetState(StateRamRd, value);
- MapRegion02BF();
- }
- }
-
- private void SetRamWrite(bool value)
- {
- if (!TestState(StateRamWrt, value))
- {
- SetState(StateRamWrt, value);
- MapRegion02BF();
- }
- }
-
- private void SetRomC1CF(bool value)
- {
- if (!TestState(StateIntCXRom, value))
- {
- SetState(StateIntCXRom, value);
- MapRegionC0CF();
- }
- }
-
- private void SetRomC3C3(bool value)
- {
- if (!TestState(StateSlotC3Rom, value))
- {
- SetState(StateSlotC3Rom, value);
- MapRegionC0CF();
- }
- }
-
- private void SetRomC8CF(bool value)
- {
- if (!TestState(StateIntC8Rom, value))
- {
- SetState(StateIntC8Rom, value);
- MapRegionC0CF();
- }
- }
-
- private void SetText(bool value)
- {
- if (!TestState(StateText, value))
- {
- SetState(StateText, value);
- MapRegion02BF();
- _video.DirtyScreen();
- }
- }
-
- private void SetZeroPage(bool value)
- {
- if (!TestState(StateAltZP, value))
- {
- SetState(StateAltZP, value);
- MapRegion0001();
- MapRegionD0FF();
- }
- }
- #endregion
-
- private void Load(Stream stream, int startAddress)
- {
- DebugService.WriteMessage("Loading memory ${0:X04}", startAddress);
- int address = startAddress;
- if (address < 0x0200)
- {
- address += stream.ReadBlock(_ramMainRegion0001, address, minCount: 0);
- }
- if ((0x0200 <= address) && (address < 0xC000))
- {
- address += stream.ReadBlock(_ramMainRegion02BF, address - 0x0200, minCount: 0);
- }
- if ((0xC000 <= address) && (address < 0xD000))
- {
- address += stream.ReadBlock(_ramMainBank1RegionD0DF, address - 0xC000, minCount: 0);
- }
- if ((0xD000 <= address) && (address < 0xE000))
- {
- address += stream.ReadBlock(_ramMainBank2RegionD0DF, address - 0xD000, minCount: 0);
- }
- if (0xE000 <= address)
- {
- address += stream.ReadBlock(_ramMainRegionE0FF, address - 0xE000, minCount: 0);
- }
- if (address > startAddress)
- {
- DebugService.WriteMessage("Loaded memory ${0:X04}-${1:X04} (${2:X04})", startAddress, address - 1, address - startAddress);
- }
- }
-
- private void Load(Stream stream, int startAddress, int length)
- {
- DebugService.WriteMessage("Loading memory ${0:X04}-${1:X04} (${2:X04})", startAddress, startAddress + length - 1, length);
- int address = startAddress;
- if (address < 0x0200)
- {
- address += stream.ReadBlock(_ramMainRegion0001, address, ref length);
- }
- if ((0x0200 <= address) && (address < 0xC000))
- {
- address += stream.ReadBlock(_ramMainRegion02BF, address - 0x0200, ref length);
- }
- if ((0xC000 <= address) && (address < 0xD000))
- {
- address += stream.ReadBlock(_ramMainBank1RegionD0DF, address - 0xC000, ref length);
- }
- if ((0xD000 <= address) && (address < 0xE000))
- {
- address += stream.ReadBlock(_ramMainBank2RegionD0DF, address - 0xD000, ref length);
- }
- if (0xE000 <= address)
- {
- address += stream.ReadBlock(_ramMainRegionE0FF, address - 0xE000, ref length);
- }
- }
-
- private void SetWarmEntry(int address)
- {
- _ramMainRegion02BF[0x03F2 - 0x0200] = (byte)(address & 0xFF);
- _ramMainRegion02BF[0x03F3 - 0x0200] = (byte)(address >> 8);
- _ramMainRegion02BF[0x03F4 - 0x0200] = (byte)((address >> 8) ^ 0xA5);
- }
-
- private static int SetBit7(int data, bool value)
- {
- return value ? (data | 0x80) : (data & 0x7F);
- }
-
- private static bool TestBit(int data, int bit)
- {
- return ((data & (0x1 << bit)) != 0x0);
- }
-
- private static bool TestMask(int data, int mask, int value)
- {
- return ((data & mask) == value);
- }
-
- private void ResetState(int mask)
- {
- _state &= ~mask;
- }
-
- private void SetState(int mask)
- {
- _state |= mask;
- }
-
- private void SetState(int mask, bool value)
- {
- if (value)
- {
- _state |= mask;
- }
- else
- {
- _state &= ~mask;
- }
- }
-
- private bool TestState(int mask)
- {
- return ((_state & mask) != 0x0);
- }
-
- private bool TestState(int mask, bool value)
- {
- return (((_state & mask) != 0x0) == value);
- }
-
- private bool TestState(int mask, int value)
- {
- return ((_state & mask) == value);
- }
-
- public bool Is80Columns { get { return TestState(State80Col); } }
- public bool Is80Store { get { return TestState(State80Store); } }
- public bool IsAnnunciator0 { get { return TestState(StateAn0); } }
- public bool IsAnnunciator1 { get { return TestState(StateAn1); } }
- public bool IsAnnunciator2 { get { return TestState(StateAn2); } }
- public bool IsAnnunciator3 { get { return TestState(StateAn3); } }
- public bool IsCharSetAlternate { get { return TestState(StateAltChrSet); } }
- public bool IsDoubleRes { get { return TestState(StateDRes); } }
- public bool IsHighRamAux { get { return IsZeroPageAux; } }
- public bool IsHighRamBank1 { get { return TestState(StateBank1); } }
- public bool IsHighRamRead { get { return TestState(StateHRamRd); } }
- public bool IsHighRamWrite { get { return !TestState(StateHRamWrt); } } // HRamWrt' [5-23]
- public bool IsHires { get { return TestState(StateHires); } }
- public bool IsMixed { get { return TestState(StateMixed); } }
- public bool IsPage2 { get { return TestState(StatePage2); } }
- public bool IsRamReadAux { get { return TestState(StateRamRd); } }
- public bool IsRamReadAuxRegion0407 { get { return Is80Store ? IsPage2 : IsRamReadAux; } }
- public bool IsRamReadAuxRegion203F { get { return TestState(State80Store | StateHires, State80Store | StateHires) ? IsPage2 : IsRamReadAux; } }
- public bool IsRamWriteAux { get { return TestState(StateRamWrt); } }
- public bool IsRamWriteAuxRegion0407 { get { return Is80Store ? IsPage2 : IsRamWriteAux; } }
- public bool IsRamWriteAuxRegion203F { get { return TestState(State80Store | StateHires, State80Store | StateHires) ? IsPage2 : IsRamWriteAux; } }
- public bool IsRomC1CFInternal { get { return TestState(StateIntCXRom); } }
- public bool IsRomC3C3External { get { return TestState(StateSlotC3Rom); } }
- public bool IsRomC8CFInternal { get { return TestState(StateIntC8Rom); } }
- public bool IsText { get { return TestState(StateText); } }
- public bool IsVideoPage2 { get { return TestState(State80Store | StatePage2, StatePage2); } } // 80Store inhibits video Page2 [5-7, 8-19]
- public bool IsZeroPageAux { get { return TestState(StateAltZP); } }
-
- public MonitorType Monitor { get; private set; }
- public int VideoMode { get { return StateVideoMode[_state & StateVideo]; } }
-
- private Action _writeIoRegionC0C0;
- private Action _writeIoRegionC1C7;
- private Action _writeIoRegionC3C3;
- private Action _writeIoRegionC8CF;
- private Action _writeRomRegionD0FF;
-
- private Keyboard _keyboard;
- private GamePort _gamePort;
- private Cassette _cassette;
- private Speaker _speaker;
- private Video _video;
- private NoSlotClock _noSlotClock;
-
- private int _state;
- private int _slotRegionC8CF;
-
- private byte[] _zeroPage;
- private byte[][] _regionRead = new byte[RegionCount][];
- private byte[][] _regionWrite = new byte[RegionCount][];
- private Action[] _writeRegion = new Action[RegionCount];
-
- private byte[] _ramMainRegion0001 = new byte[0x0200];
- private byte[] _ramMainRegion02BF = new byte[0xBE00];
- private byte[] _ramMainBank1RegionD0DF = new byte[0x1000];
- private byte[] _ramMainBank2RegionD0DF = new byte[0x1000];
- private byte[] _ramMainRegionE0FF = new byte[0x2000];
- private byte[] _ramAuxRegion0001 = new byte[0x0200];
- private byte[] _ramAuxRegion02BF = new byte[0xBE00];
- private byte[] _ramAuxBank1RegionD0DF = new byte[0x1000];
- private byte[] _ramAuxBank2RegionD0DF = new byte[0x1000];
- private byte[] _ramAuxRegionE0FF = new byte[0x2000];
-
- private byte[] _romExternalRegionC1CF = new byte[0x0F00];
- private byte[] _romInternalRegionC1CF = new byte[0x0F00];
- private byte[] _romRegionD0DF = new byte[0x1000];
- private byte[] _romRegionE0FF = new byte[0x2000];
- }
-}
diff --git a/BizHawk.Emulation.Cores/Computers/AppleII/Virtu/Services/GamePortService.cs b/BizHawk.Emulation.Cores/Computers/AppleII/Virtu/Services/GamePortService.cs
deleted file mode 100644
index 0972680ba41..00000000000
--- a/BizHawk.Emulation.Cores/Computers/AppleII/Virtu/Services/GamePortService.cs
+++ /dev/null
@@ -1,333 +0,0 @@
-using System;
-
-namespace Jellyfish.Virtu.Services
-{
- public class GamePortService : MachineService
- {
- public GamePortService(Machine machine) :
- base(machine)
- {
- Paddle0 = Paddle1 = Paddle2 = Paddle3 = 255; // not connected
- }
-
- public virtual void Update() // main thread
- {
- var keyboard = Machine.Keyboard;
-
- if (keyboard.UseGamePort)
- {
- //UpdateKey(keyboard.Joystick0UpKey, IsJoystick0Up, ref _isJoystick0UpKeyDown, ref _wasJoystick0UpKeyDown);
- //UpdateKey(keyboard.Joystick0LeftKey, IsJoystick0Left, ref _isJoystick0LeftKeyDown, ref _wasJoystick0LeftKeyDown);
- //UpdateKey(keyboard.Joystick0RightKey, IsJoystick0Right, ref _isJoystick0RightKeyDown, ref _wasJoystick0RightKeyDown);
- //UpdateKey(keyboard.Joystick0DownKey, IsJoystick0Down, ref _isJoystick0DownKeyDown, ref _wasJoystick0DownKeyDown);
- //UpdateKey(keyboard.Joystick0UpLeftKey, IsJoystick0Up && IsJoystick0Left, ref _isJoystick0UpLeftKeyDown, ref _wasJoystick0UpLeftKeyDown);
- //UpdateKey(keyboard.Joystick0UpRightKey, IsJoystick0Up && IsJoystick0Right, ref _isJoystick0UpRightKeyDown, ref _wasJoystick0UpRightKeyDown);
- //UpdateKey(keyboard.Joystick0DownLeftKey, IsJoystick0Down && IsJoystick0Left, ref _isJoystick0DownLeftKeyDown, ref _wasJoystick0DownLeftKeyDown);
- //UpdateKey(keyboard.Joystick0DownRightKey, IsJoystick0Down && IsJoystick0Right, ref _isJoystick0DownRightKeyDown, ref _wasJoystick0DownRightKeyDown);
- //UpdateKey(keyboard.Joystick1UpKey, IsJoystick1Up, ref _isJoystick1UpKeyDown, ref _wasJoystick1UpKeyDown);
- //UpdateKey(keyboard.Joystick1LeftKey, IsJoystick1Left, ref _isJoystick1LeftKeyDown, ref _wasJoystick1LeftKeyDown);
- //UpdateKey(keyboard.Joystick1RightKey, IsJoystick1Right, ref _isJoystick1RightKeyDown, ref _wasJoystick1RightKeyDown);
- //UpdateKey(keyboard.Joystick1DownKey, IsJoystick1Down, ref _isJoystick1DownKeyDown, ref _wasJoystick1DownKeyDown);
- //UpdateKey(keyboard.Joystick1UpLeftKey, IsJoystick1Up && IsJoystick1Left, ref _isJoystick1UpLeftKeyDown, ref _wasJoystick1UpLeftKeyDown);
- //UpdateKey(keyboard.Joystick1UpRightKey, IsJoystick1Up && IsJoystick1Right, ref _isJoystick1UpRightKeyDown, ref _wasJoystick1UpRightKeyDown);
- //UpdateKey(keyboard.Joystick1DownLeftKey, IsJoystick1Down && IsJoystick1Left, ref _isJoystick1DownLeftKeyDown, ref _wasJoystick1DownLeftKeyDown);
- //UpdateKey(keyboard.Joystick1DownRightKey, IsJoystick1Down && IsJoystick1Right, ref _isJoystick1DownRightKeyDown, ref _wasJoystick1DownRightKeyDown);
-
- //all the keys are going through this one thing atm
- UpdateKey(keyboard.Button0Key, IsButton0Down, ref _isButton0KeyDown, ref _wasButton0KeyDown);
- //UpdateKey(keyboard.Button1Key, IsButton1Down, ref _isButton1KeyDown, ref _wasButton1KeyDown);
- //UpdateKey(keyboard.Button2Key, IsButton2Down, ref _isButton2KeyDown, ref _wasButton2KeyDown);
-
-
- /*
- if (_lastKey > 0) // repeat last key
- {
- long time = DateTime.UtcNow.Ticks;
- if (time - _lastTime >= _repeatTime)
- {
- _lastTime = time;
- _repeatTime = RepeatSpeed;
- keyboard.Latch = GetAsciiKey((Buttons)_lastKey, Machine.Keyboard.IsControlKeyDown, Machine.Keyboard.IsShiftKeyDown, false);
- }
- }
- * */
- }
- }
-
- //static int t = 0;
-
- private void UpdateKey(ulong key, bool isActive, ref bool isKeyDown, ref bool wasKeyDown)
- {
- wasKeyDown = isKeyDown;
- isKeyDown = (key > 0);// && isActive;
-
- if (isKeyDown != wasKeyDown)
- {
- if (isKeyDown)
- {
- _lastKey = key;
- _lastTime = DateTime.UtcNow.Ticks;
- _repeatTime = RepeatDelay;
- Machine.Keyboard.Latch = GetAsciiKey((Buttons)key, Machine.Keyboard.IsControlKeyDown, Machine.Keyboard.IsShiftKeyDown, false);
- }
- else if (key == _lastKey)
- {
- _lastKey = 0;
- }
- }
-
-
- }
-
- private static int GetAsciiKey(Buttons bizKey, bool bizCtrl, bool bizShift, bool bizCaps)
- {
-
- bool control = bizCtrl;
- bool shift = bizShift;
- bool capsLock = bizCaps;
-
- switch (bizKey)
- {
- case 0:
- return 0x00;
- case Buttons.Left:
- return 0x08;
-
- case Buttons.Tab:
- return 0x09;
-
- case Buttons.Down:
- return 0x0A;
-
- case Buttons.Up:
- return 0x0B;
-
- case Buttons.Enter:
- return 0x0D;
-
- case Buttons.Right:
- return 0x15;
-
- case Buttons.Escape:
- return 0x1B;
-
- case Buttons.Back:
- return control ? -1 : 0x7F;
-
- case Buttons.Space:
- return ' ';
-
- case Buttons.Key1:
- return shift ? '!' : '1';
-
- case Buttons.Key2:
- return control ? 0x00 : shift ? '@' : '2';
-
- case Buttons.Key3:
- return shift ? '#' : '3';
-
- case Buttons.Key4:
- return shift ? '$' : '4';
-
- case Buttons.Key5:
- return shift ? '%' : '5';
-
- case Buttons.Key6:
- return control ? 0x1E : shift ? '^' : '6';
-
- case Buttons.Key7:
- return shift ? '&' : '7';
-
- case Buttons.Key8:
- return shift ? '*' : '8';
-
- case Buttons.Key9:
- return shift ? '(' : '9';
-
- case Buttons.Key0:
- return shift ? ')' : '0';
-
- case Buttons.KeyA:
- return control ? 0x01 : capsLock ? 'A' : 'a';
-
- case Buttons.KeyB:
- return control ? 0x02 : capsLock ? 'B' : 'b';
-
- case Buttons.KeyC:
- return control ? 0x03 : capsLock ? 'C' : 'c';
-
- case Buttons.KeyD:
- return control ? 0x04 : capsLock ? 'D' : 'd';
-
- case Buttons.KeyE:
- return control ? 0x05 : capsLock ? 'E' : 'e';
-
- case Buttons.KeyF:
- return control ? 0x06 : capsLock ? 'F' : 'f';
-
- case Buttons.KeyG:
- return control ? 0x07 : capsLock ? 'G' : 'g';
-
- case Buttons.KeyH:
- return control ? 0x08 : capsLock ? 'H' : 'h';
-
- case Buttons.KeyI:
- return control ? 0x09 : capsLock ? 'I' : 'i';
-
- case Buttons.KeyJ:
- return control ? 0x0A : capsLock ? 'J' : 'j';
-
- case Buttons.KeyK:
- return control ? 0x0B : capsLock ? 'K' : 'k';
-
- case Buttons.KeyL:
- return control ? 0x0C : capsLock ? 'L' : 'l';
-
- case Buttons.KeyM:
- return control ? 0x0D : capsLock ? 'M' : 'm';
-
- case Buttons.KeyN:
- return control ? 0x0E : capsLock ? 'N' : 'n';
-
- case Buttons.KeyO:
- return control ? 0x0F : capsLock ? 'O' : 'o';
-
- case Buttons.KeyP:
- return control ? 0x10 : capsLock ? 'P' : 'p';
-
- case Buttons.KeyQ:
- return control ? 0x11 : capsLock ? 'Q' : 'q';
-
- case Buttons.KeyR:
- return control ? 0x12 : capsLock ? 'R' : 'r';
-
- case Buttons.KeyS:
- return control ? 0x13 : capsLock ? 'S' : 's';
-
- case Buttons.KeyT:
- return control ? 0x14 : capsLock ? 'T' : 't';
-
- case Buttons.KeyU:
- return control ? 0x15 : capsLock ? 'U' : 'u';
-
- case Buttons.KeyV:
- return control ? 0x16 : capsLock ? 'V' : 'v';
-
- case Buttons.KeyW:
- return control ? 0x17 : capsLock ? 'W' : 'w';
-
- case Buttons.KeyX:
- return control ? 0x18 : capsLock ? 'X' : 'x';
-
- case Buttons.KeyY:
- return control ? 0x19 : capsLock ? 'Y' : 'y';
-
- case Buttons.KeyZ:
- return control ? 0x1A : capsLock ? 'Z' : 'z';
- //TODO: Get around to supporting those keys too
- /*
- case Key.Oem1:
- return shift ? ':' : ';';
-
- case Key.Oem2:
- return shift ? '?' : '/';
-
- case Key.Oem3:
- return shift ? '~' : '`';
-
- case Key.Oem4:
- return shift ? '{' : '[';
-
- case Key.Oem5:
- return control ? 0x1C : shift ? '|' : '\\';
-
- case Key.Oem6:
- return control ? 0x1D : shift ? '}' : ']';
-
- case Key.Oem7:
- return shift ? '"' : '\'';
-
- case Key.OemMinus:
- return control ? 0x1F : shift ? '_' : '-';
-
- case Key.OemPlus:
- return shift ? '+' : '=';
-
- case Key.OemComma:
- return shift ? '<' : ',';
-
- case Key.OemPeriod:
- return shift ? '>' : '.';
- * */
- }
-
- return 0;
- }
-
- public int Paddle0 { get; protected set; }
- public int Paddle1 { get; protected set; }
- public int Paddle2 { get; protected set; }
- public int Paddle3 { get; protected set; }
-
- public bool IsJoystick0Up { get; protected set; }
- public bool IsJoystick0Left { get; protected set; }
- public bool IsJoystick0Right { get; protected set; }
- public bool IsJoystick0Down { get; protected set; }
-
- public bool IsJoystick1Up { get; protected set; }
- public bool IsJoystick1Left { get; protected set; }
- public bool IsJoystick1Right { get; protected set; }
- public bool IsJoystick1Down { get; protected set; }
-
- public bool IsButton0Down { get; protected set; }
- public bool IsButton1Down { get; protected set; }
- public bool IsButton2Down { get; protected set; }
-
- private static readonly long RepeatDelay = TimeSpan.FromMilliseconds(500).Ticks;
- private static readonly long RepeatSpeed = TimeSpan.FromMilliseconds(32).Ticks;
-
- //private bool _isJoystick0UpLeftKeyDown;
- //private bool _isJoystick0UpKeyDown;
- //private bool _isJoystick0UpRightKeyDown;
- //private bool _isJoystick0LeftKeyDown;
- //private bool _isJoystick0RightKeyDown;
- //private bool _isJoystick0DownLeftKeyDown;
- //private bool _isJoystick0DownKeyDown;
- //private bool _isJoystick0DownRightKeyDown;
- //private bool _isJoystick1UpLeftKeyDown;
- //private bool _isJoystick1UpKeyDown;
- //private bool _isJoystick1UpRightKeyDown;
- //private bool _isJoystick1LeftKeyDown;
- //private bool _isJoystick1RightKeyDown;
- //private bool _isJoystick1DownLeftKeyDown;
- //private bool _isJoystick1DownKeyDown;
- //private bool _isJoystick1DownRightKeyDown;
- private bool _isButton0KeyDown;
- //private bool _isButton1KeyDown;
- //private bool _isButton2KeyDown;
-
- //private bool _wasJoystick0UpLeftKeyDown;
- //private bool _wasJoystick0UpKeyDown;
- //private bool _wasJoystick0UpRightKeyDown;
- //private bool _wasJoystick0LeftKeyDown;
- //private bool _wasJoystick0RightKeyDown;
- //private bool _wasJoystick0DownLeftKeyDown;
- //private bool _wasJoystick0DownKeyDown;
- //private bool _wasJoystick0DownRightKeyDown;
- //private bool _wasJoystick1UpLeftKeyDown;
- //private bool _wasJoystick1UpKeyDown;
- //private bool _wasJoystick1UpRightKeyDown;
- //private bool _wasJoystick1LeftKeyDown;
- //private bool _wasJoystick1RightKeyDown;
- //private bool _wasJoystick1DownLeftKeyDown;
- //private bool _wasJoystick1DownKeyDown;
- //private bool _wasJoystick1DownRightKeyDown;
- private bool _wasButton0KeyDown;
- //private bool _wasButton1KeyDown;
- //private bool _wasButton2KeyDown;
-
- private ulong _lastKey;
- private long _lastTime;
- private long _repeatTime;
- }
-}
diff --git a/BizHawk.Emulation.Cores/Computers/AppleII/Virtu/Services/IsolatedStorageService.cs b/BizHawk.Emulation.Cores/Computers/AppleII/Virtu/Services/IsolatedStorageService.cs
deleted file mode 100644
index 68159a96ba4..00000000000
--- a/BizHawk.Emulation.Cores/Computers/AppleII/Virtu/Services/IsolatedStorageService.cs
+++ /dev/null
@@ -1,53 +0,0 @@
-using System;
-using System.Diagnostics.CodeAnalysis;
-using System.IO;
-using System.IO.IsolatedStorage;
-
-namespace Jellyfish.Virtu.Services
-{
- public class IsolatedStorageService : StorageService
- {
- public IsolatedStorageService(Machine machine) :
- base(machine)
- {
- }
-
- protected override void OnLoad(string fileName, Action reader)
- {
- if (reader == null)
- {
- throw new ArgumentNullException("reader");
- }
-
- using (var store = GetStore())
- {
- using (var stream = store.OpenFile(fileName, FileMode.Open, FileAccess.Read, FileShare.Read))
- {
- reader(stream);
- }
- }
- }
-
- protected override void OnSave(string fileName, Action writer)
- {
- if (writer == null)
- {
- throw new ArgumentNullException("writer");
- }
-
- using (var store = GetStore())
- {
- using (var stream = store.OpenFile(fileName, FileMode.Create, FileAccess.Write, FileShare.None))
- {
- writer(stream);
- }
- }
- }
-
- [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
- protected virtual IsolatedStorageFile GetStore()
- {
- return IsolatedStorageFile.GetUserStoreForApplication();
- }
- }
-}
diff --git a/BizHawk.Emulation.Cores/Computers/AppleII/Virtu/Services/KeyboardService.cs b/BizHawk.Emulation.Cores/Computers/AppleII/Virtu/Services/KeyboardService.cs
deleted file mode 100644
index db3b7daffa6..00000000000
--- a/BizHawk.Emulation.Cores/Computers/AppleII/Virtu/Services/KeyboardService.cs
+++ /dev/null
@@ -1,48 +0,0 @@
-namespace Jellyfish.Virtu.Services
-{
- public abstract class KeyboardService : MachineService
- {
- protected KeyboardService(Machine machine) :
- base(machine)
- {
- }
-
- public abstract bool IsKeyDown(int key);
-
- public virtual void Update() // main thread
- {
- var keyboard = Machine.Keyboard;
- var buttons = Machine.Buttons;
-
- keyboard.Button0Key = (ulong)buttons;
-
- if (IsResetKeyDown && !keyboard.DisableResetKey)
- {
- if (!_resetKeyDown)
- {
- _resetKeyDown = true; // entering reset; pause until key released
- //TODO ADELIKAT : HANDLE RESET DIFFERENTLY
- //Machine.Pause();
- //Machine.Reset();
- }
- }
- else if (_resetKeyDown)
- {
- _resetKeyDown = false; // leaving reset
- //TODO ADELIKAT : HANDLE RESET DIFFERENTLY
- //Machine.Unpause();
- }
- }
-
- public bool IsAnyKeyDown { get { return Machine.Buttons > 0; }}
- public bool IsControlKeyDown { get { return Machine.Buttons.HasFlag(Buttons.Ctrl); }}
- public bool IsShiftKeyDown { get { return Machine.Buttons.HasFlag(Buttons.Shift); }}
-
- public bool IsOpenAppleKeyDown { get; protected set; }
- public bool IsCloseAppleKeyDown { get; protected set; }
-
- protected bool IsResetKeyDown { get; set; }
-
- private bool _resetKeyDown;
- }
-}
diff --git a/BizHawk.Emulation.Cores/Computers/AppleII/Virtu/Services/MachineService.cs b/BizHawk.Emulation.Cores/Computers/AppleII/Virtu/Services/MachineService.cs
deleted file mode 100644
index 8c2b246410f..00000000000
--- a/BizHawk.Emulation.Cores/Computers/AppleII/Virtu/Services/MachineService.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-using System;
-using Jellyfish.Library;
-
-namespace Jellyfish.Virtu.Services
-{
- public abstract class MachineService : DisposableBase
- {
- protected MachineService(Machine machine)
- {
- Machine = machine;
-
- _debugService = new Lazy(() => Machine.Services.GetService());
- }
-
- protected Machine Machine { get; private set; }
- protected DebugService DebugService { get { return _debugService.Value; } }
-
- private Lazy _debugService;
- }
-}
diff --git a/BizHawk.Emulation.Cores/Computers/AppleII/Virtu/Services/MachineServices.cs b/BizHawk.Emulation.Cores/Computers/AppleII/Virtu/Services/MachineServices.cs
deleted file mode 100644
index b8669ee3620..00000000000
--- a/BizHawk.Emulation.Cores/Computers/AppleII/Virtu/Services/MachineServices.cs
+++ /dev/null
@@ -1,51 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Diagnostics.CodeAnalysis;
-using System.Globalization;
-using Jellyfish.Virtu.Properties;
-
-namespace Jellyfish.Virtu.Services
-{
- public sealed class MachineServices : IServiceProvider
- {
- public void AddService(Type serviceType, MachineService serviceProvider)
- {
- if (serviceType == null)
- {
- throw new ArgumentNullException("serviceType");
- }
- if (_serviceProviders.ContainsKey(serviceType))
- {
- throw new ArgumentException(string.Format(CultureInfo.CurrentUICulture, Strings.ServiceAlreadyPresent, serviceType.FullName), "serviceType");
- }
- if (serviceProvider == null)
- {
- throw new ArgumentNullException("serviceProvider");
- }
- if (!serviceType.IsAssignableFrom(serviceProvider.GetType()))
- {
- throw new ArgumentException(string.Format(CultureInfo.CurrentUICulture, Strings.ServiceMustBeAssignable, serviceType.FullName, serviceProvider.GetType().FullName));
- }
-
- _serviceProviders.Add(serviceType, serviceProvider);
- }
-
- [SuppressMessage("Microsoft.Design", "CA1004:GenericMethodsShouldProvideTypeParameter")]
- public T GetService()
- {
- return (T)((IServiceProvider)this).GetService(typeof(T));
- }
-
- public void RemoveService(Type serviceType)
- {
- _serviceProviders.Remove(serviceType);
- }
-
- object IServiceProvider.GetService(Type serviceType)
- {
- return _serviceProviders.ContainsKey(serviceType) ? _serviceProviders[serviceType] : null;
- }
-
- private Dictionary _serviceProviders = new Dictionary();
- }
-}
diff --git a/BizHawk.Emulation.Cores/Computers/AppleII/Virtu/Services/StorageService.cs b/BizHawk.Emulation.Cores/Computers/AppleII/Virtu/Services/StorageService.cs
deleted file mode 100644
index f70ad21c0dc..00000000000
--- a/BizHawk.Emulation.Cores/Computers/AppleII/Virtu/Services/StorageService.cs
+++ /dev/null
@@ -1,214 +0,0 @@
-using System;
-using System.Diagnostics;
-using System.Diagnostics.CodeAnalysis;
-using System.Globalization;
-using System.IO;
-using System.Security;
-using Jellyfish.Virtu.Properties;
-
-namespace Jellyfish.Virtu.Services
-{
- public abstract class StorageService : MachineService
- {
- protected StorageService(Machine machine) :
- base(machine)
- {
- }
-
- [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
- public bool Load(string fileName, Action reader)
- {
- try
- {
- DebugService.WriteMessage("Loading file '{0}'", fileName);
- OnLoad(fileName, reader);
- }
- catch (Exception ex)
- {
- DebugService.WriteMessage(ex.ToString());
- return false;
- }
-
- return true;
- }
-
-#if !WINDOWS
- [SecuritySafeCritical]
-#endif
- [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
- public static bool LoadFile(Stream stream, Action reader)
- {
- if (reader == null)
- {
- throw new ArgumentNullException("reader");
- }
-
- try
- {
- DebugService.Default.WriteMessage("Loading file '{0}'", "STREAM");
- {
- reader(stream);
- }
- }
- catch (Exception ex)
- {
- DebugService.Default.WriteMessage(ex.ToString());
- return false;
- }
-
- return true;
- }
-
-#if !WINDOWS
- [SecuritySafeCritical]
-#endif
- [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
- public static bool LoadFile(FileInfo fileInfo, Action reader)
- {
- if (fileInfo == null)
- {
- throw new ArgumentNullException("fileInfo");
- }
- if (reader == null)
- {
- throw new ArgumentNullException("reader");
- }
-
- try
- {
- DebugService.Default.WriteMessage("Loading file '{0}'", fileInfo.Name);
- using (var stream = fileInfo.Open(FileMode.Open, FileAccess.Read, FileShare.Read))
- {
- reader(stream);
- }
- }
- catch (Exception ex)
- {
- DebugService.Default.WriteMessage(ex.ToString());
- return false;
- }
-
- return true;
- }
-
- [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
- public static bool LoadResource(string resourceName, Action reader)
- {
- if (reader == null)
- {
- throw new ArgumentNullException("reader");
- }
-
- try
- {
- DebugService.Default.WriteMessage("Loading resource '{0}'", resourceName);
- using (var stream = File.OpenRead(resourceName))
- reader(stream);
- //using (var stream = GetResourceStream(resourceName))
- //{
- // reader(stream);
- //}
- }
- catch (Exception ex)
- {
- DebugService.Default.WriteMessage(ex.ToString());
- return false;
- }
-
- return true;
- }
-
- [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
- public bool Save(string fileName, Action writer)
- {
- try
- {
- DebugService.WriteMessage("Saving file '{0}'", fileName);
- OnSave(fileName, writer);
- }
- catch (Exception ex)
- {
- DebugService.WriteMessage(ex.ToString());
- return false;
- }
-
- return true;
- }
-
-#if !WINDOWS
- [SecuritySafeCritical]
-#endif
- [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
- public static bool SaveFile(string fileName, Action writer)
- {
- if (writer == null)
- {
- throw new ArgumentNullException("writer");
- }
-
- try
- {
- DebugService.Default.WriteMessage("Saving file '{0}'", fileName);
- using (var stream = File.Open(fileName, FileMode.Create, FileAccess.Write, FileShare.None))
- {
- writer(stream);
- }
- }
- catch (Exception ex)
- {
- DebugService.Default.WriteMessage(ex.ToString());
- return false;
- }
-
- return true;
- }
-
-#if !WINDOWS
- [SecuritySafeCritical]
-#endif
- [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
- public static bool SaveFile(FileInfo fileInfo, Action writer)
- {
- if (fileInfo == null)
- {
- throw new ArgumentNullException("fileInfo");
- }
- if (writer == null)
- {
- throw new ArgumentNullException("writer");
- }
-
- try
- {
- DebugService.Default.WriteMessage("Saving file '{0}'", fileInfo.Name);
- using (var stream = fileInfo.Open(FileMode.Create, FileAccess.Write, FileShare.None))
- {
- writer(stream);
- }
- }
- catch (Exception ex)
- {
- DebugService.Default.WriteMessage(ex.ToString());
- return false;
- }
-
- return true;
- }
-
- protected abstract void OnLoad(string fileName, Action reader);
-
- protected abstract void OnSave(string fileName, Action writer);
-
- private static Stream GetResourceStream(string resourceName)
- {
- resourceName = "Jellyfish.Virtu." + resourceName.Replace('/', '.');
- var resourceStream = typeof(StorageService).Assembly.GetManifestResourceStream(resourceName);
- if (resourceStream == null)
- {
- throw new FileNotFoundException(string.Format(CultureInfo.CurrentUICulture, Strings.ResourceNotFound, resourceName));
- }
-
- return resourceStream;
- }
- }
-}
diff --git a/BizHawk.Emulation.Cores/Computers/AppleII/Virtu/Services/VideoService.cs b/BizHawk.Emulation.Cores/Computers/AppleII/Virtu/Services/VideoService.cs
deleted file mode 100644
index 43a81ae789f..00000000000
--- a/BizHawk.Emulation.Cores/Computers/AppleII/Virtu/Services/VideoService.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-namespace Jellyfish.Virtu.Services
-{
- public abstract class VideoService : MachineService
- {
- protected VideoService(Machine machine) :
- base(machine)
- {
- }
-
- public virtual void SetFullScreen(bool isFullScreen)
- {
- }
-
- public abstract void SetPixel(int x, int y, uint color);
- public abstract void Update(); // main thread
- }
-}
diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IInputPollable.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IInputPollable.cs
index b0aef31cbd0..207eb7ac7e9 100644
--- a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IInputPollable.cs
+++ b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IInputPollable.cs
@@ -12,7 +12,6 @@ public bool IsLagFrame
public int LagCount
{
get { return _lagcount; }
- set { _lagcount = value; }
}
public IInputCallbackSystem InputCallbacks { get; private set; }
diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.cs
index 0b7bbe53960..c6588a17355 100644
--- a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.cs
+++ b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.cs
@@ -164,7 +164,7 @@ public void FrameAdvance(bool render, bool rendersound)
_islag = !board.inputRead;
if (_islag)
- LagCount++;
+ _lagcount++;
_frame++;
//Console.WriteLine("CPUPC: " + C64Util.ToHex(board.cpu.PC, 4) + " 1541PC: " + C64Util.ToHex(disk.PC, 4));
diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.Core.cs b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.Core.cs
index 1949a7f06fd..38c8b207bca 100644
--- a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.Core.cs
+++ b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.Core.cs
@@ -386,7 +386,7 @@ private void FinishFrameCond()
{
_tia.CompleteAudioFrame();
if (_islag)
- LagCount++;
+ _lagcount++;
_tia.LineCount = 0;
_frameStartPending = true;
}
diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.IInputPollable.cs b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.IInputPollable.cs
index efe6e472c97..62d2b964fe1 100644
--- a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.IInputPollable.cs
+++ b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.IInputPollable.cs
@@ -7,7 +7,6 @@ public partial class Atari2600 : IInputPollable
public int LagCount
{
get { return _lagcount; }
- set { _lagcount = value; }
}
public bool IsLagFrame
diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/7800/Atari7800.IInputPollable.cs b/BizHawk.Emulation.Cores/Consoles/Atari/7800/Atari7800.IInputPollable.cs
index 74937501de5..f4aac288d4d 100644
--- a/BizHawk.Emulation.Cores/Consoles/Atari/7800/Atari7800.IInputPollable.cs
+++ b/BizHawk.Emulation.Cores/Consoles/Atari/7800/Atari7800.IInputPollable.cs
@@ -7,7 +7,6 @@ public partial class Atari7800 : IInputPollable
public int LagCount
{
get { return _lagcount; }
- set { _lagcount = value; }
}
public bool IsLagFrame
diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/7800/Atari7800.cs b/BizHawk.Emulation.Cores/Consoles/Atari/7800/Atari7800.cs
index 6b5c206ac7f..f169effc481 100644
--- a/BizHawk.Emulation.Cores/Consoles/Atari/7800/Atari7800.cs
+++ b/BizHawk.Emulation.Cores/Consoles/Atari/7800/Atari7800.cs
@@ -105,7 +105,7 @@ public void FrameAdvance(bool render, bool rendersound)
if (_islag)
{
- LagCount++;
+ _lagcount++;
}
avProvider.FillFrameBuffer();
diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.IInputPollable.cs b/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.IInputPollable.cs
index 5ec3a44bc5f..e458507f59d 100644
--- a/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.IInputPollable.cs
+++ b/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.IInputPollable.cs
@@ -6,17 +6,17 @@
namespace BizHawk.Emulation.Cores.Atari.Lynx
{
- public partial class Lynx : IInputPollable
- {
- public int LagCount { get; set; }
+ public partial class Lynx : IInputPollable
+ {
+ public int LagCount { get; private set; }
- public bool IsLagFrame { get; private set; }
+ public bool IsLagFrame { get; private set; }
- // TODO
- public IInputCallbackSystem InputCallbacks
- {
- [FeatureNotImplemented]
- get { throw new NotImplementedException(); }
- }
- }
+ // TODO
+ public IInputCallbackSystem InputCallbacks
+ {
+ [FeatureNotImplemented]
+ get { throw new NotImplementedException(); }
+ }
+ }
}
diff --git a/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.IInputPollable.cs b/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.IInputPollable.cs
index bfac04bd55a..b044051c9cc 100644
--- a/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.IInputPollable.cs
+++ b/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.IInputPollable.cs
@@ -8,7 +8,6 @@ public partial class ColecoVision : IInputPollable
public int LagCount
{
get { return _lagCount; }
- set { _lagCount = value; }
}
public bool IsLagFrame
diff --git a/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.cs b/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.cs
index 0ac81f4c8ff..9899c08e5e0 100644
--- a/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.cs
+++ b/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.cs
@@ -78,7 +78,7 @@ public void FrameAdvance(bool render, bool renderSound)
if (_isLag)
{
- LagCount++;
+ _lagCount++;
}
}
@@ -166,7 +166,7 @@ public void ResetCounters()
public string BoardName { get { return null; } }
- public ISyncSoundProvider SyncSoundProvider { get { return null; } }
+ public ISyncSoundProvider SyncSoundProvider { get { return new FakeSyncSound(SoundProvider, 735); } }
public bool StartAsyncSound() { return true; }
public void EndAsyncSound() { }
}
diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/LibmGBA.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/LibmGBA.cs
new file mode 100644
index 00000000000..644b9871788
--- /dev/null
+++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/LibmGBA.cs
@@ -0,0 +1,64 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Runtime.InteropServices;
+using BizHawk.Emulation.Common;
+
+namespace BizHawk.Emulation.Cores.Nintendo.GBA
+{
+ public static class LibmGBA
+ {
+ const string dll = "mgba.dll";
+ const CallingConvention cc = CallingConvention.Cdecl;
+
+ [DllImport(dll, CallingConvention = cc)]
+ public static extern void BizDestroy(IntPtr ctx);
+
+ [DllImport(dll, CallingConvention = cc)]
+ public static extern IntPtr BizCreate(byte[] bios);
+
+ [DllImport(dll, CallingConvention = cc)]
+ public static extern void BizReset(IntPtr ctx);
+
+ [DllImport(dll, CallingConvention = cc)]
+ public static extern void BizSkipBios(IntPtr ctx);
+
+ [DllImport(dll, CallingConvention = cc)]
+ public static extern bool BizLoad(IntPtr ctx, byte[] data, int length);
+
+ [DllImport(dll, CallingConvention = cc)]
+ public static extern bool BizAdvance(IntPtr ctx, LibVBANext.Buttons keys, int[] vbuff, ref int nsamp, short[] sbuff,
+ long time, short gyrox, short gyroy, short gyroz, byte luma);
+
+ [StructLayout(LayoutKind.Sequential)]
+ public class MemoryAreas
+ {
+ public IntPtr bios;
+ public IntPtr wram;
+ public IntPtr iwram;
+ public IntPtr mmio;
+ public IntPtr palram;
+ public IntPtr vram;
+ public IntPtr oam;
+ public IntPtr rom;
+ }
+
+ [DllImport(dll, CallingConvention = cc)]
+ public static extern void BizGetMemoryAreas(IntPtr ctx, [Out]MemoryAreas dst);
+
+ [DllImport(dll, CallingConvention = cc)]
+ public static extern int BizGetSaveRamSize(IntPtr ctx);
+ [DllImport(dll, CallingConvention = cc)]
+ public static extern void BizGetSaveRam(IntPtr ctx, byte[] dest);
+ [DllImport(dll, CallingConvention = cc)]
+ public static extern void BizPutSaveRam(IntPtr ctx, byte[] src);
+
+ [DllImport(dll, CallingConvention = cc)]
+ public static extern int BizGetStateSize();
+ [DllImport(dll, CallingConvention = cc)]
+ public static extern void BizGetState(IntPtr ctx, byte[] dest);
+ [DllImport(dll, CallingConvention = cc)]
+ public static extern void BizPutState(IntPtr ctx, byte[] src);
+ }
+}
diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/MGBAHawk.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/MGBAHawk.cs
new file mode 100644
index 00000000000..4eff95be9b4
--- /dev/null
+++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/MGBAHawk.cs
@@ -0,0 +1,420 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using BizHawk.Common;
+using BizHawk.Emulation.Common;
+using System.Runtime.InteropServices;
+using System.IO;
+using System.ComponentModel;
+
+namespace BizHawk.Emulation.Cores.Nintendo.GBA
+{
+ [CoreAttributes("mGBA", "endrift", true, false, "NOT DONE", "NOT DONE", false)]
+ public class MGBAHawk : IEmulator, IVideoProvider, ISyncSoundProvider, IGBAGPUViewable, ISaveRam, IStatable, IInputPollable, ISettable