From 25c8362e3cb0348f89d2f25d0613a7f5cb810c03 Mon Sep 17 00:00:00 2001 From: megazig Date: Sun, 12 Apr 2009 23:00:48 -0500 Subject: Brlyt is hella fixed --- brlyt.c | 288 ++++++++++++++++++++++++++++++++++++++++++++++---------------- endian.c | 27 +++++- endian.h | 4 + general.h | 6 +- 4 files changed, 248 insertions(+), 77 deletions(-) diff --git a/brlyt.c b/brlyt.c index c80d718..4b7d385 100644 --- a/brlyt.c +++ b/brlyt.c @@ -12,6 +12,7 @@ #include #include #include +#include #include "general.h" #include "types.h" @@ -47,6 +48,9 @@ static size_t BRLYT_fileoffset = 0; char *materials; int numberOfMaterials; int lengthOfMaterials; +char *textures; +int numberOfTextures; +int lengthOfTextures; static int FourCCsMatch(fourcc cc1, fourcc cc2) { @@ -96,15 +100,17 @@ float float_swap_bytes(float float1) return *newFloat; } +/* u16 short_swap_bytes(u16 short1) { unsigned char* short1c; short1c = (unsigned char*)&short1; unsigned char charTemp = 0x00; charTemp = short1c[0]; short1c[0] = short1c[1]; short1c[1] = charTemp; - short *newShort; newShort = (short*)short1c; + unsigned short *newShort; newShort = (unsigned short*)short1c; return *newShort; } +*/ unsigned int bit_extract(unsigned int num, unsigned int start, unsigned int end) { @@ -126,12 +132,13 @@ unsigned int bit_extract(unsigned int num, unsigned int start, unsigned int end) { secondMask *=2; } - mask = firstMask = secondMask; + secondMask -= 1; + mask = firstMask - secondMask; int ret = (num & mask) >> (31 - end); return ret; } -char* getMaterial(int offset) +char* getMaterial(u16 offset) { if (offset == 0) return materials; @@ -140,12 +147,28 @@ char* getMaterial(int offset) if (offset > 1) { int n = 1; - for (n; n 1) + { + int n = 1; + for (n; n%s\n", sub); + printf(" %s\n", sub); #endif //OLD_BRLYT_OUTSTYLE offset += 16; } @@ -275,13 +339,13 @@ void PrintBRLYTEntry_txl1(brlyt_entry entry, u8* brlyt_file) #endif //OLD_BRLYT_OUTSTYLE BRLYT_fileoffset = tempLocation; int oldsize = sizeof(name); - dbgprintf("size of materials before: %08x\n", sizeof(materials)); - int newSize = lengthOfMaterials+sizeof(name); - materials = realloc(materials, newSize); - numberOfMaterials += 1; - memcpy(materials+lengthOfMaterials, name, sizeof(name)); - dbgprintf("mats: %s\tnamsize: %08x\tmatsize: %08x\tnewsize: %08x\n", materials+lengthOfMaterials, sizeof(name), lengthOfMaterials, newSize); - lengthOfMaterials = newSize; + 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"); @@ -351,9 +415,9 @@ void PrintBRLYTEntry_pan1(brlyt_entry entry, u8* brlyt_file) 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(" 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)); @@ -366,9 +430,9 @@ void PrintBRLYTEntry_pan1(brlyt_entry entry, u8* brlyt_file) printf(" %08x-%08x\n", data.flag1, data.flag2); printf(" %08x-%08x\n", data.alpha, data.alpha2); printf(" \n"); - printf(" %f\n", float_swap_bytes(data.x)); - printf(" %f\n", float_swap_bytes(data.y)); - printf(" %f\n", float_swap_bytes(data.z)); + 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)); @@ -466,9 +530,9 @@ void PrintBRLYTEntry_bnd1(brlyt_entry entry, u8* brlyt_file) printf(" %08x-%08x\n", data.flag1, data.flag2); printf(" %08x-%08x\n", data.alpha, data.alpha2); printf(" \n"); - printf(" %f\n", float_swap_bytes(data.x)); - printf(" %f\n", float_swap_bytes(data.y)); - printf(" %f\n", float_swap_bytes(data.z)); + 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)); @@ -516,9 +580,9 @@ void PrintBRLYTEntry_pic1(brlyt_entry entry, u8* brlyt_file) printf(" %08x-%08x\n", data.flag1, data.flag2); printf(" %08x-%08x\n", data.alpha, data.alpha2); printf(" \n"); - printf(" %f\n", float_swap_bytes(data.x)); - printf(" %f\n", float_swap_bytes(data.y)); - printf(" %f\n", float_swap_bytes(data.z)); + 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)); @@ -536,7 +600,7 @@ void PrintBRLYTEntry_pic1(brlyt_entry entry, u8* brlyt_file) #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", be16(data2.mat_off)); + 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 @@ -597,9 +661,9 @@ void PrintBRLYTEntry_txt1(brlyt_entry entry, u8* brlyt_file) printf(" %08x-%08x\n", data.flag1, data.flag2); printf(" %08x-%08x\n", data.alpha, data.alpha2); printf(" \n"); - printf(" %f\n", float_swap_bytes(data.x)); - printf(" %f\n", float_swap_bytes(data.y)); - printf(" %f\n", float_swap_bytes(data.z)); + 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)); @@ -614,12 +678,16 @@ void PrintBRLYTEntry_txt1(brlyt_entry entry, u8* brlyt_file) printf(" %f\n", float_swap_bytes(data.width)); printf(" %f\n", float_swap_bytes(data.height)); printf(" \n"); +// for (i;i%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.font_size_x)); 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 +// } } void PrintBRLYTEntry_mat1(brlyt_entry entry, u8* brlyt_file) @@ -692,13 +773,23 @@ void PrintBRLYTEntry_mat1(brlyt_entry entry, u8* brlyt_file) printf(" %#x\n", short_swap_bytes(data3.unk_color_2[1])); printf(" %#x\n", short_swap_bytes(data3.unk_color_2[2])); printf(" %#x\n", short_swap_bytes(data3.unk_color_2[3])); - printf(" %#x\n", short_swap_bytes(data3.tev_kcolor[0])); - printf(" %#x\n", short_swap_bytes(data3.tev_kcolor[1])); - printf(" %#x\n", short_swap_bytes(data3.tev_kcolor[2])); - printf(" %#x\n", short_swap_bytes(data3.tev_kcolor[3])); + printf(" %#x\n", be32(data3.tev_kcolor[0])); + printf(" %#x\n", be32(data3.tev_kcolor[1])); + printf(" %#x\n", be32(data3.tev_kcolor[2])); + printf(" %#x\n", be32(data3.tev_kcolor[3])); printf(" \n"); printf(" %08x\n", be32(data3.flags)); #endif //OLD_BRLYT_OUTSTYLE + + 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; + int n = 0; for (n;n\n", getMaterial(tplOffset)); + printf(" \n", getTexture(tplOffset)); printf(" %08x\n", data4.wrap_s); printf(" %08x\n", data4.wrap_t); printf(" \n"); @@ -726,13 +817,16 @@ void PrintBRLYTEntry_mat1(brlyt_entry entry, u8* brlyt_file) BRLYT_ReadDataFromMemory(&data4, brlyt_file, sizeof(brlyt_ua2_chunk)); #ifdef OLD_BRLYT_OUTSTYLE printf(" ua2: %08x, %08x, %08x, %08x, %08x\n", data4.unk[0], data4.unk[1], data4.unk[2], data4.unk[3], data4.unk[4]); + int s; for (s=0;s<20;s++) printf("%02x ", brlyt_file[BRLYT_fileoffset + s -20]); printf("\n"); + for (s=0;s<5;s++) printf("%f", float_swap_bytes(data4.unk[s])); + printf("\n"); #else printf(" \n"); - printf(" %08x\n", data4.unk[0]); - printf(" %08x\n", data4.unk[1]); - printf(" %08x\n", data4.unk[2]); - printf(" %08x\n", data4.unk[3]); - printf(" %08x\n", data4.unk[4]); + printf(" %f\n", float_swap_bytes(data4.unk[0])); + printf(" %f\n", float_swap_bytes(data4.unk[1])); + printf(" %f\n", float_swap_bytes(data4.unk[2])); + printf(" %f\n", float_swap_bytes(data4.unk[3])); + printf(" %f\n", float_swap_bytes(data4.unk[4])); printf(" \n"); #endif //OLD_BRLYT_OUTSTYLE } @@ -873,6 +967,7 @@ void PrintBRLYTEntry_mat1(brlyt_entry entry, u8* brlyt_file) printf(" %08x\n", data4.unk[12]); printf(" %08x\n", data4.unk[13]); printf(" %08x\n", data4.unk[14]); + printf(" %08x\n", data4.unk[15]); printf(" \n"); #endif //OLD_BRLYT_OUTSTYLE } @@ -888,7 +983,7 @@ void PrintBRLYTEntry_mat1(brlyt_entry entry, u8* brlyt_file) printf(" \n"); printf(" %08x\n", data4.unk[0]); printf(" %08x\n", data4.unk[1]); - printf(" %08x/\n", data4.unk[2]); + printf(" %08x\n", data4.unk[2]); printf(" %08x\n", data4.unk[3]); printf(" \n"); #endif //OLD_BRLYT_OUTSTYLE @@ -1024,6 +1119,9 @@ void parse_brlyt(char *filename) materials = (char*)malloc(12); numberOfMaterials = 0; lengthOfMaterials = 0; + textures = (char*)malloc(12); + numberOfTextures = 0; + lengthOfTextures = 0; FILE* fp = fopen(filename, "rb"); if(fp == NULL) { printf("Error! Couldn't open %s!\n", filename); @@ -1089,6 +1187,7 @@ void parse_brlyt(char *filename) #endif //OLD_BRLYT_OUTSTYLE free(materials); + free(textures); } @@ -1347,7 +1446,6 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl oldNameLength = lengthOfNames; lengthOfNames += strlen(tempSub); - //printf("name: %s\t", tempSub); offsunks = realloc(offsunks, (numEntries + 1)*(2 * sizeof(u32))); if (offsunks == NULL) printf("NULLed by a realloc\n"); @@ -1385,14 +1483,18 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl fseek(fp, *fileOffset, SEEK_SET); fwrite(names, lengthOfNames, 1, fp); *fileOffset = *fileOffset + lengthOfNames; - if ((*fileOffset % 2) == 1) + if ((*fileOffset % 4) > 0) { - char nuller = '\0'; - fwrite(&nuller, sizeof(char), 1, fp); - *fileOffset = *fileOffset + 1; + u8 toAdd = 4-(*fileOffset % 4); + char nuller[3] = {'\0', '\0', '\0'}; + fwrite(&nuller, sizeof(char), toAdd, fp); + *fileOffset = *fileOffset + toAdd; } - materials = malloc(lengthOfNames * sizeof(char)); - memcpy(materials, names, lengthOfNames * sizeof(char)); +// materials = malloc(lengthOfNames * sizeof(char)); +// memcpy(materials, names, lengthOfNames * sizeof(char)); +// free(names); + textures = malloc(lengthOfNames * sizeof(char)); + memcpy(textures, names, lengthOfNames * sizeof(char)); free(names); } if ( memcmp(temp, fnl1, sizeof(fnl1)) == 0) @@ -1463,11 +1565,12 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl fseek(fp, *fileOffset, SEEK_SET); fwrite(names, lengthOfNames, 1, fp); *fileOffset = *fileOffset + lengthOfNames; - if ((*fileOffset % 2) == 1) + if ((*fileOffset % 4) > 0) { - char nuller = '\0'; - fwrite(&nuller, sizeof(char), 1, fp); - *fileOffset = *fileOffset + 1; + u8 toAdd = 4-(*fileOffset % 4); + char nuller[3] = {'\0', '\0', '\0'}; + fwrite(&nuller, sizeof(char), toAdd, fp); + *fileOffset = *fileOffset + toAdd; } free(names); } @@ -1497,7 +1600,7 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl offsets[numberOfEntries] = be32(matSize + initialOffset); fwrite(&offsets[0], sizeof(int), actualNumber, fp); - *fileOffset = *fileOffset + numberOfEntries; + *fileOffset = *fileOffset + (actualNumber * 4); //changed from numberOfEntries for(subnode=mxmlFindElement(node,node,"entries",NULL,NULL,MXML_DESCEND);subnode!=NULL;subnode=mxmlFindElement(subnode,node,"entries",NULL,NULL,MXML_DESCEND)) { @@ -1518,6 +1621,11 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl memcpy(chunk.name, zeroed, 20 * sizeof(char)); 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) @@ -1566,7 +1674,6 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl get_value(valnode, tempCoord, 256); chunk.tev_kcolor[colorNumber] = be32(strtoul(tempCoord, NULL, 16)); - colorNumber+=1; } } @@ -1591,10 +1698,10 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl if(mxmlElementGetAttr(setnode, "name") != NULL) strcpy(temp, mxmlElementGetAttr(setnode, "name")); else{ - printf("No name attribute found!\nQuitting!\n"); + printf("No name attribute found!\nQuitting!\n"); exit(1); } - chunkTexRef.tex_offs = short_swap_bytes(findOffset(temp)); + chunkTexRef.tex_offs = short_swap_bytes(findTexOffset(temp)); valnode=mxmlFindElement(setnode, setnode, "wrap_s", NULL, NULL, MXML_DESCEND); @@ -1606,10 +1713,11 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl get_value(valnode, tempCoord, 256); chunkTexRef.wrap_t = strtoul(tempCoord, NULL, 16); + + fwrite(&chunkTexRef, sizeof(chunkTexRef), 1, fp); + *fileOffset = *fileOffset + sizeof(chunkTexRef); + matSize += sizeof(chunkTexRef); } - fwrite(&chunkTexRef, sizeof(chunkTexRef), 1, fp); - *fileOffset = *fileOffset + sizeof(chunkTexRef); - matSize += sizeof(chunkTexRef); brlyt_ua2_chunk chunkUa2; setnode = mxmlFindElement(subnode, subnode, "ua2", NULL, NULL, MXML_DESCEND); @@ -1623,7 +1731,7 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl get_value(valnode, tempCoord, 256); chunkUa2.unk[dataNumber] = float_swap_bytes(atof(tempCoord)); - + dataNumber+=1; } fwrite(&chunkUa2, sizeof(chunkUa2), 1, fp); @@ -1660,7 +1768,7 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl char tempCoord[256]; get_value(valnode, tempCoord, 256); - chunkUa3.unk[dataNumber] = strtoul(tempCoord, NULL, 16); + chunkUa4.unk[dataNumber] = strtoul(tempCoord, NULL, 16); dataNumber+=1; } @@ -1775,8 +1883,8 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl matSize += sizeof(chunkUa8); } brlyt_10b_chunk chunkUa9; - setnode = mxmlFindElement(subnode, subnode, "ua9", NULL, NULL, MXML_DESCEND); - if (setnode != NULL) + for (setnode = mxmlFindElement(subnode, subnode, "ua9", NULL, NULL, MXML_DESCEND); setnode != NULL; setnode = mxmlFindElement(setnode, subnode, "ua9", NULL, NULL, MXML_DESCEND)) +// if (setnode != NULL) { mxml_node_t *valnode; int dataNumber = 0; @@ -2230,7 +2338,8 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl } if ( memcmp(temp, txt1, sizeof(txt1)) == 0) { - brlyt_pane_chunk chunk; + brlyt_pane_chunk chunk; + brlyt_text_chunk chunk2; if(mxmlElementGetAttr(node, "name") != NULL) strcpy(temp, mxmlElementGetAttr(node, "name")); @@ -2243,6 +2352,7 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl for (j=0; j<24; j++) zeroed[j] = 0; memcpy(chunk.name, zeroed, 24 * sizeof(char)); strcpy(chunk.name, temp); + chunk2.mat_off = short_swap_bytes(findMatOffset(temp)); mxml_node_t *subnode = mxmlFindElement(node, node, "coords", NULL, NULL, MXML_DESCEND); if (subnode != NULL) @@ -2352,7 +2462,7 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl chunk.angle = float_swap_bytes(atof(tempCoord)); } - brlyt_text_chunk chunk2; +// brlyt_text_chunk chunk2; subnode = mxmlFindElement(node, node, "font", NULL, NULL, MXML_DESCEND); if (subnode != NULL) { @@ -2395,6 +2505,13 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl get_value(valnode, tempCoord, 256); chunk2.line_space = float_swap_bytes(atof(tempCoord)); } + valnode = mxmlFindElement(subnode, subnode, "unk", NULL, NULL, MXML_DESCEND); + if (valnode != NULL) + { + char tempCoord[256]; + get_value(valnode, tempCoord, 256); + chunk2.unk4 = strtol(tempCoord, NULL, 16); + } } subnode = mxmlFindElement(node, node, "length", NULL, NULL, MXML_DESCEND); @@ -2415,10 +2532,32 @@ void WriteBRLYTEntry(mxml_node_t *tree, mxml_node_t *node, u8** tagblob, u32* bl chunk2.color1 = be32(strtoul(tempCoord, NULL, 16)); chunk2.color2 = be32(strtoul(tempCoord+9, NULL, 16)); } + u8 textyLength = short_swap_bytes(chunk2.len2); + if ((textyLength % 4) != 0) + textyLength += (4 - (textyLength % 4)); + unsigned char texty[textyLength]; + subnode = mxmlFindElement(node, node, "text", NULL, NULL, MXML_DESCEND); + if (subnode != NULL) + { + char tempCoord[256]; + get_value(subnode, tempCoord, 256); + //memcpy(texty, tempCoord, short_swap_bytes(chunk2.len2)); + ASCIIfromUnicode(texty, tempCoord, short_swap_bytes(chunk2.len2)); + } fwrite(&chunk, sizeof(chunk), 1, fp); *fileOffset = *fileOffset + sizeof(chunk); + + chunk2.name_offs=be32(0x74); + chunk2.pad[0]= 0;chunk2.pad[1]=0;chunk2.pad[2]=0; fwrite(&chunk2, sizeof(chunk2), 1, fp); *fileOffset = *fileOffset + sizeof(chunk2); + int q; for (q=short_swap_bytes(chunk2.len2);q>8) | - (x<<8); + return (u16)(((x>>8)) | + ((x&0xff)<<8)); } u32 be32(u32 x) @@ -22,6 +22,29 @@ u32 be32(u32 x) (x<<24); } +u32 int_swap_bytes(u32 int1) +{ + unsigned char *int1c; int1c = (unsigned char*)&int1; + + unsigned char charTemp = 0x00; + charTemp = int1c[0]; int1c[0] = int1c[3]; int1c[3] = charTemp; + charTemp = 0x00; + charTemp = int1c[1]; int1c[1] = int1c[2]; int1c[2] = charTemp; + + u32 *newInt; newInt = (int*)int1c; + return *newInt; +} + +u16 short_swap_bytes(u16 short1) +{ + unsigned char* short1c; short1c = (unsigned char*)&short1; + unsigned char charTemp = 0x00; + charTemp = short1c[0]; short1c[0] = short1c[1]; short1c[1] = charTemp; + + unsigned short *newShort; newShort = (unsigned short*)short1c; + return *newShort; +} + // __int64 for MSVC, "long long" for gcc u64 be64(u64 x) { diff --git a/endian.h b/endian.h index 51ce90f..9876b08 100755 --- a/endian.h +++ b/endian.h @@ -11,6 +11,10 @@ u16 be16(u16 x); u32 be32(u32 x); +u16 short_swap_bytes(u16 short1); + +u32 int_swap_bytes(u32 int1); + // __int64 for MSVC, "long long" for gcc u64 be64(u64 x); diff --git a/general.h b/general.h index 7997654..32587e4 100644 --- a/general.h +++ b/general.h @@ -9,7 +9,7 @@ #define BENZIN_VERSION_MAJOR 0 #define BENZIN_VERSION_MINOR 1 -#define BENZIN_VERSION_BUILD 400 +#define BENZIN_VERSION_BUILD 500 #define BENZIN_VERSION_OTHER "WIP" #define INFORMATION_TEXT \ @@ -17,8 +17,8 @@ "Written by SquidMan (Alex Marshall), comex, and megazig.\n" \ "(c) 2009 HACKERCHANNEL\n", BENZIN_VERSION_MAJOR, BENZIN_VERSION_MINOR, BENZIN_VERSION_BUILD, BENZIN_VERSION_OTHER -#define USE_BRLAN -//#define USE_BRLYT +//#define USE_BRLAN +#define USE_BRLYT //#define OLD_BRLAN_OUTSTYLE //#define OLD_BRLYT_OUTSTYLE -- cgit v1.3.1