vram.h
Go to the documentation of this file.
/**
* @file vram.h
* @brief VRAM allocator.
*/
#pragma once
typedef enum vramAllocPos
{
VRAM_ALLOC_A = BIT(0),
VRAM_ALLOC_B = BIT(1),
VRAM_ALLOC_ANY = VRAM_ALLOC_A | VRAM_ALLOC_B,
} vramAllocPos;
/**
* @brief Allocates a 0x80-byte aligned buffer.
* @param size Size of the buffer to allocate.
* @return The allocated buffer.
*/
void* vramAlloc(size_t size);
/**
* @brief Allocates a 0x80-byte aligned buffer in the given VRAM bank.
* @param size Size of the buffer to allocate.
* @param pos VRAM bank to use (see \ref vramAllocPos).
* @return The allocated buffer.
*/
void* vramAllocAt(size_t size, vramAllocPos pos);
/**
* @brief Allocates a buffer aligned to the given size.
* @param size Size of the buffer to allocate.
* @param alignment Alignment to use.
* @return The allocated buffer.
*/
void* vramMemAlign(size_t size, size_t alignment);
/**
* @brief Allocates a buffer aligned to the given size in the given VRAM bank.
* @param size Size of the buffer to allocate.
* @param alignment Alignment to use.
* @param pos VRAM bank to use (see \ref vramAllocPos).
* @return The allocated buffer.
*/
void* vramMemAlignAt(size_t size, size_t alignment, vramAllocPos pos);
/**
* @brief Reallocates a buffer.
* Note: Not implemented yet.
* @param mem Buffer to reallocate.
* @param size Size of the buffer to allocate.
* @return The reallocated buffer.
*/
void* vramRealloc(void* mem, size_t size);
/**
* @brief Retrieves the allocated size of a buffer.
* @return The size of the buffer.
*/
size_t vramGetSize(void* mem);
/**
* @brief Frees a buffer.
* @param mem Buffer to free.
*/
void vramFree(void* mem);
/**
* @brief Gets the current VRAM free space.
* @return The current VRAM free space.
*/
u32 vramSpaceFree(void);
BIT
#define BIT(n)
Creates a bitmask from a bit number.
Definition: types.h:47
u32
uint32_t u32
32-bit unsigned integer
Definition: types.h:23
vramAlloc
void * vramAlloc(size_t size)
Allocates a 0x80-byte aligned buffer.
vramMemAlign
void * vramMemAlign(size_t size, size_t alignment)
Allocates a buffer aligned to the given size.
vramMemAlignAt
void * vramMemAlignAt(size_t size, size_t alignment, vramAllocPos pos)
Allocates a buffer aligned to the given size in the given VRAM bank.
vramAllocAt
void * vramAllocAt(size_t size, vramAllocPos pos)
Allocates a 0x80-byte aligned buffer in the given VRAM bank.
vramSpaceFree
u32 vramSpaceFree(void)
Gets the current VRAM free space.
vramFree
void vramFree(void *mem)
Frees a buffer.
vramRealloc
void * vramRealloc(void *mem, size_t size)
Reallocates a buffer.
vramGetSize
size_t vramGetSize(void *mem)
Retrieves the allocated size of a buffer.