[Scummvm-cvs-logs] CVS: scummvm/gob goblin.cpp,1.13,1.14 goblin.h,1.3,1.4 map.cpp,1.10,1.11 sound.cpp,1.8,1.9
Torbjörn Andersson
eriktorbjorn at users.sourceforge.net
Sun May 1 03:15:51 CEST 2005
Update of /cvsroot/scummvm/scummvm/gob
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16985
Modified Files:
goblin.cpp goblin.h map.cpp sound.cpp
Log Message:
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.
Index: goblin.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gob/goblin.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- goblin.cpp 28 Apr 2005 10:34:47 -0000 1.13
+++ goblin.cpp 1 May 2005 10:15:30 -0000 1.14
@@ -213,10 +213,6 @@
}
void gob_drawObjects(void) {
- int16 tmp;
- int16 sndItem;
- int16 freq;
- int16 repCount;
Util_ListNode *ptr;
Util_ListNode *ptr2;
@@ -368,61 +364,50 @@
if (objDesc->toRedraw == 0 || objDesc->type == 1)
continue;
- tmp =
- objDesc->stateMach[objDesc->state][objDesc->stateColumn]->
- unk2;
+ Gob_State *state = objDesc->stateMach[objDesc->state][objDesc->stateColumn];
+ int16 sndFrame;
+ int16 sndItem;
+ int16 freq;
+ int16 repCount;
- 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);
+ 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);
}
Index: goblin.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gob/goblin.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- goblin.h 9 Apr 2005 19:19:53 -0000 1.3
+++ goblin.h 1 May 2005 10:15:30 -0000 1.4
@@ -40,7 +40,7 @@
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;
Index: map.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gob/map.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- map.cpp 28 Apr 2005 10:34:48 -0000 1.10
+++ map.cpp 1 May 2005 10:15:30 -0000 1.11
@@ -554,7 +554,7 @@
}
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 @@
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 @@
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 @@
}
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 @@
pState->unk0 = 0;
pState->unk1 = 0;
pState->sndItem = -1;
- pState->unk2 = 0;
+ pState->sndFrame = 0;
gob_placeObject(gob_objects[10], 1);
Index: sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gob/sound.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- sound.cpp 30 Apr 2005 11:32:18 -0000 1.8
+++ sound.cpp 1 May 2005 10:15:30 -0000 1.9
@@ -53,19 +53,8 @@
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);
More information about the Scummvm-git-logs
mailing list