Reworking the memory management & fixing a bug in the memory viewer goto

This commit is contained in:
Zoe Roux
2021-02-03 23:43:07 +01:00
parent 0b28719f41
commit 874c21b0fd
29 changed files with 295 additions and 307 deletions
+20 -18
View File
@@ -2,8 +2,7 @@
// Created by anonymus-raccoon on 2/4/20.
//
#ifndef COMSQUARE_RECTANGLESHADOW_HPP
#define COMSQUARE_RECTANGLESHADOW_HPP
#pragma once
#include <memory>
#include "ARectangleMemory.hpp"
@@ -14,26 +13,31 @@ namespace ComSquare::Memory
class RectangleShadow : public ARectangleMemory {
private:
//! @brief Memory to shadow from.
std::shared_ptr<ARectangleMemory> _initial;
std::shared_ptr<IMemory> _initial;
//! @brief The number of banks to add to the memory before accessing it from the initial data.
uint8_t _bankOffset = 0;
public:
//! @brief Create a shadow for the memory given as parameter.
explicit RectangleShadow(std::shared_ptr<ARectangleMemory> initial, uint8_t startBank, uint8_t endBank, uint16_t startPage, uint16_t endPage);
explicit RectangleShadow(std::shared_ptr<IMemory> initial, uint8_t startBank, uint8_t endBank, uint16_t startPage, uint16_t endPage);
RectangleShadow(const RectangleShadow &) = default;
RectangleShadow &operator=(const 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
//! @throw This function should thrown an InvalidAddress for address that are not mapped to the component.
//! @return Return the data at the address given as parameter.
uint8_t read_internal(uint24_t addr) override;
//! @brief Internal component write. Implement this as you would implement a basic AMemory's write.
//! @param addr The 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
//! @param data The new data to write.
//! @throw This function should thrown an InvalidAddress for address that are not mapped to the component.
void write_internal(uint24_t addr, uint8_t data) override;
//! @brief Read from the initial AMemory given.
//! @param addr The address to read from. The address 0x0 should refer to the first byte of the initial AMemory.
//! @throw InvalidAddress will be thrown if the address is more than the size of the initial AMemory.
//! @return Return the data at the address.
uint8_t read(uint24_t addr) override;
//! @brief Write data to the ram.
//! @param addr The address to write to. The address 0x0 should refer to the first byte of the initial AMemory.
//! @param data The data to write.
//! @throw InvalidAddress will be thrown if the address is more than the size of the initial AMemory.
void write(uint24_t addr, uint8_t data) override;
//! @brief Translate an absolute address to a relative address
//! @param addr The absolute address (in the 24 bit bus)
//! @return The local address (0 refers to the first byte of this component).
//! @throw InvalidAddress is thrown if the address is not mapped by this component.
uint24_t getRelativeAddress(uint24_t addr) override;
//! @brief Check if this memory is a mirror or not.
//! @return True if this memory is a mirror. False otherwise.
bool isMirror() override;
@@ -43,10 +47,8 @@ namespace ComSquare::Memory
Component getComponent() override;
//! @brief Return the memory accessor this accessor mirror if any
//! @return nullptr if isMirror is false, the source otherwise.
std::shared_ptr<AMemory> getMirrored() override;
std::shared_ptr<IMemory> getMirrored() override;
RectangleShadow *setBankOffset(uint8_t bankOffset);
};
}
#endif //COMSQUARE_RECTANGLESHADOW_HPP
}