diff options
author | johndoe123 | 2014-03-15 17:54:59 +0100 |
---|---|---|
committer | Eugene Sandulenko | 2018-07-20 06:43:33 +0000 |
commit | 9a63f0bd17b5c8fab468a61c09cdc29cedf287a5 (patch) | |
tree | 3e3419869311210a8d43af82af2acf5a8074bab1 /engines | |
parent | ad440a17232f88cf3623434bab75135dfcb21ac1 (diff) | |
download | scummvm-rg350-9a63f0bd17b5c8fab468a61c09cdc29cedf287a5.tar.gz scummvm-rg350-9a63f0bd17b5c8fab468a61c09cdc29cedf287a5.tar.bz2 scummvm-rg350-9a63f0bd17b5c8fab468a61c09cdc29cedf287a5.zip |
ILLUSIONS: Add background scale and priority classes
Diffstat (limited to 'engines')
-rw-r--r-- | engines/illusions/backgroundresource.cpp | 57 | ||||
-rw-r--r-- | engines/illusions/backgroundresource.h | 37 | ||||
-rw-r--r-- | engines/illusions/illusions.cpp | 18 |
3 files changed, 99 insertions, 13 deletions
diff --git a/engines/illusions/backgroundresource.cpp b/engines/illusions/backgroundresource.cpp index 3ac2a58bda..89f91655f0 100644 --- a/engines/illusions/backgroundresource.cpp +++ b/engines/illusions/backgroundresource.cpp @@ -95,6 +95,47 @@ void BgInfo::load(byte *dataStart, Common::SeekableReadStream &stream) { _flags, _priorityBase, tileMapOffs, tilePixelsOffs); } +// PriorityLayer + +void PriorityLayer::load(byte *dataStart, Common::SeekableReadStream &stream) { + _width = stream.readUint16LE(); + _height = stream.readUint16LE(); + uint32 mapOffs = stream.readUint32LE(); + uint32 valuesOffs = stream.readUint32LE(); + _map = dataStart + mapOffs; + _mapWidth = READ_LE_UINT16(_map + 0); + _mapHeight = READ_LE_UINT16(_map + 2); + _map += 8; + _values = dataStart + valuesOffs; + + debug("PriorityLayer::load() _width: %d; _height: %d; mapOffs: %08X; valuesOffs: %08X; _mapWidth: %d; _mapHeight: %d", + _width, _height, mapOffs, valuesOffs, _mapWidth, _mapHeight); +} + +int PriorityLayer::getPriority(Common::Point pos) { + pos.x = CLIP<int16>(pos.x, 0, _width - 1); + pos.y = CLIP<int16>(pos.y, 0, _height - 1); + const int16 tx = pos.x / 32, sx = pos.x % 32; + const int16 ty = pos.y / 8, sy = pos.y % 8; + uint16 mapIndex = READ_LE_UINT16(_map + 2 * (tx + ty * _mapWidth)) - 1; + return _values[mapIndex * 32 * 8 + sx + sy * 32]; +} + +void ScaleLayer::load(byte *dataStart, Common::SeekableReadStream &stream) { + _height = stream.readUint16LE(); + stream.skip(2); + uint32 valuesOffs = stream.readUint32LE(); + _values = dataStart + valuesOffs; + + debug("ScaleLayer::load() _height: %d; valuesOffs: %08X", + _height, valuesOffs); +} + +int ScaleLayer::getScale(Common::Point pos) { + pos.y = CLIP<int16>(pos.y, 0, _height - 1); + return _values[pos.y]; +} + // BackgroundResource BackgroundResource::BackgroundResource() { @@ -119,6 +160,18 @@ void BackgroundResource::load(byte *data, uint32 dataSize) { _bgInfos[i].load(data, stream); } + // Load scale layers + stream.seek(0x10); + _scaleLayersCount = stream.readUint16LE(); + _scaleLayers = new ScaleLayer[_scaleLayersCount]; + stream.seek(0x2C); + uint32 scaleLayersOffs = stream.readUint32LE(); + debug("_scaleLayersCount: %d", _scaleLayersCount); + for (uint i = 0; i < _scaleLayersCount; ++i) { + stream.seek(scaleLayersOffs + i * 8); + _scaleLayers[i].load(data, stream); + } + } int BackgroundResource::findMasterBgIndex() { @@ -183,7 +236,7 @@ void BackgroundItem::pause() { // TODO ++_pauseCtr; if (_pauseCtr <= 1) { - /* TODO + /* TODO for (uint i = 0; i < _bgRes->_item48sCount; ++i) krndictRemoveID(_bgRes->_item48s[i].id); */ @@ -201,7 +254,7 @@ void BackgroundItem::unpause() { // TODO --_pauseCtr; if (_pauseCtr <= 0) { - /* TODO + /* TODO for (uint i = 0; i < _bgRes->_item48sCount; ++i) krndictAddID(_bgRes->_item48s[i].id, _bgRes->_item48s[i]); */ diff --git a/engines/illusions/backgroundresource.h b/engines/illusions/backgroundresource.h index a12804bddb..fd802539c2 100644 --- a/engines/illusions/backgroundresource.h +++ b/engines/illusions/backgroundresource.h @@ -69,6 +69,37 @@ struct BgInfo { void load(byte *dataStart, Common::SeekableReadStream &stream); }; +class PriorityLayer { +public: + void load(byte *dataStart, Common::SeekableReadStream &stream); + int getPriority(Common::Point pos); +protected: + int16 _width, _height; + int16 _mapWidth, _mapHeight; + byte *_map, *_values; +}; + +class ScaleLayer { +public: + void load(byte *dataStart, Common::SeekableReadStream &stream); + int getScale(Common::Point pos); +protected: + int16 _height; + byte *_values; +}; + +#if 0 +BgResource_PathWalkRects struc ; (sizeof=0x8) +count dd ? +rects dd ? +BgResource_PathWalkRects ends + +BgResource_PathWalkPoints struc ; (sizeof=0x8) +count dd ? +points dd ? +BgResource_PathWalkPoints ends +#endif + class BackgroundResource { public: BackgroundResource(); @@ -79,6 +110,12 @@ public: uint _bgInfosCount; BgInfo *_bgInfos; + + uint _priorityLayersCount; + PriorityLayer *_priorityLayers; + + uint _scaleLayersCount; + ScaleLayer *_scaleLayers; }; diff --git a/engines/illusions/illusions.cpp b/engines/illusions/illusions.cpp index f0bbc0951f..2b44141537 100644 --- a/engines/illusions/illusions.cpp +++ b/engines/illusions/illusions.cpp @@ -97,16 +97,18 @@ Common::Error IllusionsEngine::run() { _resSys->loadResource(0x00100006, 0, 0); #endif -#if 0 +#if 1 // BackgroundResource test - _resSys->loadResource(0x0011000B, 0, 0); + _resSys->loadResource(0x0011001C, 0, 0); BackgroundItem *backgroundItem = _backgroundItems->debugFirst(); - _system->copyRectToScreen(backgroundItem->_surfaces[0]->getPixels(), backgroundItem->_surfaces[0]->pitch, - 0, 0, 640, 480); + _system->copyRectToScreen((byte*)backgroundItem->_surfaces[0]->getBasePtr(0, 0), backgroundItem->_surfaces[0]->pitch, 0, 0, 640, 480); _system->updateScreen(); + while (!shouldQuit()) { + updateEvents(); + } #endif -#if 1 +#if 0 // ScriptResource test _resSys->loadResource(0x000D0001, 0, 0); @@ -120,12 +122,6 @@ Common::Error IllusionsEngine::run() { #endif -#if 0 - while (!shouldQuit()) { - updateEvents(); - } -#endif - delete _camera; delete _backgroundItems; delete _actorItems; |