{"doc_urls":["introduction.html#introduction","introduction.html#other-works","ch0/index.html#chapter-0-development-setup","ch0/index.html#per-system-setup","ch0/index.html#per-project-setup","ch0/index.html#compiling","ch1/index.html#ch-1-hello-gba","ch1/hello1.html#hello1","ch1/hello1.html#explaining-hello1","ch1/hello1.html#all-those-magic-numbers","ch1/hello1.html#sidebar-volatile","ch1/io_registers.html#io-registers","ch1/the_display_control.html#the-display-control","ch1/the_display_control.html#video-modes","ch1/the_display_control.html#cgb-mode","ch1/the_display_control.html#page-flipping","ch1/the_display_control.html#oam-vram-and-blanking","ch1/the_display_control.html#screen-layers","ch1/the_display_control.html#in-conclusion","ch1/video_memory_intro.html#video-memory-intro","ch1/video_memory_intro.html#rgb15","ch1/video_memory_intro.html#mode-3","ch1/video_memory_intro.html#mode-4","ch1/video_memory_intro.html#mode-5","ch1/video_memory_intro.html#in-conclusion","ch1/hello2.html#hello2"],"index":{"documentStore":{"docInfo":{"0":{"body":16,"breadcrumbs":1,"title":1},"1":{"body":30,"breadcrumbs":1,"title":1},"10":{"body":168,"breadcrumbs":6,"title":2},"11":{"body":143,"breadcrumbs":6,"title":2},"12":{"body":49,"breadcrumbs":6,"title":2},"13":{"body":174,"breadcrumbs":6,"title":2},"14":{"body":24,"breadcrumbs":6,"title":2},"15":{"body":32,"breadcrumbs":6,"title":2},"16":{"body":57,"breadcrumbs":7,"title":3},"17":{"body":54,"breadcrumbs":6,"title":2},"18":{"body":29,"breadcrumbs":5,"title":1},"19":{"body":88,"breadcrumbs":7,"title":3},"2":{"body":20,"breadcrumbs":4,"title":4},"20":{"body":47,"breadcrumbs":5,"title":1},"21":{"body":41,"breadcrumbs":6,"title":2},"22":{"body":211,"breadcrumbs":6,"title":2},"23":{"body":25,"breadcrumbs":6,"title":2},"24":{"body":47,"breadcrumbs":5,"title":1},"25":{"body":276,"breadcrumbs":5,"title":1},"3":{"body":106,"breadcrumbs":3,"title":3},"4":{"body":93,"breadcrumbs":3,"title":3},"5":{"body":385,"breadcrumbs":1,"title":1},"6":{"body":39,"breadcrumbs":4,"title":4},"7":{"body":83,"breadcrumbs":5,"title":1},"8":{"body":245,"breadcrumbs":6,"title":2},"9":{"body":55,"breadcrumbs":7,"title":3}},"docs":{"0":{"body":"Here's a book that'll help you program in Rust on the GBA. It's very \"work in progress\". At the moment there's only one demo program.","breadcrumbs":"Introduction","id":"0","title":"Introduction"},"1":{"body":"If you want to read more about developing on the GBA there are some other good resources as well: Tonc , a tutorial series written for C, but it's what I based the ordering of this book's sections on. GBATEK , a homebrew tech manual for GBA/NDS/DSi. We will regularly link to parts of it when talking about various bits of the GBA.","breadcrumbs":"Other Works","id":"1","title":"Other Works"},"10":{"body":"We'll get into what all that is in a moment, but first let's ask ourselves: Why are we doing volatile writes? You've probably never used it before at all. What is volatile anyway? Well, the optimizer is pretty aggressive some of the time, and so it'll skip reads and writes when it thinks can. Like if you write to a pointer once, and then again a moment later, and it didn't see any other reads in between, it'll think that it can just skip doing that first write since it'll get overwritten anyway. Sometimes that's right, but sometimes it's wrong. Marking a read or write as volatile tells the compiler that it really must do that action, and in the exact order that we wrote it out. It says that there might even be special hardware side effects going on that the compiler isn't aware of. In this case, the Display Control write sets a video mode, and the Video RAM writes set pixels that will show up on the screen. Similar to \"atomic\"operationsyoumighthaveheardabout,allvolatileoperationsareenforcedtohappenintheexactorderthatyouspecifythem,butonlyrelativetoothervolatileoperations.Sosomethinglikec.volatile_write(5);\na+=b;\nd.volatile_write(7);mightendupchangingaeitherbeforeorafterthechangetoc,butthewritetodwillalwaysha