aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTravis Howell2004-08-31 07:52:47 +0000
committerTravis Howell2004-08-31 07:52:47 +0000
commit870eac39a22ed48ce0e57bf2e5391b3a128bf14e (patch)
tree5d1e276259b0c7fedff1dd37fffbbbea251b2880
parent3f1aee9ff4c71c069f5ba22dbd9effd013b5de34 (diff)
downloadscummvm-rg350-870eac39a22ed48ce0e57bf2e5391b3a128bf14e.tar.gz
scummvm-rg350-870eac39a22ed48ce0e57bf2e5391b3a128bf14e.tar.bz2
scummvm-rg350-870eac39a22ed48ce0e57bf2e5391b3a128bf14e.zip
Add eriktorbjorn's patch for separate target for Broken Sword 1 demo. Avoids sound regressions in full game.
svn-id: r14846
-rw-r--r--sword1/sound.cpp11
-rw-r--r--sword1/sound.h3
-rw-r--r--sword1/sword1.cpp42
-rw-r--r--sword1/sword1.h6
4 files changed, 43 insertions, 19 deletions
diff --git a/sword1/sound.cpp b/sword1/sound.cpp
index c5b76a6718..3c752f887e 100644
--- a/sword1/sound.cpp
+++ b/sword1/sound.cpp
@@ -31,7 +31,7 @@ namespace Sword1 {
#define SOUND_SPEECH_ID 1
#define SPEECH_FLAGS (SoundMixer::FLAG_16BITS | SoundMixer::FLAG_AUTOFREE | SoundMixer::FLAG_LITTLE_ENDIAN)
-Sound::Sound(const char *searchPath, SoundMixer *mixer, ResMan *pResMan) {
+Sound::Sound(const char *searchPath, SoundMixer *mixer, ResMan *pResMan, bool isDemo) {
strcpy(_filePath, searchPath);
_mixer = mixer;
_resMan = pResMan;
@@ -39,6 +39,7 @@ Sound::Sound(const char *searchPath, SoundMixer *mixer, ResMan *pResMan) {
_endOfQueue = 0;
_currentCowFile = 0;
_speechVolL = _speechVolR = _sfxVolL = _sfxVolR = 192;
+ _isDemo = isDemo;
}
int Sound::addToQueue(int32 fxNo) {
@@ -185,13 +186,13 @@ int16 *Sound::uncompressSpeech(uint32 index, uint32 cSize, uint32 *size) {
while ((READ_BE_UINT32(fBuf + headerPos) != 'data') && (headerPos < 100))
headerPos++;
if (headerPos < 100) {
- uint32 resSize = READ_LE_UINT32(fBuf + headerPos + 4) >> 1;
+ int32 resSize;
// Demo uses slightly different headers
- if (resSize > cSize) {
+ if (_isDemo) {
resSize = READ_LE_UINT32(fBuf + headerPos + 6) >> 1;
headerPos += 2;
- }
-
+ } else
+ resSize = READ_LE_UINT32(fBuf + headerPos + 4) >> 1;
int16 *srcData = (int16*)(fBuf + headerPos + 8);
int16 *dstData = (int16*)malloc(resSize * 2);
uint32 srcPos = 0;
diff --git a/sword1/sound.h b/sword1/sound.h
index dcb2543653..df0d17376c 100644
--- a/sword1/sound.h
+++ b/sword1/sound.h
@@ -60,7 +60,7 @@ class ResMan;
class Sound {
public:
- Sound(const char *searchPath, SoundMixer *mixer, ResMan *pResMan);
+ Sound(const char *searchPath, SoundMixer *mixer, ResMan *pResMan, bool isDemo);
~Sound(void);
void setSpeechVol(uint8 volL, uint8 volR) { _speechVolL = volL; _speechVolR = volR; };
void setSfxVol(uint8 volL, uint8 volR) { _sfxVolL = volL; _sfxVolR = volR; };
@@ -100,6 +100,7 @@ private:
uint8 _endOfQueue;
SoundMixer *_mixer;
ResMan *_resMan;
+ bool _isDemo;
char _filePath[100];
static const char _musicList[270];
static const uint16 _roomsFixedFx[TOTAL_ROOMS][TOTAL_FX_PER_ROOM];
diff --git a/sword1/sword1.cpp b/sword1/sword1.cpp
index f0eb203b3d..659c4177e8 100644
--- a/sword1/sword1.cpp
+++ b/sword1/sword1.cpp
@@ -47,29 +47,43 @@
using namespace Sword1;
/* Broken Sword 1 */
-static const GameSettings sword1_setting =
- {"sword1", "Broken Sword I", GF_DEFAULT_TO_1X_SCALER};
+static const GameSettings sword1_settings[] = {
+ {"sword1", "Broken Sword I", GF_DEFAULT_TO_1X_SCALER},
+ {"sword1demo", "Broken Sword I (Demo)", GF_DEFAULT_TO_1X_SCALER | Sword1::GF_DEMO },
+ { NULL, NULL, 0 }
+};
GameList Engine_SWORD1_gameList() {
+ const GameSettings *g = sword1_settings;
GameList games;
- games.push_back(sword1_setting);
+ while (g->name) {
+ games.push_back(*g);
+ g++;
+ }
return games;
}
DetectedGameList Engine_SWORD1_detectGames(const FSList &fslist) {
DetectedGameList detectedGames;
+ const GameSettings *g = sword1_settings;
- // Iterate over all files in the given directory
- for (FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) {
- const char *gameName = file->displayName().c_str();
+ // TODO: It would be nice if we had code here which distinguishes
+ // between the 'sword1' and 'sword1demo' targets.
- if ((0 == scumm_stricmp("swordres.rif", gameName)) ||
- (0 == scumm_stricmp("cd1.id", gameName)) ||
- (0 == scumm_stricmp("cd2.id", gameName))) {
- // Match found, add to list of candidates, then abort inner loop.
- detectedGames.push_back(sword1_setting);
- break;
+ while (g->name) {
+ // Iterate over all files in the given directory
+ for (FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) {
+ const char *gameName = file->displayName().c_str();
+
+ if ((0 == scumm_stricmp("swordres.rif", gameName)) ||
+ (0 == scumm_stricmp("cd1.id", gameName)) ||
+ (0 == scumm_stricmp("cd2.id", gameName))) {
+ // Match found, add to list of candidates, then abort inner loop.
+ detectedGames.push_back(*g);
+ break;
+ }
}
+ g++;
}
return detectedGames;
@@ -92,6 +106,8 @@ void SwordEngine::errorString(const char *buf1, char *buf2) {
SwordEngine::SwordEngine(GameDetector *detector, OSystem *syst)
: Engine(syst) {
+ _features = detector->_game.features;
+
if (!_mixer->isReady())
warning("Sound initialization failed");
}
@@ -122,7 +138,7 @@ void SwordEngine::initialize(void) {
_mouse = new Mouse(_system, _resMan, _objectMan);
_screen = new Screen(_system, _resMan, _objectMan);
_music = new Music(_system, _mixer);
- _sound = new Sound("", _mixer, _resMan);
+ _sound = new Sound("", _mixer, _resMan, (_features & GF_DEMO) != 0);
_menu = new Menu(_screen, _mouse);
_logic = new Logic(_objectMan, _resMan, _screen, _mouse, _sound, _music, _menu, _system, _mixer);
_mouse->useLogicAndMenu(_logic, _menu);
diff --git a/sword1/sword1.h b/sword1/sword1.h
index 29cab3bf9d..117b7526e6 100644
--- a/sword1/sword1.h
+++ b/sword1/sword1.h
@@ -29,6 +29,10 @@
namespace Sword1 {
+enum {
+ GF_DEMO = 1 << 0
+};
+
class Screen;
class Sound;
class Logic;
@@ -61,6 +65,8 @@ public:
virtual ~SwordEngine();
static SystemVars _systemVars;
void reinitialize(void);
+
+ uint32 _features;
protected:
void go();
private: