commodore64: PRG loading uses a more robust method

This commit is contained in:
saxxonpike 2012-11-28 17:49:42 +00:00
parent e490d1be04
commit b55d6526d1
7 changed files with 58 additions and 4 deletions

View File

@ -83,6 +83,7 @@
<Compile Include="Computers\Commodore64\C64.cs" />
<Compile Include="Computers\Commodore64\Cartridges\Mapper0000.cs" />
<Compile Include="Computers\Commodore64\C64.Input.cs" />
<Compile Include="Computers\Commodore64\Media\PRG.cs" />
<Compile Include="Computers\Commodore64\Memory.cs" />
<Compile Include="Computers\Commodore64\Cartridges\Cartridge.cs" />
<Compile Include="Computers\Commodore64\MOS\CartridgePort.cs" />

View File

@ -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;
}
}

View File

@ -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);

View File

@ -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
{

View File

@ -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
{

View File

@ -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
{

View File

@ -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++;
}
}
}
}
}
}