*Removed brlan/brlyt source because it was copyright.

This commit is contained in:
dimok321 2009-08-01 07:53:05 +00:00
parent 8fef0223c5
commit 4930c698d3
4 changed files with 0 additions and 726 deletions

View File

@ -1,214 +0,0 @@
/*
* brlan.c
* BannerPlayer
*
* Created by Alex Marshall on 09/03/16.
* Copyright 2009 __MyCompanyName__. All rights reserved.
*
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "brlan.h"
//#include "endian.h"
char* BRLAN_rootpath = NULL;
u8* BRLAN_file = NULL;
u32 BRLAN_filesize = 0;
u8* BRLAN_startfile = NULL;
u32 BRLAN_startfilesize = 0;
int BRLAN_looping = 0;
void BRLAN_Initialize(char rootpath[])
{
char brlanpath[256];
sprintf(brlanpath, "%s/arc/anim/banner.brlan", rootpath);
FILE* fp = fopen(brlanpath, "rb");
if(fp == NULL) {
fprintf(stderr, "Couldn't find banner.brlan. Let's assume it's a looping banner then.\n");
BRLAN_looping = 1;
sprintf(brlanpath, "%s/arc/anim/banner_start.brlan", rootpath);
fp = fopen(brlanpath, "rb");
if(fp == NULL) {
fprintf(stderr, "No BRLAN file found. Quitting.\n");
exit(1);
}
fseek(fp, 0, SEEK_END);
BRLAN_startfilesize = ftell(fp);
fseek(fp, 0, SEEK_SET);
fread(BRLAN_startfile, BRLAN_startfilesize, 1, fp);
fclose(fp);
sprintf(brlanpath, "%s/arc/anim/banner_loop.brlan", rootpath);
fp = fopen(brlanpath, "rb");
if(fp == NULL) {
fprintf(stderr, "No BRLAN file found. Quitting.\n");
exit(1);
}
}else
BRLAN_looping = 0;
fseek(fp, 0, SEEK_END);
BRLAN_filesize = ftell(fp);
fseek(fp, 0, SEEK_SET);
fread(BRLAN_file, BRLAN_filesize, 1, fp);
fclose(fp);
}
#define MAXIMUM_TAGS_SIZE (0x1000)
fourcc tag_FourCCs[] = { "RLPA", "RLTS", "RLVI", "RLVC", "RLMC", "RLTP" };
static size_t BRLAN_fileoffset = 0;
static void BRLAN_ReadDataFromMemoryX(void* destination, void* input, size_t size)
{
u8* out = (u8*)destination;
u8* in = ((u8*)input) + BRLAN_fileoffset;
memcpy(out, in, size);
}
static void BRLAN_ReadDataFromMemory(void* destination, void* input, size_t size)
{
BRLAN_ReadDataFromMemoryX(destination, input, size);
BRLAN_fileoffset += size;
}
static void CreateGlobal_pai1(brlan_pai1_header_type2 *pai1_header, brlan_pai1_header_type1 pai1_header1,
brlan_pai1_header_type2 pai1_header2, int pai1_header_type)
{
if(pai1_header_type == 1) {
pai1_header->magic[0] = pai1_header1.magic[0];
pai1_header->magic[1] = pai1_header1.magic[1];
pai1_header->magic[2] = pai1_header1.magic[2];
pai1_header->magic[3] = pai1_header1.magic[3];
pai1_header->size = pai1_header1.size;
pai1_header->framesize = pai1_header1.framesize;
pai1_header->flags = pai1_header1.flags;
pai1_header->unk1 = pai1_header1.unk1;
pai1_header->num_timgs = pai1_header1.num_timgs;
pai1_header->num_entries = pai1_header1.num_entries;
pai1_header->unk2 = 0;
pai1_header->entry_offset = pai1_header1.entry_offset;
}else
memcpy(pai1_header, &pai1_header2, sizeof(brlan_pai1_header_type2));
}
static int FourCCsMatch(fourcc cc1, fourcc cc2)
{
if((cc1[0] == cc2[0]) && (cc1[1] == cc2[1]) && (cc1[2] == cc2[2]) && (cc1[3] == cc2[3]))
return 1;
else
return 0;
}
static int FourCCInList(fourcc cc)
{
int i;
for(i = 0; i < 6; i++)
if(FourCCsMatch(cc, tag_FourCCs[i])) return 1;
return 0;
}
static void ReadTagFromBRLAN(BRLAN_animation **anims, int idx)
{
int taghead_location = BRLAN_fileoffset;
tag_header head;
tag_entry* entries;
tag_entryinfo* entryinfo;
BRLAN_ReadDataFromMemory(&head, BRLAN_file, sizeof(tag_header));
memcpy(anims[idx]->type, head.magic, 4);
anims[idx]->entrycount = head.entry_count;
int i, z;
entries = (tag_entry*)calloc(anims[idx]->entrycount, sizeof(tag_entry));
entryinfo = (tag_entryinfo*)calloc(anims[idx]->entrycount, sizeof(tag_entryinfo));
for(i = 0; i < anims[idx]->entrycount; i++) {
BRLAN_ReadDataFromMemory(&entries[i], BRLAN_file, sizeof(tag_entry));
}
for(i = 0; i < anims[idx]->entrycount; i++) {
BRLAN_fileoffset = be32(entries[i].offset) + taghead_location;
BRLAN_ReadDataFromMemory(&entryinfo[i], BRLAN_file, sizeof(tag_entryinfo));
anims[idx]->entries[i].animtype = be16(entryinfo[i].type);
anims[idx]->entries[i].tripletcount = be16(entryinfo[i].coord_count);
for(z = 0; z < be16(entryinfo[i].coord_count); z++) {
BRLAN_ReadDataFromMemory(&anims[idx]->entries[i].triplets[z], BRLAN_file, sizeof(f32) * 3);
anims[idx]->entries[i].triplets[z].frame = le32(anims[idx]->entries[i].triplets[z].frame);
anims[idx]->entries[i].triplets[z].value = le32(anims[idx]->entries[i].triplets[z].value);
anims[idx]->entries[i].triplets[z].blend = le32(anims[idx]->entries[i].triplets[z].blend);
}
}
free(entries);
free(entryinfo);
}
u16 BRLAN_ReadAnimations(BRLAN_animation **anims)
{
BRLAN_fileoffset = 0;
brlan_header header;
BRLAN_ReadDataFromMemoryX(&header, BRLAN_file, sizeof(brlan_header));
BRLAN_fileoffset = be16(header.pai1_offset);
brlan_pai1_universal universal;
BRLAN_ReadDataFromMemoryX(&universal, BRLAN_file, sizeof(brlan_pai1_universal));
int pai1_header_type;
brlan_pai1_header_type1 pai1_header1;
brlan_pai1_header_type2 pai1_header2;
brlan_pai1_header_type2 pai1_header;
if((be32(universal.flags) & (1 << 25)) >= 1) {
pai1_header_type = 2;
BRLAN_ReadDataFromMemory(&pai1_header2, BRLAN_file, sizeof(brlan_pai1_header_type2));
} else {
pai1_header_type = 1;
BRLAN_ReadDataFromMemory(&pai1_header1, BRLAN_file, sizeof(brlan_pai1_header_type1));
}
CreateGlobal_pai1(&pai1_header, pai1_header1, pai1_header2, pai1_header_type);
int tagcount = be16(pai1_header.num_entries);
u32 *taglocations = (u32*)calloc(tagcount, sizeof(u32));
*anims = (BRLAN_animation*)calloc(tagcount, sizeof(BRLAN_animation));
fourcc CCs[256];
memset(CCs, 0, 256*4);
BRLAN_fileoffset = be32(pai1_header.entry_offset) + be16(header.pai1_offset);
BRLAN_ReadDataFromMemory(taglocations, BRLAN_file, tagcount * sizeof(u32));
int animcnt = 1;
int i;
for(i = 0; i < tagcount; i++) {
BRLAN_fileoffset = be32(taglocations[i]) + be16(header.pai1_offset);
brlan_entry tmpentry;
BRLAN_ReadDataFromMemory(&tmpentry, BRLAN_file, sizeof(brlan_entry));
if((be32(tmpentry.flags) & (1 << 25)) >= 1)
BRLAN_fileoffset += sizeof(u32);
memcpy(anims[animcnt]->name, tmpentry.name, 20);
fourcc magick;
BRLAN_ReadDataFromMemoryX(magick, BRLAN_file, 4);
memcpy(CCs[i], magick, 4);
if(FourCCInList(CCs[i]) == 1) {
anims[animcnt]->offset = BRLAN_fileoffset;
ReadTagFromBRLAN(anims, animcnt);
animcnt++;
}
}
return tagcount;
}
void BRLAN_Finish()
{
if(BRLAN_file != NULL)
free(BRLAN_file);
if(BRLAN_startfile != NULL)
free(BRLAN_startfile);
}

View File

@ -1,146 +0,0 @@
/*
* brlan.h
* BannerPlayer
*
* Created by Alex Marshall on 09/03/16.
* Copyright 2009 __MyCompanyName__. All rights reserved.
*
*/
#ifndef _BRLAN_H_
#define _BRLAN_H_
#include <gctypes.h>
typedef char fourcc[4];
#define le16 be16
#define le32 be32
#define le64 be64
u16 be16(u16 x);
u32 be32(u32 x);
u64 be64(u64 x);
typedef enum
{
RLPA_ENTRY = 0,
RLTS_ENTRY = 1,
RLVI_ENTRY = 2,
RLVC_ENTRY = 3,
RLMC_ENTRY = 4,
RLTP_ENTRY = 5
} brlan_entry_type;
typedef struct
{
fourcc magic; // "pai1" in ASCII.
u32 size; // Size of section, which is rest of the file. (header.file_size - header.offset_pai1)
u16 framesize; // Framesize
u8 flags; // Flags
u8 unk1; // Unknown
u16 num_timgs; // Number of timgs?
u16 num_entries; // Number of tags in the brlan.
u32 unk2; // Only if bit 25 of flags is set.
u32 entry_offset; // Offset to entries. (Relative to start of pai1 header.)
} brlan_pai1_header_type2;
typedef struct
{
fourcc magic; // "RLAN" in ASCII.
u32 unk1; // Always 0xFEFF 0x0008. Possibly a versioning string.
u32 file_size; // Size of whole file, including the header.
u16 pai1_offset; // The offset to the pai1 header from the start of file.
u16 pai1_count; // How many pai1 sections there are (duh, only 1... wtf?)
} brlan_header;
typedef struct
{
fourcc magic; // "pai1" in ASCII.
u32 size; // Size of section, which is rest of the file. (header.file_size - header.offset_pai1)
u16 framesize; // Framesize
u8 flags; // Flags
u8 unk1; // Unknown
u16 num_timgs; // Number of timgs?
u16 num_entries; // Number of tags in the brlan.
} brlan_pai1_universal;
typedef struct
{
fourcc magic; // "pai1" in ASCII.
u32 size; // Size of section, which is rest of the file. (header.file_size - header.offset_pai1)
u16 framesize; // Framesize
u8 flags; // Flags
u8 unk1; // Unknown
u16 num_timgs; // Number of timgs?
u16 num_entries; // Number of tags in the brlan.
u32 entry_offset; // Offset to entries. (Relative to start of pai1 header.)
} brlan_pai1_header_type1;
typedef struct
{
char name[20]; // Name of the BRLAN entry. (Must be defined in the BRLYT)
u32 flags; // Flags? (If bit 25 is set, we have another u32 after the entry. It's use is unknown.)
u32 anim_header_len; // Length of the animation header which is directly after this entry.
} brlan_entry;
typedef struct
{
fourcc magic;
u8 entry_count; // How many entries in this chunk.
u8 pad1; // All cases I've seen is zero.
u8 pad2; // All cases I've seen is zero.
u8 pad3; // All cases I've seen is zero.
} tag_header;
typedef struct
{
u32 offset; // Offset to the data pointed to by this entry.
// Relative to the start of the RLPA header.
} tag_entry;
typedef struct
{
u16 type; // Type (look at animtypes)
u16 unk1; // ??? Every case has been 0x0200
u16 coord_count; // How many coordinates.
u16 pad1; // All cases I've seen is zero.
u32 unk2; // ??? In every case I've seen, it is 0x0000000C.
} tag_entryinfo;
typedef struct
{ // Bits not listed here are currently unknown.
u32 part1; // If Bit 9 is set in flags, this is an f32, with a coordinate. (Bit 17 seems to act the same)
u32 part2; // If Bit 16 is set in flags, this is an f32, with another coordinate. (Bit 17 seems to act the same)
u32 part3; // With Bit 16 set in flags, this seems to be yet another coordinate. (Bit 17 seems to act the same)
} tag_data;
typedef struct BRLAN_trip
{
f32 frame; // Frame number.
f32 value; // Value at the frame.
f32 blend; // Interpolation value.
} BRLAN_triplets;
typedef struct BRLAN_entr
{
u16 animtype; // What subtype of animation.
u16 tripletcount; // Number of triplets.
BRLAN_triplets triplets[20]; // Shouldn't ever be more than 20.
} BRLAN_entries;
typedef struct BRLAN_anims
{
char type[4]; // The type of animation (FourCC from BRLAN file)
char name[20]; // Name.
u32 offset; // Offset into the BRLAN file to find this animation.
u16 entrycount; // How many entries.
BRLAN_entries entries[20]; // The entries. Shouldn't ever be more than 20.
} BRLAN_animation;
void BRLAN_Initialize(char rootpath[]);
u16 BRLAN_ReadAnimations(BRLAN_animation **anims);
void BRLAN_Finish();
#endif //_BRLAN_H_

