diff --git a/BizHawk.Client.EmuHawk/config/INTV/IntvControllerSettings.cs b/BizHawk.Client.EmuHawk/config/INTV/IntvControllerSettings.cs index ddc88c89c6..42d4e28484 100644 --- a/BizHawk.Client.EmuHawk/config/INTV/IntvControllerSettings.cs +++ b/BizHawk.Client.EmuHawk/config/INTV/IntvControllerSettings.cs @@ -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); diff --git a/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/IntvSchema.cs b/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/IntvSchema.cs index 8f889a687d..4937699157 100644 --- a/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/IntvSchema.cs +++ b/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/IntvSchema.cs @@ -16,9 +16,9 @@ namespace BizHawk.Client.EmuHawk public IEnumerable 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) { diff --git a/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.IEmulator.cs b/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.IEmulator.cs index 05538860d4..9e1599675d 100644 --- a/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.IEmulator.cs +++ b/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.IEmulator.cs @@ -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(); } diff --git a/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.ISettable.cs b/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.ISettable.cs index 2551687a28..2097ac67e8 100644 --- a/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.ISettable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.ISettable.cs @@ -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 { diff --git a/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.IStatable.cs b/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.IStatable.cs index dbd1d05759..423dbfb3e2 100644 --- a/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.IStatable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.IStatable.cs @@ -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); diff --git a/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.MemoryMap.cs b/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.MemoryMap.cs index 760e02f2df..4b70a918d5 100644 --- a/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.MemoryMap.cs +++ b/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.MemoryMap.cs @@ -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; } } diff --git a/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.cs b/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.cs index 9a5d6888d6..d37bcea8c1 100644 --- a/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.cs +++ b/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.cs @@ -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 { [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(_stic); - _psg = new PSG(); + _psg = new PSG + { + ReadMemory = ReadMemory, + WriteMemory = WriteMemory + }; _psg.Reset(); - _psg.ReadMemory = ReadMemory; - _psg.WriteMemory = WriteMemory; - (ServiceProvider as BasicServiceProvider).Register(_psg); + + ser.Register(_stic); + ser.Register(_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(Tracer); + _tracer = new TraceBuffer { Header = _cpu.TraceHeader }; + ser.Register(_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();