mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-07-29 19:18:58 -07:00
Allocate aligned heaps
This commit is contained in:
parent
06fd7f662a
commit
9a7c63c46c
4 changed files with 49 additions and 6 deletions
|
@ -2397,6 +2397,9 @@ void FileChoose_Destroy(GameState* thisx);
|
||||||
|
|
||||||
char* SetQuote();
|
char* SetQuote();
|
||||||
|
|
||||||
|
void Heaps_Alloc(void);
|
||||||
|
void Heaps_Free(void);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -237,8 +237,8 @@ extern void(*D_801755D0)(void);
|
||||||
extern u8 gGfxSPTaskYieldBuffer[OS_YIELD_DATA_SIZE]; // 0xC00 bytes
|
extern u8 gGfxSPTaskYieldBuffer[OS_YIELD_DATA_SIZE]; // 0xC00 bytes
|
||||||
extern u8 gGfxSPTaskStack[0x400]; // 0x400 bytes
|
extern u8 gGfxSPTaskStack[0x400]; // 0x400 bytes
|
||||||
extern GfxPool gGfxPools[2]; // 0x24820 bytes
|
extern GfxPool gGfxPools[2]; // 0x24820 bytes
|
||||||
extern u8 gAudioHeap[0x38000]; // 0x38000 bytes
|
extern u8* gAudioHeap;
|
||||||
extern u8 gSystemHeap[];
|
extern u8* gSystemHeap;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,7 +1,44 @@
|
||||||
#include "z64.h"
|
#include "z64.h"
|
||||||
|
#include <assert.h>
|
||||||
|
#include <malloc.h>
|
||||||
|
|
||||||
// 0x38000 bytes
|
#ifndef _MSC_VER
|
||||||
u8 gAudioHeap[0x38000];
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
//u8 gSystemHeap[UNK_SIZE];
|
#define AUDIO_HEAP_SIZE 0x38000
|
||||||
u8 gSystemHeap[1024 * 1024 * 128];
|
#define SYSTEM_HEAP_SIZE (1024 * 1024 * 128)
|
||||||
|
|
||||||
|
u8* gAudioHeap;
|
||||||
|
|
||||||
|
u8* gSystemHeap;
|
||||||
|
|
||||||
|
void Heaps_Alloc(void)
|
||||||
|
{
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
gAudioHeap = (u8*)_aligned_malloc(AUDIO_HEAP_SIZE, 16);
|
||||||
|
gSystemHeap = (u8*)_aligned_malloc(SYSTEM_HEAP_SIZE, 16);
|
||||||
|
#elif defined(_POSIX_VERSION) && (_POSIX_VERSION >= 200112L)
|
||||||
|
if (posix_memalign((void**)&gAudioHeap, 16, AUDIO_HEAP_SIZE) != 0)
|
||||||
|
gAudioHeap = NULL;
|
||||||
|
if (posix_memalign((void**)&gSystemHeap, 16, SYSTEM_HEAP_SIZE) != 0)
|
||||||
|
gSystemHeap = NULL;
|
||||||
|
#else
|
||||||
|
gAudioHeap = (u8*)memalign(16, AUDIO_HEAP_SIZE);
|
||||||
|
gSystemHeap = (u8*)memalign(16, SYSTEM_HEAP_SIZE);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
assert(gAudioHeap != NULL);
|
||||||
|
assert(gSystemHeap != NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Heaps_Free(void)
|
||||||
|
{
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
_aligned_free(gAudioHeap);
|
||||||
|
_aligned_free(gSystemHeap);
|
||||||
|
#else
|
||||||
|
free(gAudioHeap);
|
||||||
|
free(gSystemHeap);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
|
@ -63,6 +63,7 @@ void Main(void* arg) {
|
||||||
PreNmiBuff_Init(gAppNmiBufferPtr);
|
PreNmiBuff_Init(gAppNmiBufferPtr);
|
||||||
Fault_Init();
|
Fault_Init();
|
||||||
SysCfb_Init(0);
|
SysCfb_Init(0);
|
||||||
|
Heaps_Alloc();
|
||||||
sysHeap = gSystemHeap;
|
sysHeap = gSystemHeap;
|
||||||
fb = SysCfb_GetFbPtr(0);
|
fb = SysCfb_GetFbPtr(0);
|
||||||
gSystemHeapSize = 1024 * 1024 * 4;
|
gSystemHeapSize = 1024 * 1024 * 4;
|
||||||
|
@ -131,4 +132,6 @@ void Main(void* arg) {
|
||||||
osDestroyThread(&sGraphThread);
|
osDestroyThread(&sGraphThread);
|
||||||
func_800FBFD8();
|
func_800FBFD8();
|
||||||
osSyncPrintf("mainproc 実行終了\n"); // "End of execution"
|
osSyncPrintf("mainproc 実行終了\n"); // "End of execution"
|
||||||
|
|
||||||
|
Heaps_Free();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue