From 85671edd4f7ea7e286335d9603e7097a501777f2 Mon Sep 17 00:00:00 2001 From: Corwin Date: Sat, 13 Jan 2024 10:05:04 +0000 Subject: [PATCH 1/7] add projects to workspace --- .vscode/agb.code-workspace | 102 ++++++++++++++++++++----------------- 1 file changed, 54 insertions(+), 48 deletions(-) diff --git a/.vscode/agb.code-workspace b/.vscode/agb.code-workspace index b0575aac..364dee24 100644 --- a/.vscode/agb.code-workspace +++ b/.vscode/agb.code-workspace @@ -1,49 +1,55 @@ { - "folders": [ - { - "path": "../agb" - }, - { - "path": "../agb-sound-converter" - }, - { - "path": "../agb-macros" - }, - { - "path": "../agb-image-converter" - }, - { - "path": "../agb-fixnum" - }, - { - "path": "../examples/the-purple-night" - }, - { - "path": "../examples/the-hat-chooses-the-wizard" - }, - { - "path": "../examples/hyperspace-roll" - }, - { - "path": "../.github" - }, - { - "path": "../template" - }, - { - "path": "../book" - }, - { - "path": "../mgba-test-runner" - }, - { - "path": "../tools" - }, - { - "path": "../examples/combo" - }, - { - "path": "../agb-hashmap" - } - ] -} \ No newline at end of file + "folders": [ + { + "path": "../agb" + }, + { + "path": "../agb-sound-converter" + }, + { + "path": "../agb-macros" + }, + { + "path": "../agb-image-converter" + }, + { + "path": "../agb-fixnum" + }, + { + "path": "../examples/the-purple-night" + }, + { + "path": "../examples/the-hat-chooses-the-wizard" + }, + { + "path": "../examples/hyperspace-roll" + }, + { + "path": "../.github" + }, + { + "path": "../template" + }, + { + "path": "../book" + }, + { + "path": "../mgba-test-runner" + }, + { + "path": "../tools" + }, + { + "path": "../examples/combo" + }, + { + "path": "../agb-hashmap" + }, + { + "path": "../examples/amplitude" + }, + { + "path": "../examples/the-dungeon-puzzlers-lament" + } + ] +} From 5e711ebb5f9f6eab0330b785ce7324af217b0514 Mon Sep 17 00:00:00 2001 From: Corwin Date: Sat, 13 Jan 2024 10:06:12 +0000 Subject: [PATCH 2/7] use latest nightly --- .github/workflows/build-and-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index cb1d1f4a..2cbb9fa7 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -10,7 +10,7 @@ on: env: CARGO_TERM_COLOR: always - RUSTUP_TOOLCHAIN: ${{ !github.event.schedule && 'nightly-2023-12-01' || 'nightly' }} + # RUSTUP_TOOLCHAIN: ${{ !github.event.schedule && 'nightly-2023-12-01' || 'nightly' }} jobs: build: From 1132bc23833bc369f6a884c0dcef8bb7b0dd81d3 Mon Sep 17 00:00:00 2001 From: Corwin Date: Sat, 13 Jan 2024 10:30:44 +0000 Subject: [PATCH 3/7] use addr_of_mut rather than mut reference --- agb/src/lib.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/agb/src/lib.rs b/agb/src/lib.rs index d44a227e..305ca5ba 100644 --- a/agb/src/lib.rs +++ b/agb/src/lib.rs @@ -387,6 +387,8 @@ pub(crate) fn program_counter_before_interrupt() -> u32 { #[cfg(test)] mod test { + use core::ptr::addr_of_mut; + use super::Gba; #[test_case] @@ -415,11 +417,11 @@ mod test { } #[link_section = ".ewram"] - static mut EWRAM_TEST: u32 = 5; + static mut EWART_TEST: u32 = 5; #[test_case] fn ewram_static_test(_gba: &mut Gba) { unsafe { - let ewram_ptr = &mut EWRAM_TEST as *mut u32; + let ewram_ptr = addr_of_mut!(EWART_TEST); let content = ewram_ptr.read_volatile(); assert_eq!(content, 5, "expected data in ewram to be 5"); ewram_ptr.write_volatile(content + 1); @@ -438,7 +440,7 @@ mod test { #[test_case] fn iwram_explicit_test(_gba: &mut Gba) { unsafe { - let iwram_ptr = &mut IWRAM_EXPLICIT as *mut u32; + let iwram_ptr = addr_of_mut!(IWRAM_EXPLICIT); let address = iwram_ptr as usize; assert!( (0x0300_0000..0x0300_8000).contains(&address), @@ -456,7 +458,7 @@ mod test { #[test_case] fn implicit_data_test(_gba: &mut Gba) { unsafe { - let iwram_ptr = &mut IMPLICIT_STORAGE as *mut u32; + let iwram_ptr = addr_of_mut!(IMPLICIT_STORAGE); let address = iwram_ptr as usize; assert!( (0x0200_0000..0x0204_0000).contains(&address), From e13d844f1f367f9113ea632c3ea2401e0a91c967 Mon Sep 17 00:00:00 2001 From: Corwin Date: Sat, 13 Jan 2024 10:31:00 +0000 Subject: [PATCH 4/7] use cloned rather than a map that clones --- agb/src/save/flash.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/agb/src/save/flash.rs b/agb/src/save/flash.rs index b160048a..08b55a38 100644 --- a/agb/src/save/flash.rs +++ b/agb/src/save/flash.rs @@ -243,7 +243,7 @@ static CHIP_INFO: InitOnce<&'static ChipInfo> = InitOnce::new(); fn cached_chip_info() -> Result<&'static ChipInfo, Error> { CHIP_INFO .try_get(|| -> Result<_, Error> { Ok(FlashChipType::detect()?.chip_info()) }) - .map(Clone::clone) + .cloned() } /// Actual implementation of the ChipInfo functions. From 3840c4ce800e33d9e1ad5cf325ed90d5433059c7 Mon Sep 17 00:00:00 2001 From: Corwin Date: Sat, 13 Jan 2024 10:31:09 +0000 Subject: [PATCH 5/7] remove unused enum parameter --- examples/amplitude/src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/amplitude/src/lib.rs b/examples/amplitude/src/lib.rs index ccff7f21..7da2c938 100644 --- a/examples/amplitude/src/lib.rs +++ b/examples/amplitude/src/lib.rs @@ -186,7 +186,7 @@ struct Game { enum GameState { Continue, - Loss(u32), + Loss, } impl Game { @@ -314,7 +314,7 @@ impl Game { || (self.head_position.y + 1).floor() > display::HEIGHT + 4; if saw_has_hit_head || out_of_bounds_death { - GameState::Loss(self.alive_frames) + GameState::Loss } else { GameState::Continue } @@ -443,7 +443,7 @@ pub fn main(mut gba: agb::Gba) -> ! { game.render(oam_frame, &sprite_cache); - if let GameState::Loss(_) = state { + if matches!(state, GameState::Loss) { for _ in 0..30 { vblank.wait_for_vblank(); } From 8e367ab6b64b865ee1f931cb86930d86bbe9dbdb Mon Sep 17 00:00:00 2001 From: Corwin Date: Sat, 13 Jan 2024 10:31:33 +0000 Subject: [PATCH 6/7] allow dead code of an enum parameter only used in a debug print --- .../the-dungeon-puzzlers-lament/src/game/simulation/entity.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/examples/the-dungeon-puzzlers-lament/src/game/simulation/entity.rs b/examples/the-dungeon-puzzlers-lament/src/game/simulation/entity.rs index c8248890..c128692d 100644 --- a/examples/the-dungeon-puzzlers-lament/src/game/simulation/entity.rs +++ b/examples/the-dungeon-puzzlers-lament/src/game/simulation/entity.rs @@ -1074,6 +1074,9 @@ mod tests { } #[derive(Debug)] + // allow dead code because field is unused apart from in a debug string, + // which is what we want to use it for. + #[allow(dead_code)] enum CompleteSimulationResult { Success, ExplicitLoss, From e35bfd063648aeaa42345ef520c33db6fd3864a7 Mon Sep 17 00:00:00 2001 From: Corwin Date: Sat, 13 Jan 2024 10:36:10 +0000 Subject: [PATCH 7/7] use nightly explicitly --- .github/workflows/build-and-test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 2cbb9fa7..fca46186 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -11,6 +11,7 @@ on: env: CARGO_TERM_COLOR: always # RUSTUP_TOOLCHAIN: ${{ !github.event.schedule && 'nightly-2023-12-01' || 'nightly' }} + RUSTUP_TOOLCHAIN: "nightly" jobs: build: