SpaghettiKart
Loading...
Searching...
No Matches
memory.c File Reference
#include <libultraship.h>
#include <libultra/types.h>
#include <align_asset_macro.h>
#include <macros.h>
#include <string.h>
#include <common_structs.h>
#include <segments.h>
#include <decode.h>
#include <stubs.h>
#include "memory.h"
#include "main.h"
#include "code_800029B0.h"
#include "defines.h"
#include "course_offsets.h"
#include "engine/tracks/Track.h"
#include "engine/editor/Editor.h"
#include <stdio.h>
#include "port/Game.h"
Include dependency graph for memory.c:

Macros

#define PRINT_MEMPOOL
 

Functions

void * get_next_available_memory_addr (uintptr_t size)
 Returns the address of the next available memory location and updates the memory pointer to reference the next location of available memory based provided size to allocate.
 
static uintptr_t get_texture2 (size_t offset, const course_texture *textures)
 
void initialize_memory_pool ()
 Sets the starting location for allocating memory and calculates pool size.
 
void * allocate_memory (size_t size)
 Allocates memory and adjusts gFreeMemorySize.
 
UNUSED void func_802A7D54 (s32 arg0, s32 arg1)
 
void * load_data (uintptr_t startAddr, uintptr_t endAddr)
 Allocate and DMA.
 
UNUSED void main_pool_init (uintptr_t start, uintptr_t end)
 
UNUSED void * main_pool_alloc (uintptr_t size, uintptr_t side)
 
UNUSED uintptr_t main_pool_free (void *addr)
 
UNUSED void * main_pool_realloc (void *addr, uintptr_t size)
 
UNUSED uintptr_t main_pool_available (void)
 
UNUSED uintptr_t main_pool_push_state (void)
 
UNUSED uintptr_t main_pool_pop_state (void)
 
UNUSED void * func_802A80B0 (u8 *dest, u8 *srcStart, u8 *srcEnd)
 
uintptr_t MIO0_0F (u8 *arg0, uintptr_t arg1, uintptr_t arg2)
 
u8 * load_lakitu_tlut_x64 (const char **textureList, size_t length)
 
void load_track (s32 trackId)
 Loads & DMAs track data. Vtx, textures, displaylists, etc.
 

Variables

s32 sGfxSeekPosition
 
s32 sPackedSeekPosition
 
static u8 sMemoryPool [0xFFFFFFF]
 
uintptr_t sPoolEnd = sMemoryPool + sizeof(sMemoryPool)
 
uintptr_t sPoolFreeSpace
 
struct MainPoolBlocksPoolListHeadL
 
struct MainPoolBlocksPoolListHeadR
 
struct MainPoolStategMainPoolState = NULL
 
struct UnkStruct_802B8CD4 D_802B8CD4 [] = { 0 }
 
s32 D_802B8CE4 = 0
 
s32 memoryPadding [2]
 
uintptr_t vtxSegEnd
 
uintptr_t dlSegEnd
 
uintptr_t texSegEnd
 
size_t texSegSize
 
Gfx * testaaa
 

Macro Definition Documentation

◆ PRINT_MEMPOOL

#define PRINT_MEMPOOL
Value:
printf("\nPool Start: %p, Pool End: %p, size: 0x%lX\ngNextFreeMemoryAddress: 0x%lX\n\n", (void*) sMemoryPool, \
(void*) (sMemoryPool + sizeof(sMemoryPool)), \
(unsigned long) (((sMemoryPool + sizeof(sMemoryPool)) - sMemoryPool)), \
(unsigned long) gNextFreeMemoryAddress)
uintptr_t gNextFreeMemoryAddress
Definition code_800029B0.c:122
u8 sMemoryPool[MEMORY_POOL_SIZE]
Definition memory_pool.c:12

Function Documentation

◆ allocate_memory()

void * allocate_memory ( size_t size)

Allocates memory and adjusts gFreeMemorySize.

Here is the caller graph for this function:

◆ func_802A7D54()

