/* 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; }