2018-06-25 16:58:01 +00:00
|
|
|
#pragma once
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include "IMemoryHandler.h"
|
|
|
|
|
|
|
|
template<size_t Mask>
|
|
|
|
class InternalRamHandler : public IMemoryHandler
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
uint8_t *_internalRam;
|
|
|
|
|
|
|
|
public:
|
|
|
|
void SetInternalRam(uint8_t* internalRam)
|
|
|
|
{
|
|
|
|
_internalRam = internalRam;
|
|
|
|
}
|
|
|
|
|
|
|
|
void GetMemoryRanges(MemoryRanges &ranges) override
|
|
|
|
{
|
|
|
|
ranges.SetAllowOverride();
|
|
|
|
ranges.AddHandler(MemoryOperation::Any, 0, 0x1FFF);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint8_t ReadRAM(uint16_t addr) override
|
|
|
|
{
|
|
|
|
return _internalRam[addr & Mask];
|
|
|
|
}
|
|
|
|
|
2018-12-25 04:31:32 +00:00
|
|
|
uint8_t PeekRAM(uint16_t addr) override
|
|
|
|
{
|
|
|
|
return ReadRAM(addr);
|
|
|
|
}
|
|
|
|
|
2018-06-25 16:58:01 +00:00
|
|
|
void WriteRAM(uint16_t addr, uint8_t value) override
|
|
|
|
{
|
|
|
|
_internalRam[addr & Mask] = value;
|
|
|
|
}
|
|
|
|
};
|