diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/prince/debugger.cpp | 111 | ||||
-rw-r--r-- | engines/prince/debugger.h | 50 | ||||
-rw-r--r-- | engines/prince/graphics.cpp | 2 | ||||
-rw-r--r-- | engines/prince/mhwanh.h | 1 | ||||
-rw-r--r-- | engines/prince/module.mk | 1 | ||||
-rw-r--r-- | engines/prince/prince.cpp | 155 | ||||
-rw-r--r-- | engines/prince/prince.h | 20 | ||||
-rw-r--r-- | engines/prince/script.cpp | 21 |
8 files changed, 298 insertions, 63 deletions
diff --git a/engines/prince/debugger.cpp b/engines/prince/debugger.cpp new file mode 100644 index 0000000000..56053afb28 --- /dev/null +++ b/engines/prince/debugger.cpp @@ -0,0 +1,111 @@ +/* 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 "prince/debugger.h" +#include "prince/prince.h" + +namespace Prince { + +Debugger::Debugger(PrinceEngine *vm) : GUI::Debugger(), _vm(vm) { + DCmd_Register("continue", WRAP_METHOD(Debugger, Cmd_Exit)); + DCmd_Register("setflag", WRAP_METHOD(Debugger, Cmd_SetFlag)); + DCmd_Register("getflag", WRAP_METHOD(Debugger, Cmd_GetFlag)); + DCmd_Register("clearflag", WRAP_METHOD(Debugger, Cmd_ClearFlag)); + DCmd_Register("viewflc", WRAP_METHOD(Debugger, Cmd_ViewFlc)); +} + +static int strToInt(const char *s) { + if (!*s) + // No string at all + return 0; + else if (toupper(s[strlen(s) - 1]) != 'H') + // Standard decimal string + return atoi(s); + + // Hexadecimal string + uint tmp = 0; + int read = sscanf(s, "%xh", &tmp); + if (read < 1) + error("strToInt failed on string \"%s\"", s); + return (int)tmp; +} + +/* + * This command sets a flag + */ +bool Debugger::Cmd_SetFlag(int argc, const char **argv) { + // Check for a flag to set + if (argc != 2) { + DebugPrintf("Usage: %s <flag number>\n", argv[0]); + return true; + } + + int flagNum = strToInt(argv[1]); + //g_globals->setFlag(flagNum); + return true; +} + +/* + * This command gets the value of a flag + */ +bool Debugger::Cmd_GetFlag(int argc, const char **argv) { + // Check for an flag to display + if (argc != 2) { + DebugPrintf("Usage: %s <flag number>\n", argv[0]); + return true; + } + + int flagNum = strToInt(argv[1]); + //DebugPrintf("Value: %d\n", g_globals->getFlag(flagNum)); + return true; +} + +/* + * This command clears a flag + */ +bool Debugger::Cmd_ClearFlag(int argc, const char **argv) { + // Check for a flag to clear + if (argc != 2) { + DebugPrintf("Usage: %s <flag number>\n", argv[0]); + return true; + } + + int flagNum = strToInt(argv[1]); + //g_globals->clearFlag(flagNum); + return true; +} + +/* + * This command starts new flc anim + */ +bool Debugger::Cmd_ViewFlc(int argc, const char **argv) { + // Check for a flag to clear + if (argc != 2) { + DebugPrintf("Usage: %s <anim number>\n", argv[0]); + return true; + } + + int flagNum = strToInt(argv[1]); + _vm->loadAnim(flagNum); + return true; +} +} diff --git a/engines/prince/debugger.h b/engines/prince/debugger.h new file mode 100644 index 0000000000..d47e439c8b --- /dev/null +++ b/engines/prince/debugger.h @@ -0,0 +1,50 @@ +/* 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 PRINCE_DEBUGGER_H +#define PRINCE_DEBUGGER_H + +#include "common/scummsys.h" +#include "gui/debugger.h" + +namespace Prince { + +class PrinceEngine; + +class Debugger : public GUI::Debugger { +public: + Debugger(PrinceEngine *vm); + virtual ~Debugger() {} // we need this for __SYMBIAN32__ archaic gcc/UIQ + +private: + bool Cmd_SetFlag(int argc, const char **argv); + bool Cmd_GetFlag(int argc, const char **argv); + bool Cmd_ClearFlag(int argc, const char **argv); + bool Cmd_ViewFlc(int argc, const char **argv); + + PrinceEngine *_vm; +}; + + +} + +#endif diff --git a/engines/prince/graphics.cpp b/engines/prince/graphics.cpp index 2b6366b00b..eae94748f6 100644 --- a/engines/prince/graphics.cpp +++ b/engines/prince/graphics.cpp @@ -33,6 +33,7 @@ void GraphicsMan::draw(const Graphics::Surface *s) { for (uint y = 0; y < 480; y++) memcpy((byte*)_frontScreen->getBasePtr(0, y), (byte*)s->getBasePtr(0, y), 640); + change(); } void GraphicsMan::drawTransparent(const Graphics::Surface *s) @@ -48,6 +49,7 @@ void GraphicsMan::drawTransparent(const Graphics::Surface *s) } } } + change(); } } diff --git a/engines/prince/mhwanh.h b/engines/prince/mhwanh.h index 44f957372e..21822759e8 100644 --- a/engines/prince/mhwanh.h +++ b/engines/prince/mhwanh.h @@ -24,6 +24,7 @@ #define PRINCE_MHWANH_H #include "graphics/decoders/image_decoder.h" +#include "graphics/surface.h" namespace Prince { diff --git a/engines/prince/module.mk b/engines/prince/module.mk index 853592b503..a177e670ed 100644 --- a/engines/prince/module.mk +++ b/engines/prince/module.mk @@ -1,6 +1,7 @@ MODULE := engines/prince
MODULE_OBJS = \
+ debugger.o \
script.o \
graphics.o \
mhwanh.o \
diff --git a/engines/prince/prince.cpp b/engines/prince/prince.cpp index 72d5e55fe8..4ad1863ba5 100644 --- a/engines/prince/prince.cpp +++ b/engines/prince/prince.cpp @@ -44,17 +44,19 @@ #include "prince/prince.h"
#include "prince/font.h"
-#include "prince/mhwanh.h"
#include "prince/graphics.h"
#include "prince/script.h"
+#include "prince/debugger.h"
#include "video/flic_decoder.h"
namespace Prince {
PrinceEngine::PrinceEngine(OSystem *syst, const PrinceGameDescription *gameDesc) :
- Engine(syst), _gameDescription(gameDesc), _graph(NULL), _script(NULL) {
+ Engine(syst), _gameDescription(gameDesc), _graph(NULL), _script(NULL),
+ _locationNr(0), _debugger(NULL) {
_rnd = new Common::RandomSource("prince");
+ _debugger = new Debugger(this);
}
@@ -62,6 +64,12 @@ PrinceEngine::~PrinceEngine() { DebugMan.clearAllDebugChannels();
delete _rnd;
+ delete _debugger;
+}
+
+GUI::Debugger *PrinceEngine::getDebugger()
+{
+ return _debugger;
}
Common::Error PrinceEngine::run() {
@@ -73,9 +81,6 @@ Common::Error PrinceEngine::run() { debug("Adding all path: %s", gameDataDir.getPath().c_str());
SearchMan.addSubDirectoryMatching(gameDataDir, "all", 0, 2);
- SearchMan.addSubDirectoryMatching(gameDataDir, "59", 0, 2);
-
- Common::SeekableReadStream * walizka = SearchMan.createReadStreamForMember("walizka");
Common::SeekableReadStream *font1stream = SearchMan.createReadStreamForMember("font1.raw");
if (!font1stream)
@@ -86,51 +91,65 @@ Common::Error PrinceEngine::run() { }
delete font1stream;
- Common::SeekableReadStream *room = SearchMan.createReadStreamForMember("room");
-
- //_frontScreen = new Graphics::Surface();
- //_frontScreen->create(640, 480, Graphics::PixelFormat::createFormatCLUT8());
-
- if (room) {
- _roomBmp.loadStream(*room);
- //_roomBackground = roomBmp.getSurface();
- _system->getPaletteManager()->setPalette(_roomBmp.getPalette(), 0, 256);
+ Common::SeekableReadStream * walizka = SearchMan.createReadStreamForMember("walizka");
+ if (!walizka)
+ return Common::kPathDoesNotExist;
- //font1.drawString(_frontScreen, "Hello World", 10, 10, 640, 1);
- //
-#if 0
- MhwanhDecoder *walizkaBmp = new MhwanhDecoder();
- if (walizka) {
- debug("Loading walizka");
- if (walizkaBmp->loadStream(*walizka)) {
- _graph->_roomBackground = walizkaBmp->getSurface();
- _graph->setPalette(walizkaBmp->getPalette());
- }
- }
-#endif
- _graph->change();
+ debug("Loading walizka");
+ if (!_walizkaBmp.loadStream(*walizka)) {
+ return Common::kPathDoesNotExist;
+ }
- Common::SeekableReadStream * skryptStream = SearchMan.createReadStreamForMember("skrypt.dat");
- if (!skryptStream)
- return Common::kPathNotFile;
+ Common::SeekableReadStream * skryptStream = SearchMan.createReadStreamForMember("skrypt.dat");
+ if (!skryptStream)
+ return Common::kPathNotFile;
- _script = new Script(this);
- _script->loadFromStream(*skryptStream);
+ debug("Loading skrypt");
+ _script = new Script(this);
+ _script->loadFromStream(*skryptStream);
- delete skryptStream;
+ delete skryptStream;
- mainLoop();
- delete room;
- //delete walizkaBmp;
- }
+ mainLoop();
return Common::kNoError;
}
-bool PrinceEngine::PlayNextFrame()
+bool PrinceEngine::loadLocation(uint16 locationNr)
{
- _graph->draw(_roomBmp.getSurface());
+ debug("PrinceEngine::loadLocation %d", locationNr);
+ const Common::FSNode gameDataDir(ConfMan.get("path"));
+ SearchMan.remove(Common::String::format("%02d", _locationNr));
+ _locationNr = locationNr;
+
+ const Common::String locationNrStr = Common::String::format("%02d", _locationNr);
+ debug("loadLocation %s", locationNrStr.c_str());
+ SearchMan.addSubDirectoryMatching(gameDataDir, locationNrStr, 0, 2);
+
+ // load location background
+ Common::SeekableReadStream *room = SearchMan.createReadStreamForMember("room");
+ if (!room)
+ {
+ error("Can't load room bitmap");
+ return false;
+ }
+
+ if(_roomBmp.loadStream(*room))
+ {
+ debug("Room bitmap loaded");
+ _system->getPaletteManager()->setPalette(_roomBmp.getPalette(), 0, 256);
+ }
+
+ delete room;
+
+ return true;
+}
+
+bool PrinceEngine::playNextFrame()
+{
+ if (_flicPlayer.endOfVideo())
+ _flicPlayer.rewind();
const Graphics::Surface *s = _flicPlayer.decodeNextFrame();
if (s)
{
@@ -141,9 +160,40 @@ bool PrinceEngine::PlayNextFrame() return true;
}
+bool PrinceEngine::loadAnim(uint16 animNr)
+{
+ Common::String streamName = Common::String::format("AN%02d", animNr);
+ Common::SeekableReadStream * flicStream = SearchMan.createReadStreamForMember(streamName);
+
+ if (!flicStream)
+ {
+ error("Can't open %s", streamName.c_str());
+ return false;
+ }
+
+ if (!_flicPlayer.loadStream(flicStream))
+ {
+ error("Can't load flic stream %s", streamName.c_str());
+ }
+
+ debug("%s loaded", streamName.c_str());
+ _flicPlayer.start();
+ return true;
+}
+
+void PrinceEngine::keyHandler(Common::Event event) {
+ uint16 nChar = event.kbd.keycode;
+ if (event.kbd.hasFlags(Common::KBD_CTRL)) {
+ switch (nChar) {
+ case Common::KEYCODE_d:
+ getDebugger()->attach();
+ getDebugger()->onFrame();
+ break;
+ }
+ }
+}
+
void PrinceEngine::mainLoop() {
- //uint32 nextFrameTime = 0;
- uint32 an = 1;
while (!shouldQuit()) {
Common::Event event;
@@ -151,6 +201,7 @@ void PrinceEngine::mainLoop() { while (eventMan->pollEvent(event)) {
switch (event.type) {
case Common::EVENT_KEYDOWN:
+ keyHandler(event);
break;
case Common::EVENT_KEYUP:
break;
@@ -172,23 +223,13 @@ void PrinceEngine::mainLoop() { if (shouldQuit())
return;
- //_script->step();
- if (_flicPlayer.endOfVideo())
- {
- Common::String streamName = Common::String::format("AN%02d", an++);
- Common::SeekableReadStream * flicStream = SearchMan.createReadStreamForMember(streamName);
-
- if (flicStream)
- {
- if (_flicPlayer.loadStream(flicStream))
- {
- debug("%s loaded", streamName.c_str());
- _flicPlayer.start();
- }
- }
- }
+ _script->step();
+
+ if (_roomBmp.getSurface())
+ _graph->draw(_roomBmp.getSurface());
+
+ playNextFrame();
- PlayNextFrame();
_graph->update();
_system->delayMillis(40);
diff --git a/engines/prince/prince.h b/engines/prince/prince.h index 58a4466825..efaf643cb7 100644 --- a/engines/prince/prince.h +++ b/engines/prince/prince.h @@ -29,9 +29,12 @@ #include "common/debug-channels.h"
#include "common/textconsole.h"
#include "common/rect.h"
+#include "common/events.h"
#include "graphics/decoders/bmp.h"
+#include "gui/debugger.h"
+
#include "engines/engine.h"
#include "engines/util.h"
@@ -40,6 +43,7 @@ #include "video/flic_decoder.h"
#include "prince/font.h"
+#include "prince/mhwanh.h"
namespace Prince {
@@ -48,6 +52,7 @@ struct PrinceGameDescription; class PrinceEngine;
class GraphicsMan;
class Script;
+class Debugger;
class PrinceEngine : public Engine {
protected:
@@ -65,14 +70,23 @@ public: Common::Language getLanguage() const;
const PrinceGameDescription *_gameDescription;
-
+ Video::FlicDecoder _flicPlayer;
+
+ bool loadLocation(uint16 locationNr);
+ bool loadAnim(uint16 animNr);
+
+ virtual GUI::Debugger *getDebugger();
+
private:
- bool PlayNextFrame();
+ bool playNextFrame();
+ void keyHandler(Common::Event event);
Common::RandomSource *_rnd;
- Video::FlicDecoder _flicPlayer;
Graphics::BitmapDecoder _roomBmp;
+ uint16 _locationNr;
+ MhwanhDecoder _walizkaBmp;
+ Debugger *_debugger;
GraphicsMan *_graph;
Script *_script;
Font _font;
diff --git a/engines/prince/script.cpp b/engines/prince/script.cpp index c2f1706ee5..239b26b355 100644 --- a/engines/prince/script.cpp +++ b/engines/prince/script.cpp @@ -1,4 +1,5 @@ #include "prince/script.h" +#include "prince/prince.h" #include "common/debug.h" #include "common/debug-channels.h" @@ -44,7 +45,7 @@ void Script::debugScript(const char *s, ...) { } void Script::step() { - while (!_opcodeNF) + //while (!_opcodeNF) { _lastInstruction = _currentInstruction; // Prepare the base debug string @@ -94,6 +95,7 @@ uint32 Script::readScript32bits() { void Script::O_WAITFOREVER() { debugScript("O_WAITFOREVER"); + _currentInstruction -= 2; } void Script::O_BLACKPALETTE() { @@ -107,6 +109,7 @@ void Script::O_SETUPPALETTE() { void Script::O_INITROOM() { uint16 roomId = readScript16bits(); debugScript("O_INITROOM %d", roomId); + _vm->loadLocation(roomId); } void Script::O_SETSAMPLE() { @@ -355,7 +358,12 @@ void Script::O_OBSOLETE_GETACTION() {} void Script::O_ADDWALKAREA() {} void Script::O_REMWALKAREA() {} void Script::O_RESTOREWALKAREA() {} -void Script::O_WAITFRAME() {} + +void Script::O_WAITFRAME() { + debugScript("O_WAITFRAME"); + _opcodeNF = true; +} + void Script::O_SETFRAME() {} void Script::O_RUNACTION() {} void Script::O_COMPAREHI() {} @@ -434,9 +442,16 @@ void Script::O_FREECURSOR() { void Script::O_ADDINVQUIET() {} void Script::O_RUNHERO() {} void Script::O_SETBACKANIMDATA() {} -void Script::O_VIEWFLC() {} + +void Script::O_VIEWFLC() { + uint16 animNr = readScript16bits(); + debugScript("O_VIEWFLC animNr %d", animNr); +} + void Script::O_CHECKFLCFRAME() {} + void Script::O_CHECKFLCEND() {} + void Script::O_FREEFLC() {} void Script::O_TALKHEROSTOP() {} void Script::O_HEROCOLOR() {} |