C64: Fix the build post-merge (derp.)

This commit is contained in:
Tony Konzel 2016-03-15 11:38:55 -05:00
parent 05914e1490
commit 93fcb293d8
2 changed files with 120 additions and 110 deletions

View File

@ -544,13 +544,9 @@ namespace BizHawk.Client.Common
(AppleII.Settings)GetCoreSettings<AppleII>());
break;
case "C64":
var c64Assets = xmlGame.Assets.Select(a => Database.GetGameInfo(a.Value, a.Key));
var c64Roms = xmlGame.Assets.Select(a => a.Value);
nextEmulator = new C64(
nextComm,
c64Assets.FirstOrDefault(), // TODO
c64Roms.FirstOrDefault(),
".d64", // TODO
xmlGame.Assets.Select(a => a.Value),
(C64.C64Settings)GetCoreSettings<C64>(),
(C64.C64SyncSettings)GetCoreSyncSettings<C64>()
);
@ -788,7 +784,7 @@ namespace BizHawk.Client.Common
nextEmulator = new Atari7800(nextComm, game, rom.RomData, gamedbpath);
break;
case "C64":
var c64 = new C64(nextComm, game, rom.RomData, GetCoreSettings<C64>(), GetCoreSyncSettings<C64>());
var c64 = new C64(nextComm, Enumerable.Repeat(rom.RomData, 1), GetCoreSettings<C64>(), GetCoreSyncSettings<C64>());
nextEmulator = c64;
break;
case "GBA":

View File

