From 872a7b2efde01039ad2aa888ae6460467704ff71 Mon Sep 17 00:00:00 2001 From: megazig Date: Sat, 19 Sep 2009 11:57:34 -0500 Subject: updated to 1.9 with lots of changes --- brlyt.c | 2422 +++++++++++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 1975 insertions(+), 447 deletions(-) (limited to 'brlyt.c') 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>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>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 disappears. - //# 2nd --> no visible effect. - //# 3rd --> disappears. - //# 4th --> no visible effect. mxml_node_t *ua4; //# 4 * flags[6] for (n=0;n> 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> 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); + 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) @@ -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); + 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); - chunk.flag1 = strtol(tempCoord, NULL, 16); - chunk.flag2 = strtol(&(tempCoord[3]), NULL, 16); + 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 Date: Sun, 20 Sep 2009 14:16:12 -0500 Subject: added lots of cleanup and changed vtx to color pieces and cleaned up main --- benzin.sh | 11 + brlan.c | 337 ++--- brlan.h | 3 +- brlyt.c | 4775 +++++++++++++++++++++++++++++++------------------------------ general.h | 2 +- main.c | 205 ++- types.h | 9 + 7 files changed, 2691 insertions(+), 2651 deletions(-) create mode 100644 benzin.sh (limited to 'brlyt.c') diff --git a/benzin.sh b/benzin.sh new file mode 100644 index 0000000..ba61649 --- /dev/null +++ b/benzin.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +sudo apt-get install git-core libmxml-dev build-essential +git clone git://github.com/SquidMan/benzin.git + +cd benzin + +make clean +make + +./benzin diff --git a/brlan.c b/brlan.c index 4ab2e8b..d2b37d8 100644 --- a/brlan.c +++ b/brlan.c @@ -19,9 +19,9 @@ #include "endian.h" #if DEBUGBRLAN == 1 -#define dbgprintf printf +#define dbgprintf printf #else -#define dbgprintf // +#define dbgprintf // #endif //DEBUGBRLAN #define MAXIMUM_TAGS_SIZE (0xf000) @@ -119,21 +119,21 @@ void BRLAN_CreateXMLTag(tag_header tagHeader, void* data, u32 offset, mxml_node_ 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]); + 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]); + 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]); + 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]); + 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]); + 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]); + 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]); + mxmlElementSetAttrf(entry, "type2", "%s",tag_types_rlim_list[tagEntryInfo.type2]); } else { - mxmlElementSetAttrf(entry, "type2", "%s", tag_types_list[tagEntryInfo.type2]); + mxmlElementSetAttrf(entry, "type2", "%s",tag_types_list[tagEntryInfo.type2]); } } else { mxmlElementSetAttrf(entry, "type2", "%u", tagEntryInfo.type2); @@ -154,9 +154,12 @@ void BRLAN_CreateXMLTag(tag_header tagHeader, void* data, u32 offset, mxml_node_ 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)); + 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)); @@ -169,9 +172,12 @@ void BRLAN_CreateXMLTag(tag_header tagHeader, void* data, u32 offset, mxml_node_ 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); + 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); } } } @@ -202,16 +208,16 @@ void parse_brlan(char* filename, char *filenameout) 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[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 @@ -219,16 +225,16 @@ void parse_brlan(char* filename, char *filenameout) strcpy(tag_types_list[14], "0x0E"); strcpy(tag_types_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[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 @@ -244,16 +250,16 @@ void parse_brlan(char* filename, char *filenameout) strcpy(tag_types_rlvi_list[0], "Visibility"); - 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[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"); @@ -261,16 +267,16 @@ void parse_brlan(char* filename, char *filenameout) strcpy(tag_types_rlvc_list[14], "Bottom Right B"); strcpy(tag_types_rlvc_list[15], "Bottom Right A"); - 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[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"); @@ -278,16 +284,16 @@ void parse_brlan(char* filename, char *filenameout) 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[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"); @@ -369,7 +375,9 @@ void parse_brlan(char* filename, char *filenameout) 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); + 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)); @@ -469,51 +477,51 @@ void create_entries_from_xml(mxml_node_t *tree, mxml_node_t *node, brlan_entry * 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, rlpa_type, 4) == 0) - { - for(i = 0; i < strlen(tag_types_rlpa_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 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_rlmc_list[x][i]); - } - } else if(memcmp(tag_type, rltp_type, 4) == 0) { - for(i = 0; i < strlen(tag_types_rltp_list[x]); i++) - { - temp3[x][i] = toupper(tag_types_rltp_list[x][i]); - } - } else if(memcmp(tag_type, rlim_type, 4) == 0) { - for(i = 0; i < strlen(tag_types_rlim_list[x]); i++) - { - temp3[x][i] = toupper(tag_types_rlim_list[x][i]); - } - } else { - for(i = 0; i < strlen(tag_types_list[x]); i++) - { - temp3[x][i] = toupper(tag_types_list[x][i]); - } - } + for(i = 0; i < 16; i++) + memset(temp3[i], 0, 24); + for(x = 0; x < 16; x++) + if(memcmp(tag_type, rlpa_type, 4) == 0) + { + for(i = 0; i < strlen(tag_types_rlpa_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 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_rlmc_list[x][i]); + } + } else if(memcmp(tag_type, rltp_type, 4) == 0) { + for(i = 0; i < strlen(tag_types_rltp_list[x]); i++) + { + temp3[x][i] = toupper(tag_types_rltp_list[x][i]); + } + } else if(memcmp(tag_type, rlim_type, 4) == 0) { + for(i = 0; i < strlen(tag_types_rlim_list[x]); i++) + { + temp3[x][i] = toupper(tag_types_rlim_list[x][i]); + } + } else { + for(i = 0; i < strlen(tag_types_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++) { @@ -605,7 +613,7 @@ void create_entries_from_xml(mxml_node_t *tree, mxml_node_t *node, brlan_entry * } 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); + tempnode = mxmlFindElement(subsubnode, subsubnode, "padding", NULL,NULL,MXML_DESCEND); if(tempnode == NULL) { printf("Couldn't find attribute \"padding\"!\n"); exit(1); @@ -654,7 +662,7 @@ void create_entries_from_xml(mxml_node_t *tree, mxml_node_t *node, brlan_entry * if ( entryinfo[0].data_type == 0x200 ) free(data); if ( entryinfo[0].data_type == 0x100 ) - free(data2); + free(data2); u32 oldpos = ftell(fp); fseek(fp, entryloc, SEEK_SET); for( x = 0; x < head->entry_count; x++) @@ -683,9 +691,10 @@ void create_tag_from_xml(mxml_node_t *tree, mxml_node_t *node, FILE* fp) strcpy(temp, mxmlElementGetAttr(node, "type")); entr.is_material = (u8)atoi(temp); } else { + // add nice safety } - + 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)) @@ -714,8 +723,8 @@ void create_tag_from_xml(mxml_node_t *tree, mxml_node_t *node, FILE* fp) { printf("animation type not recognized: %.4s", head.magic); exit(1); - } - create_entries_from_xml(node, tagnode, &entr, &head, fp); + } + create_entries_from_xml(node, tagnode, &entr, &head, fp); entr.num_tags++; } u32 tempOffset = ftell(fp); @@ -731,7 +740,8 @@ void WriteBRLANHeader(brlan_header rlanhead, FILE* fp) writehead.magic[1] = rlanhead.magic[1]; writehead.magic[2] = rlanhead.magic[2]; writehead.magic[3] = rlanhead.magic[3]; - writehead.version = be32(rlanhead.version); + writehead.endian = be16(rlanhead.endian); + writehead.version = be16(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); @@ -770,16 +780,16 @@ void write_brlan(char *infile, char* outfile) 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[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"); @@ -795,16 +805,16 @@ void write_brlan(char *infile, char* outfile) strcpy(tag_types_rlvi_list[0], "Visibility"); - 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[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"); @@ -812,16 +822,16 @@ void write_brlan(char *infile, char* outfile) strcpy(tag_types_rlvc_list[14], "Bottom Right B"); strcpy(tag_types_rlvc_list[15], "Bottom Right A"); - 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[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"); @@ -829,16 +839,16 @@ void write_brlan(char *infile, char* outfile) 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[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"); @@ -879,7 +889,8 @@ void write_brlan(char *infile, char* outfile) rlanhead.magic[1] = 'L'; rlanhead.magic[2] = 'A'; rlanhead.magic[3] = 'N'; - rlanhead.version = 0xFEFF0008; + rlanhead.endian = 0xFEFF; + rlanhead.version = 0x0008; rlanhead.file_size = 0; rlanhead.pai1_offset = sizeof(brlan_header); rlanhead.pai1_count = 1; @@ -896,7 +907,7 @@ void write_brlan(char *infile, char* outfile) 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) @@ -917,7 +928,7 @@ void write_brlan(char *infile, char* outfile) 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)) { @@ -927,7 +938,7 @@ void write_brlan(char *infile, char* outfile) 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]; @@ -974,7 +985,7 @@ void write_brlan(char *infile, char* outfile) paihead.num_timgs = timgcount; - paihead.entry_offset = sizeof(brlan_pai1_header_type1) + totaltimgize + (4*paihead.num_timgs); + 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; diff --git a/brlan.h b/brlan.h index 5617185..3cde79f 100755 --- a/brlan.h +++ b/brlan.h @@ -53,7 +53,8 @@ typedef struct typedef struct { fourcc magic; // "RLAN" in ASCII. - u32 version; // Always 0xFEFF 0x0008. Possibly a versioning string. + u16 endian; // Always 0xFEFF. Tells endian. + u16 version; // Always 0x0008. Version of brlan format 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?) diff --git a/brlyt.c b/brlyt.c index b7b3758..6a6fdb9 100644 --- a/brlyt.c +++ b/brlyt.c @@ -18,12 +18,12 @@ #include "endian.h" #ifdef DEBUGBRLYT -#define dbgprintf printf +#define dbgprintf printf #else -#define dbgprintf // +#define dbgprintf // #endif //DEBUGBRLYT -#define MAXIMUM_TAGS_SIZE (0x1000) +#define MAXIMUM_TAGS_SIZE (0x1000) char pic1_magic[] = "pic1"; char pan1_magic[] = "pan1"; @@ -51,124 +51,124 @@ int lengthOfTextures; static int FourCCsMatch(fourcc cc1, fourcc cc2) { - int ret[4]; - ret[0] = (cc1[0] == cc2[0]); - ret[1] = (cc1[1] == cc2[1]); - ret[2] = (cc1[2] == cc2[2]); - ret[3] = (cc1[3] == cc2[3]); - int retval; - if(ret[0] && ret[1] && ret[2] && ret[3]) - retval = 1; - else - retval = 0; - return retval; + int ret[4]; + ret[0] = (cc1[0] == cc2[0]); + ret[1] = (cc1[1] == cc2[1]); + ret[2] = (cc1[2] == cc2[2]); + ret[3] = (cc1[3] == cc2[3]); + int retval; + if(ret[0] && ret[1] && ret[2] && ret[3]) + retval = 1; + else + retval = 0; + return retval; } static void BRLYT_ReadDataFromMemoryX(void* destination, void* input, size_t size) { - u8* out = (u8*)destination; - u8* in = ((u8*)input) + BRLYT_fileoffset; - memcpy(out, in, size); + u8* out = (u8*)destination; + u8* in = ((u8*)input) + BRLYT_fileoffset; + memcpy(out, in, size); } static void BRLYT_ReadDataFromMemory(void* destination, void* input, size_t size) { - BRLYT_ReadDataFromMemoryX(destination, input, size); - BRLYT_fileoffset += size; + BRLYT_ReadDataFromMemoryX(destination, input, size); + BRLYT_fileoffset += size; } float float_swap_bytes(float float1) { - u8 *float1c; float1c = (u8*)&float1; + u8 *float1c; float1c = (u8*)&float1; - 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; + 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; - float *newFloat; newFloat = (float*)float1c; - return *newFloat; + float *newFloat; newFloat = (float*)float1c; + return *newFloat; } u32 bit_extract(u32 num, u32 start, u32 end) { - if (end == 100) end = start; - u32 mask; - int first; - int firstMask = 1; - for (first=0;first<31-start+1;first++) - { - firstMask *= 2; - } - firstMask -= 1; - int secondMask = 1; - - for (first=0;first< 31-end;first++) - { - secondMask *=2; - } - secondMask -= 1; - mask = firstMask - secondMask; - int ret = (num & mask) >> (31 - end); - return ret; + if (end == 100) end = start; + u32 mask; + int first; + int firstMask = 1; + for (first=0;first<31-start+1;first++) + { + firstMask *= 2; + } + firstMask -= 1; + int secondMask = 1; + + for (first=0;first< 31-end;first++) + { + secondMask *=2; + } + secondMask -= 1; + mask = firstMask - secondMask; + int ret = (num & mask) >> (31 - end); + return ret; } char* getMaterial(u16 offset) { - if (offset == 0) return materials; - char *mat = materials + strlen(materials) + 1; + if (offset == 0) return materials; + char *mat = materials + strlen(materials) + 1; - if (offset > 1) - { - int n; - for (n=1; n 1) + { + int n; + for (n=1; n 1) - { - int n; - for (n=1; n 1) + { + int n; + for (n=1; n 0) subs = mxmlNewElement(tag, "subs"); - - int n; - for (n=0;n 0) subs = mxmlNewElement(tag, "subs"); + + int i; + for (i=0;i>1); - flags = mxmlNewElement(tag, "flag"); mxmlNewTextf(flags, 0, "%02x", (data.flag1 & 0x4)>>2); + 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); + 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); + 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"); + 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)); + 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)); } void PrintBRLYTEntry_wnd1(brlyt_entry entry, u8* brlyt_file, mxml_node_t *tag) @@ -362,64 +362,64 @@ void PrintBRLYTEntry_wnd1(brlyt_entry entry, u8* brlyt_file, mxml_node_t *tag) 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); - 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); + 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); + 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); + 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, 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, "coordinate"); mxmlNewTextf(unkk, 0, "%f", float_swap_bytes(wndy.coords[i])); - } - 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, *colors, *material; - brlyt_wnd1 wndy1; - BRLYT_ReadDataFromMemory(&wndy1, brlyt_file, sizeof(brlyt_wnd1)); - wnddd = mxmlNewElement(tag, "wnd1"); - for(i=0;i<4;i++) - { - colors = mxmlNewElement(wnddd, "color"); mxmlNewTextf(colors, 0, "%08x", int_swap_bytes(wndy1.colors[i])); - } - - 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; + 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, 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, "coordinate"); mxmlNewTextf(unkk, 0, "%f", float_swap_bytes(wndy.coords[i])); + } + 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, *colors, *material; + brlyt_wnd1 wndy1; + BRLYT_ReadDataFromMemory(&wndy1, brlyt_file, sizeof(brlyt_wnd1)); + wnddd = mxmlNewElement(tag, "wnd1"); + for(i=0;i<4;i++) + { + colors = mxmlNewElement(wnddd, "color"); mxmlNewTextf(colors, 0, "%08x", int_swap_bytes(wndy1.colors[i])); + } + + 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; for ( i = 0 ; i < wndy1.coordinate_count ; i++ ){ brlyt_wnd3 wndy3; BRLYT_ReadDataFromMemory(&wndy3, brlyt_file, sizeof(brlyt_wnd3)); @@ -430,25 +430,25 @@ void PrintBRLYTEntry_wnd1(brlyt_entry entry, u8* brlyt_file, mxml_node_t *tag) } - mxml_node_t *wndddddd, *offsett; - brlyt_wnd4 wndy4; - for(i=0;i>1); - flags = mxmlNewElement(tag, "flag"); mxmlNewTextf(flags, 0, "%02x", (data.flag1 & 0x4)>>2); + 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); + 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); + 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)); + 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)); } void PrintBRLYTEntry_pic1(brlyt_entry entry, u8* brlyt_file, mxml_node_t *tag) @@ -511,58 +511,67 @@ void PrintBRLYTEntry_pic1(brlyt_entry entry, u8* brlyt_file, mxml_node_t *tag) 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)); - brlyt_pic_chunk data2; - BRLYT_ReadDataFromMemory(&data2, brlyt_file, sizeof(brlyt_pic_chunk)); - mxmlElementSetAttrf(tag, "type", "%.4s", entry.magic); - mxmlElementSetAttrf(tag, "name", "%s", data.name); - 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); + 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)); + brlyt_pic_chunk data2; + BRLYT_ReadDataFromMemory(&data2, brlyt_file, sizeof(brlyt_pic_chunk)); + mxmlElementSetAttrf(tag, "type", "%.4s", entry.magic); + mxmlElementSetAttrf(tag, "name", "%s", data.name); + 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); + 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 + 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_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])); - } - coordinates = mxmlNewElement(tag, "coordinates"); - for (n=0;n> 24 ) & 0xff ); + attr = mxmlNewElement(color, "red"); + mxmlNewTextf( attr , 0 , "%02x" , ( be32(data2.vtx_colors[n]) >> 16 ) & 0xff ); + attr = mxmlNewElement(color, "red"); + mxmlNewTextf( attr , 0 , "%02x" , ( be32(data2.vtx_colors[n]) >> 8 ) & 0xff ); + attr = mxmlNewElement(color, "red"); + mxmlNewTextf( attr , 0 , "%02x" , ( be32(data2.vtx_colors[n]) >> 0 ) & 0xff ); + + } + coordinates = mxmlNewElement(tag, "coordinates"); + for (n=0;n>1); - flags = mxmlNewElement(tag, "flag"); mxmlNewTextf(flags, 0, "%02x", (data.flag1 & 0x4)>>2); + 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); + 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); + 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, *color1, *color2, *text; - brlyt_text_chunk data2; - BRLYT_ReadDataFromMemory(&data2, brlyt_file, sizeof(brlyt_text_chunk)); - 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)); - xsize = mxmlNewElement(font, "xsize"); mxmlNewTextf(xsize, 0, "%f", float_swap_bytes(data2.font_size_x)); - 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, "%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> 0] ); @@ -898,7 +907,7 @@ void PrintBRLYTEntry_mat1(brlyt_entry entry, u8* brlyt_file, mxml_node_t *tag) 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"); @@ -907,7 +916,7 @@ void PrintBRLYTEntry_mat1(brlyt_entry entry, u8* brlyt_file, mxml_node_t *tag) 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"); @@ -916,7 +925,7 @@ void PrintBRLYTEntry_mat1(brlyt_entry entry, u8* brlyt_file, mxml_node_t *tag) 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"); @@ -925,26 +934,26 @@ void PrintBRLYTEntry_mat1(brlyt_entry entry, u8* brlyt_file, mxml_node_t *tag) 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 0) - { - u8 toAdd = 4-(*fileOffset % 4); - char nuller[3] = {'\0', '\0', '\0'}; - fwrite(&nuller, sizeof(char), toAdd, fp); - *fileOffset = *fileOffset + toAdd; - } - textures = malloc(lengthOfNames * sizeof(char)); - memcpy(textures, names, lengthOfNames * sizeof(char)); - free(names); - } - if ( memcmp(temp, fnl1, sizeof(fnl1)) == 0) - { - brlyt_numoffs_chunk chunk; - chunk.num = 0; - chunk.offs = 0; - fwrite(&chunk, sizeof(chunk), 1, fp); - *fileOffset = *fileOffset + sizeof(chunk); - - char *names; - names = malloc(sizeof(char)); - int lengthOfNames = 0; - mxml_node_t *subnode = mxmlFindElement(node, node, "entries", NULL, NULL, MXML_DESCEND); - if (subnode != NULL) - { - int numEntries = 0; - - int oldNameLength; - int baseOffset = 0; - int numoffsOffset = *fileOffset - 4; - - u32 *offsunks; - offsunks = malloc(sizeof(u32)); - - brlyt_offsunk_chunk chunk2; - mxml_node_t *valnode; - for(valnode = mxmlFindElement(subnode, subnode, "name", NULL, NULL, MXML_DESCEND); valnode != NULL; valnode = mxmlFindElement(valnode, subnode, "name", NULL, NULL, MXML_DESCEND)) { - if (valnode != NULL) - { - char tempSub[256]; - get_value(valnode, tempSub, 256); - - oldNameLength = lengthOfNames; - lengthOfNames += strlen(tempSub); - - offsunks = realloc(offsunks, (numEntries + 1)*(2 * sizeof(u32))); - offsunks[(numEntries*2)+0] = baseOffset; - offsunks[(numEntries*2)+1] = 0; - - *fileOffset = *fileOffset + sizeof(chunk2); - numEntries++; - - baseOffset += (strlen(tempSub) + 1); - names = realloc(names, 1 + sizeof(char) * lengthOfNames); - memcpy(&names[oldNameLength], tempSub, strlen(tempSub)); - char nuller = '\0'; - memcpy(&names[lengthOfNames], &nuller, sizeof(char)); - lengthOfNames += 1; - } - } - chunk.num = short_swap_bytes(numEntries); - chunk.offs = 0; - fseek(fp, numoffsOffset, SEEK_SET); - fwrite(&chunk, sizeof(chunk), 1, fp); - - int i; - for(i=0;i 0) - { - u8 toAdd = 4-(*fileOffset % 4); - char nuller[3] = {'\0', '\0', '\0'}; - fwrite(&nuller, sizeof(char), toAdd, fp); - *fileOffset = *fileOffset + toAdd; - } - free(names); - } - if ( memcmp(temp, mat1, sizeof(mat1)) == 0) - { - int numberOfEntries = 0; - int actualNumber = 0; - brlyt_numoffs_chunk numchunk; - brlyt_material_chunk chunk; - mxml_node_t *subnode; - for(subnode=mxmlFindElement(node, node, "entries", NULL, NULL, MXML_DESCEND);subnode!=NULL;subnode=mxmlFindElement(subnode, node, "entries", NULL, NULL, MXML_DESCEND)) - numberOfEntries++; - - numchunk.num = short_swap_bytes(numberOfEntries); - numchunk.offs = 0; - fwrite(&numchunk, sizeof(numchunk), 1, fp); - *fileOffset = *fileOffset + sizeof(numchunk); - - int *offsets = calloc(numberOfEntries, sizeof(int)); - int offsetsOffset = ftell(fp); - int materialOffset = 0; - actualNumber = numberOfEntries; - numberOfEntries = 0; - int matSize = 0; - int initialOffset = sizeof(numchunk) + 8 + (actualNumber * sizeof(int)); - - offsets[numberOfEntries] = be32(matSize + initialOffset); - fwrite(&offsets[0], sizeof(int), actualNumber, fp); - *fileOffset = *fileOffset + (actualNumber * 4); - - for(subnode=mxmlFindElement(node,node,"entries",NULL,NULL,MXML_DESCEND);subnode!=NULL;subnode=mxmlFindElement(subnode,node,"entries",NULL,NULL,MXML_DESCEND)) - { - numberOfEntries += 1; - char temp[256]; - if(mxmlElementGetAttr(subnode, "name") != NULL) - strcpy(temp, mxmlElementGetAttr(subnode, "name")); - else{ - printf("No name attribute found!\nQuitting!\n"); - exit(1); - } - memset(chunk.name, 0, 20); - strcpy(chunk.name, temp); - - materials = realloc(materials, lengthOfMaterials + strlen(chunk.name) + 1); - memcpy(&materials[lengthOfMaterials], chunk.name, strlen(chunk.name) + 1); - lengthOfMaterials += (1 + strlen(chunk.name)); - numberOfMaterials += 1; - - mxml_node_t *setnode; - setnode = mxmlFindElement(subnode, subnode, "colors", NULL, NULL, MXML_DESCEND); - if (setnode != NULL) - { - mxml_node_t *valnode; - int colorNumber = 0; - for (valnode=mxmlFindElement(setnode, setnode, "forecolor", NULL, NULL, MXML_DESCEND) ; valnode != NULL ; valnode=mxmlFindElement(valnode, setnode, "forecolor", NULL, NULL, MXML_DESCEND) ) - { - char tempCoord[256]; - get_value(valnode, tempCoord, 256); - - chunk.forecolor[colorNumber] = strtol(tempCoord, NULL, 10); - chunk.forecolor[colorNumber] = short_swap_bytes(chunk.forecolor[colorNumber]); - - colorNumber+=1; - } - colorNumber = 0; - for (valnode=mxmlFindElement(setnode, setnode, "backcolor", NULL, NULL, MXML_DESCEND) ; valnode != NULL ; valnode=mxmlFindElement(valnode, setnode, "backcolor", NULL, NULL, MXML_DESCEND) ) - { - char tempCoord[256]; - get_value(valnode, tempCoord, 256); - - chunk.backcolor[colorNumber] = strtol(tempCoord, NULL, 10); - chunk.backcolor[colorNumber] = short_swap_bytes(chunk.backcolor[colorNumber]); - - colorNumber+=1; - } - colorNumber = 0; - 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.colorReg3[colorNumber] = strtol(tempCoord, NULL, 10); - chunk.colorReg3[colorNumber] = short_swap_bytes(chunk.colorReg3[colorNumber]); - - colorNumber+=1; - } - colorNumber = 0; - for (valnode=mxmlFindElement(setnode, setnode, "tev_k", NULL, NULL, MXML_DESCEND) ; valnode != NULL ; valnode=mxmlFindElement(valnode, setnode, "tev_k", NULL, NULL, MXML_DESCEND) ) - { - char tempCoord[256]; - get_value(valnode, tempCoord, 256); - chunk.tev_kcolor[colorNumber] = be32(strtoul(tempCoord, NULL, 16)); - colorNumber+=1; - } - } + u32 startOfChunk = *fileOffset; + + char lyt1[4] = {'l', 'y', 't', '1'}; + char txl1[4] = {'t', 'x', 'l', '1'}; + char fnl1[4] = {'f', 'n', 'l', '1'}; + char mat1[4] = {'m', 'a', 't', '1'}; + char pan1[4] = {'p', 'a', 'n', '1'}; + char wnd1[4] = {'w', 'n', 'd', '1'}; + char bnd1[4] = {'b', 'n', 'd', '1'}; + char pic1[4] = {'p', 'i', 'c', '1'}; + char txt1[4] = {'t', 'x', 't', '1'}; + char grp1[4] = {'g', 'r', 'p', '1'}; + char grs1[4] = {'g', 'r', 's', '1'}; + char gre1[4] = {'g', 'r', 'e', '1'}; + char pas1[4] = {'p', 'a', 's', '1'}; + char pae1[4] = {'p', 'a', 'e', '1'}; + + if ( memcmp(temp, lyt1, sizeof(lyt1)) == 0) + { + brlyt_lytheader_chunk lytheader; + + mxml_node_t *subnode = mxmlFindElement(node , node , "drawnFromMiddle", NULL, NULL, MXML_DESCEND); + if (subnode != NULL) + { + char tempChar[4]; + get_value(subnode, tempChar, 256); + 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); + if (subnode != NULL) + { + mxml_node_t *valnode = mxmlFindElement(subnode , subnode , "width", NULL, NULL, MXML_DESCEND); + if (valnode != NULL) + { + char tempChar[4]; + get_value(valnode, tempChar, 256); + *(float*)(&(lytheader.width)) = atof(tempChar); + } + valnode = mxmlFindElement(subnode , subnode ,"height", NULL, NULL, MXML_DESCEND); + if (valnode != NULL) + { + char tempChar[4]; + get_value(valnode, tempChar, 256); + + *(float*)(&(lytheader.height)) = atof(tempChar); + } + } + lytheader.pad[0] = 0; lytheader.pad[1] = 0; lytheader.pad[2] = 0; + lytheader.width = float_swap_bytes(lytheader.width); + lytheader.height = float_swap_bytes(lytheader.height); + fwrite(&lytheader, sizeof(brlyt_header), 1, fp); + *fileOffset = *fileOffset + sizeof(lytheader); + } + if ( memcmp(temp, txl1, sizeof(txl1)) == 0) + { + int numoffsOffset = ftell(fp); + + brlyt_numoffs_chunk chunk; + chunk.num = 0; + chunk.offs = 0; + fwrite(&chunk, sizeof(chunk), 1, fp); + *fileOffset = *fileOffset + sizeof(chunk); + + char *names; + names = malloc(sizeof(names)); + int lengthOfNames = 0; + mxml_node_t *subnode = mxmlFindElement(node, node, "entries", NULL, NULL, MXML_DESCEND); + if (subnode != NULL) + { + int numEntries = 0; + + int oldNameLength; + int baseOffset = 0; + + u32 *offsunks; + + offsunks = malloc(sizeof(u32)); + + brlyt_offsunk_chunk chunk2; + mxml_node_t *valnode; + for(valnode = mxmlFindElement(subnode, subnode, "name", NULL, NULL, MXML_DESCEND); valnode != NULL; valnode = mxmlFindElement(valnode, subnode, "name", NULL, NULL, MXML_DESCEND)) { + if (valnode != NULL) + { + char tempSub[256]; + get_value(valnode, tempSub, 256); + + oldNameLength = lengthOfNames; + lengthOfNames += strlen(tempSub); + + offsunks = realloc(offsunks, (numEntries + 1)*(2 * sizeof(u32))); + if (offsunks == NULL) printf("NULLed by a realloc\n"); + + offsunks[(numEntries*2)+0] = baseOffset; + offsunks[(numEntries*2)+1] = 0; + + *fileOffset = *fileOffset + sizeof(chunk2); + numEntries++; + + baseOffset += (strlen(tempSub) + 1); + + names = realloc(names, 1 + sizeof(char) * lengthOfNames); + strcpy(&names[oldNameLength], tempSub); + char nuller = '\0'; + memcpy(&names[lengthOfNames], &nuller, sizeof(char)); + lengthOfNames += 1; + } + } + chunk.num = short_swap_bytes(numEntries); + chunk.offs = 0; + fseek(fp, numoffsOffset, SEEK_SET); + fwrite(&chunk, sizeof(chunk), 1, fp); + + int i; + for(i=0;i 0) + { + u8 toAdd = 4-(*fileOffset % 4); + char nuller[3] = {'\0', '\0', '\0'}; + fwrite(&nuller, sizeof(char), toAdd, fp); + *fileOffset = *fileOffset + toAdd; + } + textures = malloc(lengthOfNames * sizeof(char)); + memcpy(textures, names, lengthOfNames * sizeof(char)); + free(names); + } + if ( memcmp(temp, fnl1, sizeof(fnl1)) == 0) + { + brlyt_numoffs_chunk chunk; + chunk.num = 0; + chunk.offs = 0; + fwrite(&chunk, sizeof(chunk), 1, fp); + *fileOffset = *fileOffset + sizeof(chunk); + + char *names; + names = malloc(sizeof(char)); + int lengthOfNames = 0; + mxml_node_t *subnode = mxmlFindElement(node, node, "entries", NULL, NULL, MXML_DESCEND); + if (subnode != NULL) + { + int numEntries = 0; + + int oldNameLength; + int baseOffset = 0; + int numoffsOffset = *fileOffset - 4; + + u32 *offsunks; + offsunks = malloc(sizeof(u32)); + + brlyt_offsunk_chunk chunk2; + mxml_node_t *valnode; + for(valnode = mxmlFindElement(subnode, subnode, "name", NULL, NULL, MXML_DESCEND); valnode != NULL; valnode = mxmlFindElement(valnode, subnode, "name", NULL, NULL, MXML_DESCEND)) { + if (valnode != NULL) + { + char tempSub[256]; + get_value(valnode, tempSub, 256); + + oldNameLength = lengthOfNames; + lengthOfNames += strlen(tempSub); + + offsunks = realloc(offsunks, (numEntries + 1)*(2 * sizeof(u32))); + offsunks[(numEntries*2)+0] = baseOffset; + offsunks[(numEntries*2)+1] = 0; + + *fileOffset = *fileOffset + sizeof(chunk2); + numEntries++; + + baseOffset += (strlen(tempSub) + 1); + names = realloc(names, 1 + sizeof(char) * lengthOfNames); + memcpy(&names[oldNameLength], tempSub, strlen(tempSub)); + char nuller = '\0'; + memcpy(&names[lengthOfNames], &nuller, sizeof(char)); + lengthOfNames += 1; + } + } + chunk.num = short_swap_bytes(numEntries); + chunk.offs = 0; + fseek(fp, numoffsOffset, SEEK_SET); + fwrite(&chunk, sizeof(chunk), 1, fp); + + int i; + for(i=0;i 0) + { + u8 toAdd = 4-(*fileOffset % 4); + char nuller[3] = {'\0', '\0', '\0'}; + fwrite(&nuller, sizeof(char), toAdd, fp); + *fileOffset = *fileOffset + toAdd; + } + free(names); + } + if ( memcmp(temp, mat1, sizeof(mat1)) == 0) + { + int numberOfEntries = 0; + int actualNumber = 0; + brlyt_numoffs_chunk numchunk; + brlyt_material_chunk chunk; + mxml_node_t *subnode; + for(subnode=mxmlFindElement(node, node, "entries", NULL, NULL, MXML_DESCEND);subnode!=NULL;subnode=mxmlFindElement(subnode, node, "entries", NULL, NULL, MXML_DESCEND)) + numberOfEntries++; + + numchunk.num = short_swap_bytes(numberOfEntries); + numchunk.offs = 0; + fwrite(&numchunk, sizeof(numchunk), 1, fp); + *fileOffset = *fileOffset + sizeof(numchunk); + + int *offsets = calloc(numberOfEntries, sizeof(int)); + int offsetsOffset = ftell(fp); + int materialOffset = 0; + actualNumber = numberOfEntries; + numberOfEntries = 0; + int matSize = 0; + int initialOffset = sizeof(numchunk) + 8 + (actualNumber * sizeof(int)); + + offsets[numberOfEntries] = be32(matSize + initialOffset); + fwrite(&offsets[0], sizeof(int), actualNumber, fp); + *fileOffset = *fileOffset + (actualNumber * 4); + + for(subnode=mxmlFindElement(node,node,"entries",NULL,NULL,MXML_DESCEND);subnode!=NULL;subnode=mxmlFindElement(subnode,node,"entries",NULL,NULL,MXML_DESCEND)) + { + numberOfEntries += 1; + char temp[256]; + if(mxmlElementGetAttr(subnode, "name") != NULL) + strcpy(temp, mxmlElementGetAttr(subnode, "name")); + else{ + printf("No name attribute found!\nQuitting!\n"); + exit(1); + } + memset(chunk.name, 0, 20); + strcpy(chunk.name, temp); + + materials = realloc(materials, lengthOfMaterials + strlen(chunk.name) + 1); + memcpy(&materials[lengthOfMaterials], chunk.name, strlen(chunk.name) + 1); + lengthOfMaterials += (1 + strlen(chunk.name)); + numberOfMaterials += 1; + + mxml_node_t *setnode; + setnode = mxmlFindElement(subnode, subnode, "colors", NULL, NULL, MXML_DESCEND); + if (setnode != NULL) + { + mxml_node_t *valnode; + int colorNumber = 0; + for (valnode=mxmlFindElement(setnode, setnode, "forecolor", NULL, NULL, MXML_DESCEND) ; valnode != NULL ; valnode=mxmlFindElement(valnode, setnode, "forecolor", NULL, NULL, MXML_DESCEND) ) + { + char tempCoord[256]; + get_value(valnode, tempCoord, 256); + + chunk.forecolor[colorNumber] = strtol(tempCoord, NULL, 10); + chunk.forecolor[colorNumber] = short_swap_bytes(chunk.forecolor[colorNumber]); + + colorNumber+=1; + } + colorNumber = 0; + for (valnode=mxmlFindElement(setnode, setnode, "backcolor", NULL, NULL, MXML_DESCEND) ; valnode != NULL ; valnode=mxmlFindElement(valnode, setnode, "backcolor", NULL, NULL, MXML_DESCEND) ) + { + char tempCoord[256]; + get_value(valnode, tempCoord, 256); + + chunk.backcolor[colorNumber] = strtol(tempCoord, NULL, 10); + chunk.backcolor[colorNumber] = short_swap_bytes(chunk.backcolor[colorNumber]); + + colorNumber+=1; + } + colorNumber = 0; + 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.colorReg3[colorNumber] = strtol(tempCoord, NULL, 10); + chunk.colorReg3[colorNumber] = short_swap_bytes(chunk.colorReg3[colorNumber]); + + colorNumber+=1; + } + colorNumber = 0; + for (valnode=mxmlFindElement(setnode, setnode, "tev_k", NULL, NULL, MXML_DESCEND) ; valnode != NULL ; valnode=mxmlFindElement(valnode, setnode, "tev_k", NULL, NULL, MXML_DESCEND) ) + { + char tempCoord[256]; + get_value(valnode, tempCoord, 256); + chunk.tev_kcolor[colorNumber] = be32(strtoul(tempCoord, NULL, 16)); + colorNumber+=1; + } + } /* - setnode = mxmlFindElement(subnode,subnode,"flags",NULL,NULL,MXML_DESCEND); - if (setnode != NULL) - { - char tempCoord[256]; - get_value(setnode, tempCoord, 256); - chunk.flags = be32(strtoul(tempCoord, NULL, 16)); - } + setnode = mxmlFindElement(subnode,subnode,"flags",NULL,NULL,MXML_DESCEND); + if (setnode != NULL) + { + char tempCoord[256]; + get_value(setnode, tempCoord, 256); + chunk.flags = be32(strtoul(tempCoord, NULL, 16)); + } */ u32 tempFileOffset = ftell(fp); @@ -1644,24 +1653,24 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl flags.flags = 0; chunk.flags = 0; - fwrite(&chunk, sizeof(chunk), 1, fp); - *fileOffset = *fileOffset + sizeof(chunk); - matSize += sizeof(chunk); - - brlyt_texref_chunk chunkTexRef; - for(setnode = mxmlFindElement(subnode, subnode, "texture", NULL, NULL, MXML_DESCEND); setnode != NULL; setnode = mxmlFindElement(setnode, subnode, "texture", NULL, NULL, MXML_DESCEND)) - { - mxml_node_t *valnode; - char temp[256]; - if(mxmlElementGetAttr(setnode, "name") != NULL) - strcpy(temp, mxmlElementGetAttr(setnode, "name")); - else{ - printf("No name attribute found!\nQuitting!\n"); - exit(1); - } - chunkTexRef.tex_offs = short_swap_bytes(findTexOffset(temp)); - - valnode=mxmlFindElement(setnode, setnode, "wrap_s", NULL, NULL, MXML_DESCEND); + fwrite(&chunk, sizeof(chunk), 1, fp); + *fileOffset = *fileOffset + sizeof(chunk); + matSize += sizeof(chunk); + + brlyt_texref_chunk chunkTexRef; + for(setnode = mxmlFindElement(subnode, subnode, "texture", NULL, NULL, MXML_DESCEND); setnode != NULL; setnode = mxmlFindElement(setnode, subnode, "texture", NULL, NULL, MXML_DESCEND)) + { + mxml_node_t *valnode; + char temp[256]; + if(mxmlElementGetAttr(setnode, "name") != NULL) + strcpy(temp, mxmlElementGetAttr(setnode, "name")); + else{ + printf("No name attribute found!\nQuitting!\n"); + exit(1); + } + chunkTexRef.tex_offs = short_swap_bytes(findTexOffset(temp)); + + valnode=mxmlFindElement(setnode, setnode, "wrap_s", NULL, NULL, MXML_DESCEND); char wraps[4][20]; int l; @@ -1672,8 +1681,8 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl strcpy( wraps[2] , "GX_MIRROR" ); strcpy( wraps[3] , "GX_MAXTEXWRAPMODE" ); - char tempCoord[256]; - get_value(valnode, tempCoord, 256); + char tempCoord[256]; + get_value(valnode, tempCoord, 256); chunkTexRef.wrap_s = strtoul(tempCoord, NULL, 16); for ( l = 0 ; l < 4 ; l++ ) { if ( strncmp( wraps[l] , tempCoord , 17 ) == 0 ) { @@ -1682,9 +1691,9 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl } } - valnode=mxmlFindElement(setnode, setnode, "wrap_t", NULL, NULL, MXML_DESCEND); + valnode=mxmlFindElement(setnode, setnode, "wrap_t", NULL, NULL, MXML_DESCEND); - get_value(valnode, tempCoord, 256); + get_value(valnode, tempCoord, 256); chunkTexRef.wrap_t = strtoul(tempCoord, NULL, 16); for ( l = 0 ; l < 4 ; l++ ) { if ( strncmp( wraps[l] , tempCoord , 17 ) == 0 ) { @@ -1695,47 +1704,47 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl flags.flag.Texture++; - fwrite(&chunkTexRef, sizeof(chunkTexRef), 1, fp); - *fileOffset = *fileOffset + sizeof(chunkTexRef); - matSize += sizeof(chunkTexRef); - } - - 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, "XTrans", NULL, NULL, MXML_DESCEND); + fwrite(&chunkTexRef, sizeof(chunkTexRef), 1, fp); + *fileOffset = *fileOffset + sizeof(chunkTexRef); + matSize += sizeof(chunkTexRef); + } + + 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, "XTrans", NULL, NULL, MXML_DESCEND); memset(tempCoord, 0, 256); - get_value(valnode, tempCoord, 256); - chunkTexCoords.XTrans = float_swap_bytes(atof(tempCoord)); - valnode=mxmlFindElement(setnode, setnode, "YTrans", NULL, NULL, MXML_DESCEND); + get_value(valnode, tempCoord, 256); + 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.YTrans = float_swap_bytes(atof(tempCoord)); - valnode=mxmlFindElement(setnode, setnode, "Rotate", NULL, NULL, MXML_DESCEND); + get_value(valnode, tempCoord, 256); + 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.Rotate = float_swap_bytes(atof(tempCoord)); - valnode=mxmlFindElement(setnode, setnode, "XScale", NULL, NULL, MXML_DESCEND); + get_value(valnode, tempCoord, 256); + 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.XScale = float_swap_bytes(atof(tempCoord)); - valnode=mxmlFindElement(setnode, setnode, "YScale", NULL, NULL, MXML_DESCEND); + get_value(valnode, tempCoord, 256); + 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.YScale = float_swap_bytes(atof(tempCoord)); + get_value(valnode, tempCoord, 256); + chunkTexCoords.YScale = float_swap_bytes(atof(tempCoord)); flags.flag.TexSRT++; - fwrite(&chunkTexCoords, sizeof(chunkTexCoords), 1, fp); - *fileOffset = *fileOffset + sizeof(chunkTexCoords); - matSize += sizeof(chunkTexCoords); - } + fwrite(&chunkTexCoords, sizeof(chunkTexCoords), 1, fp); + *fileOffset = *fileOffset + sizeof(chunkTexCoords); + matSize += sizeof(chunkTexCoords); + } - 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)) - { + 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++ ) @@ -1823,7 +1832,7 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl strcpy( mtxsrc[40] , "GX_DTTMTX19" ); strcpy( mtxsrc[41] , "GX_DTTIDENTITY" ); // actually 125 not 124 - mxml_node_t *valnode; + mxml_node_t *valnode; char tempCoord[256]; valnode=mxmlFindElement(setnode, setnode, "tgen_type", NULL, NULL, MXML_DESCEND); @@ -1869,14 +1878,14 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl flags.flag.TexCoord++; - fwrite(&chunkUa3, sizeof(chunkUa3), 1, fp); - *fileOffset = *fileOffset + sizeof(chunkUa3); - matSize += sizeof(chunkUa3); - } + fwrite(&chunkUa3, sizeof(chunkUa3), 1, fp); + *fileOffset = *fileOffset + sizeof(chunkUa3); + matSize += sizeof(chunkUa3); + } - 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)) - { + 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++ ) @@ -1884,7 +1893,7 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl strcpy( matsrc[0] , "GX_SRC_REG" ); strcpy( matsrc[1] , "GX_SRC_VTX" ); - mxml_node_t *valnode; + mxml_node_t *valnode; char tempCoord[256]; valnode=mxmlFindElement(setnode, setnode, "ColorMatSource", NULL, NULL, MXML_DESCEND); @@ -1925,15 +1934,15 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl flags.flag.ua4++; - fwrite(&chunkUa4, sizeof(chunkUa4), 1, fp); - *fileOffset = *fileOffset + sizeof(chunkUa4); - matSize += sizeof(chunkUa4); - } + fwrite(&chunkUa4, sizeof(chunkUa4), 1, fp); + *fileOffset = *fileOffset + sizeof(chunkUa4); + matSize += sizeof(chunkUa4); + } - 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; + 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; char tempCoord[256]; valnode=mxmlFindElement(setnode, setnode, "red", NULL, NULL, MXML_DESCEND); @@ -1958,13 +1967,13 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl flags.flag.ua5++; - fwrite(&chunkUa5, sizeof(chunkUa5), 1, fp); - *fileOffset = *fileOffset + sizeof(chunkUa5); - matSize += sizeof(chunkUa5); - } - 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)) - { + fwrite(&chunkUa5, sizeof(chunkUa5), 1, fp); + *fileOffset = *fileOffset + sizeof(chunkUa5); + matSize += sizeof(chunkUa5); + } + 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++ ) @@ -1974,7 +1983,7 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl strcpy( tevcolor[2] , "GX_CH_BLUE" ); strcpy( tevcolor[3] , "GX_CH_ALPHA" ); - mxml_node_t *valnode; + mxml_node_t *valnode; char tempCoord[256]; valnode=mxmlFindElement(setnode, setnode, "OneRed", NULL, NULL, MXML_DESCEND); @@ -2163,60 +2172,60 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl flags.flag.ua6++; - fwrite(&chunkUa6, sizeof(chunkUa6), 1, fp); - *fileOffset = *fileOffset + sizeof(chunkUa6); - matSize += sizeof(chunkUa6); - } - - 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, "XTrans", NULL, NULL, MXML_DESCEND); - if ( valnode != NULL ) - { - char tempCoord[256]; - get_value(valnode, tempCoord, 256); - chunkUa7.XTrans = float_swap_bytes(atof(tempCoord)); - } - valnode=mxmlFindElement(setnode, setnode, "YTrans", NULL, NULL, MXML_DESCEND); - if ( valnode != NULL ) - { - char tempCoord[256]; - get_value(valnode, tempCoord, 256); - chunkUa7.YTrans = float_swap_bytes(atof(tempCoord)); - } - valnode=mxmlFindElement(setnode, setnode, "Rotate", NULL, NULL, MXML_DESCEND); - if ( valnode != NULL ) - { - char tempCoord[256]; - get_value(valnode, tempCoord, 256); - chunkUa7.Rotate = float_swap_bytes(atof(tempCoord)); - } - valnode=mxmlFindElement(setnode, setnode, "XScale", NULL, NULL, MXML_DESCEND); - if ( valnode != NULL ) - { - char tempCoord[256]; - get_value(valnode, tempCoord, 256); - chunkUa7.XScale = float_swap_bytes(atof(tempCoord)); - } - valnode=mxmlFindElement(setnode, setnode, "YScale", NULL, NULL, MXML_DESCEND); - if ( valnode != NULL ) - { - char tempCoord[256]; - get_value(valnode, tempCoord, 256); - chunkUa7.YScale = float_swap_bytes(atof(tempCoord)); - } + fwrite(&chunkUa6, sizeof(chunkUa6), 1, fp); + *fileOffset = *fileOffset + sizeof(chunkUa6); + matSize += sizeof(chunkUa6); + } + + 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, "XTrans", NULL, NULL, MXML_DESCEND); + if ( valnode != NULL ) + { + char tempCoord[256]; + get_value(valnode, tempCoord, 256); + chunkUa7.XTrans = float_swap_bytes(atof(tempCoord)); + } + valnode=mxmlFindElement(setnode, setnode, "YTrans", NULL, NULL, MXML_DESCEND); + if ( valnode != NULL ) + { + char tempCoord[256]; + get_value(valnode, tempCoord, 256); + chunkUa7.YTrans = float_swap_bytes(atof(tempCoord)); + } + valnode=mxmlFindElement(setnode, setnode, "Rotate", NULL, NULL, MXML_DESCEND); + if ( valnode != NULL ) + { + char tempCoord[256]; + get_value(valnode, tempCoord, 256); + chunkUa7.Rotate = float_swap_bytes(atof(tempCoord)); + } + valnode=mxmlFindElement(setnode, setnode, "XScale", NULL, NULL, MXML_DESCEND); + if ( valnode != NULL ) + { + char tempCoord[256]; + get_value(valnode, tempCoord, 256); + chunkUa7.XScale = float_swap_bytes(atof(tempCoord)); + } + valnode=mxmlFindElement(setnode, setnode, "YScale", NULL, NULL, MXML_DESCEND); + if ( valnode != NULL ) + { + char tempCoord[256]; + get_value(valnode, tempCoord, 256); + chunkUa7.YScale = float_swap_bytes(atof(tempCoord)); + } flags.flag.ua7++; - fwrite(&chunkUa7, sizeof(chunkUa7), 1, fp); - *fileOffset = *fileOffset + sizeof(chunkUa7); - matSize += sizeof(chunkUa7); - } - 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)) - { + fwrite(&chunkUa7, sizeof(chunkUa7), 1, fp); + *fileOffset = *fileOffset + sizeof(chunkUa7); + matSize += sizeof(chunkUa7); + } + 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++ ) @@ -2232,7 +2241,7 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl strcpy( scale[8] , "GX_ITS_256" ); strcpy( scale[9] , "GX_MAX_ITSCALE" ); - mxml_node_t *valnode; + mxml_node_t *valnode; char tempCoord[256]; valnode=mxmlFindElement(setnode, setnode, "TextureCoordinate", NULL, NULL, MXML_DESCEND); @@ -2269,15 +2278,15 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl flags.flag.ua8++; - fwrite(&chunkUa8, sizeof(chunkUa8), 1, fp); - *fileOffset = *fileOffset + sizeof(chunkUa8); - matSize += sizeof(chunkUa8); - } + fwrite(&chunkUa8, sizeof(chunkUa8), 1, fp); + *fileOffset = *fileOffset + sizeof(chunkUa8); + matSize += sizeof(chunkUa8); + } 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; + 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; char tempCoord[256]; valnode=mxmlFindElement(setnode, setnode, "TextureCoordinate", NULL, NULL, MXML_DESCEND); @@ -2478,14 +2487,14 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl flags.flag.ua9++; - fwrite(&chunkUa9, sizeof(chunkUa9), 1, fp); - *fileOffset = *fileOffset + sizeof(chunkUa9); - matSize += sizeof(chunkUa9); - } + fwrite(&chunkUa9, sizeof(chunkUa9), 1, fp); + *fileOffset = *fileOffset + sizeof(chunkUa9); + matSize += sizeof(chunkUa9); + } - 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)) - { + 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++ ) @@ -2508,7 +2517,7 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl strcpy( aop[3] , "GX_AOP_XNOR" ); strcpy( aop[4] , "GX_MAX_ALPHAOP" ); - mxml_node_t *valnode; + mxml_node_t *valnode; char tempCoord[256]; valnode=mxmlFindElement(setnode, setnode, "comp0", NULL, NULL, MXML_DESCEND); @@ -2556,14 +2565,14 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl flags.flag.uaa++; - fwrite(&chunkUaa, sizeof(chunkUaa), 1, fp); - *fileOffset = *fileOffset + sizeof(chunkUaa); - matSize += sizeof(chunkUaa); - } + fwrite(&chunkUaa, sizeof(chunkUaa), 1, fp); + *fileOffset = *fileOffset + sizeof(chunkUaa); + matSize += sizeof(chunkUaa); + } - 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)) - { + 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++ ) @@ -2606,7 +2615,7 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl strcpy( logicop[14] , "GX_LO_NAND" ); strcpy( logicop[15] , "GX_LO_SET" ); - mxml_node_t *valnode; + mxml_node_t *valnode; char tempCoord[256]; valnode=mxmlFindElement(setnode, setnode, "type", NULL, NULL, MXML_DESCEND); @@ -2655,161 +2664,161 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl flags.flag.uab++; - fwrite(&chunkUab, sizeof(chunkUab), 1, fp); - *fileOffset = *fileOffset + sizeof(chunkUab); - matSize += sizeof(chunkUab); - } + 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); + fwrite(&chunk, sizeof(chunk), 1, fp); fseek( fp , end , SEEK_SET ); - if (numberOfEntries < actualNumber) - { - offsets[numberOfEntries] = be32(matSize + initialOffset); - materialOffset = ftell(fp); - fseek(fp, offsetsOffset+(numberOfEntries * sizeof(int)), SEEK_SET); - fwrite(&offsets[numberOfEntries], sizeof(int), 1, fp); - fseek(fp, materialOffset, SEEK_SET); - initialOffset += matSize; - matSize = 0; - } - } - free(offsets); - } - if ( memcmp(temp, pan1, sizeof(pan1)) == 0) - { - brlyt_pane_chunk chunk; - char temp[256]; - if(mxmlElementGetAttr(node, "name") != NULL) - strcpy(temp, mxmlElementGetAttr(node, "name")); - else{ - printf("No name attribute found!\nQuitting!\n"); - exit(1); - } - memset(chunk.name, 0, 24); - strcpy(chunk.name, temp); - - mxml_node_t *subnode = mxmlFindElement(node, node, "translate", NULL, NULL, MXML_DESCEND); - if (subnode != NULL) - { - mxml_node_t *valnode; - valnode = mxmlFindElement(subnode, subnode, "x", NULL, NULL, MXML_DESCEND); - if (valnode != NULL) - { - char tempCoord[256]; - get_value(valnode, tempCoord, 256); - 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.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.ZTrans = float_swap_bytes(atof(tempCoord)); - } - } - subnode = mxmlFindElement(node, node, "rotate", NULL, NULL, MXML_DESCEND); - if (subnode != NULL) - { - mxml_node_t *valnode; - valnode = mxmlFindElement(subnode, subnode, "x", NULL, NULL, MXML_DESCEND); - if (valnode != NULL) - { - char tempCoord[256]; - get_value(valnode, tempCoord, 256); - 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.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, "scale", NULL, NULL, MXML_DESCEND); - if (subnode != NULL) - { - mxml_node_t *valnode; - valnode = mxmlFindElement(subnode, subnode, "x", NULL, NULL, MXML_DESCEND); - if (valnode != NULL) - { - char tempCoord[256]; - get_value(valnode, tempCoord, 256); - 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.YScale = float_swap_bytes(atof(tempCoord)); - } - } - subnode = mxmlFindElement(node, node, "size", NULL, NULL, MXML_DESCEND); - if (subnode != NULL) - { - mxml_node_t *valnode; - valnode = mxmlFindElement(subnode, subnode, "width", NULL, NULL, MXML_DESCEND); - if (valnode != NULL) - { - char tempCoord[256]; - get_value(valnode, tempCoord, 256); - chunk.width = float_swap_bytes(atof(tempCoord)); - } - valnode = mxmlFindElement(subnode, subnode, "height", NULL, NULL, MXML_DESCEND); - if (valnode != NULL) - { - char tempCoord[256]; - get_value(valnode, tempCoord, 256); - chunk.height = float_swap_bytes(atof(tempCoord)); - } - } - + if (numberOfEntries < actualNumber) + { + offsets[numberOfEntries] = be32(matSize + initialOffset); + materialOffset = ftell(fp); + fseek(fp, offsetsOffset+(numberOfEntries * sizeof(int)), SEEK_SET); + fwrite(&offsets[numberOfEntries], sizeof(int), 1, fp); + fseek(fp, materialOffset, SEEK_SET); + initialOffset += matSize; + matSize = 0; + } + } + free(offsets); + } + if ( memcmp(temp, pan1, sizeof(pan1)) == 0) + { + brlyt_pane_chunk chunk; + char temp[256]; + if(mxmlElementGetAttr(node, "name") != NULL) + strcpy(temp, mxmlElementGetAttr(node, "name")); + else{ + printf("No name attribute found!\nQuitting!\n"); + exit(1); + } + memset(chunk.name, 0, 24); + strcpy(chunk.name, temp); + + mxml_node_t *subnode = mxmlFindElement(node, node, "translate", NULL, NULL, MXML_DESCEND); + if (subnode != NULL) + { + mxml_node_t *valnode; + valnode = mxmlFindElement(subnode, subnode, "x", NULL, NULL, MXML_DESCEND); + if (valnode != NULL) + { + char tempCoord[256]; + get_value(valnode, tempCoord, 256); + 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.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.ZTrans = float_swap_bytes(atof(tempCoord)); + } + } + subnode = mxmlFindElement(node, node, "rotate", NULL, NULL, MXML_DESCEND); + if (subnode != NULL) + { + mxml_node_t *valnode; + valnode = mxmlFindElement(subnode, subnode, "x", NULL, NULL, MXML_DESCEND); + if (valnode != NULL) + { + char tempCoord[256]; + get_value(valnode, tempCoord, 256); + 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.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, "scale", NULL, NULL, MXML_DESCEND); + if (subnode != NULL) + { + mxml_node_t *valnode; + valnode = mxmlFindElement(subnode, subnode, "x", NULL, NULL, MXML_DESCEND); + if (valnode != NULL) + { + char tempCoord[256]; + get_value(valnode, tempCoord, 256); + 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.YScale = float_swap_bytes(atof(tempCoord)); + } + } + subnode = mxmlFindElement(node, node, "size", NULL, NULL, MXML_DESCEND); + if (subnode != NULL) + { + mxml_node_t *valnode; + valnode = mxmlFindElement(subnode, subnode, "width", NULL, NULL, MXML_DESCEND); + if (valnode != NULL) + { + char tempCoord[256]; + get_value(valnode, tempCoord, 256); + chunk.width = float_swap_bytes(atof(tempCoord)); + } + valnode = mxmlFindElement(subnode, subnode, "height", NULL, NULL, MXML_DESCEND); + if (valnode != NULL) + { + char tempCoord[256]; + get_value(valnode, tempCoord, 256); + chunk.height = float_swap_bytes(atof(tempCoord)); + } + } + 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 ); - } + 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) - { + 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" ); @@ -2822,9 +2831,9 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl strcpy( origins[7] , "BOTTOM CENTER" ); strcpy( origins[8] , "BOTTOM RIGHT" ); - char tempCoord[256]; - get_value(subnode, tempCoord, 256); - chunk.origin = strtol(tempCoord, NULL, 16); + 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 ) { @@ -2832,154 +2841,154 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl break; } } - } - subnode = mxmlFindElement(node, node, "alpha", NULL, NULL, MXML_DESCEND); - if (subnode != NULL) - { - char tempCoord[256]; - get_value(subnode, tempCoord, 256); - chunk.alpha = strtol(tempCoord, NULL, 16); - } - subnode = mxmlFindElement(node, node, "padding", NULL, NULL, MXML_DESCEND); - if (subnode != NULL) - { - char tempCoord[256]; - get_value(subnode, tempCoord, 256); - chunk.pad = strtol(tempCoord, NULL, 16); - } - fwrite(&chunk, sizeof(chunk), 1, fp); - *fileOffset = *fileOffset + sizeof(chunk); - } - if ( memcmp(temp, bnd1, sizeof(bnd1)) == 0) - { - brlyt_pane_chunk chunk; - char temp[256]; - if(mxmlElementGetAttr(node, "name") != NULL) - strcpy(temp, mxmlElementGetAttr(node, "name")); - else{ - printf("No name attribute found!\nQuitting!\n"); - exit(1); - } - memset(chunk.name, 0, 24 * sizeof(char)); - strcpy(chunk.name, temp); - - mxml_node_t *subnode = mxmlFindElement(node, node, "translate", NULL, NULL, MXML_DESCEND); - if (subnode != NULL) - { - mxml_node_t *valnode; - valnode = mxmlFindElement(subnode, subnode, "x", NULL, NULL, MXML_DESCEND); - if (valnode != NULL) - { - char tempCoord[256]; - get_value(valnode, tempCoord, 256); - 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.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.ZTrans = float_swap_bytes(atof(tempCoord)); - } - } - subnode = mxmlFindElement(node, node, "rotate", NULL, NULL, MXML_DESCEND); - if (subnode != NULL) - { - mxml_node_t *valnode; - valnode = mxmlFindElement(subnode, subnode, "x", NULL, NULL, MXML_DESCEND); - if (valnode != NULL) - { - char tempCoord[256]; - get_value(valnode, tempCoord, 256); - 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.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, "scale", NULL, NULL, MXML_DESCEND); - if (subnode != NULL) - { - mxml_node_t *valnode; - valnode = mxmlFindElement(subnode, subnode, "x", NULL, NULL, MXML_DESCEND); - if (valnode != NULL) - { - char tempCoord[256]; - get_value(valnode, tempCoord, 256); - 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.YScale = float_swap_bytes(atof(tempCoord)); - } - } - subnode = mxmlFindElement(node, node, "size", NULL, NULL, MXML_DESCEND); - if (subnode != NULL) - { - mxml_node_t *valnode; - valnode = mxmlFindElement(subnode, subnode, "width", NULL, NULL, MXML_DESCEND); - if (valnode != NULL) - { - char tempCoord[256]; - get_value(valnode, tempCoord, 256); - chunk.width = float_swap_bytes(atof(tempCoord)); - } - valnode = mxmlFindElement(subnode, subnode, "height", NULL, NULL, MXML_DESCEND); - if (valnode != NULL) - { - char tempCoord[256]; - get_value(valnode, tempCoord, 256); - chunk.height = float_swap_bytes(atof(tempCoord)); - } - } - + } + subnode = mxmlFindElement(node, node, "alpha", NULL, NULL, MXML_DESCEND); + if (subnode != NULL) + { + char tempCoord[256]; + get_value(subnode, tempCoord, 256); + chunk.alpha = strtol(tempCoord, NULL, 16); + } + subnode = mxmlFindElement(node, node, "padding", NULL, NULL, MXML_DESCEND); + if (subnode != NULL) + { + char tempCoord[256]; + get_value(subnode, tempCoord, 256); + chunk.pad = strtol(tempCoord, NULL, 16); + } + fwrite(&chunk, sizeof(chunk), 1, fp); + *fileOffset = *fileOffset + sizeof(chunk); + } + if ( memcmp(temp, bnd1, sizeof(bnd1)) == 0) + { + brlyt_pane_chunk chunk; + char temp[256]; + if(mxmlElementGetAttr(node, "name") != NULL) + strcpy(temp, mxmlElementGetAttr(node, "name")); + else{ + printf("No name attribute found!\nQuitting!\n"); + exit(1); + } + memset(chunk.name, 0, 24 * sizeof(char)); + strcpy(chunk.name, temp); + + mxml_node_t *subnode = mxmlFindElement(node, node, "translate", NULL, NULL, MXML_DESCEND); + if (subnode != NULL) + { + mxml_node_t *valnode; + valnode = mxmlFindElement(subnode, subnode, "x", NULL, NULL, MXML_DESCEND); + if (valnode != NULL) + { + char tempCoord[256]; + get_value(valnode, tempCoord, 256); + 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.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.ZTrans = float_swap_bytes(atof(tempCoord)); + } + } + subnode = mxmlFindElement(node, node, "rotate", NULL, NULL, MXML_DESCEND); + if (subnode != NULL) + { + mxml_node_t *valnode; + valnode = mxmlFindElement(subnode, subnode, "x", NULL, NULL, MXML_DESCEND); + if (valnode != NULL) + { + char tempCoord[256]; + get_value(valnode, tempCoord, 256); + 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.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, "scale", NULL, NULL, MXML_DESCEND); + if (subnode != NULL) + { + mxml_node_t *valnode; + valnode = mxmlFindElement(subnode, subnode, "x", NULL, NULL, MXML_DESCEND); + if (valnode != NULL) + { + char tempCoord[256]; + get_value(valnode, tempCoord, 256); + 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.YScale = float_swap_bytes(atof(tempCoord)); + } + } + subnode = mxmlFindElement(node, node, "size", NULL, NULL, MXML_DESCEND); + if (subnode != NULL) + { + mxml_node_t *valnode; + valnode = mxmlFindElement(subnode, subnode, "width", NULL, NULL, MXML_DESCEND); + if (valnode != NULL) + { + char tempCoord[256]; + get_value(valnode, tempCoord, 256); + chunk.width = float_swap_bytes(atof(tempCoord)); + } + valnode = mxmlFindElement(subnode, subnode, "height", NULL, NULL, MXML_DESCEND); + if (valnode != NULL) + { + char tempCoord[256]; + get_value(valnode, tempCoord, 256); + chunk.height = float_swap_bytes(atof(tempCoord)); + } + } + 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 ); - } + 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) - { + 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" ); @@ -2992,9 +3001,9 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl strcpy( origins[7] , "BOTTOM CENTER" ); strcpy( origins[8] , "BOTTOM RIGHT" ); - char tempCoord[256]; - get_value(subnode, tempCoord, 256); - chunk.origin = strtol(tempCoord, NULL, 16); + 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 ) { @@ -3002,154 +3011,154 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl break; } } - } - subnode = mxmlFindElement(node, node, "alpha", NULL, NULL, MXML_DESCEND); - if (subnode != NULL) - { - char tempCoord[256]; - get_value(subnode, tempCoord, 256); - chunk.alpha = strtol(tempCoord, NULL, 16); - } - subnode = mxmlFindElement(node, node, "padding", NULL, NULL, MXML_DESCEND); - if (subnode != NULL) - { - char tempCoord[256]; - get_value(subnode, tempCoord, 256); - 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; - char temp[256]; - if(mxmlElementGetAttr(node, "name") != NULL) - strcpy(temp, mxmlElementGetAttr(node, "name")); - else{ - printf("No name attribute found!\nQuitting!\n"); - exit(1); - } - memset(chunk.name, 0, 24 * sizeof(char)); - strcpy(chunk.name, temp); - - mxml_node_t *subnode = mxmlFindElement(node, node, "translate", NULL, NULL, MXML_DESCEND); - if (subnode != NULL) - { - mxml_node_t *valnode; - valnode = mxmlFindElement(subnode, subnode, "x", NULL, NULL, MXML_DESCEND); - if (valnode != NULL) - { - char tempCoord[256]; - get_value(valnode, tempCoord, 256); - 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.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.ZTrans = float_swap_bytes(atof(tempCoord)); - } - } - subnode = mxmlFindElement(node, node, "rotate", NULL, NULL, MXML_DESCEND); - if (subnode != NULL) - { - mxml_node_t *valnode; - valnode = mxmlFindElement(subnode, subnode, "x", NULL, NULL, MXML_DESCEND); - if (valnode != NULL) - { - char tempCoord[256]; - get_value(valnode, tempCoord, 256); - 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.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, "scale", NULL, NULL, MXML_DESCEND); - if (subnode != NULL) - { - mxml_node_t *valnode; - valnode = mxmlFindElement(subnode, subnode, "x", NULL, NULL, MXML_DESCEND); - if (valnode != NULL) - { - char tempCoord[256]; - get_value(valnode, tempCoord, 256); - 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.YScale = float_swap_bytes(atof(tempCoord)); - } - } - subnode = mxmlFindElement(node, node, "size", NULL, NULL, MXML_DESCEND); - if (subnode != NULL) - { - mxml_node_t *valnode; - valnode = mxmlFindElement(subnode, subnode, "width", NULL, NULL, MXML_DESCEND); - if (valnode != NULL) - { - char tempCoord[256]; - get_value(valnode, tempCoord, 256); - chunk.width = float_swap_bytes(atof(tempCoord)); - } - valnode = mxmlFindElement(subnode, subnode, "height", NULL, NULL, MXML_DESCEND); - if (valnode != NULL) - { - char tempCoord[256]; - get_value(valnode, tempCoord, 256); - chunk.height = float_swap_bytes(atof(tempCoord)); - } - } - + } + subnode = mxmlFindElement(node, node, "alpha", NULL, NULL, MXML_DESCEND); + if (subnode != NULL) + { + char tempCoord[256]; + get_value(subnode, tempCoord, 256); + chunk.alpha = strtol(tempCoord, NULL, 16); + } + subnode = mxmlFindElement(node, node, "padding", NULL, NULL, MXML_DESCEND); + if (subnode != NULL) + { + char tempCoord[256]; + get_value(subnode, tempCoord, 256); + 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; + char temp[256]; + if(mxmlElementGetAttr(node, "name") != NULL) + strcpy(temp, mxmlElementGetAttr(node, "name")); + else{ + printf("No name attribute found!\nQuitting!\n"); + exit(1); + } + memset(chunk.name, 0, 24 * sizeof(char)); + strcpy(chunk.name, temp); + + mxml_node_t *subnode = mxmlFindElement(node, node, "translate", NULL, NULL, MXML_DESCEND); + if (subnode != NULL) + { + mxml_node_t *valnode; + valnode = mxmlFindElement(subnode, subnode, "x", NULL, NULL, MXML_DESCEND); + if (valnode != NULL) + { + char tempCoord[256]; + get_value(valnode, tempCoord, 256); + 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.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.ZTrans = float_swap_bytes(atof(tempCoord)); + } + } + subnode = mxmlFindElement(node, node, "rotate", NULL, NULL, MXML_DESCEND); + if (subnode != NULL) + { + mxml_node_t *valnode; + valnode = mxmlFindElement(subnode, subnode, "x", NULL, NULL, MXML_DESCEND); + if (valnode != NULL) + { + char tempCoord[256]; + get_value(valnode, tempCoord, 256); + 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.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, "scale", NULL, NULL, MXML_DESCEND); + if (subnode != NULL) + { + mxml_node_t *valnode; + valnode = mxmlFindElement(subnode, subnode, "x", NULL, NULL, MXML_DESCEND); + if (valnode != NULL) + { + char tempCoord[256]; + get_value(valnode, tempCoord, 256); + 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.YScale = float_swap_bytes(atof(tempCoord)); + } + } + subnode = mxmlFindElement(node, node, "size", NULL, NULL, MXML_DESCEND); + if (subnode != NULL) + { + mxml_node_t *valnode; + valnode = mxmlFindElement(subnode, subnode, "width", NULL, NULL, MXML_DESCEND); + if (valnode != NULL) + { + char tempCoord[256]; + get_value(valnode, tempCoord, 256); + chunk.width = float_swap_bytes(atof(tempCoord)); + } + valnode = mxmlFindElement(subnode, subnode, "height", NULL, NULL, MXML_DESCEND); + if (valnode != NULL) + { + char tempCoord[256]; + get_value(valnode, tempCoord, 256); + chunk.height = float_swap_bytes(atof(tempCoord)); + } + } + 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 ); - } + 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) - { + 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" ); @@ -3162,9 +3171,9 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl strcpy( origins[7] , "BOTTOM CENTER" ); strcpy( origins[8] , "BOTTOM RIGHT" ); - char tempCoord[256]; - get_value(subnode, tempCoord, 256); - chunk.origin = strtol(tempCoord, NULL, 16); + 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 ) { @@ -3172,304 +3181,304 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl break; } } - } - subnode = mxmlFindElement(node, node, "alpha", NULL, NULL, MXML_DESCEND); - if (subnode != NULL) - { - char tempCoord[256]; - get_value(subnode, tempCoord, 256); - chunk.alpha = strtol(tempCoord, NULL, 16); - } - subnode = mxmlFindElement(node, node, "padding", NULL, NULL, MXML_DESCEND); - if (subnode != NULL) - { - char tempCoord[256]; - get_value(subnode, tempCoord, 256); - chunk.pad = strtol(tempCoord, NULL, 16); - } - fwrite(&chunk, sizeof(chunk), 1, fp); - *fileOffset = *fileOffset + sizeof(chunk); - - int i; - brlyt_wnd wndy; - subnode = mxmlFindElement(node, node, "wnd", NULL, NULL, MXML_DESCEND); - if (subnode != NULL) - { - i = 0; - mxml_node_t *subsubnode; - 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.coords[i] = float_swap_bytes(atof(tempCoord)); - i++; - } - subsubnode = mxmlFindElement(subnode, subnode, "FrameCount", NULL, NULL, MXML_DESCEND); - if(subsubnode != NULL) - { - - char tempCoord[256]; - get_value(subsubnode, tempCoord, 256); - wndy.frame_count = (u8)(strtoul(tempCoord, NULL, 16)); - } - wndy.padding[0] = 0x0; - wndy.padding[1] = 0x0; - wndy.padding[2] = 0x0; - - subsubnode = mxmlFindElement(subnode, subnode, "offset1", NULL, NULL, MXML_DESCEND); - if(subsubnode != NULL) - { - - char tempCoord[256]; - get_value(subsubnode, tempCoord, 256); - wndy.offset1 = be32(strtoul(tempCoord, NULL, 16)); - } - subsubnode = mxmlFindElement(subnode, subnode, "offset2", NULL, NULL, MXML_DESCEND); - if(subsubnode != NULL) - { - - char tempCoord[256]; - get_value(subsubnode, tempCoord, 256); - wndy.offset2 = be32(strtoul(tempCoord, NULL, 16)); - } - fwrite(&wndy, sizeof(brlyt_wnd), 1, fp); - *fileOffset = *fileOffset + sizeof(brlyt_wnd); - } - - brlyt_wnd1 wndy1; - subnode = mxmlFindElement(node, node, "wnd1", NULL, NULL, MXML_DESCEND); - if (subnode != NULL) - { - i=0; - mxml_node_t *subsubnode; - 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.colors[i] = be32(strtoul(tempCoord, NULL, 16)); - i++; - } - subsubnode = mxmlFindElement(subnode, subnode, "material", NULL, NULL, MXML_DESCEND); - if (subnode != NULL) - { - char tempCoord[256]; - get_value(subsubnode, tempCoord, 256); - wndy1.material = short_swap_bytes(strtoul(tempCoord, NULL, 16)); - } - subsubnode = mxmlFindElement(subnode, subnode, "CoordinateCount", NULL, NULL, MXML_DESCEND); - if (subsubnode != NULL) - { - char tempCoord[256]; - get_value(subsubnode, tempCoord, 256); - wndy1.coordinate_count = short_swap_bytes(strtoul(tempCoord, NULL, 16)); - } - 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, "Coords", NULL, NULL, MXML_DESCEND); - if (subnode != NULL) - { - i=0; - mxml_node_t *subsubnode; - for(subsubnode = mxmlFindElement(subnode, subnode, "texcoord", NULL, NULL, MXML_DESCEND); subsubnode != NULL; subsubnode = mxmlFindElement(subsubnode, subnode, "texcoord", NULL, NULL, MXML_DESCEND)) - { - char tempCoord[256]; - get_value(subsubnode, tempCoord, 256); - wndy3.texcoords[i] = float_swap_bytes(atof(tempCoord)); - i++; - } - fwrite(&wndy3, sizeof(brlyt_wnd3), 1, fp); - *fileOffset = *fileOffset + sizeof(brlyt_wnd3); - } - - brlyt_wnd4 wndy4; - for(subnode = mxmlFindElement(node, node, "wnd4", NULL, NULL, MXML_DESCEND); subnode != NULL; subnode = mxmlFindElement(subnode, node, "wnd4", NULL, NULL, MXML_DESCEND)) - { - i=0; - mxml_node_t *subsubnode; - subsubnode = mxmlFindElement(subnode, subnode, "offset", NULL, NULL, MXML_DESCEND); - if (subsubnode != NULL) - { - char tempCoord[256]; - get_value(subsubnode, tempCoord, 256); - wndy4.offset = be32(strtoul(tempCoord, NULL, 16)); - i++; - } - fwrite(&wndy4, sizeof(brlyt_wnd4), 1, fp); - *fileOffset = *fileOffset + sizeof(brlyt_wnd4); - } - brlyt_wnd4_mat wndy4mat; - for(subnode = mxmlFindElement(node, node, "wnd4mat", NULL, NULL, MXML_DESCEND); subnode != NULL; subnode = mxmlFindElement(subnode, node, "wnd4mat", NULL, NULL, MXML_DESCEND)) - { - i=0; - mxml_node_t *subsubnode; - subsubnode = mxmlFindElement(subnode, subnode, "material", NULL, NULL, MXML_DESCEND); - if (subsubnode != NULL) - { - char tempCoord[256]; - get_value(subsubnode, tempCoord, 256); - 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); - } - } - if ( memcmp(temp, txt1, sizeof(txt1)) == 0) - { - brlyt_pane_chunk chunk; - brlyt_text_chunk chunk2; - char temp[256]; - if(mxmlElementGetAttr(node, "name") != NULL) - strcpy(temp, mxmlElementGetAttr(node, "name")); - else{ - printf("No name attribute found!\nQuitting!\n"); - exit(1); - } - memset(chunk.name, 0, 24 * sizeof(char)); - strcpy(chunk.name, temp); - chunk2.mat_num = short_swap_bytes(findMatOffset(temp)); - - mxml_node_t *subnode = mxmlFindElement(node, node, "translate", NULL, NULL, MXML_DESCEND); - if (subnode != NULL) - { - mxml_node_t *valnode; - valnode = mxmlFindElement(subnode, subnode, "x", NULL, NULL, MXML_DESCEND); - if (valnode != NULL) - { - char tempCoord[256]; - get_value(valnode, tempCoord, 256); - 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.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.ZTrans = float_swap_bytes(atof(tempCoord)); - } - } - subnode = mxmlFindElement(node, node, "rotate", NULL, NULL, MXML_DESCEND); - if (subnode != NULL) - { - mxml_node_t *valnode; - valnode = mxmlFindElement(subnode, subnode, "x", NULL, NULL, MXML_DESCEND); - if (valnode != NULL) - { - char tempCoord[256]; - get_value(valnode, tempCoord, 256); - 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.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, "scale", NULL, NULL, MXML_DESCEND); - if (subnode != NULL) - { - mxml_node_t *valnode; - valnode = mxmlFindElement(subnode, subnode, "x", NULL, NULL, MXML_DESCEND); - if (valnode != NULL) - { - char tempCoord[256]; - get_value(valnode, tempCoord, 256); - 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.YScale = float_swap_bytes(atof(tempCoord)); - } - } - subnode = mxmlFindElement(node, node, "size", NULL, NULL, MXML_DESCEND); - if (subnode != NULL) - { - mxml_node_t *valnode; - valnode = mxmlFindElement(subnode, subnode, "width", NULL, NULL, MXML_DESCEND); - if (valnode != NULL) - { - char tempCoord[256]; - get_value(valnode, tempCoord, 256); - chunk.width = float_swap_bytes(atof(tempCoord)); - } - valnode = mxmlFindElement(subnode, subnode, "height", NULL, NULL, MXML_DESCEND); - if (valnode != NULL) - { - char tempCoord[256]; - get_value(valnode, tempCoord, 256); - chunk.height = float_swap_bytes(atof(tempCoord)); - } - } - + } + subnode = mxmlFindElement(node, node, "alpha", NULL, NULL, MXML_DESCEND); + if (subnode != NULL) + { + char tempCoord[256]; + get_value(subnode, tempCoord, 256); + chunk.alpha = strtol(tempCoord, NULL, 16); + } + subnode = mxmlFindElement(node, node, "padding", NULL, NULL, MXML_DESCEND); + if (subnode != NULL) + { + char tempCoord[256]; + get_value(subnode, tempCoord, 256); + chunk.pad = strtol(tempCoord, NULL, 16); + } + fwrite(&chunk, sizeof(chunk), 1, fp); + *fileOffset = *fileOffset + sizeof(chunk); + + int i; + brlyt_wnd wndy; + subnode = mxmlFindElement(node, node, "wnd", NULL, NULL, MXML_DESCEND); + if (subnode != NULL) + { + i = 0; + mxml_node_t *subsubnode; + 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.coords[i] = float_swap_bytes(atof(tempCoord)); + i++; + } + subsubnode = mxmlFindElement(subnode, subnode, "FrameCount", NULL, NULL, MXML_DESCEND); + if(subsubnode != NULL) + { + + char tempCoord[256]; + get_value(subsubnode, tempCoord, 256); + wndy.frame_count = (u8)(strtoul(tempCoord, NULL, 16)); + } + wndy.padding[0] = 0x0; + wndy.padding[1] = 0x0; + wndy.padding[2] = 0x0; + + subsubnode = mxmlFindElement(subnode, subnode, "offset1", NULL, NULL, MXML_DESCEND); + if(subsubnode != NULL) + { + + char tempCoord[256]; + get_value(subsubnode, tempCoord, 256); + wndy.offset1 = be32(strtoul(tempCoord, NULL, 16)); + } + subsubnode = mxmlFindElement(subnode, subnode, "offset2", NULL, NULL, MXML_DESCEND); + if(subsubnode != NULL) + { + + char tempCoord[256]; + get_value(subsubnode, tempCoord, 256); + wndy.offset2 = be32(strtoul(tempCoord, NULL, 16)); + } + fwrite(&wndy, sizeof(brlyt_wnd), 1, fp); + *fileOffset = *fileOffset + sizeof(brlyt_wnd); + } + + brlyt_wnd1 wndy1; + subnode = mxmlFindElement(node, node, "wnd1", NULL, NULL, MXML_DESCEND); + if (subnode != NULL) + { + i=0; + mxml_node_t *subsubnode; + 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.colors[i] = be32(strtoul(tempCoord, NULL, 16)); + i++; + } + subsubnode = mxmlFindElement(subnode, subnode, "material", NULL, NULL, MXML_DESCEND); + if (subnode != NULL) + { + char tempCoord[256]; + get_value(subsubnode, tempCoord, 256); + wndy1.material = short_swap_bytes(strtoul(tempCoord, NULL, 16)); + } + subsubnode = mxmlFindElement(subnode, subnode, "CoordinateCount", NULL, NULL, MXML_DESCEND); + if (subsubnode != NULL) + { + char tempCoord[256]; + get_value(subsubnode, tempCoord, 256); + wndy1.coordinate_count = short_swap_bytes(strtoul(tempCoord, NULL, 16)); + } + 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, "Coords", NULL, NULL, MXML_DESCEND); + if (subnode != NULL) + { + i=0; + mxml_node_t *subsubnode; + for(subsubnode = mxmlFindElement(subnode, subnode, "texcoord", NULL, NULL, MXML_DESCEND); subsubnode != NULL; subsubnode = mxmlFindElement(subsubnode, subnode, "texcoord", NULL, NULL, MXML_DESCEND)) + { + char tempCoord[256]; + get_value(subsubnode, tempCoord, 256); + wndy3.texcoords[i] = float_swap_bytes(atof(tempCoord)); + i++; + } + fwrite(&wndy3, sizeof(brlyt_wnd3), 1, fp); + *fileOffset = *fileOffset + sizeof(brlyt_wnd3); + } + + brlyt_wnd4 wndy4; + for(subnode = mxmlFindElement(node, node, "wnd4", NULL, NULL, MXML_DESCEND); subnode != NULL; subnode = mxmlFindElement(subnode, node, "wnd4", NULL, NULL, MXML_DESCEND)) + { + i=0; + mxml_node_t *subsubnode; + subsubnode = mxmlFindElement(subnode, subnode, "offset", NULL, NULL, MXML_DESCEND); + if (subsubnode != NULL) + { + char tempCoord[256]; + get_value(subsubnode, tempCoord, 256); + wndy4.offset = be32(strtoul(tempCoord, NULL, 16)); + i++; + } + fwrite(&wndy4, sizeof(brlyt_wnd4), 1, fp); + *fileOffset = *fileOffset + sizeof(brlyt_wnd4); + } + brlyt_wnd4_mat wndy4mat; + for(subnode = mxmlFindElement(node, node, "wnd4mat", NULL, NULL, MXML_DESCEND); subnode != NULL; subnode = mxmlFindElement(subnode, node, "wnd4mat", NULL, NULL, MXML_DESCEND)) + { + i=0; + mxml_node_t *subsubnode; + subsubnode = mxmlFindElement(subnode, subnode, "material", NULL, NULL, MXML_DESCEND); + if (subsubnode != NULL) + { + char tempCoord[256]; + get_value(subsubnode, tempCoord, 256); + 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); + } + } + if ( memcmp(temp, txt1, sizeof(txt1)) == 0) + { + brlyt_pane_chunk chunk; + brlyt_text_chunk chunk2; + char temp[256]; + if(mxmlElementGetAttr(node, "name") != NULL) + strcpy(temp, mxmlElementGetAttr(node, "name")); + else{ + printf("No name attribute found!\nQuitting!\n"); + exit(1); + } + memset(chunk.name, 0, 24 * sizeof(char)); + strcpy(chunk.name, temp); + chunk2.mat_num = short_swap_bytes(findMatOffset(temp)); + + mxml_node_t *subnode = mxmlFindElement(node, node, "translate", NULL, NULL, MXML_DESCEND); + if (subnode != NULL) + { + mxml_node_t *valnode; + valnode = mxmlFindElement(subnode, subnode, "x", NULL, NULL, MXML_DESCEND); + if (valnode != NULL) + { + char tempCoord[256]; + get_value(valnode, tempCoord, 256); + 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.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.ZTrans = float_swap_bytes(atof(tempCoord)); + } + } + subnode = mxmlFindElement(node, node, "rotate", NULL, NULL, MXML_DESCEND); + if (subnode != NULL) + { + mxml_node_t *valnode; + valnode = mxmlFindElement(subnode, subnode, "x", NULL, NULL, MXML_DESCEND); + if (valnode != NULL) + { + char tempCoord[256]; + get_value(valnode, tempCoord, 256); + 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.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, "scale", NULL, NULL, MXML_DESCEND); + if (subnode != NULL) + { + mxml_node_t *valnode; + valnode = mxmlFindElement(subnode, subnode, "x", NULL, NULL, MXML_DESCEND); + if (valnode != NULL) + { + char tempCoord[256]; + get_value(valnode, tempCoord, 256); + 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.YScale = float_swap_bytes(atof(tempCoord)); + } + } + subnode = mxmlFindElement(node, node, "size", NULL, NULL, MXML_DESCEND); + if (subnode != NULL) + { + mxml_node_t *valnode; + valnode = mxmlFindElement(subnode, subnode, "width", NULL, NULL, MXML_DESCEND); + if (valnode != NULL) + { + char tempCoord[256]; + get_value(valnode, tempCoord, 256); + chunk.width = float_swap_bytes(atof(tempCoord)); + } + valnode = mxmlFindElement(subnode, subnode, "height", NULL, NULL, MXML_DESCEND); + if (valnode != NULL) + { + char tempCoord[256]; + get_value(valnode, tempCoord, 256); + chunk.height = float_swap_bytes(atof(tempCoord)); + } + } + 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 ); - } + 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) - { + 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" ); @@ -3482,9 +3491,9 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl strcpy( origins[7] , "BOTTOM CENTER" ); strcpy( origins[8] , "BOTTOM RIGHT" ); - char tempCoord[256]; - get_value(subnode, tempCoord, 256); - chunk.origin = strtol(tempCoord, NULL, 16); + 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 ) { @@ -3492,67 +3501,67 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl break; } } - } - subnode = mxmlFindElement(node, node, "alpha", NULL, NULL, MXML_DESCEND); - if (subnode != NULL) - { - char tempCoord[256]; - get_value(subnode, tempCoord, 256); - chunk.alpha = strtol(tempCoord, NULL, 16); - } - subnode = mxmlFindElement(node, node, "padding", NULL, NULL, MXML_DESCEND); - if (subnode != NULL) - { - char tempCoord[256]; - get_value(subnode, tempCoord, 256); - chunk.pad = strtol(tempCoord, NULL, 16); - } - - subnode = mxmlFindElement(node, node, "font", NULL, NULL, MXML_DESCEND); - if (subnode != NULL) - { - char temp[256]; - if(mxmlElementGetAttr(subnode, "index") != NULL) - strcpy(temp, mxmlElementGetAttr(subnode, "index")); - else{ - printf("No index attribute found!\nQuitting!\n"); - exit(1); - } - chunk2.font_idx = atoi(temp); - chunk2.font_idx = short_swap_bytes(chunk2.font_idx); - - mxml_node_t *valnode; - valnode = mxmlFindElement(subnode, subnode, "xsize", NULL, NULL, MXML_DESCEND); - if (valnode != NULL) - { - char tempCoord[256]; - get_value(valnode, tempCoord, 256); - chunk2.font_size_x = float_swap_bytes(atof(tempCoord)); - } - valnode = mxmlFindElement(subnode, subnode, "ysize", NULL, NULL, MXML_DESCEND); - if (valnode != NULL) - { - char tempCoord[256]; - get_value(valnode, tempCoord, 256); - chunk2.font_size_y = float_swap_bytes(atof(tempCoord)); - } - valnode = mxmlFindElement(subnode, subnode, "charsize", NULL, NULL, MXML_DESCEND); - if (valnode != NULL) - { - char tempCoord[256]; - get_value(valnode, tempCoord, 256); - chunk2.char_space = float_swap_bytes(atof(tempCoord)); - } - valnode = mxmlFindElement(subnode, subnode, "linesize", NULL, NULL, MXML_DESCEND); - if (valnode != NULL) - { - char tempCoord[256]; - get_value(valnode, tempCoord, 256); - chunk2.line_space = float_swap_bytes(atof(tempCoord)); - } - valnode = mxmlFindElement(subnode, subnode, "alignment", NULL, NULL, MXML_DESCEND); - if (valnode != NULL) - { + } + subnode = mxmlFindElement(node, node, "alpha", NULL, NULL, MXML_DESCEND); + if (subnode != NULL) + { + char tempCoord[256]; + get_value(subnode, tempCoord, 256); + chunk.alpha = strtol(tempCoord, NULL, 16); + } + subnode = mxmlFindElement(node, node, "padding", NULL, NULL, MXML_DESCEND); + if (subnode != NULL) + { + char tempCoord[256]; + get_value(subnode, tempCoord, 256); + chunk.pad = strtol(tempCoord, NULL, 16); + } + + subnode = mxmlFindElement(node, node, "font", NULL, NULL, MXML_DESCEND); + if (subnode != NULL) + { + char temp[256]; + if(mxmlElementGetAttr(subnode, "index") != NULL) + strcpy(temp, mxmlElementGetAttr(subnode, "index")); + else{ + printf("No index attribute found!\nQuitting!\n"); + exit(1); + } + chunk2.font_idx = atoi(temp); + chunk2.font_idx = short_swap_bytes(chunk2.font_idx); + + mxml_node_t *valnode; + valnode = mxmlFindElement(subnode, subnode, "xsize", NULL, NULL, MXML_DESCEND); + if (valnode != NULL) + { + char tempCoord[256]; + get_value(valnode, tempCoord, 256); + chunk2.font_size_x = float_swap_bytes(atof(tempCoord)); + } + valnode = mxmlFindElement(subnode, subnode, "ysize", NULL, NULL, MXML_DESCEND); + if (valnode != NULL) + { + char tempCoord[256]; + get_value(valnode, tempCoord, 256); + chunk2.font_size_y = float_swap_bytes(atof(tempCoord)); + } + valnode = mxmlFindElement(subnode, subnode, "charsize", NULL, NULL, MXML_DESCEND); + if (valnode != NULL) + { + char tempCoord[256]; + get_value(valnode, tempCoord, 256); + chunk2.char_space = float_swap_bytes(atof(tempCoord)); + } + valnode = mxmlFindElement(subnode, subnode, "linesize", NULL, NULL, MXML_DESCEND); + if (valnode != NULL) + { + char tempCoord[256]; + get_value(valnode, tempCoord, 256); + chunk2.line_space = float_swap_bytes(atof(tempCoord)); + } + valnode = mxmlFindElement(subnode, subnode, "alignment", NULL, NULL, MXML_DESCEND); + if (valnode != NULL) + { char alignments[9][15]; memset( alignments , 0 , 8 * 20 ); strcpy( alignments[0] , "TOP LEFT" ); @@ -3575,200 +3584,200 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl break; } } - } - } - - subnode = mxmlFindElement(node, node, "length", NULL, NULL, MXML_DESCEND); - if (subnode != NULL) - { - char tempCoord[256]; - get_value(subnode, tempCoord, 256); - chunk2.len1 = strtoul(tempCoord, NULL, 16); - chunk2.len1 = short_swap_bytes(chunk2.len1); - chunk2.len2 = strtoul(tempCoord+5, NULL, 16); - chunk2.len2 = short_swap_bytes(chunk2.len2); - } - 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)); - } - 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)); + } + } + + subnode = mxmlFindElement(node, node, "length", NULL, NULL, MXML_DESCEND); + if (subnode != NULL) + { + char tempCoord[256]; + get_value(subnode, tempCoord, 256); + chunk2.len1 = strtoul(tempCoord, NULL, 16); + chunk2.len1 = short_swap_bytes(chunk2.len1); + chunk2.len2 = strtoul(tempCoord+5, NULL, 16); + chunk2.len2 = short_swap_bytes(chunk2.len2); + } + 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)); + } + 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)); u8 texty[textyLength + 1]; u8 tempy[textyLength*2]; - subnode = mxmlFindElement(node, node, "text", NULL, NULL, MXML_DESCEND); - if (subnode != NULL) - { - u8 tempCoord[8184]; - get_value(subnode, tempCoord, 8184); - memcpy(tempy, tempCoord, short_swap_bytes(chunk2.len2)*2); - u32 w; for (w=0;w 2) - { - printf("Unknown file extension\n"); - exit(1); - } - } - - int brlanargread; - int brlytargread; - int brlanargmake; - int brlytargmake; - int brlanargdestmake; - int brlytargdestmake; - int reqargs; - int currentarg = 2; - char helpstrmake[256]; - char helpstrread[256]; - sprintf(helpstrmake, "%s m", argv[0]); - sprintf(helpstrread, "%s r", argv[0]); -if(type == 2) -{ - brlanargread = currentarg; - strcat(helpstrread, " <*.brlan>"); - brlanargmake = currentarg++; - strcat(helpstrmake, " <*.xmlan>"); -} -if(type == 1) -{ - brlytargread = currentarg; - strcat(helpstrread, " <*.brlyt>"); - brlytargmake = currentarg++; - strcat(helpstrmake, " <*.xmlyt>"); -} - reqargs = currentarg; -if(type == 2) -{ - brlanargdestmake = currentarg++; - strcat(helpstrmake, " "); -} -if(type == 1) -{ - brlytargdestmake = currentarg++; - strcat(helpstrmake, " "); -} + u8 type = 3; + char *ext; - printf(INFORMATION_TEXT); - if(argc < reqargs) { - printf("Invalid arguments. Use like:\n\t%s\n\t\tor:\n\t%s\n", helpstrread, helpstrmake); - exit(1); - } - if((argv[1][0] == 'r') || (argv[1][0] == 'p')) { -if(type == 2) -{ - parse_brlan(argv[brlanargread], argv[3]); -} -if(type == 1) -{ - parse_brlyt(argv[brlytargread], argv[3]); -} - }else if((argv[1][0] == 'm') || (argv[1][0] == 'w')) { -if(type == 2) -{ - make_brlan(argv[brlanargmake], argv[brlanargdestmake]); -} -if(type == 1) -{ - make_brlyt(argv[brlytargmake], argv[brlytargdestmake]); -} - } - return 0; + if (argc < 4) + { + printf("Please use ./benzin r brlytfilename.brlyt xmlytfilename.xmlyt\n"); + printf(" - OR - \n"); + printf("Please use ./benzin m xmlytfilename.xmlyt brlytfilename.brlyt\n"); + exit(1); + } + + if ((strcmp(argv[1], "r") == 0) || (strcmp(argv[1], "p") == 0) || (strcmp(argv[1], "m") == 0) || (strcmp(argv[1], "w") == 0)) + { + ext = strrchr(argv[2], '.'); + } else { + printf("Please use ./benzin r brlytfilename.brlyt xmlytfilename.xmlyt\n"); + printf(" - OR - \n"); + printf("Please use ./benzin m xmlytfilename.xmlyt brlytfilename.brlyt\n"); + exit(1); + } + + if(!ext) + { + printf("No extension on file\n"); + printf("To see possible arguments type ./benzin\n"); + exit(1); + } else { + char* temp = ext; + if(strcmp(++ext, "brlyt") == 0) + { + type = 1; + } + ext = temp; + if(strcmp(++ext, "brlan") == 0) + { + type = 2; + } + if(type > 2) + { + printf("Unknown file extension\n"); + exit(1); + } + } + + int brlanargread; + int brlytargread; + int brlanargmake; + int brlytargmake; + int brlanargdestmake; + int brlytargdestmake; + int brlanargdestread; + int brlytargdestread; + int currentarg = 2; + + if(type == 1) + { + brlytargread = currentarg; + brlytargmake = currentarg++; + brlytargdestread = currentarg; + brlytargdestmake = currentarg++; + } + if(type == 2) + { + brlanargread = currentarg; + brlanargmake = currentarg++; + brlanargdestread = currentarg; + brlanargdestmake = currentarg++; + } + + printf(INFORMATION_TEXT); + + if((argv[1][0] == 'r') || (argv[1][0] == 'p')) { + if(type == 1) + parse_brlyt(argv[brlytargread], argv[brlytargdestread]); + + if(type == 2) + parse_brlan(argv[brlanargread], argv[brlanargdestread]); + + } else if( (argv[1][0] == 'm') || (argv[1][0] == 'w') ) { + if(type == 1) + make_brlyt(argv[brlytargmake], argv[brlytargdestmake]); + + if(type == 2) + make_brlan(argv[brlanargmake], argv[brlanargdestmake]); + + } + return 0; } diff --git a/types.h b/types.h index 43d21b3..956584b 100755 --- a/types.h +++ b/types.h @@ -17,6 +17,15 @@ typedef signed short s16; typedef signed int s32; typedef signed long long s64; +typedef unsigned char uint8_t; +typedef unsigned short uint16_t; +typedef unsigned int uint32_t; +typedef unsigned long long uint64_t; +typedef signed char int8_t; +typedef signed short int16_t; +typedef signed int int32_t; +typedef signed long long int64_t; + typedef float f32; typedef double f64; -- cgit v1.3.1 From 30d7029aa7e0da4f85284bb0e2a017823f53f842 Mon Sep 17 00:00:00 2001 From: megazig Date: Sun, 20 Sep 2009 14:20:55 -0500 Subject: fixed stupid vtx issue --- brlyt.c | 8 ++++---- xml.c | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'brlyt.c') diff --git a/brlyt.c b/brlyt.c index 6a6fdb9..2f0b483 100644 --- a/brlyt.c +++ b/brlyt.c @@ -550,13 +550,13 @@ void PrintBRLYTEntry_pic1(brlyt_entry entry, u8* brlyt_file, mxml_node_t *tag) int n; for (n=0;n<4;n++) { vtx = mxmlNewElement(color, "vtx"); - attr = mxmlNewElement(color, "red"); + attr = mxmlNewElement(vtx, "red"); mxmlNewTextf( attr , 0 , "%02x" , ( be32(data2.vtx_colors[n]) >> 24 ) & 0xff ); - attr = mxmlNewElement(color, "red"); + attr = mxmlNewElement(vtx, "green"); mxmlNewTextf( attr , 0 , "%02x" , ( be32(data2.vtx_colors[n]) >> 16 ) & 0xff ); - attr = mxmlNewElement(color, "red"); + attr = mxmlNewElement(vtx, "blue"); mxmlNewTextf( attr , 0 , "%02x" , ( be32(data2.vtx_colors[n]) >> 8 ) & 0xff ); - attr = mxmlNewElement(color, "red"); + attr = mxmlNewElement(vtx, "alpha"); mxmlNewTextf( attr , 0 , "%02x" , ( be32(data2.vtx_colors[n]) >> 0 ) & 0xff ); } diff --git a/xml.c b/xml.c index 80709df..bb0e067 100644 --- a/xml.c +++ b/xml.c @@ -91,7 +91,7 @@ const char *whitespace_cb(mxml_node_t *node, int where) } if (where == 3 || where == 1){ return ""; - }else if(((node->prev && where == 0) || node->parent) && !(where == 2 && strncmp(name, "ua", 2) && strcmp(name, "rotate") && strcmp(name, "scale") && strcmp(name, "translate") && strcmp(name, "entries") && strcmp(name, "xmlyt") && strcmp(name, "xmlan") && strcmp(name, "entries") && strcmp(name, "triplet") && strcmp(name, "pair") && strcmp(name, "entry") && strcmp(name, "pane") && (strcmp(name, "tag") && strcmp(name, "size") && strcmp(name, "material") && strcmp(name, "colors") && strcmp(name, "subs") && strcmp(name, "font") && strcmp(name, "wnd4") && strcmp(name, "wnd4mat") && strcmp(name, "set") && strcmp(name, "coordinates") && strcmp(name, "TevStage") && strcmp(name, "texture") && strcmp(name, "TextureSRT") && strcmp(name, "CoordGen") && strcmp(name, "ChanControl") && strcmp(name, "MaterialColor") && strcmp(name, "TevSwapModeTable") && strcmp(name, "IndTextureSRT") && strcmp(name, "IndTextureOrder") && strcmp(name, "AlphaCompare") && strcmp(name, "BlendMode") )) ){ + }else if(((node->prev && where == 0) || node->parent) && !(where == 2 && strncmp(name, "ua", 2) && strcmp(name, "rotate") && strcmp(name, "scale") && strcmp(name, "translate") && strcmp(name, "entries") && strcmp(name, "xmlyt") && strcmp(name, "xmlan") && strcmp(name, "entries") && strcmp(name, "triplet") && strcmp(name, "pair") && strcmp(name, "entry") && strcmp(name, "pane") && (strcmp(name, "tag") && strcmp(name, "size") && strcmp(name, "material") && strcmp(name, "vtx") && strcmp(name, "colors") && strcmp(name, "subs") && strcmp(name, "font") && strcmp(name, "wnd4") && strcmp(name, "wnd4mat") && strcmp(name, "set") && strcmp(name, "coordinates") && strcmp(name, "TevStage") && strcmp(name, "texture") && strcmp(name, "TextureSRT") && strcmp(name, "CoordGen") && strcmp(name, "ChanControl") && strcmp(name, "MaterialColor") && strcmp(name, "TevSwapModeTable") && strcmp(name, "IndTextureSRT") && strcmp(name, "IndTextureOrder") && strcmp(name, "AlphaCompare") && strcmp(name, "BlendMode") )) ){ //sprintf(xmlbuff, "\n%*s", (depth-1)*4 , ""); //sprintf(xmlbuff, "\n%*s", (depth)*4 , "\t"); sprintf( xmlbuff , "\n%s" , tab_buffer ); -- cgit v1.3.1