Get the current address of the stack top (lower address).
Current stack bottom address
Get the current address of the heap top (higher addresse).
Current heap top address
Get the amount of free space in the heap.
Get the current size of the heap (between heap top address and stack bottom one)
void* Mem_HeapAlloc( |
| ) |
Alloc a part of the heap.
size u16 | The size of data to allocate |
Pointer to allocated heap chunk
void Mem_HeapFree( |
| ) |
Free the last allocated area of the heap.
size u16 | The size of data to allocate |
void Mem_Copy( |
| ) |
Copy a memory block from a source address to an other (minimal size of 1 byte).
src const void* | Source address |
dst | Destination address |
size u16 | The size of data to copy. Note: A size of 0 mean 65536 |
inline void Mem_Copy_16b( |
| ) |
Copy a 16-bits memory block from a source address to an other (minimal size of 1 word / 2 byte).
src const void* | Source address |
dst | Destination address |
size u16 | The size of 16-bits data to copy. Note: size can be 1 to 32767. 0 mean 32768 |
void Mem_FastCopy( |
| ) |
Fast copy a memory block from a source address to a destination. Use 16 unrolled-LDI loop.
src const void* | Source address |
dst | Destination address |
size u16 | The size of data to copy. Note: A size of 0 mean 65536 |
inline void Mem_FastCopy_16b( |
| ) |
Fast copy a 16-bits memory block from a source address to a destination. Use 16 unrolled-LDI loop.
src const void* | Source address |
dst | Destination address |
size u16 | The size of data to copy. Note: size can be 1 to 32767. 0 mean 32768 |
void Mem_Set( |
| ) |
Fill a memory block with a given 8-bits value (minimal size of 2 bytes).
val u8 | Value to write |
dst | Destination address |
size u16 | The size of data to fill. Note: A size of 0 mean 65536 |
void Mem_Set_16b( |
| ) |
Fill a memory block with a given 16-bits value (minimal size of 2 bytes).
val u16 | Value to write |
dst | Destination address |
size u16 | The size of data to fill. Note: size can be 1 to 32767. 0 mean 32768 |
void Mem_FastSet( |
| ) |
Fast fill a memory chunk with a given value (minimal size of 2 bytes). Use 16 unrolled-LDI loop.
val u8 | Value to write |
dst | Destination address |
size u16 | The size of data to fill. Note: A size of 0 mean 65536 |
void Mem_DynamicInitialize( |
| ) |
Allocates a static memory chunk which can then be used to allocate chunks dynimically. Memory chunk can be in any pages but: - The memory space have to be continuous from a Z80 perspective. - You have to ensure that all memory segments are selected in their proper place when allocating or releasing memory.
base void* | Base address of the dynamic allocator memory buffer |
size u16 | Size of the dynamic allocator buffer (4 bytes chunk headers will consume some of this space) |
inline void Mem_DynamicInitializeHeap( |
| ) |
Allocates a static memory chunk in the heap which can then be used to allocate chunks dynimically.
size u16 | Size of the dynamic allocator buffer (4 bytes chunk headers will consume some of this space) |
void* Mem_DynamicAlloc( |
| ) |
Allocate a memory chunk from the dynamic memory buffer
size u16 | Size of the memory chunk to allocate. Note: Even if you can allocate 0 sized chunk, this is useless |
Address of the allocated memory chunk (or NULL if no enough continuous space have been found)
void Mem_DynamicFree( |
| ) |
Free a memory chunk from the dynamic memory buffer
ptr void* | Address of the allocated memory chunk |
inline u16 Mem_GetDynamicSize( |
| ) |
Get the size of a dynamically allocated memory chunk
ptr void* | Address of the allocated memory chunk |
Size of the allocated memory chunk