From d7f97b15393d3ea47304e8c848affc646afe5114 Mon Sep 17 00:00:00 2001 From: adelikat Date: Sat, 8 Feb 2020 13:09:27 -0600 Subject: [PATCH] actually delete things instead of removing them from the project --- .../BizHawk.Client.ApiHawk.csproj | 4 - .../Classes/Api/PluginBase.cs | 51 - BizHawk.Client.ApiHawk/Interfaces/IPlugin.cs | 14 - .../BizHawk.Client.Common.csproj | 4 - BizHawk.Client.Common/SharpZipWriter.cs | 45 - BizHawk.Client.Common/lua/LuaExamples.cs | 28 - .../BizHawk.Client.DiscoHawk.csproj | 6 - .../DiscoHawkDialog.Designer.cs | 481 --- BizHawk.Client.DiscoHawk/DiscoHawkDialog.cs | 224 -- BizHawk.Client.DiscoHawk/DiscoHawkDialog.resx | 123 - .../ProgressDialog.Designer.cs | 85 - BizHawk.Client.DiscoHawk/ProgressDialog.cs | 51 - BizHawk.Client.DiscoHawk/ProgressDialog.resx | 120 - BizHawk.Common/BizHawk.Common.csproj | 2 - .../Extensions/BinaryReaderExtensions.cs | 234 -- BizHawk.Common/SuperGloballyUniqueID.cs | 19 - .../BizHawk.Emulation.Common.csproj | 3 - .../Interfaces/IHookManager.cs | 59 - .../BizHawk.Emulation.Cores.csproj | 3 - .../CPUs/MOS 6502X/6502XXX/6502XXX.sln | 20 - .../CPUs/MOS 6502X/6502XXX/6502XXX.vcxproj | 92 - .../MOS 6502X/6502XXX/6502XXX.vcxproj.filters | 30 - .../CPUs/MOS 6502X/6502XXX/Execute.cpp | 2595 --------------- .../6502XXX/Old Managed Stuff/Execute.cs | 2912 ----------------- .../6502XXX/Old Managed Stuff/MOS6502X.cs | 327 -- .../CPUs/MOS 6502X/6502XXX/TableNZ.h | 19 - .../CPUs/MOS 6502X/6502XXX/UopEnum.h | 252 -- .../CPUs/MOS 6502X/6502XXX/UopTable.cpp | 268 -- .../CPUs/MOS 6502X/6502XXX/mingw/Makefile | 26 - .../ExternalCores/EmuFile.cs | 193 -- .../ExternalCores/ExternalCore.cs | 254 -- .../ExternalCores/PsxCore.cs | 101 - .../ExternalCores/Snippets.txt | 103 - .../LibretroOld/LibRetro.cs | 672 ---- .../LibRetroEmulator.InputCallbacks.cs | 219 -- .../LibretroOld/LibRetroEmulator.cs | 954 ------ .../BizHawk.Bizware.BizwareGL.csproj | 5 - .../CacheBlendState.cs | 9 - .../GuiRendererBase.cs | 414 --- .../RetroShader_OpenTK.cs | 95 - 40 files changed, 11116 deletions(-) delete mode 100644 BizHawk.Client.ApiHawk/Classes/Api/PluginBase.cs delete mode 100644 BizHawk.Client.ApiHawk/Interfaces/IPlugin.cs delete mode 100644 BizHawk.Client.Common/SharpZipWriter.cs delete mode 100644 BizHawk.Client.Common/lua/LuaExamples.cs delete mode 100644 BizHawk.Client.DiscoHawk/DiscoHawkDialog.Designer.cs delete mode 100644 BizHawk.Client.DiscoHawk/DiscoHawkDialog.cs delete mode 100644 BizHawk.Client.DiscoHawk/DiscoHawkDialog.resx delete mode 100644 BizHawk.Client.DiscoHawk/ProgressDialog.Designer.cs delete mode 100644 BizHawk.Client.DiscoHawk/ProgressDialog.cs delete mode 100644 BizHawk.Client.DiscoHawk/ProgressDialog.resx delete mode 100644 BizHawk.Common/Extensions/BinaryReaderExtensions.cs delete mode 100644 BizHawk.Common/SuperGloballyUniqueID.cs delete mode 100644 BizHawk.Emulation.Common/Interfaces/IHookManager.cs delete mode 100644 BizHawk.Emulation.Cores/CPUs/MOS 6502X/6502XXX/6502XXX.sln delete mode 100644 BizHawk.Emulation.Cores/CPUs/MOS 6502X/6502XXX/6502XXX.vcxproj delete mode 100644 BizHawk.Emulation.Cores/CPUs/MOS 6502X/6502XXX/6502XXX.vcxproj.filters delete mode 100644 BizHawk.Emulation.Cores/CPUs/MOS 6502X/6502XXX/Execute.cpp delete mode 100644 BizHawk.Emulation.Cores/CPUs/MOS 6502X/6502XXX/Old Managed Stuff/Execute.cs delete mode 100644 BizHawk.Emulation.Cores/CPUs/MOS 6502X/6502XXX/Old Managed Stuff/MOS6502X.cs delete mode 100644 BizHawk.Emulation.Cores/CPUs/MOS 6502X/6502XXX/TableNZ.h delete mode 100644 BizHawk.Emulation.Cores/CPUs/MOS 6502X/6502XXX/UopEnum.h delete mode 100644 BizHawk.Emulation.Cores/CPUs/MOS 6502X/6502XXX/UopTable.cpp delete mode 100644 BizHawk.Emulation.Cores/CPUs/MOS 6502X/6502XXX/mingw/Makefile delete mode 100644 BizHawk.Emulation.Cores/ExternalCores/EmuFile.cs delete mode 100644 BizHawk.Emulation.Cores/ExternalCores/ExternalCore.cs delete mode 100644 BizHawk.Emulation.Cores/ExternalCores/PsxCore.cs delete mode 100644 BizHawk.Emulation.Cores/ExternalCores/Snippets.txt delete mode 100644 BizHawk.Emulation.Cores/LibretroOld/LibRetro.cs delete mode 100644 BizHawk.Emulation.Cores/LibretroOld/LibRetroEmulator.InputCallbacks.cs delete mode 100644 BizHawk.Emulation.Cores/LibretroOld/LibRetroEmulator.cs delete mode 100644 Bizware/BizHawk.Bizware.BizwareGL/CacheBlendState.cs delete mode 100644 Bizware/BizHawk.Bizware.BizwareGL/GuiRendererBase.cs delete mode 100644 Bizware/BizHawk.Bizware.BizwareGL/RetroShader_OpenTK.cs diff --git a/BizHawk.Client.ApiHawk/BizHawk.Client.ApiHawk.csproj b/BizHawk.Client.ApiHawk/BizHawk.Client.ApiHawk.csproj index ea9d056f3a..579724961d 100644 --- a/BizHawk.Client.ApiHawk/BizHawk.Client.ApiHawk.csproj +++ b/BizHawk.Client.ApiHawk/BizHawk.Client.ApiHawk.csproj @@ -19,9 +19,5 @@ - - - - diff --git a/BizHawk.Client.ApiHawk/Classes/Api/PluginBase.cs b/BizHawk.Client.ApiHawk/Classes/Api/PluginBase.cs deleted file mode 100644 index 3c190c6a15..0000000000 --- a/BizHawk.Client.ApiHawk/Classes/Api/PluginBase.cs +++ /dev/null @@ -1,51 +0,0 @@ -using BizHawk.Client.Common; -using BizHawk.Emulation.Common; - -namespace BizHawk.Client.ApiHawk -{ - public abstract class PluginBase : IPlugin - { - /// - /// The base class from which all - /// plugins will be derived - /// - /// Actual plugins should implement - /// one of the below callback methods - /// or register memory callbacks in - /// their Init function. - /// - protected IApiContainer _api; - - public PluginBase() { } - - public abstract string Name { get; } - public abstract string Description { get; } - - public bool Enabled => Running; - public bool Paused => !Running; - - public bool Running { get; set; } - - public void Stop() - { - Running = false; - } - - public void Toggle() - { - Running = !Running; - } - - public virtual void PreFrameCallback() { } - public virtual void PostFrameCallback() { } - public virtual void SaveStateCallback(string name) { } - public virtual void LoadStateCallback(string name) { } - public virtual void InputPollCallback() { } - public virtual void ExitCallback() { } - public virtual void Init (IApiContainer api) - { - _api = api; - Running = true; - } - } -} diff --git a/BizHawk.Client.ApiHawk/Interfaces/IPlugin.cs b/BizHawk.Client.ApiHawk/Interfaces/IPlugin.cs deleted file mode 100644 index b7dbb2ac98..0000000000 --- a/BizHawk.Client.ApiHawk/Interfaces/IPlugin.cs +++ /dev/null @@ -1,14 +0,0 @@ -using BizHawk.Client.Common; - -namespace BizHawk.Client.ApiHawk -{ - interface IPlugin - { - void PreFrameCallback(); - void PostFrameCallback(); - void SaveStateCallback(string name); - void LoadStateCallback(string name); - void InputPollCallback(); - void Init(IApiContainer api); - } -} diff --git a/BizHawk.Client.Common/BizHawk.Client.Common.csproj b/BizHawk.Client.Common/BizHawk.Client.Common.csproj index 0105d337ab..8a007f1c16 100644 --- a/BizHawk.Client.Common/BizHawk.Client.Common.csproj +++ b/BizHawk.Client.Common/BizHawk.Client.Common.csproj @@ -38,10 +38,6 @@ - - - - diff --git a/BizHawk.Client.Common/SharpZipWriter.cs b/BizHawk.Client.Common/SharpZipWriter.cs deleted file mode 100644 index e95acc7e04..0000000000 --- a/BizHawk.Client.Common/SharpZipWriter.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System; -using System.IO; - -using ICSharpCode.SharpZipLib.Zip; - -namespace BizHawk.Client.Common -{ - public class SharpZipWriter : IZipWriter - { - private readonly int _level; - private ZipOutputStream _zipOutputStream; - - public SharpZipWriter(string path, int compressionlevel) - { - _level = compressionlevel; - _zipOutputStream = new ZipOutputStream(new FileStream(path, FileMode.Create, FileAccess.Write)) - { - IsStreamOwner = true, - UseZip64 = UseZip64.Off - }; - _zipOutputStream.SetLevel(_level); - } - - public void WriteItem(string name, Action callback) - { - var e = new ZipEntry(name) - { - CompressionMethod = _level == 0 ? CompressionMethod.Stored : CompressionMethod.Deflated - }; - - _zipOutputStream.PutNextEntry(e); - callback(_zipOutputStream); - _zipOutputStream.CloseEntry(); - } - - public void Dispose() - { - if (_zipOutputStream != null) - { - _zipOutputStream.Dispose(); - _zipOutputStream = null; - } - } - } -} diff --git a/BizHawk.Client.Common/lua/LuaExamples.cs b/BizHawk.Client.Common/lua/LuaExamples.cs deleted file mode 100644 index ff39999bad..0000000000 --- a/BizHawk.Client.Common/lua/LuaExamples.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; - -namespace BizHawk.Client.Common -{ - [AttributeUsage(AttributeTargets.Method)] - public class LuaMethodExample : Attribute - { - public LuaMethodExample(string name, string example) - { - Name = name; - Example = example; - } - - public string Name { get; } - public string Example { get; } - } - - [AttributeUsage(AttributeTargets.Class)] - public class LuaLibraryExample : Attribute - { - public LuaLibraryExample(bool released) - { - Released = released; - } - - public bool Released { get; } - } -} diff --git a/BizHawk.Client.DiscoHawk/BizHawk.Client.DiscoHawk.csproj b/BizHawk.Client.DiscoHawk/BizHawk.Client.DiscoHawk.csproj index 9f99c971ef..6ae0124c2a 100644 --- a/BizHawk.Client.DiscoHawk/BizHawk.Client.DiscoHawk.csproj +++ b/BizHawk.Client.DiscoHawk/BizHawk.Client.DiscoHawk.csproj @@ -94,14 +94,8 @@ - - - - - - diff --git a/BizHawk.Client.DiscoHawk/DiscoHawkDialog.Designer.cs b/BizHawk.Client.DiscoHawk/DiscoHawkDialog.Designer.cs deleted file mode 100644 index 3f3550a176..0000000000 --- a/BizHawk.Client.DiscoHawk/DiscoHawkDialog.Designer.cs +++ /dev/null @@ -1,481 +0,0 @@ -namespace BizHawk.Client.DiscoHawk -{ - partial class DiscoHawkDialog - { - /// - /// 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(DiscoHawkDialog)); - this.btnAddDisc = new System.Windows.Forms.Button(); - this.lvDiscs = new System.Windows.Forms.ListView(); - this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.groupBox1 = new System.Windows.Forms.GroupBox(); - this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); - this.lblSize = new System.Windows.Forms.Label(); - this.lblTracks = new System.Windows.Forms.Label(); - this.lblSessions = new System.Windows.Forms.Label(); - this.lblSectors = new System.Windows.Forms.Label(); - this.label3 = new System.Windows.Forms.Label(); - this.label2 = new System.Windows.Forms.Label(); - this.label1 = new System.Windows.Forms.Label(); - this.label4 = new System.Windows.Forms.Label(); - this.txtCuePreview = new System.Windows.Forms.TextBox(); - this.label5 = new System.Windows.Forms.Label(); - this.checkCueProp_OneBlobPerTrack = new System.Windows.Forms.CheckBox(); - this.label6 = new System.Windows.Forms.Label(); - this.panel1 = new System.Windows.Forms.Panel(); - this.panel2 = new System.Windows.Forms.Panel(); - this.label7 = new System.Windows.Forms.Label(); - this.checkCueProp_Annotations = new System.Windows.Forms.CheckBox(); - this.panel3 = new System.Windows.Forms.Panel(); - this.btnPresetCanonical = new System.Windows.Forms.Button(); - this.btnPresetDaemonTools = new System.Windows.Forms.Button(); - this.groupBox2 = new System.Windows.Forms.GroupBox(); - this.label9 = new System.Windows.Forms.Label(); - this.treeView1 = new System.Windows.Forms.TreeView(); - this.label10 = new System.Windows.Forms.Label(); - this.btnExportCue = new System.Windows.Forms.Button(); - this.label11 = new System.Windows.Forms.Label(); - this.label12 = new System.Windows.Forms.Label(); - this.label13 = new System.Windows.Forms.Label(); - this.lblMagicDragArea = new System.Windows.Forms.Label(); - this.groupBox1.SuspendLayout(); - this.tableLayoutPanel1.SuspendLayout(); - this.panel1.SuspendLayout(); - this.panel2.SuspendLayout(); - this.groupBox2.SuspendLayout(); - this.SuspendLayout(); - // - // btnAddDisc - // - this.btnAddDisc.Location = new System.Drawing.Point(12, 46); - this.btnAddDisc.Name = "btnAddDisc"; - this.btnAddDisc.Size = new System.Drawing.Size(75, 23); - this.btnAddDisc.TabIndex = 0; - this.btnAddDisc.Text = "Add Disc"; - this.btnAddDisc.UseVisualStyleBackColor = true; - this.btnAddDisc.Click += new System.EventHandler(this.btnAddDisc_Click); - // - // lvDiscs - // - this.lvDiscs.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.columnHeader1}); - this.lvDiscs.GridLines = true; - this.lvDiscs.HideSelection = false; - this.lvDiscs.Location = new System.Drawing.Point(12, 80); - this.lvDiscs.Name = "lvDiscs"; - this.lvDiscs.Size = new System.Drawing.Size(248, 165); - this.lvDiscs.TabIndex = 1; - this.lvDiscs.UseCompatibleStateImageBehavior = false; - this.lvDiscs.View = System.Windows.Forms.View.Details; - this.lvDiscs.SelectedIndexChanged += new System.EventHandler(this.lvDiscs_SelectedIndexChanged); - // - // columnHeader1 - // - this.columnHeader1.Text = "Name"; - this.columnHeader1.Width = 240; - // - // groupBox1 - // - this.groupBox1.Controls.Add(this.tableLayoutPanel1); - this.groupBox1.Location = new System.Drawing.Point(21, 251); - this.groupBox1.Name = "groupBox1"; - this.groupBox1.Padding = new System.Windows.Forms.Padding(3, 3, 3, 0); - this.groupBox1.Size = new System.Drawing.Size(203, 107); - this.groupBox1.TabIndex = 2; - this.groupBox1.TabStop = false; - this.groupBox1.Text = "Quick Info"; - // - // tableLayoutPanel1 - // - this.tableLayoutPanel1.ColumnCount = 2; - this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); - this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.tableLayoutPanel1.Controls.Add(this.lblSize, 0, 3); - this.tableLayoutPanel1.Controls.Add(this.lblTracks, 1, 1); - this.tableLayoutPanel1.Controls.Add(this.lblSessions, 1, 0); - this.tableLayoutPanel1.Controls.Add(this.lblSectors, 1, 2); - this.tableLayoutPanel1.Controls.Add(this.label3, 0, 0); - this.tableLayoutPanel1.Controls.Add(this.label2, 0, 2); - this.tableLayoutPanel1.Controls.Add(this.label1, 0, 1); - this.tableLayoutPanel1.Controls.Add(this.label4, 0, 3); - this.tableLayoutPanel1.Location = new System.Drawing.Point(6, 19); - this.tableLayoutPanel1.Margin = new System.Windows.Forms.Padding(3, 3, 3, 0); - this.tableLayoutPanel1.Name = "tableLayoutPanel1"; - this.tableLayoutPanel1.RowCount = 5; - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle()); - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle()); - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle()); - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle()); - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); - this.tableLayoutPanel1.Size = new System.Drawing.Size(184, 79); - this.tableLayoutPanel1.TabIndex = 3; - // - // lblSize - // - this.lblSize.AutoSize = true; - this.lblSize.Location = new System.Drawing.Point(61, 39); - this.lblSize.Name = "lblSize"; - this.lblSize.Size = new System.Drawing.Size(30, 13); - this.lblSize.TabIndex = 7; - this.lblSize.Text = "Size:"; - // - // lblTracks - // - this.lblTracks.AutoSize = true; - this.lblTracks.Location = new System.Drawing.Point(61, 13); - this.lblTracks.Name = "lblTracks"; - this.lblTracks.Size = new System.Drawing.Size(30, 13); - this.lblTracks.TabIndex = 6; - this.lblTracks.Text = "Size:"; - // - // lblSessions - // - this.lblSessions.AutoSize = true; - this.lblSessions.Location = new System.Drawing.Point(61, 0); - this.lblSessions.Name = "lblSessions"; - this.lblSessions.Size = new System.Drawing.Size(30, 13); - this.lblSessions.TabIndex = 5; - this.lblSessions.Text = "Size:"; - // - // lblSectors - // - this.lblSectors.AutoSize = true; - this.lblSectors.Location = new System.Drawing.Point(61, 26); - this.lblSectors.Name = "lblSectors"; - this.lblSectors.Size = new System.Drawing.Size(30, 13); - this.lblSectors.TabIndex = 4; - this.lblSectors.Text = "Size:"; - // - // label3 - // - this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(3, 0); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(52, 13); - this.label3.TabIndex = 2; - this.label3.Text = "Sessions:"; - // - // label2 - // - this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(3, 26); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(46, 13); - this.label2.TabIndex = 1; - this.label2.Text = "Sectors:"; - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(3, 13); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(43, 13); - this.label1.TabIndex = 0; - this.label1.Text = "Tracks:"; - // - // label4 - // - this.label4.AutoSize = true; - this.label4.Location = new System.Drawing.Point(3, 39); - this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(30, 13); - this.label4.TabIndex = 3; - this.label4.Text = "Size:"; - // - // txtCuePreview - // - this.txtCuePreview.Font = new System.Drawing.Font("Courier New", 8F); - this.txtCuePreview.Location = new System.Drawing.Point(284, 25); - this.txtCuePreview.Multiline = true; - this.txtCuePreview.Name = "txtCuePreview"; - this.txtCuePreview.ReadOnly = true; - this.txtCuePreview.ScrollBars = System.Windows.Forms.ScrollBars.Both; - this.txtCuePreview.Size = new System.Drawing.Size(375, 571); - this.txtCuePreview.TabIndex = 3; - this.txtCuePreview.WordWrap = false; - // - // label5 - // - this.label5.AutoSize = true; - this.label5.Location = new System.Drawing.Point(281, 6); - this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(102, 13); - this.label5.TabIndex = 4; - this.label5.Text = "Output Cue Preview"; - // - // checkCueProp_OneBlobPerTrack - // - this.checkCueProp_OneBlobPerTrack.AutoSize = true; - this.checkCueProp_OneBlobPerTrack.Location = new System.Drawing.Point(7, 6); - this.checkCueProp_OneBlobPerTrack.Name = "checkCueProp_OneBlobPerTrack"; - this.checkCueProp_OneBlobPerTrack.Size = new System.Drawing.Size(111, 17); - this.checkCueProp_OneBlobPerTrack.TabIndex = 5; - this.checkCueProp_OneBlobPerTrack.Text = "OneBlobPerTrack"; - this.checkCueProp_OneBlobPerTrack.UseVisualStyleBackColor = true; - this.checkCueProp_OneBlobPerTrack.CheckedChanged += new System.EventHandler(this.checkCueProp_CheckedChanged); - // - // label6 - // - this.label6.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label6.Location = new System.Drawing.Point(4, 26); - this.label6.Name = "label6"; - this.label6.Size = new System.Drawing.Size(196, 42); - this.label6.TabIndex = 6; - this.label6.Text = "Should the output be split into several blobs, or just use one?"; - // - // panel1 - // - this.panel1.AutoSize = true; - this.panel1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.panel1.Controls.Add(this.label6); - this.panel1.Controls.Add(this.checkCueProp_OneBlobPerTrack); - this.panel1.Location = new System.Drawing.Point(15, 19); - this.panel1.Name = "panel1"; - this.panel1.Size = new System.Drawing.Size(203, 68); - this.panel1.TabIndex = 9; - // - // panel2 - // - this.panel2.AutoSize = true; - this.panel2.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.panel2.Controls.Add(this.label7); - this.panel2.Controls.Add(this.checkCueProp_Annotations); - this.panel2.Location = new System.Drawing.Point(224, 19); - this.panel2.Name = "panel2"; - this.panel2.Size = new System.Drawing.Size(154, 68); - this.panel2.TabIndex = 10; - // - // label7 - // - this.label7.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label7.Location = new System.Drawing.Point(4, 26); - this.label7.Name = "label7"; - this.label7.Size = new System.Drawing.Size(147, 42); - this.label7.TabIndex = 6; - this.label7.Text = "Annotate cue with non-standard comments"; - // - // checkCueProp_Annotations - // - this.checkCueProp_Annotations.AutoSize = true; - this.checkCueProp_Annotations.Location = new System.Drawing.Point(7, 6); - this.checkCueProp_Annotations.Name = "checkCueProp_Annotations"; - this.checkCueProp_Annotations.Size = new System.Drawing.Size(82, 17); - this.checkCueProp_Annotations.TabIndex = 5; - this.checkCueProp_Annotations.Text = "Annotations"; - this.checkCueProp_Annotations.UseVisualStyleBackColor = true; - this.checkCueProp_Annotations.CheckedChanged += new System.EventHandler(this.checkCueProp_CheckedChanged); - // - // panel3 - // - this.panel3.AutoSize = true; - this.panel3.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.panel3.Location = new System.Drawing.Point(15, 94); - this.panel3.Name = "panel3"; - this.panel3.Size = new System.Drawing.Size(0, 0); - this.panel3.TabIndex = 10; - // - // btnPresetCanonical - // - this.btnPresetCanonical.Location = new System.Drawing.Point(720, 210); - this.btnPresetCanonical.Name = "btnPresetCanonical"; - this.btnPresetCanonical.Size = new System.Drawing.Size(114, 23); - this.btnPresetCanonical.TabIndex = 11; - this.btnPresetCanonical.Text = "BizHawk Canonical"; - this.btnPresetCanonical.UseVisualStyleBackColor = true; - this.btnPresetCanonical.Click += new System.EventHandler(this.btnPresetCanonical_Click); - // - // btnPresetDaemonTools - // - this.btnPresetDaemonTools.Location = new System.Drawing.Point(840, 210); - this.btnPresetDaemonTools.Name = "btnPresetDaemonTools"; - this.btnPresetDaemonTools.Size = new System.Drawing.Size(115, 23); - this.btnPresetDaemonTools.TabIndex = 12; - this.btnPresetDaemonTools.Text = "Daemon Tools"; - this.btnPresetDaemonTools.UseVisualStyleBackColor = true; - this.btnPresetDaemonTools.Click += new System.EventHandler(this.btnPresetDaemonTools_Click); - // - // groupBox2 - // - this.groupBox2.Controls.Add(this.panel1); - this.groupBox2.Controls.Add(this.panel2); - this.groupBox2.Controls.Add(this.panel3); - this.groupBox2.Location = new System.Drawing.Point(665, 25); - this.groupBox2.Name = "groupBox2"; - this.groupBox2.Size = new System.Drawing.Size(394, 179); - this.groupBox2.TabIndex = 13; - this.groupBox2.TabStop = false; - this.groupBox2.Text = "Cue Export Properties"; - // - // label9 - // - this.label9.AutoSize = true; - this.label9.Location = new System.Drawing.Point(672, 214); - this.label9.Name = "label9"; - this.label9.Size = new System.Drawing.Size(42, 13); - this.label9.TabIndex = 14; - this.label9.Text = "Presets"; - // - // treeView1 - // - this.treeView1.Location = new System.Drawing.Point(12, 384); - this.treeView1.Name = "treeView1"; - this.treeView1.Size = new System.Drawing.Size(239, 225); - this.treeView1.TabIndex = 15; - // - // label10 - // - this.label10.AutoSize = true; - this.label10.Location = new System.Drawing.Point(18, 364); - this.label10.Name = "label10"; - this.label10.Size = new System.Drawing.Size(137, 13); - this.label10.TabIndex = 16; - this.label10.Text = "tree/list like isobuster (TBD)"; - // - // btnExportCue - // - this.btnExportCue.Location = new System.Drawing.Point(665, 335); - this.btnExportCue.Name = "btnExportCue"; - this.btnExportCue.Size = new System.Drawing.Size(101, 23); - this.btnExportCue.TabIndex = 17; - this.btnExportCue.Text = "Export Cue+XXX"; - this.btnExportCue.UseVisualStyleBackColor = true; - this.btnExportCue.Click += new System.EventHandler(this.btnExportCue_Click); - // - // label11 - // - this.label11.Location = new System.Drawing.Point(677, 251); - this.label11.Name = "label11"; - this.label11.Size = new System.Drawing.Size(297, 81); - this.label11.TabIndex = 18; - this.label11.Text = resources.GetString("label11.Text"); - // - // label12 - // - this.label12.Location = new System.Drawing.Point(93, 5); - this.label12.Name = "label12"; - this.label12.Size = new System.Drawing.Size(167, 67); - this.label12.TabIndex = 19; - this.label12.Text = "Why is this a list? Not sure. I thought we might want to make multi-disc archive" + - " format of our own one day. Also disc hopper demo"; - // - // label13 - // - this.label13.AutoSize = true; - this.label13.Location = new System.Drawing.Point(21, 620); - this.label13.Name = "label13"; - this.label13.Size = new System.Drawing.Size(522, 13); - this.label13.TabIndex = 20; - this.label13.Text = "Wouldnt it be cool if you could edit the disc by deleting and moving and adding t" + - "racks and such .. yeahhhhhh"; - // - // lblMagicDragArea - // - this.lblMagicDragArea.AllowDrop = true; - this.lblMagicDragArea.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; - this.lblMagicDragArea.Location = new System.Drawing.Point(665, 384); - this.lblMagicDragArea.Name = "lblMagicDragArea"; - this.lblMagicDragArea.Size = new System.Drawing.Size(147, 70); - this.lblMagicDragArea.TabIndex = 21; - this.lblMagicDragArea.Text = "Drag a cue into the DRAG HERE FOR MAGIC area for magic"; - this.lblMagicDragArea.Click += new System.EventHandler(this.lblMagicDragArea_Click); - this.lblMagicDragArea.DragDrop += new System.Windows.Forms.DragEventHandler(this.handleDragDrop); - this.lblMagicDragArea.DragEnter += new System.Windows.Forms.DragEventHandler(this.handleDragEnter); - // - // DiscoHawkDialog - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(1151, 645); - this.Controls.Add(this.lblMagicDragArea); - this.Controls.Add(this.label13); - this.Controls.Add(this.label12); - this.Controls.Add(this.label11); - this.Controls.Add(this.btnExportCue); - this.Controls.Add(this.label10); - this.Controls.Add(this.treeView1); - this.Controls.Add(this.label9); - this.Controls.Add(this.groupBox2); - this.Controls.Add(this.btnPresetDaemonTools); - this.Controls.Add(this.btnPresetCanonical); - this.Controls.Add(this.label5); - this.Controls.Add(this.txtCuePreview); - this.Controls.Add(this.groupBox1); - this.Controls.Add(this.lvDiscs); - this.Controls.Add(this.btnAddDisc); - this.Name = "DiscoHawkDialog"; - this.Text = "DiscoHawkDialog"; - this.groupBox1.ResumeLayout(false); - this.tableLayoutPanel1.ResumeLayout(false); - this.tableLayoutPanel1.PerformLayout(); - this.panel1.ResumeLayout(false); - this.panel1.PerformLayout(); - this.panel2.ResumeLayout(false); - this.panel2.PerformLayout(); - this.groupBox2.ResumeLayout(false); - this.groupBox2.PerformLayout(); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.Button btnAddDisc; - private System.Windows.Forms.ListView lvDiscs; - private System.Windows.Forms.ColumnHeader columnHeader1; - private System.Windows.Forms.GroupBox groupBox1; - private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; - private System.Windows.Forms.Label label3; - private System.Windows.Forms.Label label2; - private System.Windows.Forms.Label label1; - private System.Windows.Forms.Label label4; - private System.Windows.Forms.Label lblSectors; - private System.Windows.Forms.Label lblSize; - private System.Windows.Forms.Label lblTracks; - private System.Windows.Forms.Label lblSessions; - private System.Windows.Forms.TextBox txtCuePreview; - private System.Windows.Forms.Label label5; - private System.Windows.Forms.CheckBox checkCueProp_OneBlobPerTrack; - private System.Windows.Forms.Label label6; - private System.Windows.Forms.Panel panel1; - private System.Windows.Forms.Panel panel2; - private System.Windows.Forms.Label label7; - private System.Windows.Forms.CheckBox checkCueProp_Annotations; - private System.Windows.Forms.Panel panel3; - private System.Windows.Forms.Button btnPresetCanonical; - private System.Windows.Forms.Button btnPresetDaemonTools; - private System.Windows.Forms.GroupBox groupBox2; - private System.Windows.Forms.Label label9; - private System.Windows.Forms.TreeView treeView1; - private System.Windows.Forms.Label label10; - private System.Windows.Forms.Button btnExportCue; - private System.Windows.Forms.Label label11; - private System.Windows.Forms.Label label12; - private System.Windows.Forms.Label label13; - private System.Windows.Forms.Label lblMagicDragArea; - } -} \ No newline at end of file diff --git a/BizHawk.Client.DiscoHawk/DiscoHawkDialog.cs b/BizHawk.Client.DiscoHawk/DiscoHawkDialog.cs deleted file mode 100644 index 14992bcf97..0000000000 --- a/BizHawk.Client.DiscoHawk/DiscoHawkDialog.cs +++ /dev/null @@ -1,224 +0,0 @@ -using System; -using System.Threading; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.IO; -using System.Linq; -using System.Text; -using System.Windows.Forms; - -using BizHawk.Emulation.DiscSystem; - -namespace BizHawk.Client.DiscoHawk -{ - public partial class DiscoHawkDialog : Form - { - public DiscoHawkDialog() - { - InitializeComponent(); - PresetCanonical(); - } - - private class DiscRecord - { - public Disc Disc; - public string BaseName; - } - - private void btnAddDisc_Click(object sender, EventArgs e) - { - OpenFileDialog ofd = new OpenFileDialog(); - ofd.Filter = "CUE files (*.cue)|*.cue|ISO files (*.iso)|*.iso"; - ofd.CheckFileExists = true; - ofd.CheckPathExists = true; - ofd.Multiselect = false; - if (ofd.ShowDialog() != DialogResult.OK) - return; - - Disc disc = Disc.FromCuePath(ofd.FileName, new CueBinPrefs()); - - string baseName = Path.GetFileName(ofd.FileName); - ListViewItem lvi = new ListViewItem(baseName); - DiscRecord dr = new DiscRecord(); - dr.Disc = disc; - dr.BaseName = baseName; - lvi.Tag = dr; - lvDiscs.SelectedIndices.Clear(); - lvDiscs.Items.Add(lvi); - lvDiscs.Items[lvDiscs.Items.Count-1].Selected = true; - } - - private void lvDiscs_SelectedIndexChanged(object sender, EventArgs e) - { - UnbindDisc(); - if (lvDiscs.SelectedIndices.Count != 0) - { - DiscRecord dr = (DiscRecord) lvDiscs.SelectedItems[0].Tag; - BindDisc(dr); - } - } - - void UnbindDisc() - { - btnExportCue.Enabled = false; - lblSessions.Text = ""; - lblTracks.Text = ""; - lblSectors.Text = ""; - lblSize.Text = ""; - } - - Disc boundDisc; - DiscRecord boundDiscRecord; - void BindDisc(DiscRecord discRecord) - { - Disc disc = discRecord.Disc; - boundDiscRecord = discRecord; - - DiscStructure toc = disc.ReadStructure(); - boundDisc = disc; - lblSessions.Text = toc.Sessions.Count.ToString(); - lblTracks.Text = toc.Sessions.Sum((ses) => ses.Tracks.Count).ToString(); - lblSectors.Text = string.Format("{0} ({1})", toc.LengthInSectors, toc.FriendlyLength.Value); - lblSize.Text = string.Format("{0:0.00} MB", toc.BinarySize / 1024.0 / 1024.0); - btnExportCue.Enabled = true; - UpdateCue(); - } - - void UpdateCue() - { - if (boundDisc == null) - { - txtCuePreview.Text = ""; - return; - } - - var cueBin = boundDisc.DumpCueBin(boundDiscRecord.BaseName, GetCuePrefs()); - txtCuePreview.Text = cueBin.cue.Replace("\n", "\r\n"); - } - - private void btnPresetCanonical_Click(object sender, EventArgs e) - { - PresetCanonical(); - } - void PresetCanonical() - { - checkCueProp_Annotations.Checked = false; - checkCueProp_OneBlobPerTrack.Checked = false; - } - - private void btnPresetDaemonTools_Click(object sender, EventArgs e) - { - PresetDaemonTools(); - } - void PresetDaemonTools() - { - checkCueProp_Annotations.Checked = false; - } - - private void checkCueProp_CheckedChanged(object sender, EventArgs e) - { - UpdateCue(); - } - - private void Form1_QueryContinueDrag(object sender, QueryContinueDragEventArgs e) - { - e.Action = DragAction.Continue; - } - - private void handleDragEnter(object sender, DragEventArgs e) - { - List files = validateDrop(e.Data); - if (files.Count > 0) - e.Effect = DragDropEffects.Link; - else e.Effect = DragDropEffects.None; - } - - private void handleDragDrop(object sender, DragEventArgs e) - { - List files = validateDrop(e.Data); - if (files.Count == 0) return; - try - { - foreach (var file in files) - { - Disc disc = Disc.FromCuePath(file, new CueBinPrefs()); - string baseName = Path.GetFileNameWithoutExtension(file); - baseName += "_hawked"; - var prefs = GetCuePrefs(); - prefs.ReallyDumpBin = true; - var cueBin = disc.DumpCueBin(baseName, GetCuePrefs()); - Dump(cueBin, Path.GetDirectoryName(file), prefs); - } - } - catch (Exception ex) - { - MessageBox.Show(ex.ToString(), "oops! error"); - throw; - } - } - - List validateDrop(IDataObject ido) - { - List ret = new List(); - string[] files = (string[])ido.GetData(System.Windows.Forms.DataFormats.FileDrop); - if (files == null) return new List(); - foreach (string str in files) - { - if (Path.GetExtension(str).ToUpper() != ".CUE") - { - return new List(); - } - ret.Add(str); - } - return ret; - } - - //bool Dump(CueBin cueBin, string directoryTo, CueBinPrefs prefs) - //{ - // ProgressReport pr = new ProgressReport(); - // Thread workThread = new Thread(() => - // { - // cueBin.Dump(directoryTo, prefs, pr); - // }); - - // ProgressDialog pd = new ProgressDialog(pr); - // pd.Show(this); - // this.Enabled = false; - // workThread.Start(); - // for (; ; ) - // { - // Application.DoEvents(); - // Thread.Sleep(10); - // if (workThread.ThreadState != ThreadState.Running) - // break; - // pd.Update(); - // } - // this.Enabled = true; - // pd.Dispose(); - // return !pr.CancelSignal; - //} - - private void btnExportCue_Click(object sender, EventArgs e) - { - SaveFileDialog sfd = new SaveFileDialog(); - sfd.Filter = "CUE files (*.cue)|*.cue"; - sfd.OverwritePrompt = true; - if (sfd.ShowDialog() != DialogResult.OK) - return; - string baseName = Path.GetFileNameWithoutExtension(sfd.FileName); - var prefs = GetCuePrefs(); - prefs.ReallyDumpBin = true; - var cueBin = boundDisc.DumpCueBin(baseName, prefs); - - Dump(cueBin, Path.GetDirectoryName(sfd.FileName), prefs); - } - - private void lblMagicDragArea_Click(object sender, EventArgs e) - { - - } - - } -} diff --git a/BizHawk.Client.DiscoHawk/DiscoHawkDialog.resx b/BizHawk.Client.DiscoHawk/DiscoHawkDialog.resx deleted file mode 100644 index 570069991b..0000000000 --- a/BizHawk.Client.DiscoHawk/DiscoHawkDialog.resx +++ /dev/null @@ -1,123 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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 - - - This stuff is front and center because it is a primary way of visualizing the data. But maybe not later (later it would be tree-and-list). Maybe then all these options and 'output cue preview' will move into another window that pops up when you chooes Export Cue+XXX - - \ No newline at end of file diff --git a/BizHawk.Client.DiscoHawk/ProgressDialog.Designer.cs b/BizHawk.Client.DiscoHawk/ProgressDialog.Designer.cs deleted file mode 100644 index 32d453e23c..0000000000 --- a/BizHawk.Client.DiscoHawk/ProgressDialog.Designer.cs +++ /dev/null @@ -1,85 +0,0 @@ -namespace BizHawk.Client.DiscoHawk -{ - partial class ProgressDialog - { - /// - /// 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.progressBar1 = new System.Windows.Forms.ProgressBar(); - this.btnCancel = new System.Windows.Forms.Button(); - this.lblMessage = new System.Windows.Forms.Label(); - this.SuspendLayout(); - // - // progressBar1 - // - this.progressBar1.Location = new System.Drawing.Point(12, 18); - this.progressBar1.Name = "progressBar1"; - this.progressBar1.Size = new System.Drawing.Size(353, 23); - this.progressBar1.TabIndex = 0; - // - // btnCancel - // - this.btnCancel.Location = new System.Drawing.Point(290, 63); - this.btnCancel.Name = "btnCancel"; - this.btnCancel.Size = new System.Drawing.Size(75, 23); - this.btnCancel.TabIndex = 1; - this.btnCancel.Text = "Cancel"; - this.btnCancel.UseVisualStyleBackColor = true; - this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); - // - // lblMessage - // - this.lblMessage.AutoSize = true; - this.lblMessage.Location = new System.Drawing.Point(12, 63); - this.lblMessage.Name = "lblMessage"; - this.lblMessage.Size = new System.Drawing.Size(31, 13); - this.lblMessage.TabIndex = 2; - this.lblMessage.Text = "Task"; - // - // ProgressDialog - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(377, 98); - this.ControlBox = false; - this.Controls.Add(this.lblMessage); - this.Controls.Add(this.btnCancel); - this.Controls.Add(this.progressBar1); - this.Name = "ProgressDialog"; - this.Text = "Progress"; - this.Load += new System.EventHandler(this.ProgressDialog_Load); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.ProgressBar progressBar1; - private System.Windows.Forms.Button btnCancel; - private System.Windows.Forms.Label lblMessage; - } -} \ No newline at end of file diff --git a/BizHawk.Client.DiscoHawk/ProgressDialog.cs b/BizHawk.Client.DiscoHawk/ProgressDialog.cs deleted file mode 100644 index b3c1e718ab..0000000000 --- a/BizHawk.Client.DiscoHawk/ProgressDialog.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Globalization; -using System.Linq; -using System.Text; -using System.Windows.Forms; - -using BizHawk.Emulation.DiscSystem; - -namespace BizHawk.Client.DiscoHawk -{ - public partial class ProgressDialog : Form - { - public ProgressDialog(ProgressReport pr) - { - InitializeComponent(); - this.pr = pr; - } - - ProgressReport pr; - - private void btnCancel_Click(object sender, EventArgs e) - { - btnCancel.Enabled = false; - pr.CancelSignal = true; - } - - new public void Update() - { - double curr = pr.ProgressCurrent; - double max = pr.ProgressEstimate; - if (pr.InfoPresent) - { - double value = curr/max*100; - int nValue = (int) value; - if (nValue < 0 || nValue > 100) - nValue = 0; - progressBar1.Value = nValue; - } - lblMessage.Text = pr.Message + " - " + progressBar1.Value.ToString(CultureInfo.CurrentCulture) + "%"; - } - - private void ProgressDialog_Load(object sender, EventArgs e) - { - - } - } -} diff --git a/BizHawk.Client.DiscoHawk/ProgressDialog.resx b/BizHawk.Client.DiscoHawk/ProgressDialog.resx deleted file mode 100644 index c7e0d4bdf1..0000000000 --- a/BizHawk.Client.DiscoHawk/ProgressDialog.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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.Common/BizHawk.Common.csproj b/BizHawk.Common/BizHawk.Common.csproj index f12762e3c5..f8ea1d611a 100644 --- a/BizHawk.Common/BizHawk.Common.csproj +++ b/BizHawk.Common/BizHawk.Common.csproj @@ -12,7 +12,5 @@ Condition=" '$(MachineRunAnalyzersDuringBuild)' != '' " /> - - diff --git a/BizHawk.Common/Extensions/BinaryReaderExtensions.cs b/BizHawk.Common/Extensions/BinaryReaderExtensions.cs deleted file mode 100644 index fde22c76ee..0000000000 --- a/BizHawk.Common/Extensions/BinaryReaderExtensions.cs +++ /dev/null @@ -1,234 +0,0 @@ -using System; -using System.Globalization; -using System.IO; -using System.Text; -using System.Security.Cryptography; - -namespace BizHawk.Common.BufferExtensions -{ - public static class BufferExtensions - { - public static void SaveAsHex(this byte[] buffer, TextWriter writer) - { - foreach (var b in buffer) - { - writer.Write("{0:X2}", b); - } - - writer.WriteLine(); - } - - public unsafe static void SaveAsHexFast(this byte[] buffer, TextWriter writer) - { - char* table = Util.HexConvPtr; - if (buffer.Length > 0) - { - 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]); - } - } - writer.WriteLine(); - } - - public static void SaveAsHex(this byte[] buffer, TextWriter writer, int length) - { - for (int i = 0; i < length; i++) - { - writer.Write("{0:X2}", buffer[i]); - } - writer.WriteLine(); - } - - public static void SaveAsHex(this short[] buffer, TextWriter writer) - { - foreach (var b in buffer) - { - writer.Write("{0:X4}", b); - } - writer.WriteLine(); - } - - public static void SaveAsHex(this ushort[] buffer, TextWriter writer) - { - foreach (var b in buffer) - { - writer.Write("{0:X4}", b); - } - writer.WriteLine(); - } - - public static void SaveAsHex(this int[] buffer, TextWriter writer) - { - foreach (int b in buffer) - { - writer.Write("{0:X8}", b); - } - writer.WriteLine(); - } - - public static void SaveAsHex(this uint[] buffer, TextWriter writer) - { - foreach (var b in buffer) - { - writer.Write("{0:X8}", b); - } - writer.WriteLine(); - } - - public static void ReadFromHex(this byte[] buffer, string hex) - { - if (hex.Length % 2 != 0) - { - throw new Exception("Hex value string does not appear to be properly formatted."); - } - - for (int i = 0; i < buffer.Length && i * 2 < hex.Length; i++) - { - var bytehex = "" + hex[i * 2] + hex[i * 2 + 1]; - buffer[i] = byte.Parse(bytehex, NumberStyles.HexNumber); - } - } - - public static unsafe void ReadFromHexFast(this byte[] buffer, string hex) - { - if (buffer.Length * 2 != hex.Length) - { - throw new Exception("Data size mismatch"); - } - - int count = buffer.Length; - fixed (byte* _dst = buffer) - fixed (char* _src = hex) - { - byte* dst = _dst; - char* src = _src; - while (count > 0) - { - // in my tests, replacing Hex2Int() with a 256 entry LUT slowed things down slightly - *dst++ = (byte)(Hex2Int(*src++) << 4 | Hex2Int(*src++)); - count--; - } - } - } - - public static void ReadFromHex(this short[] buffer, string hex) - { - if (hex.Length % 4 != 0) - { - throw new Exception("Hex value string does not appear to be properly formatted."); - } - - for (int i = 0; i < buffer.Length && i * 4 < hex.Length; i++) - { - var shorthex = "" + hex[i * 4] + hex[(i * 4) + 1] + hex[(i * 4) + 2] + hex[(i * 4) + 3]; - buffer[i] = short.Parse(shorthex, NumberStyles.HexNumber); - } - } - - public static void ReadFromHex(this ushort[] buffer, string hex) - { - if (hex.Length % 4 != 0) - { - throw new Exception("Hex value string does not appear to be properly formatted."); - } - - for (int i = 0; i < buffer.Length && i * 4 < hex.Length; i++) - { - var ushorthex = "" + hex[i * 4] + hex[(i * 4) + 1] + hex[(i * 4) + 2] + hex[(i * 4) + 3]; - buffer[i] = ushort.Parse(ushorthex, NumberStyles.HexNumber); - } - } - - public static void ReadFromHex(this int[] buffer, string hex) - { - if (hex.Length % 8 != 0) - { - throw new Exception("Hex value string does not appear to be properly formatted."); - } - - for (int i = 0; i < buffer.Length && i * 8 < hex.Length; i++) - { - //string inthex = "" + hex[i * 8] + hex[(i * 8) + 1] + hex[(i * 4) + 2] + hex[(i * 4) + 3] + hex[(i*4 - var inthex = hex.Substring(i * 8, 8); - buffer[i] = int.Parse(inthex, NumberStyles.HexNumber); - } - } - - /// - /// Converts bytes to an uppercase string of hex numbers in upper case without any spacing or anything - /// - public static string BytesToHexString(this byte[] bytes) - { - var sb = new StringBuilder(); - foreach (var b in bytes) - { - sb.AppendFormat("{0:X2}", b); - } - - return sb.ToString(); - } - - public static bool FindBytes(this byte[] array, byte[] pattern) - { - var fidx = 0; - int result = Array.FindIndex(array, 0, array.Length, (byte b) => - { - fidx = (b == pattern[fidx]) ? fidx + 1 : 0; - return (fidx == pattern.Length); - }); - - return (result >= pattern.Length - 1); - } - - public static string HashMD5(this byte[] data, int offset, int len) - { - using (var md5 = MD5.Create()) - { - md5.ComputeHash(data, offset, len); - return md5.Hash.BytesToHexString(); - } - } - - public static string HashMD5(this byte[] data) - { - return HashMD5(data, 0, data.Length); - } - - public static string HashSHA1(this byte[] data, int offset, int len) - { - using (var sha1 = SHA1.Create()) - { - sha1.ComputeHash(data, offset, len); - return sha1.Hash.BytesToHexString(); - } - } - - public static string HashSHA1(this byte[] data) - { - return HashSHA1(data, 0, data.Length); - } - - #region Helpers - - private static int Hex2Int(char c) - { - if (c <= '9') - { - return c - '0'; - } - - if (c <= 'F') - { - return c - '7'; - } - - return c - 'W'; - } - - #endregion - } -} diff --git a/BizHawk.Common/SuperGloballyUniqueID.cs b/BizHawk.Common/SuperGloballyUniqueID.cs deleted file mode 100644 index 97c720bc80..0000000000 --- a/BizHawk.Common/SuperGloballyUniqueID.cs +++ /dev/null @@ -1,19 +0,0 @@ -namespace BizHawk.Common -{ - using System; - using System.Diagnostics; - - internal static class SuperGloballyUniqueID - { - private static readonly string StaticPart = $"bizhawk-{Process.GetCurrentProcess().Id}-{Guid.NewGuid()}"; - - private static int ctr; - - public static string Next() - { - int myctr; - lock (typeof(SuperGloballyUniqueID)) myctr = ctr++; - return $"{StaticPart}-{myctr}"; - } - } -} diff --git a/BizHawk.Emulation.Common/BizHawk.Emulation.Common.csproj b/BizHawk.Emulation.Common/BizHawk.Emulation.Common.csproj index aa5aa3d589..cf9856f091 100644 --- a/BizHawk.Emulation.Common/BizHawk.Emulation.Common.csproj +++ b/BizHawk.Emulation.Common/BizHawk.Emulation.Common.csproj @@ -24,7 +24,4 @@ - - - diff --git a/BizHawk.Emulation.Common/Interfaces/IHookManager.cs b/BizHawk.Emulation.Common/Interfaces/IHookManager.cs deleted file mode 100644 index fec12c9b9d..0000000000 --- a/BizHawk.Emulation.Common/Interfaces/IHookManager.cs +++ /dev/null @@ -1,59 +0,0 @@ -using System; -using System.Collections.Generic; - -using BizHawk.Common; - -namespace BizHawk.Emulation.Common -{ - public interface IDebugHookReference - { - } - - public interface IDebugHookCallback - { - void Event(int address); - } - - public interface IDebugHookManager - { - IDebugHookReference Register(DebugEvent eventType, int address, int size, IDebugHookCallback cb); - void Unregister(IDebugHookReference hookReference); - } - - class BasicDebugHookManager - { - WorkingDictionary> database = new WorkingDictionary>(); - - class Reference : IDebugHookReference - { - public IDebugHookCallback cb; - public DebugEvent eventType; - public int address, size; - } - - public IDebugHookReference Register(DebugEvent eventType, int address, int size, IDebugHookCallback cb) - { - var r = new Reference(); - r.cb = cb; - r.eventType = eventType; - r.address = address; - r.size = size; - for (int i = 0; i < size; i++) - { - uint a = (uint)(address + i); - database[eventType][a].Add(r); - } - return r; - } - - public void Unregister(IDebugHookReference hookReference) - { - var hr = hookReference as Reference; - for (int i = 0; i < hr.size; i++) - { - uint a = (uint)(hr.address + i); - database[hr.eventType].Remove(a,hr); - } - } - } -} diff --git a/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj b/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj index 8d5193208c..ce4f2dce17 100644 --- a/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj +++ b/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj @@ -66,9 +66,6 @@ - - - diff --git a/BizHawk.Emulation.Cores/CPUs/MOS 6502X/6502XXX/6502XXX.sln b/BizHawk.Emulation.Cores/CPUs/MOS 6502X/6502XXX/6502XXX.sln deleted file mode 100644 index 8db457c27f..0000000000 --- a/BizHawk.Emulation.Cores/CPUs/MOS 6502X/6502XXX/6502XXX.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "6502XXX", "6502XXX.vcxproj", "{0EF7FBBC-3CA9-4121-AF6C-C46CD02354B4}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {0EF7FBBC-3CA9-4121-AF6C-C46CD02354B4}.Debug|Win32.ActiveCfg = Debug|Win32 - {0EF7FBBC-3CA9-4121-AF6C-C46CD02354B4}.Debug|Win32.Build.0 = Debug|Win32 - {0EF7FBBC-3CA9-4121-AF6C-C46CD02354B4}.Release|Win32.ActiveCfg = Release|Win32 - {0EF7FBBC-3CA9-4121-AF6C-C46CD02354B4}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/BizHawk.Emulation.Cores/CPUs/MOS 6502X/6502XXX/6502XXX.vcxproj b/BizHawk.Emulation.Cores/CPUs/MOS 6502X/6502XXX/6502XXX.vcxproj deleted file mode 100644 index cf67eb6ee6..0000000000 --- a/BizHawk.Emulation.Cores/CPUs/MOS 6502X/6502XXX/6502XXX.vcxproj +++ /dev/null @@ -1,92 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {0EF7FBBC-3CA9-4121-AF6C-C46CD02354B4} - Win32Proj - My6502XXX - - - - DynamicLibrary - true - Unicode - - - DynamicLibrary - false - true - Unicode - - - - - - - - - - - - - true - - - false - - - - - - Level3 - Disabled - WIN32;_DEBUG;_WINDOWS;_USRDLL;MY6502XXX_EXPORTS;%(PreprocessorDefinitions) - - - Windows - true - - - copy /y "$(TargetDir)$(TargetFileName)" "$(ProjectDir)..\..\..\..\output\dll\$(TargetFileName)" - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_WINDOWS;_USRDLL;MY6502XXX_EXPORTS;%(PreprocessorDefinitions) - - - Windows - true - true - true - - - copy /y "$(TargetDir)$(TargetFileName)" "$(ProjectDir)..\..\..\..\output\dll\$(TargetFileName)" - - - - - - - - - - - - - \ No newline at end of file diff --git a/BizHawk.Emulation.Cores/CPUs/MOS 6502X/6502XXX/6502XXX.vcxproj.filters b/BizHawk.Emulation.Cores/CPUs/MOS 6502X/6502XXX/6502XXX.vcxproj.filters deleted file mode 100644 index 41cfeacf23..0000000000 --- a/BizHawk.Emulation.Cores/CPUs/MOS 6502X/6502XXX/6502XXX.vcxproj.filters +++ /dev/null @@ -1,30 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Source Files - - - - - Header Files - - - Header Files - - - \ No newline at end of file diff --git a/BizHawk.Emulation.Cores/CPUs/MOS 6502X/6502XXX/Execute.cpp b/BizHawk.Emulation.Cores/CPUs/MOS 6502X/6502XXX/Execute.cpp deleted file mode 100644 index 8304f2c4ed..0000000000 --- a/BizHawk.Emulation.Cores/CPUs/MOS 6502X/6502XXX/Execute.cpp +++ /dev/null @@ -1,2595 +0,0 @@ -//http://nesdev.parodius.com/6502_cpu.txt - -#include - -#include "UopTable.cpp" - -typedef int8_t sbyte; -typedef uint8_t byte; -typedef uint16_t ushort; - -#include "TableNZ.h" - -const ushort NMIVector = 0xFFFA; -const ushort ResetVector = 0xFFFC; -const ushort BRKVector = 0xFFFE; -const ushort IRQVector = 0xFFFE; - -#ifdef __GNUC__ -#define INL __attribute__((always_inline)) -#else -#define INL -#endif - -template bool Bit(int b) -{ - return (b & (1 << index)) != 0; -} - -template bool Bit(byte b) -{ - return (b & (1 << index)) != 0; -} - -struct CPU -{ - int _anchor; - int _land0; - int _land1; - int _land2; - - // interface - void *_ReadMemory_Managed; - void *_DummyReadMemory_Managed; - void *_PeekMemory_Managed; - void *_WriteMemory_Managed; - void *_OnExecFetch_Managed; // this only calls when the first byte of an instruction is fetched. - void *_TraceCallback_Managed; // TODO - - byte (*ReadMemory)(ushort addr); - byte (*DummyReadMemory)(ushort addr); - byte (*PeekMemory)(ushort addr); - void (*WriteMemory)(ushort addr, byte val); - void (*OnExecFetch)(ushort addr); - - // config - bool BCD_Enabled; - bool debug; - - // state - byte A; - byte X; - byte Y; - //byte P; - /// Carry Flag - bool FlagC; - /// Zero Flag - bool FlagZ; - /// Interrupt Disable Flag - bool FlagI; - /// Decimal Mode Flag - bool FlagD; - /// Break Flag - bool FlagB; - /// T... Flag - bool FlagT; - /// Overflow Flag - bool FlagV; - /// Negative Flag - bool FlagN; - - ushort PC; - byte S; - - bool IRQ; - bool NMI; - bool RDY; - - int TotalExecutedCycles; - - //opcode bytes.. theoretically redundant with the temp variables? who knows. - int opcode; - byte opcode2, opcode3; - - int ea, alu_temp; //cpu internal temp variables - int mi; //microcode index - bool iflag_pending; //iflag must be stored after it is checked in some cases (CLI and SEI). - bool rdy_freeze; //true if the CPU must be frozen - - //tracks whether an interrupt condition has popped up recently. - //not sure if this is real or not but it helps with the branch_irq_hack - bool interrupt_pending; - bool branch_irq_hack; //see Uop.RelBranch_Stage3 for more details - - // transient state - byte value8, temp8; - ushort value16; - bool branch_taken; - bool my_iflag; - bool booltemp; - int tempint; - int lo, hi; - - - INL byte GetP() - { - byte ret = 0; - if (FlagC) ret |= 1; - if (FlagZ) ret |= 2; - if (FlagI) ret |= 4; - if (FlagD) ret |= 8; - if (FlagB) ret |= 16; - if (FlagT) ret |= 32; - if (FlagV) ret |= 64; - if (FlagN) ret |= 128; - return ret; - } - - - INL void SetP(byte value) - { - FlagC = (value & 1) != 0; - FlagZ = (value & 2) != 0; - FlagI = (value & 4) != 0; - FlagD = (value & 8) != 0; - FlagB = (value & 16) != 0; - FlagT = (value & 32) != 0; - FlagV = (value & 64) != 0; - FlagN = (value & 128) != 0; - } - - INL void NZ_V(byte value) - { - FlagZ = value == 0; - FlagN = (value & 0x80) != 0; - } - - - /* - void InitOpcodeHandlers() - { - //delegates arent faster than the switch. pretty sure. dont use it. - //opcodeHandlers = new Action[] { - // Unsupported,Fetch1, Fetch1_Real, Fetch2, Fetch3,FetchDummy, - // NOP,JSR,IncPC, - // Abs_WRITE_STA, Abs_WRITE_STX, Abs_WRITE_STY,Abs_WRITE_SAX,Abs_READ_BIT, Abs_READ_LDA, Abs_READ_LDY, Abs_READ_ORA, Abs_READ_LDX, Abs_READ_CMP, Abs_READ_ADC, Abs_READ_CPX, Abs_READ_SBC, Abs_READ_AND, Abs_READ_EOR, Abs_READ_CPY, Abs_READ_NOP, - // Abs_READ_LAX,Abs_RMW_Stage4, Abs_RMW_Stage6,Abs_RMW_Stage5_INC, Abs_RMW_Stage5_DEC, Abs_RMW_Stage5_LSR, Abs_RMW_Stage5_ROL, Abs_RMW_Stage5_ASL, Abs_RMW_Stage5_ROR,Abs_RMW_Stage5_SLO, Abs_RMW_Stage5_RLA, Abs_RMW_Stage5_SRE, Abs_RMW_Stage5_RRA, Abs_RMW_Stage5_DCP, Abs_RMW_Stage5_ISC, - // JMP_abs,ZpIdx_Stage3_X, ZpIdx_Stage3_Y,ZpIdx_RMW_Stage4, ZpIdx_RMW_Stage6,ZP_WRITE_STA, ZP_WRITE_STX, ZP_WRITE_STY, ZP_WRITE_SAX,ZP_RMW_Stage3, ZP_RMW_Stage5, - // ZP_RMW_DEC, ZP_RMW_INC, ZP_RMW_ASL, ZP_RMW_LSR, ZP_RMW_ROR, ZP_RMW_ROL,ZP_RMW_SLO, ZP_RMW_RLA, ZP_RMW_SRE, ZP_RMW_RRA, ZP_RMW_DCP, ZP_RMW_ISC, - // ZP_READ_EOR, ZP_READ_BIT, ZP_READ_ORA, ZP_READ_LDA, ZP_READ_LDY, ZP_READ_LDX, ZP_READ_CPX, ZP_READ_SBC, ZP_READ_CPY, ZP_READ_NOP, ZP_READ_ADC, ZP_READ_AND, ZP_READ_CMP, ZP_READ_LAX, - // IdxInd_Stage3, IdxInd_Stage4, IdxInd_Stage5,IdxInd_Stage6_READ_ORA, IdxInd_Stage6_READ_SBC, IdxInd_Stage6_READ_LDA, IdxInd_Stage6_READ_EOR, IdxInd_Stage6_READ_CMP, IdxInd_Stage6_READ_ADC, IdxInd_Stage6_READ_AND, - // IdxInd_Stage6_READ_LAX,IdxInd_Stage6_WRITE_STA, IdxInd_Stage6_WRITE_SAX,IdxInd_Stage6_RMW,IdxInd_Stage7_RMW_SLO, IdxInd_Stage7_RMW_RLA, IdxInd_Stage7_RMW_SRE, IdxInd_Stage7_RMW_RRA, IdxInd_Stage7_RMW_ISC, IdxInd_Stage7_RMW_DCP, - // IdxInd_Stage8_RMW,AbsIdx_Stage3_X, AbsIdx_Stage3_Y, AbsIdx_Stage4,AbsIdx_WRITE_Stage5_STA,AbsIdx_WRITE_Stage5_SHY, AbsIdx_WRITE_Stage5_SHX,AbsIdx_WRITE_Stage5_ERROR,AbsIdx_READ_Stage4, - // AbsIdx_READ_Stage5_LDA, AbsIdx_READ_Stage5_CMP, AbsIdx_READ_Stage5_SBC, AbsIdx_READ_Stage5_ADC, AbsIdx_READ_Stage5_EOR, AbsIdx_READ_Stage5_LDX, AbsIdx_READ_Stage5_AND, AbsIdx_READ_Stage5_ORA, AbsIdx_READ_Stage5_LDY, AbsIdx_READ_Stage5_NOP, - // AbsIdx_READ_Stage5_LAX,AbsIdx_READ_Stage5_ERROR,AbsIdx_RMW_Stage5, AbsIdx_RMW_Stage7,AbsIdx_RMW_Stage6_ROR, AbsIdx_RMW_Stage6_DEC, AbsIdx_RMW_Stage6_INC, AbsIdx_RMW_Stage6_ASL, AbsIdx_RMW_Stage6_LSR, AbsIdx_RMW_Stage6_ROL, - // AbsIdx_RMW_Stage6_SLO, AbsIdx_RMW_Stage6_RLA, AbsIdx_RMW_Stage6_SRE, AbsIdx_RMW_Stage6_RRA, AbsIdx_RMW_Stage6_DCP, AbsIdx_RMW_Stage6_ISC,IncS, DecS, - // PushPCL, PushPCH, PushP, PullP, PullPCL, PullPCH_NoInc, PushA, PullA_NoInc, PullP_NoInc,PushP_BRK, PushP_NMI, PushP_IRQ, PushP_Reset, PushDummy,FetchPCLVector, FetchPCHVector, - // Imp_ASL_A, Imp_ROL_A, Imp_ROR_A, Imp_LSR_A,Imp_SEC, Imp_CLI, Imp_SEI, Imp_CLD, Imp_CLC, Imp_CLV, Imp_SED,Imp_INY, Imp_DEY, Imp_INX, Imp_DEX,Imp_TSX, Imp_TXS, Imp_TAX, Imp_TAY, Imp_TYA, Imp_TXA, - // Imm_CMP, Imm_ADC, Imm_AND, Imm_SBC, Imm_ORA, Imm_EOR, Imm_CPY, Imm_CPX, Imm_ANC, Imm_ASR, Imm_ARR, Imm_LXA, Imm_AXS,Imm_LDA, Imm_LDX, Imm_LDY, - // Imm_Unsupported,NZ_X, NZ_Y, NZ_A,RelBranch_Stage2_BNE, RelBranch_Stage2_BPL, RelBranch_Stage2_BCC, RelBranch_Stage2_BCS, RelBranch_Stage2_BEQ, RelBranch_Stage2_BMI, RelBranch_Stage2_BVC, RelBranch_Stage2_BVS, - // RelBranch_Stage2, RelBranch_Stage3, RelBranch_Stage4,_Eor, _Bit, _Cpx, _Cpy, _Cmp, _Adc, _Sbc, _Ora, _And, _Anc, _Asr, _Arr, _Lxa, _Axs, - // AbsInd_JMP_Stage4, AbsInd_JMP_Stage5,IndIdx_Stage3, IndIdx_Stage4, IndIdx_READ_Stage5, IndIdx_WRITE_Stage5, - // IndIdx_WRITE_Stage6_STA, IndIdx_WRITE_Stage6_SHA,IndIdx_READ_Stage6_LDA, IndIdx_READ_Stage6_CMP, IndIdx_READ_Stage6_ORA, IndIdx_READ_Stage6_SBC, IndIdx_READ_Stage6_ADC, IndIdx_READ_Stage6_AND, IndIdx_READ_Stage6_EOR, - // IndIdx_READ_Stage6_LAX,IndIdx_RMW_Stage5,IndIdx_RMW_Stage6, IndIdx_RMW_Stage7_SLO, IndIdx_RMW_Stage7_RLA, IndIdx_RMW_Stage7_SRE, IndIdx_RMW_Stage7_RRA, IndIdx_RMW_Stage7_ISC, IndIdx_RMW_Stage7_DCP,IndIdx_RMW_Stage8, - // End,End_ISpecial,End_BranchSpecial,End_SuppressInterrupt, - //}; - } - */ - static const int VOP_Fetch1 = 256; - static const int VOP_RelativeStuff = 257; - static const int VOP_RelativeStuff2 = 258; - static const int VOP_RelativeStuff3 = 259; - static const int VOP_NMI = 260; - static const int VOP_IRQ = 261; - static const int VOP_RESET = 262; - static const int VOP_Fetch1_NoInterrupt = 263; - static const int VOP_NUM = 264; - - /* - bool Interrupted - { - get - { - return NMI || (IRQ && !FlagI); - } - } - */ - - INL void FetchDummy() - { - DummyReadMemory(PC); - } - - /* - void Execute(int cycles) - { - for (int i = 0; i < cycles; i++) - { - ExecuteOne(); - } - }*/ - - void Fetch1() - { - my_iflag = FlagI; - FlagI = iflag_pending; - if (!branch_irq_hack) - { - interrupt_pending = false; - if (NMI) - { - //if (TraceCallback != nullptr) - // TraceCallback("====NMI===="); - ea = NMIVector; - opcode = VOP_NMI; - NMI = false; - mi = 0; - ExecuteOneRetry(); - return; - } - else if (IRQ && !my_iflag) - { - //if (TraceCallback != nullptr) - // TraceCallback("====IRQ===="); - ea = IRQVector; - opcode = VOP_IRQ; - mi = 0; - ExecuteOneRetry(); - return; - } - } - Fetch1_Real(); - } - - INL void Fetch1_Real() - { - rdy_freeze = !RDY; - if (RDY) - { - //if (debug) Console.WriteLine(State()); - branch_irq_hack = false; - if (OnExecFetch != nullptr) OnExecFetch(PC); - //if (TraceCallback != nullptr) - // TraceCallback(State()); - opcode = ReadMemory(PC++); - mi = -1; - } - } - INL void Fetch2() - { - rdy_freeze = !RDY; - if (RDY) - { - opcode2 = ReadMemory(PC++); - } - } - INL void Fetch3() - { - rdy_freeze = !RDY; - if (RDY) - { - opcode3 = ReadMemory(PC++); - } - } - INL void PushPCH() - { - WriteMemory((ushort)(S-- + 0x100), (byte)(PC >> 8)); - } - INL void PushPCL() - { - WriteMemory((ushort)(S-- + 0x100), (byte)PC); - } - INL void PushP_BRK() - { - FlagB = true; - WriteMemory((ushort)(S-- + 0x100), GetP()); - FlagI = true; - ea = BRKVector; - - } - INL void PushP_IRQ() - { - FlagB = false; - WriteMemory((ushort)(S-- + 0x100), GetP()); - FlagI = true; - ea = IRQVector; - - } - INL void PushP_NMI() - { - FlagB = false; - WriteMemory((ushort)(S-- + 0x100), GetP()); - FlagI = true; //is this right? - ea = NMIVector; - - } - INL void PushP_Reset() - { - ea = ResetVector; - S--; - FlagI = true; - - } - INL void PushDummy() - { - S--; - - } - INL void FetchPCLVector() - { - rdy_freeze = !RDY; - if (RDY) - { - if (ea == BRKVector && FlagB && NMI) - { - NMI = false; - ea = NMIVector; - } - if (ea == IRQVector && !FlagB && NMI) - { - NMI = false; - ea = NMIVector; - } - alu_temp = ReadMemory((ushort)ea); - } - - } - INL void FetchPCHVector() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp += ReadMemory((ushort)(ea + 1)) << 8; - PC = (ushort)alu_temp; - } - - } - INL void Imp_INY() - { - rdy_freeze = !RDY; - if (RDY) - { - FetchDummy(); Y++; NZ_Y(); - } - } - INL void Imp_DEY() - { - rdy_freeze = !RDY; - if (RDY) - { - FetchDummy(); Y--; NZ_Y(); - } - } - INL void Imp_INX() - { - rdy_freeze = !RDY; - if (RDY) - { - FetchDummy(); X++; NZ_X(); - } - } - INL void Imp_DEX() - { - rdy_freeze = !RDY; - if (RDY) - { - FetchDummy(); X--; NZ_X(); - } - } - INL void NZ_A() - { - FlagZ = A == 0; - FlagN = (A & 0x80) != 0; - } - INL void NZ_X() - { - FlagZ = X == 0; - FlagN = (X & 0x80) != 0; - } - INL void NZ_Y() - { - FlagZ = Y == 0; - FlagN = (Y & 0x80) != 0; - } - INL void Imp_TSX() - { - rdy_freeze = !RDY; - if (RDY) - { - FetchDummy(); X = S; NZ_X(); - } - } - INL void Imp_TXS() - { - rdy_freeze = !RDY; - if (RDY) - { - FetchDummy(); S = X; - } - } - INL void Imp_TAX() - { - rdy_freeze = !RDY; - if (RDY) - { - FetchDummy(); X = A; NZ_X(); - } - } - INL void Imp_TAY() - { - rdy_freeze = !RDY; - if (RDY) - { - FetchDummy(); Y = A; NZ_Y(); - } - } - INL void Imp_TYA() - { - rdy_freeze = !RDY; - if (RDY) - { - FetchDummy(); A = Y; NZ_A(); - } - } - INL void Imp_TXA() - { - rdy_freeze = !RDY; - if (RDY) - { - FetchDummy(); A = X; NZ_A(); - } - - } - INL void Imp_SEI() - { - rdy_freeze = !RDY; - if (RDY) - { - FetchDummy(); iflag_pending = true; - } - } - INL void Imp_CLI() - { - rdy_freeze = !RDY; - if (RDY) - { - FetchDummy(); iflag_pending = false; - } - } - INL void Imp_SEC() - { - rdy_freeze = !RDY; - if (RDY) - { - FetchDummy(); FlagC = true; - } - } - INL void Imp_CLC() - { - rdy_freeze = !RDY; - if (RDY) - { - FetchDummy(); FlagC = false; - } - } - INL void Imp_SED() - { - rdy_freeze = !RDY; - if (RDY) - { - FetchDummy(); FlagD = true; - } - } - INL void Imp_CLD() - { - rdy_freeze = !RDY; - if (RDY) - { - FetchDummy(); FlagD = false; - } - } - INL void Imp_CLV() - { - rdy_freeze = !RDY; - if (RDY) - { - FetchDummy(); FlagV = false; - } - - } - INL void Abs_WRITE_STA() - { - WriteMemory((ushort)((opcode3 << 8) + opcode2), A); - } - INL void Abs_WRITE_STX() - { - WriteMemory((ushort)((opcode3 << 8) + opcode2), X); - } - INL void Abs_WRITE_STY() - { - WriteMemory((ushort)((opcode3 << 8) + opcode2), Y); - } - INL void Abs_WRITE_SAX() - { - WriteMemory((ushort)((opcode3 << 8) + opcode2), (byte)(X & A)); - - } - INL void ZP_WRITE_STA() - { - WriteMemory(opcode2, A); - } - INL void ZP_WRITE_STY() - { - WriteMemory(opcode2, Y); - } - INL void ZP_WRITE_STX() - { - WriteMemory(opcode2, X); - } - INL void ZP_WRITE_SAX() - { - WriteMemory(opcode2, (byte)(X & A)); - - } - INL void IndIdx_Stage3() - { - rdy_freeze = !RDY; - if (RDY) - { - ea = ReadMemory(opcode2); - } - - } - INL void IndIdx_Stage4() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ea + Y; - ea = (ReadMemory((byte)(opcode2 + 1)) << 8) - | ((alu_temp & 0xFF)); - } - - } - INL void IndIdx_WRITE_Stage5() - { - rdy_freeze = !RDY; - if (RDY) - { - ReadMemory((ushort)ea); - ea += (alu_temp >> 8) << 8; - } - - } - void IndIdx_READ_Stage5() - { - rdy_freeze = !RDY; - if (RDY) - { - if (!Bit<8>(alu_temp)) - { - mi++; - ExecuteOneRetry(); - return; - } - else - { - ReadMemory((ushort)ea); - ea = (ushort)(ea + 0x100); - } - } - } - INL void IndIdx_RMW_Stage5() - { - rdy_freeze = !RDY; - if (RDY) - { - if (Bit<8>(alu_temp)) - ea = (ushort)(ea + 0x100); - ReadMemory((ushort)ea); - } - - } - INL void IndIdx_WRITE_Stage6_STA() - { - WriteMemory((ushort)ea, A); - - } - INL void IndIdx_WRITE_Stage6_SHA() - { - WriteMemory((ushort)ea, (byte)(A & X & 7)); - - } - INL void IndIdx_READ_Stage6_LDA() - { - rdy_freeze = !RDY; - if (RDY) - { - A = ReadMemory((ushort)ea); - NZ_A(); - } - } - INL void IndIdx_READ_Stage6_CMP() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory((ushort)ea); - _Cmp(); - } - } - INL void IndIdx_READ_Stage6_AND() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory((ushort)ea); - _And(); - } - } - INL void IndIdx_READ_Stage6_EOR() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory((ushort)ea); - _Eor(); - } - } - INL void IndIdx_READ_Stage6_LAX() - { - rdy_freeze = !RDY; - if (RDY) - { - A = X = ReadMemory((ushort)ea); - NZ_A(); - } - } - INL void IndIdx_READ_Stage6_ADC() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory((ushort)ea); - _Adc(); - } - } - INL void IndIdx_READ_Stage6_SBC() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory((ushort)ea); - _Sbc(); - } - } - INL void IndIdx_READ_Stage6_ORA() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory((ushort)ea); - _Ora(); - } - } - INL void IndIdx_RMW_Stage6() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory((ushort)ea); - } - - } - INL void IndIdx_RMW_Stage7_SLO() - { - WriteMemory((ushort)ea, (byte)alu_temp); - value8 = (byte)alu_temp; - FlagC = (value8 & 0x80) != 0; - alu_temp = value8 = (byte)((value8 << 1)); - A |= value8; - NZ_A(); - } - INL void IndIdx_RMW_Stage7_SRE() - { - WriteMemory((ushort)ea, (byte)alu_temp); - value8 = (byte)alu_temp; - FlagC = (value8 & 1) != 0; - alu_temp = value8 = (byte)(value8 >> 1); - A ^= value8; - NZ_A(); - } - INL void IndIdx_RMW_Stage7_RRA() - { - WriteMemory((ushort)ea, (byte)alu_temp); - value8 = temp8 = (byte)alu_temp; - alu_temp = value8 = (byte)((value8 >> 1) | ((FlagC) << 7)); - FlagC = (temp8 & 1) != 0; - _Adc(); - } - INL void IndIdx_RMW_Stage7_ISC() - { - WriteMemory((ushort)ea, (byte)alu_temp); - value8 = temp8 = (byte)alu_temp; - alu_temp = value8 = (byte)(value8 + 1); - _Sbc(); - } - INL void IndIdx_RMW_Stage7_DCP() - { - WriteMemory((ushort)ea, (byte)alu_temp); - value8 = temp8 = (byte)alu_temp; - alu_temp = value8 = (byte)(value8 - 1); - FlagC = (temp8 & 1) != 0; - _Cmp(); - } - INL void IndIdx_RMW_Stage7_RLA() - { - WriteMemory((ushort)ea, (byte)alu_temp); - value8 = temp8 = (byte)alu_temp; - alu_temp = value8 = (byte)((value8 << 1) | (FlagC)); - FlagC = (temp8 & 0x80) != 0; - A &= value8; - NZ_A(); - } - INL void IndIdx_RMW_Stage8() - { - WriteMemory((ushort)ea, (byte)alu_temp); - - - } - INL void RelBranch_Stage2_BVS() - { - branch_taken = FlagV == true; - RelBranch_Stage2(); - } - INL void RelBranch_Stage2_BVC() - { - branch_taken = FlagV == false; - RelBranch_Stage2(); - } - INL void RelBranch_Stage2_BMI() - { - branch_taken = FlagN == true; - RelBranch_Stage2(); - } - INL void RelBranch_Stage2_BPL() - { - branch_taken = FlagN == false; - RelBranch_Stage2(); - } - INL void RelBranch_Stage2_BCS() - { - branch_taken = FlagC == true; - RelBranch_Stage2(); - } - INL void RelBranch_Stage2_BCC() - { - branch_taken = FlagC == false; - RelBranch_Stage2(); - } - INL void RelBranch_Stage2_BEQ() - { - branch_taken = FlagZ == true; - RelBranch_Stage2(); - } - INL void RelBranch_Stage2_BNE() - { - branch_taken = FlagZ == false; - RelBranch_Stage2(); - - } - INL void RelBranch_Stage2() - { - rdy_freeze = !RDY; - if (RDY) - { - opcode2 = ReadMemory(PC++); - if (branch_taken) - { - branch_taken = false; - //if the branch is taken, we enter a different bit of microcode to calculate the PC and complete the branch - opcode = VOP_RelativeStuff; - mi = -1; - } - } - - } - INL void RelBranch_Stage3() - { - FetchDummy(); - alu_temp = (byte)PC + (int)(sbyte)opcode2; - PC &= 0xFF00; - PC |= (ushort)((alu_temp & 0xFF)); - if (Bit<8>(alu_temp)) - { - //we need to carry the add, and then we'll be ready to fetch the next instruction - opcode = VOP_RelativeStuff2; - mi = -1; - } - else - { - //to pass cpu_interrupts_v2/5-branch_delays_irq we need to handle a quirk here - //if we decide to interrupt in the next cycle, this condition will cause it to get deferred by one instruction - if (!interrupt_pending) - branch_irq_hack = true; - } - - } - INL void RelBranch_Stage4() - { - FetchDummy(); - if (Bit<31>(alu_temp)) - PC = (ushort)(PC - 0x100); - else PC = (ushort)(PC + 0x100); - - - } - INL void NOP() - { - } - INL void DecS() - { - S--; - } - INL void IncS() - { - S++; - } - INL void JSR() - { - rdy_freeze = !RDY; - if (RDY) - { - PC = (ushort)((ReadMemory((ushort)(PC)) << 8) + opcode2); - } - } - INL void PullP() - { - rdy_freeze = !RDY; - if (RDY) - { - SetP(ReadMemory((ushort)(S++ + 0x100))); - FlagT = true; //force T always to remain true - } - - } - INL void PullPCL() - { - rdy_freeze = !RDY; - if (RDY) - { - PC &= 0xFF00; - PC |= ReadMemory((ushort)(S++ + 0x100)); - } - - } - INL void PullPCH_NoInc() - { - rdy_freeze = !RDY; - if (RDY) - { - PC &= 0xFF; - PC |= (ushort)(ReadMemory((ushort)(S + 0x100)) << 8); - } - - } - INL void Abs_READ_LDA() - { - rdy_freeze = !RDY; - if (RDY) - { - A = ReadMemory((ushort)((opcode3 << 8) + opcode2)); - NZ_A(); - } - } - INL void Abs_READ_LDY() - { - rdy_freeze = !RDY; - if (RDY) - { - Y = ReadMemory((ushort)((opcode3 << 8) + opcode2)); - NZ_Y(); - } - } - INL void Abs_READ_LDX() - { - rdy_freeze = !RDY; - if (RDY) - { - X = ReadMemory((ushort)((opcode3 << 8) + opcode2)); - NZ_X(); - } - } - INL void Abs_READ_BIT() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory((ushort)((opcode3 << 8) + opcode2)); - _Bit(); - } - } - INL void Abs_READ_LAX() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory((ushort)((opcode3 << 8) + opcode2)); - A = ReadMemory((ushort)((opcode3 << 8) + opcode2)); - X = A; - NZ_A(); - } - } - INL void Abs_READ_AND() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory((ushort)((opcode3 << 8) + opcode2)); - _And(); - } - } - INL void Abs_READ_EOR() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory((ushort)((opcode3 << 8) + opcode2)); - _Eor(); - } - } - INL void Abs_READ_ORA() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory((ushort)((opcode3 << 8) + opcode2)); - _Ora(); - } - } - INL void Abs_READ_ADC() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory((ushort)((opcode3 << 8) + opcode2)); - _Adc(); - } - } - INL void Abs_READ_CMP() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory((ushort)((opcode3 << 8) + opcode2)); - _Cmp(); - } - } - INL void Abs_READ_CPY() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory((ushort)((opcode3 << 8) + opcode2)); - _Cpy(); - } - } - INL void Abs_READ_NOP() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory((ushort)((opcode3 << 8) + opcode2)); - } - - } - INL void Abs_READ_CPX() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory((ushort)((opcode3 << 8) + opcode2)); - _Cpx(); - } - } - INL void Abs_READ_SBC() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory((ushort)((opcode3 << 8) + opcode2)); - _Sbc(); - } - - } - INL void ZpIdx_Stage3_X() - { - rdy_freeze = !RDY; - if (RDY) - { - ReadMemory(opcode2); - opcode2 = (byte)(opcode2 + X); //a bit sneaky to shove this into opcode2... but we can reuse all the zero page uops if we do that - } - - } - INL void ZpIdx_Stage3_Y() - { - rdy_freeze = !RDY; - if (RDY) - { - ReadMemory(opcode2); - opcode2 = (byte)(opcode2 + Y); //a bit sneaky to shove this into opcode2... but we can reuse all the zero page uops if we do that - } - - } - INL void ZpIdx_RMW_Stage4() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory(opcode2); - } - - } - INL void ZpIdx_RMW_Stage6() - { - WriteMemory(opcode2, (byte)alu_temp); - - - } - INL void ZP_READ_EOR() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory(opcode2); - _Eor(); - } - } - INL void ZP_READ_BIT() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory(opcode2); - _Bit(); - } - } - INL void ZP_READ_LDA() - { - rdy_freeze = !RDY; - if (RDY) - { - A = ReadMemory(opcode2); - NZ_A(); - } - } - INL void ZP_READ_LDY() - { - rdy_freeze = !RDY; - if (RDY) - { - Y = ReadMemory(opcode2); - NZ_Y(); - } - } - INL void ZP_READ_LDX() - { - rdy_freeze = !RDY; - if (RDY) - { - X = ReadMemory(opcode2); - NZ_X(); - } - } - INL void ZP_READ_LAX() - { - rdy_freeze = !RDY; - if (RDY) - { - //?? is this right?? - X = ReadMemory(opcode2); - A = X; - NZ_A(); - } - } - INL void ZP_READ_CPY() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory(opcode2); - _Cpy(); - } - } - INL void ZP_READ_CMP() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory(opcode2); - _Cmp(); - } - } - INL void ZP_READ_CPX() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory(opcode2); - _Cpx(); - } - } - INL void ZP_READ_ORA() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory(opcode2); - _Ora(); - } - } - INL void ZP_READ_NOP() - { - rdy_freeze = !RDY; - if (RDY) - { - ReadMemory(opcode2); //just a dummy - } - - } - INL void ZP_READ_SBC() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory(opcode2); - _Sbc(); - } - } - INL void ZP_READ_ADC() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory(opcode2); - _Adc(); - } - } - INL void ZP_READ_AND() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory(opcode2); - _And(); - } - - } - INL void _Cpx() - { - value8 = (byte)alu_temp; - value16 = (ushort)(X - value8); - FlagC = (X >= value8); - NZ_V((byte)value16); - - } - INL void _Cpy() - { - value8 = (byte)alu_temp; - value16 = (ushort)(Y - value8); - FlagC = (Y >= value8); - NZ_V((byte)value16); - - } - INL void _Cmp() - { - value8 = (byte)alu_temp; - value16 = (ushort)(A - value8); - FlagC = (A >= value8); - NZ_V((byte)value16); - - } - INL void _Bit() - { - FlagN = (alu_temp & 0x80) != 0; - FlagV = (alu_temp & 0x40) != 0; - FlagZ = (A & alu_temp) == 0; - - } - INL void _Eor() - { - A ^= (byte)alu_temp; - NZ_A(); - } - INL void _And() - { - A &= (byte)alu_temp; - NZ_A(); - } - INL void _Ora() - { - A |= (byte)alu_temp; - NZ_A(); - } - INL void _Anc() - { - A &= (byte)alu_temp; - FlagC = Bit<7>(A); - NZ_A(); - } - INL void _Asr() - { - A &= (byte)alu_temp; - FlagC = Bit<0>(A); - A >>= 1; - NZ_A(); - } - INL void _Axs() - { - X &= A; - alu_temp = X - (byte)alu_temp; - X = (byte)alu_temp; - FlagC = !Bit<8>(alu_temp); - NZ_X(); - } - INL void _Arr() - { - { - A &= (byte)alu_temp; - booltemp = Bit<0>(A); - A = (byte)((A >> 1) | (FlagC ? 0x80 : 0x00)); - FlagC = booltemp; - if (Bit<5>(A)) - if (Bit<6>(A)) - { FlagC = true; FlagV = false; } - else { FlagV = true; FlagC = false; } - else if (Bit<6>(A)) - { FlagV = true; FlagC = true; } - else { FlagV = false; FlagC = false; } - FlagZ = (A == 0); - - } - } - INL void _Lxa() - { - A |= 0xFF; //there is some debate about what this should be. it may depend on the 6502 variant. this is suggested by qeed's doc for the nes and passes blargg's instruction test - A &= (byte)alu_temp; - X = A; - NZ_A(); - } - INL void _Sbc() - { - { - value8 = (byte)alu_temp; - tempint = A - value8 - (FlagC ? 0 : 1); - if (FlagD && BCD_Enabled) - { - lo = (A & 0x0F) - (value8 & 0x0F) - (FlagC ? 0 : 1); - hi = (A & 0xF0) - (value8 & 0xF0); - if ((lo & 0xF0) != 0) lo -= 0x06; - if ((lo & 0x80) != 0) hi -= 0x10; - if ((hi & 0x0F00) != 0) hi -= 0x60; - FlagV = ((A ^ value8) & (A ^ tempint) & 0x80) != 0; - FlagC = (hi & 0xFF00) == 0; - A = (byte)((lo & 0x0F) | (hi & 0xF0)); - } - else - { - FlagV = ((A ^ value8) & (A ^ tempint) & 0x80) != 0; - FlagC = tempint >= 0; - A = (byte)tempint; - } - NZ_A(); - } - } - INL void _Adc() - { - { - //TODO - an extra cycle penalty? - value8 = (byte)alu_temp; - if (FlagD && BCD_Enabled) - { - lo = (A & 0x0F) + (value8 & 0x0F) + (FlagC ? 1 : 0); - hi = (A & 0xF0) + (value8 & 0xF0); - if (lo > 0x09) - { - hi += 0x10; - lo += 0x06; - } - if (hi > 0x90) hi += 0x60; - FlagV = (~(A ^ value8) & (A ^ hi) & 0x80) != 0; - FlagC = hi > 0xFF; - A = (byte)((lo & 0x0F) | (hi & 0xF0)); - } - else - { - tempint = value8 + A + (FlagC ? 1 : 0); - FlagV = (~(A ^ value8) & (A ^ tempint) & 0x80) != 0; - FlagC = tempint > 0xFF; - A = (byte)tempint; - } - NZ_A(); - } - - } - INL void Unsupported() - { - - - } - INL void Imm_EOR() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory(PC++); - _Eor(); - } - } - INL void Imm_ANC() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory(PC++); - _Anc(); - } - } - INL void Imm_ASR() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory(PC++); - _Asr(); - } - } - INL void Imm_AXS() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory(PC++); - _Axs(); - } - } - INL void Imm_ARR() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory(PC++); - _Arr(); - } - } - INL void Imm_LXA() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory(PC++); - _Lxa(); - } - } - INL void Imm_ORA() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory(PC++); - _Ora(); - } - } - INL void Imm_CPY() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory(PC++); - _Cpy(); - } - } - INL void Imm_CPX() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory(PC++); - _Cpx(); - } - } - INL void Imm_CMP() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory(PC++); - _Cmp(); - } - } - INL void Imm_SBC() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory(PC++); - _Sbc(); - } - } - INL void Imm_AND() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory(PC++); - _And(); - } - } - INL void Imm_ADC() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory(PC++); - _Adc(); - } - } - INL void Imm_LDA() - { - rdy_freeze = !RDY; - if (RDY) - { - A = ReadMemory(PC++); - NZ_A(); - } - } - INL void Imm_LDX() - { - rdy_freeze = !RDY; - if (RDY) - { - X = ReadMemory(PC++); - NZ_X(); - } - } - INL void Imm_LDY() - { - rdy_freeze = !RDY; - if (RDY) - { - Y = ReadMemory(PC++); - NZ_Y(); - } - } - INL void Imm_Unsupported() - { - rdy_freeze = !RDY; - if (RDY) - { - ReadMemory(PC++); - } - - } - INL void IdxInd_Stage3() - { - rdy_freeze = !RDY; - if (RDY) - { - ReadMemory(opcode2); //dummy? - alu_temp = (opcode2 + X) & 0xFF; - } - - } - INL void IdxInd_Stage4() - { - rdy_freeze = !RDY; - if (RDY) - { - ea = ReadMemory((ushort)alu_temp); - } - - } - INL void IdxInd_Stage5() - { - rdy_freeze = !RDY; - if (RDY) - { - ea += (ReadMemory((byte)(alu_temp + 1)) << 8); - } - - } - INL void IdxInd_Stage6_READ_LDA() - { - rdy_freeze = !RDY; - if (RDY) - { - //TODO make uniform with others - A = ReadMemory((ushort)ea); - NZ_A(); - } - } - INL void IdxInd_Stage6_READ_ORA() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory((ushort)ea); - _Ora(); - } - } - INL void IdxInd_Stage6_READ_LAX() - { - rdy_freeze = !RDY; - if (RDY) - { - A = X = ReadMemory((ushort)ea); - NZ_A(); - } - } - INL void IdxInd_Stage6_READ_CMP() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory((ushort)ea); - _Cmp(); - } - } - INL void IdxInd_Stage6_READ_ADC() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory((ushort)ea); - _Adc(); - } - } - INL void IdxInd_Stage6_READ_AND() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory((ushort)ea); - _And(); - } - } - INL void IdxInd_Stage6_READ_EOR() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory((ushort)ea); - _Eor(); - } - } - INL void IdxInd_Stage6_READ_SBC() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory((ushort)ea); - _Sbc(); - } - } - INL void IdxInd_Stage6_WRITE_STA() - { - WriteMemory((ushort)ea, A); - - } - INL void IdxInd_Stage6_WRITE_SAX() - { - alu_temp = A & X; - WriteMemory((ushort)ea, (byte)alu_temp); - //flag writing skipped on purpose - - } - INL void IdxInd_Stage6_RMW() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory((ushort)ea); - } - - } - INL void IdxInd_Stage7_RMW_SLO() - { - WriteMemory((ushort)ea, (byte)alu_temp); - value8 = (byte)alu_temp; - FlagC = (value8 & 0x80) != 0; - alu_temp = value8 = (byte)((value8 << 1)); - A |= value8; - NZ_A(); - } - INL void IdxInd_Stage7_RMW_ISC() - { - WriteMemory((ushort)ea, (byte)alu_temp); - value8 = (byte)alu_temp; - alu_temp = value8 = (byte)(value8 + 1); - _Sbc(); - } - INL void IdxInd_Stage7_RMW_DCP() - { - WriteMemory((ushort)ea, (byte)alu_temp); - value8 = temp8 = (byte)alu_temp; - alu_temp = value8 = (byte)(value8 - 1); - FlagC = (temp8 & 1) != 0; - _Cmp(); - } - INL void IdxInd_Stage7_RMW_SRE() - { - WriteMemory((ushort)ea, (byte)alu_temp); - value8 = (byte)alu_temp; - FlagC = (value8 & 1) != 0; - alu_temp = value8 = (byte)(value8 >> 1); - A ^= value8; - NZ_A(); - } - INL void IdxInd_Stage7_RMW_RRA() - { - WriteMemory((ushort)ea, (byte)alu_temp); - value8 = (byte)alu_temp; - value8 = temp8 = (byte)alu_temp; - alu_temp = value8 = (byte)((value8 >> 1) | ((FlagC) << 7)); - FlagC = (temp8 & 1) != 0; - _Adc(); - } - INL void IdxInd_Stage7_RMW_RLA() - { - WriteMemory((ushort)ea, (byte)alu_temp); - value8 = temp8 = (byte)alu_temp; - alu_temp = value8 = (byte)((value8 << 1) | (FlagC)); - FlagC = (temp8 & 0x80) != 0; - A &= value8; - NZ_A(); - } - INL void IdxInd_Stage8_RMW() - { - WriteMemory((ushort)ea, (byte)alu_temp); - - - } - INL void PushP() - { - FlagB = true; - WriteMemory((ushort)(S-- + 0x100), GetP()); - - } - INL void PushA() - { - WriteMemory((ushort)(S-- + 0x100), A); - } - INL void PullA_NoInc() - { - rdy_freeze = !RDY; - if (RDY) - { - A = ReadMemory((ushort)(S + 0x100)); - NZ_A(); - } - } - INL void PullP_NoInc() - { - rdy_freeze = !RDY; - if (RDY) - { - my_iflag = FlagI; - SetP(ReadMemory((ushort)(S + 0x100))); - iflag_pending = FlagI; - FlagI = my_iflag; - FlagT = true; //force T always to remain true - - } - - } - INL void Imp_ASL_A() - { - FetchDummy(); - FlagC = (A & 0x80) != 0; - A = (byte)(A << 1); - NZ_A(); - } - INL void Imp_ROL_A() - { - FetchDummy(); - temp8 = A; - A = (byte)((A << 1) | (FlagC)); - FlagC = (temp8 & 0x80) != 0; - NZ_A(); - } - INL void Imp_ROR_A() - { - FetchDummy(); - temp8 = A; - A = (byte)((A >> 1) | ((FlagC) << 7)); - FlagC = (temp8 & 1) != 0; - NZ_A(); - } - INL void Imp_LSR_A() - { - FetchDummy(); - FlagC = (A & 1) != 0; - A = (byte)(A >> 1); - NZ_A(); - - } - INL void JMP_abs() - { - rdy_freeze = !RDY; - if (RDY) - { - PC = (ushort)((ReadMemory(PC) << 8) + opcode2); - } - - } - INL void IncPC() - { - PC++; - - - } - INL void ZP_RMW_Stage3() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory(opcode2); - } - - } - INL void ZP_RMW_Stage5() - { - WriteMemory(opcode2, (byte)alu_temp); - - } - INL void ZP_RMW_INC() - { - WriteMemory(opcode2, (byte)alu_temp); - alu_temp = (byte)((alu_temp + 1) & 0xFF); - NZ_V((byte)alu_temp); - - } - INL void ZP_RMW_DEC() - { - WriteMemory(opcode2, (byte)alu_temp); - alu_temp = (byte)((alu_temp - 1) & 0xFF); - NZ_V((byte)alu_temp); - - } - INL void ZP_RMW_ASL() - { - WriteMemory(opcode2, (byte)alu_temp); - value8 = (byte)alu_temp; - FlagC = (value8 & 0x80) != 0; - alu_temp = value8 = (byte)(value8 << 1); - NZ_V((byte)value8); - - } - INL void ZP_RMW_SRE() - { - WriteMemory(opcode2, (byte)alu_temp); - value8 = (byte)alu_temp; - FlagC = (value8 & 1) != 0; - alu_temp = value8 = (byte)(value8 >> 1); - A ^= value8; - NZ_A(); - } - INL void ZP_RMW_RRA() - { - WriteMemory(opcode2, (byte)alu_temp); - value8 = temp8 = (byte)alu_temp; - alu_temp = value8 = (byte)((value8 >> 1) | ((FlagC) << 7)); - FlagC = (temp8 & 1) != 0; - _Adc(); - } - INL void ZP_RMW_DCP() - { - WriteMemory(opcode2, (byte)alu_temp); - value8 = temp8 = (byte)alu_temp; - alu_temp = value8 = (byte)(value8 - 1); - FlagC = (temp8 & 1) != 0; - _Cmp(); - } - INL void ZP_RMW_LSR() - { - WriteMemory(opcode2, (byte)alu_temp); - value8 = (byte)alu_temp; - FlagC = (value8 & 1) != 0; - alu_temp = value8 = (byte)(value8 >> 1); - NZ_V((byte)value8); - - } - INL void ZP_RMW_ROR() - { - WriteMemory(opcode2, (byte)alu_temp); - value8 = temp8 = (byte)alu_temp; - alu_temp = value8 = (byte)((value8 >> 1) | ((FlagC) << 7)); - FlagC = (temp8 & 1) != 0; - NZ_V((byte)value8); - - } - INL void ZP_RMW_ROL() - { - WriteMemory(opcode2, (byte)alu_temp); - value8 = temp8 = (byte)alu_temp; - alu_temp = value8 = (byte)((value8 << 1) | (FlagC)); - FlagC = (temp8 & 0x80) != 0; - NZ_V((byte)value8); - - } - INL void ZP_RMW_SLO() - { - WriteMemory(opcode2, (byte)alu_temp); - value8 = (byte)alu_temp; - FlagC = (value8 & 0x80) != 0; - alu_temp = value8 = (byte)((value8 << 1)); - A |= value8; - NZ_A(); - } - INL void ZP_RMW_ISC() - { - WriteMemory(opcode2, (byte)alu_temp); - value8 = (byte)alu_temp; - alu_temp = value8 = (byte)(value8 + 1); - _Sbc(); - } - INL void ZP_RMW_RLA() - { - WriteMemory(opcode2, (byte)alu_temp); - value8 = temp8 = (byte)alu_temp; - alu_temp = value8 = (byte)((value8 << 1) | (FlagC)); - FlagC = (temp8 & 0x80) != 0; - A &= value8; - NZ_A(); - - } - INL void AbsIdx_Stage3_Y() - { - rdy_freeze = !RDY; - if (RDY) - { - opcode3 = ReadMemory(PC++); - alu_temp = opcode2 + Y; - ea = (opcode3 << 8) + (alu_temp & 0xFF); - - //new Uop[] { Uop.Fetch2, Uop.AbsIdx_Stage3_Y, Uop.AbsIdx_Stage4, Uop.AbsIdx_WRITE_Stage5_STA, Uop.End }, - } - } - INL void AbsIdx_Stage3_X() - { - rdy_freeze = !RDY; - if (RDY) - { - opcode3 = ReadMemory(PC++); - alu_temp = opcode2 + X; - ea = (opcode3 << 8) + (alu_temp & 0xFF); - } - - } - void AbsIdx_READ_Stage4() - { - rdy_freeze = !RDY; - if (RDY) - { - if (!Bit<8>(alu_temp)) - { - mi++; - ExecuteOneRetry(); - return; - } - else - { - alu_temp = ReadMemory((ushort)ea); - ea = (ushort)(ea + 0x100); - } - } - - } - INL void AbsIdx_Stage4() - { - rdy_freeze = !RDY; - if (RDY) - { - //bleh.. redundant code to make sure we dont clobber alu_temp before using it to decide whether to change ea - if (Bit<8>(alu_temp)) - { - alu_temp = ReadMemory((ushort)ea); - ea = (ushort)(ea + 0x100); - } - else alu_temp = ReadMemory((ushort)ea); - } - - } - INL void AbsIdx_WRITE_Stage5_STA() - { - WriteMemory((ushort)ea, A); - - } - INL void AbsIdx_WRITE_Stage5_SHY() - { - alu_temp = Y & (ea >> 8); - ea = (ea & 0xFF) | (alu_temp << 8); //"(the bank where the value is stored may be equal to the value stored)" -- more like IS. - WriteMemory((ushort)ea, (byte)alu_temp); - - } - INL void AbsIdx_WRITE_Stage5_SHX() - { - alu_temp = X & (ea >> 8); - ea = (ea & 0xFF) | (alu_temp << 8); //"(the bank where the value is stored may be equal to the value stored)" -- more like IS. - WriteMemory((ushort)ea, (byte)alu_temp); - - } - INL void AbsIdx_WRITE_Stage5_ERROR() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory((ushort)ea); - //throw new InvalidOperationException("UNSUPPORTED OPCODE [probably SHS] PLEASE REPORT"); - } - - } - INL void AbsIdx_RMW_Stage5() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory((ushort)ea); - } - - } - INL void AbsIdx_RMW_Stage7() - { - WriteMemory((ushort)ea, (byte)alu_temp); - - } - INL void AbsIdx_RMW_Stage6_DEC() - { - WriteMemory((ushort)ea, (byte)alu_temp); - alu_temp = value8 = (byte)(alu_temp - 1); - NZ_V((byte)value8); - - } - INL void AbsIdx_RMW_Stage6_DCP() - { - WriteMemory((ushort)ea, (byte)alu_temp); - alu_temp = value8 = (byte)(alu_temp - 1); - _Cmp(); - } - INL void AbsIdx_RMW_Stage6_ISC() - { - WriteMemory((ushort)ea, (byte)alu_temp); - alu_temp = value8 = (byte)(alu_temp + 1); - _Sbc(); - } - INL void AbsIdx_RMW_Stage6_INC() - { - WriteMemory((ushort)ea, (byte)alu_temp); - alu_temp = value8 = (byte)(alu_temp + 1); - NZ_V((byte)value8); - - } - INL void AbsIdx_RMW_Stage6_ROL() - { - WriteMemory((ushort)ea, (byte)alu_temp); - value8 = temp8 = (byte)alu_temp; - alu_temp = value8 = (byte)((value8 << 1) | (FlagC)); - FlagC = (temp8 & 0x80) != 0; - NZ_V((byte)value8); - - } - INL void AbsIdx_RMW_Stage6_LSR() - { - WriteMemory((ushort)ea, (byte)alu_temp); - value8 = (byte)alu_temp; - FlagC = (value8 & 1) != 0; - alu_temp = value8 = (byte)(value8 >> 1); - NZ_V((byte)value8); - - } - INL void AbsIdx_RMW_Stage6_SLO() - { - WriteMemory((ushort)ea, (byte)alu_temp); - value8 = (byte)alu_temp; - FlagC = (value8 & 0x80) != 0; - alu_temp = value8 = (byte)(value8 << 1); - A |= value8; - NZ_A(); - } - INL void AbsIdx_RMW_Stage6_SRE() - { - WriteMemory((ushort)ea, (byte)alu_temp); - value8 = (byte)alu_temp; - FlagC = (value8 & 1) != 0; - alu_temp = value8 = (byte)(value8 >> 1); - A ^= value8; - NZ_A(); - } - INL void AbsIdx_RMW_Stage6_RRA() - { - WriteMemory((ushort)ea, (byte)alu_temp); - value8 = temp8 = (byte)alu_temp; - alu_temp = value8 = (byte)((value8 >> 1) | ((FlagC) << 7)); - FlagC = (temp8 & 1) != 0; - _Adc(); - } - INL void AbsIdx_RMW_Stage6_RLA() - { - WriteMemory((ushort)ea, (byte)alu_temp); - value8 = temp8 = (byte)alu_temp; - alu_temp = value8 = (byte)((value8 << 1) | (FlagC)); - FlagC = (temp8 & 0x80) != 0; - A &= value8; - NZ_A(); - } - INL void AbsIdx_RMW_Stage6_ASL() - { - WriteMemory((ushort)ea, (byte)alu_temp); - value8 = (byte)alu_temp; - FlagC = (value8 & 0x80) != 0; - alu_temp = value8 = (byte)(value8 << 1); - NZ_V((byte)value8); - - } - INL void AbsIdx_RMW_Stage6_ROR() - { - WriteMemory((ushort)ea, (byte)alu_temp); - value8 = temp8 = (byte)alu_temp; - alu_temp = value8 = (byte)((value8 >> 1) | ((FlagC) << 7)); - FlagC = (temp8 & 1) != 0; - NZ_V((byte)value8); - - - } - INL void AbsIdx_READ_Stage5_LDA() - { - rdy_freeze = !RDY; - if (RDY) - { - A = ReadMemory((ushort)ea); - NZ_A(); - } - } - INL void AbsIdx_READ_Stage5_LDX() - { - rdy_freeze = !RDY; - if (RDY) - { - X = ReadMemory((ushort)ea); - NZ_X(); - } - } - INL void AbsIdx_READ_Stage5_LAX() - { - rdy_freeze = !RDY; - if (RDY) - { - A = ReadMemory((ushort)ea); - X = A; - NZ_A(); - } - } - INL void AbsIdx_READ_Stage5_LDY() - { - rdy_freeze = !RDY; - if (RDY) - { - Y = ReadMemory((ushort)ea); - NZ_Y(); - } - } - INL void AbsIdx_READ_Stage5_ORA() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory((ushort)ea); - _Ora(); - } - } - INL void AbsIdx_READ_Stage5_NOP() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory((ushort)ea); - } - - } - INL void AbsIdx_READ_Stage5_CMP() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory((ushort)ea); - _Cmp(); - } - } - INL void AbsIdx_READ_Stage5_SBC() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory((ushort)ea); - _Sbc(); - } - } - INL void AbsIdx_READ_Stage5_ADC() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory((ushort)ea); - _Adc(); - } - } - INL void AbsIdx_READ_Stage5_EOR() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory((ushort)ea); - _Eor(); - } - } - INL void AbsIdx_READ_Stage5_AND() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory((ushort)ea); - _And(); - } - } - INL void AbsIdx_READ_Stage5_ERROR() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory((ushort)ea); - //throw new InvalidOperationException("UNSUPPORTED OPCODE [probably LAS] PLEASE REPORT"); - } - - } - INL void AbsInd_JMP_Stage4() - { - rdy_freeze = !RDY; - if (RDY) - { - ea = (opcode3 << 8) + opcode2; - alu_temp = ReadMemory((ushort)ea); - } - } - INL void AbsInd_JMP_Stage5() - { - rdy_freeze = !RDY; - if (RDY) - { - ea = (opcode3 << 8) + (byte)(opcode2 + 1); - alu_temp += ReadMemory((ushort)ea) << 8; - PC = (ushort)alu_temp; - } - - } - INL void Abs_RMW_Stage4() - { - rdy_freeze = !RDY; - if (RDY) - { - ea = (opcode3 << 8) + opcode2; - alu_temp = ReadMemory((ushort)ea); - } - - } - INL void Abs_RMW_Stage5_INC() - { - WriteMemory((ushort)ea, (byte)alu_temp); - value8 = (byte)(alu_temp + 1); - alu_temp = value8; - NZ_V((byte)value8); - - } - INL void Abs_RMW_Stage5_DEC() - { - WriteMemory((ushort)ea, (byte)alu_temp); - value8 = (byte)(alu_temp - 1); - alu_temp = value8; - NZ_V((byte)value8); - - } - INL void Abs_RMW_Stage5_DCP() - { - WriteMemory((ushort)ea, (byte)alu_temp); - value8 = (byte)(alu_temp - 1); - alu_temp = value8; - _Cmp(); - } - INL void Abs_RMW_Stage5_ISC() - { - WriteMemory((ushort)ea, (byte)alu_temp); - value8 = (byte)(alu_temp + 1); - alu_temp = value8; - _Sbc(); - } - INL void Abs_RMW_Stage5_ASL() - { - WriteMemory((ushort)ea, (byte)alu_temp); - value8 = (byte)alu_temp; - FlagC = (value8 & 0x80) != 0; - alu_temp = value8 = (byte)(value8 << 1); - NZ_V((byte)value8); - - } - INL void Abs_RMW_Stage5_ROR() - { - WriteMemory((ushort)ea, (byte)alu_temp); - value8 = temp8 = (byte)alu_temp; - alu_temp = value8 = (byte)((value8 >> 1) | ((FlagC) << 7)); - FlagC = (temp8 & 1) != 0; - NZ_V((byte)value8); - - } - INL void Abs_RMW_Stage5_SLO() - { - WriteMemory((ushort)ea, (byte)alu_temp); - value8 = (byte)alu_temp; - FlagC = (value8 & 0x80) != 0; - alu_temp = value8 = (byte)(value8 << 1); - A |= value8; - NZ_A(); - } - INL void Abs_RMW_Stage5_RLA() - { - WriteMemory((ushort)ea, (byte)alu_temp); - value8 = temp8 = (byte)alu_temp; - alu_temp = value8 = (byte)((value8 << 1) | (FlagC)); - FlagC = (temp8 & 0x80) != 0; - A &= value8; - NZ_A(); - } - INL void Abs_RMW_Stage5_SRE() - { - WriteMemory((ushort)ea, (byte)alu_temp); - value8 = (byte)alu_temp; - FlagC = (value8 & 1) != 0; - alu_temp = value8 = (byte)(value8 >> 1); - A ^= value8; - NZ_A(); - } - INL void Abs_RMW_Stage5_RRA() - { - WriteMemory((ushort)ea, (byte)alu_temp); - value8 = temp8 = (byte)alu_temp; - alu_temp = value8 = (byte)((value8 >> 1) | ((FlagC) << 7)); - FlagC = (temp8 & 1) != 0; - _Adc(); - } - INL void Abs_RMW_Stage5_ROL() - { - WriteMemory((ushort)ea, (byte)alu_temp); - value8 = temp8 = (byte)alu_temp; - alu_temp = value8 = (byte)((value8 << 1) | (FlagC)); - FlagC = (temp8 & 0x80) != 0; - NZ_V((byte)value8); - - } - INL void Abs_RMW_Stage5_LSR() - { - WriteMemory((ushort)ea, (byte)alu_temp); - value8 = (byte)alu_temp; - FlagC = (value8 & 1) != 0; - alu_temp = value8 = (byte)(value8 >> 1); - NZ_V((byte)value8); - - - } - INL void Abs_RMW_Stage6() - { - WriteMemory((ushort)ea, (byte)alu_temp); - - - } - void End_ISpecial() - { - opcode = VOP_Fetch1; - mi = 0; - ExecuteOneRetry(); - return; - - } - void End_SuppressInterrupt() - { - opcode = VOP_Fetch1_NoInterrupt; - mi = 0; - ExecuteOneRetry(); - return; - - } - void End() - { - opcode = VOP_Fetch1; - mi = 0; - iflag_pending = FlagI; - ExecuteOneRetry(); - return; - } - void End_BranchSpecial() - { - End(); - } - - - void ExecuteOneRetry() - { - //dont know whether this system is any faster. hard to get benchmarks someone else try it? - //Uop uop = (Uop)CompiledMicrocode[MicrocodeIndex[opcode] + mi]; - Uop uop = Microcode[opcode][mi]; - switch (uop) - { - case Uop_Fetch1: Fetch1(); break; - case Uop_Fetch1_Real: Fetch1_Real(); break; - case Uop_Fetch2: Fetch2(); break; - case Uop_Fetch3: Fetch3(); break; - case Uop_FetchDummy: FetchDummy(); break; - case Uop_PushPCH: PushPCH(); break; - case Uop_PushPCL: PushPCL(); break; - case Uop_PushP_BRK: PushP_BRK(); break; - case Uop_PushP_IRQ: PushP_IRQ(); break; - case Uop_PushP_NMI: PushP_NMI(); break; - case Uop_PushP_Reset: PushP_Reset(); break; - case Uop_PushDummy: PushDummy(); break; - case Uop_FetchPCLVector: FetchPCLVector(); break; - case Uop_FetchPCHVector: FetchPCHVector(); break; - case Uop_Imp_INY: Imp_INY(); break; - case Uop_Imp_DEY: Imp_DEY(); break; - case Uop_Imp_INX: Imp_INX(); break; - case Uop_Imp_DEX: Imp_DEX(); break; - case Uop_NZ_A: NZ_A(); break; - case Uop_NZ_X: NZ_X(); break; - case Uop_NZ_Y: NZ_Y(); break; - case Uop_Imp_TSX: Imp_TSX(); break; - case Uop_Imp_TXS: Imp_TXS(); break; - case Uop_Imp_TAX: Imp_TAX(); break; - case Uop_Imp_TAY: Imp_TAY(); break; - case Uop_Imp_TYA: Imp_TYA(); break; - case Uop_Imp_TXA: Imp_TXA(); break; - case Uop_Imp_SEI: Imp_SEI(); break; - case Uop_Imp_CLI: Imp_CLI(); break; - case Uop_Imp_SEC: Imp_SEC(); break; - case Uop_Imp_CLC: Imp_CLC(); break; - case Uop_Imp_SED: Imp_SED(); break; - case Uop_Imp_CLD: Imp_CLD(); break; - case Uop_Imp_CLV: Imp_CLV(); break; - case Uop_Abs_WRITE_STA: Abs_WRITE_STA(); break; - case Uop_Abs_WRITE_STX: Abs_WRITE_STX(); break; - case Uop_Abs_WRITE_STY: Abs_WRITE_STY(); break; - case Uop_Abs_WRITE_SAX: Abs_WRITE_SAX(); break; - case Uop_ZP_WRITE_STA: ZP_WRITE_STA(); break; - case Uop_ZP_WRITE_STY: ZP_WRITE_STY(); break; - case Uop_ZP_WRITE_STX: ZP_WRITE_STX(); break; - case Uop_ZP_WRITE_SAX: ZP_WRITE_SAX(); break; - case Uop_IndIdx_Stage3: IndIdx_Stage3(); break; - case Uop_IndIdx_Stage4: IndIdx_Stage4(); break; - case Uop_IndIdx_WRITE_Stage5: IndIdx_WRITE_Stage5(); break; - case Uop_IndIdx_READ_Stage5: IndIdx_READ_Stage5(); break; - case Uop_IndIdx_RMW_Stage5: IndIdx_RMW_Stage5(); break; - case Uop_IndIdx_WRITE_Stage6_STA: IndIdx_WRITE_Stage6_STA(); break; - case Uop_IndIdx_WRITE_Stage6_SHA: IndIdx_WRITE_Stage6_SHA(); break; - case Uop_IndIdx_READ_Stage6_LDA: IndIdx_READ_Stage6_LDA(); break; - case Uop_IndIdx_READ_Stage6_CMP: IndIdx_READ_Stage6_CMP(); break; - case Uop_IndIdx_READ_Stage6_AND: IndIdx_READ_Stage6_AND(); break; - case Uop_IndIdx_READ_Stage6_EOR: IndIdx_READ_Stage6_EOR(); break; - case Uop_IndIdx_READ_Stage6_LAX: IndIdx_READ_Stage6_LAX(); break; - case Uop_IndIdx_READ_Stage6_ADC: IndIdx_READ_Stage6_ADC(); break; - case Uop_IndIdx_READ_Stage6_SBC: IndIdx_READ_Stage6_SBC(); break; - case Uop_IndIdx_READ_Stage6_ORA: IndIdx_READ_Stage6_ORA(); break; - case Uop_IndIdx_RMW_Stage6: IndIdx_RMW_Stage6(); break; - case Uop_IndIdx_RMW_Stage7_SLO: IndIdx_RMW_Stage7_SLO(); break; - case Uop_IndIdx_RMW_Stage7_SRE: IndIdx_RMW_Stage7_SRE(); break; - case Uop_IndIdx_RMW_Stage7_RRA: IndIdx_RMW_Stage7_RRA(); break; - case Uop_IndIdx_RMW_Stage7_ISC: IndIdx_RMW_Stage7_ISC(); break; - case Uop_IndIdx_RMW_Stage7_DCP: IndIdx_RMW_Stage7_DCP(); break; - case Uop_IndIdx_RMW_Stage7_RLA: IndIdx_RMW_Stage7_RLA(); break; - case Uop_IndIdx_RMW_Stage8: IndIdx_RMW_Stage8(); break; - case Uop_RelBranch_Stage2_BVS: RelBranch_Stage2_BVS(); break; - case Uop_RelBranch_Stage2_BVC: RelBranch_Stage2_BVC(); break; - case Uop_RelBranch_Stage2_BMI: RelBranch_Stage2_BMI(); break; - case Uop_RelBranch_Stage2_BPL: RelBranch_Stage2_BPL(); break; - case Uop_RelBranch_Stage2_BCS: RelBranch_Stage2_BCS(); break; - case Uop_RelBranch_Stage2_BCC: RelBranch_Stage2_BCC(); break; - case Uop_RelBranch_Stage2_BEQ: RelBranch_Stage2_BEQ(); break; - case Uop_RelBranch_Stage2_BNE: RelBranch_Stage2_BNE(); break; - case Uop_RelBranch_Stage2: RelBranch_Stage2(); break; - case Uop_RelBranch_Stage3: RelBranch_Stage3(); break; - case Uop_RelBranch_Stage4: RelBranch_Stage4(); break; - case Uop_NOP: NOP(); break; - case Uop_DecS: DecS(); break; - case Uop_IncS: IncS(); break; - case Uop_JSR: JSR(); break; - case Uop_PullP: PullP(); break; - case Uop_PullPCL: PullPCL(); break; - case Uop_PullPCH_NoInc: PullPCH_NoInc(); break; - case Uop_Abs_READ_LDA: Abs_READ_LDA(); break; - case Uop_Abs_READ_LDY: Abs_READ_LDY(); break; - case Uop_Abs_READ_LDX: Abs_READ_LDX(); break; - case Uop_Abs_READ_BIT: Abs_READ_BIT(); break; - case Uop_Abs_READ_LAX: Abs_READ_LAX(); break; - case Uop_Abs_READ_AND: Abs_READ_AND(); break; - case Uop_Abs_READ_EOR: Abs_READ_EOR(); break; - case Uop_Abs_READ_ORA: Abs_READ_ORA(); break; - case Uop_Abs_READ_ADC: Abs_READ_ADC(); break; - case Uop_Abs_READ_CMP: Abs_READ_CMP(); break; - case Uop_Abs_READ_CPY: Abs_READ_CPY(); break; - case Uop_Abs_READ_NOP: Abs_READ_NOP(); break; - case Uop_Abs_READ_CPX: Abs_READ_CPX(); break; - case Uop_Abs_READ_SBC: Abs_READ_SBC(); break; - case Uop_ZpIdx_Stage3_X: ZpIdx_Stage3_X(); break; - case Uop_ZpIdx_Stage3_Y: ZpIdx_Stage3_Y(); break; - case Uop_ZpIdx_RMW_Stage4: ZpIdx_RMW_Stage4(); break; - case Uop_ZpIdx_RMW_Stage6: ZpIdx_RMW_Stage6(); break; - case Uop_ZP_READ_EOR: ZP_READ_EOR(); break; - case Uop_ZP_READ_BIT: ZP_READ_BIT(); break; - case Uop_ZP_READ_LDA: ZP_READ_LDA(); break; - case Uop_ZP_READ_LDY: ZP_READ_LDY(); break; - case Uop_ZP_READ_LDX: ZP_READ_LDX(); break; - case Uop_ZP_READ_LAX: ZP_READ_LAX(); break; - case Uop_ZP_READ_CPY: ZP_READ_CPY(); break; - case Uop_ZP_READ_CMP: ZP_READ_CMP(); break; - case Uop_ZP_READ_CPX: ZP_READ_CPX(); break; - case Uop_ZP_READ_ORA: ZP_READ_ORA(); break; - case Uop_ZP_READ_NOP: ZP_READ_NOP(); break; - case Uop_ZP_READ_SBC: ZP_READ_SBC(); break; - case Uop_ZP_READ_ADC: ZP_READ_ADC(); break; - case Uop_ZP_READ_AND: ZP_READ_AND(); break; - case Uop__Cpx: _Cpx(); break; - case Uop__Cpy: _Cpy(); break; - case Uop__Cmp: _Cmp(); break; - case Uop__Eor: _Eor(); break; - case Uop__And: _And(); break; - case Uop__Ora: _Ora(); break; - case Uop__Anc: _Anc(); break; - case Uop__Asr: _Asr(); break; - case Uop__Axs: _Axs(); break; - case Uop__Arr: _Arr(); break; - case Uop__Lxa: _Lxa(); break; - case Uop__Sbc: _Sbc(); break; - case Uop__Adc: _Adc(); break; - case Uop_Unsupported: Unsupported(); break; - case Uop_Imm_EOR: Imm_EOR(); break; - case Uop_Imm_ANC: Imm_ANC(); break; - case Uop_Imm_ASR: Imm_ASR(); break; - case Uop_Imm_AXS: Imm_AXS(); break; - case Uop_Imm_ARR: Imm_ARR(); break; - case Uop_Imm_LXA: Imm_LXA(); break; - case Uop_Imm_ORA: Imm_ORA(); break; - case Uop_Imm_CPY: Imm_CPY(); break; - case Uop_Imm_CPX: Imm_CPX(); break; - case Uop_Imm_CMP: Imm_CMP(); break; - case Uop_Imm_SBC: Imm_SBC(); break; - case Uop_Imm_AND: Imm_AND(); break; - case Uop_Imm_ADC: Imm_ADC(); break; - case Uop_Imm_LDA: Imm_LDA(); break; - case Uop_Imm_LDX: Imm_LDX(); break; - case Uop_Imm_LDY: Imm_LDY(); break; - case Uop_Imm_Unsupported: Imm_Unsupported(); break; - case Uop_IdxInd_Stage3: IdxInd_Stage3(); break; - case Uop_IdxInd_Stage4: IdxInd_Stage4(); break; - case Uop_IdxInd_Stage5: IdxInd_Stage5(); break; - case Uop_IdxInd_Stage6_READ_LDA: IdxInd_Stage6_READ_LDA(); break; - case Uop_IdxInd_Stage6_READ_ORA: IdxInd_Stage6_READ_ORA(); break; - case Uop_IdxInd_Stage6_READ_LAX: IdxInd_Stage6_READ_LAX(); break; - case Uop_IdxInd_Stage6_READ_CMP: IdxInd_Stage6_READ_CMP(); break; - case Uop_IdxInd_Stage6_READ_ADC: IdxInd_Stage6_READ_ADC(); break; - case Uop_IdxInd_Stage6_READ_AND: IdxInd_Stage6_READ_AND(); break; - case Uop_IdxInd_Stage6_READ_EOR: IdxInd_Stage6_READ_EOR(); break; - case Uop_IdxInd_Stage6_READ_SBC: IdxInd_Stage6_READ_SBC(); break; - case Uop_IdxInd_Stage6_WRITE_STA: IdxInd_Stage6_WRITE_STA(); break; - case Uop_IdxInd_Stage6_WRITE_SAX: IdxInd_Stage6_WRITE_SAX(); break; - case Uop_IdxInd_Stage6_RMW: IdxInd_Stage6_RMW(); break; - case Uop_IdxInd_Stage7_RMW_SLO: IdxInd_Stage7_RMW_SLO(); break; - case Uop_IdxInd_Stage7_RMW_ISC: IdxInd_Stage7_RMW_ISC(); break; - case Uop_IdxInd_Stage7_RMW_DCP: IdxInd_Stage7_RMW_DCP(); break; - case Uop_IdxInd_Stage7_RMW_SRE: IdxInd_Stage7_RMW_SRE(); break; - case Uop_IdxInd_Stage7_RMW_RRA: IdxInd_Stage7_RMW_RRA(); break; - case Uop_IdxInd_Stage7_RMW_RLA: IdxInd_Stage7_RMW_RLA(); break; - case Uop_IdxInd_Stage8_RMW: IdxInd_Stage8_RMW(); break; - case Uop_PushP: PushP(); break; - case Uop_PushA: PushA(); break; - case Uop_PullA_NoInc: PullA_NoInc(); break; - case Uop_PullP_NoInc: PullP_NoInc(); break; - case Uop_Imp_ASL_A: Imp_ASL_A(); break; - case Uop_Imp_ROL_A: Imp_ROL_A(); break; - case Uop_Imp_ROR_A: Imp_ROR_A(); break; - case Uop_Imp_LSR_A: Imp_LSR_A(); break; - case Uop_JMP_abs: JMP_abs(); break; - case Uop_IncPC: IncPC(); break; - case Uop_ZP_RMW_Stage3: ZP_RMW_Stage3(); break; - case Uop_ZP_RMW_Stage5: ZP_RMW_Stage5(); break; - case Uop_ZP_RMW_INC: ZP_RMW_INC(); break; - case Uop_ZP_RMW_DEC: ZP_RMW_DEC(); break; - case Uop_ZP_RMW_ASL: ZP_RMW_ASL(); break; - case Uop_ZP_RMW_SRE: ZP_RMW_SRE(); break; - case Uop_ZP_RMW_RRA: ZP_RMW_RRA(); break; - case Uop_ZP_RMW_DCP: ZP_RMW_DCP(); break; - case Uop_ZP_RMW_LSR: ZP_RMW_LSR(); break; - case Uop_ZP_RMW_ROR: ZP_RMW_ROR(); break; - case Uop_ZP_RMW_ROL: ZP_RMW_ROL(); break; - case Uop_ZP_RMW_SLO: ZP_RMW_SLO(); break; - case Uop_ZP_RMW_ISC: ZP_RMW_ISC(); break; - case Uop_ZP_RMW_RLA: ZP_RMW_RLA(); break; - case Uop_AbsIdx_Stage3_Y: AbsIdx_Stage3_Y(); break; - case Uop_AbsIdx_Stage3_X: AbsIdx_Stage3_X(); break; - case Uop_AbsIdx_READ_Stage4: AbsIdx_READ_Stage4(); break; - case Uop_AbsIdx_Stage4: AbsIdx_Stage4(); break; - case Uop_AbsIdx_WRITE_Stage5_STA: AbsIdx_WRITE_Stage5_STA(); break; - case Uop_AbsIdx_WRITE_Stage5_SHY: AbsIdx_WRITE_Stage5_SHY(); break; - case Uop_AbsIdx_WRITE_Stage5_SHX: AbsIdx_WRITE_Stage5_SHX(); break; - case Uop_AbsIdx_WRITE_Stage5_ERROR: AbsIdx_WRITE_Stage5_ERROR(); break; - case Uop_AbsIdx_RMW_Stage5: AbsIdx_RMW_Stage5(); break; - case Uop_AbsIdx_RMW_Stage7: AbsIdx_RMW_Stage7(); break; - case Uop_AbsIdx_RMW_Stage6_DEC: AbsIdx_RMW_Stage6_DEC(); break; - case Uop_AbsIdx_RMW_Stage6_DCP: AbsIdx_RMW_Stage6_DCP(); break; - case Uop_AbsIdx_RMW_Stage6_ISC: AbsIdx_RMW_Stage6_ISC(); break; - case Uop_AbsIdx_RMW_Stage6_INC: AbsIdx_RMW_Stage6_INC(); break; - case Uop_AbsIdx_RMW_Stage6_ROL: AbsIdx_RMW_Stage6_ROL(); break; - case Uop_AbsIdx_RMW_Stage6_LSR: AbsIdx_RMW_Stage6_LSR(); break; - case Uop_AbsIdx_RMW_Stage6_SLO: AbsIdx_RMW_Stage6_SLO(); break; - case Uop_AbsIdx_RMW_Stage6_SRE: AbsIdx_RMW_Stage6_SRE(); break; - case Uop_AbsIdx_RMW_Stage6_RRA: AbsIdx_RMW_Stage6_RRA(); break; - case Uop_AbsIdx_RMW_Stage6_RLA: AbsIdx_RMW_Stage6_RLA(); break; - case Uop_AbsIdx_RMW_Stage6_ASL: AbsIdx_RMW_Stage6_ASL(); break; - case Uop_AbsIdx_RMW_Stage6_ROR: AbsIdx_RMW_Stage6_ROR(); break; - case Uop_AbsIdx_READ_Stage5_LDA: AbsIdx_READ_Stage5_LDA(); break; - case Uop_AbsIdx_READ_Stage5_LDX: AbsIdx_READ_Stage5_LDX(); break; - case Uop_AbsIdx_READ_Stage5_LAX: AbsIdx_READ_Stage5_LAX(); break; - case Uop_AbsIdx_READ_Stage5_LDY: AbsIdx_READ_Stage5_LDY(); break; - case Uop_AbsIdx_READ_Stage5_ORA: AbsIdx_READ_Stage5_ORA(); break; - case Uop_AbsIdx_READ_Stage5_NOP: AbsIdx_READ_Stage5_NOP(); break; - case Uop_AbsIdx_READ_Stage5_CMP: AbsIdx_READ_Stage5_CMP(); break; - case Uop_AbsIdx_READ_Stage5_SBC: AbsIdx_READ_Stage5_SBC(); break; - case Uop_AbsIdx_READ_Stage5_ADC: AbsIdx_READ_Stage5_ADC(); break; - case Uop_AbsIdx_READ_Stage5_EOR: AbsIdx_READ_Stage5_EOR(); break; - case Uop_AbsIdx_READ_Stage5_AND: AbsIdx_READ_Stage5_AND(); break; - case Uop_AbsIdx_READ_Stage5_ERROR: AbsIdx_READ_Stage5_ERROR(); break; - case Uop_AbsInd_JMP_Stage4: AbsInd_JMP_Stage4(); break; - case Uop_AbsInd_JMP_Stage5: AbsInd_JMP_Stage5(); break; - case Uop_Abs_RMW_Stage4: Abs_RMW_Stage4(); break; - case Uop_Abs_RMW_Stage5_INC: Abs_RMW_Stage5_INC(); break; - case Uop_Abs_RMW_Stage5_DEC: Abs_RMW_Stage5_DEC(); break; - case Uop_Abs_RMW_Stage5_DCP: Abs_RMW_Stage5_DCP(); break; - case Uop_Abs_RMW_Stage5_ISC: Abs_RMW_Stage5_ISC(); break; - case Uop_Abs_RMW_Stage5_ASL: Abs_RMW_Stage5_ASL(); break; - case Uop_Abs_RMW_Stage5_ROR: Abs_RMW_Stage5_ROR(); break; - case Uop_Abs_RMW_Stage5_SLO: Abs_RMW_Stage5_SLO(); break; - case Uop_Abs_RMW_Stage5_RLA: Abs_RMW_Stage5_RLA(); break; - case Uop_Abs_RMW_Stage5_SRE: Abs_RMW_Stage5_SRE(); break; - case Uop_Abs_RMW_Stage5_RRA: Abs_RMW_Stage5_RRA(); break; - case Uop_Abs_RMW_Stage5_ROL: Abs_RMW_Stage5_ROL(); break; - case Uop_Abs_RMW_Stage5_LSR: Abs_RMW_Stage5_LSR(); break; - case Uop_Abs_RMW_Stage6: Abs_RMW_Stage6(); break; - case Uop_End_ISpecial: End_ISpecial(); break; - case Uop_End_SuppressInterrupt: End_SuppressInterrupt(); break; - case Uop_End: End(); break; - case Uop_End_BranchSpecial: End_BranchSpecial(); break; - } - } - - __declspec(dllexport) void ExecuteOne() - { - if (!rdy_freeze) - { - TotalExecutedCycles++; - - interrupt_pending |= NMI || (IRQ && !FlagI); - } - rdy_freeze = false; - - //i tried making ExecuteOneRetry not re-entrant by having it set a flag instead, then exit from the call below, check the flag, and GOTO if it was flagged, but it wasnt faster - ExecuteOneRetry(); - - if (!rdy_freeze) - mi++; - } //ExecuteOne - -}; // struct CPU diff --git a/BizHawk.Emulation.Cores/CPUs/MOS 6502X/6502XXX/Old Managed Stuff/Execute.cs b/BizHawk.Emulation.Cores/CPUs/MOS 6502X/6502XXX/Old Managed Stuff/Execute.cs deleted file mode 100644 index 98dac152b9..0000000000 --- a/BizHawk.Emulation.Cores/CPUs/MOS 6502X/6502XXX/Old Managed Stuff/Execute.cs +++ /dev/null @@ -1,2912 +0,0 @@ -//http://nesdev.parodius.com/6502_cpu.txt - -using System; -using BizHawk.Common; -using BizHawk.Common.NumberExtensions; - -namespace BizHawk.Emulation.Cores.Components.M6502 -{ - public partial class MOS6502X - { - //dont know whether this system is any faster. hard to get benchmarks someone else try it? - //static ShortBuffer CompiledMicrocode; - //static ShortBuffer MicrocodeIndex; - //static MOS6502X() - //{ - // int index = 0; - // MicrocodeIndex = new ShortBuffer(VOP_NUM); - // List temp = new List(); - // for (int i = 0; i < VOP_NUM; i++) - // { - // MicrocodeIndex[i] = (short)index; - // int numUops = Microcode[i].Length; - // for (int j = 0; j < numUops; j++) - // temp.Add(Microcode[i][j]); - // index += numUops; - // } - // CompiledMicrocode = new ShortBuffer(temp.Count); - // for (int i = 0; i < temp.Count; i++) - // CompiledMicrocode[i] = (short)temp[i]; - //} - - static Uop[][] Microcode = new Uop[][] - { - //0x00 - /*BRK [implied]*/ new Uop[] { Uop.Fetch2, Uop.PushPCH, Uop.PushPCL, Uop.PushP_BRK, Uop.FetchPCLVector, Uop.FetchPCHVector, Uop.End_SuppressInterrupt }, - /*ORA (addr,X) [indexed indirect READ]*/ new Uop[] { Uop.Fetch2, Uop.IdxInd_Stage3, Uop.IdxInd_Stage4, Uop.IdxInd_Stage5, Uop.IdxInd_Stage6_READ_ORA, Uop.End }, - /*JAM*/ new Uop[] { Uop.End }, - /*SLO* (addr,X) [indexed indirect RMW] [unofficial]*/ new Uop[] { Uop.Fetch2, Uop.IdxInd_Stage3, Uop.IdxInd_Stage4, Uop.IdxInd_Stage5, Uop.IdxInd_Stage6_RMW, Uop.IdxInd_Stage7_RMW_SLO, Uop.IdxInd_Stage8_RMW, Uop.End }, - /*NOP zp [zero page READ]*/ new Uop[] { Uop.Fetch2, Uop.ZP_READ_NOP, Uop.End }, - /*ORA zp [zero page READ]*/ new Uop[] { Uop.Fetch2, Uop.ZP_READ_ORA, Uop.End }, - /*ASL zp [zero page RMW]*/ new Uop[] { Uop.Fetch2, Uop.ZP_RMW_Stage3, Uop.ZP_RMW_ASL, Uop.ZP_RMW_Stage5, Uop.End }, - /*SLO* zp [zero page RMW] [unofficial]*/ new Uop[] { Uop.Fetch2, Uop.ZP_RMW_Stage3, Uop.ZP_RMW_SLO, Uop.ZP_RMW_Stage5, Uop.End }, - /*PHP [implied]*/ new Uop[] { Uop.FetchDummy, Uop.PushP, Uop.End }, - /*ORA #nn [immediate]*/ new Uop[] { Uop.Imm_ORA, Uop.End }, - /*ASL A [accumulator]*/ new Uop[] { Uop.Imp_ASL_A, Uop.End }, - /*ANC** [immediate] [unofficial]*/ new Uop[] { Uop.Imm_ANC, Uop.End }, - /*NOP addr [absolute READ]*/ new Uop[] { Uop.Fetch2, Uop.Fetch3, Uop.Abs_READ_NOP, Uop.End }, - /*ORA addr [absolute READ]*/ new Uop[] { Uop.Fetch2, Uop.Fetch3, Uop.Abs_READ_ORA, Uop.End }, - /*ASL addr [absolute RMW]*/ new Uop[] { Uop.Fetch2, Uop.Fetch3, Uop.Abs_RMW_Stage4, Uop.Abs_RMW_Stage5_ASL, Uop.Abs_RMW_Stage6, Uop.End }, - /*SLO* addr [absolute RMW] [unofficial]*/ new Uop[] { Uop.Fetch2, Uop.Fetch3, Uop.Abs_RMW_Stage4, Uop.Abs_RMW_Stage5_SLO, Uop.Abs_RMW_Stage6, Uop.End }, - //0x10 - /*BPL +/-rel*/ new Uop[] { Uop.RelBranch_Stage2_BPL, Uop.End }, - /*ORA (addr),Y* [indirect indexed READ]*/ new Uop[] { Uop.Fetch2, Uop.IndIdx_Stage3, Uop.IndIdx_Stage4, Uop.IndIdx_READ_Stage5, Uop.IndIdx_READ_Stage6_ORA, Uop.End }, - /*JAM*/ new Uop[] { Uop.End }, - /*SLO (addr),Y* [indirect indexed RMW] [unofficial] */ new Uop[] { Uop.Fetch2, Uop.IndIdx_Stage3, Uop.IndIdx_Stage4, Uop.IndIdx_RMW_Stage5, Uop.IndIdx_RMW_Stage6, Uop.IndIdx_RMW_Stage7_SLO, Uop.IndIdx_RMW_Stage8, Uop.End }, - /*NOP zp,X [zero page indexed READ]*/ new Uop[] { Uop.Fetch2, Uop.ZpIdx_Stage3_X, Uop.ZP_READ_NOP, Uop.End }, - /*ORA zp,X [zero page indexed READ]*/ new Uop[] { Uop.Fetch2, Uop.ZpIdx_Stage3_X, Uop.ZP_READ_ORA, Uop.End }, - /*ASL zp,X [zero page indexed RMW]*/ new Uop[] { Uop.Fetch2, Uop.ZpIdx_Stage3_X, Uop.ZpIdx_RMW_Stage4, Uop.ZP_RMW_ASL, Uop.ZpIdx_RMW_Stage6, Uop.End }, - /*SLO* zp,X [zero page indexed RMW] [unofficial]*/ new Uop[] { Uop.Fetch2, Uop.ZpIdx_Stage3_X, Uop.ZpIdx_RMW_Stage4, Uop.ZP_RMW_SLO, Uop.ZpIdx_RMW_Stage6, Uop.End }, - /*CLC [implied]*/ new Uop[] { Uop.Imp_CLC, Uop.End }, - /*ORA addr,Y* [absolute indexed READ Y]*/ new Uop[] { Uop.Fetch2, Uop.AbsIdx_Stage3_Y, Uop.AbsIdx_READ_Stage4, Uop.AbsIdx_READ_Stage5_ORA, Uop.End }, - /*NOP 1A*/ new Uop[] { Uop.FetchDummy, Uop.End }, - /*SLO* addr,Y [absolute indexed RMW Y] [unofficial]*/ new Uop[] { Uop.Fetch2, Uop.AbsIdx_Stage3_Y, Uop.AbsIdx_Stage4, Uop.AbsIdx_RMW_Stage5, Uop.AbsIdx_RMW_Stage6_SLO, Uop.AbsIdx_RMW_Stage7, Uop.End }, - /*NOP addr,X* [absolute indexed READ X]*/ new Uop[] { Uop.Fetch2, Uop.AbsIdx_Stage3_X, Uop.AbsIdx_READ_Stage4, Uop.AbsIdx_READ_Stage5_NOP, Uop.End }, - /*ORA addr,X* [absolute indexed READ X]*/ new Uop[] { Uop.Fetch2, Uop.AbsIdx_Stage3_X, Uop.AbsIdx_READ_Stage4, Uop.AbsIdx_READ_Stage5_ORA, Uop.End }, - /*ASL addr,X [absolute indexed RMW X]*/ new Uop[] { Uop.Fetch2, Uop.AbsIdx_Stage3_X, Uop.AbsIdx_Stage4, Uop.AbsIdx_RMW_Stage5, Uop.AbsIdx_RMW_Stage6_ASL, Uop.AbsIdx_RMW_Stage7, Uop.End }, - /*SLO* addr,X [absolute indexed RMW X] [unofficial]*/ new Uop[] { Uop.Fetch2, Uop.AbsIdx_Stage3_X, Uop.AbsIdx_Stage4, Uop.AbsIdx_RMW_Stage5, Uop.AbsIdx_RMW_Stage6_SLO, Uop.AbsIdx_RMW_Stage7, Uop.End }, - //0x20 - /*JSR*/ new Uop[] { Uop.Fetch2, Uop.NOP, Uop.PushPCH, Uop.PushPCL, Uop.JSR, Uop.End }, - /*AND (addr,X) [indexed indirect READ]*/ new Uop[] { Uop.Fetch2, Uop.IdxInd_Stage3, Uop.IdxInd_Stage4, Uop.IdxInd_Stage5, Uop.IdxInd_Stage6_READ_AND, Uop.End }, - /*JAM*/ new Uop[] { Uop.End }, - /*RLA* (addr,X) [indexed indirect RMW] [unofficial]*/ new Uop[] { Uop.Fetch2, Uop.IdxInd_Stage3, Uop.IdxInd_Stage4, Uop.IdxInd_Stage5, Uop.IdxInd_Stage6_RMW, Uop.IdxInd_Stage7_RMW_RLA, Uop.IdxInd_Stage8_RMW, Uop.End }, - /*BIT zp [zero page READ]*/ new Uop[] { Uop.Fetch2, Uop.ZP_READ_BIT, Uop.End }, - /*AND zp [zero page READ]*/ new Uop[] { Uop.Fetch2, Uop.ZP_READ_AND, Uop.End }, - /*ROL zp [zero page RMW]*/ new Uop[] { Uop.Fetch2, Uop.ZP_RMW_Stage3, Uop.ZP_RMW_ROL, Uop.ZP_RMW_Stage5, Uop.End }, - /*RLA* zp [zero page RMW] [unofficial]*/ new Uop[] { Uop.Fetch2, Uop.ZP_RMW_Stage3, Uop.ZP_RMW_RLA, Uop.ZP_RMW_Stage5, Uop.End }, - /*PLP [implied] */ new Uop[] { Uop.FetchDummy, Uop.IncS, Uop.PullP_NoInc, Uop.End_ISpecial }, - /*AND #nn [immediate]*/ new Uop[] { Uop.Imm_AND, Uop.End }, - /*ROL A [accumulator]*/ new Uop[] { Uop.Imp_ROL_A, Uop.End }, - /*ANC** [immediate] [unofficial]*/ new Uop[] { Uop.Imm_ANC, Uop.End }, - /*BIT addr [absolute]*/ new Uop[] { Uop.Fetch2, Uop.Fetch3, Uop.Abs_READ_BIT, Uop.End }, - /*AND addr [absolute READ]*/ new Uop[] { Uop.Fetch2, Uop.Fetch3, Uop.Abs_READ_AND, Uop.End }, - /*ROL addr [absolute RMW]*/ new Uop[] { Uop.Fetch2, Uop.Fetch3, Uop.Abs_RMW_Stage4, Uop.Abs_RMW_Stage5_ROL, Uop.Abs_RMW_Stage6, Uop.End }, - /*RLA* addr [absolute RMW] [unofficial]*/ new Uop[] { Uop.Fetch2, Uop.Fetch3, Uop.Abs_RMW_Stage4, Uop.Abs_RMW_Stage5_RLA, Uop.Abs_RMW_Stage6, Uop.End }, - //0x30 - /*BMI +/-rel [relative]*/ new Uop[] { Uop.RelBranch_Stage2_BMI, Uop.End }, - /*AND (addr),Y* [indirect indexed READ]*/ new Uop[] { Uop.Fetch2, Uop.IndIdx_Stage3, Uop.IndIdx_Stage4, Uop.IndIdx_READ_Stage5, Uop.IndIdx_READ_Stage6_AND, Uop.End }, - /*JAM*/ new Uop[] { Uop.End }, - /*RLA* (addr),Y* [indirect indexed RMW] [unofficial] */ new Uop[] { Uop.Fetch2, Uop.IndIdx_Stage3, Uop.IndIdx_Stage4, Uop.IndIdx_RMW_Stage5, Uop.IndIdx_RMW_Stage6, Uop.IndIdx_RMW_Stage7_RLA, Uop.IndIdx_RMW_Stage8, Uop.End }, - /*NOP zp,X [zero page indexed READ]*/ new Uop[] { Uop.Fetch2, Uop.ZpIdx_Stage3_X, Uop.ZP_READ_NOP, Uop.End }, - /*AND zp,X [zero page indexed READ]*/ new Uop[] { Uop.Fetch2, Uop.ZpIdx_Stage3_X, Uop.ZP_READ_AND, Uop.End }, - /*ROL zp,X [zero page indexed RMW]*/ new Uop[] { Uop.Fetch2, Uop.ZpIdx_Stage3_X, Uop.ZpIdx_RMW_Stage4, Uop.ZP_RMW_ROL, Uop.ZpIdx_RMW_Stage6, Uop.End }, - /*RLA* zp,X [zero page indexed RMW] [unofficial]*/ new Uop[] { Uop.Fetch2, Uop.ZpIdx_Stage3_X, Uop.ZpIdx_RMW_Stage4, Uop.ZP_RMW_RLA, Uop.ZpIdx_RMW_Stage6, Uop.End }, - /*SEC [implied]*/ new Uop[] { Uop.Imp_SEC, Uop.End }, - /*AND addr,Y* [absolute indexed READ Y]*/ new Uop[] { Uop.Fetch2, Uop.AbsIdx_Stage3_Y, Uop.AbsIdx_READ_Stage4, Uop.AbsIdx_READ_Stage5_AND, Uop.End }, - /*NOP 3A [implied]*/ new Uop[] { Uop.FetchDummy, Uop.End }, - /*RLA* addr,Y [absolute indexed RMW Y] [unofficial]*/ new Uop[] { Uop.Fetch2, Uop.AbsIdx_Stage3_Y, Uop.AbsIdx_Stage4, Uop.AbsIdx_RMW_Stage5, Uop.AbsIdx_RMW_Stage6_RLA, Uop.AbsIdx_RMW_Stage7, Uop.End }, - /*NOP addr,X* [absolute indexed READ X]*/ new Uop[] { Uop.Fetch2, Uop.AbsIdx_Stage3_X, Uop.AbsIdx_READ_Stage4, Uop.AbsIdx_READ_Stage5_NOP, Uop.End }, - /*AND addr,X* [absolute indexed READ X]*/ new Uop[] { Uop.Fetch2, Uop.AbsIdx_Stage3_X, Uop.AbsIdx_READ_Stage4, Uop.AbsIdx_READ_Stage5_AND, Uop.End }, - /*ROL addr,X [absolute indexed RMW X]*/ new Uop[] { Uop.Fetch2, Uop.AbsIdx_Stage3_X, Uop.AbsIdx_Stage4, Uop.AbsIdx_RMW_Stage5, Uop.AbsIdx_RMW_Stage6_ROL, Uop.AbsIdx_RMW_Stage7, Uop.End }, - /*RLA* addr,X [absolute indexed RMW X] [unofficial]*/ new Uop[] { Uop.Fetch2, Uop.AbsIdx_Stage3_X, Uop.AbsIdx_Stage4, Uop.AbsIdx_RMW_Stage5, Uop.AbsIdx_RMW_Stage6_RLA, Uop.AbsIdx_RMW_Stage7, Uop.End }, - //0x40 - /*RTI*/ new Uop[] { Uop.FetchDummy, Uop.IncS, Uop.PullP, Uop.PullPCL, Uop.PullPCH_NoInc, Uop.End }, - /*EOR (addr,X) [indexed indirect READ]*/ new Uop[] { Uop.Fetch2, Uop.IdxInd_Stage3, Uop.IdxInd_Stage4, Uop.IdxInd_Stage5, Uop.IdxInd_Stage6_READ_EOR, Uop.End }, - /*JAM*/ new Uop[] { Uop.End }, - /*SRE* (addr,X) [indexed indirect RMW] [unofficial]*/ new Uop[] { Uop.Fetch2, Uop.IdxInd_Stage3, Uop.IdxInd_Stage4, Uop.IdxInd_Stage5, Uop.IdxInd_Stage6_RMW, Uop.IdxInd_Stage7_RMW_SRE, Uop.IdxInd_Stage8_RMW, Uop.End }, - /*NOP zp [zero page READ]*/ new Uop[] { Uop.Fetch2, Uop.ZP_READ_NOP, Uop.End }, - /*EOR zp [zero page READ]*/ new Uop[] { Uop.Fetch2, Uop.ZP_READ_EOR, Uop.End }, - /*LSR zp [zero page RMW]*/ new Uop[] { Uop.Fetch2, Uop.ZP_RMW_Stage3, Uop.ZP_RMW_LSR, Uop.ZP_RMW_Stage5, Uop.End }, - /*SRE* zp [zero page RMW] [unofficial]*/ new Uop[] { Uop.Fetch2, Uop.ZP_RMW_Stage3, Uop.ZP_RMW_SRE, Uop.ZP_RMW_Stage5, Uop.End }, - /*PHA [implied]*/ new Uop[] { Uop.FetchDummy, Uop.PushA, Uop.End }, - /*EOR #nn [immediate]*/ new Uop[] { Uop.Imm_EOR, Uop.End }, - /*LSR A [accumulator]*/ new Uop[] { Uop.Imp_LSR_A, Uop.End }, - /*ASR** [immediate] [unofficial]*/ new Uop[] { Uop.Imm_ASR, Uop.End }, - /*JMP addr [absolute]*/ new Uop[] { Uop.Fetch2, Uop.JMP_abs, Uop.End }, - /*EOR addr [absolute READ]*/ new Uop[] { Uop.Fetch2, Uop.Fetch3, Uop.Abs_READ_EOR, Uop.End }, - /*LSR addr [absolute RMW]*/ new Uop[] { Uop.Fetch2, Uop.Fetch3, Uop.Abs_RMW_Stage4, Uop.Abs_RMW_Stage5_LSR, Uop.Abs_RMW_Stage6, Uop.End }, - /*SRE* addr [absolute RMW] [unofficial]*/ new Uop[] { Uop.Fetch2, Uop.Fetch3, Uop.Abs_RMW_Stage4, Uop.Abs_RMW_Stage5_SRE, Uop.Abs_RMW_Stage6, Uop.End }, - //0x50 - /*BVC +/-rel [relative]*/ new Uop[] { Uop.RelBranch_Stage2_BVC, Uop.End }, - /*EOR (addr),Y* [indirect indexed READ]*/ new Uop[] { Uop.Fetch2, Uop.IndIdx_Stage3, Uop.IndIdx_Stage4, Uop.IndIdx_READ_Stage5, Uop.IndIdx_READ_Stage6_EOR, Uop.End }, - /*JAM*/ new Uop[] { Uop.End }, - /*SRE* (addr),Y* [indirect indexed RMW] [unofficial] */ new Uop[] { Uop.Fetch2, Uop.IndIdx_Stage3, Uop.IndIdx_Stage4, Uop.IndIdx_RMW_Stage5, Uop.IndIdx_RMW_Stage6, Uop.IndIdx_RMW_Stage7_SRE, Uop.IndIdx_RMW_Stage8, Uop.End }, - /*NOP zp,X [zero page indexed READ]*/ new Uop[] { Uop.Fetch2, Uop.ZpIdx_Stage3_X, Uop.ZP_READ_NOP, Uop.End }, - /*EOR zp,X [zero page indexed READ]*/ new Uop[] { Uop.Fetch2, Uop.ZpIdx_Stage3_X, Uop.ZP_READ_EOR, Uop.End }, - /*LSR zp,X [zero page indexed RMW]*/ new Uop[] { Uop.Fetch2, Uop.ZpIdx_Stage3_X, Uop.ZpIdx_RMW_Stage4, Uop.ZP_RMW_LSR, Uop.ZpIdx_RMW_Stage6, Uop.End }, - /*SRE* zp,X [zero page indexed RMW] [unofficial]*/ new Uop[] { Uop.Fetch2, Uop.ZpIdx_Stage3_X, Uop.ZpIdx_RMW_Stage4, Uop.ZP_RMW_SRE, Uop.ZpIdx_RMW_Stage6, Uop.End }, - /*CLI [implied]*/ new Uop[] { Uop.Imp_CLI, Uop.End_ISpecial }, - /*EOR addr,Y* [absolute indexed READ Y]*/ new Uop[] { Uop.Fetch2, Uop.AbsIdx_Stage3_Y, Uop.AbsIdx_READ_Stage4, Uop.AbsIdx_READ_Stage5_EOR, Uop.End }, - /*NOP 5A [implied]*/ new Uop[] { Uop.FetchDummy, Uop.End }, - /*SRE* addr,Y [absolute indexed RMW Y] [unofficial]*/ new Uop[] { Uop.Fetch2, Uop.AbsIdx_Stage3_Y, Uop.AbsIdx_Stage4, Uop.AbsIdx_RMW_Stage5, Uop.AbsIdx_RMW_Stage6_SRE, Uop.AbsIdx_RMW_Stage7, Uop.End }, - /*NOP addr,X* [absolute indexed READ X]*/ new Uop[] { Uop.Fetch2, Uop.AbsIdx_Stage3_X, Uop.AbsIdx_READ_Stage4, Uop.AbsIdx_READ_Stage5_NOP, Uop.End }, - /*EOR addr,X* [absolute indexed READ X]*/ new Uop[] { Uop.Fetch2, Uop.AbsIdx_Stage3_X, Uop.AbsIdx_READ_Stage4, Uop.AbsIdx_READ_Stage5_EOR, Uop.End }, - /*LSR addr,X [absolute indexed RMW X]*/ new Uop[] { Uop.Fetch2, Uop.AbsIdx_Stage3_X, Uop.AbsIdx_Stage4, Uop.AbsIdx_RMW_Stage5, Uop.AbsIdx_RMW_Stage6_LSR, Uop.AbsIdx_RMW_Stage7, Uop.End }, - /*SRE* addr,X [absolute indexed RMW X] [unofficial]*/ new Uop[] { Uop.Fetch2, Uop.AbsIdx_Stage3_X, Uop.AbsIdx_Stage4, Uop.AbsIdx_RMW_Stage5, Uop.AbsIdx_RMW_Stage6_SRE, Uop.AbsIdx_RMW_Stage7, Uop.End }, - //0x60 - /*RTS*/ new Uop[] { Uop.FetchDummy, Uop.IncS, Uop.PullPCL, Uop.PullPCH_NoInc, Uop.IncPC, Uop.End }, //can't fetch here because the PC isnt ready until the end of the last clock - /*ADC (addr,X) [indexed indirect READ]*/ new Uop[] { Uop.Fetch2, Uop.IdxInd_Stage3, Uop.IdxInd_Stage4, Uop.IdxInd_Stage5, Uop.IdxInd_Stage6_READ_ADC, Uop.End }, - /*JAM*/ new Uop[] { Uop.End }, - /*RRA* (addr,X) [indexed indirect RMW] [unofficial]*/ new Uop[] { Uop.Fetch2, Uop.IdxInd_Stage3, Uop.IdxInd_Stage4, Uop.IdxInd_Stage5, Uop.IdxInd_Stage6_RMW, Uop.IdxInd_Stage7_RMW_RRA, Uop.IdxInd_Stage8_RMW, Uop.End }, - /*NOP zp [zero page READ]*/ new Uop[] { Uop.Fetch2, Uop.ZP_READ_NOP, Uop.End }, - /*ADC zp [zero page READ]*/ new Uop[] { Uop.Fetch2, Uop.ZP_READ_ADC, Uop.End }, - /*ROR zp [zero page RMW]*/ new Uop[] { Uop.Fetch2, Uop.ZP_RMW_Stage3, Uop.ZP_RMW_ROR, Uop.ZP_RMW_Stage5, Uop.End }, - /*RRA* zp [zero page RMW] [unofficial]*/ new Uop[] { Uop.Fetch2, Uop.ZP_RMW_Stage3, Uop.ZP_RMW_RRA, Uop.ZP_RMW_Stage5, Uop.End }, - /*PLA [implied]*/ new Uop[] { Uop.FetchDummy, Uop.IncS, Uop.PullA_NoInc, Uop.End }, - /*ADC #nn [immediate]*/ new Uop[] { Uop.Imm_ADC, Uop.End }, - /*ROR A [accumulator]*/ new Uop[] { Uop.Imp_ROR_A, Uop.End }, - /*ARR** [immediate] [unofficial]*/ new Uop[] { Uop.Imm_ARR, Uop.End }, - /*JMP (addr) [absolute indirect JMP]*/ new Uop[] { Uop.Fetch2, Uop.Fetch3, Uop.AbsInd_JMP_Stage4, Uop.AbsInd_JMP_Stage5, Uop.End }, - /*ADC addr [absolute READ]*/ new Uop[] { Uop.Fetch2, Uop.Fetch3, Uop.Abs_READ_ADC, Uop.End }, - /*ROR addr [absolute RMW]*/ new Uop[] { Uop.Fetch2, Uop.Fetch3, Uop.Abs_RMW_Stage4, Uop.Abs_RMW_Stage5_ROR, Uop.Abs_RMW_Stage6, Uop.End }, - /*RRA* addr [absolute RMW] [unofficial]*/ new Uop[] { Uop.Fetch2, Uop.Fetch3, Uop.Abs_RMW_Stage4, Uop.Abs_RMW_Stage5_RRA, Uop.Abs_RMW_Stage6, Uop.End }, - //0x70 - /*BVS +/-rel [relative]*/ new Uop[] { Uop.RelBranch_Stage2_BVS, Uop.End }, - /*ADC (addr),Y [indirect indexed READ]*/ new Uop[] { Uop.Fetch2, Uop.IndIdx_Stage3, Uop.IndIdx_Stage4, Uop.IndIdx_READ_Stage5, Uop.IndIdx_READ_Stage6_ADC, Uop.End }, - /*JAM*/ new Uop[] { Uop.End }, - /*RRA* (addr),Y [indirect indexed RMW Y] [unofficial] */ new Uop[] { Uop.Fetch2, Uop.IndIdx_Stage3, Uop.IndIdx_Stage4, Uop.IndIdx_RMW_Stage5, Uop.IndIdx_RMW_Stage6, Uop.IndIdx_RMW_Stage7_RRA, Uop.IndIdx_RMW_Stage8, Uop.End }, - /*NOP zp,X [zero page indexed READ]*/ new Uop[] { Uop.Fetch2, Uop.ZpIdx_Stage3_X, Uop.ZP_READ_NOP, Uop.End }, - /*ADC zp,X [zero page indexed READ]*/ new Uop[] { Uop.Fetch2, Uop.ZpIdx_Stage3_X, Uop.ZP_READ_ADC, Uop.End }, - /*ROR zp,X [zero page indexed RMW]*/ new Uop[] { Uop.Fetch2, Uop.ZpIdx_Stage3_X, Uop.ZpIdx_RMW_Stage4, Uop.ZP_RMW_ROR, Uop.ZpIdx_RMW_Stage6, Uop.End }, - /*RRA* zp,X [zero page indexed RMW] [unofficial]*/ new Uop[] { Uop.Fetch2, Uop.ZpIdx_Stage3_X, Uop.ZpIdx_RMW_Stage4, Uop.ZP_RMW_RRA, Uop.ZpIdx_RMW_Stage6, Uop.End }, - /*SEI [implied]*/ new Uop[] { Uop.Imp_SEI, Uop.End_ISpecial }, - /*ADC addr,Y* [absolute indexed READ Y]*/ new Uop[] { Uop.Fetch2, Uop.AbsIdx_Stage3_Y, Uop.AbsIdx_READ_Stage4, Uop.AbsIdx_READ_Stage5_ADC, Uop.End }, - /*NOP 7A [implied]*/ new Uop[] { Uop.FetchDummy, Uop.End }, - /*RRA* addr,Y [absolute indexed RMW Y] [unofficial]*/ new Uop[] { Uop.Fetch2, Uop.AbsIdx_Stage3_Y, Uop.AbsIdx_Stage4, Uop.AbsIdx_RMW_Stage5, Uop.AbsIdx_RMW_Stage6_RRA, Uop.AbsIdx_RMW_Stage7, Uop.End }, - /*NOP addr,X* [absolute indexed READ X]*/ new Uop[] { Uop.Fetch2, Uop.AbsIdx_Stage3_X, Uop.AbsIdx_READ_Stage4, Uop.AbsIdx_READ_Stage5_NOP, Uop.End }, - /*ADC addr,X* [absolute indexed READ X]*/ new Uop[] { Uop.Fetch2, Uop.AbsIdx_Stage3_X, Uop.AbsIdx_READ_Stage4, Uop.AbsIdx_READ_Stage5_ADC, Uop.End }, - /*ROR addr,X [absolute indexed RMW X]*/ new Uop[] { Uop.Fetch2, Uop.AbsIdx_Stage3_X, Uop.AbsIdx_Stage4, Uop.AbsIdx_RMW_Stage5, Uop.AbsIdx_RMW_Stage6_ROR, Uop.AbsIdx_RMW_Stage7, Uop.End }, - /*RRA* addr,X [absolute indexed RMW X] [unofficial]*/ new Uop[] { Uop.Fetch2, Uop.AbsIdx_Stage3_X, Uop.AbsIdx_Stage4, Uop.AbsIdx_RMW_Stage5, Uop.AbsIdx_RMW_Stage6_RRA, Uop.AbsIdx_RMW_Stage7, Uop.End }, - //0x80 - /*NOP #nn [immediate]*/ new Uop[] { Uop.Imm_Unsupported, Uop.End }, - /*STA (addr,X) [indexed indirect WRITE]*/ new Uop[] { Uop.Fetch2, Uop.IdxInd_Stage3, Uop.IdxInd_Stage4, Uop.IdxInd_Stage5, Uop.IdxInd_Stage6_WRITE_STA, Uop.End }, - /*NOP #nn [immediate]*/ new Uop[] { Uop.Imm_Unsupported, Uop.End }, //jams very rarely - /*SAX* (addr,X) [indexed indirect WRITE] [unofficial]*/ new Uop[] { Uop.Fetch2, Uop.IdxInd_Stage3, Uop.IdxInd_Stage4, Uop.IdxInd_Stage5, Uop.IdxInd_Stage6_WRITE_SAX, Uop.End }, - /*STY zp [zero page WRITE]*/ new Uop[] { Uop.Fetch2, Uop.ZP_WRITE_STY, Uop.End }, - /*STA zp [zero page WRITE]*/ new Uop[] { Uop.Fetch2, Uop.ZP_WRITE_STA, Uop.End }, - /*STX zp [zero page WRITE]*/ new Uop[] { Uop.Fetch2, Uop.ZP_WRITE_STX, Uop.End }, - /*SAX* zp [zero page WRITE] [unofficial]*/ new Uop[] { Uop.Fetch2, Uop.ZP_WRITE_SAX, Uop.End }, - /*DEY [implied]*/ new Uop[] { Uop.Imp_DEY, Uop.End }, - /*NOP #nn [immediate]*/ new Uop[] { Uop.Imm_Unsupported, Uop.End }, - /*TXA [implied]*/ new Uop[] { Uop.Imp_TXA, Uop.End }, - /*ANE** [immediate] [unofficial]*/ new Uop[] { Uop.Imm_Unsupported, Uop.End }, - /*STY addr [absolute WRITE]*/ new Uop[] { Uop.Fetch2, Uop.Fetch3, Uop.Abs_WRITE_STY, Uop.End }, - /*STA addr [absolute WRITE]*/ new Uop[] { Uop.Fetch2, Uop.Fetch3, Uop.Abs_WRITE_STA, Uop.End }, - /*STX addr [absolute WRITE]*/ new Uop[] { Uop.Fetch2, Uop.Fetch3, Uop.Abs_WRITE_STX, Uop.End }, - /*SAX* addr [absolute WRITE] [unofficial]*/ new Uop[] { Uop.Fetch2, Uop.Fetch3, Uop.Abs_WRITE_SAX, Uop.End }, - //0x90 - /*BCC +/-rel [relative]*/ new Uop[] { Uop.RelBranch_Stage2_BCC, Uop.End }, - /*STA (addr),Y [indirect indexed WRITE]*/ new Uop[] { Uop.Fetch2, Uop.IndIdx_Stage3, Uop.IndIdx_Stage4, Uop.IndIdx_WRITE_Stage5, Uop.IndIdx_WRITE_Stage6_STA, Uop.End }, - /*JAM*/ new Uop[] { Uop.End }, - /*SHA** [indirect indexed WRITE] [unofficial] [not tested by blargg's instruction tests]*/ new Uop[] { Uop.Fetch2, Uop.IndIdx_Stage3, Uop.IndIdx_Stage4, Uop.IndIdx_WRITE_Stage5, Uop.IndIdx_WRITE_Stage6_SHA, Uop.End }, - /*STY zp,X [zero page indexed WRITE X]*/ new Uop[] { Uop.Fetch2, Uop.ZpIdx_Stage3_X, Uop.ZP_WRITE_STY, Uop.End }, - /*STA zp,X [zero page indexed WRITE X]*/ new Uop[] { Uop.Fetch2, Uop.ZpIdx_Stage3_X, Uop.ZP_WRITE_STA, Uop.End }, - /*STX zp,Y [zero page indexed WRITE Y]*/ new Uop[] { Uop.Fetch2, Uop.ZpIdx_Stage3_Y, Uop.ZP_WRITE_STX, Uop.End }, - /*SAX* zp,Y [zero page indexed WRITE Y] [unofficial]*/ new Uop[] { Uop.Fetch2, Uop.ZpIdx_Stage3_Y, Uop.ZP_WRITE_SAX, Uop.End }, - /*TYA [implied]*/ new Uop[] { Uop.Imp_TYA, Uop.End }, - /*STA addr,Y [absolute indexed WRITE]*/ new Uop[] { Uop.Fetch2, Uop.AbsIdx_Stage3_Y, Uop.AbsIdx_Stage4, Uop.AbsIdx_WRITE_Stage5_STA, Uop.End }, - /*TXS [implied]*/ new Uop[] { Uop.Imp_TXS, Uop.End }, - /*SHS* addr,X [absolute indexed WRITE X] [unofficial] [NOT IMPLEMENTED - TRICKY, AND NO TEST]*/ new Uop[] { Uop.Fetch2, Uop.AbsIdx_Stage3_X, Uop.AbsIdx_Stage4, Uop.AbsIdx_WRITE_Stage5_ERROR, Uop.End }, - /*SHY** [absolute indexed WRITE] [unofficial]*/ new Uop[] { Uop.Fetch2, Uop.AbsIdx_Stage3_X, Uop.AbsIdx_Stage4, Uop.AbsIdx_WRITE_Stage5_SHY, Uop.End }, - /*STA addr,X [absolute indexed WRITE]*/ new Uop[] { Uop.Fetch2, Uop.AbsIdx_Stage3_X, Uop.AbsIdx_Stage4, Uop.AbsIdx_WRITE_Stage5_STA, Uop.End }, - /*SHX* addr,Y [absolute indexed WRITE Y] [unofficial]*/ new Uop[] { Uop.Fetch2, Uop.AbsIdx_Stage3_Y, Uop.AbsIdx_Stage4, Uop.AbsIdx_WRITE_Stage5_SHX, Uop.End }, - /*SHA* addr,Y [absolute indexed WRITE Y] [unofficial]*/ new Uop[] { Uop.Fetch2, Uop.AbsIdx_Stage3_Y, Uop.AbsIdx_Stage4, Uop.AbsIdx_WRITE_Stage5_SHY, Uop.End }, - //0xA0 - /*LDY #nn [immediate]*/ new Uop[] { Uop.Imm_LDY, Uop.End }, - /*LDA (addr,X) [indexed indirect READ]*/ new Uop[] { Uop.Fetch2, Uop.IdxInd_Stage3, Uop.IdxInd_Stage4, Uop.IdxInd_Stage5, Uop.IdxInd_Stage6_READ_LDA, Uop.End }, - /*LDX #nn [immediate]*/ new Uop[] { Uop.Imm_LDX, Uop.End }, - /*LAX* (addr,X) [indexed indirect READ] [unofficial]*/ new Uop[] { Uop.Fetch2, Uop.IdxInd_Stage3, Uop.IdxInd_Stage4, Uop.IdxInd_Stage5, Uop.IdxInd_Stage6_READ_LAX, Uop.End }, - /*LDY zp [zero page READ]*/ new Uop[] { Uop.Fetch2, Uop.ZP_READ_LDY, Uop.End }, - /*LDA zp [zero page READ]*/ new Uop[] { Uop.Fetch2, Uop.ZP_READ_LDA, Uop.End }, - /*LDX zp [zero page READ]*/ new Uop[] { Uop.Fetch2, Uop.ZP_READ_LDX, Uop.End }, - /*LAX* zp [zero page READ] [unofficial]*/ new Uop[] { Uop.Fetch2, Uop.ZP_READ_LAX, Uop.End }, - /*TAY [implied]*/ new Uop[] { Uop.Imp_TAY, Uop.End }, - /*LDA #nn [immediate]*/ new Uop[] { Uop.Imm_LDA, Uop.End }, - /*TAX [implied]*/ new Uop[] { Uop.Imp_TAX, Uop.End }, - /*LXA** (ATX) [immediate] [unofficial]*/ new Uop[] { Uop.Imm_LXA, Uop.End }, - /*LDY addr [absolute READ]*/ new Uop[] { Uop.Fetch2, Uop.Fetch3, Uop.Abs_READ_LDY, Uop.End }, - /*LDA addr [absolute READ]*/ new Uop[] { Uop.Fetch2, Uop.Fetch3, Uop.Abs_READ_LDA, Uop.End }, - /*LDX addr [absolute READ]*/ new Uop[] { Uop.Fetch2, Uop.Fetch3, Uop.Abs_READ_LDX, Uop.End }, - /*LAX* addr [absolute READ] [unofficial]*/ new Uop[] { Uop.Fetch2, Uop.Fetch3, Uop.Abs_READ_LAX, Uop.End }, - //0xB0 - /*BCS +/-rel [relative]*/ new Uop[] { Uop.RelBranch_Stage2_BCS, Uop.End }, - /*LDA (addr),Y* [indirect indexed READ]*/ new Uop[] { Uop.Fetch2, Uop.IndIdx_Stage3, Uop.IndIdx_Stage4, Uop.IndIdx_READ_Stage5, Uop.IndIdx_READ_Stage6_LDA, Uop.End }, - /*JAM*/ new Uop[] { Uop.End }, - /*LAX* (addr),Y* [indirect indexed READ] [unofficial] */ new Uop[] { Uop.Fetch2, Uop.IndIdx_Stage3, Uop.IndIdx_Stage4, Uop.IndIdx_READ_Stage5, Uop.IndIdx_READ_Stage6_LAX, Uop.End }, - /*LDY zp,X [zero page indexed READ X]*/ new Uop[] { Uop.Fetch2, Uop.ZpIdx_Stage3_X, Uop.ZP_READ_LDY, Uop.End }, - /*LDA zp,X [zero page indexed READ X]*/ new Uop[] { Uop.Fetch2, Uop.ZpIdx_Stage3_X, Uop.ZP_READ_LDA, Uop.End }, - /*LDX zp,Y [zero page indexed READ Y]*/ new Uop[] { Uop.Fetch2, Uop.ZpIdx_Stage3_Y, Uop.ZP_READ_LDX, Uop.End }, - /*LAX* zp,Y [zero page indexed READ] [unofficial]*/ new Uop[] { Uop.Fetch2, Uop.ZpIdx_Stage3_Y, Uop.ZP_READ_LAX, Uop.End }, - /*CLV [implied]*/ new Uop[] { Uop.Imp_CLV, Uop.End }, - /*LDA addr,Y* [absolute indexed READ Y]*/ new Uop[] { Uop.Fetch2, Uop.AbsIdx_Stage3_Y, Uop.AbsIdx_READ_Stage4, Uop.AbsIdx_READ_Stage5_LDA, Uop.End }, - /*TSX [implied]*/ new Uop[] { Uop.Imp_TSX, Uop.End }, - /*LAS* addr,X [absolute indexed READ X] [unofficial]*/ new Uop[] { Uop.Fetch2, Uop.AbsIdx_Stage3_X, Uop.AbsIdx_READ_Stage4, Uop.AbsIdx_READ_Stage5_ERROR, Uop.End }, - /*LDY addr,X* [absolute indexed READ X]*/ new Uop[] { Uop.Fetch2, Uop.AbsIdx_Stage3_X, Uop.AbsIdx_READ_Stage4, Uop.AbsIdx_READ_Stage5_LDY, Uop.End }, - /*LDA addr,X* [absolute indexed READ X]*/ new Uop[] { Uop.Fetch2, Uop.AbsIdx_Stage3_X, Uop.AbsIdx_READ_Stage4, Uop.AbsIdx_READ_Stage5_LDA, Uop.End }, - /*LDX addr,Y* [absolute indexed READ Y]*/ new Uop[] { Uop.Fetch2, Uop.AbsIdx_Stage3_Y, Uop.AbsIdx_READ_Stage4, Uop.AbsIdx_READ_Stage5_LDX, Uop.End }, - /*LAX* addr,Y [absolute indexed READ Y] [unofficial]*/ new Uop[] { Uop.Fetch2, Uop.AbsIdx_Stage3_Y, Uop.AbsIdx_READ_Stage4, Uop.AbsIdx_READ_Stage5_LAX, Uop.End }, - //0xC0 - /*CPY #nn [immediate]*/ new Uop[] { Uop.Imm_CPY, Uop.End }, - /*CMP (addr,X) [indexed indirect READ]*/ new Uop[] { Uop.Fetch2, Uop.IdxInd_Stage3, Uop.IdxInd_Stage4, Uop.IdxInd_Stage5, Uop.IdxInd_Stage6_READ_CMP, Uop.End }, - /*NOP #nn [immediate]*/ new Uop[] { Uop.Imm_Unsupported, Uop.End }, //jams very rarely - /*DCP* (addr,X) [indexed indirect RMW] [unofficial]*/ new Uop[] { Uop.Fetch2, Uop.IdxInd_Stage3, Uop.IdxInd_Stage4, Uop.IdxInd_Stage5, Uop.IdxInd_Stage6_RMW, Uop.IdxInd_Stage7_RMW_DCP, Uop.IdxInd_Stage8_RMW, Uop.End }, - /*CPY zp [zero page READ]*/ new Uop[] { Uop.Fetch2, Uop.ZP_READ_CPY, Uop.End }, - /*CMP zp [zero page READ]*/ new Uop[] { Uop.Fetch2, Uop.ZP_READ_CMP, Uop.End }, - /*DEC zp [zero page RMW]*/ new Uop[] { Uop.Fetch2, Uop.ZP_RMW_Stage3, Uop.ZP_RMW_DEC, Uop.ZP_RMW_Stage5, Uop.End }, - /*DCP* zp [zero page RMW] [unofficial]*/ new Uop[] { Uop.Fetch2, Uop.ZP_RMW_Stage3, Uop.ZP_RMW_DCP, Uop.ZP_RMW_Stage5, Uop.End }, - /*INY [implied]*/ new Uop[] { Uop.Imp_INY, Uop.End }, - /*CMP #nn [immediate]*/ new Uop[] { Uop.Imm_CMP, Uop.End }, - /*DEX [implied]*/ new Uop[] { Uop.Imp_DEX, Uop.End }, - /*AXS** [immediate] [unofficial]*/ new Uop[] { Uop.Imm_AXS, Uop.End }, - /*CPY addr [absolute READ]*/ new Uop[] { Uop.Fetch2, Uop.Fetch3, Uop.Abs_READ_CPY, Uop.End }, - /*CMP addr [absolute READ]*/ new Uop[] { Uop.Fetch2, Uop.Fetch3, Uop.Abs_READ_CMP, Uop.End }, - /*DEC addr [absolute RMW]*/ new Uop[] { Uop.Fetch2, Uop.Fetch3, Uop.Abs_RMW_Stage4, Uop.Abs_RMW_Stage5_DEC, Uop.Abs_RMW_Stage6, Uop.End }, - /*DCP* addr [absolute RMW] [unofficial]*/ new Uop[] { Uop.Fetch2, Uop.Fetch3, Uop.Abs_RMW_Stage4, Uop.Abs_RMW_Stage5_DCP, Uop.Abs_RMW_Stage6, Uop.End }, - //0xD0 - /*BNE +/-rel [relative]*/ new Uop[] { Uop.RelBranch_Stage2_BNE, Uop.End }, - /*CMP (addr),Y* [indirect indexed READ]*/ new Uop[] { Uop.Fetch2, Uop.IndIdx_Stage3, Uop.IndIdx_Stage4, Uop.IndIdx_READ_Stage5, Uop.IndIdx_READ_Stage6_CMP, Uop.End }, - /*JAM*/ new Uop[] { Uop.End }, - /*DCP* (addr),Y* [indirect indexed RMW Y] [unofficial] */ new Uop[] { Uop.Fetch2, Uop.IndIdx_Stage3, Uop.IndIdx_Stage4, Uop.IndIdx_RMW_Stage5, Uop.IndIdx_RMW_Stage6, Uop.IndIdx_RMW_Stage7_DCP, Uop.IndIdx_RMW_Stage8, Uop.End }, - /*NOP zp,X [zero page indexed READ]*/ new Uop[] { Uop.Fetch2, Uop.ZpIdx_Stage3_X, Uop.ZP_READ_NOP, Uop.End }, - /*CMP zp,X [zero page indexed READ]*/ new Uop[] { Uop.Fetch2, Uop.ZpIdx_Stage3_X, Uop.ZP_READ_CMP, Uop.End }, - /*DEC zp,X [zero page indexed RMW X]*/ new Uop[] { Uop.Fetch2, Uop.ZpIdx_Stage3_X, Uop.ZpIdx_RMW_Stage4, Uop.ZP_RMW_DEC, Uop.ZpIdx_RMW_Stage6, Uop.End }, - /*DCP* zp,X [zero page indexed RMW] [unofficial]*/ new Uop[] { Uop.Fetch2, Uop.ZpIdx_Stage3_X, Uop.ZpIdx_RMW_Stage4, Uop.ZP_RMW_DCP, Uop.ZpIdx_RMW_Stage6, Uop.End }, - /*CLD [implied]*/ new Uop[] { Uop.Imp_CLD, Uop.End }, - /*CMP addr,Y* [absolute indexed READ Y]*/ new Uop[] { Uop.Fetch2, Uop.AbsIdx_Stage3_Y, Uop.AbsIdx_READ_Stage4, Uop.AbsIdx_READ_Stage5_CMP, Uop.End }, - /*NOP DA [implied]*/ new Uop[] { Uop.FetchDummy, Uop.End }, - /*DCP* addr,Y [absolute indexed RMW Y] [unofficial]*/ new Uop[] { Uop.Fetch2, Uop.AbsIdx_Stage3_Y, Uop.AbsIdx_Stage4, Uop.AbsIdx_RMW_Stage5, Uop.AbsIdx_RMW_Stage6_DCP, Uop.AbsIdx_RMW_Stage7, Uop.End }, - /*NOP addr,X* [absolute indexed READ X]*/ new Uop[] { Uop.Fetch2, Uop.AbsIdx_Stage3_X, Uop.AbsIdx_READ_Stage4, Uop.AbsIdx_READ_Stage5_NOP, Uop.End }, - /*CMP addr,X* [absolute indexed READ X]*/ new Uop[] { Uop.Fetch2, Uop.AbsIdx_Stage3_X, Uop.AbsIdx_READ_Stage4, Uop.AbsIdx_READ_Stage5_CMP, Uop.End }, - /*DEC addr,X [absolute indexed RMW X]*/ new Uop[] { Uop.Fetch2, Uop.AbsIdx_Stage3_X, Uop.AbsIdx_Stage4, Uop.AbsIdx_RMW_Stage5, Uop.AbsIdx_RMW_Stage6_DEC, Uop.AbsIdx_RMW_Stage7, Uop.End }, - /*DCP* addr,X [absolute indexed RMW X] [unofficial]*/ new Uop[] { Uop.Fetch2, Uop.AbsIdx_Stage3_X, Uop.AbsIdx_Stage4, Uop.AbsIdx_RMW_Stage5, Uop.AbsIdx_RMW_Stage6_DCP, Uop.AbsIdx_RMW_Stage7, Uop.End }, - //0xE0 - /*CPX #nn [immediate]*/ new Uop[] { Uop.Imm_CPX, Uop.End }, - /*SBC (addr,X) [indirect indexed]*/ new Uop[] { Uop.Fetch2, Uop.IdxInd_Stage3, Uop.IdxInd_Stage4, Uop.IdxInd_Stage5, Uop.IdxInd_Stage6_READ_SBC, Uop.End }, - /*NOP #nn [immediate]*/ new Uop[] { Uop.Imm_Unsupported, Uop.End }, //jams very rarely - /*ISC* (addr,X) [indexed indirect RMW] [unofficial]*/ new Uop[] { Uop.Fetch2, Uop.IdxInd_Stage3, Uop.IdxInd_Stage4, Uop.IdxInd_Stage5, Uop.IdxInd_Stage6_RMW, Uop.IdxInd_Stage7_RMW_ISC, Uop.IdxInd_Stage8_RMW, Uop.End }, - /*CPX zp [zero page READ]*/ new Uop[] { Uop.Fetch2, Uop.ZP_READ_CPX, Uop.End }, - /*SBC zp [zero page READ]*/ new Uop[] { Uop.Fetch2, Uop.ZP_READ_SBC, Uop.End }, - /*INC zp [zero page RMW]*/ new Uop[] { Uop.Fetch2, Uop.ZP_RMW_Stage3, Uop.ZP_RMW_INC, Uop.ZP_RMW_Stage5, Uop.End }, - /*ISB* zp [zero page RMW] [unofficial]*/ new Uop[] { Uop.Fetch2, Uop.ZP_RMW_Stage3, Uop.ZP_RMW_ISC, Uop.ZP_RMW_Stage5, Uop.End }, - /*INX [implied]*/ new Uop[] { Uop.Imp_INX, Uop.End }, - /*SBC #nn [immediate READ]*/ new Uop[] { Uop.Imm_SBC, Uop.End }, - /*NOP EA [implied]*/ new Uop[] { Uop.FetchDummy, Uop.End }, //nothing happened here.. but the last thing to happen was a fetch, so we can't pipeline the next fetch - /*ISB #nn [immediate READ]*/ new Uop[] { Uop.Imm_SBC, Uop.End }, - /*CPX addr [absolute READ]*/ new Uop[] { Uop.Fetch2, Uop.Fetch3, Uop.Abs_READ_CPX, Uop.End }, - /*SBC addr [absolute READ]*/ new Uop[] { Uop.Fetch2, Uop.Fetch3, Uop.Abs_READ_SBC, Uop.End }, - /*INC addr [absolute RMW]*/ new Uop[] { Uop.Fetch2, Uop.Fetch3, Uop.Abs_RMW_Stage4, Uop.Abs_RMW_Stage5_INC, Uop.Abs_RMW_Stage6, Uop.End }, - /*ISC* addr [absolute RMW] [unofficial]*/ new Uop[] { Uop.Fetch2, Uop.Fetch3, Uop.Abs_RMW_Stage4, Uop.Abs_RMW_Stage5_ISC, Uop.Abs_RMW_Stage6, Uop.End }, - //0xF0 - /*BEQ +/-rel [relative]*/ new Uop[] { Uop.RelBranch_Stage2_BEQ, Uop.End }, - /*SBC (addr),Y* [indirect indexed READ]*/ new Uop[] { Uop.Fetch2, Uop.IndIdx_Stage3, Uop.IndIdx_Stage4, Uop.IndIdx_READ_Stage5, Uop.IndIdx_READ_Stage6_SBC, Uop.End }, - /*JAM*/ new Uop[] { Uop.End }, - /*ISC* (addr),Y* [indirect indexed RMW Y] [unofficial] */ new Uop[] { Uop.Fetch2, Uop.IndIdx_Stage3, Uop.IndIdx_Stage4, Uop.IndIdx_RMW_Stage5, Uop.IndIdx_RMW_Stage6, Uop.IndIdx_RMW_Stage7_ISC, Uop.IndIdx_RMW_Stage8, Uop.End }, - /*NOP zp,X [zero page indexed READ]*/ new Uop[] { Uop.Fetch2, Uop.ZpIdx_Stage3_X, Uop.ZP_READ_NOP, Uop.End }, - /*SBC zp,X [zero page indexed READ X]*/ new Uop[] { Uop.Fetch2, Uop.ZpIdx_Stage3_X, Uop.ZP_READ_SBC, Uop.End }, - /*INC zp,X [zero page indexed RMW X]*/ new Uop[] { Uop.Fetch2, Uop.ZpIdx_Stage3_X, Uop.ZpIdx_RMW_Stage4, Uop.ZP_RMW_INC, Uop.ZpIdx_RMW_Stage6, Uop.End }, - /*ISC* zp,X [zero page indexed RMW] [unofficial]*/ new Uop[] { Uop.Fetch2, Uop.ZpIdx_Stage3_X, Uop.ZpIdx_RMW_Stage4, Uop.ZP_RMW_ISC, Uop.ZpIdx_RMW_Stage6, Uop.End }, - /*SED [implied]*/ new Uop[] { Uop.Imp_SED, Uop.End }, - /*SBC addr,Y* [absolute indexed READ Y]*/ new Uop[] { Uop.Fetch2, Uop.AbsIdx_Stage3_Y, Uop.AbsIdx_READ_Stage4, Uop.AbsIdx_READ_Stage5_SBC, Uop.End }, - /*NOP FA [implied]*/ new Uop[] { Uop.FetchDummy, Uop.End }, - /*ISC* addr,Y [absolute indexed RMW Y] [unofficial]*/ new Uop[] { Uop.Fetch2, Uop.AbsIdx_Stage3_Y, Uop.AbsIdx_Stage4, Uop.AbsIdx_RMW_Stage5, Uop.AbsIdx_RMW_Stage6_ISC, Uop.AbsIdx_RMW_Stage7, Uop.End }, - /*NOP addr,X* [absolute indexed READ X]*/ new Uop[] { Uop.Fetch2, Uop.AbsIdx_Stage3_X, Uop.AbsIdx_READ_Stage4, Uop.AbsIdx_READ_Stage5_NOP, Uop.End }, - /*SBC addr,X* [absolute indexed READ X]*/ new Uop[] { Uop.Fetch2, Uop.AbsIdx_Stage3_X, Uop.AbsIdx_READ_Stage4, Uop.AbsIdx_READ_Stage5_SBC, Uop.End }, - /*INC addr,X [absolute indexed RMW X]*/ new Uop[] { Uop.Fetch2, Uop.AbsIdx_Stage3_X, Uop.AbsIdx_Stage4, Uop.AbsIdx_RMW_Stage5, Uop.AbsIdx_RMW_Stage6_INC, Uop.AbsIdx_RMW_Stage7, Uop.End }, - /*ISC* addr,X [absolute indexed RMW X] [unofficial]*/ new Uop[] { Uop.Fetch2, Uop.AbsIdx_Stage3_X, Uop.AbsIdx_Stage4, Uop.AbsIdx_RMW_Stage5, Uop.AbsIdx_RMW_Stage6_ISC, Uop.AbsIdx_RMW_Stage7, Uop.End }, - //0x100 - /*VOP_Fetch1*/ new Uop[] { Uop.Fetch1 }, - /*VOP_RelativeStuff*/ new Uop[] { Uop.RelBranch_Stage3, Uop.End_BranchSpecial }, - /*VOP_RelativeStuff2*/ new Uop[] { Uop.RelBranch_Stage4, Uop.End }, - /*VOP_RelativeStuff2*/ new Uop[] { Uop.End_SuppressInterrupt }, - //i assume these are dummy fetches.... maybe theyre just nops? supposedly these take 7 cycles so thats the only way i can make sense of it - //one of them might be the next instruction's fetch, and whatever fetch follows it. - //the interrupt would then take place if necessary, using a cached PC. but im not so sure about that. - /*VOP_NMI*/ new Uop[] { Uop.FetchDummy, Uop.FetchDummy, Uop.PushPCH, Uop.PushPCL, Uop.PushP_NMI, Uop.FetchPCLVector, Uop.FetchPCHVector, Uop.End_SuppressInterrupt }, - /*VOP_IRQ*/ new Uop[] { Uop.FetchDummy, Uop.FetchDummy, Uop.PushPCH, Uop.PushPCL, Uop.PushP_IRQ, Uop.FetchPCLVector, Uop.FetchPCHVector, Uop.End_SuppressInterrupt }, - /*VOP_RESET*/ new Uop[] { Uop.FetchDummy, Uop.FetchDummy, Uop.PushDummy, Uop.PushDummy, Uop.PushP_Reset, Uop.FetchPCLVector, Uop.FetchPCHVector, Uop.End_SuppressInterrupt }, - /*VOP_Fetch1_NoInterrupt*/ new Uop[] { Uop.Fetch1_Real }, - }; - - - static MOS6502X() - { - using (System.IO.StreamWriter sw = new System.IO.StreamWriter("UopEnum.h")) - { - sw.WriteLine("// AUTOGENERATED"); - sw.WriteLine("#ifndef UOPENUM_H"); - sw.WriteLine("#define UOPENUM_H"); - sw.WriteLine("enum Uop {"); - foreach (var v in Enum.GetValues(typeof(Uop))) - { - //sw.WriteLine("#define Uop_{0} {1}", (Uop)v, (int)v); - sw.WriteLine("\tUop_{0}, ", (Uop)v); - } - sw.WriteLine("};"); - sw.WriteLine("#endif // UOPENUM_H"); - } - using (System.IO.StreamWriter sw = new System.IO.StreamWriter("UopTable.cpp")) - { - sw.WriteLine("// AUTOGENERATED"); - sw.WriteLine("#include \"UopEnum.h\""); - - int max = 0; - foreach (var a in Microcode) - if (a.Length > max) - max = a.Length; - - sw.WriteLine("const Uop Microcode[{0}][{1}] = {{", Microcode.Length, max); - for (int i = 0; i < Microcode.Length; i++) - { - sw.Write("\t{"); - for (int j = 0; j < Microcode[i].Length; j++) - { - sw.Write("Uop_{0}", Microcode[i][j]); - if (j < Microcode[i].Length - 1) - sw.Write(", "); - } - sw.WriteLine("},"); - } - sw.WriteLine("};"); - } - } - - - enum Uop - { - //sometimes i used this as a marker for unsupported instructions, but it is very inconsistent - Unsupported, - - Fetch1, Fetch1_Real, Fetch2, Fetch3, - //used by instructions with no second opcode byte (6502 fetches a byte anyway but won't increment PC for these) - FetchDummy, - - NOP, - - JSR, - IncPC, //from RTS - - //[absolute WRITE] - Abs_WRITE_STA, Abs_WRITE_STX, Abs_WRITE_STY, - Abs_WRITE_SAX, //unofficials - //[absolute READ] - Abs_READ_BIT, Abs_READ_LDA, Abs_READ_LDY, Abs_READ_ORA, Abs_READ_LDX, Abs_READ_CMP, Abs_READ_ADC, Abs_READ_CPX, Abs_READ_SBC, Abs_READ_AND, Abs_READ_EOR, Abs_READ_CPY, Abs_READ_NOP, - Abs_READ_LAX, //unofficials - //[absolute RMW] - Abs_RMW_Stage4, Abs_RMW_Stage6, - Abs_RMW_Stage5_INC, Abs_RMW_Stage5_DEC, Abs_RMW_Stage5_LSR, Abs_RMW_Stage5_ROL, Abs_RMW_Stage5_ASL, Abs_RMW_Stage5_ROR, - Abs_RMW_Stage5_SLO, Abs_RMW_Stage5_RLA, Abs_RMW_Stage5_SRE, Abs_RMW_Stage5_RRA, Abs_RMW_Stage5_DCP, Abs_RMW_Stage5_ISC, //unofficials - - //[absolute JUMP] - JMP_abs, - - //[zero page misc] - ZpIdx_Stage3_X, ZpIdx_Stage3_Y, - ZpIdx_RMW_Stage4, ZpIdx_RMW_Stage6, - //[zero page WRITE] - ZP_WRITE_STA, ZP_WRITE_STX, ZP_WRITE_STY, ZP_WRITE_SAX, - //[zero page RMW] - ZP_RMW_Stage3, ZP_RMW_Stage5, - ZP_RMW_DEC, ZP_RMW_INC, ZP_RMW_ASL, ZP_RMW_LSR, ZP_RMW_ROR, ZP_RMW_ROL, - ZP_RMW_SLO, ZP_RMW_RLA, ZP_RMW_SRE, ZP_RMW_RRA, ZP_RMW_DCP, ZP_RMW_ISC, - //[zero page READ] - ZP_READ_EOR, ZP_READ_BIT, ZP_READ_ORA, ZP_READ_LDA, ZP_READ_LDY, ZP_READ_LDX, ZP_READ_CPX, ZP_READ_SBC, ZP_READ_CPY, ZP_READ_NOP, ZP_READ_ADC, ZP_READ_AND, ZP_READ_CMP, ZP_READ_LAX, - - //[indexed indirect READ] (addr,X) - //[indexed indirect WRITE] (addr,X) - IdxInd_Stage3, IdxInd_Stage4, IdxInd_Stage5, - IdxInd_Stage6_READ_ORA, IdxInd_Stage6_READ_SBC, IdxInd_Stage6_READ_LDA, IdxInd_Stage6_READ_EOR, IdxInd_Stage6_READ_CMP, IdxInd_Stage6_READ_ADC, IdxInd_Stage6_READ_AND, - IdxInd_Stage6_READ_LAX, - IdxInd_Stage6_WRITE_STA, IdxInd_Stage6_WRITE_SAX, - IdxInd_Stage6_RMW, //work happens in stage 7 - IdxInd_Stage7_RMW_SLO, IdxInd_Stage7_RMW_RLA, IdxInd_Stage7_RMW_SRE, IdxInd_Stage7_RMW_RRA, IdxInd_Stage7_RMW_ISC, IdxInd_Stage7_RMW_DCP, //unofficials - IdxInd_Stage8_RMW, - - //[absolute indexed] - AbsIdx_Stage3_X, AbsIdx_Stage3_Y, AbsIdx_Stage4, - //[absolute indexed WRITE] - AbsIdx_WRITE_Stage5_STA, - AbsIdx_WRITE_Stage5_SHY, AbsIdx_WRITE_Stage5_SHX, //unofficials - AbsIdx_WRITE_Stage5_ERROR, - //[absolute indexed READ] - AbsIdx_READ_Stage4, - AbsIdx_READ_Stage5_LDA, AbsIdx_READ_Stage5_CMP, AbsIdx_READ_Stage5_SBC, AbsIdx_READ_Stage5_ADC, AbsIdx_READ_Stage5_EOR, AbsIdx_READ_Stage5_LDX, AbsIdx_READ_Stage5_AND, AbsIdx_READ_Stage5_ORA, AbsIdx_READ_Stage5_LDY, AbsIdx_READ_Stage5_NOP, - AbsIdx_READ_Stage5_LAX, //unofficials - AbsIdx_READ_Stage5_ERROR, - //[absolute indexed RMW] - AbsIdx_RMW_Stage5, AbsIdx_RMW_Stage7, - AbsIdx_RMW_Stage6_ROR, AbsIdx_RMW_Stage6_DEC, AbsIdx_RMW_Stage6_INC, AbsIdx_RMW_Stage6_ASL, AbsIdx_RMW_Stage6_LSR, AbsIdx_RMW_Stage6_ROL, - AbsIdx_RMW_Stage6_SLO, AbsIdx_RMW_Stage6_RLA, AbsIdx_RMW_Stage6_SRE, AbsIdx_RMW_Stage6_RRA, AbsIdx_RMW_Stage6_DCP, AbsIdx_RMW_Stage6_ISC, //unofficials - - IncS, DecS, - PushPCL, PushPCH, PushP, PullP, PullPCL, PullPCH_NoInc, PushA, PullA_NoInc, PullP_NoInc, - PushP_BRK, PushP_NMI, PushP_IRQ, PushP_Reset, PushDummy, - FetchPCLVector, FetchPCHVector, //todo - may not need these ?? can reuse fetch2 and fetch3? - - //[implied] and [accumulator] - Imp_ASL_A, Imp_ROL_A, Imp_ROR_A, Imp_LSR_A, - Imp_SEC, Imp_CLI, Imp_SEI, Imp_CLD, Imp_CLC, Imp_CLV, Imp_SED, - Imp_INY, Imp_DEY, Imp_INX, Imp_DEX, - Imp_TSX, Imp_TXS, Imp_TAX, Imp_TAY, Imp_TYA, Imp_TXA, - - //[immediate] - Imm_CMP, Imm_ADC, Imm_AND, Imm_SBC, Imm_ORA, Imm_EOR, Imm_CPY, Imm_CPX, Imm_ANC, Imm_ASR, Imm_ARR, Imm_LXA, Imm_AXS, - Imm_LDA, Imm_LDX, Imm_LDY, - Imm_Unsupported, - - //sub-ops - NZ_X, NZ_Y, NZ_A, - RelBranch_Stage2_BNE, RelBranch_Stage2_BPL, RelBranch_Stage2_BCC, RelBranch_Stage2_BCS, RelBranch_Stage2_BEQ, RelBranch_Stage2_BMI, RelBranch_Stage2_BVC, RelBranch_Stage2_BVS, - RelBranch_Stage2, RelBranch_Stage3, RelBranch_Stage4, - _Eor, _Bit, _Cpx, _Cpy, _Cmp, _Adc, _Sbc, _Ora, _And, _Anc, _Asr, _Arr, _Lxa, _Axs, //alu-related sub-ops - - //JMP (addr) 0x6C - AbsInd_JMP_Stage4, AbsInd_JMP_Stage5, - - //[indirect indexed] (i.e. LDA (addr),Y ) - IndIdx_Stage3, IndIdx_Stage4, IndIdx_READ_Stage5, IndIdx_WRITE_Stage5, - IndIdx_WRITE_Stage6_STA, IndIdx_WRITE_Stage6_SHA, - IndIdx_READ_Stage6_LDA, IndIdx_READ_Stage6_CMP, IndIdx_READ_Stage6_ORA, IndIdx_READ_Stage6_SBC, IndIdx_READ_Stage6_ADC, IndIdx_READ_Stage6_AND, IndIdx_READ_Stage6_EOR, - IndIdx_READ_Stage6_LAX, - IndIdx_RMW_Stage5, - IndIdx_RMW_Stage6, //just reads from effective address - IndIdx_RMW_Stage7_SLO, IndIdx_RMW_Stage7_RLA, IndIdx_RMW_Stage7_SRE, IndIdx_RMW_Stage7_RRA, IndIdx_RMW_Stage7_ISC, IndIdx_RMW_Stage7_DCP, //unofficials - IndIdx_RMW_Stage8, - - End, - End_ISpecial, //same as end, but preserves the iflag set by the instruction - End_BranchSpecial, - End_SuppressInterrupt, - } - - void InitOpcodeHandlers() - { - //delegates arent faster than the switch. pretty sure. dont use it. - //opcodeHandlers = new Action[] { - // Unsupported,Fetch1, Fetch1_Real, Fetch2, Fetch3,FetchDummy, - // NOP,JSR,IncPC, - // Abs_WRITE_STA, Abs_WRITE_STX, Abs_WRITE_STY,Abs_WRITE_SAX,Abs_READ_BIT, Abs_READ_LDA, Abs_READ_LDY, Abs_READ_ORA, Abs_READ_LDX, Abs_READ_CMP, Abs_READ_ADC, Abs_READ_CPX, Abs_READ_SBC, Abs_READ_AND, Abs_READ_EOR, Abs_READ_CPY, Abs_READ_NOP, - // Abs_READ_LAX,Abs_RMW_Stage4, Abs_RMW_Stage6,Abs_RMW_Stage5_INC, Abs_RMW_Stage5_DEC, Abs_RMW_Stage5_LSR, Abs_RMW_Stage5_ROL, Abs_RMW_Stage5_ASL, Abs_RMW_Stage5_ROR,Abs_RMW_Stage5_SLO, Abs_RMW_Stage5_RLA, Abs_RMW_Stage5_SRE, Abs_RMW_Stage5_RRA, Abs_RMW_Stage5_DCP, Abs_RMW_Stage5_ISC, - // JMP_abs,ZpIdx_Stage3_X, ZpIdx_Stage3_Y,ZpIdx_RMW_Stage4, ZpIdx_RMW_Stage6,ZP_WRITE_STA, ZP_WRITE_STX, ZP_WRITE_STY, ZP_WRITE_SAX,ZP_RMW_Stage3, ZP_RMW_Stage5, - // ZP_RMW_DEC, ZP_RMW_INC, ZP_RMW_ASL, ZP_RMW_LSR, ZP_RMW_ROR, ZP_RMW_ROL,ZP_RMW_SLO, ZP_RMW_RLA, ZP_RMW_SRE, ZP_RMW_RRA, ZP_RMW_DCP, ZP_RMW_ISC, - // ZP_READ_EOR, ZP_READ_BIT, ZP_READ_ORA, ZP_READ_LDA, ZP_READ_LDY, ZP_READ_LDX, ZP_READ_CPX, ZP_READ_SBC, ZP_READ_CPY, ZP_READ_NOP, ZP_READ_ADC, ZP_READ_AND, ZP_READ_CMP, ZP_READ_LAX, - // IdxInd_Stage3, IdxInd_Stage4, IdxInd_Stage5,IdxInd_Stage6_READ_ORA, IdxInd_Stage6_READ_SBC, IdxInd_Stage6_READ_LDA, IdxInd_Stage6_READ_EOR, IdxInd_Stage6_READ_CMP, IdxInd_Stage6_READ_ADC, IdxInd_Stage6_READ_AND, - // IdxInd_Stage6_READ_LAX,IdxInd_Stage6_WRITE_STA, IdxInd_Stage6_WRITE_SAX,IdxInd_Stage6_RMW,IdxInd_Stage7_RMW_SLO, IdxInd_Stage7_RMW_RLA, IdxInd_Stage7_RMW_SRE, IdxInd_Stage7_RMW_RRA, IdxInd_Stage7_RMW_ISC, IdxInd_Stage7_RMW_DCP, - // IdxInd_Stage8_RMW,AbsIdx_Stage3_X, AbsIdx_Stage3_Y, AbsIdx_Stage4,AbsIdx_WRITE_Stage5_STA,AbsIdx_WRITE_Stage5_SHY, AbsIdx_WRITE_Stage5_SHX,AbsIdx_WRITE_Stage5_ERROR,AbsIdx_READ_Stage4, - // AbsIdx_READ_Stage5_LDA, AbsIdx_READ_Stage5_CMP, AbsIdx_READ_Stage5_SBC, AbsIdx_READ_Stage5_ADC, AbsIdx_READ_Stage5_EOR, AbsIdx_READ_Stage5_LDX, AbsIdx_READ_Stage5_AND, AbsIdx_READ_Stage5_ORA, AbsIdx_READ_Stage5_LDY, AbsIdx_READ_Stage5_NOP, - // AbsIdx_READ_Stage5_LAX,AbsIdx_READ_Stage5_ERROR,AbsIdx_RMW_Stage5, AbsIdx_RMW_Stage7,AbsIdx_RMW_Stage6_ROR, AbsIdx_RMW_Stage6_DEC, AbsIdx_RMW_Stage6_INC, AbsIdx_RMW_Stage6_ASL, AbsIdx_RMW_Stage6_LSR, AbsIdx_RMW_Stage6_ROL, - // AbsIdx_RMW_Stage6_SLO, AbsIdx_RMW_Stage6_RLA, AbsIdx_RMW_Stage6_SRE, AbsIdx_RMW_Stage6_RRA, AbsIdx_RMW_Stage6_DCP, AbsIdx_RMW_Stage6_ISC,IncS, DecS, - // PushPCL, PushPCH, PushP, PullP, PullPCL, PullPCH_NoInc, PushA, PullA_NoInc, PullP_NoInc,PushP_BRK, PushP_NMI, PushP_IRQ, PushP_Reset, PushDummy,FetchPCLVector, FetchPCHVector, - // Imp_ASL_A, Imp_ROL_A, Imp_ROR_A, Imp_LSR_A,Imp_SEC, Imp_CLI, Imp_SEI, Imp_CLD, Imp_CLC, Imp_CLV, Imp_SED,Imp_INY, Imp_DEY, Imp_INX, Imp_DEX,Imp_TSX, Imp_TXS, Imp_TAX, Imp_TAY, Imp_TYA, Imp_TXA, - // Imm_CMP, Imm_ADC, Imm_AND, Imm_SBC, Imm_ORA, Imm_EOR, Imm_CPY, Imm_CPX, Imm_ANC, Imm_ASR, Imm_ARR, Imm_LXA, Imm_AXS,Imm_LDA, Imm_LDX, Imm_LDY, - // Imm_Unsupported,NZ_X, NZ_Y, NZ_A,RelBranch_Stage2_BNE, RelBranch_Stage2_BPL, RelBranch_Stage2_BCC, RelBranch_Stage2_BCS, RelBranch_Stage2_BEQ, RelBranch_Stage2_BMI, RelBranch_Stage2_BVC, RelBranch_Stage2_BVS, - // RelBranch_Stage2, RelBranch_Stage3, RelBranch_Stage4,_Eor, _Bit, _Cpx, _Cpy, _Cmp, _Adc, _Sbc, _Ora, _And, _Anc, _Asr, _Arr, _Lxa, _Axs, - // AbsInd_JMP_Stage4, AbsInd_JMP_Stage5,IndIdx_Stage3, IndIdx_Stage4, IndIdx_READ_Stage5, IndIdx_WRITE_Stage5, - // IndIdx_WRITE_Stage6_STA, IndIdx_WRITE_Stage6_SHA,IndIdx_READ_Stage6_LDA, IndIdx_READ_Stage6_CMP, IndIdx_READ_Stage6_ORA, IndIdx_READ_Stage6_SBC, IndIdx_READ_Stage6_ADC, IndIdx_READ_Stage6_AND, IndIdx_READ_Stage6_EOR, - // IndIdx_READ_Stage6_LAX,IndIdx_RMW_Stage5,IndIdx_RMW_Stage6, IndIdx_RMW_Stage7_SLO, IndIdx_RMW_Stage7_RLA, IndIdx_RMW_Stage7_SRE, IndIdx_RMW_Stage7_RRA, IndIdx_RMW_Stage7_ISC, IndIdx_RMW_Stage7_DCP,IndIdx_RMW_Stage8, - // End,End_ISpecial,End_BranchSpecial,End_SuppressInterrupt, - //}; - } - - const int VOP_Fetch1 = 256; - const int VOP_RelativeStuff = 257; - const int VOP_RelativeStuff2 = 258; - const int VOP_RelativeStuff3 = 259; - const int VOP_NMI = 260; - const int VOP_IRQ = 261; - const int VOP_RESET = 262; - const int VOP_Fetch1_NoInterrupt = 263; - const int VOP_NUM = 264; - - bool Interrupted - { - get - { - return NMI || (IRQ && !FlagI); - } - } - - void FetchDummy() - { - DummyReadMemory(PC); - } - - public void Execute(int cycles) - { - for (int i = 0; i < cycles; i++) - { - ExecuteOne(); - } - } - - void Fetch1() - { - my_iflag = FlagI; - FlagI = iflag_pending; - if (!branch_irq_hack) - { - interrupt_pending = false; - if (NMI) - { - if (TraceCallback != null) - TraceCallback("====NMI===="); - ea = NMIVector; - opcode = VOP_NMI; - NMI = false; - mi = 0; - ExecuteOneRetry(); - return; - } - else if (IRQ && !my_iflag) - { - if (TraceCallback != null) - TraceCallback("====IRQ===="); - ea = IRQVector; - opcode = VOP_IRQ; - mi = 0; - ExecuteOneRetry(); - return; - } - } - Fetch1_Real(); - } - - void Fetch1_Real() - { - rdy_freeze = !RDY; - if (RDY) - { - if (debug) Console.WriteLine(State()); - branch_irq_hack = false; - if (OnExecFetch != null) OnExecFetch(PC); - if (TraceCallback != null) - TraceCallback(State()); - opcode = ReadMemory(PC++); - mi = -1; - } - } - void Fetch2() - { - rdy_freeze = !RDY; - if (RDY) - { - opcode2 = ReadMemory(PC++); - } - } - void Fetch3() - { - rdy_freeze = !RDY; - if (RDY) - { - opcode3 = ReadMemory(PC++); - } - } - void PushPCH() - { - WriteMemory((ushort)(S-- + 0x100), (byte)(PC >> 8)); - } - void PushPCL() - { - WriteMemory((ushort)(S-- + 0x100), (byte)PC); - } - void PushP_BRK() - { - FlagB = true; - WriteMemory((ushort)(S-- + 0x100), P); - FlagI = true; - ea = BRKVector; - - } - void PushP_IRQ() - { - FlagB = false; - WriteMemory((ushort)(S-- + 0x100), P); - FlagI = true; - ea = IRQVector; - - } - void PushP_NMI() - { - FlagB = false; - WriteMemory((ushort)(S-- + 0x100), P); - FlagI = true; //is this right? - ea = NMIVector; - - } - void PushP_Reset() - { - ea = ResetVector; - S--; - FlagI = true; - - } - void PushDummy() - { - S--; - - } - void FetchPCLVector() - { - rdy_freeze = !RDY; - if (RDY) - { - if (ea == BRKVector && FlagB && NMI) - { - NMI = false; - ea = NMIVector; - } - if (ea == IRQVector && !FlagB && NMI) - { - NMI = false; - ea = NMIVector; - } - alu_temp = ReadMemory((ushort)ea); - } - - } - void FetchPCHVector() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp += ReadMemory((ushort)(ea + 1)) << 8; - PC = (ushort)alu_temp; - } - - } - void Imp_INY() - { - rdy_freeze = !RDY; - if (RDY) - { - FetchDummy(); Y++; NZ_Y(); - } - } - void Imp_DEY() - { - rdy_freeze = !RDY; - if (RDY) - { - FetchDummy(); Y--; NZ_Y(); - } - } - void Imp_INX() - { - rdy_freeze = !RDY; - if (RDY) - { - FetchDummy(); X++; NZ_X(); - } - } - void Imp_DEX() - { - rdy_freeze = !RDY; - if (RDY) - { - FetchDummy(); X--; NZ_X(); - } - } - void NZ_A() - { - P = (byte)((P & 0x7D) | TableNZ[A]); - } - void NZ_X() - { - P = (byte)((P & 0x7D) | TableNZ[X]); - } - void NZ_Y() - { - P = (byte)((P & 0x7D) | TableNZ[Y]); - - } - void Imp_TSX() - { - rdy_freeze = !RDY; - if (RDY) - { - FetchDummy(); X = S; NZ_X(); - } - } - void Imp_TXS() - { - rdy_freeze = !RDY; - if (RDY) - { - FetchDummy(); S = X; - } - } - void Imp_TAX() - { - rdy_freeze = !RDY; - if (RDY) - { - FetchDummy(); X = A; NZ_X(); - } - } - void Imp_TAY() - { - rdy_freeze = !RDY; - if (RDY) - { - FetchDummy(); Y = A; NZ_Y(); - } - } - void Imp_TYA() - { - rdy_freeze = !RDY; - if (RDY) - { - FetchDummy(); A = Y; NZ_A(); - } - } - void Imp_TXA() - { - rdy_freeze = !RDY; - if (RDY) - { - FetchDummy(); A = X; NZ_A(); - } - - } - void Imp_SEI() - { - rdy_freeze = !RDY; - if (RDY) - { - FetchDummy(); iflag_pending = true; - } - } - void Imp_CLI() - { - rdy_freeze = !RDY; - if (RDY) - { - FetchDummy(); iflag_pending = false; - } - } - void Imp_SEC() - { - rdy_freeze = !RDY; - if (RDY) - { - FetchDummy(); FlagC = true; - } - } - void Imp_CLC() - { - rdy_freeze = !RDY; - if (RDY) - { - FetchDummy(); FlagC = false; - } - } - void Imp_SED() - { - rdy_freeze = !RDY; - if (RDY) - { - FetchDummy(); FlagD = true; - } - } - void Imp_CLD() - { - rdy_freeze = !RDY; - if (RDY) - { - FetchDummy(); FlagD = false; - } - } - void Imp_CLV() - { - rdy_freeze = !RDY; - if (RDY) - { - FetchDummy(); FlagV = false; - } - - } - void Abs_WRITE_STA() - { - WriteMemory((ushort)((opcode3 << 8) + opcode2), A); - } - void Abs_WRITE_STX() - { - WriteMemory((ushort)((opcode3 << 8) + opcode2), X); - } - void Abs_WRITE_STY() - { - WriteMemory((ushort)((opcode3 << 8) + opcode2), Y); - } - void Abs_WRITE_SAX() - { - WriteMemory((ushort)((opcode3 << 8) + opcode2), (byte)(X & A)); - - } - void ZP_WRITE_STA() - { - WriteMemory(opcode2, A); - } - void ZP_WRITE_STY() - { - WriteMemory(opcode2, Y); - } - void ZP_WRITE_STX() - { - WriteMemory(opcode2, X); - } - void ZP_WRITE_SAX() - { - WriteMemory(opcode2, (byte)(X & A)); - - } - void IndIdx_Stage3() - { - rdy_freeze = !RDY; - if (RDY) - { - ea = ReadMemory(opcode2); - } - - } - void IndIdx_Stage4() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ea + Y; - ea = (ReadMemory((byte)(opcode2 + 1)) << 8) - | ((alu_temp & 0xFF)); - } - - } - void IndIdx_WRITE_Stage5() - { - rdy_freeze = !RDY; - if (RDY) - { - ReadMemory((ushort)ea); - ea += (alu_temp >> 8) << 8; - } - - } - void IndIdx_READ_Stage5() - { - rdy_freeze = !RDY; - if (RDY) - { - if (!alu_temp.Bit(8)) - { - mi++; - ExecuteOneRetry(); - return; - } - else - { - ReadMemory((ushort)ea); - ea = (ushort)(ea + 0x100); - } - } - } - void IndIdx_RMW_Stage5() - { - rdy_freeze = !RDY; - if (RDY) - { - if (alu_temp.Bit(8)) - ea = (ushort)(ea + 0x100); - ReadMemory((ushort)ea); - } - - } - void IndIdx_WRITE_Stage6_STA() - { - WriteMemory((ushort)ea, A); - - } - void IndIdx_WRITE_Stage6_SHA() - { - WriteMemory((ushort)ea, (byte)(A & X & 7)); - - } - void IndIdx_READ_Stage6_LDA() - { - rdy_freeze = !RDY; - if (RDY) - { - A = ReadMemory((ushort)ea); - NZ_A(); - } - } - void IndIdx_READ_Stage6_CMP() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory((ushort)ea); - _Cmp(); - } - } - void IndIdx_READ_Stage6_AND() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory((ushort)ea); - _And(); - } - } - void IndIdx_READ_Stage6_EOR() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory((ushort)ea); - _Eor(); - } - } - void IndIdx_READ_Stage6_LAX() - { - rdy_freeze = !RDY; - if (RDY) - { - A = X = ReadMemory((ushort)ea); - NZ_A(); - } - } - void IndIdx_READ_Stage6_ADC() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory((ushort)ea); - _Adc(); - } - } - void IndIdx_READ_Stage6_SBC() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory((ushort)ea); - _Sbc(); - } - } - void IndIdx_READ_Stage6_ORA() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory((ushort)ea); - _Ora(); - } - } - void IndIdx_RMW_Stage6() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory((ushort)ea); - } - - } - void IndIdx_RMW_Stage7_SLO() - { - WriteMemory((ushort)ea, (byte)alu_temp); - value8 = (byte)alu_temp; - FlagC = (value8 & 0x80) != 0; - alu_temp = value8 = (byte)((value8 << 1)); - A |= value8; - NZ_A(); - } - void IndIdx_RMW_Stage7_SRE() - { - WriteMemory((ushort)ea, (byte)alu_temp); - value8 = (byte)alu_temp; - FlagC = (value8 & 1) != 0; - alu_temp = value8 = (byte)(value8 >> 1); - A ^= value8; - NZ_A(); - } - void IndIdx_RMW_Stage7_RRA() - { - WriteMemory((ushort)ea, (byte)alu_temp); - value8 = temp8 = (byte)alu_temp; - alu_temp = value8 = (byte)((value8 >> 1) | ((P & 1) << 7)); - FlagC = (temp8 & 1) != 0; - _Adc(); - } - void IndIdx_RMW_Stage7_ISC() - { - WriteMemory((ushort)ea, (byte)alu_temp); - value8 = temp8 = (byte)alu_temp; - alu_temp = value8 = (byte)(value8 + 1); - _Sbc(); - } - void IndIdx_RMW_Stage7_DCP() - { - WriteMemory((ushort)ea, (byte)alu_temp); - value8 = temp8 = (byte)alu_temp; - alu_temp = value8 = (byte)(value8 - 1); - FlagC = (temp8 & 1) != 0; - _Cmp(); - } - void IndIdx_RMW_Stage7_RLA() - { - WriteMemory((ushort)ea, (byte)alu_temp); - value8 = temp8 = (byte)alu_temp; - alu_temp = value8 = (byte)((value8 << 1) | (P & 1)); - FlagC = (temp8 & 0x80) != 0; - A &= value8; - NZ_A(); - } - void IndIdx_RMW_Stage8() - { - WriteMemory((ushort)ea, (byte)alu_temp); - - - } - void RelBranch_Stage2_BVS() - { - branch_taken = FlagV == true; - RelBranch_Stage2(); - } - void RelBranch_Stage2_BVC() - { - branch_taken = FlagV == false; - RelBranch_Stage2(); - } - void RelBranch_Stage2_BMI() - { - branch_taken = FlagN == true; - RelBranch_Stage2(); - } - void RelBranch_Stage2_BPL() - { - branch_taken = FlagN == false; - RelBranch_Stage2(); - } - void RelBranch_Stage2_BCS() - { - branch_taken = FlagC == true; - RelBranch_Stage2(); - } - void RelBranch_Stage2_BCC() - { - branch_taken = FlagC == false; - RelBranch_Stage2(); - } - void RelBranch_Stage2_BEQ() - { - branch_taken = FlagZ == true; - RelBranch_Stage2(); - } - void RelBranch_Stage2_BNE() - { - branch_taken = FlagZ == false; - RelBranch_Stage2(); - - } - void RelBranch_Stage2() - { - rdy_freeze = !RDY; - if (RDY) - { - opcode2 = ReadMemory(PC++); - if (branch_taken) - { - branch_taken = false; - //if the branch is taken, we enter a different bit of microcode to calculate the PC and complete the branch - opcode = VOP_RelativeStuff; - mi = -1; - } - } - - } - void RelBranch_Stage3() - { - FetchDummy(); - alu_temp = (byte)PC + (int)(sbyte)opcode2; - PC &= 0xFF00; - PC |= (ushort)((alu_temp & 0xFF)); - if (alu_temp.Bit(8)) - { - //we need to carry the add, and then we'll be ready to fetch the next instruction - opcode = VOP_RelativeStuff2; - mi = -1; - } - else - { - //to pass cpu_interrupts_v2/5-branch_delays_irq we need to handle a quirk here - //if we decide to interrupt in the next cycle, this condition will cause it to get deferred by one instruction - if (!interrupt_pending) - branch_irq_hack = true; - } - - } - void RelBranch_Stage4() - { - FetchDummy(); - if (alu_temp.Bit(31)) - PC = (ushort)(PC - 0x100); - else PC = (ushort)(PC + 0x100); - - - } - void NOP() - { - } - void DecS() - { - S--; - } - void IncS() - { - S++; - } - void JSR() - { - rdy_freeze = !RDY; - if (RDY) - { - PC = (ushort)((ReadMemory((ushort)(PC)) << 8) + opcode2); - } - } - void PullP() - { - rdy_freeze = !RDY; - if (RDY) - { - P = ReadMemory((ushort)(S++ + 0x100)); - FlagT = true; //force T always to remain true - } - - } - void PullPCL() - { - rdy_freeze = !RDY; - if (RDY) - { - PC &= 0xFF00; - PC |= ReadMemory((ushort)(S++ + 0x100)); - } - - } - void PullPCH_NoInc() - { - rdy_freeze = !RDY; - if (RDY) - { - PC &= 0xFF; - PC |= (ushort)(ReadMemory((ushort)(S + 0x100)) << 8); - } - - } - void Abs_READ_LDA() - { - rdy_freeze = !RDY; - if (RDY) - { - A = ReadMemory((ushort)((opcode3 << 8) + opcode2)); - NZ_A(); - } - } - void Abs_READ_LDY() - { - rdy_freeze = !RDY; - if (RDY) - { - Y = ReadMemory((ushort)((opcode3 << 8) + opcode2)); - NZ_Y(); - } - } - void Abs_READ_LDX() - { - rdy_freeze = !RDY; - if (RDY) - { - X = ReadMemory((ushort)((opcode3 << 8) + opcode2)); - NZ_X(); - } - } - void Abs_READ_BIT() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory((ushort)((opcode3 << 8) + opcode2)); - _Bit(); - } - } - void Abs_READ_LAX() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory((ushort)((opcode3 << 8) + opcode2)); - A = ReadMemory((ushort)((opcode3 << 8) + opcode2)); - X = A; - NZ_A(); - } - } - void Abs_READ_AND() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory((ushort)((opcode3 << 8) + opcode2)); - _And(); - } - } - void Abs_READ_EOR() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory((ushort)((opcode3 << 8) + opcode2)); - _Eor(); - } - } - void Abs_READ_ORA() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory((ushort)((opcode3 << 8) + opcode2)); - _Ora(); - } - } - void Abs_READ_ADC() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory((ushort)((opcode3 << 8) + opcode2)); - _Adc(); - } - } - void Abs_READ_CMP() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory((ushort)((opcode3 << 8) + opcode2)); - _Cmp(); - } - } - void Abs_READ_CPY() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory((ushort)((opcode3 << 8) + opcode2)); - _Cpy(); - } - } - void Abs_READ_NOP() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory((ushort)((opcode3 << 8) + opcode2)); - } - - } - void Abs_READ_CPX() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory((ushort)((opcode3 << 8) + opcode2)); - _Cpx(); - } - } - void Abs_READ_SBC() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory((ushort)((opcode3 << 8) + opcode2)); - _Sbc(); - } - - } - void ZpIdx_Stage3_X() - { - rdy_freeze = !RDY; - if (RDY) - { - ReadMemory(opcode2); - opcode2 = (byte)(opcode2 + X); //a bit sneaky to shove this into opcode2... but we can reuse all the zero page uops if we do that - } - - } - void ZpIdx_Stage3_Y() - { - rdy_freeze = !RDY; - if (RDY) - { - ReadMemory(opcode2); - opcode2 = (byte)(opcode2 + Y); //a bit sneaky to shove this into opcode2... but we can reuse all the zero page uops if we do that - } - - } - void ZpIdx_RMW_Stage4() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory(opcode2); - } - - } - void ZpIdx_RMW_Stage6() - { - WriteMemory(opcode2, (byte)alu_temp); - - - } - void ZP_READ_EOR() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory(opcode2); - _Eor(); - } - } - void ZP_READ_BIT() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory(opcode2); - _Bit(); - } - } - void ZP_READ_LDA() - { - rdy_freeze = !RDY; - if (RDY) - { - A = ReadMemory(opcode2); - NZ_A(); - } - } - void ZP_READ_LDY() - { - rdy_freeze = !RDY; - if (RDY) - { - Y = ReadMemory(opcode2); - NZ_Y(); - } - } - void ZP_READ_LDX() - { - rdy_freeze = !RDY; - if (RDY) - { - X = ReadMemory(opcode2); - NZ_X(); - } - } - void ZP_READ_LAX() - { - rdy_freeze = !RDY; - if (RDY) - { - //?? is this right?? - X = ReadMemory(opcode2); - A = X; - NZ_A(); - } - } - void ZP_READ_CPY() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory(opcode2); - _Cpy(); - } - } - void ZP_READ_CMP() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory(opcode2); - _Cmp(); - } - } - void ZP_READ_CPX() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory(opcode2); - _Cpx(); - } - } - void ZP_READ_ORA() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory(opcode2); - _Ora(); - } - } - void ZP_READ_NOP() - { - rdy_freeze = !RDY; - if (RDY) - { - ReadMemory(opcode2); //just a dummy - } - - } - void ZP_READ_SBC() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory(opcode2); - _Sbc(); - } - } - void ZP_READ_ADC() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory(opcode2); - _Adc(); - } - } - void ZP_READ_AND() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory(opcode2); - _And(); - } - - } - void _Cpx() - { - value8 = (byte)alu_temp; - value16 = (ushort)(X - value8); - FlagC = (X >= value8); - P = (byte)((P & 0x7D) | TableNZ[(byte)value16]); - - } - void _Cpy() - { - value8 = (byte)alu_temp; - value16 = (ushort)(Y - value8); - FlagC = (Y >= value8); - P = (byte)((P & 0x7D) | TableNZ[(byte)value16]); - - } - void _Cmp() - { - value8 = (byte)alu_temp; - value16 = (ushort)(A - value8); - FlagC = (A >= value8); - P = (byte)((P & 0x7D) | TableNZ[(byte)value16]); - - } - void _Bit() - { - FlagN = (alu_temp & 0x80) != 0; - FlagV = (alu_temp & 0x40) != 0; - FlagZ = (A & alu_temp) == 0; - - } - void _Eor() - { - A ^= (byte)alu_temp; - NZ_A(); - } - void _And() - { - A &= (byte)alu_temp; - NZ_A(); - } - void _Ora() - { - A |= (byte)alu_temp; - NZ_A(); - } - void _Anc() - { - A &= (byte)alu_temp; - FlagC = A.Bit(7); - NZ_A(); - } - void _Asr() - { - A &= (byte)alu_temp; - FlagC = A.Bit(0); - A >>= 1; - NZ_A(); - } - void _Axs() - { - X &= A; - alu_temp = X - (byte)alu_temp; - X = (byte)alu_temp; - FlagC = !alu_temp.Bit(8); - NZ_X(); - } - void _Arr() - { - { - A &= (byte)alu_temp; - booltemp = A.Bit(0); - A = (byte)((A >> 1) | (FlagC ? 0x80 : 0x00)); - FlagC = booltemp; - if (A.Bit(5)) - if (A.Bit(6)) - { FlagC = true; FlagV = false; } - else { FlagV = true; FlagC = false; } - else if (A.Bit(6)) - { FlagV = true; FlagC = true; } - else { FlagV = false; FlagC = false; } - FlagZ = (A == 0); - - } - } - void _Lxa() - { - A |= 0xFF; //there is some debate about what this should be. it may depend on the 6502 variant. this is suggested by qeed's doc for the nes and passes blargg's instruction test - A &= (byte)alu_temp; - X = A; - NZ_A(); - } - void _Sbc() - { - { - value8 = (byte)alu_temp; - tempint = A - value8 - (FlagC ? 0 : 1); - if (FlagD && BCD_Enabled) - { - lo = (A & 0x0F) - (value8 & 0x0F) - (FlagC ? 0 : 1); - hi = (A & 0xF0) - (value8 & 0xF0); - if ((lo & 0xF0) != 0) lo -= 0x06; - if ((lo & 0x80) != 0) hi -= 0x10; - if ((hi & 0x0F00) != 0) hi -= 0x60; - FlagV = ((A ^ value8) & (A ^ tempint) & 0x80) != 0; - FlagC = (hi & 0xFF00) == 0; - A = (byte)((lo & 0x0F) | (hi & 0xF0)); - } - else - { - FlagV = ((A ^ value8) & (A ^ tempint) & 0x80) != 0; - FlagC = tempint >= 0; - A = (byte)tempint; - } - NZ_A(); - } - } - void _Adc() - { - { - //TODO - an extra cycle penalty? - value8 = (byte)alu_temp; - if (FlagD && BCD_Enabled) - { - lo = (A & 0x0F) + (value8 & 0x0F) + (FlagC ? 1 : 0); - hi = (A & 0xF0) + (value8 & 0xF0); - if (lo > 0x09) - { - hi += 0x10; - lo += 0x06; - } - if (hi > 0x90) hi += 0x60; - FlagV = (~(A ^ value8) & (A ^ hi) & 0x80) != 0; - FlagC = hi > 0xFF; - A = (byte)((lo & 0x0F) | (hi & 0xF0)); - } - else - { - tempint = value8 + A + (FlagC ? 1 : 0); - FlagV = (~(A ^ value8) & (A ^ tempint) & 0x80) != 0; - FlagC = tempint > 0xFF; - A = (byte)tempint; - } - NZ_A(); - } - - } - void Unsupported() - { - - - } - void Imm_EOR() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory(PC++); - _Eor(); - } - } - void Imm_ANC() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory(PC++); - _Anc(); - } - } - void Imm_ASR() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory(PC++); - _Asr(); - } - } - void Imm_AXS() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory(PC++); - _Axs(); - } - } - void Imm_ARR() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory(PC++); - _Arr(); - } - } - void Imm_LXA() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory(PC++); - _Lxa(); - } - } - void Imm_ORA() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory(PC++); - _Ora(); - } - } - void Imm_CPY() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory(PC++); - _Cpy(); - } - } - void Imm_CPX() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory(PC++); - _Cpx(); - } - } - void Imm_CMP() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory(PC++); - _Cmp(); - } - } - void Imm_SBC() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory(PC++); - _Sbc(); - } - } - void Imm_AND() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory(PC++); - _And(); - } - } - void Imm_ADC() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory(PC++); - _Adc(); - } - } - void Imm_LDA() - { - rdy_freeze = !RDY; - if (RDY) - { - A = ReadMemory(PC++); - NZ_A(); - } - } - void Imm_LDX() - { - rdy_freeze = !RDY; - if (RDY) - { - X = ReadMemory(PC++); - NZ_X(); - } - } - void Imm_LDY() - { - rdy_freeze = !RDY; - if (RDY) - { - Y = ReadMemory(PC++); - NZ_Y(); - } - } - void Imm_Unsupported() - { - rdy_freeze = !RDY; - if (RDY) - { - ReadMemory(PC++); - } - - } - void IdxInd_Stage3() - { - rdy_freeze = !RDY; - if (RDY) - { - ReadMemory(opcode2); //dummy? - alu_temp = (opcode2 + X) & 0xFF; - } - - } - void IdxInd_Stage4() - { - rdy_freeze = !RDY; - if (RDY) - { - ea = ReadMemory((ushort)alu_temp); - } - - } - void IdxInd_Stage5() - { - rdy_freeze = !RDY; - if (RDY) - { - ea += (ReadMemory((byte)(alu_temp + 1)) << 8); - } - - } - void IdxInd_Stage6_READ_LDA() - { - rdy_freeze = !RDY; - if (RDY) - { - //TODO make uniform with others - A = ReadMemory((ushort)ea); - NZ_A(); - } - } - void IdxInd_Stage6_READ_ORA() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory((ushort)ea); - _Ora(); - } - } - void IdxInd_Stage6_READ_LAX() - { - rdy_freeze = !RDY; - if (RDY) - { - A = X = ReadMemory((ushort)ea); - NZ_A(); - } - } - void IdxInd_Stage6_READ_CMP() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory((ushort)ea); - _Cmp(); - } - } - void IdxInd_Stage6_READ_ADC() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory((ushort)ea); - _Adc(); - } - } - void IdxInd_Stage6_READ_AND() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory((ushort)ea); - _And(); - } - } - void IdxInd_Stage6_READ_EOR() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory((ushort)ea); - _Eor(); - } - } - void IdxInd_Stage6_READ_SBC() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory((ushort)ea); - _Sbc(); - } - } - void IdxInd_Stage6_WRITE_STA() - { - WriteMemory((ushort)ea, A); - - } - void IdxInd_Stage6_WRITE_SAX() - { - alu_temp = A & X; - WriteMemory((ushort)ea, (byte)alu_temp); - //flag writing skipped on purpose - - } - void IdxInd_Stage6_RMW() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory((ushort)ea); - } - - } - void IdxInd_Stage7_RMW_SLO() - { - WriteMemory((ushort)ea, (byte)alu_temp); - value8 = (byte)alu_temp; - FlagC = (value8 & 0x80) != 0; - alu_temp = value8 = (byte)((value8 << 1)); - A |= value8; - NZ_A(); - } - void IdxInd_Stage7_RMW_ISC() - { - WriteMemory((ushort)ea, (byte)alu_temp); - value8 = (byte)alu_temp; - alu_temp = value8 = (byte)(value8 + 1); - _Sbc(); - } - void IdxInd_Stage7_RMW_DCP() - { - WriteMemory((ushort)ea, (byte)alu_temp); - value8 = temp8 = (byte)alu_temp; - alu_temp = value8 = (byte)(value8 - 1); - FlagC = (temp8 & 1) != 0; - _Cmp(); - } - void IdxInd_Stage7_RMW_SRE() - { - WriteMemory((ushort)ea, (byte)alu_temp); - value8 = (byte)alu_temp; - FlagC = (value8 & 1) != 0; - alu_temp = value8 = (byte)(value8 >> 1); - A ^= value8; - NZ_A(); - } - void IdxInd_Stage7_RMW_RRA() - { - WriteMemory((ushort)ea, (byte)alu_temp); - value8 = (byte)alu_temp; - value8 = temp8 = (byte)alu_temp; - alu_temp = value8 = (byte)((value8 >> 1) | ((P & 1) << 7)); - FlagC = (temp8 & 1) != 0; - _Adc(); - } - void IdxInd_Stage7_RMW_RLA() - { - WriteMemory((ushort)ea, (byte)alu_temp); - value8 = temp8 = (byte)alu_temp; - alu_temp = value8 = (byte)((value8 << 1) | (P & 1)); - FlagC = (temp8 & 0x80) != 0; - A &= value8; - NZ_A(); - } - void IdxInd_Stage8_RMW() - { - WriteMemory((ushort)ea, (byte)alu_temp); - - - } - void PushP() - { - FlagB = true; - WriteMemory((ushort)(S-- + 0x100), P); - - } - void PushA() - { - WriteMemory((ushort)(S-- + 0x100), A); - } - void PullA_NoInc() - { - rdy_freeze = !RDY; - if (RDY) - { - A = ReadMemory((ushort)(S + 0x100)); - NZ_A(); - } - } - void PullP_NoInc() - { - rdy_freeze = !RDY; - if (RDY) - { - my_iflag = FlagI; - P = ReadMemory((ushort)(S + 0x100)); - iflag_pending = FlagI; - FlagI = my_iflag; - FlagT = true; //force T always to remain true - - } - - } - void Imp_ASL_A() - { - FetchDummy(); - FlagC = (A & 0x80) != 0; - A = (byte)(A << 1); - NZ_A(); - } - void Imp_ROL_A() - { - FetchDummy(); - temp8 = A; - A = (byte)((A << 1) | (P & 1)); - FlagC = (temp8 & 0x80) != 0; - NZ_A(); - } - void Imp_ROR_A() - { - FetchDummy(); - temp8 = A; - A = (byte)((A >> 1) | ((P & 1) << 7)); - FlagC = (temp8 & 1) != 0; - NZ_A(); - } - void Imp_LSR_A() - { - FetchDummy(); - FlagC = (A & 1) != 0; - A = (byte)(A >> 1); - NZ_A(); - - } - void JMP_abs() - { - rdy_freeze = !RDY; - if (RDY) - { - PC = (ushort)((ReadMemory(PC) << 8) + opcode2); - } - - } - void IncPC() - { - PC++; - - - } - void ZP_RMW_Stage3() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory(opcode2); - } - - } - void ZP_RMW_Stage5() - { - WriteMemory(opcode2, (byte)alu_temp); - - } - void ZP_RMW_INC() - { - WriteMemory(opcode2, (byte)alu_temp); - alu_temp = (byte)((alu_temp + 1) & 0xFF); - P = (byte)((P & 0x7D) | TableNZ[alu_temp]); - - } - void ZP_RMW_DEC() - { - WriteMemory(opcode2, (byte)alu_temp); - alu_temp = (byte)((alu_temp - 1) & 0xFF); - P = (byte)((P & 0x7D) | TableNZ[alu_temp]); - - } - void ZP_RMW_ASL() - { - WriteMemory(opcode2, (byte)alu_temp); - value8 = (byte)alu_temp; - FlagC = (value8 & 0x80) != 0; - alu_temp = value8 = (byte)(value8 << 1); - P = (byte)((P & 0x7D) | TableNZ[value8]); - - } - void ZP_RMW_SRE() - { - WriteMemory(opcode2, (byte)alu_temp); - value8 = (byte)alu_temp; - FlagC = (value8 & 1) != 0; - alu_temp = value8 = (byte)(value8 >> 1); - A ^= value8; - NZ_A(); - } - void ZP_RMW_RRA() - { - WriteMemory(opcode2, (byte)alu_temp); - value8 = temp8 = (byte)alu_temp; - alu_temp = value8 = (byte)((value8 >> 1) | ((P & 1) << 7)); - FlagC = (temp8 & 1) != 0; - _Adc(); - } - void ZP_RMW_DCP() - { - WriteMemory(opcode2, (byte)alu_temp); - value8 = temp8 = (byte)alu_temp; - alu_temp = value8 = (byte)(value8 - 1); - FlagC = (temp8 & 1) != 0; - _Cmp(); - } - void ZP_RMW_LSR() - { - WriteMemory(opcode2, (byte)alu_temp); - value8 = (byte)alu_temp; - FlagC = (value8 & 1) != 0; - alu_temp = value8 = (byte)(value8 >> 1); - P = (byte)((P & 0x7D) | TableNZ[value8]); - - } - void ZP_RMW_ROR() - { - WriteMemory(opcode2, (byte)alu_temp); - value8 = temp8 = (byte)alu_temp; - alu_temp = value8 = (byte)((value8 >> 1) | ((P & 1) << 7)); - FlagC = (temp8 & 1) != 0; - P = (byte)((P & 0x7D) | TableNZ[value8]); - - } - void ZP_RMW_ROL() - { - WriteMemory(opcode2, (byte)alu_temp); - value8 = temp8 = (byte)alu_temp; - alu_temp = value8 = (byte)((value8 << 1) | (P & 1)); - FlagC = (temp8 & 0x80) != 0; - P = (byte)((P & 0x7D) | TableNZ[value8]); - - } - void ZP_RMW_SLO() - { - WriteMemory(opcode2, (byte)alu_temp); - value8 = (byte)alu_temp; - FlagC = (value8 & 0x80) != 0; - alu_temp = value8 = (byte)((value8 << 1)); - A |= value8; - NZ_A(); - } - void ZP_RMW_ISC() - { - WriteMemory(opcode2, (byte)alu_temp); - value8 = (byte)alu_temp; - alu_temp = value8 = (byte)(value8 + 1); - _Sbc(); - } - void ZP_RMW_RLA() - { - WriteMemory(opcode2, (byte)alu_temp); - value8 = temp8 = (byte)alu_temp; - alu_temp = value8 = (byte)((value8 << 1) | (P & 1)); - FlagC = (temp8 & 0x80) != 0; - A &= value8; - NZ_A(); - - } - void AbsIdx_Stage3_Y() - { - rdy_freeze = !RDY; - if (RDY) - { - opcode3 = ReadMemory(PC++); - alu_temp = opcode2 + Y; - ea = (opcode3 << 8) + (alu_temp & 0xFF); - - //new Uop[] { Uop.Fetch2, Uop.AbsIdx_Stage3_Y, Uop.AbsIdx_Stage4, Uop.AbsIdx_WRITE_Stage5_STA, Uop.End }, - } - } - void AbsIdx_Stage3_X() - { - rdy_freeze = !RDY; - if (RDY) - { - opcode3 = ReadMemory(PC++); - alu_temp = opcode2 + X; - ea = (opcode3 << 8) + (alu_temp & 0xFF); - } - - } - void AbsIdx_READ_Stage4() - { - rdy_freeze = !RDY; - if (RDY) - { - if (!alu_temp.Bit(8)) - { - mi++; - ExecuteOneRetry(); - return; - } - else - { - alu_temp = ReadMemory((ushort)ea); - ea = (ushort)(ea + 0x100); - } - } - - } - void AbsIdx_Stage4() - { - rdy_freeze = !RDY; - if (RDY) - { - //bleh.. redundant code to make sure we dont clobber alu_temp before using it to decide whether to change ea - if (alu_temp.Bit(8)) - { - alu_temp = ReadMemory((ushort)ea); - ea = (ushort)(ea + 0x100); - } - else alu_temp = ReadMemory((ushort)ea); - } - - } - void AbsIdx_WRITE_Stage5_STA() - { - WriteMemory((ushort)ea, A); - - } - void AbsIdx_WRITE_Stage5_SHY() - { - alu_temp = Y & (ea >> 8); - ea = (ea & 0xFF) | (alu_temp << 8); //"(the bank where the value is stored may be equal to the value stored)" -- more like IS. - WriteMemory((ushort)ea, (byte)alu_temp); - - } - void AbsIdx_WRITE_Stage5_SHX() - { - alu_temp = X & (ea >> 8); - ea = (ea & 0xFF) | (alu_temp << 8); //"(the bank where the value is stored may be equal to the value stored)" -- more like IS. - WriteMemory((ushort)ea, (byte)alu_temp); - - } - void AbsIdx_WRITE_Stage5_ERROR() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory((ushort)ea); - //throw new InvalidOperationException("UNSUPPORTED OPCODE [probably SHS] PLEASE REPORT"); - } - - } - void AbsIdx_RMW_Stage5() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory((ushort)ea); - } - - } - void AbsIdx_RMW_Stage7() - { - WriteMemory((ushort)ea, (byte)alu_temp); - - } - void AbsIdx_RMW_Stage6_DEC() - { - WriteMemory((ushort)ea, (byte)alu_temp); - alu_temp = value8 = (byte)(alu_temp - 1); - P = (byte)((P & 0x7D) | TableNZ[value8]); - - } - void AbsIdx_RMW_Stage6_DCP() - { - WriteMemory((ushort)ea, (byte)alu_temp); - alu_temp = value8 = (byte)(alu_temp - 1); - _Cmp(); - } - void AbsIdx_RMW_Stage6_ISC() - { - WriteMemory((ushort)ea, (byte)alu_temp); - alu_temp = value8 = (byte)(alu_temp + 1); - _Sbc(); - } - void AbsIdx_RMW_Stage6_INC() - { - WriteMemory((ushort)ea, (byte)alu_temp); - alu_temp = value8 = (byte)(alu_temp + 1); - P = (byte)((P & 0x7D) | TableNZ[value8]); - - } - void AbsIdx_RMW_Stage6_ROL() - { - WriteMemory((ushort)ea, (byte)alu_temp); - value8 = temp8 = (byte)alu_temp; - alu_temp = value8 = (byte)((value8 << 1) | (P & 1)); - FlagC = (temp8 & 0x80) != 0; - P = (byte)((P & 0x7D) | TableNZ[value8]); - - } - void AbsIdx_RMW_Stage6_LSR() - { - WriteMemory((ushort)ea, (byte)alu_temp); - value8 = (byte)alu_temp; - FlagC = (value8 & 1) != 0; - alu_temp = value8 = (byte)(value8 >> 1); - P = (byte)((P & 0x7D) | TableNZ[value8]); - - } - void AbsIdx_RMW_Stage6_SLO() - { - WriteMemory((ushort)ea, (byte)alu_temp); - value8 = (byte)alu_temp; - FlagC = (value8 & 0x80) != 0; - alu_temp = value8 = (byte)(value8 << 1); - A |= value8; - NZ_A(); - } - void AbsIdx_RMW_Stage6_SRE() - { - WriteMemory((ushort)ea, (byte)alu_temp); - value8 = (byte)alu_temp; - FlagC = (value8 & 1) != 0; - alu_temp = value8 = (byte)(value8 >> 1); - A ^= value8; - NZ_A(); - } - void AbsIdx_RMW_Stage6_RRA() - { - WriteMemory((ushort)ea, (byte)alu_temp); - value8 = temp8 = (byte)alu_temp; - alu_temp = value8 = (byte)((value8 >> 1) | ((P & 1) << 7)); - FlagC = (temp8 & 1) != 0; - _Adc(); - } - void AbsIdx_RMW_Stage6_RLA() - { - WriteMemory((ushort)ea, (byte)alu_temp); - value8 = temp8 = (byte)alu_temp; - alu_temp = value8 = (byte)((value8 << 1) | (P & 1)); - FlagC = (temp8 & 0x80) != 0; - A &= value8; - NZ_A(); - } - void AbsIdx_RMW_Stage6_ASL() - { - WriteMemory((ushort)ea, (byte)alu_temp); - value8 = (byte)alu_temp; - FlagC = (value8 & 0x80) != 0; - alu_temp = value8 = (byte)(value8 << 1); - P = (byte)((P & 0x7D) | TableNZ[value8]); - - } - void AbsIdx_RMW_Stage6_ROR() - { - WriteMemory((ushort)ea, (byte)alu_temp); - value8 = temp8 = (byte)alu_temp; - alu_temp = value8 = (byte)((value8 >> 1) | ((P & 1) << 7)); - FlagC = (temp8 & 1) != 0; - P = (byte)((P & 0x7D) | TableNZ[value8]); - - - } - void AbsIdx_READ_Stage5_LDA() - { - rdy_freeze = !RDY; - if (RDY) - { - A = ReadMemory((ushort)ea); - NZ_A(); - } - } - void AbsIdx_READ_Stage5_LDX() - { - rdy_freeze = !RDY; - if (RDY) - { - X = ReadMemory((ushort)ea); - NZ_X(); - } - } - void AbsIdx_READ_Stage5_LAX() - { - rdy_freeze = !RDY; - if (RDY) - { - A = ReadMemory((ushort)ea); - X = A; - NZ_A(); - } - } - void AbsIdx_READ_Stage5_LDY() - { - rdy_freeze = !RDY; - if (RDY) - { - Y = ReadMemory((ushort)ea); - NZ_Y(); - } - } - void AbsIdx_READ_Stage5_ORA() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory((ushort)ea); - _Ora(); - } - } - void AbsIdx_READ_Stage5_NOP() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory((ushort)ea); - } - - } - void AbsIdx_READ_Stage5_CMP() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory((ushort)ea); - _Cmp(); - } - } - void AbsIdx_READ_Stage5_SBC() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory((ushort)ea); - _Sbc(); - } - } - void AbsIdx_READ_Stage5_ADC() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory((ushort)ea); - _Adc(); - } - } - void AbsIdx_READ_Stage5_EOR() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory((ushort)ea); - _Eor(); - } - } - void AbsIdx_READ_Stage5_AND() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory((ushort)ea); - _And(); - } - } - void AbsIdx_READ_Stage5_ERROR() - { - rdy_freeze = !RDY; - if (RDY) - { - alu_temp = ReadMemory((ushort)ea); - //throw new InvalidOperationException("UNSUPPORTED OPCODE [probably LAS] PLEASE REPORT"); - } - - } - void AbsInd_JMP_Stage4() - { - rdy_freeze = !RDY; - if (RDY) - { - ea = (opcode3 << 8) + opcode2; - alu_temp = ReadMemory((ushort)ea); - } - } - void AbsInd_JMP_Stage5() - { - rdy_freeze = !RDY; - if (RDY) - { - ea = (opcode3 << 8) + (byte)(opcode2 + 1); - alu_temp += ReadMemory((ushort)ea) << 8; - PC = (ushort)alu_temp; - } - - } - void Abs_RMW_Stage4() - { - rdy_freeze = !RDY; - if (RDY) - { - ea = (opcode3 << 8) + opcode2; - alu_temp = ReadMemory((ushort)ea); - } - - } - void Abs_RMW_Stage5_INC() - { - WriteMemory((ushort)ea, (byte)alu_temp); - value8 = (byte)(alu_temp + 1); - alu_temp = value8; - P = (byte)((P & 0x7D) | TableNZ[value8]); - - } - void Abs_RMW_Stage5_DEC() - { - WriteMemory((ushort)ea, (byte)alu_temp); - value8 = (byte)(alu_temp - 1); - alu_temp = value8; - P = (byte)((P & 0x7D) | TableNZ[value8]); - - } - void Abs_RMW_Stage5_DCP() - { - WriteMemory((ushort)ea, (byte)alu_temp); - value8 = (byte)(alu_temp - 1); - alu_temp = value8; - _Cmp(); - } - void Abs_RMW_Stage5_ISC() - { - WriteMemory((ushort)ea, (byte)alu_temp); - value8 = (byte)(alu_temp + 1); - alu_temp = value8; - _Sbc(); - } - void Abs_RMW_Stage5_ASL() - { - WriteMemory((ushort)ea, (byte)alu_temp); - value8 = (byte)alu_temp; - FlagC = (value8 & 0x80) != 0; - alu_temp = value8 = (byte)(value8 << 1); - P = (byte)((P & 0x7D) | TableNZ[value8]); - - } - void Abs_RMW_Stage5_ROR() - { - WriteMemory((ushort)ea, (byte)alu_temp); - value8 = temp8 = (byte)alu_temp; - alu_temp = value8 = (byte)((value8 >> 1) | ((P & 1) << 7)); - FlagC = (temp8 & 1) != 0; - P = (byte)((P & 0x7D) | TableNZ[value8]); - - } - void Abs_RMW_Stage5_SLO() - { - WriteMemory((ushort)ea, (byte)alu_temp); - value8 = (byte)alu_temp; - FlagC = (value8 & 0x80) != 0; - alu_temp = value8 = (byte)(value8 << 1); - A |= value8; - NZ_A(); - } - void Abs_RMW_Stage5_RLA() - { - WriteMemory((ushort)ea, (byte)alu_temp); - value8 = temp8 = (byte)alu_temp; - alu_temp = value8 = (byte)((value8 << 1) | (P & 1)); - FlagC = (temp8 & 0x80) != 0; - A &= value8; - NZ_A(); - } - void Abs_RMW_Stage5_SRE() - { - WriteMemory((ushort)ea, (byte)alu_temp); - value8 = (byte)alu_temp; - FlagC = (value8 & 1) != 0; - alu_temp = value8 = (byte)(value8 >> 1); - A ^= value8; - NZ_A(); - } - void Abs_RMW_Stage5_RRA() - { - WriteMemory((ushort)ea, (byte)alu_temp); - value8 = temp8 = (byte)alu_temp; - alu_temp = value8 = (byte)((value8 >> 1) | ((P & 1) << 7)); - FlagC = (temp8 & 1) != 0; - _Adc(); - } - void Abs_RMW_Stage5_ROL() - { - WriteMemory((ushort)ea, (byte)alu_temp); - value8 = temp8 = (byte)alu_temp; - alu_temp = value8 = (byte)((value8 << 1) | (P & 1)); - FlagC = (temp8 & 0x80) != 0; - P = (byte)((P & 0x7D) | TableNZ[value8]); - - } - void Abs_RMW_Stage5_LSR() - { - WriteMemory((ushort)ea, (byte)alu_temp); - value8 = (byte)alu_temp; - FlagC = (value8 & 1) != 0; - alu_temp = value8 = (byte)(value8 >> 1); - P = (byte)((P & 0x7D) | TableNZ[value8]); - - - } - void Abs_RMW_Stage6() - { - WriteMemory((ushort)ea, (byte)alu_temp); - - - } - void End_ISpecial() - { - opcode = VOP_Fetch1; - mi = 0; - ExecuteOneRetry(); - return; - - } - void End_SuppressInterrupt() - { - opcode = VOP_Fetch1_NoInterrupt; - mi = 0; - ExecuteOneRetry(); - return; - - } - void End() - { - opcode = VOP_Fetch1; - mi = 0; - iflag_pending = FlagI; - ExecuteOneRetry(); - return; - } - void End_BranchSpecial() - { - End(); - } - - void ExecuteOneRetry() - { - //dont know whether this system is any faster. hard to get benchmarks someone else try it? - //Uop uop = (Uop)CompiledMicrocode[MicrocodeIndex[opcode] + mi]; - Uop uop = Microcode[opcode][mi]; - switch (uop) - { - default: throw new InvalidOperationException(); - case Uop.Fetch1: Fetch1(); break; - case Uop.Fetch1_Real: Fetch1_Real(); break; - case Uop.Fetch2: Fetch2(); break; - case Uop.Fetch3: Fetch3(); break; - case Uop.FetchDummy: FetchDummy(); break; - case Uop.PushPCH: PushPCH(); break; - case Uop.PushPCL: PushPCL(); break; - case Uop.PushP_BRK: PushP_BRK(); break; - case Uop.PushP_IRQ: PushP_IRQ(); break; - case Uop.PushP_NMI: PushP_NMI(); break; - case Uop.PushP_Reset: PushP_Reset(); break; - case Uop.PushDummy: PushDummy(); break; - case Uop.FetchPCLVector: FetchPCLVector(); break; - case Uop.FetchPCHVector: FetchPCHVector(); break; - case Uop.Imp_INY: Imp_INY(); break; - case Uop.Imp_DEY: Imp_DEY(); break; - case Uop.Imp_INX: Imp_INX(); break; - case Uop.Imp_DEX: Imp_DEX(); break; - case Uop.NZ_A: NZ_A(); break; - case Uop.NZ_X: NZ_X(); break; - case Uop.NZ_Y: NZ_Y(); break; - case Uop.Imp_TSX: Imp_TSX(); break; - case Uop.Imp_TXS: Imp_TXS(); break; - case Uop.Imp_TAX: Imp_TAX(); break; - case Uop.Imp_TAY: Imp_TAY(); break; - case Uop.Imp_TYA: Imp_TYA(); break; - case Uop.Imp_TXA: Imp_TXA(); break; - case Uop.Imp_SEI: Imp_SEI(); break; - case Uop.Imp_CLI: Imp_CLI(); break; - case Uop.Imp_SEC: Imp_SEC(); break; - case Uop.Imp_CLC: Imp_CLC(); break; - case Uop.Imp_SED: Imp_SED(); break; - case Uop.Imp_CLD: Imp_CLD(); break; - case Uop.Imp_CLV: Imp_CLV(); break; - case Uop.Abs_WRITE_STA: Abs_WRITE_STA(); break; - case Uop.Abs_WRITE_STX: Abs_WRITE_STX(); break; - case Uop.Abs_WRITE_STY: Abs_WRITE_STY(); break; - case Uop.Abs_WRITE_SAX: Abs_WRITE_SAX(); break; - case Uop.ZP_WRITE_STA: ZP_WRITE_STA(); break; - case Uop.ZP_WRITE_STY: ZP_WRITE_STY(); break; - case Uop.ZP_WRITE_STX: ZP_WRITE_STX(); break; - case Uop.ZP_WRITE_SAX: ZP_WRITE_SAX(); break; - case Uop.IndIdx_Stage3: IndIdx_Stage3(); break; - case Uop.IndIdx_Stage4: IndIdx_Stage4(); break; - case Uop.IndIdx_WRITE_Stage5: IndIdx_WRITE_Stage5(); break; - case Uop.IndIdx_READ_Stage5: IndIdx_READ_Stage5(); break; - case Uop.IndIdx_RMW_Stage5: IndIdx_RMW_Stage5(); break; - case Uop.IndIdx_WRITE_Stage6_STA: IndIdx_WRITE_Stage6_STA(); break; - case Uop.IndIdx_WRITE_Stage6_SHA: IndIdx_WRITE_Stage6_SHA(); break; - case Uop.IndIdx_READ_Stage6_LDA: IndIdx_READ_Stage6_LDA(); break; - case Uop.IndIdx_READ_Stage6_CMP: IndIdx_READ_Stage6_CMP(); break; - case Uop.IndIdx_READ_Stage6_AND: IndIdx_READ_Stage6_AND(); break; - case Uop.IndIdx_READ_Stage6_EOR: IndIdx_READ_Stage6_EOR(); break; - case Uop.IndIdx_READ_Stage6_LAX: IndIdx_READ_Stage6_LAX(); break; - case Uop.IndIdx_READ_Stage6_ADC: IndIdx_READ_Stage6_ADC(); break; - case Uop.IndIdx_READ_Stage6_SBC: IndIdx_READ_Stage6_SBC(); break; - case Uop.IndIdx_READ_Stage6_ORA: IndIdx_READ_Stage6_ORA(); break; - case Uop.IndIdx_RMW_Stage6: IndIdx_RMW_Stage6(); break; - case Uop.IndIdx_RMW_Stage7_SLO: IndIdx_RMW_Stage7_SLO(); break; - case Uop.IndIdx_RMW_Stage7_SRE: IndIdx_RMW_Stage7_SRE(); break; - case Uop.IndIdx_RMW_Stage7_RRA: IndIdx_RMW_Stage7_RRA(); break; - case Uop.IndIdx_RMW_Stage7_ISC: IndIdx_RMW_Stage7_ISC(); break; - case Uop.IndIdx_RMW_Stage7_DCP: IndIdx_RMW_Stage7_DCP(); break; - case Uop.IndIdx_RMW_Stage7_RLA: IndIdx_RMW_Stage7_RLA(); break; - case Uop.IndIdx_RMW_Stage8: IndIdx_RMW_Stage8(); break; - case Uop.RelBranch_Stage2_BVS: RelBranch_Stage2_BVS(); break; - case Uop.RelBranch_Stage2_BVC: RelBranch_Stage2_BVC(); break; - case Uop.RelBranch_Stage2_BMI: RelBranch_Stage2_BMI(); break; - case Uop.RelBranch_Stage2_BPL: RelBranch_Stage2_BPL(); break; - case Uop.RelBranch_Stage2_BCS: RelBranch_Stage2_BCS(); break; - case Uop.RelBranch_Stage2_BCC: RelBranch_Stage2_BCC(); break; - case Uop.RelBranch_Stage2_BEQ: RelBranch_Stage2_BEQ(); break; - case Uop.RelBranch_Stage2_BNE: RelBranch_Stage2_BNE(); break; - case Uop.RelBranch_Stage2: RelBranch_Stage2(); break; - case Uop.RelBranch_Stage3: RelBranch_Stage3(); break; - case Uop.RelBranch_Stage4: RelBranch_Stage4(); break; - case Uop.NOP: NOP(); break; - case Uop.DecS: DecS(); break; - case Uop.IncS: IncS(); break; - case Uop.JSR: JSR(); break; - case Uop.PullP: PullP(); break; - case Uop.PullPCL: PullPCL(); break; - case Uop.PullPCH_NoInc: PullPCH_NoInc(); break; - case Uop.Abs_READ_LDA: Abs_READ_LDA(); break; - case Uop.Abs_READ_LDY: Abs_READ_LDY(); break; - case Uop.Abs_READ_LDX: Abs_READ_LDX(); break; - case Uop.Abs_READ_BIT: Abs_READ_BIT(); break; - case Uop.Abs_READ_LAX: Abs_READ_LAX(); break; - case Uop.Abs_READ_AND: Abs_READ_AND(); break; - case Uop.Abs_READ_EOR: Abs_READ_EOR(); break; - case Uop.Abs_READ_ORA: Abs_READ_ORA(); break; - case Uop.Abs_READ_ADC: Abs_READ_ADC(); break; - case Uop.Abs_READ_CMP: Abs_READ_CMP(); break; - case Uop.Abs_READ_CPY: Abs_READ_CPY(); break; - case Uop.Abs_READ_NOP: Abs_READ_NOP(); break; - case Uop.Abs_READ_CPX: Abs_READ_CPX(); break; - case Uop.Abs_READ_SBC: Abs_READ_SBC(); break; - case Uop.ZpIdx_Stage3_X: ZpIdx_Stage3_X(); break; - case Uop.ZpIdx_Stage3_Y: ZpIdx_Stage3_Y(); break; - case Uop.ZpIdx_RMW_Stage4: ZpIdx_RMW_Stage4(); break; - case Uop.ZpIdx_RMW_Stage6: ZpIdx_RMW_Stage6(); break; - case Uop.ZP_READ_EOR: ZP_READ_EOR(); break; - case Uop.ZP_READ_BIT: ZP_READ_BIT(); break; - case Uop.ZP_READ_LDA: ZP_READ_LDA(); break; - case Uop.ZP_READ_LDY: ZP_READ_LDY(); break; - case Uop.ZP_READ_LDX: ZP_READ_LDX(); break; - case Uop.ZP_READ_LAX: ZP_READ_LAX(); break; - case Uop.ZP_READ_CPY: ZP_READ_CPY(); break; - case Uop.ZP_READ_CMP: ZP_READ_CMP(); break; - case Uop.ZP_READ_CPX: ZP_READ_CPX(); break; - case Uop.ZP_READ_ORA: ZP_READ_ORA(); break; - case Uop.ZP_READ_NOP: ZP_READ_NOP(); break; - case Uop.ZP_READ_SBC: ZP_READ_SBC(); break; - case Uop.ZP_READ_ADC: ZP_READ_ADC(); break; - case Uop.ZP_READ_AND: ZP_READ_AND(); break; - case Uop._Cpx: _Cpx(); break; - case Uop._Cpy: _Cpy(); break; - case Uop._Cmp: _Cmp(); break; - case Uop._Eor: _Eor(); break; - case Uop._And: _And(); break; - case Uop._Ora: _Ora(); break; - case Uop._Anc: _Anc(); break; - case Uop._Asr: _Asr(); break; - case Uop._Axs: _Axs(); break; - case Uop._Arr: _Arr(); break; - case Uop._Lxa: _Lxa(); break; - case Uop._Sbc: _Sbc(); break; - case Uop._Adc: _Adc(); break; - case Uop.Unsupported: Unsupported(); break; - case Uop.Imm_EOR: Imm_EOR(); break; - case Uop.Imm_ANC: Imm_ANC(); break; - case Uop.Imm_ASR: Imm_ASR(); break; - case Uop.Imm_AXS: Imm_AXS(); break; - case Uop.Imm_ARR: Imm_ARR(); break; - case Uop.Imm_LXA: Imm_LXA(); break; - case Uop.Imm_ORA: Imm_ORA(); break; - case Uop.Imm_CPY: Imm_CPY(); break; - case Uop.Imm_CPX: Imm_CPX(); break; - case Uop.Imm_CMP: Imm_CMP(); break; - case Uop.Imm_SBC: Imm_SBC(); break; - case Uop.Imm_AND: Imm_AND(); break; - case Uop.Imm_ADC: Imm_ADC(); break; - case Uop.Imm_LDA: Imm_LDA(); break; - case Uop.Imm_LDX: Imm_LDX(); break; - case Uop.Imm_LDY: Imm_LDY(); break; - case Uop.Imm_Unsupported: Imm_Unsupported(); break; - case Uop.IdxInd_Stage3: IdxInd_Stage3(); break; - case Uop.IdxInd_Stage4: IdxInd_Stage4(); break; - case Uop.IdxInd_Stage5: IdxInd_Stage5(); break; - case Uop.IdxInd_Stage6_READ_LDA: IdxInd_Stage6_READ_LDA(); break; - case Uop.IdxInd_Stage6_READ_ORA: IdxInd_Stage6_READ_ORA(); break; - case Uop.IdxInd_Stage6_READ_LAX: IdxInd_Stage6_READ_LAX(); break; - case Uop.IdxInd_Stage6_READ_CMP: IdxInd_Stage6_READ_CMP(); break; - case Uop.IdxInd_Stage6_READ_ADC: IdxInd_Stage6_READ_ADC(); break; - case Uop.IdxInd_Stage6_READ_AND: IdxInd_Stage6_READ_AND(); break; - case Uop.IdxInd_Stage6_READ_EOR: IdxInd_Stage6_READ_EOR(); break; - case Uop.IdxInd_Stage6_READ_SBC: IdxInd_Stage6_READ_SBC(); break; - case Uop.IdxInd_Stage6_WRITE_STA: IdxInd_Stage6_WRITE_STA(); break; - case Uop.IdxInd_Stage6_WRITE_SAX: IdxInd_Stage6_WRITE_SAX(); break; - case Uop.IdxInd_Stage6_RMW: IdxInd_Stage6_RMW(); break; - case Uop.IdxInd_Stage7_RMW_SLO: IdxInd_Stage7_RMW_SLO(); break; - case Uop.IdxInd_Stage7_RMW_ISC: IdxInd_Stage7_RMW_ISC(); break; - case Uop.IdxInd_Stage7_RMW_DCP: IdxInd_Stage7_RMW_DCP(); break; - case Uop.IdxInd_Stage7_RMW_SRE: IdxInd_Stage7_RMW_SRE(); break; - case Uop.IdxInd_Stage7_RMW_RRA: IdxInd_Stage7_RMW_RRA(); break; - case Uop.IdxInd_Stage7_RMW_RLA: IdxInd_Stage7_RMW_RLA(); break; - case Uop.IdxInd_Stage8_RMW: IdxInd_Stage8_RMW(); break; - case Uop.PushP: PushP(); break; - case Uop.PushA: PushA(); break; - case Uop.PullA_NoInc: PullA_NoInc(); break; - case Uop.PullP_NoInc: PullP_NoInc(); break; - case Uop.Imp_ASL_A: Imp_ASL_A(); break; - case Uop.Imp_ROL_A: Imp_ROL_A(); break; - case Uop.Imp_ROR_A: Imp_ROR_A(); break; - case Uop.Imp_LSR_A: Imp_LSR_A(); break; - case Uop.JMP_abs: JMP_abs(); break; - case Uop.IncPC: IncPC(); break; - case Uop.ZP_RMW_Stage3: ZP_RMW_Stage3(); break; - case Uop.ZP_RMW_Stage5: ZP_RMW_Stage5(); break; - case Uop.ZP_RMW_INC: ZP_RMW_INC(); break; - case Uop.ZP_RMW_DEC: ZP_RMW_DEC(); break; - case Uop.ZP_RMW_ASL: ZP_RMW_ASL(); break; - case Uop.ZP_RMW_SRE: ZP_RMW_SRE(); break; - case Uop.ZP_RMW_RRA: ZP_RMW_RRA(); break; - case Uop.ZP_RMW_DCP: ZP_RMW_DCP(); break; - case Uop.ZP_RMW_LSR: ZP_RMW_LSR(); break; - case Uop.ZP_RMW_ROR: ZP_RMW_ROR(); break; - case Uop.ZP_RMW_ROL: ZP_RMW_ROL(); break; - case Uop.ZP_RMW_SLO: ZP_RMW_SLO(); break; - case Uop.ZP_RMW_ISC: ZP_RMW_ISC(); break; - case Uop.ZP_RMW_RLA: ZP_RMW_RLA(); break; - case Uop.AbsIdx_Stage3_Y: AbsIdx_Stage3_Y(); break; - case Uop.AbsIdx_Stage3_X: AbsIdx_Stage3_X(); break; - case Uop.AbsIdx_READ_Stage4: AbsIdx_READ_Stage4(); break; - case Uop.AbsIdx_Stage4: AbsIdx_Stage4(); break; - case Uop.AbsIdx_WRITE_Stage5_STA: AbsIdx_WRITE_Stage5_STA(); break; - case Uop.AbsIdx_WRITE_Stage5_SHY: AbsIdx_WRITE_Stage5_SHY(); break; - case Uop.AbsIdx_WRITE_Stage5_SHX: AbsIdx_WRITE_Stage5_SHX(); break; - case Uop.AbsIdx_WRITE_Stage5_ERROR: AbsIdx_WRITE_Stage5_ERROR(); break; - case Uop.AbsIdx_RMW_Stage5: AbsIdx_RMW_Stage5(); break; - case Uop.AbsIdx_RMW_Stage7: AbsIdx_RMW_Stage7(); break; - case Uop.AbsIdx_RMW_Stage6_DEC: AbsIdx_RMW_Stage6_DEC(); break; - case Uop.AbsIdx_RMW_Stage6_DCP: AbsIdx_RMW_Stage6_DCP(); break; - case Uop.AbsIdx_RMW_Stage6_ISC: AbsIdx_RMW_Stage6_ISC(); break; - case Uop.AbsIdx_RMW_Stage6_INC: AbsIdx_RMW_Stage6_INC(); break; - case Uop.AbsIdx_RMW_Stage6_ROL: AbsIdx_RMW_Stage6_ROL(); break; - case Uop.AbsIdx_RMW_Stage6_LSR: AbsIdx_RMW_Stage6_LSR(); break; - case Uop.AbsIdx_RMW_Stage6_SLO: AbsIdx_RMW_Stage6_SLO(); break; - case Uop.AbsIdx_RMW_Stage6_SRE: AbsIdx_RMW_Stage6_SRE(); break; - case Uop.AbsIdx_RMW_Stage6_RRA: AbsIdx_RMW_Stage6_RRA(); break; - case Uop.AbsIdx_RMW_Stage6_RLA: AbsIdx_RMW_Stage6_RLA(); break; - case Uop.AbsIdx_RMW_Stage6_ASL: AbsIdx_RMW_Stage6_ASL(); break; - case Uop.AbsIdx_RMW_Stage6_ROR: AbsIdx_RMW_Stage6_ROR(); break; - case Uop.AbsIdx_READ_Stage5_LDA: AbsIdx_READ_Stage5_LDA(); break; - case Uop.AbsIdx_READ_Stage5_LDX: AbsIdx_READ_Stage5_LDX(); break; - case Uop.AbsIdx_READ_Stage5_LAX: AbsIdx_READ_Stage5_LAX(); break; - case Uop.AbsIdx_READ_Stage5_LDY: AbsIdx_READ_Stage5_LDY(); break; - case Uop.AbsIdx_READ_Stage5_ORA: AbsIdx_READ_Stage5_ORA(); break; - case Uop.AbsIdx_READ_Stage5_NOP: AbsIdx_READ_Stage5_NOP(); break; - case Uop.AbsIdx_READ_Stage5_CMP: AbsIdx_READ_Stage5_CMP(); break; - case Uop.AbsIdx_READ_Stage5_SBC: AbsIdx_READ_Stage5_SBC(); break; - case Uop.AbsIdx_READ_Stage5_ADC: AbsIdx_READ_Stage5_ADC(); break; - case Uop.AbsIdx_READ_Stage5_EOR: AbsIdx_READ_Stage5_EOR(); break; - case Uop.AbsIdx_READ_Stage5_AND: AbsIdx_READ_Stage5_AND(); break; - case Uop.AbsIdx_READ_Stage5_ERROR: AbsIdx_READ_Stage5_ERROR(); break; - case Uop.AbsInd_JMP_Stage4: AbsInd_JMP_Stage4(); break; - case Uop.AbsInd_JMP_Stage5: AbsInd_JMP_Stage5(); break; - case Uop.Abs_RMW_Stage4: Abs_RMW_Stage4(); break; - case Uop.Abs_RMW_Stage5_INC: Abs_RMW_Stage5_INC(); break; - case Uop.Abs_RMW_Stage5_DEC: Abs_RMW_Stage5_DEC(); break; - case Uop.Abs_RMW_Stage5_DCP: Abs_RMW_Stage5_DCP(); break; - case Uop.Abs_RMW_Stage5_ISC: Abs_RMW_Stage5_ISC(); break; - case Uop.Abs_RMW_Stage5_ASL: Abs_RMW_Stage5_ASL(); break; - case Uop.Abs_RMW_Stage5_ROR: Abs_RMW_Stage5_ROR(); break; - case Uop.Abs_RMW_Stage5_SLO: Abs_RMW_Stage5_SLO(); break; - case Uop.Abs_RMW_Stage5_RLA: Abs_RMW_Stage5_RLA(); break; - case Uop.Abs_RMW_Stage5_SRE: Abs_RMW_Stage5_SRE(); break; - case Uop.Abs_RMW_Stage5_RRA: Abs_RMW_Stage5_RRA(); break; - case Uop.Abs_RMW_Stage5_ROL: Abs_RMW_Stage5_ROL(); break; - case Uop.Abs_RMW_Stage5_LSR: Abs_RMW_Stage5_LSR(); break; - case Uop.Abs_RMW_Stage6: Abs_RMW_Stage6(); break; - case Uop.End_ISpecial: End_ISpecial(); break; - case Uop.End_SuppressInterrupt: End_SuppressInterrupt(); break; - case Uop.End: End(); break; - case Uop.End_BranchSpecial: End_BranchSpecial(); break; - } - } - - public void ExecuteOne() - { - if (!rdy_freeze) - { - TotalExecutedCycles++; - - interrupt_pending |= Interrupted; - } - rdy_freeze = false; - - //i tried making ExecuteOneRetry not re-entrant by having it set a flag instead, then exit from the call below, check the flag, and GOTO if it was flagged, but it wasnt faster - ExecuteOneRetry(); - - if (!rdy_freeze) - mi++; - } //ExecuteOne - } -} diff --git a/BizHawk.Emulation.Cores/CPUs/MOS 6502X/6502XXX/Old Managed Stuff/MOS6502X.cs b/BizHawk.Emulation.Cores/CPUs/MOS 6502X/6502XXX/Old Managed Stuff/MOS6502X.cs deleted file mode 100644 index 2b34116abe..0000000000 --- a/BizHawk.Emulation.Cores/CPUs/MOS 6502X/6502XXX/Old Managed Stuff/MOS6502X.cs +++ /dev/null @@ -1,327 +0,0 @@ -using System; - - -using BizHawk.Common; - -using System.Runtime.InteropServices; -using System.Security; - -using System.Reflection; -using System.Reflection.Emit; - -namespace BizHawk.Emulation.Cores.Components.M6502 -{ - [StructLayout(LayoutKind.Explicit)] // LayoutKind.Sequential doesn't work right on the managed form of non-blittable structs - public sealed partial class MOS6502X - { - [FieldOffset(0)] - private int _anchor; - - [SuppressUnmanagedCodeSecurity] - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate byte ReadDel(ushort addr); - [SuppressUnmanagedCodeSecurity] - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate void WriteDel(ushort addr, byte val); - [SuppressUnmanagedCodeSecurity] - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate void AddrDel(ushort addr); - - // interface - [FieldOffset(16)]private ReadDel _ReadMemory; - [FieldOffset(20)]private ReadDel _DummyReadMemory; - [FieldOffset(24)]private ReadDel _PeekMemory; - [FieldOffset(28)]private WriteDel _WriteMemory; - [FieldOffset(32)]private AddrDel _OnExecFetch; // this only calls when the first byte of an instruction is fetched. - - public ReadDel ReadMemory - { - set { _rmp = Marshal.GetFunctionPointerForDelegate(value); _ReadMemory = value; } - get { return _ReadMemory; } - } - public ReadDel DummyReadMemory - { - set { _dmp = Marshal.GetFunctionPointerForDelegate(value); _DummyReadMemory = value; } - get { return _DummyReadMemory; } - } - public ReadDel PeekMemory - { - set { _pmp = Marshal.GetFunctionPointerForDelegate(value); _PeekMemory = value; } - get { return _PeekMemory; } - } - public WriteDel WriteMemory - { - set { _wmp = Marshal.GetFunctionPointerForDelegate(value); _WriteMemory = value; } - get { return _WriteMemory; } - } - public AddrDel OnExecFetch - { - set { _exp = IntPtr.Zero; /* Marshal.GetFunctionPointerForDelegate(value); */ _OnExecFetch = value; } - get { return _OnExecFetch; } - } - - [FieldOffset(36)]public Action TraceCallback; // TODOOO - - [FieldOffset(40)]private IntPtr _rmp; - [FieldOffset(44)]private IntPtr _dmp; - [FieldOffset(48)]private IntPtr _pmp; - [FieldOffset(52)]private IntPtr _wmp; - [FieldOffset(56)]private IntPtr _exp; - - // config - [FieldOffset(60)]public bool BCD_Enabled = true; - [FieldOffset(61)]public bool debug = false; - - // state - [FieldOffset(62)]public byte A; - [FieldOffset(63)]public byte X; - [FieldOffset(64)]public byte Y; - //public byte P; - /// Carry Flag - [FieldOffset(65)]public bool FlagC; - /// Zero Flag - [FieldOffset(66)]public bool FlagZ; - /// Interrupt Disable Flag - [FieldOffset(67)]public bool FlagI; - /// Decimal Mode Flag - [FieldOffset(68)]public bool FlagD; - /// Break Flag - [FieldOffset(69)]public bool FlagB; - /// T... Flag - [FieldOffset(70)]public bool FlagT; - /// Overflow Flag - [FieldOffset(71)]public bool FlagV; - /// Negative Flag - [FieldOffset(72)]public bool FlagN; - - [FieldOffset(74)]public ushort PC; - [FieldOffset(76)]public byte S; - - [FieldOffset(77)]public bool IRQ; - [FieldOffset(78)]public bool NMI; - [FieldOffset(79)]public bool RDY; - - [FieldOffset(80)]public int TotalExecutedCycles; - - //opcode bytes.. theoretically redundant with the temp variables? who knows. - [FieldOffset(84)]int opcode; - [FieldOffset(88)]byte opcode2; - [FieldOffset(89)]byte opcode3; - - [FieldOffset(92)]int ea; - [FieldOffset(96)]int alu_temp; //cpu internal temp variables - [FieldOffset(100)]int mi; //microcode index - [FieldOffset(104)]bool iflag_pending; //iflag must be stored after it is checked in some cases (CLI and SEI). - [FieldOffset(105)]bool rdy_freeze; //true if the CPU must be frozen - - //tracks whether an interrupt condition has popped up recently. - //not sure if this is real or not but it helps with the branch_irq_hack - [FieldOffset(106)]bool interrupt_pending; - [FieldOffset(107)]bool branch_irq_hack; //see Uop.RelBranch_Stage3 for more details - - // transient state - [FieldOffset(108)]byte value8; - [FieldOffset(109)]byte temp8; - [FieldOffset(110)]ushort value16; - [FieldOffset(112)]bool branch_taken = false; - [FieldOffset(113)]bool my_iflag; - [FieldOffset(114)]bool booltemp; - [FieldOffset(116)]int tempint; - [FieldOffset(120)]int lo; - [FieldOffset(124)]int hi; - - public byte P - { - // NVTB DIZC - get - { - byte ret = 0; - if (FlagC) ret |= 1; - if (FlagZ) ret |= 2; - if (FlagI) ret |= 4; - if (FlagD) ret |= 8; - if (FlagB) ret |= 16; - if (FlagT) ret |= 32; - if (FlagV) ret |= 64; - if (FlagN) ret |= 128; - return ret; - } - set - { - FlagC = (value & 1) != 0; - FlagZ = (value & 2) != 0; - FlagI = (value & 4) != 0; - FlagD = (value & 8) != 0; - FlagB = (value & 16) != 0; - FlagT = (value & 32) != 0; - FlagV = (value & 64) != 0; - FlagN = (value & 128) != 0; - } - } - - public MOS6502X() - { - InitOpcodeHandlers(); - InitNative(); - Reset(); - } - - public void SyncState(Serializer ser) - { - ser.BeginSection("MOS6502X"); - ser.Sync("A", ref A); - ser.Sync("X", ref X); - ser.Sync("Y", ref Y); - { - byte tmp = P; - ser.Sync("P", ref tmp); - P = tmp; - } - ser.Sync("PC", ref PC); - ser.Sync("S", ref S); - ser.Sync("NMI", ref NMI); - ser.Sync("IRQ", ref IRQ); - ser.Sync("RDY", ref RDY); - ser.Sync("TotalExecutedCycles", ref TotalExecutedCycles); - ser.Sync("opcode", ref opcode); - ser.Sync("opcode2", ref opcode2); - ser.Sync("opcode3", ref opcode3); - ser.Sync("ea", ref ea); - ser.Sync("alu_temp", ref alu_temp); - ser.Sync("mi", ref mi); - ser.Sync("iflag_pending", ref iflag_pending); - ser.Sync("rdy_freeze", ref rdy_freeze); - ser.Sync("interrupt_pending", ref interrupt_pending); - ser.Sync("branch_irq_hack", ref branch_irq_hack); - ser.EndSection(); - } - - - public void Reset() - { - A = 0; - X = 0; - Y = 0; - P = 0; - S = 0; - PC = 0; - TotalExecutedCycles = 0; - mi = 0; - opcode = 256; - iflag_pending = true; - RDY = true; - } - - public void NESSoftReset() - { - opcode = VOP_RESET; - mi = 0; - iflag_pending = true; - FlagI = true; - } - - public string State(bool disassemble = true) - { - int notused; - string a = string.Format("{0:X4} {1:X2} {2} ", PC, _PeekMemory(PC), disassemble ? Disassemble(PC, out notused) : "---").PadRight(30); - string b = string.Format("A:{0:X2} X:{1:X2} Y:{2:X2} P:{3:X2} SP:{4:X2} Cy:{5}", A, X, Y, P, S, TotalExecutedCycles); - string val = a + b + " "; - if (FlagN) val = val + "N"; - if (FlagV) val = val + "V"; - if (FlagT) val = val + "T"; - if (FlagB) val = val + "B"; - if (FlagD) val = val + "D"; - if (FlagI) val = val + "I"; - if (FlagZ) val = val + "Z"; - if (FlagC) val = val + "C"; - return val; - } - - public string TraceState() - { - // only disassemble when we're at the beginning of an opcode - return State(opcode == VOP_Fetch1 || Microcode[opcode][mi] >= Uop.End); - } - - public const ushort NMIVector = 0xFFFA; - public const ushort ResetVector = 0xFFFC; - public const ushort BRKVector = 0xFFFE; - public const ushort IRQVector = 0xFFFE; - - enum ExceptionType - { - BRK, NMI, IRQ - } - - - #region native interop - - - private void InitNative() - { - } - - [SuppressUnmanagedCodeSecurity] - [DllImport("6502XXX.dll", CallingConvention = CallingConvention.ThisCall, EntryPoint="_ZN3CPU10ExecuteOneEv")] - //[DllImport("6502XXX.dll", CallingConvention = CallingConvention.ThisCall, EntryPoint="?ExecuteOne@CPU@@QAEXXZ")] - private static extern void ExecuteOneNativeInternal(IntPtr o); - - public unsafe void ExecuteOneNative() - { - fixed (int* p = &_anchor) - { - ExecuteOneNativeInternal((IntPtr)p); - } - } - - #endregion - - public void SetCallbacks - ( - ReadDel ReadMemory, - ReadDel DummyReadMemory, - ReadDel PeekMemory, - WriteDel WriteMemory - ) - { - this.ReadMemory = ReadMemory; - this.DummyReadMemory = DummyReadMemory; - this.PeekMemory = PeekMemory; - this.WriteMemory = WriteMemory; - } - - public ushort ReadWord(ushort address) - { - byte l = _ReadMemory(address); - byte h = _ReadMemory(++address); - return (ushort)((h << 8) | l); - } - - public ushort PeekWord(ushort address) - { - byte l = _PeekMemory(address); - byte h = _PeekMemory(++address); - return (ushort)((h << 8) | l); - } - - private static readonly byte[] TableNZ = - { - 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 - }; - } -} diff --git a/BizHawk.Emulation.Cores/CPUs/MOS 6502X/6502XXX/TableNZ.h b/BizHawk.Emulation.Cores/CPUs/MOS 6502X/6502XXX/TableNZ.h deleted file mode 100644 index 18cc3d1e97..0000000000 --- a/BizHawk.Emulation.Cores/CPUs/MOS 6502X/6502XXX/TableNZ.h +++ /dev/null @@ -1,19 +0,0 @@ -const byte TableNZ[] = - { - 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 - }; \ No newline at end of file diff --git a/BizHawk.Emulation.Cores/CPUs/MOS 6502X/6502XXX/UopEnum.h b/BizHawk.Emulation.Cores/CPUs/MOS 6502X/6502XXX/UopEnum.h deleted file mode 100644 index 53a44d4b19..0000000000 --- a/BizHawk.Emulation.Cores/CPUs/MOS 6502X/6502XXX/UopEnum.h +++ /dev/null @@ -1,252 +0,0 @@ -// AUTOGENERATED -#ifndef UOPENUM_H -#define UOPENUM_H -enum Uop { - Uop_Unsupported, - Uop_Fetch1, - Uop_Fetch1_Real, - Uop_Fetch2, - Uop_Fetch3, - Uop_FetchDummy, - Uop_NOP, - Uop_JSR, - Uop_IncPC, - Uop_Abs_WRITE_STA, - Uop_Abs_WRITE_STX, - Uop_Abs_WRITE_STY, - Uop_Abs_WRITE_SAX, - Uop_Abs_READ_BIT, - Uop_Abs_READ_LDA, - Uop_Abs_READ_LDY, - Uop_Abs_READ_ORA, - Uop_Abs_READ_LDX, - Uop_Abs_READ_CMP, - Uop_Abs_READ_ADC, - Uop_Abs_READ_CPX, - Uop_Abs_READ_SBC, - Uop_Abs_READ_AND, - Uop_Abs_READ_EOR, - Uop_Abs_READ_CPY, - Uop_Abs_READ_NOP, - Uop_Abs_READ_LAX, - Uop_Abs_RMW_Stage4, - Uop_Abs_RMW_Stage6, - Uop_Abs_RMW_Stage5_INC, - Uop_Abs_RMW_Stage5_DEC, - Uop_Abs_RMW_Stage5_LSR, - Uop_Abs_RMW_Stage5_ROL, - Uop_Abs_RMW_Stage5_ASL, - Uop_Abs_RMW_Stage5_ROR, - Uop_Abs_RMW_Stage5_SLO, - Uop_Abs_RMW_Stage5_RLA, - Uop_Abs_RMW_Stage5_SRE, - Uop_Abs_RMW_Stage5_RRA, - Uop_Abs_RMW_Stage5_DCP, - Uop_Abs_RMW_Stage5_ISC, - Uop_JMP_abs, - Uop_ZpIdx_Stage3_X, - Uop_ZpIdx_Stage3_Y, - Uop_ZpIdx_RMW_Stage4, - Uop_ZpIdx_RMW_Stage6, - Uop_ZP_WRITE_STA, - Uop_ZP_WRITE_STX, - Uop_ZP_WRITE_STY, - Uop_ZP_WRITE_SAX, - Uop_ZP_RMW_Stage3, - Uop_ZP_RMW_Stage5, - Uop_ZP_RMW_DEC, - Uop_ZP_RMW_INC, - Uop_ZP_RMW_ASL, - Uop_ZP_RMW_LSR, - Uop_ZP_RMW_ROR, - Uop_ZP_RMW_ROL, - Uop_ZP_RMW_SLO, - Uop_ZP_RMW_RLA, - Uop_ZP_RMW_SRE, - Uop_ZP_RMW_RRA, - Uop_ZP_RMW_DCP, - Uop_ZP_RMW_ISC, - Uop_ZP_READ_EOR, - Uop_ZP_READ_BIT, - Uop_ZP_READ_ORA, - Uop_ZP_READ_LDA, - Uop_ZP_READ_LDY, - Uop_ZP_READ_LDX, - Uop_ZP_READ_CPX, - Uop_ZP_READ_SBC, - Uop_ZP_READ_CPY, - Uop_ZP_READ_NOP, - Uop_ZP_READ_ADC, - Uop_ZP_READ_AND, - Uop_ZP_READ_CMP, - Uop_ZP_READ_LAX, - Uop_IdxInd_Stage3, - Uop_IdxInd_Stage4, - Uop_IdxInd_Stage5, - Uop_IdxInd_Stage6_READ_ORA, - Uop_IdxInd_Stage6_READ_SBC, - Uop_IdxInd_Stage6_READ_LDA, - Uop_IdxInd_Stage6_READ_EOR, - Uop_IdxInd_Stage6_READ_CMP, - Uop_IdxInd_Stage6_READ_ADC, - Uop_IdxInd_Stage6_READ_AND, - Uop_IdxInd_Stage6_READ_LAX, - Uop_IdxInd_Stage6_WRITE_STA, - Uop_IdxInd_Stage6_WRITE_SAX, - Uop_IdxInd_Stage6_RMW, - Uop_IdxInd_Stage7_RMW_SLO, - Uop_IdxInd_Stage7_RMW_RLA, - Uop_IdxInd_Stage7_RMW_SRE, - Uop_IdxInd_Stage7_RMW_RRA, - Uop_IdxInd_Stage7_RMW_ISC, - Uop_IdxInd_Stage7_RMW_DCP, - Uop_IdxInd_Stage8_RMW, - Uop_AbsIdx_Stage3_X, - Uop_AbsIdx_Stage3_Y, - Uop_AbsIdx_Stage4, - Uop_AbsIdx_WRITE_Stage5_STA, - Uop_AbsIdx_WRITE_Stage5_SHY, - Uop_AbsIdx_WRITE_Stage5_SHX, - Uop_AbsIdx_WRITE_Stage5_ERROR, - Uop_AbsIdx_READ_Stage4, - Uop_AbsIdx_READ_Stage5_LDA, - Uop_AbsIdx_READ_Stage5_CMP, - Uop_AbsIdx_READ_Stage5_SBC, - Uop_AbsIdx_READ_Stage5_ADC, - Uop_AbsIdx_READ_Stage5_EOR, - Uop_AbsIdx_READ_Stage5_LDX, - Uop_AbsIdx_READ_Stage5_AND, - Uop_AbsIdx_READ_Stage5_ORA, - Uop_AbsIdx_READ_Stage5_LDY, - Uop_AbsIdx_READ_Stage5_NOP, - Uop_AbsIdx_READ_Stage5_LAX, - Uop_AbsIdx_READ_Stage5_ERROR, - Uop_AbsIdx_RMW_Stage5, - Uop_AbsIdx_RMW_Stage7, - Uop_AbsIdx_RMW_Stage6_ROR, - Uop_AbsIdx_RMW_Stage6_DEC, - Uop_AbsIdx_RMW_Stage6_INC, - Uop_AbsIdx_RMW_Stage6_ASL, - Uop_AbsIdx_RMW_Stage6_LSR, - Uop_AbsIdx_RMW_Stage6_ROL, - Uop_AbsIdx_RMW_Stage6_SLO, - Uop_AbsIdx_RMW_Stage6_RLA, - Uop_AbsIdx_RMW_Stage6_SRE, - Uop_AbsIdx_RMW_Stage6_RRA, - Uop_AbsIdx_RMW_Stage6_DCP, - Uop_AbsIdx_RMW_Stage6_ISC, - Uop_IncS, - Uop_DecS, - Uop_PushPCL, - Uop_PushPCH, - Uop_PushP, - Uop_PullP, - Uop_PullPCL, - Uop_PullPCH_NoInc, - Uop_PushA, - Uop_PullA_NoInc, - Uop_PullP_NoInc, - Uop_PushP_BRK, - Uop_PushP_NMI, - Uop_PushP_IRQ, - Uop_PushP_Reset, - Uop_PushDummy, - Uop_FetchPCLVector, - Uop_FetchPCHVector, - Uop_Imp_ASL_A, - Uop_Imp_ROL_A, - Uop_Imp_ROR_A, - Uop_Imp_LSR_A, - Uop_Imp_SEC, - Uop_Imp_CLI, - Uop_Imp_SEI, - Uop_Imp_CLD, - Uop_Imp_CLC, - Uop_Imp_CLV, - Uop_Imp_SED, - Uop_Imp_INY, - Uop_Imp_DEY, - Uop_Imp_INX, - Uop_Imp_DEX, - Uop_Imp_TSX, - Uop_Imp_TXS, - Uop_Imp_TAX, - Uop_Imp_TAY, - Uop_Imp_TYA, - Uop_Imp_TXA, - Uop_Imm_CMP, - Uop_Imm_ADC, - Uop_Imm_AND, - Uop_Imm_SBC, - Uop_Imm_ORA, - Uop_Imm_EOR, - Uop_Imm_CPY, - Uop_Imm_CPX, - Uop_Imm_ANC, - Uop_Imm_ASR, - Uop_Imm_ARR, - Uop_Imm_LXA, - Uop_Imm_AXS, - Uop_Imm_LDA, - Uop_Imm_LDX, - Uop_Imm_LDY, - Uop_Imm_Unsupported, - Uop_NZ_X, - Uop_NZ_Y, - Uop_NZ_A, - Uop_RelBranch_Stage2_BNE, - Uop_RelBranch_Stage2_BPL, - Uop_RelBranch_Stage2_BCC, - Uop_RelBranch_Stage2_BCS, - Uop_RelBranch_Stage2_BEQ, - Uop_RelBranch_Stage2_BMI, - Uop_RelBranch_Stage2_BVC, - Uop_RelBranch_Stage2_BVS, - Uop_RelBranch_Stage2, - Uop_RelBranch_Stage3, - Uop_RelBranch_Stage4, - Uop__Eor, - Uop__Bit, - Uop__Cpx, - Uop__Cpy, - Uop__Cmp, - Uop__Adc, - Uop__Sbc, - Uop__Ora, - Uop__And, - Uop__Anc, - Uop__Asr, - Uop__Arr, - Uop__Lxa, - Uop__Axs, - Uop_AbsInd_JMP_Stage4, - Uop_AbsInd_JMP_Stage5, - Uop_IndIdx_Stage3, - Uop_IndIdx_Stage4, - Uop_IndIdx_READ_Stage5, - Uop_IndIdx_WRITE_Stage5, - Uop_IndIdx_WRITE_Stage6_STA, - Uop_IndIdx_WRITE_Stage6_SHA, - Uop_IndIdx_READ_Stage6_LDA, - Uop_IndIdx_READ_Stage6_CMP, - Uop_IndIdx_READ_Stage6_ORA, - Uop_IndIdx_READ_Stage6_SBC, - Uop_IndIdx_READ_Stage6_ADC, - Uop_IndIdx_READ_Stage6_AND, - Uop_IndIdx_READ_Stage6_EOR, - Uop_IndIdx_READ_Stage6_LAX, - Uop_IndIdx_RMW_Stage5, - Uop_IndIdx_RMW_Stage6, - Uop_IndIdx_RMW_Stage7_SLO, - Uop_IndIdx_RMW_Stage7_RLA, - Uop_IndIdx_RMW_Stage7_SRE, - Uop_IndIdx_RMW_Stage7_RRA, - Uop_IndIdx_RMW_Stage7_ISC, - Uop_IndIdx_RMW_Stage7_DCP, - Uop_IndIdx_RMW_Stage8, - Uop_End, - Uop_End_ISpecial, - Uop_End_BranchSpecial, - Uop_End_SuppressInterrupt, -}; -#endif // UOPENUM_H diff --git a/BizHawk.Emulation.Cores/CPUs/MOS 6502X/6502XXX/UopTable.cpp b/BizHawk.Emulation.Cores/CPUs/MOS 6502X/6502XXX/UopTable.cpp deleted file mode 100644 index b071c77601..0000000000 --- a/BizHawk.Emulation.Cores/CPUs/MOS 6502X/6502XXX/UopTable.cpp +++ /dev/null @@ -1,268 +0,0 @@ -// AUTOGENERATED -#include "UopEnum.h" -const Uop Microcode[264][8] = { - {Uop_Fetch2, Uop_PushPCH, Uop_PushPCL, Uop_PushP_BRK, Uop_FetchPCLVector, Uop_FetchPCHVector, Uop_End_SuppressInterrupt}, - {Uop_Fetch2, Uop_IdxInd_Stage3, Uop_IdxInd_Stage4, Uop_IdxInd_Stage5, Uop_IdxInd_Stage6_READ_ORA, Uop_End}, - {Uop_End}, - {Uop_Fetch2, Uop_IdxInd_Stage3, Uop_IdxInd_Stage4, Uop_IdxInd_Stage5, Uop_IdxInd_Stage6_RMW, Uop_IdxInd_Stage7_RMW_SLO, Uop_IdxInd_Stage8_RMW, Uop_End}, - {Uop_Fetch2, Uop_ZP_READ_NOP, Uop_End}, - {Uop_Fetch2, Uop_ZP_READ_ORA, Uop_End}, - {Uop_Fetch2, Uop_ZP_RMW_Stage3, Uop_ZP_RMW_ASL, Uop_ZP_RMW_Stage5, Uop_End}, - {Uop_Fetch2, Uop_ZP_RMW_Stage3, Uop_ZP_RMW_SLO, Uop_ZP_RMW_Stage5, Uop_End}, - {Uop_FetchDummy, Uop_PushP, Uop_End}, - {Uop_Imm_ORA, Uop_End}, - {Uop_Imp_ASL_A, Uop_End}, - {Uop_Imm_ANC, Uop_End}, - {Uop_Fetch2, Uop_Fetch3, Uop_Abs_READ_NOP, Uop_End}, - {Uop_Fetch2, Uop_Fetch3, Uop_Abs_READ_ORA, Uop_End}, - {Uop_Fetch2, Uop_Fetch3, Uop_Abs_RMW_Stage4, Uop_Abs_RMW_Stage5_ASL, Uop_Abs_RMW_Stage6, Uop_End}, - {Uop_Fetch2, Uop_Fetch3, Uop_Abs_RMW_Stage4, Uop_Abs_RMW_Stage5_SLO, Uop_Abs_RMW_Stage6, Uop_End}, - {Uop_RelBranch_Stage2_BPL, Uop_End}, - {Uop_Fetch2, Uop_IndIdx_Stage3, Uop_IndIdx_Stage4, Uop_IndIdx_READ_Stage5, Uop_IndIdx_READ_Stage6_ORA, Uop_End}, - {Uop_End}, - {Uop_Fetch2, Uop_IndIdx_Stage3, Uop_IndIdx_Stage4, Uop_IndIdx_RMW_Stage5, Uop_IndIdx_RMW_Stage6, Uop_IndIdx_RMW_Stage7_SLO, Uop_IndIdx_RMW_Stage8, Uop_End}, - {Uop_Fetch2, Uop_ZpIdx_Stage3_X, Uop_ZP_READ_NOP, Uop_End}, - {Uop_Fetch2, Uop_ZpIdx_Stage3_X, Uop_ZP_READ_ORA, Uop_End}, - {Uop_Fetch2, Uop_ZpIdx_Stage3_X, Uop_ZpIdx_RMW_Stage4, Uop_ZP_RMW_ASL, Uop_ZpIdx_RMW_Stage6, Uop_End}, - {Uop_Fetch2, Uop_ZpIdx_Stage3_X, Uop_ZpIdx_RMW_Stage4, Uop_ZP_RMW_SLO, Uop_ZpIdx_RMW_Stage6, Uop_End}, - {Uop_Imp_CLC, Uop_End}, - {Uop_Fetch2, Uop_AbsIdx_Stage3_Y, Uop_AbsIdx_READ_Stage4, Uop_AbsIdx_READ_Stage5_ORA, Uop_End}, - {Uop_FetchDummy, Uop_End}, - {Uop_Fetch2, Uop_AbsIdx_Stage3_Y, Uop_AbsIdx_Stage4, Uop_AbsIdx_RMW_Stage5, Uop_AbsIdx_RMW_Stage6_SLO, Uop_AbsIdx_RMW_Stage7, Uop_End}, - {Uop_Fetch2, Uop_AbsIdx_Stage3_X, Uop_AbsIdx_READ_Stage4, Uop_AbsIdx_READ_Stage5_NOP, Uop_End}, - {Uop_Fetch2, Uop_AbsIdx_Stage3_X, Uop_AbsIdx_READ_Stage4, Uop_AbsIdx_READ_Stage5_ORA, Uop_End}, - {Uop_Fetch2, Uop_AbsIdx_Stage3_X, Uop_AbsIdx_Stage4, Uop_AbsIdx_RMW_Stage5, Uop_AbsIdx_RMW_Stage6_ASL, Uop_AbsIdx_RMW_Stage7, Uop_End}, - {Uop_Fetch2, Uop_AbsIdx_Stage3_X, Uop_AbsIdx_Stage4, Uop_AbsIdx_RMW_Stage5, Uop_AbsIdx_RMW_Stage6_SLO, Uop_AbsIdx_RMW_Stage7, Uop_End}, - {Uop_Fetch2, Uop_NOP, Uop_PushPCH, Uop_PushPCL, Uop_JSR, Uop_End}, - {Uop_Fetch2, Uop_IdxInd_Stage3, Uop_IdxInd_Stage4, Uop_IdxInd_Stage5, Uop_IdxInd_Stage6_READ_AND, Uop_End}, - {Uop_End}, - {Uop_Fetch2, Uop_IdxInd_Stage3, Uop_IdxInd_Stage4, Uop_IdxInd_Stage5, Uop_IdxInd_Stage6_RMW, Uop_IdxInd_Stage7_RMW_RLA, Uop_IdxInd_Stage8_RMW, Uop_End}, - {Uop_Fetch2, Uop_ZP_READ_BIT, Uop_End}, - {Uop_Fetch2, Uop_ZP_READ_AND, Uop_End}, - {Uop_Fetch2, Uop_ZP_RMW_Stage3, Uop_ZP_RMW_ROL, Uop_ZP_RMW_Stage5, Uop_End}, - {Uop_Fetch2, Uop_ZP_RMW_Stage3, Uop_ZP_RMW_RLA, Uop_ZP_RMW_Stage5, Uop_End}, - {Uop_FetchDummy, Uop_IncS, Uop_PullP_NoInc, Uop_End_ISpecial}, - {Uop_Imm_AND, Uop_End}, - {Uop_Imp_ROL_A, Uop_End}, - {Uop_Imm_ANC, Uop_End}, - {Uop_Fetch2, Uop_Fetch3, Uop_Abs_READ_BIT, Uop_End}, - {Uop_Fetch2, Uop_Fetch3, Uop_Abs_READ_AND, Uop_End}, - {Uop_Fetch2, Uop_Fetch3, Uop_Abs_RMW_Stage4, Uop_Abs_RMW_Stage5_ROL, Uop_Abs_RMW_Stage6, Uop_End}, - {Uop_Fetch2, Uop_Fetch3, Uop_Abs_RMW_Stage4, Uop_Abs_RMW_Stage5_RLA, Uop_Abs_RMW_Stage6, Uop_End}, - {Uop_RelBranch_Stage2_BMI, Uop_End}, - {Uop_Fetch2, Uop_IndIdx_Stage3, Uop_IndIdx_Stage4, Uop_IndIdx_READ_Stage5, Uop_IndIdx_READ_Stage6_AND, Uop_End}, - {Uop_End}, - {Uop_Fetch2, Uop_IndIdx_Stage3, Uop_IndIdx_Stage4, Uop_IndIdx_RMW_Stage5, Uop_IndIdx_RMW_Stage6, Uop_IndIdx_RMW_Stage7_RLA, Uop_IndIdx_RMW_Stage8, Uop_End}, - {Uop_Fetch2, Uop_ZpIdx_Stage3_X, Uop_ZP_READ_NOP, Uop_End}, - {Uop_Fetch2, Uop_ZpIdx_Stage3_X, Uop_ZP_READ_AND, Uop_End}, - {Uop_Fetch2, Uop_ZpIdx_Stage3_X, Uop_ZpIdx_RMW_Stage4, Uop_ZP_RMW_ROL, Uop_ZpIdx_RMW_Stage6, Uop_End}, - {Uop_Fetch2, Uop_ZpIdx_Stage3_X, Uop_ZpIdx_RMW_Stage4, Uop_ZP_RMW_RLA, Uop_ZpIdx_RMW_Stage6, Uop_End}, - {Uop_Imp_SEC, Uop_End}, - {Uop_Fetch2, Uop_AbsIdx_Stage3_Y, Uop_AbsIdx_READ_Stage4, Uop_AbsIdx_READ_Stage5_AND, Uop_End}, - {Uop_FetchDummy, Uop_End}, - {Uop_Fetch2, Uop_AbsIdx_Stage3_Y, Uop_AbsIdx_Stage4, Uop_AbsIdx_RMW_Stage5, Uop_AbsIdx_RMW_Stage6_RLA, Uop_AbsIdx_RMW_Stage7, Uop_End}, - {Uop_Fetch2, Uop_AbsIdx_Stage3_X, Uop_AbsIdx_READ_Stage4, Uop_AbsIdx_READ_Stage5_NOP, Uop_End}, - {Uop_Fetch2, Uop_AbsIdx_Stage3_X, Uop_AbsIdx_READ_Stage4, Uop_AbsIdx_READ_Stage5_AND, Uop_End}, - {Uop_Fetch2, Uop_AbsIdx_Stage3_X, Uop_AbsIdx_Stage4, Uop_AbsIdx_RMW_Stage5, Uop_AbsIdx_RMW_Stage6_ROL, Uop_AbsIdx_RMW_Stage7, Uop_End}, - {Uop_Fetch2, Uop_AbsIdx_Stage3_X, Uop_AbsIdx_Stage4, Uop_AbsIdx_RMW_Stage5, Uop_AbsIdx_RMW_Stage6_RLA, Uop_AbsIdx_RMW_Stage7, Uop_End}, - {Uop_FetchDummy, Uop_IncS, Uop_PullP, Uop_PullPCL, Uop_PullPCH_NoInc, Uop_End}, - {Uop_Fetch2, Uop_IdxInd_Stage3, Uop_IdxInd_Stage4, Uop_IdxInd_Stage5, Uop_IdxInd_Stage6_READ_EOR, Uop_End}, - {Uop_End}, - {Uop_Fetch2, Uop_IdxInd_Stage3, Uop_IdxInd_Stage4, Uop_IdxInd_Stage5, Uop_IdxInd_Stage6_RMW, Uop_IdxInd_Stage7_RMW_SRE, Uop_IdxInd_Stage8_RMW, Uop_End}, - {Uop_Fetch2, Uop_ZP_READ_NOP, Uop_End}, - {Uop_Fetch2, Uop_ZP_READ_EOR, Uop_End}, - {Uop_Fetch2, Uop_ZP_RMW_Stage3, Uop_ZP_RMW_LSR, Uop_ZP_RMW_Stage5, Uop_End}, - {Uop_Fetch2, Uop_ZP_RMW_Stage3, Uop_ZP_RMW_SRE, Uop_ZP_RMW_Stage5, Uop_End}, - {Uop_FetchDummy, Uop_PushA, Uop_End}, - {Uop_Imm_EOR, Uop_End}, - {Uop_Imp_LSR_A, Uop_End}, - {Uop_Imm_ASR, Uop_End}, - {Uop_Fetch2, Uop_JMP_abs, Uop_End}, - {Uop_Fetch2, Uop_Fetch3, Uop_Abs_READ_EOR, Uop_End}, - {Uop_Fetch2, Uop_Fetch3, Uop_Abs_RMW_Stage4, Uop_Abs_RMW_Stage5_LSR, Uop_Abs_RMW_Stage6, Uop_End}, - {Uop_Fetch2, Uop_Fetch3, Uop_Abs_RMW_Stage4, Uop_Abs_RMW_Stage5_SRE, Uop_Abs_RMW_Stage6, Uop_End}, - {Uop_RelBranch_Stage2_BVC, Uop_End}, - {Uop_Fetch2, Uop_IndIdx_Stage3, Uop_IndIdx_Stage4, Uop_IndIdx_READ_Stage5, Uop_IndIdx_READ_Stage6_EOR, Uop_End}, - {Uop_End}, - {Uop_Fetch2, Uop_IndIdx_Stage3, Uop_IndIdx_Stage4, Uop_IndIdx_RMW_Stage5, Uop_IndIdx_RMW_Stage6, Uop_IndIdx_RMW_Stage7_SRE, Uop_IndIdx_RMW_Stage8, Uop_End}, - {Uop_Fetch2, Uop_ZpIdx_Stage3_X, Uop_ZP_READ_NOP, Uop_End}, - {Uop_Fetch2, Uop_ZpIdx_Stage3_X, Uop_ZP_READ_EOR, Uop_End}, - {Uop_Fetch2, Uop_ZpIdx_Stage3_X, Uop_ZpIdx_RMW_Stage4, Uop_ZP_RMW_LSR, Uop_ZpIdx_RMW_Stage6, Uop_End}, - {Uop_Fetch2, Uop_ZpIdx_Stage3_X, Uop_ZpIdx_RMW_Stage4, Uop_ZP_RMW_SRE, Uop_ZpIdx_RMW_Stage6, Uop_End}, - {Uop_Imp_CLI, Uop_End_ISpecial}, - {Uop_Fetch2, Uop_AbsIdx_Stage3_Y, Uop_AbsIdx_READ_Stage4, Uop_AbsIdx_READ_Stage5_EOR, Uop_End}, - {Uop_FetchDummy, Uop_End}, - {Uop_Fetch2, Uop_AbsIdx_Stage3_Y, Uop_AbsIdx_Stage4, Uop_AbsIdx_RMW_Stage5, Uop_AbsIdx_RMW_Stage6_SRE, Uop_AbsIdx_RMW_Stage7, Uop_End}, - {Uop_Fetch2, Uop_AbsIdx_Stage3_X, Uop_AbsIdx_READ_Stage4, Uop_AbsIdx_READ_Stage5_NOP, Uop_End}, - {Uop_Fetch2, Uop_AbsIdx_Stage3_X, Uop_AbsIdx_READ_Stage4, Uop_AbsIdx_READ_Stage5_EOR, Uop_End}, - {Uop_Fetch2, Uop_AbsIdx_Stage3_X, Uop_AbsIdx_Stage4, Uop_AbsIdx_RMW_Stage5, Uop_AbsIdx_RMW_Stage6_LSR, Uop_AbsIdx_RMW_Stage7, Uop_End}, - {Uop_Fetch2, Uop_AbsIdx_Stage3_X, Uop_AbsIdx_Stage4, Uop_AbsIdx_RMW_Stage5, Uop_AbsIdx_RMW_Stage6_SRE, Uop_AbsIdx_RMW_Stage7, Uop_End}, - {Uop_FetchDummy, Uop_IncS, Uop_PullPCL, Uop_PullPCH_NoInc, Uop_IncPC, Uop_End}, - {Uop_Fetch2, Uop_IdxInd_Stage3, Uop_IdxInd_Stage4, Uop_IdxInd_Stage5, Uop_IdxInd_Stage6_READ_ADC, Uop_End}, - {Uop_End}, - {Uop_Fetch2, Uop_IdxInd_Stage3, Uop_IdxInd_Stage4, Uop_IdxInd_Stage5, Uop_IdxInd_Stage6_RMW, Uop_IdxInd_Stage7_RMW_RRA, Uop_IdxInd_Stage8_RMW, Uop_End}, - {Uop_Fetch2, Uop_ZP_READ_NOP, Uop_End}, - {Uop_Fetch2, Uop_ZP_READ_ADC, Uop_End}, - {Uop_Fetch2, Uop_ZP_RMW_Stage3, Uop_ZP_RMW_ROR, Uop_ZP_RMW_Stage5, Uop_End}, - {Uop_Fetch2, Uop_ZP_RMW_Stage3, Uop_ZP_RMW_RRA, Uop_ZP_RMW_Stage5, Uop_End}, - {Uop_FetchDummy, Uop_IncS, Uop_PullA_NoInc, Uop_End}, - {Uop_Imm_ADC, Uop_End}, - {Uop_Imp_ROR_A, Uop_End}, - {Uop_Imm_ARR, Uop_End}, - {Uop_Fetch2, Uop_Fetch3, Uop_AbsInd_JMP_Stage4, Uop_AbsInd_JMP_Stage5, Uop_End}, - {Uop_Fetch2, Uop_Fetch3, Uop_Abs_READ_ADC, Uop_End}, - {Uop_Fetch2, Uop_Fetch3, Uop_Abs_RMW_Stage4, Uop_Abs_RMW_Stage5_ROR, Uop_Abs_RMW_Stage6, Uop_End}, - {Uop_Fetch2, Uop_Fetch3, Uop_Abs_RMW_Stage4, Uop_Abs_RMW_Stage5_RRA, Uop_Abs_RMW_Stage6, Uop_End}, - {Uop_RelBranch_Stage2_BVS, Uop_End}, - {Uop_Fetch2, Uop_IndIdx_Stage3, Uop_IndIdx_Stage4, Uop_IndIdx_READ_Stage5, Uop_IndIdx_READ_Stage6_ADC, Uop_End}, - {Uop_End}, - {Uop_Fetch2, Uop_IndIdx_Stage3, Uop_IndIdx_Stage4, Uop_IndIdx_RMW_Stage5, Uop_IndIdx_RMW_Stage6, Uop_IndIdx_RMW_Stage7_RRA, Uop_IndIdx_RMW_Stage8, Uop_End}, - {Uop_Fetch2, Uop_ZpIdx_Stage3_X, Uop_ZP_READ_NOP, Uop_End}, - {Uop_Fetch2, Uop_ZpIdx_Stage3_X, Uop_ZP_READ_ADC, Uop_End}, - {Uop_Fetch2, Uop_ZpIdx_Stage3_X, Uop_ZpIdx_RMW_Stage4, Uop_ZP_RMW_ROR, Uop_ZpIdx_RMW_Stage6, Uop_End}, - {Uop_Fetch2, Uop_ZpIdx_Stage3_X, Uop_ZpIdx_RMW_Stage4, Uop_ZP_RMW_RRA, Uop_ZpIdx_RMW_Stage6, Uop_End}, - {Uop_Imp_SEI, Uop_End_ISpecial}, - {Uop_Fetch2, Uop_AbsIdx_Stage3_Y, Uop_AbsIdx_READ_Stage4, Uop_AbsIdx_READ_Stage5_ADC, Uop_End}, - {Uop_FetchDummy, Uop_End}, - {Uop_Fetch2, Uop_AbsIdx_Stage3_Y, Uop_AbsIdx_Stage4, Uop_AbsIdx_RMW_Stage5, Uop_AbsIdx_RMW_Stage6_RRA, Uop_AbsIdx_RMW_Stage7, Uop_End}, - {Uop_Fetch2, Uop_AbsIdx_Stage3_X, Uop_AbsIdx_READ_Stage4, Uop_AbsIdx_READ_Stage5_NOP, Uop_End}, - {Uop_Fetch2, Uop_AbsIdx_Stage3_X, Uop_AbsIdx_READ_Stage4, Uop_AbsIdx_READ_Stage5_ADC, Uop_End}, - {Uop_Fetch2, Uop_AbsIdx_Stage3_X, Uop_AbsIdx_Stage4, Uop_AbsIdx_RMW_Stage5, Uop_AbsIdx_RMW_Stage6_ROR, Uop_AbsIdx_RMW_Stage7, Uop_End}, - {Uop_Fetch2, Uop_AbsIdx_Stage3_X, Uop_AbsIdx_Stage4, Uop_AbsIdx_RMW_Stage5, Uop_AbsIdx_RMW_Stage6_RRA, Uop_AbsIdx_RMW_Stage7, Uop_End}, - {Uop_Imm_Unsupported, Uop_End}, - {Uop_Fetch2, Uop_IdxInd_Stage3, Uop_IdxInd_Stage4, Uop_IdxInd_Stage5, Uop_IdxInd_Stage6_WRITE_STA, Uop_End}, - {Uop_Imm_Unsupported, Uop_End}, - {Uop_Fetch2, Uop_IdxInd_Stage3, Uop_IdxInd_Stage4, Uop_IdxInd_Stage5, Uop_IdxInd_Stage6_WRITE_SAX, Uop_End}, - {Uop_Fetch2, Uop_ZP_WRITE_STY, Uop_End}, - {Uop_Fetch2, Uop_ZP_WRITE_STA, Uop_End}, - {Uop_Fetch2, Uop_ZP_WRITE_STX, Uop_End}, - {Uop_Fetch2, Uop_ZP_WRITE_SAX, Uop_End}, - {Uop_Imp_DEY, Uop_End}, - {Uop_Imm_Unsupported, Uop_End}, - {Uop_Imp_TXA, Uop_End}, - {Uop_Imm_Unsupported, Uop_End}, - {Uop_Fetch2, Uop_Fetch3, Uop_Abs_WRITE_STY, Uop_End}, - {Uop_Fetch2, Uop_Fetch3, Uop_Abs_WRITE_STA, Uop_End}, - {Uop_Fetch2, Uop_Fetch3, Uop_Abs_WRITE_STX, Uop_End}, - {Uop_Fetch2, Uop_Fetch3, Uop_Abs_WRITE_SAX, Uop_End}, - {Uop_RelBranch_Stage2_BCC, Uop_End}, - {Uop_Fetch2, Uop_IndIdx_Stage3, Uop_IndIdx_Stage4, Uop_IndIdx_WRITE_Stage5, Uop_IndIdx_WRITE_Stage6_STA, Uop_End}, - {Uop_End}, - {Uop_Fetch2, Uop_IndIdx_Stage3, Uop_IndIdx_Stage4, Uop_IndIdx_WRITE_Stage5, Uop_IndIdx_WRITE_Stage6_SHA, Uop_End}, - {Uop_Fetch2, Uop_ZpIdx_Stage3_X, Uop_ZP_WRITE_STY, Uop_End}, - {Uop_Fetch2, Uop_ZpIdx_Stage3_X, Uop_ZP_WRITE_STA, Uop_End}, - {Uop_Fetch2, Uop_ZpIdx_Stage3_Y, Uop_ZP_WRITE_STX, Uop_End}, - {Uop_Fetch2, Uop_ZpIdx_Stage3_Y, Uop_ZP_WRITE_SAX, Uop_End}, - {Uop_Imp_TYA, Uop_End}, - {Uop_Fetch2, Uop_AbsIdx_Stage3_Y, Uop_AbsIdx_Stage4, Uop_AbsIdx_WRITE_Stage5_STA, Uop_End}, - {Uop_Imp_TXS, Uop_End}, - {Uop_Fetch2, Uop_AbsIdx_Stage3_X, Uop_AbsIdx_Stage4, Uop_AbsIdx_WRITE_Stage5_ERROR, Uop_End}, - {Uop_Fetch2, Uop_AbsIdx_Stage3_X, Uop_AbsIdx_Stage4, Uop_AbsIdx_WRITE_Stage5_SHY, Uop_End}, - {Uop_Fetch2, Uop_AbsIdx_Stage3_X, Uop_AbsIdx_Stage4, Uop_AbsIdx_WRITE_Stage5_STA, Uop_End}, - {Uop_Fetch2, Uop_AbsIdx_Stage3_Y, Uop_AbsIdx_Stage4, Uop_AbsIdx_WRITE_Stage5_SHX, Uop_End}, - {Uop_Fetch2, Uop_AbsIdx_Stage3_Y, Uop_AbsIdx_Stage4, Uop_AbsIdx_WRITE_Stage5_SHY, Uop_End}, - {Uop_Imm_LDY, Uop_End}, - {Uop_Fetch2, Uop_IdxInd_Stage3, Uop_IdxInd_Stage4, Uop_IdxInd_Stage5, Uop_IdxInd_Stage6_READ_LDA, Uop_End}, - {Uop_Imm_LDX, Uop_End}, - {Uop_Fetch2, Uop_IdxInd_Stage3, Uop_IdxInd_Stage4, Uop_IdxInd_Stage5, Uop_IdxInd_Stage6_READ_LAX, Uop_End}, - {Uop_Fetch2, Uop_ZP_READ_LDY, Uop_End}, - {Uop_Fetch2, Uop_ZP_READ_LDA, Uop_End}, - {Uop_Fetch2, Uop_ZP_READ_LDX, Uop_End}, - {Uop_Fetch2, Uop_ZP_READ_LAX, Uop_End}, - {Uop_Imp_TAY, Uop_End}, - {Uop_Imm_LDA, Uop_End}, - {Uop_Imp_TAX, Uop_End}, - {Uop_Imm_LXA, Uop_End}, - {Uop_Fetch2, Uop_Fetch3, Uop_Abs_READ_LDY, Uop_End}, - {Uop_Fetch2, Uop_Fetch3, Uop_Abs_READ_LDA, Uop_End}, - {Uop_Fetch2, Uop_Fetch3, Uop_Abs_READ_LDX, Uop_End}, - {Uop_Fetch2, Uop_Fetch3, Uop_Abs_READ_LAX, Uop_End}, - {Uop_RelBranch_Stage2_BCS, Uop_End}, - {Uop_Fetch2, Uop_IndIdx_Stage3, Uop_IndIdx_Stage4, Uop_IndIdx_READ_Stage5, Uop_IndIdx_READ_Stage6_LDA, Uop_End}, - {Uop_End}, - {Uop_Fetch2, Uop_IndIdx_Stage3, Uop_IndIdx_Stage4, Uop_IndIdx_READ_Stage5, Uop_IndIdx_READ_Stage6_LAX, Uop_End}, - {Uop_Fetch2, Uop_ZpIdx_Stage3_X, Uop_ZP_READ_LDY, Uop_End}, - {Uop_Fetch2, Uop_ZpIdx_Stage3_X, Uop_ZP_READ_LDA, Uop_End}, - {Uop_Fetch2, Uop_ZpIdx_Stage3_Y, Uop_ZP_READ_LDX, Uop_End}, - {Uop_Fetch2, Uop_ZpIdx_Stage3_Y, Uop_ZP_READ_LAX, Uop_End}, - {Uop_Imp_CLV, Uop_End}, - {Uop_Fetch2, Uop_AbsIdx_Stage3_Y, Uop_AbsIdx_READ_Stage4, Uop_AbsIdx_READ_Stage5_LDA, Uop_End}, - {Uop_Imp_TSX, Uop_End}, - {Uop_Fetch2, Uop_AbsIdx_Stage3_X, Uop_AbsIdx_READ_Stage4, Uop_AbsIdx_READ_Stage5_ERROR, Uop_End}, - {Uop_Fetch2, Uop_AbsIdx_Stage3_X, Uop_AbsIdx_READ_Stage4, Uop_AbsIdx_READ_Stage5_LDY, Uop_End}, - {Uop_Fetch2, Uop_AbsIdx_Stage3_X, Uop_AbsIdx_READ_Stage4, Uop_AbsIdx_READ_Stage5_LDA, Uop_End}, - {Uop_Fetch2, Uop_AbsIdx_Stage3_Y, Uop_AbsIdx_READ_Stage4, Uop_AbsIdx_READ_Stage5_LDX, Uop_End}, - {Uop_Fetch2, Uop_AbsIdx_Stage3_Y, Uop_AbsIdx_READ_Stage4, Uop_AbsIdx_READ_Stage5_LAX, Uop_End}, - {Uop_Imm_CPY, Uop_End}, - {Uop_Fetch2, Uop_IdxInd_Stage3, Uop_IdxInd_Stage4, Uop_IdxInd_Stage5, Uop_IdxInd_Stage6_READ_CMP, Uop_End}, - {Uop_Imm_Unsupported, Uop_End}, - {Uop_Fetch2, Uop_IdxInd_Stage3, Uop_IdxInd_Stage4, Uop_IdxInd_Stage5, Uop_IdxInd_Stage6_RMW, Uop_IdxInd_Stage7_RMW_DCP, Uop_IdxInd_Stage8_RMW, Uop_End}, - {Uop_Fetch2, Uop_ZP_READ_CPY, Uop_End}, - {Uop_Fetch2, Uop_ZP_READ_CMP, Uop_End}, - {Uop_Fetch2, Uop_ZP_RMW_Stage3, Uop_ZP_RMW_DEC, Uop_ZP_RMW_Stage5, Uop_End}, - {Uop_Fetch2, Uop_ZP_RMW_Stage3, Uop_ZP_RMW_DCP, Uop_ZP_RMW_Stage5, Uop_End}, - {Uop_Imp_INY, Uop_End}, - {Uop_Imm_CMP, Uop_End}, - {Uop_Imp_DEX, Uop_End}, - {Uop_Imm_AXS, Uop_End}, - {Uop_Fetch2, Uop_Fetch3, Uop_Abs_READ_CPY, Uop_End}, - {Uop_Fetch2, Uop_Fetch3, Uop_Abs_READ_CMP, Uop_End}, - {Uop_Fetch2, Uop_Fetch3, Uop_Abs_RMW_Stage4, Uop_Abs_RMW_Stage5_DEC, Uop_Abs_RMW_Stage6, Uop_End}, - {Uop_Fetch2, Uop_Fetch3, Uop_Abs_RMW_Stage4, Uop_Abs_RMW_Stage5_DCP, Uop_Abs_RMW_Stage6, Uop_End}, - {Uop_RelBranch_Stage2_BNE, Uop_End}, - {Uop_Fetch2, Uop_IndIdx_Stage3, Uop_IndIdx_Stage4, Uop_IndIdx_READ_Stage5, Uop_IndIdx_READ_Stage6_CMP, Uop_End}, - {Uop_End}, - {Uop_Fetch2, Uop_IndIdx_Stage3, Uop_IndIdx_Stage4, Uop_IndIdx_RMW_Stage5, Uop_IndIdx_RMW_Stage6, Uop_IndIdx_RMW_Stage7_DCP, Uop_IndIdx_RMW_Stage8, Uop_End}, - {Uop_Fetch2, Uop_ZpIdx_Stage3_X, Uop_ZP_READ_NOP, Uop_End}, - {Uop_Fetch2, Uop_ZpIdx_Stage3_X, Uop_ZP_READ_CMP, Uop_End}, - {Uop_Fetch2, Uop_ZpIdx_Stage3_X, Uop_ZpIdx_RMW_Stage4, Uop_ZP_RMW_DEC, Uop_ZpIdx_RMW_Stage6, Uop_End}, - {Uop_Fetch2, Uop_ZpIdx_Stage3_X, Uop_ZpIdx_RMW_Stage4, Uop_ZP_RMW_DCP, Uop_ZpIdx_RMW_Stage6, Uop_End}, - {Uop_Imp_CLD, Uop_End}, - {Uop_Fetch2, Uop_AbsIdx_Stage3_Y, Uop_AbsIdx_READ_Stage4, Uop_AbsIdx_READ_Stage5_CMP, Uop_End}, - {Uop_FetchDummy, Uop_End}, - {Uop_Fetch2, Uop_AbsIdx_Stage3_Y, Uop_AbsIdx_Stage4, Uop_AbsIdx_RMW_Stage5, Uop_AbsIdx_RMW_Stage6_DCP, Uop_AbsIdx_RMW_Stage7, Uop_End}, - {Uop_Fetch2, Uop_AbsIdx_Stage3_X, Uop_AbsIdx_READ_Stage4, Uop_AbsIdx_READ_Stage5_NOP, Uop_End}, - {Uop_Fetch2, Uop_AbsIdx_Stage3_X, Uop_AbsIdx_READ_Stage4, Uop_AbsIdx_READ_Stage5_CMP, Uop_End}, - {Uop_Fetch2, Uop_AbsIdx_Stage3_X, Uop_AbsIdx_Stage4, Uop_AbsIdx_RMW_Stage5, Uop_AbsIdx_RMW_Stage6_DEC, Uop_AbsIdx_RMW_Stage7, Uop_End}, - {Uop_Fetch2, Uop_AbsIdx_Stage3_X, Uop_AbsIdx_Stage4, Uop_AbsIdx_RMW_Stage5, Uop_AbsIdx_RMW_Stage6_DCP, Uop_AbsIdx_RMW_Stage7, Uop_End}, - {Uop_Imm_CPX, Uop_End}, - {Uop_Fetch2, Uop_IdxInd_Stage3, Uop_IdxInd_Stage4, Uop_IdxInd_Stage5, Uop_IdxInd_Stage6_READ_SBC, Uop_End}, - {Uop_Imm_Unsupported, Uop_End}, - {Uop_Fetch2, Uop_IdxInd_Stage3, Uop_IdxInd_Stage4, Uop_IdxInd_Stage5, Uop_IdxInd_Stage6_RMW, Uop_IdxInd_Stage7_RMW_ISC, Uop_IdxInd_Stage8_RMW, Uop_End}, - {Uop_Fetch2, Uop_ZP_READ_CPX, Uop_End}, - {Uop_Fetch2, Uop_ZP_READ_SBC, Uop_End}, - {Uop_Fetch2, Uop_ZP_RMW_Stage3, Uop_ZP_RMW_INC, Uop_ZP_RMW_Stage5, Uop_End}, - {Uop_Fetch2, Uop_ZP_RMW_Stage3, Uop_ZP_RMW_ISC, Uop_ZP_RMW_Stage5, Uop_End}, - {Uop_Imp_INX, Uop_End}, - {Uop_Imm_SBC, Uop_End}, - {Uop_FetchDummy, Uop_End}, - {Uop_Imm_SBC, Uop_End}, - {Uop_Fetch2, Uop_Fetch3, Uop_Abs_READ_CPX, Uop_End}, - {Uop_Fetch2, Uop_Fetch3, Uop_Abs_READ_SBC, Uop_End}, - {Uop_Fetch2, Uop_Fetch3, Uop_Abs_RMW_Stage4, Uop_Abs_RMW_Stage5_INC, Uop_Abs_RMW_Stage6, Uop_End}, - {Uop_Fetch2, Uop_Fetch3, Uop_Abs_RMW_Stage4, Uop_Abs_RMW_Stage5_ISC, Uop_Abs_RMW_Stage6, Uop_End}, - {Uop_RelBranch_Stage2_BEQ, Uop_End}, - {Uop_Fetch2, Uop_IndIdx_Stage3, Uop_IndIdx_Stage4, Uop_IndIdx_READ_Stage5, Uop_IndIdx_READ_Stage6_SBC, Uop_End}, - {Uop_End}, - {Uop_Fetch2, Uop_IndIdx_Stage3, Uop_IndIdx_Stage4, Uop_IndIdx_RMW_Stage5, Uop_IndIdx_RMW_Stage6, Uop_IndIdx_RMW_Stage7_ISC, Uop_IndIdx_RMW_Stage8, Uop_End}, - {Uop_Fetch2, Uop_ZpIdx_Stage3_X, Uop_ZP_READ_NOP, Uop_End}, - {Uop_Fetch2, Uop_ZpIdx_Stage3_X, Uop_ZP_READ_SBC, Uop_End}, - {Uop_Fetch2, Uop_ZpIdx_Stage3_X, Uop_ZpIdx_RMW_Stage4, Uop_ZP_RMW_INC, Uop_ZpIdx_RMW_Stage6, Uop_End}, - {Uop_Fetch2, Uop_ZpIdx_Stage3_X, Uop_ZpIdx_RMW_Stage4, Uop_ZP_RMW_ISC, Uop_ZpIdx_RMW_Stage6, Uop_End}, - {Uop_Imp_SED, Uop_End}, - {Uop_Fetch2, Uop_AbsIdx_Stage3_Y, Uop_AbsIdx_READ_Stage4, Uop_AbsIdx_READ_Stage5_SBC, Uop_End}, - {Uop_FetchDummy, Uop_End}, - {Uop_Fetch2, Uop_AbsIdx_Stage3_Y, Uop_AbsIdx_Stage4, Uop_AbsIdx_RMW_Stage5, Uop_AbsIdx_RMW_Stage6_ISC, Uop_AbsIdx_RMW_Stage7, Uop_End}, - {Uop_Fetch2, Uop_AbsIdx_Stage3_X, Uop_AbsIdx_READ_Stage4, Uop_AbsIdx_READ_Stage5_NOP, Uop_End}, - {Uop_Fetch2, Uop_AbsIdx_Stage3_X, Uop_AbsIdx_READ_Stage4, Uop_AbsIdx_READ_Stage5_SBC, Uop_End}, - {Uop_Fetch2, Uop_AbsIdx_Stage3_X, Uop_AbsIdx_Stage4, Uop_AbsIdx_RMW_Stage5, Uop_AbsIdx_RMW_Stage6_INC, Uop_AbsIdx_RMW_Stage7, Uop_End}, - {Uop_Fetch2, Uop_AbsIdx_Stage3_X, Uop_AbsIdx_Stage4, Uop_AbsIdx_RMW_Stage5, Uop_AbsIdx_RMW_Stage6_ISC, Uop_AbsIdx_RMW_Stage7, Uop_End}, - {Uop_Fetch1}, - {Uop_RelBranch_Stage3, Uop_End_BranchSpecial}, - {Uop_RelBranch_Stage4, Uop_End}, - {Uop_End_SuppressInterrupt}, - {Uop_FetchDummy, Uop_FetchDummy, Uop_PushPCH, Uop_PushPCL, Uop_PushP_NMI, Uop_FetchPCLVector, Uop_FetchPCHVector, Uop_End_SuppressInterrupt}, - {Uop_FetchDummy, Uop_FetchDummy, Uop_PushPCH, Uop_PushPCL, Uop_PushP_IRQ, Uop_FetchPCLVector, Uop_FetchPCHVector, Uop_End_SuppressInterrupt}, - {Uop_FetchDummy, Uop_FetchDummy, Uop_PushDummy, Uop_PushDummy, Uop_PushP_Reset, Uop_FetchPCLVector, Uop_FetchPCHVector, Uop_End_SuppressInterrupt}, - {Uop_Fetch1_Real}, -}; diff --git a/BizHawk.Emulation.Cores/CPUs/MOS 6502X/6502XXX/mingw/Makefile b/BizHawk.Emulation.Cores/CPUs/MOS 6502X/6502XXX/mingw/Makefile deleted file mode 100644 index 05a27cbc7b..0000000000 --- a/BizHawk.Emulation.Cores/CPUs/MOS 6502X/6502XXX/mingw/Makefile +++ /dev/null @@ -1,26 +0,0 @@ -CXX = g++ -CXXFLAGS = -Wall -I.. -O3 -fno-exceptions -fomit-frame-pointer -std=c++11 -TARGET = 6502XXX.dll -LDFLAGS = -shared -static-libgcc -static-libstdc++ $(CXXFLAGS) -RM = rm -CP = cp - -SRCS = \ - ../execute.cpp - -OBJS = $(SRCS:.cpp=.o) - -all: $(TARGET) - -%.o: %.cpp - $(CXX) -c -o $@ $< $(CXXFLAGS) - -$(TARGET) : $(OBJS) - $(CXX) -o $@ $(LDFLAGS) $(OBJS) - -clean: - $(RM) $(OBJS) - $(RM) $(TARGET) - -install: - $(CP) $(TARGET) ../../../../../output/dll diff --git a/BizHawk.Emulation.Cores/ExternalCores/EmuFile.cs b/BizHawk.Emulation.Cores/ExternalCores/EmuFile.cs deleted file mode 100644 index f6d6dd6159..0000000000 --- a/BizHawk.Emulation.Cores/ExternalCores/EmuFile.cs +++ /dev/null @@ -1,193 +0,0 @@ -using System; -using System.Security; -using System.Runtime.InteropServices; -using System.Linq; -using System.Diagnostics; -using System.Globalization; -using System.IO; -using System.Collections.Generic; -using System.Reflection; -using System.Text; -using System.Reflection.Emit; -using System.Threading; -using BizHawk.DiscSystem; - -namespace BizHawk -{ - /// - /// represents an external core's interface to a disc - /// - public class DiscInterface : ExternalCore - { - public DiscInterface(IExternalCoreAccessor accessor) - : base(accessor) - { - UnmanagedOpaque = QueryCoreCall>("DiscInterface.Construct")(ManagedOpaque); - - SetFp("Dispose", new disposeDelegate(Dispose)); - SetFp("GetNumSessions", new GetNumSessionsDelegate(GetNumSessions)); - SetFp("GetNumTracks", new GetNumTracksDelegate(GetNumTracks)); - SetFp("GetTrack", new GetTrackDelegate(GetTrack)); - } - - bool disposed = false; - public override void Dispose() - { - if (disposed) return; - disposed = true; - - QueryCoreCall("DiscInterface.Delete")(); - - base.Dispose(); - } - - public DiscHopper DiscHopper; - - void SetFp(string name, Delegate del) - { - QueryCoreCall>("DiscInterface.Set_fp")(name, ExportDelegate(del)); - } - - struct TrackInfo - { - public ETrackType TrackType; - public int length_lba; - public int start_lba; - } - - int GetNumSessions() - { - return DiscHopper.CurrentDisc.ReadTOC().Sessions.Count; - } - - int GetNumTracks(int session) - { - return DiscHopper.CurrentDisc.ReadTOC().Sessions[session].Tracks.Count; - } - - TrackInfo GetTrack(int session, int track) - { - var ti = new TrackInfo(); - var toc_track = DiscHopper.CurrentDisc.ReadTOC().Sessions[session].Tracks[track]; - ti.TrackType = toc_track.TrackType; - ti.length_lba = toc_track.length_aba; - return ti; - } - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - delegate void disposeDelegate(); - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - delegate int GetNumSessionsDelegate(); - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - delegate int GetNumTracksDelegate(int session); - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - delegate TrackInfo GetTrackDelegate(int session, int track); - } - - - public class EmuFile : ExternalCore - { - public EmuFile(IExternalCoreAccessor accessor) - : base(accessor) - { - UnmanagedOpaque = QueryCoreCall>("EmuFile.Construct")(ManagedOpaque); - - SetFp("fgetc", new fgetcDelegate(fgetc)); - SetFp("fread", new freadDelegate(fread)); - SetFp("fwrite", new fwriteDelegate(fwrite)); - SetFp("fseek", new fseekDelegate(fseek)); - SetFp("ftell", new ftellDelegate(ftell)); - SetFp("size", new sizeDelegate(size)); - SetFp("dispose", new disposeDelegate(Dispose)); - } - - void SetFp(string name, Delegate del) - { - QueryCoreCall>("EmuFile.Set_fp")(name, ExportDelegate(del)); - } - - public Stream BaseStream { get; set; } - - //do we want to have a finalizer? not sure. - bool disposed = false; - public override void Dispose() - { - if (disposed) return; - disposed = true; - - //we will call Delete in the c++ side, which will delete the object, and cause Dispose() to get called. - //but, Dispose() can never be called again due to setting the flag above - QueryCoreCall("EmuFile.Delete")(); - - //do we always want to do this? not sure. but usually. - BaseStream.Dispose(); - - base.Dispose(); - } - - int fgetc() - { - return BaseStream.ReadByte(); - } - - IntPtr fread( - [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] - byte[] ptr, - IntPtr bytes) - { - long len = bytes.ToInt64(); - if (len >= int.MaxValue || len < 0) throw new ArgumentException(); - - int ret = BaseStream.Read(ptr, 0, (int)len); - return new IntPtr(ret); - } - - IntPtr fseek(IntPtr offset, IntPtr origin) - { - SeekOrigin so = (SeekOrigin)origin.ToInt32(); - long loffset = offset.ToInt64(); - return new IntPtr(BaseStream.Seek(loffset, so)); - } - - IntPtr ftell() { return new IntPtr(BaseStream.Position); } - IntPtr size() { return new IntPtr(BaseStream.Length); } - - void fwrite( - [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] - byte[] ptr, - IntPtr bytes) - { - long len = bytes.ToInt64(); - if (len >= int.MaxValue || len < 0) throw new ArgumentException(); - - BaseStream.Write(ptr, 0, (int)len); - } - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - delegate int fgetcDelegate(); - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - delegate void disposeDelegate(); - //TODO - for more speed fread and fwrite might appreciate taking pointers - //(although, we'll have to convert it to an array to deal with an underlying stream anyway -- or will we? - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - delegate IntPtr freadDelegate( - [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] - byte[] ptr, - IntPtr bytes); - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - delegate void fwriteDelegate( - [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] - byte[] ptr, - IntPtr bytes); - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - delegate IntPtr fseekDelegate(IntPtr offset, IntPtr origin); - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - delegate IntPtr ftellDelegate(); - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - delegate IntPtr sizeDelegate(); - - } -} \ No newline at end of file diff --git a/BizHawk.Emulation.Cores/ExternalCores/ExternalCore.cs b/BizHawk.Emulation.Cores/ExternalCores/ExternalCore.cs deleted file mode 100644 index 7c2fe64230..0000000000 --- a/BizHawk.Emulation.Cores/ExternalCores/ExternalCore.cs +++ /dev/null @@ -1,254 +0,0 @@ -using System; -using System.Security; -using System.Threading; -using System.Text; -using System.Reflection; -using System.Reflection.Emit; -using System.Runtime.InteropServices; -using System.Linq; -using System.Diagnostics; -using System.Globalization; -using System.IO; -using System.Collections.Generic; - -namespace BizHawk -{ - - - /// - /// universal interface to a shared library - /// - public interface ILibAccessor : IDisposable - { - IntPtr GetProcAddress(string name); - bool IsOpen { get; } - } - - /// - /// universal access to an external emulator core - /// - public interface IExternalCoreAccessor : IDisposable - { - IntPtr Signal(string type, IntPtr obj, string param, IntPtr value); - bool IsOpen { get; } - void RegisterCore(ExternalCore core, bool register); - } - - - public class CoreAccessor : IExternalCoreAccessor - { - ILibAccessor mLibAccessor; - public CoreAccessor(ILibAccessor accessor) - { - mLibAccessor = accessor; - if (accessor.IsOpen) - { - mSignal = (SignalCallbackDelegate)Marshal.GetDelegateForFunctionPointer(accessor.GetProcAddress("Core_signal"), typeof(SignalCallbackDelegate)); - IsOpen = true; - } - } - - public void RegisterCore(ExternalCore core, bool register) - { - if (core is StaticCoreCommon) return; - - //defer initialization until the core is needed, to avoid pointless costs for cores the user isnt using - if (!IsInitialized) - { - IsInitialized = true; - scc = new StaticCoreCommon(this); - scc.RegisterClientSignal(new SignalCallbackDelegate(ClientSignal)); - scc.Initialize(); - } - - if (register) - { - mCoreRegistry[core.ManagedOpaque] = core; - } - else - { - mCoreRegistry.Remove(core.ManagedOpaque); - } - } - - StaticCoreCommon scc; - Dictionary mCoreRegistry = new Dictionary(); - - public void Dispose() - { - if (mLibAccessor == null) return; - scc.Dispose(); - mLibAccessor.Dispose(); - mLibAccessor = null; - IsOpen = false; - } - - public bool IsOpen { get; private set; } - bool IsInitialized; - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate IntPtr SignalCallbackDelegate(string type, IntPtr obj, string param, IntPtr value); - SignalCallbackDelegate mSignal; - - //external cores call into the client from here - public IntPtr ClientSignal(string type, IntPtr obj, string param, IntPtr value) - { - //static calls - if (obj == IntPtr.Zero) - { - return scc.ClientSignal(type, obj, param, value); - } - else - { - return mCoreRegistry[obj].ClientSignal(type, obj, param, value); - } - } - - public IntPtr Signal(string type, IntPtr obj, string param, IntPtr value) - { - if (!IsOpen) throw new InvalidOperationException("core accessor is open"); - return mSignal(type, obj, param, value); - } - } - - //todo - make abstract - public class ExternalCore : IDisposable - { - //rename to managed and unmanaged - public IntPtr ManagedOpaque; - public IntPtr UnmanagedOpaque; - static int _ManagedOpaque_Counter = 1; - private static object oLock = new object(); - - protected IExternalCoreAccessor mAccessor; - public ExternalCore(IExternalCoreAccessor accessor) - { - mAccessor = accessor; - lock (oLock) - { - ManagedOpaque = new IntPtr(_ManagedOpaque_Counter); - _ManagedOpaque_Counter++; - } - mAccessor.RegisterCore(this, true); - } - - public virtual void Dispose() - { - mAccessor.RegisterCore(this, false); - - //universal delete mechanism? - //probably not. - } - - /// - /// cores call into the client from here. this system is not fully baked yet, though - /// - public virtual IntPtr ClientSignal(string type, IntPtr obj, string param, IntPtr value) - { - //if (type == "FACTORY") - //{ - // return new DiscInterface(mAccessor).UnmanagedOpaque; - //} - //else return IntPtr.Zero; - return IntPtr.Zero; - } - - /// - /// merely emits an integer of the current system int size to an ILGenerator - /// - static void EmitIntPtr(ILGenerator gen, IntPtr val) - { - if (IntPtr.Size == 4) gen.Emit(OpCodes.Ldc_I4, val.ToInt32()); - else gen.Emit(OpCodes.Ldc_I8, val.ToInt64()); - } - - /// - /// retrieves a function pointer from the core and returns it as the specified delegate type - /// - protected void QueryCoreCall(out T del, string name) - { - del = QueryCoreCall(name); - } - - /// - /// retrieves a function pointer from the core and returns it as the specified delegate type - /// - protected T QueryCoreCall(string name) - { - MethodInfo mi = typeof(T).GetMethod("Invoke"); - ParameterInfo[] pis = mi.GetParameters(); - Type[] unmanagedParamTypes = new Type[pis.Length + 1]; - Type[] managedParamTypes = new Type[pis.Length]; - unmanagedParamTypes[0] = typeof(int); - for (int i = 0; i < pis.Length; i++) - { - unmanagedParamTypes[i + 1] = pis[i].ParameterType; - managedParamTypes[i] = pis[i].ParameterType; - } - - IntPtr fptr = mAccessor.Signal("QUERY_FUNCTION", IntPtr.Zero, name, IntPtr.Zero); - if (fptr == IntPtr.Zero) - throw new InvalidOperationException("external core was missing requested function: " + name); - - DynamicMethod dm = new DynamicMethod("", mi.ReturnType, managedParamTypes, GetType().Module); - ILGenerator gen = dm.GetILGenerator(); - EmitIntPtr(gen, UnmanagedOpaque); - for (int i = 0; i < pis.Length; i++) gen.Emit(OpCodes.Ldarg, i); - EmitIntPtr(gen, fptr); - gen.EmitCalli(OpCodes.Calli, CallingConvention.ThisCall, mi.ReturnType, unmanagedParamTypes); - gen.Emit(OpCodes.Ret); - - Delegate d = dm.CreateDelegate(typeof(T)); - return (T)(object)d; - } - - /// - /// exports a delegate as an IntPtr for use in unmanaged code and manages its life cycle to keep it from getting freed - /// - protected IntPtr ExportDelegate(Delegate d) - { - IntPtr retPtr = Marshal.GetFunctionPointerForDelegate(d); - listLiveDelegates.Add(d); - return retPtr; - } - - //need to hold on to these callbacks to make sure they dont get GCed while unmanaged code has a pointer to them - List listLiveDelegates = new List(); - } - - - public class StaticCoreCommon : ExternalCore - { - //keep in mind that we may need to make the console thread safe if we ever do any zany multithreaded things - - public StaticCoreCommon(IExternalCoreAccessor accessor) - : base(accessor) - { - } - - EmuFile Console; - public void Initialize() - { - Console = new EmuFile(mAccessor); - if (Log.HACK_LOG_STREAM != null) - Console.BaseStream = Log.HACK_LOG_STREAM; - else - Console.BaseStream = System.Console.OpenStandardOutput(); - mAccessor.Signal("SET_CONSOLE", IntPtr.Zero, null, Console.UnmanagedOpaque); - } - - public void RegisterClientSignal(CoreAccessor.SignalCallbackDelegate ClientSignal) - { - mAccessor.Signal("SET_CLIENT_SIGNAL", IntPtr.Zero, null, ExportDelegate(ClientSignal)); - } - - public override IntPtr ClientSignal(string type, IntPtr obj, string param, IntPtr value) - { - return IntPtr.Zero; - } - - } - - - -} \ No newline at end of file diff --git a/BizHawk.Emulation.Cores/ExternalCores/PsxCore.cs b/BizHawk.Emulation.Cores/ExternalCores/PsxCore.cs deleted file mode 100644 index 10ffc26519..0000000000 --- a/BizHawk.Emulation.Cores/ExternalCores/PsxCore.cs +++ /dev/null @@ -1,101 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using System.Linq; -using System.Diagnostics; -using System.Globalization; -using System.IO; -using System.Collections.Generic; -using BizHawk.DiscSystem; - -namespace BizHawk -{ - - public class PsxCore : ExternalCore, IEmulator, IVideoProvider, ISoundProvider - { - public PsxCore(IExternalCoreAccessor accessor) - : base(accessor) - { - var domains = new List(1); - memoryDomains = domains.AsReadOnly(); - CoreOutputComm = new CoreOutputComm(); - CoreInputComm = new CoreInputComm(); - - mDiscInterface = new DiscInterface(mAccessor); - - UnmanagedOpaque = QueryCoreCall>("PsxCore.Construct")(ManagedOpaque); - - QueryCoreCall(out cGetResolution, "PsxCore.GetResolution"); - QueryCoreCall(out cUpdateVideoBuffer, "PsxCore.UpdateVideoBuffer"); - QueryCoreCall(out cFrameAdvance, "PsxCore.FrameAdvance"); - } - - DiscInterface mDiscInterface; - public void SetDiscHopper(DiscHopper hopper) - { - mDiscInterface.DiscHopper = hopper; - } - - public override IntPtr ClientSignal(string type, IntPtr obj, string param, IntPtr value) - { - if (param == "GetDiscInterface") - { - return mDiscInterface.UnmanagedOpaque; - } - return base.ClientSignal(type, obj, param, value); - } - - Func cGetResolution; - Action cFrameAdvance; - Action cUpdateVideoBuffer; - - //video provider - int[] videoBuffer = new int[256 * 256]; - public int[] GetVideoBuffer() { return videoBuffer; } - public int BufferWidth { get { return 256; } } - public int BufferHeight { get { return 192; } } - public int BackgroundColor { get { return 0; } } - - public void ResetFrameCounter() - { - Frame = 0; - } - - public string SystemId { get { return "PSX"; } } - public static readonly ControllerDefinition NullController = new ControllerDefinition { Name = "Null Controller" }; - - private Random rand = new Random(); - public CoreInputComm CoreInputComm { get; set; } - public CoreOutputComm CoreOutputComm { get; private set; } - public IVideoProvider VideoProvider { get { return this; } } - public ISoundProvider SoundProvider { get { return this; } } - public unsafe void FrameAdvance(bool render) - { - //if (render == false) return; - cFrameAdvance(); - fixed (int* vidbuf = &videoBuffer[0]) - cUpdateVideoBuffer(new IntPtr(vidbuf)); - } - public ControllerDefinition ControllerDefinition { get { return NullController; } } - public IController Controller { get; set; } - - public int Frame { get; set; } - public int LagCount { get { return 0; } set { return; } } - public bool IsLagFrame { get { return false; } } - - public byte[] SaveRam { get { return new byte[0]; } } - public bool DeterministicEmulation { get; set; } - public bool SaveRamModified { get; set; } - public void SaveStateText(TextWriter writer) { } - public void LoadStateText(TextReader reader) { } - public void SaveStateBinary(BinaryWriter writer) { } - public void LoadStateBinary(BinaryReader reader) { } - public byte[] SaveStateBinary() { return new byte[1]; } - public void GetSamples(short[] samples) { } - public void DiscardSamples() { } - public int MaxVolume { get; set; } - private IList memoryDomains; - public IList MemoryDomains { get { return memoryDomains; } } - public MemoryDomain MainMemory { get { return memoryDomains[0]; } } - public void Dispose() { } - } -} \ No newline at end of file diff --git a/BizHawk.Emulation.Cores/ExternalCores/Snippets.txt b/BizHawk.Emulation.Cores/ExternalCores/Snippets.txt deleted file mode 100644 index 56ee3b912e..0000000000 --- a/BizHawk.Emulation.Cores/ExternalCores/Snippets.txt +++ /dev/null @@ -1,103 +0,0 @@ -//////////////////////////// -//we can't use these because we need more clever control over the delegate type (marshalling attributes, for one thing) - - Delegate MyMakeDelegate(string methodName) - { - MethodInfo mi = GetType().GetMethod(methodName,BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); - var parameters = mi.GetParameters() - .Select(p => p.ParameterType) - .ToArray(); - - Type t = DelegateCreator.MakeNewCustomDelegate(mi.ReturnType, parameters); - return Delegate.CreateDelegate(t, this, mi); - } - - - static class DelegateCreator - { - public static Type MakeNewCustomDelegate(Type ret_type, Type[] argtypes) - { - var _DelegateCtorSignature = new Type[] { typeof(object), typeof(IntPtr) }; - Type returnType = ret_type; - Type[] parameterTypes = argtypes; - TypeBuilder builder = DefineDelegateType("Delegate" + argtypes.Length); - builder.DefineConstructor(MethodAttributes.RTSpecialName | MethodAttributes.HideBySig | MethodAttributes.Public, CallingConventions.Standard, _DelegateCtorSignature).SetImplementationFlags(MethodImplAttributes.CodeTypeMask); - builder.DefineMethod("Invoke", MethodAttributes.VtableLayoutMask | MethodAttributes.HideBySig | MethodAttributes.Virtual | MethodAttributes.Public, returnType, parameterTypes).SetImplementationFlags(MethodImplAttributes.CodeTypeMask); - - //[UnmanagedFunctionPointer(CallingConvention.ThisCall)] - //builder.SetCustomAttribute(new CustomAttributeBuilder(new ConstructorInfo( - ConstructorInfo ci = typeof(UnmanagedFunctionPointerAttribute).GetConstructor(new[] { typeof(CallingConvention) }); - CustomAttributeBuilder cab = new CustomAttributeBuilder(ci, new object[] { CallingConvention.ThisCall }); - builder.SetCustomAttribute(cab); - - return builder.CreateType(); - } - - internal static TypeBuilder DefineDelegateType(string name) - { - return DefineType(name, typeof(MulticastDelegate), TypeAttributes.AutoClass | TypeAttributes.Sealed | TypeAttributes.Public); - } - - static int _index; - private static TypeBuilder DefineType(string name, Type parent, TypeAttributes attr) - { - StringBuilder builder = new StringBuilder(name); - int num = Interlocked.Increment(ref _index); - builder.Append("$"); - builder.Append(num); - builder.Replace('+', '_').Replace('[', '_').Replace(']', '_').Replace('*', '_').Replace('&', '_').Replace(',', '_').Replace('\\', '_'); - name = builder.ToString(); - return _myModule.DefineType(name, attr, parent); - } - - static AssemblyBuilder _myAssembly; - static ModuleBuilder _myModule; - static void InitializeAssemblyGen() - { - AssemblyName name = new AssemblyName("Snippets"); - CustomAttributeBuilder[] assemblyAttributes = new CustomAttributeBuilder[] { new CustomAttributeBuilder(typeof(SecurityTransparentAttribute).GetConstructor(Type.EmptyTypes), new object[0]) }; - _myAssembly = AppDomain.CurrentDomain.DefineDynamicAssembly(name, AssemblyBuilderAccess.Run, assemblyAttributes); - _myModule = _myAssembly.DefineDynamicModule(name.Name, false); - _myAssembly.DefineVersionInfoResource(); - } - static DelegateCreator() - { - InitializeAssemblyGen(); - } - } - - -//////////////// -these are members of external core. theyre deprecated. - - - public IntPtr Signal(string param, IntPtr value) - { - return mAccessor.Signal(null, IntPtr.Zero, param, value); - } - - public IntPtr Signal(string param) - { - return mAccessor.Signal(null, IntPtr.Zero, param, IntPtr.Zero); - } - - public IntPtr Signal(string type, IntPtr obj, string param, Delegate value) - { - liveDelegates[value.Target ?? ostatic][param] = value; - return mAccessor.Signal(type, obj, param, Marshal.GetFunctionPointerForDelegate(value)); - } - - public IntPtr Signal(string param, Delegate value) - { - return Signal(null, IntPtr.Zero, param, value); - } - - public IntPtr Signal(string param, int value) - { - return mAccessor.Signal(null, IntPtr.Zero, param, new IntPtr(value)); - } - - public IntPtr Signal(string type, IntPtr obj, string param, IntPtr value) - { - return mAccessor.Signal(type, obj, param, value); - } \ No newline at end of file diff --git a/BizHawk.Emulation.Cores/LibretroOld/LibRetro.cs b/BizHawk.Emulation.Cores/LibretroOld/LibRetro.cs deleted file mode 100644 index 6c5dd30441..0000000000 --- a/BizHawk.Emulation.Cores/LibretroOld/LibRetro.cs +++ /dev/null @@ -1,672 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Runtime.InteropServices; -using System.Reflection; - -#pragma warning disable 649, 169 - -using BizHawk.Common; - -namespace BizHawk.Emulation.Cores -{ - /// - /// libretro related shims - /// - public class LibRetro : IDisposable - { - public const int RETRO_API_VERSION = 1; - - public enum RETRO_ROTATION - { - ROTATION_0_CCW = 0, - ROTATION_90_CCW = 1, - ROTATION_180_CCW = 2, - ROTATION_270_CCW = 3, - } - - public enum RETRO_DEVICE - { - NONE = 0, - JOYPAD = 1, - MOUSE = 2, - KEYBOARD = 3, - LIGHTGUN = 4, - ANALOG = 5, - POINTER = 6, - SENSOR_ACCELEROMETER = 7 - }; - - public enum RETRO_DEVICE_ID_JOYPAD - { - B = 0, - Y = 1, - SELECT = 2, - START = 3, - UP = 4, - DOWN = 5, - LEFT = 6, - RIGHT = 7, - A = 8, - X = 9, - L = 10, - R = 11, - L2 = 12, - R2 = 13, - L3 = 14, - R3 = 15 - }; - - public enum RETRO_LOG_LEVEL : int //exact type size is unclear - { - DEBUG = 0, - INFO, - WARN, - ERROR, - - DUMMY = Int32.MaxValue - }; - - public enum RETRO_DEVICE_ID_ANALOG - { - // LEFT / RIGHT? - X = 0, - Y = 1 - }; - - public enum RETRO_DEVICE_ID_MOUSE - { - X = 0, - Y = 1, - LEFT = 2, - RIGHT = 3 - }; - - public enum RETRO_DEVICE_ID_LIGHTGUN - { - X = 0, - Y = 1, - TRIGGER = 2, - CURSOR = 3, - TURBO = 4, - PAUSE = 5, - START = 6 - }; - - public enum RETRO_DEVICE_ID_POINTER - { - X = 0, - Y = 1, - PRESSED = 2 - }; - - public enum RETRO_DEVICE_ID_SENSOR_ACCELEROMETER - { - X = 0, - Y = 1, - Z = 2 - }; - - public enum RETRO_REGION - { - NTSC = 0, - PAL = 1 - }; - - public enum RETRO_MEMORY - { - SAVE_RAM = 0, - RTC = 1, - SYSTEM_RAM = 2, - VIDEO_RAM = 3, - }; - - public enum RETRO_KEY - { - UNKNOWN = 0, - FIRST = 0, - BACKSPACE = 8, - TAB = 9, - CLEAR = 12, - RETURN = 13, - PAUSE = 19, - ESCAPE = 27, - SPACE = 32, - EXCLAIM = 33, - QUOTEDBL = 34, - HASH = 35, - DOLLAR = 36, - AMPERSAND = 38, - QUOTE = 39, - LEFTPAREN = 40, - RIGHTPAREN = 41, - ASTERISK = 42, - PLUS = 43, - COMMA = 44, - MINUS = 45, - PERIOD = 46, - SLASH = 47, - _0 = 48, - _1 = 49, - _2 = 50, - _3 = 51, - _4 = 52, - _5 = 53, - _6 = 54, - _7 = 55, - _8 = 56, - _9 = 57, - COLON = 58, - SEMICOLON = 59, - LESS = 60, - EQUALS = 61, - GREATER = 62, - QUESTION = 63, - AT = 64, - LEFTBRACKET = 91, - BACKSLASH = 92, - RIGHTBRACKET = 93, - CARET = 94, - UNDERSCORE = 95, - BACKQUOTE = 96, - a = 97, - b = 98, - c = 99, - d = 100, - e = 101, - f = 102, - g = 103, - h = 104, - i = 105, - j = 106, - k = 107, - l = 108, - m = 109, - n = 110, - o = 111, - p = 112, - q = 113, - r = 114, - s = 115, - t = 116, - u = 117, - v = 118, - w = 119, - x = 120, - y = 121, - z = 122, - DELETE = 127, - - KP0 = 256, - KP1 = 257, - KP2 = 258, - KP3 = 259, - KP4 = 260, - KP5 = 261, - KP6 = 262, - KP7 = 263, - KP8 = 264, - KP9 = 265, - KP_PERIOD = 266, - KP_DIVIDE = 267, - KP_MULTIPLY = 268, - KP_MINUS = 269, - KP_PLUS = 270, - KP_ENTER = 271, - KP_EQUALS = 272, - - UP = 273, - DOWN = 274, - RIGHT = 275, - LEFT = 276, - INSERT = 277, - HOME = 278, - END = 279, - PAGEUP = 280, - PAGEDOWN = 281, - - F1 = 282, - F2 = 283, - F3 = 284, - F4 = 285, - F5 = 286, - F6 = 287, - F7 = 288, - F8 = 289, - F9 = 290, - F10 = 291, - F11 = 292, - F12 = 293, - F13 = 294, - F14 = 295, - F15 = 296, - - NUMLOCK = 300, - CAPSLOCK = 301, - SCROLLOCK = 302, - RSHIFT = 303, - LSHIFT = 304, - RCTRL = 305, - LCTRL = 306, - RALT = 307, - LALT = 308, - RMETA = 309, - LMETA = 310, - LSUPER = 311, - RSUPER = 312, - MODE = 313, - COMPOSE = 314, - - HELP = 315, - PRINT = 316, - SYSREQ = 317, - BREAK = 318, - MENU = 319, - POWER = 320, - EURO = 321, - UNDO = 322, - - LAST - }; - - [Flags] - public enum RETRO_MOD - { - NONE = 0, - SHIFT = 1, - CTRL = 2, - ALT = 4, - META = 8, - NUMLOCK = 16, - CAPSLOCK = 32, - SCROLLLOCK = 64 - }; - - [Flags] - public enum RETRO_SIMD - { - SSE = (1 << 0), - SSE2 = (1 << 1), - VMX = (1 << 2), - VMX128 = (1 << 3), - AVX = (1 << 4), - NEON = (1 << 5), - SSE3 = (1 << 6), - SSSE3 = (1 << 7), - MMX = (1 << 8), - MMXEXT = (1 << 9), - SSE4 = (1 << 10), - SSE42 = (1 << 11), - AVX2 = (1 << 12), - VFPU = (1 << 13), - PS = (1 << 14), - AES = (1 << 15), - VFPV3 = (1 << 16), - VFPV4 = (1 << 17), - } - - public enum RETRO_ENVIRONMENT - { - SET_ROTATION = 1, - GET_OVERSCAN = 2, - GET_CAN_DUPE = 3, - SET_MESSAGE = 6, - SHUTDOWN = 7, - SET_PERFORMANCE_LEVEL = 8, - GET_SYSTEM_DIRECTORY = 9, - SET_PIXEL_FORMAT = 10, - SET_INPUT_DESCRIPTORS = 11, - SET_KEYBOARD_CALLBACK = 12, - SET_DISK_CONTROL_INTERFACE = 13, - SET_HW_RENDER = 14, - GET_VARIABLE = 15, - SET_VARIABLES = 16, - GET_VARIABLE_UPDATE = 17, - SET_SUPPORT_NO_GAME = 18, - GET_LIBRETRO_PATH = 19, - SET_AUDIO_CALLBACK = 22, - SET_FRAME_TIME_CALLBACK = 21, - GET_RUMBLE_INTERFACE = 23, - GET_INPUT_DEVICE_CAPABILITIES = 24, - //25,26 are experimental - GET_LOG_INTERFACE = 27, - GET_PERF_INTERFACE = 28, - GET_LOCATION_INTERFACE = 29, - GET_CORE_ASSETS_DIRECTORY = 30, - GET_SAVE_DIRECTORY = 31, - SET_SYSTEM_AV_INFO = 32, - SET_PROC_ADDRESS_CALLBACK = 33, - SET_SUBSYSTEM_INFO = 34, - SET_CONTROLLER_INFO = 35, - SET_MEMORY_MAPS = 36 | EXPERIMENTAL, - SET_GEOMETRY = 37, - GET_USERNAME = 38, - GET_LANGUAGE = 39, - - EXPERIMENTAL = 0x10000 - }; - - public enum retro_hw_context_type - { - RETRO_HW_CONTEXT_NONE = 0, - RETRO_HW_CONTEXT_OPENGL = 1, - RETRO_HW_CONTEXT_OPENGLES2 = 2, - RETRO_HW_CONTEXT_OPENGL_CORE = 3, - RETRO_HW_CONTEXT_OPENGLES3 = 4, - RETRO_HW_CONTEXT_OPENGLES_VERSION = 5, - - RETRO_HW_CONTEXT_DUMMY = Int32.MaxValue - }; - - public struct retro_hw_render_callback - { - public uint context_type; //retro_hw_context_type - public IntPtr context_reset; //retro_hw_context_reset_t - public IntPtr get_current_framebuffer; //retro_hw_get_current_framebuffer_t - public IntPtr get_proc_address; //retro_hw_get_proc_address_t - [MarshalAs(UnmanagedType.U1)] public byte depth; - [MarshalAs(UnmanagedType.U1)] public bool stencil; - [MarshalAs(UnmanagedType.U1)] public bool bottom_left_origin; - public uint version_major; - public uint version_minor; - [MarshalAs(UnmanagedType.U1)] public bool cache_context; - public IntPtr context_destroy; //retro_hw_context_reset_t - [MarshalAs(UnmanagedType.U1)] public bool debug_context; - }; - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate long retro_hw_context_reset_t(); - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate IntPtr retro_hw_get_current_framebuffer_t(); - - //not used - //[UnmanagedFunctionPointer(CallingConvention.Cdecl)] - //public delegate void retro_proc_address_t(); - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate IntPtr retro_hw_get_proc_address_t(string sym); - - struct retro_memory_map - { - public IntPtr descriptors; //retro_memory_descriptor * - public uint num_descriptors; - }; - - struct retro_memory_descriptor - { - ulong flags; - IntPtr ptr; - IntPtr offset; //size_t - IntPtr start; //size_t - IntPtr select; //size_t - IntPtr disconnect; //size_t - IntPtr len; //size_t - string addrspace; - }; - - public enum RETRO_PIXEL_FORMAT - { - XRGB1555 = 0, - XRGB8888 = 1, - RGB565 = 2 - }; - - public struct retro_message - { - public string msg; - public uint frames; - } - - public struct retro_input_descriptor - { - public uint port; - public uint device; - public uint index; - public uint id; - } - - public struct retro_system_info - { - public string library_name; - public string library_version; - public string valid_extensions; - [MarshalAs(UnmanagedType.U1)] - public bool need_fullpath; - [MarshalAs(UnmanagedType.U1)] - public bool block_extract; - } - - public struct retro_game_geometry - { - public uint base_width; - public uint base_height; - public uint max_width; - public uint max_height; - public float aspect_ratio; - } - - public struct retro_system_timing - { - public double fps; - public double sample_rate; - } - - public struct retro_system_av_info - { - public retro_game_geometry geometry; - public retro_system_timing timing; - } - - public struct retro_variable - { - public string key; - public string value; - } - - public struct retro_game_info - { - public string path; - public IntPtr data; - public uint size; - public string meta; - } - - //untested - public struct retro_perf_counter - { - public string ident; - public ulong start; - public ulong total; - public ulong call_cnt; - - [MarshalAs(UnmanagedType.U1)] - public bool registered; - }; - - //perf callbacks - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate long retro_perf_get_time_usec_t(); - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate long retro_perf_get_counter_t(); - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate ulong retro_get_cpu_features_t(); - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate void retro_perf_log_t(); - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate void retro_perf_register_t(ref retro_perf_counter counter); - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate void retro_perf_start_t(ref retro_perf_counter counter); - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate void retro_perf_stop_t(ref retro_perf_counter counter); - - //for GET_PERF_INTERFACE - public struct retro_perf_callback - { - public retro_perf_get_time_usec_t get_time_usec; - public retro_get_cpu_features_t get_cpu_features; - public retro_perf_get_counter_t get_perf_counter; - public retro_perf_register_t perf_register; - public retro_perf_start_t perf_start; - public retro_perf_stop_t perf_stop; - public retro_perf_log_t perf_log; - } - - #region callback prototypes - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public unsafe delegate void retro_log_printf_t(RETRO_LOG_LEVEL level, string fmt, IntPtr a0, IntPtr a1, IntPtr a2, IntPtr a3, IntPtr a4, IntPtr a5, IntPtr a6, IntPtr a7, IntPtr a8, IntPtr a9, IntPtr a10, IntPtr a11, IntPtr a12, IntPtr a13, IntPtr a14, IntPtr a15); - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - [return:MarshalAs(UnmanagedType.U1)] - public delegate bool retro_environment_t(RETRO_ENVIRONMENT cmd, IntPtr data); - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate void retro_video_refresh_t(IntPtr data, uint width, uint height, uint pitch); - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate void retro_audio_sample_t(short left, short right); - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate uint retro_audio_sample_batch_t(IntPtr data, uint frames); - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate void retro_input_poll_t(); - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate short retro_input_state_t(uint port, uint device, uint index, uint id); - #endregion - - #region entry point prototypes - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate void epretro_set_environment(retro_environment_t cb); - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate void epretro_set_video_refresh(retro_video_refresh_t cb); - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate void epretro_set_audio_sample(retro_audio_sample_t cb); - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate void epretro_set_audio_sample_batch(retro_audio_sample_batch_t cb); - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate void epretro_set_input_poll(retro_input_poll_t cb); - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate void epretro_set_input_state(retro_input_state_t cb); - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate void epretro_init(); - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate void epretro_deinit(); - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate uint epretro_api_version(); - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate void epretro_get_system_info(ref retro_system_info info); - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate void epretro_get_system_av_info(ref retro_system_av_info info); - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate void epretro_set_controller_port_device(uint port, uint device); - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate void epretro_reset(); - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate void epretro_run(); - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate uint epretro_serialize_size(); - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - [return: MarshalAs(UnmanagedType.U1)] - public delegate bool epretro_serialize(IntPtr data, uint size); - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - [return: MarshalAs(UnmanagedType.U1)] - public delegate bool epretro_unserialize(IntPtr data, uint size); - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate void epretro_cheat_reset(); - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate void epretro_cheat_set(uint index, [MarshalAs(UnmanagedType.U1)]bool enabled, string code); - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - [return: MarshalAs(UnmanagedType.U1)] - public delegate bool epretro_load_game(ref retro_game_info game); - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - [return: MarshalAs(UnmanagedType.U1)] - public delegate bool epretro_load_game_special(uint game_type, ref retro_game_info info, uint num_info); - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate void epretro_unload_game(); - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate uint epretro_get_region(); - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate IntPtr epretro_get_memory_data(RETRO_MEMORY id); - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate uint epretro_get_memory_size(RETRO_MEMORY id); - #endregion - - #region entry points - // these are all hooked up by reflection on dll load - public epretro_set_environment retro_set_environment; - public epretro_set_video_refresh retro_set_video_refresh; - public epretro_set_audio_sample retro_set_audio_sample; - public epretro_set_audio_sample_batch retro_set_audio_sample_batch; - public epretro_set_input_poll retro_set_input_poll; - public epretro_set_input_state retro_set_input_state; - public epretro_init retro_init; - /// - /// Dispose() calls this, so you shouldn't - /// - public epretro_deinit retro_deinit; - public epretro_api_version retro_api_version; - public epretro_get_system_info retro_get_system_info; - public epretro_get_system_av_info retro_get_system_av_info; - public epretro_set_controller_port_device retro_set_controller_port_device; - public epretro_reset retro_reset; - public epretro_run retro_run; - public epretro_serialize_size retro_serialize_size; - public epretro_serialize retro_serialize; - public epretro_unserialize retro_unserialize; - public epretro_cheat_reset retro_cheat_reset; - public epretro_cheat_set retro_cheat_set; - public epretro_load_game retro_load_game; - public epretro_load_game_special retro_load_game_special; - public epretro_unload_game retro_unload_game; - public epretro_get_region retro_get_region; - public epretro_get_memory_data retro_get_memory_data; - public epretro_get_memory_size retro_get_memory_size; - #endregion - - public void Dispose() - { - dll.Dispose(); - } - - InstanceDll dll; - public LibRetro(string modulename) - { - dll = new InstanceDll(modulename); - if (!ConnectAllEntryPoints()) - { - dll.Dispose(); - throw new Exception("ConnectAllEntryPoints() failed. The console may contain more details."); - } - } - - private static IEnumerable GetAllEntryPoints() - { - return typeof(LibRetro).GetFields().Where((field) => field.FieldType.Name.StartsWith("epretro")); - } - - private void ClearAllEntryPoints() - { - foreach (var field in GetAllEntryPoints()) - { - field.SetValue(this, null); - } - } - - private bool ConnectAllEntryPoints() - { - bool succeed = true; - foreach (var field in GetAllEntryPoints()) - { - string fieldname = field.Name; - IntPtr entry = dll.GetProcAddress(fieldname); - if (entry != IntPtr.Zero) - { - field.SetValue(this, Marshal.GetDelegateForFunctionPointer(entry, field.FieldType)); - } - else - { - Console.WriteLine("Couldn't bind libretro entry point {0}", fieldname); - succeed = false; - } - } - return succeed; - } - } -} diff --git a/BizHawk.Emulation.Cores/LibretroOld/LibRetroEmulator.InputCallbacks.cs b/BizHawk.Emulation.Cores/LibretroOld/LibRetroEmulator.InputCallbacks.cs deleted file mode 100644 index fea7e41271..0000000000 --- a/BizHawk.Emulation.Cores/LibretroOld/LibRetroEmulator.InputCallbacks.cs +++ /dev/null @@ -1,219 +0,0 @@ -using System; -using System.IO; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Runtime.InteropServices; -using Newtonsoft.Json; - -using BizHawk.Common; -using BizHawk.Emulation.Common; -using BizHawk.Common.BufferExtensions; - -namespace BizHawk.Emulation.Cores -{ - partial class LibRetroEmulator - { - //meanings (they are kind of hazy, but once we're done implementing this it will be completely defined by example) - //port = console physical port? - //device = logical device type - //index = sub device index? (multitap?) - //id = button id (or key id) - short retro_input_state(uint port, uint device, uint index, uint id) - { - //helpful debugging - //Console.WriteLine("{0} {1} {2} {3}", port, device, index, id); - - switch ((LibRetro.RETRO_DEVICE)device) - { - case LibRetro.RETRO_DEVICE.POINTER: - { - switch ((LibRetro.RETRO_DEVICE_ID_POINTER)id) - { - case LibRetro.RETRO_DEVICE_ID_POINTER.X: return (short)Controller.GetFloat("Pointer X"); - case LibRetro.RETRO_DEVICE_ID_POINTER.Y: return (short)Controller.GetFloat("Pointer Y"); - case LibRetro.RETRO_DEVICE_ID_POINTER.PRESSED: return (short)(Controller.IsPressed("Pointer Pressed") ? 1 : 0); - } - return 0; - } - - case LibRetro.RETRO_DEVICE.KEYBOARD: - { - string button = ""; - switch ((LibRetro.RETRO_KEY)id) - { - case LibRetro.RETRO_KEY.BACKSPACE: button = "Backspace"; break; - case LibRetro.RETRO_KEY.TAB: button = "Tab"; break; - case LibRetro.RETRO_KEY.CLEAR: button = "Clear"; break; - case LibRetro.RETRO_KEY.RETURN: button = "Return"; break; - case LibRetro.RETRO_KEY.PAUSE: button = "Pause"; break; - case LibRetro.RETRO_KEY.ESCAPE: button = "Escape"; break; - case LibRetro.RETRO_KEY.SPACE: button = "Space"; break; - case LibRetro.RETRO_KEY.EXCLAIM: button = "Exclaim"; break; - case LibRetro.RETRO_KEY.QUOTEDBL: button = "QuoteDbl"; break; - case LibRetro.RETRO_KEY.HASH: button = "Hash"; break; - case LibRetro.RETRO_KEY.DOLLAR: button = "Dollar"; break; - case LibRetro.RETRO_KEY.AMPERSAND: button = "Ampersand"; break; - case LibRetro.RETRO_KEY.QUOTE: button = "Quote"; break; - case LibRetro.RETRO_KEY.LEFTPAREN: button = "LeftParen"; break; - case LibRetro.RETRO_KEY.RIGHTPAREN: button = "RightParen"; break; - case LibRetro.RETRO_KEY.ASTERISK: button = "Asterisk"; break; - case LibRetro.RETRO_KEY.PLUS: button = "Plus"; break; - case LibRetro.RETRO_KEY.COMMA: button = "Comma"; break; - case LibRetro.RETRO_KEY.MINUS: button = "Minus"; break; - case LibRetro.RETRO_KEY.PERIOD: button = "Period"; break; - case LibRetro.RETRO_KEY.SLASH: button = "Slash"; break; - case LibRetro.RETRO_KEY._0: button = "0"; break; - case LibRetro.RETRO_KEY._1: button = "1"; break; - case LibRetro.RETRO_KEY._2: button = "2"; break; - case LibRetro.RETRO_KEY._3: button = "3"; break; - case LibRetro.RETRO_KEY._4: button = "4"; break; - case LibRetro.RETRO_KEY._5: button = "5"; break; - case LibRetro.RETRO_KEY._6: button = "6"; break; - case LibRetro.RETRO_KEY._7: button = "7"; break; - case LibRetro.RETRO_KEY._8: button = "8"; break; - case LibRetro.RETRO_KEY._9: button = "9"; break; - case LibRetro.RETRO_KEY.COLON: button = "Colon"; break; - case LibRetro.RETRO_KEY.SEMICOLON: button = "Semicolon"; break; - case LibRetro.RETRO_KEY.LESS: button = "Less"; break; - case LibRetro.RETRO_KEY.EQUALS: button = "Equals"; break; - case LibRetro.RETRO_KEY.GREATER: button = "Greater"; break; - case LibRetro.RETRO_KEY.QUESTION: button = "Question"; break; - case LibRetro.RETRO_KEY.AT: button = "At"; break; - case LibRetro.RETRO_KEY.LEFTBRACKET: button = "LeftBracket"; break; - case LibRetro.RETRO_KEY.BACKSLASH: button = "Backslash"; break; - case LibRetro.RETRO_KEY.RIGHTBRACKET: button = "RightBracket"; break; - case LibRetro.RETRO_KEY.CARET: button = "Caret"; break; - case LibRetro.RETRO_KEY.UNDERSCORE: button = "Underscore"; break; - case LibRetro.RETRO_KEY.BACKQUOTE: button = "Backquote"; break; - case LibRetro.RETRO_KEY.a: button = "A"; break; - case LibRetro.RETRO_KEY.b: button = "B"; break; - case LibRetro.RETRO_KEY.c: button = "C"; break; - case LibRetro.RETRO_KEY.d: button = "D"; break; - case LibRetro.RETRO_KEY.e: button = "E"; break; - case LibRetro.RETRO_KEY.f: button = "F"; break; - case LibRetro.RETRO_KEY.g: button = "G"; break; - case LibRetro.RETRO_KEY.h: button = "H"; break; - case LibRetro.RETRO_KEY.i: button = "I"; break; - case LibRetro.RETRO_KEY.j: button = "J"; break; - case LibRetro.RETRO_KEY.k: button = "K"; break; - case LibRetro.RETRO_KEY.l: button = "L"; break; - case LibRetro.RETRO_KEY.m: button = "M"; break; - case LibRetro.RETRO_KEY.n: button = "N"; break; - case LibRetro.RETRO_KEY.o: button = "O"; break; - case LibRetro.RETRO_KEY.p: button = "P"; break; - case LibRetro.RETRO_KEY.q: button = "Q"; break; - case LibRetro.RETRO_KEY.r: button = "R"; break; - case LibRetro.RETRO_KEY.s: button = "S"; break; - case LibRetro.RETRO_KEY.t: button = "T"; break; - case LibRetro.RETRO_KEY.u: button = "U"; break; - case LibRetro.RETRO_KEY.v: button = "V"; break; - case LibRetro.RETRO_KEY.w: button = "W"; break; - case LibRetro.RETRO_KEY.x: button = "X"; break; - case LibRetro.RETRO_KEY.y: button = "Y"; break; - case LibRetro.RETRO_KEY.z: button = "Z"; break; - case LibRetro.RETRO_KEY.DELETE: button = "Delete"; break; - - case LibRetro.RETRO_KEY.KP0: button = "KP0"; break; - case LibRetro.RETRO_KEY.KP1: button = "KP1"; break; - case LibRetro.RETRO_KEY.KP2: button = "KP2"; break; - case LibRetro.RETRO_KEY.KP3: button = "KP3"; break; - case LibRetro.RETRO_KEY.KP4: button = "KP4"; break; - case LibRetro.RETRO_KEY.KP5: button = "KP5"; break; - case LibRetro.RETRO_KEY.KP6: button = "KP6"; break; - case LibRetro.RETRO_KEY.KP7: button = "KP7"; break; - case LibRetro.RETRO_KEY.KP8: button = "KP8"; break; - case LibRetro.RETRO_KEY.KP9: button = "KP9"; break; - case LibRetro.RETRO_KEY.KP_PERIOD: button = "KP_Period"; break; - case LibRetro.RETRO_KEY.KP_DIVIDE: button = "KP_Divide"; break; - case LibRetro.RETRO_KEY.KP_MULTIPLY: button = "KP_Multiply"; break; - case LibRetro.RETRO_KEY.KP_MINUS: button = "KP_Minus"; break; - case LibRetro.RETRO_KEY.KP_PLUS: button = "KP_Plus"; break; - case LibRetro.RETRO_KEY.KP_ENTER: button = "KP_Enter"; break; - case LibRetro.RETRO_KEY.KP_EQUALS: button = "KP_Equals"; break; - - case LibRetro.RETRO_KEY.UP: button = "Up"; break; - case LibRetro.RETRO_KEY.DOWN: button = "Down"; break; - case LibRetro.RETRO_KEY.RIGHT: button = "Right"; break; - case LibRetro.RETRO_KEY.LEFT: button = "Left"; break; - case LibRetro.RETRO_KEY.INSERT: button = "Insert"; break; - case LibRetro.RETRO_KEY.HOME: button = "Home"; break; - case LibRetro.RETRO_KEY.END: button = "End"; break; - case LibRetro.RETRO_KEY.PAGEUP: button = "PageUp"; break; - case LibRetro.RETRO_KEY.PAGEDOWN: button = "PageDown"; break; - - case LibRetro.RETRO_KEY.F1: button = "F1"; break; - case LibRetro.RETRO_KEY.F2: button = "F2"; break; - case LibRetro.RETRO_KEY.F3: button = "F3"; break; - case LibRetro.RETRO_KEY.F4: button = "F4"; break; - case LibRetro.RETRO_KEY.F5: button = "F5"; break; - case LibRetro.RETRO_KEY.F6: button = "F6"; break; - case LibRetro.RETRO_KEY.F7: button = "F7"; break; - case LibRetro.RETRO_KEY.F8: button = "F8"; break; - case LibRetro.RETRO_KEY.F9: button = "F9"; break; - case LibRetro.RETRO_KEY.F10: button = "F10"; break; - case LibRetro.RETRO_KEY.F11: button = "F11"; break; - case LibRetro.RETRO_KEY.F12: button = "F12"; break; - case LibRetro.RETRO_KEY.F13: button = "F13"; break; - case LibRetro.RETRO_KEY.F14: button = "F14"; break; - case LibRetro.RETRO_KEY.F15: button = "F15"; break; - - case LibRetro.RETRO_KEY.NUMLOCK: button = "NumLock"; break; - case LibRetro.RETRO_KEY.CAPSLOCK: button = "CapsLock"; break; - case LibRetro.RETRO_KEY.SCROLLOCK: button = "ScrollLock"; break; - case LibRetro.RETRO_KEY.RSHIFT: button = "RShift"; break; - case LibRetro.RETRO_KEY.LSHIFT: button = "LShift"; break; - case LibRetro.RETRO_KEY.RCTRL: button = "RCtrl"; break; - case LibRetro.RETRO_KEY.LCTRL: button = "LCtrl"; break; - case LibRetro.RETRO_KEY.RALT: button = "RAlt"; break; - case LibRetro.RETRO_KEY.LALT: button = "LAlt"; break; - case LibRetro.RETRO_KEY.RMETA: button = "RMeta"; break; - case LibRetro.RETRO_KEY.LMETA: button = "LMeta"; break; - case LibRetro.RETRO_KEY.LSUPER: button = "LSuper"; break; - case LibRetro.RETRO_KEY.RSUPER: button = "RSuper"; break; - case LibRetro.RETRO_KEY.MODE: button = "Mode"; break; - case LibRetro.RETRO_KEY.COMPOSE: button = "Compose"; break; - - case LibRetro.RETRO_KEY.HELP: button = "Help"; break; - case LibRetro.RETRO_KEY.PRINT: button = "Print"; break; - case LibRetro.RETRO_KEY.SYSREQ: button = "SysReq"; break; - case LibRetro.RETRO_KEY.BREAK: button = "Break"; break; - case LibRetro.RETRO_KEY.MENU: button = "Menu"; break; - case LibRetro.RETRO_KEY.POWER: button = "Power"; break; - case LibRetro.RETRO_KEY.EURO: button = "Euro"; break; - case LibRetro.RETRO_KEY.UNDO: button = "Undo"; break; - } - - return (short)(Controller.IsPressed("Key " + button) ? 1 : 0); - } - - case LibRetro.RETRO_DEVICE.JOYPAD: - { - //The JOYPAD is sometimes called RetroPad (and we'll call it that in user-facing stuff cos retroarch does) - //It is essentially a Super Nintendo controller, but with additional L2/R2/L3/R3 buttons, similar to a PS1 DualShock. - - string button = ""; - switch ((LibRetro.RETRO_DEVICE_ID_JOYPAD)id) - { - case LibRetro.RETRO_DEVICE_ID_JOYPAD.A: button = "A"; break; - case LibRetro.RETRO_DEVICE_ID_JOYPAD.B: button = "B"; break; - case LibRetro.RETRO_DEVICE_ID_JOYPAD.X: button = "X"; break; - case LibRetro.RETRO_DEVICE_ID_JOYPAD.Y: button = "Y"; break; - case LibRetro.RETRO_DEVICE_ID_JOYPAD.UP: button = "Up"; break; - case LibRetro.RETRO_DEVICE_ID_JOYPAD.DOWN: button = "Down"; break; - case LibRetro.RETRO_DEVICE_ID_JOYPAD.LEFT: button = "Left"; break; - case LibRetro.RETRO_DEVICE_ID_JOYPAD.RIGHT: button = "Right"; break; - case LibRetro.RETRO_DEVICE_ID_JOYPAD.L: button = "L"; break; - case LibRetro.RETRO_DEVICE_ID_JOYPAD.R: button = "R"; break; - case LibRetro.RETRO_DEVICE_ID_JOYPAD.SELECT: button = "Select"; break; - case LibRetro.RETRO_DEVICE_ID_JOYPAD.START: button = "Start"; break; - } - - return (short)(GetButton(port+1, "RetroPad", button) ? 1 : 0); - } - default: - return 0; - } - } - } -} diff --git a/BizHawk.Emulation.Cores/LibretroOld/LibRetroEmulator.cs b/BizHawk.Emulation.Cores/LibretroOld/LibRetroEmulator.cs deleted file mode 100644 index f82d748423..0000000000 --- a/BizHawk.Emulation.Cores/LibretroOld/LibRetroEmulator.cs +++ /dev/null @@ -1,954 +0,0 @@ -using System; -using System.IO; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Runtime.InteropServices; -using Newtonsoft.Json; - -using BizHawk.Common; -using BizHawk.Emulation.Common; -using BizHawk.Common.BufferExtensions; - -namespace BizHawk.Emulation.Cores -{ - [CoreAttributes("Libretro", "natt&zeromus")] - public unsafe partial class LibRetroEmulator : IEmulator, ISettable, - ISaveRam, IStatable, IVideoProvider, IInputPollable - { - #region Settings - - Settings _Settings = new Settings(); - SyncSettings _SyncSettings; - - public class SyncSettings - { - public SyncSettings Clone() - { - return JsonConvert.DeserializeObject(JsonConvert.SerializeObject(this)); - } - - public SyncSettings() - { - } - } - - - public class Settings - { - public void Validate() - { - } - - public Settings() - { - SettingsUtil.SetDefaultValues(this); - } - - public Settings Clone() - { - return (Settings)MemberwiseClone(); - } - } - - public Settings GetSettings() - { - return _Settings.Clone(); - } - - public SyncSettings GetSyncSettings() - { - return _SyncSettings.Clone(); - } - - public bool PutSettings(Settings o) - { - _Settings.Validate(); - _Settings = o; - - //TODO - store settings into core? or we can just keep doing it before frameadvance - - return false; - } - - public bool PutSyncSettings(SyncSettings o) - { - bool reboot = false; - - //we could do it this way roughly if we need to - //if(JsonConvert.SerializeObject(o.FIOConfig) != JsonConvert.SerializeObject(_SyncSettings.FIOConfig) - - _SyncSettings = o; - - return reboot; - } - - #endregion - - #region callbacks - - unsafe void retro_log_printf(LibRetro.RETRO_LOG_LEVEL level, string fmt, IntPtr a0, IntPtr a1, IntPtr a2, IntPtr a3, IntPtr a4, IntPtr a5, IntPtr a6, IntPtr a7, IntPtr a8, IntPtr a9, IntPtr a10, IntPtr a11, IntPtr a12, IntPtr a13, IntPtr a14, IntPtr a15) - { - //avert your eyes, these things were not meant to be seen in c# - //I'm not sure this is a great idea. It would suck for silly logging to be unstable. But.. I dont think this is unstable. The sprintf might just print some garbledy stuff. - var args = new IntPtr[] { a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15 }; - int idx = 0; - Console.Write(Sprintf.sprintf(fmt, () => args[idx++])); - } - - unsafe bool retro_environment(LibRetro.RETRO_ENVIRONMENT cmd, IntPtr data) - { - Console.WriteLine(cmd); - switch (cmd) - { - case LibRetro.RETRO_ENVIRONMENT.SET_ROTATION: - { - var rotation = (LibRetro.RETRO_ROTATION)(*(int*)data.ToPointer()); - if (rotation == LibRetro.RETRO_ROTATION.ROTATION_0_CCW) environmentInfo.Rotation_CCW = 0; - if (rotation == LibRetro.RETRO_ROTATION.ROTATION_90_CCW) environmentInfo.Rotation_CCW = 90; - if (rotation == LibRetro.RETRO_ROTATION.ROTATION_180_CCW) environmentInfo.Rotation_CCW = 180; - if (rotation == LibRetro.RETRO_ROTATION.ROTATION_270_CCW) environmentInfo.Rotation_CCW = 270; - return true; - } - case LibRetro.RETRO_ENVIRONMENT.GET_OVERSCAN: - return false; - case LibRetro.RETRO_ENVIRONMENT.GET_CAN_DUPE: - //gambatte requires this - *(bool*)data.ToPointer() = true; - return true; - case LibRetro.RETRO_ENVIRONMENT.SET_MESSAGE: - { - LibRetro.retro_message msg = new LibRetro.retro_message(); - Marshal.PtrToStructure(data, msg); - if (!string.IsNullOrEmpty(msg.msg)) - Console.WriteLine("LibRetro Message: {0}", msg.msg); - return true; - } - case LibRetro.RETRO_ENVIRONMENT.SHUTDOWN: - return false; - case LibRetro.RETRO_ENVIRONMENT.SET_PERFORMANCE_LEVEL: - Console.WriteLine("Core suggested SET_PERFORMANCE_LEVEL {0}", *(uint*)data.ToPointer()); - return true; - case LibRetro.RETRO_ENVIRONMENT.GET_SYSTEM_DIRECTORY: - //mednafen NGP neopop fails to launch with no system directory - Directory.CreateDirectory(SystemDirectory); //just to be safe, it seems likely that cores will crash without a created system directory - Console.WriteLine("returning system directory: " + SystemDirectory); - *((IntPtr*)data.ToPointer()) = SystemDirectoryAtom; - return true; - case LibRetro.RETRO_ENVIRONMENT.SET_PIXEL_FORMAT: - { - LibRetro.RETRO_PIXEL_FORMAT fmt = 0; - int[] tmp = new int[1]; - Marshal.Copy(data, tmp, 0, 1); - fmt = (LibRetro.RETRO_PIXEL_FORMAT)tmp[0]; - switch (fmt) - { - case LibRetro.RETRO_PIXEL_FORMAT.RGB565: - case LibRetro.RETRO_PIXEL_FORMAT.XRGB1555: - case LibRetro.RETRO_PIXEL_FORMAT.XRGB8888: - pixelfmt = fmt; - Console.WriteLine("New pixel format set: {0}", pixelfmt); - return true; - default: - Console.WriteLine("Unrecognized pixel format: {0}", (int)pixelfmt); - return false; - } - } - case LibRetro.RETRO_ENVIRONMENT.SET_INPUT_DESCRIPTORS: - return false; - case LibRetro.RETRO_ENVIRONMENT.SET_KEYBOARD_CALLBACK: - return false; - case LibRetro.RETRO_ENVIRONMENT.SET_DISK_CONTROL_INTERFACE: - return false; - case LibRetro.RETRO_ENVIRONMENT.SET_HW_RENDER: - { - //mupen64plus needs this, as well as 3dengine - LibRetro.retro_hw_render_callback* info = (LibRetro.retro_hw_render_callback*)data.ToPointer(); - Console.WriteLine("SET_HW_RENDER: {0}, version={1}.{2}, dbg/cache={3}/{4}, depth/stencil = {5}/{6}{7}", info->context_type, info->version_minor, info->version_major, info->debug_context, info->cache_context, info->depth, info->stencil, info->bottom_left_origin ? " (bottomleft)" : ""); - return true; - } - case LibRetro.RETRO_ENVIRONMENT.GET_VARIABLE: - { - void** variables = (void**)data.ToPointer(); - IntPtr pKey = new IntPtr(*variables++); - string key = Marshal.PtrToStringAnsi(pKey); - Console.WriteLine("Requesting variable: {0}", key); - //always return default - //TODO: cache settings atoms - if(!Description.Variables.ContainsKey(key)) - return false; - //HACK: return pointer for desmume mouse, i want to implement that first - if (key == "desmume_pointer_type") - { - *variables = unmanagedResources.StringToHGlobalAnsi("touch").ToPointer(); - return true; - } - *variables = unmanagedResources.StringToHGlobalAnsi(Description.Variables[key].DefaultOption).ToPointer(); - return true; - } - case LibRetro.RETRO_ENVIRONMENT.SET_VARIABLES: - { - void** variables = (void**)data.ToPointer(); - for (; ; ) - { - IntPtr pKey = new IntPtr(*variables++); - IntPtr pValue = new IntPtr(*variables++); - if(pKey == IntPtr.Zero) - break; - string key = Marshal.PtrToStringAnsi(pKey); - string value = Marshal.PtrToStringAnsi(pValue); - var vd = new VariableDescription() { Name = key}; - var parts = value.Split(';'); - vd.Description = parts[0]; - vd.Options = parts[1].TrimStart(' ').Split('|'); - Description.Variables[vd.Name] = vd; - } - } - return false; - case LibRetro.RETRO_ENVIRONMENT.GET_VARIABLE_UPDATE: - return false; - case LibRetro.RETRO_ENVIRONMENT.SET_SUPPORT_NO_GAME: - environmentInfo.SupportNoGame = true; - return false; - case LibRetro.RETRO_ENVIRONMENT.GET_LIBRETRO_PATH: - return false; - case LibRetro.RETRO_ENVIRONMENT.SET_AUDIO_CALLBACK: - return false; - case LibRetro.RETRO_ENVIRONMENT.SET_FRAME_TIME_CALLBACK: - return false; - case LibRetro.RETRO_ENVIRONMENT.GET_RUMBLE_INTERFACE: - return false; - case LibRetro.RETRO_ENVIRONMENT.GET_INPUT_DEVICE_CAPABILITIES: - return false; - case LibRetro.RETRO_ENVIRONMENT.GET_LOG_INTERFACE: - *(IntPtr*)data = Marshal.GetFunctionPointerForDelegate(retro_log_printf_cb); - return true; - case LibRetro.RETRO_ENVIRONMENT.GET_PERF_INTERFACE: - //some builds of fmsx core crash without this set - Marshal.StructureToPtr(retro_perf_callback, data, false); - return true; - case LibRetro.RETRO_ENVIRONMENT.GET_LOCATION_INTERFACE: - return false; - case LibRetro.RETRO_ENVIRONMENT.GET_CORE_ASSETS_DIRECTORY: - return false; - case LibRetro.RETRO_ENVIRONMENT.GET_SAVE_DIRECTORY: - //supposedly optional like everything else here, but without it ?? crashes (please write which case) - //this will suffice for now. if we find evidence later it's needed we can stash a string with - //unmanagedResources and CoreFileProvider - //mednafen NGP neopop, desmume, and others, request this, and falls back on the system directory if it isn't provided - //desmume crashes if the directory doesn't exist - Directory.CreateDirectory(SaveDirectory); - Console.WriteLine("returning save directory: " + SaveDirectory); - *((IntPtr*)data.ToPointer()) = SaveDirectoryAtom; - return true; - case LibRetro.RETRO_ENVIRONMENT.SET_CONTROLLER_INFO: - return true; - case LibRetro.RETRO_ENVIRONMENT.SET_MEMORY_MAPS: - return false; - default: - Console.WriteLine("Unknkown retro_environment command {0}", (int)cmd); - return false; - } - } - void retro_input_poll() - { - IsLagFrame = false; - } - - private bool GetButton(uint pnum, string type, string button) - { - string key = string.Format("P{0} {1} {2}", pnum, type, button); - bool b = Controller.IsPressed(key); - if (b == true) - { - return true; //debugging placeholder - } - else return false; - } - - LibRetro.retro_environment_t retro_environment_cb; - LibRetro.retro_video_refresh_t retro_video_refresh_cb; - LibRetro.retro_audio_sample_t retro_audio_sample_cb; - LibRetro.retro_audio_sample_batch_t retro_audio_sample_batch_cb; - LibRetro.retro_input_poll_t retro_input_poll_cb; - LibRetro.retro_input_state_t retro_input_state_cb; - LibRetro.retro_log_printf_t retro_log_printf_cb; - - LibRetro.retro_perf_callback retro_perf_callback = new LibRetro.retro_perf_callback(); - - #endregion - - class RetroEnvironmentInfo - { - public bool SupportNoGame; - public int Rotation_CCW; - } - - //disposable resources - private LibRetro retro; - private UnmanagedResourceHeap unmanagedResources = new UnmanagedResourceHeap(); - - /// - /// Cached information sent to the frontend by environment calls - /// - RetroEnvironmentInfo environmentInfo = new RetroEnvironmentInfo(); - - public class RetroDescription - { - /// - /// String containing a friendly display name for the core, but we probably shouldn't use this. I decided it's better to get the user used to using filenames as core 'codenames' instead. - /// - public string LibraryName; - - /// - /// String containing a friendly version number for the core library - /// - public string LibraryVersion; - - /// - /// List of extensions as "sfc|smc|fig" which this core accepts. - /// - public string ValidExtensions; - - /// - /// Whether the core needs roms to be specified as paths (can't take rom data buffersS) - /// - public bool NeedsRomAsPath; - - /// - /// Whether the core needs roms stored as archives (e.g. arcade roms). We probably shouldn't employ the dearchiver prompts when opening roms for these cores. - /// - public bool NeedsArchives; - - /// - /// Whether the core can be run without a game provided (e.g. stand-alone games, like 2048) - /// - public bool SupportsNoGame; - - /// - /// Variables defined by the core - /// - public Dictionary Variables = new Dictionary(); - } - - public class VariableDescription - { - public string Name; - public string Description; - public string[] Options; - public string DefaultOption { get { return Options[0]; } } - - public override string ToString() - { - return string.Format("{0} ({1}) = ({2})", Name, Description, string.Join("|", Options)); - } - } - - public readonly RetroDescription Description = new RetroDescription(); - - //path configuration - string SystemDirectory, SaveDirectory; - IntPtr SystemDirectoryAtom, SaveDirectoryAtom; - - public LibRetroEmulator(CoreComm nextComm, string modulename) - { - ServiceProvider = new BasicServiceProvider(this); - - _SyncSettings = new SyncSettings(); - - retro_environment_cb = new LibRetro.retro_environment_t(retro_environment); - retro_video_refresh_cb = new LibRetro.retro_video_refresh_t(retro_video_refresh); - retro_audio_sample_cb = new LibRetro.retro_audio_sample_t(retro_audio_sample); - retro_audio_sample_batch_cb = new LibRetro.retro_audio_sample_batch_t(retro_audio_sample_batch); - retro_input_poll_cb = new LibRetro.retro_input_poll_t(retro_input_poll); - retro_input_state_cb = new LibRetro.retro_input_state_t(retro_input_state); - retro_log_printf_cb = new LibRetro.retro_log_printf_t(retro_log_printf); - - //no way (need new mechanism) to check for SSSE3, MMXEXT, SSE4, SSE42 - retro_perf_callback.get_cpu_features = new LibRetro.retro_get_cpu_features_t(() => (ulong)( - (Win32PInvokes.IsProcessorFeaturePresent(Win32PInvokes.ProcessorFeature.InstructionsXMMIAvailable) ? LibRetro.RETRO_SIMD.SSE : 0) | - (Win32PInvokes.IsProcessorFeaturePresent(Win32PInvokes.ProcessorFeature.InstructionsXMMI64Available) ? LibRetro.RETRO_SIMD.SSE2 : 0) | - (Win32PInvokes.IsProcessorFeaturePresent(Win32PInvokes.ProcessorFeature.InstructionsSSE3Available) ? LibRetro.RETRO_SIMD.SSE3 : 0) | - (Win32PInvokes.IsProcessorFeaturePresent(Win32PInvokes.ProcessorFeature.InstructionsMMXAvailable) ? LibRetro.RETRO_SIMD.MMX : 0) - ) ); - retro_perf_callback.get_perf_counter = new LibRetro.retro_perf_get_counter_t(() => System.Diagnostics.Stopwatch.GetTimestamp()); - retro_perf_callback.get_time_usec = new LibRetro.retro_perf_get_time_usec_t(() => DateTime.Now.Ticks / 10); - retro_perf_callback.perf_log = new LibRetro.retro_perf_log_t( () => {} ); - retro_perf_callback.perf_register = new LibRetro.retro_perf_register_t((ref LibRetro.retro_perf_counter counter) => { }); - retro_perf_callback.perf_start = new LibRetro.retro_perf_start_t((ref LibRetro.retro_perf_counter counter) => { }); - retro_perf_callback.perf_stop = new LibRetro.retro_perf_stop_t((ref LibRetro.retro_perf_counter counter) => { }); - - retro = new LibRetro(modulename); - - try - { - CoreComm = nextComm; - - //this series of steps may be mystical. - LibRetro.retro_system_info system_info = new LibRetro.retro_system_info(); - retro.retro_get_system_info(ref system_info); - - //the dosbox core calls GET_SYSTEM_DIRECTORY and GET_SAVE_DIRECTORY from retro_set_environment. - //so, lets set some temporary values (which we'll replace) - SystemDirectory = Path.GetDirectoryName(modulename); - SystemDirectoryAtom = unmanagedResources.StringToHGlobalAnsi(SystemDirectory); - SaveDirectory = Path.GetDirectoryName(modulename); - SaveDirectoryAtom = unmanagedResources.StringToHGlobalAnsi(SaveDirectory); - retro.retro_set_environment(retro_environment_cb); - - retro.retro_set_video_refresh(retro_video_refresh_cb); - retro.retro_set_audio_sample(retro_audio_sample_cb); - retro.retro_set_audio_sample_batch(retro_audio_sample_batch_cb); - retro.retro_set_input_poll(retro_input_poll_cb); - retro.retro_set_input_state(retro_input_state_cb); - - //compile descriptive information - Description.NeedsArchives = system_info.block_extract; - Description.NeedsRomAsPath = system_info.need_fullpath; - Description.LibraryName = system_info.library_name; - Description.LibraryVersion = system_info.library_version; - Description.ValidExtensions = system_info.valid_extensions; - Description.SupportsNoGame = environmentInfo.SupportNoGame; - } - catch - { - retro.Dispose(); - retro = null; - throw; - } - - - } - - public IEmulatorServiceProvider ServiceProvider { get; private set; } - - - - public bool LoadData(byte[] data) - { - LibRetro.retro_game_info gi = new LibRetro.retro_game_info(); - fixed (byte* p = &data[0]) - { - gi.data = (IntPtr)p; - gi.meta = ""; - gi.path = ""; - gi.size = (uint)data.Length; - return LoadWork(ref gi); - } - } - - public bool LoadPath(string path) - { - LibRetro.retro_game_info gi = new LibRetro.retro_game_info(); - gi.path = path; //is this the right encoding? seems to be ok - return LoadWork(ref gi); - } - - public bool LoadNoGame() - { - LibRetro.retro_game_info gi = new LibRetro.retro_game_info(); - return LoadWork(ref gi); - } - - bool LoadWork(ref LibRetro.retro_game_info gi) - { - //defer this until loading because during the LibRetroEmulator constructor, we dont have access to the game name and so paths can't be selected - //this cannot be done until set_environment is complete - if (CoreComm.CoreFileProvider == null) - { - SaveDirectory = SystemDirectory = ""; - } - else - { - SystemDirectory = CoreComm.CoreFileProvider.GetRetroSystemPath(); - SaveDirectory = CoreComm.CoreFileProvider.GetRetroSaveRAMDirectory(); - SystemDirectoryAtom = unmanagedResources.StringToHGlobalAnsi(SystemDirectory); - SaveDirectoryAtom = unmanagedResources.StringToHGlobalAnsi(SaveDirectory); - } - - //defer this until loading because it triggers the core to read save and system paths - //if any cores did that from set_environment then i'm assured we can call set_environment again here before retro_init and it should work - //--alcaro says any cores that can't handle that should be considered a bug - //UPDATE: dosbox does that, so lets try it - retro.retro_set_environment(retro_environment_cb); - retro.retro_init(); - - if (!retro.retro_load_game(ref gi)) - { - Console.WriteLine("retro_load_game() failed"); - return false; - } - - //TODO - libretro cores can return a varying serialize size over time. I tried to get them to write it in the docs... - savebuff = new byte[retro.retro_serialize_size()]; - savebuff2 = new byte[savebuff.Length + 13]; - - LibRetro.retro_system_av_info av = new LibRetro.retro_system_av_info(); - retro.retro_get_system_av_info(ref av); - - BufferWidth = (int)av.geometry.base_width; - BufferHeight = (int)av.geometry.base_height; - vidbuff = new int[av.geometry.max_width * av.geometry.max_height]; - dar = av.geometry.aspect_ratio; - - // TODO: more precise - CoreComm.VsyncNum = (int)(10000000 * av.timing.fps); - CoreComm.VsyncDen = 10000000; - - SetupResampler(av.timing.fps, av.timing.sample_rate); - (ServiceProvider as BasicServiceProvider).Register(resampler); - - ControllerDefinition = CreateControllerDefinition(_SyncSettings); - - return true; - } - - public static ControllerDefinition CreateControllerDefinition(SyncSettings syncSettings) - { - ControllerDefinition definition = new ControllerDefinition(); - definition.Name = "LibRetro Controls"; // <-- for compatibility - - foreach(var item in new[] { - "P1 {0} Up", "P1 {0} Down", "P1 {0} Left", "P1 {0} Right", "P1 {0} Select", "P1 {0} Start", "P1 {0} Y", "P1 {0} B", "P1 {0} X", "P1 {0} A", "P1 {0} L", "P1 {0} R", - "P2 {0} Up", "P2 {0} Down", "P2 {0} Left", "P2 {0} Right", "P2 {0} Select", "P2 {0} Start", "P2 {0} Y", "P2 {0} B", "P2 {0} X", "P2 {0} A", "P2 {0} L", "P2 {0} R", - }) - definition.BoolButtons.Add(string.Format(item,"RetroPad")); - - definition.BoolButtons.Add("Pointer Pressed"); //TODO: this isnt showing up in the binding panel. I dont want to find out why. - definition.FloatControls.Add("Pointer X"); - definition.FloatControls.Add("Pointer Y"); - definition.FloatRanges.Add(new ControllerDefinition.FloatRange(-32767, 0, 32767)); - definition.FloatRanges.Add(new ControllerDefinition.FloatRange(-32767, 0, 32767)); - - foreach (var key in new[]{ - "Key Backspace", "Key Tab", "Key Clear", "Key Return", "Key Pause", "Key Escape", - "Key Space", "Key Exclaim", "Key QuoteDbl", "Key Hash", "Key Dollar", "Key Ampersand", "Key Quote", "Key LeftParen", "Key RightParen", "Key Asterisk", "Key Plus", "Key Comma", "Key Minus", "Key Period", "Key Slash", - "Key 0", "Key 1", "Key 2", "Key 3", "Key 4", "Key 5", "Key 6", "Key 7", "Key 8", "Key 9", - "Key Colon", "Key Semicolon", "Key Less", "Key Equals", "Key Greater", "Key Question", "Key At", "Key LeftBracket", "Key Backslash", "Key RightBracket", "Key Caret", "Key Underscore", "Key Backquote", - "Key A", "Key B", "Key C", "Key D", "Key E", "Key F", "Key G", "Key H", "Key I", "Key J", "Key K", "Key L", "Key M", "Key N", "Key O", "Key P", "Key Q", "Key R", "Key S", "Key T", "Key U", "Key V", "Key W", "Key X", "Key Y", "Key Z", - "Key Delete", - "Key KP0", "Key KP1", "Key KP2", "Key KP3", "Key KP4", "Key KP5", "Key KP6", "Key KP7", "Key KP8", "Key KP9", - "Key KP_Period", "Key KP_Divide", "Key KP_Multiply", "Key KP_Minus", "Key KP_Plus", "Key KP_Enter", "Key KP_Equals", - "Key Up", "Key Down", "Key Right", "Key Left", "Key Insert", "Key Home", "Key End", "Key PageUp", "Key PageDown", - "Key F1", "Key F2", "Key F3", "Key F4", "Key F5", "Key F6", "Key F7", "Key F8", "Key F9", "Key F10", "Key F11", "Key F12", "Key F13", "Key F14", "Key F15", - "Key NumLock", "Key CapsLock", "Key ScrollLock", "Key RShift", "Key LShift", "Key RCtrl", "Key LCtrl", "Key RAlt", "Key LAlt", "Key RMeta", "Key LMeta", "Key LSuper", "Key RSuper", "Key Mode", "Key Compose", - "Key Help", "Key Print", "Key SysReq", "Key Break", "Key Menu", "Key Power", "Key Euro", "Key Undo" - }) - { - definition.BoolButtons.Add(key); - definition.CategoryLabels[key] = "RetroKeyboard"; - } - - return definition; - } - - public ControllerDefinition ControllerDefinition { get; private set; } - public IController Controller { get; set; } - - public void FrameAdvance(bool render, bool rendersound = true) - { - //TODO - consider changing directory and using Libretro subdir of bizhawk as a kind of sandbox, for the duration of the run? - IsLagFrame = true; - Frame++; - nsamprecv = 0; - retro.retro_run(); - //Console.WriteLine("[{0}]", nsamprecv); - } - - public int Frame { get; private set; } - - public string SystemId - { - get { return "Libretro"; } - } - - public bool DeterministicEmulation - { - // who knows - get { return true; } - } - - public string BoardName - { - get { return null; } - } - - #region ISaveRam - //TODO - terrible things will happen if this changes at runtime - - byte[] saverambuff = new byte[0]; - - public byte[] CloneSaveRam() - { - int size = (int)retro.retro_get_memory_size(LibRetro.RETRO_MEMORY.SAVE_RAM); - if (saverambuff.Length != size) - saverambuff = new byte[size]; - - IntPtr src = retro.retro_get_memory_data(LibRetro.RETRO_MEMORY.SAVE_RAM); - if (src == IntPtr.Zero) - return null; - - Marshal.Copy(src, saverambuff, 0, size); - return (byte[])saverambuff.Clone(); - } - - public void StoreSaveRam(byte[] data) - { - int size = (int)retro.retro_get_memory_size(LibRetro.RETRO_MEMORY.SAVE_RAM); - - if (size == 0) - return; - - IntPtr dst = retro.retro_get_memory_data(LibRetro.RETRO_MEMORY.SAVE_RAM); - if (dst == IntPtr.Zero) - throw new Exception("retro_get_memory_data(RETRO_MEMORY_SAVE_RAM) returned NULL"); - - Marshal.Copy(data, 0, dst, size); - } - - public bool SaveRamModified - { - [FeatureNotImplemented] - get - { - //if we dont have saveram, it isnt modified. otherwise, assume it is - int size = (int)retro.retro_get_memory_size(LibRetro.RETRO_MEMORY.SAVE_RAM); - if (size == 0) - return false; - return true; - } - - [FeatureNotImplemented] - set { throw new NotImplementedException(); } - } - - #endregion - - public void ResetCounters() - { - Frame = 0; - LagCount = 0; - IsLagFrame = false; - } - - #region savestates - - private byte[] savebuff; - private byte[] savebuff2; - - public void SaveStateText(System.IO.TextWriter writer) - { - var temp = SaveStateBinary(); - temp.SaveAsHex(writer); - } - - public void LoadStateText(System.IO.TextReader reader) - { - string hex = reader.ReadLine(); - byte[] state = new byte[hex.Length / 2]; - state.ReadFromHex(hex); - LoadStateBinary(new BinaryReader(new MemoryStream(state))); - } - - public void SaveStateBinary(System.IO.BinaryWriter writer) - { - //is this the only way we know of to detect unavailable savestates? - if (savebuff.Length > 0) - { - fixed (byte* ptr = &savebuff[0]) - { - if (!retro.retro_serialize((IntPtr)ptr, (uint)savebuff.Length)) - throw new Exception("retro_serialize() failed"); - } - } - - writer.Write(savebuff.Length); - writer.Write(savebuff); - // other variables - writer.Write(Frame); - writer.Write(LagCount); - writer.Write(IsLagFrame); - } - - public void LoadStateBinary(System.IO.BinaryReader reader) - { - int newlen = reader.ReadInt32(); - if (newlen > savebuff.Length) - throw new Exception("Unexpected buffer size"); - reader.Read(savebuff, 0, newlen); - if (savebuff.Length > 0) - { - fixed (byte* ptr = &savebuff[0]) - { - if (!retro.retro_unserialize((IntPtr)ptr, (uint)newlen)) - throw new Exception("retro_unserialize() failed"); - } - } - // other variables - Frame = reader.ReadInt32(); - LagCount = reader.ReadInt32(); - IsLagFrame = reader.ReadBoolean(); - } - - public byte[] SaveStateBinary() - { - var ms = new System.IO.MemoryStream(savebuff2, true); - var bw = new System.IO.BinaryWriter(ms); - SaveStateBinary(bw); - bw.Flush(); - ms.Close(); - return savebuff2; - } - - public bool BinarySaveStatesPreferred { get { return true; } } - - #endregion - - public CoreComm CoreComm - { - get; - private set; - } - - #region memory access - - void SetupDebuggingStuff() - { - } - - public MemoryDomainList MemoryDomains { get; private set; } - - #endregion - - public void Dispose() - { - if (resampler != null) - { - resampler.Dispose(); - resampler = null; - } - if (retro != null) - { - retro.Dispose(); - retro = null; - } - unmanagedResources.Dispose(); - unmanagedResources = null; - } - - #region ISoundProvider - - SpeexResampler resampler; - - short[] sampbuff = new short[0]; - - // debug - int nsamprecv = 0; - - void SetupResampler(double fps, double sps) - { - Console.WriteLine("FPS {0} SPS {1}", fps, sps); - - // todo: more precise? - uint spsnum = (uint)sps * 1000; - uint spsden = (uint)1000; - - resampler = new SpeexResampler(5, 44100 * spsden, spsnum, (uint)sps, 44100, null, null); - } - - void retro_audio_sample(short left, short right) - { - resampler.EnqueueSample(left, right); - nsamprecv++; - } - - uint retro_audio_sample_batch(IntPtr data, uint frames) - { - if (sampbuff.Length < frames * 2) - sampbuff = new short[frames * 2]; - Marshal.Copy(data, sampbuff, 0, (int)(frames * 2)); - resampler.EnqueueSamples(sampbuff, (int)frames); - nsamprecv += (int)frames; - // what is the return from this used for? - return frames; - } - - #endregion - - #region IVideoProvider - - float dar; - int[] vidbuff, rawvidbuff; - LibRetro.RETRO_PIXEL_FORMAT pixelfmt = LibRetro.RETRO_PIXEL_FORMAT.XRGB1555; - - void Blit555(short* src, int* dst, int width, int height, int pitch) - { - for (int j = 0; j < height; j++) - { - short* row = src; - for (int i = 0; i < width; i++) - { - short ci = *row; - int r = ci & 0x001f; - int g = ci & 0x03e0; - int b = ci & 0x7c00; - - r = (r << 3) | (r >> 2); - g = (g >> 2) | (g >> 7); - b = (b >> 7) | (b >> 12); - int co = r | g | b | unchecked((int)0xff000000); - - *dst = co; - dst++; - row++; - } - src += pitch; - } - } - - void Blit565(short* src, int* dst, int width, int height, int pitch) - { - for (int j = 0; j < height; j++) - { - short* row = src; - for (int i = 0; i < width; i++) - { - short ci = *row; - int r = ci & 0x001f; - int g = (ci & 0x07e0)>>5; - int b = (ci & 0xf800)>>11; - - r = (r << 3) | (r >> 2); - g = (g << 2) | (g >> 4); - b = (b << 3) | (b >> 2); - int co = (b<<16) | (g<<8) | r; - - *dst = co; - dst++; - row++; - } - src += pitch; - } - } - - void Blit888(int* src, int* dst, int width, int height, int pitch) - { - for (int j = 0; j < height; j++) - { - int* row = src; - for (int i = 0; i < width; i++) - { - int ci = *row; - int co = ci | unchecked((int)0xff000000); - *dst = co; - dst++; - row++; - } - src += pitch; - } - } - - void retro_video_refresh(IntPtr data, uint width, uint height, uint pitch) - { - if (data == IntPtr.Zero) // dup frame - return; - - - //if (BufferWidth != width) BufferWidth = (int)width; - //if (BufferHeight != height) BufferHeight = (int)height; - //if (BufferWidth * BufferHeight != rawvidbuff.Length) - // rawvidbuff = new int[BufferWidth * BufferHeight]; - - //if we have rotation, we might have a geometry mismatch and in any event we need a temp buffer to do the rotation from - //but that's a general problem, isnt it? - if (rawvidbuff == null || rawvidbuff.Length != width * height) - { - rawvidbuff = new int[width * height]; - } - - int[] target = vidbuff; - if (environmentInfo.Rotation_CCW != 0) - target = rawvidbuff; - - - fixed (int* dst = &target[0]) - { - if (pixelfmt == LibRetro.RETRO_PIXEL_FORMAT.XRGB8888) - Blit888((int*)data, dst, (int)width, (int)height, (int)pitch / 4); - else if (pixelfmt == LibRetro.RETRO_PIXEL_FORMAT.RGB565) - Blit565((short*)data, dst, (int)width, (int)height, (int)pitch / 2); - else - Blit555((short*)data, dst, (int)width, (int)height, (int)pitch / 2); - } - - int dw = BufferWidth, dh = BufferHeight; - if (environmentInfo.Rotation_CCW == 0) { } - else if (environmentInfo.Rotation_CCW == 270) - { - for(int y=0;y 1.0f) - return (int)(BufferHeight * dar); - else - return BufferWidth; - } - } - public int VirtualHeight - { - get - { - if(dar<=0) - return BufferHeight; - if (dar < 1.0f) - return (int)(BufferWidth / dar); - else - return BufferHeight; - } - } - - public int BufferWidth { get; private set; } - public int BufferHeight { get; private set; } - public int BackgroundColor { get { return unchecked((int)0xff000000); } } - - #endregion - - #region IInputPollable - public int LagCount { get; set; } - public bool IsLagFrame { get; set; } - public IInputCallbackSystem InputCallbacks - { - [FeatureNotImplemented] - get - { throw new NotImplementedException(); } - } - #endregion - } -} diff --git a/Bizware/BizHawk.Bizware.BizwareGL/BizHawk.Bizware.BizwareGL.csproj b/Bizware/BizHawk.Bizware.BizwareGL/BizHawk.Bizware.BizwareGL.csproj index d732597a7a..95eda4b012 100644 --- a/Bizware/BizHawk.Bizware.BizwareGL/BizHawk.Bizware.BizwareGL.csproj +++ b/Bizware/BizHawk.Bizware.BizwareGL/BizHawk.Bizware.BizwareGL.csproj @@ -14,11 +14,6 @@ Private="true" /> - - - - - diff --git a/Bizware/BizHawk.Bizware.BizwareGL/CacheBlendState.cs b/Bizware/BizHawk.Bizware.BizwareGL/CacheBlendState.cs deleted file mode 100644 index 55f94c4ae3..0000000000 --- a/Bizware/BizHawk.Bizware.BizwareGL/CacheBlendState.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace BizHawk.Bizware.BizwareGL -{ - -} diff --git a/Bizware/BizHawk.Bizware.BizwareGL/GuiRendererBase.cs b/Bizware/BizHawk.Bizware.BizwareGL/GuiRendererBase.cs deleted file mode 100644 index 331389798f..0000000000 --- a/Bizware/BizHawk.Bizware.BizwareGL/GuiRendererBase.cs +++ /dev/null @@ -1,414 +0,0 @@ -//http://stackoverflow.com/questions/6893302/decode-rgb-value-to-single-float-without-bit-shift-in-glsl - -using System; -using System.Diagnostics; -using System.Collections; -using System.Collections.Generic; -using sd=System.Drawing; - -using OpenTK; -using OpenTK.Graphics.OpenGL; - -namespace BizHawk.Bizware.BizwareGL -{ - public class GDIPlusGuiRenderer : IGuiRenderer - { - public GDIPlusGuiRenderer(IGL owner) - { - Owner = owner; - - VertexLayout = owner.CreateVertexLayout(); - VertexLayout.DefineVertexAttribute("aPosition", 0, 2, VertexAttribPointerType.Float, false, 32, 0); - VertexLayout.DefineVertexAttribute("aTexcoord", 1, 2, VertexAttribPointerType.Float, false, 32, 8); - VertexLayout.DefineVertexAttribute("aColor", 2, 4, VertexAttribPointerType.Float, false, 32, 16); - VertexLayout.Close(); - - _Projection = new MatrixStack(); - _Modelview = new MatrixStack(); - - var vs = Owner.CreateVertexShader(DefaultVertexShader,true); - var ps = Owner.CreateFragmentShader(DefaultPixelShader, true); - CurrPipeline = DefaultPipeline = Owner.CreatePipeline(VertexLayout, vs, ps, true); - } - - OpenTK.Graphics.Color4[] CornerColors = new OpenTK.Graphics.Color4[4] { - new OpenTK.Graphics.Color4(1.0f,1.0f,1.0f,1.0f),new OpenTK.Graphics.Color4(1.0f,1.0f,1.0f,1.0f),new OpenTK.Graphics.Color4(1.0f,1.0f,1.0f,1.0f),new OpenTK.Graphics.Color4(1.0f,1.0f,1.0f,1.0f) - }; - - /// - /// Sets the specified corner color (for the gradient effect) - /// - public void SetCornerColor(int which, OpenTK.Graphics.Color4 color) - { - Flush(); //dont really need to flush with current implementation. we might as well roll modulate color into it too. - CornerColors[which] = color; - } - - /// - /// Sets all four corner colors at once - /// - public void SetCornerColors(OpenTK.Graphics.Color4[] colors) - { - Flush(); //dont really need to flush with current implementation. we might as well roll modulate color into it too. - if (colors.Length != 4) throw new ArgumentException("array must be size 4", "colors"); - for (int i = 0; i < 4; i++) - CornerColors[i] = colors[i]; - } - - public void Dispose() - { - VertexLayout.Dispose(); - VertexLayout = null; - DefaultPipeline.Dispose(); - DefaultPipeline = null; - } - - /// - /// Sets the pipeline for this GuiRenderer to use. We won't keep possession of it. - /// This pipeline must work in certain ways, which can be discerned by inspecting the built-in one - /// - public void SetPipeline(Pipeline pipeline) - { - if (IsActive) - throw new InvalidOperationException("Can't change pipeline while renderer is running!"); - - Flush(); - CurrPipeline = pipeline; - - //clobber state cache - sTexture = null; - //save the modulate color? user beware, I guess, for now. - } - - /// - /// Restores the pipeline to the default - /// - public void SetDefaultPipeline() - { - SetPipeline(DefaultPipeline); - } - - public void SetModulateColorWhite() - { - SetModulateColor(sd.Color.White); - } - - public void SetModulateColor(sd.Color color) - { - Flush(); - CurrPipeline["uModulateColor"].Set(new Vector4(color.R / 255.0f, color.G / 255.0f, color.B / 255.0f, color.A / 255.0f)); - } - - public void SetBlendState(IBlendState rsBlend) - { - #if DEBUG - BlendStateSet = true; - #endif - Flush(); - Owner.SetBlendState(rsBlend); - } - - MatrixStack _Projection, _Modelview; - public MatrixStack Projection - { - get { return _Projection; } - set - { - _Projection = value; - _Projection.IsDirty = true; - } - } - public MatrixStack Modelview - { - get { return _Modelview; } - set - { - _Modelview = value; - _Modelview.IsDirty = true; - } - } - - public void Begin(sd.Size size) { Begin(size.Width, size.Height); } - - /// - /// begin rendering, initializing viewport and projections to the given dimensions - /// - /// Whether the matrices should be Y-flipped, for use with render targets - public void Begin(int width, int height, bool yflipped = false) - { - Begin(); - - Projection = Owner.CreateGuiProjectionMatrix(width, height); - Modelview = Owner.CreateGuiViewMatrix(width, height); - - if (yflipped) - { - //not sure this is the best way to do it. could be done in the view matrix creation - Modelview.Scale(1, -1); - Modelview.Translate(0, -height); - } - Owner.SetViewport(width, height); - } - - /// - /// Begins rendering - /// - public void Begin() - { - //uhhmmm I want to throw an exception if its already active, but its annoying. - - if(CurrPipeline == null) - throw new InvalidOperationException("Pipeline hasn't been set!"); - - IsActive = true; - Owner.BindPipeline(CurrPipeline); - - //clear state cache - sTexture = null; - CurrPipeline["uSamplerEnable"].Set(false); - Modelview.Clear(); - Projection.Clear(); - SetModulateColorWhite(); - - #if DEBUG - BlendStateSet = false; - #endif - } - - /// - /// Use this, if you must do something sneaky to openGL without this GuiRenderer knowing. - /// It might be faster than End and Beginning again, and certainly prettier - /// - public void Flush() - { - //no batching, nothing to do here yet - } - - /// - /// Ends rendering - /// - public void End() - { - if (!IsActive) - throw new InvalidOperationException("GuiRenderer is not active!"); - IsActive = false; - } - - public void RectFill(float x, float y, float w, float h) - { - PrepDrawSubrectInternal(null); - EmitRectangleInternal(x, y, w, h, 0, 0, 0, 0); - } - - /// - /// Draws a subrectangle from the provided texture. For advanced users only - /// - public void DrawSubrect(Texture2d tex, float x, float y, float w, float h, float u0, float v0, float u1, float v1) - { - DrawSubrectInternal(tex, x, y, w, h, u0, v0, u1, v1); - } - - /// - /// draws the specified Art resource - /// - public void Draw(Art art) { DrawInternal(art, 0, 0, art.Width, art.Height, false, false); } - - /// - /// draws the specified Art resource with the specified offset. This could be tricky if youve applied other rotate or scale transforms first. - /// - public void Draw(Art art, float x, float y) { DrawInternal(art, x, y, art.Width, art.Height, false, false); } - - /// - /// draws the specified Art resource with the specified offset, with the specified size. This could be tricky if youve applied other rotate or scale transforms first. - /// - public void Draw(Art art, float x, float y, float width, float height) { DrawInternal(art, x, y, width, height, false, false); } - - /// - /// draws the specified Art resource with the specified offset. This could be tricky if youve applied other rotate or scale transforms first. - /// - public void Draw(Art art, Vector2 pos) { DrawInternal(art, pos.X, pos.Y, art.Width, art.Height, false, false); } - - /// - /// draws the specified texture2d resource. - /// - public void Draw(Texture2d tex) { DrawInternal(tex, 0, 0, tex.Width, tex.Height); } - - /// - /// draws the specified texture2d resource. - /// - public void Draw(Texture2d tex, float x, float y) { DrawInternal(tex, x, y, tex.Width, tex.Height); } - - /// - /// draws the specified Art resource with the given flip flags - /// - public void DrawFlipped(Art art, bool xflip, bool yflip) { DrawInternal(art, 0, 0, art.Width, art.Height, xflip, yflip); } - - public void Draw(Texture2d art, float x, float y, float width, float height) - { - DrawInternal(art, x, y, width, height); - } - - unsafe void DrawInternal(Texture2d tex, float x, float y, float w, float h) - { - Art art = new Art(null); - art.Width = w; - art.Height = h; - art.u0 = art.v0 = 0; - art.u1 = art.v1 = 1; - art.BaseTexture = tex; - DrawInternal(art,x,y,w,h,false,tex.IsUpsideDown); - } - - unsafe void DrawInternal(Art art, float x, float y, float w, float h, bool fx, bool fy) - { - float u0,v0,u1,v1; - if(fx) { u0 = art.u1; u1 = art.u0; } - else { u0 = art.u0; u1 = art.u1; } - if(fy) { v0 = art.v1; v1 = art.v0; } - else { v0 = art.v0; v1 = art.v1; } - - float[] data = new float[32] { - x,y, u0,v0, CornerColors[0].R, CornerColors[0].G, CornerColors[0].B, CornerColors[0].A, - x+art.Width,y, u1,v0, CornerColors[1].R, CornerColors[1].G, CornerColors[1].B, CornerColors[1].A, - x,y+art.Height, u0,v1, CornerColors[2].R, CornerColors[2].G, CornerColors[2].B, CornerColors[2].A, - x+art.Width,y+art.Height, u1,v1, CornerColors[3].R, CornerColors[3].G, CornerColors[3].B, CornerColors[3].A, - }; - - Texture2d tex = art.BaseTexture; - - PrepDrawSubrectInternal(tex); - - fixed (float* pData = &data[0]) - { - Owner.BindArrayData(pData); - Owner.DrawArrays(PrimitiveType.TriangleStrip, 0, 4); - } - } - - unsafe void PrepDrawSubrectInternal(Texture2d tex) - { - if (sTexture != tex) - { - sTexture = tex; - CurrPipeline["uSampler0"].Set(tex); - if (sTexture == null) - { - CurrPipeline["uSamplerEnable"].Set(false); - } - else - { - CurrPipeline["uSamplerEnable"].Set(true); - } - } - - if (_Projection.IsDirty) - { - CurrPipeline["um44Projection"].Set(ref _Projection.Top); - _Projection.IsDirty = false; - } - if (_Modelview.IsDirty) - { - CurrPipeline["um44Modelview"].Set(ref _Modelview.Top); - _Modelview.IsDirty = false; - } - } - - unsafe void EmitRectangleInternal(float x, float y, float w, float h, float u0, float v0, float u1, float v1) - { - float* pData = stackalloc float[32]; - pData[0] = x; - pData[1] = y; - pData[2] = u0; - pData[3] = v0; - pData[4] = CornerColors[0].R; - pData[5] = CornerColors[0].G; - pData[6] = CornerColors[0].B; - pData[7] = CornerColors[0].A; - pData[8] = x + w; - pData[9] = y; - pData[10] = u1; - pData[11] = v0; - pData[12] = CornerColors[1].R; - pData[13] = CornerColors[1].G; - pData[14] = CornerColors[1].B; - pData[15] = CornerColors[1].A; - pData[16] = x; - pData[17] = y + h; - pData[18] = u0; - pData[19] = v1; - pData[20] = CornerColors[2].R; - pData[21] = CornerColors[2].G; - pData[22] = CornerColors[2].B; - pData[23] = CornerColors[2].A; - pData[24] = x + w; - pData[25] = y + h; - pData[26] = u1; - pData[27] = v1; - pData[28] = CornerColors[3].R; - pData[29] = CornerColors[3].G; - pData[30] = CornerColors[3].B; - pData[31] = CornerColors[3].A; - - Owner.BindArrayData(pData); - Owner.DrawArrays(PrimitiveType.TriangleStrip, 0, 4); - - #if DEBUG - Debug.Assert(BlendStateSet); - #endif - } - - unsafe void DrawSubrectInternal(Texture2d tex, float x, float y, float w, float h, float u0, float v0, float u1, float v1) - { - PrepDrawSubrectInternal(tex); - EmitRectangleInternal(x, y, w, h, u0, v0, u1, v1); - } - - public bool IsActive { get; private set; } - public IGL Owner { get; private set; } - - VertexLayout VertexLayout; - Pipeline CurrPipeline, DefaultPipeline; - - //state cache - Texture2d sTexture; - #if DEBUG - bool BlendStateSet; - #endif - - public readonly string DefaultVertexShader = @" -#version 110 //opengl 2.0 ~ 2004 -uniform mat4 um44Modelview, um44Projection; -uniform vec4 uModulateColor; - -attribute vec2 aPosition; -attribute vec2 aTexcoord; -attribute vec4 aColor; - -varying vec2 vTexcoord0; -varying vec4 vCornerColor; - -void main() -{ - vec4 temp = vec4(aPosition,0,1); - gl_Position = um44Projection * (um44Modelview * temp); - vTexcoord0 = aTexcoord; - vCornerColor = aColor * uModulateColor; -}"; - - public readonly string DefaultPixelShader = @" -#version 110 //opengl 2.0 ~ 2004 -uniform bool uSamplerEnable; -uniform sampler2D uSampler0; - -varying vec2 vTexcoord0; -varying vec4 vCornerColor; - -void main() -{ - vec4 temp = vCornerColor; - if(uSamplerEnable) temp *= texture2D(uSampler0,vTexcoord0); - gl_FragColor = temp; -}"; - - } -} \ No newline at end of file diff --git a/Bizware/BizHawk.Bizware.BizwareGL/RetroShader_OpenTK.cs b/Bizware/BizHawk.Bizware.BizwareGL/RetroShader_OpenTK.cs deleted file mode 100644 index d1e887fd23..0000000000 --- a/Bizware/BizHawk.Bizware.BizwareGL/RetroShader_OpenTK.cs +++ /dev/null @@ -1,95 +0,0 @@ -using System; -using System.Drawing; -using System.Windows.Forms; - -using OpenTK; -using OpenTK.Graphics.OpenGL; - -namespace BizHawk.Bizware.BizwareGL.Drivers.OpenTK -{ - /// - /// Handles RetroArch's GLSL shader pass format - /// This isnt implemented in BizwareGL abstract layer because it relies too much on GLSL peculiarities - /// - public class RetroShader_OpenTK : IDisposable - { - public RetroShader_OpenTK(IGL owner, string source, bool debug = false) - { - Owner = owner as IGL_TK; - - VertexLayout = owner.CreateVertexLayout(); - VertexLayout.DefineVertexAttribute("VertexCoord", 0, 4, VertexAttribPointerType.Float, AttributeUsage.Unspecified, false, 40, 0); //VertexCoord - VertexLayout.DefineVertexAttribute("ColorShit", 1, 4, VertexAttribPointerType.Float, AttributeUsage.Unspecified, false, 40, 16); //COLOR - VertexLayout.DefineVertexAttribute("TexCoord", 2, 2, VertexAttribPointerType.Float, AttributeUsage.Unspecified, false, 40, 32); //TexCoord (is this vec2 or vec4? the glsl converted from cg had vec4 but the cg had vec2...) - VertexLayout.Close(); - - string vsSource = "#define VERTEX\r\n" + source; - string psSource = "#define FRAGMENT\r\n" + source; - var vs = Owner.CreateVertexShader(vsSource, debug); - var ps = Owner.CreateFragmentShader(psSource, debug); - Pipeline = Owner.CreatePipeline(VertexLayout, vs, ps, debug); - } - - public void Dispose() - { - Pipeline.Dispose(); - } - - public void Bind() - { - //lame... - Owner.BindPipeline(Pipeline); - } - - public unsafe void Run(Texture2d tex, Size InputSize, Size OutputSize, bool flip) - { - //ack! make sure to set the pipeline before setting - Bind(); - - Pipeline["InputSize"].Set(new Vector2(InputSize.Width,InputSize.Height)); - Pipeline["TextureSize"].Set(new Vector2(InputSize.Width, InputSize.Height)); - Pipeline["OutputSize"].Set(new Vector2(OutputSize.Width, OutputSize.Height)); - Pipeline["FrameCount"].Set(0); //todo - Pipeline["FrameDirection"].Set(1); //todo - - var Projection = Owner.CreateGuiProjectionMatrix(OutputSize); - var Modelview = Owner.CreateGuiViewMatrix(OutputSize); - Pipeline["MVPMatrix"].Set(Modelview * Projection, false); - - Owner.SetTextureWrapMode(tex, true); - - Pipeline["Texture"].Set(tex); - Owner.SetViewport(OutputSize); - - int w = OutputSize.Width; - int h = OutputSize.Height; - float v0,v1; - if (flip) { v0 = 1; v1 = 0; } - else { v0 = 0; v1 = 1; } - float* pData = stackalloc float[10*4]; - int i=0; - pData[i++] = 0; pData[i++] = 0; pData[i++] = 0; pData[i++] = 1; //topleft vert - pData[i++] = 0; pData[i++] = 0; pData[i++] = 0; pData[i++] = 0; //junk - pData[i++] = 0; pData[i++] = v0; //texcoord - pData[i++] = w; pData[i++] = 0; pData[i++] = 0; pData[i++] = 1; //topright vert - pData[i++] = 0; pData[i++] = 0; pData[i++] = 0; pData[i++] = 0; //junk - pData[i++] = 1; pData[i++] = v0; //texcoord - pData[i++] = 0; pData[i++] = h; pData[i++] = 0; pData[i++] = 1; //bottomleft vert - pData[i++] = 0; pData[i++] = 0; pData[i++] = 0; pData[i++] = 0; //junk - pData[i++] = 0; pData[i++] = v1; //texcoord - pData[i++] = w; pData[i++] = h; pData[i++] = 0; pData[i++] = 1; //bottomright vert - pData[i++] = 0; pData[i++] = 0; pData[i++] = 0; pData[i++] = 0; //junk - pData[i++] = 1; pData[i++] = v1; //texcoord - - Owner.SetBlendState(Owner.BlendNoneCopy); - Owner.BindArrayData(pData); - Owner.DrawArrays(PrimitiveType.TriangleStrip, 0, 4); - } - - - public IGL_TK Owner { get; private set; } - - VertexLayout VertexLayout; - public Pipeline Pipeline; - } -} \ No newline at end of file