diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/sci/engine/kernel.cpp | 2 | ||||
-rw-r--r-- | engines/sci/engine/kernel.h | 1 | ||||
-rw-r--r-- | engines/sci/engine/ksound.cpp | 43 | ||||
-rw-r--r-- | engines/sci/scicore/resource.cpp | 32 | ||||
-rw-r--r-- | engines/sci/scicore/resource.h | 16 | ||||
-rw-r--r-- | engines/sci/sfx/core.cpp | 1 | ||||
-rw-r--r-- | engines/sci/sfx/core.h | 2 |
7 files changed, 95 insertions, 2 deletions
diff --git a/engines/sci/engine/kernel.cpp b/engines/sci/engine/kernel.cpp index 7a3a87793f..5927e328c5 100644 --- a/engines/sci/engine/kernel.cpp +++ b/engines/sci/engine/kernel.cpp @@ -203,7 +203,7 @@ SciKernelFunction kfunct_mappers[] = { DEFUN("Message", kMessage, ".*"), DEFUN("GetMessage", kGetMessage, ".*"), DEFUN("DoAudio", kDoAudio, ".*"), - + DEFUN("DoSync", kDoSync, ".*"), // Special and NOP stuff {KF_NEW, NULL, k_Unknown, NULL}, diff --git a/engines/sci/engine/kernel.h b/engines/sci/engine/kernel.h index 1e49afda55..3975df5f0f 100644 --- a/engines/sci/engine/kernel.h +++ b/engines/sci/engine/kernel.h @@ -452,6 +452,7 @@ reg_t kIsItSkip(EngineState *s, int funct_nr, int argc, reg_t *argv); reg_t kMessage(EngineState *s, int funct_nr, int argc, reg_t *argv); reg_t kGetMessage(EngineState *s, int funct_nr, int argc, reg_t *argv); reg_t kDoAudio(EngineState *s, int funct_nr, int argc, reg_t *argv); +reg_t kDoSync(EngineState *s, int funct_nr, int argc, reg_t *argv); reg_t k_Unknown(EngineState *s, int funct_nr, int argc, reg_t *argv); // The Unknown/Unnamed kernel function diff --git a/engines/sci/engine/ksound.cpp b/engines/sci/engine/ksound.cpp index fbedf79504..4be6785e2e 100644 --- a/engines/sci/engine/ksound.cpp +++ b/engines/sci/engine/ksound.cpp @@ -26,6 +26,7 @@ #include "sci/engine/state.h" #include "sci/sfx/player.h" #include "sci/engine/kernel.h" +#include "sci/engine/vm.h" // for Object namespace Sci { @@ -989,4 +990,46 @@ reg_t kDoAudio(EngineState *s, int funct_nr, int argc, reg_t *argv) { return s->r_acc; } +reg_t kDoSync(EngineState *s, int funct_nr, int argc, reg_t *argv) { + switch (UKPV(0)) { + case 0: // start sync + //printf("kDoSync: start sync\n"); + if (s->sound.soundSync) { + s->resmgr->unlockResource(s->sound.soundSync, s->sound.soundSync->number, kResourceTypeSync); + } + + // Load sound sync resource and lock it + s->sound.soundSync = (ResourceSync *)s->resmgr->findResource(kResourceTypeSync, UKPV(2), 1); + + if (s->sound.soundSync) { + Object *obj = obj_get(s, argv[1]); + s->sound.soundSync->startSync(obj); + } else { + // Notify the scripts to stop sound sync + //Object *obj = obj_get(s, argv[1]); + // TODO: Convert the following from Greg's code to SCI's code + //obj.setPropertyN(_objOfs[0x33], 0xFFFF); // Greg's + //obj->variables[s->game_obj.offset[0x33]] = 0xFFFF; // something like this? + } + break; + case 1: // next sync + //printf("kDoSync: next sync\n"); + if (s->sound.soundSync) { + Object *obj = obj_get(s, argv[1]); + s->sound.soundSync->nextSync(obj); + } + break; + case 2: // stop sync + //printf("kDoSync: stop sync\n"); + if (s->sound.soundSync) { + s->sound.soundSync->stopSync(); + s->resmgr->unlockResource(s->sound.soundSync, s->sound.soundSync->number, kResourceTypeSync); + s->sound.soundSync = NULL; + } + break; + } + + return s->r_acc; +} + } // End of namespace Sci diff --git a/engines/sci/scicore/resource.cpp b/engines/sci/scicore/resource.cpp index ec738fea44..6132e4bae5 100644 --- a/engines/sci/scicore/resource.cpp +++ b/engines/sci/scicore/resource.cpp @@ -1167,4 +1167,36 @@ int ResourceManager::decompress(Resource *res, Common::File *file) { return error; } +void ResourceSync::startSync(Object *obj) { + _syncTime = _syncCue = 0xFFFF; + // TODO: Convert the following from Greg's code to SCI's code + //obj.setPropertyN(g_sci->_objOfs[0x33], 0); // Greg's + //obj->variables[s->game_obj.offset[0x33]] = 0; // something like this? + _ptr = (uint16 *)data; + //syncStarted = true; // not used +} + +void ResourceSync::nextSync(Object *obj) { + if (_ptr) { + _syncTime = READ_LE_UINT16(_ptr); + if (_syncTime == 0xFFFF) { + stopSync(); + } else { + _syncCue = READ_LE_UINT16(_ptr + 1); + _ptr += 2; + } + // TODO: Convert the following from Greg's code to SCI's code + //obj.setPropertyN(g_sci->_objOfs[0x32], _syncTime); // Greg's + //obj->variables[s->game_obj.offset[0x32]] = _syncTime; // something like this? + //obj.setPropertyN(g_sci->_objOfs[0x33], _syncCue); // Greg's + //obj->variables[s->game_obj.offset[0x33]] = _syncCue; // something like this? + } +} +//-------------------------------- +void ResourceSync::stopSync() { + _ptr = 0; + _syncCue = 0xFFFF; + //syncStarted = false; // not used +} + } // End of namespace Sci diff --git a/engines/sci/scicore/resource.h b/engines/sci/scicore/resource.h index 2f8abf8170..f9d95205d1 100644 --- a/engines/sci/scicore/resource.h +++ b/engines/sci/scicore/resource.h @@ -30,6 +30,7 @@ #include "common/file.h" #include "common/archive.h" +#include "sci/engine/vm.h" // for Object #include "sci/scicore/decompressor.h" namespace Common { @@ -301,6 +302,21 @@ protected: void removeFromLRU(Resource *res); }; +class ResourceSync : public Resource { +public: + ResourceSync() {} + ~ResourceSync() {} + + void startSync(Object *obj); + void nextSync(Object *obj); + void stopSync(); + +protected: + uint16 *_ptr; + uint16 _syncTime, _syncCue; + //bool _syncStarted; // not used +}; + } // End of namespace Sci #endif // SCI_SCICORE_RESOURCE_H diff --git a/engines/sci/sfx/core.cpp b/engines/sci/sfx/core.cpp index b573a52630..e35a3abad1 100644 --- a/engines/sci/sfx/core.cpp +++ b/engines/sci/sfx/core.cpp @@ -367,6 +367,7 @@ void sfx_init(sfx_state_t *self, ResourceManager *resmgr, int flags) { self->song = NULL; self->flags = flags; self->debug = 0; /* Disable all debugging by default */ + self->soundSync = NULL; if (flags & SFX_STATE_FLAG_NOSOUND) { player = NULL; diff --git a/engines/sci/sfx/core.h b/engines/sci/sfx/core.h index 3eb3cf1489..107c05a17e 100644 --- a/engines/sci/sfx/core.h +++ b/engines/sci/sfx/core.h @@ -55,7 +55,7 @@ struct sfx_state_t { song_t *song; /* Active song, or start of active song chain */ int suspended; /* Whether we are suspended */ unsigned int debug; /* Debug flags */ - + ResourceSync *soundSync; /* Used by kDoSync for speech syncing in talkie games */ }; /***********/ |