diff options
author | Colin Snover | 2016-02-14 12:07:30 -0600 |
---|---|---|
committer | Colin Snover | 2016-02-18 13:18:02 -0600 |
commit | 20ccad80bfb689822be9f70512901557cbf244bf (patch) | |
tree | 40a0a63028a9355a1c58c3090c6c043af189e26c /engines/sci/engine | |
parent | 3bddd869abbd6ba6dd88b0911f80aa305c8d464e (diff) | |
download | scummvm-rg350-20ccad80bfb689822be9f70512901557cbf244bf.tar.gz scummvm-rg350-20ccad80bfb689822be9f70512901557cbf244bf.tar.bz2 scummvm-rg350-20ccad80bfb689822be9f70512901557cbf244bf.zip |
SCI: WIP GfxText32 code
This at least prevents SQ6 from crashing when going into the
introduction
Diffstat (limited to 'engines/sci/engine')
-rw-r--r-- | engines/sci/engine/kernel_tables.h | 2 | ||||
-rw-r--r-- | engines/sci/engine/kgraphics32.cpp | 118 | ||||
-rw-r--r-- | engines/sci/engine/selector.cpp | 5 | ||||
-rw-r--r-- | engines/sci/engine/selector.h | 2 |
4 files changed, 73 insertions, 54 deletions
diff --git a/engines/sci/engine/kernel_tables.h b/engines/sci/engine/kernel_tables.h index ad0b86b8b1..b4a092a25c 100644 --- a/engines/sci/engine/kernel_tables.h +++ b/engines/sci/engine/kernel_tables.h @@ -670,7 +670,7 @@ static SciKernelMapEntry s_kernelMap[] = { { MAP_CALL(CelInfo), SIG_EVERYWHERE, "iiiiii", NULL, NULL }, { MAP_CALL(SetLanguage), SIG_EVERYWHERE, "r", NULL, NULL }, { MAP_CALL(ScrollWindow), SIG_EVERYWHERE, "i(.*)", kScrollWindow_subops, NULL }, - { MAP_CALL(SetFontRes), SIG_EVERYWHERE, "ii", NULL, NULL }, + { MAP_DUMMY(SetFontRes), SIG_EVERYWHERE, "(.*)", NULL, NULL }, { MAP_CALL(Font), SIG_EVERYWHERE, "i(.*)", NULL, NULL }, { MAP_CALL(Bitmap), SIG_EVERYWHERE, "(.*)", NULL, NULL }, { MAP_CALL(AddLine), SIG_EVERYWHERE, "oiiiiiiiii", NULL, NULL }, diff --git a/engines/sci/engine/kgraphics32.cpp b/engines/sci/engine/kgraphics32.cpp index 64ef7ca610..a83836b033 100644 --- a/engines/sci/engine/kgraphics32.cpp +++ b/engines/sci/engine/kgraphics32.cpp @@ -174,41 +174,53 @@ reg_t kIsOnMe(EngineState *s, int argc, reg_t *argv) { } reg_t kCreateTextBitmap(EngineState *s, int argc, reg_t *argv) { - switch (argv[0].toUint16()) { - case 0: { - if (argc != 4) { - warning("kCreateTextBitmap(0): expected 4 arguments, got %i", argc); - return NULL_REG; - } - reg_t object = argv[3]; - Common::String text = s->_segMan->getString(readSelector(s->_segMan, object, SELECTOR(text))); - debugC(kDebugLevelStrings, "kCreateTextBitmap case 0 (%04x:%04x, %04x:%04x, %04x:%04x)", - PRINT_REG(argv[1]), PRINT_REG(argv[2]), PRINT_REG(argv[3])); - debugC(kDebugLevelStrings, "%s", text.c_str()); - int16 maxWidth = argv[1].toUint16(); - int16 maxHeight = argv[2].toUint16(); - g_sci->_gfxCoordAdjuster->fromScriptToDisplay(maxHeight, maxWidth); - // These values can be larger than the screen in the SQ6 demo, room 100 - // TODO: Find out why. For now, don't show any text in that room. - if (g_sci->getGameId() == GID_SQ6 && g_sci->isDemo() && s->currentRoomNumber() == 100) - return NULL_REG; - return g_sci->_gfxText32->createTextBitmap(object, maxWidth, maxHeight); - } - case 1: { - if (argc != 2) { - warning("kCreateTextBitmap(1): expected 2 arguments, got %i", argc); - return NULL_REG; - } - reg_t object = argv[1]; - Common::String text = s->_segMan->getString(readSelector(s->_segMan, object, SELECTOR(text))); - debugC(kDebugLevelStrings, "kCreateTextBitmap case 1 (%04x:%04x)", PRINT_REG(argv[1])); - debugC(kDebugLevelStrings, "%s", text.c_str()); - return g_sci->_gfxText32->createTextBitmap(object); - } - default: - warning("CreateTextBitmap(%d)", argv[0].toUint16()); + SegManager *segMan = s->_segMan; + + int16 subop = argv[0].toUint16(); + + int16 width; + int16 height; + reg_t object; + + if (subop == 0) { + width = argv[1].toUint16(); + height = argv[2].toUint16(); + object = argv[3]; + } else if (subop == 1) { + object = argv[1]; + } else { + warning("Invalid kCreateTextBitmap subop %d", subop); return NULL_REG; } + + Common::String text = segMan->getString(readSelector(segMan, object, SELECTOR(text))); + int16 foreColor = readSelectorValue(segMan, object, SELECTOR(fore)); + int16 backColor = readSelectorValue(segMan, object, SELECTOR(back)); + int16 skipColor = readSelectorValue(segMan, object, SELECTOR(skip)); + GuiResourceId fontId = (GuiResourceId)readSelectorValue(segMan, object, SELECTOR(font)); + int16 borderColor = readSelectorValue(segMan, object, SELECTOR(borderColor)); + int16 dimmed = readSelectorValue(segMan, object, SELECTOR(dimmed)); + + Common::Rect rect( + readSelectorValue(segMan, object, SELECTOR(textLeft)), + readSelectorValue(segMan, object, SELECTOR(textTop)), + readSelectorValue(segMan, object, SELECTOR(textRight)), + readSelectorValue(segMan, object, SELECTOR(textBottom)) + ); + + if (subop == 0) { + TextAlign alignment = (TextAlign)readSelectorValue(segMan, object, SELECTOR(mode)); + reg_t out; + return g_sci->_gfxText32->createFontBitmap(width, height, rect, text, foreColor, backColor, skipColor, fontId, alignment, borderColor, dimmed, 1, &out); + } else { + CelInfo32 celInfo; + celInfo.type = kCelTypeView; + celInfo.resourceId = readSelectorValue(segMan, object, SELECTOR(view)); + celInfo.loopNo = readSelectorValue(segMan, object, SELECTOR(loop)); + celInfo.celNo = readSelectorValue(segMan, object, SELECTOR(cel)); + reg_t out; + return g_sci->_gfxText32->createTitledFontBitmap(celInfo, rect, text, foreColor, backColor, fontId, skipColor, borderColor, dimmed, &out); + } } reg_t kDisposeTextBitmap(EngineState *s, int argc, reg_t *argv) { @@ -455,34 +467,26 @@ reg_t kScrollWindow(EngineState *s, int argc, reg_t *argv) { } #endif -reg_t kSetFontRes(EngineState *s, int argc, reg_t *argv) { - // TODO: This defines the resolution that the fonts are supposed to be displayed - // in. Currently, this is only used for showing high-res fonts in GK1 Mac, but - // should be extended to handle other font resolutions such as those - - int xResolution = argv[0].toUint16(); - //int yResolution = argv[1].toUint16(); - - g_sci->_gfxScreen->setFontIsUpscaled(xResolution == 640 && - g_sci->_gfxScreen->getUpscaledHires() != GFX_SCREEN_UPSCALED_DISABLED); - - return s->r_acc; -} - reg_t kFont(EngineState *s, int argc, reg_t *argv) { - // Handle font settings for SCI2.1 + // TODO: Handle font settings for SCI2.1 switch (argv[0].toUint16()) { case 1: - // Set font resolution - return kSetFontRes(s, argc - 1, argv + 1); + g_sci->_gfxText32->_scaledWidth = argv[1].toUint16(); + g_sci->_gfxText32->_scaledHeight = argv[2].toUint16(); + return NULL_REG; default: - warning("kFont: unknown subop %d", argv[0].toUint16()); + error("kFont: unknown subop %d", argv[0].toUint16()); } return s->r_acc; } +// TODO: Is this actually a thing?? +reg_t kSetFontRes(EngineState *s, int argc, reg_t *argv) { + return kStub(s, argc, argv); +} + // TODO: Eventually, all of the kBitmap operations should be put // in a separate class @@ -516,8 +520,16 @@ reg_t kBitmap(EngineState *s, int argc, reg_t *argv) { memset(memoryPtr + BITMAP_HEADER_SIZE, back, width * height); // Save totalWidth, totalHeight // TODO: Save the whole bitmap header, like SSCI does - WRITE_LE_UINT16(memoryPtr, width); - WRITE_LE_UINT16(memoryPtr + 2, height); + WRITE_SCI11ENDIAN_UINT16(memoryPtr, width); + WRITE_SCI11ENDIAN_UINT16(memoryPtr + 2, height); + WRITE_SCI11ENDIAN_UINT16(memoryPtr + 4, 0); + WRITE_SCI11ENDIAN_UINT16(memoryPtr + 6, 0); + memoryPtr[8] = 0; + WRITE_SCI11ENDIAN_UINT16(memoryPtr + 10, 0); + WRITE_SCI11ENDIAN_UINT16(memoryPtr + 20, BITMAP_HEADER_SIZE); + WRITE_SCI11ENDIAN_UINT32(memoryPtr + 28, 46); + WRITE_SCI11ENDIAN_UINT16(memoryPtr + 36, width); + WRITE_SCI11ENDIAN_UINT16(memoryPtr + 38, width); return memoryId; } break; diff --git a/engines/sci/engine/selector.cpp b/engines/sci/engine/selector.cpp index 05a9e6c980..b86e0ffd68 100644 --- a/engines/sci/engine/selector.cpp +++ b/engines/sci/engine/selector.cpp @@ -179,6 +179,7 @@ void Kernel::mapSelectors() { FIND_SELECTOR(fore); FIND_SELECTOR(back); FIND_SELECTOR(skip); + FIND_SELECTOR(borderColor); FIND_SELECTOR(fixPriority); FIND_SELECTOR(mirrored); FIND_SELECTOR(visible); @@ -187,6 +188,10 @@ void Kernel::mapSelectors() { FIND_SELECTOR(inLeft); FIND_SELECTOR(inBottom); FIND_SELECTOR(inRight); + FIND_SELECTOR(textTop); + FIND_SELECTOR(textLeft); + FIND_SELECTOR(textBottom); + FIND_SELECTOR(textRight); FIND_SELECTOR(magnifier); #endif } diff --git a/engines/sci/engine/selector.h b/engines/sci/engine/selector.h index a8b195f245..6b724ed271 100644 --- a/engines/sci/engine/selector.h +++ b/engines/sci/engine/selector.h @@ -146,6 +146,7 @@ struct SelectorCache { Selector back; Selector skip; Selector dimmed; + Selector borderColor; Selector fixPriority; Selector mirrored; @@ -153,6 +154,7 @@ struct SelectorCache { Selector useInsetRect; Selector inTop, inLeft, inBottom, inRight; + Selector textTop, textLeft, textBottom, textRight; Selector magnifier; #endif |