Intellivision - more cleanup

This commit is contained in:
adelikat 2017-04-23 11:10:26 -05:00
parent 0f36bce22a
commit 30aa86cd7e
7 changed files with 70 additions and 49 deletions

View File

@ -19,7 +19,7 @@ namespace BizHawk.Client.EmuHawk
private void IntvControllerSettings_Load(object sender, EventArgs e) private void IntvControllerSettings_Load(object sender, EventArgs e)
{ {
_syncSettings = (Global.Emulator as Intellivision).SyncSettings.Clone(); _syncSettings = (Global.Emulator as Intellivision).GetSyncSettings().Clone();
var possibleControllers = IntellivisionControllerDeck.ValidControllerTypes.Select(t => t.Key); var possibleControllers = IntellivisionControllerDeck.ValidControllerTypes.Select(t => t.Key);

View File

@ -16,9 +16,9 @@ namespace BizHawk.Client.EmuHawk
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core) public IEnumerable<PadSchema> GetPadSchemas(IEmulator core)
{ {
var intv = core as Intellivision; var intvSyncSettings = ((Intellivision)core).GetSyncSettings().Clone();
var port1 = intv.SyncSettings.Port1; var port1 = intvSyncSettings.Port1;
var port2 = intv.SyncSettings.Port2; var port2 = intvSyncSettings.Port2;
if (port1 == StandardControllerName) if (port1 == StandardControllerName)
{ {

View File

@ -12,9 +12,9 @@ namespace BizHawk.Emulation.Cores.Intellivision
public void FrameAdvance(bool render, bool rendersound) public void FrameAdvance(bool render, bool rendersound)
{ {
if (Tracer.Enabled) if (_tracer.Enabled)
{ {
_cpu.TraceCallback = (s) => Tracer.Put(s); _cpu.TraceCallback = (s) => _tracer.Put(s);
} }
else else
{ {
@ -22,10 +22,10 @@ namespace BizHawk.Emulation.Cores.Intellivision
} }
_frame++; _frame++;
stic_row = -1; _sticRow = -1;
// read the controller state here for now // read the controller state here for now
get_controller_state(); GetControllerState();
// this timer tracks cycles stolen by the STIC during the visible part of the frame, quite a large number of them actually // this timer tracks cycles stolen by the STIC during the visible part of the frame, quite a large number of them actually
int delay_cycles = 700; int delay_cycles = 700;
@ -63,14 +63,14 @@ namespace BizHawk.Emulation.Cores.Intellivision
delay_cycles = -1; delay_cycles = -1;
delay_timer = 110; delay_timer = 110;
_stic.ToggleSr2(); _stic.ToggleSr2();
if (stic_row >= 0) if (_sticRow >= 0)
{ {
_stic.in_vb_2 = true; _stic.in_vb_2 = true;
_stic.Background(stic_row); _stic.Background(_sticRow);
_stic.in_vb_2 = false; _stic.in_vb_2 = false;
} }
stic_row++; _sticRow++;
} }
Connect(); Connect();
} }

View File

@ -10,29 +10,29 @@ namespace BizHawk.Emulation.Cores.Intellivision
{ {
public IntvSettings GetSettings() public IntvSettings GetSettings()
{ {
return Settings.Clone(); return _settings.Clone();
} }
public IntvSyncSettings GetSyncSettings() public IntvSyncSettings GetSyncSettings()
{ {
return SyncSettings.Clone(); return _syncSettings.Clone();
} }
public bool PutSettings(IntvSettings o) public bool PutSettings(IntvSettings o)
{ {
Settings = o; _settings = o;
return false; return false;
} }
public bool PutSyncSettings(IntvSyncSettings o) public bool PutSyncSettings(IntvSyncSettings o)
{ {
bool ret = IntvSyncSettings.NeedsReboot(SyncSettings, o); bool ret = IntvSyncSettings.NeedsReboot(_syncSettings, o);
SyncSettings = o; _syncSettings = o;
return ret; return ret;
} }
public IntvSettings Settings = new IntvSettings(); private IntvSettings _settings = new IntvSettings();
public IntvSyncSettings SyncSettings = new IntvSyncSettings(); private IntvSyncSettings _syncSettings = new IntvSyncSettings();
public class IntvSettings public class IntvSettings
{ {

View File

@ -47,7 +47,7 @@ namespace BizHawk.Emulation.Cores.Intellivision
ser.BeginSection("Intellivision"); ser.BeginSection("Intellivision");
ser.Sync("version", ref version); ser.Sync("version", ref version);
ser.Sync("Frame", ref _frame); ser.Sync("Frame", ref _frame);
ser.Sync("stic_row", ref stic_row); ser.Sync("stic_row", ref _sticRow);
ser.Sync("ScratchpadRam", ref ScratchpadRam, false); ser.Sync("ScratchpadRam", ref ScratchpadRam, false);
ser.Sync("SystemRam", ref SystemRam, false); ser.Sync("SystemRam", ref SystemRam, false);

View File

@ -205,6 +205,7 @@
{ {
return (ushort)core; return (ushort)core;
} }
return UNMAPPED; return UNMAPPED;
} }
@ -268,6 +269,7 @@
GraphicsRam[addr - 0x3800] = (byte)(value & 0x00FF); GraphicsRam[addr - 0x3800] = (byte)(value & 0x00FF);
return true; return true;
} }
return false; return false;
} }
else if (addr <= 0x3BFF) else if (addr <= 0x3BFF)
@ -277,6 +279,7 @@
GraphicsRam[addr - 0x3A00] = (byte)(value & 0x00FF); GraphicsRam[addr - 0x3A00] = (byte)(value & 0x00FF);
return true; return true;
} }
return false; return false;
} }
else if (addr <= 0x3DFF) else if (addr <= 0x3DFF)
@ -286,6 +289,7 @@
GraphicsRam[addr - 0x3C00] = (byte)(value & 0x00FF); GraphicsRam[addr - 0x3C00] = (byte)(value & 0x00FF);
return true; return true;
} }
return false; return false;
} }
else else
@ -295,6 +299,7 @@
GraphicsRam[addr - 0x3E00] = (byte)(value & 0x00FF); GraphicsRam[addr - 0x3E00] = (byte)(value & 0x00FF);
return true; return true;
} }
return false; return false;
} }
case 0x7000: case 0x7000:
@ -310,6 +315,7 @@
GraphicsRam[addr & 0x01FF] = (byte)(value & 0x00FF); GraphicsRam[addr & 0x01FF] = (byte)(value & 0x00FF);
return true; return true;
} }
return false; return false;
} }
else if (addr <= 0x7BFF) else if (addr <= 0x7BFF)
@ -319,6 +325,7 @@
GraphicsRam[addr & 0x01FF] = (byte)(value & 0x00FF); GraphicsRam[addr & 0x01FF] = (byte)(value & 0x00FF);
return true; return true;
} }
return false; return false;
} }
else if (addr <= 0x7DFF) else if (addr <= 0x7DFF)
@ -328,6 +335,7 @@
GraphicsRam[addr & 0x01FF] = (byte)(value & 0x00FF); GraphicsRam[addr & 0x01FF] = (byte)(value & 0x00FF);
return true; return true;
} }
return false; return false;
} }
else else
@ -337,6 +345,7 @@
GraphicsRam[addr & 0x01FF] = (byte)(value & 0x00FF); GraphicsRam[addr & 0x01FF] = (byte)(value & 0x00FF);
return true; return true;
} }
return false; return false;
} }
case 0x9000: case 0x9000:
@ -397,6 +406,7 @@
GraphicsRam[addr - 0xF800] = (byte)(value & 0x00FF); GraphicsRam[addr - 0xF800] = (byte)(value & 0x00FF);
return true; return true;
} }
return false; return false;
} }
else if (addr <= 0xFBFF) else if (addr <= 0xFBFF)
@ -406,6 +416,7 @@
GraphicsRam[addr - 0xFA00] = (byte)(value & 0x00FF); GraphicsRam[addr - 0xFA00] = (byte)(value & 0x00FF);
return true; return true;
} }
return false; return false;
} }
else if (addr <= 0xFDFF) else if (addr <= 0xFDFF)
@ -415,6 +426,7 @@
GraphicsRam[addr - 0xFC00] = (byte)(value & 0x00FF); GraphicsRam[addr - 0xFC00] = (byte)(value & 0x00FF);
return true; return true;
} }
return false; return false;
} }
else else
@ -424,6 +436,7 @@
GraphicsRam[addr - 0xFE00] = (byte)(value & 0x00FF); GraphicsRam[addr - 0xFE00] = (byte)(value & 0x00FF);
return true; return true;
} }
return false; return false;
} }
} }

