libctru v2.5.0
Loading...
Searching...
No Matches
vram.h
Go to the documentation of this file.
1/**
2 * @file vram.h
3 * @brief VRAM allocator.
4 */
5#pragma once
6
7typedef enum vramAllocPos
8{
9 VRAM_ALLOC_A = BIT(0),
10 VRAM_ALLOC_B = BIT(1),
11 VRAM_ALLOC_ANY = VRAM_ALLOC_A | VRAM_ALLOC_B,
12} vramAllocPos;
13
14/**
15 * @brief Allocates a 0x80-byte aligned buffer.
16 * @param size Size of the buffer to allocate.
17 * @return The allocated buffer.
18 */
19void* vramAlloc(size_t size);
20
21/**
22 * @brief Allocates a 0x80-byte aligned buffer in the given VRAM bank.
23 * @param size Size of the buffer to allocate.
24 * @param pos VRAM bank to use (see \ref vramAllocPos).
25 * @return The allocated buffer.
26 */
27void* vramAllocAt(size_t size, vramAllocPos pos);
28
29/**
30 * @brief Allocates a buffer aligned to the given size.
31 * @param size Size of the buffer to allocate.
32 * @param alignment Alignment to use.
33 * @return The allocated buffer.
34 */
35void* vramMemAlign(size_t size, size_t alignment);
36
37/**
38 * @brief Allocates a buffer aligned to the given size in the given VRAM bank.
39 * @param size Size of the buffer to allocate.
40 * @param alignment Alignment to use.
41 * @param pos VRAM bank to use (see \ref vramAllocPos).
42 * @return The allocated buffer.
43 */
44void* vramMemAlignAt(size_t size, size_t alignment, vramAllocPos pos);
45
46/**
47 * @brief Reallocates a buffer.
48 * Note: Not implemented yet.
49 * @param mem Buffer to reallocate.
50 * @param size Size of the buffer to allocate.
51 * @return The reallocated buffer.
52 */
53void* vramRealloc(void* mem, size_t size);
54
55/**
56 * @brief Retrieves the allocated size of a buffer.
57 * @return The size of the buffer.
58 */
59size_t vramGetSize(void* mem);
60
61/**
62 * @brief Frees a buffer.
63 * @param mem Buffer to free.
64 */
65void vramFree(void* mem);
66
67/**
68 * @brief Gets the current VRAM free space.
69 * @return The current VRAM free space.
70 */
#define BIT(n)
Creates a bitmask from a bit number.
Definition types.h:47
uint32_t u32
32-bit unsigned integer
Definition types.h:23
void * vramMemAlignAt(size_t size, size_t alignment, vramAllocPos pos)
Allocates a buffer aligned to the given size in the given VRAM bank.
void * vramAlloc(size_t size)
Allocates a 0x80-byte aligned buffer.
void * vramRealloc(void *mem, size_t size)
Reallocates a buffer.
u32 vramSpaceFree(void)
Gets the current VRAM free space.
void vramFree(void *mem)
Frees a buffer.
void * vramMemAlign(size_t size, size_t alignment)
Allocates a buffer aligned to the given size.
void * vramAllocAt(size_t size, vramAllocPos pos)
Allocates a 0x80-byte aligned buffer in the given VRAM bank.
size_t vramGetSize(void *mem)
Retrieves the allocated size of a buffer.