[Scummvm-git-logs] scummvm-tools master -> dc5317b3b877ef8d9b743f0bacafad06773e0354
sev-
sev at scummvm.org
Mon Oct 19 21:40:49 UTC 2020
This automated email contains information about 3 new commits which have been
pushed to the 'scummvm-tools' repo located at https://github.com/scummvm/scummvm-tools .
Summary:
19460224a0 UTILS: Add hexdump()
b83f0444bb TOOLS: Futher work on Gob CD-i extractor
dc5317b3b8 TOOLS: Cleanup for extract_gob_cdi
Commit: 19460224a034877e6d352796cfa81c6fb386a52d
https://github.com/scummvm/scummvm-tools/commit/19460224a034877e6d352796cfa81c6fb386a52d
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-10-19T20:22:24+02:00
Commit Message:
UTILS: Add hexdump()
Changed paths:
common/util.cpp
common/util.h
diff --git a/common/util.cpp b/common/util.cpp
index 2b6a7a60c..6fa6d18a4 100644
--- a/common/util.cpp
+++ b/common/util.cpp
@@ -75,3 +75,55 @@ void notice(const char *s, ...) {
fprintf(stdout, "%s\n", buf);
}
+
+//
+// Print hexdump of the data passed in
+//
+void hexdump(const byte *data, int len, int bytesPerLine, int startOffset) {
+ assert(1 <= bytesPerLine && bytesPerLine <= 32);
+ int i;
+ byte c;
+ int offset = startOffset;
+ while (len >= bytesPerLine) {
+ printf("%06x: ", offset);
+ for (i = 0; i < bytesPerLine; i++) {
+ printf("%02x ", data[i]);
+ if (i % 4 == 3)
+ printf(" ");
+ }
+ printf(" |");
+ for (i = 0; i < bytesPerLine; i++) {
+ c = data[i];
+ if (c < 32 || c >= 127)
+ c = '.';
+ printf("%c", c);
+ }
+ printf("|\n");
+ data += bytesPerLine;
+ len -= bytesPerLine;
+ offset += bytesPerLine;
+ }
+
+ if (len <= 0)
+ return;
+
+ printf("%06x: ", offset);
+ for (i = 0; i < bytesPerLine; i++) {
+ if (i < len)
+ printf("%02x ", data[i]);
+ else
+ printf(" ");
+ if (i % 4 == 3)
+ printf(" ");
+ }
+ printf(" |");
+ for (i = 0; i < len; i++) {
+ c = data[i];
+ if (c < 32 || c >= 127)
+ c = '.';
+ printf("%c", c);
+ }
+ for (; i < bytesPerLine; i++)
+ printf(" ");
+ printf("|\n");
+}
diff --git a/common/util.h b/common/util.h
index 987c21bf9..42799be5a 100644
--- a/common/util.h
+++ b/common/util.h
@@ -116,4 +116,6 @@ void warning(const char *s, ...);
void debug(int level, const char *s, ...);
void notice(const char *s, ...);
+void hexdump(const byte * data, int len, int bytesPerLine = 16, int startOffset = 0);
+
#endif
Commit: b83f0444bb4e25c1c02aafa3daedfbcb2434b9d5
https://github.com/scummvm/scummvm-tools/commit/b83f0444bb4e25c1c02aafa3daedfbcb2434b9d5
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-10-19T20:22:37+02:00
Commit Message:
TOOLS: Futher work on Gob CD-i extractor
Changed paths:
Makefile.common
engines/gob/extract_gob_cdi.cpp
diff --git a/Makefile.common b/Makefile.common
index 2376704ff..1044af300 100644
--- a/Makefile.common
+++ b/Makefile.common
@@ -141,6 +141,10 @@ degob_OBJS := \
gob_loadcalc_OBJS := \
engines/gob/gob_loadcalc.o
+extract_gob_cdi_OBJS := \
+ engines/gob/extract_gob_cdi.o \
+ $(UTILS)
+
extract_mohawk_OBJS := \
engines/mohawk/archive.o \
engines/mohawk/extract_mohawk.o \
@@ -151,9 +155,6 @@ extract_ngi_OBJS := \
engines/ngi/extract_ngi.o \
$(UTILS)
-extract_gob_cdi_OBJS := \
- engines/gob/extract_gob_cdi.o
-
construct_mohawk_OBJS := \
engines/mohawk/construct_mohawk.o \
engines/mohawk/utils.o \
diff --git a/engines/gob/extract_gob_cdi.cpp b/engines/gob/extract_gob_cdi.cpp
index c5f4dbde5..c7cf5b99f 100644
--- a/engines/gob/extract_gob_cdi.cpp
+++ b/engines/gob/extract_gob_cdi.cpp
@@ -25,6 +25,7 @@
#include <string.h>
#include "common/scummsys.h"
+#include "common/util.h"
#define RAW_SECTOR_SIZE 2352
#define MIN(x, y) ((x) < (y) ? (x) : (y));
@@ -66,7 +67,7 @@ typedef struct {
} rtf_entry;
#include "common/pack-end.h"
-void fix_entry_endianess(rtf_entry* entry) {
+void fix_entry_endianess(rtf_entry *entry) {
Uint32 data;
#ifdef SCUMM_LITTLE_ENDIAN
data = entry->offset;
@@ -88,7 +89,7 @@ void fix_entry_endianess(rtf_entry* entry) {
#endif
}
-int isSectorMode2(sect_xa_f1* sect) {
+int isSectorMode2(sect_xa_f1 *sect) {
#ifdef SCUMM_LITTLE_ENDIAN
return (sect->subheader.datatype) & 0x0060 ? 1 : 0;
#else
@@ -97,29 +98,49 @@ int isSectorMode2(sect_xa_f1* sect) {
}
int main(int argc, char** argv) {
- FILE* src_raw;
- FILE* dst_file;
-
- Uint8 index[4096];
+ FILE *src_raw;
+ FILE *dst_file;
+ bool raw = false;
+ char *fname;
+ bool listOnly = false;
+ int sectorSize = 2048;
+
+ byte index[4096];
sect_xa_f1 sector;
- sect_xa_f2* sector_f2;
+ sect_xa_f2 *sector_f2;
- if (argc != 2) {
- fprintf(stdout, "Usage: %s <real-time-file>\n", argv[0]);
+ if (argc < 2) {
+ fprintf(stdout, "Usage: %s [-raw] [-list] <real-time-file>\n", argv[0]);
return -1;
}
- src_raw = fopen(argv[1], "rb");
+ for (int i = 1; i < argc; i++) {
+ if (!strcmp(argv[i], "-raw")) {
+ raw = true;
+ sectorSize = RAW_SECTOR_SIZE;
+ } else if (!strcmp(argv[i], "-list")) {
+ listOnly = true;
+ } else {
+ fname = argv[i];
+ }
+ }
+
+ src_raw = fopen(fname, "rb");
if (src_raw == NULL) {
perror(argv[1]);
return -1;
}
- // Read the index!
- fread(§or, sizeof(sect_xa_f1), 1, src_raw);
- memcpy((index + 0), &(sector.data), 2048);
- fread(§or, sizeof(sect_xa_f1), 1, src_raw);
- memcpy((index + 2048), &(sector.data), 2048);
+ if (raw) {
+ // Read the index!
+ fread(§or, sizeof(sect_xa_f1), 1, src_raw);
+ memcpy((index + 0), &(sector.data), 2048);
+ hexdump(index, 2048);
+ fread(§or, sizeof(sect_xa_f1), 1, src_raw);
+ memcpy((index + 2048), &(sector.data), 2048);
+ } else {
+ fread(index, 2048 * 2, 1, src_raw);
+ }
// Read entries
int entryNum = 0;
@@ -133,8 +154,11 @@ int main(int argc, char** argv) {
if (strcmp(idx_entry->filename, "DIRINFO") == 0) continue; // We are not interested in this
fprintf(stdout, "Entry: %s\n", idx_entry->filename);
- fprintf(stdout, "Begins at: %u RAW blocks.\n", idx_entry->offset);
- fprintf(stdout, "Size: ~%uKb\n\n", (idx_entry->size / 1024) + (idx_entry->size % 1024 ? 1 : 0));
+ fprintf(stdout, "Begins at: %u RAW blocks (0x%d -> 0x%d).\n", idx_entry->offset, idx_entry->offset * sectorSize, idx_entry->offset * RAW_SECTOR_SIZE);
+ fprintf(stdout, "Size: ~%uKb (%u bytes)\n\n", (idx_entry->size / 1024) + (idx_entry->size % 1024 ? 1 : 0), idx_entry->size);
+
+ if (listOnly)
+ continue;
Uint32 remaining_size = idx_entry->size;
@@ -145,21 +169,29 @@ int main(int argc, char** argv) {
}
// Get to the interesting sector.
- fseek(src_raw, idx_entry->offset * RAW_SECTOR_SIZE, SEEK_SET);
+ fseek(src_raw, idx_entry->offset * sectorSize, SEEK_SET);
while (remaining_size) {
- fread(§or, sizeof(sect_xa_f1), 1, src_raw);
+ if (raw) {
+ fread(§or, sizeof(sect_xa_f1), 1, src_raw);
- if (isSectorMode2(§or)) { // Mode 2 (2324b)
- Uint32 toRead = MIN(2324, remaining_size);
+ if (isSectorMode2(§or)) { // Mode 2 (2324b)
+ Uint32 toRead = MIN(2324, remaining_size);
- sector_f2 = (sect_xa_f2*)§or;
- fwrite(&(sector_f2->data), toRead, 1, dst_file);
+ sector_f2 = (sect_xa_f2*)§or;
+ fwrite(&(sector_f2->data), toRead, 1, dst_file);
- remaining_size -= toRead;
- }
- else { // Mode 1 (2048b)
+ remaining_size -= toRead;
+ } else { // Mode 1 (2048b)
+ Uint32 toRead = MIN(2048, remaining_size);
+
+ fwrite(&(sector.data), toRead, 1, dst_file);
+
+ remaining_size -= toRead;
+ }
+ } else {
Uint32 toRead = MIN(2048, remaining_size);
+ fread(&(sector.data), toRead, 1, src_raw);
fwrite(&(sector.data), toRead, 1, dst_file);
remaining_size -= toRead;
Commit: dc5317b3b877ef8d9b743f0bacafad06773e0354
https://github.com/scummvm/scummvm-tools/commit/dc5317b3b877ef8d9b743f0bacafad06773e0354
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-10-19T23:40:18+02:00
Commit Message:
TOOLS: Cleanup for extract_gob_cdi
Changed paths:
engines/gob/extract_gob_cdi.cpp
diff --git a/engines/gob/extract_gob_cdi.cpp b/engines/gob/extract_gob_cdi.cpp
index c7cf5b99f..b7aec6b15 100644
--- a/engines/gob/extract_gob_cdi.cpp
+++ b/engines/gob/extract_gob_cdi.cpp
@@ -100,25 +100,20 @@ int isSectorMode2(sect_xa_f1 *sect) {
int main(int argc, char** argv) {
FILE *src_raw;
FILE *dst_file;
- bool raw = false;
char *fname;
bool listOnly = false;
- int sectorSize = 2048;
byte index[4096];
sect_xa_f1 sector;
sect_xa_f2 *sector_f2;
if (argc < 2) {
- fprintf(stdout, "Usage: %s [-raw] [-list] <real-time-file>\n", argv[0]);
+ fprintf(stdout, "Usage: %s [-list] <real-time-file>\n", argv[0]);
return -1;
}
for (int i = 1; i < argc; i++) {
- if (!strcmp(argv[i], "-raw")) {
- raw = true;
- sectorSize = RAW_SECTOR_SIZE;
- } else if (!strcmp(argv[i], "-list")) {
+ if (!strcmp(argv[i], "-list")) {
listOnly = true;
} else {
fname = argv[i];
@@ -131,16 +126,12 @@ int main(int argc, char** argv) {
return -1;
}
- if (raw) {
- // Read the index!
- fread(§or, sizeof(sect_xa_f1), 1, src_raw);
- memcpy((index + 0), &(sector.data), 2048);
- hexdump(index, 2048);
- fread(§or, sizeof(sect_xa_f1), 1, src_raw);
- memcpy((index + 2048), &(sector.data), 2048);
- } else {
- fread(index, 2048 * 2, 1, src_raw);
- }
+ // Read the index!
+ fread(§or, sizeof(sect_xa_f1), 1, src_raw);
+ memcpy((index + 0), &(sector.data), 2048);
+ hexdump(index, 2048);
+ fread(§or, sizeof(sect_xa_f1), 1, src_raw);
+ memcpy((index + 2048), &(sector.data), 2048);
// Read entries
int entryNum = 0;
@@ -154,7 +145,7 @@ int main(int argc, char** argv) {
if (strcmp(idx_entry->filename, "DIRINFO") == 0) continue; // We are not interested in this
fprintf(stdout, "Entry: %s\n", idx_entry->filename);
- fprintf(stdout, "Begins at: %u RAW blocks (0x%d -> 0x%d).\n", idx_entry->offset, idx_entry->offset * sectorSize, idx_entry->offset * RAW_SECTOR_SIZE);
+ fprintf(stdout, "Begins at: %u RAW blocks (0x%x).\n", idx_entry->offset, idx_entry->offset * RAW_SECTOR_SIZE);
fprintf(stdout, "Size: ~%uKb (%u bytes)\n\n", (idx_entry->size / 1024) + (idx_entry->size % 1024 ? 1 : 0), idx_entry->size);
if (listOnly)
@@ -169,29 +160,20 @@ int main(int argc, char** argv) {
}
// Get to the interesting sector.
- fseek(src_raw, idx_entry->offset * sectorSize, SEEK_SET);
+ fseek(src_raw, idx_entry->offset * RAW_SECTOR_SIZE, SEEK_SET);
while (remaining_size) {
- if (raw) {
- fread(§or, sizeof(sect_xa_f1), 1, src_raw);
-
- if (isSectorMode2(§or)) { // Mode 2 (2324b)
- Uint32 toRead = MIN(2324, remaining_size);
+ fread(§or, sizeof(sect_xa_f1), 1, src_raw);
- sector_f2 = (sect_xa_f2*)§or;
- fwrite(&(sector_f2->data), toRead, 1, dst_file);
+ if (isSectorMode2(§or)) { // Mode 2 (2324b)
+ Uint32 toRead = MIN(2324, remaining_size);
- remaining_size -= toRead;
- } else { // Mode 1 (2048b)
- Uint32 toRead = MIN(2048, remaining_size);
+ sector_f2 = (sect_xa_f2*)§or;
+ fwrite(&(sector_f2->data), toRead, 1, dst_file);
- fwrite(&(sector.data), toRead, 1, dst_file);
-
- remaining_size -= toRead;
- }
- } else {
+ remaining_size -= toRead;
+ } else { // Mode 1 (2048b)
Uint32 toRead = MIN(2048, remaining_size);
- fread(&(sector.data), toRead, 1, src_raw);
fwrite(&(sector.data), toRead, 1, dst_file);
remaining_size -= toRead;
More information about the Scummvm-git-logs
mailing list