aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorjohndoe1232013-01-06 22:41:04 +0000
committerWillem Jan Palenstijn2013-05-08 20:47:38 +0200
commit0f1aa64fd0172c374c491bcfba4ac7baa2394d2e (patch)
tree491212c167cf2f25dca8dadab0574701cac7a814 /engines
parent060287a4f85189cce3bb3b1b864b85cd81ee5c2f (diff)
downloadscummvm-rg350-0f1aa64fd0172c374c491bcfba4ac7baa2394d2e.tar.gz
scummvm-rg350-0f1aa64fd0172c374c491bcfba4ac7baa2394d2e.tar.bz2
scummvm-rg350-0f1aa64fd0172c374c491bcfba4ac7baa2394d2e.zip
NEVERHOOD: Add support for the demo version
- Remove debug resource dumping code - Fix Scene1501 (pictures without sound weren't displayed/too fast) - Move main loop to mainLoop method
Diffstat (limited to 'engines')
-rw-r--r--engines/neverhood/detection.cpp21
-rw-r--r--engines/neverhood/gamemodule.cpp50
-rw-r--r--engines/neverhood/module.cpp5
-rw-r--r--engines/neverhood/module.h1
-rw-r--r--engines/neverhood/module1000.cpp10
-rw-r--r--engines/neverhood/module1500.cpp2
-rw-r--r--engines/neverhood/module2300.cpp8
-rw-r--r--engines/neverhood/module2600.cpp22
-rw-r--r--engines/neverhood/neverhood.cpp151
-rw-r--r--engines/neverhood/neverhood.h4
-rw-r--r--engines/neverhood/resourceman.cpp2
11 files changed, 139 insertions, 137 deletions
diff --git a/engines/neverhood/detection.cpp b/engines/neverhood/detection.cpp
index ed7053ac34..c40b9e76c7 100644
--- a/engines/neverhood/detection.cpp
+++ b/engines/neverhood/detection.cpp
@@ -55,6 +55,10 @@ uint16 NeverhoodEngine::getVersion() const {
return _gameDescription->version;
}
+bool NeverhoodEngine::isDemo() const {
+ return _gameDescription->desc.flags & ADGF_DEMO;
+}
+
}
static const PlainGameDescriptor neverhoodGames[] = {
@@ -84,6 +88,23 @@ static const NeverhoodGameDescription gameDescriptions[] = {
0,
},
+ {
+ // Neverhood English demo version
+ {
+ "neverhood",
+ "Demo",
+ AD_ENTRY1s("nevdemo.blb", "05b735cfb1086892bec79b54dca5545b", 22564568),
+ Common::EN_ANY,
+ Common::kPlatformWindows,
+ ADGF_DEMO,
+ GUIO1(GUIO_NONE)
+ },
+ 0,
+ 0,
+ 0,
+ 0,
+ },
+
{ AD_TABLE_END_MARKER, 0, 0, 0, 0 }
};
diff --git a/engines/neverhood/gamemodule.cpp b/engines/neverhood/gamemodule.cpp
index 7d5932be42..548b3585cd 100644
--- a/engines/neverhood/gamemodule.cpp
+++ b/engines/neverhood/gamemodule.cpp
@@ -149,7 +149,9 @@ void GameModule::handleKeyDown(Common::KeyCode keyCode) {
}
void GameModule::handleEscapeKey() {
- if (!_prevChildObject /* && _canRequestMainMenu TODO?*/)
+ if (_vm->isDemo())
+ _vm->quitGame();
+ else if (!_prevChildObject /* && _canRequestMainMenu TODO?*/)
_mainMenuRequested = true;
else if (_childObject)
sendMessage(_childObject, 0x000C, 0);
@@ -316,8 +318,9 @@ uint32 GameModule::handleMessage(int messageNum, const MessageParam &param, Enti
void GameModule::startup() {
// TODO: Displaying of error text probably not needed in ScummVM
-// createModule(1500, 0); // Logos and intro video //Real
-
+#if 1
+ createModule(1500, 0); // Logos and intro video //Real
+#else
// DEBUG>>>
/*
setGlobalVar(V_SEEN_MUSIC_BOX, 1);
@@ -417,7 +420,7 @@ void GameModule::startup() {
_vm->gameState().sceneNum = 1;
createModule(2700, -1);
#endif
-#if 1
+#if 0
_vm->gameState().sceneNum = 1;
createModule(2800, -1);
#endif
@@ -426,9 +429,11 @@ void GameModule::startup() {
_vm->gameState().sceneNum = 0;
createModule(2500, -1);
#endif
-#if 0
+#if 1
_vm->gameState().sceneNum = 1;
- createModule(2400, -1);
+ createModule(2300, -1);
+#endif
+
#endif
}
@@ -528,6 +533,9 @@ void GameModule::createModule(int moduleNum, int which) {
setGlobalVar(V_MODULE_NAME, 0x81293110);
_childObject = new Module3000(_vm, this, which);
break;
+ case 9999:
+ createDemoScene();
+ break;
default:
error("GameModule::createModule() Could not create module %d", moduleNum);
}
@@ -689,17 +697,18 @@ void GameModule::updateModule() {
createModule(2300, 1);
break;
case 2300:
- if (_moduleResult == 1) {
- createModule(2200, 0);
- } else if (_moduleResult == 2) {
+ if (_moduleResult == 2)
createModule(1200, 0);
- } else if (_moduleResult == 3) {
+ else if (_moduleResult == 0)
+ createModule(1000, 1);
+ else if (_vm->isDemo())
+ createModule(9999, -1);
+ else if (_moduleResult == 1)
+ createModule(2200, 0);
+ else if (_moduleResult == 3)
createModule(2400, 0);
- } else if (_moduleResult == 4) {
+ else if (_moduleResult == 4)
createModule(3000, 0);
- } else {
- createModule(1000, 1);
- }
break;
case 2400:
createModule(2300, 3);
@@ -708,21 +717,19 @@ void GameModule::updateModule() {
createModule(2600, 1);
break;
case 2600:
- if (_moduleResult == 1) {
+ if (_moduleResult == 1)
createModule(2500, 0);
- } else {
+ else
createModule(1200, 1);
- }
break;
case 2700:
createModule(1800, 2);
break;
case 2800:
- if (_moduleResult == 1) {
+ if (_moduleResult == 1)
createModule(2900, 5);
- } else {
+ else
createModule(1800, 0);
- }
break;
case 2900:
if (_moduleResult != 0xFFFFFFFF) {
@@ -786,6 +793,9 @@ void GameModule::updateModule() {
createModule(2300, 4);
}
break;
+ case 9999:
+ createModuleByHash(getGlobalVar(V_MODULE_NAME));
+ break;
}
}
}
diff --git a/engines/neverhood/module.cpp b/engines/neverhood/module.cpp
index 1cd6c0d0b1..aeeb62f65c 100644
--- a/engines/neverhood/module.cpp
+++ b/engines/neverhood/module.cpp
@@ -24,6 +24,7 @@
#include "neverhood/navigationscene.h"
#include "neverhood/smackerscene.h"
#include "neverhood/module1000.h"
+#include "neverhood/module1500.h"
namespace Neverhood {
@@ -98,6 +99,10 @@ void Module::createStaticScene(uint32 backgroundFileHash, uint32 cursorFileHash)
_childObject = new StaticScene(_vm, this, backgroundFileHash, cursorFileHash);
}
+void Module::createDemoScene() {
+ _childObject = new Scene1501(_vm, this, 0x0009B624, 0, 288, 0);
+}
+
bool Module::updateChild() {
if (_childObject) {
_childObject->handleUpdate();
diff --git a/engines/neverhood/module.h b/engines/neverhood/module.h
index bb01218364..576a5a4b78 100644
--- a/engines/neverhood/module.h
+++ b/engines/neverhood/module.h
@@ -62,6 +62,7 @@ protected:
void createSmackerScene(uint32 fileHash, bool doubleSurface, bool flag1, bool canAbort);
void createSmackerScene(const uint32 *fileHashList, bool doubleSurface, bool flag1, bool canAbort);
void createStaticScene(uint32 backgroundFileHash, uint32 cursorFileHash);
+ void createDemoScene();
bool updateChild();
void leaveModule(uint32 result);
};
diff --git a/engines/neverhood/module1000.cpp b/engines/neverhood/module1000.cpp
index caa446639b..1aaa0c21a8 100644
--- a/engines/neverhood/module1000.cpp
+++ b/engines/neverhood/module1000.cpp
@@ -95,9 +95,13 @@ void Module1000::updateScene() {
case 1:
if (_moduleResult == 1)
leaveModule(0);
- else if (_moduleResult == 2)
- createScene(3, 0);
- else
+ else if (_moduleResult == 2) {
+ if (_vm->isDemo())
+ // Demo version returns to the same scene
+ createScene(1, 2);
+ else
+ createScene(3, 0);
+ } else
createScene(0, 1);
break;
case 2:
diff --git a/engines/neverhood/module1500.cpp b/engines/neverhood/module1500.cpp
index 98c55bcc13..328bda39a4 100644
--- a/engines/neverhood/module1500.cpp
+++ b/engines/neverhood/module1500.cpp
@@ -106,7 +106,7 @@ void Scene1501::update() {
_vm->_screen->clear();
leaveScene(0);
}
- } else if ((_countdown2 != 0 && (--_countdown2 == 0)) || !isSoundPlaying(0)) {
+ } else if ((_countdown2 != 0 && (--_countdown2 == 0)) || (_countdown2 == 0 && !isSoundPlaying(0))) {
_countdown1 = 12;
_palette->startFadeToBlack(11);
}
diff --git a/engines/neverhood/module2300.cpp b/engines/neverhood/module2300.cpp
index 2c43afef38..937ba9a4f3 100644
--- a/engines/neverhood/module2300.cpp
+++ b/engines/neverhood/module2300.cpp
@@ -105,6 +105,9 @@ void Module2300::createScene(int sceneNum, int which) {
_vm->_soundMan->setTwoSoundsPlayFlag(true);
createSmackerScene(0x20080A0B, true, true, false);
break;
+ case 9999:
+ createDemoScene();
+ break;
}
SetUpdateHandler(&Module2300::updateScene);
_childObject->handleUpdate();
@@ -122,6 +125,8 @@ void Module2300::updateScene() {
case 1:
if (_moduleResult == 1)
createScene(0, 0);
+ else if (_vm->isDemo())
+ createScene(9999, 0);
else if (_moduleResult == 2)
createScene(2, 1);
else if (_moduleResult == 3)
@@ -149,6 +154,9 @@ void Module2300::updateScene() {
_vm->_soundMan->setTwoSoundsPlayFlag(false);
createScene(1, 2);
break;
+ case 9999:
+ createScene(1, -1);
+ break;
}
} else {
switch (_sceneNum) {
diff --git a/engines/neverhood/module2600.cpp b/engines/neverhood/module2600.cpp
index 4ddcc38978..741f4138b9 100644
--- a/engines/neverhood/module2600.cpp
+++ b/engines/neverhood/module2600.cpp
@@ -124,6 +124,9 @@ void Module2600::createScene(int sceneNum, int which) {
else
createSmackerScene(0x42980941, true, true, false);
break;
+ case 9999:
+ createDemoScene();
+ break;
}
SetUpdateHandler(&Module2600::updateScene);
_childObject->handleUpdate();
@@ -151,8 +154,12 @@ void Module2600::updateScene() {
case 2:
if (_moduleResult == 0)
createScene(1, 0);
- else if (_moduleResult == 1)
- createScene(1002, -1);
+ else if (_moduleResult == 1) {
+ if (_vm->isDemo())
+ createScene(9999, -1);
+ else
+ createScene(1002, -1);
+ }
break;
case 3:
if (_moduleResult == 0) {
@@ -178,8 +185,12 @@ void Module2600::updateScene() {
createScene(3, 1);
break;
case 6:
- if (_moduleResult == 0)
- createScene(1006, -1);
+ if (_moduleResult == 0) {
+ if (_vm->isDemo())
+ createScene(9999, -1);
+ else
+ createScene(1006, -1);
+ }
else if (_moduleResult == 1)
createScene(1, 2);
break;
@@ -201,6 +212,9 @@ void Module2600::updateScene() {
case 1008:
createScene(6, 0);
break;
+ case 9999:
+ createScene(_vm->gameState().sceneNum, -1);
+ break;
}
}
}
diff --git a/engines/neverhood/neverhood.cpp b/engines/neverhood/neverhood.cpp
index fbb8df319b..ae181ff952 100644
--- a/engines/neverhood/neverhood.cpp
+++ b/engines/neverhood/neverhood.cpp
@@ -76,13 +76,19 @@ Common::Error NeverhoodEngine::run() {
_screen = new Screen(this);
_res = new ResourceMan();
- _res->addArchive("a.blb");
- _res->addArchive("c.blb");
- _res->addArchive("hd.blb");
- _res->addArchive("i.blb");
- _res->addArchive("m.blb");
- _res->addArchive("s.blb");
- _res->addArchive("t.blb");
+
+ if (isDemo()) {
+ _res->addArchive("a.blb");
+ _res->addArchive("nevdemo.blb");
+ } else {
+ _res->addArchive("a.blb");
+ _res->addArchive("c.blb");
+ _res->addArchive("hd.blb");
+ _res->addArchive("i.blb");
+ _res->addArchive("m.blb");
+ _res->addArchive("s.blb");
+ _res->addArchive("t.blb");
+ }
CursorMan.showMouse(true);
@@ -97,13 +103,42 @@ Common::Error NeverhoodEngine::run() {
// TODO Check if this can actually be false...
_isSaveAllowed = true;
- uint32 nextFrameTime = 0;
+ if (isDemo()) {
+ // Adjust some navigation lists for the demo version...
+ NavigationList *navigationList = _staticData->getNavigationList(0x004B67E8);
+ (*navigationList)[0].middleSmackerFileHash = 0;
+ (*navigationList)[0].middleFlag = 1;
+ (*navigationList)[2].middleSmackerFileHash = 0;
+ (*navigationList)[2].middleFlag = 1;
+ (*navigationList)[4].middleSmackerFileHash = 0;
+ (*navigationList)[4].middleFlag = 1;
+ (*navigationList)[5].middleSmackerFileHash = 0;
+ (*navigationList)[5].middleFlag = 1;
+ }
+
+ mainLoop();
+
+ delete _gameModule;
+ delete _collisionMan;
+ delete _soundMan;
+ delete _audioResourceMan;
+
+ delete _res;
+ delete _screen;
- // Preliminary main loop, needs some more work but works for testing
+ delete _gameVars;
+ delete _staticData;
+
+ debug("Ok.");
+
+ return Common::kNoError;
+}
+
+void NeverhoodEngine::mainLoop() {
+ uint32 nextFrameTime = 0;
while (!shouldQuit()) {
Common::Event event;
Common::EventManager *eventMan = _system->getEventManager();
-
while (eventMan->pollEvent(event)) {
switch (event.type) {
case Common::EVENT_KEYDOWN:
@@ -134,7 +169,6 @@ Common::Error NeverhoodEngine::run() {
break;
}
}
-
if (_system->getMillis() >= nextFrameTime) {
_gameModule->checkMainMenu();
_gameModule->handleUpdate();
@@ -142,28 +176,11 @@ Common::Error NeverhoodEngine::run() {
_screen->update();
nextFrameTime = _screen->getNextFrameTime();
};
-
_soundMan->update();
_audioResourceMan->update();
_system->updateScreen();
_system->delayMillis(10);
-
}
-
- delete _gameModule;
- delete _collisionMan;
- delete _soundMan;
- delete _audioResourceMan;
-
- delete _res;
- delete _screen;
-
- delete _gameVars;
- delete _staticData;
-
- debug("Ok.");
-
- return Common::kNoError;
}
NPoint NeverhoodEngine::getMousePos() {
@@ -173,82 +190,4 @@ NPoint NeverhoodEngine::getMousePos() {
return pt;
}
-void writeTga(const char *filename, byte *pixels, byte *palette, int16 width, int16 height) {
- byte identsize = 0;
- byte colourmaptype = 1;
- byte imagetype = 1;
- uint16 colourmapstart = 0;
- uint16 colourmaplength = 256;
- byte colourmapbits = 24;
- uint16 xstart = 0;
- uint16 ystart = 0;
- byte bits = 8;
- byte descriptor = 0x20;
- Common::DumpFile tga;
- tga.open(filename);
- tga.writeByte(identsize);
- tga.writeByte(colourmaptype);
- tga.writeByte(imagetype);
- tga.writeUint16LE(colourmapstart);
- tga.writeUint16LE(colourmaplength);
- tga.writeByte(colourmapbits);
- tga.writeUint16LE(xstart);
- tga.writeUint16LE(ystart);
- tga.writeUint16LE(width);
- tga.writeUint16LE(height);
- tga.writeByte(bits);
- tga.writeByte(descriptor);
- tga.write(palette, 768);
- tga.write(pixels, width * height);
- tga.close();
-}
-
-void NeverhoodEngine::dumpAllResources() {
-#if 0
- PaletteResource paletteResource(this);
- byte *vgaPalette = new byte[768];
- //paletteResource.load(0x4086520E);
- paletteResource.load(0x12C23307);
- byte *srcpalette = paletteResource.palette();
- for (int i = 0; i < 256; i++) {
- vgaPalette[i * 3 + 2] = srcpalette[i * 4 + 0];
- vgaPalette[i * 3 + 1] = srcpalette[i * 4 + 1];
- vgaPalette[i * 3 + 0] = srcpalette[i * 4 + 2];
- }
-
-#if 0
- for (int i = 0; i < 768; i++)
- vgaPalette[i] <<= 2;
-#endif
-
- uint entriesCount = _res->getEntryCount();
- debug("%d entries", entriesCount);
-
- for (uint i = 0; i < entriesCount; i++) {
- const ResourceFileEntry &entry = _res->getEntry(i);
- int type = _res->getResourceTypeByHash(entry.archiveEntry->fileHash);
- debug("hash: %08X; type: %d", entry.archiveEntry->fileHash, type);
- if (type == 4) {
- AnimResource anim(this);
- anim.load(entry.archiveEntry->fileHash);
- for (uint frameIndex = 0; frameIndex < anim.getFrameCount(); frameIndex++) {
- const AnimFrameInfo &frameInfo = anim.getFrameInfo(frameIndex);
- int16 width = (frameInfo.drawOffset.width + 3) & 0xFFFC;
- byte *pixels = new byte[width * frameInfo.drawOffset.height];
- memset(pixels, 0, width * frameInfo.drawOffset.height);
- anim.draw(frameIndex, pixels, width, false, false);
- Common::String filename =
- frameInfo.frameHash != 0
- ? Common::String::format("%08X_%03d_%08X.tga", entry.archiveEntry->fileHash, frameIndex, frameInfo.frameHash)
- : Common::String::format("%08X_%03d.tga", entry.archiveEntry->fileHash, frameIndex);
- writeTga(filename.c_str(), pixels, vgaPalette, width, frameInfo.drawOffset.height);
- delete[] pixels;
- }
- }
- }
-
- delete[] vgaPalette;
-#endif
-}
-
} // End of namespace Neverhood
diff --git a/engines/neverhood/neverhood.h b/engines/neverhood/neverhood.h
index a66bdb3dd7..b0f9abb2e2 100644
--- a/engines/neverhood/neverhood.h
+++ b/engines/neverhood/neverhood.h
@@ -59,6 +59,7 @@ class NeverhoodEngine : public ::Engine {
protected:
Common::Error run();
+ void mainLoop();
public:
NeverhoodEngine(OSystem *syst, const NeverhoodGameDescription *gameDesc);
@@ -71,6 +72,7 @@ public:
uint16 getVersion() const;
Common::Platform getPlatform() const;
bool hasFeature(EngineFeature f) const;
+ bool isDemo() const;
Common::RandomSource *_rnd;
@@ -130,8 +132,6 @@ public:
int16 getMouseY() const { return _mouseY; }
NPoint getMousePos();
- void dumpAllResources();
-
public:
};
diff --git a/engines/neverhood/resourceman.cpp b/engines/neverhood/resourceman.cpp
index c30e272eab..7b7d5cf236 100644
--- a/engines/neverhood/resourceman.cpp
+++ b/engines/neverhood/resourceman.cpp
@@ -77,7 +77,7 @@ ResourceFileEntry *ResourceMan::findEntry(uint32 fileHash, ResourceFileEntry **f
Common::SeekableReadStream *ResourceMan::createStream(uint32 fileHash) {
ResourceFileEntry *entry = findEntry(fileHash);
- return entry->archive->createStream(entry->archiveEntry);
+ return entry ? entry->archive->createStream(entry->archiveEntry) : NULL;
}
void ResourceMan::queryResource(uint32 fileHash, ResourceHandle &resourceHandle) {