aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--brlan.c1505
-rwxr-xr-xbrlan.h144
-rw-r--r--brlyt.c2414
-rw-r--r--brlyt.h280
-rw-r--r--general.h4
5 files changed, 3072 insertions, 1275 deletions
diff --git a/brlan.c b/brlan.c
index 5a6f6e2..4ab2e8b 100644
--- a/brlan.c
+++ b/brlan.c
@@ -24,823 +24,968 @@
#define dbgprintf //
#endif //DEBUGBRLAN
-#define MAXIMUM_TAGS_SIZE (0xf000)
-#define MAXIMUM_TIMGS_SIZE (0x1000)
+#define MAXIMUM_TAGS_SIZE (0xf000)
+#define MAXIMUM_TIMGS_SIZE (0x1000)
fourcc tag_FourCCs[] = { "RLPA", "RLTS", "RLVI", "RLVC", "RLMC", "RLTP" , "RLIM" };
char tag_types_list[15][24];
-char tag_types_rlmc_list[15][24];
+char tag_types_rlpa_list[15][24];
+char tag_types_rlts_list[15][24];
+char tag_types_rlvi_list[15][24];
char tag_types_rlvc_list[15][24];
+char tag_types_rlmc_list[15][24];
+char tag_types_rltp_list[15][24];
+char tag_types_rlim_list[15][24];
static size_t BRLAN_fileoffset = 0;
FILE* xmlanout;
static void BRLAN_ReadDataFromMemoryX(void* destination, void* input, size_t size)
{
- u8* out = (u8*)destination;
- u8* in = ((u8*)input) + BRLAN_fileoffset;
- memcpy(out, in, size);
+ u8* out = (u8*)destination;
+ u8* in = ((u8*)input) + BRLAN_fileoffset;
+ memcpy(out, in, size);
}
static void BRLAN_ReadDataFromMemory(void* destination, void* input, size_t size)
{
- BRLAN_ReadDataFromMemoryX(destination, input, size);
- BRLAN_fileoffset += size;
+ BRLAN_ReadDataFromMemoryX(destination, input, size);
+ BRLAN_fileoffset += size;
}
-static void CreateGlobal_pai1(brlan_pai1_header_type2 *pai1_header, brlan_pai1_header_type1 pai1_header1,
- brlan_pai1_header_type2 pai1_header2, int pai1_header_type)
+static void CreateGlobal_pai1(brlan_pai1_header_type2 *pai1_header, brlan_pai1_header_type1 pai1_header1, brlan_pai1_header_type2 pai1_header2, int pai1_header_type)
{
- if(pai1_header_type == 1) {
- pai1_header->magic[0] = pai1_header1.magic[0];
- pai1_header->magic[1] = pai1_header1.magic[1];
- pai1_header->magic[2] = pai1_header1.magic[2];
- pai1_header->magic[3] = pai1_header1.magic[3];
- pai1_header->size = pai1_header1.size;
- 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;
- }else
- memcpy(pai1_header, &pai1_header2, sizeof(brlan_pai1_header_type2));
+ if(pai1_header_type == 1) {
+ pai1_header->magic[0] = pai1_header1.magic[0];
+ pai1_header->magic[1] = pai1_header1.magic[1];
+ pai1_header->magic[2] = pai1_header1.magic[2];
+ pai1_header->magic[3] = pai1_header1.magic[3];
+ pai1_header->size = pai1_header1.size;
+ pai1_header->framesize = pai1_header1.framesize;
+ pai1_header->flags = pai1_header1.flags;
+ pai1_header->padding = pai1_header1.padding;
+ pai1_header->num_timgs = pai1_header1.num_timgs;
+ pai1_header->num_entries = pai1_header1.num_entries;
+ pai1_header->padding2 = 0;
+ pai1_header->entry_offset = pai1_header1.entry_offset;
+ }else
+ memcpy(pai1_header, &pai1_header2, sizeof(brlan_pai1_header_type2));
}
static int FourCCsMatch(fourcc cc1, fourcc cc2)
{
- if((cc1[0] == cc2[0]) && (cc1[1] == cc2[1]) && (cc1[2] == cc2[2]) && (cc1[3] == cc2[3]))
- return 1;
- else
- return 0;
+ if((cc1[0] == cc2[0]) && (cc1[1] == cc2[1]) && (cc1[2] == cc2[2]) && (cc1[3] == cc2[3]))
+ return 1;
+ else
+ return 0;
}
static int FourCCInList(fourcc cc)
{
- int i;
- for(i = 0; i < 7; i++)
- if(FourCCsMatch(cc, tag_FourCCs[i])) return 1;
- return 0;
+ int i;
+ for(i = 0; i < 7; i++)
+ if(FourCCsMatch(cc, tag_FourCCs[i])) return 1;
+ return 0;
}
void BRLAN_CreateXMLTag(tag_header tagHeader, void* data, u32 offset, mxml_node_t *pane)
{
- BRLAN_fileoffset = offset;
- BRLAN_ReadDataFromMemory(&tagHeader, data, sizeof(tag_header));
+ BRLAN_fileoffset = offset;
+ BRLAN_ReadDataFromMemory(&tagHeader, data, sizeof(tag_header));
- mxml_node_t *tag;
- tag = mxmlNewElement(pane, "tag"); mxmlElementSetAttrf(tag, "type", "%c%c%c%c", tagHeader.magic[0], tagHeader.magic[1], tagHeader.magic[2], tagHeader.magic[3]);
+ mxml_node_t *tag;
+ tag = mxmlNewElement(pane, "tag"); mxmlElementSetAttrf(tag, "type", "%c%c%c%c", 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++)
- {
- mxml_node_t *entry;
- BRLAN_fileoffset = offset + be32(tagentrylocations[i]);
- BRLAN_ReadDataFromMemory(&tagEntryInfo, data, sizeof(tag_entryinfo));
- if(short_swap_bytes(tagEntryInfo.type) < 16)
+ 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++)
{
- char type_rlmc[4] = {'R', 'L', 'M', 'C'};
- char type_rlvc[4] = {'R', 'L', 'V', 'C'};
- if(memcmp(tagHeader.magic, type_rlmc, 4) == 0)
- {
- entry = mxmlNewElement(tag, "entry"); mxmlElementSetAttrf(entry, "type", "%s", tag_types_rlmc_list[short_swap_bytes(tagEntryInfo.type)]);
- } else if (memcmp(tagHeader.magic, type_rlvc, 4) == 0) {
- entry = mxmlNewElement(tag, "entry"); mxmlElementSetAttrf(entry, "type", "%s", tag_types_rlvc_list[short_swap_bytes(tagEntryInfo.type)]);
- } else {
- entry = mxmlNewElement(tag, "entry"); mxmlElementSetAttrf(entry, "type", "%s", tag_types_list[short_swap_bytes(tagEntryInfo.type)]);
- }
- } else {
- entry = mxmlNewElement(tag, "entry"); mxmlElementSetAttrf(entry, "type", "%u", short_swap_bytes(tagEntryInfo.type));
- }
+ mxml_node_t *entry;
+ BRLAN_fileoffset = offset + be32(tagentrylocations[i]);
+ BRLAN_ReadDataFromMemory(&tagEntryInfo, data, sizeof(tag_entryinfo));
+ entry = mxmlNewElement(tag, "entry");
+ mxmlElementSetAttrf(entry, "type1", "%u", tagEntryInfo.type1);
+ if(tagEntryInfo.type2 < 16)
+ {
+ char type_rlpa[4] = {'R', 'L', 'P', 'A'};
+ char type_rlts[4] = {'R', 'L', 'T', 'S'};
+ char type_rlvi[4] = {'R', 'L', 'V', 'I'};
+ char type_rlvc[4] = {'R', 'L', 'V', 'C'};
+ char type_rlmc[4] = {'R', 'L', 'M', 'C'};
+ char type_rltp[4] = {'R', 'L', 'T', 'P'};
+ char type_rlim[4] = {'R', 'L', 'I', 'M'};
+ if(memcmp(tagHeader.magic, type_rlpa, 4) == 0)
+ {
+ mxmlElementSetAttrf(entry, "type2", "%s", tag_types_rlpa_list[tagEntryInfo.type2]);
+ } else if (memcmp(tagHeader.magic, type_rlts, 4) == 0) {
+ mxmlElementSetAttrf(entry, "type2", "%s", tag_types_rlts_list[tagEntryInfo.type2]);
+ } else if (memcmp(tagHeader.magic, type_rlvi, 4) == 0) {
+ mxmlElementSetAttrf(entry, "type2", "%s", tag_types_rlvi_list[tagEntryInfo.type2]);
+ } else if (memcmp(tagHeader.magic, type_rlvc, 4) == 0) {
+ mxmlElementSetAttrf(entry, "type2", "%s", tag_types_rlvc_list[tagEntryInfo.type2]);
+ } else if (memcmp(tagHeader.magic, type_rlmc, 4) == 0) {
+ mxmlElementSetAttrf(entry, "type2", "%s", tag_types_rlmc_list[tagEntryInfo.type2]);
+ } else if (memcmp(tagHeader.magic, type_rltp, 4) == 0) {
+ mxmlElementSetAttrf(entry, "type2", "%s", tag_types_rltp_list[tagEntryInfo.type2]);
+ } else if (memcmp(tagHeader.magic, type_rlim, 4) == 0) {
+ mxmlElementSetAttrf(entry, "type2", "%s", tag_types_rlim_list[tagEntryInfo.type2]);
+ } else {
+ mxmlElementSetAttrf(entry, "type2", "%s", tag_types_list[tagEntryInfo.type2]);
+ }
+ } else {
+ mxmlElementSetAttrf(entry, "type2", "%u", tagEntryInfo.type2);
+ }
- for( j = 0; j < short_swap_bytes(tagEntryInfo.coord_count); j++)
- {
- if ( tagEntryInfo.unk1 == 0x2 )
- {
- mxml_node_t *triplet;
- mxml_node_t *frame;
- mxml_node_t *value;
- mxml_node_t *blend;
- tag_data tagData;
- BRLAN_ReadDataFromMemory(&tagData, data, sizeof(tag_data));
+ for( j = 0; j < short_swap_bytes(tagEntryInfo.coord_count); j++)
+ {
+ if ( tagEntryInfo.data_type == 0x2 )
+ {
+ mxml_node_t *triplet;
+ mxml_node_t *frame;
+ mxml_node_t *value;
+ mxml_node_t *blend;
+ 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);
- triplet = mxmlNewElement(entry, "triplet");
- frame = mxmlNewElement(triplet, "frame"); mxmlNewTextf(frame, 0, "%.15f", *(f32*)(&p1));
- value = mxmlNewElement(triplet, "value"); mxmlNewTextf(value, 0, "%.15f", *(f32*)(&p2));
- blend = mxmlNewElement(triplet, "blend"); mxmlNewTextf(blend, 0, "%.15f", *(f32*)(&p3));
- } else {
- tag_data2 tagData2;
- BRLAN_ReadDataFromMemory(&tagData2, data, sizeof(tag_data2));
+ u32 p1 = be32(tagData.part1);
+ u32 p2 = be32(tagData.part2);
+ u32 p3 = be32(tagData.part3);
+ triplet = mxmlNewElement(entry, "triplet");
+ frame = mxmlNewElement(triplet, "frame"); mxmlNewTextf(frame, 0, "%.15f", *(f32*)(&p1));
+ value = mxmlNewElement(triplet, "value"); mxmlNewTextf(value, 0, "%.15f", *(f32*)(&p2));
+ blend = mxmlNewElement(triplet, "blend"); mxmlNewTextf(blend, 0, "%.15f", *(f32*)(&p3));
+ } else {
+ tag_data2 tagData2;
+ BRLAN_ReadDataFromMemory(&tagData2, data, sizeof(tag_data2));
- mxml_node_t *pair;
- mxml_node_t *data1;
- mxml_node_t *data2;
- mxml_node_t *padding;
- u32 p1 = be32(tagData2.part1);
- u16 p2 = short_swap_bytes(tagData2.part2);
- u16 p3 = short_swap_bytes(tagData2.padding);
- pair = mxmlNewElement(entry, "pair");
- data1 = mxmlNewElement(pair, "data1"); mxmlNewTextf(data1, 0, "%.15f", *(f32*)(&p1));
- data2 = mxmlNewElement(pair, "data2"); mxmlNewTextf(data2, 0, "%04x", p2);
- padding = mxmlNewElement(pair, "padding"); mxmlNewTextf(padding, 0, "%04x", p3);
- }
- }
- }
+ mxml_node_t *pair;
+ mxml_node_t *data1;
+ mxml_node_t *data2;
+ mxml_node_t *padding;
+ u32 p1 = be32(tagData2.part1);
+ u16 p2 = short_swap_bytes(tagData2.part2);
+ u16 p3 = short_swap_bytes(tagData2.padding);
+ pair = mxmlNewElement(entry, "pair");
+ data1 = mxmlNewElement(pair, "data1"); mxmlNewTextf(data1, 0, "%.15f", *(f32*)(&p1));
+ data2 = mxmlNewElement(pair, "data2"); mxmlNewTextf(data2, 0, "%04x", p2);
+ padding = mxmlNewElement(pair, "padding"); mxmlNewTextf(padding, 0, "%04x", p3);
+ }
+ }
+ }
}
void parse_brlan(char* filename, char *filenameout)
{
- FILE* fp = fopen(filename, "rb");
- if(fp == NULL) {
- printf("Error! Couldn't open %s!\n", filename);
- exit(1);
- }
- fseek(fp, 0, SEEK_END);
- u32 lengthOfFile = ftell(fp);
- fseek(fp, 0, SEEK_SET);
- u8 data[lengthOfFile];
- fread(data, lengthOfFile, 1, fp);
+ FILE* fp = fopen(filename, "rb");
+ if(fp == NULL) {
+ printf("Error! Couldn't open %s!\n", filename);
+ exit(1);
+ }
+ fseek(fp, 0, SEEK_END);
+ u32 lengthOfFile = ftell(fp);
+ fseek(fp, 0, SEEK_SET);
+ u8 data[lengthOfFile];
+ fread(data, lengthOfFile, 1, fp);
- int i, j;
- for(i = 0; i < 16; i++)
- {
- memset(tag_types_list[i], 0, 24);
- memset(tag_types_rlmc_list[i], 0, 24);
- memset(tag_types_rlvc_list[i], 0, 24);
- }
- strcpy(tag_types_list[0], "X Translation");
- strcpy(tag_types_list[1], "Y Translation");
- strcpy(tag_types_list[2], "Z Translation");
- strcpy(tag_types_list[3], "X Flip");
- strcpy(tag_types_list[4], "Y Flip");
- strcpy(tag_types_list[5], "Angle");
- strcpy(tag_types_list[6], "X Zoom");
- strcpy(tag_types_list[7], "Y Zoom");
- strcpy(tag_types_list[8], "Width");
- strcpy(tag_types_list[9], "Height");
- strcpy(tag_types_list[10], "0x0A");
- strcpy(tag_types_list[11], "0x0B");
- strcpy(tag_types_list[12], "0x0C");
- strcpy(tag_types_list[13], "0x0D");
- strcpy(tag_types_list[14], "0x0E");
- strcpy(tag_types_list[15], "0x0F");
+ int i, j;
+ for(i = 0; i < 16; i++)
+ {
+ memset(tag_types_list[i], 0, 24);
+ memset(tag_types_rlpa_list[i], 0, 24);
+ memset(tag_types_rlts_list[i], 0, 24);
+ memset(tag_types_rlvi_list[i], 0, 24);
+ memset(tag_types_rlvc_list[i], 0, 24);
+ memset(tag_types_rlmc_list[i], 0, 24);
+ memset(tag_types_rltp_list[i], 0, 24);
+ memset(tag_types_rlim_list[i], 0, 24);
+ }
+ strcpy(tag_types_list[0], "X Translation");
+ strcpy(tag_types_list[1], "Y Translation");
+ strcpy(tag_types_list[2], "Z Translation");
+ strcpy(tag_types_list[3], "X Rotate");
+ strcpy(tag_types_list[4], "Y Rotate");
+ strcpy(tag_types_list[5], "Z Rotate");
+ strcpy(tag_types_list[6], "X Scale");
+ strcpy(tag_types_list[7], "Y Scale");
+ strcpy(tag_types_list[8], "Width");
+ strcpy(tag_types_list[9], "Height");
+ strcpy(tag_types_list[10], "0x0A"); // modified x
+ strcpy(tag_types_list[11], "0x0B"); // modified y
+ strcpy(tag_types_list[12], "0x0C"); // modified z
+ strcpy(tag_types_list[13], "0x0D");
+ strcpy(tag_types_list[14], "0x0E");
+ strcpy(tag_types_list[15], "0x0F");
- strcpy(tag_types_rlmc_list[0], "0x00");
- strcpy(tag_types_rlmc_list[1], "0x01");
- strcpy(tag_types_rlmc_list[2], "0x02");
- strcpy(tag_types_rlmc_list[3], "0x03");
- strcpy(tag_types_rlmc_list[4], "Blackcolor R");
- strcpy(tag_types_rlmc_list[5], "Blackcolor G");
- strcpy(tag_types_rlmc_list[6], "Blackcolor B");
- strcpy(tag_types_rlmc_list[7], "Blackcolor A");
- strcpy(tag_types_rlmc_list[8], "Whitecolor R");
- strcpy(tag_types_rlmc_list[9], "Whitecolor G");
- strcpy(tag_types_rlmc_list[10], "Whitecolor B");
- strcpy(tag_types_rlmc_list[11], "Whitecolor A");
- strcpy(tag_types_rlmc_list[12], "0x0C");
- strcpy(tag_types_rlmc_list[13], "0x0D");
- strcpy(tag_types_rlmc_list[14], "0x0E");
- strcpy(tag_types_rlmc_list[15], "0x0F");
+ strcpy(tag_types_rlpa_list[0], "X Translation");
+ strcpy(tag_types_rlpa_list[1], "Y Translation");
+ strcpy(tag_types_rlpa_list[2], "Z Translation");
+ strcpy(tag_types_rlpa_list[3], "X Rotate");
+ strcpy(tag_types_rlpa_list[4], "Y Rotate");
+ strcpy(tag_types_rlpa_list[5], "Z Rotate");
+ strcpy(tag_types_rlpa_list[6], "X Scale");
+ strcpy(tag_types_rlpa_list[7], "Y Scale");
+ strcpy(tag_types_rlpa_list[8], "Width");
+ strcpy(tag_types_rlpa_list[9], "Height");
+ strcpy(tag_types_rlpa_list[10], "0x0A"); // modified x
+ strcpy(tag_types_rlpa_list[11], "0x0B"); // modified y
+ strcpy(tag_types_rlpa_list[12], "0x0C"); // modified z
+ strcpy(tag_types_rlpa_list[13], "0x0D");
+ strcpy(tag_types_rlpa_list[14], "0x0E");
+ strcpy(tag_types_rlpa_list[15], "0x0F");
- strcpy(tag_types_rlvc_list[0], "Top Left R");
- strcpy(tag_types_rlvc_list[1], "Top Left G");
- strcpy(tag_types_rlvc_list[2], "Top Left B");
- strcpy(tag_types_rlvc_list[3], "Top Left A");
- strcpy(tag_types_rlvc_list[4], "Top Right R");
- strcpy(tag_types_rlvc_list[5], "Top Right G");
- strcpy(tag_types_rlvc_list[6], "Top Right B");
- strcpy(tag_types_rlvc_list[7], "Top Right A");
- strcpy(tag_types_rlvc_list[8], "Bottom Left R");
- strcpy(tag_types_rlvc_list[9], "Bottom Left G");
- strcpy(tag_types_rlvc_list[10], "Bottom Left B");
- strcpy(tag_types_rlvc_list[11], "Bottom Left A");
- strcpy(tag_types_rlvc_list[12], "Bottom Right R");
- strcpy(tag_types_rlvc_list[13], "Bottom Right G");
- strcpy(tag_types_rlvc_list[14], "Bottom Right B");
- strcpy(tag_types_rlvc_list[15], "Bottom Right A");
+ strcpy(tag_types_rlts_list[0], "XTrans");
+ strcpy(tag_types_rlts_list[1], "YTrans");
+ strcpy(tag_types_rlts_list[2], "Rotate");
+ strcpy(tag_types_rlts_list[3], "XScale");
+ strcpy(tag_types_rlts_list[4], "YScale");
- BRLAN_fileoffset = 0;
- brlan_header header;
- BRLAN_ReadDataFromMemoryX(&header, data, sizeof(brlan_header));
- BRLAN_fileoffset = short_swap_bytes(header.pai1_offset);
- brlan_pai1_universal universal;
- BRLAN_ReadDataFromMemoryX(&universal, data, sizeof(brlan_pai1_universal));
-
- int pai1_header_type;
- brlan_pai1_header_type1 pai1_header1;
- brlan_pai1_header_type2 pai1_header2;
- brlan_pai1_header_type2 pai1_header;
+ strcpy(tag_types_rlvi_list[0], "Visibility");
- if((be32(universal.flags) & (1 << 25)) >= 1) {
- pai1_header_type = 2;
- BRLAN_ReadDataFromMemory(&pai1_header2, data, sizeof(brlan_pai1_header_type2));
- } else {
- pai1_header_type = 1;
- BRLAN_ReadDataFromMemory(&pai1_header1, data, sizeof(brlan_pai1_header_type1));
- }
+ strcpy(tag_types_rlvc_list[0], "Top Left R");
+ strcpy(tag_types_rlvc_list[1], "Top Left G");
+ strcpy(tag_types_rlvc_list[2], "Top Left B");
+ strcpy(tag_types_rlvc_list[3], "Top Left A");
+ strcpy(tag_types_rlvc_list[4], "Top Right R");
+ strcpy(tag_types_rlvc_list[5], "Top Right G");
+ strcpy(tag_types_rlvc_list[6], "Top Right B");
+ strcpy(tag_types_rlvc_list[7], "Top Right A");
+ strcpy(tag_types_rlvc_list[8], "Bottom Left R");
+ strcpy(tag_types_rlvc_list[9], "Bottom Left G");
+ strcpy(tag_types_rlvc_list[10], "Bottom Left B");
+ strcpy(tag_types_rlvc_list[11], "Bottom Left A");
+ strcpy(tag_types_rlvc_list[12], "Bottom Right R");
+ strcpy(tag_types_rlvc_list[13], "Bottom Right G");
+ strcpy(tag_types_rlvc_list[14], "Bottom Right B");
+ strcpy(tag_types_rlvc_list[15], "Bottom Right A");
- CreateGlobal_pai1(&pai1_header, pai1_header1, pai1_header2, pai1_header_type);
+ strcpy(tag_types_rlmc_list[0], "0x00");
+ strcpy(tag_types_rlmc_list[1], "0x01");
+ strcpy(tag_types_rlmc_list[2], "0x02");
+ strcpy(tag_types_rlmc_list[3], "0x03");
+ strcpy(tag_types_rlmc_list[4], "Blackcolor R");
+ strcpy(tag_types_rlmc_list[5], "Blackcolor G");
+ strcpy(tag_types_rlmc_list[6], "Blackcolor B");
+ strcpy(tag_types_rlmc_list[7], "Blackcolor A");
+ strcpy(tag_types_rlmc_list[8], "Whitecolor R");
+ strcpy(tag_types_rlmc_list[9], "Whitecolor G");
+ strcpy(tag_types_rlmc_list[10], "Whitecolor B");
+ strcpy(tag_types_rlmc_list[11], "Whitecolor A");
+ strcpy(tag_types_rlmc_list[12], "0x0C");
+ strcpy(tag_types_rlmc_list[13], "0x0D");
+ strcpy(tag_types_rlmc_list[14], "0x0E");
+ strcpy(tag_types_rlmc_list[15], "0x0F");
+ strcpy(tag_types_rltp_list[0], "PaletteZero");
+ strcpy(tag_types_rltp_list[1], "PaletteOne");
+ strcpy(tag_types_rltp_list[2], "PaletteTwo");
+ strcpy(tag_types_rltp_list[3], "PaletteThree");
+ strcpy(tag_types_rltp_list[4], "PaletteFour");
+ strcpy(tag_types_rltp_list[5], "PaletteFive");
+ strcpy(tag_types_rltp_list[6], "PaletteSix");
+ strcpy(tag_types_rltp_list[7], "PaletteSeven");
+ strcpy(tag_types_rltp_list[8], "PaletteEight");
+ strcpy(tag_types_rltp_list[9], "PaletteNine");
+ strcpy(tag_types_rltp_list[10], "PaletteTen");
+ strcpy(tag_types_rltp_list[11], "PaletteEleven");
+ strcpy(tag_types_rltp_list[12], "PaletteTwelve");
+ strcpy(tag_types_rltp_list[13], "PaletteThirteen");
+ strcpy(tag_types_rltp_list[14], "PaletteFourteen");
+ strcpy(tag_types_rltp_list[15], "PaletteFifteen");
- FILE *xmlFile;
- xmlFile = fopen(filenameout, "w");
- mxml_node_t *xml;
- mxml_node_t *xmlan;
- xml = mxmlNewXML("1.0");
- xmlan = mxmlNewElement(xml, "xmlan");
- mxmlElementSetAttrf(xmlan, "version", "%d.%d.%d%s", BENZIN_VERSION_MAJOR, BENZIN_VERSION_MINOR, BENZIN_VERSION_BUILD, BENZIN_VERSION_OTHER);
- mxmlElementSetAttrf(xmlan, "framesize", "%lu", (long unsigned int)short_swap_bytes(pai1_header.framesize));
- mxmlElementSetAttrf(xmlan, "flags", "%02x", pai1_header.flags);
+ strcpy(tag_types_rlim_list[0], "XTrans");
+ strcpy(tag_types_rlim_list[1], "YTrans");
+ strcpy(tag_types_rlim_list[2], "Rotate");
+ strcpy(tag_types_rlim_list[3], "XScale");
+ strcpy(tag_types_rlim_list[4], "YScale");
- int timgs = short_swap_bytes(pai1_header.num_timgs);
+ BRLAN_fileoffset = 0;
+ brlan_header header;
+ BRLAN_ReadDataFromMemoryX(&header, data, sizeof(brlan_header));
+ BRLAN_fileoffset = short_swap_bytes(header.pai1_offset);
+ brlan_pai1_universal universal;
+ BRLAN_ReadDataFromMemoryX(&universal, data, sizeof(brlan_pai1_universal));
- 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;
+ int pai1_header_type;
+ brlan_pai1_header_type1 pai1_header1;
+ brlan_pai1_header_type2 pai1_header2;
+ brlan_pai1_header_type2 pai1_header;
- mxml_node_t *timg;
- 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);
- for( j = 0; data[z] != 0; timgname[j++] = data[z], z++);
- {
- timg = mxmlNewElement(xmlan, "timg");
- mxmlElementSetAttrf(timg, "name", "%s", timgname);
- }
- currtableoff += 4;
- }
+ if((be32(universal.flags) & (1 << 25)) >= 1) {
+ pai1_header_type = 2;
+ BRLAN_ReadDataFromMemory(&pai1_header2, data, sizeof(brlan_pai1_header_type2));
+ } else {
+ pai1_header_type = 1;
+ BRLAN_ReadDataFromMemory(&pai1_header1, data, sizeof(brlan_pai1_header_type1));
+ }
- int tagcount = short_swap_bytes(pai1_header.num_entries);
- u32 taglocations[tagcount];
- BRLAN_fileoffset = be32(pai1_header.entry_offset) + short_swap_bytes(header.pai1_offset);
- BRLAN_ReadDataFromMemory(taglocations, data, tagcount * sizeof(u32));
+ CreateGlobal_pai1(&pai1_header, pai1_header1, pai1_header2, pai1_header_type);
- for( i = 0; i < tagcount; i++) {
- brlan_entry brlanEntry;
- tag_header tagHeader;
- BRLAN_fileoffset = be32(taglocations[i]) + short_swap_bytes(header.pai1_offset);
- u32 brlanEntryOffset = BRLAN_fileoffset;
- BRLAN_ReadDataFromMemory(&brlanEntry, data, sizeof(brlan_entry));
- mxml_node_t *pane;
- pane = mxmlNewElement(xmlan, "pane"); mxmlElementSetAttrf(pane, "name", "%s", brlanEntry.name); mxmlElementSetAttrf(pane, "type", "%u", brlanEntry.is_material);
+ FILE *xmlFile;
+ xmlFile = fopen(filenameout, "w");
+ mxml_node_t *xml;
+ mxml_node_t *xmlan;
+ xml = mxmlNewXML("1.0");
+ xmlan = mxmlNewElement(xml, "xmlan");
+ mxmlElementSetAttrf(xmlan, "version", "%d.%d.%d%s", BENZIN_VERSION_MAJOR, BENZIN_VERSION_MINOR, BENZIN_VERSION_BUILD, BENZIN_VERSION_OTHER);
+ mxmlElementSetAttrf(xmlan, "framesize", "%lu", (long unsigned int)short_swap_bytes(pai1_header.framesize));
+ mxmlElementSetAttrf(xmlan, "flags", "%02x", pai1_header.flags);
- 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]), pane);
- }
- }
- mxmlSaveFile(xml, xmlFile, whitespace_cb);
- mxmlDelete(xml);
- fclose(xmlFile);
- fclose(fp);
+ int timgs = short_swap_bytes(pai1_header.num_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;
+
+ mxml_node_t *timg;
+ 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);
+ for( j = 0; data[z] != 0; timgname[j++] = data[z], z++);
+ {
+ timg = mxmlNewElement(xmlan, "timg");
+ mxmlElementSetAttrf(timg, "name", "%s", timgname);
+ }
+ currtableoff += 4;
+ }
+
+ int tagcount = short_swap_bytes(pai1_header.num_entries);
+ u32 taglocations[tagcount];
+ 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++) {
+ brlan_entry brlanEntry;
+ tag_header tagHeader;
+ BRLAN_fileoffset = be32(taglocations[i]) + short_swap_bytes(header.pai1_offset);
+ u32 brlanEntryOffset = BRLAN_fileoffset;
+ BRLAN_ReadDataFromMemory(&brlanEntry, data, sizeof(brlan_entry));
+
+ mxml_node_t *pane;
+ pane = mxmlNewElement(xmlan, "pane"); mxmlElementSetAttrf(pane, "name", "%s", brlanEntry.name); mxmlElementSetAttrf(pane, "type", "%u", brlanEntry.is_material);
+
+ 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]), pane);
+ }
+ }
+ mxmlSaveFile(xml, xmlFile, whitespace_cb);
+ mxmlDelete(xml);
+ fclose(xmlFile);
+ fclose(fp);
}
void WriteBRLANTagHeader(tag_header* head, FILE* fp)
{
- fwrite(head, sizeof(tag_header), 1, fp);
+ fwrite(head, sizeof(tag_header), 1, fp);
}
void WriteBRLANTagEntries(tag_entry* entry, u8 count, FILE* fp)
{
- tag_entry writeentry;
- int i;
- for(i = 0; i < count; i++) {
- writeentry.offset = be32(entry[i].offset);
- fwrite(&writeentry, sizeof(tag_entry), 1, fp);
- }
+ tag_entry writeentry;
+ int i;
+ for(i = 0; i < count; i++) {
+ writeentry.offset = be32(entry[i].offset);
+ fwrite(&writeentry, sizeof(tag_entry), 1, fp);
+ }
}
void WriteBRLANOffsets(u32* offsets, u32 number, FILE* fp)
{
- u32 tempoffsets[number];
- int i;
- for(i=0;i<number;i++) tempoffsets[i] = be32(offsets[i]);
- fwrite(tempoffsets, number * sizeof(u32), 1, fp);
+ u32 tempoffsets[number];
+ int i;
+ for(i=0;i<number;i++) tempoffsets[i] = be32(offsets[i]);
+ fwrite(tempoffsets, number * sizeof(u32), 1, fp);
}
void WriteBRLANTagEntryinfos(tag_entryinfo entryinfo, FILE* fp)
{
- tag_entryinfo writeentryinfo;
- writeentryinfo.type = short_swap_bytes(entryinfo.type);
- writeentryinfo.unk1 = short_swap_bytes(entryinfo.unk1);
- writeentryinfo.coord_count = short_swap_bytes(entryinfo.coord_count);
- writeentryinfo.pad1 = short_swap_bytes(entryinfo.pad1);
- writeentryinfo.unk2 = be32(entryinfo.unk2);
- fwrite(&writeentryinfo, sizeof(tag_entryinfo), 1, fp);
+ tag_entryinfo writeentryinfo;
+ writeentryinfo.type1 = entryinfo.type1;
+ writeentryinfo.type2 = entryinfo.type2;
+ writeentryinfo.data_type = short_swap_bytes(entryinfo.data_type);
+ writeentryinfo.coord_count = short_swap_bytes(entryinfo.coord_count);
+ writeentryinfo.pad1 = short_swap_bytes(entryinfo.pad1);
+ writeentryinfo.offset = be32(entryinfo.offset);
+ fwrite(&writeentryinfo, sizeof(tag_entryinfo), 1, fp);
}
void WriteBRLANTagData(tag_data* data, u16 count, FILE* fp)
{
- tag_data writedata;
- int i;
- for(i = 0; i < count; i++) {
- writedata.part1 = be32(data[i].part1);
- writedata.part2 = be32(data[i].part2);
- writedata.part3 = be32(data[i].part3);
- fwrite(&writedata, sizeof(tag_data), 1, fp);
- }
+ tag_data writedata;
+ int i;
+ for(i = 0; i < count; i++) {
+ writedata.part1 = be32(data[i].part1);
+ writedata.part2 = be32(data[i].part2);
+ writedata.part3 = be32(data[i].part3);
+ fwrite(&writedata, sizeof(tag_data), 1, fp);
+ }
}
void WriteBRLANEntry(brlan_entry *entr, FILE* fp)
{
- brlan_entry writeentr;
- memset(writeentr.name, 0, 20);
- strncpy(writeentr.name, entr->name, 20);
- 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);
+ brlan_entry writeentr;
+ memset(writeentr.name, 0, 20);
+ strncpy(writeentr.name, entr->name, 20);
+ 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);
}
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;
- tag_data** data = NULL;
- tag_data2** data2 = NULL;
- mxml_node_t *tempnode = NULL;
- mxml_node_t *subnode = NULL;
- mxml_node_t *subsubnode = NULL;
- char temp[256];
- char temp2[256];
- char temp3[16][24];
- int i, x;
+ tag_entry* entry = NULL;
+ tag_entryinfo* entryinfo = NULL;
+ tag_data** data = NULL;
+ tag_data2** data2 = NULL;
+ mxml_node_t *tempnode = NULL;
+ mxml_node_t *subnode = NULL;
+ mxml_node_t *subsubnode = NULL;
+ char temp[256];
+ char temp2[256];
+ char temp3[16][24];
+ int i, x;
- char tag_type[256];
- if(mxmlElementGetAttr(node, "type") != NULL)
- strcpy(tag_type, mxmlElementGetAttr(node, "type"));
+ char tag_type[256];
+ if(mxmlElementGetAttr(node, "type2") != NULL)
+ strcpy(tag_type, mxmlElementGetAttr(node, "type2"));
- char rlmc_type[5] = {'R', 'L', 'M', 'C'};
- char rlvc_type[5] = {'R', 'L', 'V', 'C'};
+ char rlpa_type[5] = {'R', 'L', 'P', 'A'};
+ char rlts_type[5] = {'R', 'L', 'T', 'S'};
+ char rlvi_type[5] = {'R', 'L', 'V', 'I'};
+ char rlvc_type[5] = {'R', 'L', 'V', 'C'};
+ char rlmc_type[5] = {'R', 'L', 'M', 'C'};
+ char rltp_type[5] = {'R', 'L', 'T', 'P'};
+ char rlim_type[5] = {'R', 'L', 'I', 'M'};
for(i = 0; i < 16; i++)
memset(temp3[i], 0, 24);
for(x = 0; x < 16; x++)
- if(memcmp(tag_type, rlmc_type, 4) == 0)
+ if(memcmp(tag_type, rlpa_type, 4) == 0)
{
- for(i = 0; i < strlen(tag_types_rlmc_list[x]); i++)
+ for(i = 0; i < strlen(tag_types_rlpa_list[x]); i++)
{
- temp3[x][i] = toupper(tag_types_rlmc_list[x][i]);
+ temp3[x][i] = toupper(tag_types_rlpa_list[x][i]);
+ }
+ } else if(memcmp(tag_type, rlts_type, 4) == 0) {
+ for(i = 0; i < strlen(tag_types_rlts_list[x]); i++)
+ {
+ temp3[x][i] = toupper(tag_types_rlts_list[x][i]);
+ }
+ } else if(memcmp(tag_type, rlvi_type, 4) == 0) {
+ for(i = 0; i < strlen(tag_types_rlvi_list[x]); i++)
+ {
+ temp3[x][i] = toupper(tag_types_rlvi_list[x][i]);
}
} else if(memcmp(tag_type, rlvc_type, 4) == 0) {
for(i = 0; i < strlen(tag_types_rlvc_list[x]); i++)
{
temp3[x][i] = toupper(tag_types_rlvc_list[x][i]);
}
- } else {
- for(i = 0; i < strlen(tag_types_list[x]); i++)
+ } else if(memcmp(tag_type, rlmc_type, 4) == 0) {
+ for(i = 0; i < strlen(tag_types_rlmc_list[x]); i++)
{
- temp3[x][i] = toupper(tag_types_list[x][i]);
- }
- }
- head->entry_count = 0;
- subnode = node;
- for (x = 0, subnode = mxmlFindElement(subnode, node, "entry", NULL, NULL, MXML_DESCEND); subnode != NULL; subnode = mxmlFindElement(subnode, node, "entry", NULL, NULL, MXML_DESCEND), x++) {
- head->entry_count++;
- entry = realloc(entry, sizeof(tag_entry) * head->entry_count);
- entryinfo = realloc(entryinfo, sizeof(tag_entryinfo) * head->entry_count);
- if(data == NULL)
- {
- data = (tag_data**)malloc(sizeof(tag_data*) * head->entry_count);
- data2 = (tag_data2**)malloc(sizeof(tag_data2*) * head->entry_count);
- } else {
- data = (tag_data**)realloc(data, sizeof(tag_data*) * head->entry_count);
- data2 = (tag_data2**)realloc(data, sizeof(tag_data2*) * head->entry_count);
- }
- data[x] = NULL;
- data2[x] = NULL;
- memset(temp, 0, 256);
- memset(temp2, 0, 256);
- if(mxmlElementGetAttr(subnode, "type") != NULL)
- strcpy(temp, mxmlElementGetAttr(subnode, "type"));
- else{
- printf("No type attribute found!\nSkipping this entry!\n");
- head->entry_count--;
- continue;
- }
- 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--;
- }
- entry[x].offset = 0;
- entryinfo[x].type = i;
- entryinfo[x].unk1 = 0x0200;
- entryinfo[x].pad1 = 0x0000;
- entryinfo[x].unk2 = 0x0000000C;
- entryinfo[x].coord_count = 0;
- subsubnode = subnode;
- for (i = 0, subsubnode = mxmlFindElement(subsubnode, subnode, "triplet", NULL, NULL, MXML_DESCEND); subsubnode != NULL; subsubnode = mxmlFindElement(subsubnode, subnode, "triplet", NULL, NULL, MXML_DESCEND), i++) {
-
- entryinfo[x].coord_count++;
- data[x] = realloc(data[x], sizeof(tag_data) * entryinfo[x].coord_count);
- tempnode = mxmlFindElement(subsubnode, subsubnode, "frame", NULL, NULL, MXML_DESCEND);
- if(tempnode == NULL) {
- printf("Couldn't find attribute \"frame\"!\n");
- exit(1);
- }
- get_value(tempnode, temp, 256);
- *(f32*)(&(data[x][i].part1)) = atof(temp);
- tempnode = mxmlFindElement(subsubnode, subsubnode, "value", NULL, NULL, MXML_DESCEND);
- if(tempnode == NULL) {
- printf("Couldn't find attribute \"value\"!\n");
- exit(1);
- }
- get_value(tempnode, temp, 256);
- *(f32*)(&(data[x][i].part2)) = atof(temp);
- tempnode = mxmlFindElement(subsubnode, subsubnode, "blend", NULL, NULL, MXML_DESCEND);
- if(tempnode == NULL) {
- printf("Couldn't find attribute \"blend\"!\n");
- exit(1);
- }
- get_value(tempnode, temp, 256);
- *(f32*)(&(data[x][i].part3)) = atof(temp);
- }
- for (i = 0, subsubnode = mxmlFindElement(subnode, subnode, "pair", NULL, NULL, MXML_DESCEND); subsubnode != NULL; subsubnode = mxmlFindElement(subsubnode, subnode, "pair", NULL, NULL, MXML_DESCEND), i++) {
- entryinfo[x].unk1 = 0x100;
- entryinfo[x].coord_count++;
- data2[x] = realloc(data2[x], sizeof(tag_data2) * entryinfo[x].coord_count);
- tempnode = mxmlFindElement(subsubnode, subsubnode, "data1", NULL, NULL, MXML_DESCEND);
- if(tempnode == NULL) {
- printf("Couldn't find attribute \"data1\"!\n");
- exit(1);
- }
- get_value(tempnode, temp, 256);
- *(f32*)(&(data2[x][i].part1)) = atof(temp);
- tempnode = mxmlFindElement(subsubnode, subsubnode, "data2", NULL, NULL, MXML_DESCEND);
- if(tempnode == NULL) {
- printf("Couldn't find attribute \"data2\"!\n");
- exit(1);
- }
- get_value(tempnode, temp, 256);
- data2[x][i].part2 = short_swap_bytes(strtoul(temp, NULL, 16));
- tempnode = mxmlFindElement(subsubnode, subsubnode, "padding", NULL, NULL, MXML_DESCEND);
- if(tempnode == NULL) {
- printf("Couldn't find attribute \"padding\"!\n");
- exit(1);
+ temp3[x][i] = toupper(tag_types_rlmc_list[x][i]);
}
- get_value(tempnode, temp, 256);
- data2[x][i].padding = short_swap_bytes(strtoul(temp, NULL, 16));
- }
- }
-
- head->pad1 = 0x0; head->pad2 = 0x0; head->pad3 = 0x0;
- WriteBRLANTagHeader(head, fp);
- u32 entryloc = ftell(fp);
- u32 animLen;
- WriteBRLANTagEntries(entry, head->entry_count, fp);
- u32* entryinfolocs = (u32*)calloc(head->entry_count, sizeof(u32));
- for(x = 0; x < head->entry_count; x++) {
- entryinfolocs[x] = ftell(fp);
- if (x>0)
- {
- if ( entryinfo[x].unk1 == (0x200) )
+ } else if(memcmp(tag_type, rltp_type, 4) == 0) {
+ for(i = 0; i < strlen(tag_types_rltp_list[x]); i++)
{
- entry[x].offset = entry[x-1].offset + sizeof(tag_entryinfo) + (entryinfo[x-1].coord_count * sizeof(tag_data));
+ temp3[x][i] = toupper(tag_types_rltp_list[x][i]);
}
- if ( entryinfo[x].unk1 == (0x100) )
+ } else if(memcmp(tag_type, rlim_type, 4) == 0) {
+ for(i = 0; i < strlen(tag_types_rlim_list[x]); i++)
{
- entry[x].offset = entry[x-1].offset + sizeof(tag_entryinfo) + (entryinfo[x-1].coord_count * sizeof(tag_data2));
+ temp3[x][i] = toupper(tag_types_rlim_list[x][i]);
}
} else {
- entry[x].offset = x * (sizeof(tag_entryinfo) + sizeof(tag_data));
- }
- WriteBRLANTagEntryinfos(entryinfo[x], fp);
- if (x==0) animLen = ftell(fp);
- if ( entryinfo[x].unk1 == 0x200 )
- WriteBRLANTagData(data[x], entryinfo[x].coord_count, fp);
- if ( entryinfo[x].unk1 == 0x100 )
- {
- tag_data2 writedata;
- for(i = 0; i < entryinfo[x].coord_count; i++) {
- writedata.part1 = be32(data2[x][i].part1);
- writedata.part2 = (data2[x][i].part2);
- writedata.padding = (data2[x][i].padding);
- fwrite(&writedata, sizeof(tag_data2), 1, fp);
+ for(i = 0; i < strlen(tag_types_list[x]); i++)
+ {
+ temp3[x][i] = toupper(tag_types_list[x][i]);
}
}
- }
- if ( entryinfo[0].unk1 == 0x200 )
- free(data);
- if ( entryinfo[0].unk1 == 0x100 )
- free(data2);
- u32 oldpos = ftell(fp);
- fseek(fp, entryloc, SEEK_SET);
- 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);
- free(entry);
- free(entryinfo);
+ head->entry_count = 0;
+ subnode = node;
+ for (x = 0, subnode = mxmlFindElement(subnode, node, "entry", NULL, NULL, MXML_DESCEND); subnode != NULL; subnode = mxmlFindElement(subnode, node, "entry", NULL, NULL, MXML_DESCEND), x++) {
+ head->entry_count++;
+ entry = realloc(entry, sizeof(tag_entry) * head->entry_count);
+ entryinfo = realloc(entryinfo, sizeof(tag_entryinfo) * head->entry_count);
+ if(data == NULL)
+ {
+ data = (tag_data**)malloc(sizeof(tag_data*) * head->entry_count);
+ data2 = (tag_data2**)malloc(sizeof(tag_data2*) * head->entry_count);
+ } else {
+ data = (tag_data**)realloc(data, sizeof(tag_data*) * head->entry_count);
+ data2 = (tag_data2**)realloc(data, sizeof(tag_data2*) * head->entry_count);
+ }
+ data[x] = NULL;
+ data2[x] = NULL;
+ memset(temp, 0, 256);
+ memset(temp2, 0, 256);
+ u8 type1;
+ if(mxmlElementGetAttr(subnode, "type1") != NULL)
+ type1 = strtoul( mxmlElementGetAttr(subnode, "type1") , NULL , 16 );
+ else
+ type1 = 0;
+ if(mxmlElementGetAttr(subnode, "type2") != NULL)
+ strcpy(temp, mxmlElementGetAttr(subnode, "type2"));
+ else{
+ printf("No type attribute found!\nSkipping this entry!\n");
+ head->entry_count--;
+ continue;
+ }
+ 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--;
+ }
+ entry[x].offset = 0;
+ entryinfo[x].type1 = type1;
+ entryinfo[x].type2 = i;
+ entryinfo[x].data_type = 0x0200;
+ entryinfo[x].pad1 = 0x0000;
+ entryinfo[x].offset = 0x0000000C;
+ entryinfo[x].coord_count = 0;
+ subsubnode = subnode;
+ for (i = 0, subsubnode = mxmlFindElement(subsubnode, subnode, "triplet", NULL, NULL, MXML_DESCEND); subsubnode != NULL; subsubnode = mxmlFindElement(subsubnode, subnode, "triplet", NULL, NULL, MXML_DESCEND), i++) {
+
+ entryinfo[x].coord_count++;
+ data[x] = realloc(data[x], sizeof(tag_data) * entryinfo[x].coord_count);
+ tempnode = mxmlFindElement(subsubnode, subsubnode, "frame", NULL, NULL, MXML_DESCEND);
+ if(tempnode == NULL) {
+ printf("Couldn't find attribute \"frame\"!\n");
+ exit(1);
+ }
+ get_value(tempnode, temp, 256);
+ *(f32*)(&(data[x][i].part1)) = atof(temp);
+ tempnode = mxmlFindElement(subsubnode, subsubnode, "value", NULL, NULL, MXML_DESCEND);
+ if(tempnode == NULL) {
+ printf("Couldn't find attribute \"value\"!\n");
+ exit(1);
+ }
+ get_value(tempnode, temp, 256);
+ *(f32*)(&(data[x][i].part2)) = atof(temp);
+ tempnode = mxmlFindElement(subsubnode, subsubnode, "blend", NULL, NULL, MXML_DESCEND);
+ if(tempnode == NULL) {
+ printf("Couldn't find attribute \"blend\"!\n");
+ exit(1);
+ }
+ get_value(tempnode, temp, 256);
+ *(f32*)(&(data[x][i].part3)) = atof(temp);
+ }
+ for (i = 0, subsubnode = mxmlFindElement(subnode, subnode, "pair", NULL, NULL, MXML_DESCEND); subsubnode != NULL; subsubnode = mxmlFindElement(subsubnode, subnode, "pair", NULL, NULL, MXML_DESCEND), i++) {
+ entryinfo[x].data_type = 0x100;
+ entryinfo[x].coord_count++;
+ data2[x] = realloc(data2[x], sizeof(tag_data2) * entryinfo[x].coord_count);
+ tempnode = mxmlFindElement(subsubnode, subsubnode, "data1", NULL, NULL, MXML_DESCEND);
+ if(tempnode == NULL) {
+ printf("Couldn't find attribute \"data1\"!\n");
+ exit(1);
+ }
+ get_value(tempnode, temp, 256);
+ *(f32*)(&(data2[x][i].part1)) = atof(temp);
+ tempnode = mxmlFindElement(subsubnode, subsubnode, "data2", NULL, NULL, MXML_DESCEND);
+ if(tempnode == NULL) {
+ printf("Couldn't find attribute \"data2\"!\n");
+ exit(1);
+ }
+ get_value(tempnode, temp, 256);
+ data2[x][i].part2 = short_swap_bytes(strtoul(temp, NULL, 16));
+ tempnode = mxmlFindElement(subsubnode, subsubnode, "padding", NULL, NULL, MXML_DESCEND);
+ if(tempnode == NULL) {
+ printf("Couldn't find attribute \"padding\"!\n");
+ exit(1);
+ }
+ get_value(tempnode, temp, 256);
+ data2[x][i].padding = short_swap_bytes(strtoul(temp, NULL, 16));
+ }
+ }
+
+ head->pad1 = 0x0; head->pad2 = 0x0; head->pad3 = 0x0;
+ WriteBRLANTagHeader(head, fp);
+ u32 entryloc = ftell(fp);
+ u32 animLen;
+ WriteBRLANTagEntries(entry, head->entry_count, fp);
+ u32* entryinfolocs = (u32*)calloc(head->entry_count, sizeof(u32));
+ for(x = 0; x < head->entry_count; x++) {
+ entryinfolocs[x] = ftell(fp);
+ if (x>0)
+ {
+ if ( entryinfo[x].data_type == (0x200) )
+ {
+ entry[x].offset = entry[x-1].offset + sizeof(tag_entryinfo) + (entryinfo[x-1].coord_count * sizeof(tag_data));
+ }
+ if ( entryinfo[x].data_type == (0x100) )
+ {
+ entry[x].offset = entry[x-1].offset + sizeof(tag_entryinfo) + (entryinfo[x-1].coord_count * sizeof(tag_data2));
+ }
+ } else {
+ entry[x].offset = x * (sizeof(tag_entryinfo) + sizeof(tag_data));
+ }
+ WriteBRLANTagEntryinfos(entryinfo[x], fp);
+ if (x==0) animLen = ftell(fp);
+ if ( entryinfo[x].data_type == 0x200 )
+ WriteBRLANTagData(data[x], entryinfo[x].coord_count, fp);
+ if ( entryinfo[x].data_type == 0x100 )
+ {
+ tag_data2 writedata;
+ for(i = 0; i < entryinfo[x].coord_count; i++) {
+ writedata.part1 = be32(data2[x][i].part1);
+ writedata.part2 = (data2[x][i].part2);
+ writedata.padding = (data2[x][i].padding);
+ fwrite(&writedata, sizeof(tag_data2), 1, fp);
+ }
+ }
+ }
+ if ( entryinfo[0].data_type == 0x200 )
+ free(data);
+ if ( entryinfo[0].data_type == 0x100 )
+ free(data2);
+ u32 oldpos = ftell(fp);
+ fseek(fp, entryloc, SEEK_SET);
+ 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);
+ free(entry);
+ free(entryinfo);
}
void create_tag_from_xml(mxml_node_t *tree, mxml_node_t *node, FILE* fp)
{
- brlan_entry entr;
- entr.num_tags = 0x0;
- entr.is_material = 0x0;
- entr.pad[0] = 0x0;
- entr.pad[1] = 0x0;
+ brlan_entry entr;
+ entr.num_tags = 0x0;
+ entr.is_material = 0x0;
+ entr.pad[0] = 0x0;
+ entr.pad[1] = 0x0;
- char temp[256];
- memset(entr.name, 0, 20);
- if(mxmlElementGetAttr(node, "name") != NULL)
- strcpy(entr.name, mxmlElementGetAttr(node, "name"));
- else{
- }
- if(mxmlElementGetAttr(node, "type") != NULL) {
- strcpy(temp, mxmlElementGetAttr(node, "type"));
- entr.is_material = (u8)atoi(temp);
- } else {
- }
+ char temp[256];
+ memset(entr.name, 0, 20);
+ if(mxmlElementGetAttr(node, "name") != NULL)
+ strcpy(entr.name, mxmlElementGetAttr(node, "name"));
+ else{
+ }
+ if(mxmlElementGetAttr(node, "type") != NULL) {
+ strcpy(temp, mxmlElementGetAttr(node, "type"));
+ entr.is_material = (u8)atoi(temp);
+ } else {
+ }
-
- tag_header head;
- mxml_node_t *tagnode;
- for(tagnode = mxmlFindElement(node, node, "tag", NULL, NULL, MXML_DESCEND); tagnode != NULL; tagnode = mxmlFindElement(tagnode, node, "tag", NULL, NULL, MXML_DESCEND))
- {
- entr.num_tags++;
- }
- u32 brlanentryoffset = ftell(fp);
- WriteBRLANEntry(&entr, fp);
-
- u32 entrylocations[entr.num_tags];
- int i; for ( i = 0; i < entr.num_tags; i++) entrylocations[i] = brlanentryoffset;
- WriteBRLANOffsets(entrylocations, entr.num_tags, fp);
-
- entr.num_tags = 0x0;
- for(tagnode = mxmlFindElement(node, node, "tag", NULL, NULL, MXML_DESCEND); tagnode != NULL; tagnode = mxmlFindElement(tagnode, node, "tag", NULL, NULL, MXML_DESCEND))
- {
- entrylocations[entr.num_tags] = ftell(fp) - entrylocations[entr.num_tags];
- if(mxmlElementGetAttr(tagnode, "type") != NULL)
- strcpy(temp, mxmlElementGetAttr(tagnode, "type"));
- else {
- printf("No type attribute found!\nQuitting!\n");
- exit(1);
- }
- for ( i = 0; i < 4; i++) head.magic[i] = temp[i];
- if (FourCCInList(head.magic) == 0)
+ tag_header head;
+ mxml_node_t *tagnode;
+ for(tagnode = mxmlFindElement(node, node, "tag", NULL, NULL, MXML_DESCEND); tagnode != NULL; tagnode = mxmlFindElement(tagnode, node, "tag", NULL, NULL, MXML_DESCEND))
{
- printf("animation type not recognized: %.4s", head.magic);
- exit(1);
- }
- create_entries_from_xml(node, tagnode, &entr, &head, fp);
- entr.num_tags++;
- }
- u32 tempOffset = ftell(fp);
- fseek(fp, brlanentryoffset + sizeof(brlan_entry), SEEK_SET);
- WriteBRLANOffsets(entrylocations, entr.num_tags, fp);
- fseek(fp, tempOffset, SEEK_SET);
+ entr.num_tags++;
+ }
+ u32 brlanentryoffset = ftell(fp);
+ WriteBRLANEntry(&entr, fp);
+
+ u32 entrylocations[entr.num_tags];
+ int i; for ( i = 0; i < entr.num_tags; i++) entrylocations[i] = brlanentryoffset;
+ WriteBRLANOffsets(entrylocations, entr.num_tags, fp);
+
+ entr.num_tags = 0x0;
+ for(tagnode = mxmlFindElement(node, node, "tag", NULL, NULL, MXML_DESCEND); tagnode != NULL; tagnode = mxmlFindElement(tagnode, node, "tag", NULL, NULL, MXML_DESCEND))
+ {
+ entrylocations[entr.num_tags] = ftell(fp) - entrylocations[entr.num_tags];
+ if(mxmlElementGetAttr(tagnode, "type") != NULL)
+ strcpy(temp, mxmlElementGetAttr(tagnode, "type"));
+ else {
+ printf("No type attribute found!\nQuitting!\n");
+ exit(1);
+ }
+ for ( i = 0; i < 4; i++) head.magic[i] = temp[i];
+ if (FourCCInList(head.magic) == 0)
+ {
+ printf("animation type not recognized: %.4s", head.magic);
+ exit(1);
+ }
+ create_entries_from_xml(node, tagnode, &entr, &head, fp);
+ entr.num_tags++;
+ }
+ u32 tempOffset = ftell(fp);
+ fseek(fp, brlanentryoffset + sizeof(brlan_entry), SEEK_SET);
+ WriteBRLANOffsets(entrylocations, entr.num_tags, fp);
+ fseek(fp, tempOffset, SEEK_SET);
}
void WriteBRLANHeader(brlan_header rlanhead, FILE* fp)
{
- brlan_header writehead;
- writehead.magic[0] = rlanhead.magic[0];
- writehead.magic[1] = rlanhead.magic[1];
- writehead.magic[2] = rlanhead.magic[2];
- writehead.magic[3] = rlanhead.magic[3];
- writehead.unk1 = be32(rlanhead.unk1);
- writehead.file_size = be32(rlanhead.file_size);
- writehead.pai1_offset = short_swap_bytes(rlanhead.pai1_offset);
- writehead.pai1_count = short_swap_bytes(rlanhead.pai1_count);
- fwrite(&writehead, sizeof(brlan_header), 1, fp);
+ brlan_header writehead;
+ writehead.magic[0] = rlanhead.magic[0];
+ writehead.magic[1] = rlanhead.magic[1];
+ writehead.magic[2] = rlanhead.magic[2];
+ writehead.magic[3] = rlanhead.magic[3];
+ writehead.version = be32(rlanhead.version);
+ writehead.file_size = be32(rlanhead.file_size);
+ writehead.pai1_offset = short_swap_bytes(rlanhead.pai1_offset);
+ writehead.pai1_count = short_swap_bytes(rlanhead.pai1_count);
+ fwrite(&writehead, sizeof(brlan_header), 1, fp);
}
void WriteBRLANPaiHeader(brlan_pai1_header_type1 paihead, FILE* fp)
{
- brlan_pai1_header_type1 writehead;
- writehead.magic[0] = paihead.magic[0];
- writehead.magic[1] = paihead.magic[1];
- writehead.magic[2] = paihead.magic[2];
- writehead.magic[3] = paihead.magic[3];
- writehead.size = be32(paihead.size);
- writehead.framesize = short_swap_bytes(paihead.framesize);
- writehead.flags = paihead.flags;
- writehead.unk1 = paihead.unk1;
- writehead.num_timgs = short_swap_bytes(paihead.num_timgs);
- writehead.num_entries = short_swap_bytes(paihead.num_entries);
- writehead.entry_offset = be32(paihead.entry_offset);
- fwrite(&writehead, sizeof(brlan_pai1_header_type1), 1, fp);
+ brlan_pai1_header_type1 writehead;
+ writehead.magic[0] = paihead.magic[0];
+ writehead.magic[1] = paihead.magic[1];
+ writehead.magic[2] = paihead.magic[2];
+ writehead.magic[3] = paihead.magic[3];
+ writehead.size = be32(paihead.size);
+ writehead.framesize = short_swap_bytes(paihead.framesize);
+ writehead.flags = paihead.flags;
+ writehead.padding = paihead.padding;
+ writehead.num_timgs = short_swap_bytes(paihead.num_timgs);
+ writehead.num_entries = short_swap_bytes(paihead.num_entries);
+ writehead.entry_offset = be32(paihead.entry_offset);
+ fwrite(&writehead, sizeof(brlan_pai1_header_type1), 1, fp);
}
void write_brlan(char *infile, char* outfile)
{
- int i;
- for(i = 0; i < 16; i++)
- {
- memset(tag_types_list[i], 0, 24);
- memset(tag_types_rlmc_list[i], 0, 24);
- memset(tag_types_rlvc_list[i], 0, 24);
- }
- strcpy(tag_types_list[0], "X Translation");
- strcpy(tag_types_list[1], "Y Translation");
- strcpy(tag_types_list[2], "Z Translation");
- strcpy(tag_types_list[3], "X Flip");
- strcpy(tag_types_list[4], "Y Flip");
- strcpy(tag_types_list[5], "Angle");
- strcpy(tag_types_list[6], "X Zoom");
- strcpy(tag_types_list[7], "Y Zoom");
- strcpy(tag_types_list[8], "Width");
- strcpy(tag_types_list[9], "Height");
- strcpy(tag_types_list[10], "0x0A");
- strcpy(tag_types_list[11], "0x0B");
- strcpy(tag_types_list[12], "0x0C");
- strcpy(tag_types_list[13], "0x0D");
- strcpy(tag_types_list[14], "0x0E");
- strcpy(tag_types_list[15], "0x0F");
+ int i;
+ for(i = 0; i < 16; i++)
+ {
+ memset(tag_types_list[i], 0, 24);
+ memset(tag_types_rlpa_list[i], 0, 24);
+ memset(tag_types_rlts_list[i], 0, 24);
+ memset(tag_types_rlvi_list[i], 0, 24);
+ memset(tag_types_rlvc_list[i], 0, 24);
+ memset(tag_types_rlmc_list[i], 0, 24);
+ memset(tag_types_rltp_list[i], 0, 24);
+ memset(tag_types_rlim_list[i], 0, 24);
+ }
- strcpy(tag_types_rlmc_list[0], "0x00");
- strcpy(tag_types_rlmc_list[1], "0x01");
- strcpy(tag_types_rlmc_list[2], "0x02");
- strcpy(tag_types_rlmc_list[3], "0x03");
- strcpy(tag_types_rlmc_list[4], "Blackcolor R");
- strcpy(tag_types_rlmc_list[5], "Blackcolor G");
- strcpy(tag_types_rlmc_list[6], "Blackcolor B");
- strcpy(tag_types_rlmc_list[7], "Blackcolor A");
- strcpy(tag_types_rlmc_list[8], "Whitecolor R");
- strcpy(tag_types_rlmc_list[9], "Whitecolor G");
- strcpy(tag_types_rlmc_list[10], "Whitecolor B");
- strcpy(tag_types_rlmc_list[11], "Whitecolor A");
- strcpy(tag_types_rlmc_list[12], "0x0C");
- strcpy(tag_types_rlmc_list[13], "0x0D");
- strcpy(tag_types_rlmc_list[14], "0x0E");
- strcpy(tag_types_rlmc_list[15], "0x0F");
+ strcpy(tag_types_list[0], "X Translation");
+ strcpy(tag_types_list[1], "Y Translation");
+ strcpy(tag_types_list[2], "Z Translation");
+ strcpy(tag_types_list[3], "X Rotate");
+ strcpy(tag_types_list[4], "Y Rotate");
+ strcpy(tag_types_list[5], "Z Rotate");
+ strcpy(tag_types_list[6], "X Scale");
+ strcpy(tag_types_list[7], "Y Scale");
+ strcpy(tag_types_list[8], "Width");
+ strcpy(tag_types_list[9], "Height");
+ strcpy(tag_types_list[10], "0x0A");
+ strcpy(tag_types_list[11], "0x0B");
+ strcpy(tag_types_list[12], "0x0C");
+ strcpy(tag_types_list[13], "0x0D");
+ strcpy(tag_types_list[14], "0x0E");
+ strcpy(tag_types_list[15], "0x0F");
- strcpy(tag_types_rlvc_list[0], "Top Left R");
- strcpy(tag_types_rlvc_list[1], "Top Left G");
- strcpy(tag_types_rlvc_list[2], "Top Left B");
- strcpy(tag_types_rlvc_list[3], "Top Left A");
- strcpy(tag_types_rlvc_list[4], "Top Right R");
- strcpy(tag_types_rlvc_list[5], "Top Right G");
- strcpy(tag_types_rlvc_list[6], "Top Right B");
- strcpy(tag_types_rlvc_list[7], "Top Right A");
- strcpy(tag_types_rlvc_list[8], "Bottom Left R");
- strcpy(tag_types_rlvc_list[9], "Bottom Left G");
- strcpy(tag_types_rlvc_list[10], "Bottom Left B");
- strcpy(tag_types_rlvc_list[11], "Bottom Left A");
- strcpy(tag_types_rlvc_list[12], "Bottom Right R");
- strcpy(tag_types_rlvc_list[13], "Bottom Right G");
- strcpy(tag_types_rlvc_list[14], "Bottom Right B");
- strcpy(tag_types_rlvc_list[15], "Bottom Right A");
+ strcpy(tag_types_rlts_list[0], "XTrans");
+ strcpy(tag_types_rlts_list[1], "YTrans");
+ strcpy(tag_types_rlts_list[2], "Rotate");
+ strcpy(tag_types_rlts_list[3], "XScale");
+ strcpy(tag_types_rlts_list[4], "YScale");
- FILE* fpx = fopen(infile, "r");
- if(fpx == NULL) {
- printf("xmlan couldn't be opened!\n");
- exit(1);
- }
- mxml_node_t *hightree = mxmlLoadFile(NULL, fpx, MXML_TEXT_CALLBACK);
- if(hightree == NULL) {
- printf("Couldn't open hightree!\n");
- exit(1);
- }
- mxml_node_t *tree = mxmlFindElement(hightree, hightree, "xmlan", NULL, NULL, MXML_DESCEND);
- if(hightree == NULL) {
- printf("Couldn't get tree!\n");
- exit(1);
- }
- mxml_node_t *node;
- FILE* fp = fopen(outfile, "wb+");
- if(fpx == NULL) {
- printf("destination brlan couldn't be opened!\n");
- exit(1);
- }
- u16 blobcount = 0;
- brlan_header rlanhead;
- rlanhead.magic[0] = 'R';
- rlanhead.magic[1] = 'L';
- rlanhead.magic[2] = 'A';
- rlanhead.magic[3] = 'N';
- rlanhead.unk1 = 0xFEFF0008;
- rlanhead.file_size = 0;
- rlanhead.pai1_offset = sizeof(brlan_header);
- rlanhead.pai1_count = 1;
- WriteBRLANHeader(rlanhead, fp);
- brlan_pai1_header_type1 paihead;
- paihead.magic[0] = 'p';
- paihead.magic[1] = 'a';
- paihead.magic[2] = 'i';
- paihead.magic[3] = '1';
- paihead.size = 0;
- char temp[256];
- if(mxmlElementGetAttr(tree, "framesize") != NULL)
- strcpy(temp, mxmlElementGetAttr(tree, "framesize"));
- else{
- printf("No framesize attribute found!\nDefaulting to 20.");
- strcpy(temp, "20");
- }
- paihead.framesize = atoi(temp);
- memset(temp, 0, 256);
- if(mxmlElementGetAttr(tree, "flags") != NULL)
- {
- strcpy(temp, mxmlElementGetAttr(tree, "flags"));
- } else {
- printf("No flags attribute found!\nDefaulting to 1.");
- paihead.flags = 1;
- }
- paihead.flags = atoi(temp);
- paihead.unk1 = 0;
- paihead.num_timgs = 0;
- paihead.num_entries = 0;
- paihead.entry_offset = sizeof(brlan_pai1_header_type1);
- WriteBRLANPaiHeader(paihead, fp);
+ strcpy(tag_types_rlvi_list[0], "Visibility");
- u32 totaltagsize = 0;
+ strcpy(tag_types_rlvc_list[0], "Top Left R");
+ strcpy(tag_types_rlvc_list[1], "Top Left G");
+ strcpy(tag_types_rlvc_list[2], "Top Left B");
+ strcpy(tag_types_rlvc_list[3], "Top Left A");
+ strcpy(tag_types_rlvc_list[4], "Top Right R");
+ strcpy(tag_types_rlvc_list[5], "Top Right G");
+ strcpy(tag_types_rlvc_list[6], "Top Right B");
+ strcpy(tag_types_rlvc_list[7], "Top Right A");
+ strcpy(tag_types_rlvc_list[8], "Bottom Left R");
+ strcpy(tag_types_rlvc_list[9], "Bottom Left G");
+ strcpy(tag_types_rlvc_list[10], "Bottom Left B");
+ strcpy(tag_types_rlvc_list[11], "Bottom Left A");
+ strcpy(tag_types_rlvc_list[12], "Bottom Right R");
+ strcpy(tag_types_rlvc_list[13], "Bottom Right G");
+ strcpy(tag_types_rlvc_list[14], "Bottom Right B");
+ strcpy(tag_types_rlvc_list[15], "Bottom Right A");
- u16 timgcount = 0;
- u32 totaltimgize = 0;
-
- u32 timgnumber = 0x0;
- for(node = mxmlFindElement(tree, tree, "timg", NULL, NULL, MXML_DESCEND); node != NULL; node = mxmlFindElement(node, tree, "timg", NULL, NULL, MXML_DESCEND))
- {
- timgnumber++;
- }
- u32 imageoffsets[timgnumber];
- u32 imagefileoffset = ftell(fp);
- for( i = 0; i < timgnumber; i++) imageoffsets[i] = imagefileoffset;
- WriteBRLANOffsets(imageoffsets, timgnumber, fp);
-
- for(node = mxmlFindElement(tree, tree, "timg", NULL, NULL, MXML_DESCEND); node != NULL; node = mxmlFindElement(node, tree, "timg", NULL, NULL, MXML_DESCEND)) {
- timgcount++;
- imageoffsets[timgcount-1] = ftell(fp) - imageoffsets[timgcount-1];
- if(mxmlElementGetAttr(node, "name") != NULL)
- strcpy(temp, mxmlElementGetAttr(node, "name"));
- else{
- printf("No name attribute found!\n");
- exit(1);
- }
- fwrite(temp, strlen(temp) + 1, 1, fp);
- totaltimgize += strlen(temp) + 1;
- }
- if ((totaltimgize % 4) != 0)
- {
- u8 blank[3] = {0x0, 0x0, 0x0};
- fwrite(blank, (4 - (totaltimgize % 4)), 1, fp);
- totaltimgize += (4 - (totaltimgize % 4));
- }
- u32 tempoOffset = ftell(fp);
- fseek(fp, imagefileoffset, SEEK_SET);
- WriteBRLANOffsets(imageoffsets, timgnumber, fp);
- fseek(fp, tempoOffset, SEEK_SET);
+ strcpy(tag_types_rlmc_list[0], "0x00");
+ strcpy(tag_types_rlmc_list[1], "0x01");
+ strcpy(tag_types_rlmc_list[2], "0x02");
+ strcpy(tag_types_rlmc_list[3], "0x03");
+ strcpy(tag_types_rlmc_list[4], "Blackcolor R");
+ strcpy(tag_types_rlmc_list[5], "Blackcolor G");
+ strcpy(tag_types_rlmc_list[6], "Blackcolor B");
+ strcpy(tag_types_rlmc_list[7], "Blackcolor A");
+ strcpy(tag_types_rlmc_list[8], "Whitecolor R");
+ strcpy(tag_types_rlmc_list[9], "Whitecolor G");
+ strcpy(tag_types_rlmc_list[10], "Whitecolor B");
+ strcpy(tag_types_rlmc_list[11], "Whitecolor A");
+ strcpy(tag_types_rlmc_list[12], "0x0C");
+ strcpy(tag_types_rlmc_list[13], "0x0D");
+ strcpy(tag_types_rlmc_list[14], "0x0E");
+ strcpy(tag_types_rlmc_list[15], "0x0F");
+
+ strcpy(tag_types_rltp_list[0], "PaletteZero");
+ strcpy(tag_types_rltp_list[1], "PaletteOne");
+ strcpy(tag_types_rltp_list[2], "PaletteTwo");
+ strcpy(tag_types_rltp_list[3], "PaletteThree");
+ strcpy(tag_types_rltp_list[4], "PaletteFour");
+ strcpy(tag_types_rltp_list[5], "PaletteFive");
+ strcpy(tag_types_rltp_list[6], "PaletteSix");
+ strcpy(tag_types_rltp_list[7], "PaletteSeven");
+ strcpy(tag_types_rltp_list[8], "PaletteEight");
+ strcpy(tag_types_rltp_list[9], "PaletteNine");
+ strcpy(tag_types_rltp_list[10], "PaletteTen");
+ strcpy(tag_types_rltp_list[11], "PaletteEleven");
+ strcpy(tag_types_rltp_list[12], "PaletteTwelve");
+ strcpy(tag_types_rltp_list[13], "PaletteThirteen");
+ strcpy(tag_types_rltp_list[14], "PaletteFourteen");
+ strcpy(tag_types_rltp_list[15], "PaletteFifteen");
+
+ strcpy(tag_types_rlim_list[0], "XTrans");
+ strcpy(tag_types_rlim_list[1], "YTrans");
+ strcpy(tag_types_rlim_list[2], "Rotate");
+ strcpy(tag_types_rlim_list[3], "XScale");
+ strcpy(tag_types_rlim_list[4], "YScale");
+
+ FILE* fpx = fopen(infile, "r");
+ if(fpx == NULL) {
+ printf("xmlan couldn't be opened!\n");
+ exit(1);
+ }
+ mxml_node_t *hightree = mxmlLoadFile(NULL, fpx, MXML_TEXT_CALLBACK);
+ if(hightree == NULL) {
+ printf("Couldn't open hightree!\n");
+ exit(1);
+ }
+ mxml_node_t *tree = mxmlFindElement(hightree, hightree, "xmlan", NULL, NULL, MXML_DESCEND);
+ if(hightree == NULL) {
+ printf("Couldn't get tree!\n");
+ exit(1);
+ }
+ mxml_node_t *node;
+ FILE* fp = fopen(outfile, "wb+");
+ if(fpx == NULL) {
+ printf("destination brlan couldn't be opened!\n");
+ exit(1);
+ }
+ u16 blobcount = 0;
+ brlan_header rlanhead;
+ rlanhead.magic[0] = 'R';
+ rlanhead.magic[1] = 'L';
+ rlanhead.magic[2] = 'A';
+ rlanhead.magic[3] = 'N';
+ rlanhead.version = 0xFEFF0008;
+ rlanhead.file_size = 0;
+ rlanhead.pai1_offset = sizeof(brlan_header);
+ rlanhead.pai1_count = 1;
+ WriteBRLANHeader(rlanhead, fp);
+ brlan_pai1_header_type1 paihead;
+ paihead.magic[0] = 'p';
+ paihead.magic[1] = 'a';
+ paihead.magic[2] = 'i';
+ paihead.magic[3] = '1';
+ paihead.size = 0;
+ char temp[256];
+ if(mxmlElementGetAttr(tree, "framesize") != NULL)
+ strcpy(temp, mxmlElementGetAttr(tree, "framesize"));
+ else{
+ printf("No framesize attribute found!\nDefaulting to 20.");
+ strcpy(temp, "20");
+ }
+ paihead.framesize = atoi(temp);
+ memset(temp, 0, 256);
+ if(mxmlElementGetAttr(tree, "flags") != NULL)
+ {
+ strcpy(temp, mxmlElementGetAttr(tree, "flags"));
+ } else {
+ printf("No flags attribute found!\nDefaulting to 1.");
+ paihead.flags = 1;
+ }
+ paihead.flags = atoi(temp);
+ paihead.padding = 0;
+ paihead.num_timgs = 0;
+ paihead.num_entries = 0;
+ paihead.entry_offset = sizeof(brlan_pai1_header_type1);
+ WriteBRLANPaiHeader(paihead, fp);
- u32 panecount = 0x0;
- for(node = mxmlFindElement(tree, tree, "pane", NULL, NULL, MXML_DESCEND); node != NULL; node = mxmlFindElement(node, tree, "pane", NULL, NULL, MXML_DESCEND))
- {
- panecount++;
- }
- u32 paneoffsets[panecount];
- u32 tagoffset = ftell(fp);
- for(i = 0; i < panecount; i++) paneoffsets[i] = 0x10;
- WriteBRLANOffsets(paneoffsets, panecount, fp);
+ u32 totaltagsize = 0;
+
+ u16 timgcount = 0;
+ u32 totaltimgize = 0;
- for(node = mxmlFindElement(tree, tree, "pane", NULL, NULL, MXML_DESCEND); node != NULL; node = mxmlFindElement(node, tree, "pane", NULL, NULL, MXML_DESCEND))
- {
- blobcount++;
- paneoffsets[blobcount-1] = ftell(fp) - paneoffsets[blobcount-1];
- create_tag_from_xml(tree, node, fp);
- totaltagsize = ftell(fp) - tagoffset;
- }
- u32 fileSize = ftell(fp);
- fseek(fp, tagoffset, SEEK_SET);
- WriteBRLANOffsets(paneoffsets, blobcount, fp);
+ u32 timgnumber = 0x0;
+ for(node = mxmlFindElement(tree, tree, "timg", NULL, NULL, MXML_DESCEND); node != NULL; node = mxmlFindElement(node, tree, "timg", NULL, NULL, MXML_DESCEND))
+ {
+ timgnumber++;
+ }
+ u32 imageoffsets[timgnumber];
+ u32 imagefileoffset = ftell(fp);
+ for( i = 0; i < timgnumber; i++) imageoffsets[i] = imagefileoffset;
+ WriteBRLANOffsets(imageoffsets, timgnumber, fp);
+ for(node = mxmlFindElement(tree, tree, "timg", NULL, NULL, MXML_DESCEND); node != NULL; node = mxmlFindElement(node, tree, "timg", NULL, NULL, MXML_DESCEND)) {
+ timgcount++;
+ imageoffsets[timgcount-1] = ftell(fp) - imageoffsets[timgcount-1];
+ if(mxmlElementGetAttr(node, "name") != NULL)
+ strcpy(temp, mxmlElementGetAttr(node, "name"));
+ else{
+ printf("No name attribute found!\n");
+ exit(1);
+ }
+ fwrite(temp, strlen(temp) + 1, 1, fp);
+ totaltimgize += strlen(temp) + 1;
+ }
+ if ((totaltimgize % 4) != 0)
+ {
+ u8 blank[3] = {0x0, 0x0, 0x0};
+ fwrite(blank, (4 - (totaltimgize % 4)), 1, fp);
+ totaltimgize += (4 - (totaltimgize % 4));
+ }
+ u32 tempoOffset = ftell(fp);
+ fseek(fp, imagefileoffset, SEEK_SET);
+ WriteBRLANOffsets(imageoffsets, timgnumber, fp);
+ fseek(fp, tempoOffset, SEEK_SET);
+
+ u32 panecount = 0x0;
+ for(node = mxmlFindElement(tree, tree, "pane", NULL, NULL, MXML_DESCEND); node != NULL; node = mxmlFindElement(node, tree, "pane", NULL, NULL, MXML_DESCEND))
+ {
+ panecount++;
+ }
+ u32 paneoffsets[panecount];
+ u32 tagoffset = ftell(fp);
+ for(i = 0; i < panecount; i++) paneoffsets[i] = 0x10;
+ WriteBRLANOffsets(paneoffsets, panecount, fp);
+
+ for(node = mxmlFindElement(tree, tree, "pane", NULL, NULL, MXML_DESCEND); node != NULL; node = mxmlFindElement(node, tree, "pane", NULL, NULL, MXML_DESCEND))
+ {
+ blobcount++;
+ paneoffsets[blobcount-1] = ftell(fp) - paneoffsets[blobcount-1];
+ create_tag_from_xml(tree, node, fp);
+ totaltagsize = ftell(fp) - tagoffset;
+ }
+ u32 fileSize = ftell(fp);
+ fseek(fp, tagoffset, SEEK_SET);
+ WriteBRLANOffsets(paneoffsets, blobcount, fp);
+
- paihead.num_timgs = timgcount;
- paihead.entry_offset = sizeof(brlan_pai1_header_type1) + totaltimgize + (4*paihead.num_timgs);
- paihead.num_entries = blobcount;
- fseek(fp, 0, SEEK_END);
- paihead.size = fileSize - rlanhead.pai1_offset;
- rlanhead.file_size = fileSize;
- fseek(fp, 0, SEEK_SET);
- WriteBRLANHeader(rlanhead, fp);
- WriteBRLANPaiHeader(paihead, fp);
+ paihead.num_timgs = timgcount;
+ paihead.entry_offset = sizeof(brlan_pai1_header_type1) + totaltimgize + (4*paihead.num_timgs);
+ paihead.num_entries = blobcount;
+ fseek(fp, 0, SEEK_END);
+ paihead.size = fileSize - rlanhead.pai1_offset;
+ rlanhead.file_size = fileSize;
+ fseek(fp, 0, SEEK_SET);
+ WriteBRLANHeader(rlanhead, fp);
+ WriteBRLANPaiHeader(paihead, fp);
}
void make_brlan(char* infile, char* outfile)
{
- printf("Parsing XMLAN @ %s.\n", infile);
- write_brlan(infile, outfile);
+ printf("Parsing XMLAN @ %s.\n", infile);
+ write_brlan(infile, outfile);
}
diff --git a/brlan.h b/brlan.h
index 2d7b1cb..5617185 100755
--- a/brlan.h
+++ b/brlan.h
@@ -12,104 +12,122 @@
typedef enum
{
- RLPA_ENTRY = 0,
- RLTS_ENTRY = 1,
- RLVI_ENTRY = 2,
- RLVC_ENTRY = 3,
- RLMC_ENTRY = 4,
- RLTP_ENTRY = 5,
- RLIM_ENTRY
+ RLPA_ENTRY = 0, // Pane Animation .aka. Pane variable animation
+ // byte 1 not used byte 2 is which variable
+ // *( &pane.XTrans + type2<<2 ) = result
+ RLTS_ENTRY = 1, // Texture ScaleRotateTranslate Mapping
+ // byte 1 is which SRT and byte 2 is which elem.
+ // *( GetTexSRTArray()[type1] + (type2*4) ) = result
+ RLVI_ENTRY = 2, // Visibility // stores data2 to bottom of flag1
+ // bytes 1 and 2 arent' used
+ // ( pane.flag1 & 0xfe ) |= ( result & 0x01 )
+ RLVC_ENTRY = 3, // Vertex Color // byte2 is passed to Pane::SetColorElement();
+ // byte 1 not used byte 2 is which vertex and color
+ // 16-19 goes to unknown vars
+ // 20-23 goes to textureCoordinate pointer :D
+ // Pane::SetColorElement( type2 , result );
+ RLMC_ENTRY = 4, // Material Color
+ // byte1 is not used byte 2 is which color
+ // Material::SetColorElement( type2 , color );
+ RLTP_ENTRY = 5, // TPL Pallete
+ // byte 1 is which Texture byte 2 must be 0
+ // SetTextureNoWrap( type1 , (return_val<<2) + anim_basic.pointer2 );
+ RLIM_ENTRY // IndTexSRTAry Material
+ // byte 1 is which SRT and byte 2 is which elem.
+ // *( GetIndTexSRTArray()[type1] + (type2*4) ) = result
} brlan_entry_type;
typedef struct
{
- fourcc magic; // "pai1" in ASCII.
- u32 size; // Size of section, which is rest of the file. (header.file_size - header.offset_pai1)
- 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.)
+ fourcc magic; // "pai1" in ASCII.
+ u32 size; // Size of section, which is rest of the file. (header.file_size - header.offset_pai1)
+ u16 framesize; // Framesize
+ u8 flags; // Flags // isLoopData
+ u8 padding; // Padding
+ u16 num_timgs; // Number of timgs?
+ u16 num_entries; // Number of tags in the brlan.
+ u32 padding2; // Only if bit 25 of flags is set.
+ u32 entry_offset; // Offset to entries. (Relative to start of pai1 header.)
} brlan_pai1_header_type2;
typedef struct
{
- 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.
- u16 pai1_count; // How many pai1 sections there are (duh, only 1... wtf?)
+ fourcc magic; // "RLAN" in ASCII.
+ u32 version; // 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.
+ u16 pai1_count; // How many pai1 sections there are (duh, only 1... wtf?)
} brlan_header;
typedef struct
{
- fourcc magic; // "pai1" in ASCII.
- u32 size; // Size of section, which is rest of the file. (header.file_size - header.offset_pai1)
- u16 framesize; // Framesize
- u8 flags; // Flags
- u8 unk1; // Unknown
- u16 num_timgs; // Number of timgs?
- u16 num_entries; // Number of tags in the brlan.
+ fourcc magic; // "pai1" in ASCII.
+ u32 size; // Size of section, which is rest of the file. (header.file_size - header.offset_pai1)
+ u16 framesize; // Framesize
+ u8 flags; // Flags
+ u8 padding; // Padding
+ u16 num_timgs; // Number of timgs?
+ u16 num_entries; // Number of tags in the brlan.
} brlan_pai1_universal;
typedef struct
{
- fourcc magic; // "pai1" in ASCII.
- u32 size; // Size of section, which is rest of the file. (header.file_size - header.offset_pai1)
- 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.)
-} brlan_pai1_header_type1;
+ fourcc magic; // "pai1" in ASCII.
+ u32 size; // Size of section, which is rest of the file. (header.file_size - header.offset_pai1)
+ u16 framesize; // Framesize
+ u8 flags; // Flags
+ u8 padding; // Padding
+ 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.)
+} brlan_pai1_header_type1; // followed by offset list
-typedef struct
+typedef struct // pointed at by offset list + pai1_header
{
- char name[20]; // Name of the BRLAN entry. (Must be defined in the BRLYT)
- u8 num_tags;
- u8 is_material; // if 0 it's the name of a pane
- u8 pad[2];
-} brlan_entry;
+ char name[20]; // Name of the BRLAN entry. (Must be defined in the BRLYT)
+ u8 num_tags;
+ u8 is_material; // if 0 it's the name of a pane
+ u8 pad[2];
+} brlan_entry; // followed by offset list
-typedef struct
+typedef struct // pointed at by offset list + brlan_entry
{
- 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.
+ 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.
} tag_header;
typedef struct
{
- u32 offset; // Offset to the data pointed to by this entry.
- // Relative to the start of the RLPA header.
+ u32 offset; // Offset to the data pointed to by this entry.
+ // Relative to the start of the RLPA header.
} tag_entry;
typedef struct
{
- u16 type; // Type (look at animtypes)
- u16 unk1; // Every case has been 0x0200 // 0x0100 for pairs
- u16 coord_count; // How many coordinates.
- u16 pad1; // All cases I've seen is zero.
- u32 unk2; // ??? In every case I've seen, it is 0x0000000C.
+ //u16 type; // Type (look at animtypes)
+ u8 type1;
+ u8 type2;
+ u16 data_type; // Every case has been 0x0200 // 0x0100 for pairs
+ u16 coord_count; // How many coordinates.
+ u16 pad1; // All cases I've seen is zero.
+ u32 offset; // Offset to tag data
} 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)
+{ // 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)
} tag_data;
typedef struct
{
- u32 part1;
- u16 part2;
- u16 padding;
+ u32 part1;
+ u16 part2;
+ u16 padding;
} tag_data2;
diff --git a/brlyt.c b/brlyt.c
index 694e8f9..b7b3758 100644
--- a/brlyt.c
+++ b/brlyt.c
@@ -79,9 +79,9 @@ static void BRLYT_ReadDataFromMemory(void* destination, void* input, size_t size
float float_swap_bytes(float float1)
{
- unsigned char *float1c; float1c = (unsigned char*)&float1;
+ u8 *float1c; float1c = (u8*)&float1;
- unsigned char charTemp = 0x00;
+ u8 charTemp = 0x00;
charTemp = float1c[0]; float1c[0] = float1c[3]; float1c[3] = charTemp;
charTemp = 0x00;
charTemp = float1c[1]; float1c[1] = float1c[2]; float1c[2] = charTemp;
@@ -90,12 +90,10 @@ float float_swap_bytes(float float1)
return *newFloat;
}
-unsigned int bit_extract(unsigned int num, unsigned int start, unsigned int end)
+u32 bit_extract(u32 num, u32 start, u32 end)
{
if (end == 100) end = start;
- //simple bitmask, figure out when awake
- //unsigned int mask = (2**(31 - start + 1) - 1) - (2**(31 - end) - 1)
- unsigned int mask;
+ u32 mask;
int first;
int firstMask = 1;
for (first=0;first<31-start+1;first++)
@@ -182,8 +180,14 @@ void BRLYT_CheckHeaderSanity(brlyt_header header, size_t filesize)
{
if((header.magic[0] != 'R') || (header.magic[1] != 'L') || (header.magic[2] != 'Y') || (header.magic[3] != 'T')) {
printf("BRLYT magic doesn't match! %.4s\n", header.magic);
+ printf("magic: %.4s\n", header.magic);
exit(1);
}
+ if(header.version != be32(0xfeff0008) ){
+ printf("BRLYT version not right\n");
+ printf("version: %08x\n", be32(header.version) );
+ exit(1);
+ }
if(filesize != be32(header.filesize)) {
printf("BRLYT filesize doesn't match!\n");
exit(1);
@@ -200,7 +204,7 @@ void PrintBRLYTEntry_lyt1(brlyt_entry entry, u8* brlyt_file, mxml_node_t *tag)
BRLYT_fileoffset = entry.data_location;
BRLYT_ReadDataFromMemory(&data, brlyt_file, sizeof(brlyt_lytheader_chunk));
mxmlElementSetAttrf(tag, "type", "%.4s", entry.magic);
- a = mxmlNewElement(tag, "a"); mxmlNewTextf(a, 0, "%02x", data.a);
+ a = mxmlNewElement(tag, "drawnFromMiddle"); mxmlNewTextf(a, 0, "%02x", data.drawnFromMiddle);
size = mxmlNewElement(tag, "size");
width = mxmlNewElement(size, "width"); mxmlNewTextf(width, 0, "%f", float_swap_bytes(data.width));
height = mxmlNewElement(size, "height"); mxmlNewTextf(height, 0,"%f", float_swap_bytes(data.height));
@@ -300,28 +304,45 @@ void PrintBRLYTEntry_fnl1(brlyt_entry entry, u8* brlyt_file, mxml_node_t *tag)
void PrintBRLYTEntry_pan1(brlyt_entry entry, u8* brlyt_file, mxml_node_t *tag)
{
- mxml_node_t *flags1, *alpha1;
- mxml_node_t *coords, *x, *y, *z;
- mxml_node_t *flip, *rotate, *zoom;
+ char origins[9][15];
+ memset( origins , 0 , 8 * 20 );
+ strcpy( origins[0] , "TOP LEFT" );
+ strcpy( origins[1] , "TOP CENTER" );
+ strcpy( origins[2] , "TOP RIGHT" );
+ strcpy( origins[3] , "MIDDLE LEFT" );
+ strcpy( origins[4] , "MIDDLE CENTER" );
+ strcpy( origins[5] , "MIDDLE RIGHT" );
+ strcpy( origins[6] , "BOTTOM LEFT" );
+ strcpy( origins[7] , "BOTTOM CENTER" );
+ strcpy( origins[8] , "BOTTOM RIGHT" );
+
+ mxml_node_t *flags, *origin, *alpha, *padding;
+ mxml_node_t *translate, *x, *y, *z;
+ mxml_node_t *rotate, *scale;
mxml_node_t *size, *width, *height;
brlyt_pane_chunk data;
BRLYT_fileoffset = entry.data_location;
BRLYT_ReadDataFromMemory(&data, brlyt_file, sizeof(brlyt_pane_chunk));
mxmlElementSetAttrf(tag, "type", "%.4s", entry.magic);
mxmlElementSetAttrf(tag, "name", "%s", data.name);
- flags1 = mxmlNewElement(tag, "flags"); mxmlNewTextf(flags1, 0, "%02x-%02x", data.flag1, data.flag2);
- alpha1 = mxmlNewElement(tag, "alpha"); mxmlNewTextf(alpha1, 0, "%02x-%02x", data.alpha, data.alpha2);
- coords = mxmlNewElement(tag, "coords");
- x = mxmlNewElement(coords, "x"); mxmlNewTextf(x, 0, "%.20f", float_swap_bytes(data.x));
- y = mxmlNewElement(coords, "y"); mxmlNewTextf(y, 0, "%.20f", float_swap_bytes(data.y));
- z = mxmlNewElement(coords, "z"); mxmlNewTextf(z, 0, "%.20f", float_swap_bytes(data.z));
- flip = mxmlNewElement(tag, "flip");
- x = mxmlNewElement(flip, "x"); mxmlNewTextf(x, 0, "%.20f", float_swap_bytes(data.flip_x));
- y = mxmlNewElement(flip, "y"); mxmlNewTextf(y, 0, "%.20f", float_swap_bytes(data.flip_y));
- rotate = mxmlNewElement(tag, "rotate"); mxmlNewTextf(rotate, 0, "%.20f", float_swap_bytes(data.angle));
- zoom = mxmlNewElement(tag, "zoom");
- x = mxmlNewElement(zoom, "x"); mxmlNewTextf(x, 0, "%.10f", float_swap_bytes(data.xmag));
- y = mxmlNewElement(zoom, "y"); mxmlNewTextf(y, 0, "%.10f", float_swap_bytes(data.ymag));
+ mxmlElementSetAttrf(tag, "userdata", "%s", data.userdata);
+ flags = mxmlNewElement(tag, "visible"); mxmlNewTextf(flags, 0, "%02x", data.flag1 & 0x1);
+ flags = mxmlNewElement(tag, "WidescreenAffected"); mxmlNewTextf(flags, 0, "%02x", (data.flag1 & 0x2)>>1);
+ flags = mxmlNewElement(tag, "flag"); mxmlNewTextf(flags, 0, "%02x", (data.flag1 & 0x4)>>2);
+ origin = mxmlNewElement(tag, "origin"); mxmlNewTextf(origin,0,"%s",origins[data.origin%9]);
+ alpha = mxmlNewElement(tag, "alpha"); mxmlNewTextf(alpha, 0, "%02x", data.alpha);
+ padding = mxmlNewElement(tag, "padding"); mxmlNewTextf(padding, 0, "%02x", data.pad);
+ translate = mxmlNewElement(tag, "translate");
+ x = mxmlNewElement(translate, "x"); mxmlNewTextf(x, 0, "%.20f", float_swap_bytes(data.XTrans));
+ y = mxmlNewElement(translate, "y"); mxmlNewTextf(y, 0, "%.20f", float_swap_bytes(data.YTrans));
+ z = mxmlNewElement(translate, "z"); mxmlNewTextf(z, 0, "%.20f", float_swap_bytes(data.ZTrans));
+ rotate = mxmlNewElement(tag, "rotate");
+ x = mxmlNewElement(rotate, "x"); mxmlNewTextf(x, 0, "%.20f", float_swap_bytes(data.XRotate));
+ y = mxmlNewElement(rotate, "y"); mxmlNewTextf(y, 0, "%.20f", float_swap_bytes(data.YRotate));
+ z = mxmlNewElement(rotate, "z"); mxmlNewTextf(z, 0, "%.20f", float_swap_bytes(data.ZRotate));
+ scale = mxmlNewElement(tag, "scale");
+ x = mxmlNewElement(scale, "x"); mxmlNewTextf(x, 0, "%.10f", float_swap_bytes(data.XScale));
+ y = mxmlNewElement(scale, "y"); mxmlNewTextf(y, 0, "%.10f", float_swap_bytes(data.YScale));
size = mxmlNewElement(tag, "size");
width = mxmlNewElement(size, "width"); mxmlNewTextf(width, 0, "%f", float_swap_bytes(data.width));
height = mxmlNewElement(size, "height"); mxmlNewTextf(height, 0, "%f", float_swap_bytes(data.height));
@@ -329,76 +350,89 @@ void PrintBRLYTEntry_pan1(brlyt_entry entry, u8* brlyt_file, mxml_node_t *tag)
void PrintBRLYTEntry_wnd1(brlyt_entry entry, u8* brlyt_file, mxml_node_t *tag)
{
- mxml_node_t *flags1, *alpha1;
- mxml_node_t *coords, *x, *y, *z;
- mxml_node_t *flip, *rotate, *zoom;
+ char origins[9][15];
+ memset( origins , 0 , 8 * 20 );
+ strcpy( origins[0] , "TOP LEFT" );
+ strcpy( origins[1] , "TOP CENTER" );
+ strcpy( origins[2] , "TOP RIGHT" );
+ strcpy( origins[3] , "MIDDLE LEFT" );
+ strcpy( origins[4] , "MIDDLE CENTER" );
+ strcpy( origins[5] , "MIDDLE RIGHT" );
+ strcpy( origins[6] , "BOTTOM LEFT" );
+ strcpy( origins[7] , "BOTTOM CENTER" );
+ strcpy( origins[8] , "BOTTOM RIGHT" );
+
+ mxml_node_t *flags, *origin, *alpha, *padding;
+ mxml_node_t *translate, *x, *y, *z;
+ mxml_node_t *rotate, *scale;
mxml_node_t *size, *width, *height;
brlyt_pane_chunk data;
BRLYT_fileoffset = entry.data_location;
BRLYT_ReadDataFromMemory(&data, brlyt_file, sizeof(brlyt_pane_chunk));
mxmlElementSetAttrf(tag, "type", "%.4s", entry.magic);
mxmlElementSetAttrf(tag, "name", "%s", data.name);
- flags1 = mxmlNewElement(tag, "flags"); mxmlNewTextf(flags1, 0, "%02x-%02x", data.flag1, data.flag2);
- alpha1 = mxmlNewElement(tag, "alpha"); mxmlNewTextf(alpha1, 0, "%02x-%02x", data.alpha, data.alpha2);
- coords = mxmlNewElement(tag, "coords");
- x = mxmlNewElement(coords, "x"); mxmlNewTextf(x, 0, "%.20f", float_swap_bytes(data.x));
- y = mxmlNewElement(coords, "y"); mxmlNewTextf(y, 0, "%.20f", float_swap_bytes(data.y));
- z = mxmlNewElement(coords, "z"); mxmlNewTextf(z, 0, "%.20f", float_swap_bytes(data.z));
- flip = mxmlNewElement(tag, "flip");
- x = mxmlNewElement(flip, "x"); mxmlNewTextf(x, 0, "%f", float_swap_bytes(data.flip_x));
- y = mxmlNewElement(flip, "y"); mxmlNewTextf(y, 0, "%f", float_swap_bytes(data.flip_y));
- rotate = mxmlNewElement(tag, "rotate"); mxmlNewTextf(rotate, 0, "%f", float_swap_bytes(data.angle));
- zoom = mxmlNewElement(tag, "zoom");
- x = mxmlNewElement(zoom, "x"); mxmlNewTextf(x, 0, "%.10f", float_swap_bytes(data.xmag));
- y = mxmlNewElement(zoom, "y"); mxmlNewTextf(y, 0, "%.10f", float_swap_bytes(data.ymag));
+ mxmlElementSetAttrf(tag, "userdata", "%s", data.userdata);
+ flags = mxmlNewElement(tag, "visible"); mxmlNewTextf(flags, 0, "%02x", data.flag1 & 0x1);
+ flags = mxmlNewElement(tag, "WidescreenAffected"); mxmlNewTextf(flags, 0, "%02x", (data.flag1 & 0x2)>>1);
+ flags = mxmlNewElement(tag, "flag"); mxmlNewTextf(flags, 0, "%02x", (data.flag1 & 0x4)>>2);
+ origin = mxmlNewElement(tag, "origin"); mxmlNewTextf(origin,0,"%s", origins[data.origin%9]);
+ alpha = mxmlNewElement(tag, "alpha"); mxmlNewTextf(alpha, 0, "%02x", data.alpha);
+ padding = mxmlNewElement(tag, "padding"); mxmlNewTextf(padding, 0, "%02x", data.pad);
+ translate = mxmlNewElement(tag, "translate");
+ x = mxmlNewElement(translate, "x"); mxmlNewTextf(x, 0, "%.20f", float_swap_bytes(data.XTrans));
+ y = mxmlNewElement(translate, "y"); mxmlNewTextf(y, 0, "%.20f", float_swap_bytes(data.YTrans));
+ z = mxmlNewElement(translate, "z"); mxmlNewTextf(z, 0, "%.20f", float_swap_bytes(data.ZTrans));
+ rotate = mxmlNewElement(tag, "rotate");
+ x = mxmlNewElement(rotate, "x"); mxmlNewTextf(x, 0, "%.20f", float_swap_bytes(data.XRotate));
+ y = mxmlNewElement(rotate, "y"); mxmlNewTextf(y, 0, "%.20f", float_swap_bytes(data.YRotate));
+ z = mxmlNewElement(rotate, "z"); mxmlNewTextf(z, 0, "%.20f", float_swap_bytes(data.ZRotate));
+ scale = mxmlNewElement(tag, "scale");
+ x = mxmlNewElement(scale, "x"); mxmlNewTextf(x, 0, "%.10f", float_swap_bytes(data.XScale));
+ y = mxmlNewElement(scale, "y"); mxmlNewTextf(y, 0, "%.10f", float_swap_bytes(data.YScale));
size = mxmlNewElement(tag, "size");
width = mxmlNewElement(size, "width"); mxmlNewTextf(width, 0, "%f", float_swap_bytes(data.width));
height = mxmlNewElement(size, "height"); mxmlNewTextf(height, 0, "%f", float_swap_bytes(data.height));
mxml_node_t *wndd, *unkk, *count, *offset1, *offset2;
- int i;
+ int i, j;
brlyt_wnd wndy;
BRLYT_ReadDataFromMemory(&wndy, brlyt_file, sizeof(brlyt_wnd));
wndd = mxmlNewElement(tag, "wnd");
for(i=0;i<4;i++)
{
- unkk = mxmlNewElement(wndd, "unk1"); mxmlNewTextf(unkk, 0, "%f", float_swap_bytes(wndy.unk1[i]));
+ unkk = mxmlNewElement(wndd, "coordinate"); mxmlNewTextf(unkk, 0, "%f", float_swap_bytes(wndy.coords[i]));
}
- count = mxmlNewElement(wndd, "count"); mxmlNewTextf(count, 0, "%02x", wndy.count);
+ count = mxmlNewElement(wndd, "FrameCount"); mxmlNewTextf(count, 0, "%02x", wndy.frame_count);
offset1 = mxmlNewElement(wndd, "offset1"); mxmlNewTextf(offset1, 0, "%08x", be32(wndy.offset1));
offset2 = mxmlNewElement(wndd, "offset2"); mxmlNewTextf(offset2, 0, "%08x", be32(wndy.offset2));
- mxml_node_t *wnddd, *unkkk;
+ mxml_node_t *wnddd, *colors, *material;
brlyt_wnd1 wndy1;
BRLYT_ReadDataFromMemory(&wndy1, brlyt_file, sizeof(brlyt_wnd1));
wnddd = mxmlNewElement(tag, "wnd1");
for(i=0;i<4;i++)
{
- unkkk = mxmlNewElement(wnddd, "unk1"); mxmlNewTextf(unkkk, 0, "%08x", int_swap_bytes(wndy1.unk1[i]));
+ colors = mxmlNewElement(wnddd, "color"); mxmlNewTextf(colors, 0, "%08x", int_swap_bytes(wndy1.colors[i]));
}
- mxml_node_t *wndddd, *unkkkk, *unkkkk2;
- brlyt_wnd2 wndy2;
- BRLYT_ReadDataFromMemory(&wndy2, brlyt_file, sizeof(brlyt_wnd2));
- wndddd = mxmlNewElement(tag, "wnd2");
- unkkkk = mxmlNewElement(wndddd, "unk1"); mxmlNewTextf(unkkkk, 0, "%04x", short_swap_bytes(wndy2.unk1));
- unkkkk2 = mxmlNewElement(wndddd, "unk2"); mxmlNewTextf(unkkkk2, 0, "%04x", short_swap_bytes(wndy2.unk2));
+ material = mxmlNewElement(wnddd, "material"); mxmlNewTextf(material, 0, "%04x", short_swap_bytes(wndy1.material));
+ count = mxmlNewElement(wnddd, "CoordinateCount"); mxmlNewTextf(count, 0, "%02x", short_swap_bytes(wndy1.coordinate_count));
+ padding = mxmlNewElement(wnddd, "padding"); mxmlNewTextf(padding, 0, "%02x", short_swap_bytes(wndy1.padding));
mxml_node_t *wnddddd, *texcoord;
- if(wndy.offset2 == be32(0x0000009c))
- {
- brlyt_wnd3 wndy3;
- BRLYT_ReadDataFromMemory(&wndy3, brlyt_file, sizeof(brlyt_wnd3));
- wnddddd = mxmlNewElement(tag, "wnd3");
- for(i=0;i<8;i++)
- {
- texcoord = mxmlNewElement(wnddddd, "texcoord"); mxmlNewTextf(texcoord, 0, "%f", float_swap_bytes(wndy3.texcoords[i]));
- }
- }
+ for ( i = 0 ; i < wndy1.coordinate_count ; i++ ){
+ brlyt_wnd3 wndy3;
+ BRLYT_ReadDataFromMemory(&wndy3, brlyt_file, sizeof(brlyt_wnd3));
+ wnddddd = mxmlNewElement(tag, "Coords");
+ for ( j = 0 ; j < 8 ; j++ ) {
+ texcoord = mxmlNewElement(wnddddd, "texcoord"); mxmlNewTextf(texcoord, 0, "%f", float_swap_bytes(wndy3.texcoords[j]));
+ }
+
+ }
mxml_node_t *wndddddd, *offsett;
brlyt_wnd4 wndy4;
- for(i=0;i<wndy.count;i++)
+ for(i=0;i<wndy.frame_count;i++)
{
BRLYT_ReadDataFromMemory(&wndy4, brlyt_file, sizeof(brlyt_wnd4));
wndddddd = mxmlNewElement(tag, "wnd4");
@@ -407,38 +441,57 @@ void PrintBRLYTEntry_wnd1(brlyt_entry entry, u8* brlyt_file, mxml_node_t *tag)
mxml_node_t *wndmat, *matrl;
brlyt_wnd4_mat wndy4mat;
- for(i=0;i<wndy.count;i++)
+ for(i=0;i<wndy.frame_count;i++)
{
BRLYT_ReadDataFromMemory(&wndy4mat, brlyt_file, sizeof(brlyt_wnd4_mat));
wndmat = mxmlNewElement(tag, "wnd4mat");
- matrl = mxmlNewElement(wndmat, "material"); mxmlNewTextf(matrl, 0, "%08x", be32(wndy4mat.unk1));
+ matrl = mxmlNewElement(wndmat, "material"); mxmlNewTextf(matrl, 0, "%04x", be16(wndy4mat.material));
+ matrl = mxmlNewElement(wndmat, "index"); mxmlNewTextf(matrl, 0, "%02x", wndy4mat.index);
+ matrl = mxmlNewElement(wndmat, "padding"); mxmlNewTextf(matrl, 0, "%02x", wndy4mat.padding);
}
}
void PrintBRLYTEntry_bnd1(brlyt_entry entry, u8* brlyt_file, mxml_node_t *tag)
{
- mxml_node_t *flags1, *alpha1;
- mxml_node_t *coords, *x, *y, *z;
- mxml_node_t *flip, *rotate, *zoom;
+ char origins[9][15];
+ memset( origins , 0 , 8 * 20 );
+ strcpy( origins[0] , "TOP LEFT" );
+ strcpy( origins[1] , "TOP CENTER" );
+ strcpy( origins[2] , "TOP RIGHT" );
+ strcpy( origins[3] , "MIDDLE LEFT" );
+ strcpy( origins[4] , "MIDDLE CENTER" );
+ strcpy( origins[5] , "MIDDLE RIGHT" );
+ strcpy( origins[6] , "BOTTOM LEFT" );
+ strcpy( origins[7] , "BOTTOM CENTER" );
+ strcpy( origins[8] , "BOTTOM RIGHT" );
+
+ mxml_node_t *flags, *origin, *alpha, *padding;
+ mxml_node_t *translate, *x, *y, *z;
+ mxml_node_t *rotate, *scale;
mxml_node_t *size, *width, *height;
brlyt_pane_chunk data;
BRLYT_fileoffset = entry.data_location;
BRLYT_ReadDataFromMemory(&data, brlyt_file, sizeof(brlyt_pane_chunk));
mxmlElementSetAttrf(tag, "type", "%.4s", entry.magic);
mxmlElementSetAttrf(tag, "name", "%s", data.name);
- flags1 = mxmlNewElement(tag, "flags"); mxmlNewTextf(flags1, 0, "%02x-%02x", data.flag1, data.flag2);
- alpha1 = mxmlNewElement(tag, "alpha"); mxmlNewTextf(alpha1, 0, "%02x-%02x", data.alpha, data.alpha2);
- coords = mxmlNewElement(tag, "coords");
- x = mxmlNewElement(coords, "x"); mxmlNewTextf(x, 0, "%.25f", float_swap_bytes(data.x));
- y = mxmlNewElement(coords, "y"); mxmlNewTextf(y, 0, "%.25f", float_swap_bytes(data.y));
- z = mxmlNewElement(coords, "z"); mxmlNewTextf(z, 0, "%.25f", float_swap_bytes(data.z));
- flip = mxmlNewElement(tag, "flip");
- x = mxmlNewElement(flip, "x"); mxmlNewTextf(x, 0, "%f", float_swap_bytes(data.flip_x));
- y = mxmlNewElement(flip, "y"); mxmlNewTextf(y, 0, "%f", float_swap_bytes(data.flip_y));
- rotate = mxmlNewElement(tag, "rotate"); mxmlNewTextf(rotate, 0, "%f", float_swap_bytes(data.angle));
- zoom = mxmlNewElement(tag, "zoom");
- x = mxmlNewElement(zoom, "x"); mxmlNewTextf(x, 0, "%.10f", float_swap_bytes(data.xmag));
- y = mxmlNewElement(zoom, "y"); mxmlNewTextf(y, 0, "%.10f", float_swap_bytes(data.ymag));
+ mxmlElementSetAttrf(tag, "userdata", "%s", data.userdata);
+ flags = mxmlNewElement(tag, "visible"); mxmlNewTextf(flags, 0, "%02x", data.flag1 & 0x1);
+ flags = mxmlNewElement(tag, "WidescreenAffected"); mxmlNewTextf(flags, 0, "%02x", (data.flag1 & 0x2)>>1);
+ flags = mxmlNewElement(tag, "flag"); mxmlNewTextf(flags, 0, "%02x", (data.flag1 & 0x4)>>2);
+ origin = mxmlNewElement(tag, "origin"); mxmlNewTextf(origin,0,"%s", origins[data.origin%9]);
+ alpha = mxmlNewElement(tag, "alpha"); mxmlNewTextf(alpha, 0, "%02x", data.alpha);
+ padding = mxmlNewElement(tag, "padding"); mxmlNewTextf(padding, 0, "%02x", data.pad);
+ translate = mxmlNewElement(tag, "translate");
+ x = mxmlNewElement(translate, "x"); mxmlNewTextf(x, 0, "%.25f", float_swap_bytes(data.XTrans));
+ y = mxmlNewElement(translate, "y"); mxmlNewTextf(y, 0, "%.25f", float_swap_bytes(data.YTrans));
+ z = mxmlNewElement(translate, "z"); mxmlNewTextf(z, 0, "%.25f", float_swap_bytes(data.ZTrans));
+ rotate = mxmlNewElement(tag, "rotate");
+ x = mxmlNewElement(rotate, "x"); mxmlNewTextf(x, 0, "%.20f", float_swap_bytes(data.XRotate));
+ y = mxmlNewElement(rotate, "y"); mxmlNewTextf(y, 0, "%.20f", float_swap_bytes(data.YRotate));
+ z = mxmlNewElement(rotate, "z"); mxmlNewTextf(z, 0, "%.20f", float_swap_bytes(data.ZRotate));
+ scale = mxmlNewElement(tag, "scale");
+ x = mxmlNewElement(scale, "x"); mxmlNewTextf(x, 0, "%.10f", float_swap_bytes(data.XScale));
+ y = mxmlNewElement(scale, "y"); mxmlNewTextf(y, 0, "%.10f", float_swap_bytes(data.YScale));
size = mxmlNewElement(tag, "size");
width = mxmlNewElement(size, "width"); mxmlNewTextf(width, 0, "%f", float_swap_bytes(data.width));
height = mxmlNewElement(size, "height"); mxmlNewTextf(height, 0, "%f", float_swap_bytes(data.height));
@@ -446,9 +499,21 @@ void PrintBRLYTEntry_bnd1(brlyt_entry entry, u8* brlyt_file, mxml_node_t *tag)
void PrintBRLYTEntry_pic1(brlyt_entry entry, u8* brlyt_file, mxml_node_t *tag)
{
- mxml_node_t *flags1, *alpha1;
- mxml_node_t *coords, *x, *y, *z;
- mxml_node_t *flip, *rotate, *zoom;
+ char origins[9][15];
+ memset( origins , 0 , 8 * 20 );
+ strcpy( origins[0] , "TOP LEFT" );
+ strcpy( origins[1] , "TOP CENTER" );
+ strcpy( origins[2] , "TOP RIGHT" );
+ strcpy( origins[3] , "MIDDLE LEFT" );
+ strcpy( origins[4] , "MIDDLE CENTER" );
+ strcpy( origins[5] , "MIDDLE RIGHT" );
+ strcpy( origins[6] , "BOTTOM LEFT" );
+ strcpy( origins[7] , "BOTTOM CENTER" );
+ strcpy( origins[8] , "BOTTOM RIGHT" );
+
+ mxml_node_t *flags, *origin, *alpha, *padding;
+ mxml_node_t *translate, *x, *y, *z;
+ mxml_node_t *rotate, *scale;
mxml_node_t *size, *width, *height;
brlyt_pane_chunk data;
BRLYT_fileoffset = entry.data_location;
@@ -457,28 +522,34 @@ void PrintBRLYTEntry_pic1(brlyt_entry entry, u8* brlyt_file, mxml_node_t *tag)
BRLYT_ReadDataFromMemory(&data2, brlyt_file, sizeof(brlyt_pic_chunk));
mxmlElementSetAttrf(tag, "type", "%.4s", entry.magic);
mxmlElementSetAttrf(tag, "name", "%s", data.name);
- flags1 = mxmlNewElement(tag, "flags"); mxmlNewTextf(flags1, 0, "%02x-%02x", data.flag1, data.flag2);
- alpha1 = mxmlNewElement(tag, "alpha"); mxmlNewTextf(alpha1, 0, "%02x-%02x", data.alpha, data.alpha2);
- coords = mxmlNewElement(tag, "coords");
- x = mxmlNewElement(coords, "x"); mxmlNewTextf(x, 0, "%.20f", float_swap_bytes(data.x));
- y = mxmlNewElement(coords, "y"); mxmlNewTextf(y, 0, "%.20f", float_swap_bytes(data.y));
- z = mxmlNewElement(coords, "z"); mxmlNewTextf(z, 0, "%.20f", float_swap_bytes(data.z));
- flip = mxmlNewElement(tag, "flip");
- x = mxmlNewElement(flip, "x"); mxmlNewTextf(x, 0, "%f", float_swap_bytes(data.flip_x));
- y = mxmlNewElement(flip, "y"); mxmlNewTextf(y, 0, "%f", float_swap_bytes(data.flip_y));
- rotate = mxmlNewElement(tag, "rotate"); mxmlNewTextf(rotate, 0, "%f", float_swap_bytes(data.angle));
- zoom = mxmlNewElement(tag, "zoom");
- x = mxmlNewElement(zoom, "x"); mxmlNewTextf(x, 0, "%.10f", float_swap_bytes(data.xmag));
- y = mxmlNewElement(zoom, "y"); mxmlNewTextf(y, 0, "%.10f", float_swap_bytes(data.ymag));
+ mxmlElementSetAttrf(tag, "userdata", "%s", data.userdata);
+ flags = mxmlNewElement(tag, "visible"); mxmlNewTextf(flags, 0, "%02x", data.flag1 & 0x1);
+ flags = mxmlNewElement(tag, "WidescreenAffected"); mxmlNewTextf(flags, 0, "%02x", (data.flag1 & 0x2)>>1);
+ flags = mxmlNewElement(tag, "flag"); mxmlNewTextf(flags, 0, "%02x", (data.flag1 & 0x4)>>2);
+ origin = mxmlNewElement(tag, "origin"); mxmlNewTextf(origin,0,"%s", origins[data.origin%9]);
+ alpha = mxmlNewElement(tag, "alpha"); mxmlNewTextf(alpha, 0, "%02x", data.alpha);
+ padding = mxmlNewElement(tag, "padding"); mxmlNewTextf(padding, 0, "%02x", data.pad);
+ translate = mxmlNewElement(tag, "translate");
+ x = mxmlNewElement(translate, "x"); mxmlNewTextf(x, 0, "%.20f", float_swap_bytes(data.XTrans));
+ y = mxmlNewElement(translate, "y"); mxmlNewTextf(y, 0, "%.20f", float_swap_bytes(data.YTrans));
+ z = mxmlNewElement(translate, "z"); mxmlNewTextf(z, 0, "%.20f", float_swap_bytes(data.ZTrans
+ ));
+ rotate = mxmlNewElement(tag, "rotate");
+ x = mxmlNewElement(rotate, "x"); mxmlNewTextf(x, 0, "%.20f", float_swap_bytes(data.XRotate));
+ y = mxmlNewElement(rotate, "y"); mxmlNewTextf(y, 0, "%.20f", float_swap_bytes(data.YRotate));
+ z = mxmlNewElement(rotate, "z"); mxmlNewTextf(z, 0, "%.20f", float_swap_bytes(data.ZRotate));
+ scale = mxmlNewElement(tag, "scale");
+ x = mxmlNewElement(scale, "x"); mxmlNewTextf(x, 0, "%.10f", float_swap_bytes(data.XScale));
+ y = mxmlNewElement(scale, "y"); mxmlNewTextf(y, 0, "%.10f", float_swap_bytes(data.YScale));
size = mxmlNewElement(tag, "size");
width = mxmlNewElement(size, "width"); mxmlNewTextf(width, 0, "%f", float_swap_bytes(data.width));
height = mxmlNewElement(size, "height"); mxmlNewTextf(height, 0, "%f", float_swap_bytes(data.height));
mxml_node_t *material, *color, *vtx, *coordinates, *set, *coord;
- material = mxmlNewElement(tag, "material"); mxmlElementSetAttrf(material, "name", "%s", getMaterial(short_swap_bytes(data2.mat_off)));
+ material = mxmlNewElement(tag, "material"); mxmlElementSetAttrf(material, "name", "%s", getMaterial(short_swap_bytes(data2.mat_num)));
color = mxmlNewElement(tag, "colors");
int n; for (n=0;n<4;n++)
{
- vtx = mxmlNewElement(color, "vtx"); mxmlNewTextf(vtx, 0, "%#08X", be32(data2.vtx_colors[n]));
+ vtx = mxmlNewElement(color, "vtx"); mxmlNewTextf(vtx, 0, "%08X", be32(data2.vtx_colors[n]));
}
coordinates = mxmlNewElement(tag, "coordinates");
for (n=0;n<data2.num_texcoords;n++)
@@ -496,35 +567,64 @@ void PrintBRLYTEntry_pic1(brlyt_entry entry, u8* brlyt_file, mxml_node_t *tag)
void PrintBRLYTEntry_txt1(brlyt_entry entry, u8* brlyt_file, mxml_node_t *tag)
{
- mxml_node_t *flags1, *alpha1;
- mxml_node_t *coords, *x, *y, *z;
- mxml_node_t *flip, *rotate, *zoom;
+ char origins[9][15];
+ memset( origins , 0 , 8 * 20 );
+ strcpy( origins[0] , "TOP LEFT" );
+ strcpy( origins[1] , "TOP CENTER" );
+ strcpy( origins[2] , "TOP RIGHT" );
+ strcpy( origins[3] , "MIDDLE LEFT" );
+ strcpy( origins[4] , "MIDDLE CENTER" );
+ strcpy( origins[5] , "MIDDLE RIGHT" );
+ strcpy( origins[6] , "BOTTOM LEFT" );
+ strcpy( origins[7] , "BOTTOM CENTER" );
+ strcpy( origins[8] , "BOTTOM RIGHT" );
+
+ char alignments[9][15];
+ memset( alignments , 0 , 8 * 20 );
+ strcpy( alignments[0] , "TOP LEFT" );
+ strcpy( alignments[1] , "TOP CENTER" );
+ strcpy( alignments[2] , "TOP RIGHT" );
+ strcpy( alignments[3] , "MIDDLE LEFT" );
+ strcpy( alignments[4] , "MIDDLE CENTER" );
+ strcpy( alignments[5] , "MIDDLE RIGHT" );
+ strcpy( alignments[6] , "BOTTOM LEFT" );
+ strcpy( alignments[7] , "BOTTOM CENTER" );
+ strcpy( alignments[8] , "BOTTOM RIGHT" );
+
+ mxml_node_t *flags, *origin, *alpha, *padding;
+ mxml_node_t *translate, *x, *y, *z;
+ mxml_node_t *rotate, *scale;
mxml_node_t *size, *width, *height;
brlyt_pane_chunk data;
BRLYT_fileoffset = entry.data_location;
BRLYT_ReadDataFromMemory(&data, brlyt_file, sizeof(brlyt_pane_chunk));
mxmlElementSetAttrf(tag, "type", "%.4s", entry.magic);
mxmlElementSetAttrf(tag, "name", "%s", data.name);
- flags1 = mxmlNewElement(tag, "flags"); mxmlNewTextf(flags1, 0, "%02x-%02x", data.flag1, data.flag2);
- alpha1 = mxmlNewElement(tag, "alpha"); mxmlNewTextf(alpha1, 0, "%02x-%02x", data.alpha, data.alpha2);
- coords = mxmlNewElement(tag, "coords");
- x = mxmlNewElement(coords, "x"); mxmlNewTextf(x, 0, "%.16f", float_swap_bytes(data.x));
- y = mxmlNewElement(coords, "y"); mxmlNewTextf(y, 0, "%.16f", float_swap_bytes(data.y));
- z = mxmlNewElement(coords, "z"); mxmlNewTextf(z, 0, "%.16f", float_swap_bytes(data.z));
- flip = mxmlNewElement(tag, "flip");
- x = mxmlNewElement(flip, "x"); mxmlNewTextf(x, 0, "%f", float_swap_bytes(data.flip_x));
- y = mxmlNewElement(flip, "y"); mxmlNewTextf(y, 0, "%f", float_swap_bytes(data.flip_y));
- rotate = mxmlNewElement(tag, "rotate"); mxmlNewTextf(rotate, 0, "%f", float_swap_bytes(data.angle));
- zoom = mxmlNewElement(tag, "zoom");
- x = mxmlNewElement(zoom, "x"); mxmlNewTextf(x, 0, "%.10f", float_swap_bytes(data.xmag));
- y = mxmlNewElement(zoom, "y"); mxmlNewTextf(y, 0, "%.10f", float_swap_bytes(data.ymag));
+ mxmlElementSetAttrf(tag, "userdata", "%s", data.userdata);
+ flags = mxmlNewElement(tag, "visible"); mxmlNewTextf(flags, 0, "%02x", data.flag1 & 0x1);
+ flags = mxmlNewElement(tag, "WidescreenAffected"); mxmlNewTextf(flags, 0, "%02x", (data.flag1 & 0x2)>>1);
+ flags = mxmlNewElement(tag, "flag"); mxmlNewTextf(flags, 0, "%02x", (data.flag1 & 0x4)>>2);
+ origin = mxmlNewElement(tag, "origin"); mxmlNewTextf(origin,0,"%s", origins[data.origin%9]);
+ alpha = mxmlNewElement(tag, "alpha"); mxmlNewTextf(alpha, 0, "%02x", data.alpha);
+ padding = mxmlNewElement(tag, "padding"); mxmlNewTextf(padding, 0, "%02x", data.pad);
+ translate = mxmlNewElement(tag, "translate");
+ x = mxmlNewElement(translate, "x"); mxmlNewTextf(x, 0, "%.16f", float_swap_bytes(data.XTrans));
+ y = mxmlNewElement(translate, "y"); mxmlNewTextf(y, 0, "%.16f", float_swap_bytes(data.YTrans));
+ z = mxmlNewElement(translate, "z"); mxmlNewTextf(z, 0, "%.16f", float_swap_bytes(data.ZTrans));
+ rotate = mxmlNewElement(tag, "rotate");
+ x = mxmlNewElement(rotate, "x"); mxmlNewTextf(x, 0, "%.20f", float_swap_bytes(data.XRotate));
+ y = mxmlNewElement(rotate, "y"); mxmlNewTextf(y, 0, "%.20f", float_swap_bytes(data.YRotate));
+ z = mxmlNewElement(rotate, "z"); mxmlNewTextf(z, 0, "%.20f", float_swap_bytes(data.ZRotate));
+ scale = mxmlNewElement(tag, "scale");
+ x = mxmlNewElement(scale, "x"); mxmlNewTextf(x, 0, "%.10f", float_swap_bytes(data.XScale));
+ y = mxmlNewElement(scale, "y"); mxmlNewTextf(y, 0, "%.10f", float_swap_bytes(data.YScale));
size = mxmlNewElement(tag, "size");
width = mxmlNewElement(size, "width"); mxmlNewTextf(width, 0, "%.20f", float_swap_bytes(data.width));
height = mxmlNewElement(size, "height"); mxmlNewTextf(height, 0, "%.20f", float_swap_bytes(data.height));
- mxml_node_t *length, *font, *xsize, *ysize, *charsize, *linesize, *alignment, *color, *text;
+ mxml_node_t *length, *font, *xsize, *ysize, *charsize, *linesize, *alignment, *color1, *color2, *text;
brlyt_text_chunk data2;
BRLYT_ReadDataFromMemory(&data2, brlyt_file, sizeof(brlyt_text_chunk));
- unsigned char texty[short_swap_bytes(data2.len2)];
+ u8 texty[short_swap_bytes(data2.len2)];
memcpy(texty, &brlyt_file[BRLYT_fileoffset], short_swap_bytes(data2.len2));
length = mxmlNewElement(tag, "length"); mxmlNewTextf(length, 0, "%04x-%04x", short_swap_bytes(data2.len2), short_swap_bytes(data2.len2));
font = mxmlNewElement(tag, "font"); mxmlElementSetAttrf(font, "index", "%d", short_swap_bytes(data2.font_idx));
@@ -532,10 +632,11 @@ void PrintBRLYTEntry_txt1(brlyt_entry entry, u8* brlyt_file, mxml_node_t *tag)
ysize = mxmlNewElement(font, "ysize"); mxmlNewTextf(ysize, 0, "%f", float_swap_bytes(data2.font_size_y));
charsize = mxmlNewElement(font, "charsize"); mxmlNewTextf(charsize, 0, "%f", float_swap_bytes(data2.char_space));
linesize = mxmlNewElement(font, "linesize"); mxmlNewTextf(linesize, 0, "%f", float_swap_bytes(data2.line_space));
- alignment = mxmlNewElement(font, "alignment"); mxmlNewTextf(alignment, 0, "%02x", data2.alignment);
- color = mxmlNewElement(tag, "color"); mxmlNewTextf(color, 0, "%08x-%08x", be32(data2.color1), be32(data2.color2));
+ alignment = mxmlNewElement(font, "alignment"); mxmlNewTextf(alignment, 0, "%s", alignments[data2.alignment%9]);
+ color1 = mxmlNewElement(tag, "color1"); mxmlNewTextf(color1, 0, "%08x", be32(data2.color1) );
+ color2 = mxmlNewElement(tag, "color2"); mxmlNewTextf(color2, 0, "%08x", be32(data2.color2) );
// int q; for(q=0;q<short_swap_bytes(data2.len2);q++) printf("%02x", texty[q]); // S T U P I D U T F 1 6 T E X T
- unsigned char textbuffer[4096];
+ u8 textbuffer[4096];
int q; for(q=0;q<short_swap_bytes(data2.len2);q++) sprintf((char*)&textbuffer[q*2], "%02x", texty[q]);
text = mxmlNewElement(tag, "text"); mxmlNewTextf(text, 0, "%s", textbuffer);
}
@@ -557,7 +658,7 @@ void PrintBRLYTEntry_mat1(brlyt_entry entry, u8* brlyt_file, mxml_node_t *tag)
brlyt_material_chunk data3;
BRLYT_ReadDataFromMemory(&data3, brlyt_file, sizeof(brlyt_material_chunk));
- unsigned int flaggs = be32(data3.flags);
+ u32 flaggs = be32(data3.flags);
entries = mxmlNewElement(tag, "entries"); mxmlElementSetAttrf(entries, "name", "%s", data3.name);
colors = mxmlNewElement(entries, "colors");
int i; for (i=0;i<4;i++)
@@ -572,15 +673,16 @@ void PrintBRLYTEntry_mat1(brlyt_entry entry, u8* brlyt_file, mxml_node_t *tag)
}
for (i=0;i<4;i++)
{
- unk2 = mxmlNewElement(colors, "unk2");
- mxmlNewTextf(unk2, 0, "%d", short_swap_bytes(data3.unk_color_2[i]));
+ unk2 = mxmlNewElement(colors, "colorReg3");
+ mxmlNewTextf(unk2, 0, "%d", short_swap_bytes(data3.colorReg3[i]));
}
for (i=0;i<4;i++)
{
tev_k = mxmlNewElement(colors, "tev_k");
- mxmlNewTextf(tev_k, 0, "%#08x", be32(data3.tev_kcolor[i]));
+ mxmlNewTextf(tev_k, 0, "%08x", be32(data3.tev_kcolor[i]));
}
- flags = mxmlNewElement(entries, "flags"); mxmlNewTextf(flags, 0, "%08x", be32(data3.flags));
+
+ //flags = mxmlNewElement(entries, "flags"); mxmlNewTextf(flags, 0, "%08x", be32(data3.flags));
int newSize = lengthOfMaterials+strlen(data3.name)+1;
materials = realloc(materials, newSize);
@@ -596,145 +698,502 @@ void PrintBRLYTEntry_mat1(brlyt_entry entry, u8* brlyt_file, mxml_node_t *tag)
BRLYT_ReadDataFromMemory(&data4, brlyt_file, sizeof(brlyt_texref_chunk));
int tplOffset = short_swap_bytes(data4.tex_offs);
texture = mxmlNewElement(entries, "texture"); mxmlElementSetAttrf(texture, "name", "%s", getTexture(tplOffset));
- wrap_s = mxmlNewElement(texture, "wrap_s"); mxmlNewTextf(wrap_s, 0, "%02x", data4.wrap_s);
- wrap_t = mxmlNewElement(texture, "wrap_t"); mxmlNewTextf(wrap_t, 0, "%02x", data4.wrap_t);
+
+ char wraps[4][20];
+ int l;
+ for ( l = 0 ; l < 4 ; l++ )
+ memset( wraps , 0 , 20 );
+ strcpy( wraps[0] , "GX_CLAMP" );
+ strcpy( wraps[1] , "GX_REPEAT" );
+ strcpy( wraps[2] , "GX_MIRROR" );
+ strcpy( wraps[3] , "GX_MAXTEXWRAPMODE" );
+
+ wrap_s = mxmlNewElement(texture, "wrap_s");
+ mxmlNewTextf(wrap_s, 0, "%s", wraps[data4.wrap_s]);
+ wrap_t = mxmlNewElement(texture, "wrap_t");
+ mxmlNewTextf(wrap_t, 0, "%s", wraps[data4.wrap_t]);
}
mxml_node_t *tex_coords, *dataa;
// # 0x14 * flags[24-27], followed by
for (n=0;n<bit_extract(flaggs, 24,27);n++)
{
- brlyt_tex_coords data4;
- BRLYT_ReadDataFromMemory(&data4, brlyt_file, sizeof(brlyt_tex_coords));
- tex_coords = mxmlNewElement(entries, "tex_coords");
- dataa = mxmlNewElement(tex_coords, "x1"); mxmlNewTextf(dataa, 0, "%.10f", float_swap_bytes(data4.x1));
- dataa = mxmlNewElement(tex_coords, "y1"); mxmlNewTextf(dataa, 0, "%.10f", float_swap_bytes(data4.y1));
- dataa = mxmlNewElement(tex_coords, "angle"); mxmlNewTextf(dataa, 0, "%.10f", float_swap_bytes(data4.angle));
- dataa = mxmlNewElement(tex_coords, "x2"); mxmlNewTextf(dataa, 0, "%.10f", float_swap_bytes(data4.x2));
- dataa = mxmlNewElement(tex_coords, "y2"); mxmlNewTextf(dataa, 0, "%.10f", float_swap_bytes(data4.y2));
+ brlyt_tex_srt data4;
+ BRLYT_ReadDataFromMemory(&data4, brlyt_file, sizeof(brlyt_tex_srt));
+ tex_coords = mxmlNewElement(entries, "TextureSRT");
+ dataa = mxmlNewElement(tex_coords, "XTrans"); mxmlNewTextf(dataa, 0, "%.10f", float_swap_bytes(data4.XTrans));
+ dataa = mxmlNewElement(tex_coords, "YTrans"); mxmlNewTextf(dataa, 0, "%.10f", float_swap_bytes(data4.YTrans));
+ dataa = mxmlNewElement(tex_coords, "Rotate"); mxmlNewTextf(dataa, 0, "%.10f", float_swap_bytes(data4.Rotate));
+ dataa = mxmlNewElement(tex_coords, "XScale"); mxmlNewTextf(dataa, 0, "%.10f", float_swap_bytes(data4.XScale));
+ dataa = mxmlNewElement(tex_coords, "YScale"); mxmlNewTextf(dataa, 0, "%.10f", float_swap_bytes(data4.YScale));
}
mxml_node_t *ua3;
//# 4*flags[20-23], followed by
for (n=0;n<bit_extract(flaggs, 20,23);n++)
{
- brlyt_4b_chunk data4;
- BRLYT_ReadDataFromMemory(&data4, brlyt_file, sizeof(brlyt_4b_chunk));
- ua3 = mxmlNewElement(entries, "ua3");
- int j; for (j=0;j<4;j++)
- {
- dataa = mxmlNewElement(ua3, "data"); mxmlNewTextf(dataa, 0, "%02x", data4.unk[j]);
- }
+ char tgen_types[11][20];
+ int l;
+ for ( l = 0 ; l < 11 ; l++ )
+ memset( tgen_types[l] , 0 , 20 );
+ strcpy( tgen_types[0] , "GX_TG_MTX3x4" );
+ strcpy( tgen_types[1] , "GX_TG_MTX2x4" );
+ strcpy( tgen_types[2] , "GX_TG_BUMP0" );
+ strcpy( tgen_types[3] , "GX_TG_BUMP1" );
+ strcpy( tgen_types[4] , "GX_TG_BUMP2" );
+ strcpy( tgen_types[5] , "GX_TG_BUMP3" );
+ strcpy( tgen_types[6] , "GX_TG_BUMP4" );
+ strcpy( tgen_types[7] , "GX_TG_BUMP5" );
+ strcpy( tgen_types[8] , "GX_TG_BUMP6" );
+ strcpy( tgen_types[9] , "GX_TG_BUMP7" );
+ strcpy( tgen_types[10] , "GX_TG_SRTG" );
+
+ char tgen_src[21][20];
+ for ( l = 0 ; l < 21 ; l++ )
+ memset( tgen_src[l] , 0 , 20 );
+ strcpy( tgen_src[0] , "GX_TG_POS" );
+ strcpy( tgen_src[1] , "GX_TG_NRM" );
+ strcpy( tgen_src[2] , "GX_TG_BINRM" );
+ strcpy( tgen_src[3] , "GX_TG_TANGEN" );
+ strcpy( tgen_src[4] , "GX_TG_TEX0" );
+ strcpy( tgen_src[5] , "GX_TG_TEX1" );
+ strcpy( tgen_src[6] , "GX_TG_TEX2" );
+ strcpy( tgen_src[7] , "GX_TG_TEX3" );
+ strcpy( tgen_src[8] , "GX_TG_TEX4" );
+ strcpy( tgen_src[9] , "GX_TG_TEX5" );
+ strcpy( tgen_src[10] , "GX_TG_TEX6" );
+ strcpy( tgen_src[11] , "GX_TG_TEX7" );
+ strcpy( tgen_src[12] , "GX_TG_TEXCOORD0" );
+ strcpy( tgen_src[13] , "GX_TG_TEXCOORD1" );
+ strcpy( tgen_src[14] , "GX_TG_TEXCOORD2" );
+ strcpy( tgen_src[15] , "GX_TG_TEXCOORD3" );
+ strcpy( tgen_src[16] , "GX_TG_TEXCOORD4" );
+ strcpy( tgen_src[17] , "GX_TG_TEXCOORD5" );
+ strcpy( tgen_src[18] , "GX_TG_TEXCOORD6" );
+ strcpy( tgen_src[19] , "GX_TG_COLOR0" );
+ strcpy( tgen_src[20] , "GX_TG_COLOR1" );
+
+ char mtxsrc[42][20];
+ for ( l = 0 ; l < 42 ; l++ )
+ memset( mtxsrc[l] , 0 , 20 );
+ strcpy( mtxsrc[0] , "GX_PNMTX0" );
+ strcpy( mtxsrc[1] , "GX_PNMTX1" );
+ strcpy( mtxsrc[2] , "GX_PNMTX2" );
+ strcpy( mtxsrc[3] , "GX_PNMTX3" );
+ strcpy( mtxsrc[4] , "GX_PNMTX4" );
+ strcpy( mtxsrc[5] , "GX_PNMTX5" );
+ strcpy( mtxsrc[6] , "GX_PNMTX6" );
+ strcpy( mtxsrc[7] , "GX_PNMTX7" );
+ strcpy( mtxsrc[8] , "GX_PNMTX8" );
+ strcpy( mtxsrc[9] , "GX_PNMTX9" );
+ strcpy( mtxsrc[10] , "GX_TEXMTX0" );
+ strcpy( mtxsrc[11] , "GX_TEXMTX1" );
+ strcpy( mtxsrc[12] , "GX_TEXMTX2" );
+ strcpy( mtxsrc[13] , "GX_TEXMTX3" );
+ strcpy( mtxsrc[14] , "GX_TEXMTX4" );
+ strcpy( mtxsrc[15] , "GX_TEXMTX5" );
+ strcpy( mtxsrc[16] , "GX_TEXMTX6" );
+ strcpy( mtxsrc[17] , "GX_TEXMTX7" );
+ strcpy( mtxsrc[18] , "GX_TEXMTX8" );
+ strcpy( mtxsrc[19] , "GX_TEXMTX9" );
+ strcpy( mtxsrc[20] , "GX_IDENTITY" );
+ strcpy( mtxsrc[21] , "GX_DTTMTX0" );
+ strcpy( mtxsrc[22] , "GX_DTTMTX1" );
+ strcpy( mtxsrc[23] , "GX_DTTMTX2" );
+ strcpy( mtxsrc[24] , "GX_DTTMTX3" );
+ strcpy( mtxsrc[25] , "GX_DTTMTX4" );
+ strcpy( mtxsrc[26] , "GX_DTTMTX5" );
+ strcpy( mtxsrc[27] , "GX_DTTMTX6" );
+ strcpy( mtxsrc[28] , "GX_DTTMTX7" );
+ strcpy( mtxsrc[29] , "GX_DTTMTX8" );
+ strcpy( mtxsrc[30] , "GX_DTTMTX9" );
+ strcpy( mtxsrc[31] , "GX_DTTMTX1" );
+ strcpy( mtxsrc[32] , "GX_DTTMTX1" );
+ strcpy( mtxsrc[33] , "GX_DTTMTX12" );
+ strcpy( mtxsrc[34] , "GX_DTTMTX13" );
+ strcpy( mtxsrc[35] , "GX_DTTMTX14" );
+ strcpy( mtxsrc[36] , "GX_DTTMTX15" );
+ strcpy( mtxsrc[37] , "GX_DTTMTX16" );
+ strcpy( mtxsrc[38] , "GX_DTTMTX17" );
+ strcpy( mtxsrc[39] , "GX_DTTMTX18" );
+ strcpy( mtxsrc[40] , "GX_DTTMTX19" );
+ strcpy( mtxsrc[41] , "GX_DTTIDENTITY" ); // actually 125 not 124
+
+ brlyt_tex_coordgen data4;
+ BRLYT_ReadDataFromMemory(&data4, brlyt_file, sizeof(brlyt_tex_coordgen));
+ ua3 = mxmlNewElement(entries, "CoordGen");
+
+ dataa = mxmlNewElement(ua3, "tgen_type");
+ mxmlNewTextf(dataa, 0, "%s", tgen_types[data4.tgen_type]);
+ dataa = mxmlNewElement(ua3, "tgen_src");
+ mxmlNewTextf(dataa, 0, "%s", tgen_src[data4.tgen_src]);
+ dataa = mxmlNewElement(ua3, "MatrixSource");
+ mxmlNewTextf(dataa, 0, "%s", mtxsrc[data4.mtxsrc/3]);
+ dataa = mxmlNewElement(ua3, "padding"); mxmlNewTextf(dataa, 0, "%02x", data4.padding);
}
- //# Changing ua3 things
- //# 1st --> disappears.
- //# 2nd --> no visible effect.
- //# 3rd --> disappears.
- //# 4th --> no visible effect.
mxml_node_t *ua4;
//# 4 * flags[6]
for (n=0;n<bit_extract(flaggs, 6,100);n++)
{
- brlyt_4b_chunk data4;
- BRLYT_ReadDataFromMemory(&data4, brlyt_file, sizeof(brlyt_4b_chunk));
- ua4 = mxmlNewElement(entries, "ua4");
- int j; for (j=0;j<4;j++)
- {
- dataa = mxmlNewElement(ua4, "data"); mxmlNewTextf(dataa, 0, "%02x", data4.unk[j]);
- }
+ char matsrc[2][20];
+ int l;
+ for ( l = 0 ; l < 2 ; l++ )
+ memset( matsrc[l] , 0 , 20 );
+ strcpy( matsrc[0] , "GX_SRC_REG" );
+ strcpy( matsrc[1] , "GX_SRC_VTX" );
+
+ brlyt_tex_chanctrl data4;
+ BRLYT_ReadDataFromMemory(&data4, brlyt_file, sizeof(brlyt_tex_chanctrl));
+ ua4 = mxmlNewElement(entries, "ChanControl");
+
+ dataa = mxmlNewElement(ua4, "ColorMatSource");
+ mxmlNewTextf(dataa, 0, "%s", matsrc[data4.color_matsrc]);
+ dataa = mxmlNewElement(ua4, "AlphaMatSource");
+ mxmlNewTextf(dataa, 0, "%s", matsrc[data4.alpha_matsrc]);
+ dataa = mxmlNewElement(ua4, "Padding1");
+ mxmlNewTextf(dataa, 0, "%02x", data4.padding1);
+ dataa = mxmlNewElement(ua4, "Padding2");
+ mxmlNewTextf(dataa, 0, "%02x", data4.padding2);
+
}
mxml_node_t *ua5;
//# 4 * flags[4]
for (n=0;n<bit_extract(flaggs, 4,100);n++)
{
- brlyt_4b_chunk data4;
- BRLYT_ReadDataFromMemory(&data4, brlyt_file, sizeof(brlyt_4b_chunk));
- ua5 = mxmlNewElement(entries, "ua5");
- int j; for (j=0;j<4;j++)
- {
- dataa = mxmlNewElement(ua5, "data"); mxmlNewTextf(dataa, 0, "%02x", data4.unk[j]);
- }
+ brlyt_tex_matcol data4;
+ BRLYT_ReadDataFromMemory(&data4, brlyt_file, sizeof(brlyt_tex_matcol));
+ ua5 = mxmlNewElement(entries, "MaterialColor");
+
+ dataa = mxmlNewElement(ua5, "red"); mxmlNewTextf(dataa, 0, "%02x", data4.red);
+ dataa = mxmlNewElement(ua5, "green"); mxmlNewTextf(dataa, 0, "%02x", data4.green);
+ dataa = mxmlNewElement(ua5, "blue"); mxmlNewTextf(dataa, 0, "%02x", data4.blue);
+ dataa = mxmlNewElement(ua5, "alpha"); mxmlNewTextf(dataa, 0, "%02x", data4.alpha);
}
mxml_node_t *ua6;
//# 4 * flags[19]
for (n=0;n<bit_extract(flaggs, 19,100);n++)
{
- brlyt_4b_chunk data4;
- BRLYT_ReadDataFromMemory(&data4, brlyt_file, sizeof(brlyt_4b_chunk));
- ua6 = mxmlNewElement(entries, "ua6");
- int j; for (j=0;j<4;j++)
- {
- dataa = mxmlNewElement(ua6, "data"); mxmlNewTextf(dataa, 0, "%02x", data4.unk[j]);
- }
+ char tevcolor[4][20];
+ int l;
+ for ( l = 0 ; l < 4 ; l++ )
+ memset( tevcolor[l] , 0 , 20 );
+ strcpy( tevcolor[0] , "GX_CH_RED" );
+ strcpy( tevcolor[1] , "GX_CH_GREEN" );
+ strcpy( tevcolor[2] , "GX_CH_BLUE" );
+ strcpy( tevcolor[3] , "GX_CH_ALPHA" );
+
+ brlyt_tev_swapmodetable data4;
+ BRLYT_ReadDataFromMemory(&data4, brlyt_file, sizeof(brlyt_tev_swapmodetable));
+
+ ua6 = mxmlNewElement(entries, "TevSwapModeTable");
+
+ dataa = mxmlNewElement(ua6, "OneRed");
+ mxmlNewTextf(dataa, 0, "%s", tevcolor[(data4.one & 0x03) >> 0] );
+ dataa = mxmlNewElement(ua6, "OneGreen");
+ mxmlNewTextf(dataa, 0, "%s", tevcolor[(data4.one & 0x0C) >> 2] );
+ dataa = mxmlNewElement(ua6, "OneBlue");
+ mxmlNewTextf(dataa, 0, "%s", tevcolor[(data4.one & 0x30) >> 4] );
+ dataa = mxmlNewElement(ua6, "OneAlpha");
+ mxmlNewTextf(dataa, 0, "%s", tevcolor[(data4.one & 0xC0) >> 6] );
+
+ dataa = mxmlNewElement(ua6, "TwoRed");
+ mxmlNewTextf(dataa, 0, "%s", tevcolor[(data4.two & 0x03) >> 0] );
+ dataa = mxmlNewElement(ua6, "TwoGreen");
+ mxmlNewTextf(dataa, 0, "%s", tevcolor[(data4.two & 0x0C) >> 2] );
+ dataa = mxmlNewElement(ua6, "TwoBlue");
+ mxmlNewTextf(dataa, 0, "%s", tevcolor[(data4.two & 0x30) >> 4] );
+ dataa = mxmlNewElement(ua6, "TwoAlpha");
+ mxmlNewTextf(dataa, 0, "%s", tevcolor[(data4.two & 0xC0) >> 6] );
+
+ dataa = mxmlNewElement(ua6, "ThreeRed");
+ mxmlNewTextf(dataa, 0, "%s", tevcolor[(data4.three & 0x03) >> 0] );
+ dataa = mxmlNewElement(ua6, "ThreeGreen");
+ mxmlNewTextf(dataa, 0, "%s", tevcolor[(data4.three & 0x0C) >> 2] );
+ dataa = mxmlNewElement(ua6, "ThreeBlue");
+ mxmlNewTextf(dataa, 0, "%s", tevcolor[(data4.three & 0x30) >> 4] );
+ dataa = mxmlNewElement(ua6, "ThreeAlpha");
+ mxmlNewTextf(dataa, 0, "%s", tevcolor[(data4.three & 0xC0) >> 6] );
+
+ dataa = mxmlNewElement(ua6, "FourRed");
+ mxmlNewTextf(dataa, 0, "%s", tevcolor[(data4.four & 0x03) >> 0] );
+ dataa = mxmlNewElement(ua6, "FourGreen");
+ mxmlNewTextf(dataa, 0, "%s", tevcolor[(data4.four & 0x0C) >> 2] );
+ dataa = mxmlNewElement(ua6, "FourBlue");
+ mxmlNewTextf(dataa, 0, "%s", tevcolor[(data4.four & 0x30) >> 4] );
+ dataa = mxmlNewElement(ua6, "FourAlpha");
+ mxmlNewTextf(dataa, 0, "%s", tevcolor[(data4.four & 0xC0) >> 6] );
+
}
mxml_node_t *ua7, *a, *b, *c, *d, *e;
for (n=0;n<bit_extract(flaggs, 17,18);n++)
{
- brlyt_ua7_chunk data4;
- BRLYT_ReadDataFromMemory(&data4, brlyt_file, sizeof(brlyt_ua7_chunk));
- ua7 = mxmlNewElement(entries, "ua7");
- a = mxmlNewElement(ua7, "a"); mxmlNewTextf(a, 0, "%08x", be32(data4.a));
- b = mxmlNewElement(ua7, "b"); mxmlNewTextf(b, 0, "%08x", be32(data4.b));
- c = mxmlNewElement(ua7, "c"); mxmlNewTextf(c, 0, "%f", float_swap_bytes(data4.c));
- d = mxmlNewElement(ua7, "d"); mxmlNewTextf(d, 0, "%f", float_swap_bytes(data4.d));
- e = mxmlNewElement(ua7, "e"); mxmlNewTextf(e, 0, "%f", float_swap_bytes(data4.e));
+ brlyt_indtex_srt data4;
+ BRLYT_ReadDataFromMemory(&data4, brlyt_file, sizeof(brlyt_indtex_srt));
+ ua7 = mxmlNewElement(entries, "IndTextureSRT");
+ a = mxmlNewElement(ua7, "XTrans"); mxmlNewTextf(a, 0, "%f", float_swap_bytes(data4.XTrans));
+ b = mxmlNewElement(ua7, "YTrans"); mxmlNewTextf(b, 0, "%f", float_swap_bytes(data4.YTrans));
+ c = mxmlNewElement(ua7, "Rotate"); mxmlNewTextf(c, 0, "%f", float_swap_bytes(data4.Rotate));
+ d = mxmlNewElement(ua7, "XScale"); mxmlNewTextf(d, 0, "%f", float_swap_bytes(data4.XScale));
+ e = mxmlNewElement(ua7, "YScale"); mxmlNewTextf(e, 0, "%f", float_swap_bytes(data4.YScale));
}
mxml_node_t *ua8;
//# 4 * flags[14-16]
for (n=0;n<bit_extract(flaggs, 14,16);n++)
{
- brlyt_4b_chunk data4;
- BRLYT_ReadDataFromMemory(&data4, brlyt_file, sizeof(brlyt_4b_chunk));
- ua8 = mxmlNewElement(entries, "ua8");
- int j; for (j=0;j<4;j++)
- {
- dataa = mxmlNewElement(ua8, "data"); mxmlNewTextf(dataa, 0, "%02x", data4.unk[j]);
- }
+ char scale[10][20];
+ int l;
+ for ( l = 0 ; l < 10 ; l++ )
+ memset( scale[l] , 0 , 20 );
+ strcpy( scale[0] , "GX_ITS_1" );
+ strcpy( scale[1] , "GX_ITS_2" );
+ strcpy( scale[2] , "GX_ITS_4" );
+ strcpy( scale[3] , "GX_ITS_8" );
+ strcpy( scale[4] , "GX_ITS_16" );
+ strcpy( scale[5] , "GX_ITS_32" );
+ strcpy( scale[6] , "GX_ITS_64" );
+ strcpy( scale[7] , "GX_ITS_128" );
+ strcpy( scale[8] , "GX_ITS_256" );
+ strcpy( scale[9] , "GX_MAX_ITSCALE" );
+
+ brlyt_indtex_order data4;
+ BRLYT_ReadDataFromMemory(&data4, brlyt_file, sizeof(brlyt_indtex_order));
+ ua8 = mxmlNewElement(entries, "IndTextureOrder");
+
+ dataa = mxmlNewElement(ua8, "TextureCoordinate"); mxmlNewTextf(dataa, 0, "%02x", data4.tex_coord);
+ dataa = mxmlNewElement(ua8, "TextureMap"); mxmlNewTextf(dataa, 0, "%02x", data4.tex_map);
+ dataa = mxmlNewElement(ua8, "ScaleS");
+ mxmlNewTextf(dataa, 0, "%s", scale[data4.scale_s]);
+ dataa = mxmlNewElement(ua8, "ScaleT");
+ mxmlNewTextf(dataa, 0, "%s", scale[data4.scale_t]);
}
mxml_node_t *ua9;
//# 0x10 * flags[9-13]
for (n=0;n<bit_extract(flaggs, 9,13);n++)
{
- brlyt_10b_chunk data4;
- BRLYT_ReadDataFromMemory(&data4, brlyt_file, sizeof(brlyt_10b_chunk));
- ua9 = mxmlNewElement(entries, "ua9");
- int j; for (j=0;j<16;j++)
- {
- dataa = mxmlNewElement(ua9, "data");
- mxmlNewTextf(dataa, 0, "%02x", data4.unk[j]);
- }
+ TevStages data4;
+ BRLYT_ReadDataFromMemory(&data4, brlyt_file, sizeof(TevStages));
+ ua9 = mxmlNewElement(entries, "TevStage");
+
+ dataa = mxmlNewElement(ua9, "TextureCoordinate");
+ mxmlNewTextf(dataa, 0, "%02x", data4.texcoord);
+
+ dataa = mxmlNewElement(ua9, "TextureMap");
+ mxmlNewTextf(dataa, 0, "%04x", ( (data4.texmaptop << 8) | data4.texmapbot));
+
+ dataa = mxmlNewElement(ua9, "Color");
+ mxmlNewTextf(dataa, 0, "%02x", data4.color);
+
+ dataa = mxmlNewElement(ua9, "Padding1");
+ mxmlNewTextf(dataa, 0, "%01x", data4.empty1);
+
+ dataa = mxmlNewElement(ua9, "RasSelect");
+ mxmlNewTextf(dataa, 0, "%01x", data4.ras_sel);
+
+ dataa = mxmlNewElement(ua9, "TexSelect");
+ mxmlNewTextf(dataa, 0, "%01x", data4.tex_sel);
+
+ dataa = mxmlNewElement(ua9, "TevColorCombinerA");
+ mxmlNewTextf(dataa, 0, "%01x", data4.aC);
+
+ dataa = mxmlNewElement(ua9, "TevColorCombinerB");
+ mxmlNewTextf(dataa, 0, "%01x", data4.bC);
+
+ dataa = mxmlNewElement(ua9, "TevColorCombinerC");
+ mxmlNewTextf(dataa, 0, "%01x", data4.cC);
+
+ dataa = mxmlNewElement(ua9, "TevColorCombinerD");
+ mxmlNewTextf(dataa, 0, "%01x", data4.dC);
+
+ dataa = mxmlNewElement(ua9, "TevColorScale");
+ mxmlNewTextf(dataa, 0, "%01x", data4.tevscaleC);
+
+ dataa = mxmlNewElement(ua9, "TevColorBias");
+ mxmlNewTextf(dataa, 0, "%01x", data4.tevbiasC);
+
+ dataa = mxmlNewElement(ua9, "TevColorOp");
+ mxmlNewTextf(dataa, 0, "%01x", data4.tevopC);
+
+ dataa = mxmlNewElement(ua9, "TevColorClamp");
+ mxmlNewTextf(dataa, 0, "%01x", data4.clampC);
+
+ dataa = mxmlNewElement(ua9, "TevColorRegisterID");
+ mxmlNewTextf(dataa, 0, "%01x", data4.tevregidC);
+
+ dataa = mxmlNewElement(ua9, "TevKColorSelect");
+ mxmlNewTextf(dataa, 0, "%02x", data4.selC);
+
+ dataa = mxmlNewElement(ua9, "TevAlphaCombinerA");
+ mxmlNewTextf(dataa, 0, "%01x", data4.aA);
+
+ dataa = mxmlNewElement(ua9, "TevAlphaCombinerB");
+ mxmlNewTextf(dataa, 0, "%01x", data4.bA);
+
+ dataa = mxmlNewElement(ua9, "TevAlphaCombinerC");
+ mxmlNewTextf(dataa, 0, "%01x", data4.cA);
+
+ dataa = mxmlNewElement(ua9, "TevAlphaCombinerD");
+ mxmlNewTextf(dataa, 0, "%01x", data4.dA);
+
+ dataa = mxmlNewElement(ua9, "TevAlphaScale");
+ mxmlNewTextf(dataa, 0, "%01x", data4.tevscaleA);
+
+ dataa = mxmlNewElement(ua9, "TevAlphaBias");
+ mxmlNewTextf(dataa, 0, "%01x", data4.tevbiasA);
+
+ dataa = mxmlNewElement(ua9, "TevAlphaOp");
+ mxmlNewTextf(dataa, 0, "%01x", data4.tevopA);
+
+ dataa = mxmlNewElement(ua9, "TevAlphaClamp");
+ mxmlNewTextf(dataa, 0, "%01x", data4.clampA);
+
+ dataa = mxmlNewElement(ua9, "TevAlphaRegisterID");
+ mxmlNewTextf(dataa, 0, "%01x", data4.tevregidA);
+
+ dataa = mxmlNewElement(ua9, "TevKAlphaSelect");
+ mxmlNewTextf(dataa, 0, "%02x", data4.selA);
+
+ dataa = mxmlNewElement(ua9, "IndirectTextureID");
+ mxmlNewTextf(dataa, 0, "%02x", data4.indtexid);
+
+ dataa = mxmlNewElement(ua9, "IndirectTextureFormat");
+ mxmlNewTextf(dataa, 0, "%01x", data4.format);
+
+ dataa = mxmlNewElement(ua9, "IndirectTextureBias");
+ mxmlNewTextf(dataa, 0, "%01x", data4.bias);
+
+ dataa = mxmlNewElement(ua9, "IndirectTextureMatrixID");
+ mxmlNewTextf(dataa, 0, "%01x", data4.mtxid);
+
+ dataa = mxmlNewElement(ua9, "IndirectTextureWrapS");
+ mxmlNewTextf(dataa, 0, "%01x", data4.wrap_s);
+
+ dataa = mxmlNewElement(ua9, "IndirectTextureWrapT");
+ mxmlNewTextf(dataa, 0, "%01x", data4.wrap_t);
+
+ dataa = mxmlNewElement(ua9, "IndirectTextureAddPrevious");
+ mxmlNewTextf(dataa, 0, "%01x", data4.addprev);
+
+ dataa = mxmlNewElement(ua9, "IndirectTextureUTClod");
+ mxmlNewTextf(dataa, 0, "%01x", data4.utclod);
+
+ dataa = mxmlNewElement(ua9, "IndirectTextureA");
+ mxmlNewTextf(dataa, 0, "%01x", data4.aIND);
+
+ dataa = mxmlNewElement(ua9, "Padding2");
+ mxmlNewTextf(dataa, 0, "%01x", data4.empty2);
+
+ dataa = mxmlNewElement(ua9, "Padding3");
+ mxmlNewTextf(dataa, 0, "%01x", data4.empty3);
+
+ dataa = mxmlNewElement(ua9, "Padding4");
+ mxmlNewTextf(dataa, 0, "%01x", data4.empty4);
+
}
mxml_node_t *uaa;
- //# 4 * flags[8], these are bytes btw
+ //# 4 * flags[8]
for (n=0;n<bit_extract(flaggs, 8,8);n++)
{
- brlyt_4b_chunk data4;
- BRLYT_ReadDataFromMemory(&data4, brlyt_file, sizeof(brlyt_4b_chunk));
- uaa = mxmlNewElement(entries, "uaa");
- int j; for (j=0;j<4;j++)
- {
- dataa = mxmlNewElement(uaa, "data"); mxmlNewTextf(dataa, 0, "%02x", data4.unk[j]);
- }
+ char compare[8][20];
+ int l;
+ for ( l = 0 ; l < 8 ; l++ )
+ memset( compare[l] , 0 , 20 );
+ strcpy( compare[0] , "GX_NEVER" );
+ strcpy( compare[1] , "GX_LESS" );
+ strcpy( compare[2] , "GX_EQUAL" );
+ strcpy( compare[3] , "GX_LEQUAL" );
+ strcpy( compare[4] , "GX_GREATER" );
+ strcpy( compare[5] , "GX_NEQUAL" );
+ strcpy( compare[6] , "GX_GEQUAL" );
+ strcpy( compare[7] , "GX_ALWAYS" );
+
+ char aop[5][20];
+ for ( l = 0 ; l < 5 ; l++ )
+ memset( aop[l] , 0 , 20 );
+ strcpy( aop[0] , "GX_AOP_AND" );
+ strcpy( aop[1] , "GX_AOP_OR" );
+ strcpy( aop[2] , "GX_AOP_XOR" );
+ strcpy( aop[3] , "GX_AOP_XNOR" );
+ strcpy( aop[4] , "GX_MAX_ALPHAOP" );
+
+ brlyt_alpha_compare data4;
+ BRLYT_ReadDataFromMemory(&data4, brlyt_file, sizeof(brlyt_alpha_compare));
+ uaa = mxmlNewElement(entries, "AlphaCompare");
+ dataa = mxmlNewElement(uaa, "comp0");
+ mxmlNewTextf(dataa, 0, "%s", compare[data4.comp0]);
+ dataa = mxmlNewElement(uaa, "comp1");
+ mxmlNewTextf(dataa, 0, "%s", compare[data4.comp1]);
+ dataa = mxmlNewElement(uaa, "aop");
+ mxmlNewTextf(dataa, 0, "%s", aop[data4.aop]);
+ dataa = mxmlNewElement(uaa, "ref0"); mxmlNewTextf(dataa, 0, "%02x", data4.ref0);
+ dataa = mxmlNewElement(uaa, "ref1"); mxmlNewTextf(dataa, 0, "%02x", data4.ref1);
}
mxml_node_t *uab;
//# 4 * flags[7]
for (n=0;n<bit_extract(flaggs, 7,7);n++)
{
- brlyt_4b_chunk data4;
- BRLYT_ReadDataFromMemory(&data4, brlyt_file, sizeof(brlyt_4b_chunk));
- uab = mxmlNewElement(entries, "uab");
- int j; for (j=0;j<4;j++)
- {
- dataa = mxmlNewElement(uab, "data"); mxmlNewTextf(dataa, 0, "%02x", data4.unk[j]);
- }
+ char blendmode[5][20];
+ int l;
+ for ( l = 0 ; l < 5 ; l++ )
+ memset( blendmode[l] , 0 , 20 );
+ strcpy( blendmode[0] , "GX_BM_NONE" );
+ strcpy( blendmode[1] , "GX_BM_BLEND" );
+ strcpy( blendmode[2] , "GX_BM_LOGIC" );
+ strcpy( blendmode[3] , "GX_BM_SUBTRACT" );
+ strcpy( blendmode[4] , "GX_MAX_BLENDMODE" );
+
+ char blendfactor[8][20];
+ for ( l = 0 ; l < 8 ; l++ )
+ memset( blendfactor[l] , 0 , 20 );
+ strcpy( blendfactor[0] , "GX_BL_ZERO" );
+ strcpy( blendfactor[1] , "GX_BL_ONE" );
+ strcpy( blendfactor[2] , "GX_BL_SRCCLR" );
+ strcpy( blendfactor[3] , "GX_BL_INVSRCCLR" );
+ strcpy( blendfactor[4] , "GX_BL_SRCALPHA" );
+ strcpy( blendfactor[5] , "GX_BL_INVSRCALPHA" );
+ strcpy( blendfactor[6] , "GX_BL_DSTALPHA" );
+ strcpy( blendfactor[7] , "GX_BL_INVDSTALPHA" );
+
+ char logicop[16][20];
+ for ( l = 0 ; l < 16 ; l++ )
+ memset( logicop[l] , 0 , 20 );
+ strcpy( logicop[0] , "GX_LO_CLEAR" );
+ strcpy( logicop[1] , "GX_LO_AND" );
+ strcpy( logicop[2] , "GX_LO_REVAND" );
+ strcpy( logicop[3] , "GX_LO_COPY" );
+ strcpy( logicop[4] , "GX_LO_INVAND" );
+ strcpy( logicop[5] , "GX_LO_NOOP" );
+ strcpy( logicop[6] , "GX_LO_XOR" );
+ strcpy( logicop[7] , "GX_LO_OR" );
+ strcpy( logicop[8] , "GX_LO_NOR" );
+ strcpy( logicop[9] , "GX_LO_EQUIV" );
+ strcpy( logicop[10] , "GX_LO_INV" );
+ strcpy( logicop[11] , "GX_LO_REVOR" );
+ strcpy( logicop[12] , "GX_LO_INVCOPY" );
+ strcpy( logicop[13] , "GX_LO_INVOR" );
+ strcpy( logicop[14] , "GX_LO_NAND" );
+ strcpy( logicop[15] , "GX_LO_SET" );
+
+ brlyt_blend_mode data4;
+ BRLYT_ReadDataFromMemory(&data4, brlyt_file, sizeof(brlyt_blend_mode));
+ uab = mxmlNewElement(entries, "BlendMode");
+
+ dataa = mxmlNewElement(uab, "type");
+ mxmlNewTextf(dataa, 0, "%s", blendmode[data4.type]);
+ dataa = mxmlNewElement(uab, "src_fact");
+ mxmlNewTextf(dataa, 0, "%s", blendfactor[data4.src_fact]);
+ dataa = mxmlNewElement(uab, "dst_fact");
+ mxmlNewTextf(dataa, 0, "%s", blendfactor[data4.dst_fact]);
+ dataa = mxmlNewElement(uab, "op");
+ mxmlNewTextf(dataa, 0, "%s", logicop[data4.op]);
+
}
BRLYT_fileoffset = tempDataLocation;
}
@@ -863,9 +1322,9 @@ void parse_brlyt(char *filename, char *filenameout)
free(textures);
}
-void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* blobsize, char temp[4], FILE* fp, unsigned int *fileOffset)
+void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* blobsize, char temp[4], FILE* fp, u32 *fileOffset)
{
- unsigned int startOfChunk = *fileOffset;
+ u32 startOfChunk = *fileOffset;
char lyt1[4] = {'l', 'y', 't', '1'};
char txl1[4] = {'t', 'x', 'l', '1'};
@@ -886,12 +1345,12 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl
{
brlyt_lytheader_chunk lytheader;
- mxml_node_t *subnode = mxmlFindElement(node , node , "a", NULL, NULL, MXML_DESCEND);
+ mxml_node_t *subnode = mxmlFindElement(node , node , "drawnFromMiddle", NULL, NULL, MXML_DESCEND);
if (subnode != NULL)
{
char tempChar[4];
get_value(subnode, tempChar, 256);
- lytheader.a = atoi(tempChar);
+ lytheader.drawnFromMiddle = atoi(tempChar);
lytheader.pad[0]=0;lytheader.pad[1]=0;lytheader.pad[2]=0;
}
subnode = mxmlFindElement(node, node, "size", NULL, NULL, MXML_DESCEND);
@@ -981,7 +1440,7 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl
int i;
for(i=0;i<numEntries;i++) {
offsunks[(i*2)+0] = be32(offsunks[(i*2)+0] + (numEntries * 8));
- offsunks[i*2+1] = 0; // MIGHT NOT BE 0 ? //
+ offsunks[i*2+1] = 0;
fwrite(&offsunks[i*2], sizeof(u32), 1, fp);
fwrite(&offsunks[i*2+1], sizeof(u32), 1, fp);
@@ -1151,13 +1610,13 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl
colorNumber+=1;
}
colorNumber = 0;
- for (valnode=mxmlFindElement(setnode, setnode, "unk2", NULL, NULL, MXML_DESCEND) ; valnode != NULL ; valnode=mxmlFindElement(valnode, setnode, "unk2", NULL, NULL, MXML_DESCEND) )
+ for (valnode=mxmlFindElement(setnode, setnode, "colorReg3", NULL, NULL, MXML_DESCEND) ; valnode != NULL ; valnode=mxmlFindElement(valnode, setnode, "colorReg3", NULL, NULL, MXML_DESCEND) )
{
char tempCoord[256];
get_value(valnode, tempCoord, 256);
- chunk.unk_color_2[colorNumber] = strtol(tempCoord, NULL, 10);
- chunk.unk_color_2[colorNumber] = short_swap_bytes(chunk.unk_color_2[colorNumber]);
+ chunk.colorReg3[colorNumber] = strtol(tempCoord, NULL, 10);
+ chunk.colorReg3[colorNumber] = short_swap_bytes(chunk.colorReg3[colorNumber]);
colorNumber+=1;
}
@@ -1169,7 +1628,8 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl
chunk.tev_kcolor[colorNumber] = be32(strtoul(tempCoord, NULL, 16));
colorNumber+=1;
}
- }
+ }
+ /*
setnode = mxmlFindElement(subnode,subnode,"flags",NULL,NULL,MXML_DESCEND);
if (setnode != NULL)
{
@@ -1177,6 +1637,12 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl
get_value(setnode, tempCoord, 256);
chunk.flags = be32(strtoul(tempCoord, NULL, 16));
}
+ */
+
+ u32 tempFileOffset = ftell(fp);
+ mat1_flags flags;
+ flags.flags = 0;
+ chunk.flags = 0;
fwrite(&chunk, sizeof(chunk), 1, fp);
*fileOffset = *fileOffset + sizeof(chunk);
@@ -1197,220 +1663,1010 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl
valnode=mxmlFindElement(setnode, setnode, "wrap_s", NULL, NULL, MXML_DESCEND);
- char tempCoord[256];
+ char wraps[4][20];
+ int l;
+ for ( l = 0 ; l < 4 ; l++ )
+ memset( wraps , 0 , 20 );
+ strcpy( wraps[0] , "GX_CLAMP" );
+ strcpy( wraps[1] , "GX_REPEAT" );
+ strcpy( wraps[2] , "GX_MIRROR" );
+ strcpy( wraps[3] , "GX_MAXTEXWRAPMODE" );
+
+ char tempCoord[256];
get_value(valnode, tempCoord, 256);
- chunkTexRef.wrap_s = strtoul(tempCoord, NULL, 16);
+ chunkTexRef.wrap_s = strtoul(tempCoord, NULL, 16);
+ for ( l = 0 ; l < 4 ; l++ ) {
+ if ( strncmp( wraps[l] , tempCoord , 17 ) == 0 ) {
+ chunkTexRef.wrap_s = l;
+ break;
+ }
+ }
valnode=mxmlFindElement(setnode, setnode, "wrap_t", NULL, NULL, MXML_DESCEND);
get_value(valnode, tempCoord, 256);
- chunkTexRef.wrap_t = strtoul(tempCoord, NULL, 16);
+ chunkTexRef.wrap_t = strtoul(tempCoord, NULL, 16);
+ for ( l = 0 ; l < 4 ; l++ ) {
+ if ( strncmp( wraps[l] , tempCoord , 17 ) == 0 ) {
+ chunkTexRef.wrap_t = l;
+ break;
+ }
+ }
+
+ flags.flag.Texture++;
fwrite(&chunkTexRef, sizeof(chunkTexRef), 1, fp);
*fileOffset = *fileOffset + sizeof(chunkTexRef);
matSize += sizeof(chunkTexRef);
}
- brlyt_tex_coords chunkTexCoords;
- for(setnode = mxmlFindElement(subnode, subnode, "tex_coords", NULL, NULL, MXML_DESCEND); setnode != NULL; setnode = mxmlFindElement(setnode, subnode, "tex_coords", NULL, NULL, MXML_DESCEND))
+ brlyt_tex_srt chunkTexCoords;
+ for(setnode = mxmlFindElement(subnode, subnode, "TextureSRT", NULL, NULL, MXML_DESCEND); setnode != NULL; setnode = mxmlFindElement(setnode, subnode, "TextureSRT", NULL, NULL, MXML_DESCEND))
{
char tempCoord[256];
mxml_node_t *valnode;
- valnode=mxmlFindElement(setnode, setnode, "x1", NULL, NULL, MXML_DESCEND);
+ valnode=mxmlFindElement(setnode, setnode, "XTrans", NULL, NULL, MXML_DESCEND);
memset(tempCoord, 0, 256);
get_value(valnode, tempCoord, 256);
- chunkTexCoords.x1 = float_swap_bytes(atof(tempCoord));
- valnode=mxmlFindElement(setnode, setnode, "y1", NULL, NULL, MXML_DESCEND);
+ chunkTexCoords.XTrans = float_swap_bytes(atof(tempCoord));
+ valnode=mxmlFindElement(setnode, setnode, "YTrans", NULL, NULL, MXML_DESCEND);
memset(tempCoord, 0, 256);
get_value(valnode, tempCoord, 256);
- chunkTexCoords.y1 = float_swap_bytes(atof(tempCoord));
- valnode=mxmlFindElement(setnode, setnode, "angle", NULL, NULL, MXML_DESCEND);
+ chunkTexCoords.YTrans = float_swap_bytes(atof(tempCoord));
+ valnode=mxmlFindElement(setnode, setnode, "Rotate", NULL, NULL, MXML_DESCEND);
memset(tempCoord, 0, 256);
get_value(valnode, tempCoord, 256);
- chunkTexCoords.angle = float_swap_bytes(atof(tempCoord));
- valnode=mxmlFindElement(setnode, setnode, "x2", NULL, NULL, MXML_DESCEND);
+ chunkTexCoords.Rotate = float_swap_bytes(atof(tempCoord));
+ valnode=mxmlFindElement(setnode, setnode, "XScale", NULL, NULL, MXML_DESCEND);
memset(tempCoord, 0, 256);
get_value(valnode, tempCoord, 256);
- chunkTexCoords.x2 = float_swap_bytes(atof(tempCoord));
- valnode=mxmlFindElement(setnode, setnode, "y2", NULL, NULL, MXML_DESCEND);
+ chunkTexCoords.XScale = float_swap_bytes(atof(tempCoord));
+ valnode=mxmlFindElement(setnode, setnode, "YScale", NULL, NULL, MXML_DESCEND);
memset(tempCoord, 0, 256);
get_value(valnode, tempCoord, 256);
- chunkTexCoords.y2 = float_swap_bytes(atof(tempCoord));
+ chunkTexCoords.YScale = float_swap_bytes(atof(tempCoord));
+
+ flags.flag.TexSRT++;
+
fwrite(&chunkTexCoords, sizeof(chunkTexCoords), 1, fp);
*fileOffset = *fileOffset + sizeof(chunkTexCoords);
matSize += sizeof(chunkTexCoords);
}
- brlyt_4b_chunk chunkUa3;
- for(setnode = mxmlFindElement(subnode, subnode, "ua3", NULL, NULL, MXML_DESCEND); setnode != NULL; setnode = mxmlFindElement(setnode, subnode, "ua3", NULL, NULL, MXML_DESCEND))
+
+ brlyt_tex_coordgen chunkUa3;
+ for(setnode = mxmlFindElement(subnode, subnode, "CoordGen", NULL, NULL, MXML_DESCEND); setnode != NULL; setnode = mxmlFindElement(setnode, subnode, "CoordGen", NULL, NULL, MXML_DESCEND))
{
+ char tgen_types[4][20];
+ int l;
+ for ( l = 0 ; l < 4 ; l++ )
+ memset( tgen_types , 0 , 20 );
+ strcpy( tgen_types[0] , "GX_TG_MTX3x4" );
+ strcpy( tgen_types[1] , "GX_TG_MTX2x4" );
+ strcpy( tgen_types[2] , "GX_TG_BUMP0" );
+ strcpy( tgen_types[3] , "GX_TG_BUMP1" );
+ strcpy( tgen_types[4] , "GX_TG_BUMP2" );
+ strcpy( tgen_types[5] , "GX_TG_BUMP3" );
+ strcpy( tgen_types[6] , "GX_TG_BUMP4" );
+ strcpy( tgen_types[7] , "GX_TG_BUMP5" );
+ strcpy( tgen_types[8] , "GX_TG_BUMP6" );
+ strcpy( tgen_types[9] , "GX_TG_BUMP7" );
+ strcpy( tgen_types[10] , "GX_TG_SRTG" );
+
+ char tgen_src[21][20];
+ for ( l = 0 ; l < 21 ; l++ )
+ memset( tgen_src[l] , 0 , 20 );
+ strcpy( tgen_src[0] , "GX_TG_POS" );
+ strcpy( tgen_src[1] , "GX_TG_NRM" );
+ strcpy( tgen_src[2] , "GX_TG_BINRM" );
+ strcpy( tgen_src[3] , "GX_TG_TANGEN" );
+ strcpy( tgen_src[4] , "GX_TG_TEX0" );
+ strcpy( tgen_src[5] , "GX_TG_TEX1" );
+ strcpy( tgen_src[6] , "GX_TG_TEX2" );
+ strcpy( tgen_src[7] , "GX_TG_TEX3" );
+ strcpy( tgen_src[8] , "GX_TG_TEX4" );
+ strcpy( tgen_src[9] , "GX_TG_TEX5" );
+ strcpy( tgen_src[10] , "GX_TG_TEX6" );
+ strcpy( tgen_src[11] , "GX_TG_TEX7" );
+ strcpy( tgen_src[12] , "GX_TG_TEXCOORD0" );
+ strcpy( tgen_src[13] , "GX_TG_TEXCOORD1" );
+ strcpy( tgen_src[14] , "GX_TG_TEXCOORD2" );
+ strcpy( tgen_src[15] , "GX_TG_TEXCOORD3" );
+ strcpy( tgen_src[16] , "GX_TG_TEXCOORD4" );
+ strcpy( tgen_src[17] , "GX_TG_TEXCOORD5" );
+ strcpy( tgen_src[18] , "GX_TG_TEXCOORD6" );
+ strcpy( tgen_src[19] , "GX_TG_COLOR0" );
+ strcpy( tgen_src[20] , "GX_TG_COLOR1" );
+
+ char mtxsrc[42][20];
+ for ( l = 0 ; l < 42 ; l++ )
+ memset( mtxsrc[l] , 0 , 20 );
+ strcpy( mtxsrc[0] , "GX_PNMTX0" );
+ strcpy( mtxsrc[1] , "GX_PNMTX1" );
+ strcpy( mtxsrc[2] , "GX_PNMTX2" );
+ strcpy( mtxsrc[3] , "GX_PNMTX3" );
+ strcpy( mtxsrc[4] , "GX_PNMTX4" );
+ strcpy( mtxsrc[5] , "GX_PNMTX5" );
+ strcpy( mtxsrc[6] , "GX_PNMTX6" );
+ strcpy( mtxsrc[7] , "GX_PNMTX7" );
+ strcpy( mtxsrc[8] , "GX_PNMTX8" );
+ strcpy( mtxsrc[9] , "GX_PNMTX9" );
+ strcpy( mtxsrc[10] , "GX_TEXMTX0" );
+ strcpy( mtxsrc[11] , "GX_TEXMTX1" );
+ strcpy( mtxsrc[12] , "GX_TEXMTX2" );
+ strcpy( mtxsrc[13] , "GX_TEXMTX3" );
+ strcpy( mtxsrc[14] , "GX_TEXMTX4" );
+ strcpy( mtxsrc[15] , "GX_TEXMTX5" );
+ strcpy( mtxsrc[16] , "GX_TEXMTX6" );
+ strcpy( mtxsrc[17] , "GX_TEXMTX7" );
+ strcpy( mtxsrc[18] , "GX_TEXMTX8" );
+ strcpy( mtxsrc[19] , "GX_TEXMTX9" );
+ strcpy( mtxsrc[20] , "GX_IDENTITY" );
+ strcpy( mtxsrc[21] , "GX_DTTMTX0" );
+ strcpy( mtxsrc[22] , "GX_DTTMTX1" );
+ strcpy( mtxsrc[23] , "GX_DTTMTX2" );
+ strcpy( mtxsrc[24] , "GX_DTTMTX3" );
+ strcpy( mtxsrc[25] , "GX_DTTMTX4" );
+ strcpy( mtxsrc[26] , "GX_DTTMTX5" );
+ strcpy( mtxsrc[27] , "GX_DTTMTX6" );
+ strcpy( mtxsrc[28] , "GX_DTTMTX7" );
+ strcpy( mtxsrc[29] , "GX_DTTMTX8" );
+ strcpy( mtxsrc[30] , "GX_DTTMTX9" );
+ strcpy( mtxsrc[31] , "GX_DTTMTX1" );
+ strcpy( mtxsrc[32] , "GX_DTTMTX1" );
+ strcpy( mtxsrc[33] , "GX_DTTMTX12" );
+ strcpy( mtxsrc[34] , "GX_DTTMTX13" );
+ strcpy( mtxsrc[35] , "GX_DTTMTX14" );
+ strcpy( mtxsrc[36] , "GX_DTTMTX15" );
+ strcpy( mtxsrc[37] , "GX_DTTMTX16" );
+ strcpy( mtxsrc[38] , "GX_DTTMTX17" );
+ strcpy( mtxsrc[39] , "GX_DTTMTX18" );
+ strcpy( mtxsrc[40] , "GX_DTTMTX19" );
+ strcpy( mtxsrc[41] , "GX_DTTIDENTITY" ); // actually 125 not 124
+
mxml_node_t *valnode;
- int dataNumber = 0;
- for (valnode=mxmlFindElement(setnode, setnode, "data", NULL, NULL, MXML_DESCEND) ; valnode != NULL ; valnode=mxmlFindElement(valnode, setnode, "data", NULL, NULL, MXML_DESCEND) )
- {
- char tempCoord[256];
- get_value(valnode, tempCoord, 256);
- chunkUa3.unk[dataNumber] = strtoul(tempCoord, NULL, 16);
- dataNumber+=1;
- }
+ char tempCoord[256];
+
+ valnode=mxmlFindElement(setnode, setnode, "tgen_type", NULL, NULL, MXML_DESCEND);
+ memset(tempCoord,0,256);
+ get_value( valnode , tempCoord , 256 );
+ chunkUa3.tgen_type = strtoul( tempCoord , NULL , 16 );
+ for ( l = 0 ; l < 11 ; l++ ){
+ if ( strncmp( tgen_types[l] , tempCoord , 14 ) == 0 ) {
+ chunkUa3.tgen_type = l;
+ break;
+ }
+ }
+
+ valnode=mxmlFindElement(setnode, setnode, "tgen_src", NULL, NULL, MXML_DESCEND);
+ memset(tempCoord,0,256);
+ get_value( valnode , tempCoord , 256 );
+ chunkUa3.tgen_src = strtoul( tempCoord , NULL , 16 );
+ for ( l = 0 ; l < 21 ; l++ ){
+ if ( strncmp( tgen_src[l] , tempCoord , 20 ) == 0 ) {
+ chunkUa3.tgen_src = l;
+ break;
+ }
+ }
+
+ valnode=mxmlFindElement(setnode, setnode, "MatrixSource", NULL, NULL, MXML_DESCEND);
+ memset(tempCoord,0,256);
+ get_value( valnode , tempCoord , 256 );
+ chunkUa3.mtxsrc = strtoul( tempCoord , NULL , 16 );
+ for ( l = 0 ; l < 42 ; l++ ){
+ if ( strncmp( mtxsrc[l] , tempCoord , 14 ) == 0 ) {
+ chunkUa3.mtxsrc = l*3;
+ break;
+ }
+ }
+
+
+ valnode=mxmlFindElement(setnode, setnode, "padding", NULL, NULL, MXML_DESCEND);
+ memset(tempCoord,0,256);
+ get_value( valnode , tempCoord , 256 );
+ chunkUa3.padding = strtoul( tempCoord , NULL , 16 );
+ // padding should be 0
+ chunkUa3.padding = 0;
+
+ flags.flag.TexCoord++;
+
fwrite(&chunkUa3, sizeof(chunkUa3), 1, fp);
*fileOffset = *fileOffset + sizeof(chunkUa3);
matSize += sizeof(chunkUa3);
}
- brlyt_4b_chunk chunkUa4;
- for(setnode = mxmlFindElement(subnode, subnode, "ua4", NULL, NULL, MXML_DESCEND); setnode != NULL; setnode = mxmlFindElement(setnode, subnode, "ua4", NULL, NULL, MXML_DESCEND))
+
+ brlyt_tex_chanctrl chunkUa4;
+ for(setnode = mxmlFindElement(subnode, subnode, "ChanControl", NULL, NULL, MXML_DESCEND); setnode != NULL; setnode = mxmlFindElement(setnode, subnode, "ChanControl", NULL, NULL, MXML_DESCEND))
{
+ char matsrc[2][20];
+ int l;
+ for ( l = 0 ; l < 2 ; l++ )
+ memset( matsrc[l] , 0 , 20 );
+ strcpy( matsrc[0] , "GX_SRC_REG" );
+ strcpy( matsrc[1] , "GX_SRC_VTX" );
+
mxml_node_t *valnode;
- int dataNumber = 0;
- for (valnode=mxmlFindElement(setnode, setnode, "data", NULL, NULL, MXML_DESCEND) ; valnode != NULL ; valnode=mxmlFindElement(valnode, setnode, "data", NULL, NULL, MXML_DESCEND) )
- {
- char tempCoord[256];
- get_value(valnode, tempCoord, 256);
- chunkUa4.unk[dataNumber] = strtoul(tempCoord, NULL, 16);
- dataNumber+=1;
- }
+ char tempCoord[256];
+
+ valnode=mxmlFindElement(setnode, setnode, "ColorMatSource", NULL, NULL, MXML_DESCEND);
+ memset( tempCoord , 0 , 256 );
+ get_value( valnode , tempCoord , 256 );
+ chunkUa4.color_matsrc = strtoul( tempCoord , NULL , 16 );
+ for ( l = 0 ; l < 2 ; l++ ){
+ if ( strncmp( matsrc[l] , tempCoord , 14 ) == 0 ) {
+ chunkUa4.color_matsrc = l;
+ break;
+ }
+ }
+
+ valnode=mxmlFindElement(setnode, setnode, "AlphaMatSource", NULL, NULL, MXML_DESCEND);
+ memset( tempCoord , 0 , 256 );
+ get_value( valnode , tempCoord , 256 );
+ chunkUa4.alpha_matsrc = strtoul( tempCoord , NULL , 16 );
+ for ( l = 0 ; l < 2 ; l++ ){
+ if ( strncmp( matsrc[l] , tempCoord , 14 ) == 0 ) {
+ chunkUa4.alpha_matsrc = l;
+ break;
+ }
+ }
+
+ valnode=mxmlFindElement(setnode, setnode, "Padding1", NULL, NULL, MXML_DESCEND);
+ memset( tempCoord , 0 , 256 );
+ get_value( valnode , tempCoord , 256 );
+ chunkUa4.padding1 = strtoul( tempCoord , NULL , 16 );
+ // padding should be 0
+ chunkUa4.padding1 = 0;
+
+ valnode=mxmlFindElement(setnode, setnode, "Padding2", NULL, NULL, MXML_DESCEND);
+ memset( tempCoord , 0 , 256 );
+ get_value( valnode , tempCoord , 256 );
+ chunkUa4.padding2 = strtoul( tempCoord , NULL , 16 );
+ // padding should be 0
+ chunkUa4.padding2 = 0;
+
+ flags.flag.ua4++;
+
fwrite(&chunkUa4, sizeof(chunkUa4), 1, fp);
*fileOffset = *fileOffset + sizeof(chunkUa4);
matSize += sizeof(chunkUa4);
}
- brlyt_4b_chunk chunkUa5;
- for(setnode = mxmlFindElement(subnode, subnode, "ua5", NULL, NULL, MXML_DESCEND); setnode != NULL; setnode = mxmlFindElement(setnode, subnode, "ua5", NULL, NULL, MXML_DESCEND))
+
+ brlyt_tex_matcol chunkUa5;
+ for(setnode = mxmlFindElement(subnode, subnode, "MaterialColor", NULL, NULL, MXML_DESCEND); setnode != NULL; setnode = mxmlFindElement(setnode, subnode, "MaterialColor", NULL, NULL, MXML_DESCEND))
{
mxml_node_t *valnode;
- int dataNumber = 0;
- for (valnode=mxmlFindElement(setnode, setnode, "data", NULL, NULL, MXML_DESCEND) ; valnode != NULL ; valnode=mxmlFindElement(valnode, setnode, "data", NULL, NULL, MXML_DESCEND) )
- {
- char tempCoord[256];
- get_value(valnode, tempCoord, 256);
- chunkUa5.unk[dataNumber] = strtoul(tempCoord, NULL, 16);
- dataNumber+=1;
- }
+ char tempCoord[256];
+
+ valnode=mxmlFindElement(setnode, setnode, "red", NULL, NULL, MXML_DESCEND);
+ memset( tempCoord , 0 , 256 );
+ get_value( valnode , tempCoord , 256 );
+ chunkUa5.red = strtoul( tempCoord , NULL , 16 );
+
+ valnode=mxmlFindElement(setnode, setnode, "green", NULL, NULL, MXML_DESCEND);
+ memset( tempCoord , 0 , 256 );
+ get_value( valnode , tempCoord , 256 );
+ chunkUa5.green = strtoul( tempCoord , NULL , 16 );
+
+ valnode=mxmlFindElement(setnode, setnode, "blue", NULL, NULL, MXML_DESCEND);
+ memset( tempCoord , 0 , 256 );
+ get_value( valnode , tempCoord , 256 );
+ chunkUa5.blue = strtoul( tempCoord , NULL , 16 );
+
+ valnode=mxmlFindElement(setnode, setnode, "alpha", NULL, NULL, MXML_DESCEND);
+ memset( tempCoord , 0 , 256 );
+ get_value( valnode , tempCoord , 256 );
+ chunkUa5.alpha = strtoul( tempCoord , NULL , 16 );
+
+ flags.flag.ua5++;
+
fwrite(&chunkUa5, sizeof(chunkUa5), 1, fp);
*fileOffset = *fileOffset + sizeof(chunkUa5);
matSize += sizeof(chunkUa5);
}
- brlyt_4b_chunk chunkUa6;
- for(setnode = mxmlFindElement(subnode, subnode, "ua6", NULL, NULL, MXML_DESCEND); setnode != NULL; setnode = mxmlFindElement(setnode, subnode, "ua6", NULL, NULL, MXML_DESCEND))
+ brlyt_tev_swapmodetable chunkUa6;
+ for(setnode = mxmlFindElement(subnode, subnode, "TevSwapModeTable", NULL, NULL, MXML_DESCEND); setnode != NULL; setnode = mxmlFindElement(setnode, subnode, "TevSwapModeTable", NULL, NULL, MXML_DESCEND))
{
+ char tevcolor[4][20];
+ int l;
+ for ( l = 0 ; l < 4 ; l++ )
+ memset( tevcolor[l] , 0 , 20 );
+ strcpy( tevcolor[0] , "GX_CH_RED" );
+ strcpy( tevcolor[1] , "GX_CH_GREEN" );
+ strcpy( tevcolor[2] , "GX_CH_BLUE" );
+ strcpy( tevcolor[3] , "GX_CH_ALPHA" );
+
mxml_node_t *valnode;
- int dataNumber = 0;
- for (valnode=mxmlFindElement(setnode, setnode, "data", NULL, NULL, MXML_DESCEND) ; valnode != NULL ; valnode=mxmlFindElement(valnode, setnode, "data", NULL, NULL, MXML_DESCEND) )
- {
- char tempCoord[256];
- get_value(valnode, tempCoord, 256);
- chunkUa6.unk[dataNumber] = strtoul(tempCoord, NULL, 16);
- dataNumber+=1;
- }
+ char tempCoord[256];
+
+ valnode=mxmlFindElement(setnode, setnode, "OneRed", NULL, NULL, MXML_DESCEND);
+ memset( tempCoord , 0 , 256 );
+ get_value( valnode , tempCoord , 256 );
+ char red = strtoul( tempCoord , NULL , 16 );
+ for ( l = 0 ; l < 4 ; l++ ){
+ if ( strncmp( tevcolor[l] , tempCoord , 14 ) == 0 ) {
+ red = l;
+ break;
+ }
+ }
+
+ valnode=mxmlFindElement(setnode, setnode, "OneGreen", NULL, NULL, MXML_DESCEND);
+ memset( tempCoord , 0 , 256 );
+ get_value( valnode , tempCoord , 256 );
+ char green = strtoul( tempCoord , NULL , 16 );
+ for ( l = 0 ; l < 4 ; l++ ){
+ if ( strncmp( tevcolor[l] , tempCoord , 14 ) == 0 ) {
+ green = l;
+ break;
+ }
+ }
+
+ valnode=mxmlFindElement(setnode, setnode, "OneBlue", NULL, NULL, MXML_DESCEND);
+ memset( tempCoord , 0 , 256 );
+ get_value( valnode , tempCoord , 256 );
+ char blue = strtoul( tempCoord , NULL , 16 );
+ for ( l = 0 ; l < 4 ; l++ ){
+ if ( strncmp( tevcolor[l] , tempCoord , 14 ) == 0 ) {
+ blue = l;
+ break;
+ }
+ }
+
+ valnode=mxmlFindElement(setnode, setnode, "OneAlpha", NULL, NULL, MXML_DESCEND);
+ memset( tempCoord , 0 , 256 );
+ get_value( valnode , tempCoord , 256 );
+ char alpha = strtoul( tempCoord , NULL , 16 );
+ for ( l = 0 ; l < 4 ; l++ ){
+ if ( strncmp( tevcolor[l] , tempCoord , 14 ) == 0 ) {
+ alpha = l;
+ break;
+ }
+ }
+
+ chunkUa6.one = ( red << 0 ) | ( green << 2 ) | ( blue << 4 ) | ( alpha << 6 );
+
+ valnode=mxmlFindElement(setnode, setnode, "TwoRed", NULL, NULL, MXML_DESCEND);
+ memset( tempCoord , 0 , 256 );
+ get_value( valnode , tempCoord , 256 );
+ red = strtoul( tempCoord , NULL , 16 );
+ for ( l = 0 ; l < 4 ; l++ ){
+ if ( strncmp( tevcolor[l] , tempCoord , 14 ) == 0 ) {
+ red = l;
+ break;
+ }
+ }
+
+ valnode=mxmlFindElement(setnode, setnode, "TwoGreen", NULL, NULL, MXML_DESCEND);
+ memset( tempCoord , 0 , 256 );
+ get_value( valnode , tempCoord , 256 );
+ green = strtoul( tempCoord , NULL , 16 );
+ for ( l = 0 ; l < 4 ; l++ ){
+ if ( strncmp( tevcolor[l] , tempCoord , 14 ) == 0 ) {
+ green = l;
+ break;
+ }
+ }
+
+ valnode=mxmlFindElement(setnode, setnode, "TwoBlue", NULL, NULL, MXML_DESCEND);
+ memset( tempCoord , 0 , 256 );
+ get_value( valnode , tempCoord , 256 );
+ blue = strtoul( tempCoord , NULL , 16 );
+ for ( l = 0 ; l < 4 ; l++ ){
+ if ( strncmp( tevcolor[l] , tempCoord , 14 ) == 0 ) {
+ blue = l;
+ break;
+ }
+ }
+
+ valnode=mxmlFindElement(setnode, setnode, "TwoAlpha", NULL, NULL, MXML_DESCEND);
+ memset( tempCoord , 0 , 256 );
+ get_value( valnode , tempCoord , 256 );
+ alpha = strtoul( tempCoord , NULL , 16 );
+ for ( l = 0 ; l < 4 ; l++ ){
+ if ( strncmp( tevcolor[l] , tempCoord , 14 ) == 0 ) {
+ alpha = l;
+ break;
+ }
+ }
+
+ chunkUa6.two = ( red << 0 ) | ( green << 2 ) | ( blue << 4 ) | ( alpha << 6 );
+
+ valnode=mxmlFindElement(setnode, setnode, "ThreeRed", NULL, NULL, MXML_DESCEND);
+ memset( tempCoord , 0 , 256 );
+ get_value( valnode , tempCoord , 256 );
+ red = strtoul( tempCoord , NULL , 16 );
+ for ( l = 0 ; l < 4 ; l++ ){
+ if ( strncmp( tevcolor[l] , tempCoord , 14 ) == 0 ) {
+ red = l;
+ break;
+ }
+ }
+
+ valnode=mxmlFindElement(setnode, setnode, "ThreeGreen", NULL, NULL, MXML_DESCEND);
+ memset( tempCoord , 0 , 256 );
+ get_value( valnode , tempCoord , 256 );
+ green = strtoul( tempCoord , NULL , 16 );
+ for ( l = 0 ; l < 4 ; l++ ){
+ if ( strncmp( tevcolor[l] , tempCoord , 14 ) == 0 ) {
+ green = l;
+ break;
+ }
+ }
+
+ valnode=mxmlFindElement(setnode, setnode, "ThreeBlue", NULL, NULL, MXML_DESCEND);
+ memset( tempCoord , 0 , 256 );
+ get_value( valnode , tempCoord , 256 );
+ blue = strtoul( tempCoord , NULL , 16 );
+ for ( l = 0 ; l < 4 ; l++ ){
+ if ( strncmp( tevcolor[l] , tempCoord , 14 ) == 0 ) {
+ blue = l;
+ break;
+ }
+ }
+
+ valnode=mxmlFindElement(setnode, setnode, "ThreeAlpha", NULL, NULL, MXML_DESCEND);
+ memset( tempCoord , 0 , 256 );
+ get_value( valnode , tempCoord , 256 );
+ alpha = strtoul( tempCoord , NULL , 16 );
+ for ( l = 0 ; l < 4 ; l++ ){
+ if ( strncmp( tevcolor[l] , tempCoord , 14 ) == 0 ) {
+ alpha = l;
+ break;
+ }
+ }
+
+ chunkUa6.three = ( red << 0 ) | ( green << 2 ) | ( blue << 4 ) | ( alpha << 6 );
+
+ valnode=mxmlFindElement(setnode, setnode, "FourRed", NULL, NULL, MXML_DESCEND);
+ memset( tempCoord , 0 , 256 );
+ get_value( valnode , tempCoord , 256 );
+ red = strtoul( tempCoord , NULL , 16 );
+ for ( l = 0 ; l < 4 ; l++ ){
+ if ( strncmp( tevcolor[l] , tempCoord , 14 ) == 0 ) {
+ red = l;
+ break;
+ }
+ }
+
+ valnode=mxmlFindElement(setnode, setnode, "FourGreen", NULL, NULL, MXML_DESCEND);
+ memset( tempCoord , 0 , 256 );
+ get_value( valnode , tempCoord , 256 );
+ green = strtoul( tempCoord , NULL , 16 );
+ for ( l = 0 ; l < 4 ; l++ ){
+ if ( strncmp( tevcolor[l] , tempCoord , 14 ) == 0 ) {
+ green = l;
+ break;
+ }
+ }
+
+ valnode=mxmlFindElement(setnode, setnode, "FourBlue", NULL, NULL, MXML_DESCEND);
+ memset( tempCoord , 0 , 256 );
+ get_value( valnode , tempCoord , 256 );
+ blue = strtoul( tempCoord , NULL , 16 );
+ for ( l = 0 ; l < 4 ; l++ ){
+ if ( strncmp( tevcolor[l] , tempCoord , 14 ) == 0 ) {
+ blue = l;
+ break;
+ }
+ }
+
+ valnode=mxmlFindElement(setnode, setnode, "FourAlpha", NULL, NULL, MXML_DESCEND);
+ memset( tempCoord , 0 , 256 );
+ get_value( valnode , tempCoord , 256 );
+ alpha = strtoul( tempCoord , NULL , 16 );
+ for ( l = 0 ; l < 4 ; l++ ){
+ if ( strncmp( tevcolor[l] , tempCoord , 14 ) == 0 ) {
+ alpha = l;
+ break;
+ }
+ }
+
+ chunkUa6.four = ( red << 0 ) | ( green << 2 ) | ( blue << 4 ) | ( alpha << 6 );
+
+ flags.flag.ua6++;
+
fwrite(&chunkUa6, sizeof(chunkUa6), 1, fp);
*fileOffset = *fileOffset + sizeof(chunkUa6);
matSize += sizeof(chunkUa6);
}
- brlyt_ua7_chunk chunkUa7;
- for(setnode = mxmlFindElement(subnode, subnode, "ua7", NULL, NULL, MXML_DESCEND); setnode != NULL; setnode = mxmlFindElement(setnode, subnode, "ua7", NULL, NULL, MXML_DESCEND))
+
+ brlyt_indtex_srt chunkUa7;
+ for(setnode = mxmlFindElement(subnode, subnode, "IndTextureSRT", NULL, NULL, MXML_DESCEND); setnode != NULL; setnode = mxmlFindElement(setnode, subnode, "IndTextureSRT", NULL, NULL, MXML_DESCEND))
{
mxml_node_t *valnode;
- valnode=mxmlFindElement(setnode, setnode, "a", NULL, NULL, MXML_DESCEND);
+ valnode=mxmlFindElement(setnode, setnode, "XTrans", NULL, NULL, MXML_DESCEND);
if ( valnode != NULL )
{
char tempCoord[256];
get_value(valnode, tempCoord, 256);
- chunkUa7.a = be32(strtoul(tempCoord, NULL, 16));
+ chunkUa7.XTrans = float_swap_bytes(atof(tempCoord));
}
- valnode=mxmlFindElement(setnode, setnode, "b", NULL, NULL, MXML_DESCEND);
+ valnode=mxmlFindElement(setnode, setnode, "YTrans", NULL, NULL, MXML_DESCEND);
if ( valnode != NULL )
{
char tempCoord[256];
get_value(valnode, tempCoord, 256);
- chunkUa7.b = be32(strtoul(tempCoord, NULL, 16));
+ chunkUa7.YTrans = float_swap_bytes(atof(tempCoord));
}
- valnode=mxmlFindElement(setnode, setnode, "c", NULL, NULL, MXML_DESCEND);
+ valnode=mxmlFindElement(setnode, setnode, "Rotate", NULL, NULL, MXML_DESCEND);
if ( valnode != NULL )
{
char tempCoord[256];
get_value(valnode, tempCoord, 256);
- chunkUa7.c = float_swap_bytes(atof(tempCoord));
+ chunkUa7.Rotate = float_swap_bytes(atof(tempCoord));
}
- valnode=mxmlFindElement(setnode, setnode, "d", NULL, NULL, MXML_DESCEND);
+ valnode=mxmlFindElement(setnode, setnode, "XScale", NULL, NULL, MXML_DESCEND);
if ( valnode != NULL )
{
char tempCoord[256];
get_value(valnode, tempCoord, 256);
- chunkUa7.d = float_swap_bytes(atof(tempCoord));
+ chunkUa7.XScale = float_swap_bytes(atof(tempCoord));
}
- valnode=mxmlFindElement(setnode, setnode, "e", NULL, NULL, MXML_DESCEND);
+ valnode=mxmlFindElement(setnode, setnode, "YScale", NULL, NULL, MXML_DESCEND);
if ( valnode != NULL )
{
char tempCoord[256];
get_value(valnode, tempCoord, 256);
- chunkUa7.e = float_swap_bytes(atof(tempCoord));
+ chunkUa7.YScale = float_swap_bytes(atof(tempCoord));
}
+
+ flags.flag.ua7++;
+
fwrite(&chunkUa7, sizeof(chunkUa7), 1, fp);
*fileOffset = *fileOffset + sizeof(chunkUa7);
matSize += sizeof(chunkUa7);
}
- brlyt_4b_chunk chunkUa8;
- for(setnode = mxmlFindElement(subnode, subnode, "ua8", NULL, NULL, MXML_DESCEND); setnode != NULL; setnode = mxmlFindElement(setnode, subnode, "ua8", NULL, NULL, MXML_DESCEND))
+ brlyt_indtex_order chunkUa8;
+ for(setnode = mxmlFindElement(subnode, subnode, "IndTextureOrder", NULL, NULL, MXML_DESCEND); setnode != NULL; setnode = mxmlFindElement(setnode, subnode, "IndTextureOrder", NULL, NULL, MXML_DESCEND))
{
+ char scale[10][20];
+ int l;
+ for ( l = 0 ; l < 10 ; l++ )
+ memset( scale[l] , 0 , 20 );
+ strcpy( scale[0] , "GX_ITS_1" );
+ strcpy( scale[1] , "GX_ITS_2" );
+ strcpy( scale[2] , "GX_ITS_4" );
+ strcpy( scale[3] , "GX_ITS_8" );
+ strcpy( scale[4] , "GX_ITS_16" );
+ strcpy( scale[5] , "GX_ITS_32" );
+ strcpy( scale[6] , "GX_ITS_64" );
+ strcpy( scale[7] , "GX_ITS_128" );
+ strcpy( scale[8] , "GX_ITS_256" );
+ strcpy( scale[9] , "GX_MAX_ITSCALE" );
+
mxml_node_t *valnode;
- int dataNumber = 0;
- for (valnode=mxmlFindElement(setnode, setnode, "data", NULL, NULL, MXML_DESCEND) ; valnode != NULL ; valnode=mxmlFindElement(valnode, setnode, "data", NULL, NULL, MXML_DESCEND) )
- {
- char tempCoord[256];
- get_value(valnode, tempCoord, 256);
- chunkUa8.unk[dataNumber] = strtoul(tempCoord, NULL, 16);
- dataNumber+=1;
- }
+ char tempCoord[256];
+
+ valnode=mxmlFindElement(setnode, setnode, "TextureCoordinate", NULL, NULL, MXML_DESCEND);
+ memset( tempCoord , 0 , 256 );
+ get_value( valnode , tempCoord , 256 );
+ chunkUa8.tex_coord = strtoul( tempCoord , NULL , 16 );
+
+ valnode=mxmlFindElement(setnode, setnode, "TextureMap", NULL, NULL, MXML_DESCEND);
+ memset( tempCoord , 0 , 256 );
+ get_value( valnode , tempCoord , 256 );
+ chunkUa8.tex_map = strtoul( tempCoord , NULL , 16 );
+
+ valnode=mxmlFindElement(setnode, setnode, "ScaleS", NULL, NULL, MXML_DESCEND);
+ memset( tempCoord , 0 , 256 );
+ get_value( valnode , tempCoord , 256 );
+ chunkUa8.scale_s = strtoul( tempCoord , NULL , 16 );
+ for ( l = 0 ; l < 10 ; l++ ){
+ if ( strncmp( scale[l] , tempCoord , 14 ) == 0 ) {
+ chunkUa8.scale_s = l;
+ break;
+ }
+ }
+
+ valnode=mxmlFindElement(setnode, setnode, "ScaleT", NULL, NULL, MXML_DESCEND);
+ memset( tempCoord , 0 , 256 );
+ get_value( valnode , tempCoord , 256 );
+ chunkUa8.scale_t = strtoul( tempCoord , NULL , 16 );
+ for ( l = 0 ; l < 10 ; l++ ){
+ if ( strncmp( scale[l] , tempCoord , 14 ) == 0 ) {
+ chunkUa8.scale_t = l;
+ break;
+ }
+ }
+
+ flags.flag.ua8++;
+
fwrite(&chunkUa8, sizeof(chunkUa8), 1, fp);
*fileOffset = *fileOffset + sizeof(chunkUa8);
matSize += sizeof(chunkUa8);
}
- brlyt_10b_chunk chunkUa9;
- for (setnode = mxmlFindElement(subnode, subnode, "ua9", NULL, NULL, MXML_DESCEND); setnode != NULL; setnode = mxmlFindElement(setnode, subnode, "ua9", NULL, NULL, MXML_DESCEND))
+
+ TevStages chunkUa9;
+ for (setnode = mxmlFindElement(subnode, subnode, "TevStage", NULL, NULL, MXML_DESCEND); setnode != NULL; setnode = mxmlFindElement(setnode, subnode, "TevStage", NULL, NULL, MXML_DESCEND))
{
mxml_node_t *valnode;
- int dataNumber = 0;
- for (valnode=mxmlFindElement(setnode, setnode, "data", NULL, NULL, MXML_DESCEND) ; valnode != NULL ; valnode=mxmlFindElement(valnode, setnode, "data", NULL, NULL, MXML_DESCEND) )
- {
- char tempCoord[256];
- get_value(valnode, tempCoord, 256);
- chunkUa9.unk[dataNumber] = strtoul(tempCoord, NULL, 16);
- dataNumber+=1;
- }
+ char tempCoord[256];
+
+ valnode=mxmlFindElement(setnode, setnode, "TextureCoordinate", NULL, NULL, MXML_DESCEND);
+ memset( tempCoord , 0 , 256 );
+ get_value( valnode , tempCoord , 256 );
+ chunkUa9.texcoord = strtoul( tempCoord , NULL , 16 );
+
+ valnode=mxmlFindElement(setnode, setnode, "TextureMap", NULL, NULL, MXML_DESCEND);
+ memset( tempCoord , 0 , 256 );
+ get_value( valnode , tempCoord , 256 );
+ u32 tempval = strtoul( tempCoord , NULL , 16 );
+ chunkUa9.texmapbot = tempval & 0xff;
+ chunkUa9.texmaptop = (tempval & 0x100) >> 8;
+
+ valnode=mxmlFindElement(setnode, setnode, "Color", NULL, NULL, MXML_DESCEND);
+ memset( tempCoord , 0 , 256 );
+ get_value( valnode , tempCoord , 256 );
+ chunkUa9.color = strtoul( tempCoord , NULL , 16 );
+
+ valnode=mxmlFindElement(setnode, setnode, "Padding1", NULL, NULL, MXML_DESCEND);
+ memset( tempCoord , 0 , 256 );
+ get_value( valnode , tempCoord , 256 );
+ chunkUa9.empty1 = strtoul( tempCoord , NULL , 16 );
+ chunkUa9.empty1 = 0;
+
+ valnode=mxmlFindElement(setnode, setnode, "RasSelect", NULL, NULL, MXML_DESCEND);
+ memset( tempCoord , 0 , 256 );
+ get_value( valnode , tempCoord , 256 );
+ chunkUa9.ras_sel = strtoul( tempCoord , NULL , 16 );
+
+ valnode=mxmlFindElement(setnode, setnode, "TexSelect", NULL, NULL, MXML_DESCEND);
+ memset( tempCoord , 0 , 256 );
+ get_value( valnode , tempCoord , 256 );
+ chunkUa9.tex_sel = strtoul( tempCoord , NULL , 16 );
+
+ valnode=mxmlFindElement(setnode, setnode, "TevColorCombinerA", NULL, NULL, MXML_DESCEND);
+ memset( tempCoord , 0 , 256 );
+ get_value( valnode , tempCoord , 256 );
+ chunkUa9.aC = strtoul( tempCoord , NULL , 16 );
+
+ valnode=mxmlFindElement(setnode, setnode, "TevColorCombinerB", NULL, NULL, MXML_DESCEND);
+ memset( tempCoord , 0 , 256 );
+ get_value( valnode , tempCoord , 256 );
+ chunkUa9.bC = strtoul( tempCoord , NULL , 16 );
+
+ valnode=mxmlFindElement(setnode, setnode, "TevColorCombinerC", NULL, NULL, MXML_DESCEND);
+ memset( tempCoord , 0 , 256 );
+ get_value( valnode , tempCoord , 256 );
+ chunkUa9.cC = strtoul( tempCoord , NULL , 16 );
+
+ valnode=mxmlFindElement(setnode, setnode, "TevColorCombinerD", NULL, NULL, MXML_DESCEND);
+ memset( tempCoord , 0 , 256 );
+ get_value( valnode , tempCoord , 256 );
+ chunkUa9.dC = strtoul( tempCoord , NULL , 16 );
+
+ valnode=mxmlFindElement(setnode, setnode, "TevColorOp", NULL, NULL, MXML_DESCEND);
+ memset( tempCoord , 0 , 256 );
+ get_value( valnode , tempCoord , 256 );
+ chunkUa9.tevopC = strtoul( tempCoord , NULL , 16 );
+
+ valnode=mxmlFindElement(setnode, setnode, "TevColorBias", NULL, NULL, MXML_DESCEND);
+ memset( tempCoord , 0 , 256 );
+ get_value( valnode , tempCoord , 256 );
+ chunkUa9.tevbiasC = strtoul( tempCoord , NULL , 16 );
+
+ valnode=mxmlFindElement(setnode, setnode, "TevColorScale", NULL, NULL, MXML_DESCEND);
+ memset( tempCoord , 0 , 256 );
+ get_value( valnode , tempCoord , 256 );
+ chunkUa9.tevscaleC = strtoul( tempCoord , NULL , 16 );
+
+ valnode=mxmlFindElement(setnode, setnode, "TevColorClamp", NULL, NULL, MXML_DESCEND);
+ memset( tempCoord , 0 , 256 );
+ get_value( valnode , tempCoord , 256 );
+ chunkUa9.clampC = strtoul( tempCoord , NULL , 16 );
+
+ valnode=mxmlFindElement(setnode, setnode, "TevColorRegisterID", NULL, NULL, MXML_DESCEND);
+ memset( tempCoord , 0 , 256 );
+ get_value( valnode , tempCoord , 256 );
+ chunkUa9.tevregidC = strtoul( tempCoord , NULL , 16 );
+
+ valnode=mxmlFindElement(setnode, setnode, "TevKColorSelect", NULL, NULL, MXML_DESCEND);
+ memset( tempCoord , 0 , 256 );
+ get_value( valnode , tempCoord , 256 );
+ chunkUa9.selC = strtoul( tempCoord , NULL , 16 );
+
+ valnode=mxmlFindElement(setnode, setnode, "TevAlphaCombinerA", NULL, NULL, MXML_DESCEND);
+ memset( tempCoord , 0 , 256 );
+ get_value( valnode , tempCoord , 256 );
+ chunkUa9.aA = strtoul( tempCoord , NULL , 16 );
+
+ valnode=mxmlFindElement(setnode, setnode, "TevAlphaCombinerB", NULL, NULL, MXML_DESCEND);
+ memset( tempCoord , 0 , 256 );
+ get_value( valnode , tempCoord , 256 );
+ chunkUa9.bA = strtoul( tempCoord , NULL , 16 );
+
+ valnode=mxmlFindElement(setnode, setnode, "TevAlphaCombinerC", NULL, NULL, MXML_DESCEND);
+ memset( tempCoord , 0 , 256 );
+ get_value( valnode , tempCoord , 256 );
+ chunkUa9.cA = strtoul( tempCoord , NULL , 16 );
+
+ valnode=mxmlFindElement(setnode, setnode, "TevAlphaCombinerD", NULL, NULL, MXML_DESCEND);
+ memset( tempCoord , 0 , 256 );
+ get_value( valnode , tempCoord , 256 );
+ chunkUa9.dA = strtoul( tempCoord , NULL , 16 );
+
+ valnode=mxmlFindElement(setnode, setnode, "TevAlphaOp", NULL, NULL, MXML_DESCEND);
+ memset( tempCoord , 0 , 256 );
+ get_value( valnode , tempCoord , 256 );
+ chunkUa9.tevopA = strtoul( tempCoord , NULL , 16 );
+
+ valnode=mxmlFindElement(setnode, setnode, "TevAlphaBias", NULL, NULL, MXML_DESCEND);
+ memset( tempCoord , 0 , 256 );
+ get_value( valnode , tempCoord , 256 );
+ chunkUa9.tevbiasA = strtoul( tempCoord , NULL , 16 );
+
+ valnode=mxmlFindElement(setnode, setnode, "TevAlphaScale", NULL, NULL, MXML_DESCEND);
+ memset( tempCoord , 0 , 256 );
+ get_value( valnode , tempCoord , 256 );
+ chunkUa9.tevscaleA = strtoul( tempCoord , NULL , 16 );
+
+ valnode=mxmlFindElement(setnode, setnode, "TevAlphaClamp", NULL, NULL, MXML_DESCEND);
+ memset( tempCoord , 0 , 256 );
+ get_value( valnode , tempCoord , 256 );
+ chunkUa9.clampA = strtoul( tempCoord , NULL , 16 );
+
+ valnode=mxmlFindElement(setnode, setnode, "TevAlphaRegisterID", NULL, NULL, MXML_DESCEND);
+ memset( tempCoord , 0 , 256 );
+ get_value( valnode , tempCoord , 256 );
+ chunkUa9.tevregidA = strtoul( tempCoord , NULL , 16 );
+
+ valnode=mxmlFindElement(setnode, setnode, "TevKAlphaSelect", NULL, NULL, MXML_DESCEND);
+ memset( tempCoord , 0 , 256 );
+ get_value( valnode , tempCoord , 256 );
+ chunkUa9.selA = strtoul( tempCoord , NULL , 16 );
+
+ valnode=mxmlFindElement(setnode, setnode, "IndirectTextureID", NULL, NULL, MXML_DESCEND);
+ memset( tempCoord , 0 , 256 );
+ get_value( valnode , tempCoord , 256 );
+ chunkUa9.indtexid = strtoul( tempCoord , NULL , 16 );
+
+ valnode=mxmlFindElement(setnode, setnode, "IndirectTextureFormat", NULL, NULL, MXML_DESCEND);
+ memset( tempCoord , 0 , 256 );
+ get_value( valnode , tempCoord , 256 );
+ chunkUa9.format = strtoul( tempCoord , NULL , 16 );
+
+ valnode=mxmlFindElement(setnode, setnode, "IndirectTextureBias", NULL, NULL, MXML_DESCEND);
+ memset( tempCoord , 0 , 256 );
+ get_value( valnode , tempCoord , 256 );
+ chunkUa9.bias = strtoul( tempCoord , NULL , 16 );
+
+ valnode=mxmlFindElement(setnode, setnode, "IndirectTextureMatrixID", NULL, NULL, MXML_DESCEND);
+ memset( tempCoord , 0 , 256 );
+ get_value( valnode , tempCoord , 256 );
+ chunkUa9.mtxid = strtoul( tempCoord , NULL , 16 );
+
+ valnode=mxmlFindElement(setnode, setnode, "IndirectTextureWrapS", NULL, NULL, MXML_DESCEND);
+ memset( tempCoord , 0 , 256 );
+ get_value( valnode , tempCoord , 256 );
+ chunkUa9.wrap_s = strtoul( tempCoord , NULL , 16 );
+
+ valnode=mxmlFindElement(setnode, setnode, "IndirectTextureWrapT", NULL, NULL, MXML_DESCEND);
+ memset( tempCoord , 0 , 256 );
+ get_value( valnode , tempCoord , 256 );
+ chunkUa9.wrap_t = strtoul( tempCoord , NULL , 16 );
+
+ valnode=mxmlFindElement(setnode, setnode, "IndirectTextureAddPrevious", NULL, NULL, MXML_DESCEND);
+ memset( tempCoord , 0 , 256 );
+ get_value( valnode , tempCoord , 256 );
+ chunkUa9.addprev = strtoul( tempCoord , NULL , 16 );
+
+ valnode=mxmlFindElement(setnode, setnode, "IndirectTextureUTClod", NULL, NULL, MXML_DESCEND);
+ memset( tempCoord , 0 , 256 );
+ get_value( valnode , tempCoord , 256 );
+ chunkUa9.utclod = strtoul( tempCoord , NULL , 16 );
+
+ valnode=mxmlFindElement(setnode, setnode, "IndirectTextureA", NULL, NULL, MXML_DESCEND);
+ memset( tempCoord , 0 , 256 );
+ get_value( valnode , tempCoord , 256 );
+ chunkUa9.aIND = strtoul( tempCoord , NULL , 16 );
+
+ valnode=mxmlFindElement(setnode, setnode, "Padding2", NULL, NULL, MXML_DESCEND);
+ memset( tempCoord , 0 , 256 );
+ get_value( valnode , tempCoord , 256 );
+ chunkUa9.empty2 = strtoul( tempCoord , NULL , 16 );
+ chunkUa9.empty2 = 0;
+
+ valnode=mxmlFindElement(setnode, setnode, "Padding3", NULL, NULL, MXML_DESCEND);
+ memset( tempCoord , 0 , 256 );
+ get_value( valnode , tempCoord , 256 );
+ chunkUa9.empty3 = strtoul( tempCoord , NULL , 16 );
+ chunkUa9.empty3 = 0;
+
+ valnode=mxmlFindElement(setnode, setnode, "Padding4", NULL, NULL, MXML_DESCEND);
+ memset( tempCoord , 0 , 256 );
+ get_value( valnode , tempCoord , 256 );
+ chunkUa9.empty4 = strtoul( tempCoord , NULL , 16 );
+ chunkUa9.empty4 = 0;
+
+ flags.flag.ua9++;
+
fwrite(&chunkUa9, sizeof(chunkUa9), 1, fp);
*fileOffset = *fileOffset + sizeof(chunkUa9);
matSize += sizeof(chunkUa9);
}
- brlyt_4b_chunk chunkUaa;
- for(setnode = mxmlFindElement(subnode, subnode, "uaa", NULL, NULL, MXML_DESCEND); setnode != NULL; setnode = mxmlFindElement(setnode, subnode, "uaa", NULL, NULL, MXML_DESCEND))
+
+ brlyt_alpha_compare chunkUaa;
+ for(setnode = mxmlFindElement(subnode, subnode, "AlphaCompare", NULL, NULL, MXML_DESCEND); setnode != NULL; setnode = mxmlFindElement(setnode, subnode, "AlphaCompare", NULL, NULL, MXML_DESCEND))
{
+ char compare[8][20];
+ int l;
+ for ( l = 0 ; l < 8 ; l++ )
+ memset( compare[l] , 0 , 20 );
+ strcpy( compare[0] , "GX_NEVER" );
+ strcpy( compare[1] , "GX_LESS" );
+ strcpy( compare[2] , "GX_EQUAL" );
+ strcpy( compare[3] , "GX_LEQUAL" );
+ strcpy( compare[4] , "GX_GREATER" );
+ strcpy( compare[5] , "GX_NEQUAL" );
+ strcpy( compare[6] , "GX_GEQUAL" );
+ strcpy( compare[7] , "GX_ALWAYS" );
+
+ char aop[5][20];
+ for ( l = 0 ; l < 5 ; l++ )
+ memset( aop[l] , 0 , 20 );
+ strcpy( aop[0] , "GX_AOP_AND" );
+ strcpy( aop[1] , "GX_AOP_OR" );
+ strcpy( aop[2] , "GX_AOP_XOR" );
+ strcpy( aop[3] , "GX_AOP_XNOR" );
+ strcpy( aop[4] , "GX_MAX_ALPHAOP" );
+
mxml_node_t *valnode;
- int dataNumber = 0;
- for (valnode=mxmlFindElement(setnode, setnode, "data", NULL, NULL, MXML_DESCEND) ; valnode != NULL ; valnode=mxmlFindElement(valnode, setnode, "data", NULL, NULL, MXML_DESCEND) )
- {
- char tempCoord[256];
- get_value(valnode, tempCoord, 256);
- chunkUaa.unk[dataNumber] = strtoul(tempCoord, NULL, 16);
- dataNumber+=1;
- }
+ char tempCoord[256];
+
+ valnode=mxmlFindElement(setnode, setnode, "comp0", NULL, NULL, MXML_DESCEND);
+ memset( tempCoord , 0 , 256 );
+ get_value(valnode, tempCoord, 256);
+ chunkUaa.comp0 = strtoul(tempCoord, NULL, 16);
+ for ( l = 0 ; l < 8 ; l++ ){
+ if ( strncmp( compare[l] , tempCoord , 14 ) == 0 ) {
+ chunkUaa.comp0 = l;
+ break;
+ }
+ }
+
+ valnode=mxmlFindElement(setnode, setnode, "comp1", NULL, NULL, MXML_DESCEND);
+ memset( tempCoord , 0 , 256 );
+ get_value(valnode, tempCoord, 256);
+ chunkUaa.comp1 = strtoul(tempCoord, NULL, 16);
+ for ( l = 0 ; l < 8 ; l++ ){
+ if ( strncmp( compare[l] , tempCoord , 14 ) == 0 ) {
+ chunkUaa.comp1 = l;
+ break;
+ }
+ }
+
+ valnode=mxmlFindElement(setnode, setnode, "aop", NULL, NULL, MXML_DESCEND);
+ memset( tempCoord , 0 , 256 );
+ get_value(valnode, tempCoord, 256);
+ chunkUaa.aop = strtoul(tempCoord, NULL, 16);
+ for ( l = 0 ; l < 5 ; l++ ){
+ if ( strncmp( aop[l] , tempCoord , 14 ) == 0 ) {
+ chunkUaa.aop = l;
+ break;
+ }
+ }
+
+ valnode=mxmlFindElement(setnode, setnode, "ref0", NULL, NULL, MXML_DESCEND);
+ memset( tempCoord , 0 , 256 );
+ get_value(valnode, tempCoord, 256);
+ chunkUaa.ref0 = strtoul(tempCoord, NULL, 16);
+
+ valnode=mxmlFindElement(setnode, setnode, "ref1", NULL, NULL, MXML_DESCEND);
+ memset( tempCoord , 0 , 256 );
+ get_value(valnode, tempCoord, 256);
+ chunkUaa.ref1 = strtoul(tempCoord, NULL, 16);
+
+ flags.flag.uaa++;
+
fwrite(&chunkUaa, sizeof(chunkUaa), 1, fp);
*fileOffset = *fileOffset + sizeof(chunkUaa);
matSize += sizeof(chunkUaa);
}
- brlyt_4b_chunk chunkUab;
- for(setnode = mxmlFindElement(subnode, subnode, "uab", NULL, NULL, MXML_DESCEND); setnode != NULL; setnode = mxmlFindElement(setnode, subnode, "uab", NULL, NULL, MXML_DESCEND))
+
+ brlyt_blend_mode chunkUab;
+ for(setnode = mxmlFindElement(subnode, subnode, "BlendMode", NULL, NULL, MXML_DESCEND); setnode != NULL; setnode = mxmlFindElement(setnode, subnode, "BlendMode", NULL, NULL, MXML_DESCEND))
{
+ char blendmode[5][20];
+ int l;
+ for ( l = 0 ; l < 5 ; l++ )
+ memset( blendmode[l] , 0 , 20 );
+ strcpy( blendmode[0] , "GX_BM_NONE" );
+ strcpy( blendmode[1] , "GX_BM_BLEND" );
+ strcpy( blendmode[2] , "GX_BM_LOGIC" );
+ strcpy( blendmode[3] , "GX_BM_SUBTRACT" );
+ strcpy( blendmode[4] , "GX_MAX_BLENDMODE" );
+
+ char blendfactor[8][20];
+ for ( l = 0 ; l < 8 ; l++ )
+ memset( blendfactor[l] , 0 , 20 );
+ strcpy( blendfactor[0] , "GX_BL_ZERO" );
+ strcpy( blendfactor[1] , "GX_BL_ONE" );
+ strcpy( blendfactor[2] , "GX_BL_SRCCLR" );
+ strcpy( blendfactor[3] , "GX_BL_INVSRCCLR" );
+ strcpy( blendfactor[4] , "GX_BL_SRCALPHA" );
+ strcpy( blendfactor[5] , "GX_BL_INVSRCALPHA" );
+ strcpy( blendfactor[6] , "GX_BL_DSTALPHA" );
+ strcpy( blendfactor[7] , "GX_BL_INVDSTALPHA" );
+
+ char logicop[16][20];
+ for ( l = 0 ; l < 16 ; l++ )
+ memset( logicop[l] , 0 , 20 );
+ strcpy( logicop[0] , "GX_LO_CLEAR" );
+ strcpy( logicop[1] , "GX_LO_AND" );
+ strcpy( logicop[2] , "GX_LO_REVAND" );
+ strcpy( logicop[3] , "GX_LO_COPY" );
+ strcpy( logicop[4] , "GX_LO_INVAND" );
+ strcpy( logicop[5] , "GX_LO_NOOP" );
+ strcpy( logicop[6] , "GX_LO_XOR" );
+ strcpy( logicop[7] , "GX_LO_OR" );
+ strcpy( logicop[8] , "GX_LO_NOR" );
+ strcpy( logicop[9] , "GX_LO_EQUIV" );
+ strcpy( logicop[10] , "GX_LO_INV" );
+ strcpy( logicop[11] , "GX_LO_REVOR" );
+ strcpy( logicop[12] , "GX_LO_INVCOPY" );
+ strcpy( logicop[13] , "GX_LO_INVOR" );
+ strcpy( logicop[14] , "GX_LO_NAND" );
+ strcpy( logicop[15] , "GX_LO_SET" );
+
mxml_node_t *valnode;
- int dataNumber = 0;
- for (valnode=mxmlFindElement(setnode, setnode, "data", NULL, NULL, MXML_DESCEND) ; valnode != NULL ; valnode=mxmlFindElement(valnode, setnode, "data", NULL, NULL, MXML_DESCEND) )
- {
- char tempCoord[256];
- get_value(valnode, tempCoord, 256);
- chunkUab.unk[dataNumber] = strtoul(tempCoord, NULL, 16);
- dataNumber+=1;
- }
+ char tempCoord[256];
+
+ valnode=mxmlFindElement(setnode, setnode, "type", NULL, NULL, MXML_DESCEND);
+ memset( tempCoord , 0 , 256 );
+ get_value( valnode , tempCoord , 256 );
+ chunkUab.type = strtoul( tempCoord , NULL , 16 );
+ for ( l = 0 ; l < 5 ; l++ ){
+ if ( strncmp( blendmode[l] , tempCoord , 14 ) == 0 ) {
+ chunkUab.type = l;
+ break;
+ }
+ }
+
+ valnode=mxmlFindElement(setnode, setnode, "src_fact", NULL, NULL, MXML_DESCEND);
+ memset( tempCoord , 0 , 256 );
+ get_value( valnode , tempCoord , 256 );
+ chunkUab.src_fact = strtoul( tempCoord , NULL , 16 );
+ for ( l = 0 ; l < 8 ; l++ ){
+ if ( strncmp( blendfactor[l] , tempCoord , 14 ) == 0 ) {
+ chunkUab.src_fact = l;
+ break;
+ }
+ }
+
+ valnode=mxmlFindElement(setnode, setnode, "dst_fact", NULL, NULL, MXML_DESCEND);
+ memset( tempCoord , 0 , 256 );
+ get_value( valnode , tempCoord , 256 );
+ chunkUab.dst_fact = strtoul( tempCoord , NULL , 16 );
+ for ( l = 0 ; l < 8 ; l++ ){
+ if ( strncmp( blendfactor[l] , tempCoord , 14 ) == 0 ) {
+ chunkUab.dst_fact = l;
+ break;
+ }
+ }
+
+ valnode=mxmlFindElement(setnode, setnode, "op", NULL, NULL, MXML_DESCEND);
+ memset( tempCoord , 0 , 256 );
+ get_value( valnode , tempCoord , 256 );
+ chunkUab.op = strtoul( tempCoord , NULL , 16 );
+ for ( l = 0 ; l < 16 ; l++ ){
+ if ( strncmp( logicop[l] , tempCoord , 14 ) == 0 ) {
+ chunkUab.op = l;
+ break;
+ }
+ }
+
+ flags.flag.uab++;
+
fwrite(&chunkUab, sizeof(chunkUab), 1, fp);
*fileOffset = *fileOffset + sizeof(chunkUab);
matSize += sizeof(chunkUab);
}
+
+ // write mat1_header with flags
+ chunk.flags = be32( flags.flags );
+ u32 end = ftell(fp);
+ fseek( fp , tempFileOffset , SEEK_SET );
+ fwrite(&chunk, sizeof(chunk), 1, fp);
+ fseek( fp , end , SEEK_SET );
+
if (numberOfEntries < actualNumber)
{
offsets[numberOfEntries] = be32(matSize + initialOffset);
@@ -1437,7 +2693,7 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl
memset(chunk.name, 0, 24);
strcpy(chunk.name, temp);
- mxml_node_t *subnode = mxmlFindElement(node, node, "coords", NULL, NULL, MXML_DESCEND);
+ mxml_node_t *subnode = mxmlFindElement(node, node, "translate", NULL, NULL, MXML_DESCEND);
if (subnode != NULL)
{
mxml_node_t *valnode;
@@ -1446,24 +2702,24 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl
{
char tempCoord[256];
get_value(valnode, tempCoord, 256);
- chunk.x = float_swap_bytes(atof(tempCoord));
+ chunk.XTrans = float_swap_bytes(atof(tempCoord));
}
valnode = mxmlFindElement(subnode, subnode, "y", NULL, NULL, MXML_DESCEND);
if (valnode != NULL)
{
char tempCoord[256];
get_value(valnode, tempCoord, 256);
- chunk.y = float_swap_bytes(atof(tempCoord));
+ chunk.YTrans = float_swap_bytes(atof(tempCoord));
}
valnode = mxmlFindElement(subnode, subnode, "z", NULL, NULL, MXML_DESCEND);
if (valnode != NULL)
{
char tempCoord[256];
get_value(valnode, tempCoord, 256);
- chunk.z = float_swap_bytes(atof(tempCoord));
+ chunk.ZTrans = float_swap_bytes(atof(tempCoord));
}
}
- subnode = mxmlFindElement(node, node, "flip", NULL, NULL, MXML_DESCEND);
+ subnode = mxmlFindElement(node, node, "rotate", NULL, NULL, MXML_DESCEND);
if (subnode != NULL)
{
mxml_node_t *valnode;
@@ -1472,17 +2728,24 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl
{
char tempCoord[256];
get_value(valnode, tempCoord, 256);
- chunk.flip_x = float_swap_bytes(atof(tempCoord));
+ chunk.XRotate = float_swap_bytes(atof(tempCoord));
}
valnode = mxmlFindElement(subnode, subnode, "y", NULL, NULL, MXML_DESCEND);
if (valnode != NULL)
{
char tempCoord[256];
get_value(valnode, tempCoord, 256);
- chunk.flip_y = float_swap_bytes(atof(tempCoord));
+ chunk.YRotate = float_swap_bytes(atof(tempCoord));
+ }
+ valnode = mxmlFindElement(subnode, subnode, "z", NULL, NULL, MXML_DESCEND);
+ if (valnode != NULL)
+ {
+ char tempCoord[256];
+ get_value(valnode, tempCoord, 256);
+ chunk.ZRotate = float_swap_bytes(atof(tempCoord));
}
}
- subnode = mxmlFindElement(node, node, "zoom", NULL, NULL, MXML_DESCEND);
+ subnode = mxmlFindElement(node, node, "scale", NULL, NULL, MXML_DESCEND);
if (subnode != NULL)
{
mxml_node_t *valnode;
@@ -1491,14 +2754,14 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl
{
char tempCoord[256];
get_value(valnode, tempCoord, 256);
- chunk.xmag = float_swap_bytes(atof(tempCoord));
+ chunk.XScale = float_swap_bytes(atof(tempCoord));
}
valnode = mxmlFindElement(subnode, subnode, "y", NULL, NULL, MXML_DESCEND);
if (valnode != NULL)
{
char tempCoord[256];
get_value(valnode, tempCoord, 256);
- chunk.ymag = float_swap_bytes(atof(tempCoord));
+ chunk.YScale = float_swap_bytes(atof(tempCoord));
}
}
subnode = mxmlFindElement(node, node, "size", NULL, NULL, MXML_DESCEND);
@@ -1521,13 +2784,54 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl
}
}
- subnode = mxmlFindElement(node, node, "flags", NULL, NULL, MXML_DESCEND);
+ u8 flag1 = 0;
+ subnode = mxmlFindElement(node, node, "visible", NULL, NULL, MXML_DESCEND);
if (subnode != NULL)
{
char tempCoord[256];
get_value(subnode, tempCoord, 256);
- chunk.flag1 = strtol(tempCoord, NULL, 16);
- chunk.flag2 = strtol(&(tempCoord[3]), NULL, 16);
+ flag1 |= strtol(tempCoord, NULL, 16);
+ }
+ subnode = mxmlFindElement(node, node, "WidescreenAffected", NULL, NULL, MXML_DESCEND);
+ if (subnode != NULL)
+ {
+ char tempCoord[256];
+ get_value(subnode, tempCoord, 256);
+ flag1 |= ( strtol(tempCoord, NULL, 16) << 1 );
+ }
+ subnode = mxmlFindElement(node, node, "flag", NULL, NULL, MXML_DESCEND);
+ if (subnode != NULL)
+ {
+ char tempCoord[256];
+ get_value(subnode, tempCoord, 256);
+ flag1 |= ( strtol(tempCoord, NULL, 16) << 2 );
+ }
+ chunk.flag1 = flag1;
+ subnode = mxmlFindElement(node, node, "origin", NULL, NULL, MXML_DESCEND);
+ if (subnode != NULL)
+ {
+ char origins[9][15];
+ memset( origins , 0 , 8 * 20 );
+ strcpy( origins[0] , "TOP LEFT" );
+ strcpy( origins[1] , "TOP CENTER" );
+ strcpy( origins[2] , "TOP RIGHT" );
+ strcpy( origins[3] , "MIDDLE LEFT" );
+ strcpy( origins[4] , "MIDDLE CENTER" );
+ strcpy( origins[5] , "MIDDLE RIGHT" );
+ strcpy( origins[6] , "BOTTOM LEFT" );
+ strcpy( origins[7] , "BOTTOM CENTER" );
+ strcpy( origins[8] , "BOTTOM RIGHT" );
+
+ char tempCoord[256];
+ get_value(subnode, tempCoord, 256);
+ chunk.origin = strtol(tempCoord, NULL, 16);
+ int i;
+ for ( i = 0 ; i < 9 ; i++ ) {
+ if ( strncmp( origins[i] , tempCoord , 15 ) == 0 ) {
+ chunk.origin = i;
+ break;
+ }
+ }
}
subnode = mxmlFindElement(node, node, "alpha", NULL, NULL, MXML_DESCEND);
if (subnode != NULL)
@@ -1535,14 +2839,13 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl
char tempCoord[256];
get_value(subnode, tempCoord, 256);
chunk.alpha = strtol(tempCoord, NULL, 16);
- chunk.alpha2 = strtol(&(tempCoord[3]), NULL, 16);
}
- subnode = mxmlFindElement(node, node, "rotate", NULL, NULL, MXML_DESCEND);
+ subnode = mxmlFindElement(node, node, "padding", NULL, NULL, MXML_DESCEND);
if (subnode != NULL)
{
char tempCoord[256];
get_value(subnode, tempCoord, 256);
- chunk.angle = float_swap_bytes(atof(tempCoord));
+ chunk.pad = strtol(tempCoord, NULL, 16);
}
fwrite(&chunk, sizeof(chunk), 1, fp);
*fileOffset = *fileOffset + sizeof(chunk);
@@ -1560,7 +2863,7 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl
memset(chunk.name, 0, 24 * sizeof(char));
strcpy(chunk.name, temp);
- mxml_node_t *subnode = mxmlFindElement(node, node, "coords", NULL, NULL, MXML_DESCEND);
+ mxml_node_t *subnode = mxmlFindElement(node, node, "translate", NULL, NULL, MXML_DESCEND);
if (subnode != NULL)
{
mxml_node_t *valnode;
@@ -1569,24 +2872,24 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl
{
char tempCoord[256];
get_value(valnode, tempCoord, 256);
- chunk.x = float_swap_bytes(atof(tempCoord));
+ chunk.XTrans = float_swap_bytes(atof(tempCoord));
}
valnode = mxmlFindElement(subnode, subnode, "y", NULL, NULL, MXML_DESCEND);
if (valnode != NULL)
{
char tempCoord[256];
get_value(valnode, tempCoord, 256);
- chunk.y = float_swap_bytes(atof(tempCoord));
+ chunk.YTrans = float_swap_bytes(atof(tempCoord));
}
valnode = mxmlFindElement(subnode, subnode, "z", NULL, NULL, MXML_DESCEND);
if (valnode != NULL)
{
char tempCoord[256];
get_value(valnode, tempCoord, 256);
- chunk.z = float_swap_bytes(atof(tempCoord));
+ chunk.ZTrans = float_swap_bytes(atof(tempCoord));
}
}
- subnode = mxmlFindElement(node, node, "flip", NULL, NULL, MXML_DESCEND);
+ subnode = mxmlFindElement(node, node, "rotate", NULL, NULL, MXML_DESCEND);
if (subnode != NULL)
{
mxml_node_t *valnode;
@@ -1595,17 +2898,24 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl
{
char tempCoord[256];
get_value(valnode, tempCoord, 256);
- chunk.flip_x = float_swap_bytes(atof(tempCoord));
+ chunk.XRotate = float_swap_bytes(atof(tempCoord));
}
valnode = mxmlFindElement(subnode, subnode, "y", NULL, NULL, MXML_DESCEND);
if (valnode != NULL)
{
char tempCoord[256];
get_value(valnode, tempCoord, 256);
- chunk.flip_y = float_swap_bytes(atof(tempCoord));
+ chunk.YRotate = float_swap_bytes(atof(tempCoord));
+ }
+ valnode = mxmlFindElement(subnode, subnode, "z", NULL, NULL, MXML_DESCEND);
+ if (valnode != NULL)
+ {
+ char tempCoord[256];
+ get_value(valnode, tempCoord, 256);
+ chunk.ZRotate = float_swap_bytes(atof(tempCoord));
}
}
- subnode = mxmlFindElement(node, node, "zoom", NULL, NULL, MXML_DESCEND);
+ subnode = mxmlFindElement(node, node, "scale", NULL, NULL, MXML_DESCEND);
if (subnode != NULL)
{
mxml_node_t *valnode;
@@ -1614,14 +2924,14 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl
{
char tempCoord[256];
get_value(valnode, tempCoord, 256);
- chunk.xmag = float_swap_bytes(atof(tempCoord));
+ chunk.XScale = float_swap_bytes(atof(tempCoord));
}
valnode = mxmlFindElement(subnode, subnode, "y", NULL, NULL, MXML_DESCEND);
if (valnode != NULL)
{
char tempCoord[256];
get_value(valnode, tempCoord, 256);
- chunk.ymag = float_swap_bytes(atof(tempCoord));
+ chunk.YScale = float_swap_bytes(atof(tempCoord));
}
}
subnode = mxmlFindElement(node, node, "size", NULL, NULL, MXML_DESCEND);
@@ -1644,13 +2954,54 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl
}
}
- subnode = mxmlFindElement(node, node, "flags", NULL, NULL, MXML_DESCEND);
+ u8 flag1 = 0;
+ subnode = mxmlFindElement(node, node, "visible", NULL, NULL, MXML_DESCEND);
if (subnode != NULL)
{
char tempCoord[256];
get_value(subnode, tempCoord, 256);
- chunk.flag1 = strtol(tempCoord, NULL, 16);
- chunk.flag2 = strtol(&(tempCoord[3]), NULL, 16);
+ flag1 |= strtol(tempCoord, NULL, 16);
+ }
+ subnode = mxmlFindElement(node, node, "WidescreenAffected", NULL, NULL, MXML_DESCEND);
+ if (subnode != NULL)
+ {
+ char tempCoord[256];
+ get_value(subnode, tempCoord, 256);
+ flag1 |= ( strtol(tempCoord, NULL, 16) << 1 );
+ }
+ subnode = mxmlFindElement(node, node, "flag", NULL, NULL, MXML_DESCEND);
+ if (subnode != NULL)
+ {
+ char tempCoord[256];
+ get_value(subnode, tempCoord, 256);
+ flag1 |= ( strtol(tempCoord, NULL, 16) << 2 );
+ }
+ chunk.flag1 = flag1;
+ subnode = mxmlFindElement(node, node, "origin", NULL, NULL, MXML_DESCEND);
+ if (subnode != NULL)
+ {
+ char origins[9][15];
+ memset( origins , 0 , 8 * 20 );
+ strcpy( origins[0] , "TOP LEFT" );
+ strcpy( origins[1] , "TOP CENTER" );
+ strcpy( origins[2] , "TOP RIGHT" );
+ strcpy( origins[3] , "MIDDLE LEFT" );
+ strcpy( origins[4] , "MIDDLE CENTER" );
+ strcpy( origins[5] , "MIDDLE RIGHT" );
+ strcpy( origins[6] , "BOTTOM LEFT" );
+ strcpy( origins[7] , "BOTTOM CENTER" );
+ strcpy( origins[8] , "BOTTOM RIGHT" );
+
+ char tempCoord[256];
+ get_value(subnode, tempCoord, 256);
+ chunk.origin = strtol(tempCoord, NULL, 16);
+ int i;
+ for ( i = 0 ; i < 9 ; i++ ) {
+ if ( strncmp( origins[i] , tempCoord , 15 ) == 0 ) {
+ chunk.origin = i;
+ break;
+ }
+ }
}
subnode = mxmlFindElement(node, node, "alpha", NULL, NULL, MXML_DESCEND);
if (subnode != NULL)
@@ -1658,21 +3009,20 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl
char tempCoord[256];
get_value(subnode, tempCoord, 256);
chunk.alpha = strtol(tempCoord, NULL, 16);
- chunk.alpha2 = strtol(&(tempCoord[3]), NULL, 16);
}
- subnode = mxmlFindElement(node, node, "rotate", NULL, NULL, MXML_DESCEND);
+ subnode = mxmlFindElement(node, node, "padding", NULL, NULL, MXML_DESCEND);
if (subnode != NULL)
{
char tempCoord[256];
get_value(subnode, tempCoord, 256);
- chunk.angle = float_swap_bytes(atof(tempCoord));
+ chunk.pad = strtol(tempCoord, NULL, 16);
}
fwrite(&chunk, sizeof(chunk), 1, fp);
*fileOffset = *fileOffset + sizeof(chunk);
}
if ( memcmp(temp, wnd1, sizeof(wnd1)) == 0)
{
- brlyt_pane_chunk chunk;
+ brlyt_pane_chunk chunk;
char temp[256];
if(mxmlElementGetAttr(node, "name") != NULL)
strcpy(temp, mxmlElementGetAttr(node, "name"));
@@ -1683,7 +3033,7 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl
memset(chunk.name, 0, 24 * sizeof(char));
strcpy(chunk.name, temp);
- mxml_node_t *subnode = mxmlFindElement(node, node, "coords", NULL, NULL, MXML_DESCEND);
+ mxml_node_t *subnode = mxmlFindElement(node, node, "translate", NULL, NULL, MXML_DESCEND);
if (subnode != NULL)
{
mxml_node_t *valnode;
@@ -1692,24 +3042,24 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl
{
char tempCoord[256];
get_value(valnode, tempCoord, 256);
- chunk.x = float_swap_bytes(atof(tempCoord));
+ chunk.XTrans = float_swap_bytes(atof(tempCoord));
}
valnode = mxmlFindElement(subnode, subnode, "y", NULL, NULL, MXML_DESCEND);
if (valnode != NULL)
{
char tempCoord[256];
get_value(valnode, tempCoord, 256);
- chunk.y = float_swap_bytes(atof(tempCoord));
+ chunk.YTrans = float_swap_bytes(atof(tempCoord));
}
valnode = mxmlFindElement(subnode, subnode, "z", NULL, NULL, MXML_DESCEND);
if (valnode != NULL)
{
char tempCoord[256];
get_value(valnode, tempCoord, 256);
- chunk.z = float_swap_bytes(atof(tempCoord));
+ chunk.ZTrans = float_swap_bytes(atof(tempCoord));
}
}
- subnode = mxmlFindElement(node, node, "flip", NULL, NULL, MXML_DESCEND);
+ subnode = mxmlFindElement(node, node, "rotate", NULL, NULL, MXML_DESCEND);
if (subnode != NULL)
{
mxml_node_t *valnode;
@@ -1718,17 +3068,24 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl
{
char tempCoord[256];
get_value(valnode, tempCoord, 256);
- chunk.flip_x = float_swap_bytes(atof(tempCoord));
+ chunk.XRotate = float_swap_bytes(atof(tempCoord));
}
valnode = mxmlFindElement(subnode, subnode, "y", NULL, NULL, MXML_DESCEND);
if (valnode != NULL)
{
char tempCoord[256];
get_value(valnode, tempCoord, 256);
- chunk.flip_y = float_swap_bytes(atof(tempCoord));
+ chunk.YRotate = float_swap_bytes(atof(tempCoord));
+ }
+ valnode = mxmlFindElement(subnode, subnode, "z", NULL, NULL, MXML_DESCEND);
+ if (valnode != NULL)
+ {
+ char tempCoord[256];
+ get_value(valnode, tempCoord, 256);
+ chunk.ZRotate = float_swap_bytes(atof(tempCoord));
}
}
- subnode = mxmlFindElement(node, node, "zoom", NULL, NULL, MXML_DESCEND);
+ subnode = mxmlFindElement(node, node, "scale", NULL, NULL, MXML_DESCEND);
if (subnode != NULL)
{
mxml_node_t *valnode;
@@ -1737,14 +3094,14 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl
{
char tempCoord[256];
get_value(valnode, tempCoord, 256);
- chunk.xmag = float_swap_bytes(atof(tempCoord));
+ chunk.XScale = float_swap_bytes(atof(tempCoord));
}
valnode = mxmlFindElement(subnode, subnode, "y", NULL, NULL, MXML_DESCEND);
if (valnode != NULL)
{
char tempCoord[256];
get_value(valnode, tempCoord, 256);
- chunk.ymag = float_swap_bytes(atof(tempCoord));
+ chunk.YScale = float_swap_bytes(atof(tempCoord));
}
}
subnode = mxmlFindElement(node, node, "size", NULL, NULL, MXML_DESCEND);
@@ -1767,13 +3124,54 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl
}
}
- subnode = mxmlFindElement(node, node, "flags", NULL, NULL, MXML_DESCEND);
+ u8 flag1 = 0;
+ subnode = mxmlFindElement(node, node, "visible", NULL, NULL, MXML_DESCEND);
if (subnode != NULL)
{
char tempCoord[256];
get_value(subnode, tempCoord, 256);
- chunk.flag1 = strtol(tempCoord, NULL, 16);
- chunk.flag2 = strtol(&(tempCoord[3]), NULL, 16);
+ flag1 |= strtol(tempCoord, NULL, 16);
+ }
+ subnode = mxmlFindElement(node, node, "WidescreenAffected", NULL, NULL, MXML_DESCEND);
+ if (subnode != NULL)
+ {
+ char tempCoord[256];
+ get_value(subnode, tempCoord, 256);
+ flag1 |= ( strtol(tempCoord, NULL, 16) << 1 );
+ }
+ subnode = mxmlFindElement(node, node, "flag", NULL, NULL, MXML_DESCEND);
+ if (subnode != NULL)
+ {
+ char tempCoord[256];
+ get_value(subnode, tempCoord, 256);
+ flag1 |= ( strtol(tempCoord, NULL, 16) << 2 );
+ }
+ chunk.flag1 = flag1;
+ subnode = mxmlFindElement(node, node, "origin", NULL, NULL, MXML_DESCEND);
+ if (subnode != NULL)
+ {
+ char origins[9][15];
+ memset( origins , 0 , 8 * 20 );
+ strcpy( origins[0] , "TOP LEFT" );
+ strcpy( origins[1] , "TOP CENTER" );
+ strcpy( origins[2] , "TOP RIGHT" );
+ strcpy( origins[3] , "MIDDLE LEFT" );
+ strcpy( origins[4] , "MIDDLE CENTER" );
+ strcpy( origins[5] , "MIDDLE RIGHT" );
+ strcpy( origins[6] , "BOTTOM LEFT" );
+ strcpy( origins[7] , "BOTTOM CENTER" );
+ strcpy( origins[8] , "BOTTOM RIGHT" );
+
+ char tempCoord[256];
+ get_value(subnode, tempCoord, 256);
+ chunk.origin = strtol(tempCoord, NULL, 16);
+ int i;
+ for ( i = 0 ; i < 9 ; i++ ) {
+ if ( strncmp( origins[i] , tempCoord , 15 ) == 0 ) {
+ chunk.origin = i;
+ break;
+ }
+ }
}
subnode = mxmlFindElement(node, node, "alpha", NULL, NULL, MXML_DESCEND);
if (subnode != NULL)
@@ -1781,14 +3179,13 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl
char tempCoord[256];
get_value(subnode, tempCoord, 256);
chunk.alpha = strtol(tempCoord, NULL, 16);
- chunk.alpha2 = strtol(&(tempCoord[3]), NULL, 16);
}
- subnode = mxmlFindElement(node, node, "rotate", NULL, NULL, MXML_DESCEND);
+ subnode = mxmlFindElement(node, node, "padding", NULL, NULL, MXML_DESCEND);
if (subnode != NULL)
{
char tempCoord[256];
get_value(subnode, tempCoord, 256);
- chunk.angle = float_swap_bytes(atof(tempCoord));
+ chunk.pad = strtol(tempCoord, NULL, 16);
}
fwrite(&chunk, sizeof(chunk), 1, fp);
*fileOffset = *fileOffset + sizeof(chunk);
@@ -1800,20 +3197,20 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl
{
i = 0;
mxml_node_t *subsubnode;
- for(subsubnode = mxmlFindElement(subnode, subnode, "unk1", NULL, NULL, MXML_DESCEND); subsubnode != NULL; subsubnode = mxmlFindElement(subsubnode, subnode, "unk1", NULL, NULL, MXML_DESCEND))
+ for(subsubnode = mxmlFindElement(subnode, subnode, "coordinate", NULL, NULL, MXML_DESCEND); subsubnode != NULL; subsubnode = mxmlFindElement(subsubnode, subnode, "coordinate", NULL, NULL, MXML_DESCEND))
{
char tempCoord[256];
get_value(subsubnode, tempCoord, 256);
- wndy.unk1[i] = float_swap_bytes(atof(tempCoord));
+ wndy.coords[i] = float_swap_bytes(atof(tempCoord));
i++;
}
- subsubnode = mxmlFindElement(subnode, subnode, "count", NULL, NULL, MXML_DESCEND);
+ subsubnode = mxmlFindElement(subnode, subnode, "FrameCount", NULL, NULL, MXML_DESCEND);
if(subsubnode != NULL)
{
char tempCoord[256];
get_value(subsubnode, tempCoord, 256);
- wndy.count = (u8)(strtoul(tempCoord, NULL, 16));
+ wndy.frame_count = (u8)(strtoul(tempCoord, NULL, 16));
}
wndy.padding[0] = 0x0;
wndy.padding[1] = 0x0;
@@ -1845,42 +3242,40 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl
{
i=0;
mxml_node_t *subsubnode;
- for(subsubnode = mxmlFindElement(subnode, subnode, "unk1", NULL, NULL, MXML_DESCEND); subsubnode != NULL; subsubnode = mxmlFindElement(subsubnode, subnode, "unk1", NULL, NULL, MXML_DESCEND))
+ for(subsubnode = mxmlFindElement(subnode, subnode, "color", NULL, NULL, MXML_DESCEND); subsubnode != NULL; subsubnode = mxmlFindElement(subsubnode, subnode, "color", NULL, NULL, MXML_DESCEND))
{
char tempCoord[256];
get_value(subsubnode, tempCoord, 256);
- wndy1.unk1[i] = be32(strtoul(tempCoord, NULL, 16));
+ wndy1.colors[i] = be32(strtoul(tempCoord, NULL, 16));
i++;
}
- fwrite(&wndy1, sizeof(brlyt_wnd1), 1, fp);
- *fileOffset = *fileOffset + sizeof(brlyt_wnd1);
- }
-
- brlyt_wnd2 wndy2;
- subnode = mxmlFindElement(node, node, "wnd2", NULL, NULL, MXML_DESCEND);
- if (subnode != NULL)
- {
- mxml_node_t *subsubnode;
- subsubnode = mxmlFindElement(subnode, subnode, "unk1", NULL, NULL, MXML_DESCEND);
+ subsubnode = mxmlFindElement(subnode, subnode, "material", NULL, NULL, MXML_DESCEND);
if (subnode != NULL)
{
char tempCoord[256];
get_value(subsubnode, tempCoord, 256);
- wndy2.unk1 = short_swap_bytes(strtoul(tempCoord, NULL, 16));
+ wndy1.material = short_swap_bytes(strtoul(tempCoord, NULL, 16));
}
- subsubnode = mxmlFindElement(subnode, subnode, "unk2", NULL, NULL, MXML_DESCEND);
+ subsubnode = mxmlFindElement(subnode, subnode, "CoordinateCount", NULL, NULL, MXML_DESCEND);
if (subsubnode != NULL)
{
char tempCoord[256];
get_value(subsubnode, tempCoord, 256);
- wndy2.unk2 = short_swap_bytes(strtoul(tempCoord, NULL, 16));
+ wndy1.coordinate_count = short_swap_bytes(strtoul(tempCoord, NULL, 16));
}
- fwrite(&wndy2, sizeof(brlyt_wnd2), 1, fp);
- *fileOffset = *fileOffset + sizeof(brlyt_wnd2);
+ subsubnode = mxmlFindElement(subnode, subnode, "padding", NULL, NULL, MXML_DESCEND);
+ if (subsubnode != NULL)
+ {
+ char tempCoord[256];
+ get_value(subsubnode, tempCoord, 256);
+ wndy1.padding = short_swap_bytes(strtoul(tempCoord, NULL, 16));
+ }
+ fwrite(&wndy1, sizeof(brlyt_wnd1), 1, fp);
+ *fileOffset = *fileOffset + sizeof(brlyt_wnd1);
}
brlyt_wnd3 wndy3;
- subnode = mxmlFindElement(node, node, "wnd3", NULL, NULL, MXML_DESCEND);
+ subnode = mxmlFindElement(node, node, "Coords", NULL, NULL, MXML_DESCEND);
if (subnode != NULL)
{
i=0;
@@ -1922,9 +3317,23 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl
{
char tempCoord[256];
get_value(subsubnode, tempCoord, 256);
- wndy4mat.unk1 = be32(strtoul(tempCoord, NULL, 16));
+ wndy4mat.material = be16(strtoul(tempCoord, NULL, 16));
i++;
}
+ subsubnode = mxmlFindElement(subnode, subnode, "index", NULL, NULL, MXML_DESCEND);
+ if (subsubnode != NULL)
+ {
+ char tempCoord[256];
+ get_value(subsubnode, tempCoord, 256);
+ wndy4mat.index = strtoul(tempCoord, NULL, 16);
+ }
+ subsubnode = mxmlFindElement(subnode, subnode, "padding", NULL, NULL, MXML_DESCEND);
+ if (subsubnode != NULL)
+ {
+ char tempCoord[256];
+ get_value(subsubnode, tempCoord, 256);
+ wndy4mat.padding = strtoul(tempCoord, NULL, 16);
+ }
fwrite(&wndy4mat, sizeof(brlyt_wnd4_mat), 1, fp);
*fileOffset = *fileOffset + sizeof(brlyt_wnd4_mat);
}
@@ -1942,9 +3351,9 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl
}
memset(chunk.name, 0, 24 * sizeof(char));
strcpy(chunk.name, temp);
- chunk2.mat_off = short_swap_bytes(findMatOffset(temp));
+ chunk2.mat_num = short_swap_bytes(findMatOffset(temp));
- mxml_node_t *subnode = mxmlFindElement(node, node, "coords", NULL, NULL, MXML_DESCEND);
+ mxml_node_t *subnode = mxmlFindElement(node, node, "translate", NULL, NULL, MXML_DESCEND);
if (subnode != NULL)
{
mxml_node_t *valnode;
@@ -1953,24 +3362,24 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl
{
char tempCoord[256];
get_value(valnode, tempCoord, 256);
- chunk.x = float_swap_bytes(atof(tempCoord));
+ chunk.XTrans = float_swap_bytes(atof(tempCoord));
}
valnode = mxmlFindElement(subnode, subnode, "y", NULL, NULL, MXML_DESCEND);
if (valnode != NULL)
{
char tempCoord[256];
get_value(valnode, tempCoord, 256);
- chunk.y = float_swap_bytes(atof(tempCoord));
+ chunk.YTrans = float_swap_bytes(atof(tempCoord));
}
valnode = mxmlFindElement(subnode, subnode, "z", NULL, NULL, MXML_DESCEND);
if (valnode != NULL)
{
char tempCoord[256];
get_value(valnode, tempCoord, 256);
- chunk.z = float_swap_bytes(atof(tempCoord));
+ chunk.ZTrans = float_swap_bytes(atof(tempCoord));
}
}
- subnode = mxmlFindElement(node, node, "flip", NULL, NULL, MXML_DESCEND);
+ subnode = mxmlFindElement(node, node, "rotate", NULL, NULL, MXML_DESCEND);
if (subnode != NULL)
{
mxml_node_t *valnode;
@@ -1979,17 +3388,24 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl
{
char tempCoord[256];
get_value(valnode, tempCoord, 256);
- chunk.flip_x = float_swap_bytes(atof(tempCoord));
+ chunk.XRotate = float_swap_bytes(atof(tempCoord));
}
valnode = mxmlFindElement(subnode, subnode, "y", NULL, NULL, MXML_DESCEND);
if (valnode != NULL)
{
char tempCoord[256];
get_value(valnode, tempCoord, 256);
- chunk.flip_y = float_swap_bytes(atof(tempCoord));
+ chunk.YRotate = float_swap_bytes(atof(tempCoord));
+ }
+ valnode = mxmlFindElement(subnode, subnode, "z", NULL, NULL, MXML_DESCEND);
+ if (valnode != NULL)
+ {
+ char tempCoord[256];
+ get_value(valnode, tempCoord, 256);
+ chunk.ZRotate = float_swap_bytes(atof(tempCoord));
}
}
- subnode = mxmlFindElement(node, node, "zoom", NULL, NULL, MXML_DESCEND);
+ subnode = mxmlFindElement(node, node, "scale", NULL, NULL, MXML_DESCEND);
if (subnode != NULL)
{
mxml_node_t *valnode;
@@ -1998,14 +3414,14 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl
{
char tempCoord[256];
get_value(valnode, tempCoord, 256);
- chunk.xmag = float_swap_bytes(atof(tempCoord));
+ chunk.XScale = float_swap_bytes(atof(tempCoord));
}
valnode = mxmlFindElement(subnode, subnode, "y", NULL, NULL, MXML_DESCEND);
if (valnode != NULL)
{
char tempCoord[256];
get_value(valnode, tempCoord, 256);
- chunk.ymag = float_swap_bytes(atof(tempCoord));
+ chunk.YScale = float_swap_bytes(atof(tempCoord));
}
}
subnode = mxmlFindElement(node, node, "size", NULL, NULL, MXML_DESCEND);
@@ -2028,13 +3444,54 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl
}
}
- subnode = mxmlFindElement(node, node, "flags", NULL, NULL, MXML_DESCEND);
+ u8 flag1 = 0;
+ subnode = mxmlFindElement(node, node, "visible", NULL, NULL, MXML_DESCEND);
if (subnode != NULL)
{
char tempCoord[256];
get_value(subnode, tempCoord, 256);
- chunk.flag1 = strtol(tempCoord, NULL, 16);
- chunk.flag2 = strtol(&(tempCoord[3]), NULL, 16);
+ flag1 |= strtol(tempCoord, NULL, 16);
+ }
+ subnode = mxmlFindElement(node, node, "WidescreenAffected", NULL, NULL, MXML_DESCEND);
+ if (subnode != NULL)
+ {
+ char tempCoord[256];
+ get_value(subnode, tempCoord, 256);
+ flag1 |= ( strtol(tempCoord, NULL, 16) << 1 );
+ }
+ subnode = mxmlFindElement(node, node, "flag", NULL, NULL, MXML_DESCEND);
+ if (subnode != NULL)
+ {
+ char tempCoord[256];
+ get_value(subnode, tempCoord, 256);
+ flag1 |= ( strtol(tempCoord, NULL, 16) << 2 );
+ }
+ chunk.flag1 = flag1;
+ subnode = mxmlFindElement(node, node, "origin", NULL, NULL, MXML_DESCEND);
+ if (subnode != NULL)
+ {
+ char origins[9][15];
+ memset( origins , 0 , 8 * 20 );
+ strcpy( origins[0] , "TOP LEFT" );
+ strcpy( origins[1] , "TOP CENTER" );
+ strcpy( origins[2] , "TOP RIGHT" );
+ strcpy( origins[3] , "MIDDLE LEFT" );
+ strcpy( origins[4] , "MIDDLE CENTER" );
+ strcpy( origins[5] , "MIDDLE RIGHT" );
+ strcpy( origins[6] , "BOTTOM LEFT" );
+ strcpy( origins[7] , "BOTTOM CENTER" );
+ strcpy( origins[8] , "BOTTOM RIGHT" );
+
+ char tempCoord[256];
+ get_value(subnode, tempCoord, 256);
+ chunk.origin = strtol(tempCoord, NULL, 16);
+ int i;
+ for ( i = 0 ; i < 9 ; i++ ) {
+ if ( strncmp( origins[i] , tempCoord , 15 ) == 0 ) {
+ chunk.origin = i;
+ break;
+ }
+ }
}
subnode = mxmlFindElement(node, node, "alpha", NULL, NULL, MXML_DESCEND);
if (subnode != NULL)
@@ -2042,14 +3499,13 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl
char tempCoord[256];
get_value(subnode, tempCoord, 256);
chunk.alpha = strtol(tempCoord, NULL, 16);
- chunk.alpha2 = strtol(&(tempCoord[3]), NULL, 16);
}
- subnode = mxmlFindElement(node, node, "rotate", NULL, NULL, MXML_DESCEND);
+ subnode = mxmlFindElement(node, node, "padding", NULL, NULL, MXML_DESCEND);
if (subnode != NULL)
{
char tempCoord[256];
get_value(subnode, tempCoord, 256);
- chunk.angle = float_swap_bytes(atof(tempCoord));
+ chunk.pad = strtol(tempCoord, NULL, 16);
}
subnode = mxmlFindElement(node, node, "font", NULL, NULL, MXML_DESCEND);
@@ -2097,9 +3553,28 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl
valnode = mxmlFindElement(subnode, subnode, "alignment", NULL, NULL, MXML_DESCEND);
if (valnode != NULL)
{
- char tempCoord[256];
- get_value(valnode, tempCoord, 256);
- chunk2.alignment = strtol(tempCoord, NULL, 16);
+ char alignments[9][15];
+ memset( alignments , 0 , 8 * 20 );
+ strcpy( alignments[0] , "TOP LEFT" );
+ strcpy( alignments[1] , "TOP CENTER" );
+ strcpy( alignments[2] , "TOP RIGHT" );
+ strcpy( alignments[3] , "MIDDLE LEFT" );
+ strcpy( alignments[4] , "MIDDLE CENTER" );
+ strcpy( alignments[5] , "MIDDLE RIGHT" );
+ strcpy( alignments[6] , "BOTTOM LEFT" );
+ strcpy( alignments[7] , "BOTTOM CENTER" );
+ strcpy( alignments[8] , "BOTTOM RIGHT" );
+
+ char tempCoord[256];
+ get_value(subnode, tempCoord, 256);
+ chunk2.alignment = strtol(tempCoord, NULL, 16);
+ int i;
+ for ( i = 0 ; i < 9 ; i++ ) {
+ if ( strncmp( alignments[i] , tempCoord , 15 ) == 0 ) {
+ chunk2.alignment = i;
+ break;
+ }
+ }
}
}
@@ -2113,23 +3588,29 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl
chunk2.len2 = strtoul(tempCoord+5, NULL, 16);
chunk2.len2 = short_swap_bytes(chunk2.len2);
}
- subnode = mxmlFindElement(node, node, "color", NULL, NULL, MXML_DESCEND);
+ subnode = mxmlFindElement(node, node, "color1", NULL, NULL, MXML_DESCEND);
if (subnode != NULL)
{
char tempCoord[256];
get_value(subnode, tempCoord, 256);
chunk2.color1 = be32(strtoul(tempCoord, NULL, 16));
- chunk2.color2 = be32(strtoul(tempCoord+9, NULL, 16));
+ }
+ subnode = mxmlFindElement(node, node, "color2", NULL, NULL, MXML_DESCEND);
+ if (subnode != NULL)
+ {
+ char tempCoord[256];
+ get_value(subnode, tempCoord, 256);
+ chunk2.color2 = be32(strtoul(tempCoord, NULL, 16));
}
u16 textyLength = short_swap_bytes(chunk2.len2);
if ((textyLength % 4) != 0)
textyLength += (4 - (textyLength % 4));
- unsigned char texty[textyLength + 1];
- unsigned char tempy[textyLength*2];
+ u8 texty[textyLength + 1];
+ u8 tempy[textyLength*2];
subnode = mxmlFindElement(node, node, "text", NULL, NULL, MXML_DESCEND);
if (subnode != NULL)
{
- unsigned char tempCoord[8184];
+ u8 tempCoord[8184];
get_value(subnode, tempCoord, 8184);
memcpy(tempy, tempCoord, short_swap_bytes(chunk2.len2)*2);
u32 w; for (w=0;w<short_swap_bytes(chunk2.len2);w++)
@@ -2171,7 +3652,7 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl
memset(chunk.name, 0, 24 * sizeof(char));
strcpy(chunk.name, temp);
- mxml_node_t *subnode = mxmlFindElement(node, node, "coords", NULL, NULL, MXML_DESCEND);
+ mxml_node_t *subnode = mxmlFindElement(node, node, "translate", NULL, NULL, MXML_DESCEND);
if (subnode != NULL)
{
mxml_node_t *valnode;
@@ -2180,24 +3661,24 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl
{
char tempCoord[256];
get_value(valnode, tempCoord, 256);
- chunk.x = float_swap_bytes(atof(tempCoord));
+ chunk.XTrans = float_swap_bytes(atof(tempCoord));
}
valnode = mxmlFindElement(subnode, subnode, "y", NULL, NULL, MXML_DESCEND);
if (valnode != NULL)
{
char tempCoord[256];
get_value(valnode, tempCoord, 256);
- chunk.y = float_swap_bytes(atof(tempCoord));
+ chunk.YTrans = float_swap_bytes(atof(tempCoord));
}
valnode = mxmlFindElement(subnode, subnode, "z", NULL, NULL, MXML_DESCEND);
if (valnode != NULL)
{
char tempCoord[256];
get_value(valnode, tempCoord, 256);
- chunk.z = float_swap_bytes(atof(tempCoord));
+ chunk.ZTrans = float_swap_bytes(atof(tempCoord));
}
}
- subnode = mxmlFindElement(node, node, "flip", NULL, NULL, MXML_DESCEND);
+ subnode = mxmlFindElement(node, node, "rotate", NULL, NULL, MXML_DESCEND);
if (subnode != NULL)
{
mxml_node_t *valnode;
@@ -2206,17 +3687,24 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl
{
char tempCoord[256];
get_value(valnode, tempCoord, 256);
- chunk.flip_x = float_swap_bytes(atof(tempCoord));
+ chunk.XRotate = float_swap_bytes(atof(tempCoord));
}
valnode = mxmlFindElement(subnode, subnode, "y", NULL, NULL, MXML_DESCEND);
if (valnode != NULL)
{
char tempCoord[256];
get_value(valnode, tempCoord, 256);
- chunk.flip_y = float_swap_bytes(atof(tempCoord));
+ chunk.YRotate = float_swap_bytes(atof(tempCoord));
+ }
+ valnode = mxmlFindElement(subnode, subnode, "z", NULL, NULL, MXML_DESCEND);
+ if (valnode != NULL)
+ {
+ char tempCoord[256];
+ get_value(valnode, tempCoord, 256);
+ chunk.ZRotate = float_swap_bytes(atof(tempCoord));
}
}
- subnode = mxmlFindElement(node, node, "zoom", NULL, NULL, MXML_DESCEND);
+ subnode = mxmlFindElement(node, node, "scale", NULL, NULL, MXML_DESCEND);
if (subnode != NULL)
{
mxml_node_t *valnode;
@@ -2225,14 +3713,14 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl
{
char tempCoord[256];
get_value(valnode, tempCoord, 256);
- chunk.xmag = float_swap_bytes(atof(tempCoord));
+ chunk.XScale = float_swap_bytes(atof(tempCoord));
}
valnode = mxmlFindElement(subnode, subnode, "y", NULL, NULL, MXML_DESCEND);
if (valnode != NULL)
{
char tempCoord[256];
get_value(valnode, tempCoord, 256);
- chunk.ymag = float_swap_bytes(atof(tempCoord));
+ chunk.YScale = float_swap_bytes(atof(tempCoord));
}
}
subnode = mxmlFindElement(node, node, "size", NULL, NULL, MXML_DESCEND);
@@ -2255,13 +3743,54 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl
}
}
- subnode = mxmlFindElement(node, node, "flags", NULL, NULL, MXML_DESCEND);
+ u8 flag1 = 0;
+ subnode = mxmlFindElement(node, node, "visible", NULL, NULL, MXML_DESCEND);
+ if (subnode != NULL)
+ {
+ char tempCoord[256];
+ get_value(subnode, tempCoord, 256);
+ flag1 |= strtol(tempCoord, NULL, 16);
+ }
+ subnode = mxmlFindElement(node, node, "WidescreenAffected", NULL, NULL, MXML_DESCEND);
+ if (subnode != NULL)
+ {
+ char tempCoord[256];
+ get_value(subnode, tempCoord, 256);
+ flag1 |= ( strtol(tempCoord, NULL, 16) << 1 );
+ }
+ subnode = mxmlFindElement(node, node, "flag", NULL, NULL, MXML_DESCEND);
+ if (subnode != NULL)
+ {
+ char tempCoord[256];
+ get_value(subnode, tempCoord, 256);
+ flag1 |= ( strtol(tempCoord, NULL, 16) << 2 );
+ }
+ chunk.flag1 = flag1;
+ subnode = mxmlFindElement(node, node, "origin", NULL, NULL, MXML_DESCEND);
if (subnode != NULL)
{
+ char origins[9][15];
+ memset( origins , 0 , 8 * 20 );
+ strcpy( origins[0] , "TOP LEFT" );
+ strcpy( origins[1] , "TOP CENTER" );
+ strcpy( origins[2] , "TOP RIGHT" );
+ strcpy( origins[3] , "MIDDLE LEFT" );
+ strcpy( origins[4] , "MIDDLE CENTER" );
+ strcpy( origins[5] , "MIDDLE RIGHT" );
+ strcpy( origins[6] , "BOTTOM LEFT" );
+ strcpy( origins[7] , "BOTTOM CENTER" );
+ strcpy( origins[8] , "BOTTOM RIGHT" );
+
char tempCoord[256];
get_value(subnode, tempCoord, 256);
- chunk.flag1 = strtol(tempCoord, NULL, 16);
- chunk.flag2 = strtol(&(tempCoord[3]), NULL, 16);
+ chunk.origin = strtol(tempCoord, NULL, 16);
+ int i;
+ for ( i = 0 ; i < 9 ; i++ ) {
+ if ( strncmp( origins[i] , tempCoord , 15 ) == 0 ) {
+ chunk.origin = i;
+ break;
+ }
+ }
}
subnode = mxmlFindElement(node, node, "alpha", NULL, NULL, MXML_DESCEND);
if (subnode != NULL)
@@ -2269,14 +3798,13 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl
char tempCoord[256];
get_value(subnode, tempCoord, 256);
chunk.alpha = strtol(tempCoord, NULL, 16);
- chunk.alpha2 = strtol(&(tempCoord[3]), NULL, 16);
}
- subnode = mxmlFindElement(node, node, "rotate", NULL, NULL, MXML_DESCEND);
+ subnode = mxmlFindElement(node, node, "padding", NULL, NULL, MXML_DESCEND);
if (subnode != NULL)
{
char tempCoord[256];
get_value(subnode, tempCoord, 256);
- chunk.angle = float_swap_bytes(atof(tempCoord));
+ chunk.pad = strtol(tempCoord, NULL, 16);
}
brlyt_pic_chunk chunk2;
@@ -2290,7 +3818,7 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl
printf("No name attribute found!\nQuitting!\n");
exit(1);
}
- chunk2.mat_off = short_swap_bytes(findMatOffset(temp));
+ chunk2.mat_num = short_swap_bytes(findMatOffset(temp));
}
subnode = mxmlFindElement(node, node, "colors", NULL, NULL, MXML_DESCEND);
if (subnode != NULL)
@@ -2301,7 +3829,7 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl
{
char tempCoord[256];
get_value(valnode, tempCoord, 256);
- chunk2.vtx_colors[i] = be32(strtoul(&(tempCoord[2]), NULL, 16));
+ chunk2.vtx_colors[i] = be32(strtoul(tempCoord, NULL, 16));
i++;
}
}
@@ -2410,17 +3938,17 @@ void WriteBRLYTHeader(brlyt_header rlythead, FILE* fp)
writehead.magic[1] = rlythead.magic[1];
writehead.magic[2] = rlythead.magic[2];
writehead.magic[3] = rlythead.magic[3];
- writehead.unk1 = be32(rlythead.unk1);
+ writehead.version = be32(rlythead.version);
writehead.filesize = be32(rlythead.filesize);
writehead.lyt_offset = short_swap_bytes(rlythead.lyt_offset);
- writehead.unk2 = short_swap_bytes(rlythead.unk2);
+ writehead.sections = short_swap_bytes(rlythead.sections);
fwrite(&writehead, sizeof(brlyt_header), 1, fp);
}
void write_brlyt(char *infile, char *outfile)
{
- unsigned int fileOffset = 0;
+ u32 fileOffset = 0;
FILE* fpx = fopen(infile, "r");
if(fpx == NULL) {
printf("xmlyt couldn't be opened!\n");
@@ -2432,7 +3960,7 @@ void write_brlyt(char *infile, char *outfile)
exit(1);
}
mxml_node_t *tree = mxmlFindElement(hightree, hightree, "xmlyt", NULL, NULL, MXML_DESCEND);
- if(hightree == NULL) {
+ if(tree == NULL) {
printf("Couldn't get tree!\n");
exit(1);
}
@@ -2451,10 +3979,10 @@ void write_brlyt(char *infile, char *outfile)
rlythead.magic[1] = 'L';
rlythead.magic[2] = 'Y';
rlythead.magic[3] = 'T';
- rlythead.unk1 = 0xFEFF0008;
+ rlythead.version = 0xFEFF0008;
rlythead.filesize = 0;
rlythead.lyt_offset = sizeof(brlyt_header);
- rlythead.unk2 = 1;
+ rlythead.sections = 1;
WriteBRLYTHeader(rlythead, fp);
fileOffset += sizeof(brlyt_header);
@@ -2471,7 +3999,7 @@ void write_brlyt(char *infile, char *outfile)
exit(1);
}
- unsigned int chunkHeaderOffset = fileOffset;
+ u32 chunkHeaderOffset = fileOffset;
brlyt_entry_header chunk;
chunk.magic[0]=tempType[0];
@@ -2499,7 +4027,7 @@ void write_brlyt(char *infile, char *outfile)
}
rlythead.filesize = fileOffset;
- rlythead.unk2 = blobcount;
+ rlythead.sections = blobcount;
fseek(fp, 0, SEEK_SET);
WriteBRLYTHeader(rlythead, fp);
diff --git a/brlyt.h b/brlyt.h
index 262c8a7..9f009d1 100644
--- a/brlyt.h
+++ b/brlyt.h
@@ -12,41 +12,42 @@
typedef struct
{
- fourcc magic; // RLYT
- u32 unk1; // 0xFEFF0008
- u32 filesize; // The filesize of the brlyt.
- u16 lyt_offset; // Offset to the lyt1 section.
- u16 unk2; // Number of sections.
+ fourcc magic; // RLYT
+ u32 version; // 0xFEFF0008
+ u32 filesize; // The filesize of the brlyt.
+ u16 lyt_offset; // Offset to the lyt1 section.
+ u16 sections; // Number of sections.
} brlyt_header;
typedef struct
{
- fourcc magic; // The magic.
- u32 length; // How long the entry is.
+ fourcc magic; // The magic.
+ u32 length; // How long the entry is.
} brlyt_entry_header;
typedef struct
{
- fourcc magic; // The magic.
- u32 length; // How long the entry is.
- u32 data_location; // The location of the data in the BRLYT file.
+ fourcc magic; // The magic.
+ u32 length; // How long the entry is.
+ u32 data_location; // The location of the data in the BRLYT file.
} brlyt_entry;
typedef struct
{
- u8 flag1;
- u8 flag2;
+ u8 flag1; // bits: 31-visibility 30-aspect_affected 29-??
+ u8 origin;
u8 alpha;
- u8 alpha2;
- char name[24];
- float x;
- float y;
- float z;
- float flip_x;
- float flip_y;
- float angle;
- float xmag;
- float ymag;
+ u8 pad;
+ char name[0x10];
+ char userdata[0x08];
+ float XTrans;
+ float YTrans;
+ float ZTrans;
+ float XRotate;
+ float YRotate;
+ float ZRotate;
+ float XScale;
+ float YScale;
float width;
float height;
} brlyt_pane_chunk;
@@ -55,10 +56,10 @@ typedef struct
{
u16 len1;
u16 len2;
- u16 mat_off;
+ u16 mat_num;
u16 font_idx;
u8 alignment;
- u8 pad[3]; // [0, 0, 0]
+ u8 pad[3];
u32 name_offs;
u32 color1;
u32 color2;
@@ -70,72 +71,49 @@ typedef struct
typedef struct
{
- u32 vtx_colors[4]; // [4294967295L, 4294967295L, 4294967295L, 4294967295L]
- u16 mat_off;
+ u32 vtx_colors[4]; // [4294967295L, 4294967295L, 4294967295L, 4294967295L]
+ u16 mat_num;
u8 num_texcoords;
- u8 padding; // 0
+ u8 padding; // 0
} brlyt_pic_chunk;
typedef struct
{
- float unk1[4]; // all 0x00000000
- u8 count; // 0x01
- u8 padding[3]; // 0x00 0x00 0x00
- u32 offset1; // 0x00000068 offset to 0xffffffff's
- u32 offset2; // 0x0000007c offset to last 8bytes of wnd1
+ float coords[4]; // all 0x00000000
+ u8 frame_count; // 0x01
+ u8 padding[3]; // 0x00 0x00 0x00
+ u32 offset1; // 0x00000068 offset to brlyt_wnd1 colors
+ u32 offset2; // 0x0000007c offset to frame offset list
} brlyt_wnd;
-typedef struct // pointed at by offset1
+typedef struct // pointed at by offset1
{
- u32 unk1[4]; // all 0xffffffff
+ u32 colors[4]; // all 0xffffffff
+ u16 material; // 0x0000
+ u8 coordinate_count; // 0x01
+ u8 padding; // 0x00
} brlyt_wnd1;
typedef struct
{
- u16 unk1[6]; // 0x0019 0x0000 0x0000 0x0080 0x001a 0x0000
-} brlyt_wnd2ish;
-
-typedef struct
-{
- u16 unk1; // 0x0000
- u16 unk2; // 0x0100
-} brlyt_wnd2;
-
-typedef struct
-{
- float texcoords[8]; // 0x00 0x00 3f800000 0x00 0x00 3f800000 3f800000 3f800000
+ float texcoords[8]; // 0x00 0x00 3f800000 0x00 0x00 3f800000 3f800000 3f800000
} brlyt_wnd3;
-typedef struct // pointed to by offset2
+typedef struct // pointed to by offset2
{
- u32 offset; // offset to something
+ u32 offset; // offset to something
} brlyt_wnd4;
typedef struct
{
- u32 unk1; // material number ??
+ u16 material; // material number
+ u8 index;
+ u8 padding;
} brlyt_wnd4_mat;
-typedef struct // 0003-0005
-{
- u32 unk1[2]; // 0xb4 0xb8
- u16 unk2[8]; // 0x0012 0x0000 0x0013 0x0000 0x0014 0x0500 0x0015 0x0200
-} brlyt_wnd_addon2;
-
-// !! bytes 0-7 header
-// !! bytes 8-b flags/alpha
-// !! bytes c-23 name
-// !! floats 24-4b
-// ! floats 4c-5b
-// ! byte 5c count
-// ! bytes 60-63 offset // 4 8 and c are words 12 is a byte following that is tex coords
-// ! byte 64-67 offset
-// <count> words that are an offset to a struct of (short, bytes) short is a mat offset
-
-
typedef struct
{
- char a;
+ char drawnFromMiddle;// related to whether is drawn from middle // 1 = TRUE 2 = FALSE
char pad[3];
float width;
float height;
@@ -159,7 +137,7 @@ typedef struct
char name[20];
s16 forecolor[4];
s16 backcolor[4];
- s16 unk_color_2[4];
+ s16 colorReg3[4];
u32 tev_kcolor[4];
u32 flags;
} brlyt_material_chunk;
@@ -177,36 +155,164 @@ typedef struct
u8 wrap_t;
} brlyt_texref_chunk;
-typedef struct // SRT Array
+typedef struct
+{
+ float XTrans;
+ float YTrans;
+ float Rotate;
+ float XScale;
+ float YScale;
+} brlyt_tex_srt;
+
+typedef struct
+{
+ char tgen_type;
+ char tgen_src;
+ char mtxsrc;
+ char padding;
+} brlyt_tex_coordgen;
+
+typedef struct
+{
+ char color_matsrc;
+ char alpha_matsrc;
+ char padding1;
+ char padding2;
+} brlyt_tex_chanctrl;
+
+typedef struct
+{
+ u8 red;
+ u8 green;
+ u8 blue;
+ u8 alpha;
+} brlyt_tex_matcol;
+
+typedef struct
+{
+ unsigned red : 2;
+ unsigned green : 2;
+ unsigned blue : 2;
+ unsigned alpha : 2;
+} brlyt_tev_swapmode;
+
+typedef struct
+{
+ unsigned Texture : 4;
+ unsigned TexSRT : 4;
+ unsigned TexCoord : 4;
+ unsigned ua6 : 1;
+ unsigned ua7 : 2;
+ unsigned ua8 : 3;
+ unsigned ua9 : 5;
+ unsigned uaa : 1;
+ unsigned uab : 1;
+ unsigned ua4 : 1;
+ unsigned padding1 : 1;
+ unsigned ua5 : 1;
+ unsigned padding2 : 4;
+} mat_flags;
+
+// 0000 0000 0000 0000 0000 0000 0000 0000
+// xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx
+// ---- 5-4b a999 9988 8776 3333 2222 1111
+
+typedef struct
+{
+ union
+ {
+ mat_flags flag;
+ u32 flags;
+ };
+} mat1_flags;
+
+typedef struct
+{
+ u8 one;
+ u8 two;
+ u8 three;
+ u8 four;
+} brlyt_tev_swapmodetable;
+
+typedef struct
+{
+ float XTrans;
+ float YTrans;
+ float Rotate;
+ float XScale;
+ float YScale;
+} brlyt_indtex_srt;
+
+typedef struct
{
- float x1;
- float y1;
- float angle;
- float x2;
- float y2;
-} brlyt_tex_coords;
+ u8 tex_coord;
+ u8 tex_map;
+ u8 scale_s;
+ u8 scale_t;
+} brlyt_indtex_order;
typedef struct
{
- u8 unk[4];
-} brlyt_4b_chunk;
+ unsigned texcoord : 8; // GX_SetTevOrder( i , this , * , * );
+ unsigned color : 8; // GX_SetTevOrder( i , * , * , this );
+ unsigned texmapbot : 8; // GX_SetTevOrder( i , * , this | *2 , * ); *1
+ unsigned texmaptop : 1; // GX_SetTevOrder( i , * , *1 | this , * ); *2
+ unsigned ras_sel : 2; // GX_SetTevSwapMode( i , this , * );
+ unsigned tex_sel : 2; // GX_SetTevSwapMode( i , * , this );
+ unsigned empty1 : 3;//pad
+ unsigned aC : 4; // GX_SetTevColorIn( i , this , * , * , * );
+ unsigned bC : 4; // GX_SetTevColorIn( i , * , this , * , * );
+ unsigned cC : 4; // GX_SetTevColorIn( i , * , * , this , * );
+ unsigned dC : 4; // GX_SetTevColorIn( i , * , * , * , this );
+ unsigned tevscaleC : 2; // GX_SetTevColorOp( i , * , * , this , * , * );
+ unsigned tevbiasC : 2; // GX_SetTevColorOp( i , * , this , * , * , * );
+ unsigned tevopC : 4; // GX_SetTevColorOp( i , this , * , * , * , * );
+ unsigned tevregidC : 1; // GX_SetTevColorOp( i , * , * , * , * , this );
+ unsigned clampC : 2; // GX_SetTecColorOp( i , * , * , * , this , * );
+ unsigned selC : 5; // GX_SetTevKColorSel( i , this );
+ unsigned aA : 4; // GX_SetTevAlphaIn( i , this , * , * , * );
+ unsigned bA : 4; // GX_SetTevAlphaIn( i , * , this , * , * );
+ unsigned cA : 4; // GX_SetTevAlphaIn( i , * , * , this , * );
+ unsigned dA : 4; // GX_SetTevAlphaIn( i , * , * , * , this );
+ unsigned tevscaleA : 2; // GX_SetTevAlphaOp( i , * , * , this , * , * );
+ unsigned tevbiasA : 2; // GX_SetTevAlphaOp( i , * , this , * , * , * );
+ unsigned tevopA : 4; // GX_SetTevAlphaOp( i , this , * , * , * , * );
+ unsigned tevregidA : 1; // GX_SetTevAlphaOp( i , * , * , * , * , this );
+ unsigned clampA : 2; // GX_SetTecAlphaOp( i , * , * , * , this , * );
+ unsigned selA : 5; // GX_SetTevKAlphaSel( i , this );
+ unsigned indtexid : 8; // GX_SetTevIndirect( i , this , * , * , * , * , * , * , * , * );
+ unsigned bias : 3; // GX_SetTevIndirect( i , * , * , this , * , * , * , * , * , * );
+ unsigned mtxid : 4; // GX_SetTevIndirect( i , * , * , * , this , * , * , * , * , * );
+ unsigned empty2 : 1;//pad
+ unsigned wrap_s : 3; // GX_SetTevIndirect( i , * , * , * , * , this , * , * , * , * );
+ unsigned wrap_t : 3; // GX_SetTevIndirect( i , * , * , * , * , * , this , * , * , * );
+ unsigned empty3 : 2;//pad
+ unsigned format : 2; // GX_SetTevIndirect( i , * , this , * , * , * , * , * , * , * );
+ unsigned addprev : 1; // GX_SetTevIndirect( i , * , * , * , * , * , * , this , * , * );
+ unsigned utclod : 1; // GX_SetTevIndirect( i , * , * , * , * , * , * , * , this , * );
+ unsigned aIND : 2; // GX_SetTevIndirect( i , * , * , * , * , * , * , * , * , this );
+ unsigned empty4 : 2;//pad
+} TevStages;
typedef struct
{
- u32 a; // floating point
- u32 b; // floating point
- float c;
- float d;
- float e;
-} brlyt_ua7_chunk;
+ unsigned comp0 : 4;
+ unsigned comp1 : 4; // had to switch
+ unsigned aop : 8;
+ unsigned ref0 : 8;
+ unsigned ref1 : 8;
+} brlyt_alpha_compare;
typedef struct
{
- u8 unk[16];
-} brlyt_10b_chunk;
+ u8 type;
+ u8 src_fact;
+ u8 dst_fact;
+ u8 op;
+} brlyt_blend_mode;
-void swapBytes(unsigned char* char1, unsigned char* char2);
-int bitExtraction(unsigned int num, unsigned int start, unsigned int end);
+u8 swapBits( u8 char1 );
+u32 bitExtraction(u32 num, u32 start, u32 end);
void parse_brlyt(char *filename, char *filenameout);
void make_brlyt(char* infile, char* outfile);
diff --git a/general.h b/general.h
index dbf8831..9334b14 100644
--- a/general.h
+++ b/general.h
@@ -6,8 +6,8 @@
\******************************************************************************/
#define BENZIN_VERSION_MAJOR 1
-#define BENZIN_VERSION_MINOR 2
-#define BENZIN_VERSION_BUILD 1
+#define BENZIN_VERSION_MINOR 9
+#define BENZIN_VERSION_BUILD 0
#define BENZIN_VERSION_OTHER "BETA"
#define INFORMATION_TEXT \