Dungeon object updates
This commit is contained in:
@@ -623,18 +623,18 @@ class CPU : public Memory, public Loggable, public core::ExperimentFlags {
|
||||
void XCE();
|
||||
|
||||
// Memory access routines
|
||||
uint8_t ReadByte(uint16_t address) const override {
|
||||
uint8_t ReadByte(uint32_t address) const override {
|
||||
auto value = memory.ReadByte(address);
|
||||
return value;
|
||||
}
|
||||
uint16_t ReadWord(uint16_t address) const override {
|
||||
uint16_t ReadWord(uint32_t address) const override {
|
||||
return memory.ReadWord(address);
|
||||
}
|
||||
uint32_t ReadWordLong(uint16_t address) const override {
|
||||
uint32_t ReadWordLong(uint32_t address) const override {
|
||||
return memory.ReadWordLong(address);
|
||||
}
|
||||
|
||||
std::vector<uint8_t> ReadByteVector(uint16_t address,
|
||||
std::vector<uint8_t> ReadByteVector(uint32_t address,
|
||||
uint16_t size) const override {
|
||||
return memory.ReadByteVector(address, size);
|
||||
}
|
||||
|
||||
@@ -48,11 +48,21 @@ void DrawMemoryWindow(Memory* memory) {
|
||||
// Display memory areas
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("ROM");
|
||||
ImGui::Text("ROM Bank 0-63");
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("0x000000");
|
||||
ImGui::Text("0x8000");
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("%d MB", memoryImpl->rom_.size());
|
||||
ImGui::Text("128 KB");
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("LoROM");
|
||||
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("ROM Bank 64-111");
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("0x0000");
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("64 KB");
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("LoROM");
|
||||
|
||||
@@ -60,9 +70,39 @@ void DrawMemoryWindow(Memory* memory) {
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("RAM");
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("0x700000");
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("64 KB");
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("LoROM");
|
||||
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("System RAM (WRAM)");
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("0x7E0000");
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("%d KB", memoryImpl->ram_.size());
|
||||
ImGui::Text("128 KB");
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("LoROM");
|
||||
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("ROM Bank 128-191");
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("0x8000");
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("128 KB");
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("LoROM");
|
||||
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("ROM Bank 192-255");
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("0x0000");
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("64 KB");
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("LoROM");
|
||||
}
|
||||
@@ -109,7 +149,6 @@ void Emulator::Run() {
|
||||
ImGui::Button(ICON_MD_DOUBLE_ARROW);
|
||||
ImGui::SameLine();
|
||||
ImGui::Button(ICON_MD_SUBDIRECTORY_ARROW_RIGHT);
|
||||
ImGui::SameLine();
|
||||
|
||||
if (running_) {
|
||||
HandleEvents();
|
||||
@@ -331,8 +370,9 @@ void Emulator::RenderCPUInstructionLog(
|
||||
ImGui::Checkbox("Show All Opcodes", &showAllOpcodes);
|
||||
|
||||
// Instruction list
|
||||
ImGui::BeginChild("InstructionList", ImVec2(0, 0),
|
||||
ImGuiChildFlags_AlwaysAutoResize);
|
||||
ImGui::BeginChild(
|
||||
"InstructionList", ImVec2(0, 0),
|
||||
ImGuiChildFlags_AlwaysAutoResize | ImGuiChildFlags_AutoResizeY);
|
||||
for (const auto& entry : instructionLog) {
|
||||
if (ShouldDisplay(entry, filterBuf, showAllOpcodes)) {
|
||||
if (ImGui::Selectable(absl::StrFormat("%04X: %02X %s %s", entry.address,
|
||||
|
||||
@@ -109,10 +109,10 @@ constexpr uint32_t kOAMSize = 0x220;
|
||||
class Memory {
|
||||
public:
|
||||
virtual ~Memory() = default;
|
||||
virtual uint8_t ReadByte(uint16_t address) const = 0;
|
||||
virtual uint16_t ReadWord(uint16_t address) const = 0;
|
||||
virtual uint32_t ReadWordLong(uint16_t address) const = 0;
|
||||
virtual std::vector<uint8_t> ReadByteVector(uint16_t address,
|
||||
virtual uint8_t ReadByte(uint32_t address) const = 0;
|
||||
virtual uint16_t ReadWord(uint32_t address) const = 0;
|
||||
virtual uint32_t ReadWordLong(uint32_t address) const = 0;
|
||||
virtual std::vector<uint8_t> ReadByteVector(uint32_t address,
|
||||
uint16_t length) const = 0;
|
||||
|
||||
virtual void WriteByte(uint32_t address, uint8_t value) = 0;
|
||||
@@ -149,7 +149,7 @@ class MemoryImpl : public Memory, public Loggable {
|
||||
return;
|
||||
}
|
||||
|
||||
memory_.reserve(0x1000000); // 16 MB
|
||||
memory_.resize(0x1000000); // 16 MB
|
||||
|
||||
const size_t ROM_CHUNK_SIZE = 0x8000; // 32 KB
|
||||
const size_t SRAM_SIZE = 0x10000; // 64 KB
|
||||
@@ -229,25 +229,25 @@ class MemoryImpl : public Memory, public Loggable {
|
||||
memory_.begin() + kOAMStart + kOAMSize, oam_.begin());
|
||||
}
|
||||
|
||||
uint8_t ReadByte(uint16_t address) const override {
|
||||
uint8_t ReadByte(uint32_t address) const override {
|
||||
uint32_t mapped_address = GetMappedAddress(address);
|
||||
NotifyObservers(mapped_address, /*data=*/0);
|
||||
return memory_.at(mapped_address);
|
||||
}
|
||||
uint16_t ReadWord(uint16_t address) const override {
|
||||
uint16_t ReadWord(uint32_t address) const override {
|
||||
uint32_t mapped_address = GetMappedAddress(address);
|
||||
NotifyObservers(mapped_address, /*data=*/0);
|
||||
return static_cast<uint16_t>(memory_.at(mapped_address)) |
|
||||
(static_cast<uint16_t>(memory_.at(mapped_address + 1)) << 8);
|
||||
}
|
||||
uint32_t ReadWordLong(uint16_t address) const override {
|
||||
uint32_t ReadWordLong(uint32_t address) const override {
|
||||
uint32_t mapped_address = GetMappedAddress(address);
|
||||
NotifyObservers(mapped_address, /*data=*/0);
|
||||
return static_cast<uint32_t>(memory_.at(mapped_address)) |
|
||||
(static_cast<uint32_t>(memory_.at(mapped_address + 1)) << 8) |
|
||||
(static_cast<uint32_t>(memory_.at(mapped_address + 2)) << 16);
|
||||
}
|
||||
std::vector<uint8_t> ReadByteVector(uint16_t address,
|
||||
std::vector<uint8_t> ReadByteVector(uint32_t address,
|
||||
uint16_t length) const override {
|
||||
uint32_t mapped_address = GetMappedAddress(address);
|
||||
NotifyObservers(mapped_address, /*data=*/0);
|
||||
|
||||
@@ -23,11 +23,11 @@ class MockClock : public Clock {
|
||||
|
||||
class MockMemory : public Memory {
|
||||
public:
|
||||
MOCK_CONST_METHOD1(ReadByte, uint8_t(uint16_t address));
|
||||
MOCK_CONST_METHOD1(ReadWord, uint16_t(uint16_t address));
|
||||
MOCK_CONST_METHOD1(ReadWordLong, uint32_t(uint16_t address));
|
||||
MOCK_CONST_METHOD1(ReadByte, uint8_t(uint32_t address));
|
||||
MOCK_CONST_METHOD1(ReadWord, uint16_t(uint32_t address));
|
||||
MOCK_CONST_METHOD1(ReadWordLong, uint32_t(uint32_t address));
|
||||
MOCK_METHOD(std::vector<uint8_t>, ReadByteVector,
|
||||
(uint16_t address, uint16_t length), (const, override));
|
||||
(uint32_t address, uint16_t length), (const, override));
|
||||
|
||||
MOCK_METHOD2(WriteByte, void(uint32_t address, uint8_t value));
|
||||
MOCK_METHOD2(WriteWord, void(uint32_t address, uint16_t value));
|
||||
@@ -76,20 +76,20 @@ class MockMemory : public Memory {
|
||||
void Init() {
|
||||
ON_CALL(*this, ReadByte(::testing::_))
|
||||
.WillByDefault(
|
||||
[this](uint16_t address) { return memory_.at(address); });
|
||||
[this](uint32_t address) { return memory_.at(address); });
|
||||
ON_CALL(*this, ReadWord(::testing::_))
|
||||
.WillByDefault([this](uint16_t address) {
|
||||
.WillByDefault([this](uint32_t address) {
|
||||
return static_cast<uint16_t>(memory_.at(address)) |
|
||||
(static_cast<uint16_t>(memory_.at(address + 1)) << 8);
|
||||
});
|
||||
ON_CALL(*this, ReadWordLong(::testing::_))
|
||||
.WillByDefault([this](uint16_t address) {
|
||||
.WillByDefault([this](uint32_t address) {
|
||||
return static_cast<uint32_t>(memory_.at(address)) |
|
||||
(static_cast<uint32_t>(memory_.at(address + 1)) << 8) |
|
||||
(static_cast<uint32_t>(memory_.at(address + 2)) << 16);
|
||||
});
|
||||
ON_CALL(*this, ReadByteVector(::testing::_, ::testing::_))
|
||||
.WillByDefault([this](uint16_t address, uint16_t length) {
|
||||
.WillByDefault([this](uint32_t address, uint16_t length) {
|
||||
std::vector<uint8_t> data;
|
||||
for (int i = 0; i < length; i++) {
|
||||
data.push_back(memory_.at(address + i));
|
||||
|
||||
Reference in New Issue
Block a user