aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/engine
diff options
context:
space:
mode:
authorWalter van Niftrik2009-08-16 19:18:19 +0000
committerWalter van Niftrik2009-08-16 19:18:19 +0000
commit00f4794c0a0168a86d7e58e3f585f7fa4d02c7c9 (patch)
tree44f0da44eb3c80367c1921d763c99ffe3be15a42 /engines/sci/engine
parent582eb13fa2680a60ac5d1770c450fabfbc15a1b5 (diff)
downloadscummvm-rg350-00f4794c0a0168a86d7e58e3f585f7fa4d02c7c9.tar.gz
scummvm-rg350-00f4794c0a0168a86d7e58e3f585f7fa4d02c7c9.tar.bz2
scummvm-rg350-00f4794c0a0168a86d7e58e3f585f7fa4d02c7c9.zip
SCI: Stage 1 of the game detection overhaul. The end goal is to autodetect
as much as possible. All SCI_VERSION_* information was removed from detection.cpp (much of it was incorrect anyway). svn-id: r43449
Diffstat (limited to 'engines/sci/engine')
-rw-r--r--engines/sci/engine/game.cpp2
-rw-r--r--engines/sci/engine/kernel.cpp60
-rw-r--r--engines/sci/engine/kernel.h3
-rw-r--r--engines/sci/engine/kevent.cpp2
-rw-r--r--engines/sci/engine/kgraphics.cpp12
-rw-r--r--engines/sci/engine/kmovement.cpp6
-rw-r--r--engines/sci/engine/ksound.cpp4
-rw-r--r--engines/sci/engine/savegame.cpp8
-rw-r--r--engines/sci/engine/script.cpp13
-rw-r--r--engines/sci/engine/script.h2
-rw-r--r--engines/sci/engine/state.h2
11 files changed, 37 insertions, 77 deletions
diff --git a/engines/sci/engine/game.cpp b/engines/sci/engine/game.cpp
index 2d9cf6a42b..1fa0e03d4c 100644
--- a/engines/sci/engine/game.cpp
+++ b/engines/sci/engine/game.cpp
@@ -179,7 +179,7 @@ static void _free_graphics_input(EngineState *s) {
}
int game_init_sound(EngineState *s, int sound_flags) {
- if (s->resmgr->sciVersion() >= SCI_VERSION_01)
+ if (s->resmgr->sciVersion() > SCI_VERSION_0_LATE)
sound_flags |= SFX_STATE_FLAG_MULTIPLAY;
s->sfx_init_flags = sound_flags;
diff --git a/engines/sci/engine/kernel.cpp b/engines/sci/engine/kernel.cpp
index 362e41a357..193ff4cc51 100644
--- a/engines/sci/engine/kernel.cpp
+++ b/engines/sci/engine/kernel.cpp
@@ -382,6 +382,8 @@ Kernel::~Kernel() {
}
void Kernel::detectSciFeatures() {
+ // FIXME Much of this is unreliable
+
Resource *r = _resmgr->findResource(ResourceId(kResourceTypeVocab, VOCAB_RESOURCE_SNAMES), 0);
Common::StringList staticSelectorTable;
@@ -396,9 +398,15 @@ void Kernel::detectSciFeatures() {
features = 0;
// Initialize features based on SCI version
- if (_resmgr->sciVersion() == SCI_VERSION_0) {
+ switch (_resmgr->sciVersion()) {
+ case SCI_VERSION_0_EARLY:
features |= kFeatureOldScriptHeader;
+ /* Fallthrough */
+ case SCI_VERSION_0_LATE:
features |= kFeatureOldGfxFunctions;
+ break;
+ default:
+ break;
}
for (int i = 0; i < count; i++) {
@@ -413,18 +421,12 @@ void Kernel::detectSciFeatures() {
tmp = staticSelectorTable[i];
}
- if (tmp == "setTarget") // "motionInited" can also be used
- features &= ~kFeatureOldScriptHeader;
-
if (tmp == "motionCue")
features &= ~kFeatureOldGfxFunctions;
if (tmp == "egoMoveSpeed" && _resmgr->sciVersion() < SCI_VERSION_1_1)
features |= kFeatureLofsAbsolute;
- if (tmp == "sightAngle" && _resmgr->sciVersion() == SCI_VERSION_0)
- features |= kFeatureSci0Sci1Table;
-
if (tmp == "setVol")
features |= kFeatureSci1Sound;
@@ -437,12 +439,6 @@ void Kernel::detectSciFeatures() {
printf("Kernel auto-detected features:\n");
- printf("Script block headers: ");
- if (features & kFeatureOldScriptHeader)
- printf("old\n");
- else
- printf("new\n");
-
printf("Graphics functions: ");
if (features & kFeatureOldGfxFunctions)
printf("old\n");
@@ -462,9 +458,6 @@ void Kernel::detectSciFeatures() {
printf("SCI01\n");
else
printf("SCI0\n");
-
- if (features & kFeatureSci0Sci1Table)
- printf("Found SCI0 game using a SCI1 kernel table\n");
}
void Kernel::loadSelectorNames() {
@@ -642,15 +635,6 @@ void Kernel::mapFunctions() {
int mapped = 0;
int ignored = 0;
uint functions_nr = getKernelNamesSize();
- uint max_functions_nr = (_resmgr->sciVersion() == SCI_VERSION_0) ? 0x72 : 0x7b;
-
- if (functions_nr < max_functions_nr) {
- warning("SCI version believed to have %d kernel"
- " functions, but only %d reported-- filling up remaining %d",
- max_functions_nr, functions_nr, max_functions_nr - functions_nr);
-
- functions_nr = max_functions_nr;
- }
_kernelFuncs.resize(functions_nr);
@@ -833,15 +817,9 @@ reg_t *kernel_dereference_reg_pointer(EngineState *s, reg_t pointer, int entries
}
void Kernel::setDefaultKernelNames() {
- bool isSci0 = (_resmgr->sciVersion() == SCI_VERSION_0);
+ bool isSci0 = (_resmgr->sciVersion() <= SCI_VERSION_0_LATE);
int offset = 0;
- // Check if we have a SCI01 game which uses a SCI1 kernel table (e.g. the KQ1 demo
- // and full version). We do this by checking if the sightAngle selector exists, as no
- // SCI0 game seems to have it
- if (features & kFeatureSci0Sci1Table)
- isSci0 = false;
-
_kernelNames.resize(SCI_KNAMES_DEFAULT_ENTRIES_NR + (isSci0 ? 4 : 0));
for (int i = 0; i < SCI_KNAMES_DEFAULT_ENTRIES_NR; i++) {
// In SCI0, Platform was DoAvoider
@@ -897,23 +875,7 @@ static void vocab_get_knames11(ResourceManager *resmgr, Common::StringList &name
bool Kernel::loadKernelNames() {
_kernelNames.clear();
-
- switch (_resmgr->sciVersion()) {
- case SCI_VERSION_0:
- case SCI_VERSION_01:
- case SCI_VERSION_1:
- case SCI_VERSION_1_1:
- setDefaultKernelNames();
- break;
-#ifdef ENABLE_SCI32
- case SCI_VERSION_32:
- vocab_get_knames11(_resmgr, _kernelNames);
-#endif
- break;
- default:
- break;
- }
-
+ setDefaultKernelNames();
return true;
}
diff --git a/engines/sci/engine/kernel.h b/engines/sci/engine/kernel.h
index 6a275a9adb..2c90728fb0 100644
--- a/engines/sci/engine/kernel.h
+++ b/engines/sci/engine/kernel.h
@@ -60,8 +60,7 @@ enum AutoDetectedFeatures {
kFeatureOldGfxFunctions = 1 << 1,
kFeatureLofsAbsolute = 1 << 2,
kFeatureSci01Sound = 1 << 3,
- kFeatureSci1Sound = 1 << 4,
- kFeatureSci0Sci1Table = 1 << 5
+ kFeatureSci1Sound = 1 << 4
};
class Kernel {
diff --git a/engines/sci/engine/kevent.cpp b/engines/sci/engine/kevent.cpp
index 5ac09e6c76..b3b8d3d53b 100644
--- a/engines/sci/engine/kevent.cpp
+++ b/engines/sci/engine/kevent.cpp
@@ -40,7 +40,7 @@ reg_t kGetEvent(EngineState *s, int funct_nr, int argc, reg_t *argv) {
reg_t obj = argv[1];
sci_event_t e;
int oldx, oldy;
- int modifier_mask = s->_version <= SCI_VERSION_0 ? SCI_EVM_ALL : SCI_EVM_NO_FOOLOCK;
+ int modifier_mask = s->_version <= SCI_VERSION_01 ? SCI_EVM_ALL : SCI_EVM_NO_FOOLOCK;
// If there's a simkey pending, and the game wants a keyboard event, use the
// simkey instead of a normal event
diff --git a/engines/sci/engine/kgraphics.cpp b/engines/sci/engine/kgraphics.cpp
index 915b07e8a3..da1a2ec413 100644
--- a/engines/sci/engine/kgraphics.cpp
+++ b/engines/sci/engine/kgraphics.cpp
@@ -304,9 +304,9 @@ static gfx_color_t graph_map_color(EngineState *s, int color, int priority, int
reg_t kSetCursor(EngineState *s, int funct_nr, int argc, reg_t *argv) {
switch (argc) {
case 1 :
- if (s->_version < SCI_VERSION_1) {
+ if (s->_version < SCI_VERSION_1_LATE) {
GFX_ASSERT(gfxop_set_pointer_cursor(s->gfx_state, argv[0].toSint16()));
- } else if (s->_version == SCI_VERSION_1) {
+ } else if (s->_version < SCI_VERSION_1_1) {
if (argv[0].toSint16() <= 1) {
// Newer (SCI1.1) semantics: show/hide cursor
CursorMan.showMouse(argv[0].toSint16() != 0);
@@ -314,16 +314,16 @@ reg_t kSetCursor(EngineState *s, int funct_nr, int argc, reg_t *argv) {
// Pre-SCI1.1: set cursor according to the first parameter
GFX_ASSERT(gfxop_set_pointer_cursor(s->gfx_state, argv[0].toSint16()));
}
- } else if (s->_version >= SCI_VERSION_1_1) {
+ } else {
// SCI1.1: Show/hide cursor
CursorMan.showMouse(argv[0].toSint16() != 0);
}
break;
case 2 :
- if (s->_version < SCI_VERSION_1) {
+ if (s->_version < SCI_VERSION_1_LATE) {
GFX_ASSERT(gfxop_set_pointer_cursor(s->gfx_state,
argv[1].toSint16() == 0 ? GFXOP_NO_POINTER : argv[0].toSint16()));
- } else if (s->_version == SCI_VERSION_1) {
+ } else if (s->_version < SCI_VERSION_1_1) {
// Pre-SCI1.1: set cursor according to the first parameter, and toggle its
// visibility based on the second parameter
// Some late SCI1 games actually use the SCI1.1 version of this call (EcoQuest 1
@@ -342,7 +342,7 @@ reg_t kSetCursor(EngineState *s, int funct_nr, int argc, reg_t *argv) {
GFX_ASSERT(gfxop_set_pointer_position(s->gfx_state,
Common::Point(argv[0].toUint16(), argv[1].toUint16())));
}
- } else if (s->_version >= SCI_VERSION_1_1) {
+ } else {
// SCI1.1 and newer: set pointer position
GFX_ASSERT(gfxop_set_pointer_position(s->gfx_state,
Common::Point(argv[0].toUint16(), argv[1].toUint16())));
diff --git a/engines/sci/engine/kmovement.cpp b/engines/sci/engine/kmovement.cpp
index 8774224f60..7433324a70 100644
--- a/engines/sci/engine/kmovement.cpp
+++ b/engines/sci/engine/kmovement.cpp
@@ -274,7 +274,7 @@ static void bresenham_autodetect(EngineState *s) {
}
buf = s->seg_manager->getScript(fptr.segment)->buf + fptr.offset;
- handle_movecnt = (s->_version <= SCI_VERSION_0 || checksum_bytes(buf, 8) == 0x216) ? INCREMENT_MOVECNT : IGNORE_MOVECNT;
+ handle_movecnt = (s->_version <= SCI_VERSION_01 || checksum_bytes(buf, 8) == 0x216) ? INCREMENT_MOVECNT : IGNORE_MOVECNT;
printf("b-moveCnt action based on checksum: %s\n", handle_movecnt == IGNORE_MOVECNT ? "ignore" : "increment");
} else {
warning("bresenham_autodetect failed");
@@ -293,7 +293,7 @@ reg_t kDoBresen(EngineState *s, int funct_nr, int argc, reg_t *argv) {
int completed = 0;
int max_movcnt = GET_SEL32V(client, moveSpeed);
- if (s->_version > SCI_VERSION_0)
+ if (s->_version > SCI_VERSION_01)
signal &= ~_K_VIEW_SIG_FLAG_HIT_OBSTACLE;
if (handle_movecnt == UNINITIALIZED)
@@ -380,7 +380,7 @@ reg_t kDoBresen(EngineState *s, int funct_nr, int argc, reg_t *argv) {
completed = 1;
}
- if (s->_version > SCI_VERSION_0)
+ if (s->_version > SCI_VERSION_01)
if (completed)
invoke_selector(INV_SEL(mover, moveDone, kStopOnInvalidSelector), 0);
diff --git a/engines/sci/engine/ksound.cpp b/engines/sci/engine/ksound.cpp
index 8c113d35a3..38baeafad8 100644
--- a/engines/sci/engine/ksound.cpp
+++ b/engines/sci/engine/ksound.cpp
@@ -157,9 +157,9 @@ void process_sound_events(EngineState *s) { /* Get all sound events, apply their
SongHandle handle;
int cue;
- if (s->_version >= SCI_VERSION_01)
+ if (s->_version > SCI_VERSION_01)
return;
- /* SCI01 and later explicitly poll for everything */
+ /* SCI1 and later explicitly poll for everything */
while ((result = s->_sound.sfx_poll(&handle, &cue))) {
reg_t obj = DEFROBNICATE_HANDLE(handle);
diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp
index 6b481dfc25..75cd4aee54 100644
--- a/engines/sci/engine/savegame.cpp
+++ b/engines/sci/engine/savegame.cpp
@@ -693,7 +693,13 @@ int _reset_graphics_input(EngineState *s);
static void reconstruct_sounds(EngineState *s) {
Song *seeker;
- SongIteratorType it_type = s->resmgr->sciVersion() >= SCI_VERSION_01 ? SCI_SONG_ITERATOR_TYPE_SCI1 : SCI_SONG_ITERATOR_TYPE_SCI0;
+ SongIteratorType it_type;
+
+ if (((SciEngine *)g_engine)->getKernel()->usesSci01SoundFunctions()
+ || ((SciEngine *)g_engine)->getKernel()->usesSci1SoundFunctions())
+ it_type = SCI_SONG_ITERATOR_TYPE_SCI1;
+ else
+ it_type = SCI_SONG_ITERATOR_TYPE_SCI0;
seeker = s->_sound._songlib._lib;
diff --git a/engines/sci/engine/script.cpp b/engines/sci/engine/script.cpp
index 667c429821..6e47a73b18 100644
--- a/engines/sci/engine/script.cpp
+++ b/engines/sci/engine/script.cpp
@@ -88,18 +88,11 @@ opcode_format g_opcode_formats[128][4] = {
};
#undef END
-void script_adjust_opcode_formats(int res_version) {
- switch (res_version) {
- case SCI_VERSION_0:
- break;
- case SCI_VERSION_01:
- case SCI_VERSION_1:
- case SCI_VERSION_1_1:
+void script_adjust_opcode_formats(SciVersion version) {
+ // TODO: Check that this is correct
+ if ((version >= SCI_VERSION_1_1) || ((SciEngine*)g_engine)->getKernel()->hasLofsAbsolute()) {
g_opcode_formats[op_lofsa][0] = Script_Offset;
g_opcode_formats[op_lofss][0] = Script_Offset;
- break;
- default:
- error("script_adjust_opcode_formats(): Unknown script version %d\n", res_version);
}
}
diff --git a/engines/sci/engine/script.h b/engines/sci/engine/script.h
index 98e5b08bb9..dd5980eafe 100644
--- a/engines/sci/engine/script.h
+++ b/engines/sci/engine/script.h
@@ -202,7 +202,7 @@ enum sci_opcodes { /* FIXME */
extern opcode_format g_opcode_formats[128][4];
-void script_adjust_opcode_formats(int res_version);
+void script_adjust_opcode_formats(SciVersion version);
void script_free_breakpoints(EngineState *s);
diff --git a/engines/sci/engine/state.h b/engines/sci/engine/state.h
index 2fa1bd82a6..39dcbb0c0b 100644
--- a/engines/sci/engine/state.h
+++ b/engines/sci/engine/state.h
@@ -129,7 +129,7 @@ public:
SpeedThrottler(SciVersion version) {
if (version >= SCI_VERSION_1_1)
_maxInstructions = 3300;
- else if (version >= SCI_VERSION_1)
+ else if (version >= SCI_VERSION_1_EARLY)
_maxInstructions = 2200;
else
_maxInstructions = 1100;