diff options
| author | Alex Marshall <SquidMan72@gmail.com> | 2009-02-12 22:11:50 -0800 |
|---|---|---|
| committer | Alex Marshall <SquidMan72@gmail.com> | 2009-02-12 22:11:50 -0800 |
| commit | 1765efe7e1cdef59716aea343e1e6f06b336e785 (patch) | |
| tree | bfb5836b507788e57aeda4d851ac3ef9afd57c19 | |
| parent | 8c827306811e08a719cd3376d1cce6b3a96d3202 (diff) | |
Updated animtypes (a little bit) made brlan.c not spit out useless info, updated some info on pai1, and made code less RLPA biased (which is retarded). All changes were only on C files.
Diffstat (limited to '')
| -rw-r--r-- | animtypes.txt | 2 | ||||
| -rw-r--r-- | brlan.c | 199 | ||||
| -rwxr-xr-x | brlan.h | 55 | ||||
| -rwxr-xr-x | types.h | 2 |
4 files changed, 149 insertions, 109 deletions
diff --git a/animtypes.txt b/animtypes.txt index b77cfdc..a059f83 100644 --- a/animtypes.txt +++ b/animtypes.txt @@ -2,7 +2,7 @@ RLPA 0 translateX 1 translateY 2 translateZ -3 pane_unk1 +3 pane_unk1 (Related to Alpha? See GH3 banner) 4 pane_unk2 5 angle 6 xmag @@ -22,7 +22,9 @@ #define dbgprintf // #endif //DEBUGBRLAN -char RLPA_FourCC[] = "RLPA"; +fourcc tag_FourCCs[] = { "RLPA", "RLTS", "RLVI", "RLVC", "RLMC", "RLTP" }; + +char RLPA_Types[15][24]; static size_t BRLAN_fileoffset = 0; @@ -48,8 +50,10 @@ static void CreateGlobal_pai1(brlan_pai1_header_type2 *pai1_header, brlan_pai1_h pai1_header->magic[2] = pai1_header1.magic[2]; pai1_header->magic[3] = pai1_header1.magic[3]; pai1_header->size = pai1_header1.size; - pai1_header->unk1 = pai1_header1.unk1; + pai1_header->framesize = pai1_header1.framesize; pai1_header->flags = pai1_header1.flags; + pai1_header->unk1 = pai1_header1.unk1; + pai1_header->num_timgs = pai1_header1.num_timgs; pai1_header->num_entries = pai1_header1.num_entries; pai1_header->unk2 = 0; pai1_header->entry_offset = pai1_header1.entry_offset; @@ -57,29 +61,15 @@ static void CreateGlobal_pai1(brlan_pai1_header_type2 *pai1_header, brlan_pai1_h memcpy(pai1_header, &pai1_header2, sizeof(brlan_pai1_header_type2)); } -static void DisplayRLPAData(u32 flags, RLPA_data data) +static void DisplayTagData(u32 flags, tag_data data, int z) { u32 p1 = be32(data.part1); u32 p2 = be32(data.part2); u32 p3 = be32(data.part3); -// if((flags & (1 << 9)) >= 1) - printf(" Coordinate 1: %f\n", *(f32*)(&p1)); -// else if((flags & (1 << 17)) >= 1) -// printf(" Coordinate 1: %f\n", *(f32*)(&p1)); -// else -// printf(" Part 1: %08x\n", p1); -// if((flags & (1 << 16)) >= 1) - printf(" Coordinate 2: %f\n", *(f32*)(&p2)); -// else if((flags & (1 << 17)) >= 1) -// printf(" Coordinate 2: %f\n", *(f32*)(&p2)); -// else -// printf(" Part 2: %08x\n", p2); -// if((flags & (1 << 16)) >= 1) - printf(" Coordinate 3: %f\n", *(f32*)(&p3)); -// else if((flags & (1 << 17)) >= 1) -// printf(" Coordinate 3: %f\n", *(f32*)(&p3)); -// else -// printf(" Part 3: %08x\n", p3); + printf(" Triplet %d:\n", z); + printf(" Frame number: %f\n", *(f32*)(&p1)); + printf(" Value: %f\n", *(f32*)(&p2)); + printf(" Interpolation Value: %f\n", *(f32*)(&p3)); } static int FourCCsMatch(fourcc cc1, fourcc cc2) @@ -90,69 +80,84 @@ static int FourCCsMatch(fourcc cc1, fourcc cc2) return 0; } -static void DisplayRLPAInformation(int idx, RLPA_header* heads, RLPA_entry** entriesx, - RLPA_entryinfo** entryinfosx, RLPA_data*** datasxx) +static int FourCCInList(fourcc cc) +{ + int i; + for(i = 0; i < 6; i++) + if(FourCCsMatch(cc, tag_FourCCs[i])) return 1; + return 0; +} + +static void DisplayTagInformation(int idx, tag_header* heads, tag_entry** entriesx, + tag_entryinfo** entryinfosx, tag_data*** datasxx) { - RLPA_header head = heads[idx]; - RLPA_entry* entries = entriesx[idx]; - RLPA_entryinfo* entryinfos = entryinfosx[idx]; - RLPA_data** datas = datasxx[idx]; + tag_header head = heads[idx]; + tag_entry* entries = entriesx[idx]; + tag_entryinfo* entryinfos = entryinfosx[idx]; + tag_data** datas = datasxx[idx]; - printf(" Magic: %c%c%c%c\n", head.magic[0], head.magic[1], head.magic[2], head.magic[3]); printf(" Number of entries: %u\n", head.entry_count); - printf(" Unk1: %02x\n", head.pad1); + +// Why should we show padding? It's 0 every single time. +/* printf(" Unk1: %02x\n", head.pad1); printf(" Unk2: %02x\n", head.pad2); - printf(" Unk3: %02x\n", head.pad3); + printf(" Unk3: %02x\n", head.pad3); */ + int i, z; printf(" Entries:\n"); for(i = 0; i < head.entry_count; i++) { - printf(" Index: %u\n", i); + printf(" Entry %u:\n", i); + if(FourCCsMatch(head.magic, tag_FourCCs[0]) == 1) + printf(" Type: %s\n", RLPA_Types[i]); printf(" Offset: %lu\n", be32(entries[i].offset)); printf(" Flags: %08x\n", be32(entryinfos[i].flags)); - printf(" Unk1: %04x\n", be16(entryinfos[i].pad1)); - printf(" Unk2: %08x\n", be32(entryinfos[i].unk1)); - printf(" Data Count: %u\n", be16(entryinfos[i].coord_count)); + +// Yet again, these are always the same, and seem to maybe be some marker. don't bother to show. +/* printf(" Unk1: %04x\n", be16(entryinfos[i].pad1)); + printf(" Unk2: %08x\n", be32(entryinfos[i].unk1)); */ + printf(" Triplet Count: %u\n", be16(entryinfos[i].coord_count)); + printf(" Triplets:\n"); for(z = 0; z < be16(entryinfos[i].coord_count); z++) - DisplayRLPAData(be32(entryinfos[i].flags), datas[i][z]); + DisplayTagData(be32(entryinfos[i].flags), datas[i][z], z); } } -static void ReadRLPAFromBRLAN(int idx, u8* brlan_file, RLPA_header *head, RLPA_entry** entries, - RLPA_entryinfo** entryinfo, RLPA_data*** data) +static void ReadTagFromBRLAN(int idx, u8* brlan_file, tag_header *head, tag_entry** entries, + tag_entryinfo** entryinfo, tag_data*** data) { - int rlpahead_location = BRLAN_fileoffset; - BRLAN_ReadDataFromMemory(&head[idx], brlan_file, sizeof(RLPA_header)); + int taghead_location = BRLAN_fileoffset; + BRLAN_ReadDataFromMemory(&head[idx], brlan_file, sizeof(tag_header)); dbgprintf("read header. entry count %d\n", head[idx].entry_count); int i, z; - entries[idx] = realloc(entries[idx], sizeof(RLPA_entry) * head[idx].entry_count); + entries[idx] = realloc(entries[idx], sizeof(tag_entry) * head[idx].entry_count); dbgprintf("reallocated entries[idx]\n"); - entryinfo[idx] = realloc(entryinfo[idx], sizeof(RLPA_entryinfo) * head[idx].entry_count); + entryinfo[idx] = realloc(entryinfo[idx], sizeof(tag_entryinfo) * head[idx].entry_count); dbgprintf("reallocated entryinfo[idx]\n"); if(data[idx] == NULL) { dbgprintf("callocating data[idx]\n"); - data[idx] = (RLPA_data**)malloc(sizeof(RLPA_data*) * head[idx].entry_count); + data[idx] = (tag_data**)malloc(sizeof(tag_data*) * head[idx].entry_count); dbgprintf("callocated data[idx]\n"); }else{ dbgprintf("reallocating data[idx] %08x\n", data[idx]); - data[idx] = (RLPA_data**)realloc(data[idx], sizeof(RLPA_data*) * head[idx].entry_count); + data[idx] = (tag_data**)realloc(data[idx], sizeof(tag_data*) * head[idx].entry_count); dbgprintf("reallocated data[idx]\n"); } for(i = 0; i < head[idx].entry_count; i++) { dbgprintf("reading entry %d 0x%08x\n", i, &entries[idx][i]); - BRLAN_ReadDataFromMemory(&entries[idx][i], brlan_file, sizeof(RLPA_entry)); + BRLAN_ReadDataFromMemory(&entries[idx][i], brlan_file, sizeof(tag_entry)); dbgprintf("read entry.\n"); } for(i = 0; i < head[idx].entry_count; i++) { dbgprintf("i %d cnt %d\n", i, head[idx].entry_count); - BRLAN_fileoffset = be32(entries[idx][i].offset) + rlpahead_location; + BRLAN_fileoffset = be32(entries[idx][i].offset) + taghead_location; dbgprintf("read entry infos. 0x%08x\n", &entryinfo[idx][i]); - BRLAN_ReadDataFromMemory(&entryinfo[idx][i], brlan_file, sizeof(RLPA_entryinfo)); + BRLAN_ReadDataFromMemory(&entryinfo[idx][i], brlan_file, sizeof(tag_entryinfo)); dbgprintf("read entry info 0x%08x. %u\n", &data[idx][i][0], be16(entryinfo[idx][i].coord_count)); - data[idx][i] = realloc(NULL, sizeof(RLPA_data) * be16(entryinfo[idx][i].coord_count)); + data[idx][i] = realloc(NULL, sizeof(tag_data) * be16(entryinfo[idx][i].coord_count)); dbgprintf("reallocated data[i].\n"); for(z = 0; z < be16(entryinfo[idx][i].coord_count); z++) { dbgprintf("reading data 0x%08x\n", &data[idx][i][z]); - BRLAN_ReadDataFromMemory(&data[idx][i][z], brlan_file, sizeof(RLPA_data)); + BRLAN_ReadDataFromMemory(&data[idx][i][z], brlan_file, sizeof(tag_data)); dbgprintf("read data.\n"); } } @@ -165,6 +170,22 @@ void parse_brlan(char* filename) printf("Error! Couldn't open %s!\n", filename); exit(1); } + strcpy(RLPA_Types[0], "X Translation"); + strcpy(RLPA_Types[1], "Y Translation"); + strcpy(RLPA_Types[2], "Z Translation"); + strcpy(RLPA_Types[3], "Unknown (Alpha?) (0x03)"); + strcpy(RLPA_Types[4], "Unknown (0x04)"); + strcpy(RLPA_Types[5], "Angle"); + strcpy(RLPA_Types[6], "X Zoom"); + strcpy(RLPA_Types[7], "Y Zoom"); + strcpy(RLPA_Types[8], "Width"); + strcpy(RLPA_Types[9], "Height"); + strcpy(RLPA_Types[10], "Unknown (0x0A)"); + strcpy(RLPA_Types[11], "Unknown (0x0B)"); + strcpy(RLPA_Types[12], "Unknown (0x0C)"); + strcpy(RLPA_Types[13], "Unknown (0x0D)"); + strcpy(RLPA_Types[14], "Unknown (0x0E)"); + strcpy(RLPA_Types[15], "Unknown (0x0F)"); fseek(fp, 0, SEEK_END); int file_size = ftell(fp); dbgprintf("Filesize is %d\n", file_size); @@ -210,15 +231,15 @@ void parse_brlan(char* filename) dbgprintf("read tag locations.\n"); brlan_entry *tag_entries = (brlan_entry*)calloc(tagcount, sizeof(brlan_entry)); dbgprintf("tag entries allocated.\n"); - RLPA_header *RLPA_heads = NULL; - dbgprintf("rlpa heads created.\n"); - RLPA_entry **RLPA_entries = NULL; - dbgprintf("rlpa entries created.\n"); - RLPA_entryinfo **RLPA_entryinfos = NULL; + tag_header *intag_heads = NULL; + dbgprintf("tag heads created.\n"); + tag_entry **intag_entries = NULL; + dbgprintf("tag entries created.\n"); + tag_entryinfo **intag_entryinfos = NULL; dbgprintf("rlpa entry infos created.\n"); - RLPA_data ***RLPA_datas = NULL; + tag_data ***intag_datas = NULL; dbgprintf("rlpa datas created.\n"); - int RLPA_cnt = 1; + int intag_cnt = 1; int i; for(i = 0; i < tagcount; i++) { BRLAN_fileoffset = be32(taglocations[i]) + be16(header.pai1_offset); @@ -233,35 +254,35 @@ void parse_brlan(char* filename) BRLAN_ReadDataFromMemoryX(magick, brlan_file, 4); memcpy(CCs[i], magick, 4); dbgprintf("read fourcc from %04x %02x%02x%02x%02x.\n", BRLAN_fileoffset, magick[0], magick[1], magick[2], magick[3]); - if(FourCCsMatch(RLPA_FourCC, CCs[i]) == 1) { - dbgprintf("we found a rlpa.\n"); - RLPA_heads = realloc(RLPA_heads, sizeof(RLPA_header) * RLPA_cnt); - dbgprintf("reallocated rlpa heads.\n"); - RLPA_entries = realloc(RLPA_entries, sizeof(RLPA_entry) * RLPA_cnt * 20); - dbgprintf("reallocated rlpa entries.\n"); - RLPA_entryinfos = realloc(RLPA_entryinfos, sizeof(RLPA_entryinfo) * RLPA_cnt * 20); - dbgprintf("reallocated rlpa entryinfos.\n"); - RLPA_datas = realloc(RLPA_datas, sizeof(RLPA_data) * RLPA_cnt * 20 * 6); - dbgprintf("reallocated rlpa datas.\n"); - if(RLPA_heads == NULL) { + if(FourCCInList(CCs[i]) == 1) { + dbgprintf("we found a tag.\n"); + intag_heads = realloc(intag_heads, sizeof(tag_header) * intag_cnt); + dbgprintf("reallocated tag heads.\n"); + intag_entries = realloc(intag_entries, sizeof(tag_entry) * intag_cnt * 20); + dbgprintf("reallocated tag entries.\n"); + intag_entryinfos = realloc(intag_entryinfos, sizeof(tag_entryinfo) * intag_cnt * 20); + dbgprintf("reallocated tag entryinfos.\n"); + intag_datas = realloc(intag_datas, sizeof(tag_data) * intag_cnt * 20 * 6); + dbgprintf("reallocated tag datas.\n"); + if(intag_heads == NULL) { printf("Error allocating heads.\n"); exit(2); } - if(RLPA_entries == NULL) { + if(intag_entries == NULL) { printf("Error allocating entries.\n"); exit(2); } - if(RLPA_entryinfos == NULL) { + if(intag_entryinfos == NULL) { printf("Error allocating entryinfos.\n"); exit(2); } - if(RLPA_datas == NULL) { + if(intag_datas == NULL) { printf("Error allocating datas.\n"); exit(2); } - ReadRLPAFromBRLAN(RLPA_cnt - 1, brlan_file, RLPA_heads, RLPA_entries, - RLPA_entryinfos, RLPA_datas); - RLPA_cnt++; + ReadTagFromBRLAN(intag_cnt - 1, brlan_file, intag_heads, intag_entries, + intag_entryinfos, intag_datas); + intag_cnt++; } dbgprintf("looping.\n"); } @@ -271,31 +292,39 @@ void parse_brlan(char* filename) printf(" Magic: %c%c%c%c\n", header.magic[0], header.magic[1], header.magic[2], header.magic[3]); printf(" Filesize: %lu\n", be32(header.file_size)); printf(" %s real file size!\n", be32(header.file_size) == file_size ? "Matches" : "Does not match"); - printf(" pai1 Offset: %04x\n", be16(header.pai1_offset)); - printf(" pai1 Count: %04x\n", be16(header.pai1_count)); + +// Not important to user, why bother. +/* printf(" pai1 Offset: %04x\n", be16(header.pai1_offset)); + printf(" pai1 Count: %04x\n", be16(header.pai1_count)); */ printf("\npai1 header:\n"); printf(" Type: %d\n", pai1_header_type); printf(" Magic: %c%c%c%c\n", pai1_header.magic[0], pai1_header.magic[1], pai1_header.magic[2], pai1_header.magic[3]); printf(" Size: %lu\n", be32(pai1_header.size)); - printf(" unk1: %08lx\n", be32(pai1_header.unk1)); - printf(" Flags: %04x\n", be16(pai1_header.flags)); + printf(" Framesize: %u\n", be16(pai1_header.framesize)); + printf(" Flags: %02x\n", pai1_header.flags); + printf(" unk1: %02x\n", pai1_header.unk1); + printf(" Number of Textures: %u\n", be16(pai1_header.num_timgs)); printf(" Number of Entries: %u\n", be16(pai1_header.num_entries)); printf(" unk2: %08lx\n", be32(pai1_header.unk2)); - printf(" Offset to Entries: 0x%08lx\n", be32(pai1_header.entry_offset)); + +// Not important to user, why bother. +// printf(" Offset to Entries: 0x%08lx\n", be32(pai1_header.entry_offset)); + printf("\nBRLAN entries:"); - RLPA_cnt = 0; + intag_cnt = 0; for(i = 0; i < tagcount; i++) { - printf("\n Index: %u\n", i); + printf("\n Entry %u:\n", i); printf(" Name: %s\n", tag_entries[i].name); printf(" Flags: %08x\n", be32(tag_entries[i].flags)); - printf(" Animation Header Length: %lu\n", be32(tag_entries[i].anim_header_len)); +// Not important to user, why bother. +// printf(" Animation Header Length: %lu\n", be32(tag_entries[i].anim_header_len)); printf(" FourCC: %c%c%c%c\n", CCs[i][0], CCs[i][1], CCs[i][2], CCs[i][3]); - if(FourCCsMatch(RLPA_FourCC, CCs[i]) == 1) { - dbgprintf("found rlpa. cnt %d.\n", RLPA_cnt); - DisplayRLPAInformation(RLPA_cnt, RLPA_heads, RLPA_entries, RLPA_entryinfos, RLPA_datas); - RLPA_cnt++; + if(FourCCInList(CCs[i]) == 1) { + dbgprintf("found tag. cnt %d.\n", intag_cnt); + DisplayTagInformation(intag_cnt, intag_heads, intag_entries, intag_entryinfos, intag_datas); + intag_cnt++; }else{ - printf(" Sorry, this type is currently unsupported.\n"); + printf(" Sorry, this type is currently unknown.\n"); } } free(brlan_file); @@ -3,27 +3,32 @@ #include "types.h" -typedef char fourcc[4]; - typedef enum { - RLPA_ENTRY = 0 -} entry_type; + RLPA_ENTRY = 0, + RLTS_ENTRY = 1, + RLVI_ENTRY = 2, + RLVC_ENTRY = 3, + RLMC_ENTRY = 4, + RLTP_ENTRY = 5 +} brlan_entry_type; typedef struct { - char magic[4]; // "pai1" in ASCII. + fourcc magic; // "pai1" in ASCII. u32 size; // Size of section, which is rest of the file. (header.file_size - header.offset_pai1) - u32 unk1; // Unknown? - u16 flags; // Flags? + u16 framesize; // Framesize + u8 flags; // Flags + u8 unk1; // Unknown + u16 num_timgs; // Number of timgs? u16 num_entries; // Number of tags in the brlan. u32 unk2; // Only if bit 25 of flags is set. u32 entry_offset; // Offset to entries. (Relative to start of pai1 header.) -} pai1_header_type2; +} brlan_pai1_header_type2; typedef struct { - char magic[4]; // "RLAN" in ASCII. + fourcc magic; // "RLAN" in ASCII. u32 unk1; // Always 0xFEFF 0x0008. Possibly a versioning string. u32 file_size; // Size of whole file, including the header. u16 pai1_offset; // The offset to the pai1 header from the start of file. @@ -32,22 +37,26 @@ typedef struct typedef struct { - char magic[4]; // "pai1" in ASCII. + fourcc magic; // "pai1" in ASCII. u32 size; // Size of section, which is rest of the file. (header.file_size - header.offset_pai1) - u32 unk1; // Unknown - u16 flags; // Flags + u16 framesize; // Framesize + u8 flags; // Flags + u8 unk1; // Unknown + u16 num_timgs; // Number of timgs? u16 num_entries; // Number of tags in the brlan. -} pai1_universal; +} brlan_pai1_universal; typedef struct { - char magic[4]; // "pai1" in ASCII. + fourcc magic; // "pai1" in ASCII. u32 size; // Size of section, which is rest of the file. (header.file_size - header.offset_pai1) - u32 unk1; // Unknown? - u16 flags; // Flags? + u16 framesize; // Framesize + u8 flags; // Flags + u8 unk1; // Unknown + u16 num_timgs; // Number of timgs? u16 num_entries; // Number of tags in the brlan. u32 entry_offset; // Offset to entries. (Relative to start of pai1 header.) -} pai1_header_type1; +} brlan_pai1_header_type1; typedef struct { @@ -58,18 +67,18 @@ typedef struct typedef struct { - char magic[4]; // "RLPA" in ASCII + fourcc magic; u8 entry_count; // How many entries in this chunk. u8 pad1; // All cases I've seen is zero. u8 pad2; // All cases I've seen is zero. u8 pad3; // All cases I've seen is zero. -} RLPA_header; +} tag_header; typedef struct { u32 offset; // Offset to the data pointed to by this entry. // Relative to the start of the RLPA header. -} RLPA_entry; +} tag_entry; typedef struct { @@ -77,17 +86,17 @@ typedef struct u16 coord_count; // How many coordinates. u16 pad1; // All cases I've seen is zero. u32 unk1; // ??? In every case I've seen, it is \x00\x00\x00\x0C. -} RLPA_entryinfo; +} tag_entryinfo; typedef struct { // Bits not listed here are currently unknown. u32 part1; // If Bit 9 is set in flags, this is an f32, with a coordinate. (Bit 17 seems to act the same) u32 part2; // If Bit 16 is set in flags, this is an f32, with another coordinate. (Bit 17 seems to act the same) u32 part3; // With Bit 16 set in flags, this seems to be yet another coordinate. (Bit 17 seems to act the same) -} RLPA_data; - +} tag_data; +void parse_brlan(char* filename); @@ -13,4 +13,6 @@ typedef signed long long s64; typedef float f32; typedef double f64; +typedef char fourcc[4]; + #endif //__TYPEDEFS_H_ |
