From 4b695e28207d6ae9480d8cb8b0a1b329214f2c60 Mon Sep 17 00:00:00 2001
From: adelikat <adelikat@tasvideos.org>
Date: Sun, 23 Apr 2017 12:21:42 -0500
Subject: [PATCH] Intellivision - implement IDisassemblable

---
 .../BizHawk.Emulation.Cores.csproj            |  3 ++
 .../Intellivision.IDebuggable.cs              |  4 +--
 .../Intellivision.IDisassemblable.cs          | 32 +++++++++++++++++++
 .../Consoles/Intellivision/Intellivision.cs   |  2 +-
 4 files changed, 38 insertions(+), 3 deletions(-)
 create mode 100644 BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.IDisassemblable.cs

diff --git a/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj b/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj
index d4bf566fe4..78127c2c20 100644
--- a/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj
+++ b/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj
@@ -413,6 +413,9 @@
     <Compile Include="Consoles\Intellivision\ICart.cs" />
     <Compile Include="Consoles\Intellivision\Intellicart.cs" />
     <Compile Include="Consoles\Intellivision\Intellivision.IDebuggable.cs">
+      <DependentUpon>Intellivision.cs</DependentUpon>
+    </Compile>
+    <Compile Include="Consoles\Intellivision\Intellivision.IDisassemblable.cs">
         <DependentUpon>Intellivision.cs</DependentUpon>
     </Compile>
     <Compile Include="Consoles\Intellivision\Intellivision.IInputPollable.cs">
diff --git a/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.IDebuggable.cs b/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.IDebuggable.cs
index d777272bc5..e0ad1557d5 100644
--- a/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.IDebuggable.cs
+++ b/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.IDebuggable.cs
@@ -18,7 +18,7 @@ namespace BizHawk.Emulation.Cores.Intellivision
 				["R4"] = _cpu.Register[4],
 				["R5"] = _cpu.Register[5],
 				["R6"] = _cpu.Register[6],
-				["R7"] = _cpu.Register[7],
+				["PC"] = _cpu.Register[7],
 
 				["FlagS"] = _cpu.FlagS ? 1 : 0,
 				["FlagC"] = _cpu.FlagC ? 1 : 0,
@@ -57,7 +57,7 @@ namespace BizHawk.Emulation.Cores.Intellivision
 				case "R6":
 					_cpu.Register[6] = (ushort)value;
 					break;
-				case "R7":
+				case "PC":
 					_cpu.Register[7] = (ushort)value;
 					break;
 
diff --git a/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.IDisassemblable.cs b/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.IDisassemblable.cs
new file mode 100644
index 0000000000..5494aa548e
--- /dev/null
+++ b/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.IDisassemblable.cs
@@ -0,0 +1,32 @@
+using System.Collections.Generic;
+using BizHawk.Emulation.Common;
+
+namespace BizHawk.Emulation.Cores.Intellivision
+{
+	public partial class Intellivision : IDisassemblable
+	{
+		public string Cpu
+		{
+			get { return "CP1610"; }
+			set { }
+		}
+
+		public string PCRegisterName
+		{
+			get { return "PC"; }
+		}
+
+		public IEnumerable<string> AvailableCpus
+		{
+			get { yield return "CP1610"; }
+		}
+
+		public string Disassemble(MemoryDomain m, uint addr, out int length)
+		{
+			// Note: currently this core can only disassemble the SystemBus
+			// The CP1610 disassembler would need some refactoring to support anything else
+			string ret = _cpu.Disassemble((ushort)addr, out length);
+			return ret;
+		}
+	}
+}
diff --git a/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.cs b/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.cs
index 5c2525835e..82c4e2f7ec 100644
--- a/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.cs
+++ b/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.cs
@@ -12,7 +12,7 @@ namespace BizHawk.Emulation.Cores.Intellivision
 		isReleased: true
 		)]
 	[ServiceNotApplicable(typeof(ISaveRam), typeof(IDriveLight), typeof(IRegionable))]
-	public sealed partial class Intellivision : IEmulator, IStatable, IInputPollable,
+	public sealed partial class Intellivision : IEmulator, IStatable, IInputPollable, IDisassemblable,
 		IDebuggable, ISettable<Intellivision.IntvSettings, Intellivision.IntvSyncSettings>
 	{
 		[CoreConstructor("INTV")]