Print unused memory to HUD

This commit is contained in:
Ryan Dwyer 2022-10-22 20:03:56 +10:00
parent d89fef7ea9
commit 4e9d88fab9
3 changed files with 26 additions and 0 deletions

View File

@ -87,6 +87,8 @@
#include "lib/lib_06440.h"
#include "lib/lib_317f0.h"
#include "lib/main.h"
#include "lib/mema.h"
#include "lib/memp.h"
#include "lib/mtx.h"
#include "lib/music.h"
#include "lib/rng.h"
@ -953,6 +955,8 @@ void lvFindThreats(void)
u8 g_LvShowRates = 0;
u8 g_LvAntialias = 1;
u8 g_LvRateIndex = 59;
u8 g_LvOom = 0;
u32 g_LvOomSize = 0;
u8 g_LvFrameRates[60];
void lvRecordRate(void)
@ -1067,6 +1071,17 @@ Gfx *lvPrintRateText(Gfx *gdl)
x = 10;
sprintf(buffer, "Antialias %s\n", g_LvAntialias ? "on" : "off");
gdl = textRender(gdl, &x, &y, buffer, g_CharsHandelGothicXs, g_FontHandelGothicXs, 0x00ff00a0, 0x000000a0, viGetWidth(), viGetHeight(), 0, 0);
sprintf(buffer, "mema free %d KB\n", memaGetLongestFree() / 1024);
gdl = textRender(gdl, &x, &y, buffer, g_CharsHandelGothicXs, g_FontHandelGothicXs, 0x00ff00a0, 0x000000a0, viGetWidth(), viGetHeight(), 0, 0);
sprintf(buffer, "memp free %d KB\n", mempGetStageFree() / 1024);
gdl = textRender(gdl, &x, &y, buffer, g_CharsHandelGothicXs, g_FontHandelGothicXs, 0x00ff00a0, 0x000000a0, viGetWidth(), viGetHeight(), 0, 0);
if (g_LvOom) {
sprintf(buffer, "mem%c OOM %x\n", g_LvOom, g_LvOomSize);
gdl = textRender(gdl, &x, &y, buffer, g_CharsHandelGothicXs, g_FontHandelGothicXs, 0xff0000a0, 0x000000a0, viGetWidth(), viGetHeight(), 0, 0);
}
}
return gdl;

View File

@ -620,6 +620,8 @@ glabel memaAlloc
);
#endif
#else
extern u8 g_LvOom;
void *memaAlloc(u32 size)
{
u32 addr;
@ -682,6 +684,7 @@ void *memaAlloc(u32 size)
}
if (curr->addr == 0xffffffff) {
g_LvOom = 'a';
return NULL;
}
}

View File

@ -171,6 +171,9 @@ void *mempAllocFromBank(struct memorypool *pool, u32 size, u8 poolnum)
return (void *)allocation;
}
extern u8 g_LvOom;
extern u32 g_LvOomSize;
void *mempAlloc(u32 len, u8 pool)
{
void *allocation = mempAllocFromBank(g_MempOnboardPools, len, pool);
@ -185,6 +188,11 @@ void *mempAlloc(u32 len, u8 pool)
return allocation;
}
if (pool != MEMPOOL_8 && pool != MEMPOOL_7 && len) {
g_LvOom = 'p';
g_LvOomSize = len;
}
#if VERSION < VERSION_NTSC_1_0
if (pool != MEMPOOL_8 && pool != MEMPOOL_7 && len) {
char buffer[80];