ComSquare
MemoryBus.hpp
Go to the documentation of this file.
1 //
2 // Created by anonymus-raccoon on 1/23/20.
3 //
4 
5 #ifndef COMSQUARE_MEMORYBUS_HPP
6 #define COMSQUARE_MEMORYBUS_HPP
7 
8 #include <cstdint>
9 #include <vector>
10 #include <memory>
11 #include "IMemory.hpp"
12 
13 namespace ComSquare
14 {
15  struct SNES;
16 
17  namespace Memory
18  {
20  class MemoryBus {
21  private:
23  std::vector<std::shared_ptr<IMemory>> _memoryAccessors;
24 
28  std::shared_ptr<IMemory> getAccessor(uint24_t addr);
29 
31  uint8_t _openbus = 0;
32 
36  inline void _mirrorComponents(SNES &console, int i);
37 
38  public:
42  uint8_t read(uint24_t addr);
43 
47  void write(uint24_t addr, uint8_t data);
48 
51  void mapComponents(SNES &console);
52  };
53  }
54 }
55 
56 
57 #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