aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorDenis Kasak2009-07-15 19:06:24 +0000
committerDenis Kasak2009-07-15 19:06:24 +0000
commitffffc1bea4056e6f00edc935371636352962790b (patch)
tree298770ae0022cde6f1a9d4562b0201f1b0f109a6 /engines
parenta4a3ad123cb407fc9862acb43d3ca2ea27d2da2b (diff)
downloadscummvm-rg350-ffffc1bea4056e6f00edc935371636352962790b.tar.gz
scummvm-rg350-ffffc1bea4056e6f00edc935371636352962790b.tar.bz2
scummvm-rg350-ffffc1bea4056e6f00edc935371636352962790b.zip
* Changed Game members _numMasks, _init, _look, _use and _canUse from uint16 to int
* Modified Game::loadRoom to load gates and execute their scripts * The first room loaded is now Game::_info._startRoom instead of 0 * Fixed reading of _pers0 and _persStep from the data files (they are 6 instead of 12 bytes) * Added more debug info to Script and Game svn-id: r42515
Diffstat (limited to 'engines')
-rw-r--r--engines/draci/game.cpp53
-rw-r--r--engines/draci/game.h4
-rw-r--r--engines/draci/script.cpp14
3 files changed, 53 insertions, 18 deletions
diff --git a/engines/draci/game.cpp b/engines/draci/game.cpp
index f5d3a15c85..31b2d612fa 100644
--- a/engines/draci/game.cpp
+++ b/engines/draci/game.cpp
@@ -138,9 +138,10 @@ void Game::init() {
loadObject(kDragonObject);
GameObject *dragon = getObject(kDragonObject);
+ debugC(4, kDraciLogicDebugLevel, "Running init program for the dragon object...");
_vm->_script->run(dragon->_program, dragon->_init);
- changeRoom(0);
+ changeRoom(_info._startRoom);
}
void Game::loadRoom(int roomNum) {
@@ -156,28 +157,52 @@ void Game::loadRoom(int roomNum) {
_currentRoom._music = roomReader.readByte();
_currentRoom._map = roomReader.readByte();
_currentRoom._palette = roomReader.readByte() - 1;
- _currentRoom._numMasks = roomReader.readUint16LE();
- _currentRoom._init = roomReader.readUint16LE();
- _currentRoom._look = roomReader.readUint16LE();
- _currentRoom._use = roomReader.readUint16LE();
- _currentRoom._canUse = roomReader.readUint16LE();
+ _currentRoom._numMasks = roomReader.readSint16LE();
+ _currentRoom._init = roomReader.readSint16LE();
+ _currentRoom._look = roomReader.readSint16LE();
+ _currentRoom._use = roomReader.readSint16LE();
+ _currentRoom._canUse = roomReader.readSint16LE();
_currentRoom._imInit = roomReader.readByte();
_currentRoom._imLook = roomReader.readByte();
_currentRoom._imUse = roomReader.readByte();
_currentRoom._mouseOn = roomReader.readByte();
_currentRoom._heroOn = roomReader.readByte();
- roomReader.read(&_currentRoom._pers0, 12);
- roomReader.read(&_currentRoom._persStep, 12);
+ roomReader.read(&_currentRoom._pers0, 6);
+ roomReader.read(&_currentRoom._persStep, 6);
_currentRoom._escRoom = roomReader.readByte() - 1;
_currentRoom._numGates = roomReader.readByte();
+ debugC(4, kDraciLogicDebugLevel, "_music: %d", _currentRoom._music);
+ debugC(4, kDraciLogicDebugLevel, "_map: %d", _currentRoom._map);
+ debugC(4, kDraciLogicDebugLevel, "_palette: %d", _currentRoom._palette);
+ debugC(4, kDraciLogicDebugLevel, "_numMasks: %d", _currentRoom._numMasks);
+ debugC(4, kDraciLogicDebugLevel, "_init: %d", _currentRoom._init);
+ debugC(4, kDraciLogicDebugLevel, "_look: %d", _currentRoom._look);
+ debugC(4, kDraciLogicDebugLevel, "_use: %d", _currentRoom._use);
+ debugC(4, kDraciLogicDebugLevel, "_canUse: %d", _currentRoom._canUse);
+ debugC(4, kDraciLogicDebugLevel, "_imInit: %d", _currentRoom._imInit);
+ debugC(4, kDraciLogicDebugLevel, "_imLook: %d", _currentRoom._imLook);
+ debugC(4, kDraciLogicDebugLevel, "_imUse: %d", _currentRoom._imUse);
+ debugC(4, kDraciLogicDebugLevel, "_mouseOn: %d", _currentRoom._mouseOn);
+ debugC(4, kDraciLogicDebugLevel, "_heroOn: %d", _currentRoom._heroOn);
+ debugC(4, kDraciLogicDebugLevel, "_pers0: %f", _currentRoom._pers0);
+ debugC(4, kDraciLogicDebugLevel, "_persStep: %f", _currentRoom._persStep);
+ debugC(4, kDraciLogicDebugLevel, "_escRoom: %d", _currentRoom._escRoom);
+ debugC(4, kDraciLogicDebugLevel, "_numGates: %d", _currentRoom._numGates);
+
+ Common::Array<int> gates;
+
+ for (uint i = 0; i < _currentRoom._numGates; ++i) {
+ gates.push_back(roomReader.readSint16LE());
+ }
+
for (uint i = 0; i < _info._numObjects; ++i) {
- debugC(2, kDraciLogicDebugLevel,
+ debugC(7, kDraciLogicDebugLevel,
"Checking if object %d (%d) is at the current location (%d)", i,
_objects[i]._location, roomNum);
if (_objects[i]._location == roomNum) {
- debugC(2, kDraciLogicDebugLevel, "Loading object %d from room %d", i, roomNum);
+ debugC(6, kDraciLogicDebugLevel, "Loading object %d from room %d", i, roomNum);
loadObject(i);
}
}
@@ -187,6 +212,8 @@ void Game::loadRoom(int roomNum) {
// other objects that may not yet be loaded
for (uint i = 0; i < _info._numObjects; ++i) {
if (_objects[i]._location == roomNum) {
+ debugC(6, kDraciLogicDebugLevel,
+ "Running init program for object %d (offset %d)", i, getObject(i)->_init);
_vm->_script->run(getObject(i)->_program, getObject(i)->_init);
}
}
@@ -196,8 +223,14 @@ void Game::loadRoom(int roomNum) {
_currentRoom._program._length = f->_length;
memcpy(_currentRoom._program._bytecode, f->_data, f->_length);
+ debugC(4, kDraciLogicDebugLevel, "Running room init program...");
_vm->_script->run(_currentRoom._program, _currentRoom._init);
+ for (uint i = 0; i < _currentRoom._numGates; ++i) {
+ debugC(6, kDraciLogicDebugLevel, "Running program for gate %d", i);
+ _vm->_script->run(_currentRoom._program, gates[i]);
+ }
+
f = _vm->_paletteArchive->getFile(_currentRoom._palette);
_vm->_screen->setPalette(f->_data, 0, kNumColours);
}
diff --git a/engines/draci/game.h b/engines/draci/game.h
index 4f1ec66aa3..d7d352ab6e 100644
--- a/engines/draci/game.h
+++ b/engines/draci/game.h
@@ -86,8 +86,8 @@ struct Room {
byte _music;
byte _map;
byte _palette;
- uint16 _numMasks;
- uint16 _init, _look, _use, _canUse;
+ int _numMasks;
+ int _init, _look, _use, _canUse;
bool _imInit, _imLook, _imUse;
bool _mouseOn, _heroOn;
double _pers0, _persStep;
diff --git a/engines/draci/script.cpp b/engines/draci/script.cpp
index e2c902cf6f..d22b7b4941 100644
--- a/engines/draci/script.cpp
+++ b/engines/draci/script.cpp
@@ -484,17 +484,19 @@ int Script::run(GPL2Program program, uint16 offset) {
// Seek to the requested part of the program
reader.seek(offset);
+ debugC(3, kDraciBytecodeDebugLevel,
+ "Starting GPL program at offset %d (program length: %d)", offset, program._length);
+
const GPL2Command *cmd;
do {
- debugC(3, kDraciBytecodeDebugLevel,
- "Program length = %d Current position = %d "
- "Jump = %d New Position = %d", program._length,
- reader.pos(), _jump, reader.pos() + _jump);
-
// Account for GPL jump that some commands set
- if (_jump != 0)
+ if (_jump != 0) {
+ debugC(6, kDraciBytecodeDebugLevel,
+ "Jumping from offset %d to %d (%d bytes)",
+ reader.pos(), reader.pos() + _jump, _jump);
reader.seek(_jump, SEEK_CUR);
+ }
// Reset jump
_jump = 0;