2013-11-04 00:36:15 +00:00
|
|
|
|
using BizHawk.Common;
|
|
|
|
|
|
2014-10-03 21:04:37 +00:00
|
|
|
|
namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS
|
2012-11-27 05:11:40 +00:00
|
|
|
|
{
|
|
|
|
|
// DRAM for the c64
|
|
|
|
|
// 4164 = 64 kbit
|
|
|
|
|
// 4464 = 256 kbit
|
|
|
|
|
// 4864 = 512 kbit
|
2013-11-04 00:36:15 +00:00
|
|
|
|
|
2012-11-27 05:11:40 +00:00
|
|
|
|
// for purposes of simplification we'll just
|
|
|
|
|
// use one 4864, the C64 can use sets of 4164 or
|
|
|
|
|
// 4464 typically
|
|
|
|
|
|
2012-11-27 20:47:03 +00:00
|
|
|
|
// memory is striped 00/FF at intervals of 0x40
|
|
|
|
|
|
2013-11-04 00:36:15 +00:00
|
|
|
|
sealed public class Chip4864
|
2012-11-27 05:11:40 +00:00
|
|
|
|
{
|
2013-11-04 00:36:15 +00:00
|
|
|
|
byte[] ram;
|
2012-11-27 05:11:40 +00:00
|
|
|
|
|
|
|
|
|
public Chip4864()
|
|
|
|
|
{
|
2012-11-27 21:03:01 +00:00
|
|
|
|
ram = new byte[0x10000];
|
2012-11-27 05:11:40 +00:00
|
|
|
|
HardReset();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void HardReset()
|
|
|
|
|
{
|
2012-11-27 20:47:03 +00:00
|
|
|
|
// stripe the ram
|
|
|
|
|
for (int i = 0; i < 10000; i++)
|
|
|
|
|
ram[i] = ((i & 0x40) != 0) ? (byte)0xFF : (byte)0x00;
|
2012-11-27 05:11:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-01-18 15:25:47 +00:00
|
|
|
|
public byte Peek(long addr)
|
|
|
|
|
{
|
|
|
|
|
return ram[addr];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Poke(long addr, byte val)
|
|
|
|
|
{
|
|
|
|
|
ram[addr] = val;
|
|
|
|
|
}
|
|
|
|
|
|
2012-11-27 05:11:40 +00:00
|
|
|
|
public byte Peek(int addr)
|
|
|
|
|
{
|
2013-08-14 13:53:48 +00:00
|
|
|
|
return ram[addr];
|
2012-11-27 05:11:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Poke(int addr, byte val)
|
|
|
|
|
{
|
2013-11-04 00:36:15 +00:00
|
|
|
|
ram[addr] = val;
|
2012-11-27 05:11:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-08-14 05:05:17 +00:00
|
|
|
|
public byte Read(int addr)
|
2012-11-27 05:11:40 +00:00
|
|
|
|
{
|
2013-11-04 00:36:15 +00:00
|
|
|
|
return ram[addr];
|
2012-11-27 05:11:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-12-03 08:38:12 +00:00
|
|
|
|
public void SyncState(Serializer ser)
|
|
|
|
|
{
|
2013-11-04 00:36:15 +00:00
|
|
|
|
SaveState.SyncObject(ser, this);
|
|
|
|
|
}
|
2012-12-03 08:38:12 +00:00
|
|
|
|
|
2013-08-14 05:05:17 +00:00
|
|
|
|
public void Write(int addr, byte val)
|
2012-11-27 05:11:40 +00:00
|
|
|
|
{
|
2013-11-04 00:36:15 +00:00
|
|
|
|
ram[addr] = val;
|
2012-11-27 05:11:40 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|