NANCY: Add support for PCAL chunk
This commit is contained in:
parent
c0fe9e83a0
commit
d73103df45
4 changed files with 36 additions and 3 deletions
|
@ -87,7 +87,7 @@ bool IFF::load() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const byte *IFF::getChunk(uint32 id, uint &size) {
|
const byte *IFF::getChunk(uint32 id, uint &size) const {
|
||||||
for (uint i = 0; i < _chunks.size(); ++i) {
|
for (uint i = 0; i < _chunks.size(); ++i) {
|
||||||
const Chunk &chunk = _chunks[i];
|
const Chunk &chunk = _chunks[i];
|
||||||
if (chunk.id == id) {
|
if (chunk.id == id) {
|
||||||
|
@ -96,7 +96,6 @@ const byte *IFF::getChunk(uint32 id, uint &size) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
warning("Failed to locate chunk");
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,7 @@ namespace Nancy {
|
||||||
class NancyEngine;
|
class NancyEngine;
|
||||||
|
|
||||||
#define ID_DATA MKTAG('D', 'A', 'T', 'A')
|
#define ID_DATA MKTAG('D', 'A', 'T', 'A')
|
||||||
|
#define ID_PCAL MKTAG('P', 'C', 'A', 'L')
|
||||||
|
|
||||||
class IFF {
|
class IFF {
|
||||||
public:
|
public:
|
||||||
|
@ -42,7 +43,7 @@ public:
|
||||||
~IFF();
|
~IFF();
|
||||||
|
|
||||||
bool load();
|
bool load();
|
||||||
const byte *getChunk(uint32 id, uint &size);
|
const byte *getChunk(uint32 id, uint &size) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Common::String idToString(uint32 id);
|
Common::String idToString(uint32 id);
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include "common/debug-channels.h"
|
#include "common/debug-channels.h"
|
||||||
#include "common/config-manager.h"
|
#include "common/config-manager.h"
|
||||||
#include "common/textconsole.h"
|
#include "common/textconsole.h"
|
||||||
|
#include "common/memstream.h"
|
||||||
|
|
||||||
#include "nancy/nancy.h"
|
#include "nancy/nancy.h"
|
||||||
#include "nancy/resource.h"
|
#include "nancy/resource.h"
|
||||||
|
@ -108,6 +109,7 @@ Common::Error NancyEngine::run() {
|
||||||
IFF *boot = new IFF(this, "boot");
|
IFF *boot = new IFF(this, "boot");
|
||||||
if (!boot->load())
|
if (!boot->load())
|
||||||
error("Failed to load boot script");
|
error("Failed to load boot script");
|
||||||
|
preloadCals(*boot);
|
||||||
delete boot;
|
delete boot;
|
||||||
|
|
||||||
Common::EventManager *ev = g_system->getEventManager();
|
Common::EventManager *ev = g_system->getEventManager();
|
||||||
|
@ -143,6 +145,35 @@ void NancyEngine::initialize() {
|
||||||
_rnd->setSeed(42); // Kick random number generator
|
_rnd->setSeed(42); // Kick random number generator
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NancyEngine::preloadCals(const IFF &boot) {
|
||||||
|
const byte *buf;
|
||||||
|
uint size;
|
||||||
|
buf = boot.getChunk(ID_PCAL, size);
|
||||||
|
|
||||||
|
if (buf) {
|
||||||
|
Common::MemoryReadStream stream(buf, size);
|
||||||
|
uint16 count = stream.readUint16LE();
|
||||||
|
debugC(1, kDebugEngine, "Preloading %d CALs", count);
|
||||||
|
int nameLen = size / count;
|
||||||
|
|
||||||
|
char *name = new char[nameLen];
|
||||||
|
|
||||||
|
for (uint i = 0; i < count; i++) {
|
||||||
|
stream.read(name, nameLen);
|
||||||
|
name[nameLen - 1] = 0;
|
||||||
|
debugC(1, kDebugEngine, "Preloading CAL '%s'", name);
|
||||||
|
if (!_res->loadCifTree(name, "cal"))
|
||||||
|
error("Failed to preload CAL '%s'", name);
|
||||||
|
}
|
||||||
|
|
||||||
|
delete[] name;
|
||||||
|
|
||||||
|
if (stream.err())
|
||||||
|
error("Error reading PCAL chunk");
|
||||||
|
} else
|
||||||
|
debugC(1, kDebugEngine, "No PCAL chunk found");
|
||||||
|
}
|
||||||
|
|
||||||
void NancyEngine::syncSoundSettings() {
|
void NancyEngine::syncSoundSettings() {
|
||||||
Engine::syncSoundSettings();
|
Engine::syncSoundSettings();
|
||||||
|
|
||||||
|
|
|
@ -66,6 +66,7 @@ enum NancyDebugChannels {
|
||||||
struct NancyGameDescription;
|
struct NancyGameDescription;
|
||||||
|
|
||||||
class ResourceManager;
|
class ResourceManager;
|
||||||
|
class IFF;
|
||||||
|
|
||||||
class NancyEngine : public Engine {
|
class NancyEngine : public Engine {
|
||||||
public:
|
public:
|
||||||
|
@ -108,6 +109,7 @@ private:
|
||||||
Common::Platform _platform;
|
Common::Platform _platform;
|
||||||
|
|
||||||
void initialize();
|
void initialize();
|
||||||
|
void preloadCals(const IFF &boot);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // End of namespace Nancy
|
} // End of namespace Nancy
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue