aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--simon/simon.cpp32
-rw-r--r--simon/simon.h5
-rw-r--r--simon/sound.cpp30
-rw-r--r--simon/sound.h1
-rw-r--r--simon/vga.cpp24
5 files changed, 71 insertions, 21 deletions
diff --git a/simon/simon.cpp b/simon/simon.cpp
index 7f29eee9d0..648b3b7c8b 100644
--- a/simon/simon.cpp
+++ b/simon/simon.cpp
@@ -432,6 +432,7 @@ SimonEngine::SimonEngine(GameDetector *detector, OSystem *syst)
_curVgaFile1 = 0;
_curVgaFile2 = 0;
+ _curSfxFile = 0;
_timer1 = 0;
_timer5 = 0;
@@ -2275,8 +2276,9 @@ void SimonEngine::ensureVgaResLoaded(uint vga_res) {
if (vpe->vgaFile1 != NULL)
return;
- vpe->vgaFile2 = read_vga_from_datfile_2(vga_res * 2 + 1);
- vpe->vgaFile1 = read_vga_from_datfile_2(vga_res * 2);
+ vpe->vgaFile1 = read_vga_from_datfile_2(vga_res * 2, 1);
+ vpe->vgaFile2 = read_vga_from_datfile_2(vga_res * 2 + 1, 2);
+ vpe->sfxFile = read_vga_from_datfile_2(vga_res * 2, 3);
}
@@ -2358,7 +2360,7 @@ void SimonEngine::delete_memptr_range(byte *end) {
do {
if (_vgaBufFreeStart <= vpe->vgaFile1 && end >= vpe->vgaFile1 ||
_vgaBufFreeStart <= vpe->vgaFile2 && end >= vpe->vgaFile2) {
- vpe->dd = 0;
+ vpe->sfxFile = NULL;
vpe->vgaFile1 = NULL;
vpe->vgaFile2 = NULL;
}
@@ -2386,7 +2388,7 @@ void SimonEngine::o_clear_vgapointer_entry(uint a) {
vpe = &_vgaBufferPointers[a];
- vpe->dd = 0;
+ vpe->sfxFile = NULL;
vpe->vgaFile1 = NULL;
vpe->vgaFile2 = NULL;
}
@@ -2428,6 +2430,7 @@ void SimonEngine::set_video_mode_internal(uint mode, uint vga_res_id) {
_curVgaFile1 = vpe->vgaFile1;
_curVgaFile2 = vpe->vgaFile2;
+ _curSfxFile = vpe->sfxFile;
if (vpe->vgaFile1 != NULL)
break;
@@ -2617,6 +2620,7 @@ void SimonEngine::vc_resume_sprite(const byte *code_ptr, uint16 cur_file, uint16
_curVgaFile1 = vpe->vgaFile1;
_curVgaFile2 = vpe->vgaFile2;
+ _curSfxFile = vpe->sfxFile;
_vcPtr = code_ptr;
@@ -2728,6 +2732,7 @@ void SimonEngine::timer_vga_sprites() {
vpe = &_vgaBufferPointers[vsp->fileId];
_curVgaFile1 = vpe->vgaFile1;
_curVgaFile2 = vpe->vgaFile2;
+ _curSfxFile = vpe->sfxFile;
_windowNum = vsp->windowNum;
_vgaCurSpriteId = vsp->id;
@@ -2806,6 +2811,7 @@ void SimonEngine::timer_vga_sprites_2() {
vpe = &_vgaBufferPointers[vsp->fileId];
_curVgaFile1 = vpe->vgaFile1;
_curVgaFile2 = vpe->vgaFile2;
+ _curSfxFile = vpe->sfxFile;
_windowNum = vsp->windowNum;
_vgaCurSpriteId = vsp->id;
@@ -3698,7 +3704,7 @@ void SimonEngine::read_vga_from_datfile_1(uint vga_id) {
}
}
-byte *SimonEngine::read_vga_from_datfile_2(uint id) {
+byte *SimonEngine::read_vga_from_datfile_2(uint id, uint type) {
// !!! HACK !!!
// allocate more space for text to cope with foreign languages that use
// up more space than english. I hope 6400 bytes are enough. This number
@@ -3709,20 +3715,24 @@ byte *SimonEngine::read_vga_from_datfile_2(uint id) {
File in;
char buf[15];
uint32 size;
- byte *dst;
+ byte *dst = NULL;
if (getPlatform() == Common::kPlatformAmiga) {
if (getFeatures() & GF_TALKIE)
- sprintf(buf, "%.3d%d.out", id / 2, (id & 1) + 1);
+ sprintf(buf, "%.3d%d.out", id / 2, type);
else
- sprintf(buf, "%.3d%d.pkd", id / 2, (id & 1) + 1);
+ sprintf(buf, "%.3d%d.pkd", id / 2, type);
} else {
- sprintf(buf, "%.3d%d.VGA", id / 2, (id & 1) + 1);
+ sprintf(buf, "%.3d%d.VGA", id / 2, type);
}
in.open(buf);
- if (in.isOpen() == false)
- error("read_vga_from_datfile_2: can't open %s", buf);
+ if (in.isOpen() == false) {
+ if (type == 3)
+ return NULL;
+ else
+ error("read_vga_from_datfile_2: can't open %s", buf);
+ }
size = in.size();
if (getFeatures() & GF_CRUNCHED) {
diff --git a/simon/simon.h b/simon/simon.h
index 6f504802c4..c2d4b98a7e 100644
--- a/simon/simon.h
+++ b/simon/simon.h
@@ -72,7 +72,7 @@ struct HitArea {
struct VgaPointersEntry {
byte *vgaFile1;
byte *vgaFile2;
- uint32 dd;
+ byte *sfxFile;
VgaPointersEntry() { memset(this, 0, sizeof(*this)); }
};
@@ -336,6 +336,7 @@ protected:
byte *_curVgaFile1;
byte *_curVgaFile2;
+ byte *_curSfxFile;
uint16 _timer1, _timer5, _timer4;
@@ -797,7 +798,7 @@ protected:
byte *dx_lock_attached();
void dx_unlock_attached();
- byte *read_vga_from_datfile_2(uint id);
+ byte *read_vga_from_datfile_2(uint id, uint type);
void resfile_read(void *dst, uint32 offs, uint32 size);
diff --git a/simon/sound.cpp b/simon/sound.cpp
index 6bc7c04375..fd65e9f48a 100644
--- a/simon/sound.cpp
+++ b/simon/sound.cpp
@@ -450,6 +450,36 @@ void Sound::playVoice(uint sound) {
_voice->playSound(sound, &_voiceHandle, (_vm->getGameId() == GID_SIMON1CD32) ? 0 : Audio::Mixer::FLAG_UNSIGNED);
}
+void Sound::playSoundData(byte *soundData, uint sound, uint pan, uint vol, bool ambient) {
+ byte flags;
+ int rate;
+
+ if (ambient) {
+ if (_ambientPaused || sound == _ambientPlaying)
+ return;
+ } else {
+ if (_effectsPaused)
+ return;
+ }
+
+ // TODO: Use sound offsets
+ soundData += 8;
+ int32 size = READ_LE_UINT32(soundData + 4);
+ Common::MemoryReadStream stream(soundData, size);
+ if (!loadWAVFromStream(stream, size, rate, flags)) {
+ error("playSoundData: Not a valid WAV data");
+ }
+
+ byte *buffer = (byte *)malloc(size);
+ memcpy(buffer, soundData + stream.pos(), size);
+
+ if (ambient && sound == _ambientPlaying) {
+ _mixer->playRaw(&_effectsHandle, buffer, size, rate, flags);
+ } else {
+ _mixer->playRaw(&_ambientHandle, buffer, size, rate, Audio::Mixer::FLAG_LOOP|flags);
+ }
+}
+
void Sound::playEffects(uint sound) {
if (!_effects)
return;
diff --git a/simon/sound.h b/simon/sound.h
index efda01f122..027f3beaeb 100644
--- a/simon/sound.h
+++ b/simon/sound.h
@@ -65,6 +65,7 @@ public:
void playVoice(uint sound);
void playEffects(uint sound);
void playAmbient(uint sound);
+ void playSoundData(byte *soundData, uint sound, uint pan, uint vol, bool ambient);
bool hasVoice() const;
bool isVoiceActive() const;
diff --git a/simon/vga.cpp b/simon/vga.cpp
index a19f23f2c0..e8126bc365 100644
--- a/simon/vga.cpp
+++ b/simon/vga.cpp
@@ -1606,23 +1606,31 @@ void SimonEngine::vc51_clear_hitarea_bit_0x40() {
}
void SimonEngine::vc52_playSound() {
- uint16 sound_id = vc_read_next_word();
+ bool ambient = false;
+
+ uint16 sound = vc_read_next_word();
+ if (sound >= 0x8000) {
+ ambient = true;
+ sound = -sound;
+ }
if (getGameType() == GType_FF) {
uint16 pan = vc_read_next_word();
uint16 vol = vc_read_next_word();
- debug(0, "STUB: vc52_playSound: snd %d pan %d vol %d", sound_id, pan, vol);
+ debug(0, "STUB: vc52_playSound: snd %d pan %d vol %d", sound, pan, vol);
+
+ _sound->playSoundData(_curSfxFile, sound, pan, vol, ambient);
+
} else if (getGameType() == GType_SIMON2) {
- if (sound_id >= 0x8000) {
- sound_id = -sound_id;
- _sound->playAmbient(sound_id);
+ if (ambient) {
+ _sound->playAmbient(sound);
} else {
- _sound->playEffects(sound_id);
+ _sound->playEffects(sound);
}
} else if (getFeatures() & GF_TALKIE) {
- _sound->playEffects(sound_id);
+ _sound->playEffects(sound);
} else {
- playSting(sound_id);
+ playSting(sound);
}
}