mirror of
https://gitlab.com/ryandwyer/perfect-dark
synced 2026-06-01 01:38:46 -04:00
Rename lib_121e0 to memory.c, rename symbols, introduce MEMPOOL constants and improve documentation
This commit is contained in:
+1
-1
@@ -29,7 +29,7 @@
|
||||
build/ROMID/lib/main.o (section); \
|
||||
build/ROMID/lib/lib_0e9d0.o (section); \
|
||||
build/ROMID/lib/lib_11420.o (section); \
|
||||
build/ROMID/lib/lib_121e0.o (section); \
|
||||
build/ROMID/lib/memory.o (section); \
|
||||
build/ROMID/lib/lib_126b0.o (section); \
|
||||
build/ROMID/lib/lib_12dc0.o (section); \
|
||||
build/ROMID/lib/lib_13130.o (section); \
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@
|
||||
#include "gvars/gvars.h"
|
||||
#include "lib/lib_04a80.h"
|
||||
#include "lib/main.h"
|
||||
#include "lib/lib_121e0.h"
|
||||
#include "lib/memory.h"
|
||||
#include "lib/lib_126b0.h"
|
||||
#include "lib/lib_12dc0.h"
|
||||
#include "lib/lib_16110.h"
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@
|
||||
#include "gvars/gvars.h"
|
||||
#include "lib/lib_09660.h"
|
||||
#include "lib/main.h"
|
||||
#include "lib/lib_121e0.h"
|
||||
#include "lib/memory.h"
|
||||
#include "lib/lib_12dc0.h"
|
||||
#include "lib/lib_13900.h"
|
||||
#include "lib/lib_159b0.h"
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@
|
||||
#include "game/wallhit.h"
|
||||
#include "gvars/gvars.h"
|
||||
#include "lib/lib_0e9d0.h"
|
||||
#include "lib/lib_121e0.h"
|
||||
#include "lib/memory.h"
|
||||
#include "lib/lib_12dc0.h"
|
||||
#include "lib/lib_16110.h"
|
||||
#include "lib/lib_2f490.h"
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "game/data/data_020df0.h"
|
||||
#include "game/data/data_02da90.h"
|
||||
#include "gvars/gvars.h"
|
||||
#include "lib/lib_121e0.h"
|
||||
#include "lib/memory.h"
|
||||
#include "types.h"
|
||||
|
||||
void explosionsInit(void)
|
||||
@@ -29,7 +29,7 @@ void explosionsInit(void)
|
||||
if (g_MaxExplosions == 0) {
|
||||
g_Explosions = NULL;
|
||||
} else {
|
||||
g_Explosions = malloc((g_MaxExplosions * sizeof(struct explosion) + 0xf) & ~0xf, 4);
|
||||
g_Explosions = malloc((g_MaxExplosions * sizeof(struct explosion) + 0xf) & ~0xf, MEMPOOL_STAGE);
|
||||
|
||||
for (i = 0; i < g_MaxExplosions; i++) {
|
||||
g_Explosions[i].prop = NULL;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "game/data/data_02a0e0.h"
|
||||
#include "game/data/data_02da90.h"
|
||||
#include "gvars/gvars.h"
|
||||
#include "lib/lib_121e0.h"
|
||||
#include "lib/memory.h"
|
||||
#include "types.h"
|
||||
|
||||
void func0f000000(void)
|
||||
@@ -17,8 +17,8 @@ void func0f000000(void)
|
||||
s32 i;
|
||||
|
||||
if (g_LanguageId != LANGUAGE_ENGLISH) {
|
||||
var800aabb4 = malloc(0x2e80, 6);
|
||||
var800aabb8 = malloc(0x100, 6);
|
||||
var800aabb4 = malloc(0x2e80, MEMPOOL_PERMANENT);
|
||||
var800aabb8 = malloc(0x100, MEMPOOL_PERMANENT);
|
||||
|
||||
for (i = 0; i < 0x7c; i++) {
|
||||
var800aabb8[i].unk00_00 = 0;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "game/data/data_02da90.h"
|
||||
#include "gvars/gvars.h"
|
||||
#include "lib/lib_0d0a0.h"
|
||||
#include "lib/lib_121e0.h"
|
||||
#include "lib/memory.h"
|
||||
#include "types.h"
|
||||
|
||||
void loadTextureList(void)
|
||||
@@ -19,7 +19,7 @@ void loadTextureList(void)
|
||||
|
||||
u32 len = ((&_texturesTableRomEnd - &_texturesTableRomStart) + 15) & -16;
|
||||
|
||||
g_Textures = malloc(len, 6);
|
||||
g_Textures = malloc(len, MEMPOOL_PERMANENT);
|
||||
|
||||
func0000d410(g_Textures, &_texturesTableRomStart, len);
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "game/game_166e40.h"
|
||||
#include "game/lang.h"
|
||||
#include "gvars/gvars.h"
|
||||
#include "lib/lib_121e0.h"
|
||||
#include "lib/memory.h"
|
||||
#include "types.h"
|
||||
|
||||
void stageLoadCommonLang(s32 stagenum)
|
||||
@@ -36,7 +36,7 @@ void stageLoadCommonLang(s32 stagenum)
|
||||
void func0f00b420(void)
|
||||
{
|
||||
var80062410 = 0;
|
||||
var8009cc80 = malloc(0x80, 4);
|
||||
var8009cc84 = malloc(0x80, 4);
|
||||
var8009cc88 = malloc(0x80, 4);
|
||||
var8009cc80 = malloc(0x80, MEMPOOL_STAGE);
|
||||
var8009cc84 = malloc(0x80, MEMPOOL_STAGE);
|
||||
var8009cc88 = malloc(0x80, MEMPOOL_STAGE);
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "game/game_00b820.h"
|
||||
#include "game/title.h"
|
||||
#include "gvars/gvars.h"
|
||||
#include "lib/lib_121e0.h"
|
||||
#include "lib/memory.h"
|
||||
#include "types.h"
|
||||
|
||||
void func0f00b480(void)
|
||||
@@ -28,7 +28,7 @@ void func0f00b480(void)
|
||||
g_TitleNextMode = TITLEMODE_SKIP;
|
||||
}
|
||||
|
||||
var8009cca0 = malloc(0x47800, 4);
|
||||
var8009cca0 = malloc(0x47800, MEMPOOL_STAGE);
|
||||
|
||||
func0f00b420();
|
||||
}
|
||||
@@ -47,7 +47,7 @@ void func0f00b510(void)
|
||||
g_ChrSlots = NULL;
|
||||
g_NumChrSlots = 0;
|
||||
|
||||
var80062a8c = malloc(sizeof(struct var80062a8c) * 20, 4);
|
||||
var80062a8c = malloc(sizeof(struct var80062a8c) * 20, MEMPOOL_STAGE);
|
||||
|
||||
for (i = 0; i < 20; i++) {
|
||||
var80062a8c[i].prop = NULL;
|
||||
@@ -57,12 +57,12 @@ void func0f00b510(void)
|
||||
g_NumChrs = 0;
|
||||
g_Chrnums = NULL;
|
||||
g_ChrIndexes = NULL;
|
||||
var80062960 = malloc(0x1470, 4);
|
||||
var80062960 = malloc(0x1470, MEMPOOL_STAGE);
|
||||
|
||||
for (i = 0; i < 20; i++) {
|
||||
// @bug? Should the ALIGN64 should surely be applied before malloc...?
|
||||
// Not a bug if only 0x200 bytes are being used
|
||||
var8009ccc0[i] = (void *)ALIGN64(malloc(0x240, 4));
|
||||
var8009ccc0[i] = (void *)ALIGN64(malloc(0x240, MEMPOOL_STAGE));
|
||||
}
|
||||
|
||||
resetSomeStageThings();
|
||||
@@ -73,7 +73,7 @@ void func0f00b62c(s32 numchrs)
|
||||
s32 i;
|
||||
|
||||
g_NumChrSlots = PLAYERCOUNT() + numchrs + 10;
|
||||
g_ChrSlots = malloc(ALIGN16(g_NumChrSlots * sizeof(struct chrdata)), 4);
|
||||
g_ChrSlots = malloc(ALIGN16(g_NumChrSlots * sizeof(struct chrdata)), MEMPOOL_STAGE);
|
||||
|
||||
for (i = 0; i < g_NumChrSlots; i++) {
|
||||
g_ChrSlots[i].chrnum = -1;
|
||||
@@ -82,8 +82,8 @@ void func0f00b62c(s32 numchrs)
|
||||
}
|
||||
|
||||
g_NumChrs = 0;
|
||||
g_Chrnums = malloc(ALIGN16(g_NumChrSlots * 2), 4);
|
||||
g_ChrIndexes = malloc(ALIGN16(g_NumChrSlots * 2), 4);
|
||||
g_Chrnums = malloc(ALIGN16(g_NumChrSlots * 2), MEMPOOL_STAGE);
|
||||
g_ChrIndexes = malloc(ALIGN16(g_NumChrSlots * 2), MEMPOOL_STAGE);
|
||||
|
||||
for (i = 0; i < g_NumChrSlots; i++) {
|
||||
g_Chrnums[i] = -1;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "game/game_02cde0.h"
|
||||
#include "game/game_091e10.h"
|
||||
#include "gvars/gvars.h"
|
||||
#include "lib/lib_121e0.h"
|
||||
#include "lib/memory.h"
|
||||
#include "lib/lib_12dc0.h"
|
||||
#include "types.h"
|
||||
|
||||
@@ -405,8 +405,8 @@ void stageAllocateBgChrs(void)
|
||||
struct chrdata blankchr = {0};
|
||||
|
||||
// Allocate BG chrs
|
||||
g_BgChrs = malloc(ALIGN16(g_NumBgChrs * sizeof(struct chrdata)), 4);
|
||||
g_BgChrnums = malloc(ALIGN16(g_NumBgChrs * sizeof(s16)), 4);
|
||||
g_BgChrs = malloc(ALIGN16(g_NumBgChrs * sizeof(struct chrdata)), MEMPOOL_STAGE);
|
||||
g_BgChrnums = malloc(ALIGN16(g_NumBgChrs * sizeof(s16)), MEMPOOL_STAGE);
|
||||
|
||||
// Initialise BG chrs
|
||||
i = 0;
|
||||
@@ -463,8 +463,8 @@ void stageAllocateBgChrs(void)
|
||||
}
|
||||
}
|
||||
|
||||
g_TeamList = malloc(0x210, 4);
|
||||
g_SquadronList = malloc(0x220, 4);
|
||||
g_TeamList = malloc(0x210, MEMPOOL_STAGE);
|
||||
g_SquadronList = malloc(0x220, MEMPOOL_STAGE);
|
||||
}
|
||||
|
||||
GLOBAL_ASM(
|
||||
|
||||
@@ -10,15 +10,15 @@
|
||||
#include "game/game_00c240.h"
|
||||
#include "game/game_0601b0.h"
|
||||
#include "gvars/gvars.h"
|
||||
#include "lib/lib_121e0.h"
|
||||
#include "lib/memory.h"
|
||||
#include "types.h"
|
||||
|
||||
void gvarsInitProps(void)
|
||||
{
|
||||
s32 i;
|
||||
|
||||
g_Vars.props = malloc(ALIGN64(g_Vars.maxprops * sizeof(struct prop)), 4);
|
||||
g_Vars.tangibleprops = malloc(ALIGN64(200 * sizeof(void *)), 4);
|
||||
g_Vars.props = malloc(ALIGN64(g_Vars.maxprops * sizeof(struct prop)), MEMPOOL_STAGE);
|
||||
g_Vars.tangibleprops = malloc(ALIGN64(200 * sizeof(void *)), MEMPOOL_STAGE);
|
||||
|
||||
var80069880 = 1;
|
||||
|
||||
@@ -64,8 +64,8 @@ void func0f00c390(void)
|
||||
s32 i;
|
||||
s32 j;
|
||||
|
||||
var8009cda0 = malloc(ALIGN16(g_Vars.roomcount * 2), 4);
|
||||
var8009cda4 = malloc(256 * sizeof(struct var8009cda4), 4);
|
||||
var8009cda0 = malloc(ALIGN16(g_Vars.roomcount * 2), MEMPOOL_STAGE);
|
||||
var8009cda4 = malloc(256 * sizeof(struct var8009cda4), MEMPOOL_STAGE);
|
||||
|
||||
for (i = 0; i < g_Vars.roomcount; i++) {
|
||||
var8009cda0[i] = -1;
|
||||
|
||||
+12
-12
@@ -37,7 +37,7 @@
|
||||
#include "game/pad.h"
|
||||
#include "game/propobj.h"
|
||||
#include "gvars/gvars.h"
|
||||
#include "lib/lib_121e0.h"
|
||||
#include "lib/memory.h"
|
||||
#include "lib/lib_12dc0.h"
|
||||
#include "lib/lib_159b0.h"
|
||||
#include "lib/lib_16110.h"
|
||||
@@ -717,7 +717,7 @@ void setupInit(void)
|
||||
if (var8009ce40 == 0) {
|
||||
var8009ce58 = NULL;
|
||||
} else {
|
||||
var8009ce58 = malloc(ALIGN16(var8009ce40 * sizeof(struct var8009ce58)), 4);
|
||||
var8009ce58 = malloc(ALIGN16(var8009ce40 * sizeof(struct var8009ce58)), MEMPOOL_STAGE);
|
||||
|
||||
for (i = 0; i < var8009ce40; i++) {
|
||||
var8009ce58[i].base.prop = NULL;
|
||||
@@ -729,7 +729,7 @@ void setupInit(void)
|
||||
if (var8009ce44 == 0) {
|
||||
var8009ce5c = NULL;
|
||||
} else {
|
||||
var8009ce5c = malloc(ALIGN16(var8009ce44 * sizeof(struct defaultobj)), 4);
|
||||
var8009ce5c = malloc(ALIGN16(var8009ce44 * sizeof(struct defaultobj)), MEMPOOL_STAGE);
|
||||
|
||||
for (i = 0; i < var8009ce44; i++) {
|
||||
var8009ce5c[i].prop = NULL;
|
||||
@@ -741,7 +741,7 @@ void setupInit(void)
|
||||
if (var8009ce48 == 0) {
|
||||
var8009ce60 = 0;
|
||||
} else {
|
||||
var8009ce60 = malloc(ALIGN16(var8009ce48 * sizeof(struct var8009ce60)), 4);
|
||||
var8009ce60 = malloc(ALIGN16(var8009ce48 * sizeof(struct var8009ce60)), MEMPOOL_STAGE);
|
||||
|
||||
for (i = 0; i < var8009ce48; i++) {
|
||||
var8009ce60[i].base.prop = NULL;
|
||||
@@ -751,7 +751,7 @@ void setupInit(void)
|
||||
if (var8009ce4c == 0) {
|
||||
var8009ce64 = 0;
|
||||
} else {
|
||||
var8009ce64 = malloc(ALIGN16(var8009ce4c * sizeof(struct defaultobj)), 4);
|
||||
var8009ce64 = malloc(ALIGN16(var8009ce4c * sizeof(struct defaultobj)), MEMPOOL_STAGE);
|
||||
|
||||
for (i = 0; i < var8009ce4c; i++) {
|
||||
var8009ce64[i].prop = NULL;
|
||||
@@ -761,7 +761,7 @@ void setupInit(void)
|
||||
if (g_NumProjectiles == 0) {
|
||||
g_Projectiles = 0;
|
||||
} else {
|
||||
g_Projectiles = malloc(ALIGN16(g_NumProjectiles * sizeof(struct projectile)), 4);
|
||||
g_Projectiles = malloc(ALIGN16(g_NumProjectiles * sizeof(struct projectile)), MEMPOOL_STAGE);
|
||||
|
||||
for (i = 0; i < g_NumProjectiles; i++) {
|
||||
g_Projectiles[i].flags = PROJECTILEFLAG_FREE;
|
||||
@@ -771,7 +771,7 @@ void setupInit(void)
|
||||
if (g_NumMonitorThings == 0) {
|
||||
g_MonitorThings = 0;
|
||||
} else {
|
||||
g_MonitorThings = malloc(ALIGN16(g_NumMonitorThings * sizeof(struct monitorthing)), 4);
|
||||
g_MonitorThings = malloc(ALIGN16(g_NumMonitorThings * sizeof(struct monitorthing)), MEMPOOL_STAGE);
|
||||
|
||||
for (i = 0; i < g_NumMonitorThings; i++) {
|
||||
g_MonitorThings[i].flags = 0x00000001;
|
||||
@@ -795,8 +795,8 @@ void setupInit(void)
|
||||
|
||||
g_MaxThrownLaptops = g_Vars.normmplayerisrunning ? 12 : PLAYERCOUNT();
|
||||
|
||||
g_ThrownLaptops = malloc(ALIGN16(g_MaxThrownLaptops * sizeof(struct autogunobj)), 4);
|
||||
var8006996c = malloc(ALIGN16(g_MaxThrownLaptops * 0x2c), 4);
|
||||
g_ThrownLaptops = malloc(ALIGN16(g_MaxThrownLaptops * sizeof(struct autogunobj)), MEMPOOL_STAGE);
|
||||
var8006996c = malloc(ALIGN16(g_MaxThrownLaptops * 0x2c), MEMPOOL_STAGE);
|
||||
|
||||
for (i = 0; i < g_MaxThrownLaptops; i++) {
|
||||
g_ThrownLaptops[i].base.prop = NULL;
|
||||
@@ -1650,7 +1650,7 @@ void setupAutogun(struct autogunobj *autogun, s32 cmdindex)
|
||||
autogun->unk84 = *(s32 *)&autogun->unk84 * 100.0f / 65536.0f;
|
||||
autogun->unk64 = *(s32 *)&autogun->unk64 * M_BADTAU / 65536.0f;
|
||||
autogun->unk68 = *(s32 *)&autogun->unk68 * M_BADTAU / 65536.0f;
|
||||
autogun->bullettail = malloc(ALIGN16(sizeof(struct bullettail)), 4);
|
||||
autogun->bullettail = malloc(ALIGN16(sizeof(struct bullettail)), MEMPOOL_STAGE);
|
||||
autogun->bullettail->age = -1;
|
||||
autogun->unk5e = 0;
|
||||
autogun->ammoquantity = 255;
|
||||
@@ -3379,8 +3379,8 @@ void setupParseObjects(s32 stagenum)
|
||||
chopper->patroltimer60 = 0;
|
||||
chopper->cw = 0;
|
||||
chopper->weaponsarmed = true;
|
||||
chopper->fireslotthing = malloc(sizeof(struct fireslotthing), 4);
|
||||
chopper->fireslotthing->bullettail = malloc(ALIGN16(sizeof(struct bullettail)), 4);
|
||||
chopper->fireslotthing = malloc(sizeof(struct fireslotthing), MEMPOOL_STAGE);
|
||||
chopper->fireslotthing->bullettail = malloc(ALIGN16(sizeof(struct bullettail)), MEMPOOL_STAGE);
|
||||
chopper->fireslotthing->bullettail->age = -1;
|
||||
chopper->fireslotthing->unk08 = -1;
|
||||
chopper->fireslotthing->unk00 = 0;
|
||||
|
||||
@@ -8,14 +8,14 @@
|
||||
#include "game/data/data_020df0.h"
|
||||
#include "game/data/data_02da90.h"
|
||||
#include "gvars/gvars.h"
|
||||
#include "lib/lib_121e0.h"
|
||||
#include "lib/memory.h"
|
||||
#include "types.h"
|
||||
|
||||
void func0f0108d0(void)
|
||||
{
|
||||
s32 i;
|
||||
|
||||
var8006ae10 = malloc(ALIGN16((IS4MB() ? 30 : 40) * sizeof(struct var8006ae10)), 4);
|
||||
var8006ae10 = malloc(ALIGN16((IS4MB() ? 30 : 40) * sizeof(struct var8006ae10)), MEMPOOL_STAGE);
|
||||
|
||||
for (i = 0; i < (IS4MB() ? 30 : 40); i++) {
|
||||
var8006ae10[i].unk30 = 1;
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "game/game_097ba0.h"
|
||||
#include "game/game_1655c0.h"
|
||||
#include "gvars/gvars.h"
|
||||
#include "lib/lib_121e0.h"
|
||||
#include "lib/memory.h"
|
||||
#include "types.h"
|
||||
|
||||
GLOBAL_ASM(
|
||||
@@ -223,7 +223,7 @@ void func0f010bb0(void)
|
||||
i = ALIGN16(func0f09ddfc());
|
||||
}
|
||||
|
||||
g_Vars.currentplayer->unk158c = malloc(i, 4);
|
||||
g_Vars.currentplayer->unk158c = malloc(i, MEMPOOL_STAGE);
|
||||
g_Vars.currentplayer->unk159c = 0;
|
||||
g_Vars.currentplayer->unk15a0 = 0;
|
||||
g_Vars.currentplayer->unk15a4 = 0;
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#include "game/mplayer/mplayer.h"
|
||||
#include "game/pad.h"
|
||||
#include "gvars/gvars.h"
|
||||
#include "lib/lib_121e0.h"
|
||||
#include "lib/memory.h"
|
||||
#include "lib/lib_16110.h"
|
||||
#include "lib/lib_233c0.h"
|
||||
#include "types.h"
|
||||
@@ -410,7 +410,7 @@ void currentPlayerInitEyespy(void)
|
||||
prop = propAllocateEyespy(&pad, pad.room);
|
||||
|
||||
if (prop) {
|
||||
g_Vars.currentplayer->eyespy = malloc(sizeof(struct eyespy), 4);
|
||||
g_Vars.currentplayer->eyespy = malloc(sizeof(struct eyespy), MEMPOOL_STAGE);
|
||||
|
||||
if (g_Vars.currentplayer->eyespy) {
|
||||
g_Vars.currentplayer->eyespy->prop = prop;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "game/data/data_02da90.h"
|
||||
#include "game/pad.h"
|
||||
#include "gvars/gvars.h"
|
||||
#include "lib/lib_121e0.h"
|
||||
#include "lib/memory.h"
|
||||
#include "types.h"
|
||||
|
||||
GLOBAL_ASM(
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "game/data/data_020df0.h"
|
||||
#include "game/data/data_02da90.h"
|
||||
#include "gvars/gvars.h"
|
||||
#include "lib/lib_121e0.h"
|
||||
#include "lib/memory.h"
|
||||
#include "types.h"
|
||||
|
||||
/**
|
||||
@@ -98,7 +98,7 @@ void func0f013550(void)
|
||||
numberssize += 0xf;
|
||||
numberssize &= ~0xf;
|
||||
|
||||
ptr = malloc(structssize + numberssize, 4);
|
||||
ptr = malloc(structssize + numberssize, MEMPOOL_STAGE);
|
||||
|
||||
var8009cc40 = ptr;
|
||||
var800a41b0 = (struct var800a41b0 *)((u32)ptr + numberssize);
|
||||
@@ -144,7 +144,7 @@ void func0f0139f0(void)
|
||||
if (var800a45c0 == 0) {
|
||||
var800a45c4 = 0;
|
||||
} else {
|
||||
var800a45c4 = malloc(var800a45c0 * sizeof(struct var800a45c4) + 0xf & ~0xf, 4);
|
||||
var800a45c4 = malloc(var800a45c0 * sizeof(struct var800a45c4) + 0xf & ~0xf, MEMPOOL_STAGE);
|
||||
|
||||
for (i = 0; i < var800a45c0; i++) {
|
||||
var800a45c4[i].unk04 = 0;
|
||||
@@ -182,7 +182,7 @@ void func0f013ba0(void)
|
||||
}
|
||||
|
||||
if (num > 0) {
|
||||
var8007e3d0[i].unk24 = malloc(num * sizeof(struct var8007e3d0_data), 4);
|
||||
var8007e3d0[i].unk24 = malloc(num * sizeof(struct var8007e3d0_data), MEMPOOL_STAGE);
|
||||
}
|
||||
|
||||
for (j = 0; j < num; j++) {
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "game/pad.h"
|
||||
#include "gvars/gvars.h"
|
||||
#include "lib/lib_04790.h"
|
||||
#include "lib/lib_121e0.h"
|
||||
#include "lib/memory.h"
|
||||
#include "lib/lib_233c0.h"
|
||||
#include "types.h"
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "game/game_197600.h"
|
||||
#include "game/mplayer/mplayer.h"
|
||||
#include "gvars/gvars.h"
|
||||
#include "lib/lib_121e0.h"
|
||||
#include "lib/memory.h"
|
||||
#include "lib/lib_12dc0.h"
|
||||
#include "lib/lib_16110.h"
|
||||
#include "lib/lib_1a500.h"
|
||||
@@ -489,7 +489,7 @@ void aibotAllocateUnk014(struct chrdata *chr, s32 count)
|
||||
}
|
||||
|
||||
chr->aibot->unk018 = count;
|
||||
chr->aibot->unk014 = malloc(ALIGN16(count * sizeof(struct aibot014)), 4);
|
||||
chr->aibot->unk014 = malloc(ALIGN16(count * sizeof(struct aibot014)), MEMPOOL_STAGE);
|
||||
|
||||
func0f197c00(chr);
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#include "game/pad.h"
|
||||
#include "game/propobj.h"
|
||||
#include "gvars/gvars.h"
|
||||
#include "lib/lib_121e0.h"
|
||||
#include "lib/memory.h"
|
||||
#include "lib/lib_126b0.h"
|
||||
#include "lib/lib_12dc0.h"
|
||||
#include "lib/lib_16110.h"
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#include "game/propobj.h"
|
||||
#include "gvars/gvars.h"
|
||||
#include "lib/lib_0d0a0.h"
|
||||
#include "lib/lib_121e0.h"
|
||||
#include "lib/memory.h"
|
||||
#include "lib/lib_12dc0.h"
|
||||
#include "lib/lib_13130.h"
|
||||
#include "lib/lib_159b0.h"
|
||||
@@ -84,7 +84,7 @@ void tagsAllocatePtrs(void)
|
||||
|
||||
if (g_NumTags) {
|
||||
u32 size = index * 4;
|
||||
g_TagPtrs = malloc(ALIGN16(size), 4);
|
||||
g_TagPtrs = malloc(ALIGN16(size), MEMPOOL_STAGE);
|
||||
|
||||
for (index = 0; index < g_NumTags; index++) {
|
||||
g_TagPtrs[index] = NULL;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "game/data/data_02da90.h"
|
||||
#include "game/game_0b28d0.h"
|
||||
#include "gvars/gvars.h"
|
||||
#include "lib/lib_121e0.h"
|
||||
#include "lib/memory.h"
|
||||
#include "lib/lib_1a500.h"
|
||||
#include "types.h"
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@
|
||||
#include "lib/lib_09660.h"
|
||||
#include "lib/main.h"
|
||||
#include "lib/lib_0e9d0.h"
|
||||
#include "lib/lib_121e0.h"
|
||||
#include "lib/memory.h"
|
||||
#include "lib/lib_12dc0.h"
|
||||
#include "lib/lib_13900.h"
|
||||
#include "lib/lib_159b0.h"
|
||||
@@ -501,7 +501,7 @@ glabel acousticReset
|
||||
//
|
||||
// osSyncPrintf("Acoustic Reset -> Allocating %d bytes for %d roomacousticdata structures\n", size, g_Vars.roomcount);
|
||||
//
|
||||
// g_RoomAcousticData = malloc(size, 4);
|
||||
// g_RoomAcousticData = malloc(size, MEMPOOL_STAGE);
|
||||
//
|
||||
// for (i = 0; i < g_Vars.roomcount; i++) {
|
||||
// bool allgood = true;
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include "gvars/gvars.h"
|
||||
#include "lib/lib_09660.h"
|
||||
#include "lib/lib_0e9d0.h"
|
||||
#include "lib/lib_121e0.h"
|
||||
#include "lib/memory.h"
|
||||
#include "lib/lib_13130.h"
|
||||
#include "lib/lib_16110.h"
|
||||
#include "lib/lib_4a360.h"
|
||||
@@ -1591,7 +1591,7 @@ void hudmsgSystemInit(void)
|
||||
s32 i;
|
||||
|
||||
g_NumHudMessages = g_Vars.mplayerisrunning ? 20 : 8;
|
||||
g_HudMessages = malloc((sizeof(struct hudmessage) * g_NumHudMessages + 0x3f | 0x3f) ^ 0x3f, 4);
|
||||
g_HudMessages = malloc((sizeof(struct hudmessage) * g_NumHudMessages + 0x3f | 0x3f) ^ 0x3f, MEMPOOL_STAGE);
|
||||
|
||||
for (i = 0; i < g_NumHudMessages; i++) {
|
||||
g_HudMessages[i].state = HUDMSGSTATE_FREE;
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
#include "lib/lib_09660.h"
|
||||
#include "lib/main.h"
|
||||
#include "lib/lib_0e9d0.h"
|
||||
#include "lib/lib_121e0.h"
|
||||
#include "lib/memory.h"
|
||||
#include "lib/lib_12dc0.h"
|
||||
#include "lib/lib_13130.h"
|
||||
#include "lib/lib_13900.h"
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "game/game_127910.h"
|
||||
#include "game/propobj.h"
|
||||
#include "gvars/gvars.h"
|
||||
#include "lib/lib_121e0.h"
|
||||
#include "lib/memory.h"
|
||||
#include "lib/lib_12dc0.h"
|
||||
#include "types.h"
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "game/game_13b670.h"
|
||||
#include "gvars/gvars.h"
|
||||
#include "lib/main.h"
|
||||
#include "lib/lib_121e0.h"
|
||||
#include "lib/memory.h"
|
||||
#include "lib/lib_16110.h"
|
||||
#include "types.h"
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#include "lib/lib_09660.h"
|
||||
#include "lib/lib_0d0a0.h"
|
||||
#include "lib/main.h"
|
||||
#include "lib/lib_121e0.h"
|
||||
#include "lib/memory.h"
|
||||
#include "lib/lib_4a360.h"
|
||||
#include "types.h"
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
#include "lib/lib_09660.h"
|
||||
#include "lib/lib_0d0a0.h"
|
||||
#include "lib/main.h"
|
||||
#include "lib/lib_121e0.h"
|
||||
#include "lib/memory.h"
|
||||
#include "lib/lib_126b0.h"
|
||||
#include "lib/lib_12dc0.h"
|
||||
#include "lib/lib_159b0.h"
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "gvars/gvars.h"
|
||||
#include "lib/lib_074f0.h"
|
||||
#include "lib/lib_0d0a0.h"
|
||||
#include "lib/lib_121e0.h"
|
||||
#include "lib/memory.h"
|
||||
#include "lib/lib_12dc0.h"
|
||||
#include "lib/lib_13130.h"
|
||||
#include "types.h"
|
||||
@@ -315,12 +315,12 @@ glabel func0f1670fc
|
||||
// }
|
||||
//
|
||||
// // 174
|
||||
// ptr = malloc(info->unk00, 4);
|
||||
// ptr = malloc(info->unk00, MEMPOOL_STAGE);
|
||||
// info->unk04 = info->unk00;
|
||||
// func0f166eb4(ptr, info->unk00, &filetable[filenum], info);
|
||||
//
|
||||
// if (arg1 != 0x11) {
|
||||
// memReallocate(ptr, info->unk00, 4);
|
||||
// memReallocate(ptr, info->unk00, MEMPOOL_STAGE);
|
||||
// }
|
||||
// } else {
|
||||
// while (true) {
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "lib/lib_074f0.h"
|
||||
#include "lib/lib_0d0a0.h"
|
||||
#include "lib/main.h"
|
||||
#include "lib/lib_121e0.h"
|
||||
#include "lib/memory.h"
|
||||
#include "lib/lib_48120.h"
|
||||
#include "lib/lib_4b170.h"
|
||||
#include "lib/lib_4e470.h"
|
||||
@@ -5591,7 +5591,7 @@ glabel func0f173010
|
||||
/* f173320: 2484002f */ addiu $a0,$a0,0x2f
|
||||
/* f173324: 348c000f */ ori $t4,$a0,0xf
|
||||
/* f173328: 3984000f */ xori $a0,$t4,0xf
|
||||
/* f17332c: 0c004991 */ jal func00012644
|
||||
/* f17332c: 0c004991 */ jal mallocFromRight
|
||||
/* f173330: afa31490 */ sw $v1,0x1490($sp)
|
||||
/* f173334: ae02000c */ sw $v0,0xc($s0)
|
||||
/* f173338: afa20034 */ sw $v0,0x34($sp)
|
||||
@@ -6084,7 +6084,7 @@ glabel texturesLoadConfigs
|
||||
// u32 len = &_textureconfigSegmentEnd - &_textureconfigSegmentStart;
|
||||
// s32 i;
|
||||
//
|
||||
// g_TextureConfigSegment = malloc(len, 4);
|
||||
// g_TextureConfigSegment = malloc(len, MEMPOOL_STAGE);
|
||||
// func0000d410(g_TextureConfigSegment, &_textureconfigSegmentRomStart, len);
|
||||
//
|
||||
// var800ab550 = (u32)((u32)g_TextureConfigSegment - (u32)&_textureconfigSegmentStart);
|
||||
@@ -6110,7 +6110,7 @@ glabel texturesLoadConfigs
|
||||
// var800ab5ac = (struct textureconfig *)((u32)g_TextureConfigSegment - (u32)&_textureconfigSegmentStart + 0xb44);
|
||||
//
|
||||
// var800ab558 = (len - ((u32)&_textureconfigSegmentStart + 0x1c0)) + (u32)&_textureconfigSegmentStart;
|
||||
// var800ab55c = malloc(align16(var800ab558), 4);
|
||||
// var800ab55c = malloc(align16(var800ab558), MEMPOOL_STAGE);
|
||||
//
|
||||
// for (i = 0; i < var800ab558; i++) {
|
||||
// var800ab55c[i].texturenum = 0;
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "game/game_166e40.h"
|
||||
#include "game/game_175f90.h"
|
||||
#include "gvars/gvars.h"
|
||||
#include "lib/lib_121e0.h"
|
||||
#include "lib/memory.h"
|
||||
#include "types.h"
|
||||
|
||||
void func0f175f90(void)
|
||||
@@ -21,13 +21,13 @@ void func0f175f90(void)
|
||||
void func0f175f98(void)
|
||||
{
|
||||
func0f167330();
|
||||
memResetPool(5);
|
||||
memResetPool(MEMPOOL_5);
|
||||
func0f1672f0(5);
|
||||
}
|
||||
|
||||
void func0f175fc8(void)
|
||||
{
|
||||
memDisablePool(5);
|
||||
memDisablePool(MEMPOOL_5);
|
||||
func0f1672f0(5);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "game/pdoptions.h"
|
||||
#include "gvars/gvars.h"
|
||||
#include "lib/lib_09660.h"
|
||||
#include "lib/lib_121e0.h"
|
||||
#include "lib/memory.h"
|
||||
#include "types.h"
|
||||
|
||||
GLOBAL_ASM(
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "gvars/gvars.h"
|
||||
#include "lib/lib_074f0.h"
|
||||
#include "lib/lib_0d0a0.h"
|
||||
#include "lib/lib_121e0.h"
|
||||
#include "lib/memory.h"
|
||||
#include "lib/lib_12dc0.h"
|
||||
#include "lib/lib_13130.h"
|
||||
#include "types.h"
|
||||
@@ -83,12 +83,12 @@ void gfxInitMemory(void)
|
||||
}
|
||||
|
||||
// %d Players : Allocating %d bytes for master dl's\n
|
||||
g_GfxBuffers[0] = malloc(g_GfxSizesByPlayerCount[PLAYERCOUNT() - 1] * 2, 4);
|
||||
g_GfxBuffers[0] = malloc(g_GfxSizesByPlayerCount[PLAYERCOUNT() - 1] * 2, MEMPOOL_STAGE);
|
||||
g_GfxBuffers[1] = g_GfxBuffers[0] + g_GfxSizesByPlayerCount[PLAYERCOUNT() - 1];
|
||||
g_GfxBuffers[2] = g_GfxBuffers[1] + g_GfxSizesByPlayerCount[PLAYERCOUNT() - 1];
|
||||
|
||||
// Allocating %d bytes for mtxvtx space\n
|
||||
g_VtxBuffers[0] = malloc(g_VtxSizesByPlayerCount[PLAYERCOUNT() - 1] * 2, 4);
|
||||
g_VtxBuffers[0] = malloc(g_VtxSizesByPlayerCount[PLAYERCOUNT() - 1] * 2, MEMPOOL_STAGE);
|
||||
g_VtxBuffers[1] = g_VtxBuffers[0] + g_VtxSizesByPlayerCount[PLAYERCOUNT() - 1];
|
||||
g_VtxBuffers[2] = g_VtxBuffers[1] + g_VtxSizesByPlayerCount[PLAYERCOUNT() - 1];
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "game/inventory/init.h"
|
||||
#include "game/inventory/inventory.h"
|
||||
#include "gvars/gvars.h"
|
||||
#include "lib/lib_121e0.h"
|
||||
#include "lib/memory.h"
|
||||
#include "types.h"
|
||||
|
||||
void invInitGunsHeld(void)
|
||||
@@ -33,6 +33,6 @@ void invInitGunsHeld(void)
|
||||
void invInit(s32 numdoubles)
|
||||
{
|
||||
g_Vars.currentplayer->equipmaxitems = numdoubles + 30;
|
||||
g_Vars.currentplayer->equipment = malloc(ALIGN16(g_Vars.currentplayer->equipmaxitems * sizeof(struct invitem)), 4);
|
||||
g_Vars.currentplayer->equipment = malloc(ALIGN16(g_Vars.currentplayer->equipmaxitems * sizeof(struct invitem)), MEMPOOL_STAGE);
|
||||
invClear();
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
#include "gvars/gvars.h"
|
||||
#include "lib/lib_09660.h"
|
||||
#include "lib/lib_0e9d0.h"
|
||||
#include "lib/lib_121e0.h"
|
||||
#include "lib/memory.h"
|
||||
#include "lib/lib_12dc0.h"
|
||||
#include "lib/lib_13130.h"
|
||||
#include "lib/lib_159b0.h"
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
#include "gvars/gvars.h"
|
||||
#include "lib/lib_09660.h"
|
||||
#include "lib/lib_0e9d0.h"
|
||||
#include "lib/lib_121e0.h"
|
||||
#include "lib/memory.h"
|
||||
#include "lib/lib_12dc0.h"
|
||||
#include "lib/lib_13130.h"
|
||||
#include "lib/lib_159b0.h"
|
||||
|
||||
+2
-2
@@ -19,7 +19,7 @@
|
||||
#include "lib/lib_06440.h"
|
||||
#include "lib/lib_06550.h"
|
||||
#include "lib/main.h"
|
||||
#include "lib/lib_121e0.h"
|
||||
#include "lib/memory.h"
|
||||
#include "lib/lib_12dc0.h"
|
||||
#include "lib/lib_13130.h"
|
||||
#include "lib/lib_13900.h"
|
||||
@@ -4267,7 +4267,7 @@ void func0f11a32c(s8 device, u8 arg1, u32 line, char *file)
|
||||
|
||||
if ((var800a2380[device].unk014 & 1) && var800a2380[device].unk2c0 == NULL) {
|
||||
var800a2380[device].unk2be = 0;
|
||||
var800a2380[device].unk2c0 = malloc(align32(0x708), 6);
|
||||
var800a2380[device].unk2c0 = malloc(align32(0x708), MEMPOOL_PERMANENT);
|
||||
|
||||
// This would have been used in an osSyncPrintf call.
|
||||
// Perhaps using the strings at var7f1b4318 through var7f1b43ac?
|
||||
|
||||
+1
-1
@@ -70,7 +70,7 @@
|
||||
#include "lib/lib_0d0a0.h"
|
||||
#include "lib/main.h"
|
||||
#include "lib/lib_0e9d0.h"
|
||||
#include "lib/lib_121e0.h"
|
||||
#include "lib/memory.h"
|
||||
#include "lib/lib_12dc0.h"
|
||||
#include "lib/lib_13130.h"
|
||||
#include "lib/lib_159b0.h"
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@
|
||||
#include "gvars/gvars.h"
|
||||
#include "lib/lib_04790.h"
|
||||
#include "lib/lib_09660.h"
|
||||
#include "lib/lib_121e0.h"
|
||||
#include "lib/memory.h"
|
||||
#include "lib/lib_12dc0.h"
|
||||
#include "lib/lib_159b0.h"
|
||||
#include "lib/lib_16110.h"
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "game/data/data_020df0.h"
|
||||
#include "game/data/data_02da90.h"
|
||||
#include "gvars/gvars.h"
|
||||
#include "lib/lib_121e0.h"
|
||||
#include "lib/memory.h"
|
||||
#include "types.h"
|
||||
|
||||
void smokeInit(void)
|
||||
@@ -25,7 +25,7 @@ void smokeInit(void)
|
||||
if (g_MaxSmokes == 0) {
|
||||
g_Smokes = NULL;
|
||||
} else {
|
||||
g_Smokes = malloc(g_MaxSmokes * sizeof(struct smoke), 4);
|
||||
g_Smokes = malloc(g_MaxSmokes * sizeof(struct smoke), MEMPOOL_STAGE);
|
||||
|
||||
for (i = 0; i < g_MaxSmokes; i++) {
|
||||
g_Smokes[i].prop = NULL;
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
#include "lib/lib_0d0a0.h"
|
||||
#include "lib/main.h"
|
||||
#include "lib/lib_0e9d0.h"
|
||||
#include "lib/lib_121e0.h"
|
||||
#include "lib/memory.h"
|
||||
#include "lib/lib_12dc0.h"
|
||||
#include "lib/lib_13130.h"
|
||||
#include "lib/lib_159b0.h"
|
||||
@@ -439,7 +439,7 @@ void frUnloadData(void)
|
||||
|
||||
void *frLoadRomData(u32 len)
|
||||
{
|
||||
g_FrRomData = malloc(ALIGN16(len), 4);
|
||||
g_FrRomData = malloc(ALIGN16(len), MEMPOOL_STAGE);
|
||||
|
||||
if (g_FrRomData) {
|
||||
return func0000d488(g_FrRomData, &_firingrangeSegmentRomStart, len);
|
||||
@@ -1763,7 +1763,7 @@ glabel frLoadData
|
||||
// }
|
||||
//
|
||||
// // 83c
|
||||
// g_FrScriptOffsets = malloc(ALIGN16(count * 2), 4);
|
||||
// g_FrScriptOffsets = malloc(ALIGN16(count * 2), MEMPOOL_STAGE);
|
||||
//
|
||||
// // 860
|
||||
// if (g_FrScriptOffsets) {
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@
|
||||
#include "game/data/data_02da90.h"
|
||||
#include "game/utils.h"
|
||||
#include "gvars/gvars.h"
|
||||
#include "lib/lib_121e0.h"
|
||||
#include "lib/memory.h"
|
||||
#include "lib/lib_4a360.h"
|
||||
#include "types.h"
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "game/data/data_02da90.h"
|
||||
#include "game/weather/weather.h"
|
||||
#include "gvars/gvars.h"
|
||||
#include "lib/lib_121e0.h"
|
||||
#include "lib/memory.h"
|
||||
#include "types.h"
|
||||
|
||||
s32 g_WeatherEnabled = false;
|
||||
@@ -67,7 +67,7 @@ void weatherInit(void)
|
||||
|| g_StageIndex == STAGEINDEX_G5BUILDING
|
||||
|| g_StageIndex == STAGEINDEX_CRASHSITE)
|
||||
&& PLAYERCOUNT() < 2) {
|
||||
g_WeatherData = malloc(sizeof(struct weatherdata), 4);
|
||||
g_WeatherData = malloc(sizeof(struct weatherdata), MEMPOOL_STAGE);
|
||||
g_WeatherData->particledata = weatherAllocateParticles();
|
||||
g_WeatherData->type = -1;
|
||||
g_WeatherData->windanglerad = 0;
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#include "gvars/gvars.h"
|
||||
#include "lib/main.h"
|
||||
#include "lib/lib_0e9d0.h"
|
||||
#include "lib/lib_121e0.h"
|
||||
#include "lib/memory.h"
|
||||
#include "lib/lib_12dc0.h"
|
||||
#include "lib/lib_159b0.h"
|
||||
#include "lib/lib_16110.h"
|
||||
@@ -234,7 +234,7 @@ void weatherSetBoundaries(struct weatherparticledata *data, s32 index, f32 min,
|
||||
|
||||
struct weatherparticledata *weatherAllocateParticles(void)
|
||||
{
|
||||
struct weatherparticledata *data = malloc(sizeof(struct weatherparticledata), 4);
|
||||
struct weatherparticledata *data = malloc(sizeof(struct weatherparticledata), MEMPOOL_STAGE);
|
||||
u32 i;
|
||||
|
||||
data->unk3e80 = 0;
|
||||
|
||||
+2
-2
@@ -11783,9 +11783,9 @@ u32 var800992f0 = 0;
|
||||
u32 var800992f4 = 0;
|
||||
u32 var800992f8 = 0;
|
||||
u32 var800992fc = 0;
|
||||
struct memorypool g_PrimaryMemoryPools[9] = {0};
|
||||
struct memorypool g_OnboardMemoryPools[9] = {0};
|
||||
u32 var800993b4 = 0;
|
||||
struct memorypool g_SecondaryMemoryPools[9] = {0};
|
||||
struct memorypool g_ExpansionMemoryPools[9] = {0};
|
||||
u32 var8009946c = 0;
|
||||
u32 var80099470 = 0;
|
||||
u32 var80099474 = 0;
|
||||
|
||||
@@ -1138,8 +1138,15 @@
|
||||
#define MAX_SQUADRONS 16
|
||||
#define MAX_TEAMS 8
|
||||
|
||||
#define MEMBANK_PRIMARY 0
|
||||
#define MEMBANK_SECONDARY 1
|
||||
#define MEMBANK_ONBOARD 0
|
||||
#define MEMBANK_EXPANSION 1
|
||||
|
||||
#define MEMPOOL_0 0
|
||||
#define MEMPOOL_STAGE 4 // Cleared on stage load
|
||||
#define MEMPOOL_5 5
|
||||
#define MEMPOOL_PERMANENT 6 // Never cleared
|
||||
#define MEMPOOL_7 7
|
||||
#define MEMPOOL_8 8
|
||||
|
||||
#define MENUDIALOGTYPE_DEFAULT 1
|
||||
#define MENUDIALOGTYPE_DANGER 2
|
||||
|
||||
@@ -415,8 +415,8 @@ extern u32 var8009520c;
|
||||
extern u32 var80095210;
|
||||
extern u32 var80099024;
|
||||
extern u32 var800992e4;
|
||||
extern struct memorypool g_PrimaryMemoryPools[9];
|
||||
extern struct memorypool g_SecondaryMemoryPools[9];
|
||||
extern struct memorypool g_OnboardMemoryPools[9];
|
||||
extern struct memorypool g_ExpansionMemoryPools[9];
|
||||
extern u32 var8009946c;
|
||||
extern u32 var80099470;
|
||||
extern u32 var80099474;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef _IN_LIB_LIB_121E0_H
|
||||
#define _IN_LIB_LIB_121E0_H
|
||||
#ifndef _IN_LIB_MEMORY_H
|
||||
#define _IN_LIB_MEMORY_H
|
||||
#include <ultra64.h>
|
||||
#include "types.h"
|
||||
|
||||
@@ -13,7 +13,7 @@ s32 memReallocate(u32 allocation, s32 size, u8 poolnum);
|
||||
u32 memGetFree(u8 poolnum, u32 bank);
|
||||
void memResetPool(u8 pool);
|
||||
void memDisablePool(u8 pool);
|
||||
u32 func000125dc(void);
|
||||
u32 func00012644(void);
|
||||
u32 memAllocFromBankRight(void);
|
||||
u32 mallocFromRight(void);
|
||||
|
||||
#endif
|
||||
+3
-3
@@ -4896,9 +4896,9 @@ struct gecreditsdata {
|
||||
|
||||
struct memorypool {
|
||||
/*0x00*/ u32 start;
|
||||
/*0x04*/ u32 nextallocation;
|
||||
/*0x08*/ u32 end;
|
||||
/*0x0c*/ u32 unk0c;
|
||||
/*0x04*/ u32 leftpos;
|
||||
/*0x08*/ u32 rightpos;
|
||||
/*0x0c*/ u32 end;
|
||||
/*0x10*/ u32 prevallocation;
|
||||
};
|
||||
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@
|
||||
#include "gvars/gvars.h"
|
||||
#include "lib/lib_04840.h"
|
||||
#include "lib/lib_09660.h"
|
||||
#include "lib/lib_121e0.h"
|
||||
#include "lib/memory.h"
|
||||
#include "lib/lib_159b0.h"
|
||||
#include "lib/lib_2faf0.h"
|
||||
#include "lib/lib_30ce0.h"
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@
|
||||
#include "lib/lib_08a20.h"
|
||||
#include "lib/lib_0d0a0.h"
|
||||
#include "lib/lib_0e9d0.h"
|
||||
#include "lib/lib_121e0.h"
|
||||
#include "lib/memory.h"
|
||||
#include "lib/lib_12dc0.h"
|
||||
#include "lib/lib_13130.h"
|
||||
#include "lib/lib_2faf0.h"
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@
|
||||
#include "lib/lib_04790.h"
|
||||
#include "lib/lib_04a80.h"
|
||||
#include "lib/lib_0d0a0.h"
|
||||
#include "lib/lib_121e0.h"
|
||||
#include "lib/memory.h"
|
||||
#include "lib/lib_16110.h"
|
||||
#include "lib/lib_233c0.h"
|
||||
#include "lib/lib_2f490.h"
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@
|
||||
#include "game/data/data_020df0.h"
|
||||
#include "game/data/data_02da90.h"
|
||||
#include "gvars/gvars.h"
|
||||
#include "lib/lib_121e0.h"
|
||||
#include "lib/memory.h"
|
||||
#include "lib/lib_48120.h"
|
||||
#include "types.h"
|
||||
|
||||
|
||||
+8
-8
@@ -56,7 +56,7 @@
|
||||
#include "lib/lib_0d0a0.h"
|
||||
#include "lib/main.h"
|
||||
#include "lib/lib_0e9d0.h"
|
||||
#include "lib/lib_121e0.h"
|
||||
#include "lib/memory.h"
|
||||
#include "lib/lib_126b0.h"
|
||||
#include "lib/lib_12dc0.h"
|
||||
#include "lib/lib_13130.h"
|
||||
@@ -764,8 +764,8 @@ const char var70053aa0[] = " -ml0 -me0 -mgfx100 -mvtx50 -mt700 -ma400";
|
||||
// tmp = var80090b00;
|
||||
// memInit(uVar2, tmp - uVar2);
|
||||
//
|
||||
// memResetPool(8);
|
||||
// memResetPool(6);
|
||||
// memResetPool(MEMPOOL_8);
|
||||
// memResetPool(MEMPOOL_PERMANENT);
|
||||
// func0000cef8();
|
||||
// mpInitPresetFeatures();
|
||||
// func0f176ddc();
|
||||
@@ -960,15 +960,15 @@ void mainLoop(void)
|
||||
|
||||
var8005d9c4 = 0;
|
||||
|
||||
memResetPool(7);
|
||||
memResetPool(4);
|
||||
memResetPool(MEMPOOL_7);
|
||||
memResetPool(MEMPOOL_STAGE);
|
||||
func0f1672f0(4);
|
||||
|
||||
if (func00013010(1, "-ma")) {
|
||||
var8005d9b8 = func00013408(func00013010(1, "-ma"), NULL, 0) * 1024;
|
||||
}
|
||||
|
||||
func00012a14(malloc(var8005d9b8, 4), var8005d9b8);
|
||||
func00012a14(malloc(var8005d9b8, MEMPOOL_STAGE), var8005d9b8);
|
||||
stageLoadCommonLang(g_StageNum);
|
||||
playersUnrefAll();
|
||||
|
||||
@@ -1065,8 +1065,8 @@ void mainLoop(void)
|
||||
}
|
||||
|
||||
coreUnloadStage();
|
||||
memDisablePool(4);
|
||||
memDisablePool(7);
|
||||
memDisablePool(MEMPOOL_STAGE);
|
||||
memDisablePool(MEMPOOL_7);
|
||||
func0f1672f0(4);
|
||||
func00009ec4(1);
|
||||
func0f116994();
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "game/data/data_020df0.h"
|
||||
#include "game/data/data_02da90.h"
|
||||
#include "gvars/gvars.h"
|
||||
#include "lib/lib_121e0.h"
|
||||
#include "lib/memory.h"
|
||||
#include "types.h"
|
||||
|
||||
void func000121e0(void)
|
||||
@@ -17,42 +17,68 @@ void func000121e0(void)
|
||||
// empty
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise the memory allocation system by initialising the banks and pools.
|
||||
*
|
||||
* The system has two banks - onboard and expansion - which refer to the onboard
|
||||
* memory and expansion pak memory if present. The arguments passed are the
|
||||
* onboard start and length that can be used by the memory system. If the
|
||||
* expansion pak is present, the entire pak is used for the second bank.
|
||||
*
|
||||
* Each bank consists of 8 pools, which start off overlapping. Care must be
|
||||
* taken to not allocate from the wrong pool at the wrong time. In practice it
|
||||
* appears only two pools are used which makes this easy:
|
||||
*
|
||||
* MEMPOOL_PERMANENT (index 6) is for permanent data and is never cleared
|
||||
* MEMPOOL_STAGE (index 4) is for general data and is cleared on stage load
|
||||
*
|
||||
* After the permanent pool has finished its allocations, it is closed off and
|
||||
* the stage pool is then placed immediately after it. All allocations from
|
||||
* there on are made from the stage pool.
|
||||
*
|
||||
* Each pool has a start and end address. Allocations are typically served from
|
||||
* the left side of the pool but can also be allocated from the right side.
|
||||
* In practice right side allocations are only used once (by texture related
|
||||
* code).
|
||||
*
|
||||
* Resizing an allocation is also supported, but only from the left side and
|
||||
* only if it's the most recent allocation.
|
||||
*/
|
||||
void memInit(u32 heapstart, u32 heaplen)
|
||||
{
|
||||
s32 i;
|
||||
u32 extraend;
|
||||
|
||||
// Memory pool 9 is not cleared? Doesn't appear to be used anyway.
|
||||
// Maybe the array is only 0-8?
|
||||
for (i = 0; i < 9; i++) {
|
||||
g_PrimaryMemoryPools[i].start = 0;
|
||||
g_PrimaryMemoryPools[i].nextallocation = 0;
|
||||
g_PrimaryMemoryPools[i].end = 0;
|
||||
g_PrimaryMemoryPools[i].prevallocation = 0;
|
||||
g_OnboardMemoryPools[i].start = 0;
|
||||
g_OnboardMemoryPools[i].leftpos = 0;
|
||||
g_OnboardMemoryPools[i].rightpos = 0;
|
||||
g_OnboardMemoryPools[i].prevallocation = 0;
|
||||
|
||||
g_SecondaryMemoryPools[i].start = 0;
|
||||
g_SecondaryMemoryPools[i].nextallocation = 0;
|
||||
g_SecondaryMemoryPools[i].end = 0;
|
||||
g_SecondaryMemoryPools[i].prevallocation = 0;
|
||||
g_ExpansionMemoryPools[i].start = 0;
|
||||
g_ExpansionMemoryPools[i].leftpos = 0;
|
||||
g_ExpansionMemoryPools[i].rightpos = 0;
|
||||
g_ExpansionMemoryPools[i].prevallocation = 0;
|
||||
}
|
||||
|
||||
g_PrimaryMemoryPools[0].start = heapstart;
|
||||
g_PrimaryMemoryPools[0].end = heapstart + heaplen;
|
||||
g_PrimaryMemoryPools[6].start = heapstart;
|
||||
g_PrimaryMemoryPools[6].end = heapstart + heaplen;
|
||||
g_PrimaryMemoryPools[4].start = heapstart;
|
||||
g_PrimaryMemoryPools[4].end = heapstart + heaplen;
|
||||
g_OnboardMemoryPools[MEMPOOL_0].start = heapstart;
|
||||
g_OnboardMemoryPools[MEMPOOL_0].rightpos = heapstart + heaplen;
|
||||
g_OnboardMemoryPools[MEMPOOL_PERMANENT].start = heapstart;
|
||||
g_OnboardMemoryPools[MEMPOOL_PERMANENT].rightpos = heapstart + heaplen;
|
||||
g_OnboardMemoryPools[MEMPOOL_STAGE].start = heapstart;
|
||||
g_OnboardMemoryPools[MEMPOOL_STAGE].rightpos = heapstart + heaplen;
|
||||
|
||||
// If 8MB, reserve the entire expansion pak for additional mempool 4
|
||||
extraend = 0x80000000 + osGetMemSize();
|
||||
|
||||
if (osGetMemSize() > 4 * 1024 * 1024) {
|
||||
g_SecondaryMemoryPools[4].start = 0x80400000;
|
||||
g_SecondaryMemoryPools[4].end = extraend;
|
||||
g_ExpansionMemoryPools[MEMPOOL_STAGE].start = 0x80400000;
|
||||
g_ExpansionMemoryPools[MEMPOOL_STAGE].rightpos = extraend;
|
||||
}
|
||||
|
||||
for (i = 0; i < 9; i++) {
|
||||
g_PrimaryMemoryPools[i].unk0c = g_PrimaryMemoryPools[i].end;
|
||||
g_SecondaryMemoryPools[i].unk0c = g_SecondaryMemoryPools[i].end;
|
||||
g_OnboardMemoryPools[i].end = g_OnboardMemoryPools[i].rightpos;
|
||||
g_ExpansionMemoryPools[i].end = g_ExpansionMemoryPools[i].rightpos;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,9 +87,9 @@ u32 memGetPool4Available(void)
|
||||
u32 free;
|
||||
|
||||
if (IS4MB()) {
|
||||
free = g_PrimaryMemoryPools[4].end - g_PrimaryMemoryPools[4].nextallocation;
|
||||
free = g_OnboardMemoryPools[MEMPOOL_STAGE].rightpos - g_OnboardMemoryPools[MEMPOOL_STAGE].leftpos;
|
||||
} else {
|
||||
free = g_SecondaryMemoryPools[4].end - g_SecondaryMemoryPools[4].nextallocation;
|
||||
free = g_ExpansionMemoryPools[MEMPOOL_STAGE].rightpos - g_ExpansionMemoryPools[MEMPOOL_STAGE].leftpos;
|
||||
}
|
||||
|
||||
return free;
|
||||
@@ -74,9 +100,9 @@ u32 memGetNextPool4Allocation(void)
|
||||
u32 next;
|
||||
|
||||
if (IS4MB()) {
|
||||
next = g_PrimaryMemoryPools[4].nextallocation;
|
||||
next = g_OnboardMemoryPools[MEMPOOL_STAGE].leftpos;
|
||||
} else {
|
||||
next = g_SecondaryMemoryPools[4].nextallocation;
|
||||
next = g_ExpansionMemoryPools[MEMPOOL_STAGE].leftpos;
|
||||
}
|
||||
|
||||
return next;
|
||||
@@ -124,24 +150,24 @@ glabel memAllocFromBank
|
||||
//
|
||||
// pool += poolnum;
|
||||
//
|
||||
// allocation = pool->nextallocation;
|
||||
// allocation = pool->leftpos;
|
||||
//
|
||||
// if (pool->nextallocation == 0) {
|
||||
// if (pool->leftpos == 0) {
|
||||
// return allocation;
|
||||
// }
|
||||
//
|
||||
// if (pool->nextallocation > pool->end) {
|
||||
// if (pool->leftpos > pool->rightpos) {
|
||||
// return 0;
|
||||
// }
|
||||
//
|
||||
// if (pool->nextallocation + size > pool->end) {
|
||||
// if (pool->leftpos + size > pool->rightpos) {
|
||||
// return 0;
|
||||
// }
|
||||
//
|
||||
// // Mismatch because allocation in the following statement should be
|
||||
// // pool->nextallocation, but when this is changed it reuses the computed
|
||||
// // pool->leftpos, but when this is changed it reuses the computed
|
||||
// // expression from above which results in different codegen.
|
||||
// pool->nextallocation = allocation + size;
|
||||
// pool->leftpos = allocation + size;
|
||||
// pool->prevallocation = allocation;
|
||||
//
|
||||
// return allocation;
|
||||
@@ -149,13 +175,13 @@ glabel memAllocFromBank
|
||||
|
||||
void *malloc(u32 len, u8 pool)
|
||||
{
|
||||
void *allocation = (void *)memAllocFromBank(&g_PrimaryMemoryPools[0], len, pool);
|
||||
void *allocation = (void *)memAllocFromBank(g_OnboardMemoryPools, len, pool);
|
||||
|
||||
if (allocation) {
|
||||
return allocation;
|
||||
}
|
||||
|
||||
allocation = (void *)memAllocFromBank(&g_SecondaryMemoryPools[0], len, pool);
|
||||
allocation = (void *)memAllocFromBank(g_ExpansionMemoryPools, len, pool);
|
||||
|
||||
if (allocation) {
|
||||
return allocation;
|
||||
@@ -171,32 +197,32 @@ void *malloc(u32 len, u8 pool)
|
||||
* The allocation must be the most recent allocation.
|
||||
*
|
||||
* @dangerous: This function does not check the limits of the memory pool.
|
||||
* If it allocates past the end of the pool it could lead to memory corruption.
|
||||
* If it allocates past the rightpos of the pool it could lead to memory corruption.
|
||||
*/
|
||||
s32 memReallocate(u32 allocation, s32 newsize, u8 poolnum)
|
||||
{
|
||||
struct memorypool *pool = &g_PrimaryMemoryPools[poolnum];
|
||||
struct memorypool *pool = &g_OnboardMemoryPools[poolnum];
|
||||
s32 origsize;
|
||||
s32 growsize;
|
||||
|
||||
if (pool->prevallocation != allocation) {
|
||||
pool = &g_SecondaryMemoryPools[poolnum];
|
||||
pool = &g_ExpansionMemoryPools[poolnum];
|
||||
|
||||
if (pool->prevallocation != allocation) {
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
origsize = pool->nextallocation - pool->prevallocation;
|
||||
origsize = pool->leftpos - pool->prevallocation;
|
||||
growsize = newsize - origsize;
|
||||
|
||||
if (growsize <= 0) {
|
||||
pool->nextallocation += growsize;
|
||||
pool->nextallocation = ALIGN16(pool->nextallocation);
|
||||
pool->leftpos += growsize;
|
||||
pool->leftpos = ALIGN16(pool->leftpos);
|
||||
return 1;
|
||||
}
|
||||
|
||||
pool->nextallocation += growsize;
|
||||
pool->leftpos += growsize;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -209,45 +235,56 @@ u32 memGetFree(u8 poolnum, u32 bank)
|
||||
{
|
||||
struct memorypool *pool;
|
||||
|
||||
if (bank == MEMBANK_PRIMARY) {
|
||||
pool = &g_PrimaryMemoryPools[poolnum];
|
||||
if (bank == MEMBANK_ONBOARD) {
|
||||
pool = &g_OnboardMemoryPools[poolnum];
|
||||
} else {
|
||||
pool = &g_SecondaryMemoryPools[poolnum];
|
||||
pool = &g_ExpansionMemoryPools[poolnum];
|
||||
}
|
||||
|
||||
return pool->end - pool->nextallocation;
|
||||
}
|
||||
|
||||
void memResetPool(u8 pool)
|
||||
{
|
||||
// When resetting mempool 4, put it immediately after mempool 6 and close
|
||||
// off mempool 6. Perhaps mempool 6 is only allocated to during stage load
|
||||
// and mempool 4 is dynamic stuff which can happen after?
|
||||
if (pool == 4) {
|
||||
g_PrimaryMemoryPools[4].start = g_PrimaryMemoryPools[6].nextallocation;
|
||||
g_PrimaryMemoryPools[6].end = g_PrimaryMemoryPools[6].nextallocation;
|
||||
g_PrimaryMemoryPools[6].unk0c = g_PrimaryMemoryPools[6].nextallocation;
|
||||
}
|
||||
|
||||
g_PrimaryMemoryPools[pool].nextallocation = g_PrimaryMemoryPools[pool].start;
|
||||
g_SecondaryMemoryPools[pool].nextallocation = g_SecondaryMemoryPools[pool].start;
|
||||
g_PrimaryMemoryPools[pool].prevallocation = 0;
|
||||
g_SecondaryMemoryPools[pool].prevallocation = 0;
|
||||
return pool->rightpos - pool->leftpos;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setting nextallocation to 0 means that this pool will refuse all allocations.
|
||||
* Reset the pool's left side to its start address, effectively freeing the left
|
||||
* side of the pool.
|
||||
*
|
||||
* If resetting the stage pool, close off the permanent pool and place the stage
|
||||
* pool immediately after it.
|
||||
*
|
||||
* Note the right side is not reset here.
|
||||
*/
|
||||
void memResetPool(u8 pool)
|
||||
{
|
||||
if (pool == MEMPOOL_STAGE) {
|
||||
g_OnboardMemoryPools[MEMPOOL_STAGE].start = g_OnboardMemoryPools[MEMPOOL_PERMANENT].leftpos;
|
||||
g_OnboardMemoryPools[MEMPOOL_PERMANENT].rightpos = g_OnboardMemoryPools[MEMPOOL_PERMANENT].leftpos;
|
||||
g_OnboardMemoryPools[MEMPOOL_PERMANENT].end = g_OnboardMemoryPools[MEMPOOL_PERMANENT].leftpos;
|
||||
}
|
||||
|
||||
g_OnboardMemoryPools[pool].leftpos = g_OnboardMemoryPools[pool].start;
|
||||
g_ExpansionMemoryPools[pool].leftpos = g_ExpansionMemoryPools[pool].start;
|
||||
g_OnboardMemoryPools[pool].prevallocation = 0;
|
||||
g_ExpansionMemoryPools[pool].prevallocation = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setting leftpos to 0 means that this pool will refuse allocations from the
|
||||
* left.
|
||||
*
|
||||
* Setting rightpos to the end means it's resetting the right side and making
|
||||
* that available for allocations. It would have made more sense to do this in
|
||||
* memResetPool instead.
|
||||
*/
|
||||
void memDisablePool(u8 pool)
|
||||
{
|
||||
g_PrimaryMemoryPools[pool].nextallocation = 0;
|
||||
g_SecondaryMemoryPools[pool].nextallocation = 0;
|
||||
g_PrimaryMemoryPools[pool].end = g_PrimaryMemoryPools[pool].unk0c;
|
||||
g_SecondaryMemoryPools[pool].end = g_SecondaryMemoryPools[pool].unk0c;
|
||||
g_OnboardMemoryPools[pool].leftpos = 0;
|
||||
g_ExpansionMemoryPools[pool].leftpos = 0;
|
||||
g_OnboardMemoryPools[pool].rightpos = g_OnboardMemoryPools[pool].end;
|
||||
g_ExpansionMemoryPools[pool].rightpos = g_ExpansionMemoryPools[pool].end;
|
||||
}
|
||||
|
||||
GLOBAL_ASM(
|
||||
glabel func000125dc
|
||||
glabel memAllocFromBankRight
|
||||
/* 125dc: 30ce00ff */ andi $t6,$a2,0xff
|
||||
/* 125e0: 000e7880 */ sll $t7,$t6,0x2
|
||||
/* 125e4: 01ee7821 */ addu $t7,$t7,$t6
|
||||
@@ -280,24 +317,24 @@ glabel func000125dc
|
||||
);
|
||||
|
||||
GLOBAL_ASM(
|
||||
glabel func00012644
|
||||
glabel mallocFromRight
|
||||
/* 12644: 27bdffe8 */ addiu $sp,$sp,-24
|
||||
/* 12648: afa40018 */ sw $a0,0x18($sp)
|
||||
/* 1264c: afbf0014 */ sw $ra,0x14($sp)
|
||||
/* 12650: afa5001c */ sw $a1,0x1c($sp)
|
||||
/* 12654: 3c04800a */ lui $a0,%hi(g_PrimaryMemoryPools)
|
||||
/* 12658: 24849300 */ addiu $a0,$a0,%lo(g_PrimaryMemoryPools)
|
||||
/* 12654: 3c04800a */ lui $a0,%hi(g_OnboardMemoryPools)
|
||||
/* 12658: 24849300 */ addiu $a0,$a0,%lo(g_OnboardMemoryPools)
|
||||
/* 1265c: 93a6001f */ lbu $a2,0x1f($sp)
|
||||
/* 12660: 0c004977 */ jal func000125dc
|
||||
/* 12660: 0c004977 */ jal memAllocFromBankRight
|
||||
/* 12664: 8fa50018 */ lw $a1,0x18($sp)
|
||||
/* 12668: 10400003 */ beqz $v0,.L00012678
|
||||
/* 1266c: 3c04800a */ lui $a0,%hi(g_SecondaryMemoryPools)
|
||||
/* 1266c: 3c04800a */ lui $a0,%hi(g_ExpansionMemoryPools)
|
||||
/* 12670: 1000000b */ b .L000126a0
|
||||
/* 12674: 8fbf0014 */ lw $ra,0x14($sp)
|
||||
.L00012678:
|
||||
/* 12678: 248493b8 */ addiu $a0,$a0,%lo(g_SecondaryMemoryPools)
|
||||
/* 12678: 248493b8 */ addiu $a0,$a0,%lo(g_ExpansionMemoryPools)
|
||||
/* 1267c: 8fa50018 */ lw $a1,0x18($sp)
|
||||
/* 12680: 0c004977 */ jal func000125dc
|
||||
/* 12680: 0c004977 */ jal memAllocFromBankRight
|
||||
/* 12684: 93a6001f */ lbu $a2,0x1f($sp)
|
||||
/* 12688: 10400003 */ beqz $v0,.L00012698
|
||||
/* 1268c: 00401825 */ or $v1,$v0,$zero
|
||||
Reference in New Issue
Block a user