aboutsummaryrefslogtreecommitdiff
path: root/engines/access/room.cpp
diff options
context:
space:
mode:
authorPaul Gilbert2014-08-06 22:43:40 -0400
committerPaul Gilbert2014-08-06 22:43:40 -0400
commit031cc32c847bf7387859e273069f8efd3b6d4ed0 (patch)
tree99b9ff0abdc4316aa1a4df07bbbe9ff61ef70c97 /engines/access/room.cpp
parent3645aad6fb02e0430c4ff3b325e1c0012042f4b7 (diff)
downloadscummvm-rg350-031cc32c847bf7387859e273069f8efd3b6d4ed0.tar.gz
scummvm-rg350-031cc32c847bf7387859e273069f8efd3b6d4ed0.tar.bz2
scummvm-rg350-031cc32c847bf7387859e273069f8efd3b6d4ed0.zip
ACCESS: Implemented room data loading
Diffstat (limited to 'engines/access/room.cpp')
-rw-r--r--engines/access/room.cpp127
1 files changed, 125 insertions, 2 deletions
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index f735fdb167..1e9eec79b0 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -21,6 +21,7 @@
*/
#include "common/scummsys.h"
+#include "common/memstream.h"
#include "access/access.h"
#include "access/resources.h"
#include "access/room.h"
@@ -131,8 +132,77 @@ void Room::clearRoom() {
_vm->freeManData();
}
-void Room::loadRoom(int room) {
- // TODO
+void Room::loadRoomData(const byte *roomData) {
+ RoomInfo roomInfo(roomData);
+
+ _roomFlag = roomInfo._roomFlag;
+
+ _vm->_establishFlag = false;
+ if (roomInfo._estIndex != -1) {
+ _vm->_establishFlag = true;
+ if (_vm->_establishTable[roomInfo._estIndex] != 1) {
+ _vm->_establishTable[roomInfo._estIndex] = 1;
+ _vm->establish(0);
+ }
+ }
+
+ _vm->_sound->freeMusic();
+ if (roomInfo._musicFile._fileNum != -1) {
+ _vm->_sound->_music = _vm->_files->loadFile(roomInfo._musicFile._fileNum,
+ roomInfo._musicFile._subfile);
+ _vm->_sound->_midiSize = _vm->_files->_filesize;
+ _vm->_sound->midiPlay();
+ _vm->_sound->_musicRepeat = true;
+ }
+
+ _vm->_scaleH1 = roomInfo._scaleH1;
+ _vm->_scaleH2 = roomInfo._scaleH2;
+ _vm->_scaleN1 = roomInfo._scaleN1;
+ _vm->_scaleT1 = ((_vm->_scaleH2 - _vm->_scaleH1) << 8) / _vm->_scaleN1;
+
+ if (roomInfo._playFieldFile._fileNum != -1) {
+ _vm->loadPlayField(roomInfo._playFieldFile._fileNum,
+ roomInfo._playFieldFile._subfile);
+ setupRoom();
+
+ _vm->_scaleMaxY = _vm->_playFieldHeight << 4;
+ }
+
+ // Load cells
+ _vm->loadCells(roomInfo._cells);
+
+ // Load script data
+ _vm->_scripts->freeScriptData();
+ if (roomInfo._scriptFile._fileNum != -1)
+ _vm->_scripts->_script = _vm->_files->loadFile(roomInfo._scriptFile._fileNum,
+ roomInfo._scriptFile._subfile);
+
+ // Load animation data
+ _vm->freeAnimationData();
+ if (roomInfo._animFile._fileNum != -1)
+ _vm->_anim = _vm->_files->loadFile(roomInfo._animFile._fileNum,
+ roomInfo._animFile._subfile);
+
+ _vm->_scaleI = roomInfo._scaleI;
+ _vm->_screen->_scrollThreshold = roomInfo._scrollThreshold;
+
+ _vm->_screen->_startColor = roomInfo._startColor;
+ _vm->_screen->_numColors = roomInfo._numColors;
+ _vm->_screen->loadPalette(roomInfo._paletteFile._fileNum,
+ roomInfo._paletteFile._subfile);
+
+ // Load extra cells
+ _vm->_extraCells.clear();
+ for (uint i = 0; i < roomInfo._vidTable.size(); ++i) {
+ ExtraCell ec;
+ ec._vidTable = roomInfo._vidTable[i] & 0xffff;
+ ec._vidTable1 = roomInfo._vidTable[i] >> 16;
+
+ _vm->_extraCells.push_back(ec);
+ }
+
+ // Load sounds for the scene
+ _vm->_sound->loadSounds(roomInfo._sounds);
}
void Room::roomLoop() {
@@ -156,4 +226,57 @@ void Room::buildScreen() {
// TODO
}
+/*------------------------------------------------------------------------*/
+
+RoomInfo::RoomInfo(const byte *data) {
+ Common::MemoryReadStream stream(data, 999);
+
+ _roomFlag = stream.readByte() != 0;
+ _estIndex = (int16)stream.readUint16LE();
+ _musicFile._fileNum = (int16)stream.readUint16LE();
+ _musicFile._subfile = stream.readUint16LE();
+ _scaleH1 = stream.readByte();
+ _scaleH2 = stream.readByte();
+ _scaleN1 = stream.readByte();
+ _playFieldFile._fileNum = (int16)stream.readUint16LE();
+ _playFieldFile._subfile = stream.readUint16LE();
+
+ for (byte cell = stream.readByte(); cell != 0xff; cell = stream.readByte()) {
+ CellIdent ci;
+ ci._cell = cell;
+ ci._fileNum = (int16)stream.readUint16LE();
+ ci._subfile = stream.readUint16LE();
+
+ _cells.push_back(ci);
+ }
+
+ _scriptFile._fileNum = (int16)stream.readUint16LE();
+ _scriptFile._subfile = stream.readUint16LE();
+ _animFile._fileNum = (int16)stream.readUint16LE();
+ _animFile._subfile = stream.readUint16LE();
+ _scaleI = stream.readByte();
+ _scrollThreshold = stream.readByte();
+ _paletteFile._fileNum = (int16)stream.readUint16LE();
+ _paletteFile._subfile = stream.readUint16LE();
+ _startColor = stream.readUint16LE();
+ _numColors = stream.readUint16LE();
+
+ for (int16 v = (int16)stream.readUint16LE(); v != -1;
+ v = (int16)stream.readUint16LE()) {
+ uint16 v2 = stream.readUint16LE();
+
+ _vidTable.push_back(v | ((uint32)v2 << 16));
+ }
+
+ for (int16 fileNum = (int16)stream.readUint16LE(); fileNum != -1;
+ fileNum = (int16)stream.readUint16LE()) {
+ FileIdent fi;
+ fi._fileNum = fileNum;
+ fi._subfile = stream.readUint16LE();
+
+ _sounds.push_back(fi);
+ }
+};
+
+
} // End of namespace Access