[Scummvm-git-logs] scummvm master -> dee1a2fa9b173e2b0304cab193a478087a98fbdb
dreammaster
noreply at scummvm.org
Fri Jan 19 05:13:09 UTC 2024
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
1370071293 M4: Remove unused _screen global
dee1a2fa9b M4: Load dialog now showing ScummVM thumbnails
Commit: 13700712937bd3839d48fa1b791f249dbc3ecc4a
https://github.com/scummvm/scummvm/commit/13700712937bd3839d48fa1b791f249dbc3ecc4a
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2024-01-18T20:02:29-08:00
Commit Message:
M4: Remove unused _screen global
Changed paths:
engines/m4/m4.cpp
engines/m4/m4.h
diff --git a/engines/m4/m4.cpp b/engines/m4/m4.cpp
index d047718e1fd..0f45c514cb3 100644
--- a/engines/m4/m4.cpp
+++ b/engines/m4/m4.cpp
@@ -57,7 +57,6 @@ M4Engine::M4Engine(OSystem *syst, const M4GameDescription *gameDesc) : Engine(sy
}
M4Engine::~M4Engine() {
- delete _screen;
}
uint32 M4Engine::getFeatures() const {
diff --git a/engines/m4/m4.h b/engines/m4/m4.h
index 423e6c4d575..42fa914f8e5 100644
--- a/engines/m4/m4.h
+++ b/engines/m4/m4.h
@@ -74,9 +74,6 @@ protected:
*/
virtual void setupConsole() = 0;
-public:
- Graphics::Screen *_screen = nullptr;
-
public:
M4Engine(OSystem *syst, const M4GameDescription *gameDesc);
~M4Engine() override;
Commit: dee1a2fa9b173e2b0304cab193a478087a98fbdb
https://github.com/scummvm/scummvm/commit/dee1a2fa9b173e2b0304cab193a478087a98fbdb
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2024-01-18T21:11:41-08:00
Commit Message:
M4: Load dialog now showing ScummVM thumbnails
Changed paths:
engines/m4/burger/gui/game_menu.cpp
engines/m4/m4.cpp
diff --git a/engines/m4/burger/gui/game_menu.cpp b/engines/m4/burger/gui/game_menu.cpp
index f69a650eb40..e46db29841a 100644
--- a/engines/m4/burger/gui/game_menu.cpp
+++ b/engines/m4/burger/gui/game_menu.cpp
@@ -342,6 +342,15 @@ void menu_DrawMsg(void *theItem, void *theMenu, int32 x, int32 y, int32, int32)
if (backgroundBuff) {
gr_buffer_rect_copy_2(backgroundBuff, myBuff, 0, 0, x, y, backgroundBuff->w, backgroundBuff->h);
myItem->background->release();
+ } else if (myItem->tag == SL_TAG_THUMBNAIL && mySprite->w == 160) {
+ // Hack for handling smaller ScummVM thumbnails
+ for (int yp = y; yp < (y + SL_THUMBNAIL_H); ++yp) {
+ byte *line = myBuff->data + myBuff->stride * yp + x;
+ Common::fill(line, line + SL_THUMBNAIL_W, 0);
+ }
+
+ x += 25;
+ y += 25;
}
// Draw the sprite in
@@ -2928,27 +2937,7 @@ bool load_Handler(void *theItem, int32 eventType, int32 event, int32 x, int32 y,
bool LoadThumbNail(int32 slotNum) {
Sprite *&thumbNailSprite = _GM(thumbNails)[slotNum];
- if (!g_engine->loadSaveThumbnail(slotNum, thumbNailSprite))
- return false;
-/*
- const Graphics::Surface *thumbnail = g_engine->loadSaveThumbnail(slotNum);
- if (!thumbnail)
- return false;
-
-
- // Create a sprite based on the thumbnail data
- if ((thumbNailSprite = (Sprite *)mem_alloc(sizeof(Sprite), "sprite")) == nullptr) {
- delete thumbnail;
- return false;
- }
-
- thumbNailSprite->w = thumbnail->w;
- thumbNailSprite->h = thumbnail->h;
- thumbNailSprite->encoding = NO_COMPRESS;
- thumbNailSprite->data = (byte *)thumbnail->getPixels();
- thumbNailSprite->sourceOffset = 0;
- */
- return true;
+ return g_engine->loadSaveThumbnail(slotNum + 1, thumbNailSprite);
}
@@ -3424,10 +3413,8 @@ bool load_Handler(void *theItem, int32 eventType, int32 event, int32 x, int32 y,
// This determines that we are over the button
if ((myButton->itemFlags == BTN_STATE_OVER) || (myButton->itemFlags == BTN_STATE_PRESS)) {
-
// See if the current _GM(saveLoadThumbNail) is pointing to the correct sprite
if (_GM(saveLoadThumbNail) != _GM(thumbNails)[myButton->specialTag - 1]) {
-
_GM(saveLoadThumbNail) = _GM(thumbNails)[myButton->specialTag - 1];
menu_ItemRefresh(nullptr, SL_TAG_THUMBNAIL, (guiMenu *)myItem->myMenu);
}
diff --git a/engines/m4/m4.cpp b/engines/m4/m4.cpp
index 0f45c514cb3..dadbe7455da 100644
--- a/engines/m4/m4.cpp
+++ b/engines/m4/m4.cpp
@@ -307,26 +307,46 @@ bool M4Engine::loadSaveThumbnail(int slotNum, M4sprite *thumbnail) const {
// Gert the thumbnail
const Graphics::Surface *surf = desc.getThumbnail();
+ assert(surf->format.bytesPerPixel == 2);
// Set up output sprite
thumbnail->w = surf->w;
thumbnail->h = surf->h;
thumbnail->encoding = NO_COMPRESS;
- thumbnail->sourceOffset = 0;
- thumbnail->data = (byte *)malloc(surf->w * surf->h);
- // Create a surface wrapper for the destination so that we can use
- // ScummVM's blitting code to down-convert the thumbnail to paletted
- Graphics::ManagedSurface dest;
- dest.w = dest.pitch = surf->w;
- dest.h = surf->h;
- dest.format = Graphics::PixelFormat::createFormatCLUT8();
- dest.setPixels(thumbnail->data);
+ byte *data = (byte *)malloc(surf->w * surf->h);
+ thumbnail->sourceHandle = (MemHandle)malloc(sizeof(MemHandle));
+ *thumbnail->sourceHandle = data;
+ thumbnail->sourceOffset = 0;
+ thumbnail->data = data;
byte pal[PALETTE_SIZE];
+ byte r, g, b;
+ int proximity, minProximity;
g_system->getPaletteManager()->grabPalette(pal, 0, PALETTE_COUNT);
- dest.setPalette(pal, 0, PALETTE_COUNT);
- dest.blitFrom(*surf);
+
+ // Translate the 16-bit thumbnail to paletted
+ for (int y = 0; y < surf->h; ++y) {
+ const uint16 *srcLine = (const uint16 *)surf->getBasePtr(0, y);
+ byte *destLine = data + surf->w * y;
+
+ for (int x = 0; x < surf->w; ++x, ++srcLine, ++destLine) {
+ proximity = minProximity = 0xffff;
+ surf->format.colorToRGB(*srcLine, r, g, b);
+
+ const byte *palP = pal;
+ for (int palIdx = 0; palIdx < PALETTE_COUNT; ++palIdx, palP += 3) {
+ proximity = ABS((int)r - (int)palP[0]) +
+ ABS((int)g - (int)palP[1]) +
+ ABS((int)b - (int)palP[2]);
+
+ if (proximity < minProximity) {
+ minProximity = proximity;
+ *destLine = (byte)palIdx;
+ }
+ }
+ }
+ }
return true;
}
More information about the Scummvm-git-logs
mailing list