Replaced sci_hexdump() with Common::hexdump()

svn-id: r40472
This commit is contained in:
Filippos Karapetis 2009-05-12 07:21:44 +00:00
parent 1b8c5f483f
commit 80254b79cc
4 changed files with 13 additions and 42 deletions

View file

@ -212,32 +212,6 @@ void script_map_selectors(EngineState *s, selector_map_t *map) {
FIND_SELECTOR(syncTime);
}
int sci_hexdump(byte *data, int length, int offsetplus) {
char tempstr[40];
int i;
for (i = 0; i < length; i += 8) {
int j;
sprintf(tempstr, "%04x: ", i + offsetplus);
for (j = 0; j < MIN(8, length - i); j++)
sprintf(tempstr + 6 + (j*3) + (j > 3), "%02x ", data[i+j]);
for (j = 0; j < MIN(8, length - i); j++) {
int thechar;
thechar = data[i+j];
sprintf(tempstr + 31 + j, "%c", ((thechar < ' ') || (thechar > 127)) ? '.' : thechar);
}
for (j = 0; j < 38; j++)
if (!tempstr[j])
tempstr[j] = ' '; // get rid of sprintf's \0s
sciprintf("%s\n", tempstr);
}
return 0;
}
static void script_dump_object(char *data, int seeker, int objsize, const Common::StringList &selectorNames) {
int selectors, overloads, selectorsize;
int species = (int16)READ_LE_UINT16((unsigned char *) data + 8 + seeker);
@ -247,7 +221,7 @@ static void script_dump_object(char *data, int seeker, int objsize, const Common
sciprintf("Object\n");
sci_hexdump((unsigned char *) data + seeker, objsize - 4, seeker);
Common::hexdump((unsigned char *) data + seeker, objsize - 4, 16, seeker);
//-4 because the size includes the two-word header
sciprintf("Name: %s\n", namepos ? ((char *)(data + namepos)) : "<unknown>");
@ -289,7 +263,7 @@ static void script_dump_class(char *data, int seeker, int objsize, const Common:
sciprintf("Class\n");
sci_hexdump((unsigned char *) data + seeker, objsize - 4, seeker);
Common::hexdump((unsigned char *) data + seeker, objsize - 4, 16, seeker);
sciprintf("Name: %s\n", namepos ? ((char *)data + namepos) : "<unknown>");
sciprintf("Superclass: %x\n", superclass);
@ -370,19 +344,19 @@ void script_dissect(ResourceManager *resmgr, int res_no, const Common::StringLis
case sci_obj_code: {
sciprintf("Code\n");
sci_hexdump(script->data + seeker, objsize - 4, seeker);
Common::hexdump(script->data + seeker, objsize - 4, 16, seeker);
};
break;
case 3: {
sciprintf("<unknown>\n");
sci_hexdump(script->data + seeker, objsize - 4, seeker);
Common::hexdump(script->data + seeker, objsize - 4, 16, seeker);
};
break;
case sci_obj_said: {
sciprintf("Said\n");
sci_hexdump(script->data + seeker, objsize - 4, seeker);
Common::hexdump(script->data + seeker, objsize - 4, 16, seeker);
sciprintf("%04x: ", seeker);
while (seeker < _seeker) {
@ -447,25 +421,25 @@ void script_dissect(ResourceManager *resmgr, int res_no, const Common::StringLis
case sci_obj_exports: {
sciprintf("Exports\n");
sci_hexdump((unsigned char *)script->data + seeker, objsize - 4, seeker);
Common::hexdump((unsigned char *)script->data + seeker, objsize - 4, 16, seeker);
};
break;
case sci_obj_pointers: {
sciprintf("Pointers\n");
sci_hexdump(script->data + seeker, objsize - 4, seeker);
Common::hexdump(script->data + seeker, objsize - 4, 16, seeker);
};
break;
case 9: {
sciprintf("<unknown>\n");
sci_hexdump(script->data + seeker, objsize - 4, seeker);
Common::hexdump(script->data + seeker, objsize - 4, 16, seeker);
};
break;
case sci_obj_localvars: {
sciprintf("Local vars\n");
sci_hexdump(script->data + seeker, objsize - 4, seeker);
Common::hexdump(script->data + seeker, objsize - 4, 16, seeker);
};
break;

View file

@ -912,7 +912,7 @@ static int c_dump(EngineState *s, const Common::Array<cmd_param_t> &cmdParams) {
else {
Resource *resource = s->resmgr->findResource(res, cmdParams[1].val, 0);
if (resource)
sci_hexdump(resource->data, resource->size, 0);
Common::hexdump(resource->data, resource->size, 16, 0);
else
sciprintf("Resource %s.%03d not found\n", cmdParams[0].str, cmdParams[1].val);
}

View file

@ -145,7 +145,7 @@ static void midi_hexdump(byte *data, int size, int notational_offset) { // Speci
fprintf(stderr, "Track broken at %x after"
" offset mod of %d\n",
offset + notational_offset, offset_mod);
sci_hexdump(data, size, notational_offset);
Common::hexdump(data, size, 16, notational_offset);
return;
}
fprintf(stderr, "(rs %02x) ", cmd);
@ -481,7 +481,7 @@ static void _c_single_seg_info(EngineState *s, MemObject *mobj) {
sciprintf("dynmem (%s): %d bytes\n",
(*(DynMem *)mobj)._description ? (*(DynMem *)mobj)._description : "no description", (*(DynMem *)mobj)._size);
sci_hexdump((*(DynMem *)mobj)._buf, (*(DynMem *)mobj)._size, 0);
Common::hexdump((*(DynMem *)mobj)._buf, (*(DynMem *)mobj)._size, 16, 0);
}
break;
@ -618,7 +618,7 @@ static int c_vr(EngineState *s, const Common::Array<cmd_param_t> &cmdParams) {
if (reg_end.segment != 0)
sciprintf("Block size less than or equal to %d\n", size);
sci_hexdump(block, size, 0);
Common::hexdump(block, size, 16, 0);
}
break;

View file

@ -148,9 +148,6 @@ int con_hook_int(int *pointer, const char *name, const char *description);
** The internal list of int references is used by some of the basic commands.
*/
int sci_hexdump(byte *data, int length, int offsetplus);
} // End of namespace Sci
#endif // SCI_SCICORE_SCICONSOLE_H