From 7708a4ddbbcd7e7880890be252f5be1fa6a8eabb Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 18 Oct 2011 03:10:19 +0300 Subject: SCI: Added some hacks related to new functionality in Phantasmagoria 2 The game will now start (but won't do anything exciting - it'll display its main menu, which doesn't work yet) --- engines/sci/engine/klists.cpp | 10 ++++++++++ engines/sci/graphics/cursor.cpp | 12 ++++++++++++ engines/sci/graphics/frameout.cpp | 8 +++++++- 3 files changed, 29 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/sci/engine/klists.cpp b/engines/sci/engine/klists.cpp index 68469f5c9a..8500f08211 100644 --- a/engines/sci/engine/klists.cpp +++ b/engines/sci/engine/klists.cpp @@ -691,6 +691,16 @@ reg_t kArray(EngineState *s, int argc, reg_t *argv) { } case 2: { // At (return value at an index) SciArray *array = s->_segMan->lookupArray(argv[1]); + if (g_sci->getGameId() == GID_PHANTASMAGORIA2) { + // HACK: Phantasmagoria 2 keeps trying to access past the end of an + // array when it starts. I'm assuming it's trying to see where the + // array ends, or tries to resize it. Adjust the array size + // accordingly, and return NULL for now. + if (array->getSize() == argv[2].toUint16()) { + array->setSize(argv[2].toUint16()); + return NULL_REG; + } + } return array->getValue(argv[2].toUint16()); } case 3: { // Atput (put value at an index) diff --git a/engines/sci/graphics/cursor.cpp b/engines/sci/graphics/cursor.cpp index 57c65aa6e0..50da48aaf3 100644 --- a/engines/sci/graphics/cursor.cpp +++ b/engines/sci/graphics/cursor.cpp @@ -179,6 +179,18 @@ void GfxCursor::kernelSetView(GuiResourceId viewNum, int loopNum, int celNum, Co if (_useOriginalKQ6WinCursors) viewNum += 2000; // Windows cursors + if (g_sci->getGameId() == GID_PHANTASMAGORIA2) { + // HACK: Ignore cursor views for Phantasmagoria 2. They've got + // differences from other SCI32 views, thus we skip them for + // now, otherwise our view decoding code will crash. + // The view code will crash with *any* view in P2, but this hack + // allows the game to start and show the menu. + // TODO: Remove once the view code is updated to handle + // Phantasmagoria 2 views. + warning("TODO: Cursor views for Phantasmagoria 2"); + return; + } + if (!_cachedCursors.contains(viewNum)) _cachedCursors[viewNum] = new GfxView(_resMan, _screen, _palette, viewNum); diff --git a/engines/sci/graphics/frameout.cpp b/engines/sci/graphics/frameout.cpp index 9a44f07a60..c771b5c7a4 100644 --- a/engines/sci/graphics/frameout.cpp +++ b/engines/sci/graphics/frameout.cpp @@ -492,7 +492,6 @@ void GfxFrameout::kernelFrameout() { // warning("view %s %04x:%04x", _segMan->getObjectName(itemEntry->object), PRINT_REG(itemEntry->object)); - if (view->isSci2Hires()) { int16 dummyX = 0; view->adjustToUpscaledCoordinates(itemEntry->y, itemEntry->x); @@ -540,6 +539,13 @@ void GfxFrameout::kernelFrameout() { nsRect.right = (nsRect.right * scriptsRunningWidth) / _screen->getWidth(); } + if (g_sci->getGameId() == GID_PHANTASMAGORIA2) { + // HACK: Some (?) objects in Phantasmagoria 2 have no NS rect. Skip them for now. + // TODO: Remove once we figure out how Phantasmagoria 2 draws objects on screen. + if (lookupSelector(_segMan, itemEntry->object, SELECTOR(nsLeft), NULL, NULL) != kSelectorVariable) + continue; + } + writeSelectorValue(_segMan, itemEntry->object, SELECTOR(nsLeft), nsRect.left); writeSelectorValue(_segMan, itemEntry->object, SELECTOR(nsTop), nsRect.top); writeSelectorValue(_segMan, itemEntry->object, SELECTOR(nsRight), nsRect.right); -- cgit v1.2.3