MemoryBus.hpp
Go to the documentation of this file.
//
// Created by anonymus-raccoon on 1/23/20.
//
#ifndef COMSQUARE_MEMORYBUS_HPP
#define COMSQUARE_MEMORYBUS_HPP
#include <cstdint>
#include <vector>
#include <memory>
#include "IMemory.hpp"
namespace ComSquare
{
struct SNES;
namespace Memory
{
class MemoryBus {
private:
std::vector<std::shared_ptr<IMemory>> _memoryAccessors;
std::shared_ptr<IMemory> getAccessor(uint24_t addr);
uint8_t _openBus = 0;
inline void _mirrorComponents(SNES &console, int i);
public:
uint8_t read(uint24_t addr);
void write(uint24_t addr, uint8_t data);
void mapComponents(SNES &console);
};
}
}
#endif //COMSQUARE_MEMORYBUS_HPP
ComSquare::Memory::MemoryBus::read
uint8_t read(uint24_t addr)
Read data at a global address.
Definition: MemoryBus.cpp:24
ComSquare::Memory::MemoryBus
The memory bus is the component responsible of mapping addresses to components address and transmitti...
Definition: MemoryBus.hpp:20
ComSquare::Memory::MemoryBus::_memoryAccessors
std::vector< std::shared_ptr< IMemory > > _memoryAccessors
The list of components registered inside the bus. Every components that can read/write to a public ad...
Definition: MemoryBus.hpp:23
ComSquare::SNES
Container of all the components of the SNES.
Definition: SNES.hpp:18
uint24_t
unsigned uint24_t
Definition: Ints.hpp:8
ComSquare::Memory::MemoryBus::write
void write(uint24_t addr, uint8_t data)
Write a data to a global address.
Definition: MemoryBus.cpp:37
ComSquare::Memory::MemoryBus::getAccessor
std::shared_ptr< IMemory > getAccessor(uint24_t addr)
Helper function to get the components that is responsible of read/write at an address.
Definition: MemoryBus.cpp:13
ComSquare::Memory::MemoryBus::_openBus
uint8_t _openBus
The last value read via the memory bus.
Definition: MemoryBus.hpp:31
ComSquare::Memory::MemoryBus::mapComponents
void mapComponents(SNES &console)
Map components to the address space using the currently loaded cartridge to set the right mapping mod...
Definition: MemoryBus.cpp:56
IMemory.hpp
ComSquare::Memory::MemoryBus::_mirrorComponents
void _mirrorComponents(SNES &console, int i)
WRam, CPU, PPU & ALU registers are mirrored to all banks of Q1 & Q3. This function is used for the mi...
Definition: MemoryBus.cpp:48
ComSquare
Definition: APU.cpp:9