mirror of
https://github.com/dborth/vbagx.git
synced 2024-12-26 02:31:50 +01:00
move some memory to high MEM2 for performance boost
This commit is contained in:
parent
64686c5b62
commit
238d32ec71
@ -35,7 +35,7 @@
|
||||
|
||||
#define THREAD_SLEEP 100
|
||||
|
||||
unsigned char savebuffer[SAVEBUFFERSIZE] ATTRIBUTE_ALIGN(32);
|
||||
unsigned char *savebuffer;
|
||||
static mutex_t bufferLock = LWP_MUTEX_NULL;
|
||||
FILE * file; // file pointer - the only one we should ever use!
|
||||
bool unmountRequired[7] = { false, false, false, false, false, false, false };
|
||||
|
@ -40,7 +40,7 @@ size_t LoadSzFile(char * filepath, unsigned char * rbuffer);
|
||||
size_t SaveFile(char * buffer, char *filepath, size_t datasize, bool silent);
|
||||
size_t SaveFile(char * filepath, size_t datasize, bool silent);
|
||||
|
||||
extern unsigned char savebuffer[];
|
||||
extern unsigned char *savebuffer;
|
||||
extern FILE * file;
|
||||
extern bool unmountRequired[];
|
||||
extern bool isMounted[];
|
||||
|
43
source/mem2.cpp
Normal file
43
source/mem2.cpp
Normal file
@ -0,0 +1,43 @@
|
||||
/****************************************************************************
|
||||
* Visual Boy Advance GX
|
||||
*
|
||||
* Tantric 2010
|
||||
*
|
||||
* mem2.cpp
|
||||
*
|
||||
* MEM2 memory allocator
|
||||
***************************************************************************/
|
||||
|
||||
#ifdef HW_RVL
|
||||
|
||||
#include <ogc/machine/asm.h>
|
||||
#include <ogc/lwp_heap.h>
|
||||
#include <ogc/system.h>
|
||||
#include <ogc/machine/processor.h>
|
||||
|
||||
static heap_cntrl mem2_heap;
|
||||
|
||||
u32 InitMem2Manager ()
|
||||
{
|
||||
int size = (36*1024*1024);
|
||||
u32 level;
|
||||
_CPU_ISR_Disable(level);
|
||||
size &= ~0x1f; // round down, because otherwise we may exceed the area
|
||||
void *mem2_heap_ptr = (void *)((u32)SYS_GetArena2Hi()-size);
|
||||
SYS_SetArena2Hi(mem2_heap_ptr);
|
||||
_CPU_ISR_Restore(level);
|
||||
size = __lwp_heap_init(&mem2_heap, mem2_heap_ptr, size, 32);
|
||||
return size;
|
||||
}
|
||||
|
||||
void* mem2_malloc(u32 size)
|
||||
{
|
||||
return __lwp_heap_allocate(&mem2_heap, size);
|
||||
}
|
||||
|
||||
bool mem2_free(void *ptr)
|
||||
{
|
||||
return __lwp_heap_free(&mem2_heap, ptr);
|
||||
}
|
||||
|
||||
#endif
|
22
source/mem2.h
Normal file
22
source/mem2.h
Normal file
@ -0,0 +1,22 @@
|
||||
/****************************************************************************
|
||||
* Visual Boy Advance GX
|
||||
*
|
||||
* Tantric 2010
|
||||
*
|
||||
* mem2.h
|
||||
*
|
||||
* MEM2 memory allocator
|
||||
***************************************************************************/
|
||||
|
||||
#ifdef HW_RVL
|
||||
|
||||
#ifndef _MEM2MANAGER_H_
|
||||
#define _MEM2MANAGER_H_
|
||||
|
||||
u32 InitMem2Manager ();
|
||||
void* mem2_malloc(u32 size);
|
||||
bool mem2_free(void *ptr);
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
@ -32,6 +32,7 @@
|
||||
#include "input.h"
|
||||
#include "video.h"
|
||||
#include "gamesettings.h"
|
||||
#include "mem2.h"
|
||||
#include "utils/usb2storage.h"
|
||||
#include "utils/mload.h"
|
||||
#include "utils/FreeTypeGX.h"
|
||||
@ -377,20 +378,21 @@ int main(int argc, char *argv[])
|
||||
InitialiseSound();
|
||||
InitialisePalette();
|
||||
DefaultSettings (); // Set defaults
|
||||
|
||||
// Initialize font system
|
||||
InitFreeType((u8*)font_ttf, font_ttf_size);
|
||||
gameScreenPng = (u8 *)malloc(512*1024);
|
||||
browserList = (BROWSERENTRY *)malloc(sizeof(BROWSERENTRY)*MAX_BROWSER_SIZE);
|
||||
InitGUIThreads();
|
||||
|
||||
// store path app was loaded from
|
||||
InitFreeType((u8*)font_ttf, font_ttf_size); // Initialize font system
|
||||
#ifdef HW_RVL
|
||||
if(argc > 0 && argv[0] != NULL)
|
||||
CreateAppPath(argv[0]);
|
||||
CreateAppPath(argv[0]); // store path app was loaded from
|
||||
|
||||
rom = (u8 *)malloc(1024*1024*32); // allocate 32 MB to GBA ROM
|
||||
InitMem2Manager();
|
||||
savebuffer = (unsigned char *)mem2_malloc(SAVEBUFFERSIZE);
|
||||
browserList = (BROWSERENTRY *)mem2_malloc(sizeof(BROWSERENTRY)*MAX_BROWSER_SIZE);
|
||||
rom = (u8 *)mem2_malloc(1024*1024*32); // allocate 32 MB to GBA ROM
|
||||
#else
|
||||
savebuffer = (unsigned char *)malloc(SAVEBUFFERSIZE);
|
||||
browserList = (BROWSERENTRY *)malloc(sizeof(BROWSERENTRY)*MAX_BROWSER_SIZE);
|
||||
#endif
|
||||
gameScreenPng = (u8 *)malloc(512*1024);
|
||||
InitGUIThreads();
|
||||
|
||||
while(1) // main loop
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user