basic grim demo support

This commit is contained in:
Pawel Kolodziejski 2005-08-27 16:08:44 +00:00
parent 374d591195
commit 58e3e0903b
9 changed files with 56 additions and 12 deletions

View file

@ -35,6 +35,7 @@ Engine *g_engine = NULL;
extern Imuse *g_imuse;
int g_imuseState = -1;
int g_flags = 0;
#ifdef _WIN32

View file

@ -38,6 +38,10 @@ class Actor;
#define ENGINE_MODE_SMUSH 3
#define ENGINE_MODE_DRAW 4
extern int g_flags;
#define GF_DEMO 1
// Fake SDLK_* values for joystick and mouse events
enum {
SDLK_JOY1_B1 = SDLK_LAST,

View file

@ -19,6 +19,7 @@
#include "debug.h"
#include "localize.h"
#include "registry.h"
#include "engine.h"
#include <cstdio>
#include <cstring>
@ -29,6 +30,9 @@ Localizer::Localizer() {
std::FILE *f;
const char *namesToTry[] = { "/GRIM.TAB", "/Grim.tab", "/grim.tab" };
if (g_flags & GF_DEMO)
return;
for (unsigned i = 0; i < sizeof(namesToTry) / sizeof(namesToTry[0]); i++) {
const char *datadir = g_registry->get("DataDir", NULL);
std::string fname = (datadir != NULL ? datadir : ".");

View file

@ -2990,6 +2990,9 @@ static void SetEmergencyFont() {
if(debugLevel == DEBUG_ERROR || debugLevel == DEBUG_ALL)
error("OPCODE USAGE VERIFICATION: SetEmergencyFont");
}
static void LoadBundle() {
// loading grimdemo1.lab is allready handled
}
/* Generate debug information for all functions
*
@ -3119,7 +3122,6 @@ STUB_FUNC(SetCameraPosition)
STUB_FUNC(GetCameraFOV)
STUB_FUNC(SetCameraFOV)
STUB_FUNC(GetCameraRoll)
STUB_FUNC(LoadBundle)
STUB_FUNC(ActorShadow)
STUB_FUNC(ActorPuckOrient)
STUB_FUNC(GetMemoryUsage)

View file

@ -171,7 +171,9 @@ needshelp:
g_driver = new DriverGL(640, 480, 24, fullscreen);
g_imuse = new Imuse(20);
Bitmap *splash_bm = g_resourceloader->loadBitmap("splash.bm");
Bitmap *splash_bm = NULL;
if (!(g_flags & GF_DEMO))
splash_bm = g_resourceloader->loadBitmap("splash.bm");
SDL_Event event;
@ -184,6 +186,7 @@ needshelp:
#endif
g_driver->clearScreen();
if (!(g_flags & GF_DEMO))
splash_bm->draw();
g_driver->flipBuffer();

View file

@ -26,6 +26,7 @@
#include "keyframe.h"
#include "material.h"
#include "model.h"
#include "engine.h"
#include "lipsynch.h"
#include <cstring>
@ -62,16 +63,19 @@ ResourceLoader::ResourceLoader() {
#ifdef _WIN32
do {
int namelen = strlen(find_file_data.cFileName);
if ((namelen > 4) && (stricmp(find_file_data.cFileName + namelen - 4, ".lab") == 0)) {
if (namelen > 4 && ((stricmp(find_file_data.cFileName + namelen - 4, ".lab") == 0) || (stricmp(find_file_data.cFileName + namelen - 4, ".mus") == 0))) {
std::string fullname = dir_str + find_file_data.cFileName;
Lab *l = new Lab(fullname.c_str());
lab_counter++;
if (l->isOpen())
if (l->isOpen()) {
if (strstr(find_file_data.cFileName, "005"))
_labs.push_front(l);
else
else {
if (strstr(find_file_data.cFileName, "gfdemo01"))
g_flags |= GF_DEMO;
_labs.push_back(l);
else
}
} else
delete l;
}
} while (FindNextFile(d, &find_file_data));
@ -80,7 +84,7 @@ ResourceLoader::ResourceLoader() {
dirent *de;
while ((de = readdir(d)) != NULL) {
int namelen = strlen(de->d_name);
if (namelen > 4 && strcasecmp(de->d_name + namelen - 4, ".lab") == 0) {
if (namelen > 4 && ((strcasecmp(de->d_name + namelen - 4, ".lab") == 0) || (strcasecmp(de->d_name + namelen - 4, ".mus") == 0))) {
std::string fullname = dir_str + de->d_name;
Lab *l = new Lab(fullname.c_str());
lab_counter++;
@ -88,8 +92,11 @@ ResourceLoader::ResourceLoader() {
// Handle the Grim 1.1 patch's datafile
if (strstr(de->d_name, "005"))
_labs.push_front(l);
else
else {
if (strstr(find_file_data.cFileName, "gfdemo01"))
g_flags |= GF_DEMO;
_labs.push_back(l);
}
else
delete l;
}

View file

@ -24,6 +24,7 @@
#include "colormap.h"
#include "vector3d.h"
#include "driver.h"
#include "engine.h"
#include "imuse/imuse.h"
@ -44,6 +45,15 @@ Scene::Scene(const char *name, const char *buf, int len) :
_cmaps[i] = g_resourceloader->loadColormap(cmap_name);
}
if (g_flags & GF_DEMO) {
ts.expectString("section: objectstates");
ts.scanString(" tot_objects %d", 1, &_numObjectStates);
char object_name[256];
ts.scanString(" object %256s", 1, object_name);
} else {
_numObjectStates = 0;
}
ts.expectString("section: setups");
ts.scanString(" numsetups %d", 1, &_numSetups);
_setups = new Setup[_numSetups];
@ -138,6 +148,8 @@ void Scene::Setup::load(TextSplitter &ts) {
ts.scanString(" fov %f", 1, &_fov);
ts.scanString(" nclip %f", 1, &_nclip);
ts.scanString(" fclip %f", 1, &_fclip);
if (ts.checkString("object_art"))
ts.scanString(" object_art %256s", 1, &buf);
}
void Scene::Light::load(TextSplitter &ts) {

View file

@ -128,7 +128,7 @@ private:
std::string _name;
int _numCmaps;
ResPtr<CMap> *_cmaps;
int _numSetups, _numLights, _numSectors;
int _numSetups, _numLights, _numSectors, _numObjectStates;
bool _enableLights;
Sector *_sectors;
Light *_lights;

View file

@ -36,11 +36,22 @@ int residual_vsscanf(const char *str, int field_count, const char *format, va_li
unsigned int f08 = va_arg(ap, long);
unsigned int f09 = va_arg(ap, long);
unsigned int f10 = va_arg(ap, long);
unsigned int f11 = va_arg(ap, long);
unsigned int f12 = va_arg(ap, long);
unsigned int f13 = va_arg(ap, long);
unsigned int f14 = va_arg(ap, long);
unsigned int f15 = va_arg(ap, long);
unsigned int f16 = va_arg(ap, long);
unsigned int f17 = va_arg(ap, long);
unsigned int f18 = va_arg(ap, long);
unsigned int f19 = va_arg(ap, long);
unsigned int f20 = va_arg(ap, long);
if (field_count > 10)
if (field_count > 20)
error("Too many fields requested of residual_vsscanf (%d)", field_count);
return sscanf(str, format, f01, f02, f03, f04, f05, f06, f07, f08, f09, f10);
return sscanf(str, format, f01, f02, f03, f04, f05, f06, f07, f08, f09, f10,
f11, f12, f13, f14, f15, f16, f17, f18, f19, f20);
}
TextSplitter::TextSplitter(const char *data, int len) {