#include #include void display(int x, int typ) { static char *chr[8]={"Ryu", "Nina", "Garr", "Teepo", "Rei", "Momo", "Peco", "Whelp"}; static char *elem[16]={"Flame", "Frost", "Electric", "Earth", "Wind", "Holy", "Mind", "StatChg", "Death", "Learnable", "Silencable", "2048", "4096", "8192", "16384", "32768"}; int a; printf(" -"); if(!typ) { for(a=0;a<8;a++) if(x & (1 << a)) printf(" %s", chr[a]); } else { for(a=0;a<16;a++) if(x & (1 << a)) printf(" %s", elem[a]); } printf("\n"); } void disp_bits(int x) { int a; for(a=15;a>=0;a--) printf("%d", (x & (1 << a))?1:0); } void convert(char *str, int len) { unsigned char *s=str; while(*s && (!len || (char *)s-str < len)) { switch(*s) { case 0x3A: *s='('; break; case 0x3B: *s=')'; break; case 0x3C: *s=','; break; case 0x3D: *s='-'; break; case 0x3E: *s='.'; break; case 0x3F: *s='/'; break; case 0x40: *s='='; break; case 0x5C: *s='?'; break; case 0x5D: *s='!'; break; case 0x81: *s='x'; break; case 0x8B: *s='+'; break; case 0x8D: *s='&'; break; case 0x8E: *s='\''; break; case 0x8F: *s=':'; break; case 0x91: *s=';'; break; case 0x93: *s='%'; break; case 0xFF: *s=' '; break; } s++; } } /* reads string with terminating NULL from file */ char *getstring_noalloc(f) FILE *f; { static char buf[8192]; int a=0; while((buf[a]=getc(f))) if(++a >= 7999) break; convert(buf, 0); buf[7999]=0; return buf; } main() { FILE *f=fopen("afldkwa.emi", "r"); unsigned char buf[512]; char desc[512][512]; int a, pos, item; /* read title descriptions */ for(a=0;a<307;a++) { fseek(f, 0x808+a*2, SEEK_SET); fread(&pos, 2, 1, f); fseek(f, 0x808+pos, SEEK_SET); strncpy(desc[a], getstring_noalloc(f), 511); desc[a][511]='\0'; printf("%3d: %s\n", a, desc[a]); } printf("\n"); /* read item descriptions */ for(a=0;a<454;a++) { fseek(f, 0x1e94+a*2, SEEK_SET); fread(&pos, 2, 1, f); fseek(f, 0x1e94+pos, SEEK_SET); strncpy(desc[a], getstring_noalloc(f), 511); desc[a][511]='\0'; printf("%3d: %s\n", a, desc[a]); } fclose(f); printf("\n"); f=fopen("items", "r"); for(a=0;a<92;a++) { fread(buf, 18, 1, f); convert(buf, 12); item=(buf[15]-64)*256+buf[14]; printf("%3d: %-12.12s", a, buf); printf(" %-3d %-3d <%-3d> %-5d: %s\n", buf[12], buf[13], item, (buf[17]*256)+buf[16], desc[item]); } for(a=0;a<16;a++) { fread(buf, 16, 1, f); convert(buf, 12); item=(buf[13]-64)*256+buf[12]; printf("%3d: %-12.12s", a+128, buf); printf(" <%-3d> %-5d: %s\n", item, (buf[15]*256)+buf[14], desc[item]); } for(a=0;a<83;a++) { fread(buf, 24, 1, f); convert(buf, 12); item=(buf[21]-64)*256+buf[20]; printf("%3d: %-12.12s", a+256, buf); printf(" %-3d %-3d %-3d %-3d %-3d %-3d %-3d %-3d <%-3d> %-5d : %-34.34s", buf[12], buf[13], buf[14], buf[15], buf[16], buf[17], buf[18], buf[19], item, (buf[23]*256)+buf[22], desc[item]); display(buf[12], 0); } for(a=0;a<68;a++) { fread(buf, 22, 1, f); convert(buf, 12); item=(buf[19]-64)*256+buf[18]; printf("%3d: %-12.12s", a+512, buf); printf(" %-3d %-3d %-3d %-3d %-3d %-3d <%-3d> %-5d : %-34.34s", buf[12], buf[13], buf[14], buf[15], buf[16], buf[17], item, (buf[21]*256)+buf[20], desc[item]); display(buf[12], 0); } for(a=0;a<52;a++) { fread(buf, 20, 1, f); convert(buf, 12); item=(buf[17]-64)*256+buf[16]; printf("%3d: %-12.12s", a+768, buf); printf(" %-3d %-3d %-3d %-3d <%-3d> %-5d : %-34.34s", buf[12], buf[13], buf[14], buf[15], item, (buf[19]*256)+buf[18], desc[item]); display(buf[12], 0); } printf("\n -- Spells --\n\n"); fseek(f, 0x1da8, SEEK_SET); for(a=0;a<228;a++) { fread(buf, 20, 1, f); convert(buf, 12); item=(buf[19]-64)*256+buf[18]; printf("%3d: %-12.12s ", a, buf); disp_bits(buf[13]*256+buf[12]); printf(" %-3d %-3d %-5d <%3d> : %-34.34s", buf[14], (signed char)buf[15], buf[17]*256+buf[16], item, desc[item]); display(buf[17]*256+buf[16], 1); } }