diff --git a/components/tme/romhack/Makefile b/components/tme/romhack/Makefile new file mode 100644 index 0000000..44488cd --- /dev/null +++ b/components/tme/romhack/Makefile @@ -0,0 +1,7 @@ +OBJS=recalcchs.o +TARGET=recalcchs + +$(TARGET): $(OBJS) + $(CC) -o $(TARGET) $(OBJS) + + diff --git a/components/tme/romhack/recalcchs.c b/components/tme/romhack/recalcchs.c new file mode 100644 index 0000000..c357a27 --- /dev/null +++ b/components/tme/romhack/recalcchs.c @@ -0,0 +1,41 @@ +#include "stdio.h" +#include "stdint.h" +#include + +#define MAXROMSZ 3*1024*1024 + +int main(int argc, char **argv) { + FILE *f; + int l, x; + unsigned int oldchs, newchs; + unsigned char rom[MAXROMSZ]; + if (argc!=2) { + printf("Usage: %s mac-rom-image.bin\nRecalculate checksum on modified rom\n"); + exit(0); + } + + f=fopen(argv[1], "r+"); + if (f<=0) { + perror(argv[1]); + exit(1); + } + l=fread(rom, 1, MAXROMSZ, f); + + oldchs=(rom[0]<<24)+(rom[1]<<16)+(rom[2]<<8)+(rom[3]); + newchs=0; + for (x=4; x>24; + rom[1]=newchs>>16; + rom[2]=newchs>>8; + rom[3]=newchs>>0; + fseek(f, 0, SEEK_SET); + fwrite(rom, 4, 1, f); + } + fclose(f); +} \ No newline at end of file