3:I[9275,[],""] 5:I[1343,[],""] 6:I[6943,["231","static/chunks/231-0ebe1b01337998d1.js","185","static/chunks/app/layout-bc0ec78271664fe5.js"],"default"] 7:I[231,["231","static/chunks/231-0ebe1b01337998d1.js","736","static/chunks/app/share/page-f8542e6651ed049d.js"],""] 4:["postSlug","libnds-documentation","c"] 0:["0igaI1P4Q1fyJmP7Zwu8D",[[["",{"children":["share",{"children":[["postSlug","libnds-documentation","c"],{"children":["__PAGE__?{\"postSlug\":[\"libnds-documentation\"]}",{}]}]}]},"$undefined","$undefined",true],["",{"children":["share",{"children":[["postSlug","libnds-documentation","c"],{"children":["__PAGE__",{},[["$L1","$L2"],null],null]},["$","$L3",null,{"parallelRouterKey":"children","segmentPath":["children","share","children","$4","children"],"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L5",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":"$undefined","notFoundStyles":"$undefined","styles":null}],null]},["$","$L3",null,{"parallelRouterKey":"children","segmentPath":["children","share","children"],"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L5",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":"$undefined","notFoundStyles":"$undefined","styles":null}],null]},[["$","$L6",null,{"children":["$","$L3",null,{"parallelRouterKey":"children","segmentPath":["children"],"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L5",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":["$","div",null,{"className":"error-page","children":[["$","h1",null,{"children":"Page Not Found"}],["$","p",null,{"children":"Sorry, the page you are looking for does not exist."}],["$","span",null,{"className":"error-number","children":"404"}],["$","div",null,{"className":"error-buttons","children":[["$","$L7",null,{"className":"button","href":"/","children":"Back Home"}],["$","$L7",null,{"className":"button","target":"_blank","rel":"noopener noreferrer","href":"https://github.com/SidonieBouthors/sidonie.me-v2/issues/new?assignees=SidonieBouthors&labels=broken-link&projects=&template=broken-link.md&title=%5BBroken+Link%5D+","children":"Report Issue"}]]}]]}],"notFoundStyles":[],"styles":null}]}],null],null],[[["$","link","0",{"rel":"stylesheet","href":"/_next/static/css/4e6e0a6e706bbb14.css","precedence":"next","crossOrigin":"$undefined"}]],"$L8"]]]] 2:["$","div",null,{"className":"post-page","children":[["$","nav",null,{"className":"breadcrumb","children":["$","ol",null,{"children":[["$","li","/share",{"children":["$","$L7",null,{"href":"/share","children":"Share"}]}],["$","li",null,{"children":"LibNDS Quick Docs"}]]}]}],["$","p",null,{"className":"updated","children":["Last updated on"," ",["$","time",null,{"dateTime":"2024-01-12","children":"Friday, January 12, 2024"}]]}],[["$","input",null,{"type":"checkbox","id":"toc-toggle"}],["$","label",null,{"htmlFor":"toc-toggle","className":"toc-label","children":["$","span",null,{"children":"Table of Contents"}]}]],[["$","nav",null,{"className":"toc","children":["$","ol",null,{"className":"toc-level toc-level-1","children":[["$","li",null,{"className":"toc-item toc-item-h2","children":[["$","a",null,{"className":"toc-link toc-link-h2","href":"#io--peripheral-devices","children":"I/O & Peripheral Devices"}],["$","ol",null,{"className":"toc-level toc-level-2","children":[["$","li",null,{"className":"toc-item toc-item-h3","children":["$","a",null,{"className":"toc-link toc-link-h3","href":"#interrupts","children":"Interrupts"}]}],["$","li",null,{"className":"toc-item toc-item-h3","children":["$","a",null,{"className":"toc-link toc-link-h3","href":"#timers","children":"Timers"}]}]]}]]}],["$","li",null,{"className":"toc-item toc-item-h2","children":[["$","a",null,{"className":"toc-link toc-link-h2","href":"#graphics","children":"Graphics"}],["$","ol",null,{"className":"toc-level toc-level-2","children":[["$","li",null,{"className":"toc-item toc-item-h3","children":[["$","a",null,{"className":"toc-link toc-link-h3","href":"#configurations","children":"Configurations"}],["$","ol",null,{"className":"toc-level toc-level-3","children":[["$","li",null,{"className":"toc-item toc-item-h4","children":["$","a",null,{"className":"toc-link toc-link-h4","href":"#power-manager","children":"Power Manager"}]}],["$","li",null,{"className":"toc-item toc-item-h4","children":["$","a",null,{"className":"toc-link toc-link-h4","href":"#video-memory","children":"Video Memory"}]}],["$","li",null,{"className":"toc-item toc-item-h4","children":["$","a",null,{"className":"toc-link toc-link-h4","href":"#graphical-engine","children":"Graphical Engine"}]}],["$","li",null,{"className":"toc-item toc-item-h4","children":["$","a",null,{"className":"toc-link toc-link-h4","href":"#additional-configuration","children":"Additional Configuration"}]}]]}]]}],["$","li",null,{"className":"toc-item toc-item-h3","children":["$","a",null,{"className":"toc-link toc-link-h3","href":"#pixels--color","children":"Pixels & Color"}]}],["$","li",null,{"className":"toc-item toc-item-h3","children":["$","a",null,{"className":"toc-link toc-link-h3","href":"#palettes","children":"Palettes"}]}],["$","li",null,{"className":"toc-item toc-item-h3","children":["$","a",null,{"className":"toc-link toc-link-h3","href":"#screen--modes","children":"Screen & Modes"}]}],["$","li",null,{"className":"toc-item toc-item-h3","children":["$","a",null,{"className":"toc-link toc-link-h3","href":"#backgrounds","children":"Backgrounds"}]}],["$","li",null,{"className":"toc-item toc-item-h3","children":["$","a",null,{"className":"toc-link toc-link-h3","href":"#framebuffer-mode","children":"Framebuffer Mode"}]}],["$","li",null,{"className":"toc-item toc-item-h3","children":[["$","a",null,{"className":"toc-link toc-link-h3","href":"#rotoscale-mode","children":"Rotoscale Mode"}],["$","ol",null,{"className":"toc-level toc-level-3","children":["$","li",null,{"className":"toc-item toc-item-h4","children":["$","a",null,{"className":"toc-link toc-link-h4","href":"#transformation-matrix","children":"Transformation Matrix"}]}]}]]}],["$","li",null,{"className":"toc-item toc-item-h3","children":[["$","a",null,{"className":"toc-link toc-link-h3","href":"#tiled-mode","children":"Tiled Mode"}],["$","ol",null,{"className":"toc-level toc-level-3","children":[["$","li",null,{"className":"toc-item toc-item-h4","children":["$","a",null,{"className":"toc-link toc-link-h4","href":"#tiles","children":"Tiles"}]}],["$","li",null,{"className":"toc-item toc-item-h4","children":["$","a",null,{"className":"toc-link toc-link-h4","href":"#maps","children":"Maps"}]}]]}]]}],["$","li",null,{"className":"toc-item toc-item-h3","children":["$","a",null,{"className":"toc-link toc-link-h3","href":"#sprites","children":"Sprites"}]}],["$","li",null,{"className":"toc-item toc-item-h3","children":["$","a",null,{"className":"toc-link toc-link-h3","href":"#grit","children":"Grit"}]}],["$","li",null,{"className":"toc-item toc-item-h3","children":["$","a",null,{"className":"toc-link toc-link-h3","href":"#vram-management","children":"VRAM Management"}]}],["$","li",null,{"className":"toc-item toc-item-h3","children":["$","a",null,{"className":"toc-link toc-link-h3","href":"#data-transfer","children":"Data Transfer"}]}]]}]]}],["$","li",null,{"className":"toc-item toc-item-h2","children":["$","a",null,{"className":"toc-link toc-link-h2","href":"#controls","children":"Controls"}]}],["$","li",null,{"className":"toc-item toc-item-h2","children":["$","a",null,{"className":"toc-link toc-link-h2","href":"#sound","children":"Sound"}]}]]}]}],["$","h1",null,{"id":"libnds-quick-docs","children":["$","a",null,{"className":"subheading-anchor","aria-label":"Link to section","href":"#libnds-quick-docs","children":"LibNDS Quick Docs"}]}],"\n",["$","div",null,{"className":"callout note","children":["$","p",null,{"children":["This documentation is a simplified version adapted to the content of EPFL's\n",["$","a",null,{"href":"https://edu.epfl.ch/coursebook/en/microprogrammed-embedded-systems-EE-310","rel":"noopener noreferrer","target":"_blank","children":"EE-310\nCourse"}],".\nFor more details or advanced documentation, check out the official ",["$","a",null,{"href":"https://libnds.devkitpro.org/","rel":"noopener noreferrer","target":"_blank","children":"LibNDS\nDocumentation"}],"."]}]}],"\n",["$","h2",null,{"id":"io--peripheral-devices","children":["$","a",null,{"className":"subheading-anchor","aria-label":"Link to section","href":"#io--peripheral-devices","children":"I/O & Peripheral Devices"}]}],"\n",["$","p",null,{"children":["$","img",null,{"src":"/velite/nds-arm-periphs-8bb277.svg","alt":""}]}],"\n",["$","p",null,{"children":"Two 32-bit ARM cores manage the I/O and peripherals on the NDS, each connected to different peripherals. There are two basic mechanisms for I/O subystem syncronization : programmed I/O with active waiting response, and I/O interrupts."}],"\n",["$","h3",null,{"id":"interrupts","children":["$","a",null,{"className":"subheading-anchor","aria-label":"Link to section","href":"#interrupts","children":"Interrupts"}]}],"\n",["$","p",null,{"children":"Initialize interrupts subsystem"}],"\n",["$","figure",null,{"data-rehype-pretty-code-figure":"","children":["$","pre",null,{"style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"tabIndex":"0","data-language":"c","data-theme":"github-dark-dimmed github-light","children":["$","code",null,{"data-language":"c","data-theme":"github-dark-dimmed github-light","style":{"display":"grid"},"children":["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"void"}],["$","span",null,{"style":{"--shiki-dark":"#DCBDFB","--shiki-light":"#6F42C1"},"children":" irqInit"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"();"}]]}]}]}]}],"\n",["$","p",null,{"children":"This is the usual way to initialize peripherals (except when using sound)."}],"\n",["$","div",null,{"className":"callout warning","children":["$","p",null,{"children":"This disables VBLANK interrupts, that are activated by default."}]}],"\n",["$","p",null,{"children":"Specify the handler to use for the given interrupt"}],"\n",["$","figure",null,{"data-rehype-pretty-code-figure":"","children":["$","pre",null,{"style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"tabIndex":"0","data-language":"c","data-theme":"github-dark-dimmed github-light","children":["$","code",null,{"data-language":"c","data-theme":"github-dark-dimmed github-light","style":{"display":"grid"},"children":["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"void"}],["$","span",null,{"style":{"--shiki-dark":"#DCBDFB","--shiki-light":"#6F42C1"},"children":" irqSet"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"(IRQ_MASK "}],["$","span",null,{"style":{"--shiki-dark":"#F69D50","--shiki-light":"#E36209"},"children":"irq"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":", VoidFn "}],["$","span",null,{"style":{"--shiki-dark":"#F69D50","--shiki-light":"#E36209"},"children":"handler"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":")"}]]}]}]}]}],"\n",["$","p",null,{"children":"Remove the handler associated with the interrupt"}],"\n",["$","figure",null,{"data-rehype-pretty-code-figure":"","children":["$","pre",null,{"style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"tabIndex":"0","data-language":"c","data-theme":"github-dark-dimmed github-light","children":["$","code",null,{"data-language":"c","data-theme":"github-dark-dimmed github-light","style":{"display":"grid"},"children":["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"void"}],["$","span",null,{"style":{"--shiki-dark":"#DCBDFB","--shiki-light":"#6F42C1"},"children":" irqClear"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"(IRQ_MASK "}],["$","span",null,{"style":{"--shiki-dark":"#F69D50","--shiki-light":"#E36209"},"children":"irq"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":")"}]]}]}]}]}],"\n",["$","p",null,{"children":"Allow the given interrupt to occur"}],"\n",["$","figure",null,{"data-rehype-pretty-code-figure":"","children":["$","pre",null,{"style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"tabIndex":"0","data-language":"c","data-theme":"github-dark-dimmed github-light","children":["$","code",null,{"data-language":"c","data-theme":"github-dark-dimmed github-light","style":{"display":"grid"},"children":["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"void"}],["$","span",null,{"style":{"--shiki-dark":"#DCBDFB","--shiki-light":"#6F42C1"},"children":" irqEnable"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"(uint32 "}],["$","span",null,{"style":{"--shiki-dark":"#F69D50","--shiki-light":"#E36209"},"children":"irq"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":")"}]]}]}]}]}],"\n",["$","p",null,{"children":"Prevent the given interrupt from occurring"}],"\n",["$","figure",null,{"data-rehype-pretty-code-figure":"","children":["$","pre",null,{"style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"tabIndex":"0","data-language":"c","data-theme":"github-dark-dimmed github-light","children":["$","code",null,{"data-language":"c","data-theme":"github-dark-dimmed github-light","style":{"display":"grid"},"children":["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"void"}],["$","span",null,{"style":{"--shiki-dark":"#DCBDFB","--shiki-light":"#6F42C1"},"children":" irqDisable"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"(uint32 "}],["$","span",null,{"style":{"--shiki-dark":"#F69D50","--shiki-light":"#E36209"},"children":"irq"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":")"}]]}]}]}]}],"\n",["$","h3",null,{"id":"timers","children":["$","a",null,{"className":"subheading-anchor","aria-label":"Link to section","href":"#timers","children":"Timers"}]}],"\n",["$","p",null,{"children":"Libnds provides several macros to deal with timers:"}],"\n",["$","p",null,{"children":["$","strong",null,{"children":"Timer CR"}]}],"\n",["$","p",null,{"children":"Return a de-referenced pointer to the timer control register x (0 to 3):"}],"\n",["$","figure",null,{"data-rehype-pretty-code-figure":"","children":["$","pre",null,{"style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"tabIndex":"0","data-language":"c","data-theme":"github-dark-dimmed github-light","children":["$","code",null,{"data-language":"c","data-theme":"github-dark-dimmed github-light","style":{"display":"grid"},"children":["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#DCBDFB","--shiki-light":"#6F42C1"},"children":"TIMER_CR"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"(x)"}],["$","span",null,{"style":{"--shiki-dark":"#768390","--shiki-light":"#6A737D"},"children":" // or TIMERx_CR"}]]}]}]}]}],"\n",["$","p",null,{"children":"Enable the timer:"}],"\n",["$","figure",null,{"data-rehype-pretty-code-figure":"","children":["$","pre",null,{"style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"tabIndex":"0","data-language":"c","data-theme":"github-dark-dimmed github-light","children":["$","code",null,{"data-language":"c","data-theme":"github-dark-dimmed github-light","style":{"display":"grid"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"TIMER_ENABLE"}]}]}]}]}],"\n",["$","p",null,{"children":"Timer will count at (33.514 / VALUE) MHz, with VALUE = 1, 64, 256, or 1024:"}],"\n",["$","figure",null,{"data-rehype-pretty-code-figure":"","children":["$","pre",null,{"style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"tabIndex":"0","data-language":"c","data-theme":"github-dark-dimmed github-light","children":["$","code",null,{"data-language":"c","data-theme":"github-dark-dimmed github-light","style":{"display":"grid"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"TIMER_DIV_VALUE"}]}]}]}]}],"\n",["$","p",null,{"children":"Request interrupt on overflow:"}],"\n",["$","figure",null,{"data-rehype-pretty-code-figure":"","children":["$","pre",null,{"style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"tabIndex":"0","data-language":"c","data-theme":"github-dark-dimmed github-light","children":["$","code",null,{"data-language":"c","data-theme":"github-dark-dimmed github-light","style":{"display":"grid"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"TIMER_IRQ_REQ"}]}]}]}]}],"\n",["$","p",null,{"children":["$","strong",null,{"children":"Timer Data"}]}],"\n",["$","p",null,{"children":"Return a de-referenced pointer to the data register for timer x (0 to 3):"}],"\n",["$","figure",null,{"data-rehype-pretty-code-figure":"","children":["$","pre",null,{"style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"tabIndex":"0","data-language":"c","data-theme":"github-dark-dimmed github-light","children":["$","code",null,{"data-language":"c","data-theme":"github-dark-dimmed github-light","style":{"display":"grid"},"children":["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#DCBDFB","--shiki-light":"#6F42C1"},"children":"TIMER_DATA"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"(x)"}],["$","span",null,{"style":{"--shiki-dark":"#768390","--shiki-light":"#6A737D"},"children":" // or TIMERx_DATA"}]]}]}]}]}],"\n",["$","p",null,{"children":"Set up the register value to start and overflow each 1/freq second, with VALUE = 64, 256, or 1024 (if no VALUE specified, 1):"}],"\n",["$","figure",null,{"data-rehype-pretty-code-figure":"","children":["$","pre",null,{"style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"tabIndex":"0","data-language":"c","data-theme":"github-dark-dimmed github-light","children":["$","code",null,{"data-language":"c","data-theme":"github-dark-dimmed github-light","style":{"display":"grid"},"children":["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#F69D50","--shiki-light":"#E36209"},"children":"TIMER_FREQ"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"[_VALUE](freq)"}]]}]}]}]}],"\n",["$","p",null,{"children":"To choose the divider to use depending on the actual timer frequency we want, we ideally use the smallest possible value in the table below that satisfies our constraints."}],"\n",["$","table",null,{"children":[["$","thead",null,{"children":["$","tr",null,{"children":[["$","th",null,{"children":"Divider"}],["$","th",null,{"children":"Max Time/Cycle"}],["$","th",null,{"children":"Min Freq"}]]}]}],["$","tbody",null,{"children":[["$","tr",null,{"children":[["$","td",null,{"children":"1"}],["$","td",null,{"children":"1.955 ms (most precise)"}],["$","td",null,{"children":"510 Hz"}]]}],["$","tr",null,{"children":[["$","td",null,{"children":"64"}],["$","td",null,{"children":"125.151 ms"}],["$","td",null,{"children":"8 Hz"}]]}],["$","tr",null,{"children":[["$","td",null,{"children":"256"}],["$","td",null,{"children":"500.603 ms"}],["$","td",null,{"children":"2 Hz"}]]}],["$","tr",null,{"children":[["$","td",null,{"children":"1024"}],["$","td",null,{"children":"2.002 s (least precise)"}],["$","td",null,{"children":"0.5 Hz"}]]}]]}]]}],"\n",["$","div",null,{"className":"callout example","children":[["$","figure",null,{"data-rehype-pretty-code-figure":"","children":["$","pre",null,{"style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"tabIndex":"0","data-language":"c","data-theme":"github-dark-dimmed github-light","children":["$","code",null,{"data-language":"c","data-theme":"github-dark-dimmed github-light","style":{"display":"grid"},"children":[["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"int"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":" frequency "}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"="}],["$","span",null,{"style":{"--shiki-dark":"#6CB6FF","--shiki-light":"#005CC5"},"children":" 20"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":";"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"TIMER0_CR "}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"="}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":" TIMER_DIV_64 "}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"|"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":" TIMER_ENABLE "}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"|"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":" TIMER_IRQ_REQ;"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"TIMER0_DATA "}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"="}],["$","span",null,{"style":{"--shiki-dark":"#DCBDFB","--shiki-light":"#6F42C1"},"children":" TIMER_FREQ_64"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"(frequency);"}]]}]]}]}]}],["$","p",null,{"children":"To use interrupts:"}],["$","figure",null,{"data-rehype-pretty-code-figure":"","children":["$","pre",null,{"style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"tabIndex":"0","data-language":"c","data-theme":"github-dark-dimmed github-light","children":["$","code",null,{"data-language":"c","data-theme":"github-dark-dimmed github-light","style":{"display":"grid"},"children":[["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#DCBDFB","--shiki-light":"#6F42C1"},"children":"irqSet"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"(IRQ_TIMER0, timer_isr);"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#DCBDFB","--shiki-light":"#6F42C1"},"children":"irqEnable"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"(IRQ_TIMER0);"}]]}]]}]}]}]]}],"\n",["$","h2",null,{"id":"graphics","children":["$","a",null,{"className":"subheading-anchor","aria-label":"Link to section","href":"#graphics","children":"Graphics"}]}],"\n",["$","p",null,{"children":["$","img",null,{"src":"/velite/nds-graphics-map-5ce077.svg","alt":"NDS Graphics Map"}]}],"\n",["$","h3",null,{"id":"configurations","children":["$","a",null,{"className":"subheading-anchor","aria-label":"Link to section","href":"#configurations","children":"Configurations"}]}],"\n",["$","h4",null,{"id":"power-manager","children":["$","a",null,{"className":"subheading-anchor","aria-label":"Link to section","href":"#power-manager","children":"Power Manager"}]}],"\n",["$","p",null,{"children":["Control register for powering up I/O NDS devices: ",["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"REG_POWERCNT"}]}]}]}]]}],"\n",["$","p",null,{"children":["$","img",null,{"src":"/velite/nds-reg_powercnt-ac3e74.svg","alt":"Reg Powercnt"}]}],"\n",["$","p",null,{"children":["LCD and engines ",["$","strong",null,{"children":"activated by default"}]," during the boot-up process. This means we usually won't need to manually set configurations for the power manager."]}],"\n",["$","p",null,{"children":"It is possible to enable / disable them manually to save power at run-time."}],"\n",["$","div",null,{"className":"callout example","children":[["$","p",null,{"children":"Activation :"}],["$","figure",null,{"data-rehype-pretty-code-figure":"","children":["$","pre",null,{"style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"tabIndex":"0","data-language":"c","data-theme":"github-dark-dimmed github-light","children":["$","code",null,{"data-language":"c","data-theme":"github-dark-dimmed github-light","style":{"display":"grid"},"children":["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"REG_POWERCNT "}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"="}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":" POWER_LCD "}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"|"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":" POWER_2D_A;"}]]}]}]}]}],["$","p",null,{"children":"Deactivation :"}],["$","figure",null,{"data-rehype-pretty-code-figure":"","children":["$","pre",null,{"style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"tabIndex":"0","data-language":"c","data-theme":"github-dark-dimmed github-light","children":["$","code",null,{"data-language":"c","data-theme":"github-dark-dimmed github-light","style":{"display":"grid"},"children":["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"REG_POWERCNT "}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"&="}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":" ~"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"(POWER_LCD) "}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"&"}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":" ~"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"(POWER_2D_A);"}]]}]}]}]}]]}],"\n",["$","h4",null,{"id":"video-memory","children":["$","a",null,{"className":"subheading-anchor","aria-label":"Link to section","href":"#video-memory","children":"Video Memory"}]}],"\n",["$","p",null,{"children":["Control register for each bank to select and activate: ",["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"VRAM_?_CR"}]}]}]}]]}],"\n",["$","p",null,{"children":["$","img",null,{"src":"/velite/nds-vram_x_cr-014a4f.svg","alt":"VRAM CR"}]}],"\n",["$","p",null,{"children":"The VRAM is divided into 9 banks of different sizes:"}],"\n",["$","table",null,{"children":[["$","thead",null,{"children":["$","tr",null,{"children":[["$","th",null,{}],["$","th",null,{}]]}]}],["$","tbody",null,{"children":[["$","tr",null,{"children":[["$","td",null,{"children":["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"VRAM_A"}]}]}]}]}],["$","td",null,{"children":"128KiB"}]]}],["$","tr",null,{"children":[["$","td",null,{"children":["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"VRAM_B"}]}]}]}]}],["$","td",null,{"children":"128KiB"}]]}],["$","tr",null,{"children":[["$","td",null,{"children":["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"VRAM_C"}]}]}]}]}],["$","td",null,{"children":"128KiB"}]]}],["$","tr",null,{"children":[["$","td",null,{"children":["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"VRAM_D"}]}]}]}]}],["$","td",null,{"children":"128KiB"}]]}],["$","tr",null,{"children":[["$","td",null,{"children":["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"VRAM_E"}]}]}]}]}],["$","td",null,{"children":"64KiB"}]]}],["$","tr",null,{"children":[["$","td",null,{"children":["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"VRAM_F"}]}]}]}]}],["$","td",null,{"children":"16KiB"}]]}],["$","tr",null,{"children":[["$","td",null,{"children":["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"VRAM_G"}]}]}]}]}],["$","td",null,{"children":"16KiB"}]]}],["$","tr",null,{"children":[["$","td",null,{"children":["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"VRAM_H"}]}]}]}]}],["$","td",null,{"children":"32KiB"}]]}],["$","tr",null,{"children":[["$","td",null,{"children":["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"VRAM_I"}]}]}]}]}],["$","td",null,{"children":"16KiB"}]]}]]}]]}],"\n",["$","p",null,{"children":["See ",["$","a",null,{"href":"#vram-management","children":"VRAM Management"}]," for more information on how to organise storage in memory of different data."]}],"\n",["$","p",null,{"children":"Activate bank A and map it to the framebuffer:"}],"\n",["$","figure",null,{"data-rehype-pretty-code-figure":"","children":["$","pre",null,{"style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"tabIndex":"0","data-language":"c","data-theme":"github-dark-dimmed github-light","children":["$","code",null,{"data-language":"c","data-theme":"github-dark-dimmed github-light","style":{"display":"grid"},"children":["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"VRAM_A_CR "}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"="}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":" VRAM_ENABLE "}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"|"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":" VRAM_A_LCD;"}]]}]}]}]}],"\n",["$","p",null,{"children":"Activate bank A and map it to the main background:"}],"\n",["$","figure",null,{"data-rehype-pretty-code-figure":"","children":["$","pre",null,{"style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"tabIndex":"0","data-language":"c","data-theme":"github-dark-dimmed github-light","children":["$","code",null,{"data-language":"c","data-theme":"github-dark-dimmed github-light","style":{"display":"grid"},"children":["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"VRAM_A_CR "}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"="}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":" VRAM_ENABLE "}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"|"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":" VRAM_A_MAIN_BG;"}]]}]}]}]}],"\n",["$","p",null,{"children":"We can also use predefined functions:"}],"\n",["$","figure",null,{"data-rehype-pretty-code-figure":"","children":["$","pre",null,{"style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"tabIndex":"0","data-language":"c","data-theme":"github-dark-dimmed github-light","children":["$","code",null,{"data-language":"c","data-theme":"github-dark-dimmed github-light","style":{"display":"grid"},"children":["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#DCBDFB","--shiki-light":"#6F42C1"},"children":"vramSetBankA"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"(VRAM_A_LCD);"}]]}]}]}]}],"\n",["$","h4",null,{"id":"graphical-engine","children":["$","a",null,{"className":"subheading-anchor","aria-label":"Link to section","href":"#graphical-engine","children":"Graphical Engine"}]}],"\n",["$","p",null,{"children":["Display register to control the mode and active backgrounds: ",["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"REG_DISPCNT"}]}]}]}]]}],"\n",["$","p",null,{"children":["$","img",null,{"src":"/velite/nds-reg_dispcnt-dbcd9c.svg","alt":"REG DISPCNT"}]}],"\n",["$","p",null,{"children":["Choosing the configurations for the graphical engine is done according to the existing ",["$","a",null,{"href":"#screen--modes","children":"screen modes"}]," for each engine."]}],"\n",["$","p",null,{"children":["Use ",["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"REG_DISPCNT"}]}]}]}]," to choose configurations for the main graphical engine (the top screen of the NDS) and ",["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"REG_DISPCNT_SUB"}]}]}]}]," to choose the configurations for the secondary graphical engine (the bottom screen of the NDS)."]}],"\n",["$","div",null,{"className":"callout example","children":[["$","p",null,{"children":"Activate mode 0 and background 1 :"}],["$","figure",null,{"data-rehype-pretty-code-figure":"","children":["$","pre",null,{"style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"tabIndex":"0","data-language":"c","data-theme":"github-dark-dimmed github-light","children":["$","code",null,{"data-language":"c","data-theme":"github-dark-dimmed github-light","style":{"display":"grid"},"children":["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"REG_DISPCNT "}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"="}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":" MODE_0_2D "}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"|"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":" DISPLAY_BG1_ACTIVE;"}]]}]}]}]}]]}],"\n",["$","h4",null,{"id":"additional-configuration","children":["$","a",null,{"className":"subheading-anchor","aria-label":"Link to section","href":"#additional-configuration","children":"Additional Configuration"}]}],"\n",["$","p",null,{"children":["In ",["$","strong",null,{"children":"Rotoscale"}]," and ",["$","strong",null,{"children":"Tiled"}]," mode, some additional configurations are required. We will need to configure each active background, initialize palettes if we are using 8 bits mode, and optionally adjust the affine transformation matrix for each background."]}],"\n",["$","p",null,{"children":"Check out the corresponding sections for more information on these configurations."}],"\n",["$","h3",null,{"id":"pixels--color","children":["$","a",null,{"className":"subheading-anchor","aria-label":"Link to section","href":"#pixels--color","children":"Pixels & Color"}]}],"\n",["$","p",null,{"children":"Each pixel has an RGB (Red-Green-Blue) representation of 16 bits"}],"\n",["$","ul",null,{"children":["\n",["$","li",null,{"children":"5 bits for the intensity of each colour (0: none, 31: maximum value)"}],"\n",["$","li",null,{"children":"1 bit for transparency (0: pixel is transparent, 1: pixel is opaque)"}],"\n"]}],"\n",["$","p",null,{"children":"Some reference colours :"}],"\n",["$","table",null,{"children":[["$","thead",null,{"children":["$","tr",null,{"children":[["$","th",null,{}],["$","th",null,{}]]}]}],["$","tbody",null,{"children":[["$","tr",null,{"children":[["$","td",null,{"children":"Red"}],["$","td",null,{"children":["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"RGB15(31,0,0)"}]}]}]}]}]]}],["$","tr",null,{"children":[["$","td",null,{"children":"Green"}],["$","td",null,{"children":["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"RGB15(0,31,0)"}]}]}]}]}]]}],["$","tr",null,{"children":[["$","td",null,{"children":"Blue"}],["$","td",null,{"children":["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"RGB15(0,0,31)"}]}]}]}]}]]}],["$","tr",null,{"children":[["$","td",null,{"children":"Yellow"}],["$","td",null,{"children":["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"RGB15(31,31,0)"}]}]}]}]}]]}],["$","tr",null,{"children":[["$","td",null,{"children":"Black"}],["$","td",null,{"children":["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"RGB15(0,0,0)"}]}]}]}]}]]}],["$","tr",null,{"children":[["$","td",null,{"children":"White"}],["$","td",null,{"children":["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"RGB15(31,31,31)"}]}]}]}]}]]}]]}]]}],"\n",["$","div",null,{"className":"callout example","children":[["$","p",null,{"children":"With transparency bit :"}],["$","figure",null,{"data-rehype-pretty-code-figure":"","children":["$","pre",null,{"style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"tabIndex":"0","data-language":"c","data-theme":"github-dark-dimmed github-light","children":["$","code",null,{"data-language":"c","data-theme":"github-dark-dimmed github-light","style":{"display":"grid"},"children":["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"static"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":" uint16 shape_color "}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"="}],["$","span",null,{"style":{"--shiki-dark":"#DCBDFB","--shiki-light":"#6F42C1"},"children":" ARGB16"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"("}],["$","span",null,{"style":{"--shiki-dark":"#6CB6FF","--shiki-light":"#005CC5"},"children":"1"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":", "}],["$","span",null,{"style":{"--shiki-dark":"#6CB6FF","--shiki-light":"#005CC5"},"children":"31"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":", "}],["$","span",null,{"style":{"--shiki-dark":"#6CB6FF","--shiki-light":"#005CC5"},"children":"0"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":", "}],["$","span",null,{"style":{"--shiki-dark":"#6CB6FF","--shiki-light":"#005CC5"},"children":"0"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":");"}]]}]}]}]}],["$","p",null,{"children":"Without Transparency bit :"}],["$","figure",null,{"data-rehype-pretty-code-figure":"","children":["$","pre",null,{"style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"tabIndex":"0","data-language":"c","data-theme":"github-dark-dimmed github-light","children":["$","code",null,{"data-language":"c","data-theme":"github-dark-dimmed github-light","style":{"display":"grid"},"children":["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"static"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":" uint16 shape_color "}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"="}],["$","span",null,{"style":{"--shiki-dark":"#DCBDFB","--shiki-light":"#6F42C1"},"children":" RGB15"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"("}],["$","span",null,{"style":{"--shiki-dark":"#6CB6FF","--shiki-light":"#005CC5"},"children":"31"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":", "}],["$","span",null,{"style":{"--shiki-dark":"#6CB6FF","--shiki-light":"#005CC5"},"children":"0"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":", "}],["$","span",null,{"style":{"--shiki-dark":"#6CB6FF","--shiki-light":"#005CC5"},"children":"0"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":");"}]]}]}]}]}]]}],"\n",["$","h3",null,{"id":"palettes","children":["$","a",null,{"className":"subheading-anchor","aria-label":"Link to section","href":"#palettes","children":"Palettes"}]}],"\n",["$","p",null,{"children":"A palette is a color collection used to reduce index sizes needed to represent pixel colors. Instead of colors being 16 bits per pixel (ARGB16), we use only 8 bits per pixel. To do this, we predefine 256 colors (defined in ARGB16 and stored in a collection), and then use the index of these colors to set pixel colors. Since we have 256 available colors in our defined palette, this means each index is only 8 bits."}],"\n",["$","p",null,{"children":"Palettes are stored in the palette RAM, which stores either one 256 color palette, or 16 palettes of 16 colors each."}],"\n",["$","p",null,{"children":"With 256 colors the color indexes go from 0x00 to 0xFF. When using 16 palettes of 16 colors, the first digit (0x0 to 0xF) is the palette and the second (0x0 to 0xF) is the color."}],"\n",["$","p",null,{"children":"Index 0 of a palette represents transparency: a pixel set at this color will display opaque pixels behind it from other backgrounds if there are any. If there is no opaque pixel behind it, it will appear as the actual RGB color stored at index 0."}],"\n",["$","p",null,{"children":["$","img",null,{"src":"/velite/nds-palette-6f7e95.svg","alt":"NDS Palette"}]}],"\n",["$","div",null,{"className":"callout example","children":[["$","p",null,{"children":"Initializing a palette :"}],["$","figure",null,{"data-rehype-pretty-code-figure":"","children":["$","pre",null,{"style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"tabIndex":"0","data-language":"c","data-theme":"github-dark-dimmed github-light","children":["$","code",null,{"data-language":"c","data-theme":"github-dark-dimmed github-light","style":{"display":"grid"},"children":[["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"uint"}],["$","span",null,{"style":{"--shiki-dark":"#6CB6FF","--shiki-light":"#005CC5"},"children":" 16"}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"*"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":" myPalette "}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"="}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":" BG_PALETTE;"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"int"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":" i;"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"for"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":" (i"}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"="}],["$","span",null,{"style":{"--shiki-dark":"#6CB6FF","--shiki-light":"#005CC5"},"children":"0"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"; i "}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"<"}],["$","span",null,{"style":{"--shiki-dark":"#6CB6FF","--shiki-light":"#005CC5"},"children":" 32"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":" ; i"}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"++"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":") {"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#F69D50","--shiki-light":"#E36209"},"children":" myPalette"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"[i] "}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"="}],["$","span",null,{"style":{"--shiki-dark":"#DCBDFB","--shiki-light":"#6F42C1"},"children":" ARGB16"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"("}],["$","span",null,{"style":{"--shiki-dark":"#6CB6FF","--shiki-light":"#005CC5"},"children":"1"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":","}],["$","span",null,{"style":{"--shiki-dark":"#6CB6FF","--shiki-light":"#005CC5"},"children":"0"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":", "}],["$","span",null,{"style":{"--shiki-dark":"#6CB6FF","--shiki-light":"#005CC5"},"children":"0"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":", i);"}]]}],"\n",["$","span",null,{"data-line":"","children":["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"}"}]}]]}]}]}]]}],"\n",["$","h3",null,{"id":"screen--modes","children":["$","a",null,{"className":"subheading-anchor","aria-label":"Link to section","href":"#screen--modes","children":"Screen & Modes"}]}],"\n",["$","p",null,{"children":"Each of the screens have 49152 pixels: 192 rows of 256 points each. The screen draws pixels sequentially from left to right and up to down (the origin is always top left)."}],"\n",["$","p",null,{"children":"Two interrupts occure from the screen drawing :"}],"\n",["$","table",null,{"children":[["$","thead",null,{"children":["$","tr",null,{"children":[["$","th",null,{}],["$","th",null,{}]]}]}],["$","tbody",null,{"children":[["$","tr",null,{"children":[["$","td",null,{"children":["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"IRQ_HBLANK"}]}]}]}]}],["$","td",null,{"children":"Horizontal blank : after each line is drawn"}]]}],["$","tr",null,{"children":[["$","td",null,{"children":["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"IRQ_VBLANK"}]}]}]}]}],["$","td",null,{"children":"Vertical blank : after all of the lines are drawn"}]]}]]}]]}],"\n",["$","p",null,{"children":"The bitmap content to draw is changed after a vertical blank, before the start of the next redraw."}],"\n",["$","p",null,{"children":"Each engine has four backgrounds (or layers): BG0, BG1, BG2 and BG3. Final view on the screen is their combination based on the graphic mode."}],"\n",["$","p",null,{"children":"Each 2D engine has different sets of four possible modes:"}],"\n",["$","ul",null,{"children":["\n",["$","li",null,{"children":"Tiled"}],"\n",["$","li",null,{"children":"Rotoscale"}],"\n",["$","li",null,{"children":"Extended Rotoscale"}],"\n",["$","li",null,{"children":"Framebuffer"}],"\n"]}],"\n",["$","p",null,{"children":"There are two 2D engines on the NDS"}],"\n",["$","ul",null,{"children":["\n",["$","li",null,{"children":"Main: can display both video memory content or bitmaps of 256 colours. Also it can use the proprietary 3D graphics engine for backgrounds."}],"\n",["$","li",null,{"children":"Sub: secondary display that can only use the video memory content."}],"\n"]}],"\n",["$","p",null,{"children":"Main engine modes"}],"\n",["$","p",null,{"children":["$","img",null,{"src":"/velite/nds-main-screen-modes-0b168f.svg","alt":"Main Screen Modes"}]}],"\n",["$","p",null,{"children":"Sub engine modes"}],"\n",["$","p",null,{"children":["$","img",null,{"src":"/velite/nds-sub-screen-modes-3e3c49.svg","alt":"Sub Screen Modes"}]}],"\n",["$","h3",null,{"id":"backgrounds","children":["$","a",null,{"className":"subheading-anchor","aria-label":"Link to section","href":"#backgrounds","children":"Backgrounds"}]}],"\n",["$","p",null,{"children":"Up to four superposed backgrounds can be used at a time, and each one can be used in a different mode. BG0 is the topmost background and BG4 the furthest."}],"\n",["$","p",null,{"children":"The background memory is divided in 32 blocks of 16KB."}],"\n",["$","p",null,{"children":["$","img",null,{"src":"/velite/nds-background-mem-dfcc11.svg","alt":"NDS Background memory"}]}],"\n",["$","p",null,{"children":["To configure the background controller in a ",["$","strong",null,{"children":"bitmap / framebuffer"}]," mode, we indicate the slot to use in the dedicated memory for backgrounds using ",["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"BG_BMP_BASE(x)"}]}]}]}]," (or ",["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"BG_BMP_BASE_SUB(x)"}]}]}]}]," for the secondary display) and indicate background size and format (ex: ",["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"BgSize_B8_256x256"}]}]}]}]," - palette format & 256x256 pixels)."]}],"\n",["$","p",null,{"children":["To configure the background controller in a ",["$","strong",null,{"children":"tiled"}]," mode, we specify the tile grid size (ex: ",["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"BG_32x32"}]}]}]}],"), color amount (ex: ",["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"BG_COLOR_256"}]}]}]}],"), map base (ex: ",["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"BG_MAP_BASE(x)"}]}]}]}],") and tile base (ex: ",["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"BG_TILE_BASE(x)"}]}]}]}],")."]}],"\n",["$","p",null,{"children":["$","img",null,{"src":"/velite/nds-background_control-d1d10b.svg","alt":""}]}],"\n",["$","div",null,{"className":"callout example","children":[["$","p",null,{"children":"Configuring background controller in a bitmap / framebuffer mode:"}],["$","figure",null,{"data-rehype-pretty-code-figure":"","children":["$","pre",null,{"style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"tabIndex":"0","data-language":"c","data-theme":"github-dark-dimmed github-light","children":["$","code",null,{"data-language":"c","data-theme":"github-dark-dimmed github-light","style":{"display":"grid"},"children":["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#F69D50","--shiki-light":"#E36209"},"children":"BGCTRL"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"["}],["$","span",null,{"style":{"--shiki-dark":"#6CB6FF","--shiki-light":"#005CC5"},"children":"2"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"] "}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"="}],["$","span",null,{"style":{"--shiki-dark":"#DCBDFB","--shiki-light":"#6F42C1"},"children":" BG_BMP_BASE"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"("}],["$","span",null,{"style":{"--shiki-dark":"#6CB6FF","--shiki-light":"#005CC5"},"children":"0"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":") "}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"|"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":" BgSize_B16_256x256;"}]]}]}]}]}],["$","p",null,{"children":"Configuring background controller for secondary display:"}],["$","figure",null,{"data-rehype-pretty-code-figure":"","children":["$","pre",null,{"style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"tabIndex":"0","data-language":"c","data-theme":"github-dark-dimmed github-light","children":["$","code",null,{"data-language":"c","data-theme":"github-dark-dimmed github-light","style":{"display":"grid"},"children":["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#F69D50","--shiki-light":"#E36209"},"children":"BGCTRL_SUB"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"["}],["$","span",null,{"style":{"--shiki-dark":"#6CB6FF","--shiki-light":"#005CC5"},"children":"2"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"] "}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"="}],["$","span",null,{"style":{"--shiki-dark":"#DCBDFB","--shiki-light":"#6F42C1"},"children":" BG_BMP_BASE"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"("}],["$","span",null,{"style":{"--shiki-dark":"#6CB6FF","--shiki-light":"#005CC5"},"children":"0"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":") "}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"|"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":" BgSize_B8_256x256;"}]]}]}]}]}],["$","p",null,{"children":"Configuring background controller in tiled mode:"}],["$","figure",null,{"data-rehype-pretty-code-figure":"","children":["$","pre",null,{"style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"tabIndex":"0","data-language":"c","data-theme":"github-dark-dimmed github-light","children":["$","code",null,{"data-language":"c","data-theme":"github-dark-dimmed github-light","style":{"display":"grid"},"children":["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#F69D50","--shiki-light":"#E36209"},"children":"BGCTRL"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"["}],["$","span",null,{"style":{"--shiki-dark":"#6CB6FF","--shiki-light":"#005CC5"},"children":"0"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"] "}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"="}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":" BG_32x32 "}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"|"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":" BG_COLOR_256 "}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"|"}],["$","span",null,{"style":{"--shiki-dark":"#DCBDFB","--shiki-light":"#6F42C1"},"children":" BG_MAP_BASE"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"("}],["$","span",null,{"style":{"--shiki-dark":"#6CB6FF","--shiki-light":"#005CC5"},"children":"0"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":") "}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"|"}],["$","span",null,{"style":{"--shiki-dark":"#DCBDFB","--shiki-light":"#6F42C1"},"children":" BG_TILE_BASE"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"("}],["$","span",null,{"style":{"--shiki-dark":"#6CB6FF","--shiki-light":"#005CC5"},"children":"1"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":");"}]]}]}]}]}]]}],"\n",["$","p",null,{"children":["Background X can be shifted (scroll) using write-only registers ",["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"REG_BGXHOFS"}]}]}]}]," and ",["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"REG_BGXVOFS"}]}]}]}]," (where X is the number of the background)."]}],"\n",["$","h3",null,{"id":"framebuffer-mode","children":["$","a",null,{"className":"subheading-anchor","aria-label":"Link to section","href":"#framebuffer-mode","children":"Framebuffer Mode"}]}],"\n",["$","p",null,{"children":"In the Framebuffer mode, the screen is directly mapped to a portion of memory (192 x 256 bitmap). Writing data to this memory directly results in data represented onto the screen."}],"\n",["$","p",null,{"children":"There are four different framebuffers, that are each linked to one of the four 128KiB VRAM banks."}],"\n",["$","table",null,{"children":[["$","thead",null,{"children":["$","tr",null,{"children":[["$","th",null,{}],["$","th",null,{}]]}]}],["$","tbody",null,{"children":[["$","tr",null,{"children":[["$","td",null,{"children":["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"FB0"}]}]}]}]}],["$","td",null,{"children":["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"VRAM_A"}]}]}]}]}]]}],["$","tr",null,{"children":[["$","td",null,{"children":["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"FB1"}]}]}]}]}],["$","td",null,{"children":["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"VRAM_B"}]}]}]}]}]]}],["$","tr",null,{"children":[["$","td",null,{"children":["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"FB2"}]}]}]}]}],["$","td",null,{"children":["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"VRAM_C"}]}]}]}]}]]}],["$","tr",null,{"children":[["$","td",null,{"children":["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"FB3"}]}]}]}]}],["$","td",null,{"children":["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"VRAM_D"}]}]}]}]}]]}]]}]]}],"\n",["$","p",null,{"children":["The ",["$","a",null,{"href":"#pixels--color","children":"pixel format"}]," is always ",["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"RGB15"}]}]}]}]," in the framebuffer mode : pixels are always opaque, so the transparency bit is not used."]}],"\n",["$","p",null,{"children":"We can also use double buffering : One buffer is being read to write on the screen, while another one is being written in memory, and they are exchanged at the VBLANK interrupt."}],"\n",["$","div",null,{"className":"callout example","children":[["$","p",null,{"children":["Configuration when using framebuffer ",["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"FB0"}]}]}]}]]}],["$","figure",null,{"data-rehype-pretty-code-figure":"","children":["$","pre",null,{"style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"tabIndex":"0","data-language":"c","data-theme":"github-dark-dimmed github-light","children":["$","code",null,{"data-language":"c","data-theme":"github-dark-dimmed github-light","style":{"display":"grid"},"children":[["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"REG_DISPCNT "}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"="}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":" MODE_FB0;"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"VRAM_A_CR "}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"="}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":" VRAM_ENABLE "}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"|"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":" VRAM_A_LCD;"}]]}]]}]}]}]]}],"\n",["$","h3",null,{"id":"rotoscale-mode","children":["$","a",null,{"className":"subheading-anchor","aria-label":"Link to section","href":"#rotoscale-mode","children":"Rotoscale Mode"}]}],"\n",["$","p",null,{"children":"In the rotoscale mode, the memory is not directly mapped onto the screen. We have a couple more functionnalities."}],"\n",["$","p",null,{"children":"The rotoscale mode is called this way because it uses a transformation matrix, which allows us to rotate, scale an displace our original backgrounds."}],"\n",["$","p",null,{"children":"The rotoscale mode also uses palettes: instead of each pixel being 16 bits, we only use 8 bits for each pixel."}],"\n",["$","p",null,{"children":"The configuration for this mode has a couple more steps: on top of the usual Power Manager, VRAM and Graphical Engines configurations, we also need to configure each background, and the palette(s) when using 8 bit mode. We also need to adjust the transformation matrix for each background if we are using extended rotoscale."}],"\n",["$","div",null,{"className":"callout note","children":["$","p",null,{"children":"Use extended rotoscale rather than rotoscale by default. Don't forget to set the transformation matrix to be identity if you don't want to use the rotation, as it still needs to be defined."}]}],"\n",["$","h4",null,{"id":"transformation-matrix","children":["$","a",null,{"className":"subheading-anchor","aria-label":"Link to section","href":"#transformation-matrix","children":"Transformation Matrix"}]}],"\n",["$","p",null,{"children":"Rotoscale mode allows us to apply a rotation and scaling operation on the different backgrounds using a transformation matrix."}],"\n",["$","p",null,{"children":["The transformation matrix is configured using ",["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"bgTransform"}]}]}]}],"."]}],"\n",["$","p",null,{"children":["Although the fields are declared as signed integers, they use fixed-point numbers, with 8 bits for decimal part. So to write a number ",["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"x"}]}]}]}]," we must actually use ",["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"x * 256"}]}]}]}]]}],"\n",["$","figure",null,{"data-rehype-pretty-code-figure":"","children":["$","pre",null,{"style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"tabIndex":"0","data-language":"c","data-theme":"github-dark-dimmed github-light","children":["$","code",null,{"data-language":"c","data-theme":"github-dark-dimmed github-light","style":{"display":"grid"},"children":[["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"typedef"}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":" struct"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":" {"}]]}],"\n",["$","span",null,{"data-line":"","children":["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":" s16 hdx;"}]}],"\n",["$","span",null,{"data-line":"","children":["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":" s16 vdx;"}]}],"\n",["$","span",null,{"data-line":"","children":["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":" s16 hdy;"}]}],"\n",["$","span",null,{"data-line":"","children":["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":" s16 vdy;"}]}],"\n",["$","span",null,{"data-line":"","children":["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":" s32 dx;"}]}],"\n",["$","span",null,{"data-line":"","children":["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":" s32 dy;"}]}],"\n",["$","span",null,{"data-line":"","children":["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"} bg_transform;"}]}]]}]}]}],"\n",["$","p",null,{"children":"For each background, we configure the transformation matrix like this (n is the nackground number):"}],"\n",["$","figure",null,{"data-rehype-pretty-code-figure":"","children":["$","pre",null,{"style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"tabIndex":"0","data-language":"c","data-theme":"github-dark-dimmed github-light","children":["$","code",null,{"data-language":"c","data-theme":"github-dark-dimmed github-light","style":{"display":"grid"},"children":[["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#F69D50","--shiki-light":"#E36209"},"children":"bgTransform"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"[n]"}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"->"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"hdx"}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"="}],["$","span",null,{"style":{"--shiki-dark":"#6CB6FF","--shiki-light":"#005CC5"},"children":"256"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":";"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#F69D50","--shiki-light":"#E36209"},"children":"bgTransform"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"[n]"}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"->"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"vdx"}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"="}],["$","span",null,{"style":{"--shiki-dark":"#6CB6FF","--shiki-light":"#005CC5"},"children":" 0"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":";"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#F69D50","--shiki-light":"#E36209"},"children":"bgTransform"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"[n]"}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"->"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"hdy"}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"="}],["$","span",null,{"style":{"--shiki-dark":"#6CB6FF","--shiki-light":"#005CC5"},"children":" 0"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":";"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#F69D50","--shiki-light":"#E36209"},"children":"bgTransform"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"[n]"}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"->"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"vdy"}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"="}],["$","span",null,{"style":{"--shiki-dark":"#6CB6FF","--shiki-light":"#005CC5"},"children":" 256"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":";"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#F69D50","--shiki-light":"#E36209"},"children":"bgTransform"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"[n]"}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"->"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"dx"}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"="}],["$","span",null,{"style":{"--shiki-dark":"#6CB6FF","--shiki-light":"#005CC5"},"children":" 0"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":";"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#F69D50","--shiki-light":"#E36209"},"children":"bgTransform"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"[n]"}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"->"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"dy"}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"="}],["$","span",null,{"style":{"--shiki-dark":"#6CB6FF","--shiki-light":"#005CC5"},"children":" 0"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":";"}]]}]]}]}]}],"\n",["$","p",null,{"children":"Here are some well know transformations:"}],"\n",["$","table",null,{"children":[["$","thead",null,{"children":["$","tr",null,{"children":[["$","th",null,{}],["$","th",null,{}]]}]}],["$","tbody",null,{"children":[["$","tr",null,{"children":[["$","td",null,{"children":["$","img",null,{"src":"/velite/base-a6d8a8.svg","alt":""}]}],["$","td",null,{"children":"Transformation matrix format"}]]}],["$","tr",null,{"children":[["$","td",null,{"children":["$","img",null,{"src":"/velite/identity-7702e4.svg","alt":""}]}],["$","td",null,{"children":"Identity"}]]}],["$","tr",null,{"children":[["$","td",null,{"children":["$","img",null,{"src":"/velite/vert-mirror-3cd1b2.svg","alt":""}]}],["$","td",null,{"children":"Vertical Mirror"}]]}],["$","tr",null,{"children":[["$","td",null,{"children":["$","img",null,{"src":"/velite/hor-mirror-0e7b77.svg","alt":""}]}],["$","td",null,{"children":"Horizontal Mirror"}]]}],["$","tr",null,{"children":[["$","td",null,{"children":["$","img",null,{"src":"/velite/vert-hor-mirror-f4efa1.svg","alt":""}]}],["$","td",null,{"children":"Vertical & Horizontal Mirror"}]]}],["$","tr",null,{"children":[["$","td",null,{"children":["$","img",null,{"src":"/velite/vert-shrink-317196.svg","alt":""}]}],["$","td",null,{"children":"Vertical Shrink (divide height by 2)"}]]}],["$","tr",null,{"children":[["$","td",null,{"children":["$","img",null,{"src":"/velite/hor-shrink-a28395.svg","alt":""}]}],["$","td",null,{"children":"Horizontal Shrink (divide width by 2)"}]]}],["$","tr",null,{"children":[["$","td",null,{"children":["$","img",null,{"src":"/velite/rot-clockwise-y-532b83.svg","alt":""}]}],["$","td",null,{"children":"Clockwise Rotation by y (in radians)"}]]}]]}]]}],"\n",["$","div",null,{"className":"callout note","children":["$","p",null,{"children":[["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"hdx"}]}]}]}]," and ",["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"vdx"}]}]}]}]," were previously ",["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"xdx"}]}]}]}]," and ",["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"ydx"}]}]}]}],". Be careful which one you use, depending on your version of LibNDS."]}]}],"\n",["$","h3",null,{"id":"tiled-mode","children":["$","a",null,{"className":"subheading-anchor","aria-label":"Link to section","href":"#tiled-mode","children":"Tiled Mode"}]}],"\n",["$","p",null,{"children":"In the tiled mode, the backgrounds are composed of smaller blocks. The minimum unit used to create tiled backgrounds are called tiles (or text), and are blocks of 8x8 pixels."}],"\n",["$","p",null,{"children":"Backgrounds are maps of tiles : they reference tiles using their index. The tile collection can contain up to 1024 tiles, meaning their index is 10 bits."}],"\n",["$","p",null,{"children":"Palettes are also used for pixels in tiled mode. Either one 256 color palette or 16 palettes of 16 colors are used."}],"\n",["$","h4",null,{"id":"tiles","children":["$","a",null,{"className":"subheading-anchor","aria-label":"Link to section","href":"#tiles","children":"Tiles"}]}],"\n",["$","p",null,{"children":"Tiles are essentially 8x8 matrix of color indexes from a palette. These color indexes are either 8 bits (256 color palette) or 4 bits (16 color palette)."}],"\n",["$","p",null,{"children":["Tiles are stored from the base address ",["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"BG_TILE_RAM(x)"}]}]}]}],". Tile base addresses are multiples of 16KiB and the maximum size is 256KiB."]}],"\n",["$","p",null,{"children":["We use ",["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"BG_TILE_BASE(x)"}]}]}]}]," to configure the background control register and ",["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"BG_TILE_RAM(x)"}]}]}]}]," (or ",["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"BG_TILE_RAM_SUB(x)"}]}]}]}],") to access the tile set or modify it."]}],"\n",["$","p",null,{"children":[["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"x"}]}]}]}]," goes from 0 to 15 (there are 16 base addresses for tiles). This is due to the fact that 4 bits are used to store tile base displacement in the background control register."]}],"\n",["$","p",null,{"children":["$","img",null,{"src":"/velite/nds-tiles_ram-6f68b0.svg","alt":""}]}],"\n",["$","h4",null,{"id":"maps","children":["$","a",null,{"className":"subheading-anchor","aria-label":"Link to section","href":"#maps","children":"Maps"}]}],"\n",["$","p",null,{"children":"A map of tiles can be larger than the screen, and the visible area can then be adjusted with a scroll effect. The screen has size 32x34 tiles (256x192 pixels)."}],"\n",["$","p",null,{"children":"There are four possible map sizes on the NDS:"}],"\n",["$","p",null,{"children":[["$","img",null,{"src":"/velite/nds-map-size-32x32-682fa6.svg","alt":""}]," ",["$","img",null,{"src":"/velite/nds-map-size-32x64-075d77.svg","alt":""}]," ",["$","img",null,{"src":"/velite/nds-map-size-64x32-74d317.svg","alt":""}]," ",["$","img",null,{"src":"/velite/nds-map-size-64x64-bc5c2e.svg","alt":""}]]}],"\n",["$","p",null,{"children":"Each tile in a map is represented with 16 bits:"}],"\n",["$","p",null,{"children":["$","img",null,{"src":"/velite/nds-map_control-6f65a2.svg","alt":""}]}],"\n",["$","p",null,{"children":"The palette is specified if 16 palettes of 16 colors are used. This way tiles can use 4 bit colors."}],"\n",["$","p",null,{"children":["To set the tiles data in map we can use ",["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"TILE_PALETTE"}]}]}]}]," for the palette, and ",["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"TILE_FLIP_H"}]}]}]}]," and ",["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"TILE_FLIP_V"}]}]}]}]," for the flip bits."]}],"\n",["$","p",null,{"children":["Maps are stored from the base address ",["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"BG_MAP_RAM(x)"}]}]}]}],". Map base addresses are multiples of 2KiB and the maximum size is 64KiB. The most used size of map is 32x32 tiles, which is exactly 2KiB (2B per tile), but other map sizes may use up more than one slot in RAM."]}],"\n",["$","p",null,{"children":["We use ",["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"BG_MAP_BASE(x)"}]}]}]}]," to configure the background control register and ",["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"BG_MAP_RAM(x)"}]}]}]}]," (or ",["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"BG_MAP_RAM_SUB(x)"}]}]}]}],") to access the tile set or modify it."]}],"\n",["$","p",null,{"children":[["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"x"}]}]}]}]," goes from 0 to 31 (there are 32 base addresses for maps). This is due to the fact that 5 bits are used to store tile base displacement in the background control register."]}],"\n",["$","p",null,{"children":["$","img",null,{"src":"/velite/nds-map_ram-8dd709.svg","alt":""}]}],"\n",["$","h3",null,{"id":"sprites","children":["$","a",null,{"className":"subheading-anchor","aria-label":"Link to section","href":"#sprites","children":"Sprites"}]}],"\n",["$","p",null,{"children":"Sprites are small graphic objects that can be rendered on top of the backgrounds and provide extended features."}],"\n",["$","p",null,{"children":"Different sizes are possible (8x8, 16x16, 32x32, 64x64, 16x8, 32x8, 32x16, 64x32, 8x32, 16x32)."}],"\n",["$","p",null,{"children":"They can be rendered in any position, on or outside of the screen. They can be rotated, scaled or flipped, and can be made in different modes (bitmap, tiled...)."}],"\n",["$","p",null,{"children":"The amount of sprites is fixed to 128 and they are hidden by default."}],"\n",["$","p",null,{"children":"A special mode has to be configured in a VRAM mode: this bank cannot be used for anything else (e.g.: for backgrounds). A sprite is associated to a graphic stored in memory and several sprites can be associated to the same graphic (we can have several sprites with a single graphic loaded in memory). They use a special palette (different from the one used for backgrounds) and can use extended palettes"}],"\n",["$","div",null,{"className":"callout example","children":[["$","p",null,{"children":"Sprite Configuration:"}],["$","figure",null,{"data-rehype-pretty-code-figure":"","children":["$","pre",null,{"style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"tabIndex":"0","data-language":"c","data-theme":"github-dark-dimmed github-light","children":["$","code",null,{"data-language":"c","data-theme":"github-dark-dimmed github-light","style":{"display":"grid"},"children":[["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"VRAM_B_CR "}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"="}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":" VRAM_ENABLE "}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"|"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":" VRAM_B_MAIN_SPRITE;"}]]}],"\n",["$","span",null,{"data-line":"","children":" "}],"\n",["$","span",null,{"data-line":"","children":["$","span",null,{"style":{"--shiki-dark":"#768390","--shiki-light":"#6A737D"},"children":"// Initialize sprite manager and the engine"}]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#DCBDFB","--shiki-light":"#6F42C1"},"children":"oamInit"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"("}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"&"}],["$","span",null,{"style":{"--shiki-dark":"#F69D50","--shiki-light":"#E36209"},"children":"oamMain"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":", SpriteMapping_1D_32, "}],["$","span",null,{"style":{"--shiki-dark":"#6CB6FF","--shiki-light":"#005CC5"},"children":"false"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":");"}]]}],"\n",["$","span",null,{"data-line":"","children":" "}],"\n",["$","span",null,{"data-line":"","children":["$","span",null,{"style":{"--shiki-dark":"#768390","--shiki-light":"#6A737D"},"children":"// Allocate space for the graphic to show in the sprite"}]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"gfx "}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"="}],["$","span",null,{"style":{"--shiki-dark":"#DCBDFB","--shiki-light":"#6F42C1"},"children":" oamAllocateGfx"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"("}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"&"}],["$","span",null,{"style":{"--shiki-dark":"#F69D50","--shiki-light":"#E36209"},"children":"oamMain"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":", SpriteSize_32x32, SpriteColorFormat_256Color);"}]]}],"\n",["$","span",null,{"data-line":"","children":" "}],"\n",["$","span",null,{"data-line":"","children":["$","span",null,{"style":{"--shiki-dark":"#768390","--shiki-light":"#6A737D"},"children":"// Copy data for th graphic"}]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#DCBDFB","--shiki-light":"#6F42C1"},"children":"swiCopy"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"(imagePal, SPRITE_PALETTE, imagePalLen "}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"/"}],["$","span",null,{"style":{"--shiki-dark":"#6CB6FF","--shiki-light":"#005CC5"},"children":" 2"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":");"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#DCBDFB","--shiki-light":"#6F42C1"},"children":"swiCopy"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"(imageTiles, gfx, imageTilesLen);"}]]}],"\n",["$","span",null,{"data-line":"","children":" "}]]}]}]}],["$","p",null,{"children":"Simple Sprite Usage:"}],["$","figure",null,{"data-rehype-pretty-code-figure":"","children":["$","pre",null,{"style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"tabIndex":"0","data-language":"c","data-theme":"github-dark-dimmed github-light","children":["$","code",null,{"data-language":"c","data-theme":"github-dark-dimmed github-light","style":{"display":"grid"},"children":[["$","span",null,{"data-line":"","children":["$","span",null,{"style":{"--shiki-dark":"#768390","--shiki-light":"#6A737D"},"children":"//Position"}]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"int"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":" x "}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"="}],["$","span",null,{"style":{"--shiki-dark":"#6CB6FF","--shiki-light":"#005CC5"},"children":" 0"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":", y "}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"="}],["$","span",null,{"style":{"--shiki-dark":"#6CB6FF","--shiki-light":"#005CC5"},"children":" 0"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":", keys;"}]]}],"\n",["$","span",null,{"data-line":"","children":" "}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"while"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":" ("}],["$","span",null,{"style":{"--shiki-dark":"#6CB6FF","--shiki-light":"#005CC5"},"children":"1"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":") {"}]]}],"\n",["$","span",null,{"data-line":"","children":["$","span",null,{"style":{"--shiki-dark":"#768390","--shiki-light":"#6A737D"},"children":" //Read held keys"}]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#DCBDFB","--shiki-light":"#6F42C1"},"children":" scanKeys"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"() ;"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":" keys "}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"="}],["$","span",null,{"style":{"--shiki-dark":"#DCBDFB","--shiki-light":"#6F42C1"},"children":" keysHeld"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"();"}]]}],"\n",["$","span",null,{"data-line":"","children":" "}],"\n",["$","span",null,{"data-line":"","children":["$","span",null,{"style":{"--shiki-dark":"#768390","--shiki-light":"#6A737D"},"children":" //Modify position of the sprite accordingly"}]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":" if"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"((keys "}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"&"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":" KEY_RIGHT) "}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"&&"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":" (x "}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"<"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":" (SCREEN_WIDTH "}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"-"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":" SPRITE_WIDTH)))"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":" x"}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"+="}],["$","span",null,{"style":{"--shiki-dark":"#6CB6FF","--shiki-light":"#005CC5"},"children":"2"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":" if"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"((keys "}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"&"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":" KEF DOWN) "}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"&&"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":" (y "}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"<"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":" (SCREEN HEIGHT "}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"-"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":" SPRITE_HEIGHT)))"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":" y"}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"+="}],["$","span",null,{"style":{"--shiki-dark":"#6CB6FF","--shiki-light":"#005CC5"},"children":"2"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":";"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":" if"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"((keys "}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"&"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":" KEF LEFT) "}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"&&"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":" (x "}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":">"}],["$","span",null,{"style":{"--shiki-dark":"#6CB6FF","--shiki-light":"#005CC5"},"children":" 0"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"))"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":" x"}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"-="}],["$","span",null,{"style":{"--shiki-dark":"#6CB6FF","--shiki-light":"#005CC5"},"children":"2"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":";"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":" if"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"((keys "}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"&"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":" KEF UP) "}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"&&"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":" (y "}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":">"}],["$","span",null,{"style":{"--shiki-dark":"#6CB6FF","--shiki-light":"#005CC5"},"children":" 0"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"))"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":" y"}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"-="}],["$","span",null,{"style":{"--shiki-dark":"#6CB6FF","--shiki-light":"#005CC5"},"children":"2"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":";"}]]}],"\n",["$","span",null,{"data-line":"","children":" "}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#DCBDFB","--shiki-light":"#6F42C1"},"children":" oamSet"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":" ("}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"&"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"oaMain ,"}],["$","span",null,{"style":{"--shiki-dark":"#768390","--shiki-light":"#6A737D"},"children":" // oam handler"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#6CB6FF","--shiki-light":"#005CC5"},"children":" 0"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":","}],["$","span",null,{"style":{"--shiki-dark":"#768390","--shiki-light":"#6A737D"},"children":" // Number of sprite"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":" x, y,"}],["$","span",null,{"style":{"--shiki-dark":"#768390","--shiki-light":"#6A737D"},"children":" // Coordinates (top left)"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#6CB6FF","--shiki-light":"#005CC5"},"children":" 0"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":","}],["$","span",null,{"style":{"--shiki-dark":"#768390","--shiki-light":"#6A737D"},"children":" // Priority"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#6CB6FF","--shiki-light":"#005CC5"},"children":" 0"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":","}],["$","span",null,{"style":{"--shiki-dark":"#768390","--shiki-light":"#6A737D"},"children":" // Palette to use"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":" SpriteSize_32x32,"}],["$","span",null,{"style":{"--shiki-dark":"#768390","--shiki-light":"#6A737D"},"children":" // Sprite size"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":" SpriteColorFormat_256Color,"}],["$","span",null,{"style":{"--shiki-dark":"#768390","--shiki-light":"#6A737D"},"children":" // Color format"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":" gfx,"}],["$","span",null,{"style":{"--shiki-dark":"#768390","--shiki-light":"#6A737D"},"children":" // Loaded graphic to display"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":" -"}],["$","span",null,{"style":{"--shiki-dark":"#6CB6FF","--shiki-light":"#005CC5"},"children":"1"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":","}],["$","span",null,{"style":{"--shiki-dark":"#768390","--shiki-light":"#6A737D"},"children":" // Affine rotation (-1 none)"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#6CB6FF","--shiki-light":"#005CC5"},"children":" false"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":","}],["$","span",null,{"style":{"--shiki-dark":"#768390","--shiki-light":"#6A737D"},"children":" // Double size if rotating"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#6CB6FF","--shiki-light":"#005CC5"},"children":" false"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":","}],["$","span",null,{"style":{"--shiki-dark":"#768390","--shiki-light":"#6A737D"},"children":" // Hide this sprite"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#6CB6FF","--shiki-light":"#005CC5"},"children":" false"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":", "}],["$","span",null,{"style":{"--shiki-dark":"#6CB6FF","--shiki-light":"#005CC5"},"children":"false"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":","}],["$","span",null,{"style":{"--shiki-dark":"#768390","--shiki-light":"#6A737D"},"children":" // Horizontal or vertical flip"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#6CB6FF","--shiki-light":"#005CC5"},"children":" false"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":");"}],["$","span",null,{"style":{"--shiki-dark":"#768390","--shiki-light":"#6A737D"},"children":" // Mosaic"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#DCBDFB","--shiki-light":"#6F42C1"},"children":" swiWaitForVBlank"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"();"}]]}],"\n",["$","span",null,{"data-line":"","children":" "}],"\n",["$","span",null,{"data-line":"","children":["$","span",null,{"style":{"--shiki-dark":"#768390","--shiki-light":"#6A737D"},"children":" //Update the sprites"}]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#DCBDFB","--shiki-light":"#6F42C1"},"children":" oamUpdate"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"("}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"&"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"oamMain);}"}]]}]]}]}]}]]}],"\n",["$","h3",null,{"id":"grit","children":["$","a",null,{"className":"subheading-anchor","aria-label":"Link to section","href":"#grit","children":"Grit"}]}],"\n",["$","p",null,{"children":"Grit (GBA Raster Image Transmogrifier) is a tool that transforms images from PNG format into an NDS readable format."}],"\n",["$","p",null,{"children":"It generates assembly code and a C header file (declaration of palettes, maps and graphic data)."}],"\n",["$","p",null,{"children":"Conversion is automated using a few rules included in the Makefile of the project and a configuration file (extension .grit). The configuration file simply contains some parameter flags. It must have the same name as the image."}],"\n",["$","ul",null,{"children":["\n",["$","li",null,{"children":"Place image to transform (“myImage.png”) and configuration file ( “myImage.grit”) in the project folder data"}],"\n",["$","li",null,{"children":"During the compilation process, grit will be called and the output files will be placed automatically in the temporary building folder build"}],"\n"]}],"\n",["$","p",null,{"children":"The grit configuration file may contain the following parameters :"}],"\n",["$","table",null,{"children":[["$","thead",null,{"children":["$","tr",null,{"children":[["$","th",null,{}],["$","th",null,{}],["$","th",null,{}]]}]}],["$","tbody",null,{"children":[["$","tr",null,{"children":[["$","td",null,{"children":"-g | -g!"}],["$","td",null,{"children":"Include or do not include graphic data"}],["$","td",null,{"children":"Always Include!"}]]}],["$","tr",null,{"children":[["$","td",null,{"children":"-gb | -gt"}],["$","td",null,{"children":"Generate Bitmap or Tiles"}],["$","td",null,{"children":"Depends on Mode"}]]}],["$","tr",null,{"children":[["$","td",null,{"children":"-p | -p!"}],["$","td",null,{"children":"Include or do not include the palette"}],["$","td",null,{"children":"Usually Generate"}]]}],["$","tr",null,{"children":[["$","td",null,{"children":"-m | -m!"}],["$","td",null,{"children":"Include or do not include the map"}],["$","td",null,{"children":"For Tiled Mode"}]]}],["$","tr",null,{"children":[["$","td",null,{"children":"-pnX"}],["$","td",null,{"children":"Restrict the palette size to X colors"}],["$","td",null,{}]]}],["$","tr",null,{"children":[["$","td",null,{"children":"-gBX"}],["$","td",null,{"children":"Sets the pixel size to X bits"}],["$","td",null,{"children":"X = 8 or 16"}]]}],["$","tr",null,{"children":[["$","td",null,{"children":"-gTC"}],["$","td",null,{"children":"Sets the color C to transparent"}],["$","td",null,{"children":"C = hex"}]]}]]}]]}],"\n",["$","p",null,{"children":"Grit can be used from the terminal like this :"}],"\n",["$","figure",null,{"data-rehype-pretty-code-figure":"","children":["$","pre",null,{"style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"tabIndex":"0","data-language":"bash","data-theme":"github-dark-dimmed github-light","children":["$","code",null,{"data-language":"bash","data-theme":"github-dark-dimmed github-light","style":{"display":"grid"},"children":["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#F69D50","--shiki-light":"#6F42C1"},"children":"grit"}],["$","span",null,{"style":{"--shiki-dark":"#96D0FF","--shiki-light":"#032F62"},"children":" myImage.png"}],["$","span",null,{"style":{"--shiki-dark":"#6CB6FF","--shiki-light":"#005CC5"},"children":" -g"}],["$","span",null,{"style":{"--shiki-dark":"#6CB6FF","--shiki-light":"#005CC5"},"children":" -gB16"}]]}]}]}]}],"\n",["$","p",null,{"children":["For more parameters use ",["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"bash","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#F69D50","--shiki-light":"#6F42C1"},"children":"grit"}],["$","span",null,{"style":{"--shiki-dark":"#6CB6FF","--shiki-light":"#005CC5"},"children":" --help"}]]}]}]}],"."]}],"\n",["$","div",null,{"className":"callout note","children":[["$","p",null,{"children":"For tiles, image sizes must be multiples of 8."}],["$","p",null,{"children":"Color (for setting transparency color) should be a 16bit BGR color or 24bit RGB color in hex."}]]}],"\n",["$","h3",null,{"id":"vram-management","children":["$","a",null,{"className":"subheading-anchor","aria-label":"Link to section","href":"#vram-management","children":"VRAM Management"}]}],"\n",["$","p",null,{"children":"Many different types of data may be stored in VRAM, like palettes, maps, tiles... Because all of these are stored in the same memory spaces we must be careful to avoid overlaps, or we may accidentally overwrite some parts of memory and loose data."}],"\n",["$","p",null,{"children":["To do this we must take into consideration base addresses as well as storage size. For example ",["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"BG_TILE_BASE"}]}]}]}]," and ",["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"BG_MAP_BASE"}]}]}]}]," may overlap : both begin at the same place in memory. This is something we must take into account when assigning our slots."]}],"\n",["$","p",null,{"children":"Note that the VRAM banks reside in the background memory starting from 0x6000000. If you use the macro VRAM_x_MAIN_BG when activating VRAM_x, then all the VRAM banks will be continuous starting from VRAM_A at 0x6000000."}],"\n",["$","p",null,{"children":"Each type of data has a fixed assignment in VRAM banks:"}],"\n",["$","p",null,{"children":["$","img",null,{"src":"/velite/nds-vram-assignments-e6246b.svg","alt":""}]}],"\n",["$","p",null,{"children":"The base indexes we use to place each type of data in VRAM overlap like this:"}],"\n",["$","p",null,{"children":["$","img",null,{"src":"/velite/nds-vram_collis-3aecda.svg","alt":""}]}],"\n",["$","p",null,{"children":"Some things to keep in mind:"}],"\n",["$","ul",null,{"children":["\n",["$","li",null,{"children":"64x64 maps take up 4 map slots. They are not stored linearly but by quadrant: each of the 4 used map bases contain a quarter of the total map."}],"\n"]}],"\n",["$","h3",null,{"id":"data-transfer","children":["$","a",null,{"className":"subheading-anchor","aria-label":"Link to section","href":"#data-transfer","children":"Data Transfer"}]}],"\n",["$","p",null,{"children":"There are mutliple ways to transfer data between the CPU and I/O subsystems."}],"\n",["$","p",null,{"children":["$","strong",null,{"children":"MemCopy"}]}],"\n",["$","figure",null,{"data-rehype-pretty-code-figure":"","children":["$","pre",null,{"style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"tabIndex":"0","data-language":"c","data-theme":"github-dark-dimmed github-light","children":["$","code",null,{"data-language":"c","data-theme":"github-dark-dimmed github-light","style":{"display":"grid"},"children":["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"void"}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":" *"}],["$","span",null,{"style":{"--shiki-dark":"#DCBDFB","--shiki-light":"#6F42C1"},"children":"memcpy"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"("}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"void"}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":" *"}],["$","span",null,{"style":{"--shiki-dark":"#F69D50","--shiki-light":"#E36209"},"children":"dest"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":", "}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"const"}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":" void"}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":" *"}],["$","span",null,{"style":{"--shiki-dark":"#F69D50","--shiki-light":"#E36209"},"children":" src"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":", "}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"size_t"}],["$","span",null,{"style":{"--shiki-dark":"#F69D50","--shiki-light":"#E36209"},"children":" n"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":")"}]]}]}]}]}],"\n",["$","table",null,{"children":[["$","thead",null,{"children":["$","tr",null,{"children":[["$","th",null,{}],["$","th",null,{}]]}]}],["$","tbody",null,{"children":[["$","tr",null,{"children":[["$","td",null,{"children":"dest"}],["$","td",null,{"children":"Pointer to the destination array where the content is to be copied, type-casted to a pointer of type void*."}]]}],["$","tr",null,{"children":[["$","td",null,{"children":"src"}],["$","td",null,{"children":"Pointer to the source of data to be copied, type-casted to a pointer of type void*."}]]}],["$","tr",null,{"children":[["$","td",null,{"children":"n"}],["$","td",null,{"children":"Number of bytes to be copied."}]]}]]}]]}],"\n",["$","p",null,{"children":["$","strong",null,{"children":"SwiCopy"}]}],"\n",["$","figure",null,{"data-rehype-pretty-code-figure":"","children":["$","pre",null,{"style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"tabIndex":"0","data-language":"c","data-theme":"github-dark-dimmed github-light","children":["$","code",null,{"data-language":"c","data-theme":"github-dark-dimmed github-light","style":{"display":"grid"},"children":["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"void"}],["$","span",null,{"style":{"--shiki-dark":"#DCBDFB","--shiki-light":"#6F42C1"},"children":" swiCopy"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"("}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"const"}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":" void"}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":" *"}],["$","span",null,{"style":{"--shiki-dark":"#F69D50","--shiki-light":"#E36209"},"children":"src"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":", "}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"void"}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":" *"}],["$","span",null,{"style":{"--shiki-dark":"#F69D50","--shiki-light":"#E36209"},"children":"dest"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":", "}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"int"}],["$","span",null,{"style":{"--shiki-dark":"#F69D50","--shiki-light":"#E36209"},"children":" flags"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":")"}]]}]}]}]}],"\n",["$","table",null,{"children":[["$","thead",null,{"children":["$","tr",null,{"children":[["$","th",null,{}],["$","th",null,{}]]}]}],["$","tbody",null,{"children":[["$","tr",null,{"children":[["$","td",null,{"children":"dest"}],["$","td",null,{"children":"Pointer to the destination array where the content is to be copied, type-casted to a pointer of type void*."}]]}],["$","tr",null,{"children":[["$","td",null,{"children":"src"}],["$","td",null,{"children":"Pointer to the source of data to be copied, type-casted to a pointer of type void*."}]]}],["$","tr",null,{"children":[["$","td",null,{"children":"flags"}],["$","td",null,{"children":"Bits(0-20): size of data to copy/fill in words, or'd with the copy mode size (word or halfword) and type (copy or fill)."}]]}]]}]]}],"\n",["$","p",null,{"children":["You can use ",["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"swiCopy"}]}]}]}]," as you would memCopy, only dividing n by 2 to obtain flags (",["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"swiCopy"}]}]}]}]," copies half words instead of bytes)"]}],"\n",["$","p",null,{"children":["$","strong",null,{"children":"DMACopy"}]}],"\n",["$","figure",null,{"data-rehype-pretty-code-figure":"","children":["$","pre",null,{"style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"tabIndex":"0","data-language":"c","data-theme":"github-dark-dimmed github-light","children":["$","code",null,{"data-language":"c","data-theme":"github-dark-dimmed github-light","style":{"display":"grid"},"children":["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"void"}],["$","span",null,{"style":{"--shiki-dark":"#DCBDFB","--shiki-light":"#6F42C1"},"children":" dmaCopy"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"("}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"const"}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":" void"}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":" *"}],["$","span",null,{"style":{"--shiki-dark":"#F69D50","--shiki-light":"#E36209"},"children":"src"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":", "}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"void"}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":" *"}],["$","span",null,{"style":{"--shiki-dark":"#F69D50","--shiki-light":"#E36209"},"children":"dest"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":", uint32 "}],["$","span",null,{"style":{"--shiki-dark":"#F69D50","--shiki-light":"#E36209"},"children":"size"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":")"}]]}]}]}]}],"\n",["$","table",null,{"children":[["$","thead",null,{"children":["$","tr",null,{"children":[["$","th",null,{}],["$","th",null,{}]]}]}],["$","tbody",null,{"children":[["$","tr",null,{"children":[["$","td",null,{"children":"dest"}],["$","td",null,{"children":"Pointer to the destination array where the content is to be copied, type-casted to a pointer of type void*."}]]}],["$","tr",null,{"children":[["$","td",null,{"children":"src"}],["$","td",null,{"children":"Pointer to the source of data to be copied, type-casted to a pointer of type void*."}]]}],["$","tr",null,{"children":[["$","td",null,{"children":"n"}],["$","td",null,{"children":"Number of bytes to be copied (will be truncated to the nearest half word)."}]]}]]}]]}],"\n",["$","p",null,{"children":[["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"dmaCopy"}]}]}]}]," uses Direct Memory Access to copy data. Using DMA is generally faster and more efficient than CPU copies (",["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"memcpy"}]}]}]}],", ",["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"swiCopy"}]}]}]}],") because it offloads the task of data transfer to a dedicated hardware component, allowing the CPU to perform other tasks."]}],"\n",["$","p",null,{"children":[["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"BG_GFX"}]}]}]}]," is simply a u16 pointer to the address 0x6000000, very useful for copying the bitmaps. This address is the start of VRAM."]}],"\n",["$","div",null,{"className":"callout warning","children":[["$","p",null,{"children":[["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"BG_BMP_RAM"}]}]}]}]," and other similar pointers are often u16 pointers! Make sure to take this into account when incrementing your pointers."]}],["$","p",null,{"children":"For example:"}],["$","figure",null,{"data-rehype-pretty-code-figure":"","children":["$","pre",null,{"style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"tabIndex":"0","data-language":"c","data-theme":"github-dark-dimmed github-light","children":["$","code",null,{"data-language":"c","data-theme":"github-dark-dimmed github-light","style":{"display":"grid"},"children":[["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#DCBDFB","--shiki-light":"#6F42C1"},"children":"dmaCopy"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"(RedTile, "}],["$","span",null,{"style":{"--shiki-dark":"#DCBDFB","--shiki-light":"#6F42C1"},"children":"BG_TILE_RAM_SUB"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"("}],["$","span",null,{"style":{"--shiki-dark":"#6CB6FF","--shiki-light":"#005CC5"},"children":"1"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"), "}],["$","span",null,{"style":{"--shiki-dark":"#6CB6FF","--shiki-light":"#005CC5"},"children":"64"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":");"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#DCBDFB","--shiki-light":"#6F42C1"},"children":"dmaCopy"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"(BlueTile, "}],["$","span",null,{"style":{"--shiki-dark":"#DCBDFB","--shiki-light":"#6F42C1"},"children":"BG_TILE_RAM"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"("}],["$","span",null,{"style":{"--shiki-dark":"#6CB6FF","--shiki-light":"#005CC5"},"children":"1"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":") "}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"+"}],["$","span",null,{"style":{"--shiki-dark":"#6CB6FF","--shiki-light":"#005CC5"},"children":" 32"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":", "}],["$","span",null,{"style":{"--shiki-dark":"#6CB6FF","--shiki-light":"#005CC5"},"children":"64"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":");"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#DCBDFB","--shiki-light":"#6F42C1"},"children":"dmaCopy"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"(GreenTile, "}],["$","span",null,{"style":{"--shiki-dark":"#DCBDFB","--shiki-light":"#6F42C1"},"children":"BG_TILE_RAM"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"("}],["$","span",null,{"style":{"--shiki-dark":"#6CB6FF","--shiki-light":"#005CC5"},"children":"1"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":") "}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"+"}],["$","span",null,{"style":{"--shiki-dark":"#6CB6FF","--shiki-light":"#005CC5"},"children":" 32"}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"*"}],["$","span",null,{"style":{"--shiki-dark":"#6CB6FF","--shiki-light":"#005CC5"},"children":"2"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":", "}],["$","span",null,{"style":{"--shiki-dark":"#6CB6FF","--shiki-light":"#005CC5"},"children":"64"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":");"}]]}]]}]}]}],["$","p",null,{"children":"Tiles are 64 bytes here but we only increment by 32 each time because our pointer is u16 (one increment is 2 bytes)."}],["$","p",null,{"children":"You can also cast your pointer to a u8 or void pointer instead."}]]}],"\n",["$","h2",null,{"id":"controls","children":["$","a",null,{"className":"subheading-anchor","aria-label":"Link to section","href":"#controls","children":"Controls"}]}],"\n",["$","p",null,{"children":"Controls are handled on either the ARM9 or ARM7 CPU, depending on the button."}],"\n",["$","p",null,{"children":["$","img",null,{"src":"/velite/nds-controls-periphs-c71a47.svg","alt":""}]}],"\n",["$","p",null,{"children":"Two methods exist to use the I/O:"}],"\n",["$","p",null,{"children":[["$","strong",null,{"children":"Polling:"}]," programmed I/O with active waiting, using LibNDS methods"]}],"\n",["$","p",null,{"children":"Controls linked to ARM7 can only be used with polling (touchscreen, X and Y Keys) and not with interrupts."}],"\n",["$","p",null,{"children":[["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"void scanKeys()"}]}]}]}]," : scans and stores pressed keys"]}],"\n",["$","p",null,{"children":[["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"uint32 keysHeld()"}]}]}]}]," : returns keys pressed and held"]}],"\n",["$","p",null,{"children":[["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"uint32 keysDown()"}]}]}]}]," : returns keys just pressed"]}],"\n",["$","p",null,{"children":[["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"uint32 keysUp()"}]}]}]}]," : returns keys just released"]}],"\n",["$","p",null,{"children":[["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"void touchRead(touchPosition* pos)"}]}]}]}]," : where was the touch screen pressed?"]}],"\n",["$","p",null,{"children":[["$","strong",null,{"children":"I/O interrupts:"}]," directly managing the ",["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"REG_KEYCNT"}]}]}]}]," register (setup interrupts using bits manipulation of the register using C code)"]}],"\n",["$","p",null,{"children":["Whether a key is currently pressed is stored in the ",["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"REG_KEYINPUT"}]}]}]}]," register for the ARM9 and the ",["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"REG_KEYXY"}]}]}]}]," register for the ARM7. ",["$","strong",null,{"children":"A 0 means the key is pressed, not a 1."}]]}],"\n",["$","p",null,{"children":["Control interrupts are configured in the ",["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"REG_KEYCNT"}]}]}]}]," register. The lower 14 bits control which bits can trigger interrupts. These also correspond to the bits in ",["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"REG_KEYINPUT"}]}]}]}]," and ",["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"REG_KEYXY"}]}]}]}],"."]}],"\n",["$","table",null,{"children":[["$","thead",null,{"children":["$","tr",null,{"children":[["$","th",null,{"children":"Bit"}],["$","th",null,{"children":"LibNDS Name"}],["$","th",null,{"children":"Description"}]]}]}],["$","tbody",null,{"children":[["$","tr",null,{"children":[["$","td",null,{"children":"0"}],["$","td",null,{"children":"KEY_A"}],["$","td",null,{"children":"The A button"}]]}],["$","tr",null,{"children":[["$","td",null,{"children":"1"}],["$","td",null,{"children":"KEY_B"}],["$","td",null,{"children":"The B button"}]]}],["$","tr",null,{"children":[["$","td",null,{"children":"2"}],["$","td",null,{"children":"KEY_SELECT"}],["$","td",null,{"children":"The Select button"}]]}],["$","tr",null,{"children":[["$","td",null,{"children":"3"}],["$","td",null,{"children":"KEY_START"}],["$","td",null,{"children":"The Start button"}]]}],["$","tr",null,{"children":[["$","td",null,{"children":"4"}],["$","td",null,{"children":"KEY_RIGHT"}],["$","td",null,{"children":"Right arrow D-Pad"}]]}],["$","tr",null,{"children":[["$","td",null,{"children":"5"}],["$","td",null,{"children":"KEY_LEFT"}],["$","td",null,{"children":"Left arrow D-Pad"}]]}],["$","tr",null,{"children":[["$","td",null,{"children":"6"}],["$","td",null,{"children":"KEY_UP"}],["$","td",null,{"children":"Up arrow D-Pad"}]]}],["$","tr",null,{"children":[["$","td",null,{"children":"7"}],["$","td",null,{"children":"KEY_DOWN"}],["$","td",null,{"children":"Down arrow D-Pad"}]]}],["$","tr",null,{"children":[["$","td",null,{"children":"8"}],["$","td",null,{"children":"KEY_R"}],["$","td",null,{"children":"Right shoulder button"}]]}],["$","tr",null,{"children":[["$","td",null,{"children":"9"}],["$","td",null,{"children":"KEY_L"}],["$","td",null,{"children":"Left shoulder button"}]]}],["$","tr",null,{"children":[["$","td",null,{"children":"10"}],["$","td",null,{"children":"KEY_X"}],["$","td",null,{"children":"The X button"}]]}],["$","tr",null,{"children":[["$","td",null,{"children":"11"}],["$","td",null,{"children":"KEY_Y"}],["$","td",null,{"children":"The Y button"}]]}],["$","tr",null,{"children":[["$","td",null,{"children":"12"}],["$","td",null,{"children":"KEY_TOUCH"}],["$","td",null,{"children":"Touchscreen pressed"}]]}],["$","tr",null,{"children":[["$","td",null,{"children":"13"}],["$","td",null,{"children":"KEY_LID"}],["$","td",null,{"children":"Lid closed"}]]}]]}]]}],"\n",["$","p",null,{"children":["In the ",["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"REG_KEYCNT"}]}]}]}]," register, bit 14 enables the key button interrupt (i.e. when any button whose ",["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"KEYCNT"}]}]}]}]," bit is set is pressed, it triggers an interrupt). Bit 15 makes it so all buttons whose ",["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"KEYCNT"}]}]}]}]," bits are set need to be pressed at the same time to trigger an interrupt."]}],"\n",["$","p",null,{"children":["To read where the touchscreen is pressed, call ",["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"touchRead(touchPosition* pos)"}]}]}]}]," to write into ",["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"pos"}]}]}]}]," the touchscreen data. ",["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"touchPosition"}]}]}]}]," is defined:"]}],"\n",["$","figure",null,{"data-rehype-pretty-code-figure":"","children":["$","pre",null,{"style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"tabIndex":"0","data-language":"c","data-theme":"github-dark-dimmed github-light","children":["$","code",null,{"data-language":"c","data-theme":"github-dark-dimmed github-light","style":{"display":"grid"},"children":[["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"typedef"}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":" struct"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":" {"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":" u16 rawx;"}],["$","span",null,{"style":{"--shiki-dark":"#768390","--shiki-light":"#6A737D"},"children":" // Raw x value"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":" u16 rawy;"}],["$","span",null,{"style":{"--shiki-dark":"#768390","--shiki-light":"#6A737D"},"children":" // Raw y value"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":" u16 px;"}],["$","span",null,{"style":{"--shiki-dark":"#768390","--shiki-light":"#6A737D"},"children":" // Pixel X value"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":" u16 py;"}],["$","span",null,{"style":{"--shiki-dark":"#768390","--shiki-light":"#6A737D"},"children":" // Pixel Y value"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":" u16 z1;"}],["$","span",null,{"style":{"--shiki-dark":"#768390","--shiki-light":"#6A737D"},"children":" // Raw cross panel resistance"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":" u16 z2;"}],["$","span",null,{"style":{"--shiki-dark":"#768390","--shiki-light":"#6A737D"},"children":" // Raw cross panel resistance"}]]}],"\n",["$","span",null,{"data-line":"","children":["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"}"}]}]]}]}]}],"\n",["$","div",null,{"className":"callout note","children":["$","p",null,{"children":["To draw onto the bottom screen, we need the framebuffer mode, which is only possible on the main 2D engine. To make the bottom screen use the main 2D engine, flip bit 15 in the ",["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"REG_POWERCNT"}]}]}]}]," register."]}]}],"\n",["$","h2",null,{"id":"sound","children":["$","a",null,{"className":"subheading-anchor","aria-label":"Link to section","href":"#sound","children":"Sound"}]}],"\n",["$","p",null,{"children":["$","img",null,{"src":"/velite/nds-audio-map-f2a615.svg","alt":""}]}],"\n",["$","p",null,{"children":"Power on the sound system :"}],"\n",["$","figure",null,{"data-rehype-pretty-code-figure":"","children":["$","pre",null,{"style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"tabIndex":"0","data-language":"c","data-theme":"github-dark-dimmed github-light","children":["$","code",null,{"data-language":"c","data-theme":"github-dark-dimmed github-light","style":{"display":"grid"},"children":["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#DCBDFB","--shiki-light":"#6F42C1"},"children":"powerON"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"(POWER_SOUND);"}]]}]}]}]}],"\n",["$","p",null,{"children":"Set the sound configurations :"}],"\n",["$","figure",null,{"data-rehype-pretty-code-figure":"","children":["$","pre",null,{"style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"tabIndex":"0","data-language":"c","data-theme":"github-dark-dimmed github-light","children":["$","code",null,{"data-language":"c","data-theme":"github-dark-dimmed github-light","style":{"display":"grid"},"children":["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"SOUND_CR "}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"="}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":" SOUND_ENABLE "}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"|"}],["$","span",null,{"style":{"--shiki-dark":"#DCBDFB","--shiki-light":"#6F42C1"},"children":" SOUND_VOL"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"("}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"0x"}],["$","span",null,{"style":{"--shiki-dark":"#6CB6FF","--shiki-light":"#005CC5"},"children":"7F"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":");"}]]}]}]}]}],"\n",["$","p",null,{"children":["The volume goes from ",["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"0x00"}]}]}]}]," (silent) to ",["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"0x7F"}]}]}]}]," (full)."]}],"\n",["$","p",null,{"children":["Each channel can then be configured independently through ",["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"SCHANNEL_CR(n)"}]}]}]}],", and additional properties can be configured using ",["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"SCHANNEL_property(n)"}]}]}]}],"."]}],"\n",["$","div",null,{"className":"callout example","children":["$","figure",null,{"data-rehype-pretty-code-figure":"","children":["$","pre",null,{"style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"tabIndex":"0","data-language":"c","data-theme":"github-dark-dimmed github-light","children":["$","code",null,{"data-language":"c","data-theme":"github-dark-dimmed github-light","style":{"display":"grid"},"children":[["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#DCBDFB","--shiki-light":"#6F42C1"},"children":"SCHANNEL_CR"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"("}],["$","span",null,{"style":{"--shiki-dark":"#6CB6FF","--shiki-light":"#005CC5"},"children":"0"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":") "}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"="}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":" SCHANNEL_ENABLE "}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"|"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":" SOUND_ONE_SHOT"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":" |"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":" SOUND_8BIT;"}]]}],"\n",["$","span",null,{"data-line":"","children":" "}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#DCBDFB","--shiki-light":"#6F42C1"},"children":"SCHANNEL_TIMER"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"("}],["$","span",null,{"style":{"--shiki-dark":"#6CB6FF","--shiki-light":"#005CC5"},"children":"0"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":") "}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"="}],["$","span",null,{"style":{"--shiki-dark":"#DCBDFB","--shiki-light":"#6F42C1"},"children":" SOUND_FREQ"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"("}],["$","span",null,{"style":{"--shiki-dark":"#6CB6FF","--shiki-light":"#005CC5"},"children":"11127"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":");"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#DCBDFB","--shiki-light":"#6F42C1"},"children":"SCHANNEL_SOURCE"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"("}],["$","span",null,{"style":{"--shiki-dark":"#6CB6FF","--shiki-light":"#005CC5"},"children":"0"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":") "}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"="}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":" (uint32)sound1;"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#DCBDFB","--shiki-light":"#6F42C1"},"children":"SCHANNEL_LENGTH"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"("}],["$","span",null,{"style":{"--shiki-dark":"#6CB6FF","--shiki-light":"#005CC5"},"children":"0"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":") "}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"="}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":" (("}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"int"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":")sound1_end "}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"-"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":" ("}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"int"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":")sound) "}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":">>"}],["$","span",null,{"style":{"--shiki-dark":"#6CB6FF","--shiki-light":"#005CC5"},"children":" 2"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":";"}]]}]]}]}]}]}],"\n",["$","p",null,{"children":["We use the ",["$","a",null,{"href":"https://maxmod.org/","rel":"noopener noreferrer","target":"_blank","children":"MaxMod API"}]," to deal with sound. We can use two types of sound: module files (.mod, .s3m, .it or .xm) for background music, and sound effects (.wav) to be played on demand.",["$","br",null,{}],"\n","Sound effects can also be a module sound played only once instead of looping, but this is not recommended. Wav file generate large binaries, so they must be used sparingly."]}],"\n",["$","p",null,{"children":"Some useful ressources :"}],"\n",["$","ul",null,{"children":["\n",["$","li",null,{"children":[["$","a",null,{"href":"https://modarchive.org/index.php","rel":"noopener noreferrer","target":"_blank","children":"The Mod Archive"}]," (music modules)"]}],"\n",["$","li",null,{"children":[["$","a",null,{"href":"https://www.wavsource.com/sfx/sfx.htm","rel":"noopener noreferrer","target":"_blank","children":"WavSource"}]," (wav sounds)"]}],"\n"]}],"\n",["$","p",null,{"children":["$","strong",null,{"children":"Initializing the library pointers to sounds and internal buffers :"}]}],"\n",["$","figure",null,{"data-rehype-pretty-code-figure":"","children":["$","pre",null,{"style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"tabIndex":"0","data-language":"c","data-theme":"github-dark-dimmed github-light","children":["$","code",null,{"data-language":"c","data-theme":"github-dark-dimmed github-light","style":{"display":"grid"},"children":["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"void"}],["$","span",null,{"style":{"--shiki-dark":"#DCBDFB","--shiki-light":"#6F42C1"},"children":" mmInitDefaultMem"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"(mm_addr "}],["$","span",null,{"style":{"--shiki-dark":"#F69D50","--shiki-light":"#E36209"},"children":"soundbank"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":");"}]]}]}]}]}],"\n",["$","p",null,{"children":["The input parameter is the name of the sound-bank binary object (by default it is ",["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"soundbank_bin"}]}]}]}],")."]}],"\n",["$","p",null,{"children":["$","strong",null,{"children":"Load music modules :"}]}],"\n",["$","figure",null,{"data-rehype-pretty-code-figure":"","children":["$","pre",null,{"style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"tabIndex":"0","data-language":"c","data-theme":"github-dark-dimmed github-light","children":["$","code",null,{"data-language":"c","data-theme":"github-dark-dimmed github-light","style":{"display":"grid"},"children":["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"void"}],["$","span",null,{"style":{"--shiki-dark":"#DCBDFB","--shiki-light":"#6F42C1"},"children":" mmLoad"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"(mm_word "}],["$","span",null,{"style":{"--shiki-dark":"#F69D50","--shiki-light":"#E36209"},"children":"module_ID"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":");"}]]}]}]}]}],"\n",["$","p",null,{"children":["The input parameter is the 32-bit index with the module identifier (by default all identifiers are defined in ",["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"soundbank.h"}]}]}]}],")."]}],"\n",["$","p",null,{"children":["$","strong",null,{"children":"Load sound effect :"}]}],"\n",["$","figure",null,{"data-rehype-pretty-code-figure":"","children":["$","pre",null,{"style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"tabIndex":"0","data-language":"c","data-theme":"github-dark-dimmed github-light","children":["$","code",null,{"data-language":"c","data-theme":"github-dark-dimmed github-light","style":{"display":"grid"},"children":["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"void"}],["$","span",null,{"style":{"--shiki-dark":"#DCBDFB","--shiki-light":"#6F42C1"},"children":" mmLoadEffect"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"(mm_word "}],["$","span",null,{"style":{"--shiki-dark":"#F69D50","--shiki-light":"#E36209"},"children":"sample_ID"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":");"}]]}]}]}]}],"\n",["$","p",null,{"children":["The input parameter is the 32-bit sample index with the effect identifier (by default all identifiers are defined in ",["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"soundbank."}]}]}]}],"h)."]}],"\n",["$","p",null,{"children":["$","strong",null,{"children":"Play music :"}]}],"\n",["$","figure",null,{"data-rehype-pretty-code-figure":"","children":["$","pre",null,{"style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"tabIndex":"0","data-language":"c","data-theme":"github-dark-dimmed github-light","children":["$","code",null,{"data-language":"c","data-theme":"github-dark-dimmed github-light","style":{"display":"grid"},"children":["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"void"}],["$","span",null,{"style":{"--shiki-dark":"#DCBDFB","--shiki-light":"#6F42C1"},"children":" mmStart"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"(mm_word "}],["$","span",null,{"style":{"--shiki-dark":"#F69D50","--shiki-light":"#E36209"},"children":"module_ID"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":", mm_pmode "}],["$","span",null,{"style":{"--shiki-dark":"#F69D50","--shiki-light":"#E36209"},"children":"mode"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":");"}]]}]}]}]}],"\n",["$","p",null,{"children":["The first input parameter is the module identifier. The second parameter specifies whether the music has to be played once (",["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"MM_PLAY_ONCE"}]}]}]}],") or in an infinite loop (",["$","span",null,{"data-rehype-pretty-code-figure":"","children":["$","code",null,{"data-language":"plaintext","data-theme":"github-dark-dimmed github-light","style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"children":["$","span",null,{"data-line":"","children":["$","span",null,{"children":"MM_PLAY_LOOP"}]}]}]}],")"]}],"\n",["$","p",null,{"children":["$","strong",null,{"children":"Pause, resume or stop music :"}]}],"\n",["$","figure",null,{"data-rehype-pretty-code-figure":"","children":["$","pre",null,{"style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"tabIndex":"0","data-language":"c","data-theme":"github-dark-dimmed github-light","children":["$","code",null,{"data-language":"c","data-theme":"github-dark-dimmed github-light","style":{"display":"grid"},"children":[["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"void"}],["$","span",null,{"style":{"--shiki-dark":"#DCBDFB","--shiki-light":"#6F42C1"},"children":" mmPause"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"();"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"void"}],["$","span",null,{"style":{"--shiki-dark":"#DCBDFB","--shiki-light":"#6F42C1"},"children":" mmResume"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"();"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"void"}],["$","span",null,{"style":{"--shiki-dark":"#DCBDFB","--shiki-light":"#6F42C1"},"children":" mmStop"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"();"}]]}]]}]}]}],"\n",["$","p",null,{"children":["$","strong",null,{"children":"Play sound effect :"}]}],"\n",["$","figure",null,{"data-rehype-pretty-code-figure":"","children":["$","pre",null,{"style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"tabIndex":"0","data-language":"c","data-theme":"github-dark-dimmed github-light","children":["$","code",null,{"data-language":"c","data-theme":"github-dark-dimmed github-light","style":{"display":"grid"},"children":["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"mm_sfxhand "}],["$","span",null,{"style":{"--shiki-dark":"#DCBDFB","--shiki-light":"#6F42C1"},"children":"mmEffect"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"(mm_word "}],["$","span",null,{"style":{"--shiki-dark":"#F69D50","--shiki-light":"#E36209"},"children":"sample_ID"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":");"}]]}]}]}]}],"\n",["$","p",null,{"children":"The input parameter specifies sound effect identifier of effect to play. The effect will be played without modifying the sound configuration."}],"\n",["$","p",null,{"children":["$","strong",null,{"children":"Play sound effect with specific sound configuration :"}]}],"\n",["$","figure",null,{"data-rehype-pretty-code-figure":"","children":["$","pre",null,{"style":{"--shiki-dark":"#adbac7","--shiki-light":"#24292e","--shiki-dark-bg":"#22272e","--shiki-light-bg":"#fff"},"tabIndex":"0","data-language":"c","data-theme":"github-dark-dimmed github-light","children":["$","code",null,{"data-language":"c","data-theme":"github-dark-dimmed github-light","style":{"display":"grid"},"children":["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"mm_sfxhand "}],["$","span",null,{"style":{"--shiki-dark":"#DCBDFB","--shiki-light":"#6F42C1"},"children":"mmEffectEx"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":"(mm_sound_effect"}],["$","span",null,{"style":{"--shiki-dark":"#F47067","--shiki-light":"#D73A49"},"children":"*"}],["$","span",null,{"style":{"--shiki-dark":"#F69D50","--shiki-light":"#E36209"},"children":" sound"}],["$","span",null,{"style":{"--shiki-dark":"#ADBAC7","--shiki-light":"#24292E"},"children":");"}]]}]}]}]}],"\n",["$","p",null,{"children":"The input parameter is a structure with the effect identifier (id) and three main parameters: Volume, Panning, and Rate (frequency)."}]]]}] 8:[["$","meta","0",{"name":"viewport","content":"width=device-width, initial-scale=1"}],["$","meta","1",{"charSet":"utf-8"}],["$","title","2",{"children":"LibNDS Quick Docs | Sidonie's Website"}],["$","meta","3",{"name":"description","content":"Simplified LibNDS documentation. Written for the EE-310 Course @ EPFL"}],["$","meta","4",{"name":"author","content":"Sidonie Bouthors"}],["$","link","5",{"rel":"shortcut icon","href":"/_next/static/media/favicon.dce2379b.ico"}],["$","link","6",{"rel":"icon","href":"/_next/static/media/favicon.dce2379b.ico"}]] 1:null