add system for applying individual game hacks by gamecode

This commit is contained in:
zeromus 2017-03-04 01:31:14 -06:00
parent 7c9abef399
commit c1e5a56233
6 changed files with 53 additions and 13 deletions

View File

@ -304,6 +304,11 @@ bool GameInfo::hasRomBanner()
else return true; else return true;
} }
bool GameInfo::IsCode(const char* code) const
{
return memcmp(code,header.gameCode,strlen(code));
}
const RomBanner& GameInfo::getRomBanner() const RomBanner& GameInfo::getRomBanner()
{ {
return banner; return banner;
@ -1492,7 +1497,7 @@ static void execHardware_hstart()
} }
else if (nds.VCount == 262) else if (nds.VCount == 262)
{ {
if (!NDS_ARM9.freeze && nds.overclock < 2 && CommonSettings.gamehacks) if (!NDS_ARM9.freeze && nds.overclock < 2 && CommonSettings.gamehacks.flags.overclock)
{ {
//suspend arm7 during overclocking so much doesn't run out of control //suspend arm7 during overclocking so much doesn't run out of control
//actually, this isn't needed yet. //actually, this isn't needed yet.
@ -2507,6 +2512,8 @@ void NDS_Reset()
{ {
PrepareLogfiles(); PrepareLogfiles();
CommonSettings.gamehacks.apply();
if(movieMode != MOVIEMODE_INACTIVE && !_HACK_DONT_STOPMOVIE) if(movieMode != MOVIEMODE_INACTIVE && !_HACK_DONT_STOPMOVIE)
movie_reset_command = true; movie_reset_command = true;
@ -3064,3 +3071,16 @@ void NDS_GetCPULoadAverage(u32 &outLoadAvgARM9, u32 &outLoadAvgARM7)
//these templates needed to be instantiated manually //these templates needed to be instantiated manually
template void NDS_exec<FALSE>(s32 nb); template void NDS_exec<FALSE>(s32 nb);
template void NDS_exec<TRUE>(s32 nb); template void NDS_exec<TRUE>(s32 nb);
void TCommonSettings::GameHacks::apply()
{
clear();
if(!en) return;
flags.overclock = gameInfo.IsCode("IPK") || gameInfo.IsCode("IPG"); //HG/SS
}
void TCommonSettings::GameHacks::clear()
{
memset(&flags,0,sizeof(flags));
}

View File

@ -353,6 +353,8 @@ struct GameInfo
~GameInfo() { closeROM(); } ~GameInfo() { closeROM(); }
bool IsCode(const char* code) const;
bool loadROM(std::string fname, u32 type = ROM_NDS); bool loadROM(std::string fname, u32 type = ROM_NDS);
void closeROM(); void closeROM();
u32 readROM(u32 pos); u32 readROM(u32 pos);
@ -475,7 +477,8 @@ template<bool FORCE> void NDS_exec(s32 nb = 560190<<1);
extern int lagframecounter; extern int lagframecounter;
extern struct TCommonSettings { extern struct TCommonSettings
{
TCommonSettings() TCommonSettings()
: GFX3D_HighResolutionInterpolateColor(true) : GFX3D_HighResolutionInterpolateColor(true)
, GFX3D_EdgeMark(true) , GFX3D_EdgeMark(true)
@ -502,7 +505,6 @@ extern struct TCommonSettings {
, cheatsDisable(false) , cheatsDisable(false)
, rigorous_timing(false) , rigorous_timing(false)
, advanced_timing(true) , advanced_timing(true)
, gamehacks(false)
, micMode(InternalNoise) , micMode(InternalNoise)
, spuInterpolationMode(1) , spuInterpolationMode(1)
, manualBackupType(0) , manualBackupType(0)
@ -579,7 +581,22 @@ extern struct TCommonSettings {
int num_cores; int num_cores;
bool single_core() { return num_cores==1; } bool single_core() { return num_cores==1; }
bool rigorous_timing; bool rigorous_timing;
bool gamehacks;
struct GameHacks {
GameHacks()
: en(true)
{
clear();
}
bool en;
struct {
bool overclock;
} flags;
void apply();
void clear();
} gamehacks;
int StylusPressure; int StylusPressure;
bool StylusJitter; bool StylusJitter;

View File

@ -41,8 +41,9 @@ public:
NDS_SLOT1_TYPE selection = NDS_SLOT1_RETAIL_MCROM; NDS_SLOT1_TYPE selection = NDS_SLOT1_RETAIL_MCROM;
//check game ID in core emulator and select right implementation //check game ID in core emulator and select right implementation
if ((memcmp(gameInfo.header.gameCode, "UOR", 3) == 0) || // WarioWare - D.I.Y. (U)(E)(EUR) / Made in Ore (J) //gamehack: definitely not a game hack, just a lazy way of selecting the right equipment for the game
(memcmp(gameInfo.header.gameCode, "UXBP", 4) == 0) // Jam with the Band (EUR) if(gameInfo.IsCode("UOR") || // WarioWare - D.I.Y. (U)(E)(EUR) / Made in Ore (J)
gameInfo.IsCode("UXBP") // Jam with the Band (EUR)
) )
selection = NDS_SLOT1_RETAIL_NAND; selection = NDS_SLOT1_RETAIL_NAND;

View File

@ -1,5 +1,5 @@
/* /*
Copyright (C) 2013-2015 DeSmuME team Copyright (C) 2013-2017 DeSmuME team
This file is free software: you can redistribute it and/or modify This file is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -37,5 +37,7 @@ void Slot1Comp_MC::auxspi_reset(int PROCNUM)
void Slot1Comp_MC::connect() void Slot1Comp_MC::connect()
{ {
if(!memcmp(gameInfo.header.gameCode,"AXBJ", 4)) MMU_new.backupDevice.uninitializedValue = 0x00; // Daigassou! Band Brothers DX (JP) //gamehack: not really a game hack
if(gameInfo.IsCode("AXBJ"))
MMU_new.backupDevice.uninitializedValue = 0x00; // Daigassou! Band Brothers DX (JP)
} }

View File

@ -355,7 +355,7 @@ bool CommandLine::parse(int argc,char **argv)
if(_num_cores != -1) CommonSettings.num_cores = _num_cores; if(_num_cores != -1) CommonSettings.num_cores = _num_cores;
if(_rigorous_timing) CommonSettings.rigorous_timing = true; if(_rigorous_timing) CommonSettings.rigorous_timing = true;
if(_advanced_timing != -1) CommonSettings.advanced_timing = _advanced_timing==1; if(_advanced_timing != -1) CommonSettings.advanced_timing = _advanced_timing==1;
if(_gamehacks != -1) CommonSettings.gamehacks = _gamehacks==1; if(_gamehacks != -1) CommonSettings.gamehacks.en = _gamehacks==1;
#ifdef HAVE_JIT #ifdef HAVE_JIT
if(_cpu_mode != -1) CommonSettings.use_jit = (_cpu_mode==1); if(_cpu_mode != -1) CommonSettings.use_jit = (_cpu_mode==1);

View File

@ -2988,7 +2988,7 @@ int _main()
CommonSettings.showGpu.sub = GetPrivateProfileInt("Display", "SubGpu", 1, IniName) != 0; CommonSettings.showGpu.sub = GetPrivateProfileInt("Display", "SubGpu", 1, IniName) != 0;
CommonSettings.spu_advanced = GetPrivateProfileBool("Sound", "SpuAdvanced", false, IniName); CommonSettings.spu_advanced = GetPrivateProfileBool("Sound", "SpuAdvanced", false, IniName);
CommonSettings.advanced_timing = GetPrivateProfileBool("Emulation", "AdvancedTiming", true, IniName); CommonSettings.advanced_timing = GetPrivateProfileBool("Emulation", "AdvancedTiming", true, IniName);
CommonSettings.gamehacks = GetPrivateProfileBool("Emulation", "GameHacks", true, IniName); CommonSettings.gamehacks.en = GetPrivateProfileBool("Emulation", "GameHacks", true, IniName);
CommonSettings.StylusJitter = GetPrivateProfileBool("Emulation", "StylusJitter", false, IniName); CommonSettings.StylusJitter = GetPrivateProfileBool("Emulation", "StylusJitter", false, IniName);
CommonSettings.GFX3D_Zelda_Shadow_Depth_Hack = GetPrivateProfileInt("3D", "ZeldaShadowDepthHack", 0, IniName); CommonSettings.GFX3D_Zelda_Shadow_Depth_Hack = GetPrivateProfileInt("3D", "ZeldaShadowDepthHack", 0, IniName);
@ -6447,7 +6447,7 @@ LRESULT CALLBACK EmulationSettingsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, L
CheckDlgItem(hDlg,IDC_CHECKBOX_DEBUGGERMODE,CommonSettings.DebugConsole); CheckDlgItem(hDlg,IDC_CHECKBOX_DEBUGGERMODE,CommonSettings.DebugConsole);
CheckDlgItem(hDlg,IDC_CHECKBOX_ENSATAEMULATION,CommonSettings.EnsataEmulation); CheckDlgItem(hDlg,IDC_CHECKBOX_ENSATAEMULATION,CommonSettings.EnsataEmulation);
CheckDlgItem(hDlg, IDC_CHECBOX_ADVANCEDTIMING, CommonSettings.advanced_timing); CheckDlgItem(hDlg, IDC_CHECBOX_ADVANCEDTIMING, CommonSettings.advanced_timing);
CheckDlgItem(hDlg, IDC_CHECKBOX_GAMEHACKS, CommonSettings.gamehacks); CheckDlgItem(hDlg, IDC_CHECKBOX_GAMEHACKS, CommonSettings.gamehacks.en);
CheckDlgItem(hDlg,IDC_USEEXTBIOS,CommonSettings.UseExtBIOS); CheckDlgItem(hDlg,IDC_USEEXTBIOS,CommonSettings.UseExtBIOS);
CheckDlgItem(hDlg, IDC_BIOSSWIS, CommonSettings.SWIFromBIOS); CheckDlgItem(hDlg, IDC_BIOSSWIS, CommonSettings.SWIFromBIOS);
CheckDlgItem(hDlg, IDC_PATCHSWI3, CommonSettings.PatchSWI3); CheckDlgItem(hDlg, IDC_PATCHSWI3, CommonSettings.PatchSWI3);
@ -6553,7 +6553,7 @@ LRESULT CALLBACK EmulationSettingsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, L
CommonSettings.DebugConsole = IsDlgCheckboxChecked(hDlg, IDC_CHECKBOX_DEBUGGERMODE); CommonSettings.DebugConsole = IsDlgCheckboxChecked(hDlg, IDC_CHECKBOX_DEBUGGERMODE);
CommonSettings.EnsataEmulation = IsDlgCheckboxChecked(hDlg, IDC_CHECKBOX_ENSATAEMULATION); CommonSettings.EnsataEmulation = IsDlgCheckboxChecked(hDlg, IDC_CHECKBOX_ENSATAEMULATION);
CommonSettings.advanced_timing = IsDlgCheckboxChecked(hDlg, IDC_CHECBOX_ADVANCEDTIMING); CommonSettings.advanced_timing = IsDlgCheckboxChecked(hDlg, IDC_CHECBOX_ADVANCEDTIMING);
CommonSettings.gamehacks = IsDlgCheckboxChecked(hDlg, IDC_CHECKBOX_GAMEHACKS); CommonSettings.gamehacks.en = IsDlgCheckboxChecked(hDlg, IDC_CHECKBOX_GAMEHACKS);
#ifdef HAVE_JIT #ifdef HAVE_JIT
CommonSettings.use_jit = IsDlgCheckboxChecked(hDlg, IDC_CHECKBOX_DYNAREC); CommonSettings.use_jit = IsDlgCheckboxChecked(hDlg, IDC_CHECKBOX_DYNAREC);
if (CommonSettings.use_jit) if (CommonSettings.use_jit)
@ -6566,7 +6566,7 @@ LRESULT CALLBACK EmulationSettingsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, L
WritePrivateProfileInt("Emulation", "DebugConsole", ((CommonSettings.DebugConsole == true) ? 1 : 0), IniName); WritePrivateProfileInt("Emulation", "DebugConsole", ((CommonSettings.DebugConsole == true) ? 1 : 0), IniName);
WritePrivateProfileInt("Emulation", "EnsataEmulation", ((CommonSettings.EnsataEmulation == true) ? 1 : 0), IniName); WritePrivateProfileInt("Emulation", "EnsataEmulation", ((CommonSettings.EnsataEmulation == true) ? 1 : 0), IniName);
WritePrivateProfileBool("Emulation", "AdvancedTiming", CommonSettings.advanced_timing, IniName); WritePrivateProfileBool("Emulation", "AdvancedTiming", CommonSettings.advanced_timing, IniName);
WritePrivateProfileBool("Emulation", "GameHacks", CommonSettings.gamehacks, IniName); WritePrivateProfileBool("Emulation", "GameHacks", CommonSettings.gamehacks.en, IniName);
WritePrivateProfileInt("BIOS", "UseExtBIOS", ((CommonSettings.UseExtBIOS == true) ? 1 : 0), IniName); WritePrivateProfileInt("BIOS", "UseExtBIOS", ((CommonSettings.UseExtBIOS == true) ? 1 : 0), IniName);
WritePrivateProfileString("BIOS", "ARM9BIOSFile", CommonSettings.ARM9BIOS, IniName); WritePrivateProfileString("BIOS", "ARM9BIOSFile", CommonSettings.ARM9BIOS, IniName);
WritePrivateProfileString("BIOS", "ARM7BIOSFile", CommonSettings.ARM7BIOS, IniName); WritePrivateProfileString("BIOS", "ARM7BIOSFile", CommonSettings.ARM7BIOS, IniName);