aboutsummaryrefslogtreecommitdiff
path: root/saga
diff options
context:
space:
mode:
authorTorbjörn Andersson2004-10-01 06:45:13 +0000
committerTorbjörn Andersson2004-10-01 06:45:13 +0000
commit54cec2e011b56d875022ec6a6c05654b08300876 (patch)
treebbd54527e158f9e9cd6cca8c47b040d0a49c280d /saga
parent2f8136b703a5738e8a7f715b2cb3c4c4dd013473 (diff)
downloadscummvm-rg350-54cec2e011b56d875022ec6a6c05654b08300876.tar.gz
scummvm-rg350-54cec2e011b56d875022ec6a6c05654b08300876.tar.bz2
scummvm-rg350-54cec2e011b56d875022ec6a6c05654b08300876.zip
Set up file paths to handle the differences between the file layout of the
Windows and Linux versions. (TODO: Handle game detection.) Added preliminary support for the P2_A.aif file that the Linux version uses, where the Windows version uses p2_a.voc. Someone will have to verify the actual format of it, and we have a silly bug in playVoice() which will have to be fixed before things work properly. svn-id: r15365
Diffstat (limited to 'saga')
-rw-r--r--saga/game.cpp34
-rw-r--r--saga/game.h5
-rw-r--r--saga/game_mod.h1
-rw-r--r--saga/music.cpp56
-rw-r--r--saga/saga.cpp10
-rw-r--r--saga/sndres.cpp52
-rw-r--r--saga/sound.cpp5
-rw-r--r--saga/sound.h2
8 files changed, 91 insertions, 74 deletions
diff --git a/saga/game.cpp b/saga/game.cpp
index dff6a692ca..f680f172f7 100644
--- a/saga/game.cpp
+++ b/saga/game.cpp
@@ -268,27 +268,11 @@ R_GAMEDESC GameDescs[] = {
static R_GAMEMODULE GameModule;
-void GAME_setGameDirectory(const char *gamedir) {
- assert(gamedir != NULL);
-
- debug(0, "Using game data path: %s", gamedir);
-
- strcpy(GameModule.game_dir, gamedir);
-}
-
int GAME_Register() {
return R_SUCCESS;
- // Register "gamedir" cfg cvar
- strncpy(GameModule.game_dir, "./", R_MAXPATH);
-
- if (CVAR_Register_S(GameModule.game_dir,
- "gamedir", NULL, R_CVAR_CFG, R_MAXPATH) != R_SUCCESS) {
- return R_FAILURE;
- }
-
// Register "g_language" cfg cvar
- strncpy(GameModule.game_dir, "us", R_MAXPATH);
+ strncpy(GameModule.game_language, "us", R_MAXPATH);
if (CVAR_Register_S(GameModule.game_language, "g_language",
NULL, R_CVAR_CFG, R_GAME_LANGSTR_LIMIT) != R_SUCCESS) {
@@ -305,16 +289,13 @@ int GAME_Register() {
int GAME_Init() {
uint16 game_n;
- char *game_dir;
-
- game_dir = GameModule.game_dir;
- if (DetectGame(game_dir, &game_n) != R_SUCCESS) {
+ if (DetectGame(&game_n) != R_SUCCESS) {
warning("No valid games were found in the specified directory.");
return R_FAILURE;
}
- if (LoadGame(game_dir, game_n) != R_SUCCESS) {
+ if (LoadGame(game_n) != R_SUCCESS) {
warning("Error loading game resource files.");
return R_FAILURE;
}
@@ -432,7 +413,7 @@ DetectedGameList GAME_ProbeGame(const FSList &fslist) {
return detectedGames;
}
-int DetectGame(const char *game_dir, uint16 *game_n_p) {
+int DetectGame(uint16 *game_n_p) {
uint16 game_count = ARRAYSIZE(GameDescs);
uint16 game_n;
@@ -442,7 +423,7 @@ int DetectGame(const char *game_dir, uint16 *game_n_p) {
int file_missing = 0;
- if ((game_dir == NULL) || (game_n_p == NULL)) {
+ if (game_n_p == NULL) {
return R_FAILURE;
}
@@ -473,14 +454,14 @@ int DetectGame(const char *game_dir, uint16 *game_n_p) {
return R_FAILURE;
}
-int LoadGame(const char *game_dir, uint16 game_n) {
+int LoadGame(uint16 game_n) {
R_RSCFILE_CONTEXT *load_ctxt;
uint16 game_count = ARRAYSIZE(GameDescs);
const char *game_fname;
uint16 game_filect;
uint16 i;
- if ((game_dir == NULL) || (game_n >= game_count)) {
+ if (game_n >= game_count) {
return R_FAILURE;
}
@@ -491,7 +472,6 @@ int LoadGame(const char *game_dir, uint16 game_n) {
return R_MEM;
}
- File::addDefaultDirectory(game_dir);
GameModule.gfile_n = game_filect;
// Load game resource files
diff --git a/saga/game.h b/saga/game.h
index 0e7e585566..19b55e5885 100644
--- a/saga/game.h
+++ b/saga/game.h
@@ -79,7 +79,6 @@ struct R_GAMEMODULE {
int game_number;
R_GAMEDESC *gamedesc;
int g_skipintro;
- char game_dir[R_MAXPATH];
char game_language[R_GAME_LANGSTR_LIMIT];
uint16 gfile_n;
R_GAME_FILEDATA *gfile_data;
@@ -90,8 +89,8 @@ struct R_GAMEMODULE {
};
int LoadLanguage();
-int LoadGame(const char *game_dir, uint16 game_n_p);
-int DetectGame(const char *game_dir, uint16 *game_n_p);
+int LoadGame(uint16 game_n_p);
+int DetectGame(uint16 *game_n_p);
} // End of namespace Saga
diff --git a/saga/game_mod.h b/saga/game_mod.h
index c229627aca..d427cc9f4f 100644
--- a/saga/game_mod.h
+++ b/saga/game_mod.h
@@ -104,7 +104,6 @@ int GAME_GetDisplayInfo(R_GAME_DISPLAYINFO *);
int GAME_GetSceneInfo(R_GAME_SCENEDESC *);
int GAME_GetGame();
int GAME_GetGameType();
-void GAME_setGameDirectory(const char *gamedir);
GameList GAME_GameList();
DetectedGameList GAME_ProbeGame(const FSList &fslist);
diff --git a/saga/music.cpp b/saga/music.cpp
index a1b87c4dab..c57bfd77d0 100644
--- a/saga/music.cpp
+++ b/saga/music.cpp
@@ -165,32 +165,32 @@ Music::~Music() {
// reset.mid seems to be unused.
const MUSIC_MIDITABLE Music::_midiTableITECD[26] = {
- {"cave", R_MUSIC_LOOP}, // 9
- {"intro", R_MUSIC_LOOP}, // 10
- {"fvillage", R_MUSIC_LOOP}, // 11
- {"elkhall", R_MUSIC_LOOP}, // 12
- {"mouse", 0}, // 13
- {"darkclaw", R_MUSIC_LOOP}, // 14
- {"birdchrp", R_MUSIC_LOOP}, // 15
- {"orbtempl", R_MUSIC_LOOP}, // 16
- {"spooky", R_MUSIC_LOOP}, // 17
- {"catfest", R_MUSIC_LOOP}, // 18
- {"elkfanfare", 0}, // 19
- {"bcexpl", R_MUSIC_LOOP}, // 20
- {"boargtnt", R_MUSIC_LOOP}, // 21
- {"boarking", R_MUSIC_LOOP}, // 22
- {"explorea", R_MUSIC_LOOP}, // 23
- {"exploreb", R_MUSIC_LOOP}, // 24
- {"explorec", R_MUSIC_LOOP}, // 25
- {"sunstatm", R_MUSIC_LOOP}, // 26
- {"nitstrlm", R_MUSIC_LOOP}, // 27
- {"humruinm", R_MUSIC_LOOP}, // 28
- {"damexplm", R_MUSIC_LOOP}, // 29
- {"tychom", R_MUSIC_LOOP}, // 30
- {"kitten", R_MUSIC_LOOP}, // 31
- {"sweet", R_MUSIC_LOOP}, // 32
- {"brutalmt", R_MUSIC_LOOP}, // 33
- {"shiala", R_MUSIC_LOOP} // 34
+ {"cave.mid", R_MUSIC_LOOP}, // 9
+ {"intro.mid", R_MUSIC_LOOP}, // 10
+ {"fvillage.mid", R_MUSIC_LOOP}, // 11
+ {"elkhall.mid", R_MUSIC_LOOP}, // 12
+ {"mouse.mid", 0}, // 13
+ {"darkclaw.mid", R_MUSIC_LOOP}, // 14
+ {"birdchrp.mid", R_MUSIC_LOOP}, // 15
+ {"orbtempl.mid", R_MUSIC_LOOP}, // 16
+ {"spooky.mid", R_MUSIC_LOOP}, // 17
+ {"catfest.mid", R_MUSIC_LOOP}, // 18
+ {"elkfanfare.mid", 0}, // 19
+ {"bcexpl.mid", R_MUSIC_LOOP}, // 20
+ {"boargtnt.mid", R_MUSIC_LOOP}, // 21
+ {"boarking.mid", R_MUSIC_LOOP}, // 22
+ {"explorea.mid", R_MUSIC_LOOP}, // 23
+ {"exploreb.mid", R_MUSIC_LOOP}, // 24
+ {"explorec.mid", R_MUSIC_LOOP}, // 25
+ {"sunstatm.mid", R_MUSIC_LOOP}, // 26
+ {"nitstrlm.mid", R_MUSIC_LOOP}, // 27
+ {"humruinm.mid", R_MUSIC_LOOP}, // 28
+ {"damexplm.mid", R_MUSIC_LOOP}, // 29
+ {"tychom.mid", R_MUSIC_LOOP}, // 30
+ {"kitten.mid", R_MUSIC_LOOP}, // 31
+ {"sweet.mid", R_MUSIC_LOOP}, // 32
+ {"brutalmt.mid", R_MUSIC_LOOP}, // 33
+ {"shiala.mid", R_MUSIC_LOOP} // 34
};
int Music::play(uint32 music_rn, uint16 flags) {
@@ -212,9 +212,7 @@ int Music::play(uint32 music_rn, uint16 flags) {
if (GAME_GetGameType() == GID_ITE) {
if (music_rn >= 9 && music_rn <= 34) {
- char file_name[20];
- sprintf(file_name, "music/%s.mid", _midiTableITECD[music_rn - 9].filename);
- f_midi.open(file_name);
+ f_midi.open(_midiTableITECD[music_rn - 9].filename);
}
}
diff --git a/saga/saga.cpp b/saga/saga.cpp
index b1868abb4a..50f38437c2 100644
--- a/saga/saga.cpp
+++ b/saga/saga.cpp
@@ -83,7 +83,15 @@ SagaEngine *_vm = NULL;
SagaEngine::SagaEngine(GameDetector *detector, OSystem *syst)
: Engine(syst) {
- GAME_setGameDirectory(getGameDataPath());
+ // The Linux version of Inherit the Earth puts all data files in an
+ // 'itedata' sub-directory, except for voices.rsc
+ File::addDefaultDirectory(_gameDataPath + "/itedata/");
+
+ // The Windows version of Inherit the Earth puts various data files in
+ // other subdirectories.
+ File::addDefaultDirectory(_gameDataPath + "/graphics/");
+ File::addDefaultDirectory(_gameDataPath + "/music/");
+ File::addDefaultDirectory(_gameDataPath + "/sound/");
// Setup mixer
if (!_mixer->isReady()) {
diff --git a/saga/sndres.cpp b/saga/sndres.cpp
index 4efe99d95c..d918f7e133 100644
--- a/saga/sndres.cpp
+++ b/saga/sndres.cpp
@@ -61,22 +61,50 @@ int SndRes::playVoice(uint32 voice_rn) {
debug(0, "SndRes::playVoice(%ld)", voice_rn);
- // The Wyrmkeep release of Inherit the Earth provides a separate VOC
- // file, sound/p2_a.voc, to correct voice 4 in the intro. Use that, if
- // available.
- //
- // FIXME: There's a nasty 'pop' at the beginning of the sound, and a
- // smaller one at the end. I don't know if that's in the file, or in
- // our playback code.
-
- File f;
+ if (GAME_GetGameType() == GID_ITE && voice_rn == 4) {
+ // The Windows version of the Wyrmkeep release of Inherit the
+ // Earth provides a separate VOC file, sound/p2_a.voc, to
+ // correct voice 4 in the intro. In the Linux version, it's
+ // called P2_A.iaf and appears to be plain raw data.
+ //
+ // In either case, use the file if available.
+ //
+ // FIXME: In the VOC case there's a nasty 'pop' at the
+ // beginning of the sound, , and a smaller one at the end. In
+ // the IAF case, the next voice will overlap. At least part of
+ // this is because of an obvious bug in playVoice(). See the
+ // FIXME comment there.
+
+ File f;
+ uint32 size;
+ bool voc = false;
+
+ if (f.open("p2_a.voc"))
+ voc = true;
+ else
+ f.open("P2_A.iaf");
+
+ if (!f.isOpen())
+ return R_FAILURE;
- if (GAME_GetGameType() == GID_ITE && voice_rn == 4 && f.open("sound/p2_a.voc")) {
- uint32 size = f.size();
+ size = f.size();
byte *snd_res = (byte *)malloc(size);
f.read(snd_res, size);
- result = loadVocSound(snd_res, size, &snd_buffer);
f.close();
+
+ if (!voc) {
+ // FIXME: Verify this!
+ snd_buffer.s_stereo = 0;
+ snd_buffer.s_samplebits = 16;
+ snd_buffer.s_freq = 22050;
+ snd_buffer.res_data = snd_res;
+ snd_buffer.res_len = size;
+ snd_buffer.s_buf = snd_res + 16760;
+ snd_buffer.s_buf_len = size - 16760;
+ snd_buffer.s_signed = 1;
+ result = R_SUCCESS;
+ } else
+ result = loadVocSound(snd_res, size, &snd_buffer);
} else
result = load(_voice_ctxt, voice_rn, &snd_buffer);
diff --git a/saga/sound.cpp b/saga/sound.cpp
index 8fb38b1f19..979addd861 100644
--- a/saga/sound.cpp
+++ b/saga/sound.cpp
@@ -130,6 +130,11 @@ int Sound::playVoice(R_SOUNDBUFFER *buf) {
}
#endif
+ // FIXME: No, no, NO! We should use buf->s_buf and buf->s_buf_len, not
+ // buf->res_data and buf->res_len. Right now, we're playing the
+ // resource header as if it was a sound! But we can't just
+ // change it without also removing FLAG_AUTOFREE...
+
_mixer->playRaw(&_voiceHandle, buf->res_data, buf->res_len, buf->s_freq, flags);
return R_SUCCESS;
diff --git a/saga/sound.h b/saga/sound.h
index 819f82a152..217237f8d7 100644
--- a/saga/sound.h
+++ b/saga/sound.h
@@ -41,7 +41,7 @@ struct R_SOUNDBUFFER {
int s_stereo;
int s_signed;
- const byte *s_buf;
+ byte *s_buf;
size_t s_buf_len;
};