libctru/graphics_2printing_2hello-world_2source_2main_8c-example.html
2024-11-03 20:36:34 +00:00

135 lines
11 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<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.9.1"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>libctru: graphics/printing/hello-world/source/main.c</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="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" />
</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">libctru
&#160;<span id="projectnumber">v2.4.1</span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.1 -->
<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','.html');
/* @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 -->
<!-- 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="headertitle">
<div class="title">graphics/printing/hello-world/source/main.c</div> </div>
</div><!--header-->
<div class="contents">
<div class="fragment"><div class="line"><span class="comment">/*</span></div>
<div class="line"><span class="comment"> Hello World example made by Aurelio Mannara for libctru</span></div>
<div class="line"><span class="comment"> This code was modified for the last time on: 12/12/2014 21:00 UTC+1</span></div>
<div class="line"><span class="comment">*/</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="3ds_8h.html">3ds.h</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;stdio.h&gt;</span></div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> **argv)</div>
<div class="line">{</div>
<div class="line"> <a name="a0"></a><a class="code" href="gfx_8h.html#a236a005ae029247c8bfe4a4a649206fc">gfxInitDefault</a>();</div>
<div class="line"> </div>
<div class="line"> <span class="comment">//Initialize console on top screen. Using NULL as the second argument tells the console library to use the internal console structure as current one</span></div>
<div class="line"> <a name="a1"></a><a class="code" href="console_8h.html#a8e014e84f81ff901ca62d7669a8c8de8">consoleInit</a>(<a name="a2"></a><a class="code" href="gfx_8h.html#a356112d87f5cf6bbba3ea3b6b010e09caf9d44178134d07cf9c5923200e14af09">GFX_TOP</a>, NULL);</div>
<div class="line"> </div>
<div class="line"> <span class="comment">//Move the cursor to row 15 and column 19 and then prints &quot;Hello World!&quot;</span></div>
<div class="line"> <span class="comment">//To move the cursor you have to print &quot;\x1b[r;cH&quot;, where r and c are respectively</span></div>
<div class="line"> <span class="comment">//the row and column where you want your cursor to move</span></div>
<div class="line"> <span class="comment">//The top screen has 30 rows and 50 columns</span></div>
<div class="line"> <span class="comment">//The bottom screen has 30 rows and 40 columns</span></div>
<div class="line"> printf(<span class="stringliteral">&quot;\x1b[16;20HHello World!&quot;</span>);</div>
<div class="line"> </div>
<div class="line"> printf(<span class="stringliteral">&quot;\x1b[30;16HPress Start to exit.&quot;</span>);</div>
<div class="line"> </div>
<div class="line"> <span class="comment">// Main loop</span></div>
<div class="line"> <span class="keywordflow">while</span> (<a name="a3"></a><a class="code" href="apt_8h.html#a84808c36d9a8c389896ecf241c7f89cb">aptMainLoop</a>())</div>
<div class="line"> {</div>
<div class="line"> <span class="comment">//Scan all the inputs. This should be done once for each frame</span></div>
<div class="line"> <a name="a4"></a><a class="code" href="hid_8h.html#abbbf0e1f3a79a75e459e19f85a66bee6">hidScanInput</a>();</div>
<div class="line"> </div>
<div class="line"> <span class="comment">//hidKeysDown returns information about which buttons have been just pressed (and they weren&#39;t in the previous frame)</span></div>
<div class="line"> <a class="code" href="types_8h.html#afaa62991928fb9fb18ff0db62a040aba">u32</a> kDown = <a name="a5"></a><a class="code" href="hid_8h.html#aa2cababf764bf0b4297dc2e2fffe2a76">hidKeysDown</a>();</div>
<div class="line"> </div>
<div class="line"> <span class="keywordflow">if</span> (kDown &amp; <a name="a6"></a><a class="code" href="hid_8h.html#a531c35e38ede3ea4e5ba5afb24b29493a616a1f5c4ed36080ca954453084aea3b">KEY_START</a>) <span class="keywordflow">break</span>; <span class="comment">// break in order to return to hbmenu</span></div>
<div class="line"> </div>
<div class="line"> <span class="comment">// Flush and swap framebuffers</span></div>
<div class="line"> <a name="a7"></a><a class="code" href="gfx_8h.html#aea1808bd74fe0c00f9794e455fc8499b">gfxFlushBuffers</a>();</div>
<div class="line"> <a name="a8"></a><a class="code" href="gfx_8h.html#a0f338920111994110975dc0d1360bb1f">gfxSwapBuffers</a>();</div>
<div class="line"> </div>
<div class="line"> <span class="comment">//Wait for VBlank</span></div>
<div class="line"> <a name="a9"></a><a class="code" href="gspgpu_8h.html#abf0a992835649b5fe90e95d8a58b8c45">gspWaitForVBlank</a>();</div>
<div class="line"> }</div>
<div class="line"> </div>
<div class="line"> <a name="a10"></a><a class="code" href="gfx_8h.html#aa446ccfdfdd4c575e648956ae96f2a3b">gfxExit</a>();</div>
<div class="line"> <span class="keywordflow">return</span> 0;</div>
<div class="line">}</div>
<div class="ttc" id="a3ds_8h_html"><div class="ttname"><a href="3ds_8h.html">3ds.h</a></div><div class="ttdoc">Central 3DS header.</div></div>
<div class="ttc" id="aapt_8h_html_a84808c36d9a8c389896ecf241c7f89cb"><div class="ttname"><a href="apt_8h.html#a84808c36d9a8c389896ecf241c7f89cb">aptMainLoop</a></div><div class="ttdeci">bool aptMainLoop(void)</div><div class="ttdoc">Main function which handles sleep mode and HOME/power buttons - call this at the beginning of every f...</div></div>
<div class="ttc" id="aconsole_8h_html_a8e014e84f81ff901ca62d7669a8c8de8"><div class="ttname"><a href="console_8h.html#a8e014e84f81ff901ca62d7669a8c8de8">consoleInit</a></div><div class="ttdeci">PrintConsole * consoleInit(gfxScreen_t screen, PrintConsole *console)</div><div class="ttdoc">Initialise the console.</div></div>
<div class="ttc" id="agfx_8h_html_a0f338920111994110975dc0d1360bb1f"><div class="ttname"><a href="gfx_8h.html#a0f338920111994110975dc0d1360bb1f">gfxSwapBuffers</a></div><div class="ttdeci">void gfxSwapBuffers(void)</div><div class="ttdoc">Updates the configuration of both screens.</div></div>
<div class="ttc" id="agfx_8h_html_a236a005ae029247c8bfe4a4a649206fc"><div class="ttname"><a href="gfx_8h.html#a236a005ae029247c8bfe4a4a649206fc">gfxInitDefault</a></div><div class="ttdeci">void gfxInitDefault(void)</div><div class="ttdoc">Initializes the LCD framebuffers with default parameters This is equivalent to calling:</div></div>
<div class="ttc" id="agfx_8h_html_a356112d87f5cf6bbba3ea3b6b010e09caf9d44178134d07cf9c5923200e14af09"><div class="ttname"><a href="gfx_8h.html#a356112d87f5cf6bbba3ea3b6b010e09caf9d44178134d07cf9c5923200e14af09">GFX_TOP</a></div><div class="ttdeci">@ GFX_TOP</div><div class="ttdoc">Top screen.</div><div class="ttdef"><b>Definition:</b> gfx.h:26</div></div>
<div class="ttc" id="agfx_8h_html_aa446ccfdfdd4c575e648956ae96f2a3b"><div class="ttname"><a href="gfx_8h.html#aa446ccfdfdd4c575e648956ae96f2a3b">gfxExit</a></div><div class="ttdeci">void gfxExit(void)</div><div class="ttdoc">Deinitializes and frees the LCD framebuffers.</div></div>
<div class="ttc" id="agfx_8h_html_aea1808bd74fe0c00f9794e455fc8499b"><div class="ttname"><a href="gfx_8h.html#aea1808bd74fe0c00f9794e455fc8499b">gfxFlushBuffers</a></div><div class="ttdeci">void gfxFlushBuffers(void)</div><div class="ttdoc">Flushes the data cache for the current framebuffers.</div></div>
<div class="ttc" id="agspgpu_8h_html_abf0a992835649b5fe90e95d8a58b8c45"><div class="ttname"><a href="gspgpu_8h.html#abf0a992835649b5fe90e95d8a58b8c45">gspWaitForVBlank</a></div><div class="ttdeci">#define gspWaitForVBlank()</div><div class="ttdoc">Waits for VBlank.</div><div class="ttdef"><b>Definition:</b> gspgpu.h:151</div></div>
<div class="ttc" id="ahid_8h_html_a531c35e38ede3ea4e5ba5afb24b29493a616a1f5c4ed36080ca954453084aea3b"><div class="ttname"><a href="hid_8h.html#a531c35e38ede3ea4e5ba5afb24b29493a616a1f5c4ed36080ca954453084aea3b">KEY_START</a></div><div class="ttdeci">@ KEY_START</div><div class="ttdoc">Start.</div><div class="ttdef"><b>Definition:</b> hid.h:15</div></div>
<div class="ttc" id="ahid_8h_html_aa2cababf764bf0b4297dc2e2fffe2a76"><div class="ttname"><a href="hid_8h.html#aa2cababf764bf0b4297dc2e2fffe2a76">hidKeysDown</a></div><div class="ttdeci">u32 hidKeysDown(void)</div><div class="ttdoc">Returns a bitmask of newly pressed buttons, this frame.</div></div>
<div class="ttc" id="ahid_8h_html_abbbf0e1f3a79a75e459e19f85a66bee6"><div class="ttname"><a href="hid_8h.html#abbbf0e1f3a79a75e459e19f85a66bee6">hidScanInput</a></div><div class="ttdeci">void hidScanInput(void)</div><div class="ttdoc">Scans HID for input data.</div></div>
<div class="ttc" id="atypes_8h_html_afaa62991928fb9fb18ff0db62a040aba"><div class="ttname"><a href="types_8h.html#afaa62991928fb9fb18ff0db62a040aba">u32</a></div><div class="ttdeci">uint32_t u32</div><div class="ttdoc">32-bit unsigned integer</div><div class="ttdef"><b>Definition:</b> types.h:23</div></div>
</div><!-- fragment --> </div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.1
</small></address>
</body>
</html>