mirror of
https://github.com/zoriya/ComSquare.git
synced 2025-12-20 06:05:11 +00:00
Adding const qualifiers to the IMemory and adding error messages in the memory viewer
This commit is contained in:
@@ -17,22 +17,23 @@ namespace ComSquare::APU
|
|||||||
this->reset();
|
this->reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool APU::isDebugger()
|
bool APU::isDebugger() const
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string APU::getName()
|
std::string APU::getName() const
|
||||||
{
|
{
|
||||||
return "APU";
|
return "APU";
|
||||||
}
|
}
|
||||||
|
|
||||||
Component APU::getComponent()
|
Component APU::getComponent() const
|
||||||
{
|
{
|
||||||
return Apu;
|
return Apu;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t APU::_internalRead(uint24_t addr) {
|
uint8_t APU::_internalRead(uint24_t addr) const
|
||||||
|
{
|
||||||
switch (addr) {
|
switch (addr) {
|
||||||
case 0x0000 ... 0x00EF:
|
case 0x0000 ... 0x00EF:
|
||||||
return this->_map->Page0.read(addr);
|
return this->_map->Page0.read(addr);
|
||||||
@@ -71,7 +72,8 @@ namespace ComSquare::APU
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void APU::_internalWrite(uint24_t addr, uint8_t data) {
|
void APU::_internalWrite(uint24_t addr, uint8_t data)
|
||||||
|
{
|
||||||
switch (addr) {
|
switch (addr) {
|
||||||
case 0x0000 ... 0x00EF:
|
case 0x0000 ... 0x00EF:
|
||||||
this->_map->Page0.write(addr, data);
|
this->_map->Page0.write(addr, data);
|
||||||
@@ -129,7 +131,7 @@ namespace ComSquare::APU
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t APU::read(uint24_t addr)
|
uint8_t APU::read(uint24_t addr) const
|
||||||
{
|
{
|
||||||
switch (addr) {
|
switch (addr) {
|
||||||
case 0x00:
|
case 0x00:
|
||||||
@@ -165,6 +167,11 @@ namespace ComSquare::APU
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint24_t APU::getSize() const
|
||||||
|
{
|
||||||
|
return 0x3;
|
||||||
|
}
|
||||||
|
|
||||||
void APU::reset()
|
void APU::reset()
|
||||||
{
|
{
|
||||||
this->_registers.port0 = 0x00;
|
this->_registers.port0 = 0x00;
|
||||||
|
|||||||
@@ -149,19 +149,14 @@ namespace ComSquare::APU
|
|||||||
//! @param addr The address to read from. The address 0x0000 should refer to the first byte of the register.
|
//! @param addr The address to read from. The address 0x0000 should refer to the first byte of the register.
|
||||||
//! @throw InvalidAddress will be thrown if the address is more than $FFFF (the number of register).
|
//! @throw InvalidAddress will be thrown if the address is more than $FFFF (the number of register).
|
||||||
//! @return Return the data.
|
//! @return Return the data.
|
||||||
uint8_t _internalRead(uint24_t addr);
|
uint8_t _internalRead(uint24_t addr) const;
|
||||||
|
|
||||||
//! @brief Write data to the APU ram.
|
//! @brief Write data to the APU ram.
|
||||||
//! @param addr The address to write to. The address 0x0000 should refer to the first byte of register.
|
//! @param addr The address to write to. The address 0x0000 should refer to the first byte of register.
|
||||||
//! @param data The new value of the register.
|
//! @param data The new value of the register.
|
||||||
//! @throw InvalidAddress will be thrown if the address is more than $FFFF (the number of register).
|
//! @throw InvalidAddress will be thrown if the address is more than $FFFF (the number of register).
|
||||||
void _internalWrite(uint24_t addr, uint8_t data);
|
void _internalWrite(uint24_t addr, uint8_t data);
|
||||||
|
|
||||||
//! @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 Current state of APU CPU
|
//! @brief Current state of APU CPU
|
||||||
StateMode _state = Running;
|
StateMode _state = Running;
|
||||||
|
|
||||||
@@ -372,16 +367,28 @@ namespace ComSquare::APU
|
|||||||
APU &operator=(const APU &) = default;
|
APU &operator=(const APU &) = default;
|
||||||
~APU() override = default;
|
~APU() override = default;
|
||||||
|
|
||||||
//! @brief Read from the internal APU register.
|
//! @brief Read from the APU ram.
|
||||||
//! @param addr The address to read from. The address 0x00 should refer to the first byte of the register.
|
//! @param addr The address to read from. The address 0x0000 should refer to the first byte of the register.
|
||||||
//! @throw InvalidAddress will be thrown if the address is more than $0F (the number of register).
|
//! @throw InvalidAddress will be thrown if the address is more than $FFFF (the number of register).
|
||||||
//! @return Return the value of the register.
|
//! @return Return the data.
|
||||||
uint8_t read(uint24_t addr) override;
|
uint8_t read(uint24_t addr) const override;
|
||||||
//! @brief Write data to the internal APU register.
|
|
||||||
//! @param addr The address to write to. The address 0x00 should refer to the first byte of register.
|
//! @brief Write data to the APU ram.
|
||||||
|
//! @param addr The address to write to. The address 0x0000 should refer to the first byte of register.
|
||||||
//! @param data The new value of the register.
|
//! @param data The new value of the register.
|
||||||
//! @throw InvalidAddress will be thrown if the address is more than $0F (the number of register).
|
//! @throw InvalidAddress will be thrown if the address is more than $FFFF (the number of register).
|
||||||
void write(uint24_t addr, uint8_t data) override;
|
void write(uint24_t addr, uint8_t data) override;
|
||||||
|
|
||||||
|
//! @brief Get the name of this accessor (used for debug purpose)
|
||||||
|
std::string getName() const override;
|
||||||
|
|
||||||
|
//! @brief Get the component of this accessor (used for debug purpose)
|
||||||
|
Component getComponent() const override;
|
||||||
|
|
||||||
|
//! @brief Get the size of the data. This size can be lower than the mapped data.
|
||||||
|
//! @return The number of bytes inside this memory.
|
||||||
|
uint24_t getSize() const override;
|
||||||
|
|
||||||
//! @brief This function execute the instructions received until the maximum number of cycles is reached.
|
//! @brief This function execute the instructions received until the maximum number of cycles is reached.
|
||||||
//! @return The number of cycles that elapsed.
|
//! @return The number of cycles that elapsed.
|
||||||
virtual void update(unsigned cycles);
|
virtual void update(unsigned cycles);
|
||||||
@@ -390,7 +397,7 @@ namespace ComSquare::APU
|
|||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
//! @brief Return true if the CPU is overloaded with debugging features.
|
//! @brief Return true if the CPU is overloaded with debugging features.
|
||||||
virtual bool isDebugger();
|
virtual bool isDebugger() const;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
namespace ComSquare::APU::DSP
|
namespace ComSquare::APU::DSP
|
||||||
{
|
{
|
||||||
uint8_t DSP::read(uint24_t addr)
|
uint8_t DSP::read(uint24_t addr) const
|
||||||
{
|
{
|
||||||
switch (addr) {
|
switch (addr) {
|
||||||
case 0x00:
|
case 0x00:
|
||||||
@@ -579,6 +579,11 @@ namespace ComSquare::APU::DSP
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint24_t DSP::getSize() const
|
||||||
|
{
|
||||||
|
return 0x7F;
|
||||||
|
}
|
||||||
|
|
||||||
Registers DSP::getRegisters()
|
Registers DSP::getRegisters()
|
||||||
{
|
{
|
||||||
return this->_registers;
|
return this->_registers;
|
||||||
@@ -589,12 +594,12 @@ namespace ComSquare::APU::DSP
|
|||||||
return this->_channels;
|
return this->_channels;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string DSP::getName()
|
std::string DSP::getName() const
|
||||||
{
|
{
|
||||||
return "DSP";
|
return "DSP";
|
||||||
}
|
}
|
||||||
|
|
||||||
Component DSP::getComponent()
|
Component DSP::getComponent() const
|
||||||
{
|
{
|
||||||
return Apu;
|
return Apu;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ namespace ComSquare::APU::DSP
|
|||||||
//! @param addr The address to read from. The address 0x0 should refer to the first byte of the register.
|
//! @param addr The address to read from. The address 0x0 should refer to the first byte of the register.
|
||||||
//! @throw InvalidAddress will be thrown if the address is more than $7F (the number of register).
|
//! @throw InvalidAddress will be thrown if the address is more than $7F (the number of register).
|
||||||
//! @return Return the value of the register.
|
//! @return Return the value of the register.
|
||||||
uint8_t read(uint24_t addr) override;
|
uint8_t read(uint24_t addr) const override;
|
||||||
//! @brief Write data to the internal DSP register.
|
//! @brief Write data to the internal DSP register.
|
||||||
//! @param addr The address to write to. The address 0x0 should refer to the first byte of register.
|
//! @param addr The address to write to. The address 0x0 should refer to the first byte of register.
|
||||||
//! @param data The new value of the register.
|
//! @param data The new value of the register.
|
||||||
@@ -142,10 +142,14 @@ namespace ComSquare::APU::DSP
|
|||||||
void write(uint24_t addr, uint8_t data) override;
|
void write(uint24_t addr, uint8_t data) override;
|
||||||
|
|
||||||
//! @brief Get the name of this accessor (used for debug purpose)
|
//! @brief Get the name of this accessor (used for debug purpose)
|
||||||
std::string getName() override;
|
std::string getName() const override;
|
||||||
|
|
||||||
//! @brief Get the component of this accessor (used for debug purpose)
|
//! @brief Get the component of this accessor (used for debug purpose)
|
||||||
Component getComponent() override;
|
Component getComponent() const override;
|
||||||
|
|
||||||
|
//! @brief Get the size of the data. This size can be lower than the mapped data.
|
||||||
|
//! @return The number of bytes inside this memory.
|
||||||
|
uint24_t getSize() const override;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ namespace ComSquare::APU::IPL
|
|||||||
IPL::~IPL()
|
IPL::~IPL()
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
uint8_t IPL::read(uint24_t addr)
|
uint8_t IPL::read(uint24_t addr) const
|
||||||
{
|
{
|
||||||
if (addr >= this->_size)
|
if (addr >= this->_size)
|
||||||
throw InvalidAddress("IPL read", addr);
|
throw InvalidAddress("IPL read", addr);
|
||||||
@@ -31,12 +31,17 @@ namespace ComSquare::APU::IPL
|
|||||||
this->_data[addr] = data;
|
this->_data[addr] = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string IPL::getName()
|
uint24_t IPL::getSize() const
|
||||||
|
{
|
||||||
|
return this->_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string IPL::getName() const
|
||||||
{
|
{
|
||||||
return this->_iplName;
|
return this->_iplName;
|
||||||
}
|
}
|
||||||
|
|
||||||
Component IPL::getComponent()
|
Component IPL::getComponent() const
|
||||||
{
|
{
|
||||||
return this->_iplType;
|
return this->_iplType;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ namespace ComSquare::APU::IPL
|
|||||||
//! @param addr The global 24 bits address. This method is responsible of mapping to the component's read.
|
//! @param addr The global 24 bits address. This method is responsible of mapping to the component's read.
|
||||||
//! @throw InvalidAddress if the address is not mapped to the component.
|
//! @throw InvalidAddress if the address is not mapped to the component.
|
||||||
//! @return Return the data at the address given as parameter.
|
//! @return Return the data at the address given as parameter.
|
||||||
uint8_t read(uint24_t addr) override;
|
uint8_t read(uint24_t addr) const override;
|
||||||
|
|
||||||
//! @brief Write data to this component using the same method as the basic IMemory.
|
//! @brief Write data to this component using the same method as the basic IMemory.
|
||||||
//! @param addr The global 24 bits address. This method is responsible of mapping to the component's write.
|
//! @param addr The global 24 bits address. This method is responsible of mapping to the component's write.
|
||||||
@@ -53,11 +53,15 @@ namespace ComSquare::APU::IPL
|
|||||||
//! @throw InvalidAddress if the address is not mapped to the component.
|
//! @throw InvalidAddress if the address is not mapped to the component.
|
||||||
void write(uint24_t addr, uint8_t data) override;
|
void write(uint24_t addr, uint8_t data) override;
|
||||||
|
|
||||||
|
//! @brief Get the size of the data. This size can be lower than the mapped data.
|
||||||
|
//! @return The number of bytes inside this memory.
|
||||||
|
uint24_t getSize() const override;
|
||||||
|
|
||||||
//! @brief Get the name of this accessor (used for debug purpose)
|
//! @brief Get the name of this accessor (used for debug purpose)
|
||||||
std::string getName() override;
|
std::string getName() const override;
|
||||||
|
|
||||||
//! @brief Get the component of this accessor (used for debug purpose)
|
//! @brief Get the component of this accessor (used for debug purpose)
|
||||||
Component getComponent() override;
|
Component getComponent() const override;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ namespace ComSquare::CPU
|
|||||||
channel.setBus(_bus);
|
channel.setBus(_bus);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CPU::isDebugger()
|
bool CPU::isDebugger() const
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -31,7 +31,7 @@ namespace ComSquare::CPU
|
|||||||
}
|
}
|
||||||
|
|
||||||
//! @bref The CPU's internal registers starts at $4200 and finish at $421F.
|
//! @bref The CPU's internal registers starts at $4200 and finish at $421F.
|
||||||
uint8_t CPU::read(uint24_t addr)
|
uint8_t CPU::read(uint24_t addr) const
|
||||||
{
|
{
|
||||||
uint8_t tmp = 0;
|
uint8_t tmp = 0;
|
||||||
|
|
||||||
@@ -207,6 +207,11 @@ namespace ComSquare::CPU
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint24_t CPU::getSize() const
|
||||||
|
{
|
||||||
|
return 0x180;
|
||||||
|
}
|
||||||
|
|
||||||
uint8_t CPU::readPC()
|
uint8_t CPU::readPC()
|
||||||
{
|
{
|
||||||
uint8_t ret = this->_bus->read(this->_registers.pac);
|
uint8_t ret = this->_bus->read(this->_registers.pac);
|
||||||
@@ -349,12 +354,12 @@ namespace ComSquare::CPU
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CPU::getName()
|
std::string CPU::getName() const
|
||||||
{
|
{
|
||||||
return "CPU";
|
return "CPU";
|
||||||
}
|
}
|
||||||
|
|
||||||
Component CPU::getComponent()
|
Component CPU::getComponent() const
|
||||||
{
|
{
|
||||||
return Cpu;
|
return Cpu;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -741,18 +741,22 @@ namespace ComSquare::CPU
|
|||||||
//! @param addr The address to read from. The address 0x0 should refer to the first byte of the register.
|
//! @param addr The address to read from. The address 0x0 should refer to the first byte of the register.
|
||||||
//! @throw InvalidAddress will be thrown if the address is more than $1F (the number of register).
|
//! @throw InvalidAddress will be thrown if the address is more than $1F (the number of register).
|
||||||
//! @return Return the value of the register.
|
//! @return Return the value of the register.
|
||||||
uint8_t read(uint24_t addr) override;
|
uint8_t read(uint24_t addr) const override;
|
||||||
//! @brief Write data to the internal CPU register.
|
//! @brief Write data to the internal CPU register.
|
||||||
//! @param addr The address to write to. The address 0x0 should refer to the first byte of register.
|
//! @param addr The address to write to. The address 0x0 should refer to the first byte of register.
|
||||||
//! @param data The new value of the register.
|
//! @param data The new value of the register.
|
||||||
//! @throw InvalidAddress will be thrown if the address is more than $1F (the number of register).
|
//! @throw InvalidAddress will be thrown if the address is more than $1F (the number of register).
|
||||||
void write(uint24_t addr, uint8_t data) override;
|
void write(uint24_t addr, uint8_t data) override;
|
||||||
|
|
||||||
|
//! @brief Get the size of the data. This size can be lower than the mapped data.
|
||||||
|
//! @return The number of bytes inside this memory.
|
||||||
|
uint24_t getSize() const override;
|
||||||
|
|
||||||
//! @brief Get the name of this accessor (used for debug purpose)
|
//! @brief Get the name of this accessor (used for debug purpose)
|
||||||
std::string getName() override;
|
std::string getName() const override;
|
||||||
|
|
||||||
//! @brief Get the component of this accessor (used for debug purpose)
|
//! @brief Get the component of this accessor (used for debug purpose)
|
||||||
Component getComponent() override;
|
Component getComponent() const override;
|
||||||
|
|
||||||
//! @brief Reset interrupt - Called on boot and when the reset button is pressed.
|
//! @brief Reset interrupt - Called on boot and when the reset button is pressed.
|
||||||
virtual int RESB();
|
virtual int RESB();
|
||||||
@@ -765,7 +769,7 @@ namespace ComSquare::CPU
|
|||||||
bool IsAbortRequested = false;
|
bool IsAbortRequested = false;
|
||||||
|
|
||||||
//! @brief Return true if the CPU is overloaded with debugging features.
|
//! @brief Return true if the CPU is overloaded with debugging features.
|
||||||
virtual bool isDebugger();
|
virtual bool isDebugger() const;
|
||||||
|
|
||||||
//! @brief Change the memory bus used by the CPU.
|
//! @brief Change the memory bus used by the CPU.
|
||||||
virtual void setMemoryBus(std::shared_ptr<Memory::MemoryBus> bus);
|
virtual void setMemoryBus(std::shared_ptr<Memory::MemoryBus> bus);
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ namespace ComSquare::CPU
|
|||||||
this->_bus = std::move(bus);
|
this->_bus = std::move(bus);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t DMA::read(uint8_t addr)
|
uint8_t DMA::read(uint8_t addr) const
|
||||||
{
|
{
|
||||||
switch (addr) {
|
switch (addr) {
|
||||||
case 0x0:
|
case 0x0:
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ namespace ComSquare::CPU
|
|||||||
void setBus(std::shared_ptr<Memory::MemoryBus> bus);
|
void setBus(std::shared_ptr<Memory::MemoryBus> bus);
|
||||||
|
|
||||||
//! @brief Bus helper to read from this channel.
|
//! @brief Bus helper to read from this channel.
|
||||||
uint8_t read(uint8_t addr);
|
uint8_t read(uint8_t addr) const;
|
||||||
//! @brief Bus helper to write to this channel.
|
//! @brief Bus helper to write to this channel.
|
||||||
void write(uint8_t addr, uint8_t data);
|
void write(uint8_t addr, uint8_t data);
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ namespace ComSquare::Cartridge
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint8_t Cartridge::read(uint24_t addr)
|
uint8_t Cartridge::read(uint24_t addr) const
|
||||||
{
|
{
|
||||||
return Ram::read(addr + this->_romStart);
|
return Ram::read(addr + this->_romStart);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ namespace ComSquare::Cartridge
|
|||||||
//! @param addr The address to read from. The address 0x0 should refer to the first byte of the rom's memory.
|
//! @param addr The address to read from. The address 0x0 should refer to the first byte of the rom's memory.
|
||||||
//! @throw InvalidAddress will be thrown if the address is more than the size of the rom's memory.
|
//! @throw InvalidAddress will be thrown if the address is more than the size of the rom's memory.
|
||||||
//! @return Return the data at the address.
|
//! @return Return the data at the address.
|
||||||
uint8_t read(uint24_t addr) override;
|
uint8_t read(uint24_t addr) const override;
|
||||||
//! @brief Write data to the rom.
|
//! @brief Write data to the rom.
|
||||||
//! @param addr The address to write to. The address 0x0 should refer to the first byte of the rom's memory.
|
//! @param addr The address to write to. The address 0x0 should refer to the first byte of the rom's memory.
|
||||||
//! @param data The data to write.
|
//! @param data The data to write.
|
||||||
|
|||||||
@@ -522,7 +522,7 @@ namespace ComSquare::Debugger
|
|||||||
this->_snes.disableAPUDebugging();
|
this->_snes.disableAPUDebugging();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool APUDebug::isDebugger()
|
bool APUDebug::isDebugger() const
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ namespace ComSquare::Debugger
|
|||||||
|
|
||||||
|
|
||||||
//! @brief Return true if the CPU is overloaded with debugging features.
|
//! @brief Return true if the CPU is overloaded with debugging features.
|
||||||
bool isDebugger() override;
|
bool isDebugger() const override;
|
||||||
|
|
||||||
//! @brief Focus the debugger's window.
|
//! @brief Focus the debugger's window.
|
||||||
void focus();
|
void focus();
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
#include <QtEvents>
|
#include <QtEvents>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
using namespace ComSquare::CPU;
|
using namespace ComSquare::CPU;
|
||||||
|
|
||||||
@@ -58,7 +59,7 @@ namespace ComSquare::Debugger
|
|||||||
this->_updateDisassembly(this->_registers.pac, 0);
|
this->_updateDisassembly(this->_registers.pac, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CPUDebug::isDebugger()
|
bool CPUDebug::isDebugger() const
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -387,7 +388,9 @@ QSize RowPainter::sizeHint(const QStyleOptionViewItem &, const QModelIndex &) co
|
|||||||
return QSize();
|
return QSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
StackModel::StackModel(std::shared_ptr<ComSquare::Memory::MemoryBus> bus, ComSquare::Debugger::CPUDebug &cpu) : _bus(bus), _cpu(cpu) { }
|
StackModel::StackModel(std::shared_ptr<ComSquare::Memory::MemoryBus> bus, ComSquare::Debugger::CPUDebug &cpu)
|
||||||
|
: _bus(std::move(bus)), _cpu(cpu)
|
||||||
|
{ }
|
||||||
|
|
||||||
void StackModel::setMemoryBus(std::shared_ptr<ComSquare::Memory::MemoryBus> bus)
|
void StackModel::setMemoryBus(std::shared_ptr<ComSquare::Memory::MemoryBus> bus)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -281,7 +281,7 @@ namespace ComSquare::Debugger
|
|||||||
~CPUDebug() override = default;
|
~CPUDebug() override = default;
|
||||||
|
|
||||||
//! @brief Return true if the CPU is overloaded with debugging features.
|
//! @brief Return true if the CPU is overloaded with debugging features.
|
||||||
bool isDebugger() override;
|
bool isDebugger() const override;
|
||||||
|
|
||||||
//! @brief Focus the debugger's window.
|
//! @brief Focus the debugger's window.
|
||||||
void focus();
|
void focus();
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <QtWidgets/QInputDialog>
|
#include <QtWidgets/QInputDialog>
|
||||||
#include <QtWidgets/QSpinBox>
|
#include <QtWidgets/QSpinBox>
|
||||||
|
#include <QMessageBox>
|
||||||
#include "MemoryViewer.hpp"
|
#include "MemoryViewer.hpp"
|
||||||
#include "../SNES.hpp"
|
#include "../SNES.hpp"
|
||||||
#include "../Memory/MemoryShadow.hpp"
|
#include "../Memory/MemoryShadow.hpp"
|
||||||
@@ -147,11 +148,17 @@ namespace ComSquare::Debugger
|
|||||||
if (dialogUI.checkBox->isChecked()) {
|
if (dialogUI.checkBox->isChecked()) {
|
||||||
try {
|
try {
|
||||||
value = this->switchToAddrTab(value);
|
value = this->switchToAddrTab(value);
|
||||||
} catch (const InvalidAddress &) {}
|
} catch (const InvalidAddress &) {
|
||||||
|
QMessageBox msgBox;
|
||||||
|
msgBox.setText("This address is not mapped. Reading it will result in OpenBus.");
|
||||||
|
msgBox.exec();
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
QModelIndex index = this->_ui.tableView->model()->index(value >> 4, value & 0x0F);
|
QModelIndex index = this->_ui.tableView->model()->index(value >> 4, value & 0x0F);
|
||||||
this->_ui.tableView->scrollTo(index);
|
this->_ui.tableView->scrollTo(index);
|
||||||
this->_ui.tableView->selectionModel()->select(index, QItemSelectionModel::ClearAndSelect);
|
this->_ui.tableView->selectionModel()->select(index, QItemSelectionModel::ClearAndSelect);
|
||||||
|
this->_ui.tableView->setCurrentIndex(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned MemoryViewer::switchToAddrTab(uint24_t addr)
|
unsigned MemoryViewer::switchToAddrTab(uint24_t addr)
|
||||||
@@ -173,7 +180,14 @@ namespace ComSquare::Debugger
|
|||||||
default:
|
default:
|
||||||
throw InvalidAddress("Memory viewer switch to address", addr);
|
throw InvalidAddress("Memory viewer switch to address", addr);
|
||||||
}
|
}
|
||||||
return accessor->getRelativeAddress(addr);
|
addr = accessor->getRelativeAddress(addr);
|
||||||
|
if (addr > accessor->getSize()) {
|
||||||
|
QMessageBox msgBox;
|
||||||
|
msgBox.setText((std::string("The ") + accessor->getName() + " is too small to contain this address.").c_str());
|
||||||
|
msgBox.exec();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MemoryViewer::focus()
|
void MemoryViewer::focus()
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
namespace ComSquare::Memory
|
namespace ComSquare::Memory
|
||||||
{
|
{
|
||||||
uint24_t AMemory::getRelativeAddress(uint24_t addr)
|
uint24_t AMemory::getRelativeAddress(uint24_t addr) const
|
||||||
{
|
{
|
||||||
return addr - this->_start;
|
return addr - this->_start;
|
||||||
}
|
}
|
||||||
@@ -17,22 +17,22 @@ namespace ComSquare::Memory
|
|||||||
this->_end = end;
|
this->_end = end;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AMemory::hasMemoryAt(uint24_t addr)
|
bool AMemory::hasMemoryAt(uint24_t addr) const
|
||||||
{
|
{
|
||||||
return this->_start <= addr && addr <= this->_end;
|
return this->_start <= addr && addr <= this->_end;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AMemory::isMirror()
|
bool AMemory::isMirror() const
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<IMemory> AMemory::getMirrored()
|
std::shared_ptr<IMemory> AMemory::getMirrored() const
|
||||||
{
|
{
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string AMemory::getValueName(uint24_t)
|
std::string AMemory::getValueName(uint24_t) const
|
||||||
{
|
{
|
||||||
return "???";
|
return "???";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ namespace ComSquare::Memory
|
|||||||
//! @param addr The absolute address (in the 24 bit bus)
|
//! @param addr The absolute address (in the 24 bit bus)
|
||||||
//! @return The local address (0 refers to the first byte of this component).
|
//! @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.
|
//! @throw InvalidAddress is thrown if the address is not mapped by this component.
|
||||||
virtual uint24_t getRelativeAddress(uint24_t addr) override;
|
virtual uint24_t getRelativeAddress(uint24_t addr) const override;
|
||||||
//! @brief Change starting and ending points of this mapped memory.
|
//! @brief Change starting and ending points of this mapped memory.
|
||||||
//! @param start The first address mapped to this component.
|
//! @param start The first address mapped to this component.
|
||||||
//! @param end The last address mapped to this component.
|
//! @param end The last address mapped to this component.
|
||||||
@@ -35,16 +35,16 @@ namespace ComSquare::Memory
|
|||||||
//! @brief Return true if this component has mapped the address.
|
//! @brief Return true if this component has mapped the address.
|
||||||
//! @param addr The address to check.
|
//! @param addr The address to check.
|
||||||
//! @return True if this address is mapped to the component. False otherwise.
|
//! @return True if this address is mapped to the component. False otherwise.
|
||||||
virtual bool hasMemoryAt(uint24_t addr) override;
|
virtual bool hasMemoryAt(uint24_t addr) const override;
|
||||||
//! @brief Check if this memory is a mirror or not.
|
//! @brief Check if this memory is a mirror or not.
|
||||||
//! @return True if this memory is a mirror. False otherwise.
|
//! @return True if this memory is a mirror. False otherwise.
|
||||||
virtual bool isMirror() override;
|
virtual bool isMirror() const override;
|
||||||
//! @brief Get the name of the data at the address
|
//! @brief Get the name of the data at the address
|
||||||
//! @param addr The address (in local space)
|
//! @param addr The address (in local space)
|
||||||
virtual std::string getValueName(uint24_t addr) override;
|
virtual std::string getValueName(uint24_t addr) const override;
|
||||||
//! @brief Return the memory accessor this accessor mirror if any
|
//! @brief Return the memory accessor this accessor mirror if any
|
||||||
//! @return nullptr if isMirror is false, the source otherwise.
|
//! @return nullptr if isMirror is false, the source otherwise.
|
||||||
virtual std::shared_ptr<IMemory> getMirrored() override;
|
virtual std::shared_ptr<IMemory> getMirrored() const override;
|
||||||
virtual ~AMemory() override = default;
|
virtual ~AMemory() override = default;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -5,11 +5,10 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "ARectangleMemory.hpp"
|
#include "ARectangleMemory.hpp"
|
||||||
#include "../Exceptions/InvalidAddress.hpp"
|
#include "../Exceptions/InvalidAddress.hpp"
|
||||||
#include "../Utility/Utility.hpp"
|
|
||||||
|
|
||||||
namespace ComSquare::Memory
|
namespace ComSquare::Memory
|
||||||
{
|
{
|
||||||
uint24_t ARectangleMemory::getRelativeAddress(uint24_t addr)
|
uint24_t ARectangleMemory::getRelativeAddress(uint24_t addr) const
|
||||||
{
|
{
|
||||||
uint8_t bank = addr >> 16u;
|
uint8_t bank = addr >> 16u;
|
||||||
uint16_t page = addr;
|
uint16_t page = addr;
|
||||||
@@ -24,7 +23,7 @@ namespace ComSquare::Memory
|
|||||||
return pageCount * bankCount + page;
|
return pageCount * bankCount + page;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ARectangleMemory::hasMemoryAt(uint24_t addr)
|
bool ARectangleMemory::hasMemoryAt(uint24_t addr) const
|
||||||
{
|
{
|
||||||
uint8_t bank = addr >> 16u;
|
uint8_t bank = addr >> 16u;
|
||||||
uint16_t page = addr;
|
uint16_t page = addr;
|
||||||
@@ -43,17 +42,17 @@ namespace ComSquare::Memory
|
|||||||
this->_endPage = endPage;
|
this->_endPage = endPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ARectangleMemory::isMirror()
|
bool ARectangleMemory::isMirror() const
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<IMemory> ARectangleMemory::getMirrored()
|
std::shared_ptr<IMemory> ARectangleMemory::getMirrored() const
|
||||||
{
|
{
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ARectangleMemory::getValueName(uint24_t)
|
std::string ARectangleMemory::getValueName(uint24_t) const
|
||||||
{
|
{
|
||||||
return "???";
|
return "???";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,11 +24,11 @@ namespace ComSquare::Memory
|
|||||||
//! @param addr The absolute address (in the 24 bit bus)
|
//! @param addr The absolute address (in the 24 bit bus)
|
||||||
//! @return The local address (0 refers to the first byte of this component).
|
//! @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.
|
//! @throw InvalidAddress is thrown if the address is not mapped by this component.
|
||||||
virtual uint24_t getRelativeAddress(uint24_t addr) override;
|
virtual uint24_t getRelativeAddress(uint24_t addr) const override;
|
||||||
//! @brief Return true if this component has mapped the address.
|
//! @brief Return true if this component has mapped the address.
|
||||||
//! @param addr The address to check.
|
//! @param addr The address to check.
|
||||||
//! @return True if this address is mapped to the component. False otherwise.
|
//! @return True if this address is mapped to the component. False otherwise.
|
||||||
bool hasMemoryAt(uint24_t addr) override;
|
bool hasMemoryAt(uint24_t addr) const override;
|
||||||
//! @brief Change starting and ending points of this mapped memory.
|
//! @brief Change starting and ending points of this mapped memory.
|
||||||
//! @param startBank The first bank mapped to this component.
|
//! @param startBank The first bank mapped to this component.
|
||||||
//! @param endBank The last bank mapped to this component.
|
//! @param endBank The last bank mapped to this component.
|
||||||
@@ -38,13 +38,13 @@ namespace ComSquare::Memory
|
|||||||
void setMemoryRegion(uint8_t startBank, uint8_t endBank, uint16_t startPage, uint16_t endPage);
|
void setMemoryRegion(uint8_t startBank, uint8_t endBank, uint16_t startPage, uint16_t endPage);
|
||||||
//! @brief Check if this memory is a mirror or not.
|
//! @brief Check if this memory is a mirror or not.
|
||||||
//! @return True if this memory is a mirror. False otherwise.
|
//! @return True if this memory is a mirror. False otherwise.
|
||||||
virtual bool isMirror() override;
|
virtual bool isMirror() const override;
|
||||||
//! @brief Get the name of the data at the address
|
//! @brief Get the name of the data at the address
|
||||||
//! @param addr The address (in local space)
|
//! @param addr The address (in local space)
|
||||||
virtual std::string getValueName(uint24_t addr) override;
|
virtual std::string getValueName(uint24_t addr) const override;
|
||||||
//! @brief Return the memory accessor this accessor mirror if any
|
//! @brief Return the memory accessor this accessor mirror if any
|
||||||
//! @return nullptr if isMirror is false, the source otherwise.
|
//! @return nullptr if isMirror is false, the source otherwise.
|
||||||
virtual std::shared_ptr<IMemory> getMirrored() override;
|
virtual std::shared_ptr<IMemory> getMirrored() const override;
|
||||||
virtual ~ARectangleMemory() override = default;
|
virtual ~ARectangleMemory() override = default;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -20,7 +20,7 @@ namespace ComSquare::Memory
|
|||||||
//! @param addr The local address to read from (0x0 should refer to the first byte of this component).
|
//! @param addr The local address to read from (0x0 should refer to the first byte of this component).
|
||||||
//! @throw This function should thrown an InvalidAddress for address that are not mapped to the component.
|
//! @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.
|
//! @return Return the data at the address given as parameter.
|
||||||
virtual uint8_t read(uint24_t addr) = 0;
|
virtual uint8_t read(uint24_t addr) const = 0;
|
||||||
//! @brief Write data to this component.
|
//! @brief Write data to this component.
|
||||||
//! @param addr The local address to write data (0x0 should refer to the first byte of this component).
|
//! @param addr The local address to write data (0x0 should refer to the first byte of this component).
|
||||||
//! @param data The new data to write.
|
//! @param data The new data to write.
|
||||||
@@ -29,25 +29,28 @@ namespace ComSquare::Memory
|
|||||||
//! @brief Return true if this component has mapped the address.
|
//! @brief Return true if this component has mapped the address.
|
||||||
//! @param addr The address to check.
|
//! @param addr The address to check.
|
||||||
//! @return True if this address is mapped to the component. False otherwise.
|
//! @return True if this address is mapped to the component. False otherwise.
|
||||||
virtual bool hasMemoryAt(uint24_t addr) = 0;
|
virtual bool hasMemoryAt(uint24_t addr) const = 0;
|
||||||
//! @brief Translate an absolute address to a relative address
|
//! @brief Translate an absolute address to a relative address
|
||||||
//! @param addr The absolute address (in the 24 bit bus)
|
//! @param addr The absolute address (in the 24 bit bus)
|
||||||
//! @return The local address (0 refers to the first byte of this component).
|
//! @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.
|
//! @throw InvalidAddress is thrown if the address is not mapped by this component.
|
||||||
virtual uint24_t getRelativeAddress(uint24_t addr) = 0;
|
virtual uint24_t getRelativeAddress(uint24_t addr) const = 0;
|
||||||
|
//! @brief Get the size of the data. This size can be lower than the mapped data.
|
||||||
|
//! @return The number of bytes inside this memory.
|
||||||
|
virtual uint24_t getSize() const = 0;
|
||||||
//! @brief Check if this memory is a mirror or not.
|
//! @brief Check if this memory is a mirror or not.
|
||||||
//! @return True if this memory is a mirror. False otherwise.
|
//! @return True if this memory is a mirror. False otherwise.
|
||||||
virtual bool isMirror() = 0;
|
virtual bool isMirror() const = 0;
|
||||||
//! @brief Get the name of this accessor (used for debug purpose)
|
//! @brief Get the name of this accessor (used for debug purpose)
|
||||||
virtual std::string getName() = 0;
|
virtual std::string getName() const = 0;
|
||||||
//! @brief Get the component of this accessor (used for debug purpose)
|
//! @brief Get the component of this accessor (used for debug purpose)
|
||||||
virtual Component getComponent() = 0;
|
virtual Component getComponent() const = 0;
|
||||||
//! @brief Get the name of the data at the address
|
//! @brief Get the name of the data at the address
|
||||||
//! @param addr The address (in local space)
|
//! @param addr The address (in local space)
|
||||||
virtual std::string getValueName(uint24_t addr) = 0;
|
virtual std::string getValueName(uint24_t addr) const = 0;
|
||||||
//! @brief Return the memory accessor this accessor mirror if any
|
//! @brief Return the memory accessor this accessor mirror if any
|
||||||
//! @return nullptr if isMirror is false, the source otherwise.
|
//! @return nullptr if isMirror is false, the source otherwise.
|
||||||
virtual std::shared_ptr<IMemory> getMirrored() = 0;
|
virtual std::shared_ptr<IMemory> getMirrored() const = 0;
|
||||||
virtual ~IMemory() = default;
|
virtual ~IMemory() = default;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -14,7 +14,7 @@ namespace ComSquare::Memory
|
|||||||
this->setMemoryRegion(start, end);
|
this->setMemoryRegion(start, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t MemoryShadow::read(uint24_t addr)
|
uint8_t MemoryShadow::read(uint24_t addr) const
|
||||||
{
|
{
|
||||||
return this->_initial->read(addr);
|
return this->_initial->read(addr);
|
||||||
}
|
}
|
||||||
@@ -24,22 +24,27 @@ namespace ComSquare::Memory
|
|||||||
return this->_initial->write(addr, data);
|
return this->_initial->write(addr, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MemoryShadow::isMirror()
|
uint24_t MemoryShadow::getSize() const
|
||||||
|
{
|
||||||
|
return this->_initial->getSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool MemoryShadow::isMirror() const
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<IMemory> MemoryShadow::getMirrored()
|
std::shared_ptr<IMemory> MemoryShadow::getMirrored() const
|
||||||
{
|
{
|
||||||
return this->_initial;
|
return this->_initial;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string MemoryShadow::getName()
|
std::string MemoryShadow::getName() const
|
||||||
{
|
{
|
||||||
return this->_initial->getName();
|
return this->_initial->getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
Component MemoryShadow::getComponent()
|
Component MemoryShadow::getComponent() const
|
||||||
{
|
{
|
||||||
return this->_initial->getComponent();
|
return this->_initial->getComponent();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,21 +24,24 @@ namespace ComSquare::Memory
|
|||||||
//! @param addr The address to read from. The address 0x0 should refer to the first byte of the initial AMemory.
|
//! @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.
|
//! @throw InvalidAddress will be thrown if the address is more than the size of the initial AMemory.
|
||||||
//! @return Return the data at the address.
|
//! @return Return the data at the address.
|
||||||
uint8_t read(uint24_t addr) override;
|
uint8_t read(uint24_t addr) const override;
|
||||||
//! @brief Write data to the ram.
|
//! @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 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.
|
//! @param data The data to write.
|
||||||
//! @throw InvalidAddress will be thrown if the address is more than the size of the initial AMemory.
|
//! @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;
|
void write(uint24_t addr, uint8_t data) override;
|
||||||
|
//! @brief Get the size of the data. This size can be lower than the mapped data.
|
||||||
|
//! @return The number of bytes inside this memory.
|
||||||
|
virtual uint24_t getSize() const override;
|
||||||
//! @brief Check if this memory is a mirror or not.
|
//! @brief Check if this memory is a mirror or not.
|
||||||
//! @return True if this memory is a mirror. False otherwise.
|
//! @return True if this memory is a mirror. False otherwise.
|
||||||
bool isMirror() override;
|
bool isMirror() const override;
|
||||||
//! @brief Get the name of this accessor (used for debug purpose)
|
//! @brief Get the name of this accessor (used for debug purpose)
|
||||||
std::string getName() override;
|
std::string getName() const override;
|
||||||
//! @brief Get the component of this accessor (used for debug purpose)
|
//! @brief Get the component of this accessor (used for debug purpose)
|
||||||
Component getComponent() override;
|
Component getComponent() const override;
|
||||||
//! @brief Return the memory accessor this accessor mirror if any
|
//! @brief Return the memory accessor this accessor mirror if any
|
||||||
//! @return nullptr if isMirror is false, the source otherwise.
|
//! @return nullptr if isMirror is false, the source otherwise.
|
||||||
std::shared_ptr<IMemory> getMirrored() override;
|
std::shared_ptr<IMemory> getMirrored() const override;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -18,13 +18,13 @@ namespace ComSquare::Memory
|
|||||||
this->setMemoryRegion(startBank, endBank, startPage, endPage);
|
this->setMemoryRegion(startBank, endBank, startPage, endPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint24_t RectangleShadow::getRelativeAddress(uint24_t addr)
|
uint24_t RectangleShadow::getRelativeAddress(uint24_t addr) const
|
||||||
{
|
{
|
||||||
uint24_t base = ARectangleMemory::getRelativeAddress(addr);
|
uint24_t base = ARectangleMemory::getRelativeAddress(addr);
|
||||||
return base + this->_bankOffset * (this->_endPage - this->_startPage);
|
return base + this->_bankOffset * (this->_endPage - this->_startPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t RectangleShadow::read(uint24_t addr)
|
uint8_t RectangleShadow::read(uint24_t addr) const
|
||||||
{
|
{
|
||||||
return this->_initial->read(addr);
|
return this->_initial->read(addr);
|
||||||
}
|
}
|
||||||
@@ -40,22 +40,27 @@ namespace ComSquare::Memory
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RectangleShadow::isMirror()
|
uint24_t RectangleShadow::getSize() const
|
||||||
|
{
|
||||||
|
return this->_initial->getSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RectangleShadow::isMirror() const
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<IMemory> RectangleShadow::getMirrored()
|
std::shared_ptr<IMemory> RectangleShadow::getMirrored() const
|
||||||
{
|
{
|
||||||
return this->_initial;
|
return this->_initial;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string RectangleShadow::getName()
|
std::string RectangleShadow::getName() const
|
||||||
{
|
{
|
||||||
return this->_initial->getName();
|
return this->_initial->getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
Component RectangleShadow::getComponent()
|
Component RectangleShadow::getComponent() const
|
||||||
{
|
{
|
||||||
return this->_initial->getComponent();
|
return this->_initial->getComponent();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ namespace ComSquare::Memory
|
|||||||
//! @param addr The address to read from. The address 0x0 should refer to the first byte of the initial AMemory.
|
//! @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.
|
//! @throw InvalidAddress will be thrown if the address is more than the size of the initial AMemory.
|
||||||
//! @return Return the data at the address.
|
//! @return Return the data at the address.
|
||||||
uint8_t read(uint24_t addr) override;
|
uint8_t read(uint24_t addr) const override;
|
||||||
//! @brief Write data to the ram.
|
//! @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 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.
|
//! @param data The data to write.
|
||||||
@@ -37,17 +37,20 @@ namespace ComSquare::Memory
|
|||||||
//! @param addr The absolute address (in the 24 bit bus)
|
//! @param addr The absolute address (in the 24 bit bus)
|
||||||
//! @return The local address (0 refers to the first byte of this component).
|
//! @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.
|
//! @throw InvalidAddress is thrown if the address is not mapped by this component.
|
||||||
uint24_t getRelativeAddress(uint24_t addr) override;
|
uint24_t getRelativeAddress(uint24_t addr) const override;
|
||||||
|
//! @brief Get the size of the data. This size can be lower than the mapped data.
|
||||||
|
//! @return The number of bytes inside this memory.
|
||||||
|
virtual uint24_t getSize() const override;
|
||||||
//! @brief Check if this memory is a mirror or not.
|
//! @brief Check if this memory is a mirror or not.
|
||||||
//! @return True if this memory is a mirror. False otherwise.
|
//! @return True if this memory is a mirror. False otherwise.
|
||||||
bool isMirror() override;
|
bool isMirror() const override;
|
||||||
//! @brief Get the name of this accessor (used for debug purpose)
|
//! @brief Get the name of this accessor (used for debug purpose)
|
||||||
std::string getName() override;
|
std::string getName() const override;
|
||||||
//! @brief Get the component of this accessor (used for debug purpose)
|
//! @brief Get the component of this accessor (used for debug purpose)
|
||||||
Component getComponent() override;
|
Component getComponent() const override;
|
||||||
//! @brief Return the memory accessor this accessor mirror if any
|
//! @brief Return the memory accessor this accessor mirror if any
|
||||||
//! @return nullptr if isMirror is false, the source otherwise.
|
//! @return nullptr if isMirror is false, the source otherwise.
|
||||||
std::shared_ptr<IMemory> getMirrored() override;
|
std::shared_ptr<IMemory> getMirrored() const override;
|
||||||
|
|
||||||
RectangleShadow *setBankOffset(uint8_t bankOffset);
|
RectangleShadow *setBankOffset(uint8_t bankOffset);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ namespace ComSquare::PPU
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t PPU::read(uint24_t addr)
|
uint8_t PPU::read(uint24_t addr) const
|
||||||
{
|
{
|
||||||
switch (addr) {
|
switch (addr) {
|
||||||
case ppuRegisters::mpyl:
|
case ppuRegisters::mpyl:
|
||||||
@@ -216,6 +216,11 @@ namespace ComSquare::PPU
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint24_t PPU::getSize() const
|
||||||
|
{
|
||||||
|
return 0x3F;
|
||||||
|
}
|
||||||
|
|
||||||
uint16_t PPU::getVramAddress()
|
uint16_t PPU::getVramAddress()
|
||||||
{
|
{
|
||||||
uint16_t vanillaAddress = this->_registers._vmadd.vmadd * 2;
|
uint16_t vanillaAddress = this->_registers._vmadd.vmadd * 2;
|
||||||
@@ -262,12 +267,12 @@ namespace ComSquare::PPU
|
|||||||
this->_renderer.drawScreen();
|
this->_renderer.drawScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string PPU::getName()
|
std::string PPU::getName() const
|
||||||
{
|
{
|
||||||
return "PPU";
|
return "PPU";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string PPU::getValueName(uint24_t addr)
|
std::string PPU::getValueName(uint24_t addr) const
|
||||||
{
|
{
|
||||||
switch (addr) {
|
switch (addr) {
|
||||||
case ppuRegisters::inidisp:
|
case ppuRegisters::inidisp:
|
||||||
@@ -403,12 +408,12 @@ namespace ComSquare::PPU
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Component PPU::getComponent()
|
Component PPU::getComponent() const
|
||||||
{
|
{
|
||||||
return Ppu;
|
return Ppu;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PPU::isDebugger()
|
bool PPU::isDebugger() const
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -562,16 +562,19 @@ namespace ComSquare::PPU
|
|||||||
//! @param addr The local address to read from (0x0 should refer to the first byte of this component).
|
//! @param addr The local address to read from (0x0 should refer to the first byte of this component).
|
||||||
//! @throw This function should thrown an InvalidAddress for address that are not mapped to the component.
|
//! @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.
|
//! @return Return the data at the address given as parameter.
|
||||||
uint8_t read(uint24_t addr) override;
|
uint8_t read(uint24_t addr) const override;
|
||||||
//! @brief Write data to this component.
|
//! @brief Write data to this component.
|
||||||
//! @param addr The local address to write data (0x0 should refer to the first byte of this component).
|
//! @param addr The local address to write data (0x0 should refer to the first byte of this component).
|
||||||
//! @param data The new data to write.
|
//! @param data The new data to write.
|
||||||
//! @throw This function should thrown an InvalidAddress for address that are not mapped to the component.
|
//! @throw This function should thrown an InvalidAddress for address that are not mapped to the component.
|
||||||
void write(uint24_t addr, uint8_t data) override;
|
void write(uint24_t addr, uint8_t data) override;
|
||||||
//! @brief Get the name of this accessor (used for debug purpose)
|
//! @brief Get the name of this accessor (used for debug purpose)
|
||||||
std::string getName() override;
|
std::string getName() const override;
|
||||||
//! @brief Get the component of this accessor (used for debug purpose)
|
//! @brief Get the component of this accessor (used for debug purpose)
|
||||||
Component getComponent() override;
|
Component getComponent() const override;
|
||||||
|
//! @brief Get the size of the data. This size can be lower than the mapped data.
|
||||||
|
//! @return The number of bytes inside this memory.
|
||||||
|
uint24_t getSize() const override;
|
||||||
|
|
||||||
//! @brief Update the PPU of n cycles.
|
//! @brief Update the PPU of n cycles.
|
||||||
//! @param The number of cycles to update.
|
//! @param The number of cycles to update.
|
||||||
@@ -579,9 +582,9 @@ namespace ComSquare::PPU
|
|||||||
//! @brief Give the Vram Address with the right Address remapping
|
//! @brief Give the Vram Address with the right Address remapping
|
||||||
uint16_t getVramAddress();
|
uint16_t getVramAddress();
|
||||||
//! @brief Give the name of the Address register (used for debug)
|
//! @brief Give the name of the Address register (used for debug)
|
||||||
std::string getValueName(uint24_t addr);
|
std::string getValueName(uint24_t addr) const;
|
||||||
//! @brief Return true if the CPU is overloaded with debugging features.
|
//! @brief Return true if the CPU is overloaded with debugging features.
|
||||||
virtual bool isDebugger();
|
virtual bool isDebugger() const;
|
||||||
//! @brief Allow others components to read the CGRAM (Debuggers)
|
//! @brief Allow others components to read the CGRAM (Debuggers)
|
||||||
uint16_t cgramRead(uint16_t addr);
|
uint16_t cgramRead(uint16_t addr);
|
||||||
//! @brief Render a background on the screen
|
//! @brief Render a background on the screen
|
||||||
|
|||||||
@@ -27,8 +27,9 @@ namespace ComSquare::Ram
|
|||||||
delete[] this->_data;
|
delete[] this->_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t Ram::read(uint24_t addr)
|
uint8_t Ram::read(uint24_t addr) const
|
||||||
{
|
{
|
||||||
|
// TODO read/write after the size of the rom should noop or behave like a mirror. I don't really know.
|
||||||
if (addr >= this->_size)
|
if (addr >= this->_size)
|
||||||
throw InvalidAddress(this->getName() + " read", addr);
|
throw InvalidAddress(this->getName() + " read", addr);
|
||||||
return this->_data[addr];
|
return this->_data[addr];
|
||||||
@@ -41,17 +42,17 @@ namespace ComSquare::Ram
|
|||||||
this->_data[addr] = data;
|
this->_data[addr] = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t Ram::getSize()
|
uint24_t Ram::getSize() const
|
||||||
{
|
{
|
||||||
return this->_size;
|
return this->_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Ram::getName()
|
std::string Ram::getName() const
|
||||||
{
|
{
|
||||||
return this->_ramName;
|
return this->_ramName;
|
||||||
}
|
}
|
||||||
|
|
||||||
Component Ram::getComponent()
|
Component Ram::getComponent() const
|
||||||
{
|
{
|
||||||
return this->_ramType;
|
return this->_ramType;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ namespace ComSquare::Ram
|
|||||||
//! @brief The ram. (Can be used for WRam, SRam, VRam etc)
|
//! @brief The ram. (Can be used for WRam, SRam, VRam etc)
|
||||||
uint8_t *_data;
|
uint8_t *_data;
|
||||||
//! @brief The size of the ram (in bytes).
|
//! @brief The size of the ram (in bytes).
|
||||||
size_t _size;
|
uint24_t _size;
|
||||||
//! @brief An id identifying the type of memory this is (for the debugger)
|
//! @brief An id identifying the type of memory this is (for the debugger)
|
||||||
Component _ramType;
|
Component _ramType;
|
||||||
//! @brief The name of this ram.
|
//! @brief The name of this ram.
|
||||||
@@ -34,7 +34,7 @@ namespace ComSquare::Ram
|
|||||||
//! @param addr The local address to read from (0x0 should refer to the first byte of this component).
|
//! @param addr The local address to read from (0x0 should refer to the first byte of this component).
|
||||||
//! @throw This function should thrown an InvalidAddress for address that are not mapped to the component.
|
//! @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.
|
//! @return Return the data at the address given as parameter.
|
||||||
uint8_t read(uint24_t addr) override;
|
uint8_t read(uint24_t addr) const override;
|
||||||
//! @brief Write data to this component.
|
//! @brief Write data to this component.
|
||||||
//! @param addr The local address to write data (0x0 should refer to the first byte of this component).
|
//! @param addr The local address to write data (0x0 should refer to the first byte of this component).
|
||||||
//! @param data The new data to write.
|
//! @param data The new data to write.
|
||||||
@@ -43,13 +43,13 @@ namespace ComSquare::Ram
|
|||||||
|
|
||||||
|
|
||||||
//! @brief Get the name of this accessor (used for debug purpose)
|
//! @brief Get the name of this accessor (used for debug purpose)
|
||||||
std::string getName() override;
|
std::string getName() const override;
|
||||||
|
|
||||||
//! @brief Get the component of this accessor (used for debug purpose)
|
//! @brief Get the component of this accessor (used for debug purpose)
|
||||||
Component getComponent() override;
|
Component getComponent() const override;
|
||||||
|
|
||||||
//! @brief Get the size of the ram in bytes.
|
//! @brief Get the size of the ram in bytes.
|
||||||
size_t getSize();
|
uint24_t getSize() const override;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user