From cc9d00ba706dc83725ca524c14a1e0ee44aa922d Mon Sep 17 00:00:00 2001 From: megazig Date: Mon, 4 May 2009 19:03:56 -0500 Subject: first mxml change --- brlyt.c | 1145 +++++++++++++++++++++++---------------------------------------- 1 file changed, 421 insertions(+), 724 deletions(-) (limited to 'brlyt.c') diff --git a/brlyt.c b/brlyt.c index 0e00980..3aadff7 100644 --- a/brlyt.c +++ b/brlyt.c @@ -90,7 +90,7 @@ float float_swap_bytes(float float1) { unsigned char *float1c; float1c = (unsigned char*)&float1; - unsigned char charTemp = 0x00; + unsigned char charTemp = 0x00; charTemp = float1c[0]; float1c[0] = float1c[3]; float1c[3] = charTemp; charTemp = 0x00; charTemp = float1c[1]; float1c[1] = float1c[2]; float1c[2] = charTemp; @@ -143,16 +143,16 @@ char* getMaterial(u16 offset) char* getTexture(u16 offset) { - if (offset == 0) return textures; - char *tex = textures + strlen(textures) + 1; + if (offset == 0) return textures; + char *tex = textures + strlen(textures) + 1; - if (offset > 1) - { - int n = 1; - for (n; n 1) + { + int n = 1; + for (n; n\n", entry.magic[0], entry.magic[1], entry.magic[2], entry.magic[3]); - printf(" %08x\n", data.a); - printf(" \n"); - printf(" %f\n", float_swap_bytes(data.width)); - printf(" %f\n", float_swap_bytes(data.height)); - printf(" \n"); - printf(" \n"); -#endif //OLD_BRLYT_OUTSTYLE + mxmlElementSetAttrf(tag, "type", "%c%c%c%c", entry.magic[0], entry.magic[1], entry.magic[2], entry.magic[3]); + a = mxmlNewElement(tag, "a"); mxmlNewTextf(a, 0, "%08x", data.a); + 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_grp1(brlyt_entry entry, u8* brlyt_file) +void PrintBRLYTEntry_grp1(brlyt_entry entry, u8* brlyt_file, mxml_node_t *tag) { + mxml_node_t *subs; + mxml_node_t *sub; brlyt_group_chunk data; BRLYT_fileoffset = entry.data_location; BRLYT_ReadDataFromMemory(&data, brlyt_file, sizeof(brlyt_group_chunk)); -#ifdef OLD_BRLYT_OUTSTYLE - printf(" Type: %c%c%c%c\n", entry.magic[0], entry.magic[1], entry.magic[2], entry.magic[3]); - printf(" Name: %s\n", data.name); - printf(" Number of subs: %08x\n", be16(data.numsubs)); - printf(" unk: %08x\n", be16(data.unk)); -#else - printf("type=\"%c%c%c%c\" name=\"%s\">\n", entry.magic[0], entry.magic[1], entry.magic[2], entry.magic[3], data.name); - printf(" \n"); -#endif //OLD_BRLYT_OUTSTYLE + mxmlElementSetAttrf(tag, "type", "%c%c%c%c", entry.magic[0], entry.magic[1], entry.magic[2], entry.magic[3]); + subs = mxmlNewElement(tag, "subs"); int offset; offset = 20; int n = 0; for (n;n%s\n", sub); -#endif //OLD_BRLYT_OUTSTYLE + sub = mxmlNewElement(subs, "sub"); mxmlNewTextf(sub, 0, "%s", subb); offset += 16; } -#ifndef OLD_BRLYT_OUTSTYLE - printf(" \n"); - printf(" \n"); -#endif //OLD_BRLYT_OUTSTYLE } -void PrintBRLYTEntry_txl1(brlyt_entry entry, u8* brlyt_file) +void PrintBRLYTEntry_txl1(brlyt_entry entry, u8* brlyt_file, mxml_node_t *tag) { + mxml_node_t *entries; + mxml_node_t *naame; brlyt_numoffs_chunk data; BRLYT_fileoffset = entry.data_location; BRLYT_ReadDataFromMemory(&data, brlyt_file, sizeof(brlyt_numoffs_chunk)); -#ifdef OLD_BRLYT_OUTSTYLE - printf(" Type: %c%c%c%c\n", entry.magic[0], entry.magic[1], entry.magic[2], entry.magic[3]); - printf(" num: %08x\n", be16(data.num)); - printf(" offs: %08x\n", be16(data.offs)); -#else - printf("type=\"%c%c%c%c\">\n", entry.magic[0], entry.magic[1], entry.magic[2], entry.magic[3]); - printf(" \n"); -#endif //OLD_BRLYT_OUTSTYLE + mxmlElementSetAttrf(tag, "type", "%c%c%c%c", entry.magic[0], entry.magic[1], entry.magic[2], entry.magic[3]); + entries = mxmlNewElement(tag, "entries"); int pos = 4; pos += data.offs; int bpos = pos; int n = 0; for (n;n%s\n", name); -#endif //OLD_BRLYT_OUTSTYLE - BRLYT_fileoffset = tempLocation; + naame = mxmlNewElement(entries, "name"); mxmlNewTextf(naame, 0, "%s", name); + BRLYT_fileoffset = tempLocation; int oldsize = sizeof(name); - dbgprintf("size of textures before: %08x\n", sizeof(textures)); int newSize = lengthOfTextures+sizeof(name); textures = realloc(textures, newSize); numberOfTextures += 1; memcpy(textures+lengthOfTextures, name, sizeof(name)); - dbgprintf("tex: %s\tnamsize: %08x\ttexsize: %08x\tnewsize: %08x\n", textures+lengthOfMaterials, sizeof(name), lengthOfTextures, newSize); lengthOfTextures = newSize; } -#ifndef OLD_BRLYT_OUTSTYLE - printf(" \n"); - printf(" \n"); -#endif //OLD_BRLYT_OUTSTYLE } -void PrintBRLYTEntry_fnl1(brlyt_entry entry, u8* brlyt_file) +void PrintBRLYTEntry_fnl1(brlyt_entry entry, u8* brlyt_file, mxml_node_t *tag) { - brlyt_numoffs_chunk data; - BRLYT_fileoffset = entry.data_location; - BRLYT_ReadDataFromMemory(&data, brlyt_file, sizeof(brlyt_numoffs_chunk)); -#ifdef OLD_BRLYT_OUTSTYLE - printf(" Type: %c%c%c%c\n", entry.magic[0], entry.magic[1], entry.magic[2], entry.magic[3]); - printf(" num: %08x\n", be16(data.num)); - printf(" offs: %08x\n", be16(data.offs)); -#else - printf("type=\"%c%c%c%c\">\n", entry.magic[0], entry.magic[1], entry.magic[2], entry.magic[3]); - printf(" \n"); -#endif //OLD_BRLYT_OUTSTYLE - int pos = 4; - pos += data.offs; - int bpos = pos; - int n = 0; + mxml_node_t *entries; + mxml_node_t *naame; + brlyt_numoffs_chunk data; + BRLYT_fileoffset = entry.data_location; + BRLYT_ReadDataFromMemory(&data, brlyt_file, sizeof(brlyt_numoffs_chunk)); + mxmlElementSetAttrf(tag, "type", "%c%c%c%c", entry.magic[0], entry.magic[1], entry.magic[2], entry.magic[3]); + entries = mxmlNewElement(tag, "entries"); + int pos = 4; + pos += data.offs; + int bpos = pos; + int n = 0; for (n;n%s\n", name); -#endif //OLD_BRLYT_OUTSTYLE - BRLYT_fileoffset = tempLocation; - } -#ifndef OLD_BRLYT_OUTSTYLE - printf(" \n"); - printf(" \n"); -#endif //OLD_BRLYT_OUTSTYLE + { + brlyt_offsunk_chunk data2; + BRLYT_ReadDataFromMemory(&data2, brlyt_file, sizeof(brlyt_offsunk_chunk)); + int tempLocation = BRLYT_fileoffset; + BRLYT_fileoffset = entry.data_location + bpos + be32(data2.offset); + int toRead = (be32(entry.length) + entry.data_location - 8) - BRLYT_fileoffset; + char nameRead[toRead]; + BRLYT_ReadDataFromMemory(nameRead, brlyt_file, sizeof(nameRead)); + + char tpl = 0; + char *ending = memchr(nameRead, tpl, toRead); + int end = ending - nameRead; + char name[end+1]; + memcpy(name, nameRead, sizeof(name)); + naame = mxmlNewElement(entries, "name"); mxmlNewTextf(naame, 0, "%s", name); + BRLYT_fileoffset = tempLocation; + } } -void PrintBRLYTEntry_pan1(brlyt_entry entry, u8* brlyt_file) +void PrintBRLYTEntry_pan1(brlyt_entry entry, u8* brlyt_file, mxml_node_t *tag) { + mxml_node_t *flags1, *flags2, *alpha1, *alpha2; + mxml_node_t *coords, *x, *y, *z; + mxml_node_t *flip, *rotate, *zoom; + mxml_node_t *size, *width, *height; brlyt_pane_chunk data; BRLYT_fileoffset = entry.data_location; BRLYT_ReadDataFromMemory(&data, brlyt_file, sizeof(brlyt_pane_chunk)); -#ifdef OLD_BRLYT_OUTSTYLE - printf(" Type: %c%c%c%c\n", entry.magic[0], entry.magic[1], entry.magic[2], entry.magic[3]); - printf(" flag1: %08x\n", data.flag1); - printf(" flag2: %08x\n", data.flag2); - printf(" alpha: %08x\n", data.alpha); - printf(" alpha2: %08x\n", data.alpha2); - printf(" name: %s\n", data.name); - printf(" x: %.16f\n", float_swap_bytes(data.x)); - printf(" y: %.16f\n", float_swap_bytes(data.y)); - printf(" z: %.16f\n", float_swap_bytes(data.z)); - printf(" flip_x: %f\n", float_swap_bytes(data.flip_x)); - printf(" flip_y: %f\n", float_swap_bytes(data.flip_y)); - printf(" angle: %f\n", float_swap_bytes(data.angle)); - printf(" xmag: %f\n", float_swap_bytes(data.xmag)); - printf(" ymag: %f\n", float_swap_bytes(data.ymag)); - printf(" width: %f\n", float_swap_bytes(data.width)); - printf(" height: %f\n", float_swap_bytes(data.height)); -#else - printf("type=\"%c%c%c%c\" name=\"%s\">\n", entry.magic[0], entry.magic[1], entry.magic[2], entry.magic[3], data.name); - printf(" %02x-%02x\n", data.flag1, data.flag2); - printf(" %02x-%02x\n", data.alpha, data.alpha2); - printf(" \n"); - printf(" %.16f\n", float_swap_bytes(data.x)); - printf(" %.16f\n", float_swap_bytes(data.y)); - printf(" %.16f\n", float_swap_bytes(data.z)); - printf(" \n"); - printf(" \n"); - printf(" %f\n", float_swap_bytes(data.flip_x)); - printf(" %f\n", float_swap_bytes(data.flip_y)); - printf(" \n"); - printf(" %f\n", float_swap_bytes(data.angle)); - printf(" \n"); - printf(" %.10f\n", float_swap_bytes(data.xmag)); - printf(" %.10f\n", float_swap_bytes(data.ymag)); - printf(" \n"); - printf(" \n"); - printf(" %f\n", float_swap_bytes(data.width)); - printf(" %f\n", float_swap_bytes(data.height)); - printf(" \n"); - printf(" \n"); -#endif //OLD_BRLYT_OUTSTYLE + mxmlElementSetAttrf(tag, "type", "%c%c%c%c", entry.magic[0], entry.magic[1], entry.magic[2], entry.magic[3]); + flags1 = mxmlNewElement(tag, "flags"); mxmlNewTextf(flags1, 0, "%02x-%02x", data.flag1, data.flag2); + alpha1 = mxmlNewElement(tag, "alpha"); mxmlNewTextf(alpha1, 0, "%02x-%02x", data.alpha, data.alpha2); + coords = mxmlNewElement(tag, "coords"); + x = mxmlNewElement(coords, "x"); mxmlNewTextf(x, 0, "%.16f", float_swap_bytes(data.x)); + y = mxmlNewElement(coords, "y"); mxmlNewTextf(y, 0, "%.16f", float_swap_bytes(data.y)); + z = mxmlNewElement(coords, "z"); mxmlNewTextf(z, 0, "%.16f", float_swap_bytes(data.z)); + flip = mxmlNewElement(tag, "flip"); + x = mxmlNewElement(flip, "x"); mxmlNewTextf(x, 0, "%f", float_swap_bytes(data.flip_x)); + y = mxmlNewElement(flip, "y"); mxmlNewTextf(y, 0, "%f", float_swap_bytes(data.flip_y)); + rotate = mxmlNewElement(tag, "rotate"); mxmlNewTextf(rotate, 0, "%f", float_swap_bytes(data.angle)); + zoom = mxmlNewElement(tag, "zoom"); + x = mxmlNewElement(zoom, "x"); mxmlNewTextf(x, 0, "%.10f", float_swap_bytes(data.xmag)); + y = mxmlNewElement(zoom, "y"); mxmlNewTextf(y, 0, "%.10f", float_swap_bytes(data.ymag)); + 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) +void PrintBRLYTEntry_wnd1(brlyt_entry entry, u8* brlyt_file, mxml_node_t *tag) { - brlyt_pane_chunk data; - BRLYT_fileoffset = entry.data_location; - BRLYT_ReadDataFromMemory(&data, brlyt_file, sizeof(brlyt_pane_chunk)); -#ifdef OLD_BRLYT_OUTSTYLE - printf(" Type: %c%c%c%c\n", entry.magic[0], entry.magic[1], entry.magic[2], entry.magic[3]); - printf(" flag1: %08x\n", data.flag1); - printf(" flag2: %08x\n", data.flag2); - printf(" alpha: %08x\n", data.alpha); - printf(" alpha2: %08x\n", data.alpha2); - printf(" name: %s\n", data.name); - printf(" x: %f\n", float_swap_bytes(data.x)); - printf(" y: %f\n", float_swap_bytes(data.y)); - printf(" z: %f\n", float_swap_bytes(data.z)); - printf(" flip_x: %f\n", float_swap_bytes(data.flip_x)); - printf(" flip_y: %f\n", float_swap_bytes(data.flip_y)); - printf(" angle: %f\n", float_swap_bytes(data.angle)); - printf(" xmag: %f\n", float_swap_bytes(data.xmag)); - printf(" ymag: %f\n", float_swap_bytes(data.ymag)); - printf(" width: %f\n", float_swap_bytes(data.width)); - printf(" height: %f\n", float_swap_bytes(data.height)); -#else - printf("type=\"%c%c%c%c\" name=\"%s\">\n", entry.magic[0], entry.magic[1], entry.magic[2], entry.magic[3], data.name); - printf(" %02x-%02x\n", data.flag1, data.flag2); - printf(" %02x-%02x\n", data.alpha, data.alpha2); - printf(" \n"); - printf(" %.12f\n", float_swap_bytes(data.x)); - printf(" %.12f\n", float_swap_bytes(data.y)); - printf(" %.12f\n", float_swap_bytes(data.z)); - printf(" \n"); - printf(" \n"); - printf(" %f\n", float_swap_bytes(data.flip_x)); - printf(" %f\n", float_swap_bytes(data.flip_y)); - printf(" \n"); - printf(" %f\n", float_swap_bytes(data.angle)); - printf(" \n"); - printf(" %.10f\n", float_swap_bytes(data.xmag)); - printf(" %.10f\n", float_swap_bytes(data.ymag)); - printf(" \n"); - printf(" \n"); - printf(" %f\n", float_swap_bytes(data.width)); - printf(" %f\n", float_swap_bytes(data.height)); - printf(" \n"); -#endif //OLD_BRLYT_OUTSTYLE - + mxml_node_t *flags1, *flags2, *alpha1, *alpha2; + mxml_node_t *coords, *x, *y, *z; + mxml_node_t *flip, *rotate, *zoom; + 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", "%c%c%c%c", entry.magic[0], entry.magic[1], entry.magic[2], entry.magic[3]); + flags1 = mxmlNewElement(tag, "flags"); mxmlNewTextf(flags1, 0, "%02x-%02x", data.flag1, data.flag2); + alpha1 = mxmlNewElement(tag, "alpha"); mxmlNewTextf(alpha1, 0, "%02x-%02x", data.alpha, data.alpha2); + coords = mxmlNewElement(tag, "coords"); + x = mxmlNewElement(coords, "x"); mxmlNewTextf(x, 0, "%.16f", float_swap_bytes(data.x)); + y = mxmlNewElement(coords, "y"); mxmlNewTextf(y, 0, "%.16f", float_swap_bytes(data.y)); + z = mxmlNewElement(coords, "z"); mxmlNewTextf(z, 0, "%.16f", float_swap_bytes(data.z)); + flip = mxmlNewElement(tag, "flip"); + x = mxmlNewElement(flip, "x"); mxmlNewTextf(x, 0, "%f", float_swap_bytes(data.flip_x)); + y = mxmlNewElement(flip, "y"); mxmlNewTextf(y, 0, "%f", float_swap_bytes(data.flip_y)); + rotate = mxmlNewElement(tag, "rotate"); mxmlNewTextf(rotate, 0, "%f", float_swap_bytes(data.angle)); + zoom = mxmlNewElement(tag, "zoom"); + x = mxmlNewElement(zoom, "x"); mxmlNewTextf(x, 0, "%.10f", float_swap_bytes(data.xmag)); + y = mxmlNewElement(zoom, "y"); mxmlNewTextf(y, 0, "%.10f", float_swap_bytes(data.ymag)); + 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; brlyt_wnd wndy; BRLYT_ReadDataFromMemory(&wndy, brlyt_file, sizeof(brlyt_wnd)); - printf(" \n"); - for(i=0;i<4;i++) printf(" %f\n", float_swap_bytes(wndy.unk1[i])); - printf(" %02x\n", wndy.count); - printf(" %08x\n", be32(wndy.offset1)); - printf(" %08x\n", be32(wndy.offset2)); - printf(" \n"); + wndd = mxmlNewElement(tag, "wnd"); + for(i=0;i<4;i++) + { + unkk = mxmlNewElement(wndd, "unk1"); mxmlNewTextf(unkk, 0, "%f", float_swap_bytes(wndy.unk1[i])); + } + count = mxmlNewElement(wndd, "count"); mxmlNewTextf(count, 0, "%02x", wndy.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; brlyt_wnd1 wndy1; BRLYT_ReadDataFromMemory(&wndy1, brlyt_file, sizeof(brlyt_wnd1)); - printf(" \n"); - for(i=0;i<4;i++) printf(" %08x\n", int_swap_bytes(wndy1.unk1[i])); - printf(" \n"); + wnddd = mxmlNewElement(tag, "wnd1"); + for(i=0;i<4;i++) + { + unkkk = mxmlNewElement(wnddd, "unk1"); mxmlNewTextf(unkkk, 0, "%08x", int_swap_bytes(wndy1.unk1[i])); + } + mxml_node_t *wndddd, *unkkkk, *unkkkk2; brlyt_wnd2 wndy2; BRLYT_ReadDataFromMemory(&wndy2, brlyt_file, sizeof(brlyt_wnd2)); - printf(" \n"); - printf(" %04x\n", short_swap_bytes(wndy2.unk1)); - printf(" %04x\n", short_swap_bytes(wndy2.unk2)); - printf(" \n"); + 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)); + mxml_node_t *wnddddd, *texcoord; if(wndy.offset2 == be32(0x0000009c)) { - brlyt_wnd3 wndy3; - BRLYT_ReadDataFromMemory(&wndy3, brlyt_file, sizeof(brlyt_wnd3)); - printf(" \n"); - for(i=0;i<8;i++) printf(" %f\n", float_swap_bytes(wndy3.texcoords[i])); - printf(" \n"); + 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])); + } } + mxml_node_t *wndddddd, *offsett; brlyt_wnd4 wndy4; for(i=0;i\n"); - printf(" %08x\n", be32(wndy4.offset)); - printf(" \n"); + wndddddd = mxmlNewElement(tag, "wnd4"); + offsett = mxmlNewElement(wndddddd, "offset"); mxmlNewTextf(offsett, 0, "%08x", be32(wndy4.offset)); } + mxml_node_t *wndmat, *matrl; brlyt_wnd4_mat wndy4mat; for(i=0;i\n"); - printf(" %08x\n", be32(wndy4mat.unk1)); - printf(" \n"); + wndmat = mxmlNewElement(tag, "wnd4mat"); + matrl = mxmlNewElement(wndmat, "material"); mxmlNewTextf(matrl, 0, "%08x", be32(wndy4mat.unk1)); } - - printf(" \n"); } -void PrintBRLYTEntry_bnd1(brlyt_entry entry, u8* brlyt_file) +void PrintBRLYTEntry_bnd1(brlyt_entry entry, u8* brlyt_file, mxml_node_t *tag) { - dbgprintf("entry length: %08x\n", be32(entry.length)); - int w; - for (w=0;w\n", entry.magic[0], entry.magic[1], entry.magic[2], entry.magic[3], data.name); - printf(" %02x-%02x\n", data.flag1, data.flag2); - printf(" %02x-%02x\n", data.alpha, data.alpha2); - printf(" \n"); - printf(" %.25f\n", float_swap_bytes(data.x)); - printf(" %.25f\n", float_swap_bytes(data.y)); - printf(" %.25f\n", float_swap_bytes(data.z)); - printf(" \n"); - printf(" \n"); - printf(" %f\n", float_swap_bytes(data.flip_x)); - printf(" %f\n", float_swap_bytes(data.flip_y)); - printf(" \n"); - printf(" %f\n", float_swap_bytes(data.angle)); - printf(" \n"); - printf(" %.10f\n", float_swap_bytes(data.xmag)); - printf(" %.10f\n", float_swap_bytes(data.ymag)); - printf(" \n"); - printf(" \n"); - printf(" %f\n", float_swap_bytes(data.width)); - printf(" %f\n", float_swap_bytes(data.height)); - printf(" \n"); - printf(" \n"); -#endif //OLD_BRLYT_OUTSTYLE + mxml_node_t *flags1, *flags2, *alpha1, *alpha2; + mxml_node_t *coords, *x, *y, *z; + mxml_node_t *flip, *rotate, *zoom; + 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", "%c%c%c%c", entry.magic[0], entry.magic[1], entry.magic[2], entry.magic[3]); + flags1 = mxmlNewElement(tag, "flags"); mxmlNewTextf(flags1, 0, "%02x-%02x", data.flag1, data.flag2); + alpha1 = mxmlNewElement(tag, "alpha"); mxmlNewTextf(alpha1, 0, "%02x-%02x", data.alpha, data.alpha2); + coords = mxmlNewElement(tag, "coords"); + x = mxmlNewElement(coords, "x"); mxmlNewTextf(x, 0, "%.16f", float_swap_bytes(data.x)); + y = mxmlNewElement(coords, "y"); mxmlNewTextf(y, 0, "%.16f", float_swap_bytes(data.y)); + z = mxmlNewElement(coords, "z"); mxmlNewTextf(z, 0, "%.16f", float_swap_bytes(data.z)); + flip = mxmlNewElement(tag, "flip"); + x = mxmlNewElement(flip, "x"); mxmlNewTextf(x, 0, "%f", float_swap_bytes(data.flip_x)); + y = mxmlNewElement(flip, "y"); mxmlNewTextf(y, 0, "%f", float_swap_bytes(data.flip_y)); + rotate = mxmlNewElement(tag, "rotate"); mxmlNewTextf(rotate, 0, "%f", float_swap_bytes(data.angle)); + zoom = mxmlNewElement(tag, "zoom"); + x = mxmlNewElement(zoom, "x"); mxmlNewTextf(x, 0, "%.10f", float_swap_bytes(data.xmag)); + y = mxmlNewElement(zoom, "y"); mxmlNewTextf(y, 0, "%.10f", float_swap_bytes(data.ymag)); + 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) +void PrintBRLYTEntry_pic1(brlyt_entry entry, u8* brlyt_file, mxml_node_t *tag) { - brlyt_pane_chunk data; - BRLYT_fileoffset = entry.data_location; - BRLYT_ReadDataFromMemory(&data, brlyt_file, sizeof(brlyt_pane_chunk)); + mxml_node_t *flags1, *flags2, *alpha1, *alpha2; + mxml_node_t *coords, *x, *y, *z; + mxml_node_t *flip, *rotate, *zoom; + 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)); -#ifdef OLD_BRLYT_OUTSTYLE - printf(" Type: %c%c%c%c\n", entry.magic[0], entry.magic[1], entry.magic[2], entry.magic[3]); - printf(" flag1: %08x\n", data.flag1); - printf(" flag2: %08x\n", data.flag2); - printf(" alpha: %08x\n", data.alpha); - printf(" alpha2: %08x\n", data.alpha2); - printf(" name: %s\n", data.name); - printf(" x: %f\n", float_swap_bytes(data.x)); - printf(" y: %f\n", float_swap_bytes(data.y)); - printf(" z: %f\n", float_swap_bytes(data.z)); - printf(" flip_x: %f\n", float_swap_bytes(data.flip_x)); - printf(" flip_y: %f\n", float_swap_bytes(data.flip_y)); - printf(" angle: %f\n", float_swap_bytes(data.angle)); - printf(" xmag: %f\n", float_swap_bytes(data.xmag)); - printf(" ymag: %f\n", float_swap_bytes(data.ymag)); - printf(" width: %f\n", float_swap_bytes(data.width)); - printf(" height: %f\n", float_swap_bytes(data.height)); -#else - printf("type=\"%c%c%c%c\" name=\"%s\">\n", entry.magic[0], entry.magic[1], entry.magic[2], entry.magic[3], data.name); - printf(" %02x-%02x\n", data.flag1, data.flag2); - printf(" %02x-%02x\n", data.alpha, data.alpha2); - printf(" \n"); - printf(" %.20f\n", float_swap_bytes(data.x)); - printf(" %.20f\n", float_swap_bytes(data.y)); - printf(" %.20f\n", float_swap_bytes(data.z)); - printf(" \n"); - printf(" \n"); - printf(" %f\n", float_swap_bytes(data.flip_x)); - printf(" %f\n", float_swap_bytes(data.flip_y)); - printf(" \n"); - printf(" %f\n", float_swap_bytes(data.angle)); - printf(" \n"); - printf(" %.10f\n", float_swap_bytes(data.xmag)); - printf(" %.10f\n", float_swap_bytes(data.ymag)); - printf(" \n"); - printf(" \n"); - printf(" %f\n", float_swap_bytes(data.width)); - printf(" %f\n", float_swap_bytes(data.height)); - printf(" \n"); -#endif //OLD_BRLYT_OUTSTYLE -#ifdef OLD_BRLYT_OUTSTYLE - printf(" vtx_colors: %u,%u,%u,%u\n", be32(data2.vtx_colors[0]), be32(data2.vtx_colors[1]), be32(data2.vtx_colors[2]), be32(data2.vtx_colors[3])); - printf(" mat_off: %08x\n", short_swap_bytes(data2.mat_off)); - printf(" num_texcoords: %08x\n", data2.num_texcoords); - printf(" padding: %08x\n", data2.padding); -#else - printf(" \n", getMaterial(short_swap_bytes(data2.mat_off))); - printf(" \n"); - printf(" 0x%08X\n", be32(data2.vtx_colors[0])); - printf(" 0x%08X\n", be32(data2.vtx_colors[1])); - printf(" 0x%08X\n", be32(data2.vtx_colors[2])); - printf(" 0x%08X\n", be32(data2.vtx_colors[3])); - printf(" \n"); - printf(" \n"); -#endif //OLD_BRLYT_OUTSTYLE - int n = 0; + mxmlElementSetAttrf(tag, "type", "%c%c%c%c", entry.magic[0], entry.magic[1], entry.magic[2], entry.magic[3]); + flags1 = mxmlNewElement(tag, "flags"); mxmlNewTextf(flags1, 0, "%02x-%02x", data.flag1, data.flag2); + alpha1 = mxmlNewElement(tag, "alpha"); mxmlNewTextf(alpha1, 0, "%02x-%02x", data.alpha, data.alpha2); + coords = mxmlNewElement(tag, "coords"); + x = mxmlNewElement(coords, "x"); mxmlNewTextf(x, 0, "%.16f", float_swap_bytes(data.x)); + y = mxmlNewElement(coords, "y"); mxmlNewTextf(y, 0, "%.16f", float_swap_bytes(data.y)); + z = mxmlNewElement(coords, "z"); mxmlNewTextf(z, 0, "%.16f", float_swap_bytes(data.z)); + flip = mxmlNewElement(tag, "flip"); + x = mxmlNewElement(flip, "x"); mxmlNewTextf(x, 0, "%f", float_swap_bytes(data.flip_x)); + y = mxmlNewElement(flip, "y"); mxmlNewTextf(y, 0, "%f", float_swap_bytes(data.flip_y)); + rotate = mxmlNewElement(tag, "rotate"); mxmlNewTextf(rotate, 0, "%f", float_swap_bytes(data.angle)); + zoom = mxmlNewElement(tag, "zoom"); + x = mxmlNewElement(zoom, "x"); mxmlNewTextf(x, 0, "%.10f", float_swap_bytes(data.xmag)); + y = mxmlNewElement(zoom, "y"); mxmlNewTextf(y, 0, "%.10f", float_swap_bytes(data.ymag)); + 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 *tpl, *color, *vtx, *coordinates, *set, *coord; + tpl = mxmlNewElement(tag, "tpl"); mxmlElementSetAttrf(tpl, "name", "%s", getMaterial(short_swap_bytes(data2.mat_off))); + 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;n\n"); + set = mxmlNewElement(coordinates, "set"); for(i = 0; i < 8; i++) - printf(" %f\n", float_swap_bytes(texcoords[i])); - printf(" \n"); -#endif //OLD_BRLYT_OUTSTYLE + { + coord = mxmlNewElement(set, "coord"); mxmlNewTextf(coord, 0, "%f", float_swap_bytes(texcoords[i])); + } } -#ifndef OLD_BRLYT_OUTSTYLE - printf(" \n"); - printf(" \n"); -#endif //OLD_BRLYT_OUTSTYLE } -void PrintBRLYTEntry_txt1(brlyt_entry entry, u8* brlyt_file) +void PrintBRLYTEntry_txt1(brlyt_entry entry, u8* brlyt_file, mxml_node_t *tag) { - brlyt_pane_chunk data; - BRLYT_fileoffset = entry.data_location; - BRLYT_ReadDataFromMemory(&data, brlyt_file, sizeof(brlyt_pane_chunk)); -#ifdef OLD_BRLYT_OUTSTYLE - printf(" Type: %c%c%c%c\n", entry.magic[0], entry.magic[1], entry.magic[2], entry.magic[3]); - printf(" flag1: %08x\n", data.flag1); - printf(" flag2: %08x\n", data.flag2); - printf(" alpha: %08x\n", data.alpha); - printf(" alpha2: %08x\n", data.alpha2); - printf(" name: %s\n", data.name); - printf(" x: %f\n", float_swap_bytes(data.x)); - printf(" y: %f\n", float_swap_bytes(data.y)); - printf(" z: %f\n", float_swap_bytes(data.z)); - printf(" flip_x: %f\n", float_swap_bytes(data.flip_x)); - printf(" flip_y: %f\n", float_swap_bytes(data.flip_y)); - printf(" angle: %f\n", float_swap_bytes(data.angle)); - printf(" xmag: %f\n", float_swap_bytes(data.xmag)); - printf(" ymag: %f\n", float_swap_bytes(data.ymag)); - printf(" width: %f\n", float_swap_bytes(data.width)); - printf(" height: %f\n", float_swap_bytes(data.height)); -#else - printf("type=\"%c%c%c%c\" name=\"%s\">\n", entry.magic[0], entry.magic[1], entry.magic[2], entry.magic[3], data.name); - printf(" %02x-%02x\n", data.flag1, data.flag2); - printf(" %02x-%02x\n", data.alpha, data.alpha2); - printf(" \n"); - printf(" %.16f\n", float_swap_bytes(data.x)); - printf(" %.16f\n", float_swap_bytes(data.y)); - printf(" %.16f\n", float_swap_bytes(data.z)); - printf(" \n"); - printf(" \n"); - printf(" %.10f\n", float_swap_bytes(data.flip_x)); - printf(" %.10f\n", float_swap_bytes(data.flip_y)); - printf(" \n"); - printf(" %f\n", float_swap_bytes(data.angle)); - printf(" \n"); - printf(" %.10f\n", float_swap_bytes(data.xmag)); - printf(" %.10f\n", float_swap_bytes(data.ymag)); - printf(" \n"); - printf(" \n"); - printf(" %.10f\n", float_swap_bytes(data.width)); - printf(" %.10f\n", float_swap_bytes(data.height)); - printf(" \n"); -#endif //OLD_BRLYT_OUTSTYLE + mxml_node_t *flags1, *flags2, *alpha1, *alpha2; + mxml_node_t *coords, *x, *y, *z; + mxml_node_t *flip, *rotate, *zoom; + 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", "%c%c%c%c", entry.magic[0], entry.magic[1], entry.magic[2], entry.magic[3]); + flags1 = mxmlNewElement(tag, "flags"); mxmlNewTextf(flags1, 0, "%02x-%02x", data.flag1, data.flag2); + alpha1 = mxmlNewElement(tag, "alpha"); mxmlNewTextf(alpha1, 0, "%02x-%02x", data.alpha, data.alpha2); + coords = mxmlNewElement(tag, "coords"); + x = mxmlNewElement(coords, "x"); mxmlNewTextf(x, 0, "%.16f", float_swap_bytes(data.x)); + y = mxmlNewElement(coords, "y"); mxmlNewTextf(y, 0, "%.16f", float_swap_bytes(data.y)); + z = mxmlNewElement(coords, "z"); mxmlNewTextf(z, 0, "%.16f", float_swap_bytes(data.z)); + flip = mxmlNewElement(tag, "flip"); + x = mxmlNewElement(flip, "x"); mxmlNewTextf(x, 0, "%f", float_swap_bytes(data.flip_x)); + y = mxmlNewElement(flip, "y"); mxmlNewTextf(y, 0, "%f", float_swap_bytes(data.flip_y)); + rotate = mxmlNewElement(tag, "rotate"); mxmlNewTextf(rotate, 0, "%f", float_swap_bytes(data.angle)); + zoom = mxmlNewElement(tag, "zoom"); + x = mxmlNewElement(zoom, "x"); mxmlNewTextf(x, 0, "%.10f", float_swap_bytes(data.xmag)); + y = mxmlNewElement(zoom, "y"); mxmlNewTextf(y, 0, "%.10f", float_swap_bytes(data.ymag)); + 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 *length, *font, *xsize, *ysize, *charsize, *linesize, *unkk, *color; brlyt_text_chunk data2; BRLYT_ReadDataFromMemory(&data2, brlyt_file, sizeof(brlyt_text_chunk)); unsigned char texty[short_swap_bytes(data2.len2)]; memcpy(texty, &brlyt_file[BRLYT_fileoffset], short_swap_bytes(data2.len2)); -#ifdef OLD_BRLYT_OUTSTYLE - printf(" len1: %08x\n", be16(data2.len1)); - printf(" len2: %08x\n", short_swap_bytes(data2.len2)); - printf(" mat_off: %08x\n", be16(data2.mat_off)); - printf(" font_idx: %08x\n", be16(data2.font_idx)); - printf(" unk4: %08x\n", data2.unk4); - printf(" pad[3]: %08x\n", data2.pad[0], data2.pad[1], data2.pad[2]); - printf(" name_offs: %08x\n", be32(data2.name_offs)); - printf(" color1: %08x\n", be32(data2.color1)); - printf(" color2: %08x\n", be32(data2.color2)); - printf(" font_size_x: %f\n", float_swap_bytes(data2.font_size_x)); - printf(" font_size_y: %f\n", float_swap_bytes(data2.font_size_y)); - printf(" char_space: %f\n", float_swap_bytes(data2.char_space)); - printf(" line_space: %f\n", float_swap_bytes(data2.line_space)); - printf(" text: "); - int q; for (q=0;q%04x-%04x\n", short_swap_bytes(data2.len1), short_swap_bytes(data2.len2)); - printf(" \n", short_swap_bytes(data2.font_idx)); - printf(" %f\n", float_swap_bytes(data2.font_size_x)); - printf(" %f\n", float_swap_bytes(data2.font_size_y)); - printf(" %f\n", float_swap_bytes(data2.char_space)); - printf(" %f\n", float_swap_bytes(data2.line_space)); - printf(" %02x\n", data2.unk4); - printf(" \n"); - printf(" %08x-%08x\n", be32(data2.color1), be32(data2.color2)); - printf(" "); - int q; for(q=0;q\n"); - printf(" \n"); -#endif //OLD_BRLYT_OUTSTYLE + 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, 0, "%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)); + unkk = mxmlNewElement(font, "unk"); mxmlNewTextf(unkk, 0, "%02x", data2.unk4); + color = mxmlNewElement(tag, "color"); mxmlNewTextf(color, 0, "%08x-%08x", be32(data2.color1), be32(data2.color2)); +// int q; for(q=0;q\n", entry.magic[0], entry.magic[1], entry.magic[2], entry.magic[3], short_swap_bytes(data.num)); -#endif //OLD_BRLYT_OUTSTYLE + mxmlElementSetAttrf(tag, "type", "%c%c%c%c", entry.magic[0], entry.magic[1], entry.magic[2], entry.magic[3]); int n = 0; for (n;n\n", data3.name); - printf(" \n"); - printf(" %d\n", short_swap_bytes(data3.black_color[0])); - printf(" %d\n", short_swap_bytes(data3.black_color[1])); - printf(" %d\n", short_swap_bytes(data3.black_color[2])); - printf(" %d\n", short_swap_bytes(data3.black_color[3])); - printf(" %d\n", short_swap_bytes(data3.white_color[0])); - printf(" %d\n", short_swap_bytes(data3.white_color[1])); - printf(" %d\n", short_swap_bytes(data3.white_color[2])); - printf(" %d\n", short_swap_bytes(data3.white_color[3])); - printf(" %d\n", short_swap_bytes(data3.unk_color_2[0])); - printf(" %d\n", short_swap_bytes(data3.unk_color_2[1])); - printf(" %d\n", short_swap_bytes(data3.unk_color_2[2])); - printf(" %d\n", short_swap_bytes(data3.unk_color_2[3])); - printf(" %#08x\n", be32(data3.tev_kcolor[0])); - printf(" %#08x\n", be32(data3.tev_kcolor[1])); - printf(" %#08x\n", be32(data3.tev_kcolor[2])); - printf(" %#08x\n", be32(data3.tev_kcolor[3])); - printf(" \n"); - printf(" %08x\n", be32(data3.flags)); -#endif //OLD_BRLYT_OUTSTYLE + entries = mxmlNewElement(tag, "entries"); mxmlElementSetAttrf(entries, "%s", data3.name); + colors = mxmlNewElement(entries, "colors"); + int i; for (i=0;i<4;i++) + { + black_color = mxmlNewElement(colors, "black_color"); + mxmlNewTextf(black_color, 0, "%d", short_swap_bytes(data3.black_color[i])); + } + for (i=0;i<4;i++) + { + white_color = mxmlNewElement(colors, "white_color"); + mxmlNewTextf(white_color, 0, "%d", short_swap_bytes(data3.white_color[i])); + } + for (i=0;i<4;i++) + { + unk2 = mxmlNewElement(colors, "unk2"); + mxmlNewTextf(unk2, 0, "%d", short_swap_bytes(data3.unk_color_2[i])); + } + for (i=0;i<4;i++) + { + tev_k = mxmlNewElement(colors, "tev_k"); + mxmlNewTextf(tev_k, 0, "%#08x", be32(data3.tev_kcolor[i])); + } + flags = mxmlNewElement(tag, "flags"); mxmlNewTextf(flags, 0, "%08x", be32(data3.flags)); int oldsize = 1+strlen(data3.name); - dbgprintf("size of materials before: %08x\n", sizeof(materials)); int newSize = lengthOfMaterials+strlen(data3.name)+1; materials = realloc(materials, newSize); numberOfMaterials += 1; memcpy(materials+lengthOfMaterials, data3.name, 1+strlen(data3.name)); - dbgprintf("mats: %s\tnamsize: %08x\tmatsize: %08x\tnewsize: %08x\n", materials+lengthOfMaterials, strlen(data3.name), lengthOfMaterials, newSize); lengthOfMaterials = newSize; + mxml_node_t *material, *wrap_t, *wrap_s; int n = 0; for (n;n\n", getTexture(tplOffset)); - printf(" %02x\n", data4.wrap_s); - printf(" %02x\n", data4.wrap_t); - printf(" \n"); -#endif //OLD_BRLYT_OUTSTYLE + material = mxmlNewElement(tag, "material"); mxmlElementSetAttrf(material, "name", "%s", getTexture(tplOffset)); + wrap_s = mxmlNewElement(material, "wrap_s"); mxmlNewTextf(wrap_s, 0, "%02x", data4.wrap_s); + wrap_t = mxmlNewElement(material, "wrap_t"); mxmlNewTextf(wrap_t, 0, "%02x", data4.wrap_t); } + mxml_node_t *ua2, *dataa; // # 0x14 * flags[24-27], followed by n = 0; for (n;n\n"); - printf(" %.10f\n", float_swap_bytes(data4.unk[0])); - printf(" %.10f\n", float_swap_bytes(data4.unk[1])); - printf(" %.10f\n", float_swap_bytes(data4.unk[2])); - printf(" %.10f\n", float_swap_bytes(data4.unk[3])); - printf(" %.10f\n", float_swap_bytes(data4.unk[4])); - printf(" \n"); -#endif //OLD_BRLYT_OUTSTYLE + ua2 = mxmlNewElement(tag, "ua2"); + int j; for (j=0;j<5;j++) + { + dataa = mxmlNewElement(ua2, "data"); mxmlNewTextf(dataa, 0, "%.10f", float_swap_bytes(data4.unk[j])); + } } + + mxml_node_t *ua3; //# 4*flags[20-23], followed by n = 0; for (n;n\n"); - printf(" %02x\n", data4.unk[0]); - printf(" %02x\n", data4.unk[1]); - printf(" %02x\n", data4.unk[2]); - printf(" %02x\n", data4.unk[3]); - printf(" \n"); -#endif //OLD_BRLYT_OUTSTYLE + ua3 = mxmlNewElement(tag, "ua3"); + int j; for (j=0;j<4;j++) + { + dataa = mxmlNewElement(ua3, "data"); mxmlNewTextf(dataa, 0, "%02x", data4.unk[j]); + } } //# Changing ua3 things //# 1st --> disappears. @@ -858,264 +636,177 @@ void PrintBRLYTEntry_mat1(brlyt_entry entry, u8* brlyt_file) //# 3rd --> disappears. //# 4th --> no visible effect. + mxml_node_t *ua4; //# 4 * flags[6] n = 0; for (n;n\n"); - printf(" %02x\n", data4.unk[0]); - printf(" %02x\n", data4.unk[1]); - printf(" %02x\n", data4.unk[2]); - printf(" %02x\n", data4.unk[3]); - printf(" \n"); -#endif //OLD_BRLYT_OUTSTYLE + ua4 = mxmlNewElement(tag, "ua4"); + int j; for (j=0;j<4;j++) + { + dataa = mxmlNewElement(ua4, "data"); mxmlNewTextf(dataa, 0, "%02x", data4.unk[j]); + } } + + mxml_node_t *ua5; //# 4 * flags[4] n = 0; for (n;n\n"); - printf(" %02x\n", data4.unk[0]); - printf(" %02x\n", data4.unk[1]); - printf(" %02x\n", data4.unk[2]); - printf(" %02x\n", data4.unk[3]); - printf(" \n"); -#endif //OLD_BRLYT_OUTSTYLE + ua5 = mxmlNewElement(tag, "ua5"); + int j; for (j=0;j<4;j++) + { + dataa = mxmlNewElement(ua5, "data"); mxmlNewTextf(dataa, 0, "%02x", data4.unk[j]); + } } + + mxml_node_t *ua6; //# 4 * flags[19] n = 0; for (n;n\n"); - printf(" %02x\n", data4.unk[0]); - printf(" %02x\n", data4.unk[1]); - printf(" %02x\n", data4.unk[2]); - printf(" %02x\n", data4.unk[3]); - printf(" \n"); -#endif //OLD_BRLYT_OUTSTYLE + ua6 = mxmlNewElement(tag, "ua6"); + int j; for (j=0;j<4;j++) + { + dataa = mxmlNewElement(ua6, "data"); mxmlNewTextf(dataa, 0, "%02x", data4.unk[j]); + } } + + mxml_node_t *ua7, *a, *b, *c, *d, *e; n = 0; for (n;n\n"); - printf(" %08x\n", be32(data4.a)); - printf(" %08x\n", be32(data4.b)); - printf(" %f\n", float_swap_bytes(data4.c)); - printf(" %f\n", float_swap_bytes(data4.d)); - printf(" %f\n", float_swap_bytes(data4.e)); - printf(" \n"); -#endif //OLD_BRLYT_OUTSTYLE + ua7 = mxmlNewElement(tag, "ua7"); + a = mxmlNewElement(ua7, "a"); mxmlNewTextf(a, 0, "%08x", be32(data4.a)); + b = mxmlNewElement(ua7, "b"); mxmlNewTextf(b, 0, "%08x", be32(data4.b)); + c = mxmlNewElement(ua7, "c"); mxmlNewTextf(c, 0, "%f", float_swap_bytes(data4.c)); + d = mxmlNewElement(ua7, "d"); mxmlNewTextf(d, 0, "%f", float_swap_bytes(data4.d)); + e = mxmlNewElement(ua7, "e"); mxmlNewTextf(e, 0, "%f", float_swap_bytes(data4.e)); } + + mxml_node_t *ua8; //# 4 * flags[14-16] n = 0; for (n;n\n"); - printf(" %02x\n", data4.unk[0]); - printf(" %02x\n", data4.unk[1]); - printf(" %02x\n", data4.unk[2]); - printf(" %02x\n", data4.unk[3]); - printf(" \n"); -#endif //OLD_BRLYT_OUTSTYLE + ua8 = mxmlNewElement(tag, "ua8"); + int j; for (j=0;j<4;j++) + { + dataa = mxmlNewElement(ua8, "data"); mxmlNewTextf(dataa, 0, "%02x", data4.unk[j]); + } } + + mxml_node_t *ua9; //# 0x10 * flags[9-13] n = 0; for (n;n\n"); - printf(" %02x\n", data4.unk[0]); - printf(" %02x\n", data4.unk[1]); - printf(" %02x\n", data4.unk[2]); - printf(" %02x\n", data4.unk[3]); - printf(" %02x\n", data4.unk[4]); - printf(" %02x\n", data4.unk[5]); - printf(" %02x\n", data4.unk[6]); - printf(" %02x\n", data4.unk[7]); - printf(" %02x\n", data4.unk[8]); - printf(" %02x\n", data4.unk[9]); - printf(" %02x\n", data4.unk[10]); - printf(" %02x\n", data4.unk[11]); - printf(" %02x\n", data4.unk[12]); - printf(" %02x\n", data4.unk[13]); - printf(" %02x\n", data4.unk[14]); - printf(" %02x\n", data4.unk[15]); - printf(" \n"); -#endif //OLD_BRLYT_OUTSTYLE + ua9 = mxmlNewElement(tag, "ua9"); + int j; for (j=0;j<16;j++) + { + dataa = mxmlNewElement(ua9, "data"); + mxmlNewTextf(dataa, 0, "%02x", data4.unk[j]); + } } + + mxml_node_t *uaa; //# 4 * flags[8], these are bytes btw n = 0; for (n;n\n"); - printf(" %02x\n", data4.unk[0]); - printf(" %02x\n", data4.unk[1]); - printf(" %02x\n", data4.unk[2]); - printf(" %02x\n", data4.unk[3]); - printf(" \n"); -#endif //OLD_BRLYT_OUTSTYLE + uaa = mxmlNewElement(tag, "uaa"); + int j; for (j=0;j<4;j++) + { + dataa = mxmlNewElement(uaa, "data"); mxmlNewTextf(dataa, 0, "%02x", data4.unk[j]); + } } + mxml_node_t *uab; //# 4 * flags[7] n = 0; for (n;n\n"); - printf(" %02x\n", data4.unk[0]); - printf(" %02x\n", data4.unk[1]); - printf(" %02x\n", data4.unk[2]); - printf(" %02x\n", data4.unk[3]); - printf(" \n"); -#endif //OLD_BRLYT_OUTSTYLE + uab = mxmlNewElement(tag, "uab"); + int j; for (j=0;j<4;j++) + { + dataa = mxmlNewElement(uab, "data"); mxmlNewTextf(dataa, 0, "%02x", data4.unk[j]); + } } -#ifndef OLD_BRLYT_OUTSTYLE - printf(" \n"); -#endif //OLD_BRLYT_OUTSTYLE BRLYT_fileoffset = tempDataLocation; } -#ifndef OLD_BRLYT_OUTSTYLE - printf(" \n"); -#endif //OLD_BRLYT_OUTSTYLE } -void PrintBRLYTEntry_gre1(brlyt_entry entry, u8* brlyt_file) +void PrintBRLYTEntry_gre1(brlyt_entry entry, u8* brlyt_file, mxml_node_t *tag) { -#ifdef OLD_BRLYT_OUTSTYLE - printf(" Type: %c%c%c%c\n", entry.magic[0], entry.magic[1], entry.magic[2], entry.magic[3]); -#else - printf("type=\"%c%c%c%c\" />\n", entry.magic[0], entry.magic[1], entry.magic[2], entry.magic[3]); -#endif //OLD_BRLYT_OUTSTYLE + mxmlElementSetAttrf(tag, "type", "%c%c%c%c", entry.magic[0], entry.magic[1], entry.magic[2], entry.magic[3]); } -void PrintBRLYTEntry_grs1(brlyt_entry entry, u8* brlyt_file) +void PrintBRLYTEntry_grs1(brlyt_entry entry, u8* brlyt_file, mxml_node_t *tag) { -#ifdef OLD_BRLYT_OUTSTYLE - printf(" Type: %c%c%c%c\n", entry.magic[0], entry.magic[1], entry.magic[2], entry.magic[3]); -#else - printf("type=\"%c%c%c%c\" />\n", entry.magic[0], entry.magic[1], entry.magic[2], entry.magic[3]); -#endif //OLD_BRLYT_OUTSTYLE + mxmlElementSetAttrf(tag, "type", "%c%c%c%c", entry.magic[0], entry.magic[1], entry.magic[2], entry.magic[3]); } -void PrintBRLYTEntry_pae1(brlyt_entry entry, u8* brlyt_file) +void PrintBRLYTEntry_pae1(brlyt_entry entry, u8* brlyt_file, mxml_node_t *tag) { -#ifdef OLD_BRLYT_OUTSTYLE - printf(" Type: %c%c%c%c\n", entry.magic[0], entry.magic[1], entry.magic[2], entry.magic[3]); -#else - printf("type=\"%c%c%c%c\" />\n", entry.magic[0], entry.magic[1], entry.magic[2], entry.magic[3]); -#endif //OLD_BRLYT_OUTSTYLE + mxmlElementSetAttrf(tag, "type", "%c%c%c%c", entry.magic[0], entry.magic[1], entry.magic[2], entry.magic[3]); } -void PrintBRLYTEntry_pas1(brlyt_entry entry, u8* brlyt_file) +void PrintBRLYTEntry_pas1(brlyt_entry entry, u8* brlyt_file, mxml_node_t* tag) { -#ifdef OLD_BRLYT_OUTSTYLE - printf(" Type: %c%c%c%c\n", entry.magic[0], entry.magic[1], entry.magic[2], entry.magic[3]); -#else - printf("type=\"%c%c%c%c\" />\n", entry.magic[0], entry.magic[1], entry.magic[2], entry.magic[3]); -#endif //OLD_BRLYT_OUTSTYLE + mxmlElementSetAttrf(tag, "type", "%c%c%c%c", entry.magic[0], entry.magic[1], entry.magic[2], entry.magic[3]); } -void PrintBRLYTEntries(brlyt_entry *entries, int entrycnt, u8* brlyt_file) +void PrintBRLYTEntries(brlyt_entry *entries, int entrycnt, u8* brlyt_file, mxml_node_t *xmlyt) { - dbgprintf("Printing BRLYT Entries"); int i; - + mxml_node_t *tag; for(i = 0; i < entrycnt; i++) { -#ifdef OLD_BRLYT_OUTSTYLE - printf("\n Index %d (@%08x):\n", i, entries[i].data_location - 8); -#else - printf(" \n"); -#endif //OLD_BRLYT_OUTSTYLE } } } @@ -1135,12 +826,9 @@ void parse_brlyt(char *filename) } fseek(fp, 0, SEEK_END); size_t file_size = ftell(fp); - dbgprintf("Filesize is %d\n", file_size); u8* brlyt_file = (u8*)malloc(file_size); - dbgprintf("brlyt_file allocated\n"); fseek(fp, 0, SEEK_SET); fread(brlyt_file, file_size, 1, fp); - dbgprintf("brlyt_file read to.\n"); BRLYT_fileoffset = 0; brlyt_header header; BRLYT_ReadDataFromMemory(&header, brlyt_file, sizeof(brlyt_header)); @@ -1149,22 +837,18 @@ void parse_brlyt(char *filename) BRLYT_fileoffset = short_swap_bytes(header.lyt_offset); brlyt_entry_header tempentry; int i; - dbgprintf("curr %08x max %08x\n", BRLYT_fileoffset, file_size); for(i = 0; BRLYT_fileoffset < file_size; i++) { BRLYT_ReadDataFromMemoryX(&tempentry, brlyt_file, sizeof(brlyt_entry_header)); BRLYT_fileoffset += be32(tempentry.length); - dbgprintf("curr %08x max %08x\n", BRLYT_fileoffset, file_size); } int entrycount = i; entries = (brlyt_entry*)calloc(entrycount, sizeof(brlyt_entry)); - dbgprintf("%08x\n", entries); if(entries == NULL) { printf("Couldn't allocate for entries!\n"); exit(1); } BRLYT_fileoffset = short_swap_bytes(header.lyt_offset); for(i = 0; i < entrycount; i++) { - dbgprintf("&(entries[i]) = %08x\n", &(entries[i])); BRLYT_ReadDataFromMemoryX(&tempentry, brlyt_file, sizeof(brlyt_entry_header)); memcpy(entries[i].magic, tempentry.magic, 4); entries[i].length = tempentry.length; @@ -1172,29 +856,46 @@ void parse_brlyt(char *filename) BRLYT_fileoffset += be32(tempentry.length); } - dbgprintf("%08x\n", entries); -#ifdef OLD_BRLYT_OUTSTYLE - printf("Parsed BRLYT! Information:\n"); - printf("Main header:\n"); - printf(" Magic: %c%c%c%c\n", header.magic[0], header.magic[1], header.magic[2], header.magic[3]); - printf(" Unk1: %08x\n", be32(header.unk1)); - printf(" Filesize: %lu\n", be32(header.filesize)); - printf(" %s real file size!\n", be32(header.filesize) == file_size ? "Matches" : "Does not match"); - printf(" Offset to lyt1: %04x\n", short_swap_bytes(header.lyt_offset)); - printf(" Unk2: %04x\n", short_swap_bytes(header.unk2)); - printf("\nBRLYT Entries:"); -#else - printf("\n" \ - "\n"); -#endif //OLD_BRLYT_OUTSTYLE - PrintBRLYTEntries(entries, entrycount, brlyt_file); -#ifndef OLD_BRLYT_OUTSTYLE - printf("\n"); -#endif //OLD_BRLYT_OUTSTYLE + const char *whitespace_cb(mxml_node_t *node, int where) + { + const char *name; + name = node->value.element.name; + + if (!strcmp(name, "xmlyt")) + { + if ((where == MXML_WS_BEFORE_OPEN) || (where == MXML_WS_BEFORE_CLOSE)) + return("\n"); + } + else if (!strcmp(name, "tag")) + { + if ((where == MXML_WS_BEFORE_OPEN) || (where == MXML_WS_BEFORE_CLOSE)) + return ("\n\t"); + } + else if (!strcmp(name, "a") || + !strcmp(name, "size") || + !strcmp(name, "entries")) + { + if ((where == MXML_WS_BEFORE_OPEN) || (where == MXML_WS_BEFORE_CLOSE)) + return ("\n\t\t"); + } + /* + * Return NULL for no added whitespace... + */ + return (NULL); + } + FILE *xmlFile; + xmlFile = fopen("testy.xmlyt", "w"); + mxml_node_t *xml; + mxml_node_t *xmlyt; + xml = mxmlNewXML("1.0"); + xmlyt = mxmlNewElement(xml, "xmlyt"); + PrintBRLYTEntries(entries, entrycount, brlyt_file, xmlyt); + mxmlSaveFile(xml, xmlFile, whitespace_cb); + fclose(xmlFile); + mxmlDelete(xml); free(materials); free(textures); - } void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* blobsize, char temp[4], FILE* fp, unsigned int *fileOffset) @@ -1282,10 +983,8 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl 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); @@ -1365,7 +1064,6 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl 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]; @@ -1418,7 +1116,6 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl } if ( memcmp(temp, mat1, sizeof(mat1)) == 0) { - int numberOfEntries = 0; int actualNumber = 0; brlyt_numoffs_chunk numchunk; @@ -2451,7 +2148,7 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl if ((textyLength % 4) != 0) textyLength += (4 - (textyLength % 4)); unsigned char texty[textyLength + 1]; - unsigned char tempy[textyLength*2]; + unsigned char tempy[textyLength*2]; subnode = mxmlFindElement(node, node, "text", NULL, NULL, MXML_DESCEND); if (subnode != NULL) { @@ -2476,7 +2173,7 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl fwrite(&chunk2, sizeof(chunk2), 1, fp); *fileOffset = *fileOffset + sizeof(chunk2); - int q;for (q=short_swap_bytes(chunk2.len2);q