diff --git a/BizHawk.Emulation.Common/Base Implementations/BasicServiceProvider.cs b/BizHawk.Emulation.Common/Base Implementations/BasicServiceProvider.cs
index 30c7c9d5b8..b0d653cd7c 100644
--- a/BizHawk.Emulation.Common/Base Implementations/BasicServiceProvider.cs
+++ b/BizHawk.Emulation.Common/Base Implementations/BasicServiceProvider.cs
@@ -45,6 +45,17 @@ namespace BizHawk.Emulation.Common
}
}
+ ///
+ /// the core can call this to register an additional service
+ ///
+ ///
+ ///
+ public void Register(T provider)
+ where T : IEmulatorService
+ {
+ Services[typeof(T)] = provider;
+ }
+
public IEmulatorService GetService()
where T : IEmulatorService
{
diff --git a/BizHawk.Emulation.Common/Interfaces/IDisassemblable.cs b/BizHawk.Emulation.Common/Interfaces/IDisassemblable.cs
index 29067ad9ab..d3611faacd 100644
--- a/BizHawk.Emulation.Common/Interfaces/IDisassemblable.cs
+++ b/BizHawk.Emulation.Common/Interfaces/IDisassemblable.cs
@@ -1,8 +1,10 @@
-using System.Collections.Generic;
+using System;
+using System.Linq;
+using System.Collections.Generic;
namespace BizHawk.Emulation.Common
{
- public interface IDisassemblable : IEmulator, IEmulatorService
+ public interface IDisassemblable : IEmulatorService
{
///
/// Gets or sets the Cpu that will be used to disassemble
@@ -13,11 +15,45 @@ namespace BizHawk.Emulation.Common
///
/// Gets a list of Cpus that can be used when setting the Cpu property
///
- IEnumerable AvailableCpus { get; set; }
+ IEnumerable AvailableCpus { get; }
///
/// returns a disassembly starting at addr lasting for length, using the given domain
///
string Disassemble(MemoryDomain m, uint addr, out int length);
}
+
+ ///
+ /// does santiy checking on Cpu parameters
+ ///
+ public abstract class VerifiedDisassembler : IDisassemblable
+ {
+ protected string _cpu;
+
+ public virtual string Cpu
+ {
+ get
+ {
+ return _cpu;
+ }
+ set
+ {
+ if (!AvailableCpus.Contains(value))
+ throw new ArgumentException();
+ _cpu = value;
+ }
+ }
+
+ public abstract IEnumerable AvailableCpus
+ {
+ get;
+ }
+
+ public abstract string Disassemble(MemoryDomain m, uint addr, out int length);
+
+ public VerifiedDisassembler()
+ {
+ _cpu = AvailableCpus.First();
+ }
+ }
}
diff --git a/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj b/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj
index e2f41d8526..c76ea7263c 100644
--- a/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj
+++ b/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj
@@ -274,6 +274,7 @@
+
diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/ArmV4Disassembler.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/ArmV4Disassembler.cs
new file mode 100644
index 0000000000..af09c8ab90
--- /dev/null
+++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/ArmV4Disassembler.cs
@@ -0,0 +1,42 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using BizHawk.Emulation.Common;
+
+namespace BizHawk.Emulation.Cores.Nintendo.GBA
+{
+ public class ArmV4Disassembler : VerifiedDisassembler
+ {
+ public override IEnumerable AvailableCpus
+ {
+ get
+ {
+ return new[] { "ARM v4", "ARM v4 (Thumb)" };
+ }
+ }
+
+ public override string Disassemble(MemoryDomain m, uint addr, out int length)
+ {
+ if (_cpu == "ARM v4 (Thumb)")
+ {
+ addr &= unchecked((uint)~1);
+ int op = m.PeekByte((int)addr) | m.PeekByte((int)addr + 1) << 8;
+ string ret = Emulation.Cores.Components.ARM.Darm.DisassembleStuff(addr | 1, (uint)op);
+ length = 2;
+ return ret;
+ }
+ else
+ {
+ addr &= unchecked((uint)~3);
+ int op = m.PeekByte((int)addr)
+ | m.PeekByte((int)addr + 1) << 8
+ | m.PeekByte((int)addr + 2) << 16
+ | m.PeekByte((int)addr + 3) << 24;
+ string ret = Emulation.Cores.Components.ARM.Darm.DisassembleStuff(addr, (uint)op);
+ length = 4;
+ return ret;
+ }
+ }
+ }
+}
diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/VBANext.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/VBANext.cs
index f1d1125183..3edc338189 100644
--- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/VBANext.cs
+++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/VBANext.cs
@@ -23,7 +23,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
[CoreConstructor("GBA")]
public VBANext(byte[] file, CoreComm comm, GameInfo game, bool deterministic, object syncsettings)
{
- ServiceProvider = new BasicServiceProvider(this);
+ var ser = new BasicServiceProvider(this);
+ ser.Register(new ArmV4Disassembler());
+ ServiceProvider = ser;
+
CoreComm = comm;
byte[] biosfile = CoreComm.CoreFileProvider.GetFirmware("GBA", "Bios", true, "GBA bios file is mandatory.");