From ca0242bafe91ffe49580a24059c5f0296de537d2 Mon Sep 17 00:00:00 2001 From: Mathieu Schroeter Date: Sun, 5 Feb 2017 09:57:43 +0100 Subject: [PATCH] Remove more ddraw palette stuff --- blupi.cpp | 32 ++++++++++++++++---------------- decor.cpp | 6 +++--- event.cpp | 2 +- pixmap.cpp | 41 +++-------------------------------------- pixmap.h | 7 ++----- 5 files changed, 25 insertions(+), 63 deletions(-) diff --git a/blupi.cpp b/blupi.cpp index 218cdad..816f071 100644 --- a/blupi.cpp +++ b/blupi.cpp @@ -334,7 +334,7 @@ void WindowProc2 (const SDL_Event &event) totalDim.y = 66; iconDim.x = 64; iconDim.y = 66 / 2; - g_pPixmap->Cache (CHHILI, "image\\hili.blp", totalDim, iconDim, true); + g_pPixmap->Cache (CHHILI, "image\\hili.blp", totalDim, iconDim); g_pPixmap->SetTransparent (CHHILI, RGB (0, 0, 255)); // bleu } SDL_SetWindowTitle (g_window, "Blupi"); @@ -486,9 +486,9 @@ static bool DoInit(HINSTANCE hInstance, LPSTR lpCmdLine, int nCmdShow) iconDim.x = 0; iconDim.y = 0; #if _INTRO - if ( !g_pPixmap->Cache(CHBACK, "image\\intro1.blp", totalDim, iconDim, true) ) + if ( !g_pPixmap->Cache(CHBACK, "image\\intro1.blp", totalDim, iconDim) ) #else - if ( !g_pPixmap->Cache(CHBACK, "image\\init.blp", totalDim, iconDim, true) ) + if ( !g_pPixmap->Cache(CHBACK, "image\\init.blp", totalDim, iconDim) ) #endif return false; @@ -497,7 +497,7 @@ static bool DoInit(HINSTANCE hInstance, LPSTR lpCmdLine, int nCmdShow) totalDim.y = LYIMAGE; iconDim.x = 0; iconDim.y = 0; - if ( !g_pPixmap->Cache(CHGROUND, "image\\init.blp", totalDim, iconDim, true) ) + if ( !g_pPixmap->Cache(CHGROUND, "image\\init.blp", totalDim, iconDim) ) return false; g_pPixmap->SetDebug(false); @@ -513,7 +513,7 @@ static bool DoInit(HINSTANCE hInstance, LPSTR lpCmdLine, int nCmdShow) totalDim.y = DIMCELY*2*6; iconDim.x = DIMCELX*2; iconDim.y = DIMCELY*2; - if ( !g_pPixmap->Cache(CHFLOOR, "image\\floor000.blp", totalDim, iconDim, false) ) + if ( !g_pPixmap->Cache(CHFLOOR, "image\\floor000.blp", totalDim, iconDim) ) return InitFail("Cache floor000.blp", true); g_pPixmap->SetTransparent(CHFLOOR, RGB(0,0,255)); // bleu @@ -521,11 +521,11 @@ static bool DoInit(HINSTANCE hInstance, LPSTR lpCmdLine, int nCmdShow) totalDim.y = DIMOBJY*8; iconDim.x = DIMOBJX; iconDim.y = DIMOBJY; - if ( !g_pPixmap->Cache(CHOBJECT, "image\\obj000.blp", totalDim, iconDim, false) ) + if ( !g_pPixmap->Cache(CHOBJECT, "image\\obj000.blp", totalDim, iconDim) ) return InitFail("Cache obj000.blp", true); g_pPixmap->SetTransparent(CHOBJECT, RGB(0,0,255)); // bleu - if ( !g_pPixmap->Cache(CHOBJECTo, "image\\obj-o000.blp", totalDim, iconDim, false) ) + if ( !g_pPixmap->Cache(CHOBJECTo, "image\\obj-o000.blp", totalDim, iconDim) ) return InitFail("Cache obj-o000.blp", true); g_pPixmap->SetTransparent(CHOBJECTo, RGB(255,255,255)); // blanc @@ -533,7 +533,7 @@ static bool DoInit(HINSTANCE hInstance, LPSTR lpCmdLine, int nCmdShow) totalDim.y = DIMBLUPIY*23; iconDim.x = DIMBLUPIX; iconDim.y = DIMBLUPIY; - if ( !g_pPixmap->Cache(CHBLUPI, "image\\blupi.blp", totalDim, iconDim, false) ) + if ( !g_pPixmap->Cache(CHBLUPI, "image\\blupi.blp", totalDim, iconDim) ) return InitFail("Cache blupi.blp", true); g_pPixmap->SetTransparent(CHBLUPI, RGB(0,0,255)); // bleu @@ -541,7 +541,7 @@ static bool DoInit(HINSTANCE hInstance, LPSTR lpCmdLine, int nCmdShow) totalDim.y = 66; iconDim.x = 64; iconDim.y = 66/2; - if ( !g_pPixmap->Cache(CHHILI, "image\\hili.blp", totalDim, iconDim, false) ) + if ( !g_pPixmap->Cache(CHHILI, "image\\hili.blp", totalDim, iconDim) ) return InitFail("Cache hili.blp", true); g_pPixmap->SetTransparent(CHHILI, RGB(0,0,255)); // bleu @@ -549,7 +549,7 @@ static bool DoInit(HINSTANCE hInstance, LPSTR lpCmdLine, int nCmdShow) totalDim.y = DIMCELY*2*5; iconDim.x = DIMCELX*2; iconDim.y = DIMCELY*2; - if ( !g_pPixmap->Cache(CHFOG, "image\\fog.blp", totalDim, iconDim, false) ) + if ( !g_pPixmap->Cache(CHFOG, "image\\fog.blp", totalDim, iconDim) ) return InitFail("Cache fog.blp", true); g_pPixmap->SetTransparent(CHFOG, RGB(255,255,255)); // blanc @@ -557,7 +557,7 @@ static bool DoInit(HINSTANCE hInstance, LPSTR lpCmdLine, int nCmdShow) totalDim.y = DIMCELY*2*1; iconDim.x = DIMCELX*2; iconDim.y = DIMCELY*2; - if ( !g_pPixmap->Cache(CHMASK1, "image\\mask1.blp", totalDim, iconDim, false) ) + if ( !g_pPixmap->Cache(CHMASK1, "image\\mask1.blp", totalDim, iconDim) ) return InitFail("Cache mask1.blp", true); g_pPixmap->SetTransparent(CHMASK1, RGB(0,0,0)); // noir @@ -565,7 +565,7 @@ static bool DoInit(HINSTANCE hInstance, LPSTR lpCmdLine, int nCmdShow) totalDim.y = DIMBUTTONY*21; iconDim.x = DIMBUTTONX; iconDim.y = DIMBUTTONY; - if ( !g_pPixmap->Cache(CHBUTTON, "image\\button00.blp", totalDim, iconDim, false) ) + if ( !g_pPixmap->Cache(CHBUTTON, "image\\button00.blp", totalDim, iconDim) ) return InitFail("Cache button00.blp", true); g_pPixmap->SetTransparent(CHBUTTON, RGB(0,0,255)); // bleu @@ -573,7 +573,7 @@ static bool DoInit(HINSTANCE hInstance, LPSTR lpCmdLine, int nCmdShow) totalDim.y = DIMJAUGEY*4; iconDim.x = DIMJAUGEX; iconDim.y = DIMJAUGEY; - if ( !g_pPixmap->Cache(CHJAUGE, "image\\jauge.blp", totalDim, iconDim, false) ) + if ( !g_pPixmap->Cache(CHJAUGE, "image\\jauge.blp", totalDim, iconDim) ) return InitFail("Cache jauge.blp", true); g_pPixmap->SetTransparent(CHJAUGE, RGB(0,0,255)); // bleu @@ -581,7 +581,7 @@ static bool DoInit(HINSTANCE hInstance, LPSTR lpCmdLine, int nCmdShow) totalDim.y = DIMTEXTY*8*3; iconDim.x = DIMTEXTX; iconDim.y = DIMTEXTY; - if ( !g_pPixmap->Cache(CHTEXT, "image\\text.blp", totalDim, iconDim, false) ) + if ( !g_pPixmap->Cache(CHTEXT, "image\\text.blp", totalDim, iconDim) ) return InitFail("Cache text.blp", true); g_pPixmap->SetTransparent(CHTEXT, RGB(0,0,255)); // bleu @@ -589,7 +589,7 @@ static bool DoInit(HINSTANCE hInstance, LPSTR lpCmdLine, int nCmdShow) totalDim.y = DIMLITTLEY*8; iconDim.x = DIMLITTLEX; iconDim.y = DIMLITTLEY; - if ( !g_pPixmap->Cache(CHLITTLE, "image\\little.blp", totalDim, iconDim, false) ) + if ( !g_pPixmap->Cache(CHLITTLE, "image\\little.blp", totalDim, iconDim) ) return InitFail("Cache little.blp", true); g_pPixmap->SetTransparent(CHLITTLE, RGB(0,0,255)); // bleu @@ -597,7 +597,7 @@ static bool DoInit(HINSTANCE hInstance, LPSTR lpCmdLine, int nCmdShow) totalDim.y = 52; iconDim.x = 426; iconDim.y = 52; - if ( !g_pPixmap->Cache(CHBIGNUM, "image\\bignum.blp", totalDim, iconDim, false) ) + if ( !g_pPixmap->Cache(CHBIGNUM, "image\\bignum.blp", totalDim, iconDim) ) return InitFail("Cache bignum.blp", true); g_pPixmap->SetTransparent(CHBIGNUM, RGB(0,0,255)); // bleu diff --git a/decor.cpp b/decor.cpp index 83d7471..91daeba 100644 --- a/decor.cpp +++ b/decor.cpp @@ -224,7 +224,7 @@ bool CDecor::LoadImages() iconDim.x = DIMCELX*2; iconDim.y = DIMCELY*2; sprintf(filename, "image\\floor%.3d.blp", m_region); - if ( !m_pPixmap->Cache(CHFLOOR, filename, totalDim, iconDim, false) ) + if ( !m_pPixmap->Cache(CHFLOOR, filename, totalDim, iconDim) ) return false; m_pPixmap->SetTransparent(CHFLOOR, RGB(0,0,255)); // bleu @@ -233,12 +233,12 @@ bool CDecor::LoadImages() iconDim.x = DIMOBJX; iconDim.y = DIMOBJY; sprintf(filename, "image\\obj%.3d.blp", m_region); - if ( !m_pPixmap->Cache(CHOBJECT, filename, totalDim, iconDim, false) ) + if ( !m_pPixmap->Cache(CHOBJECT, filename, totalDim, iconDim) ) return false; m_pPixmap->SetTransparent(CHOBJECT, RGB(0,0,255)); // bleu sprintf(filename, "image\\obj-o%.3d.blp", m_region); - if ( !m_pPixmap->Cache(CHOBJECTo, filename, totalDim, iconDim, false) ) + if ( !m_pPixmap->Cache(CHOBJECTo, filename, totalDim, iconDim) ) return false; m_pPixmap->SetTransparent(CHOBJECTo, RGB(255,255,255)); // blanc diff --git a/event.cpp b/event.cpp index e484824..103e002 100644 --- a/event.cpp +++ b/event.cpp @@ -2858,7 +2858,7 @@ bool CEvent::ChangePhase(UINT phase) totalDim.y = LYIMAGE; iconDim.x = 0; iconDim.y = 0; - if ( !m_pPixmap->Cache(CHBACK, filename, totalDim, iconDim, false) ) + if ( !m_pPixmap->Cache(CHBACK, filename, totalDim, iconDim) ) { WaitMouse(false); // enlève le sablier m_tryInsertCount = 40; diff --git a/pixmap.cpp b/pixmap.cpp index b646e68..37b50de 100644 --- a/pixmap.cpp +++ b/pixmap.cpp @@ -38,7 +38,6 @@ CPixmap::CPixmap() m_lpDDSPrimary = NULL; m_lpDDSBack = NULL; m_lpDDSMouse = NULL; - m_lpDDPal = NULL; for ( i=0 ; iRelease(); - m_lpDDPal = NULL; - } - for ( i=0 ; i= MAXIMAGE ) return false; - // Create and set the palette. - if ( bUsePalette ) - { - if ( m_bDebug ) OutputDebug("Use palette\n"); - if ( m_lpDDPal != NULL ) - { - if ( m_bDebug ) OutputDebug("Release palette\n"); - m_lpDDPal->Release(); - m_lpDDPal = NULL; - } - - m_lpDDPal = DDLoadPalette(m_lpDD, pFilename); - - if ( m_lpDDPal ) - { - if ( m_bDebug ) OutputDebug("Set palette\n"); - m_lpDDSPrimary->SetPalette(NULL); // indispensable ! - ddrval = m_lpDDSPrimary->SetPalette(m_lpDDPal); - if ( ddrval != DD_OK ) - { - TraceErrorDD(ddrval, pFilename, 1); - } - } - } - std::string file = pFilename; if (_access ((file + ".bmp").c_str (), 0 /* F_OK */) != -1) file += ".bmp"; @@ -350,7 +315,7 @@ bool CPixmap::Cache(int channel, char *pFilename, POINT totalDim, POINT iconDim, // Cache une image globale. -bool CPixmap::Cache(int channel, char *pFilename, POINT totalDim, bool bUsePalette) +bool CPixmap::Cache(int channel, char *pFilename, POINT totalDim) { POINT iconDim; @@ -359,7 +324,7 @@ bool CPixmap::Cache(int channel, char *pFilename, POINT totalDim, bool bUsePalet iconDim.x = 0; iconDim.y = 0; - return Cache(channel, pFilename, totalDim, iconDim, bUsePalette); + return Cache(channel, pFilename, totalDim, iconDim); } // Cache une image provenant d'un bitmap. diff --git a/pixmap.h b/pixmap.h index 7f8c15e..055cb2b 100644 --- a/pixmap.h +++ b/pixmap.h @@ -22,8 +22,8 @@ public: bool Flush(); void Fill(RECT rect, COLORREF color); - bool Cache(int channel, char *pFilename, POINT totalDim, POINT iconDim, bool bUsePalette); - bool Cache(int channel, char *pFilename, POINT totalDim, bool bUsePalette); + bool Cache(int channel, char *pFilename, POINT totalDim, POINT iconDim); + bool Cache(int channel, char *pFilename, POINT totalDim); bool Cache(int channel, SDL_Surface *surface, POINT totalDim); void SetTransparent(int channel, COLORREF color); void SetTransparent2(int channel, COLORREF color1, COLORREF color2); @@ -77,11 +77,8 @@ protected: SDL_Cursor * m_lpCurrentCursor; SDL_Cursor * m_lpSDLCursors[MAXCURSORS]; SDL_Surface * m_lpSDLBlupi; - LPDIRECTDRAWPALETTE m_lpDDPal; // the primary surface palette SDL_Surface * m_lpSDLSurface[MAXIMAGE]; SDL_Texture * m_lpSDLTexture[MAXIMAGE]; - PALETTEENTRY m_pal[256]; // sauvegarde palette - PALETTEENTRY m_sysPal[256]; // sauvegarde palette COLORREF m_colorSurface[2*MAXIMAGE]; char m_filename[MAXIMAGE][20];