diff --git a/book/src-bak/SUMMARY.md b/book/src-bak/SUMMARY.md new file mode 100644 index 0000000..a177f06 --- /dev/null +++ b/book/src-bak/SUMMARY.md @@ -0,0 +1,23 @@ + +# Rust GBA Tutorials + +* [Introduction](introduction.md) +* [Ch 0: Development Setup](ch00/index.md) +* [Ch 1: Hello GBA](ch01/index.md) + * [hello1](ch01/hello1.md) + * [Volatile](ch01/volatile.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) + * [GBA Memory Mapping](ch03/gba_memory_mapping.md) + * [Tile Data](ch03/tile_data.md) + * [Regular Backgrounds](ch03/regular_backgrounds.md) + * [Regular Objects](ch03/regular_objects.md) + * [GBA PRNG](ch03/gba_prng.md) + * [memory_game](ch03/memory_game.md) diff --git a/book/src/ch00/index.md b/book/src-bak/ch00/index.md similarity index 100% rename from book/src/ch00/index.md rename to book/src-bak/ch00/index.md diff --git a/book/src/ch01/hello1.md b/book/src-bak/ch01/hello1.md similarity index 100% rename from book/src/ch01/hello1.md rename to book/src-bak/ch01/hello1.md diff --git a/book/src/ch01/hello2.md b/book/src-bak/ch01/hello2.md similarity index 100% rename from book/src/ch01/hello2.md rename to book/src-bak/ch01/hello2.md diff --git a/book/src/ch01/index.md b/book/src-bak/ch01/index.md similarity index 100% rename from book/src/ch01/index.md rename to book/src-bak/ch01/index.md diff --git a/book/src/ch01/io_registers.md b/book/src-bak/ch01/io_registers.md similarity index 100% rename from book/src/ch01/io_registers.md rename to book/src-bak/ch01/io_registers.md diff --git a/book/src/ch01/the_display_control_register.md b/book/src-bak/ch01/the_display_control_register.md similarity index 100% rename from book/src/ch01/the_display_control_register.md rename to book/src-bak/ch01/the_display_control_register.md diff --git a/book/src/ch01/video_memory_intro.md b/book/src-bak/ch01/video_memory_intro.md similarity index 100% rename from book/src/ch01/video_memory_intro.md rename to book/src-bak/ch01/video_memory_intro.md diff --git a/book/src/ch01/volatile.md b/book/src-bak/ch01/volatile.md similarity index 100% rename from book/src/ch01/volatile.md rename to book/src-bak/ch01/volatile.md diff --git a/book/src/ch02/index.md b/book/src-bak/ch02/index.md similarity index 100% rename from book/src/ch02/index.md rename to book/src-bak/ch02/index.md diff --git a/book/src/ch02/light_cycle.md b/book/src-bak/ch02/light_cycle.md similarity index 100% rename from book/src/ch02/light_cycle.md rename to book/src-bak/ch02/light_cycle.md diff --git a/book/src/ch02/the_key_input_register.md b/book/src-bak/ch02/the_key_input_register.md similarity index 100% rename from book/src/ch02/the_key_input_register.md rename to book/src-bak/ch02/the_key_input_register.md diff --git a/book/src/ch02/the_vcount_register.md b/book/src-bak/ch02/the_vcount_register.md similarity index 100% rename from book/src/ch02/the_vcount_register.md rename to book/src-bak/ch02/the_vcount_register.md diff --git a/book/src/ch03/gba_memory_mapping.md b/book/src-bak/ch03/gba_memory_mapping.md similarity index 100% rename from book/src/ch03/gba_memory_mapping.md rename to book/src-bak/ch03/gba_memory_mapping.md diff --git a/book/src/ch03/gba_prng.md b/book/src-bak/ch03/gba_prng.md similarity index 100% rename from book/src/ch03/gba_prng.md rename to book/src-bak/ch03/gba_prng.md diff --git a/book/src/ch03/index.md b/book/src-bak/ch03/index.md similarity index 100% rename from book/src/ch03/index.md rename to book/src-bak/ch03/index.md diff --git a/book/src/ch03/memory_game.md b/book/src-bak/ch03/memory_game.md similarity index 97% rename from book/src/ch03/memory_game.md rename to book/src-bak/ch03/memory_game.md index 0bb11af..3e65170 100644 --- a/book/src/ch03/memory_game.md +++ b/book/src-bak/ch03/memory_game.md @@ -183,7 +183,7 @@ pub struct RegularScreenblockEntry(u16); impl RegularScreenblockEntry { pub const SCREENBLOCK_ENTRY_TILE_ID_MASK: u16 = 0b11_1111_1111; - pub fn from_tile_id(id: u16) -> Self { + pub const fn from_tile_id(id: u16) -> Self { RegularScreenblockEntry(id & Self::SCREENBLOCK_ENTRY_TILE_ID_MASK) } } @@ -243,8 +243,9 @@ the "screen base block" value. pub struct BackgroundControlSetting(u16); impl BackgroundControlSetting { - pub fn from_base_block(sbb: u16) -> Self { - BackgroundControlSetting(sbb << 8) + pub const SCREEN_BASE_BLOCK_MASK: u16 = 0b1_1111; + pub const fn from_base_block(sbb: u16) -> Self { + BackgroundControlSetting((sbb & Self::SCREEN_BASE_BLOCK_MASK) << 8) } } diff --git a/book/src/ch03/obj_memory_2d1d.jpg b/book/src-bak/ch03/obj_memory_2d1d.jpg similarity index 100% rename from book/src/ch03/obj_memory_2d1d.jpg rename to book/src-bak/ch03/obj_memory_2d1d.jpg diff --git a/book/src/ch03/regular_backgrounds.md b/book/src-bak/ch03/regular_backgrounds.md similarity index 100% rename from book/src/ch03/regular_backgrounds.md rename to book/src-bak/ch03/regular_backgrounds.md diff --git a/book/src/ch03/regular_objects.md b/book/src-bak/ch03/regular_objects.md similarity index 100% rename from book/src/ch03/regular_objects.md rename to book/src-bak/ch03/regular_objects.md diff --git a/book/src/ch03/screenshot_checkers.png b/book/src-bak/ch03/screenshot_checkers.png similarity index 100% rename from book/src/ch03/screenshot_checkers.png rename to book/src-bak/ch03/screenshot_checkers.png diff --git a/book/src/ch03/tile_data.md b/book/src-bak/ch03/tile_data.md similarity index 100% rename from book/src/ch03/tile_data.md rename to book/src-bak/ch03/tile_data.md diff --git a/book/src/introduction.md b/book/src-bak/introduction.md similarity index 100% rename from book/src/introduction.md rename to book/src-bak/introduction.md diff --git a/book/src/SUMMARY.md b/book/src/SUMMARY.md index a177f06..1847cab 100644 --- a/book/src/SUMMARY.md +++ b/book/src/SUMMARY.md @@ -1,23 +1,34 @@ -# Rust GBA Tutorials - -* [Introduction](introduction.md) -* [Ch 0: Development Setup](ch00/index.md) -* [Ch 1: Hello GBA](ch01/index.md) - * [hello1](ch01/hello1.md) - * [Volatile](ch01/volatile.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) - * [GBA Memory Mapping](ch03/gba_memory_mapping.md) - * [Tile Data](ch03/tile_data.md) - * [Regular Backgrounds](ch03/regular_backgrounds.md) - * [Regular Objects](ch03/regular_objects.md) - * [GBA PRNG](ch03/gba_prng.md) - * [memory_game](ch03/memory_game.md) +* Introduction + * Goals Of This Book + * Prerequisites + * Getting Outside Help + * Development Setup + * Hello Magic + * Volatile + * Core Only +* Broad Concepts + * BIOS + * Working RAM + * IO Registers + * Palette RAM + * Video RAM + * Object Attribute Memory + * Game Pak ROM / Flash ROM + * Save RAM +* Video Modes + * RBG15 Color + * Bitmap Modes + * Tiled Modes + * Affine Math + * Special Effects +* Non-Video Hardware + * Buttons + * Timers + * Direct Memory Access + * Sound + * Interrupts + * Network + * Game Pak +* Examples + * for example in example_list diff --git a/examples/memory_game.rs b/examples/memory_game.rs index 9ccb037..c18a00c 100644 --- a/examples/memory_game.rs +++ b/examples/memory_game.rs @@ -107,7 +107,7 @@ pub struct RegularScreenblockEntry(u16); impl RegularScreenblockEntry { pub const SCREENBLOCK_ENTRY_TILE_ID_MASK: u16 = 0b11_1111_1111; - pub fn from_tile_id(id: u16) -> Self { + pub const fn from_tile_id(id: u16) -> Self { RegularScreenblockEntry(id & Self::SCREENBLOCK_ENTRY_TILE_ID_MASK) } } @@ -136,8 +136,9 @@ pub fn checker_screenblock(slot: usize, a_entry: RegularScreenblockEntry, b_entr pub struct BackgroundControlSetting(u16); impl BackgroundControlSetting { - pub fn from_base_block(sbb: u16) -> Self { - BackgroundControlSetting(sbb << 8) + pub const SCREEN_BASE_BLOCK_MASK: u16 = 0b1_1111; + pub const fn from_base_block(sbb: u16) -> Self { + BackgroundControlSetting((sbb & Self::SCREEN_BASE_BLOCK_MASK) << 8) } }