Fixed crash when rom contains no CHR ROM & no CHR RAM
This commit is contained in:
parent
d805ac2d3c
commit
1bff8affb9
1 changed files with 22 additions and 2 deletions
|
@ -135,8 +135,14 @@ void BaseMapper::SetPpuMemoryMapping(uint16_t startAddr, uint16_t endAddr, uint1
|
|||
uint8_t defaultAccessType = MemoryAccessType::Read;
|
||||
switch(type) {
|
||||
case ChrMemoryType::Default:
|
||||
pageCount = GetCHRPageCount();
|
||||
pageSize = InternalGetChrPageSize();
|
||||
if(pageSize == 0) {
|
||||
#ifdef _DEBUG
|
||||
MessageManager::DisplayMessage("Debug", "Tried to map undefined chr rom/ram.");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
pageCount = GetCHRPageCount();
|
||||
sourceMemory = _onlyChrRam ? _chrRam : _chrRom;
|
||||
if(_onlyChrRam) {
|
||||
defaultAccessType |= MemoryAccessType::Write;
|
||||
|
@ -144,8 +150,15 @@ void BaseMapper::SetPpuMemoryMapping(uint16_t startAddr, uint16_t endAddr, uint1
|
|||
break;
|
||||
|
||||
case ChrMemoryType::ChrRom:
|
||||
pageCount = GetCHRPageCount();
|
||||
pageSize = InternalGetChrPageSize();
|
||||
if(pageSize == 0) {
|
||||
#ifdef _DEBUG
|
||||
MessageManager::DisplayMessage("Debug", "Tried to map undefined chr rom.");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
pageCount = GetCHRPageCount();
|
||||
|
||||
sourceMemory = _chrRom;
|
||||
break;
|
||||
|
||||
|
@ -163,6 +176,13 @@ void BaseMapper::SetPpuMemoryMapping(uint16_t startAddr, uint16_t endAddr, uint1
|
|||
break;
|
||||
}
|
||||
|
||||
if(pageCount == 0) {
|
||||
#ifdef _DEBUG
|
||||
MessageManager::DisplayMessage("Debug", "Tried to map undefined chr ram.");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
SetPpuMemoryMapping(startAddr, endAddr, sourceMemory + (pageNumber % pageCount) * pageSize, accessType == -1 ? defaultAccessType : accessType);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue