diff options
author | lukaslw | 2014-05-17 23:25:31 +0200 |
---|---|---|
committer | lukaslw | 2014-06-22 20:08:08 +0200 |
commit | 3d590627eda86a56080bbb55f5b51c19b55cd3a1 (patch) | |
tree | fdce82a04131f38d3de79dff14f0e07a2f1b9567 /engines/prince | |
parent | d5f2b97c3e291832317e950773997e3f206b8975 (diff) | |
download | scummvm-rg350-3d590627eda86a56080bbb55f5b51c19b55cd3a1.tar.gz scummvm-rg350-3d590627eda86a56080bbb55f5b51c19b55cd3a1.tar.bz2 scummvm-rg350-3d590627eda86a56080bbb55f5b51c19b55cd3a1.zip |
PRINCE: Room struct implementation and objects drawing fix
Diffstat (limited to 'engines/prince')
-rw-r--r-- | engines/prince/object.cpp | 11 | ||||
-rw-r--r-- | engines/prince/object.h | 4 | ||||
-rw-r--r-- | engines/prince/prince.cpp | 28 | ||||
-rw-r--r-- | engines/prince/prince.h | 3 | ||||
-rw-r--r-- | engines/prince/script.cpp | 36 | ||||
-rw-r--r-- | engines/prince/script.h | 18 |
6 files changed, 77 insertions, 23 deletions
diff --git a/engines/prince/object.cpp b/engines/prince/object.cpp index 4148cdf854..9386eaa496 100644 --- a/engines/prince/object.cpp +++ b/engines/prince/object.cpp @@ -32,7 +32,7 @@ namespace Prince { -Object::Object() : _surface(NULL), _x(0), _y(0), _z(0) { +Object::Object() : _surface(NULL), _x(0), _y(0), _z(0), _overlay(0) { } Object::~Object() { @@ -45,9 +45,11 @@ Object::~Object() { void Object::loadSurface(Common::SeekableReadStream &stream) { stream.skip(4); - + int width = stream.readUint16LE(); + int height = stream.readUint16LE(); _surface = new Graphics::Surface(); - _surface->create(stream.readUint16LE(), stream.readUint16LE(), Graphics::PixelFormat::createFormatCLUT8()); + _surface->create(width, height, Graphics::PixelFormat::createFormatCLUT8()); + for (int h = 0; h < _surface->h; ++h) { stream.read(_surface->getBasePtr(0, h), _surface->w); } @@ -71,11 +73,12 @@ bool Object::loadFromStream(Common::SeekableReadStream &stream) { loadSurface(*obStream); delete obStream; + _overlay = stream.readUint16LE(); _z = stream.readUint16LE(); stream.seek(pos + 16); - debug("Object x %d, y %d, z %d", _x, _y, _z); + debug("Object x %d, y %d, z %d overlay %d", _x, _y, _z, _overlay); return true; } diff --git a/engines/prince/object.h b/engines/prince/object.h index 7a3d19e906..66f2a725f8 100644 --- a/engines/prince/object.h +++ b/engines/prince/object.h @@ -35,12 +35,10 @@ public: bool loadFromStream(Common::SeekableReadStream &stream); const Graphics::Surface *getSurface() const { return _surface; } - + uint16 _x, _y, _z, _overlay; private: void loadSurface(Common::SeekableReadStream &stream); - Graphics::Surface *_surface; - uint16 _x, _y, _z; }; } diff --git a/engines/prince/prince.cpp b/engines/prince/prince.cpp index 98f9689b9a..ea7b9e8b0c 100644 --- a/engines/prince/prince.cpp +++ b/engines/prince/prince.cpp @@ -76,7 +76,7 @@ void PrinceEngine::debugEngine(const char *s, ...) { PrinceEngine::PrinceEngine(OSystem *syst, const PrinceGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc), _graph(nullptr), _script(nullptr), _interpreter(nullptr), _flags(nullptr), - _locationNr(0), _debugger(nullptr), _midiPlayer(nullptr), + _locationNr(0), _debugger(nullptr), _midiPlayer(nullptr), _room(nullptr), _cameraX(0), _newCameraX(0), _frameNr(0), _cursor1(nullptr), _cursor2(nullptr), _font(nullptr), _suitcaseBmp(nullptr), _roomBmp(nullptr), _cursorNr(0), _picWindowX(0), _picWindowY(0) { @@ -108,6 +108,7 @@ PrinceEngine::~PrinceEngine() { delete _variaTxt; delete[] _talkTxt; delete _graph; + delete _room; for (uint i = 0; i < _objList.size(); i++) { delete _objList[i]; @@ -195,6 +196,8 @@ void PrinceEngine::init() { _roomBmp = new Image::BitmapDecoder(); + _room = new Room(); + _mainHero = new Hero(this, _graph); _secondHero = new Hero(this, _graph); @@ -298,12 +301,6 @@ bool PrinceEngine::loadLocation(uint16 locationNr) { _picWindowX = 0; - _mainHero->_lightX = _script->getLightX(_locationNr); - _mainHero->_lightY = _script->getLightY(_locationNr); - _mainHero->setShadowScale(_script->getShadowScale(_locationNr)); - debug("lightX: %d", _mainHero->_lightX); - debug("lightY: %d", _mainHero->_lightY); - _mobList.clear(); Resource::loadResource(_mobList, "mob.lst", false); @@ -316,6 +313,12 @@ bool PrinceEngine::loadLocation(uint16 locationNr) { _animList.clear(); Resource::loadResource(_animList, "anim.lst", false); + _mainHero->_lightX = _script->getLightX(_locationNr); + _mainHero->_lightY = _script->getLightY(_locationNr); + _mainHero->setShadowScale(_script->getShadowScale(_locationNr)); + + _room->loadRoom(_script->getRoomOffset(_locationNr)); + _graph->makeShadowTable(70, _graph->_shadowTable70); _graph->makeShadowTable(50, _graph->_shadowTable50); @@ -688,10 +691,13 @@ void PrinceEngine::drawScreen() { } playNextFrame(); - - //if (_objectList) - // _graph->drawTransparent(_objectList->getSurface()); - + /* + if (!_objList.empty()) { + for (int i = 0; i < _objList.size(); i++) { + _graph->drawTransparent(_objList[i]->_x, _objList[i]->_y, _objList[i]->getSurface()); + } + } + */ hotspot(); showTexts(); diff --git a/engines/prince/prince.h b/engines/prince/prince.h index dd00abb788..5dd039beec 100644 --- a/engines/prince/prince.h +++ b/engines/prince/prince.h @@ -63,6 +63,7 @@ class MhwanhDecoder; class Font; class Hero; class Animation; +class Room; struct Text { const char *_str; @@ -177,7 +178,7 @@ private: Interpreter *_interpreter; Font *_font; MusicPlayer *_midiPlayer; - + Room *_room; static const uint32 MAX_SAMPLES = 60; Common::SeekableReadStream *_voiceStream[MAX_SAMPLES]; diff --git a/engines/prince/script.cpp b/engines/prince/script.cpp index 78704eb6f8..a0c015d48b 100644 --- a/engines/prince/script.cpp +++ b/engines/prince/script.cpp @@ -40,6 +40,29 @@ static const uint16 NUM_OPCODES = 144; Room::Room() {} +bool Room::loadRoom(byte *roomData) { + int roomSize = 64; + Common::MemoryReadStream roomStream(roomData, roomSize); + + _mobs = roomStream.readSint32LE(); + _backAnim = roomStream.readSint32LE(); + _obj = roomStream.readSint32LE(); + _nak = roomStream.readSint32LE(); + _itemUse = roomStream.readSint32LE(); + _itemGive = roomStream.readSint32LE(); + _walkTo = roomStream.readSint32LE(); + _examine = roomStream.readSint32LE(); + _pickup = roomStream.readSint32LE(); + _use = roomStream.readSint32LE(); + _pushOpen = roomStream.readSint32LE(); + _pullClose = roomStream.readSint32LE(); + _talk = roomStream.readSint32LE(); + _give = roomStream.readSint32LE(); + + return true; +} + +/* void Room::loadMobs(Common::SeekableReadStream &stream) { debug("loadMobs %d", stream.pos()); static const uint8 MAX_MOBS = 64; @@ -73,7 +96,8 @@ void Room::loadPushOpen(Common::SeekableReadStream &stream) {} void Room::loadPullClose(Common::SeekableReadStream &stream) {} void Room::loadTalk(Common::SeekableReadStream &stream) {} void Room::loadGive(Common::SeekableReadStream &stream) {} - +*/ +/* void Room::nextLoadStep(Common::SeekableReadStream &stream, LoadingStep step) { uint32 offset = stream.readUint32LE(); uint32 pos = stream.pos(); @@ -85,7 +109,8 @@ void Room::nextLoadStep(Common::SeekableReadStream &stream, LoadingStep step) { stream.seek(pos); } - +*/ +/* bool Room::loadFromStream(Common::SeekableReadStream &stream) { uint32 pos = stream.pos(); @@ -109,8 +134,9 @@ bool Room::loadFromStream(Common::SeekableReadStream &stream) { static const uint8 ROOM_ENTRY_SIZE = 64; stream.seek(pos + ROOM_ENTRY_SIZE); - return true;; + return true; } +*/ Script::Script() : _data(nullptr), _dataSize(0) { } @@ -174,6 +200,10 @@ uint32 Script::getStartGameOffset() { return _scriptInfo.startGame; } +uint8 *Script::getRoomOffset(int locationNr) { + return &_data[_scriptInfo.rooms + locationNr * 64]; // Room_Len (64?) +} + InterpreterFlags::InterpreterFlags() { resetAllFlags(); } diff --git a/engines/prince/script.h b/engines/prince/script.h index f21df1d717..5a1e49ab23 100644 --- a/engines/prince/script.h +++ b/engines/prince/script.h @@ -47,8 +47,24 @@ namespace Detail { class Room { public: Room(); + int _mobs; // mob flag offset + int _backAnim; // offset to array of animation numbers + int _obj; // offset to array of object numbers + int _nak; // offset to array of overlays + int _itemUse; + int _itemGive; + int _walkTo; // offset to array of WALKTO events or 0 + int _examine; // offset to array of EXAMINE events or 0 + int _pickup; + int _use; + int _pushOpen; + int _pullClose; + int _talk; + int _give; + //Room_Pad db 64-(Room_Pad-Room_Mobs) dup (0) ??? bool loadFromStream(Common::SeekableReadStream &stream); + bool loadRoom(byte *roomData); private: @@ -109,11 +125,11 @@ public: return Detail::LittleEndianReader<T>(&_data[address]); } - //uint32 getRoomTableOffset(); uint32 getStartGameOffset(); int16 getLightX(int locationNr); int16 getLightY(int locationNr); int32 getShadowScale(int locationNr); + uint8 *getRoomOffset(int locationNr); const char *getString(uint32 offset) { return (const char *)(&_data[offset]); |