diff --git a/BizHawk.Emulation.Common/Database/FirmwareDatabase.cs b/BizHawk.Emulation.Common/Database/FirmwareDatabase.cs
index fd841ef1c0..d94537b65d 100644
--- a/BizHawk.Emulation.Common/Database/FirmwareDatabase.cs
+++ b/BizHawk.Emulation.Common/Database/FirmwareDatabase.cs
@@ -46,13 +46,16 @@ namespace BizHawk.Emulation.Common
//FirmwareAndOption("BFAAC75F101C135E32E2AAF541DE6B1BE4C8C62D", "NDS", "Bios_Arm9", "biosnds9.rom", "ARM9 Bios");
FirmwareAndOption("5A65B922B562CB1F57DAB51B73151283F0E20C7A", 8192, "INTV", "EROM", "erom.bin", "Executive Rom");
FirmwareAndOption("F9608BB4AD1CFE3640D02844C7AD8E0BCD974917", 2048, "INTV", "GROM", "grom.bin", "Graphics Rom");
+
FirmwareAndOption("1D503E56DF85A62FEE696E7618DC5B4E781DF1BB", 8192, "C64", "Kernal", "c64-kernal.bin", "Kernal Rom");
FirmwareAndOption("79015323128650C742A3694C9429AA91F355905E", 8192, "C64", "Basic", "c64-basic.bin", "Basic Rom");
FirmwareAndOption("ADC7C31E18C7C7413D54802EF2F4193DA14711AA", 4096, "C64", "Chargen", "c64-chargen.bin", "Chargen Rom");
+ FirmwareAndOption("AB16F56989B27D89BABE5F89C5A8CB3DA71A82F0", 16384, "C64", "Drive1541", "drive-1541.bin", "1541 Disk Drive Rom");
+ FirmwareAndOption("D3B78C3DBAC55F5199F33F3FE0036439811F7FB3", 16384, "C64", "Drive1541II", "drive-1541ii.bin", "1541-II Disk Drive Rom");
- //for saturn, we think any bios region can pretty much run any iso
- //so, we're going to lay this out carefully so that we choose things in a sensible order, but prefer the correct region
- var ss_100_j = File("2B8CB4F87580683EB4D760E4ED210813D667F0A2", 524288, "saturn-1.00-(J).bin", "Bios v1.00 (J)");
+ //for saturn, we think any bios region can pretty much run any iso
+ //so, we're going to lay this out carefully so that we choose things in a sensible order, but prefer the correct region
+ var ss_100_j = File("2B8CB4F87580683EB4D760E4ED210813D667F0A2", 524288, "saturn-1.00-(J).bin", "Bios v1.00 (J)");
var ss_100_ue = File("FAA8EA183A6D7BBE5D4E03BB1332519800D3FBC3", 524288, "saturn-1.00-(U+E).bin", "Bios v1.00 (U+E)");
var ss_100a_ue = File("3BB41FEB82838AB9A35601AC666DE5AACFD17A58", 524288, "saturn-1.00a-(U+E).bin", "Bios v1.00a (U+E)"); //?? is this size correct?
var ss_101_j = File("DF94C5B4D47EB3CC404D88B33A8FDA237EAF4720", 524288, "saturn-1.01-(J).bin", "Bios v1.01 (J)"); //?? is this size correct?
diff --git a/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj b/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj
index e729bc31ad..f2fe4a4d32 100644
--- a/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj
+++ b/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj
@@ -177,37 +177,54 @@
-
-
+
+
+
-
-
+
+
+
-
+
-
-
-
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
@@ -217,7 +234,7 @@
-
+
Atari2600.cs
@@ -926,7 +943,6 @@
-
@@ -969,7 +985,6 @@
-
diff --git a/BizHawk.Emulation.Cores/CPUs/MOS 6502X/MOS6502X.cs b/BizHawk.Emulation.Cores/CPUs/MOS 6502X/MOS6502X.cs
index 684be9377d..46384b15a1 100644
--- a/BizHawk.Emulation.Cores/CPUs/MOS 6502X/MOS6502X.cs
+++ b/BizHawk.Emulation.Cores/CPUs/MOS 6502X/MOS6502X.cs
@@ -243,6 +243,12 @@ namespace BizHawk.Emulation.Cores.Components.M6502
return (ushort)(ReadMemory(address) | (ReadMemory(highAddress) << 8));
}
+ // SO pin
+ public void SetOverflow()
+ {
+ FlagV = true;
+ }
+
private static readonly byte[] TableNZ =
{
0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IDebuggable.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IDebuggable.cs
index 8e29874b02..ad389ed80b 100644
--- a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IDebuggable.cs
+++ b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IDebuggable.cs
@@ -1,160 +1,69 @@
using System;
using System.Collections.Generic;
-
+using System.Linq;
using BizHawk.Emulation.Common;
namespace BizHawk.Emulation.Cores.Computers.Commodore64
{
public partial class C64 : IDebuggable
{
- public IDictionary GetCpuFlagsAndRegisters()
+ [SaveState.DoNotSave] private IDebuggable _selectedDebuggable;
+
+ private IEnumerable GetAvailableDebuggables()
+ {
+ yield return _board.Cpu;
+ if (_board.DiskDrive != null)
+ {
+ yield return _board.DiskDrive;
+ }
+ }
+
+ private void SetDefaultDebuggable()
+ {
+ _selectedDebuggable = GetAvailableDebuggables().First();
+ }
+
+ IDictionary IDebuggable.GetCpuFlagsAndRegisters()
{
- return new Dictionary
- {
- { "A", board.cpu.A },
- { "X", board.cpu.X },
- { "Y", board.cpu.Y },
- { "S", board.cpu.S },
- { "PC", board.cpu.PC },
- { "Flag C", board.cpu.FlagC },
- { "Flag Z", board.cpu.FlagZ },
- { "Flag I", board.cpu.FlagI },
- { "Flag D", board.cpu.FlagD },
- { "Flag B", board.cpu.FlagB },
- { "Flag V", board.cpu.FlagV },
- { "Flag N", board.cpu.FlagN },
- { "Flag T", board.cpu.FlagT }
- };
+ if (_selectedDebuggable == null)
+ {
+ SetDefaultDebuggable();
+ }
+ return _selectedDebuggable.GetCpuFlagsAndRegisters();
}
- public void SetCpuRegister(string register, int value)
+ void IDebuggable.SetCpuRegister(string register, int value)
{
- switch (register)
- {
- default:
- throw new InvalidOperationException();
- case "A":
- board.cpu.A = (byte)value;
- break;
- case "X":
- board.cpu.X = (byte)value;
- break;
- case "Y":
- board.cpu.Y = (byte)value;
- break;
- case "S":
- board.cpu.S = (byte)value;
- break;
- case "PC":
- board.cpu.PC = (ushort)value;
- break;
- }
+ if (_selectedDebuggable == null)
+ {
+ SetDefaultDebuggable();
+ }
+ _selectedDebuggable.SetCpuRegister(register, value);
}
- public bool CanStep(StepType type)
+ bool IDebuggable.CanStep(StepType type)
{
- switch (type)
- {
- case StepType.Into:
- case StepType.Over:
- case StepType.Out:
- return true;
- default:
- return false;
- }
+ if (_selectedDebuggable == null)
+ {
+ SetDefaultDebuggable();
+ }
+ return _selectedDebuggable.CanStep(type);
}
- public void Step(StepType type)
+ void IDebuggable.Step(StepType type)
{
- switch (type)
- {
- case StepType.Into:
- StepInto();
- break;
- case StepType.Out:
- StepOut();
- break;
- case StepType.Over:
- StepOver();
- break;
- }
+ if (_selectedDebuggable == null)
+ {
+ SetDefaultDebuggable();
+ }
+ _selectedDebuggable.Step(type);
}
- private void StepInto()
- {
- while (board.cpu.AtInstructionStart())
- {
- DoCycle();
- }
- while (!board.cpu.AtInstructionStart())
- {
- DoCycle();
- }
- }
+ [SaveState.DoNotSave]
+ private readonly IMemoryCallbackSystem _memoryCallbacks;
- private void StepOver()
- {
- var instruction = board.cpu.Peek(board.cpu.PC);
-
- if (instruction == JSR)
- {
- var destination = board.cpu.PC + JSRSize;
- while (board.cpu.PC != destination)
- {
- StepInto();
- }
- }
- else
- {
- StepInto();
- }
- }
-
- private void StepOut()
- {
- var instr = board.cpu.Peek(board.cpu.PC);
-
- JSRCount = instr == JSR ? 1 : 0;
-
- var bailOutFrame = Frame + 1;
-
- while (true)
- {
- StepInto();
- instr = board.cpu.Peek(board.cpu.PC);
- if (instr == JSR)
- {
- JSRCount++;
- }
- else if ((instr == RTS || instr == RTI) && JSRCount <= 0)
- {
- StepInto();
- JSRCount = 0;
- break;
- }
- else if (instr == RTS || instr == RTI)
- {
- JSRCount--;
- }
- else //Emergency Bailout Logic
- {
- if (Frame == bailOutFrame)
- {
- break;
- }
- }
- }
- }
-
- private int JSRCount = 0;
-
- private const byte JSR = 0x20;
- private const byte RTI = 0x40;
- private const byte RTS = 0x60;
-
- private const byte JSRSize = 3;
-
- public IMemoryCallbackSystem MemoryCallbacks { get; private set; }
+ [SaveState.DoNotSave]
+ IMemoryCallbackSystem IDebuggable.MemoryCallbacks { get { return _memoryCallbacks; } }
}
}
diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IDisassemblable.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IDisassemblable.cs
index 9afa0b3220..787d07fe42 100644
--- a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IDisassemblable.cs
+++ b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IDisassemblable.cs
@@ -1,30 +1,76 @@
-using System;
-using System.Collections.Generic;
-
-using BizHawk.Emulation.Common;
-
-namespace BizHawk.Emulation.Cores.Computers.Commodore64
-{
- public partial class C64 : IDisassemblable
- {
- public string Cpu
- {
- get { return "6510"; } set { }
- }
-
- public string PCRegisterName
- {
- get { return "PC"; }
- }
-
- public IEnumerable AvailableCpus
- {
- get { yield return "6510"; }
- }
-
- public string Disassemble(MemoryDomain m, uint addr, out int length)
- {
- return Components.M6502.MOS6502X.Disassemble((ushort)addr, out length, (a) => m.PeekByte(a));
- }
- }
-}
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using BizHawk.Emulation.Common;
+
+namespace BizHawk.Emulation.Cores.Computers.Commodore64
+{
+ public partial class C64 : IDisassemblable
+ {
+ [SaveState.DoNotSave] private IDisassemblable _selectedDisassemblable;
+
+ private IEnumerable GetAvailableDisassemblables()
+ {
+ yield return _board.Cpu;
+ if (_board.DiskDrive != null)
+ {
+ yield return _board.DiskDrive;
+ }
+ }
+
+ private void SetDefaultDisassemblable()
+ {
+ _selectedDisassemblable = GetAvailableDisassemblables().First();
+ }
+
+ [SaveState.DoNotSave]
+ public string Cpu
+ {
+ get
+ {
+ if (_selectedDisassemblable == null)
+ {
+ SetDefaultDisassemblable();
+ }
+ return _selectedDisassemblable.Cpu;
+ }
+ set
+ {
+ var currentSelectedDisassemblable = _selectedDisassemblable;
+ _selectedDisassemblable = GetAvailableDisassemblables().FirstOrDefault(d => d.Cpu == value) ?? currentSelectedDisassemblable;
+ if (_selectedDisassemblable is IDebuggable)
+ {
+ _selectedDebuggable = _selectedDisassemblable as IDebuggable;
+ }
+ }
+ }
+
+ [SaveState.DoNotSave]
+ public string PCRegisterName
+ {
+ get
+ {
+ if (_selectedDisassemblable == null)
+ {
+ SetDefaultDisassemblable();
+ }
+ return _selectedDisassemblable.PCRegisterName;
+ }
+ }
+
+ [SaveState.DoNotSave]
+ public IEnumerable AvailableCpus
+ {
+ get { return GetAvailableDisassemblables().SelectMany(d => d.AvailableCpus); }
+ }
+
+ public string Disassemble(MemoryDomain m, uint addr, out int length)
+ {
+ if (_selectedDisassemblable == null)
+ {
+ SetDefaultDisassemblable();
+ }
+ return _selectedDisassemblable.Disassemble(m, addr, out length);
+ }
+ }
+}
diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IDriveLight.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IDriveLight.cs
index 769c1d79e5..7a1834497d 100644
--- a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IDriveLight.cs
+++ b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IDriveLight.cs
@@ -6,14 +6,5 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64
{
public bool DriveLightEnabled { get { return true; } }
public bool DriveLightOn { get; private set; }
-
- public bool DriveLED
- {
- get
- {
- //return (disk.PeekVia1(0x00) & 0x08) != 0;
- return false;
- }
- }
}
}
diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IInputPollable.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IInputPollable.cs
index fd668b5830..8f5ca1d344 100644
--- a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IInputPollable.cs
+++ b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IInputPollable.cs
@@ -4,21 +4,10 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64
{
public partial class C64 : IInputPollable
{
- public bool IsLagFrame
- {
- get { return _islag; }
- set { _islag = value; }
- }
+ public bool IsLagFrame { get; set; }
+ public int LagCount { get; set; }
- public int LagCount
- {
- get { return _lagcount; }
- set { _lagcount = value; }
- }
-
- public IInputCallbackSystem InputCallbacks { get; private set; }
-
- private bool _islag = true;
- private int _lagcount = 0;
+ [SaveState.DoNotSave]
+ public IInputCallbackSystem InputCallbacks { get; private set; }
}
}
diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IMemoryDomains.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IMemoryDomains.cs
index 072e97bb1f..8f30e1df60 100644
--- a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IMemoryDomains.cs
+++ b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IMemoryDomains.cs
@@ -1,29 +1,45 @@
-using System.Collections.Generic;
+using System;
+using System.Collections.Generic;
using BizHawk.Emulation.Common;
namespace BizHawk.Emulation.Cores.Computers.Commodore64
{
public partial class C64
{
- private IMemoryDomains memoryDomains;
+ private IMemoryDomains _memoryDomains;
- private void SetupMemoryDomains()
+ private void SetupMemoryDomains(bool diskDriveEnabled)
{
+ var domains = new List
+ {
+ C64MemoryDomainFactory.Create("System Bus", 0x10000, a => _board.Cpu.Peek(a), (a, v) => _board.Cpu.Poke(a, v)),
+ C64MemoryDomainFactory.Create("RAM", 0x10000, a => _board.Ram.Peek(a), (a, v) => _board.Ram.Poke(a, v)),
+ C64MemoryDomainFactory.Create("CIA0", 0x10, a => _board.Cia0.Peek(a), (a, v) => _board.Cia0.Poke(a, v)),
+ C64MemoryDomainFactory.Create("CIA1", 0x10, a => _board.Cia1.Peek(a), (a, v) => _board.Cia1.Poke(a, v)),
+ C64MemoryDomainFactory.Create("VIC", 0x40, a => _board.Vic.Peek(a), (a, v) => _board.Vic.Poke(a, v)),
+ C64MemoryDomainFactory.Create("SID", 0x20, a => _board.Sid.Peek(a), (a, v) => _board.Sid.Poke(a, v)),
+ };
- // chips must be initialized before this code runs!
- var domains = new List(1);
- domains.Add(new MemoryDomain("System Bus", 0x10000, MemoryDomain.Endian.Little, board.cpu.Peek, board.cpu.Poke));
- domains.Add(new MemoryDomain("RAM", 0x10000, MemoryDomain.Endian.Little, board.ram.Peek, board.ram.Poke));
- domains.Add(new MemoryDomain("CIA0", 0x10, MemoryDomain.Endian.Little, board.cia0.Peek, board.cia0.Poke));
- domains.Add(new MemoryDomain("CIA1", 0x10, MemoryDomain.Endian.Little, board.cia1.Peek, board.cia1.Poke));
- domains.Add(new MemoryDomain("VIC", 0x40, MemoryDomain.Endian.Little, board.vic.Peek, board.vic.Poke));
- domains.Add(new MemoryDomain("SID", 0x20, MemoryDomain.Endian.Little, board.sid.Peek, board.sid.Poke));
- //domains.Add(new MemoryDomain("1541 Bus", 0x10000, MemoryDomain.Endian.Little, new Func(disk.Peek), new Action(disk.Poke)));
- //domains.Add(new MemoryDomain("1541 VIA0", 0x10, MemoryDomain.Endian.Little, new Func(disk.PeekVia0), new Action(disk.PokeVia0)));
- //domains.Add(new MemoryDomain("1541 VIA1", 0x10, MemoryDomain.Endian.Little, new Func(disk.PeekVia1), new Action(disk.PokeVia1)));
- //domains.Add(new MemoryDomain("1541 RAM", 0x1000, MemoryDomain.Endian.Little, new Func(disk.PeekRam), new Action(disk.PokeRam)));
- memoryDomains = new MemoryDomainList(domains);
- (ServiceProvider as BasicServiceProvider).Register(memoryDomains);
+ if (diskDriveEnabled)
+ {
+ domains.AddRange(new[]
+ {
+ C64MemoryDomainFactory.Create("1541 Bus", 0x10000, a => _board.DiskDrive.Peek(a), (a, v) => _board.DiskDrive.Poke(a, v)),
+ C64MemoryDomainFactory.Create("1541 RAM", 0x800, a => _board.DiskDrive.Peek(a), (a, v) => _board.DiskDrive.Poke(a, v)),
+ C64MemoryDomainFactory.Create("1541 VIA0", 0x10, a => _board.DiskDrive.PeekVia0(a), (a, v) => _board.DiskDrive.PokeVia0(a, v)),
+ C64MemoryDomainFactory.Create("1541 VIA1", 0x10, a => _board.DiskDrive.PeekVia1(a), (a, v) => _board.DiskDrive.PokeVia1(a, v))
+ });
+ }
+ _memoryDomains = new MemoryDomainList(domains);
+ ((BasicServiceProvider) ServiceProvider).Register(_memoryDomains);
}
- }
+
+ private static class C64MemoryDomainFactory
+ {
+ public static MemoryDomain Create(string name, int size, Func peekByte, Action pokeByte)
+ {
+ return new MemoryDomain(name, size, MemoryDomain.Endian.Little, addr => unchecked((byte)peekByte((int)addr)), (addr, val) => pokeByte(unchecked((int)addr), val));
+ }
+ }
+ }
}
diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.ISettable.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.ISettable.cs
index b6e382a294..5ea9385b54 100644
--- a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.ISettable.cs
+++ b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.ISettable.cs
@@ -9,13 +9,12 @@ using System.Drawing;
namespace BizHawk.Emulation.Cores.Computers.Commodore64
{
- // adelikat: changing settings to default object untl there are actually settings, as the ui depends on it to know if there are any settings avaialable
- public partial class C64 : ISettable