aboutsummaryrefslogtreecommitdiff
path: root/saga
diff options
context:
space:
mode:
authorAndrew Kurushin2005-01-09 23:41:22 +0000
committerAndrew Kurushin2005-01-09 23:41:22 +0000
commit31ceb0bb71d2f6446a54aa4d9c7896472e1534de (patch)
tree9b1d54261fdf3eda4552b7e14ae5efdd44c92e77 /saga
parent7a8e1c1efd72bd5bb9aa3db8f6cbb4ca39ca8c0f (diff)
downloadscummvm-rg350-31ceb0bb71d2f6446a54aa4d9c7896472e1534de.tar.gz
scummvm-rg350-31ceb0bb71d2f6446a54aa4d9c7896472e1534de.tar.bz2
scummvm-rg350-31ceb0bb71d2f6446a54aa4d9c7896472e1534de.zip
- GameModule is gone
- structures renamed - SagaEngine class gives all current game descriptions regression : "verb" is broken cause work in progress svn-id: r16511
Diffstat (limited to 'saga')
-rw-r--r--saga/animation.cpp15
-rw-r--r--saga/font.cpp8
-rw-r--r--saga/game.cpp204
-rw-r--r--saga/game.h50
-rw-r--r--saga/ihnm_introproc.cpp5
-rw-r--r--saga/interface.cpp208
-rw-r--r--saga/interface.h11
-rw-r--r--saga/isomap.cpp6
-rw-r--r--saga/ite_introproc.cpp4
-rw-r--r--saga/render.cpp17
-rw-r--r--saga/saga.cpp4
-rw-r--r--saga/saga.h92
-rw-r--r--saga/scene.cpp32
-rw-r--r--saga/script.cpp6
-rw-r--r--saga/sfuncs.cpp11
-rw-r--r--saga/sndres.cpp2
-rw-r--r--saga/sndres.h2
17 files changed, 277 insertions, 400 deletions
diff --git a/saga/animation.cpp b/saga/animation.cpp
index 4233d4e7c3..a2b8181cab 100644
--- a/saga/animation.cpp
+++ b/saga/animation.cpp
@@ -180,14 +180,10 @@ int Anim::play(uint16 anim_id, int vector_time, bool playing) {
uint16 frame;
int result;
- GAME_DISPLAYINFO disp_info;
-
if (anim_id >= _anim_count) {
return FAILURE;
}
- _vm->getDisplayInfo(&disp_info);
-
_vm->_render->getBufferInfo(&buf_info);
display_buf = buf_info.bg_buf;
@@ -207,7 +203,7 @@ int Anim::play(uint16 anim_id, int vector_time, bool playing) {
if (_vm->_gameType == GType_ITE) {
// FIXME: if start > 0, then this works incorrectly
result = ITE_DecodeFrame(anim->resdata, anim->resdata_len, anim->frame_offsets[frame], display_buf,
- disp_info.logical_w * disp_info.logical_h);
+ _vm->getDisplayWidth() * _vm->getDisplayHeight());
if (result != SUCCESS) {
warning("Anim::play: Error decoding frame %u", anim->current_frame);
anim->state = ANIM_PAUSE;
@@ -219,7 +215,7 @@ int Anim::play(uint16 anim_id, int vector_time, bool playing) {
return FAILURE;
}
- result = IHNM_DecodeFrame(display_buf, disp_info.logical_w * disp_info.logical_h,
+ result = IHNM_DecodeFrame(display_buf, _vm->getDisplayWidth() * _vm->getDisplayHeight(),
anim->cur_frame_p, anim->cur_frame_len, &nextf_p, &nextf_len);
if (result != SUCCESS) {
warning("Anim::play: Error decoding frame %u", anim->current_frame);
@@ -633,9 +629,6 @@ int Anim::IHNM_DecodeFrame(byte *decode_buf, size_t decode_buf_len, const byte *
byte *outbuf_endp = (decode_buf + decode_buf_len) - 1;
size_t outbuf_remain = decode_buf_len;
- GAME_DISPLAYINFO di;
-
- _vm->getDisplayInfo(&di);
*nextf_p = NULL;
@@ -668,7 +661,7 @@ int Anim::IHNM_DecodeFrame(byte *decode_buf, size_t decode_buf_len, const byte *
x_origin = param1;
y_origin = param2;
- outbuf_p = decode_buf + x_origin + (y_origin * di.logical_w);
+ outbuf_p = decode_buf + x_origin + (y_origin * _vm->getDisplayWidth());
if (outbuf_p > outbuf_endp) {
warning("0x%02X: (0x%X) Invalid output position. (x: %d, y: %d)",
@@ -738,7 +731,7 @@ int Anim::IHNM_DecodeFrame(byte *decode_buf, size_t decode_buf_len, const byte *
x_vector = readS.readSint16();
new_row = readS.readSint16();
- outbuf_p = decode_buf + ((y_origin + new_row) * di.logical_w) + x_origin + x_vector;
+ outbuf_p = decode_buf + ((y_origin + new_row) * _vm->getDisplayWidth()) + x_origin + x_vector;
outbuf_remain = (outbuf_endp - outbuf_p) + 1;
continue;
break;
diff --git a/saga/font.cpp b/saga/font.cpp
index d28db992d6..0b0bc67608 100644
--- a/saga/font.cpp
+++ b/saga/font.cpp
@@ -33,7 +33,6 @@
namespace Saga {
Font::Font(SagaEngine *vm) : _vm(vm), _initialized(false) {
- GAME_FONTDESC *gamefonts;
int i;
// Load font module resource context
@@ -42,10 +41,9 @@ Font::Font(SagaEngine *vm) : _vm(vm), _initialized(false) {
error("Font::Font(): Couldn't get resource context.");
}
- // Allocate font table
- _vm->getFontInfo(&gamefonts, &_nFonts);
+ assert(_vm->getFontsCount() > 0);
- assert(_nFonts > 0);
+ _nFonts = _vm->getFontsCount();
_fonts = (FONT **)malloc(_nFonts * sizeof(*_fonts));
if (_fonts == NULL) {
@@ -53,7 +51,7 @@ Font::Font(SagaEngine *vm) : _vm(vm), _initialized(false) {
}
for (i = 0; i < _nFonts; i++) {
- loadFont(gamefonts[i].font_rn, gamefonts[i].font_id);
+ loadFont(_vm->getFontDescription(i)->font_rn, _vm->getFontDescription(i)->font_id);
}
_initialized = true;
diff --git a/saga/game.cpp b/saga/game.cpp
index 394243dbfa..82e2efc8d3 100644
--- a/saga/game.cpp
+++ b/saga/game.cpp
@@ -44,29 +44,29 @@ static int detectGame(const FSList &fslist, bool mode = false);
// Inherit the Earth - DOS Demo version
-static GAME_FILEDESC ITEDEMO_GameFiles[] = {
+static GameFileDescription ITEDEMO_GameFiles[] = {
{"ite.rsc", GAME_RESOURCEFILE},
{"ite.dmo", GAME_DEMOFILE},
{"scripts.rsc", GAME_SCRIPTFILE},
{"voices.rsc", GAME_SOUNDFILE | GAME_VOICEFILE}
};
-static GAME_FONTDESC ITEDEMO_GameFonts[] = {
+static GameFontDescription ITEDEMO_GameFonts[] = {
{GAME_FONT_SMALL, 0},
{GAME_FONT_MEDIUM, 1}
};
-static GAME_SOUNDINFO ITEDEMO_GameSound = {
+static GameSoundInfo ITEDEMO_GameSound = {
GAME_SOUND_VOC, 0, 0, 0
};
-static GAME_FONTDESC ITEMACDEMO_GameFonts[] = {
+static GameFontDescription ITEMACDEMO_GameFonts[] = {
{GAME_FONT_MEDIUM, 0},
{GAME_FONT_SMALL, 2}
};
// Inherit the Earth - Wyrmkeep Win32 Demo version
-static GAME_FILEDESC ITEWINDEMO_GameFiles[] = {
+static GameFileDescription ITEWINDEMO_GameFiles[] = {
{"ited.rsc", GAME_RESOURCEFILE},
{"scriptsd.rsc", GAME_SCRIPTFILE},
{"soundsd.rsc", GAME_SOUNDFILE},
@@ -74,7 +74,7 @@ static GAME_FILEDESC ITEWINDEMO_GameFiles[] = {
};
// Inherit the Earth - Wyrmkeep Linux Demo version
-static GAME_FILEDESC ITELINDEMO_GameFiles[] = {
+static GameFileDescription ITELINDEMO_GameFiles[] = {
{"ited.rsc", GAME_RESOURCEFILE},
{"scriptsd.rsc", GAME_SCRIPTFILE},
{"soundsd.rsc", GAME_SOUNDFILE},
@@ -83,7 +83,7 @@ static GAME_FILEDESC ITELINDEMO_GameFiles[] = {
};
// Inherit the Earth - Wyrmkeep Linux version
-static GAME_FILEDESC ITELINCD_GameFiles[] = {
+static GameFileDescription ITELINCD_GameFiles[] = {
{"ite.rsc", GAME_RESOURCEFILE},
{"scripts.rsc", GAME_SCRIPTFILE},
{"sounds.rsc", GAME_SOUNDFILE},
@@ -91,13 +91,13 @@ static GAME_FILEDESC ITELINCD_GameFiles[] = {
{"music.rsc", GAME_MUSICFILE}
};
-static GAME_FONTDESC ITEWINDEMO_GameFonts[] = {
+static GameFontDescription ITEWINDEMO_GameFonts[] = {
{GAME_FONT_MEDIUM, 0},
{GAME_FONT_SMALL, 2}
};
// Inherit the Earth - Mac Wyrmkeep version
-static GAME_FILEDESC ITEMACCD_GameFiles[] = {
+static GameFileDescription ITEMACCD_GameFiles[] = {
{"ite.rsc", GAME_RESOURCEFILE},
{"scripts.rsc", GAME_SCRIPTFILE},
{"sounds.rsc", GAME_SOUNDFILE},
@@ -106,44 +106,44 @@ static GAME_FILEDESC ITEMACCD_GameFiles[] = {
};
// Inherit the Earth - Diskette version
-static GAME_FILEDESC ITEDISK_GameFiles[] = {
+static GameFileDescription ITEDISK_GameFiles[] = {
{"ite.rsc", GAME_RESOURCEFILE},
{"scripts.rsc", GAME_SCRIPTFILE},
{"voices.rsc", GAME_SOUNDFILE | GAME_VOICEFILE}
};
-static GAME_FONTDESC ITEDISK_GameFonts[] = {
+static GameFontDescription ITEDISK_GameFonts[] = {
{GAME_FONT_MEDIUM, 0},
{GAME_FONT_LARGE, 1},
{GAME_FONT_SMALL, 2}
};
-static GAME_RESOURCEDESC ITE_Resources = {
+static GameResourceDescription ITE_Resources = {
RID_ITE_SCENE_LUT, // Scene lookup table RN
RID_ITE_SCRIPT_LUT, // Script lookup table RN
RID_ITE_COMMAND_PANEL,
RID_ITE_DIALOGUE_PANEL
};
-static GAME_SOUNDINFO ITE_GameSound = {
+static GameSoundInfo ITE_GameSound = {
GAME_SOUND_VOC, 0, 0, 0
};
// Inherit the Earth - CD Enhanced version
-static GAME_FILEDESC ITECD_GameFiles[] = {
+static GameFileDescription ITECD_GameFiles[] = {
{"ite.rsc", GAME_RESOURCEFILE},
{"scripts.rsc", GAME_SCRIPTFILE},
{"sounds.rsc", GAME_SOUNDFILE},
{"voices.rsc", GAME_VOICEFILE}
};
-static GAME_FONTDESC ITECD_GameFonts[] = {
+static GameFontDescription ITECD_GameFonts[] = {
{GAME_FONT_MEDIUM, 0},
{GAME_FONT_LARGE, 1},
{GAME_FONT_SMALL, 2}
};
-static GAME_SOUNDINFO ITECD_GameSound = {
+static GameSoundInfo ITECD_GameSound = {
GAME_SOUND_PCM,
22050,
16,
@@ -151,7 +151,7 @@ static GAME_SOUNDINFO ITECD_GameSound = {
};
// I Have No Mouth and I Must Scream - Demo version
-static GAME_FILEDESC IHNMDEMO_GameFiles[] = {
+static GameFileDescription IHNMDEMO_GameFiles[] = {
{"scream.res", GAME_RESOURCEFILE},
{"scripts.res", GAME_SCRIPTFILE},
{"sfx.res", GAME_SOUNDFILE},
@@ -159,7 +159,7 @@ static GAME_FILEDESC IHNMDEMO_GameFiles[] = {
};
// I Have No Mouth and I Must Scream - Retail CD version
-static GAME_FILEDESC IHNMCD_GameFiles[] = {
+static GameFileDescription IHNMCD_GameFiles[] = {
{"musicfm.res", GAME_MUSICFILE_FM},
{"musicgm.res", GAME_MUSICFILE_GM},
{"scream.res", GAME_RESOURCEFILE},
@@ -176,7 +176,7 @@ static GAME_FILEDESC IHNMCD_GameFiles[] = {
};
// I Have No Mouth and I Must Scream - Retail German CD version
-static GAME_FILEDESC IHNMCDDE_GameFiles[] = {
+static GameFileDescription IHNMCDDE_GameFiles[] = {
{"musicfm.res", GAME_MUSICFILE_FM},
{"musicgm.res", GAME_MUSICFILE_GM},
{"scream.res", GAME_RESOURCEFILE},
@@ -191,7 +191,7 @@ static GAME_FILEDESC IHNMCDDE_GameFiles[] = {
{"voicess.res", GAME_VOICEFILE}
};
-static GAME_FONTDESC IHNMCD_GameFonts[] = {
+static GameFontDescription IHNMCD_GameFonts[] = {
{GAME_FONT_MEDIUM, 2},
{GAME_FONT_LARGE, 3},
{GAME_FONT_SMALL, 4},
@@ -201,19 +201,19 @@ static GAME_FONTDESC IHNMCD_GameFonts[] = {
{GAME_FONT_LARGE3, 8}
};
-static GAME_RESOURCEDESC IHNM_Resources = {
+static GameResourceDescription IHNM_Resources = {
RID_IHNM_SCENE_LUT, // Scene lookup table RN
RID_IHNM_SCRIPT_LUT, // Script lookup table RN
RID_IHNM_COMMAND_PANEL,
RID_IHNM_DIALOGUE_PANEL
};
-static GAME_SOUNDINFO IHNM_GameSound = {
+static GameSoundInfo IHNM_GameSound = {
GAME_SOUND_WAV, 0, 0, 0
};
-struct GAME_MD5 {
- GAME_IDS id;
+struct GameMD5 {
+ GameIds id;
const char *md5;
const char *filename;
bool caseSensitive;
@@ -221,7 +221,7 @@ struct GAME_MD5 {
#define FILE_MD5_BYTES 5000
-static GAME_MD5 game_md5[] = {
+static GameMD5 gameMD5[] = {
{ GID_ITE_DISK_G, "8f4315a9bb10ec839253108a032c8b54", "ite.rsc", false },
{ GID_ITE_DISK_G, "516f7330f8410057b834424ea719d1ef", "scripts.rsc", false },
{ GID_ITE_DISK_G, "c46e4392fcd2e89bc91e5567db33b62d", "voices.rsc", false },
@@ -326,7 +326,7 @@ static GAME_MD5 game_md5[] = {
{ GID_IHNM_DEMO, "3bbc16a8f741dbb511da506c660a0b54", "voicesd.res", false },
};
-static GAMEDESC GameDescs[] = {
+static GameDescription gameDescriptions[] = {
// Inherit the earth - DOS Demo version
{
"ite-demo",
@@ -618,18 +618,16 @@ static GAMEDESC GameDescs[] = {
}
};
-static GAMEMODULE GameModule;
-
int SagaEngine::initGame(void) {
- int game_n;
+ int gameNumber;
FSList dummy;
- if ((game_n = detectGame(dummy)) == -1) {
+ if ((gameNumber = detectGame(dummy)) == -1) {
warning("No valid games were found in the specified directory.");
return FAILURE;
}
- if (loadGame(game_n) != SUCCESS) {
+ if (loadGame(gameNumber) != SUCCESS) {
warning("Error loading game resource files.");
return FAILURE;
}
@@ -642,14 +640,11 @@ int SagaEngine::initGame(void) {
int SagaEngine::loadLanguage(void) {
char lang_file[MAXPATH];
- uint16 game_n;
-
File test_file;
- game_n = GameModule.game_number;
- if (GameDescs[game_n].gd_game_type == GType_ITE) {
- snprintf(lang_file, MAXPATH, "%s%s.%s", GAME_ITE_LANG_PREFIX, GameModule.game_language, GAME_LANG_EXT);
+ if (_gameType == GType_ITE) {
+ snprintf(lang_file, MAXPATH, "%s%s.%s", GAME_ITE_LANG_PREFIX, _gameLanguage, GAME_LANG_EXT);
if (!test_file.open(lang_file)) {
debug(0, "Couldn't open language file %s. Using default (US English)", lang_file);
return SUCCESS;
@@ -678,16 +673,15 @@ int SagaEngine::loadLanguage(void) {
}
RSCFILE_CONTEXT *SagaEngine::getFileContext(uint16 type, int param) {
- RSCFILE_CONTEXT *found_ctxt = NULL;
uint16 i;
- for (i = 0; i < GameModule.gfile_n; i++) {
- if (GameModule.gfile_data[i].file_types & type) {
- found_ctxt = GameModule.gfile_data[i].file_ctxt;
+ for (i = 0; i < _gameDescription->filesCount; i++) {
+ if ( _gameDescription->filesDescriptions[i].fileType & type) {
+ return _gameFileContexts[i];
}
}
- return found_ctxt;
+ return NULL;
}
DetectedGameList GAME_ProbeGame(const FSList &fslist) {
@@ -695,13 +689,13 @@ DetectedGameList GAME_ProbeGame(const FSList &fslist) {
int game_n;
if ((game_n = detectGame(fslist, true)) != -1)
- detectedGames.push_back(GameDescs[game_n].toGameSettings());
+ detectedGames.push_back(gameDescriptions[game_n].toGameSettings());
return detectedGames;
}
int detectGame(const FSList &fslist, bool mode) {
- int game_count = ARRAYSIZE(GameDescs);
+ int game_count = ARRAYSIZE(gameDescriptions);
int game_n = -1;
Common::StringMap filesMD5;
@@ -718,12 +712,12 @@ int detectGame(const FSList &fslist, bool mode) {
uint8 md5sum[16];
// First we compose list of files which we need MD5s for
- for (int i = 0; i < ARRAYSIZE(game_md5); i++) {
- tstr = Common::String(game_md5[i].filename);
+ for (int i = 0; i < ARRAYSIZE(gameMD5); i++) {
+ tstr = Common::String(gameMD5[i].filename);
tstr.toLowercase();
- if (game_md5[i].caseSensitive && !mode)
- filesList[Common::String(game_md5[i].filename)] = true;
+ if (gameMD5[i].caseSensitive && !mode)
+ filesList[Common::String(gameMD5[i].filename)] = true;
else
filesList[tstr] = true;
}
@@ -766,12 +760,12 @@ int detectGame(const FSList &fslist, bool mode) {
}
for (game_n = 0; game_n < game_count; game_n++) {
- file_count = GameDescs[game_n].gd_filect;
+ file_count = gameDescriptions[game_n].filesCount;
file_missing = false;
// Try to open all files for this game
for (file_n = 0; file_n < file_count; file_n++) {
- tstr = GameDescs[game_n].gd_filedescs[file_n].gf_fname;
+ tstr = gameDescriptions[game_n].filesDescriptions[file_n].fileName;
if (!filesMD5.contains(tstr)) {
file_missing = true;
@@ -786,13 +780,13 @@ int detectGame(const FSList &fslist, bool mode) {
} else {
bool match = true;
- debug(5, "Probing game: %s", GameDescs[game_n].gd_title);
+ debug(5, "Probing game: %s", gameDescriptions[game_n].title);
- for (int i = 0; i < ARRAYSIZE(game_md5); i++) {
- if (game_md5[i].id == GameDescs[game_n].gd_game_id) {
- tstr = game_md5[i].filename;
+ for (int i = 0; i < ARRAYSIZE(gameMD5); i++) {
+ if (gameMD5[i].id == gameDescriptions[game_n].gameId) {
+ tstr = gameMD5[i].filename;
- if (strcmp(game_md5[i].md5, filesMD5[tstr].c_str())) {
+ if (strcmp(gameMD5[i].md5, filesMD5[tstr].c_str())) {
match = false;
break;
}
@@ -801,7 +795,7 @@ int detectGame(const FSList &fslist, bool mode) {
if (!match)
continue;
- debug(5, "Found game: %s", GameDescs[game_n].gd_title);
+ debug(5, "Found game: %s", gameDescriptions[game_n].title);
return game_n;
}
@@ -819,70 +813,48 @@ int detectGame(const FSList &fslist, bool mode) {
return -1;
}
-int SagaEngine::loadGame(int game_n) {
- RSCFILE_CONTEXT *load_ctxt;
- uint16 game_count = ARRAYSIZE(GameDescs);
- const char *game_fname;
- uint16 game_filect;
+int SagaEngine::loadGame(int gameNumber) {
+ RSCFILE_CONTEXT *loadContext;
+ uint16 gameCount = ARRAYSIZE(gameDescriptions);
+ const char *gameFileName;
+ uint16 gameFileCount;
uint16 i;
- if (game_n >= game_count) {
- return FAILURE;
+ if (gameNumber >= gameCount) {
+ error("SagaEngine::loadGame wrong gameNumber");
}
- GameModule.game_number = game_n;
- GameModule.gamedesc = &GameDescs[game_n];
+ _gameNumber = gameNumber;
+ _gameDescription = &gameDescriptions[gameNumber];
- _gameId = GameModule.gamedesc->gd_game_id;
- _gameType = GameModule.gamedesc->gd_game_type;
- _features = GameModule.gamedesc->features;
+ _gameId = _gameDescription->gameId;
+ _gameType = _gameDescription->gameType;
+ _features = _gameDescription->features;
- game_filect = GameDescs[game_n].gd_filect;
+ gameFileCount = _gameDescription->filesCount;
- GameModule.gfile_data = (GAME_FILEDATA *)malloc(game_filect * sizeof(*GameModule.gfile_data));
- if (GameModule.gfile_data == NULL) {
- return MEM;
+ _gameFileContexts = (RSCFILE_CONTEXT **)malloc(gameFileCount * sizeof(*_gameFileContexts));
+ //TODO: on exit - FREE!
+ if (_gameFileContexts == NULL) {
+ error("SagaEngine::loadGame not enough memory");
}
- GameModule.gfile_n = game_filect;
// Load game resource files
- for (i = 0; i < game_filect; i++) {
- load_ctxt = RSC_CreateContext();
- game_fname = GameDescs[game_n].gd_filedescs[i].gf_fname;
- if (RSC_OpenContext(load_ctxt, game_fname) != SUCCESS) {
+ for (i = 0; i < gameFileCount; i++) {
+ loadContext = RSC_CreateContext();
+ gameFileName = _gameDescription->filesDescriptions[i].fileName;
+ if (RSC_OpenContext(loadContext, gameFileName) != SUCCESS) {
return FAILURE;
}
- debug(0, "Opened resource file: %s", game_fname);
- GameModule.gfile_data[i].file_ctxt = load_ctxt;
- GameModule.gfile_data[i].file_types = GameDescs[game_n].gd_filedescs[i].gf_type;
- GameModule.gfile_data[i].file_flags = 0;
+ debug(0, "Opened resource file: %s", gameFileName);
+ _gameFileContexts[i] = loadContext;
}
- // Load game font data
- GameModule.gd_fontct = GameDescs[game_n].gd_fontct;
- GameModule.gd_fontdescs = GameDescs[game_n].gd_fontdescs;
-
return SUCCESS;
}
-const GAME_RESOURCEDESC SagaEngine::getResourceInfo(void) {
- return *GameModule.gamedesc->gd_resource_desc;
-}
-
-const GAME_SOUNDINFO SagaEngine::getSoundInfo(void) {
- return *GameModule.gamedesc->gd_soundinfo;
-}
-
-int SagaEngine::getDisplayWidth() {
- return GameDescs[GameModule.game_number].gd_logical_w;
-}
-
-int SagaEngine::getDisplayHeight() {
- return GameDescs[GameModule.game_number].gd_logical_h;
-}
-
int SagaEngine::getPathYOffset() { //fixme: should be in GameDesc
if (_gameType == GType_ITE) {
return 35;
@@ -899,36 +871,4 @@ int SagaEngine::getStatusYOffset() { //fixme: should be in GameDesc
}
}
-int SagaEngine::getDisplayInfo(GAME_DISPLAYINFO *disp_info) {
- int game_n;
-
- assert(disp_info != NULL);
-
- game_n = GameModule.game_number;
-
- disp_info->logical_w = GameDescs[game_n].gd_logical_w;
- disp_info->logical_h = GameDescs[game_n].gd_logical_h;
- disp_info->scene_h = GameDescs[game_n].gd_scene_h;
-
- return SUCCESS;
-}
-
-int SagaEngine::getFontInfo(GAME_FONTDESC **gf_desc, int *font_n) {
- assert((gf_desc != NULL) && (font_n != NULL));
-
- *gf_desc = GameModule.gd_fontdescs;
- *font_n = GameModule.gd_fontct;
-
- return SUCCESS;
-}
-
-int SagaEngine::getSceneInfo(GAME_SCENEDESC *gs_desc) {
- assert(gs_desc != NULL);
-
- gs_desc->first_scene = GameModule.gamedesc->gd_startscene;
- gs_desc->scene_lut_rn = RSC_ConvertID(GameModule.gamedesc->gd_resource_desc->scene_lut_rn);
-
- return SUCCESS;
-}
-
} // End of namespace Saga
diff --git a/saga/game.h b/saga/game.h
index b04380be50..850f343914 100644
--- a/saga/game.h
+++ b/saga/game.h
@@ -30,62 +30,12 @@
namespace Saga {
-#define GAME_LANGSTR_LIMIT 3
#define GAME_PATH_LIMIT 512
-#define GAME_ITE_LANG_PREFIX "ite_"
-#define GAME_LANG_EXT "lng"
-
// Script lookup table entry sizes for game verification
#define SCR_LUT_ENTRYLEN_ITECD 22
#define SCR_LUT_ENTRYLEN_ITEDISK 16
-struct GAME_FILEDESC {
- const char *gf_fname;
- uint16 gf_type;
-};
-
-struct GAMEDESC {
- const char *name;
- SAGAGameType gd_game_type;
- GAME_IDS gd_game_id;
- const char *gd_title;
- int gd_logical_w;
- int gd_logical_h;
- int gd_scene_h;
- int gd_startscene;
- GAME_RESOURCEDESC *gd_resource_desc;
- int gd_filect;
- GAME_FILEDESC *gd_filedescs;
- int gd_fontct;
- GAME_FONTDESC *gd_fontdescs;
- GAME_SOUNDINFO *gd_soundinfo;
- uint32 features;
-
- GameSettings toGameSettings() const {
- GameSettings dummy = { name, gd_title, features };
- return dummy;
- }
-};
-
-struct GAME_FILEDATA {
- RSCFILE_CONTEXT *file_ctxt;
- uint16 file_types;
- uint16 file_flags;
-};
-
-struct GAMEMODULE {
- int game_number;
- GAMEDESC *gamedesc;
- int g_skipintro;
- char game_language[GAME_LANGSTR_LIMIT];
- uint16 gfile_n;
- GAME_FILEDATA *gfile_data;
- uint16 gd_fontct;
- GAME_FONTDESC *gd_fontdescs;
- int err_n;
- const char *err_str;
-};
DetectedGameList GAME_ProbeGame(const FSList &fslist);
diff --git a/saga/ihnm_introproc.cpp b/saga/ihnm_introproc.cpp
index 919169754c..643f570927 100644
--- a/saga/ihnm_introproc.cpp
+++ b/saga/ihnm_introproc.cpp
@@ -92,7 +92,6 @@ int Scene::IHNMStartProc() {
size_t i;
SCENE_QUEUE first_scene;
- GAME_SCENEDESC gs_desc;
n_introscenes = ARRAYSIZE(IHNM_IntroList);
@@ -105,10 +104,8 @@ int Scene::IHNMStartProc() {
// it will cause the end titles music to play, which is wrong. (But
// hey, it's a nice piece of music!)
- _vm->getSceneInfo(&gs_desc);
-
first_scene.load_flag = BY_SCENE;
- first_scene.scene_n = gs_desc.first_scene;
+ first_scene.scene_n = _vm->getStartSceneNumber();
first_scene.scene_skiptarget = 1;
first_scene.scene_proc = NULL;
first_scene.fadeType = SCENE_FADE;
diff --git a/saga/interface.cpp b/saga/interface.cpp
index 57318d8785..c1369ac3f7 100644
--- a/saga/interface.cpp
+++ b/saga/interface.cpp
@@ -81,8 +81,8 @@ static INTERFACE_DESC ITE_interface = {
ITE_INVENTORY_YSPACING
};
-static INTERFACE_BUTTON ITE_c_buttons[] = {
- {5, 4, 46, 47, "Portrait", 0, 0, BUTTON_NONE, 0},
+static InterfaceButton ITEMainPanel[] = {
+ {5, 4, 46, 47, "Portrait", 0, 0, BUTTON_NONE, 0}, //TODO: remove?
// "Walk To" and "Talk To" share button sprites
{52, 4, 109, 14, "Walk To", 1, 2, BUTTON_VERB, I_VERB_WALKTO},
{52, 15, 109, 25, "Look At", 3, 4, BUTTON_VERB, I_VERB_LOOKAT},
@@ -136,7 +136,7 @@ static INTERFACE_DESC IHNM_interface = {
IHNM_INVENTORY_YSPACING
};
-static INTERFACE_BUTTON IHNM_c_buttons[] = {
+static InterfaceButton IHNMMainPanel[] = {
{5, 4, 46, 47, "Portrait", 0, 0, 0, 0}
};
@@ -160,8 +160,6 @@ int Interface::registerLang(void) {
}
Interface::Interface(SagaEngine *vm) : _vm(vm), _initialized(false) {
- GAME_RESOURCEDESC g_resdesc;
-
int result;
if (_initialized) {
@@ -183,37 +181,32 @@ Interface::Interface(SagaEngine *vm) : _vm(vm), _initialized(false) {
// Initialize interface data by game type
if (_vm->_gameType == GType_ITE) {
// Load Inherit the Earth interface desc
- _cPanel.buttons = ITE_c_buttons;
- _cPanel.nbuttons = ARRAYSIZE(ITE_c_buttons);
+ _mainPanel.buttons = ITEMainPanel;
+ _mainPanel.nbuttons = ARRAYSIZE(ITEMainPanel);
_iDesc = ITE_interface;
} else if (_vm->_gameType == GType_IHNM) {
// Load I Have No Mouth interface desc
- _cPanel.buttons = IHNM_c_buttons;
- _cPanel.nbuttons = ARRAYSIZE(IHNM_c_buttons);
+ _mainPanel.buttons = IHNMMainPanel;
+ _mainPanel.nbuttons = ARRAYSIZE(IHNMMainPanel);
_iDesc = IHNM_interface;
} else {
return;
}
- // Load interface resources
- g_resdesc = _vm->getResourceInfo();
-
// Load command panel resource
- result = RSC_LoadResource(_interfaceContext, g_resdesc.command_panel_rn,
- &_cPanel.res, &_cPanel.res_len);
+ result = RSC_LoadResource(_interfaceContext, _vm->getResourceDescription()->command_panel_rn, &_mainPanel.res, &_mainPanel.res_len);
if (result != SUCCESS) {
return;
}
// Load dialogue panel resource
- result = RSC_LoadResource(_interfaceContext, g_resdesc.dialogue_panel_rn,
- &_dPanel.res, &_dPanel.res_len);
+ result = RSC_LoadResource(_interfaceContext, _vm->getResourceDescription()->dialogue_panel_rn, &_conversePanel.res, &_conversePanel.res_len);
if (result != SUCCESS) {
return;
}
- if (_vm->_sprite->loadList(RID_ITE_COMMAND_BUTTONSPRITES, _cPanel.sprites) != SUCCESS) {
+ if (_vm->_sprite->loadList(RID_ITE_COMMAND_BUTTONSPRITES, _mainPanel.sprites) != SUCCESS) {
error("Unable to load sprite list");
}
@@ -223,20 +216,20 @@ Interface::Interface(SagaEngine *vm) : _vm(vm), _initialized(false) {
}
- _vm->decodeBGImage(_cPanel.res, _cPanel.res_len, &_cPanel.img,
- &_cPanel.img_len, &_cPanel.img_w, &_cPanel.img_h);
+ _vm->decodeBGImage(_mainPanel.res, _mainPanel.res_len, &_mainPanel.img,
+ &_mainPanel.img_len, &_mainPanel.img_w, &_mainPanel.img_h);
- _vm->decodeBGImage(_dPanel.res, _dPanel.res_len,
- &_dPanel.img, &_dPanel.img_len,
- &_dPanel.img_w, &_dPanel.img_h);
+ _vm->decodeBGImage(_conversePanel.res, _conversePanel.res_len,
+ &_conversePanel.img, &_conversePanel.img_len,
+ &_conversePanel.img_w, &_conversePanel.img_h);
- _cPanel.x = 0;
- _cPanel.y = 149;
+ _mainPanel.x = 0;
+ _mainPanel.y = 149;
- _dPanel.x = 0;
- _dPanel.y = 149;
+ _conversePanel.x = 0;
+ _conversePanel.y = 149;
- _cPanel.set_button = COMMAND_DEFAULT_BUTTON;
+ _mainPanel.set_button = COMMAND_DEFAULT_BUTTON;
_leftPortrait = 0;
_rightPortrait = 0;
@@ -262,7 +255,7 @@ Interface::Interface(SagaEngine *vm) : _vm(vm), _initialized(false) {
Interface::~Interface(void) {
free(_inventory);
- _cPanel.sprites.freeMem();
+ _mainPanel.sprites.freeMem();
_defPortraits.freeMem();
_scenePortraits.freeMem();
_initialized = false;
@@ -310,23 +303,25 @@ void Interface::restoreMode() {
int Interface::setMode(int mode, bool force) {
// TODO: Is this where we should hide/show the mouse cursor?
- int newmode = mode;
+ int newMode = mode;
- if (mode == kPanelConverse)
+ if (mode == kPanelConverse) {
_inMainMode = false;
- else if (mode == kPanelInventory) {
- _inMainMode = true;
- newmode = kPanelMain;
+ } else {
+ if (mode == kPanelInventory) {
+ _inMainMode = true;
+ newMode = kPanelMain;
+ }
}
// This lets us to prevents actors to pop up during initial
// scene fade in.
if (_savedMode != -1 && !force) {
- _savedMode = newmode;
- debug(0, "Saved mode: %d. my mode is %d", newmode, _panelMode);
+ _savedMode = newMode;
+ debug(0, "Saved mode: %d. my mode is %d", newMode, _panelMode);
}
else
- _panelMode = newmode;
+ _panelMode = newMode;
draw();
@@ -362,71 +357,63 @@ int Interface::setRightPortrait(int portrait) {
}
int Interface::draw() {
- GAME_DISPLAYINFO g_di;
- SURFACE *back_buf;
+ SURFACE *backBuffer;
- int xbase;
- int ybase;
- Point lportrait;
- Point rportrait;
-
+ Point base;
+ Point leftPortraitPoint;
+ Point rightPortraitPoint;
Point origin;
- back_buf = _vm->_gfx->getBackBuffer();
+ backBuffer = _vm->_gfx->getBackBuffer();
if (_vm->_scene->isInDemo() || _panelMode == kPanelFade)
return SUCCESS;
- // Get game display info
- _vm->getDisplayInfo(&g_di);
- drawStatusBar(back_buf);
+ drawStatusBar(backBuffer);
- // Draw command panel background
if (_panelMode == kPanelMain) {
- xbase = _cPanel.x;
- ybase = _cPanel.y;
+ base.x = _mainPanel.x;
+ base.y = _mainPanel.y;
origin.x = 0;
- origin.y = g_di.logical_h - _cPanel.img_h;
+ origin.y = _vm->getDisplayHeight() - _mainPanel.img_h;
- bufToSurface(back_buf, _cPanel.img, _cPanel.img_w,
- _cPanel.img_h, NULL, &origin);
+ bufToSurface(backBuffer, _mainPanel.img, _mainPanel.img_w, _mainPanel.img_h, NULL, &origin);
+
} else {
- xbase = _dPanel.x;
- ybase = _dPanel.y;
+ base.x = _conversePanel.x;
+ base.y = _conversePanel.y;
origin.x = 0;
- origin.y = g_di.logical_h - _cPanel.img_h;
+ origin.y = _vm->getDisplayHeight() - _mainPanel.img_h;
- bufToSurface(back_buf, _dPanel.img, _dPanel.img_w,
- _dPanel.img_h, NULL, &origin);
+ bufToSurface(backBuffer, _conversePanel.img, _conversePanel.img_w,
+ _conversePanel.img_h, NULL, &origin);
}
- // Draw character portrait
- lportrait.x = xbase + _iDesc.lportrait_x;
- lportrait.y = ybase + _iDesc.lportrait_y;
-
if (_panelMode == kPanelMain || _panelMode == kPanelConverse ||
- _lockedMode == kPanelMain || _lockedMode == kPanelConverse)
- _vm->_sprite->draw(back_buf, _defPortraits, _leftPortrait, lportrait, 256);
+ _lockedMode == kPanelMain || _lockedMode == kPanelConverse) {
+ leftPortraitPoint.x = base.x + _iDesc.lportrait_x;
+ leftPortraitPoint.y = base.y + _iDesc.lportrait_y;
+ _vm->_sprite->draw(backBuffer, _defPortraits, _leftPortrait, leftPortraitPoint, 256);
+ }
+
if (!_inMainMode && _iDesc.rportrait_x >= 0) {
- rportrait.x = xbase + _iDesc.rportrait_x;
- rportrait.y = ybase + _iDesc.rportrait_y;
+ rightPortraitPoint.x = base.x + _iDesc.rportrait_x;
+ rightPortraitPoint.y = base.y + _iDesc.rportrait_y;
- _vm->_sprite->draw(back_buf, _scenePortraits, _rightPortrait, rportrait, 256);
+ _vm->_sprite->draw(backBuffer, _scenePortraits, _rightPortrait, rightPortraitPoint, 256);
}
- if (_inMainMode)
+ if (_inMainMode) {
drawInventory();
-
+ }
return SUCCESS;
}
int Interface::update(const Point& imousePt, int update_flag) {
- GAME_DISPLAYINFO g_di;
-
SURFACE *back_buf;
int imouse_x, imouse_y;
@@ -439,12 +426,10 @@ int Interface::update(const Point& imousePt, int update_flag) {
back_buf = _vm->_gfx->getBackBuffer();
- // Get game display info
- _vm->getDisplayInfo(&g_di);
if (_panelMode == kPanelMain) { // FIXME: HACK
// Update playfield space ( only if cursor is inside )
- if (imouse_y < g_di.scene_h) {
+ if (imouse_y < _vm->getStatusYOffset()) {
// Mouse is in playfield space
if (update_flag == UPDATE_MOUSEMOVE) {
handlePlayfieldUpdate(back_buf, imousePt);
@@ -467,7 +452,6 @@ int Interface::update(const Point& imousePt, int update_flag) {
}
int Interface::drawStatusBar(SURFACE *ds) {
- GAME_DISPLAYINFO g_di;
Rect rect;
int string_w;
@@ -479,13 +463,11 @@ int Interface::drawStatusBar(SURFACE *ds) {
return SUCCESS;
}
- // Get game display info
- _vm->getDisplayInfo(&g_di);
// Erase background of status bar
rect.left = 0;
rect.top = _iDesc.status_y;
- rect.right = g_di.logical_w;
+ rect.right = _vm->getDisplayWidth();
rect.bottom = _iDesc.status_y + _iDesc.status_h;
drawRect(ds, &rect, _iDesc.status_bgcol);
@@ -516,31 +498,31 @@ int Interface::handleCommandClick(SURFACE *ds, const Point& imousePt) {
return SUCCESS;
}
- x_base = _cPanel.x;
- y_base = _cPanel.y;
+ x_base = _mainPanel.x;
+ y_base = _mainPanel.y;
- if (_cPanel.buttons[ibutton_num].flags & BUTTON_SET) {
- old_set_button = _cPanel.set_button;
+ if (_mainPanel.buttons[ibutton_num].flags & BUTTON_SET) {
+ old_set_button = _mainPanel.set_button;
set_button = ibutton_num;
- _cPanel.set_button = set_button;
+ _mainPanel.set_button = set_button;
- if (_cPanel.buttons[set_button].flags & BUTTON_VERB) {
- _activeVerb = _cPanel.buttons[ibutton_num].data;
+ if (_mainPanel.buttons[set_button].flags & BUTTON_VERB) {
+ _activeVerb = _mainPanel.buttons[ibutton_num].data;
}
- if (_cPanel.buttons[set_button].flags & BUTTON_BITMAP) {
- button.x = x_base + _cPanel.buttons[set_button].x1;
- button.y = y_base + _cPanel.buttons[set_button].y1;
+ if (_mainPanel.buttons[set_button].flags & BUTTON_BITMAP) {
+ button.x = x_base + _mainPanel.buttons[set_button].x1;
+ button.y = y_base + _mainPanel.buttons[set_button].y1;
- _vm->_sprite->draw(ds, _cPanel.sprites, _cPanel.buttons[set_button].
+ _vm->_sprite->draw(ds, _mainPanel.sprites, _mainPanel.buttons[set_button].
active_sprite - 1, button, 256);
}
- if (_cPanel.buttons[old_set_button].flags & BUTTON_BITMAP) {
- button.x = x_base + _cPanel.buttons[old_set_button].x1;
- button.y = y_base + _cPanel.buttons[old_set_button].y1;
+ if (_mainPanel.buttons[old_set_button].flags & BUTTON_BITMAP) {
+ button.x = x_base + _mainPanel.buttons[old_set_button].x1;
+ button.y = y_base + _mainPanel.buttons[old_set_button].y1;
- _vm->_sprite->draw(ds, _cPanel.sprites, _cPanel.buttons[old_set_button].
+ _vm->_sprite->draw(ds, _mainPanel.sprites, _mainPanel.buttons[old_set_button].
inactive_sprite - 1, button, 256);
}
}
@@ -553,13 +535,12 @@ int Interface::handleCommandUpdate(SURFACE *ds, const Point& imousePt) {
int ibutton_num;
Point button;
- int button_w = 0;
+// int button_w = 0;
- int verb_idx = 0;
+/* int verb_idx = 0;
int string_w = 0;
-
int color;
- int i;
+ int i;*/
hit_button = inventoryTest(imousePt, &ibutton_num);
@@ -568,21 +549,21 @@ int Interface::handleCommandUpdate(SURFACE *ds, const Point& imousePt) {
return SUCCESS;
}
- hit_button = hitTest(imousePt, &ibutton_num);
+/* hit_button = hitTest(imousePt, &ibutton_num);
if (hit_button == SUCCESS) {
// Hovering over a command panel button
setStatusText(I_VerbData[_activeVerb].verb_str);
}
- for (i = 0; i < _cPanel.nbuttons; i++) {
- if (!(_cPanel.buttons[i].flags & BUTTON_LABEL)) {
+ for (i = 0; i < _mainPanel.nbuttons; i++) {
+ if (!(_mainPanel.buttons[i].flags & BUTTON_LABEL)) {
continue;
}
- button_w = _cPanel.buttons[i].x2 - _cPanel.buttons[i].x1;
+ button_w = _mainPanel.buttons[i].x2 - _mainPanel.buttons[i].x1;
- verb_idx = _cPanel.buttons[i].data;
+ verb_idx = _mainPanel.buttons[i].data;
string_w = _vm->_font->getStringWidth(SMALL_FONT_ID, I_VerbData[verb_idx].verb_str, 0, 0);
@@ -592,19 +573,19 @@ int Interface::handleCommandUpdate(SURFACE *ds, const Point& imousePt) {
color = _iDesc.cmd_txt_col;
}
- button.x = _cPanel.x + _cPanel.buttons[i].x1;
- button.y = _cPanel.y + _cPanel.buttons[i].y1;
+ button.x = _mainPanel.x + _mainPanel.buttons[i].x1;
+ button.y = _mainPanel.y + _mainPanel.buttons[i].y1;
_vm->_font->draw(SMALL_FONT_ID, ds, I_VerbData[verb_idx].verb_str, 0,
button.x + ((button_w / 2) - (string_w / 2)), button.y + 1,
color, _iDesc.cmd_txt_shadowcol, FONT_SHADOW);
- if ((i == _cPanel.set_button) && (_cPanel.buttons[i].flags & BUTTON_BITMAP)) {
- _vm->_sprite->draw(ds, _cPanel.sprites, _cPanel.buttons[i].active_sprite - 1,
+ if ((i == _mainPanel.set_button) && (_mainPanel.buttons[i].flags & BUTTON_BITMAP)) {
+ _vm->_sprite->draw(ds, _mainPanel.sprites, _mainPanel.buttons[i].active_sprite - 1,
button, 256);
}
}
-
+*/
return SUCCESS;
}
@@ -687,7 +668,7 @@ int Interface::handlePlayfieldUpdate(SURFACE *ds, const Point& imousePt) {
}
int Interface::hitTest(const Point& imousePt, int *ibutton) {
- INTERFACE_BUTTON *buttons;
+ InterfaceButton *buttons;
int nbuttons;
int xbase;
@@ -695,11 +676,11 @@ int Interface::hitTest(const Point& imousePt, int *ibutton) {
int i;
- buttons = _cPanel.buttons;
- nbuttons = _cPanel.nbuttons;
+ buttons = _mainPanel.buttons;
+ nbuttons = _mainPanel.nbuttons;
- xbase = _cPanel.x;
- ybase = _cPanel.y;
+ xbase = _mainPanel.x;
+ ybase = _mainPanel.y;
for (i = 0; i < nbuttons; i++) {
if ((imousePt.x >= (xbase + buttons[i].x1)) && (imousePt.x < (xbase + buttons[i].x2)) &&
@@ -808,4 +789,7 @@ int Interface::inventoryTest(const Point& imousePt, int *ibutton) {
return FAILURE;
}
+void Interface::drawVerb(int verb, int state) {
+}
+
} // End of namespace Saga
diff --git a/saga/interface.h b/saga/interface.h
index 313954fce2..b3edf44957 100644
--- a/saga/interface.h
+++ b/saga/interface.h
@@ -126,7 +126,7 @@ enum BUTTON_FLAGS {
#define BUTTON_VERB ( BUTTON_LABEL | BUTTON_BITMAP | BUTTON_SET )
-struct INTERFACE_BUTTON {
+struct InterfaceButton {
int x1;
int y1;
int x2;
@@ -138,7 +138,7 @@ struct INTERFACE_BUTTON {
int data;
};
-struct INTERFACE_PANEL {
+struct InterfacePanel {
byte *res;
size_t res_len;
int x;
@@ -149,7 +149,7 @@ struct INTERFACE_PANEL {
int img_h;
int set_button;
int nbuttons;
- INTERFACE_BUTTON *buttons;
+ InterfaceButton *buttons;
SpriteList sprites;
};
@@ -235,6 +235,7 @@ private:
int handleCommandClick(SURFACE *ds, const Point& imousePt);
int handlePlayfieldUpdate(SURFACE *ds, const Point& imousePt);
int handlePlayfieldClick(SURFACE *ds, const Point& imousePt);
+ void drawVerb(int verb, int state);
private:
SagaEngine *_vm;
@@ -247,8 +248,8 @@ private:
int _savedMode;
int _lockedMode;
bool _inMainMode;
- INTERFACE_PANEL _cPanel;
- INTERFACE_PANEL _dPanel;
+ InterfacePanel _mainPanel;
+ InterfacePanel _conversePanel;
char _statusText[STATUS_TEXT_LEN];
int _leftPortrait;
int _rightPortrait;
diff --git a/saga/isomap.cpp b/saga/isomap.cpp
index 6d9ac7b35f..53f963e3e6 100644
--- a/saga/isomap.cpp
+++ b/saga/isomap.cpp
@@ -132,13 +132,11 @@ int IsoMap::loadMetamap(const byte *mm_res_p, size_t mm_res_len) {
}
int IsoMap::draw(SURFACE *dst_s) {
- GAME_DISPLAYINFO disp_info;
- _vm->getDisplayInfo(&disp_info);
- Rect iso_rect(disp_info.logical_w, disp_info.scene_h);
+/* Rect iso_rect(disp_info.logical_w, disp_info.scene_h);
drawRect(dst_s, &iso_rect, 0);
drawMetamap(dst_s, -1000, -500);
-
+*/
return SUCCESS;
}
diff --git a/saga/ite_introproc.cpp b/saga/ite_introproc.cpp
index f798e0341e..f346bb880d 100644
--- a/saga/ite_introproc.cpp
+++ b/saga/ite_introproc.cpp
@@ -126,7 +126,6 @@ int Scene::ITEStartProc() {
SCENE_QUEUE first_scene;
SCENE_QUEUE tempScene;
- GAME_SCENEDESC gs_desc;
n_introscenes = ARRAYSIZE(ITE_IntroList);
@@ -136,10 +135,9 @@ int Scene::ITEStartProc() {
_vm->_scene->queueScene(&tempScene);
}
- _vm->getSceneInfo(&gs_desc);
first_scene.load_flag = BY_SCENE;
- first_scene.scene_n = gs_desc.first_scene;
+ first_scene.scene_n = _vm->getStartSceneNumber();
first_scene.scene_skiptarget = 1;
first_scene.scene_proc = NULL;
first_scene.fadeType = SCENE_FADE;
diff --git a/saga/render.cpp b/saga/render.cpp
index 67409add72..69f21a943e 100644
--- a/saga/render.cpp
+++ b/saga/render.cpp
@@ -46,28 +46,25 @@ Render::Render(SagaEngine *vm, OSystem *system) {
_system = system;
_initialized = false;
- GAME_DISPLAYINFO disp_info;
int tmp_w, tmp_h, tmp_bytepp;
- // Initialize system graphics
- _vm->getDisplayInfo(&disp_info);
// Initialize FPS timer callback
g_timer->installTimerProc(&fpsTimerCallback, 1000000, this);
// Create background buffer
- _bg_buf_w = disp_info.logical_w;
- _bg_buf_h = disp_info.logical_h;
- _bg_buf = (byte *)calloc(disp_info.logical_w, disp_info.logical_h);
+ _bg_buf_w = _vm->getDisplayWidth();
+ _bg_buf_h = _vm->getDisplayHeight();
+ _bg_buf = (byte *)calloc(_vm->getDisplayWidth(), _vm->getDisplayHeight());
if (_bg_buf == NULL) {
- return;
+ error("Render::Render not enough memory");
}
// Allocate temp buffer for animation decoding,
// graphics scalers (2xSaI), etc.
- tmp_w = disp_info.logical_w;
- tmp_h = disp_info.logical_h + 4; // BG unbanking requres extra rows
+ tmp_w = _vm->getDisplayWidth();
+ tmp_h = _vm->getDisplayHeight() + 4; // BG unbanking requres extra rows
tmp_bytepp = 1;
_tmp_buf = (byte *)calloc(1, tmp_w * tmp_h * tmp_bytepp);
@@ -98,7 +95,6 @@ bool Render::initialized() {
int Render::drawScene() {
SURFACE *backbuf_surface;
- GAME_DISPLAYINFO disp_info;
SCENE_INFO scene_info;
SCENE_BGINFO bg_info;
Point bg_pt;
@@ -118,7 +114,6 @@ int Render::drawScene() {
mouse_pt = _vm->getMousePos();
_vm->_scene->getBGInfo(&bg_info);
- _vm->getDisplayInfo(&disp_info);
bg_pt.x = 0;
bg_pt.y = 0;
diff --git a/saga/saga.cpp b/saga/saga.cpp
index 5ce9f8a164..e864414e69 100644
--- a/saga/saga.cpp
+++ b/saga/saga.cpp
@@ -169,9 +169,7 @@ int SagaEngine::init(GameDetector &detector) {
_previousTicks = _system->getMillis();
// Initialize graphics
- GAME_DISPLAYINFO disp_info;
- getDisplayInfo(&disp_info);
- _gfx = new Gfx(_system, disp_info.logical_w, disp_info.logical_h, detector);
+ _gfx = new Gfx(_system, _vm->getDisplayWidth(), _vm->getDisplayHeight(), detector);
// Graphics driver should be initialized before console
_console = new Console(this);
diff --git a/saga/saga.h b/saga/saga.h
index 8e531fc861..a39fcb5c6b 100644
--- a/saga/saga.h
+++ b/saga/saga.h
@@ -60,6 +60,9 @@ class Console;
class Events;
class PalAnim;
+#define GAME_LANGSTR_LIMIT 3
+#define GAME_ITE_LANG_PREFIX "ite_"
+#define GAME_LANG_EXT "lng"
#define PBOUNDS(n,max) (((n)>=(0))&&((n)<(max)))
#define MAXPATH 512
@@ -150,7 +153,7 @@ struct CLICKAREA {
Point *points;
};
-enum GAME_IDS {
+enum GameIds {
// Dreamers Guild
GID_ITE_DEMO_G = 0,
GID_ITE_DISK_G,
@@ -181,7 +184,7 @@ enum GAME_IDS {
GID_IHNM_CD_DE // reported by mld. German retail
};
-enum GAME_FILETYPES {
+enum GameFileTypes {
GAME_RESOURCEFILE = 1 << 0,
GAME_SCRIPTFILE = 1 << 1,
GAME_SOUNDFILE = 1 << 2,
@@ -193,14 +196,14 @@ enum GAME_FILETYPES {
GAME_PATCHFILE = 1 << 8
};
-enum GAME_SOUNDINFO_TYPES {
+enum GameSoundTypes {
GAME_SOUND_PCM = 0,
GAME_SOUND_VOC,
GAME_SOUND_WAV,
GAME_SOUND_VOX
};
-enum GAME_FONT_IDS {
+enum GameFontIds {
GAME_FONT_SMALL = 0,
GAME_FONT_MEDIUM,
GAME_FONT_LARGE,
@@ -210,7 +213,7 @@ enum GAME_FONT_IDS {
GAME_FONT_LARGE3
};
-enum GAME_FEATURES {
+enum GameFeatures {
GF_VOX_VOICES = 1 << 0,
GF_BIG_ENDIAN_DATA = 1 << 1,
GF_MAC_RESOURCES = 1 << 2,
@@ -218,36 +221,60 @@ enum GAME_FEATURES {
GF_WYRMKEEP = 1 << 4
};
-struct GAME_DISPLAYINFO {
- int logical_w;
- int logical_h;
- int scene_h;
-};
-
-struct GAME_SOUNDINFO {
+struct GameSoundInfo {
int res_type;
long freq;
int sample_size;
int stereo;
};
-struct GAME_FONTDESC {
+struct GameFontDescription {
uint16 font_id;
uint32 font_rn;
};
-struct GAME_SCENEDESC {
- uint32 scene_lut_rn;
- uint32 first_scene;
-};
-
-struct GAME_RESOURCEDESC {
+struct GameResourceDescription {
uint32 scene_lut_rn;
uint32 script_lut_rn;
uint32 command_panel_rn;
uint32 dialogue_panel_rn;
};
+struct GameFileDescription {
+ const char *fileName;
+ uint16 fileType;
+};
+
+struct GameDisplayInfo {
+ int logicalWidth;
+ int logicalHeight;
+ int scene_h;
+};
+
+struct GameDescription {
+ const char *name;
+ SAGAGameType gameType;
+ GameIds gameId;
+ const char *title;
+ int gd_logical_w;
+ int gd_logical_h;
+ int gd_scene_h;
+ int startSceneNumber;
+ GameResourceDescription *resourceDescription;
+ int filesCount;
+ GameFileDescription *filesDescriptions;
+ int fontsCount;
+ GameFontDescription *fontDescriptions;
+ GameSoundInfo *soundInfo;
+ uint32 features;
+
+ GameSettings toGameSettings() const {
+ GameSettings dummy = { name, title, features };
+ return dummy;
+ }
+};
+
+
inline int ticksToMSec(int tick) {
return tick * 1000 / kScriptTimeTicksPerSecond;
}
@@ -287,10 +314,16 @@ public:
int _soundEnabled;
int _musicEnabled;
+
+ char _gameLanguage[GAME_LANGSTR_LIMIT];
+ RSCFILE_CONTEXT **_gameFileContexts;
+//current game description
int _gameId;
int _gameType;
uint32 _features;
+ int _gameNumber;
+ GameDescription *_gameDescription;
SndRes *_sndRes;
Sound *_sound;
@@ -351,18 +384,23 @@ public:
public:
int initGame(void);
RSCFILE_CONTEXT *getFileContext(uint16 type, int param);
- int getFontInfo(GAME_FONTDESC **, int *);
- const GAME_RESOURCEDESC getResourceInfo(void);
- const GAME_SOUNDINFO getSoundInfo(void);
- int getDisplayInfo(GAME_DISPLAYINFO *disp_info);
- int getSceneInfo(GAME_SCENEDESC *);
- int getDisplayWidth();
- int getDisplayHeight();
+public:
+ const GameResourceDescription *getResourceDescription() { return _gameDescription->resourceDescription; }
+ const GameSoundInfo *getSoundInfo() { return _gameDescription->soundInfo; }
+ const GameFontDescription *getFontDescription(int index) {
+ assert(index < _gameDescription->fontsCount);
+ return &_gameDescription->fontDescriptions[index];
+ }
+ int getFontsCount() const { return _gameDescription->fontsCount; }
+
+ int getStartSceneNumber() { return _gameDescription->startSceneNumber; }
+ int getDisplayWidth() { return _gameDescription->gd_logical_w; }
+ int getDisplayHeight() { return _gameDescription->gd_logical_h;}
int getStatusYOffset();
int getPathYOffset();
private:
int loadLanguage(void);
- int loadGame(int game_n_p);
+ int loadGame(int gameNumber);
};
// FIXME: Global var. We use it until everything will be turned into objects
diff --git a/saga/scene.cpp b/saga/scene.cpp
index 5a9d6d0247..f92e018cee 100644
--- a/saga/scene.cpp
+++ b/saga/scene.cpp
@@ -51,14 +51,11 @@ static int initSceneDoors[SCENE_DOORS_MAX] = {
};
Scene::Scene(SagaEngine *vm) : _vm(vm), _initialized(false) {
- GAME_SCENEDESC gs_desc;
byte *scene_lut_p;
size_t scene_lut_len;
int result;
int i;
- // Load game-specific scene data
- _vm->getSceneInfo(&gs_desc);
// Load scene module resource context
_sceneContext = _vm->getFileContext(GAME_RESOURCEFILE, 0);
@@ -69,8 +66,8 @@ Scene::Scene(SagaEngine *vm) : _vm(vm), _initialized(false) {
// Load scene lookup table
- debug(0, "Loading scene LUT from resource %u.", gs_desc.scene_lut_rn);
- result = RSC_LoadResource(_sceneContext, gs_desc.scene_lut_rn, &scene_lut_p, &scene_lut_len);
+ debug(0, "Loading scene LUT from resource %u.", _vm->getResourceDescription()->scene_lut_rn);
+ result = RSC_LoadResource(_sceneContext, _vm->getResourceDescription()->scene_lut_rn, &scene_lut_p, &scene_lut_len);
if (result != SUCCESS) {
warning("Scene::Scene(): Error: couldn't load scene LUT");
return;
@@ -95,9 +92,7 @@ Scene::Scene(SagaEngine *vm) : _vm(vm), _initialized(false) {
free(scene_lut_p);
- if (gs_desc.first_scene != 0) {
- _firstScene = gs_desc.first_scene;
- }
+ _firstScene = _vm->getStartSceneNumber();
debug(0, "First scene set to %d.", _firstScene);
@@ -320,7 +315,6 @@ void Scene::getSlopes(int &beginSlope, int &endSlope) {
}
int Scene::getBGInfo(SCENE_BGINFO *bginfo) {
- GAME_DISPLAYINFO di;
int x, y;
assert(_initialized);
@@ -331,16 +325,15 @@ int Scene::getBGInfo(SCENE_BGINFO *bginfo) {
bginfo->bg_h = _bg.h;
bginfo->bg_p = _bg.p;
- _vm->getDisplayInfo(&di);
x = 0;
y = 0;
- if (_bg.w < di.logical_w) {
- x = (di.logical_w - _bg.w) / 2;
+ if (_bg.w < _vm->getDisplayWidth()) {
+ x = (_vm->getDisplayWidth() - _bg.w) / 2;
}
- if (_bg.h < di.scene_h) {
- y = (di.scene_h - _bg.h) / 2;
+ if (_bg.h < _vm->getStatusYOffset()) {
+ y = (_vm->getStatusYOffset() - _bg.h) / 2;
}
bginfo->bg_x = x;
@@ -902,23 +895,22 @@ int Scene::processSceneResources() {
}
int Scene::draw(SURFACE *dst_s) {
- GAME_DISPLAYINFO disp_info;
BUFFER_INFO buf_info;
Point bg_pt;
assert(_initialized);
_vm->_render->getBufferInfo(&buf_info);
- _vm->getDisplayInfo(&disp_info);
bg_pt.x = 0;
bg_pt.y = 0;
- if (_vm->_scene->getFlags() & kSceneFlagISO)
+ if (_vm->_scene->getFlags() & kSceneFlagISO) {
_vm->_isoMap->draw(dst_s);
- else
- bufToSurface(dst_s, buf_info.bg_buf, disp_info.logical_w,
- MAX(disp_info.scene_h, _bg.h), NULL, &bg_pt);
+ } else {
+ bufToSurface(dst_s, buf_info.bg_buf, _vm->getDisplayWidth(),
+ MAX(_vm->getStatusYOffset(), _bg.h), NULL, &bg_pt);
+ }
return SUCCESS;
}
diff --git a/saga/script.cpp b/saga/script.cpp
index 260c4f8339..06b889ec37 100644
--- a/saga/script.cpp
+++ b/saga/script.cpp
@@ -37,7 +37,6 @@ namespace Saga {
// Initializes the scripting module.
// Loads script resource look-up table, initializes script data system
Script::Script() {
- GAME_RESOURCEDESC gr_desc;
RSCFILE_CONTEXT *s_lut_ctxt;
RSCFILE_CONTEXT *resourceContext;
byte *rsc_ptr;
@@ -71,7 +70,6 @@ Script::Script() {
_dataBuf[i].data = NULL;
}
- gr_desc = _vm->getResourceInfo();
debug(0, "Initializing scripting subsystem");
// Load script resource file context
@@ -86,8 +84,8 @@ Script::Script() {
error("Couldn't get resource file context");
}
- debug(0, "Loading script LUT from resource %u.", gr_desc.script_lut_rn);
- result = RSC_LoadResource(s_lut_ctxt, gr_desc.script_lut_rn, &rsc_ptr, &rsc_len);
+ debug(0, "Loading script LUT from resource %u.", _vm->getResourceDescription()->script_lut_rn);
+ result = RSC_LoadResource(s_lut_ctxt, _vm->getResourceDescription()->script_lut_rn, &rsc_ptr, &rsc_len);
if (result != SUCCESS) {
error("Error: Couldn't load script resource look-up table");
}
diff --git a/saga/sfuncs.cpp b/saga/sfuncs.cpp
index eb2e3c9c30..9562763674 100644
--- a/saga/sfuncs.cpp
+++ b/saga/sfuncs.cpp
@@ -1005,7 +1005,6 @@ static TEXTLIST_ENTRY *placardTextEntry;
// Param1: string rid
int Script::sfPlacard(SCRIPTFUNC_PARAMS) {
int stringId;
- GAME_DISPLAYINFO disp;
SURFACE *back_buf = _vm->_gfx->getBackBuffer();
static PALENTRY cur_pal[PAL_ENTRIES];
PALENTRY *pal;
@@ -1017,8 +1016,6 @@ int Script::sfPlacard(SCRIPTFUNC_PARAMS) {
_vm->_interface->rememberMode();
_vm->_interface->setMode(kPanelPlacard);
- _vm->getDisplayInfo(&disp);
-
stringId = thread->pop();
event.type = ONESHOT_EVENT;
@@ -1057,9 +1054,9 @@ int Script::sfPlacard(SCRIPTFUNC_PARAMS) {
event.data = back_buf;
event.param = 138;
event.param2 = 0;
- event.param3 = disp.scene_h;
+ event.param3 = _vm->getStatusYOffset();
event.param4 = 0;
- event.param5 = disp.logical_w;
+ event.param5 = _vm->getDisplayWidth();
q_event = _vm->_events->chain(q_event, &event);
@@ -1076,8 +1073,8 @@ int Script::sfPlacard(SCRIPTFUNC_PARAMS) {
text_entry.color = _vm->_gfx->getWhite();
text_entry.effect_color = _vm->_gfx->getBlack();
- text_entry.text_x = disp.logical_w / 2;
- text_entry.text_y = (disp.scene_h - _vm->_font->getHeight(MEDIUM_FONT_ID)) / 2;
+ text_entry.text_x = _vm->getDisplayWidth() / 2;
+ text_entry.text_y = (_vm->getStatusYOffset() - _vm->_font->getHeight(MEDIUM_FONT_ID)) / 2;
text_entry.font_id = MEDIUM_FONT_ID;
text_entry.flags = FONT_OUTLINE | FONT_CENTERED;
text_entry.string = getScriptString(stringId);
diff --git a/saga/sndres.cpp b/saga/sndres.cpp
index 9757e3217d..de47cafc09 100644
--- a/saga/sndres.cpp
+++ b/saga/sndres.cpp
@@ -51,7 +51,7 @@ SndRes::SndRes(SagaEngine *vm) : _vm(vm) {
}
// Grab sound resource information for the current game
- _snd_info = _vm->getSoundInfo();
+ _snd_info = *_vm->getSoundInfo();
_init = 1;
}
diff --git a/saga/sndres.h b/saga/sndres.h
index 5b0151504b..3ba3d3a712 100644
--- a/saga/sndres.h
+++ b/saga/sndres.h
@@ -51,7 +51,7 @@ public:
RSCFILE_CONTEXT *_sfx_ctxt;
RSCFILE_CONTEXT *_voice_ctxt;
- GAME_SOUNDINFO _snd_info;
+ GameSoundInfo _snd_info;
SagaEngine *_vm;
};