From 56b557727bf7a7e80059d9f3889154f199431a8f Mon Sep 17 00:00:00 2001 From: Justin Marshall Date: Fri, 5 Jun 2020 08:24:07 -0700 Subject: [PATCH] Ddraw::Unlock no longer calls present, Device_Present needs to be manually called. This helps performance and visuals. --- REDALERT/CONQUER.CPP | 4 ++++ REDALERT/FUNCTION.H | 1 + REDALERT/GOPTIONS.CPP | 1 + REDALERT/MENUS.CPP | 2 ++ REDALERT/MPLAYER.CPP | 2 ++ REDALERT/MSGBOX.CPP | 2 ++ REDALERT/NULLDLG.CPP | 1 + REDALERT/SCENARIO.CPP | 5 ++++- REDALERT/SCORE.CPP | 10 +++++----- REDALERT/SPECIAL.CPP | 2 ++ REDALERT/VQAMOVIE.CPP | 2 ++ REDALERT/WINSTUB.CPP | 4 +++- ddraw/ddrawwrapper/DirectDrawSurfaceWrapper.cpp | 17 ++++++++++++----- 13 files changed, 41 insertions(+), 12 deletions(-) diff --git a/REDALERT/CONQUER.CPP b/REDALERT/CONQUER.CPP index e4bed45..c3b299f 100644 --- a/REDALERT/CONQUER.CPP +++ b/REDALERT/CONQUER.CPP @@ -416,6 +416,8 @@ void Main_Game(int argc, char * argv[]) break; } } + + Device_Present(); } #endif @@ -502,6 +504,8 @@ void Main_Game(int argc, char * argv[]) } #endif //WIN32 #endif // !WOLAPI_INTEGRATION + + Device_Present(); } /* diff --git a/REDALERT/FUNCTION.H b/REDALERT/FUNCTION.H index 67086f5..01a52f8 100644 --- a/REDALERT/FUNCTION.H +++ b/REDALERT/FUNCTION.H @@ -1073,6 +1073,7 @@ template <>class DynamicVectorClass; extern DynamicVectorClass whatever; void WWSDL_ProcessEvents(KeyNumType& key, int& flags); +void Device_Present(void); /* ** Debug output. ST - 6/27/2019 10:00PM diff --git a/REDALERT/GOPTIONS.CPP b/REDALERT/GOPTIONS.CPP index 018593a..a43fe14 100644 --- a/REDALERT/GOPTIONS.CPP +++ b/REDALERT/GOPTIONS.CPP @@ -265,6 +265,7 @@ void GameOptionsClass::Process(void) bool process = true; pressed = false; while (process) { + Device_Present(); /* ** Invoke game callback. diff --git a/REDALERT/MENUS.CPP b/REDALERT/MENUS.CPP index ad5be42..a339111 100644 --- a/REDALERT/MENUS.CPP +++ b/REDALERT/MENUS.CPP @@ -1017,6 +1017,8 @@ int Main_Menu(unsigned long ) default: break; } + + Device_Present(); } Options.Set_Score_Volume(oldvolume, false); diff --git a/REDALERT/MPLAYER.CPP b/REDALERT/MPLAYER.CPP index 7593739..bbc8ab1 100644 --- a/REDALERT/MPLAYER.CPP +++ b/REDALERT/MPLAYER.CPP @@ -252,6 +252,8 @@ GameType Select_MPlayer_Game (void) process = true; pressed = false; while (process) { + Device_Present(); + #ifdef WIN32 /* ** If we have just received input focus again after running in the background then diff --git a/REDALERT/MSGBOX.CPP b/REDALERT/MSGBOX.CPP index 7f55a9e..7e6cbf1 100644 --- a/REDALERT/MSGBOX.CPP +++ b/REDALERT/MSGBOX.CPP @@ -254,6 +254,8 @@ int WWMessageBox::Process(const char * msg, const char * b1txt, const char * b2t pressed = false; while (process) { + Device_Present(); + #ifdef WIN32 /* ** If we have just received input focus again after running in the background then diff --git a/REDALERT/NULLDLG.CPP b/REDALERT/NULLDLG.CPP index 08f203a..5f50671 100644 --- a/REDALERT/NULLDLG.CPP +++ b/REDALERT/NULLDLG.CPP @@ -617,6 +617,7 @@ int Com_Scenario_Dialog(bool skirmish) oh_dear_its_a_label: while (process) { + Device_Present(); #if(SHOW_MONO) if (!skirmish) { NullModem.Mono_Debug_Print(0); diff --git a/REDALERT/SCENARIO.CPP b/REDALERT/SCENARIO.CPP index 1148f12..62018ab 100644 --- a/REDALERT/SCENARIO.CPP +++ b/REDALERT/SCENARIO.CPP @@ -898,10 +898,13 @@ void Do_Win(void) Fancy_Text_Print(TXT_HACKHACK, x, 110*RESFACTOR, &ColorRemaps[PCOLOR_RED], TBLACK, TPF_CENTER|TPF_VCR|TPF_USE_GRAD_PAL|TPF_DROPSHADOW); #endif CountDownTimer = TIMER_SECOND * 3; - while (Is_Speaking()) {}; + while (Is_Speaking()) { + Device_Present(); + }; Speak(VOX_ACCOMPLISHED); while (CountDownTimer || Is_Speaking()) { Call_Back(); + Device_Present(); } } diff --git a/REDALERT/SCORE.CPP b/REDALERT/SCORE.CPP index c2d474b..3d212bb 100644 --- a/REDALERT/SCORE.CPP +++ b/REDALERT/SCORE.CPP @@ -1705,8 +1705,8 @@ void Draw_Bar_Graphs(int i, int gkilled, int nkilled) *=========================================================================*/ void Call_Back_Delay(int time) { - time; -#if (0)//PG + Device_Present(); + if (time < 0 ) time = 0; if (time > 60) time = 60; CDTimerClass cd; @@ -1721,16 +1721,16 @@ void Call_Back_Delay(int time) if (ControlQ) time=0; cd = time; - StreamLowImpact = true; +// StreamLowImpact = true; do { if (callbackcd == 0) { Call_Back(); callbackcd = TIMER_SECOND/4; } Animate_Score_Objs(); + Device_Present(); } while (cd); - StreamLowImpact = false; -#endif + //StreamLowImpact = false; } diff --git a/REDALERT/SPECIAL.CPP b/REDALERT/SPECIAL.CPP index 42163b6..69f23f0 100644 --- a/REDALERT/SPECIAL.CPP +++ b/REDALERT/SPECIAL.CPP @@ -567,6 +567,8 @@ int Fetch_Difficulty(void) */ Call_Back(); + Device_Present(); + #ifdef WIN32 /* ** Handle possible surface loss due to a focus switch diff --git a/REDALERT/VQAMOVIE.CPP b/REDALERT/VQAMOVIE.CPP index b83f807..be52417 100644 --- a/REDALERT/VQAMOVIE.CPP +++ b/REDALERT/VQAMOVIE.CPP @@ -143,6 +143,8 @@ long VQA_Play(_VQAHandle* vqaHandle) { Buffer_To_Page(0, 0, ScreenWidth, ScreenHeight, vqa_output_buffer, *vqaHandle->video_graphics_buffer); vqaHandle->video_graphics_buffer->Unlock(); + + Device_Present(); if (clock() - curTime >= 30) { currentFrame++; diff --git a/REDALERT/WINSTUB.CPP b/REDALERT/WINSTUB.CPP index 619e703..72dcfdc 100644 --- a/REDALERT/WINSTUB.CPP +++ b/REDALERT/WINSTUB.CPP @@ -719,7 +719,7 @@ void WWSDL_ProcessEvents(KeyNumType& key, int& flags) { Keyboard->MouseQY = mousey; // if (flags == LEFTRELEASE || flags == RIGHTRELEASE) - // flags = 0; + // flags = 0; SDL_Event event; while (SDL_PollEvent(&event)) { @@ -749,6 +749,8 @@ void WWSDL_ProcessEvents(KeyNumType& key, int& flags) { break; } } + + Device_Present(); } diff --git a/ddraw/ddrawwrapper/DirectDrawSurfaceWrapper.cpp b/ddraw/ddrawwrapper/DirectDrawSurfaceWrapper.cpp index 2a67c23..836263f 100644 --- a/ddraw/ddrawwrapper/DirectDrawSurfaceWrapper.cpp +++ b/ddraw/ddrawwrapper/DirectDrawSurfaceWrapper.cpp @@ -1041,6 +1041,11 @@ HRESULT __stdcall IDirectDrawSurfaceWrapper::SetPalette(LPDIRECTDRAWPALETTE lpDD */ } +IDirectDrawWrapper* currentddrawParent = nullptr; +void Device_Present(void) { + currentddrawParent->Present(); +} + // Notifies DirectDraw that the direct surface manipulations are complete. HRESULT __stdcall IDirectDrawSurfaceWrapper::Unlock(LPVOID lpRect) { @@ -1094,12 +1099,14 @@ HRESULT __stdcall IDirectDrawSurfaceWrapper::Unlock(LPVOID lpRect) IDirectDrawSurface7::Lock and IDirectDrawSurface7::Unlock methods. */ + currentddrawParent = ddrawParent; + // Present the surface - if(!ddrawParent->Present()) - { - // Failed to presnt the surface, error reporting handled previously - return DDERR_GENERIC; - } + //if(!ddrawParent->Present()) + //{ + // // Failed to presnt the surface, error reporting handled previously + // return DDERR_GENERIC; + //} // Success return DD_OK;