From 9cee28492d5c7d4beb0763aee138be570c5156c8 Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Tue, 26 Jun 2007 03:08:03 +0000 Subject: Add FLAC support for speech in Broken Sword 1. svn-id: r27721 --- engines/sword1/sound.cpp | 27 +++++++++++++++++++++++++-- engines/sword1/sound.h | 3 ++- 2 files changed, 27 insertions(+), 3 deletions(-) (limited to 'engines/sword1') diff --git a/engines/sword1/sound.cpp b/engines/sword1/sound.cpp index 4d8601a0d8..a266e5e1a8 100644 --- a/engines/sword1/sound.cpp +++ b/engines/sword1/sound.cpp @@ -197,8 +197,8 @@ bool Sound::startSpeech(uint16 roomNo, uint16 localNo) { if (data) _mixer->playRaw(Audio::Mixer::kSpeechSoundType, &_speechHandle, data, size, 11025, SPEECH_FLAGS, SOUND_SPEECH_ID, speechVol, speechPan); } -#ifdef USE_MAD - else if (_cowMode == CowMp3) { +#ifdef USE_FLAC + else if (_cowMode == CowFlac) { _cowFile.seek(index); _mixer->playInputStream(Audio::Mixer::kSpeechSoundType, &_speechHandle, Audio::makeMP3Stream(&_cowFile, sampleSize), SOUND_SPEECH_ID, speechVol, speechPan); // with compressed audio, we can't calculate the wave volume. @@ -212,6 +212,19 @@ bool Sound::startSpeech(uint16 roomNo, uint16 localNo) { else if (_cowMode == CowVorbis) { _cowFile.seek(index); _mixer->playInputStream(Audio::Mixer::kSpeechSoundType, &_speechHandle, Audio::makeVorbisStream(&_cowFile, sampleSize), SOUND_SPEECH_ID, speechVol, speechPan); + // with compressed audio, we can't calculate the wave volume. + // so default to talking. + for (int cnt = 0; cnt < 480; cnt++) + _waveVolume[cnt] = true; + _waveVolPos = 0; + } +#endif +#ifdef USE_MAD + else if (_cowMode == CowMp3) { + _cowFile.seek(index); + _mixer->playInputStream(Audio::Mixer::kSpeechSoundType, &_speechHandle, Audio::makeMP3Stream(&_cowFile, sampleSize), SOUND_SPEECH_ID, speechVol, speechPan); + // with compressed audio, we can't calculate the wave volume. + // so default to talking. for (int cnt = 0; cnt < 480; cnt++) _waveVolume[cnt] = true; _waveVolPos = 0; @@ -332,6 +345,16 @@ void Sound::initCowSystem(void) { /* look for speech1/2.clu in the data dir and speech/speech.clu (running from cd or using cd layout) */ +#ifdef USE_FLAC + if (!_cowFile.isOpen()) { + sprintf(cowName, "SPEECH%d.CLF", SwordEngine::_systemVars.currentCD); + _cowFile.open(cowName); + if (_cowFile.isOpen()) { + debug(1, "Using Vorbis compressed Speech Cluster"); + _cowMode = CowFlac; + } + } +#endif #ifdef USE_VORBIS if (!_cowFile.isOpen()) { sprintf(cowName, "SPEECH%d.CLV", SwordEngine::_systemVars.currentCD); diff --git a/engines/sword1/sound.h b/engines/sword1/sound.h index fb608a9631..fafc9c2d06 100644 --- a/engines/sword1/sound.h +++ b/engines/sword1/sound.h @@ -66,8 +66,9 @@ class ResMan; enum CowMode { CowWave = 0, - CowMp3, + CowFlac, CowVorbis, + CowMp3, CowDemo }; -- cgit v1.2.3 From 2e3ce7dc8eec143f1e94afbb122923e394f09f3b Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Tue, 26 Jun 2007 05:51:47 +0000 Subject: Fix FLAC support for speech in Broken Sword 1. svn-id: r27723 --- engines/sword1/sound.cpp | 5 +++-- engines/sword1/sword1.cpp | 20 ++++++++++++++------ 2 files changed, 17 insertions(+), 8 deletions(-) (limited to 'engines/sword1') diff --git a/engines/sword1/sound.cpp b/engines/sword1/sound.cpp index a266e5e1a8..492672fad8 100644 --- a/engines/sword1/sound.cpp +++ b/engines/sword1/sound.cpp @@ -33,6 +33,7 @@ #include "sword1/logic.h" #include "sword1/sword1.h" +#include "sound/flac.h" #include "sound/mp3.h" #include "sound/vorbis.h" #include "sound/wave.h" @@ -200,7 +201,7 @@ bool Sound::startSpeech(uint16 roomNo, uint16 localNo) { #ifdef USE_FLAC else if (_cowMode == CowFlac) { _cowFile.seek(index); - _mixer->playInputStream(Audio::Mixer::kSpeechSoundType, &_speechHandle, Audio::makeMP3Stream(&_cowFile, sampleSize), SOUND_SPEECH_ID, speechVol, speechPan); + _mixer->playInputStream(Audio::Mixer::kSpeechSoundType, &_speechHandle, Audio::makeFlacStream(&_cowFile, sampleSize), SOUND_SPEECH_ID, speechVol, speechPan); // with compressed audio, we can't calculate the wave volume. // so default to talking. for (int cnt = 0; cnt < 480; cnt++) @@ -350,7 +351,7 @@ void Sound::initCowSystem(void) { sprintf(cowName, "SPEECH%d.CLF", SwordEngine::_systemVars.currentCD); _cowFile.open(cowName); if (_cowFile.isOpen()) { - debug(1, "Using Vorbis compressed Speech Cluster"); + debug(1, "Using Flac compressed Speech Cluster"); _cowMode = CowFlac; } } diff --git a/engines/sword1/sword1.cpp b/engines/sword1/sword1.cpp index 3c8abd0953..5633a58f0f 100644 --- a/engines/sword1/sword1.cpp +++ b/engines/sword1/sword1.cpp @@ -355,14 +355,18 @@ const CdFile SwordEngine::_pcCdFileList[] = { { "cows.mad", FLAG_DEMO }, { "speech1.clu", FLAG_SPEECH1 }, { "speech2.clu", FLAG_SPEECH2 } -#ifdef USE_MAD - ,{ "speech1.cl3", FLAG_SPEECH1 }, - { "speech2.cl3", FLAG_SPEECH2 } +#ifdef USE_FLAC + ,{ "speech1.clf", FLAG_SPEECH1 }, + { "speech2.clf", FLAG_SPEECH2 } #endif #ifdef USE_VORBIS ,{ "speech1.clv", FLAG_SPEECH1 }, { "speech2.clv", FLAG_SPEECH2 } #endif +#ifdef USE_MAD + ,{ "speech1.cl3", FLAG_SPEECH1 }, + { "speech2.cl3", FLAG_SPEECH2 } +#endif }; const CdFile SwordEngine::_macCdFileList[] = { @@ -383,14 +387,18 @@ const CdFile SwordEngine::_macCdFileList[] = { { "text.clm", FLAG_CD1 | FLAG_DEMO }, { "speech1.clu", FLAG_SPEECH1 }, { "speech2.clu", FLAG_SPEECH2 } -#ifdef USE_MAD - ,{ "speech1.cl3", FLAG_SPEECH1 }, - { "speech2.cl3", FLAG_SPEECH2 } +#ifdef USE_FLAC + ,{ "speech1.clf", FLAG_SPEECH1 }, + { "speech2.clf", FLAG_SPEECH2 } #endif #ifdef USE_VORBIS ,{ "speech1.clv", FLAG_SPEECH1 }, { "speech2.clv", FLAG_SPEECH2 } #endif +#ifdef USE_MAD + ,{ "speech1.cl3", FLAG_SPEECH1 }, + { "speech2.cl3", FLAG_SPEECH2 } +#endif }; -- cgit v1.2.3 From e2ad271bd854369b437524cde60bfcb462225b82 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sun, 1 Jul 2007 12:47:07 +0000 Subject: Removing non-ASCII chars from source code svn-id: r27818 --- engines/sword1/control.cpp | 9 +-------- engines/sword1/staticres.cpp | 2 +- 2 files changed, 2 insertions(+), 9 deletions(-) (limited to 'engines/sword1') diff --git a/engines/sword1/control.cpp b/engines/sword1/control.cpp index 1ebfaedb2e..c5b968aabe 100644 --- a/engines/sword1/control.cpp +++ b/engines/sword1/control.cpp @@ -650,14 +650,7 @@ bool Control::getConfirm(const uint8 *title) { } bool Control::keyAccepted(uint16 ascii) { - // this routine needs changes for Czech keys... No idea how to do that, though. - // FIXME: It is not a good idea to put non-ASCII chars into a C source file, - // since there is no way to specify which encoding you are using. - // It is better to encode them as hex/octal. Although in this particular - // case, it seems questionable to do this at all, since we currently - // do not at all specify which encoding keyboard events use, so this - // check here is probably not portable anyway... - static const char allowedSpecials[] = "éèáàúùäöüÄÖÜß,.:-()?! \"\'"; + static const char allowedSpecials[] = ",.:-()?! \"\'"; if (((ascii >= 'A') && (ascii <= 'Z')) || ((ascii >= 'a') && (ascii <= 'z')) || ((ascii >= '0') && (ascii <= '9')) || diff --git a/engines/sword1/staticres.cpp b/engines/sword1/staticres.cpp index 366e2c7608..08e6a108c4 100644 --- a/engines/sword1/staticres.cpp +++ b/engines/sword1/staticres.cpp @@ -5158,7 +5158,7 @@ const FxDef Sound::_fxList[312] = { }, }, //------------------------ - // 198 Ambient sound for Montfauçon Square + // 198 Ambient sound for Montfaucon Square { FX_MONTAMB, // sampleId FX_LOOP, // type -- cgit v1.2.3 From e1bcd70436656ed48933aadca38636f70348c842 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sun, 1 Jul 2007 18:18:43 +0000 Subject: Re-added __attribute__(packed) svn-id: r27830 --- engines/sword1/mouse.h | 2 +- engines/sword1/object.h | 10 +++++----- engines/sword1/router.h | 4 ++-- engines/sword1/sworddefs.h | 10 +++++----- 4 files changed, 13 insertions(+), 13 deletions(-) (limited to 'engines/sword1') diff --git a/engines/sword1/mouse.h b/engines/sword1/mouse.h index 92b26c3573..f2c800d63b 100644 --- a/engines/sword1/mouse.h +++ b/engines/sword1/mouse.h @@ -60,7 +60,7 @@ struct MousePtr { uint16 hotSpotX; uint16 hotSpotY; uint8 dummyData[0x30]; -}; +} PACKED_STRUCT; #include "common/pack-end.h" // END STRUCT PACKING diff --git a/engines/sword1/object.h b/engines/sword1/object.h index ba65002918..87cbce7b84 100644 --- a/engines/sword1/object.h +++ b/engines/sword1/object.h @@ -40,7 +40,7 @@ namespace Sword1 { struct OEventSlot { //receiving event list in the compact - int32 o_event; //array of these with O_TOTAL_EVENTS elements int32 o_event_script; -}; // size = 2*int32 = 8 bytes +} PACKED_STRUCT; // size = 2*int32 = 8 bytes #define TOTAL_script_levels 5 @@ -48,12 +48,12 @@ struct ScriptTree { //this is a logic tree, used by OBJECTs int32 o_script_level; //logic level int32 o_script_id[TOTAL_script_levels]; //script id's (are unique to each level) int32 o_script_pc[TOTAL_script_levels]; //pc of script for each (if script_manager) -}; // size = 11*int32 = 44 bytes +} PACKED_STRUCT; // size = 11*int32 = 44 bytes struct TalkOffset { int32 x; int32 y; -}; // size = 2*int32 = 8 bytes +} PACKED_STRUCT; // size = 2*int32 = 8 bytes struct WalkData { int32 frame; @@ -61,7 +61,7 @@ struct WalkData { int32 y; int32 step; int32 dir; -}; // size = 5*int32 = 20 bytes +} PACKED_STRUCT; // size = 5*int32 = 20 bytes struct Object { int32 o_type; // 0 broad description of type - object, floor, etc. @@ -119,7 +119,7 @@ struct Object { WalkData o_route[O_WALKANIM_SIZE]; // 340 size = 600*20 bytes = 12000 // mega size = 12340 bytes (+ 8 byte offset table + 20 byte header = 12368) -}; +} PACKED_STRUCT; #include "common/pack-end.h" // END STRUCT PACKING diff --git a/engines/sword1/router.h b/engines/sword1/router.h index 67be8d0593..60456cc5c8 100644 --- a/engines/sword1/router.h +++ b/engines/sword1/router.h @@ -44,7 +44,7 @@ struct BarData { int16 dx; // x2 - x1 int16 dy; // y2 - y1 int32 co; // co = (y1*dx) - (x1*dy) from an equation for a line y*dx = x*dy + co -}; +} PACKED_STRUCT; struct NodeData { int16 x; @@ -52,7 +52,7 @@ struct NodeData { int16 level; int16 prev; int16 dist; -}; +} PACKED_STRUCT; #include "common/pack-end.h" // END STRUCT PACKING diff --git a/engines/sword1/sworddefs.h b/engines/sword1/sworddefs.h index aedc38ef7e..e90eafe825 100644 --- a/engines/sword1/sworddefs.h +++ b/engines/sword1/sworddefs.h @@ -100,7 +100,7 @@ struct Header { uint32 comp_length; char compression[4]; uint32 decomp_length; -}; +} PACKED_STRUCT; struct FrameHeader { uint8 runTimeComp[4]; @@ -115,25 +115,25 @@ struct ParallaxHeader { char type[16]; uint16 sizeX; uint16 sizeY; -}; +} PACKED_STRUCT; struct AnimUnit { uint32 animX; uint32 animY; uint32 animFrame; -}; +} PACKED_STRUCT; struct AnimSet { uint32 cdt; uint32 spr; -}; +} PACKED_STRUCT; struct WalkGridHeader { int32 scaleA; int32 scaleB; int32 numBars; int32 numNodes; -}; +} PACKED_STRUCT; #include "common/pack-end.h" // END STRUCT PACKING -- cgit v1.2.3