WIP (still non-working) code for speech sync in CD talkie games (like e.g. KQ5 CD and SQ4 CD), taken from Greg's SCI implementation.
svn-id: r40142
This commit is contained in:
parent
86debbd679
commit
f1893d8f25
7 changed files with 95 additions and 2 deletions
|
@ -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},
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 */
|
||||
};
|
||||
|
||||
/***********/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue