Fixing memory shadow's bank offset

This commit is contained in:
Anonymus Raccoon
2020-04-06 15:49:46 +02:00
parent 9d5cbb4ed2
commit e60c6d7bd7
6 changed files with 98 additions and 5 deletions
+1
View File
@@ -5,6 +5,7 @@
#include <iostream>
#include "ARectangleMemory.hpp"
#include "../Exceptions/InvalidAddress.hpp"
#include "../Utility/Utility.hpp"
namespace ComSquare::Memory
{
+1 -1
View File
@@ -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 -2
View File
@@ -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);
}
+1 -1
View File
@@ -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