aboutsummaryrefslogtreecommitdiff
path: root/saga
diff options
context:
space:
mode:
authorAndrew Kurushin2005-01-11 21:10:36 +0000
committerAndrew Kurushin2005-01-11 21:10:36 +0000
commit244b227b19b6bec659e4c00e2d7aa9596978cbe5 (patch)
treef7a88160f68d6f4da5e5580ae13ce9bb382d7795 /saga
parentf1026ce3eb0bf4ad4e68987e4952dff141ccf331 (diff)
downloadscummvm-rg350-244b227b19b6bec659e4c00e2d7aa9596978cbe5.tar.gz
scummvm-rg350-244b227b19b6bec659e4c00e2d7aa9596978cbe5.tar.bz2
scummvm-rg350-244b227b19b6bec659e4c00e2d7aa9596978cbe5.zip
- remove game.h & image.h
- all display information of current game goes to SagaEngine - remove GameFontIds - hide SagaEngine _gameId,_gameType & etc with methods getGameId(), getGameType() svn-id: r16545
Diffstat (limited to 'saga')
-rw-r--r--saga/actor.cpp14
-rw-r--r--saga/animation.cpp12
-rw-r--r--saga/animation.h2
-rw-r--r--saga/font.cpp20
-rw-r--r--saga/font.h2
-rw-r--r--saga/game.cpp200
-rw-r--r--saga/image.cpp3
-rw-r--r--saga/input.cpp2
-rw-r--r--saga/interface.cpp121
-rw-r--r--saga/interface.h97
-rw-r--r--saga/ite_introproc.cpp12
-rw-r--r--saga/music.cpp8
-rw-r--r--saga/palanim.cpp2
-rw-r--r--saga/rscfile.cpp4
-rw-r--r--saga/saga.cpp57
-rw-r--r--saga/saga.h105
-rw-r--r--saga/scene.cpp15
-rw-r--r--saga/sfuncs.cpp4
-rw-r--r--saga/sndres.cpp8
-rw-r--r--saga/sound.cpp2
-rw-r--r--saga/sprite.cpp6
-rw-r--r--saga/sthread.cpp2
22 files changed, 299 insertions, 399 deletions
diff --git a/saga/actor.cpp b/saga/actor.cpp
index 77625d3871..462c65ddd1 100644
--- a/saga/actor.cpp
+++ b/saga/actor.cpp
@@ -136,7 +136,7 @@ Actor::Actor(SagaEngine *vm) : _vm(vm) {
ActorData *actor;
debug(9, "Actor::Actor()");
- if (_vm->_gameType == GType_IHNM) {
+ if (_vm->getGameType() == GType_IHNM) {
warning("Actors aren't implemented for IHNM yet");
return;
}
@@ -155,7 +155,7 @@ Actor::Actor(SagaEngine *vm) : _vm(vm) {
_centerActor = _protagonist = NULL;
_lastTickMsec = 0;
- _yCellCount = _vm->getStatusYOffset() + 1;
+ _yCellCount = _vm->getSceneHeight();
_xCellCount = _vm->getDisplayWidth();
_pathCell = (int8*) malloc(_yCellCount * _xCellCount * sizeof(*_pathCell));
@@ -163,8 +163,8 @@ Actor::Actor(SagaEngine *vm) : _vm(vm) {
_pathRect.left = 0;
_pathRect.right = _vm->getDisplayWidth();
- _pathRect.top = _vm->getPathYOffset();
- _pathRect.bottom = _vm->getStatusYOffset();
+ _pathRect.top = _vm->getDisplayInfo().pathStartY;
+ _pathRect.bottom = _vm->getSceneHeight();
// Get actor resource file context
_actorContext = _vm->getFileContext(GAME_RESOURCEFILE, 0);
@@ -395,7 +395,7 @@ bool Actor::validFollowerLocation(const ActorLocation &location) {
location.toScreenPointXY(point);
if ((point.x < 5) || (point.x >= _vm->getDisplayWidth() - 5) ||
- (point.y < 0) || (point.y > _vm->getStatusYOffset())) {
+ (point.y < 0) || (point.y > _vm->getSceneHeight())) {
return false;
}
@@ -410,7 +410,7 @@ void Actor::updateActorsScene() {
ActorLocation possibleLocation;
Point delta;
- if (_vm->_gameType == GType_IHNM) {
+ if (_vm->getGameType() == GType_IHNM) {
warning("Actors aren't implemented for IHNM yet");
return;
}
@@ -883,7 +883,7 @@ void Actor::calcActorScreenPosition(ActorData *actor) {
if (_vm->_scene->getFlags() & kSceneFlagISO) {
//todo: it
} else {
- middle = _vm->getStatusYOffset() - actor->location.y / ACTOR_LMULT;
+ middle = _vm->getSceneHeight() - actor->location.y / ACTOR_LMULT;
_vm->_scene->getSlopes(beginSlope, endSlope);
diff --git a/saga/animation.cpp b/saga/animation.cpp
index a2b8181cab..998351e5a3 100644
--- a/saga/animation.cpp
+++ b/saga/animation.cpp
@@ -94,7 +94,7 @@ int Anim::load(const byte *anim_resdata, size_t anim_resdata_len, uint16 *anim_i
new_anim->maxframe = ah.maxframe;
new_anim->loopframe = ah.loopframe;
- if (_vm->_gameType == GType_ITE) {
+ if (_vm->getGameType() == GType_ITE) {
// Cache frame offsets
new_anim->frame_offsets = (size_t *)malloc((new_anim->maxframe + 1) * sizeof(*new_anim->frame_offsets));
if (new_anim->frame_offsets == NULL) {
@@ -200,7 +200,7 @@ int Anim::play(uint16 anim_id, int vector_time, bool playing) {
if (anim->completed < anim->cycles) {
frame = anim->current_frame;
- if (_vm->_gameType == GType_ITE) {
+ if (_vm->getGameType() == GType_ITE) {
// FIXME: if start > 0, then this works incorrectly
result = ITE_DecodeFrame(anim->resdata, anim->resdata_len, anim->frame_offsets[frame], display_buf,
_vm->getDisplayWidth() * _vm->getDisplayHeight());
@@ -401,7 +401,7 @@ int Anim::freeId(uint16 anim_id) {
return FAILURE;
}
- if (_vm->_gameType == GType_ITE) {
+ if (_vm->getGameType() == GType_ITE) {
free(anim->frame_offsets);
anim->frame_offsets = NULL;
}
@@ -482,7 +482,7 @@ int Anim::ITE_DecodeFrame(const byte *resdata, size_t resdata_len, size_t frame_
fh.x_start = readS.readUint16BE();
- if (_vm->_features & GF_BIG_ENDIAN_DATA)
+ if (_vm->getFeatures() & GF_BIG_ENDIAN_DATA)
fh.y_start = readS.readUint16BE();
else
fh.y_start = readS.readByte();
@@ -537,7 +537,7 @@ int Anim::ITE_DecodeFrame(const byte *resdata, size_t resdata_len, size_t frame_
case SAGA_FRAME_ROW_END: // End of row
x_vector = readS.readSint16BE();
- if (_vm->_features & GF_BIG_ENDIAN_DATA)
+ if (_vm->getFeatures() & GF_BIG_ENDIAN_DATA)
new_row = readS.readSint16BE();
else
new_row = readS.readByte();
@@ -877,7 +877,7 @@ int Anim::getFrameOffset(const byte *resdata, size_t resdata_len, uint16 find_fr
break;
case SAGA_FRAME_ROW_END: // End of row marker
readS.readSint16BE();
- if (_vm->_features & GF_BIG_ENDIAN_DATA)
+ if (_vm->getFeatures() & GF_BIG_ENDIAN_DATA)
readS.readSint16BE();
else
readS.readByte();
diff --git a/saga/animation.h b/saga/animation.h
index 7e8f691f40..b1f6cd405b 100644
--- a/saga/animation.h
+++ b/saga/animation.h
@@ -33,7 +33,7 @@ namespace Saga {
#define MAX_ANIMATIONS 7
#define DEFAULT_FRAME_TIME 140
-#define SAGA_FRAME_HEADER_LEN (_vm->_features & GF_MAC_RESOURCES ? 13 : 12)
+#define SAGA_FRAME_HEADER_LEN (_vm->getFeatures() & GF_MAC_RESOURCES ? 13 : 12)
#define SAGA_FRAME_START 0xF
#define SAGA_FRAME_END 0x3F
diff --git a/saga/font.cpp b/saga/font.cpp
index aca642b064..b55d33f973 100644
--- a/saga/font.cpp
+++ b/saga/font.cpp
@@ -43,15 +43,15 @@ Font::Font(SagaEngine *vm) : _vm(vm), _initialized(false) {
assert(_vm->getFontsCount() > 0);
- _nFonts = _vm->getFontsCount();
+ _nFonts = 0;
- _fonts = (FONT **)malloc(_nFonts * sizeof(*_fonts));
+ _fonts = (FONT **)malloc(_vm->getFontsCount() * sizeof(*_fonts));
if (_fonts == NULL) {
error("Font::Font(): Memory allocation failure.");
}
- for (i = 0; i < _nFonts; i++) {
- loadFont(_vm->getFontDescription(i)->font_rn, _vm->getFontDescription(i)->font_id);
+ for (i = 0; i < _vm->getFontsCount(); i++) {
+ loadFont(_vm->getFontDescription(i)->fontResourceId);
}
_initialized = true;
@@ -80,7 +80,7 @@ Font::~Font(void) {
*/
}
-int Font::loadFont(uint32 font_rn, int font_id) {
+int Font::loadFont(uint32 fontResourceId) {
FONT_HEADER fh;
FONT *font;
FONT_STYLE *normal_font;
@@ -89,12 +89,8 @@ int Font::loadFont(uint32 font_rn, int font_id) {
int nbits;
int c;
- if ((font_id < 0) || (font_id >= _nFonts)) {
- return FAILURE;
- }
-
// Load font resource
- if (RSC_LoadResource(_fontContext, font_rn, &fontres_p, &fontres_len) != SUCCESS) {
+ if (RSC_LoadResource(_fontContext, fontResourceId, &fontres_p, &fontres_len) != SUCCESS) {
error("Font::loadFont(): Couldn't load font resource.");
}
@@ -116,7 +112,7 @@ int Font::loadFont(uint32 font_rn, int font_id) {
fh.c_width = readS.readUint16();
fh.row_length = readS.readUint16();
- debug(1, "Font::loadFont(): Reading font resource #%d...", font_rn);
+ debug(1, "Font::loadFont(): Reading fontResourceId %d...", fontResourceId);
debug(2, "Character width: %d", fh.c_width);
debug(2, "Character height: %d", fh.c_height);
@@ -165,7 +161,7 @@ int Font::loadFont(uint32 font_rn, int font_id) {
font->outline_loaded = 1;
// Set font data
- _fonts[font_id] = font;
+ _fonts[_nFonts++] = font;
return SUCCESS;
}
diff --git a/saga/font.h b/saga/font.h
index 8e7947ee3d..42bf6c3933 100644
--- a/saga/font.h
+++ b/saga/font.h
@@ -108,7 +108,7 @@ class Font {
private:
- int loadFont(uint32 font_rn, int font_id);
+ int loadFont(uint32 fontResourceId);
FONT_STYLE *createOutline(FONT_STYLE * src_font);
int outFont(FONT_STYLE *font, SURFACE * ds, const char *draw_str, size_t draw_str_ct,
int text_x, int text_y, int color, int flags);
diff --git a/saga/game.cpp b/saga/game.cpp
index 00fedbd986..c85b1f8f01 100644
--- a/saga/game.cpp
+++ b/saga/game.cpp
@@ -36,14 +36,46 @@
#include "saga/interface.h"
#include "saga/scene.h"
-#include "saga/game.h"
-
namespace Saga {
static int detectGame(const FSList &fslist, bool mode = false);
-// Inherit the Earth - DOS Demo version
+// ITE section
+static GameDisplayInfo ITE_DisplayInfo = {
+ 320, 200,
+
+ 35,
+ 137,
+
+ 137,
+ 320,
+ 12,
+ 2,
+ 186,
+ 15,
+
+ 147,
+ 15,
+ 96,
+
+ 5, 4,
+ 274, 4,
+
+ 181, 155,
+ 2, 4,
+ 29, 20,
+ 1, 0,
+ 3, 1
+};
+
+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
+};
+// Inherit the Earth - DOS Demo version
static GameFileDescription ITEDEMO_GameFiles[] = {
{"ite.rsc", GAME_RESOURCEFILE},
{"ite.dmo", GAME_DEMOFILE},
@@ -52,8 +84,8 @@ static GameFileDescription ITEDEMO_GameFiles[] = {
};
static GameFontDescription ITEDEMO_GameFonts[] = {
- {GAME_FONT_SMALL, 0},
- {GAME_FONT_MEDIUM, 1}
+ {0},
+ {1}
};
static GameSoundInfo ITEDEMO_GameSound = {
@@ -61,8 +93,8 @@ static GameSoundInfo ITEDEMO_GameSound = {
};
static GameFontDescription ITEMACDEMO_GameFonts[] = {
- {GAME_FONT_MEDIUM, 0},
- {GAME_FONT_SMALL, 2}
+ {0},
+ {2}
};
// Inherit the Earth - Wyrmkeep Win32 Demo version
@@ -92,8 +124,8 @@ static GameFileDescription ITELINCD_GameFiles[] = {
};
static GameFontDescription ITEWINDEMO_GameFonts[] = {
- {GAME_FONT_MEDIUM, 0},
- {GAME_FONT_SMALL, 2}
+ {0},
+ {2}
};
// Inherit the Earth - Mac Wyrmkeep version
@@ -113,16 +145,9 @@ static GameFileDescription ITEDISK_GameFiles[] = {
};
static GameFontDescription ITEDISK_GameFonts[] = {
- {GAME_FONT_MEDIUM, 0},
- {GAME_FONT_LARGE, 1},
- {GAME_FONT_SMALL, 2}
-};
-
-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
+ {2},
+ {0},
+ {1}
};
static GameSoundInfo ITE_GameSound = {
@@ -138,9 +163,9 @@ static GameFileDescription ITECD_GameFiles[] = {
};
static GameFontDescription ITECD_GameFonts[] = {
- {GAME_FONT_MEDIUM, 0},
- {GAME_FONT_LARGE, 1},
- {GAME_FONT_SMALL, 2}
+ {2},
+ {0},
+ {1}
};
static GameSoundInfo ITECD_GameSound = {
@@ -150,6 +175,42 @@ static GameSoundInfo ITECD_GameSound = {
0
};
+// IHNM section
+
+static GameDisplayInfo IHNM_DisplayInfo = {
+ 640, 480,
+
+ 0, //TODO: correct pathStartY
+ 304, //TODO: correct sceneHeight
+
+ 304,
+ 640,
+ 24,
+ 8,
+ 186,
+ 11,
+
+ 147,
+ 15,
+ 96,
+
+ 5, 4,
+ -1, -1,
+
+ 0, 0, //TODO: fill it all
+ 0, 0,
+ 0, 0,
+ 0, 0,
+ 0, 0
+};
+
+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
+};
+
// I Have No Mouth and I Must Scream - Demo version
static GameFileDescription IHNMDEMO_GameFiles[] = {
{"scream.res", GAME_RESOURCEFILE},
@@ -192,20 +253,13 @@ static GameFileDescription IHNMCDDE_GameFiles[] = {
};
static GameFontDescription IHNMCD_GameFonts[] = {
- {GAME_FONT_MEDIUM, 2},
- {GAME_FONT_LARGE, 3},
- {GAME_FONT_SMALL, 4},
- {GAME_FONT_SMALL2, 5},
- {GAME_FONT_MEDIUM2, 6},
- {GAME_FONT_LARGE2, 7},
- {GAME_FONT_LARGE3, 8}
-};
-
-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
+ {2},
+ {3},
+ {4},
+ {5},
+ {6},
+ {7},
+ {8}
};
static GameSoundInfo IHNM_GameSound = {
@@ -332,8 +386,7 @@ static GameDescription gameDescriptions[] = {
GType_ITE,
GID_ITE_DEMO_G, // Game id
"Inherit the Earth (DOS Demo)", // Game title
- 320, 200, // Logical resolution
- 137, // Scene viewport height
+ &ITE_DisplayInfo,
ITE_DEFAULT_SCENE, // Starting scene number
&ITE_Resources,
ARRAYSIZE(ITEDEMO_GameFiles), // Game datafiles
@@ -350,8 +403,7 @@ static GameDescription gameDescriptions[] = {
GType_ITE,
GID_ITE_MACDEMO2,
"Inherit the Earth (MAC Demo)",
- 320, 200,
- 137,
+ &ITE_DisplayInfo,
ITE_DEFAULT_SCENE,
&ITE_Resources,
ARRAYSIZE(ITEWINDEMO_GameFiles),
@@ -368,8 +420,7 @@ static GameDescription gameDescriptions[] = {
GType_ITE,
GID_ITE_MACDEMO1,
"Inherit the Earth (early MAC Demo)",
- 320, 200,
- 137,
+ &ITE_DisplayInfo,
ITE_DEFAULT_SCENE,
&ITE_Resources,
ARRAYSIZE(ITEWINDEMO_GameFiles),
@@ -386,8 +437,7 @@ static GameDescription gameDescriptions[] = {
GType_ITE,
GID_ITE_MACCD,
"Inherit the Earth (MAC CD)",
- 320, 200,
- 137,
+ &ITE_DisplayInfo,
ITE_DEFAULT_SCENE,
&ITE_Resources,
ARRAYSIZE(ITEMACCD_GameFiles),
@@ -405,8 +455,7 @@ static GameDescription gameDescriptions[] = {
GType_ITE,
GID_ITE_LINDEMO,
"Inherit the Earth (Linux Demo)",
- 320, 200,
- 137,
+ &ITE_DisplayInfo,
ITE_DEFAULT_SCENE,
&ITE_Resources,
ARRAYSIZE(ITELINDEMO_GameFiles),
@@ -423,8 +472,7 @@ static GameDescription gameDescriptions[] = {
GType_ITE,
GID_ITE_WINDEMO2,
"Inherit the Earth (Win32 Demo)",
- 320, 200,
- 137,
+ &ITE_DisplayInfo,
ITE_DEFAULT_SCENE,
&ITE_Resources,
ARRAYSIZE(ITEWINDEMO_GameFiles),
@@ -441,8 +489,7 @@ static GameDescription gameDescriptions[] = {
GType_ITE,
GID_ITE_WINDEMO1,
"Inherit the Earth (early Win32 Demo)",
- 320, 200,
- 137,
+ &ITE_DisplayInfo,
ITE_DEFAULT_SCENE,
&ITE_Resources,
ARRAYSIZE(ITEWINDEMO_GameFiles),
@@ -460,8 +507,7 @@ static GameDescription gameDescriptions[] = {
GType_ITE,
GID_ITE_LINCD,
"Inherit the Earth (Linux CD Version)",
- 320, 200,
- 137,
+ &ITE_DisplayInfo,
ITE_DEFAULT_SCENE,
&ITE_Resources,
ARRAYSIZE(ITELINCD_GameFiles),
@@ -478,8 +524,7 @@ static GameDescription gameDescriptions[] = {
GType_ITE,
GID_ITE_CD_G,
"Inherit the Earth (DOS CD Version)",
- 320, 200,
- 137,
+ &ITE_DisplayInfo,
ITE_DEFAULT_SCENE,
&ITE_Resources,
ARRAYSIZE(ITECD_GameFiles),
@@ -496,8 +541,7 @@ static GameDescription gameDescriptions[] = {
GType_ITE,
GID_ITE_CD_DE,
"Inherit the Earth (De DOS CD Version)",
- 320, 200,
- 137,
+ &ITE_DisplayInfo,
ITE_DEFAULT_SCENE,
&ITE_Resources,
ARRAYSIZE(ITECD_GameFiles),
@@ -514,8 +558,7 @@ static GameDescription gameDescriptions[] = {
GType_ITE,
GID_ITE_CD,
"Inherit the Earth (DOS/Win32 CD Version)",
- 320, 200,
- 137,
+ &ITE_DisplayInfo,
ITE_DEFAULT_SCENE,
&ITE_Resources,
ARRAYSIZE(ITECD_GameFiles),
@@ -532,8 +575,7 @@ static GameDescription gameDescriptions[] = {
GType_ITE,
GID_ITE_DISK_DE,
"Inherit the Earth (De DOS Floppy)",
- 320, 200,
- 137,
+ &ITE_DisplayInfo,
ITE_DEFAULT_SCENE,
&ITE_Resources,
ARRAYSIZE(ITEDISK_GameFiles),
@@ -550,8 +592,7 @@ static GameDescription gameDescriptions[] = {
GType_ITE,
GID_ITE_DISK_G,
"Inherit the Earth (DOS Floppy)",
- 320, 200,
- 137,
+ &ITE_DisplayInfo,
ITE_DEFAULT_SCENE,
&ITE_Resources,
ARRAYSIZE(ITEDISK_GameFiles),
@@ -568,8 +609,7 @@ static GameDescription gameDescriptions[] = {
GType_IHNM,
GID_IHNM_DEMO,
"I Have No Mouth and I Must Scream (DOS Demo)",
- 640, 480,
- 7,
+ &IHNM_DisplayInfo,
0,
&IHNM_Resources,
ARRAYSIZE(IHNMDEMO_GameFiles),
@@ -586,8 +626,7 @@ static GameDescription gameDescriptions[] = {
GType_IHNM,
GID_IHNM_CD,
"I Have No Mouth and I Must Scream (DOS)",
- 640, 480,
- 7,
+ &IHNM_DisplayInfo,
152,
&IHNM_Resources,
ARRAYSIZE(IHNMCD_GameFiles),
@@ -604,8 +643,7 @@ static GameDescription gameDescriptions[] = {
GType_IHNM,
GID_IHNM_CD_DE,
"I Have No Mouth and I Must Scream (DE DOS)",
- 640, 480,
- 7,
+ &IHNM_DisplayInfo,
152,
&IHNM_Resources,
ARRAYSIZE(IHNMCDDE_GameFiles),
@@ -630,7 +668,6 @@ int SagaEngine::initGame(void) {
warning("Error loading game resource files.");
return FAILURE;
}
-
// Load dialogue file
loadLanguage();
@@ -642,7 +679,7 @@ int SagaEngine::loadLanguage(void) {
File test_file;
- if (_gameType == GType_ITE) {
+ if (getGameType() == 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);
@@ -825,14 +862,11 @@ int SagaEngine::loadGame(int gameNumber) {
_gameNumber = gameNumber;
_gameDescription = &gameDescriptions[gameNumber];
-
- _gameId = _gameDescription->gameId;
- _gameType = _gameDescription->gameType;
- _features = _gameDescription->features;
+ _gameDisplayInfo = *_gameDescription->gameDisplayInfo;
gameFileCount = _gameDescription->filesCount;
- _gameFileContexts = (RSCFILE_CONTEXT **)malloc(gameFileCount * sizeof(*_gameFileContexts));
+ _gameFileContexts = (RSCFILE_CONTEXT **)realloc(_gameFileContexts, gameFileCount * sizeof(*_gameFileContexts));
//TODO: on exit - FREE!
if (_gameFileContexts == NULL) {
error("SagaEngine::loadGame not enough memory");
@@ -854,20 +888,4 @@ int SagaEngine::loadGame(int gameNumber) {
return SUCCESS;
}
-int SagaEngine::getPathYOffset() { //fixme: should be in GameDesc
- if (_gameType == GType_ITE) {
- return 35;
- } else {
- return 35; //fixme i don't know exact value
- }
-}
-
-int SagaEngine::getStatusYOffset() { //fixme: should be in GameDesc
- if (_gameType == GType_ITE) {
- return ITE_STATUS_Y;
- } else {
- return IHNM_STATUS_Y;
- }
-}
-
} // End of namespace Saga
diff --git a/saga/image.cpp b/saga/image.cpp
index c50d3479c4..379eae2cfc 100644
--- a/saga/image.cpp
+++ b/saga/image.cpp
@@ -24,7 +24,6 @@
// SAGA Image resource management routines
#include "saga/saga.h"
-#include "saga/image.h"
#include "saga/stream.h"
namespace Saga {
@@ -92,7 +91,7 @@ int SagaEngine::decodeBGImage(const byte *image_data, size_t image_size,
unbankBGImage(out_buf, decode_buf, hdr.width, hdr.height);
// For some reason bg images in IHNM are upside down
- if (_vm->_gameType == GType_IHNM) {
+ if (_vm->getGameType() == GType_IHNM) {
flipImage(out_buf, hdr.width, hdr.height);
}
diff --git a/saga/input.cpp b/saga/input.cpp
index e63e362e9f..5c032da81a 100644
--- a/saga/input.cpp
+++ b/saga/input.cpp
@@ -111,7 +111,7 @@ int SagaEngine::processInput() {
imousePt = _mousePos;
break;
case OSystem::EVENT_QUIT:
- g_system->quit();
+ _system->quit();
break;
default:
break;
diff --git a/saga/interface.cpp b/saga/interface.cpp
index 72a9781828..d24dad7744 100644
--- a/saga/interface.cpp
+++ b/saga/interface.cpp
@@ -50,37 +50,6 @@ static VERB_DATA I_VerbData[] = {
{I_VERB_GIVE, "verb_give", "Give", kVerbGive}
};
-static INTERFACE_DESC ITE_interface = {
- ITE_STATUS_Y,
- ITE_STATUS_W,
- ITE_STATUS_H,
- ITE_STATUS_TEXT_Y,
- ITE_STATUS_TXTCOL,
- ITE_STATUS_BGCOL,
-
- ITE_CMD_TEXT_COL,
- ITE_CMD_TEXT_SHADOWCOL,
- ITE_CMD_TEXT_HILITECOL,
-
- COMMAND_DEFAULT_BUTTON,
-
- ITE_LPORTRAIT_X,
- ITE_LPORTRAIT_Y,
- ITE_RPORTRAIT_X,
- ITE_RPORTRAIT_Y,
-
- ITE_INVENTORY_XSTART,
- ITE_INVENTORY_YSTART,
- ITE_INVENTORY_ROWS,
- ITE_INVENTORY_COLUMNS,
- ITE_INVENTORY_ICON_WIDTH,
- ITE_INVENTORY_ICON_HEIGHT,
- ITE_INVENTORY_ICON_XOFFSET,
- ITE_INVENTORY_ICON_YOFFSET,
- ITE_INVENTORY_XSPACING,
- ITE_INVENTORY_YSPACING
-};
-
static InterfaceButton ITEMainPanel[] = {
{5, 4, 46, 47, "Portrait", 0, 0, BUTTON_NONE, 0}, //TODO: remove?
// "Walk To" and "Talk To" share button sprites
@@ -105,36 +74,6 @@ static InterfaceButton ITEMainPanel[] = {
{306, 41, 314, 45, "InvDown", 0, 0, BUTTON_NONE, 0}
};
-static INTERFACE_DESC IHNM_interface = {
- IHNM_STATUS_Y,
- IHNM_STATUS_W,
- IHNM_STATUS_H,
- IHNM_STATUS_TEXT_Y,
- IHNM_STATUS_TXTCOL,
- IHNM_STATUS_BGCOL,
-
- IHNM_CMD_TEXT_COL,
- IHNM_CMD_TEXT_SHADOWCOL,
- IHNM_CMD_TEXT_HILITECOL,
-
- COMMAND_DEFAULT_BUTTON,
-
- IHNM_LPORTRAIT_X,
- IHNM_LPORTRAIT_Y,
- IHNM_RPORTRAIT_X,
- IHNM_RPORTRAIT_Y,
-
- IHNM_INVENTORY_XSTART,
- IHNM_INVENTORY_YSTART,
- IHNM_INVENTORY_ROWS,
- IHNM_INVENTORY_COLUMNS,
- IHNM_INVENTORY_ICON_WIDTH,
- IHNM_INVENTORY_ICON_HEIGHT,
- IHNM_INVENTORY_ICON_XOFFSET,
- IHNM_INVENTORY_ICON_YOFFSET,
- IHNM_INVENTORY_XSPACING,
- IHNM_INVENTORY_YSPACING
-};
static InterfaceButton IHNMMainPanel[] = {
{5, 4, 46, 47, "Portrait", 0, 0, 0, 0}
@@ -179,17 +118,15 @@ Interface::Interface(SagaEngine *vm) : _vm(vm), _initialized(false) {
}
// Initialize interface data by game type
- if (_vm->_gameType == GType_ITE) {
+ if (_vm->getGameType() == GType_ITE) {
// Load Inherit the Earth interface desc
_mainPanel.buttons = ITEMainPanel;
_mainPanel.nbuttons = ARRAYSIZE(ITEMainPanel);
- _iDesc = ITE_interface;
- } else if (_vm->_gameType == GType_IHNM) {
+ } else if (_vm->getGameType() == GType_IHNM) {
// Load I Have No Mouth interface desc
_mainPanel.buttons = IHNMMainPanel;
_mainPanel.nbuttons = ARRAYSIZE(IHNMMainPanel);
- _iDesc = IHNM_interface;
} else {
return;
}
@@ -229,7 +166,7 @@ Interface::Interface(SagaEngine *vm) : _vm(vm), _initialized(false) {
_conversePanel.x = 0;
_conversePanel.y = 149;
- _mainPanel.set_button = COMMAND_DEFAULT_BUTTON;
+ _mainPanel.set_button = 1;
_leftPortrait = 0;
_rightPortrait = 0;
@@ -394,15 +331,15 @@ int Interface::draw() {
if (_panelMode == kPanelMain || _panelMode == kPanelConverse ||
_lockedMode == kPanelMain || _lockedMode == kPanelConverse) {
- leftPortraitPoint.x = base.x + _iDesc.lportrait_x;
- leftPortraitPoint.y = base.y + _iDesc.lportrait_y;
+ leftPortraitPoint.x = base.x + _vm->getDisplayInfo().leftPortraitX;
+ leftPortraitPoint.y = base.y + _vm->getDisplayInfo().leftPortraitY;
_vm->_sprite->draw(backBuffer, _defPortraits, _leftPortrait, leftPortraitPoint, 256);
}
- if (!_inMainMode && _iDesc.rportrait_x >= 0) {
- rightPortraitPoint.x = base.x + _iDesc.rportrait_x;
- rightPortraitPoint.y = base.y + _iDesc.rportrait_y;
+ if (!_inMainMode && _vm->getDisplayInfo().rightPortraitX >= 0) {
+ rightPortraitPoint.x = base.x + _vm->getDisplayInfo().rightPortraitX;
+ rightPortraitPoint.y = base.y + _vm->getDisplayInfo().rightPortraitY;
_vm->_sprite->draw(backBuffer, _scenePortraits, _rightPortrait, rightPortraitPoint, 256);
}
@@ -429,7 +366,7 @@ int Interface::update(const Point& imousePt, int update_flag) {
if (_panelMode == kPanelMain) { // FIXME: HACK
// Update playfield space ( only if cursor is inside )
- if (imouse_y < _vm->getStatusYOffset()) {
+ if (imouse_y < _vm->getSceneHeight()) {
// Mouse is in playfield space
if (update_flag == UPDATE_MOUSEMOVE) {
handlePlayfieldUpdate(back_buf, imousePt);
@@ -459,23 +396,23 @@ int Interface::drawStatusBar(SURFACE *ds) {
// Disable this for IHNM for now, since that game uses the full screen
// in some cases.
- if (_vm->_gameType == GType_IHNM) {
+ if (_vm->getGameType() == GType_IHNM) {
return SUCCESS;
}
// Erase background of status bar
rect.left = 0;
- rect.top = _iDesc.status_y;
+ rect.top = _vm->getDisplayInfo().statusY;
rect.right = _vm->getDisplayWidth();
- rect.bottom = _iDesc.status_y + _iDesc.status_h;
+ rect.bottom = _vm->getDisplayInfo().statusY + _vm->getDisplayInfo().statusHeight;
- drawRect(ds, &rect, _iDesc.status_bgcol);
+ drawRect(ds, &rect, _vm->getDisplayInfo().statusBGColor);
string_w = _vm->_font->getStringWidth(SMALL_FONT_ID, _statusText, 0, 0);
- _vm->_font->draw(SMALL_FONT_ID, ds, _statusText, 0, (_iDesc.status_w / 2) - (string_w / 2),
- _iDesc.status_y + _iDesc.status_txt_y, _iDesc.status_txt_col, 0, 0);
+ _vm->_font->draw(SMALL_FONT_ID, ds, _statusText, 0, (_vm->getDisplayInfo().statusWidth / 2) - (string_w / 2),
+ _vm->getDisplayInfo().statusY + _vm->getDisplayInfo().statusTextY, _vm->getDisplayInfo().statusTextColor, 0, 0);
return SUCCESS;
}
@@ -733,10 +670,10 @@ void Interface::drawInventory() {
int row = 0;
int col = 0;
- int x = _iDesc.inv_xstart + _iDesc.inv_icon_xoffset;
- int y = _iDesc.inv_ystart + _iDesc.inv_icon_yoffset;
- int width = _iDesc.inv_icon_width + _iDesc.inv_xspacing;
- int height = _iDesc.inv_icon_height + _iDesc.inv_yspacing;
+ int x = _vm->getDisplayInfo().inventoryX + _vm->getDisplayInfo().inventoryIconX;
+ int y = _vm->getDisplayInfo().inventoryY + _vm->getDisplayInfo().inventoryIconY;
+ int width = _vm->getDisplayInfo().inventoryIconWidth + _vm->getDisplayInfo().inventoryXSpacing;
+ int height = _vm->getDisplayInfo().inventoryIconHeight + _vm->getDisplayInfo().inventoryYSpacing;
Point drawPoint;
for (int i = 0; i < _inventoryCount; i++) {
@@ -750,8 +687,8 @@ void Interface::drawInventory() {
ObjectTable[_inventory[i]].spritelistRn,
drawPoint, 256);
- if (++col >= _iDesc.inv_columns) {
- if (++row >= _iDesc.inv_rows) {
+ if (++col >= _vm->getDisplayInfo().inventoryColumns) {
+ if (++row >= _vm->getDisplayInfo().inventoryRows) {
break;
}
col = 0;
@@ -763,22 +700,22 @@ int Interface::inventoryTest(const Point& imousePt, int *ibutton) {
int row = 0;
int col = 0;
- int xbase = _iDesc.inv_xstart;
- int ybase = _iDesc.inv_ystart;
- int width = _iDesc.inv_icon_width + _iDesc.inv_xspacing;
- int height = _iDesc.inv_icon_height + _iDesc.inv_yspacing;
+ int xbase = _vm->getDisplayInfo().inventoryX;
+ int ybase = _vm->getDisplayInfo().inventoryY;
+ int width = _vm->getDisplayInfo().inventoryIconWidth + _vm->getDisplayInfo().inventoryXSpacing;
+ int height = _vm->getDisplayInfo().inventoryIconHeight + _vm->getDisplayInfo().inventoryYSpacing;
for (int i = 0; i < _inventoryCount; i++) {
int x = xbase + col * width;
int y = ybase + row * height;
- if (imousePt.x >= x && imousePt.x < x + _iDesc.inv_icon_width && imousePt.y >= y && imousePt.y < y + _iDesc.inv_icon_height) {
+ if (imousePt.x >= x && imousePt.x < x + _vm->getDisplayInfo().inventoryIconWidth && imousePt.y >= y && imousePt.y < y + _vm->getDisplayInfo().inventoryIconHeight) {
*ibutton = i;
return SUCCESS;
}
- if (++col >= _iDesc.inv_columns) {
- if (++row >= _iDesc.inv_rows) {
+ if (++col >= _vm->getDisplayInfo().inventoryColumns) {
+ if (++row >= _vm->getDisplayInfo().inventoryRows) {
break;
}
col = 0;
@@ -954,7 +891,7 @@ void Interface::converseDisplayTextLine(int textcolor, bool btnDown, bool rebuil
if (_converseTextCount > i) {
const char *str = _converseText[relpos].text;
- char bullet[] = { 0xb7, 0 };
+ char bullet[] = { (char)0xb7, 0 };
int scry = i * CONVERSE_TEXT_HEIGHT + _conversePanel.y + y;
byte tcolor, bcolor;
diff --git a/saga/interface.h b/saga/interface.h
index 84e4be2d59..f6d98ff2b2 100644
--- a/saga/interface.h
+++ b/saga/interface.h
@@ -42,65 +42,6 @@ enum INTERFACE_UPDATE_FLAGS {
#define STATUS_TEXT_LEN 128
-#define COMMAND_DEFAULT_BUTTON 1
-
-// Inherit the Earth interface values
-#define ITE_STATUS_Y 137
-#define ITE_STATUS_W 320
-#define ITE_STATUS_H 12
-#define ITE_STATUS_TEXT_Y 2
-#define ITE_STATUS_TXTCOL 186
-#define ITE_STATUS_BGCOL 15
-
-#define ITE_CMD_TEXT_COL 147
-#define ITE_CMD_TEXT_SHADOWCOL 15
-#define ITE_CMD_TEXT_HILITECOL 96
-
-#define ITE_LPORTRAIT_X 5
-#define ITE_LPORTRAIT_Y 4
-#define ITE_RPORTRAIT_X 274
-#define ITE_RPORTRAIT_Y 4
-
-#define ITE_INVENTORY_XSTART 181
-#define ITE_INVENTORY_YSTART 155
-#define ITE_INVENTORY_ROWS 2
-#define ITE_INVENTORY_COLUMNS 4
-#define ITE_INVENTORY_ICON_WIDTH 29
-#define ITE_INVENTORY_ICON_HEIGHT 20
-#define ITE_INVENTORY_ICON_XOFFSET 1
-#define ITE_INVENTORY_ICON_YOFFSET 0
-#define ITE_INVENTORY_XSPACING 3
-#define ITE_INVENTORY_YSPACING 1
-
-// IHNMAIMS interface values
-#define IHNM_STATUS_Y 304
-#define IHNM_STATUS_W 640
-#define IHNM_STATUS_H 24
-#define IHNM_STATUS_TEXT_Y 8
-#define IHNM_STATUS_TXTCOL 186
-#define IHNM_STATUS_BGCOL 11
-
-#define IHNM_CMD_TEXT_COL 147
-#define IHNM_CMD_TEXT_SHADOWCOL 15
-#define IHNM_CMD_TEXT_HILITECOL 96
-
-#define IHNM_LPORTRAIT_X 5
-#define IHNM_LPORTRAIT_Y 4
-#define IHNM_RPORTRAIT_X -1
-#define IHNM_RPORTRAIT_Y -1
-
-// TODO
-#define IHNM_INVENTORY_XSTART 0
-#define IHNM_INVENTORY_YSTART 0
-#define IHNM_INVENTORY_ROWS 0
-#define IHNM_INVENTORY_COLUMNS 0
-#define IHNM_INVENTORY_ICON_WIDTH 0
-#define IHNM_INVENTORY_ICON_HEIGHT 0
-#define IHNM_INVENTORY_ICON_XOFFSET 0
-#define IHNM_INVENTORY_ICON_YOFFSET 0
-#define IHNM_INVENTORY_XSPACING 0
-#define IHNM_INVENTORY_YSPACING 0
-
// Converse-specific stuff
#define CONVERSE_MAX_TEXTS 64
#define CONVERSE_MAX_TEXT_WIDTH (256 - 60)
@@ -127,11 +68,10 @@ enum BUTTON_FLAGS {
BUTTON_NONE = 0x0,
BUTTON_LABEL = 0x01,
BUTTON_BITMAP = 0x02,
- BUTTON_SET = 0x04
+ BUTTON_SET = 0x04,
+ BUTTON_VERB = BUTTON_LABEL | BUTTON_BITMAP | BUTTON_SET
};
-#define BUTTON_VERB ( BUTTON_LABEL | BUTTON_BITMAP | BUTTON_SET )
-
struct InterfaceButton {
int x1;
int y1;
@@ -153,42 +93,12 @@ struct InterfacePanel {
size_t img_len;
int img_w;
int img_h;
- int set_button;
+ int set_button;//TODO: remove
int nbuttons;
InterfaceButton *buttons;
SpriteList sprites;
};
-struct INTERFACE_DESC {
- int status_y;
- int status_w;
- int status_h;
- int status_txt_y;
- int status_txt_col;
- int status_bgcol;
- int cmd_txt_col;
- int cmd_txt_shadowcol;
- int cmd_txt_hilitecol;
- int cmd_defaultbutton;
- int lportrait_x;
- int lportrait_y;
- int rportrait_x;
- int rportrait_y;
- int inv_xstart;
- int inv_ystart;
- int inv_rows;
- int inv_columns;
- int inv_icon_width;
- int inv_icon_height;
- int inv_icon_xoffset;
- int inv_icon_yoffset;
- int inv_xspacing;
- int inv_yspacing;
-};
-
-struct INTERFACE_MODULE {
-};
-
enum INTERFACE_VERBS {
I_VERB_WALKTO,
I_VERB_LOOKAT,
@@ -270,7 +180,6 @@ private:
bool _initialized;
bool _active;
RSCFILE_CONTEXT *_interfaceContext;
- INTERFACE_DESC _iDesc;
int _panelMode;
int _savedMode;
int _lockedMode;
diff --git a/saga/ite_introproc.cpp b/saga/ite_introproc.cpp
index a20655ec4a..76e66a1281 100644
--- a/saga/ite_introproc.cpp
+++ b/saga/ite_introproc.cpp
@@ -189,11 +189,11 @@ EVENT *Scene::ITEQueueCredits(SCENE_INFO *scene_info, int delta_time, int durati
// The assumption here is that all WyrmKeep versions have the same
// credits, regardless of which operating system they're for.
- if (_vm->_features & GF_WYRMKEEP) {
+ if (_vm->getFeatures() & GF_WYRMKEEP) {
game = kITEWyrmKeep;
- } else if (_vm->_features & GF_MAC_RESOURCES) {
+ } else if (_vm->getFeatures() & GF_MAC_RESOURCES) {
game = kITEMac;
- } else if (_vm->_gameId == GID_ITE_CD_G) {
+ } else if (_vm->getGameId() == GID_ITE_CD_G) {
game = kITEPCCD;
} else {
game = kITEPC;
@@ -324,14 +324,14 @@ int Scene::ITEIntroAnimProc(int param, SCENE_INFO *scene_info) {
// playback
int lastAnim;
- if (_vm->_features & GF_WYRMKEEP) {
- if (_vm->_features & GF_MAC_RESOURCES) {
+ if (_vm->getFeatures() & GF_WYRMKEEP) {
+ if (_vm->getFeatures() & GF_MAC_RESOURCES) {
lastAnim = 3;
} else {
lastAnim = 2;
}
} else {
- if (_vm->_features & GF_MAC_RESOURCES) {
+ if (_vm->getFeatures() & GF_MAC_RESOURCES) {
lastAnim = 4;
} else {
lastAnim = 5;
diff --git a/saga/music.cpp b/saga/music.cpp
index 8c1de67b37..634c40434d 100644
--- a/saga/music.cpp
+++ b/saga/music.cpp
@@ -138,7 +138,7 @@ void RAWInputStream::refill() {
if (len & 1)
len--;
- if (_vm->_features & GF_BIG_ENDIAN_DATA) {
+ if (_vm->getFeatures() & GF_BIG_ENDIAN_DATA) {
uint16 *ptr16 = (uint16 *)ptr;
for (uint32 i = 0; i < (len / 2); i++)
ptr16[i] = TO_BE_16(ptr16[i]);
@@ -297,7 +297,7 @@ Music::Music(SoundMixer *mixer, MidiDriver *driver, int enabled) : _mixer(mixer)
_musicInitialized = 1;
_mixer->setVolumeForSoundType(SoundMixer::kMusicAudioDataType, ConfMan.getInt("music_volume"));
- if (_vm->_gameType == GType_ITE) {
+ if (_vm->getGameType() == GType_ITE) {
File file;
byte footerBuf[ARRAYSIZE(_digiTableITECD) * 8];
@@ -406,7 +406,7 @@ int Music::play(uint32 music_rn, uint16 flags) {
MidiParser *parser;
File midiFile;
- if (_vm->_gameType == GType_ITE) {
+ if (_vm->getGameType() == GType_ITE) {
if (music_rn >= 9 && music_rn <= 34) {
if (flags == MUSIC_DEFAULT) {
flags = _midiTableITECD[music_rn - 9].flags;
@@ -456,7 +456,7 @@ int Music::play(uint32 music_rn, uint16 flags) {
} else {
// Load MIDI/XMI resource data
- if (_vm->_gameType == GType_ITE) {
+ if (_vm->getGameType() == GType_ITE) {
rsc_ctxt = _vm->getFileContext(GAME_RESOURCEFILE, 0);
} else {
// I've listened to music from both the FM and the GM
diff --git a/saga/palanim.cpp b/saga/palanim.cpp
index 264d017baa..4070b2d8b8 100644
--- a/saga/palanim.cpp
+++ b/saga/palanim.cpp
@@ -56,7 +56,7 @@ int PalAnim::loadPalAnim(const byte *resdata, size_t resdata_len) {
MemoryReadStreamEndian readS(resdata, resdata_len, IS_BIG_ENDIAN);
- if (_vm->_gameType == GType_IHNM) {
+ if (_vm->getGameType() == GType_IHNM) {
return SUCCESS;
}
diff --git a/saga/rscfile.cpp b/saga/rscfile.cpp
index 8053f640d1..0fbde0ab81 100644
--- a/saga/rscfile.cpp
+++ b/saga/rscfile.cpp
@@ -253,7 +253,7 @@ int RSC_LoadResource(RSCFILE_CONTEXT *rsc, uint32 res_num, byte **res_p, size_t
break;
}
- if (!(_vm->_features & GF_WYRMKEEP))
+ if (!(_vm->getFeatures() & GF_WYRMKEEP))
substnum = -1;
if (substnum != -1) {
@@ -305,7 +305,7 @@ int RSC_FreeResource(byte *resource_ptr) {
int RSC_ConvertID(int id) {
int res = id;
- if (_vm->_features & GF_MAC_RESOURCES) {
+ if (_vm->getFeatures() & GF_MAC_RESOURCES) {
if (res > 1537)
res -= 2;
else if (res == 1535 || res == 1536) {
diff --git a/saga/saga.cpp b/saga/saga.cpp
index 89340353fc..58ebbd7862 100644
--- a/saga/saga.cpp
+++ b/saga/saga.cpp
@@ -42,7 +42,6 @@
#include "saga/console.h"
#include "saga/events.h"
#include "saga/font.h"
-#include "saga/game.h"
#include "saga/interface.h"
#include "saga/isomap.h"
#include "saga/script.h"
@@ -93,6 +92,8 @@ SagaEngine::SagaEngine(GameDetector *detector, OSystem *syst)
: Engine(syst) {
_console = NULL;
+ _gameFileContexts = NULL;
+ _quit = false;
// The Linux version of Inherit the Earth puts all data files in an
// 'itedata' sub-directory, except for voices.rsc
@@ -119,6 +120,32 @@ SagaEngine::SagaEngine(GameDetector *detector, OSystem *syst)
}
SagaEngine::~SagaEngine() {
+ int i;
+
+ delete _scene;
+ delete _actor;
+ delete _script;
+ delete _sprite;
+ delete _font;
+ delete _console;
+ delete _events;
+ delete _palanim;
+
+ delete _interface;
+ delete _render;
+ delete _isoMap;
+ delete _sndRes;
+ // Shutdown system modules */
+ delete _music;
+ delete _sound;
+ delete _anim;
+
+ if (_gameFileContexts != NULL) {
+ for (i = 0; i < _gameDescription->filesCount; i++) {
+ RSC_DestroyContext(_gameFileContexts[i]);
+ }
+ }
+ free(_gameFileContexts);
}
void SagaEngine::errorString(const char *buf1, char *buf2) {
@@ -224,7 +251,7 @@ int SagaEngine::go() {
_scene->startScene();
uint32 currentTicks;
- for (;;) {
+ while(!_quit) {
if (_console->isAttached())
_console->onFrame();
@@ -244,7 +271,7 @@ int SagaEngine::go() {
msec = MAX_TIME_DELTA;
}
- if (!_vm->_scene->isInDemo() && _gameType == GType_ITE)
+ if (!_vm->_scene->isInDemo() && getGameType() == GType_ITE)
if (_vm->_interface->getMode() == kPanelMain ||
_vm->_interface->getMode() == kPanelConverse ||
_vm->_interface->getMode() == kPanelNull)
@@ -258,29 +285,7 @@ int SagaEngine::go() {
_system->delayMillis(10);
}
- //return 0;
-}
-
-void SagaEngine::shutdown() {
- delete _scene;
- delete _actor;
- delete _script;
- delete _sprite;
- delete _font;
- delete _console;
- delete _events;
- delete _palanim;
-
- delete _interface;
- delete _render;
- delete _isoMap;
- delete _sndRes;
- // Shutdown system modules */
- delete _music;
- delete _sound;
- delete _anim;
-
- _system->quit();
+ return 0;
}
void SagaEngine::loadStrings(StringsTable &stringsTable, const byte *stringsPointer, size_t stringsLength) {
diff --git a/saga/saga.h b/saga/saga.h
index 8b8675112d..e32527239a 100644
--- a/saga/saga.h
+++ b/saga/saga.h
@@ -28,6 +28,7 @@
#include "common/scummsys.h"
#include "base/engine.h"
#include "base/gameDetector.h"
+#include "base/plugins.h"
#include "common/stream.h"
#include "common/rect.h"
@@ -62,10 +63,16 @@ class PalAnim;
#define GAME_ITE_LANG_PREFIX "ite_"
#define GAME_LANG_EXT "lng"
+#define MIN_IMG_RLECODE 3
+#define MODEX_SCANLINE_LIMIT 200
+
+#define SAGA_IMAGE_DATA_OFFSET 776
+#define SAGA_IMAGE_HEADER_LEN 8
+
#define PBOUNDS(n,max) (((n)>=(0))&&((n)<(max)))
#define MAXPATH 512
-#define IS_BIG_ENDIAN ((_vm->_features & GF_BIG_ENDIAN_DATA) != 0)
+#define IS_BIG_ENDIAN ((_vm->getFeatures() & GF_BIG_ENDIAN_DATA) != 0)
#define ID_NOTHING 0
#define ID_PROTAG 1
@@ -124,6 +131,12 @@ enum HitZoneFlags {
kHitZoneTerminus = (1 << 3)
};
+
+struct IMAGE_HEADER {
+ int width;
+ int height;
+};
+
struct StringsTable {
byte *stringsPointer;
int stringsCount;
@@ -201,16 +214,6 @@ enum GameSoundTypes {
GAME_SOUND_VOX
};
-enum GameFontIds {
- GAME_FONT_SMALL = 0,
- GAME_FONT_MEDIUM,
- GAME_FONT_LARGE,
- GAME_FONT_SMALL2,
- GAME_FONT_MEDIUM2,
- GAME_FONT_LARGE2,
- GAME_FONT_LARGE3
-};
-
enum GameFeatures {
GF_VOX_VOICES = 1 << 0,
GF_BIG_ENDIAN_DATA = 1 << 1,
@@ -227,8 +230,7 @@ struct GameSoundInfo {
};
struct GameFontDescription {
- uint16 font_id;
- uint32 font_rn;
+ uint32 fontResourceId;
};
struct GameResourceDescription {
@@ -246,7 +248,36 @@ struct GameFileDescription {
struct GameDisplayInfo {
int logicalWidth;
int logicalHeight;
- int scene_h;
+
+ int pathStartY;
+ int sceneHeight;
+
+ int statusY;
+ int statusWidth;
+ int statusHeight;
+ int statusTextY;
+ int statusTextColor;
+ int statusBGColor;
+
+ int verbTextColor;
+ int verbTextShadowColor;
+ int verbTextActiveColor;
+
+ int leftPortraitX;
+ int leftPortraitY;
+ int rightPortraitX;
+ int rightPortraitY;
+
+ int inventoryX;
+ int inventoryY;
+ int inventoryRows;
+ int inventoryColumns;
+ int inventoryIconWidth;
+ int inventoryIconHeight;
+ int inventoryIconX;
+ int inventoryIconY;
+ int inventoryXSpacing;
+ int inventoryYSpacing;
};
struct GameDescription {
@@ -254,9 +285,7 @@ struct GameDescription {
SAGAGameType gameType;
GameIds gameId;
const char *title;
- int gd_logical_w;
- int gd_logical_h;
- int gd_scene_h;
+ GameDisplayInfo *gameDisplayInfo;
int startSceneNumber;
GameResourceDescription *resourceDescription;
int filesCount;
@@ -297,6 +326,8 @@ inline int objectIdType(uint16 objectId) {
return objectId >> 13;
}
+DetectedGameList GAME_ProbeGame(const FSList &fslist);
+
class SagaEngine : public Engine {
void errorString(const char *buf_input, char *buf_output);
@@ -307,22 +338,12 @@ protected:
public:
SagaEngine(GameDetector * detector, OSystem * syst);
virtual ~SagaEngine();
-
- void shutdown();
+ void shutDown() { _quit = true; }
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;
Music *_music;
@@ -379,23 +400,39 @@ public:
private:
Point _mousePos;
+ bool _quit;
+ char _gameLanguage[GAME_LANGSTR_LIMIT];
+ RSCFILE_CONTEXT **_gameFileContexts;
+
+//current game description
+ int _gameNumber;
+ GameDescription *_gameDescription;
+ GameDisplayInfo _gameDisplayInfo;
+
public:
int initGame(void);
RSCFILE_CONTEXT *getFileContext(uint16 type, int param);
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();
+ int getGameId() const { return _gameDescription->gameId; }
+ int getGameType() const { return _gameDescription->gameType; }
+ uint32 getFeatures() const { return _gameDescription->features; }
+ int getGameNumber() const { return _gameNumber; }
+ int getStartSceneNumber() const { return _gameDescription->startSceneNumber; }
+
+
+ int getDisplayWidth() const { return _gameDisplayInfo.logicalWidth; }
+ int getDisplayHeight() const { return _gameDisplayInfo.logicalHeight;}
+ int getSceneHeight() const { return _gameDisplayInfo.sceneHeight; }
+ const GameDisplayInfo & getDisplayInfo() { return _gameDisplayInfo; }
private:
int loadLanguage(void);
int loadGame(int gameNumber);
diff --git a/saga/scene.cpp b/saga/scene.cpp
index f92e018cee..7f73ba814a 100644
--- a/saga/scene.cpp
+++ b/saga/scene.cpp
@@ -80,8 +80,7 @@ Scene::Scene(SagaEngine *vm) : _vm(vm), _initialized(false) {
_sceneMax = _sceneCount - 1;
_sceneLUT = (int *)malloc(_sceneMax * sizeof(*_sceneLUT));
if (_sceneLUT == NULL) {
- warning("Scene::Scene(): Memory allocation failed");
- return;
+ error("Scene::Scene(): Memory allocation failed");
}
MemoryReadStreamEndian readS(scene_lut_p, scene_lut_len, IS_BIG_ENDIAN);
@@ -171,7 +170,7 @@ int Scene::startScene() {
event.op = EVENT_HIDE;
_vm->_events->queue(&event);
- switch (_vm->_gameType) {
+ switch (_vm->getGameType()) {
case GType_ITE:
ITEStartProc();
break;
@@ -310,8 +309,8 @@ int Scene::changeScene(int scene_num) {
}
void Scene::getSlopes(int &beginSlope, int &endSlope) {
- beginSlope = _vm->getStatusYOffset() - _desc.beginSlope;
- endSlope = _vm->getStatusYOffset() - _desc.endSlope;
+ beginSlope = _vm->getSceneHeight() - _desc.beginSlope;
+ endSlope = _vm->getSceneHeight() - _desc.endSlope;
}
int Scene::getBGInfo(SCENE_BGINFO *bginfo) {
@@ -332,8 +331,8 @@ int Scene::getBGInfo(SCENE_BGINFO *bginfo) {
x = (_vm->getDisplayWidth() - _bg.w) / 2;
}
- if (_bg.h < _vm->getStatusYOffset()) {
- y = (_vm->getStatusYOffset() - _bg.h) / 2;
+ if (_bg.h < _vm->getSceneHeight()) {
+ y = (_vm->getSceneHeight() - _bg.h) / 2;
}
bginfo->bg_x = x;
@@ -909,7 +908,7 @@ int Scene::draw(SURFACE *dst_s) {
_vm->_isoMap->draw(dst_s);
} else {
bufToSurface(dst_s, buf_info.bg_buf, _vm->getDisplayWidth(),
- MAX(_vm->getStatusYOffset(), _bg.h), NULL, &bg_pt);
+ MAX(_vm->getSceneHeight(), _bg.h), NULL, &bg_pt);
}
return SUCCESS;
diff --git a/saga/sfuncs.cpp b/saga/sfuncs.cpp
index 9562763674..1952f15dcc 100644
--- a/saga/sfuncs.cpp
+++ b/saga/sfuncs.cpp
@@ -1054,7 +1054,7 @@ int Script::sfPlacard(SCRIPTFUNC_PARAMS) {
event.data = back_buf;
event.param = 138;
event.param2 = 0;
- event.param3 = _vm->getStatusYOffset();
+ event.param3 = _vm->getSceneHeight();
event.param4 = 0;
event.param5 = _vm->getDisplayWidth();
@@ -1074,7 +1074,7 @@ int Script::sfPlacard(SCRIPTFUNC_PARAMS) {
text_entry.color = _vm->_gfx->getWhite();
text_entry.effect_color = _vm->_gfx->getBlack();
text_entry.text_x = _vm->getDisplayWidth() / 2;
- text_entry.text_y = (_vm->getStatusYOffset() - _vm->_font->getHeight(MEDIUM_FONT_ID)) / 2;
+ text_entry.text_y = (_vm->getSceneHeight() - _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 8bb225bb0d..4262709bc0 100644
--- a/saga/sndres.cpp
+++ b/saga/sndres.cpp
@@ -78,7 +78,7 @@ int SndRes::playVoice(uint32 voice_rn) {
debug(0, "SndRes::playVoice(%ld)", voice_rn);
- if (_vm->_gameType == GType_ITE && voice_rn == 4) {
+ if (_vm->getGameType() == GType_ITE && voice_rn == 4) {
// The Wyrmkeep release of Inherit the Earth provides a
// separate file (p2_a.voc or P2_A.iaf), to correct voice 4 in
// the intro. Use that, if available.
@@ -122,7 +122,7 @@ int SndRes::playVoice(uint32 voice_rn) {
return FAILURE;
}
- if (_vm->_features & GF_VOX_VOICES && !voiceFile)
+ if (_vm->getFeatures() & GF_VOX_VOICES && !voiceFile)
_vm->_sound->playVoxVoice(&snd_buffer);
else
_vm->_sound->playVoice(&snd_buffer);
@@ -241,7 +241,7 @@ int SndRes::getVoiceLength(uint32 voice_rn) {
// (p2_a.voc or P2_A.iaf), to correct voice 4 in the intro. Use that,
// if available.
- if (_vm->_gameType == GType_ITE && voice_rn == 4) {
+ if (_vm->getGameType() == GType_ITE && voice_rn == 4) {
if (f.open("p2_a.voc")) {
result = SUCCESS;
length = f.size();
@@ -265,7 +265,7 @@ int SndRes::getVoiceLength(uint32 voice_rn) {
}
}
- if (_vm->_features & GF_VOX_VOICES && !voiceFile) {
+ if (_vm->getFeatures() & GF_VOX_VOICES && !voiceFile) {
// Rough hack, fix this to be accurate
ms_f = (double)length / 22050 * 2000.0;
ms_i = (int)ms_f;
diff --git a/saga/sound.cpp b/saga/sound.cpp
index 96f4199760..2253ce8c5e 100644
--- a/saga/sound.cpp
+++ b/saga/sound.cpp
@@ -166,7 +166,7 @@ int Sound::playSoundBuffer(PlayingSoundHandle *handle, SOUNDBUFFER *buf, int vol
if (buf->s_samplebits == 16) {
flags |= SoundMixer::FLAG_16BITS;
- if (!(_vm->_features & GF_BIG_ENDIAN_DATA))
+ if (!(_vm->getFeatures() & GF_BIG_ENDIAN_DATA))
flags |= SoundMixer::FLAG_LITTLE_ENDIAN;
}
if (buf->s_stereo)
diff --git a/saga/sprite.cpp b/saga/sprite.cpp
index d21ede5656..7801eb5904 100644
--- a/saga/sprite.cpp
+++ b/saga/sprite.cpp
@@ -106,7 +106,7 @@ int Sprite::loadList(int resourceId, SpriteList &spriteList) {
for (i = oldSpriteCount; i < spriteList.spriteCount; i++) {
spriteInfo = &spriteList.infoList[i];
- if (_vm->_features & GF_MAC_RESOURCES)
+ if (_vm->getFeatures() & GF_MAC_RESOURCES)
offset = readS.readUint32();
else
offset = readS.readUint16();
@@ -118,9 +118,9 @@ int Sprite::loadList(int resourceId, SpriteList &spriteList) {
spritePointer = spriteListData;
spritePointer += offset;
- MemoryReadStream readS2(spritePointer, (_vm->_features & GF_MAC_RESOURCES) ? 8 : 4);
+ MemoryReadStream readS2(spritePointer, (_vm->getFeatures() & GF_MAC_RESOURCES) ? 8 : 4);
- if (!(_vm->_features & GF_MAC_RESOURCES)) {
+ if (!(_vm->getFeatures() & GF_MAC_RESOURCES)) {
spriteInfo->xAlign = readS2.readSByte();
spriteInfo->yAlign = readS2.readSByte();
diff --git a/saga/sthread.cpp b/saga/sthread.cpp
index fa9530cd4c..7aa59fa3f2 100644
--- a/saga/sthread.cpp
+++ b/saga/sthread.cpp
@@ -758,7 +758,7 @@ void Script::runThread(SCRIPT_THREAD *thread, int instr_limit) {
}
// now data contains last string index
- if (_vm->_gameId == GID_ITE_DISK_G) { // special ITE dos
+ if (_vm->getGameId() == GID_ITE_DISK_G) { // special ITE dos
if ((_vm->_scene->currentSceneNumber() == ITE_DEFAULT_SCENE) && (data >= 288) && (data <= (RID_SCENE1_VOICE_138 - RID_SCENE1_VOICE_009 + 288))) {
sampleResourceId = RID_SCENE1_VOICE_009 + data - 288;
}