SCI: Move GameFeatures from EngineState to SciEngine

svn-id: r48049
This commit is contained in:
Max Horn 2010-02-13 17:44:58 +00:00
parent a82939c9be
commit 9575cc08a2
14 changed files with 45 additions and 35 deletions

View file

@ -30,11 +30,12 @@
#include "sci/debug.h" #include "sci/debug.h"
#include "sci/event.h" #include "sci/event.h"
#include "sci/resource.h" #include "sci/resource.h"
#include "sci/engine/savegame.h"
#include "sci/engine/state.h" #include "sci/engine/state.h"
#include "sci/engine/selector.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/kernel_types.h" // for determine_reg_type
#include "sci/engine/gc.h"
#include "sci/engine/features.h"
#ifdef USE_OLD_MUSIC_FUNCTIONS #ifdef USE_OLD_MUSIC_FUNCTIONS
#include "sci/sound/iterator/songlib.h" // for SongLibrary #include "sci/sound/iterator/songlib.h" // for SongLibrary
#include "sci/sound/iterator/iterator.h" // for SCI_SONG_ITERATOR_TYPE_SCI0 #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("\n");
DebugPrintf("Detected features:\n"); DebugPrintf("Detected features:\n");
DebugPrintf("------------------\n"); DebugPrintf("------------------\n");
DebugPrintf("Sound type: %s\n", getSciVersionDesc(s->_features->detectDoSoundType())); DebugPrintf("Sound type: %s\n", getSciVersionDesc(_engine->_features->detectDoSoundType()));
DebugPrintf("Graphics functions type: %s\n", getSciVersionDesc(s->_features->detectGfxFunctionsType())); DebugPrintf("Graphics functions type: %s\n", getSciVersionDesc(_engine->_features->detectGfxFunctionsType()));
DebugPrintf("Lofs type: %s\n", getSciVersionDesc(s->_features->detectLofsType())); DebugPrintf("Lofs type: %s\n", getSciVersionDesc(_engine->_features->detectLofsType()));
DebugPrintf("Move count type: %s\n", (s->_features->detectMoveCountType() == kIncrementMoveCount) ? "increment" : "ignore"); DebugPrintf("Move count type: %s\n", (_engine->_features->detectMoveCountType() == kIncrementMoveCount) ? "increment" : "ignore");
DebugPrintf("SetCursor type: %s\n", getSciVersionDesc(s->_features->detectSetCursorType())); DebugPrintf("SetCursor type: %s\n", getSciVersionDesc(_engine->_features->detectSetCursorType()));
DebugPrintf("View type: %s\n", viewTypeDesc[g_sci->getResMan()->getViewType()]); DebugPrintf("View type: %s\n", viewTypeDesc[g_sci->getResMan()->getViewType()]);
DebugPrintf("Resource volume version: %s\n", g_sci->getResMan()->getVolVersionDesc()); DebugPrintf("Resource volume version: %s\n", g_sci->getResMan()->getVolVersionDesc());
DebugPrintf("Resource map version: %s\n", g_sci->getResMan()->getMapVersionDesc()); DebugPrintf("Resource map version: %s\n", g_sci->getResMan()->getMapVersionDesc());
@ -1593,7 +1594,7 @@ bool Console::cmdIsSample(int argc, const char **argv) {
return true; 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) { if (!soundRes) {
DebugPrintf("Not a sound resource!\n"); DebugPrintf("Not a sound resource!\n");

View file

@ -30,6 +30,7 @@
#include "sci/sci.h" #include "sci/sci.h"
#include "sci/resource.h" #include "sci/resource.h"
#include "sci/engine/features.h"
#include "sci/engine/state.h" #include "sci/engine/state.h"
#include "sci/engine/kernel.h" #include "sci/engine/kernel.h"
#include "sci/engine/kernel_types.h" #include "sci/engine/kernel_types.h"
@ -221,7 +222,7 @@ int script_init_engine(EngineState *s) {
s->_breakpoints.clear(); // No breakpoints defined s->_breakpoints.clear(); // No breakpoints defined
s->_activeBreakpointTypes = 0; s->_activeBreakpointTypes = 0;
if (s->_features->detectLofsType() == SCI_VERSION_1_MIDDLE) if (g_sci->_features->detectLofsType() == SCI_VERSION_1_MIDDLE)
s->_segMan->setExportAreWide(true); s->_segMan->setExportAreWide(true);
else else
s->_segMan->setExportAreWide(false); s->_segMan->setExportAreWide(false);
@ -280,7 +281,7 @@ int game_init(EngineState *s) {
#ifdef USE_OLD_MUSIC_FUNCTIONS #ifdef USE_OLD_MUSIC_FUNCTIONS
if (s->sfx_init_flags & SFX_STATE_FLAG_NOSOUND) 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 #endif
// Load game language into printLang property of game object // Load game language into printLang property of game object
@ -296,7 +297,7 @@ int game_exit(EngineState *s) {
#ifdef USE_OLD_MUSIC_FUNCTIONS #ifdef USE_OLD_MUSIC_FUNCTIONS
s->_sound.sfx_exit(); s->_sound.sfx_exit();
// Reinit because some other code depends on having a valid state // 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 #else
s->_audio->stopAllAudio(); s->_audio->stopAllAudio();
s->_soundCmd->clearPlayList(); s->_soundCmd->clearPlayList();

View file

@ -25,6 +25,7 @@
#ifdef ENABLE_SCI32 #ifdef ENABLE_SCI32
#include "sci/engine/features.h"
#include "sci/engine/kernel.h" #include "sci/engine/kernel.h"
#include "sci/engine/segment.h" #include "sci/engine/segment.h"
#include "sci/engine/state.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 // 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. // 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); _kernelNames = Common::StringList(sci2_default_knames, kKernelEntriesGk2Demo);
// OnMe is IsOnMe here, but they should be compatible // OnMe is IsOnMe here, but they should be compatible
_kernelNames[0x23] = "Robot"; // Graph in SCI2 _kernelNames[0x23] = "Robot"; // Graph in SCI2

View file

@ -24,6 +24,7 @@
*/ */
#include "sci/sci.h" #include "sci/sci.h"
#include "sci/engine/features.h"
#include "sci/engine/state.h" #include "sci/engine/state.h"
#include "sci/engine/selector.h" #include "sci/engine/selector.h"
#include "sci/engine/kernel.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 #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 // 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, // for the fact that SCI0 does not poll to update the sound cues itself,
// like SCI01 and later do with cmdUpdateSoundCues. kGetEvent is called // like SCI01 and later do with cmdUpdateSoundCues. kGetEvent is called

View file

@ -31,6 +31,7 @@
#include "sci/debug.h" // for g_debug_sleeptime_factor #include "sci/debug.h" // for g_debug_sleeptime_factor
#include "sci/resource.h" #include "sci/resource.h"
#include "sci/video/seq_decoder.h" #include "sci/video/seq_decoder.h"
#include "sci/engine/features.h"
#include "sci/engine/state.h" #include "sci/engine/state.h"
#include "sci/engine/selector.h" #include "sci/engine/selector.h"
#include "sci/engine/kernel.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) { reg_t kSetCursor(EngineState *s, int argc, reg_t *argv) {
switch (s->_features->detectSetCursorType()) { switch (g_sci->_features->detectSetCursorType()) {
case SCI_VERSION_0_EARLY: case SCI_VERSION_0_EARLY:
return kSetCursorSci0(s, argc, argv); return kSetCursorSci0(s, argc, argv);
case SCI_VERSION_1_1: case SCI_VERSION_1_1:
@ -517,7 +518,7 @@ reg_t kDrawPic(EngineState *s, int argc, reg_t *argv) {
if (argc >= 3) { if (argc >= 3) {
if (!argv[2].isNull()) if (!argv[2].isNull())
addToFlag = true; addToFlag = true;
if (!s->_features->usesOldGfxFunctions()) if (!g_sci->_features->usesOldGfxFunctions())
addToFlag = !addToFlag; addToFlag = !addToFlag;
} }
if (argc >= 4) if (argc >= 4)

View file

@ -25,6 +25,7 @@
#include "sci/sci.h" #include "sci/sci.h"
#include "sci/resource.h" #include "sci/resource.h"
#include "sci/engine/features.h"
#include "sci/engine/state.h" #include "sci/engine/state.h"
#include "sci/engine/selector.h" #include "sci/engine/selector.h"
#include "sci/engine/kernel.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); //printf("movecnt %d, move speed %d\n", movcnt, max_movcnt);
if (s->_features->handleMoveCount()) { if (g_sci->_features->handleMoveCount()) {
if (max_movcnt > movcnt) { if (max_movcnt > movcnt) {
++movcnt; ++movcnt;
PUT_SEL32V(segMan, mover, SELECTOR(b_movCnt), movcnt); // Needed for HQ1/Ogre? PUT_SEL32V(segMan, mover, SELECTOR(b_movCnt), movcnt); // Needed for HQ1/Ogre?

View file

@ -24,10 +24,11 @@
*/ */
#include "sci/sci.h" #include "sci/sci.h"
#include "sci/engine/features.h"
#include "sci/engine/state.h" #include "sci/engine/state.h"
#include "sci/sound/soundcmd.h"
#include "sci/engine/kernel.h" #include "sci/engine/kernel.h"
#include "sci/engine/vm.h" // for Object #include "sci/engine/vm.h" // for Object
#include "sci/sound/soundcmd.h"
#include "sound/mixer.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) { reg_t kDoAudio(EngineState *s, int argc, reg_t *argv) {
// JonesCD uses different functions based on the cdaudio.map file // JonesCD uses different functions based on the cdaudio.map file
// to use red book tracks. // to use red book tracks.
if (s->_features->usesCdTrack()) if (g_sci->_features->usesCdTrack())
return kDoCdAudio(s, argc, argv); return kDoCdAudio(s, argc, argv);
Audio::Mixer *mixer = g_system->getMixer(); Audio::Mixer *mixer = g_system->getMixer();

View file

@ -32,6 +32,7 @@
#include "sci/sci.h" #include "sci/sci.h"
#include "sci/event.h" #include "sci/event.h"
#include "sci/engine/features.h"
#include "sci/engine/state.h" #include "sci/engine/state.h"
#include "sci/engine/message.h" #include "sci/engine/message.h"
#include "sci/engine/savegame.h" #include "sci/engine/savegame.h"
@ -966,7 +967,7 @@ void gamestate_restore(EngineState *s, Common::SeekableReadStream *fh) {
#ifdef USE_OLD_MUSIC_FUNCTIONS #ifdef USE_OLD_MUSIC_FUNCTIONS
temp = retval->_sound._songlib; 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->sfx_init_flags = s->sfx_init_flags;
retval->_sound._songlib.freeSounds(); retval->_sound._songlib.freeSounds();
retval->_sound._songlib = temp; retval->_sound._songlib = temp;
@ -1018,7 +1019,7 @@ void gamestate_restore(EngineState *s, Common::SeekableReadStream *fh) {
} else { } else {
#endif #endif
g_sci->_gui->resetEngineState(retval); g_sci->_gui->resetEngineState(retval);
g_sci->_gui->init(retval->_features->usesOldGfxFunctions()); g_sci->_gui->init(g_sci->_features->usesOldGfxFunctions());
#ifdef ENABLE_SCI32 #ifdef ENABLE_SCI32
} }
#endif #endif

View file

@ -25,6 +25,7 @@
#include "sci/sci.h" #include "sci/sci.h"
#include "sci/resource.h" #include "sci/resource.h"
#include "sci/engine/features.h"
#include "sci/engine/state.h" #include "sci/engine/state.h"
#include "sci/engine/kernel.h" #include "sci/engine/kernel.h"
#include "sci/engine/script.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. // constructor (?) of a VirtualMachine or a ScriptManager class.
void script_adjust_opcode_formats(EngineState *s) { void script_adjust_opcode_formats(EngineState *s) {
// TODO: Check that this is correct // 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_lofsa][0] = Script_Offset;
g_opcode_formats[op_lofss][0] = Script_Offset; g_opcode_formats[op_lofss][0] = Script_Offset;
} }

View file

@ -40,8 +40,6 @@ EngineState::EngineState(Kernel *kernel, Vocabulary *voc, SegManager *segMan, Au
sfx_init_flags = 0; sfx_init_flags = 0;
#endif #endif
_features = new GameFeatures(_segMan, _kernel);
restarting_flags = 0; restarting_flags = 0;
last_wait_time = 0; last_wait_time = 0;
@ -80,7 +78,6 @@ EngineState::EngineState(Kernel *kernel, Vocabulary *voc, SegManager *segMan, Au
} }
EngineState::~EngineState() { EngineState::~EngineState() {
delete _features;
delete _msgState; delete _msgState;
} }

View file

@ -36,8 +36,6 @@ namespace Common {
} }
#include "sci/sci.h" #include "sci/sci.h"
#include "sci/resource.h"
#include "sci/engine/features.h"
#include "sci/engine/seg_manager.h" #include "sci/engine/seg_manager.h"
#include "sci/parser/vocabulary.h" #include "sci/parser/vocabulary.h"
@ -122,8 +120,6 @@ public:
Common::String _gameId; /**< Designation of the primary object (which inherits from Game) */ Common::String _gameId; /**< Designation of the primary object (which inherits from Game) */
GameFeatures *_features;
/* Non-VM information */ /* Non-VM information */
SciEvent *_event; // Event handling SciEvent *_event; // Event handling

View file

@ -31,6 +31,7 @@
#include "sci/console.h" #include "sci/console.h"
#include "sci/debug.h" // for g_debugState #include "sci/debug.h" // for g_debugState
#include "sci/resource.h" #include "sci/resource.h"
#include "sci/engine/features.h"
#include "sci/engine/state.h" #include "sci/engine/state.h"
#include "sci/engine/kernel.h" #include "sci/engine/kernel.h"
#include "sci/engine/kernel_types.h" #include "sci/engine/kernel_types.h"
@ -1385,7 +1386,7 @@ void run_vm(EngineState *s, bool restoring) {
case op_lofsa: // 0x39 (57) case op_lofsa: // 0x39 (57)
s->r_acc.segment = scriptState.xs->addr.pc.segment; s->r_acc.segment = scriptState.xs->addr.pc.segment;
switch (s->_features->detectLofsType()) { switch (g_sci->_features->detectLofsType()) {
case SCI_VERSION_1_1: case SCI_VERSION_1_1:
s->r_acc.offset = opparams[0] + local_script->_scriptSize; s->r_acc.offset = opparams[0] + local_script->_scriptSize;
break; break;
@ -1407,7 +1408,7 @@ void run_vm(EngineState *s, bool restoring) {
case op_lofss: // 0x3a (58) case op_lofss: // 0x3a (58)
r_temp.segment = scriptState.xs->addr.pc.segment; r_temp.segment = scriptState.xs->addr.pc.segment;
switch (s->_features->detectLofsType()) { switch (g_sci->_features->detectLofsType()) {
case SCI_VERSION_1_1: case SCI_VERSION_1_1:
r_temp.offset = opparams[0] + local_script->_scriptSize; r_temp.offset = opparams[0] + local_script->_scriptSize;
break; break;

View file

@ -33,6 +33,7 @@
#include "sci/console.h" #include "sci/console.h"
#include "sci/event.h" #include "sci/event.h"
#include "sci/engine/features.h"
#include "sci/engine/state.h" #include "sci/engine/state.h"
#include "sci/engine/kernel.h" #include "sci/engine/kernel.h"
#include "sci/engine/script.h" // for script_adjust_opcode_formats #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); assert(g_sci = 0);
g_sci = this; g_sci = this;
_features = 0;
// Set up the engine specific debug levels // Set up the engine specific debug levels
Common::addDebugChannel(kDebugLevelError, "Error", "Script error debugging"); Common::addDebugChannel(kDebugLevelError, "Error", "Script error debugging");
@ -117,6 +119,7 @@ SciEngine::~SciEngine() {
delete _vocabulary; delete _vocabulary;
delete _console; delete _console;
delete _resMan; delete _resMan;
delete _features;
g_sci = 0; g_sci = 0;
} }
@ -175,6 +178,8 @@ Common::Error SciEngine::run() {
SegManager *segMan = new SegManager(_resMan); SegManager *segMan = new SegManager(_resMan);
_features = new GameFeatures(segMan, _kernel);
// We'll set the GUI below // We'll set the GUI below
_gamestate = new EngineState(_kernel, _vocabulary, segMan, _audio); _gamestate = new EngineState(_kernel, _vocabulary, segMan, _audio);
_gamestate->_event = new SciEvent(); _gamestate->_event = new SciEvent();
@ -223,7 +228,7 @@ Common::Error SciEngine::run() {
assert(_gamestate->sys_strings->_strings[SYS_STRING_SAVEDIR]._value != 0); assert(_gamestate->sys_strings->_strings[SYS_STRING_SAVEDIR]._value != 0);
strcpy(_gamestate->sys_strings->_strings[SYS_STRING_SAVEDIR]._value, ""); 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); _gamestate->_soundCmd = new SoundCommandParser(_resMan, segMan, _kernel, _audio, soundVersion);
@ -243,7 +248,7 @@ Common::Error SciEngine::run() {
_gui32->init(); _gui32->init();
else else
#endif #endif
_gui->init(_gamestate->_features->usesOldGfxFunctions()); _gui->init(_features->usesOldGfxFunctions());
debug("Emulating SCI version %s\n", getSciVersionDesc(getSciVersion())); debug("Emulating SCI version %s\n", getSciVersionDesc(getSciVersion()));

View file

@ -44,14 +44,14 @@ namespace Sci {
// Uncomment this to use old music functions // Uncomment this to use old music functions
//#define USE_OLD_MUSIC_FUNCTIONS //#define USE_OLD_MUSIC_FUNCTIONS
class Console;
struct EngineState; struct EngineState;
class Kernel;
class Vocabulary; class Vocabulary;
class ResourceManager; class ResourceManager;
class Kernel;
class GameFeatures;
class Console;
class AudioPlayer; class AudioPlayer;
class SciEvent;
class GfxAnimate; class GfxAnimate;
class GfxCache; class GfxCache;
class GfxCompare; class GfxCompare;
@ -185,6 +185,8 @@ public:
GfxFrameout *_gfxFrameout; // kFrameout and the like for 32-bit gfx GfxFrameout *_gfxFrameout; // kFrameout and the like for 32-bit gfx
#endif #endif
GameFeatures *_features;
private: private:
const ADGameDescription *_gameDescription; const ADGameDescription *_gameDescription;
AudioPlayer *_audio; AudioPlayer *_audio;