[Scummvm-cvs-logs] CVS: scummvm/simon items.cpp,1.42,1.43 midi.cpp,1.20,1.21 midi.h,1.7,1.8 simon.cpp,1.130,1.131 simon.h,1.40,1.41 vga.cpp,1.29,1.30

Travis Howell kirben at users.sourceforge.net
Fri Jan 3 04:08:51 CET 2003


Update of /cvsroot/scummvm/scummvm/simon
In directory sc8-pr-cvs1:/tmp/cvs-serv706/simon

Modified Files:
	items.cpp midi.cpp midi.h simon.cpp simon.h vga.cpp 
Log Message:

Add olki's patch for sound effects in simon1dos
Plus hack to allow choice between midi music and sound effects via 's' key


Index: items.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/simon/items.cpp,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -d -r1.42 -r1.43
--- items.cpp	22 Dec 2002 08:08:53 -0000	1.42
+++ items.cpp	3 Jan 2003 12:06:30 -0000	1.43
@@ -1045,7 +1045,7 @@
 		case 185:{
 				if (_game & GAME_SIMON2)
 					goto invalid_opcode;
-				getVarOrWord();
+				_midi_sfx = getVarOrWord();
 			}
 			break;
 
@@ -1527,7 +1527,10 @@
 
 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)

Index: midi.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/simon/midi.cpp,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- midi.cpp	3 Jan 2003 04:24:16 -0000	1.20
+++ midi.cpp	3 Jan 2003 12:06:30 -0000	1.21
@@ -61,7 +61,16 @@
 	}
 }
 
-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 @@
 						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_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 @@
 
 	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 @@
 
 void MidiPlayer::reset_tracks()
 {
+	if (_midi_sfx_toggle)
+		return;
+
 	Track *t;
 	uint i;
 

Index: midi.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/simon/midi.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- midi.h	11 Dec 2002 16:09:56 -0000	1.7
+++ midi.h	3 Jan 2003 12:06:30 -0000	1.8
@@ -31,7 +31,9 @@
 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 @@
 	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);

Index: simon.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/simon/simon.cpp,v
retrieving revision 1.130
retrieving revision 1.131
diff -u -d -r1.130 -r1.131
--- simon.cpp	3 Jan 2003 10:36:13 -0000	1.130
+++ simon.cpp	3 Jan 2003 12:06:30 -0000	1.131
@@ -806,7 +806,7 @@
 				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 @@
 		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 @@
 			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 @@
 	} else {
 		_vk_t_toggle = true;
 	}
+
+	midi._midi_sfx_toggle = false;
 	
 	while (1) {
 		hitarea_stuff();
@@ -4810,6 +4858,9 @@
 
 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();

Index: simon.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/simon/simon.h,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -d -r1.40 -r1.41
--- simon.h	22 Dec 2002 08:08:53 -0000	1.40
+++ simon.h	3 Jan 2003 12:06:30 -0000	1.41
@@ -100,6 +100,12 @@
 
 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 @@
 	bool _skip_speech;
 	byte _video_var_9;
 
+	uint _midi_sfx;
 	uint _last_music_played;
 
 	bool _show_preposition;

Index: vga.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/simon/vga.cpp,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- vga.cpp	22 Dec 2002 09:26:42 -0000	1.29
+++ vga.cpp	3 Jan 2003 12:06:30 -0000	1.30
@@ -1594,7 +1594,9 @@
 {
 	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) {





More information about the Scummvm-git-logs mailing list