mirror of
https://github.com/zoriya/ComSquare.git
synced 2025-12-20 06:05:11 +00:00
Solving some bugs with the memory accessor
This commit is contained in:
@@ -53,7 +53,7 @@ namespace ComSquare::Memory
|
|||||||
|
|
||||||
uint24_t IRectangleMemory::getStart()
|
uint24_t IRectangleMemory::getStart()
|
||||||
{
|
{
|
||||||
return this->_startBank + this->_startPage;
|
return (this->_startBank << 16u) + this->_startPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IRectangleMemory::setMemoryRegion(uint8_t startBank, uint8_t endBank, uint16_t startPage, uint16_t endPage)
|
void IRectangleMemory::setMemoryRegion(uint8_t startBank, uint8_t endBank, uint16_t startPage, uint16_t endPage)
|
||||||
|
|||||||
@@ -88,11 +88,11 @@ namespace ComSquare::Memory
|
|||||||
// Mirror on the lower half of the Q2.
|
// Mirror on the lower half of the Q2.
|
||||||
this->_memoryAccessors.emplace_back((new Memory::RectangleShadow(console.cartridge, 0x40, 0x6F, 0x0000, 0x7FFF))->setBankOffset(0x40));
|
this->_memoryAccessors.emplace_back((new Memory::RectangleShadow(console.cartridge, 0x40, 0x6F, 0x0000, 0x7FFF))->setBankOffset(0x40));
|
||||||
// Mirror on the lower half of the Q4
|
// Mirror on the lower half of the Q4
|
||||||
this->_memoryAccessors.emplace_back((new Memory::RectangleShadow(console.cartridge, 0xC0, 0xF0, 0x0000, 0x7FFF))->setBankOffset(0x40));
|
this->_memoryAccessors.emplace_back((new Memory::RectangleShadow(console.cartridge, 0xC0, 0xEF, 0x0000, 0x7FFF))->setBankOffset(0x40));
|
||||||
|
|
||||||
console.sram->setMemoryRegion(0x70, 0x7D, 0x0000, 0x7FFF);
|
console.sram->setMemoryRegion(0xF0, 0xFD, 0x0000, 0x7FFF);
|
||||||
this->_memoryAccessors.push_back(console.sram);
|
this->_memoryAccessors.push_back(console.sram);
|
||||||
this->_memoryAccessors.emplace_back(new Memory::RectangleShadow(console.sram, 0xF0, 0xFD, 0x0000, 0x7FFF));
|
this->_memoryAccessors.emplace_back(new Memory::RectangleShadow(console.sram, 0x70, 0x7D, 0x0000, 0x7FFF));
|
||||||
}
|
}
|
||||||
// TODO should implement HiRom.
|
// TODO should implement HiRom.
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,31 +70,28 @@ Test(BusAccessor, GetOpenBus)
|
|||||||
Test(BusAccessor, GetSramStart)
|
Test(BusAccessor, GetSramStart)
|
||||||
{
|
{
|
||||||
auto pair = Init();
|
auto pair = Init();
|
||||||
std::shared_ptr<Memory::IMemory> accessor = nullptr;
|
std::shared_ptr<Memory::RectangleShadow> accessor = nullptr;
|
||||||
|
|
||||||
accessor = pair.first.getAccessor(0x700000);
|
accessor = std::static_pointer_cast<Memory::RectangleShadow>(pair.first.getAccessor(0x700000));
|
||||||
cr_assert_eq(accessor.get(), pair.second.sram.get());
|
cr_assert_eq(accessor->_initial.get(), pair.second.sram.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
Test(BusAccessor, GetSramEnd)
|
Test(BusAccessor, GetSramEnd)
|
||||||
{
|
{
|
||||||
auto pair = Init();
|
auto pair = Init();
|
||||||
std::shared_ptr<Memory::IMemory> accessor = nullptr;
|
std::shared_ptr<Memory::RectangleShadow> accessor = nullptr;
|
||||||
|
|
||||||
accessor = pair.first.getAccessor(0x7D7FFF);
|
accessor = std::static_pointer_cast<Memory::RectangleShadow>(pair.first.getAccessor(0x7D7FFF));
|
||||||
cr_assert_eq(accessor.get(), pair.second.sram.get());
|
cr_assert_eq(accessor->_initial.get(), pair.second.sram.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
Test(BusAccessor, GetSramMirror)
|
Test(BusAccessor, GetSramMirror)
|
||||||
{
|
{
|
||||||
auto pair = Init();
|
auto pair = Init();
|
||||||
std::shared_ptr<Memory::RectangleShadow> accessor = nullptr;
|
std::shared_ptr<Memory::IRectangleMemory> accessor = nullptr;
|
||||||
|
|
||||||
accessor = std::static_pointer_cast<Memory::RectangleShadow>(pair.first.getAccessor(0xF00123));
|
accessor = std::static_pointer_cast<Memory::IRectangleMemory>(pair.first.getAccessor(0xF00123));
|
||||||
// TODO the page of the rectangle accessor seems a bit buggy and here the rom is returned as the accessor.
|
cr_assert_eq(accessor.get(), pair.second.sram.get());
|
||||||
std::cout << std::hex << accessor->_initial->getStart() << std::endl;
|
|
||||||
std::cout << std::hex << pair.second.sram.get() << std::endl;
|
|
||||||
cr_assert_eq(accessor->_initial.get(), pair.second.sram.get());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Test(BusAccessor, GetSramMirror2)
|
Test(BusAccessor, GetSramMirror2)
|
||||||
@@ -103,7 +100,7 @@ Test(BusAccessor, GetSramMirror2)
|
|||||||
std::shared_ptr<Memory::RectangleShadow> accessor = nullptr;
|
std::shared_ptr<Memory::RectangleShadow> accessor = nullptr;
|
||||||
|
|
||||||
// TODO implement the SRam accessor for the FE/FF.
|
// TODO implement the SRam accessor for the FE/FF.
|
||||||
std::cout << pair.first.getAccessor(0xFE0123) << std::endl;
|
//std::cout << pair.first.getAccessor(0xFE0123) << std::endl;
|
||||||
accessor = std::static_pointer_cast<Memory::RectangleShadow>(pair.first.getAccessor(0xFE0123));
|
accessor = std::static_pointer_cast<Memory::RectangleShadow>(pair.first.getAccessor(0xFE0123));
|
||||||
cr_assert_eq(accessor->_initial.get(), pair.second.sram.get());
|
cr_assert_eq(accessor->_initial.get(), pair.second.sram.get());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user