aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNipun Garg2019-06-07 17:19:23 +0530
committerEugene Sandulenko2019-09-03 17:16:44 +0200
commit90bba2df0417111af8a9f812dc4637215a76a4e1 (patch)
treefdf94bab61176d6169f7b8ed500ed03cec6beb5d
parent846d799b19c41963ec2ad9c3324392e57a5f23c0 (diff)
downloadscummvm-rg350-90bba2df0417111af8a9f812dc4637215a76a4e1.tar.gz
scummvm-rg350-90bba2df0417111af8a9f812dc4637215a76a4e1.tar.bz2
scummvm-rg350-90bba2df0417111af8a9f812dc4637215a76a4e1.zip
HDB: Shift loadMap from MapLoader to Map
-rw-r--r--engines/hdb/map-loader.cpp98
-rw-r--r--engines/hdb/map-loader.h46
2 files changed, 120 insertions, 24 deletions
diff --git a/engines/hdb/map-loader.cpp b/engines/hdb/map-loader.cpp
index ba0917cb7d..316d1830c9 100644
--- a/engines/hdb/map-loader.cpp
+++ b/engines/hdb/map-loader.cpp
@@ -24,6 +24,65 @@
namespace HDB {
+Map::Map() {
+ _mapLoaded = false;
+}
+
+bool Map::load(Common::SeekableReadStream *stream) {
+ if (_mapLoaded) {
+ return false;
+ }
+
+ // Load MSM data header
+ stream->read(_name, 32);
+ _width = stream->readUint16LE();
+ _height = stream->readUint16LE();
+ _backgroundOffset = stream->readUint32LE();
+ _foregroundOffset = stream->readUint32LE();
+ _iconNum = stream->readUint16LE();
+ _iconListOffset = stream->readUint32LE();
+ _infoNum = stream->readUint16LE();
+ _infoListOffset = stream->readUint32LE();
+
+ // Reading Background
+ _background = new uint16[_width * _height];
+ stream->seek(_backgroundOffset);
+ for (int i = 0; i < _width * _height; i++) {
+ _background[i] = stream->readUint16LE();
+ }
+
+ // Reading Foreground
+ _foreground = new uint16[_width * _height];
+ stream->seek(_foregroundOffset);
+ for (int i = 0; i < _width * _height; i++) {
+ _foreground[i] = stream->readUint16LE();
+ }
+
+ // Reading Icon List
+ _iconList = new MSMIcon[_iconNum];
+ for (int i = 0; i < _iconNum; i++) {
+ _iconList[i].icon = stream->readUint16LE();
+ _iconList[i].x = stream->readUint16LE();
+ _iconList[i].y = stream->readUint16LE();
+
+ stream->read(_iconList[i].funcInit, 32);
+ stream->read(_iconList[i].funcAction, 32);
+ stream->read(_iconList[i].funcUse, 32);
+
+ _iconList[i].dir = stream->readUint16LE();
+ _iconList[i].level = stream->readUint16LE();
+ _iconList[i].value1 = stream->readUint16LE();
+ _iconList[i].value2 = stream->readUint16LE();
+ }
+
+ /*
+ TODO: Add the InfoList when it comes up
+ */
+
+ return true;
+}
+
+#if 0
MapLoader::MapLoader() {
_mapLoaded = false;
}
@@ -34,22 +93,37 @@ bool MapLoader::loadMap(Common::SeekableReadStream *stream, int32 length) {
return false;
}
- // Load MSM data into mapHeader
- mapHeader = new MSMHeader;
- stream->read(mapHeader->name, 32);
- mapHeader->width = stream->readUint16LE();
- mapHeader->height = stream->readUint16LE();
- mapHeader->background = stream->readUint32LE();
- mapHeader->foreground = stream->readUint32LE();
- mapHeader->iconNum = stream->readUint16LE();
- mapHeader->iconList = stream->readUint32LE();
- mapHeader->infoNum = stream->readUint16LE();
- mapHeader->infoList = stream->readUint32LE();
+ // Load MSM data into _mapHeader
+ _mapHeader = new MSMHeader;
+ stream->read(_mapHeader->name, 32);
+ _mapHeader->width = stream->readUint16LE();
+ _mapHeader->height = stream->readUint16LE();
+ _mapHeader->background = stream->readUint32LE();
+ _mapHeader->foreground = stream->readUint32LE();
+ _mapHeader->iconNum = stream->readUint16LE();
+ _mapHeader->iconList = stream->readUint32LE();
+ _mapHeader->infoNum = stream->readUint16LE();
+ _mapHeader->infoList = stream->readUint32LE();
/*
TODO: Set the InMapName in hdb.cpp
*/
+ mapWidth = _mapHeader->width;
+ mapHeight = _mapHeader->height;
+
+ // Create matrices to keep track of Explosions, Barrels and LaserBeams
+ _mapExplosions = new char[mapWidth * mapHeight];
+ _mapExpBarrels = new char[mapWidth * mapHeight];
+ _mapLaserBeams = new char[mapWidth * mapHeight];
+
+ mapX = mapY = 0;
+
+ debug("Background: %d\n", _mapHeader->background);
+ debug("Foreground: %d\n", _mapHeader->foreground);
+ debug("IconList: %d\n", _mapHeader->iconList);
+ debug("InfoList: %d\n", _mapHeader->infoList);
+
warning("STUB: MAPLOADER: LOAD MAP INCOMPLETE");
return false;
}
@@ -58,5 +132,5 @@ int MapLoader::loadTiles() {
warning("STUB: MAPLOADER: LOAD TILES");
return 0;
}
-
+#endif
}
diff --git a/engines/hdb/map-loader.h b/engines/hdb/map-loader.h
index 5f06817ac2..43edefd7fb 100644
--- a/engines/hdb/map-loader.h
+++ b/engines/hdb/map-loader.h
@@ -24,21 +24,10 @@
#define HDB_MAP_LOADER_H
#include "common/system.h"
+#include "common/array.h"
namespace HDB {
-struct MSMHeader {
- char name[32];
- uint16 width;
- uint16 height;
- uint32 background;
- uint32 foreground;
- uint16 iconNum;
- uint32 iconList;
- uint16 infoNum;
- uint32 infoList;
-};
-
struct MSMIcon {
uint16 icon; // index into icon list
uint16 x;
@@ -52,6 +41,39 @@ struct MSMIcon {
uint16 value1, value2;
};
+struct SeeThroughTile {
+ uint16 x;
+ uint16 y;
+ uint16 tile;
+};
+
+class Map {
+public:
+ Map();
+
+ bool load(Common::SeekableReadStream *stream);
+private:
+ char _name[32];
+ uint16 _width;
+ uint16 _height;
+ uint32 _backgroundOffset;
+ uint32 _foregroundOffset;
+ uint16 _iconNum;
+ uint32 _iconListOffset;
+ uint16 _infoNum;
+ uint32 _infoListOffset;
+
+ uint16 *_background;
+ uint16 *_foreground;
+ MSMIcon *_iconList;
+
+ char *_mapExplosions;
+ char *_mapExpBarrels;
+ char *_mapLaserBeams;
+
+ bool _mapLoaded;
+};
+
class MapLoader {
public:
MapLoader();