aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorMatthew Hoops2010-07-04 23:38:08 +0000
committerMatthew Hoops2010-07-04 23:38:08 +0000
commit18b449d4fdcf9651f325259fb7ba1d81135143ff (patch)
tree8c736b4c828f03a762fc3efe890b18832dabd424 /engines
parent6219ffe52f2f38dfcdf000227554eaa8d9d3098c (diff)
downloadscummvm-rg350-18b449d4fdcf9651f325259fb7ba1d81135143ff.tar.gz
scummvm-rg350-18b449d4fdcf9651f325259fb7ba1d81135143ff.tar.bz2
scummvm-rg350-18b449d4fdcf9651f325259fb7ba1d81135143ff.zip
Add a hexDumpReg function to view references that are not raw and fix SCI32 strings/arrays in segmentInfo.
svn-id: r50660
Diffstat (limited to 'engines')
-rw-r--r--engines/sci/console.cpp74
-rw-r--r--engines/sci/console.h1
2 files changed, 72 insertions, 3 deletions
diff --git a/engines/sci/console.cpp b/engines/sci/console.cpp
index b83ffee0e7..bb79fc145a 100644
--- a/engines/sci/console.cpp
+++ b/engines/sci/console.cpp
@@ -1558,6 +1558,15 @@ bool Console::segmentInfo(int nr) {
break;
}
+#ifdef ENABLE_SCI32
+ case SEG_TYPE_STRING:
+ DebugPrintf("SCI32 strings\n");
+ break;
+ case SEG_TYPE_ARRAY:
+ DebugPrintf("SCI32 arrays\n");
+ break;
+#endif
+
default :
DebugPrintf("Invalid type %d\n", mobj->getType());
break;
@@ -2112,7 +2121,7 @@ bool Console::cmdViewReference(int argc, const char **argv) {
return true;
}
- if (reg_end.segment != reg.segment) {
+ if (reg_end.segment != reg.segment && reg_end != NULL_REG) {
DebugPrintf("Ending segment different from starting segment. Assuming no bound on dump.\n");
reg_end = NULL_REG;
}
@@ -2151,13 +2160,15 @@ bool Console::cmdViewReference(int argc, const char **argv) {
switch (_engine->_gamestate->_segMan->getSegmentType(reg.segment)) {
#ifdef ENABLE_SCI32
case SEG_TYPE_STRING: {
+ DebugPrintf("SCI32 string\n");
const SciString *str = _engine->_gamestate->_segMan->lookupString(reg);
Common::hexdump((const byte *) str->getRawData(), str->getSize(), 16, 0);
break;
}
case SEG_TYPE_ARRAY: {
+ DebugPrintf("SCI32 array:\n");
const SciArray<reg_t> *array = _engine->_gamestate->_segMan->lookupArray(reg);
- Common::hexdump((const byte *) array->getRawData(), array->getSize(), 16, 0);
+ hexDumpReg(array->getRawData(), array->getSize(), 4, 0, true);
break;
}
#endif
@@ -2179,7 +2190,10 @@ bool Console::cmdViewReference(int argc, const char **argv) {
if (reg_end.segment != 0)
DebugPrintf("Block size less than or equal to %d\n", size);
- Common::hexdump(block.raw, size, 16, 0);
+ if (block.isRaw)
+ Common::hexdump(block.raw, size, 16, 0);
+ else
+ hexDumpReg(block.reg, size / 2, 4, 0);
}
}
break;
@@ -3284,4 +3298,58 @@ int Console::printObject(reg_t pos) {
return 0;
}
+void Console::hexDumpReg(const reg_t *data, int len, int regsPerLine, int startOffset, bool isArray) {
+ // reg_t version of Common::hexdump
+ assert(1 <= regsPerLine && regsPerLine <= 8);
+ int i;
+ byte c;
+ int offset = startOffset;
+ while (len >= regsPerLine) {
+ printf("%06x: ", offset);
+ for (i = 0; i < regsPerLine; i++) {
+ printf("%04x:%04x ", PRINT_REG(data[i]));
+ }
+ printf(" |");
+ for (i = 0; i < regsPerLine; i++) {
+ c = data[i].toUint16() >> 8;
+ if (c < 32 || c >= 127)
+ c = '.';
+ printf("%c", c);
+ c = data[i].toUint16() & 0xff;
+ if (c < 32 || c >= 127)
+ c = '.';
+ printf("%c", c);
+ }
+ printf("|\n");
+ data += regsPerLine;
+ len -= regsPerLine;
+ offset += regsPerLine * (isArray ? 1 : 2);
+ }
+
+ if (len <= 0)
+ return;
+
+ printf("%06x: ", offset);
+ for (i = 0; i < regsPerLine; i++) {
+ if (i < len)
+ printf("%04x:%04x ", PRINT_REG(data[i]));
+ else
+ printf(" ");
+ }
+ printf(" |");
+ for (i = 0; i < len; i++) {
+ c = data[i].toUint16() >> 8;
+ if (c < 32 || c >= 127)
+ c = '.';
+ printf("%c", c);
+ c = data[i].toUint16() & 0xff;
+ if (c < 32 || c >= 127)
+ c = '.';
+ printf("%c", c);
+ }
+ for (; i < regsPerLine; i++)
+ printf(" ");
+ printf("|\n");
+}
+
} // End of namespace Sci
diff --git a/engines/sci/console.h b/engines/sci/console.h
index 2948e348d8..7e7b30ea58 100644
--- a/engines/sci/console.h
+++ b/engines/sci/console.h
@@ -151,6 +151,7 @@ private:
bool segmentInfo(int nr);
void printList(List *list);
int printNode(reg_t addr);
+ void hexDumpReg(const reg_t *data, int len, int regsPerLine = 4, int startOffset = 0, bool isArray = false);
private:
SciEngine *_engine;