File: romdiff.c

package info (click to toggle)
aranym 0.9.4beta2-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 7,468 kB
  • ctags: 15,193
  • sloc: cpp: 69,881; ansic: 28,236; sh: 3,470; asm: 1,818; makefile: 706; perl: 492; objc: 225
file content (51 lines) | stat: -rw-r--r-- 965 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <stdio.h>

int main(int argc, char **argv)
{
	char *n1, *n2;
	FILE *f1, *f2;
	unsigned long ptr;
	if (argc != 3) {
		fprintf(stderr, "Usage: %s file1 file2\n", argv[0]);
		return 1;
	}

	n1 = argv[1];
	n2 = argv[2];
	f1 = fopen(n1, "rb");
	if (f1 == NULL) {
		fprintf(stderr, "Error opening '%s'\n", n1);
		return 2;
	}
	f2 = fopen(n2, "rb");
	if (f2 == NULL) {
		fprintf(stderr, "Error opening '%s'\n", n2);
		fclose(f1);
		return 3;
	}

	ptr = 0;
	printf("\
/*\n\
 * This is the list of neccessary changes in the form <offset, value>\n\
 * for patching the original TOS 4.04 for 68040 compatibility.\n\
 *\n\
 * Autogenerated by tools/romdiff.c tool\n\
 */\n\
\n\
#include \"romdiff.h\"\n\
\n");
	printf("ROMdiff tosdiff[] = {\n");
	while(!feof(f1) && !feof(f2)) {
		unsigned char c1, c2;
		c1 = fgetc(f1);
		c2 = fgetc(f2);
		if (c1 != c2)
			printf("\t{0x%lx, 0x%02x},\n", ptr, c2);
		ptr++;
	}
	printf("\t{-1, 0}\n};\n");

	fclose(f1);
	fclose(f2);
}