NESemu/src/Cartridge.hpp

62 lines
1.2 KiB
C++
Raw Normal View History

2022-02-28 15:04:25 +00:00
#pragma once
#include <string>
#include <memory>
#include "Types.hpp"
#include "Mapper.hpp"
class Bus;
2022-02-28 15:43:35 +00:00
/**
* @brief Represents a cartridge and handles CPU/PPU read/writes.
*/
2022-02-28 15:04:25 +00:00
class Cartridge
{
public:
2022-02-28 15:43:35 +00:00
/**
* @brief Add a cartridge to the Bus.
*/
2022-02-28 15:04:25 +00:00
Cartridge(Bus* bus);
~Cartridge();
2022-02-28 15:43:35 +00:00
/**
* @brief Read from the CPU.
*/
inline Byte ReadCPU(Word addr) { return mapper->ReadCPU(addr); }
2022-02-28 15:04:25 +00:00
2022-02-28 15:43:35 +00:00
/**
* @brief Read from the PPU.
*/
inline Byte ReadPPU(Word addr) { return mapper->ReadPPU(addr); }
/**
* @brief Wrote from the CPU.
*/
inline void WriteCPU(Word addr, Byte val) { mapper->WriteCPU(addr, val); }
/**
* @brief Write from the PPU.
*/
inline void WritePPU(Word addr, Byte val) { mapper->WritePPU(addr, val); }
2022-03-01 02:34:19 +00:00
inline bool MapCIRAM(Word& addr) { return mapper->MapCIRAM(addr); }
inline Byte ReadVRAM(Word addr) { return mapper->ReadVRAM(addr); }
inline void WriteVRAM(Word addr, Byte val) { mapper->WriteVRAM(addr, val); }
2022-02-28 15:43:35 +00:00
/**
* @brief Load an iNES file from disk.
*/
2022-02-28 15:04:25 +00:00
void Load(std::string path);
2022-02-28 15:43:35 +00:00
/**
* @brief Returns the Mapper used by the cartridge.
*/
2022-02-28 15:04:25 +00:00
inline Mapper* GetMapper() { return mapper; }
private:
Mapper* mapper;
Bus* bus;
};