mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 14:19:46 -06:00
updating the HLE FS and FileIO
added banner support of the savegames for wii... same games git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1031 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -21,6 +21,7 @@
|
||||
#include "BannerLoaderGC.h"
|
||||
|
||||
#include "VolumeCreator.h"
|
||||
#include "FileUtil.h"
|
||||
|
||||
namespace DiscIO
|
||||
{
|
||||
|
@ -21,77 +21,110 @@
|
||||
|
||||
#include "Common.h"
|
||||
#include "BannerLoaderWii.h"
|
||||
#include "FileHandlerARC.h"
|
||||
// #include "FileHandlerLZ77.h"
|
||||
#include "FileUtil.h"
|
||||
|
||||
namespace DiscIO
|
||||
{
|
||||
CBannerLoaderWii::CBannerLoaderWii(DiscIO::IFileSystem& _rFileSystem)
|
||||
: m_pBuffer(NULL)
|
||||
CBannerLoaderWii::CBannerLoaderWii(DiscIO::IFileSystem& _rFileSystem)
|
||||
: m_pBannerFile(NULL)
|
||||
, m_IsValid(false)
|
||||
{
|
||||
FILE* pFile = fopen("e:\\opening.bnr", "rb");
|
||||
InitLUTTable();
|
||||
|
||||
char Filename[260];
|
||||
char TitleID[4];
|
||||
|
||||
_rFileSystem.GetVolume()->Read(0, 4, (u8*)TitleID);
|
||||
sprintf(Filename, "Wii/title/00010000/%02x%02x%02x%02x/data/banner.bin", (u8)TitleID[0], (u8)TitleID[1], (u8)TitleID[2], (u8)TitleID[3]);
|
||||
|
||||
if (pFile)
|
||||
// load the opening.bnr
|
||||
size_t FileSize = File::GetSize(Filename);
|
||||
|
||||
if (FileSize > 0)
|
||||
{
|
||||
fseek(pFile, 0, SEEK_END);
|
||||
int insize = ftell(pFile);
|
||||
fseek(pFile, 0, SEEK_SET);
|
||||
|
||||
m_pBuffer = new u8[insize];
|
||||
|
||||
fread(m_pBuffer, 1, insize, pFile);
|
||||
|
||||
fclose(pFile);
|
||||
|
||||
CARCFile ArcFile(m_pBuffer + 0x600, insize - 0x600);
|
||||
|
||||
size_t BannerSize = ArcFile.GetFileSize("meta\\banner.bin");
|
||||
|
||||
if (BannerSize > 0)
|
||||
m_pBannerFile = new u8[FileSize];
|
||||
FILE* pFile = fopen(Filename, "rb");
|
||||
if (pFile != NULL)
|
||||
{
|
||||
u8* TempBuffer = new u8[BannerSize];
|
||||
ArcFile.ReadFile("meta\\banner.bin", TempBuffer, BannerSize);
|
||||
|
||||
// CLZ77File File(TempBuffer + 0x20 + 4, BannerSize - 0x20 - 4);
|
||||
delete[] TempBuffer;
|
||||
|
||||
// CARCFile IconFile(File.GetBuffer(), File.GetSize());
|
||||
|
||||
// IconFile.ExportFile("arc\\anim\\banner_loop.brlan", "e:\\banner_loop.brlan");
|
||||
|
||||
//IconFile.ReadFile("meta\\icon.bin", TempBuffer, BannerSize);
|
||||
fread(m_pBannerFile, FileSize, 1, pFile);
|
||||
fclose(pFile);
|
||||
m_IsValid = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
m_Name = std::string("Wii: ") + _rFileSystem.GetVolume()->GetName();
|
||||
}
|
||||
|
||||
|
||||
CBannerLoaderWii::~CBannerLoaderWii()
|
||||
{
|
||||
delete [] m_pBuffer;
|
||||
m_pBuffer = NULL;
|
||||
if (m_pBannerFile)
|
||||
{
|
||||
delete [] m_pBannerFile;
|
||||
m_pBannerFile = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
CBannerLoaderWii::IsValid()
|
||||
{
|
||||
return(true);
|
||||
return (m_IsValid);
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
CBannerLoaderWii::GetBanner(u32* _pBannerImage)
|
||||
{
|
||||
return(false);
|
||||
if (!IsValid())
|
||||
{
|
||||
return(false);
|
||||
}
|
||||
|
||||
SWiiBanner* pBanner = (SWiiBanner*)m_pBannerFile;
|
||||
|
||||
static u32 Buffer[192 * 64];
|
||||
decode5A3image(Buffer, (u16*)pBanner->m_BannerTexture, 192, 64);
|
||||
|
||||
for (int y=0; y<32; y++)
|
||||
{
|
||||
for (int x=0; x<96; x++)
|
||||
{
|
||||
_pBannerImage[y*96+x] = Buffer[(y*2)*96+(x*2)];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
std::string
|
||||
CBannerLoaderWii::StupidWideCharToString(u16* _pSrc, size_t _max)
|
||||
{
|
||||
std::string temp;
|
||||
|
||||
int offset = 0;
|
||||
while (_pSrc[offset] != 0x0000)
|
||||
{
|
||||
temp += (char)(_pSrc[offset] >> 8);
|
||||
offset ++;
|
||||
|
||||
if (offset >= _max)
|
||||
break;
|
||||
}
|
||||
|
||||
return temp;
|
||||
}
|
||||
|
||||
bool
|
||||
CBannerLoaderWii::GetName(std::string& _rName, int language)
|
||||
{
|
||||
if (IsValid())
|
||||
{
|
||||
SWiiBanner* pBanner = (SWiiBanner*)m_pBannerFile;
|
||||
|
||||
// very stupid
|
||||
_rName = StupidWideCharToString(pBanner->m_Comment[0], WII_BANNER_COMMENT_SIZE);
|
||||
return true;
|
||||
}
|
||||
|
||||
_rName = m_Name;
|
||||
return(true);
|
||||
}
|
||||
@ -107,7 +140,84 @@ CBannerLoaderWii::GetCompany(std::string& _rCompany)
|
||||
bool
|
||||
CBannerLoaderWii::GetDescription(std::string& _rDescription)
|
||||
{
|
||||
if (IsValid())
|
||||
{
|
||||
SWiiBanner* pBanner = (SWiiBanner*)m_pBannerFile;
|
||||
|
||||
// very stupid
|
||||
_rDescription = StupidWideCharToString(pBanner->m_Comment[1], WII_BANNER_COMMENT_SIZE);
|
||||
return true;
|
||||
}
|
||||
|
||||
return(false);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CBannerLoaderWii::InitLUTTable()
|
||||
{
|
||||
// build LUT Table
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
lut3to8[i] = (i * 255) / 7;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
lut4to8[i] = (i * 255) / 15;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 32; i++)
|
||||
{
|
||||
lut5to8[i] = (i * 255) / 31;
|
||||
}
|
||||
}
|
||||
|
||||
u32
|
||||
CBannerLoaderWii::decode5A3(u16 val)
|
||||
{
|
||||
u32 bannerBGColor = 0x00000000;
|
||||
|
||||
int r, g, b, a;
|
||||
|
||||
if ((val & 0x8000))
|
||||
{
|
||||
r = lut5to8[(val >> 10) & 0x1f];
|
||||
g = lut5to8[(val >> 5) & 0x1f];
|
||||
b = lut5to8[(val) & 0x1f];
|
||||
a = 0xFF;
|
||||
}
|
||||
else
|
||||
{
|
||||
a = lut3to8[(val >> 12) & 0x7];
|
||||
r = (lut4to8[(val >> 8) & 0xf] * a + (bannerBGColor & 0xFF) * (255 - a)) / 255;
|
||||
g = (lut4to8[(val >> 4) & 0xf] * a + ((bannerBGColor >> 8) & 0xFF) * (255 - a)) / 255;
|
||||
b = (lut4to8[(val) & 0xf] * a + ((bannerBGColor >> 16) & 0xFF) * (255 - a)) / 255;
|
||||
a = 0xFF;
|
||||
}
|
||||
|
||||
return((a << 24) | (r << 16) | (g << 8) | b);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CBannerLoaderWii::decode5A3image(u32* dst, u16* src, int width, int height)
|
||||
{
|
||||
for (int y = 0; y < height; y += 4)
|
||||
{
|
||||
for (int x = 0; x < width; x += 4)
|
||||
{
|
||||
for (int iy = 0; iy < 4; iy++, src += 4)
|
||||
{
|
||||
for (int ix = 0; ix < 4; ix++)
|
||||
{
|
||||
u32 RGBA = decode5A3(Common::swap16(src[ix]));
|
||||
dst[(y + iy) * width + (x + ix)] = RGBA;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
|
@ -43,10 +43,40 @@ class CBannerLoaderWii
|
||||
|
||||
|
||||
private:
|
||||
|
||||
#define WII_BANNER_TEXTURE_SIZE (192 * 64 * 2)
|
||||
#define WII_BANNER_ICON_SIZE ( 48 * 48 * 2)
|
||||
#define WII_BANNER_COMMENT_SIZE 32
|
||||
|
||||
struct SWiiBanner
|
||||
{
|
||||
u32 ID;
|
||||
|
||||
u32 m_Flag;
|
||||
u16 m_Speed;
|
||||
u8 m_Unknown[22];
|
||||
|
||||
u16 m_Comment[2][WII_BANNER_COMMENT_SIZE];
|
||||
u8 m_BannerTexture[WII_BANNER_TEXTURE_SIZE];
|
||||
u8 m_IconTexture[8][WII_BANNER_ICON_SIZE];
|
||||
} ;
|
||||
|
||||
// for banner decoding
|
||||
int lut3to8[8];
|
||||
int lut4to8[16];
|
||||
int lut5to8[32];
|
||||
|
||||
std::string m_Name;
|
||||
|
||||
u8* m_pBuffer;
|
||||
u8* m_pBannerFile;
|
||||
|
||||
bool m_IsValid;
|
||||
|
||||
void InitLUTTable();
|
||||
u32 decode5A3(u16 val);
|
||||
void decode5A3image(u32* dst, u16* src, int width, int height);
|
||||
|
||||
std::string StupidWideCharToString(u16* _pSrc, size_t _max);
|
||||
};
|
||||
} // namespace
|
||||
|
||||
|
Reference in New Issue
Block a user