commit 534e82f706cc261579d1a2c065202c5b8db596e5 Author: kou029w Date: Tue Aug 28 21:40:32 2012 +0900 profile.cを追加 diff --git a/c/profile.c b/c/profile.c new file mode 100644 index 0000000..bba749e --- /dev/null +++ b/c/profile.c @@ -0,0 +1,54 @@ +/* profile.c +Windows版、Mac版の洞窟物語のセーブデータ(Profile.dat)を相互に変換する +(C)2012 kou029w - MIT License +*/ + +#include +#include + +uint16_t swab2(uint16_t x) { + return ((x << 8) | (x >> 8)); +} + +uint32_t swab4(uint32_t x){ + return ((swab2(x) << 16) | swab2(x >> 16)); +} + +int profile(char *filename){ + FILE *fp; + unsigned char bufc[8]; + unsigned short bufs[8]; + unsigned int bufi[123]; + int i; + size_t size; + fp = fopen(filename, "rb"); + if(fp == NULL) return 1; + size = fread(bufc, sizeof(unsigned char), 8, fp); + fwrite(bufc, sizeof(unsigned char), size, stdout); + size = fread(bufi, sizeof(unsigned int), 5, fp); + for(i=0; i 1){ + return profile(argv[1]); + } + return 0; +}