diff options
Diffstat (limited to 'engines/sludge/sound_bass.cpp')
-rw-r--r-- | engines/sludge/sound_bass.cpp | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/engines/sludge/sound_bass.cpp b/engines/sludge/sound_bass.cpp index 017796cb4d..6f16d66bb3 100644 --- a/engines/sludge/sound_bass.cpp +++ b/engines/sludge/sound_bass.cpp @@ -49,10 +49,10 @@ soundThing soundCache[MAX_SAMPLES]; int defVol = 128; int defSoundVol = 255; -char *loadEntireFileToMemory(FILE *inputFile, uint32_t size) { +char *loadEntireFileToMemory(Common::SeekableReadStream *inputFile, uint32_t size) { char *allData = new char[size]; - if (! allData) return NULL; - fread(allData, size, 1, inputFile); + if (!allData) return NULL; + inputFile->read(allData, size); finishAccess(); return allData; @@ -136,17 +136,17 @@ bool playMOD(int f, int a, int fromTrack) { char *memImage; memImage = loadEntireFileToMemory(bigDataFile, length); - if (! memImage) return fatal(ERROR_MUSIC_MEMORY_LOW); + if (!memImage) return fatal(ERROR_MUSIC_MEMORY_LOW); mod[a] = BASS_MusicLoad(true, memImage, 0, length, BASS_MUSIC_LOOP | BASS_MUSIC_RAMP/*|BASS_MUSIC_PRESCAN needed too if we're going to set the position in bytes*/, 0); delete memImage; - if (! mod[a]) { + if (!mod[a]) { } else { setMusicVolume(a, defVol); - if (! BASS_ChannelPlay(mod[a], true)) + if (!BASS_ChannelPlay(mod[a], true)) debugOut("playMOD: Error %d!\n", BASS_ErrorGetCode()); BASS_ChannelSetPosition(mod[a], MAKELONG(fromTrack, 0), BASS_POS_MUSIC_ORDER); @@ -161,7 +161,7 @@ void setMusicVolume(int a, int v) { int ret; if (soundOK && mod[a]) { ret = BASS_ChannelSetAttribute(mod[a], BASS_ATTRIB_VOL, (float) v / 256); - if (! ret) { + if (!ret) { debugOut("setMusicVolume: Error %d\n", BASS_ErrorGetCode()); } } @@ -215,19 +215,19 @@ int findEmptySoundSlot() { for (t = 0; t < MAX_SAMPLES; t ++) { emptySoundSlot ++; emptySoundSlot %= MAX_SAMPLES; - if (! soundCache[emptySoundSlot].sample) + if (!soundCache[emptySoundSlot].sample) return emptySoundSlot; } - // Argh! They're all playing! Let's trash the oldest that's not looping... + // Argh!They're all playing!Let's trash the oldest that's not looping... for (t = 0; t < MAX_SAMPLES; t ++) { emptySoundSlot ++; emptySoundSlot %= MAX_SAMPLES; - if (! soundCache[emptySoundSlot].looping) return emptySoundSlot; + if (!soundCache[emptySoundSlot].looping) return emptySoundSlot; } - // Holy crap, they're all looping! What's this twat playing at? + // Holy crap, they're all looping!What's this twat playing at? emptySoundSlot ++; emptySoundSlot %= MAX_SAMPLES; @@ -246,7 +246,7 @@ void soundWarning (char * t, int i) { bool forceRemoveSound() { for (int a = 0; a < 8; a ++) { - if (soundCache[a].fileLoaded != -1 && ! stillPlayingSound(a)) { + if (soundCache[a].fileLoaded != -1 && !stillPlayingSound(a)) { // soundWarning ("Deleting silent sound", a); freeSound(a); return 1; @@ -267,7 +267,7 @@ bool forceRemoveSound() { int cacheSound(int f) { setResourceForFatal(f); - if (! soundOK) return 0; + if (!soundOK) return 0; int a = findInSoundCache(f); if (a != -1) return a; @@ -276,7 +276,7 @@ int cacheSound(int f) { freeSound(a); uint32_t length = openFileFromNum(f); - if (! length) return -1; + if (!length) return -1; char *memImage; @@ -286,7 +286,7 @@ int cacheSound(int f) { memImage = loadEntireFileToMemory(bigDataFile, length); tryAgain = memImage == NULL; if (tryAgain) { - if (! forceRemoveSound()) { + if (!forceRemoveSound()) { fatal(ERROR_SOUND_MEMORY_LOW); return -1; } @@ -347,32 +347,32 @@ void debugSounds () { } // */ -void saveSounds(FILE *fp) { +void saveSounds(Common::WriteStream *stream) { if (soundOK) { for (int i = 0; i < MAX_SAMPLES; i ++) { if (soundCache[i].looping) { - fputc(1, fp); - put2bytes(soundCache[i].fileLoaded, fp); - put2bytes(soundCache[i].vol, fp); + putch(1, stream); + put2bytes(soundCache[i].fileLoaded, stream); + put2bytes(soundCache[i].vol, stream); } } } - fputc(0, fp); - put2bytes(defSoundVol, fp); - put2bytes(defVol, fp); + putch(0, stream); + put2bytes(defSoundVol, stream); + put2bytes(defVol, stream); } -void loadSounds(FILE *fp) { +void loadSounds(Common::SeekableReadStream *stream) { for (int i = 0; i < MAX_SAMPLES; i ++) freeSound(i); - while (fgetc(fp)) { - int fileLoaded = get2bytes(fp); - defSoundVol = get2bytes(fp); + while (getch(stream)) { + int fileLoaded = get2bytes(stream); + defSoundVol = get2bytes(stream); startSound(fileLoaded, 1); } - defSoundVol = get2bytes(fp); - defVol = get2bytes(fp); + defSoundVol = get2bytes(stream); + defVol = get2bytes(stream); } bool getSoundCacheStack(stackHandler *sH) { @@ -382,7 +382,7 @@ bool getSoundCacheStack(stackHandler *sH) { for (int a = 0; a < MAX_SAMPLES; a ++) { if (soundCache[a].fileLoaded != -1) { setVariable(newFileHandle, SVT_FILE, soundCache[a].fileLoaded); - if (! addVarToStackQuick(newFileHandle, sH -> first)) return false; + if (!addVarToStackQuick(newFileHandle, sH -> first)) return false; if (sH -> last == NULL) sH -> last = sH -> first; } } |