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
|
|
|
|
|
|
2016-02-22 23:50:11 +00:00
|
|
|
|
public sealed class Chip4864
|
2012-11-27 05:11:40 +00:00
|
|
|
|
{
|
2017-04-24 13:35:05 +00:00
|
|
|
|
private int[] _ram;
|
2012-11-27 05:11:40 +00:00
|
|
|
|
|
|
|
|
|
public Chip4864()
|
|
|
|
|
{
|
2016-02-22 23:50:11 +00:00
|
|
|
|
_ram = new int[0x10000];
|
2012-11-27 05:11:40 +00:00
|
|
|
|
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;
|
2012-11-27 05:11:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-02-22 23:50:11 +00:00
|
|
|
|
public int Peek(int addr)
|
2015-01-18 15:25:47 +00:00
|
|
|
|
{
|
2016-02-22 23:50:11 +00:00
|
|
|
|
return _ram[addr];
|
2015-01-18 15:25:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-02-22 23:50:11 +00:00
|
|
|
|
public void Poke(int addr, int val)
|
2015-01-18 15:25:47 +00:00
|
|
|
|
{
|
2016-02-22 23:50:11 +00:00
|
|
|
|
_ram[addr] = val;
|
2015-01-18 15:25:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-02-22 23:50:11 +00:00
|
|
|
|
public int Read(int addr)
|
2012-11-27 05:11:40 +00:00
|
|
|
|
{
|
2016-02-22 23:50:11 +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)
|
|
|
|
|
{
|
2017-05-13 13:42:07 +00:00
|
|
|
|
ser.Sync("_ram", ref _ram, useNull: false);
|
2013-11-04 00:36:15 +00:00
|
|
|
|
}
|
2012-12-03 08:38:12 +00:00
|
|
|
|
|
2016-02-22 23:50:11 +00:00
|
|
|
|
public void Write(int addr, int val)
|
2012-11-27 05:11:40 +00:00
|
|
|
|
{
|
2016-02-22 23:50:11 +00:00
|
|
|
|
_ram[addr] = val;
|
2012-11-27 05:11:40 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|