Ticket #296: simonfix

File simonfix, 2.5 KB (added by SF/olki, 22 years ago)
Line 
1--- simon.cpp.orig Wed Jun 5 21:04:36 2002
2+++ simon.cpp Wed Jun 5 21:04:15 2002
3@@ -8247,14 +8247,20 @@
4 /* only read voice file in windows game */
5 if (_game & GAME_WIN) {
6 const char *s = gss->wav_filename;
7+ const char *s2 = gss->wav_filename2;
8 const char *e = gss->effects_filename;
9
10 _voice_offsets = NULL;
11
12 _voice_file = fopen_maybe_lowercase(s);
13 if (_voice_file == NULL) {
14- warning("Cannot open %s",s);
15- return;
16+ warning("Cannot open %s, trying %s",s,s2);
17+
18+ _voice_file = fopen_maybe_lowercase(s2);
19+ if (_voice_file == NULL) {
20+ warning("Cannot open %s",s2);
21+ return;
22+ }
23 }
24
25 _voice_offsets = (uint32*)malloc(gss->NUM_VOICE_RESOURCES * sizeof(uint32));
26@@ -8328,13 +8334,13 @@
27
28
29 void SimonState::playVoice(uint voice) {
30- WaveHeader wave_hdr;
31- uint32 data[2];
32+ _mixer->stop(_voice_sound);
33
34- if (!_effects_offsets) { /* WAVE audio */
35- _mixer->stop(_voice_sound);
36+ fseek(_voice_file, _voice_offsets[voice], SEEK_SET);
37
38- fseek(_voice_file, _voice_offsets[voice], SEEK_SET);
39+ if (!_effects_offsets) { /* WAVE audio */
40+ WaveHeader wave_hdr;
41+ uint32 data[2];
42
43 if (fread(&wave_hdr, sizeof(wave_hdr), 1, _voice_file)!=1 ||
44 wave_hdr.riff!=MKID('RIFF') || wave_hdr.wave!=MKID('WAVE') || wave_hdr.fmt!=MKID('fmt ') ||
45@@ -8373,8 +8379,11 @@
46
47 uint32 samples_per_sec = 1000000L/(256L-(long)voc_block_hdr.tc);
48
49- _mixer->play_raw(&_voice_sound, _voice_file, size, samples_per_sec,
50- SoundMixer::FLAG_FILE|SoundMixer::FLAG_UNSIGNED);
51+ byte *buffer = (byte*)malloc(size);
52+ fread(buffer, size, 1, _voice_file);
53+
54+ _mixer->play_raw(&_voice_sound, buffer, size, samples_per_sec,
55+ SoundMixer::FLAG_UNSIGNED);
56 }
57 }
58
59@@ -8400,11 +8409,15 @@
60 size = size & 0xffffff;
61 fseek(_effects_file, -1, SEEK_CUR);
62 fread(&voc_block_hdr, sizeof(voc_block_hdr), 1, _effects_file);
63-
64+
65 uint32 samples_per_sec = 1000000L/(256L-(long)voc_block_hdr.tc);
66
67- _mixer->play_raw(&_effects_sound, _effects_file, size, samples_per_sec,
68- SoundMixer::FLAG_FILE|SoundMixer::FLAG_UNSIGNED);
69+ byte *buffer = (byte*)malloc(size);
70+ fread(buffer, size, 1, _effects_file);
71+
72+ _mixer->play_raw(&_effects_sound, buffer, size, samples_per_sec,
73+ SoundMixer::FLAG_UNSIGNED);
74+
75 } else {
76 byte *p;
77
78@@ -8444,7 +8457,7 @@
79
80 /* FIXME: not properly implemented */
81 if (_game & GAME_WIN) {
82- fseek(_game_file, _game_offsets_ptr[gss->MUSIC_INDEX_BASE + music],SEEK_SET);
83+ fseek(_game_file, _game_offsets_ptr[gss->MUSIC_INDEX_BASE + music] - 1,SEEK_SET);
84 f = _game_file;
85
86 midi.read_all_songs(f);