├── .gitignore ├── minesweeper.png ├── .gdbinit ├── memory.x ├── openocd.cfg ├── .cargo └── config ├── .vscode └── settings.json ├── src ├── wiring.rs ├── board.rs ├── main.rs ├── sprites.rs └── game.rs ├── Cargo.toml ├── readme.md ├── LICENSE-MIT ├── LICENSE-APACHE └── Cargo.lock /.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | -------------------------------------------------------------------------------- /minesweeper.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotcypress/minesweeper/HEAD/minesweeper.png -------------------------------------------------------------------------------- /.gdbinit: -------------------------------------------------------------------------------- 1 | target remote :3333 2 | 3 | set print asm-demangle on 4 | monitor arm semihosting enable 5 | load 6 | continue -------------------------------------------------------------------------------- /memory.x: -------------------------------------------------------------------------------- 1 | /* Linker script for the STM32G030F6Px */ 2 | MEMORY 3 | { 4 | FLASH : ORIGIN = 0x08000000, LENGTH = 32K 5 | RAM : ORIGIN = 0x20000000, LENGTH = 8K 6 | } -------------------------------------------------------------------------------- /openocd.cfg: -------------------------------------------------------------------------------- 1 | source [find interface/stlink.cfg] 2 | source [find target/stm32g0x.cfg] 3 | 4 | reset halt 5 | stm32g0x unlock 0 6 | reset halt 7 | 8 | reset_config srst_only srst_nogate 9 | init 10 | flash probe 0 -------------------------------------------------------------------------------- /.cargo/config: -------------------------------------------------------------------------------- 1 | [target.thumbv6m-none-eabi] 2 | runner = "probe-run --chip STM32G030F6" 3 | # runner = "arm-none-eabi-gdb -q" 4 | 5 | rustflags = [ 6 | "-C", "linker=arm-none-eabi-ld", 7 | "-C", "link-arg=-Tdefmt.x", 8 | "-C", "link-arg=-Tlink.x", 9 | ] 10 | 11 | [build] 12 | target = "thumbv6m-none-eabi" -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "rust-analyzer.cargo.target": "thumbv6m-none-eabi", 3 | "rust-analyzer.checkOnSave.allTargets": false, 4 | "rust.build_bin": "pwr", 5 | "rust.target": "thumbv6m-none-eabi", 6 | "rust.unstable_features": true, 7 | "rust.all_targets": false, 8 | "rust.all_features": false, 9 | "rust.cfg_test": false 10 | } -------------------------------------------------------------------------------- /src/wiring.rs: -------------------------------------------------------------------------------- 1 | use hal::gpio::{gpioa::*, *}; 2 | use hal::i2c::I2c; 3 | use hal::spi::*; 4 | use hal::stm32; 5 | use hal::timer::*; 6 | use klaptik::drivers::st7567::ST7567; 7 | use wii_ext::nunchuk::Nunchuk; 8 | 9 | pub type RngTimer = Timer; 10 | pub type InputTimer = Timer; 11 | pub type RenderTimer = Timer; 12 | pub type DisplayController = ST7567< 13 | Spi, NoMiso, PA4)>, 14 | PA5>, 15 | PA7>, 16 | PA3>, 17 | >; 18 | pub type Joystick = Nunchuk< 19 | I2c>, PA11>>, 20 | >; 21 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "minesweeper" 3 | authors = ["Vitaly Domnikov "] 4 | edition = "2018" 5 | license = "MIT/Apache-2.0" 6 | readme = "README.md" 7 | repository = "https://github.com/dotcypress/pwr" 8 | version = "0.0.0" 9 | 10 | [dependencies] 11 | cortex-m-rtic = "1.1.3" 12 | panic-halt = "0.2.0" 13 | klaptik = { git = "https://github.com/dotcypress/klaptik", features = ["st7567"] } 14 | stm32g0xx-hal = { git = "https://github.com/stm32-rs/stm32g0xx-hal.git", features = ["rt", "stm32g030"] } 15 | wii-ext = "0.3.0" 16 | defmt = "0.3.0" 17 | defmt-rtt = "0.3.1" 18 | 19 | [profile.dev] 20 | incremental = false 21 | opt-level = 2 22 | 23 | [profile.release] 24 | incremental = false 25 | lto = true 26 | opt-level = "z" 27 | 28 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # minesweeper.rs 2 | 3 | Rate my game setup 😜 4 | 5 | minesweeper.rs 6 | 7 | ## Components 8 | 9 | * [Placebo Development Board](https://github.com/dotcypress/placebo) 10 | * ST7567 LCD Display 11 | * Wii Nunchuk 12 | 13 | ## License 14 | 15 | Licensed under either of 16 | 17 | - Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or 18 | http://www.apache.org/licenses/LICENSE-2.0) 19 | - MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) 20 | 21 | at your option. 22 | 23 | ### Contribution 24 | 25 | Unless you explicitly state otherwise, any contribution intentionally submitted 26 | for inclusion in the work by you, as defined in the Apache-2.0 license, shall be 27 | dual licensed as above, without any additional terms or conditions. 28 | -------------------------------------------------------------------------------- /LICENSE-MIT: -------------------------------------------------------------------------------- 1 | MIT LICENSE 2 | 3 | Copyright (c) 2021 Vitaly Domnikov 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/board.rs: -------------------------------------------------------------------------------- 1 | use klaptik::*; 2 | 3 | #[derive(Copy, Clone, PartialEq, Eq)] 4 | pub enum TileStatus { 5 | Closed, 6 | Flagged, 7 | Opened, 8 | } 9 | 10 | #[derive(Copy, Clone, PartialEq, Eq)] 11 | pub enum TileContent { 12 | Bomb, 13 | Hint(u8), 14 | } 15 | 16 | #[derive(Copy, Clone)] 17 | pub struct Tile { 18 | status: TileStatus, 19 | content: TileContent, 20 | } 21 | 22 | impl Default for Tile { 23 | fn default() -> Self { 24 | Self { 25 | status: TileStatus::Closed, 26 | content: TileContent::Hint(0), 27 | } 28 | } 29 | } 30 | 31 | impl Tile { 32 | pub fn new(status: TileStatus, content: TileContent) -> Self { 33 | Self { status, content } 34 | } 35 | 36 | pub fn status(&self) -> TileStatus { 37 | self.status 38 | } 39 | 40 | pub fn content(&self) -> TileContent { 41 | self.content 42 | } 43 | } 44 | 45 | impl From<&Tile> for Glyph { 46 | fn from(tile: &Tile) -> Self { 47 | match tile.status() { 48 | TileStatus::Closed => b'-', 49 | TileStatus::Flagged => b'.', 50 | TileStatus::Opened => match tile.content() { 51 | TileContent::Bomb => b'/', 52 | TileContent::Hint(0) => b',', 53 | TileContent::Hint(hint) => b'0' + hint, 54 | }, 55 | } 56 | } 57 | } 58 | 59 | pub struct Board { 60 | cursor: Point, 61 | tiles: [Tile; Self::TILES], 62 | } 63 | 64 | impl Board { 65 | pub const WIDTH: usize = 16; 66 | pub const HEIGHT: usize = 6; 67 | pub const TILES: usize = Self::HEIGHT * Self::WIDTH; 68 | 69 | pub fn new() -> Self { 70 | Self { 71 | tiles: [Tile::default(); Self::TILES], 72 | cursor: Point::new(Self::WIDTH as i32 / 2, Self::HEIGHT as i32 / 2), 73 | } 74 | } 75 | 76 | pub fn reset(&mut self) { 77 | for tile in self.tiles.iter_mut() { 78 | *tile = Tile::default() 79 | } 80 | } 81 | 82 | pub fn set_status_at(&mut self, pos: Point, status: TileStatus) { 83 | self.tiles[Self::point_offset(pos)].status = status 84 | } 85 | 86 | pub fn set_content_at(&mut self, pos: Point, content: TileContent) { 87 | self.tiles[Self::point_offset(pos)].content = content; 88 | } 89 | 90 | pub fn tiles(&self) -> &[Tile] { 91 | &self.tiles 92 | } 93 | 94 | pub fn tile_at(&self, pos: Point) -> Tile { 95 | self.tiles[Self::point_offset(pos)] 96 | } 97 | 98 | pub fn cursor(&self) -> Point { 99 | self.cursor 100 | } 101 | 102 | pub fn move_cursor(&mut self, target: Point) { 103 | self.cursor = target; 104 | } 105 | 106 | pub fn cursor_offset(&self) -> usize { 107 | Self::point_offset(self.cursor) 108 | } 109 | 110 | fn point_offset(point: Point) -> usize { 111 | point.x as usize + point.y as usize * Board::WIDTH 112 | } 113 | } 114 | 115 | pub struct Neighbors { 116 | origin: Point, 117 | next: usize, 118 | } 119 | 120 | impl Neighbors { 121 | const NEIGHBORHOOD: [(i32, i32); 8] = [ 122 | (-1, -1), 123 | (-1, 0), 124 | (-1, 1), 125 | (0, 1), 126 | (1, 1), 127 | (1, 0), 128 | (1, -1), 129 | (0, -1), 130 | ]; 131 | 132 | pub fn at(origin: Point) -> Self { 133 | Self { origin, next: 0 } 134 | } 135 | } 136 | 137 | impl Iterator for Neighbors { 138 | type Item = Point; 139 | 140 | fn next(&mut self) -> Option { 141 | loop { 142 | if self.next >= Self::NEIGHBORHOOD.len() { 143 | return None; 144 | } 145 | 146 | let addr = Self::NEIGHBORHOOD[self.next]; 147 | self.next += 1; 148 | 149 | let x = self.origin.x + addr.0; 150 | let y = self.origin.y + addr.1; 151 | 152 | if x >= 0 && y >= 0 && x < Board::WIDTH as i32 && y < Board::HEIGHT as i32 { 153 | return Some(Point::new(x, y)); 154 | } 155 | } 156 | } 157 | } 158 | -------------------------------------------------------------------------------- /src/main.rs: -------------------------------------------------------------------------------- 1 | #![no_std] 2 | #![no_main] 3 | // #![deny(warnings)] 4 | 5 | extern crate panic_halt; 6 | extern crate rtic; 7 | extern crate stm32g0xx_hal as hal; 8 | 9 | mod board; 10 | mod game; 11 | mod sprites; 12 | mod wiring; 13 | 14 | use defmt_rtt as _; 15 | 16 | use hal::gpio::*; 17 | use hal::i2c; 18 | use hal::prelude::*; 19 | use klaptik::drivers::st7567::*; 20 | use klaptik::*; 21 | use wii_ext::nunchuk::*; 22 | 23 | use crate::game::*; 24 | use crate::wiring::*; 25 | 26 | #[rtic::app(device = hal::stm32, peripherals = true)] 27 | mod app { 28 | use super::*; 29 | 30 | const BOMBS: usize = 8; 31 | 32 | #[shared] 33 | struct Shared { 34 | #[lock_free] 35 | game: Minesweeper, 36 | #[lock_free] 37 | render_timer: RenderTimer, 38 | #[lock_free] 39 | input_timer: InputTimer, 40 | #[lock_free] 41 | rng_timer: RngTimer, 42 | } 43 | 44 | #[local] 45 | struct Local { 46 | display: DisplayController, 47 | ui: GameUI, 48 | nunchuk: Joystick, 49 | } 50 | 51 | #[init] 52 | fn init(ctx: init::Context) -> (Shared, Local, init::Monotonics) { 53 | let mut rcc = ctx.device.RCC.constrain(); 54 | let port_a = ctx.device.GPIOA.split(&mut rcc); 55 | 56 | let mut delay = ctx.device.TIM1.delay(&mut rcc); 57 | 58 | let mut rng_timer = ctx.device.TIM3.timer(&mut rcc); 59 | rng_timer.resume(); 60 | 61 | let mut render_timer = ctx.device.TIM14.timer(&mut rcc); 62 | render_timer.start(40.millis()); 63 | render_timer.listen(); 64 | 65 | let mut input_timer = ctx.device.TIM17.timer(&mut rcc); 66 | input_timer.start(100.millis()); 67 | input_timer.listen(); 68 | 69 | let spi = ctx.device.SPI2.spi( 70 | (port_a.pa0, hal::spi::NoMiso, port_a.pa4), 71 | hal::spi::MODE_0, 72 | 4.MHz(), 73 | &mut rcc, 74 | ); 75 | let mut display = ST7567::new( 76 | spi, 77 | port_a.pa7.into_push_pull_output(), 78 | port_a.pa3.into_push_pull_output(), 79 | port_a.pa5.into_push_pull_output(), 80 | ); 81 | display.reset(&mut delay); 82 | display.on(); 83 | 84 | let sda = port_a.pa12.into_open_drain_output(); 85 | let scl = port_a.pa11.into_open_drain_output(); 86 | let i2c_config = i2c::Config::new(100.kHz()); 87 | let i2c = ctx.device.I2C2.i2c(sda, scl, i2c_config, &mut rcc); 88 | let nunchuk = Nunchuk::new(i2c, &mut delay).unwrap(); 89 | 90 | let game = Minesweeper::new(BOMBS); 91 | let mut ui = GameUI::new(); 92 | ui.update(&game); 93 | 94 | port_a.pa6.into_open_drain_output_in_state(PinState::Low); 95 | 96 | ( 97 | Shared { 98 | game, 99 | input_timer, 100 | render_timer, 101 | rng_timer, 102 | }, 103 | Local { 104 | ui, 105 | display, 106 | nunchuk, 107 | }, 108 | init::Monotonics(), 109 | ) 110 | } 111 | 112 | #[task(binds = TIM14, local = [display, ui], shared = [game, render_timer])] 113 | fn render_timer_tick(ctx: render_timer_tick::Context) { 114 | let render_timer_tick::LocalResources { display, ui } = ctx.local; 115 | let render_timer_tick::SharedResources { game, render_timer } = ctx.shared; 116 | 117 | ui.update(&game); 118 | ui.render(display); 119 | 120 | render_timer.clear_irq(); 121 | } 122 | 123 | #[task(binds = TIM17, local = [nunchuk], shared = [game, input_timer, rng_timer])] 124 | fn input_timer_tick(ctx: input_timer_tick::Context) { 125 | let input_timer_tick::LocalResources { nunchuk } = ctx.local; 126 | let input_timer_tick::SharedResources { 127 | game, 128 | input_timer, 129 | rng_timer, 130 | } = ctx.shared; 131 | let state = nunchuk.read_no_wait().unwrap(); 132 | 133 | if state.button_z { 134 | game.seed_random(rng_timer.get_current()); 135 | game.button_click(GameButton::A); 136 | } 137 | if state.button_c { 138 | game.button_click(GameButton::B); 139 | } 140 | 141 | if state.joystick_x > (127 + 64) { 142 | game.button_click(GameButton::DPad(Dir::Right)); 143 | } else if state.joystick_x < (127 - 64) { 144 | game.button_click(GameButton::DPad(Dir::Left)); 145 | } 146 | 147 | if state.joystick_y > (127 + 64) { 148 | game.button_click(GameButton::DPad(Dir::Up)); 149 | } else if state.joystick_y < (127 - 64) { 150 | game.button_click(GameButton::DPad(Dir::Down)); 151 | } 152 | 153 | input_timer.clear_irq(); 154 | } 155 | } 156 | -------------------------------------------------------------------------------- /src/sprites.rs: -------------------------------------------------------------------------------- 1 | use klaptik::*; 2 | 3 | pub const LOGO: Sprite = Sprite::new( 4 | Glyphs::Alphabet(b"~"), 5 | Size::new(72, 16), 6 | &[ 7 | 0x00, 0xf0, 0xf0, 0x30, 0xf0, 0xe0, 0x30, 0xf0, 0xe0, 0x00, 0xf0, 0xf0, 0x00, 0xf0, 0xf0, 8 | 0x30, 0xf0, 0xe0, 0x00, 0xe0, 0xf0, 0xb0, 0xf0, 0xe0, 0x00, 0xe0, 0xf0, 0xb0, 0xb0, 0x30, 9 | 0x00, 0xf0, 0xf0, 0x00, 0xf0, 0xf0, 0x00, 0xf0, 0xf0, 0x00, 0xe0, 0xf0, 0xb0, 0xf0, 0xe0, 10 | 0x00, 0xe0, 0xf0, 0xb0, 0xf0, 0xe0, 0x00, 0xf0, 0xf0, 0x30, 0xf0, 0xe0, 0x00, 0xe0, 0xf0, 11 | 0xb0, 0xf0, 0xe0, 0x00, 0xf0, 0xf0, 0xb0, 0xf0, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x0f, 12 | 0x00, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 13 | 0x00, 0x07, 0x0f, 0x0d, 0x0d, 0x0d, 0x00, 0x0c, 0x0d, 0x0d, 0x0f, 0x07, 0x00, 0x00, 0x07, 14 | 0x0f, 0x07, 0x07, 0x0f, 0x07, 0x00, 0x00, 0x07, 0x0f, 0x0d, 0x0d, 0x0d, 0x00, 0x07, 0x0f, 15 | 0x0d, 0x0d, 0x0d, 0x00, 0x3f, 0x3f, 0x0c, 0x0f, 0x07, 0x00, 0x07, 0x0f, 0x0d, 0x0d, 0x0d, 16 | 0x00, 0x0f, 0x0f, 0x01, 0x0f, 0x0e, 0x00, 0x00, 0x00, 17 | ], 18 | ); 19 | 20 | pub const POPUP: Sprite = Sprite::new( 21 | Glyphs::Alphabet(b"WL"), 22 | Size::new(74, 32), 23 | &[ 24 | 0xff, 0x0f, 0x7f, 0xf1, 0x81, 0x01, 0x0f, 0x7f, 0xf1, 0x81, 0x01, 0x0f, 0x7f, 0xf1, 0x81, 25 | 0x01, 0x0f, 0x7f, 0xf1, 0x81, 0x01, 0x0f, 0x7f, 0xf1, 0x81, 0x01, 0x0f, 0x7f, 0xf1, 0x81, 26 | 0x01, 0x0f, 0x7f, 0xf1, 0x81, 0x01, 0x0f, 0x7f, 0xf1, 0x81, 0x01, 0x0f, 0x7f, 0xf1, 0x81, 27 | 0x01, 0x0f, 0x7f, 0xf1, 0x81, 0x01, 0x0f, 0x7f, 0xf1, 0x81, 0x01, 0x0f, 0x7f, 0xf1, 0x81, 28 | 0x01, 0x0f, 0x7f, 0xf1, 0x81, 0x01, 0x0f, 0x7f, 0xf1, 0x81, 0x01, 0x0f, 0x7f, 0xff, 0xff, 29 | 0x02, 0x02, 0x03, 0x03, 0x02, 0x02, 0x02, 0x03, 0x03, 0x02, 0x02, 0x02, 0x03, 0x83, 0x82, 30 | 0x02, 0x82, 0x83, 0x03, 0x02, 0x82, 0x82, 0x83, 0x03, 0x02, 0x82, 0x82, 0x03, 0x83, 0x82, 31 | 0x02, 0x02, 0x03, 0x03, 0x02, 0x02, 0x82, 0x83, 0x03, 0x82, 0x82, 0x02, 0x83, 0x83, 0x02, 32 | 0x02, 0x82, 0x83, 0x83, 0x02, 0x02, 0x82, 0x83, 0x83, 0x82, 0x02, 0x02, 0x83, 0x83, 0x02, 33 | 0x02, 0x02, 0x03, 0x03, 0x02, 0x02, 0x02, 0x03, 0x03, 0x02, 0x02, 0x02, 0xff, 0xff, 0x00, 34 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9f, 0xbf, 0xb0, 35 | 0xff, 0xff, 0x00, 0x3f, 0x7f, 0x61, 0x7f, 0x3f, 0x00, 0x3f, 0x7f, 0x60, 0x7f, 0x3f, 0x00, 36 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x3f, 0x78, 0x3f, 0x3f, 0x78, 0x3f, 0x07, 0x00, 0x3f, 37 | 0x7f, 0x61, 0x7f, 0x3f, 0x00, 0x7f, 0x7f, 0x01, 0x7f, 0x7f, 0x00, 0x6f, 0x6f, 0x00, 0x00, 38 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x80, 0x80, 39 | 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x81, 0x81, 0x81, 0x81, 40 | 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 41 | 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 42 | 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 43 | 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xff, 0xff, 0x0f, 0x7f, 0xf1, 44 | 0x81, 0x01, 0x0f, 0x7f, 0xf1, 0x81, 0x01, 0x0f, 0x7f, 0xf1, 0x81, 0x01, 0x0f, 0x7f, 0xf1, 45 | 0x81, 0x01, 0x0f, 0x7f, 0xf1, 0x81, 0x01, 0x0f, 0x7f, 0xf1, 0x81, 0x01, 0x0f, 0x7f, 0xf1, 46 | 0x81, 0x01, 0x0f, 0x7f, 0xf1, 0x81, 0x01, 0x0f, 0x7f, 0xf1, 0x81, 0x01, 0x0f, 0x7f, 0xf1, 47 | 0x81, 0x01, 0x0f, 0x7f, 0xf1, 0x81, 0x01, 0x0f, 0x7f, 0xf1, 0x81, 0x01, 0x0f, 0x7f, 0xf1, 48 | 0x81, 0x01, 0x0f, 0x7f, 0xf1, 0x81, 0x01, 0x0f, 0x7f, 0xff, 0xff, 0x02, 0x02, 0x03, 0x03, 49 | 0x02, 0x02, 0x02, 0x03, 0x83, 0x82, 0x82, 0x82, 0x03, 0x83, 0x82, 0x82, 0x82, 0x03, 0x03, 50 | 0x82, 0x82, 0x82, 0x83, 0x03, 0x82, 0x82, 0x02, 0x03, 0x03, 0x82, 0x82, 0x82, 0x03, 0x03, 51 | 0x02, 0x02, 0x02, 0x03, 0x03, 0x02, 0x82, 0x82, 0x83, 0x03, 0x02, 0x82, 0x82, 0x03, 0x83, 52 | 0x82, 0x02, 0x02, 0x83, 0x83, 0x82, 0x02, 0x02, 0x83, 0x83, 0x82, 0x82, 0x02, 0x03, 0x83, 53 | 0x82, 0x02, 0x02, 0x03, 0x03, 0x02, 0x02, 0x02, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 54 | 0x00, 0x00, 0x9f, 0xbf, 0xb1, 0xff, 0xff, 0x00, 0x79, 0x7d, 0x6d, 0x7f, 0x7f, 0x00, 0x7f, 55 | 0x7f, 0x01, 0x7f, 0x7f, 0x01, 0x7f, 0x7f, 0x00, 0x3f, 0x7f, 0x6d, 0x6f, 0x6f, 0x00, 0x00, 56 | 0x00, 0x00, 0x00, 0x00, 0x3f, 0x7f, 0x61, 0x7f, 0x3f, 0x00, 0x07, 0x3f, 0x78, 0x3f, 0x07, 57 | 0x00, 0x3f, 0x7f, 0x6d, 0x6f, 0x6f, 0x00, 0x7f, 0x7f, 0x0d, 0x7f, 0x77, 0x00, 0x6f, 0x6f, 58 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 59 | 0x80, 0x81, 0x81, 0x81, 0x81, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 60 | 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 61 | 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 62 | 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 63 | 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xff, 64 | ], 65 | ); 66 | 67 | pub const GAME_TILES: Sprite = Sprite::new( 68 | Glyphs::Alphabet(b",-./0123456789:;<=>?@ABCDE"), 69 | Size::new(8, 8), 70 | &[ 71 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x0c, 0x00, 0x00, 72 | 0x00, 0x00, 0x02, 0x2a, 0x2a, 0x0e, 0x0e, 0x00, 0x00, 0x0c, 0x3f, 0x3f, 0x7f, 0x7f, 0x3f, 73 | 0x3f, 0x0c, 0x00, 0x3e, 0x3e, 0x22, 0x3e, 0x3e, 0x00, 0x00, 0x00, 0x02, 0x3e, 0x3e, 0x00, 74 | 0x00, 0x00, 0x00, 0x00, 0x3a, 0x3a, 0x2a, 0x2e, 0x2e, 0x00, 0x00, 0x00, 0x2a, 0x2a, 0x2a, 75 | 0x3e, 0x3e, 0x00, 0x00, 0x00, 0x1e, 0x1e, 0x10, 0x3e, 0x3e, 0x00, 0x00, 0x00, 0x2e, 0x2e, 76 | 0x2a, 0x3a, 0x3a, 0x00, 0x00, 0x00, 0x3e, 0x3e, 0x2a, 0x3a, 0x3a, 0x00, 0x00, 0x00, 0x02, 77 | 0x02, 0x02, 0x3e, 0x3e, 0x00, 0x00, 0x00, 0x3e, 0x3e, 0x2a, 0x3e, 0x3e, 0x00, 0x00, 0xff, 78 | 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0xff, 0xff, 0xff, 0xff, 0xe7, 0xe7, 0xff, 0xff, 0xff, 79 | 0xff, 0xfb, 0xab, 0xab, 0xe3, 0xe3, 0xff, 0xff, 0xc7, 0x03, 0x01, 0x01, 0x01, 0x01, 0x03, 80 | 0xc7, 0xff, 0x83, 0x83, 0xbb, 0x83, 0x83, 0xff, 0xff, 0xff, 0xfb, 0x83, 0x83, 0xff, 0xff, 81 | 0xff, 0xff, 0xff, 0x8b, 0x8b, 0xab, 0xa3, 0xa3, 0xff, 0xff, 0xff, 0xab, 0xab, 0xab, 0x83, 82 | 0x83, 0xff, 0xff, 0xff, 0xc3, 0xc3, 0xdf, 0x83, 0x83, 0xff, 0xff, 0xff, 0xa3, 0xa3, 0xab, 83 | 0x8b, 0x8b, 0xff, 0xff, 0xff, 0x83, 0x83, 0xab, 0x8b, 0x8b, 0xff, 0xff, 0xff, 0xfb, 0xfb, 84 | 0xfb, 0x83, 0x83, 0xff, 0xff, 0xff, 0x83, 0x83, 0xab, 0x83, 0x83, 0xff, 0xff, 0x03, 0x03, 85 | 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 86 | ], 87 | ); 88 | -------------------------------------------------------------------------------- /src/game.rs: -------------------------------------------------------------------------------- 1 | use klaptik::*; 2 | 3 | use crate::board::*; 4 | use crate::sprites::*; 5 | 6 | #[derive(PartialEq, Debug)] 7 | pub enum GameButton { 8 | DPad(Dir), 9 | A, 10 | B, 11 | } 12 | 13 | #[derive(PartialEq, Debug)] 14 | pub enum Dir { 15 | Up, 16 | Right, 17 | Down, 18 | Left, 19 | } 20 | 21 | #[derive(Copy, Clone)] 22 | pub enum GameStatus { 23 | Win, 24 | Bootstrap, 25 | Playing, 26 | GameOver, 27 | } 28 | 29 | pub struct Minesweeper { 30 | board: Board, 31 | status: GameStatus, 32 | bombs: usize, 33 | rng_seed: u32, 34 | } 35 | 36 | impl Minesweeper { 37 | pub fn new(bombs: usize) -> Self { 38 | assert!(bombs < Board::TILES); 39 | Self { 40 | bombs, 41 | board: Board::new(), 42 | status: GameStatus::Bootstrap, 43 | rng_seed: 42, 44 | } 45 | } 46 | 47 | pub fn seed_random(&mut self, seed: u32) { 48 | self.rng_seed = seed % 0x7fff_ffff; 49 | } 50 | 51 | pub fn button_click(&mut self, button: GameButton) { 52 | let mut cursor = self.board.cursor(); 53 | match button { 54 | GameButton::A => match self.status { 55 | GameStatus::Bootstrap => { 56 | self.bootstrap(); 57 | self.open_tile(cursor) 58 | } 59 | GameStatus::Playing => { 60 | self.open_tile(cursor); 61 | self.refresh_game_state() 62 | } 63 | _ => self.bootstrap(), 64 | }, 65 | GameButton::B => { 66 | match self.board.tile_at(cursor).status() { 67 | TileStatus::Closed => self.board.set_status_at(cursor, TileStatus::Flagged), 68 | TileStatus::Flagged => self.board.set_status_at(cursor, TileStatus::Closed), 69 | _ => {} 70 | }; 71 | self.refresh_game_state() 72 | } 73 | GameButton::DPad(dir) => { 74 | match dir { 75 | Dir::Left if cursor.x > 0 => { 76 | cursor = Point::new(cursor.x - 1, cursor.y); 77 | } 78 | Dir::Right if cursor.x + 1 < Board::WIDTH as i32 => { 79 | cursor = Point::new(cursor.x + 1, cursor.y); 80 | } 81 | Dir::Up if cursor.y > 0 => { 82 | cursor = Point::new(cursor.x, cursor.y - 1); 83 | } 84 | Dir::Down if cursor.y + 1 < Board::HEIGHT as i32 => { 85 | cursor = Point::new(cursor.x, cursor.y + 1); 86 | } 87 | _ => {} 88 | } 89 | self.board.move_cursor(cursor); 90 | } 91 | }; 92 | } 93 | 94 | fn refresh_game_state(&mut self) { 95 | if self 96 | .board 97 | .tiles() 98 | .iter() 99 | .any(|&tile| tile.status() == TileStatus::Opened && tile.content() == TileContent::Bomb) 100 | { 101 | self.status = GameStatus::GameOver; 102 | return; 103 | } 104 | 105 | let win = self.board.tiles().iter().all(|&tile| { 106 | matches!( 107 | (tile.status(), tile.content()), 108 | (TileStatus::Flagged, TileContent::Bomb) | (TileStatus::Opened, _) 109 | ) 110 | }); 111 | 112 | if win { 113 | self.status = GameStatus::Win; 114 | } 115 | } 116 | 117 | fn open_tile(&mut self, origin: Point) { 118 | if let TileStatus::Closed = self.board.tile_at(origin).status() { 119 | match self.board.tile_at(origin).content() { 120 | TileContent::Hint(0) => { 121 | self.board.set_status_at(origin, TileStatus::Opened); 122 | for neighbor in Neighbors::at(origin) { 123 | self.open_tile(neighbor); 124 | } 125 | } 126 | _ => self.board.set_status_at(origin, TileStatus::Opened), 127 | } 128 | } 129 | } 130 | 131 | fn bootstrap(&mut self) { 132 | self.board.reset(); 133 | 134 | let mut bombs_planted = 0; 135 | while bombs_planted < self.bombs { 136 | let pos = Point::new( 137 | self.gen_random(Board::WIDTH as u16), 138 | self.gen_random(Board::HEIGHT as u16), 139 | ); 140 | match self.board.tile_at(pos).content() { 141 | TileContent::Hint(_) if pos != self.board.cursor() => { 142 | self.board.set_content_at(pos, TileContent::Bomb); 143 | bombs_planted += 1; 144 | } 145 | _ => {} 146 | } 147 | } 148 | 149 | for x in 0..Board::WIDTH { 150 | for y in 0..Board::HEIGHT { 151 | let pos = Point::new(x as i32, y as i32); 152 | 153 | if let TileContent::Bomb = self.board.tile_at(pos).content() { 154 | continue; 155 | } 156 | 157 | let mut bombs = 0; 158 | for neighbor in Neighbors::at(pos) { 159 | if let TileContent::Bomb = self.board.tile_at(neighbor).content() { 160 | bombs += 1; 161 | } 162 | } 163 | 164 | self.board.set_content_at(pos, TileContent::Hint(bombs)); 165 | } 166 | } 167 | 168 | self.status = GameStatus::Playing; 169 | } 170 | 171 | fn gen_random(&mut self, up_to: u16) -> i32 { 172 | self.rng_seed = self.rng_seed * 16_807 % 0x7fff_ffff; 173 | (self.rng_seed % up_to as u32) as i32 174 | } 175 | } 176 | 177 | widget_group! { 178 | GameUI<&Minesweeper>, 179 | { 180 | bg: Background, Point::new(0, 0), Size::new(128, 64); 181 | logo: GlyphIcon, LOGO, b'~', Point::new(0, 0); 182 | game_screen: GameScreen; 183 | }, 184 | |game_ui: &mut GameUI, state: &Minesweeper| { 185 | game_ui.game_screen.update(state); 186 | } 187 | } 188 | 189 | widget_mux!( 190 | GameScreen<&Minesweeper>, 191 | GameScreenNode::Board, 192 | { 193 | board: GameBoard; 194 | win: GlyphIcon, POPUP, b'W', Point::new(24, 24); 195 | game_over: GlyphIcon, POPUP, b'L', Point::new(24, 24); 196 | }, 197 | |mux: &mut GameScreen, state: &Minesweeper| { 198 | let node = match state.status { 199 | GameStatus::GameOver => GameScreenNode::GameOver, 200 | GameStatus::Win => GameScreenNode::Win, 201 | _ => GameScreenNode::Board, 202 | }; 203 | mux.set_active(node); 204 | mux.board.update(&state.board); 205 | } 206 | ); 207 | 208 | pub type GameWidget = WrapPanel<{ Board::TILES }, { Board::WIDTH as _ }>; 209 | 210 | widget_group!( 211 | GameBoard<&Board>, 212 | { 213 | field: GameWidget, GAME_TILES, "", Point::new(0, 16); 214 | }, 215 | |board: &mut GameBoard, state: &Board| { 216 | let cursor_idx = state.cursor_offset(); 217 | for (idx, tile) in state.tiles().iter().enumerate() { 218 | let mut glyph = tile.into(); 219 | if idx == cursor_idx { 220 | glyph += 13; 221 | } 222 | board.field.set_glyph(idx, glyph); 223 | } 224 | } 225 | ); 226 | -------------------------------------------------------------------------------- /LICENSE-APACHE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | -------------------------------------------------------------------------------- /Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "aho-corasick" 7 | version = "0.7.19" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "b4f55bd91a0978cbfd91c457a164bab8b4001c833b7f323132c0a4e1922dd44e" 10 | dependencies = [ 11 | "memchr", 12 | ] 13 | 14 | [[package]] 15 | name = "atomic-polyfill" 16 | version = "0.1.10" 17 | source = "registry+https://github.com/rust-lang/crates.io-index" 18 | checksum = "9c041a8d9751a520ee19656232a18971f18946a7900f1520ee4400002244dd89" 19 | dependencies = [ 20 | "critical-section", 21 | ] 22 | 23 | [[package]] 24 | name = "autocfg" 25 | version = "1.1.0" 26 | source = "registry+https://github.com/rust-lang/crates.io-index" 27 | checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" 28 | 29 | [[package]] 30 | name = "az" 31 | version = "1.2.1" 32 | source = "registry+https://github.com/rust-lang/crates.io-index" 33 | checksum = "7b7e4c2464d97fe331d41de9d5db0def0a96f4d823b8b32a2efd503578988973" 34 | 35 | [[package]] 36 | name = "bare-metal" 37 | version = "0.2.5" 38 | source = "registry+https://github.com/rust-lang/crates.io-index" 39 | checksum = "5deb64efa5bd81e31fcd1938615a6d98c82eafcbcd787162b6f63b91d6bac5b3" 40 | dependencies = [ 41 | "rustc_version 0.2.3", 42 | ] 43 | 44 | [[package]] 45 | name = "bare-metal" 46 | version = "1.0.0" 47 | source = "registry+https://github.com/rust-lang/crates.io-index" 48 | checksum = "f8fe8f5a8a398345e52358e18ff07cc17a568fbca5c6f73873d3a62056309603" 49 | 50 | [[package]] 51 | name = "bit_field" 52 | version = "0.10.1" 53 | source = "registry+https://github.com/rust-lang/crates.io-index" 54 | checksum = "dcb6dd1c2376d2e096796e234a70e17e94cc2d5d54ff8ce42b28cef1d0d359a4" 55 | 56 | [[package]] 57 | name = "bitfield" 58 | version = "0.13.2" 59 | source = "registry+https://github.com/rust-lang/crates.io-index" 60 | checksum = "46afbd2983a5d5a7bd740ccb198caf5b82f45c40c09c0eed36052d91cb92e719" 61 | 62 | [[package]] 63 | name = "bitflags" 64 | version = "1.3.2" 65 | source = "registry+https://github.com/rust-lang/crates.io-index" 66 | checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" 67 | 68 | [[package]] 69 | name = "byteorder" 70 | version = "1.4.3" 71 | source = "registry+https://github.com/rust-lang/crates.io-index" 72 | checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" 73 | 74 | [[package]] 75 | name = "cfg-if" 76 | version = "1.0.0" 77 | source = "registry+https://github.com/rust-lang/crates.io-index" 78 | checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" 79 | 80 | [[package]] 81 | name = "cortex-m" 82 | version = "0.7.6" 83 | source = "registry+https://github.com/rust-lang/crates.io-index" 84 | checksum = "70858629a458fdfd39f9675c4dc309411f2a3f83bede76988d81bf1a0ecee9e0" 85 | dependencies = [ 86 | "bare-metal 0.2.5", 87 | "bitfield", 88 | "embedded-hal", 89 | "volatile-register", 90 | ] 91 | 92 | [[package]] 93 | name = "cortex-m-rt" 94 | version = "0.7.1" 95 | source = "registry+https://github.com/rust-lang/crates.io-index" 96 | checksum = "3c433da385b720d5bb9f52362fa2782420798e68d40d67bfe4b0d992aba5dfe7" 97 | dependencies = [ 98 | "cortex-m-rt-macros", 99 | ] 100 | 101 | [[package]] 102 | name = "cortex-m-rt-macros" 103 | version = "0.7.0" 104 | source = "registry+https://github.com/rust-lang/crates.io-index" 105 | checksum = "f0f6f3e36f203cfedbc78b357fb28730aa2c6dc1ab060ee5c2405e843988d3c7" 106 | dependencies = [ 107 | "proc-macro2", 108 | "quote", 109 | "syn", 110 | ] 111 | 112 | [[package]] 113 | name = "cortex-m-rtic" 114 | version = "1.1.3" 115 | source = "registry+https://github.com/rust-lang/crates.io-index" 116 | checksum = "c6b82f1c39acd6c3a35c2013b6110c20f5bc534522791fabadeed49ccada2dce" 117 | dependencies = [ 118 | "bare-metal 1.0.0", 119 | "cortex-m", 120 | "cortex-m-rtic-macros", 121 | "heapless", 122 | "rtic-core", 123 | "rtic-monotonic", 124 | "version_check", 125 | ] 126 | 127 | [[package]] 128 | name = "cortex-m-rtic-macros" 129 | version = "1.1.5" 130 | source = "registry+https://github.com/rust-lang/crates.io-index" 131 | checksum = "9e8e9645ef54bec1cf70ac33e9bf9566e6507ab5b41ae6baf3735662194e8607" 132 | dependencies = [ 133 | "proc-macro-error", 134 | "proc-macro2", 135 | "quote", 136 | "rtic-syntax", 137 | "syn", 138 | ] 139 | 140 | [[package]] 141 | name = "critical-section" 142 | version = "0.2.7" 143 | source = "registry+https://github.com/rust-lang/crates.io-index" 144 | checksum = "95da181745b56d4bd339530ec393508910c909c784e8962d15d722bacf0bcbcd" 145 | dependencies = [ 146 | "bare-metal 1.0.0", 147 | "cfg-if", 148 | "cortex-m", 149 | "riscv", 150 | ] 151 | 152 | [[package]] 153 | name = "defmt" 154 | version = "0.3.2" 155 | source = "registry+https://github.com/rust-lang/crates.io-index" 156 | checksum = "d3a0ae7494d9bff013d7b89471f4c424356a71e9752e0c78abe7e6c608a16bb3" 157 | dependencies = [ 158 | "bitflags", 159 | "defmt-macros", 160 | ] 161 | 162 | [[package]] 163 | name = "defmt-macros" 164 | version = "0.3.3" 165 | source = "registry+https://github.com/rust-lang/crates.io-index" 166 | checksum = "8500cbe4cca056412efce4215a63d0bc20492942aeee695f23b624a53e0a6854" 167 | dependencies = [ 168 | "defmt-parser", 169 | "proc-macro-error", 170 | "proc-macro2", 171 | "quote", 172 | "syn", 173 | ] 174 | 175 | [[package]] 176 | name = "defmt-parser" 177 | version = "0.3.1" 178 | source = "registry+https://github.com/rust-lang/crates.io-index" 179 | checksum = "0db23d29972d99baa3de2ee2ae3f104c10564a6d05a346eb3f4c4f2c0525a06e" 180 | 181 | [[package]] 182 | name = "defmt-rtt" 183 | version = "0.3.2" 184 | source = "registry+https://github.com/rust-lang/crates.io-index" 185 | checksum = "1d2cbbbd58847d508d97629b32cd9730a2d28532f71e219714614406029f18b1" 186 | dependencies = [ 187 | "critical-section", 188 | "defmt", 189 | ] 190 | 191 | [[package]] 192 | name = "embedded-graphics-core" 193 | version = "0.3.3" 194 | source = "registry+https://github.com/rust-lang/crates.io-index" 195 | checksum = "b8b1239db5f3eeb7e33e35bd10bd014e7b2537b17e071f726a09351431337cfa" 196 | dependencies = [ 197 | "az", 198 | "byteorder", 199 | ] 200 | 201 | [[package]] 202 | name = "embedded-hal" 203 | version = "0.2.7" 204 | source = "registry+https://github.com/rust-lang/crates.io-index" 205 | checksum = "35949884794ad573cf46071e41c9b60efb0cb311e3ca01f7af807af1debc66ff" 206 | dependencies = [ 207 | "nb 0.1.3", 208 | "void", 209 | ] 210 | 211 | [[package]] 212 | name = "fugit" 213 | version = "0.3.6" 214 | source = "registry+https://github.com/rust-lang/crates.io-index" 215 | checksum = "7ab17bb279def6720d058cb6c052249938e7f99260ab534879281a95367a87e5" 216 | dependencies = [ 217 | "gcd", 218 | ] 219 | 220 | [[package]] 221 | name = "gcd" 222 | version = "2.1.0" 223 | source = "registry+https://github.com/rust-lang/crates.io-index" 224 | checksum = "f37978dab2ca789938a83b2f8bc1ef32db6633af9051a6cd409eff72cbaaa79a" 225 | dependencies = [ 226 | "paste", 227 | ] 228 | 229 | [[package]] 230 | name = "hash32" 231 | version = "0.2.1" 232 | source = "registry+https://github.com/rust-lang/crates.io-index" 233 | checksum = "b0c35f58762feb77d74ebe43bdbc3210f09be9fe6742234d573bacc26ed92b67" 234 | dependencies = [ 235 | "byteorder", 236 | ] 237 | 238 | [[package]] 239 | name = "hashbrown" 240 | version = "0.12.3" 241 | source = "registry+https://github.com/rust-lang/crates.io-index" 242 | checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" 243 | 244 | [[package]] 245 | name = "heapless" 246 | version = "0.7.16" 247 | source = "registry+https://github.com/rust-lang/crates.io-index" 248 | checksum = "db04bc24a18b9ea980628ecf00e6c0264f3c1426dac36c00cb49b6fbad8b0743" 249 | dependencies = [ 250 | "atomic-polyfill", 251 | "hash32", 252 | "rustc_version 0.4.0", 253 | "spin", 254 | "stable_deref_trait", 255 | ] 256 | 257 | [[package]] 258 | name = "indexmap" 259 | version = "1.9.1" 260 | source = "registry+https://github.com/rust-lang/crates.io-index" 261 | checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e" 262 | dependencies = [ 263 | "autocfg", 264 | "hashbrown", 265 | ] 266 | 267 | [[package]] 268 | name = "klaptik" 269 | version = "0.0.4" 270 | source = "git+https://github.com/dotcypress/klaptik#d3f57fcf6b2e77e000b0959957b1d1a11eeb45bf" 271 | dependencies = [ 272 | "embedded-graphics-core", 273 | "embedded-hal", 274 | "paste", 275 | ] 276 | 277 | [[package]] 278 | name = "lazy_static" 279 | version = "1.4.0" 280 | source = "registry+https://github.com/rust-lang/crates.io-index" 281 | checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" 282 | 283 | [[package]] 284 | name = "lock_api" 285 | version = "0.4.9" 286 | source = "registry+https://github.com/rust-lang/crates.io-index" 287 | checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" 288 | dependencies = [ 289 | "autocfg", 290 | "scopeguard", 291 | ] 292 | 293 | [[package]] 294 | name = "memchr" 295 | version = "2.5.0" 296 | source = "registry+https://github.com/rust-lang/crates.io-index" 297 | checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" 298 | 299 | [[package]] 300 | name = "minesweeper" 301 | version = "0.0.0" 302 | dependencies = [ 303 | "cortex-m-rtic", 304 | "defmt", 305 | "defmt-rtt", 306 | "klaptik", 307 | "panic-halt", 308 | "stm32g0xx-hal", 309 | "wii-ext", 310 | ] 311 | 312 | [[package]] 313 | name = "nb" 314 | version = "0.1.3" 315 | source = "registry+https://github.com/rust-lang/crates.io-index" 316 | checksum = "801d31da0513b6ec5214e9bf433a77966320625a37860f910be265be6e18d06f" 317 | dependencies = [ 318 | "nb 1.0.0", 319 | ] 320 | 321 | [[package]] 322 | name = "nb" 323 | version = "1.0.0" 324 | source = "registry+https://github.com/rust-lang/crates.io-index" 325 | checksum = "546c37ac5d9e56f55e73b677106873d9d9f5190605e41a856503623648488cae" 326 | 327 | [[package]] 328 | name = "panic-halt" 329 | version = "0.2.0" 330 | source = "registry+https://github.com/rust-lang/crates.io-index" 331 | checksum = "de96540e0ebde571dc55c73d60ef407c653844e6f9a1e2fdbd40c07b9252d812" 332 | 333 | [[package]] 334 | name = "paste" 335 | version = "1.0.9" 336 | source = "registry+https://github.com/rust-lang/crates.io-index" 337 | checksum = "b1de2e551fb905ac83f73f7aedf2f0cb4a0da7e35efa24a202a936269f1f18e1" 338 | 339 | [[package]] 340 | name = "proc-macro-error" 341 | version = "1.0.4" 342 | source = "registry+https://github.com/rust-lang/crates.io-index" 343 | checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" 344 | dependencies = [ 345 | "proc-macro-error-attr", 346 | "proc-macro2", 347 | "quote", 348 | "syn", 349 | "version_check", 350 | ] 351 | 352 | [[package]] 353 | name = "proc-macro-error-attr" 354 | version = "1.0.4" 355 | source = "registry+https://github.com/rust-lang/crates.io-index" 356 | checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" 357 | dependencies = [ 358 | "proc-macro2", 359 | "quote", 360 | "version_check", 361 | ] 362 | 363 | [[package]] 364 | name = "proc-macro2" 365 | version = "1.0.47" 366 | source = "registry+https://github.com/rust-lang/crates.io-index" 367 | checksum = "5ea3d908b0e36316caf9e9e2c4625cdde190a7e6f440d794667ed17a1855e725" 368 | dependencies = [ 369 | "unicode-ident", 370 | ] 371 | 372 | [[package]] 373 | name = "quote" 374 | version = "1.0.21" 375 | source = "registry+https://github.com/rust-lang/crates.io-index" 376 | checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" 377 | dependencies = [ 378 | "proc-macro2", 379 | ] 380 | 381 | [[package]] 382 | name = "regex" 383 | version = "1.6.0" 384 | source = "registry+https://github.com/rust-lang/crates.io-index" 385 | checksum = "4c4eb3267174b8c6c2f654116623910a0fef09c4753f8dd83db29c48a0df988b" 386 | dependencies = [ 387 | "aho-corasick", 388 | "memchr", 389 | "regex-syntax", 390 | ] 391 | 392 | [[package]] 393 | name = "regex-syntax" 394 | version = "0.6.27" 395 | source = "registry+https://github.com/rust-lang/crates.io-index" 396 | checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244" 397 | 398 | [[package]] 399 | name = "riscv" 400 | version = "0.7.0" 401 | source = "registry+https://github.com/rust-lang/crates.io-index" 402 | checksum = "6907ccdd7a31012b70faf2af85cd9e5ba97657cc3987c4f13f8e4d2c2a088aba" 403 | dependencies = [ 404 | "bare-metal 1.0.0", 405 | "bit_field", 406 | "riscv-target", 407 | ] 408 | 409 | [[package]] 410 | name = "riscv-target" 411 | version = "0.1.2" 412 | source = "registry+https://github.com/rust-lang/crates.io-index" 413 | checksum = "88aa938cda42a0cf62a20cfe8d139ff1af20c2e681212b5b34adb5a58333f222" 414 | dependencies = [ 415 | "lazy_static", 416 | "regex", 417 | ] 418 | 419 | [[package]] 420 | name = "rtic-core" 421 | version = "1.0.0" 422 | source = "registry+https://github.com/rust-lang/crates.io-index" 423 | checksum = "d9369355b04d06a3780ec0f51ea2d225624db777acbc60abd8ca4832da5c1a42" 424 | 425 | [[package]] 426 | name = "rtic-monotonic" 427 | version = "1.0.0" 428 | source = "registry+https://github.com/rust-lang/crates.io-index" 429 | checksum = "fb8b0b822d1a366470b9cea83a1d4e788392db763539dc4ba022bcc787fece82" 430 | 431 | [[package]] 432 | name = "rtic-syntax" 433 | version = "1.0.2" 434 | source = "registry+https://github.com/rust-lang/crates.io-index" 435 | checksum = "3ad3ae243dd8d0a1b064615f664d4fa7e63929939074c564cbe5efdc4c503065" 436 | dependencies = [ 437 | "indexmap", 438 | "proc-macro2", 439 | "quote", 440 | "syn", 441 | ] 442 | 443 | [[package]] 444 | name = "rustc_version" 445 | version = "0.2.3" 446 | source = "registry+https://github.com/rust-lang/crates.io-index" 447 | checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" 448 | dependencies = [ 449 | "semver 0.9.0", 450 | ] 451 | 452 | [[package]] 453 | name = "rustc_version" 454 | version = "0.4.0" 455 | source = "registry+https://github.com/rust-lang/crates.io-index" 456 | checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" 457 | dependencies = [ 458 | "semver 1.0.14", 459 | ] 460 | 461 | [[package]] 462 | name = "scopeguard" 463 | version = "1.1.0" 464 | source = "registry+https://github.com/rust-lang/crates.io-index" 465 | checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" 466 | 467 | [[package]] 468 | name = "semver" 469 | version = "0.9.0" 470 | source = "registry+https://github.com/rust-lang/crates.io-index" 471 | checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" 472 | dependencies = [ 473 | "semver-parser", 474 | ] 475 | 476 | [[package]] 477 | name = "semver" 478 | version = "1.0.14" 479 | source = "registry+https://github.com/rust-lang/crates.io-index" 480 | checksum = "e25dfac463d778e353db5be2449d1cce89bd6fd23c9f1ea21310ce6e5a1b29c4" 481 | 482 | [[package]] 483 | name = "semver-parser" 484 | version = "0.7.0" 485 | source = "registry+https://github.com/rust-lang/crates.io-index" 486 | checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" 487 | 488 | [[package]] 489 | name = "spin" 490 | version = "0.9.4" 491 | source = "registry+https://github.com/rust-lang/crates.io-index" 492 | checksum = "7f6002a767bff9e83f8eeecf883ecb8011875a21ae8da43bffb817a57e78cc09" 493 | dependencies = [ 494 | "lock_api", 495 | ] 496 | 497 | [[package]] 498 | name = "stable_deref_trait" 499 | version = "1.2.0" 500 | source = "registry+https://github.com/rust-lang/crates.io-index" 501 | checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" 502 | 503 | [[package]] 504 | name = "stm32g0" 505 | version = "0.14.0" 506 | source = "registry+https://github.com/rust-lang/crates.io-index" 507 | checksum = "dfc2ac544cea741c92a501bfd027d197354cd22ee92b439aea26d2ee0b55bcd7" 508 | dependencies = [ 509 | "bare-metal 1.0.0", 510 | "cortex-m", 511 | "cortex-m-rt", 512 | "vcell", 513 | ] 514 | 515 | [[package]] 516 | name = "stm32g0xx-hal" 517 | version = "0.1.5" 518 | source = "git+https://github.com/stm32-rs/stm32g0xx-hal.git#e272a8f3a49f8a6206afa08afed3b5dac635cc1c" 519 | dependencies = [ 520 | "bare-metal 1.0.0", 521 | "cortex-m", 522 | "embedded-hal", 523 | "fugit", 524 | "nb 1.0.0", 525 | "stm32g0", 526 | "void", 527 | ] 528 | 529 | [[package]] 530 | name = "syn" 531 | version = "1.0.102" 532 | source = "registry+https://github.com/rust-lang/crates.io-index" 533 | checksum = "3fcd952facd492f9be3ef0d0b7032a6e442ee9b361d4acc2b1d0c4aaa5f613a1" 534 | dependencies = [ 535 | "proc-macro2", 536 | "quote", 537 | "unicode-ident", 538 | ] 539 | 540 | [[package]] 541 | name = "unicode-ident" 542 | version = "1.0.5" 543 | source = "registry+https://github.com/rust-lang/crates.io-index" 544 | checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3" 545 | 546 | [[package]] 547 | name = "vcell" 548 | version = "0.1.3" 549 | source = "registry+https://github.com/rust-lang/crates.io-index" 550 | checksum = "77439c1b53d2303b20d9459b1ade71a83c716e3f9c34f3228c00e6f185d6c002" 551 | 552 | [[package]] 553 | name = "version_check" 554 | version = "0.9.4" 555 | source = "registry+https://github.com/rust-lang/crates.io-index" 556 | checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" 557 | 558 | [[package]] 559 | name = "void" 560 | version = "1.0.2" 561 | source = "registry+https://github.com/rust-lang/crates.io-index" 562 | checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" 563 | 564 | [[package]] 565 | name = "volatile-register" 566 | version = "0.2.1" 567 | source = "registry+https://github.com/rust-lang/crates.io-index" 568 | checksum = "9ee8f19f9d74293faf70901bc20ad067dc1ad390d2cbf1e3f75f721ffee908b6" 569 | dependencies = [ 570 | "vcell", 571 | ] 572 | 573 | [[package]] 574 | name = "wii-ext" 575 | version = "0.3.0" 576 | source = "registry+https://github.com/rust-lang/crates.io-index" 577 | checksum = "b4277ee73b6efa141a5ff2c46e92deef2cb4ee0a902aa865dfd4b9b09ad47149" 578 | dependencies = [ 579 | "embedded-hal", 580 | ] 581 | --------------------------------------------------------------------------------