[Scummvm-git-logs] scummvm master -> 1c8335476c01ed57d23b6723064c1fc91c694fba
dreammaster
noreply at scummvm.org
Thu Dec 25 03:42:37 UTC 2025
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .
Summary:
80b5cadedf IMAGE: Added Image::writePalettedBitmap
1c8335476c MM: MM1: Allow override graphics for scroll symbols
Commit: 80b5cadedfe6ac32ce27d80a1dd3695f8c84f46a
https://github.com/scummvm/scummvm/commit/80b5cadedfe6ac32ce27d80a1dd3695f8c84f46a
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-12-25T14:36:58+11:00
Commit Message:
IMAGE: Added Image::writePalettedBitmap
Changed paths:
image/bmp.cpp
image/bmp.h
diff --git a/image/bmp.cpp b/image/bmp.cpp
index ffc68406c1f..b498ca89229 100644
--- a/image/bmp.cpp
+++ b/image/bmp.cpp
@@ -195,4 +195,60 @@ bool writeBMP(Common::WriteStream &out, const Graphics::Surface &input, const by
return true;
}
+bool writePalettedBMP(Common::WriteStream &out, const Graphics::Surface &surface, const byte *palette) {
+ // We assume surface is already 8bpp indexed
+ // surface->pitch should be >= surface->w
+
+ const int bytesPerPixel = 1;
+ const int rowSize = surface.w * bytesPerPixel;
+ const int rowPadding = (4 - (rowSize & 3)) & 3;
+
+ const uint32 paletteSize = 256 * 4;
+ const uint32 pixelDataSize = (rowSize + rowPadding) * surface.h;
+ const uint32 dataOffset = 14 + 40 + paletteSize;
+ const uint32 fileSize = dataOffset + pixelDataSize;
+
+ /* === BITMAPFILEHEADER === */
+ out.writeByte('B');
+ out.writeByte('M');
+ out.writeUint32LE(fileSize);
+ out.writeUint16LE(0);
+ out.writeUint16LE(0);
+ out.writeUint32LE(dataOffset);
+
+ /* === BITMAPINFOHEADER === */
+ out.writeUint32LE(40); // biSize
+ out.writeUint32LE(surface.w);
+ out.writeUint32LE(surface.h);
+ out.writeUint16LE(1); // planes
+ out.writeUint16LE(8); // bit count
+ out.writeUint32LE(0); // BI_RGB
+ out.writeUint32LE(pixelDataSize);
+ out.writeUint32LE(0); // x ppm
+ out.writeUint32LE(0); // y ppm
+ out.writeUint32LE(256); // colors used
+ out.writeUint32LE(256); // important colors
+
+ /* === PALETTE === */
+ // Input palette: RGBRGBRGB...
+ // BMP palette: B G R 0
+ for (int i = 0; i < 256; i++) {
+ out.writeByte(palette[i * 3 + 2]); // B
+ out.writeByte(palette[i * 3 + 1]); // G
+ out.writeByte(palette[i * 3 + 0]); // R
+ out.writeByte(0); // reserved
+ }
+
+ /* === PIXEL DATA (bottom-up) === */
+ byte pad[3] = { 0, 0, 0 };
+
+ for (int y = surface.h - 1; y >= 0; y--) {
+ out.write(surface.getBasePtr(0, y), rowSize);
+ if (rowPadding)
+ out.write(pad, rowPadding);
+ }
+
+ return true;
+}
+
} // End of namespace Image
diff --git a/image/bmp.h b/image/bmp.h
index ba756d7d919..9bbc7d4d2f4 100644
--- a/image/bmp.h
+++ b/image/bmp.h
@@ -87,6 +87,12 @@ private:
* Outputs an uncompressed BMP stream of the given input surface.
*/
bool writeBMP(Common::WriteStream &out, const Graphics::Surface &input, const byte *palette = nullptr);
+
+/**
+ * Outputs an uncompressed BMP stream of the given paletted input surface, without converting it to 24 bpp.
+ */
+bool writePalettedBMP(Common::WriteStream &out, const Graphics::Surface &surface, const byte *palette);
+
/** @} */
} // End of namespace Image
Commit: 1c8335476c01ed57d23b6723064c1fc91c694fba
https://github.com/scummvm/scummvm/commit/1c8335476c01ed57d23b6723064c1fc91c694fba
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-12-25T14:42:14+11:00
Commit Message:
MM: MM1: Allow override graphics for scroll symbols
Changed paths:
A engines/mm/mm1/gfx/symbols.cpp
A engines/mm/mm1/gfx/symbols.h
engines/mm/mm1/globals.cpp
engines/mm/mm1/globals.h
engines/mm/mm1/views_enh/scroll_view.cpp
engines/mm/module.mk
diff --git a/engines/mm/mm1/gfx/symbols.cpp b/engines/mm/mm1/gfx/symbols.cpp
new file mode 100644
index 00000000000..6b4dab625de
--- /dev/null
+++ b/engines/mm/mm1/gfx/symbols.cpp
@@ -0,0 +1,69 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "common/file.h"
+#include "image/bmp.h"
+#include "image/png.h"
+#include "mm/mm1/gfx/symbols.h"
+
+namespace MM {
+namespace MM1 {
+namespace Gfx {
+
+void Symbols::load() {
+ Common::File f;
+ if (!f.open("symbols.bin"))
+ error("Could not load symbols.bin");
+
+ for (uint i = 0; i < MAX_SYMBOLS; ++i) {
+ const Common::String fname1 = Common::String::format("gfx//symbols.bin//image%.2d.bmp", i);
+ const Common::String fname2 = Common::String::format("gfx//symbols.bin//image%.2d.bmp", i);
+
+ Common::File fOverride1, fOverride2;
+ Image::BitmapDecoder bmpDecoder;
+ Image::PNGDecoder pngDecoder;
+
+ if (fOverride1.open(fname1.c_str()) && bmpDecoder.loadStream(fOverride1)) {
+ // Load the bitmap
+ _data[i].copyFrom(*bmpDecoder.getSurface());
+ f.skip(SYMBOL_WIDTH * SYMBOL_HEIGHT);
+ } else if (fOverride2.open(fname2.c_str()) && pngDecoder.loadStream(fOverride2)) {
+ // Load the png
+ _data[i].copyFrom(*pngDecoder.getSurface());
+ f.skip(SYMBOL_WIDTH * SYMBOL_HEIGHT);
+ } else {
+ // Fall back on the default
+ _data[i].create(SYMBOL_WIDTH, SYMBOL_HEIGHT);
+ f.read((byte *)_data[i].getPixels(), SYMBOL_WIDTH * SYMBOL_HEIGHT);
+ }
+ }
+
+ f.close();
+}
+
+void Symbols::draw(Graphics::ManagedSurface &dest, const Common::Point &destPos, int symbolNum) {
+ assert(symbolNum < MAX_SYMBOLS);
+ dest.blitFrom(_data[symbolNum], destPos);
+}
+
+} // namespace Gfx
+} // namespace MM1
+} // namespace MM
diff --git a/engines/mm/mm1/gfx/symbols.h b/engines/mm/mm1/gfx/symbols.h
new file mode 100644
index 00000000000..480fe17f0a8
--- /dev/null
+++ b/engines/mm/mm1/gfx/symbols.h
@@ -0,0 +1,49 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef MM1_GFX_SYMBOLS_H
+#define MM1_GFX_SYMBOLS_H
+
+#include "graphics/managed_surface.h"
+
+namespace MM {
+namespace MM1 {
+namespace Gfx {
+
+#define MAX_SYMBOLS 20
+#define SYMBOL_WIDTH 8
+#define SYMBOL_HEIGHT 8
+
+class Symbols {
+private:
+ Graphics::ManagedSurface _data[20];
+
+public:
+ void load();
+
+ void draw(Graphics::ManagedSurface &dest, const Common::Point &destPos, int symbolNum);
+};
+
+} // namespace Gfx
+} // namespace MM1
+} // namespace MM
+
+#endif
diff --git a/engines/mm/mm1/globals.cpp b/engines/mm/mm1/globals.cpp
index a121ef59b0f..9dc2f167b9a 100644
--- a/engines/mm/mm1/globals.cpp
+++ b/engines/mm/mm1/globals.cpp
@@ -98,13 +98,7 @@ bool Globals::load(bool isEnhanced) {
}
}
- {
- Common::File f;
- if (!f.open("symbols.bin"))
- error("Could not load symbols.bin");
- f.read(SYMBOLS, 20 * 64);
- f.close();
- }
+ _symbols.load();
{
Common::File f;
diff --git a/engines/mm/mm1/globals.h b/engines/mm/mm1/globals.h
index 6936de4181e..aa4c85c5809 100644
--- a/engines/mm/mm1/globals.h
+++ b/engines/mm/mm1/globals.h
@@ -33,6 +33,7 @@
#include "mm/mm1/data/roster.h"
#include "mm/mm1/data/treasure.h"
#include "mm/mm1/gfx/bitmap_font.h"
+#include "mm/mm1/gfx/symbols.h"
#include "mm/mm1/game/combat.h"
#include "mm/mm1/game/encounter.h"
#include "mm/mm1/maps/maps.h"
@@ -79,7 +80,7 @@ public:
Shared::Xeen::SpriteResource _escSprites;
Graphics::ManagedSurface _blankButton;
Graphics::ManagedSurface _gameBackground;
- byte SYMBOLS[20][64];
+ Gfx::Symbols _symbols;
XeenFont _fontNormal;
XeenFont _fontReduced;
public:
diff --git a/engines/mm/mm1/views_enh/scroll_view.cpp b/engines/mm/mm1/views_enh/scroll_view.cpp
index bec4e037e36..d5d5395d0e5 100644
--- a/engines/mm/mm1/views_enh/scroll_view.cpp
+++ b/engines/mm/mm1/views_enh/scroll_view.cpp
@@ -28,9 +28,6 @@ namespace MM {
namespace MM1 {
namespace ViewsEnh {
-#define SYMBOL_WIDTH FRAME_BORDER_SIZE
-#define SYMBOL_HEIGHT FRAME_BORDER_SIZE
-
ScrollView::ScrollView(const Common::String &name) :
TextView(name, g_engine) {
_bounds.setBorderSize(FRAME_BORDER_SIZE);
@@ -175,21 +172,7 @@ void ScrollView::fill() {
void ScrollView::writeSymbol(int symbolId) {
Graphics::ManagedSurface s = getSurface();
- const byte *srcP = &g_globals->SYMBOLS[symbolId][0];
- s.addDirtyRect(Common::Rect(_symbolPos.x, _symbolPos.y,
- _symbolPos.x + SYMBOL_WIDTH, _symbolPos.y + SYMBOL_HEIGHT));
-
- for (int yp = 0; yp < SYMBOL_HEIGHT; ++yp) {
- byte *destP = (byte *)s.getBasePtr(
- _symbolPos.x, _symbolPos.y + yp);
-
- for (int xp = 0; xp < SYMBOL_WIDTH; ++xp, ++destP) {
- byte b = *srcP++;
- if (b)
- *destP = b;
- }
- }
-
+ g_globals->_symbols.draw(s, Common::Point(_symbolPos.x, _symbolPos.y), symbolId);
_symbolPos.x += SYMBOL_WIDTH;
}
diff --git a/engines/mm/module.mk b/engines/mm/module.mk
index 1b0d6dd331a..b2b87fbf723 100644
--- a/engines/mm/module.mk
+++ b/engines/mm/module.mk
@@ -58,6 +58,7 @@ MODULE_OBJS += \
mm1/gfx/dta.o \
mm1/gfx/gfx.o \
mm1/gfx/screen_decoder.o \
+ mm1/gfx/symbols.o \
mm1/utils/mouse.o \
mm1/utils/strings.o \
mm1/views/locations/location.o \
More information about the Scummvm-git-logs
mailing list