ComSquare
IRectangleMemory.hpp
Go to the documentation of this file.
1 //
2 // Created by anonymus-raccoon on 1/29/20.
3 //
4 
5 #ifndef COMSQUARE_IRECTANGLEMEMORY_HPP
6 #define COMSQUARE_IRECTANGLEMEMORY_HPP
7 
8 
9 #include "IMemory.hpp"
10 
11 namespace ComSquare::Memory
12 {
14  class IRectangleMemory : public IMemory {
15  private:
17  uint8_t _startBank = 0;
19  uint8_t _endBank = 0;
21  uint16_t _startPage = 0;
23  uint16_t _endPage = 0;
24  public:
29  uint8_t read(uint24_t addr) override;
34  void write(uint24_t addr, uint8_t data) override;
39  virtual uint8_t read_internal(uint24_t addr) = 0;
44  virtual void write_internal(uint24_t addr, uint8_t data) = 0;
48  bool hasMemoryAt(uint24_t addr) override;
51  uint24_t getStart() override;
58  void setMemoryRegion(uint8_t startBank, uint8_t endBank, uint16_t startPage, uint16_t endPage);
59  };
60 }
61 
62 #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