UNUSED void func_802A7D54 ( s32 arg0,
s32 arg1 )

◆ func_802A80B0()

UNUSED void * func_802A80B0 ( u8 * dest,
u8 * srcStart,
u8 * srcEnd )
Here is the call graph for this function:

◆ get_next_available_memory_addr()

void * get_next_available_memory_addr ( uintptr_t size)

Returns the address of the next available memory location and updates the memory pointer to reference the next location of available memory based provided size to allocate.

Parameters
sizeof memory to allocate.
Returns
Address of free memory
Here is the caller graph for this function:

◆ get_texture2()

static uintptr_t get_texture2 ( size_t offset,
const course_texture * textures )
static

◆ initialize_memory_pool()

void initialize_memory_pool ( void )

Sets the starting location for allocating memory and calculates pool size.

Default memory size, 701.984 Kilobytes.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_data()

void * load_data ( uintptr_t startAddr,
uintptr_t endAddr )

Allocate and DMA.

Here is the call graph for this function:

◆ load_lakitu_tlut_x64()

u8 * load_lakitu_tlut_x64 ( const char ** textureList,
size_t length )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_track()

void load_track ( s32 trackId)

Loads & DMAs track data. Vtx, textures, displaylists, etc.

Parameters
trackId
Here is the call graph for this function:
Here is the caller graph for this function:

◆ main_pool_alloc()

UNUSED void * main_pool_alloc ( uintptr_t size,
uintptr_t side )

Allocate a block of memory from the pool of given size, and from the specified side of the pool (MEMORY_POOL_LEFT or MEMORY_POOL_RIGHT). If there is not enough space, return NULL.

Here is the caller graph for this function:

◆ main_pool_available()

UNUSED uintptr_t main_pool_available ( void )

◆ main_pool_free()

UNUSED uintptr_t main_pool_free ( void * addr)

Free a block of memory that was allocated from the pool. The block must be the most recently allocated block from its end of the pool, otherwise all newer blocks are freed as well. Return the amount of free space left in the pool.

Here is the caller graph for this function:

◆ main_pool_init()

UNUSED void main_pool_init ( uintptr_t start,
uintptr_t end )

◆ main_pool_pop_state()

UNUSED uintptr_t main_pool_pop_state ( void )

Restore pool state from a previous call to main_pool_push_state. Return the amount of free space left in the pool.

◆ main_pool_push_state()

UNUSED uintptr_t main_pool_push_state ( void )
Here is the call graph for this function:

◆ main_pool_realloc()

UNUSED void * main_pool_realloc ( void * addr,
uintptr_t size )
Here is the call graph for this function:

◆ MIO0_0F()

uintptr_t MIO0_0F ( u8 * arg0,
uintptr_t arg1,
uintptr_t arg2 )
Here is the call graph for this function:

Variable Documentation

◆ D_802B8CD4

struct UnkStruct_802B8CD4 D_802B8CD4[] = { 0 }

◆ D_802B8CE4

s32 D_802B8CE4 = 0

◆ dlSegEnd

uintptr_t dlSegEnd

◆ gMainPoolState

struct MainPoolState* gMainPoolState = NULL

◆ memoryPadding

s32 memoryPadding[2]

◆ sGfxSeekPosition

s32 sGfxSeekPosition

◆ sMemoryPool

u8 sMemoryPool[0xFFFFFFF]
static

◆ sPackedSeekPosition

s32 sPackedSeekPosition

◆ sPoolEnd

uintptr_t sPoolEnd = sMemoryPool + sizeof(sMemoryPool)

◆ sPoolFreeSpace

uintptr_t sPoolFreeSpace

◆ sPoolListHeadL

struct MainPoolBlock* sPoolListHeadL

◆ sPoolListHeadR

struct MainPoolBlock* sPoolListHeadR

◆ testaaa

Gfx* testaaa

◆ texSegEnd

uintptr_t texSegEnd

◆ texSegSize

size_t texSegSize

◆ vtxSegEnd

uintptr_t vtxSegEnd