mirror of
https://github.com/zoriya/ComSquare.git
synced 2025-12-19 05:35:10 +00:00
Adding a global goto but it still doesn't work with rectangle shadows
This commit is contained in:
@@ -9,6 +9,8 @@
|
|||||||
#include "MemoryViewer.hpp"
|
#include "MemoryViewer.hpp"
|
||||||
#include "../SNES.hpp"
|
#include "../SNES.hpp"
|
||||||
#include "../Utility/Utility.hpp"
|
#include "../Utility/Utility.hpp"
|
||||||
|
#include "../Memory/MemoryShadow.hpp"
|
||||||
|
#include "../Exceptions/InvalidAddress.hpp"
|
||||||
|
|
||||||
MemoryViewerModel::MemoryViewerModel(std::shared_ptr<Ram> memory, QObject *parent) :
|
MemoryViewerModel::MemoryViewerModel(std::shared_ptr<Ram> memory, QObject *parent) :
|
||||||
QAbstractTableModel(parent),
|
QAbstractTableModel(parent),
|
||||||
@@ -62,9 +64,10 @@ void MemoryViewerModel::setMemory(std::shared_ptr<Ram> memory)
|
|||||||
|
|
||||||
namespace ComSquare::Debugger
|
namespace ComSquare::Debugger
|
||||||
{
|
{
|
||||||
MemoryViewer::MemoryViewer(ComSquare::SNES &snes) :
|
MemoryViewer::MemoryViewer(ComSquare::SNES &snes, Memory::MemoryBus &bus) :
|
||||||
QMainWindow(),
|
QMainWindow(),
|
||||||
_snes(snes),
|
_snes(snes),
|
||||||
|
_bus(bus),
|
||||||
_ui(),
|
_ui(),
|
||||||
_model(snes.wram)
|
_model(snes.wram)
|
||||||
{
|
{
|
||||||
@@ -128,15 +131,35 @@ namespace ComSquare::Debugger
|
|||||||
if (dialog.exec() != QDialog::Accepted)
|
if (dialog.exec() != QDialog::Accepted)
|
||||||
return;
|
return;
|
||||||
long value = std::strtol(dialogUI.spinBox->text().toStdString().c_str() + 1, nullptr, 16);
|
long value = std::strtol(dialogUI.spinBox->text().toStdString().c_str() + 1, nullptr, 16);
|
||||||
if (dialogUI.checkBox->isChecked())
|
if (dialogUI.checkBox->isChecked()) {
|
||||||
this->switchToAddrTab(value);
|
try {
|
||||||
|
value = this->switchToAddrTab(value);
|
||||||
|
} catch (InvalidAddress &) {}
|
||||||
|
}
|
||||||
QModelIndex index = this->_ui.tableView->model()->index(value >> 4, value & 0x0000000F);
|
QModelIndex index = this->_ui.tableView->model()->index(value >> 4, value & 0x0000000F);
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MemoryViewer::switchToAddrTab(uint24_t addr)
|
unsigned MemoryViewer::switchToAddrTab(uint24_t addr)
|
||||||
{
|
{
|
||||||
|
std::shared_ptr<Memory::IMemory> accessor = this->_bus.getAccessor(addr);
|
||||||
|
if (!accessor)
|
||||||
|
throw InvalidAddress("Memory viewer switch to address", addr);
|
||||||
|
Memory::IMemory *ptr;
|
||||||
|
if (accessor->isMirror())
|
||||||
|
ptr = accessor->getMirrored().get();
|
||||||
|
else
|
||||||
|
ptr = accessor.get();
|
||||||
|
|
||||||
|
if (ptr == this->_snes.wram.get())
|
||||||
|
this->_ui.tabs->setCurrentIndex(0);
|
||||||
|
else if (ptr == this->_snes.sram.get())
|
||||||
|
this->_ui.tabs->setCurrentIndex(1);
|
||||||
|
else if (ptr == this->_snes.cartridge.get())
|
||||||
|
this->_ui.tabs->setCurrentIndex(2);
|
||||||
|
else
|
||||||
|
throw InvalidAddress("Memory viewer switch to address", addr);
|
||||||
|
return addr - accessor->getStart();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -9,6 +9,7 @@
|
|||||||
#include "../../ui/ui_ramView.h"
|
#include "../../ui/ui_ramView.h"
|
||||||
#include "../../ui/ui_gotoDialog.h"
|
#include "../../ui/ui_gotoDialog.h"
|
||||||
#include "../Ram/Ram.hpp"
|
#include "../Ram/Ram.hpp"
|
||||||
|
#include "../Memory/MemoryBus.hpp"
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
using ComSquare::Ram::Ram;
|
using ComSquare::Ram::Ram;
|
||||||
@@ -52,6 +53,8 @@ namespace ComSquare
|
|||||||
private:
|
private:
|
||||||
//! @brief SNES containing all rams to view.
|
//! @brief SNES containing all rams to view.
|
||||||
SNES &_snes;
|
SNES &_snes;
|
||||||
|
//! @brief The memory bus used to get the view for a given address.
|
||||||
|
Memory::MemoryBus &_bus;
|
||||||
//! @brief The layout of the viewer.
|
//! @brief The layout of the viewer.
|
||||||
Ui::RamView _ui;
|
Ui::RamView _ui;
|
||||||
//! @brief The Ram visualizer model for QT.
|
//! @brief The Ram visualizer model for QT.
|
||||||
@@ -60,7 +63,8 @@ namespace ComSquare
|
|||||||
void _internalGoto(bool isAbsolute);
|
void _internalGoto(bool isAbsolute);
|
||||||
public:
|
public:
|
||||||
//! @brief Select the memory tab corresponding to a 24 bit address (map the address via the bus).
|
//! @brief Select the memory tab corresponding to a 24 bit address (map the address via the bus).
|
||||||
void switchToAddrTab(uint24_t addr);
|
//! @return The address converted to the new tab's locale space.
|
||||||
|
unsigned switchToAddrTab(uint24_t addr);
|
||||||
|
|
||||||
//! @brief Callback called when a memory tab is selected.
|
//! @brief Callback called when a memory tab is selected.
|
||||||
void changeRam(int id);
|
void changeRam(int id);
|
||||||
@@ -69,7 +73,7 @@ namespace ComSquare
|
|||||||
//! @brief Create a popup asking you where you want to jump to with the absolute mode selected.
|
//! @brief Create a popup asking you where you want to jump to with the absolute mode selected.
|
||||||
void gotoAbsoluteAddr();
|
void gotoAbsoluteAddr();
|
||||||
|
|
||||||
explicit MemoryViewer(SNES &snes);
|
explicit MemoryViewer(SNES &snes, Memory::MemoryBus &bus);
|
||||||
MemoryViewer(const MemoryViewer &) = delete;
|
MemoryViewer(const MemoryViewer &) = delete;
|
||||||
MemoryViewer &operator=(const MemoryViewer &) = delete;
|
MemoryViewer &operator=(const MemoryViewer &) = delete;
|
||||||
~MemoryViewer() override = default;
|
~MemoryViewer() override = default;
|
||||||
|
|||||||
@@ -22,4 +22,14 @@ namespace ComSquare::Memory
|
|||||||
{
|
{
|
||||||
return this->_start;
|
return this->_start;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IMemory::isMirror()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<IMemory> IMemory::getMirrored()
|
||||||
|
{
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <memory>
|
||||||
#include "../Models/Int24.hpp"
|
#include "../Models/Int24.hpp"
|
||||||
|
|
||||||
namespace ComSquare::Memory
|
namespace ComSquare::Memory
|
||||||
@@ -42,6 +43,12 @@ namespace ComSquare::Memory
|
|||||||
//! @brief Get the first address mapped to this component.
|
//! @brief Get the first address mapped to this component.
|
||||||
//! @return the _start value.
|
//! @return the _start value.
|
||||||
virtual uint24_t getStart();
|
virtual uint24_t getStart();
|
||||||
|
//! @brief Check if this memory is a mirror or not.
|
||||||
|
//! @return True if this memory is a mirror. False otherwise.
|
||||||
|
virtual bool isMirror();
|
||||||
|
//! @brief Return the memory accessor this accessor mirror if any
|
||||||
|
//! @return nullptr if isMirror is false, the source otherwise.
|
||||||
|
virtual std::shared_ptr<IMemory> getMirrored();
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -22,11 +22,6 @@ namespace ComSquare
|
|||||||
//! @brief The list of components registered inside the bus. Every components that can read/write to a public address should be in this vector.
|
//! @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::shared_ptr<IMemory>> _memoryAccessors;
|
||||||
|
|
||||||
//! @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 The last value read via the memory bus.
|
//! @brief The last value read via the memory bus.
|
||||||
uint8_t _openBus = 0;
|
uint8_t _openBus = 0;
|
||||||
|
|
||||||
@@ -54,6 +49,11 @@ namespace ComSquare
|
|||||||
//! @brief Map components to the address space using the currently loaded cartridge to set the right mapping mode.
|
//! @brief Map components to the address space using the currently loaded cartridge to set the right mapping mode.
|
||||||
//! @param console All the components.
|
//! @param console All the components.
|
||||||
void mapComponents(SNES &console);
|
void mapComponents(SNES &console);
|
||||||
|
|
||||||
|
//! @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);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,4 +23,14 @@ namespace ComSquare::Memory
|
|||||||
{
|
{
|
||||||
return this->_initial->write(addr, data);
|
return this->_initial->write(addr, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MemoryShadow::isMirror()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<IMemory> MemoryShadow::getMirrored()
|
||||||
|
{
|
||||||
|
return this->_initial;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -31,6 +31,12 @@ namespace ComSquare::Memory
|
|||||||
//! @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 IMemory.
|
//! @throw InvalidAddress will be thrown if the address is more than the size of the initial IMemory.
|
||||||
void write(uint24_t addr, uint8_t data) override;
|
void write(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 Return the memory accessor this accessor mirror if any
|
||||||
|
//! @return nullptr if isMirror is false, the source otherwise.
|
||||||
|
std::shared_ptr<IMemory> getMirrored() override;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,4 +32,14 @@ namespace ComSquare::Memory
|
|||||||
this->_bankOffset = bankOffset;
|
this->_bankOffset = bankOffset;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool RectangleShadow::isMirror()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<IMemory> RectangleShadow::getMirrored()
|
||||||
|
{
|
||||||
|
return this->_initial;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -34,7 +34,12 @@ namespace ComSquare::Memory
|
|||||||
//! @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_internal(uint24_t addr, uint8_t data) override;
|
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 Return the memory accessor this accessor mirror if any
|
||||||
|
//! @return nullptr if isMirror is false, the source otherwise.
|
||||||
|
std::shared_ptr<IMemory> getMirrored() override;
|
||||||
|
|
||||||
RectangleShadow *setBankOffset(uint8_t bankOffset);
|
RectangleShadow *setBankOffset(uint8_t bankOffset);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
namespace ComSquare
|
namespace ComSquare
|
||||||
{
|
{
|
||||||
SNES::SNES(const std::shared_ptr<Memory::MemoryBus> &bus, const std::string &romPath, Renderer::IRenderer &renderer) :
|
SNES::SNES(const std::shared_ptr<Memory::MemoryBus> &bus, const std::string &romPath, Renderer::IRenderer &renderer) :
|
||||||
|
_bus(bus),
|
||||||
cartridge(new Cartridge::Cartridge(romPath)),
|
cartridge(new Cartridge::Cartridge(romPath)),
|
||||||
wram(new Ram::Ram(16384)),
|
wram(new Ram::Ram(16384)),
|
||||||
sram(new Ram::Ram(this->cartridge->header.sramSize)),
|
sram(new Ram::Ram(this->cartridge->header.sramSize)),
|
||||||
@@ -42,7 +43,7 @@ namespace ComSquare
|
|||||||
void SNES::enableRamViewer()
|
void SNES::enableRamViewer()
|
||||||
{
|
{
|
||||||
#ifdef DEBUGGER_ENABLED
|
#ifdef DEBUGGER_ENABLED
|
||||||
this->_ramViewer = std::make_shared<Debugger::MemoryViewer>(*this);
|
this->_ramViewer = std::make_shared<Debugger::MemoryViewer>(*this, *this->_bus);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,13 +22,14 @@ namespace ComSquare
|
|||||||
{
|
{
|
||||||
//! @brief Container of all the components of the SNES.
|
//! @brief Container of all the components of the SNES.
|
||||||
class SNES {
|
class SNES {
|
||||||
#ifdef DEBUGGER_ENABLED
|
|
||||||
private:
|
private:
|
||||||
|
#ifdef DEBUGGER_ENABLED
|
||||||
//! @brief The window that allow the user to view a memory.
|
//! @brief The window that allow the user to view a memory.
|
||||||
std::shared_ptr<Debugger::MemoryViewer> _ramViewer;
|
std::shared_ptr<Debugger::MemoryViewer> _ramViewer;
|
||||||
//! @brief The window that allow the user to view the cartridge's header.
|
//! @brief The window that allow the user to view the cartridge's header.
|
||||||
std::shared_ptr<Debugger::HeaderViewer> _headerViewer;
|
std::shared_ptr<Debugger::HeaderViewer> _headerViewer;
|
||||||
#endif
|
#endif
|
||||||
|
std::shared_ptr<Memory::MemoryBus> _bus;
|
||||||
public:
|
public:
|
||||||
//! @brief Cartridge containing instructions (ROM).
|
//! @brief Cartridge containing instructions (ROM).
|
||||||
std::shared_ptr<Cartridge::Cartridge> cartridge;
|
std::shared_ptr<Cartridge::Cartridge> cartridge;
|
||||||
|
|||||||
Reference in New Issue
Block a user