2012-05-06 12:59:58 +02:00
|
|
|
/*
|
|
|
|
Copyright (c) 2012 - Dimok
|
|
|
|
|
|
|
|
This software is provided 'as-is', without any express or implied
|
|
|
|
warranty. In no event will the authors be held liable for any damages
|
|
|
|
arising from the use of this software.
|
|
|
|
|
|
|
|
Permission is granted to anyone to use this software for any purpose,
|
|
|
|
including commercial applications, and to alter it and redistribute it
|
|
|
|
freely, subject to the following restrictions:
|
|
|
|
|
|
|
|
1. The origin of this software must not be misrepresented; you must not
|
|
|
|
claim that you wrote the original software. If you use this software
|
|
|
|
in a product, an acknowledgment in the product documentation would be
|
|
|
|
appreciated but is not required.
|
|
|
|
|
|
|
|
2. Altered source versions must be plainly marked as such, and must not be
|
|
|
|
misrepresented as being the original software.
|
|
|
|
|
|
|
|
3. This notice may not be removed or altered from any source
|
|
|
|
distribution.
|
|
|
|
*/
|
2010-12-27 10:44:27 +01:00
|
|
|
#ifndef OPENING_BNR_HPP_
|
|
|
|
#define OPENING_BNR_HPP_
|
|
|
|
|
|
|
|
#include <gctypes.h>
|
2012-05-06 12:59:58 +02:00
|
|
|
#include "usbloader/disc.h"
|
|
|
|
#include "CustomBanner.h"
|
|
|
|
|
|
|
|
typedef struct _GC_OpeningBnr
|
|
|
|
{
|
|
|
|
u32 magic; // BNR1 or BNR2
|
|
|
|
u8 pad[0x1C];
|
|
|
|
u8 tpl_data[0x1800]; // 96x32 pixel format GX_TF_RGB5A3
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
u8 disc_title[0x20]; // Gamename
|
|
|
|
u8 developer_short[0x20]; // Company/Developer
|
|
|
|
u8 full_title[0x40]; // Full Game Title
|
|
|
|
u8 developer[0x40]; // Company/Developer Full name, or description
|
|
|
|
u8 long_description[0x80]; // Game Description
|
|
|
|
} description[6]; // 6 only on BNR2 => English, German, French, Spanish, Italian, Dutch ??
|
|
|
|
} GC_OpeningBnr;
|
2010-12-27 10:44:27 +01:00
|
|
|
|
|
|
|
typedef struct _IMETHeader
|
|
|
|
{
|
2011-07-26 00:28:22 +02:00
|
|
|
u8 zeroes[64];
|
|
|
|
u32 fcc;
|
|
|
|
u8 unk[8];
|
|
|
|
u32 iconSize;
|
|
|
|
u32 bannerSize;
|
|
|
|
u32 soundSize;
|
|
|
|
u32 flag1;
|
|
|
|
u16 names[10][42]; // 10 languages (thanks dkosmari for the info)
|
|
|
|
u16 zeroes_2[7*42]; // padding for 7 more languages (thanks dkosmari for the info)
|
|
|
|
u8 crypto[16];
|
2010-12-27 10:44:27 +01:00
|
|
|
} __attribute__((packed)) IMETHeader;
|
|
|
|
|
2011-07-23 21:49:51 +02:00
|
|
|
typedef struct _IMD5Header
|
|
|
|
{
|
2011-07-26 00:28:22 +02:00
|
|
|
u32 fcc;
|
|
|
|
u32 filesize;
|
|
|
|
u8 zeroes[8];
|
|
|
|
u8 crypto[16];
|
2011-07-23 21:49:51 +02:00
|
|
|
} __attribute__((packed)) IMD5Header;
|
|
|
|
|
|
|
|
typedef struct _U8Header
|
|
|
|
{
|
2011-07-26 00:28:22 +02:00
|
|
|
u32 fcc;
|
|
|
|
u32 rootNodeOffset;
|
|
|
|
u32 headerSize;
|
|
|
|
u32 dataOffset;
|
|
|
|
u8 zeroes[16];
|
2011-07-23 21:49:51 +02:00
|
|
|
} __attribute__((packed)) U8Header;
|
|
|
|
|
|
|
|
typedef struct _U8Entry
|
|
|
|
{
|
2011-07-26 00:28:22 +02:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
u32 fileType :8;
|
|
|
|
u32 nameOffset :24;
|
|
|
|
};
|
|
|
|
u32 fileOffset;
|
|
|
|
union
|
|
|
|
{
|
|
|
|
u32 fileLength;
|
|
|
|
u32 numEntries;
|
|
|
|
};
|
2011-07-23 21:49:51 +02:00
|
|
|
} __attribute__( ( packed ) ) U8Entry;
|
|
|
|
|
|
|
|
|
|
|
|
static inline const char * u8Filename(const U8Entry *fst, int i)
|
|
|
|
{
|
2011-07-26 00:28:22 +02:00
|
|
|
return (char *) (fst + fst[0].numEntries) + fst[i].nameOffset;
|
2011-07-23 21:49:51 +02:00
|
|
|
}
|
|
|
|
|
2010-12-27 10:44:27 +01:00
|
|
|
class OpeningBNR
|
|
|
|
{
|
2011-07-26 00:28:22 +02:00
|
|
|
public:
|
|
|
|
OpeningBNR();
|
|
|
|
~OpeningBNR();
|
2012-05-06 12:59:58 +02:00
|
|
|
bool Load(const discHdr * header);
|
|
|
|
bool LoadWiiBanner(const discHdr * header);
|
|
|
|
bool LoadChannelBanner(const discHdr *header);
|
|
|
|
CustomBanner *CreateGCBanner(const discHdr * header);
|
|
|
|
CustomBanner *CreateGCIcon(const discHdr * header);
|
|
|
|
|
|
|
|
const u8 * Get() const { return (const u8*) imetHdr; }
|
|
|
|
u32 GetSize() const { return filesize; }
|
|
|
|
|
|
|
|
bool LoadCachedBNR(const char *id);
|
|
|
|
void WriteCachedBNR(const char *id, const u8 *buffer, u32 size);
|
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
const u16 * GetIMETTitle(int lang);
|
2012-05-06 12:59:58 +02:00
|
|
|
const u16 * GetIMETTitle(const discHdr * header, int lang) { Load(header); return GetIMETTitle(lang); }
|
2011-07-26 00:28:22 +02:00
|
|
|
private:
|
2012-05-06 12:59:58 +02:00
|
|
|
u8 *LoadGCBNR(const discHdr * header, u32 *len = 0);
|
2011-07-26 00:28:22 +02:00
|
|
|
IMETHeader *imetHdr;
|
2012-05-06 12:59:58 +02:00
|
|
|
u32 filesize;
|
2011-07-26 00:28:22 +02:00
|
|
|
char gameID[7];
|
2010-12-27 10:44:27 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
class BNRInstance : public OpeningBNR
|
|
|
|
{
|
2011-07-26 00:28:22 +02:00
|
|
|
public:
|
2012-05-06 12:59:58 +02:00
|
|
|
static BNRInstance * Instance() { if(!instance) instance = new BNRInstance; return instance; }
|
|
|
|
static void DestroyInstance() { delete instance; instance = NULL; }
|
2011-07-26 00:28:22 +02:00
|
|
|
private:
|
2012-05-06 12:59:58 +02:00
|
|
|
BNRInstance() { }
|
|
|
|
~BNRInstance() { }
|
2011-07-26 00:28:22 +02:00
|
|
|
static BNRInstance * instance;
|
2010-12-27 10:44:27 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|