From 71ba1194d17b2a72e3b4f0dbb8a62011952b7cf3 Mon Sep 17 00:00:00 2001 From: Mathieu Schroeter Date: Sun, 5 Feb 2017 10:48:20 +0100 Subject: [PATCH] Remove absolutly all ddraw stuff from pixmap --- blupi.cpp | 6 +-- decor.cpp | 5 +-- pixmap.cpp | 106 +++++++++++++++-------------------------------------- pixmap.h | 19 ++++------ 4 files changed, 41 insertions(+), 95 deletions(-) diff --git a/blupi.cpp b/blupi.cpp index 991be10..d8673bc 100644 --- a/blupi.cpp +++ b/blupi.cpp @@ -147,7 +147,7 @@ void UpdateFrame(void) rcRect.top = 0; rcRect.right = LXIMAGE; rcRect.bottom = LYIMAGE; - g_pPixmap->DrawImage(-1, CHBACK, rcRect, 1); // dessine le fond + g_pPixmap->DrawImage(-1, CHBACK, rcRect); // dessine le fond } if ( phase == WM_PHASE_INTRO1 || @@ -499,13 +499,11 @@ static bool DoInit(HINSTANCE hInstance, LPSTR lpCmdLine, int nCmdShow) if ( !g_pPixmap->Cache(CHGROUND, "image\\init.blp", totalDim, iconDim) ) return false; - g_pPixmap->SetDebug(false); - rcRect.left = 0; rcRect.top = 0; rcRect.right = LXIMAGE; rcRect.bottom = LYIMAGE; - g_pPixmap->DrawImage(-1, CHBACK, rcRect, 1); // dessine le fond + g_pPixmap->DrawImage(-1, CHBACK, rcRect); // dessine le fond g_pPixmap->Display(); totalDim.x = DIMCELX*2*16; diff --git a/decor.cpp b/decor.cpp index 747d118..9d97771 100644 --- a/decor.cpp +++ b/decor.cpp @@ -644,8 +644,7 @@ void CDecor::BuildMoveFloor(int x, int y, POINT pos, int rank) m_move[rank].channel, m_move[rank].icon, 0); - m_pPixmap->DrawIcon(-1, m_move[rank].channel, 0, - pos, 0, true); + m_pPixmap->DrawIcon(-1, m_move[rank].channel, 0, pos, true); } else { @@ -1032,7 +1031,7 @@ void CDecor::Build(RECT clip, POINT posMouse) } // Dessine tous les sols fixes. - m_pPixmap->DrawImage(-1, CHGROUND, clip, 1); + m_pPixmap->DrawImage(-1, CHGROUND, clip); width = clip.right-clip.left; height = clip.bottom-clip.top; diff --git a/pixmap.cpp b/pixmap.cpp index 5d67ee8..b9343be 100644 --- a/pixmap.cpp +++ b/pixmap.cpp @@ -5,14 +5,12 @@ #include #include #include -#include #include #include #include #include "def.h" #include "pixmap.h" #include "misc.h" -#include "ddutil.h" #include "blupi.h" @@ -42,10 +40,6 @@ CPixmap::CPixmap() m_lpSDLTexture[i] = NULL; } - // initialize special effects structure - ZeroMemory(&m_DDbltfx, sizeof(m_DDbltfx)); - m_DDbltfx.dwSize = sizeof(m_DDbltfx); - m_lpCurrentCursor = nullptr; } @@ -74,14 +68,6 @@ CPixmap::~CPixmap() } } - -void CPixmap::SetDebug(bool bDebug) -{ - m_bDebug = bDebug; - DDSetDebug(bDebug); -} - - // Crée l'objet DirectDraw principal. // Retourne false en cas d'erreur. @@ -117,15 +103,9 @@ void CPixmap::Fill(RECT rect, COLORREF color) // Effectue un appel BltFast. // Les modes sont 0=transparent, 1=opaque. -HRESULT CPixmap::BltFast(int chDst, int channel, - POINT dst, RECT rcRect, int mode) +int CPixmap::BltFast(int chDst, int channel, POINT dst, RECT rcRect) { - DWORD dwTrans; - HRESULT ddrval = DD_OK; - int limit; - - if ( mode == 0 ) dwTrans = DDBLTFAST_SRCCOLORKEY; - else dwTrans = DDBLTFAST_NOCOLORKEY; + int res, limit; // Effectue un peu de clipping. if ( dst.x < m_clipRect.left ) @@ -150,7 +130,8 @@ HRESULT CPixmap::BltFast(int chDst, int channel, } if ( rcRect.left >= rcRect.right || - rcRect.top >= rcRect.bottom ) return DD_OK; + rcRect.top >= rcRect.bottom ) + return 0; if ( chDst < 0 ) { @@ -163,7 +144,7 @@ HRESULT CPixmap::BltFast(int chDst, int channel, dstRect.x = dst.x; dstRect.y = dst.y; - SDL_RenderCopy (g_renderer, m_lpSDLTexture[channel], &srcRect, &dstRect); + res = SDL_RenderCopy (g_renderer, m_lpSDLTexture[channel], &srcRect, &dstRect); } else { @@ -177,24 +158,19 @@ HRESULT CPixmap::BltFast(int chDst, int channel, dstRect.y = dst.y; SDL_SetRenderTarget (g_renderer, m_lpSDLTexture[chDst]); - SDL_RenderCopy (g_renderer, m_lpSDLTexture[channel], &srcRect, &dstRect); + res = SDL_RenderCopy (g_renderer, m_lpSDLTexture[channel], &srcRect, &dstRect); SDL_SetRenderTarget (g_renderer, nullptr); } - return ddrval; + return res; } // Effectue un appel BltFast. // Les modes sont 0=transparent, 1=opaque. -HRESULT CPixmap::BltFast(SDL_Texture *lpSDL, - int channel, POINT dst, RECT rcRect, int mode) +int CPixmap::BltFast(SDL_Texture *lpSDL, int channel, POINT dst, RECT rcRect) { - DWORD dwTrans; - HRESULT ddrval = DD_OK; - - if ( mode == 0 ) dwTrans = DDBLTFAST_SRCCOLORKEY; - else dwTrans = DDBLTFAST_NOCOLORKEY; + int res; SDL_Rect srcRect, dstRect; srcRect.x = rcRect.left; @@ -206,10 +182,10 @@ HRESULT CPixmap::BltFast(SDL_Texture *lpSDL, dstRect.y = dst.y; SDL_SetRenderTarget (g_renderer, lpSDL); - SDL_RenderCopy (g_renderer, m_lpSDLTexture[channel], &srcRect, &dstRect); + res = SDL_RenderCopy (g_renderer, m_lpSDLTexture[channel], &srcRect, &dstRect); SDL_SetRenderTarget (g_renderer, nullptr); - return ddrval; + return res; } // Cache une image contenant des icônes. @@ -363,12 +339,10 @@ bool CPixmap::IsIconPixel(int channel, int rank, POINT pos) // Dessine une partie d'image rectangulaire. // Les modes sont 0=transparent, 1=opaque. -bool CPixmap::DrawIcon(int chDst, int channel, int rank, POINT pos, - int mode, bool bMask) +bool CPixmap::DrawIcon(int chDst, int channel, int rank, POINT pos, bool bMask) { int nbx, nby; RECT rect; - HRESULT ddrval; COLORREF oldColor1, oldColor2; if ( channel < 0 || channel >= MAXIMAGE ) return false; @@ -390,10 +364,7 @@ bool CPixmap::DrawIcon(int chDst, int channel, int rank, POINT pos, oldColor1 = m_colorSurface[2*channel+0]; oldColor2 = m_colorSurface[2*channel+1]; - ddrval = BltFast(chDst, channel, pos, rect, mode); - - if ( ddrval != DD_OK ) return false; - return true; + return !BltFast (chDst, channel, pos, rect); } // Dessine une partie d'image rectangulaire. @@ -406,12 +377,10 @@ bool CPixmap::DrawIcon(int chDst, int channel, int rank, POINT pos, // 32,32 34,33 // 33,48 35,49 -bool CPixmap::DrawIconDemi(int chDst, int channel, int rank, POINT pos, - int mode, bool bMask) +bool CPixmap::DrawIconDemi(int chDst, int channel, int rank, POINT pos, bool bMask) { int nbx, nby; RECT rect; - HRESULT ddrval; COLORREF oldColor1, oldColor2; if ( channel < 0 || channel >= MAXIMAGE ) return false; @@ -435,22 +404,16 @@ bool CPixmap::DrawIconDemi(int chDst, int channel, int rank, POINT pos, oldColor1 = m_colorSurface[2*channel+0]; oldColor2 = m_colorSurface[2*channel+1]; - ddrval = BltFast(chDst, channel, pos, rect, mode); - - if ( ddrval != DD_OK ) return false; - return true; + return !BltFast (chDst, channel, pos, rect); } // Dessine une partie d'image rectangulaire. -// Les modes sont 0=transparent, 1=opaque. bool CPixmap::DrawIconPart(int chDst, int channel, int rank, POINT pos, - int startY, int endY, - int mode, bool bMask) + int startY, int endY, bool bMask) { int nbx, nby; RECT rect; - HRESULT ddrval; COLORREF oldColor1, oldColor2; if ( channel < 0 || channel >= MAXIMAGE ) return false; @@ -475,19 +438,13 @@ bool CPixmap::DrawIconPart(int chDst, int channel, int rank, POINT pos, oldColor1 = m_colorSurface[2*channel+0]; oldColor2 = m_colorSurface[2*channel+1]; - ddrval = BltFast(chDst, channel, pos, rect, mode); - - if ( ddrval != DD_OK ) return false; - return true; + return !BltFast (chDst, channel, pos, rect); } // Dessine une partie d'image n'importe où. -// Les modes sont 0=transparent, 1=opaque. -bool CPixmap::DrawPart(int chDst, int channel, POINT dest, RECT rect, - int mode, bool bMask) +bool CPixmap::DrawPart(int chDst, int channel, POINT dest, RECT rect, bool bMask) { - HRESULT ddrval; COLORREF oldColor1, oldColor2; if ( channel < 0 || channel >= MAXIMAGE ) return false; @@ -496,19 +453,15 @@ bool CPixmap::DrawPart(int chDst, int channel, POINT dest, RECT rect, oldColor1 = m_colorSurface[2*channel+0]; oldColor2 = m_colorSurface[2*channel+1]; - ddrval = BltFast(chDst, channel, dest, rect, mode); - - if ( ddrval != DD_OK ) return false; - return true; + return !BltFast (chDst, channel, dest, rect); } // Dessine une partie d'image rectangulaire. -// Les modes sont 0=transparent, 1=opaque. -bool CPixmap::DrawImage(int chDst, int channel, RECT rect, int mode) +bool CPixmap::DrawImage(int chDst, int channel, RECT rect) { POINT dst; - HRESULT ddrval; + int res; if ( channel < 0 || channel >= MAXIMAGE ) return false; if (m_lpSDLTexture[channel] == NULL ) return false; @@ -516,9 +469,10 @@ bool CPixmap::DrawImage(int chDst, int channel, RECT rect, int mode) dst.x = rect.left; dst.y = rect.top; - ddrval = BltFast(chDst, channel, dst, rect, mode); + res = BltFast(chDst, channel, dst, rect); - if ( ddrval != DD_OK ) return false; + if (res) + return false; if ( channel == CHBACK ) { @@ -537,7 +491,7 @@ bool CPixmap::BuildIconMask(int channelMask, int rankMask, int nbx, nby; POINT posDst; RECT rect; - HRESULT ddrval; + int res; if ( channel < 0 || channel >= MAXIMAGE ) return false; if (m_lpSDLTexture[channel] == NULL ) return false; @@ -557,8 +511,9 @@ bool CPixmap::BuildIconMask(int channelMask, int rankMask, rect.bottom = rect.top + m_iconDim[channel].y; posDst.x = (rankDst%nbx)*m_iconDim[channel].x; posDst.y = (rankDst/nbx)*m_iconDim[channel].y; - ddrval = BltFast(m_lpSDLTexture[channel], channel, posDst, rect, 1); - if ( ddrval != DD_OK ) return false; + res = BltFast(m_lpSDLTexture[channel], channel, posDst, rect); + if (res) + return false; if ( m_iconDim[channelMask].x == 0 || m_iconDim[channelMask].y == 0 ) return false; @@ -572,10 +527,9 @@ bool CPixmap::BuildIconMask(int channelMask, int rankMask, rect.top = (rankMask/nbx)*m_iconDim[channelMask].y; rect.right = rect.left + m_iconDim[channelMask].x; rect.bottom = rect.top + m_iconDim[channelMask].y; - ddrval = BltFast(m_lpSDLTexture[channel], channelMask, posDst, rect, 0); - if ( ddrval != DD_OK ) return false; + res = BltFast(m_lpSDLTexture[channel], channelMask, posDst, rect); - return true; + return !res; } diff --git a/pixmap.h b/pixmap.h index 9caa2c8..f266424 100644 --- a/pixmap.h +++ b/pixmap.h @@ -2,7 +2,6 @@ #pragma once -#include #include ///////////////////////////////////////////////////////////////////////////// @@ -16,8 +15,6 @@ public: CPixmap(); ~CPixmap(); - void SetDebug(bool bDebug); - bool Create(POINT dim, bool bFullScreen, int mouseType); bool Flush(); void Fill(RECT rect, COLORREF color); @@ -30,11 +27,11 @@ public: bool IsIconPixel(int channel, int rank, POINT pos); - bool DrawIcon(int chDst, int channel, int rank, POINT pos, int mode=0, bool bMask=false); - bool DrawIconDemi(int chDst, int channel, int rank, POINT pos, int mode=0, bool bMask=false); - bool DrawIconPart(int chDst, int channel, int rank, POINT pos, int startY, int endY, int mode=0, bool bMask=false); - bool DrawPart(int chDst, int channel, POINT dest, RECT rect, int mode=0, bool bMask=false); - bool DrawImage(int chDst, int channel, RECT rect, int mode=0); + bool DrawIcon(int chDst, int channel, int rank, POINT pos, bool bMask=false); + bool DrawIconDemi(int chDst, int channel, int rank, POINT pos, bool bMask=false); + bool DrawIconPart(int chDst, int channel, int rank, POINT pos, int startY, int endY, bool bMask=false); + bool DrawPart(int chDst, int channel, POINT dest, RECT rect, bool bMask=false); + bool DrawImage(int chDst, int channel, RECT rect); bool BuildIconMask(int channelMask, int rankMask, int channel, int rankSrc, int rankDst); @@ -47,9 +44,8 @@ public: void ChangeSprite (MouseSprites sprite); protected: - HRESULT BltFast(int chDst, int channel, POINT dst, RECT rcRect, int mode); - HRESULT BltFast(SDL_Texture *lpSDL, - int channel, POINT dst, RECT rcRect, int mode); + int BltFast(int chDst, int channel, POINT dst, RECT rcRect); + int BltFast(SDL_Texture *lpSDL, int channel, POINT dst, RECT rcRect); RECT MouseRectSprite(); SDL_Point GetCursorHotSpot (int sprite); @@ -75,7 +71,6 @@ protected: char m_filename[MAXIMAGE][20]; POINT m_totalDim[MAXIMAGE]; // dimensions totale image POINT m_iconDim[MAXIMAGE]; // dimensions d'une icône - DDBLTFX m_DDbltfx; }; /////////////////////////////////////////////////////////////////////////////