ComSquare
Public Member Functions | Private Attributes | List of all members
ComSquare::Memory::IMemory Class Referenceabstract

Common interface implemented by all components mapping memory. More...

#include <IMemory.hpp>

Inheritance diagram for ComSquare::Memory::IMemory:
Inheritance graph
Collaboration diagram for ComSquare::Memory::IMemory:
Collaboration graph

Public Member Functions

virtual uint8_t read (uint24_t addr)=0
 Read data from the component. More...
 
virtual void write (uint24_t addr, uint8_t data)=0
 Write data to this component. More...
 
void setMemoryRegion (uint24_t start, uint24_t end)
 Change starting and ending points of this mapped memory. More...
 
virtual bool hasMemoryAt (uint24_t addr)
 Return true if this component has mapped the address. More...
 
virtual uint24_t getStart ()
 Get the first address mapped to this component. More...
 

Private Attributes

uint24_t _start = 0
 The starting address mapped to this component. More...
 
uint24_t _end = 0
 The last continuous address mapped to this components. For shadows, see the MemoryShadow class. More...
 

Detailed Description

Common interface implemented by all components mapping memory.

Member Function Documentation

◆ getStart()

uint32_t ComSquare::Memory::IMemory::getStart ( )
virtual

Get the first address mapped to this component.

Returns
the _start value.

Reimplemented in ComSquare::Memory::IRectangleMemory.

◆ hasMemoryAt()

bool ComSquare::Memory::IMemory::hasMemoryAt ( uint24_t  addr)
virtual

Return true if this component has mapped the address.

Parameters
addrThe address to check.
Returns
True if this address is mapped to the component. False otherwise.

Reimplemented in ComSquare::Memory::IRectangleMemory.

◆ read()

virtual uint8_t ComSquare::Memory::IMemory::read ( uint24_t  addr)
pure virtual

Read data from the component.

Parameters
addrThe local address to read from (0x0 should refer to the first byte of this component).
Exceptions
Thisfunction should thrown an InvalidAddress for address that are not mapped to the component.
Returns
Return the data at the address given as parameter.

Implemented in ComSquare::PPU::PPU, ComSquare::CPU::CPU, ComSquare::APU::DSP::DSP, ComSquare::APU::APU, ComSquare::Memory::IRectangleMemory, ComSquare::Ram::Ram, and ComSquare::Memory::MemoryShadow.

◆ setMemoryRegion()

void ComSquare::Memory::IMemory::setMemoryRegion ( uint24_t  start,
uint24_t  end 
)

Change starting and ending points of this mapped memory.

Parameters
startThe first address mapped to this component.
endThe last address mapped to this component.
Warning
The start/end address should be a continuous range. You can't map address 0x0 and 0x2 but not 0x1. To do that, use two IMemory.

◆ write()

virtual void ComSquare::Memory::IMemory::write ( uint24_t  addr,
uint8_t  data 
)
pure virtual

Write data to this component.

Parameters
addrThe local address to write data (0x0 should refer to the first byte of this component).
dataThe new data to write.
Exceptions
Thisfunction should thrown an InvalidAddress for address that are not mapped to the component.

Implemented in ComSquare::PPU::PPU, ComSquare::CPU::CPU, ComSquare::APU::DSP::DSP, ComSquare::APU::APU, ComSquare::Memory::IRectangleMemory, ComSquare::Ram::Ram, and ComSquare::Memory::MemoryShadow.

Member Data Documentation

◆ _end

uint24_t ComSquare::Memory::IMemory::_end = 0
private

The last continuous address mapped to this components. For shadows, see the MemoryShadow class.

◆ _start

uint24_t ComSquare::Memory::IMemory::_start = 0
private

The starting address mapped to this component.


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