[Scummvm-cvs-logs] CVS: scummex scummex.cpp,1.1.1.1,1.2
Adrien Mercier
yoshizf at users.sourceforge.net
Thu Sep 18 11:39:07 CEST 2003
Update of /cvsroot/scummvm/scummex
In directory sc8-pr-cvs1:/tmp/cvs-serv30478
Modified Files:
scummex.cpp
Log Message:
Replaced fileView by a better one copied from ScummVM's hexdump
Index: scummex.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummex/scummex.cpp,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- scummex.cpp 18 Sep 2003 16:26:55 -0000 1.1.1.1
+++ scummex.cpp 18 Sep 2003 18:37:46 -0000 1.2
@@ -115,45 +115,107 @@
}
void ScummEX::fileView() {
- int j = 0;
- uint32 i;
+ int j, i;
char *text;
+ char title[256];
char buf[256];
-
- text = (char *) malloc(4 * _blockTable[block_id].blockSize);
+ byte* data;
+ byte* dataorg;
+ int len, offset, nlines, bytes_per_line;
+ byte c;
- sprintf(text, "%s Block at offset %d", _blockTable[block_id].blockName, _blockTable[block_id].offset);
+ len = _blockTable[block_id].blockSize;
+ offset = _blockTable[block_id].offset;
+ bytes_per_line = 16;
+ nlines = len / bytes_per_line;
+
+ text = (char *) calloc(((16 + (3*bytes_per_line) + (bytes_per_line/4) + bytes_per_line) * nlines) + 256, 1);
+
+ if (text == NULL)
+ return;
+
+ sprintf(title, "%s Block at offset %d", _blockTable[block_id].blockName, _blockTable[block_id].offset);
- sprintf(text, " ");
-
_input.seek(_blockTable[block_id].offset, SEEK_SET);
-
- for (i=0; i<_blockTable[block_id].blockSize; i++) {
- byte c;
- c = _input.readByte();
-
- sprintf(buf, "%02X ", c);
-
+
+ dataorg = data = (byte*) malloc(_blockTable[block_id].blockSize);
+
+ if (data == NULL)
+ return;
+
+ _input.read(data, _blockTable[block_id].blockSize);
+
+ while (len >= bytes_per_line) {
+ sprintf(buf, "%06X: ", offset);
strcat(text, buf);
-
- if (j == 3 || j == 7 || j == 11) {
- sprintf(buf, " ");
+ for (i = 0; i < bytes_per_line; i++) {
+ sprintf(buf, "%02X ", data[i]);
+ strcat(text, buf);
+ if (i % 4 == 3) {
+ sprintf(buf, " ");
+ strcat(text, buf);
+ }
+ }
+ sprintf(buf, " |");
+ strcat(text, buf);
+ for (i = 0; i < bytes_per_line; i++) {
+ c = data[i];
+ if (c < 32 || c >= 127)
+ c = '.';
+ sprintf(buf, "%c", c);
strcat(text, buf);
}
+ sprintf(buf, "|\n");
+ strcat(text, buf);
+ data += bytes_per_line;
+ len -= bytes_per_line;
+ offset += bytes_per_line;
+ }
- if (j == 15) {
- sprintf(buf, "\n");
+ if (len <= 0)
+ return;
+
+ sprintf(buf, "%06X: ", offset);
+ strcat(text, buf);
+ for (i = 0; i < len; i++) {
+ sprintf(buf, "%02X ", data[i]);
+ strcat(text, buf);
+ if (i % 4 == 3) {
+ sprintf(buf, " ");
strcat(text, buf);
- j = 0;
- } else {
- j++;
}
}
+
+ for (; i < bytes_per_line; i++) {
+ sprintf(buf, " ");
+ strcat(text, buf);
+ if (i % 4 == 3) {
+ sprintf(buf, " ");
+ strcat(text, buf);
+ }
+ }
+ sprintf(buf, " |");
+ strcat(text, buf);
+ for (i = 0; i < len; i++) {
+ c = data[i];
+ if (c < 32 || c >= 127)
+ c = '.';
+ sprintf(buf, "%c", c);
+ strcat(text, buf);
+ }
+ for (; i < bytes_per_line; i++) {
+ sprintf(buf, " ");
+ strcat(text, buf);
+ }
+ sprintf(buf, "|\n");
strcat(text, buf);
- _gui->DisplayViewer("Block", 600, 400, text);
+ free(dataorg);
+
+ _gui->DisplayViewer(title, 660, 480, text);
free(text);
+
}
void ScummEX::iMUSEPlay()
More information about the Scummvm-git-logs
mailing list