[Scummvm-cvs-logs] CVS: scummvm/sword1 logic.cpp,1.40,1.41 sound.cpp,1.34,1.35 sword1.cpp,1.58,1.59 sword1.h,1.16,1.17
Robert Göffringmann
lavosspawn at users.sourceforge.net
Sun Nov 14 18:49:09 CET 2004
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/common file.cpp,1.73,1.74
- Next message: [Scummvm-cvs-logs] CVS: scummvm/saga actor.cpp,1.33,1.34 font.cpp,1.17,1.18 game.cpp,1.24,1.25 game.h,1.10,1.11 game_mod.h,1.9,1.10 interface.cpp,1.34,1.35 music.cpp,1.30,1.31 music.h,1.12,1.13 rscfile.cpp,1.10,1.11 rscfile_mod.h,1.5,1.6 saga.cpp,1.57,1.58 scene.cpp,1.51,1.52 script.cpp,1.27,1.28 sndres.cpp,1.25,1.26 sndres.h,1.12,1.13 sound.cpp,1.14,1.15 sound.h,1.11,1.12 sprite.cpp,1.24,1.25
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/scummvm/scummvm/sword1
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9008/sword1
Modified Files:
logic.cpp sound.cpp sword1.cpp sword1.h
Log Message:
BS1 demo's speech and logic work now.
But there's something wrong with the SFX, which can lead to crashes.
Index: logic.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword1/logic.cpp,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -d -r1.40 -r1.41
--- logic.cpp 9 Nov 2004 04:06:09 -0000 1.40
+++ logic.cpp 15 Nov 2004 02:48:30 -0000 1.41
@@ -474,6 +474,7 @@
int32 a, b, c, d, e, f;
int mCodeReturn = 0;
int32 mCodeNumber = 0, mCodeArguments = 0;
+ uint32 varNum = 0;
while (1) {
assert((stackIdx >= 0) && (stackIdx <= MAX_STACK_SIZE));
switch (scriptCode[pc++]) {
@@ -504,7 +505,14 @@
break;
case IT_PUSHVARIABLE:
debug(9, "IT_PUSHVARIABLE: ScriptVar[%d] => %d", scriptCode[pc], _scriptVars[scriptCode[pc]]);
- stack[stackIdx++] = _scriptVars[scriptCode[pc++]];
+ varNum = scriptCode[pc++];
+ if (SwordEngine::_systemVars.isDemo) {
+ if (varNum >= 397) // BS1 Demo has different number of script variables
+ varNum++;
+ if (varNum >= 699)
+ varNum++;
+ }
+ stack[stackIdx++] = _scriptVars[varNum];
break;
case IT_NOTEQUAL:
stackIdx--;
@@ -588,7 +596,14 @@
return 0;
case IT_POPVAR: // pop a variable
debug(9, "IT_POPVAR: ScriptVars[%d] = %d", scriptCode[pc], stack[stackIdx-1]);
- _scriptVars[scriptCode[pc++]] = stack[--stackIdx];
+ varNum = scriptCode[pc++];
+ if (SwordEngine::_systemVars.isDemo) {
+ if (varNum >= 397) // BS1 Demo has different number of script variables
+ varNum++;
+ if (varNum >= 699)
+ varNum++;
+ }
+ _scriptVars[varNum] = stack[--stackIdx];
break;
case IT_POPLONGOFFSET:
offset = scriptCode[pc++];
Index: sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword1/sound.cpp,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- sound.cpp 9 Nov 2004 04:06:10 -0000 1.34
+++ sound.cpp 15 Nov 2004 02:48:30 -0000 1.35
@@ -218,36 +218,28 @@
headerPos++;
if (headerPos < 100) {
int32 resSize;
- if (_cowMode == CowDemo) { // Demo uses slightly different headers
- resSize = READ_LE_UINT32(fBuf + headerPos + 6) >> 1;
- headerPos += 2;
- } else
- resSize = READ_LE_UINT32(fBuf + headerPos + 4) >> 1;
- int16 *srcData = (int16*)(fBuf + headerPos + 8);
- uint32 srcPos = 0;
- uint32 dstPos = 0;
- cSize = (cSize - (headerPos + 8)) / 2;
- if (_cowMode == CowDemo) {
- // FIXME: Until someone figures out how to really
- // calculate the uncompressed buffer size, use
- // brute force to avoid crashes.
- debug(1, "old resSize = %d", resSize);
- resSize = 0;
- while (srcPos < cSize) {
- int16 length = (int16)READ_LE_UINT16(srcData + srcPos);
- srcPos++;
- if (length < 0) {
- length = -length;
- srcPos++;
- } else {
- srcPos += length;
- }
- resSize += length;
- }
- debug(1, "new resSize = %d", resSize);
+ headerPos += 4; // skip 'data' tag
+ if (_cowMode != CowDemo) {
+ resSize = READ_LE_UINT32(fBuf + headerPos) >> 1;
+ headerPos += 4;
+ } else {
+ // the demo speech files have the uncompressed size embedded
+ // in the compressed stream *sigh*
+ if (READ_LE_UINT16(fBuf + headerPos) == 1) {
+ resSize = READ_LE_UINT16(fBuf + headerPos + 2);
+ resSize |= READ_LE_UINT16(fBuf + headerPos + 6) << 16;
+ resSize >>= 1;
+ } else
+ resSize = READ_LE_UINT32(fBuf + headerPos + 2) >> 1;
}
- int16 *dstData = (int16*)malloc(resSize * 2);
- srcPos = 0;
+ assert(!(headerPos & 1));
+ int16 *srcData = (int16*)fBuf;
+ uint32 srcPos = headerPos >> 1;
+ cSize /= 2;
+ uint32 dstPos = 0;
+ /* alloc 200 additional bytes, as the demo sometimes has ASCII junk
+ at the end of the wave data */
+ int16 *dstData = (int16*)malloc(resSize * 2 + 200);
while (srcPos < cSize) {
int16 length = (int16)READ_LE_UINT16(srcData + srcPos);
srcPos++;
@@ -262,6 +254,9 @@
srcPos += length;
}
}
+ assert(dstPos < (uint32)resSize + 100);
+ if (_cowMode == CowDemo) // demo has wave output size embedded in the compressed data
+ *(uint32*)dstData = 0;
free(fBuf);
*size = resSize * 2;
calcWaveVolume(dstData, resSize);
Index: sword1.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword1/sword1.cpp,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -d -r1.58 -r1.59
--- sword1.cpp 9 Nov 2004 04:20:33 -0000 1.58
+++ sword1.cpp 15 Nov 2004 02:48:30 -0000 1.59
@@ -1095,6 +1095,7 @@
File test;
_systemVars.playSpeech = true;
+ _systemVars.isDemo = false;
for (int i = 1; i <= 2; i++) {
for (int j = 0; j < ARRAYSIZE(speechFiles); j++) {
@@ -1113,6 +1114,10 @@
_systemVars.runningFromCd = false;
_systemVars.playSpeech = true;
} else { // speech1 & speech2 not present. are we running from cd?
+ if (test.open("cows.mad")) {
+ _systemVars.isDemo = true;
+ test.close();
+ }
if (test.open("cd1.id")) {
_systemVars.runningFromCd = true;
_systemVars.currentCD = 1;
Index: sword1.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword1/sword1.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- sword1.h 9 Nov 2004 04:06:10 -0000 1.16
+++ sword1.h 15 Nov 2004 02:48:30 -0000 1.17
@@ -63,6 +63,7 @@
uint8 playSpeech;
uint8 showText;
uint8 language;
+ bool isDemo;
};
class SwordEngine : public Engine {
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/common file.cpp,1.73,1.74
- Next message: [Scummvm-cvs-logs] CVS: scummvm/saga actor.cpp,1.33,1.34 font.cpp,1.17,1.18 game.cpp,1.24,1.25 game.h,1.10,1.11 game_mod.h,1.9,1.10 interface.cpp,1.34,1.35 music.cpp,1.30,1.31 music.h,1.12,1.13 rscfile.cpp,1.10,1.11 rscfile_mod.h,1.5,1.6 saga.cpp,1.57,1.58 scene.cpp,1.51,1.52 script.cpp,1.27,1.28 sndres.cpp,1.25,1.26 sndres.h,1.12,1.13 sound.cpp,1.14,1.15 sound.h,1.11,1.12 sprite.cpp,1.24,1.25
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Scummvm-git-logs
mailing list