diff options
author | lukaslw | 2014-05-01 18:50:20 +0200 |
---|---|---|
committer | lukaslw | 2014-06-22 20:07:54 +0200 |
commit | acf9ac241eb1d23d435643f0d0ff2c04d78945d9 (patch) | |
tree | 2eb2f005e2697c61e11684b97536a639eb4a617d /engines/prince | |
parent | 05ef38f7d9f912f8613d56764aa93c85e3365bbc (diff) | |
download | scummvm-rg350-acf9ac241eb1d23d435643f0d0ff2c04d78945d9.tar.gz scummvm-rg350-acf9ac241eb1d23d435643f0d0ff2c04d78945d9.tar.bz2 scummvm-rg350-acf9ac241eb1d23d435643f0d0ff2c04d78945d9.zip |
PRINCE: Proper memory reading for lightX, lightY, shadowScale
Diffstat (limited to 'engines/prince')
-rw-r--r-- | engines/prince/script.cpp | 40 | ||||
-rw-r--r-- | engines/prince/script.h | 30 |
2 files changed, 53 insertions, 17 deletions
diff --git a/engines/prince/script.cpp b/engines/prince/script.cpp index 5070236c72..11cba8fdf9 100644 --- a/engines/prince/script.cpp +++ b/engines/prince/script.cpp @@ -134,30 +134,44 @@ bool Script::loadFromStream(Common::SeekableReadStream &stream) { stream.read(_data, _dataSize); Common::MemoryReadStream scriptDataStream(_data, _dataSize); - scriptDataStream.seek(getRoomTableOffset()+64); - debug("room table offset %d", scriptDataStream.pos()); - Room room; - room.loadFromStream(scriptDataStream); + _scriptInfo.rooms = scriptDataStream.readSint32LE(); + _scriptInfo.startGame = scriptDataStream.readSint32LE(); + _scriptInfo.restoreGame = scriptDataStream.readSint32LE(); + _scriptInfo.stdExamine = scriptDataStream.readSint32LE(); + _scriptInfo.stdPickup = scriptDataStream.readSint32LE(); + _scriptInfo.stdUse = scriptDataStream.readSint32LE(); + _scriptInfo.stdOpen = scriptDataStream.readSint32LE(); + _scriptInfo.stdClose = scriptDataStream.readSint32LE(); + _scriptInfo.stdTalk = scriptDataStream.readSint32LE(); + _scriptInfo.stdGive = scriptDataStream.readSint32LE(); + _scriptInfo.usdCode = scriptDataStream.readSint32LE(); + _scriptInfo.invObjExam = scriptDataStream.readSint32LE(); + _scriptInfo.invObjUse = scriptDataStream.readSint32LE(); + _scriptInfo.invObjUU = scriptDataStream.readSint32LE(); + _scriptInfo.stdUseItem = scriptDataStream.readSint32LE(); + _scriptInfo.lightSources = scriptDataStream.readSint32LE(); + _scriptInfo.specRout = scriptDataStream.readSint32LE(); + _scriptInfo.invObjGive = scriptDataStream.readSint32LE(); + _scriptInfo.stdGiveItem = scriptDataStream.readSint32LE(); + _scriptInfo.goTester = scriptDataStream.readSint32LE(); return true; } int16 Script::getLightX(int locationNr) { - Common::MemoryReadStream readS(_data, _dataSize); - readS.seek(4*15 + locationNr*8); - return readS.readSint16LE(); + return (int)READ_UINT16(&_data[_scriptInfo.lightSources + locationNr * 8]); } int16 Script::getLightY(int locationNr) { - Common::MemoryReadStream readS(_data, _dataSize); - readS.seek(4*15 + locationNr*8 + 2); - return readS.readSint16LE(); + return (int)READ_UINT16(&_data[_scriptInfo.lightSources + locationNr * 8 + 2]); } int32 Script::getShadowScale(int locationNr) { - Common::MemoryReadStream readS(_data, _dataSize); - readS.seek(4*15 + locationNr*8 + 4); - return readS.readSint32LE(); + return (int)READ_UINT16(&_data[_scriptInfo.lightSources + locationNr * 8 + 4]); +} + +uint32 Script::getStartGameOffset() { + return _scriptInfo.startGame; } InterpreterFlags::InterpreterFlags() { diff --git a/engines/prince/script.h b/engines/prince/script.h index 4d3c822ad6..f21df1d717 100644 --- a/engines/prince/script.h +++ b/engines/prince/script.h @@ -42,7 +42,6 @@ namespace Detail { template <> inline uint8 LittleEndianReader<uint8>(void *data) { return *(uint8*)(data); } template <> inline uint16 LittleEndianReader<uint16>(void *data) { return READ_LE_UINT16(data); } template <> inline uint32 LittleEndianReader<uint32>(void *data) { return READ_LE_UINT32(data); } - template <> inline int8 LittleEndianReader<int8>(void *data) { return *(int8*)(data); } } class Room { @@ -79,6 +78,29 @@ public: Script(); ~Script(); + struct ScriptInfo { + int rooms; + int startGame; + int restoreGame; + int stdExamine; + int stdPickup; + int stdUse; + int stdOpen; + int stdClose; + int stdTalk; + int stdGive; + int usdCode; + int invObjExam; + int invObjUse; + int invObjUU; + int stdUseItem; + int lightSources; + int specRout; + int invObjGive; + int stdGiveItem; + int goTester; + }; + bool loadFromStream(Common::SeekableReadStream &stream); template <typename T> @@ -87,9 +109,8 @@ public: return Detail::LittleEndianReader<T>(&_data[address]); } - // Some magic numbers for now, data stored in header - uint32 getRoomTableOffset() { return read<uint32>(0); } - uint32 getStartGameOffset() { return read<uint32>(4); } + //uint32 getRoomTableOffset(); + uint32 getStartGameOffset(); int16 getLightX(int locationNr); int16 getLightY(int locationNr); int32 getShadowScale(int locationNr); @@ -102,6 +123,7 @@ private: uint8 *_data; uint32 _dataSize; Common::Array<Room> _roomList; + ScriptInfo _scriptInfo; }; class InterpreterFlags { |