Cleaned up detectGfxFunctionsType() slightly, and made it work for Hoyle 1 and 2 properly.

svn-id: r49292
This commit is contained in:
Filippos Karapetis 2010-05-28 12:36:47 +00:00
parent d9c0abe0b8
commit b2e4e4b340

View file

@ -332,35 +332,21 @@ bool GameFeatures::autoDetectGfxFunctionsType(int methodNum) {
SciVersion GameFeatures::detectGfxFunctionsType() { SciVersion GameFeatures::detectGfxFunctionsType() {
if (_gfxFunctionsType == SCI_VERSION_NONE) { if (_gfxFunctionsType == SCI_VERSION_NONE) {
// This detection only works (and is only needed) for SCI0 games if (getSciVersion() == SCI_VERSION_0_EARLY) {
if (getSciVersion() >= SCI_VERSION_01) { // Old SCI0 games always used old graphics functions
_gfxFunctionsType = SCI_VERSION_0_LATE;
} else if (getSciVersion() > SCI_VERSION_0_EARLY) {
// Check if the game is using an overlay
bool found = false;
if (_kernel->_selectorCache.overlay == -1) {
// No overlay selector found, check if any method of the Rm object
// is calling kDrawPic, as the overlay selector might be missing in demos
const Object *obj = _segMan->getObject(_segMan->findObjectByName("Rm"));
for (uint m = 0; m < obj->getMethodCount(); m++) {
found = autoDetectGfxFunctionsType(m);
if (found)
break;
}
if (!found) {
// No overlay selector found, therefore the game is definitely
// using old graphics functions
_gfxFunctionsType = SCI_VERSION_0_EARLY; _gfxFunctionsType = SCI_VERSION_0_EARLY;
} } else if (getSciVersion() >= SCI_VERSION_01) {
} else { // _kernel->_selectorCache.overlay != -1 // SCI01 and newer games always used new graphics functions
// An in-between case: The game does not have a shiftParser _gfxFunctionsType = SCI_VERSION_0_LATE;
// selector, but it does have an overlay selector, so it uses an } else { // SCI0 late
// overlay. Therefore, check it to see how it calls kDrawPic to // Check if the game is using an overlay
// determine the graphics functions type used bool searchRoomObj = false;
if (_kernel->_selectorCache.overlay != -1) {
// The game has an overlay selector, check how it calls kDrawPicto determine
// the graphics functions type used
reg_t objAddr = _segMan->findObjectByName("Rm");
if (lookup_selector(_segMan, objAddr, _kernel->_selectorCache.overlay, NULL, NULL) == kSelectorMethod) {
if (!autoDetectGfxFunctionsType()) { if (!autoDetectGfxFunctionsType()) {
warning("Graphics functions detection failed, taking an educated guess"); warning("Graphics functions detection failed, taking an educated guess");
@ -371,11 +357,35 @@ SciVersion GameFeatures::detectGfxFunctionsType() {
else else
_gfxFunctionsType = SCI_VERSION_0_EARLY; _gfxFunctionsType = SCI_VERSION_0_EARLY;
} }
} else {
// 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
searchRoomObj = true;
} }
} else { // (getSciVersion() == SCI_VERSION_0_EARLY) } else {
// Old SCI0 games always used old graphics functions // The game doesn't have an overlay selector, so search for it manually
searchRoomObj = true;
}
if (searchRoomObj) {
// If requested, check if any method of the Rm object is calling kDrawPic,
// as the overlay selector might be missing in demos
bool found = false;
const Object *obj = _segMan->getObject(_segMan->findObjectByName("Rm"));
for (uint m = 0; m < obj->getMethodCount(); m++) {
found = autoDetectGfxFunctionsType(m);
if (found)
break;
}
if (!found) {
// No method of the Rm object is calling kDrawPic, thus the game
// doesn't have overlays and is using older graphics functions
_gfxFunctionsType = SCI_VERSION_0_EARLY; _gfxFunctionsType = SCI_VERSION_0_EARLY;
} }
}
}
debugC(1, kDebugLevelVM, "Detected graphics functions type: %s", getSciVersionDesc(_gfxFunctionsType)); debugC(1, kDebugLevelVM, "Detected graphics functions type: %s", getSciVersionDesc(_gfxFunctionsType));
} }