Skip to content

Commit

Permalink
SCI32: Add debugger command to view screen items in the visible plane…
Browse files Browse the repository at this point in the history
… list
  • Loading branch information
csnover committed Mar 7, 2016
1 parent 8be1ff1 commit 13f2a2c
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 5 deletions.
31 changes: 31 additions & 0 deletions engines/sci/console.cpp
Expand Up @@ -141,6 +141,8 @@ Console::Console(SciEngine *engine) : GUI::Debugger(),
registerCmd("vpl", WRAP_METHOD(Console, cmdVisiblePlaneList)); // alias
registerCmd("plane_items", WRAP_METHOD(Console, cmdPlaneItemList));
registerCmd("pi", WRAP_METHOD(Console, cmdPlaneItemList)); // alias
registerCmd("visible_plane_items", WRAP_METHOD(Console, cmdVisiblePlaneItemList));
registerCmd("vpi", WRAP_METHOD(Console, cmdVisiblePlaneItemList)); // alias
registerCmd("saved_bits", WRAP_METHOD(Console, cmdSavedBits));
registerCmd("show_saved_bits", WRAP_METHOD(Console, cmdShowSavedBits));
// Segments
Expand Down Expand Up @@ -386,6 +388,7 @@ bool Console::cmdHelp(int argc, const char **argv) {
debugPrintf(" plane_list / pl - Shows a list of all the planes in the draw list (SCI2+)\n");
debugPrintf(" visible_plane_list / vpl - Shows a list of all the planes in the visible draw list (SCI2+)\n");
debugPrintf(" plane_items / pi - Shows a list of all items for a plane (SCI2+)\n");
debugPrintf(" visible_plane_items / vpi - Shows a list of all items for a plane in the visible 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 @@ -1817,6 +1820,34 @@ bool Console::cmdPlaneItemList(int argc, const char **argv) {
return true;
}

bool Console::cmdVisiblePlaneItemList(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("Visible plane item list:\n");
_engine->_gfxFrameout->printVisiblePlaneItemList(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) {
SegManager *segman = _engine->_gamestate->_segMan;
SegmentId id = segman->findSegmentByType(SEG_TYPE_HUNK);
Expand Down
1 change: 1 addition & 0 deletions engines/sci/console.h
Expand Up @@ -98,6 +98,7 @@ class Console : public GUI::Debugger {
bool cmdPlaneList(int argc, const char **argv);
bool cmdVisiblePlaneList(int argc, const char **argv);
bool cmdPlaneItemList(int argc, const char **argv);
bool cmdVisiblePlaneItemList(int argc, const char **argv);
bool cmdSavedBits(int argc, const char **argv);
bool cmdShowSavedBits(int argc, const char **argv);
// Segments
Expand Down
25 changes: 20 additions & 5 deletions engines/sci/graphics/frameout.cpp
Expand Up @@ -2064,6 +2064,15 @@ void GfxFrameout::printVisiblePlaneList(Console *con) const {
printPlaneListInternal(con, _visiblePlanes);
}

void GfxFrameout::printPlaneItemListInternal(Console *con, const ScreenItemList &screenItemList) const {
ScreenItemList::size_type i = 0;
for (ScreenItemList::const_iterator sit = screenItemList.begin(); sit != screenItemList.end(); sit++) {
ScreenItem *screenItem = *sit;
con->debugPrintf("%2d: ", i++);
screenItem->printDebugInfo(con);
}
}

void GfxFrameout::printPlaneItemList(Console *con, const reg_t planeObject) const {
Plane *p = _planes.findByObject(planeObject);

Expand All @@ -2072,12 +2081,18 @@ void GfxFrameout::printPlaneItemList(Console *con, const reg_t planeObject) cons
return;
}

ScreenItemList::size_type i = 0;
for (ScreenItemList::iterator sit = p->_screenItemList.begin(); sit != p->_screenItemList.end(); sit++) {
ScreenItem *screenItem = *sit;
con->debugPrintf("%2d: ", i++);
screenItem->printDebugInfo(con);
printPlaneItemListInternal(con, p->_screenItemList);
}

void GfxFrameout::printVisiblePlaneItemList(Console *con, const reg_t planeObject) const {
Plane *p = _visiblePlanes.findByObject(planeObject);

if (p == nullptr) {
con->debugPrintf("Plane does not exist");
return;
}

printPlaneItemListInternal(con, p->_screenItemList);
}

} // End of namespace Sci
2 changes: 2 additions & 0 deletions engines/sci/graphics/frameout.h
Expand Up @@ -512,6 +512,8 @@ class GfxFrameout {
void printVisiblePlaneList(Console *con) const;
void printPlaneListInternal(Console *con, const PlaneList &planeList) const;
void printPlaneItemList(Console *con, const reg_t planeObject) const;
void printVisiblePlaneItemList(Console *con, const reg_t planeObject) const;
void printPlaneItemListInternal(Console *con, const ScreenItemList &screenItemList) const;
};

} // End of namespace Sci
Expand Down

0 comments on commit 13f2a2c

Please sign in to comment.