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

Superset of the IMemory to map non continuous rectangle to the memory. (A rectangle that spam across more than one bank but that does not start at 0000 or end at FFFF). More...

#include <IRectangleMemory.hpp>

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

Public Member Functions

uint8_t read (uint24_t addr) override
 Read data from the component using the same method as the basic IMemory. More...
 
void write (uint24_t addr, uint8_t data) override
 Write data to this component using the same method as the basic IMemory. More...
 
virtual uint8_t read_internal (uint24_t addr)=0
 Internal component read. Implement this as you would implement a basic IMemory's read. More...
 
virtual void write_internal (uint24_t addr, uint8_t data)=0
 Internal component write. Implement this as you would implement a basic IMemory's write. More...
 
bool hasMemoryAt (uint24_t addr) override
 Return true if this component has mapped the address. More...
 
uint24_t getStart () override
 Get the first address mapped to this component. More...
 
void setMemoryRegion (uint8_t startBank, uint8_t endBank, uint16_t startPage, uint16_t endPage)
 Change starting and ending points of this mapped memory. More...
 
- Public Member Functions inherited from ComSquare::Memory::IMemory
void setMemoryRegion (uint24_t start, uint24_t end)
 Change starting and ending points of this mapped memory. More...
 

Private Attributes

uint8_t _startBank = 0
 The first bank to map to. More...
 
uint8_t _endBank = 0
 The last bank to map to. More...
 
uint16_t _startPage = 0
 The first address of each bank to map. More...
 
uint16_t _endPage = 0
 The last address of each bank to map. More...
 

Detailed Description

Superset of the IMemory to map non continuous rectangle to the memory. (A rectangle that spam across more than one bank but that does not start at 0000 or end at FFFF).

Member Function Documentation

◆ getStart()

uint24_t ComSquare::Memory::IRectangleMemory::getStart ( )
overridevirtual

Get the first address mapped to this component.

Returns
the _start value.

Reimplemented from ComSquare::Memory::IMemory.

◆ hasMemoryAt()

bool ComSquare::Memory::IRectangleMemory::hasMemoryAt ( uint24_t  addr)
overridevirtual

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 from ComSquare::Memory::IMemory.

◆ read()

uint8_t ComSquare::Memory::IRectangleMemory::read ( uint24_t  addr)
overridevirtual

Read data from the component using the same method as the basic IMemory.

Parameters
addrThe local address to read from. 0x0 should refer to the first byte of this component on the fist bank. This method is responsible of mapping to the component's read.
Exceptions
InvalidAddressif the address is not mapped to the component.
Returns
Return the data at the address given as parameter.

Implements ComSquare::Memory::IMemory.

◆ read_internal()

virtual uint8_t ComSquare::Memory::IRectangleMemory::read_internal ( uint24_t  addr)
pure virtual

Internal component read. Implement this as you would implement a basic IMemory's read.

Parameters
addrThe local address to read from. 0x0 refer to the first byte of your data and the address is in the component's space. That means that you can consider this address as continuous
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::Cartridge::Cartridge.

◆ setMemoryRegion()

void ComSquare::Memory::IRectangleMemory::setMemoryRegion ( uint8_t  startBank,
uint8_t  endBank,
uint16_t  startPage,
uint16_t  endPage 
)

Change starting and ending points of this mapped memory.

Parameters
startBankThe first bank mapped to this component.
endBankThe last bank mapped to this component.
startPageThe first page mapped to this component (every mapped banks will have this page mapped)
endPageThe end page mapped to this component (every mapped banks will have this pages lower than this mapped)
Warning
The start/end address should be a rectangle. To mirror memory, use the MemoryShadow class and not this one.

◆ write()

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

Write data to this component using the same method as the basic IMemory.

Parameters
addrThe local address to write data 0x0 should refer to the first byte of this component on the fist bank. This method is responsible of mapping to the component's write.
dataThe new data to write.
Exceptions
InvalidAddressif the address is not mapped to the component.

Implements ComSquare::Memory::IMemory.

◆ write_internal()

virtual void ComSquare::Memory::IRectangleMemory::write_internal ( uint24_t  addr,
uint8_t  data 
)
pure virtual

Internal component write. Implement this as you would implement a basic IMemory's write.

Parameters
addrThe local address to write to. 0x0 refer to the first byte of your data and the address is in the component's space. That means that you can consider this address as continuous
dataThe new data to write.
Exceptions
Thisfunction should thrown an InvalidAddress for address that are not mapped to the component.

Implemented in ComSquare::Cartridge::Cartridge.

Member Data Documentation

◆ _endBank

uint8_t ComSquare::Memory::IRectangleMemory::_endBank = 0
private

The last bank to map to.

◆ _endPage

uint16_t ComSquare::Memory::IRectangleMemory::_endPage = 0
private

The last address of each bank to map.

◆ _startBank

uint8_t ComSquare::Memory::IRectangleMemory::_startBank = 0
private

The first bank to map to.

◆ _startPage

uint16_t ComSquare::Memory::IRectangleMemory::_startPage = 0
private

The first address of each bank to map.


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