Path: blob/a-new-beginning/Cherry/Core/include/CVMemory.h
2 views
/*1* Gearcoleco - ColecoVision Emulator2* Copyright (C) 2021 Ignacio Sanchez34* This program is free software: you can redistribute it and/or modify5* it under the terms of the GNU General Public License as published by6* the Free Software Foundation, either version 3 of the License, or7* any later version.89* This program is distributed in the hope that it will be useful,10* but WITHOUT ANY WARRANTY; without even the implied warranty of11* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12* GNU General Public License for more details.1314* You should have received a copy of the GNU General Public License15* along with this program. If not, see http://www.gnu.org/licenses/16*17*/1819#ifndef MEMORY_H20#define MEMORY_H2122#include "definitions.h"23#include <vector>2425class Processor;26class Cartridge;27class Mapper;2829class CVMemory30{31public:32struct stDisassembleRecord33{34u16 address;35char segment[5];36char name[32];37char bytes[16];38int size;39int bank;40u8 opcodes[4];41bool jump;42u16 jump_address;43};4445struct stMemoryBreakpoint46{47u16 address1;48u16 address2;49bool read;50bool write;51bool range;52};5354public:55CVMemory(Cartridge* pCartridge);56~CVMemory();57void SetProcessor(Processor* pProcessor);58void Init();59void Reset();60void SetupMapper();61u8 Read(u16 address);62void Write(u16 address, u8 value);63u8* GetRam();64u8* GetSGMRam();65u8* GetBios();66u8 GetRomBank();67u32 GetRomBankAddress();68void LoadBios(const char* szFilePath);69bool IsBiosLoaded();70void SaveState(std::ostream& stream);71void LoadState(std::istream& stream);72void ResetRomDisassembledMemory();73stDisassembleRecord* GetDisassembleRecord(u16 address, bool createIfNotFound);74stDisassembleRecord** GetDisassembledRomMemoryMap();75stDisassembleRecord** GetDisassembledRamMemoryMap();76stDisassembleRecord** GetDisassembledBiosMemoryMap();77stDisassembleRecord** GetDisassembledSGMRamMemoryMap();78std::vector<stDisassembleRecord*>* GetBreakpointsCPU();79std::vector<stMemoryBreakpoint>* GetBreakpointsMem();80stDisassembleRecord* GetRunToBreakpoint();81void SetRunToBreakpoint(stDisassembleRecord* pBreakpoint);82void EnableSGMUpper(bool enable);83void EnableSGMLower(bool enable);84void Tick(unsigned int cycles) { m_iTotalCycles += cycles; }85u64 GetTotalCycles() const { return m_iTotalCycles; }8687private:88void CheckBreakpoints(u16 address, bool write);8990private:91Processor* m_pProcessor;92Cartridge* m_pCartridge;93Mapper* m_pMapper;94stDisassembleRecord** m_pDisassembledRomMap;95stDisassembleRecord** m_pDisassembledRamMap;96stDisassembleRecord** m_pDisassembledBiosMap;97stDisassembleRecord** m_pDisassembledSGMRamMap;98std::vector<stDisassembleRecord*> m_BreakpointsCPU;99std::vector<stMemoryBreakpoint> m_BreakpointsMem;100stDisassembleRecord* m_pRunToBreakpoint;101bool m_bBiosLoaded;102bool m_bSGMUpper;103bool m_bSGMLower;104u8* m_pBios;105u8* m_pRam;106u8* m_pSGMRam;107u64 m_iTotalCycles;108};109110#include "CVMemory_inline.h"111112#endif /* MEMORY_H */113114115