diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IDriveLight.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IDriveLight.cs index 7a1834497d..d782403dea 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IDriveLight.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IDriveLight.cs @@ -4,7 +4,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 { public partial class C64 : IDriveLight { - public bool DriveLightEnabled { get { return true; } } - public bool DriveLightOn { get; private set; } + public bool DriveLightEnabled { get { return _board != null && (_board.CartPort.DriveLightEnabled || _board.Serial.DriveLightEnabled); } } + public bool DriveLightOn { get { return _board != null && (_board.CartPort.DriveLightOn || _board.Serial.DriveLightOn);} } } } diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.cs index 632e72073d..6c4a061b85 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.cs @@ -20,7 +20,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 )] [ServiceNotApplicable(typeof(ISettable<,>))] public sealed partial class C64 : IEmulator, IRegionable - { + { // framework public C64(CoreComm comm, GameInfo game, byte[] rom, object settings, object syncSettings) { @@ -51,7 +51,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 } ((BasicServiceProvider) ServiceProvider).Register(_board.Vic); - ((BasicServiceProvider) ServiceProvider).Register(_board.Serial); + ((BasicServiceProvider) ServiceProvider).Register(this); } // internal variables diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/CartridgeDevice.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/CartridgeDevice.cs index 2c7ef4fddc..7fed92029f 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/CartridgeDevice.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/CartridgeDevice.cs @@ -3,10 +3,11 @@ using System.Collections.Generic; using System.IO; using System.Linq; using BizHawk.Common; +using BizHawk.Emulation.Common; namespace BizHawk.Emulation.Cores.Computers.Commodore64.Cartridge { - public abstract partial class CartridgeDevice + public abstract partial class CartridgeDevice : IDriveLight { public static CartridgeDevice Load(byte[] crtFile) { @@ -273,5 +274,8 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Cartridge public virtual void WriteDF00(int addr, int val) { } + + public bool DriveLightEnabled { get; protected set; } + public bool DriveLightOn { get; protected set; } } } diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/CartridgePort.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/CartridgePort.cs index c980d8ae85..9ca7f2112b 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/CartridgePort.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/CartridgePort.cs @@ -1,8 +1,9 @@ using BizHawk.Common; +using BizHawk.Emulation.Common; namespace BizHawk.Emulation.Cores.Computers.Commodore64.Cartridge { - public sealed class CartridgePort + public sealed class CartridgePort : IDriveLight { private CartridgeDevice _cartridgeDevice; private bool _connected; @@ -126,5 +127,8 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Cartridge { SaveState.SyncObject(ser, this); } + + public bool DriveLightEnabled { get { return _connected && _cartridgeDevice.DriveLightEnabled; } } + public bool DriveLightOn { get { return _connected && _cartridgeDevice.DriveLightOn; } } } } diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper0020.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper0020.cs index ffb5906798..3bac7c0e69 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper0020.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper0020.cs @@ -53,6 +53,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Cartridge public Mapper0020(IList newAddresses, IList newBanks, IList newData) { + DriveLightEnabled = true; var count = newAddresses.Count; // force ultimax mode (the cart SHOULD set this @@ -194,6 +195,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Cartridge pinExRom = (val & 0x02) == 0; _boardLed = (val & 0x80) != 0; _internalRomState = 0; + DriveLightOn = _boardLed; } public override void Write8000(int addr, int val) @@ -289,6 +291,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Cartridge SaveState.SyncDelta("MediaStateA", ser, _originalMediaA, ref _banksA); SaveState.SyncDelta("MediaStateB", ser, _originalMediaB, ref _banksB); base.SyncState(ser); + DriveLightOn = _boardLed; } } } diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/Serial/Drive1541.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/Serial/Drive1541.cs index e7afd30f56..1397450b1c 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/Serial/Drive1541.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/Serial/Drive1541.cs @@ -25,8 +25,6 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Serial private bool _byteReady; [SaveState.SaveWithName("DriveCpuClockNumerator")] private readonly int _driveCpuClockNum; - [SaveState.SaveWithName("DriveCpuClockDenominator")] - private readonly int _driveCpuClockDen; [SaveState.SaveWithName("TrackNumber")] private int _trackNumber; [SaveState.SaveWithName("MotorEnabled")] @@ -35,8 +33,6 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Serial private bool _ledEnabled; [SaveState.SaveWithName("MotorStep")] private int _motorStep; - [SaveState.DoNotSave] - private int _via0PortBtemp; [SaveState.SaveWithName("CPU")] private readonly MOS6502X _cpu; [SaveState.SaveWithName("RAM")] @@ -114,9 +110,6 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Serial _cpu.IRQ = !(Via0.Irq && Via1.Irq); // active low IRQ line _cpu.ExecuteOne(); - _via0PortBtemp = Via0.EffectivePrB; - _ledEnabled = (_via0PortBtemp & 0x08) != 0; - if (_ledEnabled) { _driveLightOffTime = 25000; diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/Serial/SerialPort.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/Serial/SerialPort.cs index 9e16296ad2..25b9debb42 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/Serial/SerialPort.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/Serial/SerialPort.cs @@ -84,5 +84,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Serial public bool DriveLightEnabled { get { return true; } } [SaveState.DoNotSave] public bool DriveLightOn { get { return ReadDeviceLight(); } } + [SaveState.DoNotSave] + public bool IsConnected { get { return _connected; } } } }