IRectangleMemory.hpp
Go to the documentation of this file.
//
// Created by anonymus-raccoon on 1/29/20.
//
#ifndef COMSQUARE_IRECTANGLEMEMORY_HPP
#define COMSQUARE_IRECTANGLEMEMORY_HPP
#include "IMemory.hpp"
namespace ComSquare::Memory
{
class IRectangleMemory : public IMemory {
private:
uint8_t _startBank = 0;
uint8_t _endBank = 0;
uint16_t _startPage = 0;
uint16_t _endPage = 0;
public:
uint8_t read(uint24_t addr) override;
void write(uint24_t addr, uint8_t data) override;
virtual uint8_t read_internal(uint24_t addr) = 0;
virtual void write_internal(uint24_t addr, uint8_t data) = 0;
bool hasMemoryAt(uint24_t addr) override;
uint24_t getStart() override;
void setMemoryRegion(uint8_t startBank, uint8_t endBank, uint16_t startPage, uint16_t endPage);
};
}
#endif //COMSQUARE_IRECTANGLEMEMORY_HPP
ComSquare::Memory::IRectangleMemory
Superset of the IMemory to map non continuous rectangle to the memory. (A rectangle that spam across ...
Definition: IRectangleMemory.hpp:14
ComSquare::Memory::IRectangleMemory::_startBank
uint8_t _startBank
The first bank to map to.
Definition: IRectangleMemory.hpp:17
ComSquare::Memory::IRectangleMemory::read
uint8_t read(uint24_t addr) override
Read data from the component using the same method as the basic IMemory.
Definition: IRectangleMemory.cpp:10
uint24_t
unsigned uint24_t
Definition: Ints.hpp:8
ComSquare::Memory::IMemory
Common interface implemented by all components mapping memory.
Definition: IMemory.hpp:16
ComSquare::Memory::IRectangleMemory::getStart
uint24_t getStart() override
Get the first address mapped to this component.
Definition: IRectangleMemory.cpp:53
ComSquare::Memory::IRectangleMemory::write
void write(uint24_t addr, uint8_t data) override
Write data to this component using the same method as the basic IMemory.
Definition: IRectangleMemory.cpp:26
ComSquare::Memory::IRectangleMemory::read_internal
virtual uint8_t read_internal(uint24_t addr)=0
Internal component read. Implement this as you would implement a basic IMemory's read.
ComSquare::Memory::IRectangleMemory::setMemoryRegion
void setMemoryRegion(uint8_t startBank, uint8_t endBank, uint16_t startPage, uint16_t endPage)
Change starting and ending points of this mapped memory.
Definition: IRectangleMemory.cpp:58
ComSquare::Memory::IRectangleMemory::_startPage
uint16_t _startPage
The first address of each bank to map.
Definition: IRectangleMemory.hpp:21
ComSquare::Memory::IRectangleMemory::_endPage
uint16_t _endPage
The last address of each bank to map.
Definition: IRectangleMemory.hpp:23
ComSquare::Memory
Definition: IMemory.cpp:8
IMemory.hpp
ComSquare::Memory::IRectangleMemory::write_internal
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.
ComSquare::Memory::IRectangleMemory::hasMemoryAt
bool hasMemoryAt(uint24_t addr) override
Return true if this component has mapped the address.
Definition: IRectangleMemory.cpp:42
ComSquare::Memory::IRectangleMemory::_endBank
uint8_t _endBank
The last bank to map to.
Definition: IRectangleMemory.hpp:19