@ -1,14 +1,9 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using BizHawk.Emulation.Common;
using BizHawk.Emulation.Cores.Computers.Commodore64.MOS;
using System.Windows.Forms;
using BizHawk.Emulation.Cores.Computers.Commodore64.Cartridge;
using BizHawk.Emulation.Cores.Computers.Commodore64.Cassette;
using BizHawk.Emulation.Cores.Computers.Commodore64.Media;
using BizHawk.Emulation.Cores.Computers.Commodore64.Serial;
namespace BizHawk.Emulation.Cores.Computers.Commodore64
{
@ -21,74 +16,16 @@ 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)
{
PutSyncSettings((C64SyncSettings)syncSettings ?? new C64SyncSettings());
PutSettings((C64Settings)settings ?? new C64Settings());
#region Internals
ServiceProvider = new BasicServiceProvider(this);
InputCallbacks = new InputCallbackSystem();
[SaveState.DoNotSave]
private readonly int _cyclesPerFrame;
CoreComm = comm;
Roms = new List<byte[]> { rom };
Init(SyncSettings.VicType, Settings.BorderType, SyncSettings.SidType, SyncSettings.TapeDriveType, SyncSettings.DiskDriveType);
_cyclesPerFrame = _board.Vic.CyclesPerFrame;
SetupMemoryDomains(_board.DiskDrive != null);
_memoryCallbacks = new MemoryCallbackSystem();
HardReset();
[SaveState.DoNotSave]
public GameInfo Game;
switch (SyncSettings.VicType)
{
case VicType.Ntsc:
case VicType.Drean:
case VicType.NtscOld:
Region = DisplayType.NTSC;
break;
case VicType.Pal:
Region = DisplayType.PAL;
break;
}
((BasicServiceProvider) ServiceProvider).Register<IVideoProvider>(_board.Vic);
((BasicServiceProvider) ServiceProvider).Register<IDriveLight>(this);
}
// internal variables
private int _frame;
[SaveState.DoNotSave] private readonly int _cyclesPerFrame;
private bool _driveLed;
// bizhawk I/O
[SaveState.DoNotSave] public CoreComm CoreComm { get; private set; }
// game/rom specific
[SaveState.DoNotSave] public GameInfo Game;
[SaveState.DoNotSave] public string SystemId { get { return "C64"; } }
[SaveState.DoNotSave] public string BoardName { get { return null; } }
// running state
public bool DeterministicEmulation { get { return true; } set { ; } }
[SaveState.DoNotSave] public int Frame { get { return _frame; } set { _frame = value; } }
public void ResetCounters()
{
_frame = 0;
LagCount = 0;
IsLagFrame = false;
_frameCycles = 0;
}
// audio/video
public void EndAsyncSound() { } //TODO
[SaveState.DoNotSave] public ISoundProvider SoundProvider { get { return null; } }
public bool StartAsyncSound() { return false; } //TODO
[SaveState.DoNotSave] public ISyncSoundProvider SyncSoundProvider { get { return DCFilter.AsISyncSoundProvider(_board.Sid, 512); } }
// controller
[SaveState.DoNotSave] public ControllerDefinition ControllerDefinition { get { return C64ControllerDefinition; } }
[SaveState.DoNotSave] public IController Controller { get { return _board.Controller; } set { _board.Controller = value; } }
[SaveState.DoNotSave] public IEnumerable<byte[]> Roms { get; private set; }
[SaveState.DoNotSave]
public IEnumerable<byte[]> Roms { get; private set; }
[SaveState.DoNotSave]
private static readonly ControllerDefinition C64ControllerDefinition = new ControllerDefinition
@ -107,14 +44,57 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64
}
};
[SaveState.DoNotSave] public IEmulatorServiceProvider ServiceProvider { get; private set; }
[SaveState.SaveWithName("Board")]
private Motherboard _board;
public DisplayType Region
private int _frameCycles;
#endregion
#region Ctor
public C64(CoreComm comm, IEnumerable<byte[]> roms, object settings, object syncSettings)
{
get;
private set;
PutSyncSettings((C64SyncSettings)syncSettings ?? new C64SyncSettings());
PutSettings((C64Settings)settings ?? new C64Settings());
ServiceProvider = new BasicServiceProvider(this);
InputCallbacks = new InputCallbackSystem();
CoreComm = comm;
Roms = roms;
Init(SyncSettings.VicType, Settings.BorderType, SyncSettings.SidType, SyncSettings.TapeDriveType, SyncSettings.DiskDriveType);
_cyclesPerFrame = _board.Vic.CyclesPerFrame;
SetupMemoryDomains(_board.DiskDrive != null);
_memoryCallbacks = new MemoryCallbackSystem();
HardReset();
switch (SyncSettings.VicType)
{
case VicType.Ntsc:
case VicType.Drean:
case VicType.NtscOld:
Region = DisplayType.NTSC;
break;
case VicType.Pal:
Region = DisplayType.PAL;
break;
}
if (_board.Sid != null)
{
SyncSoundProvider = DCFilter.AsISyncSoundProvider(_board.Sid, 512);
}
DeterministicEmulation = true;
((BasicServiceProvider) ServiceProvider).Register<IVideoProvider>(_board.Vic);
((BasicServiceProvider) ServiceProvider).Register<IDriveLight>(this);
}
#endregion
#region IDisposable
public void Dispose()
{
if (_board != null)
@ -131,7 +111,51 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64
}
}
private int _frameCycles;
#endregion
#region IRegionable
[SaveState.DoNotSave]
public DisplayType Region
{
get;
private set;
}
#endregion
#region IEmulator
[SaveState.DoNotSave]
public CoreComm CoreComm { get; private set; }
[SaveState.DoNotSave]
public string SystemId { get { return "C64"; } }
[SaveState.DoNotSave]
public string BoardName { get { return null; } }
[SaveState.SaveWithName("DeterministicEmulation")]
public bool DeterministicEmulation { get; set; }
[SaveState.SaveWithName("Frame")]
public int Frame { get; set; }
public bool StartAsyncSound() { return false; }
public void EndAsyncSound() { }
[SaveState.DoNotSave]
public ISoundProvider SoundProvider { get { return null; } }
[SaveState.DoNotSave]
public ISyncSoundProvider SyncSoundProvider { get; private set; }
[SaveState.DoNotSave]
public ControllerDefinition ControllerDefinition { get { return C64ControllerDefinition; } }
[SaveState.DoNotSave]
public IController Controller { get { return _board.Controller; } set { _board.Controller = value; } }
[SaveState.DoNotSave]
public IEmulatorServiceProvider ServiceProvider { get; private set; }
public void ResetCounters()
{
Frame = 0;
LagCount = 0;
IsLagFrame = false;
_frameCycles = 0;
}
// process frame
public void FrameAdvance(bool render, bool rendersound)
@ -143,6 +167,8 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64
while (_frameCycles != 0);
}
#endregion
private void DoCycle()
{
if (_frameCycles == 0) {
@ -151,8 +177,6 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64
_board.Cpu.LagCycles = 0;
}
_driveLed = _board.Serial.ReadDeviceLight();
_board.Execute();
_frameCycles++;
@ -167,17 +191,9 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64
if (IsLagFrame)
LagCount++;
_frameCycles -= _cyclesPerFrame;
_frame++;
Frame++;
}
private void HandleFirmwareError(string file)
{
MessageBox.Show("the C64 core is referencing a firmware file which could not be found. Please make sure it's in your configured C64 firmwares folder. The referenced filename is: " + file);
throw new FileNotFoundException();
}
private Motherboard _board;
private byte[] GetFirmware(int length, params string[] names)
{
var result = names.Select(n => CoreComm.CoreFileProvider.GetFirmware("C64", n, false)).FirstOrDefault(b => b != null && b.Length == length);
@ -307,8 +323,6 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64
}
}
// ------------------------------------
public void HardReset()
{
InitMedia();