diff --git a/BizHawk.Emulation/BizHawk.Emulation.csproj b/BizHawk.Emulation/BizHawk.Emulation.csproj
index 0e9e075304..e245a6da57 100644
--- a/BizHawk.Emulation/BizHawk.Emulation.csproj
+++ b/BizHawk.Emulation/BizHawk.Emulation.csproj
@@ -76,6 +76,8 @@
+
+
@@ -516,6 +518,7 @@
+
diff --git a/BizHawk.Emulation/Computers/Commodore64/C64.core.cs b/BizHawk.Emulation/Computers/Commodore64/C64.core.cs
new file mode 100644
index 0000000000..bde26b7f3b
--- /dev/null
+++ b/BizHawk.Emulation/Computers/Commodore64/C64.core.cs
@@ -0,0 +1,32 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using BizHawk.Emulation.CPUs.M6502;
+
+namespace BizHawk.Emulation.Computers.Commodore64
+{
+ public partial class C64 : IEmulator
+ {
+ public byte[] rom;
+ public MOS6502X cpu;
+
+ private void HardReset()
+ {
+ cpu = new MOS6502X();
+ cpu.ReadMemory = ReadMemory;
+ cpu.WriteMemory = WriteMemory;
+ cpu.DummyReadMemory = ReadMemory;
+ }
+
+ public byte ReadMemory(ushort addr)
+ {
+ return 0;
+ }
+
+ public void WriteMemory(ushort addr, byte value)
+ {
+ //TODO
+ }
+ }
+}
diff --git a/BizHawk.Emulation/Computers/Commodore64/C64.cs b/BizHawk.Emulation/Computers/Commodore64/C64.cs
new file mode 100644
index 0000000000..0518962806
--- /dev/null
+++ b/BizHawk.Emulation/Computers/Commodore64/C64.cs
@@ -0,0 +1,164 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.IO;
+
+
+namespace BizHawk.Emulation.Computers.Commodore64
+{
+ public partial class C64 : IEmulator
+ {
+ public C64(GameInfo game, byte[] rom)
+ {
+ videoProvider = new MyVideoProvider(this);
+ SetupMemoryDomains();
+ CoreOutputComm = new CoreOutputComm();
+ CoreInputComm = new CoreInputComm();
+ HardReset();
+ }
+
+ public string SystemId { get { return "C64"; } }
+ public GameInfo game;
+
+ public CoreInputComm CoreInputComm { get; set; }
+ public CoreOutputComm CoreOutputComm { get; private set; }
+ private IList memoryDomains;
+ public IList MemoryDomains { get { return memoryDomains; } }
+ public MemoryDomain MainMemory { get { return memoryDomains[0]; } }
+ public int Frame { get { return _frame; } set { _frame = value; } }
+ public int LagCount { get { return _lagcount; } set { _lagcount = value; } }
+ public bool IsLagFrame { get { return _islag; } }
+ private bool _islag = true;
+ private int _lagcount = 0;
+ private int _frame = 0;
+ public byte[] ReadSaveRam() { return null; }
+ public void StoreSaveRam(byte[] data) { }
+ public void ClearSaveRam() { }
+ public bool SaveRamModified { get; set; }
+ public void Dispose() { }
+ public IVideoProvider VideoProvider { get { return videoProvider; } }
+ public ISoundProvider SoundProvider { get { return soundProvider; } }
+ public void ResetFrameCounter()
+ {
+ _frame = 0;
+ }
+
+ /*TODO*/
+ public int[] frameBuffer = new int[256 * 192]; //TODO
+ public ISyncSoundProvider SyncSoundProvider { get { return null; } } //TODO
+ public bool StartAsyncSound() { return true; } //TODO
+ public void EndAsyncSound() { } //TODO
+ public bool DeterministicEmulation { get; set; } //TODO
+ public void SaveStateText(TextWriter writer) { } //TODO
+ public void LoadStateText(TextReader reader) { } //TODO
+ public void SaveStateBinary(BinaryWriter bw) { } //TODO
+ public void LoadStateBinary(BinaryReader br) { } //TODO
+ public ControllerDefinition ControllerDefinition { get { return Atari7800ControllerDefinition; } }
+ public IController Controller { get; set; }
+ public static readonly ControllerDefinition Atari7800ControllerDefinition = new ControllerDefinition
+ {
+ Name = "Atari 7800 Basic Controller", //TODO
+ BoolButtons =
+ {
+ "P1 Up", "P1 Down", "P1 Left", "P1 Right", "P1 Button",
+ "P2 Up", "P2 Down", "P2 Left", "P2 Right", "P2 Button",
+ "Reset", "Select"
+ }
+ };
+
+ class MySoundProvider : ISoundProvider
+ {
+ Atari7800 emu;
+ public MySoundProvider(Atari7800 emu)
+ {
+ this.emu = emu;
+ }
+ public int MaxVolume { get { return 0; } set { } }
+ public void DiscardSamples()
+ {
+ }
+
+ public void GetSamples(short[] samples)
+ {
+ }
+ }
+
+ public void FrameAdvance(bool render, bool rendersound)
+ {
+ _frame++;
+ _islag = true;
+
+ //TODO
+ //Do stuff here
+
+ if (_islag)
+ {
+ LagCount++;
+ }
+
+ videoProvider.FillFrameBuffer();
+ }
+
+ /*******************************/
+
+ private MySoundProvider soundProvider;
+ private MyVideoProvider videoProvider;
+ class MyVideoProvider : IVideoProvider
+ {
+ public int top = 0; //TODO
+ public int bottom = 262; //TODO
+ public int left = 0; //TODO
+ public int right = 320; //TODO
+
+ C64 emu;
+ public MyVideoProvider(C64 emu)
+ {
+ this.emu = emu;
+ }
+
+ int[] buffer = new int[262 * 320];
+
+ public void FillFrameBuffer()
+ {
+ for (int i = 0; i < buffer.Length; i++)
+ {
+ buffer[i] = 0; //TODO
+ }
+ }
+
+ public int[] GetVideoBuffer()
+ {
+ return buffer;
+ }
+
+ public int VirtualWidth { get { return BufferWidth; } }
+ public int BufferWidth { get { return right - left + 1; } }
+ public int BufferHeight { get { return bottom - top + 1; } }
+ public int BackgroundColor { get { return 0; } }
+ }
+
+ private void SetupMemoryDomains()
+ {
+ var domains = new List(1);
+ domains.Add(new MemoryDomain("Main RAM", 1, Endian.Little, addr => 0xFF, null)); //TODO
+ memoryDomains = domains.AsReadOnly();
+ }
+
+ public byte[] SaveStateBinary()
+ {
+ MemoryStream ms = new MemoryStream();
+ BinaryWriter bw = new BinaryWriter(ms);
+ SaveStateBinary(bw);
+ bw.Flush();
+ return ms.ToArray();
+ }
+
+ void SyncState(Serializer ser) //TODO
+ {
+ ser.Sync("Lag", ref _lagcount);
+ ser.Sync("Frame", ref _frame);
+ ser.Sync("IsLag", ref _islag);
+ }
+ }
+}
diff --git a/BizHawk.Emulation/Database/Database.cs b/BizHawk.Emulation/Database/Database.cs
index d92c257fce..fca617ef51 100644
--- a/BizHawk.Emulation/Database/Database.cs
+++ b/BizHawk.Emulation/Database/Database.cs
@@ -154,6 +154,12 @@ namespace BizHawk
case ".COL": Game.System = "COLV"; break;
case ".ROM":
case ".INT": Game.System = "INTV"; break;
+ case ".PRG":
+ case ".D64":
+ case ".G64":
+ case ".CRT":
+ Game.System = "C64";
+ break;
}
Game.Name = Path.GetFileNameWithoutExtension(fileName).Replace('_', ' ');
diff --git a/BizHawk.MultiClient/MainForm.cs b/BizHawk.MultiClient/MainForm.cs
index 48878c4b62..9df6df928e 100644
--- a/BizHawk.MultiClient/MainForm.cs
+++ b/BizHawk.MultiClient/MainForm.cs
@@ -17,6 +17,7 @@ using BizHawk.MultiClient.tools;
using System.Collections.Generic;
using BizHawk.Emulation.Consoles.Intellivision;
using BizHawk.Emulation.Consoles.GB;
+using BizHawk.Emulation.Computers.Commodore64;
namespace BizHawk.MultiClient
{
@@ -1123,6 +1124,7 @@ namespace BizHawk.MultiClient
case "GBC": str += "Game Boy Color"; break;
case "A26": str += "Atari 2600"; break;
case "A78": str += "Atari 7800"; break;
+ case "C64": str += "Commodore 64"; break;
}
if (INTERIM) str += " (interim)";
@@ -1364,7 +1366,7 @@ namespace BizHawk.MultiClient
if (path == null) return false;
using (var file = new HawkFile())
{
- string[] romExtensions = new string[] { "SMS", "SMC", "SFC", "PCE", "SGX", "GG", "SG", "BIN", "GEN", "MD", "SMD", "GB", "NES", "FDS", "ROM", "INT", "GBC", "UNF", "A78" };
+ string[] romExtensions = new string[] { "SMS", "SMC", "SFC", "PCE", "SGX", "GG", "SG", "BIN", "GEN", "MD", "SMD", "GB", "NES", "FDS", "ROM", "INT", "GBC", "UNF", "A78", "C64" };
//lets not use this unless we need to
//file.NonArchiveExtensions = romExtensions;
@@ -1643,6 +1645,9 @@ namespace BizHawk.MultiClient
Atari7800 a78 = new Atari7800(game, rom.RomData, NTSC_BIOS7800, PAL_BIOS7800, HighScoreBIOS);
nextEmulator = a78;
break;
+ case "C64":
+ C64 c64 = new C64(game, rom.RomData); //TODO: need to load in BIOSes?
+ break;
}
}
@@ -3005,7 +3010,7 @@ namespace BizHawk.MultiClient
if (INTERIM)
{
ofd.Filter = FormatFilter(
- "Rom Files", "*.nes;*.sms;*.gg;*.sg;*.pce;*.sgx;*.bin;*.smd;*.rom;*.a26;*.a78;*.cue;*.exe;*.gb;*.gbc;*.gen;*.md;*.col;.int;*.smc;*.sfc;%ARCH%",
+ "Rom Files", "*.nes;*.sms;*.gg;*.sg;*.pce;*.sgx;*.bin;*.smd;*.rom;*.a26;*.a78;*.cue;*.exe;*.gb;*.gbc;*.gen;*.md;*.col;.int;*.smc;*.sfc;*.prg;*.d64;*.g64;*.crt;%ARCH%",
"Disc Images", "*.cue",
"NES", "*.nes;%ARCH%",
"Super NES", "*.smc;*.sfc;%ARCH%",
@@ -3021,6 +3026,7 @@ namespace BizHawk.MultiClient
"Colecovision (very experimental)", "*.col;%ARCH%",
"Intellivision (very experimental)", "*.int;*.bin;*.rom;%ARCH%",
"PSX Executables (very experimental)", "*.exe",
+ "Commodore 64 (very experimental)", "*.prg; *.d64, *.g64; *.crt;%ARCH%",
"All Files", "*.*");
}
else