2013-04-14 20:39:19 +00:00
|
|
|
|
namespace BizHawk.Emulation.Computers.Commodore64.MOS
|
2012-11-27 05:11:40 +00:00
|
|
|
|
{
|
|
|
|
|
// 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
|
|
|
|
|
|
2012-12-05 21:07:51 +00:00
|
|
|
|
public class Chip4864
|
2012-11-27 05:11:40 +00:00
|
|
|
|
{
|
|
|
|
|
private byte[] ram;
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public byte Peek(int addr)
|
|
|
|
|
{
|
2013-08-14 05:33:10 +00:00
|
|
|
|
return ram[addr & 0xFFFF];
|
2012-11-27 05:11:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Poke(int addr, byte val)
|
|
|
|
|
{
|
2013-08-14 05:33:10 +00:00
|
|
|
|
ram[addr & 0xFFFF] = 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-08-14 05:33:10 +00:00
|
|
|
|
return ram[addr & 0xFFFF];
|
2012-11-27 05:11:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-12-03 08:38:12 +00:00
|
|
|
|
public void SyncState(Serializer ser)
|
|
|
|
|
{
|
|
|
|
|
ByteBuffer buffer = new ByteBuffer(ram);
|
|
|
|
|
ser.Sync("ram", ref buffer);
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-14 05:05:17 +00:00
|
|
|
|
public void Write(int addr, byte val)
|
2012-11-27 05:11:40 +00:00
|
|
|
|
{
|
2013-08-14 05:33:10 +00:00
|
|
|
|
ram[addr & 0xFFFF] = val;
|
2012-11-27 05:11:40 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|