View File

@ -11,22 +11,24 @@ namespace BizHawk.Emulation.Cores.Intellivision
isPorted: false, isPorted: false,
isReleased: true isReleased: true
)] )]
[ServiceNotApplicable(typeof(ISaveRam), typeof(IDriveLight))] [ServiceNotApplicable(typeof(ISaveRam), typeof(IDriveLight), typeof(IRegionable))]
public sealed partial class Intellivision : IEmulator, IStatable, IInputPollable, ISettable<Intellivision.IntvSettings, Intellivision.IntvSyncSettings> public sealed partial class Intellivision : IEmulator, IStatable, IInputPollable, ISettable<Intellivision.IntvSettings, Intellivision.IntvSyncSettings>
{ {
[CoreConstructor("INTV")] [CoreConstructor("INTV")]
public Intellivision(CoreComm comm, GameInfo game, byte[] rom, object Settings, object SyncSettings) public Intellivision(CoreComm comm, GameInfo game, byte[] rom, object Settings, object SyncSettings)
{ {
ServiceProvider = new BasicServiceProvider(this); var ser = new BasicServiceProvider(this);
ServiceProvider = ser;
CoreComm = comm; CoreComm = comm;
_rom = rom; _rom = rom;
_gameInfo = game; _gameInfo = game;
this.Settings = (IntvSettings)Settings ?? new IntvSettings(); _settings = (IntvSettings)Settings ?? new IntvSettings();
this.SyncSettings = (IntvSyncSettings)SyncSettings ?? new IntvSyncSettings(); _syncSettings = (IntvSyncSettings)SyncSettings ?? new IntvSyncSettings();
ControllerDeck = new IntellivisionControllerDeck(this.SyncSettings.Port1, this.SyncSettings.Port2); ControllerDeck = new IntellivisionControllerDeck(_syncSettings.Port1, _syncSettings.Port2);
ControllerDefinition.BoolButtons.Add("Power"); ControllerDefinition.BoolButtons.Add("Power");
ControllerDefinition.BoolButtons.Add("Reset"); ControllerDefinition.BoolButtons.Add("Reset");
@ -37,48 +39,53 @@ namespace BizHawk.Emulation.Cores.Intellivision
_cart.Parse(_rom); _cart.Parse(_rom);
} }
_cpu = new CP1610(); _cpu = new CP1610
_cpu.ReadMemory = ReadMemory; {
_cpu.WriteMemory = WriteMemory; ReadMemory = ReadMemory,
WriteMemory = WriteMemory
};
_cpu.Reset(); _cpu.Reset();
_stic = new STIC(); _stic = new STIC
_stic.ReadMemory = ReadMemory; {
_stic.WriteMemory = WriteMemory; ReadMemory = ReadMemory,
WriteMemory = WriteMemory
};
_stic.Reset(); _stic.Reset();
(ServiceProvider as BasicServiceProvider).Register<IVideoProvider>(_stic);
_psg = new PSG(); _psg = new PSG
{
ReadMemory = ReadMemory,
WriteMemory = WriteMemory
};
_psg.Reset(); _psg.Reset();
_psg.ReadMemory = ReadMemory;
_psg.WriteMemory = WriteMemory; ser.Register<IVideoProvider>(_stic);
(ServiceProvider as BasicServiceProvider).Register<ISoundProvider>(_psg); ser.Register<ISoundProvider>(_psg);
Connect(); Connect();
LoadExecutiveRom(CoreComm.CoreFileProvider.GetFirmware("INTV", "EROM", true, "Executive ROM is required.")); LoadExecutiveRom(CoreComm.CoreFileProvider.GetFirmware("INTV", "EROM", true, "Executive ROM is required."));
LoadGraphicsRom(CoreComm.CoreFileProvider.GetFirmware("INTV", "GROM", true, "Graphics ROM is required.")); LoadGraphicsRom(CoreComm.CoreFileProvider.GetFirmware("INTV", "GROM", true, "Graphics ROM is required."));
Tracer = new TraceBuffer { Header = _cpu.TraceHeader }; _tracer = new TraceBuffer { Header = _cpu.TraceHeader };
(ServiceProvider as BasicServiceProvider).Register<ITraceable>(Tracer); ser.Register<ITraceable>(_tracer);
SetupMemoryDomains(); SetupMemoryDomains();
} }
public IntellivisionControllerDeck ControllerDeck { get; private set; } public IntellivisionControllerDeck ControllerDeck { get; private set; }
private ITraceable Tracer { get; set; } private readonly byte[] _rom;
private readonly GameInfo _gameInfo;
private readonly ITraceable _tracer;
private readonly CP1610 _cpu;
private readonly STIC _stic;
private readonly PSG _psg;
private byte[] _rom;
private GameInfo _gameInfo;
private CP1610 _cpu;
private ICart _cart; private ICart _cart;
private STIC _stic;
private PSG _psg;
private int _frame; private int _frame;
private int stic_row; private int _sticRow;
public void Connect() public void Connect()
{ {
@ -95,6 +102,7 @@ namespace BizHawk.Emulation.Cores.Intellivision
} }
int index = 0; int index = 0;
// Combine every two bytes into a word. // Combine every two bytes into a word.
while (index + 1 < erom.Length) while (index + 1 < erom.Length)
{ {
@ -112,7 +120,7 @@ namespace BizHawk.Emulation.Cores.Intellivision
GraphicsRom = grom; GraphicsRom = grom;
} }
public void get_controller_state() private void GetControllerState()
{ {
InputCallbacks.Call(); InputCallbacks.Call();
@ -123,7 +131,7 @@ namespace BizHawk.Emulation.Cores.Intellivision
_psg.Register[14] = (ushort)(0xFF - port2); _psg.Register[14] = (ushort)(0xFF - port2);
} }
void HardReset() private void HardReset()
{ {
_cpu.Reset(); _cpu.Reset();
_stic.Reset(); _stic.Reset();
@ -142,7 +150,7 @@ namespace BizHawk.Emulation.Cores.Intellivision
} }
} }
void SoftReset() private void SoftReset()
{ {
_cpu.Reset(); _cpu.Reset();
_stic.Reset(); _stic.Reset();