Files
gbdk-2020/docs/api/rand_8h.html
2021-09-10 11:47:31 +03:00

239 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:a60388a55aa51a3950fab556d472c2768"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="rand_8h.html#a60388a55aa51a3950fab556d472c2768">initrand</a> (<a class="el" href="stdint_8h.html#adf4d876453337156dde61095e1f20223">uint16_t</a> seed)</td></tr>
<tr class="separator:a60388a55aa51a3950fab556d472c2768"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a2c1b2cc92ec9f0c0b2fd90876ba5c8ec"><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#a2c1b2cc92ec9f0c0b2fd90876ba5c8ec">rand</a> (void)</td></tr>
<tr class="separator:a2c1b2cc92ec9f0c0b2fd90876ba5c8ec"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a78fb5ab799d1193062eee3645bae93c2"><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#a78fb5ab799d1193062eee3645bae93c2">randw</a> (void)</td></tr>
<tr class="separator:a78fb5ab799d1193062eee3645bae93c2"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ae54bd9c3d48dfab0754499a3a7ba8a30"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="rand_8h.html#ae54bd9c3d48dfab0754499a3a7ba8a30">initarand</a> (<a class="el" href="stdint_8h.html#adf4d876453337156dde61095e1f20223">uint16_t</a> seed)</td></tr>
<tr class="separator:ae54bd9c3d48dfab0754499a3a7ba8a30"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ab6b156c085bb1daf9098eba18575bf03"><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#ab6b156c085bb1daf9098eba18575bf03">arand</a> (void)</td></tr>
<tr class="separator:ab6b156c085bb1daf9098eba18575bf03"><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="a60388a55aa51a3950fab556d472c2768"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a60388a55aa51a3950fab556d472c2768">&#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#a2c1b2cc92ec9f0c0b2fd90876ba5c8ec">rand()</a>, <a class="el" href="rand_8h.html#a78fb5ab799d1193062eee3645bae93c2">randw()</a> </dd></dl>
</div>
</div>
<a id="a2c1b2cc92ec9f0c0b2fd90876ba5c8ec"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a2c1b2cc92ec9f0c0b2fd90876ba5c8ec">&#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="paramtype">void&#160;</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#a60388a55aa51a3950fab556d472c2768">initrand()</a> should be used to initialize the random number generator before using <a class="el" href="rand_8h.html#a2c1b2cc92ec9f0c0b2fd90876ba5c8ec">rand()</a> </p>
</div>
</div>
<a id="a78fb5ab799d1193062eee3645bae93c2"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a78fb5ab799d1193062eee3645bae93c2">&#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="paramtype">void&#160;</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#a60388a55aa51a3950fab556d472c2768">initrand()</a> should be used to initialize the random number generator before using <a class="el" href="rand_8h.html#a2c1b2cc92ec9f0c0b2fd90876ba5c8ec">rand()</a> </p>
</div>
</div>
<a id="ae54bd9c3d48dfab0754499a3a7ba8a30"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ae54bd9c3d48dfab0754499a3a7ba8a30">&#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#ae54bd9c3d48dfab0754499a3a7ba8a30">initarand()</a> calls <a class="el" href="rand_8h.html#a60388a55aa51a3950fab556d472c2768">initrand()</a> with the same seed value, and uses <a class="el" href="rand_8h.html#a2c1b2cc92ec9f0c0b2fd90876ba5c8ec">rand()</a> to initialize the random generator.</p>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="rand_8h.html#a60388a55aa51a3950fab556d472c2768">initrand()</a> for suggestions about seed values, <a class="el" href="rand_8h.html#ab6b156c085bb1daf9098eba18575bf03">arand()</a> </dd></dl>
</div>
</div>
<a id="ab6b156c085bb1daf9098eba18575bf03"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ab6b156c085bb1daf9098eba18575bf03">&#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="paramtype">void&#160;</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#ae54bd9c3d48dfab0754499a3a7ba8a30">initarand()</a> should be used to initialize the random number generator before using <a class="el" href="rand_8h.html#ab6b156c085bb1daf9098eba18575bf03">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>