Fixed SetCpuMemoryMapping() behavior when range is bigger than page size

This commit is contained in:
Souryo 2016-08-26 21:50:52 -04:00
parent 1657e254b5
commit 514663fba0
2 changed files with 12 additions and 7 deletions

View file

@ -89,11 +89,16 @@ void BaseMapper::SetCpuMemoryMapping(uint16_t startAddr, uint16_t endAddr, int16
MessageManager::DisplayMessage("Debug", "Tried to map undefined prg - page size too small for selected range.");
#endif
//Make sure the range is no bigger than a single page, else we could read from unallocated memory
endAddr = startAddr + pageSize - 1;
//If range is bigger than a single page, keep going until we reach the last page
while(pageNumber < pageCount && startAddr <= endAddr - pageSize + 1) {
SetCpuMemoryMapping(startAddr, startAddr + pageSize - 1, source, accessType);
pageNumber++;
startAddr += pageSize;
source += pageSize;
}
} else {
SetCpuMemoryMapping(startAddr, endAddr, source, accessType);
}
SetCpuMemoryMapping(startAddr, endAddr, source, accessType);
}
void BaseMapper::SetCpuMemoryMapping(uint16_t startAddr, uint16_t endAddr, uint8_t *source, int8_t accessType)

View file

@ -118,9 +118,9 @@ protected:
virtual uint32_t GetChrRamSize() { return 0x0000; }
//Work ram is NOT saved - aka Expansion ram, etc.
virtual uint32_t GetWorkRamPageSize() { return HasBattery() ? 0 : 0x2000; }
virtual uint32_t GetWorkRamSize() { return 0x2000; }
virtual uint32_t GetWorkRamSize() { return HasBattery() ? 0 : 0x2000; }
virtual uint32_t GetWorkRamPageSize() { return 0x2000; }
virtual uint16_t RegisterStartAddress() { return 0x8000; }
virtual uint16_t RegisterEndAddress() { return 0xFFFF; }
virtual bool AllowRegisterRead() { return false; }