From f81e350f619a25620474fe4766df07380c11c127 Mon Sep 17 00:00:00 2001 From: Lokathor Date: Wed, 14 Nov 2018 19:53:21 -0700 Subject: [PATCH] book chapter directory rename (we'll get 10+ chapters) --- book/src/SUMMARY.md | 23 ++- book/src/{ch0 => ch00}/index.md | 0 book/src/{ch1 => ch01}/hello1.md | 0 book/src/{ch1 => ch01}/hello2.md | 5 +- book/src/{ch1 => ch01}/index.md | 0 book/src/{ch1 => ch01}/io_registers.md | 0 .../the_display_control_register.md | 0 book/src/{ch1 => ch01}/video_memory_intro.md | 0 book/src/{ch2 => ch02}/index.md | 0 book/src/{ch2 => ch02}/light_cycle.md | 20 +- .../{ch2 => ch02}/the_key_input_register.md | 6 +- book/src/{ch2 => ch02}/the_vcount_register.md | 0 book/src/ch03/index.md | 1 + docs/{ch0 => ch00}/index.html | 6 +- docs/{ch1 => ch01}/hello1.html | 10 +- docs/{ch1 => ch01}/hello2.html | 15 +- docs/{ch1 => ch01}/index.html | 10 +- docs/{ch1 => ch01}/io_registers.html | 10 +- .../the_display_control_register.html | 10 +- docs/{ch1 => ch01}/video_memory_intro.html | 10 +- docs/{ch2 => ch02}/index.html | 10 +- docs/{ch2 => ch02}/light_cycle.html | 30 ++- .../{ch2 => ch02}/the_key_input_register.html | 16 +- docs/{ch2 => ch02}/the_vcount_register.html | 10 +- docs/ch03/index.html | 192 ++++++++++++++++++ docs/index.html | 2 +- docs/introduction.html | 6 +- docs/print.html | 30 ++- docs/searchindex.js | 2 +- docs/searchindex.json | 2 +- 30 files changed, 339 insertions(+), 87 deletions(-) rename book/src/{ch0 => ch00}/index.md (100%) rename book/src/{ch1 => ch01}/hello1.md (100%) rename book/src/{ch1 => ch01}/hello2.md (94%) rename book/src/{ch1 => ch01}/index.md (100%) rename book/src/{ch1 => ch01}/io_registers.md (100%) rename book/src/{ch1 => ch01}/the_display_control_register.md (100%) rename book/src/{ch1 => ch01}/video_memory_intro.md (100%) rename book/src/{ch2 => ch02}/index.md (100%) rename book/src/{ch2 => ch02}/light_cycle.md (81%) rename book/src/{ch2 => ch02}/the_key_input_register.md (96%) rename book/src/{ch2 => ch02}/the_vcount_register.md (100%) create mode 100644 book/src/ch03/index.md rename docs/{ch0 => ch00}/index.html (91%) rename docs/{ch1 => ch01}/hello1.html (89%) rename docs/{ch1 => ch01}/hello2.html (84%) rename docs/{ch1 => ch01}/index.html (82%) rename docs/{ch1 => ch01}/io_registers.html (83%) rename docs/{ch1 => ch01}/the_display_control_register.html (87%) rename docs/{ch1 => ch01}/video_memory_intro.html (87%) rename docs/{ch2 => ch02}/index.html (83%) rename docs/{ch2 => ch02}/light_cycle.html (79%) rename docs/{ch2 => ch02}/the_key_input_register.html (88%) rename docs/{ch2 => ch02}/the_vcount_register.html (85%) create mode 100644 docs/ch03/index.html diff --git a/book/src/SUMMARY.md b/book/src/SUMMARY.md index 6b3fee5..1bef5fd 100644 --- a/book/src/SUMMARY.md +++ b/book/src/SUMMARY.md @@ -2,14 +2,15 @@ # Rust GBA Tutorials * [Introduction](introduction.md) -* [Ch 0: Development Setup](ch0/index.md) -* [Ch 1: Hello GBA](ch1/index.md) - * [hello1](ch1/hello1.md) - * [IO Registers](ch1/io_registers.md) - * [The Display Control Register](ch1/the_display_control_register.md) - * [Video Memory Intro](ch1/video_memory_intro.md) - * [hello2](ch1/hello2.md) -* [Ch 2: User Input](ch2/index.md) - * [The Key Input Register](ch2/the_key_input_register.md) - * [The VCount Register](ch2/the_vcount_register.md) - * [light_cycle](ch2/light_cycle.md) +* [Ch 0: Development Setup](ch00/index.md) +* [Ch 1: Hello GBA](ch01/index.md) + * [hello1](ch01/hello1.md) + * [IO Registers](ch01/io_registers.md) + * [The Display Control Register](ch01/the_display_control_register.md) + * [Video Memory Intro](ch01/video_memory_intro.md) + * [hello2](ch01/hello2.md) +* [Ch 2: User Input](ch02/index.md) + * [The Key Input Register](ch02/the_key_input_register.md) + * [The VCount Register](ch02/the_vcount_register.md) + * [light_cycle](ch02/light_cycle.md) +* [Ch 3: Memory and Objects](ch03/index.md) diff --git a/book/src/ch0/index.md b/book/src/ch00/index.md similarity index 100% rename from book/src/ch0/index.md rename to book/src/ch00/index.md diff --git a/book/src/ch1/hello1.md b/book/src/ch01/hello1.md similarity index 100% rename from book/src/ch1/hello1.md rename to book/src/ch01/hello1.md diff --git a/book/src/ch1/hello2.md b/book/src/ch01/hello2.md similarity index 94% rename from book/src/ch1/hello2.md rename to book/src/ch01/hello2.md index 1273a69..23c413b 100644 --- a/book/src/ch1/hello2.md +++ b/book/src/ch01/hello2.md @@ -110,5 +110,6 @@ pub unsafe fn mode3_pixel(col: isize, row: isize, color: u16) { Exact same program that we started with, but much easier to read. Of course, in the full `gba` crate that this book is a part of we have these and -other elements all labeled and sorted out for you. Still, for educational -purposes it's often best to do it yourself at least once. +other elements all labeled and sorted out for you (not identically, but +similarly). Still, for educational purposes it's often best to do it yourself at +least once. diff --git a/book/src/ch1/index.md b/book/src/ch01/index.md similarity index 100% rename from book/src/ch1/index.md rename to book/src/ch01/index.md diff --git a/book/src/ch1/io_registers.md b/book/src/ch01/io_registers.md similarity index 100% rename from book/src/ch1/io_registers.md rename to book/src/ch01/io_registers.md diff --git a/book/src/ch1/the_display_control_register.md b/book/src/ch01/the_display_control_register.md similarity index 100% rename from book/src/ch1/the_display_control_register.md rename to book/src/ch01/the_display_control_register.md diff --git a/book/src/ch1/video_memory_intro.md b/book/src/ch01/video_memory_intro.md similarity index 100% rename from book/src/ch1/video_memory_intro.md rename to book/src/ch01/video_memory_intro.md diff --git a/book/src/ch2/index.md b/book/src/ch02/index.md similarity index 100% rename from book/src/ch2/index.md rename to book/src/ch02/index.md diff --git a/book/src/ch2/light_cycle.md b/book/src/ch02/light_cycle.md similarity index 81% rename from book/src/ch2/light_cycle.md rename to book/src/ch02/light_cycle.md index 79ee4d6..f2e031a 100644 --- a/book/src/ch2/light_cycle.md +++ b/book/src/ch02/light_cycle.md @@ -113,7 +113,23 @@ it's not black that means we've been here before and the player has crashed into their own line. In this case, we reset the game without moving them to a new location. -Finally, if the player is in bounds and they haven't crashed, we write their color into memory at this position. +Finally, if the player is in bounds and they haven't crashed, we write their +color into memory at this position. Regardless of how it worked out, we hold here until vdraw starts before going to -the next loop. +the next loop. That's all there is to it. + +## The gba crate doesn't quite work like this + +Once again, as with the `hello1` and `hello2` examples, the `gba` crate covers +much of this same ground as our example here, but in slightly different ways. + +Better organization and abstractions are usually only realized once you've used +more of the whole thing you're trying to work with. If we want to have a crate +where the whole thing is well integrated with itself, then the examples would +also end up having to explain about things we haven't really touched on much +yet. It becomes a lot harder to teach. + +So, going forward, we will continue to teach concepts and build examples that +don't directly depend on the `gba` crate. This allows the crate to freely grow +without all the past examples becoming a great inertia upon it. \ No newline at end of file diff --git a/book/src/ch2/the_key_input_register.md b/book/src/ch02/the_key_input_register.md similarity index 96% rename from book/src/ch2/the_key_input_register.md rename to book/src/ch02/the_key_input_register.md index 656ae1e..16bf6fa 100644 --- a/book/src/ch2/the_key_input_register.md +++ b/book/src/ch02/the_key_input_register.md @@ -93,11 +93,13 @@ folded and refolded by the compiler, but we can just check. It turns out that the `!=0` test is 4 instructions and the `==0` test is 6 instructions. Since we want to get savings where we can, and we'll probably check the keys of an input often enough, we'll just always use a `!=0` test and -then adjust how we initially read the register to compensate. +then adjust how we initially read the register to compensate. By using xor with +a mask for only the 10 used bits we can flip the "low when pressed" values so +that the entire result has active bits in all positions where a key is pressed. ```rust pub fn read_key_input() -> KeyInputSetting { - unsafe { KeyInputSetting(KEYINPUT.read_volatile() ^ 0b1111_1111_1111_1111) } + unsafe { KeyInputSetting(KEYINPUT.read_volatile() ^ 0b0000_0011_1111_1111) } } ``` diff --git a/book/src/ch2/the_vcount_register.md b/book/src/ch02/the_vcount_register.md similarity index 100% rename from book/src/ch2/the_vcount_register.md rename to book/src/ch02/the_vcount_register.md diff --git a/book/src/ch03/index.md b/book/src/ch03/index.md new file mode 100644 index 0000000..d2dfbd8 --- /dev/null +++ b/book/src/ch03/index.md @@ -0,0 +1 @@ +# Ch 3: Memory and Objects diff --git a/docs/ch0/index.html b/docs/ch00/index.html similarity index 91% rename from docs/ch0/index.html rename to docs/ch00/index.html index 98f151a..a06e96c 100644 --- a/docs/ch0/index.html +++ b/docs/ch00/index.html @@ -72,7 +72,7 @@
@@ -288,7 +288,7 @@ ROM is patched in place, so we don't even need to specify a new destination. + @@ -306,7 +306,7 @@ ROM is patched in place, so we don't even need to specify a new destination. + diff --git a/docs/ch1/hello1.html b/docs/ch01/hello1.html similarity index 89% rename from docs/ch1/hello1.html rename to docs/ch01/hello1.html index be878c3..258b519 100644 --- a/docs/ch1/hello1.html +++ b/docs/ch01/hello1.html @@ -72,7 +72,7 @@
@@ -311,13 +311,13 @@ safety concerns.