Files
mazegame/engine/doc/html/files/memory-h.html
T

125 lines
20 KiB
HTML

<!DOCTYPE html>
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><meta http-equiv="X-UA-Compatible" content="IE=edge"><title>memory.h</title><link rel="stylesheet" type="text/css" href="../styles/main.css" /><script type="text/javascript" src="../styles/main.js"></script><script type="text/javascript">NDLoader.LoadJS("Content", "../styles/");</script></head>
<!-- Generated by Natural Docs, version 2.2 -->
<!-- saved from url=(0016)http://localhost -->
<body onload="NDLoader.OnLoad('Content');" class="NDPage NDContentPage">
<a name="Heap_handling"></a><a name="Topic996"></a><div class="CTopic TGroup LC first">
<div class="CTitle">Heap handling</div>
</div>
<a name="Mem_GetStackAddress"></a><a name="Topic997"></a><div class="CTopic TFunction LC">
<div class="CTitle">Mem_GetStackAddress</div>
<div id="NDPrototype997" class="NDPrototype"><div class="PSection PPlainSection">u16 Mem_GetStackAddress()</div></div>
<div class="CBody"><p>Get the current address of the stack top (lower address).</p><div class="CHeading">Return</div><p>Current stack bottom address</p></div>
</div>
<a name="Mem_GetHeapAddress"></a><a name="Topic998"></a><div class="CTopic TFunction LC">
<div class="CTitle">Mem_GetHeapAddress</div>
<div id="NDPrototype998" class="NDPrototype"><div class="PSection PPlainSection"><span class="SHKeyword">inline</span> u16 Mem_GetHeapAddress()</div></div>
<div class="CBody"><p>Get the current address of the heap top (higher address).</p><div class="CHeading">Return</div><p>Current heap top address</p></div>
</div>
<a name="Mem_GetHeapSize"></a><a name="Topic999"></a><div class="CTopic TFunction LC">
<div class="CTitle">Mem_GetHeapSize</div>
<div id="NDPrototype999" class="NDPrototype"><div class="PSection PPlainSection"><span class="SHKeyword">inline</span> u16 Mem_GetHeapSize()</div></div>
<div class="CBody"><p>Get the amount of free space in the heap.</p><div class="CHeading">Return</div><p>Get the current size of the heap (between heap top address and stack bottom one)</p></div>
</div>
<a name="Mem_HeapAlloc"></a><a name="Topic1000"></a><div class="CTopic TFunction LC">
<div class="CTitle">Mem_HeapAlloc</div>
<div id="NDPrototype1000" class="NDPrototype WideForm"><div class="PSection PParameterSection CStyle"><table><tr><td class="PBeforeParameters"><span class="SHKeyword">void</span>* Mem_HeapAlloc(</td><td class="PParametersParentCell"><table class="PParameters"><tr><td class="PType first">u16&nbsp;</td><td class="PName last">size</td></tr></table></td><td class="PAfterParameters">)</td></tr></table></div></div>
<div class="CBody"><p>Alloc a part of the heap.</p><div class="CHeading">Parameters</div><table class="CDefinitionList"><tr><td class="CDLEntry">size<div class="CDLParameterType">u16</div></td><td class="CDLDefinition"><p>The size of data to allocate</p></td></tr></table><div class="CHeading">Return</div><p>Pointer to allocated heap chunk</p></div>
</div>
<a name="Mem_HeapFree"></a><a name="Topic1001"></a><div class="CTopic TFunction LC">
<div class="CTitle">Mem_HeapFree</div>
<div id="NDPrototype1001" class="NDPrototype WideForm"><div class="PSection PParameterSection CStyle"><table><tr><td class="PBeforeParameters"><span class="SHKeyword">void</span> Mem_HeapFree(</td><td class="PParametersParentCell"><table class="PParameters"><tr><td class="PType first">u16&nbsp;</td><td class="PName last">size</td></tr></table></td><td class="PAfterParameters">)</td></tr></table></div></div>
<div class="CBody"><p>Free the last allocated area of the heap.</p><div class="CHeading">Parameters</div><table class="CDefinitionList"><tr><td class="CDLEntry">size<div class="CDLParameterType">u16</div></td><td class="CDLDefinition"><p>The size of data to allocate</p></td></tr></table></div>
</div>
<a name="Memory_content_modification"></a><a name="Topic1002"></a><div class="CTopic TGroup LC">
<div class="CTitle">Memory content modification</div>
</div>
<a name="Mem_Copy"></a><a name="Topic1003"></a><div class="CTopic TFunction LC">
<div class="CTitle">Mem_Copy</div>
<div id="NDPrototype1003" class="NDPrototype WideForm"><div class="PSection PParameterSection CStyle"><table><tr><td class="PBeforeParameters"><span class="SHKeyword">void</span> Mem_Copy(</td><td class="PParametersParentCell"><table class="PParameters"><tr><td class="PModifierQualifier first"><span class="SHKeyword">const</span>&nbsp;</td><td class="PType"><span class="SHKeyword">void</span>*&nbsp;</td><td class="PName last">src,</td></tr><tr><td class="first"></td><td class="PType"><span class="SHKeyword">void</span>*&nbsp;</td><td class="PName last">dest,</td></tr><tr><td class="first"></td><td class="PType">u16&nbsp;</td><td class="PName last">size</td></tr></table></td><td class="PAfterParameters">)</td></tr></table></div></div>
<div class="CBody"><p>Copy a memory block from a source address to another (minimal size of 1 byte).</p><div class="CHeading">Parameters</div><table class="CDefinitionList"><tr><td class="CDLEntry">src<div class="CDLParameterType"><span class="SHKeyword">const</span> <span class="SHKeyword">void</span>*</div></td><td class="CDLDefinition"><p>Source address</p></td></tr><tr><td class="CDLEntry">dst</td><td class="CDLDefinition"><p>Destination address</p></td></tr><tr><td class="CDLEntry">size<div class="CDLParameterType">u16</div></td><td class="CDLDefinition"><p>The size of data to copy. Note: A size of 0 mean 65536</p></td></tr></table></div>
</div>
<a name="Mem_Copy_16b"></a><a name="Topic1004"></a><div class="CTopic TFunction LC">
<div class="CTitle">Mem_Copy_16b</div>
<div id="NDPrototype1004" class="NDPrototype WideForm"><div class="PSection PParameterSection CStyle"><table><tr><td class="PBeforeParameters"><span class="SHKeyword">inline</span> <span class="SHKeyword">void</span> Mem_Copy_16b(</td><td class="PParametersParentCell"><table class="PParameters"><tr><td class="PModifierQualifier first"><span class="SHKeyword">const</span>&nbsp;</td><td class="PType"><span class="SHKeyword">void</span>*&nbsp;</td><td class="PName last">src,</td></tr><tr><td class="first"></td><td class="PType"><span class="SHKeyword">void</span>*&nbsp;</td><td class="PName last">dest,</td></tr><tr><td class="first"></td><td class="PType">u16&nbsp;</td><td class="PName last">size</td></tr></table></td><td class="PAfterParameters">)</td></tr></table></div></div>
<div class="CBody"><p>Copy a 16-bits memory block from a source address to another (minimal size of 1 word / 2 byte).</p><div class="CHeading">Parameters</div><table class="CDefinitionList"><tr><td class="CDLEntry">src<div class="CDLParameterType"><span class="SHKeyword">const</span> <span class="SHKeyword">void</span>*</div></td><td class="CDLDefinition"><p>Source address</p></td></tr><tr><td class="CDLEntry">dst</td><td class="CDLDefinition"><p>Destination address</p></td></tr><tr><td class="CDLEntry">size<div class="CDLParameterType">u16</div></td><td class="CDLDefinition"><p>The size of 16-bits data to copy. Note: size can be 1 to 32767. 0 mean 32768</p></td></tr></table></div>
</div>
<a name="Mem_FastCopy"></a><a name="Topic1005"></a><div class="CTopic TFunction LC">
<div class="CTitle">Mem_FastCopy</div>
<div id="NDPrototype1005" class="NDPrototype WideForm"><div class="PSection PParameterSection CStyle"><table><tr><td class="PBeforeParameters"><span class="SHKeyword">void</span> Mem_FastCopy(</td><td class="PParametersParentCell"><table class="PParameters"><tr><td class="PModifierQualifier first"><span class="SHKeyword">const</span>&nbsp;</td><td class="PType"><span class="SHKeyword">void</span>*&nbsp;</td><td class="PName last">src,</td></tr><tr><td class="first"></td><td class="PType"><span class="SHKeyword">void</span>*&nbsp;</td><td class="PName last">dest,</td></tr><tr><td class="first"></td><td class="PType">u16&nbsp;</td><td class="PName last">size</td></tr></table></td><td class="PAfterParameters">)</td></tr></table></div></div>
<div class="CBody"><p>Fast copy a memory block from a source address to a destination.&nbsp; Use 16 unrolled-LDI loop.</p><div class="CHeading">Parameters</div><table class="CDefinitionList"><tr><td class="CDLEntry">src<div class="CDLParameterType"><span class="SHKeyword">const</span> <span class="SHKeyword">void</span>*</div></td><td class="CDLDefinition"><p>Source address</p></td></tr><tr><td class="CDLEntry">dst</td><td class="CDLDefinition"><p>Destination address</p></td></tr><tr><td class="CDLEntry">size<div class="CDLParameterType">u16</div></td><td class="CDLDefinition"><p>The size of data to copy. Note: A size of 0 mean 65536</p></td></tr></table></div>
</div>
<a name="Mem_FastCopy_16b"></a><a name="Topic1006"></a><div class="CTopic TFunction LC">
<div class="CTitle">Mem_FastCopy_16b</div>
<div id="NDPrototype1006" class="NDPrototype WideForm"><div class="PSection PParameterSection CStyle"><table><tr><td class="PBeforeParameters"><span class="SHKeyword">inline</span> <span class="SHKeyword">void</span> Mem_FastCopy_16b(</td><td class="PParametersParentCell"><table class="PParameters"><tr><td class="PModifierQualifier first"><span class="SHKeyword">const</span>&nbsp;</td><td class="PType"><span class="SHKeyword">void</span>*&nbsp;</td><td class="PName last">src,</td></tr><tr><td class="first"></td><td class="PType"><span class="SHKeyword">void</span>*&nbsp;</td><td class="PName last">dest,</td></tr><tr><td class="first"></td><td class="PType">u16&nbsp;</td><td class="PName last">size</td></tr></table></td><td class="PAfterParameters">)</td></tr></table></div></div>
<div class="CBody"><p>Fast copy a 16-bits memory block from a source address to a destination.&nbsp; Use 16 unrolled-LDI loop.</p><div class="CHeading">Parameters</div><table class="CDefinitionList"><tr><td class="CDLEntry">src<div class="CDLParameterType"><span class="SHKeyword">const</span> <span class="SHKeyword">void</span>*</div></td><td class="CDLDefinition"><p>Source address</p></td></tr><tr><td class="CDLEntry">dst</td><td class="CDLDefinition"><p>Destination address</p></td></tr><tr><td class="CDLEntry">size<div class="CDLParameterType">u16</div></td><td class="CDLDefinition"><p>The size of data to copy. Note: size can be 1 to 32767. 0 mean 32768</p></td></tr></table></div>
</div>
<a name="Mem_Set"></a><a name="Topic1007"></a><div class="CTopic TFunction LC">
<div class="CTitle">Mem_Set</div>
<div id="NDPrototype1007" class="NDPrototype WideForm"><div class="PSection PParameterSection CStyle"><table><tr><td class="PBeforeParameters"><span class="SHKeyword">void</span> Mem_Set(</td><td class="PParametersParentCell"><table class="PParameters"><tr><td class="PType first">u8&nbsp;</td><td class="PName last">val,</td></tr><tr><td class="PType first"><span class="SHKeyword">void</span>*&nbsp;</td><td class="PName last">dest,</td></tr><tr><td class="PType first">u16&nbsp;</td><td class="PName last">size</td></tr></table></td><td class="PAfterParameters">)</td></tr></table></div></div>
<div class="CBody"><p>Fill a memory block with a given 8-bits value (minimal size of 2 bytes).</p><div class="CHeading">Parameters</div><table class="CDefinitionList"><tr><td class="CDLEntry">val<div class="CDLParameterType">u8</div></td><td class="CDLDefinition"><p>Value to write</p></td></tr><tr><td class="CDLEntry">dst</td><td class="CDLDefinition"><p>Destination address</p></td></tr><tr><td class="CDLEntry">size<div class="CDLParameterType">u16</div></td><td class="CDLDefinition"><p>The size of data to fill. Note: A size of 0 mean 65536</p></td></tr></table></div>
</div>
<a name="Mem_Set_16b"></a><a name="Topic1008"></a><div class="CTopic TFunction LC">
<div class="CTitle">Mem_Set_16b</div>
<div id="NDPrototype1008" class="NDPrototype WideForm"><div class="PSection PParameterSection CStyle"><table><tr><td class="PBeforeParameters"><span class="SHKeyword">void</span> Mem_Set_16b(</td><td class="PParametersParentCell"><table class="PParameters"><tr><td class="PType first">u16&nbsp;</td><td class="PName last">val,</td></tr><tr><td class="PType first"><span class="SHKeyword">void</span>*&nbsp;</td><td class="PName last">dest,</td></tr><tr><td class="PType first">u16&nbsp;</td><td class="PName last">size</td></tr></table></td><td class="PAfterParameters">)</td></tr></table></div></div>
<div class="CBody"><p>Fill a memory block with a given 16-bits value (minimal size of 2 bytes).</p><div class="CHeading">Parameters</div><table class="CDefinitionList"><tr><td class="CDLEntry">val<div class="CDLParameterType">u16</div></td><td class="CDLDefinition"><p>Value to write</p></td></tr><tr><td class="CDLEntry">dst</td><td class="CDLDefinition"><p>Destination address</p></td></tr><tr><td class="CDLEntry">size<div class="CDLParameterType">u16</div></td><td class="CDLDefinition"><p>The size of data to fill. Note: size can be 1 to 32767. 0 mean 32768</p></td></tr></table></div>
</div>
<a name="Mem_FastSet"></a><a name="Topic1009"></a><div class="CTopic TFunction LC">
<div class="CTitle">Mem_FastSet</div>
<div id="NDPrototype1009" class="NDPrototype WideForm"><div class="PSection PParameterSection CStyle"><table><tr><td class="PBeforeParameters"><span class="SHKeyword">void</span> Mem_FastSet(</td><td class="PParametersParentCell"><table class="PParameters"><tr><td class="PType first">u8&nbsp;</td><td class="PName last">val,</td></tr><tr><td class="PType first"><span class="SHKeyword">void</span>*&nbsp;</td><td class="PName last">dest,</td></tr><tr><td class="PType first">u16&nbsp;</td><td class="PName last">size</td></tr></table></td><td class="PAfterParameters">)</td></tr></table></div></div>
<div class="CBody"><p>Fast fill a memory chunk with a given value (minimal size of 2 bytes).&nbsp; Use 16 unrolled-LDI loop.</p><div class="CHeading">Parameters</div><table class="CDefinitionList"><tr><td class="CDLEntry">val<div class="CDLParameterType">u8</div></td><td class="CDLDefinition"><p>Value to write</p></td></tr><tr><td class="CDLEntry">dst</td><td class="CDLDefinition"><p>Destination address</p></td></tr><tr><td class="CDLEntry">size<div class="CDLParameterType">u16</div></td><td class="CDLDefinition"><p>The size of data to fill. Note: A size of 0 mean 65536</p></td></tr></table></div>
</div>
<a name="Dynamic_allocator"></a><a name="Topic1010"></a><div class="CTopic TGroup LC">
<div class="CTitle">Dynamic allocator</div>
</div>
<a name="Mem_DynamicInitialize"></a><a name="Topic1011"></a><div class="CTopic TFunction LC">
<div class="CTitle">Mem_DynamicInitialize</div>
<div id="NDPrototype1011" class="NDPrototype WideForm"><div class="PSection PParameterSection CStyle"><table><tr><td class="PBeforeParameters"><span class="SHKeyword">void</span> Mem_DynamicInitialize(</td><td class="PParametersParentCell"><table class="PParameters"><tr><td class="PType first"><span class="SHKeyword">void</span>*&nbsp;</td><td class="PName last">base,</td></tr><tr><td class="PType first">u16&nbsp;</td><td class="PName last">size</td></tr></table></td><td class="PAfterParameters">)</td></tr></table></div></div>
<div class="CBody"><p>Allocates a static memory chunk which can then be used to allocate chunks dynamically.&nbsp; Memory chunk can be in any pages but: - The memory space have to be continuous from a Z80 perspective.&nbsp; - You have to ensure that all memory segments are selected in their proper place when allocating or releasing memory.</p><div class="CHeading">Parameters</div><table class="CDefinitionList"><tr><td class="CDLEntry">base<div class="CDLParameterType"><span class="SHKeyword">void</span>*</div></td><td class="CDLDefinition"><p>Base address of the dynamic allocator memory buffer</p></td></tr><tr><td class="CDLEntry">size<div class="CDLParameterType">u16</div></td><td class="CDLDefinition"><p>Size of the dynamic allocator buffer (4 bytes chunk headers will consume some of this space)</p></td></tr></table></div>
</div>
<a name="Mem_DynamicInitializeHeap"></a><a name="Topic1012"></a><div class="CTopic TFunction LC">
<div class="CTitle">Mem_DynamicInitializeHeap</div>
<div id="NDPrototype1012" class="NDPrototype WideForm"><div class="PSection PParameterSection CStyle"><table><tr><td class="PBeforeParameters"><span class="SHKeyword">inline</span> <span class="SHKeyword">void</span> Mem_DynamicInitializeHeap(</td><td class="PParametersParentCell"><table class="PParameters"><tr><td class="PType first">u16&nbsp;</td><td class="PName last">size</td></tr></table></td><td class="PAfterParameters">)</td></tr></table></div></div>
<div class="CBody"><p>Allocates a static memory chunk in the heap which can then be used to allocate chunks dynamically.</p><div class="CHeading">Parameters</div><table class="CDefinitionList"><tr><td class="CDLEntry">size<div class="CDLParameterType">u16</div></td><td class="CDLDefinition"><p>Size of the dynamic allocator buffer (4 bytes chunk headers will consume some of this space)</p></td></tr></table></div>
</div>
<a name="Mem_DynamicAlloc"></a><a name="Topic1013"></a><div class="CTopic TFunction LC">
<div class="CTitle">Mem_DynamicAlloc</div>
<div id="NDPrototype1013" class="NDPrototype WideForm"><div class="PSection PParameterSection CStyle"><table><tr><td class="PBeforeParameters"><span class="SHKeyword">void</span>* Mem_DynamicAlloc(</td><td class="PParametersParentCell"><table class="PParameters"><tr><td class="PType first">u16&nbsp;</td><td class="PName last">size</td></tr></table></td><td class="PAfterParameters">)</td></tr></table></div></div>
<div class="CBody"><p>Allocate a memory chunk from the dynamic memory buffer</p><div class="CHeading">Parameters</div><table class="CDefinitionList"><tr><td class="CDLEntry">size<div class="CDLParameterType">u16</div></td><td class="CDLDefinition"><p>Size of the memory chunk to allocate. Note: Even if you can allocate 0 sized chunk, this is useless</p></td></tr></table><div class="CHeading">Return</div><p>Address of the allocated memory chunk (or NULL if no enough continuous space have been found)</p></div>
</div>
<a name="Mem_DynamicFree"></a><a name="Topic1014"></a><div class="CTopic TFunction LC">
<div class="CTitle">Mem_DynamicFree</div>
<div id="NDPrototype1014" class="NDPrototype WideForm"><div class="PSection PParameterSection CStyle"><table><tr><td class="PBeforeParameters"><span class="SHKeyword">void</span> Mem_DynamicFree(</td><td class="PParametersParentCell"><table class="PParameters"><tr><td class="PType first"><span class="SHKeyword">void</span>*&nbsp;</td><td class="PName last">ptr</td></tr></table></td><td class="PAfterParameters">)</td></tr></table></div></div>
<div class="CBody"><p>Free a memory chunk from the dynamic memory buffer</p><div class="CHeading">Parameters</div><table class="CDefinitionList"><tr><td class="CDLEntry">ptr<div class="CDLParameterType"><span class="SHKeyword">void</span>*</div></td><td class="CDLDefinition"><p>Address of the allocated memory chunk</p></td></tr></table></div>
</div>
<a name="Mem_GetDynamicSize"></a><a name="Topic1015"></a><div class="CTopic TFunction LC last">
<div class="CTitle">Mem_GetDynamicSize</div>
<div id="NDPrototype1015" class="NDPrototype WideForm"><div class="PSection PParameterSection CStyle"><table><tr><td class="PBeforeParameters"><span class="SHKeyword">inline</span> u16 Mem_GetDynamicSize(</td><td class="PParametersParentCell"><table class="PParameters"><tr><td class="PType first"><span class="SHKeyword">void</span>*&nbsp;</td><td class="PName last">ptr</td></tr></table></td><td class="PAfterParameters">)</td></tr></table></div></div>
<div class="CBody"><p>Get the size of a dynamically allocated memory chunk</p><div class="CHeading">Parameters</div><table class="CDefinitionList"><tr><td class="CDLEntry">ptr<div class="CDLParameterType"><span class="SHKeyword">void</span>*</div></td><td class="CDLDefinition"><p>Address of the allocated memory chunk</p></td></tr></table><div class="CHeading">Return</div><p>Size of the allocated memory chunk</p></div>
</div>
</body></html>