Skip to content

Commit

Permalink
SCI: Added two new debug commands, plane_list and plane_items
Browse files Browse the repository at this point in the history
These can be used to debug drawn items in SCI32
  • Loading branch information
bluegr committed May 20, 2012
1 parent e7a7e22 commit 6cda15b
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 1 deletion.
54 changes: 53 additions & 1 deletion engines/sci/console.cpp
Expand Up @@ -53,6 +53,7 @@
#include "video/avi_decoder.h"
#include "sci/video/seq_decoder.h"
#ifdef ENABLE_SCI32
#include "sci/graphics/frameout.h"
#include "video/coktel_decoder.h"
#include "sci/video/robot_decoder.h"
#endif
Expand Down Expand Up @@ -131,6 +132,10 @@ Console::Console(SciEngine *engine) : GUI::Debugger(),
DCmd_Register("al", WRAP_METHOD(Console, cmdAnimateList)); // alias
DCmd_Register("window_list", WRAP_METHOD(Console, cmdWindowList));
DCmd_Register("wl", WRAP_METHOD(Console, cmdWindowList)); // alias
DCmd_Register("plane_list", WRAP_METHOD(Console, cmdPlaneList));
DCmd_Register("pl", WRAP_METHOD(Console, cmdPlaneList)); // alias
DCmd_Register("plane_items", WRAP_METHOD(Console, cmdPlaneItemList));
DCmd_Register("pi", WRAP_METHOD(Console, cmdPlaneItemList)); // alias
DCmd_Register("saved_bits", WRAP_METHOD(Console, cmdSavedBits));
DCmd_Register("show_saved_bits", WRAP_METHOD(Console, cmdShowSavedBits));
// Segments
Expand Down Expand Up @@ -365,7 +370,9 @@ bool Console::cmdHelp(int argc, const char **argv) {
DebugPrintf(" pic_visualize - Enables visualization of the drawing process of EGA pictures\n");
DebugPrintf(" undither - Enable/disable undithering\n");
DebugPrintf(" play_video - Plays a SEQ, AVI, VMD, RBT or DUK video\n");
DebugPrintf(" animate_object_list / al - Shows the current list of objects in kAnimate's draw list\n");
DebugPrintf(" animate_list / al - Shows the current list of objects in kAnimate's draw list (SCI0 - SCI1.1)\n");
DebugPrintf(" window_list / wl - Shows a list of all the windows (ports) in the draw list (SCI0 - SCI1.1)\n");
DebugPrintf(" plane_list / pl - Shows a list of all the planes in the draw list (SCI2+)\n");
DebugPrintf(" saved_bits - List saved bits on the hunk\n");
DebugPrintf(" show_saved_bits - Display saved bits\n");
DebugPrintf("\n");
Expand Down Expand Up @@ -1589,6 +1596,8 @@ bool Console::cmdAnimateList(int argc, const char **argv) {
if (_engine->_gfxAnimate) {
DebugPrintf("Animate list:\n");
_engine->_gfxAnimate->printAnimateList(this);
} else {
DebugPrintf("This SCI version does not have an animate list\n");
}
return true;
}
Expand All @@ -1597,9 +1606,52 @@ bool Console::cmdWindowList(int argc, const char **argv) {
if (_engine->_gfxPorts) {
DebugPrintf("Window list:\n");
_engine->_gfxPorts->printWindowList(this);
} else {
DebugPrintf("This SCI version does not have a list of ports\n");
}
return true;
}

bool Console::cmdPlaneList(int argc, const char **argv) {
#ifdef ENABLE_SCI32
if (_engine->_gfxFrameout) {
DebugPrintf("Plane list:\n");
_engine->_gfxFrameout->printPlaneList(this);
} else {
DebugPrintf("This SCI version does not have a list of planes\n");
}
#else
DebugPrintf("SCI32 isn't included in this compiled executable\n");
#endif
return true;
}

bool Console::cmdPlaneItemList(int argc, const char **argv) {
if (argc != 2) {
DebugPrintf("Shows the list of items for a plane\n");
DebugPrintf("Usage: %s <plane address>\n", argv[0]);
return true;
}

reg_t planeObject = NULL_REG;

if (parse_reg_t(_engine->_gamestate, argv[1], &planeObject, false)) {
DebugPrintf("Invalid address passed.\n");
DebugPrintf("Check the \"addresses\" command on how to use addresses\n");
return true;
}

#ifdef ENABLE_SCI32
if (_engine->_gfxFrameout) {
DebugPrintf("Plane item list:\n");
_engine->_gfxFrameout->printPlaneItemList(this, planeObject);
} else {
DebugPrintf("This SCI version does not have a list of plane items\n");
}
#else
DebugPrintf("SCI32 isn't included in this compiled executable\n");
#endif
return true;
}

bool Console::cmdSavedBits(int argc, const char **argv) {
Expand Down
2 changes: 2 additions & 0 deletions engines/sci/console.h
Expand Up @@ -94,6 +94,8 @@ class Console : public GUI::Debugger {
bool cmdPlayVideo(int argc, const char **argv);
bool cmdAnimateList(int argc, const char **argv);
bool cmdWindowList(int argc, const char **argv);
bool cmdPlaneList(int argc, const char **argv);
bool cmdPlaneItemList(int argc, const char **argv);
bool cmdSavedBits(int argc, const char **argv);
bool cmdShowSavedBits(int argc, const char **argv);
// Segments
Expand Down
51 changes: 51 additions & 0 deletions engines/sci/graphics/frameout.cpp
Expand Up @@ -31,6 +31,7 @@
#include "graphics/surface.h"

#include "sci/sci.h"
#include "sci/console.h"
#include "sci/engine/kernel.h"
#include "sci/engine/state.h"
#include "sci/engine/selector.h"
Expand Down Expand Up @@ -677,4 +678,54 @@ void GfxFrameout::kernelFrameout() {
g_sci->getEngineState()->_throttleTrigger = true;
}

void GfxFrameout::printPlaneList(Console *con) {
for (PlaneList::const_iterator it = _planes.begin(); it != _planes.end(); ++it) {
PlaneEntry p = *it;
Common::String curPlaneName = _segMan->getObjectName(p.object);
Common::Rect r = p.upscaledPlaneRect;
Common::Rect cr = p.upscaledPlaneClipRect;

con->DebugPrintf("%04x:%04x (%s): prio %d, lastprio %d, offsetX %d, offsetY %d, pic %d, mirror %d, back %d\n",
PRINT_REG(p.object), curPlaneName.c_str(),
(int16)p.priority, (int16)p.lastPriority,
p.planeOffsetX, p.planeOffsetY, p.pictureId,
p.planePictureMirrored, p.planeBack);
con->DebugPrintf(" rect: (%d, %d, %d, %d), clip rect: (%d, %d, %d, %d)\n",
r.left, r.top, r.right, r.bottom,
cr.left, cr.top, cr.right, cr.bottom);

if (p.pictureId != 0xffff && p.pictureId != 0xfffe) {
con->DebugPrintf("Pictures:\n");

for (PlanePictureList::iterator pictureIt = _planePictures.begin(); pictureIt != _planePictures.end(); pictureIt++) {
if (pictureIt->object == p.object) {
con->DebugPrintf(" Picture %d: x %d, y %d\n", pictureIt->pictureId, pictureIt->startX, pictureIt->startY);
}
}
}
}
}

void GfxFrameout::printPlaneItemList(Console *con, reg_t planeObject) {
for (FrameoutList::iterator listIterator = _screenItems.begin(); listIterator != _screenItems.end(); listIterator++) {
FrameoutEntry *e = *listIterator;
reg_t itemPlane = readSelector(_segMan, e->object, SELECTOR(plane));

if (planeObject == itemPlane) {
Common::String curItemName = _segMan->getObjectName(e->object);
Common::Rect icr = e->celRect;
GuiResourceId picId = e->picture ? e->picture->getResourceId() : 0;

con->DebugPrintf("%d: %04x:%04x (%s), view %d, loop %d, cel %d, x %d, y %d, z %d, "
"signal %d, scale signal %d, scaleX %d, scaleY %d, rect (%d, %d, %d, %d), "
"pic %d, picX %d, picY %d, visible %d\n",
e->givenOrderNr, PRINT_REG(e->object), curItemName.c_str(),
e->viewId, e->loopNo, e->celNo, e->x, e->y, e->z,
e->signal, e->scaleSignal, e->scaleX, e->scaleY,
icr.left, icr.top, icr.right, icr.bottom,
picId, e->picStartX, e->picStartY, e->visible);
}
}
}

} // End of namespace Sci
2 changes: 2 additions & 0 deletions engines/sci/graphics/frameout.h
Expand Up @@ -104,6 +104,8 @@ class GfxFrameout {
void addPlanePicture(reg_t object, GuiResourceId pictureId, uint16 startX, uint16 startY = 0);
void deletePlanePictures(reg_t object);
void clear();
void printPlaneList(Console *con);
void printPlaneItemList(Console *con, reg_t planeObject);

private:
void showVideo();
Expand Down

0 comments on commit 6cda15b

Please sign in to comment.