aboutsummaryrefslogtreecommitdiff
path: root/engines/draci/game.cpp
diff options
context:
space:
mode:
authorDenis Kasak2009-07-06 19:50:59 +0000
committerDenis Kasak2009-07-06 19:50:59 +0000
commit79c42abf086911537400750fc356127669bf4c23 (patch)
treec183d758d8024d53d10aa8a4130d7e722d818d64 /engines/draci/game.cpp
parent3b75b8003d74f5587d3434d642b05c61a4227fed (diff)
downloadscummvm-rg350-79c42abf086911537400750fc356127669bf4c23.tar.gz
scummvm-rg350-79c42abf086911537400750fc356127669bf4c23.tar.bz2
scummvm-rg350-79c42abf086911537400750fc356127669bf4c23.zip
* Fixed extracting visibility and location of object from its status byte
* Added Game::getRoomNum() which returns the current room number * Made Game::loadRoom() execute the room's startup script, load the room's objects and run their init scripts as well svn-id: r42194
Diffstat (limited to 'engines/draci/game.cpp')
-rw-r--r--engines/draci/game.cpp38
1 files changed, 35 insertions, 3 deletions
diff --git a/engines/draci/game.cpp b/engines/draci/game.cpp
index b2295d15b8..ab2302cae4 100644
--- a/engines/draci/game.cpp
+++ b/engines/draci/game.cpp
@@ -121,10 +121,10 @@ Game::Game(DraciEngine *vm) : _vm(vm) {
byte tmp = objStatus.readByte();
// Set object visibility
- _objects[i]._visible = tmp & 1;
+ _objects[i]._visible = tmp & (1 << 7);
// Set object location
- _objects[i]._location = tmp & ~1;
+ _objects[i]._location = (~(1 << 7) & tmp) - 1;
}
assert(numDialogs == _info->_numDialogs);
@@ -172,6 +172,32 @@ void Game::loadRoom(uint roomNum) {
_currentRoom._escRoom = roomReader.readByte() - 1;
_currentRoom._numGates = roomReader.readByte();
+ for (uint i = 0; i < _info->_numObjects; ++i) {
+ debugC(1, kDraciLogicDebugLevel,
+ "Checking if object %d (%d) is at the current location (%d)", i,
+ _objects[i]._location, roomNum);
+
+ if (_objects[i]._location == roomNum) {
+ debugC(1, kDraciLogicDebugLevel, "Loading object %d from room %d", i, roomNum);
+ loadObject(i);
+ }
+ }
+
+ // We can't do this in the above loop because some objects' scripts reference
+ // other objects that may not yet be loaded
+ for (uint i = 0; i < _info->_numObjects; ++i) {
+ if (_objects[i]._location == roomNum) {
+ _vm->_script->run(getObject(i)->_program, getObject(i)->_init);
+ }
+ }
+
+ f = _vm->_roomsArchive->getFile(roomNum * 4 + 3);
+ _currentRoom._program._bytecode = new byte[f->_length];
+ _currentRoom._program._length = f->_length;
+ memcpy(_currentRoom._program._bytecode, f->_data, f->_length);
+
+ _vm->_script->run(_currentRoom._program, _currentRoom._init);
+
f = _vm->_paletteArchive->getFile(_currentRoom._palette);
_vm->_screen->setPalette(f->_data, 0, kNumColours);
}
@@ -295,7 +321,13 @@ void Game::loadOverlays() {
void Game::changeRoom(uint roomNum) {
_currentRoom._roomNum = roomNum;
loadRoom(roomNum);
- loadOverlays();
+ loadOverlays();
+
+ _vm->_script->run(_currentRoom._program, _currentRoom._init);
+}
+
+int Game::getRoomNum() {
+ return _currentRoom._roomNum;
}
Game::~Game() {