Finish memory.h

This commit is contained in:
Ryan Myers
2021-09-12 12:33:03 -04:00
parent 1be1d00092
commit df9c8eca3b
3 changed files with 76 additions and 72 deletions
+2 -68
View File
@@ -3,13 +3,6 @@
#include "memory.h"
#include "structs.h"
#include "types.h"
#include "macros.h"
#define RAM_END 0x80400000
#define MAIN_POOL_SLOT_COUNT 1600
/************ .rodata ************/
const char D_800E7210[] = "*** mmAlloc: size = 0 ***\n";
@@ -31,36 +24,6 @@ const char D_800E7488[] = "Unable to record %d slots, colours overflowed table.\
/************ .bss ************/
/* Size: 0x8 bytes */
typedef struct unk80070BE4_8_0 {
s16 unk0;
s16 unk2;
s32 unk4;
} unk80070BE4_8_0;
/* Size: 0x14 bytes */
typedef struct MemoryPoolSlot {
/* 0x00 */ unk80070BE4_8_0 *unk0;
/* 0x04 */ s32 size;
/* 0x08 */ s16 flags;
// 0x00 = Slot is free
// 0x01 = Slot is being used?
// 0x02 = ???
// 0x04 = ???
/* 0x0A */ s16 prevIndex;
/* 0x0C */ s16 nextIndex;
/* 0x0E */ s16 index;
/* 0x10 */ u32 colorTag;
} MemoryPoolSlot;
/* Size: 0x10 bytes */
typedef struct MemoryPool {
/* 0x00 */ s32 maxNumSlots;
/* 0x04 */ s32 curNumSlots;
/* 0x08 */ MemoryPoolSlot *slots;
/* 0x0C */ s32 size;
} MemoryPool;
MemoryPool gMemoryPools[4];
#ifndef _ALIGN16
@@ -69,15 +32,7 @@ MemoryPool gMemoryPools[4];
s32 gNumberOfMemoryPools;
s32 D_801235C4;
/* Size: 0x8 bytes */
typedef struct FreeQueueSlot {
void *dataAddress;
u8 unk4;
} FreeQueueSlot;
FreeQueueSlot gFreeQueue[256];
s32 gFreeQueueCount;
s32 gFreeQueueState;
s32 D_80123DD0[64];
@@ -89,24 +44,6 @@ extern MemoryPoolSlot D_8012D3F0;
/******************************/
/* Unknown size */
typedef struct unk800B7D10 {
u8 pad0[0x14];
s32 unk14;
} unk800B7D10;
unk800B7D10 *get_stack_pointer(void);
MemoryPoolSlot *allocate_from_memory_pool(s32, s32, u32);
MemoryPoolSlot *new_memory_pool(MemoryPoolSlot *arg0, s32 size, s32 numSlots);
void set_free_queue_state(s32);
void *allocate_from_main_pool_safe(s32, u32);
s32 *func_8006F510(void);
void func_8006F53C(s32*);
void func_80071440(void *dataAddress);
s32 get_memory_pool_index_containing_address(u8 *address);
void free_memory_pool_slot(s32 poolIndex, s32 slotIndex);
/**
* Creates the main memory pool.
* Starts at 0x8012D3F0. Ends at 0x80400000. Contains 1600 allocation slots.
@@ -292,8 +229,6 @@ void *allocate_at_address_in_main_pool(s32 size, u8 *address, u32 colorTag) {
GLOBAL_ASM("asm/non_matchings/memory/allocate_at_address_in_main_pool.s")
#endif
void free_slot_containing_address(u8 *address);
/**
* Sets the state of the free queue. State is either 0, 1, or 2.
* The free queue will get flushed if the state is set to 0.
@@ -399,8 +334,8 @@ void func_80071314(void) {
GLOBAL_ASM("asm/non_matchings/memory/free_slot_containing_address.s")
#endif
void func_80071440(void *data) {
gFreeQueue[gFreeQueueCount].dataAddress = data;
void func_80071440(void *dataAddress) {
gFreeQueue[gFreeQueueCount].dataAddress = dataAddress;
gFreeQueue[gFreeQueueCount].unk4 = gFreeQueueState;
gFreeQueueCount++;
}
@@ -650,7 +585,6 @@ void render_memory_color_tags(void) {
}
#ifdef NON_MATCHING
// Unused. Does nothing?
void func_80071C74(void) {
s32 i, flags;
+73
View File
@@ -1,7 +1,12 @@
#ifndef _MEMORY_H_
#define _MEMORY_H_
#include "structs.h"
#include "types.h"
#include "macros.h"
#define RAM_END 0x80400000
#define MAIN_POOL_SLOT_COUNT 1600
// Animation related?
#define COLOR_TAG_RED 0xFF0000FF
@@ -24,8 +29,76 @@
// ???
#define COLOR_TAG_BLACK 0x000000FF
/* Size: 0x8 bytes */
typedef struct unk80070BE4_8_0 {
s16 unk0;
s16 unk2;
s32 unk4;
} unk80070BE4_8_0;
/* Size: 0x14 bytes */
typedef struct MemoryPoolSlot {
/* 0x00 */ unk80070BE4_8_0 *unk0;
/* 0x04 */ s32 size;
/* 0x08 */ s16 flags;
// 0x00 = Slot is free
// 0x01 = Slot is being used?
// 0x02 = ???
// 0x04 = ???
/* 0x0A */ s16 prevIndex;
/* 0x0C */ s16 nextIndex;
/* 0x0E */ s16 index;
/* 0x10 */ u32 colorTag;
} MemoryPoolSlot;
/* Size: 0x10 bytes */
typedef struct MemoryPool {
/* 0x00 */ s32 maxNumSlots;
/* 0x04 */ s32 curNumSlots;
/* 0x08 */ MemoryPoolSlot *slots;
/* 0x0C */ s32 size;
} MemoryPool;
/* Size: 0x8 bytes */
typedef struct FreeQueueSlot {
void *dataAddress;
u8 unk4; //FreeQueueState?
} FreeQueueSlot;
/* Unknown size */
typedef struct unk800B7D10 {
u8 pad0[0x14];
s32 unk14;
} unk800B7D10;
unk800B7D10 *get_stack_pointer(void); // Non Matching with own file
s32 *func_8006F510(void); // Non Matching unknown_070110
void func_8006F53C(s32*); // Non Matching unknown_070110
void init_main_memory_pool(void);
MemoryPoolSlot *new_sub_memory_pool(s32 poolDataSize, s32 numSlots);
void *allocate_from_main_pool_safe(s32 size, u32 colorTag);
MemoryPoolSlot *allocate_from_main_pool(s32 size, u32 colorTag);
void *allocate_from_pool_containing_slots(MemoryPoolSlot *slots, s32 size);
void set_free_queue_state(s32 state);
void free_from_memory_pool(void *data);
void clear_free_queue(void);
void func_80071440(void *dataAddress);
s32 func_80071478(u8 *address);
s32 func_80071538(u8 *address);
s32 get_memory_pool_index_containing_address(u8 *address);
u8 *align16(u8 *address);
u8 *align8(u8 *address);
u8 *align4(u8 *address);
void print_memory_color_tags(void);
void render_memory_color_tags(void);
void func_80071CE8(void);
MemoryPoolSlot *allocate_from_memory_pool(s32 memoryPoolIndex, s32 size, u32 colorTag); // Non Matching
MemoryPoolSlot *new_memory_pool(MemoryPoolSlot *slots, s32 poolSize, s32 numSlots); // Non Matching
void free_memory_pool_slot(s32 poolIndex, s32 slotIndex); // Non Matching
void *allocate_at_address_in_main_pool(s32 size, u8 *address, u32 colorTag); // Non Matching
void free_slot_containing_address(u8 *address); // Non Matching
s32 get_memory_color_tag_count(s32 arg0); // Non Matching
#endif
+1 -4
View File
@@ -9,6 +9,7 @@
#include "structs.h"
#include "f3ddkr.h"
#include "asset_sections.h"
#include "asset_loading.h"
/************ .data ************/
@@ -296,10 +297,6 @@ void calc_dynamic_lighting_for_object_1(unk8001D6E4_arg1 *, ObjectModel *, s16,
void calc_dynamic_lighting_for_object_2(unk8001D6E4_arg1 *, ObjectModel *, s16, f32);
void func_8000C460(void);
void *new_sub_memory_pool(s32, u32);
void *allocate_from_main_pool_safe(s32, u32);
s32 *load_asset_section_from_rom(s32);
void gParticlePtrList_addObject(Object *);
void gParticlePtrList_flush(void);
void func_8001D258(f32, f32, s32, s32, s32);