From 2047e75d2b3ac553acd54e31fd9725d6821668ae Mon Sep 17 00:00:00 2001 From: Martin Kiewitz Date: Sat, 24 Jul 2010 15:15:38 +0000 Subject: SCI: kCelWide/kCelHigh now adjust on hires views somewhat fixes gk1 hires inventory issue svn-id: r51245 --- engines/sci/engine/kgraphics.cpp | 11 ++--------- engines/sci/graphics/cache.cpp | 4 ++-- engines/sci/graphics/view.cpp | 38 ++++++++++++++++++++++++++++++++++---- engines/sci/graphics/view.h | 1 + 4 files changed, 39 insertions(+), 15 deletions(-) (limited to 'engines') diff --git a/engines/sci/engine/kgraphics.cpp b/engines/sci/engine/kgraphics.cpp index 5e8869af5e..afbc08b1ec 100644 --- a/engines/sci/engine/kgraphics.cpp +++ b/engines/sci/engine/kgraphics.cpp @@ -436,15 +436,6 @@ reg_t kCelWide(EngineState *s, int argc, reg_t *argv) { celWidth = g_sci->_gfxCache->kernelViewGetCelWidth(viewId, loopNo, celNo); -#ifdef ENABLE_SCI32 - if (getSciVersion() == SCI_VERSION_2_1) { - if (g_sci->_gfxScreen->getWidth() > 320) - celWidth = celWidth / 2; // half the width returned here, fixes lsl6 action icon placements - } - // the scripts work low-res and add the returned value from here to the coordinate - // TODO: check, if this is actually right. I'm slightly confused by this, but even GK1CD has some idivs in this - // code, so it seems plausible. -#endif return make_reg(0, celWidth); } @@ -1159,6 +1150,8 @@ reg_t kDeleteScreenItem(EngineState *s, int argc, reg_t *argv) { reg_t kAddPlane(EngineState *s, int argc, reg_t *argv) { reg_t planeObj = argv[0]; + warning("AddPlane %s", s->_segMan->getObjectName(argv[0])); + g_sci->_gfxFrameout->kernelAddPlane(planeObj); return NULL_REG; } diff --git a/engines/sci/graphics/cache.cpp b/engines/sci/graphics/cache.cpp index 8caa28b3a1..25475c727f 100644 --- a/engines/sci/graphics/cache.cpp +++ b/engines/sci/graphics/cache.cpp @@ -90,11 +90,11 @@ GfxView *GfxCache::getView(GuiResourceId viewId) { } int16 GfxCache::kernelViewGetCelWidth(GuiResourceId viewId, int16 loopNo, int16 celNo) { - return getView(viewId)->getCelInfo(loopNo, celNo)->width; + return getView(viewId)->getCelInfo(loopNo, celNo)->scriptWidth; } int16 GfxCache::kernelViewGetCelHeight(GuiResourceId viewId, int16 loopNo, int16 celNo) { - return getView(viewId)->getCelInfo(loopNo, celNo)->height; + return getView(viewId)->getCelInfo(loopNo, celNo)->scriptHeight; } int16 GfxCache::kernelViewGetLoopCount(GuiResourceId viewId) { diff --git a/engines/sci/graphics/view.cpp b/engines/sci/graphics/view.cpp index 93df45820c..80778504ec 100644 --- a/engines/sci/graphics/view.cpp +++ b/engines/sci/graphics/view.cpp @@ -160,8 +160,8 @@ void GfxView::initData(GuiResourceId resourceId) { // For EGA // Width:WORD Height:WORD DisplaceX:BYTE DisplaceY:BYTE ClearKey:BYTE EGAData starts now directly cel = &_loop[loopNo].cel[celNo]; - cel->width = READ_LE_UINT16(celData); - cel->height = READ_LE_UINT16(celData + 2); + cel->scriptWidth = cel->width = READ_LE_UINT16(celData); + cel->scriptHeight = cel->height = READ_LE_UINT16(celData + 2); cel->displaceX = (signed char)celData[4]; cel->displaceY = celData[5]; cel->clearKey = celData[6]; @@ -231,8 +231,8 @@ void GfxView::initData(GuiResourceId resourceId) { _loop[loopNo].cel = new CelInfo[celCount]; for (celNo = 0; celNo < celCount; celNo++) { cel = &_loop[loopNo].cel[celNo]; - cel->width = READ_SCI11ENDIAN_UINT16(celData); - cel->height = READ_SCI11ENDIAN_UINT16(celData + 2); + cel->scriptWidth = cel->width = READ_SCI11ENDIAN_UINT16(celData); + cel->scriptHeight = cel->height = READ_SCI11ENDIAN_UINT16(celData + 2); cel->displaceX = READ_SCI11ENDIAN_UINT16(celData + 4); cel->displaceY = READ_SCI11ENDIAN_UINT16(celData + 6); @@ -253,6 +253,36 @@ void GfxView::initData(GuiResourceId resourceId) { celData += celSize; } } +#ifdef ENABLE_SCI32 + // adjust width/height returned to scripts + switch (getSciVersion()) { + case SCI_VERSION_2: + if (_isSci2Hires) { + for (loopNo = 0; loopNo < _loopCount; loopNo++) { + for (celNo = 0; celNo < _loop[loopNo].celCount; celNo++) { + _screen->adjustBackUpscaledCoordinates(_loop[loopNo].cel[celNo].scriptWidth, _loop[loopNo].cel[celNo].scriptHeight); + } + } + } + break; + + case SCI_VERSION_2_1: + // half the width returned here, fixes lsl6 action icon placements + // the scripts work low-res and add the returned value from here to the coordinate + // TODO: check, if this is actually right. I'm slightly confused by this, but even GK1CD has some idivs in this + // code, so it seems plausible. + if (_screen->getDisplayWidth() > 320) { + for (loopNo = 0; loopNo < _loopCount; loopNo++) { + for (celNo = 0; celNo < _loop[loopNo].celCount; celNo++) { + _loop[loopNo].cel[celNo].scriptWidth /= 2; + _loop[loopNo].cel[celNo].scriptHeight /= 2; + } + } + } + default: + break; + } +#endif break; default: diff --git a/engines/sci/graphics/view.h b/engines/sci/graphics/view.h index 6eb1830b99..bcfae8a112 100644 --- a/engines/sci/graphics/view.h +++ b/engines/sci/graphics/view.h @@ -30,6 +30,7 @@ namespace Sci { struct CelInfo { int16 width, height; + int16 scriptWidth, scriptHeight; int16 displaceX; int16 displaceY; byte clearKey; -- cgit v1.2.3