aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTravis Howell2003-01-03 12:06:30 +0000
committerTravis Howell2003-01-03 12:06:30 +0000
commit3a4782f16656c180b48be4afa1270a7ec351ed72 (patch)
tree063280408ebd9536376aae69d6f2e7a9108a96ab
parentf1365f4f2b861ecfed42dea4b534ee14eca245ac (diff)
downloadscummvm-rg350-3a4782f16656c180b48be4afa1270a7ec351ed72.tar.gz
scummvm-rg350-3a4782f16656c180b48be4afa1270a7ec351ed72.tar.bz2
scummvm-rg350-3a4782f16656c180b48be4afa1270a7ec351ed72.zip
Add olki's patch for sound effects in simon1dos
Plus hack to allow choice between midi music and sound effects via 's' key svn-id: r6326
-rw-r--r--simon/items.cpp7
-rw-r--r--simon/midi.cpp23
-rw-r--r--simon/midi.h6
-rw-r--r--simon/simon.cpp55
-rw-r--r--simon/simon.h7
-rw-r--r--simon/vga.cpp4
6 files changed, 91 insertions, 11 deletions
diff --git a/simon/items.cpp b/simon/items.cpp
index c9903d6e68..8cd5ff67df 100644
--- a/simon/items.cpp
+++ b/simon/items.cpp
@@ -1045,7 +1045,7 @@ int SimonState::runScript()
case 185:{
if (_game & GAME_SIMON2)
goto invalid_opcode;
- getVarOrWord();
+ _midi_sfx = getVarOrWord();
}
break;
@@ -1527,7 +1527,10 @@ void SimonState::o_unk_120(uint a)
void SimonState::o_unk_163(uint a)
{
- _sound->playEffects(a);
+ if (_game == GAME_SIMON1DOS)
+ playSting(a);
+ else
+ _sound->playEffects(a);
}
void SimonState::o_unk_160(uint a)
diff --git a/simon/midi.cpp b/simon/midi.cpp
index ad9c7d24f8..306cbca6ee 100644
--- a/simon/midi.cpp
+++ b/simon/midi.cpp
@@ -61,7 +61,16 @@ void MidiPlayer::read_all_songs_old(File *in, uint music)
}
}
-void MidiPlayer::read_mthd(File *in, Song *s, bool old, uint music)
+void MidiPlayer::read_all_songs_old(File *in, uint music, uint16 size)
+{
+ _currentSong = _songs;
+
+ _lastDelay = 0;
+
+ read_one_song(in, &_songs[0], music, size);
+}
+
+void MidiPlayer::read_mthd(File *in, Song *s, bool old, uint music, uint16 size)
{
Track *t;
uint i;
@@ -98,6 +107,9 @@ void MidiPlayer::read_mthd(File *in, Song *s, bool old, uint music)
6570, 5384, 8909, 6457, 16321, 2742, 8968, 4804, 8442, 7717,
9444, 5800, 1381, 5660, 6684, 2456, 4744, 2455, 1177, 1232,
17256, 5103, 8794, 4884, 16};
+ if (size)
+ t->data_size = size - 8;
+ else
t->data_size = music_data_size[music] - 8;
}
@@ -123,7 +135,7 @@ void MidiPlayer::read_mthd(File *in, Song *s, bool old, uint music)
}
}
-void MidiPlayer::read_one_song(File *in, Song *s, uint music)
+void MidiPlayer::read_one_song(File *in, Song *s, uint music, uint16 size)
{
_lastDelay = 0;
@@ -136,11 +148,11 @@ void MidiPlayer::read_one_song(File *in, Song *s, uint music)
switch (id) {
case 'MThd':
- read_mthd(in, s, false, music);
+ read_mthd(in, s, false, music, size);
break;
case 'GMF\x1':
- read_mthd(in, s, true, music);
+ read_mthd(in, s, true, music, size);
break;
default:
@@ -281,6 +293,9 @@ bool MidiPlayer::fill_helper(NoteRec *nr, MidiEvent *me)
void MidiPlayer::reset_tracks()
{
+ if (_midi_sfx_toggle)
+ return;
+
Track *t;
uint i;
diff --git a/simon/midi.h b/simon/midi.h
index 9b3cfc7a6a..d3ab7bd1fd 100644
--- a/simon/midi.h
+++ b/simon/midi.h
@@ -31,7 +31,9 @@ class MidiPlayer {
public:
MidiPlayer();
+ bool _midi_sfx_toggle;
void read_all_songs (File *in, uint music);
+ void read_all_songs_old (File *in, uint music, uint16 size);
void read_all_songs_old (File *in, uint music);
void initialize();
void shutdown();
@@ -76,9 +78,9 @@ private:
byte _masterVolume; // 0-255
bool _paused;
- void read_mthd(File *in, Song *s, bool old, uint music);
+ void read_mthd(File *in, Song *s, bool old, uint music, uint16 size);
- void read_one_song(File *in, Song *s, uint music);
+ void read_one_song(File *in, Song *s, uint music, uint16 size = 0);
static uint32 track_read_gamma(Track *t);
static byte track_read_byte(Track *t);
diff --git a/simon/simon.cpp b/simon/simon.cpp
index e1b3325e06..b91b907f0a 100644
--- a/simon/simon.cpp
+++ b/simon/simon.cpp
@@ -806,7 +806,7 @@ void SimonState::loadTablesIntoMem(uint subr_id)
closeTablesFile(in);
memcpy(filename, "SFXXXX", 6);
- if (_game == GAME_SIMON1WIN )
+ if (_game == GAME_SIMON1WIN)
_sound->readSfxFile(filename, _gameDataPath);
else if (_game & GAME_SIMON2) {
_sound->loadSfxTable(_game_file, _game_offsets_ptr[atoi(filename + 6) - 1 + gss->SOUND_INDEX_BASE]);
@@ -828,6 +828,45 @@ void SimonState::loadTablesIntoMem(uint subr_id)
warning("loadTablesIntoMem: didn't find %d", subr_id);
}
+void SimonState::readSting(uint a)
+{
+ char filename[11];
+ uint16 size;
+
+ _mus_file = new File();
+
+ sprintf(filename, "stings%i.mus", a);
+
+ _mus_file->open(filename, _gameDataPath);
+
+ if (!_mus_file->isOpen())
+ return;
+
+ size = _mus_file->readUint16LE();
+
+ _mus_offsets = (uint16 *)malloc(size);
+
+ _mus_file->seek(0, SEEK_SET);
+
+ if (_mus_file->read(_mus_offsets, size) != size)
+ error("Cannot read offsets");
+}
+
+void SimonState::playSting(uint a)
+{
+ if (!midi._midi_sfx_toggle)
+ return;
+
+ readSting(_midi_sfx);
+
+ midi.shutdown();
+ _mus_file->seek(_mus_offsets[a], SEEK_SET);
+ midi.read_all_songs_old(_mus_file, a, _mus_offsets[a+1] - _mus_offsets[a]);
+
+ midi.initialize();
+ midi.play();
+}
+
Subroutine *SimonState::getSubroutineByID(uint subroutine_id)
{
Subroutine *cur;
@@ -3099,7 +3138,14 @@ void SimonState::processSpecialKeys()
break;
case 's':
- _sound->effectsPause(_effects_paused ^= 1);
+ if (_game == GAME_SIMON1DOS) {
+ midi._midi_sfx_toggle ^= 1;
+ if (midi._midi_sfx_toggle)
+ midi.shutdown();
+ else
+ playMusic(0, _last_music_played);
+ } else
+ _sound->effectsPause(_effects_paused ^= 1);
break;
case 'b':
@@ -4502,6 +4548,8 @@ void SimonState::go()
} else {
_vk_t_toggle = true;
}
+
+ midi._midi_sfx_toggle = false;
while (1) {
hitarea_stuff();
@@ -4810,6 +4858,9 @@ bool SimonState::load_game(uint slot)
void SimonState::playMusic(uint music_unk, uint music)
{
+ if (midi._midi_sfx_toggle)
+ return;
+
if (_game & GAME_SIMON2) { // Simon 2 music
if (_game & GAME_WIN) {
midi.shutdown();
diff --git a/simon/simon.h b/simon/simon.h
index 4b62082fd8..aa488a407d 100644
--- a/simon/simon.h
+++ b/simon/simon.h
@@ -100,6 +100,12 @@ struct GameSpecificSettings;
class SimonState : public Engine {
public:
+ File *_mus_file;
+ uint16 *_mus_offsets;
+
+ void SimonState::readSting(uint a);
+ void SimonState::playSting(uint a);
+
byte *_vc_ptr; /* video code ptr */
uint32 *_game_offsets_ptr;
@@ -246,6 +252,7 @@ public:
bool _skip_speech;
byte _video_var_9;
+ uint _midi_sfx;
uint _last_music_played;
bool _show_preposition;
diff --git a/simon/vga.cpp b/simon/vga.cpp
index 7d5b271d37..50a7d56406 100644
--- a/simon/vga.cpp
+++ b/simon/vga.cpp
@@ -1594,7 +1594,9 @@ void SimonState::vc_52_play_sound()
{
uint16 a = vc_read_next_word();
- if (!(_game & GAME_SIMON2)) {
+ if (_game == GAME_SIMON1DOS) {
+ playSting(a);
+ } else if (!(_game & GAME_SIMON2)) {
_sound->playEffects(a);
} else {
if (a >= 0x8000) {