diff --git a/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj b/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj
index 0c151c60a1..078346da51 100644
--- a/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj
+++ b/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj
@@ -85,7 +85,10 @@
VersionInfo.cs
+
+
+
diff --git a/BizHawk.Emulation.Cores/Calculator/TI83.IDebuggable.cs b/BizHawk.Emulation.Cores/Calculator/TI83.IDebuggable.cs
new file mode 100644
index 0000000000..f8b32f1a3b
--- /dev/null
+++ b/BizHawk.Emulation.Cores/Calculator/TI83.IDebuggable.cs
@@ -0,0 +1,123 @@
+using System;
+using System.Collections.Generic;
+
+using BizHawk.Common.NumberExtensions;
+using BizHawk.Emulation.Common;
+
+namespace BizHawk.Emulation.Cores.Calculators
+{
+ public partial class TI83 : IDebuggable
+ {
+ public IDictionary GetCpuFlagsAndRegisters()
+ {
+ return new Dictionary
+ {
+ { "A", cpu.RegisterA },
+ { "AF", cpu.RegisterAF },
+ { "B", cpu.RegisterB },
+ { "BC", cpu.RegisterBC },
+ { "C", cpu.RegisterC },
+ { "D", cpu.RegisterD },
+ { "DE", cpu.RegisterDE },
+ { "E", cpu.RegisterE },
+ { "F", cpu.RegisterF },
+ { "H", cpu.RegisterH },
+ { "HL", cpu.RegisterHL },
+ { "I", cpu.RegisterI },
+ { "IX", cpu.RegisterIX },
+ { "IY", cpu.RegisterIY },
+ { "L", cpu.RegisterL },
+ { "PC", cpu.RegisterPC },
+ { "R", cpu.RegisterR },
+ { "Shadow AF", cpu.RegisterShadowAF },
+ { "Shadow BC", cpu.RegisterShadowBC },
+ { "Shadow DE", cpu.RegisterShadowDE },
+ { "Shadow HL", cpu.RegisterShadowHL },
+ { "SP", cpu.RegisterSP },
+ { "Flag C", cpu.RegisterF.Bit(0) ? 1 : 0 },
+ { "Flag N", cpu.RegisterF.Bit(1) ? 1 : 0 },
+ { "Flag P/V", cpu.RegisterF.Bit(2) ? 1 : 0 },
+ { "Flag 3rd", cpu.RegisterF.Bit(3) ? 1 : 0 },
+ { "Flag H", cpu.RegisterF.Bit(4) ? 1 : 0 },
+ { "Flag 5th", cpu.RegisterF.Bit(5) ? 1 : 0 },
+ { "Flag Z", cpu.RegisterF.Bit(6) ? 1 : 0 },
+ { "Flag S", cpu.RegisterF.Bit(7) ? 1 : 0 }
+ };
+ }
+
+ public void SetCpuRegister(string register, int value)
+ {
+ switch (register)
+ {
+ default:
+ throw new InvalidOperationException();
+ case "A":
+ cpu.RegisterA = (byte)value;
+ break;
+ case "AF":
+ cpu.RegisterAF = (byte)value;
+ break;
+ case "B":
+ cpu.RegisterB = (byte)value;
+ break;
+ case "BC":
+ cpu.RegisterBC = (byte)value;
+ break;
+ case "C":
+ cpu.RegisterC = (byte)value;
+ break;
+ case "D":
+ cpu.RegisterD = (byte)value;
+ break;
+ case "DE":
+ cpu.RegisterDE = (byte)value;
+ break;
+ case "E":
+ cpu.RegisterE = (byte)value;
+ break;
+ case "F":
+ cpu.RegisterF = (byte)value;
+ break;
+ case "H":
+ cpu.RegisterH = (byte)value;
+ break;
+ case "HL":
+ cpu.RegisterHL = (byte)value;
+ break;
+ case "I":
+ cpu.RegisterI = (byte)value;
+ break;
+ case "IX":
+ cpu.RegisterIX = (byte)value;
+ break;
+ case "IY":
+ cpu.RegisterIY = (byte)value;
+ break;
+ case "L":
+ cpu.RegisterL = (byte)value;
+ break;
+ case "PC":
+ cpu.RegisterPC = (ushort)value;
+ break;
+ case "R":
+ cpu.RegisterR = (byte)value;
+ break;
+ case "Shadow AF":
+ cpu.RegisterShadowAF = (byte)value;
+ break;
+ case "Shadow BC":
+ cpu.RegisterShadowBC = (byte)value;
+ break;
+ case "Shadow DE":
+ cpu.RegisterShadowDE = (byte)value;
+ break;
+ case "Shadow HL":
+ cpu.RegisterShadowHL = (byte)value;
+ break;
+ case "SP":
+ cpu.RegisterSP = (byte)value;
+ break;
+ }
+ }
+ }
+}
diff --git a/BizHawk.Emulation.Cores/Calculator/TI83.IMemoryDomains.cs b/BizHawk.Emulation.Cores/Calculator/TI83.IMemoryDomains.cs
new file mode 100644
index 0000000000..64a8de78cd
--- /dev/null
+++ b/BizHawk.Emulation.Cores/Calculator/TI83.IMemoryDomains.cs
@@ -0,0 +1,31 @@
+using System.Collections.Generic;
+using BizHawk.Emulation.Common;
+
+namespace BizHawk.Emulation.Cores.Calculators
+{
+ public partial class TI83 : IMemoryDomains
+ {
+ public MemoryDomainList MemoryDomains
+ {
+ get { return _memoryDomains; }
+ }
+
+ private void SetupMemoryDomains()
+ {
+ var domains = new List
+ {
+ new MemoryDomain(
+ "Main RAM",
+ ram.Length,
+ MemoryDomain.Endian.Little,
+ addr => ram[addr],
+ (addr, value) => ram[addr] = value
+ )
+ };
+
+ _memoryDomains = new MemoryDomainList(domains);
+ }
+
+ private MemoryDomainList _memoryDomains;
+ }
+}
diff --git a/BizHawk.Emulation.Cores/Calculator/TI83.ISettable.cs b/BizHawk.Emulation.Cores/Calculator/TI83.ISettable.cs
new file mode 100644
index 0000000000..c3d84b355e
--- /dev/null
+++ b/BizHawk.Emulation.Cores/Calculator/TI83.ISettable.cs
@@ -0,0 +1,46 @@
+using BizHawk.Emulation.Common;
+
+namespace BizHawk.Emulation.Cores.Calculators
+{
+ public partial class TI83 : ISettable
+ {
+ private TI83Settings Settings;
+
+ public TI83Settings GetSettings()
+ {
+ return Settings.Clone();
+ }
+
+ public bool PutSettings(TI83Settings o)
+ {
+ Settings = o;
+ return false;
+ }
+
+ public object GetSyncSettings()
+ {
+ return null;
+ }
+
+ public bool PutSyncSettings(object o)
+ {
+ return false;
+ }
+
+ public class TI83Settings
+ {
+ public uint BGColor = 0x889778;
+ public uint ForeColor = 0x36412D;
+
+ public TI83Settings()
+ {
+
+ }
+
+ public TI83Settings Clone()
+ {
+ return (TI83Settings)MemberwiseClone();
+ }
+ }
+ }
+}
diff --git a/BizHawk.Emulation.Cores/Calculator/TI83.cs b/BizHawk.Emulation.Cores/Calculator/TI83.cs
index 895c7cac01..52d2b23c32 100644
--- a/BizHawk.Emulation.Cores/Calculator/TI83.cs
+++ b/BizHawk.Emulation.Cores/Calculator/TI83.cs
@@ -9,7 +9,7 @@ using BizHawk.Common.NumberExtensions;
using BizHawk.Emulation.Common;
using BizHawk.Emulation.Cores.Components.Z80;
-//http://www.ticalc.org/pub/text/calcinfo/
+// http://www.ticalc.org/pub/text/calcinfo/
namespace BizHawk.Emulation.Cores.Calculators
{
@@ -19,7 +19,7 @@ namespace BizHawk.Emulation.Cores.Calculators
isPorted: false,
isReleased: true
)]
- public class TI83 : IEmulator, IMemoryDomains, IDebuggable, ISettable
+ public partial class TI83 : IEmulator, IMemoryDomains, IDebuggable, ISettable
{
//hardware
private readonly Z80A cpu = new Z80A();
@@ -47,6 +47,38 @@ namespace BizHawk.Emulation.Cores.Calculators
private bool LinkActive;
private bool m_CursorMoved;
+ private int lagCount = 0;
+ private bool lagged = true;
+ private bool isLag = false;
+ private int frame;
+
+ [CoreConstructor("TI83")]
+ public TI83(CoreComm comm, GameInfo game, byte[] rom, object Settings)
+ {
+ PutSettings((TI83Settings)Settings ?? new TI83Settings());
+
+ CoreComm = comm;
+ cpu.ReadMemory = ReadMemory;
+ cpu.WriteMemory = WriteMemory;
+ cpu.ReadHardware = ReadHardware;
+ cpu.WriteHardware = WriteHardware;
+ cpu.IRQCallback = IRQCallback;
+ cpu.NMICallback = NMICallback;
+
+ this.rom = rom;
+ LinkPort = new Link(this);
+
+ //different calculators (different revisions?) have different initPC. we track this in the game database by rom hash
+ //if( *(unsigned long *)(m_pRom + 0x6ce) == 0x04D3163E ) m_Regs.PC.W = 0x6ce; //KNOWN
+ //else if( *(unsigned long *)(m_pRom + 0x6f6) == 0x04D3163E ) m_Regs.PC.W = 0x6f6; //UNKNOWN
+
+ if (game["initPC"])
+ startPC = ushort.Parse(game.OptionValue("initPC"), NumberStyles.HexNumber);
+
+ HardReset();
+ SetupMemoryDomains();
+ }
+
//-------
public byte ReadMemory(ushort addr)
@@ -155,7 +187,7 @@ namespace BizHawk.Emulation.Cores.Calculators
return 0xFF;
}
- byte ReadKeyboard()
+ private byte ReadKeyboard()
{
CoreComm.InputCallback.Call();
//ref TI-9X
@@ -240,7 +272,7 @@ namespace BizHawk.Emulation.Cores.Calculators
}
- byte ReadDispData()
+ private byte ReadDispData()
{
if (m_CursorMoved)
{
@@ -265,7 +297,7 @@ namespace BizHawk.Emulation.Cores.Calculators
return ret;
}
- void WriteDispData(byte value)
+ private void WriteDispData(byte value)
{
int offset;
if (disp_mode == 1)
@@ -298,7 +330,7 @@ namespace BizHawk.Emulation.Cores.Calculators
doDispMove();
}
- void doDispMove()
+ private void doDispMove()
{
switch (disp_move)
{
@@ -312,7 +344,7 @@ namespace BizHawk.Emulation.Cores.Calculators
disp_y &= 0x3F;
}
- void WriteDispCtrl(byte value)
+ private void WriteDispCtrl(byte value)
{
if (value <= 1)
disp_mode = value;
@@ -347,50 +379,22 @@ namespace BizHawk.Emulation.Cores.Calculators
}
}
- [CoreConstructor("TI83")]
- public TI83(CoreComm comm, GameInfo game, byte[] rom, object Settings)
- {
- PutSettings((TI83Settings)Settings ?? new TI83Settings());
-
- CoreComm = comm;
- cpu.ReadMemory = ReadMemory;
- cpu.WriteMemory = WriteMemory;
- cpu.ReadHardware = ReadHardware;
- cpu.WriteHardware = WriteHardware;
- cpu.IRQCallback = IRQCallback;
- cpu.NMICallback = NMICallback;
-
- this.rom = rom;
- LinkPort = new Link(this);
-
- //different calculators (different revisions?) have different initPC. we track this in the game database by rom hash
- //if( *(unsigned long *)(m_pRom + 0x6ce) == 0x04D3163E ) m_Regs.PC.W = 0x6ce; //KNOWN
- //else if( *(unsigned long *)(m_pRom + 0x6f6) == 0x04D3163E ) m_Regs.PC.W = 0x6f6; //UNKNOWN
-
- if (game["initPC"])
- startPC = ushort.Parse(game.OptionValue("initPC"), NumberStyles.HexNumber);
-
- HardReset();
- SetupMemoryDomains();
- }
-
- void IRQCallback()
+ private void IRQCallback()
{
//Console.WriteLine("IRQ with vec {0} and cpu.InterruptMode {1}", cpu.RegisterI, cpu.InterruptMode);
cpu.Interrupt = false;
}
- void NMICallback()
+ private void NMICallback()
{
Console.WriteLine("NMI");
cpu.NonMaskableInterrupt = false;
}
-
public CoreComm CoreComm { get; private set; }
protected byte[] vram = new byte[0x300];
- class MyVideoProvider : IVideoProvider
+ private class MyVideoProvider : IVideoProvider
{
private readonly TI83 emu;
public MyVideoProvider(TI83 emu)
@@ -458,8 +462,8 @@ namespace BizHawk.Emulation.Cores.Calculators
public IController Controller { get; set; }
- //configuration
- ushort startPC;
+ // configuration
+ private ushort startPC;
public void FrameAdvance(bool render, bool rendersound)
{
@@ -507,10 +511,6 @@ namespace BizHawk.Emulation.Cores.Calculators
disp_x = disp_y = 0;
}
- private int lagCount = 0;
- private bool lagged = true;
- private bool isLag = false;
- private int frame;
public int Frame { get { return frame; } set { frame = value; } }
public int LagCount { get { return lagCount; } set { lagCount = value; } }
public bool IsLagFrame { get { return isLag; } }
@@ -539,7 +539,7 @@ namespace BizHawk.Emulation.Cores.Calculators
public void SaveStateText(TextWriter tw) { SyncState(Serializer.CreateTextWriter(tw)); }
public void LoadStateText(TextReader tr) { SyncState(Serializer.CreateTextReader(tr)); }
- void SyncState(Serializer ser)
+ private void SyncState(Serializer ser)
{
ser.BeginSection("TI83");
cpu.SyncState(ser);
@@ -562,7 +562,7 @@ namespace BizHawk.Emulation.Cores.Calculators
ser.EndSection();
}
- byte[] stateBuffer;
+ private byte[] stateBuffer;
public byte[] SaveStateBinary()
{
if (stateBuffer == null)
@@ -587,27 +587,8 @@ namespace BizHawk.Emulation.Cores.Calculators
public string SystemId { get { return "TI83"; } }
public string BoardName { get { return null; } }
- private MemoryDomainList _memoryDomains;
private const ushort RamSizeMask = 0x7FFF;
- private void SetupMemoryDomains()
- {
- var domains = new List
- {
- new MemoryDomain(
- "Main RAM",
- ram.Length,
- MemoryDomain.Endian.Little,
- addr => ram[addr],
- (addr, value) => ram[addr] = value
- )
- };
-
- _memoryDomains = new MemoryDomainList(domains);
- }
-
- public MemoryDomainList MemoryDomains { get { return _memoryDomains; } }
-
public void Dispose() { }
public Link LinkPort;
@@ -979,145 +960,5 @@ namespace BizHawk.Emulation.Cores.Calculators
SendNextFile();
}
}
-
- public class TI83Settings
- {
- public uint BGColor = 0x889778;
- public uint ForeColor = 0x36412D;
-
- public TI83Settings()
- {
- }
-
- public TI83Settings Clone()
- {
- return (TI83Settings)MemberwiseClone();
- }
- }
-
- TI83Settings Settings;
-
- public TI83Settings GetSettings() { return Settings.Clone(); }
-
- public bool PutSettings(TI83Settings o)
- {
- Settings = o;
- return false;
- }
-
- public object GetSyncSettings() { return null; }
- public bool PutSyncSettings(object o) { return false; }
-
- public IDictionary GetCpuFlagsAndRegisters()
- {
- return new Dictionary
- {
- { "A", cpu.RegisterA },
- { "AF", cpu.RegisterAF },
- { "B", cpu.RegisterB },
- { "BC", cpu.RegisterBC },
- { "C", cpu.RegisterC },
- { "D", cpu.RegisterD },
- { "DE", cpu.RegisterDE },
- { "E", cpu.RegisterE },
- { "F", cpu.RegisterF },
- { "H", cpu.RegisterH },
- { "HL", cpu.RegisterHL },
- { "I", cpu.RegisterI },
- { "IX", cpu.RegisterIX },
- { "IY", cpu.RegisterIY },
- { "L", cpu.RegisterL },
- { "PC", cpu.RegisterPC },
- { "R", cpu.RegisterR },
- { "Shadow AF", cpu.RegisterShadowAF },
- { "Shadow BC", cpu.RegisterShadowBC },
- { "Shadow DE", cpu.RegisterShadowDE },
- { "Shadow HL", cpu.RegisterShadowHL },
- { "SP", cpu.RegisterSP },
- { "Flag C", cpu.RegisterF.Bit(0) ? 1 : 0 },
- { "Flag N", cpu.RegisterF.Bit(1) ? 1 : 0 },
- { "Flag P/V", cpu.RegisterF.Bit(2) ? 1 : 0 },
- { "Flag 3rd", cpu.RegisterF.Bit(3) ? 1 : 0 },
- { "Flag H", cpu.RegisterF.Bit(4) ? 1 : 0 },
- { "Flag 5th", cpu.RegisterF.Bit(5) ? 1 : 0 },
- { "Flag Z", cpu.RegisterF.Bit(6) ? 1 : 0 },
- { "Flag S", cpu.RegisterF.Bit(7) ? 1 : 0 }
- };
- }
-
- public void SetCpuRegister(string register, int value)
- {
- switch (register)
- {
- default:
- throw new InvalidOperationException();
- case "A":
- cpu.RegisterA = (byte)value;
- break;
- case "AF":
- cpu.RegisterAF = (byte)value;
- break;
- case "B":
- cpu.RegisterB = (byte)value;
- break;
- case "BC":
- cpu.RegisterBC = (byte)value;
- break;
- case "C":
- cpu.RegisterC = (byte)value;
- break;
- case "D":
- cpu.RegisterD = (byte)value;
- break;
- case "DE":
- cpu.RegisterDE = (byte)value;
- break;
- case "E":
- cpu.RegisterE = (byte)value;
- break;
- case "F":
- cpu.RegisterF = (byte)value;
- break;
- case "H":
- cpu.RegisterH = (byte)value;
- break;
- case "HL":
- cpu.RegisterHL = (byte)value;
- break;
- case "I":
- cpu.RegisterI = (byte)value;
- break;
- case "IX":
- cpu.RegisterIX = (byte)value;
- break;
- case "IY":
- cpu.RegisterIY = (byte)value;
- break;
- case "L":
- cpu.RegisterL = (byte)value;
- break;
- case "PC":
- cpu.RegisterPC = (ushort)value;
- break;
- case "R":
- cpu.RegisterR = (byte)value;
- break;
- case "Shadow AF":
- cpu.RegisterShadowAF = (byte)value;
- break;
- case "Shadow BC":
- cpu.RegisterShadowBC = (byte)value;
- break;
- case "Shadow DE":
- cpu.RegisterShadowDE = (byte)value;
- break;
- case "Shadow HL":
- cpu.RegisterShadowHL = (byte)value;
- break;
- case "SP":
- cpu.RegisterSP = (byte)value;
- break;
- }
- }
}
}
\ No newline at end of file