![]() |
DSC Engine
|
flexible VRAM manager More...
#include <allocator.hpp>
Public Member Functions | |
| Allocator (int offset, int length) | |
| Creates a new allocator instance. More... | |
| void * | reserve (int size, int desired_offset=-1) |
The equivalent of malloc(size). More... | |
| void | release (void *address) |
| frees the specified offset More... | |
Static Public Member Functions | |
| static Allocator | defaultMainSpriteVram () |
| static Allocator | defaultSubSpriteVram () |
flexible VRAM manager
| DSC::Allocator::Allocator | ( | int | offset, |
| int | length | ||
| ) |
Creates a new allocator instance.
| [in] | offset | base segment offset |
| [in] | length | base segment length |
This object allocates addresses in range [offset, offset+length-1]
| void DSC::Allocator::release | ( | void * | address | ) |
frees the specified offset
| [in] | address | offset to free |
No penalties if the address isn't in the allocator's range, it points to unallocated memory or has been previosuly released.
| void * DSC::Allocator::reserve | ( | int | size, |
| int | desired_offset = -1 |
||
| ) |
The equivalent of malloc(size).
| [in] | size | Data length (works best in units of 32 bytes a.k.a. the size of a 4bpp tile) |
| [in] | desired_offset | If positive, the block of specified size tries to be placed at [base segment offset + desired_offset] |
nullptr if allocation failed.