[Scummvm-cvs-logs] CVS: scummvm/scumm actor.cpp,1.379.2.7,1.379.2.8 intern.h,2.529.2.5,2.529.2.6 module.mk,1.56.2.1,1.56.2.2 resource.cpp,1.339.2.7,1.339.2.8 script_v100he.cpp,2.173.2.3,2.173.2.4 script_v72he.cpp,2.307.2.5,2.307.2.6 script_v7he.cpp,2.166.2.4,2.166.2.5 script_v80he.cpp,2.125.2.1,2.125.2.2 script_v90he.cpp,2.281.2.3,2.281.2.4 scumm.cpp,1.603.2.29,1.603.2.30 scumm.h,1.647.2.10,1.647.2.11 sound.cpp,1.479.2.6,1.479.2.7 sound.h,1.92.2.1,1.92.2.2 vars.cpp,1.150.2.4,1.150.2.5
kirben
kirben at users.sourceforge.net
Sat Jan 14 22:46:01 CET 2006
Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5682/scumm
Modified Files:
Tag: branch-0-8-0
actor.cpp intern.h module.mk resource.cpp script_v100he.cpp
script_v72he.cpp script_v7he.cpp script_v80he.cpp
script_v90he.cpp scumm.cpp scumm.h sound.cpp sound.h vars.cpp
Log Message:
Backport sound code support for HE games.
Backport a few other fixes for HE games.
Index: actor.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/actor.cpp,v
retrieving revision 1.379.2.7
retrieving revision 1.379.2.8
diff -u -d -r1.379.2.7 -r1.379.2.8
--- actor.cpp 13 Jan 2006 05:47:10 -0000 1.379.2.7
+++ actor.cpp 15 Jan 2006 06:45:14 -0000 1.379.2.8
@@ -1143,13 +1143,19 @@
bcr->_skipLimbs = (_heSkipLimbs != 0);
bcr->_paletteNum = _hePaletteNum;
- if (_vm->_heversion >= 80 && _heNoTalkAnimation == 0) {
- _heCondMask = (_heCondMask & ~0x3FF) | 1;
- if (_vm->getTalkingActor() == _number) {
- // Checks if talk sound is active?
- // Otherwise just do rand animation
- int rnd = _vm->_rnd.getRandomNumberRng(1, 10);
- setTalkCondition(rnd);
+ if (_vm->_heversion >= 80 && _heNoTalkAnimation == 0 && _animProgress == 0) {
+ if (_vm->getTalkingActor() == _number && !_vm->_string[0].no_talk_anim) {
+ int talkState = 0;
+
+ if (_vm->_sound->isSoundCodeUsed(1))
+ talkState = _vm->_sound->getSoundVar(1, 19);
+ if (talkState == 0)
+ talkState = _vm->_rnd.getRandomNumberRng(1, 10);
+
+ checkRange(13, 1, talkState, "Talk state %d out of range");
+ setTalkCondition(talkState);
+ } else {
+ setTalkCondition(1);
}
}
_heNoTalkAnimation = 0;
@@ -1250,7 +1256,7 @@
// Redraw all actors if a full redraw was requested.
// Also redraw all actors in COMI (see bug #1066329 for details).
- if (_fullRedraw || _version == 8) {
+ if (_fullRedraw || _version == 8 || (VAR_REDRAW_ALL_ACTORS != 0xFF && VAR(VAR_REDRAW_ALL_ACTORS) != 0)) {
for (j = 1; j < _numActors; j++) {
_actors[j]._needRedraw = true;
}
@@ -1983,14 +1989,14 @@
}
void Actor::setUserCondition(int slot, int set) {
- debug(1, "Actor::setUserCondition(%d, %d)", slot, set);
- assert(slot >= 1 && slot <= 0x20);
+ const int condMaskCode = (_vm->_heversion >= 90) ? 0x1FFF : 0x3FF;
+ checkRange(32, 1, slot, "Condition %d out of range");
if (set == 0) {
_heCondMask &= ~(1 << (slot + 0xF));
} else {
_heCondMask |= 1 << (slot + 0xF);
}
- if (_heCondMask & 0x3FF) {
+ if (_heCondMask & condMaskCode) {
_heCondMask &= ~1;
} else {
_heCondMask |= 1;
@@ -1998,17 +2004,17 @@
}
bool Actor::isUserConditionSet(int slot) const {
- assert(slot >= 1 && slot <= 0x20);
+ checkRange(32, 1, slot, "Condition %d out of range");
return (_heCondMask & (1 << (slot + 0xF))) != 0;
}
void Actor::setTalkCondition(int slot) {
- debug(1, "Actor::setTalkCondition(%d)", slot);
- assert(slot >= 1 && slot <= 0x10);
- _heCondMask = (_heCondMask & ~0x3FF) | 1;
+ const int condMaskCode = (_vm->_heversion >= 90) ? 0x1FFF : 0x3FF;
+ checkRange(32, 1, slot, "Condition %d out of range");
+ _heCondMask = (_heCondMask & ~condMaskCode) | 1;
if (slot != 1) {
_heCondMask |= 1 << (slot - 1);
- if (_heCondMask & 0x3FF) {
+ if (_heCondMask & condMaskCode) {
_heCondMask &= ~1;
} else {
_heCondMask |= 1;
@@ -2017,7 +2023,7 @@
}
bool Actor::isTalkConditionSet(int slot) const {
- assert(slot >= 1 && slot <= 0x10);
+ checkRange(32, 1, slot, "Condition %d out of range");
return (_heCondMask & (1 << (slot - 1))) != 0;
}
Index: intern.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/intern.h,v
retrieving revision 2.529.2.5
retrieving revision 2.529.2.6
diff -u -d -r2.529.2.5 -r2.529.2.6
--- intern.h 8 Nov 2005 00:49:33 -0000 2.529.2.5
+++ intern.h 15 Jan 2006 06:45:14 -0000 2.529.2.6
@@ -1011,7 +1011,7 @@
void o72_captureWizImage();
void o72_getTimer();
void o72_setTimer();
- void o72_getSoundElapsedTime();
+ void o72_getSoundPosition();
void o72_startScript();
void o72_startObject();
void o72_drawObject();
Index: module.mk
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/module.mk,v
retrieving revision 1.56.2.1
retrieving revision 1.56.2.2
diff -u -d -r1.56.2.1 -r1.56.2.2
--- module.mk 19 Oct 2005 07:42:58 -0000 1.56.2.1
+++ module.mk 15 Jan 2006 06:45:14 -0000 1.56.2.2
@@ -42,6 +42,7 @@
scumm/script_v6he.o \
scumm/scumm.o \
scumm/sound.o \
+ scumm/sound_he.o \
scumm/string.o \
scumm/usage_bits.o \
scumm/util.o \
Index: resource.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/resource.cpp,v
retrieving revision 1.339.2.7
retrieving revision 1.339.2.8
diff -u -d -r1.339.2.7 -r1.339.2.8
--- resource.cpp 21 Dec 2005 12:38:53 -0000 1.339.2.7
+++ resource.cpp 15 Jan 2006 06:45:14 -0000 1.339.2.8
@@ -990,6 +990,8 @@
return _sound->isSoundInUse(i);
case rtCharset:
return _charset->getCurID() == i;
+ case rtSpoolBuffer:
+ return _sound->isSoundRunning(10000 + i) != 0;
default:
return false;
}
@@ -1333,6 +1335,9 @@
allocResTypeData(rtImage, MKID('AWIZ'), _numImages, "images", 1);
allocResTypeData(rtTalkie, MKID('TLKE'), _numTalkies, "talkie", 1);
+ if (_heversion >= 70) {
+ allocResTypeData(rtSpoolBuffer, MKID('NONE'), 9, "spool buffer", 0);
+ }
}
void ScummEngine::dumpResource(const char *tag, int idx, const byte *ptr, int length) {
Index: script_v100he.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v100he.cpp,v
retrieving revision 2.173.2.3
retrieving revision 2.173.2.4
diff -u -d -r2.173.2.3 -r2.173.2.4
--- script_v100he.cpp 21 Oct 2005 12:11:10 -0000 2.173.2.3
+++ script_v100he.cpp 15 Jan 2006 06:45:15 -0000 2.173.2.4
@@ -309,7 +309,7 @@
OPCODE(o6_isScriptRunning),
OPCODE(o90_sin),
/* D8 */
- OPCODE(o72_getSoundElapsedTime),
+ OPCODE(o72_getSoundPosition),
OPCODE(o6_isSoundRunning),
OPCODE(o80_getSoundVar),
OPCODE(o100_getSpriteInfo),
@@ -430,7 +430,6 @@
for (i = 0; i < k; ++i) {
a->setUserCondition(args[i] & 0x7F, args[i] & 0x80);
}
- debug(1,"o100_actorOps: case 21 (%d)", k);
break;
case 25: // SO_COSTUME
a->setActorCostume(pop());
@@ -558,9 +557,10 @@
break;
case 142:
k = pop();
+ if (k == 0)
+ k = _rnd.getRandomNumberRng(1, 10);
a->_heNoTalkAnimation = 1;
a->setTalkCondition(k);
- debug(1,"o100_actorOps: case 24 (%d)", k);
break;
case 143: // SO_TEXT_OFFSET
a->_talkPosY = pop();
@@ -1644,7 +1644,8 @@
value = pop();
var = pop();
_heSndSoundId = pop();
- debug(0,"o100_startSound: case 29 (snd %d, var %d, value %d)", _heSndSoundId, var, value);
+ _sound->setSoundVar(_heSndSoundId, var, value);
+ debug(0,"o100_startSound: case 83 (snd %d, var %d, value %d)", _heSndSoundId, var, value);
break;
case 92:
debug(0, "o100_startSound (ID %d, Offset %d, Channel %d, Flags %d)", _heSndSoundId, _heSndOffset, _heSndChannel, _heSndFlags);
@@ -1657,11 +1658,11 @@
_heSndChannel = pop();
break;
case 130:
- _heSndFlags |= 40;
+ _heSndFlags |= 64;
pop();
break;
case 131:
- _heSndFlags |= 4;
+ _heSndFlags |= 1;
break;
case 132: // Music
case 134: // Sound
@@ -1669,16 +1670,17 @@
_heSndOffset = 0;
_heSndSoundFreq = 11025;
_heSndChannel = VAR(VAR_MUSIC_CHANNEL);
+ _heSndFlags = 0;
break;
case 133:
- _heSndFlags |= 80;
+ _heSndFlags |= 128;
pop();
break;
case 135:
_heSndFlags |= 4;
break;
case 136:
- _heSndFlags |= 20;
+ _heSndFlags |= 32;
pop();
break;
default:
Index: script_v72he.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v72he.cpp,v
retrieving revision 2.307.2.5
retrieving revision 2.307.2.6
diff -u -d -r2.307.2.5 -r2.307.2.6
--- script_v72he.cpp 21 Dec 2005 11:37:28 -0000 2.307.2.5
+++ script_v72he.cpp 15 Jan 2006 06:45:15 -0000 2.307.2.6
@@ -156,7 +156,7 @@
/* 58 */
OPCODE(o72_getTimer),
OPCODE(o72_setTimer),
- OPCODE(o72_getSoundElapsedTime),
+ OPCODE(o72_getSoundPosition),
OPCODE(o6_wordArrayDec),
/* 5C */
OPCODE(o6_if),
@@ -866,9 +866,7 @@
int cmd = fetchScriptByte();
if (cmd == 10 || cmd == 50) {
- checkRange(3, 1, timer, "o72_getTimer: Timer %d out of range(%d)");
- int diff = _system->getMillis() - _timers[timer];
- push(diff);
+ push(getHETimer(timer));
} else {
push(0);
}
@@ -879,17 +877,15 @@
int cmd = fetchScriptByte();
if (cmd == 158 || cmd == 61) {
- checkRange(3, 1, timer, "o72_setTimer: Timer %d out of range(%d)");
- _timers[timer] = _system->getMillis();
+ setHETimer(timer);
} else {
error("TIMER command %d?", cmd);
}
}
-void ScummEngine_v72he::o72_getSoundElapsedTime() {
+void ScummEngine_v72he::o72_getSoundPosition() {
int snd = pop();
- push(_sound->getSoundElapsedTime(snd) * 10);
- debug(1,"o72_getSoundElapsedTime (%d)", snd);
+ push(_sound->getSoundPos(snd));
}
void ScummEngine_v72he::o72_startScript() {
@@ -1137,13 +1133,13 @@
for (i = 0; i < k; ++i) {
a->setUserCondition(args[i] & 0x7F, args[i] & 0x80);
}
- debug(1,"o72_actorOps: case 21 (%d)", k);
break;
case 24: // HE 80+
k = pop();
+ if (k == 0)
+ k = _rnd.getRandomNumberRng(1, 10);
a->_heNoTalkAnimation = 1;
a->setTalkCondition(k);
- debug(1,"o72_actorOps: case 24 (%d)", k);
break;
case 43: // HE 90+
// HE games use reverse order of layering, so we adjust
Index: script_v7he.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v7he.cpp,v
retrieving revision 2.166.2.4
retrieving revision 2.166.2.5
diff -u -d -r2.166.2.4 -r2.166.2.5
--- script_v7he.cpp 18 Nov 2005 23:49:07 -0000 2.166.2.4
+++ script_v7he.cpp 15 Jan 2006 06:45:15 -0000 2.166.2.5
@@ -436,11 +436,13 @@
value = pop();
var = pop();
_heSndSoundId = pop();
- debug(0,"o70_startSound: case 29 (snd %d, var %d, value %d)", _heSndSoundId, var, value);
+ _sound->setSoundVar(_heSndSoundId, var, value);
+ debug(0,"o70_startSound: case 23 (snd %d, var %d, value %d)", _heSndSoundId, var, value);
break;
case 25:
value = pop();
_heSndSoundId = pop();
+ debug(0, "o70_startSound: case 25 (ID %d, Offset 0, Channel 0, Flags 8)", _heSndSoundId);
_sound->addSoundToQueue(_heSndSoundId, 0, 0, 8);
case 56:
_heSndFlags |= 16;
Index: script_v80he.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v80he.cpp,v
retrieving revision 2.125.2.1
retrieving revision 2.125.2.2
diff -u -d -r2.125.2.1 -r2.125.2.2
--- script_v80he.cpp 18 Oct 2005 02:11:21 -0000 2.125.2.1
+++ script_v80he.cpp 15 Jan 2006 06:45:15 -0000 2.125.2.2
@@ -155,7 +155,7 @@
/* 58 */
OPCODE(o72_getTimer),
OPCODE(o72_setTimer),
- OPCODE(o72_getSoundElapsedTime),
+ OPCODE(o72_getSoundPosition),
OPCODE(o6_wordArrayDec),
/* 5C */
OPCODE(o6_if),
@@ -432,14 +432,9 @@
}
void ScummEngine_v80he::o80_getSoundVar() {
- // Checks sound variable
int var = pop();
int snd = pop();
- int rnd = _rnd.getRandomNumberRng(1, 3);
-
- checkRange(27, 0, var, "Illegal sound variable %d");
- push (rnd);
- debug(1,"o80_getSoundVar stub (snd %d, var %d)", snd, var);
+ push(_sound->getSoundVar(snd, var));
}
void ScummEngine_v80he::o80_localizeArrayToRoom() {
Index: script_v90he.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v90he.cpp,v
retrieving revision 2.281.2.3
retrieving revision 2.281.2.4
diff -u -d -r2.281.2.3 -r2.281.2.4
--- script_v90he.cpp 18 Nov 2005 23:23:11 -0000 2.281.2.3
+++ script_v90he.cpp 15 Jan 2006 06:45:15 -0000 2.281.2.4
@@ -152,7 +152,7 @@
/* 58 */
OPCODE(o72_getTimer),
OPCODE(o72_setTimer),
- OPCODE(o72_getSoundElapsedTime),
+ OPCODE(o72_getSoundPosition),
OPCODE(o6_wordArrayDec),
/* 5C */
OPCODE(o6_if),
Index: scumm.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.cpp,v
retrieving revision 1.603.2.29
retrieving revision 1.603.2.30
diff -u -d -r1.603.2.29 -r1.603.2.30
--- scumm.cpp 14 Jan 2006 09:35:46 -0000 1.603.2.29
+++ scumm.cpp 15 Jan 2006 06:45:15 -0000 1.603.2.30
@@ -1216,7 +1216,7 @@
_actorClipOverride.right = 640;
_skipDrawObject = 0;
- memset(_timers, 0, sizeof(_timers));
+ memset(_heTimers, 0, sizeof(_heTimers));
memset(_akosQueue, 0, sizeof(_akosQueue));
_akosQueuePos = 0;
@@ -1343,9 +1343,15 @@
VAR_MUSIC_BUNDLE_LOADED = 0xFF;
VAR_VOICE_BUNDLE_LOADED = 0xFF;
+ VAR_REDRAW_ALL_ACTORS = 0xFF;
VAR_SKIP_RESET_TALK_ACTOR = 0xFF;
+
VAR_MUSIC_CHANNEL = 0xFF;
VAR_SOUND_CHANNEL = 0xFF;
+ VAR_SOUNDCODE_TMR = 0xFF;
+ VAR_DEFAULT_SOUND_CHANNEL = 0xFF;
+
+ VAR_MAIN_SCRIPT = 0xFF;
VAR_NUM_SCRIPT_CYCLES = 0xFF;
VAR_SCRIPT_CYCLE = 0xFF;
@@ -2481,6 +2487,9 @@
_fullRedraw = true;
}
+ if (_heversion >= 80) {
+ _sound->processSoundCode();
+ }
runAllScripts();
checkExecVerbs();
checkAndRunSentenceScript();
@@ -2551,6 +2560,10 @@
clearClickedStatus();
}
+ if (VAR_MAIN_SCRIPT != 0xFF && VAR(VAR_MAIN_SCRIPT) != 0) {
+ runScript(VAR(VAR_MAIN_SCRIPT), 0, 0, 0);
+ }
+
// Handle mouse over effects (for verbs).
handleMouseOver(oldEgo != VAR(VAR_EGO));
@@ -2601,6 +2614,17 @@
#pragma mark --- SCUMM ---
#pragma mark -
+int ScummEngine::getHETimer(int timer) {
+ checkRange(15, 1, timer, "getHETimer: Timer %d out of range(%d)");
+ int time = _system->getMillis() - _heTimers[timer];
+ return time;
+}
+
+void ScummEngine::setHETimer(int timer) {
+ checkRange(15, 1, timer, "setHETimer: Timer %d out of range(%d)");
+ _heTimers[timer] = _system->getMillis();
+}
+
void ScummEngine::pauseGame() {
pauseDialog();
}
Index: scumm.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.h,v
retrieving revision 1.647.2.10
retrieving revision 1.647.2.11
diff -u -d -r1.647.2.10 -r1.647.2.11
--- scumm.h 21 Dec 2005 12:38:53 -0000 1.647.2.10
+++ scumm.h 15 Jan 2006 06:45:15 -0000 1.647.2.11
@@ -192,8 +192,9 @@
rtRoomImage = 18,
rtImage = 19,
rtTalkie = 20,
- rtLast = 20,
- rtNumTypes = 21
+ rtSpoolBuffer = 21,
+ rtLast = 21,
+ rtNumTypes = 22
};
enum {
@@ -1070,14 +1071,19 @@
bool testGfxOtherUsageBits(int strip, int bit);
public:
- uint8 *_hePalettes;
- byte _HEV7ActorPalette[256];
byte _roomPalette[256];
byte *_shadowPalette;
bool _skipDrawObject;
- int _timers[4];
int _voiceMode;
+ // HE specific
+ byte _HEV7ActorPalette[256];
+ uint8 *_hePalettes;
+
+ int _heTimers[16];
+ int getHETimer(int timer);
+ void setHETimer(int timer);
+
protected:
int _shadowPaletteSize;
byte _currentPalette[3 * 256];
@@ -1320,9 +1326,15 @@
byte VAR_CLICK_AREA;
// HE specific variables
+ byte VAR_REDRAW_ALL_ACTORS;
byte VAR_SKIP_RESET_TALK_ACTOR;
+
byte VAR_MUSIC_CHANNEL;
byte VAR_SOUND_CHANNEL;
+ byte VAR_SOUNDCODE_TMR;
+ byte VAR_DEFAULT_SOUND_CHANNEL;
+
+ byte VAR_MAIN_SCRIPT;
byte VAR_SCRIPT_CYCLE;
byte VAR_NUM_SCRIPT_CYCLES;
Index: sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/sound.cpp,v
retrieving revision 1.479.2.6
retrieving revision 1.479.2.7
diff -u -d -r1.479.2.6 -r1.479.2.7
--- sound.cpp 17 Nov 2005 23:42:04 -0000 1.479.2.6
+++ sound.cpp 15 Jan 2006 06:45:15 -0000 1.479.2.7
@@ -80,6 +80,7 @@
_sfxMode(0),
_heMusicTracks(0) {
+ memset(_heChannel, 0, sizeof(_heChannel));
memset(_soundQue, 0, sizeof(_soundQue));
memset(_soundQue2, 0, sizeof(_soundQue2));
memset(_mouthSyncTimes, 0, sizeof(_mouthSyncTimes));
@@ -93,9 +94,16 @@
void Sound::addSoundToQueue(int sound, int heOffset, int heChannel, int heFlags) {
if (_vm->VAR_LAST_SOUND != 0xFF)
_vm->VAR(_vm->VAR_LAST_SOUND) = sound;
+
+ if (heFlags & 16) {
+ playHESound(sound, heOffset, heChannel, heFlags);
+ return;
+ }
+
// HE music resources are in separate file
if (sound <= _vm->_numSounds)
_vm->ensureResourceLoaded(rtSound, sound);
+
addSoundToQueue2(sound, heOffset, heChannel, heFlags);
}
@@ -141,8 +149,12 @@
heOffset = _soundQue2[_soundQue2Pos].offset;
heChannel = _soundQue2[_soundQue2Pos].channel;
heFlags = _soundQue2[_soundQue2Pos].flags;
- if (snd)
- playSound(snd, heOffset, heChannel, heFlags);
+ if (snd) {
+ if (_vm->_heversion>= 60)
+ playHESound(snd, heOffset, heChannel, heFlags);
+ else
+ playSound(snd);
+ }
}
while (i < _soundQuePos) {
@@ -169,64 +181,7 @@
_soundQuePos = 0;
}
-void Sound::setOverrideFreq(int freq) {
- _overrideFreq = freq;
-}
-
-void Sound::setupHEMusicFile() {
- int i, total_size;
- char buf[32], buf1[128];
- Common::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) == true) {
- musicFile.seek(4, SEEK_SET);
- total_size = musicFile.readUint32BE();
- musicFile.seek(16, SEEK_SET);
- _heMusicTracks = musicFile.readUint32LE();
- debug(0, "Total music tracks %d", _heMusicTracks);
-
- int musicStart = (_vm->_heversion >= 80) ? 56 : 20;
- musicFile.seek(musicStart, SEEK_SET);
-
- _heMusic = (HEMusic *)malloc((_heMusicTracks + 1) * sizeof(HEMusic));
- for (i = 0; i < _heMusicTracks; i++) {
- _heMusic[i].id = musicFile.readUint32LE();
- _heMusic[i].offset = musicFile.readUint32LE();
- _heMusic[i].size = musicFile.readUint32LE();
-
- if (_vm->_heversion >= 80) {
- musicFile.seek(+9, SEEK_CUR);
- } else {
- musicFile.seek(+13, SEEK_CUR);
- }
- }
-
- musicFile.close();
- }
-}
-
-bool Sound::getHEMusicDetails(int id, int &musicOffs, int &musicSize) {
- int i;
-
- for (i = 0; i < _heMusicTracks; i++) {
- if (_heMusic[i].id == id) {
- musicOffs = _heMusic[i].offset;
- musicSize = _heMusic[i].size;
- return 1;
- }
- }
-
- return 0;
-}
-
-void Sound::playSound(int soundID, int heOffset, int heChannel, int heFlags) {
- debug(5,"playSound: soundID %d heOffset %d heChannel %d heFlags %d", soundID, heOffset, heChannel, heFlags);
+void Sound::playSound(int soundID) {
byte *mallocedPtr = NULL;
byte *ptr;
char *sound;
@@ -234,56 +189,10 @@
int rate;
byte flags = Audio::Mixer::FLAG_UNSIGNED | Audio::Mixer::FLAG_AUTOFREE;
- if (heChannel == -1) {
- heChannel = 1;
- }
- if (_vm->_heversion >= 70 && soundID > _vm->_numSounds) {
- debug(1, "playSound #%d", soundID);
-
- if (soundID >= 10000) {
- // Special codes, used in pjgames
- return;
- }
-
- int music_offs;
- char buf[32], buf1[128];
- Common::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("playSound: Can't open music file %s", buf);
- return;
- }
- if (!getHEMusicDetails(soundID, music_offs, size)) {
- debug(0, "playSound: musicID %d not found", soundID);
- return;
- }
-
- musicFile.seek(music_offs, SEEK_SET);
- ptr = (byte *)malloc(size);
- musicFile.read(ptr, size);
- musicFile.close();
-
- _vm->_mixer->stopID(_currentMusic);
- _currentMusic = soundID;
- if (_vm->_heversion == 70) {
- _vm->_mixer->playRaw(&_heSoundChannels[heChannel], ptr, size, 11025, flags, soundID);
- return;
- }
-
- // This pointer will be freed at the end of the function
- mallocedPtr = ptr;
- } else {
- debugC(DEBUG_SOUND, "playSound #%d (room %d)", soundID,
- _vm->getResourceRoomNr(rtSound, soundID));
+ debugC(DEBUG_SOUND, "playSound #%d (room %d)", soundID,
+ _vm->getResourceRoomNr(rtSound, soundID));
- ptr = _vm->getResourceAddress(rtSound, soundID);
- }
+ ptr = _vm->getResourceAddress(rtSound, soundID);
if (!ptr) {
return;
@@ -305,7 +214,6 @@
memcpy(sound, ptr, size);
_vm->_mixer->playRaw(NULL, sound, size, rate, flags, soundID);
}
-
// WORKAROUND bug # 1311447
else if (READ_UINT32(ptr) == MKID(0x460e200d)) {
// This sound resource occurs in the Macintosh version of Monkey Island.
@@ -328,87 +236,6 @@
memcpy(sound, ptr, size);
_vm->_mixer->playRaw(NULL, sound, size, rate, flags, soundID);
}
-
- // Support for later Backyard sports games sounds
- else if (READ_UINT32(ptr) == MKID('RIFF')) {
- uint16 type;
- int blockAlign;
- size = READ_LE_UINT32(ptr + 4);
- Common::MemoryReadStream stream(ptr, size);
-
- if (!loadWAVFromStream(stream, size, rate, flags, &type, &blockAlign)) {
- error("playSound: Not a valid WAV file");
- }
-
- if (type == 17) {
- AudioStream *voxStream = new ADPCMInputStream(&stream, size, kADPCMIma, (flags & Audio::Mixer::FLAG_STEREO) ? 2 : 1, blockAlign);
-
- sound = (char *)malloc(size * 4);
- size = voxStream->readBuffer((int16*)sound, size * 2);
- size *= 2; // 16bits.
- } else {
- // Allocate a sound buffer, copy the data into it, and play
- sound = (char *)malloc(size);
- memcpy(sound, ptr + stream.pos(), size);
- }
- _vm->_mixer->playRaw(&_heSoundChannels[heChannel], sound, size, rate, flags, soundID);
- }
- // Support for Putt-Putt sounds - very hackish, too 8-)
- else if (READ_UINT32(ptr) == MKID('DIGI') || READ_UINT32(ptr) == MKID('TALK') || READ_UINT32(ptr) == MKID('HSHD')) {
- if (READ_UINT32(ptr) == MKID('HSHD')) {
- rate = READ_LE_UINT16(ptr + 14);
- ptr += READ_BE_UINT32(ptr + 4);
- } else {
- rate = READ_LE_UINT16(ptr + 22);
- ptr += 8 + READ_BE_UINT32(ptr + 12);
- }
-
- if (READ_UINT32(ptr) == MKID('SBNG')) {
- ptr += READ_BE_UINT32(ptr + 4);
- }
-
- assert(READ_UINT32(ptr) == MKID('SDAT'));
- size = READ_BE_UINT32(ptr+4) - 8;
- if (heOffset < 0 || heOffset > size) {
- // Occurs when making fireworks in puttmoon
- debug(0, "playSound: Invalid sound offset (%d) in sound %d", heOffset, soundID);
- heOffset = 0;
- }
- size -= heOffset;
-
- if (_overrideFreq) {
- // Used by the piano in Fatty Bear's Birthday Surprise
- rate = _overrideFreq;
- _overrideFreq = 0;
- }
-
- if (heFlags & 1) {
- // TODO
- // flags |= Audio::Mixer::FLAG_LOOP;
- }
-
- // Allocate a sound buffer, copy the data into it, and play
- sound = (char *)malloc(size);
- memcpy(sound, ptr + heOffset + 8, size);
- _vm->_mixer->playRaw(&_heSoundChannels[heChannel], sound, size, rate, flags, soundID);
- }
- else if (READ_UINT32(ptr) == MKID('MRAW')) {
- // pcm music in 3DO humongous games
- ptr += 8 + READ_BE_UINT32(ptr+12);
- if (READ_UINT32(ptr) != MKID('SDAT'))
- return;
-
- size = READ_BE_UINT32(ptr+4) - 8;
- rate = 22050;
- flags = Audio::Mixer::FLAG_AUTOFREE;
-
- // Allocate a sound buffer, copy the data into it, and play
- sound = (char *)malloc(size);
- memcpy(sound, ptr + 8, size);
- _vm->_mixer->stopID(_currentMusic);
- _currentMusic = soundID;
- _vm->_mixer->playRaw(NULL, sound, size, rate, flags, soundID);
- }
// Support for sampled sound effects in Monkey Island 1 and 2
else if (READ_UINT32(ptr) == MKID('SBL ')) {
debugC(DEBUG_SOUND, "Using SBL sound effect");
@@ -693,30 +520,6 @@
return ((const MP3OffsetTable *)a)->org_offset - ((const MP3OffsetTable *)b)->org_offset;
}
-void Sound::startHETalkSound(uint32 offset) {
- byte *ptr;
- int32 size;
-
- if (ConfMan.getBool("speech_mute"))
- return;
-
- if (!_sfxFile->isOpen()) {
- error("startHETalkSound: Speech file is not open");
- return;
- }
-
- _sfxMode |= 2;
- _vm->res.nukeResource(rtSound, 1);
- _sfxFile->seek(offset + 4, SEEK_SET);
- size = _sfxFile->readUint32BE() - 8;
- _vm->res.createResource(rtSound, 1, size);
- ptr = _vm->getResourceAddress(rtSound, 1);
- _sfxFile->read(ptr, size);
-
- int channel = (_vm->VAR_SOUND_CHANNEL != 0xFF) ? _vm->VAR(_vm->VAR_SOUND_CHANNEL) : 0;
- addSoundToQueue2(1, 0, channel, 0);
-}
-
void Sound::startTalkSound(uint32 offset, uint32 b, int mode, Audio::SoundHandle *handle) {
int num = 0, i;
int size = 0;
@@ -895,15 +698,6 @@
}
-int Sound::getSoundElapsedTime(int sound) const {
- if (sound >= 10000) {
- int channel = sound - 10000;
- return _vm->_mixer->getSoundElapsedTime(_heSoundChannels[channel]);
- } else {
- return _vm->_mixer->getSoundElapsedTimeOfSoundID(sound);
- }
-}
-
int Sound::isSoundRunning(int sound) const {
#ifndef DISABLE_SCUMM_7_8
if (_vm->_imuseDigital)
@@ -975,6 +769,9 @@
if (_vm->_imuse)
return _vm->_imuse->get_sound_active(sound);
+ if (_vm->_mixer->isSoundIDActive(sound))
+ return 1;
+
return false;
}
@@ -1005,7 +802,13 @@
if (_vm->_heversion >= 70) {
if ( sound >= 10000) {
- _vm->_mixer->stopHandle(_heSoundChannels[sound - 10000]);
+ int chan = sound - 10000;
+ _vm->_mixer->stopHandle(_heSoundChannels[chan]);
+ _heChannel[chan].sound = 0;
+ _heChannel[chan].priority = 0;
+ _heChannel[chan].sbngBlock = 0;
+ _heChannel[chan].codeOffs = 0;
+ memset(_heChannel[chan].soundVars, 0, sizeof(_heChannel[chan].soundVars));
}
} else if (_vm->_heversion >= 60) {
if (sound == -2) {
@@ -1030,6 +833,16 @@
if (_vm->_musicEngine)
_vm->_musicEngine->stopSound(sound);
+ for (i = 0; i < ARRAYSIZE(_heChannel); i++) {
+ if (_heChannel[i].sound == sound) {
+ _heChannel[i].sound = 0;
+ _heChannel[i].priority = 0;
+ _heChannel[i].sbngBlock = 0;
+ _heChannel[i].codeOffs = 0;
+ memset(_heChannel[i].soundVars, 0, sizeof(_heChannel[i].soundVars));
+ }
+ }
+
for (i = 0; i < ARRAYSIZE(_soundQue2); i++) {
if (_soundQue2[i].sound == sound) {
_soundQue2[i].sound = 0;
@@ -1047,6 +860,9 @@
stopCDTimer();
}
+ // Clear sound channels for HE games
+ memset(_heChannel, 0, sizeof(_heChannel));
+
// Clear the (secondary) sound queue
_soundQue2Pos = 0;
memset(_soundQue2, 0, sizeof(_soundQue2));
@@ -1446,7 +1262,6 @@
case MKID('Mac1'):
case MKID('RIFF'):
- case MKID('HSHD'):
case MKID('TALK'):
case MKID('DIGI'):
case MKID('Crea'):
@@ -1458,6 +1273,15 @@
//dumpResource("sound-", idx, ptr);
return 1;
+ case MKID('HSHD'):
+ // HE sound type without SOUN header
+ _fileHandle->seek(-16, SEEK_CUR);
+ total_size = max_total_size + 8;
+ ptr = res.createResource(type, idx, total_size);
+ _fileHandle->read(ptr, total_size);
+ //dumpResource("sound-", idx, ptr);
+ return 1;
+
case MKID('FMUS'): {
// Used in 3DO version of puttputt joins the parade and probably others
// Specifies a separate file to be used for music from what I gather.
Index: sound.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/sound.h,v
retrieving revision 1.92.2.1
retrieving revision 1.92.2.2
diff -u -d -r1.92.2.1 -r1.92.2.2
--- sound.h 18 Oct 2005 02:11:25 -0000 1.92.2.1
+++ sound.h 15 Jan 2006 06:45:15 -0000 1.92.2.2
@@ -94,6 +94,14 @@
HEMusic *_heMusic;
int16 _heMusicTracks;
+ struct {
+ int sound;
+ int codeOffs;
+ int priority;
+ int sbngBlock;
+ int soundVars[27];
+ } _heChannel[9];
+
public:
Audio::SoundHandle _talkChannelHandle; // Handle of mixer channel actor is talking on
Audio::SoundHandle _heSoundChannels[8];
@@ -108,13 +116,11 @@
void addSoundToQueue2(int sound, int heOffset = 0, int heChannel = 0, int heFlags = 0);
void processSound();
void processSoundQueues();
- void setOverrideFreq(int freq);
- void playSound(int soundID, int heOffset, int heChannel, int heFlags);
- void startHETalkSound(uint32 offset);
+
+ void playSound(int soundID);
void startTalkSound(uint32 offset, uint32 b, int mode, Audio::SoundHandle *handle = NULL);
void stopTalkSound();
bool isMouthSyncOff(uint pos);
- int getSoundElapsedTime(int sound) const;
int isSoundRunning(int sound) const;
bool isSoundInUse(int sound) const;
void stopSound(int sound);
@@ -133,8 +139,18 @@
void updateCD();
int getCurrentCDSound() const { return _currentCDSound; }
- void setupHEMusicFile();
+ // HE specific
bool getHEMusicDetails(int id, int &musicOffs, int &musicSize);
+ int isSoundCodeUsed(int sound);
+ int getSoundPos(int sound);
+ int getSoundVar(int sound, int var);
+ void setSoundVar(int sound, int var, int val);
+ void playHESound(int soundID, int heOffset, int heChannel, int heFlags);
+ void processSoundCode();
+ void processSoundOpcodes(int sound, byte *codePtr, int *soundVars);
+ void setOverrideFreq(int freq);
+ void setupHEMusicFile();
+ void startHETalkSound(uint32 offset);
// Used by the save/load system:
const SaveLoadEntry *getSaveLoadEntries();
Index: vars.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/vars.cpp,v
retrieving revision 1.150.2.4
retrieving revision 1.150.2.5
diff -u -d -r1.150.2.4 -r1.150.2.5
--- vars.cpp 21 Dec 2005 12:30:58 -0000 1.150.2.4
+++ vars.cpp 15 Jan 2006 06:45:15 -0000 1.150.2.5
@@ -296,11 +296,13 @@
VAR_NUM_SOUND_CHANNELS = 56;
}
if (_heversion >= 80)
- VAR_PLATFORM = 78; // 1 is PC, 2 is Macintosh
- VAR_WINDOWS_VERSION = 79; // 31 is Windows 3.1, 40 is Windows 95+
+ VAR_PLATFORM = 78; // 1 is PC, 2 is Macintosh
+ VAR_WINDOWS_VERSION = 79; // 31 is Windows 3.1, 40 is Windows 95+
VAR_CURRENT_CHARSET = 80;
+ VAR_SOUNDCODE_TMR = 84;
VAR_KEY_STATE = 86;
VAR_NUM_SOUND_CHANNELS = 88;
+ VAR_REDRAW_ALL_ACTORS = 95;
if (_heversion >= 90) {
VAR_SCRIPT_CYCLE = 103;
VAR_NUM_SCRIPT_CYCLES = 104;
@@ -311,11 +313,13 @@
VAR_U32_VERSION = 107;
VAR_U32_ARRAY_UNK = 116;
VAR_WIZ_TCOLOR = 117;
+ VAR_DEFAULT_SOUND_CHANNEL = 120;
}
if (_heversion >= 98) {
VAR_SKIP_RESET_TALK_ACTOR = 125;
}
if (_heversion >= 99) {
+ VAR_MAIN_SCRIPT = 127;
VAR_NUM_PALETTES = 130;
VAR_NUM_UNK = 131;
}
More information about the Scummvm-git-logs
mailing list