aboutsummaryrefslogtreecommitdiff
path: root/gob
diff options
context:
space:
mode:
authorTorbjörn Andersson2005-05-01 10:15:30 +0000
committerTorbjörn Andersson2005-05-01 10:15:30 +0000
commitd6fb5517ed384a3f35d6d5915f50f661f755a225 (patch)
treeb0a9d82b38d29db7b449c0ce2aad891334510b66 /gob
parent2b351f73f46004fd0817a5650dd9de6b5190af3a (diff)
downloadscummvm-rg350-d6fb5517ed384a3f35d6d5915f50f661f755a225.tar.gz
scummvm-rg350-d6fb5517ed384a3f35d6d5915f50f661f755a225.tar.bz2
scummvm-rg350-d6fb5517ed384a3f35d6d5915f50f661f755a225.zip
This should fix the negative frequency bug that caused some sound effects
to not be played, and probably fixes wrong frequency on some that were played. It's all guesswork, though. I don't know if this is what the original did. svn-id: r17882
Diffstat (limited to 'gob')
-rw-r--r--gob/goblin.cpp81
-rw-r--r--gob/goblin.h2
-rw-r--r--gob/map.cpp21
-rw-r--r--gob/sound.cpp13
4 files changed, 45 insertions, 72 deletions
diff --git a/gob/goblin.cpp b/gob/goblin.cpp
index 45779846c5..cb704fdf3e 100644
--- a/gob/goblin.cpp
+++ b/gob/goblin.cpp
@@ -213,10 +213,6 @@ void gob_playSound(Snd_SoundDesc *snd, int16 repCount, int16 freq) {
}
void gob_drawObjects(void) {
- int16 tmp;
- int16 sndItem;
- int16 freq;
- int16 repCount;
Util_ListNode *ptr;
Util_ListNode *ptr2;
@@ -368,61 +364,50 @@ void gob_drawObjects(void) {
if (objDesc->toRedraw == 0 || objDesc->type == 1)
continue;
- tmp =
- objDesc->stateMach[objDesc->state][objDesc->stateColumn]->
- unk2;
-
- if ((tmp >> 8) != 0) {
- if (objDesc->curFrame == (tmp >> 8)) {
- sndItem =
- objDesc->stateMach[objDesc->
- state][objDesc->stateColumn]->sndItem >> 8;
- if (sndItem != -1) {
- freq =
- (objDesc->stateMach[objDesc->
- state][objDesc->stateColumn]->
- freq >> 8) * 100;
- repCount =
- (objDesc->stateMach[objDesc->
- state][objDesc->stateColumn]->
- repCount >> 8);
+ Gob_State *state = objDesc->stateMach[objDesc->state][objDesc->stateColumn];
+ int16 sndFrame;
+ int16 sndItem;
+ int16 freq;
+ int16 repCount;
+
+ if (state->sndFrame & 0xff00) {
+ // There are two frames which trigger a sound effect,
+ // so everything has to be encoded in one byte each.
+ // Note that the frequency is multiplied by 100, not -
+ // as I would have thought, 0x100.
+
+ sndFrame = (state->sndFrame >> 8) & 0xff;
+ sndItem = (state->sndItem >> 8) & 0xff;
+ freq = 100 * ((state->freq >> 8) & 0xff);
+ repCount = (state->repCount >> 8) & 0xff;
+
+ if (objDesc->curFrame == sndFrame) {
+ if (sndItem != 0xff) {
gob_playSound(gob_soundData[sndItem],
repCount, freq);
}
}
- if (objDesc->curFrame == (tmp & 0xff)) {
- sndItem =
- objDesc->stateMach[objDesc->
- state][objDesc->stateColumn]->
- sndItem & 0xff;
- if (sndItem != -1) {
- freq =
- (objDesc->stateMach[objDesc->
- state][objDesc->stateColumn]->
- freq & 0xff) * 100;
- repCount =
- (objDesc->stateMach[objDesc->
- state][objDesc->stateColumn]->
- repCount & 0xff);
+ sndFrame = state->sndFrame & 0xff;
+ sndItem = state->sndItem & 0xff;
+ freq = 100 * (state->freq & 0xff);
+ repCount = state->repCount & 0xff;
+
+ if (objDesc->curFrame == sndFrame) {
+ if (sndItem != 0xff) {
gob_playSound(gob_soundData[sndItem],
repCount, freq);
}
}
} else {
- if (objDesc->curFrame == tmp) {
- sndItem =
- objDesc->stateMach[objDesc->
- state][objDesc->stateColumn]->sndItem;
+ // There is only one, so frequency etc. are used as is.
+ sndFrame = state->sndFrame;
+ sndItem = state->sndItem;
+ freq = state->freq;
+ repCount = state->repCount;
+
+ if (objDesc->curFrame == sndFrame) {
if (sndItem != -1) {
- freq =
- objDesc->stateMach[objDesc->
- state][objDesc->stateColumn]->
- freq * 100;
- repCount =
- objDesc->stateMach[objDesc->
- state][objDesc->stateColumn]->
- repCount;
gob_playSound(gob_soundData[sndItem],
repCount, freq);
}
diff --git a/gob/goblin.h b/gob/goblin.h
index 31bbca0bc9..13862c1701 100644
--- a/gob/goblin.h
+++ b/gob/goblin.h
@@ -40,7 +40,7 @@ typedef struct Gob_State {
int16 sndItem; // +8h, high/low byte - sound sample index
int16 freq; // +Ah, high/low byte * 100 - frequency
int16 repCount; // +Ch high/low byte - repeat count
- int16 unk2; // +Eh
+ int16 sndFrame; // +Eh
} GCC_PACK Gob_State;
typedef struct Gob_State *Gob_PState;
diff --git a/gob/map.cpp b/gob/map.cpp
index a947996ff8..6671e33895 100644
--- a/gob/map.cpp
+++ b/gob/map.cpp
@@ -554,7 +554,7 @@ void map_loadMapObjects(char *avjFile) {
}
tmpState->freq = map_loadFromAvo_LE_UINT16();
tmpState->repCount = map_loadFromAvo_LE_UINT16();
- tmpState->unk2 = map_loadFromAvo_LE_UINT16();
+ tmpState->sndFrame = map_loadFromAvo_LE_UINT16();
}
}
}
@@ -583,13 +583,13 @@ void map_loadMapObjects(char *avjFile) {
pState->unk1 = 0;
pState->sndItem = -1;
- gob_goblins[2]->stateMach[10][0]->unk2 = 13;
- gob_goblins[2]->stateMach[11][0]->unk2 = 13;
- gob_goblins[2]->stateMach[28][0]->unk2 = 13;
- gob_goblins[2]->stateMach[29][0]->unk2 = 13;
+ gob_goblins[2]->stateMach[10][0]->sndFrame = 13;
+ gob_goblins[2]->stateMach[11][0]->sndFrame = 13;
+ gob_goblins[2]->stateMach[28][0]->sndFrame = 13;
+ gob_goblins[2]->stateMach[29][0]->sndFrame = 13;
- gob_goblins[1]->stateMach[10][0]->unk2 = 13;
- gob_goblins[1]->stateMach[11][0]->unk2 = 13;
+ gob_goblins[1]->stateMach[10][0]->sndFrame = 13;
+ gob_goblins[1]->stateMach[11][0]->sndFrame = 13;
for (state = 40; state < 70; state++) {
pState = (Gob_State *)malloc(sizeof(Gob_State));
@@ -599,7 +599,7 @@ void map_loadMapObjects(char *avjFile) {
pState->animation = 9;
pState->layer = state - 40;
pState->sndItem = -1;
- pState->unk2 = 0;
+ pState->sndFrame = 0;
}
gob_objCount = map_loadFromAvo_LE_UINT16();
@@ -651,10 +651,9 @@ void map_loadMapObjects(char *avjFile) {
}
tmpState->freq = map_loadFromAvo_LE_UINT16();
tmpState->repCount = map_loadFromAvo_LE_UINT16();
- tmpState->unk2 = map_loadFromAvo_LE_UINT16();
+ tmpState->sndFrame = map_loadFromAvo_LE_UINT16();
}
}
-
}
gob_objects[10] = (Gob_Object *)malloc(sizeof(Gob_Object));
@@ -672,7 +671,7 @@ void map_loadMapObjects(char *avjFile) {
pState->unk0 = 0;
pState->unk1 = 0;
pState->sndItem = -1;
- pState->unk2 = 0;
+ pState->sndFrame = 0;
gob_placeObject(gob_objects[10], 1);
diff --git a/gob/sound.cpp b/gob/sound.cpp
index 023384c2ba..17e0570aff 100644
--- a/gob/sound.cpp
+++ b/gob/sound.cpp
@@ -53,19 +53,8 @@ void snd_speakerOff(void) {return;}
void snd_stopSound(int16 arg){return;}
void snd_setResetTimerFlag(char flag){return;}
-// This is mostly to see if we are interpreting the sound effects correctly. If
-// we want to implement looping etc. we're probably going to need something a
-// bit more elaborate.
-//
-// Currently we ignore looping completely. We also ignore samples with negative
-// sample frequency. Something wacky is going on here, and I don't think it's
-// a simple signed/unsigned issue.
-
void snd_playSample(Snd_SoundDesc *sndDesc, int16 repCount, int16 frequency) {
- if (frequency < 0) {
- warning("snd_playSample: frequency = %d - this is weird", frequency);
- return;
- }
+ assert(frequency > 0);
if (!_vm->_mixer->isSoundHandleActive(sndDesc->handle)) {
_vm->_mixer->playRaw(&sndDesc->handle, sndDesc->data, sndDesc->size, frequency, 0);