C64: Drive light reflects both cartridge LED and disk drive now.

This commit is contained in:
Anthony Konzel 2016-03-05 16:00:19 -06:00
parent 8fd552274e
commit 178457309a
7 changed files with 19 additions and 13 deletions

View File

@ -4,7 +4,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64
{ {
public partial class C64 : IDriveLight public partial class C64 : IDriveLight
{ {
public bool DriveLightEnabled { get { return true; } } public bool DriveLightEnabled { get { return _board != null && (_board.CartPort.DriveLightEnabled || _board.Serial.DriveLightEnabled); } }
public bool DriveLightOn { get; private set; } public bool DriveLightOn { get { return _board != null && (_board.CartPort.DriveLightOn || _board.Serial.DriveLightOn);} }
} }
} }

View File

@ -20,7 +20,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64
)] )]
[ServiceNotApplicable(typeof(ISettable<,>))] [ServiceNotApplicable(typeof(ISettable<,>))]
public sealed partial class C64 : IEmulator, IRegionable public sealed partial class C64 : IEmulator, IRegionable
{ {
// framework // framework
public C64(CoreComm comm, GameInfo game, byte[] rom, object settings, object syncSettings) 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<IVideoProvider>(_board.Vic); ((BasicServiceProvider) ServiceProvider).Register<IVideoProvider>(_board.Vic);
((BasicServiceProvider) ServiceProvider).Register<IDriveLight>(_board.Serial); ((BasicServiceProvider) ServiceProvider).Register<IDriveLight>(this);
} }
// internal variables // internal variables

View File

@ -3,10 +3,11 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using BizHawk.Common; using BizHawk.Common;
using BizHawk.Emulation.Common;
namespace BizHawk.Emulation.Cores.Computers.Commodore64.Cartridge namespace BizHawk.Emulation.Cores.Computers.Commodore64.Cartridge
{ {
public abstract partial class CartridgeDevice public abstract partial class CartridgeDevice : IDriveLight
{ {
public static CartridgeDevice Load(byte[] crtFile) 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 virtual void WriteDF00(int addr, int val)
{ {
} }
public bool DriveLightEnabled { get; protected set; }
public bool DriveLightOn { get; protected set; }
} }
} }

View File

@ -1,8 +1,9 @@
using BizHawk.Common; using BizHawk.Common;
using BizHawk.Emulation.Common;
namespace BizHawk.Emulation.Cores.Computers.Commodore64.Cartridge namespace BizHawk.Emulation.Cores.Computers.Commodore64.Cartridge
{ {
public sealed class CartridgePort public sealed class CartridgePort : IDriveLight
{ {
private CartridgeDevice _cartridgeDevice; private CartridgeDevice _cartridgeDevice;
private bool _connected; private bool _connected;
@ -126,5 +127,8 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Cartridge
{ {
SaveState.SyncObject(ser, this); SaveState.SyncObject(ser, this);
} }
public bool DriveLightEnabled { get { return _connected && _cartridgeDevice.DriveLightEnabled; } }
public bool DriveLightOn { get { return _connected && _cartridgeDevice.DriveLightOn; } }
} }
} }

View File

@ -53,6 +53,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Cartridge
public Mapper0020(IList<int> newAddresses, IList<int> newBanks, IList<int[]> newData) public Mapper0020(IList<int> newAddresses, IList<int> newBanks, IList<int[]> newData)
{ {
DriveLightEnabled = true;
var count = newAddresses.Count; var count = newAddresses.Count;
// force ultimax mode (the cart SHOULD set this // force ultimax mode (the cart SHOULD set this
@ -194,6 +195,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Cartridge
pinExRom = (val & 0x02) == 0; pinExRom = (val & 0x02) == 0;
_boardLed = (val & 0x80) != 0; _boardLed = (val & 0x80) != 0;
_internalRomState = 0; _internalRomState = 0;
DriveLightOn = _boardLed;
} }
public override void Write8000(int addr, int val) 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("MediaStateA", ser, _originalMediaA, ref _banksA);
SaveState.SyncDelta("MediaStateB", ser, _originalMediaB, ref _banksB); SaveState.SyncDelta("MediaStateB", ser, _originalMediaB, ref _banksB);
base.SyncState(ser); base.SyncState(ser);
DriveLightOn = _boardLed;
} }
} }
} }

View File

@ -25,8 +25,6 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Serial
private bool _byteReady; private bool _byteReady;
[SaveState.SaveWithName("DriveCpuClockNumerator")] [SaveState.SaveWithName("DriveCpuClockNumerator")]
private readonly int _driveCpuClockNum; private readonly int _driveCpuClockNum;
[SaveState.SaveWithName("DriveCpuClockDenominator")]
private readonly int _driveCpuClockDen;
[SaveState.SaveWithName("TrackNumber")] [SaveState.SaveWithName("TrackNumber")]
private int _trackNumber; private int _trackNumber;
[SaveState.SaveWithName("MotorEnabled")] [SaveState.SaveWithName("MotorEnabled")]
@ -35,8 +33,6 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Serial
private bool _ledEnabled; private bool _ledEnabled;
[SaveState.SaveWithName("MotorStep")] [SaveState.SaveWithName("MotorStep")]
private int _motorStep; private int _motorStep;
[SaveState.DoNotSave]
private int _via0PortBtemp;
[SaveState.SaveWithName("CPU")] [SaveState.SaveWithName("CPU")]
private readonly MOS6502X _cpu; private readonly MOS6502X _cpu;
[SaveState.SaveWithName("RAM")] [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.IRQ = !(Via0.Irq && Via1.Irq); // active low IRQ line
_cpu.ExecuteOne(); _cpu.ExecuteOne();
_via0PortBtemp = Via0.EffectivePrB;
_ledEnabled = (_via0PortBtemp & 0x08) != 0;
if (_ledEnabled) if (_ledEnabled)
{ {
_driveLightOffTime = 25000; _driveLightOffTime = 25000;

View File

@ -84,5 +84,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Serial
public bool DriveLightEnabled { get { return true; } } public bool DriveLightEnabled { get { return true; } }
[SaveState.DoNotSave] [SaveState.DoNotSave]
public bool DriveLightOn { get { return ReadDeviceLight(); } } public bool DriveLightOn { get { return ReadDeviceLight(); } }
[SaveState.DoNotSave]
public bool IsConnected { get { return _connected; } }
} }
} }