Browse Source

add xdump (dump .text data from an .X file as a C hex array)

vampirefrog 1 year ago
parent
commit
5ba7cb6054
2 changed files with 19 additions and 0 deletions
  1. 3
    0
      Makefile
  2. 16
    0
      xdump.c

+ 3
- 0
Makefile View File

@@ -18,6 +18,9 @@ v68: main.o tools.o v68.o v68ipl.o v68io.o v68periph.o v68human.o v68doscall.o v
18 18
 xinfo: xinfo.o md5.o cmdline.o
19 19
 	gcc $^ -o $@
20 20
 
21
+xdump: xdump.o tools.o
22
+	gcc $^ -o $@
23
+
21 24
 sjis2utf8: sjis2utf8.o sjis.o sjis_unicode.o utf8.o
22 25
 	gcc $^ -o $@
23 26
 

+ 16
- 0
xdump.c View File

@@ -0,0 +1,16 @@
1
+#include <stdio.h>
2
+#include "tools.h"
3
+
4
+int main(int argc, char **argv) {
5
+	size_t len = 0;
6
+	uint8_t *data = load_file(argv[1], &len);
7
+	#define READ_LONG(x) ((data[x] << 24) | (data[x + 1] << 16) | (data[x + 2] << 8) | data[x + 3])
8
+	uint32_t text_size = READ_LONG(0x0c);
9
+	for(int i = 0; i < text_size; i+=2) {
10
+		if(i % 16 == 0 && i > 0) printf("\n");
11
+		printf("0x%02x%02x, ", data[0x40 + i], data[0x41 + i]);
12
+	}
13
+	printf("\n");
14
+	free(data);
15
+	return 0;
16
+}

Loading…
Cancel
Save