VOYEUR: Refactoring of BoltFile now that have more than one bolt file

This commit is contained in:
Paul Gilbert 2013-12-07 20:44:28 -05:00
parent b40c34a883
commit a6ceaf2985
8 changed files with 150 additions and 54 deletions

View File

@ -73,6 +73,7 @@ EventsManager::EventsManager(): _intPtr(_gameData),
_priorFrameTime = g_system->getMillis();
Common::fill(&_keyState[0], &_keyState[256], false);
_v2A0A2 = 0;
_videoComputerNum = 0;
_videoComputerBut1 = 0;
_videoComputerBut4 = 0;

View File

@ -66,7 +66,7 @@ public:
int _RTVNum;
int _switchBGNum;
int _group;
int _resolvePtr;
const int *_resolvePtr;
int _seconds;
int _minutes;
int _hours;
@ -171,6 +171,7 @@ public:
int _fadeCount;
int _fadeStatus;
int _v2A0A2;
int _videoComputerNum;
int _videoComputerBut1;
int _videoComputerBut4;

View File

@ -185,9 +185,14 @@ bool FilesManager::openBoltLib(const Common::String &filename, BoltFile *&boltFi
return true;
}
// TODO: Specific library classes for buoy.blt versus stampblt.blt
// Create the bolt file interface object and load the index
boltFile = _boltFilesState._curLibPtr = new BoltFile(_boltFilesState);
if (filename == "bvoy.blt")
boltFile = _boltFilesState._curLibPtr = new BVoyBoltFile(_boltFilesState);
else if (filename == "stampblt.blt")
boltFile = _boltFilesState._curLibPtr = new StampBoltFile(_boltFilesState);
else
error("Unknown bolt file specified");
return true;
}
@ -212,20 +217,10 @@ byte *FilesManager::fload(const Common::String &filename, int *size) {
/*------------------------------------------------------------------------*/
const BoltMethodPtr BoltFile::_fnInitType[25] = {
&BoltFile::initDefault, &BoltFile::initDefault, &BoltFile::initDefault, &BoltFile::initDefault,
&BoltFile::initDefault, &BoltFile::initDefault, &BoltFile::initDefault, &BoltFile::initDefault,
&BoltFile::sInitPic, &BoltFile::initDefault, &BoltFile::vInitCMap, &BoltFile::vInitCycl,
&BoltFile::initDefault, &BoltFile::initDefault, &BoltFile::initDefault, &BoltFile::initViewPort,
&BoltFile::initViewPortList, &BoltFile::initFont, &BoltFile::initFontInfo,
&BoltFile::initSoundMap, &BoltFile::initDefault, &BoltFile::initDefault, &BoltFile::initDefault,
&BoltFile::initDefault, &BoltFile::initDefault
};
BoltFile::BoltFile(BoltFilesState &state): _state(state) {
BoltFile::BoltFile(const Common::String &filename, BoltFilesState &state): _state(state) {
_state._curFd = &_file;
if (!_file.open("bvoy.blt"))
error("Could not open buoy.blt");
if (!_file.open(filename))
error("Could not open %s", filename.c_str());
_state._curFilePosition = 0;
// Read in the file header
@ -403,7 +398,7 @@ byte *BoltFile::getBoltMember(uint32 id) {
if (_state._curGroupPtr->_processed) {
// TODO: Figure out weird access type. Uncompressed read perhaps?
//int fileDiff = _state._curGroupPtr->_fileOffset - _state._curMemberPtr->_fileOffset;
error("TODO: processed bolt flag");
} else {
_state._bufStart = _state._decompressBuf;
_state._bufSize = DECOMPRESS_SIZE;
@ -425,7 +420,7 @@ byte *BoltFile::getBoltMember(uint32 id) {
// Initialise the resource
assert(_state._curMemberPtr->_initMethod < 25);
(this->*_fnInitType[_state._curMemberPtr->_initMethod])();
initResource(_state._curMemberPtr->_initMethod);
return _state._curMemberPtr->_data;
}
@ -435,27 +430,44 @@ void BoltFile::initDefault() {
_state._curMemberPtr->_mode);
}
void BoltFile::sInitPic() {
// Read in the header data
_state._curMemberPtr->_data = _state.decompress(NULL, 24, _state._curMemberPtr->_mode);
_state._curMemberPtr->_picResource = new PictureResource(_state,
_state._curMemberPtr->_data);
/*------------------------------------------------------------------------*/
BVoyBoltFile::BVoyBoltFile(BoltFilesState &state): BoltFile("bvoy.blt", state) {
}
void BoltFile::vInitCMap() {
initDefault();
_state._curMemberPtr->_cMapResource = new CMapResource(
_state, _state._curMemberPtr->_data);
void BVoyBoltFile::initResource(int resType) {
switch (resType) {
case 8:
sInitPic();
break;
case 10:
vInitCMap();
break;
case 11:
vInitCycl();
break;
case 15:
initViewPort();
break;
case 16:
initViewPortList();
break;
case 17:
initFont();
break;
case 18:
initFontInfo();
break;
case 19:
initSoundMap();
break;
default:
initDefault();
break;
}
}
void BoltFile::vInitCycl() {
initDefault();
_state._vm->_eventsManager.vStopCycle();
_state._curMemberPtr->_vInitCyclResource = new VInitCyclResource(
_state, _state._curMemberPtr->_data);
}
void BoltFile::initViewPort() {
void BVoyBoltFile::initViewPort() {
initDefault();
ViewPortResource *viewPort;
@ -467,7 +479,7 @@ void BoltFile::initViewPort() {
viewPort->_parent = getBoltEntryFromLong(READ_LE_UINT32(src + 2))._viewPortResource;
}
void BoltFile::initViewPortList() {
void BVoyBoltFile::initViewPortList() {
initDefault();
ViewPortListResource *res;
@ -478,21 +490,54 @@ void BoltFile::initViewPortList() {
_state._vm->_graphicsManager._vPort = &res->_entries[0];
}
void BoltFile::initFontInfo() {
void BVoyBoltFile::initFontInfo() {
initDefault();
_state._curMemberPtr->_fontInfoResource = new FontInfoResource(
_state, _state._curMemberPtr->_data);
}
void BoltFile::initFont() {
void BVoyBoltFile::initFont() {
initDefault();
_state._curMemberPtr->_fontResource = new FontResource(_state, _state._curMemberPtr->_data);
}
void BoltFile::initSoundMap() {
void BVoyBoltFile::initSoundMap() {
initDefault();
}
void BVoyBoltFile::sInitPic() {
// Read in the header data
_state._curMemberPtr->_data = _state.decompress(NULL, 24, _state._curMemberPtr->_mode);
_state._curMemberPtr->_picResource = new PictureResource(_state,
_state._curMemberPtr->_data);
}
void BVoyBoltFile::vInitCMap() {
initDefault();
_state._curMemberPtr->_cMapResource = new CMapResource(
_state, _state._curMemberPtr->_data);
}
void BVoyBoltFile::vInitCycl() {
initDefault();
_state._vm->_eventsManager.vStopCycle();
_state._curMemberPtr->_vInitCyclResource = new VInitCyclResource(
_state, _state._curMemberPtr->_data);
}
/*------------------------------------------------------------------------*/
StampBoltFile::StampBoltFile(BoltFilesState &state): BoltFile("stampblt.blt", state) {
}
void StampBoltFile::initResource(int resType) {
switch (resType) {
default:
initDefault();
break;
}
}
/*------------------------------------------------------------------------*/
BoltGroup::BoltGroup(Common::SeekableReadStream *f): _file(f) {

View File

@ -44,8 +44,6 @@ class VInitCyclResource;
#define DECOMPRESS_SIZE 0x7000
typedef void (BoltFile::*BoltMethodPtr)();
class ResolveEntry {
public:
uint32 _id;
@ -98,22 +96,13 @@ public:
class BoltFile {
private:
static const BoltMethodPtr _fnInitType[25];
private:
BoltFilesState &_state;
Common::Array<BoltGroup> _groups;
Common::File _file;
protected:
BoltFilesState &_state;
// initType method table
virtual void initResource(int resType) = 0;
void initDefault();
void sInitPic();
void vInitCMap();
void vInitCycl();
void initViewPort();
void initViewPortList();
void initFontInfo();
void initFont();
void initSoundMap();
private:
void resolveAll();
byte *getBoltMember(uint32 id);
@ -124,7 +113,7 @@ private:
void initGro() {} // TODO
void termGro() {} // TODO
public:
BoltFile(BoltFilesState &state);
BoltFile(const Common::String &filename, BoltFilesState &state);
~BoltFile();
bool getBoltGroup(uint32 id);
@ -140,6 +129,30 @@ public:
CMapResource *getCMapResource(uint32 id);
};
class BVoyBoltFile: public BoltFile {
private:
// initType method table
void sInitPic();
void vInitCMap();
void vInitCycl();
void initViewPort();
void initViewPortList();
void initFontInfo();
void initFont();
void initSoundMap();
protected:
virtual void initResource(int resType);
public:
BVoyBoltFile(BoltFilesState &state);
};
class StampBoltFile: public BoltFile {
protected:
virtual void initResource(int resType);
public:
StampBoltFile(BoltFilesState &state);
};
class BoltGroup {
private:
Common::SeekableReadStream *_file;

View File

@ -33,4 +33,14 @@ const int COMPUTER_DEFAULTS[] = {
2, 28, 0, 998, -1
};
const int RESOLVE_TABLE[] = {
0x2A00, 0x4A00, 0x1000, 0x4B00, 0x2C00, 0x4F00, 0x1400, 0x5000,
0x1700, 0x5100, 0x1800, 0x5200, 0x3300, 0x5400, 0x3700, 0x5500,
0x1A00, 0x1C00, 0x1E00, 0x1F00, 0x2100, 0x2200, 0x2400, 0x2700,
0x2B00, 0x1100, 0x4C00, 0x1200, 0x4D00, 0x1300, 0x4E00, 0x2E00,
0x1900, 0x3200, 0x3400, 0x3800, 0x2800, 0x3E00, 0x4100, 0x2900,
0x4400, 0x4600, 0x5300, 0x3900, 0x7600, 0x7200, 0x7300, 0x7400,
0x7500
};
} // End of namespace Voyeur

View File

@ -29,6 +29,8 @@ namespace Voyeur {
extern const int COMPUTER_DEFAULTS[];
extern const int RESOLVE_TABLE[];
} // End of namespace Voyeur
#endif

View File

@ -66,6 +66,7 @@ private:
Common::Array<int> _resolves;
FontInfoResource _defaultFontInfo;
int _iForceDeath;
byte *_stampData;
void ESP_Init();
void initialiseManagers();
@ -80,7 +81,9 @@ private:
bool doLock();
void showTitleScreen();
void doOpening();
void playStamp();
void initThreadStruct(int commandId);
protected:
// Engine APIs
virtual Common::Error run();

View File

@ -21,6 +21,7 @@
*/
#include "voyeur/voyeur.h"
#include "voyeur/staticres.h"
namespace Voyeur {
@ -35,7 +36,27 @@ void VoyeurEngine::addVideoEventStart() {
}
void VoyeurEngine::playStamp() {
BoltFile *boltFile = NULL;
_filesManager.openBoltLib("stampblt.blt", boltFile);
boltFile->getBoltGroup(0x10000);
_voy._resolvePtr = &RESOLVE_TABLE[0];
byte *commandData = boltFile->memberAddr(3);
//uint32 commandId = READ_LE_UINT32(commandData);
//initThreadStruct(commandId);
_voy._delaySecs = 0;
_eventsManager._videoComputerNum = 9;
_eventsManager._videoComputerBut1 = 0;
_eventsManager._v2A0A2 = 0;
_voy._eCursorOff[53] = 1;
bool breakFlag = false;
while (!breakFlag && !shouldQuit()) {
breakFlag = true;
}
_voy._field4386 = 0;
}
} // End of namespace Voyeur