From edeca6574daa792e02d7d02e22836ea0ad680fa6 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Sat, 1 Feb 2020 15:43:51 +0100 Subject: [PATCH] Replace tagRECT with SDL_Rect --- 3rdParty/Storm/Source/storm.h | 13 ------------ Source/dx.h | 2 +- Source/palette.cpp | 38 ++++++++++++++++++++--------------- Source/scrollrt.cpp | 22 ++++++++++++-------- SourceS/miniwin/misc.h | 9 --------- SourceX/dx.cpp | 20 ++++-------------- 6 files changed, 41 insertions(+), 63 deletions(-) diff --git a/3rdParty/Storm/Source/storm.h b/3rdParty/Storm/Source/storm.h index 3cb4d8c83..8c19c7023 100644 --- a/3rdParty/Storm/Source/storm.h +++ b/3rdParty/Storm/Source/storm.h @@ -487,12 +487,6 @@ BOOL STORMAPI SDlgSetControlBitmaps(HWND parentwindow, int *id, int a3, char *bu BOOL STORMAPI SDlgSetSystemCursor(void *lpSrcBuffer, void *p_a2, LPSIZE lpSize, LPCSTR lpCursorName); */ -BOOL STORMAPI SDlgBltToWindowI(HWND hWnd, HRGN a2, char *a3, int a4, void *buffer, RECT *rct, SIZE *size, int a8, int a9, DWORD rop); -BOOL STORMAPI SDlgBltToWindowE(HWND hWnd, HRGN a2, char *a3, int a4, void *buffer, RECT *rct, SIZE *size, int a8, int a9, DWORD rop); -BOOL STORMAPI SDlgSetBitmapE(HWND hWnd, int a2, char *src, int mask1, int flags, int a6, int a7, int width, int a9, int mask2); - -int STORMAPI Ordinal224(int a1); - BOOL STORMAPI SFileCloseArchive(HANDLE hArchive); BOOL STORMAPI SFileCloseFile(HANDLE hFile); @@ -560,8 +554,6 @@ BOOL STORMAPI SFileLoadFileEx(void *hArchive, char *filename, int a3, int a4, in //BOOL STORMAPI StormSetOption(int type, void *pValue, unsigned int size); BOOL STORMAPI SBltROP3(void *lpDstBuffer, void *lpSrcBuffer, int srcDrawWidth, int srcDrawHeight, int dstWidth, int srcWidth, int a7, DWORD rop); -BOOL STORMAPI SBltROP3Clipped(void *lpDstBuffer, RECT *lpDstRect, POINT *lpDstPt, int a4, void *lpSrcBuffer, RECT *lpSrcRect, POINT *lpSrcPt, int a8, int a9, DWORD rop); -BOOL STORMAPI SBltROP3Tiled(void *lpDstBuffer, RECT *lpDstRect, POINT *lpDstPt, int a4, void *lpSrcBuffer, RECT *lpSrcRect, POINT *lpSrcPt, int a8, int a9, DWORD rop); #define SBMP_DEFAULT 0 #define SBMP_BMP 1 @@ -707,9 +699,6 @@ SDrawGetScreenSize( DWORD *pdwBpp); -// undefined -BOOL STORMAPI SDrawLockSurface(int surfacenumber, RECT *lpDestRect, void **lplpSurface, int *lpPitch, int arg_unused); - /* SDrawPostClose @ 353 * * Posts a WM_QUIT message to the active drawing window specified @@ -725,7 +714,6 @@ SDrawPostClose(); // undefined //BOOL STORMAPI SDrawRealizePalette(); -BOOL STORMAPI SDrawUnlockSurface(int surfacenumber, void *lpSurface, int a3, RECT *lpRect); void SDrawUpdatePalette(unsigned int firstentry, unsigned int numentries, SDL_Color *pPalEntries, int a4); BOOL STORMAPI SEvtDispatch(DWORD dwMessageID, DWORD dwFlags, int type, PS_EVT pEvent); @@ -1158,7 +1146,6 @@ STORMAPI SStrUpper( char* string); -void STORMAPI SRgn523(HANDLE hRgn, RECT *pRect, int a3, int a4); void STORMAPI SRgnCreateRegion(HANDLE *hRgn, int a2); void STORMAPI SRgnDeleteRegion(HANDLE hRgn); diff --git a/Source/dx.h b/Source/dx.h index d51753283..3f74bee5a 100644 --- a/Source/dx.h +++ b/Source/dx.h @@ -14,7 +14,7 @@ void dx_cleanup(); void dx_reinit(); void CreatePalette(); -void BltFast(DWORD dwX, DWORD dwY, LPRECT lpSrcRect); +void BltFast(SDL_Rect *src_rect, SDL_Rect *dst_rect); void RenderPresent(); void PaletteGetEntries(DWORD dwNumEntries, SDL_Color *lpEntries); void PaletteSetEntries(DWORD dwCount, SDL_Color *lpEntries); diff --git a/Source/palette.cpp b/Source/palette.cpp index 1d8a267d1..9e491f2ab 100644 --- a/Source/palette.cpp +++ b/Source/palette.cpp @@ -156,24 +156,30 @@ int UpdateGamma(int gamma) void SetFadeLevel(DWORD fadeval) { int i; - RECT SrcRect; - if (1) { - for (i = 0; i < 255; i++) { - system_palette[i].r = (fadeval * logical_palette[i].r) >> 8; - system_palette[i].g = (fadeval * logical_palette[i].g) >> 8; - system_palette[i].b = (fadeval * logical_palette[i].b) >> 8; - } - palette_update(); - - // Workaround for flickering mouse in caves https://github.com/diasurgical/devilutionX/issues/7 - SrcRect.left = BORDER_LEFT; - SrcRect.top = BORDER_TOP; - SrcRect.right = BUFFER_WIDTH; - SrcRect.bottom = BUFFER_HEIGHT; // menu isn't offset so make sure we copy all of it - BltFast(0, 0, &SrcRect); - RenderPresent(); + for (i = 0; i < 255; i++) { + system_palette[i].r = (fadeval * logical_palette[i].r) >> 8; + system_palette[i].g = (fadeval * logical_palette[i].g) >> 8; + system_palette[i].b = (fadeval * logical_palette[i].b) >> 8; } + palette_update(); + + // Workaround for flickering mouse in caves https://github.com/diasurgical/devilutionX/issues/7 + SDL_Rect SrcRect = { + SCREEN_X, + SCREEN_Y, + SCREEN_WIDTH, + SCREEN_HEIGHT, + }; + SDL_Rect DstRect = { + 0, + 0, + SCREEN_WIDTH, + SCREEN_HEIGHT, + }; + + BltFast(&SrcRect, &DstRect); + RenderPresent(); } void BlackPalette() diff --git a/Source/scrollrt.cpp b/Source/scrollrt.cpp index fd6993664..5d639702e 100644 --- a/Source/scrollrt.cpp +++ b/Source/scrollrt.cpp @@ -1081,14 +1081,20 @@ static void DrawFPS() */ static void DoBlitScreen(DWORD dwX, DWORD dwY, DWORD dwWdt, DWORD dwHgt) { - RECT SrcRect; - - SrcRect.left = dwX + SCREEN_X; - SrcRect.top = dwY + SCREEN_Y; - SrcRect.right = SrcRect.left + dwWdt - 1; - SrcRect.bottom = SrcRect.top + dwHgt - 1; - - BltFast(dwX, dwY, &SrcRect); + SDL_Rect SrcRect = { + dwX + SCREEN_X, + dwY + SCREEN_Y, + dwWdt, + dwHgt, + }; + SDL_Rect DstRect = { + dwX, + dwY, + dwWdt, + dwHgt, + }; + + BltFast(&SrcRect, &DstRect); } /** diff --git a/SourceS/miniwin/misc.h b/SourceS/miniwin/misc.h index ce6f2b44f..56fe581d8 100644 --- a/SourceS/miniwin/misc.h +++ b/SourceS/miniwin/misc.h @@ -55,15 +55,6 @@ typedef struct _FILETIME { DWORD dwHighDateTime; } FILETIME, *LPFILETIME; -typedef struct tagRECT { - LONG left; - LONG top; - LONG right; - LONG bottom; -} RECT; - -typedef RECT *LPRECT; - typedef struct tagPOINT { LONG x; LONG y; diff --git a/SourceX/dx.cpp b/SourceX/dx.cpp index 625e7a62f..02876f044 100644 --- a/SourceX/dx.cpp +++ b/SourceX/dx.cpp @@ -171,32 +171,20 @@ void CreatePalette() } } -void BltFast(DWORD dwX, DWORD dwY, LPRECT lpSrcRect) +void BltFast(SDL_Rect *src_rect, SDL_Rect *dst_rect) { - auto w = static_cast(lpSrcRect->right - lpSrcRect->left + 1); - auto h = static_cast(lpSrcRect->bottom - lpSrcRect->top + 1); - SDL_Rect src_rect = { - static_cast(lpSrcRect->left), - static_cast(lpSrcRect->top), - w, h - }; - SDL_Rect dst_rect = { - static_cast(dwX), - static_cast(dwY), - w, h - }; if (OutputRequiresScaling()) { - ScaleOutputRect(&dst_rect); + ScaleOutputRect(dst_rect); // Convert from 8-bit to 32-bit SDL_Surface *tmp = SDL_ConvertSurface(pal_surface, GetOutputSurface()->format, 0); - if (SDL_BlitScaled(tmp, &src_rect, GetOutputSurface(), &dst_rect) <= -1) { + if (SDL_BlitScaled(tmp, src_rect, GetOutputSurface(), dst_rect) <= -1) { SDL_FreeSurface(tmp); ErrSdl(); } SDL_FreeSurface(tmp); } else { // Convert from 8-bit to 32-bit - if (SDL_BlitSurface(pal_surface, &src_rect, GetOutputSurface(), &dst_rect) <= -1) { + if (SDL_BlitSurface(pal_surface, src_rect, GetOutputSurface(), dst_rect) <= -1) { ErrSdl(); } }