2014-06-14 15:27:55 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "stdafx.h"
|
2017-04-01 02:14:16 +00:00
|
|
|
#include "Types.h"
|
2016-07-02 18:48:46 +00:00
|
|
|
|
2014-06-25 16:22:48 +00:00
|
|
|
class MemoryRanges
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
vector<uint16_t> _ramReadAddresses;
|
|
|
|
vector<uint16_t> _ramWriteAddresses;
|
2016-06-26 00:46:54 +00:00
|
|
|
bool _allowOverride = false;
|
2014-06-25 16:22:48 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
vector<uint16_t>* GetRAMReadAddresses() { return &_ramReadAddresses; }
|
|
|
|
vector<uint16_t>* GetRAMWriteAddresses() { return &_ramWriteAddresses; }
|
|
|
|
|
2016-06-26 00:46:54 +00:00
|
|
|
bool GetAllowOverride()
|
|
|
|
{
|
|
|
|
return _allowOverride;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetAllowOverride()
|
|
|
|
{
|
|
|
|
_allowOverride = true;
|
|
|
|
}
|
|
|
|
|
2015-07-30 02:10:34 +00:00
|
|
|
void AddHandler(MemoryOperation operation, uint16_t start, uint16_t end = 0)
|
2014-06-25 16:22:48 +00:00
|
|
|
{
|
|
|
|
if(end == 0) {
|
|
|
|
end = start;
|
|
|
|
}
|
|
|
|
|
2017-03-12 02:03:45 +00:00
|
|
|
if(operation == MemoryOperation::Read || operation == MemoryOperation::Any) {
|
|
|
|
for(uint32_t i = start; i <= end; i++) {
|
|
|
|
_ramReadAddresses.push_back((uint16_t)i);
|
|
|
|
}
|
2014-06-25 16:22:48 +00:00
|
|
|
}
|
2017-03-12 02:03:45 +00:00
|
|
|
|
|
|
|
if(operation == MemoryOperation::Write || operation == MemoryOperation::Any) {
|
|
|
|
for(uint32_t i = start; i <= end; i++) {
|
|
|
|
_ramWriteAddresses.push_back((uint16_t)i);
|
|
|
|
}
|
2014-06-25 16:22:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-06-14 15:27:55 +00:00
|
|
|
class IMemoryHandler
|
|
|
|
{
|
2014-06-16 01:45:36 +00:00
|
|
|
public:
|
2014-06-25 16:22:48 +00:00
|
|
|
virtual void GetMemoryRanges(MemoryRanges &ranges) = 0;
|
2014-06-16 01:45:36 +00:00
|
|
|
virtual uint8_t ReadRAM(uint16_t addr) = 0;
|
|
|
|
virtual void WriteRAM(uint16_t addr, uint8_t value) = 0;
|
2018-12-25 04:31:32 +00:00
|
|
|
virtual uint8_t PeekRAM(uint16_t addr) { return 0; }
|
2018-06-11 23:07:05 +00:00
|
|
|
|
|
|
|
virtual ~IMemoryHandler() {}
|
2014-06-14 15:27:55 +00:00
|
|
|
};
|