Update Shadow RAM mem mapping, add verbose flag

This commit is contained in:
scawful
2023-12-05 03:45:28 -05:00
parent fdb4fe6971
commit 6931ed4500

View File

@@ -138,8 +138,9 @@ enum class MemoryMapping { SNES_LOROM = 0, PC_ADDRESS = 1 };
class MemoryImpl : public Memory, public Loggable { class MemoryImpl : public Memory, public Loggable {
public: public:
void Initialize(const std::vector<uint8_t>& romData, void Initialize(const std::vector<uint8_t>& romData, bool verbose = false,
MemoryMapping mapping = MemoryMapping::SNES_LOROM) { MemoryMapping mapping = MemoryMapping::SNES_LOROM) {
verbose_ = verbose;
mapping_ = mapping; mapping_ = mapping;
if (mapping == MemoryMapping::PC_ADDRESS) { if (mapping == MemoryMapping::PC_ADDRESS) {
memory_.resize(romData.size()); memory_.resize(romData.size());
@@ -338,7 +339,7 @@ class MemoryImpl : public Memory, public Loggable {
private: private:
uint32_t GetMappedAddress(uint32_t address) const { uint32_t GetMappedAddress(uint32_t address) const {
uint32_t bank = address >> 16; uint8_t bank = address >> 16;
uint32_t offset = address & 0xFFFF; uint32_t offset = address & 0xFFFF;
if (mapping_ == MemoryMapping::PC_ADDRESS) { if (mapping_ == MemoryMapping::PC_ADDRESS) {
@@ -347,9 +348,9 @@ class MemoryImpl : public Memory, public Loggable {
if (bank <= 0x3F) { if (bank <= 0x3F) {
if (offset <= 0x1FFF) { if (offset <= 0x1FFF) {
return offset; // Shadow RAM return (0x7E << 16) + offset; // Shadow RAM
} else if (offset <= 0x5FFF) { } else if (offset <= 0x5FFF) {
return offset - 0x2000 + 0x2000; // Hardware Registers return (bank << 16) + (offset - 0x2000) + 0x2000; // Hardware Registers
} else if (offset <= 0x7FFF) { } else if (offset <= 0x7FFF) {
return offset - 0x6000 + 0x6000; // Expansion RAM return offset - 0x6000 + 0x6000; // Expansion RAM
} else { } else {
@@ -373,6 +374,8 @@ class MemoryImpl : public Memory, public Loggable {
} }
} }
bool verbose_ = false;
std::vector<Observer*> observers_; std::vector<Observer*> observers_;
// Memory (64KB) // Memory (64KB)