aboutsummaryrefslogtreecommitdiff
path: root/simon
diff options
context:
space:
mode:
authorTravis Howell2003-07-21 04:00:04 +0000
committerTravis Howell2003-07-21 04:00:04 +0000
commit2b5cc772d71a15622dc970793fbb6f9c03763772 (patch)
treed7f5665216e22b7807446e7b32946c37b4f989c4 /simon
parent2929a90d17a81b285f8041f24993023ab3cc35e6 (diff)
downloadscummvm-rg350-2b5cc772d71a15622dc970793fbb6f9c03763772.tar.gz
scummvm-rg350-2b5cc772d71a15622dc970793fbb6f9c03763772.tar.bz2
scummvm-rg350-2b5cc772d71a15622dc970793fbb6f9c03763772.zip
Add sfx/voice support for simon1cd32, thanks to olki.
Adjust a few debugs Add hack to allow load/save in simon1cd32 via keyboard svn-id: r9105
Diffstat (limited to 'simon')
-rw-r--r--simon/items.cpp56
-rw-r--r--simon/simon.cpp6
-rw-r--r--simon/sound.cpp100
-rw-r--r--simon/sound.h1
-rw-r--r--simon/vga.cpp2
5 files changed, 141 insertions, 24 deletions
diff --git a/simon/items.cpp b/simon/items.cpp
index dea3c4d59d..6b294b72aa 100644
--- a/simon/items.cpp
+++ b/simon/items.cpp
@@ -1049,7 +1049,15 @@ int SimonEngine::runScript() {
case 185:{ /* midi sfx file number */
if (_game & GF_SIMON2)
goto invalid_opcode;
- _midi_sfx = getVarOrWord();
+ _midi_sfx = getVarOrWord();
+ if (_game == GAME_SIMON1CD32) {
+ char buf[10];
+ sprintf(buf, "%d%s", _midi_sfx, "Effects");
+ _sound->readSfxFile(buf, _gameDataPath);
+ sprintf(buf, "%d%s", _midi_sfx, "simon");
+ _sound->readVoiceFile(buf, _gameDataPath);
+ }
+
}
break;
@@ -1374,6 +1382,9 @@ int SimonEngine::o_unk_132_helper(bool *b, char *buf) {
start_over:;
_key_pressed = 0;
+ if (_game == GAME_SIMON1CD32)
+ goto start_over_3;
+
start_over_2:;
_last_hitarea = _last_hitarea_3 = 0;
@@ -1419,6 +1430,49 @@ start_over_2:;
if (ha->id >= 214)
goto start_over_2;
return ha->id - 208;
+
+//FIXME Hack to allow load and save file selection in simon1cd32
+// Uses the follow keys for moving around
+// 1 - 6 to select slot to load/save
+// Up Arrow to move up slots
+// Down Arrow to move down slots
+// X to exit
+start_over_3:;
+ if (_saveload_flag) {
+ *b = false;
+ delay(1);
+ return _key_pressed;
+ }
+
+ if (_key_pressed == 17) {
+ if (_saveload_row_curpos == 1)
+ goto start_over_3;
+ if (_saveload_row_curpos < 7)
+ _saveload_row_curpos = 1;
+ else
+ _saveload_row_curpos -= 6;
+
+ goto strange_jump;
+ }
+
+ if (_key_pressed == 18) {
+ if (!_savedialog_flag)
+ goto start_over_3;
+ _saveload_row_curpos += 6;
+ goto strange_jump;
+ }
+
+ if (_key_pressed == 120)
+ return 205;
+
+ if (_key_pressed > 48 && _key_pressed < 55) {
+ return _key_pressed - 49;
+ }
+
+
+ delay(1);
+ goto start_over_3;
+
}
void SimonEngine::o_unk_132_helper_3() {
diff --git a/simon/simon.cpp b/simon/simon.cpp
index 56be85d26c..10fb7a7ef6 100644
--- a/simon/simon.cpp
+++ b/simon/simon.cpp
@@ -1079,8 +1079,6 @@ void SimonEngine::loadTablesIntoMem(uint subr_id) {
if (_game == GAME_SIMON1WIN) {
memcpy(filename, "SFXXXX", 6);
_sound->readSfxFile(filename, _gameDataPath);
- } else if (_game == GAME_SIMON1CD32) {
- //TODO Add loading of simon1cd32 sound effects and voice files.
} else if (_game & GF_SIMON2) {
_sound->loadSfxTable(_game_file, _game_offsets_ptr[atoi(filename + 6) - 1 + gss->SOUND_INDEX_BASE]);
}
@@ -4745,10 +4743,10 @@ void SimonEngine::loadMusic (uint music) {
if (_game & GF_AMIGA) {
if (_game != GAME_SIMON1CD32) {
// TODO Add support for decruncher
- debug(1,"playMusic - Decrunch %dtune attempt", music);
+ debug(5,"playMusic - Decrunch %dtune attempt", music);
}
// TODO Add Protracker support for simon1amiga/cd32
- debug(1,"playMusic - Load %dtune attempt", music);
+ debug(5,"playMusic - Load %dtune attempt", music);
} else {
midi.stop();
midi.setLoop (true); // Must do this BEFORE loading music. (GMF may have its own override.)
diff --git a/simon/sound.cpp b/simon/sound.cpp
index 61b22b5cd3..c18c6a34db 100644
--- a/simon/sound.cpp
+++ b/simon/sound.cpp
@@ -22,6 +22,9 @@
#include "common/file.h"
#include "common/engine.h"
+#define SOUND_BIG_ENDIAN true
+#define FLAG_SIGNED 0
+
class BaseSound {
protected:
File *_file;
@@ -29,26 +32,32 @@ protected:
SoundMixer *_mixer;
public:
- BaseSound(SoundMixer *mixer, File *file, uint32 base = 0);
- BaseSound(SoundMixer *mixer, File *file, uint32 *offsets);
+ BaseSound(SoundMixer *mixer, File *file, uint32 base = 0, bool bigendian = false);
+ BaseSound(SoundMixer *mixer, File *file, uint32 *offsets, bool bigendian = false);
virtual ~BaseSound();
- virtual int playSound(uint sound, PlayingSoundHandle *handle, byte flags = 0) = 0;
+ virtual int playSound(uint sound, PlayingSoundHandle *handle, byte flags = SoundMixer::FLAG_UNSIGNED) = 0;
};
class WavSound : public BaseSound {
public:
- WavSound(SoundMixer *mixer, File *file, uint32 base = 0) : BaseSound(mixer, file, base) {};
+ WavSound(SoundMixer *mixer, File *file, uint32 base = 0, bool bigendian = false) : BaseSound(mixer, file, base, bigendian) {};
WavSound(SoundMixer *mixer, File *file, uint32 *offsets) : BaseSound(mixer, file, offsets) {};
- int playSound(uint sound, PlayingSoundHandle *handle, byte flags = 0);
+ int playSound(uint sound, PlayingSoundHandle *handle, byte flags = SoundMixer::FLAG_UNSIGNED);
};
class VocSound : public BaseSound {
public:
- VocSound(SoundMixer *mixer, File *file, uint32 base = 0) : BaseSound(mixer, file, base) {};
- int playSound(uint sound, PlayingSoundHandle *handle, byte flags = 0);
+ VocSound(SoundMixer *mixer, File *file, uint32 base = 0, bool bigendian = false) : BaseSound(mixer, file, base, bigendian) {};
+ int playSound(uint sound, PlayingSoundHandle *handle, byte flags = SoundMixer::FLAG_UNSIGNED);
+};
+class RawSound : public BaseSound {
+public:
+ RawSound(SoundMixer *mixer, File *file, uint32 base = 0, bool bigendian = false) : BaseSound(mixer, file, base, bigendian) {};
+ int playSound(uint sound, PlayingSoundHandle *handle, byte flags = SoundMixer::FLAG_UNSIGNED);
};
-BaseSound::BaseSound(SoundMixer *mixer, File *file, uint32 base) {
+
+BaseSound::BaseSound(SoundMixer *mixer, File *file, uint32 base, bool bigendian) {
_mixer = mixer;
_file = file;
@@ -56,7 +65,10 @@ BaseSound::BaseSound(SoundMixer *mixer, File *file, uint32 base) {
uint32 size;
_file->seek(base + sizeof(uint32), SEEK_SET);
- size = _file->readUint32LE();
+ if (bigendian)
+ size = _file->readUint32BE();
+ else
+ size = _file->readUint32LE();
res = size / sizeof(uint32);
@@ -69,8 +81,11 @@ BaseSound::BaseSound(SoundMixer *mixer, File *file, uint32 base) {
for (uint i = 0; i < res; i++) {
#if defined(SCUMM_BIG_ENDIAN)
+ if (!(bigendian))
_offsets[i] = FROM_LE_32(_offsets[i]);
#endif
+ if (bigendian)
+ _offsets[i] = TO_BE_32(_offsets[i]);
_offsets[i] += base;
}
@@ -79,7 +94,7 @@ BaseSound::BaseSound(SoundMixer *mixer, File *file, uint32 base) {
_offsets[res] = _file->pos();
}
-BaseSound::BaseSound(SoundMixer *mixer, File *file, uint32 *offsets) {
+BaseSound::BaseSound(SoundMixer *mixer, File *file, uint32 *offsets, bool bigendian) {
_mixer = mixer;
_file = file;
_offsets = offsets;
@@ -136,7 +151,7 @@ int WavSound::playSound(uint sound, PlayingSoundHandle *handle, byte flags) {
WaveHeader wave_hdr;
uint32 data[2];
- flags |= SoundMixer::FLAG_UNSIGNED|SoundMixer::FLAG_AUTOFREE;
+ flags |= SoundMixer::FLAG_AUTOFREE;
_file->seek(_offsets[sound], SEEK_SET);
@@ -171,7 +186,7 @@ int VocSound::playSound(uint sound, PlayingSoundHandle *handle, byte flags) {
VocBlockHeader voc_block_hdr;
uint32 size;
- flags |= SoundMixer::FLAG_UNSIGNED|SoundMixer::FLAG_AUTOFREE;
+ flags |= SoundMixer::FLAG_AUTOFREE;
_file->seek(_offsets[sound], SEEK_SET);
@@ -201,11 +216,25 @@ int VocSound::playSound(uint sound, PlayingSoundHandle *handle, byte flags) {
return _mixer->playRaw(handle, buffer, size, samples_per_sec, flags);
}
+int RawSound::playSound(uint sound, PlayingSoundHandle *handle, byte flags) {
+ if (_offsets == NULL)
+ return 0;
+
+ flags |= SoundMixer::FLAG_AUTOFREE;
+
+ _file->seek(_offsets[sound], SEEK_SET);
+ uint size = _file->readUint32BE();
+ byte *buffer = (byte *)malloc(size);
+ _file->read(buffer, size);
+
+ return _mixer->playRaw(handle, buffer, size, 22050, flags);
+}
+
#ifdef USE_MAD
class MP3Sound : public BaseSound {
public:
MP3Sound(SoundMixer *mixer, File *file, uint32 base = 0) : BaseSound(mixer, file, base) {};
- int playSound(uint sound, PlayingSoundHandle *handle, byte flags = 0);
+ int playSound(uint sound, PlayingSoundHandle *handle, byte flags = SoundMixer::FLAG_UNSIGNED);
};
int MP3Sound::playSound(uint sound, PlayingSoundHandle *handle, byte flags)
@@ -289,6 +318,9 @@ SimonSound::SimonSound(const byte game, const GameSpecificSettings *gss, const c
_voice_file = true;
_voice = new WavSound(_mixer, file);
}
+ } else if (_game == GAME_SIMON1CD32) {
+ // simon1cd32 uses separate voice files
+ return;
} else if (_game & GF_TALKIE) {
s = gss->voc_filename;
file->open(s, gameDataPath);
@@ -355,7 +387,10 @@ void SimonSound::readSfxFile(const char *filename, const char *gameDataPath) {
}
}
- _effects = new WavSound(_mixer, file);
+ if (_game == GAME_SIMON1CD32) {
+ _effects = new VocSound(_mixer, file, 0, SOUND_BIG_ENDIAN);
+ } else
+ _effects = new WavSound(_mixer, file);
}
void SimonSound::loadSfxTable(File *gameFile, uint32 base) {
@@ -367,6 +402,29 @@ void SimonSound::loadSfxTable(File *gameFile, uint32 base) {
_effects = new VocSound(_mixer, gameFile, base);
}
+void SimonSound::readVoiceFile(const char *filename, const char *gameDataPath) {
+ stopAll();
+
+ File *file = new File();
+ file->open(filename, gameDataPath);
+
+ if (file->isOpen() == false) {
+ char *filename2;
+ filename2 = (char *)malloc(strlen(filename) + 2);
+ strcpy(filename2, filename);
+ strcat(filename2, ".");
+ file->open(filename2, gameDataPath);
+ free(filename2);
+ if (file->isOpen() == false) {
+ if (atoi(filename + 6) != 1 && atoi(filename + 6) != 30)
+ warning("readVoiceFile: Can't load voice file %s", filename);
+ return;
+ }
+ }
+
+ _voice = new RawSound(_mixer, file, 0, SOUND_BIG_ENDIAN);
+}
+
void SimonSound::playVoice(uint sound) {
if (_game == GAME_SIMON2MAC && _filenums) {
char filename[16];
@@ -383,8 +441,11 @@ void SimonSound::playVoice(uint sound) {
if (!_voice)
return;
-
- _voice_index = _voice->playSound(sound, &_voice_handle);
+
+ if (_game == GAME_SIMON1CD32)
+ _voice_index = _voice->playSound(sound, &_voice_handle, FLAG_SIGNED);
+ else
+ _voice_index = _voice->playSound(sound, &_voice_handle);
}
void SimonSound::playEffects(uint sound) {
@@ -394,7 +455,10 @@ void SimonSound::playEffects(uint sound) {
if (_effects_paused)
return;
- _effects->playSound(sound, &_effects_handle);
+ if (_game == GAME_SIMON1CD32)
+ _effects->playSound(sound, &_effects_handle, FLAG_SIGNED);
+ else
+ _effects->playSound(sound, &_effects_handle);
}
void SimonSound::playAmbient(uint sound) {
@@ -412,7 +476,7 @@ void SimonSound::playAmbient(uint sound) {
if (_ambient_handle)
_mixer->stop(_ambient_index);
- _ambient_index = _effects->playSound(sound, &_ambient_handle, SoundMixer::FLAG_LOOP);
+ _ambient_index = _effects->playSound(sound, &_ambient_handle, SoundMixer::FLAG_LOOP|SoundMixer::FLAG_UNSIGNED);
}
bool SimonSound::hasVoice() {
diff --git a/simon/sound.h b/simon/sound.h
index d3eb7ab325..d6faaff251 100644
--- a/simon/sound.h
+++ b/simon/sound.h
@@ -54,6 +54,7 @@ public:
void readSfxFile(const char *filename, const char *gameDataPath);
void loadSfxTable(File *gameFile, uint32 base);
+ void readVoiceFile(const char *filename, const char *gameDataPath);
void playVoice(uint sound);
void playEffects(uint sound);
diff --git a/simon/vga.cpp b/simon/vga.cpp
index 84f4fa00ac..9d9e3d9711 100644
--- a/simon/vga.cpp
+++ b/simon/vga.cpp
@@ -658,7 +658,7 @@ void SimonEngine::vc_10_draw() {
} else if (state.e & 1) {
// FIXME: vc_10_no_depack_swap should be called but is currently not supported
//state.depack_src = vc_10_no_depack_swap(state.depack_src);
- debug(1,"vc_10_no_depack_swap unimpl");
+ debug(5,"vc_10_no_depack_swap unimpl");
state.depack_src = vc_10_depack_swap(state.depack_src, width, height);
}