aboutsummaryrefslogtreecommitdiff
path: root/simon
diff options
context:
space:
mode:
authorLudvig Strigeus2002-04-14 18:13:08 +0000
committerLudvig Strigeus2002-04-14 18:13:08 +0000
commitac62a7cb2e17a86350681366d768a99db3b9845d (patch)
tree48a6f9eca1242f7ebf03f05835372811a4048f7a /simon
parenta5e3dbb85dad96d8ffb6205e07d12ff8396ba5c7 (diff)
downloadscummvm-rg350-ac62a7cb2e17a86350681366d768a99db3b9845d.tar.gz
scummvm-rg350-ac62a7cb2e17a86350681366d768a99db3b9845d.tar.bz2
scummvm-rg350-ac62a7cb2e17a86350681366d768a99db3b9845d.zip
wrote new mixer class,
cleaned up sound header files, integrated mixer into scummvm & simon svn-id: r3937
Diffstat (limited to 'simon')
-rw-r--r--simon/midi.cpp3
-rw-r--r--simon/simon.cpp45
-rw-r--r--simon/simon.h40
-rw-r--r--simon/simonsys.cpp1
4 files changed, 53 insertions, 36 deletions
diff --git a/simon/midi.cpp b/simon/midi.cpp
index d48a03eb48..a83ed65707 100644
--- a/simon/midi.cpp
+++ b/simon/midi.cpp
@@ -23,7 +23,8 @@
#include "stdafx.h"
#include "scummsys.h"
#include "system.h"
-#include "gmidi.h"
+#include "mididrv.h"
+#include "mixer.h"
#include "simon.h"
void MidiPlayer::read_from_file(void *dst, uint size) {
diff --git a/simon/simon.cpp b/simon/simon.cpp
index ada5890267..f673a65e16 100644
--- a/simon/simon.cpp
+++ b/simon/simon.cpp
@@ -23,8 +23,10 @@
#include "stdafx.h"
#include "scummsys.h"
#include "system.h"
+#include "mixer.h"
#include "simon.h"
+
#include <errno.h>
#include <time.h>
#ifdef WIN32
@@ -5034,8 +5036,7 @@ void SimonState::vc_29_stop_all_sounds() {
/* XXX: implement */
// warning("vc_29_stop_all_sounds unimplemented");
- _voice_size = 0;
- _sound_size = 0;
+ _mixer->stop_all();
}
void SimonState::vc_30_set_base_delay() {
@@ -6518,7 +6519,7 @@ bool SimonState::vc_59_helper() {
#else
if (_voice_file==NULL)
return false;
- return _voice_size == 0;
+ return _voice_sound == 0;
#endif
}
@@ -6574,9 +6575,8 @@ void SimonState::readSfxFile(const char *filename) {
rewind(in);
- /* if a sound is playing, stop it */
- _sound_size = 0;
-
+ /* stop all sounds */
+ _mixer->stop_all();
if (_sfx_heap) free(_sfx_heap);
@@ -6595,10 +6595,6 @@ void SimonState::readSfxFile(const char *filename) {
vc_29_stop_all_sounds();
- /* if a sound is playing, stop it */
- _sound_size = 0;
-
-
if (_sfx_heap) free(_sfx_heap);
res = atoi(filename + 6) + gss->SOUND_INDEX_BASE - 1;
@@ -7386,7 +7382,7 @@ void SimonState::openGameFile() {
loadIconFile();
- _system->init_size(320,200,OSystem::SOUND_8BIT);
+ _system->init_size(320,200);
startUp(1);
}
@@ -7411,6 +7407,7 @@ void SimonState::runSubroutine101() {
startUp_helper_2();
}
+#if 0
void SimonState::generateSound(byte *ptr, int len) {
uint cur;
@@ -7438,10 +7435,11 @@ void SimonState::generateSound(byte *ptr, int len) {
_sound_ptr += cur;
}
}
+#endif
-static void fill_sound(void *userdata, int16 *stream, int len) {
- ((SimonState*)userdata)->generateSound((byte*)stream, len*2);
-}
+//static void fill_sound(void *userdata, int16 *stream, int len) {
+// ((SimonState*)userdata)->generateSound((byte*)stream, len*2);
+//}
void SimonState::dx_copy_rgn_from_3_to_2(uint b, uint r, uint y, uint x) {
byte *dst, *src;
@@ -7579,8 +7577,10 @@ void SimonState::go(OSystem *syst, MidiDriver *driver) {
_vga_base_delay = 1;
_vk_t_toggle = true;
- _system->set_param(OSystem::PARAM_SHOW_DEFAULT_CURSOR, 1);
- _system->set_sound_proc(this, fill_sound);
+ _system->property(OSystem::PROP_SHOW_DEFAULT_CURSOR, 1);
+
+ _mixer->bind_to_system(_system);
+ _mixer->set_volume(256);
while(1) {
hitarea_stuff();
@@ -7915,11 +7915,11 @@ void SimonState::playVoice(uint voice) {
// assert(voice < 14496/4);
- _voice_size = 0;
-
if (_voice_offsets == NULL)
return;
+ _mixer->stop(_voice_sound);
+
fseek(_voice_file, _voice_offsets[voice], SEEK_SET);
if (fread(&wave_hdr, sizeof(wave_hdr), 1, _voice_file)!=1 ||
@@ -7937,7 +7937,8 @@ void SimonState::playVoice(uint voice) {
return;
}
- _voice_size = data[1];
+ _mixer->play_raw(&_voice_sound, _voice_file, data[1], wave_hdr.samples_per_sec,
+ SoundMixer::FLAG_FILE|SoundMixer::FLAG_UNSIGNED);
}
@@ -7945,8 +7946,7 @@ void SimonState::playSound(uint sound) {
if (_game & GAME_WIN) {
byte *p;
- /* stop any currently playing sound */
- _sound_size = 0;
+ _mixer->stop(_playing_sound);
/* Check if _sfx_heap is NULL */
if (_sfx_heap == NULL) {
@@ -7968,8 +7968,7 @@ void SimonState::playSound(uint sound) {
p++;
}
- _sound_ptr = p + 8;
- _sound_size = ((uint32*)p)[1];
+ _mixer->play_raw(&_playing_sound, p+8,*(uint32*)(p+4),22050,SoundMixer::FLAG_UNSIGNED);
} else {
warning("playSound(%d)", sound);
}
diff --git a/simon/simon.h b/simon/simon.h
index a4067dad26..a4391e482f 100644
--- a/simon/simon.h
+++ b/simon/simon.h
@@ -1,12 +1,22 @@
-/* Copyright ©2002, The ScummVM Team.
+/* ScummVM - Scumm Interpreter
+ * Copyright (C) 2001/2002 The ScummVM project
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Header$
*
- * Current status:
- * Save/Load dialog doesn't work. You can still save, but only to ONE slot.
- * There is possibly one or two problems that makes it impossible to finish SIMON1WIN.
- * Sound & Music only works with SIMON1WIN.
- * SIMON1DOS works, but without sound & music.
- * Simon 2 works a little.
- * The code only compiles in win32. It's currently not alignment safe and not endian safe.
*/
/* GFX Settings. Sound & Music only works properly with SIMON1WIN */
@@ -504,10 +514,10 @@ public:
uint _invoke_timer_callback;
- uint32 _voice_size;
+// uint32 _voice_size;
- uint32 _sound_size;
- byte *_sound_ptr;
+// uint32 _sound_size;
+// byte *_sound_ptr;
uint _vga_sprite_changed;
@@ -542,6 +552,8 @@ public:
byte _fcs_data_1[8];
bool _fcs_data_2[8];
+ SoundMixer _mixer[1];
+
ThreeValues _threevalues_1, _threevalues_2, _threevalues_3, _threevalues_4;
int _free_string_slot;
@@ -574,6 +586,9 @@ public:
int _num_screen_updates;
int _vga_tick_counter;
+ PlayingSoundHandle _playing_sound;
+ PlayingSoundHandle _voice_sound;
+
int _timer_id;
FILE *_dump_file;
@@ -994,7 +1009,8 @@ public:
void playVoice(uint voice);
void playSound(uint sound);
- void generateSound(byte *ptr, int len);
+
+// void generateSound(byte *ptr, int len);
void playMusic(uint music);
diff --git a/simon/simonsys.cpp b/simon/simonsys.cpp
index 047a672f71..7d6d54b6c5 100644
--- a/simon/simonsys.cpp
+++ b/simon/simonsys.cpp
@@ -23,6 +23,7 @@
#include "stdafx.h"
#include "scummsys.h"
#include "system.h"
+#include "mixer.h"
#include "simon.h"
#include <stdarg.h>