Ticket #8430: gob-beeper.diff
File gob-beeper.diff, 4.5 KB (added by , 19 years ago) |
---|
-
gob/goblin.cpp
diff -ur ScummVM-cvs20050505/gob/goblin.cpp ScummVM-cvs20050505+hack/gob/goblin.cpp
old new 1562 1562 if (gobDesc->state >= 0 && gobDesc->state < 10 && 1563 1563 gobDesc->stateMach == gobDesc->realStateMach && 1564 1564 (gobDesc->curFrame == 3 || gobDesc->curFrame == 6)) { 1565 snd_speakerOn(10 * util_getRandom(3) + 50); 1566 util_delay(5); 1567 snd_speakerOff(); 1565 snd_speakerOn(10 * util_getRandom(3) + 50, 5); 1568 1566 } 1569 1567 1570 1568 if (gob_currentGoblin == 0 -
gob/inter.cpp
diff -ur ScummVM-cvs20050505/gob/inter.cpp ScummVM-cvs20050505+hack/gob/inter.cpp
old new 1314 1314 break; 1315 1315 1316 1316 case 2: 1317 snd_speakerOn(parse_parseValExpr() );1317 snd_speakerOn(parse_parseValExpr(), -1); 1318 1318 break; 1319 1319 1320 1320 case 3: -
gob/sound.cpp
diff -ur ScummVM-cvs20050505/gob/sound.cpp ScummVM-cvs20050505+hack/gob/sound.cpp
old new 19 19 * $Header: /cvsroot/scummvm/scummvm/gob/sound.cpp,v 1.9 2005/05/01 10:15:30 eriktorbjorn Exp $ 20 20 * 21 21 */ 22 23 #include "sound/audiostream.h" 24 22 25 #include "gob/gob.h" 23 26 #include "gob/global.h" 24 27 #include "gob/sound.h" 28 25 29 namespace Gob { 26 30 31 // TODO: This is a very primitive square wave generator. The only thing is 32 // has in common with the PC speaker is that it sounds terrible. 33 34 class SquareWaveStream : public AudioStream { 35 private: 36 uint _rate; 37 bool _beepForever; 38 uint32 _periodLength; 39 uint32 _periodSamples; 40 uint32 _remainingSamples; 41 int16 _sampleValue; 42 43 public: 44 SquareWaveStream() {} 45 ~SquareWaveStream() {} 46 47 void playNote(int freq, int32 ms); 48 49 int readBuffer(int16 *buffer, const int numSamples); 50 51 bool endOfData() const { return _remainingSamples == 0; } 52 bool isStereo() const { return false; } 53 int getRate() const { return _rate; } 54 }; 55 56 void SquareWaveStream::playNote(int freq, int32 ms) { 57 _rate = _vm->_mixer->getOutputRate(); 58 _periodLength = _rate / (2 * freq); 59 _periodSamples = 0; 60 _sampleValue = 25000; 61 if (ms == -1) { 62 _remainingSamples = 1; 63 _beepForever = true; 64 } else { 65 _remainingSamples = (_rate * ms) / 1000; 66 _beepForever = false; 67 } 68 } 69 70 int SquareWaveStream::readBuffer(int16 *buffer, const int numSamples) { 71 int samples = 0; 72 73 while (samples < numSamples && _remainingSamples > 0) { 74 *buffer++ = _sampleValue; 75 if (_periodSamples++ > _periodLength) { 76 _periodSamples = 0; 77 _sampleValue = -_sampleValue; 78 } 79 samples++; 80 if (!_beepForever) 81 _remainingSamples--; 82 } 83 84 return samples; 85 } 86 87 SquareWaveStream speakerStream; 88 SoundHandle speakerHandle; 27 89 Snd_SoundDesc *snd_loopingSounds[5]; // Should be enough 28 90 29 91 void snd_initSound(void) { … … 48 110 int16 snd_checkAdlib(void) {return 0;} 49 111 int16 snd_checkBlaster(void) {return 0;} 50 112 void snd_setBlasterPort(int16 port) {return;} 51 void snd_speakerOn(int16 frequency) {return;} 52 void snd_speakerOff(void) {return;} 113 114 void snd_speakerOn(int16 frequency, int32 length) { 115 speakerStream.playNote(frequency, length); 116 if (!_vm->_mixer->isSoundHandleActive(speakerHandle)) { 117 _vm->_mixer->playInputStream(SoundMixer::kSFXSoundType, &speakerHandle, &speakerStream, -1, 255, 0, false); 118 } 119 } 120 121 void snd_speakerOff(void) { 122 _vm->_mixer->stopHandle(speakerHandle); 123 } 124 53 125 void snd_stopSound(int16 arg){return;} 54 126 void snd_setResetTimerFlag(char flag){return;} 55 127 -
gob/sound.h
diff -ur ScummVM-cvs20050505/gob/sound.h ScummVM-cvs20050505+hack/gob/sound.h
old new 30 30 int16 snd_checkAdlib(void); 31 31 int16 snd_checkBlaster(void); 32 32 void snd_setBlasterPort(int16 port); 33 void snd_speakerOn(int16 frequency );33 void snd_speakerOn(int16 frequency, int32 length); 34 34 void snd_speakerOff(void); 35 35 void snd_stopSound(int16 arg); 36 36 void snd_setResetTimerFlag(char flag); -
gob/util.cpp
diff -ur ScummVM-cvs20050505/gob/util.cpp ScummVM-cvs20050505+hack/gob/util.cpp
old new 192 192 if (soundFlags == 0) 193 193 return; 194 194 195 //sound(freq); 196 util_delay(50); 197 //nosound(); 195 snd_speakerOn(freq, 50); 198 196 } 199 197 200 198 uint32 util_getTimeKey(void) {