aboutsummaryrefslogtreecommitdiff
path: root/scumm
diff options
context:
space:
mode:
authorPaweł Kołodziejski2004-01-09 22:10:32 +0000
committerPaweł Kołodziejski2004-01-09 22:10:32 +0000
commit7ab3348329ee395cd72a6279517a738a3fe86fbd (patch)
treef94df1926cb097440cdcaf46c8beef7a285cfc39 /scumm
parent25854050deb1a7780c545946753b66fec3f64c66 (diff)
downloadscummvm-rg350-7ab3348329ee395cd72a6279517a738a3fe86fbd.tar.gz
scummvm-rg350-7ab3348329ee395cd72a6279517a738a3fe86fbd.tar.bz2
scummvm-rg350-7ab3348329ee395cd72a6279517a738a3fe86fbd.zip
added lipSync code
svn-id: r12284
Diffstat (limited to 'scumm')
-rw-r--r--scumm/imuse_digi/dimuse.cpp78
-rw-r--r--scumm/imuse_digi/dimuse.h5
-rw-r--r--scumm/imuse_digi/dimuse_sndmgr.cpp14
-rw-r--r--scumm/imuse_digi/dimuse_sndmgr.h2
-rw-r--r--scumm/scumm.h1
-rw-r--r--scumm/scummvm.cpp1
6 files changed, 81 insertions, 20 deletions
diff --git a/scumm/imuse_digi/dimuse.cpp b/scumm/imuse_digi/dimuse.cpp
index 664d33c47e..65f601b865 100644
--- a/scumm/imuse_digi/dimuse.cpp
+++ b/scumm/imuse_digi/dimuse.cpp
@@ -257,19 +257,16 @@ void IMuseDigital::startSound(int soundId, const char *soundName, int soundType,
channels = _sound->getChannels(_track[l].soundHandle);
freq = _sound->getFreq(_track[l].soundHandle);
- _track[l].iteration = freq * channels;
- if ((bits == 12) || (bits == 16))
- _track[l].iteration *= 2;
-
assert(channels == 1 || channels == 2);
- _track[l].pullSize = freq * channels;
- if (channels == 2) {
+
+ _track[l].iteration = _track[l].pullSize = freq * channels;
+
+ if (channels == 2)
mixerFlags = SoundMixer::FLAG_STEREO | SoundMixer::FLAG_REVERSE_STEREO;
- }
if ((bits == 12) || (bits == 16)) {
mixerFlags |= SoundMixer::FLAG_16BITS;
- _track[l].pullSize *= 2;
+ _track[l].iteration = _track[l].pullSize *= 2;
} else if (bits == 8) {
mixerFlags |= SoundMixer::FLAG_UNSIGNED;
} else
@@ -579,6 +576,39 @@ int IMuseDigital::getSoundStatus(int sound) const {
return 0;
}
+void IMuseDigital::getLipSync(int soundId, int syncId, int32 msPos, int32 &width, int32 &height) {
+ int32 param1 = 0, param2 = 0;
+ int32 sync_size;
+ byte *sync_ptr;
+
+ msPos /= 16;
+ if (msPos < 65536) {
+ for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) {
+ if ((_track[l].idSound == soundId) && _track[l].used) {
+ sync_size = _sound->getSyncSizeById(_track[l].soundHandle, syncId);
+ sync_ptr = _sound->getSyncPtrById(_track[l].soundHandle, syncId);
+ if ((sync_size != 0) && (sync_ptr != NULL)) {
+ sync_size /= 4;
+ while (sync_size--) {
+ if (READ_BE_UINT16(sync_ptr) >= msPos)
+ break;
+ sync_ptr += 4;
+ }
+ if (sync_size < 0)
+ sync_ptr -= 4;
+ else
+ if (READ_BE_UINT16(sync_ptr) > msPos)
+ sync_ptr -= 4;
+
+ width = sync_ptr[2];
+ height = sync_ptr[3];
+ return;
+ }
+ }
+ }
+ }
+}
+
int32 IMuseDigital::getPosInMs(int soundId) {
for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) {
if ((_track[l].idSound == soundId) && _track[l].used) {
@@ -596,23 +626,35 @@ int32 IMuseDigital::getCurMusicPosInMs() {
}
int32 IMuseDigital::getCurVoiceLipSyncWidth() {
-// int32 pos = getPosInMs(kTalkSoundID);
- return _vm->_rnd.getRandomNumber(255);
+ int32 msPos = getPosInMs(kTalkSoundID) + _vm->VAR(_vm->VAR_SYNC) + 50;
+ int32 width = 0, height = 0;
+
+ getLipSync(kTalkSoundID, 0, msPos, width, height);
+ return width;
}
int32 IMuseDigital::getCurVoiceLipSyncHeight() {
-// int32 pos = getPosInMs(kTalkSoundID);
- return _vm->_rnd.getRandomNumber(255);
+ int32 msPos = getPosInMs(kTalkSoundID) + _vm->VAR(_vm->VAR_SYNC) + 50;
+ int32 width = 0, height = 0;
+
+ getLipSync(kTalkSoundID, 0, msPos, width, height);
+ return height;
}
-int32 IMuseDigital::getCurMusicLipSyncWidth(int32 param) {
-// int32 pos = getPosInMs(_curMusicId);
- return _vm->_rnd.getRandomNumber(255);
+int32 IMuseDigital::getCurMusicLipSyncWidth(int syncId) {
+ int32 msPos = getPosInMs(_curMusicId) + _vm->VAR(_vm->VAR_SYNC) + 50;
+ int32 width = 0, height = 0;
+
+ getLipSync(_curMusicId, syncId, msPos, width, height);
+ return width;
}
-int32 IMuseDigital::getCurMusicLipSyncHeight(int32 param) {
-// int32 pos = getPosInMs(_curMusicId);
- return _vm->_rnd.getRandomNumber(255);
+int32 IMuseDigital::getCurMusicLipSyncHeight(int syncId) {
+ int32 msPos = getPosInMs(_curMusicId) + _vm->VAR(_vm->VAR_SYNC) + 50;
+ int32 width = 0, height = 0;
+
+ getLipSync(_curMusicId, syncId, msPos, width, height);
+ return height;
}
} // End of namespace Scumm
diff --git a/scumm/imuse_digi/dimuse.h b/scumm/imuse_digi/dimuse.h
index ba2485b9aa..918bab6e03 100644
--- a/scumm/imuse_digi/dimuse.h
+++ b/scumm/imuse_digi/dimuse.h
@@ -106,11 +106,12 @@ public:
void parseScriptCmds(int a, int b, int c, int d, int e, int f, int g, int h);
int getSoundStatus(int sound) const;
int32 getPosInMs(int soundId);
+ void getLipSync(int soundId, int syncId, int32 msPos, int32 &width, int32 &height);
int32 getCurMusicPosInMs();
int32 getCurVoiceLipSyncWidth();
int32 getCurVoiceLipSyncHeight();
- int32 getCurMusicLipSyncWidth(int32 param);
- int32 getCurMusicLipSyncHeight(int32 param);
+ int32 getCurMusicLipSyncWidth(int syncId);
+ int32 getCurMusicLipSyncHeight(int syncId);
};
struct imuse_music_table {
diff --git a/scumm/imuse_digi/dimuse_sndmgr.cpp b/scumm/imuse_digi/dimuse_sndmgr.cpp
index 43e68004bb..87848d7853 100644
--- a/scumm/imuse_digi/dimuse_sndmgr.cpp
+++ b/scumm/imuse_digi/dimuse_sndmgr.cpp
@@ -352,6 +352,20 @@ int ImuseDigiSndMgr::getJumpIdByRegionId(soundStruct *soundHandle, int number) {
return -1;
}
+int ImuseDigiSndMgr::getSyncSizeById(soundStruct *soundHandle, int number) {
+ Common::StackLock tmpLock(_mutex);
+ assert(soundHandle && checkForProperHandle(soundHandle));
+ assert(number >= 0 && number < soundHandle->numSyncs);
+ return soundHandle->sync[number].size;
+}
+
+byte *ImuseDigiSndMgr::getSyncPtrById(soundStruct *soundHandle, int number) {
+ Common::StackLock tmpLock(_mutex);
+ assert(soundHandle && checkForProperHandle(soundHandle));
+ assert(number >= 0 && number < soundHandle->numSyncs);
+ return soundHandle->sync[number].ptr;
+}
+
int ImuseDigiSndMgr::getRegionIdByHookId(soundStruct *soundHandle, int number) {
Common::StackLock tmpLock(_mutex);
assert(soundHandle && checkForProperHandle(soundHandle));
diff --git a/scumm/imuse_digi/dimuse_sndmgr.h b/scumm/imuse_digi/dimuse_sndmgr.h
index 02000eb77c..710ca62654 100644
--- a/scumm/imuse_digi/dimuse_sndmgr.h
+++ b/scumm/imuse_digi/dimuse_sndmgr.h
@@ -130,6 +130,8 @@ public:
int getJumpHookId(soundStruct *soundHandle, int number);
int getJumpFade(soundStruct *soundHandle, int number);
char *getMarker(soundStruct *soundHandle, int number);
+ int getSyncSizeById(soundStruct *soundHandle, int number);
+ byte *getSyncPtrById(soundStruct *soundHandle, int number);
int32 getDataFromRegion(soundStruct *soundHandle, int region, byte **buf, int32 offset, int32 size);
};
diff --git a/scumm/scumm.h b/scumm/scumm.h
index 145e268506..f9c58f4f19 100644
--- a/scumm/scumm.h
+++ b/scumm/scumm.h
@@ -1084,6 +1084,7 @@ public:
/* Scumm Vars */
byte VAR_LANGUAGE;
byte VAR_KEYPRESS;
+ byte VAR_SYNC;
byte VAR_EGO;
byte VAR_CAMERA_POS_X;
byte VAR_HAVE_MSG;
diff --git a/scumm/scummvm.cpp b/scumm/scummvm.cpp
index a1274a6d61..43a85e611d 100644
--- a/scumm/scummvm.cpp
+++ b/scumm/scummvm.cpp
@@ -492,6 +492,7 @@ ScummEngine::ScummEngine(GameDetector *detector, OSystem *syst, const ScummGameS
//
VAR_LANGUAGE = 0xFF;
VAR_KEYPRESS = 0xFF;
+ VAR_SYNC = 0xFF;
VAR_EGO = 0xFF;
VAR_CAMERA_POS_X = 0xFF;
VAR_HAVE_MSG = 0xFF;