aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWinterGrascph2016-05-07 21:59:59 +0200
committerBendegúz Nagy2016-08-26 23:02:22 +0200
commit68f13e8462bfb6ca85b45273696173acdf112910 (patch)
treea82b1b3a943bef656cae24f576e18c3c82d76f33
parent4f9182507afb365638b33341fb797d82c3a50df0 (diff)
downloadscummvm-rg350-68f13e8462bfb6ca85b45273696173acdf112910.tar.gz
scummvm-rg350-68f13e8462bfb6ca85b45273696173acdf112910.tar.bz2
scummvm-rg350-68f13e8462bfb6ca85b45273696173acdf112910.zip
DM: Implement F0173_DUNGEON_SetCurrentMap
-rw-r--r--engines/dm/dm.cpp2
-rw-r--r--engines/dm/dungeonman.cpp63
-rw-r--r--engines/dm/dungeonman.h39
3 files changed, 67 insertions, 37 deletions
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 8f6f294551..a27506d5f4 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -59,6 +59,8 @@ Common::Error DMEngine::run() {
_displayMan->loadPalette(kPalCredits);
+ _dungeonMan->setCurrentMap(0);
+
uint16 i = 0; //TODO: testing, please delete me
while (true) {
_displayMan->clearScreen(kColorBlack);
diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index e33895db5a..07c52a78dc 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -30,11 +30,11 @@ DungeonMan::DungeonMan(DMEngine *dmEngine) : _vm(dmEngine), _rawDunFileData(NULL
DungeonMan::~DungeonMan() {
delete[] _rawDunFileData;
delete[] _maps;
- delete[] _dunData.dunMapsFirstColumnIndex;
- delete[] _dunData.dunColumnsCumulativeSquareThingCount;
+ delete[] _dunData.mapsFirstColumnIndex;
+ delete[] _dunData.columnsCumulativeSquareThingCount;
delete[] _dunData.squareFirstThings;
- delete[] _dunData.dunTextData;
- delete[] _dunData.dungeonMapData;
+ delete[] _dunData.textData;
+ delete[] _dunData.mapData;
}
void DungeonMan::decompressDungeonFile() {
@@ -159,10 +159,10 @@ void DungeonMan::loadDungeonFile() {
// init party position and mapindex
if (_messages.newGame) {
- _dunData.partyDir = _fileHeader.partyStartDir;
- _dunData.partyPosX = _fileHeader.partyStartPosX;
- _dunData.partyPosY = _fileHeader.partyStartPosY;
- _dunData.currMapIndex = 0;
+ _currMap.partyDir = _fileHeader.partyStartDir;
+ _currMap.partyPosX = _fileHeader.partyStartPosX;
+ _currMap.partyPosY = _fileHeader.partyStartPosY;
+ _currMap.currPartyMapIndex = 0;
}
// load map data
@@ -199,26 +199,26 @@ void DungeonMan::loadDungeonFile() {
}
// TODO: ??? is this - begin
- if (_dunData.dunMapsFirstColumnIndex) delete[] _dunData.dunMapsFirstColumnIndex;
+ if (_dunData.mapsFirstColumnIndex) delete[] _dunData.mapsFirstColumnIndex;
- _dunData.dunMapsFirstColumnIndex = new uint16[_fileHeader.mapCount];
+ _dunData.mapsFirstColumnIndex = new uint16[_fileHeader.mapCount];
uint16 columCount = 0;
for (uint16 i = 0; i < _fileHeader.mapCount; ++i) {
- _dunData.dunMapsFirstColumnIndex[i] = columCount;
+ _dunData.mapsFirstColumnIndex[i] = columCount;
columCount += _maps[i].width + 1;
}
- _dunData.dunColumCount = columCount;
+ _dunData.columCount = columCount;
// TODO: ??? is this - end
if (_messages.newGame) // TODO: what purpose does this serve?
_fileHeader.squareFirstThingCount += 300;
// TODO: ??? is this - begin
- if (_dunData.dunColumnsCumulativeSquareThingCount)
- delete[] _dunData.dunColumnsCumulativeSquareThingCount;
- _dunData.dunColumnsCumulativeSquareThingCount = new uint16[columCount];
+ if (_dunData.columnsCumulativeSquareThingCount)
+ delete[] _dunData.columnsCumulativeSquareThingCount;
+ _dunData.columnsCumulativeSquareThingCount = new uint16[columCount];
for (uint16 i = 0; i < columCount; ++i)
- _dunData.dunColumnsCumulativeSquareThingCount[i] = dunDataStream.readUint16BE();
+ _dunData.columnsCumulativeSquareThingCount[i] = dunDataStream.readUint16BE();
// TODO: ??? is this - end
// TODO: ??? is this - begin
@@ -238,11 +238,11 @@ void DungeonMan::loadDungeonFile() {
// TODO: ??? is this - end
// load text data
- if (_dunData.dunTextData)
- delete[] _dunData.dunTextData;
- _dunData.dunTextData = new uint16[_fileHeader.textDataWordCount];
+ if (_dunData.textData)
+ delete[] _dunData.textData;
+ _dunData.textData = new uint16[_fileHeader.textDataWordCount];
for (uint16 i = 0; i < _fileHeader.textDataWordCount; ++i)
- _dunData.dunTextData[i] = dunDataStream.readUint16BE();
+ _dunData.textData[i] = dunDataStream.readUint16BE();
// TODO: ??? what this
if (_messages.newGame)
@@ -256,14 +256,14 @@ void DungeonMan::loadDungeonFile() {
_rawMapData = _rawDunFileData + dunDataStream.pos();
- if (_dunData.dungeonMapData) delete[] _dunData.dungeonMapData;
+ if (_dunData.mapData) delete[] _dunData.mapData;
- if (_messages.restartGameRequest) {
+ if (!_messages.restartGameRequest) {
uint8 mapCount = _fileHeader.mapCount;
- _dunData.dungeonMapData = new byte**[_dunData.dunColumCount + mapCount];
- byte **colFirstSquares = _dunData.dungeonMapData[mapCount];
+ _dunData.mapData = new byte**[_dunData.columCount + mapCount];
+ byte **colFirstSquares = (byte**)_dunData.mapData + mapCount;
for (uint8 i = 0; i < mapCount; ++i) {
- _dunData.dungeonMapData[i] = colFirstSquares;
+ _dunData.mapData[i] = colFirstSquares;
byte *square = _rawMapData + _maps[i].rawDunDataOffset;
*colFirstSquares++ = square;
for (uint16 w = 0; w <= _maps[i].width; ++w) {
@@ -272,4 +272,17 @@ void DungeonMan::loadDungeonFile() {
}
}
}
+}
+
+void DungeonMan::setCurrentMap(uint16 mapIndex) {
+ if (_currMap.index == mapIndex)
+ return;
+
+ _currMap.index = mapIndex;
+ _currMap.data = _dunData.mapData[mapIndex];
+ _currMap.map = _maps + mapIndex;
+ _currMap.width = _maps[mapIndex].width + 1;
+ _currMap.height = _maps[mapIndex].height + 1;
+ _currMap.colCumulativeSquareFirstThingCount
+ = &_dunData.columnsCumulativeSquareThingCount[_dunData.mapsFirstColumnIndex[mapIndex]];
} \ No newline at end of file
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index b26d56fc4c..213a76dad6 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -6,6 +6,7 @@
namespace DM {
class DungeonMan;
+class Map;
enum ThingType {
kPartyThingType = -1, // @ CM1_THING_TYPE_PARTY, special value
@@ -57,27 +58,39 @@ class Thing {
class DungeonData {
friend class DungeonMan;
- direction partyDir; // @ G0308_i_PartyDirection
- uint16 partyPosX; // @ G0306_i_PartyMapX
- uint16 partyPosY; // @ G0307_i_PartyMapY
- uint8 currMapIndex; // @ G0309_i_PartyMapIndex
-
// I have no idea the heck is this
- uint16 *dunMapsFirstColumnIndex = NULL; // @ G0281_pui_DungeonMapsFirstColumnIndex
- uint16 dunColumCount; // @ G0282_ui_DungeonColumnCount
+ uint16 *mapsFirstColumnIndex = NULL; // @ G0281_pui_DungeonMapsFirstColumnIndex
+ uint16 columCount; // @ G0282_ui_DungeonColumnCount
// I have no idea the heck is this
- uint16 *dunColumnsCumulativeSquareThingCount = NULL; // @ G0280_pui_DungeonColumnsCumulativeSquareThingCount
+ uint16 *columnsCumulativeSquareThingCount = NULL; // @ G0280_pui_DungeonColumnsCumulativeSquareThingCount
Thing *squareFirstThings = NULL; // @ G0283_pT_SquareFirstThings
- uint16 *dunTextData = NULL; // @ G0260_pui_DungeonTextData
+ uint16 *textData = NULL; // @ G0260_pui_DungeonTextData
byte *rawThingData[16] = {NULL}; // @ G0284_apuc_ThingData
- byte ***dungeonMapData = NULL; // @ G0279_pppuc_DungeonMapData
+ byte ***mapData = NULL; // @ G0279_pppuc_DungeonMapData
+ // TODO: ??? is this doing here
uint16 eventMaximumCount; // @ G0369_ui_EventMaximumCount
}; // @ AGGREGATE
+class CurrMapData {
+ friend class DungeonMan;
+
+ direction partyDir; // @ G0308_i_PartyDirection
+ uint16 partyPosX; // @ G0306_i_PartyMapX
+ uint16 partyPosY; // @ G0307_i_PartyMapY
+ uint8 currPartyMapIndex; // @ G0309_i_PartyMapIndex
+
+ uint8 index; // @ G0272_i_CurrentMapIndex
+ byte **data; // @ G0271_ppuc_CurrentMapData
+ Map *map; // @ G0269_ps_CurrentMap
+ uint16 width; // @ G0273_i_CurrentMapWidth
+ uint16 height; // @ G0274_i_CurrentMapHeight
+ uint16 *colCumulativeSquareFirstThingCount; // @G0270_pui_CurrentMapColumnsCumulativeSquareFirstThingCount
+}; // @ AGGREGATE
+
struct Messages {
friend class DungeonMan;
@@ -93,7 +106,7 @@ class Map {
uint8 offsetMapX, offsetMapY;
uint8 level; // only used in DMII
- uint8 width, height; // THESRE ARE INCLUSIVE BOUNDARIES
+ uint8 width, height; // !!! THESRE ARE INCLUSIVE BOUNDARIES
// orn short for Ornament
uint8 wallOrnCount; /* May be used in a Sensor on a Wall or closed Fake Wall square */
uint8 randWallOrnCount; /* Used only on some Wall squares and some closed Fake Wall squares */
@@ -113,11 +126,12 @@ class Map {
class DungeonMan {
DMEngine *_vm;
- uint32 _rawDunFileDataSize;
+ uint32 _rawDunFileDataSize; // @ probably NONE
byte *_rawDunFileData; // @ ???
DungeonFileHeader _fileHeader; // @ G0278_ps_DungeonHeader
DungeonData _dunData; // @ NONE
+ CurrMapData _currMap; // @ NONE
Map *_maps; // @ G0277_ps_DungeonMaps
// does not have to be freed
byte *_rawMapData; // @ G0276_puc_DungeonRawMapData
@@ -134,6 +148,7 @@ public:
~DungeonMan();
// TODO: this does stuff other than load the file!
void loadDungeonFile(); // @ F0434_STARTEND_IsLoadDungeonSuccessful_CPSC
+ void setCurrentMap(uint16 mapIndex); // @ F0173_DUNGEON_SetCurrentMap
};
}