mirror of
https://github.com/zoriya/ComSquare.git
synced 2026-06-02 10:15:45 +00:00
Adding an error message on invalid instructions
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
#include "../SNES.hpp"
|
||||
#include "MemoryShadow.hpp"
|
||||
#include "RectangleShadow.hpp"
|
||||
#include "../Exceptions/InvalidAddress.hpp"
|
||||
|
||||
namespace ComSquare::Memory
|
||||
{
|
||||
@@ -22,20 +23,34 @@ namespace ComSquare::Memory
|
||||
return *it;
|
||||
}
|
||||
|
||||
uint8_t MemoryBus::read(uint24_t addr, bool silence)
|
||||
uint8_t MemoryBus::read(uint24_t addr)
|
||||
{
|
||||
std::shared_ptr<IMemory> handler = this->getAccessor(addr);
|
||||
|
||||
if (!handler) {
|
||||
if (!silence)
|
||||
std::cout << "Unknown memory accessor for address $" << std::hex << addr << ". Using open bus." << std::endl;
|
||||
std::cout << "Unknown memory accessor for address $" << std::hex << addr << ". Using open bus." << std::endl;
|
||||
return this->_openBus;
|
||||
}
|
||||
uint8_t data = handler->read(handler->getRelativeAddress(addr));
|
||||
uint8_t data = handler->read(handler->getRelativeAddress(addr));
|
||||
this->_openBus = data;
|
||||
return data;
|
||||
}
|
||||
|
||||
uint8_t MemoryBus::read(uint24_t addr, bool silence)
|
||||
{
|
||||
if (!silence)
|
||||
return this->read(addr);
|
||||
std::shared_ptr<IMemory> handler = this->getAccessor(addr);
|
||||
|
||||
if (!handler)
|
||||
return this->_openBus;
|
||||
try {
|
||||
return handler->read(handler->getRelativeAddress(addr));
|
||||
} catch (const InvalidAddress &) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void MemoryBus::write(uint24_t addr, uint8_t data)
|
||||
{
|
||||
std::shared_ptr<IMemory> handler = this->getAccessor(addr);
|
||||
|
||||
@@ -40,9 +40,14 @@ namespace ComSquare
|
||||
|
||||
//! @brief Read data at a global address.
|
||||
//! @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.
|
||||
//! @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 = false);
|
||||
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.
|
||||
//! @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);
|
||||
|
||||
//! @brief Write a data to a global address.
|
||||
//! @param addr The address to write to.
|
||||
|
||||
Reference in New Issue
Block a user