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)
{
_syncSettings = (Global.Emulator as Intellivision).SyncSettings.Clone();
_syncSettings = (Global.Emulator as Intellivision).GetSyncSettings().Clone();
var possibleControllers = IntellivisionControllerDeck.ValidControllerTypes.Select(t => t.Key);

View File

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

View File

@ -12,9 +12,9 @@ namespace BizHawk.Emulation.Cores.Intellivision
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
{
@ -22,10 +22,10 @@ namespace BizHawk.Emulation.Cores.Intellivision
}
_frame++;
stic_row = -1;
_sticRow = -1;
// 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
int delay_cycles = 700;
@ -63,14 +63,14 @@ namespace BizHawk.Emulation.Cores.Intellivision
delay_cycles = -1;
delay_timer = 110;
_stic.ToggleSr2();
if (stic_row >= 0)
if (_sticRow >= 0)
{
_stic.in_vb_2 = true;
_stic.Background(stic_row);
_stic.Background(_sticRow);
_stic.in_vb_2 = false;
}
stic_row++;
_sticRow++;
}
Connect();
}

View File

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

View File

@ -47,7 +47,7 @@ namespace BizHawk.Emulation.Cores.Intellivision
ser.BeginSection("Intellivision");
ser.Sync("version", ref version);
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("SystemRam", ref SystemRam, false);

View File

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

View File

@ -11,22 +11,24 @@ namespace BizHawk.Emulation.Cores.Intellivision
isPorted: false,
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>
{
[CoreConstructor("INTV")]
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;
_rom = rom;
_gameInfo = game;
this.Settings = (IntvSettings)Settings ?? new IntvSettings();
this.SyncSettings = (IntvSyncSettings)SyncSettings ?? new IntvSyncSettings();
_settings = (IntvSettings)Settings ?? new IntvSettings();
_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("Reset");
@ -37,48 +39,53 @@ namespace BizHawk.Emulation.Cores.Intellivision
_cart.Parse(_rom);
}
_cpu = new CP1610();
_cpu.ReadMemory = ReadMemory;
_cpu.WriteMemory = WriteMemory;
_cpu = new CP1610
{
ReadMemory = ReadMemory,
WriteMemory = WriteMemory
};
_cpu.Reset();
_stic = new STIC();
_stic.ReadMemory = ReadMemory;
_stic.WriteMemory = WriteMemory;
_stic = new STIC
{
ReadMemory = ReadMemory,
WriteMemory = WriteMemory
};
_stic.Reset();
(ServiceProvider as BasicServiceProvider).Register<IVideoProvider>(_stic);
_psg = new PSG();
_psg = new PSG
{
ReadMemory = ReadMemory,
WriteMemory = WriteMemory
};
_psg.Reset();
_psg.ReadMemory = ReadMemory;
_psg.WriteMemory = WriteMemory;
(ServiceProvider as BasicServiceProvider).Register<ISoundProvider>(_psg);
ser.Register<IVideoProvider>(_stic);
ser.Register<ISoundProvider>(_psg);
Connect();
LoadExecutiveRom(CoreComm.CoreFileProvider.GetFirmware("INTV", "EROM", true, "Executive ROM is required."));
LoadGraphicsRom(CoreComm.CoreFileProvider.GetFirmware("INTV", "GROM", true, "Graphics ROM is required."));
Tracer = new TraceBuffer { Header = _cpu.TraceHeader };
(ServiceProvider as BasicServiceProvider).Register<ITraceable>(Tracer);
_tracer = new TraceBuffer { Header = _cpu.TraceHeader };
ser.Register<ITraceable>(_tracer);
SetupMemoryDomains();
}
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 STIC _stic;
private PSG _psg;
private int _frame;
private int stic_row;
private int _sticRow;
public void Connect()
{
@ -95,6 +102,7 @@ namespace BizHawk.Emulation.Cores.Intellivision
}
int index = 0;
// Combine every two bytes into a word.
while (index + 1 < erom.Length)
{
@ -112,7 +120,7 @@ namespace BizHawk.Emulation.Cores.Intellivision
GraphicsRom = grom;
}
public void get_controller_state()
private void GetControllerState()
{
InputCallbacks.Call();
@ -123,7 +131,7 @@ namespace BizHawk.Emulation.Cores.Intellivision
_psg.Register[14] = (ushort)(0xFF - port2);
}
void HardReset()
private void HardReset()
{
_cpu.Reset();
_stic.Reset();
@ -142,7 +150,7 @@ namespace BizHawk.Emulation.Cores.Intellivision
}
}
void SoftReset()
private void SoftReset()
{
_cpu.Reset();
_stic.Reset();