aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilippos Karapetis2011-10-11 02:33:45 +0300
committerFilippos Karapetis2011-10-11 02:33:45 +0300
commita9c6d2a4c4e80708d63dbbd7dc2c0419258d6d19 (patch)
tree1f161c57d6b0bd1449ecbfd519c13897e4e0fa8e
parent4cb9a2c809d7b66a4065de68247153f1057c84be (diff)
downloadscummvm-rg350-a9c6d2a4c4e80708d63dbbd7dc2c0419258d6d19.tar.gz
scummvm-rg350-a9c6d2a4c4e80708d63dbbd7dc2c0419258d6d19.tar.bz2
scummvm-rg350-a9c6d2a4c4e80708d63dbbd7dc2c0419258d6d19.zip
SCI: Some work on the SCI32 bitmap / font code
- Initial implementation of kBitmap(0) - Bugfixes for fonts in upscaled games
-rw-r--r--engines/sci/engine/kgraphics.cpp6
-rw-r--r--engines/sci/graphics/text32.cpp17
-rw-r--r--engines/sci/graphics/text32.h1
3 files changed, 19 insertions, 5 deletions
diff --git a/engines/sci/engine/kgraphics.cpp b/engines/sci/engine/kgraphics.cpp
index be86cb5b49..5c33db080f 100644
--- a/engines/sci/engine/kgraphics.cpp
+++ b/engines/sci/engine/kgraphics.cpp
@@ -1637,10 +1637,8 @@ reg_t kBitmap(EngineState *s, int argc, reg_t *argv) {
uint16 back = argv[4].toUint16();
uint16 width2 = (argc >= 6) ? argv[5].toUint16() : 0;
uint16 height2 = (argc >= 7) ? argv[6].toUint16() : 0;
- uint16 transparent = (argc >= 8) ? argv[7].toUint16() : 0;
- warning("kBitmap(0): width %d, height %d, skip %d, back %d, width2 %d, height2 %d, transparent %d",
- width, height, skip, back, width2, height2, transparent);
- return NULL_REG; // TODO: return a hunk handle for the new bitmap surface
+ uint16 transparentFlag = (argc >= 8) ? argv[7].toUint16() : 0;
+ return g_sci->_gfxText32->createTextBitmapSci21(width, height, skip, back, width2, height2, transparentFlag);
}
break;
case 1: // dispose text bitmap surface
diff --git a/engines/sci/graphics/text32.cpp b/engines/sci/graphics/text32.cpp
index d906d56892..1939baeb06 100644
--- a/engines/sci/graphics/text32.cpp
+++ b/engines/sci/graphics/text32.cpp
@@ -100,6 +100,15 @@ reg_t GfxText32::createTextBitmap(reg_t textObject, uint16 maxWidth, uint16 maxH
return memoryId;
}
+reg_t GfxText32::createTextBitmapSci21(uint16 width, uint16 height, byte skip, byte back, uint16 width2, uint16 height2, byte transparentFlag) {
+ // TODO: skip, width2, height2, transparentFlag
+ int entrySize = width * height;
+ reg_t memoryId = _segMan->allocateHunkEntry("TextBitmap()", entrySize);
+ byte *memoryPtr = _segMan->getHunkPointer(memoryId);
+ memset(memoryPtr, back, entrySize);
+ return memoryId;
+}
+
void GfxText32::disposeTextBitmap(reg_t hunkId) {
_segMan->freeHunkEntry(hunkId);
}
@@ -119,11 +128,17 @@ void GfxText32::drawTextBitmap(reg_t textObject) {
uint16 width = nsRect.width();
uint16 height = nsRect.height();
+ // Upscale the coordinates/width if the fonts are already upscaled
+ if (_screen->fontIsUpscaled()) {
+ textX = textX * _screen->getDisplayWidth() / _screen->getWidth();
+ textY = textY * _screen->getDisplayHeight() / _screen->getHeight();
+ }
+
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
byte pixel = surface[curByte++];
if (pixel)
- _screen->putPixel(x + textX, y + textY, 1, pixel, 0, 0);
+ _screen->putFontPixel(textY, x + textX, y, pixel);
}
}
}
diff --git a/engines/sci/graphics/text32.h b/engines/sci/graphics/text32.h
index 4c1e53d971..43395f6517 100644
--- a/engines/sci/graphics/text32.h
+++ b/engines/sci/graphics/text32.h
@@ -38,6 +38,7 @@ public:
GfxText32(SegManager *segMan, GfxCache *fonts, GfxScreen *screen);
~GfxText32();
reg_t createTextBitmap(reg_t textObject, uint16 maxWidth = 0, uint16 maxHeight = 0);
+ reg_t createTextBitmapSci21(uint16 width, uint16 height, byte skip, byte back, uint16 width2, uint16 height2, byte transparentFlag);
void disposeTextBitmap(reg_t hunkId);
void drawTextBitmap(reg_t textObject);
int16 GetLongest(const char *text, int16 maxWidth, GfxFont *font);