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

40 lines
645 B
C#
Raw Normal View History

2016-02-22 23:50:11 +00:00
using System;
namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS
{
// ROM chips
public sealed class Chip23128
{
2017-05-13 18:18:52 +00:00
private readonly int[] _rom;
2016-02-22 23:50:11 +00:00
2017-04-24 13:35:05 +00:00
public Chip23128()
{
_rom = new int[0x4000];
}
2016-02-22 23:50:11 +00:00
2017-04-24 13:35:05 +00:00
public Chip23128(byte[] data) : this()
2016-02-22 23:50:11 +00:00
{
2017-04-24 13:35:05 +00:00
Flash(data);
}
2016-02-22 23:50:11 +00:00
2017-04-24 13:35:05 +00:00
public void Flash(byte[] data)
{
// ensures ROM is mirrored
for (var i = 0; i < _rom.Length; i += data.Length)
{
Array.Copy(data, 0, _rom, i, data.Length);
}
}
2016-02-22 23:50:11 +00:00
2017-04-24 13:35:05 +00:00
public int Peek(int addr)
2016-02-22 23:50:11 +00:00
{
return _rom[addr & 0x3FFF];
}
public int Read(int addr)
{
return _rom[addr & 0x3FFF];
}
}
}