[Scummvm-cvs-logs] CVS: scummvm/scumm intern.h,2.444,2.445 resource_v7he.cpp,1.32,1.33 script_v100he.cpp,2.127,2.128 script_v72he.cpp,2.263,2.264 script_v80he.cpp,2.95,2.96 sound.cpp,1.442,1.443 sound.h,1.83,1.84
kirben
kirben at users.sourceforge.net
Mon Apr 18 00:18:57 CEST 2005
Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13215/scumm
Modified Files:
intern.h resource_v7he.cpp script_v100he.cpp script_v72he.cpp
script_v80he.cpp sound.cpp sound.h
Log Message:
Use correct music offsets for HE games, only a few demos use wrong tunes now.
Get all music details for HE games from one function only.
Index: intern.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/intern.h,v
retrieving revision 2.444
retrieving revision 2.445
diff -u -d -r2.444 -r2.445
--- intern.h 17 Apr 2005 23:19:15 -0000 2.444
+++ intern.h 18 Apr 2005 07:18:31 -0000 2.445
@@ -812,7 +812,6 @@
byte *heFindResource(uint32 tag, byte *ptr);
byte *findWrappedBlock(uint32 tag, byte *ptr, int state, bool flagError);
int findObject(int x, int y, int num, int *args);
- int getMusicResourceSize(int id);
/* HE version 72 script opcodes */
void o72_pushDWord();
Index: resource_v7he.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/resource_v7he.cpp,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
--- resource_v7he.cpp 14 Apr 2005 06:06:57 -0000 1.32
+++ resource_v7he.cpp 18 Apr 2005 07:18:32 -0000 1.33
@@ -1753,58 +1753,4 @@
return ((ScummEngine_v72he::ArrayHeader *)addr)->data;
}
-int ScummEngine_v72he::getMusicResourceSize(int id) {
- int size, total_size;
- uint tracks, skip;
- char buf[32], buf1[128];
- File musicFile;
-
- sprintf(buf, "%s.he4", getGameName());
-
- if (_substResFileNameIndex > 0) {
- generateSubstResFileName(buf, buf1, sizeof(buf1));
- strcpy(buf, buf1);
- }
- if (musicFile.open(buf) == false) {
- warning("getMusicResourceSize: Music file is not open");
- return 0;
- }
- musicFile.seek(4, SEEK_SET);
- total_size = musicFile.readUint32BE();
- musicFile.seek(+8, SEEK_CUR);
- tracks = musicFile.readUint32LE();
-
- skip = 0;
- if (id >= 8500)
- skip = (id - 8500);
- else if (id >= 8000)
- skip = (id - 8000);
- else if (id >= 4000)
- skip = (id - 4000);
-
- if (skip > tracks - 1)
- skip = 0;
-
- if (_heversion >= 80) {
- // Skip to offsets
- musicFile.seek(+40, SEEK_CUR);
-
- // Skip to correct music header
- skip *= 21;
- } else {
- // Skip to offsets
- musicFile.seek(+4, SEEK_CUR);
-
- // Skip to correct music header
- skip *= 25;
- }
-
- musicFile.seek(+skip, SEEK_CUR);
- musicFile.readUint32LE();
- size = musicFile.readUint32LE();
- musicFile.close();
-
- return size;
-}
-
} // End of namespace Scumm
Index: script_v100he.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v100he.cpp,v
retrieving revision 2.127
retrieving revision 2.128
diff -u -d -r2.127 -r2.128
--- script_v100he.cpp 17 Apr 2005 14:20:43 -0000 2.127
+++ script_v100he.cpp 18 Apr 2005 07:18:32 -0000 2.128
@@ -2211,7 +2211,9 @@
break;
case 72:
if (resid > _numSounds) {
- push(getMusicResourceSize(resid));
+ int offs;
+ _sound->getHEMusicDetails(resid, offs, size);
+ push(size);
return;
}
type = rtSound;
Index: script_v72he.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v72he.cpp,v
retrieving revision 2.263
retrieving revision 2.264
diff -u -d -r2.263 -r2.264
--- script_v72he.cpp 17 Apr 2005 14:27:17 -0000 2.263
+++ script_v72he.cpp 18 Apr 2005 07:18:32 -0000 2.264
@@ -2160,7 +2160,9 @@
resid = pop();
if (resid > _numSounds) {
- push(getMusicResourceSize(resid));
+ int offs;
+ _sound->getHEMusicDetails(resid, offs, size);
+ push(size);
return;
}
Index: script_v80he.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v80he.cpp,v
retrieving revision 2.95
retrieving revision 2.96
diff -u -d -r2.95 -r2.96
--- script_v80he.cpp 16 Apr 2005 11:01:31 -0000 2.95
+++ script_v80he.cpp 18 Apr 2005 07:18:32 -0000 2.96
@@ -814,7 +814,9 @@
switch (subOp) {
case 13:
if (resid > _numSounds) {
- push(getMusicResourceSize(resid));
+ int offs;
+ _sound->getHEMusicDetails(resid, offs, size);
+ push(size);
return;
}
type = rtSound;
Index: sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/sound.cpp,v
retrieving revision 1.442
retrieving revision 1.443
diff -u -d -r1.442 -r1.443
--- sound.cpp 16 Apr 2005 11:31:00 -0000 1.442
+++ sound.cpp 18 Apr 2005 07:18:32 -0000 1.443
@@ -161,6 +161,60 @@
_overrideFreq = freq;
}
+void Sound::getHEMusicDetails(int id, int &musicOffs, int &musicSize) {
+ int musicID, offs, tracks, total_size;
+ char buf[32], buf1[128];
+ File musicFile;
+
+ sprintf(buf, "%s.he4", _vm->getGameName());
+
+ if (_vm->_substResFileNameIndex > 0) {
+ _vm->generateSubstResFileName(buf, buf1, sizeof(buf1));
+ strcpy(buf, buf1);
+ }
+ if (musicFile.open(buf) == false) {
+ warning("getHEMusicDetails: Music file is not open");
+ return;
+ }
+ musicFile.seek(4, SEEK_SET);
+ total_size = musicFile.readUint32BE();
+ musicFile.seek(16, SEEK_SET);
+ tracks = musicFile.readUint32LE();
+
+ int musicStart = (_vm->_heversion >= 80) ? 56 : 20;
+
+ musicFile.seek(musicStart, SEEK_SET);
+ int musicStartID = musicFile.readUint32LE();
+
+ // Music is off by one in freddi2/puttzoo
+ offs = id - musicStartID - 1;
+ if (offs < 0 || offs > tracks)
+ offs = 0;
+
+ offs *= (_vm->_heversion >= 80) ? 21 : 25;
+ musicFile.seek(musicStart + offs, SEEK_SET);
+
+ // Adjust all other games.
+ musicID = musicFile.readUint32LE();
+ if (id == musicID + 1) {
+ offs += (_vm->_heversion >= 80) ? 21 : 25;
+ musicFile.seek(musicStart + offs, SEEK_SET);
+ musicID = musicFile.readUint32LE();
+ }
+
+ musicOffs = musicFile.readUint32LE();
+ musicSize = musicFile.readUint32LE();
+
+ if (id != musicID) {
+ debug(0, "getHEMusicDetails: Music track doesn't match (%d, %d)", id, musicID);
+ }
+ if (musicOffs > total_size || (musicSize + musicOffs > total_size) || musicSize < 0) {
+ error("getHEMusicDetails: Invalid music offset (%d) in music %d", id);
+ }
+
+ musicFile.close();
+}
+
void Sound::playSound(int soundID, int heOffset, int heChannel, int heFlags) {
debug(5,"playSound: soundID %d heOffset %d heChannel %d heFlags %d\n", soundID, heOffset, heChannel, heFlags);
byte *mallocedPtr = NULL;
@@ -176,8 +230,7 @@
if (_vm->_heversion >= 70 && soundID > _vm->_numSounds) {
debug(1, "playSound #%d", soundID);
- int music_offs, total_size;
- uint tracks, skip = 0;
+ int music_offs;
char buf[32], buf1[128];
File musicFile;
@@ -191,43 +244,8 @@
warning("playSound: Music file is not open");
return;
}
- musicFile.seek(4, SEEK_SET);
- total_size = musicFile.readUint32BE();
- musicFile.seek(+8, SEEK_CUR);
- tracks = musicFile.readUint32LE();
-
- if (soundID >= 8500)
- skip = (soundID - 8500);
- else if (soundID >= 8000)
- skip = (soundID - 8000);
- else if (soundID >= 4000)
- skip = (soundID - 4000);
-
- if (skip > tracks - 1)
- skip = 0;
-
- if (_vm->_heversion >= 80) {
- // Skip to offsets
- musicFile.seek(+40, SEEK_CUR);
-
- // Skip to correct music header
- skip *= 21;
- } else {
- // Skip to offsets
- musicFile.seek(+4, SEEK_CUR);
-
- // Skip to correct music header
- skip *= 25;
- }
-
- musicFile.seek(+skip, SEEK_CUR);
- music_offs = musicFile.readUint32LE();
- size = musicFile.readUint32LE();
-
- if (music_offs > total_size || (size + music_offs > total_size) || size < 0) {
- error("playSound: Invalid music offset (%d) in music %d", soundID);
- }
+ getHEMusicDetails(soundID, music_offs, size);
musicFile.seek(music_offs, SEEK_SET);
ptr = (byte *)malloc(size);
musicFile.read(ptr, size);
Index: sound.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/sound.h,v
retrieving revision 1.83
retrieving revision 1.84
diff -u -d -r1.83 -r1.84
--- sound.h 4 Apr 2005 11:41:17 -0000 1.83
+++ sound.h 18 Apr 2005 07:18:33 -0000 1.84
@@ -120,6 +120,8 @@
void updateCD();
int getCurrentCDSound() const { return _currentCDSound; }
+ void getHEMusicDetails(int id, int &musicOffs, int &musicSize);
+
// Used by the save/load system:
const SaveLoadEntry *getSaveLoadEntries();
More information about the Scummvm-git-logs
mailing list