Add support for SCI32 segment types to seg_table and vr debug commands

svn-id: r49686
This commit is contained in:
Lars Skovlund 2010-06-15 08:21:39 +00:00
parent 0dab9e0e1f
commit 9a1db3f770
3 changed files with 47 additions and 14 deletions

View File

@ -1095,6 +1095,14 @@ bool Console::cmdSaveGame(int argc, const char **argv) {
delete out;
}
out->finalize();
if (out->err()) {
delete out;
warning("Writing the savegame failed.");
} else {
delete out;
}
return true;
}
@ -1420,6 +1428,16 @@ bool Console::cmdPrintSegmentTable(int argc, const char **argv) {
DebugPrintf("F string fragments");
break;
#ifdef ENABLE_SCI32
case SEG_TYPE_ARRAY:
DebugPrintf("A SCI32 arrays (%d)", (*(ArrayTable *)mobj).entries_used);
break;
case SEG_TYPE_STRING:
DebugPrintf("T SCI32 strings (%d)", (*(StringTable *)mobj).entries_used);
break;
#endif
default:
DebugPrintf("I Invalid (type = %x)", mobj->getType());
break;
@ -2180,26 +2198,40 @@ bool Console::cmdViewReference(int argc, const char **argv) {
printObject(reg);
break;
case KSIG_REF: {
int size;
const SegmentRef block = _engine->_gamestate->_segMan->dereference(reg);
size = block.maxSize;
switch (_engine->_gamestate->_segMan->getSegmentType(reg.segment)) {
case SEG_TYPE_STRING: {
const SciString *str = _engine->_gamestate->_segMan->lookupString(reg);
Common::hexdump((const byte *) str->getRawData(), str->getSize(), 16, 0);
break;
}
case SEG_TYPE_ARRAY: {
const SciArray<reg_t> *array = _engine->_gamestate->_segMan->lookupArray(reg);
Common::hexdump((const byte *) array->getRawData(), array->getSize(), 16, 0);
break;
}
default: {
int size;
const SegmentRef block = _engine->_gamestate->_segMan->dereference(reg);
size = block.maxSize;
DebugPrintf("raw data\n");
DebugPrintf("raw data\n");
if (reg_end.segment != 0 && size < reg_end.offset - reg.offset) {
DebugPrintf("Block end out of bounds (size %d). Resetting.\n", size);
reg_end = NULL_REG;
}
if (reg_end.segment != 0 && size < reg_end.offset - reg.offset) {
DebugPrintf("Block end out of bounds (size %d). Resetting.\n", size);
reg_end = NULL_REG;
}
if (reg_end.segment != 0 && (size >= reg_end.offset - reg.offset))
size = reg_end.offset - reg.offset;
if (reg_end.segment != 0 && (size >= reg_end.offset - reg.offset))
size = reg_end.offset - reg.offset;
if (reg_end.segment != 0)
DebugPrintf("Block size less than or equal to %d\n", size);
if (reg_end.segment != 0)
DebugPrintf("Block size less than or equal to %d\n", size);
Common::hexdump(block.raw, size, 16, 0);
Common::hexdump(block.raw, size, 16, 0);
}
}
break;
}
case KSIG_ARITHMETIC:
DebugPrintf("arithmetic value\n %d (%04x)\n", (int16) reg.offset, reg.offset);
break;

View File

@ -435,7 +435,7 @@ bool Script::isValidOffset(uint16 offset) const {
SegmentRef Script::dereference(reg_t pointer) {
if (pointer.offset > _bufSize) {
warning("Script::dereference(): Attempt to dereference invalid pointer %04x:%04x into script segment (script size=%d)",
error("Script::dereference(): Attempt to dereference invalid pointer %04x:%04x into script segment (script size=%d)",
PRINT_REG(pointer), (uint)_bufSize);
return SegmentRef();
}

View File

@ -802,6 +802,7 @@ public:
byte getType() const { return _type; }
uint32 getSize() const { return _size; }
T *getRawData() { return _data; }
const T *getRawData()const { return _data; }
protected:
int8 _type;