diff --git a/desmume/src/NDSSystem.h b/desmume/src/NDSSystem.h index 2f334ab39..f5af5d497 100644 --- a/desmume/src/NDSSystem.h +++ b/desmume/src/NDSSystem.h @@ -511,6 +511,7 @@ extern struct TCommonSettings { , GFX3D_EdgeMark(true) , GFX3D_Fog(true) , GFX3D_Texture(true) + , GFX3D_Zelda_Shadow_Depth_Hack(0) , UseExtBIOS(false) , SWIFromBIOS(false) , PatchSWI3(false) @@ -548,6 +549,7 @@ extern struct TCommonSettings { bool GFX3D_EdgeMark; bool GFX3D_Fog; bool GFX3D_Texture; + int GFX3D_Zelda_Shadow_Depth_Hack; bool UseExtBIOS; char ARM9BIOS[256]; diff --git a/desmume/src/commandline.cpp b/desmume/src/commandline.cpp index fe17b4297..614719809 100644 --- a/desmume/src/commandline.cpp +++ b/desmume/src/commandline.cpp @@ -52,10 +52,12 @@ CommandLine::CommandLine() , _rigorous_timing(0) , _advanced_timing(-1) , _slot1(NULL) +, depth_threshold(-1) +, load_slot(-1) +, arm9_gdb_port(0) +, arm7_gdb_port(0) +, start_paused(FALSE) { - load_slot = -1; - arm9_gdb_port = arm7_gdb_port = 0; - start_paused = FALSE; #ifndef _MSC_VER disable_sound = 0; disable_limiter = 0; @@ -92,6 +94,7 @@ void CommandLine::loadCommonOptions() { "rigorous-timing", 0, 0, G_OPTION_ARG_INT, &_rigorous_timing, "Use some rigorous timings instead of unrealistically generous (default 0)", "RIGOROUS_TIMING"}, { "advanced-timing", 0, 0, G_OPTION_ARG_INT, &_advanced_timing, "Use advanced BUS-level timing (default 1)", "ADVANCED_TIMING"}, { "slot1", 0, 0, G_OPTION_ARG_STRING, &_slot1, "Device to load in slot 1 (default retail)", "SLOT1"}, + { "depth-threshold", 0, 0, G_OPTION_ARG_INT, &depth_threshold, "Depth comparison threshold (default 0)", "DEPTHTHRESHOLD"}, #ifndef _MSC_VER { "disable-sound", 0, 0, G_OPTION_ARG_NONE, &disable_sound, "Disables the sound emulation", NULL}, { "disable-limiter", 0, 0, G_OPTION_ARG_NONE, &disable_limiter, "Disables the 60fps limiter", NULL}, @@ -127,6 +130,8 @@ bool CommandLine::parse(int argc,char **argv) if(_num_cores != -1) CommonSettings.num_cores = _num_cores; if(_rigorous_timing) CommonSettings.rigorous_timing = true; if(_advanced_timing != -1) CommonSettings.advanced_timing = _advanced_timing==1; + if(depth_threshold != -1) + CommonSettings.GFX3D_Zelda_Shadow_Depth_Hack = depth_threshold; //TODO MAX PRIORITY! change ARM9BIOS etc to be a std::string if(_bios_arm9) { CommonSettings.UseExtBIOS = true; strcpy(CommonSettings.ARM9BIOS,_bios_arm9); } diff --git a/desmume/src/commandline.h b/desmume/src/commandline.h index ef12a2f76..fbd8c5346 100644 --- a/desmume/src/commandline.h +++ b/desmume/src/commandline.h @@ -40,6 +40,7 @@ class CommandLine public: //actual options: these may move to another sturct int load_slot; + int depth_threshold; std::string nds_file; std::string play_movie_file; std::string record_movie_file; diff --git a/desmume/src/rasterize.cpp b/desmume/src/rasterize.cpp index a9df8d316..dcadc9c63 100644 --- a/desmume/src/rasterize.cpp +++ b/desmume/src/rasterize.cpp @@ -546,10 +546,23 @@ public: if(polyAttr.decalMode) { - if(depth != destFragment.depth) + if ( CommonSettings.GFX3D_Zelda_Shadow_Depth_Hack > 0) { - goto depth_fail; + if(depthdestFragment.depth + CommonSettings.GFX3D_Zelda_Shadow_Depth_Hack) + { + goto depth_fail; + } + } + else + { + if(depth != destFragment.depth) + { + goto depth_fail; + } + } + } else { diff --git a/desmume/src/windows/main.cpp b/desmume/src/windows/main.cpp index bb47b8922..44cd5eebf 100644 --- a/desmume/src/windows/main.cpp +++ b/desmume/src/windows/main.cpp @@ -2582,7 +2582,9 @@ int _main() CommonSettings.showGpu.sub = GetPrivateProfileInt("Display", "SubGpu", 1, IniName) != 0; CommonSettings.spu_advanced = GetPrivateProfileBool("Sound", "SpuAdvanced", false, IniName); CommonSettings.advanced_timing = GetPrivateProfileBool("Emulation", "AdvancedTiming", true, IniName); - + + CommonSettings.GFX3D_Zelda_Shadow_Depth_Hack = GetPrivateProfileInt("3D", "ZeldaShadowDepthHack", 0, IniName); + lostFocusPause = GetPrivateProfileBool("Focus", "BackgroundPause", false, IniName); //Get Ram-Watch values @@ -5491,6 +5493,7 @@ LRESULT CALLBACK GFX3DSettingsDlgProc(HWND hw, UINT msg, WPARAM wp, LPARAM lp) CheckDlgButton(hw,IDC_3DSETTINGS_EDGEMARK,CommonSettings.GFX3D_EdgeMark); CheckDlgButton(hw,IDC_3DSETTINGS_FOG,CommonSettings.GFX3D_Fog); CheckDlgButton(hw,IDC_3DSETTINGS_TEXTURE,CommonSettings.GFX3D_Texture); + SetDlgItemInt (hw,IDC_ZELDA_SHADOW_DEPTH_HACK,CommonSettings.GFX3D_Zelda_Shadow_Depth_Hack,FALSE); //CheckDlgButton(hw,IDC_ALTERNATEFLUSH,CommonSettings.gfx3d_flushMode); for(i = 0; core3DList[i] != NULL; i++) @@ -5511,11 +5514,14 @@ LRESULT CALLBACK GFX3DSettingsDlgProc(HWND hw, UINT msg, WPARAM wp, LPARAM lp) CommonSettings.GFX3D_EdgeMark = IsDlgCheckboxChecked(hw,IDC_3DSETTINGS_EDGEMARK); CommonSettings.GFX3D_Fog = IsDlgCheckboxChecked(hw,IDC_3DSETTINGS_FOG); CommonSettings.GFX3D_Texture = IsDlgCheckboxChecked(hw,IDC_3DSETTINGS_TEXTURE); + CommonSettings.GFX3D_Zelda_Shadow_Depth_Hack = GetDlgItemInt(hw,IDC_ZELDA_SHADOW_DEPTH_HACK,NULL,FALSE); + Change3DCoreWithFallbackAndSave(ComboBox_GetCurSel(GetDlgItem(hw, IDC_3DCORE))); WritePrivateProfileBool("3D", "HighResolutionInterpolateColor", CommonSettings.GFX3D_HighResolutionInterpolateColor, IniName); WritePrivateProfileBool("3D", "EnableEdgeMark", CommonSettings.GFX3D_EdgeMark, IniName); WritePrivateProfileBool("3D", "EnableFog", CommonSettings.GFX3D_Fog, IniName); WritePrivateProfileBool("3D", "EnableTexture", CommonSettings.GFX3D_Texture, IniName); + WritePrivateProfileInt ("3D", "ZeldaShadowDepthHack", CommonSettings.GFX3D_Zelda_Shadow_Depth_Hack, IniName); //CommonSettings.gfx3d_flushMode = (IsDlgButtonChecked(hw,IDC_ALTERNATEFLUSH) == BST_CHECKED)?1:0; //WritePrivateProfileInt("3D", "AlternateFlush", CommonSettings.gfx3d_flushMode, IniName); } diff --git a/desmume/src/windows/resource.h b/desmume/src/windows/resource.h index 13edb008b..4750171b7 100644 --- a/desmume/src/windows/resource.h +++ b/desmume/src/windows/resource.h @@ -779,6 +779,12 @@ #define IDC_USENOISE 5010 #define IDC_CPU 6000 #define IDC_IOREG 6001 + +//ZELDA SHADOW HACK +#define ID_LABEL_ZELDA_SHADOW_DEPTH_HACK 9000 +#define IDC_ZELDA_SHADOW_DEPTH_HACK 9001 + + #define IDD_CHEAT_ADD_XX_CODE 10005 #define IDD_GBASLOT_GUITARGRIP 10009 #define IDD_GBASLOT_PIANO 10010 diff --git a/desmume/src/windows/resources.rc b/desmume/src/windows/resources.rc index b19134ad2..a84c6b129 100644 Binary files a/desmume/src/windows/resources.rc and b/desmume/src/windows/resources.rc differ