From 47e137fd8e26471ff678b49355a2f01cfe1e6c39 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 17 Nov 2010 14:28:32 +0000 Subject: SCI: lofsa/lofss functionality for SCI3 - Updated detectLofsType() for SCI3 - Cleaned up op_lofsa and op_lofss and updated them for SCI3 svn-id: r54293 --- engines/sci/engine/features.cpp | 11 ++++++++++- engines/sci/engine/features.h | 2 +- engines/sci/engine/vm.cpp | 20 ++++++++++++++++---- 3 files changed, 27 insertions(+), 6 deletions(-) (limited to 'engines') diff --git a/engines/sci/engine/features.cpp b/engines/sci/engine/features.cpp index 97eec38caf..7d9b4f43fc 100644 --- a/engines/sci/engine/features.cpp +++ b/engines/sci/engine/features.cpp @@ -270,11 +270,20 @@ SciVersion GameFeatures::detectLofsType() { return _lofsType; } - if (getSciVersion() >= SCI_VERSION_1_1) { + if (getSciVersion() >= SCI_VERSION_1_1 && getSciVersion() <= SCI_VERSION_2_1) { + // SCI1.1 type, i.e. we compensate for the fact that the heap is attached + // to the end of the script _lofsType = SCI_VERSION_1_1; return _lofsType; } + 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; + } + // Find a function of the "Game" object (which is the game super class) which invokes lofsa/lofss reg_t gameSuperClass = g_sci->getGameSuperClassAddress(); bool found = false; diff --git a/engines/sci/engine/features.h b/engines/sci/engine/features.h index 755054fb25..336520f0d9 100644 --- a/engines/sci/engine/features.h +++ b/engines/sci/engine/features.h @@ -57,7 +57,7 @@ public: /** * Autodetects the Lofs type - * @return Lofs type, SCI_VERSION_0_EARLY / SCI_VERSION_1_MIDDLE / SCI_VERSION_1_1 + * @return Lofs type, SCI_VERSION_0_EARLY / SCI_VERSION_1_MIDDLE / SCI_VERSION_1_1 / SCI_VERSION_3 */ SciVersion detectLofsType(); diff --git a/engines/sci/engine/vm.cpp b/engines/sci/engine/vm.cpp index 79fe08792d..b251521041 100644 --- a/engines/sci/engine/vm.cpp +++ b/engines/sci/engine/vm.cpp @@ -1723,14 +1723,20 @@ void run_vm(EngineState *s) { s->r_acc.segment = s->xs->addr.pc.segment; switch (g_sci->_features->detectLofsType()) { + case SCI_VERSION_0_EARLY: + s->r_acc.offset = s->xs->addr.pc.offset + opparams[0]; + break; + case SCI_VERSION_1_MIDDLE: + s->r_acc.offset = opparams[0]; + break; case SCI_VERSION_1_1: s->r_acc.offset = opparams[0] + local_script->getScriptSize(); break; - case SCI_VERSION_1_MIDDLE: + case SCI_VERSION_3: s->r_acc.offset = opparams[0]; break; default: - s->r_acc.offset = s->xs->addr.pc.offset + opparams[0]; + error("Unknown lofs type"); } if (s->r_acc.offset >= scr->getBufSize()) { @@ -1744,14 +1750,20 @@ void run_vm(EngineState *s) { r_temp.segment = s->xs->addr.pc.segment; switch (g_sci->_features->detectLofsType()) { + case SCI_VERSION_0_EARLY: + r_temp.offset = s->xs->addr.pc.offset + opparams[0]; + break; + case SCI_VERSION_1_MIDDLE: + r_temp.offset = opparams[0]; + break; case SCI_VERSION_1_1: r_temp.offset = opparams[0] + local_script->getScriptSize(); break; - case SCI_VERSION_1_MIDDLE: + case SCI_VERSION_3: r_temp.offset = opparams[0]; break; default: - r_temp.offset = s->xs->addr.pc.offset + opparams[0]; + error("Unknown lofs type"); } if (r_temp.offset >= scr->getBufSize()) { -- cgit v1.2.3