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.
|
|
|
|
*/
|
2020-12-12 22:35:12 +01:00
|
|
|
#if __GNUC__ > 8
|
|
|
|
#pragma GCC diagnostic ignored "-Waddress-of-packed-member"
|
|
|
|
#endif
|
|
|
|
|
2010-12-27 10:44:27 +01:00
|
|
|
#include <malloc.h>
|
|
|
|
#include <stdio.h>
|
2011-11-13 10:09:27 +01:00
|
|
|
#include "Channels/channels.h"
|
2012-05-06 12:59:58 +02:00
|
|
|
#include "GameCube/GCGames.h"
|
|
|
|
#include "libs/libwbfs/gcdisc.h"
|
|
|
|
#include "FileOperations/fileops.h"
|
|
|
|
#include "language/gettext.h"
|
2010-12-27 10:44:27 +01:00
|
|
|
#include "usbloader/disc.h"
|
|
|
|
#include "usbloader/wbfs.h"
|
2012-05-06 12:59:58 +02:00
|
|
|
#include "usbloader/wdvd.h"
|
|
|
|
#include "usbloader/wbfs/wbfs_rw.h"
|
2020-07-09 03:11:20 +02:00
|
|
|
#include "utils/sjis.h"
|
2010-12-27 10:44:27 +01:00
|
|
|
#include "utils/uncompress.h"
|
2012-05-06 12:59:58 +02:00
|
|
|
#include "themes/CTheme.h"
|
|
|
|
#include "settings/GameTitles.h"
|
|
|
|
#include "wstring.hpp"
|
2010-12-27 10:44:27 +01:00
|
|
|
#include "OpeningBNR.hpp"
|
|
|
|
|
2021-08-01 19:00:20 +02:00
|
|
|
BNRInstance *BNRInstance::instance = NULL;
|
2010-12-27 10:44:27 +01:00
|
|
|
|
|
|
|
OpeningBNR::OpeningBNR()
|
2012-05-06 12:59:58 +02:00
|
|
|
: imetHdr(0), filesize(0)
|
2010-12-27 10:44:27 +01:00
|
|
|
{
|
|
|
|
memset(gameID, 0, sizeof(gameID));
|
|
|
|
}
|
|
|
|
|
|
|
|
OpeningBNR::~OpeningBNR()
|
|
|
|
{
|
2021-08-01 19:00:20 +02:00
|
|
|
if (imetHdr)
|
2011-07-26 00:28:22 +02:00
|
|
|
free(imetHdr);
|
2010-12-27 10:44:27 +01:00
|
|
|
}
|
|
|
|
|
2012-05-06 12:59:58 +02:00
|
|
|
bool OpeningBNR::LoadCachedBNR(const char *id)
|
2011-11-13 10:09:27 +01:00
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
char path[255];
|
|
|
|
snprintf(path, sizeof(path), "%s%.6s.bnr", Settings.BNRCachePath, id);
|
2021-08-01 19:00:20 +02:00
|
|
|
if ((filesize = FileSize(path)) == 0)
|
2012-05-06 12:59:58 +02:00
|
|
|
{
|
|
|
|
snprintf(path, sizeof(path), "%s%.3s.bnr", Settings.BNRCachePath, id);
|
2021-08-01 19:00:20 +02:00
|
|
|
if ((filesize = FileSize(path)) == 0)
|
2012-05-06 12:59:58 +02:00
|
|
|
return false;
|
|
|
|
}
|
2011-11-13 10:09:27 +01:00
|
|
|
|
2012-05-06 12:59:58 +02:00
|
|
|
FILE *f = fopen(path, "rb");
|
2021-08-01 19:00:20 +02:00
|
|
|
if (!f)
|
2012-05-06 12:59:58 +02:00
|
|
|
return false;
|
2011-11-13 10:09:27 +01:00
|
|
|
|
2021-08-01 19:00:20 +02:00
|
|
|
imetHdr = (IMETHeader *)malloc(filesize);
|
|
|
|
if (!imetHdr)
|
2012-05-06 12:59:58 +02:00
|
|
|
{
|
|
|
|
fclose(f);
|
2011-11-13 10:09:27 +01:00
|
|
|
return false;
|
2012-05-06 12:59:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
fread(imetHdr, 1, filesize, f);
|
|
|
|
fclose(f);
|
2011-11-13 10:09:27 +01:00
|
|
|
|
|
|
|
if (imetHdr->fcc != 'IMET')
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
//! check if it's a channel .app file
|
|
|
|
IMETHeader *channelImet = (IMETHeader *)(((u8 *)imetHdr) + 0x40);
|
2021-08-01 19:00:20 +02:00
|
|
|
if (channelImet->fcc != 'IMET')
|
2012-05-06 12:59:58 +02:00
|
|
|
{
|
|
|
|
free(imetHdr);
|
|
|
|
imetHdr = NULL;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
//! just move it 0x40 bytes back, the rest 0x40 bytes will just be unused
|
|
|
|
//! as it's a temporary file usually it's not worth to reallocate
|
|
|
|
filesize -= 0x40;
|
|
|
|
memcpy(imetHdr, channelImet, filesize);
|
2011-11-13 10:09:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-05-06 12:59:58 +02:00
|
|
|
void OpeningBNR::WriteCachedBNR(const char *id, const u8 *buffer, u32 size)
|
|
|
|
{
|
|
|
|
char path[255];
|
|
|
|
snprintf(path, sizeof(path), "%s%.6s.bnr", Settings.BNRCachePath, id);
|
|
|
|
|
|
|
|
CreateSubfolder(Settings.BNRCachePath);
|
|
|
|
|
|
|
|
FILE *f = fopen(path, "wb");
|
2021-08-01 19:00:20 +02:00
|
|
|
if (!f)
|
2012-05-06 12:59:58 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
fwrite(buffer, 1, size, f);
|
|
|
|
fclose(f);
|
|
|
|
}
|
|
|
|
|
2021-08-01 19:00:20 +02:00
|
|
|
bool OpeningBNR::Load(const discHdr *header)
|
2010-12-27 10:44:27 +01:00
|
|
|
{
|
2021-08-01 19:00:20 +02:00
|
|
|
if (!header)
|
2011-07-26 00:28:22 +02:00
|
|
|
return false;
|
2010-12-27 10:44:27 +01:00
|
|
|
|
2021-08-01 19:00:20 +02:00
|
|
|
if (memcmp(gameID, header->id, 6) == 0)
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
2010-12-27 10:44:27 +01:00
|
|
|
|
2012-05-06 12:59:58 +02:00
|
|
|
memcpy(gameID, header->id, 6);
|
2011-11-13 10:09:27 +01:00
|
|
|
|
2021-08-01 19:00:20 +02:00
|
|
|
if (imetHdr)
|
2011-07-26 00:28:22 +02:00
|
|
|
free(imetHdr);
|
|
|
|
imetHdr = NULL;
|
2010-12-27 10:44:27 +01:00
|
|
|
|
2021-08-01 19:00:20 +02:00
|
|
|
switch (header->type)
|
2012-05-06 12:59:58 +02:00
|
|
|
{
|
|
|
|
case TYPE_GAME_WII_IMG:
|
|
|
|
case TYPE_GAME_WII_DISC:
|
|
|
|
return LoadWiiBanner(header);
|
|
|
|
case TYPE_GAME_NANDCHAN:
|
|
|
|
case TYPE_GAME_EMUNANDCHAN:
|
|
|
|
return LoadChannelBanner(header);
|
|
|
|
case TYPE_GAME_GC_IMG:
|
|
|
|
case TYPE_GAME_GC_DISC:
|
|
|
|
case TYPE_GAME_GC_EXTRACTED:
|
2021-08-01 19:00:20 +02:00
|
|
|
if (!Settings.CacheBNRFiles)
|
2012-05-06 12:59:58 +02:00
|
|
|
return false;
|
|
|
|
return LoadCachedBNR((char *)header->id);
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-08-01 19:00:20 +02:00
|
|
|
bool OpeningBNR::LoadWiiBanner(const discHdr *header)
|
2012-05-06 12:59:58 +02:00
|
|
|
{
|
2021-08-01 19:00:20 +02:00
|
|
|
if (!header || ((header->type != TYPE_GAME_WII_IMG) && (header->type != TYPE_GAME_WII_DISC)))
|
2011-07-26 00:28:22 +02:00
|
|
|
return false;
|
2010-12-27 10:44:27 +01:00
|
|
|
|
2021-08-01 19:00:20 +02:00
|
|
|
if (Settings.CacheBNRFiles && LoadCachedBNR((const char *)header->id))
|
2012-05-06 12:59:58 +02:00
|
|
|
return true;
|
|
|
|
|
2021-08-01 19:00:20 +02:00
|
|
|
if (header->type == TYPE_GAME_WII_DISC)
|
2012-05-06 12:59:58 +02:00
|
|
|
{
|
|
|
|
wiidisc_t *wdisc = wd_open_disc(__ReadDVD, 0);
|
|
|
|
if (!wdisc)
|
|
|
|
return false;
|
|
|
|
|
2021-08-01 19:00:20 +02:00
|
|
|
imetHdr = (IMETHeader *)wd_extract_file(wdisc, ALL_PARTITIONS, (char *)"opening.bnr");
|
2012-05-06 12:59:58 +02:00
|
|
|
|
|
|
|
filesize = wdisc->extracted_size;
|
|
|
|
|
|
|
|
wd_close_disc(wdisc);
|
|
|
|
}
|
|
|
|
else
|
2011-07-26 00:28:22 +02:00
|
|
|
{
|
2021-08-01 19:00:20 +02:00
|
|
|
wbfs_disc_t *disc = WBFS_OpenDisc((u8 *)gameID);
|
2012-05-06 12:59:58 +02:00
|
|
|
if (!disc)
|
|
|
|
return false;
|
|
|
|
|
2021-08-01 19:00:20 +02:00
|
|
|
wiidisc_t *wdisc = wd_open_disc((s32(*)(void *, u32, u32, void *))wbfs_disc_read, disc);
|
2012-05-06 12:59:58 +02:00
|
|
|
if (!wdisc)
|
|
|
|
{
|
|
|
|
WBFS_CloseDisc(disc);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-08-01 19:00:20 +02:00
|
|
|
imetHdr = (IMETHeader *)wd_extract_file(wdisc, ALL_PARTITIONS, (char *)"opening.bnr");
|
2012-05-06 12:59:58 +02:00
|
|
|
|
|
|
|
filesize = wdisc->extracted_size;
|
|
|
|
|
|
|
|
wd_close_disc(wdisc);
|
2011-07-26 00:28:22 +02:00
|
|
|
WBFS_CloseDisc(disc);
|
2012-05-06 12:59:58 +02:00
|
|
|
}
|
|
|
|
|
2021-08-01 19:00:20 +02:00
|
|
|
if (!imetHdr)
|
2012-05-06 12:59:58 +02:00
|
|
|
return false;
|
|
|
|
|
|
|
|
if (imetHdr->fcc != 'IMET')
|
|
|
|
{
|
|
|
|
free(imetHdr);
|
|
|
|
imetHdr = NULL;
|
2011-07-26 00:28:22 +02:00
|
|
|
return false;
|
|
|
|
}
|
2010-12-27 10:44:27 +01:00
|
|
|
|
2021-08-01 19:00:20 +02:00
|
|
|
if (Settings.CacheBNRFiles)
|
|
|
|
WriteCachedBNR((const char *)header->id, (u8 *)imetHdr, filesize);
|
2012-05-06 12:59:58 +02:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2010-12-27 10:44:27 +01:00
|
|
|
|
2012-05-06 12:59:58 +02:00
|
|
|
bool OpeningBNR::LoadChannelBanner(const discHdr *header)
|
|
|
|
{
|
2021-08-01 19:00:20 +02:00
|
|
|
if (!header || (header->tid == 0) || ((header->type != TYPE_GAME_NANDCHAN) && (header->type != TYPE_GAME_EMUNANDCHAN)))
|
2012-05-06 12:59:58 +02:00
|
|
|
return false;
|
2010-12-27 10:44:27 +01:00
|
|
|
|
2021-08-01 19:00:20 +02:00
|
|
|
if (Settings.CacheBNRFiles && LoadCachedBNR((char *)header->id))
|
2012-05-06 12:59:58 +02:00
|
|
|
return true;
|
|
|
|
|
|
|
|
const u64 &tid = header->tid;
|
|
|
|
const char *pathPrefix = (header->type == TYPE_GAME_EMUNANDCHAN) ? Settings.NandEmuChanPath : "";
|
|
|
|
|
2021-08-01 19:00:20 +02:00
|
|
|
imetHdr = (IMETHeader *)Channels::GetOpeningBnr(tid, &filesize, pathPrefix);
|
|
|
|
if (!imetHdr)
|
2011-07-26 00:28:22 +02:00
|
|
|
return false;
|
2010-12-27 10:44:27 +01:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
if (imetHdr->fcc != 'IMET')
|
|
|
|
{
|
|
|
|
free(imetHdr);
|
|
|
|
imetHdr = NULL;
|
|
|
|
return false;
|
|
|
|
}
|
2010-12-27 10:44:27 +01:00
|
|
|
|
2021-08-01 19:00:20 +02:00
|
|
|
if (Settings.CacheBNRFiles)
|
|
|
|
WriteCachedBNR((char *)header->id, (u8 *)imetHdr, filesize);
|
2012-05-06 12:59:58 +02:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
2010-12-27 10:44:27 +01:00
|
|
|
}
|
|
|
|
|
2021-08-01 19:00:20 +02:00
|
|
|
const u16 *OpeningBNR::GetIMETTitle(int lang)
|
2010-12-27 10:44:27 +01:00
|
|
|
{
|
2021-08-01 19:00:20 +02:00
|
|
|
if (!imetHdr || lang < 0 || lang >= 10)
|
2011-07-26 00:28:22 +02:00
|
|
|
return NULL;
|
2010-12-27 10:44:27 +01:00
|
|
|
|
2012-05-06 12:59:58 +02:00
|
|
|
if (imetHdr->fcc != 'IMET')
|
|
|
|
return NULL;
|
|
|
|
|
2021-08-01 19:00:20 +02:00
|
|
|
if (imetHdr->names[lang][0] == 0)
|
2011-07-26 00:28:22 +02:00
|
|
|
lang = CONF_LANG_ENGLISH;
|
2010-12-27 10:44:27 +01:00
|
|
|
|
2020-12-12 22:35:12 +01:00
|
|
|
return imetHdr->names[lang]; // possible unaligned pointer value
|
2010-12-27 10:44:27 +01:00
|
|
|
}
|
|
|
|
|
2021-08-01 19:00:20 +02:00
|
|
|
static s32 GC_Disc_Read(void *fp, u32 offset, u32 count, void *iobuf)
|
2010-12-27 10:44:27 +01:00
|
|
|
{
|
2021-08-01 19:00:20 +02:00
|
|
|
if (fp)
|
2012-05-06 12:59:58 +02:00
|
|
|
{
|
|
|
|
fseek((FILE *)fp, offset, SEEK_SET);
|
|
|
|
return fread(iobuf, 1, count, (FILE *)fp);
|
|
|
|
}
|
|
|
|
|
|
|
|
return __ReadDVDPlain(iobuf, count, offset);
|
|
|
|
}
|
|
|
|
|
2021-08-01 19:00:20 +02:00
|
|
|
u8 *OpeningBNR::LoadGCBNR(const discHdr *header, u32 *len)
|
2012-05-06 12:59:58 +02:00
|
|
|
{
|
2021-08-01 19:00:20 +02:00
|
|
|
if (!header || ((header->type != TYPE_GAME_GC_IMG) && (header->type != TYPE_GAME_GC_DISC) && (header->type != TYPE_GAME_GC_EXTRACTED)))
|
2011-07-26 00:28:22 +02:00
|
|
|
return NULL;
|
|
|
|
|
2021-08-01 19:00:20 +02:00
|
|
|
const char *path = GCGames::Instance()->GetPath((char *)header->id);
|
|
|
|
if (!path)
|
2012-05-06 12:59:58 +02:00
|
|
|
return NULL;
|
2011-07-26 00:28:22 +02:00
|
|
|
|
2012-05-06 12:59:58 +02:00
|
|
|
FILE *file = NULL;
|
|
|
|
GC_OpeningBnr *openingBnr = NULL;
|
2011-07-26 00:28:22 +02:00
|
|
|
|
2012-05-06 12:59:58 +02:00
|
|
|
// read from file
|
2021-08-01 19:00:20 +02:00
|
|
|
if ((header->type == TYPE_GAME_GC_IMG) || (header->type == TYPE_GAME_GC_DISC))
|
2011-07-26 00:28:22 +02:00
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
//! open iso file if it's iso
|
2021-08-01 19:00:20 +02:00
|
|
|
if (header->type == TYPE_GAME_GC_IMG)
|
2012-05-06 12:59:58 +02:00
|
|
|
{
|
|
|
|
file = fopen(path, "rb");
|
2021-08-01 19:00:20 +02:00
|
|
|
if (!file)
|
2012-05-06 12:59:58 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
gcdisc_t *disc = gc_open_disc(GC_Disc_Read, file);
|
2021-08-01 19:00:20 +02:00
|
|
|
if (!disc)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
fclose(file);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2021-08-01 19:00:20 +02:00
|
|
|
if (!strcmp(Settings.db_language, "JA"))
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
bool loaded = gc_extract_file(disc, "openingJA.bnr");
|
2021-08-01 19:00:20 +02:00
|
|
|
if (!loaded)
|
2012-05-06 12:59:58 +02:00
|
|
|
loaded = gc_extract_file(disc, "opening.bnr");
|
2021-08-01 19:00:20 +02:00
|
|
|
if (!loaded)
|
2012-05-06 12:59:58 +02:00
|
|
|
loaded = gc_extract_file(disc, "openingUS.bnr");
|
2021-08-01 19:00:20 +02:00
|
|
|
if (!loaded)
|
2012-05-06 12:59:58 +02:00
|
|
|
loaded = gc_extract_file(disc, "openingEU.bnr");
|
|
|
|
}
|
2021-08-01 19:00:20 +02:00
|
|
|
else if (!strcmp(Settings.db_language, "EN"))
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
bool loaded = gc_extract_file(disc, "openingUS.bnr");
|
2021-08-01 19:00:20 +02:00
|
|
|
if (!loaded)
|
2012-05-06 12:59:58 +02:00
|
|
|
loaded = gc_extract_file(disc, "opening.bnr");
|
2021-08-01 19:00:20 +02:00
|
|
|
if (!loaded)
|
2012-05-06 12:59:58 +02:00
|
|
|
loaded = gc_extract_file(disc, "openingEU.bnr");
|
2021-08-01 19:00:20 +02:00
|
|
|
if (!loaded)
|
2012-05-06 12:59:58 +02:00
|
|
|
loaded = gc_extract_file(disc, "openingJA.bnr");
|
|
|
|
}
|
2021-08-01 19:00:20 +02:00
|
|
|
else
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
bool loaded = gc_extract_file(disc, "openingEU.bnr");
|
2021-08-01 19:00:20 +02:00
|
|
|
if (!loaded)
|
2012-05-06 12:59:58 +02:00
|
|
|
loaded = gc_extract_file(disc, "opening.bnr");
|
2021-08-01 19:00:20 +02:00
|
|
|
if (!loaded)
|
2012-05-06 12:59:58 +02:00
|
|
|
loaded = gc_extract_file(disc, "openingUS.bnr");
|
2021-08-01 19:00:20 +02:00
|
|
|
if (!loaded)
|
2012-05-06 12:59:58 +02:00
|
|
|
loaded = gc_extract_file(disc, "openingJA.bnr");
|
|
|
|
}
|
|
|
|
|
2021-08-01 19:00:20 +02:00
|
|
|
openingBnr = (GC_OpeningBnr *)disc->extracted_buffer;
|
|
|
|
if (len)
|
2012-05-06 12:59:58 +02:00
|
|
|
*len = disc->extracted_size;
|
2011-07-26 00:28:22 +02:00
|
|
|
|
2012-05-06 12:59:58 +02:00
|
|
|
gc_close_disc(disc);
|
|
|
|
}
|
2021-08-01 19:00:20 +02:00
|
|
|
else if (header->type == TYPE_GAME_GC_EXTRACTED)
|
2011-07-26 00:28:22 +02:00
|
|
|
{
|
2023-01-01 18:00:23 +01:00
|
|
|
std::string gamePath(path);
|
2012-05-06 12:59:58 +02:00
|
|
|
gamePath += "root/";
|
|
|
|
//! open default file first
|
|
|
|
file = fopen((gamePath + "opening.bnr").c_str(), "rb");
|
|
|
|
|
|
|
|
// if not found try the region specific ones
|
2021-08-01 19:00:20 +02:00
|
|
|
if (!strcmp(Settings.db_language, "JA"))
|
|
|
|
{
|
|
|
|
if (!file)
|
2012-05-06 12:59:58 +02:00
|
|
|
file = fopen((gamePath + "openingJA.bnr").c_str(), "rb");
|
2021-08-01 19:00:20 +02:00
|
|
|
if (!file)
|
2012-05-06 12:59:58 +02:00
|
|
|
file = fopen((gamePath + "openingUS.bnr").c_str(), "rb");
|
2021-08-01 19:00:20 +02:00
|
|
|
if (!file)
|
2012-05-06 12:59:58 +02:00
|
|
|
file = fopen((gamePath + "openingEU.bnr").c_str(), "rb");
|
|
|
|
}
|
2021-08-01 19:00:20 +02:00
|
|
|
else if (!strcmp(Settings.db_language, "EN"))
|
|
|
|
{
|
|
|
|
if (!file)
|
2012-05-06 12:59:58 +02:00
|
|
|
file = fopen((gamePath + "openingUS.bnr").c_str(), "rb");
|
2021-08-01 19:00:20 +02:00
|
|
|
if (!file)
|
2012-05-06 12:59:58 +02:00
|
|
|
file = fopen((gamePath + "openingEU.bnr").c_str(), "rb");
|
2021-08-01 19:00:20 +02:00
|
|
|
if (!file)
|
2012-05-06 12:59:58 +02:00
|
|
|
file = fopen((gamePath + "openingJA.bnr").c_str(), "rb");
|
|
|
|
}
|
2021-08-01 19:00:20 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!file)
|
2012-05-06 12:59:58 +02:00
|
|
|
file = fopen((gamePath + "openingEU.bnr").c_str(), "rb");
|
2021-08-01 19:00:20 +02:00
|
|
|
if (!file)
|
2012-05-06 12:59:58 +02:00
|
|
|
file = fopen((gamePath + "openingUS.bnr").c_str(), "rb");
|
2021-08-01 19:00:20 +02:00
|
|
|
if (!file)
|
2012-05-06 12:59:58 +02:00
|
|
|
file = fopen((gamePath + "openingJA.bnr").c_str(), "rb");
|
|
|
|
}
|
|
|
|
|
|
|
|
// file not found
|
2021-08-01 19:00:20 +02:00
|
|
|
if (!file)
|
2012-05-06 12:59:58 +02:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
fseek(file, 0, SEEK_END);
|
|
|
|
int size = ftell(file);
|
|
|
|
rewind(file);
|
|
|
|
|
2021-08-01 19:00:20 +02:00
|
|
|
openingBnr = (GC_OpeningBnr *)malloc(size);
|
|
|
|
if (openingBnr)
|
2012-05-06 12:59:58 +02:00
|
|
|
{
|
2021-08-01 19:00:20 +02:00
|
|
|
if (len)
|
2012-05-06 12:59:58 +02:00
|
|
|
*len = size;
|
|
|
|
fread(openingBnr, 1, size, file);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-01 19:00:20 +02:00
|
|
|
if (file)
|
2012-05-06 12:59:58 +02:00
|
|
|
fclose(file);
|
|
|
|
|
2021-08-01 19:00:20 +02:00
|
|
|
if (!openingBnr)
|
2012-05-06 12:59:58 +02:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
// check magic of the opening bnr
|
2021-08-01 19:00:20 +02:00
|
|
|
if (openingBnr->magic != 'BNR1' && openingBnr->magic != 'BNR2')
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
free(openingBnr);
|
2011-07-26 00:28:22 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2021-08-01 19:00:20 +02:00
|
|
|
return (u8 *)openingBnr;
|
2012-05-06 12:59:58 +02:00
|
|
|
}
|
|
|
|
|
2021-08-01 19:00:20 +02:00
|
|
|
CustomBanner *OpeningBNR::CreateGCBanner(const discHdr *header)
|
2012-05-06 12:59:58 +02:00
|
|
|
{
|
|
|
|
int language = 0;
|
|
|
|
u32 openingBnrSize;
|
2021-08-01 19:00:20 +02:00
|
|
|
wString developer;
|
|
|
|
GC_OpeningBnr *openingBnr = (GC_OpeningBnr *)LoadGCBNR(header, &openingBnrSize);
|
2012-05-06 12:59:58 +02:00
|
|
|
|
|
|
|
CustomBanner *banner = new CustomBanner;
|
|
|
|
banner->LoadBanner(Resources::GetFile("custom_banner.bnr"), Resources::GetFileSize("custom_banner.bnr"));
|
|
|
|
banner->SetBannerPngImage("bg.tpl", Resources::GetFile("gc_banner_bg.png"), Resources::GetFileSize("gc_banner_bg.png"));
|
|
|
|
|
|
|
|
banner->SetBannerText("T_PF", tr("GameCube"));
|
|
|
|
|
2021-08-01 19:00:20 +02:00
|
|
|
if (openingBnr)
|
2011-07-26 00:28:22 +02:00
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
banner->SetBannerTexture("HBPic.tpl", openingBnr->tpl_data, 96, 32, GX_TF_RGB5A3);
|
|
|
|
|
|
|
|
// European opening bnr file
|
2021-08-01 19:00:20 +02:00
|
|
|
if (openingBnr->magic == 'BNR2')
|
2011-07-26 00:28:22 +02:00
|
|
|
{
|
2021-08-01 19:00:20 +02:00
|
|
|
if (!strcmp(Settings.db_language, "DE"))
|
2012-05-06 12:59:58 +02:00
|
|
|
language = 1;
|
2021-08-01 19:00:20 +02:00
|
|
|
else if (!strcmp(Settings.db_language, "FR"))
|
2012-05-06 12:59:58 +02:00
|
|
|
language = 2;
|
2021-08-01 19:00:20 +02:00
|
|
|
else if (!strcmp(Settings.db_language, "ES"))
|
2012-05-06 12:59:58 +02:00
|
|
|
language = 3;
|
2021-08-01 19:00:20 +02:00
|
|
|
else if (!strcmp(Settings.db_language, "IT"))
|
2012-05-06 12:59:58 +02:00
|
|
|
language = 4;
|
2021-08-01 19:00:20 +02:00
|
|
|
else if (!strcmp(Settings.db_language, "NL"))
|
2012-05-06 12:59:58 +02:00
|
|
|
language = 5;
|
|
|
|
|
2021-08-01 19:00:20 +02:00
|
|
|
if ((0x1820 + sizeof(openingBnr->description[0]) * language) > openingBnrSize)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
language = 0;
|
|
|
|
}
|
2011-07-26 00:28:22 +02:00
|
|
|
}
|
|
|
|
|
2020-07-09 03:11:20 +02:00
|
|
|
// sets the developer
|
2021-08-01 19:00:20 +02:00
|
|
|
developer.resize(strlen((char *)openingBnr->description[language].developer));
|
|
|
|
for (u32 i = 0; i < developer.size(); i++)
|
|
|
|
developer[i] = *(openingBnr->description[language].developer + i);
|
2012-05-06 12:59:58 +02:00
|
|
|
|
|
|
|
banner->SetBannerText("T_Coded_by", tr("Developer:"));
|
2021-08-01 19:00:20 +02:00
|
|
|
banner->SetBannerText("T_coder", developer.toUTF8().c_str());
|
2011-07-26 00:28:22 +02:00
|
|
|
|
2020-07-09 03:11:20 +02:00
|
|
|
// sets the description and converts encodings (Japan and Taiwan)
|
2021-08-01 19:00:20 +02:00
|
|
|
if (header->id[3] == 'J' || header->id[3] == 'W')
|
2020-07-09 03:11:20 +02:00
|
|
|
{
|
2021-08-01 19:00:20 +02:00
|
|
|
std::string description((char *)openingBnr->description[language].long_description);
|
2020-07-09 03:11:20 +02:00
|
|
|
banner->SetBannerText("T_short_descript", sj2utf8(description).c_str());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-08-01 19:00:20 +02:00
|
|
|
wString description;
|
|
|
|
description.resize(strlen((char *)openingBnr->description[language].long_description));
|
|
|
|
for (u32 i = 0; i < description.size(); i++)
|
|
|
|
description[i] = *(openingBnr->description[language].long_description + i);
|
2012-05-06 12:59:58 +02:00
|
|
|
|
2021-08-01 19:00:20 +02:00
|
|
|
banner->SetBannerText("T_short_descript", description.toUTF8().c_str());
|
2020-07-09 03:11:20 +02:00
|
|
|
}
|
2012-05-06 12:59:58 +02:00
|
|
|
|
|
|
|
// free buffer
|
|
|
|
free(openingBnr);
|
|
|
|
}
|
|
|
|
else
|
2011-07-26 00:28:22 +02:00
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
banner->SetBannerPngImage("HBPic.tpl", Resources::GetFile("gc_icon_bg.png"), Resources::GetFileSize("gc_icon_bg.png"));
|
|
|
|
banner->SetBannerText("T_Coded_by", tr("Developer:"));
|
|
|
|
banner->SetBannerText("T_coder", tr("Unknown"));
|
|
|
|
banner->SetBannerText("T_short_descript", " ");
|
2011-07-26 00:28:22 +02:00
|
|
|
}
|
|
|
|
|
2021-08-01 19:00:20 +02:00
|
|
|
if (strcmp(Settings.db_language, "KO") == 0)
|
|
|
|
{
|
|
|
|
banner->SetBannerText("T_Coded_by", developer.toUTF8().c_str());
|
|
|
|
banner->SetBannerPaneVisible("T_coder", false);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
banner->SetBannerText("T_name", GameTitles.GetTitle(header));
|
2012-05-06 12:59:58 +02:00
|
|
|
banner->SetBannerPaneVisible("Line1", false);
|
|
|
|
banner->SetBannerPaneVisible("Line2", false);
|
|
|
|
banner->SetBannerPaneVisible("T_Released", false);
|
|
|
|
banner->SetBannerPaneVisible("T_release_date", false);
|
|
|
|
banner->SetBannerPaneVisible("T_versiontext", false);
|
|
|
|
banner->SetBannerPaneVisible("T_version", false);
|
|
|
|
banner->SetBannerTextureScale(Settings.GCBannerScale);
|
|
|
|
|
|
|
|
return banner;
|
|
|
|
}
|
|
|
|
|
2021-08-01 19:00:20 +02:00
|
|
|
CustomBanner *OpeningBNR::CreateGCIcon(const discHdr *header)
|
2012-05-06 12:59:58 +02:00
|
|
|
{
|
2021-08-01 19:00:20 +02:00
|
|
|
GC_OpeningBnr *openingBnr = (GC_OpeningBnr *)LoadGCBNR(header);
|
2012-05-06 12:59:58 +02:00
|
|
|
|
|
|
|
CustomBanner *newBanner = new CustomBanner;
|
|
|
|
newBanner->LoadIcon(Resources::GetFile("custom_banner.bnr"), Resources::GetFileSize("custom_banner.bnr"));
|
|
|
|
|
2021-08-01 19:00:20 +02:00
|
|
|
if (openingBnr)
|
2012-05-06 12:59:58 +02:00
|
|
|
newBanner->SetIconTexture("Iconpng.tpl", openingBnr->tpl_data, 96, 32, GX_TF_RGB5A3);
|
|
|
|
else
|
|
|
|
newBanner->SetIconPngImage("Iconpng.tpl", Resources::GetFile("gc_icon_bg.png"), Resources::GetFileSize("gc_icon_bg.png"));
|
|
|
|
|
|
|
|
newBanner->SetIconPngImage("HBLogo.tpl", Resources::GetFile("gc_icon_bg.png"), Resources::GetFileSize("gc_icon_bg.png"));
|
|
|
|
|
|
|
|
// free buffer
|
2021-08-01 19:00:20 +02:00
|
|
|
if (openingBnr)
|
2012-05-06 12:59:58 +02:00
|
|
|
free(openingBnr);
|
|
|
|
|
|
|
|
return newBanner;
|
2010-12-27 10:44:27 +01:00
|
|
|
}
|