Mesen-X/Core/MemoryManager.h

56 lines
1.4 KiB
C
Raw Normal View History

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
class BaseMapper;
2014-06-25 21:52:37 -04:00
class MemoryManager: public Snapshotable
2014-06-14 11:27:55 -04:00
{
private:
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
shared_ptr<BaseMapper> _mapper;
2014-06-14 11:27:55 -04:00
uint8_t *_internalRAM;
uint8_t *_nametableRAM[2];
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:
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);
uint8_t DebugRead(uint16_t addr);
uint8_t DebugReadVRAM(uint16_t addr);
uint8_t* GetInternalRAM();
void ProcessCpuClock();
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);
void ProcessVramAccess(uint16_t &addr);
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);
uint32_t ToAbsoluteChrAddress(uint16_t vramAddr);
2014-06-14 11:27:55 -04:00
};