aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Sandulenko2004-05-01 23:42:22 +0000
committerEugene Sandulenko2004-05-01 23:42:22 +0000
commit66876dc1d12802b6d2339df2a31d010e55f3d700 (patch)
treee94167bbc94ef5f0d653ef12cd192e742963fb23
parentc0772498b6d2351ed2f3c2ba308d0bbda84b7cb0 (diff)
downloadscummvm-rg350-66876dc1d12802b6d2339df2a31d010e55f3d700.tar.gz
scummvm-rg350-66876dc1d12802b6d2339df2a31d010e55f3d700.tar.bz2
scummvm-rg350-66876dc1d12802b6d2339df2a31d010e55f3d700.zip
Proper #includes everywhere
Improved game detector svn-id: r13724
-rw-r--r--saga/animation.cpp2
-rw-r--r--saga/font.cpp2
-rw-r--r--saga/game.cpp222
-rw-r--r--saga/game.h20
-rw-r--r--saga/game_mod.h4
-rw-r--r--saga/gfx.cpp2
-rw-r--r--saga/image.cpp2
-rw-r--r--saga/interface.cpp2
-rw-r--r--saga/isomap.cpp2
-rw-r--r--saga/palanim.cpp2
-rw-r--r--saga/reinherit.h1
-rw-r--r--saga/saga.cpp53
-rw-r--r--saga/scene.cpp2
-rw-r--r--saga/script.cpp2
-rw-r--r--saga/sprite.cpp2
-rw-r--r--saga/sysgfx.cpp1
16 files changed, 138 insertions, 183 deletions
diff --git a/saga/animation.cpp b/saga/animation.cpp
index 84b12b83f8..81552d5584 100644
--- a/saga/animation.cpp
+++ b/saga/animation.cpp
@@ -22,7 +22,7 @@
*/
// Background animation management module
-
+#include "saga.h"
#include "reinherit.h"
#include "yslib.h"
diff --git a/saga/font.cpp b/saga/font.cpp
index 67f466ebd8..64c280bae2 100644
--- a/saga/font.cpp
+++ b/saga/font.cpp
@@ -22,7 +22,7 @@
*/
// Font management and font drawing module
-
+#include "saga.h"
#include "reinherit.h"
#include "yslib.h"
diff --git a/saga/game.cpp b/saga/game.cpp
index 6a657c4a0c..3bbbf4909f 100644
--- a/saga/game.cpp
+++ b/saga/game.cpp
@@ -27,6 +27,9 @@
#include "yslib.h"
#include "common/file.h"
+#include "base/gameDetector.h"
+#include "base/plugins.h"
+#include "backends/fs/fs.h"
#include "rscfile_mod.h"
#include "cvar_mod.h"
@@ -157,9 +160,10 @@ R_GAME_SOUNDINFO IHNM_GameSound = {
R_GAMEDESC GameDescs[] = {
// Inherit the earth - DOS Demo version
{
+ "ite-demo",
R_GAMETYPE_ITE,
R_GAME_ITE_DEMO, // Game id
- "Inherit the Earth - DOS Demo version", // Game title
+ "Inherit the Earth (DOS Demo)", // Game title
320, 200, // Logical resolution
137, // Scene viewport height
ITE_DEFAULT_SCENE, // Starting scene number
@@ -169,15 +173,15 @@ R_GAMEDESC GameDescs[] = {
ARRAYSIZE(ITEDEMO_GameFonts),
ITEDEMO_GameFonts,
&ITEDEMO_GameSound,
- Verify_ITEDEMO, // Game verification func
0 // Game supported flag
},
// Inherit the earth - win32 Wyrmkeep Demo version
{
+ "ite-demo-win",
R_GAMETYPE_ITE,
R_GAME_ITE_WINDEMO,
- "Inherit the Earth - Win32 Wyrmkeep Demo version",
+ "Inherit the Earth (Win32 Demo)",
320, 200,
137,
ITE_DEFAULT_SCENE,
@@ -187,50 +191,52 @@ R_GAMEDESC GameDescs[] = {
ARRAYSIZE(ITECD_GameFonts),
ITECD_GameFonts,
&ITECD_GameSound,
- NULL,
0
},
- // Inherit the earth - Disk version
+ // Inherit the earth - CD version
+ // NOTE: it should be before floppy version
{
+ "itecd",
R_GAMETYPE_ITE,
- R_GAME_ITE_DISK,
- "Inherit the Earth - Disk version",
+ R_GAME_ITE_CD,
+ "Inherit the Earth (DOS CD Version)",
320, 200,
137,
ITE_DEFAULT_SCENE,
&ITE_Resources,
- ARRAYSIZE(ITEDISK_GameFiles),
- ITEDISK_GameFiles,
- ARRAYSIZE(ITEDISK_GameFonts),
- ITEDISK_GameFonts,
- &ITE_GameSound,
- Verify_ITEDISK,
+ ARRAYSIZE(ITECD_GameFiles),
+ ITECD_GameFiles,
+ ARRAYSIZE(ITECD_GameFonts),
+ ITECD_GameFonts,
+ &ITECD_GameSound,
1
},
- // Inherit the earth - CD version
+ // Inherit the earth - Disk version
{
+ "ite",
R_GAMETYPE_ITE,
- R_GAME_ITE_CD,
- "Inherit the Earth - CD version",
+ R_GAME_ITE_DISK,
+ "Inherit the Earth (DOS)",
320, 200,
137,
ITE_DEFAULT_SCENE,
&ITE_Resources,
- ARRAYSIZE(ITECD_GameFiles),
- ITECD_GameFiles,
- ARRAYSIZE(ITECD_GameFonts),
- ITECD_GameFonts,
- &ITECD_GameSound,
- NULL,
- 1},
+ ARRAYSIZE(ITEDISK_GameFiles),
+ ITEDISK_GameFiles,
+ ARRAYSIZE(ITEDISK_GameFonts),
+ ITEDISK_GameFonts,
+ &ITE_GameSound,
+ 1
+ },
// I Have No Mouth And I Must Scream - Demo version
{
+ "ihnm-demo",
R_GAMETYPE_IHNM,
R_GAME_IHNM_DEMO,
- "I Have No Mouth - Demo version",
+ "I Have No Mouth and I Must Scream (DOS Demo)",
640, 480,
304,
0,
@@ -240,31 +246,32 @@ R_GAMEDESC GameDescs[] = {
0,
NULL,
&IHNM_GameSound,
- NULL,
- 0} ,
+ 0
+ },
// I Have No Mouth And I Must Scream - CD version
{
- R_GAMETYPE_IHNM,
- R_GAME_IHNM_CD,
- "I Have No Mouth - CD version",
- 640, 480,
- 304,
+ "ihnm",
+ R_GAMETYPE_IHNM,
+ R_GAME_IHNM_CD,
+ "I Have No Mouth and I Must Scream (DOS)",
+ 640, 480,
+ 304,
- 1,
+ 1,
- &IHNM_Resources,
+ &IHNM_Resources,
- ARRAYSIZE(IHNMCD_GameFiles),
- IHNMCD_GameFiles,
+ ARRAYSIZE(IHNMCD_GameFiles),
+ IHNMCD_GameFiles,
- ARRAYSIZE(IHNMCD_GameFonts),
- IHNMCD_GameFonts,
+ ARRAYSIZE(IHNMCD_GameFonts),
+ IHNMCD_GameFonts,
- &IHNM_GameSound,
+ &IHNM_GameSound,
- NULL,
- 1}
+ 1
+ }
};
static R_GAMEMODULE GameModule;
@@ -329,6 +336,11 @@ int GAME_Init() {
return R_FAILURE;
}
+ if (!GameDescs[game_n].gd_supported) {
+ GameModule.err_str = "This game is not currently supported.";
+ return R_FAILURE;
+ }
+
if (LoadGame(game_dir, game_n) != R_SUCCESS) {
GameModule.err_str = "Error loading game resource files.";
return R_FAILURE;
@@ -411,9 +423,10 @@ int GAME_GetFileContext(R_RSCFILE_CONTEXT ** ctxt_p, uint16 r_type, int param) {
return R_SUCCESS;
}
-int DetectGame(const char *game_dir, uint16 *game_n_p) {
+DetectedGameList GAME_ProbeGame(const FSList &fslist) {
uint16 game_count = ARRAYSIZE(GameDescs);
uint16 game_n;
+ DetectedGameList detectedGames;
uint16 file_count;
uint16 file_n;
@@ -422,11 +435,56 @@ int DetectGame(const char *game_dir, uint16 *game_n_p) {
int file_missing = 0;
int found_game = 0;
+ for (game_n = 0; (game_n < game_count) && !found_game; game_n++) {
+ file_count = GameDescs[game_n].gd_filect;
+ file_missing = 0;
+
+ // Try to open all files for this game
+ for (file_n = 0; file_n < file_count; file_n++) {
+ file_missing = 1;
+ // Iterate over all files in the given directory
+ for (FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) {
+ const char *gameName = file->displayName().c_str();
+
+ if (0 == scumm_stricmp(GameDescs[game_n].gd_filedescs[file_n].gf_fname,
+ gameName)) {
+ file_missing = 0;
+ break;
+ }
+ }
+
+ if (file_missing)
+ break;
+ }
+
+ // Try the next game, couldn't find all files for the current
+ // game
+ if (file_missing) {
+ continue;
+ } else {
+ detectedGames.push_back(GameDescs[game_n].toGameSettings());
+ return detectedGames;
+ }
+ }
+
+ return detectedGames;
+}
+
+int DetectGame(const char *game_dir, uint16 *game_n_p) {
+ uint16 game_count = ARRAYSIZE(GameDescs);
+ uint16 game_n;
+
+ uint16 file_count;
+ uint16 file_n;
+ File test_file;
+
+ int file_missing = 0;
+
if ((game_dir == NULL) || (game_n_p == NULL)) {
return R_FAILURE;
}
- for (game_n = 0; (game_n < game_count) && !found_game; game_n++) {
+ for (game_n = 0; game_n < game_count; game_n++) {
file_count = GameDescs[game_n].gd_filect;
file_missing = 0;
@@ -445,19 +503,9 @@ int DetectGame(const char *game_dir, uint16 *game_n_p) {
continue;
}
- // If there's a verification function for this game, use it,
- // otherwise assume we've found the game if all files are found.
- found_game = 1;
-
- if (GameDescs[game_n].gd_verifyf != NULL && GameDescs[game_n].gd_verifyf(game_dir) != R_SUCCESS) {
- found_game = 0;
- }
-
- if (found_game) {
- R_printf(R_STDOUT, "Found game: %s\n", GameDescs[game_n].gd_title);
- *game_n_p = game_n;
- return R_SUCCESS;
- }
+ R_printf(R_STDOUT, "Found game: %s\n", GameDescs[game_n].gd_title);
+ *game_n_p = game_n;
+ return R_SUCCESS;
}
return R_FAILURE;
@@ -569,65 +617,15 @@ int GAME_GetGameType() {
return GameModule.gamedesc->gd_game_type;
}
-int Verify_ITEDEMO(const char *game_dir) {
- debug(3, "Verify_ITEDEMO()");
- YS_IGNORE_PARAM(game_dir);
-
- return R_SUCCESS;
-}
-
-int Verify_ITEDISK(const char *game_dir) {
- R_RSCFILE_CONTEXT *test_ctx;
-
- debug(3, "Verify_ITEDISK()");
- uint32 script_lut_len;
- uint32 script_lut_rn;
- int verified = 0;
- test_ctx = RSC_CreateContext();
-
- if (RSC_OpenContext(test_ctx, "ITE.RSC") != R_SUCCESS) {
- return R_FAILURE;
- }
-
- script_lut_rn = GameDescs[R_GAME_ITE_DISK].gd_resource_desc->script_lut_rn;
- if (RSC_GetResourceSize(test_ctx,
- script_lut_rn, &script_lut_len) != R_SUCCESS) {
- RSC_DestroyContext(test_ctx);
- return R_FAILURE;
- }
-
- RSC_DestroyContext(test_ctx);
-
- if (script_lut_len % R_SCR_LUT_ENTRYLEN_ITEDISK == 0) {
- verified = 1;
- }
-
- if (!verified) {
- return R_FAILURE;
- }
-
- return R_SUCCESS;
-}
-
-int Verify_ITECD(const char *game_dir) {
- debug(3, "Verify_ITECD()");
- YS_IGNORE_PARAM(game_dir);
-
- return R_SUCCESS;
-}
-
-int Verify_IHNMDEMO(const char *game_dir) {
- debug(3, "Verify_IHNMDEMO()");
- YS_IGNORE_PARAM(game_dir);
+GameList GAME_GameList() {
+ int gNum = ARRAYSIZE(GameDescs);
+ int i;
+ GameList games;
- return R_SUCCESS;
-}
-
-int Verify_IHNMCD(const char *game_dir) {
- debug(3, "Verify_IHNMCD()");
- YS_IGNORE_PARAM(game_dir);
+ for (i = 0; i < gNum; i++)
+ games.push_back(GameDescs[i].toGameSettings());
- return R_SUCCESS;
+ return games;
}
} // End of namespace Saga
diff --git a/saga/game.h b/saga/game.h
index 6f7efa6203..fdf065f77f 100644
--- a/saga/game.h
+++ b/saga/game.h
@@ -26,6 +26,8 @@
#ifndef SAGA_GAME_H_
#define SAGA_GAME_H_
+#include "base/plugins.h"
+
namespace Saga {
#define R_GAME_LANGSTR_LIMIT 3
@@ -38,16 +40,15 @@ namespace Saga {
#define R_SCR_LUT_ENTRYLEN_ITECD 22
#define R_SCR_LUT_ENTRYLEN_ITEDISK 16
-typedef int (*R_GAME_VERIFYFUNC) (const char *);
-
struct R_GAME_FILEDESC {
const char *gf_fname;
uint16 gf_type;
};
struct R_GAMEDESC {
+ const char *name;
int gd_game_type;
- int gd_game_id;
+ uint32 gd_game_id;
const char *gd_title;
int gd_logical_w;
int gd_logical_h;
@@ -59,8 +60,12 @@ struct R_GAMEDESC {
int gd_fontct;
R_GAME_FONTDESC *gd_fontdescs;
R_GAME_SOUNDINFO *gd_soundinfo;
- R_GAME_VERIFYFUNC gd_verifyf;
int gd_supported;
+
+ GameSettings toGameSettings() const {
+ GameSettings dummy = { name, gd_title, gd_game_id };
+ return dummy;
+ }
};
struct R_GAME_FILEDATA {
@@ -86,13 +91,8 @@ struct R_GAMEMODULE {
};
int LoadLanguage();
-int DetectGame(const char *game_dir, uint16 * game_n_p);
int LoadGame(const char *game_dir, uint16 game_n_p);
-int Verify_ITEDEMO(const char *game_dir);
-int Verify_ITEDISK(const char *game_dir);
-int Verify_ITECD(const char *game_dir);
-int Verify_IHNMDEMO(const char *game_dir);
-int Verify_IHNMCD(const char *game_dit);
+int DetectGame(const char *game_dir, uint16 *game_n_p);
} // End of namespace Saga
diff --git a/saga/game_mod.h b/saga/game_mod.h
index 1dafdabf40..215b58ab61 100644
--- a/saga/game_mod.h
+++ b/saga/game_mod.h
@@ -26,6 +26,8 @@
#ifndef SAGA_GAME_MOD_H__
#define SAGA_GAME_MOD_H__
+#include "base/plugins.h"
+
namespace Saga {
enum R_GAME_BASETYPES {
@@ -110,6 +112,8 @@ int GAME_GetGameType();
int GAME_GetErrN();
void GAME_setGameDirectory(const char *gamedir);
const char *GAME_GetErrS();
+GameList GAME_GameList();
+DetectedGameList GAME_ProbeGame(const FSList &fslist);
} // End of namespace Saga
diff --git a/saga/gfx.cpp b/saga/gfx.cpp
index 6ca6ae2ab3..df60ff34b0 100644
--- a/saga/gfx.cpp
+++ b/saga/gfx.cpp
@@ -72,7 +72,7 @@ int GFX_SimpleBlit(R_SURFACE *dst_s, R_SURFACE *src_s) {
src_p = src_s->buf;
dst_p = dst_s->buf;
- w = src_s->buf_w * (dst_s->bpp / 8);
+ w = src_s->buf_w;
p = src_s->buf_pitch;
for (y = 0; y < src_s->buf_h; y++) {
diff --git a/saga/image.cpp b/saga/image.cpp
index 319cab0834..1db32b7bcc 100644
--- a/saga/image.cpp
+++ b/saga/image.cpp
@@ -22,7 +22,7 @@
*/
// SAGA Image resource management routines
-
+#include "saga.h"
#include "reinherit.h"
#include "yslib.h"
diff --git a/saga/interface.cpp b/saga/interface.cpp
index d5b16c0a8b..6644796566 100644
--- a/saga/interface.cpp
+++ b/saga/interface.cpp
@@ -22,7 +22,7 @@
*/
// Game interface module
-
+#include "saga.h"
#include "reinherit.h"
#include "yslib.h"
diff --git a/saga/isomap.cpp b/saga/isomap.cpp
index 0236034288..894d6a55f4 100644
--- a/saga/isomap.cpp
+++ b/saga/isomap.cpp
@@ -22,7 +22,7 @@
*/
// Isometric level module
-
+#include "saga.h"
#include "reinherit.h"
#include "yslib.h"
diff --git a/saga/palanim.cpp b/saga/palanim.cpp
index 693a846eca..4c3aef330f 100644
--- a/saga/palanim.cpp
+++ b/saga/palanim.cpp
@@ -22,7 +22,7 @@
*/
// Palette animation module
-
+#include "saga.h"
#include "reinherit.h"
#include "yslib.h"
diff --git a/saga/reinherit.h b/saga/reinherit.h
index 06afa6a918..36dcea552a 100644
--- a/saga/reinherit.h
+++ b/saga/reinherit.h
@@ -71,7 +71,6 @@ struct R_SURFACE {
int buf_w;
int buf_h;
int buf_pitch;
- int bpp;
R_RECT clip_rect;
void *impl_src;
};
diff --git a/saga/saga.cpp b/saga/saga.cpp
index d27a6f3850..e8660e88ec 100644
--- a/saga/saga.cpp
+++ b/saga/saga.cpp
@@ -46,6 +46,7 @@
#include "actionmap_mod.h"
#include "font_mod.h"
#include "game_mod.h"
+#include "game.h"
#include "interface_mod.h"
#include "isomap_mod.h"
#include "script_mod.h"
@@ -56,60 +57,14 @@
#include "objectmap_mod.h"
#include "sound.h"
#include "music.h"
-
-struct SAGAGameSettings {
- const char *name;
- const char *description;
- byte id;
- uint32 features;
- const char *detectname;
- GameSettings toGameSettings() const {
- GameSettings dummy = { name, description, features };
- return dummy;
- }
-};
-
-static const SAGAGameSettings saga_settings[] = {
- /* Inherit the Earth - Original floppy version */
- { "ite", "Inherit the Earth (DOS)", Saga::GID_ITE,
- MDT_ADLIB, "ite.rsc" },
- /* Inherit the Earth - CD version */
- { "itecd", "Inherit the Earth (DOS CD Version)", Saga::GID_ITECD,
- MDT_ADLIB, "sounds.rsc" },
- /* I Have No Mouth and I Must Scream */
- { "ihnm", "I Have No Mouth and I Must Scream (DOS)", Saga::GID_IHNM,
- MDT_ADLIB, "scream.res" },
-
- { NULL, NULL, 0, 0, NULL }
-};
+#include "game_mod.h"
GameList Engine_SAGA_gameList() {
- const SAGAGameSettings *g = saga_settings;
- GameList games;
- while (g->name) {
- games.push_back(g->toGameSettings());
- g++;
- }
- return games;
+ return Saga::GAME_GameList();
}
DetectedGameList Engine_SAGA_detectGames(const FSList &fslist) {
- DetectedGameList detectedGames;
- const SAGAGameSettings *g;
-
- for (g = saga_settings; g->name; ++g) {
- // Iterate over all files in the given directory
- for (FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) {
- const char *gameName = file->displayName().c_str();
-
- if (0 == scumm_stricmp(g->detectname, gameName)) {
- // Match found, add to list of candidates, then abort inner loop.
- detectedGames.push_back(g->toGameSettings());
- break;
- }
- }
- }
- return detectedGames;
+ return Saga::GAME_ProbeGame(fslist);
}
Engine *Engine_SAGA_create(GameDetector *detector, OSystem *syst) {
diff --git a/saga/scene.cpp b/saga/scene.cpp
index 7a525174fe..6ddef0eac5 100644
--- a/saga/scene.cpp
+++ b/saga/scene.cpp
@@ -22,7 +22,7 @@
*/
// Scene management module
-
+#include "saga.h"
#include "reinherit.h"
#include "yslib.h"
diff --git a/saga/script.cpp b/saga/script.cpp
index bbb51e6a02..103ea24711 100644
--- a/saga/script.cpp
+++ b/saga/script.cpp
@@ -22,7 +22,7 @@
*/
// Scripting module: Script resource handling functions
-
+#include "saga.h"
#include "reinherit.h"
#include "yslib.h"
diff --git a/saga/sprite.cpp b/saga/sprite.cpp
index e47c175c02..e401261264 100644
--- a/saga/sprite.cpp
+++ b/saga/sprite.cpp
@@ -22,7 +22,7 @@
*/
// Sprite management module
-
+#include "saga.h"
#include "reinherit.h"
#include "yslib.h"
diff --git a/saga/sysgfx.cpp b/saga/sysgfx.cpp
index 6c8ad4d8ac..1f81d58707 100644
--- a/saga/sysgfx.cpp
+++ b/saga/sysgfx.cpp
@@ -44,7 +44,6 @@ int SYSGFX_Init(OSystem *system, int width, int height) {
r_back_buf.buf_w = width;
r_back_buf.buf_h = height;
r_back_buf.buf_pitch = width;
- r_back_buf.bpp = 8;
r_back_buf.clip_rect.left = 0;
r_back_buf.clip_rect.top = 0;