Skip to content

Commit

Permalink
NES: Disable Game Genie bus conflicts emulation when running an unkno…
Browse files Browse the repository at this point in the history
…wn iNES 1.0 ROM

Otherwise, Game Genie codes that could have worked on hardware did not work as expected because of the bus conflicts. This could occur when e.g trying to use cheats on a romhack, etc.
  • Loading branch information
SourMesen committed Jul 20, 2024
1 parent 485c204 commit c774155
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
7 changes: 7 additions & 0 deletions Core/NES/BaseMapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,11 @@ void BaseMapper::InitializeChrRam(int32_t chrRamSize)
}
}

bool BaseMapper::HasDefaultWorkRam()
{
return _hasDefaultWorkRam;
}

void BaseMapper::SetupDefaultWorkRam()
{
//Setup a default work/save ram in 0x6000-0x7FFF space
Expand Down Expand Up @@ -576,6 +581,7 @@ void BaseMapper::Initialize(NesConsole* console, RomData& romData)

if(romData.SaveRamSize == -1) {
_saveRamSize = HasBattery() ? GetSaveRamSize() : 0;
_hasDefaultWorkRam = _saveRamSize > 0;
} else if(ForceSaveRamSize()) {
_saveRamSize = GetSaveRamSize();
} else {
Expand All @@ -584,6 +590,7 @@ void BaseMapper::Initialize(NesConsole* console, RomData& romData)

if(romData.WorkRamSize == -1) {
_workRamSize = HasBattery() ? 0 : GetWorkRamSize();
_hasDefaultWorkRam = _workRamSize > 0;
} else if(ForceWorkRamSize()) {
_workRamSize = GetWorkRamSize();
} else {
Expand Down
3 changes: 3 additions & 0 deletions Core/NES/BaseMapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class BaseMapper : public INesMemoryHandler, public ISerializable
uint32_t _internalRamMask = 0x7FF;

bool _hasBusConflicts = false;
bool _hasDefaultWorkRam = false;

bool _allowRegisterRead = false;
bool _isReadRegisterAddr[0x10000] = {};
Expand Down Expand Up @@ -170,6 +171,8 @@ class BaseMapper : public INesMemoryHandler, public ISerializable

GameSystem GetGameSystem();
PpuModel GetPpuModel();

bool HasDefaultWorkRam();

virtual void SetRegion(ConsoleRegion region) { }
virtual void ProcessCpuClock() { }
Expand Down
6 changes: 0 additions & 6 deletions Core/NES/GameDatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,12 +217,6 @@ void GameDatabase::SetGameInfo(uint32_t romCrc, RomData &romData, bool updateRom
bool foundInDatabase = result != _gameDatabase.end();
if(foundInDatabase) {
info = result->second;
if(!forHeaderlessRom && info.Board == "UNK") {
//Boards marked as UNK should only be used for headerless roms (since their data is unverified)
romData.Info.DatabaseInfo = {};
return;
}

MessageManager::Log("[DB] Game found in database");

MessageManager::Log("[DB] Mapper: " + std::to_string(info.MapperID) + " Sub: " + std::to_string(GetSubMapper(info)));
Expand Down
2 changes: 1 addition & 1 deletion Core/NES/NesConsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ void NesConsole::InitializeInputDevices(GameInputType inputType, GameSystem syst
void NesConsole::ProcessCheatCode(InternalCheatCode& code, uint32_t addr, uint8_t& value)
{
if(code.Type == CheatType::NesGameGenie && addr >= 0xC020) {
if(GetNesConfig().DisableGameGenieBusConflicts) {
if(GetNesConfig().DisableGameGenieBusConflicts || _mapper->HasDefaultWorkRam()) {
return;
}

Expand Down

0 comments on commit c774155

Please sign in to comment.