commodore64: PRG files now autoload after Kernal is ready- hardcoded to load at 2064 for now
This commit is contained in:
parent
7d62265047
commit
f682734c39
|
@ -84,6 +84,8 @@
|
|||
<Compile Include="Computers\Commodore64\Cartridge.cs" />
|
||||
<Compile Include="Computers\Commodore64\Cia.cs" />
|
||||
<Compile Include="Computers\Commodore64\DataPort.cs" />
|
||||
<Compile Include="Computers\Commodore64\IMedia.cs" />
|
||||
<Compile Include="Computers\Commodore64\PRGFile.cs" />
|
||||
<Compile Include="Computers\Commodore64\MemBus.cs" />
|
||||
<Compile Include="Computers\Commodore64\Sid.cs" />
|
||||
<Compile Include="Computers\Commodore64\VicII.cs" />
|
||||
|
|
|
@ -11,9 +11,9 @@ namespace BizHawk.Emulation.Computers.Commodore64
|
|||
{
|
||||
// source
|
||||
public Cartridge cart;
|
||||
public bool cartInserted;
|
||||
public string extension;
|
||||
public byte[] inputFile;
|
||||
public List<IMedia> mediaAttached = new List<IMedia>();
|
||||
|
||||
// chipset
|
||||
public Cia cia0;
|
||||
|
@ -59,18 +59,12 @@ namespace BizHawk.Emulation.Computers.Commodore64
|
|||
{
|
||||
case @".PRG":
|
||||
if (inputFile.Length > 2)
|
||||
{
|
||||
mem.ApplyMemory(inputFile);
|
||||
// idle vector
|
||||
cpu.PC = (ushort)2064;
|
||||
}
|
||||
mediaAttached.Add(new PRGFile(inputFile, mem, cpu));
|
||||
break;
|
||||
case @".CRT":
|
||||
Cartridge cart = new Cartridge(inputFile);
|
||||
if (cart.valid)
|
||||
{
|
||||
mem.ApplyCartridge(cart);
|
||||
}
|
||||
mediaAttached.Add(cart);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -89,6 +89,14 @@ namespace BizHawk.Emulation.Computers.Commodore64
|
|||
|
||||
int cyclesPerSecond = (14318181 / 14 / 60);
|
||||
|
||||
foreach (IMedia media in mediaAttached)
|
||||
{
|
||||
if (!media.Loaded() && media.Ready())
|
||||
{
|
||||
media.Apply(mem);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < cyclesPerSecond; i++)
|
||||
{
|
||||
cpu.IRQ = signal.CpuIRQ;
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace BizHawk.Emulation.Computers.Commodore64
|
|||
public int type;
|
||||
}
|
||||
|
||||
public class Cartridge
|
||||
public class Cartridge : IMedia
|
||||
{
|
||||
public List<CartridgeChip> chips;
|
||||
public bool exRomPin;
|
||||
|
@ -24,6 +24,8 @@ namespace BizHawk.Emulation.Computers.Commodore64
|
|||
public bool valid;
|
||||
public int version;
|
||||
|
||||
private bool loaded;
|
||||
|
||||
public Cartridge(byte[] rom)
|
||||
{
|
||||
chips = new List<CartridgeChip>();
|
||||
|
@ -135,12 +137,31 @@ namespace BizHawk.Emulation.Computers.Commodore64
|
|||
}
|
||||
}
|
||||
|
||||
public void Apply(Memory mem)
|
||||
{
|
||||
mem.cart = this;
|
||||
mem.exRomPin = exRomPin;
|
||||
mem.gamePin = gamePin;
|
||||
mem.UpdateLayout();
|
||||
loaded = true;
|
||||
}
|
||||
|
||||
public bool Loaded()
|
||||
{
|
||||
return loaded;
|
||||
}
|
||||
|
||||
public byte Read(ushort addr)
|
||||
{
|
||||
CartridgeChip currentChip = chips[0];
|
||||
return currentChip.data[addr & currentChip.romMask];
|
||||
}
|
||||
|
||||
public bool Ready()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Write(ushort addr, byte val)
|
||||
{
|
||||
// can't write to rom but we can process DE00/DF00 here
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace BizHawk.Emulation.Computers.Commodore64
|
||||
{
|
||||
public interface IMedia
|
||||
{
|
||||
void Apply(Memory mem);
|
||||
bool Loaded();
|
||||
bool Ready();
|
||||
}
|
||||
}
|
|
@ -45,7 +45,6 @@ namespace BizHawk.Emulation.Computers.Commodore64
|
|||
|
||||
// storage
|
||||
public Cartridge cart;
|
||||
public bool cartInserted = false;
|
||||
|
||||
// roms
|
||||
public byte[] basicRom;
|
||||
|
@ -107,27 +106,15 @@ namespace BizHawk.Emulation.Computers.Commodore64
|
|||
HardReset();
|
||||
}
|
||||
|
||||
public void ApplyCartridge(Cartridge newCart)
|
||||
public byte this[ushort index]
|
||||
{
|
||||
cart = newCart;
|
||||
cartInserted = true;
|
||||
exRomPin = cart.exRomPin;
|
||||
gamePin = cart.gamePin;
|
||||
UpdateLayout();
|
||||
}
|
||||
|
||||
public void ApplyMemory(byte[] newMemory)
|
||||
{
|
||||
int address = newMemory[1];
|
||||
address <<= 8;
|
||||
address |= newMemory[0];
|
||||
|
||||
int count = newMemory.Length;
|
||||
|
||||
for (int i = 2; i < count; i++)
|
||||
get
|
||||
{
|
||||
Write((ushort)(address & 0xFFFF), newMemory[i]);
|
||||
address++;
|
||||
return ram[index];
|
||||
}
|
||||
set
|
||||
{
|
||||
ram[index] = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,79 @@
|
|||
using BizHawk.Emulation.CPUs.M6502;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace BizHawk.Emulation.Computers.Commodore64
|
||||
{
|
||||
public class PRGFile : IMedia
|
||||
{
|
||||
private MOS6502X cpu;
|
||||
private byte[] data;
|
||||
private bool loaded;
|
||||
private Memory mem;
|
||||
|
||||
public PRGFile(byte[] file, Memory checkMem, MOS6502X targetCpu)
|
||||
{
|
||||
cpu = targetCpu;
|
||||
mem = checkMem;
|
||||
data = file;
|
||||
}
|
||||
|
||||
public void Apply(Memory mem)
|
||||
{
|
||||
int address = data[1];
|
||||
address <<= 8;
|
||||
address |= data[0];
|
||||
|
||||
int count = data.Length;
|
||||
|
||||
for (int i = 2; i < count; i++)
|
||||
{
|
||||
mem.Write((ushort)(address & 0xFFFF), data[i]);
|
||||
address++;
|
||||
}
|
||||
|
||||
//// "RUN"
|
||||
//mem[0x04F0] = 0x12;
|
||||
//mem[0x04F1] = 0x15;
|
||||
//mem[0x04F2] = 0x0E;
|
||||
|
||||
//// set cursor to be right after run (3, 6)
|
||||
//mem[0x00C9] = 0x06;
|
||||
//mem[0x00CA] = 0x03;
|
||||
//mem[0x00D3] = 0x03;
|
||||
//mem[0x00D6] = 0x06;
|
||||
|
||||
//// set keyboard buffer
|
||||
//mem[0x00C5] = 0x0D;
|
||||
//mem[0x00C6] = 0x02;
|
||||
//mem[0x00CB] = 0x0D;
|
||||
//mem[0x0277] = 0x0D;
|
||||
//mem[0x0278] = 0x0D;
|
||||
|
||||
cpu.PC = 2064;
|
||||
|
||||
loaded = true;
|
||||
}
|
||||
|
||||
public bool Loaded()
|
||||
{
|
||||
return loaded;
|
||||
}
|
||||
|
||||
public bool Ready()
|
||||
{
|
||||
// wait for READY. to be on display
|
||||
return (
|
||||
mem[0x04C8] == 0x12 &&
|
||||
mem[0x04C9] == 0x05 &&
|
||||
mem[0x04CA] == 0x01 &&
|
||||
mem[0x04CB] == 0x04 &&
|
||||
mem[0x04CC] == 0x19 &&
|
||||
mem[0x04CD] == 0x2E &&
|
||||
mem[0x04CE] == 0x20
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue