diff --git a/BizHawk.Emulation/BizHawk.Emulation.csproj b/BizHawk.Emulation/BizHawk.Emulation.csproj
index a44ccc9d0b..c1c817d1ed 100644
--- a/BizHawk.Emulation/BizHawk.Emulation.csproj
+++ b/BizHawk.Emulation/BizHawk.Emulation.csproj
@@ -83,6 +83,7 @@
+
diff --git a/BizHawk.Emulation/Computers/Commodore64/C64.Core.cs b/BizHawk.Emulation/Computers/Commodore64/C64.Core.cs
index cf34875580..9c447033d5 100644
--- a/BizHawk.Emulation/Computers/Commodore64/C64.Core.cs
+++ b/BizHawk.Emulation/Computers/Commodore64/C64.Core.cs
@@ -31,7 +31,11 @@ namespace BizHawk.Emulation.Computers.Commodore64
{
// ------------------------------------
- C64Chips chips;
+ private C64Chips chips;
+
+ // ------------------------------------
+
+ private bool loadPrg;
// ------------------------------------
@@ -62,6 +66,10 @@ namespace BizHawk.Emulation.Computers.Commodore64
chips.pla.Game = chips.cartPort.Game;
}
break;
+ case @".PRG":
+ if (inputFile.Length > 2)
+ loadPrg = true;
+ break;
}
}
diff --git a/BizHawk.Emulation/Computers/Commodore64/C64.cs b/BizHawk.Emulation/Computers/Commodore64/C64.cs
index e75c4474cd..343665a0b0 100644
--- a/BizHawk.Emulation/Computers/Commodore64/C64.cs
+++ b/BizHawk.Emulation/Computers/Commodore64/C64.cs
@@ -90,6 +90,21 @@ namespace BizHawk.Emulation.Computers.Commodore64
// process frame
public void FrameAdvance(bool render, bool rendersound)
{
+ // load PRG file if needed
+ if (loadPrg)
+ {
+ if (chips.pla.Peek(0x04C8) == 0x12 &&
+ chips.pla.Peek(0x04C9) == 0x05 &&
+ chips.pla.Peek(0x04CA) == 0x01 &&
+ chips.pla.Peek(0x04CB) == 0x04 &&
+ chips.pla.Peek(0x04CC) == 0x19 &&
+ chips.pla.Peek(0x04CD) == 0x2E)
+ {
+ Media.PRG.Load(chips.pla, inputFile);
+ loadPrg = false;
+ }
+ }
+
PollInput();
chips.pla.InputWasRead = false;
Execute(cyclesPerFrame);
diff --git a/BizHawk.Emulation/Computers/Commodore64/Media/D64.cs b/BizHawk.Emulation/Computers/Commodore64/Media/D64.cs
index 523b63542e..c4e2505c83 100644
--- a/BizHawk.Emulation/Computers/Commodore64/Media/D64.cs
+++ b/BizHawk.Emulation/Computers/Commodore64/Media/D64.cs
@@ -4,7 +4,7 @@ using System.IO;
using System.Linq;
using System.Text;
-namespace BizHawk.Emulation.Computers.Commodore64
+namespace BizHawk.Emulation.Computers.Commodore64.Media
{
public static class D64
{
diff --git a/BizHawk.Emulation/Computers/Commodore64/Media/Disk.cs b/BizHawk.Emulation/Computers/Commodore64/Media/Disk.cs
index 65df7f3517..158b5c5419 100644
--- a/BizHawk.Emulation/Computers/Commodore64/Media/Disk.cs
+++ b/BizHawk.Emulation/Computers/Commodore64/Media/Disk.cs
@@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
-namespace BizHawk.Emulation.Computers.Commodore64
+namespace BizHawk.Emulation.Computers.Commodore64.Media
{
public class Track
{
diff --git a/BizHawk.Emulation/Computers/Commodore64/Media/G64.cs b/BizHawk.Emulation/Computers/Commodore64/Media/G64.cs
index 746517ed29..8febdc8f75 100644
--- a/BizHawk.Emulation/Computers/Commodore64/Media/G64.cs
+++ b/BizHawk.Emulation/Computers/Commodore64/Media/G64.cs
@@ -4,7 +4,7 @@ using System.IO;
using System.Linq;
using System.Text;
-namespace BizHawk.Emulation.Computers.Commodore64
+namespace BizHawk.Emulation.Computers.Commodore64.Media
{
public static class G64
{
diff --git a/BizHawk.Emulation/Computers/Commodore64/Media/PRG.cs b/BizHawk.Emulation/Computers/Commodore64/Media/PRG.cs
new file mode 100644
index 0000000000..0e3bdb4f3b
--- /dev/null
+++ b/BizHawk.Emulation/Computers/Commodore64/Media/PRG.cs
@@ -0,0 +1,30 @@
+using BizHawk.Emulation.Computers.Commodore64.MOS;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace BizHawk.Emulation.Computers.Commodore64.Media
+{
+ public static class PRG
+ {
+ static public void Load(MOSPLA pla, byte[] prgFile)
+ {
+ uint length = (uint)prgFile.Length;
+ if (length > 2)
+ {
+ ushort addr = (ushort)(prgFile[0] | (prgFile[1] << 8));
+ uint offset = 2;
+ unchecked
+ {
+ while (offset < length)
+ {
+ pla.Write(addr, prgFile[offset]);
+ offset++;
+ addr++;
+ }
+ }
+ }
+ }
+ }
+}