mirror of
https://github.com/zoriya/ComSquare.git
synced 2026-06-09 04:24:58 +00:00
Enabling the memory bus debugger
This commit is contained in:
+12
-7
@@ -7,11 +7,16 @@
|
||||
|
||||
namespace ComSquare::CPU
|
||||
{
|
||||
DMA::DMA(Memory::MemoryBus &bus)
|
||||
DMA::DMA(Memory::IMemoryBus &bus)
|
||||
: _bus(bus),
|
||||
enabled(false)
|
||||
{}
|
||||
|
||||
void DMA::setBus(Memory::IMemoryBus &bus)
|
||||
{
|
||||
this->_bus = bus;
|
||||
}
|
||||
|
||||
uint8_t DMA::read(uint8_t addr) const
|
||||
{
|
||||
switch (addr) {
|
||||
@@ -68,22 +73,22 @@ namespace ComSquare::CPU
|
||||
// Address $2180 refers to the WRam data register.
|
||||
// Write to/Read from this port when the a address is on the vram cause different behaviors.
|
||||
if (this->_port == 0x80) {
|
||||
auto accessor = this->_bus.getAccessor(aAddress);
|
||||
auto accessor = this->getBus().getAccessor(aAddress);
|
||||
if (accessor && accessor->getComponent() == WRam) {
|
||||
// WRAM->$2180 The write is not performed but the time is consumed anyway.
|
||||
if (this->_controlRegister.direction == AtoB)
|
||||
return 8;
|
||||
// $2180->WRAM No read is performed (so only 4 master cycles are needed) but the value written is invalid.
|
||||
this->_bus.write(aAddress, 0xFF);
|
||||
this->getBus().write(aAddress, 0xFF);
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
if (this->_controlRegister.direction == AtoB) {
|
||||
uint8_t data = this->_bus.read(aAddress);
|
||||
this->_bus.write(bAddress, data);
|
||||
uint8_t data = this->getBus().read(aAddress);
|
||||
this->getBus().write(bAddress, data);
|
||||
} else {
|
||||
uint8_t data = this->_bus.read(bAddress);
|
||||
this->_bus.write(aAddress, data);
|
||||
uint8_t data = this->getBus().read(bAddress);
|
||||
this->getBus().write(aAddress, data);
|
||||
}
|
||||
return 8;
|
||||
}
|
||||
|
||||
+11
-2
@@ -93,9 +93,18 @@ namespace ComSquare::CPU
|
||||
} _count {};
|
||||
|
||||
//! @brief The memory bus to use for read/write.
|
||||
Memory::MemoryBus &_bus;
|
||||
Memory::IMemoryBus &_bus;
|
||||
|
||||
public:
|
||||
//! @brief Get the memory bus used by this CPU.
|
||||
[[nodiscard]] inline Memory::IMemoryBus &getBus()
|
||||
{
|
||||
return this->_bus;
|
||||
}
|
||||
//! @brief Set the memory bus used by this CPU
|
||||
//! @param bus The bus to use.
|
||||
void setBus(Memory::IMemoryBus &bus);
|
||||
|
||||
//! @brief Is this channel set to run?
|
||||
bool enabled;
|
||||
|
||||
@@ -116,7 +125,7 @@ namespace ComSquare::CPU
|
||||
|
||||
//! @brief Create a DMA channel with a given bus
|
||||
//! @param bus The memory bus to use.
|
||||
explicit DMA(Memory::MemoryBus &bus);
|
||||
explicit DMA(Memory::IMemoryBus &bus);
|
||||
//! @brief A DMA is copy constructable.
|
||||
DMA(const DMA &) = default;
|
||||
//! @brief A DMA is not assignable
|
||||
|
||||
Reference in New Issue
Block a user