aboutsummaryrefslogtreecommitdiff
path: root/engines
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
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')
-rw-r--r--engines/draci/game.cpp38
-rw-r--r--engines/draci/game.h5
2 files changed, 39 insertions, 4 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() {
diff --git a/engines/draci/game.h b/engines/draci/game.h
index 8f02dd579a..14140f44e3 100644
--- a/engines/draci/game.h
+++ b/engines/draci/game.h
@@ -91,6 +91,7 @@ struct Room {
double _pers0, _persStep;
byte _escRoom;
byte _numGates;
+ GPL2Program _program;
};
class Game {
@@ -103,6 +104,8 @@ public:
void changeRoom(uint roomNum);
+ int getRoomNum();
+
void loadRoom(uint roomNum);
int loadAnimation(uint animNum);
void loadOverlays();
@@ -118,7 +121,7 @@ private:
uint16 *_dialogOffsets;
int16 *_variables;
byte *_itemStatus;
- GameObject *_objects;
+ GameObject *_objects;
Room _currentRoom;
};