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");
|
||||||
|
@ -422,10 +422,10 @@ u32 Nand::__configsetsetting(const char *item, const char *val)
|
|||||||
void Nand::__FATify(char *ptr, const char *str)
|
void Nand::__FATify(char *ptr, const char *str)
|
||||||
{
|
{
|
||||||
char ctr;
|
char ctr;
|
||||||
while ((ctr = *(str++)) != '\0')
|
while((ctr = *(str++)) != '\0')
|
||||||
{
|
{
|
||||||
const char *esc;
|
const char *esc;
|
||||||
switch (ctr)
|
switch(ctr)
|
||||||
{
|
{
|
||||||
case '"':
|
case '"':
|
||||||
esc = "&qt;";
|
esc = "&qt;";
|
||||||
@ -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_
|
||||||
|
|
||||||
@ -7,17 +6,16 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern bool geckoinit;
|
extern bool geckoinit;
|
||||||
extern bool bufferMessages;
|
extern bool bufferMessages;
|
||||||
extern bool WriteToSD;
|
extern bool WriteToSD;
|
||||||
|
|
||||||
//use this just like printf();
|
//use this just like printf();
|
||||||
void gprintf(const char *format, ...);
|
void gprintf(const char *format, ...);
|
||||||
void ghexdump(void *d, int len);
|
void ghexdump(void *d, int len);
|
||||||
bool InitGecko();
|
bool InitGecko();
|
||||||
void AllocSDGeckoBuffer();
|
void AllocSDGeckoBuffer();
|
||||||
void ClearLogBuffer();
|
void ClearLogBuffer();
|
||||||
void GeckoDisable();
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -1,25 +1,25 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Copyright (C) 2010
|
*Copyright (C) 2010
|
||||||
* by Dimok
|
*by Dimok
|
||||||
*
|
*
|
||||||
* This software is provided 'as-is', without any express or implied
|
*This software is provided 'as-is', without any express or implied
|
||||||
* warranty. In no event will the authors be held liable for any
|
*warranty. In no event will the authors be held liable for any
|
||||||
* damages arising from the use of this software.
|
*damages arising from the use of this software.
|
||||||
*
|
*
|
||||||
* Permission is granted to anyone to use this software for any
|
*Permission is granted to anyone to use this software for any
|
||||||
* purpose, including commercial applications, and to alter it and
|
*purpose, including commercial applications, and to alter it and
|
||||||
* redistribute it freely, subject to the following restrictions:
|
*redistribute it freely, subject to the following restrictions:
|
||||||
*
|
*
|
||||||
* 1. The origin of this software must not be misrepresented; you
|
*1. The origin of this software must not be misrepresented; you
|
||||||
* must not claim that you wrote the original software. If you use
|
*must not claim that you wrote the original software. If you use
|
||||||
* this software in a product, an acknowledgment in the product
|
*this software in a product, an acknowledgment in the product
|
||||||
* documentation would be appreciated but is not required.
|
*documentation would be appreciated but is not required.
|
||||||
*
|
*
|
||||||
* 2. Altered source versions must be plainly marked as such, and
|
*2. Altered source versions must be plainly marked as such, and
|
||||||
* must not be misrepresented as being the original software.
|
*must not be misrepresented as being the original software.
|
||||||
*
|
*
|
||||||
* 3. This notice may not be removed or altered from any source
|
*3. This notice may not be removed or altered from any source
|
||||||
* distribution.
|
*distribution.
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -33,11 +33,11 @@
|
|||||||
#include "text.hpp"
|
#include "text.hpp"
|
||||||
|
|
||||||
#define NAME_OFFSET_DB "gametdb_offsets.bin"
|
#define NAME_OFFSET_DB "gametdb_offsets.bin"
|
||||||
#define MAXREADSIZE 1024*1024 // Cache size only for parsing the offsets: 1MB
|
#define MAXREADSIZE 1024*1024 //Cache size only for parsing the offsets: 1MB
|
||||||
|
|
||||||
typedef struct _ReplaceStruct
|
typedef struct _ReplaceStruct
|
||||||
{
|
{
|
||||||
const char * orig;
|
const char *orig;
|
||||||
char replace;
|
char replace;
|
||||||
short size;
|
short size;
|
||||||
} ReplaceStruct;
|
} ReplaceStruct;
|
||||||
@ -58,7 +58,7 @@ GameTDB::GameTDB()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
GameTDB::GameTDB(const char * filepath)
|
GameTDB::GameTDB(const char *filepath)
|
||||||
: isLoaded(false), isParsed(false), file(0), filepath(0), LangCode("EN"), GameNodeCache(0)
|
: isLoaded(false), isParsed(false), file(0), filepath(0), LangCode("EN"), GameNodeCache(0)
|
||||||
{
|
{
|
||||||
OpenFile(filepath);
|
OpenFile(filepath);
|
||||||
@ -69,9 +69,10 @@ GameTDB::~GameTDB()
|
|||||||
CloseFile();
|
CloseFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,22 +121,23 @@ void GameTDB::Refresh()
|
|||||||
gprintf("Refreshing file '%s'\n", filepath);
|
gprintf("Refreshing file '%s'\n", filepath);
|
||||||
CloseFile();
|
CloseFile();
|
||||||
|
|
||||||
if (filepath == NULL)
|
if(filepath == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
OpenFile(filepath);
|
OpenFile(filepath);
|
||||||
}
|
}
|
||||||
|
|
||||||
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] != '/')
|
||||||
OffsetDBPath += '/';
|
OffsetDBPath += '/';
|
||||||
OffsetDBPath += NAME_OFFSET_DB;
|
OffsetDBPath += NAME_OFFSET_DB;
|
||||||
|
|
||||||
FILE * fp = fopen(OffsetDBPath.c_str(), "rb");
|
FILE *fp = fopen(OffsetDBPath.c_str(), "rb");
|
||||||
if(!fp)
|
if(!fp)
|
||||||
{
|
{
|
||||||
bool result = ParseFile();
|
bool result = ParseFile();
|
||||||
@ -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);
|
||||||
|
|
||||||
@ -189,16 +192,17 @@ bool GameTDB::LoadGameOffsets(const char * path)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GameTDB::SaveGameOffsets(const char * path)
|
bool GameTDB::SaveGameOffsets(const char *path)
|
||||||
{
|
{
|
||||||
if(OffsetMap.size() == 0 || !path)
|
if(OffsetMap.size() == 0 || !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;
|
||||||
@ -233,14 +237,14 @@ unsigned long long GameTDB::GetGameTDBVersion()
|
|||||||
if(GetData(TmpText, 0, sizeof(TmpText)) < 0)
|
if(GetData(TmpText, 0, sizeof(TmpText)) < 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
char * VersionText = GetNodeText(TmpText, "<GameTDB version=\"", "/>");
|
char *VersionText = GetNodeText(TmpText, "<GameTDB version=\"", "/>");
|
||||||
if(!VersionText)
|
if(!VersionText)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return strtoull(VersionText, NULL, 10);
|
return strtoull(VersionText, NULL, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
int GameTDB::GetData(char * data, int offset, int size)
|
int GameTDB::GetData(char *data, int offset, int size)
|
||||||
{
|
{
|
||||||
if(!file || !data)
|
if(!file || !data)
|
||||||
return -1;
|
return -1;
|
||||||
@ -250,15 +254,15 @@ int GameTDB::GetData(char * data, int offset, int size)
|
|||||||
return fread(data, 1, size, file);
|
return fread(data, 1, size, file);
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
char * data = new (std::nothrow) char[offset->nodesize+1];
|
char *data = new (std::nothrow) char[offset->nodesize+1];
|
||||||
if(!data)
|
if(!data)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@ -273,9 +277,9 @@ char * GameTDB::LoadGameNode(const char * id)
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
char * GameTDB::GetGameNode(const char * id)
|
char *GameTDB::GetGameNode(const char *id)
|
||||||
{
|
{
|
||||||
char * data = NULL;
|
char *data = NULL;
|
||||||
|
|
||||||
if(GameNodeCache != 0 && strncmp(id, GameIDCache, strlen(GameIDCache)) == 0)
|
if(GameNodeCache != 0 && strncmp(id, GameIDCache, strlen(GameIDCache)) == 0)
|
||||||
{
|
{
|
||||||
@ -302,9 +306,9 @@ char * GameTDB::GetGameNode(const char * id)
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
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];
|
||||||
@ -313,13 +317,13 @@ GameOffsets * GameTDB::GetGameOffset(const char * gameID)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline char * CleanText(char * in_text)
|
static inline char *CleanText(char *in_text)
|
||||||
{
|
{
|
||||||
if(!in_text)
|
if(!in_text)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
const char * ptr = in_text;
|
const char *ptr = in_text;
|
||||||
char * text = in_text;
|
char *text = in_text;
|
||||||
|
|
||||||
while(*ptr != '\0')
|
while(*ptr != '\0')
|
||||||
{
|
{
|
||||||
@ -351,18 +355,18 @@ static inline char * CleanText(char * in_text)
|
|||||||
return in_text;
|
return in_text;
|
||||||
}
|
}
|
||||||
|
|
||||||
char * GameTDB::GetNodeText(char * data, const char * nodestart, const char * nodeend)
|
char *GameTDB::GetNodeText(char *data, const char *nodestart, const char *nodeend)
|
||||||
{
|
{
|
||||||
if(!data || !nodestart || !nodeend)
|
if(!data || !nodestart || !nodeend)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
char * position = strstr(data, nodestart);
|
char *position = strstr(data, nodestart);
|
||||||
if(!position)
|
if(!position)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
position += strlen(nodestart);
|
position += strlen(nodestart);
|
||||||
|
|
||||||
char * end = strstr(position, nodeend);
|
char *end = strstr(position, nodeend);
|
||||||
if(!end)
|
if(!end)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@ -371,11 +375,12 @@ char * GameTDB::GetNodeText(char * data, const char * nodestart, const char * no
|
|||||||
return CleanText(position);
|
return CleanText(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
ptr += strlen("<locale lang=\"");
|
ptr += strlen("<locale lang=\"");
|
||||||
@ -383,7 +388,7 @@ char * GameTDB::SeekLang(char * text, const char * langcode)
|
|||||||
if(strncmp(ptr, langcode, strlen(langcode)) == 0)
|
if(strncmp(ptr, langcode, strlen(langcode)) == 0)
|
||||||
{
|
{
|
||||||
//! Cut off all the other languages
|
//! Cut off all the other languages
|
||||||
char * end = strstr(ptr, "</locale>");
|
char *end = strstr(ptr, "</locale>");
|
||||||
if(!end)
|
if(!end)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@ -404,16 +409,16 @@ bool GameTDB::ParseFile()
|
|||||||
if(!file)
|
if(!file)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
char * Line = new (std::nothrow) char[MAXREADSIZE+1];
|
char *Line = new (std::nothrow) char[MAXREADSIZE+1];
|
||||||
if(!Line)
|
if(!Line)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
bool readnew = false;
|
bool readnew = false;
|
||||||
int i, currentPos = 0;
|
int i, currentPos = 0;
|
||||||
int read = 0;
|
int read = 0;
|
||||||
const char * gameNode = NULL;
|
const char *gameNode = NULL;
|
||||||
const char * idNode = NULL;
|
const char *idNode = NULL;
|
||||||
const char * gameEndNode = NULL;
|
const char *gameEndNode = NULL;
|
||||||
|
|
||||||
while((read = GetData(Line, currentPos, MAXREADSIZE)) > 0)
|
while((read = GetData(Line, currentPos, MAXREADSIZE)) > 0)
|
||||||
{
|
{
|
||||||
@ -461,23 +466,19 @@ bool GameTDB::ParseFile()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GameTDB::FindTitle(char * data, string & title, string langCode)
|
bool GameTDB::FindTitle(char *data, string & title, string langCode)
|
||||||
{
|
{
|
||||||
char * language = SeekLang(data, langCode.c_str());
|
char *language = SeekLang(data, langCode.c_str());
|
||||||
if(!language)
|
if(!language)
|
||||||
{
|
{
|
||||||
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);
|
||||||
@ -486,13 +487,15 @@ bool GameTDB::FindTitle(char * data, string & title, string langCode)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
@ -501,15 +504,17 @@ bool GameTDB::GetTitle(const char * id, string & title)
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
language = SeekLang(data, "EN");
|
language = SeekLang(data, "EN");
|
||||||
@ -520,7 +525,7 @@ bool GameTDB::GetSynopsis(const char * id, string & synopsis)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char * the_synopsis = GetNodeText(language, "<synopsis>", "</synopsis>");
|
char *the_synopsis = GetNodeText(language, "<synopsis>", "</synopsis>");
|
||||||
if(!the_synopsis)
|
if(!the_synopsis)
|
||||||
{
|
{
|
||||||
delete [] data;
|
delete [] data;
|
||||||
@ -534,15 +539,17 @@ bool GameTDB::GetSynopsis(const char * id, string & synopsis)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
delete [] data;
|
delete [] data;
|
||||||
@ -556,15 +563,17 @@ bool GameTDB::GetRegion(const char * id, string & region)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
delete [] data;
|
delete [] data;
|
||||||
@ -578,15 +587,17 @@ bool GameTDB::GetDeveloper(const char * id, string & dev)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
delete [] data;
|
delete [] data;
|
||||||
@ -600,25 +611,27 @@ 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)
|
||||||
{
|
{
|
||||||
delete [] data;
|
delete [] data;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int year, day, month;
|
u32 year, day, month;
|
||||||
|
|
||||||
year = atoi(year_string);
|
year = atoi(year_string);
|
||||||
|
|
||||||
char * month_string = strstr(year_string, "month=\"");
|
char *month_string = strstr(year_string, "month=\"");
|
||||||
if(!month_string)
|
if(!month_string)
|
||||||
{
|
{
|
||||||
delete [] data;
|
delete [] data;
|
||||||
@ -629,7 +642,7 @@ unsigned int GameTDB::GetPublishDate(const char * id)
|
|||||||
|
|
||||||
month = atoi(month_string);
|
month = atoi(month_string);
|
||||||
|
|
||||||
char * day_string = strstr(month_string, "day=\"");
|
char *day_string = strstr(month_string, "day=\"");
|
||||||
if(!day_string)
|
if(!day_string)
|
||||||
{
|
{
|
||||||
delete [] data;
|
delete [] data;
|
||||||
@ -645,25 +658,27 @@ unsigned int GameTDB::GetPublishDate(const char * id)
|
|||||||
return ((year & 0xFFFF) << 16 | (month & 0xFF) << 8 | (day & 0xFF));
|
return ((year & 0xFFFF) << 16 | (month & 0xFF) << 8 | (day & 0xFF));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GameTDB::GetGenres(const char * id, string & gen)
|
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)
|
||||||
{
|
{
|
||||||
delete [] data;
|
delete [] data;
|
||||||
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;
|
||||||
}
|
}
|
||||||
@ -694,7 +710,7 @@ bool GameTDB::GetGenres(const char * id, string & gen)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char * GameTDB::RatingToString(int rating)
|
const char *GameTDB::RatingToString(int rating)
|
||||||
{
|
{
|
||||||
switch(rating)
|
switch(rating)
|
||||||
{
|
{
|
||||||
@ -713,16 +729,18 @@ const char * GameTDB::RatingToString(int rating)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int GameTDB::GetRating(const char * id)
|
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)
|
||||||
{
|
{
|
||||||
delete [] data;
|
delete [] data;
|
||||||
@ -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;
|
||||||
|
|
||||||
@ -746,22 +761,24 @@ int GameTDB::GetRating(const char * id)
|
|||||||
return rating;
|
return rating;
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
delete [] data;
|
delete [] data;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
char * value_text = GetNodeText(rating_text, "value=\"", "\"");
|
char *value_text = GetNodeText(rating_text, "value=\"", "\"");
|
||||||
if(!value_text)
|
if(!value_text)
|
||||||
{
|
{
|
||||||
delete [] data;
|
delete [] data;
|
||||||
@ -775,24 +792,24 @@ bool GameTDB::GetRatingValue(const char * id, string & rating_value)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int GameTDB::GetRatingDescriptors(const char * id, vector<string> & desc_list)
|
int GameTDB::GetRatingDescriptors(const char *id, vector<string> & desc_list)
|
||||||
{
|
{
|
||||||
desc_list.clear();
|
desc_list.clear();
|
||||||
if(!id)
|
if(!id)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
char * data = GetGameNode(id);
|
char *data = GetGameNode(id);
|
||||||
if(!data)
|
if(!data)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
char * descriptor_text = GetNodeText(data, "<descriptor>", "</rating>");
|
char *descriptor_text = GetNodeText(data, "<descriptor>", "</rating>");
|
||||||
if(!descriptor_text)
|
if(!descriptor_text)
|
||||||
{
|
{
|
||||||
delete [] data;
|
delete [] data;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int list_num = 0;
|
u32 list_num = 0;
|
||||||
|
|
||||||
while(*descriptor_text != '\0')
|
while(*descriptor_text != '\0')
|
||||||
{
|
{
|
||||||
@ -819,18 +836,18 @@ int GameTDB::GetRatingDescriptors(const char * id, vector<string> & desc_list)
|
|||||||
return desc_list.size();
|
return desc_list.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
int GameTDB::GetWifiPlayers(const char * id)
|
int GameTDB::GetWifiPlayers(const char *id)
|
||||||
{
|
{
|
||||||
int players = -1;
|
int players = -1;
|
||||||
|
|
||||||
if(!id)
|
if(!id)
|
||||||
return players;
|
return players;
|
||||||
|
|
||||||
char * data = GetGameNode(id);
|
char *data = GetGameNode(id);
|
||||||
if(!data)
|
if(!data)
|
||||||
return players;
|
return players;
|
||||||
|
|
||||||
char * PlayersNode = GetNodeText(data, "<wi-fi players=\"", "\">");
|
char *PlayersNode = GetNodeText(data, "<wi-fi players=\"", "\">");
|
||||||
if(!PlayersNode)
|
if(!PlayersNode)
|
||||||
{
|
{
|
||||||
delete [] data;
|
delete [] data;
|
||||||
@ -842,24 +859,24 @@ int GameTDB::GetWifiPlayers(const char * id)
|
|||||||
return players;
|
return players;
|
||||||
}
|
}
|
||||||
|
|
||||||
int GameTDB::GetWifiFeatures(const char * id, vector<string> & feat_list)
|
int GameTDB::GetWifiFeatures(const char *id, vector<string> & feat_list)
|
||||||
{
|
{
|
||||||
feat_list.clear();
|
feat_list.clear();
|
||||||
if(!id)
|
if(!id)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
char * data = GetGameNode(id);
|
char *data = GetGameNode(id);
|
||||||
if(!data)
|
if(!data)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
char * feature_text = GetNodeText(data, "<feature>", "</wi-fi>");
|
char *feature_text = GetNodeText(data, "<feature>", "</wi-fi>");
|
||||||
if(!feature_text)
|
if(!feature_text)
|
||||||
{
|
{
|
||||||
delete [] data;
|
delete [] data;
|
||||||
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
|
||||||
@ -891,18 +907,18 @@ int GameTDB::GetWifiFeatures(const char * id, vector<string> & feat_list)
|
|||||||
return feat_list.size();
|
return feat_list.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
int GameTDB::GetPlayers(const char * id)
|
int GameTDB::GetPlayers(const char *id)
|
||||||
{
|
{
|
||||||
int players = -1;
|
int players = -1;
|
||||||
|
|
||||||
if(!id)
|
if(!id)
|
||||||
return players;
|
return players;
|
||||||
|
|
||||||
char * data = GetGameNode(id);
|
char *data = GetGameNode(id);
|
||||||
if(!data)
|
if(!data)
|
||||||
return players;
|
return players;
|
||||||
|
|
||||||
char * PlayersNode = GetNodeText(data, "<input players=\"", "\">");
|
char *PlayersNode = GetNodeText(data, "<input players=\"", "\">");
|
||||||
if(!PlayersNode)
|
if(!PlayersNode)
|
||||||
{
|
{
|
||||||
delete [] data;
|
delete [] data;
|
||||||
@ -914,36 +930,35 @@ int GameTDB::GetPlayers(const char * id)
|
|||||||
return players;
|
return players;
|
||||||
}
|
}
|
||||||
|
|
||||||
int GameTDB::GetAccessories(const char * id, vector<Accessory> & acc_list)
|
int GameTDB::GetAccessories(const char *id, vector<Accessory> & acc_list)
|
||||||
{
|
{
|
||||||
acc_list.clear();
|
acc_list.clear();
|
||||||
if(!id)
|
if(!id)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
char * data = GetGameNode(id);
|
char *data = GetGameNode(id);
|
||||||
if(!data)
|
if(!data)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
char * ControlsNode = GetNodeText(data, "<control type=\"", "</input>");
|
char *ControlsNode = GetNodeText(data, "<control type=\"", "</input>");
|
||||||
if(!ControlsNode)
|
if(!ControlsNode)
|
||||||
{
|
{
|
||||||
delete [] data;
|
delete [] data;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int list_num = 0;
|
u32 list_num = 0;
|
||||||
|
|
||||||
while(ControlsNode && *ControlsNode != '\0')
|
while(ControlsNode && *ControlsNode != '\0')
|
||||||
{
|
{
|
||||||
if(list_num >= acc_list.size())
|
if(list_num >= acc_list.size())
|
||||||
acc_list.resize(list_num+1);
|
acc_list.resize(list_num+1);
|
||||||
|
|
||||||
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=\"");
|
||||||
if(!requiredField)
|
if(!requiredField)
|
||||||
{
|
{
|
||||||
delete [] data;
|
delete [] data;
|
||||||
@ -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,41 +995,40 @@ 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;
|
||||||
|
|
||||||
char * data = GetGameNode(id);
|
char *data = GetGameNode(id);
|
||||||
if(!data)
|
if(!data)
|
||||||
return color;
|
return color;
|
||||||
|
|
||||||
|
|
||||||
color = FindCaseColor(data);
|
color = FindCaseColor(data);
|
||||||
|
|
||||||
if( color != 0xffffffff )
|
if(color != 0xffffffff)
|
||||||
gprintf("GameTDB: Found alternate color(%x) for: %s\n", color, id);
|
gprintf("GameTDB: Found alternate color(%x) for: %s\n", color, id);
|
||||||
|
|
||||||
delete [] data;
|
delete [] data;
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
int GameTDB::GetCaseVersions(const char * id)
|
int GameTDB::GetCaseVersions(const char *id)
|
||||||
{
|
{
|
||||||
int altcase = -1;
|
int altcase = -1;
|
||||||
|
|
||||||
if(!id)
|
if(!id)
|
||||||
return altcase;
|
return altcase;
|
||||||
|
|
||||||
char * data = GetGameNode(id);
|
char *data = GetGameNode(id);
|
||||||
if(!data)
|
if(!data)
|
||||||
{
|
{
|
||||||
gprintf("GameTDB: GameNode for %s not found\n", id);
|
gprintf("GameTDB: GameNode for %s not found\n", id);
|
||||||
return altcase;
|
return altcase;
|
||||||
}
|
}
|
||||||
|
|
||||||
char * PlayersNode = GetNodeText(data, "case versions=\"", "\"");
|
char *PlayersNode = GetNodeText(data, "case versions=\"", "\"");
|
||||||
if(!PlayersNode)
|
if(!PlayersNode)
|
||||||
{
|
{
|
||||||
delete [] data;
|
delete [] data;
|
||||||
@ -1028,7 +1040,7 @@ int GameTDB::GetCaseVersions(const char * id)
|
|||||||
return altcase;
|
return altcase;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GameTDB::GetGameXMLInfo(const char * id, GameXMLInfo * gameInfo)
|
bool GameTDB::GetGameXMLInfo(const char *id, GameXMLInfo *gameInfo)
|
||||||
{
|
{
|
||||||
if(!id || !gameInfo)
|
if(!id || !gameInfo)
|
||||||
return false;
|
return false;
|
||||||
|
@ -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);
|
||||||
|
@ -22,7 +22,7 @@ typedef void *(*app_final)();
|
|||||||
typedef void (*app_entry)(void (**init)(void (*report)(const char *fmt, ...)), int (**main)(), void *(**final)());
|
typedef void (*app_entry)(void (**init)(void (*report)(const char *fmt, ...)), int (**main)(), void *(**final)());
|
||||||
|
|
||||||
/* Apploader pointers */
|
/* Apploader pointers */
|
||||||
static u8 *appldr = (u8 *) 0x81200000;
|
static u8 *appldr = (u8 *)0x81200000;
|
||||||
|
|
||||||
/* Constants */
|
/* Constants */
|
||||||
#define APPLDR_OFFSET 0x2440
|
#define APPLDR_OFFSET 0x2440
|
||||||
@ -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"
|
||||||
@ -21,7 +21,7 @@
|
|||||||
#define split_error(x) do { gprintf("\nsplit error: %s\n\n",x); } while(0)
|
#define split_error(x) do { gprintf("\nsplit error: %s\n\n",x); } while(0)
|
||||||
|
|
||||||
// 1 cluster less than 4gb
|
// 1 cluster less than 4gb
|
||||||
u64 OPT_split_size = (u64) 4LL * 1024 * 1024 * 1024 - 32 * 1024;
|
u64 OPT_split_size = (u64)4LL * 1024 * 1024 * 1024 - 32 * 1024;
|
||||||
// 1 cluster less than 2gb
|
// 1 cluster less than 2gb
|
||||||
//u64 OPT_split_size = (u64)2LL * 1024 * 1024 * 1024 - 32 * 1024;
|
//u64 OPT_split_size = (u64)2LL * 1024 * 1024 * 1024 - 32 * 1024;
|
||||||
|
|
||||||
@ -88,7 +88,7 @@ int split_fill(split_info_t *s, int idx, u64 size)
|
|||||||
int fd = split_open_file(s, idx);
|
int fd = split_open_file(s, idx);
|
||||||
|
|
||||||
off64_t fsize = lseek(fd, 0, SEEK_END);
|
off64_t fsize = lseek(fd, 0, SEEK_END);
|
||||||
if ((u64)fsize < size)
|
if((u64)fsize < size)
|
||||||
{
|
{
|
||||||
// gprintf("TRUNC %d "FMT_lld" "FMT_lld"\n", idx, size, fsize); // Wpad_WaitButtons();
|
// gprintf("TRUNC %d "FMT_lld" "FMT_lld"\n", idx, size, fsize); // Wpad_WaitButtons();
|
||||||
ftruncate(fd, size);
|
ftruncate(fd, size);
|
||||||
|
@ -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;
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ void do_wip_code(u8 * dst, u32 len)
|
|||||||
//! if set was successful the codelist will be freed when it's done
|
//! if set was successful the codelist will be freed when it's done
|
||||||
bool set_wip_list(WIP_Code * list, int size)
|
bool set_wip_list(WIP_Code * list, int size)
|
||||||
{
|
{
|
||||||
if (!CodeList && size > 0)
|
if(!CodeList && size > 0)
|
||||||
{
|
{
|
||||||
CodeList = list;
|
CodeList = list;
|
||||||
CodesCount = size;
|
CodesCount = size;
|
||||||
@ -92,8 +92,8 @@ int load_wip_patches(u8 *dir, u8 *gameid)
|
|||||||
memcpy(GameID, gameid, 6);
|
memcpy(GameID, gameid, 6);
|
||||||
snprintf(filepath, sizeof(filepath), "%s/%s.wip", dir, GameID);
|
snprintf(filepath, sizeof(filepath), "%s/%s.wip", dir, GameID);
|
||||||
|
|
||||||
FILE * fp = fopen(filepath, "rb");
|
FILE *fp = fopen(filepath, "rb");
|
||||||
if (!fp)
|
if(!fp)
|
||||||
{
|
{
|
||||||
memset(GameID, 0, sizeof(GameID));
|
memset(GameID, 0, sizeof(GameID));
|
||||||
memcpy(GameID, gameid, 3);
|
memcpy(GameID, gameid, 3);
|
||||||
@ -101,17 +101,16 @@ int load_wip_patches(u8 *dir, u8 *gameid)
|
|||||||
fp = fopen(filepath, "rb");
|
fp = fopen(filepath, "rb");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fp)
|
if(!fp)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
char line[255];
|
char line[255];
|
||||||
gprintf("\nLoading WIP code from %s.\n", filepath);
|
gprintf("\nLoading WIP code from %s.\n", filepath);
|
||||||
|
|
||||||
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,37 +53,39 @@ 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bytes[0] & 0x80)
|
if(bytes[0] & 0x80)
|
||||||
return -f;
|
return -f;
|
||||||
else
|
else
|
||||||
return f;
|
return f;
|
||||||
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -31,14 +31,14 @@
|
|||||||
|
|
||||||
class AifDecoder : public SoundDecoder
|
class AifDecoder : public SoundDecoder
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AifDecoder(const char * filepath);
|
AifDecoder(const char *filepath);
|
||||||
AifDecoder(const u8 * snd, int len);
|
AifDecoder(const u8 *snd, int len);
|
||||||
~AifDecoder();
|
~AifDecoder();
|
||||||
int GetFormat() { return Format; };
|
int GetFormat() { return Format; };
|
||||||
int GetSampleRate() { return SampleRate; };
|
int GetSampleRate() { return SampleRate; };
|
||||||
int Read(u8 * buffer, int buffer_size, int pos);
|
int Read(u8 *buffer, int buffer_size, int pos);
|
||||||
protected:
|
protected:
|
||||||
void OpenFile();
|
void OpenFile();
|
||||||
void CloseFile();
|
void CloseFile();
|
||||||
u32 DataOffset;
|
u32 DataOffset;
|
||||||
|
@ -66,7 +66,7 @@ BNSDecoder::~BNSDecoder()
|
|||||||
|
|
||||||
void BNSDecoder::OpenFile()
|
void BNSDecoder::OpenFile()
|
||||||
{
|
{
|
||||||
u8 * tempbuff = new (std::nothrow) u8[file_fd->size()];
|
u8 *tempbuff = new (std::nothrow) u8[file_fd->size()];
|
||||||
if(!tempbuff)
|
if(!tempbuff)
|
||||||
{
|
{
|
||||||
CloseFile();
|
CloseFile();
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
|
|
||||||
typedef struct _SoundBlock
|
typedef struct _SoundBlock
|
||||||
{
|
{
|
||||||
u8 * buffer;
|
u8 *buffer;
|
||||||
u32 size;
|
u32 size;
|
||||||
u8 format;
|
u8 format;
|
||||||
u32 frequency;
|
u32 frequency;
|
||||||
@ -41,14 +41,14 @@ typedef struct _SoundBlock
|
|||||||
|
|
||||||
class BNSDecoder : public SoundDecoder
|
class BNSDecoder : public SoundDecoder
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BNSDecoder(const char * filepath);
|
BNSDecoder(const char * filepath);
|
||||||
BNSDecoder(const u8 * snd, int len);
|
BNSDecoder(const u8 * snd, int len);
|
||||||
~BNSDecoder();
|
~BNSDecoder();
|
||||||
int GetFormat() { return SoundData.format; };
|
int GetFormat() { return SoundData.format; };
|
||||||
int GetSampleRate() { return SoundData.frequency; };
|
int GetSampleRate() { return SoundData.frequency; };
|
||||||
int Read(u8 * buffer, int buffer_size, int pos);
|
int Read(u8 * buffer, int buffer_size, int pos);
|
||||||
protected:
|
protected:
|
||||||
void OpenFile();
|
void OpenFile();
|
||||||
void CloseFile();
|
void CloseFile();
|
||||||
SoundBlock SoundData;
|
SoundBlock SoundData;
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
|
|
||||||
class BufferCircle
|
class BufferCircle
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//!> Constructor
|
//!> Constructor
|
||||||
BufferCircle();
|
BufferCircle();
|
||||||
//!> Destructor
|
//!> Destructor
|
||||||
@ -79,7 +79,7 @@ class BufferCircle
|
|||||||
void SetBufferSize(int pos, int size);
|
void SetBufferSize(int pos, int size);
|
||||||
//!> Get the current position in the circle
|
//!> Get the current position in the circle
|
||||||
u16 Which() { return which; };
|
u16 Which() { return which; };
|
||||||
protected:
|
protected:
|
||||||
//!> Check if the position is a valid position in the vector
|
//!> Check if the position is a valid position in the vector
|
||||||
bool Valid(int pos) { return !(pos < 0 || pos >= Size()); };
|
bool Valid(int pos) { return !(pos < 0 || pos >= Size()); };
|
||||||
|
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
class CFile
|
class CFile
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CFile();
|
CFile();
|
||||||
CFile(const char * filepath, const char * mode);
|
CFile(const char * filepath, const char * mode);
|
||||||
CFile(const u8 * memory, int memsize);
|
CFile(const u8 * memory, int memsize);
|
||||||
@ -20,7 +20,7 @@ class CFile
|
|||||||
long int tell() { return Pos; };
|
long int tell() { return Pos; };
|
||||||
long int size() { return filesize; };
|
long int size() { return filesize; };
|
||||||
void rewind() { seek(0, SEEK_SET); };
|
void rewind() { seek(0, SEEK_SET); };
|
||||||
protected:
|
protected:
|
||||||
FILE * file_fd;
|
FILE * file_fd;
|
||||||
const u8 * mem_file;
|
const u8 * mem_file;
|
||||||
u64 filesize;
|
u64 filesize;
|
||||||
|
@ -155,12 +155,12 @@ int Mp3Decoder::Read(u8 * buffer, int buffer_size, int)
|
|||||||
if(write_pos >= write_end)
|
if(write_pos >= write_end)
|
||||||
return write_pos-buffer;
|
return write_pos-buffer;
|
||||||
|
|
||||||
*((s16 *) write_pos) = FixedToShort(Synth.pcm.samples[0][SynthPos]);
|
*((s16 *)write_pos) = FixedToShort(Synth.pcm.samples[0][SynthPos]);
|
||||||
write_pos += 2;
|
write_pos += 2;
|
||||||
|
|
||||||
if(MAD_NCHANNELS(&Frame.header) == 2)
|
if(MAD_NCHANNELS(&Frame.header) == 2)
|
||||||
{
|
{
|
||||||
*((s16 *) write_pos) = FixedToShort(Synth.pcm.samples[1][SynthPos]);
|
*((s16 *)write_pos) = FixedToShort(Synth.pcm.samples[1][SynthPos]);
|
||||||
write_pos += 2;
|
write_pos += 2;
|
||||||
}
|
}
|
||||||
SynthPos++;
|
SynthPos++;
|
||||||
@ -168,7 +168,7 @@ int Mp3Decoder::Read(u8 * buffer, int buffer_size, int)
|
|||||||
|
|
||||||
if(Stream.buffer == NULL || Stream.error == MAD_ERROR_BUFLEN)
|
if(Stream.buffer == NULL || Stream.error == MAD_ERROR_BUFLEN)
|
||||||
{
|
{
|
||||||
u8 * ReadStart = ReadBuffer;
|
u8 *ReadStart = ReadBuffer;
|
||||||
int ReadSize = SoundBlockSize*SoundBlocks;
|
int ReadSize = SoundBlockSize*SoundBlocks;
|
||||||
int Remaining = 0;
|
int Remaining = 0;
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
class Mp3Decoder : public SoundDecoder
|
class Mp3Decoder : public SoundDecoder
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Mp3Decoder(const char * filepath);
|
Mp3Decoder(const char * filepath);
|
||||||
Mp3Decoder(const u8 * sound, int len);
|
Mp3Decoder(const u8 * sound, int len);
|
||||||
~Mp3Decoder();
|
~Mp3Decoder();
|
||||||
@ -37,7 +37,7 @@ class Mp3Decoder : public SoundDecoder
|
|||||||
int GetSampleRate() { return SampleRate; };
|
int GetSampleRate() { return SampleRate; };
|
||||||
int Rewind();
|
int Rewind();
|
||||||
int Read(u8 * buffer, int buffer_size, int pos);
|
int Read(u8 * buffer, int buffer_size, int pos);
|
||||||
protected:
|
protected:
|
||||||
void OpenFile();
|
void OpenFile();
|
||||||
struct mad_stream Stream;
|
struct mad_stream Stream;
|
||||||
struct mad_frame Frame;
|
struct mad_frame Frame;
|
||||||
|
@ -38,13 +38,13 @@ extern "C" int ogg_seek(int *f, ogg_int64_t offset, int mode)
|
|||||||
|
|
||||||
extern "C" int ogg_close(int *f)
|
extern "C" int ogg_close(int *f)
|
||||||
{
|
{
|
||||||
((CFile *) f)->close();
|
((CFile*)f)->close();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" long ogg_tell(int *f)
|
extern "C" long ogg_tell(int *f)
|
||||||
{
|
{
|
||||||
return (long) ((CFile *) f)->tell();
|
return (long)((CFile *)f)->tell();
|
||||||
}
|
}
|
||||||
|
|
||||||
static ov_callbacks callbacks = {
|
static ov_callbacks callbacks = {
|
||||||
@ -88,7 +88,7 @@ OggDecoder::~OggDecoder()
|
|||||||
|
|
||||||
void OggDecoder::OpenFile()
|
void OggDecoder::OpenFile()
|
||||||
{
|
{
|
||||||
if (ov_open_callbacks(file_fd, &ogg_file, NULL, 0, callbacks) < 0)
|
if(ov_open_callbacks(file_fd, &ogg_file, NULL, 0, callbacks) < 0)
|
||||||
{
|
{
|
||||||
delete file_fd;
|
delete file_fd;
|
||||||
file_fd = NULL;
|
file_fd = NULL;
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
|
|
||||||
class OggDecoder : public SoundDecoder
|
class OggDecoder : public SoundDecoder
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
OggDecoder(const char * filepath);
|
OggDecoder(const char * filepath);
|
||||||
OggDecoder(const u8 * snd, int len);
|
OggDecoder(const u8 * snd, int len);
|
||||||
~OggDecoder();
|
~OggDecoder();
|
||||||
@ -38,7 +38,7 @@ class OggDecoder : public SoundDecoder
|
|||||||
int GetSampleRate();
|
int GetSampleRate();
|
||||||
int Rewind();
|
int Rewind();
|
||||||
int Read(u8 * buffer, int buffer_size, int pos);
|
int Read(u8 * buffer, int buffer_size, int pos);
|
||||||
protected:
|
protected:
|
||||||
void OpenFile();
|
void OpenFile();
|
||||||
OggVorbis_File ogg_file;
|
OggVorbis_File ogg_file;
|
||||||
vorbis_info *ogg_info;
|
vorbis_info *ogg_info;
|
||||||
|
@ -97,7 +97,7 @@ void SoundDecoder::Decode()
|
|||||||
|
|
||||||
u16 newWhich = SoundBuffer.Which();
|
u16 newWhich = SoundBuffer.Which();
|
||||||
u16 i = 0;
|
u16 i = 0;
|
||||||
for (i = 0; i < SoundBuffer.Size()-2; i++)
|
for(i = 0; i < SoundBuffer.Size()-2; i++)
|
||||||
{
|
{
|
||||||
if(!SoundBuffer.IsBufferReady(newWhich))
|
if(!SoundBuffer.IsBufferReady(newWhich))
|
||||||
break;
|
break;
|
||||||
@ -111,7 +111,7 @@ void SoundDecoder::Decode()
|
|||||||
Decoding = true;
|
Decoding = true;
|
||||||
|
|
||||||
int done = 0;
|
int done = 0;
|
||||||
u8 * write_buf = SoundBuffer.GetBuffer(newWhich);
|
u8 *write_buf = SoundBuffer.GetBuffer(newWhich);
|
||||||
if(!write_buf)
|
if(!write_buf)
|
||||||
{
|
{
|
||||||
ExitRequested = true;
|
ExitRequested = true;
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
|
|
||||||
class SoundHandler
|
class SoundHandler
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static SoundHandler * Instance();
|
static SoundHandler * Instance();
|
||||||
static void DestroyInstance();
|
static void DestroyInstance();
|
||||||
|
|
||||||
@ -46,7 +46,7 @@ class SoundHandler
|
|||||||
SoundDecoder * Decoder(int i) { return ((i < 0 || i >= MAX_DECODERS) ? NULL : DecoderList[i]); };
|
SoundDecoder * Decoder(int i) { return ((i < 0 || i >= MAX_DECODERS) ? NULL : DecoderList[i]); };
|
||||||
void ThreadSignal() { LWP_ThreadSignal(ThreadQueue); };
|
void ThreadSignal() { LWP_ThreadSignal(ThreadQueue); };
|
||||||
bool IsDecoding() { return Decoding; };
|
bool IsDecoding() { return Decoding; };
|
||||||
protected:
|
protected:
|
||||||
SoundHandler();
|
SoundHandler();
|
||||||
~SoundHandler();
|
~SoundHandler();
|
||||||
static void * UpdateThread(void *arg);
|
static void * UpdateThread(void *arg);
|
||||||
|
@ -54,6 +54,7 @@ WavDecoder::WavDecoder(const u8 * snd, int len)
|
|||||||
|
|
||||||
WavDecoder::~WavDecoder()
|
WavDecoder::~WavDecoder()
|
||||||
{
|
{
|
||||||
|
CloseFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WavDecoder::OpenFile()
|
void WavDecoder::OpenFile()
|
||||||
@ -66,7 +67,7 @@ void WavDecoder::OpenFile()
|
|||||||
file_fd->read((u8 *) &Header, sizeof(SWaveHdr));
|
file_fd->read((u8 *) &Header, sizeof(SWaveHdr));
|
||||||
file_fd->read((u8 *) &FmtChunk, sizeof(SWaveFmtChunk));
|
file_fd->read((u8 *) &FmtChunk, sizeof(SWaveFmtChunk));
|
||||||
|
|
||||||
if (Header.magicRIFF != 'RIFF')
|
if(Header.magicRIFF != 'RIFF')
|
||||||
{
|
{
|
||||||
CloseFile();
|
CloseFile();
|
||||||
return;
|
return;
|
||||||
@ -104,13 +105,13 @@ void WavDecoder::OpenFile()
|
|||||||
Is16Bit = (le16(FmtChunk.bps) == 16);
|
Is16Bit = (le16(FmtChunk.bps) == 16);
|
||||||
SampleRate = le32(FmtChunk.freq);
|
SampleRate = le32(FmtChunk.freq);
|
||||||
|
|
||||||
if (le16(FmtChunk.channels) == 1 && le16(FmtChunk.bps) == 8 && le16(FmtChunk.alignment) <= 1)
|
if(le16(FmtChunk.channels) == 1 && le16(FmtChunk.bps) == 8 && le16(FmtChunk.alignment) <= 1)
|
||||||
Format = VOICE_MONO_8BIT;
|
Format = VOICE_MONO_8BIT;
|
||||||
else if (le16(FmtChunk.channels) == 1 && le16(FmtChunk.bps) == 16 && le16(FmtChunk.alignment) <= 2)
|
else if(le16(FmtChunk.channels) == 1 && le16(FmtChunk.bps) == 16 && le16(FmtChunk.alignment) <= 2)
|
||||||
Format = VOICE_MONO_16BIT;
|
Format = VOICE_MONO_16BIT;
|
||||||
else if (le16(FmtChunk.channels) == 2 && le16(FmtChunk.bps) == 8 && le16(FmtChunk.alignment) <= 2)
|
else if(le16(FmtChunk.channels) == 2 && le16(FmtChunk.bps) == 8 && le16(FmtChunk.alignment) <= 2)
|
||||||
Format = VOICE_STEREO_8BIT;
|
Format = VOICE_STEREO_8BIT;
|
||||||
else if (le16(FmtChunk.channels) == 2 && le16(FmtChunk.bps) == 16 && le16(FmtChunk.alignment) <= 4)
|
else if(le16(FmtChunk.channels) == 2 && le16(FmtChunk.bps) == 16 && le16(FmtChunk.alignment) <= 4)
|
||||||
Format = VOICE_STEREO_16BIT;
|
Format = VOICE_STEREO_16BIT;
|
||||||
|
|
||||||
Decode();
|
Decode();
|
||||||
@ -140,12 +141,12 @@ int WavDecoder::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)
|
||||||
{
|
{
|
||||||
if (Is16Bit)
|
if(Is16Bit)
|
||||||
{
|
{
|
||||||
read &= ~0x0001;
|
read &= ~0x0001;
|
||||||
|
|
||||||
for (u32 i = 0; i < (u32) (read / sizeof (u16)); ++i)
|
for(u32 i = 0; i < (u32) (read / sizeof (u16)); ++i)
|
||||||
((u16 *) buffer)[i] = le16(((u16 *) buffer)[i]);
|
((u16 *)buffer)[i] = le16(((u16 *)buffer)[i]);
|
||||||
}
|
}
|
||||||
CurPos += read;
|
CurPos += read;
|
||||||
}
|
}
|
||||||
|
@ -55,14 +55,14 @@ typedef struct
|
|||||||
|
|
||||||
class WavDecoder : public SoundDecoder
|
class WavDecoder : public SoundDecoder
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
WavDecoder(const char * filepath);
|
WavDecoder(const char * filepath);
|
||||||
WavDecoder(const u8 * snd, int len);
|
WavDecoder(const u8 * snd, int len);
|
||||||
~WavDecoder();
|
~WavDecoder();
|
||||||
int GetFormat() { return Format; };
|
int GetFormat() { return Format; };
|
||||||
int GetSampleRate() { return SampleRate; };
|
int GetSampleRate() { return SampleRate; };
|
||||||
int Read(u8 * buffer, int buffer_size, int pos);
|
int Read(u8 * buffer, int buffer_size, int pos);
|
||||||
protected:
|
protected:
|
||||||
void OpenFile();
|
void OpenFile();
|
||||||
void CloseFile();
|
void CloseFile();
|
||||||
u32 DataOffset;
|
u32 DataOffset;
|
||||||
|
@ -55,8 +55,9 @@ 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,11 +99,12 @@ 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)
|
||||||
{
|
{
|
||||||
u8 * snd = (u8 *) malloc(g->length);
|
u8 *snd = (u8 *) malloc(g->length);
|
||||||
memcpy(snd, g->sound, g->length);
|
memcpy(snd, g->sound, g->length);
|
||||||
Load(snd, g->length, true);
|
Load(snd, g->length, true);
|
||||||
}
|
}
|
||||||
@ -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())
|
||||||
@ -303,13 +307,14 @@ void GuiSound::Play()
|
|||||||
void GuiSound::Stop()
|
void GuiSound::Stop()
|
||||||
{
|
{
|
||||||
volume = 0;
|
volume = 0;
|
||||||
if (!IsPlaying() || voice < 0 || voice >= 16)
|
if(!IsPlaying() || voice < 0 || voice >= 16)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
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();
|
||||||
@ -361,16 +366,18 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
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,24 +404,25 @@ 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;
|
||||||
|
|
||||||
while (bufCur < bufEnd && inBuf < inBufEnd)
|
while(bufCur < bufEnd && inBuf < inBufEnd)
|
||||||
{
|
{
|
||||||
u8 flags = *inBuf;
|
u8 flags = *inBuf;
|
||||||
++inBuf;
|
++inBuf;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (i = 0; i < 8 && bufCur < bufEnd && inBuf < inBufEnd; ++i)
|
for(i = 0; i < 8 && bufCur < bufEnd && inBuf < inBufEnd; ++i)
|
||||||
{
|
{
|
||||||
if ((flags & 0x80) != 0)
|
if((flags & 0x80) != 0)
|
||||||
{
|
{
|
||||||
const LZ77Info * info = (const LZ77Info *)inBuf;
|
const LZ77Info * info = (const LZ77Info *)inBuf;
|
||||||
inBuf += sizeof (LZ77Info);
|
inBuf += sizeof (LZ77Info);
|
||||||
int length = info->length + 3;
|
int length = info->length + 3;
|
||||||
if (bufCur - info->offset - 1 < buffer || bufCur + length > bufEnd)
|
if(bufCur - info->offset - 1 < buffer || bufCur + length > bufEnd)
|
||||||
return buffer;
|
return buffer;
|
||||||
memcpy(bufCur, bufCur - info->offset - 1, length);
|
memcpy(bufCur, bufCur - info->offset - 1, length);
|
||||||
bufCur += length;
|
bufCur += length;
|
||||||
@ -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')
|
||||||
{
|
{
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
//!Sound conversion and playback. A wrapper for other sound libraries - ASND, libmad, ltremor, etc
|
//!Sound conversion and playback. A wrapper for other sound libraries - ASND, libmad, ltremor, etc
|
||||||
class GuiSound
|
class GuiSound
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//!Constructor
|
//!Constructor
|
||||||
GuiSound();
|
GuiSound();
|
||||||
//!Copy Constructor
|
//!Copy Constructor
|
||||||
@ -81,12 +81,12 @@ class GuiSound
|
|||||||
void SetVolume(int v);
|
void SetVolume(int v);
|
||||||
//!\param l Loop (true to loop)
|
//!\param l Loop (true to loop)
|
||||||
void SetLoop(u8 l);
|
void SetLoop(u8 l);
|
||||||
private:
|
private:
|
||||||
//!Initializes the GuiSound object by setting the default values
|
//!Initializes the GuiSound object by setting the default values
|
||||||
void Init();
|
void Init();
|
||||||
//!Special sound case for sound.bin
|
//!Special sound case for sound.bin
|
||||||
void UncompressSoundbin(const u8 * snd, u32 len, bool isallocated);
|
void UncompressSoundbin(const u8 * snd, u32 len, bool isallocated);
|
||||||
protected:
|
protected:
|
||||||
std::string filepath;
|
std::string filepath;
|
||||||
u8 *sound; //!< Pointer to the sound data
|
u8 *sound; //!< Pointer to the sound data
|
||||||
u32 length; //!< Length of sound data
|
u32 length; //!< Length of sound data
|
||||||
|
@ -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,82 +53,34 @@ 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)
|
||||||
|
|
||||||
while (!Stop)
|
|
||||||
{
|
|
||||||
if (unzGetCurrentFileInfo(File, &cur_file_info, filename, sizeof(filename), NULL, 0, NULL, 0) != UNZ_OK)
|
|
||||||
Stop = true;
|
Stop = true;
|
||||||
|
|
||||||
if (!Stop && filename[strlen(filename) - 1] != '/')
|
while(!Stop)
|
||||||
|
{
|
||||||
|
if(unzGetCurrentFileInfo(File, &cur_file_info, filename, sizeof(filename), NULL, 0, NULL, 0) != UNZ_OK)
|
||||||
|
Stop = true;
|
||||||
|
|
||||||
|
if(!Stop && filename[strlen(filename) - 1] != '/')
|
||||||
{
|
{
|
||||||
u32 uncompressed_size = cur_file_info.uncompressed_size;
|
u32 uncompressed_size = cur_file_info.uncompressed_size;
|
||||||
|
|
||||||
@ -146,29 +99,32 @@ bool ZipFile::ExtractAll(const char *dest)
|
|||||||
|
|
||||||
fsop_MakeFolder(temppath);
|
fsop_MakeFolder(temppath);
|
||||||
|
|
||||||
if (ret == UNZ_OK)
|
if(ret == UNZ_OK)
|
||||||
{
|
{
|
||||||
FILE *pfile = fopen(writepath, "wb");
|
FILE *pfile = fopen(writepath, "wb");
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
done += ret;
|
done += ret;
|
||||||
|
|
||||||
} while (done < uncompressed_size);
|
} while(done < uncompressed_size);
|
||||||
|
|
||||||
fclose(pfile);
|
fclose(pfile);
|
||||||
unzCloseCurrentFile(File);
|
unzCloseCurrentFile(File);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (unzGoToNextFile(File) != UNZ_OK) Stop = true;
|
if(unzGoToNextFile(File) != UNZ_OK)
|
||||||
|
Stop = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
delete[] buffer;
|
delete[] buffer;
|
||||||
|
@ -40,7 +40,7 @@ typedef struct
|
|||||||
|
|
||||||
class ZipFile
|
class ZipFile
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//!Constructor
|
//!Constructor
|
||||||
ZipFile(const char *filepath);
|
ZipFile(const char *filepath);
|
||||||
//!Destructor
|
//!Destructor
|
||||||
@ -48,7 +48,7 @@ class ZipFile
|
|||||||
//!Extract all files from a zip file to a directory
|
//!Extract all files from a zip file to a directory
|
||||||
//!\param dest Destination path to where to extract
|
//!\param dest Destination path to where to extract
|
||||||
bool ExtractAll(const char *dest);
|
bool ExtractAll(const char *dest);
|
||||||
protected:
|
protected:
|
||||||
bool LoadList();
|
bool LoadList();
|
||||||
unzFile File;
|
unzFile File;
|
||||||
unz_file_info cur_file_info;
|
unz_file_info cur_file_info;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user