From 652acfc4ca6e8b63fb7d02103fe5a07c2f4cd312 Mon Sep 17 00:00:00 2001 From: Denis Kasak Date: Thu, 16 Jul 2009 18:31:15 +0000 Subject: * Added WalkingMaps class * Added DraciEngine::walkingMapsArchive * Made Game::loadRoom() read in the current walking map svn-id: r42541 --- engines/draci/draci.cpp | 3 +++ engines/draci/draci.h | 1 + engines/draci/game.cpp | 40 ++++++++++++++++++++++------------------ engines/draci/game.h | 35 ++++++++++++++++++++++++++++++++++- 4 files changed, 60 insertions(+), 19 deletions(-) (limited to 'engines') diff --git a/engines/draci/draci.cpp b/engines/draci/draci.cpp index 2578d8a12e..339962ac52 100644 --- a/engines/draci/draci.cpp +++ b/engines/draci/draci.cpp @@ -51,6 +51,7 @@ const Common::String overlaysPath("OBR_MAS.DFW"); const Common::String roomsPath("MIST.DFW"); const Common::String animationsPath("ANIM.DFW"); const Common::String iconsPath("HRA.DFW"); +const Common::String walkingMapsPath("MAPY.DFW"); DraciEngine::DraciEngine(OSystem *syst, const ADGameDescription *gameDesc) : Engine(syst) { @@ -86,6 +87,7 @@ int DraciEngine::init() { _overlaysArchive = new BArchive(overlaysPath); _animationsArchive = new BArchive(animationsPath); _iconsArchive = new BArchive(iconsPath); + _walkingMapsArchive = new BArchive(walkingMapsPath); // Load the game's fonts _smallFont = new Font(kFontSmall); @@ -182,6 +184,7 @@ DraciEngine::~DraciEngine() { delete _overlaysArchive; delete _animationsArchive; delete _iconsArchive; + delete _walkingMapsArchive; // Remove all of our debug levels here Common::clearAllDebugChannels(); diff --git a/engines/draci/draci.h b/engines/draci/draci.h index b3e3b020a7..630ce0c29a 100644 --- a/engines/draci/draci.h +++ b/engines/draci/draci.h @@ -67,6 +67,7 @@ public: BArchive *_roomsArchive; BArchive *_overlaysArchive; BArchive *_animationsArchive; + BArchive *_walkingMapsArchive; Common::RandomSource _rnd; }; diff --git a/engines/draci/game.cpp b/engines/draci/game.cpp index e7bafa17ee..9e06f44a1e 100644 --- a/engines/draci/game.cpp +++ b/engines/draci/game.cpp @@ -157,7 +157,11 @@ void Game::loadRoom(int roomNum) { roomReader.readUint32LE(); // Pointer to room title, not used _currentRoom._music = roomReader.readByte(); - _currentRoom._map = roomReader.readByte() - 1; + + int mapIdx = roomReader.readByte() - 1; + f = _vm->_walkingMapsArchive->getFile(mapIdx); + _currentRoom._walkingMap.load(f->_data, f->_length); + _currentRoom._palette = roomReader.readByte() - 1; _currentRoom._numMasks = roomReader.readSint16LE(); _currentRoom._init = roomReader.readSint16LE(); @@ -174,23 +178,23 @@ void Game::loadRoom(int roomNum) { _currentRoom._escRoom = roomReader.readByte() - 1; _currentRoom._numGates = roomReader.readByte(); - debugC(4, kDraciLogicDebugLevel, "_music: %d", _currentRoom._music); - debugC(4, kDraciLogicDebugLevel, "_map: %d", _currentRoom._map); - debugC(4, kDraciLogicDebugLevel, "_palette: %d", _currentRoom._palette); - debugC(4, kDraciLogicDebugLevel, "_numMasks: %d", _currentRoom._numMasks); - debugC(4, kDraciLogicDebugLevel, "_init: %d", _currentRoom._init); - debugC(4, kDraciLogicDebugLevel, "_look: %d", _currentRoom._look); - debugC(4, kDraciLogicDebugLevel, "_use: %d", _currentRoom._use); - debugC(4, kDraciLogicDebugLevel, "_canUse: %d", _currentRoom._canUse); - debugC(4, kDraciLogicDebugLevel, "_imInit: %d", _currentRoom._imInit); - debugC(4, kDraciLogicDebugLevel, "_imLook: %d", _currentRoom._imLook); - debugC(4, kDraciLogicDebugLevel, "_imUse: %d", _currentRoom._imUse); - debugC(4, kDraciLogicDebugLevel, "_mouseOn: %d", _currentRoom._mouseOn); - debugC(4, kDraciLogicDebugLevel, "_heroOn: %d", _currentRoom._heroOn); - debugC(4, kDraciLogicDebugLevel, "_pers0: %f", _currentRoom._pers0); - debugC(4, kDraciLogicDebugLevel, "_persStep: %f", _currentRoom._persStep); - debugC(4, kDraciLogicDebugLevel, "_escRoom: %d", _currentRoom._escRoom); - debugC(4, kDraciLogicDebugLevel, "_numGates: %d", _currentRoom._numGates); + debugC(4, kDraciLogicDebugLevel, "Music: %d", _currentRoom._music); + debugC(4, kDraciLogicDebugLevel, "Map: %d", mapIdx); + debugC(4, kDraciLogicDebugLevel, "Palette: %d", _currentRoom._palette); + debugC(4, kDraciLogicDebugLevel, "Overlays: %d", _currentRoom._numMasks); + debugC(4, kDraciLogicDebugLevel, "Init: %d", _currentRoom._init); + debugC(4, kDraciLogicDebugLevel, "Look: %d", _currentRoom._look); + debugC(4, kDraciLogicDebugLevel, "Use: %d", _currentRoom._use); + debugC(4, kDraciLogicDebugLevel, "CanUse: %d", _currentRoom._canUse); + debugC(4, kDraciLogicDebugLevel, "ImInit: %d", _currentRoom._imInit); + debugC(4, kDraciLogicDebugLevel, "ImLook: %d", _currentRoom._imLook); + debugC(4, kDraciLogicDebugLevel, "ImUse: %d", _currentRoom._imUse); + debugC(4, kDraciLogicDebugLevel, "MouseOn: %d", _currentRoom._mouseOn); + debugC(4, kDraciLogicDebugLevel, "HeroOn: %d", _currentRoom._heroOn); + debugC(4, kDraciLogicDebugLevel, "Pers0: %f", _currentRoom._pers0); + debugC(4, kDraciLogicDebugLevel, "PersStep: %f", _currentRoom._persStep); + debugC(4, kDraciLogicDebugLevel, "EscRoom: %d", _currentRoom._escRoom); + debugC(4, kDraciLogicDebugLevel, "Gates: %d", _currentRoom._numGates); // Set cursor state diff --git a/engines/draci/game.h b/engines/draci/game.h index d7d352ab6e..2b17002ef6 100644 --- a/engines/draci/game.h +++ b/engines/draci/game.h @@ -43,6 +43,39 @@ enum StructSizes { personSize = sizeof(uint16) * 2 + sizeof(byte) }; +class WalkingMap { + +public: + WalkingMap() { + _realWidth = 0; + _realHeight = 0; + _mapWidth = 0; + _mapHeight = 0; + _byteWidth = 0; + _data = NULL; + } + + void load(byte *data, uint length) { + Common::MemoryReadStream mapReader(data, length); + + _realWidth = mapReader.readUint16LE(); + _realHeight = mapReader.readUint16LE(); + _mapWidth = mapReader.readUint16LE(); + _mapHeight = mapReader.readUint16LE(); + _byteWidth = mapReader.readUint16LE(); + + // Set the data pointer to raw map data + _data = data + mapReader.pos(); + } + +private: + int _realWidth, _realHeight; + int _deltaX, _deltaY; + int _mapWidth, _mapHeight; + int _byteWidth; + byte *_data; +}; + struct GameObject { GameObject() : _title(NULL) {} @@ -84,7 +117,7 @@ struct Person { struct Room { byte _roomNum; byte _music; - byte _map; + WalkingMap _walkingMap; byte _palette; int _numMasks; int _init, _look, _use, _canUse; -- cgit v1.2.3