aboutsummaryrefslogtreecommitdiff
path: root/engines/sci
diff options
context:
space:
mode:
authorMax Horn2010-02-13 17:44:58 +0000
committerMax Horn2010-02-13 17:44:58 +0000
commit9575cc08a2d54af57ada390f0f736d64857a49d1 (patch)
treee2966a582ffb7b9828c25e0ce25fa991d6586836 /engines/sci
parenta82939c9bee20f2969f1006c1c9a836cea5c7903 (diff)
downloadscummvm-rg350-9575cc08a2d54af57ada390f0f736d64857a49d1.tar.gz
scummvm-rg350-9575cc08a2d54af57ada390f0f736d64857a49d1.tar.bz2
scummvm-rg350-9575cc08a2d54af57ada390f0f736d64857a49d1.zip
SCI: Move GameFeatures from EngineState to SciEngine
svn-id: r48049
Diffstat (limited to 'engines/sci')
-rw-r--r--engines/sci/console.cpp17
-rw-r--r--engines/sci/engine/game.cpp7
-rw-r--r--engines/sci/engine/kernel32.cpp3
-rw-r--r--engines/sci/engine/kevent.cpp3
-rw-r--r--engines/sci/engine/kgraphics.cpp5
-rw-r--r--engines/sci/engine/kmovement.cpp3
-rw-r--r--engines/sci/engine/ksound.cpp5
-rw-r--r--engines/sci/engine/savegame.cpp5
-rw-r--r--engines/sci/engine/script.cpp3
-rw-r--r--engines/sci/engine/state.cpp3
-rw-r--r--engines/sci/engine/state.h4
-rw-r--r--engines/sci/engine/vm.cpp5
-rw-r--r--engines/sci/sci.cpp9
-rw-r--r--engines/sci/sci.h8
14 files changed, 45 insertions, 35 deletions
diff --git a/engines/sci/console.cpp b/engines/sci/console.cpp
index d6193ba92e..d6c3b07f75 100644
--- a/engines/sci/console.cpp
+++ b/engines/sci/console.cpp
@@ -30,11 +30,12 @@
#include "sci/debug.h"
#include "sci/event.h"
#include "sci/resource.h"
-#include "sci/engine/savegame.h"
#include "sci/engine/state.h"
#include "sci/engine/selector.h"
-#include "sci/engine/gc.h"
+#include "sci/engine/savegame.h"
#include "sci/engine/kernel_types.h" // for determine_reg_type
+#include "sci/engine/gc.h"
+#include "sci/engine/features.h"
#ifdef USE_OLD_MUSIC_FUNCTIONS
#include "sci/sound/iterator/songlib.h" // for SongLibrary
#include "sci/sound/iterator/iterator.h" // for SCI_SONG_ITERATOR_TYPE_SCI0
@@ -418,11 +419,11 @@ bool Console::cmdGetVersion(int argc, const char **argv) {
DebugPrintf("\n");
DebugPrintf("Detected features:\n");
DebugPrintf("------------------\n");
- DebugPrintf("Sound type: %s\n", getSciVersionDesc(s->_features->detectDoSoundType()));
- DebugPrintf("Graphics functions type: %s\n", getSciVersionDesc(s->_features->detectGfxFunctionsType()));
- DebugPrintf("Lofs type: %s\n", getSciVersionDesc(s->_features->detectLofsType()));
- DebugPrintf("Move count type: %s\n", (s->_features->detectMoveCountType() == kIncrementMoveCount) ? "increment" : "ignore");
- DebugPrintf("SetCursor type: %s\n", getSciVersionDesc(s->_features->detectSetCursorType()));
+ DebugPrintf("Sound type: %s\n", getSciVersionDesc(_engine->_features->detectDoSoundType()));
+ DebugPrintf("Graphics functions type: %s\n", getSciVersionDesc(_engine->_features->detectGfxFunctionsType()));
+ DebugPrintf("Lofs type: %s\n", getSciVersionDesc(_engine->_features->detectLofsType()));
+ DebugPrintf("Move count type: %s\n", (_engine->_features->detectMoveCountType() == kIncrementMoveCount) ? "increment" : "ignore");
+ DebugPrintf("SetCursor type: %s\n", getSciVersionDesc(_engine->_features->detectSetCursorType()));
DebugPrintf("View type: %s\n", viewTypeDesc[g_sci->getResMan()->getViewType()]);
DebugPrintf("Resource volume version: %s\n", g_sci->getResMan()->getVolVersionDesc());
DebugPrintf("Resource map version: %s\n", g_sci->getResMan()->getMapVersionDesc());
@@ -1593,7 +1594,7 @@ bool Console::cmdIsSample(int argc, const char **argv) {
return true;
}
- SoundResource *soundRes = new SoundResource(number, _engine->getResMan(), _engine->_gamestate->_features->detectDoSoundType());
+ SoundResource *soundRes = new SoundResource(number, _engine->getResMan(), _engine->_features->detectDoSoundType());
if (!soundRes) {
DebugPrintf("Not a sound resource!\n");
diff --git a/engines/sci/engine/game.cpp b/engines/sci/engine/game.cpp
index 5b61fdd734..52fc47c4d6 100644
--- a/engines/sci/engine/game.cpp
+++ b/engines/sci/engine/game.cpp
@@ -30,6 +30,7 @@
#include "sci/sci.h"
#include "sci/resource.h"
+#include "sci/engine/features.h"
#include "sci/engine/state.h"
#include "sci/engine/kernel.h"
#include "sci/engine/kernel_types.h"
@@ -221,7 +222,7 @@ int script_init_engine(EngineState *s) {
s->_breakpoints.clear(); // No breakpoints defined
s->_activeBreakpointTypes = 0;
- if (s->_features->detectLofsType() == SCI_VERSION_1_MIDDLE)
+ if (g_sci->_features->detectLofsType() == SCI_VERSION_1_MIDDLE)
s->_segMan->setExportAreWide(true);
else
s->_segMan->setExportAreWide(false);
@@ -280,7 +281,7 @@ int game_init(EngineState *s) {
#ifdef USE_OLD_MUSIC_FUNCTIONS
if (s->sfx_init_flags & SFX_STATE_FLAG_NOSOUND)
- game_init_sound(s, 0, s->_features->detectDoSoundType());
+ game_init_sound(s, 0, g_sci->_features->detectDoSoundType());
#endif
// Load game language into printLang property of game object
@@ -296,7 +297,7 @@ int game_exit(EngineState *s) {
#ifdef USE_OLD_MUSIC_FUNCTIONS
s->_sound.sfx_exit();
// Reinit because some other code depends on having a valid state
- game_init_sound(s, SFX_STATE_FLAG_NOSOUND, s->_features->detectDoSoundType());
+ game_init_sound(s, SFX_STATE_FLAG_NOSOUND, g_sci->_features->detectDoSoundType());
#else
s->_audio->stopAllAudio();
s->_soundCmd->clearPlayList();
diff --git a/engines/sci/engine/kernel32.cpp b/engines/sci/engine/kernel32.cpp
index 035388cbc2..f37631ec80 100644
--- a/engines/sci/engine/kernel32.cpp
+++ b/engines/sci/engine/kernel32.cpp
@@ -25,6 +25,7 @@
#ifdef ENABLE_SCI32
+#include "sci/engine/features.h"
#include "sci/engine/kernel.h"
#include "sci/engine/segment.h"
#include "sci/engine/state.h"
@@ -383,7 +384,7 @@ void Kernel::setKernelNamesSci21(EngineState *s) {
// This is interesting because they all have the same interpreter version (2.100.002), yet
// they would not be compatible with other games of the same interpreter.
- if (s->_features->detectSci21KernelType() == SCI_VERSION_2) {
+ if (g_sci->_features->detectSci21KernelType() == SCI_VERSION_2) {
_kernelNames = Common::StringList(sci2_default_knames, kKernelEntriesGk2Demo);
// OnMe is IsOnMe here, but they should be compatible
_kernelNames[0x23] = "Robot"; // Graph in SCI2
diff --git a/engines/sci/engine/kevent.cpp b/engines/sci/engine/kevent.cpp
index 72dba8b6d5..156035b30d 100644
--- a/engines/sci/engine/kevent.cpp
+++ b/engines/sci/engine/kevent.cpp
@@ -24,6 +24,7 @@
*/
#include "sci/sci.h"
+#include "sci/engine/features.h"
#include "sci/engine/state.h"
#include "sci/engine/selector.h"
#include "sci/engine/kernel.h"
@@ -147,7 +148,7 @@ reg_t kGetEvent(EngineState *s, int argc, reg_t *argv) {
}
#ifndef USE_OLD_MUSIC_FUNCTIONS
- if (s->_features->detectDoSoundType() <= SCI_VERSION_0_LATE) {
+ if (g_sci->_features->detectDoSoundType() <= SCI_VERSION_0_LATE) {
// If we're running a SCI0 game, update the sound cues, to compensate
// for the fact that SCI0 does not poll to update the sound cues itself,
// like SCI01 and later do with cmdUpdateSoundCues. kGetEvent is called
diff --git a/engines/sci/engine/kgraphics.cpp b/engines/sci/engine/kgraphics.cpp
index e82bf17182..8eb2401b3a 100644
--- a/engines/sci/engine/kgraphics.cpp
+++ b/engines/sci/engine/kgraphics.cpp
@@ -31,6 +31,7 @@
#include "sci/debug.h" // for g_debug_sleeptime_factor
#include "sci/resource.h"
#include "sci/video/seq_decoder.h"
+#include "sci/engine/features.h"
#include "sci/engine/state.h"
#include "sci/engine/selector.h"
#include "sci/engine/kernel.h"
@@ -168,7 +169,7 @@ static reg_t kSetCursorSci11(EngineState *s, int argc, reg_t *argv) {
}
reg_t kSetCursor(EngineState *s, int argc, reg_t *argv) {
- switch (s->_features->detectSetCursorType()) {
+ switch (g_sci->_features->detectSetCursorType()) {
case SCI_VERSION_0_EARLY:
return kSetCursorSci0(s, argc, argv);
case SCI_VERSION_1_1:
@@ -517,7 +518,7 @@ reg_t kDrawPic(EngineState *s, int argc, reg_t *argv) {
if (argc >= 3) {
if (!argv[2].isNull())
addToFlag = true;
- if (!s->_features->usesOldGfxFunctions())
+ if (!g_sci->_features->usesOldGfxFunctions())
addToFlag = !addToFlag;
}
if (argc >= 4)
diff --git a/engines/sci/engine/kmovement.cpp b/engines/sci/engine/kmovement.cpp
index 67fd835d67..b91ccadce6 100644
--- a/engines/sci/engine/kmovement.cpp
+++ b/engines/sci/engine/kmovement.cpp
@@ -25,6 +25,7 @@
#include "sci/sci.h"
#include "sci/resource.h"
+#include "sci/engine/features.h"
#include "sci/engine/state.h"
#include "sci/engine/selector.h"
#include "sci/engine/kernel.h"
@@ -267,7 +268,7 @@ reg_t kDoBresen(EngineState *s, int argc, reg_t *argv) {
//printf("movecnt %d, move speed %d\n", movcnt, max_movcnt);
- if (s->_features->handleMoveCount()) {
+ if (g_sci->_features->handleMoveCount()) {
if (max_movcnt > movcnt) {
++movcnt;
PUT_SEL32V(segMan, mover, SELECTOR(b_movCnt), movcnt); // Needed for HQ1/Ogre?
diff --git a/engines/sci/engine/ksound.cpp b/engines/sci/engine/ksound.cpp
index 21a22438d2..c3d572c174 100644
--- a/engines/sci/engine/ksound.cpp
+++ b/engines/sci/engine/ksound.cpp
@@ -24,10 +24,11 @@
*/
#include "sci/sci.h"
+#include "sci/engine/features.h"
#include "sci/engine/state.h"
-#include "sci/sound/soundcmd.h"
#include "sci/engine/kernel.h"
#include "sci/engine/vm.h" // for Object
+#include "sci/sound/soundcmd.h"
#include "sound/mixer.h"
@@ -90,7 +91,7 @@ reg_t kDoCdAudio(EngineState *s, int argc, reg_t *argv) {
reg_t kDoAudio(EngineState *s, int argc, reg_t *argv) {
// JonesCD uses different functions based on the cdaudio.map file
// to use red book tracks.
- if (s->_features->usesCdTrack())
+ if (g_sci->_features->usesCdTrack())
return kDoCdAudio(s, argc, argv);
Audio::Mixer *mixer = g_system->getMixer();
diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp
index d579b29b9e..cef8525200 100644
--- a/engines/sci/engine/savegame.cpp
+++ b/engines/sci/engine/savegame.cpp
@@ -32,6 +32,7 @@
#include "sci/sci.h"
#include "sci/event.h"
+#include "sci/engine/features.h"
#include "sci/engine/state.h"
#include "sci/engine/message.h"
#include "sci/engine/savegame.h"
@@ -966,7 +967,7 @@ void gamestate_restore(EngineState *s, Common::SeekableReadStream *fh) {
#ifdef USE_OLD_MUSIC_FUNCTIONS
temp = retval->_sound._songlib;
- retval->_sound.sfx_init(retval->resMan, s->sfx_init_flags, s->_features->detectDoSoundType());
+ retval->_sound.sfx_init(retval->resMan, s->sfx_init_flags, g_sci->_features->detectDoSoundType());
retval->sfx_init_flags = s->sfx_init_flags;
retval->_sound._songlib.freeSounds();
retval->_sound._songlib = temp;
@@ -1018,7 +1019,7 @@ void gamestate_restore(EngineState *s, Common::SeekableReadStream *fh) {
} else {
#endif
g_sci->_gui->resetEngineState(retval);
- g_sci->_gui->init(retval->_features->usesOldGfxFunctions());
+ g_sci->_gui->init(g_sci->_features->usesOldGfxFunctions());
#ifdef ENABLE_SCI32
}
#endif
diff --git a/engines/sci/engine/script.cpp b/engines/sci/engine/script.cpp
index 58302b1aeb..b09462e70c 100644
--- a/engines/sci/engine/script.cpp
+++ b/engines/sci/engine/script.cpp
@@ -25,6 +25,7 @@
#include "sci/sci.h"
#include "sci/resource.h"
+#include "sci/engine/features.h"
#include "sci/engine/state.h"
#include "sci/engine/kernel.h"
#include "sci/engine/script.h"
@@ -95,7 +96,7 @@ opcode_format g_opcode_formats[128][4] = {
// constructor (?) of a VirtualMachine or a ScriptManager class.
void script_adjust_opcode_formats(EngineState *s) {
// TODO: Check that this is correct
- if (s->_features->detectLofsType() != SCI_VERSION_0_EARLY) {
+ if (g_sci->_features->detectLofsType() != SCI_VERSION_0_EARLY) {
g_opcode_formats[op_lofsa][0] = Script_Offset;
g_opcode_formats[op_lofss][0] = Script_Offset;
}
diff --git a/engines/sci/engine/state.cpp b/engines/sci/engine/state.cpp
index 6599a8b287..d61bc7ede8 100644
--- a/engines/sci/engine/state.cpp
+++ b/engines/sci/engine/state.cpp
@@ -40,8 +40,6 @@ EngineState::EngineState(Kernel *kernel, Vocabulary *voc, SegManager *segMan, Au
sfx_init_flags = 0;
#endif
- _features = new GameFeatures(_segMan, _kernel);
-
restarting_flags = 0;
last_wait_time = 0;
@@ -80,7 +78,6 @@ EngineState::EngineState(Kernel *kernel, Vocabulary *voc, SegManager *segMan, Au
}
EngineState::~EngineState() {
- delete _features;
delete _msgState;
}
diff --git a/engines/sci/engine/state.h b/engines/sci/engine/state.h
index afa3389464..eca061027c 100644
--- a/engines/sci/engine/state.h
+++ b/engines/sci/engine/state.h
@@ -36,8 +36,6 @@ namespace Common {
}
#include "sci/sci.h"
-#include "sci/resource.h"
-#include "sci/engine/features.h"
#include "sci/engine/seg_manager.h"
#include "sci/parser/vocabulary.h"
@@ -122,8 +120,6 @@ public:
Common::String _gameId; /**< Designation of the primary object (which inherits from Game) */
- GameFeatures *_features;
-
/* Non-VM information */
SciEvent *_event; // Event handling
diff --git a/engines/sci/engine/vm.cpp b/engines/sci/engine/vm.cpp
index aac08c09e2..9c1e203c5f 100644
--- a/engines/sci/engine/vm.cpp
+++ b/engines/sci/engine/vm.cpp
@@ -31,6 +31,7 @@
#include "sci/console.h"
#include "sci/debug.h" // for g_debugState
#include "sci/resource.h"
+#include "sci/engine/features.h"
#include "sci/engine/state.h"
#include "sci/engine/kernel.h"
#include "sci/engine/kernel_types.h"
@@ -1385,7 +1386,7 @@ void run_vm(EngineState *s, bool restoring) {
case op_lofsa: // 0x39 (57)
s->r_acc.segment = scriptState.xs->addr.pc.segment;
- switch (s->_features->detectLofsType()) {
+ switch (g_sci->_features->detectLofsType()) {
case SCI_VERSION_1_1:
s->r_acc.offset = opparams[0] + local_script->_scriptSize;
break;
@@ -1407,7 +1408,7 @@ void run_vm(EngineState *s, bool restoring) {
case op_lofss: // 0x3a (58)
r_temp.segment = scriptState.xs->addr.pc.segment;
- switch (s->_features->detectLofsType()) {
+ switch (g_sci->_features->detectLofsType()) {
case SCI_VERSION_1_1:
r_temp.offset = opparams[0] + local_script->_scriptSize;
break;
diff --git a/engines/sci/sci.cpp b/engines/sci/sci.cpp
index 40bb1f03cc..fc6fc218f6 100644
--- a/engines/sci/sci.cpp
+++ b/engines/sci/sci.cpp
@@ -33,6 +33,7 @@
#include "sci/console.h"
#include "sci/event.h"
+#include "sci/engine/features.h"
#include "sci/engine/state.h"
#include "sci/engine/kernel.h"
#include "sci/engine/script.h" // for script_adjust_opcode_formats
@@ -65,6 +66,7 @@ SciEngine::SciEngine(OSystem *syst, const ADGameDescription *desc)
assert(g_sci = 0);
g_sci = this;
+ _features = 0;
// Set up the engine specific debug levels
Common::addDebugChannel(kDebugLevelError, "Error", "Script error debugging");
@@ -117,6 +119,7 @@ SciEngine::~SciEngine() {
delete _vocabulary;
delete _console;
delete _resMan;
+ delete _features;
g_sci = 0;
}
@@ -175,6 +178,8 @@ Common::Error SciEngine::run() {
SegManager *segMan = new SegManager(_resMan);
+ _features = new GameFeatures(segMan, _kernel);
+
// We'll set the GUI below
_gamestate = new EngineState(_kernel, _vocabulary, segMan, _audio);
_gamestate->_event = new SciEvent();
@@ -223,7 +228,7 @@ Common::Error SciEngine::run() {
assert(_gamestate->sys_strings->_strings[SYS_STRING_SAVEDIR]._value != 0);
strcpy(_gamestate->sys_strings->_strings[SYS_STRING_SAVEDIR]._value, "");
- SciVersion soundVersion = _gamestate->_features->detectDoSoundType();
+ SciVersion soundVersion = _features->detectDoSoundType();
_gamestate->_soundCmd = new SoundCommandParser(_resMan, segMan, _kernel, _audio, soundVersion);
@@ -243,7 +248,7 @@ Common::Error SciEngine::run() {
_gui32->init();
else
#endif
- _gui->init(_gamestate->_features->usesOldGfxFunctions());
+ _gui->init(_features->usesOldGfxFunctions());
debug("Emulating SCI version %s\n", getSciVersionDesc(getSciVersion()));
diff --git a/engines/sci/sci.h b/engines/sci/sci.h
index 4fbdf775ef..c411f48bc9 100644
--- a/engines/sci/sci.h
+++ b/engines/sci/sci.h
@@ -44,14 +44,14 @@ namespace Sci {
// Uncomment this to use old music functions
//#define USE_OLD_MUSIC_FUNCTIONS
-class Console;
struct EngineState;
-class Kernel;
class Vocabulary;
class ResourceManager;
+class Kernel;
+class GameFeatures;
+class Console;
class AudioPlayer;
-class SciEvent;
class GfxAnimate;
class GfxCache;
class GfxCompare;
@@ -185,6 +185,8 @@ public:
GfxFrameout *_gfxFrameout; // kFrameout and the like for 32-bit gfx
#endif
+ GameFeatures *_features;
+
private:
const ADGameDescription *_gameDescription;
AudioPlayer *_audio;