aboutsummaryrefslogtreecommitdiff
path: root/engines/mads/scene_data.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/mads/scene_data.cpp')
-rw-r--r--engines/mads/scene_data.cpp173
1 files changed, 173 insertions, 0 deletions
diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp
index d0e40d4097..aac70750b8 100644
--- a/engines/mads/scene_data.cpp
+++ b/engines/mads/scene_data.cpp
@@ -23,6 +23,7 @@
#include "common/scummsys.h"
#include "mads/scene_data.h"
#include "mads/mads.h"
+#include "mads/resources.h"
#include "mads/nebular/nebular_scenes.h"
namespace MADS {
@@ -161,4 +162,176 @@ Hotspot::Hotspot(Common::SeekableReadStream &f) {
_verbId = f.readUint16LE();
}
+/*------------------------------------------------------------------------*/
+
+void ARTHeader::load(Common::SeekableReadStream &f) {
+ _width = f.readUint16LE();
+ _height = f.readUint16LE();
+
+ _palCount = f.readUint16LE();
+ for (int i = 0; i < 256; ++i) {
+ RGB6 rgb;
+ rgb.r = f.readByte();
+ rgb.g = f.readByte();
+ rgb.b = f.readByte();
+ f.read(&rgb.unused[0], 3);
+
+ _palette.push_back(rgb);
+ }
+
+ int palCount = f.readUint16LE();
+ for (int i = 0; i < palCount; ++i) {
+ RGB4 rgb;
+ rgb.r = f.readByte();
+ rgb.g = f.readByte();
+ rgb.b = f.readByte();
+ rgb.u = f.readByte();
+
+ _palData.push_back(rgb);
+ }
+}
+
+/*------------------------------------------------------------------------*/
+
+SceneInfo *SceneInfo::load(MADSEngine *vm, int sceneId, int v1, const Common::String &resName,
+ int v3, MSurface &depthSurface, MSurface &bgSurface) {
+ return new SceneInfo(vm, sceneId, v1, resName, v3, depthSurface, bgSurface);
+}
+
+SceneInfo::SceneInfo(MADSEngine *vm, int sceneId, int v1, const Common::String &resName,
+ int flags, MSurface &depthSurface, MSurface &bgSurface) {
+ bool flag = true;
+ bool sceneFlag = sceneId >= 0;
+ bool ssFlag = false, wsFlag = false;
+ int handle = 0;
+
+ SpriteAsset *spriteSets[10];
+ int xpList[10];
+ Common::fill(&spriteSets[0], &spriteSets[10], (SpriteAsset *)nullptr);
+ Common::fill(&xpList[0], &xpList[10], -1);
+
+ // Figure out the resource to use
+ Common::String resourceName;
+ if (sceneFlag) {
+ resourceName = Resources::formatName(RESPREFIX_RM, sceneId, ".DAT");
+ } else {
+ resourceName = "*" + Resources::formatResource(resName, resName);
+ }
+
+ // Open the scene info resource for access
+ File infoFile(resName);
+
+ // Read in basic data
+ _sceneId = infoFile.readUint16LE();
+ _artFileNum = infoFile.readUint16LE();
+ _depthStyle = infoFile.readUint16LE();
+ _width = infoFile.readUint16LE();
+ _height = infoFile.readUint16LE();
+ infoFile.skip(24);
+ _nodeCount = infoFile.readUint16LE();
+ _yBandsEnd = infoFile.readUint16LE();
+ _yBandsStart = infoFile.readUint16LE();
+ _maxScale = infoFile.readUint16LE();
+ _minScale = infoFile.readUint16LE();
+ for (int i = 0; i < 15; ++i)
+ _depthList[i] = infoFile.readUint16LE();
+ _field4A = infoFile.readUint16LE();
+
+ // Load the set of objects that are associated with the scene
+ for (int i = 0; i < 20; ++i) {
+ InventoryObject obj;
+ obj.load(infoFile);
+ _objects.push_back(obj);
+ }
+
+ int setCount = infoFile.readUint16LE();
+ int field40E = infoFile.readUint16LE();
+
+ for (int i = 0; i < 20; ++i) {
+ char name[64];
+ infoFile.read(name, 64);
+ _setNames.push_back(Common::String(name));
+ }
+
+ infoFile.close();
+ int width = _width;
+ int height = _height;
+
+ if (!bgSurface.getPixels()) {
+ bgSurface.setSize(width, height);
+ ssFlag = true;
+ }
+
+ if (_depthStyle == 2)
+ width >>= 2;
+ if (!depthSurface.getPixels()) {
+ depthSurface.setSize(width, height);
+ wsFlag = true;
+ }
+
+ // Load the depth surface with the scene codes
+ loadCodes(depthSurface);
+
+ // Get the ART resource
+ if (sceneFlag) {
+ resourceName = Resources::formatName(RESPREFIX_RM, sceneId, ".ART");
+ } else {
+ resourceName = "*" + Resources::formatResource(resName, resName);
+ }
+
+ // Load in the ART header and palette
+ File artFile(resourceName);
+ ARTHeader artHeader;
+ artHeader.load(artFile);
+ artFile.close();
+
+ // Copy out the palette data
+ for (int i = 0; i < artHeader._palData.size(); ++i)
+ _palette.push_back(artHeader._palData[i]);
+/*
+ if (!(flags & 1)) {
+ if (_vm->_game->_scene->_scenePalette) {
+ //_vm->_game->_scene->_scenePalette->clean(&artHeader._palCount);
+ //_vm->_game->_scene->_scenePalette->process(&artHeader._palCount)
+ }
+ }
+ */
+ warning("TODO");
+}
+
+void SceneInfo::loadCodes(MSurface &depthSurface) {
+ File f(Resources::formatName(RESPREFIX_RM, _sceneId, ".DAT"));
+
+ uint16 width = _width;
+ uint16 height = _height;
+ byte *walkMap = new byte[f.size()];
+
+ depthSurface.setSize(width, height);
+ f.read(walkMap, f.size());
+
+ byte *ptr = (byte *)depthSurface.getPixels();
+
+ for (int y = 0; y < height; y++) {
+ for (int x = 0; x < width; x++) {
+ int ofs = x + (y * width);
+ if ((walkMap[ofs / 8] << (ofs % 8)) & 0x80)
+ *ptr++ = 1; // walkable
+ else
+ *ptr++ = 0;
+ }
+ }
+
+ delete[] walkMap;
+}
+
+/*------------------------------------------------------------------------*/
+
+void ScenePalette::clean(int *palCount) {
+ warning("TODO: ScenePalette::clean");
+}
+
+void ScenePalette::process(int *palCount) {
+ warning("TODO: ScenePalette::process");
+}
+
} // End of namespace MADS