mirror of
https://github.com/zoriya/ComSquare.git
synced 2025-12-19 21:55:11 +00:00
53 lines
2.5 KiB
C++
53 lines
2.5 KiB
C++
//
|
|
// Created by anonymus-raccoon on 2/4/20.
|
|
//
|
|
|
|
#ifndef COMSQUARE_RECTANGLESHADOW_HPP
|
|
#define COMSQUARE_RECTANGLESHADOW_HPP
|
|
|
|
#include <memory>
|
|
#include "ARectangleMemory.hpp"
|
|
#include "MemoryShadow.hpp"
|
|
|
|
namespace ComSquare::Memory
|
|
{
|
|
class RectangleShadow : public ARectangleMemory {
|
|
private:
|
|
//! @brief Memory to shadow from.
|
|
std::shared_ptr<ARectangleMemory> _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);
|
|
RectangleShadow(const RectangleShadow &) = default;
|
|
RectangleShadow &operator=(const RectangleShadow &) = default;
|
|
~RectangleShadow() = 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 Check if this memory is a mirror or not.
|
|
//! @return True if this memory is a mirror. False otherwise.
|
|
bool isMirror() override;
|
|
//! @brief Get the name of this accessor (used for debug purpose)
|
|
std::string getName() override;
|
|
//! @brief Get the component of this accessor (used for debug purpose)
|
|
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;
|
|
|
|
RectangleShadow *setBankOffset(uint8_t bankOffset);
|
|
};
|
|
}
|
|
|
|
#endif //COMSQUARE_RECTANGLESHADOW_HPP
|