bcd_8h.html (17403B)
1<!-- HTML header for doxygen 1.8.14--> 2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 3<html xmlns="http://www.w3.org/1999/xhtml"> 4<head> 5<meta http-equiv="cache-control" content="max-age=86400"/> 6<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> 7<meta http-equiv="X-UA-Compatible" content="IE=9"/> 8<meta name="generator" content="Doxygen 1.8.20"/> 9<meta name="viewport" content="width=device-width, initial-scale=1"/> 10<title>GBDK 2020 Docs: gb/bcd.h File Reference</title> 11<link href="tabs.css" rel="stylesheet" type="text/css"/> 12<script type="text/javascript" src="jquery.js"></script> 13<script type="text/javascript" src="dynsections.js"></script> 14<link href="navtree.css" rel="stylesheet" type="text/css"/> 15<script type="text/javascript" src="resize.js"></script> 16<script type="text/javascript" src="navtreedata.js"></script> 17<script type="text/javascript" src="navtree.js"></script> 18<link href="search/search.css" rel="stylesheet" type="text/css"/> 19<script type="text/javascript" src="search/searchdata.js"></script> 20<script type="text/javascript" src="search/search.js"></script> 21<link href="doxygen.css" rel="stylesheet" type="text/css" /> 22<link href="doxygen_extra.css" rel="stylesheet" type="text/css"/> 23</head> 24<body> 25<div id="top"><!-- do not remove this div, it is closed by doxygen! --> 26<div id="titlearea"> 27<table cellspacing="0" cellpadding="0"> 28 <tbody> 29 <tr style="height: 56px;"> 30 <td id="projectalign" style="padding-left: 0.5em;"> 31 <div id="projectname">GBDK 2020 Docs 32  <span id="projectnumber">4.0.6</span> 33 </div> 34 <div id="projectbrief">API Documentation for GBDK 2020</div> 35 </td> 36 </tr> 37 </tbody> 38</table> 39</div> 40<!-- end header part --> 41<!-- Generated by Doxygen 1.8.20 --> 42<script type="text/javascript"> 43/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */ 44var searchBox = new SearchBox("searchBox", "search",false,'Search'); 45/* @license-end */ 46</script> 47<script type="text/javascript" src="menudata.js"></script> 48<script type="text/javascript" src="menu.js"></script> 49<script type="text/javascript"> 50/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */ 51$(function() { 52 initMenu('',true,false,'search.php','Search'); 53 $(document).ready(function() { init_search(); }); 54}); 55/* @license-end */</script> 56<div id="main-nav"></div> 57</div><!-- top --> 58<div id="side-nav" class="ui-resizable side-nav-resizable"> 59 <div id="nav-tree"> 60 <div id="nav-tree-contents"> 61 <div id="nav-sync" class="sync"></div> 62 </div> 63 </div> 64 <div id="splitbar" style="-moz-user-select:none;" 65 class="ui-resizable-handle"> 66 </div> 67</div> 68<script type="text/javascript"> 69/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */ 70$(document).ready(function(){initNavTree('bcd_8h.html',''); initResizable(); }); 71/* @license-end */ 72</script> 73<div id="doc-content"> 74<!-- window showing the filter options --> 75<div id="MSearchSelectWindow" 76 onmouseover="return searchBox.OnSearchSelectShow()" 77 onmouseout="return searchBox.OnSearchSelectHide()" 78 onkeydown="return searchBox.OnSearchSelectKey(event)"> 79</div> 80 81<!-- iframe showing the search results (closed by default) --> 82<div id="MSearchResultsWindow"> 83<iframe src="javascript:void(0)" frameborder="0" 84 name="MSearchResults" id="MSearchResults"> 85</iframe> 86</div> 87 88<div class="header"> 89 <div class="summary"> 90<a href="#define-members">Macros</a> | 91<a href="#typedef-members">Typedefs</a> | 92<a href="#func-members">Functions</a> </div> 93 <div class="headertitle"> 94<div class="title">bcd.h File Reference</div> </div> 95</div><!--header--> 96<div class="contents"> 97<div class="textblock"><code>#include <types.h></code><br /> 98<code>#include <<a class="el" href="stdint_8h_source.html">stdint.h</a>></code><br /> 99</div> 100<p><a href="bcd_8h_source.html">Go to the source code of this file.</a></p> 101<table class="memberdecls"> 102<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="define-members"></a> 103Macros</h2></td></tr> 104<tr class="memitem:a5b336fcb3fc84fe505dc7e14d0ec17a7"><td class="memItemLeft" align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="bcd_8h.html#a5b336fcb3fc84fe505dc7e14d0ec17a7">BCD_HEX</a>(v)   ((<a class="el" href="bcd_8h.html#a4813acd7f1852dd32b67175ca6aca2eb">BCD</a>)(v))</td></tr> 105<tr class="separator:a5b336fcb3fc84fe505dc7e14d0ec17a7"><td class="memSeparator" colspan="2"> </td></tr> 106<tr class="memitem:a8a3023920aa103a74c7d59007bcc7b6f"><td class="memItemLeft" align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="bcd_8h.html#a8a3023920aa103a74c7d59007bcc7b6f">MAKE_BCD</a>(v)   <a class="el" href="bcd_8h.html#a5b336fcb3fc84fe505dc7e14d0ec17a7">BCD_HEX</a>(0x ## v)</td></tr> 107<tr class="separator:a8a3023920aa103a74c7d59007bcc7b6f"><td class="memSeparator" colspan="2"> </td></tr> 108</table><table class="memberdecls"> 109<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="typedef-members"></a> 110Typedefs</h2></td></tr> 111<tr class="memitem:a4813acd7f1852dd32b67175ca6aca2eb"><td class="memItemLeft" align="right" valign="top">typedef <a class="el" href="stdint_8h.html#a33594304e786b158f3fb30289278f5af">uint32_t</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="bcd_8h.html#a4813acd7f1852dd32b67175ca6aca2eb">BCD</a></td></tr> 112<tr class="separator:a4813acd7f1852dd32b67175ca6aca2eb"><td class="memSeparator" colspan="2"> </td></tr> 113</table><table class="memberdecls"> 114<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a> 115Functions</h2></td></tr> 116<tr class="memitem:af3d125e9dbb48d630cf7e2f7d1343ba1"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="bcd_8h.html#af3d125e9dbb48d630cf7e2f7d1343ba1">uint2bcd</a> (<a class="el" href="stdint_8h.html#adf4d876453337156dde61095e1f20223">uint16_t</a> i, <a class="el" href="bcd_8h.html#a4813acd7f1852dd32b67175ca6aca2eb">BCD</a> *value) <a class="el" href="asm_2types_8h.html#a0971918860055db2e50dacea4da8f3bc">OLDCALL</a></td></tr> 117<tr class="separator:af3d125e9dbb48d630cf7e2f7d1343ba1"><td class="memSeparator" colspan="2"> </td></tr> 118<tr class="memitem:a0b14c76afa669863ed43c080f5baca98"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="bcd_8h.html#a0b14c76afa669863ed43c080f5baca98">bcd_add</a> (<a class="el" href="bcd_8h.html#a4813acd7f1852dd32b67175ca6aca2eb">BCD</a> *sour, const <a class="el" href="bcd_8h.html#a4813acd7f1852dd32b67175ca6aca2eb">BCD</a> *value) <a class="el" href="asm_2types_8h.html#a0971918860055db2e50dacea4da8f3bc">OLDCALL</a></td></tr> 119<tr class="separator:a0b14c76afa669863ed43c080f5baca98"><td class="memSeparator" colspan="2"> </td></tr> 120<tr class="memitem:a743275b2ee21c93633a933a2d3073d4e"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="bcd_8h.html#a743275b2ee21c93633a933a2d3073d4e">bcd_sub</a> (<a class="el" href="bcd_8h.html#a4813acd7f1852dd32b67175ca6aca2eb">BCD</a> *sour, const <a class="el" href="bcd_8h.html#a4813acd7f1852dd32b67175ca6aca2eb">BCD</a> *value) <a class="el" href="asm_2types_8h.html#a0971918860055db2e50dacea4da8f3bc">OLDCALL</a></td></tr> 121<tr class="separator:a743275b2ee21c93633a933a2d3073d4e"><td class="memSeparator" colspan="2"> </td></tr> 122<tr class="memitem:aec09ce7373727160488408c65fc8a91e"><td class="memItemLeft" align="right" valign="top"><a class="el" href="stdint_8h.html#aba7bc1797add20fe3efdf37ced1182c5">uint8_t</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="bcd_8h.html#aec09ce7373727160488408c65fc8a91e">bcd2text</a> (const <a class="el" href="bcd_8h.html#a4813acd7f1852dd32b67175ca6aca2eb">BCD</a> *bcd, <a class="el" href="stdint_8h.html#aba7bc1797add20fe3efdf37ced1182c5">uint8_t</a> tile_offset, <a class="el" href="stdint_8h.html#aba7bc1797add20fe3efdf37ced1182c5">uint8_t</a> *buffer) <a class="el" href="asm_2types_8h.html#a0971918860055db2e50dacea4da8f3bc">OLDCALL</a></td></tr> 123<tr class="separator:aec09ce7373727160488408c65fc8a91e"><td class="memSeparator" colspan="2"> </td></tr> 124</table> 125<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2> 126<div class="textblock"><p>Support for working with BCD (Binary Coded Decimal)</p> 127<p>See the example BCD project for additional details. </p> 128</div><h2 class="groupheader">Macro Definition Documentation</h2> 129<a id="a5b336fcb3fc84fe505dc7e14d0ec17a7"></a> 130<h2 class="memtitle"><span class="permalink"><a href="#a5b336fcb3fc84fe505dc7e14d0ec17a7">◆ </a></span>BCD_HEX</h2> 131 132<div class="memitem"> 133<div class="memproto"> 134 <table class="memname"> 135 <tr> 136 <td class="memname">#define BCD_HEX</td> 137 <td>(</td> 138 <td class="paramtype"> </td> 139 <td class="paramname">v</td><td>)</td> 140 <td>   ((<a class="el" href="bcd_8h.html#a4813acd7f1852dd32b67175ca6aca2eb">BCD</a>)(v))</td> 141 </tr> 142 </table> 143</div><div class="memdoc"> 144 145</div> 146</div> 147<a id="a8a3023920aa103a74c7d59007bcc7b6f"></a> 148<h2 class="memtitle"><span class="permalink"><a href="#a8a3023920aa103a74c7d59007bcc7b6f">◆ </a></span>MAKE_BCD</h2> 149 150<div class="memitem"> 151<div class="memproto"> 152 <table class="memname"> 153 <tr> 154 <td class="memname">#define MAKE_BCD</td> 155 <td>(</td> 156 <td class="paramtype"> </td> 157 <td class="paramname">v</td><td>)</td> 158 <td>   <a class="el" href="bcd_8h.html#a5b336fcb3fc84fe505dc7e14d0ec17a7">BCD_HEX</a>(0x ## v)</td> 159 </tr> 160 </table> 161</div><div class="memdoc"> 162<p>Converts an integer value into BCD format</p> 163<p>A maximum of 8 digits may be used </p> 164 165</div> 166</div> 167<h2 class="groupheader">Typedef Documentation</h2> 168<a id="a4813acd7f1852dd32b67175ca6aca2eb"></a> 169<h2 class="memtitle"><span class="permalink"><a href="#a4813acd7f1852dd32b67175ca6aca2eb">◆ </a></span>BCD</h2> 170 171<div class="memitem"> 172<div class="memproto"> 173 <table class="memname"> 174 <tr> 175 <td class="memname">typedef <a class="el" href="stdint_8h.html#a33594304e786b158f3fb30289278f5af">uint32_t</a> <a class="el" href="bcd_8h.html#a4813acd7f1852dd32b67175ca6aca2eb">BCD</a></td> 176 </tr> 177 </table> 178</div><div class="memdoc"> 179 180</div> 181</div> 182<h2 class="groupheader">Function Documentation</h2> 183<a id="af3d125e9dbb48d630cf7e2f7d1343ba1"></a> 184<h2 class="memtitle"><span class="permalink"><a href="#af3d125e9dbb48d630cf7e2f7d1343ba1">◆ </a></span>uint2bcd()</h2> 185 186<div class="memitem"> 187<div class="memproto"> 188 <table class="memname"> 189 <tr> 190 <td class="memname">void uint2bcd </td> 191 <td>(</td> 192 <td class="paramtype"><a class="el" href="stdint_8h.html#adf4d876453337156dde61095e1f20223">uint16_t</a> </td> 193 <td class="paramname"><em>i</em>, </td> 194 </tr> 195 <tr> 196 <td class="paramkey"></td> 197 <td></td> 198 <td class="paramtype"><a class="el" href="bcd_8h.html#a4813acd7f1852dd32b67175ca6aca2eb">BCD</a> * </td> 199 <td class="paramname"><em>value</em> </td> 200 </tr> 201 <tr> 202 <td></td> 203 <td>)</td> 204 <td></td><td></td> 205 </tr> 206 </table> 207</div><div class="memdoc"> 208<p>Converts integer <b>i</b> into BCD format (Binary Coded Decimal) </p><dl class="params"><dt>Parameters</dt><dd> 209 <table class="params"> 210 <tr><td class="paramname">i</td><td>Numeric value to convert </td></tr> 211 <tr><td class="paramname">value</td><td>Pointer to a BCD variable to store the converted result </td></tr> 212 </table> 213 </dd> 214</dl> 215 216</div> 217</div> 218<a id="a0b14c76afa669863ed43c080f5baca98"></a> 219<h2 class="memtitle"><span class="permalink"><a href="#a0b14c76afa669863ed43c080f5baca98">◆ </a></span>bcd_add()</h2> 220 221<div class="memitem"> 222<div class="memproto"> 223 <table class="memname"> 224 <tr> 225 <td class="memname">void bcd_add </td> 226 <td>(</td> 227 <td class="paramtype"><a class="el" href="bcd_8h.html#a4813acd7f1852dd32b67175ca6aca2eb">BCD</a> * </td> 228 <td class="paramname"><em>sour</em>, </td> 229 </tr> 230 <tr> 231 <td class="paramkey"></td> 232 <td></td> 233 <td class="paramtype">const <a class="el" href="bcd_8h.html#a4813acd7f1852dd32b67175ca6aca2eb">BCD</a> * </td> 234 <td class="paramname"><em>value</em> </td> 235 </tr> 236 <tr> 237 <td></td> 238 <td>)</td> 239 <td></td><td></td> 240 </tr> 241 </table> 242</div><div class="memdoc"> 243<p>Adds two numbers in BCD format: <b>sour</b> += <b>value</b> </p><dl class="params"><dt>Parameters</dt><dd> 244 <table class="params"> 245 <tr><td class="paramname">sour</td><td>Pointer to a BCD value to add to (and where the result is stored) </td></tr> 246 <tr><td class="paramname">value</td><td>Pointer to the BCD value to add to <b>sour</b> </td></tr> 247 </table> 248 </dd> 249</dl> 250 251</div> 252</div> 253<a id="a743275b2ee21c93633a933a2d3073d4e"></a> 254<h2 class="memtitle"><span class="permalink"><a href="#a743275b2ee21c93633a933a2d3073d4e">◆ </a></span>bcd_sub()</h2> 255 256<div class="memitem"> 257<div class="memproto"> 258 <table class="memname"> 259 <tr> 260 <td class="memname">void bcd_sub </td> 261 <td>(</td> 262 <td class="paramtype"><a class="el" href="bcd_8h.html#a4813acd7f1852dd32b67175ca6aca2eb">BCD</a> * </td> 263 <td class="paramname"><em>sour</em>, </td> 264 </tr> 265 <tr> 266 <td class="paramkey"></td> 267 <td></td> 268 <td class="paramtype">const <a class="el" href="bcd_8h.html#a4813acd7f1852dd32b67175ca6aca2eb">BCD</a> * </td> 269 <td class="paramname"><em>value</em> </td> 270 </tr> 271 <tr> 272 <td></td> 273 <td>)</td> 274 <td></td><td></td> 275 </tr> 276 </table> 277</div><div class="memdoc"> 278<p>Subtracts two numbers in BCD format: <b>sour</b> -= <b>value</b> </p><dl class="params"><dt>Parameters</dt><dd> 279 <table class="params"> 280 <tr><td class="paramname">sour</td><td>Pointer to a BCD value to subtract from (and where the result is stored) </td></tr> 281 <tr><td class="paramname">value</td><td>Pointer to the BCD value to subtract from <b>sour</b> </td></tr> 282 </table> 283 </dd> 284</dl> 285 286</div> 287</div> 288<a id="aec09ce7373727160488408c65fc8a91e"></a> 289<h2 class="memtitle"><span class="permalink"><a href="#aec09ce7373727160488408c65fc8a91e">◆ </a></span>bcd2text()</h2> 290 291<div class="memitem"> 292<div class="memproto"> 293 <table class="memname"> 294 <tr> 295 <td class="memname"><a class="el" href="stdint_8h.html#aba7bc1797add20fe3efdf37ced1182c5">uint8_t</a> bcd2text </td> 296 <td>(</td> 297 <td class="paramtype">const <a class="el" href="bcd_8h.html#a4813acd7f1852dd32b67175ca6aca2eb">BCD</a> * </td> 298 <td class="paramname"><em>bcd</em>, </td> 299 </tr> 300 <tr> 301 <td class="paramkey"></td> 302 <td></td> 303 <td class="paramtype"><a class="el" href="stdint_8h.html#aba7bc1797add20fe3efdf37ced1182c5">uint8_t</a> </td> 304 <td class="paramname"><em>tile_offset</em>, </td> 305 </tr> 306 <tr> 307 <td class="paramkey"></td> 308 <td></td> 309 <td class="paramtype"><a class="el" href="stdint_8h.html#aba7bc1797add20fe3efdf37ced1182c5">uint8_t</a> * </td> 310 <td class="paramname"><em>buffer</em> </td> 311 </tr> 312 <tr> 313 <td></td> 314 <td>)</td> 315 <td></td><td></td> 316 </tr> 317 </table> 318</div><div class="memdoc"> 319<p>Convert a BCD number into an asciiz (null terminated) string and return the length </p><dl class="params"><dt>Parameters</dt><dd> 320 <table class="params"> 321 <tr><td class="paramname">bcd</td><td>Pointer to BCD value to convert </td></tr> 322 <tr><td class="paramname">tile_offset</td><td>Optional per-character offset value to add (use 0 for none) </td></tr> 323 <tr><td class="paramname">buffer</td><td>Buffer to store the result in</td></tr> 324 </table> 325 </dd> 326</dl> 327<p>Returns: Length in characters (always 8)</p> 328<p><b>buffer</b> should be large enough to store the converted string (9 bytes: 8 characters + 1 for terminator)</p> 329<p>There are a couple different ways to use <b>tile_offset</b>. For example: </p><ul> 330<li>It can be the Index of the Font Tile '0' in VRAM to allow the buffer to be used directly with <a class="el" href="gb_8h.html#a6da9e2fa1bafd35363e84ee999909ec7">set_bkg_tiles</a>. </li> 331<li>It can also be set to the ascii value for character '0' so that the buffer is a normal string that can be passed to <a class="el" href="stdio_8h.html#ab403fa700816f08631ba75bc536f74d4">printf</a>. </li> 332</ul> 333 334</div> 335</div> 336</div><!-- contents --> 337</div><!-- doc-content --> 338<!-- HTML footer for doxygen 1.8.14--> 339<!-- start footer part --> 340<div id="nav-path" class="navpath"><!-- id is needed for treeview function! --> 341</div> 342</body> 343</html>