Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * alytDumper.c
- * by Reisyukaku
- *
- * Dumps media from GameFreak's ALYT format.
- */
- #include <stdio.h>
- #include <stdint.h>
- #include <malloc.h>
- #include <string.h>
- typedef uint8_t u8;
- typedef uint16_t u16;
- typedef uint32_t u32;
- typedef struct{
- u32 magic;
- u32 unk;
- u32 *entries;
- } Lyt;
- typedef struct{
- u32 magic;
- u16 majorVer;
- u16 minorVer;
- u32 ltblOff;
- u32 ltblSize;
- u32 lmtlOff;
- u32 lmtlSize;
- u32 lfntOff;
- u32 lfntSize;
- u32 contOff;
- u32 contSize;
- Lyt *ltbl;
- Lyt *lmtl;
- Lyt *lfnt;
- } AlytHeader;
- int main(int argc, char **argv){
- if(argc != 2){
- printf("Usage: %s <alyt file>\n", argv[0]);
- return -1;
- }
- //Open file
- FILE *fp;
- size_t fileSize;
- fp = fopen(argv[1], "rb");
- if(!fp) {printf("File not found!\n"); return -1;}
- //Parse header
- AlytHeader alyt;
- fread(&alyt, 0x28, 1, fp);
- if(alyt.magic != 0x54594C41) {printf("Not a ALYT file!\n"); return -1;} //Magic ALYT
- alyt.ltbl = malloc(alyt.ltblSize);
- alyt.lmtl = malloc(alyt.lmtlSize);
- alyt.lfnt = malloc(alyt.lfntSize);
- //Parse tables
- fseek(fp, alyt.ltblOff, SEEK_SET);
- fread(alyt.ltbl, alyt.ltblSize, 1, fp);
- fseek(fp, alyt.lmtlOff, SEEK_SET);
- fread(alyt.lmtl, alyt.lmtlSize, 1, fp);
- fseek(fp, alyt.lfntOff, SEEK_SET);
- fread(alyt.lfnt, alyt.lfntSize, 1, fp);
- fseek(fp, alyt.contOff, SEEK_SET);
- //Read symbols table
- char string[0x40];
- u32 numOfEntries = 0, i;
- printf("ALYT Tool\n-----------\n");
- fread(&numOfEntries, sizeof(u32), 1, fp);
- printf("Symbol entries: %d [%08X]\n\n", numOfEntries, alyt.contOff);
- for(i = 0; i < numOfEntries; i++){
- fseek(fp, (alyt.contOff + 4) + (i*0x40), SEEK_SET);
- fread(string, sizeof(char), 0x40, fp);
- printf("%s\n", string);
- }
- u32 currPos = alyt.contOff + ((numOfEntries * 0x40)+4);
- fseek(fp, currPos, SEEK_SET);
- fread(&numOfEntries, sizeof(u32), 1, fp);
- printf("\nSymbol entries: %d [%08X]\n\n", numOfEntries, currPos);
- for(i = 0; i < numOfEntries; i++){
- fseek(fp, (currPos + 4) + (i*0x20), SEEK_SET);
- fread(string, sizeof(char), 0x20, fp);
- printf("%s\n", string);
- }
- //TODO
- //Free!
- free(alyt.ltbl);
- free(alyt.lmtl);
- free(alyt.lfnt);
- return 0;
- }
Add Comment
Please, Sign In to add comment