mirror of
https://github.com/zoriya/ComSquare.git
synced 2026-05-28 16:43:35 +00:00
Solving some tests
This commit is contained in:
@@ -87,10 +87,12 @@ namespace ComSquare::Memory
|
||||
this->_memoryAccessors.emplace_back(new Memory::RectangleShadow(console.cartridge, 0x00, 0x7D, 0x8000, 0xFFFF));
|
||||
// Mirror on the lower half of the Q2.
|
||||
this->_memoryAccessors.emplace_back((new Memory::RectangleShadow(console.cartridge, 0x40, 0x6F, 0x0000, 0x7FFF))->setBankOffset(0x40));
|
||||
// Mirror on the lower half of the Q4
|
||||
this->_memoryAccessors.emplace_back((new Memory::RectangleShadow(console.cartridge, 0xC0, 0xF0, 0x0000, 0x7FFF))->setBankOffset(0x40));
|
||||
|
||||
console.sram->setMemoryRegion(0x70, 0x7D, 0x0000, 0x7FFF);
|
||||
this->_memoryAccessors.push_back(console.sram);
|
||||
this->_memoryAccessors.emplace_back(new Memory::RectangleShadow(console.sram, 0xFE, 0xFF, 0x0000, 0x7FFF));
|
||||
this->_memoryAccessors.emplace_back(new Memory::RectangleShadow(console.sram, 0xF0, 0xFD, 0x0000, 0x7FFF));
|
||||
}
|
||||
// TODO should implement HiRom.
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace ComSquare::Memory
|
||||
//! @brief Memory to shadow from.
|
||||
std::shared_ptr<IRectangleMemory> _initial;
|
||||
//! @brief The number of banks to add to the memory before accessing it from the initial data.
|
||||
uint8_t _bankOffset;
|
||||
uint8_t _bankOffset = 0;
|
||||
public:
|
||||
//! @brief Create a shadow for the memory given as parameter.
|
||||
explicit RectangleShadow(std::shared_ptr<IRectangleMemory> initial, uint8_t startBank, uint8_t endBank, uint16_t startPage, uint16_t endPage);
|
||||
|
||||
+20
-17
@@ -60,13 +60,11 @@ Test(BusAccessor, GetWramMirror)
|
||||
cr_assert_eq(accessor->_initial.get(), pair.second.wram.get());
|
||||
}
|
||||
|
||||
Test(BusAccessor, GetWramMirror2)
|
||||
Test(BusAccessor, GetOpenBus)
|
||||
{
|
||||
auto pair = Init();
|
||||
std::shared_ptr<Memory::IMemory> accessor = nullptr;
|
||||
|
||||
accessor = pair.first.getAccessor(0x897654);
|
||||
cr_assert_eq(accessor.get(), pair.second.wram.get());
|
||||
std::shared_ptr<Memory::IMemory> accessor = pair.first.getAccessor(0x897654);
|
||||
cr_assert_eq(accessor.get(), nullptr);
|
||||
}
|
||||
|
||||
Test(BusAccessor, GetSramStart)
|
||||
@@ -90,19 +88,24 @@ Test(BusAccessor, GetSramEnd)
|
||||
Test(BusAccessor, GetSramMirror)
|
||||
{
|
||||
auto pair = Init();
|
||||
std::shared_ptr<Memory::IMemory> accessor = nullptr;
|
||||
std::shared_ptr<Memory::RectangleShadow> accessor = nullptr;
|
||||
|
||||
accessor = pair.first.getAccessor(0xF00123);
|
||||
cr_assert_eq(accessor.get(), pair.second.sram.get());
|
||||
accessor = std::static_pointer_cast<Memory::RectangleShadow>(pair.first.getAccessor(0xF00123));
|
||||
// TODO the page of the rectangle accessor seems a bit buggy and here the rom is returned as the accessor.
|
||||
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)
|
||||
{
|
||||
auto pair = Init();
|
||||
std::shared_ptr<Memory::IMemory> accessor = nullptr;
|
||||
std::shared_ptr<Memory::RectangleShadow> accessor = nullptr;
|
||||
|
||||
accessor = pair.first.getAccessor(0xFE0123);
|
||||
cr_assert_eq(accessor.get(), pair.second.sram.get());
|
||||
// TODO implement the SRam accessor for the FE/FF.
|
||||
std::cout << pair.first.getAccessor(0xFE0123) << std::endl;
|
||||
accessor = std::static_pointer_cast<Memory::RectangleShadow>(pair.first.getAccessor(0xFE0123));
|
||||
cr_assert_eq(accessor->_initial.get(), pair.second.sram.get());
|
||||
}
|
||||
|
||||
Test(BusAccessor, GetAPUStart)
|
||||
@@ -225,19 +228,19 @@ Test(BusAccessor, GetRomMirror)
|
||||
Test(BusAccessor, GetRomMirror2)
|
||||
{
|
||||
auto pair = Init();
|
||||
std::shared_ptr<Memory::IMemory> accessor = nullptr;
|
||||
std::shared_ptr<Memory::RectangleShadow> accessor = nullptr;
|
||||
|
||||
accessor = pair.first.getAccessor(0x01FEDC);
|
||||
cr_assert_eq(accessor.get(), pair.second.cartridge.get());
|
||||
accessor = std::static_pointer_cast<Memory::RectangleShadow>(pair.first.getAccessor(0x01FEDC));
|
||||
cr_assert_eq(accessor->_initial.get(), pair.second.cartridge.get());
|
||||
}
|
||||
|
||||
Test(BusAccessor, GetRomMirror3)
|
||||
{
|
||||
auto pair = Init();
|
||||
std::shared_ptr<Memory::IMemory> accessor = nullptr;
|
||||
std::shared_ptr<Memory::RectangleShadow> accessor = nullptr;
|
||||
|
||||
accessor = pair.first.getAccessor(0xDE1248);
|
||||
cr_assert_eq(accessor.get(), pair.second.cartridge.get());
|
||||
accessor = std::static_pointer_cast<Memory::RectangleShadow>(pair.first.getAccessor(0xDE1248));
|
||||
cr_assert_eq(accessor->_initial.get(), pair.second.cartridge.get());
|
||||
}
|
||||
|
||||
////////////////////////////
|
||||
|
||||
Reference in New Issue
Block a user