aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/engine
diff options
context:
space:
mode:
authorFilippos Karapetis2009-08-23 21:57:30 +0000
committerFilippos Karapetis2009-08-23 21:57:30 +0000
commit60af2db2fdd8c0ca0d597033798bdf4b4efa4938 (patch)
treee427d0f6d3701a50d7288f8d20dce4eea0d22eeb /engines/sci/engine
parente858994060118b0d21bbb18d3cfe59fb10f4399d (diff)
downloadscummvm-rg350-60af2db2fdd8c0ca0d597033798bdf4b4efa4938.tar.gz
scummvm-rg350-60af2db2fdd8c0ca0d597033798bdf4b4efa4938.tar.bz2
scummvm-rg350-60af2db2fdd8c0ca0d597033798bdf4b4efa4938.zip
- Added more mappings from Sierra's internal IDs to our own ones. Hopefully, all SCI0-SCI11 games can now be detected correctly from the fallback detector
- Simplified some checks for old script types svn-id: r43678
Diffstat (limited to 'engines/sci/engine')
-rw-r--r--engines/sci/engine/game.cpp4
-rw-r--r--engines/sci/engine/kernel.cpp5
-rw-r--r--engines/sci/engine/kernel.h4
-rw-r--r--engines/sci/engine/savegame.cpp2
-rw-r--r--engines/sci/engine/seg_manager.cpp9
-rw-r--r--engines/sci/engine/seg_manager.h3
-rw-r--r--engines/sci/engine/static_selectors.cpp8
-rw-r--r--engines/sci/engine/vm.cpp6
-rw-r--r--engines/sci/engine/vm.h2
9 files changed, 19 insertions, 24 deletions
diff --git a/engines/sci/engine/game.cpp b/engines/sci/engine/game.cpp
index f649d97412..994054f6a7 100644
--- a/engines/sci/engine/game.cpp
+++ b/engines/sci/engine/game.cpp
@@ -191,7 +191,7 @@ int game_init_sound(EngineState *s, int sound_flags) {
// Architectural stuff: Init/Unintialize engine
int script_init_engine(EngineState *s) {
s->kernel_opt_flags = 0;
- s->seg_manager = new SegManager(s->resmgr, s->_version, ((SciEngine*)g_engine)->getKernel()->hasOldScriptHeader());
+ s->seg_manager = new SegManager(s->resmgr, s->_version);
s->gc_countdown = GC_INTERVAL - 1;
SegmentId script_000_segment = s->seg_manager->getSegment(0, SCRIPT_GET_LOCK);
@@ -294,7 +294,7 @@ int game_init(EngineState *s) {
s->stack_base = stack->entries;
s->stack_top = s->stack_base + VM_STACK_SIZE;
- if (!script_instantiate(s->resmgr, s->seg_manager, s->_version, ((SciEngine*)g_engine)->getKernel()->hasOldScriptHeader(), 0)) {
+ if (!script_instantiate(s->resmgr, s->seg_manager, s->_version, 0)) {
warning("game_init(): Could not instantiate script 0");
return 1;
}
diff --git a/engines/sci/engine/kernel.cpp b/engines/sci/engine/kernel.cpp
index a871df936f..687e621405 100644
--- a/engines/sci/engine/kernel.cpp
+++ b/engines/sci/engine/kernel.cpp
@@ -363,15 +363,12 @@ static const char *argtype_description[] = {
"Arithmetic"
};
-Kernel::Kernel(ResourceManager *resmgr, bool minimalLoad) : _resmgr(resmgr) {
+Kernel::Kernel(ResourceManager *resmgr) : _resmgr(resmgr) {
memset(&_selectorMap, 0, sizeof(_selectorMap)); // FIXME: Remove this once/if we C++ify selector_map_t
loadSelectorNames();
detectSciFeatures();
- if (minimalLoad) // If we're only asked to detect game features, stop here
- return;
-
mapSelectors(); // Map a few special selectors for later use
loadOpcodes();
loadKernelNames();
diff --git a/engines/sci/engine/kernel.h b/engines/sci/engine/kernel.h
index 997cdaea77..a85025f514 100644
--- a/engines/sci/engine/kernel.h
+++ b/engines/sci/engine/kernel.h
@@ -67,10 +67,8 @@ class Kernel {
public:
/**
* Initializes the SCI kernel
- * @param minimalLoad If true, only the selector names are loaded, to detect game features.
- * It's set to true by the advanced game detector to speed it up
*/
- Kernel(ResourceManager *resmgr, bool minimalLoad = false);
+ Kernel(ResourceManager *resmgr);
~Kernel();
uint getOpcodesSize() const { return _opcodes.size(); }
diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp
index 0ddb5187ac..b53e9d522c 100644
--- a/engines/sci/engine/savegame.cpp
+++ b/engines/sci/engine/savegame.cpp
@@ -219,7 +219,7 @@ static void sync_SegManagerPtr(Common::Serializer &s, SegManager *&obj) {
if (s.isLoading()) {
// FIXME: Do in-place loading at some point, instead of creating a new EngineState instance from scratch.
delete obj;
- obj = new SegManager(resMgr, version, ((SciEngine*)g_engine)->getKernel()->hasOldScriptHeader());
+ obj = new SegManager(resMgr, version);
}
obj->saveLoadWithSerializer(s);
diff --git a/engines/sci/engine/seg_manager.cpp b/engines/sci/engine/seg_manager.cpp
index ddcd639f3c..0c731d449c 100644
--- a/engines/sci/engine/seg_manager.cpp
+++ b/engines/sci/engine/seg_manager.cpp
@@ -52,7 +52,7 @@ namespace Sci {
#define INVALID_SCRIPT_ID -1
-SegManager::SegManager(ResourceManager *resMgr, SciVersion version, bool oldScriptHeader) {
+SegManager::SegManager(ResourceManager *resMgr, SciVersion version) {
id_seg_map = new IntMapper();
reserved_id = INVALID_SCRIPT_ID;
id_seg_map->checkKey(reserved_id, true); // reserve entry 0 for INVALID_SCRIPT_ID
@@ -68,7 +68,6 @@ SegManager::SegManager(ResourceManager *resMgr, SciVersion version, bool oldScri
exports_wide = 0;
_version = version;
_resMgr = resMgr;
- _oldScriptHeader = oldScriptHeader;
int result = 0;
@@ -150,7 +149,7 @@ void SegManager::setScriptSize(Script &scr, int script_nr) {
if (!script || (_version >= SCI_VERSION_1_1 && !heap)) {
error("SegManager::setScriptSize: failed to load %s", !script ? "script" : "heap");
}
- if (_oldScriptHeader) {
+ if (_version == SCI_VERSION_0_EARLY) { // check if we got an old script header
scr.buf_size = script->size + READ_LE_UINT16(script->data) * 2;
//locals_size = READ_LE_UINT16(script->data) * 2;
} else if (_version < SCI_VERSION_1_1) {
@@ -445,7 +444,7 @@ SegmentId SegManager::getSegment(int script_nr, SCRIPT_GET load) {
SegmentId segment;
if ((load & SCRIPT_GET_LOAD) == SCRIPT_GET_LOAD)
- script_instantiate(_resMgr, this, _version, _oldScriptHeader, script_nr);
+ script_instantiate(_resMgr, this, _version, script_nr);
segment = segGet(script_nr);
@@ -987,7 +986,7 @@ int SegManager::createSci0ClassTable() {
Resource *script = _resMgr->findResource(ResourceId(kResourceTypeScript, scriptnr), 0);
if (script) {
- if (_oldScriptHeader)
+ if (version == SCI_VERSION_0_EARLY) // check if we got an old script header
magic_offset = seeker = 2;
else
magic_offset = seeker = 0;
diff --git a/engines/sci/engine/seg_manager.h b/engines/sci/engine/seg_manager.h
index fcf2659df3..5676990343 100644
--- a/engines/sci/engine/seg_manager.h
+++ b/engines/sci/engine/seg_manager.h
@@ -58,7 +58,7 @@ public:
/**
* Initialize the segment manager
*/
- SegManager(ResourceManager *resMgr, SciVersion version, bool oldScriptHeader);
+ SegManager(ResourceManager *resMgr, SciVersion version);
/**
* Deallocate all memory associated with the segment manager
@@ -342,7 +342,6 @@ public:
private:
IntMapper *id_seg_map; ///< id - script id; seg - index of heap
- bool _oldScriptHeader;
public: // TODO: make private
Common::Array<MemObject *> _heap;
int reserved_id;
diff --git a/engines/sci/engine/static_selectors.cpp b/engines/sci/engine/static_selectors.cpp
index 9c2abbfbc9..1897748c6d 100644
--- a/engines/sci/engine/static_selectors.cpp
+++ b/engines/sci/engine/static_selectors.cpp
@@ -499,10 +499,12 @@ static const SelectorRemap lsl5_demo_selectors[] = {
} while (0)
Common::StringList Kernel::checkStaticSelectorNames() {
- Common::String gameID = ((SciEngine*)g_engine)->getGameID();
-
Common::StringList names;
-
+ if (!g_engine)
+ return names;
+
+ Common::String gameID = ((SciEngine*)g_engine)->getGameID();
+
if (gameID == "kq4sci")
USE_SELECTOR_TABLE(kq4_demo_selectors);
else if (gameID == "lsl3" || gameID == "iceman") // identical, except iceman has "flags"
diff --git a/engines/sci/engine/vm.cpp b/engines/sci/engine/vm.cpp
index 943a8e0354..613de69f05 100644
--- a/engines/sci/engine/vm.cpp
+++ b/engines/sci/engine/vm.cpp
@@ -208,7 +208,7 @@ ExecStack *execute_method(EngineState *s, uint16 script, uint16 pubfunct, StackP
Script *scr = s->seg_manager->getScriptIfLoaded(seg);
if (!scr) // Script not present yet?
- seg = script_instantiate(s->resmgr, s->seg_manager, s->_version, ((SciEngine*)g_engine)->getKernel()->hasOldScriptHeader(), script);
+ seg = script_instantiate(s->resmgr, s->seg_manager, s->_version, script);
else
scr->unmarkDeleted();
@@ -1761,11 +1761,11 @@ int script_instantiate_sci11(ResourceManager *resMgr, SegManager *segManager, Sc
return seg_id;
}
-int script_instantiate(ResourceManager *resMgr, SegManager *segManager, SciVersion version, bool oldScriptHeader, int script_nr) {
+int script_instantiate(ResourceManager *resMgr, SegManager *segManager, SciVersion version, int script_nr) {
if (version >= SCI_VERSION_1_1)
return script_instantiate_sci11(resMgr, segManager, version, script_nr);
else
- return script_instantiate_sci0(resMgr, segManager, version, oldScriptHeader, script_nr);
+ return script_instantiate_sci0(resMgr, segManager, version, (version == SCI_VERSION_0_EARLY), script_nr);
}
void script_uninstantiate_sci0(SegManager *segManager, SciVersion version, int script_nr, SegmentId seg) {
diff --git a/engines/sci/engine/vm.h b/engines/sci/engine/vm.h
index 867f732e2a..c8f94d5446 100644
--- a/engines/sci/engine/vm.h
+++ b/engines/sci/engine/vm.h
@@ -489,7 +489,7 @@ reg_t script_lookup_export(SegManager *segManager, int script_nr, int export_ind
* @param[in] script_nr The script number to load
* @return The script's segment ID or 0 if out of heap
*/
-int script_instantiate(ResourceManager *resMgr, SegManager *segManager, SciVersion version, bool oldScriptHeader, int script_nr);
+int script_instantiate(ResourceManager *resMgr, SegManager *segManager, SciVersion version, int script_nr);
/**
* Decreases the numer of lockers of a script and unloads it if that number