Skip to content

Commit

Permalink
SCI: Added some hacks related to new functionality in Phantasmagoria 2
Browse files Browse the repository at this point in the history
The game will now start (but won't do anything exciting - it'll display
its main menu, which doesn't work yet)
  • Loading branch information
bluegr committed Oct 18, 2011
1 parent 021b09d commit 7708a4d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
10 changes: 10 additions & 0 deletions engines/sci/engine/klists.cpp
Expand Up @@ -691,6 +691,16 @@ reg_t kArray(EngineState *s, int argc, reg_t *argv) {
}
case 2: { // At (return value at an index)
SciArray<reg_t> *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)
Expand Down
12 changes: 12 additions & 0 deletions engines/sci/graphics/cursor.cpp
Expand Up @@ -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);

Expand Down
8 changes: 7 additions & 1 deletion engines/sci/graphics/frameout.cpp
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 7708a4d

Please sign in to comment.