aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorFilippos Karapetis2013-01-02 20:01:00 +0200
committerFilippos Karapetis2013-01-02 20:02:29 +0200
commit69da727c550c9f0f57bd50ca2d70e1730266df59 (patch)
tree1a4ad34b1e3ec95dbef397568df2e4f90614cb6a /engines
parent3cacade68d40d462b7fcd97ee31481c0d1d47a23 (diff)
downloadscummvm-rg350-69da727c550c9f0f57bd50ca2d70e1730266df59.tar.gz
scummvm-rg350-69da727c550c9f0f57bd50ca2d70e1730266df59.tar.bz2
scummvm-rg350-69da727c550c9f0f57bd50ca2d70e1730266df59.zip
TOLTECS: Add a debug console
Diffstat (limited to 'engines')
-rw-r--r--engines/toltecs/console.cpp79
-rw-r--r--engines/toltecs/console.h45
-rw-r--r--engines/toltecs/module.mk1
-rw-r--r--engines/toltecs/resource.cpp9
-rw-r--r--engines/toltecs/resource.h2
-rw-r--r--engines/toltecs/toltecs.cpp21
-rw-r--r--engines/toltecs/toltecs.h2
7 files changed, 137 insertions, 22 deletions
diff --git a/engines/toltecs/console.cpp b/engines/toltecs/console.cpp
new file mode 100644
index 0000000000..f3394909ed
--- /dev/null
+++ b/engines/toltecs/console.cpp
@@ -0,0 +1,79 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "gui/debugger.h"
+
+#include "toltecs/console.h"
+//#include "toltecs/palette.h"
+#include "toltecs/resource.h"
+//#include "toltecs/sound.h"
+#include "toltecs/toltecs.h"
+
+namespace Toltecs {
+
+Console::Console(ToltecsEngine *vm) : GUI::Debugger(), _vm(vm) {
+ DCmd_Register("room", WRAP_METHOD(Console, Cmd_Room));
+ DCmd_Register("dump", WRAP_METHOD(Console, Cmd_Dump));
+}
+
+Console::~Console() {
+}
+
+bool Console::Cmd_Room(int argc, const char **argv) {
+ if (argc < 2) {
+ DebugPrintf("Current room number is %d\n", _vm->_sceneResIndex);
+#if 0
+ DebugPrintf("Calling this command with the room number changes the room\n");
+ DebugPrintf("WARNING: It's a bad idea to warp to rooms with this, as the room object scripts are not loaded\n");
+#endif
+ return true;
+#if 0
+ } else {
+ int roomNum = atoi(argv[1]);
+
+ // sfClearPaletteFragments
+ _vm->_palette->clearFragments();
+
+ // sfLoadScene
+ _vm->_sound->stopAll();
+ _vm->_res->purgeCache();
+ _vm->loadScene(roomNum);
+#endif
+ }
+
+ return false;
+}
+
+bool Console::Cmd_Dump(int argc, const char **argv) {
+ if (argc < 2) {
+ DebugPrintf("Usage: dump <resource number>\n");
+ return true;
+ }
+
+ int resNum = atoi(argv[1]);
+ _vm->_arc->dump(resNum);
+ DebugPrintf("Resource %d has been dumped to disk\n", resNum);
+
+ return true;
+}
+
+} // End of namespace Toltecs
diff --git a/engines/toltecs/console.h b/engines/toltecs/console.h
new file mode 100644
index 0000000000..bcdfd0cf04
--- /dev/null
+++ b/engines/toltecs/console.h
@@ -0,0 +1,45 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef TOLTECS_CONSOLE_H
+#define TOLTECS_CONSOLE_H
+
+#include "gui/debugger.h"
+
+namespace Toltecs {
+
+class ToltecsEngine;
+
+class Console : public GUI::Debugger {
+public:
+ Console(ToltecsEngine *vm);
+ virtual ~Console(void);
+
+private:
+ ToltecsEngine *_vm;
+
+ bool Cmd_Dump(int argc, const char **argv);
+ bool Cmd_Room(int argc, const char **argv);
+};
+
+} // End of namespace Toltecs
+#endif
diff --git a/engines/toltecs/module.mk b/engines/toltecs/module.mk
index aa4a6f376b..0de1eef733 100644
--- a/engines/toltecs/module.mk
+++ b/engines/toltecs/module.mk
@@ -2,6 +2,7 @@ MODULE := engines/toltecs
MODULE_OBJS = \
animation.o \
+ console.o \
detection.o \
menu.o \
microtiles.o \
diff --git a/engines/toltecs/resource.cpp b/engines/toltecs/resource.cpp
index 0b9f7c8fcd..437b4a963a 100644
--- a/engines/toltecs/resource.cpp
+++ b/engines/toltecs/resource.cpp
@@ -61,16 +61,11 @@ uint32 ArchiveReader::getResourceSize(uint resIndex) {
return _offsets[resIndex + 1] - _offsets[resIndex];
}
-void ArchiveReader::dump(uint resIndex, const char *prefix) {
+void ArchiveReader::dump(uint resIndex) {
int32 resourceSize = getResourceSize(resIndex);
byte *data = new byte[resourceSize];
- Common::String fn;
-
- if (prefix)
- fn = Common::String::format("%s_%04X.0", prefix, resIndex);
- else
- fn = Common::String::format("%04X.0", resIndex);
+ Common::String fn = Common::String::format("toltecs_res.%03d", resIndex);
openResource(resIndex);
read(data, resourceSize);
diff --git a/engines/toltecs/resource.h b/engines/toltecs/resource.h
index 3fed2e11ca..3d45d9fb1b 100644
--- a/engines/toltecs/resource.h
+++ b/engines/toltecs/resource.h
@@ -50,7 +50,7 @@ public:
// Returns the size of the resource
uint32 getResourceSize(uint resIndex);
- void dump(uint resIndex, const char *prefix = NULL);
+ void dump(uint resIndex);
protected:
uint32 *_offsets;
diff --git a/engines/toltecs/toltecs.cpp b/engines/toltecs/toltecs.cpp
index b3ab09725a..6d8a5eb782 100644
--- a/engines/toltecs/toltecs.cpp
+++ b/engines/toltecs/toltecs.cpp
@@ -39,6 +39,7 @@
#include "toltecs/toltecs.h"
#include "toltecs/animation.h"
+#include "toltecs/console.h"
#include "toltecs/menu.h"
#include "toltecs/movie.h"
#include "toltecs/music.h"
@@ -126,6 +127,7 @@ Common::Error ToltecsEngine::run() {
_menuSystem = new MenuSystem(this);
_sound = new Sound(this);
+ _console = new Console(this);
_cfgText = ConfMan.getBool("subtitles");
_cfgVoices = !ConfMan.getBool("speech_mute");
@@ -179,6 +181,7 @@ Common::Error ToltecsEngine::run() {
_music->stopSequence();
_sound->stopAll();
+ delete _console;
delete _arc;
delete _res;
delete _screen;
@@ -218,7 +221,6 @@ void ToltecsEngine::requestLoadgame(int slotNum) {
}
void ToltecsEngine::loadScene(uint resIndex) {
-
Resource *sceneResource = _res->load(resIndex);
byte *scene = sceneResource->data;
@@ -253,13 +255,10 @@ void ToltecsEngine::loadScene(uint resIndex) {
_screen->_fullRefresh = true;
_screen->_renderQueue->clear();
-
}
void ToltecsEngine::updateScreen() {
-
_sound->updateSpeech();
-
_screen->updateShakeScreen();
// TODO: Set quit flag
@@ -292,7 +291,6 @@ void ToltecsEngine::updateScreen() {
_counter02 = (currUpdateTime - prevUpdateTime) / 13;
} while (_counter02 == 0);
prevUpdateTime = currUpdateTime;
-
}
void ToltecsEngine::drawScreen() {
@@ -313,6 +311,7 @@ void ToltecsEngine::drawScreen() {
_screen->_guiRefresh = false;
}
+ _console->onFrame();
_system->updateScreen();
_system->delayMillis(10);
@@ -320,7 +319,6 @@ void ToltecsEngine::drawScreen() {
}
void ToltecsEngine::updateInput() {
-
Common::Event event;
Common::EventManager *eventMan = _system->getEventManager();
while (eventMan->pollEvent(event)) {
@@ -330,6 +328,9 @@ void ToltecsEngine::updateInput() {
//debug("key: flags = %02X; keycode = %d", _keyState.flags, _keyState.keycode);
+ if (event.kbd.hasFlags(Common::KBD_CTRL) && event.kbd.keycode == Common::KEYCODE_d)
+ _console->attach();
+
switch (event.kbd.keycode) {
case Common::KEYCODE_F5:
showMenu(kMenuIdSave);
@@ -411,9 +412,7 @@ void ToltecsEngine::updateInput() {
_mouseWaitForRelease = false;
_mouseButton = 0;
}
-
}
-
}
void ToltecsEngine::setGuiHeight(int16 guiHeight) {
@@ -481,7 +480,6 @@ void ToltecsEngine::scrollCameraRight(int16 delta) {
}
void ToltecsEngine::updateCamera() {
-
if (_cameraX != _newCameraX) {
_cameraX = _newCameraX;
_screen->_fullRefresh = true;
@@ -495,11 +493,9 @@ void ToltecsEngine::updateCamera() {
}
//debug(0, "ToltecsEngine::updateCamera() _cameraX = %d; _cameraY = %d", _cameraX, _cameraY);
-
}
void ToltecsEngine::talk(int16 slotIndex, int16 slotOffset) {
-
byte *scanData = _script->getSlotData(slotIndex) + slotOffset;
while (*scanData < 0xF0) {
@@ -529,11 +525,9 @@ void ToltecsEngine::talk(int16 slotIndex, int16 slotOffset) {
} else {
_screen->updateTalkText(slotIndex, slotOffset);
}
-
}
void ToltecsEngine::walk(byte *walkData) {
-
int16 xdelta, ydelta, v8, v10, v11;
int16 xstep, ystep;
ScriptWalk walkInfo;
@@ -616,7 +610,6 @@ void ToltecsEngine::walk(byte *walkData) {
WRITE_LE_UINT16(walkData + 14, walkInfo.xerror);
WRITE_LE_UINT16(walkData + 16, walkInfo.mulValue);
WRITE_LE_UINT16(walkData + 18, walkInfo.scaling);
-
}
int16 ToltecsEngine::findRectAtPoint(byte *rectData, int16 x, int16 y, int16 index, int16 itemSize,
diff --git a/engines/toltecs/toltecs.h b/engines/toltecs/toltecs.h
index b95a4f77cb..0be2d2a646 100644
--- a/engines/toltecs/toltecs.h
+++ b/engines/toltecs/toltecs.h
@@ -42,6 +42,7 @@ struct ToltecsGameDescription;
class AnimationPlayer;
class ArchiveReader;
+class Console;
class Input;
class MenuSystem;
class MoviePlayer;
@@ -144,6 +145,7 @@ public:
AnimationPlayer *_anim;
ArchiveReader *_arc;
+ Console *_console;
Input *_input;
MenuSystem *_menuSystem;
MoviePlayer *_moviePlayer;