From 133b9866b65b541fa5f223a4e1a337f461f4a6bc Mon Sep 17 00:00:00 2001 From: zeromus Date: Tue, 19 May 2009 03:26:15 +0000 Subject: [PATCH] gfx3d: make 'alternate flush mode' emulation option. this option toggles between two methods, neither of which is entirely accurate such that under one of the modes, certain games are unplayable. if a game is fixed by alternate flush mode, please report it in the bug tracker under that category for data collecting purposes. also hooked up this option in windows. --- desmume/src/NDSSystem.h | 4 ++++ desmume/src/gfx3d.cpp | 8 ++++++-- desmume/src/windows/main.cpp | 6 ++++++ desmume/src/windows/resource.h | 1 + desmume/src/windows/resources.rc | 11 +++++++---- 5 files changed, 24 insertions(+), 6 deletions(-) diff --git a/desmume/src/NDSSystem.h b/desmume/src/NDSSystem.h index b6faf316f..038134840 100644 --- a/desmume/src/NDSSystem.h +++ b/desmume/src/NDSSystem.h @@ -357,6 +357,7 @@ extern struct TCommonSettings { , wifiBridgeAdapterNum(0) , spuInterpolationMode(SPUInterpolation_Linear) , spuAdpcmCache(false) + , gfx3d_flushMode(0) { strcpy(ARM9BIOS, "biosnds9.bin"); strcpy(ARM7BIOS, "biosnds7.bin"); @@ -376,6 +377,9 @@ extern struct TCommonSettings { bool DebugConsole; int wifiBridgeAdapterNum; + + //this is a temporary hack until we straighten out the flushing logic and/or gxfifo + int gfx3d_flushMode; SPUInterpolationMode spuInterpolationMode; bool spuAdpcmCache; diff --git a/desmume/src/gfx3d.cpp b/desmume/src/gfx3d.cpp index 685767ba4..8f731c080 100644 --- a/desmume/src/gfx3d.cpp +++ b/desmume/src/gfx3d.cpp @@ -39,6 +39,7 @@ #include "mem.h" #include "types.h" #include "saves.h" +#include "NDSSystem.h" #include "readwrite.h" #include "FIFO.h" @@ -1397,8 +1398,10 @@ void gfx3d_glFlush(u32 v) flushPending = TRUE; gfx3d.sortmode = BIT0(v); gfx3d.wbuffer = BIT1(v); + //see discussion at top of file - gfx3d_doFlush(); + if(CommonSettings.gfx3d_flushMode == 0) + gfx3d_doFlush(); } static int _CDECL_ gfx3d_ysort_compare_old_qsort(const void * elem1, const void * elem2) @@ -1516,7 +1519,8 @@ void gfx3d_VBlankSignal() } //see discussion at top of file - //gfx3d_doFlush(); + if(CommonSettings.gfx3d_flushMode == 1) + gfx3d_doFlush(); } void gfx3d_VBlankEndSignal(bool skipFrame) diff --git a/desmume/src/windows/main.cpp b/desmume/src/windows/main.cpp index b17cb45a6..e173be9bf 100644 --- a/desmume/src/windows/main.cpp +++ b/desmume/src/windows/main.cpp @@ -1829,6 +1829,7 @@ int WINAPI WinMain (HINSTANCE hThisInstance, cur3DCore = GetPrivateProfileInt("3D", "Renderer", GPU3D_OPENGL, IniName); CommonSettings.HighResolutionInterpolateColor = GetPrivateProfileInt("3D", "HighResolutionInterpolateColor", 1, IniName); + CommonSettings.gfx3d_flushMode = GetPrivateProfileInt("3D", "AlternateFlush", 0, IniName); NDS_3D_ChangeCore(cur3DCore); #ifdef BETA_VERSION @@ -3589,6 +3590,7 @@ LRESULT CALLBACK GFX3DSettingsDlgProc(HWND hw, UINT msg, WPARAM wp, LPARAM lp) int i; CheckDlgButton(hw,IDC_INTERPOLATECOLOR,CommonSettings.HighResolutionInterpolateColor?1:0); + CheckDlgButton(hw,IDC_ALTERNATEFLUSH,CommonSettings.gfx3d_flushMode); for(i = 0; core3DList[i] != NULL; i++) { @@ -3608,6 +3610,8 @@ LRESULT CALLBACK GFX3DSettingsDlgProc(HWND hw, UINT msg, WPARAM wp, LPARAM lp) NDS_3D_ChangeCore(ComboBox_GetCurSel(GetDlgItem(hw, IDC_3DCORE))); WritePrivateProfileInt("3D", "Renderer", cur3DCore, IniName); WritePrivateProfileInt("3D", "HighResolutionInterpolateColor", CommonSettings.HighResolutionInterpolateColor?1:0, IniName); + CommonSettings.gfx3d_flushMode = (IsDlgButtonChecked(hw,IDC_ALTERNATEFLUSH) == BST_CHECKED)?1:0; + WritePrivateProfileInt("3D", "AlternateFlush", CommonSettings.gfx3d_flushMode, IniName); } case IDCANCEL: { @@ -3620,6 +3624,8 @@ LRESULT CALLBACK GFX3DSettingsDlgProc(HWND hw, UINT msg, WPARAM wp, LPARAM lp) NDS_3D_ChangeCore(GPU3D_OPENGL); ComboBox_SetCurSel(GetDlgItem(hw, IDC_3DCORE), GPU3D_OPENGL); WritePrivateProfileInt("3D", "Renderer", GPU3D_OPENGL, IniName); + CommonSettings.gfx3d_flushMode = 0; + WritePrivateProfileInt("3D", "AlternateFlush", CommonSettings.gfx3d_flushMode, IniName); } return TRUE; } diff --git a/desmume/src/windows/resource.h b/desmume/src/windows/resource.h index bf5ae8918..7f1b72e7f 100644 --- a/desmume/src/windows/resource.h +++ b/desmume/src/windows/resource.h @@ -225,6 +225,7 @@ #define IDC_SOUNDCORECB 1000 #define IDC_USEEXTBIOS 1000 #define ID_BROWSE 1000 +#define IDC_ALTERNATEFLUSH 1001 #define IDC_BGMAP_BGXCNT 1001 #define IDC_CHECKBOX_DEBUGGERMODE 1001 #define IDC_EDIT01 1001 diff --git a/desmume/src/windows/resources.rc b/desmume/src/windows/resources.rc index 787ab735b..bb207a83e 100644 --- a/desmume/src/windows/resources.rc +++ b/desmume/src/windows/resources.rc @@ -638,19 +638,22 @@ FONT 8, "MS Sans Serif" + LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -IDD_3DSETTINGS DIALOGEX 0, 0, 174, 120 +IDD_3DSETTINGS DIALOGEX 0, 0, 174, 136 STYLE DS_MODALFRAME | DS_SETFONT | WS_BORDER | WS_CAPTION | WS_DLGFRAME | WS_POPUP | WS_SYSMENU CAPTION "3D settings" FONT 8, "MS Sans Serif", 0, 0, 0 { - DEFPUSHBUTTON "OK", IDOK, 62, 92, 50, 14, BS_DEFPUSHBUTTON - PUSHBUTTON "Cancel", IDCANCEL, 117, 92, 50, 14, BS_PUSHBUTTON - PUSHBUTTON "Default", IDC_DEFAULT, 7, 92, 50, 14, BS_PUSHBUTTON + DEFPUSHBUTTON "OK", IDOK, 62, 111, 50, 14, BS_DEFPUSHBUTTON + PUSHBUTTON "Cancel", IDCANCEL, 117, 111, 50, 14, BS_PUSHBUTTON + PUSHBUTTON "Default", IDC_DEFAULT, 7, 111, 50, 14, BS_PUSHBUTTON GROUPBOX "Renderer:", IDC_STATIC, 7, 7, 160, 39 COMBOBOX IDC_3DCORE, 15, 23, 146, 138, WS_TABSTOP | WS_VSCROLL | WS_TABSTOP | CBS_DROPDOWNLIST AUTOCHECKBOX "Unrealistically High-Precision Color Interpolation", IDC_INTERPOLATECOLOR, 9, 55, 165, 10, BS_AUTOCHECKBOX LTEXT "(Presently only effective for SoftRasterizer)", IDC_STATIC, 21, 65, 134, 8, SS_LEFT + AUTOCHECKBOX "Alternate Flush Mode", IDC_ALTERNATEFLUSH, 9, 79, 83, 10, BS_AUTOCHECKBOX + LTEXT "(Fixes some games with flickering graphics)", IDC_STATIC, 21, 89, 136, 8, SS_LEFT }