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

54 lines
856 B
C#
Raw Normal View History

using BizHawk.Common;
namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS
{
// used as Color RAM in C64
2016-02-22 23:50:11 +00:00
public sealed class Chip2114
{
2017-04-24 13:35:05 +00:00
private int[] _ram = new int[0x400];
public Chip2114()
{
HardReset();
}
public void HardReset()
{
2017-04-24 13:35:05 +00:00
for (var i = 0; i < 0x400; i++)
{
_ram[i] = 0x0;
}
}
2016-02-22 23:50:11 +00:00
public int Peek(int addr)
{
2016-02-22 23:50:11 +00:00
return _ram[addr & 0x3FF];
}
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 & 0x3FF] = val & 0xF;
}
2016-02-22 23:50:11 +00:00
public int Read(int addr)
{
2016-02-22 23:50:11 +00:00
return _ram[addr & 0x3FF];
}
public int ReadInt(int addr)
{
2016-02-22 23:50:11 +00:00
return _ram[addr & 0x3FF];
}
public void SyncState(Serializer ser)
{
ser.Sync("_ram", ref _ram, useNull: false);
}
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 & 0x3FF] = val & 0xF;
}
}
}