2014-06-14 11:27:55 -04:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include "IMemoryHandler.h"
|
2014-06-25 21:52:37 -04:00
|
|
|
#include "Snapshotable.h"
|
2014-06-14 11:27:55 -04:00
|
|
|
|
2015-07-01 23:17:14 -04:00
|
|
|
class BaseMapper;
|
|
|
|
|
2014-06-25 21:52:37 -04:00
|
|
|
class MemoryManager: public Snapshotable
|
2014-06-14 11:27:55 -04:00
|
|
|
{
|
|
|
|
private:
|
2015-08-09 20:45:45 -04:00
|
|
|
static const int RAMSize = 0x10000;
|
|
|
|
static const int InternalRAMSize = 0x800;
|
|
|
|
static const int VRAMSize = 0x4000;
|
|
|
|
static const int NameTableScreenSize = 0x400;
|
2014-06-14 11:27:55 -04:00
|
|
|
|
2014-06-24 02:47:32 -04:00
|
|
|
shared_ptr<BaseMapper> _mapper;
|
2014-06-19 19:58:15 -04:00
|
|
|
|
2014-06-14 11:27:55 -04:00
|
|
|
uint8_t *_internalRAM;
|
2015-07-29 22:10:34 -04:00
|
|
|
uint8_t *_nametableRAM[2];
|
2014-07-01 12:44:01 -04:00
|
|
|
|
2014-06-25 12:22:48 -04:00
|
|
|
IMemoryHandler** _ramReadHandlers;
|
|
|
|
IMemoryHandler** _ramWriteHandlers;
|
2014-06-14 11:27:55 -04:00
|
|
|
|
2014-06-15 21:45:36 -04:00
|
|
|
uint8_t ReadRegister(uint16_t addr);
|
|
|
|
void WriteRegister(uint16_t addr, uint8_t value);
|
2016-06-25 20:46:54 -04:00
|
|
|
void InitializeMemoryHandlers(IMemoryHandler** memoryHandlers, IMemoryHandler* handler, vector<uint16_t> *addresses, bool allowOverride);
|
2014-06-15 21:45:36 -04:00
|
|
|
|
2014-06-25 21:52:37 -04:00
|
|
|
protected:
|
|
|
|
void StreamState(bool saving);
|
|
|
|
|
2014-06-14 11:27:55 -04:00
|
|
|
public:
|
2014-06-24 02:47:32 -04:00
|
|
|
MemoryManager(shared_ptr<BaseMapper> mapper);
|
2014-06-14 11:27:55 -04:00
|
|
|
~MemoryManager();
|
|
|
|
|
2015-07-05 20:30:39 -04:00
|
|
|
void Reset(bool softReset);
|
2014-06-14 11:27:55 -04:00
|
|
|
void RegisterIODevice(IMemoryHandler *handler);
|
|
|
|
|
2015-06-24 19:26:19 -04:00
|
|
|
uint8_t DebugRead(uint16_t addr);
|
2015-08-05 20:40:10 -04:00
|
|
|
uint8_t DebugReadVRAM(uint16_t addr);
|
|
|
|
|
2015-07-01 23:17:14 -04:00
|
|
|
uint8_t* GetInternalRAM();
|
|
|
|
|
2016-01-24 16:51:58 -05:00
|
|
|
void ProcessCpuClock();
|
|
|
|
|
2015-08-17 19:32:10 -04:00
|
|
|
uint8_t Read(uint16_t addr, MemoryOperationType operationType = MemoryOperationType::Read);
|
2014-06-15 21:45:36 -04:00
|
|
|
void Write(uint16_t addr, uint8_t value);
|
|
|
|
|
2015-07-29 22:10:34 -04:00
|
|
|
void ProcessVramAccess(uint16_t &addr);
|
2015-08-17 19:32:10 -04:00
|
|
|
uint8_t ReadVRAM(uint16_t addr, MemoryOperationType operationType = MemoryOperationType::PpuRenderingRead);
|
2014-06-15 21:45:36 -04:00
|
|
|
void WriteVRAM(uint16_t addr, uint8_t value);
|
2015-08-14 21:50:14 -04:00
|
|
|
|
|
|
|
uint32_t ToAbsoluteChrAddress(uint16_t vramAddr);
|
2014-06-14 11:27:55 -04:00
|
|
|
};
|
|
|
|
|