mirror of
https://github.com/Fledge68/WiiFlow_Lite.git
synced 2024-11-01 00:55:06 +01:00
-changed the memory management yet again, now just use the mem
which has enough space left instead of fixed memory in most parts -fixed alot of things about banner playing, now shouldnt randomly codedump anymore or things like this, also some banner sounds which did not play before should work fine now -removed unused code and added better debug prints -using some fixed voice for game banner and not always a new one per banner -fixed DIOS-MIOS cheats for sure now :P -fixed possible memory allocation bug in wbfs alloc (thanks to cfg-loader) -removed MEM2_memalign since it did not work correctly -fixed a few wrong memset sizes
This commit is contained in:
parent
e55ab171c6
commit
88955e9461
@ -43,14 +43,14 @@ void AnimatedBanner::LoadFont(u8 *font1, u8 *font2)
|
||||
|
||||
void AnimatedBanner::Clear()
|
||||
{
|
||||
if(layout_banner)
|
||||
if(layout_banner != NULL)
|
||||
{
|
||||
delete layout_banner;
|
||||
layout_banner = NULL;
|
||||
}
|
||||
if(newBanner)
|
||||
if(newBanner != NULL)
|
||||
{
|
||||
delete newBanner;
|
||||
free(newBanner);
|
||||
newBanner = NULL;
|
||||
}
|
||||
}
|
||||
@ -58,13 +58,15 @@ void AnimatedBanner::Clear()
|
||||
bool AnimatedBanner::LoadBanner(Banner *banner)
|
||||
{
|
||||
u32 banner_bin_size;
|
||||
const u8 *banner_bin = banner->GetFile((char*)"banner.bin", &banner_bin_size);
|
||||
u8 *banner_bin = banner->GetFile((char*)"banner.bin", &banner_bin_size);
|
||||
if(banner_bin == NULL)
|
||||
return false;
|
||||
return LoadBannerBin(banner_bin, banner_bin_size);
|
||||
bool ret = LoadBannerBin(banner_bin, banner_bin_size);
|
||||
free(banner_bin);
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool AnimatedBanner::LoadBannerBin(const u8 *banner_bin, u32 banner_bin_size)
|
||||
bool AnimatedBanner::LoadBannerBin(u8 *banner_bin, u32 banner_bin_size)
|
||||
{
|
||||
Clear();
|
||||
layout_banner = LoadLayout(banner_bin, banner_bin_size, "banner", CONF_GetLanguageString());
|
||||
@ -101,10 +103,12 @@ void AnimatedBanner::SetBannerTexture(const char *tex_name, const u8 *data, floa
|
||||
}
|
||||
}
|
||||
|
||||
Layout* AnimatedBanner::LoadLayout(const u8 *bnr, u32 bnr_size, const std::string& lyt_name, const std::string &language)
|
||||
Layout* AnimatedBanner::LoadLayout(u8 *bnr, u32 bnr_size, const std::string& lyt_name, const std::string &language)
|
||||
{
|
||||
u32 brlyt_size = 0;
|
||||
newBanner = DecompressCopy(bnr, bnr_size, &bnr_size);
|
||||
if(newBanner == NULL)
|
||||
return NULL;
|
||||
|
||||
const u8 *brlyt = u8_get_file(newBanner, (char*)fmt("%s.brlyt", lyt_name.c_str()), &brlyt_size);
|
||||
if(!brlyt)
|
||||
@ -147,43 +151,39 @@ Layout* AnimatedBanner::LoadLayout(const u8 *bnr, u32 bnr_size, const std::strin
|
||||
return layout;
|
||||
}
|
||||
|
||||
u8 *AnimatedBanner::DecompressCopy( const u8 * stuff, u32 len, u32 *size )
|
||||
u8 *DecompressCopy(u8 *stuff, u32 len, u32 *size)
|
||||
{
|
||||
// check for IMD5 header and skip it
|
||||
if( len > 0x40 && *(u32*)stuff == 0x494d4435 )// IMD5
|
||||
if(len > 0x40 && *(u32*)stuff == 0x494d4435) // IMD5
|
||||
{
|
||||
stuff += 0x20;
|
||||
len -= 0x20;
|
||||
}
|
||||
|
||||
u8* ret = NULL;
|
||||
u8 *ret = NULL;
|
||||
// determine if it needs to be decompressed
|
||||
if( IsAshCompressed( stuff, len ) )
|
||||
if(IsAshCompressed(stuff, len))
|
||||
{
|
||||
//u32 len2 = len;
|
||||
// ASH0
|
||||
ret = DecompressAsh( stuff, len );
|
||||
if( !ret )
|
||||
ret = DecompressAsh(stuff, len);
|
||||
if(!ret)
|
||||
{
|
||||
gprintf( "out of memory\n" );
|
||||
gprintf("out of memory\n");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else if( isLZ77compressed( (u8*)stuff ) )
|
||||
else if(isLZ77compressed(stuff))
|
||||
{
|
||||
// LZ77 with no magic word
|
||||
if( decompressLZ77content( (u8*)stuff, len, &ret, &len ) )
|
||||
{
|
||||
if(decompressLZ77content(stuff, len, &ret, &len))
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else if( *(u32*)( stuff ) == 0x4C5A3737 )// LZ77
|
||||
else if(*(u32*)(stuff) == 0x4C5A3737) // LZ77
|
||||
{
|
||||
// LZ77 with a magic word
|
||||
if( decompressLZ77content( (u8*)stuff + 4, len - 4, &ret, &len ) )
|
||||
{
|
||||
if(decompressLZ77content(stuff + 4, len - 4, &ret, &len ))
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -196,12 +196,10 @@ u8 *AnimatedBanner::DecompressCopy( const u8 * stuff, u32 len, u32 *size )
|
||||
}
|
||||
memcpy( ret, stuff, len );
|
||||
}
|
||||
if( size )
|
||||
{
|
||||
if(size)
|
||||
*size = len;
|
||||
}
|
||||
|
||||
// flush the cache so if there are any textures in this data, it will be ready for the GX
|
||||
DCFlushRange( ret, len );
|
||||
DCFlushRange(ret, len);
|
||||
return ret;
|
||||
}
|
||||
|
@ -37,18 +37,18 @@ public:
|
||||
void Clear();
|
||||
|
||||
bool LoadBanner(Banner *banner);
|
||||
bool LoadBannerBin(const u8 *banner_bin, u32 banner_bin_size);
|
||||
bool LoadBannerBin(u8 *banner_bin, u32 banner_bin_size);
|
||||
Layout *getBanner() const { return layout_banner; }
|
||||
void SetBannerTexture(const char *tex_name, const u8 *data, float width, float height, u8 fmt);
|
||||
void SetBannerText(const char *text_name, const wchar_t *wText);
|
||||
|
||||
protected:
|
||||
Layout* LoadLayout(const u8 *bnr, u32 bnr_size, const std::string& lyt_name, const std::string &language);
|
||||
u8 *DecompressCopy( const u8 * stuff, u32 len, u32 *size );
|
||||
Layout* LoadLayout(u8 *bnr, u32 bnr_size, const std::string& lyt_name, const std::string &language);
|
||||
Layout *layout_banner;
|
||||
u8 *newBanner;
|
||||
u8 *sysFont1;
|
||||
u8 *sysFont2;
|
||||
};
|
||||
|
||||
u8 *DecompressCopy(u8 *stuff, u32 len, u32 *size);
|
||||
|
||||
#endif
|
||||
|
@ -566,7 +566,7 @@ unsigned char * MD5fromFile(unsigned char *dst, const char *src)
|
||||
else
|
||||
blksize = 1048576;
|
||||
|
||||
unsigned char * buffer = MEM2_alloc(blksize);
|
||||
unsigned char * buffer = malloc(blksize);
|
||||
if(buffer == NULL)
|
||||
{
|
||||
//no memory
|
||||
@ -581,7 +581,7 @@ unsigned char * MD5fromFile(unsigned char *dst, const char *src)
|
||||
} while(read > 0);
|
||||
|
||||
fclose(file);
|
||||
MEM2_free(buffer);
|
||||
free(buffer);
|
||||
|
||||
(void)auth_md5CloseCtx( ctx, dst ); /* Close the context. */
|
||||
|
||||
|
@ -49,10 +49,11 @@ Banner::Banner(u8 *bnr, u32 bnr_size, u64 title, bool custom)
|
||||
opening_size = bnr_size;
|
||||
imet = NULL;
|
||||
|
||||
if (opening == NULL) return;
|
||||
if(opening == NULL)
|
||||
return;
|
||||
|
||||
IMET *imet = (IMET *) opening;
|
||||
if (imet->sig != IMET_SIGNATURE)
|
||||
IMET *imet = (IMET *)opening;
|
||||
if(imet->sig != IMET_SIGNATURE)
|
||||
imet = (IMET *) (opening + IMET_OFFSET);
|
||||
|
||||
if(imet->sig == IMET_SIGNATURE)
|
||||
@ -125,21 +126,29 @@ bool Banner::GetName(wchar_t *name, int language)
|
||||
if (imet == NULL) return false;
|
||||
|
||||
u16 *channelname = GetName(language);
|
||||
if (channelname)
|
||||
if(channelname)
|
||||
{
|
||||
for (int i = 0; i < IMET_MAX_NAME_LEN; i++)
|
||||
{
|
||||
for(int i = 0; i < IMET_MAX_NAME_LEN; i++)
|
||||
name[i] = channelname[i];
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
const u8 *Banner::GetFile(char *name, u32 *size)
|
||||
u8 *Banner::GetFile(char *name, u32 *size)
|
||||
{
|
||||
const u8 *bnrArc = (const u8 *)(((u8 *) imet) + sizeof(IMET));
|
||||
return u8_get_file(bnrArc, name, size);
|
||||
const u8* curfile = u8_get_file(bnrArc, name, size);
|
||||
if(curfile == NULL || *size == 0)
|
||||
return NULL;
|
||||
|
||||
//I like to have stuff in a separate memory region
|
||||
u8 *file = (u8*)malloc(*size);
|
||||
if(file == NULL)
|
||||
return NULL;
|
||||
|
||||
memcpy(file, curfile, (*size));
|
||||
return file;
|
||||
}
|
||||
|
||||
Banner * Banner::GetBanner(u64 title, char *appname, bool isfs, bool imetOnly)
|
||||
@ -152,7 +161,7 @@ Banner * Banner::GetBanner(u64 title, char *appname, bool isfs, bool imetOnly)
|
||||
if (size == 0)
|
||||
{
|
||||
if(buf != NULL)
|
||||
MEM2_free(buf);
|
||||
free(buf);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@ -170,7 +179,7 @@ Banner * Banner::GetBanner(u64 title, char *appname, bool isfs, bool imetOnly)
|
||||
fseek(fp, 0, SEEK_SET);
|
||||
}
|
||||
|
||||
buf = MEM2_alloc(size);
|
||||
buf = malloc(size);
|
||||
if(!buf)
|
||||
return NULL;
|
||||
|
||||
|
@ -67,19 +67,18 @@ class Banner
|
||||
|
||||
bool GetName(u8 *name, int language);
|
||||
bool GetName(wchar_t *name, int language);
|
||||
const u8 *GetFile(char *name, u32 *size);
|
||||
u8 *GetFile(char *name, u32 *size);
|
||||
|
||||
static Banner *GetBanner(u64 title, char *appname, bool isfs, bool imetOnly = false);
|
||||
u8 *GetBannerFile() { return opening; }
|
||||
u32 GetBannerFileSize() { return opening_size; }
|
||||
private:
|
||||
protected:
|
||||
u8 *opening;
|
||||
u32 opening_size;
|
||||
u64 title;
|
||||
IMET *imet;
|
||||
|
||||
u16 *GetName(int language);
|
||||
|
||||
static bool GetChannelNameFromApp(u64 title, wchar_t* name, int language);
|
||||
};
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <malloc.h>
|
||||
|
||||
#include "disc.h"
|
||||
#include "patchcode.h"
|
||||
@ -12,7 +13,6 @@
|
||||
#include "utils.h"
|
||||
#include "fs.h"
|
||||
#include "gecko.h"
|
||||
#include "mem2.hpp"
|
||||
|
||||
void __Disc_SetLowMem(void);
|
||||
void __Disc_SetTime(void);
|
||||
@ -199,8 +199,9 @@ void PatchChannel(u8 vidMode, GXRModeObj *vmode, bool vipatch, bool countryStrin
|
||||
|
||||
bool Identify_GenerateTik(signed_blob **outbuf, u32 *outlen)
|
||||
{
|
||||
signed_blob *buffer = (signed_blob *)MEM2_alloc(STD_SIGNED_TIK_SIZE);
|
||||
if (!buffer) return false;
|
||||
signed_blob *buffer = (signed_blob *)memalign(32, ALIGN32(STD_SIGNED_TIK_SIZE));
|
||||
if(!buffer)
|
||||
return false;
|
||||
memset(buffer, 0, STD_SIGNED_TIK_SIZE);
|
||||
|
||||
sig_rsa2048 *signature = (sig_rsa2048 *)buffer;
|
||||
@ -249,8 +250,8 @@ bool Identify(u64 titleid)
|
||||
if (certBuffer == NULL || certSize == 0)
|
||||
{
|
||||
gprintf("Failed!\n");
|
||||
MEM2_free(tmdBuffer);
|
||||
MEM2_free(tikBuffer);
|
||||
free(tmdBuffer);
|
||||
free(tikBuffer);
|
||||
return false;
|
||||
}
|
||||
gprintf("Success!\n");
|
||||
@ -279,9 +280,9 @@ bool Identify(u64 titleid)
|
||||
}
|
||||
}
|
||||
|
||||
MEM2_free(tmdBuffer);
|
||||
MEM2_free(tikBuffer);
|
||||
MEM2_free(certBuffer);
|
||||
free(tmdBuffer);
|
||||
free(tikBuffer);
|
||||
free(certBuffer);
|
||||
|
||||
return ret < 0 ? false : true;
|
||||
}
|
||||
@ -305,10 +306,10 @@ u8 *GetDol(u64 title, u32 bootcontent)
|
||||
if (decompressLZ77content(data, contentSize, &decompressed, &size) < 0)
|
||||
{
|
||||
gprintf("Decompression failed\n");
|
||||
MEM2_free(data);
|
||||
free(data);
|
||||
return NULL;
|
||||
}
|
||||
MEM2_free(data);
|
||||
free(data);
|
||||
data = decompressed;
|
||||
}
|
||||
return data;
|
||||
|
@ -106,7 +106,7 @@ u8 Channels::GetRequestedIOS(u64 title)
|
||||
if(size > 0x18B)
|
||||
IOS = titleTMD[0x18B];
|
||||
|
||||
MEM2_free(titleTMD);
|
||||
free(titleTMD);
|
||||
gprintf("Requested Game IOS: %i\n", IOS);
|
||||
return IOS;
|
||||
}
|
||||
@ -122,7 +122,7 @@ u64* Channels::GetChannelList(u32* count)
|
||||
|
||||
if(ES_GetTitles(titles, countall) < 0)
|
||||
{
|
||||
MEM2_free(titles);
|
||||
free(titles);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -143,7 +143,7 @@ u64* Channels::GetChannelList(u32* count)
|
||||
channels[(*count)++] = titles[i];
|
||||
}
|
||||
}
|
||||
MEM2_free(titles);
|
||||
free(titles);
|
||||
|
||||
return(u64*)MEM2_realloc(channels, *count * sizeof(u64));
|
||||
}
|
||||
@ -173,7 +173,7 @@ bool Channels::GetAppNameFromTmd(u64 title, char *app, bool dol, u32 *bootconten
|
||||
}
|
||||
}
|
||||
|
||||
MEM2_free(data);
|
||||
free(data);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -250,7 +250,7 @@ void Channels::Search(u32 channelType, string lang)
|
||||
}
|
||||
}
|
||||
|
||||
MEM2_free(list);
|
||||
free(list);
|
||||
}
|
||||
|
||||
wchar_t * Channels::GetName(int index)
|
||||
|
@ -12,14 +12,13 @@
|
||||
* -----------
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#include <gccore.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <malloc.h>
|
||||
|
||||
#include "lz77.h"
|
||||
#include "mem2.hpp"
|
||||
#include "utils.h"
|
||||
|
||||
u32 packBytes(int a, int b, int c, int d)
|
||||
@ -47,7 +46,7 @@ s32 __decompressLZ77_11(u8 *in, u32 inputLen, u8 **output, u32 *outputLen)
|
||||
|
||||
//printf("Decompressed size : %i\n", decompressedSize);
|
||||
|
||||
out = MEM2_alloc(ALIGN32(decompressedSize));
|
||||
out = malloc(ALIGN32(decompressedSize));
|
||||
if (out == NULL)
|
||||
{
|
||||
printf("Out of memory\n");
|
||||
@ -134,7 +133,7 @@ s32 __decompressLZ77_10(u8 *in, u8 **output, u32 *outputLen)
|
||||
|
||||
//printf("Decompressed size : %i\n", decompressedSize);
|
||||
|
||||
out = MEM2_alloc(ALIGN32(decompressedSize));
|
||||
out = malloc(ALIGN32(decompressedSize));
|
||||
if (out == NULL)
|
||||
{
|
||||
printf("Out of memory\n");
|
||||
|
@ -33,9 +33,9 @@
|
||||
#include <cstdlib>
|
||||
#include <stdarg.h>
|
||||
#include <dirent.h>
|
||||
#include <malloc.h>
|
||||
|
||||
#include "nand.hpp"
|
||||
#include "mem2.hpp"
|
||||
#include "wbfs.h"
|
||||
#include "gecko.h"
|
||||
#include "fileOps.h"
|
||||
@ -248,7 +248,7 @@ void Nand::__GetNameList(const char *source, namelist **entries, int *count)
|
||||
char entrypath[ISFS_MAXPATH];
|
||||
|
||||
s32 ret = ISFS_ReadDir(source, NULL, &numentries);
|
||||
names = (char *)MEM2_alloc((ISFS_MAXPATH) * numentries);
|
||||
names = (char *)memalign(32, ALIGN32((ISFS_MAXPATH) * numentries));
|
||||
if(names == NULL)
|
||||
return;
|
||||
|
||||
@ -257,13 +257,16 @@ void Nand::__GetNameList(const char *source, namelist **entries, int *count)
|
||||
|
||||
if(*entries != NULL)
|
||||
{
|
||||
MEM2_free(*entries);
|
||||
free(*entries);
|
||||
*entries = NULL;
|
||||
}
|
||||
|
||||
*entries = (namelist *)MEM2_alloc(sizeof(namelist) * numentries);
|
||||
*entries = (namelist *)malloc(sizeof(namelist) * numentries);
|
||||
if(*entries == NULL)
|
||||
{
|
||||
free(names);
|
||||
return;
|
||||
}
|
||||
|
||||
for(i = 0, k = 0; i < numentries; i++)
|
||||
{
|
||||
@ -283,13 +286,13 @@ void Nand::__GetNameList(const char *source, namelist **entries, int *count)
|
||||
ret = ISFS_ReadDir(entrypath, NULL, &l);
|
||||
(*entries)[i].type = ret < 0 ? 0 : 1;
|
||||
}
|
||||
MEM2_free(names);
|
||||
free(names);
|
||||
}
|
||||
|
||||
s32 Nand::__configread(void)
|
||||
{
|
||||
confbuffer = (u8 *)MEM2_alloc(0x4000);
|
||||
txtbuffer = (char *)MEM2_alloc(0x100);
|
||||
confbuffer = (u8 *)malloc(0x4000);
|
||||
txtbuffer = (char *)malloc(0x100);
|
||||
if(confbuffer == NULL || txtbuffer == NULL)
|
||||
return -1;
|
||||
|
||||
@ -349,8 +352,8 @@ s32 Nand::__configwrite(void)
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
MEM2_free(confbuffer);
|
||||
MEM2_free(txtbuffer);
|
||||
free(confbuffer);
|
||||
free(txtbuffer);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -526,7 +529,7 @@ s32 Nand::__FlashNandFile(const char *source, const char *dest)
|
||||
return fd;
|
||||
}
|
||||
|
||||
u8 *buffer = (u8 *)MEM2_alloc(BLOCK);
|
||||
u8 *buffer = (u8 *)memalign(32, ALIGN32(BLOCK));
|
||||
if(buffer == NULL)
|
||||
return -1;
|
||||
|
||||
@ -543,7 +546,7 @@ s32 Nand::__FlashNandFile(const char *source, const char *dest)
|
||||
gprintf(" failed\nError: fread(%p, 1, %d, %s) %d\n", buffer, size, source, ret);
|
||||
ISFS_Close(fd);
|
||||
fclose(file);
|
||||
MEM2_free(buffer);
|
||||
free(buffer);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -553,7 +556,7 @@ s32 Nand::__FlashNandFile(const char *source, const char *dest)
|
||||
gprintf(" failed\nError: ISFS_Write(%d, %p, %d) %d\n", fd, buffer, size, ret);
|
||||
ISFS_Close(fd);
|
||||
fclose(file);
|
||||
MEM2_free(buffer);
|
||||
free(buffer);
|
||||
return ret;
|
||||
}
|
||||
toread -= size;
|
||||
@ -574,7 +577,7 @@ s32 Nand::__FlashNandFile(const char *source, const char *dest)
|
||||
dumper(NandDone, NandSize, fsize, FileDone, FilesDone, FoldersDone, (char *)file, data);
|
||||
}
|
||||
ISFS_Close(fd);
|
||||
MEM2_free(buffer);
|
||||
free(buffer);
|
||||
fclose(file);
|
||||
return 1;
|
||||
}
|
||||
@ -589,16 +592,16 @@ s32 Nand::__DumpNandFile(const char *source, const char *dest)
|
||||
return fd;
|
||||
}
|
||||
|
||||
fstats *status = (fstats *)MEM2_alloc(sizeof(fstats));
|
||||
fstats *status = (fstats *)memalign(32, ALIGN32(sizeof(fstats)));
|
||||
if(status == NULL)
|
||||
return -1;
|
||||
|
||||
s32 ret = ISFS_GetFileStats(fd, status);
|
||||
if (ret < 0)
|
||||
if(ret < 0)
|
||||
{
|
||||
gprintf("Error: ISFS_GetFileStats(%d) %d\n", fd, ret);
|
||||
ISFS_Close(fd);
|
||||
MEM2_free(status);
|
||||
free(status);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -608,7 +611,7 @@ s32 Nand::__DumpNandFile(const char *source, const char *dest)
|
||||
if(showprogress)
|
||||
dumper(NandSize, 0x1f400000, 0x1f400000, NandSize, FilesDone, FoldersDone, (char *)"", data);
|
||||
ISFS_Close(fd);
|
||||
MEM2_free(status);
|
||||
free(status);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -616,18 +619,22 @@ s32 Nand::__DumpNandFile(const char *source, const char *dest)
|
||||
fsop_deleteFile(dest);
|
||||
|
||||
FILE *file = fopen(dest, "wb");
|
||||
if (!file)
|
||||
if(!file)
|
||||
{
|
||||
gprintf("Error opening destination: \"%s\"\n", dest);
|
||||
ISFS_Close(fd);
|
||||
free(status);
|
||||
return 0;
|
||||
}
|
||||
|
||||
gprintf("Dumping: %s (%ukb)...", source, (status->file_length / 0x400)+1);
|
||||
|
||||
u8 *buffer = (u8 *)MEM2_alloc(BLOCK);
|
||||
u8 *buffer = (u8 *)memalign(32, ALIGN32(BLOCK));
|
||||
if(buffer == NULL)
|
||||
{
|
||||
free(status);
|
||||
return -1;
|
||||
}
|
||||
|
||||
u32 toread = status->file_length;
|
||||
while(toread > 0)
|
||||
@ -642,8 +649,8 @@ s32 Nand::__DumpNandFile(const char *source, const char *dest)
|
||||
gprintf(" failed\nError: ISFS_Read(%d, %p, %d) %d\n", fd, buffer, size, ret);
|
||||
ISFS_Close(fd);
|
||||
fclose(file);
|
||||
MEM2_free(status);
|
||||
MEM2_free(buffer);
|
||||
free(status);
|
||||
free(buffer);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -653,8 +660,8 @@ s32 Nand::__DumpNandFile(const char *source, const char *dest)
|
||||
gprintf(" failed\nError writing to destination: \"%s\" (%d)\n", dest, ret);
|
||||
ISFS_Close(fd);
|
||||
fclose(file);
|
||||
MEM2_free(status);
|
||||
MEM2_free(buffer);
|
||||
free(status);
|
||||
free(buffer);
|
||||
return ret;
|
||||
}
|
||||
toread -= size;
|
||||
@ -676,8 +683,8 @@ s32 Nand::__DumpNandFile(const char *source, const char *dest)
|
||||
gprintf(" done!\n");
|
||||
fclose(file);
|
||||
ISFS_Close(fd);
|
||||
MEM2_free(status);
|
||||
MEM2_free(buffer);
|
||||
free(status);
|
||||
free(buffer);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -764,7 +771,7 @@ s32 Nand::__DumpNandFolder(const char *source, const char *dest)
|
||||
__DumpNandFolder(nsource, dest);
|
||||
}
|
||||
}
|
||||
MEM2_free(names);
|
||||
free(names);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -822,7 +829,7 @@ void Nand::CreateTitleTMD(const char *path, dir_discHdr *hdr)
|
||||
struct stat filestat;
|
||||
if (stat(nandpath, &filestat) == 0)
|
||||
{
|
||||
MEM2_free(titleTMD);
|
||||
free(titleTMD);
|
||||
gprintf("%s Exists!\n", nandpath);
|
||||
return;
|
||||
}
|
||||
@ -838,7 +845,7 @@ void Nand::CreateTitleTMD(const char *path, dir_discHdr *hdr)
|
||||
else
|
||||
gprintf("Creating title TMD: %s failed (%i)\n", nandpath, file);
|
||||
|
||||
MEM2_free(titleTMD);
|
||||
free(titleTMD);
|
||||
}
|
||||
|
||||
s32 Nand::FlashToNAND(const char *source, const char *dest, dump_callback_t i_dumper, void *i_data)
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <gccore.h>
|
||||
#include <malloc.h>
|
||||
|
||||
#include "utils.h"
|
||||
#include "mem2.hpp"
|
||||
@ -16,11 +17,18 @@
|
||||
#define wbfs_fatal(x) do { gprintf(x); wd_last_error = 1; } while(0)
|
||||
#define wbfs_error(x) do { gprintf(x); wd_last_error = 2; } while(0)
|
||||
|
||||
#define wbfs_malloc(x) MEM2_alloc(x)
|
||||
#define wbfs_free(x) MEM2_free(x)
|
||||
/* Thanks to cfg-loader */
|
||||
#define wbfs_malloc(x) calloc(x, 1)
|
||||
#define wbfs_free(x) free(x)
|
||||
|
||||
#define wbfs_ioalloc(x) MEM2_memalign(32, x)
|
||||
#define wbfs_iofree(x) MEM2_free(x)
|
||||
static inline void *wbfs_ioalloc(size_t x)
|
||||
{
|
||||
void *p = memalign(32, x);
|
||||
if(p)
|
||||
memset(p, 0, x);
|
||||
return p;
|
||||
}
|
||||
#define wbfs_iofree(x) free(x)
|
||||
|
||||
#define wbfs_be16(x) (*((u16*)(x)))
|
||||
#define wbfs_be32(x) (*((u32*)(x)))
|
||||
|
@ -12,13 +12,12 @@ en exposed s_fsop fsop structure can be used by callback to update operation sta
|
||||
#include <math.h>
|
||||
#include <ogcsys.h>
|
||||
#include <ogc/lwp_watchdog.h>
|
||||
|
||||
#include <malloc.h>
|
||||
#include <dirent.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/statvfs.h>
|
||||
|
||||
#include "fileOps.h"
|
||||
#include "memory/mem2.hpp"
|
||||
#include "utils.h"
|
||||
#include "gecko.h"
|
||||
|
||||
@ -205,7 +204,7 @@ bool fsop_CopyFile(char *source, char *target, progress_callback_t spinner, void
|
||||
u8 *threadStack = NULL;
|
||||
lwp_t hthread = LWP_THREAD_NULL;
|
||||
|
||||
buff = MEM2_alloc(block * 2);
|
||||
buff = malloc(block * 2);
|
||||
if(buff == NULL)
|
||||
return false;
|
||||
|
||||
@ -215,9 +214,12 @@ bool fsop_CopyFile(char *source, char *target, progress_callback_t spinner, void
|
||||
blockInfo[1] = 0;
|
||||
u32 bytes = 0;
|
||||
|
||||
threadStack = MEM2_alloc(STACKSIZE);
|
||||
threadStack = malloc(STACKSIZE);
|
||||
if(threadStack == NULL)
|
||||
{
|
||||
free(buff);
|
||||
return false;
|
||||
}
|
||||
|
||||
LWP_CreateThread(&hthread, thread_CopyFileReader, NULL, threadStack, STACKSIZE, 30);
|
||||
|
||||
@ -259,14 +261,14 @@ bool fsop_CopyFile(char *source, char *target, progress_callback_t spinner, void
|
||||
usleep(5);
|
||||
|
||||
LWP_JoinThread(hthread, NULL);
|
||||
MEM2_free(threadStack);
|
||||
free(threadStack);
|
||||
|
||||
stopThread = 1;
|
||||
DCFlushRange(&stopThread, sizeof(stopThread));
|
||||
|
||||
fclose(fs);
|
||||
fclose(ft);
|
||||
MEM2_free(buff);
|
||||
free(buff);
|
||||
|
||||
if(err)
|
||||
{
|
||||
|
@ -2,13 +2,8 @@
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <malloc.h>
|
||||
#include <ogc/machine/processor.h>
|
||||
#include "gc.h"
|
||||
#include "gecko.h"
|
||||
#include "fileOps.h"
|
||||
#include "utils.h"
|
||||
#include "memory/mem2.hpp"
|
||||
#include "loader/disc.h"
|
||||
|
||||
// for directory parsing and low-level file I/O
|
||||
#include <sys/types.h>
|
||||
@ -16,14 +11,20 @@
|
||||
#include <fcntl.h>
|
||||
#include <dirent.h>
|
||||
|
||||
#include "gc.h"
|
||||
#include "gecko.h"
|
||||
#include "fileOps.h"
|
||||
#include "utils.h"
|
||||
#include "loader/disc.h"
|
||||
|
||||
// DIOS-MIOS
|
||||
DML_CFG *DMLCfg = NULL;
|
||||
|
||||
void DML_New_SetOptions(const char *GamePath, char *CheatPath, char *NewCheatPath, const char *partition, bool cheats, bool debugger, u8 NMM, u8 nodisc, u8 DMLvideoMode, u8 videoSetting, bool widescreen, bool new_dm_cfg)
|
||||
void DML_New_SetOptions(const char *GamePath, char *CheatPath, const char *NewCheatPath, const char *partition, bool cheats, bool debugger, u8 NMM, u8 nodisc, u8 DMLvideoMode, u8 videoSetting, bool widescreen, bool new_dm_cfg)
|
||||
{
|
||||
gprintf("Wiiflow GC: Launch game '%s' through memory (new method)\n", GamePath);
|
||||
|
||||
DMLCfg = (DML_CFG*)MEM1_alloc(sizeof(DML_CFG));
|
||||
DMLCfg = (DML_CFG*)malloc(sizeof(DML_CFG));
|
||||
if(DMLCfg == NULL)
|
||||
return;
|
||||
memset(DMLCfg, 0, sizeof(DML_CFG));
|
||||
@ -55,12 +56,13 @@ void DML_New_SetOptions(const char *GamePath, char *CheatPath, char *NewCheatPat
|
||||
char *ptr;
|
||||
if(strstr(CheatPath, partition) == NULL)
|
||||
{
|
||||
fsop_CopyFile(CheatPath, NewCheatPath, NULL, NULL);
|
||||
ptr = &NewCheatPath[3];
|
||||
fsop_CopyFile(CheatPath, (char*)NewCheatPath, NULL, NULL);
|
||||
ptr = strstr(NewCheatPath, ":/") + 1;
|
||||
}
|
||||
else
|
||||
ptr = &CheatPath[3];
|
||||
ptr = strstr(CheatPath, ":/") + 1;
|
||||
strncpy(DMLCfg->CheatPath, ptr, sizeof(DMLCfg->CheatPath));
|
||||
gprintf("Cheat Path: %s\n", ptr);
|
||||
DMLCfg->Config |= DML_CFG_CHEAT_PATH;
|
||||
}
|
||||
|
||||
@ -86,7 +88,7 @@ void DML_New_SetOptions(const char *GamePath, char *CheatPath, char *NewCheatPat
|
||||
DMLCfg->VideoMode |= DML_VID_PROG_PATCH;
|
||||
}
|
||||
|
||||
void DML_Old_SetOptions(char *GamePath, char *CheatPath, char *NewCheatPath, bool cheats)
|
||||
void DML_Old_SetOptions(const char *GamePath)
|
||||
{
|
||||
gprintf("Wiiflow GC: Launch game '%s' through boot.bin (old method)\n", GamePath);
|
||||
FILE *f;
|
||||
@ -94,9 +96,6 @@ void DML_Old_SetOptions(char *GamePath, char *CheatPath, char *NewCheatPath, boo
|
||||
fwrite(GamePath, 1, strlen(GamePath) + 1, f);
|
||||
fclose(f);
|
||||
|
||||
if(cheats && strstr(CheatPath, NewCheatPath) == NULL)
|
||||
fsop_CopyFile(CheatPath, NewCheatPath, NULL, NULL);
|
||||
|
||||
//Tell DML to boot the game from sd card
|
||||
*(vu32*)0x80001800 = 0xB002D105;
|
||||
DCFlushRange((void *)(0x80001800), 4);
|
||||
@ -109,7 +108,7 @@ void DML_New_SetBootDiscOption(bool new_dm_cfg)
|
||||
{
|
||||
gprintf("Booting GC game\n");
|
||||
|
||||
DMLCfg = (DML_CFG*)MEM1_alloc(sizeof(DML_CFG));
|
||||
DMLCfg = (DML_CFG*)malloc(sizeof(DML_CFG));
|
||||
if(DMLCfg == NULL)
|
||||
return;
|
||||
memset(DMLCfg, 0, sizeof(DML_CFG));
|
||||
@ -137,7 +136,7 @@ void DML_New_WriteOptions()
|
||||
memcpy((void *)0x81200000, DMLCfg, sizeof(DML_CFG));
|
||||
DCFlushRange((void *)(0x81200000), sizeof(DML_CFG));
|
||||
|
||||
MEM1_free(DMLCfg);
|
||||
free(DMLCfg);
|
||||
}
|
||||
|
||||
|
||||
@ -155,12 +154,12 @@ bool DEVO_Installed(const char* path)
|
||||
FILE *f = fopen(loader_path, "rb");
|
||||
if(f)
|
||||
{
|
||||
u8 *tbuf = (u8 *)MEM2_alloc(0x04);
|
||||
u8 *tbuf = (u8 *)malloc(0x04);
|
||||
fread(tbuf, 1, 4, f);
|
||||
if(*(vu32*)tbuf == 0x4800004c)
|
||||
devo = true;
|
||||
|
||||
MEM2_free(tbuf);
|
||||
free(tbuf);
|
||||
fclose(f);
|
||||
}
|
||||
return devo;
|
||||
@ -205,7 +204,7 @@ void DEVO_SetOptions(const char *isopath, const char *partition, const char *loa
|
||||
fclose(f);
|
||||
|
||||
// fill out the Devolution config struct
|
||||
memset(DEVO_CONFIG, 0, sizeof(*DEVO_CONFIG));
|
||||
memset(DEVO_CONFIG, 0, sizeof(gconfig));
|
||||
DEVO_CONFIG->signature = 0x3EF9DB23;
|
||||
DEVO_CONFIG->version = 0x00000100;
|
||||
DEVO_CONFIG->device_signature = st.st_dev;
|
||||
|
@ -49,8 +49,8 @@ enum dmlvideomode
|
||||
DML_VID_PROG_PATCH = (1<<4),
|
||||
};
|
||||
|
||||
void DML_New_SetOptions(const char *GamePath, char *CheatPath, char *NewCheatPath, const char *partition, bool cheats, bool debugger, u8 NMM, u8 nodisc, u8 DMLvideoMode, u8 videoSetting, bool widescreen, bool new_dm_cfg);
|
||||
void DML_Old_SetOptions(char *GamePath, char *CheatPath, char *NewCheatPath, bool cheats);
|
||||
void DML_New_SetOptions(const char *GamePath, char *CheatPath, const char *NewCheatPath, const char *partition, bool cheats, bool debugger, u8 NMM, u8 nodisc, u8 DMLvideoMode, u8 videoSetting, bool widescreen, bool new_dm_cfg);
|
||||
void DML_Old_SetOptions(const char *GamePath);
|
||||
void DML_New_SetBootDiscOption(bool new_dm_cfg);
|
||||
void DML_New_WriteOptions();
|
||||
|
||||
|
@ -55,13 +55,13 @@ void GC_Disc::init(char *path)
|
||||
f = fopen(GamePath, "rb");
|
||||
if(f == NULL)
|
||||
return;
|
||||
u8 *ReadBuffer = (u8*)MEM2_alloc(0x440);
|
||||
u8 *ReadBuffer = (u8*)malloc(0x440);
|
||||
if(ReadBuffer == NULL)
|
||||
return;
|
||||
fread(ReadBuffer, 1, 0x440, f);
|
||||
u32 FSTOffset = *(vu32*)(ReadBuffer+0x424);
|
||||
u32 FSTSize = *(vu32*)(ReadBuffer+0x428);
|
||||
MEM2_free(ReadBuffer);
|
||||
free(ReadBuffer);
|
||||
fseek(f, FSTOffset, SEEK_SET);
|
||||
Read_FST(f, FSTSize);
|
||||
fclose(f);
|
||||
@ -72,19 +72,19 @@ void GC_Disc::clear()
|
||||
{
|
||||
if(opening_bnr)
|
||||
{
|
||||
MEM2_free(opening_bnr);
|
||||
free(opening_bnr);
|
||||
opening_bnr = NULL;
|
||||
}
|
||||
if(FSTable)
|
||||
{
|
||||
MEM2_free(FSTable);
|
||||
free(FSTable);
|
||||
FSTable = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void GC_Disc::Read_FST(FILE *f, u32 FST_size)
|
||||
{
|
||||
FSTable = (u8*)MEM2_alloc(FST_size);
|
||||
FSTable = (u8*)malloc(FST_size);
|
||||
if(FSTable == NULL)
|
||||
return;
|
||||
fread(FSTable, 1, FST_size, f);
|
||||
@ -119,7 +119,7 @@ u8 *GC_Disc::GetGameCubeBanner()
|
||||
}
|
||||
if(f)
|
||||
{
|
||||
opening_bnr = (u8*)MEM2_alloc(fst[i].FileLength);
|
||||
opening_bnr = (u8*)malloc(fst[i].FileLength);
|
||||
fread(opening_bnr, 1, fst[i].FileLength, f);
|
||||
fclose(f);
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ bool bufferMessages = true;
|
||||
bool WriteToSD = false;
|
||||
|
||||
char *tmpfilebuffer = NULL;
|
||||
u32 tmpbuffersize = filebuffer + 1 * sizeof(char);
|
||||
|
||||
static ssize_t __out_write(struct _reent *r __attribute__((unused)), int fd __attribute__((unused)), const char *ptr, size_t len)
|
||||
{
|
||||
@ -71,7 +72,7 @@ void ClearLogBuffer()
|
||||
{
|
||||
if(tmpfilebuffer == NULL)
|
||||
return;
|
||||
MEM2_free(tmpfilebuffer);
|
||||
free(tmpfilebuffer);
|
||||
tmpfilebuffer = NULL;
|
||||
}
|
||||
|
||||
@ -87,7 +88,7 @@ void WriteToFile(char* tmp)
|
||||
}
|
||||
else
|
||||
{
|
||||
MEM2_free(tmpfilebuffer);
|
||||
free(tmpfilebuffer);
|
||||
tmpfilebuffer = NULL;
|
||||
return;
|
||||
}
|
||||
@ -98,7 +99,7 @@ void WriteToFile(char* tmp)
|
||||
if(outfile)
|
||||
{
|
||||
fwrite(tmpfilebuffer, 1, strlen(tmpfilebuffer), outfile);
|
||||
memset(tmpfilebuffer, 0, sizeof(tmpfilebuffer));
|
||||
memset(tmpfilebuffer, 0, tmpbuffersize);
|
||||
fclose(outfile);
|
||||
}
|
||||
}
|
||||
@ -183,7 +184,7 @@ bool InitGecko()
|
||||
|
||||
void AllocSDGeckoBuffer()
|
||||
{
|
||||
tmpfilebuffer = (char*)MEM2_alloc(filebuffer + 1 * sizeof(char));
|
||||
tmpfilebuffer = (char*)malloc(tmpbuffersize);
|
||||
if(tmpfilebuffer != NULL)
|
||||
memset(tmpfilebuffer, 0, sizeof(tmpfilebuffer));
|
||||
memset(tmpfilebuffer, 0, tmpbuffersize);
|
||||
}
|
||||
|
@ -1,25 +1,25 @@
|
||||
/****************************************************************************
|
||||
*Copyright (C) 2010
|
||||
*by Dimok
|
||||
* Copyright (C) 2010
|
||||
* by Dimok
|
||||
*
|
||||
*This software is provided 'as-is', without any express or implied
|
||||
*warranty. In no event will the authors be held liable for any
|
||||
*damages arising from the use of this software.
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any
|
||||
* damages arising from the use of this software.
|
||||
*
|
||||
*Permission is granted to anyone to use this software for any
|
||||
*purpose, including commercial applications, and to alter it and
|
||||
*redistribute it freely, subject to the following restrictions:
|
||||
* Permission is granted to anyone to use this software for any
|
||||
* purpose, including commercial applications, and to alter it and
|
||||
* redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
*1. The origin of this software must not be misrepresented; you
|
||||
*must not claim that you wrote the original software. If you use
|
||||
*this software in a product, an acknowledgment in the product
|
||||
*documentation would be appreciated but is not required.
|
||||
* 1. The origin of this software must not be misrepresented; you
|
||||
* must not claim that you wrote the original software. If you use
|
||||
* this software in a product, an acknowledgment in the product
|
||||
* documentation would be appreciated but is not required.
|
||||
*
|
||||
*2. Altered source versions must be plainly marked as such, and
|
||||
*must not be misrepresented as being the original software.
|
||||
* 2. Altered source versions must be plainly marked as such, and
|
||||
* must not be misrepresented as being the original software.
|
||||
*
|
||||
*3. This notice may not be removed or altered from any source
|
||||
*distribution.
|
||||
* 3. This notice may not be removed or altered from any source
|
||||
* distribution.
|
||||
***************************************************************************/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -27,13 +27,13 @@
|
||||
|
||||
#include "Gekko.h"
|
||||
|
||||
#define HW_GPIO 0xCD0000C0;
|
||||
#define DISC_SLOT_LED 0x20
|
||||
#define HW_GPIOB_OUT 0xCD0000C0;
|
||||
#define DISC_SLOT_LED 0x20
|
||||
|
||||
lwp_t light_thread = LWP_THREAD_NULL;
|
||||
|
||||
void *light_loop();
|
||||
vu32 *light_reg = (u32*) HW_GPIO;
|
||||
vu32 *light_reg = (u32*)HW_GPIOB_OUT;
|
||||
bool light_on = false;
|
||||
u8 light_level = 0;
|
||||
|
||||
@ -43,7 +43,7 @@ struct timespec light_timeoff;
|
||||
void wiiLightOn()
|
||||
{
|
||||
light_on = true;
|
||||
|
||||
light_level = 0;
|
||||
if(light_thread == LWP_THREAD_NULL)
|
||||
LWP_CreateThread(&light_thread, light_loop, NULL, NULL, 0, LWP_PRIO_HIGHEST);
|
||||
}
|
||||
@ -51,7 +51,7 @@ void wiiLightOn()
|
||||
void wiiLightOff()
|
||||
{
|
||||
light_on = false;
|
||||
|
||||
light_level = 0;
|
||||
LWP_JoinThread(light_thread, NULL);
|
||||
light_thread = LWP_THREAD_NULL;
|
||||
*light_reg &= ~DISC_SLOT_LED;
|
||||
@ -93,7 +93,7 @@ void *light_loop()
|
||||
*light_reg |= DISC_SLOT_LED;
|
||||
nanosleep(&timeon);
|
||||
// Turn off the light (if required) and sleep for a bit
|
||||
if (timeoff.tv_nsec > 0)
|
||||
if(timeoff.tv_nsec > 0)
|
||||
*light_reg &= ~DISC_SLOT_LED;
|
||||
nanosleep(&timeoff);
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ WiiMovie::WiiMovie(const char * filepath)
|
||||
}
|
||||
|
||||
PlayThreadStack = NULL;
|
||||
ThreadStack = (u8 *)MEM2_alloc(32768);
|
||||
ThreadStack = (u8 *)malloc(32768);
|
||||
if (!ThreadStack)
|
||||
return;
|
||||
|
||||
@ -109,7 +109,7 @@ WiiMovie::~WiiMovie()
|
||||
}
|
||||
if (ThreadStack != NULL)
|
||||
{
|
||||
MEM2_free(ThreadStack);
|
||||
free(ThreadStack);
|
||||
ThreadStack = NULL;
|
||||
}
|
||||
|
||||
@ -127,7 +127,7 @@ bool WiiMovie::Play(bool loop)
|
||||
|
||||
gprintf("Start playing video\n");
|
||||
|
||||
PlayThreadStack = (u8 *)MEM2_alloc(32768);
|
||||
PlayThreadStack = (u8 *)malloc(32768);
|
||||
if (PlayThreadStack == NULL)
|
||||
return false;
|
||||
|
||||
@ -155,7 +155,7 @@ void WiiMovie::Stop()
|
||||
gprintf("Playing thread stopped\n");
|
||||
|
||||
if(PlayThreadStack != NULL)
|
||||
MEM2_free(PlayThreadStack);
|
||||
free(PlayThreadStack);
|
||||
}
|
||||
|
||||
void WiiMovie::SetVolume(int vol)
|
||||
|
@ -280,7 +280,7 @@ void VideoFrame::resize(int width, int height)
|
||||
_p = 3*width;
|
||||
_p += (4 - _p%4)%4;
|
||||
|
||||
_data = (u8 *)MEM2_alloc(_p * _h);
|
||||
_data = (u8 *)malloc(_p * _h);
|
||||
}
|
||||
|
||||
int VideoFrame::getWidth() const
|
||||
@ -301,7 +301,7 @@ const u8* VideoFrame::getData() const
|
||||
void VideoFrame::dealloc()
|
||||
{
|
||||
if(_data != NULL)
|
||||
MEM2_free(_data);
|
||||
free(_data);
|
||||
_w = _h = _p = 0;
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@ IMGCTX PNGU_SelectImageFromBuffer (const void *buffer)
|
||||
{
|
||||
if (!buffer) return NULL;
|
||||
|
||||
IMGCTX ctx = MEM2_alloc(sizeof (struct _IMGCTX));
|
||||
IMGCTX ctx = malloc(sizeof (struct _IMGCTX));
|
||||
if (!ctx) return NULL;
|
||||
|
||||
ctx->buffer = (void *) buffer;
|
||||
@ -79,7 +79,7 @@ IMGCTX PNGU_SelectImageFromDevice (const char *filename)
|
||||
if (!filename)
|
||||
return NULL;
|
||||
|
||||
IMGCTX ctx = MEM2_alloc(sizeof (struct _IMGCTX));
|
||||
IMGCTX ctx = malloc(sizeof (struct _IMGCTX));
|
||||
if (ctx == NULL)
|
||||
return NULL;
|
||||
|
||||
@ -87,11 +87,11 @@ IMGCTX PNGU_SelectImageFromDevice (const char *filename)
|
||||
ctx->source = PNGU_SOURCE_DEVICE;
|
||||
ctx->cursor = 0;
|
||||
|
||||
ctx->filename = MEM2_alloc(strlen (filename) + 1);
|
||||
ctx->filename = malloc(strlen (filename) + 1);
|
||||
if (ctx->filename == NULL)
|
||||
{
|
||||
if(ctx != NULL)
|
||||
MEM2_free(ctx);
|
||||
free(ctx);
|
||||
return NULL;
|
||||
}
|
||||
strcpy(ctx->filename, filename);
|
||||
@ -109,14 +109,14 @@ void PNGU_ReleaseImageContext (IMGCTX ctx)
|
||||
return;
|
||||
|
||||
if(ctx->filename)
|
||||
MEM2_free(ctx->filename);
|
||||
free(ctx->filename);
|
||||
|
||||
if((ctx->propRead) && (ctx->prop.trans))
|
||||
MEM2_free(ctx->prop.trans);
|
||||
free(ctx->prop.trans);
|
||||
|
||||
pngu_free_info(ctx);
|
||||
|
||||
MEM2_free(ctx);
|
||||
free(ctx);
|
||||
}
|
||||
|
||||
|
||||
@ -156,8 +156,8 @@ int PNGU_DecodeToYCbYCr (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *buff
|
||||
*(ctx->row_pointers[y]+x*6+3), *(ctx->row_pointers[y]+x*6+4), *(ctx->row_pointers[y]+x*6+5));
|
||||
|
||||
// Free resources
|
||||
MEM2_free(ctx->img_data);
|
||||
MEM2_free(ctx->row_pointers);
|
||||
free(ctx->img_data);
|
||||
free(ctx->row_pointers);
|
||||
|
||||
// Success
|
||||
return PNGU_OK;
|
||||
@ -180,8 +180,8 @@ int PNGU_DecodeToRGB565 (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *buff
|
||||
(((PNGU_u16) (ctx->row_pointers[y][x*3+2] & 0xF8)) >> 3);
|
||||
|
||||
// Free resources
|
||||
MEM2_free(ctx->img_data);
|
||||
MEM2_free(ctx->row_pointers);
|
||||
free(ctx->img_data);
|
||||
free(ctx->row_pointers);
|
||||
|
||||
// Success
|
||||
return PNGU_OK;
|
||||
@ -216,8 +216,8 @@ int PNGU_DecodeToRGBA8 (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *buffe
|
||||
}
|
||||
|
||||
// Free resources
|
||||
MEM2_free(ctx->img_data);
|
||||
MEM2_free(ctx->row_pointers);
|
||||
free(ctx->img_data);
|
||||
free(ctx->row_pointers);
|
||||
|
||||
// Success
|
||||
return PNGU_OK;
|
||||
@ -279,8 +279,8 @@ int PNGU_DecodeTo4x4RGB565 (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *b
|
||||
}
|
||||
|
||||
// Free resources
|
||||
MEM2_free(ctx->img_data);
|
||||
MEM2_free(ctx->row_pointers);
|
||||
free(ctx->img_data);
|
||||
free(ctx->row_pointers);
|
||||
|
||||
// Success
|
||||
return PNGU_OK;
|
||||
@ -526,8 +526,8 @@ int PNGU_DecodeTo4x4RGB5A3 (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *b
|
||||
}
|
||||
|
||||
// Free resources
|
||||
MEM2_free(ctx->img_data);
|
||||
MEM2_free(ctx->row_pointers);
|
||||
free(ctx->img_data);
|
||||
free(ctx->row_pointers);
|
||||
|
||||
// Success
|
||||
return PNGU_OK;
|
||||
@ -650,8 +650,8 @@ int PNGU_DecodeTo4x4RGBA8 (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *bu
|
||||
}
|
||||
|
||||
// Free resources
|
||||
MEM2_free(ctx->img_data);
|
||||
MEM2_free(ctx->row_pointers);
|
||||
free(ctx->img_data);
|
||||
free(ctx->row_pointers);
|
||||
|
||||
// Success
|
||||
return PNGU_OK;
|
||||
@ -768,8 +768,8 @@ int PNGU_DecodeToCMPR(IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *buffer)
|
||||
outBuf += 4;
|
||||
}
|
||||
// Free resources
|
||||
MEM2_free(ctx->img_data);
|
||||
MEM2_free(ctx->row_pointers);
|
||||
free(ctx->img_data);
|
||||
free(ctx->row_pointers);
|
||||
|
||||
// Success
|
||||
return PNGU_OK;
|
||||
@ -839,7 +839,7 @@ int PNGU_EncodeFromYCbYCr(IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *buf
|
||||
if (rowbytes % 4)
|
||||
rowbytes = ((rowbytes / 4) + 1) * 4; // Add extra padding so each row starts in a 4 byte boundary
|
||||
|
||||
ctx->img_data = MEM2_alloc(rowbytes * height);
|
||||
ctx->img_data = malloc(rowbytes * height);
|
||||
if (!ctx->img_data)
|
||||
{
|
||||
png_destroy_write_struct (&(ctx->png_ptr), (png_infopp)NULL);
|
||||
@ -848,7 +848,7 @@ int PNGU_EncodeFromYCbYCr(IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *buf
|
||||
return PNGU_LIB_ERROR;
|
||||
}
|
||||
|
||||
ctx->row_pointers = MEM2_alloc(sizeof (png_bytep) * height);
|
||||
ctx->row_pointers = malloc(sizeof (png_bytep) * height);
|
||||
if (!ctx->row_pointers)
|
||||
{
|
||||
png_destroy_write_struct (&(ctx->png_ptr), (png_infopp)NULL);
|
||||
@ -880,8 +880,8 @@ int PNGU_EncodeFromYCbYCr(IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *buf
|
||||
png_write_end (ctx->png_ptr, (png_infop) NULL);
|
||||
|
||||
// Free resources
|
||||
MEM2_free(ctx->img_data);
|
||||
MEM2_free(ctx->row_pointers);
|
||||
free(ctx->img_data);
|
||||
free(ctx->row_pointers);
|
||||
png_destroy_write_struct (&(ctx->png_ptr), &(ctx->info_ptr));
|
||||
if (ctx->source == PNGU_SOURCE_DEVICE)
|
||||
fclose (ctx->fd);
|
||||
@ -1060,7 +1060,7 @@ int pngu_info (IMGCTX ctx)
|
||||
{
|
||||
if (ctx->prop.numTrans)
|
||||
{
|
||||
ctx->prop.trans = MEM2_alloc(sizeof (PNGUCOLOR) * ctx->prop.numTrans);
|
||||
ctx->prop.trans = malloc(sizeof (PNGUCOLOR) * ctx->prop.numTrans);
|
||||
if (ctx->prop.trans)
|
||||
{
|
||||
for (i = 0; i < ctx->prop.numTrans; i++)
|
||||
@ -1079,7 +1079,7 @@ int pngu_info (IMGCTX ctx)
|
||||
{
|
||||
if (ctx->prop.numTrans)
|
||||
{
|
||||
ctx->prop.trans = MEM2_alloc(sizeof (PNGUCOLOR) * ctx->prop.numTrans);
|
||||
ctx->prop.trans = malloc(sizeof (PNGUCOLOR) * ctx->prop.numTrans);
|
||||
if (ctx->prop.trans)
|
||||
for (i = 0; i < ctx->prop.numTrans; i++)
|
||||
ctx->prop.trans[i].r = ctx->prop.trans[i].g = ctx->prop.trans[i].b =
|
||||
@ -1126,8 +1126,8 @@ int pngu_decode (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, PNGU_u32 stripAlph
|
||||
{
|
||||
error:
|
||||
memcpy(png_jmpbuf(ctx->png_ptr), save_jmp, sizeof(save_jmp));
|
||||
MEM2_free(ctx->row_pointers);
|
||||
MEM2_free(ctx->img_data);
|
||||
free(ctx->row_pointers);
|
||||
free(ctx->img_data);
|
||||
pngu_free_info (ctx);
|
||||
//printf("*** This is a corrupted image!!\n"); sleep(5);
|
||||
return mem_err ? PNGU_LIB_ERROR : -666;
|
||||
@ -1161,14 +1161,14 @@ int pngu_decode (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, PNGU_u32 stripAlph
|
||||
if (rowbytes % 4)
|
||||
rowbytes = ((rowbytes / 4) + 1) * 4; // Add extra padding so each row starts in a 4 byte boundary
|
||||
|
||||
ctx->img_data = MEM2_alloc(rowbytes * ctx->prop.imgHeight);
|
||||
ctx->img_data = malloc(rowbytes * ctx->prop.imgHeight);
|
||||
if (!ctx->img_data)
|
||||
{
|
||||
mem_err = 1;
|
||||
goto error;
|
||||
}
|
||||
|
||||
ctx->row_pointers = MEM2_alloc(sizeof (png_bytep) * ctx->prop.imgHeight);
|
||||
ctx->row_pointers = malloc(sizeof (png_bytep) * ctx->prop.imgHeight);
|
||||
if (!ctx->row_pointers)
|
||||
{
|
||||
mem_err = 1;
|
||||
|
@ -199,7 +199,7 @@ STexture::TexErr STexture::fromImageFile(const char *filename, u8 f, Alloc alloc
|
||||
u8 *Image = NULL;
|
||||
if(fileSize)
|
||||
{
|
||||
Image = (u8*)MEM2_alloc(fileSize);
|
||||
Image = (u8*)malloc(fileSize);
|
||||
if(Image != NULL)
|
||||
fread(Image, 1, fileSize, file);
|
||||
}
|
||||
@ -212,7 +212,7 @@ STexture::TexErr STexture::fromImageFile(const char *filename, u8 f, Alloc alloc
|
||||
result = fromPNG(Image, f, alloc, minMipSize, maxMipSize);
|
||||
else
|
||||
result = fromJPG(Image, fileSize, f, alloc, minMipSize, maxMipSize);
|
||||
MEM2_free(Image);
|
||||
free(Image);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -274,8 +274,8 @@ void CVideo::cleanup(void)
|
||||
}
|
||||
free(MEM_K1_TO_K0(m_frameBuf[0]));
|
||||
free(MEM_K1_TO_K0(m_frameBuf[1]));
|
||||
MEM1_free(m_stencil);
|
||||
MEM1_free(m_fifo);
|
||||
free(m_stencil);
|
||||
free(m_fifo);
|
||||
}
|
||||
|
||||
void CVideo::prepareAAPass(int aaStep)
|
||||
@ -502,7 +502,6 @@ void CVideo::_showWaitMessages(CVideo *m)
|
||||
m->prepare();
|
||||
m->setup2DProjection();
|
||||
GX_SetNumChans(0);
|
||||
wiiLightSetLevel(0);
|
||||
wiiLightOn();
|
||||
|
||||
while(m->m_showWaitMessage)
|
||||
|
@ -167,7 +167,7 @@ static bool PrinceOfPersiaPatch()
|
||||
if (memcmp("SPX", (char *) 0x80000000, 3) != 0 && memcmp("RPW", (char *) 0x80000000, 3) != 0)
|
||||
return false;
|
||||
|
||||
WIP_Code * CodeList = MEM2_alloc(5 * sizeof(WIP_Code));
|
||||
WIP_Code * CodeList = malloc(5 * sizeof(WIP_Code));
|
||||
CodeList[0].offset = 0x007AAC6A;
|
||||
CodeList[0].srcaddress = 0x7A6B6F6A;
|
||||
CodeList[0].dstaddress = 0x6F6A7A6B;
|
||||
@ -186,7 +186,7 @@ static bool PrinceOfPersiaPatch()
|
||||
|
||||
if (set_wip_list(CodeList, 5) == false)
|
||||
{
|
||||
MEM2_free(CodeList);
|
||||
free(CodeList);
|
||||
CodeList = NULL;
|
||||
return false;
|
||||
}
|
||||
@ -200,7 +200,7 @@ static bool NewSuperMarioBrosPatch()
|
||||
|
||||
if (memcmp("SMNE01", (char *) 0x80000000, 6) == 0)
|
||||
{
|
||||
CodeList = MEM2_alloc(3 * sizeof(WIP_Code));
|
||||
CodeList = malloc(3 * sizeof(WIP_Code));
|
||||
if(!CodeList)
|
||||
return false;
|
||||
CodeList[0].offset = 0x001AB610;
|
||||
@ -215,7 +215,7 @@ static bool NewSuperMarioBrosPatch()
|
||||
}
|
||||
else if (memcmp("SMNP01", (char *) 0x80000000, 6) == 0)
|
||||
{
|
||||
CodeList = MEM2_alloc(3 * sizeof(WIP_Code));
|
||||
CodeList = malloc(3 * sizeof(WIP_Code));
|
||||
if(!CodeList)
|
||||
return false;
|
||||
CodeList[0].offset = 0x001AB750;
|
||||
@ -230,7 +230,7 @@ static bool NewSuperMarioBrosPatch()
|
||||
}
|
||||
else if (memcmp("SMNJ01", (char *) 0x80000000, 6) == 0)
|
||||
{
|
||||
CodeList = MEM2_alloc(3 * sizeof(WIP_Code));
|
||||
CodeList = malloc(3 * sizeof(WIP_Code));
|
||||
if(!CodeList)
|
||||
return false;
|
||||
CodeList[0].offset = 0x001AB420;
|
||||
@ -245,7 +245,7 @@ static bool NewSuperMarioBrosPatch()
|
||||
}
|
||||
if (CodeList && set_wip_list(CodeList, 3) == false)
|
||||
{
|
||||
MEM2_free(CodeList);
|
||||
free(CodeList);
|
||||
CodeList = NULL;
|
||||
return false;
|
||||
}
|
||||
|
@ -31,7 +31,6 @@
|
||||
|
||||
#include "cios.h"
|
||||
#include "utils.h"
|
||||
#include "mem2.hpp"
|
||||
#include "gecko.h"
|
||||
#include "fs.h"
|
||||
#include "mload.h"
|
||||
@ -70,12 +69,12 @@ bool D2X(u8 ios, u8 *base)
|
||||
|| info->version < 6 /* Version */
|
||||
|| strncasecmp(info->name, "d2x", 3) != 0) /* Name */
|
||||
{
|
||||
MEM2_free(info);
|
||||
free(info);
|
||||
return false;
|
||||
}
|
||||
|
||||
*base = (u8)info->baseios;
|
||||
MEM2_free(info);
|
||||
free(info);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -84,13 +83,13 @@ signed_blob *GetTMD(u8 ios, u32 *TMD_Length)
|
||||
if(ES_GetStoredTMDSize(TITLE_ID(1, ios), TMD_Length) < 0)
|
||||
return NULL;
|
||||
|
||||
signed_blob *TMD = (signed_blob*)MEM2_alloc(ALIGN32(*TMD_Length));
|
||||
signed_blob *TMD = (signed_blob*)memalign(32, ALIGN32(*TMD_Length));
|
||||
if(TMD == NULL)
|
||||
return NULL;
|
||||
|
||||
if(ES_GetStoredTMD(TITLE_ID(1, ios), TMD, *TMD_Length) < 0)
|
||||
{
|
||||
MEM2_free(TMD);
|
||||
free(TMD);
|
||||
return NULL;
|
||||
}
|
||||
return TMD;
|
||||
@ -111,7 +110,7 @@ iosinfo_t *GetInfo(u8 ios)
|
||||
char filepath[ISFS_MAXPATH] ATTRIBUTE_ALIGN(32);
|
||||
sprintf(filepath, "/title/00000001/%08x/content/%08x.app", ios, *(u8 *)((u32)TMD+0x1E7));
|
||||
|
||||
MEM2_free(TMD);
|
||||
free(TMD);
|
||||
|
||||
u32 size = 0;
|
||||
u8 *buffer = ISFS_GetFile((u8 *)filepath, &size, sizeof(iosinfo_t));
|
||||
@ -147,17 +146,17 @@ int get_ios_type(u8 slot)
|
||||
tmd *iosTMD = (tmd*)SIGNATURE_PAYLOAD(TMD_Buffer);
|
||||
if(Title_GetSize_FromTMD(iosTMD) < 0x100000 || iosTMD->title_version == 65280)
|
||||
{
|
||||
MEM2_free(TMD_Buffer);
|
||||
free(TMD_Buffer);
|
||||
return IOS_TYPE_NO_CIOS;
|
||||
}
|
||||
|
||||
iosinfo_t *info = GetInfo(slot);
|
||||
if(info == NULL)
|
||||
{
|
||||
MEM2_free(TMD_Buffer);
|
||||
free(TMD_Buffer);
|
||||
return IOS_TYPE_NO_CIOS;
|
||||
}
|
||||
MEM2_free(info);
|
||||
free(info);
|
||||
|
||||
u8 base = 0;
|
||||
switch(slot)
|
||||
@ -187,7 +186,7 @@ int get_ios_type(u8 slot)
|
||||
else
|
||||
return IOS_TYPE_NO_CIOS;
|
||||
}
|
||||
MEM2_free(TMD_Buffer);
|
||||
free(TMD_Buffer);
|
||||
}
|
||||
|
||||
int is_ios_type(int type, u8 slot)
|
||||
|
@ -193,18 +193,19 @@ void __Disc_SetTime(void)
|
||||
|
||||
s32 Disc_FindPartition(u64 *outbuf)
|
||||
{
|
||||
u8 TMP_Buffer_size = 0x20;
|
||||
u64 offset = 0;
|
||||
u32 cnt;
|
||||
|
||||
u32 *TMP_Buffer = (u32*)MEM2_alloc(0x20);
|
||||
u32 *TMP_Buffer = (u32*)malloc(TMP_Buffer_size);
|
||||
if(!TMP_Buffer)
|
||||
return -1;
|
||||
|
||||
/* Read partition info */
|
||||
s32 ret = WDVD_UnencryptedRead(TMP_Buffer, 0x20, PTABLE_OFFSET);
|
||||
s32 ret = WDVD_UnencryptedRead(TMP_Buffer, TMP_Buffer_size, PTABLE_OFFSET);
|
||||
if(ret < 0)
|
||||
{
|
||||
MEM2_free(TMP_Buffer);
|
||||
free(TMP_Buffer);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -214,17 +215,17 @@ s32 Disc_FindPartition(u64 *outbuf)
|
||||
|
||||
if(nb_partitions > 8)
|
||||
{
|
||||
MEM2_free(TMP_Buffer);
|
||||
free(TMP_Buffer);
|
||||
return -1;
|
||||
}
|
||||
|
||||
memset(TMP_Buffer, 0, sizeof(TMP_Buffer));
|
||||
memset(TMP_Buffer, 0, TMP_Buffer_size);
|
||||
|
||||
/* Read partition table */
|
||||
ret = WDVD_UnencryptedRead(TMP_Buffer, 0x20, table_offset);
|
||||
ret = WDVD_UnencryptedRead(TMP_Buffer, TMP_Buffer_size, table_offset);
|
||||
if (ret < 0)
|
||||
{
|
||||
MEM2_free(TMP_Buffer);
|
||||
free(TMP_Buffer);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -237,7 +238,7 @@ s32 Disc_FindPartition(u64 *outbuf)
|
||||
if(!type)
|
||||
offset = TMP_Buffer[cnt * 2] << 2;
|
||||
}
|
||||
MEM2_free(TMP_Buffer);
|
||||
free(TMP_Buffer);
|
||||
|
||||
/* No game partition found */
|
||||
if (!offset)
|
||||
|
@ -169,9 +169,9 @@ int get_frag_list(u8 *id, char *path, const u32 hdd_sector_size)
|
||||
bool isWBFS = wbfs_part_fs != PART_FS_WBFS && strcasestr(strrchr(fname,'.'), ".wbfs") != 0;
|
||||
|
||||
struct stat st;
|
||||
FragList *fs = MEM2_alloc(sizeof(FragList));
|
||||
FragList *fa = MEM2_alloc(sizeof(FragList));
|
||||
FragList *fw = MEM2_alloc(sizeof(FragList));
|
||||
FragList *fs = malloc(sizeof(FragList));
|
||||
FragList *fa = malloc(sizeof(FragList));
|
||||
FragList *fw = malloc(sizeof(FragList));
|
||||
if(fs == NULL || fa == NULL || fw == NULL)
|
||||
goto out;
|
||||
|
||||
@ -241,7 +241,7 @@ int get_frag_list(u8 *id, char *path, const u32 hdd_sector_size)
|
||||
frag_concat(fa, fs);
|
||||
}
|
||||
|
||||
frag_list = MEM1_alloc(ALIGN32(sizeof(FragList)));
|
||||
frag_list = malloc(ALIGN32(sizeof(FragList)));
|
||||
if(frag_list == NULL)
|
||||
goto out;
|
||||
|
||||
@ -276,22 +276,22 @@ int get_frag_list(u8 *id, char *path, const u32 hdd_sector_size)
|
||||
out:
|
||||
if(ret_val && frag_list != NULL)
|
||||
{
|
||||
MEM1_free(frag_list);
|
||||
free(frag_list);
|
||||
frag_list = NULL;
|
||||
}
|
||||
if(fs != NULL)
|
||||
{
|
||||
MEM2_free(fs);
|
||||
free(fs);
|
||||
fs = NULL;
|
||||
}
|
||||
if(fa != NULL)
|
||||
{
|
||||
MEM2_free(fa);
|
||||
free(fa);
|
||||
fa = NULL;
|
||||
}
|
||||
if(fw != NULL)
|
||||
{
|
||||
MEM2_free(fw);
|
||||
free(fw);
|
||||
fw = NULL;
|
||||
}
|
||||
return ret_val;
|
||||
|
@ -3,32 +3,32 @@
|
||||
#include <ogc/isfs.h>
|
||||
#include <malloc.h>
|
||||
#include "utils.h"
|
||||
#include "mem2.hpp"
|
||||
#include "fs.h"
|
||||
|
||||
u8 *ISFS_GetFile(u8 *path, u32 *size, s32 length)
|
||||
{
|
||||
*size = 0;
|
||||
|
||||
s32 fd = ISFS_Open((const char *) path, ISFS_OPEN_READ);
|
||||
s32 fd = ISFS_Open((const char *)path, ISFS_OPEN_READ);
|
||||
u8 *buf = NULL;
|
||||
static fstats stats ATTRIBUTE_ALIGN(32);
|
||||
|
||||
if (fd >= 0)
|
||||
if(fd >= 0)
|
||||
{
|
||||
if (ISFS_GetFileStats(fd, &stats) >= 0)
|
||||
if(ISFS_GetFileStats(fd, &stats) >= 0)
|
||||
{
|
||||
if (length <= 0) length = stats.file_length;
|
||||
if (length > 0)
|
||||
buf = (u8 *)MEM2_alloc(ALIGN32(length));
|
||||
if(length <= 0)
|
||||
length = stats.file_length;
|
||||
if(length > 0)
|
||||
buf = (u8 *)memalign(32, ALIGN32(length));
|
||||
|
||||
if (buf)
|
||||
if(buf)
|
||||
{
|
||||
*size = stats.file_length;
|
||||
if (ISFS_Read(fd, (char*)buf, length) != length)
|
||||
if(ISFS_Read(fd, (char*)buf, length) != length)
|
||||
{
|
||||
*size = 0;
|
||||
MEM2_free(buf);
|
||||
free(buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ int app_gameconfig_load(u8 *discid, const u8 *gameconfig, u32 tempgameconfsize)
|
||||
|
||||
if (gameconf == NULL)
|
||||
{
|
||||
gameconf = MEM2_alloc(65536);
|
||||
gameconf = malloc(65536);
|
||||
if (gameconf == NULL)
|
||||
return -1;
|
||||
}
|
||||
@ -242,7 +242,7 @@ int app_gameconfig_load(u8 *discid, const u8 *gameconfig, u32 tempgameconfsize)
|
||||
if (i != tempgameconfsize) while ((tempgameconf[i] != 10 && tempgameconf[i] != 13) && (i != 0)) i--;
|
||||
}
|
||||
}
|
||||
MEM2_free(gameconf);
|
||||
free(gameconf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -443,7 +443,7 @@ int ocarina_do_code(u64 chantitle)
|
||||
{
|
||||
memcpy(codelist, code_buf, code_size);
|
||||
DCFlushRange(codelist, (u32)codelistend - (u32)codelist);
|
||||
MEM2_free(code_buf);
|
||||
free(code_buf);
|
||||
}
|
||||
|
||||
// TODO What's this???
|
||||
|
@ -39,6 +39,7 @@
|
||||
#include "gecko.h"
|
||||
#include "fileOps.h"
|
||||
#include "defines.h"
|
||||
#include "Gekko.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@ -46,7 +47,7 @@ static u8 *FSTable ALIGNED(32);
|
||||
|
||||
void GCDump::__AnalizeMultiDisc()
|
||||
{
|
||||
u8 *Buffer = (u8 *)MEM2_alloc(0x10);
|
||||
u8 *Buffer = (u8 *)malloc(0x10);
|
||||
if(Buffer == NULL)
|
||||
return;
|
||||
|
||||
@ -64,17 +65,18 @@ void GCDump::__AnalizeMultiDisc()
|
||||
}
|
||||
MultiGameCnt++;
|
||||
}
|
||||
MEM2_free(Buffer);
|
||||
free(Buffer);
|
||||
}
|
||||
|
||||
s32 GCDump::__DiscReadRaw(void *outbuf, u64 offset, u32 length)
|
||||
{
|
||||
wiiLightOn();
|
||||
wiiLightSetLevel(255);
|
||||
while(1)
|
||||
{
|
||||
*(u32*)0xCD0000C0 |= 0x20;
|
||||
gc_error = 0;
|
||||
s32 ret = WDVD_UnencryptedRead(outbuf, length, offset);
|
||||
if( ret != 0 )
|
||||
if(ret != 0)
|
||||
{
|
||||
WDVD_LowRequestError(&gc_error);
|
||||
if(gc_error == 0x30200 || gc_error == 0x30201 || gc_error == 0x31100)
|
||||
@ -91,17 +93,14 @@ s32 GCDump::__DiscReadRaw(void *outbuf, u64 offset, u32 length)
|
||||
}
|
||||
if(gc_retry >= gc_nbrretry)
|
||||
{
|
||||
wiiLightOff();
|
||||
if(!skiponerror)
|
||||
{
|
||||
*(u32*)0xCD0000C0 &= ~0x20;
|
||||
return gc_error;
|
||||
}
|
||||
else
|
||||
{
|
||||
gc_retry = 0;
|
||||
gc_skipped++;
|
||||
gprintf("Read error (%x) at offset: 0x%08x. Skipping %d bytes\n", gc_error, offset, length);
|
||||
*(u32*)0xCD0000C0 &= ~0x20;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@ -118,17 +117,18 @@ s32 GCDump::__DiscReadRaw(void *outbuf, u64 offset, u32 length)
|
||||
else
|
||||
{
|
||||
gprintf("Read error(%x) at offset: 0x%08x.\n", gc_error, offset);
|
||||
*(u32*)0xCD0000C0 &= ~0x20;
|
||||
wiiLightOff();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
*(u32*)0xCD0000C0 &= ~0x20;
|
||||
wiiLightOff();
|
||||
gc_retry = 0;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
wiiLightOff();
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -170,7 +170,7 @@ s32 GCDump::__DiscWriteFile(FILE *f, u64 offset, u32 length, u8 *ReadBuffer)
|
||||
|
||||
bool GCDump::__WaitForDisc(u8 dsc, u32 msg)
|
||||
{
|
||||
u8 *ReadBuffer = (u8 *)MEM2_alloc(0x440);
|
||||
u8 *ReadBuffer = (u8 *)malloc(0x440);
|
||||
if(ReadBuffer == NULL)
|
||||
return false;
|
||||
|
||||
@ -178,13 +178,14 @@ bool GCDump::__WaitForDisc(u8 dsc, u32 msg)
|
||||
bool done = false;
|
||||
while(!done)
|
||||
{
|
||||
message( msg, dsc+1, minfo, u_data);
|
||||
message(msg, dsc+1, minfo, u_data);
|
||||
while(1)
|
||||
{
|
||||
*(u32*)0xCD0000C0 |= 0x20;
|
||||
usleep( 1000000 );
|
||||
*(u32*)0xCD0000C0 &= ~0x20;
|
||||
usleep( 1000000 );
|
||||
wiiLightOn();
|
||||
wiiLightSetLevel(255);
|
||||
usleep(1000000);
|
||||
wiiLightOff();
|
||||
usleep(1000000);
|
||||
WDVD_GetCoverStatus(&cover);
|
||||
if(!(cover & 0x2))
|
||||
break;
|
||||
@ -192,16 +193,17 @@ bool GCDump::__WaitForDisc(u8 dsc, u32 msg)
|
||||
|
||||
while(1)
|
||||
{
|
||||
*(u32*)0xCD0000C0 |= 0x20;
|
||||
usleep( 1000000 );
|
||||
*(u32*)0xCD0000C0 &= ~0x20;
|
||||
usleep( 1000000 );
|
||||
wiiLightOn();
|
||||
wiiLightSetLevel(255);
|
||||
usleep(1000000);
|
||||
wiiLightOff();
|
||||
usleep(1000000);
|
||||
if(Disc_Wait() < 0)
|
||||
continue;
|
||||
|
||||
if(Disc_Open(true) < 0)
|
||||
{
|
||||
MEM2_free(ReadBuffer);
|
||||
free(ReadBuffer);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -210,7 +212,7 @@ bool GCDump::__WaitForDisc(u8 dsc, u32 msg)
|
||||
s32 ret = __DiscReadRaw(ReadBuffer, NextOffset, 0x440);
|
||||
if(ret > 0)
|
||||
{
|
||||
MEM2_free(ReadBuffer);
|
||||
free(ReadBuffer);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -250,7 +252,7 @@ bool GCDump::__WaitForDisc(u8 dsc, u32 msg)
|
||||
}
|
||||
}
|
||||
}
|
||||
MEM2_free(ReadBuffer);
|
||||
free(ReadBuffer);
|
||||
return done;
|
||||
}
|
||||
|
||||
@ -277,7 +279,7 @@ s32 GCDump::DumpGame()
|
||||
{
|
||||
static gc_discHdr gcheader ATTRIBUTE_ALIGN(32);
|
||||
|
||||
u8 *ReadBuffer = (u8 *)MEM2_alloc(gc_readsize);
|
||||
u8 *ReadBuffer = (u8 *)malloc(gc_readsize);
|
||||
if(ReadBuffer == NULL)
|
||||
return 0x31100;
|
||||
|
||||
@ -341,7 +343,7 @@ s32 GCDump::DumpGame()
|
||||
ret = __DiscReadRaw(ReadBuffer, NextOffset, 0x440);
|
||||
if(ret > 0)
|
||||
{
|
||||
MEM2_free(ReadBuffer);
|
||||
free(ReadBuffer);
|
||||
return 0x31100;
|
||||
}
|
||||
|
||||
@ -358,7 +360,7 @@ s32 GCDump::DumpGame()
|
||||
DOLSize = FSTOffset - DOLOffset;
|
||||
DiscSize = DataSize + GamePartOffset;
|
||||
|
||||
FSTBuffer = (u8 *)MEM2_alloc(ALIGN32(FSTSize));
|
||||
FSTBuffer = (u8 *)malloc(ALIGN32(FSTSize));
|
||||
if(FSTBuffer == NULL)
|
||||
return 0x31100;
|
||||
|
||||
@ -366,8 +368,8 @@ s32 GCDump::DumpGame()
|
||||
|
||||
if(ret > 0)
|
||||
{
|
||||
MEM2_free(FSTBuffer);
|
||||
MEM2_free(ReadBuffer);
|
||||
free(FSTBuffer);
|
||||
free(ReadBuffer);
|
||||
return 0x31100;
|
||||
}
|
||||
|
||||
@ -484,8 +486,8 @@ s32 GCDump::DumpGame()
|
||||
}
|
||||
else
|
||||
{
|
||||
MEM2_free(ReadBuffer);
|
||||
MEM2_free(FSTBuffer);
|
||||
free(ReadBuffer);
|
||||
free(FSTBuffer);
|
||||
fclose(f);
|
||||
return gc_error;
|
||||
}
|
||||
@ -504,13 +506,13 @@ s32 GCDump::DumpGame()
|
||||
ret = __DiscWrite(gamepath, NextOffset, DiscSize, ReadBuffer);
|
||||
if( ret < 0 )
|
||||
{
|
||||
MEM2_free(ReadBuffer);
|
||||
MEM2_free(FSTBuffer);
|
||||
free(ReadBuffer);
|
||||
free(FSTBuffer);
|
||||
return gc_error;
|
||||
}
|
||||
gprintf("Done!! Disc size: %d\n", DiscSize);
|
||||
}
|
||||
MEM2_free(FSTBuffer);
|
||||
free(FSTBuffer);
|
||||
|
||||
if((FSTTotal > FSTSize || __CheckMDHack(ID)) && !multigamedisc)
|
||||
{
|
||||
@ -541,7 +543,7 @@ s32 GCDump::DumpGame()
|
||||
gamedone = true;
|
||||
}
|
||||
|
||||
MEM2_free(ReadBuffer);
|
||||
free(ReadBuffer);
|
||||
|
||||
return gc_skipped;
|
||||
}
|
||||
@ -550,7 +552,7 @@ s32 GCDump::CheckSpace(u32 *needed, bool comp)
|
||||
{
|
||||
static gc_discHdr gcheader ATTRIBUTE_ALIGN(32);
|
||||
|
||||
u8 *ReadBuffer = (u8 *)MEM2_alloc(0x440);
|
||||
u8 *ReadBuffer = (u8 *)malloc(0x440);
|
||||
if(ReadBuffer == NULL)
|
||||
return 1;
|
||||
|
||||
@ -582,7 +584,7 @@ s32 GCDump::CheckSpace(u32 *needed, bool comp)
|
||||
s32 ret = __DiscReadRaw(ReadBuffer, NextOffset, 0x440);
|
||||
if(ret > 0)
|
||||
{
|
||||
MEM2_free(ReadBuffer);
|
||||
free(ReadBuffer);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -614,14 +616,14 @@ s32 GCDump::CheckSpace(u32 *needed, bool comp)
|
||||
}
|
||||
else
|
||||
{
|
||||
u8 *FSTBuffer = (u8 *)MEM2_alloc(ALIGN32(FSTSize));
|
||||
u8 *FSTBuffer = (u8 *)malloc(ALIGN32(FSTSize));
|
||||
if(FSTBuffer == NULL)
|
||||
return 1;
|
||||
|
||||
ret = __DiscReadRaw(FSTBuffer, FSTOffset+NextOffset, ALIGN32(FSTSize));
|
||||
if(ret > 0)
|
||||
{
|
||||
MEM2_free(FSTBuffer);
|
||||
free(FSTBuffer);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -657,7 +659,7 @@ s32 GCDump::CheckSpace(u32 *needed, bool comp)
|
||||
multisize += fst[i].FileLength;
|
||||
}
|
||||
}
|
||||
MEM2_free(FSTBuffer);
|
||||
free(FSTBuffer);
|
||||
}
|
||||
size += multisize;
|
||||
Gamesize[MultiGameDump] = multisize;
|
||||
@ -694,7 +696,7 @@ s32 GCDump::CheckSpace(u32 *needed, bool comp)
|
||||
else
|
||||
gamedone = true;
|
||||
}
|
||||
MEM2_free(ReadBuffer);
|
||||
free(ReadBuffer);
|
||||
DiscSizeCalculated = size/0x400;
|
||||
*needed = (size/0x8000) >> 2;
|
||||
gprintf("Free space needed: %d Mb (%d blocks)\n", size/0x100000, (size/0x8000) >> 2);
|
||||
|
@ -23,10 +23,10 @@
|
||||
* nk.c
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ogcsys.h>
|
||||
#include <string.h>
|
||||
#include <malloc.h>
|
||||
|
||||
#include "mem2.hpp"
|
||||
#include "nk.h"
|
||||
@ -58,13 +58,11 @@ s32 Launch_nk(u64 TitleID, const char *nandpath)
|
||||
DCFlushRange((void *)0x91000000, fsize);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
fclose(file);
|
||||
|
||||
memcfg *MC = (memcfg*)MEM1_alloc(sizeof(memcfg));
|
||||
memcfg *MC = (memcfg*)malloc(sizeof(memcfg));
|
||||
if(MC == NULL)
|
||||
return 0;
|
||||
|
||||
@ -81,7 +79,7 @@ s32 Launch_nk(u64 TitleID, const char *nandpath)
|
||||
|
||||
memcpy((void *)0x81200000, MC, sizeof(memcfg));
|
||||
DCFlushRange((void *)(0x81200000), sizeof(memcfg));
|
||||
MEM1_free(MC);
|
||||
free(MC);
|
||||
|
||||
/*** Thnx giantpune! ***/
|
||||
void *mini = MEM1_memalign(32, armboot_size);
|
||||
|
@ -67,7 +67,7 @@ s32 __WBFS_ReadDVD(void *fp, u32 lba, u32 len, void *iobuf)
|
||||
if (mod)
|
||||
{
|
||||
/* Allocate memory */
|
||||
fp = MEM2_alloc(0x20);
|
||||
fp = malloc(0x20);
|
||||
if (!fp)
|
||||
return -1;
|
||||
|
||||
@ -85,7 +85,7 @@ s32 __WBFS_ReadDVD(void *fp, u32 lba, u32 len, void *iobuf)
|
||||
|
||||
out:
|
||||
/* Free memory */
|
||||
MEM2_free(fp);
|
||||
free(fp);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ wbfs_disc_t* WBFS_Ext_OpenDisc(u8 *discid, char *fname)
|
||||
int fd = open(fname, O_RDONLY);
|
||||
if (fd == -1) return NULL;
|
||||
|
||||
wbfs_disc_t *iso_file = MEM2_alloc(sizeof(wbfs_disc_t));
|
||||
wbfs_disc_t *iso_file = malloc(sizeof(wbfs_disc_t));
|
||||
memset(iso_file, 0, sizeof(wbfs_disc_t));
|
||||
|
||||
if (iso_file == NULL)
|
||||
@ -81,7 +81,7 @@ void WBFS_Ext_CloseDisc(wbfs_disc_t* disc)
|
||||
if (part == &wbfs_iso_file)
|
||||
{
|
||||
close((int)disc->header);
|
||||
MEM2_free(disc);
|
||||
free(disc);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -78,7 +78,7 @@ void wip_reset_counter()
|
||||
void free_wip()
|
||||
{
|
||||
if(CodeList)
|
||||
MEM2_free(CodeList);
|
||||
free(CodeList);
|
||||
|
||||
CodesCount = 0;
|
||||
ProcessedLength = 0;
|
||||
@ -122,7 +122,7 @@ int load_wip_patches(u8 *dir, u8 *gameid)
|
||||
WIP_Code *tmp = MEM2_realloc(CodeList, (CodesCount+1)*sizeof(WIP_Code));
|
||||
if(!tmp)
|
||||
{
|
||||
MEM2_free(CodeList);
|
||||
free(CodeList);
|
||||
fclose(fp);
|
||||
return -1;
|
||||
}
|
||||
|
@ -74,11 +74,6 @@ void *MEM2_alloc(unsigned int s)
|
||||
return g_mem2gp.allocate(s);
|
||||
}
|
||||
|
||||
void *MEM2_memalign(unsigned int a, unsigned int s)
|
||||
{
|
||||
return g_mem2gp.allocate(ALIGN(a, s));
|
||||
}
|
||||
|
||||
void *MEM2_realloc(void *p, unsigned int s)
|
||||
{
|
||||
return g_mem2gp.reallocate(p, s);
|
||||
@ -138,15 +133,19 @@ void *__wrap_memalign(size_t a, size_t size)
|
||||
void *p;
|
||||
if(SYS_GetArena1Lo() >= MAX_MEM1_ARENA_LO || size >= MEM2_PRIORITY_SIZE)
|
||||
{
|
||||
p = MEM2_memalign(a, size);
|
||||
if (p != 0)
|
||||
return p;
|
||||
if(a <= 32 && 32 % a == 0)
|
||||
{
|
||||
p = g_mem2gp.allocate(size);
|
||||
if (p != 0)
|
||||
return p;
|
||||
}
|
||||
return __real_memalign(a, size);
|
||||
}
|
||||
p = __real_memalign(a, size);
|
||||
if(p != 0)
|
||||
if(p != 0 || a > 32 || 32 % a != 0)
|
||||
return p;
|
||||
return MEM2_memalign(a, size);
|
||||
|
||||
return g_mem2gp.allocate(size);
|
||||
}
|
||||
|
||||
void __wrap_free(void *p)
|
||||
|
@ -22,7 +22,6 @@ void MEM2_cleanup(void);
|
||||
void MEM2_clear(void);
|
||||
void MEM2_free(void *p);
|
||||
void *MEM2_alloc(unsigned int s);
|
||||
void *MEM2_memalign(unsigned int a, unsigned int s);
|
||||
void *MEM2_realloc(void *p, unsigned int s);
|
||||
unsigned int MEM2_usableSize(void *p);
|
||||
unsigned int MEM2_freesize();
|
||||
|
@ -145,7 +145,8 @@ CMenu::CMenu(CVideo &vid) :
|
||||
m_current_view = COVERFLOW_USB;
|
||||
m_Emulator_boot = false;
|
||||
m_banner = new BannerWindow;
|
||||
m_music = new MusicPlayer;
|
||||
m_music = new MusicPlayer; //Voice 0
|
||||
m_gameSound = new GuiSound; //Voice 1
|
||||
}
|
||||
|
||||
void CMenu::init(void)
|
||||
@ -1827,17 +1828,17 @@ void CMenu::_mainLoopCommon(bool withCF, bool blockReboot, bool adjusting)
|
||||
Sys_Test();
|
||||
}
|
||||
|
||||
if(withCF && m_gameSelected && m_gamesound_changed && (m_gameSoundHdr == NULL) && !m_gameSound.IsPlaying() && m_music->GetVolume() == 0)
|
||||
if(withCF && m_gameSelected && m_gamesound_changed && (m_gameSoundHdr == NULL) && !m_gameSound->IsPlaying() && m_music->GetVolume() == 0)
|
||||
{
|
||||
CheckGameSoundThread();
|
||||
m_gameSound.Play(m_bnrSndVol);
|
||||
m_gameSound->Play(m_bnrSndVol);
|
||||
m_gamesound_changed = false;
|
||||
}
|
||||
else if(!m_gameSelected)
|
||||
m_gameSound.Stop();
|
||||
m_gameSound->Stop();
|
||||
|
||||
m_music->Tick(m_video_playing || (m_gameSelected &&
|
||||
m_gameSound.IsLoaded()) || m_gameSound.IsPlaying());
|
||||
m_gameSound->IsLoaded()) || m_gameSound->IsPlaying());
|
||||
|
||||
//Take Screenshot
|
||||
if(gc_btnsPressed & PAD_TRIGGER_Z)
|
||||
@ -2258,11 +2259,11 @@ void CMenu::_stopSounds(void)
|
||||
|
||||
if(!m_music->IsStopped())
|
||||
{
|
||||
while(m_music->GetVolume() > 0 || m_gameSound.GetVolume() > 0)
|
||||
while(m_music->GetVolume() > 0 || m_gameSound->GetVolume() > 0)
|
||||
{
|
||||
m_music->Tick(true);
|
||||
if(m_gameSound.GetVolume() > 0)
|
||||
m_gameSound.SetVolume(m_gameSound.GetVolume() < fade_rate ? 0 : m_gameSound.GetVolume() - fade_rate);
|
||||
if(m_gameSound->GetVolume() > 0)
|
||||
m_gameSound->SetVolume(m_gameSound->GetVolume() < fade_rate ? 0 : m_gameSound->GetVolume() - fade_rate);
|
||||
VIDEO_WaitVSync();
|
||||
}
|
||||
}
|
||||
@ -2270,7 +2271,7 @@ void CMenu::_stopSounds(void)
|
||||
m_cf.stopSound();
|
||||
|
||||
m_music->Stop();
|
||||
m_gameSound.Stop();
|
||||
m_gameSound->Stop();
|
||||
}
|
||||
|
||||
bool CMenu::_loadFile(SmartBuf &buffer, u32 &size, const char *path, const char *file)
|
||||
@ -2379,7 +2380,7 @@ retry:
|
||||
memcpy(m_base_font.get(), font_file, size);
|
||||
if(!!m_base_font)
|
||||
m_base_font_size = size;
|
||||
MEM2_free(u8_font_archive);
|
||||
free(u8_font_archive);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -2400,7 +2401,7 @@ retry:
|
||||
m_wbf2_font = smartMem2Alloc(size);
|
||||
memcpy(m_wbf2_font.get(), font_file2, size);
|
||||
|
||||
MEM2_free(u8_font_archive);
|
||||
free(u8_font_archive);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2411,7 +2412,7 @@ retry:
|
||||
goto retry;
|
||||
}
|
||||
|
||||
MEM2_free(content);
|
||||
free(content);
|
||||
}
|
||||
|
||||
void CMenu::_cleanupDefaultFont()
|
||||
@ -2491,16 +2492,16 @@ int CMenu::MIOSisDML()
|
||||
if(*(vu32*)(appfile+j) == 0x4C697465)
|
||||
{
|
||||
gprintf("DIOS-MIOS Lite is installed as MIOS\n");
|
||||
MEM2_free(appfile);
|
||||
free(appfile);
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
gprintf("DIOS-MIOS is installed as MIOS\n");
|
||||
MEM2_free(appfile);
|
||||
free(appfile);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
MEM2_free(appfile);
|
||||
free(appfile);
|
||||
}
|
||||
gprintf("DIOS-MIOS (Lite) not found\n");
|
||||
return 0;
|
||||
|
@ -682,7 +682,7 @@ private:
|
||||
volatile float m_fileProgress;
|
||||
volatile bool m_thrdMessageAdded;
|
||||
volatile bool m_gameSelected;
|
||||
GuiSound m_gameSound;
|
||||
GuiSound *m_gameSound;
|
||||
SmartGuiSound m_cameraSound;
|
||||
dir_discHdr *m_gameSoundHdr;
|
||||
lwp_t m_gameSoundThread;
|
||||
|
@ -120,12 +120,13 @@ void CMenu::_textAbout(void)
|
||||
{
|
||||
fseek(f, 0, SEEK_END);
|
||||
u32 fsize = ftell(f);
|
||||
char *help = (char*)MEM2_alloc(fsize+1); //+1 for null character
|
||||
char *help = (char*)malloc(fsize + 1); //+1 for null character
|
||||
memset(help, 0, fsize + 1);
|
||||
fseek(f, 0, SEEK_SET);
|
||||
fread(help, 1, fsize, f);
|
||||
help[fsize] = '\0';
|
||||
help_text.fromUTF8(help);
|
||||
MEM2_free(help);
|
||||
free(help);
|
||||
fclose(f);
|
||||
}
|
||||
else
|
||||
@ -163,6 +164,6 @@ void CMenu::_textAbout(void)
|
||||
if(iosInfo != NULL)
|
||||
{
|
||||
m_btnMgr.setText(m_aboutLblIOS, wfmt(_fmt("ios", L"IOS%i base %i v%i"), mainIOS, iosInfo->baseios, iosInfo->version), true);
|
||||
MEM2_free(iosInfo);
|
||||
free(iosInfo);
|
||||
}
|
||||
}
|
||||
|
@ -404,7 +404,7 @@ bool CMenu::_isNetworkAvailable()
|
||||
if (buf && size > 4)
|
||||
{
|
||||
retval = buf[4] > 0; // There is a valid connection defined.
|
||||
MEM2_free(buf);
|
||||
free(buf);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
@ -426,13 +426,13 @@ void CMenu::_game(bool launch)
|
||||
m_banner->DeleteBanner();
|
||||
_CategorySettings(true);
|
||||
_showGame();
|
||||
if (!m_gameSound.IsPlaying())
|
||||
if (!m_gameSound->IsPlaying())
|
||||
startGameSound = -6;
|
||||
continue;
|
||||
}
|
||||
if(BTN_HOME_PRESSED || BTN_B_PRESSED)
|
||||
{
|
||||
m_gameSound.FreeMemory();
|
||||
m_gameSound->FreeMemory();
|
||||
CheckGameSoundThread();
|
||||
ClearGameSoundThreadStack();
|
||||
m_banner->DeleteBanner();
|
||||
@ -445,7 +445,7 @@ void CMenu::_game(bool launch)
|
||||
m_gameSelected = true;
|
||||
_gameinfo();
|
||||
_showGame();
|
||||
if (!m_gameSound.IsPlaying())
|
||||
if (!m_gameSound->IsPlaying())
|
||||
startGameSound = -6;
|
||||
}
|
||||
else if(BTN_MINUS_PRESSED)
|
||||
@ -476,7 +476,7 @@ void CMenu::_game(bool launch)
|
||||
_showGame();
|
||||
m_music->Play();
|
||||
m_video_playing = false;
|
||||
//m_gameSound.play(m_bnrSndVol);
|
||||
//m_gameSound->play(m_bnrSndVol);
|
||||
}
|
||||
}
|
||||
else if((BTN_1_PRESSED) || (BTN_2_PRESSED))
|
||||
@ -499,7 +499,7 @@ void CMenu::_game(bool launch)
|
||||
_hideGame();
|
||||
if(_wbfsOp(CMenu::WO_REMOVE_GAME))
|
||||
{
|
||||
m_gameSound.Stop();
|
||||
m_gameSound->Stop();
|
||||
CheckGameSoundThread();
|
||||
break;
|
||||
}
|
||||
@ -512,7 +512,7 @@ void CMenu::_game(bool launch)
|
||||
m_gcfg1.setBool("ADULTONLY", id, !m_gcfg1.getBool("ADULTONLY", id, false));
|
||||
else if(m_btnMgr.selected(m_gameBtnBack) || m_btnMgr.selected(m_gameBtnBackFull))
|
||||
{
|
||||
m_gameSound.FreeMemory();
|
||||
m_gameSound->FreeMemory();
|
||||
CheckGameSoundThread();
|
||||
ClearGameSoundThreadStack();
|
||||
m_banner->DeleteBanner();
|
||||
@ -534,7 +534,7 @@ void CMenu::_game(bool launch)
|
||||
m_banner->ToogleGameSettings();
|
||||
|
||||
_showGame();
|
||||
if(!m_gameSound.IsPlaying())
|
||||
if(!m_gameSound->IsPlaying())
|
||||
startGameSound = -6;
|
||||
}
|
||||
else if(launch || m_btnMgr.selected(m_gameBtnPlay) || m_btnMgr.selected(m_gameBtnPlayFull) || (!WPadIR_Valid(0) && !WPadIR_Valid(1) && !WPadIR_Valid(2) && !WPadIR_Valid(3) && m_btnMgr.selected((u16)-1)))
|
||||
@ -637,7 +637,7 @@ void CMenu::_game(bool launch)
|
||||
}
|
||||
if(startGameSound == -10)
|
||||
{
|
||||
m_gameSound.Stop();
|
||||
m_gameSound->Stop();
|
||||
m_gameSelected = false;
|
||||
m_fa.unload();
|
||||
m_banner->DeleteBanner(true);
|
||||
@ -824,31 +824,31 @@ void CMenu::_launchGC(dir_discHdr *hdr, bool disc)
|
||||
loader = 1;
|
||||
m_cfg.setString("DML", "current_item", id);
|
||||
char CheatPath[256];
|
||||
char NewCheatPath[255];
|
||||
u8 NMM = min((u32)m_gcfg2.getInt(id, "dml_nmm", 0), ARRAY_SIZE(CMenu::_NMM) - 1u);
|
||||
NMM = (NMM == 0) ? m_cfg.getInt("DML", "dml_nmm", 0) : NMM-1;
|
||||
u8 nodisc = min((u32)m_gcfg2.getInt(id, "no_disc_patch", 0), ARRAY_SIZE(CMenu::_NoDVD) - 1u);
|
||||
nodisc = (nodisc == 0) ? m_cfg.getInt("DML", "no_disc_patch", 0) : nodisc-1;
|
||||
bool cheats = m_gcfg2.testOptBool(id, "cheat", m_cfg.getBool("DML", "cheat", false));
|
||||
string NewCheatPath;
|
||||
bool DML_debug = m_gcfg2.getBool(id, "debugger", false);
|
||||
bool DM_Widescreen = m_gcfg2.getBool(id, "dm_widescreen", false);
|
||||
if(cheats)
|
||||
{
|
||||
snprintf(CheatPath, sizeof(CheatPath), "%s/%s", m_cheatDir.c_str(), fmt("%s.gct", id.c_str()));
|
||||
snprintf(NewCheatPath, sizeof(NewCheatPath), "%s/%s/%s", fmt(DML_DIR, DeviceName[currentPartition]), path.c_str(), fmt("%s.gct", id.c_str()));
|
||||
}
|
||||
string newPath;
|
||||
if(strcasestr(path.c_str(), "boot.bin") != NULL)
|
||||
{
|
||||
newPath = &path[path.find_first_of(":/")+1];
|
||||
newPath.erase(newPath.end() - 12, newPath.end());
|
||||
path.erase(path.end() - 12, path.end());
|
||||
NewCheatPath = sfmt("%s%s", path.c_str(), fmt("%s.gct", id.c_str()));
|
||||
}
|
||||
else
|
||||
newPath = &path[path.find_first_of(":/")+1];
|
||||
{
|
||||
NewCheatPath = sfmt("%s%s", path.c_str(), fmt("%s.gct", id.c_str()));
|
||||
path.erase(path.end() - 19, path.end() - 11);
|
||||
}
|
||||
if(cheats)
|
||||
snprintf(CheatPath, sizeof(CheatPath), "%s/%s", m_cheatDir.c_str(), fmt("%s.gct", id.c_str()));
|
||||
string newPath = &path[path.find_first_of(":/")+1];
|
||||
if(m_new_dml)
|
||||
DML_New_SetOptions(newPath.c_str(), CheatPath, NewCheatPath, DeviceName[currentPartition], cheats, DML_debug, NMM, nodisc, videoMode, videoSetting, DM_Widescreen, m_new_dm_cfg);
|
||||
DML_New_SetOptions(newPath.c_str(), CheatPath, NewCheatPath.c_str(), DeviceName[currentPartition], cheats, DML_debug, NMM, nodisc, videoMode, videoSetting, DM_Widescreen, m_new_dm_cfg);
|
||||
else
|
||||
DML_Old_SetOptions((char*)path.c_str(), CheatPath, NewCheatPath, cheats);
|
||||
DML_Old_SetOptions(newPath.c_str());
|
||||
|
||||
if(!nodisc || !m_new_dml)
|
||||
{
|
||||
@ -1193,10 +1193,10 @@ void CMenu::_launchGame(dir_discHdr *hdr, bool dvd)
|
||||
else
|
||||
{
|
||||
/* Read GC disc header */
|
||||
struct gc_discHdr *gcHeader = (struct gc_discHdr *)MEM2_alloc(sizeof(struct gc_discHdr));
|
||||
struct gc_discHdr *gcHeader = (struct gc_discHdr *)malloc(sizeof(struct gc_discHdr));
|
||||
Disc_ReadGCHeader(gcHeader);
|
||||
strncpy(hdr->id, (char*)gcHeader->id, 6);
|
||||
MEM2_free(gcHeader);
|
||||
free(gcHeader);
|
||||
/* Launching GC Game */
|
||||
_launchGC(hdr, true);
|
||||
}
|
||||
@ -1204,10 +1204,10 @@ void CMenu::_launchGame(dir_discHdr *hdr, bool dvd)
|
||||
else
|
||||
{
|
||||
/* Read header */
|
||||
struct discHdr *header = (struct discHdr *)MEM2_alloc(sizeof(struct discHdr));
|
||||
struct discHdr *header = (struct discHdr *)malloc(sizeof(struct discHdr));
|
||||
Disc_ReadHeader(header);
|
||||
id = string((const char*)header->id);
|
||||
MEM2_free(header);
|
||||
free(header);
|
||||
}
|
||||
gprintf("Game ID: %s\n", id.c_str());
|
||||
}
|
||||
@ -1518,10 +1518,11 @@ u32 gameSoundThreadStackSize = (u32)32768;
|
||||
void CMenu::_gameSoundThread(CMenu *m)
|
||||
{
|
||||
m->m_gameSoundHdr = m->m_cf.getHdr();
|
||||
|
||||
if(m->m_cf.getHdr()->type == TYPE_PLUGIN)
|
||||
{
|
||||
m_banner->DeleteBanner();
|
||||
m->m_gameSound.Load(m->m_plugin.GetBannerSound(m->m_cf.getHdr()->settings[0]), m->m_plugin.GetBannerSoundSize(), false);
|
||||
m->m_gameSound->Load(m->m_plugin.GetBannerSound(m->m_cf.getHdr()->settings[0]), m->m_plugin.GetBannerSoundSize(), false);
|
||||
m->m_gamesound_changed = true;
|
||||
m->m_gameSoundHdr = NULL;
|
||||
return;
|
||||
@ -1547,7 +1548,13 @@ void CMenu::_gameSoundThread(CMenu *m)
|
||||
fseek(fp, 0, SEEK_END);
|
||||
cached_bnr_size = ftell(fp);
|
||||
fseek(fp, 0, SEEK_SET);
|
||||
cached_bnr_file = (u8*)MEM2_alloc(cached_bnr_size);
|
||||
cached_bnr_file = (u8*)malloc(cached_bnr_size);
|
||||
if(cached_bnr_file == NULL)
|
||||
{
|
||||
m_banner->DeleteBanner();
|
||||
m->m_gameSoundHdr = NULL;
|
||||
return;
|
||||
}
|
||||
fread(cached_bnr_file, 1, cached_bnr_size, fp);
|
||||
fclose(fp);
|
||||
}
|
||||
@ -1567,64 +1574,79 @@ void CMenu::_gameSoundThread(CMenu *m)
|
||||
u8 *opening_bnr = disc.GetGameCubeBanner();
|
||||
if(opening_bnr != NULL)
|
||||
m_banner->CreateGCBanner(opening_bnr, &m->m_vid, m_wbf1_font.get(), m_wbf2_font.get(), m->m_cf.getHdr()->title);
|
||||
m->m_gameSound.Load(gc_ogg, gc_ogg_size, false);
|
||||
m->m_gameSound->Load(gc_ogg, gc_ogg_size, false);
|
||||
m->m_gamesound_changed = true;
|
||||
disc.clear();
|
||||
m->m_gameSoundHdr = NULL;
|
||||
disc.clear();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(fp)
|
||||
{
|
||||
custom = true;
|
||||
gprintf("Custom Banner detected for: %s\n", m->m_cf.getHdr()->id);
|
||||
fseek(fp, 0, SEEK_END);
|
||||
custom_bnr_size = ftell(fp);
|
||||
fseek(fp, 0, SEEK_SET);
|
||||
custom_bnr_file = (u8*)MEM2_alloc(custom_bnr_size);
|
||||
custom_bnr_file = (u8*)malloc(custom_bnr_size);
|
||||
if(custom_bnr_file == NULL)
|
||||
{
|
||||
m_banner->DeleteBanner();
|
||||
m->m_gameSoundHdr = NULL;
|
||||
return;
|
||||
}
|
||||
fread(custom_bnr_file, 1, custom_bnr_size, fp);
|
||||
fclose(fp);
|
||||
}
|
||||
}
|
||||
m->m_gamesound_changed = false;
|
||||
u32 sndSize = 0;
|
||||
u8 *soundBin = NULL;
|
||||
|
||||
Banner *banner = cached ? new Banner((u8 *)cached_bnr_file, cached_bnr_size) :
|
||||
Banner *banner = cached ? new Banner(cached_bnr_file, cached_bnr_size) :
|
||||
(custom ? new Banner((u8 *)custom_bnr_file, custom_bnr_size, 0, true) :
|
||||
(m->m_gameSoundHdr->type == TYPE_WII_GAME ? _extractBnr(m->m_gameSoundHdr) : (m->m_gameSoundHdr->type == TYPE_CHANNEL ?
|
||||
_extractChannelBnr(TITLE_ID(m->m_gameSoundHdr->settings[0],m->m_gameSoundHdr->settings[1])) : NULL)));
|
||||
|
||||
if (banner == NULL || !banner->IsValid())
|
||||
if(banner != NULL && banner->IsValid())
|
||||
{
|
||||
m_banner->LoadBanner(banner, &m->m_vid, m_wbf1_font.get(), m_wbf2_font.get());
|
||||
soundBin = banner->GetFile((char *)"sound.bin", &sndSize);
|
||||
}
|
||||
if(banner == NULL || soundBin == NULL || sndSize == 0)
|
||||
{
|
||||
gprintf("no valid banner found\n");
|
||||
m_banner->DeleteBanner();
|
||||
delete banner;
|
||||
m->m_gameSoundHdr = NULL;
|
||||
delete banner;
|
||||
return;
|
||||
}
|
||||
else if(!custom && !cached)
|
||||
if(!custom && !cached)
|
||||
{
|
||||
FILE *fp = fopen(cached_banner, "wb");
|
||||
fwrite(banner->GetBannerFile(), 1, banner->GetBannerFileSize(), fp);
|
||||
fclose(fp);
|
||||
}
|
||||
_extractBannerTitle(banner, GetLanguage(m->m_loc.getString(m->m_curLanguage, "gametdb_code", "EN").c_str()));
|
||||
|
||||
const u8 *soundBin = banner->GetFile((char *) "sound.bin", &sndSize);
|
||||
m_banner->LoadBanner(banner, &m->m_vid, m_wbf1_font.get(), m_wbf2_font.get());
|
||||
delete banner;
|
||||
|
||||
if (soundBin == NULL || (((IMD5Header *)soundBin)->fcc != 'IMD5' && ((IMD5Header *)soundBin)->fcc != 'RIFF'))
|
||||
if(((IMD5Header *)soundBin)->fcc == 'IMD5')
|
||||
{
|
||||
gprintf("Failed to load banner sound!\n\n");
|
||||
if(soundBin != NULL)
|
||||
delete soundBin;
|
||||
m->m_gameSoundHdr = NULL;
|
||||
return;
|
||||
u32 newSize = 0;
|
||||
u8 *newSound = DecompressCopy(soundBin, sndSize, &newSize);
|
||||
if(newSound == NULL || newSize == 0 || !m->m_gameSound->Load(newSound, newSize))
|
||||
{
|
||||
if(newSound != NULL)
|
||||
free(newSound);
|
||||
m_banner->DeleteBanner();
|
||||
m->m_gameSoundHdr = NULL;
|
||||
return;
|
||||
}
|
||||
free(soundBin);
|
||||
}
|
||||
else
|
||||
m->m_gameSound->Load(soundBin, sndSize);
|
||||
|
||||
m->m_gameSound.Load(soundBin, sndSize, false);
|
||||
m->m_gamesound_changed = true;
|
||||
if(m->m_gameSound->IsLoaded())
|
||||
m->m_gamesound_changed = true;
|
||||
else
|
||||
m_banner->DeleteBanner();
|
||||
m->m_gameSoundHdr = NULL;
|
||||
}
|
||||
|
||||
@ -1638,17 +1660,20 @@ void CMenu::_playGameSound(void)
|
||||
CheckGameSoundThread();
|
||||
if(!gameSoundThreadStack.get())
|
||||
gameSoundThreadStack = smartMem2Alloc(gameSoundThreadStackSize);
|
||||
|
||||
LWP_CreateThread(&m_gameSoundThread, (void *(*)(void *))CMenu::_gameSoundThread, (void *)this, gameSoundThreadStack.get(), gameSoundThreadStackSize, 60);
|
||||
}
|
||||
|
||||
void CMenu::CheckGameSoundThread()
|
||||
{
|
||||
if(m_gameSoundThread == LWP_THREAD_NULL)
|
||||
return;
|
||||
|
||||
if(LWP_ThreadIsSuspended(m_gameSoundThread))
|
||||
LWP_ResumeThread(m_gameSoundThread);
|
||||
|
||||
while(m_gameSoundHdr != NULL)
|
||||
usleep(50);
|
||||
|
||||
LWP_JoinThread(m_gameSoundThread, NULL);
|
||||
m_gameSoundThread = LWP_THREAD_NULL;
|
||||
}
|
||||
|
@ -23,14 +23,14 @@
|
||||
*
|
||||
* for WiiXplorer 2010
|
||||
***************************************************************************/
|
||||
|
||||
#include <malloc.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "mem2.hpp"
|
||||
#include "BNSDecoder.hpp"
|
||||
|
||||
SoundBlock DecodefromBNS(const u8 *buffer, u32 size);
|
||||
|
||||
BNSDecoder::BNSDecoder(const char * filepath)
|
||||
: SoundDecoder(filepath)
|
||||
{
|
||||
@ -61,12 +61,15 @@ BNSDecoder::~BNSDecoder()
|
||||
while(Decoding)
|
||||
usleep(100);
|
||||
|
||||
MEM2_free(SoundData.buffer);
|
||||
if(SoundData.buffer != NULL)
|
||||
free(SoundData.buffer);
|
||||
|
||||
SoundData.buffer = NULL;
|
||||
}
|
||||
|
||||
void BNSDecoder::OpenFile()
|
||||
{
|
||||
u8 *tempbuff = new (std::nothrow) u8[file_fd->size()];
|
||||
u8 * tempbuff = new (std::nothrow) u8[file_fd->size()];
|
||||
if(!tempbuff)
|
||||
{
|
||||
CloseFile();
|
||||
@ -77,7 +80,7 @@ void BNSDecoder::OpenFile()
|
||||
|
||||
while(done < file_fd->size())
|
||||
{
|
||||
int read = file_fd->read(tempbuff, file_fd->size());
|
||||
int read = file_fd->read(tempbuff+done, file_fd->size()-done);
|
||||
if(read > 0)
|
||||
done += read;
|
||||
else
|
||||
@ -264,7 +267,7 @@ static u8 * decodeBNS(u32 &size, const BNSInfo &bnsInfo, const BNSData &bnsData)
|
||||
int numBlocks = (bnsData.size - 8) / 8;
|
||||
int numSamples = numBlocks * 14;
|
||||
const BNSADPCMBlock *inputBuf = (const BNSADPCMBlock *)&bnsData.data;
|
||||
u8 * buffer = (u8 *)MEM2_alloc(numSamples * sizeof (s16));
|
||||
u8 * buffer = (u8 *) malloc(numSamples * sizeof (s16));
|
||||
s16 *outputBuf;
|
||||
|
||||
if (!buffer)
|
||||
@ -321,7 +324,7 @@ SoundBlock DecodefromBNS(const u8 *buffer, u32 size)
|
||||
// Check sizes
|
||||
if (size < hdr.size || size < hdr.infoOffset + hdr.infoSize || size < hdr.dataOffset + hdr.dataSize
|
||||
|| hdr.infoSize < 0x60 || hdr.dataSize < sizeof dataChunk
|
||||
|| infoChunk.size != hdr.infoSize || dataChunk.size != hdr.dataSize)
|
||||
|| infoChunk.size != hdr.infoSize || dataChunk.size > hdr.dataSize)
|
||||
return OutBlock;
|
||||
// Check format
|
||||
if (infoChunk.codecNum != 0) // Only codec i've found : 0 = ADPCM. Maybe there's also 1 and 2 for PCM 8 or 16 bits ?
|
||||
@ -344,7 +347,7 @@ SoundBlock DecodefromBNS(const u8 *buffer, u32 size)
|
||||
}
|
||||
else
|
||||
{
|
||||
OutBlock.buffer = (u8*)MEM2_alloc(dataChunk.size);
|
||||
OutBlock.buffer = (u8*) malloc(dataChunk.size);
|
||||
if (!OutBlock.buffer)
|
||||
return OutBlock;
|
||||
memcpy(OutBlock.buffer, &dataChunk.data, dataChunk.size);
|
||||
|
@ -30,7 +30,7 @@
|
||||
|
||||
typedef struct _SoundBlock
|
||||
{
|
||||
u8 *buffer;
|
||||
u8 * buffer;
|
||||
u32 size;
|
||||
u8 format;
|
||||
u32 frequency;
|
||||
@ -44,7 +44,7 @@ class BNSDecoder : public SoundDecoder
|
||||
public:
|
||||
BNSDecoder(const char * filepath);
|
||||
BNSDecoder(const u8 * snd, int len);
|
||||
~BNSDecoder();
|
||||
virtual ~BNSDecoder();
|
||||
int GetFormat() { return SoundData.format; };
|
||||
int GetSampleRate() { return SoundData.frequency; };
|
||||
int Read(u8 * buffer, int buffer_size, int pos);
|
||||
@ -54,6 +54,4 @@ protected:
|
||||
SoundBlock SoundData;
|
||||
};
|
||||
|
||||
SoundBlock DecodefromBNS(const u8 *buffer, u32 size);
|
||||
|
||||
#endif
|
||||
|
@ -23,7 +23,8 @@
|
||||
*
|
||||
* for WiiXplorer 2010
|
||||
***************************************************************************/
|
||||
#include "mem2.hpp"
|
||||
#include <malloc.h>
|
||||
|
||||
#include "BufferCircle.hpp"
|
||||
#include "utils.h"
|
||||
|
||||
@ -51,10 +52,10 @@ void BufferCircle::SetBufferBlockSize(int size)
|
||||
for(int i = 0; i < Size(); i++)
|
||||
{
|
||||
if(SoundBuffer[i] != NULL)
|
||||
MEM2_free(SoundBuffer[i]);
|
||||
free(SoundBuffer[i]);
|
||||
|
||||
SoundBuffer[i] = (u8 *)MEM2_memalign(32, BufferBlockSize);
|
||||
memset(SoundBuffer[i], 0, sizeof(SoundBuffer[i]));
|
||||
SoundBuffer[i] = (u8 *)malloc(BufferBlockSize);
|
||||
memset(SoundBuffer[i], 0, BufferBlockSize);
|
||||
BufferSize[i] = 0;
|
||||
BufferReady[i] = false;
|
||||
}
|
||||
@ -75,8 +76,8 @@ void BufferCircle::Resize(int size)
|
||||
{
|
||||
if(BufferBlockSize > 0)
|
||||
{
|
||||
SoundBuffer[i] = (u8 *)MEM2_memalign(32, BufferBlockSize);
|
||||
memset(SoundBuffer[i], 0, sizeof(SoundBuffer[i]));
|
||||
SoundBuffer[i] = (u8 *)malloc(BufferBlockSize);
|
||||
memset(SoundBuffer[i], 0, BufferBlockSize);
|
||||
}
|
||||
else
|
||||
SoundBuffer[i] = NULL;
|
||||
@ -91,7 +92,7 @@ void BufferCircle::RemoveBuffer(int pos)
|
||||
return;
|
||||
|
||||
if(SoundBuffer[pos] != NULL)
|
||||
MEM2_free(SoundBuffer[pos]);
|
||||
free(SoundBuffer[pos]);
|
||||
|
||||
SoundBuffer.erase(SoundBuffer.begin()+pos);
|
||||
BufferSize.erase(BufferSize.begin()+pos);
|
||||
@ -113,7 +114,7 @@ void BufferCircle::FreeBuffer()
|
||||
for(int i = 0; i < Size(); i++)
|
||||
{
|
||||
if(SoundBuffer[i] != NULL)
|
||||
MEM2_free(SoundBuffer[i]);
|
||||
free(SoundBuffer[i]);
|
||||
BufferSize[i] = 0;
|
||||
BufferReady[i] = false;
|
||||
}
|
||||
|
@ -28,9 +28,9 @@
|
||||
#include <limits.h>
|
||||
#include <unistd.h>
|
||||
#include <math.h>
|
||||
#include <malloc.h>
|
||||
|
||||
#include "Mp3Decoder.hpp"
|
||||
#include "mem2.hpp"
|
||||
|
||||
Mp3Decoder::Mp3Decoder(const char * filepath)
|
||||
: SoundDecoder(filepath)
|
||||
@ -74,13 +74,13 @@ Mp3Decoder::~Mp3Decoder()
|
||||
mad_frame_finish(&Frame);
|
||||
mad_stream_finish(&Stream);
|
||||
|
||||
MEM2_free(ReadBuffer);
|
||||
free(ReadBuffer);
|
||||
}
|
||||
|
||||
void Mp3Decoder::OpenFile()
|
||||
{
|
||||
GuardPtr = NULL;
|
||||
ReadBuffer = (u8 *)MEM2_alloc(SoundBlockSize * SoundBlocks);
|
||||
ReadBuffer = (u8 *)malloc(SoundBlockSize * SoundBlocks);
|
||||
if(!ReadBuffer)
|
||||
{
|
||||
if(file_fd)
|
||||
|
@ -24,15 +24,15 @@
|
||||
* for WiiXplorer 2010
|
||||
***************************************************************************/
|
||||
#include <unistd.h>
|
||||
#include <malloc.h>
|
||||
|
||||
#include "SoundHandler.hpp"
|
||||
#include "Mp3Decoder.hpp"
|
||||
#include "OggDecoder.hpp"
|
||||
#include "WavDecoder.hpp"
|
||||
#include "AifDecoder.hpp"
|
||||
#include "BNSDecoder.hpp"
|
||||
|
||||
#include "gecko/gecko.h"
|
||||
#include "mem2.hpp"
|
||||
|
||||
SoundHandler * SoundHandler::instance = NULL;
|
||||
|
||||
@ -43,11 +43,11 @@ SoundHandler::SoundHandler()
|
||||
for(u32 i = 0; i < MAX_DECODERS; ++i)
|
||||
DecoderList[i] = NULL;
|
||||
|
||||
ThreadStack = (u8 *)MEM2_memalign(32, 32768);
|
||||
ThreadStack = (u8 *)memalign(32, 32768);
|
||||
if(!ThreadStack)
|
||||
return;
|
||||
|
||||
LWP_CreateThread(&SoundThread, UpdateThread, this, ThreadStack, 32768, 80);
|
||||
LWP_CreateThread(&SoundThread, UpdateThread, this, ThreadStack, 32768, LWP_PRIO_HIGHEST);
|
||||
gprintf("SHND: Running sound thread\n");
|
||||
}
|
||||
|
||||
@ -61,7 +61,7 @@ SoundHandler::~SoundHandler()
|
||||
SoundThread = LWP_THREAD_NULL;
|
||||
if(ThreadStack != NULL)
|
||||
{
|
||||
MEM2_free(ThreadStack);
|
||||
free(ThreadStack);
|
||||
ThreadStack = NULL;
|
||||
}
|
||||
|
||||
@ -99,13 +99,19 @@ void SoundHandler::AddDecoder(int voice, const char * filepath)
|
||||
void SoundHandler::AddDecoder(int voice, const u8 * snd, int len)
|
||||
{
|
||||
if(voice < 0 || voice >= MAX_DECODERS)
|
||||
{
|
||||
gprintf("SoundHandler: Invalid voice!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (snd == NULL || len == 0)
|
||||
if(snd == NULL || len == 0)
|
||||
{
|
||||
gprintf("SoundHandler: Invalid sound!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if(DecoderList[voice] != NULL)
|
||||
RemoveDecoder(voice);
|
||||
RemoveDecoder(voice);
|
||||
|
||||
DecoderList[voice] = GetSoundDecoder(snd, len);
|
||||
}
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "musicplayer.h"
|
||||
#include "WavDecoder.hpp"
|
||||
#include "loader/sys.h"
|
||||
#include "banner/AnimatedBanner.h"
|
||||
|
||||
#define MAX_SND_VOICES 16
|
||||
|
||||
@ -37,19 +38,19 @@ using namespace std;
|
||||
|
||||
static bool VoiceUsed[MAX_SND_VOICES] =
|
||||
{
|
||||
true, false, false, false, false, false,
|
||||
false, false, false, false, false, false,
|
||||
false, false, false, false, false, false,
|
||||
false, false, false, false
|
||||
};
|
||||
|
||||
static inline int GetFirstUnusedVoice()
|
||||
{
|
||||
for(int i = 1; i < MAX_SND_VOICES; i++)
|
||||
for(u8 i = 0; i < MAX_SND_VOICES; i++)
|
||||
{
|
||||
if(VoiceUsed[i] == false)
|
||||
return i;
|
||||
}
|
||||
gprintf("ALL VOICES USED UP!!\n");
|
||||
gprintf("gui_sound.cpp: ALL VOICES USED UP!!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -75,20 +76,20 @@ extern "C" void SoundCallback(s32 voice)
|
||||
|
||||
GuiSound::GuiSound()
|
||||
{
|
||||
voice = -1;
|
||||
this->voice = -1;
|
||||
Init();
|
||||
}
|
||||
|
||||
GuiSound::GuiSound(string filepath, int v)
|
||||
{
|
||||
voice = v;
|
||||
this->voice = v;
|
||||
Init();
|
||||
Load(filepath.c_str());
|
||||
}
|
||||
|
||||
GuiSound::GuiSound(const u8 * snd, u32 len, string name, bool isallocated, int v)
|
||||
{
|
||||
voice = v;
|
||||
this->voice = v;
|
||||
Init();
|
||||
Load(snd, len, isallocated);
|
||||
this->filepath = name;
|
||||
@ -96,7 +97,7 @@ GuiSound::GuiSound(const u8 * snd, u32 len, string name, bool isallocated, int v
|
||||
|
||||
GuiSound::GuiSound(GuiSound *g)
|
||||
{
|
||||
voice = -1;
|
||||
this->voice = -1;
|
||||
|
||||
Init();
|
||||
if(g == NULL)
|
||||
@ -104,7 +105,7 @@ GuiSound::GuiSound(GuiSound *g)
|
||||
|
||||
if(g->sound != NULL)
|
||||
{
|
||||
u8 *snd = (u8 *) malloc(g->length);
|
||||
u8 *snd = (u8 *)malloc(g->length);
|
||||
memcpy(snd, g->sound, g->length);
|
||||
Load(snd, g->length, true);
|
||||
}
|
||||
@ -115,7 +116,7 @@ GuiSound::GuiSound(GuiSound *g)
|
||||
GuiSound::~GuiSound()
|
||||
{
|
||||
FreeMemory();
|
||||
VoiceUsed[voice] = false;
|
||||
VoiceUsed[this->voice] = false;
|
||||
}
|
||||
|
||||
void GuiSound::Init()
|
||||
@ -123,10 +124,10 @@ void GuiSound::Init()
|
||||
sound = NULL;
|
||||
length = 0;
|
||||
|
||||
if (voice == -1)
|
||||
voice = GetFirstUnusedVoice();
|
||||
if(voice > 0)
|
||||
VoiceUsed[voice] = true;
|
||||
if(this->voice == -1)
|
||||
this->voice = GetFirstUnusedVoice();
|
||||
if(this->voice != -1)
|
||||
VoiceUsed[this->voice] = true;
|
||||
|
||||
volume = 255;
|
||||
SoundEffectLength = 0;
|
||||
@ -139,14 +140,12 @@ void GuiSound::FreeMemory()
|
||||
Stop();
|
||||
|
||||
// Prevent reinitialization of SoundHandler since we're exiting
|
||||
if (!Sys_Exiting())
|
||||
SoundHandler::Instance()->RemoveDecoder(voice);
|
||||
if(!Sys_Exiting())
|
||||
SoundHandler::Instance()->RemoveDecoder(this->voice);
|
||||
|
||||
if(allocated)
|
||||
{
|
||||
if(allocated && sound != NULL)
|
||||
free(sound);
|
||||
allocated = false;
|
||||
}
|
||||
allocated = false;
|
||||
sound = NULL;
|
||||
length = 0;
|
||||
filepath = "";
|
||||
@ -164,7 +163,7 @@ bool GuiSound::Load(const char * filepath)
|
||||
FILE * f = fopen(filepath, "rb");
|
||||
if(!f)
|
||||
{
|
||||
gprintf("Failed to load file %s!!\n", filepath);
|
||||
gprintf("gui_sound.cpp: Failed to load file %s!!\n", filepath);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -172,19 +171,19 @@ bool GuiSound::Load(const char * filepath)
|
||||
fread(&magic, 1, 4, f);
|
||||
fclose(f);
|
||||
|
||||
SoundHandler::Instance()->AddDecoder(voice, filepath);
|
||||
gprintf("Loading %s using voice %d\n", filepath, voice);
|
||||
SoundDecoder * decoder = SoundHandler::Instance()->Decoder(voice);
|
||||
SoundHandler::Instance()->AddDecoder(this->voice, filepath);
|
||||
gprintf("gui_sound.cpp: Loading %s using voice %d\n", filepath, this->voice);
|
||||
SoundDecoder * decoder = SoundHandler::Instance()->Decoder(this->voice);
|
||||
if(!decoder)
|
||||
{
|
||||
gprintf("No Decoder!!!\n");
|
||||
gprintf("gui_sound.cpp: No Decoder!\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!decoder->IsBufferReady())
|
||||
{
|
||||
gprintf("Buffer not ready!!\n");
|
||||
SoundHandler::Instance()->RemoveDecoder(voice);
|
||||
gprintf("gui_sound.cpp: Buffer not ready!\n");
|
||||
SoundHandler::Instance()->RemoveDecoder(this->voice);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -197,7 +196,6 @@ bool GuiSound::Load(const char * filepath)
|
||||
bool GuiSound::Load(const u8 * snd, u32 len, bool isallocated)
|
||||
{
|
||||
FreeMemory();
|
||||
this->voice = voice;
|
||||
|
||||
if(!snd)
|
||||
return false;
|
||||
@ -205,24 +203,15 @@ bool GuiSound::Load(const u8 * snd, u32 len, bool isallocated)
|
||||
if(!isallocated && *((u32 *) snd) == 'RIFF')
|
||||
return LoadSoundEffect(snd, len);
|
||||
|
||||
if(*((u32 *) snd) == 'IMD5')
|
||||
UncompressSoundbin(snd, len, isallocated);
|
||||
else
|
||||
{
|
||||
sound = (u8 *) snd;
|
||||
length = len;
|
||||
allocated = isallocated;
|
||||
}
|
||||
sound = (u8*)snd;
|
||||
length = len;
|
||||
allocated = isallocated;
|
||||
|
||||
SoundHandler::Instance()->AddDecoder(this->voice, sound, length);
|
||||
|
||||
SoundDecoder * decoder = SoundHandler::Instance()->Decoder(voice);
|
||||
if(!decoder)
|
||||
return false;
|
||||
|
||||
if(!decoder->IsBufferReady())
|
||||
SoundDecoder *decoder = SoundHandler::Instance()->Decoder(this->voice);
|
||||
if(!decoder || !decoder->IsBufferReady())
|
||||
{
|
||||
SoundHandler::Instance()->RemoveDecoder(voice);
|
||||
SoundHandler::Instance()->RemoveDecoder(this->voice);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -271,19 +260,19 @@ void GuiSound::Play(int vol, bool restart)
|
||||
{
|
||||
if(SoundEffectLength > 0)
|
||||
{
|
||||
ASND_StopVoice(voice);
|
||||
ASND_SetVoice(voice, VOICE_MONO_16BIT, 22050, 0, sound, SoundEffectLength, vol, vol, NULL);
|
||||
ASND_StopVoice(this->voice);
|
||||
ASND_SetVoice(this->voice, VOICE_MONO_16BIT, 22050, 0, sound, SoundEffectLength, vol, vol, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
if((IsPlaying() && !restart) || voice < 0 || voice >= 16)
|
||||
if((IsPlaying() && !restart) || this->voice < 0 || this->voice >= 16)
|
||||
return;
|
||||
|
||||
SoundDecoder *decoder = SoundHandler::Instance()->Decoder(voice);
|
||||
SoundDecoder *decoder = SoundHandler::Instance()->Decoder(this->voice);
|
||||
if(!decoder)
|
||||
return;
|
||||
|
||||
ASND_StopVoice(voice);
|
||||
ASND_StopVoice(this->voice);
|
||||
if(decoder->IsEOF())
|
||||
{
|
||||
decoder->ClearBuffer();
|
||||
@ -296,7 +285,7 @@ void GuiSound::Play(int vol, bool restart)
|
||||
decoder->LoadNext();
|
||||
SoundHandler::Instance()->ThreadSignal();
|
||||
|
||||
ASND_SetVoice(voice, decoder->GetFormat(), decoder->GetSampleRate(), 0, curbuffer, bufsize, vol, vol, SoundCallback);
|
||||
ASND_SetVoice(this->voice, decoder->GetFormat(), decoder->GetSampleRate(), 0, curbuffer, bufsize, vol, vol, SoundCallback);
|
||||
}
|
||||
|
||||
void GuiSound::Play()
|
||||
@ -307,12 +296,12 @@ void GuiSound::Play()
|
||||
void GuiSound::Stop()
|
||||
{
|
||||
volume = 0;
|
||||
if(!IsPlaying() || voice < 0 || voice >= 16)
|
||||
if(!IsPlaying() || this->voice < 0 || this->voice >= 16)
|
||||
return;
|
||||
|
||||
ASND_StopVoice(voice);
|
||||
ASND_StopVoice(this->voice);
|
||||
|
||||
SoundDecoder *decoder = SoundHandler::Instance()->Decoder(voice);
|
||||
SoundDecoder *decoder = SoundHandler::Instance()->Decoder(this->voice);
|
||||
if(!decoder)
|
||||
return;
|
||||
|
||||
@ -324,10 +313,10 @@ void GuiSound::Stop()
|
||||
|
||||
void GuiSound::Pause()
|
||||
{
|
||||
if(voice < 0 || voice >= 16)
|
||||
if(this->voice < 0 || this->voice >= 16)
|
||||
return;
|
||||
|
||||
ASND_StopVoice(voice);
|
||||
ASND_StopVoice(this->voice);
|
||||
}
|
||||
|
||||
void GuiSound::Resume()
|
||||
@ -337,10 +326,10 @@ void GuiSound::Resume()
|
||||
|
||||
bool GuiSound::IsPlaying()
|
||||
{
|
||||
if(voice < 0 || voice >= 16)
|
||||
if(this->voice < 0 || this->voice >= 16)
|
||||
return false;
|
||||
|
||||
int result = ASND_StatusVoice(voice);
|
||||
int result = ASND_StatusVoice(this->voice);
|
||||
|
||||
if(result == SND_WORKING || result == SND_WAITING)
|
||||
return true;
|
||||
@ -355,18 +344,18 @@ int GuiSound::GetVolume()
|
||||
|
||||
void GuiSound::SetVolume(int vol)
|
||||
{
|
||||
if(voice < 0 || voice >= 16 || vol < 0)
|
||||
if(this->voice < 0 || this->voice >= 16 || vol < 0)
|
||||
return;
|
||||
|
||||
volume = vol;
|
||||
ASND_ChangeVolumeVoice(voice, volume, volume);
|
||||
ASND_ChangeVolumeVoice(this->voice, volume, volume);
|
||||
}
|
||||
|
||||
void GuiSound::SetLoop(u8 l)
|
||||
{
|
||||
loop = l;
|
||||
|
||||
SoundDecoder *decoder = SoundHandler::Instance()->Decoder(voice);
|
||||
SoundDecoder *decoder = SoundHandler::Instance()->Decoder(this->voice);
|
||||
if(!decoder)
|
||||
return;
|
||||
|
||||
@ -375,112 +364,13 @@ void GuiSound::SetLoop(u8 l)
|
||||
|
||||
void GuiSound::Rewind()
|
||||
{
|
||||
SoundDecoder *decoder = SoundHandler::Instance()->Decoder(voice);
|
||||
SoundDecoder *decoder = SoundHandler::Instance()->Decoder(this->voice);
|
||||
if(!decoder)
|
||||
return;
|
||||
|
||||
decoder->Rewind();
|
||||
}
|
||||
|
||||
struct _LZ77Info
|
||||
{
|
||||
u16 length : 4;
|
||||
u16 offset : 12;
|
||||
} __attribute__((packed));
|
||||
|
||||
typedef struct _LZ77Info LZ77Info;
|
||||
|
||||
u8 * uncompressLZ77(const u8 *inBuf, u32 inLength, u32 * size)
|
||||
{
|
||||
u8 *buffer = NULL;
|
||||
if (inLength <= 0x8 || *((const u32 *)inBuf) != 0x4C5A3737 /*"LZ77"*/ || inBuf[4] != 0x10)
|
||||
return NULL;
|
||||
|
||||
u32 uncSize = le32(((const u32 *)inBuf)[1] << 8);
|
||||
if(uncSize <= 0) return 0;
|
||||
|
||||
const u8 *inBufEnd = inBuf + inLength;
|
||||
inBuf += 8;
|
||||
|
||||
buffer = (u8 *)malloc(uncSize);
|
||||
|
||||
if(!buffer)
|
||||
return buffer;
|
||||
|
||||
u8 *bufCur = buffer;
|
||||
u8 *bufEnd = buffer + uncSize;
|
||||
|
||||
while(bufCur < bufEnd && inBuf < inBufEnd)
|
||||
{
|
||||
u8 flags = *inBuf;
|
||||
++inBuf;
|
||||
int i = 0;
|
||||
for(i = 0; i < 8 && bufCur < bufEnd && inBuf < inBufEnd; ++i)
|
||||
{
|
||||
if((flags & 0x80) != 0)
|
||||
{
|
||||
const LZ77Info * info = (const LZ77Info *)inBuf;
|
||||
inBuf += sizeof (LZ77Info);
|
||||
int length = info->length + 3;
|
||||
if(bufCur - info->offset - 1 < buffer || bufCur + length > bufEnd)
|
||||
return buffer;
|
||||
memcpy(bufCur, bufCur - info->offset - 1, length);
|
||||
bufCur += length;
|
||||
}
|
||||
else
|
||||
{
|
||||
*bufCur = *inBuf;
|
||||
++inBuf;
|
||||
++bufCur;
|
||||
}
|
||||
flags <<= 1;
|
||||
}
|
||||
}
|
||||
|
||||
*size = uncSize;
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
void GuiSound::UncompressSoundbin(const u8 * snd, u32 len, bool isallocated)
|
||||
{
|
||||
const u8 * file = snd+32;
|
||||
|
||||
length = len-32;
|
||||
if(length <= 0)
|
||||
return;
|
||||
|
||||
if(*((u32 *) file) == 'LZ77')
|
||||
{
|
||||
u32 size = 0;
|
||||
sound = uncompressLZ77(file, length, &size);
|
||||
if (!sound)
|
||||
{
|
||||
length = 0;
|
||||
return;
|
||||
}
|
||||
length = size;
|
||||
}
|
||||
else
|
||||
{
|
||||
sound = (u8 *)malloc(length);
|
||||
if (!sound)
|
||||
{
|
||||
length = 0;
|
||||
return;
|
||||
}
|
||||
memcpy(sound, file, length);
|
||||
}
|
||||
|
||||
if(isallocated)
|
||||
{
|
||||
void *p = (void *)snd;
|
||||
free(p);
|
||||
}
|
||||
|
||||
allocated = true;
|
||||
}
|
||||
|
||||
void soundInit(void)
|
||||
{
|
||||
ASND_Init();
|
||||
|
@ -84,13 +84,11 @@ public:
|
||||
private:
|
||||
//!Initializes the GuiSound object by setting the default values
|
||||
void Init();
|
||||
//!Special sound case for sound.bin
|
||||
void UncompressSoundbin(const u8 * snd, u32 len, bool isallocated);
|
||||
protected:
|
||||
std::string filepath;
|
||||
u8 *sound; //!< Pointer to the sound data
|
||||
u32 length; //!< Length of sound data
|
||||
s32 voice; //!< Currently assigned ASND voice channel
|
||||
s8 voice; //!< Currently assigned ASND voice channel
|
||||
int volume; //!< Sound volume (0-100)
|
||||
u8 loop; //!< Loop sound playback
|
||||
u32 SoundEffectLength; //!< Check if it is an app soundeffect for faster playback
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include <malloc.h>
|
||||
#include "dns.h"
|
||||
#include "mem2.hpp"
|
||||
|
||||
/**
|
||||
* Resolves a domainname to an ip address
|
||||
@ -70,14 +70,14 @@ u32 getipbynamecached(char *domain)
|
||||
u32 ip = getipbyname(domain);
|
||||
|
||||
//No cache of this domain could be found, create a cache node and add it to the front of the cache
|
||||
struct dnsentry *newnode = MEM2_alloc(sizeof(struct dnsentry));
|
||||
struct dnsentry *newnode = malloc(sizeof(struct dnsentry));
|
||||
if(newnode == NULL) return ip;
|
||||
|
||||
newnode->ip = ip;
|
||||
newnode->domain = MEM2_alloc(strlen(domain)+1);
|
||||
newnode->domain = malloc(strlen(domain)+1);
|
||||
if(newnode->domain == NULL)
|
||||
{
|
||||
MEM2_free(newnode);
|
||||
free(newnode);
|
||||
return ip;
|
||||
}
|
||||
strcpy(newnode->domain, domain);
|
||||
@ -110,8 +110,8 @@ u32 getipbynamecached(char *domain)
|
||||
previousnode->nextnode = NULL;
|
||||
}
|
||||
|
||||
MEM2_free(node->domain);
|
||||
MEM2_free(node);
|
||||
free(node->domain);
|
||||
free(node);
|
||||
dnsentrycount--;
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,10 @@
|
||||
#include <string.h>
|
||||
#include <malloc.h>
|
||||
|
||||
#include "gcard.h"
|
||||
#include "http.h"
|
||||
#include "utils.h"
|
||||
#include "gecko/gecko.h"
|
||||
#include "mem2.hpp"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#define MAX_URL_SIZE 178 // 128 + 48 + 6
|
||||
|
||||
@ -45,7 +44,7 @@ void add_game_to_card(const char *gameid)
|
||||
{
|
||||
int i;
|
||||
|
||||
char *url = (char *)MEM2_alloc(MAX_URL_SIZE); // Too much memory, but only like 10 bytes
|
||||
char *url = (char *)malloc(MAX_URL_SIZE); // Too much memory, but only like 10 bytes
|
||||
memset(url, 0, sizeof(url));
|
||||
|
||||
for (i = 0; i < amount_of_providers && providers != NULL; i++)
|
||||
@ -57,5 +56,5 @@ void add_game_to_card(const char *gameid)
|
||||
gprintf("Gamertag URL:\n%s\n",(char*)url);
|
||||
downloadfile(NULL, 0, (char *) url, NULL, NULL);
|
||||
}
|
||||
MEM2_free(url);
|
||||
free(url);
|
||||
}
|
@ -18,9 +18,9 @@
|
||||
#include <ogcsys.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <malloc.h>
|
||||
|
||||
#include "plugin.hpp"
|
||||
#include "memory/mem2.hpp"
|
||||
#include "gui/text.hpp"
|
||||
#include "gecko/gecko.h"
|
||||
#include "devicemounter/PartitionHandle.h"
|
||||
@ -51,7 +51,7 @@ void Plugin::Cleanup()
|
||||
for(u8 pos = 0; pos < Plugins.size(); pos++)
|
||||
{
|
||||
if(Plugins[pos].BannerSound != NULL)
|
||||
MEM2_free(Plugins[pos].BannerSound);
|
||||
free(Plugins[pos].BannerSound);
|
||||
}
|
||||
}
|
||||
|
||||
@ -86,7 +86,7 @@ bool Plugin::AddPlugin(Config &plugin)
|
||||
size = infile.tellg();
|
||||
infile.seekg(0, ios::beg);
|
||||
//Don't free that, otherwise you would delete the sound
|
||||
char* FileReadBuffer = (char*)MEM2_alloc(size);
|
||||
char* FileReadBuffer = (char*)malloc(size);
|
||||
infile.read(FileReadBuffer, size);
|
||||
NewPlugin.BannerSound = (u8*)FileReadBuffer;
|
||||
NewPlugin.BannerSoundSize = size;
|
||||
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user