BizHawk/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Chip4864.cs

59 lines
1002 B
C#
Raw Normal View History

using BizHawk.Common;
namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS
{
// DRAM for the c64
// 4164 = 64 kbit
// 4464 = 256 kbit
// 4864 = 512 kbit
// 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
2016-02-22 23:50:11 +00:00
public sealed class Chip4864
{
2017-04-24 13:35:05 +00:00
private int[] _ram;
public Chip4864()
{
2016-02-22 23:50:11 +00:00
_ram = new int[0x10000];
HardReset();
}
public void HardReset()
{
2012-11-27 20:47:03 +00:00
// stripe the ram
2016-02-22 23:50:11 +00:00
for (var i = 0; i < 10000; i++)
_ram[i] = (i & 0x40) != 0 ? 0xFF : 0x00;
}
2016-02-22 23:50:11 +00:00
public int Peek(int addr)
{
2016-02-22 23:50:11 +00:00
return _ram[addr];
}
2016-02-22 23:50:11 +00:00
public void Poke(int addr, int val)
{
2016-02-22 23:50:11 +00:00
_ram[addr] = val;
}
2016-02-22 23:50:11 +00:00
public int Read(int addr)
{
2016-02-22 23:50:11 +00:00
return _ram[addr];
}
public void SyncState(Serializer ser)
{
SaveState.SyncObject(ser, this);
}
2016-02-22 23:50:11 +00:00
public void Write(int addr, int val)
{
2016-02-22 23:50:11 +00:00
_ram[addr] = val;
}
}
}