2010-02-03 11:02:43 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2014-02-18 02:34:24 +01:00
|
|
|
*
|
2010-02-03 11:02:43 +00:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2014-02-18 02:34:24 +01:00
|
|
|
*
|
2010-02-03 11:02:43 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "sci/engine/features.h"
|
2010-06-23 15:23:37 +00:00
|
|
|
#include "sci/engine/kernel.h"
|
2010-02-03 11:02:43 +00:00
|
|
|
#include "sci/engine/script.h"
|
|
|
|
#include "sci/engine/selector.h"
|
|
|
|
#include "sci/engine/vm.h"
|
|
|
|
|
2012-03-25 16:40:49 +03:00
|
|
|
#include "common/config-manager.h"
|
2010-02-17 23:38:43 +00:00
|
|
|
#include "common/file.h"
|
|
|
|
|
2010-02-03 11:02:43 +00:00
|
|
|
namespace Sci {
|
|
|
|
|
|
|
|
GameFeatures::GameFeatures(SegManager *segMan, Kernel *kernel) : _segMan(segMan), _kernel(kernel) {
|
|
|
|
_setCursorType = SCI_VERSION_NONE;
|
|
|
|
_doSoundType = SCI_VERSION_NONE;
|
|
|
|
_lofsType = SCI_VERSION_NONE;
|
|
|
|
_gfxFunctionsType = SCI_VERSION_NONE;
|
2010-07-27 19:07:39 +00:00
|
|
|
_messageFunctionType = SCI_VERSION_NONE;
|
2010-02-03 11:02:43 +00:00
|
|
|
_moveCountType = kMoveCountUninitialized;
|
|
|
|
#ifdef ENABLE_SCI32
|
|
|
|
_sci21KernelType = SCI_VERSION_NONE;
|
|
|
|
#endif
|
|
|
|
_usesCdTrack = Common::File::exists("cdaudio.map");
|
2012-03-31 13:55:03 +03:00
|
|
|
if (!ConfMan.getBool("use_cdaudio"))
|
2012-03-25 16:40:49 +03:00
|
|
|
_usesCdTrack = false;
|
2012-04-29 20:43:04 +03:00
|
|
|
_forceDOSTracks = false;
|
2016-08-13 14:58:07 +02:00
|
|
|
_pseudoMouseAbility = kPseudoMouseAbilityUninitialized;
|
2010-02-03 11:02:43 +00:00
|
|
|
}
|
|
|
|
|
2010-02-07 12:15:59 +00:00
|
|
|
reg_t GameFeatures::getDetectionAddr(const Common::String &objName, Selector slc, int methodNum) {
|
|
|
|
// Get address of target object
|
2010-11-21 00:44:04 +00:00
|
|
|
reg_t objAddr = _segMan->findObjectByName(objName, 0);
|
2010-02-07 12:15:59 +00:00
|
|
|
reg_t addr;
|
|
|
|
|
|
|
|
if (objAddr.isNull()) {
|
2010-06-17 23:45:38 +00:00
|
|
|
error("getDetectionAddr: %s object couldn't be found", objName.c_str());
|
2010-02-07 12:15:59 +00:00
|
|
|
return NULL_REG;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (methodNum == -1) {
|
2010-05-29 23:37:15 +00:00
|
|
|
if (lookupSelector(_segMan, objAddr, slc, NULL, &addr) != kSelectorMethod) {
|
2010-06-17 23:45:38 +00:00
|
|
|
error("getDetectionAddr: target selector is not a method of object %s", objName.c_str());
|
2010-02-07 12:15:59 +00:00
|
|
|
return NULL_REG;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
addr = _segMan->getObject(objAddr)->getFunction(methodNum);
|
|
|
|
}
|
|
|
|
|
|
|
|
return addr;
|
|
|
|
}
|
|
|
|
|
2010-02-07 12:16:23 +00:00
|
|
|
bool GameFeatures::autoDetectSoundType() {
|
|
|
|
// Look up the script address
|
2010-06-10 09:18:57 +00:00
|
|
|
reg_t addr = getDetectionAddr("Sound", SELECTOR(play));
|
2010-02-03 11:02:43 +00:00
|
|
|
|
2012-06-18 05:21:59 +03:00
|
|
|
if (!addr.getSegment())
|
2010-04-24 22:02:31 +00:00
|
|
|
return false;
|
|
|
|
|
2017-05-20 19:21:24 -05:00
|
|
|
uint32 offset = addr.getOffset();
|
2012-06-18 05:21:59 +03:00
|
|
|
Script *script = _segMan->getScript(addr.getSegment());
|
2010-02-07 12:16:23 +00:00
|
|
|
uint16 intParam = 0xFFFF;
|
2010-02-07 12:15:35 +00:00
|
|
|
bool foundTarget = false;
|
2010-02-03 11:02:43 +00:00
|
|
|
|
2010-02-07 12:15:59 +00:00
|
|
|
while (true) {
|
2010-02-07 12:16:23 +00:00
|
|
|
int16 opparams[4];
|
2010-02-07 17:57:25 +00:00
|
|
|
byte extOpcode;
|
2010-02-07 12:16:23 +00:00
|
|
|
byte opcode;
|
2010-06-28 11:22:20 +00:00
|
|
|
offset += readPMachineInstruction(script->getBuf(offset), extOpcode, opparams);
|
2010-02-07 17:57:25 +00:00
|
|
|
opcode = extOpcode >> 1;
|
2010-02-07 12:15:35 +00:00
|
|
|
|
2010-02-07 12:15:59 +00:00
|
|
|
// Check for end of script
|
2010-05-30 16:14:31 +00:00
|
|
|
if (opcode == op_ret || offset >= script->getBufSize())
|
2010-02-07 12:15:59 +00:00
|
|
|
break;
|
|
|
|
|
2010-06-28 11:23:16 +00:00
|
|
|
// The play method of the Sound object pushes the DoSound command that
|
|
|
|
// it will use just before it calls DoSound. We intercept that here in
|
|
|
|
// order to check what sound semantics are used, cause the position of
|
|
|
|
// the sound commands has changed at some point during SCI1 middle.
|
2010-02-07 12:16:23 +00:00
|
|
|
if (opcode == op_pushi) {
|
|
|
|
// Load the pushi parameter
|
|
|
|
intParam = opparams[0];
|
|
|
|
} else if (opcode == op_callk) {
|
|
|
|
uint16 kFuncNum = opparams[0];
|
|
|
|
|
|
|
|
// Late SCI1 games call kIsObject before kDoSound
|
|
|
|
if (kFuncNum == 6) { // kIsObject (SCI0-SCI11)
|
|
|
|
foundTarget = true;
|
|
|
|
} else if (kFuncNum == 45) { // kDoSound (SCI1)
|
2010-06-28 11:23:16 +00:00
|
|
|
// First, check which DoSound function is called by the play
|
|
|
|
// method of the Sound object
|
2010-02-07 12:16:23 +00:00
|
|
|
switch (intParam) {
|
|
|
|
case 1:
|
|
|
|
_doSoundType = SCI_VERSION_0_EARLY;
|
|
|
|
break;
|
|
|
|
case 7:
|
|
|
|
_doSoundType = SCI_VERSION_1_EARLY;
|
|
|
|
break;
|
|
|
|
case 8:
|
|
|
|
_doSoundType = SCI_VERSION_1_LATE;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
// Unknown case... should never happen. We fall back to
|
2010-06-28 11:23:16 +00:00
|
|
|
// alternative detection here, which works in general, apart
|
|
|
|
// from some transitive games like Jones CD
|
2010-02-07 12:16:23 +00:00
|
|
|
_doSoundType = foundTarget ? SCI_VERSION_1_LATE : SCI_VERSION_1_EARLY;
|
|
|
|
break;
|
2010-02-07 12:15:35 +00:00
|
|
|
}
|
|
|
|
|
2010-02-07 12:16:23 +00:00
|
|
|
if (_doSoundType != SCI_VERSION_NONE)
|
2010-02-07 12:15:35 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2010-02-07 12:15:59 +00:00
|
|
|
}
|
2010-02-03 11:02:43 +00:00
|
|
|
|
|
|
|
return false; // not found
|
|
|
|
}
|
|
|
|
|
|
|
|
SciVersion GameFeatures::detectDoSoundType() {
|
|
|
|
if (_doSoundType == SCI_VERSION_NONE) {
|
|
|
|
if (getSciVersion() == SCI_VERSION_0_EARLY) {
|
2010-09-04 08:51:10 +00:00
|
|
|
// Almost all of the SCI0EARLY games use different sound resources than
|
|
|
|
// SCI0LATE. Although the last SCI0EARLY game (lsl2) uses SCI0LATE resources
|
|
|
|
_doSoundType = g_sci->getResMan()->detectEarlySound() ? SCI_VERSION_0_EARLY : SCI_VERSION_0_LATE;
|
2010-07-14 11:29:55 +00:00
|
|
|
#ifdef ENABLE_SCI32
|
2017-06-16 16:32:16 -05:00
|
|
|
} else if (getSciVersion() >= SCI_VERSION_2_1_MIDDLE &&
|
|
|
|
g_sci->getGameId() != GID_SQ6 &&
|
|
|
|
// Assuming MGDX uses SCI2.1early sound mode since SQ6 does
|
|
|
|
// and it was released earlier, but not verified (Phar Lap
|
|
|
|
// Windows-only release)
|
|
|
|
g_sci->getGameId() != GID_MOTHERGOOSEHIRES) {
|
|
|
|
_doSoundType = SCI_VERSION_2_1_MIDDLE;
|
2015-12-29 01:44:11 +01:00
|
|
|
} else if (getSciVersion() >= SCI_VERSION_2_1_EARLY) {
|
|
|
|
_doSoundType = SCI_VERSION_2_1_EARLY;
|
2017-06-16 16:32:16 -05:00
|
|
|
} else if (getSciVersion() >= SCI_VERSION_2) {
|
|
|
|
_doSoundType = SCI_VERSION_2;
|
2010-07-14 11:29:55 +00:00
|
|
|
#endif
|
2010-06-10 09:18:57 +00:00
|
|
|
} else if (SELECTOR(nodePtr) == -1) {
|
2010-02-03 11:02:43 +00:00
|
|
|
// No nodePtr selector, so this game is definitely using newer
|
|
|
|
// SCI0 sound code (i.e. SCI_VERSION_0_LATE)
|
|
|
|
_doSoundType = SCI_VERSION_0_LATE;
|
2010-02-07 12:16:45 +00:00
|
|
|
} else if (getSciVersion() >= SCI_VERSION_1_LATE) {
|
|
|
|
// All SCI1 late games use the newer doSound semantics
|
|
|
|
_doSoundType = SCI_VERSION_1_LATE;
|
2010-02-03 11:02:43 +00:00
|
|
|
} else {
|
2010-02-07 12:16:45 +00:00
|
|
|
if (!autoDetectSoundType()) {
|
|
|
|
warning("DoSound detection failed, taking an educated guess");
|
|
|
|
|
|
|
|
if (getSciVersion() >= SCI_VERSION_1_MIDDLE)
|
|
|
|
_doSoundType = SCI_VERSION_1_LATE;
|
|
|
|
else if (getSciVersion() > SCI_VERSION_01)
|
|
|
|
_doSoundType = SCI_VERSION_1_EARLY;
|
2010-02-03 11:02:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-02-13 11:58:15 +00:00
|
|
|
debugC(1, kDebugLevelSound, "Detected DoSound type: %s", getSciVersionDesc(_doSoundType));
|
2010-02-03 11:02:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return _doSoundType;
|
|
|
|
}
|
|
|
|
|
|
|
|
SciVersion GameFeatures::detectSetCursorType() {
|
|
|
|
if (_setCursorType == SCI_VERSION_NONE) {
|
2010-02-07 02:53:07 +00:00
|
|
|
if (getSciVersion() <= SCI_VERSION_1_MIDDLE) {
|
|
|
|
// SCI1 middle and older games never use cursor views
|
2010-02-03 11:02:43 +00:00
|
|
|
_setCursorType = SCI_VERSION_0_EARLY;
|
|
|
|
} else if (getSciVersion() >= SCI_VERSION_1_1) {
|
|
|
|
// SCI1.1 games always use cursor views
|
|
|
|
_setCursorType = SCI_VERSION_1_1;
|
|
|
|
} else { // SCI1 late game, detect cursor semantics
|
2010-06-28 11:23:16 +00:00
|
|
|
// If the Cursor object doesn't exist, we're using the SCI0 early
|
|
|
|
// kSetCursor semantics.
|
2010-02-07 02:53:07 +00:00
|
|
|
if (_segMan->findObjectByName("Cursor") == NULL_REG) {
|
|
|
|
_setCursorType = SCI_VERSION_0_EARLY;
|
2010-02-13 11:58:15 +00:00
|
|
|
debugC(1, kDebugLevelGraphics, "Detected SetCursor type: %s", getSciVersionDesc(_setCursorType));
|
2010-02-07 02:53:07 +00:00
|
|
|
return _setCursorType;
|
|
|
|
}
|
2010-02-03 11:02:43 +00:00
|
|
|
|
2010-06-28 11:23:16 +00:00
|
|
|
// Check for the existence of the handCursor object (first found).
|
|
|
|
// This is based on KQ5.
|
2010-02-07 02:53:07 +00:00
|
|
|
reg_t objAddr = _segMan->findObjectByName("handCursor", 0);
|
2010-02-03 11:02:43 +00:00
|
|
|
|
2010-02-07 02:53:07 +00:00
|
|
|
// If that doesn't exist, we assume it uses SCI1.1 kSetCursor semantics
|
|
|
|
if (objAddr == NULL_REG) {
|
|
|
|
_setCursorType = SCI_VERSION_1_1;
|
2010-02-13 11:58:15 +00:00
|
|
|
debugC(1, kDebugLevelGraphics, "Detected SetCursor type: %s", getSciVersionDesc(_setCursorType));
|
2010-02-07 02:53:07 +00:00
|
|
|
return _setCursorType;
|
2010-02-03 11:02:43 +00:00
|
|
|
}
|
|
|
|
|
2010-06-28 11:23:16 +00:00
|
|
|
// Now we check what the number variable holds in the handCursor
|
|
|
|
// object.
|
2010-05-29 23:37:15 +00:00
|
|
|
uint16 number = readSelectorValue(_segMan, objAddr, SELECTOR(number));
|
2010-02-03 11:02:43 +00:00
|
|
|
|
2010-06-28 11:23:16 +00:00
|
|
|
// If the number is 0, it uses views and therefore the SCI1.1
|
|
|
|
// kSetCursor semantics, otherwise it uses the SCI0 early kSetCursor
|
|
|
|
// semantics.
|
2010-02-07 02:53:07 +00:00
|
|
|
if (number == 0)
|
|
|
|
_setCursorType = SCI_VERSION_1_1;
|
|
|
|
else
|
|
|
|
_setCursorType = SCI_VERSION_0_EARLY;
|
2010-02-03 11:02:43 +00:00
|
|
|
}
|
|
|
|
|
2010-02-13 11:58:15 +00:00
|
|
|
debugC(1, kDebugLevelGraphics, "Detected SetCursor type: %s", getSciVersionDesc(_setCursorType));
|
2010-02-03 11:02:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return _setCursorType;
|
|
|
|
}
|
|
|
|
|
2010-07-31 22:45:38 +00:00
|
|
|
bool GameFeatures::autoDetectLofsType(Common::String gameSuperClassName, int methodNum) {
|
2010-02-07 12:16:23 +00:00
|
|
|
// Look up the script address
|
2010-07-31 22:45:38 +00:00
|
|
|
reg_t addr = getDetectionAddr(gameSuperClassName.c_str(), -1, methodNum);
|
2010-02-07 12:16:23 +00:00
|
|
|
|
2012-06-18 05:21:59 +03:00
|
|
|
if (!addr.getSegment())
|
2010-04-24 22:02:31 +00:00
|
|
|
return false;
|
|
|
|
|
2017-05-20 19:21:24 -05:00
|
|
|
uint32 offset = addr.getOffset();
|
2012-06-18 05:21:59 +03:00
|
|
|
Script *script = _segMan->getScript(addr.getSegment());
|
2010-02-07 12:16:23 +00:00
|
|
|
|
|
|
|
while (true) {
|
|
|
|
int16 opparams[4];
|
2010-02-07 17:57:25 +00:00
|
|
|
byte extOpcode;
|
2010-02-07 12:16:23 +00:00
|
|
|
byte opcode;
|
2010-06-28 11:22:20 +00:00
|
|
|
offset += readPMachineInstruction(script->getBuf(offset), extOpcode, opparams);
|
2010-02-07 17:57:25 +00:00
|
|
|
opcode = extOpcode >> 1;
|
2010-02-07 12:16:23 +00:00
|
|
|
|
|
|
|
// Check for end of script
|
2010-05-30 16:14:31 +00:00
|
|
|
if (opcode == op_ret || offset >= script->getBufSize())
|
2010-02-07 12:16:23 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
if (opcode == op_lofsa || opcode == op_lofss) {
|
|
|
|
// Load lofs operand
|
|
|
|
uint16 lofs = opparams[0];
|
|
|
|
|
|
|
|
// Check for going out of bounds when interpreting as abs/rel
|
2010-05-30 16:14:31 +00:00
|
|
|
if (lofs >= script->getBufSize())
|
2010-02-07 12:16:23 +00:00
|
|
|
_lofsType = SCI_VERSION_0_EARLY;
|
|
|
|
|
|
|
|
if ((signed)offset + (int16)lofs < 0)
|
|
|
|
_lofsType = SCI_VERSION_1_MIDDLE;
|
|
|
|
|
2010-05-30 16:14:31 +00:00
|
|
|
if ((signed)offset + (int16)lofs >= (signed)script->getBufSize())
|
2010-02-07 12:16:23 +00:00
|
|
|
_lofsType = SCI_VERSION_1_MIDDLE;
|
|
|
|
|
|
|
|
if (_lofsType != SCI_VERSION_NONE)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
// If we reach here, we haven't been able to deduce the lofs
|
|
|
|
// parameter type so far.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false; // not found
|
|
|
|
}
|
|
|
|
|
2010-02-03 11:02:43 +00:00
|
|
|
SciVersion GameFeatures::detectLofsType() {
|
|
|
|
if (_lofsType == SCI_VERSION_NONE) {
|
|
|
|
// This detection only works (and is only needed) for SCI 1
|
|
|
|
if (getSciVersion() <= SCI_VERSION_01) {
|
|
|
|
_lofsType = SCI_VERSION_0_EARLY;
|
|
|
|
return _lofsType;
|
|
|
|
}
|
|
|
|
|
2015-12-29 01:44:11 +01:00
|
|
|
if (getSciVersion() >= SCI_VERSION_1_1 && getSciVersion() <= SCI_VERSION_2_1_LATE) {
|
2010-11-17 14:28:32 +00:00
|
|
|
// SCI1.1 type, i.e. we compensate for the fact that the heap is attached
|
|
|
|
// to the end of the script
|
2010-02-03 11:02:43 +00:00
|
|
|
_lofsType = SCI_VERSION_1_1;
|
|
|
|
return _lofsType;
|
2010-11-17 14:28:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (getSciVersion() == SCI_VERSION_3) {
|
|
|
|
// SCI3 type, same as pre-SCI1.1, really, as there is no separate heap
|
|
|
|
// resource
|
|
|
|
_lofsType = SCI_VERSION_3;
|
|
|
|
return _lofsType;
|
2010-02-03 11:02:43 +00:00
|
|
|
}
|
|
|
|
|
2010-08-23 20:29:13 +00:00
|
|
|
// Find a function of the "Game" object (which is the game super class) which invokes lofsa/lofss
|
2011-02-28 00:15:47 +02:00
|
|
|
const Object *gameObject = _segMan->getObject(g_sci->getGameObject());
|
|
|
|
const Object *gameSuperObject = _segMan->getObject(gameObject->getSuperClassSelector());
|
2010-02-03 11:02:43 +00:00
|
|
|
bool found = false;
|
2011-02-28 00:15:47 +02:00
|
|
|
if (gameSuperObject) {
|
|
|
|
Common::String gameSuperClassName = _segMan->getObjectName(gameObject->getSuperClassSelector());
|
|
|
|
|
|
|
|
for (uint m = 0; m < gameSuperObject->getMethodCount(); m++) {
|
|
|
|
found = autoDetectLofsType(gameSuperClassName, m);
|
|
|
|
if (found)
|
|
|
|
break;
|
2010-07-31 22:45:38 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
warning("detectLofsType(): Could not find superclass of game object");
|
2010-02-03 11:02:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!found) {
|
2010-07-31 22:45:38 +00:00
|
|
|
warning("detectLofsType(): failed, taking an educated guess");
|
2010-02-03 11:02:43 +00:00
|
|
|
|
|
|
|
if (getSciVersion() >= SCI_VERSION_1_MIDDLE)
|
|
|
|
_lofsType = SCI_VERSION_1_MIDDLE;
|
|
|
|
else
|
|
|
|
_lofsType = SCI_VERSION_0_EARLY;
|
|
|
|
}
|
|
|
|
|
2010-02-13 11:58:15 +00:00
|
|
|
debugC(1, kDebugLevelVM, "Detected Lofs type: %s", getSciVersionDesc(_lofsType));
|
2010-02-03 11:02:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return _lofsType;
|
|
|
|
}
|
|
|
|
|
2010-02-07 12:16:23 +00:00
|
|
|
bool GameFeatures::autoDetectGfxFunctionsType(int methodNum) {
|
|
|
|
// Look up the script address
|
2010-06-10 09:18:57 +00:00
|
|
|
reg_t addr = getDetectionAddr("Rm", SELECTOR(overlay), methodNum);
|
2010-02-07 12:16:23 +00:00
|
|
|
|
2012-06-18 05:21:59 +03:00
|
|
|
if (!addr.getSegment())
|
2010-04-24 22:02:31 +00:00
|
|
|
return false;
|
|
|
|
|
2017-05-20 19:21:24 -05:00
|
|
|
uint32 offset = addr.getOffset();
|
2012-06-18 05:21:59 +03:00
|
|
|
Script *script = _segMan->getScript(addr.getSegment());
|
2010-02-07 12:16:23 +00:00
|
|
|
|
|
|
|
while (true) {
|
|
|
|
int16 opparams[4];
|
2010-02-07 17:57:25 +00:00
|
|
|
byte extOpcode;
|
2010-02-07 12:16:23 +00:00
|
|
|
byte opcode;
|
2010-06-28 11:22:20 +00:00
|
|
|
offset += readPMachineInstruction(script->getBuf(offset), extOpcode, opparams);
|
2010-02-07 17:57:25 +00:00
|
|
|
opcode = extOpcode >> 1;
|
2010-02-07 12:16:23 +00:00
|
|
|
|
|
|
|
// Check for end of script
|
2010-05-30 16:14:31 +00:00
|
|
|
if (opcode == op_ret || offset >= script->getBufSize())
|
2010-02-07 12:16:23 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
if (opcode == op_callk) {
|
|
|
|
uint16 kFuncNum = opparams[0];
|
|
|
|
uint16 argc = opparams[1];
|
|
|
|
|
|
|
|
if (kFuncNum == 8) { // kDrawPic (SCI0 - SCI11)
|
2010-06-28 11:23:16 +00:00
|
|
|
// If kDrawPic is called with 6 parameters from the overlay
|
|
|
|
// selector, the game is using old graphics functions.
|
2014-08-08 02:51:57 +03:00
|
|
|
// Otherwise, if it's called with 8 parameters (e.g. SQ3) or 4 parameters
|
|
|
|
// (e.g. Hoyle 1/2), it's using new graphics functions.
|
|
|
|
_gfxFunctionsType = (argc == 6) ? SCI_VERSION_0_EARLY : SCI_VERSION_0_LATE;
|
2010-02-07 12:16:23 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false; // not found
|
|
|
|
}
|
|
|
|
|
2010-02-03 11:02:43 +00:00
|
|
|
SciVersion GameFeatures::detectGfxFunctionsType() {
|
|
|
|
if (_gfxFunctionsType == SCI_VERSION_NONE) {
|
2010-05-28 12:36:47 +00:00
|
|
|
if (getSciVersion() == SCI_VERSION_0_EARLY) {
|
|
|
|
// Old SCI0 games always used old graphics functions
|
|
|
|
_gfxFunctionsType = SCI_VERSION_0_EARLY;
|
|
|
|
} else if (getSciVersion() >= SCI_VERSION_01) {
|
|
|
|
// SCI01 and newer games always used new graphics functions
|
2010-02-03 11:02:43 +00:00
|
|
|
_gfxFunctionsType = SCI_VERSION_0_LATE;
|
2010-05-28 12:36:47 +00:00
|
|
|
} else { // SCI0 late
|
2010-02-03 11:02:43 +00:00
|
|
|
// Check if the game is using an overlay
|
2010-05-28 12:36:47 +00:00
|
|
|
bool searchRoomObj = false;
|
2010-05-31 07:34:18 +00:00
|
|
|
reg_t rmObjAddr = _segMan->findObjectByName("Rm");
|
2010-05-28 12:36:47 +00:00
|
|
|
|
2010-06-10 09:18:57 +00:00
|
|
|
if (SELECTOR(overlay) != -1) {
|
2010-06-28 11:23:16 +00:00
|
|
|
// The game has an overlay selector, check how it calls kDrawPic
|
|
|
|
// to determine the graphics functions type used
|
2010-06-10 09:18:57 +00:00
|
|
|
if (lookupSelector(_segMan, rmObjAddr, SELECTOR(overlay), NULL, NULL) == kSelectorMethod) {
|
2010-05-28 12:36:47 +00:00
|
|
|
if (!autoDetectGfxFunctionsType()) {
|
|
|
|
warning("Graphics functions detection failed, taking an educated guess");
|
|
|
|
|
2010-06-28 11:23:16 +00:00
|
|
|
// Try detecting the graphics function types from the
|
|
|
|
// existence of the motionCue selector (which is a bit
|
|
|
|
// of a hack)
|
2010-05-28 12:36:47 +00:00
|
|
|
if (_kernel->findSelector("motionCue") != -1)
|
|
|
|
_gfxFunctionsType = SCI_VERSION_0_LATE;
|
|
|
|
else
|
|
|
|
_gfxFunctionsType = SCI_VERSION_0_EARLY;
|
|
|
|
}
|
|
|
|
} else {
|
2010-06-28 11:23:16 +00:00
|
|
|
// The game has an overlay selector, but it's not a method
|
|
|
|
// of the Rm object (like in Hoyle 1 and 2), so search for
|
|
|
|
// other methods
|
2010-05-28 12:36:47 +00:00
|
|
|
searchRoomObj = true;
|
|
|
|
}
|
|
|
|
} else {
|
2010-06-28 11:23:16 +00:00
|
|
|
// The game doesn't have an overlay selector, so search for it
|
|
|
|
// manually
|
2010-05-28 12:36:47 +00:00
|
|
|
searchRoomObj = true;
|
|
|
|
}
|
2010-02-03 11:02:43 +00:00
|
|
|
|
2010-05-28 12:36:47 +00:00
|
|
|
if (searchRoomObj) {
|
2010-06-28 11:23:16 +00:00
|
|
|
// If requested, check if any method of the Rm object is calling
|
|
|
|
// kDrawPic, as the overlay selector might be missing in demos
|
2010-05-28 12:36:47 +00:00
|
|
|
bool found = false;
|
2010-02-03 11:02:43 +00:00
|
|
|
|
2010-05-31 07:34:18 +00:00
|
|
|
const Object *obj = _segMan->getObject(rmObjAddr);
|
2010-02-03 11:02:43 +00:00
|
|
|
for (uint m = 0; m < obj->getMethodCount(); m++) {
|
2010-02-07 12:16:23 +00:00
|
|
|
found = autoDetectGfxFunctionsType(m);
|
2010-02-03 11:02:43 +00:00
|
|
|
if (found)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-02-07 12:16:45 +00:00
|
|
|
if (!found) {
|
2010-06-28 11:23:16 +00:00
|
|
|
// No method of the Rm object is calling kDrawPic, thus the
|
|
|
|
// game doesn't have overlays and is using older graphics
|
|
|
|
// functions
|
2010-02-07 12:16:45 +00:00
|
|
|
_gfxFunctionsType = SCI_VERSION_0_EARLY;
|
|
|
|
}
|
2010-02-03 11:02:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-02-13 11:58:15 +00:00
|
|
|
debugC(1, kDebugLevelVM, "Detected graphics functions type: %s", getSciVersionDesc(_gfxFunctionsType));
|
2010-02-03 11:02:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return _gfxFunctionsType;
|
|
|
|
}
|
|
|
|
|
2010-07-27 19:07:39 +00:00
|
|
|
SciVersion GameFeatures::detectMessageFunctionType() {
|
|
|
|
if (_messageFunctionType != SCI_VERSION_NONE)
|
|
|
|
return _messageFunctionType;
|
|
|
|
|
|
|
|
if (getSciVersion() > SCI_VERSION_1_1) {
|
|
|
|
_messageFunctionType = SCI_VERSION_1_1;
|
|
|
|
return _messageFunctionType;
|
|
|
|
} else if (getSciVersion() < SCI_VERSION_1_1) {
|
|
|
|
_messageFunctionType = SCI_VERSION_1_LATE;
|
|
|
|
return _messageFunctionType;
|
|
|
|
}
|
|
|
|
|
2012-01-15 18:25:00 +01:00
|
|
|
Common::List<ResourceId> resources = g_sci->getResMan()->listResources(kResourceTypeMessage, -1);
|
2010-08-02 22:27:26 +00:00
|
|
|
|
2012-01-15 18:25:00 +01:00
|
|
|
if (resources.empty()) {
|
2010-07-27 19:07:39 +00:00
|
|
|
// No messages found, so this doesn't really matter anyway...
|
|
|
|
_messageFunctionType = SCI_VERSION_1_1;
|
|
|
|
return _messageFunctionType;
|
|
|
|
}
|
|
|
|
|
2012-01-15 18:25:00 +01:00
|
|
|
Resource *res = g_sci->getResMan()->findResource(*resources.begin(), false);
|
2010-07-27 19:07:39 +00:00
|
|
|
assert(res);
|
|
|
|
|
|
|
|
// Only v2 Message resources use the kGetMessage kernel function.
|
|
|
|
// v3-v5 use the kMessage kernel function.
|
|
|
|
|
2016-12-31 20:39:57 -06:00
|
|
|
if (res->getUint32SEAt(0) / 1000 == 2)
|
2010-07-27 19:07:39 +00:00
|
|
|
_messageFunctionType = SCI_VERSION_1_LATE;
|
|
|
|
else
|
|
|
|
_messageFunctionType = SCI_VERSION_1_1;
|
|
|
|
|
|
|
|
debugC(1, kDebugLevelVM, "Detected message function type: %s", getSciVersionDesc(_messageFunctionType));
|
|
|
|
return _messageFunctionType;
|
|
|
|
}
|
|
|
|
|
2010-02-03 11:02:43 +00:00
|
|
|
#ifdef ENABLE_SCI32
|
2010-02-07 12:16:23 +00:00
|
|
|
bool GameFeatures::autoDetectSci21KernelType() {
|
2010-07-01 21:08:38 +00:00
|
|
|
// First, check if the Sound object is loaded
|
|
|
|
reg_t soundObjAddr = _segMan->findObjectByName("Sound");
|
|
|
|
if (soundObjAddr.isNull()) {
|
|
|
|
// Usually, this means that the Sound object isn't loaded yet.
|
|
|
|
// This case doesn't occur in early SCI2.1 games, and we've only
|
|
|
|
// seen it happen in the RAMA demo, thus we can assume that the
|
|
|
|
// game is using a SCI2.1 table
|
2012-10-22 12:19:13 +03:00
|
|
|
|
2013-08-20 19:43:05 +03:00
|
|
|
// HACK: The Inside the Chest Demo and King's Questions minigame
|
|
|
|
// don't have sounds at all, but they're using a SCI2 kernel
|
|
|
|
if (g_sci->getGameId() == GID_CHEST || g_sci->getGameId() == GID_KQUESTIONS) {
|
2012-10-22 12:19:13 +03:00
|
|
|
_sci21KernelType = SCI_VERSION_2;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-07-01 21:08:38 +00:00
|
|
|
warning("autoDetectSci21KernelType(): Sound object not loaded, assuming a SCI2.1 table");
|
2015-12-29 01:44:11 +01:00
|
|
|
_sci21KernelType = SCI_VERSION_2_1_EARLY;
|
2010-07-01 21:08:38 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-02-07 12:16:23 +00:00
|
|
|
// Look up the script address
|
2010-06-10 09:18:57 +00:00
|
|
|
reg_t addr = getDetectionAddr("Sound", SELECTOR(play));
|
2010-02-07 12:16:23 +00:00
|
|
|
|
2012-06-18 05:21:59 +03:00
|
|
|
if (!addr.getSegment())
|
2010-04-24 22:02:31 +00:00
|
|
|
return false;
|
|
|
|
|
2017-05-20 19:21:24 -05:00
|
|
|
uint32 offset = addr.getOffset();
|
2012-06-18 05:21:59 +03:00
|
|
|
Script *script = _segMan->getScript(addr.getSegment());
|
2010-02-07 12:16:23 +00:00
|
|
|
|
|
|
|
while (true) {
|
|
|
|
int16 opparams[4];
|
2010-02-07 17:57:25 +00:00
|
|
|
byte extOpcode;
|
2010-02-07 12:16:23 +00:00
|
|
|
byte opcode;
|
2010-06-28 11:22:20 +00:00
|
|
|
offset += readPMachineInstruction(script->getBuf(offset), extOpcode, opparams);
|
2010-02-07 17:57:25 +00:00
|
|
|
opcode = extOpcode >> 1;
|
2010-02-07 12:16:23 +00:00
|
|
|
|
|
|
|
// Check for end of script
|
2013-04-28 13:42:50 -04:00
|
|
|
// We don't check for op_ret here because the Phantasmagoria Mac script
|
|
|
|
// has an op_ret early on in its script (controlled by a branch).
|
|
|
|
if (offset >= script->getBufSize())
|
2010-02-07 12:16:23 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
if (opcode == op_callk) {
|
|
|
|
uint16 kFuncNum = opparams[0];
|
|
|
|
|
2010-02-07 17:18:14 +00:00
|
|
|
// Here we check for the kDoSound opcode that's used in SCI2.1.
|
2010-06-28 11:23:16 +00:00
|
|
|
// Finding 0x40 as kDoSound in the Sound::play() function means the
|
|
|
|
// game is using the modified SCI2 kernel table found in some older
|
|
|
|
// SCI2.1 games (GK2 demo, KQ7 v1.4).
|
|
|
|
// Finding 0x75 as kDoSound means the game is using the regular
|
|
|
|
// SCI2.1 kernel table.
|
2010-02-07 12:16:23 +00:00
|
|
|
if (kFuncNum == 0x40) {
|
|
|
|
_sci21KernelType = SCI_VERSION_2;
|
|
|
|
return true;
|
|
|
|
} else if (kFuncNum == 0x75) {
|
2015-12-29 01:44:11 +01:00
|
|
|
_sci21KernelType = SCI_VERSION_2_1_EARLY;
|
2010-02-07 12:16:23 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false; // not found
|
|
|
|
}
|
|
|
|
|
2010-02-03 11:02:43 +00:00
|
|
|
SciVersion GameFeatures::detectSci21KernelType() {
|
2010-02-07 12:16:45 +00:00
|
|
|
if (_sci21KernelType == SCI_VERSION_NONE) {
|
2010-02-07 12:16:23 +00:00
|
|
|
if (!autoDetectSci21KernelType())
|
2010-02-03 11:02:43 +00:00
|
|
|
error("Could not detect the SCI2.1 kernel table type");
|
|
|
|
|
2010-02-13 11:58:15 +00:00
|
|
|
debugC(1, kDebugLevelVM, "Detected SCI2.1 kernel type: %s", getSciVersionDesc(_sci21KernelType));
|
2010-02-07 12:16:45 +00:00
|
|
|
}
|
2010-02-03 11:02:43 +00:00
|
|
|
return _sci21KernelType;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
SCI: Improve audio volume & settings sync code
This patch includes enhancements to the ScummVM integration with
SCI engine, with particular focus on SCI32 support.
1. Fixes audio volumes syncing erroneously to ScummVM in games
that modify the audio volume without user action (e.g. SCI1.1
talkies that reduce music volume during speech playback). Now,
volumes will only be synchronised when the user interacts with
the game's audio settings. This mechanism works by looking for
a known volume control object in the stack, and only syncing
when the control object is present. (Ports and planes were
researched and found unreliable.)
2. Fixes audio syncing in SCI32 games that do not set game
volumes through kDoSoundMasterVolume/kDoAudioVolume, like GK1,
GK2, Phant1, and Torin.
3. Fixes speech/subtitles syncing in SCI32 games that do not use
global 90, like LSL6hires.
4. Fixes in-game volume controls in SCI32 games reflecting
outdated audio volumes when a change is made during the game
from the ScummVM launcher.
5. Fixes SCI32 games that would restore volumes from save games
or reset volumes on startup, which caused game volumes to be
out-of-sync with ScummVM when started.
6. ScummVM integration code for audio sync has been abstracted
into a new GuestAdditions class. This keeps the ScummVM-
specific code all in one place, with only small hooks into the
engine code. ScummVM integrated save/load code should probably
also go here in the future.
Fixes Trac#9700.
2017-01-26 13:18:41 -06:00
|
|
|
bool GameFeatures::supportsSpeechWithSubtitles() const {
|
|
|
|
switch (g_sci->getGameId()) {
|
|
|
|
case GID_SQ4:
|
|
|
|
case GID_FREDDYPHARKAS:
|
|
|
|
case GID_ECOQUEST:
|
|
|
|
case GID_LSL6:
|
|
|
|
case GID_LAURABOW2:
|
|
|
|
case GID_KQ6:
|
|
|
|
#ifdef ENABLE_SCI32
|
|
|
|
// TODO: Hoyle5, SCI3
|
|
|
|
case GID_GK1:
|
|
|
|
case GID_KQ7:
|
|
|
|
case GID_LSL6HIRES:
|
|
|
|
case GID_PQ4:
|
|
|
|
case GID_QFG4:
|
|
|
|
case GID_SQ6:
|
|
|
|
case GID_TORIN:
|
|
|
|
#endif
|
|
|
|
return true;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool GameFeatures::audioVolumeSyncUsesGlobals() const {
|
|
|
|
switch (g_sci->getGameId()) {
|
|
|
|
case GID_GK1:
|
|
|
|
case GID_GK2:
|
|
|
|
case GID_LSL6HIRES:
|
|
|
|
case GID_PHANTASMAGORIA:
|
|
|
|
case GID_TORIN:
|
|
|
|
// TODO: SCI3
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
MessageTypeSyncStrategy GameFeatures::getMessageTypeSyncStrategy() const {
|
|
|
|
if (getSciVersion() < SCI_VERSION_1_1) {
|
|
|
|
return kMessageTypeSyncStrategyNone;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (getSciVersion() == SCI_VERSION_1_1 && g_sci->isCD()) {
|
|
|
|
return kMessageTypeSyncStrategyDefault;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef ENABLE_SCI32
|
|
|
|
switch (g_sci->getGameId()) {
|
|
|
|
// TODO: Hoyle5, SCI3
|
|
|
|
case GID_GK1:
|
2017-05-05 23:24:20 -05:00
|
|
|
case GID_PQ4:
|
|
|
|
case GID_QFG4:
|
|
|
|
return g_sci->isCD() ? kMessageTypeSyncStrategyDefault : kMessageTypeSyncStrategyNone;
|
|
|
|
|
SCI: Improve audio volume & settings sync code
This patch includes enhancements to the ScummVM integration with
SCI engine, with particular focus on SCI32 support.
1. Fixes audio volumes syncing erroneously to ScummVM in games
that modify the audio volume without user action (e.g. SCI1.1
talkies that reduce music volume during speech playback). Now,
volumes will only be synchronised when the user interacts with
the game's audio settings. This mechanism works by looking for
a known volume control object in the stack, and only syncing
when the control object is present. (Ports and planes were
researched and found unreliable.)
2. Fixes audio syncing in SCI32 games that do not set game
volumes through kDoSoundMasterVolume/kDoAudioVolume, like GK1,
GK2, Phant1, and Torin.
3. Fixes speech/subtitles syncing in SCI32 games that do not use
global 90, like LSL6hires.
4. Fixes in-game volume controls in SCI32 games reflecting
outdated audio volumes when a change is made during the game
from the ScummVM launcher.
5. Fixes SCI32 games that would restore volumes from save games
or reset volumes on startup, which caused game volumes to be
out-of-sync with ScummVM when started.
6. ScummVM integration code for audio sync has been abstracted
into a new GuestAdditions class. This keeps the ScummVM-
specific code all in one place, with only small hooks into the
engine code. ScummVM integrated save/load code should probably
also go here in the future.
Fixes Trac#9700.
2017-01-26 13:18:41 -06:00
|
|
|
case GID_KQ7:
|
|
|
|
case GID_MOTHERGOOSEHIRES:
|
|
|
|
case GID_PHANTASMAGORIA:
|
2017-05-05 23:24:20 -05:00
|
|
|
case GID_SQ6:
|
SCI: Improve audio volume & settings sync code
This patch includes enhancements to the ScummVM integration with
SCI engine, with particular focus on SCI32 support.
1. Fixes audio volumes syncing erroneously to ScummVM in games
that modify the audio volume without user action (e.g. SCI1.1
talkies that reduce music volume during speech playback). Now,
volumes will only be synchronised when the user interacts with
the game's audio settings. This mechanism works by looking for
a known volume control object in the stack, and only syncing
when the control object is present. (Ports and planes were
researched and found unreliable.)
2. Fixes audio syncing in SCI32 games that do not set game
volumes through kDoSoundMasterVolume/kDoAudioVolume, like GK1,
GK2, Phant1, and Torin.
3. Fixes speech/subtitles syncing in SCI32 games that do not use
global 90, like LSL6hires.
4. Fixes in-game volume controls in SCI32 games reflecting
outdated audio volumes when a change is made during the game
from the ScummVM launcher.
5. Fixes SCI32 games that would restore volumes from save games
or reset volumes on startup, which caused game volumes to be
out-of-sync with ScummVM when started.
6. ScummVM integration code for audio sync has been abstracted
into a new GuestAdditions class. This keeps the ScummVM-
specific code all in one place, with only small hooks into the
engine code. ScummVM integrated save/load code should probably
also go here in the future.
Fixes Trac#9700.
2017-01-26 13:18:41 -06:00
|
|
|
case GID_TORIN:
|
|
|
|
return kMessageTypeSyncStrategyDefault;
|
|
|
|
|
|
|
|
case GID_LSL6HIRES:
|
|
|
|
return kMessageTypeSyncStrategyLSL6Hires;
|
|
|
|
|
|
|
|
case GID_SHIVERS:
|
|
|
|
return kMessageTypeSyncStrategyShivers;
|
|
|
|
|
2017-05-05 23:24:20 -05:00
|
|
|
case GID_GK2:
|
|
|
|
case GID_PQSWAT:
|
SCI: Improve audio volume & settings sync code
This patch includes enhancements to the ScummVM integration with
SCI engine, with particular focus on SCI32 support.
1. Fixes audio volumes syncing erroneously to ScummVM in games
that modify the audio volume without user action (e.g. SCI1.1
talkies that reduce music volume during speech playback). Now,
volumes will only be synchronised when the user interacts with
the game's audio settings. This mechanism works by looking for
a known volume control object in the stack, and only syncing
when the control object is present. (Ports and planes were
researched and found unreliable.)
2. Fixes audio syncing in SCI32 games that do not set game
volumes through kDoSoundMasterVolume/kDoAudioVolume, like GK1,
GK2, Phant1, and Torin.
3. Fixes speech/subtitles syncing in SCI32 games that do not use
global 90, like LSL6hires.
4. Fixes in-game volume controls in SCI32 games reflecting
outdated audio volumes when a change is made during the game
from the ScummVM launcher.
5. Fixes SCI32 games that would restore volumes from save games
or reset volumes on startup, which caused game volumes to be
out-of-sync with ScummVM when started.
6. ScummVM integration code for audio sync has been abstracted
into a new GuestAdditions class. This keeps the ScummVM-
specific code all in one place, with only small hooks into the
engine code. ScummVM integrated save/load code should probably
also go here in the future.
Fixes Trac#9700.
2017-01-26 13:18:41 -06:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return kMessageTypeSyncStrategyNone;
|
|
|
|
}
|
|
|
|
|
2010-02-07 12:16:23 +00:00
|
|
|
bool GameFeatures::autoDetectMoveCountType() {
|
|
|
|
// Look up the script address
|
2010-06-10 09:18:57 +00:00
|
|
|
reg_t addr = getDetectionAddr("Motion", SELECTOR(doit));
|
2010-02-07 12:16:23 +00:00
|
|
|
|
2012-06-18 05:21:59 +03:00
|
|
|
if (!addr.getSegment())
|
2010-04-24 22:02:31 +00:00
|
|
|
return false;
|
|
|
|
|
2017-05-20 19:21:24 -05:00
|
|
|
uint32 offset = addr.getOffset();
|
2012-06-18 05:21:59 +03:00
|
|
|
Script *script = _segMan->getScript(addr.getSegment());
|
2010-02-07 12:16:23 +00:00
|
|
|
bool foundTarget = false;
|
|
|
|
|
|
|
|
while (true) {
|
|
|
|
int16 opparams[4];
|
2010-02-07 17:57:25 +00:00
|
|
|
byte extOpcode;
|
2010-02-07 12:16:23 +00:00
|
|
|
byte opcode;
|
2010-06-28 11:22:20 +00:00
|
|
|
offset += readPMachineInstruction(script->getBuf(offset), extOpcode, opparams);
|
2010-02-07 17:57:25 +00:00
|
|
|
opcode = extOpcode >> 1;
|
2010-02-07 12:16:23 +00:00
|
|
|
|
|
|
|
// Check for end of script
|
2010-05-30 16:14:31 +00:00
|
|
|
if (opcode == op_ret || offset >= script->getBufSize())
|
2010-02-07 12:16:23 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
if (opcode == op_callk) {
|
|
|
|
uint16 kFuncNum = opparams[0];
|
|
|
|
|
|
|
|
// Games which ignore move count call kAbs before calling kDoBresen
|
|
|
|
if (_kernel->getKernelName(kFuncNum) == "Abs") {
|
|
|
|
foundTarget = true;
|
|
|
|
} else if (_kernel->getKernelName(kFuncNum) == "DoBresen") {
|
|
|
|
_moveCountType = foundTarget ? kIgnoreMoveCount : kIncrementMoveCount;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false; // not found
|
|
|
|
}
|
|
|
|
|
2010-02-03 11:02:43 +00:00
|
|
|
MoveCountType GameFeatures::detectMoveCountType() {
|
|
|
|
if (_moveCountType == kMoveCountUninitialized) {
|
|
|
|
// SCI0/SCI01 games always increment move count
|
|
|
|
if (getSciVersion() <= SCI_VERSION_01) {
|
|
|
|
_moveCountType = kIncrementMoveCount;
|
2010-11-17 15:02:58 +00:00
|
|
|
} else if (getSciVersion() >= SCI_VERSION_1_1) {
|
|
|
|
// SCI1.1 and newer games always ignore move count
|
|
|
|
_moveCountType = kIgnoreMoveCount;
|
2010-02-03 11:02:43 +00:00
|
|
|
} else {
|
2010-02-07 12:16:23 +00:00
|
|
|
if (!autoDetectMoveCountType()) {
|
2010-06-17 23:45:38 +00:00
|
|
|
error("Move count autodetection failed");
|
2010-02-03 11:02:43 +00:00
|
|
|
_moveCountType = kIncrementMoveCount; // Most games do this, so best guess
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
debugC(1, kDebugLevelVM, "Detected move count handling: %s", (_moveCountType == kIncrementMoveCount) ? "increment" : "ignore");
|
|
|
|
}
|
|
|
|
|
|
|
|
return _moveCountType;
|
|
|
|
}
|
|
|
|
|
2010-11-25 14:22:09 +00:00
|
|
|
bool GameFeatures::useAltWinGMSound() {
|
2012-04-29 20:43:04 +03:00
|
|
|
if (g_sci && g_sci->getPlatform() == Common::kPlatformWindows && g_sci->isCD() && !_forceDOSTracks) {
|
2010-11-25 14:22:09 +00:00
|
|
|
SciGameId id = g_sci->getGameId();
|
|
|
|
return (id == GID_ECOQUEST ||
|
|
|
|
id == GID_JONES ||
|
|
|
|
id == GID_KQ5 ||
|
|
|
|
//id == GID_FREDDYPHARKAS || // Has alternate tracks, but handles them differently
|
|
|
|
id == GID_SQ4);
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-07 11:30:07 -05:00
|
|
|
bool GameFeatures::generalMidiOnly() {
|
|
|
|
#ifdef ENABLE_SCI32
|
|
|
|
switch (g_sci->getGameId()) {
|
|
|
|
case GID_MOTHERGOOSEHIRES:
|
|
|
|
return true;
|
|
|
|
case GID_KQ7: {
|
|
|
|
SoundResource sound(13, g_sci->getResMan(), detectDoSoundType());
|
|
|
|
return (sound.getTrackByType(/* AdLib */ 0) == nullptr);
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-08-13 14:58:07 +02:00
|
|
|
// PseudoMouse was added during SCI1
|
|
|
|
// PseudoMouseAbility is about a tiny difference in the keyboard driver, which sets the event type to either
|
|
|
|
// 40h (old behaviour) or 44h (the keyboard driver actually added 40h to the existing value).
|
|
|
|
// See engine/kevent.cpp, kMapKeyToDir - also script 933
|
|
|
|
|
|
|
|
// SCI1EGA:
|
|
|
|
// Quest for Glory 2 still used the old way.
|
|
|
|
//
|
|
|
|
// SCI1EARLY:
|
|
|
|
// King's Quest 5 0.000.062 uses the old way.
|
|
|
|
// Leisure Suit Larry 1 demo uses the new way, but no PseudoMouse class.
|
|
|
|
// Fairy Tales uses the new way.
|
|
|
|
// X-Mas 1990 uses the old way, no PseudoMouse class.
|
|
|
|
// Space Quest 4 floppy (1.1) uses the new way.
|
|
|
|
// Mixed Up Mother Goose uses the old way, no PseudoMouse class.
|
|
|
|
//
|
|
|
|
// SCI1MIDDLE:
|
|
|
|
// Leisure Suit Larry 5 demo uses the new way.
|
|
|
|
// Conquests of the Longbow demo uses the new way.
|
|
|
|
// Leisure Suit Larry 1 (2.0) uses the new way.
|
|
|
|
// Astro Chicken II uses the new way.
|
|
|
|
PseudoMouseAbilityType GameFeatures::detectPseudoMouseAbility() {
|
|
|
|
if (_pseudoMouseAbility == kPseudoMouseAbilityUninitialized) {
|
|
|
|
if (getSciVersion() < SCI_VERSION_1_EARLY) {
|
|
|
|
// SCI1 EGA or earlier -> pseudo mouse ability is always disabled
|
|
|
|
_pseudoMouseAbility = kPseudoMouseAbilityFalse;
|
|
|
|
|
|
|
|
} else if (getSciVersion() == SCI_VERSION_1_EARLY) {
|
|
|
|
// For SCI1 early some games had it enabled, some others didn't.
|
|
|
|
// We try to find an object called "PseudoMouse". If it's found, we enable the ability otherwise we don't.
|
|
|
|
reg_t pseudoMouseAddr = _segMan->findObjectByName("PseudoMouse", 0);
|
|
|
|
|
|
|
|
if (pseudoMouseAddr != NULL_REG) {
|
|
|
|
_pseudoMouseAbility = kPseudoMouseAbilityTrue;
|
|
|
|
} else {
|
|
|
|
_pseudoMouseAbility = kPseudoMouseAbilityFalse;
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
// SCI1 middle or later -> pseudo mouse ability is always enabled
|
|
|
|
_pseudoMouseAbility = kPseudoMouseAbilityTrue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return _pseudoMouseAbility;
|
|
|
|
}
|
|
|
|
|
2010-02-03 11:02:43 +00:00
|
|
|
} // End of namespace Sci
|