mirror of
https://github.com/zoriya/ComSquare.git
synced 2025-12-22 23:25:22 +00:00
Cleaning up
This commit is contained in:
@@ -2,13 +2,14 @@
|
||||
// Created by anonymus-raccoon on 1/23/20.
|
||||
//
|
||||
|
||||
#ifndef COMSQUARE_MEMORYBUS_HPP
|
||||
#define COMSQUARE_MEMORYBUS_HPP
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include "AMemory.hpp"
|
||||
#include "RectangleShadow.hpp"
|
||||
#include "MemoryShadow.hpp"
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
namespace ComSquare
|
||||
{
|
||||
@@ -17,10 +18,16 @@ namespace ComSquare
|
||||
namespace Memory
|
||||
{
|
||||
//! @brief The memory bus is the component responsible of mapping addresses to components address and transmitting the data.
|
||||
class MemoryBus {
|
||||
class MemoryBus
|
||||
{
|
||||
private:
|
||||
//! @brief The list of components registered inside the bus. Every components that can read/write to a public address should be in this vector.
|
||||
std::vector<std::shared_ptr<IMemory>> _memoryAccessors;
|
||||
std::vector<std::reference_wrapper<IMemory>> _memoryAccessors;
|
||||
|
||||
//! @brief The list of simple memory shadows that are used to map duplicated zones of memory.
|
||||
std::vector<MemoryShadow> _shadows = {};
|
||||
//! @brief The list of rectangle memory shadows that are used to map duplicated zones of memory.
|
||||
std::vector<RectangleShadow> _rectangleShadows = {};
|
||||
|
||||
//! @brief WRam, CPU, PPU & APU registers are mirrored to all banks of Q1 & Q3. This function is used for the mirroring.
|
||||
//! @param console All the components.
|
||||
@@ -30,29 +37,33 @@ namespace ComSquare
|
||||
//! @brief The last value read via the memory bus.
|
||||
uint8_t _openBus = 0;
|
||||
public:
|
||||
//! @brief Create a new default memory bus.
|
||||
MemoryBus() = default;
|
||||
//! @brief A memory bus is copyable.
|
||||
MemoryBus(const MemoryBus &) = default;
|
||||
//! @brief A memory bus is assignable.
|
||||
MemoryBus &operator=(const MemoryBus &) = default;
|
||||
//! @brief A default destructor
|
||||
~MemoryBus() = default;
|
||||
|
||||
//! @brief Force silencing read to the bus.
|
||||
bool forceSilence = false;
|
||||
|
||||
//! @brief Read data at a global address.
|
||||
//! @param addr The address to read from.
|
||||
//! @return The value that the component returned for this address. If the address was mapped to ram, it simply returned the value. If the address was mapped to a register the component returned the register.
|
||||
virtual uint8_t read(uint24_t addr);
|
||||
|
||||
//! @brief Read data at a global address. This form allow read to be silenced.
|
||||
//! @param addr The address to read from.
|
||||
//! @param silence Disable login to the memory bus's debugger (if enabled). Should only be used by other debuggers. This also won't affect the open bus.
|
||||
//! @throws InvalidAddress If the address is not mapped to the bus, this exception is thrown.
|
||||
//! @return The value that the component returned for this address. If the address was mapped to ram, it simply returned the value. If the address was mapped to a register the component returned the register.
|
||||
virtual uint8_t read(uint24_t addr, bool silence);
|
||||
uint8_t read(uint24_t addr);
|
||||
|
||||
//! @brief This as the same purpose as a read but it does not change the open bus and won't throw an exception.
|
||||
//! @param addr The address to read from.
|
||||
//! @return The value that the component returned for this address. If the address was mapped to ram, it simply returned the value. If the address was mapped to a register the component returned the register.
|
||||
uint8_t peek(uint24_t addr);
|
||||
|
||||
//! @brief Write a data to a global address.
|
||||
//! @param addr The address to write to.
|
||||
//! @param data The data to write.
|
||||
virtual void write(uint24_t addr, uint8_t data);
|
||||
void write(uint24_t addr, uint8_t data);
|
||||
|
||||
//! @brief Map components to the address space using the currently loaded cartridge to set the right mapping mode.
|
||||
//! @param console All the components.
|
||||
@@ -61,13 +72,7 @@ namespace ComSquare
|
||||
//! @brief Helper function to get the components that is responsible of read/write at an address.
|
||||
//! @param addr The address you want to look for.
|
||||
//! @return The components responsible for the address param or nullptr if none was found.
|
||||
std::shared_ptr<IMemory> getAccessor(uint24_t addr);
|
||||
|
||||
//! @brief Return true if the Bus is overloaded with debugging features.
|
||||
virtual bool isDebugger();
|
||||
IMemory *getAccessor(uint24_t addr);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif //COMSQUARE_MEMORYBUS_HPP
|
||||
|
||||
Reference in New Issue
Block a user