aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2013-06-15 11:39:28 -0400
committerPaul Gilbert2013-06-15 11:39:28 -0400
commit0a0db2bf73fc417d1094ae744e0d350dd4462d38 (patch)
tree739de6bc60f48fbbde8b01916be4dac38618365c
parentb02c72b45f0ea15490b41896e33d40cb783b96e6 (diff)
downloadscummvm-rg350-0a0db2bf73fc417d1094ae744e0d350dd4462d38.tar.gz
scummvm-rg350-0a0db2bf73fc417d1094ae744e0d350dd4462d38.tar.bz2
scummvm-rg350-0a0db2bf73fc417d1094ae744e0d350dd4462d38.zip
VOYEUR: Refactoring and bugfixes for correctly loading fontInfo and font resources
-rw-r--r--engines/voyeur/files.cpp99
-rw-r--r--engines/voyeur/files.h33
-rw-r--r--engines/voyeur/graphics.cpp42
-rw-r--r--engines/voyeur/graphics.h31
-rw-r--r--engines/voyeur/voyeur.cpp18
-rw-r--r--engines/voyeur/voyeur.h2
6 files changed, 140 insertions, 85 deletions
diff --git a/engines/voyeur/files.cpp b/engines/voyeur/files.cpp
index cfc82ddc67..94a770ae0e 100644
--- a/engines/voyeur/files.cpp
+++ b/engines/voyeur/files.cpp
@@ -217,7 +217,7 @@ const BoltMethodPtr BoltFile::_fnInitType[25] = {
&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::initDefault, &BoltFile::initFontInfo,
+ &BoltFile::initViewPortList, &BoltFile::initFont, &BoltFile::initFontInfo,
&BoltFile::initSoundMap, &BoltFile::initDefault, &BoltFile::initDefault, &BoltFile::initDefault,
&BoltFile::initDefault, &BoltFile::initDefault
};
@@ -281,7 +281,7 @@ void BoltFile::freeBoltGroup(uint32 id) {
_state._curGroupPtr->unload();
}
-BoltEntry &BoltFile::getBoltEntry(uint32 id) {
+BoltEntry &BoltFile::getBoltEntryFromLong(uint32 id) {
BoltGroup &group = _groups[id >> 24];
assert(group._loaded);
@@ -291,20 +291,32 @@ BoltEntry &BoltFile::getBoltEntry(uint32 id) {
return entry;
}
+BoltEntry &BoltFile::boltEntry(uint16 id) {
+ BoltGroup &group = _groups[id >> 8];
+ assert(group._loaded);
+
+ BoltEntry &entry = group._entries[id & 0xff];
+ assert(entry.hasResource());
+
+ return entry;
+}
+
PictureResource *BoltFile::getPictureResource(uint32 id) {
if ((int32)id == -1)
return NULL;
if (id & 0xffff)
id <<= 16;
- return getBoltEntry(id)._picResource;
+ return getBoltEntryFromLong(id)._picResource;
}
CMapResource *BoltFile::getCMapResource(uint32 id) {
if ((int32)id == -1)
return NULL;
- return getBoltEntry(id)._cMapResource;
+ if (id & 0xffff)
+ id <<= 16;
+ return getBoltEntryFromLong(id)._cMapResource;
}
byte *BoltFile::memberAddr(uint32 id) {
@@ -462,10 +474,15 @@ void BoltFile::initViewPortList() {
void BoltFile::initFontInfo() {
initDefault();
- _state._curMemberPtr->_fontResource = new FontResource(
+ _state._curMemberPtr->_fontInfoResource = new FontInfoResource(
_state, _state._curMemberPtr->_data);
}
+void BoltFile::initFont() {
+ initDefault();
+ _state._curMemberPtr->_fontResource = new FontResource(_state, _state._curMemberPtr->_data);
+}
+
void BoltFile::initSoundMap() {
initDefault();
}
@@ -514,6 +531,7 @@ BoltEntry::BoltEntry(Common::SeekableReadStream *f): _file(f) {
_viewPortResource = NULL;
_viewPortListResource = NULL;
_fontResource = NULL;
+ _fontInfoResource = NULL;
_cMapResource = NULL;
_vInitCyclResource = NULL;
@@ -533,6 +551,7 @@ BoltEntry::~BoltEntry() {
delete _viewPortResource;
delete _viewPortListResource;
delete _fontResource;
+ delete _fontInfoResource;
delete _cMapResource;
delete _vInitCyclResource;
}
@@ -547,7 +566,7 @@ void BoltEntry::load() {
*/
bool BoltEntry::hasResource() const {
return _picResource || _viewPortResource || _viewPortListResource
- || _fontResource || _cMapResource || _vInitCyclResource;
+ || _fontResource || _fontInfoResource || _cMapResource || _vInitCyclResource;
}
/*------------------------------------------------------------------------*/
@@ -660,7 +679,7 @@ PictureResource::~PictureResource() {
ViewPortResource::ViewPortResource(BoltFilesState &state, const byte *src):
_state(state) {
_flags = READ_LE_UINT16(src);
- _next = state._curLibPtr->getBoltEntry(READ_LE_UINT32(src + 2))._viewPortResource;
+ _next = state._curLibPtr->getBoltEntryFromLong(READ_LE_UINT32(src + 2))._viewPortResource;
_pageCount = READ_LE_UINT16(src + 6);
_pageIndex = READ_LE_UINT16(src + 8);
_lastPage = READ_LE_UINT16(src + 10);
@@ -797,7 +816,9 @@ void ViewPortResource::setupViewPort() {
int ViewPortResource::drawText(const Common::String &msg) {
GraphicsManager &gfxManager = _state._vm->_graphicsManager;
- FontInfo &fontInfo = *gfxManager._fontPtr;
+ assert(gfxManager._fontPtr);
+ assert(gfxManager._fontPtr->_curFont);
+ FontInfoResource &fontInfo = *gfxManager._fontPtr;
FontResource &fontData = *fontInfo._curFont;
int xShadows[9] = { 0, 1, 1, 1, 0, -1, -1, -1, 0 };
int yShadows[9] = { 0, 1, 0, -1, -1, -1, 0, 1, 1 };
@@ -1026,7 +1047,7 @@ ViewPortListResource::ViewPortListResource(BoltFilesState &state, const byte *sr
uint32 *idP = (uint32 *)&src[8];
for (uint i = 0; i < count; ++i, ++idP) {
uint32 id = READ_LE_UINT32(idP);
- BoltEntry &entry = state._curLibPtr->getBoltEntry(id);
+ BoltEntry &entry = state._curLibPtr->getBoltEntryFromLong(id);
assert(entry._viewPortResource);
_entries.push_back(entry._viewPortResource);
@@ -1072,6 +1093,66 @@ FontResource::~FontResource() {
/*------------------------------------------------------------------------*/
+FontInfoResource::FontInfoResource(BoltFilesState &state, const byte *src) {
+ _curFont = NULL;
+ _picFlags = src[4];
+ _picSelect = src[5];
+ _picPick = src[6];
+ _picOnOff = src[7];
+ _fontFlags = src[8];
+ _justify = (FontJustify)src[9];
+ _fontSaveBack = READ_LE_UINT16(src + 10);
+ _pos.x = (int16)READ_LE_UINT16(src + 12);
+ _pos.y = (int16)READ_LE_UINT16(src + 14);
+ _justifyWidth = READ_LE_UINT16(src + 16);
+ _justifyHeight = READ_LE_UINT16(src + 18);
+ _shadow.x = READ_LE_UINT16(src + 20);
+ _shadow.y = READ_LE_UINT16(src + 22);
+ _foreColor = READ_LE_UINT16(src + 24);
+ _backColor = READ_LE_UINT16(src + 26);
+ _shadowColor = READ_LE_UINT16(src + 28);
+}
+
+FontInfoResource::FontInfoResource() {
+ _curFont = NULL;
+ _picFlags = 3;
+ _picSelect = 0xff;
+ _picPick = 0xff;
+ _picOnOff = 0;
+ _fontFlags = 0;
+ _justify = ALIGN_LEFT;
+ _fontSaveBack = 0;
+ _justifyWidth = 1;
+ _justifyHeight = 1;
+ _shadow = Common::Point(1, 1);
+ _foreColor = 1;
+ _backColor = 0;
+ _shadowColor = 0;
+}
+
+FontInfoResource::FontInfoResource(byte picFlags, byte picSelect, byte picPick, byte picOnOff,
+ byte fontFlags, FontJustify justify, int fontSaveBack, const Common::Point &pos,
+ int justifyWidth, int justifyHeight, const Common::Point &shadow, int foreColor,
+ int backColor, int shadowColor) {
+ _curFont = NULL;
+ _picFlags = picFlags;
+ _picSelect = picSelect;
+ _picPick = picPick;
+ _picOnOff = picOnOff;
+ _fontFlags = fontFlags;
+ _justify = justify;
+ _fontSaveBack = fontSaveBack;
+ _pos = pos;
+ _justifyWidth = justifyWidth;
+ _justifyHeight = justifyHeight;
+ _shadow = shadow;
+ _foreColor = foreColor;
+ _backColor = backColor;
+ _shadowColor = shadowColor;
+}
+
+/*------------------------------------------------------------------------*/
+
CMapResource::CMapResource(BoltFilesState &state, const byte *src): _vm(state._vm) {
_steps = src[0];
_fadeStatus = src[1];
diff --git a/engines/voyeur/files.h b/engines/voyeur/files.h
index 499cbb8972..f612904b6d 100644
--- a/engines/voyeur/files.h
+++ b/engines/voyeur/files.h
@@ -112,6 +112,7 @@ private:
void initViewPort();
void initViewPortList();
void initFontInfo();
+ void initFont();
void initSoundMap();
private:
void resolveAll();
@@ -133,7 +134,8 @@ public:
void resolveIt(uint32 id, byte **p);
void resolveFunction(uint32 id, GraphicMethodPtr *fn);
- BoltEntry &getBoltEntry(uint32 id);
+ BoltEntry &boltEntry(uint16 id);
+ BoltEntry &getBoltEntryFromLong(uint32 id);
PictureResource *getPictureResource(uint32 id);
CMapResource *getCMapResource(uint32 id);
};
@@ -174,6 +176,7 @@ public:
ViewPortResource *_viewPortResource;
ViewPortListResource *_viewPortListResource;
FontResource *_fontResource;
+ FontInfoResource *_fontInfoResource;
CMapResource *_cMapResource;
VInitCyclResource *_vInitCyclResource;
public:
@@ -299,6 +302,34 @@ public:
virtual ~FontResource();
};
+enum FontJustify { ALIGN_LEFT = 0, ALIGN_CENTRE = 1, ALIGN_RIGHT = 2 };
+
+class FontInfoResource {
+public:
+ FontResource *_curFont;
+ byte _picFlags;
+ byte _picSelect;
+ byte _picPick;
+ byte _picOnOff;
+ byte _fontFlags;
+ FontJustify _justify;
+ int _fontSaveBack;
+ Common::Point _pos;
+ int _justifyWidth;
+ int _justifyHeight;
+ Common::Point _shadow;
+ int _foreColor;
+ int _backColor;
+ int _shadowColor;
+public:
+ FontInfoResource(BoltFilesState &state, const byte *src);
+ FontInfoResource();
+ FontInfoResource(byte picFlags, byte picSelect, byte picPick, byte picOnOff, byte fontFlags,
+ FontJustify justify, int fontSaveBack, const Common::Point &pos, int justifyWidth,
+ int justifyHeight, const Common::Point &shadow, int foreColor, int backColor,
+ int shadowColor);
+};
+
class CMapResource {
private:
VoyeurEngine *_vm;
diff --git a/engines/voyeur/graphics.cpp b/engines/voyeur/graphics.cpp
index fda7c833f7..7a6c72c027 100644
--- a/engines/voyeur/graphics.cpp
+++ b/engines/voyeur/graphics.cpp
@@ -29,42 +29,6 @@
namespace Voyeur {
-FontInfo::FontInfo() {
- _curFont = NULL;
- _picFlags = 3;
- _picSelect = 0xff;
- _picPick = 0xff;
- _picOnOff = 0;
- _fontFlags = 0;
- _justify = ALIGN_LEFT;
- _fontSaveBack = 0;
- _justifyWidth = 1;
- _justifyHeight = 1;
- _shadow = Common::Point(1, 1);
- _foreColor = 1;
- _backColor = 0;
- _shadowColor = 0;
-}
-
-FontInfo::FontInfo(byte picFlags, byte picSelect, byte picPick, byte picOnOff, byte fontFlags,
- FontJustify justify, int fontSaveBack, const Common::Point &pos, int justifyWidth, int justifyHeight,
- const Common::Point &shadow, int foreColor, int backColor, int shadowColor) {
- _curFont = NULL;
- _picSelect = picSelect;
- _picPick = picPick;
- _picOnOff = picOnOff;
- _fontFlags = fontFlags;
- _justify = justify;
- _fontSaveBack = fontSaveBack;
- _pos = pos;
- _justifyWidth = justifyWidth;
- _justifyHeight = justifyHeight;
- _shadow = shadow;
- _foreColor = foreColor;
- _backColor = backColor;
- _shadowColor = shadowColor;
-}
-
/*------------------------------------------------------------------------*/
DrawInfo::DrawInfo(int penColor, const Common::Point &pos, int flags) {
@@ -76,9 +40,8 @@ DrawInfo::DrawInfo(int penColor, const Common::Point &pos, int flags) {
/*------------------------------------------------------------------------*/
GraphicsManager::GraphicsManager():
- _defaultFontInfo(3, 0xff, 0xff, 0, 0, ALIGN_LEFT, 0, Common::Point(), 1, 1,
- Common::Point(1, 1), 1, 0, 0), _defaultDrawInfo(1, Common::Point(), 0),
- _fontPtr(&_defaultFontInfo), _drawPtr(&_defaultDrawInfo) {
+ _defaultDrawInfo(1, Common::Point(), 0),
+ _drawPtr(&_defaultDrawInfo) {
_SVGAPage = 0;
_SVGAMode = 0;
_SVGAReset = 0;
@@ -92,6 +55,7 @@ GraphicsManager::GraphicsManager():
_clipPtr = NULL;
_viewPortListPtr = NULL;
_vPort = NULL;
+ _fontPtr = NULL;
}
void GraphicsManager::sInitGraphics() {
diff --git a/engines/voyeur/graphics.h b/engines/voyeur/graphics.h
index 9c66a32a67..02e9698a5e 100644
--- a/engines/voyeur/graphics.h
+++ b/engines/voyeur/graphics.h
@@ -43,35 +43,9 @@ class PictureResource;
class ViewPortResource;
class ViewPortListResource;
class FontResource;
+class FontInfoResource;
class CMapResource;
-enum FontJustify { ALIGN_LEFT = 0, ALIGN_CENTRE = 1, ALIGN_RIGHT = 2 };
-
-class FontInfo {
-public:
- FontResource *_curFont;
- byte _picFlags;
- byte _picSelect;
- byte _picPick;
- byte _picOnOff;
- byte _fontFlags;
- FontJustify _justify;
- int _fontSaveBack;
- Common::Point _pos;
- int _justifyWidth;
- int _justifyHeight;
- Common::Point _shadow;
- int _foreColor;
- int _backColor;
- int _shadowColor;
-public:
- FontInfo();
- FontInfo(byte picFlags, byte picSelect, byte picPick, byte picOnOff, byte fontFlags,
- FontJustify justify, int fontSaveBack, const Common::Point &pos, int justifyWidth,
- int justifyHeight, const Common::Point &shadow, int foreColor, int backColor,
- int shadowColor);
-};
-
class DrawInfo {
public:
int _penColor;
@@ -106,8 +80,7 @@ public:
int _sImageShift;
Graphics::Surface _screenSurface;
CMapResource *_backColors;
- FontInfo *_fontPtr;
- FontInfo _defaultFontInfo;
+ FontInfoResource *_fontPtr;
DrawInfo *_drawPtr;
DrawInfo _defaultDrawInfo;
bool _drawTextPermFlag;
diff --git a/engines/voyeur/voyeur.cpp b/engines/voyeur/voyeur.cpp
index 9078cc9eda..3dec56fe6c 100644
--- a/engines/voyeur/voyeur.cpp
+++ b/engines/voyeur/voyeur.cpp
@@ -32,7 +32,9 @@ namespace Voyeur {
VoyeurEngine *g_vm;
VoyeurEngine::VoyeurEngine(OSystem *syst, const VoyeurGameDescription *gameDesc) : Engine(syst),
- _gameDescription(gameDesc), _randomSource("Voyeur") {
+ _gameDescription(gameDesc), _randomSource("Voyeur"),
+ _defaultFontInfo(3, 0xff, 0xff, 0, 0, ALIGN_LEFT, 0, Common::Point(), 1, 1,
+ Common::Point(1, 1), 1, 0, 0) {
DebugMan.addDebugChannel(kDebugPath, "Path", "Pathfinding debug level");
_bVoy = NULL;
@@ -99,6 +101,7 @@ void VoyeurEngine::initialiseManagers() {
_filesManager.setVm(this);
_graphicsManager.setVm(this);
_soundManager.setVm(this);
+
}
void VoyeurEngine::ESP_Init() {
@@ -110,7 +113,10 @@ void VoyeurEngine::globalInitBolt() {
_filesManager.openBoltLib("bvoy.blt", _bVoy);
_bVoy->getBoltGroup(0x10000);
_bVoy->getBoltGroup(0x10100);
- _fontPtr = _bVoy->memberAddr(0x101);
+
+ _graphicsManager._fontPtr = &_defaultFontInfo;
+ _graphicsManager._fontPtr->_curFont = _bVoy->boltEntry(0x101)._fontResource;
+ assert(_graphicsManager._fontPtr->_curFont);
// Setup default flags
Common::fill((byte *)&_voy, (byte *)&_voy + sizeof(SVoy), 0);
@@ -156,7 +162,7 @@ void VoyeurEngine::doHeadTitle() {
}
void VoyeurEngine::showConversionScreen() {
- _graphicsManager._backgroundPage = _bVoy->getBoltEntry(0x5020000)._picResource;
+ _graphicsManager._backgroundPage = _bVoy->boltEntry(0x502)._picResource;
(*_graphicsManager._vPort)->setupViewPort();
(*_graphicsManager._vPort)->_flags |= 8;
@@ -164,7 +170,7 @@ void VoyeurEngine::showConversionScreen() {
_eventsManager.sWaitFlip();
// Immediate palette load to show the initial screen
- CMapResource *cMap = _bVoy->getCMapResource(0x5030000);
+ CMapResource *cMap = _bVoy->getCMapResource(0x503);
assert(cMap);
cMap->_steps = 0;
cMap->startFade();
@@ -238,10 +244,10 @@ bool VoyeurEngine::doLock() {
_graphicsManager.setColor(3, 0x0A, 0xA0, 0x0A);
_graphicsManager.setColor(4, 0x0E, 0xE0, 0x0E);
- _eventsManager._intPtr.field38 = 1;
+ _eventsManager._intPtr. field38 = 1;
_eventsManager._intPtr._hasPalette = true;
- _graphicsManager._fontPtr->_curFont = _bVoy->getBoltEntry(0x708)._fontResource;
+ _graphicsManager._fontPtr->_curFont = _bVoy->boltEntry(0x708)._fontResource;
_graphicsManager._fontPtr->_fontSaveBack = 0;
_graphicsManager._fontPtr->_fontFlags = 0;
diff --git a/engines/voyeur/voyeur.h b/engines/voyeur/voyeur.h
index 723875512c..7a156b8f3f 100644
--- a/engines/voyeur/voyeur.h
+++ b/engines/voyeur/voyeur.h
@@ -66,9 +66,9 @@ private:
Common::RandomSource _randomSource;
BoltFile *_bVoy;
- byte *_fontPtr;
SVoy _voy;
Common::Array<int> _resolves;
+ FontInfoResource _defaultFontInfo;
void ESP_Init();
void initialiseManagers();