mirror of
https://github.com/zoriya/ComSquare.git
synced 2026-05-27 00:07:10 +00:00
Fixing memory shadow's bank offset
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include <iostream>
|
||||
#include "ARectangleMemory.hpp"
|
||||
#include "../Exceptions/InvalidAddress.hpp"
|
||||
#include "../Utility/Utility.hpp"
|
||||
|
||||
namespace ComSquare::Memory
|
||||
{
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace ComSquare::Memory
|
||||
{
|
||||
//! @brief Superset of the AMemory 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).
|
||||
class ARectangleMemory : public AMemory {
|
||||
private:
|
||||
protected:
|
||||
//! @brief The first bank to map to.
|
||||
uint8_t _startBank = 0;
|
||||
//! @brief The last bank to map to.
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
//
|
||||
|
||||
#include "RectangleShadow.hpp"
|
||||
#include "../Utility/Utility.hpp"
|
||||
|
||||
#include <utility>
|
||||
#include <iostream>
|
||||
@@ -17,13 +18,13 @@ namespace ComSquare::Memory
|
||||
|
||||
uint8_t RectangleShadow::read_internal(uint24_t addr)
|
||||
{
|
||||
addr += this->_bankOffset << 16u;
|
||||
addr += this->_bankOffset * (this->_endPage - this->_startPage);
|
||||
return this->_initial->read_internal(addr);
|
||||
}
|
||||
|
||||
void RectangleShadow::write_internal(uint24_t addr, uint8_t data)
|
||||
{
|
||||
addr += this->_bankOffset << 16u;
|
||||
addr += this->_bankOffset * (this->_endPage - this->_startPage);
|
||||
this->_initial->write_internal(addr, data);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace ComSquare::Memory
|
||||
explicit RectangleShadow(std::shared_ptr<ARectangleMemory> initial, uint8_t startBank, uint8_t endBank, uint16_t startPage, uint16_t endPage);
|
||||
RectangleShadow(const RectangleShadow &) = default;
|
||||
RectangleShadow &operator=(const RectangleShadow &) = default;
|
||||
~RectangleShadow() = default;
|
||||
~RectangleShadow() override = default;
|
||||
|
||||
//! @brief Internal component read. Implement this as you would implement a basic AMemory's read.
|
||||
//! @param addr The 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
|
||||
|
||||
Reference in New Issue
Block a user