aboutsummaryrefslogtreecommitdiff
path: root/engines/sci
diff options
context:
space:
mode:
authorColin Snover2016-07-31 15:19:29 -0500
committerColin Snover2016-08-19 13:57:40 -0500
commitff00e93c677e9437aee256b3ff9f1bce7e9b5032 (patch)
treebd26c93fea92febc6de9f29385dfe9da2d7d4993 /engines/sci
parentc8a2b9af225e0ebca7d98f7b1063793a290953cd (diff)
downloadscummvm-rg350-ff00e93c677e9437aee256b3ff9f1bce7e9b5032.tar.gz
scummvm-rg350-ff00e93c677e9437aee256b3ff9f1bce7e9b5032.tar.bz2
scummvm-rg350-ff00e93c677e9437aee256b3ff9f1bce7e9b5032.zip
SCI32: Remove GfxScreen from SCI32
Diffstat (limited to 'engines/sci')
-rw-r--r--engines/sci/engine/kernel.h2
-rw-r--r--engines/sci/engine/kernel_tables.h7
-rw-r--r--engines/sci/engine/kgraphics.cpp13
-rw-r--r--engines/sci/engine/kgraphics32.cpp39
-rw-r--r--engines/sci/graphics/cache.cpp10
-rw-r--r--engines/sci/graphics/celobj32.cpp37
-rw-r--r--engines/sci/graphics/celobj32.h3
-rw-r--r--engines/sci/graphics/screen.cpp2
-rw-r--r--engines/sci/sci.cpp16
9 files changed, 108 insertions, 21 deletions
diff --git a/engines/sci/engine/kernel.h b/engines/sci/engine/kernel.h
index 77927ba7d5..892f0febec 100644
--- a/engines/sci/engine/kernel.h
+++ b/engines/sci/engine/kernel.h
@@ -422,6 +422,8 @@ reg_t kStubNull(EngineState *s, int argc, reg_t *argv);
#ifdef ENABLE_SCI32
// SCI2 Kernel Functions
reg_t kSetCursor32(EngineState *s, int argc, reg_t *argv);
+reg_t kSetNowSeen32(EngineState *s, int argc, reg_t *argv);
+reg_t kBaseSetter32(EngineState *s, int argc, reg_t *argv);
reg_t kDoAudio32(EngineState *s, int argc, reg_t *argv);
reg_t kDoAudioInit(EngineState *s, int argc, reg_t *argv);
diff --git a/engines/sci/engine/kernel_tables.h b/engines/sci/engine/kernel_tables.h
index 097eb8b405..058e4835fb 100644
--- a/engines/sci/engine/kernel_tables.h
+++ b/engines/sci/engine/kernel_tables.h
@@ -569,7 +569,10 @@ static SciKernelMapEntry s_kernelMap[] = {
{ MAP_CALL(Animate), SIG_EVERYWHERE, "(l0)(i)", NULL, NULL },
{ MAP_CALL(AssertPalette), SIG_EVERYWHERE, "i", NULL, NULL },
{ MAP_CALL(AvoidPath), SIG_EVERYWHERE, "ii(.*)", NULL, NULL },
- { MAP_CALL(BaseSetter), SIG_EVERYWHERE, "o", NULL, NULL },
+ { MAP_CALL(BaseSetter), SIG_SCI16, SIGFOR_ALL, "o", NULL, NULL },
+#ifdef ENABLE_SCI32
+ { "BaseSetter", kBaseSetter32, SIG_SCI32, SIGFOR_ALL, "o", NULL, NULL },
+#endif
{ MAP_CALL(CanBeHere), SIG_EVERYWHERE, "o(l)", NULL, NULL },
{ MAP_CALL(CantBeHere), SIG_SCI16, SIGFOR_ALL, "o(l)", NULL, NULL },
#ifdef ENABLE_SCI32
@@ -703,7 +706,7 @@ static SciKernelMapEntry s_kernelMap[] = {
{ MAP_CALL(SetMenu), SIG_EVERYWHERE, "i(.*)", NULL, NULL },
{ MAP_CALL(SetNowSeen), SIG_SCI16, SIGFOR_ALL, "o(i)", NULL, NULL },
#ifdef ENABLE_SCI32
- { MAP_CALL(SetNowSeen), SIG_SCI32, SIGFOR_ALL, "o", NULL, NULL },
+ { "SetNowSeen", kSetNowSeen32, SIG_SCI32, SIGFOR_ALL, "o", NULL, NULL },
#endif
{ MAP_CALL(SetPort), SIG_EVERYWHERE, "i(iiiii)(i)", NULL, kSetPort_workarounds },
{ MAP_CALL(SetQuitStr), SIG_EVERYWHERE, "r", NULL, NULL },
diff --git a/engines/sci/engine/kgraphics.cpp b/engines/sci/engine/kgraphics.cpp
index cae5a09789..d375a27954 100644
--- a/engines/sci/engine/kgraphics.cpp
+++ b/engines/sci/engine/kgraphics.cpp
@@ -579,17 +579,8 @@ reg_t kBaseSetter(EngineState *s, int argc, reg_t *argv) {
}
reg_t kSetNowSeen(EngineState *s, int argc, reg_t *argv) {
-#ifdef ENABLE_SCI32
- if (getSciVersion() >= SCI_VERSION_2) {
- g_sci->_gfxFrameout->kernelSetNowSeen(argv[0]);
- return NULL_REG;
- } else {
-#endif
- g_sci->_gfxCompare->kernelSetNowSeen(argv[0]);
- return s->r_acc;
-#ifdef ENABLE_SCI32
- }
-#endif
+ g_sci->_gfxCompare->kernelSetNowSeen(argv[0]);
+ return s->r_acc;
}
reg_t kPalette(EngineState *s, int argc, reg_t *argv) {
diff --git a/engines/sci/engine/kgraphics32.cpp b/engines/sci/engine/kgraphics32.cpp
index 2286a66de1..41dc9a2bae 100644
--- a/engines/sci/engine/kgraphics32.cpp
+++ b/engines/sci/engine/kgraphics32.cpp
@@ -64,6 +64,45 @@ namespace Sci {
extern void showScummVMDialog(const Common::String &message);
+reg_t kBaseSetter32(EngineState *s, int argc, reg_t *argv) {
+ reg_t object = argv[0];
+
+ const GuiResourceId viewId = readSelectorValue(s->_segMan, object, SELECTOR(view));
+ const int16 loopNo = readSelectorValue(s->_segMan, object, SELECTOR(loop));
+ const int16 celNo = readSelectorValue(s->_segMan, object, SELECTOR(cel));
+ const int16 x = readSelectorValue(s->_segMan, object, SELECTOR(x));
+ const int16 y = readSelectorValue(s->_segMan, object, SELECTOR(y));
+
+ CelObjView celObj(viewId, loopNo, celNo);
+
+ const int16 scriptWidth = g_sci->_gfxFrameout->getCurrentBuffer().scriptWidth;
+ const int16 scriptHeight = g_sci->_gfxFrameout->getCurrentBuffer().scriptHeight;
+
+ const Ratio scaleX(scriptWidth, celObj._scaledWidth);
+ const Ratio scaleY(scriptHeight, celObj._scaledHeight);
+
+ int16 brLeft;
+
+ if (celObj._mirrorX) {
+ brLeft = x - ((celObj._width - celObj._displace.x) * scaleX).toInt();
+ } else {
+ brLeft = x - (celObj._displace.x * scaleX).toInt();
+ }
+
+ const int16 brRight = brLeft + (celObj._width * scaleX).toInt() - 1;
+
+ writeSelectorValue(s->_segMan, object, SELECTOR(brLeft), brLeft);
+ writeSelectorValue(s->_segMan, object, SELECTOR(brRight), brRight);
+ writeSelectorValue(s->_segMan, object, SELECTOR(brBottom), y + 1);
+ writeSelectorValue(s->_segMan, object, SELECTOR(brTop), y + 1 - readSelectorValue(s->_segMan, object, SELECTOR(yStep)));
+
+ return s->r_acc;
+}
+
+reg_t kSetNowSeen32(EngineState *s, int argc, reg_t *argv) {
+ return make_reg(0, g_sci->_gfxFrameout->kernelSetNowSeen(argv[0]));
+}
+
reg_t kSetCursor32(EngineState *s, int argc, reg_t *argv) {
switch (argc) {
case 1: {
diff --git a/engines/sci/graphics/cache.cpp b/engines/sci/graphics/cache.cpp
index fb1f557ad6..9c77f31a14 100644
--- a/engines/sci/graphics/cache.cpp
+++ b/engines/sci/graphics/cache.cpp
@@ -95,10 +95,20 @@ int16 GfxCache::kernelViewGetCelHeight(GuiResourceId viewId, int16 loopNo, int16
}
int16 GfxCache::kernelViewGetLoopCount(GuiResourceId viewId) {
+#ifdef ENABLE_SCI32
+ if (getSciVersion() >= SCI_VERSION_2) {
+ return CelObjView::getNumLoops(viewId);
+ }
+#endif
return getView(viewId)->getLoopCount();
}
int16 GfxCache::kernelViewGetCelCount(GuiResourceId viewId, int16 loopNo) {
+#ifdef ENABLE_SCI32
+ if (getSciVersion() >= SCI_VERSION_2) {
+ return CelObjView::getNumCels(viewId, loopNo);
+ }
+#endif
return getView(viewId)->getCelCount(loopNo);
}
diff --git a/engines/sci/graphics/celobj32.cpp b/engines/sci/graphics/celobj32.cpp
index 311684d595..ebe845b567 100644
--- a/engines/sci/graphics/celobj32.cpp
+++ b/engines/sci/graphics/celobj32.cpp
@@ -791,6 +791,43 @@ void CelObj::scaleDrawUncompNoMD(Buffer &target, const Ratio &scaleX, const Rati
#pragma mark -
#pragma mark CelObjView
+int16 CelObjView::getNumLoops(const GuiResourceId viewId) {
+ Resource *resource = g_sci->getResMan()->findResource(ResourceId(kResourceTypeView, viewId), false);
+
+ if (!resource) {
+ return 0;
+ }
+
+ return resource->data[2];
+}
+
+int16 CelObjView::getNumCels(const GuiResourceId viewId, const int16 loopNo) {
+ Resource *resource = g_sci->getResMan()->findResource(ResourceId(kResourceTypeView, viewId), false);
+
+ if (!resource) {
+ return 0;
+ }
+
+ byte *data = resource->data;
+
+ uint16 loopCount = data[2];
+ if (loopNo >= loopCount) {
+ return 0;
+ }
+
+ const uint16 viewHeaderSize = READ_SCI11ENDIAN_UINT16(data);
+ const uint8 loopHeaderSize = data[12];
+ const uint8 viewHeaderFieldSize = 2;
+
+ byte *loopHeader = data + viewHeaderFieldSize + viewHeaderSize + (loopHeaderSize * loopNo);
+
+ if ((int8)loopHeader[0] != -1) {
+ loopHeader = data + viewHeaderFieldSize + viewHeaderSize + (loopHeaderSize * (int8)loopHeader[0]);
+ }
+
+ return loopHeader[2];
+}
+
CelObjView::CelObjView(const GuiResourceId viewId, const int16 loopNo, const int16 celNo) {
_info.type = kCelTypeView;
_info.resourceId = viewId;
diff --git a/engines/sci/graphics/celobj32.h b/engines/sci/graphics/celobj32.h
index eb6ce3a3c9..e1751deb64 100644
--- a/engines/sci/graphics/celobj32.h
+++ b/engines/sci/graphics/celobj32.h
@@ -505,6 +505,9 @@ public:
using CelObj::draw;
+ static int16 getNumLoops(const GuiResourceId viewId);
+ static int16 getNumCels(const GuiResourceId viewId, const int16 loopNo);
+
/**
* Draws the cel to the target buffer using the
* positioning, mirroring, and scaling information from
diff --git a/engines/sci/graphics/screen.cpp b/engines/sci/graphics/screen.cpp
index 8e638b9cad..394a43350c 100644
--- a/engines/sci/graphics/screen.cpp
+++ b/engines/sci/graphics/screen.cpp
@@ -192,7 +192,7 @@ GfxScreen::GfxScreen(ResourceManager *resMan) : _resMan(resMan) {
initGraphics(_displayWidth, _displayHeight + 28 + 2, _displayWidth > 320);
else
error("Unknown SCI1.1 Mac game");
- } else if (getSciVersion() < SCI_VERSION_2)
+ } else
initGraphics(_displayWidth, _displayHeight, _displayWidth > 320);
}
diff --git a/engines/sci/sci.cpp b/engines/sci/sci.cpp
index 842384ed1a..2c8683ab8c 100644
--- a/engines/sci/sci.cpp
+++ b/engines/sci/sci.cpp
@@ -265,10 +265,13 @@ Common::Error SciEngine::run() {
_forceHiresGraphics = ConfMan.getBool("enable_high_resolution_graphics");
}
- // TODO: Get rid of GfxScreen when running SCI32 games
- // Initialize the game screen
- _gfxScreen = new GfxScreen(_resMan);
- _gfxScreen->enableUndithering(ConfMan.getBool("disable_dithering"));
+ if (getSciVersion() < SCI_VERSION_2) {
+ // Initialize the game screen
+ _gfxScreen = new GfxScreen(_resMan);
+ _gfxScreen->enableUndithering(ConfMan.getBool("disable_dithering"));
+ } else {
+ _gfxScreen = nullptr;
+ }
_kernel = new Kernel(_resMan, segMan);
_kernel->init();
@@ -737,7 +740,7 @@ void SciEngine::initGraphics() {
// SCI32 graphic objects creation
_gfxCoordAdjuster = new GfxCoordAdjuster32(_gamestate->_segMan);
_gfxCursor32 = new GfxCursor32();
- _gfxCompare = new GfxCompare(_gamestate->_segMan, _gfxCache, _gfxScreen, _gfxCoordAdjuster);
+ _gfxCompare = new GfxCompare(_gamestate->_segMan, _gfxCache, nullptr, _gfxCoordAdjuster);
_gfxPaint32 = new GfxPaint32(_gamestate->_segMan);
_robotDecoder = new RobotDecoder(getPlatform() == Common::kPlatformMacintosh);
_gfxTransitions32 = new GfxTransitions32(_gamestate->_segMan);
@@ -748,9 +751,8 @@ void SciEngine::initGraphics() {
_gfxFrameout->run();
} else {
#endif
- _gfxCursor = new GfxCursor(_resMan, _gfxPalette16, _gfxScreen);
-
// SCI0-SCI1.1 graphic objects creation
+ _gfxCursor = new GfxCursor(_resMan, _gfxPalette16, _gfxScreen);
_gfxPorts = new GfxPorts(_gamestate->_segMan, _gfxScreen);
_gfxCoordAdjuster = new GfxCoordAdjuster16(_gfxPorts);
_gfxCursor->init(_gfxCoordAdjuster, _eventMan);