Files
gbdk-2020/docs/api/rand_8h.html
2021-09-24 16:34:00 +03:00

236 lines
12 KiB
HTML

<!-- HTML header for doxygen 1.8.14-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="cache-control" content="max-age=86400"/>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.20"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>GBDK 2020 Docs: rand.h File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="doxygen_extra.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td id="projectalign" style="padding-left: 0.5em;">
<div id="projectname">GBDK 2020 Docs
</div>
<div id="projectbrief">API Documentation for GBDK 2020</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.20 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
initMenu('',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
<div id="nav-tree">
<div id="nav-tree-contents">
<div id="nav-sync" class="sync"></div>
</div>
</div>
<div id="splitbar" style="-moz-user-select:none;"
class="ui-resizable-handle">
</div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('rand_8h.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<div class="header">
<div class="summary">
<a href="#func-members">Functions</a> </div>
<div class="headertitle">
<div class="title">rand.h File Reference</div> </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><code>#include &lt;<a class="el" href="types_8h_source.html">types.h</a>&gt;</code><br />
<code>#include &lt;<a class="el" href="stdint_8h_source.html">stdint.h</a>&gt;</code><br />
</div>
<p><a href="rand_8h_source.html">Go to the source code of this file.</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:a964538799843c0ba5bd01151ef7e2640"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="rand_8h.html#a964538799843c0ba5bd01151ef7e2640">initrand</a> (<a class="el" href="stdint_8h.html#adf4d876453337156dde61095e1f20223">uint16_t</a> seed) <a class="el" href="asm_2types_8h.html#a0971918860055db2e50dacea4da8f3bc">OLDCALL</a></td></tr>
<tr class="separator:a964538799843c0ba5bd01151ef7e2640"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ad81c61515217f062f5872031a7761fef"><td class="memItemLeft" align="right" valign="top"><a class="el" href="stdint_8h.html#aef44329758059c91c76d334e8fc09700">int8_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="rand_8h.html#ad81c61515217f062f5872031a7761fef">rand</a> () <a class="el" href="asm_2types_8h.html#a0971918860055db2e50dacea4da8f3bc">OLDCALL</a></td></tr>
<tr class="separator:ad81c61515217f062f5872031a7761fef"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ac659150eb39aae2f523bef6554b19b77"><td class="memItemLeft" align="right" valign="top"><a class="el" href="stdint_8h.html#adf4d876453337156dde61095e1f20223">uint16_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="rand_8h.html#ac659150eb39aae2f523bef6554b19b77">randw</a> () <a class="el" href="asm_2types_8h.html#a0971918860055db2e50dacea4da8f3bc">OLDCALL</a></td></tr>
<tr class="separator:ac659150eb39aae2f523bef6554b19b77"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a333400f85febd7e1360835955103db8b"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="rand_8h.html#a333400f85febd7e1360835955103db8b">initarand</a> (<a class="el" href="stdint_8h.html#adf4d876453337156dde61095e1f20223">uint16_t</a> seed) <a class="el" href="asm_2types_8h.html#a0971918860055db2e50dacea4da8f3bc">OLDCALL</a></td></tr>
<tr class="separator:a333400f85febd7e1360835955103db8b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ac3154758c17a5960a730a0a7c0fa7b0b"><td class="memItemLeft" align="right" valign="top"><a class="el" href="stdint_8h.html#aef44329758059c91c76d334e8fc09700">int8_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="rand_8h.html#ac3154758c17a5960a730a0a7c0fa7b0b">arand</a> () <a class="el" href="asm_2types_8h.html#a0971918860055db2e50dacea4da8f3bc">OLDCALL</a></td></tr>
<tr class="separator:ac3154758c17a5960a730a0a7c0fa7b0b"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>Random generator using the linear congruential method</p>
<dl class="section author"><dt>Author</dt><dd>Luc Van den Borre </dd></dl>
</div><h2 class="groupheader">Function Documentation</h2>
<a id="a964538799843c0ba5bd01151ef7e2640"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a964538799843c0ba5bd01151ef7e2640">&#9670;&nbsp;</a></span>initrand()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void initrand </td>
<td>(</td>
<td class="paramtype"><a class="el" href="stdint_8h.html#adf4d876453337156dde61095e1f20223">uint16_t</a>&#160;</td>
<td class="paramname"><em>seed</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Initalise the pseudo-random number generator.</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">seed</td><td>The value for initializing the random number generator.</td></tr>
</table>
</dd>
</dl>
<p>The seed should be different each time, otherwise the same pseudo-random sequence will be generated.</p>
<p>The DIV Register (<a class="el" href="gb_2hardware_8h.html#afa1e18e47bf68ce68d7807fff6edf16b">DIV_REG</a>) is sometimes used as a seed, particularly if read at some variable point in time (such as when the player presses a button).</p>
<p>Only needs to be called once to initialize, buy may be called again to re-initialize with the same or a different seed. </p><dl class="section see"><dt>See also</dt><dd><a class="el" href="rand_8h.html#ad81c61515217f062f5872031a7761fef">rand()</a>, <a class="el" href="rand_8h.html#ac659150eb39aae2f523bef6554b19b77">randw()</a> </dd></dl>
</div>
</div>
<a id="ad81c61515217f062f5872031a7761fef"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ad81c61515217f062f5872031a7761fef">&#9670;&nbsp;</a></span>rand()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="stdint_8h.html#aef44329758059c91c76d334e8fc09700">int8_t</a> rand </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Returns a random byte (8 bit) value.</p>
<p><a class="el" href="rand_8h.html#a964538799843c0ba5bd01151ef7e2640">initrand()</a> should be used to initialize the random number generator before using <a class="el" href="rand_8h.html#ad81c61515217f062f5872031a7761fef">rand()</a> </p>
</div>
</div>
<a id="ac659150eb39aae2f523bef6554b19b77"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ac659150eb39aae2f523bef6554b19b77">&#9670;&nbsp;</a></span>randw()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="stdint_8h.html#adf4d876453337156dde61095e1f20223">uint16_t</a> randw </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Returns a random word (16 bit) value.</p>
<p><a class="el" href="rand_8h.html#a964538799843c0ba5bd01151ef7e2640">initrand()</a> should be used to initialize the random number generator before using <a class="el" href="rand_8h.html#ad81c61515217f062f5872031a7761fef">rand()</a> </p>
</div>
</div>
<a id="a333400f85febd7e1360835955103db8b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a333400f85febd7e1360835955103db8b">&#9670;&nbsp;</a></span>initarand()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void initarand </td>
<td>(</td>
<td class="paramtype"><a class="el" href="stdint_8h.html#adf4d876453337156dde61095e1f20223">uint16_t</a>&#160;</td>
<td class="paramname"><em>seed</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Random generator using the linear lagged additive method</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">seed</td><td>The value for initializing the random number generator.</td></tr>
</table>
</dd>
</dl>
<p>Note: <a class="el" href="rand_8h.html#a333400f85febd7e1360835955103db8b">initarand()</a> calls <a class="el" href="rand_8h.html#a964538799843c0ba5bd01151ef7e2640">initrand()</a> with the same seed value, and uses <a class="el" href="rand_8h.html#ad81c61515217f062f5872031a7761fef">rand()</a> to initialize the random generator.</p>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="rand_8h.html#a964538799843c0ba5bd01151ef7e2640">initrand()</a> for suggestions about seed values, <a class="el" href="rand_8h.html#ac3154758c17a5960a730a0a7c0fa7b0b">arand()</a> </dd></dl>
</div>
</div>
<a id="ac3154758c17a5960a730a0a7c0fa7b0b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ac3154758c17a5960a730a0a7c0fa7b0b">&#9670;&nbsp;</a></span>arand()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="stdint_8h.html#aef44329758059c91c76d334e8fc09700">int8_t</a> arand </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Returns a random number generated with the linear lagged additive method.</p>
<p><a class="el" href="rand_8h.html#a333400f85febd7e1360835955103db8b">initarand()</a> should be used to initialize the random number generator before using <a class="el" href="rand_8h.html#ac3154758c17a5960a730a0a7c0fa7b0b">arand()</a> </p>
</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- HTML footer for doxygen 1.8.14-->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
</div>
</body>
</html>