From 4e907d5469deeacf0cf71e6cf856269532ef47f5 Mon Sep 17 00:00:00 2001 From: Arceveti <73617174+Arceveti@users.noreply.github.com> Date: Tue, 2 Nov 2021 12:50:09 -0700 Subject: [PATCH] Some memory pool size defines --- src/boot/main.c | 2 +- src/boot/memory.c | 2 -- src/game/memory.h | 7 ++----- src/game/object_list_processor.c | 10 +++++----- src/game/object_list_processor.h | 2 ++ src/game/puppyprint.c | 10 ++++++---- 6 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/boot/main.c b/src/boot/main.c index 1fee0dcb8..498ab948e 100644 --- a/src/boot/main.c +++ b/src/boot/main.c @@ -107,7 +107,7 @@ void alloc_pool(void) { void *end = (void *) (SEG_POOL_START + POOL_SIZE); main_pool_init(start, end); - gEffectsMemoryPool = mem_pool_init(0x4000, MEMORY_POOL_LEFT); + gEffectsMemoryPool = mem_pool_init(EFFECTS_MEMORY_POOL, MEMORY_POOL_LEFT); #ifdef PUPPYLIGHTS gLightsPool = mem_pool_init(PUPPYLIGHTS_POOL, MEMORY_POOL_LEFT); #endif diff --git a/src/boot/memory.c b/src/boot/memory.c index 96a390cc4..c8a278504 100644 --- a/src/boot/memory.c +++ b/src/boot/memory.c @@ -2,8 +2,6 @@ #include "sm64.h" -#define INCLUDED_FROM_MEMORY_C - #include "buffers/buffers.h" #include "slidec.h" #include "game/game_init.h" diff --git a/src/game/memory.h b/src/game/memory.h index 2b16d7bb3..75f9b78b7 100644 --- a/src/game/memory.h +++ b/src/game/memory.h @@ -38,12 +38,9 @@ struct DmaHandlerList { void *bufTarget; }; -#ifndef INCLUDED_FROM_MEMORY_C -// Declaring this variable extern puts it in the wrong place in the bss order -// when this file is included from memory.c (first instead of last). Hence, -// ifdef hack. It was very likely subject to bss reordering originally. +#define EFFECTS_MEMORY_POOL 0x4000 + extern struct MemoryPool *gEffectsMemoryPool; -#endif uintptr_t set_segment_base_addr(s32 segment, void *addr); void *get_segment_base_addr(s32 segment); diff --git a/src/game/object_list_processor.c b/src/game/object_list_processor.c index 68502f5d8..339cb87a0 100644 --- a/src/game/object_list_processor.c +++ b/src/game/object_list_processor.c @@ -468,9 +468,9 @@ void spawn_objects_from_info(struct SpawnInfo *spawnInfo) { void clear_objects(void) { s32 i; - gTHIWaterDrained = 0; - gTimeStopState = 0; - gMarioObject = NULL; + gTHIWaterDrained = 0; + gTimeStopState = 0; + gMarioObject = NULL; gMarioCurrentRoom = 0; for (i = 0; i < 60; i++) { @@ -488,8 +488,8 @@ void clear_objects(void) { geo_reset_object_node(&gObjectPool[i].header.gfx); } - gObjectMemoryPool = mem_pool_init(0x800, MEMORY_POOL_LEFT); - gObjectLists = gObjectListArray; + gObjectMemoryPool = mem_pool_init(OBJECT_MEMORY_POOL, MEMORY_POOL_LEFT); + gObjectLists = gObjectListArray; clear_dynamic_surfaces(); } diff --git a/src/game/object_list_processor.h b/src/game/object_list_processor.h index 8f7a1a8fe..e9c2e0c20 100644 --- a/src/game/object_list_processor.h +++ b/src/game/object_list_processor.h @@ -95,6 +95,8 @@ extern s32 gSurfacesAllocated; extern s32 gNumStaticSurfaceNodes; extern s32 gNumStaticSurfaces; +#define OBJECT_MEMORY_POOL 0x800 + extern struct MemoryPool *gObjectMemoryPool; enum CollisionFlags { diff --git a/src/game/puppyprint.c b/src/game/puppyprint.c index 536e6157b..d69dfdbd7 100644 --- a/src/game/puppyprint.c +++ b/src/game/puppyprint.c @@ -145,9 +145,11 @@ void puppyprint_calculate_ram_usage(void) { } // These are a bit hacky, but what can ye do eh? - // gEffectsMemoryPool is 0x4000, gObjectsMemoryPool is 0x800. Epic C limitations mean I can't just sizeof their values :) - ramsizeSegment[5] = (0x4000 + 0x800 + 0x4000 + 0x800); - ramsizeSegment[6] = ((SURFACE_NODE_POOL_SIZE * sizeof(struct SurfaceNode)) + (SURFACE_POOL_SIZE * sizeof(struct Surface))); + // gEffectsMemoryPool is 0x4000, gObjectMemoryPool is 0x800. Epic C limitations mean I can't just sizeof their values :) + ramsizeSegment[5] = (EFFECTS_MEMORY_POOL + OBJECT_MEMORY_POOL + + EFFECTS_MEMORY_POOL + OBJECT_MEMORY_POOL); + ramsizeSegment[6] = ((SURFACE_NODE_POOL_SIZE * sizeof(struct SurfaceNode)) + + ( SURFACE_POOL_SIZE * sizeof(struct Surface ))); ramsizeSegment[7] = gAudioHeapSize; } @@ -225,7 +227,7 @@ void print_ram_bar(void) { continue; } perfPercentage = ((f32)ramsizeSegment[i] / ramsize); - graphPos = prevGraph + CLAMP((BAR_LENGTH * perfPercentage), 1, (SCREEN_CENTER_X + (BAR_LENGTH / 2))); + graphPos = (prevGraph + CLAMP((BAR_LENGTH * perfPercentage), 1, (SCREEN_CENTER_X + (BAR_LENGTH / 2)))); render_blank_box(prevGraph, (SCREEN_HEIGHT - 30), graphPos, (SCREEN_HEIGHT - 22), colourChart[i][0], colourChart[i][1],