ComSquare
Public Member Functions | Private Member Functions | Private Attributes | List of all members
ComSquare::Memory::MemoryBus Class Reference

The memory bus is the component responsible of mapping addresses to components address and transmitting the data. More...

#include <MemoryBus.hpp>

Collaboration diagram for ComSquare::Memory::MemoryBus:
Collaboration graph

Public Member Functions

uint8_t read (uint24_t addr)
 Read data at a global address. More...
 
void write (uint24_t addr, uint8_t data)
 Write a data to a global address. More...
 
void mapComponents (SNES &console)
 Map components to the address space using the currently loaded cartridge to set the right mapping mode. More...
 

Private Member Functions

std::shared_ptr< IMemorygetAccessor (uint24_t addr)
 Helper function to get the components that is responsible of read/write at an address. More...
 
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 mirroring. More...
 

Private Attributes

std::vector< std::shared_ptr< IMemory > > _memoryAccessors
 The list of components registered inside the bus. Every components that can read/write to a public address should be in this vector. More...
 
uint8_t _openBus = 0
 The last value read via the memory bus. More...
 

Detailed Description

The memory bus is the component responsible of mapping addresses to components address and transmitting the data.

Member Function Documentation

◆ _mirrorComponents()

void ComSquare::Memory::MemoryBus::_mirrorComponents ( SNES console,
int  i 
)
inlineprivate

WRam, CPU, PPU & ALU registers are mirrored to all banks of Q1 & Q3. This function is used for the mirroring.

Parameters
consoleAll the components.
iBase address for the mirrors.

◆ getAccessor()

std::shared_ptr< IMemory > ComSquare::Memory::MemoryBus::getAccessor ( uint24_t  addr)
private

Helper function to get the components that is responsible of read/write at an address.

Parameters
addrThe address you want to look for.
Returns
The components responsible for the address param or nullptr if none was found.

◆ mapComponents()

void ComSquare::Memory::MemoryBus::mapComponents ( SNES console)

Map components to the address space using the currently loaded cartridge to set the right mapping mode.

Parameters
consoleAll the components.

◆ read()

uint8_t ComSquare::Memory::MemoryBus::read ( uint24_t  addr)

Read data at a global address.

Parameters
addrThe address to read from.
Returns
The value that the component returned for this address. If the address was mapped to ram, it simply returned the value. If the address was mapped to a register the component returned the register.

◆ write()

void ComSquare::Memory::MemoryBus::write ( uint24_t  addr,
uint8_t  data 
)

Write a data to a global address.

Parameters
addrThe address to write to.
dataThe data to write.

Member Data Documentation

◆ _memoryAccessors

std::vector<std::shared_ptr<IMemory> > ComSquare::Memory::MemoryBus::_memoryAccessors
private

The list of components registered inside the bus. Every components that can read/write to a public address should be in this vector.

◆ _openBus

uint8_t ComSquare::Memory::MemoryBus::_openBus = 0
private

The last value read via the memory bus.


The documentation for this class was generated from the following files: