mirror of
https://github.com/Fledge68/WiiFlow_Lite.git
synced 2025-02-20 05:52:41 +01:00
Making things ready for official wiiflow svn ;)
-made wait animation faster -removed a few unneeded lines in the wait message code -fixed booting wii games from disc -fixed possible bug in wii game launching in general -gecko output again on wii game booting -converted alot of spaces to tabs, fitting the general wiiflow coding style -general cleaning up things
This commit is contained in:
parent
6cb919c7ae
commit
a36fab3cdd
@ -14,17 +14,9 @@
|
|||||||
#include "gecko.h"
|
#include "gecko.h"
|
||||||
#include "mem2.hpp"
|
#include "mem2.hpp"
|
||||||
|
|
||||||
#define STACK_ALIGN(type, name, cnt, alignment) \
|
|
||||||
u8 _al__##name[((sizeof(type)*(cnt)) + (alignment) + \
|
|
||||||
(((sizeof(type)*(cnt))%(alignment)) > 0 ? ((alignment) - \
|
|
||||||
((sizeof(type)*(cnt))%(alignment))) : 0))]; \
|
|
||||||
type *name = (type*)(((u32)(_al__##name)) + ((alignment) - (( \
|
|
||||||
(u32)(_al__##name))&((alignment)-1))))
|
|
||||||
|
|
||||||
void __Disc_SetLowMem(void);
|
void __Disc_SetLowMem(void);
|
||||||
void __Disc_SetTime(void);
|
void __Disc_SetTime(void);
|
||||||
void _unstub_start();
|
void _unstub_start();
|
||||||
u32 entryPoint;
|
|
||||||
|
|
||||||
extern void __exception_closeall();
|
extern void __exception_closeall();
|
||||||
|
|
||||||
@ -41,6 +33,8 @@ typedef struct _dolheader
|
|||||||
u32 padding[7];
|
u32 padding[7];
|
||||||
} __attribute__((packed)) dolheader;
|
} __attribute__((packed)) dolheader;
|
||||||
|
|
||||||
|
u32 entryPoint;
|
||||||
|
|
||||||
s32 BootChannel(u32 entry, u64 chantitle, u32 ios, u8 vidMode, bool vipatch, bool countryString, u8 patchVidMode, int aspectRatio)
|
s32 BootChannel(u32 entry, u64 chantitle, u32 ios, u8 vidMode, bool vipatch, bool countryString, u8 patchVidMode, int aspectRatio)
|
||||||
{
|
{
|
||||||
gprintf("Loading Channel...\n");
|
gprintf("Loading Channel...\n");
|
||||||
|
@ -468,13 +468,20 @@ void Nand::__NANDify(char *str)
|
|||||||
{
|
{
|
||||||
if(c == '&')
|
if(c == '&')
|
||||||
{
|
{
|
||||||
if(!strncmp(src, "qt;", 3)) c = '"';
|
if(!strncmp(src, "qt;", 3))
|
||||||
else if (!strncmp(src, "st;", 3)) c = '*';
|
c = '"';
|
||||||
else if (!strncmp(src, "cl;", 3)) c = ':';
|
else if(!strncmp(src, "st;", 3))
|
||||||
else if (!strncmp(src, "lt;", 3)) c = '<';
|
c = '*';
|
||||||
else if (!strncmp(src, "gt;", 3)) c = '>';
|
else if(!strncmp(src, "cl;", 3))
|
||||||
else if (!strncmp(src, "qm;", 3)) c = '?';
|
c = ':';
|
||||||
else if (!strncmp(src, "vb;", 3)) c = '|';
|
else if(!strncmp(src, "lt;", 3))
|
||||||
|
c = '<';
|
||||||
|
else if(!strncmp(src, "gt;", 3))
|
||||||
|
c = '>';
|
||||||
|
else if(!strncmp(src, "qm;", 3))
|
||||||
|
c = '?';
|
||||||
|
else if(!strncmp(src, "vb;", 3))
|
||||||
|
c = '|';
|
||||||
|
|
||||||
if (c != '&')
|
if (c != '&')
|
||||||
src += 3;
|
src += 3;
|
||||||
@ -862,9 +869,7 @@ s32 Nand::DoNandDump(const char *source, const char *dest, dump_callback_t i_dum
|
|||||||
__DumpNandFile(source, ndest);
|
__DumpNandFile(source, ndest);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
__DumpNandFolder(source, dest);
|
__DumpNandFolder(source, dest);
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,8 +12,6 @@
|
|||||||
#define likely(x) __builtin_expect(!!(x), 1)
|
#define likely(x) __builtin_expect(!!(x), 1)
|
||||||
#define unlikely(x) __builtin_expect(!!(x), 0)
|
#define unlikely(x) __builtin_expect(!!(x), 0)
|
||||||
|
|
||||||
#define read_le32_unaligned(x) ((x)[0]|((x)[1]<<8)|((x)[2]<<16)|((x)[3]<<24))
|
|
||||||
|
|
||||||
#define ERROR(x) do {wbfs_error(x);goto error;}while(0)
|
#define ERROR(x) do {wbfs_error(x);goto error;}while(0)
|
||||||
#define ALIGN_LBA(x) (((x)+p->hd_sec_sz-1)&(~(p->hd_sec_sz-1)))
|
#define ALIGN_LBA(x) (((x)+p->hd_sec_sz-1)&(~(p->hd_sec_sz-1)))
|
||||||
|
|
||||||
@ -37,6 +35,8 @@ static u8 size_to_shift(u32 size)
|
|||||||
return ret - 1;
|
return ret - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define read_le32_unaligned(x) ((x)[0]|((x)[1]<<8)|((x)[2]<<16)|((x)[3]<<24))
|
||||||
|
|
||||||
wbfs_t *wbfs_open_hd(rw_sector_callback_t read_hdsector, rw_sector_callback_t write_hdsector, void *callback_data, int hd_sector_size, int num_hd_sector __attribute((unused)), int reset)
|
wbfs_t *wbfs_open_hd(rw_sector_callback_t read_hdsector, rw_sector_callback_t write_hdsector, void *callback_data, int hd_sector_size, int num_hd_sector __attribute((unused)), int reset)
|
||||||
{
|
{
|
||||||
int i=num_hd_sector,ret;
|
int i=num_hd_sector,ret;
|
||||||
@ -64,7 +64,6 @@ wbfs_t *wbfs_open_hd(rw_sector_callback_t read_hdsector, rw_sector_callback_t wr
|
|||||||
wbfs_iofree(tmp_buffer);
|
wbfs_iofree(tmp_buffer);
|
||||||
if(reset)// XXX make a empty hd partition..
|
if(reset)// XXX make a empty hd partition..
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -382,6 +382,7 @@ void aes_decrypt(u8 *iv, u8 *inbuf, u8 *outbuf, unsigned long long len)
|
|||||||
}
|
}
|
||||||
else fraction = 16;
|
else fraction = 16;
|
||||||
|
|
||||||
|
// debug_printf("block %d: fraction = %d\n", blockno, fraction);
|
||||||
memcpy(block, inbuf + blockno * sizeof(block), fraction);
|
memcpy(block, inbuf + blockno * sizeof(block), fraction);
|
||||||
decrypt((char*) block);
|
decrypt((char*) block);
|
||||||
u8 *ctext_ptr;
|
u8 *ctext_ptr;
|
||||||
@ -391,6 +392,8 @@ void aes_decrypt(u8 *iv, u8 *inbuf, u8 *outbuf, unsigned long long len)
|
|||||||
|
|
||||||
for (i = 0; i < fraction; i++)
|
for (i = 0; i < fraction; i++)
|
||||||
outbuf[blockno * sizeof(block) + i] = ctext_ptr[i] ^ block[i];
|
outbuf[blockno * sizeof(block) + i] = ctext_ptr[i] ^ block[i];
|
||||||
|
// debug_printf("Block %d output: ", blockno);
|
||||||
|
// hexdump(outbuf + blockno*sizeof(block), 16);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -400,6 +403,8 @@ void aes_encrypt(u8 *iv, u8 *inbuf, u8 *outbuf, unsigned long long len)
|
|||||||
u8 block[16];
|
u8 block[16];
|
||||||
unsigned int blockno = 0, i;
|
unsigned int blockno = 0, i;
|
||||||
|
|
||||||
|
// debug_printf("aes_decrypt(%p, %p, %p, %lld)\n", iv, inbuf, outbuf, len);
|
||||||
|
|
||||||
for (blockno = 0; blockno <= (len / sizeof(block)); blockno++)
|
for (blockno = 0; blockno <= (len / sizeof(block)); blockno++)
|
||||||
{
|
{
|
||||||
unsigned int fraction;
|
unsigned int fraction;
|
||||||
@ -411,6 +416,7 @@ void aes_encrypt(u8 *iv, u8 *inbuf, u8 *outbuf, unsigned long long len)
|
|||||||
}
|
}
|
||||||
else fraction = 16;
|
else fraction = 16;
|
||||||
|
|
||||||
|
// debug_printf("block %d: fraction = %d\n", blockno, fraction);
|
||||||
memcpy(block, inbuf + blockno * sizeof(block), fraction);
|
memcpy(block, inbuf + blockno * sizeof(block), fraction);
|
||||||
|
|
||||||
for (i = 0; i < fraction; i++)
|
for (i = 0; i < fraction; i++)
|
||||||
@ -419,6 +425,8 @@ void aes_encrypt(u8 *iv, u8 *inbuf, u8 *outbuf, unsigned long long len)
|
|||||||
encrypt((char*) block);
|
encrypt((char*) block);
|
||||||
memcpy(iv, block, sizeof(block));
|
memcpy(iv, block, sizeof(block));
|
||||||
memcpy(outbuf + blockno * sizeof(block), block, sizeof(block));
|
memcpy(outbuf + blockno * sizeof(block), block, sizeof(block));
|
||||||
|
// debug_printf("Block %d output: ", blockno);
|
||||||
|
// hexdump(outbuf + blockno*sizeof(block), 16);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
/* init-globals */
|
/* init-globals */
|
||||||
bool geckoinit = false;
|
bool geckoinit = false;
|
||||||
bool textVideoInit = false;
|
bool textVideoInit = false;
|
||||||
bool geckoDisable = false;
|
|
||||||
bool bufferMessages = true;
|
bool bufferMessages = true;
|
||||||
bool WriteToSD = false;
|
bool WriteToSD = false;
|
||||||
|
|
||||||
@ -108,8 +107,6 @@ void WriteToFile(char* tmp)
|
|||||||
//using the gprintf from crediar because it is smaller than mine
|
//using the gprintf from crediar because it is smaller than mine
|
||||||
void gprintf( const char *format, ... )
|
void gprintf( const char *format, ... )
|
||||||
{
|
{
|
||||||
if(geckoDisable)
|
|
||||||
return;
|
|
||||||
char *tmp = NULL;
|
char *tmp = NULL;
|
||||||
va_list va;
|
va_list va;
|
||||||
va_start(va, format);
|
va_start(va, format);
|
||||||
@ -184,11 +181,6 @@ bool InitGecko()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GeckoDisable()
|
|
||||||
{
|
|
||||||
geckoDisable = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AllocSDGeckoBuffer()
|
void AllocSDGeckoBuffer()
|
||||||
{
|
{
|
||||||
tmpfilebuffer = (char*)MEM2_alloc(filebuffer + 1 * sizeof(char));
|
tmpfilebuffer = (char*)MEM2_alloc(filebuffer + 1 * sizeof(char));
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
|
|
||||||
|
|
||||||
#ifndef _GECKO_H_
|
#ifndef _GECKO_H_
|
||||||
#define _GECKO_H_
|
#define _GECKO_H_
|
||||||
|
|
||||||
@ -17,7 +16,6 @@ extern "C" {
|
|||||||
bool InitGecko();
|
bool InitGecko();
|
||||||
void AllocSDGeckoBuffer();
|
void AllocSDGeckoBuffer();
|
||||||
void ClearLogBuffer();
|
void ClearLogBuffer();
|
||||||
void GeckoDisable();
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,8 @@ GameTDB::~GameTDB()
|
|||||||
|
|
||||||
bool GameTDB::OpenFile(const char *filepath)
|
bool GameTDB::OpenFile(const char *filepath)
|
||||||
{
|
{
|
||||||
if(!filepath) return false;
|
if(!filepath)
|
||||||
|
return false;
|
||||||
|
|
||||||
gprintf("Trying to open '%s'...", filepath);
|
gprintf("Trying to open '%s'...", filepath);
|
||||||
file = fopen(filepath, "rb");
|
file = fopen(filepath, "rb");
|
||||||
@ -110,7 +111,8 @@ void GameTDB::CloseFile()
|
|||||||
delete [] GameNodeCache;
|
delete [] GameNodeCache;
|
||||||
GameNodeCache = NULL;
|
GameNodeCache = NULL;
|
||||||
|
|
||||||
if(file) fclose(file);
|
if(file)
|
||||||
|
fclose(file);
|
||||||
file = NULL;
|
file = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,7 +129,8 @@ void GameTDB::Refresh()
|
|||||||
|
|
||||||
bool GameTDB::LoadGameOffsets(const char *path)
|
bool GameTDB::LoadGameOffsets(const char *path)
|
||||||
{
|
{
|
||||||
if(!path) return false;
|
if(!path)
|
||||||
|
return false;
|
||||||
|
|
||||||
string OffsetDBPath = path;
|
string OffsetDBPath = path;
|
||||||
if(strlen(path) > 0 && path[strlen(path)-1] != '/')
|
if(strlen(path) > 0 && path[strlen(path)-1] != '/')
|
||||||
@ -144,9 +147,9 @@ bool GameTDB::LoadGameOffsets(const char * path)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long long ExistingVersion = GetGameTDBVersion();
|
u64 ExistingVersion = GetGameTDBVersion();
|
||||||
unsigned long long Version = 0;
|
u64 Version = 0;
|
||||||
unsigned int NodeCount = 0;
|
u32 NodeCount = 0;
|
||||||
|
|
||||||
fread(&Version, 1, sizeof(Version), fp);
|
fread(&Version, 1, sizeof(Version), fp);
|
||||||
|
|
||||||
@ -195,10 +198,11 @@ bool GameTDB::SaveGameOffsets(const char * path)
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
FILE *fp = fopen(path, "wb");
|
FILE *fp = fopen(path, "wb");
|
||||||
if(!fp) return false;
|
if(!fp)
|
||||||
|
return false;
|
||||||
|
|
||||||
unsigned long long ExistingVersion = GetGameTDBVersion();
|
u64 ExistingVersion = GetGameTDBVersion();
|
||||||
unsigned int NodeCount = OffsetMap.size();
|
u32 NodeCount = OffsetMap.size();
|
||||||
|
|
||||||
if(fwrite(&ExistingVersion, 1, sizeof(ExistingVersion), fp) != sizeof(ExistingVersion))
|
if(fwrite(&ExistingVersion, 1, sizeof(ExistingVersion), fp) != sizeof(ExistingVersion))
|
||||||
{
|
{
|
||||||
@ -223,7 +227,7 @@ bool GameTDB::SaveGameOffsets(const char * path)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long long GameTDB::GetGameTDBVersion()
|
u64 GameTDB::GetGameTDBVersion()
|
||||||
{
|
{
|
||||||
if(!file)
|
if(!file)
|
||||||
return 0;
|
return 0;
|
||||||
@ -252,7 +256,7 @@ int GameTDB::GetData(char * data, int offset, int size)
|
|||||||
|
|
||||||
char *GameTDB::LoadGameNode(const char *id)
|
char *GameTDB::LoadGameNode(const char *id)
|
||||||
{
|
{
|
||||||
unsigned int read = 0;
|
u32 read = 0;
|
||||||
|
|
||||||
GameOffsets *offset = this->GetGameOffset(id);
|
GameOffsets *offset = this->GetGameOffset(id);
|
||||||
if(!offset)
|
if(!offset)
|
||||||
@ -304,7 +308,7 @@ char * GameTDB::GetGameNode(const char * id)
|
|||||||
|
|
||||||
GameOffsets *GameTDB::GetGameOffset(const char *gameID)
|
GameOffsets *GameTDB::GetGameOffset(const char *gameID)
|
||||||
{
|
{
|
||||||
for(unsigned int i = 0; i < OffsetMap.size(); ++i)
|
for(u32 i = 0; i < OffsetMap.size(); ++i)
|
||||||
{
|
{
|
||||||
if(strncmp(gameID, OffsetMap[i].gameID, strlen(OffsetMap[i].gameID)) == 0)
|
if(strncmp(gameID, OffsetMap[i].gameID, strlen(OffsetMap[i].gameID)) == 0)
|
||||||
return &OffsetMap[i];
|
return &OffsetMap[i];
|
||||||
@ -373,7 +377,8 @@ char * GameTDB::GetNodeText(char * data, const char * nodestart, const char * no
|
|||||||
|
|
||||||
char *GameTDB::SeekLang(char *text, const char *langcode)
|
char *GameTDB::SeekLang(char *text, const char *langcode)
|
||||||
{
|
{
|
||||||
if(!text || !langcode) return NULL;
|
if(!text || !langcode)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
char *ptr = text;
|
char *ptr = text;
|
||||||
while((ptr = strstr(ptr, "<locale lang=")) != NULL)
|
while((ptr = strstr(ptr, "<locale lang=")) != NULL)
|
||||||
@ -468,16 +473,12 @@ bool GameTDB::FindTitle(char * data, string & title, string langCode)
|
|||||||
{
|
{
|
||||||
language = SeekLang(data, "EN");
|
language = SeekLang(data, "EN");
|
||||||
if(!language)
|
if(!language)
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
char *the_title = GetNodeText(language, "<title>", "</title>");
|
char *the_title = GetNodeText(language, "<title>", "</title>");
|
||||||
if(!the_title)
|
if(!the_title)
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
char tmp[64];
|
char tmp[64];
|
||||||
strncpy(tmp, the_title, sizeof(tmp) - 1);
|
strncpy(tmp, the_title, sizeof(tmp) - 1);
|
||||||
@ -489,10 +490,12 @@ bool GameTDB::FindTitle(char * data, string & title, string langCode)
|
|||||||
bool GameTDB::GetTitle(const char *id, string & title)
|
bool GameTDB::GetTitle(const char *id, string & title)
|
||||||
{
|
{
|
||||||
title = "";
|
title = "";
|
||||||
if(!id) return false;
|
if(!id)
|
||||||
|
return false;
|
||||||
|
|
||||||
char *data = GetGameNode(id);
|
char *data = GetGameNode(id);
|
||||||
if(!data) return false;
|
if(!data)
|
||||||
|
return false;
|
||||||
|
|
||||||
bool retval = FindTitle(data, title, LangCode);
|
bool retval = FindTitle(data, title, LangCode);
|
||||||
|
|
||||||
@ -504,10 +507,12 @@ bool GameTDB::GetTitle(const char * id, string & title)
|
|||||||
bool GameTDB::GetSynopsis(const char *id, string & synopsis)
|
bool GameTDB::GetSynopsis(const char *id, string & synopsis)
|
||||||
{
|
{
|
||||||
synopsis = "";
|
synopsis = "";
|
||||||
if(!id) return false;
|
if(!id)
|
||||||
|
return false;
|
||||||
|
|
||||||
char *data = GetGameNode(id);
|
char *data = GetGameNode(id);
|
||||||
if(!data) return false;
|
if(!data)
|
||||||
|
return false;
|
||||||
|
|
||||||
char *language = SeekLang(data, LangCode.c_str());
|
char *language = SeekLang(data, LangCode.c_str());
|
||||||
if(!language)
|
if(!language)
|
||||||
@ -537,10 +542,12 @@ bool GameTDB::GetSynopsis(const char * id, string & synopsis)
|
|||||||
bool GameTDB::GetRegion(const char *id, string & region)
|
bool GameTDB::GetRegion(const char *id, string & region)
|
||||||
{
|
{
|
||||||
region = "";
|
region = "";
|
||||||
if(!id) return false;
|
if(!id)
|
||||||
|
return false;
|
||||||
|
|
||||||
char *data = GetGameNode(id);
|
char *data = GetGameNode(id);
|
||||||
if(!data) return false;
|
if(!data)
|
||||||
|
return false;
|
||||||
|
|
||||||
char *the_region = GetNodeText(data, "<region>", "</region>");
|
char *the_region = GetNodeText(data, "<region>", "</region>");
|
||||||
if(!the_region)
|
if(!the_region)
|
||||||
@ -559,10 +566,12 @@ bool GameTDB::GetRegion(const char * id, string & region)
|
|||||||
bool GameTDB::GetDeveloper(const char *id, string & dev)
|
bool GameTDB::GetDeveloper(const char *id, string & dev)
|
||||||
{
|
{
|
||||||
dev = "";
|
dev = "";
|
||||||
if(!id) return false;
|
if(!id)
|
||||||
|
return false;
|
||||||
|
|
||||||
char *data = GetGameNode(id);
|
char *data = GetGameNode(id);
|
||||||
if(!data) return false;
|
if(!data)
|
||||||
|
return false;
|
||||||
|
|
||||||
char *the_dev = GetNodeText(data, "<developer>", "</developer>");
|
char *the_dev = GetNodeText(data, "<developer>", "</developer>");
|
||||||
if(!the_dev)
|
if(!the_dev)
|
||||||
@ -581,10 +590,12 @@ bool GameTDB::GetDeveloper(const char * id, string & dev)
|
|||||||
bool GameTDB::GetPublisher(const char *id, string & pub)
|
bool GameTDB::GetPublisher(const char *id, string & pub)
|
||||||
{
|
{
|
||||||
pub = "";
|
pub = "";
|
||||||
if(!id) return false;
|
if(!id)
|
||||||
|
return false;
|
||||||
|
|
||||||
char *data = GetGameNode(id);
|
char *data = GetGameNode(id);
|
||||||
if(!data) return false;
|
if(!data)
|
||||||
|
return false;
|
||||||
|
|
||||||
char *the_pub = GetNodeText(data, "<publisher>", "</publisher>");
|
char *the_pub = GetNodeText(data, "<publisher>", "</publisher>");
|
||||||
if(!the_pub)
|
if(!the_pub)
|
||||||
@ -600,12 +611,14 @@ bool GameTDB::GetPublisher(const char * id, string & pub)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int GameTDB::GetPublishDate(const char * id)
|
u32 GameTDB::GetPublishDate(const char *id)
|
||||||
{
|
{
|
||||||
if(!id) return 0;
|
if(!id)
|
||||||
|
return 0;
|
||||||
|
|
||||||
char *data = GetGameNode(id);
|
char *data = GetGameNode(id);
|
||||||
if(!data) return 0;
|
if(!data)
|
||||||
|
return 0;
|
||||||
|
|
||||||
char *year_string = GetNodeText(data, "<date year=\"", "/>");
|
char *year_string = GetNodeText(data, "<date year=\"", "/>");
|
||||||
if(!year_string)
|
if(!year_string)
|
||||||
@ -614,7 +627,7 @@ unsigned int GameTDB::GetPublishDate(const char * id)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int year, day, month;
|
u32 year, day, month;
|
||||||
|
|
||||||
year = atoi(year_string);
|
year = atoi(year_string);
|
||||||
|
|
||||||
@ -650,10 +663,12 @@ bool GameTDB::GetGenres(const char * id, string & gen)
|
|||||||
vector<string> genre;
|
vector<string> genre;
|
||||||
|
|
||||||
gen = "";
|
gen = "";
|
||||||
if(!id) return false;
|
if(!id)
|
||||||
|
return false;
|
||||||
|
|
||||||
char *data = GetGameNode(id);
|
char *data = GetGameNode(id);
|
||||||
if(!data) return false;
|
if(!data)
|
||||||
|
return false;
|
||||||
|
|
||||||
char *the_genre = GetNodeText(data, "<genre>", "</genre>");
|
char *the_genre = GetNodeText(data, "<genre>", "</genre>");
|
||||||
if(!the_genre)
|
if(!the_genre)
|
||||||
@ -662,7 +677,7 @@ bool GameTDB::GetGenres(const char * id, string & gen)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int genre_num = 0;
|
u32 genre_num = 0;
|
||||||
const char *ptr = the_genre;
|
const char *ptr = the_genre;
|
||||||
|
|
||||||
while(*ptr != '\0')
|
while(*ptr != '\0')
|
||||||
@ -673,7 +688,8 @@ bool GameTDB::GetGenres(const char * id, string & gen)
|
|||||||
if(*ptr == ',' || *ptr == '/' || *ptr == ';')
|
if(*ptr == ',' || *ptr == '/' || *ptr == ';')
|
||||||
{
|
{
|
||||||
ptr++;
|
ptr++;
|
||||||
while(*ptr == ' ') ptr++;
|
while(*ptr == ' ')
|
||||||
|
ptr++;
|
||||||
genre_num++;
|
genre_num++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -717,10 +733,12 @@ int GameTDB::GetRating(const char * id)
|
|||||||
{
|
{
|
||||||
int rating = -1;
|
int rating = -1;
|
||||||
|
|
||||||
if(!id) return rating;
|
if(!id)
|
||||||
|
return rating;
|
||||||
|
|
||||||
char *data = GetGameNode(id);
|
char *data = GetGameNode(id);
|
||||||
if(!data) return rating;
|
if(!data)
|
||||||
|
return rating;
|
||||||
|
|
||||||
char *rating_text = GetNodeText(data, "<rating type=\"", "/>");
|
char *rating_text = GetNodeText(data, "<rating type=\"", "/>");
|
||||||
if(!rating_text)
|
if(!rating_text)
|
||||||
@ -731,13 +749,10 @@ int GameTDB::GetRating(const char * id)
|
|||||||
|
|
||||||
if(strncmp(rating_text, "CERO", 4) == 0)
|
if(strncmp(rating_text, "CERO", 4) == 0)
|
||||||
rating = GAMETDB_RATING_TYPE_CERO;
|
rating = GAMETDB_RATING_TYPE_CERO;
|
||||||
|
|
||||||
else if(strncmp(rating_text, "ESRB", 4) == 0)
|
else if(strncmp(rating_text, "ESRB", 4) == 0)
|
||||||
rating = GAMETDB_RATING_TYPE_ESRB;
|
rating = GAMETDB_RATING_TYPE_ESRB;
|
||||||
|
|
||||||
else if(strncmp(rating_text, "PEGI", 4) == 0)
|
else if(strncmp(rating_text, "PEGI", 4) == 0)
|
||||||
rating = GAMETDB_RATING_TYPE_PEGI;
|
rating = GAMETDB_RATING_TYPE_PEGI;
|
||||||
|
|
||||||
else if(strncmp(rating_text, "GRB", 4) == 0)
|
else if(strncmp(rating_text, "GRB", 4) == 0)
|
||||||
rating = GAMETDB_RATING_TYPE_GRB;
|
rating = GAMETDB_RATING_TYPE_GRB;
|
||||||
|
|
||||||
@ -749,10 +764,12 @@ int GameTDB::GetRating(const char * id)
|
|||||||
bool GameTDB::GetRatingValue(const char *id, string & rating_value)
|
bool GameTDB::GetRatingValue(const char *id, string & rating_value)
|
||||||
{
|
{
|
||||||
rating_value = "";
|
rating_value = "";
|
||||||
if(!id) return false;
|
if(!id)
|
||||||
|
return false;
|
||||||
|
|
||||||
char *data = GetGameNode(id);
|
char *data = GetGameNode(id);
|
||||||
if(!data) return false;
|
if(!data)
|
||||||
|
return false;
|
||||||
|
|
||||||
char *rating_text = GetNodeText(data, "<rating type=\"", "/>");
|
char *rating_text = GetNodeText(data, "<rating type=\"", "/>");
|
||||||
if(!rating_text)
|
if(!rating_text)
|
||||||
@ -792,7 +809,7 @@ int GameTDB::GetRatingDescriptors(const char * id, vector<string> & desc_list)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int list_num = 0;
|
u32 list_num = 0;
|
||||||
|
|
||||||
while(*descriptor_text != '\0')
|
while(*descriptor_text != '\0')
|
||||||
{
|
{
|
||||||
@ -859,7 +876,7 @@ int GameTDB::GetWifiFeatures(const char * id, vector<string> & feat_list)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int list_num = 0;
|
u32 list_num = 0;
|
||||||
|
|
||||||
while(*feature_text != '\0')
|
while(*feature_text != '\0')
|
||||||
{
|
{
|
||||||
@ -877,7 +894,6 @@ int GameTDB::GetWifiFeatures(const char * id, vector<string> & feat_list)
|
|||||||
if(list_num >= feat_list.size())
|
if(list_num >= feat_list.size())
|
||||||
feat_list.resize(list_num+1);
|
feat_list.resize(list_num+1);
|
||||||
|
|
||||||
|
|
||||||
if(feat_list[list_num].size() == 0)
|
if(feat_list[list_num].size() == 0)
|
||||||
feat_list[list_num].push_back(toupper((int)*feature_text));
|
feat_list[list_num].push_back(toupper((int)*feature_text));
|
||||||
else
|
else
|
||||||
@ -931,7 +947,7 @@ int GameTDB::GetAccessories(const char * id, vector<Accessory> & acc_list)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int list_num = 0;
|
u32 list_num = 0;
|
||||||
|
|
||||||
while(ControlsNode && *ControlsNode != '\0')
|
while(ControlsNode && *ControlsNode != '\0')
|
||||||
{
|
{
|
||||||
@ -940,7 +956,6 @@ int GameTDB::GetAccessories(const char * id, vector<Accessory> & acc_list)
|
|||||||
|
|
||||||
for(const char *ptr = ControlsNode; *ptr != '"' && *ptr != '\0'; ptr++)
|
for(const char *ptr = ControlsNode; *ptr != '"' && *ptr != '\0'; ptr++)
|
||||||
acc_list[list_num].Name.push_back(*ptr);
|
acc_list[list_num].Name.push_back(*ptr);
|
||||||
|
|
||||||
acc_list[list_num].Name.push_back('\0');
|
acc_list[list_num].Name.push_back('\0');
|
||||||
|
|
||||||
char *requiredField = strstr(ControlsNode, "required=\"");
|
char *requiredField = strstr(ControlsNode, "required=\"");
|
||||||
@ -966,14 +981,12 @@ int GameTDB::GetAccessories(const char * id, vector<Accessory> & acc_list)
|
|||||||
return acc_list.size();
|
return acc_list.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int GameTDB::FindCaseColor(char * data)
|
u32 GameTDB::FindCaseColor(char *data)
|
||||||
{
|
{
|
||||||
unsigned int color = -1;
|
u32 color = -1;
|
||||||
|
|
||||||
char *ColorNode = GetNodeText(data, "<case color=\"", "\"");
|
char *ColorNode = GetNodeText(data, "<case color=\"", "\"");
|
||||||
if(!ColorNode)
|
if(!ColorNode || strlen(ColorNode) == 0)
|
||||||
return color;
|
|
||||||
if(strlen(ColorNode) == 0)
|
|
||||||
return color;
|
return color;
|
||||||
|
|
||||||
char format[8];
|
char format[8];
|
||||||
@ -982,9 +995,9 @@ unsigned int GameTDB::FindCaseColor(char * data)
|
|||||||
return strtoul(format, NULL, 16);
|
return strtoul(format, NULL, 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int GameTDB::GetCaseColor(const char * id)
|
u32 GameTDB::GetCaseColor(const char *id)
|
||||||
{
|
{
|
||||||
unsigned int color = -1;
|
u32 color = -1;
|
||||||
if(!id)
|
if(!id)
|
||||||
return color;
|
return color;
|
||||||
|
|
||||||
@ -992,7 +1005,6 @@ unsigned int GameTDB::GetCaseColor(const char * id)
|
|||||||
if(!data)
|
if(!data)
|
||||||
return color;
|
return color;
|
||||||
|
|
||||||
|
|
||||||
color = FindCaseColor(data);
|
color = FindCaseColor(data);
|
||||||
|
|
||||||
if(color != 0xffffffff)
|
if(color != 0xffffffff)
|
||||||
|
@ -497,10 +497,11 @@ void CVideo::_showWaitMessages(CVideo *m)
|
|||||||
|
|
||||||
vector<STexture>::iterator waitItr = m->m_waitMessages.begin();
|
vector<STexture>::iterator waitItr = m->m_waitMessages.begin();
|
||||||
gprintf("Going to show a wait message screen, delay: %d, # images: %d\n", waitFrames, m->m_waitMessages.size());
|
gprintf("Going to show a wait message screen, delay: %d, # images: %d\n", waitFrames, m->m_waitMessages.size());
|
||||||
|
m->_clearScreen();
|
||||||
|
|
||||||
m->waitMessage(*waitItr);
|
m->prepare();
|
||||||
waitItr += PNGfadeDirection;
|
m->setup2DProjection();
|
||||||
|
GX_SetNumChans(0);
|
||||||
wiiLightSetLevel(0);
|
wiiLightSetLevel(0);
|
||||||
wiiLightOn();
|
wiiLightOn();
|
||||||
|
|
||||||
@ -523,16 +524,15 @@ void CVideo::_showWaitMessages(CVideo *m)
|
|||||||
{
|
{
|
||||||
m->waitMessage(*waitItr);
|
m->waitMessage(*waitItr);
|
||||||
waitItr += PNGfadeDirection;
|
waitItr += PNGfadeDirection;
|
||||||
|
|
||||||
if(waitItr == m->m_waitMessages.end())
|
if(waitItr == m->m_waitMessages.end())
|
||||||
waitItr = m->m_waitMessages.begin();
|
waitItr = m->m_waitMessages.begin();
|
||||||
|
|
||||||
waitFrames = frames;
|
waitFrames = frames;
|
||||||
}
|
}
|
||||||
waitFrames--;
|
|
||||||
VIDEO_WaitVSync();
|
VIDEO_WaitVSync();
|
||||||
|
waitFrames--;
|
||||||
}
|
}
|
||||||
wiiLightOff();
|
wiiLightOff();
|
||||||
|
GX_SetNumChans(1);
|
||||||
m->m_showingWaitMessages = false;
|
m->m_showingWaitMessages = false;
|
||||||
gprintf("Stop showing images\n");
|
gprintf("Stop showing images\n");
|
||||||
}
|
}
|
||||||
@ -584,26 +584,23 @@ void CVideo::waitMessage(float delay)
|
|||||||
void CVideo::waitMessage(const vector<STexture> &tex, float delay)
|
void CVideo::waitMessage(const vector<STexture> &tex, float delay)
|
||||||
{
|
{
|
||||||
hideWaitMessage();
|
hideWaitMessage();
|
||||||
|
|
||||||
if(tex.size() == 0)
|
if(tex.size() == 0)
|
||||||
{
|
{
|
||||||
m_waitMessages = m_defaultWaitMessages;
|
m_waitMessages = m_defaultWaitMessages;
|
||||||
m_waitMessageDelay = 0.2f;
|
m_waitMessageDelay = 0.1f;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_waitMessages = tex;
|
m_waitMessages = tex;
|
||||||
m_waitMessageDelay = delay;
|
m_waitMessageDelay = delay;
|
||||||
}
|
}
|
||||||
_clearScreen();
|
|
||||||
|
|
||||||
if(m_waitMessages.size() == 1)
|
if(m_waitMessages.size() == 1)
|
||||||
waitMessage(m_waitMessages[0]);
|
waitMessage(m_waitMessages[0]);
|
||||||
else if(m_waitMessages.size() > 1)
|
else if(m_waitMessages.size() > 1)
|
||||||
{
|
{
|
||||||
CheckWaitThread();
|
|
||||||
m_showWaitMessage = true;
|
m_showWaitMessage = true;
|
||||||
unsigned int stack_size = (unsigned int)32768;
|
u32 stack_size = (u32)32768;
|
||||||
waitThreadStack = smartMem2Alloc(stack_size);
|
waitThreadStack = smartMem2Alloc(stack_size);
|
||||||
LWP_CreateThread(&waitThread, (void *(*)(void *))CVideo::_showWaitMessages, (void *)this, waitThreadStack.get(), stack_size, LWP_PRIO_IDLE);
|
LWP_CreateThread(&waitThread, (void *(*)(void *))CVideo::_showWaitMessages, (void *)this, waitThreadStack.get(), stack_size, LWP_PRIO_IDLE);
|
||||||
}
|
}
|
||||||
@ -614,9 +611,6 @@ void CVideo::waitMessage(const STexture &tex)
|
|||||||
Mtx modelViewMtx;
|
Mtx modelViewMtx;
|
||||||
GXTexObj texObj;
|
GXTexObj texObj;
|
||||||
|
|
||||||
prepare();
|
|
||||||
setup2DProjection();
|
|
||||||
GX_SetNumChans(0);
|
|
||||||
GX_ClearVtxDesc();
|
GX_ClearVtxDesc();
|
||||||
GX_SetVtxDesc(GX_VA_POS, GX_DIRECT);
|
GX_SetVtxDesc(GX_VA_POS, GX_DIRECT);
|
||||||
GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0);
|
GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0);
|
||||||
@ -648,7 +642,6 @@ void CVideo::waitMessage(const STexture &tex)
|
|||||||
GX_TexCoord2f32(0.f, 1.f);
|
GX_TexCoord2f32(0.f, 1.f);
|
||||||
GX_End();
|
GX_End();
|
||||||
render();
|
render();
|
||||||
GX_SetNumChans(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 CVideo::TakeScreenshot(const char *path)
|
s32 CVideo::TakeScreenshot(const char *path)
|
||||||
|
@ -64,6 +64,7 @@ public:
|
|||||||
bool wide(void) const { return m_wide; }
|
bool wide(void) const { return m_wide; }
|
||||||
bool vid_50hz(void) const { return m_50hz; }
|
bool vid_50hz(void) const { return m_50hz; }
|
||||||
u8 getAA(void) const { return m_aa; }
|
u8 getAA(void) const { return m_aa; }
|
||||||
|
bool showingWaitMessage() { return m_showingWaitMessages; }
|
||||||
void set2DViewport(u32 w, u32 h, int x, int y);
|
void set2DViewport(u32 w, u32 h, int x, int y);
|
||||||
void prepareStencil(void);
|
void prepareStencil(void);
|
||||||
void renderStencil(void);
|
void renderStencil(void);
|
||||||
|
@ -57,11 +57,15 @@ s32 Apploader_Run(entry_point *entry, u8 vidMode, GXRModeObj *vmode, bool vipatc
|
|||||||
/* Calculate apploader length */
|
/* Calculate apploader length */
|
||||||
appldr_len = buffer[5] + buffer[6];
|
appldr_len = buffer[5] + buffer[6];
|
||||||
|
|
||||||
|
SYS_SetArena1Hi((void *)0x816FFFF0); //Kills the possibility of codedumps with gprintf
|
||||||
|
|
||||||
/* Read apploader code */
|
/* Read apploader code */
|
||||||
ret = WDVD_Read(appldr, appldr_len, APPLDR_OFFSET + 0x20);
|
ret = WDVD_Read(appldr, appldr_len, APPLDR_OFFSET + 0x20);
|
||||||
if(ret < 0)
|
if(ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
DCFlushRange(appldr, appldr_len);
|
||||||
|
|
||||||
/* Set apploader entry function */
|
/* Set apploader entry function */
|
||||||
app_entry appldr_entry = (app_entry)buffer[4];
|
app_entry appldr_entry = (app_entry)buffer[4];
|
||||||
|
|
||||||
|
@ -241,7 +241,7 @@ int get_frag_list(u8 *id, char *path, const u32 hdd_sector_size)
|
|||||||
frag_concat(fa, fs);
|
frag_concat(fa, fs);
|
||||||
}
|
}
|
||||||
|
|
||||||
frag_list = MEM1_memalign(32, sizeof(FragList));
|
frag_list = MEM1_alloc(ALIGN32(sizeof(FragList)));
|
||||||
if(frag_list == NULL)
|
if(frag_list == NULL)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
@ -307,10 +307,12 @@ int set_frag_list(u8 *id)
|
|||||||
DCFlushRange(frag_list, size);
|
DCFlushRange(frag_list, size);
|
||||||
|
|
||||||
gprintf("Calling WDVD_SetFragList, frag list size %d\n", size);
|
gprintf("Calling WDVD_SetFragList, frag list size %d\n", size);
|
||||||
|
/* if (size > 400) ghexdump(frag_list, 400);
|
||||||
|
else ghexdump(frag_list, size); */
|
||||||
|
|
||||||
int ret = WDVD_SetFragList(wbfsDev, frag_list, size);
|
int ret = WDVD_SetFragList(wbfsDev, frag_list, size);
|
||||||
|
|
||||||
MEM1_free(frag_list);
|
free(frag_list);
|
||||||
frag_list = NULL;
|
frag_list = NULL;
|
||||||
|
|
||||||
if(ret)
|
if(ret)
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
#include "splits.h"
|
#include "splits.h"
|
||||||
#include "gecko/gecko.h"
|
#include "gecko.h"
|
||||||
|
|
||||||
#define off64_t off_t
|
#define off64_t off_t
|
||||||
#define FMT_llu "%llu"
|
#define FMT_llu "%llu"
|
||||||
|
@ -53,6 +53,8 @@ wbfs_disc_t* WBFS_Ext_OpenDisc(u8 *discid, char *fname)
|
|||||||
if (fd == -1) return NULL;
|
if (fd == -1) return NULL;
|
||||||
|
|
||||||
wbfs_disc_t *iso_file = MEM2_alloc(sizeof(wbfs_disc_t));
|
wbfs_disc_t *iso_file = MEM2_alloc(sizeof(wbfs_disc_t));
|
||||||
|
memset(iso_file, 0, sizeof(wbfs_disc_t));
|
||||||
|
|
||||||
if (iso_file == NULL)
|
if (iso_file == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -109,9 +109,8 @@ int load_wip_patches(u8 *dir, u8 *gameid)
|
|||||||
|
|
||||||
while(fgets(line, sizeof(line), fp))
|
while(fgets(line, sizeof(line), fp))
|
||||||
{
|
{
|
||||||
if (line[0] == '#') continue;
|
if(line[0] == '#' || strlen(line) < 26)
|
||||||
|
continue;
|
||||||
if(strlen(line) < 26) continue;
|
|
||||||
|
|
||||||
u32 offset = (u32) strtoul(line, NULL, 16);
|
u32 offset = (u32) strtoul(line, NULL, 16);
|
||||||
u32 srcaddress = (u32) strtoul(line+9, NULL, 16);
|
u32 srcaddress = (u32) strtoul(line+9, NULL, 16);
|
||||||
|
@ -37,7 +37,7 @@ int main(int argc, char **argv)
|
|||||||
vid.init();
|
vid.init();
|
||||||
|
|
||||||
MEM2_init(47); //Should be safe to use
|
MEM2_init(47); //Should be safe to use
|
||||||
vid.waitMessage(0.2f);
|
vid.waitMessage(0.1f);
|
||||||
|
|
||||||
AllocSDGeckoBuffer();
|
AllocSDGeckoBuffer();
|
||||||
gprintf(" \nWelcome to %s (%s-r%s)!\nThis is the debug output.\n", APP_NAME, APP_VERSION, SVN_REV);
|
gprintf(" \nWelcome to %s (%s-r%s)!\nThis is the debug output.\n", APP_NAME, APP_VERSION, SVN_REV);
|
||||||
|
@ -1812,8 +1812,9 @@ void CMenu::_mainLoopCommon(bool withCF, bool blockReboot, bool adjusting)
|
|||||||
|
|
||||||
m_btnMgr.draw();
|
m_btnMgr.draw();
|
||||||
ScanInput();
|
ScanInput();
|
||||||
|
if(!m_vid.showingWaitMessage())
|
||||||
m_vid.render();
|
m_vid.render();
|
||||||
|
|
||||||
if(!blockReboot)
|
if(!blockReboot)
|
||||||
{
|
{
|
||||||
if(withCF && Sys_Exiting())
|
if(withCF && Sys_Exiting())
|
||||||
|
@ -1427,7 +1427,6 @@ void CMenu::_launchGame(dir_discHdr *hdr, bool dvd)
|
|||||||
|
|
||||||
if(currentPartition == 0)
|
if(currentPartition == 0)
|
||||||
SDHC_Init();
|
SDHC_Init();
|
||||||
GeckoDisable();
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
RunApploader(offset, videoMode, vipatch, countryPatch, patchVidMode, aspectRatio, returnTo);
|
RunApploader(offset, videoMode, vipatch, countryPatch, patchVidMode, aspectRatio, returnTo);
|
||||||
|
@ -188,11 +188,12 @@ int CMenu::GetCoverStatusAsync(CMenu *m)
|
|||||||
|
|
||||||
void CMenu::LoadView(void)
|
void CMenu::LoadView(void)
|
||||||
{
|
{
|
||||||
_showWaitMessage();
|
|
||||||
_hideMain();
|
|
||||||
|
|
||||||
m_curGameId = m_cf.getId();
|
m_curGameId = m_cf.getId();
|
||||||
|
|
||||||
|
_hideMain(true);
|
||||||
|
m_cf.clear();
|
||||||
|
_showWaitMessage();
|
||||||
|
|
||||||
_loadList();
|
_loadList();
|
||||||
_showMain();
|
_showMain();
|
||||||
_initCF();
|
_initCF();
|
||||||
@ -418,8 +419,10 @@ int CMenu::main(void)
|
|||||||
}
|
}
|
||||||
else if(m_btnMgr.selected(m_mainBtnDVD))
|
else if(m_btnMgr.selected(m_mainBtnDVD))
|
||||||
{
|
{
|
||||||
_showWaitMessage();
|
|
||||||
_hideMain(true);
|
_hideMain(true);
|
||||||
|
m_cf.clear();
|
||||||
|
_showWaitMessage();
|
||||||
|
|
||||||
dir_discHdr hdr;
|
dir_discHdr hdr;
|
||||||
memset(&hdr, 0, sizeof(dir_discHdr));
|
memset(&hdr, 0, sizeof(dir_discHdr));
|
||||||
memcpy(&hdr.id, "dvddvd", 6);
|
memcpy(&hdr.id, "dvddvd", 6);
|
||||||
|
@ -53,30 +53,32 @@ typedef struct
|
|||||||
|
|
||||||
# define UnsignedToFloat(u) (((double)((long)(u - 2147483647L - 1))) + 2147483648.0)
|
# define UnsignedToFloat(u) (((double)((long)(u - 2147483647L - 1))) + 2147483648.0)
|
||||||
|
|
||||||
static double ConvertFromIeeeExtended(const unsigned char* bytes)
|
static double ConvertFromIeeeExtended(const u8* bytes)
|
||||||
{
|
{
|
||||||
double f;
|
double f;
|
||||||
int expon;
|
int expon;
|
||||||
unsigned long hiMant, loMant;
|
u64 hiMant, loMant;
|
||||||
|
|
||||||
expon = ((bytes[0] & 0x7F) << 8) | (bytes[1] & 0xFF);
|
expon = ((bytes[0] & 0x7F) << 8) | (bytes[1] & 0xFF);
|
||||||
hiMant = ((unsigned long)(bytes[2] & 0xFF) << 24)
|
|
||||||
| ((unsigned long)(bytes[3] & 0xFF) << 16)
|
|
||||||
| ((unsigned long)(bytes[4] & 0xFF) << 8)
|
|
||||||
| ((unsigned long)(bytes[5] & 0xFF));
|
|
||||||
loMant = ((unsigned long)(bytes[6] & 0xFF) << 24)
|
|
||||||
| ((unsigned long)(bytes[7] & 0xFF) << 16)
|
|
||||||
| ((unsigned long)(bytes[8] & 0xFF) << 8)
|
|
||||||
| ((unsigned long)(bytes[9] & 0xFF));
|
|
||||||
|
|
||||||
if (expon == 0 && hiMant == 0 && loMant == 0) {
|
hiMant = ((u64)(bytes[2] & 0xFF) << 24)
|
||||||
|
| ((u64)(bytes[3] & 0xFF) << 16)
|
||||||
|
| ((u64)(bytes[4] & 0xFF) << 8)
|
||||||
|
| ((u64)(bytes[5] & 0xFF));
|
||||||
|
|
||||||
|
loMant = ((u64)(bytes[6] & 0xFF) << 24)
|
||||||
|
| ((u64)(bytes[7] & 0xFF) << 16)
|
||||||
|
| ((u64)(bytes[8] & 0xFF) << 8)
|
||||||
|
| ((u64)(bytes[9] & 0xFF));
|
||||||
|
|
||||||
|
if(expon == 0 && hiMant == 0 && loMant == 0)
|
||||||
f = 0;
|
f = 0;
|
||||||
}
|
else
|
||||||
else {
|
{
|
||||||
if (expon == 0x7FFF) {
|
if(expon == 0x7FFF)
|
||||||
f = HUGE_VAL;
|
f = HUGE_VAL;
|
||||||
}
|
else
|
||||||
else {
|
{
|
||||||
expon -= 16383;
|
expon -= 16383;
|
||||||
f = ldexp(UnsignedToFloat(hiMant), expon-=31);
|
f = ldexp(UnsignedToFloat(hiMant), expon-=31);
|
||||||
f += ldexp(UnsignedToFloat(loMant), expon-=32);
|
f += ldexp(UnsignedToFloat(loMant), expon-=32);
|
||||||
@ -227,9 +229,7 @@ int AifDecoder::Read(u8 * buffer, int buffer_size, int)
|
|||||||
|
|
||||||
int read = file_fd->read(buffer, buffer_size);
|
int read = file_fd->read(buffer, buffer_size);
|
||||||
if(read > 0)
|
if(read > 0)
|
||||||
{
|
|
||||||
CurPos += read;
|
CurPos += read;
|
||||||
}
|
|
||||||
|
|
||||||
return read;
|
return read;
|
||||||
}
|
}
|
||||||
|
@ -112,17 +112,11 @@ int CFile::seek(long int offset, int origin)
|
|||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
if(origin == SEEK_SET)
|
if(origin == SEEK_SET)
|
||||||
{
|
|
||||||
Pos = offset;
|
Pos = offset;
|
||||||
}
|
|
||||||
else if(origin == SEEK_CUR)
|
else if(origin == SEEK_CUR)
|
||||||
{
|
|
||||||
Pos += offset;
|
Pos += offset;
|
||||||
}
|
|
||||||
else if(origin == SEEK_END)
|
else if(origin == SEEK_END)
|
||||||
{
|
|
||||||
Pos = filesize+offset;
|
Pos = filesize+offset;
|
||||||
}
|
|
||||||
if(Pos < 0)
|
if(Pos < 0)
|
||||||
{
|
{
|
||||||
Pos = 0;
|
Pos = 0;
|
||||||
@ -132,14 +126,11 @@ int CFile::seek(long int offset, int origin)
|
|||||||
if(file_fd)
|
if(file_fd)
|
||||||
ret = fseek(file_fd, Pos, SEEK_SET);
|
ret = fseek(file_fd, Pos, SEEK_SET);
|
||||||
|
|
||||||
if(mem_file != NULL)
|
if(mem_file != NULL && Pos > (long int)filesize)
|
||||||
{
|
|
||||||
if(Pos > (long int) filesize)
|
|
||||||
{
|
{
|
||||||
Pos = filesize;
|
Pos = filesize;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -54,6 +54,7 @@ WavDecoder::WavDecoder(const u8 * snd, int len)
|
|||||||
|
|
||||||
WavDecoder::~WavDecoder()
|
WavDecoder::~WavDecoder()
|
||||||
{
|
{
|
||||||
|
CloseFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WavDecoder::OpenFile()
|
void WavDecoder::OpenFile()
|
||||||
|
@ -56,7 +56,8 @@ static inline int GetFirstUnusedVoice()
|
|||||||
extern "C" void SoundCallback(s32 voice)
|
extern "C" void SoundCallback(s32 voice)
|
||||||
{
|
{
|
||||||
SoundDecoder *decoder = SoundHandler::Instance()->Decoder(voice);
|
SoundDecoder *decoder = SoundHandler::Instance()->Decoder(voice);
|
||||||
if(!decoder) return;
|
if(!decoder)
|
||||||
|
return;
|
||||||
|
|
||||||
if(decoder->IsBufferReady())
|
if(decoder->IsBufferReady())
|
||||||
{
|
{
|
||||||
@ -98,7 +99,8 @@ GuiSound::GuiSound(GuiSound *g)
|
|||||||
voice = -1;
|
voice = -1;
|
||||||
|
|
||||||
Init();
|
Init();
|
||||||
if (g == NULL) return;
|
if(g == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
if(g->sound != NULL)
|
if(g->sound != NULL)
|
||||||
{
|
{
|
||||||
@ -161,7 +163,8 @@ bool GuiSound::Load(const char * filepath)
|
|||||||
|
|
||||||
FILE * f = fopen(filepath, "rb");
|
FILE * f = fopen(filepath, "rb");
|
||||||
if(!f)
|
if(!f)
|
||||||
{ gprintf("Failed to load file %s!!\n", filepath);
|
{
|
||||||
|
gprintf("Failed to load file %s!!\n", filepath);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,12 +176,14 @@ bool GuiSound::Load(const char * filepath)
|
|||||||
gprintf("Loading %s using voice %d\n", filepath, voice);
|
gprintf("Loading %s using voice %d\n", filepath, voice);
|
||||||
SoundDecoder * decoder = SoundHandler::Instance()->Decoder(voice);
|
SoundDecoder * decoder = SoundHandler::Instance()->Decoder(voice);
|
||||||
if(!decoder)
|
if(!decoder)
|
||||||
{ gprintf("No Decoder!!!\n");
|
{
|
||||||
|
gprintf("No Decoder!!!\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!decoder->IsBufferReady())
|
if(!decoder->IsBufferReady())
|
||||||
{ gprintf("Buffer not ready!!n");
|
{
|
||||||
|
gprintf("Buffer not ready!!\n");
|
||||||
SoundHandler::Instance()->RemoveDecoder(voice);
|
SoundHandler::Instance()->RemoveDecoder(voice);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -194,15 +199,14 @@ bool GuiSound::Load(const u8 * snd, u32 len, bool isallocated)
|
|||||||
FreeMemory();
|
FreeMemory();
|
||||||
this->voice = voice;
|
this->voice = voice;
|
||||||
|
|
||||||
if(!snd) return false;
|
if(!snd)
|
||||||
|
return false;
|
||||||
|
|
||||||
if(!isallocated && *((u32 *) snd) == 'RIFF')
|
if(!isallocated && *((u32 *) snd) == 'RIFF')
|
||||||
return LoadSoundEffect(snd, len);
|
return LoadSoundEffect(snd, len);
|
||||||
|
|
||||||
if(*((u32 *) snd) == 'IMD5')
|
if(*((u32 *) snd) == 'IMD5')
|
||||||
{
|
|
||||||
UncompressSoundbin(snd, len, isallocated);
|
UncompressSoundbin(snd, len, isallocated);
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sound = (u8 *) snd;
|
sound = (u8 *) snd;
|
||||||
@ -214,9 +218,7 @@ bool GuiSound::Load(const u8 * snd, u32 len, bool isallocated)
|
|||||||
|
|
||||||
SoundDecoder * decoder = SoundHandler::Instance()->Decoder(voice);
|
SoundDecoder * decoder = SoundHandler::Instance()->Decoder(voice);
|
||||||
if(!decoder)
|
if(!decoder)
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
if(!decoder->IsBufferReady())
|
if(!decoder->IsBufferReady())
|
||||||
{
|
{
|
||||||
@ -274,10 +276,12 @@ void GuiSound::Play(int vol, bool restart)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((IsPlaying() && !restart) || voice < 0 || voice >= 16) return;
|
if((IsPlaying() && !restart) || voice < 0 || voice >= 16)
|
||||||
|
return;
|
||||||
|
|
||||||
SoundDecoder *decoder = SoundHandler::Instance()->Decoder(voice);
|
SoundDecoder *decoder = SoundHandler::Instance()->Decoder(voice);
|
||||||
if(!decoder) return;
|
if(!decoder)
|
||||||
|
return;
|
||||||
|
|
||||||
ASND_StopVoice(voice);
|
ASND_StopVoice(voice);
|
||||||
if(decoder->IsEOF())
|
if(decoder->IsEOF())
|
||||||
@ -309,7 +313,8 @@ void GuiSound::Stop()
|
|||||||
ASND_StopVoice(voice);
|
ASND_StopVoice(voice);
|
||||||
|
|
||||||
SoundDecoder *decoder = SoundHandler::Instance()->Decoder(voice);
|
SoundDecoder *decoder = SoundHandler::Instance()->Decoder(voice);
|
||||||
if(!decoder) return;
|
if(!decoder)
|
||||||
|
return;
|
||||||
|
|
||||||
decoder->ClearBuffer();
|
decoder->ClearBuffer();
|
||||||
Rewind();
|
Rewind();
|
||||||
@ -362,7 +367,8 @@ void GuiSound::SetLoop(u8 l)
|
|||||||
loop = l;
|
loop = l;
|
||||||
|
|
||||||
SoundDecoder *decoder = SoundHandler::Instance()->Decoder(voice);
|
SoundDecoder *decoder = SoundHandler::Instance()->Decoder(voice);
|
||||||
if(!decoder) return;
|
if(!decoder)
|
||||||
|
return;
|
||||||
|
|
||||||
decoder->SetLoop(l == 1);
|
decoder->SetLoop(l == 1);
|
||||||
}
|
}
|
||||||
@ -370,7 +376,8 @@ void GuiSound::SetLoop(u8 l)
|
|||||||
void GuiSound::Rewind()
|
void GuiSound::Rewind()
|
||||||
{
|
{
|
||||||
SoundDecoder *decoder = SoundHandler::Instance()->Decoder(voice);
|
SoundDecoder *decoder = SoundHandler::Instance()->Decoder(voice);
|
||||||
if(!decoder) return;
|
if(!decoder)
|
||||||
|
return;
|
||||||
|
|
||||||
decoder->Rewind();
|
decoder->Rewind();
|
||||||
}
|
}
|
||||||
@ -397,7 +404,8 @@ u8 * uncompressLZ77(const u8 *inBuf, u32 inLength, u32 * size)
|
|||||||
|
|
||||||
buffer = (u8 *)malloc(uncSize);
|
buffer = (u8 *)malloc(uncSize);
|
||||||
|
|
||||||
if (!buffer) return buffer;
|
if(!buffer)
|
||||||
|
return buffer;
|
||||||
|
|
||||||
u8 *bufCur = buffer;
|
u8 *bufCur = buffer;
|
||||||
u8 *bufEnd = buffer + uncSize;
|
u8 *bufEnd = buffer + uncSize;
|
||||||
@ -439,7 +447,8 @@ void GuiSound::UncompressSoundbin(const u8 * snd, u32 len, bool isallocated)
|
|||||||
const u8 * file = snd+32;
|
const u8 * file = snd+32;
|
||||||
|
|
||||||
length = len-32;
|
length = len-32;
|
||||||
if (length <= 0) return;
|
if(length <= 0)
|
||||||
|
return;
|
||||||
|
|
||||||
if(*((u32 *) file) == 'LZ77')
|
if(*((u32 *) file) == 'LZ77')
|
||||||
{
|
{
|
||||||
|
@ -40,7 +40,8 @@
|
|||||||
ZipFile::ZipFile(const char *filepath)
|
ZipFile::ZipFile(const char *filepath)
|
||||||
{
|
{
|
||||||
File = unzOpen(filepath);
|
File = unzOpen(filepath);
|
||||||
if (File) this->LoadList();
|
if(File)
|
||||||
|
this->LoadList();
|
||||||
}
|
}
|
||||||
|
|
||||||
ZipFile::~ZipFile()
|
ZipFile::~ZipFile()
|
||||||
@ -52,75 +53,27 @@ bool ZipFile::LoadList()
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
bool ZipFile::FindFile(const char *file)
|
|
||||||
{
|
|
||||||
if (!File) return false;
|
|
||||||
|
|
||||||
char filename[MAXPATHLEN];
|
|
||||||
|
|
||||||
int ret = unzGoToFirstFile(File);
|
|
||||||
if (ret != UNZ_OK) return false;
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
if(unzGetCurrentFileInfo(File, &cur_file_info, filename, sizeof(filename), NULL, 0, NULL, 0) != UNZ_OK)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
const char *realfilename = strrchr(filename, '/');
|
|
||||||
if(!realfilename || strlen(realfilename) == 0)
|
|
||||||
realfilename = filename;
|
|
||||||
|
|
||||||
if(strcasecmp(realfilename, file) == 0)
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
while(unzGoToNextFile(File) == UNZ_OK);
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ZipFile::FindFilePart(const char *partfilename, std::string &realname)
|
|
||||||
{
|
|
||||||
if (!File) return false;
|
|
||||||
|
|
||||||
char filename[MAXPATHLEN];
|
|
||||||
|
|
||||||
int ret = unzGoToFirstFile(File);
|
|
||||||
if (ret != UNZ_OK) return false;
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
if(unzGetCurrentFileInfo(File, &cur_file_info, filename, sizeof(filename), NULL, 0, NULL, 0) != UNZ_OK)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if(strcasestr(filename, partfilename) != 0)
|
|
||||||
{
|
|
||||||
realname = filename;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
while(unzGoToNextFile(File) == UNZ_OK);
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
bool ZipFile::ExtractAll(const char *dest)
|
bool ZipFile::ExtractAll(const char *dest)
|
||||||
{
|
{
|
||||||
if (!File) return false;
|
if(!File)
|
||||||
|
return false;
|
||||||
|
|
||||||
bool Stop = false;
|
bool Stop = false;
|
||||||
|
|
||||||
u32 blocksize = 1024 * 50;
|
u32 blocksize = 1024 * 50;
|
||||||
u8 *buffer = new u8[blocksize];
|
u8 *buffer = new u8[blocksize];
|
||||||
|
|
||||||
if (!buffer) return false;
|
if(!buffer)
|
||||||
|
return false;
|
||||||
|
|
||||||
char writepath[MAXPATHLEN];
|
char writepath[MAXPATHLEN];
|
||||||
char filename[MAXPATHLEN];
|
char filename[MAXPATHLEN];
|
||||||
memset(filename, 0, sizeof(filename));
|
memset(filename, 0, sizeof(filename));
|
||||||
|
|
||||||
int ret = unzGoToFirstFile(File);
|
int ret = unzGoToFirstFile(File);
|
||||||
if (ret != UNZ_OK) Stop = true;
|
if(ret != UNZ_OK)
|
||||||
|
Stop = true;
|
||||||
|
|
||||||
while(!Stop)
|
while(!Stop)
|
||||||
{
|
{
|
||||||
@ -152,11 +105,13 @@ bool ZipFile::ExtractAll(const char *dest)
|
|||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if (uncompressed_size - done < blocksize) blocksize = uncompressed_size - done;
|
if(uncompressed_size - done < blocksize)
|
||||||
|
blocksize = uncompressed_size - done;
|
||||||
|
|
||||||
ret = unzReadCurrentFile(File, buffer, blocksize);
|
ret = unzReadCurrentFile(File, buffer, blocksize);
|
||||||
|
|
||||||
if (ret == 0) break;
|
if(ret == 0)
|
||||||
|
break;
|
||||||
|
|
||||||
fwrite(buffer, 1, blocksize, pfile);
|
fwrite(buffer, 1, blocksize, pfile);
|
||||||
|
|
||||||
@ -168,7 +123,8 @@ bool ZipFile::ExtractAll(const char *dest)
|
|||||||
unzCloseCurrentFile(File);
|
unzCloseCurrentFile(File);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (unzGoToNextFile(File) != UNZ_OK) Stop = true;
|
if(unzGoToNextFile(File) != UNZ_OK)
|
||||||
|
Stop = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
delete[] buffer;
|
delete[] buffer;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user