mirror of
https://github.com/Fledge68/WiiFlow_Lite.git
synced 2024-12-24 19:01:56 +01:00
-cleaned up code more, set clear priority to alloc in which
memory region
This commit is contained in:
parent
d669a1a17e
commit
49a31c4f25
@ -81,7 +81,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <malloc.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "MD5.h"
|
||||
|
@ -26,7 +26,6 @@
|
||||
* for wiiflow 2010
|
||||
***************************************************************************/
|
||||
|
||||
#include <malloc.h>
|
||||
#include <ogcsys.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
@ -14,7 +14,6 @@
|
||||
******************************************************************************/
|
||||
|
||||
#include <gccore.h>
|
||||
#include <malloc.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
@ -29,7 +29,6 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ogcsys.h>
|
||||
#include <malloc.h>
|
||||
#include <string.h>
|
||||
#include <cstdlib>
|
||||
#include <stdarg.h>
|
||||
|
@ -2,7 +2,6 @@
|
||||
#define _NAND_H_
|
||||
|
||||
#include <gccore.h>
|
||||
#include <malloc.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
@ -23,7 +23,7 @@
|
||||
*
|
||||
* for WiiXplorer 2010
|
||||
***************************************************************************/
|
||||
#include <malloc.h>
|
||||
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <ogc/mutex.h>
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "WiiMovie.hpp"
|
||||
#include "musicplayer.h"
|
||||
#include "gecko.h"
|
||||
#include "mem2.hpp"
|
||||
|
||||
#define SND_BUFFERS 8
|
||||
#define FRAME_BUFFERS 8
|
||||
@ -75,7 +76,7 @@ WiiMovie::WiiMovie(const char * filepath)
|
||||
}
|
||||
|
||||
PlayThreadStack = NULL;
|
||||
ThreadStack = (u8 *) memalign(32, 32768);
|
||||
ThreadStack = (u8 *)MEM2_alloc(32768);
|
||||
if (!ThreadStack)
|
||||
return;
|
||||
|
||||
@ -111,7 +112,7 @@ WiiMovie::~WiiMovie()
|
||||
}
|
||||
if (ThreadStack != NULL)
|
||||
{
|
||||
SAFE_FREE(ThreadStack);
|
||||
MEM2_free(ThreadStack);
|
||||
ThreadStack = NULL;
|
||||
}
|
||||
|
||||
@ -129,7 +130,7 @@ bool WiiMovie::Play(bool loop)
|
||||
|
||||
gprintf("Start playing video\n");
|
||||
|
||||
PlayThreadStack = (u8 *) memalign(32, 32768);
|
||||
PlayThreadStack = (u8 *)MEM2_alloc(32768);
|
||||
if (PlayThreadStack == NULL) return false;
|
||||
|
||||
Playing = true;
|
||||
@ -156,7 +157,7 @@ void WiiMovie::Stop()
|
||||
PlayThread = LWP_THREAD_NULL;
|
||||
gprintf("Playing thread stopped\n");
|
||||
|
||||
SAFE_FREE(PlayThreadStack);
|
||||
MEM2_free(PlayThreadStack);
|
||||
}
|
||||
|
||||
void WiiMovie::SetVolume(int vol)
|
||||
|
@ -9,7 +9,6 @@ More info : http://frontier-dev.net
|
||||
********************************************************************************************/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <malloc.h>
|
||||
|
||||
#include "pngu.h"
|
||||
#include "png.h"
|
||||
|
@ -1,3 +1,6 @@
|
||||
|
||||
#include <ogc/machine/processor.h>
|
||||
|
||||
#include "DeviceHandler.hpp"
|
||||
#include "wdvd.h"
|
||||
#include "disc.h"
|
||||
@ -6,10 +9,6 @@
|
||||
#include "alt_ios.h"
|
||||
#include "sys.h"
|
||||
#include "wbfs.h"
|
||||
|
||||
#include <malloc.h>
|
||||
#include <ogc/machine/processor.h>
|
||||
|
||||
#include "gecko.h"
|
||||
|
||||
extern "C" {extern u8 currentPartition;}
|
||||
@ -77,37 +76,18 @@ bool loadIOS(int ios, bool launch_game)
|
||||
WDVD_Close();
|
||||
USBStorage_Deinit();
|
||||
|
||||
//gprintf("AHBPROT state before reloading: %s\n", HAVE_AHBPROT ? "enabled" : "disabled");
|
||||
//IOSPATCH_AHBPROT();
|
||||
|
||||
/* void *backup = MEM1_alloc(0x200000); // 0x126CA0 bytes were needed last time i checked. But take more just in case.
|
||||
if (backup != 0)
|
||||
{
|
||||
memcpy(backup, &__Arena2Lo, 0x200000);
|
||||
DCFlushRange(backup, 0x200000);
|
||||
} */
|
||||
|
||||
bool iosOK = IOS_ReloadIOS(ios) == 0;
|
||||
|
||||
/* if (backup != 0)
|
||||
{
|
||||
memcpy(&__Arena2Lo, backup, 0x200000);
|
||||
DCFlushRange(&__Arena2Lo, 0x200000);
|
||||
free(backup);
|
||||
} */
|
||||
|
||||
gprintf("%s, Current IOS: %i\n", iosOK ? "OK" : "FAILED!", IOS_GetVersion());
|
||||
|
||||
//IOSPATCH_AHBPROT();
|
||||
//gprintf("Current AHBPROT state: %s\n", HAVE_AHBPROT ? "enabled" : "disabled");
|
||||
|
||||
if (launch_game)
|
||||
if(launch_game)
|
||||
{
|
||||
DeviceHandler::Instance()->MountAll();
|
||||
DeviceHandler::Instance()->Open_WBFS(currentPartition);
|
||||
Disc_Init();
|
||||
}
|
||||
else Open_Inputs();
|
||||
else
|
||||
Open_Inputs();
|
||||
|
||||
return iosOK;
|
||||
}
|
@ -24,7 +24,6 @@
|
||||
* distribution.
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include <gctypes.h>
|
||||
#include <malloc.h>
|
||||
#include <cstdio>
|
||||
|
@ -277,7 +277,8 @@ out:
|
||||
|
||||
int set_frag_list(u8 *id)
|
||||
{
|
||||
if (frag_list == NULL) return -2;
|
||||
if (frag_list == NULL)
|
||||
return -2;
|
||||
|
||||
// (+1 for header which is same size as fragment)
|
||||
int size = sizeof(Fragment) * (frag_list->num + 1);
|
||||
@ -289,10 +290,11 @@ int set_frag_list(u8 *id)
|
||||
|
||||
int ret = WDVD_SetFragList(wbfsDev, frag_list, size);
|
||||
|
||||
free(frag_list);
|
||||
MEM2_free(frag_list);
|
||||
frag_list = NULL;
|
||||
|
||||
if (ret) return ret;
|
||||
if(ret)
|
||||
return ret;
|
||||
|
||||
// verify id matches
|
||||
char discid[32] ATTRIBUTE_ALIGN(32);
|
||||
|
@ -1,7 +1,6 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <malloc.h>
|
||||
#include <ogcsys.h>
|
||||
#include <dirent.h>
|
||||
#include <sys/types.h>
|
||||
|
@ -3,7 +3,6 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <malloc.h>
|
||||
#include <ogcsys.h>
|
||||
#include <dirent.h>
|
||||
#include <sys/types.h>
|
||||
|
@ -1,7 +1,9 @@
|
||||
|
||||
#include <gccore.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "mem2.hpp"
|
||||
#include "utils.h" //SAFE_CLOSE
|
||||
#include "gecko.h"
|
||||
|
||||
@ -106,12 +108,13 @@ int load_wip_patches(u8 *dir, u8 *gameid)
|
||||
u32 srcaddress = (u32) strtoul(line+9, NULL, 16);
|
||||
u32 dstaddress = (u32) strtoul(line+18, NULL, 16);
|
||||
|
||||
if(!CodeList) CodeList = malloc(sizeof(WIP_Code));
|
||||
if(!CodeList)
|
||||
CodeList = MEM2_alloc(sizeof(WIP_Code));
|
||||
|
||||
WIP_Code * tmp = realloc(CodeList, (CodesCount+1)*sizeof(WIP_Code));
|
||||
WIP_Code *tmp = MEM2_realloc(CodeList, (CodesCount+1)*sizeof(WIP_Code));
|
||||
if(!tmp)
|
||||
{
|
||||
SAFE_FREE(CodeList);
|
||||
MEM2_free(CodeList);
|
||||
SAFE_CLOSE(fp);
|
||||
return -1;
|
||||
}
|
||||
|
@ -1039,7 +1039,7 @@ void CMenu::_launchGame(dir_discHdr *hdr, bool dvd)
|
||||
struct gc_discHdr *gcHeader = (struct gc_discHdr *)MEM2_alloc(sizeof(struct gc_discHdr));
|
||||
Disc_ReadGCHeader(gcHeader);
|
||||
memcpy(hdr->hdr.id, gcHeader->id, 6);
|
||||
SAFE_FREE(gcHeader);
|
||||
MEM2_free(gcHeader);
|
||||
/* Launching GC Game */
|
||||
_launchGC(hdr, false);
|
||||
}
|
||||
@ -1050,7 +1050,7 @@ void CMenu::_launchGame(dir_discHdr *hdr, bool dvd)
|
||||
Disc_ReadHeader(header);
|
||||
for (int i = 0;i < 6; i++)
|
||||
id[i] = header->id[i];
|
||||
SAFE_FREE(header);
|
||||
MEM2_free(header);
|
||||
}
|
||||
bool vipatch = m_gcfg2.testOptBool(id, "vipatch", m_cfg.getBool("GENERAL", "vipatch", false));
|
||||
bool cheat = m_gcfg2.testOptBool(id, "cheat", m_cfg.getBool("GAMES", "cheat", false));
|
||||
|
@ -23,9 +23,8 @@
|
||||
*
|
||||
* for WiiXplorer 2010
|
||||
***************************************************************************/
|
||||
#include <malloc.h>
|
||||
#include "mem2.hpp"
|
||||
#include "BufferCircle.hpp"
|
||||
#include "utils.h"
|
||||
|
||||
BufferCircle::BufferCircle()
|
||||
{
|
||||
@ -50,9 +49,9 @@ void BufferCircle::SetBufferBlockSize(int size)
|
||||
|
||||
for(int i = 0; i < Size(); i++)
|
||||
{
|
||||
SAFE_FREE(SoundBuffer[i]);
|
||||
MEM1_free(SoundBuffer[i]);
|
||||
|
||||
SoundBuffer[i] = (u8 *) memalign(32, ALIGN32(BufferBlockSize));
|
||||
SoundBuffer[i] = (u8 *)MEM1_memalign(32, BufferBlockSize);
|
||||
BufferSize[i] = 0;
|
||||
BufferReady[i] = false;
|
||||
}
|
||||
@ -72,7 +71,7 @@ void BufferCircle::Resize(int size)
|
||||
for(int i = oldSize; i < Size(); i++)
|
||||
{
|
||||
if(BufferBlockSize > 0)
|
||||
SoundBuffer[i] = (u8 *) memalign(32, ALIGN32(BufferBlockSize));
|
||||
SoundBuffer[i] = (u8 *)MEM1_memalign(32, BufferBlockSize);
|
||||
else
|
||||
SoundBuffer[i] = NULL;
|
||||
BufferSize[i] = 0;
|
||||
@ -85,7 +84,7 @@ void BufferCircle::RemoveBuffer(int pos)
|
||||
if(!Valid(pos))
|
||||
return;
|
||||
|
||||
SAFE_FREE(SoundBuffer[pos]);
|
||||
MEM1_free(SoundBuffer[pos]);
|
||||
|
||||
SoundBuffer.erase(SoundBuffer.begin()+pos);
|
||||
BufferSize.erase(BufferSize.begin()+pos);
|
||||
@ -106,7 +105,7 @@ void BufferCircle::FreeBuffer()
|
||||
{
|
||||
for(int i = 0; i < Size(); i++)
|
||||
{
|
||||
SAFE_FREE(SoundBuffer[i]);
|
||||
MEM1_free(SoundBuffer[i]);
|
||||
BufferSize[i] = 0;
|
||||
BufferReady[i] = false;
|
||||
}
|
||||
|
@ -27,9 +27,10 @@
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
#include <unistd.h>
|
||||
#include <malloc.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "Mp3Decoder.hpp"
|
||||
#include "mem2.hpp"
|
||||
|
||||
Mp3Decoder::Mp3Decoder(const char * filepath)
|
||||
: SoundDecoder(filepath)
|
||||
@ -73,13 +74,13 @@ Mp3Decoder::~Mp3Decoder()
|
||||
mad_frame_finish(&Frame);
|
||||
mad_stream_finish(&Stream);
|
||||
|
||||
SAFE_FREE(ReadBuffer);
|
||||
MEM2_free(ReadBuffer);
|
||||
}
|
||||
|
||||
void Mp3Decoder::OpenFile()
|
||||
{
|
||||
GuardPtr = NULL;
|
||||
ReadBuffer = (u8 *) memalign(32, SoundBlockSize*SoundBlocks);
|
||||
ReadBuffer = (u8 *)MEM2_alloc(SoundBlockSize * SoundBlocks);
|
||||
if(!ReadBuffer)
|
||||
{
|
||||
if(file_fd)
|
||||
|
@ -24,7 +24,6 @@
|
||||
* for WiiXplorer 2010
|
||||
***************************************************************************/
|
||||
#include <unistd.h>
|
||||
#include <malloc.h>
|
||||
#include "OggDecoder.hpp"
|
||||
|
||||
extern "C" int ogg_read(void * punt, int bytes, int blocks, int *f)
|
||||
|
@ -26,7 +26,6 @@
|
||||
* for WiiXplorer 2010
|
||||
***************************************************************************/
|
||||
#include <gccore.h>
|
||||
#include <malloc.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include "SoundDecoder.hpp"
|
||||
|
@ -24,7 +24,6 @@
|
||||
* for WiiXplorer 2010
|
||||
***************************************************************************/
|
||||
#include <unistd.h>
|
||||
#include <malloc.h>
|
||||
#include "SoundHandler.hpp"
|
||||
#include "Mp3Decoder.hpp"
|
||||
#include "OggDecoder.hpp"
|
||||
@ -33,6 +32,7 @@
|
||||
#include "BNSDecoder.hpp"
|
||||
|
||||
#include "gecko/gecko.h"
|
||||
#include "mem2.hpp"
|
||||
|
||||
SoundHandler * SoundHandler::instance = NULL;
|
||||
|
||||
@ -43,7 +43,7 @@ SoundHandler::SoundHandler()
|
||||
for(u32 i = 0; i < MAX_DECODERS; ++i)
|
||||
DecoderList[i] = NULL;
|
||||
|
||||
ThreadStack = (u8 *) memalign(32, 32768);
|
||||
ThreadStack = (u8 *)MEM1_memalign(32, 32768);
|
||||
if(!ThreadStack)
|
||||
return;
|
||||
|
||||
@ -59,7 +59,7 @@ SoundHandler::~SoundHandler()
|
||||
ThreadSignal();
|
||||
LWP_JoinThread(SoundThread, NULL);
|
||||
SoundThread = LWP_THREAD_NULL;
|
||||
SAFE_FREE(ThreadStack);
|
||||
MEM1_free(ThreadStack);
|
||||
|
||||
ClearDecoderList();
|
||||
gprintf("SHND: Stopped sound thread\n");
|
||||
|
@ -245,7 +245,7 @@ bool GuiSound::LoadSoundEffect(const u8 * snd, u32 len)
|
||||
u8 * tmpsnd = (u8 *)MEM2_realloc(sound, done+4096);
|
||||
if(!tmpsnd)
|
||||
{
|
||||
SAFE_FREE(sound);
|
||||
MEM2_free(sound);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -479,8 +479,8 @@ void GuiSound::UncompressSoundbin(const u8 * snd, u32 len, bool isallocated)
|
||||
|
||||
if(isallocated)
|
||||
{
|
||||
void *p = (void *) snd;
|
||||
SAFE_FREE(p);
|
||||
void *p = (void *)snd;
|
||||
MEM2_free(p);
|
||||
}
|
||||
|
||||
allocated = true;
|
||||
|
@ -32,7 +32,6 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <malloc.h>
|
||||
|
||||
#include "ZipFile.h"
|
||||
#include "miniunz.h"
|
||||
|
Loading…
Reference in New Issue
Block a user