aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Zbróg2013-11-05 18:45:40 +0000
committerKamil Zbróg2013-11-05 18:45:40 +0000
commit91466575eb8fa7e192ce1385a4bf3bb86be5a8c5 (patch)
tree93aae74fc2a8775936caea84178873c4d080ab74
parent04207e0d46e8da2c2b5b65f0448e2381c320ab61 (diff)
downloadscummvm-rg350-91466575eb8fa7e192ce1385a4bf3bb86be5a8c5.tar.gz
scummvm-rg350-91466575eb8fa7e192ce1385a4bf3bb86be5a8c5.tar.bz2
scummvm-rg350-91466575eb8fa7e192ce1385a4bf3bb86be5a8c5.zip
PRINCE: unified debug output
-rw-r--r--engines/prince/prince.cpp26
-rw-r--r--engines/prince/prince.h1
-rw-r--r--engines/prince/script.cpp28
3 files changed, 32 insertions, 23 deletions
diff --git a/engines/prince/prince.cpp b/engines/prince/prince.cpp
index 5543499b28..b5cb26739b 100644
--- a/engines/prince/prince.cpp
+++ b/engines/prince/prince.cpp
@@ -81,6 +81,16 @@ Graphics::Surface *loadCursor(const char *curName)
return curSurface;
}
+void PrinceEngine::debugEngine(const char *s, ...) {
+ char buf[STRINGBUFLEN];
+ va_list va;
+
+ va_start(va, s);
+ vsnprintf(buf, STRINGBUFLEN, s, va);
+ va_end(va);
+
+ debug("Prince::Engine frame %08ld %s", _frameNr, buf);
+}
PrinceEngine::PrinceEngine(OSystem *syst, const PrinceGameDescription *gameDesc) :
@@ -122,7 +132,7 @@ Common::Error PrinceEngine::run() {
const Common::FSNode gameDataDir(ConfMan.get("path"));
- debug("Adding all path: %s", gameDataDir.getPath().c_str());
+ debugEngine("Adding all path: %s", gameDataDir.getPath().c_str());
SearchMan.addSubDirectoryMatching(gameDataDir, "all", 0, 2);
SearchMan.addSubDirectoryMatching(gameDataDir, "data/voices/output", 0, 2);
@@ -140,7 +150,7 @@ Common::Error PrinceEngine::run() {
if (!walizka)
return Common::kPathDoesNotExist;
- debug("Loading walizka");
+ debugEngine("Loading walizka");
if (!_walizkaBmp.loadStream(*walizka)) {
return Common::kPathDoesNotExist;
}
@@ -149,7 +159,7 @@ Common::Error PrinceEngine::run() {
if (!skryptStream)
return Common::kPathNotFile;
- debug("Loading skrypt");
+ debugEngine("Loading skrypt");
_script = new Script(this);
_script->loadFromStream(*skryptStream);
@@ -232,13 +242,13 @@ bool ObjectList::loadFromStream(Common::SeekableReadStream &stream)
}
bool PrinceEngine::loadLocation(uint16 locationNr) {
- debug("PrinceEngine::loadLocation %d", locationNr);
+ debugEngine("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());
+ debugEngine("loadLocation %s", locationNrStr.c_str());
SearchMan.addSubDirectoryMatching(gameDataDir, locationNrStr, 0, 2);
// load location background
@@ -250,7 +260,7 @@ bool PrinceEngine::loadLocation(uint16 locationNr) {
}
if(_roomBmp.loadStream(*room)) {
- debug("Room bitmap loaded");
+ debugEngine("Room bitmap loaded");
_sceneWidth = _roomBmp.getSurface()->w;
}
@@ -350,7 +360,7 @@ bool PrinceEngine::loadAnim(uint16 animNr, bool loop) {
error("Can't load flic stream %s", streamName.c_str());
}
- debug("%s loaded", streamName.c_str());
+ debugEngine("%s loaded", streamName.c_str());
_flicLooped = loop;
_flicPlayer.start();
playNextFrame();
@@ -371,7 +381,7 @@ void PrinceEngine::scrollCameraRight(int16 delta) {
if (_sceneWidth - 640 < delta + _newCameraX)
delta += (_sceneWidth - 640) - (delta + _newCameraX);
_newCameraX += delta;
- debug(0, "PrinceEngine::scrollCameraRight() _newCameraX = %d; delta = %d", _newCameraX, delta);
+ debugEngine("PrinceEngine::scrollCameraRight() _newCameraX = %d; delta = %d", _newCameraX, delta);
}
}
diff --git a/engines/prince/prince.h b/engines/prince/prince.h
index 68a7793157..977f178b18 100644
--- a/engines/prince/prince.h
+++ b/engines/prince/prince.h
@@ -122,6 +122,7 @@ private:
void showTexts();
uint32 getTextWidth(const char *s);
+ void debugEngine(const char *s, ...);
Common::RandomSource *_rnd;
Graphics::BitmapDecoder _roomBmp;
diff --git a/engines/prince/script.cpp b/engines/prince/script.cpp
index 1da3d44036..f32c1724b9 100644
--- a/engines/prince/script.cpp
+++ b/engines/prince/script.cpp
@@ -79,7 +79,7 @@ void Script::debugScript(const char *s, ...) {
str += Common::String::format("op %04d: ", _lastOpcode);
//debugC(10, DebugChannel::kScript, "PrinceEngine::Script %s %s", str.c_str(), buf);
- debug("Prince::Script mode %s frame %ld %s %s", _mode, _vm->_frameNr, str.c_str(), buf);
+ debug("Prince::Script frame %08ld mode %s %s %s", _vm->_frameNr, _mode, str.c_str(), buf);
}
void Script::step() {
@@ -388,19 +388,20 @@ void Script::O_COMPARE() {
void Script::O_JUMPZ() {
int32 offset = readScript32bits();
- debugScript("O_JUMPZ offset 0x%04X", offset);
if (! _result) {
_currentInstruction += offset - 4;
}
+
+ debugScript("O_JUMPZ result = %d, next %08x, offset 0x%08X", _result, _currentInstruction, offset);
}
void Script::O_JUMPNZ() {
int32 offset = readScript32bits();
- debugScript("O_JUMPNZ offset 0x%08X", offset);
if (_result) {
_currentInstruction += offset - 4;
- debugScript("O_JUMPNZ next 0x%08X", _currentInstruction);
}
+
+ debugScript("O_JUMPNZ result = %d, next %08x, offset 0x%08X", _result, _currentInstruction, offset);
}
void Script::O_EXIT() {
@@ -454,13 +455,13 @@ void Script::O_SETSTRING() {
_currentString = offset;
if (offset >= 80000) {
- debug("GetVaria %s", _vm->_variaTxt->getString(offset - 80000));
+ debugScript("GetVaria %s", _vm->_variaTxt->getString(offset - 80000));
}
else if (offset < 2000) {
uint32 of = READ_LE_UINT32(_vm->_talkTxt+offset*4);
const char * txt = (const char *)&_vm->_talkTxt[of];
_string = &_vm->_talkTxt[of];
- debug("TalkTxt %d %s", of, txt);
+ debugScript("TalkTxt %d %s", of, txt);
}
debugScript("O_SETSTRING %04d", offset);
@@ -758,10 +759,9 @@ void Script::O_GETANIMDATA() {
}
void Script::O_SETBGCODE() {
- int32 bgcode = readScript32bits();
- debugScript("O_SETBGCODE %d", bgcode);
- _bgOpcodePC = _currentInstruction + bgcode;
- debugScript("O_SETBGCODE next %08X", _bgOpcodePC);
+ int32 offset = readScript32bits();
+ _bgOpcodePC = _currentInstruction + offset;
+ debugScript("O_SETBGCODE next %08x, offset %08x", _bgOpcodePC, offset);
}
void Script::O_SETBACKFRAME() {
@@ -952,11 +952,9 @@ void Script::O_POPSTRING() {
void Script::O_SETFGCODE() {
int32 offset = readScript32bits();
-
- debugScript("O_SETFGCODE offset %04X", offset);
-
_fgOpcodePC = _currentInstruction + offset;
- debugScript("O_SETFGCODE next %08X", _fgOpcodePC);
+
+ debugScript("O_SETFGCODE next %08x, offset %08x", _fgOpcodePC, offset);
}
void Script::O_STOPHERO() {
@@ -1005,7 +1003,7 @@ void Script::O_SETBACKANIMDATA() {
void Script::O_VIEWFLC() {
uint16 animNr = readScript16bits();
- debug("O_VIEWFLC animNr %d", animNr);
+ debugScript("O_VIEWFLC animNr %d", animNr);
_vm->loadAnim(animNr, false);
}