View File

@ -1,213 +0,0 @@
/*
* brlyt.h
* Parses brlyt file
*
* by nIxx
* http://wiibrew.org/wiki/Wii_Animations#Textures_and_Material_lists_.28.2A.brlyt.29
*
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <fat.h>
#include "brlyt.h"
#include "openingbnr.h"
brlyt_header brlytheader;
lyt1_header lyt1header;
txl1_header txl1header;
txl1_offset **txl1offsets;
tpl_files **tplss;
mat1_header mat1header;
mat1_offset **mat1offsets;
mat1_material **mat1materials;
pic1_header **pic1header;
pae1_header pae1header;
grp1_header grp1header;
int BRLYT_Initialize(const char *rootpath)
{
//fatInitDefault();
FILE * fp = fopen(rootpath,"rb");
if (fp == NULL) return 0;
fread((void*)&brlytheader,1,sizeof(brlytheader),fp);
fread((void*)&lyt1header,1,sizeof(lyt1header),fp);
fread((void*)&txl1header,1,sizeof(txl1header),fp);
//printf("Filesize: %i\n",be32((u8*)&brlytheader.file_size));
//printf("Num Textures: %i\n",be16((u8*)&txl1header.num_textures));
txl1offsets = (txl1_offset**)malloc(sizeof(txl1_offset*)*be16((u8*)&txl1header.num_textures));
if(txl1offsets == NULL)
{
fprintf(stderr, "out of memory\n");
return 0;
}
int i = 0;
for(i = 0; i < be16((u8*)&txl1header.num_textures); i++)
{
txl1offsets[i] = (txl1_offset*)malloc(sizeof(txl1_offset));
if(txl1offsets[i] == NULL)
{
fprintf(stderr, "out of memory\n");
return 0;
}
fread(txl1offsets[i],1,sizeof(*txl1offsets[i]),fp);
//printf("Offset Filename: %i\n",be32((u8*)&txl1offsets[i]->offset_filename));
}
tplss = (tpl_files**)malloc(sizeof(tpl_files*)*be16((u8*)&txl1header.num_textures));
if(tplss == NULL)
{
fprintf(stderr, "out of memory\n");
return 0;
}
for(i = 0; i < be16((u8*)&txl1header.num_textures); i++)
{
tplss[i] = (tpl_files*)malloc(sizeof(tpl_files));
if(tplss[i] == NULL)
{
fprintf(stderr, "out of memory\n");
return 0;
}
fseek(fp,0x30+ be32((u8*)&txl1offsets[i]->offset_filename),SEEK_SET);
fread(tplss[i],1,sizeof(*tplss[i]),fp);
//printf("%i. Filename: %s\n",i,tplss[i]->tplfilename);
}
fseek(fp,0x10+be32((u8*)&lyt1header.size_header)+be32((u8*)&txl1header.size_section),SEEK_SET);
mat1_header mat1header;
fread((void*)&mat1header,1,sizeof(mat1header),fp);
//printf("Sig: %s SizeHeader:%i Num materials%i\n",mat1header.sig ,be32((u8*)&mat1header.size_section) ,be16((u8*)&mat1header.num_materials) );
mat1_offset **mat1offsets = (mat1_offset**)malloc(sizeof(mat1_offset*)*be16((u8*)&mat1header.num_materials));
if(mat1offsets == NULL)
{
fprintf(stderr, "out of memory\n");
return 0;
}
for(i = 0; i < be16((u8*)&mat1header.num_materials); i++)
{
mat1offsets[i] = (mat1_offset*)malloc(sizeof(mat1_offset));
if(mat1offsets[i] == NULL)
{
fprintf(stderr, "out of memory\n");
return 0;
}
fread(mat1offsets[i],1,sizeof(*mat1offsets[i]),fp);
//printf("%i. Material Offset: %X\n",i,be32((u8*)&mat1offsets[i]->offset));
}
mat1materials = (mat1_material**)malloc(sizeof(mat1_material*)*be16((u8*)&mat1header.num_materials));
if(mat1materials == NULL)
{
fprintf(stderr, "out of memory\n");
return 0;
}
for(i = 0; i < be16((u8*)&mat1header.num_materials); i++)
{
mat1materials[i] = (mat1_material*)malloc(sizeof(mat1_material));
if(mat1materials[i] == NULL)
{
fprintf(stderr, "out of memory\n");
return 0;
}
fseek(fp,0x10+be32((u8*)&lyt1header.size_header)+be32((u8*)&txl1header.size_section)+be32((u8*)&mat1offsets[i]->offset),SEEK_SET);
fread(mat1materials[i],1,sizeof(*mat1materials[i]),fp);
//printf("%i. Material Names: %s\n",i,mat1materials[i]->name);
}
fseek(fp,0x10+be32((u8*)&lyt1header.size_header)+be32((u8*)&txl1header.size_section)+be32((u8*)&mat1header.size_section),SEEK_SET);
pan1_header pan1header;
fread((void*)&pan1header,1,sizeof(pan1header),fp);
pas1_header pas1header;
fread((void*)&pas1header,1,sizeof(pas1header),fp);
pic1_header **pic1header = (pic1_header**)malloc(sizeof(pic1_header*)*be16((u8*)&mat1header.num_materials));
if(pic1header == NULL)
{
fprintf(stderr, "out of memory\n");
return 0;
}
for(i = 0; i < be16((u8*)&mat1header.num_materials); i++)
{
pic1header[i] = (pic1_header*)malloc(sizeof(pic1_header));
if(pic1header[i] == NULL)
{
fprintf(stderr, "out of memory\n");
return 0;
}
fpos_t pos;
fgetpos(fp,&pos);
fread(pic1header[i],1,sizeof(*pic1header[i]),fp);
fseek(fp,pos+be32((u8*)&pic1header[i]->size_section),SEEK_SET);
// printf("%i. Pic1 Names: %s\n",i,pic1header[i]->name);
}
fread((void*)&pae1header,1,sizeof(pae1header),fp);
fread((void*)&grp1header,1,sizeof(grp1header),fp);
//Close File
fclose(fp);
return 1;
}
int BRLYT_ReadObjects(BRLYT_object** objs)
{
return 0;
}
void BRLYT_Finish()
{
}
void BRLYT_FreeMem()
{
int i = 0;
//free memory
for(i = 0; i < be16((u8*)&txl1header.num_textures); i++)
free(txl1offsets[i]);
free(txl1offsets);
for(i = 0; i < be16((u8*)&txl1header.num_textures); i++)
free(tplss[i]);
free(tplss);
for(i = 0; i < be16((u8*)&mat1header.num_materials); i++)
free(mat1offsets[i]);
free(mat1offsets);
for(i = 0; i < be16((u8*)&mat1header.num_materials); i++)
free(mat1materials[i]);
free(mat1materials);
for(i = 0; i < be16((u8*)&mat1header.num_materials); i++)
free(pic1header[i]);
free(pic1header);
}

View File

@ -1,153 +0,0 @@
/*
* brlyt.h
* Parses brlyt file
*
* by nIxx
* Infos: http://wiibrew.org/wiki/Wii_Animations#Textures_and_Material_lists_.28.2A.brlyt.29
*
*/
#ifndef _BRLYT_H_
#define _BRLYT_H_
#include <gctypes.h>
#ifdef __cplusplus
extern "C"
{
#endif
int BRLYT_Initialize(const char *rootpath);
typedef struct BRLYT_objs
{
char type[4]; // The type of object (FourCC from BRLYT file)
u32 offset; // Offset into the BRLYT file to find this object.
} BRLYT_object;
int BRLYT_ReadObjects(BRLYT_object** objs);
void BRLYT_Finish();
typedef struct
{
char sig [4]; // "RLYT" in ASCII
u32 unk; // Always 0xFE 0xFF 0x 00 0x08.
u32 file_size; // Size of whole file, including the header.
u32 num; // number of sections
} brlyt_header;
typedef struct
{
char sig [4]; // "lyt1" in ASCII.
u32 size_header;
u32 a;
u32 width;
u32 height;
} lyt1_header;
typedef struct
{
char sig [4]; // "txl1" in ASCII.
u32 size_section; // Size of the whole section.
u16 num_textures; // Number of textures in list.
u16 unk2; // Always zero?
} txl1_header;
typedef struct
{
u32 offset_filename; // Offset to a null-terminated ASCII string containing the filename.
// The offset-base should be after the txl1-header.
u32 unk; // Always zero?
} txl1_offset;
typedef struct
{
char sig [4]; // "mat1" in ASCII.
u32 size_section; // // Size of the whole section.
u16 num_materials; //
u16 size_header; // Offset to list start. Always zero
} mat1_header;
typedef struct
{
u32 offset; // Offset from beginning of mat1-section.
} mat1_offset;
typedef struct
{
char name[20];
s16 black_color[4];
s16 white_color[4];
s16 unk_color_2[4];
u32 tev_kcolor[4];
u32 flags;
} mat1_material;
typedef struct
{
char sig [4]; // "pan1" in ASCII.
u32 size_section;
u16 flag;
u16 alpha;
char pane_name [0x18]; // Pane name in ASCII.
float x;
float y;
float z;
float xFlip;
float yFlip;
float zFlip; //rotate
float xMag; //Zoom
float yMag;
float width;
float height;
} pan1_header;
typedef struct
{
char sig [4]; // "pas1" in ASCII.
u32 size_section;
} pas1_header;
typedef struct
{
char sig [4]; // "pic1" in ASCII.
u32 size_section;
u16 flags;
u16 alpha;
char name[0x18];
float x;
float y;
float z;
float xFlip;
float yFlip;
float zFlip; //rotate
float xMag;
float yMag; //zoom
float width;
float height;
} pic1_header;
typedef struct
{
char sig [4]; // "pae1" in ASCII.
u32 size_section;
} pae1_header;
typedef struct {
char sig [4]; // "grp1" in ASCII.
u32 size_section;
char name[16];
u16 numsubs;
u16 unk1;
} grp1_header;
typedef struct
{
char tplfilename[40];
} tpl_files;
#ifdef __cplusplus
}
#endif
#endif //_BRLYT_H_