mirror of
https://github.com/Fledge68/WiiFlow_Lite.git
synced 2024-11-27 05:34:15 +01:00
-fixed missing background music
-back to the entry point we had before -set up cache to 32 again, seems to make wiiflow faster -changed few things about memory management again -made a few free safe again in code
This commit is contained in:
parent
678dc5ac0d
commit
1f5d72f2a4
2
Makefile
2
Makefile
@ -73,7 +73,7 @@ ios := 249
|
||||
CFLAGS = -g -Os -Wall -Wextra -Wno-multichar $(MACHDEP) $(INCLUDE) -DHAVE_CONFIG_H
|
||||
CXXFLAGS = $(CFLAGS)
|
||||
|
||||
LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map,--section-start,.init=0x80A80000,-wrap,malloc,-wrap,free,-wrap,memalign,-wrap,calloc,-wrap,realloc,-wrap,malloc_usable_size
|
||||
LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map,--section-start,.init=0x80B00000,-wrap,malloc,-wrap,free,-wrap,memalign,-wrap,calloc,-wrap,realloc,-wrap,malloc_usable_size
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# any extra libraries we wish to link with the project
|
||||
|
@ -42,7 +42,7 @@
|
||||
#define PARTITION_TYPE_WIN95_EXTENDED 0x0F /* Windows 95 extended partition */
|
||||
#define PARTITION_TYPE_GPT_TABLE 0xEE /* New Standard */
|
||||
|
||||
#define CACHE 8
|
||||
#define CACHE 32
|
||||
#define SECTORS 64
|
||||
|
||||
extern const DISC_INTERFACE __io_sdhc;
|
||||
|
@ -171,8 +171,8 @@ void CVideo::init(void)
|
||||
GX_SetNumChans(0);
|
||||
GX_SetZCompLoc(GX_ENABLE);
|
||||
setup2DProjection();
|
||||
m_stencil = smartMemAlign32(CVideo::_stencilWidth * CVideo::_stencilHeight);
|
||||
memset(m_stencil.get(), 0, CVideo::_stencilWidth * CVideo::_stencilHeight);
|
||||
m_stencil = MEM1_memalign(32, CVideo::_stencilWidth * CVideo::_stencilHeight);
|
||||
memset(m_stencil, 0, CVideo::_stencilWidth * CVideo::_stencilHeight);
|
||||
}
|
||||
|
||||
void CVideo::set2DViewport(u32 w, u32 h, int x, int y)
|
||||
@ -238,7 +238,6 @@ void CVideo::cleanup(void)
|
||||
VIDEO_WaitVSync();
|
||||
if (m_rmode->viTVMode & VI_NON_INTERLACE)
|
||||
VIDEO_WaitVSync();
|
||||
//MEM1_free(m_fifo);
|
||||
}
|
||||
|
||||
void CVideo::prepareAAPass(int aaStep)
|
||||
@ -407,7 +406,7 @@ int CVideo::stencilVal(int x, int y)
|
||||
u32 i = coordsI8(x, y, (u32)CVideo::_stencilWidth);
|
||||
if (i >= (u32)(CVideo::_stencilWidth * CVideo::_stencilHeight))
|
||||
return 0;
|
||||
return m_stencil.get()[i];
|
||||
return ((u8*)m_stencil)[i];
|
||||
}
|
||||
|
||||
void CVideo::prepareStencil(void)
|
||||
@ -427,9 +426,9 @@ void CVideo::renderStencil(void)
|
||||
GX_SetCopyFilter(GX_FALSE, NULL, GX_FALSE, NULL);
|
||||
GX_SetTexCopySrc(0, 0, CVideo::_stencilWidth, CVideo::_stencilHeight);
|
||||
GX_SetTexCopyDst(CVideo::_stencilWidth, CVideo::_stencilHeight, GX_CTF_R8, GX_FALSE);
|
||||
GX_CopyTex(m_stencil.get(), GX_TRUE);
|
||||
GX_CopyTex(m_stencil, GX_TRUE);
|
||||
GX_PixModeSync();
|
||||
DCFlushRange(m_stencil.get(), CVideo::_stencilWidth * CVideo::_stencilHeight);
|
||||
DCFlushRange(m_stencil, CVideo::_stencilWidth * CVideo::_stencilHeight);
|
||||
GX_SetCopyFilter(m_rmode->aa, m_rmode->sample_pattern, GX_TRUE, m_rmode->vfilter);
|
||||
}
|
||||
|
||||
|
@ -78,6 +78,7 @@ private:
|
||||
void *m_frameBuf[2];
|
||||
int m_curFB;
|
||||
void *m_fifo;
|
||||
void *m_stencil;
|
||||
float m_yScale;
|
||||
u32 m_xfbHeight;
|
||||
bool m_wide;
|
||||
@ -90,7 +91,6 @@ private:
|
||||
bool m_aaAlpha;
|
||||
int m_aaWidth;
|
||||
int m_aaHeight;
|
||||
SmartBuf m_stencil;
|
||||
SmartBuf m_aaBuffer[8];
|
||||
u32 m_aaBufferSize[8];
|
||||
float m_vpX;
|
||||
|
@ -1,13 +1,6 @@
|
||||
#ifndef _DISC_H_
|
||||
#define _DISC_H_
|
||||
|
||||
#ifndef APPLOADER_START
|
||||
#define APPLOADER_START (void *)0x81200000
|
||||
#endif
|
||||
#ifndef APPLOADER_END
|
||||
#define APPLOADER_END (void *)0x81700000
|
||||
#endif
|
||||
|
||||
#define Sys_Magic ((vu32*)0x80000020)
|
||||
#define Version ((vu32*)0x80000024)
|
||||
#define Arena_L ((vu32*)0x80000030)
|
||||
|
@ -36,14 +36,14 @@ extern "C"
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
__exception_setreload(5);
|
||||
MEM2_init(52);
|
||||
|
||||
geckoinit = InitGecko();
|
||||
gprintf(" \nWelcome to %s (%s-r%s)!\nThis is the debug output.\n", APP_NAME, APP_VERSION, SVN_REV);
|
||||
|
||||
// Init video
|
||||
CVideo vid;
|
||||
vid.init();
|
||||
|
||||
MEM2_init(52);
|
||||
geckoinit = InitGecko();
|
||||
gprintf(" \nWelcome to %s (%s-r%s)!\nThis is the debug output.\n", APP_NAME, APP_VERSION, SVN_REV);
|
||||
vid.waitMessage(0.2f);
|
||||
|
||||
char *gameid = NULL;
|
||||
|
@ -6,7 +6,6 @@
|
||||
#include "mem2.hpp"
|
||||
#include "mem2alloc.hpp"
|
||||
#include "gecko.h"
|
||||
#include "disc.h"
|
||||
|
||||
// Forbid the use of MEM2 through malloc
|
||||
u32 MALLOC_MEM2 = 0;
|
||||
@ -44,10 +43,10 @@ void MEM1_free(void *p)
|
||||
__real_free(p);
|
||||
}
|
||||
|
||||
|
||||
void MEM2_init(unsigned int mem2Size)
|
||||
{
|
||||
g_mem2gp.init(mem2Size);
|
||||
g_mem2gp.clear();
|
||||
}
|
||||
|
||||
void MEM2_cleanup(void)
|
||||
@ -90,7 +89,7 @@ void *__wrap_malloc(size_t size)
|
||||
void *p;
|
||||
if ((SYS_GetArena1Lo() >= MAX_MEM1_ARENA_LO) || size >= MEM2_PRIORITY_SIZE)
|
||||
{
|
||||
p = MEM2_alloc(size);
|
||||
p = g_mem2gp.allocate(size);
|
||||
if(p != 0)
|
||||
return p;
|
||||
return __real_malloc(size);
|
||||
@ -98,7 +97,7 @@ void *__wrap_malloc(size_t size)
|
||||
p = __real_malloc(size);
|
||||
if(p != 0)
|
||||
return p;
|
||||
return MEM2_alloc(size);
|
||||
return g_mem2gp.allocate(size);
|
||||
}
|
||||
|
||||
void *__wrap_calloc(size_t n, size_t size)
|
||||
@ -106,7 +105,7 @@ void *__wrap_calloc(size_t n, size_t size)
|
||||
void *p;
|
||||
if ((SYS_GetArena1Lo() >= MAX_MEM1_ARENA_LO) || (n * size) >= MEM2_PRIORITY_SIZE)
|
||||
{
|
||||
p = MEM2_alloc(n * size);
|
||||
p = g_mem2gp.allocate(n * size);
|
||||
if (p != 0)
|
||||
{
|
||||
memset(p, 0, n * size);
|
||||
@ -118,7 +117,7 @@ void *__wrap_calloc(size_t n, size_t size)
|
||||
p = __real_calloc(n, size);
|
||||
if (p != 0) return p;
|
||||
|
||||
p = MEM2_alloc(n * size);
|
||||
p = g_mem2gp.allocate(n * size);
|
||||
if (p != 0)
|
||||
memset(p, 0, n * size);
|
||||
return p;
|
||||
@ -131,7 +130,7 @@ void *__wrap_memalign(size_t a, size_t size)
|
||||
{
|
||||
if (a <= 32 && 32 % a == 0)
|
||||
{
|
||||
p = MEM2_alloc(size);
|
||||
p = g_mem2gp.allocate(size);
|
||||
if (p != 0)
|
||||
return p;
|
||||
}
|
||||
@ -140,7 +139,7 @@ void *__wrap_memalign(size_t a, size_t size)
|
||||
p = __real_memalign(a, size);
|
||||
if(p != 0)
|
||||
return p;
|
||||
return MEM2_alloc(size);
|
||||
return g_mem2gp.allocate(size);
|
||||
}
|
||||
|
||||
void __wrap_free(void *p)
|
||||
@ -160,7 +159,7 @@ void *__wrap_realloc(void *p, size_t size)
|
||||
// ptr from mem2
|
||||
if (((u32)p & 0x10000000) != 0 || (p == 0 && size > MEM2_PRIORITY_SIZE))
|
||||
{
|
||||
n = MEM2_realloc(p, size);
|
||||
n = g_mem2gp.reallocate(p, size);
|
||||
if (n != 0)
|
||||
return n;
|
||||
n = __real_malloc(size);
|
||||
@ -169,7 +168,7 @@ void *__wrap_realloc(void *p, size_t size)
|
||||
if (p != 0)
|
||||
{
|
||||
memcpy(n, p, MEM2_usableSize(p) < size ? MEM2_usableSize(p) : size);
|
||||
MEM2_free(p);
|
||||
g_mem2gp.release(p);
|
||||
}
|
||||
return n;
|
||||
}
|
||||
@ -177,7 +176,7 @@ void *__wrap_realloc(void *p, size_t size)
|
||||
n = __real_realloc(p, size);
|
||||
if (n != 0)
|
||||
return n;
|
||||
n = MEM2_alloc(size);
|
||||
n = g_mem2gp.allocate(size);
|
||||
if (n == 0)
|
||||
return 0;
|
||||
if (p != 0)
|
||||
@ -191,7 +190,7 @@ void *__wrap_realloc(void *p, size_t size)
|
||||
size_t __wrap_malloc_usable_size(void *p)
|
||||
{
|
||||
if(((u32)p & 0x10000000) != 0)
|
||||
return MEM2_usableSize(p);
|
||||
return CMEM2Alloc::usableSize(p);
|
||||
return __real_malloc_usable_size(p);
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@ extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#define MAX_MEM1_ARENA_LO ((void *) (((u32)APPLOADER_START)-size))
|
||||
#define MAX_MEM1_ARENA_LO ((void *)(0x81700000-size))
|
||||
#define MEM2_PRIORITY_SIZE 0x1000
|
||||
|
||||
void *MEM1_alloc(unsigned int s);
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
#include "mem2alloc.hpp"
|
||||
|
||||
#include <ogc/system.h>
|
||||
@ -7,13 +6,15 @@
|
||||
|
||||
#include "lockMutex.hpp"
|
||||
|
||||
#define IOS_RELOAD_AREA 0x90200000
|
||||
|
||||
void CMEM2Alloc::init(unsigned int size)
|
||||
{
|
||||
m_baseAddress = (SBlock *)(((u32)SYS_GetArena2Lo() + 31) & ~31);
|
||||
m_endAddress = (SBlock *)((char *)m_baseAddress + std::min(size * 0x100000, (SYS_GetArena2Size() - 0x20 - 31) & ~31)); // Round down - an extra 32 for wdvd_unencrypted read
|
||||
m_baseAddress = (SBlock *) std::max(((u32)SYS_GetArena2Lo() + 31) & ~31, IOS_RELOAD_AREA);
|
||||
m_endAddress = (SBlock *)((char *)m_baseAddress + std::min(size * 0x100000, SYS_GetArena2Size() & ~31));
|
||||
if (m_endAddress > (SBlock *)0x93000000)
|
||||
m_endAddress = (SBlock *)0x93000000;
|
||||
SYS_SetArena2Lo(m_endAddress + 0x20);
|
||||
SYS_SetArena2Lo(m_endAddress);
|
||||
LWP_MutexInit(&m_mutex, 0);
|
||||
}
|
||||
|
||||
@ -51,9 +52,9 @@ void *CMEM2Alloc::allocate(unsigned int s)
|
||||
{
|
||||
if (s == 0)
|
||||
s = 1;
|
||||
//
|
||||
//
|
||||
LockMutex lock(m_mutex);
|
||||
//
|
||||
//
|
||||
s = (s - 1) / sizeof (SBlock) + 1;
|
||||
// First block
|
||||
if (m_first == 0)
|
||||
@ -116,10 +117,10 @@ void CMEM2Alloc::release(void *p)
|
||||
SBlock *i = (SBlock *)p - 1;
|
||||
i->f = true;
|
||||
|
||||
// If there are no other blocks following yet,
|
||||
// set the remaining size to free size. - Dimok
|
||||
// If there are no other blocks following yet,
|
||||
// set the remaining size to free size. - Dimok
|
||||
if(i->next == 0)
|
||||
i->s = m_endAddress - i - 1;
|
||||
i->s = m_endAddress - i - 1;
|
||||
|
||||
// Merge with previous block
|
||||
if (i->prev != 0 && i->prev->f)
|
||||
@ -148,7 +149,6 @@ void *CMEM2Alloc::reallocate(void *p, unsigned int s)
|
||||
|
||||
if (s == 0)
|
||||
s = 1;
|
||||
|
||||
if (p == 0)
|
||||
return allocate(s);
|
||||
|
||||
@ -157,7 +157,7 @@ void *CMEM2Alloc::reallocate(void *p, unsigned int s)
|
||||
{
|
||||
LockMutex lock(m_mutex);
|
||||
|
||||
// Check for out of memory (dimok)
|
||||
//out of memory /* Dimok */
|
||||
if (i + s + 1 >= m_endAddress)
|
||||
{
|
||||
return 0;
|
||||
@ -208,25 +208,25 @@ void *CMEM2Alloc::reallocate(void *p, unsigned int s)
|
||||
|
||||
unsigned int CMEM2Alloc::FreeSize()
|
||||
{
|
||||
LockMutex lock(m_mutex);
|
||||
LockMutex lock(m_mutex);
|
||||
|
||||
if (m_first == 0)
|
||||
return (const char *) m_endAddress - (const char *) m_baseAddress;
|
||||
if (m_first == 0)
|
||||
return (const char *) m_endAddress - (const char *) m_baseAddress;
|
||||
|
||||
SBlock *i;
|
||||
unsigned int size = 0;
|
||||
unsigned int size = 0;
|
||||
|
||||
for(i = m_first; i != 0; i = i->next)
|
||||
{
|
||||
if(i->f && i->next != 0)
|
||||
size += i->s;
|
||||
size += i->s;
|
||||
|
||||
else if(i->f && i->next == 0)
|
||||
size += m_endAddress - i - 1;
|
||||
else if(i->f && i->next == 0)
|
||||
size += m_endAddress - i - 1;
|
||||
|
||||
else if(!i->f && i->next == 0)
|
||||
size += m_endAddress - i - i->s - 1;
|
||||
}
|
||||
else if(!i->f && i->next == 0)
|
||||
size += m_endAddress - i - i->s - 1;
|
||||
}
|
||||
|
||||
return size*sizeof(SBlock);
|
||||
return size*sizeof(SBlock);
|
||||
}
|
||||
|
@ -1289,7 +1289,7 @@ void CMenu::_launchGame(dir_discHdr *hdr, bool dvd)
|
||||
SDHC_Init();
|
||||
|
||||
// clear mem1 main
|
||||
u32 size = (u32)0x80A80000 - (u32)0x80004000;
|
||||
u32 size = (u32)0x80A00000 - (u32)0x80004000;
|
||||
memset((void*)0x80004000, 0, size);
|
||||
DCFlushRange((void*)0x80004000, size);
|
||||
|
||||
@ -1299,10 +1299,9 @@ void CMenu::_launchGame(dir_discHdr *hdr, bool dvd)
|
||||
u64 offset;
|
||||
Disc_FindPartition(&offset);
|
||||
u32 AppEntryPoint = RunApploader(offset, videoMode, vipatch, countryPatch, patchVidMode, disableIOSreload, aspectRatio);
|
||||
gprintf("\n\nEntry Point is: 0x%08x\n", AppEntryPoint);
|
||||
DeviceHandler::DestroyInstance();
|
||||
USBStorage_Deinit();
|
||||
gprintf("\n\nEntry Point is: 0x%08x\n", AppEntryPoint);
|
||||
usleep(100 * 1000);
|
||||
if (Disc_WiiBoot(AppEntryPoint) < 0)
|
||||
Sys_LoadMenu();
|
||||
}
|
||||
|
@ -26,6 +26,8 @@
|
||||
#include "mem2.hpp"
|
||||
#include "BufferCircle.hpp"
|
||||
|
||||
#define ALIGN32(x) (((x) + 31) & ~31)
|
||||
|
||||
BufferCircle::BufferCircle()
|
||||
{
|
||||
which = 0;
|
||||
@ -49,9 +51,9 @@ void BufferCircle::SetBufferBlockSize(int size)
|
||||
|
||||
for(int i = 0; i < Size(); i++)
|
||||
{
|
||||
MEM1_free(SoundBuffer[i]);
|
||||
|
||||
SoundBuffer[i] = (u8 *)MEM1_memalign(32, BufferBlockSize);
|
||||
if(SoundBuffer[i] != NULL)
|
||||
MEM1_free(SoundBuffer[i]);
|
||||
SoundBuffer[i] = (u8 *)MEM1_memalign(32, ALIGN32(BufferBlockSize));
|
||||
BufferSize[i] = 0;
|
||||
BufferReady[i] = false;
|
||||
}
|
||||
@ -71,7 +73,7 @@ void BufferCircle::Resize(int size)
|
||||
for(int i = oldSize; i < Size(); i++)
|
||||
{
|
||||
if(BufferBlockSize > 0)
|
||||
SoundBuffer[i] = (u8 *)MEM1_memalign(32, BufferBlockSize);
|
||||
SoundBuffer[i] = (u8 *)MEM1_memalign(32, ALIGN32(BufferBlockSize));
|
||||
else
|
||||
SoundBuffer[i] = NULL;
|
||||
BufferSize[i] = 0;
|
||||
@ -84,7 +86,8 @@ void BufferCircle::RemoveBuffer(int pos)
|
||||
if(!Valid(pos))
|
||||
return;
|
||||
|
||||
MEM1_free(SoundBuffer[pos]);
|
||||
if(SoundBuffer[pos] != NULL)
|
||||
MEM1_free(SoundBuffer[pos]);
|
||||
|
||||
SoundBuffer.erase(SoundBuffer.begin()+pos);
|
||||
BufferSize.erase(BufferSize.begin()+pos);
|
||||
@ -105,7 +108,8 @@ void BufferCircle::FreeBuffer()
|
||||
{
|
||||
for(int i = 0; i < Size(); i++)
|
||||
{
|
||||
MEM1_free(SoundBuffer[i]);
|
||||
if(SoundBuffer[i] != NULL)
|
||||
MEM1_free(SoundBuffer[i]);
|
||||
BufferSize[i] = 0;
|
||||
BufferReady[i] = false;
|
||||
}
|
||||
|
@ -59,7 +59,8 @@ SoundHandler::~SoundHandler()
|
||||
ThreadSignal();
|
||||
LWP_JoinThread(SoundThread, NULL);
|
||||
SoundThread = LWP_THREAD_NULL;
|
||||
MEM1_free(ThreadStack);
|
||||
if(ThreadStack != NULL)
|
||||
MEM1_free(ThreadStack);
|
||||
|
||||
ClearDecoderList();
|
||||
gprintf("SHND: Stopped sound thread\n");
|
||||
|
Loading…
Reference in New Issue
Block a user