#include #include #include #include unsigned char enemy[256][136]={}; unsigned char item[820][24]={}; unsigned char desc[512][36]={}; unsigned char spell[228][21]={}; int prettyprint=0; 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"}; static char *field[8]={"Field", "Battle", "Player", "Cantsell", "All", "Opponent", "Select", "SwitchGroup"}; static char *cond[8]={"Regenerate", "Egg", "Paralyzed", "Silenced", "Blind", "Confused", "Asleep", "Poisoned"}; int a, b=0; if(!typ) { for(a=0;a<8;a++) if(x & (1 << a)) printf(" %s", chr[a]); } else if(typ == 1) { if(prettyprint) x &= 2047; for(a=0;a<16;a++) if(x & (1 << a)) printf(" %s", elem[a]); } else if(typ == 2) { if(prettyprint) x &= 11; for(a=0;a<8;a++) if(x & (1 << a)) printf(" %s", field[a]); } else { for(a=0;a<8;a++) if(x & (1 << a)) printf("%c%s", b++?' ':'(', cond[a]); if(b) printf(")"); } 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; } void init_database() { unsigned char special[]={7, 13, 30, 31, 34, 35, 38, 39, 40, 43, 62, 67, 82, 83, 84, 85, 88, 89, 90, 163, 184, 185, 186, 187, 190, 191, 192, 225, 0}; FILE *f; int a, num; short pos; unsigned char buf[136]; if(!(f=fopen("afldkwa.emi", "r"))) { perror("afldkwa.emi"); exit(1); } /* 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), 35); desc[a][35]='\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), 35); desc[a][35]='\0'; // printf("%3d: %s\n", a, desc[a]); } fclose(f); //printf("\n"); /* read enemy definitions */ if(!(f=fopen("enemy.db", "r"))) { perror("enemy.db"); exit(1); } while(fread(buf, 136, 1, f)) { num=buf[8]; convert(buf, 8); memcpy(enemy[num], buf, 136); } fclose(f); /* read item definitions */ f=fopen("game.emi", "r"); fseek(f, 0x33964, SEEK_SET); for(a=0;a<92;a++) { fread(item[a], 18, 1, f); convert(item[a], 12); } for(a=0;a<16;a++) { fread(item[a+128], 16, 1, f); convert(item[a+128], 12); } for(a=0;a<83;a++) { fread(item[a+256], 24, 1, f); convert(item[a+256], 12); } for(a=0;a<68;a++) { fread(item[a+512], 22, 1, f); convert(item[a+512], 12); } for(a=0;a<52;a++) { fread(item[a+768], 20, 1, f); convert(item[a+768], 12); } /* read spell definitions */ fseek(f, 0x3570c, SEEK_SET); for(a=0;a<228;a++) { fread(spell[a], 20, 1, f); convert(spell[a], 12); } fclose(f); /* set special spell flags */ for(a=0;special[a];a++) spell[special[a]][20]=1; } int main(int argc) { int a, b, c, d, stat[12]; if(argc > 1) prettyprint=1; init_database(); /* read in game values */ /* print items */ printf("\n______________________________________________________________________________\n\n" "Section 2: Usable Items, Vital Items, Weapons, Armor, Accessories\n\n"); printf(" Usable Items: ZENNY\n"); for(a=0;a<92;a++) { printf("%3d: %-12.12s %-5d : %-34.34s -", a, item[a], item[a][17]*256+item[a][16], desc[(item[a][15]-64)*256+item[a][14]]); display(item[a][12], 2); } printf("\n"); printf(" Vital Items: ZENNY\n"); for(a=128;a<144;a++) printf("%3d: %-12.12s %-5d : %-34.34s\n", a, item[a], item[a][15]*256+item[a][14], desc[(item[a][13]-64)*256+item[a][12]]); printf("\n"); printf(" Weapons: Pwr Wgt : ZENNY\n"); for(a=256;a<339;a++) { printf("%3d: %-12.12s %-3d %-3d : %-5d : %-34.34s -", a, item[a], item[a][18], item[a][16], item[a][23]*256+item[a][22], desc[(item[a][21]-64)*256+item[a][20]]); display(item[a][12], 0); } printf("\n"); printf(" Armor: Def Wgt : ZENNY\n"); for(a=512;a<580;a++) { printf("%3d: %-12.12s %-3d %-3d : %-5d : %-34.34s -", a, item[a], item[a][16], item[a][15], item[a][21]*256+item[a][20], desc[(item[a][19]-64)*256+item[a][18]]); display(item[a][12], 0); } printf("\n"); printf(" Option: Wgt : ZENNY\n"); for(a=768;a<820;a++) { printf("%3d: %-12.12s %-3d : %-5d : %-34.34s -", a, item[a], item[a][15], item[a][19]*256+item[a][18], desc[(item[a][17]-64)*256+item[a][16]]); display(item[a][12], 0); } printf("\n"); /* print spells */ printf("\n______________________________________________________________________________\n\n" "Section 3: Spells\n\n"); printf(" Spells: AP Power\n"); for(a=0;a<228;a++) { printf("%3d: %-12.12s %3d ", a, spell[a], spell[a][14]); if(spell[a][20]) { b=(signed char)spell[a][15]; printf("%+4d%%", b*2); } else printf("%4d ", spell[a][15]); printf(" : %-34.34s -", desc[(spell[a][19]-64)*256+spell[a][18]]); // disp_bits(spell[a][13]*256+spell[a][12]); display(spell[a][17]*256+spell[a][16], 1); } printf(" EXP ZENNY | HP AP | PWR DEF AGL INT\n"); for(a=0;a<256;a++) if(*enemy[a]) { printf("%3d: %-8.8s | %-5d %-5d | %-5d %-5d | %-3d %-3d %-3d %-3d", a, enemy[a], (enemy[a][19])*256+enemy[a][18], (enemy[a][17])*256+enemy[a][16], (enemy[a][33])*256+enemy[a][32], (enemy[a][35])*256+enemy[a][34], (enemy[a][37])*256+enemy[a][36], (enemy[a][39])*256+enemy[a][38], (enemy[a][41])*256+enemy[a][40], (enemy[a][43])*256+enemy[a][42]); printf(" Steal: %d-%-12.12s Win: %d-%-12.12s\n", enemy[a][46], item[enemy[a][45]*256+enemy[a][44]], enemy[a][50], item[enemy[a][49]*256+enemy[a][48]]); } for(a=0;a<256;a++) { if(!*enemy[a]) continue; printf("%3d. %-8.8s %s", a, enemy[a], (enemy[a][23]*256+enemy[a][22] == 65535)?"(Boss) ":""); display(enemy[a][129], 3); printf("\n LEVEL: %-5d HP: %-5d PWR: %-5d Steal: %-12.12s (%d)\n", enemy[a][21]*256+enemy[a][20], enemy[a][33]*256+enemy[a][32], enemy[a][37]*256+enemy[a][36], item[enemy[a][45]*256+enemy[a][44]], enemy[a][46]); printf(" ZENNY: %-5d AP: %-5d DEF: %-5d Win: %-12.12s (%d)\n", enemy[a][17]*256+enemy[a][16], enemy[a][35]*256+enemy[a][34], enemy[a][39]*256+enemy[a][38], item[enemy[a][49]*256+enemy[a][48]], enemy[a][50]); printf(" EXP: %-5d AGL: %d\n", enemy[a][19]*256+enemy[a][18], enemy[a][41]*256+enemy[a][40]); printf(" INT: %-5d Prot: Mind (%d), Status (%d), Death (%d)\n\n", enemy[a][43]*256+enemy[a][42], enemy[a][126], enemy[a][127], enemy[a][128]); /* determine elemental weaknesses & strengths */ stat[0]=stat[1]=stat[2]=stat[3]=0; for(b=120;b<126;b++) { if(enemy[a][b] < 2) stat[0] |= 1 << (b-120); else if(enemy[a][b] > 2 && enemy[a][b] < 6) stat[1] |= 1 << (b-120); else if(enemy[a][b] == 6) stat[2] |= 1 << (b-120); else if(enemy[a][b] == 7) stat[3] |= 1 << (b-120); } if(stat[0]) { printf(" WeakPt:"); display(stat[0], 1); } if(stat[1]) { printf(" Strong:"); display(stat[1], 1); } if(stat[2]) { printf(" No Dmg:"); display(stat[2], 1); } if(stat[3]) { printf(" Cure:"); display(stat[3], 1); } printf("\n"); for(c=0;c<12;c++) stat[c]=0; if(a >= 25 && a <= 30) printf(" No special attacks.\n\n"); else { for(c=0,b=24;b<116;b++) { if(b == 32) b+=28; else if(b > 60 && (b % 16) == 4) b+=8; if((b >= 60 && (b % 16) == 12) && enemy[a][b] == 1) { b+=7; continue; } if(b == 24 || (b >= 60 && (b % 16) == 12) && enemy[a][b] == 1) { b+=7; continue; } for(d=0;d