From 1fefc8ed20827dff12fcfa8928d7d0074f740641 Mon Sep 17 00:00:00 2001 From: megazig Date: Wed, 22 Apr 2009 00:53:28 -0500 Subject: fixed brlan.c for new struct --- brlan.c | 949 +++++++++++----------------------------------------------------- 1 file changed, 160 insertions(+), 789 deletions(-) diff --git a/brlan.c b/brlan.c index 85d2683..91557b5 100644 --- a/brlan.c +++ b/brlan.c @@ -87,6 +87,60 @@ static int FourCCInList(fourcc cc) return 0; } +void BRLAN_CreateXMLTag(tag_header tagHeader, void* data, u32 offset) +{ + BRLAN_fileoffset = offset; + BRLAN_ReadDataFromMemory(&tagHeader, data, sizeof(tag_header)); + + printf("\t\t\n", tagHeader.magic[0], tagHeader.magic[1], tagHeader.magic[2], tagHeader.magic[3]); + + tag_entryinfo tagEntryInfo; + u32 tagentrylocations[tagHeader.entry_count]; + BRLAN_ReadDataFromMemory(&tagentrylocations, data, tagHeader.entry_count * sizeof(u32)); + u32 i, j; + for ( i = 0; i < tagHeader.entry_count; i++) + { + BRLAN_fileoffset = offset + be32(tagentrylocations[i]); + BRLAN_ReadDataFromMemory(&tagEntryInfo, data, sizeof(tag_entryinfo)); + if(short_swap_bytes(tagEntryInfo.type) < 16) + printf("\t\t\t\n", tag_types_list[short_swap_bytes(tagEntryInfo.type)]); + else + printf("\t\t\t\n", short_swap_bytes(tagEntryInfo.type)); + + for( j = 0; j < short_swap_bytes(tagEntryInfo.coord_count); j++) + { + if ( tagEntryInfo.unk1 == 0x2 ) + { + tag_data tagData; + BRLAN_ReadDataFromMemory(&tagData, data, sizeof(tag_data)); + + u32 p1 = be32(tagData.part1); + u32 p2 = be32(tagData.part2); + u32 p3 = be32(tagData.part3); + printf("\t\t\t\t\n"); + printf("\t\t\t\t\t%.15f\n", *(f32*)(&p1)); + printf("\t\t\t\t\t%.15f\n", *(f32*)(&p2)); + printf("\t\t\t\t\t%.15f\n", *(f32*)(&p3)); + printf("\t\t\t\t\n"); + } else { + tag_data2 tagData2; + BRLAN_ReadDataFromMemory(&tagData2, data, sizeof(tag_data2)); + + u32 p1 = be32(tagData2.part1); + u16 p2 = short_swap_bytes(tagData2.part2); + u16 p3 = short_swap_bytes(tagData2.padding); + printf("\t\t\t\t\n"); + printf("\t\t\t\t\t%.15f\n", *(f32*)(&p1)); + printf("\t\t\t\t\t%04x\n", p2); + printf("\t\t\t\t\t%04x\n", p3); + printf("\t\t\t\t\n"); + } + } + printf("\t\t\t\n"); + } + printf("\t\t\n"); +} + void parse_brlan(char* filename) { FILE* fp = fopen(filename, "rb"); @@ -100,7 +154,7 @@ void parse_brlan(char* filename) u8 data[lengthOfFile]; fread(data, lengthOfFile, 1, fp); - int i; + int i, j; for(i = 0; i < 16; i++) memset(tag_types_list[i], 0, 24); strcpy(tag_types_list[0], "X Translation"); @@ -148,21 +202,19 @@ void parse_brlan(char* filename) "\n", (long unsigned int)short_swap_bytes(pai1_header.framesize), pai1_header.flags); int timgs = short_swap_bytes(pai1_header.num_timgs); -// printf("Number of TPL files: %d\n", timgs); BRLAN_fileoffset = short_swap_bytes(header.pai1_offset) + sizeof(brlan_pai1_header_type1); if ( pai1_header_type == 2 ) BRLAN_fileoffset += 4; int tableoff = BRLAN_fileoffset; int currtableoff = BRLAN_fileoffset; - for(i = 0; i < timgs; i++) { + for( i = 0; i < timgs; i++) { u32 curr_timg_off = 0; BRLAN_ReadDataFromMemory(&curr_timg_off, data, 4); char timgname[256]; memset(timgname, 0, 256); int z = tableoff + be32(curr_timg_off); - int o; - for(o = 0; data[z] != 0; timgname[o++] = data[z], z++); + for( j = 0; data[z] != 0; timgname[j++] = data[z], z++); printf("\t\n", timgname); currtableoff += 4; } @@ -172,8 +224,7 @@ void parse_brlan(char* filename) BRLAN_fileoffset = be32(pai1_header.entry_offset) + short_swap_bytes(header.pai1_offset); BRLAN_ReadDataFromMemory(taglocations, data, tagcount * sizeof(u32)); - for(i = 0; i < tagcount; i++) { - u8 isTriplet = 0; + for( i = 0; i < tagcount; i++) { brlan_entry brlanEntry; tag_header tagHeader; tag_entry tagEntry; @@ -182,300 +233,17 @@ void parse_brlan(char* filename) u32 brlanEntryOffset = BRLAN_fileoffset; BRLAN_ReadDataFromMemory(&brlanEntry, data, sizeof(brlan_entry)); - u32 offsetToExtras; - u32 offsetToOther; - if(((be32(brlanEntry.flags) & (1 << 24)) >= 1 ) && ((be32(brlanEntry.flags) & (1<<25)) >=1)) { - somethingElseIsSet = 1; - somethingIsSet = 1; - BRLAN_ReadDataFromMemory(&offsetToOther, data, 4); - BRLAN_ReadDataFromMemory(&offsetToExtras, data, 4); - }else if((be32(brlanEntry.flags) & (1 << 25)) >= 1) { - somethingIsSet = 1; - BRLAN_ReadDataFromMemory(&offsetToExtras, data, 4); - } - - if ((be32(brlanEntry.flags) | 0x00000000 ) == 0 ) - { - printf("\t\n", brlanEntry.name); - continue; - } - - if (somethingElseIsSet == 1) - { - BRLAN_ReadDataFromMemory(&tagHeader, data, sizeof(tag_header)); - printf("\t\n", be32(brlanEntry.flags)); - u32 startOfEntries = BRLAN_fileoffset; - u32 sOE = startOfEntries; - u32 j; - for(j=0;j\n", tag_types_list[short_swap_bytes(tagEntryInfo.type)]); - else - printf("\t\t\n", short_swap_bytes(tagEntryInfo.type)); - if ( tagEntryInfo.unk1 == short_swap_bytes(0x0200) ) isTriplet = 1; - int k; for(k=0;k\n"); - printf("\t\t\t\t%.15f\n", *(f32*)(&p1)); - printf("\t\t\t\t%.15f\n", *(f32*)(&p2)); - printf("\t\t\t\t%.15f\n", *(f32*)(&p3)); - printf("\t\t\t\n"); - - } else { - tag_data2 tagData2; - memcpy(&tagData2, &data[sOE -8+ be32(tagEntry.offset) + sizeof(tag_entryinfo)+ (k*sizeof(tag_data2))], sizeof(tag_data2)); - u32 p1 = be32(tagData2.part1); - u16 p2 = short_swap_bytes(tagData2.part2); - u16 p3 = short_swap_bytes(tagData2.padding); - printf("\t\t\t\n"); - printf("\t\t\t\t%.15f\n", *(f32*)(&p1)); - printf("\t\t\t\t%04x\n", p2); - printf("\t\t\t\t%04x\n", p3); - printf("\t\t\t\n"); - - } - } - printf("\t\t\n"); - isTriplet = 0; - } - printf("\t\n"); - - BRLAN_fileoffset = brlanEntryOffset + be32(offsetToOther); - BRLAN_ReadDataFromMemory(&tagHeader, data, sizeof(tag_header)); - printf("\t\n", tagHeader.magic[0], tagHeader.magic[1], tagHeader.magic[2], tagHeader.magic[3]); - startOfEntries = BRLAN_fileoffset; - sOE = startOfEntries; - - for(j=0;j\n", tag_types_list[short_swap_bytes(tagEntryInfo.type)]); - else - printf("\t\t\n", short_swap_bytes(tagEntryInfo.type)); - if ( tagEntryInfo.unk1 == short_swap_bytes(0x0200) ) isTriplet = 1; - int k; for(k=0;k\n"); - printf("\t\t\t\t%.15f\n", *(f32*)(&p1)); - printf("\t\t\t\t%.15f\n", *(f32*)(&p2)); - printf("\t\t\t\t%.15f\n", *(f32*)(&p3)); - printf("\t\t\t\n"); - - } else { - tag_data2 tagData2; - memcpy(&tagData2, &data[sOE -8+ be32(tagEntry.offset) + sizeof(tag_entryinfo)+ (k*sizeof(tag_data2))], sizeof(tag_data2)); - u32 p1 = be32(tagData2.part1); - u16 p2 = short_swap_bytes(tagData2.part2); - u16 p3 = short_swap_bytes(tagData2.padding); - printf("\t\t\t\n"); - printf("\t\t\t\t%.15f\n", *(f32*)(&p1)); - printf("\t\t\t\t%04x\n", p2); - printf("\t\t\t\t%04x\n", p3); - printf("\t\t\t\n"); - - } - } - printf("\t\t\n"); - isTriplet = 0; - } - printf("\t\n"); - - if (somethingIsSet == 1) - { - tag_header tagHeader; - tag_entry tagEntry; - tag_entryinfo tagEntryInfo; - memcpy(&tagHeader, &data[brlanEntryOffset + be32(offsetToExtras)], sizeof(tag_header)); - printf("\t\n", tagHeader.magic[0], tagHeader.magic[1], tagHeader.magic[2], tagHeader.magic[3]); - for(j=0;j\n", tag_types_list[short_swap_bytes(tagEntryInfo.type)]); - else - printf("\t\t\n", short_swap_bytes(tagEntryInfo.type)); - if ( tagEntryInfo.unk1 == short_swap_bytes(0x0200) ) isTriplet = 1; - int k; - - for(k=0;k\n"); - printf("\t\t\t\t%.15f\n", *(f32*)(&p1)); - printf("\t\t\t\t%.15f\n", *(f32*)(&p2)); - printf("\t\t\t\t%.15f\n", *(f32*)(&p3)); - printf("\t\t\t\n"); - - } else { - tag_data2 tagData2; - memcpy(&tagData2, &data[brlanEntryOffset + be32(offsetToExtras) + be32(tagEntry.offset) + sizeof(tag_entryinfo)+ (k*sizeof(tag_data2))], sizeof(tag_data2)); - u32 p1 = be32(tagData2.part1); - u16 p2 = short_swap_bytes(tagData2.part2); - u16 p3 = short_swap_bytes(tagData2.padding); - printf("\t\t\t\n"); - printf("\t\t\t\t%.15f\n", *(f32*)(&p1)); - printf("\t\t\t\t%04x\n", p2); - printf("\t\t\t\t%04x\n", p3); - printf("\t\t\t\n"); - - } - } - printf("\t\t\n"); - isTriplet = 0; - } - printf("\t\n"); - } - somethingIsSet = 0; - somethingElseIsSet = 0; - } else { - - BRLAN_ReadDataFromMemory(&tagHeader, data, sizeof(tag_header)); - printf("\t\n", "Normal"); - else - { - printf("format=\"%08x\">\n", be32(brlanEntry.flags)); - } - - u32 startOfEntries = BRLAN_fileoffset; - u32 sOE = startOfEntries; - u32 j; - for (j=0;j\n", tag_types_list[short_swap_bytes(tagEntryInfo.type)]); - else - printf("\t\t\n", short_swap_bytes(tagEntryInfo.type)); - if( tagEntryInfo.unk1 == 0x2) isTriplet = 1; - - int k; - for(k=0;k\n"); - printf("\t\t\t\t%.15f\n", *(f32*)(&p1)); - printf("\t\t\t\t%.15f\n", *(f32*)(&p2)); - printf("\t\t\t\t%.15f\n", *(f32*)(&p3)); - printf("\t\t\t\n"); - - } else { - tag_data2 tagData2; - memcpy(&tagData2, &data[sOE -8+ be32(tagEntry.offset) + sizeof(tag_entryinfo)+ (k*sizeof(tag_data2))], sizeof(tag_data2)); - u32 p1 = be32(tagData2.part1); - u16 p2 = short_swap_bytes(tagData2.part2); - u16 p3 = short_swap_bytes(tagData2.padding); - printf("\t\t\t\n"); - printf("\t\t\t\t%.15f\n", *(f32*)(&p1)); - printf("\t\t\t\t%04x\n", p2); - printf("\t\t\t\t%04x\n", p3); - printf("\t\t\t\n"); - - } - } - printf("\t\t\n"); - isTriplet = 0; - } - printf("\t\n"); - if (somethingIsSet == 1) - { - tag_header tagHeader; - tag_entry tagEntry; - tag_entryinfo tagEntryInfo; - memcpy(&tagHeader, &data[brlanEntryOffset + be32(offsetToExtras)], sizeof(tag_header)); - printf("\t\n", tagHeader.magic[0], tagHeader.magic[1], tagHeader.magic[2], tagHeader.magic[3]); - for(j=0;j\n", tag_types_list[short_swap_bytes(tagEntryInfo.type)]); - else - printf("\t\t\n", short_swap_bytes(tagEntryInfo.type)); - if ( tagEntryInfo.unk1 == short_swap_bytes(0x0200) ) isTriplet = 1; - int k; - - for(k=0;k\n"); - printf("\t\t\t\t%.15f\n", *(f32*)(&p1)); - printf("\t\t\t\t%.15f\n", *(f32*)(&p2)); - printf("\t\t\t\t%.15f\n", *(f32*)(&p3)); - printf("\t\t\t\n"); - - } else { - tag_data2 tagData2; - memcpy(&tagData2, &data[brlanEntryOffset + be32(offsetToExtras) + be32(tagEntry.offset) + sizeof(tag_entryinfo)+ (k*sizeof(tag_data2))], sizeof(tag_data2)); - u32 p1 = be32(tagData2.part1); - u16 p2 = short_swap_bytes(tagData2.part2); - u16 p3 = short_swap_bytes(tagData2.padding); - printf("\t\t\t\n"); - printf("\t\t\t\t%.15f\n", *(f32*)(&p1)); - printf("\t\t\t\t%04x\n", p2); - printf("\t\t\t\t%04x\n", p3); - printf("\t\t\t\n"); - - } - } - printf("\t\t\n"); - isTriplet = 0; - } - printf("\t\n"); - } - somethingIsSet = 0; - } - } + printf("\t\n", brlanEntry.name); + u32 entrylocations[brlanEntry.num_tags]; + BRLAN_ReadDataFromMemory(entrylocations, data, brlanEntry.num_tags * sizeof(u32)); + for ( j = 0; j < brlanEntry.num_tags; j++) + { + BRLAN_CreateXMLTag(tagHeader, data, brlanEntryOffset + be32(entrylocations[j])); + } + printf("\t\n"); + } printf("\n"); - fclose(fp); } @@ -494,6 +262,14 @@ void WriteBRLANTagEntries(tag_entry* entry, u8 count, FILE* fp) } } +void WriteBRLANOffsets(u32* offsets, u32 number, FILE* fp) +{ + u32 tempoffsets[number]; + int i; + for(i=0;iname, 20); - writeentr.flags = be32(entr->flags); - writeentr.anim_header_len = be32(entr->anim_header_len); + writeentr.num_tags = entr->num_tags; + writeentr.is_material = entr->is_material; + writeentr.pad[0] = 0x0; + writeentr.pad[1] = 0x0; fwrite(&writeentr, sizeof(brlan_entry), 1, fp); } -u32 create_entries_from_xml(mxml_node_t *tree, mxml_node_t *node, brlan_entry *entr, tag_header* head, u8** tagblob, u32* blobsize) +void create_entries_from_xml(mxml_node_t *tree, mxml_node_t *node, brlan_entry *entr, tag_header* head, FILE* fp) { tag_entry* entry = NULL; tag_entryinfo* entryinfo = NULL; @@ -642,29 +420,8 @@ u32 create_entries_from_xml(mxml_node_t *tree, mxml_node_t *node, brlan_entry *e data2[x][i].padding = short_swap_bytes(strtoul(temp, NULL, 16)); } } - FILE* fp = fopen("temp.blan", "wb+"); - if(fp == NULL) { - printf("Couldn't open temporary temp.blan file\n"); - exit(1); - } - fseek(fp, 0, SEEK_SET); - entr->anim_header_len = 0; - WriteBRLANEntry(entr, fp); - u32 fillerIntOffset = ftell(fp); - u32 fillerInt = be32(0x60); - u32 fillerInt2 = be32(0x60); - if ((entr->flags & ( 1 << 25 )) && (entr->flags & ( 1 << 24 ))) - { - fillerInt2 = be32(0x60); - fwrite(&fillerInt, sizeof(u32), 1, fp); - fwrite(&fillerInt2, sizeof(u32), 1, fp); - BRLAN_fileoffset += 8; - } else if (entr->flags & 0x02000000) - { - fillerInt = be32(0x60); - fwrite(&fillerInt, sizeof(u32), 1, fp); - BRLAN_fileoffset += 4; - } + + head->pad1 = 0x0; head->pad2 = 0x0; head->pad3 = 0x0; WriteBRLANTagHeader(head, fp); u32 entryloc = ftell(fp); u32 animLen; @@ -692,7 +449,6 @@ u32 create_entries_from_xml(mxml_node_t *tree, mxml_node_t *node, brlan_entry *e if ( entryinfo[x].unk1 == 0x100 ) { tag_data2 writedata; - int i; for(i = 0; i < entryinfo[x].coord_count; i++) { writedata.part1 = be32(data2[x][i].part1); writedata.part2 = (data2[x][i].part2); @@ -707,410 +463,60 @@ u32 create_entries_from_xml(mxml_node_t *tree, mxml_node_t *node, brlan_entry *e free(data2); u32 oldpos = ftell(fp); fseek(fp, entryloc, SEEK_SET); - for(x=0;xentry_count;x++) + for( x = 0; x < head->entry_count; x++) entry[x].offset += sizeof(u32) * (head->entry_count) + 8; WriteBRLANTagEntries(entry, head->entry_count, fp); fseek(fp, oldpos, SEEK_SET); - u32 filesz = ftell(fp); - fseek(fp, 0, SEEK_SET); - u32 monkeyOffset; - entr->anim_header_len = sizeof(brlan_entry); - if ((entr->flags & (1 << 25)) && (entr->flags & (1 << 24))) - { - entr->anim_header_len += 8; - u32 tempOffset = ftell(fp); - fillerInt = be32(filesz); - fseek(fp, fillerIntOffset, SEEK_SET); - fwrite(&fillerInt, sizeof(u32), 1, fp); // MONKEY OFFSET - monkeyOffset = ftell(fp); - fwrite(&fillerInt, sizeof(u32), 1, fp); // GO BACK FOR EXTRA OFFSET - fseek(fp, tempOffset, SEEK_SET); - } else if (entr->flags & 0x02000000) - { - entr->anim_header_len += 4; - u32 tempOffset = ftell(fp); - fillerInt = be32(filesz); - fseek(fp, fillerIntOffset, SEEK_SET); - fwrite(&fillerInt, sizeof(u32), 1, fp); - fseek(fp, tempOffset, SEEK_SET); - } - WriteBRLANEntry(entr, fp); - - if ((entr->flags & ( 1 << 25 )) && (entr->flags & ( 1 << 24 ))) - { - mxml_node_t *monkeynode = NULL; - mxml_node_t *monkeysubnode = NULL; - mxml_node_t *monkeysubsubnode = NULL; - tag_header monkeyTagHeader; - tag_entry monkeyTagEntry[256]; - tag_entryinfo monkeyTagEntryInfo[256]; - tag_data *monkeyTagData[1024]; - tag_data2 *monkeyTagData2[1024]; - char tempChar[256]; - if(entr->flags & 0x02000000) - { - monkeynode = mxmlFindElement(node, tree, "monkey", NULL, NULL, MXML_DESCEND); - if (monkeynode != NULL) - { - if(mxmlElementGetAttr(monkeynode, "type") != NULL) - strcpy(temp, mxmlElementGetAttr(monkeynode, "type")); - else{ - printf("No type attribute found!\nSkipping this entry!\n"); - } - memcpy(monkeyTagHeader.magic, temp, 4); - monkeyTagHeader.entry_count = 0x00; - monkeyTagHeader.pad1 = 0x0; - monkeyTagHeader.pad2 = 0x0; - monkeyTagHeader.pad3 = 0x0; - fseek(fp, oldpos, SEEK_SET); - fwrite(&monkeyTagHeader, sizeof(tag_header), 1, fp); - - mxml_node_t *monkeyentrynode; - for(monkeyentrynode = mxmlFindElement(monkeynode, monkeynode, "entry", NULL, NULL, MXML_DESCEND); monkeyentrynode != NULL; monkeyentrynode = mxmlFindElement(monkeyentrynode, monkeynode, "entry", NULL, NULL, MXML_DESCEND)) - { - memset(temp, 0, 256); - memset(temp2, 0, 256); - if(mxmlElementGetAttr(monkeyentrynode, "type") != NULL) - strcpy(temp, mxmlElementGetAttr(monkeyentrynode, "type")); - else{ - printf("No type attribute found!\nSkipping this entry!\n"); - head->entry_count--; - } - for(i = 0; i < strlen(temp); i++) - temp2[i] = toupper(temp[i]); - for(i = 0; (i < 17) && (strcmp(temp3[i - 1], temp2) != 0); i++); - if(i == 17) - i = atoi(temp2); - else - i--; - monkeyTagEntryInfo[monkeyTagHeader.entry_count].type = short_swap_bytes(i); - monkeyTagEntryInfo[monkeyTagHeader.entry_count].unk1 = short_swap_bytes(0x0200); - monkeyTagEntryInfo[monkeyTagHeader.entry_count].pad1 = 0x0000; - monkeyTagEntryInfo[monkeyTagHeader.entry_count].unk2 = be32(0x0000000C); - monkeyTagEntryInfo[monkeyTagHeader.entry_count].coord_count = 0x0; - - for(monkeysubnode = mxmlFindElement(monkeyentrynode, monkeyentrynode, "triplet", NULL, NULL, MXML_DESCEND); monkeysubnode != NULL; monkeysubnode = mxmlFindElement(monkeysubnode, monkeyentrynode, "triplet", NULL, NULL, MXML_DESCEND)) - { - monkeyTagEntryInfo[monkeyTagHeader.entry_count].unk1 = short_swap_bytes(0x0200); - monkeyTagEntryInfo[monkeyTagHeader.entry_count].coord_count += 1; - u32 tC = monkeyTagEntryInfo[monkeyTagHeader.entry_count].coord_count; - - monkeyTagData[monkeyTagHeader.entry_count] = realloc(monkeyTagData[monkeyTagHeader.entry_count], sizeof(tag_data) * tC); // S E R I O U S H E L P N E E D E D // - monkeysubsubnode = mxmlFindElement(monkeysubnode, monkeysubnode, "frame", NULL, NULL, MXML_DESCEND); - if (monkeysubsubnode != NULL) - { - get_value(monkeysubsubnode, tempChar, 256); - f32 f1 = atof(tempChar); - monkeyTagData[monkeyTagHeader.entry_count][tC-1].part1 = *(u32*)&f1; - monkeyTagData[monkeyTagHeader.entry_count][tC-1].part1 = int_swap_bytes(monkeyTagData[monkeyTagHeader.entry_count][tC-1].part1); - } - monkeysubsubnode = mxmlFindElement(monkeysubnode, monkeysubnode, "value", NULL, NULL, MXML_DESCEND); - if (monkeysubsubnode != NULL) - { - get_value(monkeysubsubnode, tempChar, 256); - f32 f2 = atof(tempChar); - monkeyTagData[monkeyTagHeader.entry_count][tC-1].part2 = *(u32*)&f2; - monkeyTagData[monkeyTagHeader.entry_count][tC-1].part2 = int_swap_bytes(monkeyTagData[monkeyTagHeader.entry_count][tC-1].part2); - } - monkeysubsubnode = mxmlFindElement(monkeysubnode, monkeysubnode, "blend", NULL, NULL, MXML_DESCEND); - if(monkeysubsubnode != NULL) - { - get_value(monkeysubsubnode, tempChar, 256); - f32 f3 = atof(tempChar); - monkeyTagData[monkeyTagHeader.entry_count][tC-1].part3 = *(u32*)&f3; - monkeyTagData[monkeyTagHeader.entry_count][tC-1].part3 = int_swap_bytes(monkeyTagData[monkeyTagHeader.entry_count][tC-1].part3); - } - } - for(monkeysubnode = mxmlFindElement(monkeyentrynode, monkeyentrynode, "pair", NULL, NULL, MXML_DESCEND); monkeysubnode != NULL; monkeysubnode = mxmlFindElement(monkeysubnode, monkeyentrynode, "pair", NULL, NULL, MXML_DESCEND)) - { - monkeyTagEntryInfo[monkeyTagHeader.entry_count].unk1 = short_swap_bytes(0x0100); - monkeyTagEntryInfo[monkeyTagHeader.entry_count].coord_count +=1; - u32 tC = monkeyTagEntryInfo[monkeyTagHeader.entry_count].coord_count; - - monkeyTagData2[monkeyTagHeader.entry_count] = realloc(monkeyTagData2[monkeyTagHeader.entry_count], sizeof(tag_data2) * tC); - monkeysubsubnode = mxmlFindElement(monkeysubnode, monkeysubnode, "data1", NULL, NULL, MXML_DESCEND); - if (monkeysubsubnode != NULL) - { - get_value(monkeysubsubnode, tempChar, 256); - f32 f1 = atof(tempChar); - monkeyTagData2[monkeyTagHeader.entry_count][tC-1].part1 = *(u32*)&f1; - monkeyTagData2[monkeyTagHeader.entry_count][tC-1].part1 = int_swap_bytes(monkeyTagData2[monkeyTagHeader.entry_count][tC-1].part1); - } - monkeysubsubnode = mxmlFindElement(monkeysubnode, monkeysubnode, "data2", NULL, NULL, MXML_DESCEND); - if (monkeysubsubnode != NULL) - { - get_value(monkeysubsubnode, tempChar, 256); - monkeyTagData2[monkeyTagHeader.entry_count][tC-1].part2 = short_swap_bytes((short)strtoul(tempChar, NULL, 16)); - } - monkeysubsubnode = mxmlFindElement(monkeysubnode, monkeysubnode, "padding", NULL, NULL, MXML_DESCEND); - if(monkeysubsubnode != NULL) - { - get_value(monkeysubsubnode, tempChar, 256); - monkeyTagData2[monkeyTagHeader.entry_count][tC-1].padding = short_swap_bytes((short)strtoul(tempChar, NULL, 16)); - } - } - u32 eC = monkeyTagHeader.entry_count; - u32 cC = monkeyTagEntryInfo[eC].coord_count; - if (monkeyTagHeader.entry_count > 0) - { - cC = short_swap_bytes(monkeyTagEntryInfo[eC-1].coord_count); - printf("cC: %08x\n", cC); - } - monkeyTagEntry[monkeyTagHeader.entry_count].offset = sizeof(tag_header); - if (monkeyTagHeader.entry_count > 0) - { - if (monkeyTagEntryInfo[eC-1].unk1 == 0x2) - { - monkeyTagEntry[monkeyTagHeader.entry_count].offset = monkeyTagEntry[monkeyTagHeader.entry_count-1].offset + sizeof(tag_entryinfo) + (sizeof(tag_data) * cC); - } - if (monkeyTagEntryInfo[eC-1].unk1 == 0x1) - { - monkeyTagEntry[monkeyTagHeader.entry_count].offset = monkeyTagEntry[monkeyTagHeader.entry_count-1].offset + sizeof(tag_entryinfo) + (sizeof(tag_data2) * cC); - } - } - - monkeyTagEntryInfo[eC].coord_count = short_swap_bytes(monkeyTagEntryInfo[eC].coord_count); - monkeyTagHeader.entry_count++; - } - fseek(fp, oldpos, SEEK_SET); - fwrite(&monkeyTagHeader, sizeof(tag_header), 1, fp); - int l; for (l=0;lflags & 0x02000000) - { - addonnode = mxmlFindElement(node, tree, "extratag", NULL, NULL, MXML_DESCEND); - if (addonnode != NULL) - { - if(mxmlElementGetAttr(addonnode, "type") != NULL) - strcpy(temp, mxmlElementGetAttr(addonnode, "type")); - else{ - printf("No type attribute found!\nSkipping this entry!\n"); - } - memcpy(addonTagHeader.magic, temp, 4); - addonTagHeader.entry_count = 0x00; - addonTagHeader.pad1 = 0x0; - addonTagHeader.pad2 = 0x0; - addonTagHeader.pad3 = 0x0; - fseek(fp, oldpos, SEEK_SET); - fwrite(&addonTagHeader, sizeof(tag_header), 1, fp); - - mxml_node_t *entrynode; - for(entrynode = mxmlFindElement(addonnode, addonnode, "entry", NULL, NULL, MXML_DESCEND); entrynode != NULL; entrynode = mxmlFindElement(entrynode, addonnode, "entry", NULL, NULL, MXML_DESCEND)) - { - memset(temp, 0, 256); - memset(temp2, 0, 256); - if(mxmlElementGetAttr(entrynode, "type") != NULL) - strcpy(temp, mxmlElementGetAttr(entrynode, "type")); - else{ - printf("No type attribute found!\nSkipping this entry!\n"); - head->entry_count--; - } - for(i = 0; i < strlen(temp); i++) - temp2[i] = toupper(temp[i]); - for(i = 0; (i < 17) && (strcmp(temp3[i - 1], temp2) != 0); i++); - if(i == 17) - i = atoi(temp2); - else - i--; - addonTagEntryInfo[addonTagHeader.entry_count].type = short_swap_bytes(i); - addonTagEntryInfo[addonTagHeader.entry_count].unk1 = short_swap_bytes(0x0200); - addonTagEntryInfo[addonTagHeader.entry_count].pad1 = 0x0000; - addonTagEntryInfo[addonTagHeader.entry_count].unk2 = be32(0x0000000C); - addonTagEntryInfo[addonTagHeader.entry_count].coord_count = 0x0; - - for(addonsubnode = mxmlFindElement(entrynode, entrynode, "triplet", NULL, NULL, MXML_DESCEND); addonsubnode != NULL; addonsubnode = mxmlFindElement(addonsubnode, entrynode, "triplet", NULL, NULL, MXML_DESCEND)) - { - addonTagEntryInfo[addonTagHeader.entry_count].unk1 = short_swap_bytes(0x0200); - addonTagEntryInfo[addonTagHeader.entry_count].coord_count += 1; - u32 tC = addonTagEntryInfo[addonTagHeader.entry_count].coord_count; - - addonTagData[addonTagHeader.entry_count] = realloc(addonTagData[addonTagHeader.entry_count], sizeof(tag_data) * tC); // S E R I O U S H E L P N E E D E D // - addonsubsubnode = mxmlFindElement(addonsubnode, addonsubnode, "frame", NULL, NULL, MXML_DESCEND); - if (addonsubsubnode != NULL) - { - get_value(addonsubsubnode, tempChar, 256); - f32 f1 = atof(tempChar); - addonTagData[addonTagHeader.entry_count][tC-1].part1 = *(u32*)&f1; - addonTagData[addonTagHeader.entry_count][tC-1].part1 = int_swap_bytes(addonTagData[addonTagHeader.entry_count][tC-1].part1); - } - addonsubsubnode = mxmlFindElement(addonsubnode, addonsubnode, "value", NULL, NULL, MXML_DESCEND); - if (addonsubsubnode != NULL) - { - get_value(addonsubsubnode, tempChar, 256); - f32 f2 = atof(tempChar); - addonTagData[addonTagHeader.entry_count][tC-1].part2 = *(u32*)&f2; - addonTagData[addonTagHeader.entry_count][tC-1].part2 = int_swap_bytes(addonTagData[addonTagHeader.entry_count][tC-1].part2); - } - addonsubsubnode = mxmlFindElement(addonsubnode, addonsubnode, "blend", NULL, NULL, MXML_DESCEND); - if(addonsubsubnode != NULL) - { - get_value(addonsubsubnode, tempChar, 256); - f32 f3 = atof(tempChar); - addonTagData[addonTagHeader.entry_count][tC-1].part3 = *(u32*)&f3; - addonTagData[addonTagHeader.entry_count][tC-1].part3 = int_swap_bytes(addonTagData[addonTagHeader.entry_count][tC-1].part3); - } - } - for(addonsubnode = mxmlFindElement(entrynode, entrynode, "pair", NULL, NULL, MXML_DESCEND); addonsubnode != NULL; addonsubnode = mxmlFindElement(addonsubnode, entrynode, "pair", NULL, NULL, MXML_DESCEND)) - { - addonTagEntryInfo[addonTagHeader.entry_count].unk1 = short_swap_bytes(0x0100); - addonTagEntryInfo[addonTagHeader.entry_count].coord_count +=1; - u32 tC = addonTagEntryInfo[addonTagHeader.entry_count].coord_count; - - addonTagData2[addonTagHeader.entry_count] = realloc(addonTagData2[addonTagHeader.entry_count], sizeof(tag_data2) * tC); - addonsubsubnode = mxmlFindElement(addonsubnode, addonsubnode, "data1", NULL, NULL, MXML_DESCEND); - if (addonsubsubnode != NULL) - { - get_value(addonsubsubnode, tempChar, 256); - f32 f1 = atof(tempChar); - addonTagData2[addonTagHeader.entry_count][tC-1].part1 = *(u32*)&f1; - addonTagData2[addonTagHeader.entry_count][tC-1].part1 = int_swap_bytes(addonTagData2[addonTagHeader.entry_count][tC-1].part1); - } - addonsubsubnode = mxmlFindElement(addonsubnode, addonsubnode, "data2", NULL, NULL, MXML_DESCEND); - if (addonsubsubnode != NULL) - { - get_value(addonsubsubnode, tempChar, 256); - addonTagData2[addonTagHeader.entry_count][tC-1].part2 = short_swap_bytes((short)strtoul(tempChar, NULL, 16)); - } - addonsubsubnode = mxmlFindElement(addonsubnode, addonsubnode, "padding", NULL, NULL, MXML_DESCEND); - if(addonsubsubnode != NULL) - { - get_value(addonsubsubnode, tempChar, 256); - addonTagData2[addonTagHeader.entry_count][tC-1].padding = short_swap_bytes((short)strtoul(tempChar, NULL, 16)); - } - } - u32 eC = addonTagHeader.entry_count; - u32 cC = addonTagEntryInfo[eC].coord_count; - if (addonTagHeader.entry_count > 0) - { - cC = short_swap_bytes(addonTagEntryInfo[eC-1].coord_count); - printf("cC: %08x\n", cC); - } - addonTagEntry[addonTagHeader.entry_count].offset = sizeof(tag_header); - if (addonTagHeader.entry_count > 0) - { - if (addonTagEntryInfo[eC-1].unk1 == 0x2) - { - addonTagEntry[addonTagHeader.entry_count].offset = addonTagEntry[addonTagHeader.entry_count-1].offset + sizeof(tag_entryinfo) + (sizeof(tag_data) * cC); - } - if (addonTagEntryInfo[eC-1].unk1 == 0x1) - { - addonTagEntry[addonTagHeader.entry_count].offset = addonTagEntry[addonTagHeader.entry_count-1].offset + sizeof(tag_entryinfo) + (sizeof(tag_data2) * cC); - } - } - - addonTagEntryInfo[eC].coord_count = short_swap_bytes(addonTagEntryInfo[eC].coord_count); - addonTagHeader.entry_count++; - } - fseek(fp, oldpos, SEEK_SET); - fwrite(&addonTagHeader, sizeof(tag_header), 1, fp); - int l; for (l=0;l