diff --git a/apps/.cargo/config.toml b/apps/.cargo/config.toml deleted file mode 100644 index 60e186d..0000000 --- a/apps/.cargo/config.toml +++ /dev/null @@ -1,10 +0,0 @@ -[build] -target = "thumbv7em-none-eabi" -target-dir = "../target" - -[target.thumbv7em-none-eabi] -rustflags = ["-C", "link-arg=-Tapp.ld", "-C", "link-arg=--emit-relocs", "-C", "target-feature=+no-movt", "--check-cfg=cfg(wp2_sim)"] - -# host builds: cargo test, and the wp2-apps simulator (--cfg wp2_sim) -[target.'cfg(not(target_os = "none"))'] -rustflags = ["--check-cfg=cfg(wp2_sim)"] diff --git a/apps/Cargo.lock b/apps/Cargo.lock deleted file mode 100644 index 70750d8..0000000 --- a/apps/Cargo.lock +++ /dev/null @@ -1,185 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 4 - -[[package]] -name = "calendar" -version = "0.1.0" -dependencies = [ - "cmf-wp2-app", - "cmf-wp2-ui", - "companion-rpc", - "wp2-core", -] - -[[package]] -name = "cmf-wp2-app" -version = "0.1.0" - -[[package]] -name = "cmf-wp2-ui" -version = "0.1.0" -dependencies = [ - "cmf-wp2-app", - "wp2-core", -] - -[[package]] -name = "companion-rpc" -version = "0.1.0" - -[[package]] -name = "focus-timer" -version = "0.1.0" -dependencies = [ - "cmf-wp2-app", - "wp2-core", -] - -[[package]] -name = "ha-remote" -version = "0.1.0" -dependencies = [ - "cmf-wp2-app", - "wp2-core", -] - -[[package]] -name = "markets" -version = "0.1.0" -dependencies = [ - "cmf-wp2-app", - "cmf-wp2-ui", - "companion-rpc", -] - -[[package]] -name = "metrolist" -version = "0.1.0" -dependencies = [ - "cmf-wp2-app", - "wp2-core", -] - -[[package]] -name = "metronome" -version = "0.1.0" -dependencies = [ - "cmf-wp2-app", -] - -[[package]] -name = "mood" -version = "0.1.0" -dependencies = [ - "cmf-wp2-app", - "wp2-core", -] - -[[package]] -name = "music-controller" -version = "0.1.0" -dependencies = [ - "cmf-wp2-app", - "cmf-wp2-ui", -] - -[[package]] -name = "orbit" -version = "0.1.0" -dependencies = [ - "cmf-wp2-app", - "cmf-wp2-ui", -] - -[[package]] -name = "reminders" -version = "0.1.0" -dependencies = [ - "cmf-wp2-app", - "companion-rpc", - "wp2-core", -] - -[[package]] -name = "sky-hop" -version = "0.1.0" -dependencies = [ - "cmf-wp2-app", - "cmf-wp2-ui", -] - -[[package]] -name = "snake" -version = "0.1.0" -dependencies = [ - "cmf-wp2-app", -] - -[[package]] -name = "storage" -version = "0.1.0" -dependencies = [ - "cmf-wp2-app", - "wp2-core", -] - -[[package]] -name = "tetris" -version = "0.1.0" -dependencies = [ - "cmf-wp2-app", - "cmf-wp2-ui", -] - -[[package]] -name = "twenty48" -version = "0.1.0" -dependencies = [ - "cmf-wp2-app", -] - -[[package]] -name = "ui-gallery" -version = "0.1.0" -dependencies = [ - "cmf-wp2-app", - "cmf-wp2-ui", - "wp2-core", -] - -[[package]] -name = "v-maps" -version = "0.1.0" -dependencies = [ - "cmf-wp2-app", - "cmf-wp2-ui", -] - -[[package]] -name = "vela-nav" -version = "0.1.0" -dependencies = [ - "cmf-wp2-app", - "cmf-wp2-ui", -] - -[[package]] -name = "vibration-lab" -version = "0.1.0" -dependencies = [ - "cmf-wp2-app", -] - -[[package]] -name = "weather" -version = "0.1.0" -dependencies = [ - "cmf-wp2-app", - "companion-rpc", - "wp2-core", -] - -[[package]] -name = "wp2-core" -version = "0.1.0" diff --git a/apps/Cargo.toml b/apps/Cargo.toml deleted file mode 100644 index b055d0a..0000000 --- a/apps/Cargo.toml +++ /dev/null @@ -1,30 +0,0 @@ -[workspace] -resolver = "3" -members = ["*"] -exclude = [".cargo"] - -[workspace.package] -edition = "2024" -license = "MIT" -version = "0.1.0" - -# The SDK, from the wp2-apps checkout `make sdk` puts at the commit pinned in the Makefile (WP2_APPS_REV). -[workspace.dependencies] -cmf-wp2-app = { path = "../.sdk/wp2-apps/sdk/cmf-wp2-app" } -cmf-wp2-ui = { path = "../.sdk/wp2-apps/sdk/cmf-wp2-ui" } -wp2-core = { path = "../.sdk/wp2-apps/fw/wp2-core" } -# shared by the apps here (../crates) -companion-rpc = { path = "../crates/companion-rpc" } - -[profile.dev] -panic = "abort" - -[profile.release] -panic = "abort" -opt-level = "s" -lto = true -codegen-units = 1 - -# Storage is a read-mostly utility; keep its package small without changing other apps. -[profile.release.package.storage] -opt-level = "z" diff --git a/apps/blocks/Cargo.toml b/apps/blocks/Cargo.toml deleted file mode 100644 index 9df891c..0000000 --- a/apps/blocks/Cargo.toml +++ /dev/null @@ -1,12 +0,0 @@ -[package] -name = "blocks" -edition.workspace = true -license.workspace = true -version.workspace = true - -[dependencies] -cmf-wp2-app.workspace = true - -[[bin]] -name = "blocks" -bench = false diff --git a/apps/blocks/icon.svg b/apps/blocks/icon.svg deleted file mode 100644 index 5d3b0b5..0000000 --- a/apps/blocks/icon.svg +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/apps/blocks/src/game.rs b/apps/blocks/src/game.rs deleted file mode 100644 index e293024..0000000 --- a/apps/blocks/src/game.rs +++ /dev/null @@ -1,490 +0,0 @@ -//! The block puzzle's rules: an 8×8 board, three pieces at a time, rows and columns clear when full. No device calls -//! here, so host tests cover placement, clears, the refill and the game-over check. - -pub const SIDE: usize = 8; -pub const CELLS: usize = SIDE * SIDE; -/// Colours on the board are 1..=8; 0 is empty. -pub const COLOURS: usize = 8; - -pub struct Shape { - /// Bit `y * 4 + x` is a block, in a 4×4 frame. - pub mask: u16, - pub w: u8, - pub h: u8, -} - -const fn s(mask: u16, w: u8, h: u8) -> Shape { - Shape { mask, w, h } -} - -pub const SHAPES: [Shape; 31] = [ - s(0b0001, 1, 1), // dot - s(0b0011, 2, 1), // domino across - s(0b0001_0001, 1, 2), // domino down - s(0b0111, 3, 1), // three across - s(0b0001_0001_0001, 1, 3), // three down - s(0b1111, 4, 1), // four across - s(0b0001_0001_0001_0001, 1, 4), // four down - s(0b0011_0011, 2, 2), // square - s(0b0111_0111_0111, 3, 3), // big square - s(0b0011_0001, 2, 2), // corner, all four turns - s(0b0001_0011, 2, 2), - s(0b0010_0011, 2, 2), - s(0b0011_0010, 2, 2), - s(0b0001_0001_0111, 3, 3), // L, all four turns - s(0b0100_0100_0111, 3, 3), - s(0b0111_0100_0100, 3, 3), - s(0b0111_0001_0001, 3, 3), - s(0b0111_0100, 3, 2), // J, all four turns - s(0b0011_0001_0001, 2, 3), - s(0b0001_0111, 3, 2), - s(0b0010_0010_0011, 2, 3), - s(0b0010_0111, 3, 2), // T, all four turns - s(0b0001_0011_0001, 2, 3), - s(0b0100_0010, 3, 2), - s(0b0010_0011_0010, 2, 3), - s(0b0011_0110, 3, 2), // S and Z, flat and upright - s(0b0110_0011, 3, 2), - s(0b0001_0011_0010, 2, 3), - s(0b0010_0011_0001, 2, 3), - s(0b0011_0011_0011, 2, 3), // rectangles - s(0b0111_0111, 3, 2), -]; - -pub struct Game { - pub board: [u8; CELLS], - /// Shape index per tray slot, `None` once placed. - pub tray: [Option; 3], - pub score: u32, - pub best: u32, - pub over: bool, - /// Cells the last [`Game::clear`] emptied, 1 = cleared; the device animates them one by one. - pub cleared: [u8; CELLS], - /// Consecutive placements that cleared a line, 0..=10 (x1..x10). - pub streak: u8, - /// 0 = a colour per shape, 1..=8 = every piece in that colour. - pub colour: u8, - /// Placements without a clear since the last one; the streak survives two of them. - misses: u8, - rng: u32, -} - -/// Points for placing one piece: 30 for the dot up to 50 for the 3×3 square. -pub fn shape_points(shape: u8) -> u32 { - let cells = SHAPES[shape as usize].mask.count_ones(); - 30 + (cells - 1) * 5 / 2 -} - -impl Game { - pub fn new(seed: u32, best: u32) -> Game { - let mut g = Game { - board: [0; CELLS], - tray: [None; 3], - score: 0, - best, - over: false, - cleared: [0; CELLS], - streak: 0, - colour: 0, - misses: 0, - rng: seed | 1, - }; - g.fill_tray(); - g - } - - /// Replaces the tray's three pieces with new ones. - pub fn fill_tray(&mut self) { - for i in 0..3 { - self.tray[i] = Some(self.next_shape()); - } - } - - fn next(&mut self) -> u32 { - self.rng = self.rng.wrapping_mul(1_664_525).wrapping_add(1_013_904_223); - self.rng >> 8 - } - - fn next_shape(&mut self) -> u8 { - (self.next() % SHAPES.len() as u32) as u8 - } - - /// Colour of the block a shape would write at `(c, r)` top-left, or 0 if it doesn't fit. - pub fn fits(&self, shape: u8, c: usize, r: usize) -> bool { - let sh = &SHAPES[shape as usize]; - if c + sh.w as usize > SIDE || r + sh.h as usize > SIDE { - return false; - } - for dy in 0..sh.h as usize { - for dx in 0..sh.w as usize { - if sh.mask & (1 << (dy * 4 + dx)) != 0 && self.board[(r + dy) * SIDE + c + dx] != 0 - { - return false; - } - } - } - true - } - - /// Is there any free spot for any piece still in the tray? - pub fn any_fit(&self) -> bool { - self.tray - .iter() - .flatten() - .any(|&p| (0..SIDE).any(|r| (0..SIDE).any(|c| self.fits(p, c, r)))) - } - - /// Colour of the block a shape writes: the single-colour override, else one colour per shape. - pub fn colour_of(&self, shape: u8) -> u8 { - if self.colour != 0 { - self.colour - } else { - 1 + shape % COLOURS as u8 - } - } - - /// Places tray `slot` with its top-left at `(c, r)`. Returns how many lines cleared, or `None` if it doesn't fit. - /// Fills the tray and checks for the end of the game here, so the caller only redraws. - pub fn place(&mut self, slot: usize, c: usize, r: usize) -> Option { - let shape = self.tray.get(slot).copied().flatten()?; - if !self.fits(shape, c, r) { - return None; - } - let sh = &SHAPES[shape as usize]; - let colour = self.colour_of(shape); - for dy in 0..sh.h as usize { - for dx in 0..sh.w as usize { - if sh.mask & (1 << (dy * 4 + dx)) != 0 { - self.board[(r + dy) * SIDE + c + dx] = colour; - } - } - } - self.tray[slot] = None; - let lines = self.clear(); - let points = shape_points(shape); - if lines > 0 { - // every line cleared in a row raises the multiplier, x1 up to x10 - self.streak = (self.streak + 1).min(10); - self.misses = 0; - self.score += (points + lines as u32 * 20) * self.streak as u32; - } else { - // two quiet placements keep the streak; the third one in a row drops it - self.misses += 1; - if self.misses >= 3 { - self.streak = 0; - self.misses = 0; - } - self.score += points; - } - if self.tray.iter().all(|p| p.is_none()) { - self.fill_tray(); - } - if !self.any_fit() { - self.over = true; - if self.score > self.best { - self.best = self.score; - } - } - Some(lines) - } - - /// Empties every full row and column at once; returns how many lines went. Marks the cells in `cleared`. - pub fn clear(&mut self) -> usize { - let mut rows = 0u8; - let mut cols = 0u8; - for i in 0..SIDE { - let full_row = (0..SIDE).all(|c| self.board[i * SIDE + c] != 0); - let full_col = (0..SIDE).all(|r| self.board[r * SIDE + i] != 0); - if full_row { - rows |= 1 << i; - } - if full_col { - cols |= 1 << i; - } - } - self.cleared = [0; CELLS]; - for i in 0..SIDE { - for j in 0..SIDE { - if rows & (1 << i) != 0 || cols & (1 << j) != 0 { - self.board[i * SIDE + j] = 0; - self.cleared[i * SIDE + j] = 1; - } - } - } - rows.count_ones() as usize + cols.count_ones() as usize - } - - pub fn restart(&mut self, seed: u32) { - self.board = [0; CELLS]; - self.tray = [None; 3]; - self.score = 0; - self.over = false; - self.cleared = [0; CELLS]; - self.streak = 0; - self.misses = 0; - self.rng = seed | 1; - self.fill_tray(); - } -} - -/// Fills `out` with the indices of the cleared cells, nearest to the placed piece first; returns how many. -pub fn clear_order( - cleared: &[u8; CELLS], - shape: u8, - c: usize, - r: usize, - out: &mut [u8; CELLS], -) -> usize { - let sh = &SHAPES[shape as usize]; - // twice the cell coordinates, so the piece's centre stays whole - let ax = c as i32 * 2 + sh.w as i32 - 1; - let ay = r as i32 * 2 + sh.h as i32 - 1; - let d2 = |i: u8| { - let x = (i as i32 % SIDE as i32) * 2 - ax; - let y = (i as i32 / SIDE as i32) * 2 - ay; - x * x + y * y - }; - let mut n = 0; - for (i, &v) in cleared.iter().enumerate() { - if v != 0 { - out[n] = i as u8; - n += 1; - } - } - for a in 1..n { - let v = out[a]; - let mut b = a; - while b > 0 && d2(out[b - 1]) > d2(v) { - out[b] = out[b - 1]; - b -= 1; - } - out[b] = v; - } - n -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn shapes_fit_their_frame() { - for (i, sh) in SHAPES.iter().enumerate() { - assert!( - (1..=4).contains(&sh.w) && (1..=4).contains(&sh.h), - "shape {i} frame" - ); - let mut bits = 0; - for y in 0..sh.h { - for x in 0..sh.w { - if sh.mask & (1 << (y * 4 + x)) != 0 { - bits += 1; - } - } - } - assert!(bits > 0, "shape {i} has no blocks"); - // nothing outside the frame, or `fits` and `place` would disagree - let mut frame = 0u16; - for y in 0..sh.h { - for x in 0..sh.w { - frame |= 1 << (y * 4 + x); - } - } - assert_eq!( - sh.mask & !frame, - 0, - "shape {i} spills past {}x{}", - sh.w, - sh.h - ); - } - } - - #[test] - fn places_and_refuses_overlap_and_edges() { - let mut g = Game::new(7, 0); - g.tray = [Some(0), Some(0), Some(0)]; // a dot - assert!(g.place(0, 0, 0).is_some()); - assert!(g.place(0, 0, 0).is_none(), "occupied"); - g.tray = [Some(5), Some(5), Some(5)]; // four across - assert!(g.fits(5, 4, 0)); - assert!(!g.fits(5, 5, 0)); - assert!(!g.fits(5, 0, 8)); - assert_eq!(g.board[0], 1); - } - - #[test] - fn clears_row_and_column_together() { - let mut g = Game::new(1, 0); - for i in 0..SIDE { - g.board[i] = 3; - g.board[i * SIDE] = 3; - } - g.board[0] = 3; - assert_eq!(g.clear(), 2); - assert!(g.board.iter().all(|&b| b == 0)); - assert_eq!(g.cleared.iter().filter(|&&c| c != 0).count(), 15); - } - - #[test] - fn full_board_ends_the_game() { - let mut g = Game::new(1, 0); - g.board = [3; CELLS]; - assert!(!g.any_fit()); - g.board = [0; CELLS]; - g.board[0] = 3; - g.tray = [Some(0), Some(0), Some(0)]; // a dot still fits in a free cell - assert!(g.any_fit()); - } - - #[test] - fn score_goes_up_with_lines_and_best_stays() { - let mut g = Game::new(3, 5); - for c in 1..SIDE { - g.board[c] = 2; - } - g.tray = [Some(0), Some(1), Some(1)]; // a dot on the hole, others stay - assert_eq!(g.place(0, 0, 0), Some(1)); - assert_eq!(g.score, 50, "30 for the dot plus 20 for the line"); - assert_eq!(g.best, 5, "a new game keeps the stored best"); - // a 2×2 hole plus single holes on the diagonal: no full line, and after a dot only an L of 3 free cells - g.board = [4; CELLS]; - for (r, c) in [ - (2, 2), - (2, 3), - (3, 2), - (3, 3), - (0, 0), - (1, 1), - (4, 4), - (5, 5), - (6, 6), - (7, 7), - ] { - g.board[r * SIDE + c] = 0; - } - g.tray = [Some(0), Some(5), Some(5)]; - g.score = 70; - assert_eq!(g.place(0, 2, 2), Some(0)); - assert!(g.over); - assert_eq!( - g.best, 100, - "30 for the last dot, the record is updated at the end" - ); - } - - #[test] - fn streak_survives_two_misses_then_resets() { - let mut g = Game::new(1, 0); - g.tray = [Some(0), Some(0), Some(0)]; // dots - for c in 1..SIDE { - g.board[7 * SIDE + c] = 2; - } - assert_eq!(g.place(0, 0, 7), Some(1)); - assert_eq!((g.streak, g.score), (1, 50)); - for c in 1..SIDE { - g.board[6 * SIDE + c] = 2; - } - assert_eq!(g.place(1, 0, 6), Some(1)); - assert_eq!((g.streak, g.score), (2, 150), "the second clear is x2"); - // two placements without a clear keep the streak - assert_eq!(g.place(2, 4, 4), Some(0)); - assert_eq!((g.streak, g.score), (2, 180), "one miss is still x2"); - g.tray = [Some(0), Some(0), Some(0)]; - assert_eq!(g.place(0, 5, 5), Some(0)); - assert_eq!((g.streak, g.score), (2, 210), "two misses still x2"); - // the third miss in a row drops it - assert_eq!(g.place(1, 6, 6), Some(0)); - assert_eq!( - (g.streak, g.score), - (0, 240), - "the third miss drops the streak" - ); - // and a clear after the grace started it again at x1 - g.tray = [Some(0), Some(0), Some(0)]; - for c in 0..SIDE - 1 { - g.board[7 * SIDE + c] = 2; - } - assert_eq!(g.place(2, 7, 7), Some(1)); - assert_eq!((g.streak, g.score), (1, 240 + 50)); - } - - #[test] - fn random_play_never_leaves_the_board() { - for seed in 1..40u32 { - let mut g = Game::new(seed, 0); - for _ in 0..500 { - if g.over { - break; - } - let mut placed = false; - 'slots: for slot in 0..3 { - let Some(p) = g.tray[slot] else { continue }; - for r in 0..SIDE { - for c in 0..SIDE { - if g.fits(p, c, r) { - assert!(g.place(slot, c, r).is_some()); - placed = true; - break 'slots; - } - } - } - } - if !placed { - // a piece is still in the tray and none fits: the game must say so - assert!(g.over); - break; - } - } - assert!(g.board.iter().all(|&v| v <= COLOURS as u8)); - assert!(g.streak <= 10); - } - } - - #[test] - fn single_colour_overrides_every_piece() { - let mut g = Game::new(1, 0); - g.tray = [Some(0), Some(0), Some(0)]; - g.colour = 6; - assert_eq!(g.colour_of(0), 6); - assert_eq!(g.colour_of(30), 6); - assert_eq!(g.place(0, 0, 0), Some(0)); - assert_eq!(g.board[0], 6); - } - - #[test] - fn clear_order_starts_at_the_piece() { - let mut cleared = [0u8; CELLS]; - for c in 0..SIDE { - cleared[7 * SIDE + c] = 1; - } - let mut out = [0u8; CELLS]; - let n = clear_order(&cleared, 0, 0, 7, &mut out); // a dot in the left end of the bottom row - assert_eq!(n, SIDE); - assert_eq!( - usize::from(out[0]), - 7 * SIDE, - "the block under the piece goes first" - ); - assert_eq!( - usize::from(out[n - 1]), - 7 * SIDE + SIDE - 1, - "the far end last" - ); - } - - #[test] - fn restart_clears_everything() { - let mut g = Game::new(9, 0); - g.board = [2; CELLS]; - g.score = 40; - g.over = true; - g.streak = 4; - g.restart(11); - assert!(g.board.iter().all(|&b| b == 0)); - assert_eq!(g.score, 0); - assert!(!g.over); - assert_eq!(g.streak, 0); - assert!(g.tray.iter().all(|p| p.is_some())); - } -} diff --git a/apps/blocks/src/main.rs b/apps/blocks/src/main.rs deleted file mode 100644 index 70b4a45..0000000 --- a/apps/blocks/src/main.rs +++ /dev/null @@ -1,831 +0,0 @@ -//! Blocks: an 8×8 block puzzle in the spirit of Block Blast. The start screen has a title with blocks hanging from it, -//! Play, Themes and the best score. Tap a piece in the tray, then tap the board: a ghost of the piece appears centred on -//! the tap (green frame = fits, red = doesn't). Tap another cell to move the ghost, tap the same spot again to place it. -//! The SDK has no touch-move events, so this aim-then-confirm stands in for dragging. A full row or column clears, one -//! block at a time starting from the piece that finished the line. Consecutive clears raise the score multiplier -//! x1..x10, and two quiet placements keep it. Themes: dark, light, pastel; single-colour mode can paint every piece in -//! one colour, fixed or random. The crown steps the selected piece. Best score and the theme live in the storage blob. -#![cfg_attr( - any(target_os = "none", wp2_sim), - no_main, - cfg_attr(target_os = "none", no_std) -)] - -#[cfg_attr(not(any(target_os = "none", wp2_sim)), allow(dead_code))] -mod game; - -#[cfg(not(any(target_os = "none", wp2_sim)))] -fn main() {} - -#[cfg(any(target_os = "none", wp2_sim))] -mod device { - use crate::game::{CELLS, COLOURS, Game, SHAPES, SIDE, clear_order}; - use cmf_wp2_app::{Api, BUTTON, CROWN, Event, PAUSE, RESUME, TOUCH_DOWN}; - - cmf_wp2_app::entry!(main); - cmf_wp2_app::app_icon!(); - - const BASE: [u16; COLOURS] = [ - 0x3D7F, // sky blue - 0x2FE6, // green - 0x8B5D, // violet - 0xE2AD, // amber - 0xFC82, // orange - 0x2EAB, // teal - 0xF81F, // magenta - 0x07FF, // cyan - ]; - const ACCENT: u16 = 0xFD20; - const GHOST_OK: u16 = 0x07E0; - const GHOST_BAD: u16 = 0xF800; - - #[repr(u8)] - #[derive(Clone, Copy, PartialEq)] - enum Theme { - Dark = 0, - Light = 1, - Pastel = 2, - } - - impl Theme { - const ALL: [Theme; 3] = [Theme::Dark, Theme::Light, Theme::Pastel]; - const NAMES: [&'static str; 3] = ["DARK", "LIGHT", "PASTEL"]; - - fn from_u8(v: u8) -> Theme { - match v { - 1 => Theme::Light, - 2 => Theme::Pastel, - _ => Theme::Dark, - } - } - - fn bg(self) -> u16 { - match self { - Theme::Dark => 0x0000, - Theme::Light => 0xFFFF, - Theme::Pastel => 0xFFDE, - } - } - - fn text(self) -> u16 { - match self { - Theme::Dark => 0xFFFF, - _ => 0x0000, - } - } - - fn dim(self) -> u16 { - match self { - Theme::Dark => 0x8410, - Theme::Light => 0x4208, - Theme::Pastel => 0x5AEB, - } - } - - fn grid(self) -> u16 { - match self { - Theme::Dark => 0x2124, - Theme::Light => 0xC618, - Theme::Pastel => 0xE71C, - } - } - - fn panel(self) -> u16 { - match self { - Theme::Dark => 0x3186, - Theme::Light => 0x9CF3, - Theme::Pastel => 0xEF7D, - } - } - - fn piece(self, v: u8) -> u16 { - let c = BASE[(v as usize - 1).min(COLOURS - 1)]; - if self == Theme::Pastel { - mix_white(c) - } else { - c - } - } - - /// Dark outlines on light backgrounds, a darker shade of the block on the dark theme. - fn edge(self, c: u16) -> u16 { - if self == Theme::Dark { dim(c) } else { 0x0000 } - } - } - - #[derive(Clone, Copy)] - struct Settings { - theme: Theme, - single: bool, - /// 0 = a random colour each game, 1..=8 = that palette colour. - colour: u8, - } - - impl Settings { - const fn new() -> Settings { - Settings { - theme: Theme::Dark, - single: false, - colour: 0, - } - } - } - - #[derive(Clone, Copy, PartialEq)] - enum Screen { - Menu, - Themes, - Game, - } - - const CELL: i16 = 38; - const BX: i16 = 81; - const BY: i16 = 56; - const TRAY_Y: i16 = 372; - const SLOT_W: i16 = 76; - const SLOT_X0: i16 = 119; - - const BTN_W: i16 = 200; - const BTN_H: i16 = 56; - const BTN_X: i16 = (466 - BTN_W) / 2; - const PLAY_Y: i16 = 232; - const THEMES_Y: i16 = 300; - - const ROW_X: i16 = 83; - const ROW_W: i16 = 300; - const ROW_H: i16 = 40; - const ROW_Y: [i16; 3] = [60, 106, 152]; - const TOGGLE_Y: i16 = 206; - - const SW: i16 = 32; - const SW_GAP: i16 = 4; - const SW_X0: i16 = 73; - const SW_Y: i16 = 266; - - const BACK_X: i16 = 153; - const BACK_Y: i16 = 366; - const BACK_W: i16 = 160; - const BACK_H: i16 = 44; - - static mut GAME: Option = None; - static mut STORE: [u8; 16] = [0; 16]; - - fn centre(api: &Api, y: i16, s: &str, c: u16) { - let w = s.chars().count() as i16 * 16; - api.text((api.width as i16 - w) / 2, y, s, c); - } - - fn num_str(mut n: u32, buf: &mut [u8; 10]) -> &str { - let mut d = 0; - loop { - buf[d] = b'0' + (n % 10) as u8; - d += 1; - n /= 10; - if n == 0 { - break; - } - } - buf[..d].reverse(); - core::str::from_utf8(&buf[..d]).unwrap_or("?") - } - - fn number(api: &Api, y: i16, prefix: &str, n: u32, c: u16) { - let mut buf = [0u8; 24]; - let mut len = 0; - for b in prefix.bytes() { - buf[len] = b; - len += 1; - } - let mut digits = [0u8; 10]; - let mut d = 0; - let mut v = n; - loop { - digits[d] = b'0' + (v % 10) as u8; - d += 1; - v /= 10; - if v == 0 { - break; - } - } - while d > 0 { - d -= 1; - buf[len] = digits[d]; - len += 1; - } - centre(api, y, core::str::from_utf8(&buf[..len]).unwrap_or(""), c); - } - - /// Half brightness, for a block's outline on the dark theme. - fn dim(c: u16) -> u16 { - (c >> 1) & 0x7BEF - } - - /// A quarter step towards white, for a block's top edge. - fn bright(c: u16) -> u16 { - let r = (c >> 11) & 0x1F; - let g = (c >> 5) & 0x3F; - let b = c & 0x1F; - ((r + (31 - r) / 3) << 11) | ((g + (63 - g) / 3) << 5) | (b + (31 - b) / 3) - } - - /// Halfway to white, for the pastel palette. - fn mix_white(c: u16) -> u16 { - let r = (c >> 11) & 0x1F; - let g = (c >> 5) & 0x3F; - let b = c & 0x1F; - ((r + (31 - r) / 2) << 11) | ((g + (63 - g) / 2) << 5) | (b + (31 - b) / 2) - } - - /// A rounded rectangle with a 2 px corner cut, for buttons, rows and the switch track. - fn panel_rect(api: &Api, x: i16, y: i16, w: i16, h: i16, fill: u16, edge: u16) { - api.rect(x + 2, y, (w - 4) as u16, h as u16, edge); - api.rect(x, y + 2, w as u16, (h - 4) as u16, edge); - api.rect(x + 3, y + 2, (w - 6) as u16, (h - 4) as u16, fill); - api.rect(x + 2, y + 3, (w - 4) as u16, (h - 6) as u16, fill); - } - - /// A block with slightly rounded corners, a darker outline and a light top edge. - fn block(api: &Api, x: i16, y: i16, w: i16, colour: u16, theme: Theme) { - let edge = theme.edge(colour); - api.rect(x + 2, y, (w - 4) as u16, w as u16, edge); - api.rect(x, y + 2, w as u16, (w - 4) as u16, edge); - api.rect(x + 3, y + 2, (w - 6) as u16, (w - 4) as u16, colour); - api.rect(x + 2, y + 3, (w - 4) as u16, (w - 6) as u16, colour); - api.rect(x + 4, y + 3, (w - 8) as u16, 2, bright(colour)); - } - - /// The same look at tray size, where a 2 px radius would eat the block. - fn mini_block(api: &Api, x: i16, y: i16, w: i16, colour: u16, theme: Theme) { - let edge = theme.edge(colour); - api.rect(x + 1, y, (w - 2) as u16, w as u16, edge); - api.rect(x, y + 1, w as u16, (w - 2) as u16, edge); - api.rect(x + 2, y + 1, (w - 4) as u16, (w - 2) as u16, colour); - api.rect(x + 1, y + 2, (w - 2) as u16, (w - 4) as u16, colour); - } - - fn draw_board(api: &Api, board: &[u8; CELLS], theme: Theme) { - let end = CELL * SIDE as i16; - api.rect( - BX - 4, - BY - 4, - (end + 8) as u16, - (end + 8) as u16, - theme.bg(), - ); - for i in 0..SIDE as i16 { - for j in 0..SIDE as i16 { - let x = BX + j * CELL; - let y = BY + i * CELL; - let v = board[(i * SIDE as i16 + j) as usize]; - if v == 0 { - api.rect( - x + 1, - y + 1, - (CELL - 2) as u16, - (CELL - 2) as u16, - theme.grid(), - ); - } else { - block(api, x + 1, y + 1, CELL - 2, theme.piece(v), theme); - } - } - } - } - - fn draw_status(api: &Api, g: &Game, shown: u32, theme: Theme) { - api.rect(0, 0, api.width, (BY - 4) as u16, theme.bg()); - number(api, 18, "score ", shown, theme.text()); - let mut db = [0u8; 10]; - let best = num_str(g.best.max(shown), &mut db); - let mut sb = [0u8; 10]; - let streak = if g.streak >= 1 { - Some(num_str(g.streak as u32, &mut sb)) - } else { - None - }; - let mut chars = 5 + best.len() as i16; - if let Some(s) = streak { - chars += 2 + s.len() as i16; - } - let mut x = (api.width as i16 - chars * 16) / 2; - api.text(x, 36, "best ", theme.dim()); - x += 5 * 16; - api.text(x, 36, best, theme.dim()); - x += best.len() as i16 * 16; - if let Some(s) = streak { - api.text(x, 36, " x", ACCENT); - x += 2 * 16; - api.text(x, 36, s, ACCENT); - } - } - - /// Top-left `(column, row)` of the ghost piece, set by the first tap on the board. - type Ghost = Option<(usize, usize)>; - - fn draw_tray(api: &Api, g: &Game, selected: Option, theme: Theme) { - for slot in 0..3 { - let x = SLOT_X0 + slot as i16 * SLOT_W; - api.rect( - x, - TRAY_Y, - (SLOT_W - 4) as u16, - 56, - if Some(slot) == selected { - theme.panel() - } else { - theme.bg() - }, - ); - let Some(p) = g.tray[slot] else { continue }; - let sh = &SHAPES[p as usize]; - let mini = 10i16; - let w = sh.w as i16 * mini; - let h = sh.h as i16 * mini; - let ox = x + (SLOT_W - 4 - w) / 2; - let oy = TRAY_Y + (56 - h) / 2; - let colour = theme.piece(g.colour_of(p)); - for dy in 0..sh.h as i16 { - for dx in 0..sh.w as i16 { - if sh.mask & (1 << (dy * 4 + dx)) != 0 { - mini_block(api, ox + dx * mini, oy + dy * mini, mini, colour, theme); - } - } - } - } - } - - fn draw_game( - api: &Api, - g: &Game, - selected: Option, - ghost: Ghost, - shown: u32, - theme: Theme, - ) { - api.rect(0, 0, api.width, api.height, theme.bg()); - draw_status(api, g, shown, theme); - draw_board(api, &g.board, theme); - if let (Some(slot), Some((gc, gr))) = (selected, ghost) { - if let Some(p) = g.tray[slot] { - let sh = &SHAPES[p as usize]; - let ok = g.fits(p, gc, gr); - let edge = if ok { GHOST_OK } else { GHOST_BAD }; - for dy in 0..sh.h as usize { - for dx in 0..sh.w as usize { - if sh.mask & (1 << (dy * 4 + dx)) == 0 { - continue; - } - let x = BX + (gc + dx) as i16 * CELL; - let y = BY + (gr + dy) as i16 * CELL; - // a coloured frame; inside, the piece itself if it fits, else what lies underneath - let v = g.board[(gr + dy) * SIDE + gc + dx]; - let inner = if ok { - theme.piece(g.colour_of(p)) - } else if v == 0 { - theme.grid() - } else { - theme.piece(v) - }; - api.rect(x + 1, y + 1, (CELL - 2) as u16, (CELL - 2) as u16, edge); - api.rect(x + 5, y + 5, (CELL - 10) as u16, (CELL - 10) as u16, inner); - } - } - } - } - draw_tray(api, g, selected, theme); - if g.over { - api.rect(70, 176, 326, 116, theme.panel()); - centre(api, 190, "GAME OVER", ACCENT); - number(api, 216, "score ", g.score, theme.text()); - centre(api, 250, "tap to play again", theme.dim()); - } - api.show(); - } - - /// One block hanging from the bar under the title. - fn hang(api: &Api, theme: Theme, string_x: i16, left: i16, top: i16, size: i16, colour: u8) { - api.rect(string_x, 116, 2, (top - 116) as u16, theme.dim()); - block(api, left, top, size, theme.piece(colour), theme); - } - - fn draw_menu(api: &Api, best: u32, settings: Settings) { - let t = settings.theme; - api.rect(0, 0, api.width, api.height, t.bg()); - let x = (api.width as i16 - 6 * 16) / 2; - api.text(x + 2, 72, "BLOCKS", t.dim()); - api.text(x, 70, "BLOCKS", t.text()); - centre(api, 94, "a tiny puzzle", t.dim()); - api.rect(163, 116, 140, 2, t.dim()); - hang(api, t, 182, 170, 152, 24, 1); - hang(api, t, 214, 204, 176, 20, 3); - hang(api, t, 249, 234, 144, 30, 5); - hang(api, t, 282, 272, 168, 20, 7); - panel_rect(api, BTN_X, PLAY_Y, BTN_W, BTN_H, ACCENT, t.edge(ACCENT)); - centre(api, PLAY_Y + 20, "PLAY", 0x0000); - panel_rect( - api, - BTN_X, - THEMES_Y, - BTN_W, - BTN_H, - t.panel(), - t.edge(t.panel()), - ); - centre(api, THEMES_Y + 20, "THEMES", t.text()); - number(api, 392, "best ", best, t.dim()); - api.show(); - } - - fn swatch(api: &Api, x: i16, y: i16, colour: u8, theme: Theme, selected: bool) { - if selected { - api.rect(x - 3, y - 3, (SW + 6) as u16, (SW + 6) as u16, theme.text()); - } - block(api, x, y, SW, theme.piece(colour), theme); - } - - fn draw_themes(api: &Api, settings: Settings) { - let t = settings.theme; - api.rect(0, 0, api.width, api.height, t.bg()); - centre(api, 22, "THEMES", t.text()); - for i in 0..3 { - let y = ROW_Y[i]; - let sel = t == Theme::ALL[i]; - let fill = if sel { t.panel() } else { t.bg() }; - let edge = if sel { t.panel() } else { t.grid() }; - panel_rect(api, ROW_X, y, ROW_W, ROW_H, fill, edge); - centre( - api, - y + 12, - Theme::NAMES[i], - if sel { t.text() } else { t.dim() }, - ); - } - panel_rect(api, ROW_X, TOGGLE_Y, ROW_W, ROW_H, t.bg(), t.grid()); - api.text(ROW_X + 12, TOGGLE_Y + 12, "SINGLE COLOUR", t.text()); - let tx = ROW_X + ROW_W - 60; - let track = if settings.single { ACCENT } else { t.grid() }; - panel_rect(api, tx, TOGGLE_Y + 10, 48, 20, track, t.edge(track)); - let knob = if settings.single { tx + 30 } else { tx + 2 }; - panel_rect(api, knob, TOGGLE_Y + 12, 16, 16, t.text(), t.text()); - if settings.single { - for i in 0..8u8 { - let x = SW_X0 + i as i16 * (SW + SW_GAP); - swatch(api, x, SW_Y, i + 1, t, settings.colour == i + 1); - } - let x = SW_X0 + 8 * (SW + SW_GAP); - if settings.colour == 0 { - api.rect(x - 3, SW_Y - 3, (SW + 6) as u16, (SW + 6) as u16, t.text()); - } - panel_rect(api, x, SW_Y, SW, SW, t.panel(), t.edge(t.panel())); - api.text(x + 8, SW_Y + 8, "?", t.text()); - } - panel_rect( - api, - BACK_X, - BACK_Y, - BACK_W, - BACK_H, - t.panel(), - t.edge(t.panel()), - ); - centre(api, BACK_Y + 14, "BACK", t.text()); - api.show(); - } - - fn hit(e: &Event, x: i16, y: i16, w: i16, h: i16) -> bool { - e.x >= x && e.x < x + w && e.y >= y && e.y < y + h - } - - fn resolve_colour(s: Settings, seed: u32) -> u8 { - if !s.single { - 0 - } else if s.colour == 0 { - 1 + ((seed >> 8) % COLOURS as u32) as u8 - } else { - s.colour - } - } - - fn save_state(api: &Api, best: u32, s: Settings) { - let blob = unsafe { &mut *core::ptr::addr_of_mut!(STORE) }; - blob[..2].copy_from_slice(b"B2"); - blob[2..6].copy_from_slice(&best.to_le_bytes()); - blob[6] = s.theme as u8; - blob[7] = s.single as u8; - blob[8] = s.colour; - api.save(&blob[..9]); - } - - fn load_state(api: &Api) -> (u32, Settings) { - let blob = unsafe { &mut *core::ptr::addr_of_mut!(STORE) }; - let n = api.load(blob); - let mut best = 0; - let mut s = Settings::new(); - if n >= 6 && &blob[..2] == b"B1" { - best = u32::from_le_bytes([blob[2], blob[3], blob[4], blob[5]]); - } - if n >= 9 && &blob[..2] == b"B2" { - best = u32::from_le_bytes([blob[2], blob[3], blob[4], blob[5]]); - s.theme = Theme::from_u8(blob[6]); - s.single = blob[7] != 0; - s.colour = blob[8].min(COLOURS as u8); - } - (best, s) - } - - /// Blinks the cleared cells out one by one, from the piece that finished the line outwards. - /// `before` is the board before the piece was placed. Returns false if the user asked to leave. - fn animate_clear( - api: &Api, - g: &Game, - before: &[u8; CELLS], - shape: u8, - c: usize, - r: usize, - cleared: &[u8; CELLS], - theme: Theme, - colour: u8, - ) -> bool { - let mut anim = *before; - let sh = &SHAPES[shape as usize]; - for dy in 0..sh.h as usize { - for dx in 0..sh.w as usize { - if sh.mask & (1 << (dy * 4 + dx)) != 0 { - anim[(r + dy) * SIDE + c + dx] = colour; - } - } - } - let mut order = [0u8; CELLS]; - let n = clear_order(cleared, shape, c, r, &mut order); - if n == 0 { - return true; - } - // one block per step, the whole line in about a quarter of a second - let delay = (300 / n as u32).clamp(12, 45); - draw_tray(api, g, None, theme); - for &i in &order[..n] { - anim[i as usize] = 0; - draw_board(api, &anim, theme); - api.show(); - if let Some(e) = api.event(delay) { - if e.kind == BUTTON { - return false; - } - } - } - true - } - - /// Counts the score up in a few quick steps. Returns false if the user asked to leave. - fn animate_score(api: &Api, g: &Game, shown: &mut u32, theme: Theme) -> bool { - let target = g.score; - if *shown == target { - return true; - } - let from = *shown; - for i in 1..=4 { - *shown = from + (target - from) * i / 4; - draw_status(api, g, *shown, theme); - api.show(); - if let Some(e) = api.event(18) { - if e.kind == BUTTON { - *shown = target; - return false; - } - } - } - *shown = target; - true - } - - fn main(api: &'static Api) -> i32 { - let (mut best, mut settings) = load_state(api); - let mut screen = Screen::Menu; - let mut selected: Option = None; - let mut ghost: Ghost = None; - let mut shown = 0u32; // the score on screen, tweened towards game.score - let mut buzz_off: Option = None; - let mut paused = false; - draw_menu(api, best, settings); - loop { - let now = api.now(); - if let Some(t) = buzz_off { - if (now.wrapping_sub(t) as i32) >= 0 { - api.vibrate(0, 31); - buzz_off = None; - } - } - let timeout = if paused { - u32::MAX - } else { - buzz_off.map_or(u32::MAX, |t| (t.wrapping_sub(now) as i32).max(0) as u32) - }; - let Some(e) = api.event(timeout) else { - continue; - }; - match screen { - Screen::Menu => match e.kind { - BUTTON => { - api.vibrate(0, 31); - return 0; - } - PAUSE => paused = true, - RESUME => { - paused = false; - draw_menu(api, best, settings); - } - TOUCH_DOWN if !paused => { - if hit(&e, BTN_X, PLAY_Y, BTN_W, BTN_H) { - let seed = api.now() | 1; - let g = unsafe { &mut *core::ptr::addr_of_mut!(GAME) }; - let mut game = Game::new(seed, best); - game.colour = resolve_colour(settings, seed); - *g = Some(game); - selected = None; - ghost = None; - shown = 0; - screen = Screen::Game; - draw_game( - api, - g.as_ref().unwrap(), - selected, - ghost, - shown, - settings.theme, - ); - } else if hit(&e, BTN_X, THEMES_Y, BTN_W, BTN_H) { - screen = Screen::Themes; - draw_themes(api, settings); - } - } - _ => {} - }, - Screen::Themes => match e.kind { - BUTTON => { - api.vibrate(0, 31); - return 0; - } - PAUSE => paused = true, - RESUME => { - paused = false; - draw_themes(api, settings); - } - TOUCH_DOWN if !paused => { - let mut changed = false; - for i in 0..3 { - if settings.theme != Theme::ALL[i] - && hit(&e, ROW_X, ROW_Y[i], ROW_W, ROW_H) - { - settings.theme = Theme::ALL[i]; - changed = true; - } - } - if hit(&e, ROW_X, TOGGLE_Y, ROW_W, ROW_H) { - settings.single = !settings.single; - changed = true; - } - if settings.single && e.y >= SW_Y && e.y < SW_Y + SW && e.x >= SW_X0 { - let i = (e.x - SW_X0) / (SW + SW_GAP); - if i < 9 && (e.x - SW_X0) % (SW + SW_GAP) < SW { - let c = if i == 8 { 0 } else { (i + 1) as u8 }; - if settings.colour != c { - settings.colour = c; - changed = true; - } - } - } - if hit(&e, BACK_X, BACK_Y, BACK_W, BACK_H) { - screen = Screen::Menu; - draw_menu(api, best, settings); - continue; - } - if changed { - save_state(api, best, settings); - draw_themes(api, settings); - } - } - _ => {} - }, - Screen::Game => { - let g = unsafe { &mut *core::ptr::addr_of_mut!(GAME) }; - let Some(game) = g.as_mut() else { continue }; - match e.kind { - BUTTON => { - api.vibrate(0, 31); - return 0; - } - PAUSE => paused = true, - RESUME => { - paused = false; - draw_game(api, game, selected, ghost, shown, settings.theme); - } - CROWN if !paused => { - if game.over { - continue; - } - ghost = None; - let step = if e.delta < 0 { 2 } else { 1 }; // +2 mod 3 steps back - let mut at = selected.map_or(0, |s| s + 1) % 3; - for _ in 0..3 { - if game.tray[at].is_some() { - selected = Some(at); - break; - } - at = (at + step) % 3; - } - draw_game(api, game, selected, ghost, shown, settings.theme); - } - TOUCH_DOWN if !paused => { - if game.over { - let seed = api.now() | 1; - game.restart(seed); - game.colour = resolve_colour(settings, seed); - selected = None; - ghost = None; - shown = 0; - draw_game(api, game, selected, ghost, shown, settings.theme); - continue; - } - if e.y >= TRAY_Y - && e.y < TRAY_Y + 56 - && e.x >= SLOT_X0 - && e.x < SLOT_X0 + SLOT_W * 3 - { - let slot = ((e.x - SLOT_X0) / SLOT_W) as usize; - if game.tray[slot].is_some() { - selected = if selected == Some(slot) { - None - } else { - Some(slot) - }; - ghost = None; - draw_game(api, game, selected, ghost, shown, settings.theme); - } - continue; - } - let Some(slot) = selected else { continue }; - let board_end = CELL * SIDE as i16; - if e.y < BY - || e.y >= BY + board_end - || e.x < BX - || e.x >= BX + board_end - { - continue; - } - let Some(p) = game.tray[slot] else { continue }; - let sh = &SHAPES[p as usize]; - let (w, h, side) = (sh.w as i16, sh.h as i16, SIDE as i16); - // the tap lands on the middle of the piece, so the finger doesn't hide it - let c = ((e.x - BX) / CELL - (w - 1) / 2).clamp(0, side - w) as usize; - let r = ((e.y - BY) / CELL - (h - 1) / 2).clamp(0, side - h) as usize; - if ghost != Some((c, r)) { - // first tap, or a tap elsewhere: aim the ghost here - ghost = Some((c, r)); - draw_game(api, game, selected, ghost, shown, settings.theme); - continue; - } - // second tap on the same spot: place it (a red ghost just stays) - let before = game.board; - let colour = game.colour_of(p); - let Some(lines) = game.place(slot, c, r) else { - continue; - }; - selected = None; - ghost = None; - if lines > 0 { - if api.vibrate(500, 31) == 0 { - buzz_off = Some(api.now().wrapping_add(45)); - } - if !animate_clear( - api, - game, - &before, - p, - c, - r, - &game.cleared, - settings.theme, - colour, - ) { - api.vibrate(0, 31); - return 0; - } - } - if game.over { - best = game.best; - save_state(api, best, settings); - shown = game.score; - } - draw_game(api, game, selected, ghost, shown, settings.theme); - if !game.over && !animate_score(api, game, &mut shown, settings.theme) { - api.vibrate(0, 31); - return 0; - } - } - _ => {} - } - } - } - } - } -} diff --git a/apps/blocks/store.md b/apps/blocks/store.md deleted file mode 100644 index d633679..0000000 --- a/apps/blocks/store.md +++ /dev/null @@ -1,13 +0,0 @@ -An 8×8 block puzzle. Three pieces wait in the tray; tap one, tap the board to aim a ghost, then tap the same cell again -to place it. Complete a row or a column and it clears one block at a time, starting from the piece that finished the -line. - -Consecutive clears raise a score multiplier from x1 up to x10. The multiplier survives two placements without a clear; -a third one resets it. Bigger pieces and more lines score more, and the best score stays on the watch. - -Three themes — dark, light and pastel — plus a single-colour mode that paints every piece in one of eight colours or a -random colour for each game. The crown steps through the tray, and a tap on the tray picks a piece directly. - -## Requirements - -The [patched firmware](/firmware) and the [App Loader](/firmware). diff --git a/apps/blocks/store.toml b/apps/blocks/store.toml deleted file mode 100644 index 21fb35a..0000000 --- a/apps/blocks/store.toml +++ /dev/null @@ -1,4 +0,0 @@ -name = "Blocks" -summary = "A block puzzle with combos, streaks and themes" -version = "0.1.0" -author = "defaulty01" diff --git a/apps/calendar/Cargo.toml b/apps/calendar/Cargo.toml deleted file mode 100644 index 7bb40b0..0000000 --- a/apps/calendar/Cargo.toml +++ /dev/null @@ -1,17 +0,0 @@ -[package] -name = "calendar" -edition.workspace = true -license.workspace = true -version.workspace = true - -[dependencies] -cmf-wp2-app.workspace = true -cmf-wp2-ui.workspace = true -companion-rpc.workspace = true - -[dev-dependencies] -wp2-core.workspace = true - -[[bin]] -name = "calendar" -bench = false diff --git a/apps/calendar/icon.svg b/apps/calendar/icon.svg deleted file mode 100644 index 5347c55..0000000 --- a/apps/calendar/icon.svg +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/apps/calendar/shots/card.png b/apps/calendar/shots/card.png deleted file mode 100644 index ee2b8c8..0000000 Binary files a/apps/calendar/shots/card.png and /dev/null differ diff --git a/apps/calendar/shots/day.png b/apps/calendar/shots/day.png deleted file mode 100644 index 4d4ab7c..0000000 Binary files a/apps/calendar/shots/day.png and /dev/null differ diff --git a/apps/calendar/shots/month.png b/apps/calendar/shots/month.png deleted file mode 100644 index 9f966a4..0000000 Binary files a/apps/calendar/shots/month.png and /dev/null differ diff --git a/apps/calendar/shots/page.png b/apps/calendar/shots/page.png deleted file mode 100644 index 0496b6a..0000000 Binary files a/apps/calendar/shots/page.png and /dev/null differ diff --git a/apps/calendar/src/date.rs b/apps/calendar/src/date.rs deleted file mode 100644 index 8004b59..0000000 --- a/apps/calendar/src/date.rs +++ /dev/null @@ -1,171 +0,0 @@ -//! Gregorian dates for a month grid: weeks start on Monday, six rows of seven days. - -#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)] -pub struct Month { - pub year: u16, - /// 1..=12 - pub month: u8, -} - -#[derive(Clone, Copy, Debug, PartialEq, Eq)] -pub struct Day { - pub month: Month, - /// 1..=31 - pub day: u8, -} - -pub const NAMES: [&str; 12] = [ - "january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", - "december", -]; -pub const SHORT: [&str; 12] = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]; -/// Monday first, as the grid. -pub const WEEKDAYS: [&str; 7] = ["mo", "tu", "we", "th", "fr", "sa", "su"]; -pub const WEEKDAY_NAMES: [&str; 7] = ["monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"]; -pub const ROWS: usize = 6; -pub const CELLS: usize = ROWS * 7; - -pub fn leap(year: u16) -> bool { - (year % 4 == 0 && year % 100 != 0) || year % 400 == 0 -} - -impl Month { - /// `None` for a month outside 1..=12 or a year outside 1970..=2199 (what the grid and the protocol accept). - pub fn new(year: u16, month: u8) -> Option { - ((1..=12).contains(&month) && (1970..=2199).contains(&year)).then_some(Month { year, month }) - } - - pub fn days(self) -> u8 { - match self.month { - 2 if leap(self.year) => 29, - 2 => 28, - 4 | 6 | 9 | 11 => 30, - _ => 31, - } - } - - /// `n` months later (negative: earlier). - pub fn add(self, n: i32) -> Month { - let i = self.year as i32 * 12 + self.month as i32 - 1 + n; - Month { year: i.div_euclid(12) as u16, month: (i.rem_euclid(12) + 1) as u8 } - } - - /// Weekday of the 1st, 0 = Monday. - pub fn first_weekday(self) -> u8 { - weekday(Day { month: self, day: 1 }) - } - - pub fn name(self) -> &'static str { - NAMES[self.month as usize - 1] - } -} - -/// 0 = Monday (Sakamoto's method). -pub fn weekday(d: Day) -> u8 { - const T: [u16; 12] = [0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4]; - let m = d.month.month as usize; - let y = d.month.year - (m < 3) as u16; - let sunday0 = (y + y / 4 - y / 100 + y / 400 + T[m - 1] + d.day as u16) % 7; - ((sunday0 + 6) % 7) as u8 -} - -/// The 42 days of `m`'s grid: the tail of the month before, `m`, the head of the next. -pub fn grid(m: Month) -> [Day; CELLS] { - let lead = m.first_weekday() as i32; - let prev = m.add(-1); - let mut out = [Day { month: m, day: 1 }; CELLS]; - for (i, cell) in out.iter_mut().enumerate() { - let n = i as i32 - lead + 1; // day number within m - *cell = if n < 1 { - Day { month: prev, day: (prev.days() as i32 + n) as u8 } - } else if n > m.days() as i32 { - Day { month: m.add(1), day: (n - m.days() as i32) as u8 } - } else { - Day { month: m, day: n as u8 } - }; - } - out -} - -/// The Monday-to-Sunday week of `d`. -pub fn week(d: Day) -> [Day; 7] { - let g = grid(d.month); - let i = g.iter().position(|c| *c == d).unwrap_or(0); - let start = i - i % 7; - let mut out = [d; 7]; - out.copy_from_slice(&g[start..start + 7]); - out -} - -#[cfg(test)] -mod tests { - use super::*; - - fn m(y: u16, mo: u8) -> Month { - Month::new(y, mo).unwrap() - } - - #[test] - fn month_lengths_and_leap_years() { - assert_eq!(m(2026, 2).days(), 28); - assert_eq!(m(2028, 2).days(), 29); - assert_eq!(m(2100, 2).days(), 28); - assert_eq!(m(2000, 2).days(), 29); - assert_eq!(m(2026, 11).days(), 30); - assert_eq!(m(2026, 12).days(), 31); - } - - #[test] - fn months_add_across_years() { - assert_eq!(m(2026, 11).add(2), m(2027, 1)); - assert_eq!(m(2026, 1).add(-1), m(2025, 12)); - assert_eq!(m(2026, 1).add(-13), m(2024, 12)); - assert_eq!(m(2026, 5).add(0), m(2026, 5)); - } - - #[test] - fn weekdays() { - // 2026-11-15 is a Sunday, 2026-11-01 too; 2000-01-01 a Saturday; 2024-02-29 a Thursday - assert_eq!(weekday(Day { month: m(2026, 11), day: 15 }), 6); - assert_eq!(m(2026, 11).first_weekday(), 6); - assert_eq!(m(2000, 1).first_weekday(), 5); - assert_eq!(weekday(Day { month: m(2024, 2), day: 29 }), 3); - assert_eq!(m(2026, 12).first_weekday(), 1); - } - - #[test] - fn november_2026_grid_matches_a_wall_calendar() { - let g = grid(m(2026, 11)); - // starts on Monday 26 October, as the reference screenshot - assert_eq!(g[0], Day { month: m(2026, 10), day: 26 }); - assert_eq!(g[6], Day { month: m(2026, 11), day: 1 }); - assert_eq!(g[34], Day { month: m(2026, 11), day: 29 }); - assert_eq!(g[35], Day { month: m(2026, 11), day: 30 }); - assert_eq!(g[41], Day { month: m(2026, 12), day: 6 }); - // every day of the month once, in order - let days: std::vec::Vec = g.iter().filter(|d| d.month == m(2026, 11)).map(|d| d.day).collect(); - assert_eq!(days, (1..=30).collect::>()); - } - - #[test] - fn a_month_starting_on_monday_has_no_lead() { - // June 2026 starts on a Monday - assert_eq!(grid(m(2026, 6))[0], Day { month: m(2026, 6), day: 1 }); - } - - #[test] - fn week_of_a_day() { - let w = week(Day { month: m(2026, 11), day: 15 }); - assert_eq!(w[0], Day { month: m(2026, 11), day: 9 }); - assert_eq!(w[6], Day { month: m(2026, 11), day: 15 }); - let w = week(Day { month: m(2026, 12), day: 1 }); - assert_eq!(w[0], Day { month: m(2026, 11), day: 30 }); - } - - #[test] - fn bad_months_are_refused() { - assert!(Month::new(2026, 0).is_none()); - assert!(Month::new(2026, 13).is_none()); - assert!(Month::new(1969, 5).is_none()); - } -} diff --git a/apps/calendar/src/main.rs b/apps/calendar/src/main.rs deleted file mode 100644 index 1bc5143..0000000 --- a/apps/calendar/src/main.rs +++ /dev/null @@ -1,356 +0,0 @@ -//! calendar: a month grid with a dot per calendar on the days that have events, and today in a widget. -//! -//! - From the Apps menu: the month view. `<` `>` change the month (in place, `screen::month_turn`), a tap on the -//! title goes back to today's month, a tap on a day with events lists them; a tap on that title or BUTTON (the -//! right swipe, `own_back`) comes back. BUTTON on the month exits. -//! - As the page next to the watch face (`app_features!(PAGE)`): the week and a day's events. A tap on the date -//! opens the month view, a tap on its title comes back. -//! - The card left of the watch face (`app_features!(WIDGET)`): "Sun 15 Nov" and today's count. -//! -//! Events for the coming week come from FMC Companion on the phone (`calendar.events`, the `companion-rpc` crate); the watch keeps -//! the last answer (`model.rs`) and turns it into a count and calendar-coloured dots per day (`marks.rs`). Without -//! the phone the calendar works and says "not synced". -#![cfg_attr(target_os = "none", no_std, no_main)] - -#[cfg_attr(not(target_os = "none"), allow(dead_code))] -mod date; -#[cfg_attr(not(target_os = "none"), allow(dead_code))] -mod marks; -#[cfg_attr(not(target_os = "none"), allow(dead_code))] -mod model; -#[cfg_attr(not(target_os = "none"), allow(dead_code))] -mod screen; - -#[cfg(not(target_os = "none"))] -fn main() {} - -#[cfg(target_os = "none")] -mod device { - use crate::date::{Day, Month}; - use crate::marks::Marks; - use crate::model::{BLOB_MAX, Got, Model, wall_min}; - use crate::screen::{self, DayView, EventView, MonthView, WidgetView}; - use cmf_wp2_app::lv::{Batch, Lv, LvError}; - use cmf_wp2_app::{Api, BUTTON, LV, MESSAGE, MSG_MAX, PAUSE, RESUME}; - - cmf_wp2_app::entry!(main); - cmf_wp2_app::app_icon!(); - cmf_wp2_app::app_features!(cmf_wp2_app::WIDGET | cmf_wp2_app::PAGE); - - const CLICKED: i16 = 7; - /// How often to look at the clock (a new day). - const TICK_MS: u32 = 30_000; - const FALLBACK: Month = Month { year: 2026, month: 1 }; - - // read by an emulator e2e: last submit result, view (1 month, 2 widget), shown month (yyyymm), phone answers - const RC: usize = 0; - const VIEW: usize = 1; - const SHOWN: usize = 2; - const SYNCS: usize = 3; - // non-zero: in .data, fresh at every launch; RC 1 until the first screen is up - #[unsafe(no_mangle)] - static mut STATS: [i32; 4] = [1, 0, 0, 0]; - static mut STORE: [u8; BLOB_MAX] = [0; BLOB_MAX]; - // ponytail: ~4.6 KB of events, kept off the 8 KiB stack - static mut MODEL: Model = Model::new(); - - fn set(i: usize, v: i32) { - unsafe { (&raw mut STATS[i]).write_volatile(v) } - } - fn get(i: usize) -> i32 { - unsafe { (&raw const STATS[i]).read_volatile() } - } - fn code(r: Result<(), LvError>) -> i32 { - match r { - Ok(()) => 0, - Err(LvError::Code(c)) => c, - Err(_) => -1000, - } - } - - fn wall(api: &Api) -> Option { - let t = api.time()?; - Some(wall_min(t.year as i32, t.month as u32, t.day as u32, t.hour as u32, t.minute as u32)) - } - - fn today(api: &Api) -> Option { - let t = api.time()?; - let month = Month::new(t.year, t.month)?; - (1..=month.days()).contains(&t.day).then_some(Day { month, day: t.day }) - } - - #[derive(Clone, Copy)] - enum View { - Month(MonthView), - Widget(WidgetView), - Day(DayView), - Event(EventView), - } - - impl View { - fn root(&self) -> cmf_wp2_app::lv::Obj { - match self { - View::Month(v) => v.root, - View::Widget(v) => v.root, - View::Day(v) => v.root, - View::Event(v) => v.root, - } - } - } - - enum Want { - Month(Month), - /// The page, listing that day of this week. - Widget(Day), - Day(Day), - /// The `n`th event of a day, from the page or not. - Event(Day, usize, bool), - } - - /// The list an event was opened from. - fn back(v: EventView) -> Want { - if v.page { Want::Widget(v.day) } else { Want::Day(v.day) } - } - - /// The phone's events that start on `d`. - fn events(m: &Model, w: i32, today: Option, d: Day) -> impl Iterator { - let off = crate::marks::day_no(d) - today.map_or(0, crate::marks::day_no); - (0..m.n).filter(move |&i| m.span(i, w).0 == off).map(move |i| &m.events[i]) - } - - struct App { - api: &'static Api, - lv: Lv, - b: Batch, - model: &'static mut Model, - marks: Marks, - view: View, - today: Option, - } - - impl App { - /// Replaces the screen with `want`; on an error the old screen stays. - fn show(&mut self, want: Want) { - let lv = self.lv; - let mut flush = |b: &mut Batch| b.submit(&lv); - if let (Want::Month(m), View::Month(v)) = (&want, self.view) { - if v.root != cmf_wp2_app::lv::ROOT { - // the same screen, another month: swapped in place, no blink - let r = screen::month_turn(&mut self.b, &mut flush, v, *m, self.today, &self.marks); - if let Ok(v) = r { - self.view = View::Month(v); - set(SHOWN, v.shown.year as i32 * 100 + v.shown.month as i32); - } - set(RC, code(r.and_then(|_| self.b.submit(&lv)))); - return; - } - } - let old = self.view.root(); - let (m, w, today) = (&*self.model, wall(self.api).unwrap_or(0), self.today); - let r = screen::leave(&mut self.b, old).and_then(|_| match want { - Want::Month(m) => { - screen::month_view(&mut self.b, &mut flush, m, self.today, &self.marks).map(View::Month) - } - Want::Widget(d) => { - let t = self.today.unwrap_or(d); - screen::widget_view(&mut self.b, &mut flush, t, d, &self.marks, events(m, w, today, d)).map(View::Widget) - } - Want::Day(d) => screen::day_view(&mut self.b, &mut flush, d, events(m, w, today, d)).map(View::Day), - Want::Event(d, n, page) => match events(m, w, today, d).nth(n) { - Some(e) => screen::event_view(&mut self.b, &mut flush, d, e, page).map(View::Event), - None => screen::day_view(&mut self.b, &mut flush, d, events(m, w, today, d)).map(View::Day), - }, - }); - let r = match r { - Ok(v) => { - self.view = v; - self.b.submit(&lv) - } - Err(e) => Err(e), - }; - set(RC, code(r)); - match self.view { - View::Month(v) => { - set(VIEW, 1); - set(SHOWN, v.shown.year as i32 * 100 + v.shown.month as i32); - } - View::Widget(_) => set(VIEW, 2), - View::Day(_) => set(VIEW, 3), - View::Event(_) => set(VIEW, 4), - } - } - - /// The same screen again, for a new day or new marks. - fn refresh(&mut self) { - let want = match self.view { - View::Month(v) => Want::Month(v.shown), - View::Day(v) => Want::Day(v.day), - // new data can reorder the day: back to its list - View::Event(v) => back(v), - // the picked day stays while it's still this week's - View::Widget(v) => match self.today { - Some(_) if Some(v.today) == self.today => Want::Widget(v.sel), - Some(d) => Want::Widget(d), - None => Want::Month(FALLBACK), - }, - }; - self.show(want); - } - - fn card(&self) { - if let Some(d) = self.today { - self.api.widget("Calendar", screen::card_value(d, &self.marks).as_str()); - } - } - - fn remark(&mut self) { - if let (Some(d), Some(w)) = (self.today, wall(self.api)) { - self.marks = Marks::build(self.model, d, w); - } - } - - fn poll(&mut self) { - if let Some(req) = self.model.poll(self.api.now()) { - self.api.send(&req); // -107 with no phone: the retry timer covers it - } - } - - /// A new day since the last look: the screens and the card follow. - fn tick(&mut self) { - let now = today(self.api); - if now == self.today { - return; - } - let was = self.today; - self.today = now; - self.remark(); - if let (View::Month(v), Some(old), Some(new)) = (self.view, was, now) { - if v.shown == old.month { - self.show(Want::Month(new.month)); - self.card(); - return; - } - } - self.refresh(); - self.card(); - } - - fn message(&mut self, m: &[u8]) { - let w = wall(self.api).unwrap_or(self.model.fetched.unwrap_or(0)); - let got = self.model.reply(m, self.api.now(), w); - if got == Got::Events { - let blob = unsafe { &mut *core::ptr::addr_of_mut!(STORE) }; - let n = self.model.save(blob); - self.api.save(&blob[..n]); // on change: the app can end without notice - set(SYNCS, get(SYNCS) + 1); - } - if got != Got::Nothing { - self.remark(); - self.refresh(); - self.card(); - } - } - } - - fn main(api: &'static Api) -> i32 { - let Some(lv) = api.lv() else { return -95 }; // loader older than ABI 1.2 - let Some(mut b) = Batch::new() else { return -1 }; - if screen::fonts(&mut b).and_then(|_| b.submit(&lv)).is_err() { - return 1; - } - if screen::theme(&mut b).and_then(|_| b.submit(&lv)).is_err() { - return 2; - } - let model = unsafe { &mut *core::ptr::addr_of_mut!(MODEL) }; - let blob = unsafe { &mut *core::ptr::addr_of_mut!(STORE) }; - let n = api.load(blob); - if n > 0 { - model.load(&blob[..n as usize]); - } - model.ask_now(api.now()); - let today = today(api); - let placeholder = View::Month(MonthView { - root: cmf_wp2_app::lv::ROOT, - title: cmf_wp2_app::lv::ROOT, - prev: cmf_wp2_app::lv::ROOT, - next: cmf_wp2_app::lv::ROOT, - foot: cmf_wp2_app::lv::ROOT, - shown: FALLBACK, - grid: cmf_wp2_app::lv::ROOT, - cells: [cmf_wp2_app::lv::ROOT; crate::date::CELLS], - }); - let mut app = App { api, lv, b, model, marks: Marks::empty(), view: placeholder, today }; - app.remark(); - let on_page = api.on_page(); - api.own_back(true); // the right swipe on a day goes back to its month, not out (no-op before ABI 1.3) - app.show(match (on_page, today) { - (true, Some(d)) => Want::Widget(d), - (_, d) => Want::Month(d.map_or(FALLBACK, |d| d.month)), - }); - app.card(); - let mut paused = false; - let mut msg = [0u8; MSG_MAX]; - loop { - if !paused { - app.poll(); - } - let e = api.event(if paused { u32::MAX } else { app.model.wait(api.now()).min(TICK_MS) }); - if !paused { - app.tick(); - } - let Some(e) = e else { continue }; - match e.kind { - BUTTON => match app.view { - View::Day(v) => app.show(Want::Month(v.day.month)), - View::Event(v) => app.show(back(v)), - _ => break, - }, - PAUSE => paused = true, - RESUME => { - paused = false; - app.model.ask_now(api.now()); - app.tick(); - } - MESSAGE => { - while let Some(m) = api.recv(&mut msg) { - app.message(m); - } - } - LV if e.y == CLICKED && !paused => { - let h = e.x as u16; - match app.view { - View::Month(v) if h == v.prev.0 => app.show(Want::Month(v.shown.add(-1))), - View::Month(v) if h == v.next.0 => app.show(Want::Month(v.shown.add(1))), - View::Month(v) if h == v.title.0 => app.show(match (on_page, app.today) { - (true, Some(d)) => Want::Widget(d), - (_, d) => Want::Month(d.map_or(v.shown, |d| d.month)), - }), - View::Month(v) => { - if let Some(i) = v.cells.iter().position(|c| c.0 == h) { - app.show(Want::Day(crate::date::grid(v.shown)[i])); - } - } - View::Day(v) if h == v.title.0 => app.show(Want::Month(v.day.month)), - View::Day(v) => { - if let Some(n) = v.cards.iter().position(|c| c.0 == h) { - app.show(Want::Event(v.day, n, false)); - } - } - View::Event(v) if h == v.root.0 => app.show(back(v)), - View::Widget(w) if h == w.title.0 => app.show(Want::Month(w.today.month)), - View::Widget(w) => { - if let Some(i) = w.cells.iter().position(|c| c.0 == h) { - app.show(Want::Widget(crate::date::week(w.today)[i])); - } else if let Some(n) = w.cards.iter().position(|c| c.0 == h) { - app.show(Want::Event(w.sel, n, true)); - } - } - _ => {} - } - } - _ => {} - } - } - 0 - } -} diff --git a/apps/calendar/src/marks.rs b/apps/calendar/src/marks.rs deleted file mode 100644 index b76c478..0000000 --- a/apps/calendar/src/marks.rs +++ /dev/null @@ -1,113 +0,0 @@ -//! What the screens show per day, built from the phone's events (`model.rs`): how many events and up to -//! [`DOTS`] calendar colours. The phone answers for [`DAYS`] days from today, so days outside them have no marks. - -use crate::date::Day; -use crate::model::{Model, Status, days}; - -pub const DAYS: usize = 7; -pub const DOTS: usize = 3; - -#[derive(Clone, Copy, Default, PartialEq, Debug)] -pub struct Mark { - pub count: u8, - /// RGB565 (as LVGL styles take it) of each calendar with an event that day, `dots` of them. - pub colours: [i32; DOTS], - pub dots: u8, -} - -pub struct Marks { - /// Day number (since 1970) of `days[0]`. - from: i32, - days: [Mark; DAYS], - /// What the summary says instead of a count; `None` once the phone answered. - pub note: Option<&'static str>, -} - -pub fn day_no(d: Day) -> i32 { - days(d.month.year as i32, d.month.month as u32, d.day as u32) -} - -impl Marks { - pub const fn empty() -> Marks { - Marks { from: 0, days: [Mark { count: 0, colours: [0; DOTS], dots: 0 }; DAYS], note: Some("not synced") } - } - - /// The marks for `today` at `wall` (watch minutes, `model::wall_min`). - pub fn build(m: &Model, today: Day, wall: i32) -> Marks { - let mut k = Marks::empty(); - k.from = day_no(today); - k.note = match m.status { - Status::Ask => Some("allow on your phone"), - Status::Denied => Some("no calendar access"), - _ if m.fetched.is_none() => Some("not synced"), - _ => None, - }; - // ponytail: an event marks the day it starts on; a multi-day one shows on its first day only - for i in 0..m.n { - let (day, _, _) = m.span(i, wall); - let Some(d) = usize::try_from(day).ok().filter(|&d| d < DAYS) else { continue }; - let mk = &mut k.days[d]; - mk.count = mk.count.saturating_add(1); - let c = m.events[i].color as i32; - if (mk.dots as usize) < DOTS && !mk.colours[..mk.dots as usize].contains(&c) { - mk.colours[mk.dots as usize] = c; - mk.dots += 1; - } - } - k - } - - /// The day's mark; empty outside the phone's window. - pub fn get(&self, d: Day) -> Mark { - usize::try_from(day_no(d) - self.from).ok().and_then(|i| self.days.get(i)).copied().unwrap_or_default() - } - - /// Every day of the window from `today` marked `mark`, for screen tests. - #[cfg(test)] - pub fn filled(today: Day, mark: Mark) -> Marks { - Marks { from: day_no(today), days: [mark; DAYS], note: None } - } -} - -#[cfg(test)] -mod tests { - use super::*; - use crate::date::Month; - use crate::model::wall_min; - - fn rec(day: i8, start: u16, color: u16) -> Vec { - let mut r = vec![day as u8]; - r.extend(start.to_le_bytes()); - r.extend(30u16.to_le_bytes()); - r.push(4); - r.extend(color.to_le_bytes()); - r - } - - #[test] - fn events_become_counts_and_dots() { - let nov = Month::new(2026, 11).unwrap(); - let today = Day { month: nov, day: 17 }; - let wall = wall_min(2026, 11, 17, 8, 0); - let mut m = Model::new(); - assert_eq!(Marks::build(&m, today, wall).note, Some("not synced")); - m.ask_now(0); - m.poll(0); - let recs = [rec(0, 570, 0xF800), rec(0, 600, 0xF800), rec(0, 700, 0x07E0), rec(2, 60, 0x001F), rec(9, 0, 0xFFFF)]; - for (i, r) in recs.iter().enumerate() { - let mut msg = vec![b'R', b'1', b'A', 1, 0, i as u8, recs.len() as u8]; - msg.extend(r); - m.reply(&msg, 0, wall); - } - let k = Marks::build(&m, today, wall); - assert_eq!(k.note, None); - assert_eq!(k.get(today), Mark { count: 3, colours: [0xF800, 0x07E0, 0], dots: 2 }); - assert_eq!(k.get(Day { month: nov, day: 19 }).colours[0], 0x001F); - // outside the window: before today, past 7 days - assert_eq!(k.get(Day { month: nov, day: 16 }), Mark::default()); - assert_eq!(k.get(Day { month: nov, day: 26 }), Mark::default()); - // the same cache a day later: everything moved one day closer - let k = Marks::build(&m, Day { month: nov, day: 18 }, wall + 1440); - assert_eq!(k.get(Day { month: nov, day: 19 }).count, 1); - } -} diff --git a/apps/calendar/src/model.rs b/apps/calendar/src/model.rs deleted file mode 100644 index a9dab4c..0000000 --- a/apps/calendar/src/model.rs +++ /dev/null @@ -1,279 +0,0 @@ -//! What the app knows and when it asks: the last answer, the cache, polling with retry and back-off. No `Api`: `now` is `api.now()` ms, `wall` the watch's local time in minutes -//! since 1970-01-01 (see [`wall_min`]). - -use companion_rpc::{self as rpc, Call, Event}; - -/// Events asked for (the week from today, at most this many; the RPC sends 32 at most). -pub const MAX: usize = 32; -/// Poll while running. -pub const PERIOD_MS: u32 = 300_000; -/// While the phone asks the user: look again soon, the grant may come any moment. -pub const ASK_AGAIN_MS: u32 = 10_000; -/// The cache blob: magic, fetched (i32 wall minute), count, then `len ‖ record` per event. -const MAGIC: &[u8; 2] = b"C1"; -pub const BLOB_MAX: usize = 7 + MAX * (1 + Event::RECORD_MAX); - -#[derive(Clone, Copy, PartialEq, Debug)] -pub enum Status { - /// No answer yet since start. - Waiting, - Ok, - Ask, - Denied, - /// UNAVAILABLE, BAD_REQUEST and anything unknown: the phone answered without data. - Unavailable, -} - -#[derive(Clone, Copy, PartialEq, Debug)] -pub enum Got { - Nothing, - Changed, - /// New events: save the cache. - Events, -} - -pub struct Model { - pub events: [Event; MAX], - pub n: usize, - /// When `events` came, wall minutes; `None` = nothing ever came. - pub fetched: Option, - pub status: Status, - call: Call, - ids: u8, - pending: [Event; MAX], - /// The records of the open answer that decoded. - ok: u32, -} - -/// Days since 1970-01-01 of a civil date (H. Hinnant's `days_from_civil`). -pub fn days(y: i32, m: u32, d: u32) -> i32 { - let y = if m <= 2 { y - 1 } else { y }; - let era = y.div_euclid(400); - let yoe = y - era * 400; - let mp = (m as i32 + 9) % 12; - let doy = (153 * mp + 2) / 5 + d as i32 - 1; - era * 146_097 + yoe * 365 + yoe / 4 - yoe / 100 + doy - 719_468 -} - -pub fn wall_min(y: i32, m: u32, d: u32, hour: u32, minute: u32) -> i32 { - days(y, m, d) * 1440 + (hour * 60 + minute) as i32 -} - -const EMPTY: Event = Event { day: 0, start: 0, duration: 0, flags: 0, color: 0, title: rpc::Text::EMPTY }; - -impl Model { - pub const fn new() -> Self { - Model { - events: [EMPTY; MAX], - n: 0, - fetched: None, - status: Status::Waiting, - call: Call::new(PERIOD_MS), - ids: 0, - pending: [EMPTY; MAX], - ok: 0, - } - } - - /// A request to send now, if one is due (the first one, or a retry that backs off while the phone is silent). - pub fn poll(&mut self, now: u32) -> Option { - let id = self.call.due(now, &mut self.ids)?; - self.ok = 0; - Some(rpc::calendar_events(id, 0, crate::marks::DAYS as u8, MAX as u8)) - } - - /// Ms until [`Model::poll`] has something to do. - pub fn wait(&self, now: u32) -> u32 { - self.call.wait(now) - } - - /// Ask at once (start, RESUME), with a fresh back-off. - pub fn ask_now(&mut self, now: u32) { - self.call.now(now); - } - - /// One message from the channel. Replies to anything but the latest request are dropped. - pub fn reply(&mut self, m: &[u8], now: u32, wall: i32) -> Got { - match self.call.take(m) { - rpc::Got::Nothing => Got::Nothing, - rpc::Got::Status(s) => { - self.status = match s { - rpc::OK => Status::Ok, - rpc::ASK => Status::Ask, - rpc::DENIED => Status::Denied, - _ => Status::Unavailable, - }; - self.call.after(now, if self.status == Status::Ask { ASK_AGAIN_MS } else { PERIOD_MS }); - if self.status != Status::Ok { - return Got::Changed; - } - self.n = 0; - self.fetched = Some(wall); - Got::Events - } - // a multi-part answer: one record each, any order; one that doesn't decode is left out - rpc::Got::Record { index, record, last, .. } => { - if let (Some(e), true) = (Event::decode(record), (index as usize) < MAX) { - self.pending[index as usize] = e; - self.ok |= 1 << index; - } - if !last { - return Got::Nothing; - } - self.n = 0; - for i in 0..MAX { - if self.ok & 1 << i != 0 { - self.events[self.n] = self.pending[i]; - self.n += 1; - } - } - self.fetched = Some(wall); - self.status = Status::Ok; - self.call.after(now, PERIOD_MS); - Got::Events - } - } - } - - /// The cache blob into `out` ([`BLOB_MAX`] bytes); its length, 0 if there is nothing to keep. - pub fn save(&self, out: &mut [u8]) -> usize { - let Some(f) = self.fetched else { return 0 }; - out[..2].copy_from_slice(MAGIC); - out[2..6].copy_from_slice(&f.to_le_bytes()); - out[6] = self.n as u8; - let mut at = 7; - for e in &self.events[..self.n] { - let len = e.encode(&mut out[at + 1..]); - out[at] = len as u8; - at += 1 + len; - } - at - } - - /// Restores a cache blob; anything it cannot read leaves the model empty. - pub fn load(&mut self, b: &[u8]) { - if b.len() < 7 || &b[..2] != MAGIC || b[6] as usize > MAX { - return; - } - let mut at = 7; - for i in 0..b[6] as usize { - let Some(&len) = b.get(at) else { return }; - let Some(e) = b.get(at + 1..at + 1 + len as usize).and_then(Event::decode) else { return }; - self.pending[i] = e; - at += 1 + len as usize; - } - self.n = b[6] as usize; - self.events[..self.n].copy_from_slice(&self.pending[..self.n]); - self.fetched = Some(i32::from_le_bytes([b[2], b[3], b[4], b[5]])); - } - - /// Event `i` relative to today 00:00 at `wall`: (day, start minute, end minute). The phone's `day` counts from - /// the day of the answer, so a cache from yesterday moves one day back. - pub fn span(&self, i: usize, wall: i32) -> (i32, i32, i32) { - let e = &self.events[i]; - let shift = wall.div_euclid(1440) - self.fetched.unwrap_or(wall).div_euclid(1440); - let day = e.day as i32 - shift; - let start = day * 1440 + e.start as i32; - (day, start, start + e.duration as i32) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use companion_rpc::RETRY_MS; - - fn hex(s: &str) -> Vec { - (0..s.len()).step_by(2).map(|i| u8::from_str_radix(&s[i..i + 2], 16).unwrap()).collect() - } - - // 2026-11-17 08:00 - const WALL: i32 = 20_774 * 1440 + 8 * 60; - - fn rec(day: i8, start: u16, dur: u16, flags: u8, title: &str) -> Vec { - let mut r = vec![day as u8]; - r.extend(start.to_le_bytes()); - r.extend(dur.to_le_bytes()); - r.push(flags); - r.extend(0xF800u16.to_le_bytes()); - r.extend(title.as_bytes()); - r - } - - fn msg(id: u8, status: u8, index: u8, total: u8, record: &[u8]) -> Vec { - let mut m = vec![b'R', b'1', b'A', id, status, index, total]; - m.extend(record); - m - } - - #[test] - fn days_since_epoch() { - assert_eq!(days(1970, 1, 1), 0); - assert_eq!(days(2026, 11, 17), 20_774); - assert_eq!(days(2024, 3, 1) - days(2024, 2, 28), 2); - } - - #[test] - fn multi_part_answer_in_any_order_then_cached() { - let mut m = Model::new(); - assert!(m.poll(0).is_none()); // nothing before the start's ask_now - m.ask_now(0); - let req = m.poll(0).unwrap(); - assert_eq!(&req[..], [b'R', b'1', b'Q', 1, 0x10, 0, 7, 32]); - assert_eq!(m.reply(&msg(1, 0, 1, 2, &rec(0, 600, 30, 0, "Обед")), 100, WALL), Got::Nothing); - assert_eq!(m.reply(&msg(1, 0, 0, 2, &rec(0, 570, 30, 4, "")), 100, WALL), Got::Events); - assert_eq!((m.n, m.status, m.events[1].title.as_str(), m.events[0].title.as_str()), (2, Status::Ok, "Обед", "")); - assert!(m.poll(PERIOD_MS + 99).is_none() && m.poll(PERIOD_MS + 100).is_some()); - - let mut blob = [0u8; BLOB_MAX]; - let n = m.save(&mut blob); - let mut back = Model::new(); - back.load(&blob[..n]); - assert_eq!((back.n, back.fetched, back.events), (2, Some(WALL), m.events)); - let mut junk = Model::new(); - junk.load(&blob[..n - 1]); - junk.load(b"C2\0\0\0\0\0"); - assert_eq!((junk.n, junk.fetched), (0, None)); - } - - #[test] - fn spec_reply_vector_with_a_hidden_title() { - // rpc-vectors.json "replies", id 8: one record, title hidden - let mut m = Model::new(); - for _ in 0..7 { - m.ask_now(0); - m.poll(0); - } - m.ask_now(0); - assert_eq!(m.poll(0).unwrap()[3], 8); - assert_eq!(m.reply(&hex("52314108000001003a021e000400f8"), 0, WALL), Got::Events); - assert_eq!((m.n, m.events[0].title.as_str()), (1, "")); - } - - #[test] - fn stale_ids_dropped_silence_backs_off() { - let mut m = Model::new(); - m.ask_now(0); - m.poll(0); - assert!(m.poll(RETRY_MS - 1).is_none()); - assert_eq!(m.poll(RETRY_MS).unwrap()[3], 2); - assert!(m.call.silent()); - assert_eq!(m.wait(RETRY_MS), 2 * RETRY_MS); - // the late answer to request 1 is not the latest - assert_eq!(m.reply(&msg(1, 0, 0, 0, &[]), RETRY_MS + 5, WALL), Got::Nothing); - assert!(m.poll(3 * RETRY_MS).is_some()); - assert_eq!(m.wait(3 * RETRY_MS), 4 * RETRY_MS); - let mut t = 3 * RETRY_MS; - for _ in 0..10 { - t += m.wait(t); - m.poll(t); - } - assert_eq!(m.wait(t), PERIOD_MS); - // ASK for the latest id, look again in 10 s, the silence is over - let id = m.ids; - assert_eq!(m.reply(&msg(id, rpc::ASK, 0, 0, &[]), 7, WALL), Got::Changed); - assert_eq!((m.status, m.call.silent(), m.wait(7)), (Status::Ask, false, ASK_AGAIN_MS)); - // a second answer to the same id is ignored - assert_eq!(m.reply(&msg(id, rpc::DENIED, 0, 0, &[]), 8, WALL), Got::Nothing); - } -} diff --git a/apps/calendar/src/screen.rs b/apps/calendar/src/screen.rs deleted file mode 100644 index b2e8488..0000000 --- a/apps/calendar/src/screen.rs +++ /dev/null @@ -1,687 +0,0 @@ -//! The two screens, in the stock look (`cmf_wp2_app::stock`): -//! - month: the accent month title between `<` and `>`, weekday initials, a 6×7 grid of days with a dot per calendar -//! that has an event, today in an accent pill, a summary line under it; -//! - day: a day's events as cards under its date; -//! - widget (the page next to the watch face): the day screen with this week between the date and the events. -//! -//! Each screen is one root object under `ROOT`; leaving it deletes the root and everything in it. A screen is built -//! hidden, over as many batches as it needs, and shown in the last one. - -use crate::date::{self, Day, Month, CELLS}; -use crate::marks::{Mark, Marks}; -use companion_rpc::Event; -use cmf_wp2_app::lv::*; -use cmf_wp2_app::stock::{self, ACCENT, BLACK, CIRCLE, GREY, SCREEN, WHITE}; -use core::fmt::Write; - -/// Font slots besides the system font (slot 0). -pub const F24: u8 = 1; -pub const F48: u8 = 2; - -const DOT: i32 = 6; -const DOT_STEP: i16 = 10; - -// month grid geometry, inside the 466 px circle (the bottom row's corners at radius ~200) -const COL_W: i32 = 48; -const ROW_H: i32 = 44; -const GRID_X: i32 = (SCREEN - 7 * COL_W) / 2; -const GRID_Y: i32 = 128; -const CELL_W: i32 = COL_W - 4; -const CELL_H: i32 = ROW_H - 4; -const TITLE_Y: i16 = 44; -const TITLE_W: i32 = 190; -const ARROW: i32 = 64; -const ARROW_DX: i16 = 125; -const WEEKDAYS_Y: i16 = 94; -const FOOTER_Y: i16 = GRID_Y as i16 + 6 * ROW_H as i16 + 8; - -// bytes one cell, dots included, can take: flush first when fewer are left -const GROUP: usize = 480; - -pub type Flush<'a> = dyn FnMut(&mut Batch) -> Result<(), LvError> + 'a; - -fn room(b: &mut Batch, flush: &mut Flush) -> Result<(), LvError> { - if b.bytes().len() + GROUP > BUF { flush(b) } else { Ok(()) } -} - -/// The fonts, in a batch of their own. -pub fn fonts(b: &mut Batch) -> Result<(), LvError> { - stock::font(b)?; - b.font(F24, StockFont::F24M)?; - b.font(F48, StockFont::F48M) -} - -/// A short line of text in a fixed buffer. -pub struct Line { - buf: [u8; 40], - len: usize, -} - -impl Line { - pub fn new() -> Line { - Line { buf: [0; 40], len: 0 } - } - - pub fn as_str(&self) -> &str { - core::str::from_utf8(&self.buf[..self.len]).unwrap_or("") - } -} - -impl Default for Line { - fn default() -> Self { - Self::new() - } -} - -impl Write for Line { - fn write_str(&mut self, s: &str) -> core::fmt::Result { - if self.len + s.len() > self.buf.len() { - return Err(core::fmt::Error); - } - self.buf[self.len..self.len + s.len()].copy_from_slice(s.as_bytes()); - self.len += s.len(); - Ok(()) - } -} - -fn events(n: u32, out: &mut Line) { - let _ = match n { - 0 => write!(out, "no events"), - 1 => write!(out, "1 event"), - n => write!(out, "{n} events"), - }; -} - -/// The line under the month grid. -/// The line under the month grid: today's count whatever month is shown (the phone only tells the coming week). -pub fn month_summary(today: Option, k: &Marks) -> Line { - let mut out = Line::new(); - if let Some(n) = k.note { - let _ = out.write_str(n); - } else if let Some(t) = today { - let _ = out.write_str("today: "); - events(k.get(t).count as u32, &mut out); - } - out -} - -/// Today's events, for the widget screen and the card. -pub fn today_summary(today: Day, k: &Marks) -> Line { - let mut out = Line::new(); - if let Some(n) = k.note { - let _ = out.write_str(n); - } else { - events(k.get(today).count as u32, &mut out); - let _ = out.write_str(" today"); - } - out -} - -/// The card left of the watch face: "Sun 15 Nov" and today's events. -pub fn card_value(today: Day, k: &Marks) -> Line { - const DAYS: [&str; 7] = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]; - let mut out = Line::new(); - let _ = write!( - out, - "{} {} {}\n{}", - DAYS[date::weekday(today) as usize], - today.day, - date::SHORT[today.month.month as usize - 1], - today_summary(today, k).as_str() - ); - out -} - -fn bare(b: &mut Batch, o: Obj) -> Result<(), LvError> { - for p in [Prop::PadTop, Prop::PadBottom, Prop::PadLeft, Prop::PadRight, Prop::BorderWidth, Prop::BgOpa, Prop::Radius] { - b.style(o, p, 0, 0)?; - } - b.flags(o, &[], &[Flag::Scrollable]) -} - -/// A full-screen, transparent, hidden root. -fn root(b: &mut Batch) -> Result { - let r = b.create(Class::Obj, ROOT)?; - b.size(r, SCREEN, SCREEN)?; - bare(b, r)?; - b.style(r, Prop::TextAlign, 0, 2)?; // LV_TEXT_ALIGN_CENTER, inherited by every label - b.flags(r, &[Flag::Hidden], &[])?; - Ok(r) -} - -fn label(b: &mut Batch, parent: Obj, text: &str, w: i32, x: i16, y: i16) -> Result { - let l = b.create(Class::Label, parent)?; - b.size(l, w, CONTENT)?; - b.text(l, text)?; - b.align(l, Align::TopMid, x, y)?; - Ok(l) -} - -fn num(n: u8) -> Line { - let mut l = Line::new(); - let _ = write!(l, "{n}"); - l -} - -/// One day: its number, `today` in the accent pill, a dot per calendar with events. `x`, `y`: top left in `parent`. -fn cell(b: &mut Batch, parent: Obj, d: Day, dim: bool, today: bool, mark: Mark, x: i32, y: i32) -> Result { - let c = b.create(Class::Label, parent)?; - if mark.count > 0 { - // a tap shows the day's events - b.flags(c, &[Flag::Clickable], &[])?; - b.events(c, &[Ev::Clicked])?; - b.style(c, Prop::BgColor, stock::PRESSED, stock::ROW_PRESSED)?; - b.style(c, Prop::BgOpa, stock::PRESSED, 255)?; - b.style(c, Prop::Radius, 0, 12)?; - } - b.size(c, CELL_W, CELL_H)?; - b.align(c, Align::TopLeft, x as i16, y as i16)?; - // 24 px: two digits of the 32 px system font fill a 48 px column and run into the next - b.style(c, Prop::TextFont, 0, F24 as i32)?; - b.style(c, Prop::PadTop, 0, 4)?; - b.text(c, num(d.day).as_str())?; - if today { - b.style(c, Prop::BgColor, 0, ACCENT)?; - b.style(c, Prop::BgOpa, 0, 255)?; - b.style(c, Prop::Radius, 0, 12)?; - } else if dim { - b.style(c, Prop::TextColor, 0, GREY)?; - } - let n = mark.dots as i16; - for (i, &colour) in mark.colours[..mark.dots as usize].iter().enumerate() { - let i = i as i16; - let dot = b.create(Class::Obj, c)?; - b.size(dot, DOT, DOT)?; - b.style(dot, Prop::Radius, 0, CIRCLE)?; - b.style(dot, Prop::BorderWidth, 0, 0)?; - // on the accent pill a calendar's colour can vanish: white there - let colour = if today { WHITE } else { colour }; - b.style(dot, Prop::BgColor, 0, colour)?; - b.style(dot, Prop::BgOpa, 0, if dim { 128 } else { 255 })?; - b.align(dot, Align::BottomMid, -(n - 1) * DOT_STEP / 2 + i * DOT_STEP, -3)?; - } - Ok(c) -} - -/// Heroicons' `chevron-left` (outline, `M15.75 19.5 8.25 12l7.5-7.5`), or mirrored to the right for `dir` 1. LVGL -/// here has no line or image, so the stroke is round dots a pixel apart along both legs: a 2·[`CHEVRON`] px tall -/// chevron, round caps and joint like the SVG's. -fn chevron(b: &mut Batch, flush: &mut Flush, parent: Obj, dir: i16) -> Result<(), LvError> { - let h = CHEVRON; - for i in 0..=2 * h { - if i % 4 == 0 { - room(b, flush)?; - } - // the leg from the top end to the point, then the one down to the bottom end - let (x, y) = if i <= h { (h / 2 - i, i - h) } else { (-h / 2 + (i - h), i - h) }; - let d = b.create(Class::Obj, parent)?; - b.size(d, STROKE, STROKE)?; - b.style(d, Prop::Radius, 0, CIRCLE)?; - b.style(d, Prop::BorderWidth, 0, 0)?; - b.style(d, Prop::BgColor, 0, GREY)?; - b.style(d, Prop::BgOpa, 0, 255)?; - b.flags(d, &[], &[Flag::Clickable])?; // a press goes to the tap target - b.align(d, Align::Center, -dir * x, y)?; - } - Ok(()) -} - -/// Half the chevron's height and its stroke, px: 20 px tall; a 4 px stroke reads at arm's length. -const CHEVRON: i16 = 10; -const STROKE: i32 = 4; - -/// A round tap target with a grey chevron; `dir` -1 left, 1 right. -fn arrow(b: &mut Batch, flush: &mut Flush, parent: Obj, dir: i16, dx: i16) -> Result { - let a = b.create(Class::Obj, parent)?; - b.size(a, ARROW, ARROW)?; - bare(b, a)?; - b.style(a, Prop::BgColor, stock::PRESSED, stock::ROW_PRESSED)?; - b.style(a, Prop::BgOpa, stock::PRESSED, 255)?; - b.style(a, Prop::Radius, 0, CIRCLE)?; - // centred on the title's glyphs (digits at y 47-63 in the emulator), not its 32 px line box - b.align(a, Align::TopMid, dx, TITLE_Y + 11 - ARROW as i16 / 2)?; - b.events(a, &[Ev::Clicked])?; - chevron(b, flush, a, dir)?; - Ok(a) -} - -#[derive(Clone, Copy, Debug)] -pub struct MonthView { - pub root: Obj, - pub title: Obj, - pub prev: Obj, - pub next: Obj, - pub foot: Obj, - pub shown: Month, - /// The days, under the title: [`month_turn`] swaps it for another month's. - pub grid: Obj, - /// The grid's cells, as `date::grid(shown)`: a tap on one opens its day. - pub cells: [Obj; CELLS], -} - -/// `shown`'s days in a hidden box over the grid area (the caller shows it), a cell per day. -fn grid(b: &mut Batch, flush: &mut Flush, r: Obj, shown: Month, today: Option, k: &Marks) - -> Result<(Obj, [Obj; CELLS]), LvError> { - room(b, flush)?; - let g = b.create(Class::Obj, r)?; - b.size(g, 7 * COL_W, 6 * ROW_H)?; - bare(b, g)?; - b.flags(g, &[Flag::Hidden], &[Flag::Clickable])?; - b.align(g, Align::TopLeft, GRID_X as i16, GRID_Y as i16)?; - let mut cells = [ROOT; CELLS]; - for (i, d) in date::grid(shown).iter().enumerate().take(CELLS) { - room(b, flush)?; - let (x, y) = ((i % 7) as i32 * COL_W + 2, (i / 7) as i32 * ROW_H + 2); - cells[i] = cell(b, g, *d, d.month != shown, today == Some(*d), k.get(*d), x, y)?; - } - Ok((g, cells)) -} - -fn month_title(shown: Month) -> Line { - let mut t = Line::new(); - let _ = write!(t, "{} {}", shown.name(), shown.year); - t -} - -/// Another month on the month screen without leaving it: the new grid is built hidden next to the old one, then one -/// batch drops the old grid, shows the new one and renames the title, so the screen never goes black in between. -pub fn month_turn(b: &mut Batch, flush: &mut Flush, v: MonthView, shown: Month, today: Option, k: &Marks) - -> Result { - let (g, cells) = grid(b, flush, v.root, shown, today, k)?; - flush(b)?; - b.text(v.title, month_title(shown).as_str())?; - b.text(v.foot, month_summary(today, k).as_str())?; - b.del(v.grid)?; - b.flags(g, &[], &[Flag::Hidden])?; - Ok(MonthView { shown, grid: g, cells, ..v }) -} - -pub fn month_view(b: &mut Batch, flush: &mut Flush, shown: Month, today: Option, k: &Marks) - -> Result { - room(b, flush)?; - let r = root(b)?; - let title = label(b, r, month_title(shown).as_str(), TITLE_W, 0, TITLE_Y)?; - b.style(title, Prop::TextColor, 0, ACCENT)?; - b.style(title, Prop::TextFont, 0, F24 as i32)?; - b.flags(title, &[Flag::Clickable], &[])?; - b.events(title, &[Ev::Clicked])?; - let prev = arrow(b, flush, r, -1, -ARROW_DX)?; - let next = arrow(b, flush, r, 1, ARROW_DX)?; - room(b, flush)?; - for (i, w) in date::WEEKDAYS.iter().enumerate() { - let l = b.create(Class::Label, r)?; - b.size(l, COL_W, CONTENT)?; - b.style(l, Prop::TextColor, 0, GREY)?; - b.style(l, Prop::TextFont, 0, F24 as i32)?; - b.text(l, w)?; - b.align(l, Align::TopLeft, (GRID_X + i as i32 * COL_W) as i16, WEEKDAYS_Y)?; - } - let (grid, cells) = grid(b, flush, r, shown, today, k)?; - b.flags(grid, &[], &[Flag::Hidden])?; - room(b, flush)?; - let foot = label(b, r, month_summary(today, k).as_str(), 300, 0, FOOTER_Y)?; - b.style(foot, Prop::TextColor, 0, GREY)?; - b.style(foot, Prop::TextFont, 0, F24 as i32)?; - b.flags(r, &[], &[Flag::Hidden])?; - Ok(MonthView { root: r, title, prev, next, foot, shown, grid, cells }) -} - -#[derive(Clone, Copy, Debug)] -pub struct WidgetView { - pub root: Obj, - /// Tap: the month. - pub title: Obj, - pub today: Day, - /// The day whose events are listed. - pub sel: Day, - /// `date::week(today)`: a tap lists that day. - pub cells: [Obj; 7], - pub cards: Cards, -} - -const EVENT_H: i32 = 96; -/// One line of the 24 px font. -const NAME_H: i32 = 30; -const DAY_TOP: i32 = 110; -// the page: the week under the title, the events under the week -const W_WEEK_Y: i32 = GRID_Y; -const W_TOP: i32 = GRID_Y + ROW_H + 16; - -/// "09:30–10:00", "all day", or from the start on for one that runs past midnight. -pub fn span_text(e: &Event) -> Line { - let mut out = Line::new(); - let hm = |m: u32| (m / 60 % 24, m % 60); - if e.flags & Event::ALL_DAY != 0 { - let _ = out.write_str("all day"); - } else { - let (a, b) = (hm(e.start as u32), hm(e.start as u32 + e.duration as u32)); - let _ = write!(out, "{:02}:{:02}–{:02}:{:02}", a.0, a.1, b.0, b.1); - } - out -} - -/// Event cards, in their events' order: a tap opens that event. -pub type Cards = [Obj; crate::model::MAX]; - -/// A crown-scrolled root with the accent "wed 18 november" title (clickable). -fn day_root(b: &mut Batch, day: Day) -> Result<(Obj, Obj), LvError> { - // laid out by hand: stock::page's flex column came out 16 px left in the emulator - let r = root(b)?; - b.flags(r, &[Flag::Scrollable], &[])?; - b.style(r, Prop::PadBottom, 0, DAY_TOP)?; // the last card can scroll up to the middle - let mut t = Line::new(); - let _ = write!(t, "{} {} {}", &date::WEEKDAY_NAMES[date::weekday(day) as usize][..3], day.day, day.month.name()); - let title = label(b, r, t.as_str(), stock::ROW_W - 80, 0, TITLE_Y)?; - b.style(title, Prop::TextColor, 0, ACCENT)?; - b.flags(title, &[Flag::Clickable], &[])?; - b.events(title, &[Ev::Clicked])?; - Ok((r, title)) -} - -/// A card per event from `top` down, with its calendar's colour, its time and its title ("busy" while the phone -/// keeps titles); `empty` when there are none. Then the scroll bar, and the root shown. -fn event_cards<'e>(b: &mut Batch, flush: &mut Flush, r: Obj, top: i32, events: impl Iterator, - empty: &str) -> Result { - let mut cards = [ROOT; crate::model::MAX]; - let mut n = 0; - for e in events.take(cards.len()) { - room(b, flush)?; - let c = stock::card(b, r, EVENT_H)?; - b.align(c, Align::TopMid, 0, (top + n as i32 * (EVENT_H + stock::ROW_GAP)) as i16)?; - // a tap opens the event, its whole title - b.events(c, &[Ev::Clicked])?; - b.style(c, Prop::BgColor, stock::PRESSED, stock::ROW_PRESSED)?; - cards[n] = c; - let bar = b.create(Class::Obj, c)?; - b.flags(bar, &[], &[Flag::Clickable])?; // a press goes to the card - b.size(bar, 8, EVENT_H - 40)?; - b.style(bar, Prop::Radius, 0, CIRCLE)?; - b.style(bar, Prop::BorderWidth, 0, 0)?; - b.style(bar, Prop::BgColor, 0, e.color as i32)?; - b.style(bar, Prop::BgOpa, 0, 255)?; - b.align(bar, Align::LeftMid, 40, 0)?; - let time = b.create(Class::Label, c)?; - b.text(time, span_text(e).as_str())?; - b.align(time, Align::TopLeft, 68, 10)?; - let name = b.create(Class::Label, c)?; - // one line: with CONTENT height a long title wraps out of the card instead of ending in "..." - b.size(name, stock::ROW_W - 68 - 48, NAME_H)?; - b.long_mode(name, LongMode::Dot)?; - b.style(name, Prop::TextAlign, 0, 1)?; // LV_TEXT_ALIGN_LEFT: the root centres - b.style(name, Prop::TextFont, 0, F24 as i32)?; - b.style(name, Prop::TextColor, 0, GREY)?; - b.text(name, if e.title.is_empty() { "busy" } else { e.title.as_str() })?; - b.align(name, Align::TopLeft, 68, 52)?; - n += 1; - } - if n == 0 { - let l = label(b, r, empty, 300, 0, top as i16)?; - b.style(l, Prop::TextColor, 0, GREY)?; - } - b.scroll_bar(r)?; - b.knob(r)?; - b.flags(r, &[], &[Flag::Hidden])?; - Ok(cards) -} - -/// The page next to the watch face: `sel`'s date, this week with its dots (a tap picks a day), and `sel`'s events -/// under it, scrolled by the crown. -pub fn widget_view<'e>(b: &mut Batch, flush: &mut Flush, today: Day, sel: Day, k: &Marks, - events: impl Iterator) -> Result { - room(b, flush)?; - let (r, title) = day_root(b, sel)?; - for (i, w) in date::WEEKDAYS.iter().enumerate() { - let l = b.create(Class::Label, r)?; - b.size(l, COL_W, CONTENT)?; - b.style(l, Prop::TextColor, 0, GREY)?; - b.style(l, Prop::TextFont, 0, F24 as i32)?; - b.text(l, w)?; - b.align(l, Align::TopLeft, (GRID_X + i as i32 * COL_W) as i16, WEEKDAYS_Y)?; - } - let mut cells = [ROOT; 7]; - for (i, d) in date::week(today).iter().enumerate() { - room(b, flush)?; - let c = cell(b, r, *d, d.month != today.month, *d == today, k.get(*d), GRID_X + i as i32 * COL_W + 2, W_WEEK_Y)?; - // every day of the week picks, an empty one too; the picked one sits on the pressed grey - b.flags(c, &[Flag::Clickable], &[])?; - b.events(c, &[Ev::Clicked])?; - b.style(c, Prop::BgColor, stock::PRESSED, stock::ROW_PRESSED)?; - b.style(c, Prop::BgOpa, stock::PRESSED, 255)?; - b.style(c, Prop::Radius, 0, 12)?; - if *d == sel && sel != today { - b.style(c, Prop::BgColor, 0, stock::ROW_PRESSED)?; - b.style(c, Prop::BgOpa, 0, 255)?; - } - cells[i] = c; - } - room(b, flush)?; - let cards = event_cards(b, flush, r, W_TOP, events, k.note.unwrap_or("no events"))?; - Ok(WidgetView { root: r, title, today, sel, cells, cards }) -} - -#[derive(Clone, Copy, Debug)] -pub struct DayView { - pub root: Obj, - /// Tap: back to the month. - pub title: Obj, - pub day: Day, - pub cards: Cards, -} - -/// One day's events, a crown-scrolled page like the stock lists: the accent date (tap: back to the month), then a -/// card per event. -pub fn day_view<'e>(b: &mut Batch, flush: &mut Flush, day: Day, events: impl Iterator) - -> Result { - room(b, flush)?; - let (r, title) = day_root(b, day)?; - let cards = event_cards(b, flush, r, DAY_TOP, events, "no events")?; - Ok(DayView { root: r, title, day, cards }) -} - -#[derive(Clone, Copy, Debug)] -pub struct EventView { - /// Tap anywhere: back to the list. - pub root: Obj, - pub day: Day, - /// Opened from the page (back to it) rather than from a day. - pub page: bool, -} - -/// One event: its date, time and calendar colour, and the whole title wrapped (as much as the phone sends, -/// `companion_rpc::TEXT_MAX` bytes); the crown scrolls a long one. -pub fn event_view(b: &mut Batch, flush: &mut Flush, day: Day, e: &Event, page: bool) -> Result { - room(b, flush)?; - let (r, title) = day_root(b, day)?; - b.flags(title, &[], &[Flag::Clickable])?; // the root takes the tap - b.flags(r, &[Flag::Clickable], &[])?; - b.events(r, &[Ev::Clicked])?; - let time = label(b, r, span_text(e).as_str(), 300, 0, DAY_TOP as i16)?; - b.style(time, Prop::TextFont, 0, F48 as i32)?; - let bar = b.create(Class::Obj, r)?; - b.size(bar, 64, 8)?; - b.style(bar, Prop::Radius, 0, CIRCLE)?; - b.style(bar, Prop::BorderWidth, 0, 0)?; - b.style(bar, Prop::BgColor, 0, e.color as i32)?; - b.style(bar, Prop::BgOpa, 0, 255)?; - b.flags(bar, &[], &[Flag::Clickable])?; - b.align(bar, Align::TopMid, 0, DAY_TOP as i16 + 76)?; - let name = label(b, r, if e.title.is_empty() { "busy" } else { e.title.as_str() }, stock::ROW_W - 40, 0, - DAY_TOP as i16 + 104)?; - b.long_mode(name, LongMode::Wrap)?; - if e.title.is_empty() { - b.style(name, Prop::TextColor, 0, GREY)?; - } - b.scroll_bar(r)?; - b.knob(r)?; - b.flags(r, &[], &[Flag::Hidden])?; - Ok(EventView { root: r, day, page }) -} - -/// Deletes a screen. -pub fn leave(b: &mut Batch, root: Obj) -> Result<(), LvError> { - if root != ROOT { b.del(root) } else { Ok(()) } -} - -/// Black behind everything, the system font and white text: first, once. -pub fn theme(b: &mut Batch) -> Result<(), LvError> { - stock::theme(b)?; - b.style(ROOT, Prop::BgColor, 0, BLACK) -} - -#[cfg(test)] -mod tests { - extern crate std; - use super::*; - use std::boxed::Box; - use std::vec::Vec; - use wp2_core::lvcmd::{self, Table}; - - fn batch() -> Batch { - Batch::with_buf(Box::leak(Box::new([0; BUF]))) - } - - fn m(y: u16, mo: u8) -> Month { - Month::new(y, mo).unwrap() - } - - const FONTS: u8 = 0b111; - - /// Runs `build` with a flush that validates each batch against the loader's table and applies it; returns the - /// table, the batches' sizes and the result. - fn run(t: &mut Table, b: &mut Batch, build: impl FnOnce(&mut Batch, &mut Flush) -> Result) - -> (T, Vec) { - let sizes = std::cell::RefCell::new(Vec::new()); - let mut flush = |b: &mut Batch| -> Result<(), LvError> { - assert_eq!(lvcmd::validate(b.bytes(), t, FONTS), Ok(())); - for r in lvcmd::records(b.bytes()) { - lvcmd::apply(t, &r.unwrap()); - } - sizes.borrow_mut().push(b.bytes().len()); - b.clear(); - Ok(()) - }; - let out = build(b, &mut flush).unwrap(); - flush(b).unwrap(); - (out, sizes.into_inner()) - } - - fn busy(today: Day) -> Marks { - // a week of days with three calendars each: the most objects a screen can take - Marks::filled(today, Mark { count: 31, colours: [ACCENT, 0x867D, 0x9772], dots: 3 }) - } - - #[test] - fn fonts_validate_on_their_own() { - let mut b = batch(); - fonts(&mut b).unwrap(); - assert_eq!(lvcmd::validate(b.bytes(), &Table::new(), 0), Ok(())); - } - - #[test] - fn month_view_validates_and_fits_the_budget() { - let today = Day { month: m(2026, 11), day: 15 }; - for k in [Marks::empty(), busy(today)] { - let mut t = Table::new(); - let mut b = batch(); - let (v, sizes) = run(&mut t, &mut b, |b, f| { - theme(b)?; - month_view(b, f, m(2026, 11), Some(today), &k) - }); - assert!(sizes.iter().all(|&n| n <= BUF)); - std::println!("month view: {} batches, {sizes:?} B", sizes.len()); - // leaving frees every handle: the next month takes the same ones - let (_, _) = run(&mut t, &mut b, |b, _| leave(b, v.root)); - let (w, _) = run(&mut t, &mut b, |b, f| month_view(b, f, m(2026, 12), Some(today), &k)); - assert_eq!(w.root, v.root); - assert_eq!((w.title, w.prev, w.next), (v.title, v.prev, v.next)); - // turning months in place: two grids at once stay inside the object budget, and the old one is freed - let mut v = w; - for mo in [11, 10, 9, 11] { - let (n, _) = run(&mut t, &mut b, |b, f| month_turn(b, f, v, m(2026, mo), Some(today), &k)); - assert_eq!((n.root, n.title), (v.root, v.title)); - v = n; - } - } - } - - #[test] - fn widget_view_validates() { - let today = Day { month: m(2026, 12), day: 1 }; // its week starts in November - let all: Vec = (0..32).map(|i| event(i * 30, 30, 0, "Созвон с командой по релизу и обсуждение")).collect(); - for k in [Marks::empty(), busy(today)] { - let mut t = Table::new(); - let mut b = batch(); - let (v, sizes) = run(&mut t, &mut b, |b, f| { - theme(b)?; - widget_view(b, f, today, today, &k, all.iter()) - }); - std::println!("widget view: {sizes:?} B"); - run(&mut t, &mut b, |b, _| leave(b, v.root)); - // and the month view after it, as a tap does - run(&mut t, &mut b, |b, f| month_view(b, f, today.month, Some(today), &k)); - } - } - - fn event(start: u16, dur: u16, flags: u8, title: &str) -> Event { - let mut r = std::vec![0u8]; - r.extend(start.to_le_bytes()); - r.extend(dur.to_le_bytes()); - r.push(flags); - r.extend(0x4CFDu16.to_le_bytes()); - r.extend(title.as_bytes()); - Event::decode(&r).unwrap() - } - - #[test] - fn day_view_validates_then_the_month_again() { - let today = Day { month: m(2026, 11), day: 17 }; - let long = "Созвон с командой по релизу и обсуждение планов"; - let all: Vec = (0..32).map(|i| event(i * 30, 30, 0, long)).collect(); - for evs in [&all[..], &[][..]] { - let mut t = Table::new(); - let mut b = batch(); - let (v, sizes) = run(&mut t, &mut b, |b, f| { - theme(b)?; - day_view(b, f, today, evs.iter()) - }); - std::println!("day view: {sizes:?} B"); - run(&mut t, &mut b, |b, _| leave(b, v.root)); - if let Some(e) = evs.first() { - let (v, _) = run(&mut t, &mut b, |b, f| event_view(b, f, today, e, false)); - run(&mut t, &mut b, |b, _| leave(b, v.root)); - } - let (v, _) = run(&mut t, &mut b, |b, f| event_view(b, f, today, &event(0, 1440, 1, ""), true)); - run(&mut t, &mut b, |b, _| leave(b, v.root)); - run(&mut t, &mut b, |b, f| month_view(b, f, today.month, Some(today), &busy(today))); - } - } - - #[test] - fn event_times() { - assert_eq!(span_text(&event(570, 30, 0, "")).as_str(), "09:30–10:00"); - assert_eq!(span_text(&event(1380, 120, 0, "")).as_str(), "23:00–01:00"); - assert_eq!(span_text(&event(0, 1440, 1, "")).as_str(), "all day"); - } - - #[test] - fn summaries() { - let nov = m(2026, 11); - let today = Day { month: nov, day: 15 }; - let k = Marks::empty(); - assert_eq!(month_summary(Some(today), &k).as_str(), "not synced"); - assert_eq!(today_summary(today, &k).as_str(), "not synced"); - let one = Mark { count: 1, colours: [ACCENT, 0, 0], dots: 1 }; - let k = Marks::filled(today, Mark { count: 3, ..one }); - assert_eq!(month_summary(Some(today), &k).as_str(), "today: 3 events"); - assert_eq!(today_summary(today, &k).as_str(), "3 events today"); - assert_eq!(today_summary(today, &Marks::filled(today, one)).as_str(), "1 event today"); - assert_eq!(today_summary(today, &Marks::filled(today, Mark::default())).as_str(), "no events today"); - assert_eq!(card_value(today, &k).as_str(), "Sun 15 Nov\n3 events today"); - // the card's value limit, the longest note too - let dec30 = Day { month: m(2026, 12), day: 30 }; - assert!(card_value(dec30, &busy(dec30)).as_str().len() <= 39); - let mut ask = Marks::empty(); - ask.note = Some("allow on your phone"); - assert!(card_value(dec30, &ask).as_str().len() <= 39); - } -} diff --git a/apps/calendar/store.md b/apps/calendar/store.md deleted file mode 100644 index df52836..0000000 --- a/apps/calendar/store.md +++ /dev/null @@ -1,20 +0,0 @@ -A month calendar for the wrist. Today sits in an accent pill, and each day of the coming week with events gets a dot -in its calendar's colour (up to three per day). Tap **<** and **>** to change the month; tap the -month's name to come back to today. Tap a day with dots to see its events: time, calendar colour and title; tap an event for its whole title; swipe right to come back. - -It can also live next to the watch face: long-press **Calendar** in Apps and choose **Add page** for today's events under this -week (tap a day of the week for its events, the crown scrolls them), or **Add widget** for a card with the date and today's event count. - -The events come from your phone: the watch asks when you open the app and every 5 minutes while it runs, and keeps the -last answer. The phone sends the next 7 days, so days further on have no dots. - -Titles stay on the phone by default and the watch shows "busy". To see them, turn on "Show text on the watch" for -Calendar in FMC Companion: anyone near enough to the watch's Bluetooth could read them too. - -The first time, the watch says "allow on your phone": allow Calendar in FMC Companion's Permissions screen. - -## Requirements - -- The [patched firmware](/firmware) with the channel key (2026-11-13 or later) and the [App Loader](/firmware) - (2026-11-15 or later for the widget and the page). -- **FMC Companion** on the phone the watch is paired with (iOS or Android), with calendar access allowed. diff --git a/apps/calendar/store.toml b/apps/calendar/store.toml deleted file mode 100644 index b563b30..0000000 --- a/apps/calendar/store.toml +++ /dev/null @@ -1,6 +0,0 @@ -# The app's listing in the FMC store (README.md, "store.toml"). The page's body is store.md. -name = "Calendar" -summary = "A month with your phone's events as dots, a page next to the watch face and a widget" -version = "0.2.4" -author = "Egor Kolesnikov" -screenshots = ["shots/month.png", "shots/day.png", "shots/page.png", "shots/card.png"] diff --git a/apps/connect-four/Cargo.toml b/apps/connect-four/Cargo.toml deleted file mode 100644 index c8f352e..0000000 --- a/apps/connect-four/Cargo.toml +++ /dev/null @@ -1,13 +0,0 @@ -[package] -name = "connect-four" -edition.workspace = true -license.workspace = true -version.workspace = true - -[dependencies] -cmf-wp2-app.workspace = true -cmf-wp2-ui.workspace = true - -[[bin]] -name = "connect-four" -bench = false diff --git a/apps/connect-four/icon.svg b/apps/connect-four/icon.svg deleted file mode 100644 index e6b069a..0000000 --- a/apps/connect-four/icon.svg +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/apps/connect-four/shots/menu.png b/apps/connect-four/shots/menu.png deleted file mode 100644 index 76884a1..0000000 Binary files a/apps/connect-four/shots/menu.png and /dev/null differ diff --git a/apps/connect-four/shots/playing.png b/apps/connect-four/shots/playing.png deleted file mode 100644 index 7e1db67..0000000 Binary files a/apps/connect-four/shots/playing.png and /dev/null differ diff --git a/apps/connect-four/shots/result.png b/apps/connect-four/shots/result.png deleted file mode 100644 index 9595121..0000000 Binary files a/apps/connect-four/shots/result.png and /dev/null differ diff --git a/apps/connect-four/shots/won.png b/apps/connect-four/shots/won.png deleted file mode 100644 index 8b12cb2..0000000 Binary files a/apps/connect-four/shots/won.png and /dev/null differ diff --git a/apps/connect-four/src/engine.rs b/apps/connect-four/src/engine.rs deleted file mode 100644 index 7759520..0000000 --- a/apps/connect-four/src/engine.rs +++ /dev/null @@ -1,1001 +0,0 @@ -// The bot: Connect Four on bitboards, negamax with alpha-beta pruning, iterative deepening and a small transposition -// table. Pure: no Api, no heap, no floats, so `cargo test` runs it on the host. -// -// Bitboard layout (the classic one): column `c` takes bits `7c .. 7c + 5`, row 0 at the bottom, and bit `7c + 6` is -// a sentinel that is always empty, so shifted lines never wrap from one column into the next. A position is the side -// to move's stones (`cur`) and every stone (`mask`); the other side's stones are `cur ^ mask`. - -pub const W: usize = 7; -pub const H: usize = 6; -/// Bits per column: `H` cells and the sentinel. -const H1: u32 = H as u32 + 1; -pub const CELLS: u8 = (W * H) as u8; - -const fn bottom_row() -> u64 { - let mut b = 0; - let mut c = 0; - while c < W { - b |= 1 << (c as u32 * H1); - c += 1; - } - b -} - -/// The bottom cell of every column. -pub const BOTTOM: u64 = bottom_row(); -/// Every playable cell (no sentinels). -pub const BOARD: u64 = BOTTOM * ((1 << H) - 1); - -/// Columns from the centre out: the best first guess at any node. -pub const ORDER: [u8; W] = [3, 2, 4, 1, 5, 0, 6]; - -pub const fn bit(col: usize, row: usize) -> u64 { - 1 << (col as u32 * H1 + row as u32) -} - -pub const fn column(col: usize) -> u64 { - ((1 << H) - 1) << (col as u32 * H1) -} - -const fn top_cell(col: usize) -> u64 { - bit(col, H - 1) -} - -/// Scores: a heuristic stays inside ±`WIN`; a won game scores `WIN + 42 - stones`, so a sooner win is worth more. The -/// score depends on the position only (not on the search's ply), which keeps it valid in the transposition table. -pub const WIN: i16 = 1000; -const INF: i16 = 2000; - -/// The score of a win that lands with the `stones`-th stone. -pub const fn mate(stones: u8) -> i16 { - WIN + CELLS as i16 - stones as i16 -} - -pub fn is_mate(score: i16) -> bool { - score >= WIN || score <= -WIN -} - -#[derive(Clone, Copy, PartialEq, Eq, Debug, Default)] -pub struct Pos { - /// Stones of the side to move. - pub cur: u64, - /// Every stone. - pub mask: u64, - pub moves: u8, -} - -impl Pos { - /// From each side's stones; `cur` is the side to move. - pub fn new(cur: u64, other: u64) -> Pos { - let mask = cur | other; - Pos { cur, mask, moves: mask.count_ones() as u8 } - } - - pub fn other(&self) -> u64 { - self.cur ^ self.mask - } - - pub fn can_play(&self, col: usize) -> bool { - col < W && self.mask & top_cell(col) == 0 - } - - /// The row a stone dropped into `col` lands on (`H` when the column is full). - pub fn height(&self, col: usize) -> usize { - (self.mask & column(col)).count_ones() as usize - } - - /// Drops a stone of the side to move into `col` (which must be playable); the other side moves next. - #[cfg(test)] - pub fn play(&mut self, col: usize) { - self.play_bit((self.mask + bit(col, 0)) & column(col)); - } - - fn play_bit(&mut self, mv: u64) { - self.cur ^= self.mask; - self.mask |= mv; - self.moves += 1; - } - - /// Unique per position: `cur + mask` adds a bit above each column's stones, which marks its height. - pub fn key(&self) -> u64 { - self.cur + self.mask - } - - /// The cell each non-full column would take next. - pub fn possible(&self) -> u64 { - (self.mask + BOTTOM) & BOARD - } - - #[cfg(test)] - pub fn is_full(&self) -> bool { - self.moves >= CELLS - } - - /// Would a stone in `col` complete four for the side to move? - #[cfg(test)] - pub fn wins_with(&self, col: usize) -> bool { - winning_cells(self.cur, self.mask) & self.possible() & column(col) != 0 - } - - #[cfg(test)] - pub fn can_win_next(&self) -> bool { - winning_cells(self.cur, self.mask) & self.possible() != 0 - } - - /// The moves that don't hand the other side a win on its next stone: blocks a single threat, gives up (0) on two, - /// and never plays right under a cell the other side wins on. Assumes the side to move can't win at once. - pub fn non_losing(&self) -> u64 { - let mut possible = self.possible(); - let theirs = winning_cells(self.other(), self.mask); - let forced = possible & theirs; - if forced != 0 { - if forced & (forced - 1) != 0 { - return 0; // two threats at once: lost - } - possible = forced; - } - possible & !(theirs >> 1) - } - - /// Heuristic value for the side to move, inside ±(`WIN` − 1): open threes and twos per window of four, and the - /// centre column. Only called where nobody has four. - pub fn eval(&self) -> i16 { - let empty = BOARD & !self.mask; - let me = self.cur; - let them = self.other(); - let mut s = lines(me, empty) - lines(them, empty); - let centre = column(3); - s += CENTRE * ((me & centre).count_ones() as i32 - (them & centre).count_ones() as i32); - // threats on the rows that win the endgame's zugzwang: odd rows (1, 3, 5) for the first player, even ones for - // the second - let (mine, theirs) = if self.moves % 2 == 0 { (ODD_ROWS, EVEN_ROWS) } else { (EVEN_ROWS, ODD_ROWS) }; - let good = |p: u64, rows: u64| (winning_cells(p, self.mask) & rows).count_ones() as i32; - s += PARITY * (good(me, mine) - good(them, theirs)); - s.clamp(-(WIN as i32 - 1), WIN as i32 - 1) as i16 - } -} - -/// Weights of the heuristic: a window of four with three of one side and one empty cell, with two and two empty, with -/// one and three empty, and each stone in the centre column (tuned so deep searches keep to the centre early on). -pub const THREE: i32 = 8; -pub const TWO: i32 = 2; -pub const ONE: i32 = 1; -pub const CENTRE: i32 = 8; -/// An empty cell that completes four for a side, on a row of that side's parity (on top of its `THREE`). -pub const PARITY: i32 = 16; -/// Rows 1, 3, 5 counted from 1 (indices 0, 2, 4) and rows 2, 4, 6. -const ODD_ROWS: u64 = BOTTOM * 0b01_0101; -const EVEN_ROWS: u64 = BOTTOM * 0b10_1010; -/// Line directions as bit shifts: up, right, down-right, up-right. -const DIRS: [u32; 4] = [1, H1, H1 - 1, H1 + 1]; - -/// `THREE` × windows with 3 of `p` and 1 empty + `TWO` × windows with 2 and 2, over all 69 windows, computed for every -/// window start at once. A window that leaves the board has a cell that is neither `p` nor empty, so it never counts. -fn lines(p: u64, empty: u64) -> i32 { - let mut threes = 0; - let mut twos = 0; - let mut ones = 0; - for d in DIRS { - let (a0, a1, a2, a3) = (p, p >> d, p >> (2 * d), p >> (3 * d)); - let (e0, e1, e2, e3) = (empty, empty >> d, empty >> (2 * d), empty >> (3 * d)); - let three = (a0 & a1 & a2 & e3) | (a0 & a1 & e2 & a3) | (a0 & e1 & a2 & a3) | (e0 & a1 & a2 & a3); - let two = (a0 & a1 & e2 & e3) - | (a0 & e1 & a2 & e3) - | (a0 & e1 & e2 & a3) - | (e0 & a1 & a2 & e3) - | (e0 & a1 & e2 & a3) - | (e0 & e1 & a2 & a3); - let one = (a0 & e1 & e2 & e3) | (e0 & a1 & e2 & e3) | (e0 & e1 & a2 & e3) | (e0 & e1 & e2 & a3); - threes += three.count_ones() as i32; - twos += two.count_ones() as i32; - ones += one.count_ones() as i32; - } - THREE * threes + TWO * twos + ONE * ones -} - -/// Empty cells that would complete four for `p` (playable now or not). -pub fn winning_cells(p: u64, mask: u64) -> u64 { - // vertical: three below - let mut r = (p << 1) & (p << 2) & (p << 3); - for d in [H1, H1 - 1, H1 + 1] { - let q = (p << d) & (p << (2 * d)); - r |= q & (p << (3 * d)); - r |= q & (p >> d); - let q = (p >> d) & (p >> (2 * d)); - r |= q & (p << d); - r |= q & (p >> (3 * d)); - } - r & (BOARD ^ mask) -} - -/// Every stone of `p` that is part of a line of four (0 if none). -pub fn fours(p: u64) -> u64 { - let mut r = 0; - for d in DIRS { - let m = p & (p >> d); - let s = m & (m >> (2 * d)); - r |= s | s << d | s << (2 * d) | s << (3 * d); - } - r -} - -pub fn has_four(p: u64) -> bool { - fours(p) != 0 -} - -/// xorshift32; the app seeds it from the clock. -pub fn rand(state: &mut u32) -> u32 { - let mut x = *state | 1; - x ^= x << 13; - x ^= x >> 17; - x ^= x << 5; - *state = x; - x -} - -// Transposition table: `SLOTS` entries of a full key and a packed value, 12 B each. Replace-always. - -pub const SLOTS: usize = 2048; -const EXACT: u32 = 1; -const LOWER: u32 = 2; -const UPPER: u32 = 3; - -pub struct Tt { - keys: [u64; SLOTS], - vals: [u32; SLOTS], -} - -#[derive(Clone, Copy)] -struct Entry { - score: i16, - depth: u8, - flag: u32, - best: u8, -} - -impl Tt { - pub const fn new() -> Tt { - Tt { keys: [0; SLOTS], vals: [0; SLOTS] } - } - - pub fn clear(&mut self) { - self.keys = [0; SLOTS]; - self.vals = [0; SLOTS]; - } - - fn slot(key: u64) -> usize { - (key.wrapping_mul(0x9E37_79B9_7F4A_7C15) >> (64 - SLOTS.trailing_zeros())) as usize - } - - fn get(&self, key: u64) -> Option { - let i = Tt::slot(key); - let v = self.vals[i]; - if v == 0 || self.keys[i] != key { - return None; - } - Some(Entry { score: v as u16 as i16, depth: (v >> 16 & 0x3F) as u8, flag: v >> 22 & 3, best: (v >> 24 & 0xF) as u8 }) - } - - fn put(&mut self, key: u64, e: Entry) { - let i = Tt::slot(key); - self.keys[i] = key; - self.vals[i] = e.score as u16 as u32 | (e.depth as u32 & 0x3F) << 16 | e.flag << 22 | (e.best as u32 & 0xF) << 24; - } -} - -impl Default for Tt { - fn default() -> Self { - Tt::new() - } -} - -/// How hard the bot thinks. -#[derive(Clone, Copy, Debug, PartialEq)] -pub struct Config { - /// Deepest iteration, in plies. - pub depth: u8, - /// Node budget for the whole move. - pub nodes: u32, - /// Root moves within this many points of the best are equally good; the bot picks one of them at random - /// (0: only exact ties). A mate score is never within the margin of a non-mate one. Needs `exact`. - pub margin: i16, - /// Score every root move with a full window, so `margin` compares exact scores (costs more nodes). - pub exact: bool, -} - -#[derive(Clone, Copy, Debug, PartialEq)] -pub struct Choice { - pub col: u8, - pub score: i16, - /// Deepest completed iteration (0: the move was forced or found without a search). - pub depth: u8, - pub nodes: u32, -} - -/// How often the search asks `stop`, in nodes (a power of two). -pub const POLL_NODES: u32 = 256; - -/// The moves in `next` in search order: `first` (the table's move), then by how many winning cells each one makes -/// for the side to move, centre first on ties. -#[inline(always)] -pub fn order(p: &Pos, next: u64, first: u8) -> ([u8; W], usize) { - let mut cols = [0u8; W]; - let mut keys = [0i8; W]; - let mut n = 0; - for c in ORDER { - let mv = next & column(c as usize); - if mv == 0 { - continue; - } - let k = if c == first { i8::MAX } else { winning_cells(p.cur | mv, p.mask | mv).count_ones() as i8 }; - let mut j = n; - while j > 0 && keys[j - 1] < k { - cols[j] = cols[j - 1]; - keys[j] = keys[j - 1]; - j -= 1; - } - cols[j] = c; - keys[j] = k; - n += 1; - } - (cols, n) -} - -pub struct Search<'a, F: FnMut() -> bool> { - tt: &'a mut Tt, - stop: F, - pub nodes: u32, - cap: u32, - aborted: bool, -} - -impl<'a, F: FnMut() -> bool> Search<'a, F> { - /// `stop` is called every `POLL_NODES` nodes; `true` ends the search, which then plays the best move of the - /// deepest iteration it completed. - pub fn new(tt: &'a mut Tt, stop: F) -> Self { - Search { tt, stop, nodes: 0, cap: u32::MAX, aborted: false } - } - - /// The bot's move in `p`, which must have a playable column and no four on the board. `rng` breaks ties. - pub fn choose(&mut self, p: &Pos, cfg: Config, rng: &mut u32) -> Choice { - self.nodes = 0; - self.cap = cfg.nodes; - self.aborted = false; - let first = |bits: u64| ORDER.iter().copied().find(|&c| bits & column(c as usize) != 0); - let done = |col: u8, score: i16, depth: u8, nodes: u32| Choice { col, score, depth, nodes }; - if p.moves == 0 && cfg.margin == 0 { - return done(3, 0, 0, 0); // the book: the centre is the solved game's only winning first move - } - let possible = p.possible(); - // a win now - let wins = winning_cells(p.cur, p.mask) & possible; - if let Some(c) = first(wins) { - return done(c, mate(p.moves + 1), 0, 0); - } - let next = p.non_losing(); - if next == 0 { - // lost whatever we do: block one of the threats if there is one, else anything - let theirs = winning_cells(p.other(), p.mask) & possible; - let c = first(theirs).or_else(|| first(possible)).unwrap_or(3); - return done(c, -mate(p.moves + 2), 0, 0); - } - if next & (next - 1) == 0 { - return done(first(next).unwrap_or(3), 0, 0, 0); // one move left that doesn't lose: no choice - } - let mut cols = [0u8; W]; - let mut n = 0; - for c in ORDER { - if next & column(c as usize) != 0 { - cols[n] = c; - n += 1; - } - } - let mut best = Choice { col: cols[0], score: 0, depth: 0, nodes: 0 }; - let mut good = [i16::MIN; W]; // per root move, the scores of the last completed iteration - let empty = CELLS - p.moves; - for depth in 1..=cfg.depth.min(empty) { - let mut scores = [i16::MIN; W]; - let mut alpha = -INF; - for &c in &cols[..n] { - let mut child = *p; - child.play_bit(next & column(c as usize)); - let s = if cfg.exact { - -self.negamax(&child, depth - 1, -INF, INF) - } else { - -self.negamax(&child, depth - 1, -INF, -alpha) - }; - if self.aborted { - break; - } - scores[c as usize] = s; - alpha = alpha.max(s); - } - if self.aborted { - break; - } - good = scores; - best.depth = depth; - // next iteration: best first (stable, so ties keep the centre-first order) - for i in 1..n { - let mut j = i; - while j > 0 && scores[cols[j] as usize] > scores[cols[j - 1] as usize] { - cols.swap(j, j - 1); - j -= 1; - } - } - best.col = cols[0]; - best.score = scores[cols[0] as usize]; - if is_mate(best.score) { - break; // proven - } - } - // with a narrowed window the other moves' scores are only bounds: pick among them only when they are exact - if best.depth > 0 && cfg.exact && cfg.margin >= 0 { - let top = best.score; - let near = |s: i16| s != i16::MIN && s >= top.saturating_sub(cfg.margin) && is_mate(s) == is_mate(top); - let count = cols[..n].iter().filter(|&&c| near(good[c as usize])).count() as u32; - if count > 1 { - let k = rand(rng) % count; - if let Some(&c) = cols[..n].iter().filter(|&&c| near(good[c as usize])).nth(k as usize) { - best.col = c; - best.score = good[c as usize]; - } - } - } - best.nodes = self.nodes; - best - } - - /// Value of `p` for the side to move, which can't win with its next stone. Keep the frame small: the stack is - /// 8 KiB and this recurses once per ply. - fn negamax(&mut self, p: &Pos, depth: u8, mut alpha: i16, mut beta: i16) -> i16 { - self.nodes += 1; - if self.nodes & (POLL_NODES - 1) == 0 && (self.nodes >= self.cap || (self.stop)()) { - self.aborted = true; - } - if self.aborted { - return 0; - } - let next = p.non_losing(); - if next == 0 { - return -mate(p.moves + 2); - } - if p.moves >= CELLS - 2 { - return 0; // nobody can win in the last two stones - } - // we can't win before stone moves + 3, and the other side can't before moves + 4 - let hi = mate(p.moves + 3); - if beta > hi { - beta = hi; - if alpha >= beta { - return beta; - } - } - if depth == 0 { - return p.eval(); - } - let key = p.key(); - let mut tt_move = 0xFF; - if let Some(e) = self.tt.get(key) { - tt_move = e.best; - if e.depth >= depth { - match e.flag { - EXACT => return e.score, - LOWER => alpha = alpha.max(e.score), - _ => beta = beta.min(e.score), - } - if alpha >= beta { - return e.score; - } - } - } - let (cols, n) = order(p, next, tt_move); - let low = alpha; - let mut best = -INF; - let mut best_col = cols[0]; - for &c in &cols[..n] { - let mut child = *p; - child.play_bit(next & column(c as usize)); - let s = -self.negamax(&child, depth - 1, -beta, -alpha); - if self.aborted { - return 0; - } - if s > best { - best = s; - best_col = c; - } - if s > alpha { - alpha = s; - if alpha >= beta { - break; - } - } - } - let flag = if best <= low { - UPPER - } else if best >= beta { - LOWER - } else { - EXACT - }; - self.tt.put(key, Entry { score: best, depth, flag, best: best_col }); - best - } -} - -#[cfg(test)] -mod tests { - use super::*; - - /// A position from a move string of columns 1-7 (the usual notation), first player to move first. - fn pos(moves: &str) -> Pos { - let mut p = Pos::default(); - for ch in moves.bytes() { - let c = (ch - b'1') as usize; - assert!(p.can_play(c), "{moves}: column {} full", c + 1); - assert!(!has_four(p.other()), "{moves}: game over before {}", c + 1); - p.play(c); - } - p - } - - fn solve(p: &Pos, depth: u8) -> Choice { - let mut tt = Box::new(Tt::new()); - let mut rng = 1; - let cfg = Config { depth, nodes: u32::MAX, margin: 0, exact: false }; - Search::new(&mut tt, || false).choose(p, cfg, &mut rng) - } - - /// The naive heuristic, window by window, to check the bit-parallel one. - fn naive_lines(p: u64, empty: u64) -> i32 { - let mut s = 0; - let dirs: [(i32, i32); 4] = [(0, 1), (1, 0), (1, -1), (1, 1)]; - for c in 0..W as i32 { - for r in 0..H as i32 { - for (dc, dr) in dirs { - let (ec, er) = (c + 3 * dc, r + 3 * dr); - if !(0..W as i32).contains(&ec) || !(0..H as i32).contains(&er) { - continue; - } - let (mut mine, mut free) = (0, 0); - for k in 0..4 { - let b = bit((c + k * dc) as usize, (r + k * dr) as usize); - mine += (p & b != 0) as i32; - free += (empty & b != 0) as i32; - } - if mine + free == 4 { - s += match mine { - 3 => THREE, - 2 => TWO, - 1 => ONE, - _ => 0, - }; - } - } - } - } - s - } - - #[test] - fn layout_constants() { - assert_eq!(BOARD.count_ones(), 42); - assert_eq!(BOARD & (0x7F << 49), 0); - for c in 0..W { - assert_eq!(column(c).count_ones(), 6); - assert_eq!(column(c) & BOARD, column(c)); - } - } - - #[test] - fn there_are_69_windows() { - // every empty window counts as a "two" of nobody; count them via a full board of one side minus... - // simpler: on an empty board with p = empty set, two/three counts are 0; with all cells of p, none either. - // Count windows directly with the naive walker: 24 horizontal, 21 vertical, 12 + 12 diagonal. - let mut n = 0; - for c in 0..W as i32 { - for r in 0..H as i32 { - for (dc, dr) in [(0, 1), (1, 0), (1, -1), (1, 1)] { - let (ec, er) = (c + 3 * dc, r + 3 * dr); - if (0..W as i32).contains(&ec) && (0..H as i32).contains(&er) { - n += 1; - } - } - } - } - assert_eq!(n, 69); - } - - #[test] - fn heuristic_matches_window_by_window_count() { - let mut rng = 12345u32; - for _ in 0..2000 { - let mut p = Pos::default(); - let stones = rand(&mut rng) % 30; - for _ in 0..stones { - let cols: Vec = (0..W).filter(|&c| p.can_play(c)).collect(); - let c = cols[rand(&mut rng) as usize % cols.len()]; - if p.wins_with(c) { - break; - } - p.play(c); - } - let empty = BOARD & !p.mask; - assert_eq!(lines(p.cur, empty), naive_lines(p.cur, empty), "{p:?}"); - assert_eq!(lines(p.other(), empty), naive_lines(p.other(), empty), "{p:?}"); - } - } - - #[test] - fn eval_is_symmetric_and_likes_the_centre() { - assert_eq!(Pos::default().eval(), 0); - let centre = pos("4"); - let edge = pos("1"); - // after one stone the side to move is the other player: negative is good for the first player - assert!(centre.eval() < edge.eval()); - // mirror image scores the same - assert_eq!(pos("12").eval(), pos("76").eval()); - } - - #[test] - fn detects_vertical_win() { - let p = pos("1212121"); - assert!(has_four(p.other())); // the player who just moved - assert!(!has_four(p.cur)); - assert_eq!(fours(p.other()), bit(0, 0) | bit(0, 1) | bit(0, 2) | bit(0, 3)); - } - - #[test] - fn detects_horizontal_win() { - let p = pos("1122334"); - assert_eq!(fours(p.other()), bit(0, 0) | bit(1, 0) | bit(2, 0) | bit(3, 0)); - let p = pos("4455667"); // touching the right edge - assert_eq!(fours(p.other()), bit(3, 0) | bit(4, 0) | bit(5, 0) | bit(6, 0)); - } - - #[test] - fn detects_rising_diagonal_win() { - // first player: (0,0) (1,1) (2,2) (3,3) - let p = pos("12233434414"); - let f = fours(p.other()); - assert_eq!(f, bit(0, 0) | bit(1, 1) | bit(2, 2) | bit(3, 3), "{f:x}"); - } - - #[test] - fn detects_falling_diagonal_win() { - // mirror of the rising one: (6,0) (5,1) (4,2) (3,3) - let p = pos("76655454474"); - let f = fours(p.other()); - assert_eq!(f, bit(6, 0) | bit(5, 1) | bit(4, 2) | bit(3, 3), "{f:x}"); - } - - #[test] - fn no_wrap_between_columns() { - // stones at the top of column 1 and the bottom of column 2 are bit-adjacent through the sentinel: no line - let a = bit(0, 4) | bit(0, 5) | bit(1, 0) | bit(1, 1); - assert!(!has_four(a)); - let b = bit(0, 3) | bit(1, 4) | bit(2, 5) | bit(3, 0); - assert!(!has_four(b)); - assert_eq!(winning_cells(bit(0, 3) | bit(0, 4) | bit(0, 5), bit(0, 3) | bit(0, 4) | bit(0, 5)), 0); - } - - #[test] - fn five_in_a_row_highlights_all_five() { - let p = bit(0, 0) | bit(1, 0) | bit(2, 0) | bit(3, 0) | bit(4, 0); - assert_eq!(fours(p), p); - } - - #[test] - fn play_and_heights() { - let mut p = Pos::default(); - p.play(3); - p.play(3); - assert_eq!(p.height(3), 2); - assert_eq!(p.other(), bit(3, 1)); // second player just moved - assert_eq!(p.cur, bit(3, 0)); - assert_eq!(p.moves, 2); - for _ in 0..4 { - p.play(3); - } - assert!(!p.can_play(3)); - assert!(p.can_play(2)); - assert!(!p.can_play(7)); - assert_eq!(Pos::new(p.cur, p.other()), p); - } - - #[test] - fn keys_are_unique_on_small_trees() { - use std::collections::HashMap; - let mut seen: HashMap = HashMap::new(); - fn walk(p: Pos, d: u8, seen: &mut HashMap) { - let prev = seen.insert(p.key(), (p.cur, p.mask)); - if let Some(prev) = prev { - assert_eq!(prev, (p.cur, p.mask)); - } - if d == 0 { - return; - } - for c in 0..W { - if p.can_play(c) && !p.wins_with(c) { - let mut q = p; - q.play(c); - walk(q, d - 1, seen); - } - } - } - walk(Pos::default(), 5, &mut seen); - assert!(seen.len() > 1000); - } - - #[test] - fn move_order_is_centre_first_on_an_empty_board() { - assert_eq!(ORDER, [3, 2, 4, 1, 5, 0, 6]); - let mut seen = [false; W]; - for c in ORDER { - seen[c as usize] = true; - } - assert!(seen.iter().all(|&s| s)); - let p = Pos::default(); - assert_eq!(order(&p, p.possible(), 0xFF), (ORDER, 7)); - // the table's move goes first, the rest keep their order - assert_eq!(order(&p, p.possible(), 6), ([6, 3, 2, 4, 1, 5, 0], 7)); - // full columns and moves outside `next` are left out - let q = pos("111111"); - assert_eq!(order(&q, q.possible(), 0xFF), ([3, 2, 4, 1, 5, 6, 0], 6)); - assert_eq!(order(&q, bit(5, 0) | bit(1, 0), 0xFF), ([1, 5, 0, 0, 0, 0, 0], 2)); - // a move that makes a threat comes before the centre: (1,0),(2,0) and an open (3,0)... (0,0) makes three - let t = Pos::new(bit(1, 0) | bit(2, 0), bit(1, 1) | bit(2, 1)); - let (cols, _) = order(&t, t.possible(), 0xFF); - assert!(cols[0] == 0 || cols[0] == 3, "{cols:?}"); - assert_eq!(cols[0], 3); // (3,0) makes two winning cells ((0,0) and (4,0)), (0,0) only one - // with no tactics at all, a depth-1 search picks the centre - assert_eq!(solve(&pos("1"), 1).col, 3); - } - - #[test] - fn non_losing_blocks_and_avoids_cells_below_threats() { - // second player threatens column 1 (three in column 1 at rows 0..2)? use a horizontal threat instead - let p = pos("1213"); // first: c1 r0, c1 r1? -> "1213": 1(F) 2(S) 1(F) 3(S) - // first to move: F has (0,0),(0,1); S has (1,0),(2,0): S threatens nothing yet - assert_eq!(p.non_losing(), p.possible()); - let p = pos("12131"); // F: (0,0),(0,1),(0,2); S: (1,0),(2,0); S to move must block column 1 - assert_eq!(p.non_losing(), bit(0, 3)); - // two threats at once: lost - let p = pos("4455"); // F: (3,0),(4,0); S: (3,1),(4,1) - let mut q = p; - q.play(5); // F: (3,0),(4,0),(5,0): wins at (2,0) and (6,0) - assert_eq!(q.non_losing(), 0); - } - - #[test] - fn finds_an_immediate_win() { - let p = pos("121212"); // first player has three in column 1 - for depth in [1, 2, 6, 12] { - let c = solve(&p, depth); - assert_eq!(c.col, 0, "depth {depth}"); - assert_eq!(c.score, mate(7)); - } - // horizontal: first player has (1,0),(2,0),(3,0); both ends win, centre-first picks column 5 (index 4) - let p = pos("2233445"); - assert!(has_four(p.other())); - let p = pos("223344"); - let c = solve(&p, 4); - assert!(c.col == 0 || c.col == 4, "{c:?}"); - } - - #[test] - fn blocks_an_immediate_threat() { - // second player to move; the first threatens to complete column 1 - let p = pos("12131"); - for depth in [1, 2, 6, 10] { - assert_eq!(solve(&p, depth).col, 0, "depth {depth}"); - } - // a single horizontal threat: the other side has (1,0),(2,0),(3,0), (0,0) is taken, (4,0) must be blocked - let p = Pos::new(bit(0, 0) | bit(6, 0) | bit(6, 1), bit(1, 0) | bit(2, 0) | bit(3, 0)); - for depth in [1, 3, 8] { - assert_eq!(solve(&p, depth).col, 4, "depth {depth}"); - } - // two threats at once ((0,0) and (4,0)): lost, but it still blocks one of them - let p = Pos::new(bit(6, 0) | bit(6, 1) | bit(5, 0), bit(1, 0) | bit(2, 0) | bit(3, 0)); - assert_eq!(p.non_losing(), 0); - let c = solve(&p, 6); - assert!(c.col == 0 || c.col == 4, "{c:?}"); - assert_eq!(c.score, -mate(p.moves + 2)); - } - - #[test] - fn sees_a_double_threat_coming() { - // F to move with (2,0),(3,0) and empty (1,0),(4,0),(5,0): playing (4,0) makes _XXX_ on the bottom row - let p = Pos::new(bit(2, 0) | bit(3, 0), bit(2, 1) | bit(3, 1)); - let c = solve(&p, 3); - assert!(c.col == 1 || c.col == 4, "{c:?}"); - assert_eq!(c.score, mate(p.moves + 3)); - } - - #[test] - fn known_positions_are_solved() { - // first player to move with (3,0),(4,0),(5,0) and both ends open: wins at once - let p = pos("445566"); - let c = solve(&p, 8); - assert_eq!(c.score, mate(7)); - assert!(c.col == 2 || c.col == 6, "{c:?}"); - // (2,0) and (4,0) with (1,0), (3,0), (5,0) empty: (3,0) makes an open three, a win in 3 plies - let p = Pos::new(bit(2, 0) | bit(4, 0), bit(0, 0) | bit(6, 0)); - let c = solve(&p, 5); - assert_eq!(c.col, 3); - assert_eq!(c.score, mate(p.moves + 3)); - // the opening: the book plays the centre, and a search answers a centre opening in the centre too - assert_eq!(solve(&Pos::default(), 8).col, 3); - for depth in [4, 8, 12] { - let c = solve(&pos("4"), depth); - assert_eq!(c.col, 3, "depth {depth}"); - assert!(!is_mate(c.score)); - } - } - - /// Plain minimax to the end of the game, for small endgames. - fn brute(p: &Pos) -> i16 { - if p.moves >= CELLS { - return 0; - } - if p.can_win_next() { - return mate(p.moves + 1); - } - let mut best = -INF; - for c in 0..W { - if p.can_play(c) { - let mut q = *p; - q.play(c); - best = best.max(-brute(&q)); - } - } - best - } - - /// A random game that nobody has won yet, `stones` long (None if it ran into a win first). - fn random_game(seed: u32, stones: u8) -> Option { - let mut rng = seed; - let mut p = Pos::default(); - while p.moves < stones { - let cols: Vec = (0..W).filter(|&c| p.can_play(c) && !p.wins_with(c)).collect(); - if cols.is_empty() { - return None; - } - p.play(cols[rand(&mut rng) as usize % cols.len()]); - } - Some(p) - } - - #[test] - fn endgames_are_solved_exactly() { - let mut checked = 0; - for seed in 1..400u32 { - let Some(p) = random_game(seed.wrapping_mul(0x9E37_79B9), 33) else { continue }; - if p.can_win_next() { - continue; - } - let want = brute(&p); - let got = solve(&p, 42); - if got.depth > 0 { - assert_eq!(got.score, want, "seed {seed} {p:?} {got:?}"); // else a forced move: no score - } - let mut q = p; - q.play(got.col as usize); - assert_eq!(-brute(&q), want, "seed {seed}: the move doesn't keep the score"); - checked += 1; - if checked == 25 { - break; - } - } - assert!(checked >= 10, "{checked}"); - } - - #[test] - fn full_board_and_last_move_do_not_crash() { - // a full board with no four for either side: a draw - let rows = ["1121122", "2212211", "1121122", "2212211", "1121122", "2212211"]; - let (mut a, mut b) = (0u64, 0u64); - for (r, row) in rows.iter().enumerate() { - for (c, ch) in row.bytes().enumerate() { - if ch == b'1' { - a |= bit(c, r); - } else { - b |= bit(c, r); - } - } - } - assert_eq!(a | b, BOARD); - assert!(!has_four(a) && !has_four(b)); - let full = Pos::new(a, b); - assert!(full.is_full()); - assert_eq!(full.possible(), 0); - assert!((0..W).all(|c| !full.can_play(c))); - assert_eq!(full.non_losing(), 0); - assert_eq!(full.eval(), 0); - // one empty cell left: the search plays it and calls it a draw - let last = Pos::new(a & !bit(6, 5), b); - assert_eq!(last.moves, 41); - let c = solve(&last, 42); - assert_eq!(c.col, 6); - // two left, in different columns - let two = Pos::new(a & !bit(6, 5), b & !bit(4, 5)); - assert_eq!(two.moves, 40); - let c = solve(&two, 42); - assert!(c.col == 4 || c.col == 6, "{c:?}"); - assert_eq!(c.score, brute(&two)); - } - - #[test] - fn transposition_table_round_trip() { - let mut tt = Box::new(Tt::new()); - let key = pos("4433").key(); - assert!(tt.get(key).is_none()); - tt.put(key, Entry { score: -1041, depth: 20, flag: LOWER, best: 6 }); - let e = tt.get(key).unwrap(); - assert_eq!((e.score, e.depth, e.flag, e.best), (-1041, 20, LOWER, 6)); - assert!(tt.get(key + 1).is_none()); - tt.clear(); - assert!(tt.get(key).is_none()); - } - - #[test] - fn stop_and_node_cap_end_the_search_with_a_legal_move() { - let p = pos("4453"); - let mut tt = Box::new(Tt::new()); - let mut rng = 7; - let mut calls = 0; - let cfg = Config { depth: 30, nodes: u32::MAX, margin: 0, exact: false }; - let c = Search::new(&mut tt, || { - calls += 1; - calls > 20 - }) - .choose(&p, cfg, &mut rng); - assert!(p.can_play(c.col as usize)); - assert!(c.nodes <= 21 * POLL_NODES + 64, "{c:?}"); - let cfg = Config { depth: 30, nodes: 10_000, margin: 0, exact: false }; - let c = Search::new(&mut tt, || false).choose(&p, cfg, &mut rng); - assert!(c.nodes <= 10_000 + POLL_NODES, "{c:?}"); - assert!(c.depth >= 4, "{c:?}"); - } - - #[test] - fn easy_varies_but_never_blunders_a_win_or_a_block() { - let cfg = Config { depth: 2, nodes: 50_000, margin: 12, exact: true }; - let mut tt = Box::new(Tt::new()); - let mut seen = [false; W]; - for seed in 1..60u32 { - let mut rng = seed.wrapping_mul(2_654_435_761); - let c = Search::new(&mut tt, || false).choose(&Pos::default(), cfg, &mut rng); - seen[c.col as usize] = true; - let mut rng = seed; - assert_eq!(Search::new(&mut tt, || false).choose(&pos("12131"), cfg, &mut rng).col, 0); - assert_eq!(Search::new(&mut tt, || false).choose(&pos("121212"), cfg, &mut rng).col, 0); - } - assert!(seen.iter().filter(|&&s| s).count() >= 2, "{seen:?}"); - } - - /// Node rate and depth reached on the host, for the report (`cargo test --release -- --nocapture speed`). - #[test] - fn speed() { - let mut tt = Box::new(Tt::new()); - let mut rng = 3; - let mut shown = 0; - for seed in 1..200u32 { - let stones = [1u8, 6, 12, 20][shown % 4]; - let Some(p) = random_game(seed.wrapping_mul(0x2545_F491), stones) else { continue }; - if p.can_win_next() || p.non_losing().count_ones() < 2 { - continue; // no search there - } - tt.clear(); - let t = std::time::Instant::now(); - let cfg = Config { depth: 20, nodes: 200_000, margin: 0, exact: false }; - let c = Search::new(&mut tt, || false).choose(&p, cfg, &mut rng); - let ms = t.elapsed().as_secs_f64() * 1000.0; - println!("{stones:>2} stones: col {} score {} depth {} nodes {} in {ms:.1} ms ({:.0} k/s)", c.col, c.score, c.depth, c.nodes, c.nodes as f64 / ms); - shown += 1; - if shown == 8 { - break; - } - } - } -} diff --git a/apps/connect-four/src/game.rs b/apps/connect-four/src/game.rs deleted file mode 100644 index 77e2e61..0000000 --- a/apps/connect-four/src/game.rs +++ /dev/null @@ -1,373 +0,0 @@ -// The game around the engine: whose stones are where, who moves, how it ended, the levels and the stored settings. -// Pure, tested on the host. - -use crate::engine::{Config, H, Pos, W, bit, fours, has_four}; - -#[derive(Clone, Copy, PartialEq, Eq, Debug)] -pub enum Side { - You, - Bot, -} - -#[derive(Clone, Copy, PartialEq, Eq, Debug)] -pub enum Outcome { - Won, - Lost, - Draw, -} - -impl Outcome { - /// Index into a level's tally. - pub fn index(self) -> usize { - match self { - Outcome::Won => 0, - Outcome::Lost => 1, - Outcome::Draw => 2, - } - } -} - -pub const LEVELS: usize = 3; -pub const LEVEL_NAMES: [&str; LEVELS] = ["Easy", "Medium", "Hard"]; - -/// The search per level. Easy looks two plies ahead and picks at random among moves close to its best; Medium looks -/// six plies ahead and breaks exact ties at random; Hard deepens until its time (or node) budget runs out. -pub const CONFIGS: [Config; LEVELS] = [ - Config { depth: 2, nodes: 20_000, margin: 24, exact: true }, - Config { depth: 6, nodes: 300_000, margin: 0, exact: true }, - Config { depth: HARD_DEPTH, nodes: 2_000_000, margin: 0, exact: false }, -]; - -/// Hard's deepest iteration: bounds the recursion. One negamax frame is 160 B on the watch (thumbv7em release build: -/// 36 B of saved registers + 124 B of locals), so 20 plies take ~3.2 KiB of the 8 KiB stack, plus ~0.6 KiB for -/// `main` and ~0.2 KiB for the leaf's heuristic. -pub const HARD_DEPTH: u8 = 20; - -/// Wall-clock budget per bot move, ms, on top of the node budget. -pub const THINK_MS: [u32; LEVELS] = [400, 1200, 1500]; - -#[derive(Clone, Copy, PartialEq, Eq, Debug)] -pub struct Game { - pub you: u64, - pub bot: u64, - pub turn: Side, - pub outcome: Option, - /// The stones of the winning line(s), once someone has four. - pub line: u64, - /// The last stone dropped: (column, row). - pub last: Option<(u8, u8)>, -} - -impl Game { - pub fn new(bot_first: bool) -> Game { - Game { you: 0, bot: 0, turn: if bot_first { Side::Bot } else { Side::You }, outcome: None, line: 0, last: None } - } - - /// The engine's view: the side to move first. - pub fn pos(&self) -> Pos { - match self.turn { - Side::You => Pos::new(self.you, self.bot), - Side::Bot => Pos::new(self.bot, self.you), - } - } - - pub fn stones(&self) -> u8 { - (self.you | self.bot).count_ones() as u8 - } - - /// Stones the player dropped. - pub fn your_moves(&self) -> u8 { - self.you.count_ones() as u8 - } - - pub fn over(&self) -> bool { - self.outcome.is_some() - } - - pub fn can_drop(&self, col: usize) -> bool { - !self.over() && self.pos().can_play(col) - } - - /// The row the next stone in `col` lands on. - pub fn height(&self, col: usize) -> usize { - self.pos().height(col) - } - - pub fn at(&self, col: usize, row: usize) -> Option { - let b = bit(col, row); - if self.you & b != 0 { - Some(Side::You) - } else if self.bot & b != 0 { - Some(Side::Bot) - } else { - None - } - } - - /// Drops a stone of the side to move into `col`; returns its row, or None if it can't go there. - pub fn drop(&mut self, col: usize) -> Option { - if col >= W || !self.can_drop(col) { - return None; - } - let row = self.height(col); - let b = bit(col, row); - let mine = match self.turn { - Side::You => { - self.you |= b; - self.you - } - Side::Bot => { - self.bot |= b; - self.bot - } - }; - self.last = Some((col as u8, row as u8)); - if has_four(mine) { - self.line = fours(mine); - self.outcome = Some(if self.turn == Side::You { Outcome::Won } else { Outcome::Lost }); - } else if self.stones() as usize == W * H { - self.outcome = Some(Outcome::Draw); - } - self.turn = if self.turn == Side::You { Side::Bot } else { Side::You }; - Some(row) - } -} - -// Stored settings: "C4", version, level, who starts, then wins/losses/draws per level as u16 LE. 23 bytes. - -const MAGIC: [u8; 2] = *b"C4"; -const VERSION: u8 = 1; -pub const BLOB: usize = 5 + LEVELS * 3 * 2; - -#[derive(Clone, Copy, PartialEq, Eq, Debug, Default)] -pub struct Settings { - pub level: u8, - pub bot_first: bool, - /// Per level: won, lost, drawn. - pub tally: [[u16; 3]; LEVELS], -} - -impl Settings { - pub fn level(&self) -> usize { - (self.level as usize).min(LEVELS - 1) - } - - pub fn count(&mut self, outcome: Outcome) { - let t = &mut self.tally[self.level()][outcome.index()]; - *t = t.saturating_add(1); - } - - pub fn encode(&self) -> [u8; BLOB] { - let mut b = [0u8; BLOB]; - b[..2].copy_from_slice(&MAGIC); - b[2] = VERSION; - b[3] = self.level; - b[4] = self.bot_first as u8; - for (l, t) in self.tally.iter().enumerate() { - for (k, n) in t.iter().enumerate() { - let at = 5 + (l * 3 + k) * 2; - b[at..at + 2].copy_from_slice(&n.to_le_bytes()); - } - } - b - } - - /// None for anything that isn't a blob this version wrote: the app then starts from the defaults. - pub fn decode(b: &[u8]) -> Option { - if b.len() != BLOB || b[..2] != MAGIC || b[2] != VERSION || b[3] as usize >= LEVELS || b[4] > 1 { - return None; - } - let mut s = Settings { level: b[3], bot_first: b[4] == 1, tally: [[0; 3]; LEVELS] }; - for l in 0..LEVELS { - for k in 0..3 { - let at = 5 + (l * 3 + k) * 2; - s.tally[l][k] = u16::from_le_bytes([b[at], b[at + 1]]); - } - } - Some(s) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use crate::engine::{Search, Tt}; - - #[test] - fn settings_round_trip() { - let s = Settings { level: 2, bot_first: true, tally: [[1, 2, 3], [400, 0, 65535], [7, 8, 9]] }; - let b = s.encode(); - assert_eq!(b.len(), BLOB); - assert_eq!(&b[..3], b"C4\x01"); - assert_eq!(Settings::decode(&b), Some(s)); - assert_eq!(Settings::decode(&Settings::default().encode()), Some(Settings::default())); - } - - #[test] - fn bad_blobs_load_as_nothing() { - let good = Settings { level: 1, ..Settings::default() }.encode(); - assert_eq!(Settings::decode(&[]), None); - assert_eq!(Settings::decode(&good[..BLOB - 1]), None); - let mut long = [0u8; BLOB + 1]; - long[..BLOB].copy_from_slice(&good); - assert_eq!(Settings::decode(&long), None); - for (i, v) in [(0, b'X'), (2, 2), (3, 3), (4, 2)] { - let mut b = good; - b[i] = v; - assert_eq!(Settings::decode(&b), None, "byte {i}"); - } - } - - #[test] - fn tallies_count_per_level_and_saturate() { - let mut s = Settings { level: 1, ..Settings::default() }; - s.count(Outcome::Won); - s.count(Outcome::Draw); - s.level = 2; - s.count(Outcome::Lost); - assert_eq!(s.tally, [[0, 0, 0], [1, 0, 1], [0, 1, 0]]); - s.tally[2][1] = u16::MAX; - s.count(Outcome::Lost); - assert_eq!(s.tally[2][1], u16::MAX); - } - - #[test] - fn turns_alternate_and_stones_stack() { - let mut g = Game::new(false); - assert_eq!(g.turn, Side::You); - assert_eq!(g.drop(3), Some(0)); - assert_eq!(g.turn, Side::Bot); - assert_eq!(g.drop(3), Some(1)); - assert_eq!(g.at(3, 0), Some(Side::You)); - assert_eq!(g.at(3, 1), Some(Side::Bot)); - assert_eq!(g.at(3, 2), None); - assert_eq!(g.last, Some((3, 1))); - assert_eq!(g.drop(7), None); - let g = Game::new(true); - assert_eq!(g.turn, Side::Bot); - } - - #[test] - fn a_full_column_takes_no_more() { - let mut g = Game::new(false); - for _ in 0..6 { - assert!(g.drop(0).is_some()); - } - assert!(!g.can_drop(0)); - assert_eq!(g.drop(0), None); - assert_eq!(g.stones(), 6); - } - - #[test] - fn four_ends_the_game_with_its_line() { - let mut g = Game::new(false); - for c in [0, 0, 1, 1, 2, 2] { - g.drop(c); - } - assert!(!g.over()); - g.drop(3); - assert_eq!(g.outcome, Some(Outcome::Won)); - assert_eq!(g.line, bit(0, 0) | bit(1, 0) | bit(2, 0) | bit(3, 0)); - assert!(!g.can_drop(4)); - assert_eq!(g.drop(4), None); - let mut g = Game::new(true); - for c in [0, 6, 0, 6, 0, 6, 0] { - g.drop(c); - } - assert_eq!(g.outcome, Some(Outcome::Lost)); - } - - #[test] - fn a_full_board_without_four_is_a_draw() { - // columns filled in this order make no four (rows alternate in pairs) - let rows = ["1121122", "2212211", "1121122", "2212211", "1121122", "2212211"]; - let mut g = Game::new(false); - // drop row by row; the owner of each cell must be the side to move, so drop in an order that alternates - let mut cells: Vec<(usize, usize, Side)> = Vec::new(); - for (r, row) in rows.iter().enumerate() { - for (c, ch) in row.bytes().enumerate() { - cells.push((c, r, if ch == b'1' { Side::You } else { Side::Bot })); - } - } - // play greedily: the lowest open cell owned by the side to move - for _ in 0..42 { - let pick = cells.iter().position(|&(c, r, s)| s == g.turn && g.height(c) == r).expect("a legal order"); - let (c, _, _) = cells.remove(pick); - assert!(!g.over()); - g.drop(c); - } - assert_eq!(g.outcome, Some(Outcome::Draw)); - assert_eq!(g.line, 0); - } - - /// Plays one game between two levels; returns the first level's result. - fn duel(a: usize, b: usize, a_first: bool, seed: u32) -> Outcome { - let mut tt = Box::new(Tt::new()); - let mut rng = seed; - let mut g = Game::new(!a_first); // "You" is level a - while !g.over() { - let level = if g.turn == Side::You { a } else { b }; - let mut cfg = CONFIGS[level]; - let cap: u32 = std::env::var("C4_NODES").ok().and_then(|v| v.parse().ok()).unwrap_or(40_000); - cfg.nodes = cfg.nodes.min(cap); // keep the debug test quick - let c = Search::new(&mut tt, || false).choose(&g.pos(), cfg, &mut rng); - assert!(g.drop(c.col as usize).is_some()); - } - g.outcome.unwrap() - } - - /// Nodes and depth per level over a few positions (`C4_FULL=1 cargo test --release -- --nocapture levels_cost` - /// for Hard's full node budget; the default caps it to keep the debug run short). - #[test] - fn levels_cost() { - let mut tt = Box::new(Tt::new()); - let full = std::env::var("C4_FULL").is_ok(); - for (level, cfg) in CONFIGS.iter().enumerate() { - let mut cfg = *cfg; - if !full { - cfg.nodes = cfg.nodes.min(100_000); - } - let cfg = &cfg; - let (mut max_nodes, mut min_depth, mut max_depth) = (0, u8::MAX, 0); - for seed in 1..=12u32 { - let mut g = Game::new(false); - let mut rng = seed.wrapping_mul(2_654_435_761); - // a few random opening moves, then a position to think about - for _ in 0..(seed % 9 + 2) { - let cols: Vec = (0..W).filter(|&c| g.can_drop(c)).collect(); - g.drop(cols[crate::engine::rand(&mut rng) as usize % cols.len()]); - if g.over() { - break; - } - } - if g.over() { - continue; - } - tt.clear(); - let c = Search::new(&mut tt, || false).choose(&g.pos(), *cfg, &mut rng); - if c.depth > 0 { - max_nodes = max_nodes.max(c.nodes); - min_depth = min_depth.min(c.depth); - max_depth = max_depth.max(c.depth); - } - } - println!("{}: up to {max_nodes} nodes, depth {min_depth}..{max_depth}", LEVEL_NAMES[level]); - assert!(max_nodes <= cfg.nodes + crate::engine::POLL_NODES); - } - } - - #[test] - fn harder_levels_beat_easier_ones() { - let (mut hard, mut medium, mut top) = ([0; 3], [0; 3], [0; 3]); - let games: u32 = std::env::var("C4_GAMES").ok().and_then(|v| v.parse().ok()).unwrap_or(6); - for seed in 1..=games { - hard[duel(2, 0, seed % 2 == 0, seed * 7919).index()] += 1; - medium[duel(1, 0, seed % 2 == 1, seed * 104_729).index()] += 1; - top[duel(2, 1, seed % 2 == 1, seed * 15_485_863).index()] += 1; - } - println!("won/lost/drawn: hard-easy {hard:?} medium-easy {medium:?} hard-medium {top:?}"); - assert!(hard[0] >= 5, "hard vs easy: {hard:?}"); - assert!(medium[0] >= 4, "medium vs easy: {medium:?}"); - assert!(top[0] > top[1], "hard vs medium: {top:?}"); - } -} diff --git a/apps/connect-four/src/main.rs b/apps/connect-four/src/main.rs deleted file mode 100644 index f73bd6b..0000000 --- a/apps/connect-four/src/main.rs +++ /dev/null @@ -1,378 +0,0 @@ -#![cfg_attr(any(target_os = "none", wp2_sim), no_main, cfg_attr(target_os = "none", no_std))] - -#[cfg_attr(not(any(target_os = "none", wp2_sim)), allow(dead_code))] -mod engine; -#[cfg_attr(not(any(target_os = "none", wp2_sim)), allow(dead_code))] -mod game; -#[cfg_attr(not(any(target_os = "none", wp2_sim)), allow(dead_code))] -mod view; - -#[cfg(not(any(target_os = "none", wp2_sim)))] -fn main() {} - -#[cfg(any(target_os = "none", wp2_sim))] -mod device { - use crate::engine::{Search, Tt}; - use crate::game::{BLOB, CONFIGS, Game, LEVELS, Outcome, Settings, Side, THINK_MS}; - use crate::view::{self, MenuHit, ResultHit}; - use cmf_wp2_app::{Api, BUTTON, CROWN, PAUSE, RESUME, TOUCH_DOWN}; - use cmf_wp2_ui::ONE; - use cmf_wp2_ui::haptic::{DOUBLE, Motor, Pattern, TICK}; - - cmf_wp2_app::entry!(main); - cmf_wp2_app::app_icon!(); - - /// The transposition table, 24 KiB: a static, the stack is 8 KiB. - static mut TT: Tt = Tt::new(); - - /// Drop animation frame. - const FRAME_MS: u32 = 25; - /// The bot's disc waits over its column this long after yours lands (or after it decided, if that took longer). - const BOT_DELAY_MS: u32 = 450; - /// The finished board stays up this long before the results (a tap skips it). - const SHOW_MS: u32 = 2600; - /// While the bot thinks, input is looked at this often (BUTTON must end the app within 1000 ms). - const POLL_MS: u32 = 30; - - const WIN: Pattern = Pattern::new(&[(600, 70), (0, 70), (600, 70), (0, 70), (900, 160), (0, 0)]); - const LOSS: Pattern = Pattern::new(&[(800, 260), (0, 0)]); - - #[derive(Clone, Copy, PartialEq)] - enum Mode { - Menu, - Play, - /// The finished board with the winning line. - Shown, - Result, - } - - #[derive(Clone, Copy)] - struct Drop { - col: usize, - row: usize, - side: Side, - start: u32, - ms: u32, - } - - impl Drop { - fn new(g: &Game, col: usize, now: u32) -> Drop { - let row = g.height(col); - let ms = 140 + (view::cell_y(row) - view::HOVER_Y) as u32 / 2; - Drop { col, row, side: g.turn, start: now, ms } - } - - /// The disc's centre: falling with gravity (quadratic ease-in). - fn y(&self, now: u32) -> i32 { - let t = now.wrapping_sub(self.start).min(self.ms) as i32; - let u = t * ONE / self.ms as i32; - view::HOVER_Y + (view::cell_y(self.row) - view::HOVER_Y) * (u * u / ONE) / ONE - } - } - - fn due(now: u32, at: u32) -> bool { - (now.wrapping_sub(at) as i32) >= 0 - } - - fn left(now: u32, at: u32) -> u32 { - (at.wrapping_sub(now) as i32).max(0) as u32 - } - - // true on RESUME, false on BUTTON - fn paused(api: &Api) -> bool { - loop { - match api.event(u32::MAX).map(|e| e.kind) { - Some(RESUME) => return true, - Some(BUTTON) => return false, - _ => {} - } - } - } - - fn seed(api: &Api) -> u32 { - let t = api.time().map_or(0, |t| (t.minute as u32 * 60 + t.second as u32) * 1000 + t.millis as u32); - api.now().wrapping_mul(2_654_435_761) ^ t - } - - struct Thought { - col: Option, - /// A popup paused the app meanwhile: the screen needs a full repaint. - repaint: bool, - } - - /// The bot's move. Runs the search here, in the event loop's thread, and looks at input every `POLL_MS` from - /// inside it: BUTTON ends the search at once (`col` None: leave), PAUSE blocks until RESUME (the pause does not - /// count against the budget), taps and the crown are dropped. The search stops on its node budget or the - /// level's time budget, whichever comes first, and plays the best move of its deepest finished iteration. - fn think(api: &Api, motor: &mut Motor, g: &Game, level: usize, tt: &mut Tt, rng: &mut u32) -> Thought { - let start = api.now(); - let mut deadline = start.wrapping_add(THINK_MS[level]); - let mut polled = start; - let mut calls = 0u32; - let (mut quit, mut repaint) = (false, false); - let choice = { - let mut search = Search::new(tt, || { - calls += 1; - let now = api.now(); - // by time on the watch; every 64th call too, for the simulator, whose clock barely moves meanwhile - if now.wrapping_sub(polled) >= POLL_MS || calls % 64 == 0 { - polled = now; - while let Some(e) = api.event(0) { - match e.kind { - BUTTON => { - quit = true; - return true; - } - PAUSE => { - motor.off(); - let t0 = api.now(); - if !paused(api) { - quit = true; - return true; - } - deadline = deadline.wrapping_add(api.now().wrapping_sub(t0)); - repaint = true; - } - _ => {} - } - } - } - due(api.now(), deadline) - }); - search.choose(&g.pos(), CONFIGS[level], rng) - }; - Thought { col: if quit { None } else { Some(choice.col as usize) }, repaint } - } - - fn save(api: &Api, st: &Settings, saved: &mut Settings) { - if st != saved { - api.save(&st.encode()); - *saved = *st; - } - } - - fn main(api: &'static Api) -> i32 { - let mut screen = api; - let mut motor = Motor::new(api); // dropped on return: the motor goes off - let mut blob = [0u8; BLOB + 8]; - let n = api.load(&mut blob); - let fresh = Settings { level: 1, ..Settings::default() }; - let mut st = if n > 0 { Settings::decode(&blob[..n as usize]).unwrap_or(fresh) } else { fresh }; - let mut saved = st; - // SAFETY: the only reference to TT; the app is one thread - let tt = unsafe { &mut *core::ptr::addr_of_mut!(TT) }; - let mut rng = seed(api); - - let mut mode = Mode::Menu; - let mut g = Game::new(st.bot_first); - let mut cursor = 3usize; - let mut drop: Option = None; - // the bot's column and when its disc starts to fall - let mut bot: Option<(usize, u32)> = None; - let mut shown_until = 0u32; - let mut repaint = true; - - loop { - motor.update(); - if repaint { - repaint = false; - match mode { - Mode::Menu => view::menu(&mut screen, &st), - Mode::Play | Mode::Shown => { - view::game(&mut screen, &g, &st, Some(cursor)); - if let Some((col, _)) = bot { - view::hover(&mut screen, Some((col, Side::Bot))); - } - } - Mode::Result => view::result(&mut screen, &g, &st), - } - api.show(); - } - let now = api.now(); - - if let Some(d) = drop { - if due(now, d.start.wrapping_add(d.ms)) { - // landed - drop = None; - let prev = g.last; - g.drop(d.col); - view::falling(&mut screen, &g, d.col, None); - if let Some((c, r)) = prev.filter(|&(c, _)| c as usize != d.col) { - view::redraw_cell(&mut screen, &g, c as usize, r as usize); - } - let (text, c) = view::status_text(&g); - view::status(&mut screen, text, c); - if let Some(outcome) = g.outcome { - view::board(&mut screen, &g); // the winning line lit, the rest dimmed - motor.play(match outcome { - Outcome::Won => WIN, - Outcome::Lost => LOSS, - Outcome::Draw => DOUBLE, - }); - st.count(outcome); - save(api, &st, &mut saved); // now: the app can be ended without notice - mode = Mode::Shown; - shown_until = now.wrapping_add(SHOW_MS); - } else { - motor.play(TICK); - if g.turn == Side::You { - view::hover(&mut screen, Some((cursor, Side::You))); - } - } - api.show(); - } else { - view::falling(&mut screen, &g, d.col, Some((d.y(now), d.side))); - api.show(); - } - } - - if mode == Mode::Play && drop.is_none() && bot.is_none() && !g.over() && g.turn == Side::Bot { - let t = think(api, &mut motor, &g, st.level(), tt, &mut rng); - let Some(col) = t.col else { - save(api, &st, &mut saved); - return 0; - }; - let now = api.now(); - // after your disc lands, give the bot a moment to "look" before it drops - let at = if g.stones() == 0 { now.wrapping_add(BOT_DELAY_MS / 2) } else { now.wrapping_add(BOT_DELAY_MS) }; - bot = Some((col, at)); - if t.repaint { - repaint = true; - } else { - view::hover(&mut screen, Some((col, Side::Bot))); - api.show(); - } - continue; - } - - let now = api.now(); - if let Some((col, at)) = bot - && drop.is_none() - && due(now, at) - { - bot = None; - drop = Some(Drop::new(&g, col, now)); - continue; - } - if mode == Mode::Shown && due(now, shown_until) { - mode = Mode::Result; - repaint = true; - continue; - } - - let mut wait = u32::MAX; - if drop.is_some() { - wait = FRAME_MS; - } - if let Some((_, at)) = bot { - wait = wait.min(left(now, at)); - } - if mode == Mode::Shown { - wait = wait.min(left(now, shown_until)); - } - let wait = motor.wait().map_or(wait, |m| m.min(wait)); - let Some(e) = api.event(wait) else { continue }; - match e.kind { - BUTTON => { - save(api, &st, &mut saved); - return 0; - } - PAUSE => { - motor.off(); - let t0 = api.now(); - if !paused(api) { - save(api, &st, &mut saved); - return 0; - } - // timers resume where they stopped - let dt = api.now().wrapping_sub(t0); - if let Some(d) = drop.as_mut() { - d.start = d.start.wrapping_add(dt); - } - if let Some((_, at)) = bot.as_mut() { - *at = at.wrapping_add(dt); - } - shown_until = shown_until.wrapping_add(dt); - repaint = true; - } - TOUCH_DOWN => { - let (x, y) = (e.x as i32, e.y as i32); - match mode { - Mode::Menu => match view::menu_hit(x, y) { - Some(MenuHit::Level) => { - st.level = (st.level + 1) % LEVELS as u8; - view::menu_row(&mut screen, &st, MenuHit::Level); - view::menu_tally(&mut screen, &st); - motor.play(TICK); - api.show(); - } - Some(MenuHit::First) => { - st.bot_first = !st.bot_first; - view::menu_row(&mut screen, &st, MenuHit::First); - motor.play(TICK); - api.show(); - } - Some(MenuHit::Play) => { - save(api, &st, &mut saved); - motor.play(TICK); - g = Game::new(st.bot_first); - tt.clear(); - cursor = 3; - mode = Mode::Play; - repaint = true; - } - None => {} - }, - Mode::Play => { - if g.turn == Side::You && drop.is_none() && !g.over() { - let col = view::column_at(x, y).unwrap_or(cursor); - if g.can_drop(col) { - cursor = col; - view::hover(&mut screen, None); - drop = Some(Drop::new(&g, col, api.now())); - } - } - } - Mode::Shown => { - mode = Mode::Result; - repaint = true; - } - Mode::Result => match view::result_hit(x, y) { - Some(ResultHit::Again) => { - motor.play(TICK); - g = Game::new(st.bot_first); - tt.clear(); - cursor = 3; - mode = Mode::Play; - repaint = true; - } - Some(ResultHit::Menu) => { - mode = Mode::Menu; - repaint = true; - } - None => {} - }, - } - } - CROWN => match mode { - Mode::Menu => { - st.level = (st.level as i16 + e.delta).clamp(0, LEVELS as i16 - 1) as u8; - view::menu_row(&mut screen, &st, MenuHit::Level); - view::menu_tally(&mut screen, &st); - api.show(); - } - Mode::Play if g.turn == Side::You && drop.is_none() && !g.over() => { - let c = (cursor as i16 + e.delta).clamp(0, 6) as usize; - if c != cursor { - cursor = c; - view::hover(&mut screen, Some((cursor, Side::You))); - api.show(); - } - } - _ => {} - }, - _ => {} - } - } - } -} diff --git a/apps/connect-four/src/view.rs b/apps/connect-four/src/view.rs deleted file mode 100644 index 6451b36..0000000 --- a/apps/connect-four/src/view.rs +++ /dev/null @@ -1,466 +0,0 @@ -// Drawing and hit testing, through cmf-wp2-ui's Surface: the watch draws with `&Api`, the tests with `Fb`. The board -// is 7 × 44 px wide and sits low in the circle; above it a row for the disc you are about to drop, above that one -// status line. Everything stays inside the round panel (tested below). - -use crate::engine::{H, W, bit}; -use crate::game::{Game, LEVEL_NAMES, Outcome, Settings, Side}; -use cmf_wp2_ui::draw::{disc, rrect}; -use cmf_wp2_ui::text::{big, big_width, centre, int}; -use cmf_wp2_ui::{Rgb, Surface}; - -pub const BLACK: Rgb = Rgb(0, 0, 0); -pub const WHITE: u16 = 0xFFFF; -/// Secondary text. -pub const GREY: u16 = 0x8C71; -/// The board and the menu's rows: the stock selected-row grey. -pub const PANEL: Rgb = Rgb::from565(0x2124); -/// The stock orange accent: the main button. -pub const ACCENT: Rgb = Rgb::from565(0xFD20); -pub const RED: Rgb = Rgb(240, 56, 48); -pub const YELLOW: Rgb = Rgb(255, 204, 0); -pub const GREEN: u16 = cmf_wp2_ui::color::rgb565(60, 220, 110); - -pub fn colour(side: Side) -> Rgb { - match side { - Side::You => RED, - Side::Bot => YELLOW, - } -} - -// Board geometry. -pub const CELL: i32 = 44; -pub const DISC_R: i32 = 18; -pub const GRID_X: i32 = 233 - CELL * W as i32 / 2; -/// Bottom edge of the bottom row. -pub const GRID_BOTTOM: i32 = 386; -pub const GRID_TOP: i32 = GRID_BOTTOM - CELL * H as i32; -const PAD: i32 = 8; -pub const FRAME_TOP: i32 = GRID_TOP - PAD; -pub const FRAME_BOTTOM: i32 = GRID_BOTTOM + PAD; -/// Corner radius: small enough that the corners stay outside the column strips the drop animation repaints. -const FRAME_R: i32 = PAD; -/// The row the next disc waits in. -pub const HOVER_Y: i32 = FRAME_TOP - 6 - DISC_R; -const HOVER_TOP: i32 = HOVER_Y - DISC_R - 4; -pub const STATUS_Y: i32 = 38; -pub const FOOTER_Y: i32 = FRAME_BOTTOM + 10; - -pub fn cell_x(col: usize) -> i32 { - GRID_X + col as i32 * CELL + CELL / 2 -} - -pub fn cell_y(row: usize) -> i32 { - GRID_BOTTOM - row as i32 * CELL - CELL / 2 -} - -/// The column under a tap anywhere from the hover row down to the board's bottom edge. -pub fn column_at(x: i32, y: i32) -> Option { - if !(HOVER_TOP..FRAME_BOTTOM).contains(&y) || x < GRID_X || x >= GRID_X + CELL * W as i32 { - return None; - } - Some(((x - GRID_X) / CELL) as usize) -} - -/// A small text buffer: no heap, no `core::fmt`. -pub struct Buf { - b: [u8; 32], - n: usize, -} - -impl Buf { - pub fn new() -> Buf { - Buf { b: [0; 32], n: 0 } - } - - pub fn s(&mut self, s: &str) -> &mut Buf { - let k = s.len().min(self.b.len() - self.n); - self.b[self.n..self.n + k].copy_from_slice(&s.as_bytes()[..k]); - self.n += k; - self - } - - pub fn n(&mut self, v: u32) -> &mut Buf { - let mut t = [0u8; 11]; - let s = int(v.min(i32::MAX as u32) as i32, &mut t); - self.s(s) - } - - pub fn str(&self) -> &str { - core::str::from_utf8(&self.b[..self.n]).unwrap_or("?") - } -} - -impl Default for Buf { - fn default() -> Self { - Buf::new() - } -} - -fn clear(s: &mut impl Surface) { - s.rect(0, 0, 466, 466, 0); -} - -/// One board cell: the hole or its disc. `line`: the winning stones once the game is over (the others are dimmed). -fn cell(s: &mut impl Surface, g: &Game, col: usize, row: usize) { - let (x, y) = (cell_x(col), cell_y(row)); - let Some(side) = g.at(col, row) else { - disc(s, x, y, DISC_R, BLACK, PANEL); - return; - }; - let c = colour(side); - if g.line != 0 { - if g.line & bit(col, row) != 0 { - disc(s, x, y, DISC_R + 3, Rgb(255, 255, 255), PANEL); - disc(s, x, y, DISC_R - 2, c, Rgb(255, 255, 255)); - } else { - disc(s, x, y, DISC_R, c.scale(420), PANEL); - } - return; - } - disc(s, x, y, DISC_R, c, PANEL); - if g.last == Some((col as u8, row as u8)) { - disc(s, x, y, 5, c.scale(640), c); // where the last stone went - } -} - -/// Repaints one cell (after a drop, or to take the last-stone mark off). -pub fn redraw_cell(s: &mut impl Surface, g: &Game, col: usize, row: usize) { - s.rect(GRID_X + col as i32 * CELL, cell_y(row) - CELL / 2, CELL, CELL, PANEL.rgb565()); - cell(s, g, col, row); -} - -pub fn board(s: &mut impl Surface, g: &Game) { - let w = CELL * W as i32 + 2 * PAD; - rrect(s, GRID_X - PAD, FRAME_TOP, w, FRAME_BOTTOM - FRAME_TOP, FRAME_R, PANEL, BLACK); - for col in 0..W { - for row in 0..H { - cell(s, g, col, row); - } - } -} - -/// The hover row: the disc about to drop over `col`, or nothing. -pub fn hover(s: &mut impl Surface, at: Option<(usize, Side)>) { - s.rect(GRID_X - PAD, HOVER_TOP, CELL * W as i32 + 2 * PAD, FRAME_TOP - HOVER_TOP, 0); - if let Some((col, side)) = at { - disc(s, cell_x(col), HOVER_Y, DISC_R, colour(side), BLACK); - } -} - -/// One column, from the hover row to the bottom of the board, with a disc falling at height `y` (its centre), or -/// none once it landed. -pub fn falling(s: &mut impl Surface, g: &Game, col: usize, disc_at: Option<(i32, Side)>) { - let x0 = GRID_X + col as i32 * CELL; - s.rect(x0, HOVER_TOP, CELL, FRAME_TOP - HOVER_TOP, 0); - s.rect(x0, FRAME_TOP, CELL, FRAME_BOTTOM - FRAME_TOP, PANEL.rgb565()); - for row in 0..H { - cell(s, g, col, row); - } - if let Some((y, side)) = disc_at { - let under = if y - DISC_R >= FRAME_TOP { PANEL } else { BLACK }; - disc(s, cell_x(col), y, DISC_R, colour(side), under); - } -} - -/// The status line on top. -pub fn status(s: &mut impl Surface, text: &str, c: u16) { - s.rect(120, STATUS_Y - 4, 226, 24, 0); - centre(s, 233, STATUS_Y, text, c); -} - -/// What the status line says in a game. -pub fn status_text(g: &Game) -> (&'static str, u16) { - match g.outcome { - Some(Outcome::Won) => ("You win!", GREEN), - Some(Outcome::Lost) => ("Bot wins", YELLOW.rgb565()), - Some(Outcome::Draw) => ("Draw", WHITE), - None if g.turn == Side::You => ("Your move", WHITE), - None => ("Thinking", GREY), - } -} - -/// The level under the board (the tallies are on the start and results screens: the bottom line is too short). -pub fn footer(s: &mut impl Surface, st: &Settings) { - s.rect(130, FOOTER_Y - 2, 206, 20, 0); - centre(s, 233, FOOTER_Y, LEVEL_NAMES[st.level()], GREY); -} - -/// The whole game screen. -pub fn game(s: &mut impl Surface, g: &Game, st: &Settings, cursor: Option) { - clear(s); - let (text, c) = status_text(g); - status(s, text, c); - hover(s, cursor.filter(|_| !g.over() && g.turn == Side::You).map(|c| (c, Side::You))); - board(s, g); - footer(s, st); -} - -// The start screen: title, two setting rows, Play, the level's tally. - -pub const ROW_X: i32 = 63; -pub const ROW_W: i32 = 340; -pub const ROW_H: i32 = 56; -pub const LEVEL_Y: i32 = 160; -pub const FIRST_Y: i32 = 226; -pub const PLAY_Y: i32 = 300; -pub const PLAY_W: i32 = 200; -const TITLE_Y: i32 = 62; -const MENU_TALLY_Y: i32 = 382; - -#[derive(Clone, Copy, PartialEq, Eq, Debug)] -pub enum MenuHit { - Level, - First, - Play, -} - -pub fn menu_hit(x: i32, y: i32) -> Option { - let inside = |top: i32| (top..top + ROW_H).contains(&y) && (ROW_X - 20..ROW_X + ROW_W + 20).contains(&x); - if inside(LEVEL_Y) { - Some(MenuHit::Level) - } else if inside(FIRST_Y) { - Some(MenuHit::First) - } else if (PLAY_Y - 6..PLAY_Y + ROW_H + 10).contains(&y) && (233 - PLAY_W / 2 - 30..233 + PLAY_W / 2 + 30).contains(&x) { - Some(MenuHit::Play) - } else { - None - } -} - -fn setting(s: &mut impl Surface, y: i32, label: &str, value: &str) { - rrect(s, ROW_X, y, ROW_W, ROW_H, ROW_H / 2, PANEL, BLACK); - s.text(ROW_X + 28, y + 20, label, GREY); - let w = cmf_wp2_ui::text::width(value); - s.text(ROW_X + ROW_W - 28 - w, y + 20, value, WHITE); -} - -pub fn menu_row(s: &mut impl Surface, st: &Settings, which: MenuHit) { - match which { - MenuHit::Level => setting(s, LEVEL_Y, "Level", LEVEL_NAMES[st.level()]), - MenuHit::First => setting(s, FIRST_Y, "First", if st.bot_first { "Bot" } else { "You" }), - MenuHit::Play => {} - } -} - -pub fn menu_tally(s: &mut impl Surface, st: &Settings) { - s.rect(100, MENU_TALLY_Y - 2, 266, 20, 0); - let t = st.tally[st.level()]; - let mut b = Buf::new(); - b.s("W ").n(t[0] as u32).s(" L ").n(t[1] as u32).s(" D ").n(t[2] as u32); - centre(s, 233, MENU_TALLY_Y, b.str(), GREY); -} - -pub fn menu(s: &mut impl Surface, st: &Settings) { - clear(s); - let title = "Connect Four"; - big(s, 233 - big_width(title, 3) / 2, TITLE_Y, title, 3, WHITE); - for (i, side) in [Side::You, Side::Bot, Side::You, Side::Bot].into_iter().enumerate() { - disc(s, 233 - 66 + 44 * i as i32, 118, 15, colour(side), BLACK); - } - menu_row(s, st, MenuHit::Level); - menu_row(s, st, MenuHit::First); - rrect(s, 233 - PLAY_W / 2, PLAY_Y, PLAY_W, ROW_H, ROW_H / 2, ACCENT, BLACK); - centre(s, 233, PLAY_Y + 20, "Play", 0); - menu_tally(s, st); -} - -// The results screen. - -pub const AGAIN_Y: i32 = 262; -pub const AGAIN_W: i32 = 240; -pub const MENU_Y: i32 = 330; -pub const MENU_W: i32 = 160; - -#[derive(Clone, Copy, PartialEq, Eq, Debug)] -pub enum ResultHit { - Again, - Menu, -} - -pub fn result_hit(x: i32, y: i32) -> Option { - let near = |cx_w: i32| (233 - cx_w / 2 - 30..233 + cx_w / 2 + 30).contains(&x); - if (AGAIN_Y - 6..AGAIN_Y + ROW_H + 6).contains(&y) && near(AGAIN_W) { - Some(ResultHit::Again) - } else if (MENU_Y - 6..MENU_Y + ROW_H + 14).contains(&y) && near(MENU_W) { - Some(ResultHit::Menu) - } else { - None - } -} - -pub fn result(s: &mut impl Surface, g: &Game, st: &Settings) { - clear(s); - let (text, c) = match g.outcome { - Some(Outcome::Won) => ("You win", GREEN), - Some(Outcome::Lost) => ("Bot wins", YELLOW.rgb565()), - _ => ("Draw", WHITE), - }; - big(s, 233 - big_width(text, 3) / 2, 76, text, 3, c); - let mut b = Buf::new(); - b.s(LEVEL_NAMES[st.level()]).s(", ").n(g.your_moves() as u32).s(if g.your_moves() == 1 { " move" } else { " moves" }); - centre(s, 233, 116, b.str(), GREY); - let t = st.tally[st.level()]; - for (i, (n, label)) in [(t[0], "Wins"), (t[1], "Losses"), (t[2], "Draws")].into_iter().enumerate() { - let cx = 233 + (i as i32 - 1) * 112; - let mut d = [0u8; 11]; - let num = int(n as i32, &mut d); - big(s, cx - big_width(num, 3) / 2, 162, num, 3, WHITE); - centre(s, cx, 196, label, GREY); - } - rrect(s, 233 - AGAIN_W / 2, AGAIN_Y, AGAIN_W, ROW_H, ROW_H / 2, ACCENT, BLACK); - centre(s, 233, AGAIN_Y + 20, "Play again", 0); - rrect(s, 233 - MENU_W / 2, MENU_Y, MENU_W, ROW_H, ROW_H / 2, PANEL, BLACK); - centre(s, 233, MENU_Y + 20, "Menu", WHITE); -} - -#[cfg(test)] -mod tests { - use super::*; - use cmf_wp2_ui::{Fb, SIZE}; - - fn screen() -> Vec { - vec![0u16; (SIZE * SIZE) as usize] - } - - /// Nothing lit within `margin` px of the round edge or outside it. - fn inside_circle(px: &[u16], margin: i32) -> Result<(), (i32, i32)> { - let r = 233 - margin; - for y in 0..SIZE { - for x in 0..SIZE { - let (dx, dy) = (2 * x + 1 - SIZE, 2 * y + 1 - SIZE); - if dx * dx + dy * dy > 4 * r * r && px[(y * SIZE + x) as usize] != 0 { - return Err((x, y)); - } - } - } - Ok(()) - } - - fn sample_game() -> Game { - let mut g = Game::new(false); - for c in [3, 3, 2, 4, 1, 0, 6, 6, 5, 5, 6, 0, 0, 6] { - g.drop(c); - } - g - } - - fn tallies() -> Settings { - Settings { level: 1, bot_first: true, tally: [[0; 3], [999, 999, 999], [0; 3]] } - } - - #[test] - fn every_screen_fits_the_circle() { - let st = tallies(); - let mut won = Game::new(false); - for c in [0, 0, 1, 1, 2, 2, 3] { - won.drop(c); - } - let mut full = Game::new(false); - // fill every column so discs sit in all corners - for _ in 0..H { - for c in [0, 6, 1, 5, 2, 4, 3] { - full.drop(c); - } - } - for (name, draw) in [ - ("menu", &(|s: &mut Fb| menu(s, &st)) as &dyn Fn(&mut Fb)), - ("game", &|s: &mut Fb| game(s, &sample_game(), &st, Some(0))), - ("game right", &|s: &mut Fb| game(s, &sample_game(), &st, Some(6))), - ("won", &|s: &mut Fb| game(s, &won, &st, None)), - ("full", &|s: &mut Fb| game(s, &full, &st, None)), - ("result", &|s: &mut Fb| result(s, &won, &st)), - ("falling", &|s: &mut Fb| falling(s, &sample_game(), 0, Some((HOVER_Y, Side::You)))), - ] { - let mut px = screen(); - draw(&mut Fb::new(&mut px)); - assert_eq!(inside_circle(&px, 4), Ok(()), "{name}"); - } - } - - #[test] - fn taps_find_their_column() { - for col in 0..W { - assert_eq!(column_at(cell_x(col), cell_y(0)), Some(col)); - assert_eq!(column_at(cell_x(col), cell_y(H - 1)), Some(col)); - assert_eq!(column_at(cell_x(col), HOVER_Y), Some(col)); - assert_eq!(column_at(GRID_X + col as i32 * CELL, cell_y(2)), Some(col)); - assert_eq!(column_at(GRID_X + col as i32 * CELL + CELL - 1, cell_y(2)), Some(col)); - } - assert_eq!(column_at(GRID_X - 1, cell_y(2)), None); - assert_eq!(column_at(GRID_X + 7 * CELL, cell_y(2)), None); - assert_eq!(column_at(233, STATUS_Y), None); - assert_eq!(column_at(233, FOOTER_Y + 4), None); - } - - #[test] - fn discs_land_where_the_game_says() { - let g = sample_game(); - let mut px = screen(); - let mut fb = Fb::new(&mut px); - game(&mut fb, &g, &tallies(), None); - for col in 0..W { - for row in 0..H { - let want = match g.at(col, row) { - Some(side) => colour(side).rgb565(), - None => 0, - }; - // a little off centre: the centre of the last stone carries its mark - assert_eq!(fb.at(cell_x(col) + 9, cell_y(row)), want, "{col},{row}"); - } - } - // between holes: the board - assert_eq!(fb.at(GRID_X + CELL, cell_y(0) - CELL / 2), PANEL.rgb565()); - } - - #[test] - fn a_falling_disc_repaint_matches_the_board_once_it_lands() { - let mut g = sample_game(); - let st = tallies(); - let row = g.height(1); - let side = g.turn; - let mut px = screen(); - let mut fb = Fb::new(&mut px); - game(&mut fb, &g, &st, None); - for y in (HOVER_Y..cell_y(row)).step_by(17) { - falling(&mut fb, &g, 1, Some((y, side))); - } - let prev = g.last; - g.drop(1); - falling(&mut fb, &g, 1, None); - hover(&mut fb, None); - if let Some((c, r)) = prev { - redraw_cell(&mut fb, &g, c as usize, r as usize); - } - let mut want = screen(); - game(&mut Fb::new(&mut want), &g, &st, None); - // the status line differs (the caller repaints it); compare the board and hover rows - for y in HOVER_TOP..FRAME_BOTTOM { - for x in 0..SIZE { - assert_eq!(px[(y * SIZE + x) as usize], want[(y * SIZE + x) as usize], "{x},{y}"); - } - } - } - - #[test] - fn menu_and_result_taps() { - assert_eq!(menu_hit(233, LEVEL_Y + 20), Some(MenuHit::Level)); - assert_eq!(menu_hit(233, FIRST_Y + 20), Some(MenuHit::First)); - assert_eq!(menu_hit(233, PLAY_Y + 20), Some(MenuHit::Play)); - assert_eq!(menu_hit(233, 60), None); - assert_eq!(result_hit(233, AGAIN_Y + 20), Some(ResultHit::Again)); - assert_eq!(result_hit(233, MENU_Y + 20), Some(ResultHit::Menu)); - assert_eq!(result_hit(233, 100), None); - } - - #[test] - fn text_buffer() { - let mut b = Buf::new(); - b.s("W ").n(0).s(" L ").n(65535); - assert_eq!(b.str(), "W 0 L 65535"); - let mut b = Buf::new(); - for _ in 0..10 { - b.s("abcd"); - } - assert_eq!(b.str().len(), 32); - } -} diff --git a/apps/connect-four/store.md b/apps/connect-four/store.md deleted file mode 100644 index 55a80ff..0000000 --- a/apps/connect-four/store.md +++ /dev/null @@ -1,21 +0,0 @@ -Connect Four against a bot. Drop your red discs into the seven columns and get four in a row — across, up or -diagonally — before the bot's yellow ones do. - -Tap a column to drop a disc into it. You can also turn the crown to move the disc waiting above the board, then tap -anywhere outside the board to drop it there. The last disc played carries a small dot, and when someone wins, the four -light up and the watch buzzes. - -Three levels, picked on the start screen together with who goes first: - -- **Easy** looks two moves ahead and plays loosely, but never misses a win in one or an obvious block. -- **Medium** looks six moves ahead. -- **Hard** searches as deep as it can in about a second and a half (negamax with alpha-beta pruning, iterative - deepening and a transposition table), and knows which rows win the endgame. - -Wins, losses and draws are counted per level and kept on the watch, with your level and who starts. Press the crown or -swipe right to leave. - -## Requirements - -The [patched firmware](/firmware) and the [App Loader](/firmware). Open it from the **Apps** row at the end of the -watch's app list (list style, not the waterfall). diff --git a/apps/connect-four/store.toml b/apps/connect-four/store.toml deleted file mode 100644 index fef701f..0000000 --- a/apps/connect-four/store.toml +++ /dev/null @@ -1,6 +0,0 @@ -# The app's listing in the FMC store (README.md, "store.toml"). The page's body is store.md. -name = "Connect Four" -summary = "Drop discs, line up four. Play a negamax bot on three levels" -version = "0.1.0" -author = "Ziyad Eslam" -screenshots = ["shots/menu.png", "shots/playing.png", "shots/won.png", "shots/result.png"] diff --git a/apps/focus-timer/Cargo.toml b/apps/focus-timer/Cargo.toml deleted file mode 100644 index f3a5ab5..0000000 --- a/apps/focus-timer/Cargo.toml +++ /dev/null @@ -1,15 +0,0 @@ -[package] -name = "focus-timer" -edition.workspace = true -license.workspace = true -version.workspace = true - -[dependencies] -cmf-wp2-app.workspace = true - -[dev-dependencies] -wp2-core.workspace = true - -[[bin]] -name = "focus-timer" -bench = false diff --git a/apps/focus-timer/icon.svg b/apps/focus-timer/icon.svg deleted file mode 100644 index 2f397a0..0000000 --- a/apps/focus-timer/icon.svg +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/apps/focus-timer/src/main.rs b/apps/focus-timer/src/main.rs deleted file mode 100644 index ff0373b..0000000 --- a/apps/focus-timer/src/main.rs +++ /dev/null @@ -1,165 +0,0 @@ -//! focus-timer: an adjustable focus session on the watch. The crown sets the length (±1 minute), the white pill -//! starts, pauses and restarts it, and three motor pulses tell the user it is over. The chosen length survives a -//! restart in the app's 4 KiB blob. -//! -//! The screen is the stock LVGL kit in black and white (`src/screen.rs`); the state machine and the pulse pattern -//! are pure code with host tests (`src/timer.rs`). -#![cfg_attr(target_os = "none", no_std, no_main)] - -#[cfg_attr(not(target_os = "none"), allow(dead_code))] -mod screen; -#[cfg_attr(not(target_os = "none"), allow(dead_code))] -mod timer; - -#[cfg(not(target_os = "none"))] -fn main() {} - -#[cfg(target_os = "none")] -mod device { - use crate::screen::{self, Screen}; - use crate::timer::{Buzz, Focus, Phase, BUZZ_HZ, DEFAULT_S}; - use cmf_wp2_app::lv::{Batch, Lv, StockFont}; - use cmf_wp2_app::{stock, Api, BUTTON, CROWN, LV, PAUSE, RESUME}; - - cmf_wp2_app::entry!(main); - cmf_wp2_app::app_icon!(); - - /// LVGL 8.3 `LV_EVENT_CLICKED`. - const CLICKED: i16 = 7; - /// Blob layout: `"FT"`, version, `u16` seconds. Anything else is treated as "never saved". - const STORE_MAGIC: [u8; 2] = *b"FT"; - const STORE_VERSION: u8 = 1; - const STORE_LEN: usize = 5; - - fn load(api: &Api) -> Focus { - let mut buf = [0u8; STORE_LEN]; - if api.load(&mut buf) == STORE_LEN as i32 - && buf[0..2] == STORE_MAGIC - && buf[2] == STORE_VERSION - { - Focus::new(u16::from_le_bytes([buf[3], buf[4]]) as u32) - } else { - Focus::new(DEFAULT_S) - } - } - - fn save(api: &Api, f: &Focus) { - let mut buf = [0u8; STORE_LEN]; - buf[0..2].copy_from_slice(&STORE_MAGIC); - buf[2] = STORE_VERSION; - buf[3..5].copy_from_slice(&(f.total_s as u16).to_le_bytes()); - api.save(&buf); - } - - /// One batch: countdown, ring, hint and button word. `drawn` keeps the last countdown that reached the panel. - fn redraw(b: &mut Batch, lv: &Lv, s: &Screen, f: &Focus, now: u32, drawn: &mut u32) { - let mut buf = [0u8; 5]; - let text = f.label(now, &mut buf); - let arc = f.arc(now); - if screen::draw(b, s, text, arc, f.hint(), f.action()).and_then(|_| b.submit(lv)).is_ok() { - *drawn = f.remaining_s(now); - } - } - - fn main(api: &'static Api) -> i32 { - let Some(lv) = api.lv() else { return -95 }; // loader older than ABI 1.2 - let Some(mut b) = Batch::new() else { return -1 }; - - // Each font in a batch of its own: a missing file stops the batch it is in. - for (slot, font) in [ - (screen::FONT_UI, stock::SYSTEM_FONT), - (screen::FONT_TIME, StockFont::F48M), - (screen::FONT_SMALL, StockFont::F18M), - ] { - if screen::open_font(&mut b, slot, font).and_then(|_| b.submit(&lv)).is_err() { - return 1; - } - } - let Ok(s) = screen::build(&mut b) else { return 2 }; - if b.submit(&lv).is_err() { - return 3; - } - - let mut focus = load(api); - let mut buzz = Buzz::default(); - let mut drawn = u32::MAX; // force the first paint - let mut now = api.now(); - redraw(&mut b, &lv, &s, &focus, now, &mut drawn); - - loop { - let _ = buzz.poll(now).map(|duty| api.vibrate(duty, BUZZ_HZ)); - - if focus.phase == Phase::Running { - let left = focus.remaining_s(now); - if left == 0 { - focus.phase = Phase::Done; - buzz.start(now); - redraw(&mut b, &lv, &s, &focus, now, &mut drawn); - } else if left != drawn { - redraw(&mut b, &lv, &s, &focus, now, &mut drawn); - } - } - - let timeout = if focus.phase == Phase::Running { 200 } else { u32::MAX }; - let Some(e) = api.event(timeout) else { - now = api.now(); - continue; - }; - now = api.now(); - - match e.kind { - BUTTON => break, - CROWN => { - if focus.adjust(e.delta as i32) { - save(api, &focus); - redraw(&mut b, &lv, &s, &focus, now, &mut drawn); - } - } - LV => { - if e.y == CLICKED && e.x >= 0 && e.x as u16 == s.button.0 { - match focus.phase { - Phase::Idle => focus.start(now), - // stop the ringing and keep what is left, so the next tap resumes - Phase::Running => { - buzz.stop(); - api.vibrate(0, 0); - focus.pause(now); - save(api, &focus); - } - Phase::Done => focus.reset(), - } - redraw(&mut b, &lv, &s, &focus, now, &mut drawn); - } - } - PAUSE => { - // a stock popup covers the app: motor off, then wait. The deadline keeps counting. - buzz.stop(); - api.vibrate(0, 0); - loop { - match api.event(u32::MAX) { - Some(e) if e.kind == RESUME => break, - Some(e) if e.kind == BUTTON => { - save(api, &focus); - return 0; - } - _ => {} - } - } - now = api.now(); - drawn = u32::MAX; - redraw(&mut b, &lv, &s, &focus, now, &mut drawn); - } - RESUME => { - now = api.now(); - drawn = u32::MAX; - redraw(&mut b, &lv, &s, &focus, now, &mut drawn); - } - _ => {} - } - } - - api.vibrate(0, 0); // the loader cuts it too, but the app's own pattern has to stop - save(api, &focus); - 0 - } -} diff --git a/apps/focus-timer/src/screen.rs b/apps/focus-timer/src/screen.rs deleted file mode 100644 index 2967437..0000000 --- a/apps/focus-timer/src/screen.rs +++ /dev/null @@ -1,186 +0,0 @@ -//! The focus-timer screen: the stock look, in black and white. A black page, a white progress ring, the countdown in -//! the largest stock font inside it, a grey hint line and one white pill button. -//! -//! Layout on the 466x466 round screen (visible half-width at `y` is `isqrt(233² - (y-233)²)`): -//! -//! ```text -//! y 52.. 88 title "Focus" 32 px, white -//! y 90..112 hint line 18 px, grey -//! y 119..359 arc, 240 px the countdown sits in its centre (48 px, white) -//! y 372..436 button, 190x64 white pill, black label (at y 436 the screen is 228 px wide) -//! ``` - -use cmf_wp2_app::lv::*; -use cmf_wp2_app::stock; - -/// Slot of the stock system font, opened by [`stock::font`]. -pub const FONT_UI: u8 = stock::FONT; -/// The countdown: the largest stock font. -pub const FONT_TIME: u8 = 1; -/// The hint line under the title. -pub const FONT_SMALL: u8 = 2; - -pub const ARC_D: i32 = 240; -/// At y 52..88 the screen is only ~280 px wide, so the title and the hint line are narrower than a full row. -pub const TITLE_W: i32 = 240; -pub const HINT_W: i32 = 320; -pub const BUTTON_W: i32 = 190; -pub const BUTTON_H: i32 = 64; -pub const BUTTON_Y: i16 = -30; - -/// Dark grey track of the ring, and the lighter grey a press turns the pill. -const TRACK: i32 = 0x2124; -const PRESSED_FILL: i32 = 0xC618; - -pub struct Screen { - pub arc: Obj, - pub time: Obj, - pub hint: Obj, - pub button: Obj, - pub button_label: Obj, -} - -/// Opens one font. Each font needs a batch of its own: a missing font file stops the batch it is in. -pub fn open_font(b: &mut Batch, slot: u8, font: StockFont) -> Result<(), LvError> { - b.font(slot, font) -} - -/// The whole screen, in the batch the caller submits after it. -pub fn build(b: &mut Batch) -> Result { - stock::theme(b)?; - - let page = b.create(Class::Obj, ROOT)?; - b.size(page, stock::SCREEN, stock::SCREEN)?; - for p in [Prop::PadTop, Prop::PadBottom, Prop::PadLeft, Prop::PadRight, Prop::BorderWidth, Prop::BgOpa] { - b.style(page, p, 0, 0)?; - } - b.flags(page, &[], &[Flag::Scrollable])?; // the crown belongs to the app, not to a scroller - - let title = b.create(Class::Label, page)?; - b.size(title, TITLE_W, 36)?; - b.align(title, Align::TopMid, 0, 52)?; - b.style(title, Prop::TextAlign, 0, 2)?; - b.text(title, "Focus")?; - - let hint = b.create(Class::Label, page)?; - b.size(hint, HINT_W, 22)?; - b.align(hint, Align::TopMid, 0, 90)?; - b.style(hint, Prop::TextAlign, 0, 2)?; - b.style(hint, Prop::TextColor, 0, stock::GREY)?; - b.style(hint, Prop::TextFont, 0, FONT_SMALL as i32)?; - b.text(hint, "crown: minutes")?; - - let arc = b.create(Class::Arc, page)?; - b.size(arc, ARC_D, ARC_D)?; - b.align(arc, Align::Center, 0, 6)?; - b.flags(arc, &[], &[Flag::Clickable])?; // display only - b.value(arc, 100, false)?; - for (part, colour) in [(0, TRACK), (stock::INDICATOR, stock::WHITE)] { - b.style(arc, Prop::ArcColor, part, colour)?; - b.style(arc, Prop::ArcOpa, part, 255)?; - b.style(arc, Prop::ArcWidth, part, 12)?; - b.style(arc, Prop::ArcRounded, part, 1)?; - } - - let time = b.create(Class::Label, arc)?; - b.align(time, Align::Center, 0, 0)?; - b.style(time, Prop::TextFont, 0, FONT_TIME as i32)?; - b.text(time, "25:00")?; - - let button = b.create(Class::Obj, page)?; - b.size(button, BUTTON_W, BUTTON_H)?; - b.align(button, Align::BottomMid, 0, BUTTON_Y)?; - b.style(button, Prop::Radius, 0, BUTTON_H / 2)?; - b.style(button, Prop::BgColor, 0, stock::WHITE)?; - b.style(button, Prop::BgOpa, 0, 255)?; - b.style(button, Prop::BgColor, stock::PRESSED, PRESSED_FILL)?; - b.style(button, Prop::BorderWidth, 0, 0)?; - b.flags(button, &[Flag::Clickable], &[Flag::Scrollable])?; - b.events(button, &[Ev::Clicked])?; - let button_label = b.create(Class::Label, button)?; - b.align(button_label, Align::Center, 0, 0)?; - b.style(button_label, Prop::TextColor, 0, stock::BLACK)?; - b.text(button_label, "Start")?; - - Ok(Screen { arc, time, hint, button, button_label }) -} - -/// Everything that changes with the phase: countdown, ring, hint, button word. -pub fn draw(b: &mut Batch, s: &Screen, time: &str, arc: i32, hint: &str, action: &str) -> Result<(), LvError> { - b.text(s.time, time)?; - b.value(s.arc, arc.clamp(0, 100), false)?; - b.text(s.hint, hint)?; - b.text(s.button_label, action) -} - -#[cfg(test)] -mod tests { - extern crate std; - use super::*; - use std::boxed::Box; - use wp2_core::lvcmd::{self, Table}; - - fn batch() -> Batch { - Batch::with_buf(Box::leak(Box::new([0; BUF]))) - } - - fn apply(t: &mut Table, records: &[u8]) { - for r in lvcmd::records(records) { - lvcmd::apply(t, &r.unwrap()); - } - } - - /// The launch as the app does it: three font batches, then the screen, validated in order on one Batch. - fn launch() -> (Batch, Screen, Table) { - let mut t = Table::new(); - let mut b = batch(); - let mut mask = 0u8; - for (slot, font) in - [(FONT_UI, stock::SYSTEM_FONT), (FONT_TIME, StockFont::F48M), (FONT_SMALL, StockFont::F18M)] - { - open_font(&mut b, slot, font).unwrap(); - assert_eq!(lvcmd::validate(b.bytes(), &t, mask), Ok(()), "font {slot}"); - apply(&mut t, b.bytes()); - mask |= 1 << slot; - } - let s = build(&mut b).unwrap(); - std::println!("screen batch: {} B", b.bytes().len()); - assert_eq!(lvcmd::validate(b.bytes(), &t, mask), Ok(())); - apply(&mut t, b.bytes()); - (b, s, t) - } - - #[test] - fn the_screen_validates_in_four_batches() { - let (mut b, s, t) = launch(); - let n = b.bytes().len(); - for (time, arc, hint, action) in - [("25:00", 100, "crown: minutes", "Start"), ("00:01", 1, "session done", "Restart")] - { - draw(&mut b, &s, time, arc, hint, action).unwrap(); - } - assert_eq!(lvcmd::validate(&b.bytes()[n..], &t, 0b111), Ok(())); - } - - #[test] - fn every_layout_row_fits_the_round_screen() { - // half-width of the visible disc at a row, minus the 6 px margin - fn half(y0: i32, y1: i32) -> i32 { - let d = (y0 - 233).abs().max((y1 - 233).abs()); - let w = (233 * 233 - d * d).max(0) as f64; - w.sqrt() as i32 - 6 - } - assert!(TITLE_W / 2 <= half(52, 88), "title"); - assert!(HINT_W / 2 <= half(90, 112), "hint"); - // the arc is a circle: its widest row is its centre - assert!(ARC_D / 2 <= half(119, 359) + 6, "arc"); - assert!(BUTTON_W / 2 <= half(372, 436), "button"); - } - - #[test] - fn the_button_sits_below_the_arc() { - let arc_bottom = 233 + 6 + ARC_D / 2; - let button_top = 466 - 30 - BUTTON_H; // BottomMid, BUTTON_Y - assert!(button_top > arc_bottom, "{button_top} > {arc_bottom}"); - } -} diff --git a/apps/focus-timer/src/timer.rs b/apps/focus-timer/src/timer.rs deleted file mode 100644 index 309d625..0000000 --- a/apps/focus-timer/src/timer.rs +++ /dev/null @@ -1,280 +0,0 @@ -//! Focus timer state: a whole-minute duration, the countdown and the end-of-session buzz. -//! Pure logic, no SDK calls, so it is host-tested (`cargo test -p focus-timer`). - -/// Where the session is: choosing a length, counting down, or finished. -#[derive(Clone, Copy, PartialEq, Eq, Debug)] -pub enum Phase { - Idle, - Running, - Done, -} - -pub const DEFAULT_S: u32 = 25 * 60; -pub const MIN_S: u32 = 60; -/// 99 minutes keeps the countdown at five glyphs (`99:00`). -pub const MAX_S: u32 = 99 * 60; -/// One crown detent, and one saved step, is one minute. -pub const STEP_S: u32 = 60; - -/// End-of-session pattern: this many pulses, each on for [`PULSE_MS`]. -pub const PULSES: u8 = 3; -pub const PULSE_MS: u32 = 250; -pub const BUZZ_DUTY: u16 = 800; -pub const BUZZ_HZ: u16 = 31; - -#[derive(Clone, Copy, Debug)] -pub struct Focus { - pub total_s: u32, - pub phase: Phase, - ends_at: u32, -} - -fn clamp_s(s: i64) -> u32 { - s.clamp(MIN_S as i64, MAX_S as i64) as u32 -} - -impl Focus { - pub fn new(total_s: u32) -> Self { - Self { total_s: clamp_s(total_s as i64), phase: Phase::Idle, ends_at: 0 } - } - - /// Crown detent: `minutes` may be negative. Only while idle or done. Returns whether the length changed. - pub fn adjust(&mut self, minutes: i32) -> bool { - if self.phase == Phase::Running { - return false; - } - let next = clamp_s(self.total_s as i64 + minutes as i64 * STEP_S as i64); - if next == self.total_s && self.phase == Phase::Idle { - return false; - } - self.total_s = next; - self.phase = Phase::Idle; - true - } - - pub fn start(&mut self, now: u32) { - self.ends_at = now.wrapping_add(self.total_s.saturating_mul(1000)); - self.phase = Phase::Running; - } - - /// Stops the clock and keeps what is left, so tapping again resumes from there. - pub fn pause(&mut self, now: u32) { - if self.phase == Phase::Running { - self.total_s = clamp_s(self.remaining_s(now) as i64); - self.phase = Phase::Idle; - } - } - - /// Back to the chosen length without starting. - pub fn reset(&mut self) { - self.phase = Phase::Idle; - } - - /// Whole seconds left, rounded up so the last second is shown as `00:01`, not `00:00`. - pub fn remaining_s(&self, now: u32) -> u32 { - if self.phase != Phase::Running { - return self.total_s; - } - let ms = self.ends_at.wrapping_sub(now) as i32; // signed compare survives the 49-day wrap - if ms <= 0 { - 0 - } else { - (ms as u32).div_ceil(1000) - } - } - - /// Arc value 0..=100: full at the start of a session, empty when it is done. - pub fn arc(&self, now: u32) -> i32 { - match self.phase { - Phase::Idle => 100, - Phase::Done => 0, - Phase::Running => { - let left = self.remaining_s(now).min(self.total_s); - // rounded up: a ring that still shows a sliver until the very end - ((left * 100).div_ceil(self.total_s.max(1))) as i32 - } - } - } - - /// `MM:SS` into `buf`. `total_s` is clamped to 99 minutes, so five bytes always fit. - pub fn label<'a>(&self, now: u32, buf: &'a mut [u8; 5]) -> &'a str { - let s = match self.phase { - Phase::Done => 0, - _ => self.remaining_s(now).min(MAX_S), - }; - let (m, sec) = (s / 60, s % 60); - buf[0] = b'0' + (m / 10) as u8; - buf[1] = b'0' + (m % 10) as u8; - buf[2] = b':'; - buf[3] = b'0' + (sec / 10) as u8; - buf[4] = b'0' + (sec % 10) as u8; - core::str::from_utf8(buf).unwrap_or("--:--") - } - - /// The word the button carries in this phase. - pub fn action(&self) -> &'static str { - match self.phase { - Phase::Idle => "Start", - Phase::Running => "Pause", - Phase::Done => "Restart", - } - } - - /// The grey line under the title. - pub fn hint(&self) -> &'static str { - match self.phase { - Phase::Idle => "crown: minutes", - Phase::Running => "tap pause to stop", - Phase::Done => "session done", - } - } -} - -/// The pulse pattern after a finished session: on, gap, on, gap, on, then off. -/// Times are `api.now()` milliseconds, compared with the same signed-wrap rule as [`Focus`]. -#[derive(Clone, Copy, Debug, Default)] -pub struct Buzz { - next_at: u32, - left: u8, - on: bool, - active: bool, -} - -impl Buzz { - pub fn start(&mut self, now: u32) { - self.left = PULSES; - self.on = false; - self.next_at = now; - self.active = PULSES > 0; - } - - pub fn stop(&mut self) { - self.active = false; - } - - /// The duty to apply now, or `None` when nothing is due. `Some(0)` switches the motor off. - pub fn poll(&mut self, now: u32) -> Option { - if !self.active || (now.wrapping_sub(self.next_at) as i32) < 0 { - return None; - } - if self.on { - self.on = false; - self.next_at = now.wrapping_add(PULSE_MS); - return Some(0); - } - if self.left == 0 { - self.active = false; - return Some(0); - } - self.left -= 1; - self.on = true; - self.next_at = now.wrapping_add(PULSE_MS); - Some(BUZZ_DUTY) - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn length_steps_by_a_minute_and_clamps() { - let mut f = Focus::new(DEFAULT_S); - assert_eq!(f.total_s, 1500); - assert!(f.adjust(1)); - assert_eq!(f.total_s, 1560); - assert!(f.adjust(-1)); - assert_eq!(f.total_s, DEFAULT_S); - for _ in 0..200 { - f.adjust(-1); - } - assert_eq!(f.total_s, MIN_S); - for _ in 0..200 { - f.adjust(1); - } - assert_eq!(f.total_s, MAX_S); - assert!(!f.adjust(1)); // already at the top - } - - #[test] - fn crown_is_ignored_while_running() { - let mut f = Focus::new(600); - f.start(1000); - assert!(!f.adjust(5)); - assert_eq!(f.total_s, 600); - } - - #[test] - fn counts_down_and_finishes_on_zero() { - let mut f = Focus::new(60); - f.start(10_000); - assert_eq!(f.remaining_s(10_000), 60); - assert_eq!(f.remaining_s(10_500), 60); // rounded up - assert_eq!(f.remaining_s(69_000), 1); - assert_eq!(f.remaining_s(70_000), 0); - assert_eq!(f.arc(10_000), 100); - assert_eq!(f.arc(40_000), 50); - assert!(f.arc(69_000) > 0); // a sliver stays until the last millisecond - } - - #[test] - fn pause_keeps_the_remainder_and_resumes() { - let mut f = Focus::new(600); - f.start(0); - f.pause(90_000); // 8.5 minutes left, rounded up = 510 s - assert_eq!(f.phase, Phase::Idle); - assert_eq!(f.total_s, 510); - f.start(100_000); - assert_eq!(f.remaining_s(100_000), 510); - assert_eq!(f.remaining_s(100_000 + 510_000), 0); - } - - #[test] - fn the_wrap_of_now_does_not_stop_the_clock() { - let mut f = Focus::new(60); - f.start(u32::MAX - 30_000); // ends after the wrap - assert_eq!(f.remaining_s(0), 30); - assert_eq!(f.remaining_s(30_000), 0); - } - - #[test] - fn label_is_always_five_glyphs() { - let mut buf = [0u8; 5]; - let mut f = Focus::new(DEFAULT_S); - assert_eq!(f.label(0, &mut buf), "25:00"); - f = Focus::new(99 * 60); - assert_eq!(f.label(0, &mut buf), "99:00"); - f = Focus::new(60); - f.start(0); - assert_eq!(f.label(59_500, &mut buf), "00:01"); - assert_eq!(f.label(60_000, &mut buf), "00:00"); - f.phase = Phase::Done; - assert_eq!(f.label(0, &mut buf), "00:00"); - assert_eq!(f.action(), "Restart"); - } - - #[test] - fn buzz_is_three_pulses_then_off() { - let mut b = Buzz::default(); - b.start(0); - assert_eq!(b.poll(0), Some(BUZZ_DUTY)); // on - assert_eq!(b.poll(100), None); // still inside the pulse - assert_eq!(b.poll(250), Some(0)); // off - assert_eq!(b.poll(500), Some(BUZZ_DUTY)); // second pulse - assert_eq!(b.poll(750), Some(0)); - assert_eq!(b.poll(1000), Some(BUZZ_DUTY)); // third - assert_eq!(b.poll(1250), Some(0)); - assert_eq!(b.poll(1500), Some(0)); // final off, not active any more - assert!(!b.active); - assert_eq!(b.poll(2000), None); - } - - #[test] - fn stop_cancels_the_rest() { - let mut b = Buzz::default(); - b.start(0); - assert_eq!(b.poll(0), Some(BUZZ_DUTY)); - b.stop(); - assert_eq!(b.poll(250), None); - } -} diff --git a/apps/focus-timer/store.md b/apps/focus-timer/store.md deleted file mode 100644 index 00b66a0..0000000 --- a/apps/focus-timer/store.md +++ /dev/null @@ -1,9 +0,0 @@ -A focus session timer in black and white. - -- **Crown** sets the length: one click is one minute, 1 to 99. -- **Tap Start** to begin. The white ring empties as the session runs and the countdown sits in the middle. -- **Tap Pause** to stop; what is left is kept, so the next tap resumes from there. -- **Three motor pulses** (250 ms each) mark the end. The button then reads **Restart**. - -The chosen length is saved, so it is still there the next time the app opens. Nothing else is stored and nothing -leaves the watch; it needs no phone. diff --git a/apps/focus-timer/store.toml b/apps/focus-timer/store.toml deleted file mode 100644 index d4ef373..0000000 --- a/apps/focus-timer/store.toml +++ /dev/null @@ -1,5 +0,0 @@ -# The app's listing in the FMC store (README.md, "store.toml"). The page's body is store.md. -name = "Focus" -summary = "An adjustable focus timer: crown for minutes, one tap to start, three buzzes when it ends" -version = "0.1.0" -author = "CMF Tech Community" diff --git a/apps/gemini-watch/Cargo.toml b/apps/gemini-watch/Cargo.toml deleted file mode 100644 index f2c4655..0000000 --- a/apps/gemini-watch/Cargo.toml +++ /dev/null @@ -1,12 +0,0 @@ -[package] -name = "gemini-watch" -edition.workspace = true -license.workspace = true -version.workspace = true - -[dependencies] -cmf-wp2-app.workspace = true - -[[bin]] -name = "gemini-watch" -bench = false diff --git a/apps/gemini-watch/icon.svg b/apps/gemini-watch/icon.svg deleted file mode 100644 index 4d1fcec..0000000 --- a/apps/gemini-watch/icon.svg +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/apps/gemini-watch/src/logic.rs b/apps/gemini-watch/src/logic.rs deleted file mode 100644 index 5795bfb..0000000 --- a/apps/gemini-watch/src/logic.rs +++ /dev/null @@ -1,130 +0,0 @@ -pub const PROMPTS: [&str; 6] = [ - "Daily summary", - "Motivation quote", - "Quantum computing", - "Science fact", - "Desk stretches", - "Recipe ideas", -]; - -#[derive(Clone, Copy, PartialEq, Debug)] -pub enum AppState { - SelectPrompt, - Waiting, - Viewing, -} - -pub struct GeminiLogic { - pub state: AppState, - pub selected: usize, - pub response_len: usize, - pub response_buf: [u8; 512], -} - -impl GeminiLogic { - pub fn new() -> Self { - Self { - state: AppState::SelectPrompt, - selected: 0, - response_len: 0, - response_buf: [0; 512], - } - } - - pub fn on_crown(&mut self, delta: i16) -> bool { - match self.state { - AppState::SelectPrompt => { - if delta > 0 && self.selected + 1 < PROMPTS.len() { - self.selected += 1; - true - } else if delta < 0 && self.selected > 0 { - self.selected -= 1; - true - } else { - false - } - } - _ => false, - } - } - - pub fn on_touch(&mut self, _x: i16, y: i16, _width: u16, _height: u16) -> Option<&'static str> { - match self.state { - AppState::SelectPrompt => { - let start_y = 90; - let row_h = 45; - if y >= start_y && y < start_y + (PROMPTS.len() as i16 * row_h) { - let idx = ((y - start_y) / row_h) as usize; - if idx < PROMPTS.len() { - self.selected = idx; - self.state = AppState::Waiting; - self.response_len = 0; - return Some(PROMPTS[idx]); - } - } - None - } - AppState::Viewing => { - if y >= 350 { - self.state = AppState::SelectPrompt; - } - None - } - AppState::Waiting => None, - } - } - - pub fn on_recv(&mut self, chunk: &[u8]) -> bool { - if chunk == b"[DONE]" { - self.state = AppState::Viewing; - return true; - } - - let space = self.response_buf.len() - self.response_len; - let to_copy = chunk.len().min(space); - if to_copy > 0 { - self.response_buf[self.response_len..self.response_len + to_copy] - .copy_from_slice(&chunk[..to_copy]); - self.response_len += to_copy; - true - } else { - false - } - } - - pub fn view_text(&self) -> &str { - core::str::from_utf8(&self.response_buf[..self.response_len]).unwrap_or("Received response") - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn test_logic_navigation() { - let mut logic = GeminiLogic::new(); - assert_eq!(logic.state, AppState::SelectPrompt); - assert_eq!(logic.selected, 0); - - assert!(logic.on_crown(1)); - assert_eq!(logic.selected, 1); - - assert!(logic.on_crown(-1)); - assert_eq!(logic.selected, 0); - } - - #[test] - fn test_prompt_selection_and_recv() { - let mut logic = GeminiLogic::new(); - let prompt = logic.on_touch(100, 100, 360, 360); - assert_eq!(prompt, Some("Daily summary")); - assert_eq!(logic.state, AppState::Waiting); - - logic.on_recv(b"Hello from Gemini"); - assert_eq!(logic.view_text(), "Hello from Gemini"); - - logic.on_recv(b"[DONE]"); - assert_eq!(logic.state, AppState::Viewing); - } -} diff --git a/apps/gemini-watch/src/main.rs b/apps/gemini-watch/src/main.rs deleted file mode 100644 index cc2b459..0000000 --- a/apps/gemini-watch/src/main.rs +++ /dev/null @@ -1,87 +0,0 @@ -#![cfg_attr(any(target_os = "none", wp2_sim), no_main, cfg_attr(target_os = "none", no_std))] - -#[cfg_attr(not(any(target_os = "none", wp2_sim)), allow(dead_code))] -mod logic; - -#[cfg(not(any(target_os = "none", wp2_sim)))] -fn main() {} - -#[cfg(any(target_os = "none", wp2_sim))] -mod device { - use crate::logic::{AppState, GeminiLogic, PROMPTS}; - use cmf_wp2_app::{Api, BUTTON, CROWN, MESSAGE, MSG_MAX, PAUSE, RESUME, TOUCH_DOWN}; - - cmf_wp2_app::entry!(main); - cmf_wp2_app::app_icon!(); - - const BG: u16 = 0x0000; - const WHITE: u16 = 0xFFFF; - const GREY: u16 = 0x39E7; - const DARK: u16 = 0x2124; - const ACCENT: u16 = 0xFD20; - const BLUE: u16 = 0x4E82; - - fn draw(api: &Api, logic: &GeminiLogic) { - api.rect(0, 0, api.width, api.height, BG); - match logic.state { - AppState::SelectPrompt => { - api.text(api.width as i16 / 2 - 40, 40, "Gemini AI", ACCENT); - for (i, prompt) in PROMPTS.iter().enumerate() { - let y = 90 + (i as i16 * 45); - let is_sel = i == logic.selected; - let color = if is_sel { ACCENT } else { WHITE }; - let bg_color = if is_sel { DARK } else { BG }; - api.rect(20, y - 4, api.width - 40, 38, bg_color); - api.text(30, y + 4, prompt, color); - } - } - AppState::Waiting => { - api.text(api.width as i16 / 2 - 60, 160, "Querying Gemini...", BLUE); - api.text(api.width as i16 / 2 - 80, 210, "Waiting for BLE bridge", GREY); - } - AppState::Viewing => { - api.rect(0, 0, api.width, 50, DARK); - api.text(api.width as i16 / 2 - 30, 16, "Answer", ACCENT); - let text = logic.view_text(); - api.text(30, 80, text, WHITE); - api.rect(30, 360, api.width - 60, 40, DARK); - api.text(api.width as i16 / 2 - 20, 372, "BACK", ACCENT); - } - } - api.show(); - } - - fn main(api: &'static Api) -> i32 { - let mut logic = GeminiLogic::new(); - draw(api, &logic); - - loop { - let Some(event) = api.event(u32::MAX) else { continue }; - match event.kind { - BUTTON => return 0, - CROWN => { - if logic.on_crown(event.delta) { - draw(api, &logic); - } - } - TOUCH_DOWN => { - if let Some(to_send) = logic.on_touch(event.x, event.y, api.width, api.height) { - let _ = api.send(to_send.as_bytes()); - } - draw(api, &logic); - } - MESSAGE => { - let mut rx = [0u8; MSG_MAX]; - while let Some(msg) = api.recv(&mut rx) { - if logic.on_recv(msg) { - draw(api, &logic); - } - } - } - RESUME => draw(api, &logic), - PAUSE => {} - _ => {} - } - } - } -} diff --git a/apps/gemini-watch/store.md b/apps/gemini-watch/store.md deleted file mode 100644 index 0e6743b..0000000 --- a/apps/gemini-watch/store.md +++ /dev/null @@ -1,12 +0,0 @@ -# Gemini AI - -Interact with Google Gemini AI directly from your wrist. Select quick prompts using the touch screen or watch crown and view AI-generated answers on your watch display. - -## How It Works -The CMF Watch Pro 2 sends the selected prompt over the watch's BLE app message channel. A companion bridge running on your phone, PC, Mac, or local gateway receives the message, calls Google Gemini's API, and streams the formatted response back to the watch display in chunks. - -## Requirements -* **Patched firmware & App Loader** installed on your CMF Watch Pro 2. -* **Host Companion Bridge**: Because the watch has no standalone Wi-Fi/LTE network hardware and cannot make direct HTTPS POST requests with an API key, an external companion bridge (such as the provided Python BLE script or companion daemon) must be running on your connected computer, phone, or local gateway. -* **Google Gemini API Key**: Configured in the companion bridge daemon. -* **Security Notice**: Communication across the BLE channel travels unencrypted within local radio range; avoid transmitting sensitive personal credentials. diff --git a/apps/gemini-watch/store.toml b/apps/gemini-watch/store.toml deleted file mode 100644 index 9a6949d..0000000 --- a/apps/gemini-watch/store.toml +++ /dev/null @@ -1,4 +0,0 @@ -name = "Gemini AI" -summary = "Ask questions and receive Google Gemini responses via a host BLE bridge" -version = "0.1.0" -author = "ultima-spec" diff --git a/apps/ha-remote/ANDROID_COMPANION.md b/apps/ha-remote/ANDROID_COMPANION.md deleted file mode 100644 index 05f264d..0000000 --- a/apps/ha-remote/ANDROID_COMPANION.md +++ /dev/null @@ -1,104 +0,0 @@ -# Home Assistant remote Android companion - -This is the implementation contract for the Android companion paired with `apps/ha-remote`. The phone is the only -Home Assistant client: the watch sends an intent, and the phone reports the entity state after Home Assistant -confirms it. The watch never stores a Home Assistant URL, token, entity ID, room name, or credential. -The configured short button labels are sent over BLE to be shown on the watch; keep them generic and non-sensitive. - -## Connection model - -1. The user pairs the watch once in Nothing X. The companion does not run a second pairing flow and must not perform - the App Loader's `0x8047` / `0x8049` bind handshake. -2. Resolve the already bonded WP2 and use `connectGatt` to its existing GATT identity while Nothing X is active. - Android coexistence with Nothing X is a required hardware validation. If Android cannot maintain the second GATT - client on a phone model, report that combination as unsupported instead of rebinding or disconnecting Nothing X. -3. Subscribe to notify UUIDs `0000FFF1-0000-1000-8000-00805F9B34FB`, - `77D4FF02-2FE2-2334-0D35-9CCD078F529C`, and - `02F00000-0000-0000-0000-00000000FFE2`; write to `FFF2` and shell - `77D4FF01-2FE2-2334-0D35-9CCD078F529C`. The data-notify subscription is the stock firmware's - phone-ready signal, so wait briefly after the third subscription before reading K. Accumulate shell - notifications until the complete `GETSECRET:<32 hex>,OK` response arrives and retry that read after a reconnect. -4. Treat K as a password. This companion keeps K in memory only and clears it when the GATT session closes; never - log, export, sync, or put it in a project file. Nothing personal goes over this channel. -5. Send one encrypted channel `PING` (`0x90A7`) under K to register. Encode/decode channel frames as specified in - `.sdk/wp2-apps/docs/abi-1.4.md`. Do not send Nothing X authentication or pairing frames. -6. Decode `0xB0A6` EVENT notifications, verify sequence and running app slot, and pass only `H1` app messages to - the protocol handler. Respond to watch HELLO with a full button configuration and current state snapshots. -7. On process restart, reconnect and try K directly. On no response, show a compatibility diagnostic for stock or - old patched firmware; never silently start a fresh bind. - -## Watch protocol v3 (`H1`) - -All integers are unsigned bytes. App messages have a 128-byte maximum. UTF-8 names are capped at 15 bytes and -section titles at 10. There are **ten slots** (0-9), each with a kind: `0` toggle, `1` dimmer (brightness slider). -Up to **five favorites** are slot indexes sent as five bytes with `0xFF` for an empty slot. Entity IDs remain -phone-local. - -| Direction | Frame | Meaning | -|---|---|---| -| Watch → phone | `H1?` | App started or resumed; send config and all states | -| Phone → watch | `H1V n (enabled kind len name)*` | Slots 5-9; `n <= 5` | -| Phone → watch | `H1J n (len section)*` | Sections for slots 0-4 | -| Phone → watch | `H1K n (len section)*` | Sections for slots 5-9 | -| Phone → watch | `H1U n (enabled kind len name)* fav[5]` | Slots 0-4 + favorites; **the commit frame the watch persists** | -| Phone → watch | `H1I icon[10]` | Per-control icon id: `0` auto, `1` bulb, `2` ceiling light, `3` fan, `4` device | -| Watch → phone | `H1T seq slot on` | Toggle request (`slot 0..9`) | -| Watch → phone | `H1B seq slot value` | Brightness request, `value 0..=100`, dimmer slots only | -| Phone → watch | `H1A seq` | Command accepted; pending remains until `H1S` | -| Phone → watch | `H1P` | Companion heartbeat (10 s) | -| Phone → watch | `H1S slot on value result available` | Authoritative state; `value` is brightness percent, result `0` confirmed, nonzero generic failure, `available 0` means HA has no data for the entity (device lost power): the watch greys the row and shows **Inactive** | -| Phone → watch | `H1E seq error_code` | Generic failure; never include HA response text or entity data | -| Watch → phone | `H1W result` | Runtime result from `Api::widget` | - -The phone sends `V, J, K, U, I` in that order on every HELLO; `U` commits the control configuration and `I` -updates its icon choices. A half-delivered -configuration never replaces the stored one. The legacy `H1C` (five slots, optional single favorite) and `H1G` -frames from older companions are still accepted. For `H1B`, send `H1A` promptly, set the brightness through Home -Assistant, wait for the reported value to settle, then send `H1S`. The phone serializes commands: one outstanding -watch command at a time, duplicate sequences are idempotent, and a failed or timed-out Home Assistant call sends -`H1S` with a nonzero result and the cached state so the watch never keeps an optimistic value. - -On the watch a dimmer row is a plain element: a short press sends `H1B` with 0 or 100 (on/off), and a long press -opens the device's own slider page — drag it or turn the crown; both send normal `H1B` frames. No slider lives in -the list rows. - -Watch config persistence uses a versioned `D4` blob: count, the five favorites, then ten fixed records of -`enabled, kind, icon, on, value, len, name[15], sec_len, section[10]`. The old `D3` and `D2` blobs are migrated on load -(icons default to auto; `D2` controls migrate as toggles). Android remains authoritative and resends config, icons and fresh states after every -HELLO. - -State frames may be 6 bytes (legacy), 7 bytes (no availability byte) or 8 bytes (current); a missing availability -byte means available. An unavailable push is a device state, not an app error: the watch clears any pending command, -keeps the last on/value, and shows the row as Inactive until HA reports the entity again. - -## Android app behavior - -- Home Assistant setup: user enters instance URL and long-lived access token in app UI; token stays in Keystore- - protected app storage and is used only by the phone's HTTPS REST client. -- **All entities** in Home Assistant are selectable (the picker loads `/api/states`); for each of the ten slots the - user chooses the kind: toggle switch or brightness slider (sliders require `light.*`). -- Watch labels are short names (15 UTF-8 bytes), section titles are 10 bytes, each control can choose a Material - icon, and up to five slots can be marked favorite: favorites are what the watch page and widget show. -- Startup: load stored slot settings, connect HA, resolve current states, connect to the bonded watch, open K - channel, then publish `V, J, K, U` and state snapshots. Send a full config and states on `H1?` and after every - reconnect. Keep the channel registered with `P` at least every 10 seconds. -- Toggle handling: validate slot and requested state; serialize watch commands; call `homeassistant.turn_on/off`, - await the state, publish `H1S` with the read-back value. Brightness uses `light.turn_on` with `brightness_pct` - (0 turns off) and confirms against the reported brightness. Duplicate seq is idempotent. -- HA state changes from another controller are detected by five-second polling and sent to the watch as `H1S`, so - the rows and widget stay current. -- The Android connected-device foreground service owns the GATT session independently of the setup screen; it keeps - an ongoing notification and reconnects with exponential backoff up to 60 seconds after BLE errors. Home Assistant - outages keep the watch channel alive and retain the last confirmed states until polling recovers. -- UI exposes BLE/channel/HA connection status and a **Test connection** action. Never expose K or raw protocol - payloads in logs or diagnostics. - -## Compatibility and release gates - -- Firmware: K channel requires patched stub and loader from 2026-11-13 or later. The app widget requires stub v4+ - and a loader release from 2026-11-15 or later. -- Android release gate: exercise Nothing X + companion simultaneously on each supported Android vendor/version; - verify no new pairing popup, both BLE clients retain notifications, K channel works after screen off, service - restart and watch reboot, and Home Assistant state changes and brightness propagate both ways. -- Watch release gate: host protocol tests, target build, FMC store check, then emulator/hardware validation. The - emulator does not model LVGL widgets, cards, pages, or BLE coexistence. diff --git a/apps/ha-remote/Cargo.toml b/apps/ha-remote/Cargo.toml deleted file mode 100644 index 5952558..0000000 --- a/apps/ha-remote/Cargo.toml +++ /dev/null @@ -1,15 +0,0 @@ -[package] -name = "ha-remote" -edition.workspace = true -license.workspace = true -version.workspace = true - -[dependencies] -cmf-wp2-app.workspace = true - -[dev-dependencies] -wp2-core.workspace = true - -[[bin]] -name = "ha-remote" -bench = false diff --git a/apps/ha-remote/README.md b/apps/ha-remote/README.md deleted file mode 100644 index 1d35a6c..0000000 --- a/apps/ha-remote/README.md +++ /dev/null @@ -1,25 +0,0 @@ -# Home Assistant (ha-remote) - -Up to ten Home Assistant controls on the watch: toggle switches for on/off entities and brightness -sliders for lights, with names and sections set from the phone. The Apps row lists every control; -the page next to the face and the widget card show up to five favorites. - -The Android companion (setup UI, entity picker, Home Assistant connection, the watch's BLE link, -and the APK) lives in its own repository: . That repository -also carries this watch app under the same `apps/ha-remote/` layout, plus PC install instructions. - -`store.toml` and `store.md` are the FMC store listing; `ANDROID_COMPANION.md` documents the -watch-phone protocol contract. - -## Build and install - -From the repository root (the same commands work in both repositories): - -```bash -make test APP=ha-remote # host protocol and screen-batch tests -make build APP=ha-remote # target/ha-remote.wp2app -make run APP=ha-remote ADDRESS=AA:BB:CC:DD:EE:FF # install on the watch over BLE -``` - -The watch needs the FMC patched firmware and App Loader with channel key K (2026-11-13 or newer); the page and -widget surfaces need a loader from 2026-11-15 or newer. diff --git a/apps/ha-remote/icon.svg b/apps/ha-remote/icon.svg deleted file mode 100644 index 9454f64..0000000 --- a/apps/ha-remote/icon.svg +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/apps/ha-remote/icons/ceiling-light.svg b/apps/ha-remote/icons/ceiling-light.svg deleted file mode 100644 index a7c4c5d..0000000 --- a/apps/ha-remote/icons/ceiling-light.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/apps/ha-remote/icons/device.svg b/apps/ha-remote/icons/device.svg deleted file mode 100644 index 587bada..0000000 --- a/apps/ha-remote/icons/device.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/apps/ha-remote/icons/fan.svg b/apps/ha-remote/icons/fan.svg deleted file mode 100644 index 7346742..0000000 --- a/apps/ha-remote/icons/fan.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/apps/ha-remote/icons/light-bulb.svg b/apps/ha-remote/icons/light-bulb.svg deleted file mode 100644 index 4732e72..0000000 --- a/apps/ha-remote/icons/light-bulb.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/apps/ha-remote/shots/watch.jpg b/apps/ha-remote/shots/watch.jpg deleted file mode 100644 index 3ae5757..0000000 Binary files a/apps/ha-remote/shots/watch.jpg and /dev/null differ diff --git a/apps/ha-remote/src/main.rs b/apps/ha-remote/src/main.rs deleted file mode 100644 index 6393226..0000000 --- a/apps/ha-remote/src/main.rs +++ /dev/null @@ -1,379 +0,0 @@ -#![cfg_attr( - any(target_os = "none", wp2_sim), - no_main, - cfg_attr(target_os = "none", no_std) -)] - -#[cfg_attr(not(any(target_os = "none", wp2_sim)), allow(dead_code))] -mod proto; -mod screen; - -#[cfg(not(any(target_os = "none", wp2_sim)))] -fn main() {} - -#[cfg(any(target_os = "none", wp2_sim))] -mod device { - use crate::proto::{self, Effect, MAX_BUTTONS, Model}; - use crate::screen::{Mode, Screen, View}; - use cmf_wp2_app::lv::{Batch, Lv}; - use cmf_wp2_app::{Api, BUTTON, CROWN, LV, MSG_MAX, PAUSE, RESUME, stock}; - - cmf_wp2_app::entry!(main); - cmf_wp2_app::app_icon!(); - cmf_wp2_app::app_features!(cmf_wp2_app::WIDGET | cmf_wp2_app::PAGE); - - /// LVGL event codes: row tap, row long press, slider drag. - const CLICKED: i16 = 7; - const LONG_PRESSED: i16 = 5; - const RELEASED: i16 = 8; - const VALUE_CHANGED: i16 = 28; - /// A long press opens the slider page; a CLICKED landing right after it belongs to the - /// same press and must not flip the brightness. - const LONG_GRACE_MS: u32 = 900; - /// Percent per crown detent on the slider page. - const CROWN_STEP: i16 = 5; - - static mut MODEL: Model = Model::new(); - static mut STORE: [u8; 384] = [0; 384]; - - /// The widget card: the first favorite's name and state (or the first enabled control). - fn update_widget(api: &Api, m: &Model) -> i32 { - let chosen = m.primary().and_then(|i| m.buttons.get(i)).copied(); - let mut val = [0u8; 40]; - let value = if !m.connected { - "Phone offline" - } else { - match chosen { - Some(b) if b.enabled => { - let label = b.label(); - let n = label.len().min(proto::NAME_MAX); - val[..n].copy_from_slice(&label.as_bytes()[..n]); - let mut k = n; - val[k] = b'\n'; - k += 1; - if !b.available { - val[k..k + 8].copy_from_slice(b"INACTIVE"); - k += 8; - } else { - let state: &[u8] = if b.on { b"ON" } else { b"OFF" }; - val[k..k + 2].copy_from_slice(state); - k += 2; - if b.is_dimmer() { - val[k] = b' '; - k += 1; - let v = b.value.min(100); - if v >= 100 { - val[k..k + 3].copy_from_slice(b"100"); - k += 3; - } else if v >= 10 { - val[k] = b'0' + v / 10; - val[k + 1] = b'0' + v % 10; - k += 2; - } else { - val[k] = b'0' + v; - k += 1; - } - val[k] = b'%'; - k += 1; - } - } - core::str::from_utf8(&val[..k]).unwrap_or("") - } - _ => "Set up in the phone app", - } - }; - api.widget("Home Assistant", value) - } - - fn main(api: &'static Api) -> i32 { - let Some(lv) = api.lv() else { return -95 }; - // The crown press / right swipe is ours: while the slider page is open it goes - // back to the list; only a plain list press exits. - api.own_back(true); - let Some(mut batch) = Batch::new() else { return 6 }; - if stock::font(&mut batch) - .and_then(|_| batch.submit(&lv)) - .is_err() - { - return 1; - } - // SAFETY: a single app thread owns these static buffers. - let m = unsafe { &mut *core::ptr::addr_of_mut!(MODEL) }; - let stored = unsafe { &mut *core::ptr::addr_of_mut!(STORE) }; - let n = api.load(stored); - if n > 0 { - m.load(&stored[..n as usize]); - } - let mode = if api.on_page() { Mode::Page } else { Mode::Menu }; - list_main(api, m, stored, lv, batch, mode) - } - - struct Link { - last_rx: u32, - last_connection: bool, - widget_last: u32, - widget_reported: bool, - widget_dirty: bool, - last_state: [u8; MAX_BUTTONS], - } - - impl Link { - fn new(api: &Api, m: &Model) -> Self { - Self { - last_rx: api.now(), - last_connection: m.connected, - widget_last: 0, - widget_reported: false, - widget_dirty: true, - last_state: [0xFF; MAX_BUTTONS], - } - } - } - - fn sync(api: &Api, m: &mut Model, stored: &mut [u8; 384], link: &mut Link) -> bool { - let mut dirty = false; - if m.connected != link.last_connection { - link.last_connection = m.connected; - dirty = true; - link.widget_dirty = true; - } - for i in 0..MAX_BUTTONS { - let b = match m.buttons.get(i) { Some(b) => b, None => continue }; - let state = ((b.enabled as u8) << 2) | ((b.on as u8) << 1) | (b.value >= 100) as u8; - if link.last_state[i] != state { - link.last_state[i] = state; - link.widget_dirty = true; - dirty = true; - } - } - let mut rx = [0u8; MSG_MAX]; - while let Some(msg) = api.recv(&mut rx) { - link.last_rx = api.now(); - match m.apply(msg) { - Effect::Ignored | Effect::Heartbeat | Effect::Ack(_) => {} - Effect::Linked => { - dirty = true; - link.widget_dirty = true; - } - Effect::Configured => { - let n = m.save(stored); - if n > 0 { let _ = api.save(&stored[..n]); } - dirty = true; - link.widget_dirty = true; - } - Effect::Changed => { - dirty = true; - link.widget_dirty = true; - } - Effect::Error(_) => dirty = true, - } - } - let now = api.now(); - if m.pending.is_some() && now.wrapping_sub(link.last_rx) > 12_000 { - m.cancel_pending(2); - link.last_rx = now; - dirty = true; - link.widget_dirty = true; - } - if m.connected && now.wrapping_sub(link.last_rx) > 30_000 { - m.mark_disconnected(); - dirty = true; - link.widget_dirty = true; - } - if link.widget_dirty && now.wrapping_sub(link.widget_last) >= 1000 { - let result = update_widget(api, m); - link.widget_dirty = false; - link.widget_last = now; - if !link.widget_reported && api.send(&[b'H', b'1', b'W', result as i8 as u8]) >= 0 { - link.widget_reported = true; - } - } - dirty - } - - /// Maps a negative `send` result to a diagnostic code shown on the phone row. - fn send_code(r: i32) -> u8 { - match r { - -11 => 11, - -107 => 107, - _ => 255, - } - } - - /// Sends one already-built command and consumes its sequence number. - fn send_cmd(api: &Api, m: &mut Model, frame: [u8; 6], seq: &mut u8) { - *seq = seq.wrapping_add(1); - let sent = api.send(&frame); - if sent < 0 { m.cancel_pending(send_code(sent)); } - } - - fn list_main( - api: &'static Api, - m: &mut Model, - stored: &mut [u8; 384], - lv: Lv, - mut batch: Batch, - mode: Mode, - ) -> i32 { - let mut flush = |b: &mut Batch| b.submit(&lv); - let mut screen = match Screen::build(&mut batch, m, mode, &mut flush) { - Ok(screen) => screen, - Err(_) => return 2, - }; - if flush(&mut batch).is_err() { return 3; } - let mut seq = 0u8; - let mut dirty = true; - let mut redraw_retry = false; - let mut last_redraw_retry = api.now(); - let mut link = Link::new(api, m); - let mut long_at = 0u32; - let mut long_slot = usize::MAX; - - let _ = api.send(&proto::HELLO); - loop { - let mut timeout = 250; - if m.pending.is_some() { timeout = 20; } - match api.event(timeout) { - Some(e) if e.kind == BUTTON => { - if screen.view == View::Slider { - // Own back: close the slider page instead of leaving the app. - if screen.leave(&mut batch).is_err() { return 7; } - screen = match Screen::build(&mut batch, m, mode, &mut flush) { - Ok(s) => s, - Err(_) => return 7, - }; - dirty = true; - } else if mode == Mode::Menu { - return 0; - } - } - Some(e) if e.kind == CROWN && screen.view == View::Slider => { - let slot = screen.slider_slot as usize; - if slot < MAX_BUTTONS { - let cur = m.buttons[slot].value.min(100) as i16; - let v = (cur + e.delta * CROWN_STEP).clamp(0, 100) as u8; - if let Some(frame) = m.brightness_frame(slot, v, seq) { - send_cmd(api, m, frame, &mut seq); - } else if !m.connected { - m.cancel_pending(107); - } - dirty = true; - } - } - Some(e) if e.kind == LV && e.y == CLICKED => { - let now = api.now(); - let slot = screen.row_slot(e.x as u16); - if let Some(slot) = slot { - if slot == long_slot && now.wrapping_sub(long_at) < LONG_GRACE_MS { - long_slot = usize::MAX; - } else if let Some((enabled, dimmer, on, value)) = - m.buttons.get(slot).map(|b| (b.enabled, b.is_dimmer(), b.on, b.value)) - { - if enabled && dimmer { - // Short press on a device: jump between 0 and 100. - let target = if on && value > 0 { 0 } else { 100 }; - if let Some(frame) = m.brightness_frame(slot, target, seq) { - send_cmd(api, m, frame, &mut seq); - } else if !m.connected { - m.cancel_pending(107); - } - dirty = true; - } else if enabled { - if let Some(frame) = m.toggle_frame(slot, seq) { - send_cmd(api, m, frame, &mut seq); - dirty = true; - } else if !m.connected { - m.cancel_pending(107); - dirty = true; - } - } - } - } - } - Some(e) if e.kind == LV && e.y == LONG_PRESSED => { - if screen.view == View::List { - if let Some(slot) = screen.row_slot(e.x as u16) { - if m.buttons.get(slot).is_some_and(|b| b.enabled && b.is_dimmer()) { - long_at = api.now(); - long_slot = slot; - if screen.leave(&mut batch).is_err() { return 7; } - screen = match Screen::build_slider(&mut batch, m, mode, &mut flush, slot) { - Ok(s) => s, - Err(_) => return 7, - }; - dirty = true; - } - } - } - } - Some(e) if e.kind == LV && e.y == VALUE_CHANGED => { - if screen.is_slider(e.x as u16) { - let slot = screen.slider_slot as usize; - if slot < MAX_BUTTONS { - let v = e.delta.clamp(0, 100) as u8; - screen.preview_slider(v); - dirty = true; - } - } - } - Some(e) if e.kind == LV && e.y == RELEASED => { - if screen.is_slider(e.x as u16) { - let slot = screen.slider_slot as usize; - if let (Some(v), true) = (screen.finish_slider(), slot < MAX_BUTTONS) { - if let Some(frame) = m.brightness_frame(slot, v, seq) { - send_cmd(api, m, frame, &mut seq); - } else if !m.connected { - m.cancel_pending(107); - } - dirty = true; - } - } - } - Some(e) if e.kind == PAUSE => { - loop { - match api.event(u32::MAX).map(|e| e.kind) { - Some(BUTTON) if mode == Mode::Menu && screen.view == View::List => return 0, - Some(RESUME) => break, - _ => {} - } - } - if screen.view == View::Slider { - // Returning from a popup lands back on the main list. - if screen.leave(&mut batch).is_err() { return 7; } - screen = match Screen::build(&mut batch, m, mode, &mut flush) { - Ok(s) => s, - Err(_) => return 7, - }; - } - let _ = api.send(&proto::HELLO); - dirty = true; - } - _ => {} - } - // Flush a brightness queued behind an in-flight command. - if let Some(frame) = m.take_later(seq) { - send_cmd(api, m, frame, &mut seq); - dirty = true; - } - if redraw_retry && api.now().wrapping_sub(last_redraw_retry) >= 1000 { - dirty = true; - last_redraw_retry = api.now(); - } - if sync(api, m, stored, &mut link) { dirty = true; } - if dirty { - let redraw = screen - .update(&mut batch, m, &mut flush) - .and_then(|_| flush(&mut batch)); - if redraw.is_err() { - // Keep the live BLE session: retry instead of exiting the app. - redraw_retry = true; - last_redraw_retry = api.now(); - } else { - redraw_retry = false; - } - dirty = false; - } - } - } -} - diff --git a/apps/ha-remote/src/proto.rs b/apps/ha-remote/src/proto.rs deleted file mode 100644 index 5d269ae..0000000 --- a/apps/ha-remote/src/proto.rs +++ /dev/null @@ -1,754 +0,0 @@ -//! Compact, bounded protocol shared with the Android companion. -//! -//! Frames are ASCII `H1`, a type byte and fixed binary fields. v3 carries ten slots, a -//! control kind per slot (toggle or dimmer) and up to five favorites. Ten 15-byte names do -//! not fit one 128-byte message, so configuration is split: `V`/`K` configure slots 5..10 -//! (config, sections), `J` their sections and `U` slots 0..5 plus the favorites; the phone -//! sends V, J, K, U in that order and `U` commits the state to NAND. The legacy `C`/`G` -//! frames from an older companion stay accepted, so an old phone still works. - -pub const MAX_BUTTONS: usize = 10; -pub const MAX_FAVORITES: usize = 5; -pub const HALF: usize = 5; -pub const NAME_MAX: usize = 15; -pub const SECTION_MAX: usize = 10; - -pub const KIND_TOGGLE: u8 = 0; -pub const KIND_DIMMER: u8 = 1; -pub const ICON_AUTO: u8 = 0; -pub const ICON_LIGHT_BULB: u8 = 1; -pub const ICON_CEILING_LIGHT: u8 = 2; -pub const ICON_FAN: u8 = 3; -pub const ICON_DEVICE: u8 = 4; - -pub const CONFIG_A: u8 = b'U'; -pub const CONFIG_B: u8 = b'V'; -pub const SECTIONS_A: u8 = b'J'; -pub const SECTIONS_B: u8 = b'K'; -pub const ICONS: u8 = b'I'; -pub const CONFIG: u8 = b'C'; -pub const GROUPS: u8 = b'G'; -pub const STATE: u8 = b'S'; -pub const HEARTBEAT: u8 = b'P'; -pub const ACK: u8 = b'A'; -pub const ERROR: u8 = b'E'; -pub const TOGGLE: u8 = b'T'; -pub const BRIGHTNESS: u8 = b'B'; -pub const RESULT_OK: u8 = 0; -pub const HELLO: [u8; 3] = *b"H1?"; - -/// One persisted controls blob: `D4`, count, favorites, then ten fixed records including an icon id. -pub const SAVE_LEN: usize = 3 + MAX_FAVORITES + MAX_BUTTONS * (6 + NAME_MAX + 1 + SECTION_MAX); -const SAVE_LEN_V3: usize = 3 + MAX_FAVORITES + MAX_BUTTONS * (4 + NAME_MAX + 1 + SECTION_MAX); - -/// No favorite in a favorites slot. -pub const NO_FAVORITE: u8 = 0xFF; - -#[derive(Clone, Copy, Debug, Eq, PartialEq)] -pub struct Button { - pub enabled: bool, - pub on: bool, - /// Last HA availability; runtime-only (not persisted): true until the phone says otherwise. - pub available: bool, - /// Brightness percent 0..=100 for a dimmer; 0 or 100 mirrors `on` for a toggle. - pub value: u8, - pub kind: u8, - pub icon: u8, - pub name: [u8; NAME_MAX], - pub len: u8, - pub section: [u8; SECTION_MAX], - pub sec_len: u8, -} - -impl Button { - pub const EMPTY: Self = Self { - enabled: false, - on: false, - available: true, - value: 0, - kind: KIND_TOGGLE, - icon: ICON_AUTO, - name: [0; NAME_MAX], - len: 0, - section: [0; SECTION_MAX], - sec_len: 0, - }; - - pub fn label(&self) -> &str { - core::str::from_utf8(&self.name[..self.len as usize]).unwrap_or("Control") - } - - pub fn section_label(&self) -> &str { - core::str::from_utf8(&self.section[..self.sec_len as usize]).unwrap_or("") - } - - pub fn is_dimmer(&self) -> bool { self.kind == KIND_DIMMER } -} - -#[derive(Clone, Copy, Debug, Eq, PartialEq)] -pub enum Effect { - Ignored, - Changed, - /// A half config or sections frame: redraw, mark linked, no NAND write yet. - Linked, - /// The commit frame: redraw and persist. - Configured, - Heartbeat, - Ack(u8), - Error(u8), -} - -pub struct Model { - pub buttons: [Button; MAX_BUTTONS], - pub favorites: [u8; MAX_FAVORITES], - pub connected: bool, - pub pending: Option, - pub pending_target: Option, - pub pending_value: Option, - pub pending_seq: Option, - /// Latest brightness the user dragged to while another command was in flight. - pub later: Option<(u8, u8)>, - pub error: Option, -} - -impl Model { - pub const fn new() -> Self { - Self { - buttons: [Button::EMPTY; MAX_BUTTONS], - favorites: [NO_FAVORITE; MAX_FAVORITES], - connected: false, - pending: None, - pending_target: None, - pending_value: None, - pending_seq: None, - later: None, - error: None, - } - } - - /// The widget's control: the first favorite, else the first enabled slot. - pub fn primary(&self) -> Option { - self.favorites - .iter() - .filter(|&&f| f != NO_FAVORITE) - .map(|&f| f as usize) - .find(|&i| i < MAX_BUTTONS && self.buttons[i].enabled) - .or_else(|| self.buttons.iter().position(|b| b.enabled)) - } - - pub fn is_favorite(&self, slot: usize) -> bool { - self.favorites.iter().any(|&f| f as usize == slot) - } - - fn parse_record(msg: &[u8], p: usize, three_byte: bool) -> Option<(usize, bool, u8, usize, [u8; NAME_MAX])> { - // three_byte: v3 records carry `enabled, kind, len`; legacy carries `enabled, len`. - let head = if three_byte { 3 } else { 2 }; - if p + head > msg.len() { return None; } - let enabled = msg[p]; - let (kind, len_at) = if three_byte { (msg[p + 1], p + 2) } else { (KIND_TOGGLE, p + 1) }; - let len = msg[len_at] as usize; - if enabled > 1 || len > NAME_MAX { return None; } - if three_byte && kind != KIND_TOGGLE && kind != KIND_DIMMER { return None; } - let name_at = p + head; - if name_at + len > msg.len() { return None; } - if core::str::from_utf8(&msg[name_at..name_at + len]).is_err() { return None; } - let mut name = [0u8; NAME_MAX]; - name[..len].copy_from_slice(&msg[name_at..name_at + len]); - Some((name_at + len, enabled == 1, kind, len, name)) - } - - fn config_half(&mut self, msg: &[u8], base: usize, with_favs: bool) -> Effect { - if base >= MAX_BUTTONS || msg[3] as usize > HALF { return Effect::Ignored; } - let n = msg[3] as usize; - let mut p = 4; - let mut parsed = [(false, KIND_TOGGLE, 0usize, [0u8; NAME_MAX]); HALF]; - for slot in parsed.iter_mut().take(n) { - match Self::parse_record(msg, p, true) { - Some((next, enabled, kind, len, name)) => { - p = next; - *slot = (enabled, kind, len, name); - } - None => return Effect::Ignored, - } - } - let fav_len = if with_favs { MAX_FAVORITES } else { 0 }; - if p + fav_len != msg.len() { return Effect::Ignored; } - let mut favs = self.favorites; - if with_favs { - favs = [NO_FAVORITE; MAX_FAVORITES]; - for (f, &b) in favs.iter_mut().zip(&msg[p..p + MAX_FAVORITES]) { - if b != NO_FAVORITE && b as usize >= MAX_BUTTONS { return Effect::Ignored; } - *f = b; - } - } - for (i, &(enabled, kind, len, ref name)) in parsed.iter().enumerate().take(n) { - let b = &mut self.buttons[base + i]; - b.enabled = enabled; - b.kind = kind; - b.icon = ICON_AUTO; - b.len = len as u8; - b.name = *name; - } - for i in n..HALF { - let b = &mut self.buttons[base + i]; - b.enabled = false; - b.icon = ICON_AUTO; - b.len = 0; - } - if with_favs { self.favorites = favs; } - self.connected = true; - if with_favs { Effect::Configured } else { Effect::Linked } - } - - fn sections_half(&mut self, msg: &[u8], base: usize) -> Effect { - if base >= MAX_BUTTONS || msg[3] as usize > HALF { return Effect::Ignored; } - let n = msg[3] as usize; - let mut p = 4; - let mut sections = [[0u8; SECTION_MAX]; HALF]; - let mut lens = [0usize; HALF]; - for i in 0..n { - if p >= msg.len() { return Effect::Ignored; } - let len = msg[p] as usize; - p += 1; - if len > SECTION_MAX || p + len > msg.len() { return Effect::Ignored; } - if core::str::from_utf8(&msg[p..p + len]).is_err() { return Effect::Ignored; } - sections[i][..len].copy_from_slice(&msg[p..p + len]); - lens[i] = len; - p += len; - } - if p != msg.len() { return Effect::Ignored; } - for i in 0..HALF { - let b = &mut self.buttons[base + i]; - if i < n { - b.sec_len = lens[i] as u8; - b.section = sections[i]; - } else { - b.sec_len = 0; - } - } - self.connected = true; - Effect::Linked - } - - fn icons(&mut self, msg: &[u8]) -> Effect { - if msg.len() != 3 + MAX_BUTTONS || msg[3..].iter().any(|&icon| icon > ICON_DEVICE) { - return Effect::Ignored; - } - for (button, &icon) in self.buttons.iter_mut().zip(&msg[3..]) { - button.icon = icon; - } - self.connected = true; - Effect::Configured - } - - fn legacy_config(&mut self, msg: &[u8]) -> Effect { - let n = msg[3] as usize; - if n > HALF { return Effect::Ignored; } - let mut p = 4; - let mut parsed = [(false, 0usize, [0u8; NAME_MAX]); HALF]; - for slot in parsed.iter_mut().take(n) { - match Self::parse_record(msg, p, false) { - Some((next, enabled, _, len, name)) => { p = next; *slot = (enabled, len, name); } - None => return Effect::Ignored, - } - } - let mut favs = self.favorites; - if p == msg.len() { - // older phone, no favorite byte: keep what we have - } else if p + 1 == msg.len() { - let fav = msg[p]; - if fav != NO_FAVORITE && fav as usize >= MAX_BUTTONS { return Effect::Ignored; } - favs = [NO_FAVORITE; MAX_FAVORITES]; - favs[0] = fav; - } else { - return Effect::Ignored; - } - for (i, &(enabled, len, ref name)) in parsed.iter().enumerate().take(n) { - let b = &mut self.buttons[i]; - b.enabled = enabled; - b.icon = ICON_AUTO; - b.len = len as u8; - b.name = *name; - } - for i in n..HALF { - self.buttons[i].enabled = false; - self.buttons[i].icon = ICON_AUTO; - self.buttons[i].len = 0; - } - self.favorites = favs; - self.connected = true; - Effect::Configured - } - - fn legacy_groups(&mut self, msg: &[u8]) -> Effect { - if msg[3] as usize != HALF { return Effect::Ignored; } - let mut p = 4; - let mut sections = [[0u8; SECTION_MAX]; HALF]; - let mut lens = [0usize; HALF]; - for i in 0..HALF { - if p >= msg.len() { return Effect::Ignored; } - let len = msg[p] as usize; - p += 1; - if len > SECTION_MAX || p + len > msg.len() { return Effect::Ignored; } - if core::str::from_utf8(&msg[p..p + len]).is_err() { return Effect::Ignored; } - sections[i][..len].copy_from_slice(&msg[p..p + len]); - lens[i] = len; - p += len; - } - let mut favs = self.favorites; - if p + 1 == msg.len() { - let fav = msg[p]; - if fav != NO_FAVORITE && fav as usize >= MAX_BUTTONS { return Effect::Ignored; } - favs = [NO_FAVORITE; MAX_FAVORITES]; - favs[0] = fav; - } else if p != msg.len() { - return Effect::Ignored; - } - for i in 0..HALF { - self.buttons[i].sec_len = lens[i] as u8; - self.buttons[i].section = sections[i]; - } - self.favorites = favs; - self.connected = true; - Effect::Configured - } - - pub fn apply(&mut self, msg: &[u8]) -> Effect { - if msg.len() < 3 || &msg[..2] != b"H1" { return Effect::Ignored; } - match msg[2] { - CONFIG_A if msg.len() >= 4 => self.config_half(msg, 0, true), - CONFIG_B if msg.len() >= 4 => self.config_half(msg, HALF, false), - SECTIONS_A if msg.len() >= 4 => self.sections_half(msg, 0), - SECTIONS_B if msg.len() >= 4 => self.sections_half(msg, HALF), - ICONS => self.icons(msg), - CONFIG if msg.len() >= 4 => self.legacy_config(msg), - GROUPS if msg.len() >= 4 => self.legacy_groups(msg), - HEARTBEAT if msg.len() == 3 => { self.connected = true; Effect::Heartbeat } - STATE if matches!(msg.len(), 6 | 7 | 8) => { - let i = msg[3] as usize; - if i >= MAX_BUTTONS || msg[4] > 1 { return Effect::Ignored; } - let (value, result, available) = match msg.len() { - 8 => { - if msg[5] > 100 || msg[7] > 1 { return Effect::Ignored; } - (msg[5], msg[6], msg[7] == 1) - } - 7 => { - if msg[5] > 100 { return Effect::Ignored; } - (msg[5], msg[6], true) - } - _ => (if msg[4] == 1 { 100 } else { 0 }, msg[5], true), - }; - let b = &mut self.buttons[i]; - b.on = msg[4] == 1; - b.value = value; - b.available = available; - self.connected = true; - let was_pending = self.pending == Some(i as u8); - if self.pending == Some(i as u8) { - self.pending = None; - self.pending_target = None; - self.pending_value = None; - self.pending_seq = None; - } - if available { - if result != RESULT_OK { self.error = Some(result); } else { self.error = None; } - } else if was_pending { - // The device itself is offline; the command is resolved and that is a - // device state, not an app/link failure. - self.error = None; - } - Effect::Changed - } - ACK if msg.len() == 4 && self.pending_seq == Some(msg[3]) => { - self.error = None; - Effect::Ack(msg[3]) - } - ERROR if msg.len() == 5 && self.pending_seq == Some(msg[3]) => { - let code = msg[4]; - self.cancel_pending(code); - Effect::Error(code) - } - _ => Effect::Ignored, - } - } - - pub fn toggle_frame(&mut self, i: usize, seq: u8) -> Option<[u8; 6]> { - if i >= MAX_BUTTONS || !self.connected || !self.buttons[i].enabled || self.pending.is_some() { - return None; - } - let target = !self.buttons[i].on; - self.pending = Some(i as u8); - self.pending_target = Some(target); - self.pending_value = None; - self.pending_seq = Some(seq); - Some([b'H', b'1', TOGGLE, seq, i as u8, target as u8]) - } - - /// Starts (or queues) a brightness change. Returns the frame to send now, or None when - /// another command is in flight (the value is remembered and flushed by [`take_later`]). - pub fn brightness_frame(&mut self, i: usize, value: u8, seq: u8) -> Option<[u8; 6]> { - if i >= MAX_BUTTONS || !self.connected || !self.buttons[i].enabled || !self.buttons[i].is_dimmer() { - return None; - } - let value = value.min(100); - // Show the dragged/pressed value immediately; the phone's state confirms it. - self.buttons[i].value = value; - if self.pending.is_some() { - self.later = Some((i as u8, value)); - return None; - } - self.pending = Some(i as u8); - self.pending_value = Some(value); - self.pending_target = None; - self.pending_seq = Some(seq); - Some([b'H', b'1', BRIGHTNESS, seq, i as u8, value]) - } - - /// Sends the queued drag value once the line is free again. - pub fn take_later(&mut self, seq: u8) -> Option<[u8; 6]> { - if self.pending.is_some() { return None; } - let (i, v) = self.later?; - self.later = None; - self.brightness_frame(i as usize, v, seq) - } - - /// A send failed or a command was rejected: drop every trace of it and show the code. - pub fn cancel_pending(&mut self, code: u8) { - self.pending = None; - self.pending_target = None; - self.pending_value = None; - self.pending_seq = None; - self.later = None; - self.error = Some(code); - } - - pub fn mark_disconnected(&mut self) { - self.connected = false; - self.pending = None; - self.pending_target = None; - self.pending_value = None; - self.pending_seq = None; - self.later = None; - self.error = None; - } - - pub fn load(&mut self, bytes: &[u8]) { - if bytes.len() == SAVE_LEN && &bytes[..2] == b"D4" && bytes[2] as usize == MAX_BUTTONS { - let base = 3 + MAX_FAVORITES; - let stride = 6 + NAME_MAX + 1 + SECTION_MAX; - let mut buttons = [Button::EMPTY; MAX_BUTTONS]; - let mut favs = [NO_FAVORITE; MAX_FAVORITES]; - for (f, &b) in favs.iter_mut().zip(&bytes[3..3 + MAX_FAVORITES]) { - if b != NO_FAVORITE && b as usize >= MAX_BUTTONS { return; } - *f = b; - } - for i in 0..MAX_BUTTONS { - let p = base + i * stride; - let len = bytes[p + 5] as usize; - let sec_len = bytes[p + 6 + NAME_MAX] as usize; - if bytes[p] > 1 - || (bytes[p + 1] != KIND_TOGGLE && bytes[p + 1] != KIND_DIMMER) - || bytes[p + 2] > ICON_DEVICE - || bytes[p + 3] > 1 - || bytes[p + 4] > 100 - || len > NAME_MAX - || sec_len > SECTION_MAX - || core::str::from_utf8(&bytes[p + 6..p + 6 + len]).is_err() - || core::str::from_utf8(&bytes[p + 7 + NAME_MAX..p + 7 + NAME_MAX + sec_len]).is_err() - { - return; - } - let b = &mut buttons[i]; - b.enabled = bytes[p] == 1; - b.kind = bytes[p + 1]; - b.icon = bytes[p + 2]; - b.on = bytes[p + 3] == 1; - b.value = bytes[p + 4]; - b.len = len as u8; - b.name[..len].copy_from_slice(&bytes[p + 6..p + 6 + len]); - b.sec_len = sec_len as u8; - b.section[..sec_len].copy_from_slice(&bytes[p + 7 + NAME_MAX..p + 7 + NAME_MAX + sec_len]); - } - self.buttons = buttons; - self.favorites = favs; - return; - } - // D3: the previous ten-slot format had no per-control icon. - if bytes.len() == SAVE_LEN_V3 && &bytes[..2] == b"D3" && bytes[2] as usize == MAX_BUTTONS { - let base = 3 + MAX_FAVORITES; - let stride = 4 + NAME_MAX + 1 + SECTION_MAX; - let mut migrated = [0u8; SAVE_LEN]; - migrated[..2].copy_from_slice(b"D4"); - migrated[2] = MAX_BUTTONS as u8; - migrated[3..3 + MAX_FAVORITES].copy_from_slice(&bytes[3..3 + MAX_FAVORITES]); - for i in 0..MAX_BUTTONS { - let old = base + i * stride; - let new = base + i * (6 + NAME_MAX + 1 + SECTION_MAX); - let len = bytes[old + 4] as usize; - let old_section_len = bytes[old + 5 + NAME_MAX] as usize; - // D3's stride overlapped the prior row's final section byte with this row's - // enabled flag, so retain only the bytes that were independently stored. - let section_len = old_section_len.min(SECTION_MAX - 1); - if bytes[old] > 1 - || (bytes[old + 1] != KIND_TOGGLE && bytes[old + 1] != KIND_DIMMER) - || bytes[old + 2] > 1 || bytes[old + 3] > 100 || len > NAME_MAX - || old_section_len > SECTION_MAX - || core::str::from_utf8(&bytes[old + 5..old + 5 + len]).is_err() - || core::str::from_utf8(&bytes[old + 6 + NAME_MAX..old + 6 + NAME_MAX + section_len]).is_err() - { - return; - } - migrated[new] = bytes[old]; - migrated[new + 1] = bytes[old + 1]; - migrated[new + 2] = ICON_AUTO; - migrated[new + 3] = bytes[old + 2]; - migrated[new + 4] = bytes[old + 3]; - migrated[new + 5] = len as u8; - migrated[new + 6..new + 6 + len].copy_from_slice(&bytes[old + 5..old + 5 + len]); - migrated[new + 6 + NAME_MAX] = section_len as u8; - migrated[new + 7 + NAME_MAX..new + 7 + NAME_MAX + section_len] - .copy_from_slice(&bytes[old + 6 + NAME_MAX..old + 6 + NAME_MAX + section_len]); - } - self.load(&migrated); - return; - } - // D2: the old five-slot blob (enabled, len, on, name[15], sec_len, section[10]). - if bytes.len() == 4 + HALF * (3 + NAME_MAX + 1 + SECTION_MAX) && &bytes[..2] == b"D2" && bytes[2] as usize == HALF { - let stride = 3 + NAME_MAX + 1 + SECTION_MAX; - let mut buttons = [Button::EMPTY; MAX_BUTTONS]; - let fav = bytes[3]; - if fav != NO_FAVORITE && fav as usize >= HALF { return; } - for i in 0..HALF { - let p = 4 + i * stride; - let len = bytes[p + 1] as usize; - let sec_len = bytes[p + 3 + NAME_MAX] as usize; - if bytes[p] > 1 || bytes[p + 2] > 1 || len > NAME_MAX || sec_len > SECTION_MAX - || core::str::from_utf8(&bytes[p + 3..p + 3 + len]).is_err() - || core::str::from_utf8(&bytes[p + 4 + NAME_MAX..p + 4 + NAME_MAX + sec_len]).is_err() - { - return; - } - let b = &mut buttons[i]; - b.enabled = bytes[p] == 1; - b.on = bytes[p + 2] == 1; - b.value = if b.on { 100 } else { 0 }; - b.len = len as u8; - b.name[..len].copy_from_slice(&bytes[p + 3..p + 3 + len]); - b.sec_len = sec_len as u8; - b.section[..sec_len].copy_from_slice(&bytes[p + 4 + NAME_MAX..p + 4 + NAME_MAX + sec_len]); - } - self.buttons = buttons; - self.favorites = [NO_FAVORITE; MAX_FAVORITES]; - self.favorites[0] = fav; - } - } - - pub fn save(&self, bytes: &mut [u8]) -> usize { - if bytes.len() < SAVE_LEN { return 0; } - bytes[..SAVE_LEN].fill(0); - bytes[..2].copy_from_slice(b"D4"); - bytes[2] = MAX_BUTTONS as u8; - bytes[3..3 + MAX_FAVORITES].copy_from_slice(&self.favorites); - let base = 3 + MAX_FAVORITES; - let stride = 6 + NAME_MAX + 1 + SECTION_MAX; - for i in 0..MAX_BUTTONS { - let p = base + i * stride; - let b = &self.buttons[i]; - bytes[p] = b.enabled as u8; - bytes[p + 1] = b.kind; - bytes[p + 2] = b.icon; - bytes[p + 3] = b.on as u8; - bytes[p + 4] = b.value; - bytes[p + 5] = b.len; - bytes[p + 6..p + 6 + b.len as usize].copy_from_slice(&b.name[..b.len as usize]); - bytes[p + 6 + NAME_MAX] = b.sec_len; - bytes[p + 7 + NAME_MAX..p + 7 + NAME_MAX + b.sec_len as usize] - .copy_from_slice(&b.section[..b.sec_len as usize]); - } - SAVE_LEN - } -} - -#[cfg(test)] -mod tests { - use super::*; - - fn config_frame(t: u8, base: usize, specs: &[(&str, bool, u8)], favs: Option<&[u8]>) -> Vec { - let mut f = vec![b'H', b'1', t, specs.len() as u8]; - for (name, enabled, kind) in specs { - let raw = name.as_bytes(); - f.push(*enabled as u8); - f.push(*kind); - f.push(raw.len() as u8); - f.extend_from_slice(raw); - } - if let Some(favs) = favs { f.extend_from_slice(favs); } - let _ = base; - f - } - - fn sections_frame(t: u8, sections: &[&str]) -> Vec { - let mut f = vec![b'H', b'1', t, sections.len() as u8]; - for s in sections { - f.push(s.len() as u8); - f.extend_from_slice(s.as_bytes()); - } - f - } - - fn ten_slots() -> Model { - let mut m = Model::new(); - let half_a = [("Lamp", true, KIND_DIMMER), ("Fan", true, KIND_TOGGLE), ("Desk", true, KIND_TOGGLE), ("Hall", false, KIND_TOGGLE), ("Plug", true, KIND_TOGGLE)]; - let half_b = [("Strip", true, KIND_DIMMER), ("Porch", false, KIND_TOGGLE), ("Bed", true, KIND_DIMMER), ("TV", true, KIND_TOGGLE), ("Heater", true, KIND_TOGGLE)]; - let favs = [0u8, 5, 7, 9, NO_FAVORITE]; - assert_eq!(m.apply(&config_frame(CONFIG_B, HALF, &half_b, None)), Effect::Linked); - assert_eq!(m.apply(§ions_frame(SECTIONS_A, &["Room", "Room", "", "", ""])), Effect::Linked); - assert_eq!(m.apply(§ions_frame(SECTIONS_B, &["", "", "Room", "", ""])), Effect::Linked); - assert_eq!(m.apply(&config_frame(CONFIG_A, 0, &half_a, Some(&favs))), Effect::Configured); - m - } - - #[test] - fn ten_slots_kinds_sections_and_favorites() { - let m = ten_slots(); - assert_eq!(m.buttons[0].label(), "Lamp"); - assert!(m.buttons[0].is_dimmer()); - assert_eq!(m.buttons[5].label(), "Strip"); - assert!(m.buttons[5].is_dimmer()); - assert!(!m.buttons[1].is_dimmer()); - assert!(!m.buttons[6].enabled); - assert_eq!(m.buttons[0].section_label(), "Room"); - assert_eq!(m.buttons[7].section_label(), "Room"); - assert_eq!(m.favorites, [0, 5, 7, 9, NO_FAVORITE]); - assert!(m.is_favorite(9)); - assert!(!m.is_favorite(1)); - assert_eq!(m.primary(), Some(0)); - } - - #[test] - fn legacy_five_slot_companion_still_configures() { - let mut m = Model::new(); - assert_eq!(m.apply(b"H1C\x02\x01\x04Desk\x01\x05Hall1"), Effect::Configured); - assert_eq!(m.apply(b"H1G\x05\x04Room\x00\x00\x00\x00\x00"), Effect::Configured); - assert!(m.buttons[0].enabled); - assert_eq!(m.buttons[0].label(), "Desk"); - assert_eq!(m.buttons[0].section_label(), "Room"); - assert!(!m.buttons[0].is_dimmer()); - assert_eq!(m.favorites[0], 0); - for i in HALF..MAX_BUTTONS { assert!(!m.buttons[i].enabled); } - assert_eq!(m.apply(b"H1C\x06"), Effect::Ignored); - } - - #[test] - fn toggle_state_old_and_new_brightness_flow() { - let mut m = ten_slots(); - assert_eq!(m.toggle_frame(0, 7), Some(*b"H1T\x07\x00\x01")); - assert!(m.toggle_frame(0, 8).is_none()); - // old 6-byte state from an older companion: value mirrors on/off - assert_eq!(m.apply(b"H1S\x00\x01\x00"), Effect::Changed); - assert!(m.buttons[0].on); - assert_eq!(m.buttons[0].value, 100); - assert!(m.pending.is_none()); - // new 7-byte state: authoritative brightness - assert_eq!(m.apply(b"H1S\x05\x01\x19\x00"), Effect::Changed); - assert_eq!(m.buttons[5].value, 25); - // drag while busy is queued, then flushed when the line frees - assert_eq!(m.apply(b"H1S\x05\x01\x19\x00"), Effect::Changed); - let f = m.brightness_frame(7, 40, 1).unwrap(); - assert_eq!(f, [b'H', b'1', b'B', 1, 7, 40]); - assert_eq!(m.buttons[7].value, 40); - assert!(m.brightness_frame(7, 80, 2).is_none()); - assert_eq!(m.later, Some((7, 80))); - assert_eq!(m.apply(b"H1S\x07\x01\x19\x00"), Effect::Changed); - let f2 = m.take_later(3).unwrap(); - assert_eq!(f2, [b'H', b'1', b'B', 3, 7, 80]); - assert_eq!(m.buttons[7].value, 80); - } - - #[test] - fn errors_timeouts_and_disconnect_clear_pending_state() { - let mut m = ten_slots(); - m.toggle_frame(0, 19).unwrap(); - assert_eq!(m.apply(b"H1A\x12"), Effect::Ignored); - assert_eq!(m.apply(b"H1E\x13\x02"), Effect::Error(2)); - assert_eq!(m.pending, None); - assert_eq!(m.error, Some(2)); - m.brightness_frame(5, 60, 1).unwrap(); - m.brightness_frame(5, 75, 2); // queued - assert_eq!(m.later, Some((5, 75))); - m.cancel_pending(107); - assert_eq!(m.pending, None); - assert_eq!(m.later, None); - assert_eq!(m.error, Some(107)); - m.mark_disconnected(); - assert!(!m.connected); - assert_eq!(m.error, None); - assert!(m.toggle_frame(0, 1).is_none()); - assert!(m.brightness_frame(0, 10, 1).is_none()); - assert_eq!(m.apply(b"H1P"), Effect::Heartbeat); - assert!(m.connected); - } - - #[test] - fn availability_marks_a_device_inactive_without_an_app_error() { - let mut m = ten_slots(); - m.toggle_frame(0, 9).unwrap(); - // 8-byte state: slot, on, value, result, available - assert_eq!(m.apply(b"H1S\x00\x00\x00\x00\x00"), Effect::Changed); - assert!(!m.buttons[0].available); - assert!(m.pending.is_none()); - assert_eq!(m.error, None); - // HA reports the entity again - assert_eq!(m.apply(b"H1S\x00\x01\x64\x00\x01"), Effect::Changed); - assert!(m.buttons[0].available); - // an availability byte other than 0/1 is rejected - assert_eq!(m.apply(b"H1S\x01\x00\x00\x00\x02"), Effect::Ignored); - assert!(m.buttons[1].available); - } - - #[test] - fn malformed_v3_frames_are_ignored_without_mutation() { - let mut m = ten_slots(); - let before = m.buttons[0].label().to_string(); - assert_eq!(m.apply(&config_frame(CONFIG_A, 0, &[("X", true, KIND_DIMMER)], Some(&[0, 1, 2, 3, 10]))), Effect::Ignored); // favorite 10 is not a slot - let mut bad_kind = config_frame(CONFIG_A, 0, &[("X", true, 9)], Some(&[0, 1, 2, 3, 4])); - bad_kind[3] = 1; - assert_eq!(m.apply(&bad_kind), Effect::Ignored); - assert_eq!(m.apply(§ions_frame(SECTIONS_A, &["Room", "Room", "", "", "", "Extra"])), Effect::Ignored); - assert_eq!(m.apply(b"H1S\x0A\x01\x32\x00"), Effect::Ignored); // slot 10 - assert_eq!(m.apply(b"H1S\x00\x01\x65\x00"), Effect::Ignored); // 101 percent - assert_eq!(m.buttons[0].label(), before); - } - - #[test] - fn d3_round_trip_and_d2_migration() { - let mut m = ten_slots(); - m.buttons[0].on = true; - m.buttons[0].value = 65; - m.buttons[7].on = true; - m.buttons[7].value = 100; - let mut data = [0u8; SAVE_LEN]; - let n = m.save(&mut data); - let mut loaded = Model::new(); - loaded.load(&data[..n]); - assert_eq!(loaded.buttons[0].label(), "Lamp"); - assert_eq!(loaded.buttons[0].value, 65); - assert!(loaded.buttons[7].is_dimmer()); - assert_eq!(loaded.favorites, m.favorites); - // the old five-slot blob migrates: toggles, one favorite, slots 5.. empty - let mut old = [0u8; 4 + HALF * (3 + NAME_MAX + 1 + SECTION_MAX)]; - old[..2].copy_from_slice(b"D2"); - old[2] = HALF as u8; - old[3] = 1; - let p = 4; - old[p] = 1; old[p + 1] = 4; old[p + 2] = 1; - old[p + 3..p + 7].copy_from_slice(b"Desk"); - let mut mig = Model::new(); - mig.load(&old); - assert!(mig.buttons[0].enabled && mig.buttons[0].on); - assert_eq!(mig.buttons[0].value, 100); - assert!(!mig.buttons[0].is_dimmer()); - assert_eq!(mig.favorites[0], 1); - for i in HALF..MAX_BUTTONS { assert!(!mig.buttons[i].enabled); } - } -} diff --git a/apps/ha-remote/src/screen.rs b/apps/ha-remote/src/screen.rs deleted file mode 100644 index 84098f3..0000000 --- a/apps/ha-remote/src/screen.rs +++ /dev/null @@ -1,727 +0,0 @@ -use crate::proto::{ - Button, ICON_CEILING_LIGHT, ICON_DEVICE, ICON_FAN, ICON_LIGHT_BULB, MAX_BUTTONS, Model, NAME_MAX, -}; -use cmf_wp2_app::lv::{ - Align, BUF, Batch, Class, CONTENT, CHECKED, Ev, Flag, LongMode, LvError, Obj, Prop, ROOT, -}; -use cmf_wp2_app::stock; - -const ROW_BYTES: usize = 1200; -const UPDATE_BYTES: usize = 400; -const ROW_H: i32 = 110; -const ROW_GAP: i32 = 2; -const ICON_SLOT: i32 = 80; -const ICON_X: i16 = 8; -const NAME_X: i16 = 104; -const NAME_W: i32 = stock::ROW_W - NAME_X as i32 - 84; -const SWITCH_W: i32 = 56; -const SWITCH_H: i32 = 28; -const KNOB: i32 = 24; -const PCT_W: i32 = 84; -/// The dimmer page's capsule: like the firmware's volume slider, no knob nub. -const TRACK_W: i32 = 168; -/// Tall like the firmware volume capsule; no text on the page, so it sits centered. -const TRACK_H: i32 = 300; - -/// Which surface is showing: the Apps row / face page list, or a device's slider page. -#[derive(Clone, Copy, PartialEq, Eq, Debug)] -pub(crate) enum Mode { Menu, Page } -#[derive(Clone, Copy, PartialEq, Eq, Debug)] -pub(crate) enum View { List, Slider } - -pub(crate) struct Screen { - pub(crate) mode: Mode, - pub(crate) view: View, - page: Obj, - // list surface (ROOT handles while the slider page is showing) - phone_detail: Obj, - headers: [Obj; MAX_BUTTONS], - names: [Obj; MAX_BUTTONS], - pills: [Obj; MAX_BUTTONS], - knobs: [Obj; MAX_BUTTONS], - details: [Obj; MAX_BUTTONS], - inactive: [Obj; MAX_BUTTONS], - icons: [Obj; MAX_BUTTONS], - icon_kinds: [u8; MAX_BUTTONS], - pub(crate) rows: [Obj; MAX_BUTTONS], - // slider surface - slider: Obj, - /// Local touch preview; the phone receives it only after release. - slider_preview: Option, - /// The slot whose slider page is open (0xFF on the list). - pub(crate) slider_slot: u8, -} - -/// A row shows when its slot is enabled; the page next to the face also requires a favorite. -fn visible(m: &Model, i: usize, mode: Mode) -> bool { - m.buttons.get(i).is_some_and(|b| b.enabled) - && (mode == Mode::Menu || m.is_favorite(i)) -} - -fn header_for<'a>(m: &'a Model, i: usize, mode: Mode) -> &'a str { - if !visible(m, i, mode) { return ""; } - let section = m.buttons[i].section_label(); - if section.is_empty() { return ""; } - match (0..i).rev().find(|&j| visible(m, j, mode)) { - Some(prev) if m.buttons[prev].section_label() == section => "", - _ => section, - } -} - -/// "65%" / "100%" for a dimmer row or the slider page. -pub(crate) fn pct_text<'a>(value: u8, buf: &'a mut [u8; 5]) -> &'a str { - let v = value.min(100); - let n = if v >= 100 { - buf[..3].copy_from_slice(b"100"); - 3 - } else if v >= 10 { - buf[0] = b'0' + v / 10; - buf[1] = b'0' + v % 10; - 2 - } else { - buf[0] = b'0' + v; - 1 - }; - buf[n] = b'%'; - core::str::from_utf8(&buf[..n + 1]).unwrap_or("") -} - -#[derive(Clone, Copy, PartialEq, Eq, Debug)] -pub(crate) enum Glyph { - Bulb, - CeilingLight, - Switch, - Fan, - Device, - Phone, -} - -const LIGHT_WORDS: &[&str] = &["light", "lamp", "bulb", "chandelier", "sconce", "lantern"]; - -fn word_matches(word: &str, needles: &[&str]) -> bool { - let bare = word.strip_suffix('s').or_else(|| word.strip_suffix('S')).unwrap_or(word); - needles.iter().any(|n| word.eq_ignore_ascii_case(n) || bare.eq_ignore_ascii_case(n)) -} - -fn words_of(name: &str) -> impl Iterator { - name.split(|c: char| !c.is_ascii_alphanumeric()) -} - -fn glyph_kind(name: &str) -> Glyph { - if words_of(name).any(|w| word_matches(w, LIGHT_WORDS)) { - Glyph::Bulb - } else if words_of(name).any(|w| word_matches(w, &["switch"])) { - Glyph::Switch - } else if words_of(name).any(|w| word_matches(w, &["fan"])) { - Glyph::Fan - } else { - Glyph::Switch - } -} - -fn glyph_for(button: &Button) -> Glyph { - match button.icon { - ICON_LIGHT_BULB => Glyph::Bulb, - ICON_CEILING_LIGHT => Glyph::CeilingLight, - ICON_FAN => Glyph::Fan, - ICON_DEVICE => Glyph::Device, - _ => glyph_kind(button.label()), - } -} - -fn write_label<'a>(m: &'a Model, i: usize, buf: &'a mut [u8; NAME_MAX + 2]) -> &'a str { - let label = match m.buttons.get(i) { Some(b) => b.label(), None => return "Control" }; - let prefix: &[u8] = if m.pending == Some(i as u8) { - b"\xe2\x80\xa6 " - } else if m.error.is_some() { - b"! " - } else { - b"" - }; - let copy = prefix.len().min(buf.len()); - buf[..copy].copy_from_slice(&prefix[..copy]); - let n = (prefix.len() + label.len()).min(buf.len()); - buf[prefix.len().min(n)..n].copy_from_slice(&label.as_bytes()[..n - prefix.len().min(n)]); - core::str::from_utf8(&buf[..n]).unwrap_or(label) -} - -fn glyph_piece( - b: &mut Batch, - parent: Obj, - w: i32, - h: i32, - x: i16, - y: i16, - radius: i32, - color: i32, -) -> Result { - let piece = b.create(Class::Obj, parent)?; - b.size(piece, w, h)?; - b.align(piece, Align::Center, x, y)?; - b.style(piece, Prop::Radius, 0, radius)?; - b.style(piece, Prop::BgColor, 0, color)?; - b.style(piece, Prop::BgOpa, 0, 255)?; - b.style(piece, Prop::BorderWidth, 0, 0)?; - b.flags(piece, &[], &[Flag::Clickable, Flag::Scrollable])?; - Ok(piece) -} - -fn glyph_blade(b: &mut Batch, parent: Obj, rotation: u16) -> Result { - let blade = b.create(Class::Arc, parent)?; - b.size(blade, 56, 56)?; - b.align(blade, Align::Center, 0, 0)?; - b.angles(blade, 15, 80, rotation)?; - b.value(blade, 0, false)?; - b.style(blade, Prop::ArcWidth, 0, 12)?; - b.style(blade, Prop::ArcRounded, 0, 1)?; - b.style(blade, Prop::ArcColor, 0, stock::WHITE)?; - b.style(blade, Prop::ArcOpa, 0, 255)?; - b.style(blade, Prop::ArcOpa, stock::INDICATOR, 0)?; - b.style(blade, Prop::BgOpa, stock::KNOB, 0)?; - b.flags(blade, &[], &[Flag::Clickable, Flag::Scrollable])?; - Ok(blade) -} - -fn draw_glyph(b: &mut Batch, slot: Obj, kind: Glyph) -> Result<(), LvError> { - match kind { - Glyph::Bulb => { - glyph_piece(b, slot, 42, 42, 0, -8, stock::CIRCLE, stock::WHITE)?; - glyph_piece(b, slot, 30, 30, 0, -8, stock::CIRCLE, stock::ROW_BG)?; - glyph_piece(b, slot, 22, 8, 0, 14, 3, stock::WHITE)?; - glyph_piece(b, slot, 14, 5, 0, 22, 2, stock::WHITE)?; - } - Glyph::CeilingLight => { - glyph_piece(b, slot, 30, 5, 0, -24, 2, stock::WHITE)?; - glyph_piece(b, slot, 4, 11, 0, -16, 2, stock::WHITE)?; - glyph_piece(b, slot, 42, 19, 0, -4, 12, stock::WHITE)?; - glyph_piece(b, slot, 32, 11, 0, -4, 8, stock::ROW_BG)?; - glyph_piece(b, slot, 4, 14, 0, 11, 2, stock::WHITE)?; - glyph_piece(b, slot, 20, 5, 0, 20, 2, stock::WHITE)?; - } - Glyph::Switch => { - glyph_piece(b, slot, 48, 28, 0, 0, 14, stock::WHITE)?; - glyph_piece(b, slot, 20, 20, 10, 0, stock::CIRCLE, stock::BLACK)?; - } - Glyph::Fan => { - glyph_piece(b, slot, 18, 18, 0, 0, stock::CIRCLE, stock::WHITE)?; - glyph_blade(b, slot, 0)?; - glyph_blade(b, slot, 120)?; - glyph_blade(b, slot, 240)?; - } - Glyph::Device | Glyph::Phone => { - glyph_piece(b, slot, 30, 48, 0, 0, 9, stock::WHITE)?; - glyph_piece(b, slot, 22, 34, 0, -3, 5, stock::BLACK)?; - glyph_piece(b, slot, 6, 6, 0, 16, stock::CIRCLE, stock::WHITE)?; - } - } - Ok(()) -} - -fn draw_icon(b: &mut Batch, row: Obj, kind: Glyph) -> Result { - let slot = b.create(Class::Obj, row)?; - b.size(slot, ICON_SLOT, ICON_SLOT)?; - b.align(slot, Align::LeftMid, ICON_X, 0)?; - b.style(slot, Prop::BgOpa, 0, 0)?; - b.style(slot, Prop::BorderWidth, 0, 0)?; - b.flags(slot, &[], &[Flag::Clickable, Flag::Scrollable])?; - draw_glyph(b, slot, kind)?; - Ok(slot) -} - -impl Screen { - fn empty(mode: Mode, view: View, page: Obj) -> Self { - Self { - mode, - view, - page, - phone_detail: ROOT, - headers: [ROOT; MAX_BUTTONS], - names: [ROOT; MAX_BUTTONS], - pills: [ROOT; MAX_BUTTONS], - knobs: [ROOT; MAX_BUTTONS], - details: [ROOT; MAX_BUTTONS], - inactive: [ROOT; MAX_BUTTONS], - icons: [ROOT; MAX_BUTTONS], - icon_kinds: [0; MAX_BUTTONS], - rows: [ROOT; MAX_BUTTONS], - slider: ROOT, - slider_preview: None, - slider_slot: 0xFF, - } - } - - /// The control list, as the Apps row or the page next to the face. - pub(crate) fn build( - b: &mut Batch, - m: &Model, - mode: Mode, - flush: &mut impl FnMut(&mut Batch) -> Result<(), LvError>, - ) -> Result { - stock::theme(b)?; - let (page, _bar) = stock::focus_page(b, 0)?; - let mut s = Self::empty(mode, View::List, page); - b.style(page, Prop::PadRow, 0, ROW_GAP)?; - b.style(page, Prop::PadTop, 0, 40)?; - let title = b.create(Class::Label, page)?; - b.size(title, stock::ROW_W, 72)?; - b.style(title, Prop::TextColor, 0, stock::WHITE)?; - b.style(title, Prop::TextAlign, 0, 2)?; - b.text(title, "Home Assistant")?; - - Self::room(b, flush, ROW_BYTES)?; - let phone = Self::row_base(b, page)?; - draw_icon(b, phone, Glyph::Phone)?; - let phone_name = b.create(Class::Label, phone)?; - b.text(phone_name, "Phone")?; - b.align(phone_name, Align::LeftMid, NAME_X, 0)?; - s.phone_detail = b.create(Class::Label, phone)?; - b.text(s.phone_detail, Self::phone_status(m))?; - b.style(s.phone_detail, Prop::TextColor, 0, stock::GREY)?; - b.align(s.phone_detail, Align::RightMid, -20, 0)?; - - for i in 0..MAX_BUTTONS { - Self::room(b, flush, ROW_BYTES)?; - let header = b.create(Class::Label, page)?; - let text = header_for(m, i, mode); - b.size(header, stock::ROW_W, CONTENT)?; - b.style(header, Prop::TextAlign, 0, 2)?; - b.style(header, Prop::TextColor, 0, stock::GREY)?; - b.text(header, text)?; - if text.is_empty() { b.flags(header, &[Flag::Hidden], &[])?; } - s.headers[i] = header; - - let row = Self::row_base(b, page)?; - s.rows[i] = row; - if !visible(m, i, mode) { b.flags(row, &[Flag::Hidden], &[])?; } - let button = &m.buttons[i]; - let kind = glyph_for(button); - s.icons[i] = draw_icon(b, row, kind)?; - s.icon_kinds[i] = kind as u8; - let name_label = b.create(Class::Label, row)?; - b.size(name_label, NAME_W, CONTENT)?; - b.long_mode(name_label, LongMode::Dot)?; - b.text(name_label, if button.enabled { button.label() } else { "Not configured" })?; - s.names[i] = name_label; - - let pill = b.create(Class::Obj, row)?; - b.size(pill, SWITCH_W, SWITCH_H)?; - b.align(pill, Align::RightMid, -20, 0)?; - b.style(pill, Prop::Radius, 0, stock::CIRCLE)?; - b.style(pill, Prop::BgColor, 0, stock::GREY)?; - b.style(pill, Prop::BgOpa, 0, 255)?; - b.flags(pill, &[], &[Flag::Clickable, Flag::Scrollable])?; - let knob = b.create(Class::Obj, pill)?; - b.size(knob, KNOB, KNOB)?; - b.style(knob, Prop::Radius, 0, stock::CIRCLE)?; - b.style(knob, Prop::BgColor, 0, stock::WHITE)?; - b.style(knob, Prop::BgOpa, 0, 255)?; - b.flags(knob, &[], &[Flag::Clickable, Flag::Scrollable])?; - b.align(knob, Align::LeftMid, 2, 0)?; - s.pills[i] = pill; - s.knobs[i] = knob; - - // A dimmer's row shows its brightness; a switch row shows the pill. - let pct = b.create(Class::Label, row)?; - b.size(pct, PCT_W, CONTENT)?; - b.style(pct, Prop::TextAlign, 0, 2)?; - b.style(pct, Prop::TextColor, 0, stock::GREY)?; - s.details[i] = pct; - let inactive = b.create(Class::Label, row)?; - b.text(inactive, "Inactive")?; - b.size(inactive, 120, CONTENT)?; - b.style(inactive, Prop::TextColor, 0, stock::GREY)?; - b.style(inactive, Prop::TextAlign, 0, 2)?; - s.inactive[i] = inactive; - Self::row_state_layout( - b, name_label, pill, pct, inactive, button.is_dimmer(), button.available, - )?; - } - Ok(s) - } - - /// A device's brightness page: the stock-looking thick vertical slider, a big percent - /// number, and the crown (the page is non-scrollable, so knob() routes CROWN to us). - pub(crate) fn build_slider( - b: &mut Batch, - m: &Model, - mode: Mode, - flush: &mut impl FnMut(&mut Batch) -> Result<(), LvError>, - slot: usize, - ) -> Result { - if slot >= MAX_BUTTONS || !m.buttons[slot].is_dimmer() { return Err(LvError::Code(-22)); } - stock::theme(b)?; - Self::room(b, flush, ROW_BYTES)?; - let page = b.create(Class::Obj, ROOT)?; - b.size(page, stock::SCREEN, stock::SCREEN)?; - for p in [ - Prop::PadTop, Prop::PadBottom, Prop::PadLeft, Prop::PadRight, - Prop::BorderWidth, Prop::Radius, Prop::BgOpa, - ] { - b.style(page, p, 0, 0)?; - } - b.flags(page, &[], &[Flag::Scrollable])?; - b.knob(page)?; - - let mut s = Self::empty(mode, View::Slider, page); - s.slider_slot = slot as u8; - s.slider = b.create(Class::Slider, page)?; - b.size(s.slider, TRACK_W, TRACK_H)?; - b.align(s.slider, Align::Center, 0, 0)?; - b.range(s.slider, 0, 100)?; - b.value(s.slider, m.buttons[slot].value.min(100) as i32, false)?; - // Use LVGL's own clipped indicator so the fill follows the capsule exactly at every value. - b.style(s.slider, Prop::BgColor, 0, stock::LETTER_BG)?; - b.style(s.slider, Prop::BgOpa, 0, 255)?; - b.style(s.slider, Prop::Radius, 0, stock::CIRCLE)?; - b.style(s.slider, Prop::BgColor, stock::INDICATOR, stock::WHITE)?; - b.style(s.slider, Prop::BgOpa, stock::INDICATOR, 255)?; - b.style(s.slider, Prop::Radius, stock::INDICATOR, stock::CIRCLE)?; - b.style(s.slider, Prop::BgOpa, stock::KNOB, 0)?; - b.style(s.slider, Prop::BorderWidth, stock::KNOB, 0)?; - b.events(s.slider, &[Ev::ValueChanged, Ev::Released])?; - - // Plus (top) and minus (bottom), both inset within the capsule ends. - Self::plus_minus(b, s.slider, 0, -((TRACK_H / 2 - 48) as i16), true, stock::GREY)?; - Self::plus_minus(b, s.slider, 0, (TRACK_H / 2 - 48) as i16, false, stock::BLACK)?; - Ok(s) - } - - /// Plus/Minus icon: a circle (26x26) with a plus (vertical+horizontal) or minus (horizontal only) cross. - /// Plus (is_plus=true): grey on dark track. Minus (is_plus=false): black on white fill. - fn plus_minus( - b: &mut Batch, - parent: Obj, - x: i16, - y: i16, - is_plus: bool, - colour: i32, - ) -> Result<(), LvError> { - // Circle background - glyph_piece(b, parent, 26, 26, x, y, stock::CIRCLE, colour)?; - // Horizontal bar (both plus and minus) - let mark = if colour == stock::GREY { stock::BLACK } else { stock::WHITE }; - glyph_piece(b, parent, 18, 4, x, y, 2, mark)?; - // Vertical bar (plus only) - if is_plus { - glyph_piece(b, parent, 4, 18, x, y, 2, mark)?; - } - Ok(()) - } - - /// Deletes the current screen (its page, with every object and its scroll bar), like - /// ui-gallery's screen switch; the next build starts from a clean handle table. - pub(crate) fn leave(&mut self, b: &mut Batch) -> Result<(), LvError> { - if self.page != ROOT { b.del(self.page)?; } - Ok(()) - } - - fn row_base(b: &mut Batch, parent: Obj) -> Result { - let row = stock::focus_row(b, parent)?; - b.size(row, stock::ROW_W, ROW_H)?; - b.style(row, Prop::BgOpa, CHECKED, 0)?; - // Long press opens the device's slider page. - b.events(row, &[Ev::LongPressed])?; - Ok(row) - } - - /// Switch/percent/inactive visibility for the row's kind and availability. - fn row_state_layout( - b: &mut Batch, - name: Obj, - pill: Obj, - pct: Obj, - inactive: Obj, - dimmer: bool, - available: bool, - ) -> Result<(), LvError> { - b.align(name, Align::LeftMid, NAME_X, 0)?; - b.align(pct, Align::RightMid, -20, 0)?; - b.align(inactive, Align::RightMid, -20, 0)?; - b.style(name, Prop::TextColor, 0, if available { stock::WHITE } else { stock::GREY })?; - if !available { - b.flags(pct, &[Flag::Hidden], &[])?; - b.flags(inactive, &[], &[Flag::Hidden])?; - b.flags(pill, &[Flag::Hidden], &[])?; - } else if dimmer { - b.flags(pill, &[Flag::Hidden], &[])?; - b.flags(inactive, &[Flag::Hidden], &[])?; - b.flags(pct, &[], &[Flag::Hidden])?; - } else { - b.flags(pct, &[Flag::Hidden], &[])?; - b.flags(inactive, &[Flag::Hidden], &[])?; - b.flags(pill, &[], &[Flag::Hidden])?; - } - Ok(()) - } - - fn room( - b: &mut Batch, - flush: &mut impl FnMut(&mut Batch) -> Result<(), LvError>, - need: usize, - ) -> Result<(), LvError> { - if b.bytes().len() + need > BUF { flush(b)?; } - Ok(()) - } - - fn phone_status(m: &Model) -> &'static str { - if !m.connected { - "Offline" - } else if m.error == Some(2) { - "Timeout" - } else if m.error.is_some() { - "Failed" - } else if m.pending.is_some() { - "Busy" - } else { - "Online" - } - } - - pub(crate) fn row_slot(&self, handle: u16) -> Option { - if self.view != View::List { return None; } - self.rows.iter().position(|r| r.0 == handle && handle != ROOT.0) - } - - /// True when [handle] is the slider page's slider. - pub(crate) fn is_slider(&self, handle: u16) -> bool { - self.view == View::Slider && self.slider.0 == handle - } - - pub(crate) fn preview_slider(&mut self, value: u8) { - self.slider_preview = Some(value.min(100)); - } - - pub(crate) fn finish_slider(&mut self) -> Option { - self.slider_preview.take() - } - - pub(crate) fn update( - &mut self, - b: &mut Batch, - m: &Model, - flush: &mut impl FnMut(&mut Batch) -> Result<(), LvError>, - ) -> Result<(), LvError> { - match self.view { - View::Slider => { - let i = self.slider_slot as usize; - if i >= MAX_BUTTONS { return Ok(()); } - let value = self.slider_preview.unwrap_or(m.buttons[i].value).min(100); - b.value(self.slider, value as i32, false)?; - Ok(()) - } - View::List => { - b.text(self.phone_detail, Self::phone_status(m))?; - for i in 0..MAX_BUTTONS { - Self::room(b, flush, UPDATE_BYTES)?; - let text = header_for(m, i, self.mode); - b.text(self.headers[i], text)?; - if text.is_empty() { b.flags(self.headers[i], &[Flag::Hidden], &[])?; } - else { b.flags(self.headers[i], &[], &[Flag::Hidden])?; } - let button = &m.buttons[i]; - if visible(m, i, self.mode) { b.flags(self.rows[i], &[], &[Flag::Hidden])?; } - else { b.flags(self.rows[i], &[Flag::Hidden], &[])?; } - let kind = glyph_for(button); - if kind as u8 != self.icon_kinds[i] { - Self::room(b, flush, UPDATE_BYTES)?; - let _ = b.del(self.icons[i]); - match draw_icon(b, self.rows[i], kind) { - Ok(icon) => { - self.icons[i] = icon; - self.icon_kinds[i] = kind as u8; - } - Err(e) => return Err(e), - } - } - let mut buf = [0u8; NAME_MAX + 2]; - b.text(self.names[i], write_label(m, i, &mut buf))?; - let dimmer = button.is_dimmer(); - if dimmer && button.available { - let mut pbuf = [0u8; 5]; - b.text(self.details[i], pct_text(button.value, &mut pbuf))?; - } - if !dimmer && button.available { - b.style(self.pills[i], Prop::BgColor, 0, if button.on { stock::WHITE } else { stock::GREY })?; - b.style(self.knobs[i], Prop::BgColor, 0, if button.on { stock::BLACK } else { stock::WHITE })?; - b.align( - self.knobs[i], - if button.on { Align::RightMid } else { Align::LeftMid }, - if button.on { -2 } else { 2 }, - 0, - )?; - } - Self::row_state_layout( - b, - self.names[i], - self.pills[i], - self.details[i], - self.inactive[i], - dimmer, - button.available, - )?; - } - Ok(()) - } - } - } -} - -#[cfg(test)] -mod tests { - use super::*; - use crate::proto::{Effect, KIND_DIMMER, NO_FAVORITE}; - use wp2_core::lvcmd::{self, Table}; - - const FONTS: u8 = 1 << stock::FONT; - - fn open_fonts(b: &mut Batch) { - stock::font(b).unwrap(); - } - - fn validate_and_apply(b: &mut Batch, table: &mut Table) -> Result<(), LvError> { - assert_eq!(lvcmd::validate(b.bytes(), table, FONTS), Ok(())); - for record in lvcmd::records(b.bytes()) { - lvcmd::apply(table, &record.unwrap()); - } - b.clear(); - Ok(()) - } - - fn menu_model() -> Model { - let mut m = Model::new(); - let mut v = vec![b'H', b'1', b'V', 5]; - for (name, kind, en) in [("Strip", KIND_DIMMER, 1u8), ("Porch", 0, 1), ("Bed", KIND_DIMMER, 1), ("TV", 0, 1), ("Heater", 0, 0)] { - v.extend([en, kind, name.len() as u8]); - v.extend_from_slice(name.as_bytes()); - } - assert_eq!(m.apply(&v), Effect::Linked); - let mut u = vec![b'H', b'1', b'U', 3]; - for (name, kind, en) in [("Lamp", KIND_DIMMER, 1u8), ("Fan", 0, 1), ("Desk", 0, 1)] { - u.extend([en, kind, name.len() as u8]); - u.extend_from_slice(name.as_bytes()); - } - u.extend([0, 5, 7, 9, 0xFF]); - assert_eq!(m.apply(&u), Effect::Configured); - m - } - - #[test] - fn menu_build_updates_and_lifecycle_validate() { - let mut b = Batch::with_buf(Box::leak(Box::new([0; BUF]))); - open_fonts(&mut b); - assert_eq!(lvcmd::validate(b.bytes(), &Table::new(), FONTS), Ok(())); - b.clear(); - - let mut model = menu_model(); - let mut table = Table::new(); - let mut screen = Screen::build(&mut b, &model, Mode::Menu, &mut |batch| { - validate_and_apply(batch, &mut table) - }) - .unwrap(); - validate_and_apply(&mut b, &mut table).unwrap(); - - assert!(table.has(wp2_core::lvcmd::Class::ScrollBar)); - for i in 0..MAX_BUTTONS { - assert_eq!(table.class(screen.rows[i].0), Some(wp2_core::lvcmd::Class::Obj)); - assert_eq!(table.class(screen.details[i].0), Some(wp2_core::lvcmd::Class::Label)); - assert_eq!(table.class(screen.pills[i].0), Some(wp2_core::lvcmd::Class::Obj)); - assert_eq!(table.class(screen.inactive[i].0), Some(wp2_core::lvcmd::Class::Label)); - } - // state, failure, disconnect and the inactive state all redraw cleanly - assert_eq!(model.apply(b"H1S\x00\x01\x19\x00\x01"), Effect::Changed); - screen.update(&mut b, &model, &mut |batch| validate_and_apply(batch, &mut table)).unwrap(); - validate_and_apply(&mut b, &mut table).unwrap(); - model.apply(b"H1S\x02\x00\x00\x01\x01"); - screen.update(&mut b, &model, &mut |batch| validate_and_apply(batch, &mut table)).unwrap(); - validate_and_apply(&mut b, &mut table).unwrap(); - model.mark_disconnected(); - screen.update(&mut b, &model, &mut |batch| validate_and_apply(batch, &mut table)).unwrap(); - validate_and_apply(&mut b, &mut table).unwrap(); - model.apply(b"H1S\x00\x00\x00\x00\x00"); - screen.update(&mut b, &model, &mut |batch| validate_and_apply(batch, &mut table)).unwrap(); - validate_and_apply(&mut b, &mut table).unwrap(); - // a rename swaps the glyph - model.apply(b"H1C\x01\x01\x04Desk"); - screen.update(&mut b, &model, &mut |batch| validate_and_apply(batch, &mut table)).unwrap(); - validate_and_apply(&mut b, &mut table).unwrap(); - - // switch to a dimmer's slider page and back: delete + rebuild, ui-gallery style - screen.leave(&mut b).unwrap(); - validate_and_apply(&mut b, &mut table).unwrap(); - let mut slider = Screen::build_slider(&mut b, &model, Mode::Menu, &mut |batch| { - validate_and_apply(batch, &mut table) - }, 0) - .unwrap(); - validate_and_apply(&mut b, &mut table).unwrap(); - assert!(slider.is_slider(slider.slider.0)); - model.buttons[0].value = 65; - slider.update(&mut b, &model, &mut |batch| validate_and_apply(batch, &mut table)).unwrap(); - validate_and_apply(&mut b, &mut table).unwrap(); - slider.leave(&mut b).unwrap(); - validate_and_apply(&mut b, &mut table).unwrap(); - let back = Screen::build(&mut b, &model, Mode::Menu, &mut |batch| { - validate_and_apply(batch, &mut table) - }) - .unwrap(); - validate_and_apply(&mut b, &mut table).unwrap(); - assert_eq!(back.view, View::List); - } - - #[test] - fn page_shows_only_favorites_and_headers_follow_visible_rows() { - let mut m = menu_model(); - m.apply(b"H1J\x05\x04East\x04East\x04West\x00\x00"); - m.apply(b"H1K\x05\x04East\x00\x04West\x00\x00"); - assert!(visible(&m, 0, Mode::Page)); - assert!(!visible(&m, 1, Mode::Page)); - assert!(!visible(&m, 3, Mode::Page)); - assert!(visible(&m, 5, Mode::Page)); - assert!(visible(&m, 7, Mode::Page)); - assert_eq!(header_for(&m, 0, Mode::Page), "East"); - assert_eq!(header_for(&m, 7, Mode::Page), "West"); - assert!(visible(&m, 1, Mode::Menu)); - assert_eq!(header_for(&m, 1, Mode::Menu), ""); - assert_eq!(header_for(&m, 5, Mode::Menu), "East"); - assert_eq!(header_for(&m, 7, Mode::Menu), "West"); - } - - #[test] - fn rows_map_back_to_slots_and_pct_formats() { - let m = menu_model(); - let mut b = Batch::with_buf(Box::leak(Box::new([0; BUF]))); - let mut flush = |batch: &mut Batch| { - batch.clear(); - Ok(()) - }; - let s = Screen::build(&mut b, &m, Mode::Menu, &mut flush).unwrap(); - assert_eq!(s.row_slot(s.rows[3].0), Some(3)); - assert_eq!(s.row_slot(ROOT.0), None); - assert!(!s.is_slider(s.rows[3].0)); - let mut buf = [0u8; 5]; - assert_eq!(pct_text(0, &mut buf), "0%"); - assert_eq!(pct_text(7, &mut buf), "7%"); - assert_eq!(pct_text(65, &mut buf), "65%"); - assert_eq!(pct_text(100, &mut buf), "100%"); - let _ = m.primary(); - assert_eq!(m.favorites.iter().filter(|&&f| f != NO_FAVORITE).count(), 4); - } - - #[test] - fn section_headers_show_only_at_group_starts() { - let mut m = Model::new(); - m.apply(b"H1C\x03\x01\x02A1\x01\x02A2\x01\x02B1"); - m.apply(b"H1G\x05\x04East\x04East\x04West\x00\x00\xFF"); - assert_eq!(header_for(&m, 0, Mode::Menu), "East"); - assert_eq!(header_for(&m, 1, Mode::Menu), ""); - assert_eq!(header_for(&m, 2, Mode::Menu), "West"); - } - - #[test] - fn control_names_pick_their_icon() { - assert!(word_matches("LIGHTS", LIGHT_WORDS)); - assert!(word_matches("Lamps", LIGHT_WORDS)); - assert_eq!(glyph_kind("Living Room Light"), Glyph::Bulb); - assert_eq!(glyph_kind("Fan with Light"), Glyph::Bulb); - assert_eq!(glyph_kind("Ceiling Fan"), Glyph::Fan); - assert_eq!(glyph_kind("Main Switch"), Glyph::Switch); - } -} diff --git a/apps/ha-remote/store.md b/apps/ha-remote/store.md deleted file mode 100644 index 08bbadb..0000000 --- a/apps/ha-remote/store.md +++ /dev/null @@ -1,17 +0,0 @@ -Control up to ten Home Assistant entities from the wrist: lights, switches, fans, plugs, anything that turns on and off. The Android companion lists every entity in your Home Assistant; you pick each control's kind, short watch name and section, and the watch shows them grouped and centered. - -- **Toggle rows** show a stock switch for on/off controls. -- **Lights are one tap for 0/100 and a long press for the dimmer page**: a knob-free, text-free vertical capsule — dark track, white fill, drag or crown — the same shape as the settings volume slider. A finger drag sends its brightness after release; the phone confirms the real state back. -- **Choose a Material icon for each control** in the Android app, or leave it on Auto to match the control name. -- **Up to five favorites** live on the page next to the watch face and the widget card; everything else stays in the Apps row. -- **Inactive** appears when Home Assistant has no data for a device (it lost power): the row greys out instead of failing, and comes back when the device does. - -The phone is the only Home Assistant client: it sends commands over the encrypted app channel and reports the confirmed state, including changes made from other apps. - -## Requirements - -- FMC patched firmware/App Loader with channel key K support (2026-11-13 or later). The optional page and widget need firmware stub v4+ and a loader from 2026-11-15 or later. -- The Home Assistant companion app v0.3.0 or later on the same phone as Nothing X: . It connects to the watch's existing bonded BLE identity without rebinding and sends commands through the encrypted app channel. -- A Home Assistant instance configured in the companion app. - -The BLE app channel is readable by any nearby BLE client that can obtain the pairing secret. Do not send credentials or personal data over it. The app protocol carries slot indexes, short labels, states and generic error codes only. diff --git a/apps/ha-remote/store.toml b/apps/ha-remote/store.toml deleted file mode 100644 index 89b4051..0000000 --- a/apps/ha-remote/store.toml +++ /dev/null @@ -1,6 +0,0 @@ -name = "Home Assistant" -summary = "Control up to ten Home Assistant entities from your watch, with brightness sliders" -version = "0.2.6" -author = "CMF Tech Community" -screenshots = ["shots/watch.jpg"] - diff --git a/apps/lake-cast/Cargo.toml b/apps/lake-cast/Cargo.toml deleted file mode 100644 index 4956b65..0000000 --- a/apps/lake-cast/Cargo.toml +++ /dev/null @@ -1,13 +0,0 @@ -[package] -name = "lake-cast" -edition.workspace = true -license.workspace = true -version.workspace = true - -[dependencies] -cmf-wp2-app.workspace = true -cmf-wp2-ui.workspace = true - -[[bin]] -name = "lake-cast" -bench = false diff --git a/apps/lake-cast/icon.svg b/apps/lake-cast/icon.svg deleted file mode 100644 index 70cd54d..0000000 --- a/apps/lake-cast/icon.svg +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/apps/lake-cast/shots/caught.png b/apps/lake-cast/shots/caught.png deleted file mode 100644 index 7033b7b..0000000 Binary files a/apps/lake-cast/shots/caught.png and /dev/null differ diff --git a/apps/lake-cast/shots/difficulty.png b/apps/lake-cast/shots/difficulty.png deleted file mode 100644 index 28cc68c..0000000 Binary files a/apps/lake-cast/shots/difficulty.png and /dev/null differ diff --git a/apps/lake-cast/shots/lake.png b/apps/lake-cast/shots/lake.png deleted file mode 100644 index bb02754..0000000 Binary files a/apps/lake-cast/shots/lake.png and /dev/null differ diff --git a/apps/lake-cast/shots/menu.png b/apps/lake-cast/shots/menu.png deleted file mode 100644 index c676e0c..0000000 Binary files a/apps/lake-cast/shots/menu.png and /dev/null differ diff --git a/apps/lake-cast/shots/reeling.png b/apps/lake-cast/shots/reeling.png deleted file mode 100644 index f7b6d98..0000000 Binary files a/apps/lake-cast/shots/reeling.png and /dev/null differ diff --git a/apps/lake-cast/shots/trophies.png b/apps/lake-cast/shots/trophies.png deleted file mode 100644 index 109a61a..0000000 Binary files a/apps/lake-cast/shots/trophies.png and /dev/null differ diff --git a/apps/lake-cast/src/font.rs b/apps/lake-cast/src/font.rs deleted file mode 100644 index 1073cbe..0000000 --- a/apps/lake-cast/src/font.rs +++ /dev/null @@ -1,1431 +0,0 @@ -//! Smooth 4-bpp (16-level) anti-aliased fonts generated by `tools/gen_font.py`. -//! -//! Glyphs rasterized from Barlow SemiBold (Copyright 2017 The Barlow Project Authors, -//! https://github.com/jpt/barlow), licensed under the SIL Open Font License 1.1 -//! (https://scripts.sil.org/OFL). - -use cmf_wp2_ui::draw::Run; -use cmf_wp2_ui::{ONE, Rgb, Surface}; - -#[derive(Clone, Copy)] -pub struct Glyph { - pub ch: u8, - pub x_off: i8, - pub y_off: i8, - pub w: u8, - pub h: u8, - pub adv: u8, - pub offset: u16, -} - -pub struct Font { - pub glyphs: &'static [Glyph], - pub data: &'static [u8], -} - -impl Font { - fn glyph(&self, b: u8) -> Option<&Glyph> { - self.glyphs.iter().find(|g| g.ch == b) - } - - pub fn width(&self, text: &str) -> i32 { - let mut w = 0i32; - for b in text.bytes() { - w += self.glyph(b).map_or(0, |g| g.adv as i32); - } - w - } - - pub fn draw(&self, s: &mut impl Surface, x: i32, y: i32, text: &str, fg: Rgb, bg: Rgb) { - let mut pal = [0u16; 16]; - pal[0] = bg.rgb565(); - pal[15] = fg.rgb565(); - for i in 1..15 { - pal[i] = bg.mix(fg, (i as i32) * ONE / 15).rgb565(); - } - let mut cx = x; - for b in text.bytes() { - let Some(g) = self.glyph(b) else { continue }; - let gw = g.w as usize; - let gh = g.h as usize; - if gw > 0 && gh > 0 { - let gx = cx + g.x_off as i32; - let gy = y + g.y_off as i32; - let start = g.offset as usize; - for row in 0..gh { - let mut run = Run::new(s, gy + row as i32, false); - for col in 0..gw { - let idx = row * gw + col; - let byte = self.data[start + (idx >> 1)]; - let lvl = if (idx & 1) == 0 { byte >> 4 } else { byte & 0x0F } as usize; - if lvl != 0 { - run.put(gx + col as i32, 1, pal[lvl]); - } - } - } - } - cx += g.adv as i32; - } - } - - pub fn centre(&self, s: &mut impl Surface, cx: i32, y: i32, text: &str, fg: Rgb, bg: Rgb) { - let w = self.width(text); - self.draw(s, cx - w / 2, y, text, fg, bg); - } - - pub fn draw_over(&self, s: &mut impl Surface, x: i32, y: i32, text: &str, fg: Rgb, under: &impl Fn(i32, i32) -> Rgb) { - let fg565 = fg.rgb565(); - let mut cx = x; - for b in text.bytes() { - let Some(g) = self.glyph(b) else { continue }; - let gw = g.w as usize; - let gh = g.h as usize; - if gw > 0 && gh > 0 { - let gx = cx + g.x_off as i32; - let gy = y + g.y_off as i32; - let start = g.offset as usize; - for row in 0..gh { - let py = gy + row as i32; - let mut run = Run::new(s, py, false); - for col in 0..gw { - let idx = row * gw + col; - let byte = self.data[start + (idx >> 1)]; - let lvl = if (idx & 1) == 0 { byte >> 4 } else { byte & 0x0F } as i32; - if lvl == 0 { continue; } - let px = gx + col as i32; - let c = if lvl == 15 { fg565 } else { under(px, py).mix(fg, lvl * ONE / 15).rgb565() }; - run.put(px, 1, c); - } - } - } - cx += g.adv as i32; - } - } - - pub fn centre_over(&self, s: &mut impl Surface, cx: i32, y: i32, text: &str, fg: Rgb, under: &impl Fn(i32, i32) -> Rgb) { - let w = self.width(text); - self.draw_over(s, cx - w / 2, y, text, fg, under); - } -} - -static FONT_SM_DATA: [u8; 2052] = [ - 0x00, 0x7D, 0xED, 0x80, 0x00, 0x8F, 0xD9, 0xCF, 0x90, 0x0F, 0xE1, 0x00, 0xDF, 0x12, 0xFB, 0x00, - 0x0A, 0xF3, 0x2F, 0xB0, 0x00, 0xAF, 0x32, 0xFB, 0x00, 0x0A, 0xF3, 0x2F, 0xB0, 0x00, 0xAF, 0x32, - 0xFB, 0x00, 0x0A, 0xF3, 0x0E, 0xE1, 0x00, 0xDF, 0x10, 0x8F, 0xD9, 0xCF, 0x90, 0x00, 0x7D, 0xED, - 0x80, 0x00, 0x06, 0xDF, 0x84, 0xFE, 0xF8, 0x13, 0x5F, 0x80, 0x05, 0xF8, 0x00, 0x5F, 0x80, 0x05, - 0xF8, 0x00, 0x5F, 0x80, 0x05, 0xF8, 0x00, 0x5F, 0x80, 0x05, 0xF8, 0x00, 0x5F, 0x80, 0x01, 0x9E, - 0xFC, 0x50, 0x00, 0xCF, 0xB9, 0xEF, 0x50, 0x3F, 0xC0, 0x03, 0xFB, 0x02, 0xA6, 0x00, 0x3F, 0xB0, - 0x00, 0x00, 0x0B, 0xF6, 0x00, 0x00, 0x08, 0xFB, 0x00, 0x00, 0x06, 0xFD, 0x10, 0x00, 0x05, 0xFE, - 0x20, 0x00, 0x04, 0xEE, 0x30, 0x00, 0x02, 0xEF, 0xC8, 0x88, 0x80, 0x3F, 0xFF, 0xFF, 0xFF, 0x10, - 0x3F, 0xFF, 0xFF, 0xF8, 0x28, 0x88, 0x9F, 0xF8, 0x00, 0x01, 0xCF, 0xB0, 0x00, 0x1C, 0xFA, 0x00, - 0x00, 0x7F, 0xFD, 0x50, 0x00, 0x06, 0x4D, 0xF3, 0x00, 0x00, 0x05, 0xF9, 0x39, 0x40, 0x03, 0xFA, - 0x4F, 0xB0, 0x07, 0xF8, 0x0C, 0xFB, 0xAF, 0xE2, 0x01, 0x9E, 0xEB, 0x30, 0x00, 0x07, 0xF7, 0x00, - 0x00, 0x01, 0xEE, 0x10, 0x00, 0x00, 0x6F, 0x80, 0x00, 0x00, 0x0D, 0xF1, 0x00, 0x00, 0x05, 0xF9, - 0x04, 0xF9, 0x00, 0xCF, 0x20, 0x4F, 0x90, 0x4F, 0xE9, 0x9B, 0xFD, 0x56, 0xFF, 0xFF, 0xFF, 0xF8, - 0x00, 0x00, 0x04, 0xF9, 0x00, 0x00, 0x00, 0x4F, 0x90, 0x00, 0x00, 0x04, 0xF9, 0x00, 0x2F, 0xFF, - 0xFF, 0xF6, 0x3F, 0xD8, 0x88, 0x83, 0x3F, 0xA0, 0x00, 0x00, 0x3F, 0xA0, 0x00, 0x00, 0x3F, 0xDC, - 0xED, 0x60, 0x3F, 0xFC, 0x9E, 0xF5, 0x18, 0x70, 0x03, 0xFB, 0x01, 0x10, 0x01, 0xFC, 0x1F, 0xD1, - 0x05, 0xFA, 0x09, 0xFC, 0x9E, 0xF4, 0x00, 0x8D, 0xEC, 0x50, 0x01, 0xAE, 0xFC, 0x50, 0x0C, 0xFB, - 0x9E, 0xF4, 0x2F, 0xC0, 0x06, 0xF8, 0x3F, 0xA0, 0x01, 0x31, 0x3F, 0xCB, 0xED, 0x60, 0x3F, 0xFC, - 0x9E, 0xF5, 0x3F, 0xD0, 0x04, 0xFB, 0x3F, 0xB0, 0x01, 0xFC, 0x1F, 0xD0, 0x04, 0xFA, 0x09, 0xFC, - 0x9E, 0xF4, 0x00, 0x8D, 0xFC, 0x50, 0x9F, 0xFF, 0xFF, 0xF8, 0x9F, 0x88, 0x8C, 0xF7, 0x47, 0x00, - 0x0C, 0xF2, 0x00, 0x00, 0x3F, 0xC0, 0x00, 0x00, 0x9F, 0x60, 0x00, 0x00, 0xEE, 0x10, 0x00, 0x05, - 0xF9, 0x00, 0x00, 0x0B, 0xF4, 0x00, 0x00, 0x2F, 0xD0, 0x00, 0x00, 0x8F, 0x70, 0x00, 0x00, 0xDF, - 0x20, 0x00, 0x01, 0x9E, 0xFC, 0x40, 0x0A, 0xFC, 0x9E, 0xF3, 0x1F, 0xD0, 0x05, 0xF8, 0x1F, 0xC0, - 0x05, 0xF8, 0x09, 0xFB, 0x9E, 0xE2, 0x05, 0xFF, 0xFF, 0xC1, 0x1E, 0xE3, 0x19, 0xF8, 0x4F, 0xA0, - 0x02, 0xFB, 0x3F, 0xC0, 0x04, 0xFA, 0x0C, 0xFB, 0x9E, 0xF4, 0x01, 0x9E, 0xFC, 0x50, 0x01, 0xAE, - 0xEB, 0x30, 0x0C, 0xFB, 0xAF, 0xE2, 0x4F, 0xB0, 0x07, 0xF7, 0x6F, 0x70, 0x04, 0xF9, 0x4F, 0xA0, - 0x07, 0xF9, 0x0D, 0xFB, 0xAF, 0xF9, 0x02, 0xBE, 0xD9, 0xF9, 0x03, 0x20, 0x03, 0xF9, 0x2F, 0xC0, - 0x05, 0xF9, 0x0C, 0xFB, 0x9E, 0xF4, 0x01, 0xAE, 0xFC, 0x50, 0x00, 0x02, 0xFF, 0x70, 0x00, 0x00, - 0x07, 0xFF, 0xC0, 0x00, 0x00, 0x0C, 0xFD, 0xF2, 0x00, 0x00, 0x2F, 0xC7, 0xF7, 0x00, 0x00, 0x7F, - 0x72, 0xFC, 0x00, 0x00, 0xCF, 0x30, 0xDF, 0x20, 0x02, 0xFD, 0x00, 0x8F, 0x70, 0x06, 0xFA, 0x22, - 0x5F, 0xC0, 0x0B, 0xFF, 0xFF, 0xFF, 0xF2, 0x1F, 0xE4, 0x44, 0x4A, 0xF7, 0x6F, 0x90, 0x00, 0x03, - 0xFB, 0xCF, 0xFF, 0xFD, 0x70, 0x0C, 0xF8, 0x89, 0xDF, 0x70, 0xCF, 0x00, 0x01, 0xFC, 0x0C, 0xF0, - 0x00, 0x1F, 0xC0, 0xCF, 0x88, 0x9D, 0xF6, 0x0C, 0xFF, 0xFF, 0xFB, 0x10, 0xCF, 0x10, 0x06, 0xFA, - 0x0C, 0xF0, 0x00, 0x0D, 0xF0, 0xCF, 0x00, 0x01, 0xEF, 0x0C, 0xF8, 0x89, 0xDF, 0xA0, 0xCF, 0xFF, - 0xFD, 0x71, 0x00, 0x00, 0x5C, 0xEE, 0xB4, 0x00, 0x6F, 0xE9, 0xAF, 0xF4, 0x0E, 0xE2, 0x00, 0x4F, - 0xB1, 0xFC, 0x00, 0x00, 0xA9, 0x2F, 0xB0, 0x00, 0x00, 0x02, 0xFB, 0x00, 0x00, 0x00, 0x2F, 0xB0, - 0x00, 0x00, 0x01, 0xFC, 0x00, 0x00, 0xA9, 0x0E, 0xE2, 0x00, 0x4F, 0xB0, 0x6F, 0xE9, 0xAF, 0xF4, - 0x00, 0x5C, 0xEE, 0xB4, 0x00, 0xCF, 0xFF, 0xFD, 0x70, 0x0C, 0xF9, 0x89, 0xDF, 0x80, 0xCF, 0x00, - 0x01, 0xEE, 0x0C, 0xF0, 0x00, 0x0C, 0xF1, 0xCF, 0x00, 0x00, 0xCF, 0x1C, 0xF0, 0x00, 0x0C, 0xF1, - 0xCF, 0x00, 0x00, 0xCF, 0x1C, 0xF0, 0x00, 0x0C, 0xF1, 0xCF, 0x00, 0x02, 0xEE, 0x0C, 0xF8, 0x89, - 0xDF, 0x80, 0xCF, 0xFF, 0xFD, 0x70, 0x00, 0xCF, 0xFF, 0xFF, 0xFB, 0xCF, 0x88, 0x88, 0x86, 0xCF, - 0x00, 0x00, 0x00, 0xCF, 0x00, 0x00, 0x00, 0xCF, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xFE, 0x00, 0xCF, - 0x88, 0x88, 0x00, 0xCF, 0x00, 0x00, 0x00, 0xCF, 0x00, 0x00, 0x00, 0xCF, 0x88, 0x88, 0x86, 0xCF, - 0xFF, 0xFF, 0xFB, 0xCF, 0xFF, 0xFF, 0xFB, 0xCF, 0x88, 0x88, 0x86, 0xCF, 0x00, 0x00, 0x00, 0xCF, - 0x00, 0x00, 0x00, 0xCF, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xFE, 0x00, 0xCF, 0x88, 0x88, 0x00, 0xCF, - 0x00, 0x00, 0x00, 0xCF, 0x00, 0x00, 0x00, 0xCF, 0x00, 0x00, 0x00, 0xCF, 0x00, 0x00, 0x00, 0x00, - 0x5C, 0xEE, 0xB4, 0x00, 0x6F, 0xE9, 0xAF, 0xF4, 0x0E, 0xE2, 0x00, 0x4F, 0xB1, 0xFC, 0x00, 0x00, - 0x98, 0x2F, 0xB0, 0x00, 0x00, 0x02, 0xFB, 0x03, 0xFF, 0xFD, 0x2F, 0xB0, 0x18, 0x8F, 0xD1, 0xFC, - 0x00, 0x00, 0xED, 0x0E, 0xF2, 0x00, 0x3F, 0xA0, 0x6F, 0xE9, 0x9E, 0xF3, 0x00, 0x5C, 0xEE, 0xB3, - 0x00, 0xCF, 0x00, 0x00, 0xBF, 0x2C, 0xF0, 0x00, 0x0B, 0xF2, 0xCF, 0x00, 0x00, 0xBF, 0x2C, 0xF0, - 0x00, 0x0B, 0xF2, 0xCF, 0x00, 0x00, 0xBF, 0x2C, 0xFF, 0xFF, 0xFF, 0xF2, 0xCF, 0x88, 0x88, 0xDF, - 0x2C, 0xF0, 0x00, 0x0B, 0xF2, 0xCF, 0x00, 0x00, 0xBF, 0x2C, 0xF0, 0x00, 0x0B, 0xF2, 0xCF, 0x00, - 0x00, 0xBF, 0x20, 0xCF, 0x0C, 0xF0, 0xCF, 0x0C, 0xF0, 0xCF, 0x0C, 0xF0, 0xCF, 0x0C, 0xF0, 0xCF, - 0x0C, 0xF0, 0xCF, 0x00, 0x00, 0x00, 0x00, 0xBF, 0x20, 0x00, 0x00, 0x0B, 0xF2, 0x00, 0x00, 0x00, - 0xBF, 0x20, 0x00, 0x00, 0x0B, 0xF2, 0x00, 0x00, 0x00, 0xBF, 0x20, 0x00, 0x00, 0x0B, 0xF2, 0x6A, - 0x20, 0x00, 0xBF, 0x29, 0xF3, 0x00, 0x0B, 0xF2, 0x7F, 0x70, 0x01, 0xEE, 0x02, 0xEF, 0xA9, 0xDF, - 0x80, 0x02, 0xAE, 0xFC, 0x60, 0x00, 0xCF, 0x00, 0x02, 0xEE, 0x2C, 0xF0, 0x01, 0xDF, 0x40, 0xCF, - 0x00, 0xBF, 0x60, 0x0C, 0xF0, 0x9F, 0x90, 0x00, 0xCF, 0x8F, 0xC0, 0x00, 0x0C, 0xFF, 0xFE, 0x20, - 0x00, 0xCF, 0xC5, 0xFB, 0x00, 0x0C, 0xF2, 0x0A, 0xF6, 0x00, 0xCF, 0x00, 0x1E, 0xE2, 0x0C, 0xF0, - 0x00, 0x6F, 0xB0, 0xCF, 0x00, 0x00, 0xBF, 0x50, 0xCF, 0x00, 0x00, 0x00, 0xCF, 0x00, 0x00, 0x00, - 0xCF, 0x00, 0x00, 0x00, 0xCF, 0x00, 0x00, 0x00, 0xCF, 0x00, 0x00, 0x00, 0xCF, 0x00, 0x00, 0x00, - 0xCF, 0x00, 0x00, 0x00, 0xCF, 0x00, 0x00, 0x00, 0xCF, 0x00, 0x00, 0x00, 0xCF, 0x88, 0x88, 0x85, - 0xCF, 0xFF, 0xFF, 0xFA, 0xCF, 0x50, 0x00, 0x0C, 0xF4, 0xCF, 0xE1, 0x00, 0x8F, 0xF4, 0xCF, 0xFA, - 0x03, 0xFF, 0xF4, 0xCF, 0xCF, 0x5D, 0xFC, 0xF4, 0xCF, 0x2E, 0xFF, 0x89, 0xF4, 0xCF, 0x06, 0xFC, - 0x09, 0xF4, 0xCF, 0x00, 0x62, 0x09, 0xF4, 0xCF, 0x00, 0x00, 0x09, 0xF4, 0xCF, 0x00, 0x00, 0x09, - 0xF4, 0xCF, 0x00, 0x00, 0x09, 0xF4, 0xCF, 0x00, 0x00, 0x09, 0xF4, 0xCF, 0x40, 0x00, 0x5F, 0x8C, - 0xFD, 0x00, 0x05, 0xF8, 0xCF, 0xF7, 0x00, 0x5F, 0x8C, 0xFD, 0xE2, 0x05, 0xF8, 0xCF, 0x4F, 0xB0, - 0x5F, 0x8C, 0xF0, 0xAF, 0x55, 0xF8, 0xCF, 0x01, 0xED, 0x5F, 0x8C, 0xF0, 0x06, 0xFD, 0xF8, 0xCF, - 0x00, 0x0C, 0xFF, 0x8C, 0xF0, 0x00, 0x3F, 0xF8, 0xCF, 0x00, 0x00, 0x8F, 0x80, 0x00, 0x4B, 0xEE, - 0xB4, 0x00, 0x05, 0xFE, 0x9A, 0xEF, 0x40, 0x0D, 0xF2, 0x00, 0x3F, 0xC0, 0x1F, 0xC0, 0x00, 0x0D, - 0xF0, 0x2F, 0xB0, 0x00, 0x0C, 0xF1, 0x2F, 0xB0, 0x00, 0x0C, 0xF1, 0x2F, 0xB0, 0x00, 0x0C, 0xF1, - 0x1F, 0xC0, 0x00, 0x0D, 0xF0, 0x0D, 0xF2, 0x00, 0x3F, 0xC0, 0x05, 0xFE, 0x9A, 0xEF, 0x40, 0x00, - 0x5B, 0xEE, 0xB4, 0x00, 0xEF, 0xFF, 0xFD, 0x80, 0x0E, 0xF8, 0x89, 0xDF, 0x80, 0xEE, 0x00, 0x01, - 0xEE, 0x0E, 0xE0, 0x00, 0x0D, 0xF0, 0xEE, 0x00, 0x06, 0xFC, 0x0E, 0xFF, 0xFF, 0xFE, 0x40, 0xEF, - 0x88, 0x86, 0x20, 0x0E, 0xE0, 0x00, 0x00, 0x00, 0xEE, 0x00, 0x00, 0x00, 0x0E, 0xE0, 0x00, 0x00, - 0x00, 0xEE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6C, 0xFE, 0x91, 0x00, 0x7F, 0xD9, 0xBF, 0xC1, 0x1E, - 0xE1, 0x00, 0x9F, 0x63, 0xFA, 0x00, 0x04, 0xF9, 0x4F, 0x90, 0x00, 0x3F, 0xA4, 0xF9, 0x00, 0x03, - 0xFA, 0x4F, 0x90, 0x00, 0x3F, 0xA4, 0xF9, 0x00, 0x03, 0xFA, 0x2F, 0xB0, 0x00, 0x5F, 0x80, 0xCF, - 0x61, 0x3D, 0xF3, 0x03, 0xDF, 0xFF, 0xF7, 0x00, 0x01, 0x7F, 0xC2, 0x00, 0x00, 0x03, 0xF9, 0x00, - 0x00, 0xCF, 0xFF, 0xFE, 0x80, 0x0C, 0xF8, 0x89, 0xDF, 0x80, 0xCF, 0x00, 0x01, 0xEE, 0x0C, 0xF0, - 0x00, 0x0D, 0xF1, 0xCF, 0x00, 0x05, 0xFD, 0x0C, 0xFF, 0xFF, 0xFF, 0x40, 0xCF, 0x88, 0xEF, 0x20, - 0x0C, 0xF0, 0x07, 0xF6, 0x00, 0xCF, 0x00, 0x1E, 0xD1, 0x0C, 0xF0, 0x00, 0x7F, 0x70, 0xCF, 0x00, - 0x01, 0xDE, 0x10, 0x01, 0x8D, 0xFE, 0xA2, 0x00, 0xBF, 0xB9, 0xBF, 0xE2, 0x2F, 0xC0, 0x00, 0x7F, - 0x81, 0xFD, 0x10, 0x01, 0x96, 0x08, 0xFD, 0x72, 0x00, 0x00, 0x05, 0xCF, 0xFB, 0x30, 0x00, 0x00, - 0x39, 0xFF, 0x43, 0xA5, 0x00, 0x05, 0xFA, 0x4F, 0xB0, 0x00, 0x4F, 0xA0, 0xCF, 0xD9, 0x9E, 0xF4, - 0x01, 0x8D, 0xFE, 0xB4, 0x00, 0x7F, 0xFF, 0xFF, 0xFF, 0xB4, 0x88, 0xBF, 0xC8, 0x86, 0x00, 0x05, - 0xF8, 0x00, 0x00, 0x00, 0x5F, 0x80, 0x00, 0x00, 0x05, 0xF8, 0x00, 0x00, 0x00, 0x5F, 0x80, 0x00, - 0x00, 0x05, 0xF8, 0x00, 0x00, 0x00, 0x5F, 0x80, 0x00, 0x00, 0x05, 0xF8, 0x00, 0x00, 0x00, 0x5F, - 0x80, 0x00, 0x00, 0x05, 0xF7, 0x00, 0x00, 0xEE, 0x00, 0x00, 0xBF, 0x1E, 0xE0, 0x00, 0x0B, 0xF2, - 0xEE, 0x00, 0x00, 0xBF, 0x2E, 0xE0, 0x00, 0x0B, 0xF2, 0xEE, 0x00, 0x00, 0xBF, 0x2E, 0xE0, 0x00, - 0x0B, 0xF2, 0xEE, 0x00, 0x00, 0xBF, 0x2E, 0xE0, 0x00, 0x0C, 0xF1, 0xBF, 0x40, 0x02, 0xEE, 0x04, - 0xFF, 0xA9, 0xEF, 0x60, 0x04, 0xBE, 0xEC, 0x50, 0x00, 0x6F, 0x80, 0x00, 0x0B, 0xF3, 0x2F, 0xD0, - 0x00, 0x1F, 0xD0, 0x0C, 0xF2, 0x00, 0x5F, 0x80, 0x07, 0xF7, 0x00, 0xAF, 0x30, 0x02, 0xFB, 0x00, - 0xEE, 0x00, 0x00, 0xDF, 0x13, 0xF9, 0x00, 0x00, 0x8F, 0x58, 0xF4, 0x00, 0x00, 0x3F, 0x9C, 0xE0, - 0x00, 0x00, 0x0D, 0xEF, 0x90, 0x00, 0x00, 0x09, 0xFF, 0x50, 0x00, 0x00, 0x04, 0xFE, 0x00, 0x00, - 0x7F, 0x70, 0x01, 0xFF, 0x10, 0x05, 0xF8, 0x3F, 0xB0, 0x04, 0xFF, 0x50, 0x09, 0xF4, 0x0E, 0xE0, - 0x08, 0xFF, 0x90, 0x0D, 0xF1, 0x0A, 0xF3, 0x0C, 0xDD, 0xD0, 0x1F, 0xC0, 0x06, 0xF7, 0x1F, 0xA9, - 0xF2, 0x5F, 0x80, 0x02, 0xFB, 0x4F, 0x66, 0xF6, 0x9F, 0x40, 0x00, 0xDE, 0x8F, 0x32, 0xFA, 0xDE, - 0x00, 0x00, 0x9F, 0xEE, 0x00, 0xDE, 0xFB, 0x00, 0x00, 0x5F, 0xFB, 0x00, 0xAF, 0xF7, 0x00, 0x00, - 0x1F, 0xF7, 0x00, 0x6F, 0xF3, 0x00, 0x00, 0x0B, 0xF4, 0x00, 0x2F, 0xE0, 0x00, 0x4F, 0xB0, 0x00, - 0x0D, 0xF2, 0x0A, 0xF5, 0x00, 0x7F, 0x80, 0x01, 0xED, 0x12, 0xED, 0x00, 0x00, 0x6F, 0x8A, 0xF4, - 0x00, 0x00, 0x0C, 0xFF, 0xA0, 0x00, 0x00, 0x05, 0xFF, 0x30, 0x00, 0x00, 0x0C, 0xFF, 0xA0, 0x00, - 0x00, 0x6F, 0x8A, 0xF4, 0x00, 0x01, 0xED, 0x12, 0xED, 0x00, 0x0A, 0xF5, 0x00, 0x7F, 0x70, 0x4F, - 0xB0, 0x00, 0x0D, 0xF2, 0x4F, 0xA0, 0x00, 0x2E, 0xD0, 0x0C, 0xF3, 0x00, 0x9F, 0x60, 0x04, 0xFA, - 0x02, 0xFD, 0x00, 0x00, 0xBF, 0x39, 0xF5, 0x00, 0x00, 0x3F, 0xCF, 0xC0, 0x00, 0x00, 0x0A, 0xFF, - 0x40, 0x00, 0x00, 0x03, 0xFC, 0x00, 0x00, 0x00, 0x02, 0xFB, 0x00, 0x00, 0x00, 0x02, 0xFB, 0x00, - 0x00, 0x00, 0x02, 0xFB, 0x00, 0x00, 0x00, 0x02, 0xFB, 0x00, 0x00, 0x6F, 0xFF, 0xFF, 0xFF, 0x23, - 0x88, 0x88, 0x9F, 0xF2, 0x00, 0x00, 0x08, 0xF8, 0x00, 0x00, 0x04, 0xFC, 0x00, 0x00, 0x01, 0xDF, - 0x30, 0x00, 0x00, 0xAF, 0x70, 0x00, 0x00, 0x6F, 0xB0, 0x00, 0x00, 0x2E, 0xE1, 0x00, 0x00, 0x0C, - 0xF5, 0x00, 0x00, 0x05, 0xFE, 0x88, 0x88, 0x81, 0x6F, 0xFF, 0xFF, 0xFF, 0x20, 0x11, 0x0D, 0xF2, - 0xBD, 0x10, 0x01, 0x03, 0xFC, 0x2E, 0xA0, 0x00, 0x00, 0x00, 0x10, 0x3F, 0xC2, 0xEA, 0x3F, 0x93, - 0xF9, 0x2F, 0x82, 0xF8, 0x2F, 0x81, 0xF7, 0x1F, 0x70, 0x00, 0x02, 0x06, 0xF9, 0x4E, 0x70, 0x00, - 0x0D, 0xB0, 0x00, 0x00, 0x0D, 0xB0, 0x00, 0x00, 0x0D, 0xB0, 0x00, 0x7F, 0xFF, 0xFF, 0xF5, 0x48, - 0x8E, 0xD8, 0x83, 0x00, 0x0D, 0xB0, 0x00, 0x00, 0x0D, 0xB0, 0x00, 0x48, 0x88, 0x88, 0x7F, 0xFF, - 0xFE, 0x00, 0x00, 0xBF, 0x10, 0x00, 0x2F, 0xA0, 0x00, 0x08, 0xF5, 0x00, 0x00, 0xDE, 0x00, 0x00, - 0x4F, 0x90, 0x00, 0x09, 0xF3, 0x00, 0x01, 0xED, 0x00, 0x00, 0x5F, 0x70, 0x00, 0x0B, 0xF2, 0x00, - 0x02, 0xFB, 0x00, 0x00, 0x7F, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x16, 0xD5, - 0x00, 0x18, 0xEF, 0xD3, 0x29, 0xFF, 0xB5, 0x00, 0x7F, 0xD3, 0x00, 0x00, 0x4D, 0xFD, 0x71, 0x00, - 0x00, 0x5C, 0xFF, 0xA2, 0x00, 0x00, 0x4B, 0xF5, 0x00, 0x00, 0x00, 0x22, 0x10, 0x00, 0x00, 0x00, - 0x7C, 0x50, 0x00, 0x00, 0x5E, 0xFD, 0x71, 0x00, 0x01, 0x6C, 0xFE, 0x81, 0x00, 0x00, 0x4E, 0xF5, - 0x00, 0x28, 0xEF, 0xC2, 0x3B, 0xFF, 0xB4, 0x00, 0x7F, 0x93, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00, - 0x00, 0x0C, 0xF1, 0x0D, 0xF0, 0x00, 0x0F, 0xD0, 0x1F, 0xC0, 0x08, 0xFF, 0xFF, 0xFF, 0xFE, 0x04, - 0xBF, 0xC8, 0xBF, 0xB7, 0x00, 0x7F, 0x60, 0x8F, 0x50, 0x00, 0x9F, 0x40, 0xAF, 0x30, 0x1F, 0xFF, - 0xFF, 0xFF, 0xF5, 0x18, 0xFE, 0x88, 0xFE, 0x83, 0x01, 0xFC, 0x02, 0xFB, 0x00, 0x03, 0xF9, 0x04, - 0xF8, 0x00, 0x0A, 0xEC, 0x20, 0x03, 0xF2, 0x00, 0x9E, 0x9C, 0xC0, 0x0B, 0x90, 0x00, 0xC6, 0x02, - 0xF1, 0x5E, 0x10, 0x00, 0x9E, 0x9C, 0xD0, 0xD7, 0x00, 0x00, 0x1A, 0xFC, 0x27, 0xD0, 0x00, 0x00, - 0x00, 0x00, 0x1E, 0x50, 0x00, 0x00, 0x00, 0x00, 0x9B, 0x08, 0xED, 0x30, 0x00, 0x03, 0xF3, 0x6E, - 0x9B, 0xE1, 0x00, 0x0B, 0x90, 0xA8, 0x00, 0xE3, 0x00, 0x5E, 0x20, 0x6E, 0x9B, 0xE1, 0x00, 0xD7, - 0x00, 0x08, 0xED, 0x30, -]; - -static FONT_SM_GLYPHS: [Glyph; 47] = [ - Glyph { ch: 32, x_off: 0, y_off: 0, w: 0, h: 0, adv: 3, offset: 0 }, - Glyph { ch: 48, x_off: 0, y_off: 0, w: 9, h: 11, adv: 9, offset: 0 }, - Glyph { ch: 49, x_off: 0, y_off: 0, w: 5, h: 11, adv: 6, offset: 50 }, - Glyph { ch: 50, x_off: 0, y_off: 0, w: 9, h: 11, adv: 9, offset: 78 }, - Glyph { ch: 51, x_off: 0, y_off: 0, w: 8, h: 11, adv: 9, offset: 128 }, - Glyph { ch: 52, x_off: 0, y_off: 0, w: 9, h: 11, adv: 9, offset: 172 }, - Glyph { ch: 53, x_off: 0, y_off: 0, w: 8, h: 11, adv: 8, offset: 222 }, - Glyph { ch: 54, x_off: 0, y_off: 0, w: 8, h: 11, adv: 8, offset: 266 }, - Glyph { ch: 55, x_off: 0, y_off: 0, w: 8, h: 11, adv: 8, offset: 310 }, - Glyph { ch: 56, x_off: 0, y_off: 0, w: 8, h: 11, adv: 9, offset: 354 }, - Glyph { ch: 57, x_off: 0, y_off: 0, w: 8, h: 11, adv: 8, offset: 398 }, - Glyph { ch: 65, x_off: 0, y_off: 0, w: 10, h: 11, adv: 10, offset: 442 }, - Glyph { ch: 66, x_off: 1, y_off: 0, w: 9, h: 11, adv: 10, offset: 497 }, - Glyph { ch: 67, x_off: 0, y_off: 0, w: 9, h: 11, adv: 10, offset: 547 }, - Glyph { ch: 68, x_off: 1, y_off: 0, w: 9, h: 11, adv: 10, offset: 597 }, - Glyph { ch: 69, x_off: 1, y_off: 0, w: 8, h: 11, adv: 9, offset: 647 }, - Glyph { ch: 70, x_off: 1, y_off: 0, w: 8, h: 11, adv: 9, offset: 691 }, - Glyph { ch: 71, x_off: 0, y_off: 0, w: 9, h: 11, adv: 10, offset: 735 }, - Glyph { ch: 72, x_off: 1, y_off: 0, w: 9, h: 11, adv: 10, offset: 785 }, - Glyph { ch: 73, x_off: 1, y_off: 0, w: 3, h: 11, adv: 4, offset: 835 }, - Glyph { ch: 74, x_off: 0, y_off: 0, w: 9, h: 11, adv: 9, offset: 852 }, - Glyph { ch: 75, x_off: 1, y_off: 0, w: 9, h: 11, adv: 10, offset: 902 }, - Glyph { ch: 76, x_off: 1, y_off: 0, w: 8, h: 11, adv: 9, offset: 952 }, - Glyph { ch: 77, x_off: 1, y_off: 0, w: 10, h: 11, adv: 11, offset: 996 }, - Glyph { ch: 78, x_off: 1, y_off: 0, w: 9, h: 11, adv: 11, offset: 1051 }, - Glyph { ch: 79, x_off: 0, y_off: 0, w: 10, h: 11, adv: 10, offset: 1101 }, - Glyph { ch: 80, x_off: 1, y_off: 0, w: 9, h: 11, adv: 10, offset: 1156 }, - Glyph { ch: 81, x_off: 0, y_off: 0, w: 9, h: 13, adv: 9, offset: 1206 }, - Glyph { ch: 82, x_off: 1, y_off: 0, w: 9, h: 11, adv: 10, offset: 1265 }, - Glyph { ch: 83, x_off: 0, y_off: 0, w: 9, h: 11, adv: 9, offset: 1315 }, - Glyph { ch: 84, x_off: 0, y_off: 0, w: 9, h: 11, adv: 9, offset: 1365 }, - Glyph { ch: 85, x_off: 1, y_off: 0, w: 9, h: 11, adv: 10, offset: 1415 }, - Glyph { ch: 86, x_off: 0, y_off: 0, w: 10, h: 11, adv: 10, offset: 1465 }, - Glyph { ch: 87, x_off: 0, y_off: 0, w: 14, h: 11, adv: 14, offset: 1520 }, - Glyph { ch: 88, x_off: 0, y_off: 0, w: 10, h: 11, adv: 10, offset: 1597 }, - Glyph { ch: 89, x_off: 0, y_off: 0, w: 10, h: 11, adv: 10, offset: 1652 }, - Glyph { ch: 90, x_off: 0, y_off: 0, w: 9, h: 11, adv: 9, offset: 1707 }, - Glyph { ch: 46, x_off: 1, y_off: 8, w: 3, h: 3, adv: 4, offset: 1757 }, - Glyph { ch: 58, x_off: 1, y_off: 3, w: 3, h: 8, adv: 6, offset: 1762 }, - Glyph { ch: 33, x_off: 1, y_off: 0, w: 3, h: 11, adv: 5, offset: 1774 }, - Glyph { ch: 43, x_off: 0, y_off: 3, w: 8, h: 7, adv: 8, offset: 1791 }, - Glyph { ch: 45, x_off: 0, y_off: 5, w: 6, h: 2, adv: 6, offset: 1819 }, - Glyph { ch: 47, x_off: 0, y_off: 0, w: 7, h: 11, adv: 7, offset: 1825 }, - Glyph { ch: 60, x_off: 0, y_off: 2, w: 8, h: 9, adv: 8, offset: 1864 }, - Glyph { ch: 62, x_off: 0, y_off: 2, w: 8, h: 9, adv: 8, offset: 1900 }, - Glyph { ch: 35, x_off: 0, y_off: 1, w: 10, h: 10, adv: 11, offset: 1936 }, - Glyph { ch: 37, x_off: 1, y_off: 0, w: 12, h: 11, adv: 13, offset: 1986 }, -]; - -pub static FONT_SM: Font = Font { glyphs: &FONT_SM_GLYPHS, data: &FONT_SM_DATA }; - -static FONT_MD_DATA: [u8; 3974] = [ - 0x00, 0x5B, 0xEF, 0xD8, 0x10, 0x00, 0x9F, 0xFF, 0xFF, 0xFE, 0x20, 0x4F, 0xFD, 0x75, 0xAF, 0xFB, - 0x0A, 0xFF, 0x20, 0x00, 0x9F, 0xF2, 0xCF, 0xC0, 0x00, 0x05, 0xFF, 0x4C, 0xFC, 0x00, 0x00, 0x4F, - 0xF4, 0xCF, 0xC0, 0x00, 0x04, 0xFF, 0x4C, 0xFC, 0x00, 0x00, 0x4F, 0xF4, 0xCF, 0xC0, 0x00, 0x04, - 0xFF, 0x4C, 0xFC, 0x00, 0x00, 0x4F, 0xF4, 0xCF, 0xC0, 0x00, 0x04, 0xFF, 0x4C, 0xFC, 0x00, 0x00, - 0x5F, 0xF4, 0x9F, 0xF2, 0x00, 0x09, 0xFF, 0x24, 0xFF, 0xD7, 0x5A, 0xFF, 0xB0, 0x09, 0xFF, 0xFF, - 0xFF, 0xE2, 0x00, 0x05, 0xBE, 0xFD, 0x91, 0x00, 0x00, 0x6D, 0xFF, 0x30, 0xDF, 0xFF, 0xF3, 0x0F, - 0xFD, 0xFF, 0x30, 0x51, 0x5F, 0xF3, 0x00, 0x05, 0xFF, 0x30, 0x00, 0x5F, 0xF3, 0x00, 0x05, 0xFF, - 0x30, 0x00, 0x5F, 0xF3, 0x00, 0x05, 0xFF, 0x30, 0x00, 0x5F, 0xF3, 0x00, 0x05, 0xFF, 0x30, 0x00, - 0x5F, 0xF3, 0x00, 0x05, 0xFF, 0x30, 0x00, 0x5F, 0xF3, 0x00, 0x05, 0xFF, 0x30, 0x00, 0x5F, 0xF3, - 0x01, 0x7C, 0xEE, 0xB5, 0x00, 0x01, 0xCF, 0xFF, 0xFF, 0xF9, 0x00, 0x9F, 0xFB, 0x66, 0xDF, 0xF4, - 0x0D, 0xFD, 0x00, 0x02, 0xFF, 0x90, 0xFF, 0x90, 0x00, 0x0D, 0xFA, 0x04, 0x42, 0x00, 0x02, 0xFF, - 0x80, 0x00, 0x00, 0x00, 0xBF, 0xF3, 0x00, 0x00, 0x00, 0x7F, 0xF9, 0x00, 0x00, 0x00, 0x4F, 0xFD, - 0x10, 0x00, 0x00, 0x2E, 0xFE, 0x30, 0x00, 0x00, 0x1D, 0xFF, 0x50, 0x00, 0x00, 0x0B, 0xFF, 0x60, - 0x00, 0x00, 0x09, 0xFF, 0x80, 0x00, 0x00, 0x08, 0xFF, 0xD5, 0x55, 0x55, 0x50, 0xEF, 0xFF, 0xFF, - 0xFF, 0xFF, 0x1D, 0xFF, 0xFF, 0xFF, 0xFF, 0xF1, 0x0D, 0xFF, 0xFF, 0xFF, 0xFF, 0x60, 0xEF, 0xFF, - 0xFF, 0xFF, 0xF6, 0x04, 0x55, 0x55, 0x8F, 0xFF, 0x40, 0x00, 0x00, 0x3E, 0xFF, 0x60, 0x00, 0x00, - 0x3E, 0xFF, 0x70, 0x00, 0x00, 0x3E, 0xFF, 0x70, 0x00, 0x00, 0x09, 0xFF, 0xFE, 0x80, 0x00, 0x00, - 0x1D, 0x9A, 0xFF, 0xA0, 0x00, 0x00, 0x00, 0x08, 0xFF, 0x20, 0x00, 0x00, 0x00, 0x2F, 0xF6, 0x04, - 0x41, 0x00, 0x01, 0xFF, 0x81, 0xFF, 0x80, 0x00, 0x1F, 0xF8, 0x0E, 0xFC, 0x00, 0x06, 0xFF, 0x50, - 0x7F, 0xFA, 0x57, 0xEF, 0xD1, 0x01, 0xBF, 0xFF, 0xFF, 0xF4, 0x00, 0x01, 0x7C, 0xEE, 0xA3, 0x00, - 0x00, 0x00, 0x1E, 0xF9, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xF3, 0x00, 0x00, 0x00, 0x00, 0xEF, 0xC0, - 0x00, 0x00, 0x00, 0x05, 0xFF, 0x50, 0x00, 0x00, 0x00, 0x0C, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x3F, - 0xF8, 0x00, 0x00, 0x00, 0x00, 0xAF, 0xF1, 0x01, 0xFF, 0x60, 0x01, 0xFF, 0xA0, 0x02, 0xFF, 0x70, - 0x07, 0xFF, 0x30, 0x02, 0xFF, 0x70, 0x0E, 0xFE, 0x66, 0x67, 0xFF, 0xA4, 0x2F, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFB, 0x2F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFB, 0x00, 0x00, 0x00, 0x02, 0xFF, 0x70, 0x00, 0x00, - 0x00, 0x02, 0xFF, 0x70, 0x00, 0x00, 0x00, 0x02, 0xFF, 0x70, 0x00, 0x00, 0x00, 0x01, 0xFF, 0x70, - 0xDF, 0xFF, 0xFF, 0xFF, 0xF3, 0xDF, 0xFF, 0xFF, 0xFF, 0xF4, 0xDF, 0xC5, 0x55, 0x55, 0x51, 0xDF, - 0xA0, 0x00, 0x00, 0x00, 0xDF, 0xA0, 0x00, 0x00, 0x00, 0xDF, 0xA0, 0x34, 0x20, 0x00, 0xDF, 0xDD, - 0xFF, 0xFB, 0x20, 0xDF, 0xFF, 0xFF, 0xFF, 0xD0, 0xDF, 0xF7, 0x11, 0x9F, 0xF6, 0x67, 0x60, 0x00, - 0x1F, 0xFA, 0x00, 0x00, 0x00, 0x0D, 0xFC, 0x78, 0x60, 0x00, 0x0E, 0xFB, 0xAF, 0xF1, 0x00, 0x3F, - 0xF9, 0x4F, 0xFC, 0x66, 0xEF, 0xF3, 0x09, 0xFF, 0xFF, 0xFF, 0x70, 0x00, 0x5C, 0xEE, 0xB4, 0x00, - 0x01, 0x8D, 0xEE, 0xB5, 0x00, 0x1D, 0xFF, 0xFF, 0xFF, 0x80, 0x8F, 0xFB, 0x67, 0xEF, 0xF2, 0xCF, - 0xD0, 0x00, 0x5F, 0xF6, 0xDF, 0xA0, 0x00, 0x18, 0x83, 0xDF, 0xA0, 0x24, 0x20, 0x00, 0xDF, 0xCC, - 0xFF, 0xFB, 0x20, 0xDF, 0xFF, 0xFF, 0xFF, 0xD1, 0xDF, 0xF8, 0x11, 0xAF, 0xF6, 0xDF, 0xD0, 0x00, - 0x1E, 0xFA, 0xDF, 0xB0, 0x00, 0x0C, 0xFB, 0xCF, 0xB0, 0x00, 0x0D, 0xFB, 0xAF, 0xE1, 0x00, 0x3F, - 0xF8, 0x4F, 0xFC, 0x66, 0xDF, 0xF3, 0x09, 0xFF, 0xFF, 0xFF, 0x80, 0x00, 0x6C, 0xEE, 0xB5, 0x00, - 0x6F, 0xFF, 0xFF, 0xFF, 0xFF, 0x56, 0xFF, 0xFF, 0xFF, 0xFF, 0xF5, 0x6F, 0xC5, 0x55, 0x5A, 0xFF, - 0x44, 0xB7, 0x00, 0x00, 0xCF, 0xE0, 0x00, 0x00, 0x00, 0x2F, 0xF8, 0x00, 0x00, 0x00, 0x08, 0xFF, - 0x30, 0x00, 0x00, 0x00, 0xDF, 0xC0, 0x00, 0x00, 0x00, 0x4F, 0xF7, 0x00, 0x00, 0x00, 0x09, 0xFF, - 0x20, 0x00, 0x00, 0x01, 0xEF, 0xB0, 0x00, 0x00, 0x00, 0x5F, 0xF6, 0x00, 0x00, 0x00, 0x0B, 0xFE, - 0x10, 0x00, 0x00, 0x01, 0xFF, 0xA0, 0x00, 0x00, 0x00, 0x7F, 0xF4, 0x00, 0x00, 0x00, 0x0C, 0xFE, - 0x00, 0x00, 0x00, 0x02, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x07, 0xCE, 0xEB, 0x50, 0x00, 0x0B, 0xFF, - 0xFF, 0xFF, 0x70, 0x06, 0xFF, 0xC6, 0x7E, 0xFF, 0x20, 0xBF, 0xD0, 0x00, 0x3F, 0xF6, 0x0B, 0xFC, - 0x00, 0x01, 0xFF, 0x70, 0x8F, 0xF7, 0x12, 0xAF, 0xF3, 0x01, 0xDF, 0xFF, 0xFF, 0xF8, 0x00, 0x09, - 0xFF, 0xFF, 0xFF, 0x40, 0x06, 0xFF, 0xC6, 0x6D, 0xFE, 0x20, 0xCF, 0xD1, 0x00, 0x3F, 0xF7, 0x0F, - 0xFA, 0x00, 0x00, 0xEF, 0xA0, 0xFF, 0xA0, 0x00, 0x0E, 0xFA, 0x0C, 0xFD, 0x10, 0x03, 0xFF, 0x80, - 0x7F, 0xFC, 0x67, 0xEF, 0xF3, 0x00, 0xCF, 0xFF, 0xFF, 0xF7, 0x00, 0x00, 0x7C, 0xEE, 0xB5, 0x00, - 0x00, 0x18, 0xDF, 0xDA, 0x30, 0x00, 0x1D, 0xFF, 0xFF, 0xFE, 0x40, 0x09, 0xFF, 0xA5, 0x7E, 0xFD, - 0x00, 0xEF, 0xB0, 0x00, 0x6F, 0xF4, 0x2F, 0xF6, 0x00, 0x02, 0xFF, 0x72, 0xFF, 0x60, 0x00, 0x2F, - 0xF7, 0x1F, 0xFB, 0x00, 0x06, 0xFF, 0x80, 0xAF, 0xFA, 0x57, 0xEF, 0xF8, 0x02, 0xEF, 0xFF, 0xFF, - 0xFF, 0x80, 0x02, 0xAE, 0xEB, 0x4F, 0xF8, 0x00, 0x00, 0x00, 0x01, 0xFF, 0x80, 0x9C, 0x80, 0x00, - 0x1F, 0xF7, 0x0B, 0xFE, 0x10, 0x05, 0xFF, 0x60, 0x7F, 0xFB, 0x67, 0xEF, 0xF3, 0x01, 0xCF, 0xFF, - 0xFF, 0xF8, 0x00, 0x01, 0x8D, 0xFE, 0xB5, 0x00, 0x00, 0x00, 0x09, 0xFF, 0xD0, 0x00, 0x00, 0x00, - 0x00, 0x0E, 0xFF, 0xF3, 0x00, 0x00, 0x00, 0x00, 0x4F, 0xFF, 0xF7, 0x00, 0x00, 0x00, 0x00, 0x8F, - 0xFD, 0xFC, 0x00, 0x00, 0x00, 0x00, 0xDF, 0xB8, 0xFF, 0x20, 0x00, 0x00, 0x03, 0xFF, 0x63, 0xFF, - 0x60, 0x00, 0x00, 0x07, 0xFF, 0x20, 0xDF, 0xB0, 0x00, 0x00, 0x0C, 0xFC, 0x00, 0x9F, 0xF1, 0x00, - 0x00, 0x2F, 0xF8, 0x00, 0x4F, 0xF5, 0x00, 0x00, 0x6F, 0xF3, 0x00, 0x0E, 0xFA, 0x00, 0x00, 0xBF, - 0xE0, 0x00, 0x0A, 0xFE, 0x00, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x40, 0x05, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0x90, 0x0A, 0xFF, 0x22, 0x22, 0x22, 0xCF, 0xD0, 0x0E, 0xFB, 0x00, 0x00, 0x00, 0x7F, - 0xF3, 0x3F, 0xF7, 0x00, 0x00, 0x00, 0x3F, 0xF7, 0x6F, 0xFF, 0xFF, 0xFD, 0xA3, 0x00, 0x6F, 0xFF, - 0xFF, 0xFF, 0xFF, 0x50, 0x6F, 0xF6, 0x55, 0x59, 0xFF, 0xD0, 0x6F, 0xF2, 0x00, 0x00, 0x8F, 0xF2, - 0x6F, 0xF2, 0x00, 0x00, 0x4F, 0xF3, 0x6F, 0xF2, 0x00, 0x00, 0x8F, 0xF1, 0x6F, 0xF6, 0x55, 0x59, - 0xFF, 0x90, 0x6F, 0xFF, 0xFF, 0xFF, 0xF8, 0x00, 0x6F, 0xFF, 0xFF, 0xFF, 0xFE, 0x40, 0x6F, 0xF2, - 0x00, 0x04, 0xDF, 0xE1, 0x6F, 0xF2, 0x00, 0x00, 0x4F, 0xF5, 0x6F, 0xF2, 0x00, 0x00, 0x2F, 0xF6, - 0x6F, 0xF2, 0x00, 0x00, 0x6F, 0xF5, 0x6F, 0xF6, 0x55, 0x58, 0xFF, 0xF1, 0x6F, 0xFF, 0xFF, 0xFF, - 0xFF, 0x60, 0x6F, 0xFF, 0xFF, 0xFE, 0xA3, 0x00, 0x00, 0x29, 0xDF, 0xEB, 0x60, 0x00, 0x05, 0xEF, - 0xFF, 0xFF, 0xFB, 0x00, 0x2E, 0xFF, 0x95, 0x7C, 0xFF, 0x80, 0x7F, 0xF5, 0x00, 0x00, 0xCF, 0xE1, - 0xAF, 0xE0, 0x00, 0x00, 0x6F, 0xF3, 0xBF, 0xC0, 0x00, 0x00, 0x26, 0x61, 0xCF, 0xC0, 0x00, 0x00, - 0x00, 0x00, 0xCF, 0xC0, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xC0, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xC0, - 0x00, 0x00, 0x00, 0x00, 0xBF, 0xC0, 0x00, 0x00, 0x16, 0x61, 0xAF, 0xE0, 0x00, 0x00, 0x6F, 0xF3, - 0x7F, 0xF5, 0x00, 0x00, 0xCF, 0xE1, 0x2E, 0xFF, 0x95, 0x6C, 0xFF, 0x80, 0x04, 0xEF, 0xFF, 0xFF, - 0xFB, 0x00, 0x00, 0x29, 0xDF, 0xEB, 0x60, 0x00, 0x6F, 0xFF, 0xFF, 0xFD, 0x92, 0x00, 0x6F, 0xFF, - 0xFF, 0xFF, 0xFE, 0x40, 0x6F, 0xF6, 0x55, 0x59, 0xFF, 0xE0, 0x6F, 0xF2, 0x00, 0x00, 0x8F, 0xF5, - 0x6F, 0xF2, 0x00, 0x00, 0x3F, 0xF7, 0x6F, 0xF2, 0x00, 0x00, 0x1F, 0xF7, 0x6F, 0xF2, 0x00, 0x00, - 0x1F, 0xF7, 0x6F, 0xF2, 0x00, 0x00, 0x1F, 0xF7, 0x6F, 0xF2, 0x00, 0x00, 0x1F, 0xF7, 0x6F, 0xF2, - 0x00, 0x00, 0x1F, 0xF7, 0x6F, 0xF2, 0x00, 0x00, 0x1F, 0xF7, 0x6F, 0xF2, 0x00, 0x00, 0x3F, 0xF7, - 0x6F, 0xF2, 0x00, 0x00, 0x8F, 0xF5, 0x6F, 0xF6, 0x55, 0x59, 0xFF, 0xE0, 0x6F, 0xFF, 0xFF, 0xFF, - 0xFE, 0x40, 0x6F, 0xFF, 0xFF, 0xFD, 0x92, 0x00, 0x6F, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0x6F, 0xFF, - 0xFF, 0xFF, 0xFF, 0xF0, 0x6F, 0xF6, 0x55, 0x55, 0x55, 0x40, 0x6F, 0xF2, 0x00, 0x00, 0x00, 0x00, - 0x6F, 0xF2, 0x00, 0x00, 0x00, 0x00, 0x6F, 0xF2, 0x00, 0x00, 0x00, 0x00, 0x6F, 0xF6, 0x55, 0x55, - 0x20, 0x00, 0x6F, 0xFF, 0xFF, 0xFF, 0x80, 0x00, 0x6F, 0xFF, 0xFF, 0xFF, 0x80, 0x00, 0x6F, 0xF2, - 0x00, 0x00, 0x00, 0x00, 0x6F, 0xF2, 0x00, 0x00, 0x00, 0x00, 0x6F, 0xF2, 0x00, 0x00, 0x00, 0x00, - 0x6F, 0xF2, 0x00, 0x00, 0x00, 0x00, 0x6F, 0xF6, 0x55, 0x55, 0x55, 0x40, 0x6F, 0xFF, 0xFF, 0xFF, - 0xFF, 0xF0, 0x6F, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0x6F, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0x6F, 0xFF, - 0xFF, 0xFF, 0xFF, 0xF0, 0x6F, 0xF6, 0x55, 0x55, 0x55, 0x40, 0x6F, 0xF2, 0x00, 0x00, 0x00, 0x00, - 0x6F, 0xF2, 0x00, 0x00, 0x00, 0x00, 0x6F, 0xF2, 0x00, 0x00, 0x00, 0x00, 0x6F, 0xF6, 0x55, 0x55, - 0x20, 0x00, 0x6F, 0xFF, 0xFF, 0xFF, 0x80, 0x00, 0x6F, 0xFF, 0xFF, 0xFF, 0x80, 0x00, 0x6F, 0xF2, - 0x00, 0x00, 0x00, 0x00, 0x6F, 0xF2, 0x00, 0x00, 0x00, 0x00, 0x6F, 0xF2, 0x00, 0x00, 0x00, 0x00, - 0x6F, 0xF2, 0x00, 0x00, 0x00, 0x00, 0x6F, 0xF2, 0x00, 0x00, 0x00, 0x00, 0x6F, 0xF2, 0x00, 0x00, - 0x00, 0x00, 0x6F, 0xF2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x29, 0xDF, 0xEB, 0x60, 0x00, 0x04, 0xEF, - 0xFF, 0xFF, 0xFC, 0x10, 0x1E, 0xFF, 0x95, 0x6C, 0xFF, 0x90, 0x7F, 0xF5, 0x00, 0x00, 0xBF, 0xF1, - 0xAF, 0xE0, 0x00, 0x00, 0x5F, 0xF3, 0xBF, 0xC0, 0x00, 0x00, 0x02, 0x20, 0xCF, 0xC0, 0x00, 0x00, - 0x00, 0x00, 0xCF, 0xC0, 0x05, 0xFF, 0xFF, 0xF3, 0xCF, 0xC0, 0x06, 0xFF, 0xFF, 0xF4, 0xCF, 0xC0, - 0x01, 0x55, 0x8F, 0xF4, 0xBF, 0xC0, 0x00, 0x00, 0x4F, 0xF3, 0xAF, 0xE0, 0x00, 0x00, 0x6F, 0xF2, - 0x7F, 0xF6, 0x00, 0x00, 0xBF, 0xD0, 0x1E, 0xFF, 0x96, 0x6C, 0xFF, 0x70, 0x04, 0xEF, 0xFF, 0xFF, - 0xFA, 0x00, 0x00, 0x29, 0xDF, 0xEB, 0x60, 0x00, 0x6F, 0xF2, 0x00, 0x00, 0x0F, 0xF8, 0x6F, 0xF2, - 0x00, 0x00, 0x0F, 0xF8, 0x6F, 0xF2, 0x00, 0x00, 0x0F, 0xF8, 0x6F, 0xF2, 0x00, 0x00, 0x0F, 0xF8, - 0x6F, 0xF2, 0x00, 0x00, 0x0F, 0xF8, 0x6F, 0xF2, 0x00, 0x00, 0x0F, 0xF8, 0x6F, 0xF6, 0x55, 0x55, - 0x5F, 0xF8, 0x6F, 0xFF, 0xFF, 0xFF, 0xFF, 0xF8, 0x6F, 0xFF, 0xFF, 0xFF, 0xFF, 0xF8, 0x6F, 0xF2, - 0x00, 0x00, 0x0F, 0xF8, 0x6F, 0xF2, 0x00, 0x00, 0x0F, 0xF8, 0x6F, 0xF2, 0x00, 0x00, 0x0F, 0xF8, - 0x6F, 0xF2, 0x00, 0x00, 0x0F, 0xF8, 0x6F, 0xF2, 0x00, 0x00, 0x0F, 0xF8, 0x6F, 0xF2, 0x00, 0x00, - 0x0F, 0xF8, 0x6F, 0xF2, 0x00, 0x00, 0x0F, 0xF8, 0x5F, 0xF2, 0x6F, 0xF2, 0x6F, 0xF2, 0x6F, 0xF2, - 0x6F, 0xF2, 0x6F, 0xF2, 0x6F, 0xF2, 0x6F, 0xF2, 0x6F, 0xF2, 0x6F, 0xF2, 0x6F, 0xF2, 0x6F, 0xF2, - 0x6F, 0xF2, 0x6F, 0xF2, 0x6F, 0xF2, 0x6F, 0xF2, 0x00, 0x00, 0x00, 0x00, 0x5F, 0xF2, 0x00, 0x00, - 0x00, 0x00, 0x5F, 0xF3, 0x00, 0x00, 0x00, 0x00, 0x5F, 0xF3, 0x00, 0x00, 0x00, 0x00, 0x5F, 0xF3, - 0x00, 0x00, 0x00, 0x00, 0x5F, 0xF3, 0x00, 0x00, 0x00, 0x00, 0x5F, 0xF3, 0x00, 0x00, 0x00, 0x00, - 0x5F, 0xF3, 0x00, 0x00, 0x00, 0x00, 0x5F, 0xF3, 0x00, 0x00, 0x00, 0x00, 0x5F, 0xF3, 0x6C, 0xC0, - 0x00, 0x00, 0x5F, 0xF3, 0x8F, 0xF0, 0x00, 0x00, 0x5F, 0xF3, 0x7F, 0xF2, 0x00, 0x00, 0x7F, 0xF2, - 0x4F, 0xF8, 0x00, 0x00, 0xCF, 0xE0, 0x0D, 0xFF, 0xA6, 0x6C, 0xFF, 0x80, 0x03, 0xEF, 0xFF, 0xFF, - 0xFB, 0x00, 0x00, 0x28, 0xDE, 0xEB, 0x60, 0x00, 0x5F, 0xF2, 0x00, 0x00, 0x4F, 0xF9, 0x06, 0xFF, - 0x20, 0x00, 0x2E, 0xFD, 0x10, 0x6F, 0xF2, 0x00, 0x1C, 0xFE, 0x20, 0x06, 0xFF, 0x20, 0x0A, 0xFF, - 0x50, 0x00, 0x6F, 0xF2, 0x07, 0xFF, 0x80, 0x00, 0x06, 0xFF, 0x25, 0xFF, 0xB0, 0x00, 0x00, 0x6F, - 0xF5, 0xEF, 0xE1, 0x00, 0x00, 0x06, 0xFF, 0xEF, 0xFE, 0x20, 0x00, 0x00, 0x6F, 0xFF, 0xFF, 0xFA, - 0x00, 0x00, 0x06, 0xFF, 0xF5, 0xAF, 0xF4, 0x00, 0x00, 0x6F, 0xF7, 0x01, 0xEF, 0xD1, 0x00, 0x06, - 0xFF, 0x20, 0x06, 0xFF, 0x80, 0x00, 0x6F, 0xF2, 0x00, 0x0B, 0xFF, 0x30, 0x06, 0xFF, 0x20, 0x00, - 0x2F, 0xFC, 0x00, 0x6F, 0xF2, 0x00, 0x00, 0x7F, 0xF6, 0x06, 0xFF, 0x20, 0x00, 0x00, 0xCF, 0xE1, - 0x5F, 0xF2, 0x00, 0x00, 0x00, 0x06, 0xFF, 0x20, 0x00, 0x00, 0x00, 0x6F, 0xF2, 0x00, 0x00, 0x00, - 0x06, 0xFF, 0x20, 0x00, 0x00, 0x00, 0x6F, 0xF2, 0x00, 0x00, 0x00, 0x06, 0xFF, 0x20, 0x00, 0x00, - 0x00, 0x6F, 0xF2, 0x00, 0x00, 0x00, 0x06, 0xFF, 0x20, 0x00, 0x00, 0x00, 0x6F, 0xF2, 0x00, 0x00, - 0x00, 0x06, 0xFF, 0x20, 0x00, 0x00, 0x00, 0x6F, 0xF2, 0x00, 0x00, 0x00, 0x06, 0xFF, 0x20, 0x00, - 0x00, 0x00, 0x6F, 0xF2, 0x00, 0x00, 0x00, 0x06, 0xFF, 0x65, 0x55, 0x55, 0x54, 0x6F, 0xFF, 0xFF, - 0xFF, 0xFF, 0xE6, 0xFF, 0xFF, 0xFF, 0xFF, 0xFD, 0x5F, 0xF6, 0x00, 0x00, 0x00, 0xAF, 0xF2, 0x6F, - 0xFE, 0x10, 0x00, 0x05, 0xFF, 0xF2, 0x6F, 0xFF, 0xA0, 0x00, 0x1D, 0xFF, 0xF2, 0x6F, 0xFF, 0xF4, - 0x00, 0x9F, 0xFF, 0xF2, 0x6F, 0xFF, 0xFD, 0x13, 0xFF, 0xEF, 0xF2, 0x6F, 0xF6, 0xFF, 0x9C, 0xFE, - 0x8F, 0xF2, 0x6F, 0xF2, 0xAF, 0xFF, 0xF6, 0x6F, 0xF2, 0x6F, 0xF2, 0x1E, 0xFF, 0xB0, 0x6F, 0xF2, - 0x6F, 0xF2, 0x05, 0xFE, 0x20, 0x6F, 0xF2, 0x6F, 0xF2, 0x00, 0x43, 0x00, 0x6F, 0xF2, 0x6F, 0xF2, - 0x00, 0x00, 0x00, 0x6F, 0xF2, 0x6F, 0xF2, 0x00, 0x00, 0x00, 0x6F, 0xF2, 0x6F, 0xF2, 0x00, 0x00, - 0x00, 0x6F, 0xF2, 0x6F, 0xF2, 0x00, 0x00, 0x00, 0x6F, 0xF2, 0x6F, 0xF2, 0x00, 0x00, 0x00, 0x6F, - 0xF2, 0x6F, 0xF2, 0x00, 0x00, 0x00, 0x6F, 0xF2, 0x5F, 0xF5, 0x00, 0x00, 0x06, 0xFF, 0x16, 0xFF, - 0xD0, 0x00, 0x00, 0x7F, 0xF2, 0x6F, 0xFF, 0x70, 0x00, 0x07, 0xFF, 0x26, 0xFF, 0xFE, 0x20, 0x00, - 0x7F, 0xF2, 0x6F, 0xFF, 0xFA, 0x00, 0x07, 0xFF, 0x26, 0xFF, 0x9F, 0xF4, 0x00, 0x6F, 0xF2, 0x6F, - 0xF2, 0xDF, 0xC0, 0x06, 0xFF, 0x26, 0xFF, 0x25, 0xFF, 0x60, 0x6F, 0xF2, 0x6F, 0xF2, 0x0B, 0xFE, - 0x16, 0xFF, 0x26, 0xFF, 0x20, 0x2F, 0xF9, 0x6F, 0xF2, 0x6F, 0xF2, 0x00, 0x8F, 0xF9, 0xFF, 0x26, - 0xFF, 0x20, 0x01, 0xEF, 0xFF, 0xF2, 0x6F, 0xF2, 0x00, 0x06, 0xFF, 0xFF, 0x26, 0xFF, 0x20, 0x00, - 0x0C, 0xFF, 0xF2, 0x6F, 0xF2, 0x00, 0x00, 0x3F, 0xFF, 0x26, 0xFF, 0x20, 0x00, 0x00, 0x9F, 0xF1, - 0x00, 0x18, 0xDE, 0xEB, 0x60, 0x00, 0x03, 0xEF, 0xFF, 0xFF, 0xFB, 0x10, 0x1D, 0xFF, 0x96, 0x7C, - 0xFF, 0x90, 0x6F, 0xF6, 0x00, 0x00, 0xBF, 0xF2, 0xAF, 0xE0, 0x00, 0x00, 0x4F, 0xF5, 0xBF, 0xC0, - 0x00, 0x00, 0x2F, 0xF6, 0xCF, 0xC0, 0x00, 0x00, 0x2F, 0xF7, 0xCF, 0xC0, 0x00, 0x00, 0x2F, 0xF7, - 0xCF, 0xC0, 0x00, 0x00, 0x2F, 0xF7, 0xCF, 0xC0, 0x00, 0x00, 0x2F, 0xF7, 0xBF, 0xC0, 0x00, 0x00, - 0x2F, 0xF6, 0xAF, 0xE0, 0x00, 0x00, 0x4F, 0xF5, 0x6F, 0xF6, 0x00, 0x00, 0xBF, 0xF1, 0x1E, 0xFF, - 0x96, 0x6C, 0xFF, 0x90, 0x03, 0xEF, 0xFF, 0xFF, 0xFB, 0x10, 0x00, 0x28, 0xDE, 0xEC, 0x60, 0x00, - 0x8F, 0xFF, 0xFF, 0xFE, 0xA3, 0x00, 0x8F, 0xFF, 0xFF, 0xFF, 0xFF, 0x50, 0x8F, 0xF5, 0x55, 0x59, - 0xFF, 0xE0, 0x8F, 0xF0, 0x00, 0x00, 0x7F, 0xF4, 0x8F, 0xF0, 0x00, 0x00, 0x2F, 0xF6, 0x8F, 0xF0, - 0x00, 0x00, 0x4F, 0xF5, 0x8F, 0xF1, 0x00, 0x04, 0xDF, 0xF2, 0x8F, 0xFF, 0xFF, 0xFF, 0xFF, 0x80, - 0x8F, 0xFF, 0xFF, 0xFF, 0xE8, 0x00, 0x8F, 0xF5, 0x55, 0x53, 0x10, 0x00, 0x8F, 0xF0, 0x00, 0x00, - 0x00, 0x00, 0x8F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x8F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x8F, 0xF0, - 0x00, 0x00, 0x00, 0x00, 0x8F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x8F, 0xF0, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x3A, 0xDF, 0xD9, 0x20, 0x00, 0x6F, 0xFF, 0xFF, 0xFE, 0x50, 0x3F, 0xFE, 0x85, 0x8F, 0xFE, - 0x29, 0xFF, 0x30, 0x00, 0x4F, 0xF7, 0xDF, 0xB0, 0x00, 0x00, 0xCF, 0xBE, 0xF9, 0x00, 0x00, 0x0A, - 0xFD, 0xFF, 0x90, 0x00, 0x00, 0xAF, 0xDF, 0xF9, 0x00, 0x00, 0x0A, 0xFD, 0xFF, 0x90, 0x00, 0x00, - 0xAF, 0xDF, 0xF9, 0x00, 0x00, 0x0A, 0xFD, 0xFF, 0x90, 0x00, 0x00, 0xAF, 0xDE, 0xFA, 0x00, 0x00, - 0x0C, 0xFD, 0xCF, 0xE1, 0x00, 0x02, 0xEF, 0xB8, 0xFF, 0xB3, 0x13, 0xCF, 0xF6, 0x1D, 0xFF, 0xFF, - 0xFF, 0xFC, 0x00, 0x2C, 0xFF, 0xFF, 0xFB, 0x10, 0x00, 0x04, 0xEF, 0xD3, 0x00, 0x00, 0x00, 0x0C, - 0xFB, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xB0, 0x00, 0x00, 0x6F, 0xFF, 0xFF, 0xFE, 0xB4, 0x00, 0x6F, - 0xFF, 0xFF, 0xFF, 0xFF, 0x50, 0x6F, 0xF6, 0x55, 0x58, 0xFF, 0xE0, 0x6F, 0xF2, 0x00, 0x00, 0x6F, - 0xF5, 0x6F, 0xF2, 0x00, 0x00, 0x2F, 0xF6, 0x6F, 0xF2, 0x00, 0x00, 0x4F, 0xF6, 0x6F, 0xF2, 0x00, - 0x03, 0xDF, 0xF2, 0x6F, 0xFF, 0xFF, 0xFF, 0xFF, 0xA0, 0x6F, 0xFF, 0xFF, 0xFF, 0xF9, 0x00, 0x6F, - 0xF6, 0x55, 0xDF, 0x90, 0x00, 0x6F, 0xF2, 0x00, 0x7F, 0xF1, 0x00, 0x6F, 0xF2, 0x00, 0x1E, 0xF8, - 0x00, 0x6F, 0xF2, 0x00, 0x08, 0xFE, 0x10, 0x6F, 0xF2, 0x00, 0x02, 0xFF, 0x80, 0x6F, 0xF2, 0x00, - 0x00, 0xAF, 0xE1, 0x6F, 0xF2, 0x00, 0x00, 0x3F, 0xF7, 0x00, 0x06, 0xCE, 0xFD, 0xA4, 0x00, 0x00, - 0x0B, 0xFF, 0xFF, 0xFF, 0xF8, 0x00, 0x07, 0xFF, 0xC6, 0x58, 0xEF, 0xF5, 0x00, 0xBF, 0xD0, 0x00, - 0x02, 0xEF, 0xB0, 0x0C, 0xFB, 0x00, 0x00, 0x0A, 0xFD, 0x00, 0x9F, 0xF4, 0x00, 0x00, 0x24, 0x40, - 0x02, 0xEF, 0xFA, 0x40, 0x00, 0x00, 0x00, 0x03, 0xCF, 0xFF, 0xD7, 0x10, 0x00, 0x00, 0x00, 0x4B, - 0xFF, 0xFE, 0x60, 0x00, 0x00, 0x00, 0x02, 0x8E, 0xFF, 0x50, 0x05, 0x52, 0x00, 0x00, 0x2D, 0xFD, - 0x01, 0xFF, 0x70, 0x00, 0x00, 0x8F, 0xF0, 0x0E, 0xFC, 0x10, 0x00, 0x0C, 0xFE, 0x00, 0x8F, 0xFD, - 0x75, 0x6B, 0xFF, 0x90, 0x01, 0xBF, 0xFF, 0xFF, 0xFF, 0xC1, 0x00, 0x00, 0x5B, 0xEF, 0xEC, 0x70, - 0x00, 0x3F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0x4F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x15, 0x55, 0x5F, - 0xFB, 0x55, 0x54, 0x00, 0x00, 0x0F, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xF8, 0x00, 0x00, 0x00, - 0x00, 0x0F, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xF8, 0x00, - 0x00, 0x00, 0x00, 0x0F, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x0F, - 0xF8, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xF8, 0x00, 0x00, 0x00, - 0x00, 0x0F, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x0E, 0xF8, 0x00, - 0x00, 0x8F, 0xF0, 0x00, 0x00, 0x0F, 0xF7, 0x8F, 0xF0, 0x00, 0x00, 0x0F, 0xF8, 0x8F, 0xF0, 0x00, - 0x00, 0x0F, 0xF8, 0x8F, 0xF0, 0x00, 0x00, 0x0F, 0xF8, 0x8F, 0xF0, 0x00, 0x00, 0x0F, 0xF8, 0x8F, - 0xF0, 0x00, 0x00, 0x0F, 0xF8, 0x8F, 0xF0, 0x00, 0x00, 0x0F, 0xF8, 0x8F, 0xF0, 0x00, 0x00, 0x0F, - 0xF8, 0x8F, 0xF0, 0x00, 0x00, 0x0F, 0xF8, 0x8F, 0xF0, 0x00, 0x00, 0x0F, 0xF8, 0x8F, 0xF1, 0x00, - 0x00, 0x1F, 0xF8, 0x7F, 0xF3, 0x00, 0x00, 0x3F, 0xF6, 0x3F, 0xF9, 0x00, 0x00, 0x9F, 0xF3, 0x0C, - 0xFF, 0xB6, 0x6B, 0xFF, 0xC0, 0x02, 0xDF, 0xFF, 0xFF, 0xFD, 0x20, 0x00, 0x17, 0xCE, 0xEC, 0x71, - 0x00, 0x3F, 0xF7, 0x00, 0x00, 0x00, 0xEF, 0xA0, 0xEF, 0xB0, 0x00, 0x00, 0x4F, 0xF6, 0x0A, 0xFF, - 0x10, 0x00, 0x08, 0xFF, 0x20, 0x5F, 0xF4, 0x00, 0x00, 0xCF, 0xC0, 0x01, 0xFF, 0x80, 0x00, 0x1F, - 0xF7, 0x00, 0x0C, 0xFD, 0x00, 0x05, 0xFF, 0x30, 0x00, 0x7F, 0xF2, 0x00, 0x9F, 0xD0, 0x00, 0x03, - 0xFF, 0x60, 0x0E, 0xF9, 0x00, 0x00, 0x0D, 0xFA, 0x03, 0xFF, 0x40, 0x00, 0x00, 0x9F, 0xE0, 0x7F, - 0xE0, 0x00, 0x00, 0x04, 0xFF, 0x3B, 0xFA, 0x00, 0x00, 0x00, 0x0E, 0xF8, 0xFF, 0x60, 0x00, 0x00, - 0x00, 0xAF, 0xEF, 0xF1, 0x00, 0x00, 0x00, 0x06, 0xFF, 0xFB, 0x00, 0x00, 0x00, 0x00, 0x1F, 0xFF, - 0x70, 0x00, 0x00, 0x00, 0x00, 0xBF, 0xF2, 0x00, 0x00, 0x5F, 0xF4, 0x00, 0x00, 0xBF, 0xE1, 0x00, - 0x00, 0xDF, 0xA2, 0xFF, 0x80, 0x00, 0x0F, 0xFF, 0x50, 0x00, 0x2F, 0xF7, 0x0D, 0xFC, 0x00, 0x03, - 0xFF, 0xF8, 0x00, 0x06, 0xFF, 0x30, 0x9F, 0xF1, 0x00, 0x7F, 0xFF, 0xC0, 0x00, 0x9F, 0xE0, 0x05, - 0xFF, 0x40, 0x0A, 0xFF, 0xFF, 0x10, 0x0D, 0xFB, 0x00, 0x1F, 0xF8, 0x00, 0xEF, 0xCF, 0xF4, 0x01, - 0xFF, 0x70, 0x00, 0xCF, 0xB0, 0x2F, 0xF5, 0xFF, 0x80, 0x5F, 0xF3, 0x00, 0x08, 0xFF, 0x06, 0xFF, - 0x1B, 0xFC, 0x08, 0xFE, 0x00, 0x00, 0x5F, 0xF4, 0x9F, 0xC0, 0x8F, 0xF0, 0xCF, 0xB0, 0x00, 0x01, - 0xFF, 0x7D, 0xF9, 0x04, 0xFF, 0x4F, 0xF7, 0x00, 0x00, 0x0C, 0xFC, 0xFF, 0x50, 0x1F, 0xFC, 0xFF, - 0x30, 0x00, 0x00, 0x8F, 0xFF, 0xF2, 0x00, 0xCF, 0xFF, 0xE0, 0x00, 0x00, 0x04, 0xFF, 0xFD, 0x00, - 0x08, 0xFF, 0xFB, 0x00, 0x00, 0x00, 0x1F, 0xFF, 0xA0, 0x00, 0x4F, 0xFF, 0x70, 0x00, 0x00, 0x00, - 0xBF, 0xF6, 0x00, 0x01, 0xFF, 0xF4, 0x00, 0x00, 0x00, 0x07, 0xFF, 0x20, 0x00, 0x0B, 0xFE, 0x00, - 0x00, 0x1F, 0xFA, 0x00, 0x00, 0x02, 0xEF, 0x90, 0x8F, 0xF4, 0x00, 0x00, 0xBF, 0xF2, 0x01, 0xEF, - 0xD0, 0x00, 0x4F, 0xF8, 0x00, 0x06, 0xFF, 0x70, 0x0D, 0xFD, 0x10, 0x00, 0x0C, 0xFE, 0x17, 0xFF, - 0x50, 0x00, 0x00, 0x4F, 0xFB, 0xEF, 0xC0, 0x00, 0x00, 0x00, 0xAF, 0xFF, 0xF3, 0x00, 0x00, 0x00, - 0x02, 0xFF, 0xFA, 0x00, 0x00, 0x00, 0x00, 0x1E, 0xFF, 0x90, 0x00, 0x00, 0x00, 0x0A, 0xFF, 0xFF, - 0x30, 0x00, 0x00, 0x03, 0xFF, 0xBF, 0xFB, 0x00, 0x00, 0x00, 0xCF, 0xE1, 0x7F, 0xF5, 0x00, 0x00, - 0x5F, 0xF7, 0x00, 0xDF, 0xD1, 0x00, 0x1D, 0xFD, 0x00, 0x05, 0xFF, 0x70, 0x08, 0xFF, 0x40, 0x00, - 0x0B, 0xFE, 0x21, 0xFF, 0xA0, 0x00, 0x00, 0x2E, 0xF9, 0x2F, 0xF8, 0x00, 0x00, 0x06, 0xFF, 0x50, - 0xAF, 0xF1, 0x00, 0x00, 0xDF, 0xD0, 0x03, 0xFF, 0x80, 0x00, 0x5F, 0xF6, 0x00, 0x0A, 0xFE, 0x10, - 0x0D, 0xFD, 0x00, 0x00, 0x3F, 0xF7, 0x05, 0xFF, 0x60, 0x00, 0x00, 0xAF, 0xE1, 0xCF, 0xD0, 0x00, - 0x00, 0x03, 0xFF, 0xBF, 0xF6, 0x00, 0x00, 0x00, 0x0A, 0xFF, 0xFD, 0x00, 0x00, 0x00, 0x00, 0x3F, - 0xFF, 0x60, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x0B, 0xFD, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xBF, 0xD0, 0x00, 0x00, 0x00, 0x00, 0x0B, 0xFD, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xBF, 0xD0, 0x00, 0x00, 0x00, 0x00, 0x0B, 0xFD, 0x00, 0x00, 0x00, 0x00, 0x00, 0xAF, 0xD0, 0x00, - 0x00, 0x2F, 0xFF, 0xFF, 0xFF, 0xFF, 0xF3, 0x3F, 0xFF, 0xFF, 0xFF, 0xFF, 0xF4, 0x15, 0x55, 0x55, - 0x55, 0xDF, 0xF2, 0x00, 0x00, 0x00, 0x05, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x2E, 0xFC, 0x00, 0x00, - 0x00, 0x00, 0xBF, 0xF3, 0x00, 0x00, 0x00, 0x06, 0xFF, 0x70, 0x00, 0x00, 0x00, 0x2E, 0xFC, 0x00, - 0x00, 0x00, 0x00, 0xBF, 0xF2, 0x00, 0x00, 0x00, 0x06, 0xFF, 0x70, 0x00, 0x00, 0x00, 0x2E, 0xFC, - 0x00, 0x00, 0x00, 0x00, 0xCF, 0xE2, 0x00, 0x00, 0x00, 0x07, 0xFF, 0x60, 0x00, 0x00, 0x00, 0x1F, - 0xFE, 0x55, 0x55, 0x55, 0x51, 0x3F, 0xFF, 0xFF, 0xFF, 0xFF, 0xF4, 0x2F, 0xFF, 0xFF, 0xFF, 0xFF, - 0xF3, 0x3E, 0xD2, 0x9F, 0xF6, 0x3E, 0xD2, 0x4E, 0xC1, 0xAF, 0xF5, 0x4E, 0xC1, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4E, 0xC1, 0xAF, 0xF5, 0x4E, 0xC1, 0x8F, 0xF0, 0x8F, - 0xF0, 0x8F, 0xE0, 0x7F, 0xE0, 0x7F, 0xE0, 0x7F, 0xD0, 0x6F, 0xD0, 0x6F, 0xC0, 0x6F, 0xC0, 0x5F, - 0xC0, 0x4F, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x8E, 0xA0, 0xEF, 0xF1, 0x8E, 0xA0, 0x00, 0x00, 0xAF, - 0x70, 0x00, 0x00, 0x00, 0x0A, 0xF7, 0x00, 0x00, 0x00, 0x00, 0xAF, 0x70, 0x00, 0x00, 0x00, 0x0A, - 0xF7, 0x00, 0x00, 0x4F, 0xFF, 0xFF, 0xFF, 0xFF, 0x14, 0xFF, 0xFF, 0xFF, 0xFF, 0xF1, 0x15, 0x55, - 0xCF, 0xA5, 0x55, 0x00, 0x00, 0x0A, 0xF7, 0x00, 0x00, 0x00, 0x00, 0xAF, 0x70, 0x00, 0x00, 0x00, - 0x0A, 0xF7, 0x00, 0x00, 0x15, 0x55, 0x55, 0x55, 0x04, 0xFF, 0xFF, 0xFF, 0xF2, 0x4F, 0xFF, 0xFF, - 0xFF, 0x20, 0x00, 0x00, 0x02, 0xFF, 0x60, 0x00, 0x00, 0x7F, 0xF1, 0x00, 0x00, 0x0C, 0xFB, 0x00, - 0x00, 0x02, 0xFF, 0x60, 0x00, 0x00, 0x8F, 0xF1, 0x00, 0x00, 0x0D, 0xFA, 0x00, 0x00, 0x03, 0xFF, - 0x50, 0x00, 0x00, 0x8F, 0xE1, 0x00, 0x00, 0x0D, 0xFA, 0x00, 0x00, 0x04, 0xFF, 0x40, 0x00, 0x00, - 0x9F, 0xE0, 0x00, 0x00, 0x0E, 0xF9, 0x00, 0x00, 0x04, 0xFF, 0x40, 0x00, 0x00, 0xAF, 0xD0, 0x00, - 0x00, 0x1E, 0xF8, 0x00, 0x00, 0x05, 0xFF, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, - 0x00, 0x00, 0x00, 0x39, 0xF1, 0x00, 0x00, 0x04, 0xBF, 0xFF, 0x10, 0x00, 0x5C, 0xFF, 0xFC, 0x60, - 0x07, 0xDF, 0xFF, 0xA3, 0x00, 0x04, 0xFF, 0xE7, 0x10, 0x00, 0x00, 0x4F, 0xFE, 0x71, 0x00, 0x00, - 0x00, 0x7E, 0xFF, 0xFA, 0x30, 0x00, 0x00, 0x06, 0xCF, 0xFF, 0xC6, 0x00, 0x00, 0x00, 0x4B, 0xFF, - 0xF1, 0x00, 0x00, 0x00, 0x03, 0xAF, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10, 0x11, 0x00, 0x00, 0x00, - 0x00, 0x04, 0xE8, 0x10, 0x00, 0x00, 0x00, 0x4F, 0xFF, 0x93, 0x00, 0x00, 0x01, 0x7D, 0xFF, 0xFB, - 0x40, 0x00, 0x00, 0x05, 0xBF, 0xFF, 0xC5, 0x00, 0x00, 0x00, 0x29, 0xEF, 0xF1, 0x00, 0x00, 0x03, - 0x9E, 0xFF, 0x10, 0x00, 0x5B, 0xFF, 0xFC, 0x50, 0x17, 0xDF, 0xFF, 0xB4, 0x00, 0x04, 0xFF, 0xFA, - 0x30, 0x00, 0x00, 0x4E, 0x82, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, - 0xAA, 0x00, 0x1A, 0xA4, 0x00, 0x00, 0x9F, 0xE0, 0x03, 0xFF, 0x50, 0x00, 0x0C, 0xFC, 0x00, 0x5F, - 0xF3, 0x00, 0x00, 0xEF, 0xA0, 0x08, 0xFF, 0x10, 0x0E, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x90, 0xEF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFA, 0x04, 0x9F, 0xF6, 0x55, 0xFF, 0xB5, 0x30, 0x08, 0xFF, 0x00, 0x2F, - 0xF6, 0x00, 0x00, 0xBF, 0xD0, 0x05, 0xFF, 0x40, 0x0B, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC0, 0xCF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFD, 0x03, 0x7F, 0xF9, 0x55, 0xDF, 0xD5, 0x40, 0x04, 0xFF, 0x40, 0x0D, - 0xFA, 0x00, 0x00, 0x6F, 0xF2, 0x00, 0xFF, 0x80, 0x00, 0x08, 0xFF, 0x00, 0x2F, 0xF6, 0x00, 0x00, - 0x24, 0x40, 0x01, 0x44, 0x10, 0x00, 0x01, 0x9E, 0xE9, 0x10, 0x00, 0x0B, 0xE1, 0x00, 0x0B, 0xFE, - 0xEF, 0xB0, 0x00, 0x5F, 0x80, 0x00, 0x4F, 0x90, 0x09, 0xF3, 0x00, 0xDE, 0x10, 0x00, 0x5F, 0x30, - 0x04, 0xF5, 0x06, 0xF7, 0x00, 0x00, 0x3F, 0xA1, 0x2B, 0xF2, 0x0D, 0xD1, 0x00, 0x00, 0x0A, 0xFF, - 0xFF, 0x90, 0x7F, 0x60, 0x00, 0x00, 0x00, 0x7C, 0xC7, 0x01, 0xED, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x08, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x9F, 0x40, 0x5C, 0xFC, 0x40, 0x00, 0x00, 0x02, 0xFB, 0x04, 0xFF, 0xDF, 0xF3, 0x00, 0x00, - 0x0A, 0xF3, 0x0B, 0xF3, 0x04, 0xFA, 0x00, 0x00, 0x3F, 0xA0, 0x0D, 0xB0, 0x00, 0xCC, 0x00, 0x00, - 0xBF, 0x20, 0x0B, 0xC0, 0x00, 0xDA, 0x00, 0x04, 0xF9, 0x00, 0x04, 0xF8, 0x39, 0xF3, 0x00, 0x0C, - 0xE1, 0x00, 0x00, 0x5C, 0xFC, 0x40, -]; - -static FONT_MD_GLYPHS: [Glyph; 47] = [ - Glyph { ch: 32, x_off: 0, y_off: 0, w: 0, h: 0, adv: 4, offset: 0 }, - Glyph { ch: 48, x_off: 1, y_off: 0, w: 11, h: 16, adv: 13, offset: 0 }, - Glyph { ch: 49, x_off: 2, y_off: 0, w: 7, h: 16, adv: 13, offset: 88 }, - Glyph { ch: 50, x_off: 1, y_off: 0, w: 11, h: 16, adv: 13, offset: 144 }, - Glyph { ch: 51, x_off: 0, y_off: 0, w: 11, h: 16, adv: 13, offset: 232 }, - Glyph { ch: 52, x_off: 0, y_off: 0, w: 12, h: 16, adv: 13, offset: 320 }, - Glyph { ch: 53, x_off: 1, y_off: 0, w: 10, h: 16, adv: 13, offset: 416 }, - Glyph { ch: 54, x_off: 1, y_off: 0, w: 10, h: 16, adv: 13, offset: 496 }, - Glyph { ch: 55, x_off: 1, y_off: 0, w: 11, h: 16, adv: 13, offset: 576 }, - Glyph { ch: 56, x_off: 0, y_off: 0, w: 11, h: 16, adv: 13, offset: 664 }, - Glyph { ch: 57, x_off: 0, y_off: 0, w: 11, h: 16, adv: 13, offset: 752 }, - Glyph { ch: 65, x_off: 0, y_off: 0, w: 14, h: 16, adv: 14, offset: 840 }, - Glyph { ch: 66, x_off: 1, y_off: 0, w: 12, h: 16, adv: 14, offset: 952 }, - Glyph { ch: 67, x_off: 1, y_off: 0, w: 12, h: 16, adv: 13, offset: 1048 }, - Glyph { ch: 68, x_off: 1, y_off: 0, w: 12, h: 16, adv: 14, offset: 1144 }, - Glyph { ch: 69, x_off: 1, y_off: 0, w: 12, h: 16, adv: 13, offset: 1240 }, - Glyph { ch: 70, x_off: 1, y_off: 0, w: 12, h: 16, adv: 12, offset: 1336 }, - Glyph { ch: 71, x_off: 1, y_off: 0, w: 12, h: 16, adv: 13, offset: 1432 }, - Glyph { ch: 72, x_off: 1, y_off: 0, w: 12, h: 16, adv: 14, offset: 1528 }, - Glyph { ch: 73, x_off: 1, y_off: 0, w: 4, h: 16, adv: 6, offset: 1624 }, - Glyph { ch: 74, x_off: 0, y_off: 0, w: 12, h: 16, adv: 13, offset: 1656 }, - Glyph { ch: 75, x_off: 1, y_off: 0, w: 13, h: 16, adv: 14, offset: 1752 }, - Glyph { ch: 76, x_off: 1, y_off: 0, w: 11, h: 16, adv: 13, offset: 1856 }, - Glyph { ch: 77, x_off: 1, y_off: 0, w: 14, h: 16, adv: 16, offset: 1944 }, - Glyph { ch: 78, x_off: 1, y_off: 0, w: 13, h: 16, adv: 15, offset: 2056 }, - Glyph { ch: 79, x_off: 1, y_off: 0, w: 12, h: 16, adv: 14, offset: 2160 }, - Glyph { ch: 80, x_off: 1, y_off: 0, w: 12, h: 16, adv: 13, offset: 2256 }, - Glyph { ch: 81, x_off: 1, y_off: 0, w: 11, h: 19, adv: 13, offset: 2352 }, - Glyph { ch: 82, x_off: 1, y_off: 0, w: 12, h: 16, adv: 13, offset: 2457 }, - Glyph { ch: 83, x_off: 0, y_off: 0, w: 13, h: 16, adv: 13, offset: 2553 }, - Glyph { ch: 84, x_off: 0, y_off: 0, w: 12, h: 16, adv: 13, offset: 2657 }, - Glyph { ch: 85, x_off: 1, y_off: 0, w: 12, h: 16, adv: 14, offset: 2753 }, - Glyph { ch: 86, x_off: 0, y_off: 0, w: 13, h: 16, adv: 13, offset: 2849 }, - Glyph { ch: 87, x_off: 0, y_off: 0, w: 19, h: 16, adv: 19, offset: 2953 }, - Glyph { ch: 88, x_off: 0, y_off: 0, w: 13, h: 16, adv: 14, offset: 3105 }, - Glyph { ch: 89, x_off: 0, y_off: 0, w: 13, h: 16, adv: 13, offset: 3209 }, - Glyph { ch: 90, x_off: 0, y_off: 0, w: 12, h: 16, adv: 12, offset: 3313 }, - Glyph { ch: 46, x_off: 1, y_off: 13, w: 4, h: 3, adv: 6, offset: 3409 }, - Glyph { ch: 58, x_off: 2, y_off: 5, w: 4, h: 11, adv: 8, offset: 3415 }, - Glyph { ch: 33, x_off: 2, y_off: 0, w: 4, h: 16, adv: 7, offset: 3437 }, - Glyph { ch: 43, x_off: 0, y_off: 4, w: 11, h: 10, adv: 11, offset: 3469 }, - Glyph { ch: 45, x_off: 0, y_off: 7, w: 9, h: 3, adv: 9, offset: 3524 }, - Glyph { ch: 47, x_off: 0, y_off: 0, w: 9, h: 16, adv: 10, offset: 3538 }, - Glyph { ch: 60, x_off: 0, y_off: 4, w: 11, h: 12, adv: 11, offset: 3610 }, - Glyph { ch: 62, x_off: 0, y_off: 4, w: 11, h: 12, adv: 11, offset: 3676 }, - Glyph { ch: 35, x_off: 1, y_off: 0, w: 13, h: 16, adv: 15, offset: 3742 }, - Glyph { ch: 37, x_off: 1, y_off: 0, w: 16, h: 16, adv: 18, offset: 3846 }, -]; - -pub static FONT_MD: Font = Font { glyphs: &FONT_MD_GLYPHS, data: &FONT_MD_DATA }; - -static FONT_LG_DATA: [u8; 12604] = [ - 0x00, 0x00, 0x01, 0x6A, 0xDE, 0xFE, 0xDA, 0x61, 0x00, 0x00, 0x00, 0x00, 0x07, 0xEF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xE7, 0x00, 0x00, 0x00, 0x1B, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFB, 0x00, 0x00, - 0x0B, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFA, 0x00, 0x06, 0xFF, 0xFF, 0xFF, 0xB8, 0x78, - 0xCF, 0xFF, 0xFF, 0xF5, 0x00, 0xDF, 0xFF, 0xFE, 0x40, 0x00, 0x00, 0x4E, 0xFF, 0xFF, 0xD0, 0x3F, - 0xFF, 0xFF, 0x40, 0x00, 0x00, 0x00, 0x5F, 0xFF, 0xFF, 0x36, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, - 0x00, 0xCF, 0xFF, 0xF6, 0x8F, 0xFF, 0xF9, 0x00, 0x00, 0x00, 0x00, 0x09, 0xFF, 0xFF, 0x89, 0xFF, - 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x8F, 0xFF, 0xF9, 0x9F, 0xFF, 0xF8, 0x00, 0x00, 0x00, 0x00, - 0x08, 0xFF, 0xFF, 0x99, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x8F, 0xFF, 0xF9, 0x9F, 0xFF, - 0xF8, 0x00, 0x00, 0x00, 0x00, 0x08, 0xFF, 0xFF, 0x99, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, - 0x8F, 0xFF, 0xF9, 0x9F, 0xFF, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x08, 0xFF, 0xFF, 0x99, 0xFF, 0xFF, - 0x80, 0x00, 0x00, 0x00, 0x00, 0x8F, 0xFF, 0xF9, 0x9F, 0xFF, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x08, - 0xFF, 0xFF, 0x99, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x8F, 0xFF, 0xF9, 0x9F, 0xFF, 0xF8, - 0x00, 0x00, 0x00, 0x00, 0x08, 0xFF, 0xFF, 0x99, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x8F, - 0xFF, 0xF9, 0x9F, 0xFF, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x08, 0xFF, 0xFF, 0x99, 0xFF, 0xFF, 0x80, - 0x00, 0x00, 0x00, 0x00, 0x8F, 0xFF, 0xF9, 0x8F, 0xFF, 0xF9, 0x00, 0x00, 0x00, 0x00, 0x09, 0xFF, - 0xFF, 0x76, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF6, 0x2F, 0xFF, 0xFF, 0x40, - 0x00, 0x00, 0x00, 0x4F, 0xFF, 0xFF, 0x20, 0xDF, 0xFF, 0xFE, 0x40, 0x00, 0x00, 0x4E, 0xFF, 0xFF, - 0xC0, 0x05, 0xFF, 0xFF, 0xFF, 0xB8, 0x78, 0xCF, 0xFF, 0xFF, 0xF5, 0x00, 0x0A, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFA, 0x00, 0x00, 0x1B, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFA, 0x00, - 0x00, 0x00, 0x07, 0xEF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE6, 0x00, 0x00, 0x00, 0x00, 0x01, 0x6A, 0xDE, - 0xFE, 0xDA, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x29, 0xEF, 0xFF, 0xF6, 0x00, 0x29, 0xFF, 0xFF, - 0xFF, 0xF7, 0x08, 0xFF, 0xFF, 0xFF, 0xFF, 0xF7, 0x1F, 0xFF, 0xFF, 0xFF, 0xFF, 0xF7, 0x0F, 0xFF, - 0xFF, 0xFF, 0xFF, 0xF7, 0x0E, 0xFE, 0x95, 0xBF, 0xFF, 0xF7, 0x06, 0x40, 0x00, 0xAF, 0xFF, 0xF7, - 0x00, 0x00, 0x00, 0xAF, 0xFF, 0xF7, 0x00, 0x00, 0x00, 0xAF, 0xFF, 0xF7, 0x00, 0x00, 0x00, 0xAF, - 0xFF, 0xF7, 0x00, 0x00, 0x00, 0xAF, 0xFF, 0xF7, 0x00, 0x00, 0x00, 0xAF, 0xFF, 0xF7, 0x00, 0x00, - 0x00, 0xAF, 0xFF, 0xF7, 0x00, 0x00, 0x00, 0xAF, 0xFF, 0xF7, 0x00, 0x00, 0x00, 0xAF, 0xFF, 0xF7, - 0x00, 0x00, 0x00, 0xAF, 0xFF, 0xF7, 0x00, 0x00, 0x00, 0xAF, 0xFF, 0xF7, 0x00, 0x00, 0x00, 0xAF, - 0xFF, 0xF7, 0x00, 0x00, 0x00, 0xAF, 0xFF, 0xF7, 0x00, 0x00, 0x00, 0xAF, 0xFF, 0xF7, 0x00, 0x00, - 0x00, 0xAF, 0xFF, 0xF7, 0x00, 0x00, 0x00, 0xAF, 0xFF, 0xF7, 0x00, 0x00, 0x00, 0xAF, 0xFF, 0xF7, - 0x00, 0x00, 0x00, 0xAF, 0xFF, 0xF7, 0x00, 0x00, 0x00, 0xAF, 0xFF, 0xF7, 0x00, 0x00, 0x00, 0xAF, - 0xFF, 0xF7, 0x00, 0x00, 0x00, 0xAF, 0xFF, 0xF7, 0x00, 0x00, 0x00, 0xAF, 0xFF, 0xF7, 0x00, 0x00, - 0x00, 0xAF, 0xFF, 0xF7, 0x00, 0x00, 0x00, 0xAF, 0xFF, 0xF7, 0x00, 0x00, 0x00, 0x9F, 0xFF, 0xF6, - 0x00, 0x00, 0x03, 0x8C, 0xDF, 0xED, 0xB7, 0x10, 0x00, 0x00, 0x00, 0x00, 0x3C, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x6F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC1, 0x00, 0x00, - 0x6F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC0, 0x00, 0x1E, 0xFF, 0xFF, 0xFD, 0x97, 0x7B, - 0xFF, 0xFF, 0xFF, 0x70, 0x07, 0xFF, 0xFF, 0xF9, 0x00, 0x00, 0x03, 0xDF, 0xFF, 0xFE, 0x00, 0xCF, - 0xFF, 0xFB, 0x00, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xF4, 0x0E, 0xFF, 0xFF, 0x50, 0x00, 0x00, 0x00, - 0x0C, 0xFF, 0xFF, 0x60, 0xEF, 0xFF, 0xF3, 0x00, 0x00, 0x00, 0x00, 0xBF, 0xFF, 0xF7, 0x0E, 0xFF, - 0xFF, 0x30, 0x00, 0x00, 0x00, 0x0D, 0xFF, 0xFF, 0x50, 0x24, 0x44, 0x30, 0x00, 0x00, 0x00, 0x04, - 0xFF, 0xFF, 0xF2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xBF, 0xFF, 0xFC, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x6F, 0xFF, 0xFF, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2E, 0xFF, - 0xFF, 0xD0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, 0xFF, 0xFF, 0xF4, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x0A, 0xFF, 0xFF, 0xF9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0xFF, 0xFF, 0xFC, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0xFF, 0xFF, 0xFE, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x04, 0xFF, 0xFF, 0xFF, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xEF, 0xFF, 0xFF, 0x50, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x01, 0xDF, 0xFF, 0xFF, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xCF, - 0xFF, 0xFF, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xBF, 0xFF, 0xFF, 0xA0, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x9F, 0xFF, 0xFF, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8F, 0xFF, 0xFF, - 0xC1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xFF, 0xFF, 0xD2, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x5F, 0xFF, 0xFF, 0xF9, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x0C, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF3, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0x3C, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF3, 0xBF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x20, 0x0B, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFB, - 0x00, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC0, 0x0C, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0x00, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC0, - 0x04, 0x66, 0x66, 0x66, 0x66, 0x66, 0x8F, 0xFF, 0xFF, 0xFB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x2D, 0xFF, 0xFF, 0xFE, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2D, 0xFF, 0xFF, 0xFE, 0x20, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x2D, 0xFF, 0xFF, 0xFE, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2D, 0xFF, - 0xFF, 0xFE, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3E, 0xFF, 0xFF, 0xFE, 0x30, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x3E, 0xFF, 0xFF, 0xFE, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3E, 0xFF, 0xFF, 0xFF, - 0x82, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0x30, 0x00, 0x00, 0x00, - 0x00, 0x0B, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x60, 0x00, 0x00, 0x00, 0x00, 0x1D, 0xFC, 0x9B, 0xFF, - 0xFF, 0xFF, 0x40, 0x00, 0x00, 0x00, 0x00, 0x35, 0x00, 0x02, 0xCF, 0xFF, 0xFD, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x01, 0xEF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, - 0xFF, 0xFF, 0xA0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4F, 0xFF, 0xFE, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x02, 0xFF, 0xFF, 0xF0, 0x03, 0x33, 0x32, 0x00, 0x00, 0x00, 0x00, 0x1F, - 0xFF, 0xFF, 0x14, 0xFF, 0xFF, 0xD0, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xF1, 0x3F, 0xFF, 0xFF, - 0x00, 0x00, 0x00, 0x00, 0x3F, 0xFF, 0xFF, 0x01, 0xFF, 0xFF, 0xF4, 0x00, 0x00, 0x00, 0x07, 0xFF, - 0xFF, 0xD0, 0x0C, 0xFF, 0xFF, 0xB0, 0x00, 0x00, 0x01, 0xDF, 0xFF, 0xF9, 0x00, 0x6F, 0xFF, 0xFF, - 0x80, 0x00, 0x00, 0xAF, 0xFF, 0xFF, 0x40, 0x00, 0xDF, 0xFF, 0xFF, 0xD8, 0x79, 0xEF, 0xFF, 0xFF, - 0xC0, 0x00, 0x04, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE3, 0x00, 0x00, 0x05, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xE4, 0x00, 0x00, 0x00, 0x03, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC3, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x49, 0xCE, 0xFE, 0xC9, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x0D, 0xFF, 0xFF, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0xFF, 0xFF, 0xF1, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x4F, 0xFF, 0xFF, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0B, 0xFF, 0xFF, - 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xFF, 0xFF, 0xF4, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x9F, 0xFF, 0xFD, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, - 0xFF, 0xFF, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xFF, 0xFF, 0xE0, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xEF, 0xFF, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x6F, 0xFF, 0xFF, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0xFF, 0xFF, 0x90, - 0x00, 0x02, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x04, 0xFF, 0xFF, 0xF3, 0x00, 0x00, 0x3F, 0xFF, 0xFE, - 0x00, 0x00, 0x00, 0xBF, 0xFF, 0xFB, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xE0, 0x00, 0x00, 0x2F, 0xFF, - 0xFF, 0x40, 0x00, 0x00, 0x3F, 0xFF, 0xFE, 0x00, 0x00, 0x09, 0xFF, 0xFF, 0xD0, 0x00, 0x00, 0x03, - 0xFF, 0xFF, 0xE0, 0x00, 0x01, 0xEF, 0xFF, 0xF6, 0x00, 0x00, 0x00, 0x3F, 0xFF, 0xFE, 0x00, 0x00, - 0x7F, 0xFF, 0xFE, 0x10, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xE0, 0x00, 0x0E, 0xFF, 0xFF, 0xC6, 0x66, - 0x66, 0x66, 0x9F, 0xFF, 0xFE, 0x66, 0x24, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xF7, 0x5F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x85, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF8, 0x4F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xE0, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xFF, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xFF, - 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xE0, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xFF, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x03, 0xFF, 0xFF, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2F, 0xFF, 0xFC, 0x00, - 0x00, 0xAF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x60, 0xBF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0x70, 0xBF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x70, 0xBF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x70, 0xBF, 0xFF, 0xFA, 0x66, 0x66, 0x66, 0x66, - 0x66, 0x66, 0x20, 0xBF, 0xFF, 0xF6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xBF, 0xFF, 0xF6, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xBF, 0xFF, 0xF6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0xBF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xBF, 0xFF, 0xF5, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xBF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xBF, - 0xFF, 0xF5, 0x17, 0xBE, 0xFE, 0xC9, 0x30, 0x00, 0x00, 0xBF, 0xFF, 0xFA, 0xEF, 0xFF, 0xFF, 0xFF, - 0xFA, 0x10, 0x00, 0xBF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xD2, 0x00, 0xBF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFD, 0x00, 0xBF, 0xFF, 0xFF, 0xFE, 0xA7, 0x7A, 0xFF, 0xFF, 0xFF, - 0x70, 0xBF, 0xFF, 0xFF, 0xB1, 0x00, 0x00, 0x3E, 0xFF, 0xFF, 0xD0, 0xBF, 0xFF, 0xFD, 0x10, 0x00, - 0x00, 0x05, 0xFF, 0xFF, 0xF2, 0x25, 0x55, 0x52, 0x00, 0x00, 0x00, 0x00, 0xEF, 0xFF, 0xF6, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xBF, 0xFF, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9F, 0xFF, 0xF9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xAF, 0xFF, 0xF9, 0x7B, 0xBB, 0xB5, - 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF7, 0x9F, 0xFF, 0xFB, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, - 0xF5, 0x5F, 0xFF, 0xFF, 0x30, 0x00, 0x00, 0x08, 0xFF, 0xFF, 0xF2, 0x1E, 0xFF, 0xFF, 0xD2, 0x00, - 0x00, 0x6F, 0xFF, 0xFF, 0xC0, 0x08, 0xFF, 0xFF, 0xFF, 0xA7, 0x8C, 0xFF, 0xFF, 0xFF, 0x40, 0x00, - 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF9, 0x00, 0x00, 0x1C, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xA0, 0x00, 0x00, 0x01, 0x9F, 0xFF, 0xFF, 0xFF, 0xFF, 0xE6, 0x00, 0x00, 0x00, 0x00, 0x02, - 0x7B, 0xEF, 0xED, 0xA6, 0x10, 0x00, 0x00, 0x00, 0x00, 0x04, 0x9C, 0xDF, 0xEC, 0xA5, 0x10, 0x00, - 0x00, 0x00, 0x04, 0xDF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE7, 0x00, 0x00, 0x00, 0x7F, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xB0, 0x00, 0x05, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF9, 0x00, 0x1E, - 0xFF, 0xFF, 0xFD, 0x87, 0x8C, 0xFF, 0xFF, 0xFF, 0x30, 0x6F, 0xFF, 0xFF, 0x90, 0x00, 0x00, 0x6F, - 0xFF, 0xFF, 0x90, 0x9F, 0xFF, 0xFC, 0x00, 0x00, 0x00, 0x09, 0xFF, 0xFF, 0xC0, 0xBF, 0xFF, 0xF7, - 0x00, 0x00, 0x00, 0x05, 0xFF, 0xFF, 0xD0, 0xBF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x02, 0xCC, 0xCC, - 0x90, 0xBF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xBF, 0xFF, 0xF5, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xBF, 0xFF, 0xF5, 0x06, 0xBE, 0xFE, 0xD9, 0x40, 0x00, 0x00, 0xBF, - 0xFF, 0xF7, 0xCF, 0xFF, 0xFF, 0xFF, 0xFA, 0x10, 0x00, 0xBF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xD2, 0x00, 0xBF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFB, 0x00, 0xBF, 0xFF, 0xFF, - 0xFE, 0x97, 0x7B, 0xFF, 0xFF, 0xFF, 0x60, 0xBF, 0xFF, 0xFF, 0xC2, 0x00, 0x00, 0x4E, 0xFF, 0xFF, - 0xD0, 0xBF, 0xFF, 0xFF, 0x20, 0x00, 0x00, 0x06, 0xFF, 0xFF, 0xF2, 0xBF, 0xFF, 0xFB, 0x00, 0x00, - 0x00, 0x00, 0xEF, 0xFF, 0xF5, 0xBF, 0xFF, 0xF7, 0x00, 0x00, 0x00, 0x00, 0xBF, 0xFF, 0xF7, 0xBF, - 0xFF, 0xF6, 0x00, 0x00, 0x00, 0x00, 0x9F, 0xFF, 0xF8, 0xBF, 0xFF, 0xF6, 0x00, 0x00, 0x00, 0x00, - 0x9F, 0xFF, 0xF8, 0xAF, 0xFF, 0xF7, 0x00, 0x00, 0x00, 0x00, 0xBF, 0xFF, 0xF6, 0x8F, 0xFF, 0xFB, - 0x00, 0x00, 0x00, 0x00, 0xEF, 0xFF, 0xF4, 0x4F, 0xFF, 0xFF, 0x20, 0x00, 0x00, 0x06, 0xFF, 0xFF, - 0xF1, 0x0E, 0xFF, 0xFF, 0xC1, 0x00, 0x00, 0x4E, 0xFF, 0xFF, 0xB0, 0x07, 0xFF, 0xFF, 0xFE, 0x97, - 0x7B, 0xFF, 0xFF, 0xFF, 0x40, 0x00, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF9, 0x00, 0x00, - 0x2D, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xA0, 0x00, 0x00, 0x01, 0x9F, 0xFF, 0xFF, 0xFF, 0xFF, - 0xE7, 0x00, 0x00, 0x00, 0x00, 0x02, 0x8B, 0xEF, 0xFD, 0xB7, 0x10, 0x00, 0x00, 0xCF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFA, 0xDF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFB, 0xDF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFB, 0xDF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFB, 0xDF, 0xFF, 0xA6, 0x66, 0x66, 0x66, 0x66, 0xDF, 0xFF, 0xFA, 0xDF, - 0xFF, 0x60, 0x00, 0x00, 0x00, 0x02, 0xFF, 0xFF, 0xF5, 0xDF, 0xFF, 0x50, 0x00, 0x00, 0x00, 0x07, - 0xFF, 0xFF, 0xE0, 0x13, 0x32, 0x00, 0x00, 0x00, 0x00, 0x0D, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x3F, 0xFF, 0xFF, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9F, 0xFF, 0xFC, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xEF, 0xFF, 0xF7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x05, 0xFF, 0xFF, 0xF1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0B, 0xFF, 0xFF, 0xA0, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x2F, 0xFF, 0xFF, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xFF, - 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xDF, 0xFF, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x04, 0xFF, 0xFF, 0xF3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0xFF, 0xFF, 0xC0, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0xFF, 0xFF, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6F, - 0xFF, 0xFF, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xFA, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x02, 0xFF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0xFF, 0xFF, 0xE0, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x4F, 0xFF, 0xFF, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xAF, 0xFF, 0xFC, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xF6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0xFF, 0xFF, - 0xF1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0xFF, 0xFF, 0xA0, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x3F, 0xFF, 0xFF, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xFF, 0xFD, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0xCD, 0xFE, 0xDA, 0x51, 0x00, 0x00, 0x00, 0x00, 0x02, - 0xAF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE6, 0x00, 0x00, 0x00, 0x03, 0xEF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xF9, 0x00, 0x00, 0x02, 0xEF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF8, 0x00, 0x00, 0xBF, 0xFF, - 0xFF, 0xE9, 0x78, 0xCF, 0xFF, 0xFF, 0xF2, 0x00, 0x2F, 0xFF, 0xFF, 0xA1, 0x00, 0x00, 0x5F, 0xFF, - 0xFF, 0x80, 0x07, 0xFF, 0xFF, 0xD1, 0x00, 0x00, 0x00, 0x7F, 0xFF, 0xFC, 0x00, 0x9F, 0xFF, 0xF8, - 0x00, 0x00, 0x00, 0x02, 0xFF, 0xFF, 0xE0, 0x09, 0xFF, 0xFF, 0x70, 0x00, 0x00, 0x00, 0x1F, 0xFF, - 0xFE, 0x00, 0x7F, 0xFF, 0xFB, 0x00, 0x00, 0x00, 0x04, 0xFF, 0xFF, 0xC0, 0x03, 0xFF, 0xFF, 0xF4, - 0x00, 0x00, 0x01, 0xCF, 0xFF, 0xF8, 0x00, 0x0A, 0xFF, 0xFF, 0xE7, 0x20, 0x15, 0xCF, 0xFF, 0xFE, - 0x20, 0x00, 0x1D, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x50, 0x00, 0x00, 0x2D, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFE, 0x50, 0x00, 0x00, 0x01, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE5, 0x00, - 0x00, 0x02, 0xDF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF6, 0x00, 0x00, 0xBF, 0xFF, 0xFF, 0x82, - 0x01, 0x5C, 0xFF, 0xFF, 0xE2, 0x00, 0x4F, 0xFF, 0xFF, 0x40, 0x00, 0x00, 0x0C, 0xFF, 0xFF, 0x90, - 0x09, 0xFF, 0xFF, 0xB0, 0x00, 0x00, 0x00, 0x4F, 0xFF, 0xFE, 0x00, 0xDF, 0xFF, 0xF6, 0x00, 0x00, - 0x00, 0x00, 0xEF, 0xFF, 0xF3, 0x0F, 0xFF, 0xFF, 0x40, 0x00, 0x00, 0x00, 0x0C, 0xFF, 0xFF, 0x51, - 0xFF, 0xFF, 0xF3, 0x00, 0x00, 0x00, 0x00, 0xBF, 0xFF, 0xF6, 0x0F, 0xFF, 0xFF, 0x50, 0x00, 0x00, - 0x00, 0x0D, 0xFF, 0xFF, 0x60, 0xDF, 0xFF, 0xF8, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xF4, 0x0A, - 0xFF, 0xFF, 0xE1, 0x00, 0x00, 0x00, 0x8F, 0xFF, 0xFF, 0x10, 0x5F, 0xFF, 0xFF, 0xA1, 0x00, 0x00, - 0x5F, 0xFF, 0xFF, 0xA0, 0x00, 0xCF, 0xFF, 0xFF, 0xE9, 0x77, 0xBF, 0xFF, 0xFF, 0xF4, 0x00, 0x03, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF9, 0x00, 0x00, 0x05, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFA, 0x00, 0x00, 0x00, 0x03, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE7, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x49, 0xCE, 0xFE, 0xDA, 0x61, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x6A, 0xDE, 0xFE, 0xC8, - 0x30, 0x00, 0x00, 0x00, 0x00, 0x5E, 0xFF, 0xFF, 0xFF, 0xFF, 0xFB, 0x20, 0x00, 0x00, 0x09, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE3, 0x00, 0x00, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, - 0x20, 0x02, 0xFF, 0xFF, 0xFF, 0xC8, 0x78, 0xDF, 0xFF, 0xFF, 0xB0, 0x08, 0xFF, 0xFF, 0xF5, 0x00, - 0x00, 0x09, 0xFF, 0xFF, 0xF3, 0x0D, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, 0xDF, 0xFF, 0xF7, 0x2F, - 0xFF, 0xFF, 0x20, 0x00, 0x00, 0x00, 0x7F, 0xFF, 0xFB, 0x4F, 0xFF, 0xFD, 0x00, 0x00, 0x00, 0x00, - 0x3F, 0xFF, 0xFD, 0x5F, 0xFF, 0xFB, 0x00, 0x00, 0x00, 0x00, 0x2F, 0xFF, 0xFE, 0x5F, 0xFF, 0xFC, - 0x00, 0x00, 0x00, 0x00, 0x3F, 0xFF, 0xFF, 0x4F, 0xFF, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x5F, 0xFF, - 0xFF, 0x2F, 0xFF, 0xFF, 0x50, 0x00, 0x00, 0x00, 0xAF, 0xFF, 0xFF, 0x0D, 0xFF, 0xFF, 0xD1, 0x00, - 0x00, 0x04, 0xFF, 0xFF, 0xFF, 0x07, 0xFF, 0xFF, 0xFD, 0x51, 0x02, 0x7F, 0xFF, 0xFF, 0xFF, 0x01, - 0xDF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x3F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0x00, 0x04, 0xEF, 0xFF, 0xFF, 0xFF, 0xFF, 0xBF, 0xFF, 0xFF, 0x00, 0x00, 0x29, - 0xEF, 0xFF, 0xFF, 0xD6, 0x2F, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x03, 0x66, 0x53, 0x00, 0x2F, 0xFF, - 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2F, 0xFF, 0xFF, 0x01, 0x33, 0x33, 0x00, 0x00, - 0x00, 0x00, 0x2F, 0xFF, 0xFF, 0x09, 0xFF, 0xFF, 0x70, 0x00, 0x00, 0x00, 0x2F, 0xFF, 0xFF, 0x09, - 0xFF, 0xFF, 0x90, 0x00, 0x00, 0x00, 0x4F, 0xFF, 0xFE, 0x08, 0xFF, 0xFF, 0xD0, 0x00, 0x00, 0x00, - 0x9F, 0xFF, 0xFD, 0x05, 0xFF, 0xFF, 0xFA, 0x00, 0x00, 0x07, 0xFF, 0xFF, 0xF9, 0x00, 0xDF, 0xFF, - 0xFF, 0xD8, 0x78, 0xCF, 0xFF, 0xFF, 0xF3, 0x00, 0x5F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0x90, 0x00, 0x06, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFA, 0x00, 0x00, 0x00, 0x4D, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFE, 0x60, 0x00, 0x00, 0x00, 0x00, 0x49, 0xCE, 0xFE, 0xCA, 0x51, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x02, 0xEF, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x7F, 0xFF, 0xFF, 0xFD, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0B, 0xFF, - 0xFF, 0xFF, 0xF3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, - 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6F, 0xFF, 0xFF, 0xFF, 0xFD, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0B, 0xFF, 0xFF, 0xFF, 0xFF, 0xF3, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xFC, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x5F, 0xFF, 0xFC, 0x6F, 0xFF, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0xFF, - 0xFF, 0x71, 0xFF, 0xFF, 0xF2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xEF, 0xFF, 0xF3, 0x0B, - 0xFF, 0xFF, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5F, 0xFF, 0xFD, 0x00, 0x7F, 0xFF, 0xFC, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0xFF, 0xFF, 0x90, 0x02, 0xFF, 0xFF, 0xF2, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xEF, 0xFF, 0xF4, 0x00, 0x0D, 0xFF, 0xFF, 0x60, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x4F, 0xFF, 0xFE, 0x00, 0x00, 0x8F, 0xFF, 0xFB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0xFF, - 0xFF, 0xA0, 0x00, 0x03, 0xFF, 0xFF, 0xF1, 0x00, 0x00, 0x00, 0x00, 0x00, 0xDF, 0xFF, 0xF5, 0x00, - 0x00, 0x0E, 0xFF, 0xFF, 0x60, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xFF, 0xFF, 0x10, 0x00, 0x00, 0x9F, - 0xFF, 0xFB, 0x00, 0x00, 0x00, 0x00, 0x08, 0xFF, 0xFF, 0xB0, 0x00, 0x00, 0x04, 0xFF, 0xFF, 0xF1, - 0x00, 0x00, 0x00, 0x00, 0xDF, 0xFF, 0xF7, 0x00, 0x00, 0x00, 0x0E, 0xFF, 0xFF, 0x50, 0x00, 0x00, - 0x00, 0x3F, 0xFF, 0xFF, 0x20, 0x00, 0x00, 0x00, 0xAF, 0xFF, 0xFA, 0x00, 0x00, 0x00, 0x07, 0xFF, - 0xFF, 0xD0, 0x00, 0x00, 0x00, 0x06, 0xFF, 0xFF, 0xE0, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xFC, 0x66, - 0x66, 0x66, 0x66, 0x8F, 0xFF, 0xFF, 0x50, 0x00, 0x00, 0x2F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xF9, 0x00, 0x00, 0x07, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xE0, 0x00, 0x00, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x40, - 0x00, 0x1F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF9, 0x00, 0x06, 0xFF, - 0xFF, 0xF2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0xFF, 0xFF, 0xD0, 0x00, 0xBF, 0xFF, 0xFC, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x4F, 0xFF, 0xFF, 0x30, 0x1F, 0xFF, 0xFF, 0x70, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xEF, 0xFF, 0xF8, 0x05, 0xFF, 0xFF, 0xF2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x09, 0xFF, 0xFF, 0xD0, 0x9F, 0xFF, 0xFB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4F, 0xFF, - 0xFF, 0x20, 0xBF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xED, 0xB8, 0x30, 0x00, 0x00, 0xCF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFB, 0x30, 0x00, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xF4, 0x00, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x20, 0xCF, 0xFF, - 0xF9, 0x66, 0x66, 0x66, 0x8B, 0xFF, 0xFF, 0xFF, 0xA0, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, - 0x3D, 0xFF, 0xFF, 0xF1, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x02, 0xFF, 0xFF, 0xF4, 0xCF, - 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0xBF, 0xFF, 0xF6, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x8F, 0xFF, 0xF7, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9F, 0xFF, 0xF5, - 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0xDF, 0xFF, 0xF3, 0xCF, 0xFF, 0xF5, 0x00, 0x00, - 0x00, 0x00, 0x08, 0xFF, 0xFF, 0xC0, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x14, 0xBF, 0xFF, 0xFF, - 0x40, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF6, 0x00, 0xCF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0x30, 0x00, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFD, - 0x40, 0x00, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF8, 0x00, 0xCF, 0xFF, 0xF9, - 0x66, 0x66, 0x66, 0x7A, 0xEF, 0xFF, 0xFF, 0x60, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x1B, - 0xFF, 0xFF, 0xE1, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0xDF, 0xFF, 0xF7, 0xCF, 0xFF, - 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6F, 0xFF, 0xFB, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x4F, 0xFF, 0xFD, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4F, 0xFF, 0xFD, 0xCF, - 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6F, 0xFF, 0xFC, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, - 0x00, 0x01, 0xDF, 0xFF, 0xFA, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x1B, 0xFF, 0xFF, 0xF6, - 0xCF, 0xFF, 0xF9, 0x66, 0x66, 0x66, 0x7A, 0xEF, 0xFF, 0xFF, 0xE1, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x50, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF6, - 0x00, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0x30, 0x00, 0xBF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xED, 0xB8, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0xAD, 0xEF, 0xED, 0xA7, 0x20, - 0x00, 0x00, 0x00, 0x00, 0x01, 0x9F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xA2, 0x00, 0x00, 0x00, 0x04, - 0xEF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE4, 0x00, 0x00, 0x03, 0xEF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xF4, 0x00, 0x01, 0xDF, 0xFF, 0xFF, 0xFB, 0x87, 0x8A, 0xFF, 0xFF, 0xFF, 0xE1, - 0x00, 0x8F, 0xFF, 0xFF, 0xB2, 0x00, 0x00, 0x02, 0xBF, 0xFF, 0xFF, 0x90, 0x0E, 0xFF, 0xFF, 0xB0, - 0x00, 0x00, 0x00, 0x00, 0xBF, 0xFF, 0xFE, 0x03, 0xFF, 0xFF, 0xF2, 0x00, 0x00, 0x00, 0x00, 0x02, - 0xFF, 0xFF, 0xF4, 0x6F, 0xFF, 0xFB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0xFF, 0xFF, 0x67, 0xFF, - 0xFF, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9F, 0xFF, 0xF7, 0x8F, 0xFF, 0xF8, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x03, 0x66, 0x66, 0x28, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x8F, 0xFF, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0xFF, 0xFF, 0x80, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8F, 0xFF, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x08, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8F, - 0xFF, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0xFF, 0xFF, 0x80, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8F, 0xFF, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x08, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8F, 0xFF, 0xF8, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x66, 0x66, 0x27, 0xFF, 0xFF, 0x90, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x9F, 0xFF, 0xF7, 0x6F, 0xFF, 0xFB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0xFF, 0xFF, 0x63, - 0xFF, 0xFF, 0xF2, 0x00, 0x00, 0x00, 0x00, 0x02, 0xFF, 0xFF, 0xF4, 0x0E, 0xFF, 0xFF, 0xB0, 0x00, - 0x00, 0x00, 0x00, 0xBF, 0xFF, 0xFE, 0x00, 0x8F, 0xFF, 0xFF, 0xB2, 0x00, 0x00, 0x01, 0xAF, 0xFF, - 0xFF, 0x80, 0x01, 0xDF, 0xFF, 0xFF, 0xFB, 0x87, 0x7A, 0xFF, 0xFF, 0xFF, 0xE1, 0x00, 0x03, 0xEF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF4, 0x00, 0x00, 0x04, 0xEF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xE4, 0x00, 0x00, 0x00, 0x01, 0x9F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xA2, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x17, 0xAD, 0xEF, 0xED, 0xA7, 0x20, 0x00, 0x00, 0x00, 0xBF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xED, 0xA6, 0x10, 0x00, 0x00, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF9, - 0x10, 0x00, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xD3, 0x00, 0xCF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0x20, 0xCF, 0xFF, 0xF9, 0x66, 0x66, 0x66, 0x7B, 0xFF, - 0xFF, 0xFF, 0xB0, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x3D, 0xFF, 0xFF, 0xF4, 0xCF, 0xFF, - 0xF5, 0x00, 0x00, 0x00, 0x00, 0x02, 0xFF, 0xFF, 0xF9, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x9F, 0xFF, 0xFC, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5F, 0xFF, 0xFE, 0xCF, - 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xFF, 0xFE, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x2F, 0xFF, 0xFE, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2F, 0xFF, 0xFE, - 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2F, 0xFF, 0xFE, 0xCF, 0xFF, 0xF5, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x2F, 0xFF, 0xFE, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2F, 0xFF, - 0xFE, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2F, 0xFF, 0xFE, 0xCF, 0xFF, 0xF5, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x2F, 0xFF, 0xFE, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2F, - 0xFF, 0xFE, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2F, 0xFF, 0xFE, 0xCF, 0xFF, 0xF5, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x2F, 0xFF, 0xFE, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x2F, 0xFF, 0xFE, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xFF, 0xFE, 0xCF, 0xFF, - 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5F, 0xFF, 0xFE, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x9F, 0xFF, 0xFC, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xF9, 0xCF, - 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x3D, 0xFF, 0xFF, 0xF4, 0xCF, 0xFF, 0xF9, 0x66, 0x66, 0x66, - 0x7B, 0xFF, 0xFF, 0xFF, 0xC0, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0x20, - 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xD3, 0x00, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xF9, 0x10, 0x00, 0xBF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xED, 0xA7, 0x10, 0x00, - 0x00, 0xBF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE0, 0xCF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF1, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xF1, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF1, 0xCF, 0xFF, 0xF9, - 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x60, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, - 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, - 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x10, 0x00, 0x00, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0x20, 0x00, 0x00, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x20, 0x00, - 0x00, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x20, 0x00, 0x00, 0xCF, 0xFF, 0xF9, 0x66, - 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, - 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, - 0xFF, 0xF9, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x60, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xF1, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF1, - 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF1, 0xBF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE0, 0xBF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xE0, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0xCF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xF0, 0xCF, 0xFF, 0xF9, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x50, 0xCF, 0xFF, 0xF5, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, - 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, - 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x10, 0x00, 0x00, - 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x20, 0x00, 0x00, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0x20, 0x00, 0x00, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x20, 0x00, - 0x00, 0xCF, 0xFF, 0xF9, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, - 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, - 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xBF, 0xFF, 0xF4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0xAD, - 0xEF, 0xED, 0xA6, 0x10, 0x00, 0x00, 0x00, 0x00, 0x01, 0x9F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x91, - 0x00, 0x00, 0x00, 0x03, 0xEF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE4, 0x00, 0x00, 0x03, 0xEF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF4, 0x00, 0x01, 0xDF, 0xFF, 0xFF, 0xFB, 0x87, 0x7A, - 0xEF, 0xFF, 0xFF, 0xE1, 0x00, 0x7F, 0xFF, 0xFF, 0xB2, 0x00, 0x00, 0x01, 0xAF, 0xFF, 0xFF, 0x90, - 0x0D, 0xFF, 0xFF, 0xB0, 0x00, 0x00, 0x00, 0x00, 0xAF, 0xFF, 0xFE, 0x13, 0xFF, 0xFF, 0xF2, 0x00, - 0x00, 0x00, 0x00, 0x01, 0xEF, 0xFF, 0xF4, 0x6F, 0xFF, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0B, - 0xFF, 0xFF, 0x67, 0xFF, 0xFF, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9F, 0xFF, 0xF7, 0x8F, 0xFF, - 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x33, 0x33, 0x18, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x8F, 0xFF, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x08, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8F, 0xFF, 0xF8, 0x00, - 0x00, 0x0A, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x68, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0xBF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xF7, 0x8F, 0xFF, 0xF8, 0x00, 0x00, 0x0B, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x78, 0xFF, - 0xFF, 0x80, 0x00, 0x00, 0xBF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF7, 0x8F, 0xFF, 0xF8, 0x00, 0x00, 0x04, - 0x66, 0x66, 0x6C, 0xFF, 0xFF, 0x78, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9F, 0xFF, - 0xF7, 0x8F, 0xFF, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0xFF, 0xFF, 0x77, 0xFF, 0xFF, 0x90, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x9F, 0xFF, 0xF6, 0x6F, 0xFF, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x0B, 0xFF, 0xFF, 0x43, 0xFF, 0xFF, 0xF3, 0x00, 0x00, 0x00, 0x00, 0x01, 0xEF, 0xFF, 0xF1, 0x0D, - 0xFF, 0xFF, 0xC1, 0x00, 0x00, 0x00, 0x00, 0x8F, 0xFF, 0xFC, 0x00, 0x7F, 0xFF, 0xFF, 0xC3, 0x00, - 0x00, 0x00, 0x8F, 0xFF, 0xFF, 0x50, 0x01, 0xDF, 0xFF, 0xFF, 0xFB, 0x87, 0x79, 0xEF, 0xFF, 0xFF, - 0xC0, 0x00, 0x03, 0xEF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE2, 0x00, 0x00, 0x03, 0xEF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xD3, 0x00, 0x00, 0x00, 0x01, 0x9F, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0x91, 0x00, 0x00, 0x00, 0x00, 0x00, 0x17, 0xAD, 0xEF, 0xED, 0xA6, 0x10, 0x00, 0x00, 0x00, - 0xAF, 0xFF, 0xF4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0E, 0xFF, 0xFE, 0x1C, 0xFF, 0xFF, 0x50, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xF1, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, - 0xFF, 0xFF, 0x1C, 0xFF, 0xFF, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xF1, 0xCF, 0xFF, - 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFF, 0x1C, 0xFF, 0xFF, 0x50, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xFF, 0xFF, 0xF1, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFF, - 0x1C, 0xFF, 0xFF, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xF1, 0xCF, 0xFF, 0xF5, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFF, 0x1C, 0xFF, 0xFF, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xFF, 0xFF, 0xF1, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFF, 0x1C, 0xFF, - 0xFF, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xF1, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x1F, 0xFF, 0xFF, 0x1C, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xF1, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x1C, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF1, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0x1C, 0xFF, 0xFF, 0x96, 0x66, 0x66, 0x66, 0x66, 0x67, 0xFF, 0xFF, 0xF1, 0xCF, - 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFF, 0x1C, 0xFF, 0xFF, 0x50, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xF1, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, - 0xFF, 0x1C, 0xFF, 0xFF, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xF1, 0xCF, 0xFF, 0xF5, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFF, 0x1C, 0xFF, 0xFF, 0x50, 0x00, 0x00, 0x00, 0x00, - 0x00, 0xFF, 0xFF, 0xF1, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFF, 0x1C, - 0xFF, 0xFF, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xF1, 0xCF, 0xFF, 0xF5, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFF, 0x1C, 0xFF, 0xFF, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, - 0xFF, 0xF1, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFF, 0x1C, 0xFF, 0xFF, - 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xF1, 0xBF, 0xFF, 0xF4, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x0E, 0xFF, 0xFE, 0x10, 0xBF, 0xFF, 0xF4, 0xCF, 0xFF, 0xF5, 0xCF, 0xFF, 0xF5, 0xCF, 0xFF, - 0xF5, 0xCF, 0xFF, 0xF5, 0xCF, 0xFF, 0xF5, 0xCF, 0xFF, 0xF5, 0xCF, 0xFF, 0xF5, 0xCF, 0xFF, 0xF5, - 0xCF, 0xFF, 0xF5, 0xCF, 0xFF, 0xF5, 0xCF, 0xFF, 0xF5, 0xCF, 0xFF, 0xF5, 0xCF, 0xFF, 0xF5, 0xCF, - 0xFF, 0xF5, 0xCF, 0xFF, 0xF5, 0xCF, 0xFF, 0xF5, 0xCF, 0xFF, 0xF5, 0xCF, 0xFF, 0xF5, 0xCF, 0xFF, - 0xF5, 0xCF, 0xFF, 0xF5, 0xCF, 0xFF, 0xF5, 0xCF, 0xFF, 0xF5, 0xCF, 0xFF, 0xF5, 0xCF, 0xFF, 0xF5, - 0xCF, 0xFF, 0xF5, 0xCF, 0xFF, 0xF5, 0xCF, 0xFF, 0xF5, 0xCF, 0xFF, 0xF5, 0xCF, 0xFF, 0xF5, 0xBF, - 0xFF, 0xF4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0xFF, 0xFF, 0x40, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xBF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x0B, 0xFF, 0xFF, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xBF, 0xFF, 0xF5, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0B, 0xFF, 0xFF, 0x50, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xBF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0B, - 0xFF, 0xFF, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xBF, 0xFF, 0xF5, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0B, 0xFF, 0xFF, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xBF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0B, 0xFF, 0xFF, - 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xBF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x0B, 0xFF, 0xFF, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xBF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0B, 0xFF, 0xFF, 0x50, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xBF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x0B, 0xFF, 0xFF, 0x50, 0x23, 0x33, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0xBF, 0xFF, - 0xF5, 0x0F, 0xFF, 0xFF, 0x10, 0x00, 0x00, 0x00, 0x00, 0x0B, 0xFF, 0xFF, 0x50, 0xFF, 0xFF, 0xF1, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xBF, 0xFF, 0xF5, 0x0F, 0xFF, 0xFF, 0x10, 0x00, 0x00, 0x00, 0x00, - 0x0B, 0xFF, 0xFF, 0x50, 0xFF, 0xFF, 0xF1, 0x00, 0x00, 0x00, 0x00, 0x00, 0xBF, 0xFF, 0xF5, 0x0E, - 0xFF, 0xFF, 0x30, 0x00, 0x00, 0x00, 0x00, 0x0D, 0xFF, 0xFF, 0x40, 0xCF, 0xFF, 0xF8, 0x00, 0x00, - 0x00, 0x00, 0x02, 0xFF, 0xFF, 0xF2, 0x08, 0xFF, 0xFF, 0xE2, 0x00, 0x00, 0x00, 0x00, 0xBF, 0xFF, - 0xFD, 0x00, 0x3F, 0xFF, 0xFF, 0xD3, 0x00, 0x00, 0x02, 0xBF, 0xFF, 0xFF, 0x70, 0x00, 0xAF, 0xFF, - 0xFF, 0xFC, 0x87, 0x7A, 0xFF, 0xFF, 0xFF, 0xD1, 0x00, 0x01, 0xDF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xE3, 0x00, 0x00, 0x02, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE4, 0x00, 0x00, - 0x00, 0x00, 0x7E, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xA2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0xAD, - 0xEF, 0xED, 0xB7, 0x20, 0x00, 0x00, 0x00, 0xBF, 0xFF, 0xF4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3E, - 0xFF, 0xFF, 0x80, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x01, 0xDF, 0xFF, 0xFD, 0x10, 0xCF, - 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x1C, 0xFF, 0xFF, 0xE2, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, - 0x00, 0x00, 0xAF, 0xFF, 0xFF, 0x40, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x08, 0xFF, 0xFF, - 0xF7, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x5F, 0xFF, 0xFF, 0xA0, 0x00, 0x00, 0xCF, - 0xFF, 0xF5, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xFC, 0x10, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, - 0x2E, 0xFF, 0xFF, 0xE2, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x01, 0xCF, 0xFF, 0xFF, 0x40, - 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x0B, 0xFF, 0xFF, 0xF6, 0x00, 0x00, 0x00, 0x00, 0xCF, - 0xFF, 0xF5, 0x00, 0x8F, 0xFF, 0xFF, 0x90, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x06, 0xFF, - 0xFF, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x4F, 0xFF, 0xFF, 0xD1, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF7, 0xEF, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF2, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFB, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x60, 0x00, - 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xFF, 0xFF, 0x4B, 0xFF, 0xFF, 0xE1, 0x00, 0x00, 0x00, 0x00, 0xCF, - 0xFF, 0xFF, 0xF5, 0x02, 0xEF, 0xFF, 0xFA, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xFF, 0x80, 0x00, - 0x7F, 0xFF, 0xFF, 0x50, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xFA, 0x00, 0x00, 0x0C, 0xFF, 0xFF, 0xD1, - 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xF9, 0x00, 0x00, 0x00, 0xCF, - 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x8F, 0xFF, 0xFF, 0x40, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, - 0x00, 0x0D, 0xFF, 0xFF, 0xD0, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x04, 0xFF, 0xFF, - 0xF8, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x9F, 0xFF, 0xFF, 0x30, 0x00, 0xCF, - 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x1E, 0xFF, 0xFF, 0xC0, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, - 0x00, 0x00, 0x05, 0xFF, 0xFF, 0xF6, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0xAF, - 0xFF, 0xFE, 0x20, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2E, 0xFF, 0xFF, 0xB0, 0xBF, - 0xFF, 0xF4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0xFF, 0xFF, 0xF3, 0xBF, 0xFF, 0xF4, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0xFF, 0xFF, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0xFF, 0xFF, 0x50, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, - 0xFF, 0xFF, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x0C, 0xFF, 0xFF, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, - 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0xFF, 0xFF, 0x50, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0xFF, - 0xFF, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x0C, 0xFF, 0xFF, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, - 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0xFF, 0xFF, 0x50, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0xFF, 0xFF, - 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x0C, 0xFF, 0xFF, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0xFF, 0xFF, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0xFF, 0xFF, 0x50, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x0C, 0xFF, 0xFF, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF9, 0x66, - 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x4C, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFC, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xCC, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xBF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xB0, 0xBF, 0xFF, 0xF7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xEF, 0xFF, 0xF3, 0xCF, 0xFF, - 0xFF, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0xFF, 0xFF, 0xF4, 0xCF, 0xFF, 0xFF, 0xC0, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x5F, 0xFF, 0xFF, 0xF4, 0xCF, 0xFF, 0xFF, 0xF7, 0x00, 0x00, 0x00, 0x00, - 0x01, 0xEF, 0xFF, 0xFF, 0xF4, 0xCF, 0xFF, 0xFF, 0xFF, 0x20, 0x00, 0x00, 0x00, 0x0A, 0xFF, 0xFF, - 0xFF, 0xF4, 0xCF, 0xFF, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, 0x5F, 0xFF, 0xFF, 0xFF, 0xF4, 0xCF, - 0xFF, 0xFF, 0xFF, 0xF6, 0x00, 0x00, 0x01, 0xEF, 0xFF, 0xFF, 0xFF, 0xF4, 0xCF, 0xFF, 0xFF, 0xFF, - 0xFE, 0x20, 0x00, 0x09, 0xFF, 0xFF, 0xFF, 0xFF, 0xF4, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xB0, 0x00, - 0x4F, 0xFF, 0xFF, 0xFF, 0xFF, 0xF4, 0xCF, 0xFF, 0xFA, 0xFF, 0xFF, 0xF6, 0x01, 0xDF, 0xFF, 0xFB, - 0xDF, 0xFF, 0xF4, 0xCF, 0xFF, 0xF5, 0xAF, 0xFF, 0xFE, 0x29, 0xFF, 0xFF, 0xE2, 0xDF, 0xFF, 0xF4, - 0xCF, 0xFF, 0xF5, 0x1E, 0xFF, 0xFF, 0xDF, 0xFF, 0xFF, 0x60, 0xDF, 0xFF, 0xF4, 0xCF, 0xFF, 0xF5, - 0x05, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0x00, 0xDF, 0xFF, 0xF4, 0xCF, 0xFF, 0xF5, 0x00, 0xAF, 0xFF, - 0xFF, 0xFF, 0xF2, 0x00, 0xDF, 0xFF, 0xF4, 0xCF, 0xFF, 0xF5, 0x00, 0x1E, 0xFF, 0xFF, 0xFF, 0x70, - 0x00, 0xDF, 0xFF, 0xF4, 0xCF, 0xFF, 0xF5, 0x00, 0x05, 0xFF, 0xFF, 0xFC, 0x00, 0x00, 0xDF, 0xFF, - 0xF4, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0xBF, 0xFF, 0xF3, 0x00, 0x00, 0xDF, 0xFF, 0xF4, 0xCF, 0xFF, - 0xF5, 0x00, 0x00, 0x2E, 0xFF, 0x80, 0x00, 0x00, 0xDF, 0xFF, 0xF4, 0xCF, 0xFF, 0xF5, 0x00, 0x00, - 0x01, 0x22, 0x00, 0x00, 0x00, 0xDF, 0xFF, 0xF4, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xDF, 0xFF, 0xF4, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xDF, - 0xFF, 0xF4, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xDF, 0xFF, 0xF4, 0xCF, - 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xDF, 0xFF, 0xF4, 0xCF, 0xFF, 0xF5, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xDF, 0xFF, 0xF4, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xDF, 0xFF, 0xF4, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xDF, 0xFF, 0xF4, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xDF, 0xFF, 0xF4, - 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xDF, 0xFF, 0xF4, 0xCF, 0xFF, 0xF5, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xDF, 0xFF, 0xF4, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xDF, 0xFF, 0xF4, 0xBF, 0xFF, 0xF4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0xCF, 0xFF, 0xF3, 0xBF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF2, - 0xCF, 0xFF, 0xFE, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0xDF, 0xFF, 0xF3, 0xCF, 0xFF, 0xFF, 0x80, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xDF, 0xFF, 0xF3, 0xCF, 0xFF, 0xFF, 0xF3, 0x00, 0x00, 0x00, 0x00, - 0x00, 0xDF, 0xFF, 0xF3, 0xCF, 0xFF, 0xFF, 0xFB, 0x00, 0x00, 0x00, 0x00, 0x00, 0xDF, 0xFF, 0xF3, - 0xCF, 0xFF, 0xFF, 0xFF, 0x60, 0x00, 0x00, 0x00, 0x00, 0xDF, 0xFF, 0xF3, 0xCF, 0xFF, 0xFF, 0xFF, - 0xE1, 0x00, 0x00, 0x00, 0x00, 0xDF, 0xFF, 0xF3, 0xCF, 0xFF, 0xFF, 0xFF, 0xF9, 0x00, 0x00, 0x00, - 0x00, 0xDF, 0xFF, 0xF3, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0x30, 0x00, 0x00, 0x00, 0xDF, 0xFF, 0xF3, - 0xCF, 0xFF, 0xFE, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, 0xDF, 0xFF, 0xF3, 0xCF, 0xFF, 0xF5, 0xEF, - 0xFF, 0xF6, 0x00, 0x00, 0x00, 0xDF, 0xFF, 0xF3, 0xCF, 0xFF, 0xF4, 0x7F, 0xFF, 0xFE, 0x10, 0x00, - 0x00, 0xDF, 0xFF, 0xF3, 0xCF, 0xFF, 0xF4, 0x0C, 0xFF, 0xFF, 0x90, 0x00, 0x00, 0xDF, 0xFF, 0xF3, - 0xCF, 0xFF, 0xF4, 0x04, 0xFF, 0xFF, 0xF3, 0x00, 0x00, 0xDF, 0xFF, 0xF3, 0xCF, 0xFF, 0xF4, 0x00, - 0x9F, 0xFF, 0xFC, 0x00, 0x00, 0xDF, 0xFF, 0xF3, 0xCF, 0xFF, 0xF4, 0x00, 0x1E, 0xFF, 0xFF, 0x60, - 0x00, 0xDF, 0xFF, 0xF3, 0xCF, 0xFF, 0xF4, 0x00, 0x06, 0xFF, 0xFF, 0xE1, 0x00, 0xDF, 0xFF, 0xF3, - 0xCF, 0xFF, 0xF4, 0x00, 0x00, 0xCF, 0xFF, 0xFA, 0x00, 0xDF, 0xFF, 0xF3, 0xCF, 0xFF, 0xF4, 0x00, - 0x00, 0x3F, 0xFF, 0xFF, 0x40, 0xDF, 0xFF, 0xF3, 0xCF, 0xFF, 0xF4, 0x00, 0x00, 0x09, 0xFF, 0xFF, - 0xC0, 0xDF, 0xFF, 0xF3, 0xCF, 0xFF, 0xF4, 0x00, 0x00, 0x01, 0xEF, 0xFF, 0xF7, 0xDF, 0xFF, 0xF3, - 0xCF, 0xFF, 0xF4, 0x00, 0x00, 0x00, 0x6F, 0xFF, 0xFE, 0xEF, 0xFF, 0xF3, 0xCF, 0xFF, 0xF4, 0x00, - 0x00, 0x00, 0x0C, 0xFF, 0xFF, 0xFF, 0xFF, 0xF3, 0xCF, 0xFF, 0xF4, 0x00, 0x00, 0x00, 0x03, 0xFF, - 0xFF, 0xFF, 0xFF, 0xF3, 0xCF, 0xFF, 0xF4, 0x00, 0x00, 0x00, 0x00, 0x9F, 0xFF, 0xFF, 0xFF, 0xF3, - 0xCF, 0xFF, 0xF4, 0x00, 0x00, 0x00, 0x00, 0x1E, 0xFF, 0xFF, 0xFF, 0xF3, 0xCF, 0xFF, 0xF4, 0x00, - 0x00, 0x00, 0x00, 0x05, 0xFF, 0xFF, 0xFF, 0xF3, 0xCF, 0xFF, 0xF4, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xBF, 0xFF, 0xFF, 0xF3, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2F, 0xFF, 0xFF, 0xF3, - 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0xFF, 0xFF, 0xF3, 0xBF, 0xFF, 0xF4, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x01, 0xDF, 0xFF, 0xF2, 0x00, 0x00, 0x00, 0x15, 0xAC, 0xEF, 0xED, 0xB7, - 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xA2, 0x00, 0x00, 0x00, - 0x02, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE5, 0x00, 0x00, 0x02, 0xDF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xF5, 0x00, 0x00, 0xBF, 0xFF, 0xFF, 0xFB, 0x87, 0x7A, 0xEF, 0xFF, 0xFF, - 0xE2, 0x00, 0x5F, 0xFF, 0xFF, 0xC3, 0x00, 0x00, 0x01, 0x9F, 0xFF, 0xFF, 0xA0, 0x0C, 0xFF, 0xFF, - 0xD1, 0x00, 0x00, 0x00, 0x00, 0x9F, 0xFF, 0xFF, 0x22, 0xFF, 0xFF, 0xF4, 0x00, 0x00, 0x00, 0x00, - 0x01, 0xEF, 0xFF, 0xF7, 0x5F, 0xFF, 0xFD, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0xFF, 0xFF, 0xA7, - 0xFF, 0xFF, 0xA0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5F, 0xFF, 0xFC, 0x8F, 0xFF, 0xF9, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x04, 0xFF, 0xFF, 0xD8, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4F, - 0xFF, 0xFD, 0x8F, 0xFF, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0xFF, 0xFF, 0xD8, 0xFF, 0xFF, - 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4F, 0xFF, 0xFD, 0x8F, 0xFF, 0xF8, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x04, 0xFF, 0xFF, 0xD8, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4F, 0xFF, 0xFD, - 0x8F, 0xFF, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0xFF, 0xFF, 0xD8, 0xFF, 0xFF, 0x80, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x4F, 0xFF, 0xFD, 0x8F, 0xFF, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, - 0xFF, 0xFF, 0xD8, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4F, 0xFF, 0xFD, 0x8F, 0xFF, - 0xF9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0xFF, 0xFF, 0xD7, 0xFF, 0xFF, 0xA0, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x5F, 0xFF, 0xFC, 0x5F, 0xFF, 0xFD, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0xFF, 0xFF, - 0xA2, 0xFF, 0xFF, 0xF4, 0x00, 0x00, 0x00, 0x00, 0x01, 0xEF, 0xFF, 0xF7, 0x0C, 0xFF, 0xFF, 0xD1, - 0x00, 0x00, 0x00, 0x00, 0x9F, 0xFF, 0xFF, 0x20, 0x6F, 0xFF, 0xFF, 0xC3, 0x00, 0x00, 0x01, 0x9F, - 0xFF, 0xFF, 0xA0, 0x00, 0xCF, 0xFF, 0xFF, 0xFB, 0x87, 0x7A, 0xEF, 0xFF, 0xFF, 0xE2, 0x00, 0x02, - 0xDF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF5, 0x00, 0x00, 0x02, 0xDF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xE5, 0x00, 0x00, 0x00, 0x01, 0x8E, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xA2, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x16, 0xAD, 0xEF, 0xED, 0xB7, 0x20, 0x00, 0x00, 0x00, 0x0E, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xEC, 0x94, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFC, 0x20, 0x00, 0x1F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0x40, 0x01, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0x20, 0x1F, 0xFF, 0xFF, 0x76, 0x66, - 0x66, 0x67, 0xAF, 0xFF, 0xFF, 0xFB, 0x01, 0xFF, 0xFF, 0xF1, 0x00, 0x00, 0x00, 0x00, 0x2C, 0xFF, - 0xFF, 0xF3, 0x1F, 0xFF, 0xFF, 0x10, 0x00, 0x00, 0x00, 0x00, 0x1E, 0xFF, 0xFF, 0x81, 0xFF, 0xFF, - 0xF1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8F, 0xFF, 0xFB, 0x1F, 0xFF, 0xFF, 0x10, 0x00, 0x00, 0x00, - 0x00, 0x04, 0xFF, 0xFF, 0xD1, 0xFF, 0xFF, 0xF1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xFF, 0xFD, - 0x1F, 0xFF, 0xFF, 0x10, 0x00, 0x00, 0x00, 0x00, 0x05, 0xFF, 0xFF, 0xC1, 0xFF, 0xFF, 0xF1, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xBF, 0xFF, 0xFA, 0x1F, 0xFF, 0xFF, 0x10, 0x00, 0x00, 0x00, 0x00, 0x6F, - 0xFF, 0xFF, 0x61, 0xFF, 0xFF, 0xF1, 0x00, 0x00, 0x00, 0x13, 0xAF, 0xFF, 0xFF, 0xE1, 0x1F, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF6, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xF9, 0x00, 0x1F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF7, 0x00, - 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xA3, 0x00, 0x00, 0x1F, 0xFF, 0xFF, 0x76, - 0x66, 0x66, 0x66, 0x53, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xF1, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x1F, 0xFF, 0xFF, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, - 0xFF, 0xF1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0xFF, 0xFF, 0x10, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xF1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x1F, 0xFF, 0xFF, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xF1, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0xFF, 0xFF, 0x10, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xF1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, - 0xFF, 0xFF, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xF1, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0E, 0xFF, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0xCE, 0xFF, 0xDB, 0x72, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xA2, 0x00, 0x00, 0x00, 0x07, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFE, 0x40, 0x00, 0x00, 0x6F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF4, 0x00, 0x03, 0xFF, - 0xFF, 0xFF, 0xD9, 0x77, 0xAE, 0xFF, 0xFF, 0xFE, 0x10, 0x0C, 0xFF, 0xFF, 0xF7, 0x00, 0x00, 0x01, - 0x9F, 0xFF, 0xFF, 0x90, 0x3F, 0xFF, 0xFF, 0x60, 0x00, 0x00, 0x00, 0x09, 0xFF, 0xFF, 0xF1, 0x8F, - 0xFF, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x01, 0xEF, 0xFF, 0xF5, 0xBF, 0xFF, 0xF6, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x9F, 0xFF, 0xF8, 0xDF, 0xFF, 0xF4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6F, 0xFF, 0xFA, - 0xEF, 0xFF, 0xF3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5F, 0xFF, 0xFB, 0xEF, 0xFF, 0xF3, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x5F, 0xFF, 0xFC, 0xEF, 0xFF, 0xF3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5F, 0xFF, - 0xFC, 0xEF, 0xFF, 0xF3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5F, 0xFF, 0xFC, 0xEF, 0xFF, 0xF3, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x5F, 0xFF, 0xFC, 0xEF, 0xFF, 0xF3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5F, - 0xFF, 0xFC, 0xEF, 0xFF, 0xF3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5F, 0xFF, 0xFC, 0xEF, 0xFF, 0xF3, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x5F, 0xFF, 0xFC, 0xEF, 0xFF, 0xF3, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x5F, 0xFF, 0xFC, 0xEF, 0xFF, 0xF3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5F, 0xFF, 0xFC, 0xEF, 0xFF, - 0xF3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5F, 0xFF, 0xFC, 0xEF, 0xFF, 0xF3, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x6F, 0xFF, 0xFB, 0xDF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8F, 0xFF, 0xFA, 0xBF, - 0xFF, 0xF9, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF8, 0x7F, 0xFF, 0xFF, 0x20, 0x00, 0x00, - 0x00, 0x04, 0xFF, 0xFF, 0xF5, 0x2F, 0xFF, 0xFF, 0xD2, 0x00, 0x00, 0x00, 0x3E, 0xFF, 0xFF, 0xE1, - 0x0A, 0xFF, 0xFF, 0xFE, 0x72, 0x01, 0x38, 0xFF, 0xFF, 0xFF, 0x70, 0x02, 0xEF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0x00, 0x00, 0x4E, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xD2, - 0x00, 0x00, 0x03, 0xDF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0x20, 0x00, 0x00, 0x00, 0x17, 0xEF, - 0xFF, 0xFF, 0xFF, 0xFD, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xCF, 0xFF, 0xFA, 0x20, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9F, 0xFF, 0xF7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x9F, 0xFF, 0xF7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9F, 0xFF, 0xF7, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8F, 0xFF, 0xF6, 0x00, 0x00, 0x00, 0x00, 0xBF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xDA, 0x50, 0x00, 0x00, 0x0C, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xD3, 0x00, 0x00, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF5, 0x00, - 0x0C, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE2, 0x00, 0xCF, 0xFF, 0xF9, 0x66, - 0x66, 0x66, 0x79, 0xEF, 0xFF, 0xFF, 0xC0, 0x0C, 0xFF, 0xFF, 0x50, 0x00, 0x00, 0x00, 0x01, 0xAF, - 0xFF, 0xFF, 0x40, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF9, 0x0C, 0xFF, - 0xFF, 0x50, 0x00, 0x00, 0x00, 0x00, 0x06, 0xFF, 0xFF, 0xC0, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x3F, 0xFF, 0xFE, 0x0C, 0xFF, 0xFF, 0x50, 0x00, 0x00, 0x00, 0x00, 0x03, 0xFF, 0xFF, - 0xE0, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6F, 0xFF, 0xFD, 0x0C, 0xFF, 0xFF, 0x50, - 0x00, 0x00, 0x00, 0x00, 0x0C, 0xFF, 0xFF, 0xA0, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x1A, - 0xFF, 0xFF, 0xF6, 0x0C, 0xFF, 0xFF, 0x96, 0x66, 0x66, 0x67, 0x9E, 0xFF, 0xFF, 0xFE, 0x10, 0xCF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x50, 0x0C, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0x80, 0x00, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0x50, - 0x00, 0x0C, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF6, 0x10, 0x00, 0x00, 0xCF, 0xFF, 0xF5, - 0x00, 0x00, 0x0C, 0xFF, 0xFF, 0x40, 0x00, 0x00, 0x0C, 0xFF, 0xFF, 0x50, 0x00, 0x00, 0x5F, 0xFF, - 0xFB, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF4, 0x00, 0x00, 0x0C, - 0xFF, 0xFF, 0x50, 0x00, 0x00, 0x06, 0xFF, 0xFF, 0xB0, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, - 0x00, 0x0D, 0xFF, 0xFF, 0x30, 0x00, 0x0C, 0xFF, 0xFF, 0x50, 0x00, 0x00, 0x00, 0x7F, 0xFF, 0xFB, - 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x01, 0xEF, 0xFF, 0xF3, 0x00, 0x0C, 0xFF, 0xFF, - 0x50, 0x00, 0x00, 0x00, 0x08, 0xFF, 0xFF, 0xB0, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, - 0x1E, 0xFF, 0xFF, 0x30, 0x0C, 0xFF, 0xFF, 0x50, 0x00, 0x00, 0x00, 0x00, 0x8F, 0xFF, 0xFA, 0x00, - 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x02, 0xFF, 0xFF, 0xF3, 0x0C, 0xFF, 0xFF, 0x50, 0x00, - 0x00, 0x00, 0x00, 0x09, 0xFF, 0xFF, 0xA0, 0xBF, 0xFF, 0xF4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2E, - 0xFF, 0xFF, 0x20, 0x00, 0x00, 0x00, 0x17, 0xAD, 0xEF, 0xED, 0xB8, 0x30, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x1A, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFD, 0x50, 0x00, 0x00, 0x00, 0x03, 0xEF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFA, 0x10, 0x00, 0x00, 0x3E, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xB0, 0x00, 0x00, 0xCF, 0xFF, 0xFF, 0xEA, 0x77, 0x7A, 0xEF, 0xFF, 0xFF, 0xF8, 0x00, 0x03, - 0xFF, 0xFF, 0xF9, 0x10, 0x00, 0x00, 0x06, 0xEF, 0xFF, 0xFF, 0x20, 0x07, 0xFF, 0xFF, 0xC0, 0x00, - 0x00, 0x00, 0x00, 0x4F, 0xFF, 0xFF, 0x70, 0x09, 0xFF, 0xFF, 0x60, 0x00, 0x00, 0x00, 0x00, 0x09, - 0xFF, 0xFF, 0xB0, 0x0A, 0xFF, 0xFF, 0x60, 0x00, 0x00, 0x00, 0x00, 0x04, 0xFF, 0xFF, 0xC0, 0x08, - 0xFF, 0xFF, 0x90, 0x00, 0x00, 0x00, 0x00, 0x02, 0xFF, 0xFF, 0xC0, 0x05, 0xFF, 0xFF, 0xF4, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x33, 0x33, 0x20, 0x00, 0xEF, 0xFF, 0xFF, 0x81, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x5F, 0xFF, 0xFF, 0xFE, 0x93, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x06, 0xFF, 0xFF, 0xFF, 0xFF, 0xD7, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4D, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFB, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x7D, 0xFF, 0xFF, 0xFF, 0xFF, 0xFD, - 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5B, 0xFF, 0xFF, 0xFF, 0xFF, 0xFB, 0x10, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x27, 0xDF, 0xFF, 0xFF, 0xFF, 0xD1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x04, 0xBF, 0xFF, 0xFF, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0xDF, - 0xFF, 0xFF, 0x60, 0x05, 0x55, 0x53, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, 0xFF, 0xFF, 0xC0, 0x2F, - 0xFF, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0xFF, 0xFF, 0xF0, 0x2F, 0xFF, 0xFD, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xF1, 0x1F, 0xFF, 0xFF, 0x20, 0x00, 0x00, 0x00, 0x00, 0x03, - 0xFF, 0xFF, 0xE0, 0x0D, 0xFF, 0xFF, 0xC1, 0x00, 0x00, 0x00, 0x00, 0x09, 0xFF, 0xFF, 0xC0, 0x08, - 0xFF, 0xFF, 0xFC, 0x30, 0x00, 0x00, 0x00, 0x8F, 0xFF, 0xFF, 0x80, 0x01, 0xEF, 0xFF, 0xFF, 0xFD, - 0x97, 0x77, 0x9E, 0xFF, 0xFF, 0xFE, 0x10, 0x00, 0x4F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xF5, 0x00, 0x00, 0x04, 0xEF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x60, 0x00, 0x00, - 0x00, 0x19, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xB2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x9C, - 0xEF, 0xFE, 0xDA, 0x72, 0x00, 0x00, 0x00, 0x6F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xE8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x8F, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF7, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x26, 0x66, 0x66, 0x66, 0x6F, 0xFF, 0xFF, 0x86, 0x66, 0x66, 0x66, - 0x50, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xF2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x0F, 0xFF, 0xFF, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xF2, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFF, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xF2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, - 0xFF, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xF2, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFF, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0xFF, 0xFF, 0xF2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFF, 0x20, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xF2, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFF, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, - 0xFF, 0xF2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFF, 0x20, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xF2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x0F, 0xFF, 0xFF, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xF2, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFF, 0x20, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xF2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, - 0xFF, 0xFF, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xF2, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFF, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xFF, 0xFF, 0xF2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFF, - 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xF2, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x0D, 0xFF, 0xFF, 0x10, 0x00, 0x00, 0x00, 0x00, 0x0E, 0xFF, 0xFE, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xEF, 0xFF, 0xE0, 0x1F, 0xFF, 0xFF, 0x10, 0x00, 0x00, 0x00, 0x00, - 0x01, 0xFF, 0xFF, 0xF0, 0x1F, 0xFF, 0xFF, 0x10, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xF0, - 0x1F, 0xFF, 0xFF, 0x10, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xF0, 0x1F, 0xFF, 0xFF, 0x10, - 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xF0, 0x1F, 0xFF, 0xFF, 0x10, 0x00, 0x00, 0x00, 0x00, - 0x01, 0xFF, 0xFF, 0xF0, 0x1F, 0xFF, 0xFF, 0x10, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xF0, - 0x1F, 0xFF, 0xFF, 0x10, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xF0, 0x1F, 0xFF, 0xFF, 0x10, - 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xF0, 0x1F, 0xFF, 0xFF, 0x10, 0x00, 0x00, 0x00, 0x00, - 0x01, 0xFF, 0xFF, 0xF0, 0x1F, 0xFF, 0xFF, 0x10, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xF0, - 0x1F, 0xFF, 0xFF, 0x10, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xF0, 0x1F, 0xFF, 0xFF, 0x10, - 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xF0, 0x1F, 0xFF, 0xFF, 0x10, 0x00, 0x00, 0x00, 0x00, - 0x01, 0xFF, 0xFF, 0xF0, 0x1F, 0xFF, 0xFF, 0x10, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xF0, - 0x1F, 0xFF, 0xFF, 0x10, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xF0, 0x1F, 0xFF, 0xFF, 0x10, - 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xF0, 0x1F, 0xFF, 0xFF, 0x10, 0x00, 0x00, 0x00, 0x00, - 0x01, 0xFF, 0xFF, 0xF0, 0x1F, 0xFF, 0xFF, 0x10, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xF0, - 0x1F, 0xFF, 0xFF, 0x10, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xF0, 0x1F, 0xFF, 0xFF, 0x10, - 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xF0, 0x0F, 0xFF, 0xFF, 0x20, 0x00, 0x00, 0x00, 0x00, - 0x02, 0xFF, 0xFF, 0xF0, 0x0E, 0xFF, 0xFF, 0x40, 0x00, 0x00, 0x00, 0x00, 0x05, 0xFF, 0xFF, 0xD0, - 0x0B, 0xFF, 0xFF, 0xA0, 0x00, 0x00, 0x00, 0x00, 0x0A, 0xFF, 0xFF, 0xA0, 0x06, 0xFF, 0xFF, 0xF4, - 0x00, 0x00, 0x00, 0x00, 0x5F, 0xFF, 0xFF, 0x60, 0x01, 0xEF, 0xFF, 0xFF, 0x60, 0x00, 0x00, 0x06, - 0xFF, 0xFF, 0xFE, 0x10, 0x00, 0x6F, 0xFF, 0xFF, 0xFD, 0x97, 0x79, 0xDF, 0xFF, 0xFF, 0xF6, 0x00, - 0x00, 0x0A, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xA0, 0x00, 0x00, 0x00, 0x9F, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF9, 0x00, 0x00, 0x00, 0x00, 0x05, 0xDF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFD, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x8C, 0xEF, 0xFE, 0xC9, 0x40, 0x00, 0x00, 0x00, - 0x9F, 0xFF, 0xFB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0B, 0xFF, 0xFF, 0x76, 0xFF, 0xFF, 0xF1, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xFF, 0xFF, 0xF4, 0x1F, 0xFF, 0xFF, 0x60, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x6F, 0xFF, 0xFE, 0x00, 0xBF, 0xFF, 0xFA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0xFF, - 0xFF, 0x90, 0x07, 0xFF, 0xFF, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xEF, 0xFF, 0xF5, 0x00, 0x2F, - 0xFF, 0xFF, 0x30, 0x00, 0x00, 0x00, 0x00, 0x4F, 0xFF, 0xFE, 0x00, 0x00, 0xCF, 0xFF, 0xF8, 0x00, - 0x00, 0x00, 0x00, 0x08, 0xFF, 0xFF, 0xA0, 0x00, 0x08, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, 0x00, - 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x3F, 0xFF, 0xFF, 0x10, 0x00, 0x00, 0x00, 0x1F, 0xFF, 0xFF, 0x10, - 0x00, 0x00, 0xDF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x06, 0xFF, 0xFF, 0xB0, 0x00, 0x00, 0x09, 0xFF, - 0xFF, 0xA0, 0x00, 0x00, 0x00, 0xAF, 0xFF, 0xF6, 0x00, 0x00, 0x00, 0x4F, 0xFF, 0xFE, 0x00, 0x00, - 0x00, 0x0E, 0xFF, 0xFF, 0x20, 0x00, 0x00, 0x00, 0xEF, 0xFF, 0xF3, 0x00, 0x00, 0x03, 0xFF, 0xFF, - 0xC0, 0x00, 0x00, 0x00, 0x0A, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x8F, 0xFF, 0xF7, 0x00, 0x00, 0x00, - 0x00, 0x5F, 0xFF, 0xFC, 0x00, 0x00, 0x0C, 0xFF, 0xFF, 0x30, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, - 0xF1, 0x00, 0x01, 0xFF, 0xFF, 0xD0, 0x00, 0x00, 0x00, 0x00, 0x0B, 0xFF, 0xFF, 0x50, 0x00, 0x5F, - 0xFF, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6F, 0xFF, 0xFA, 0x00, 0x0A, 0xFF, 0xFF, 0x30, 0x00, - 0x00, 0x00, 0x00, 0x02, 0xFF, 0xFF, 0xE0, 0x00, 0xEF, 0xFF, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x0C, 0xFF, 0xFF, 0x30, 0x3F, 0xFF, 0xF9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8F, 0xFF, 0xF7, - 0x07, 0xFF, 0xFF, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xC0, 0xCF, 0xFF, 0xE0, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0xFF, 0xFF, 0x2F, 0xFF, 0xFA, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x9F, 0xFF, 0xFB, 0xFF, 0xFF, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, - 0xFF, 0xFF, 0xFF, 0xFF, 0xF1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0E, 0xFF, 0xFF, 0xFF, - 0xFB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xAF, 0xFF, 0xFF, 0xFF, 0x60, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0xFF, 0xFF, 0xFF, 0xF2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x1F, 0xFF, 0xFF, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xBF, - 0xFF, 0xFF, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0xFF, 0xFF, 0xF2, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF7, 0x00, 0x00, 0x00, 0x00, 0x06, 0xFF, 0xFF, 0xE1, 0x00, - 0x00, 0x00, 0x00, 0x0A, 0xFF, 0xFF, 0x69, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, 0x00, 0xAF, 0xFF, - 0xFF, 0x40, 0x00, 0x00, 0x00, 0x00, 0xEF, 0xFF, 0xF4, 0x5F, 0xFF, 0xFF, 0x10, 0x00, 0x00, 0x00, - 0x0D, 0xFF, 0xFF, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xFF, 0xFF, 0x01, 0xFF, 0xFF, 0xF4, 0x00, - 0x00, 0x00, 0x02, 0xFF, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, 0x07, 0xFF, 0xFF, 0xB0, 0x0C, 0xFF, - 0xFF, 0x80, 0x00, 0x00, 0x00, 0x6F, 0xFF, 0xFF, 0xFF, 0x10, 0x00, 0x00, 0x00, 0xAF, 0xFF, 0xF7, - 0x00, 0x8F, 0xFF, 0xFC, 0x00, 0x00, 0x00, 0x09, 0xFF, 0xFF, 0xFF, 0xF4, 0x00, 0x00, 0x00, 0x0E, - 0xFF, 0xFF, 0x30, 0x04, 0xFF, 0xFF, 0xF1, 0x00, 0x00, 0x00, 0xDF, 0xFF, 0xFF, 0xFF, 0x80, 0x00, - 0x00, 0x03, 0xFF, 0xFF, 0xE0, 0x00, 0x1F, 0xFF, 0xFF, 0x40, 0x00, 0x00, 0x1F, 0xFF, 0xFF, 0xFF, - 0xFC, 0x00, 0x00, 0x00, 0x6F, 0xFF, 0xFB, 0x00, 0x00, 0xBF, 0xFF, 0xF8, 0x00, 0x00, 0x05, 0xFF, - 0xFF, 0xFF, 0xFF, 0xF1, 0x00, 0x00, 0x0A, 0xFF, 0xFF, 0x70, 0x00, 0x07, 0xFF, 0xFF, 0xB0, 0x00, - 0x00, 0x8F, 0xFF, 0xFC, 0xFF, 0xFF, 0x40, 0x00, 0x00, 0xEF, 0xFF, 0xF3, 0x00, 0x00, 0x3F, 0xFF, - 0xFF, 0x10, 0x00, 0x0C, 0xFF, 0xFE, 0x6F, 0xFF, 0xF8, 0x00, 0x00, 0x2F, 0xFF, 0xFE, 0x00, 0x00, - 0x00, 0xEF, 0xFF, 0xF4, 0x00, 0x01, 0xFF, 0xFF, 0xA2, 0xFF, 0xFF, 0xC0, 0x00, 0x06, 0xFF, 0xFF, - 0xB0, 0x00, 0x00, 0x0A, 0xFF, 0xFF, 0x80, 0x00, 0x4F, 0xFF, 0xF7, 0x0D, 0xFF, 0xFF, 0x10, 0x00, - 0xAF, 0xFF, 0xF7, 0x00, 0x00, 0x00, 0x6F, 0xFF, 0xFB, 0x00, 0x08, 0xFF, 0xFF, 0x30, 0xAF, 0xFF, - 0xF4, 0x00, 0x0D, 0xFF, 0xFF, 0x30, 0x00, 0x00, 0x02, 0xFF, 0xFF, 0xF0, 0x00, 0xBF, 0xFF, 0xE0, - 0x06, 0xFF, 0xFF, 0x80, 0x02, 0xFF, 0xFF, 0xE0, 0x00, 0x00, 0x00, 0x0D, 0xFF, 0xFF, 0x40, 0x0E, - 0xFF, 0xFB, 0x00, 0x2F, 0xFF, 0xFC, 0x00, 0x6F, 0xFF, 0xFA, 0x00, 0x00, 0x00, 0x00, 0x9F, 0xFF, - 0xF8, 0x03, 0xFF, 0xFF, 0x80, 0x00, 0xDF, 0xFF, 0xF1, 0x09, 0xFF, 0xFF, 0x70, 0x00, 0x00, 0x00, - 0x05, 0xFF, 0xFF, 0xB0, 0x7F, 0xFF, 0xF4, 0x00, 0x0A, 0xFF, 0xFF, 0x50, 0xDF, 0xFF, 0xF3, 0x00, - 0x00, 0x00, 0x00, 0x1F, 0xFF, 0xFF, 0x0A, 0xFF, 0xFF, 0x10, 0x00, 0x6F, 0xFF, 0xF8, 0x1F, 0xFF, - 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF4, 0xEF, 0xFF, 0xC0, 0x00, 0x02, 0xFF, 0xFF, - 0xC5, 0xFF, 0xFF, 0xA0, 0x00, 0x00, 0x00, 0x00, 0x08, 0xFF, 0xFF, 0xBF, 0xFF, 0xF9, 0x00, 0x00, - 0x0E, 0xFF, 0xFF, 0xAF, 0xFF, 0xF6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4F, 0xFF, 0xFF, 0xFF, 0xFF, - 0x50, 0x00, 0x00, 0xAF, 0xFF, 0xFF, 0xFF, 0xFF, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, - 0xFF, 0xFF, 0xF2, 0x00, 0x00, 0x06, 0xFF, 0xFF, 0xFF, 0xFF, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x0B, 0xFF, 0xFF, 0xFF, 0xFD, 0x00, 0x00, 0x00, 0x3F, 0xFF, 0xFF, 0xFF, 0xFA, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x7F, 0xFF, 0xFF, 0xFF, 0xA0, 0x00, 0x00, 0x00, 0xEF, 0xFF, 0xFF, 0xFF, 0x60, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xFF, 0xF6, 0x00, 0x00, 0x00, 0x0A, 0xFF, 0xFF, - 0xFF, 0xF2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0E, 0xFF, 0xFF, 0xFF, 0x30, 0x00, 0x00, 0x00, - 0x7F, 0xFF, 0xFF, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xAF, 0xFF, 0xFF, 0xE0, 0x00, - 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xFF, 0xA0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0xFF, 0xFF, - 0xFB, 0x00, 0x00, 0x00, 0x00, 0x0E, 0xFF, 0xFF, 0xF6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x2F, 0xFF, 0xFF, 0x70, 0x00, 0x00, 0x00, 0x00, 0xBF, 0xFF, 0xFF, 0x20, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF3, 0x00, 0x00, 0x00, 0x00, 0x06, 0xFF, 0xFF, 0xD0, 0x00, 0x00, - 0x00, 0x00, 0x6F, 0xFF, 0xFE, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1D, 0xFF, 0xFF, 0x70, 0xDF, - 0xFF, 0xFA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0xFF, 0xFF, 0xE1, 0x05, 0xFF, 0xFF, 0xF4, 0x00, - 0x00, 0x00, 0x00, 0x02, 0xFF, 0xFF, 0xF6, 0x00, 0x0B, 0xFF, 0xFF, 0xD0, 0x00, 0x00, 0x00, 0x00, - 0xBF, 0xFF, 0xFC, 0x00, 0x00, 0x2F, 0xFF, 0xFF, 0x70, 0x00, 0x00, 0x00, 0x5F, 0xFF, 0xFF, 0x30, - 0x00, 0x00, 0x8F, 0xFF, 0xFE, 0x10, 0x00, 0x00, 0x0D, 0xFF, 0xFF, 0x90, 0x00, 0x00, 0x01, 0xDF, - 0xFF, 0xF9, 0x00, 0x00, 0x07, 0xFF, 0xFF, 0xE1, 0x00, 0x00, 0x00, 0x05, 0xFF, 0xFF, 0xF3, 0x00, - 0x02, 0xEF, 0xFF, 0xF7, 0x00, 0x00, 0x00, 0x00, 0x0B, 0xFF, 0xFF, 0xC0, 0x00, 0xAF, 0xFF, 0xFC, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x2F, 0xFF, 0xFF, 0x60, 0x4F, 0xFF, 0xFF, 0x40, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x8F, 0xFF, 0xFE, 0x1D, 0xFF, 0xFF, 0xA0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xEF, - 0xFF, 0xFD, 0xFF, 0xFF, 0xE2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0xFF, 0xFF, 0xFF, 0xFF, - 0xF7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0xFF, 0xFF, 0xFF, 0xFD, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xFF, 0xFF, 0xFF, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xBF, 0xFF, 0xFF, 0xD0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xFF, - 0xFF, 0xFF, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0B, 0xFF, 0xFF, 0xFF, 0xFD, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0xFF, 0xFF, 0xFF, 0xFF, 0xF7, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x01, 0xEF, 0xFF, 0xFD, 0xFF, 0xFF, 0xE2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8F, - 0xFF, 0xFE, 0x1D, 0xFF, 0xFF, 0xA0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2F, 0xFF, 0xFF, 0x60, 0x4F, - 0xFF, 0xFF, 0x40, 0x00, 0x00, 0x00, 0x00, 0x0B, 0xFF, 0xFF, 0xC0, 0x00, 0xAF, 0xFF, 0xFC, 0x00, - 0x00, 0x00, 0x00, 0x05, 0xFF, 0xFF, 0xF3, 0x00, 0x02, 0xFF, 0xFF, 0xF6, 0x00, 0x00, 0x00, 0x01, - 0xDF, 0xFF, 0xF9, 0x00, 0x00, 0x08, 0xFF, 0xFF, 0xE1, 0x00, 0x00, 0x00, 0x8F, 0xFF, 0xFE, 0x10, - 0x00, 0x00, 0x1D, 0xFF, 0xFF, 0x90, 0x00, 0x00, 0x2F, 0xFF, 0xFF, 0x60, 0x00, 0x00, 0x00, 0x5F, - 0xFF, 0xFF, 0x30, 0x00, 0x0B, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, 0x00, 0xBF, 0xFF, 0xFC, 0x00, - 0x05, 0xFF, 0xFF, 0xF3, 0x00, 0x00, 0x00, 0x00, 0x02, 0xFF, 0xFF, 0xF6, 0x00, 0xDF, 0xFF, 0xF9, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0xFF, 0xFF, 0xE1, 0x6F, 0xFF, 0xFE, 0x10, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x1D, 0xFF, 0xFF, 0x70, 0x7F, 0xFF, 0xFD, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8F, - 0xFF, 0xFD, 0x1E, 0xFF, 0xFF, 0x60, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xF7, 0x08, 0xFF, - 0xFF, 0xD0, 0x00, 0x00, 0x00, 0x00, 0x09, 0xFF, 0xFF, 0xE1, 0x01, 0xEF, 0xFF, 0xF6, 0x00, 0x00, - 0x00, 0x00, 0x1F, 0xFF, 0xFF, 0x60, 0x00, 0x8F, 0xFF, 0xFD, 0x00, 0x00, 0x00, 0x00, 0x9F, 0xFF, - 0xFD, 0x00, 0x00, 0x1E, 0xFF, 0xFF, 0x60, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xF6, 0x00, 0x00, 0x07, - 0xFF, 0xFF, 0xD0, 0x00, 0x00, 0x09, 0xFF, 0xFF, 0xD0, 0x00, 0x00, 0x01, 0xEF, 0xFF, 0xF6, 0x00, - 0x00, 0x1F, 0xFF, 0xFF, 0x60, 0x00, 0x00, 0x00, 0x7F, 0xFF, 0xFD, 0x00, 0x00, 0x9F, 0xFF, 0xFD, - 0x00, 0x00, 0x00, 0x00, 0x1E, 0xFF, 0xFF, 0x60, 0x01, 0xFF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, - 0x07, 0xFF, 0xFF, 0xD0, 0x09, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x01, 0xEF, 0xFF, 0xF6, - 0x1F, 0xFF, 0xFF, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6F, 0xFF, 0xFD, 0x9F, 0xFF, 0xFC, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0xFF, 0xFF, 0xFF, 0xFF, 0xF4, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x06, 0xFF, 0xFF, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xDF, 0xFF, - 0xFF, 0xFF, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6F, 0xFF, 0xFF, 0xFB, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0xFF, 0xFF, 0xF3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x07, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0xFF, - 0xFF, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0xFF, 0xFF, 0xB0, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0xFF, 0xFF, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x06, 0xFF, 0xFF, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0xFF, - 0xFF, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0xFF, 0xFF, 0xB0, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0xFF, 0xFF, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x06, 0xFF, 0xFF, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0xFF, - 0xFF, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0xFF, 0xFF, 0xB0, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0xFF, 0xFF, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x05, 0xFF, 0xFF, 0x90, 0x00, 0x00, 0x00, 0x00, 0x4F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xF6, 0x6F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF7, - 0x6F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF7, 0x6F, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF7, 0x16, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x6A, 0xFF, 0xFF, - 0xF6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1D, 0xFF, 0xFF, 0xD1, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x9F, 0xFF, 0xFF, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0xFF, 0xFF, - 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xAF, 0xFF, 0xFE, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0xFF, 0xFF, - 0xF6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2E, 0xFF, 0xFF, 0xB0, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xBF, 0xFF, 0xFE, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xFF, 0xFF, - 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xFF, 0xFF, 0xA0, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xFD, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0xFF, 0xFF, - 0xF4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x01, 0xDF, 0xFF, 0xFD, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0xFF, 0xFF, - 0xF3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5F, 0xFF, 0xFF, 0x70, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x01, 0xEF, 0xFF, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0xFF, 0xFF, - 0xE2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6F, 0xFF, 0xFF, 0x60, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x02, 0xEF, 0xFF, 0xFA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0B, 0xFF, 0xFF, - 0xE1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4F, 0xFF, 0xFF, 0xB6, 0x66, 0x66, 0x66, 0x66, - 0x66, 0x66, 0x62, 0x6F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF7, 0x6F, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF7, 0x6F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xF7, 0x4F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF6, 0x1E, - 0xFF, 0xFD, 0x01, 0xFF, 0xFF, 0xE0, 0x1F, 0xFF, 0xFE, 0x01, 0xFF, 0xFF, 0xE0, 0x0F, 0xFF, 0xFD, - 0x00, 0xFF, 0xFF, 0xD0, 0x0F, 0xFF, 0xFD, 0x00, 0xEF, 0xFF, 0xC0, 0x0E, 0xFF, 0xFC, 0x00, 0xDF, - 0xFF, 0xC0, 0x0D, 0xFF, 0xFB, 0x00, 0xDF, 0xFF, 0xB0, 0x0C, 0xFF, 0xFA, 0x00, 0xCF, 0xFF, 0xA0, - 0x0C, 0xFF, 0xFA, 0x00, 0xBF, 0xFF, 0x90, 0x0B, 0xFF, 0xF9, 0x00, 0xBF, 0xFF, 0x90, 0x0A, 0xFF, - 0xF8, 0x00, 0xAF, 0xFF, 0x80, 0x08, 0xFF, 0xF6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8D, 0xEA, 0x20, 0x7F, 0xFF, 0xFD, 0x0C, 0xFF, 0xFF, - 0xF3, 0xCF, 0xFF, 0xFF, 0x37, 0xFF, 0xFF, 0xC0, 0x08, 0xDE, 0xA2, 0x00, -]; - -static FONT_LG_GLYPHS: [Glyph; 38] = [ - Glyph { ch: 32, x_off: 0, y_off: 0, w: 0, h: 0, adv: 9, offset: 0 }, - Glyph { ch: 48, x_off: 2, y_off: 0, w: 21, h: 31, adv: 26, offset: 0 }, - Glyph { ch: 49, x_off: 6, y_off: 0, w: 12, h: 31, adv: 26, offset: 326 }, - Glyph { ch: 50, x_off: 3, y_off: 0, w: 21, h: 31, adv: 26, offset: 512 }, - Glyph { ch: 51, x_off: 2, y_off: 0, w: 21, h: 31, adv: 26, offset: 838 }, - Glyph { ch: 52, x_off: 1, y_off: 0, w: 23, h: 31, adv: 26, offset: 1164 }, - Glyph { ch: 53, x_off: 3, y_off: 0, w: 20, h: 31, adv: 26, offset: 1521 }, - Glyph { ch: 54, x_off: 3, y_off: 0, w: 20, h: 31, adv: 26, offset: 1831 }, - Glyph { ch: 55, x_off: 3, y_off: 0, w: 20, h: 31, adv: 26, offset: 2141 }, - Glyph { ch: 56, x_off: 2, y_off: 0, w: 21, h: 31, adv: 26, offset: 2451 }, - Glyph { ch: 57, x_off: 2, y_off: 0, w: 20, h: 31, adv: 26, offset: 2777 }, - Glyph { ch: 65, x_off: 1, y_off: 0, w: 27, h: 31, adv: 29, offset: 3087 }, - Glyph { ch: 66, x_off: 3, y_off: 0, w: 22, h: 31, adv: 27, offset: 3506 }, - Glyph { ch: 67, x_off: 2, y_off: 0, w: 23, h: 31, adv: 27, offset: 3847 }, - Glyph { ch: 68, x_off: 3, y_off: 0, w: 22, h: 31, adv: 27, offset: 4204 }, - Glyph { ch: 69, x_off: 3, y_off: 0, w: 22, h: 31, adv: 26, offset: 4545 }, - Glyph { ch: 70, x_off: 3, y_off: 0, w: 22, h: 31, adv: 25, offset: 4886 }, - Glyph { ch: 71, x_off: 2, y_off: 0, w: 23, h: 31, adv: 27, offset: 5227 }, - Glyph { ch: 72, x_off: 3, y_off: 0, w: 23, h: 31, adv: 28, offset: 5584 }, - Glyph { ch: 73, x_off: 3, y_off: 0, w: 6, h: 31, adv: 12, offset: 5941 }, - Glyph { ch: 74, x_off: 0, y_off: 0, w: 23, h: 31, adv: 26, offset: 6034 }, - Glyph { ch: 75, x_off: 3, y_off: 0, w: 24, h: 31, adv: 27, offset: 6391 }, - Glyph { ch: 76, x_off: 3, y_off: 0, w: 21, h: 31, adv: 25, offset: 6763 }, - Glyph { ch: 77, x_off: 3, y_off: 0, w: 26, h: 31, adv: 31, offset: 7089 }, - Glyph { ch: 78, x_off: 3, y_off: 0, w: 24, h: 31, adv: 29, offset: 7492 }, - Glyph { ch: 79, x_off: 2, y_off: 0, w: 23, h: 31, adv: 27, offset: 7864 }, - Glyph { ch: 80, x_off: 2, y_off: 0, w: 23, h: 31, adv: 26, offset: 8221 }, - Glyph { ch: 81, x_off: 2, y_off: 0, w: 22, h: 36, adv: 26, offset: 8578 }, - Glyph { ch: 82, x_off: 3, y_off: 0, w: 23, h: 31, adv: 27, offset: 8974 }, - Glyph { ch: 83, x_off: 1, y_off: 0, w: 24, h: 31, adv: 26, offset: 9331 }, - Glyph { ch: 84, x_off: 1, y_off: 0, w: 23, h: 31, adv: 25, offset: 9703 }, - Glyph { ch: 85, x_off: 2, y_off: 0, w: 24, h: 31, adv: 28, offset: 10060 }, - Glyph { ch: 86, x_off: 1, y_off: 0, w: 25, h: 31, adv: 27, offset: 10432 }, - Glyph { ch: 87, x_off: 1, y_off: 0, w: 37, h: 31, adv: 39, offset: 10820 }, - Glyph { ch: 88, x_off: 1, y_off: 0, w: 25, h: 31, adv: 27, offset: 11394 }, - Glyph { ch: 89, x_off: 1, y_off: 0, w: 24, h: 31, adv: 26, offset: 11782 }, - Glyph { ch: 90, x_off: 1, y_off: 0, w: 22, h: 31, adv: 24, offset: 12154 }, - Glyph { ch: 33, x_off: 4, y_off: 0, w: 7, h: 31, adv: 15, offset: 12495 }, -]; - -pub static FONT_LG: Font = Font { glyphs: &FONT_LG_GLYPHS, data: &FONT_LG_DATA }; diff --git a/apps/lake-cast/src/game.rs b/apps/lake-cast/src/game.rs deleted file mode 100644 index caf9740..0000000 --- a/apps/lake-cast/src/game.rs +++ /dev/null @@ -1,1621 +0,0 @@ -//! Pure Lake Cast game state: open shoreline beach + full lake canvas, 3 roaming fish, -//! dynamic cast target anywhere on water, and tuned vertical bar fishing duel. - -use crate::sprites::{ - Sprite, SPRITE_CARP, SPRITE_KOI, SPRITE_PERCH, SPRITE_PIKE, SPRITE_ROACH, SPRITE_TROUT, -}; -use cmf_wp2_ui::motion::isqrt; -use cmf_wp2_ui::Rgb; - -pub const SIZE: i32 = 466; -pub const C: i32 = SIZE / 2; - -/// Shoreline splits upper/mid open water (`0..SHORE_Y`) from sunny foreground beach (`SHORE_Y..SIZE`). -pub const SHORE_Y: i32 = 326; -pub const CAST_X_MIN: i32 = 106; // keeps bobber & ripples strictly clear of left vertical gauge -pub const CAST_X_MAX: i32 = SIZE - 42; -pub const CAST_Y_MIN: i32 = 82; -pub const CAST_Y_MAX: i32 = SHORE_Y - 14; -pub const CAST_R_MAX: i32 = 200; - -/// Left vertical catch bar geometry (shown during `Reeling`). -pub const GAUGE_X: i32 = 34; -pub const GAUGE_Y: i32 = 112; -pub const GAUGE_W: i32 = 46; -pub const GAUGE_H: i32 = 198; -pub const TRACK_X: i32 = GAUGE_X + 5; -pub const TRACK_Y: i32 = GAUGE_Y + 7; -pub const TRACK_W: i32 = 24; -pub const TRACK_H: i32 = GAUGE_H - 14; // 184 px -pub const PROG_X: i32 = TRACK_X + TRACK_W + 4; -pub const PROG_W: i32 = 8; - -pub const DERBY_MS: u32 = 90_000; -pub const CAST_FLIGHT_MS: u32 = 220; -pub const HOOK_WINDOW_MS: u32 = 1_300; -pub const RESULT_BANNER_MS: u32 = 1_100; -pub const CATCH_GUARD_MS: u32 = 360; -pub const CONFIRM_FLASH_MS: u32 = 160; -pub const MAX_FISH: usize = 6; - -/// Top HUD tappable menu pill & mode/score pill geometry. -pub const HUD_Y: i32 = 34; -pub const HUD_H: i32 = 28; -pub const HUD_MENU_X: i32 = 118; -pub const HUD_MENU_W: i32 = 76; -pub const HUD_INFO_X: i32 = 200; -pub const HUD_INFO_W: i32 = 148; - -/// Menu buttons geometry (centred symmetrically on 466px circle). -pub const MENU_BTN_X: i32 = 123; -pub const MENU_BTN_W: i32 = 220; -pub const MENU_BTN_H: i32 = 52; -pub const MENU_RELAX_Y: i32 = 142; -pub const MENU_DERBY_Y: i32 = 204; -pub const MENU_TROPHY_Y: i32 = 266; - -/// Over / Derby summary & Caught continue buttons. -pub const OVER_BTN_X: i32 = 133; -pub const OVER_BTN_W: i32 = 200; -pub const OVER_BTN_H: i32 = 48; -pub const OVER_RETRY_Y: i32 = 286; -pub const OVER_MENU_Y: i32 = 344; - -pub const CAUGHT_BTN_X: i32 = 148; -pub const CAUGHT_BTN_Y: i32 = 328; -pub const CAUGHT_BTN_W: i32 = 170; -pub const CAUGHT_BTN_H: i32 = 36; - -/// Trophies prev/next arrow buttons. -pub const TROPHY_PREV_X: i32 = 48; -pub const TROPHY_NEXT_X: i32 = 364; -pub const TROPHY_NAV_W: i32 = 54; -pub const TROPHY_NAV_Y: i32 = 198; -pub const TROPHY_NAV_H: i32 = 56; - -pub fn in_rect(x: i32, y: i32, rx: i32, ry: i32, rw: i32, rh: i32) -> bool { - x >= rx && x < rx + rw && y >= ry && y < ry + rh -} - -pub fn in_menu_back_pill(x: i32, y: i32) -> bool { - in_rect(x, y, HUD_MENU_X - 4, HUD_Y - 4, HUD_MENU_W + 8, HUD_H + 8) -} - -#[derive(Clone, Copy, PartialEq, Eq, Debug)] -pub enum Mode { - Relax, - Derby, -} - -#[derive(Clone, Copy, PartialEq, Eq, Debug)] -#[repr(u8)] -pub enum Difficulty { - Easy = 0, - Medium = 1, - Hard = 2, -} - -pub const DIFFICULTIES: [Difficulty; 3] = [Difficulty::Easy, Difficulty::Medium, Difficulty::Hard]; - -#[derive(Clone, Copy, PartialEq, Eq, Debug)] -pub struct DifficultyTuning { - pub start_progress: i32, - pub gain_per_s: i32, - pub decay_per_s: i32, - pub step_px: i32, - pub accel_mul: i32, - pub min_accel_dv: i32, - pub overlap_pad: i32, - pub jump_min: i32, - pub jump_max: i32, -} - -impl Difficulty { - pub const fn idx(self) -> usize { - self as usize - } - - pub const fn name(self) -> &'static str { - match self { - Difficulty::Easy => "EASY", - Difficulty::Medium => "MEDIUM", - Difficulty::Hard => "HARD", - } - } - - pub const fn desc(self) -> &'static str { - match self { - Difficulty::Easy => "WIDE BAR - GENTLE", - Difficulty::Medium => "BALANCED 50/50", - Difficulty::Hard => "FAST FISH - NARROW", - } - } - - pub const fn short(self) -> &'static str { - match self { - Difficulty::Easy => "E", - Difficulty::Medium => "M", - Difficulty::Hard => "H", - } - } - - pub const fn accent(self) -> Rgb { - match self { - Difficulty::Easy => Rgb(84, 226, 114), - Difficulty::Medium => Rgb(255, 212, 76), - Difficulty::Hard => Rgb(255, 112, 86), - } - } - - pub const fn tuning(self) -> DifficultyTuning { - match self { - // Exact classic balance from before hardening. - Difficulty::Easy => DifficultyTuning { - start_progress: 320, - gain_per_s: 220, - decay_per_s: 115, - step_px: 14, - accel_mul: 4, - min_accel_dv: 2, - overlap_pad: 4, - jump_min: 0, - jump_max: 0, - }, - // Balanced 50/50 midpoint: strictly between Easy and Hard for every species. - Difficulty::Medium => DifficultyTuning { - start_progress: 280, - gain_per_s: 198, - decay_per_s: 130, - step_px: 13, - accel_mul: 5, - min_accel_dv: 3, - overlap_pad: 3, - jump_min: 24, - jump_max: 76, - }, - // Tight bar & darting fish balance. - Difficulty::Hard => DifficultyTuning { - start_progress: 240, - gain_per_s: 175, - decay_per_s: 145, - step_px: 12, - accel_mul: 6, - min_accel_dv: 4, - overlap_pad: 3, - jump_min: 42, - jump_max: 118, - }, - } - } -} - -#[derive(Clone, Copy, PartialEq, Eq, Debug)] -#[repr(u8)] -pub enum Species { - Roach = 0, - Perch = 1, - Trout = 2, - Carp = 3, - Pike = 4, - GoldenKoi = 5, -} - -pub const SPECIES_ALL: [Species; 6] = [ - Species::Roach, - Species::Perch, - Species::Trout, - Species::Carp, - Species::Pike, - Species::GoldenKoi, -]; - -impl Species { - pub const fn idx(self) -> usize { - self as usize - } - - pub const fn name(self) -> &'static str { - match self { - Species::Roach => "SILVER ROACH", - Species::Perch => "STRIPED PERCH", - Species::Trout => "RAINBOW TROUT", - Species::Carp => "AMBER CARP", - Species::Pike => "NORTHERN PIKE", - Species::GoldenKoi => "GOLDEN KOI", - } - } - - pub const fn rarity(self) -> &'static str { - match self { - Species::Roach | Species::Perch => "COMMON", - Species::Trout | Species::Carp => "UNCOMMON", - Species::Pike => "RARE", - Species::GoldenKoi => "LEGENDARY", - } - } - - pub const fn sprite(self) -> &'static Sprite { - match self { - Species::Roach => &SPRITE_ROACH, - Species::Perch => &SPRITE_PERCH, - Species::Trout => &SPRITE_TROUT, - Species::Carp => &SPRITE_CARP, - Species::Pike => &SPRITE_PIKE, - Species::GoldenKoi => &SPRITE_KOI, - } - } - - pub const fn accent(self) -> Rgb { - match self { - Species::Roach => Rgb(134, 214, 255), - Species::Perch => Rgb(186, 224, 92), - Species::Trout => Rgb(244, 138, 176), - Species::Carp => Rgb(246, 182, 72), - Species::Pike => Rgb(96, 224, 132), - Species::GoldenKoi => Rgb(255, 208, 66), - } - } - - /// (min_hg, max_hg, base_pts) - pub const fn stats(self) -> (u16, u16, u32) { - match self { - Species::Roach => (25, 165, 45), - Species::Perch => (35, 220, 65), - Species::Trout => (95, 440, 120), - Species::Carp => (150, 680, 150), - Species::Pike => (260, 1120, 235), - Species::GoldenKoi => (340, 1450, 440), - } - } - - /// Difficulty-tuned bar duel parameters: `(bar_h_px, fish_speed_px_s, ai_min_ms, ai_max_ms)`. - /// Bands never overlap across difficulties: every fish on Easy stays gentle, Medium balanced, Hard intense. - pub const fn fight(self, diff: Difficulty) -> (i32, i32, i32, i32) { - match (self, diff) { - (Species::Roach, Difficulty::Easy) => (60, 38, 850, 1300), - (Species::Perch, Difficulty::Easy) => (58, 42, 800, 1220), - (Species::Carp, Difficulty::Easy) => (55, 46, 740, 1140), - (Species::Trout, Difficulty::Easy) => (54, 50, 700, 1080), - (Species::Pike, Difficulty::Easy) => (52, 54, 660, 1020), - (Species::GoldenKoi, Difficulty::Easy) => (50, 58, 620, 980), - - (Species::Roach, Difficulty::Medium) => (48, 64, 520, 920), - (Species::Perch, Difficulty::Medium) => (46, 70, 490, 860), - (Species::Carp, Difficulty::Medium) => (44, 74, 460, 810), - (Species::Trout, Difficulty::Medium) => (42, 80, 430, 760), - (Species::Pike, Difficulty::Medium) => (40, 84, 400, 720), - (Species::GoldenKoi, Difficulty::Medium) => (38, 88, 380, 680), - - (Species::Roach, Difficulty::Hard) => (36, 92, 320, 620), - (Species::Perch, Difficulty::Hard) => (34, 98, 290, 560), - (Species::Carp, Difficulty::Hard) => (32, 106, 260, 520), - (Species::Trout, Difficulty::Hard) => (30, 114, 220, 460), - (Species::Pike, Difficulty::Hard) => (28, 124, 190, 420), - (Species::GoldenKoi, Difficulty::Hard) => (26, 134, 160, 380), - } - } - - /// Underwater silhouette size & cruise speed (w, h, speed_px_per_s). - pub const fn silhouette(self) -> (i32, i32, i32) { - match self { - Species::Roach => (24, 11, 25), - Species::Perch => (26, 13, 23), - Species::Trout => (30, 12, 32), - Species::Carp => (29, 15, 19), - Species::Pike => (36, 11, 29), - Species::GoldenKoi => (32, 15, 24), - } - } - - pub const fn from_u8(v: u8) -> Option { - match v { - 0 => Some(Species::Roach), - 1 => Some(Species::Perch), - 2 => Some(Species::Trout), - 3 => Some(Species::Carp), - 4 => Some(Species::Pike), - 5 => Some(Species::GoldenKoi), - _ => None, - } - } -} - -#[derive(Clone, Copy, PartialEq, Eq, Debug)] -pub enum Feedback { - None, - Tap, - CastSplash, - Nibble, - Bite, - BarTick, - CatchHold, - Caught, - Escape, - DerbyEnd, -} - -#[derive(Clone, Copy, PartialEq, Eq, Debug)] -pub enum BannerKind { - Escaped, -} - -#[derive(Clone, Copy, PartialEq, Eq, Debug)] -pub enum PendingNav { - OpenDifficulty(Mode), - OpenTrophies, - StartGame(Difficulty), - RetryDerby, - BackToMenu, -} - -#[derive(Clone, Copy, PartialEq, Eq, Debug)] -pub enum State { - Menu, - Difficulty, - Trophies, - Aim, - Casting, - Floating, - Nibble, - Bite, - Reeling, - Caught, - Banner, - DerbyOver, -} - -#[derive(Clone, Copy, PartialEq, Eq, Debug)] -pub enum FishAi { - Cruise, - Curious, - Stalking, -} - -#[derive(Clone, Copy, PartialEq, Eq, Debug)] -pub struct LakeFish { - pub species: Species, - pub x_q8: i32, - pub y_q8: i32, - pub vx_q8: i32, - pub vy_q8: i32, - pub phase_ms: u16, - pub weight_hg: u16, - pub ai: FishAi, - pub spook_ms: u16, -} - -impl LakeFish { - pub fn x(&self) -> i32 { - self.x_q8 >> 8 - } - - pub fn y(&self) -> i32 { - self.y_q8 >> 8 - } - - pub fn facing_right(&self) -> bool { - self.vx_q8 >= 0 - } -} - -/// Sleek rod extending from the sandy beach across the shoreline toward cast spot `(bx, by)`. -#[derive(Clone, Copy, PartialEq, Eq, Debug)] -pub struct RodPose { - pub grip_x: i32, - pub grip_y: i32, - pub ctrl_x: i32, - pub ctrl_y: i32, - pub tip_x: i32, - pub tip_y: i32, -} - -/// Clamps any tap on the water cleanly inside the round bezel and right of the vertical bar zone. -pub fn clamp_cast(tx: i32, ty: i32) -> (i32, i32) { - let mut y = ty.clamp(CAST_Y_MIN, CAST_Y_MAX); - let mut x = tx.clamp(CAST_X_MIN, CAST_X_MAX); - let dx = x - C; - let dy = y - C; - let d2 = dx * dx + dy * dy; - let max_d2 = CAST_R_MAX * CAST_R_MAX; - if d2 > max_d2 { - let d = isqrt(d2).max(1); - x = C + dx * CAST_R_MAX / d; - y = (C + dy * CAST_R_MAX / d).clamp(CAST_Y_MIN, CAST_Y_MAX); - let dy2 = y - C; - let max_dx = isqrt((max_d2 - dy2 * dy2).max(0)); - x = x.clamp((C - max_dx).max(CAST_X_MIN), (C + max_dx).min(CAST_X_MAX)); - } - (x, y) -} - -/// Rod rooted on the sunny sand (`y ~ 420..446`), reaching straight over the shore line (`y ~ 282..308`). -pub fn rod_pose(bx: i32, by: i32, bend: i32) -> RodPose { - let grip_x = (bx + if bx <= C { 10 } else { -10 }).clamp(124, 342); - let dx_c = grip_x - C; - let max_bottom = C + isqrt((C * C - dx_c * dx_c).max(0)) - 22; - let grip_y = max_bottom.clamp(388, 444); - - let aim_x = grip_x + (bx - grip_x) * 42 / 100; - let tip_x = aim_x.clamp(112, SIZE - 62); - let base_tip_y = (302 - (SHORE_Y - by).max(0) / 8).clamp(272, 308); - let flex = bend.clamp(0, 256); - let tip_y = base_tip_y + flex * 12 / 256; - - let ctrl_x = (grip_x + tip_x) / 2 + if tip_x < grip_x { -5 } else { 5 }; - let ctrl_y = (grip_y + tip_y) / 2 - 6; - - RodPose { grip_x, grip_y, ctrl_x, ctrl_y, tip_x, tip_y } -} - -/// Persistent catch records & stats across sessions (`43` bytes). -#[derive(Clone, Copy, PartialEq, Eq, Debug, Default)] -pub struct Records { - pub relax_best: u32, - pub derby_best: u32, - pub total_caught: u32, - pub biggest_species: Option, - pub biggest_hg: u16, - pub species_count: [u16; 6], - pub species_best_hg: [u16; 6], -} - -impl Records { - pub fn species_unlocked(&self) -> usize { - self.species_count.iter().filter(|&&c| c > 0).count() - } - - pub fn best_overall_score(&self) -> u32 { - self.relax_best.max(self.derby_best) - } -} - -const SAVE_MAGIC: [u8; 4] = *b"LC01"; -pub const SAVE_LEN: usize = 43; - -pub fn encode(r: Records) -> [u8; SAVE_LEN] { - let mut b = [0u8; SAVE_LEN]; - b[0..4].copy_from_slice(&SAVE_MAGIC); - b[4..8].copy_from_slice(&r.relax_best.to_le_bytes()); - b[8..12].copy_from_slice(&r.derby_best.to_le_bytes()); - b[12..16].copy_from_slice(&r.total_caught.to_le_bytes()); - b[16] = r.biggest_species.map_or(255, |s| s as u8); - b[17..19].copy_from_slice(&r.biggest_hg.to_le_bytes()); - for i in 0..6 { - let c = r.species_count[i].to_le_bytes(); - let w = r.species_best_hg[i].to_le_bytes(); - b[19 + i * 2..21 + i * 2].copy_from_slice(&c); - b[31 + i * 2..33 + i * 2].copy_from_slice(&w); - } - b -} - -pub fn decode(b: &[u8]) -> Records { - if b.len() < SAVE_LEN || b[0..4] != SAVE_MAGIC { - return Records::default(); - } - let u32_at = |o: usize| u32::from_le_bytes([b[o], b[o + 1], b[o + 2], b[o + 3]]); - let u16_at = |o: usize| u16::from_le_bytes([b[o], b[o + 1]]); - let mut r = Records { - relax_best: u32_at(4), - derby_best: u32_at(8), - total_caught: u32_at(12), - biggest_species: Species::from_u8(b[16]), - biggest_hg: u16_at(17), - species_count: [0; 6], - species_best_hg: [0; 6], - }; - for i in 0..6 { - r.species_count[i] = u16_at(19 + i * 2); - r.species_best_hg[i] = u16_at(31 + i * 2); - } - r -} - -pub struct Game { - pub state: State, - pub mode: Mode, - pub pending_mode: Mode, - pub difficulty: Difficulty, - pub menu_sel: usize, - pub diff_sel: usize, - pub trophy_idx: usize, - pub over_sel: usize, - pub score: u32, - pub session_catches: u16, - pub session_best_species: Option, - pub session_best_hg: u16, - pub derby_left_ms: u32, - pub new_best_score: bool, - - pub fish: [LakeFish; MAX_FISH], - pub lake_ms: u32, - - /// Current cast / bobber spot in the lake. - pub bx: i32, - pub by: i32, - pub has_cast: bool, - - /// Cast / wait / bite timers. - pub cast_ms: u32, - pub wait_ms: u32, - pub splash_ms: u32, - pub nibbles_left: u8, - pub target_fish: usize, - pub bite_left_ms: u32, - pub will_bite: bool, - - /// Vertical bar fight state (left-hand gauge). - pub reel_species: Species, - pub reel_weight_hg: u16, - pub reel_progress: i32, - pub bar_y: i32, - pub bar_h: i32, - pub track_fish_y_q8: i32, - pub track_fish_vy_q8: i32, - pub track_target_y: i32, - pub track_ai_ms: u32, - pub fish_in_bar: bool, - pub reel_phase_ms: u32, - - /// Caught modal info. - pub caught_species: Species, - pub caught_hg: u16, - pub caught_pts: u32, - pub caught_record: bool, - pub caught_guard_ms: u32, - - /// Banner state (Escaped). - pub banner: BannerKind, - pub banner_ms: u32, - - /// Brief pressed-button flash before switching screen/starting play. - pub confirm_ms: u32, - pub pending_nav: Option, - - rng: u32, -} - -impl Game { - pub fn new(seed: u32) -> Self { - let mut g = Game { - state: State::Menu, - mode: Mode::Relax, - pending_mode: Mode::Relax, - difficulty: Difficulty::Medium, - menu_sel: 0, - diff_sel: Difficulty::Medium.idx(), - trophy_idx: 0, - over_sel: 0, - score: 0, - session_catches: 0, - session_best_species: None, - session_best_hg: 0, - derby_left_ms: DERBY_MS, - new_best_score: false, - fish: [LakeFish { - species: Species::Roach, - x_q8: C << 8, - y_q8: 180 << 8, - vx_q8: 20 << 8, - vy_q8: 0, - phase_ms: 0, - weight_hg: 80, - ai: FishAi::Cruise, - spook_ms: 0, - }; MAX_FISH], - lake_ms: 0, - bx: 186, - by: 274, - has_cast: false, - cast_ms: 0, - wait_ms: 0, - splash_ms: 0, - nibbles_left: 0, - target_fish: 0, - bite_left_ms: 0, - will_bite: false, - reel_species: Species::Roach, - reel_weight_hg: 80, - reel_progress: 240, - bar_y: (TRACK_H - 38) / 2, - bar_h: 38, - track_fish_y_q8: (TRACK_H / 2) << 8, - track_fish_vy_q8: 0, - track_target_y: TRACK_H / 2, - track_ai_ms: 0, - fish_in_bar: true, - reel_phase_ms: 0, - caught_species: Species::Roach, - caught_hg: 80, - caught_pts: 45, - caught_record: false, - caught_guard_ms: 0, - banner: BannerKind::Escaped, - banner_ms: 0, - confirm_ms: 0, - pending_nav: None, - rng: seed | 1, - }; - for i in 0..MAX_FISH { - g.respawn_fish(i, true); - } - g - } - - fn next_u32(&mut self) -> u32 { - let mut x = self.rng; - x ^= x << 13; - x ^= x >> 17; - x ^= x << 5; - self.rng = x; - x - } - - fn rand_range(&mut self, lo: i32, hi: i32) -> i32 { - if hi <= lo { - return lo; - } - lo + (self.next_u32() % (hi - lo + 1) as u32) as i32 - } - - fn pick_species(&mut self, y: i32) -> Species { - let roll = self.rand_range(0, 99); - if y < 145 { - // Far deep upper lake has larger rare fish & Koi! - match roll { - 0..=34 => Species::Pike, - 35..=58 => Species::Carp, - 59..=78 => Species::Trout, - 79..=93 => Species::GoldenKoi, - _ => Species::Perch, - } - } else if y < 235 { - match roll { - 0..=26 => Species::Perch, - 27..=54 => Species::Trout, - 55..=76 => Species::Carp, - 77..=89 => Species::Pike, - 90..=96 => Species::GoldenKoi, - _ => Species::Roach, - } - } else { - // Shallow nearshore water. - match roll { - 0..=38 => Species::Roach, - 39..=74 => Species::Perch, - 75..=90 => Species::Trout, - 91..=97 => Species::Carp, - _ => Species::GoldenKoi, - } - } - } - - fn roll_weight(&mut self, sp: Species) -> u16 { - let (min_w, max_w, _) = sp.stats(); - let a = self.rand_range(min_w as i32, max_w as i32); - let b = self.rand_range(min_w as i32, max_w as i32); - ((a + b) / 2) as u16 - } - - fn respawn_fish(&mut self, idx: usize, initial: bool) { - // Spread all 6 distinct fish cleanly across upper, mid, and nearshore lake lanes. - let (y_min, y_max) = match idx % 6 { - 0 => (106, 122), - 1 => (134, 150), - 2 => (162, 182), - 3 => (194, 216), - 4 => (228, 254), - _ => (266, 294), - }; - let y = self.rand_range(y_min, y_max); - let half_w = (isqrt((196 * 196 - (y - C) * (y - C)).max(0)) - 26).max(32); - let left_to_right = if initial { (idx & 1) == 0 } else { (self.next_u32() & 1) == 0 }; - let x = if initial { - match idx % 6 { - 0 => self.rand_range(C - half_w, C - 18), - 1 => self.rand_range(C + 18, C + half_w), - 2 => self.rand_range(C - half_w / 2, C + half_w / 2), - 3 => self.rand_range(C + 24, C + half_w), - 4 => self.rand_range(C - half_w, C - 10), - _ => self.rand_range(C - half_w / 2, C + half_w), - } - } else if left_to_right { - C - half_w - } else { - C + half_w - }; - let sp = if initial { - match idx % 6 { - 0 => Species::Trout, - 1 => Species::Perch, - 2 => Species::GoldenKoi, - 3 => Species::Roach, - 4 => Species::Carp, - _ => Species::Pike, - } - } else { - self.pick_species(y) - }; - let (_, _, spd) = sp.silhouette(); - let dir = if left_to_right { 1 } else { -1 }; - let vy = self.rand_range(-3, 3); - self.fish[idx] = LakeFish { - species: sp, - x_q8: x << 8, - y_q8: y << 8, - vx_q8: dir * (spd << 8), - vy_q8: vy << 8, - phase_ms: self.rand_range(0, 999) as u16, - weight_hg: self.roll_weight(sp), - ai: FishAi::Cruise, - spook_ms: 0, - }; - } - - fn clear_confirm(&mut self) { - self.confirm_ms = 0; - self.pending_nav = None; - } - - fn queue_nav(&mut self, nav: PendingNav) { - self.confirm_ms = CONFIRM_FLASH_MS; - self.pending_nav = Some(nav); - } - - pub fn open_difficulty(&mut self, mode: Mode) { - self.clear_confirm(); - self.pending_mode = mode; - self.diff_sel = self.difficulty.idx(); - self.state = State::Difficulty; - self.has_cast = false; - } - - pub fn start_with_difficulty(&mut self, mode: Mode, diff: Difficulty) { - self.clear_confirm(); - self.difficulty = diff; - self.diff_sel = diff.idx(); - self.start_mode(mode); - } - - pub fn start_mode(&mut self, mode: Mode) { - self.clear_confirm(); - self.mode = mode; - self.state = State::Aim; - self.score = 0; - self.session_catches = 0; - self.session_best_species = None; - self.session_best_hg = 0; - self.derby_left_ms = DERBY_MS; - self.new_best_score = false; - self.has_cast = false; - self.bx = 186; - self.by = 274; - self.splash_ms = 0; - for i in 0..MAX_FISH { - self.respawn_fish(i, true); - } - } - - pub fn open_trophies(&mut self) { - self.clear_confirm(); - self.state = State::Trophies; - self.trophy_idx = 0; - } - - pub fn back_to_menu(&mut self) { - self.clear_confirm(); - self.state = State::Menu; - self.has_cast = false; - } - - pub fn animating(&self) -> bool { - matches!( - self.state, - State::Aim - | State::Casting - | State::Floating - | State::Nibble - | State::Bite - | State::Reeling - | State::Banner - ) - } - - pub fn needs_tick(&self) -> bool { - self.animating() - || self.confirm_ms > 0 - || (self.state == State::Caught && self.caught_guard_ms > 0) - } - - /// Cast rod and bobber directly to tapped spot `(tx, ty)` anywhere on the water. - pub fn cast_to(&mut self, tx: i32, ty: i32) -> Feedback { - let (bx, by) = clamp_cast(tx, ty); - self.bx = bx; - self.by = by; - self.has_cast = true; - self.state = State::Casting; - self.cast_ms = 0; - self.splash_ms = 0; - for f in &mut self.fish { - f.ai = FishAi::Cruise; - } - Feedback::Tap - } - - fn nearest_ready_fish(&self, bx: i32, by: i32) -> (usize, i32) { - let mut best_i = 0usize; - let mut best_d2 = i32::MAX; - for (i, f) in self.fish.iter().enumerate() { - if f.spook_ms > 0 { - continue; - } - let dx = f.x() - bx; - let dy = f.y() - by; - let d2 = dx * dx + dy * dy; - if d2 < best_d2 { - best_d2 = d2; - best_i = i; - } - } - (best_i, best_d2) - } - - pub fn begin_reeling(&mut self, fish_idx: usize) { - let f = &self.fish[fish_idx]; - let sp = f.species; - let w = f.weight_hg; - let tuning = self.difficulty.tuning(); - let (bar_h, _, ai_min, ai_max) = sp.fight(self.difficulty); - self.state = State::Reeling; - self.reel_species = sp; - self.reel_weight_hg = w; - self.reel_progress = tuning.start_progress; - self.bar_h = bar_h; - let start_y = (TRACK_H - 12) / 2; - self.bar_y = ((TRACK_H - bar_h) / 2).clamp(0, TRACK_H - bar_h); - self.track_fish_y_q8 = start_y << 8; - self.track_fish_vy_q8 = 0; - if tuning.jump_max == 0 { - self.track_target_y = self.rand_range(16, TRACK_H - 20); - self.track_ai_ms = self.rand_range(ai_min, ai_max) as u32; - } else { - let up = (self.next_u32() & 1) == 0; - let (lo_hi, hi_lo) = if self.difficulty == Difficulty::Medium { - (66, TRACK_H - 68) - } else { - (54, TRACK_H - 56) - }; - self.track_target_y = if up { - self.rand_range(12, lo_hi) - } else { - self.rand_range(hi_lo, TRACK_H - 12) - }; - let min_init = if self.difficulty == Difficulty::Medium { 260 } else { 200 }; - self.track_ai_ms = (ai_min as u32).max(min_init); - } - self.fish_in_bar = true; - self.reel_phase_ms = 0; - self.splash_ms = 0; - self.respawn_fish(fish_idx, false); - } - - pub fn try_hook(&mut self) -> Feedback { - match self.state { - State::Bite => { - self.begin_reeling(self.target_fish); - Feedback::CastSplash - } - State::Nibble => { - self.state = State::Floating; - self.wait_ms = 550; - self.splash_ms = 260; - Feedback::Tap - } - _ => Feedback::None, - } - } - - fn record_catch(&mut self, best: &mut Records) -> (Feedback, bool) { - let sp = self.reel_species; - let w = self.reel_weight_hg; - let (min_w, max_w, base_pts) = sp.stats(); - let span = (max_w - min_w).max(1) as u32; - let size_bonus = ((w - min_w) as u32 * base_pts / 2) / span; - let pts = base_pts + size_bonus; - - self.score += pts; - self.session_catches = self.session_catches.saturating_add(1); - if w > self.session_best_hg { - self.session_best_hg = w; - self.session_best_species = Some(sp); - } - - let mut broke_persist = false; - best.total_caught = best.total_caught.saturating_add(1); - let si = sp.idx(); - best.species_count[si] = best.species_count[si].saturating_add(1); - let mut is_species_record = false; - if w > best.species_best_hg[si] { - best.species_best_hg[si] = w; - is_species_record = true; - broke_persist = true; - } - if w > best.biggest_hg { - best.biggest_hg = w; - best.biggest_species = Some(sp); - broke_persist = true; - } - match self.mode { - Mode::Relax => { - if self.score > best.relax_best { - best.relax_best = self.score; - self.new_best_score = true; - broke_persist = true; - } - } - Mode::Derby => { - if self.score > best.derby_best { - best.derby_best = self.score; - self.new_best_score = true; - broke_persist = true; - } - } - } - - self.caught_species = sp; - self.caught_hg = w; - self.caught_pts = pts; - self.caught_record = is_species_record; - self.caught_guard_ms = CATCH_GUARD_MS; - self.state = State::Caught; - (Feedback::Caught, broke_persist) - } - - pub fn crown(&mut self, delta: i16) -> Feedback { - if delta == 0 || self.confirm_ms > 0 { - return Feedback::None; - } - let d = if delta > 0 { 1 } else { -1 }; - match self.state { - State::Menu => { - self.menu_sel = ((self.menu_sel as i32 + d).rem_euclid(3)) as usize; - Feedback::Tap - } - State::Difficulty => { - self.diff_sel = ((self.diff_sel as i32 + d).rem_euclid(3)) as usize; - Feedback::Tap - } - State::Trophies => { - self.trophy_idx = ((self.trophy_idx as i32 + d).rem_euclid(6)) as usize; - Feedback::Tap - } - State::DerbyOver => { - self.over_sel = ((self.over_sel as i32 + d).rem_euclid(2)) as usize; - Feedback::Tap - } - State::Bite => self.try_hook(), - State::Reeling => { - let step_px = self.difficulty.tuning().step_px; - let max_y = (TRACK_H - self.bar_h).max(0); - let next_y = (self.bar_y + (delta as i32) * step_px).clamp(0, max_y); - if next_y != self.bar_y { - self.bar_y = next_y; - self.update_fish_overlap(); - return Feedback::BarTick; - } - Feedback::None - } - State::Caught if self.caught_guard_ms == 0 => { - self.state = State::Aim; - self.has_cast = false; - Feedback::Tap - } - _ => Feedback::None, - } - } - - pub fn track_fish_y(&self) -> i32 { - (self.track_fish_y_q8 >> 8).clamp(6, TRACK_H - 7) - } - - fn update_fish_overlap(&mut self) -> bool { - let fy = self.track_fish_y(); - let pad = self.difficulty.tuning().overlap_pad; - let inside = fy >= self.bar_y - pad && fy <= self.bar_y + self.bar_h + pad; - let entered = inside && !self.fish_in_bar; - self.fish_in_bar = inside; - entered - } - - pub fn dismiss_caught(&mut self) -> Feedback { - if self.state == State::Caught && self.caught_guard_ms == 0 { - self.state = State::Aim; - self.has_cast = false; - Feedback::Tap - } else { - Feedback::None - } - } - - /// Strict button hit-testing across all UI screens: taps outside button bounds are ignored! - pub fn tap_ui(&mut self, tx: i32, ty: i32) -> (Feedback, bool) { - if self.confirm_ms > 0 { - return (Feedback::None, false); - } - match self.state { - State::Menu => { - let opts = [ - (MENU_RELAX_Y, PendingNav::OpenDifficulty(Mode::Relax)), - (MENU_DERBY_Y, PendingNav::OpenDifficulty(Mode::Derby)), - (MENU_TROPHY_Y, PendingNav::OpenTrophies), - ]; - for (i, &(y, nav)) in opts.iter().enumerate() { - if in_rect(tx, ty, MENU_BTN_X, y, MENU_BTN_W, MENU_BTN_H) { - self.menu_sel = i; - self.queue_nav(nav); - return (Feedback::Tap, true); - } - } - (Feedback::None, false) - } - State::Difficulty => { - if in_menu_back_pill(tx, ty) { - self.back_to_menu(); - return (Feedback::Tap, true); - } - let ys = [MENU_RELAX_Y, MENU_DERBY_Y, MENU_TROPHY_Y]; - for (i, &y) in ys.iter().enumerate() { - if in_rect(tx, ty, MENU_BTN_X, y, MENU_BTN_W, MENU_BTN_H) { - self.diff_sel = i; - self.queue_nav(PendingNav::StartGame(DIFFICULTIES[i])); - return (Feedback::Tap, true); - } - } - (Feedback::None, false) - } - State::Trophies => { - if in_menu_back_pill(tx, ty) { - self.back_to_menu(); - (Feedback::Tap, true) - } else if in_rect(tx, ty, TROPHY_PREV_X, TROPHY_NAV_Y, TROPHY_NAV_W, TROPHY_NAV_H) { - self.trophy_idx = (self.trophy_idx + 5) % 6; - (Feedback::Tap, false) - } else if in_rect(tx, ty, TROPHY_NEXT_X, TROPHY_NAV_Y, TROPHY_NAV_W, TROPHY_NAV_H) { - self.trophy_idx = (self.trophy_idx + 1) % 6; - (Feedback::Tap, false) - } else { - (Feedback::None, false) - } - } - State::Caught => { - if in_rect(tx, ty, CAUGHT_BTN_X - 4, CAUGHT_BTN_Y - 4, CAUGHT_BTN_W + 8, CAUGHT_BTN_H + 8) { - let fb = self.dismiss_caught(); - (fb, fb != Feedback::None) - } else { - (Feedback::None, false) - } - } - State::DerbyOver => { - let opts = [ - (OVER_RETRY_Y, PendingNav::RetryDerby), - (OVER_MENU_Y, PendingNav::BackToMenu), - ]; - for (i, &(y, nav)) in opts.iter().enumerate() { - if in_rect(tx, ty, OVER_BTN_X, y, OVER_BTN_W, OVER_BTN_H) { - self.over_sel = i; - self.queue_nav(nav); - return (Feedback::Tap, true); - } - } - (Feedback::None, false) - } - _ => (Feedback::None, false), - } - } - - fn update_fish_pool(&mut self, dt_ms: u32) { - if self.state == State::Reeling { - return; - } - let bob_active = matches!(self.state, State::Floating | State::Nibble | State::Bite); - let bx = self.bx; - let by = self.by; - - for i in 0..MAX_FISH { - let mut f = self.fish[i]; - f.phase_ms = ((f.phase_ms as u32 + dt_ms) % 1000) as u16; - if f.spook_ms > 0 { - f.spook_ms = f.spook_ms.saturating_sub(dt_ms as u16); - } - - if bob_active && i == self.target_fish && f.ai != FishAi::Cruise { - let tx_q8 = bx << 8; - let ty_q8 = by << 8; - let dx = tx_q8 - f.x_q8; - let dy = ty_q8 - f.y_q8; - let dist_px = isqrt((dx >> 8) * (dx >> 8) + (dy >> 8) * (dy >> 8)); - if dist_px > 16 { - let spd = if f.ai == FishAi::Stalking { 46 } else { 36 }; - f.vx_q8 = dx * spd / dist_px.max(1); - f.vy_q8 = dy * spd / dist_px.max(1); - } else { - f.vx_q8 = if f.vx_q8 >= 0 { 6 << 8 } else { -6 << 8 }; - f.vy_q8 = 0; - } - } else { - let x = f.x(); - let y = f.y(); - let half_w = (isqrt((196 * 196 - (y - C) * (y - C)).max(0)) - 24).max(28); - if x <= C - half_w && f.vx_q8 < 0 { - f.vx_q8 = -f.vx_q8; - } else if x >= C + half_w && f.vx_q8 > 0 { - f.vx_q8 = -f.vx_q8; - } - if y <= 104 && f.vy_q8 < 0 { - f.vy_q8 = -f.vy_q8; - } else if y >= SHORE_Y - 26 && f.vy_q8 > 0 { - f.vy_q8 = -f.vy_q8; - } - } - - f.x_q8 += (f.vx_q8 * dt_ms as i32) / 1000; - f.y_q8 += (f.vy_q8 * dt_ms as i32) / 1000; - self.fish[i] = f; - } - } - - pub fn tick(&mut self, raw_dt_ms: u32, best: &mut Records) -> (Feedback, bool) { - let dt = raw_dt_ms.min(80); - if dt == 0 { - return (Feedback::None, false); - } - self.lake_ms = self.lake_ms.wrapping_add(dt); - - if self.state == State::Caught { - self.caught_guard_ms = self.caught_guard_ms.saturating_sub(dt); - return (Feedback::None, false); - } - - if self.confirm_ms > 0 { - self.confirm_ms = self.confirm_ms.saturating_sub(dt); - if self.confirm_ms == 0 { - if let Some(nav) = self.pending_nav.take() { - match nav { - PendingNav::OpenDifficulty(mode) => self.open_difficulty(mode), - PendingNav::OpenTrophies => self.open_trophies(), - PendingNav::StartGame(diff) => self.start_with_difficulty(self.pending_mode, diff), - PendingNav::RetryDerby => self.start_mode(Mode::Derby), - PendingNav::BackToMenu => self.back_to_menu(), - } - } - } - return (Feedback::None, false); - } - - if self.splash_ms > 0 { - self.splash_ms = self.splash_ms.saturating_sub(dt); - } - - self.update_fish_pool(dt); - - if self.mode == Mode::Derby - && matches!( - self.state, - State::Aim - | State::Casting - | State::Floating - | State::Nibble - | State::Bite - | State::Reeling - | State::Banner - ) - { - if dt >= self.derby_left_ms { - self.derby_left_ms = 0; - self.state = State::DerbyOver; - self.over_sel = 0; - self.has_cast = false; - return (Feedback::DerbyEnd, false); - } - self.derby_left_ms -= dt; - } - - match self.state { - State::Casting => { - self.cast_ms += dt; - if self.cast_ms >= CAST_FLIGHT_MS { - let (fi, d2) = self.nearest_ready_fish(self.bx, self.by); - self.target_fish = fi; - self.fish[fi].ai = FishAi::Curious; - let close_bonus = if d2 < 68 * 68 { 600 } else { 0 }; - let base = self.rand_range(1200, 2250); - self.wait_ms = (base - close_bonus).max(550) as u32; - self.nibbles_left = 1; - self.splash_ms = 420; - self.state = State::Floating; - return (Feedback::CastSplash, false); - } - } - State::Floating => { - if dt >= self.wait_ms { - self.fish[self.target_fish].ai = FishAi::Stalking; - self.will_bite = true; - self.nibbles_left = 0; - self.wait_ms = self.rand_range(400, 620) as u32; - self.splash_ms = 340; - self.state = State::Nibble; - return (Feedback::Nibble, false); - } - self.wait_ms -= dt; - } - State::Nibble => { - if dt >= self.wait_ms { - self.state = State::Bite; - self.bite_left_ms = HOOK_WINDOW_MS; - self.splash_ms = 520; - return (Feedback::Bite, false); - } - self.wait_ms -= dt; - } - State::Bite => { - if dt >= self.bite_left_ms { - self.fish[self.target_fish].ai = FishAi::Cruise; - self.fish[self.target_fish].spook_ms = 2000; - self.banner = BannerKind::Escaped; - self.banner_ms = RESULT_BANNER_MS; - self.state = State::Banner; - return (Feedback::Escape, false); - } - self.bite_left_ms -= dt; - } - State::Reeling => { - self.reel_phase_ms = self.reel_phase_ms.wrapping_add(dt); - let tuning = self.difficulty.tuning(); - let (_, max_spd, ai_min, ai_max) = self.reel_species.fight(self.difficulty); - - if dt >= self.track_ai_ms { - self.track_ai_ms = self.rand_range(ai_min, ai_max) as u32; - if tuning.jump_max == 0 { - self.track_target_y = self.rand_range(10, TRACK_H - 12); - } else { - let cur = (self.track_fish_y_q8 >> 8).clamp(8, TRACK_H - 10); - let jump = self.rand_range(tuning.jump_min, tuning.jump_max); - let up = if cur > TRACK_H * 2 / 3 { - true - } else if cur < TRACK_H / 3 { - false - } else { - (self.next_u32() & 1) == 0 - }; - self.track_target_y = if up { - (cur - jump).max(10) - } else { - (cur + jump).min(TRACK_H - 12) - }; - } - } else { - self.track_ai_ms -= dt; - } - - let diff = self.track_target_y - (self.track_fish_y_q8 >> 8); - let desired_v = if diff.abs() <= 4 { - 0 - } else { - (diff.signum() * max_spd).clamp(-max_spd, max_spd) - }; - let accel = max_spd * tuning.accel_mul * dt as i32 / 1000; - let cur_v = self.track_fish_vy_q8 >> 8; - let next_v = if cur_v < desired_v { - (cur_v + accel.max(tuning.min_accel_dv)).min(desired_v) - } else if cur_v > desired_v { - (cur_v - accel.max(tuning.min_accel_dv)).max(desired_v) - } else { - cur_v - }; - self.track_fish_vy_q8 = next_v << 8; - self.track_fish_y_q8 = (self.track_fish_y_q8 + (self.track_fish_vy_q8 * dt as i32) / 1000) - .clamp(8 << 8, (TRACK_H - 9) << 8); - - let entered = self.update_fish_overlap(); - if self.fish_in_bar { - self.reel_progress = - (self.reel_progress + (tuning.gain_per_s * dt as i32) / 1000).min(1000); - if self.reel_progress >= 1000 { - return self.record_catch(best); - } - if entered { - return (Feedback::CatchHold, false); - } - } else { - self.reel_progress = - (self.reel_progress - (tuning.decay_per_s * dt as i32) / 1000).max(0); - if self.reel_progress <= 0 { - self.banner = BannerKind::Escaped; - self.banner_ms = RESULT_BANNER_MS; - self.state = State::Banner; - return (Feedback::Escape, false); - } - } - return (Feedback::None, false); - } - State::Banner => { - if dt >= self.banner_ms { - self.state = State::Aim; - self.has_cast = false; - } else { - self.banner_ms -= dt; - } - } - _ => {} - } - (Feedback::None, false) - } - - pub fn bobber_pos(&self) -> (i32, i32) { - match self.state { - State::Casting => { - let pose = rod_pose(self.bx, self.by, 12); - let t = (self.cast_ms.min(CAST_FLIGHT_MS) as i32) * 256 / CAST_FLIGHT_MS as i32; - let x = pose.tip_x + (self.bx - pose.tip_x) * t / 256; - let arc = (t * (256 - t)) >> 10; - let y = pose.tip_y + (self.by - pose.tip_y) * t / 256 - arc * 2; - (x, y) - } - _ => (self.bx, self.by), - } - } -} - -/// Format hectograms (e.g. `145` -> `"1.45 KG"`) without heap or floats. -pub fn format_weight(hg: u16, buf: &mut [u8; 16]) -> &str { - let whole = hg / 100; - let frac = hg % 100; - let mut i = 0usize; - if whole >= 10 { - buf[i] = b'0' + (whole / 10) as u8; - i += 1; - } - buf[i] = b'0' + (whole % 10) as u8; - i += 1; - buf[i] = b'.'; - i += 1; - buf[i] = b'0' + (frac / 10) as u8; - i += 1; - buf[i] = b'0' + (frac % 10) as u8; - i += 1; - buf[i..i + 3].copy_from_slice(b" KG"); - i += 3; - core::str::from_utf8(&buf[..i]).unwrap_or("0.00 KG") -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn cast_stays_inside_water_and_right_of_gauge() { - for &(tx, ty) in &[(10, 20), (450, 400), (240, 180), (40, 220)] { - let (bx, by) = clamp_cast(tx, ty); - assert!(by >= CAST_Y_MIN && by <= CAST_Y_MAX); - assert!(bx >= CAST_X_MIN && bx <= CAST_X_MAX); - assert!((bx - C) * (bx - C) + (by - C) * (by - C) <= CAST_R_MAX * CAST_R_MAX); - } - } - - #[test] - fn rod_starts_on_sand_and_leans_toward_cast() { - let left = rod_pose(120, 180, 0); - let right = rod_pose(360, 180, 0); - assert!(left.grip_y > SHORE_Y && right.grip_y > SHORE_Y); - assert!(left.tip_y < SHORE_Y && right.tip_y < SHORE_Y); - assert!(left.tip_x < right.tip_x); - } - - #[test] - fn vertical_bar_follows_crown_and_catches_when_tracked() { - let mut g = Game::new(42); - let mut rec = Records::default(); - g.start_mode(Mode::Relax); - g.cast_to(220, 180); - while g.state != State::Bite { - g.tick(40, &mut rec); - } - assert_eq!(g.try_hook(), Feedback::CastSplash); - assert_eq!(g.state, State::Reeling); - - let initial_y = g.bar_y; - g.crown(-1); - assert!(g.bar_y < initial_y); - g.crown(2); - assert!(g.bar_y > initial_y); - - let mut steps = 0; - while g.state == State::Reeling && steps < 500 { - let fy = g.track_fish_y(); - let center = g.bar_y + g.bar_h / 2; - if fy < center - 5 { - g.crown(-1); - } else if fy > center + 5 { - g.crown(1); - } - g.tick(40, &mut rec); - steps += 1; - } - assert_eq!(g.state, State::Caught); - assert_eq!(rec.total_caught, 1); - } - - #[test] - fn idle_bar_loses_fish_when_fish_swims_away() { - let mut g = Game::new(99); - let mut rec = Records::default(); - g.start_mode(Mode::Relax); - g.cast_to(220, 180); - while g.state != State::Bite { - g.tick(40, &mut rec); - } - g.try_hook(); - g.track_target_y = TRACK_H - 12; - g.track_fish_y_q8 = (TRACK_H - 12) << 8; - g.track_ai_ms = 5_000; - for _ in 0..100 { - if g.state != State::Reeling { - break; - } - g.crown(-1); - g.tick(40, &mut rec); - } - assert_eq!(g.state, State::Banner); - assert_eq!(rec.total_caught, 0); - } - - #[test] - fn ui_buttons_ignore_taps_outside_button_bounds() { - let mut g = Game::new(5); - let mut rec = Records::default(); - g.menu_sel = 0; - - // Miss all Menu buttons -> stays on Menu, no feedback. - assert_eq!(g.tap_ui(233, 50), (Feedback::None, false)); - assert_eq!(g.tap_ui(60, 233), (Feedback::None, false)); - assert_eq!(g.state, State::Menu); - - // Tap DERBY button while RELAX is focused -> DERBY lights up first, then opens Difficulty. - assert_eq!(g.tap_ui(233, MENU_DERBY_Y + 10), (Feedback::Tap, true)); - assert_eq!(g.state, State::Menu); - assert_eq!(g.menu_sel, 1); - assert_eq!(g.confirm_ms, CONFIRM_FLASH_MS); - assert!(g.needs_tick()); - assert_eq!(g.crown(-1), Feedback::None); - assert_eq!(g.tap_ui(233, MENU_RELAX_Y + 10), (Feedback::None, false)); - g.tick(80, &mut rec); - assert_eq!(g.state, State::Menu); - g.tick(80, &mut rec); - assert_eq!(g.state, State::Difficulty); - assert_eq!(g.pending_mode, Mode::Derby); - assert_eq!(g.confirm_ms, 0); - - // Crown focuses HARD, tapping off-button sand area MUST NOT launch game. - g.crown(1); - assert_eq!(g.diff_sel, Difficulty::Hard.idx()); - assert_eq!(g.tap_ui(233, 390), (Feedback::None, false)); - assert_eq!(g.state, State::Difficulty); - - // Reset focus back to MEDIUM, tap EASY -> EASY lights up visibly first, then starts EASY. - g.open_difficulty(Mode::Relax); - assert_eq!(g.diff_sel, Difficulty::Medium.idx()); - assert_eq!(g.tap_ui(233, MENU_RELAX_Y + 10), (Feedback::Tap, true)); - assert_eq!(g.state, State::Difficulty); - assert_eq!(g.diff_sel, Difficulty::Easy.idx()); - assert_eq!(g.confirm_ms, CONFIRM_FLASH_MS); - assert_eq!(g.crown(1), Feedback::None); - assert_eq!(g.diff_sel, Difficulty::Easy.idx()); - g.tick(80, &mut rec); - assert_eq!(g.state, State::Difficulty); - g.tick(80, &mut rec); - assert_eq!(g.state, State::Aim); - assert_eq!(g.difficulty, Difficulty::Easy); - - // `< BACK` on Difficulty stays immediate. - g.open_difficulty(Mode::Relax); - assert_eq!(g.tap_ui(HUD_MENU_X + 10, HUD_Y + 10), (Feedback::Tap, true)); - assert_eq!(g.state, State::Menu); - - // Trophies: tapping blank center/edges does not turn pages. - g.open_trophies(); - assert_eq!(g.tap_ui(233, 233), (Feedback::None, false)); - assert_eq!(g.trophy_idx, 0); - assert_eq!(g.tap_ui(TROPHY_NEXT_X + 10, TROPHY_NAV_Y + 10), (Feedback::Tap, false)); - assert_eq!(g.trophy_idx, 1); - - // Caught: must tap CONTINUE button after guard window. - g.state = State::Caught; - g.caught_guard_ms = 0; - assert_eq!(g.tap_ui(233, 150), (Feedback::None, false)); - assert_eq!(g.state, State::Caught); - assert_eq!(g.tap_ui(CAUGHT_BTN_X + 20, CAUGHT_BTN_Y + 10), (Feedback::Tap, true)); - assert_eq!(g.state, State::Aim); - - // DerbyOver: stray tap ignored; tapping MENU highlights MENU first, then switches to Menu. - g.state = State::DerbyOver; - g.over_sel = 0; - assert_eq!(g.tap_ui(233, 120), (Feedback::None, false)); - assert_eq!(g.state, State::DerbyOver); - assert_eq!(g.tap_ui(OVER_BTN_X + 20, OVER_MENU_Y + 10), (Feedback::Tap, true)); - assert_eq!(g.state, State::DerbyOver); - assert_eq!(g.over_sel, 1); - g.tick(80, &mut rec); - assert_eq!(g.state, State::DerbyOver); - g.tick(80, &mut rec); - assert_eq!(g.state, State::Menu); - } - - #[test] - fn difficulty_presets_scale_bar_speed_and_select_flow() { - let mut g = Game::new(11); - g.open_difficulty(Mode::Derby); - assert_eq!(g.state, State::Difficulty); - assert_eq!(g.pending_mode, Mode::Derby); - assert_eq!(g.diff_sel, Difficulty::Medium.idx()); - - g.crown(1); - assert_eq!(g.diff_sel, Difficulty::Hard.idx()); - g.crown(1); - assert_eq!(g.diff_sel, Difficulty::Easy.idx()); - - g.start_with_difficulty(Mode::Derby, DIFFICULTIES[g.diff_sel]); - assert_eq!(g.state, State::Aim); - assert_eq!(g.mode, Mode::Derby); - assert_eq!(g.difficulty, Difficulty::Easy); - - for a in SPECIES_ALL { - let (eb, es, elo, _) = a.fight(Difficulty::Easy); - let (mb, ms, mlo, _) = a.fight(Difficulty::Medium); - let (hb, hs, hlo, _) = a.fight(Difficulty::Hard); - assert!(eb > mb && mb > hb, "{:?}: bar_h should shrink Easy>Medium>Hard", a); - assert!(es < ms && ms < hs, "{:?}: speed should rise Easy mb2 && es < ms2 && elo > mlo2, "Easy ({:?}) must stay strictly easier than Medium ({:?})", a, b); - assert!(mb > hb2 && ms < hs2 && mlo > hlo2, "Medium ({:?}) must stay strictly easier than Hard ({:?})", a, b); - } - let _ = (hb, hs, hlo); - } - - // Catching multiple fish never changes selected difficulty. - let mut rec = Records::default(); - g.start_with_difficulty(Mode::Relax, Difficulty::Easy); - for _ in 0..5 { - g.begin_reeling(0); - g.record_catch(&mut rec); - assert_eq!(g.difficulty, Difficulty::Easy); - g.caught_guard_ms = 0; - g.dismiss_caught(); - assert_eq!(g.difficulty, Difficulty::Easy); - } - - let te = Difficulty::Easy.tuning(); - let tm = Difficulty::Medium.tuning(); - let th = Difficulty::Hard.tuning(); - assert!(te.start_progress > tm.start_progress && tm.start_progress > th.start_progress); - assert!(te.gain_per_s > tm.gain_per_s && tm.gain_per_s > th.gain_per_s); - assert!(te.decay_per_s < tm.decay_per_s && tm.decay_per_s < th.decay_per_s); - } - - #[test] - fn records_roundtrip_and_weight_format() { - let mut r = Records::default(); - r.relax_best = 540; - r.derby_best = 320; - r.total_caught = 9; - r.biggest_species = Some(Species::Pike); - r.biggest_hg = 875; - r.species_count[Species::Pike.idx()] = 2; - r.species_best_hg[Species::Pike.idx()] = 875; - - assert_eq!(decode(&encode(r)), r); - let mut b = [0u8; 16]; - assert_eq!(format_weight(875, &mut b), "8.75 KG"); - } -} diff --git a/apps/lake-cast/src/main.rs b/apps/lake-cast/src/main.rs deleted file mode 100644 index fc2e22c..0000000 --- a/apps/lake-cast/src/main.rs +++ /dev/null @@ -1,320 +0,0 @@ -//! Lake Cast device entrypoint, gentle haptics, widget sync, and compact 40ms frame pacing. - -#![cfg_attr(any(target_os = "none", wp2_sim), no_main, cfg_attr(target_os = "none", no_std))] - -#[cfg_attr(not(any(target_os = "none", wp2_sim)), allow(dead_code))] -mod font; -#[cfg_attr(not(any(target_os = "none", wp2_sim)), allow(dead_code))] -mod game; -#[cfg_attr(not(any(target_os = "none", wp2_sim)), allow(dead_code))] -mod sprites; -#[cfg_attr(not(any(target_os = "none", wp2_sim)), allow(dead_code))] -mod view; - -#[cfg(not(any(target_os = "none", wp2_sim)))] -fn main() {} - -#[cfg(any(target_os = "none", wp2_sim))] -mod device { - use crate::game::{ - decode, encode, format_weight, in_menu_back_pill, Feedback, Game, Records, SAVE_LEN, State, - CAST_Y_MIN, GAUGE_H, GAUGE_Y, HUD_H, HUD_Y, SHORE_Y, TRACK_Y, - }; - use crate::view::frame; - use cmf_wp2_app::{Api, BUTTON, CROWN, PAUSE, RESUME, TOUCH_DOWN}; - use cmf_wp2_ui::haptic::{Motor, Pattern, DONE, TICK}; - use cmf_wp2_ui::text::int; - - cmf_wp2_app::entry!(main); - cmf_wp2_app::app_icon!(); - cmf_wp2_app::app_features!(cmf_wp2_app::WIDGET); - - const FRAME_MS: u32 = 40; - const RETRY_MS: u32 = 450; - - const SPLASH_PULSE: Pattern = Pattern::new(&[(320, 26), (0, 0)]); - const NIBBLE_PULSE: Pattern = Pattern::new(&[(240, 22), (0, 0)]); - const BITE_PULSE: Pattern = Pattern::new(&[(860, 65), (0, 45), (680, 50), (0, 0)]); - const BAR_TICK: Pattern = Pattern::new(&[(180, 12), (0, 0)]); - const HOLD_PULSE: Pattern = Pattern::new(&[(340, 20), (0, 0)]); - const CAUGHT_PULSE: Pattern = Pattern::new(&[(650, 55), (0, 40), (920, 110), (0, 0)]); - - fn play_feedback(motor: &mut Motor, fb: Feedback) { - match fb { - Feedback::None => {} - Feedback::Tap => motor.play(TICK), - Feedback::CastSplash => motor.play(SPLASH_PULSE), - Feedback::Nibble => motor.play(NIBBLE_PULSE), - Feedback::Bite => motor.play(BITE_PULSE), - Feedback::BarTick => motor.play(BAR_TICK), - Feedback::CatchHold => motor.play(HOLD_PULSE), - Feedback::Caught => motor.play(CAUGHT_PULSE), - Feedback::Escape | Feedback::DerbyEnd => motor.play(DONE), - } - } - - fn due(now: u32, at: u32) -> bool { - (now.wrapping_sub(at) as i32) >= 0 - } - - fn seed(api: &Api) -> u32 { - let t = api - .time() - .map_or(0, |t| (t.minute as u32 * 60 + t.second as u32) * 1000 + t.millis as u32); - api.now().wrapping_mul(2_654_435_761) ^ t - } - - fn paused(api: &Api) -> bool { - loop { - match api.event(u32::MAX).map(|e| e.kind) { - Some(RESUME) => return true, - Some(BUTTON) => return false, - _ => {} - } - } - } - - fn push_widget(api: &Api, best: Records) { - let mut buf = [0u8; 39]; - let mut idx = 0usize; - let push = |buf: &mut [u8], idx: &mut usize, bytes: &[u8]| { - let n = bytes.len().min(buf.len() - *idx); - buf[*idx..*idx + n].copy_from_slice(&bytes[..n]); - *idx += n; - }; - let mut db = [0u8; 11]; - push(&mut buf, &mut idx, b"Best:"); - push(&mut buf, &mut idx, int(best.best_overall_score() as i32, &mut db).as_bytes()); - push(&mut buf, &mut idx, b" Big:"); - if best.biggest_hg > 0 { - let mut wb = [0u8; 16]; - push(&mut buf, &mut idx, format_weight(best.biggest_hg, &mut wb).as_bytes()); - } else { - push(&mut buf, &mut idx, b"--"); - } - push(&mut buf, &mut idx, b"\nCaught:"); - push(&mut buf, &mut idx, int(best.total_caught as i32, &mut db).as_bytes()); - push(&mut buf, &mut idx, b" ("); - push(&mut buf, &mut idx, int(best.species_unlocked() as i32, &mut db).as_bytes()); - push(&mut buf, &mut idx, b"/6)"); - let value = core::str::from_utf8(&buf[..idx]).unwrap_or("Best:0"); - api.widget("Lake Cast", value); - } - - fn needs_screen_awake(state: State) -> bool { - matches!( - state, - State::Casting | State::Floating | State::Nibble | State::Bite | State::Reeling - ) - } - - fn handle_touch( - api: &Api, - game: &mut Game, - motor: &mut Motor, - tx: i32, - ty: i32, - now: u32, - last_tick: &mut u32, - end_at: &mut u32, - ) { - if matches!( - game.state, - State::Menu | State::Difficulty | State::Trophies | State::Caught | State::DerbyOver - ) { - if game.state == State::DerbyOver && !due(now, end_at.wrapping_add(RETRY_MS)) { - return; - } - let prev = game.state; - let (fb, reset_tick) = game.tap_ui(tx, ty); - play_feedback(motor, fb); - if reset_tick { - *last_tick = now; - } - if prev == State::Caught && game.state == State::Aim { - api.keep_screen_on(false); - } - return; - } - - if in_menu_back_pill(tx, ty) { - motor.play(TICK); - api.keep_screen_on(false); - game.back_to_menu(); - *last_tick = now; - return; - } - - match game.state { - State::Aim | State::Floating | State::Banner => { - if ty >= CAST_Y_MIN - 4 && ty <= SHORE_Y + 20 { - let fb = game.cast_to(tx, ty); - play_feedback(motor, fb); - api.keep_screen_on(true); - *last_tick = now; - } - } - State::Nibble => { - let dx = tx - game.bx; - let dy = ty - game.by; - if dx * dx + dy * dy > 44 * 44 && ty >= CAST_Y_MIN - 4 && ty <= SHORE_Y + 20 { - let fb = game.cast_to(tx, ty); - play_feedback(motor, fb); - } else if ty >= HUD_Y + HUD_H + 8 { - let fb = game.try_hook(); - play_feedback(motor, fb); - } - } - State::Bite => { - if ty >= HUD_Y + HUD_H + 8 { - let fb = game.try_hook(); - play_feedback(motor, fb); - } - } - State::Reeling => { - if ty >= GAUGE_Y - 12 && ty <= GAUGE_Y + GAUGE_H + 12 { - let bar_screen_mid = TRACK_Y + game.bar_y + game.bar_h / 2; - let delta = if ty < bar_screen_mid { -1 } else { 1 }; - let fb = game.crown(delta); - play_feedback(motor, fb); - } - } - _ => {} - } - } - - fn main(api: &'static Api) -> i32 { - let mut screen = api; - let mut motor = Motor::new(api); - let mut blob = [0u8; SAVE_LEN + 8]; - let n = api.load(&mut blob); - let mut best = if n > 0 { decode(&blob[..n as usize]) } else { Records::default() }; - push_widget(api, best); - - let mut game = Game::new(seed(api)); - let (mut seen, _) = frame(&mut screen, &game, best, None); - api.show(); - - let mut last_tick = api.now(); - let mut next_frame = last_tick.wrapping_add(FRAME_MS); - let mut end_at = 0u32; - let mut dirty = false; - - loop { - motor.update(); - - let now = api.now(); - let animating = game.needs_tick(); - let frame_wait = if animating || dirty { - (next_frame.wrapping_sub(now) as i32).max(0) as u32 - } else { - u32::MAX - }; - let wait = motor.wait().map_or(frame_wait, |m| m.min(frame_wait)); - let mut force_draw = false; - - if let Some(first) = api.event(wait) { - let mut crown_delta = 0i32; - let mut cur = Some(first); - while let Some(e) = cur { - let ev_now = api.now(); - match e.kind { - BUTTON => { - api.keep_screen_on(false); - return 0; - } - PAUSE => { - motor.off(); - api.keep_screen_on(false); - if !paused(api) { - return 0; - } - let res_now = api.now(); - last_tick = res_now; - next_frame = res_now.wrapping_add(FRAME_MS); - if needs_screen_awake(game.state) { - api.keep_screen_on(true); - } - let (s, _) = frame(&mut screen, &game, best, None); - seen = s; - api.show(); - dirty = false; - crown_delta = 0; - break; - } - CROWN => { - crown_delta += e.delta as i32; - dirty = true; - } - TOUCH_DOWN => { - if crown_delta != 0 { - let fb = game.crown(crown_delta.clamp(-12, 12) as i16); - play_feedback(&mut motor, fb); - crown_delta = 0; - } - handle_touch( - api, - &mut game, - &mut motor, - e.x as i32, - e.y as i32, - ev_now, - &mut last_tick, - &mut end_at, - ); - dirty = true; - force_draw = true; - } - _ => {} - } - cur = api.event(0); - } - if crown_delta != 0 { - let fb = game.crown(crown_delta.clamp(-12, 12) as i16); - play_feedback(&mut motor, fb); - dirty = true; - } - } - - let now = api.now(); - let animating_now = game.needs_tick(); - if animating_now && (force_draw || due(now, next_frame)) { - let dt = now.wrapping_sub(last_tick); - last_tick = now; - if animating && dt > 0 { - let prev_state = game.state; - let (fb, broke) = game.tick(dt, &mut best); - if broke { - api.save(&encode(best)); - push_widget(api, best); - } - if fb != Feedback::None { - play_feedback(&mut motor, fb); - } - if prev_state != game.state && matches!(game.state, State::Caught | State::DerbyOver | State::Aim) { - api.keep_screen_on(false); - if game.state == State::DerbyOver { - end_at = now; - } - } - } - dirty = true; - } - - if (dirty || animating_now) && (force_draw || due(now, next_frame)) { - let (next_seen, drew) = frame(&mut screen, &game, best, Some(seen)); - seen = next_seen; - if drew { - api.show(); - } - dirty = false; - let stepped = next_frame.wrapping_add(FRAME_MS); - next_frame = if due(now, stepped) { - now.wrapping_add(FRAME_MS) - } else { - stepped - }; - } - } - } -} diff --git a/apps/lake-cast/src/sprites.rs b/apps/lake-cast/src/sprites.rs deleted file mode 100644 index fe0a3ae..0000000 --- a/apps/lake-cast/src/sprites.rs +++ /dev/null @@ -1,233 +0,0 @@ -//! Compact crisp multi-rect pixel art sprites for the 6 Lake Cast fish species. - -use cmf_wp2_ui::{Rgb, Surface}; - -pub const fn c565(r: u8, g: u8, b: u8) -> u16 { - (((r as u16) >> 3) << 11) | (((g as u16) >> 2) << 5) | ((b as u16) >> 3) -} - -pub struct Sprite { - pub w: i32, - pub h: i32, - pub rects: &'static [(i16, i16, i16, i16, u16)], -} - -/// Draw a fish sprite scaled by integer factor (1..=3). If `tint` is `Some`, draws a crisp silhouette. -pub fn draw_fish(s: &mut impl Surface, sp: &Sprite, x: i32, y: i32, scale: i32, tint: Option) { - let sc = scale.max(1); - let fixed = tint.map(Rgb::rgb565); - for &(rx, ry, rw, rh, c) in sp.rects { - s.rect( - x + (rx as i32) * sc, - y + (ry as i32) * sc, - (rw as i32) * sc, - (rh as i32) * sc, - fixed.unwrap_or(c), - ); - } -} - -// 1. SILVER ROACH (26x14): sleek silver-blue body with signature coral-red tail & fins. -const R_OUT: u16 = c565(22, 44, 68); -const R_BACK: u16 = c565(88, 152, 206); -const R_MID: u16 = c565(198, 224, 242); -const R_BELLY: u16 = c565(238, 246, 255); -const R_FIN: u16 = c565(238, 86, 62); -const EYE_W: u16 = c565(255, 255, 255); -const EYE_K: u16 = c565(18, 26, 36); - -pub const SPRITE_ROACH: Sprite = Sprite { - w: 26, - h: 14, - rects: &[ - // Dorsal fin - (10, 0, 5, 2, R_FIN), - // Upper outline & back - (5, 2, 11, 1, R_OUT), - (3, 3, 15, 2, R_BACK), - (1, 5, 19, 3, R_MID), - (2, 8, 17, 2, R_BELLY), - (5, 10, 11, 1, R_OUT), - // Ventral fin - (11, 11, 4, 2, R_FIN), - // Tail - (20, 4, 3, 6, R_FIN), - (23, 2, 3, 4, R_FIN), - (23, 8, 3, 4, R_FIN), - // Eye & gill - (4, 5, 2, 2, EYE_W), - (4, 5, 1, 1, EYE_K), - (8, 5, 1, 4, R_OUT), - ], -}; - -// 2. STRIPED PERCH (28x15): olive-gold body, bold dark vertical tiger stripes, orange fins. -const P_OUT: u16 = c565(26, 42, 28); -const P_BACK: u16 = c565(78, 134, 64); -const P_GOLD: u16 = c565(188, 198, 72); -const P_BELLY: u16 = c565(236, 228, 146); -const P_STRIPE: u16 = c565(34, 58, 40); -const P_FIN: u16 = c565(242, 112, 36); - -pub const SPRITE_PERCH: Sprite = Sprite { - w: 28, - h: 15, - rects: &[ - // Spiky dorsal fin - (9, 0, 8, 2, P_BACK), - (10, 1, 6, 1, P_FIN), - // Body - (5, 2, 13, 1, P_OUT), - (3, 3, 17, 3, P_BACK), - (1, 6, 20, 3, P_GOLD), - (2, 9, 17, 2, P_BELLY), - (5, 11, 12, 1, P_OUT), - // Tiger stripes - (9, 3, 2, 6, P_STRIPE), - (13, 3, 2, 6, P_STRIPE), - (17, 4, 2, 5, P_STRIPE), - // Orange lower fins & tail - (11, 12, 5, 2, P_FIN), - (21, 5, 3, 5, P_FIN), - (24, 3, 3, 4, P_FIN), - (24, 8, 3, 4, P_FIN), - // Eye & gill - (4, 5, 2, 2, EYE_W), - (4, 6, 1, 1, EYE_K), - (7, 5, 1, 4, P_OUT), - ], -}; - -// 3. RAINBOW TROUT (30x14): slender turquoise-silver predator with pink rainbow stripe & speckles. -const T_BACK: u16 = c565(46, 116, 126); -const T_SILVER: u16 = c565(186, 212, 224); -const T_PINK: u16 = c565(236, 114, 152); -const T_BELLY: u16 = c565(240, 244, 248); -const T_SPOT: u16 = c565(28, 48, 60); -const T_FIN: u16 = c565(132, 166, 186); - -pub const SPRITE_TROUT: Sprite = Sprite { - w: 30, - h: 14, - rects: &[ - (12, 0, 5, 2, T_FIN), - (5, 2, 16, 3, T_BACK), - (2, 5, 21, 2, T_SILVER), - (3, 7, 19, 2, T_PINK), - (4, 9, 17, 2, T_BELLY), - // Speckles - (9, 3, 1, 1, T_SPOT), - (13, 4, 1, 1, T_SPOT), - (16, 3, 1, 1, T_SPOT), - (19, 4, 1, 1, T_SPOT), - // Lower fin & forked tail - (13, 11, 4, 2, T_PINK), - (23, 5, 3, 4, T_BACK), - (26, 3, 4, 3, T_FIN), - (26, 8, 4, 3, T_FIN), - // Eye & mouth - (4, 5, 2, 2, EYE_W), - (4, 5, 1, 1, EYE_K), - (1, 7, 3, 1, T_SPOT), - ], -}; - -// 4. AMBER CARP (29x17): broad golden-bronze carp with deep scales & warm belly. -const C_DARK: u16 = c565(106, 56, 20); -const C_BRONZE: u16 = c565(204, 126, 44); -const C_GOLD: u16 = c565(242, 182, 68); -const C_CREAM: u16 = c565(250, 224, 138); -const C_FIN: u16 = c565(218, 92, 34); - -pub const SPRITE_CARP: Sprite = Sprite { - w: 29, - h: 17, - rects: &[ - // Long carp dorsal crest - (9, 0, 10, 2, C_FIN), - (6, 2, 13, 1, C_DARK), - (3, 3, 17, 3, C_BRONZE), - (1, 6, 20, 4, C_GOLD), - (2, 10, 18, 3, C_CREAM), - (5, 13, 12, 1, C_DARK), - // Scale glints - (10, 5, 2, 2, C_GOLD), - (14, 7, 2, 2, C_CREAM), - (11, 8, 2, 2, C_BRONZE), - // Belly fins & fan tail - (12, 14, 5, 2, C_FIN), - (21, 6, 4, 5, C_FIN), - (25, 4, 4, 4, C_FIN), - (25, 9, 4, 4, C_FIN), - // Eye & whisker - (4, 6, 2, 2, EYE_W), - (4, 7, 1, 1, EYE_K), - (0, 9, 2, 2, C_GOLD), - ], -}; - -// 5. NORTHERN PIKE (32x13): long sleek ambush predator with emerald hide & pale yellow spots. -const K_DARK: u16 = c565(24, 66, 44); -const K_GREEN: u16 = c565(56, 134, 74); -const K_SPOT: u16 = c565(218, 232, 118); -const K_BELLY: u16 = c565(222, 234, 198); -const K_FIN: u16 = c565(204, 98, 42); - -pub const SPRITE_PIKE: Sprite = Sprite { - w: 32, - h: 13, - rects: &[ - // Rear dorsal fin (signature pike silhouette!) - (19, 0, 5, 2, K_FIN), - // Long snout & body - (1, 4, 24, 2, K_DARK), - (0, 6, 26, 3, K_GREEN), - (3, 9, 21, 2, K_BELLY), - // Predator spots - (10, 5, 2, 1, K_SPOT), - (14, 7, 2, 1, K_SPOT), - (18, 5, 2, 1, K_SPOT), - (22, 7, 2, 1, K_SPOT), - // Tail & lower fins - (20, 11, 4, 2, K_FIN), - (26, 5, 3, 4, K_DARK), - (29, 3, 3, 3, K_FIN), - (29, 8, 3, 3, K_FIN), - // Fierce eye & jaw - (5, 4, 2, 2, K_SPOT), - (5, 5, 1, 1, EYE_K), - (0, 7, 5, 1, K_DARK), - ], -}; - -// 6. GOLDEN KOI (31x16): rare radiant orange-gold & pearl-white ornamental trophy fish. -const G_CRIMSON: u16 = c565(234, 58, 36); -const G_GOLD: u16 = c565(255, 196, 46); -const G_PEARL: u16 = c565(252, 248, 238); -const G_OUT: u16 = c565(146, 54, 16); - -pub const SPRITE_KOI: Sprite = Sprite { - w: 31, - h: 16, - rects: &[ - // Flowing crest & body - (10, 0, 9, 2, G_GOLD), - (5, 2, 15, 1, G_OUT), - (3, 3, 18, 3, G_GOLD), - (1, 6, 21, 4, G_PEARL), - (3, 10, 18, 2, G_GOLD), - (6, 12, 12, 1, G_OUT), - // Koi crimson patches - (3, 4, 5, 4, G_CRIMSON), - (12, 3, 6, 5, G_CRIMSON), - (17, 7, 4, 3, G_CRIMSON), - // Flowing veil fins & tail - (10, 13, 6, 3, G_GOLD), - (22, 5, 4, 6, G_CRIMSON), - (26, 2, 5, 5, G_GOLD), - (26, 8, 5, 5, G_PEARL), - // Eye - (4, 6, 2, 2, EYE_W), - (4, 6, 1, 1, EYE_K), - ], -}; diff --git a/apps/lake-cast/src/view.rs b/apps/lake-cast/src/view.rs deleted file mode 100644 index 51ff843..0000000 --- a/apps/lake-cast/src/view.rs +++ /dev/null @@ -1,1598 +0,0 @@ -//! Open-beach Lake Cast renderer matching the user's sketch: full azure lake (`0..SHORE_Y`), -//! warm sandy beach (`SHORE_Y..SIZE`), rod rising from sand into water, single-pass zero-flicker -//! swimming fish rendering, and left vertical bar that appears only during Reeling. - -use crate::font::{FONT_LG, FONT_MD, FONT_SM}; -use crate::game::{ - format_weight, rod_pose, Difficulty, Game, LakeFish, Mode, Records, RodPose, Species, State, - C, CAUGHT_BTN_H, CAUGHT_BTN_W, CAUGHT_BTN_X, CAUGHT_BTN_Y, DIFFICULTIES, GAUGE_H, GAUGE_W, - GAUGE_X, GAUGE_Y, HUD_H, HUD_INFO_W, HUD_INFO_X, HUD_MENU_W, HUD_MENU_X, HUD_Y, MAX_FISH, - MENU_BTN_H, MENU_BTN_W, MENU_BTN_X, MENU_DERBY_Y, MENU_RELAX_Y, MENU_TROPHY_Y, OVER_BTN_H, - OVER_BTN_W, OVER_BTN_X, OVER_MENU_Y, OVER_RETRY_Y, PROG_W, PROG_X, SHORE_Y, SIZE, SPECIES_ALL, - TRACK_H, TRACK_W, TRACK_X, TRACK_Y, TROPHY_NAV_H, TROPHY_NAV_W, TROPHY_NAV_Y, TROPHY_NEXT_X, - TROPHY_PREV_X, -}; -use crate::sprites::draw_fish; -use cmf_wp2_ui::draw::{line, rrect, Run}; -use cmf_wp2_ui::motion::isqrt; -use cmf_wp2_ui::text::int; -use cmf_wp2_ui::{ONE, Rgb, Surface}; - -const WHITE: Rgb = Rgb(255, 255, 255); -const SHADOW_TEXT: Rgb = Rgb(10, 48, 86); -const PILL_BG: Rgb = Rgb(12, 34, 58); -const PILL_BORDER: Rgb = Rgb(86, 178, 218); -const PILL_ACTIVE_BG: Rgb = Rgb(20, 66, 98); -const PILL_ACTIVE_RIM: Rgb = Rgb(255, 206, 86); -const CARD_BG: Rgb = Rgb(11, 32, 54); -const CARD_BORDER: Rgb = Rgb(242, 194, 72); -const DIM_TEXT: Rgb = Rgb(172, 210, 232); -const TROPHY_BG: Rgb = Rgb(12, 34, 56); -const SILHOUETTE: Rgb = Rgb(28, 72, 102); - -// Left vertical gauge colors. -const GAUGE_FRAME: Rgb = Rgb(138, 92, 52); -const GAUGE_RIM: Rgb = Rgb(228, 178, 98); -const TRACK_BG: Rgb = Rgb(16, 44, 68); -const BAR_LIT: Rgb = Rgb(84, 226, 114); -const BAR_LIT_EDGE: Rgb = Rgb(172, 252, 186); -const BAR_DIM: Rgb = Rgb(48, 124, 82); -const BAR_DIM_EDGE: Rgb = Rgb(88, 164, 118); - -const CAUGHT_X: i32 = 84; -const CAUGHT_Y: i32 = 98; -const CAUGHT_W: i32 = 298; -const CAUGHT_H: i32 = 280; - -#[derive(Clone, Copy, PartialEq, Eq, Debug)] -struct Rect { - x0: i32, - y0: i32, - x1: i32, - y1: i32, -} - -impl Rect { - fn new(x: i32, y: i32, w: i32, h: i32) -> Self { - Rect { - x0: x.max(0), - y0: y.max(0), - x1: (x + w).min(SIZE), - y1: (y + h).min(SIZE), - } - } - - fn empty() -> Self { - Rect { x0: 0, y0: 0, x1: 0, y1: 0 } - } - - fn is_empty(self) -> bool { - self.x1 <= self.x0 || self.y1 <= self.y0 - } - - fn union(self, other: Self) -> Self { - if self.is_empty() { - return other; - } - if other.is_empty() { - return self; - } - Rect { - x0: self.x0.min(other.x0), - y0: self.y0.min(other.y0), - x1: self.x1.max(other.x1), - y1: self.y1.max(other.y1), - } - } - - fn intersects(self, other: Self) -> bool { - !self.is_empty() - && !other.is_empty() - && self.x0 < other.x1 - && self.x1 > other.x0 - && self.y0 < other.y1 - && self.y1 > other.y0 - } -} - -struct Clip<'a, S: Surface> { - s: &'a mut S, - r: Rect, -} - -impl Surface for Clip<'_, S> { - fn rect(&mut self, x: i32, y: i32, w: i32, h: i32, c: u16) { - let ax = x.max(self.r.x0); - let ay = y.max(self.r.y0); - let bx = (x + w).min(self.r.x1); - let by = (y + h).min(self.r.y1); - if bx > ax && by > ay { - self.s.rect(ax, ay, bx - ax, by - ay, c); - } - } - - fn text(&mut self, x: i32, y: i32, t: &str, c: u16) { - self.s.text(x, y, t, c); - } -} - -/// Deterministic background matching user sketch: full azure lake (`0..SHORE_Y`) + warm yellow sand (`SHORE_Y..SIZE`). -pub fn scene_rgb(x: i32, y: i32) -> Rgb { - if y < SHORE_Y { - if y >= SHORE_Y - 3 { - return Rgb(188, 242, 248); // shoreline foam highlight - } - // Smooth 4px-banded bright azure/ocean water gradient. - let wy = (y & !3).clamp(0, SHORE_Y - 4); - let mut wcol = if wy < 140 { - Rgb(14, 128, 196).mix(Rgb(20, 162, 214), wy * ONE / 140) - } else { - Rgb(20, 162, 214).mix(Rgb(46, 194, 228), (wy - 140) * ONE / (SHORE_Y - 144)) - }; - // Subtle ambient water shimmer streaks. - if (y % 26) == 0 && ((x + y * 3) % 67) < 8 { - wcol = wcol.mix(Rgb(126, 224, 244), 260); - } - return wcol; - } - - if y < SHORE_Y + 7 { - return Rgb(194, 160, 88); // wet shoreline sand strip - } - - // Sunny warm golden sand beach. - let sy = ((y - SHORE_Y - 7) & !3).clamp(0, SIZE - SHORE_Y - 7); - let sand = Rgb(246, 206, 102).mix(Rgb(234, 184, 78), sy * ONE / (SIZE - SHORE_Y - 7)); - - // Small beach pebbles safely in lower sand (`y = 355..432`). - const PEBBLES: [(i32, i32, i32); 3] = [(118, 376, 5), (356, 364, 5), (318, 412, 4)]; - for &(px, py, pr) in &PEBBLES { - let d2 = (x - px) * (x - px) + (y - py) * (y - py); - if d2 <= pr * pr { - return if y < py { Rgb(160, 152, 138) } else { Rgb(114, 106, 94) }; - } - } - sand -} - -fn bg_has_row_variation(y: i32) -> bool { - if y < SHORE_Y - 3 { - return (y % 26) == 0; - } - if y < SHORE_Y + 7 { - return false; - } - y >= 355 && y <= 420 -} - -fn draw_bg_box(s: &mut impl Surface, r: Rect) { - if r.is_empty() { - return; - } - let mut y = r.y0; - while y < r.y1 { - if !bg_has_row_variation(y) { - let c = scene_rgb(r.x0, y).rgb565(); - let mut y_end = y + 1; - while y_end < r.y1 && !bg_has_row_variation(y_end) && scene_rgb(r.x0, y_end).rgb565() == c - { - y_end += 1; - } - s.rect(r.x0, y, r.x1 - r.x0, y_end - y, c); - y = y_end; - continue; - } - let mut run = Run::new(s, y, false); - for x in r.x0..r.x1 { - run.put(x, 1, scene_rgb(x, y).rgb565()); - } - drop(run); - y += 1; - } -} - -fn fish_bbox(f: &LakeFish) -> Rect { - let (w, h, _) = f.species.silhouette(); - Rect::new(f.x() - w / 2 - 12, f.y() - h / 2 - 6, w + 24, h + 12) -} - -/// Evaluates whether pixel `(x, y)` belongs to `f` underwater sprite (ZERO-FLICKER single-pass render!). -fn fish_pixel_at(f: &LakeFish, x: i32, y: i32) -> Option { - let (w, h, _) = f.species.silhouette(); - let cx = f.x(); - let cy = f.y(); - let rx = (w / 2).max(9); - let ry = (h / 2).max(4); - if (y - cy).abs() > ry + 4 || (x - cx).abs() > rx + 10 { - return None; - } - - let dir = if f.facing_right() { 1 } else { -1 }; - let lx = (x - cx) * dir; // + toward nose, - toward tail - let dy = y - cy; - let wag = (((f.phase_ms as i32 / 90) % 4) - 2).abs() - 1; - let depth = scene_rgb(x.clamp(0, SIZE - 1), y.clamp(0, SHORE_Y - 1)); - - // Palette per species softly blended into water depth so fish stay genuinely submerged. - let (dorsal_t, flank_t, belly_t, fin_t, mix_w) = match f.species { - Species::Roach => (Rgb(22, 62, 108), Rgb(118, 188, 224), Rgb(208, 238, 250), Rgb(224, 96, 68), 640), - Species::Perch => (Rgb(26, 78, 54), Rgb(108, 164, 72), Rgb(198, 222, 138), Rgb(232, 122, 46), 670), - Species::Trout => (Rgb(20, 84, 108), Rgb(112, 182, 206), Rgb(218, 236, 244), Rgb(228, 118, 154), 650), - Species::Carp => (Rgb(84, 58, 24), Rgb(178, 132, 56), Rgb(234, 202, 118), Rgb(214, 98, 42), 680), - Species::Pike => (Rgb(18, 66, 48), Rgb(56, 128, 76), Rgb(168, 212, 166), Rgb(192, 98, 46), 670), - Species::GoldenKoi => (Rgb(226, 86, 36), Rgb(248, 194, 58), Rgb(248, 244, 228), Rgb(246, 136, 46), 740), - }; - let shade = |c: Rgb| depth.mix(c, mix_w).rgb565(); - - // Organic tapered body contour: rounded snout front, graceful taper to a narrow tail wrist. - let front_x = match f.species { - Species::Pike => rx / 6, - Species::Carp | Species::GoldenKoi => rx / 3, - _ => rx / 4, - }; - let tail_wrist_x = -rx + 1; - let body_half = if lx >= tail_wrist_x && lx <= rx { - if lx >= front_x { - let fr = (rx - front_x + 1).max(2); - let dx_f = lx - front_x; - ry * isqrt((fr * fr - dx_f * dx_f).max(0)) / fr - } else { - let span_b = (front_x - tail_wrist_x).max(1); - let t = lx - tail_wrist_x; - let wrist = if ry >= 6 { 2 } else { 1 }; - wrist + (ry - wrist) * (t * (2 * span_b - t)) / (span_b * span_b) - } - } else { - -1 - }; - - if body_half > 0 && dy.abs() <= body_half { - // Eye glint near upper-front head. - let eye_x = rx - 5; - let eye_y = -(ry / 3).max(1); - if lx >= eye_x && lx <= eye_x + 1 && dy >= eye_y && dy <= eye_y + 1 { - let eye_c = if lx == eye_x && dy == eye_y { - Rgb(10, 18, 28) - } else { - Rgb(242, 250, 255) - }; - return Some(depth.mix(eye_c, 820).rgb565()); - } - - // Curved gill accent behind head. - if lx == eye_x - 3 && dy.abs() <= (body_half - 2).max(1) && dy >= -body_half / 2 { - return Some(shade(dorsal_t)); - } - - // Species-distinct markings & dorsal-to-belly shading. - let col = match f.species { - Species::Perch => { - if dy < body_half - 1 && lx < eye_x - 3 && lx > tail_wrist_x + 2 && (lx + 5).rem_euclid(5) < 2 { - dorsal_t - } else if dy <= -body_half / 3 { - dorsal_t - } else if dy >= body_half * 2 / 3 { - belly_t - } else { - flank_t - } - } - Species::Trout => { - if (dy == 0 || dy == 1) && lx < eye_x - 2 && lx > tail_wrist_x + 1 { - fin_t - } else if dy < 0 && ((lx + dy * 2) & 3) == 0 && lx < eye_x - 2 { - Rgb(16, 48, 66) - } else if dy <= -body_half / 3 { - dorsal_t - } else if dy >= body_half * 2 / 3 { - belly_t - } else { - flank_t - } - } - Species::Pike => { - if dy >= -1 && dy < body_half - 1 && ((lx + dy * 3) & 7) == 0 && lx < eye_x - 2 { - Rgb(210, 228, 128) - } else if dy <= -body_half / 3 { - dorsal_t - } else if dy >= body_half * 2 / 3 { - belly_t - } else { - flank_t - } - } - Species::GoldenKoi => { - if ((lx >= 2 && lx <= 7) || (lx >= -6 && lx <= -2)) && dy <= 1 { - dorsal_t // crimson koi spot - } else if dy >= 2 { - belly_t // pearl belly - } else { - flank_t // golden back - } - } - _ => { - if dy <= -body_half / 3 { - dorsal_t - } else if dy >= body_half * 2 / 3 { - belly_t - } else { - flank_t - } - } - }; - return Some(shade(col)); - } - - // Species-shaped dorsal crest on top. - let (d0, d1, dh) = match f.species { - Species::Pike => (-rx + 3, -rx + 10, 2), - Species::Carp | Species::GoldenKoi => (-rx / 2, rx / 4, 2), - Species::Perch => (-3, rx / 3, 2), - _ => (-2, rx / 4, 2), - }; - if lx >= d0 && lx <= d1 && body_half > 0 && dy < -body_half && dy >= -body_half - dh { - if lx > d0 || dy == -body_half - 1 { - return Some(shade(fin_t)); - } - } - - // Lower pectoral/ventral fin. - if lx >= -3 && lx <= 2 && body_half > 0 && (dy == body_half + 1 || (dy == body_half + 2 && lx <= 0)) { - return Some(shade(fin_t)); - } - - // Flared forked or veil caudal tail behind the narrow tail wrist (`step >= 0`). - let tail_len = if f.species == Species::GoldenKoi { 8 } else { 6 }; - let step = tail_wrist_x - lx; - if (0..=tail_len).contains(&step) { - let wy = cy + wag * step / tail_len; - let tdy = (y - wy).abs(); - let half = 1 + step * (ry + 1) / tail_len; - let forked = !matches!(f.species, Species::Carp | Species::GoldenKoi); - if forked && step >= 3 { - let notch = (step - 2).min(half - 1); - if tdy >= notch && tdy <= half { - return Some(shade(fin_t)); - } - } else if tdy <= half { - return Some(shade(if f.species == Species::GoldenKoi && dy > 0 { belly_t } else { fin_t })); - } - } - - None -} - -fn rod_bounds(pose: RodPose, bob_x: i32, bob_y: i32) -> Rect { - let x0 = pose.grip_x.min(pose.ctrl_x).min(pose.tip_x).min(bob_x) - 16; - let x1 = pose.grip_x.max(pose.ctrl_x).max(pose.tip_x).max(bob_x) + 16; - let y0 = pose.grip_y.min(pose.ctrl_y).min(pose.tip_y).min(bob_y) - 10; - let y1 = pose.grip_y.max(bob_y) + 12; - Rect::new(x0, y0, x1 - x0, y1 - y0) -} - -fn draw_rod_and_line( - s: &mut impl Surface, - pose: RodPose, - bob_x: i32, - bob_y: i32, - show_line: bool, - taut: bool, - clip: Rect, -) { - let mut c = Clip { s, r: clip }; - let under = |px: i32, py: i32| scene_rgb(px.clamp(0, SIZE - 1), py.clamp(0, SIZE - 1)); - - if show_line { - let line_col = if taut { WHITE } else { Rgb(218, 244, 255) }; - if taut { - line(&mut c, pose.tip_x, pose.tip_y, bob_x, bob_y, 2, line_col, under(pose.tip_x, pose.tip_y)); - } else { - let mx = (pose.tip_x + bob_x) / 2; - let my = (pose.tip_y + bob_y) / 2 + 8; - line(&mut c, pose.tip_x, pose.tip_y, mx, my, 1, line_col, under(mx, my)); - line(&mut c, mx, my, bob_x, bob_y, 1, line_col, under(bob_x, bob_y)); - } - } - - // Sleek ivory-white & warm cork rod matching user sketch, with small red tip marker when aiming! - let mut px = pose.grip_x; - let mut py = pose.grip_y; - for step in 1..=5 { - let t = step * 256 / 5; - let u = 256 - t; - let nx = (u * u * pose.grip_x + 2 * u * t * pose.ctrl_x + t * t * pose.tip_x) >> 16; - let ny = (u * u * pose.grip_y + 2 * u * t * pose.ctrl_y + t * t * pose.tip_y) >> 16; - let thick = match step { - 1 => 6, - 2 => 4, - 3 | 4 => 3, - _ => 2, - }; - let col = if step == 1 { - Rgb(172, 114, 62) // cork handle on beach sand - } else { - Rgb(246, 248, 252) // clean crisp white shaft (as in sketch!) - }; - line(&mut c, px, py, nx, ny, thick, col, under((px + nx) / 2, (py + ny) / 2)); - px = nx; - py = ny; - } - - // Red tip marker when uncast (or reel at bottom). - if !show_line { - c.rect(pose.tip_x - 3, pose.tip_y - 3, 6, 5, Rgb(246, 60, 44).rgb565()); - } - let rx = (pose.grip_x * 3 + pose.ctrl_x) / 4; - let ry = (pose.grip_y * 3 + pose.ctrl_y) / 4; - c.rect(rx - 5, ry - 5, 10, 10, Rgb(228, 174, 52).rgb565()); - c.rect(rx - 3, ry - 3, 6, 6, Rgb(36, 42, 52).rgb565()); -} - -const HOOK_PW: i32 = 74; -const HOOK_PH: i32 = 24; - -fn hook_pill_pos(bx: i32, by: i32) -> (i32, i32) { - ( - (bx - HOOK_PW / 2).clamp(112, SIZE - HOOK_PW - 36), - (by - 34).max(HUD_Y + HUD_H + 8), - ) -} - -fn bobber_bounds(bx: i32, by: i32, state: State, splash_ms: u32) -> Rect { - if state == State::Banner { - return Rect::new( - (bx - 76).clamp(108, SIZE - 170), - (by - 24).clamp(HUD_Y + HUD_H + 10, SHORE_Y - 40), - 152, - 48, - ); - } - if state == State::Bite { - let (px, hpy) = hook_pill_pos(bx, by); - return Rect::new(bx - 36, by - 36, 72, 72) - .union(Rect::new(px - 2, hpy - 2, HOOK_PW + 4, HOOK_PH + 4)); - } - let r = if splash_ms > 0 { 36 } else { 18 }; - Rect::new(bx - r, by - r - 8, r * 2, r * 2 + 16) -} - -fn draw_ring_outline(s: &mut impl Surface, cx: i32, cy: i32, r: i32, col: Rgb) { - if r <= 2 { - return; - } - let c = col.rgb565(); - let r2_hi = (r + 1) * (r + 1); - let r2_lo = (r - 1) * (r - 1); - for dy in -r..=r { - let oy = dy * 2; - if oy.abs() > r + 1 { - continue; - } - let mut run = Run::new(s, cy + dy, false); - for dx in -r..=r { - let d2 = dx * dx + oy * oy; - if d2 >= r2_lo && d2 <= r2_hi { - run.put(cx + dx, 1, c); - } - } - } -} - -fn draw_bobber_and_fx(s: &mut impl Surface, g: &Game, clip: Rect) { - if !g.has_cast && g.state != State::Banner { - return; - } - let (bx, by) = g.bobber_pos(); - let bb = bobber_bounds(bx, by, g.state, g.splash_ms); - if !bb.intersects(clip) { - return; - } - let mut c = Clip { s, r: clip }; - - if g.state == State::Banner { - let bw = 144; - let bh = 32; - let x = (bx - bw / 2).clamp(112, SIZE - bw - 26); - let y = (by - 16).clamp(HUD_Y + HUD_H + 12, SHORE_Y - bh - 12); - let border = Rgb(255, 176, 68); - rrect(&mut c, x, y, bw, bh, 12, border, scene_rgb(x, y)); - rrect(&mut c, x + 2, y + 2, bw - 4, bh - 4, 10, PILL_BG, border); - FONT_SM.centre(&mut c, x + bw / 2, y + 8, "FISH ESCAPED!", WHITE, PILL_BG); - return; - } - - if g.splash_ms > 0 { - let k = (520 - g.splash_ms.min(520)) as i32; - let r1 = 8 + k / 20; - draw_ring_outline(&mut c, bx, by + 2, r1, Rgb(220, 248, 255)); - if r1 > 14 { - draw_ring_outline(&mut c, bx, by + 2, r1 - 9, Rgb(146, 226, 246)); - } - } - - if g.state == State::Floating { - let wave_r = 9 + ((g.lake_ms / 120) % 6) as i32; - draw_ring_outline(&mut c, bx, by + 2, wave_r, Rgb(176, 236, 250)); - } - - if g.state == State::Reeling { - let col = if g.fish_in_bar { Rgb(106, 244, 184) } else { Rgb(255, 134, 82) }; - let wave_r = 9 + ((g.reel_phase_ms / 140) % 5) as i32; - draw_ring_outline(&mut c, bx, by + 2, wave_r, col); - c.rect(bx - 3, by - 4, 6, 4, Rgb(252, 68, 48).rgb565()); - c.rect(bx - 3, by, 6, 3, WHITE.rgb565()); - return; - } - - let bob_dy = match g.state { - State::Floating => (((g.lake_ms / 240) % 4) as i32 - 2).abs() - 1, - State::Nibble => 3, - State::Bite => 7, - _ => 0, - }; - let py = by + bob_dy; - - if g.state != State::Bite { - c.rect(bx - 1, py - 9, 2, 4, Rgb(30, 34, 42).rgb565()); - c.rect(bx - 4, py - 5, 8, 5, Rgb(252, 68, 48).rgb565()); - c.rect(bx - 5, py - 4, 10, 3, Rgb(252, 68, 48).rgb565()); - c.rect(bx - 2, py - 4, 2, 2, WHITE.rgb565()); - c.rect(bx - 4, py, 8, 4, WHITE.rgb565()); - } else { - c.rect(bx - 4, py - 2, 8, 5, Rgb(255, 124, 46).rgb565()); - draw_ring_outline(&mut c, bx, by + 2, 18, Rgb(255, 226, 86)); - let (px, hpy) = hook_pill_pos(bx, by); - rrect(&mut c, px, hpy, HOOK_PW, HOOK_PH, 10, Rgb(255, 138, 36), scene_rgb(px, hpy)); - FONT_SM.centre(&mut c, px + HOOK_PW / 2, hpy + 5, "HOOK!", WHITE, Rgb(255, 138, 36)); - } -} - -/// Draws the wooden left gauge frame ONLY when `Reeling`. -fn draw_gauge_frame(s: &mut impl Surface) { - rrect( - s, - GAUGE_X, - GAUGE_Y, - GAUGE_W, - GAUGE_H, - 10, - GAUGE_RIM, - scene_rgb(GAUGE_X, GAUGE_Y), - ); - rrect( - s, - GAUGE_X + 2, - GAUGE_Y + 2, - GAUGE_W - 4, - GAUGE_H - 4, - 8, - GAUGE_FRAME, - GAUGE_RIM, - ); -} - -fn prog_color(reel_progress: i32) -> (u8, Rgb) { - if reel_progress >= 720 { - (2, Rgb(84, 242, 168)) - } else if reel_progress >= 360 { - (1, Rgb(248, 206, 68)) - } else { - (0, Rgb(242, 118, 58)) - } -} - -fn gauge_row_sig(y: i32, bar_top: i32, bar_bot: i32, fy: i32) -> (u8, i32) { - let zone = if y >= bar_top && y < bar_bot { - if y == bar_top || y == bar_bot - 1 { 1 } else { 2 } - } else { - 0 - }; - let d = y - fy; - let f_rel = if (-5..=5).contains(&d) { d } else { 99 }; - (zone, f_rel) -} - -/// ZERO-FLICKER incremental single-pass vertical gauge interior: skips unchanged scanlines and writes only deltas! -fn draw_gauge_inner(s: &mut impl Surface, g: &Game, prev: Option) { - let bar_top = g.bar_y.clamp(0, TRACK_H); - let bar_bot = (g.bar_y + g.bar_h).clamp(bar_top, TRACK_H); - let bar_fill = if g.fish_in_bar { BAR_LIT.rgb565() } else { BAR_DIM.rgb565() }; - let bar_edge = if g.fish_in_bar { - BAR_LIT_EDGE.rgb565() - } else { - BAR_DIM_EDGE.rgb565() - }; - - let fy = g.track_fish_y(); - let track_bg_c = TRACK_BG.rgb565(); - let fish_body_c = Rgb(255, 188, 56).rgb565(); - let fish_out_c = Rgb(168, 66, 22).rgb565(); - let fish_eye_c = WHITE.rgb565(); - - let diff_only = prev.filter(|o| o.fish_in_bar == g.fish_in_bar); - let old_bar_top = diff_only.map_or(0, |o| o.bar_y.clamp(0, TRACK_H)); - let old_bar_bot = diff_only.map_or(0, |o| (o.bar_y + o.bar_h).clamp(old_bar_top, TRACK_H)); - let old_fy = diff_only.map_or(-99, |o| o.track_fish_y); - - let mut y = 0; - while y < TRACK_H { - let cur_sig = gauge_row_sig(y, bar_top, bar_bot, fy); - if diff_only.is_some() && cur_sig == gauge_row_sig(y, old_bar_top, old_bar_bot, old_fy) { - y += 1; - continue; - } - - if cur_sig.1 != 99 { - let dy = (y - fy).abs(); - let half = match dy { - 0..=1 => 7, - 2..=3 => 5, - _ => 3, - }; - let bg_c = match cur_sig.0 { - 1 => bar_edge, - 2 => bar_fill, - _ => track_bg_c, - }; - let cx = TRACK_W / 2; - let fx0 = cx - half; - let fx1 = cx + half; - s.rect(TRACK_X, TRACK_Y + y, fx0, 1, bg_c); - s.rect(TRACK_X + fx0, TRACK_Y + y, 1, 1, fish_out_c); - if dy == 1 && y < fy { - s.rect(TRACK_X + fx0 + 1, TRACK_Y + y, 2, 1, fish_eye_c); - s.rect(TRACK_X + fx0 + 3, TRACK_Y + y, (fx1 - fx0 - 4).max(1), 1, fish_body_c); - } else { - s.rect(TRACK_X + fx0 + 1, TRACK_Y + y, (fx1 - fx0 - 2).max(1), 1, fish_body_c); - } - s.rect(TRACK_X + fx1 - 1, TRACK_Y + y, 1, 1, fish_out_c); - s.rect(TRACK_X + fx1, TRACK_Y + y, TRACK_W - fx1, 1, bg_c); - y += 1; - continue; - } - - let col = match cur_sig.0 { - 1 => bar_edge, - 2 => bar_fill, - _ => track_bg_c, - }; - let mut y_end = y + 1; - while y_end < TRACK_H { - let nsig = gauge_row_sig(y_end, bar_top, bar_bot, fy); - if nsig != cur_sig { - break; - } - if diff_only.is_some() && nsig == gauge_row_sig(y_end, old_bar_top, old_bar_bot, old_fy) { - break; - } - y_end += 1; - } - s.rect(TRACK_X, TRACK_Y + y, TRACK_W, y_end - y, col); - y = y_end; - } - - let fill_h = (g.reel_progress.clamp(0, 1000) * TRACK_H / 1000).clamp(0, TRACK_H); - let empty_h = TRACK_H - fill_h; - let empty_bg = Rgb(18, 38, 54).rgb565(); - let (bucket, pcol) = prog_color(g.reel_progress); - let pcol_c = pcol.rgb565(); - - match prev { - Some(old) if old.prog_bucket == bucket => { - if fill_h > old.prog_h { - s.rect(PROG_X, TRACK_Y + empty_h, PROG_W, fill_h - old.prog_h, pcol_c); - } else if fill_h < old.prog_h { - let old_empty = TRACK_H - old.prog_h; - s.rect(PROG_X, TRACK_Y + old_empty, PROG_W, old.prog_h - fill_h, empty_bg); - } - } - _ => { - if empty_h > 0 { - s.rect(PROG_X, TRACK_Y, PROG_W, empty_h, empty_bg); - } - if fill_h > 0 { - s.rect(PROG_X, TRACK_Y + empty_h, PROG_W, fill_h, pcol_c); - } - } - } -} - -fn draw_hud(s: &mut impl Surface, g: &Game, best: Records, clip: Rect) { - if !matches!( - g.state, - State::Aim - | State::Casting - | State::Floating - | State::Nibble - | State::Bite - | State::Reeling - | State::Banner - ) { - return; - } - let hud_r = Rect::new(HUD_MENU_X, HUD_Y, HUD_INFO_X + HUD_INFO_W - HUD_MENU_X, HUD_H); - if !hud_r.intersects(clip) { - return; - } - let mut c = Clip { s, r: clip }; - rrect(&mut c, HUD_MENU_X, HUD_Y, HUD_MENU_W, HUD_H, 12, PILL_BORDER, scene_rgb(HUD_MENU_X, HUD_Y)); - rrect(&mut c, HUD_MENU_X + 2, HUD_Y + 2, HUD_MENU_W - 4, HUD_H - 4, 10, PILL_BG, PILL_BORDER); - FONT_SM.centre(&mut c, HUD_MENU_X + HUD_MENU_W / 2, HUD_Y + 6, "< MENU", WHITE, PILL_BG); - - let info_rim = g.difficulty.accent(); - rrect(&mut c, HUD_INFO_X, HUD_Y, HUD_INFO_W, HUD_H, 12, info_rim, scene_rgb(HUD_INFO_X, HUD_Y)); - rrect(&mut c, HUD_INFO_X + 2, HUD_Y + 2, HUD_INFO_W - 4, HUD_H - 4, 10, PILL_BG, info_rim); - - let mut line_buf = [0u8; 24]; - let mut len = 0usize; - let push = |buf: &mut [u8], len: &mut usize, bytes: &[u8]| { - let n = bytes.len().min(buf.len() - *len); - buf[*len..*len + n].copy_from_slice(&bytes[..n]); - *len += n; - }; - let mut db = [0u8; 11]; - push(&mut line_buf, &mut len, g.difficulty.short().as_bytes()); - push(&mut line_buf, &mut len, b" "); - push(&mut line_buf, &mut len, int(g.score as i32, &mut db).as_bytes()); - push(&mut line_buf, &mut len, b"P"); - match g.mode { - Mode::Relax => { - push(&mut line_buf, &mut len, b" B:"); - push(&mut line_buf, &mut len, int(best.relax_best as i32, &mut db).as_bytes()); - } - Mode::Derby => { - let secs = (g.derby_left_ms + 999) / 1000; - push(&mut line_buf, &mut len, b" "); - push(&mut line_buf, &mut len, int(secs as i32, &mut db).as_bytes()); - push(&mut line_buf, &mut len, b"S"); - } - } - let text = core::str::from_utf8(&line_buf[..len]).unwrap_or("0P"); - let timer_low = g.mode == Mode::Derby && g.derby_left_ms <= 10_000; - let fg = if timer_low { Rgb(255, 118, 96) } else { WHITE }; - FONT_SM.centre(&mut c, HUD_INFO_X + HUD_INFO_W / 2, HUD_Y + 6, text, fg, PILL_BG); -} - -fn draw_prompt_pill(s: &mut impl Surface, g: &Game, clip: Rect) { - if !matches!(g.state, State::Aim | State::Reeling) || (g.state == State::Aim && g.has_cast) { - return; - } - let pr = Rect::new(132, 68, 202, 24); - if !pr.intersects(clip) { - return; - } - let mut c = Clip { s, r: clip }; - let msg = if g.state == State::Reeling { - "CROWN: MOVE BAR" - } else { - "TAP WATER TO CAST" - }; - let rim = if g.state == State::Reeling { PILL_ACTIVE_RIM } else { PILL_BORDER }; - rrect(&mut c, 132, 68, 202, 24, 10, rim, scene_rgb(132, 68)); - rrect(&mut c, 134, 70, 198, 20, 8, PILL_BG, rim); - FONT_SM.centre(&mut c, C, 73, msg, WHITE, PILL_BG); -} - -fn draw_option_pills( - s: &mut impl Surface, - active_idx: usize, - confirming: bool, - items: &[(i32, &str, &str, Rgb); 3], -) { - for (idx, &(y, title, sub, accent)) in items.iter().enumerate() { - let active = active_idx == idx; - let lit = active && confirming; - let fill = if lit { - PILL_ACTIVE_BG.mix(accent, ONE * 36 / 100) - } else if active { - PILL_ACTIVE_BG - } else { - PILL_BG - }; - let rim = if lit { - accent.mix(WHITE, ONE / 2) - } else if active { - accent - } else { - PILL_BORDER - }; - rrect(s, MENU_BTN_X, y, MENU_BTN_W, MENU_BTN_H, 16, rim, scene_rgb(MENU_BTN_X, y)); - rrect(s, MENU_BTN_X + 2, y + 2, MENU_BTN_W - 4, MENU_BTN_H - 4, 14, fill, rim); - if active { - let bar_col = if lit { WHITE } else { accent }; - s.rect(MENU_BTN_X + 12, y + 12, 5, MENU_BTN_H - 24, bar_col.rgb565()); - } - let tcol = if lit || !active { WHITE } else { accent }; - let scol = if lit { WHITE.mix(DIM_TEXT, ONE / 2) } else { DIM_TEXT }; - FONT_MD.centre(s, C, y + 7, title, tcol, fill); - FONT_SM.centre(s, C, y + 31, sub, scol, fill); - } -} - -fn draw_menu_overlay(s: &mut impl Surface, g: &Game, best: Records) { - let under = |px: i32, py: i32| scene_rgb(px.clamp(0, SIZE - 1), py.clamp(0, SIZE - 1)); - FONT_LG.centre_over(s, C + 2, 34, "LAKE", SHADOW_TEXT, &under); - FONT_LG.centre_over(s, C, 32, "LAKE", WHITE, &under); - FONT_MD.centre_over(s, C + 1, 73, "CAST", SHADOW_TEXT, &under); - FONT_MD.centre_over(s, C, 72, "CAST", Rgb(255, 224, 108), &under); - - let mut b0 = [0u8; 20]; - let mut b1 = [0u8; 20]; - let mut b2 = [0u8; 20]; - let mut db = [0u8; 11]; - let fmt_sub = |prefix: &[u8], val: i32, suffix: &[u8], out: &mut [u8; 20], db: &mut [u8; 11]| -> usize { - let mut i = 0; - let pn = prefix.len().min(out.len()); - out[..pn].copy_from_slice(&prefix[..pn]); - i += pn; - let v = int(val, db).as_bytes(); - let vn = v.len().min(out.len() - i); - out[i..i + vn].copy_from_slice(&v[..vn]); - i += vn; - let sn = suffix.len().min(out.len() - i); - out[i..i + sn].copy_from_slice(&suffix[..sn]); - i + sn - }; - let l0 = fmt_sub(b"BEST ", best.relax_best as i32, b" PTS", &mut b0, &mut db); - let l1 = fmt_sub(b"BEST ", best.derby_best as i32, b" PTS", &mut b1, &mut db); - let l2 = fmt_sub(b"", best.species_unlocked() as i32, b"/6 SPECIES", &mut b2, &mut db); - - let items = [ - (MENU_RELAX_Y, "RELAX", core::str::from_utf8(&b0[..l0]).unwrap_or(""), PILL_ACTIVE_RIM), - (MENU_DERBY_Y, "DERBY 90S", core::str::from_utf8(&b1[..l1]).unwrap_or(""), PILL_ACTIVE_RIM), - (MENU_TROPHY_Y, "TROPHIES", core::str::from_utf8(&b2[..l2]).unwrap_or(""), PILL_ACTIVE_RIM), - ]; - - draw_option_pills(s, g.menu_sel, g.confirm_ms > 0, &items); - FONT_SM.centre_over(s, C, 372, "CROWN OR TAP", Rgb(62, 42, 20), &under); -} - -fn draw_difficulty_overlay(s: &mut impl Surface, g: &Game) { - let under = |px: i32, py: i32| scene_rgb(px.clamp(0, SIZE - 1), py.clamp(0, SIZE - 1)); - rrect(s, HUD_MENU_X, HUD_Y, HUD_MENU_W, HUD_H, 12, PILL_BORDER, scene_rgb(HUD_MENU_X, HUD_Y)); - rrect(s, HUD_MENU_X + 2, HUD_Y + 2, HUD_MENU_W - 4, HUD_H - 4, 10, PILL_BG, PILL_BORDER); - FONT_SM.centre(s, HUD_MENU_X + HUD_MENU_W / 2, HUD_Y + 6, "< BACK", WHITE, PILL_BG); - - let mode_label = match g.pending_mode { - Mode::Relax => "RELAX", - Mode::Derby => "DERBY 90S", - }; - rrect(s, HUD_INFO_X, HUD_Y, HUD_INFO_W, HUD_H, 12, PILL_BORDER, scene_rgb(HUD_INFO_X, HUD_Y)); - rrect(s, HUD_INFO_X + 2, HUD_Y + 2, HUD_INFO_W - 4, HUD_H - 4, 10, PILL_BG, PILL_BORDER); - FONT_SM.centre(s, HUD_INFO_X + HUD_INFO_W / 2, HUD_Y + 6, mode_label, Rgb(255, 224, 108), PILL_BG); - - FONT_MD.centre_over(s, C + 1, 93, "DIFFICULTY", SHADOW_TEXT, &under); - FONT_MD.centre_over(s, C, 92, "DIFFICULTY", WHITE, &under); - - let ys = [MENU_RELAX_Y, MENU_DERBY_Y, MENU_TROPHY_Y]; - let items = [ - (ys[0], DIFFICULTIES[0].name(), DIFFICULTIES[0].desc(), DIFFICULTIES[0].accent()), - (ys[1], DIFFICULTIES[1].name(), DIFFICULTIES[1].desc(), DIFFICULTIES[1].accent()), - (ys[2], DIFFICULTIES[2].name(), DIFFICULTIES[2].desc(), DIFFICULTIES[2].accent()), - ]; - draw_option_pills(s, g.diff_sel, g.confirm_ms > 0, &items); - FONT_SM.centre_over(s, C, 372, "CROWN OR TAP", Rgb(62, 42, 20), &under); -} - -/// Renders background + swimming fish silhouettes in a SINGLE PASS per pixel (ZERO FLICKER!). -fn paint_water_with_fish_single_pass(s: &mut impl Surface, g: &Game, clip: Rect) { - if clip.is_empty() { - return; - } - let mut fish_active = [false; MAX_FISH]; - let mut any_fish = false; - for i in 0..MAX_FISH { - if fish_bbox(&g.fish[i]).intersects(clip) { - fish_active[i] = true; - any_fish = true; - } - } - if !any_fish { - draw_bg_box(s, clip); - return; - } - - for y in clip.y0..clip.y1 { - let mut run = Run::new(s, y, false); - for x in clip.x0..clip.x1 { - let mut px_c = None; - for i in 0..MAX_FISH { - if fish_active[i] { - if let Some(fc) = fish_pixel_at(&g.fish[i], x, y) { - px_c = Some(fc); - break; - } - } - } - let final_c = px_c.unwrap_or_else(|| scene_rgb(x, y).rgb565()); - run.put(x, 1, final_c); - } - } -} - -fn paint_pond_region(s: &mut impl Surface, g: &Game, best: Records, clip: Rect) { - if clip.is_empty() { - return; - } - paint_water_with_fish_single_pass(s, g, clip); - - let (rod_target_x, rod_target_y) = if g.has_cast { (g.bx, g.by) } else { (186, 274) }; - let bend = match g.state { - State::Reeling => 64, - State::Bite => 48, - _ => 0, - }; - let pose = rod_pose(rod_target_x, rod_target_y, bend); - let (bob_x, bob_y) = g.bobber_pos(); - if rod_bounds(pose, bob_x, bob_y).intersects(clip) { - let show_line = g.has_cast && g.state != State::Banner; - let taut = matches!(g.state, State::Casting | State::Bite | State::Reeling); - draw_rod_and_line(s, pose, bob_x, bob_y, show_line, taut, clip); - } - draw_bobber_and_fx(s, g, clip); - draw_prompt_pill(s, g, clip); - draw_hud(s, g, best, clip); -} - -fn draw_weight_lg(s: &mut impl Surface, cx: i32, y: i32, hg: u16, fg: Rgb, bg: Rgb) { - let mut wb = [0u8; 16]; - let w_str = format_weight(hg, &mut wb); - let Some(dot_pos) = w_str.find('.') else { - FONT_LG.centre(s, cx, y, w_str, fg, bg); - return; - }; - let left = &w_str[..dot_pos]; - let right = &w_str[dot_pos + 1..]; - let lw = FONT_LG.width(left); - let rw = FONT_LG.width(right); - const DOT_ADV: i32 = 11; - let x0 = cx - (lw + DOT_ADV + rw) / 2; - FONT_LG.draw(s, x0, y, left, fg, bg); - let dx = x0 + lw + 3; - let dy = y + 26; - let fg_c = fg.rgb565(); - let aa_c = bg.mix(fg, ONE / 2).rgb565(); - s.rect(dx + 1, dy, 3, 5, fg_c); - s.rect(dx, dy + 1, 5, 3, fg_c); - s.rect(dx, dy, 1, 1, aa_c); - s.rect(dx + 4, dy, 1, 1, aa_c); - s.rect(dx, dy + 4, 1, 1, aa_c); - s.rect(dx + 4, dy + 4, 1, 1, aa_c); - FONT_LG.draw(s, x0 + lw + DOT_ADV, y, right, fg, bg); -} - -fn draw_caught_modal(s: &mut impl Surface, g: &Game) { - let sp = g.caught_species; - rrect(s, CAUGHT_X, CAUGHT_Y, CAUGHT_W, CAUGHT_H, 24, CARD_BORDER, scene_rgb(CAUGHT_X, CAUGHT_Y)); - rrect( - s, - CAUGHT_X + 3, - CAUGHT_Y + 3, - CAUGHT_W - 6, - CAUGHT_H - 6, - 21, - CARD_BG, - CARD_BORDER, - ); - - let top_badge = if g.caught_record { "NEW RECORD!" } else { sp.rarity() }; - let badge_col = if g.caught_record { Rgb(255, 212, 68) } else { DIM_TEXT }; - FONT_SM.centre(s, C, CAUGHT_Y + 16, top_badge, badge_col, CARD_BG); - - let sprite = sp.sprite(); - let sc = 3; - let fx = C - (sprite.w * sc) / 2; - let fy = CAUGHT_Y + 52 + (54 - sprite.h * sc) / 2; - draw_fish(s, sprite, fx, fy, sc, None); - - FONT_MD.centre(s, C, CAUGHT_Y + 124, sp.name(), sp.accent(), CARD_BG); - draw_weight_lg(s, C, CAUGHT_Y + 158, g.caught_hg, WHITE, CARD_BG); - - let mut pb = [0u8; 16]; - let mut db = [0u8; 11]; - pb[0] = b'+'; - let p_bytes = int(g.caught_pts as i32, &mut db).as_bytes(); - let pn = p_bytes.len().min(8); - pb[1..1 + pn].copy_from_slice(&p_bytes[..pn]); - pb[1 + pn..5 + pn].copy_from_slice(b" PTS"); - let pts_str = core::str::from_utf8(&pb[..5 + pn]).unwrap_or("+0 PTS"); - FONT_MD.centre(s, C, CAUGHT_Y + 196, pts_str, Rgb(106, 240, 186), CARD_BG); - rrect(s, CAUGHT_BTN_X, CAUGHT_BTN_Y, CAUGHT_BTN_W, CAUGHT_BTN_H, 14, CARD_BORDER, CARD_BG); - rrect( - s, - CAUGHT_BTN_X + 2, - CAUGHT_BTN_Y + 2, - CAUGHT_BTN_W - 4, - CAUGHT_BTN_H - 4, - 12, - PILL_ACTIVE_BG, - CARD_BORDER, - ); - FONT_SM.centre(s, C, CAUGHT_BTN_Y + 11, "CONTINUE", WHITE, PILL_ACTIVE_BG); -} - -fn draw_trophies_screen(s: &mut impl Surface, g: &Game, best: Records) { - s.rect(0, 0, SIZE, SIZE, TROPHY_BG.rgb565()); - rrect(s, HUD_MENU_X, HUD_Y, HUD_MENU_W, HUD_H, 12, PILL_BORDER, TROPHY_BG); - rrect(s, HUD_MENU_X + 2, HUD_Y + 2, HUD_MENU_W - 4, HUD_H - 4, 10, PILL_BG, PILL_BORDER); - FONT_SM.centre(s, HUD_MENU_X + HUD_MENU_W / 2, HUD_Y + 6, "< MENU", WHITE, PILL_BG); - - let mut hb = [0u8; 16]; - hb[..9].copy_from_slice(b"TROPHIES "); - hb[9] = b'0' + best.species_unlocked() as u8; - hb[10..12].copy_from_slice(b"/6"); - let hdr = core::str::from_utf8(&hb[..12]).unwrap_or("TROPHIES"); - FONT_MD.centre(s, 272, HUD_Y + 4, hdr, Rgb(255, 224, 108), TROPHY_BG); - - let idx = g.trophy_idx.min(5); - let sp = SPECIES_ALL[idx]; - let count = best.species_count[idx]; - let unlocked = count > 0; - - let (cx, cy, cw, ch) = (114, 92, 238, 268); - let rim = if unlocked { sp.accent() } else { PILL_BORDER }; - rrect(s, cx, cy, cw, ch, 22, rim, TROPHY_BG); - rrect(s, cx + 2, cy + 2, cw - 4, ch - 4, 20, PILL_BG, rim); - - FONT_SM.centre(s, C, cy + 16, sp.rarity(), if unlocked { sp.accent() } else { DIM_TEXT }, PILL_BG); - - let sprite = sp.sprite(); - let sc = 3; - let fx = C - (sprite.w * sc) / 2; - let fy = cy + 54 + (54 - sprite.h * sc) / 2; - draw_fish(s, sprite, fx, fy, sc, if unlocked { None } else { Some(SILHOUETTE) }); - - if unlocked { - FONT_MD.centre(s, C, cy + 128, sp.name(), WHITE, PILL_BG); - let mut wb = [0u8; 16]; - let mut rb = [0u8; 22]; - rb[..5].copy_from_slice(b"BEST "); - let ws = format_weight(best.species_best_hg[idx], &mut wb).as_bytes(); - rb[5..5 + ws.len()].copy_from_slice(ws); - let r_str = core::str::from_utf8(&rb[..5 + ws.len()]).unwrap_or("BEST 0"); - FONT_MD.centre(s, C, cy + 164, r_str, Rgb(106, 240, 186), PILL_BG); - - let mut cb = [0u8; 18]; - let mut db = [0u8; 11]; - cb[..7].copy_from_slice(b"CAUGHT "); - let cs = int(count as i32, &mut db).as_bytes(); - let cn = cs.len().min(8); - cb[7..7 + cn].copy_from_slice(&cs[..cn]); - let c_str = core::str::from_utf8(&cb[..7 + cn]).unwrap_or("CAUGHT 0"); - FONT_SM.centre(s, C, cy + 206, c_str, DIM_TEXT, PILL_BG); - } else { - FONT_MD.centre(s, C, cy + 132, "MYSTERY FISH", SILHOUETTE.mix(WHITE, 420), PILL_BG); - FONT_SM.centre(s, C, cy + 178, "NOT CAUGHT YET", DIM_TEXT, PILL_BG); - } - - for (bx, sym) in [(TROPHY_PREV_X, "<"), (TROPHY_NEXT_X, ">")] { - rrect(s, bx, TROPHY_NAV_Y, TROPHY_NAV_W, TROPHY_NAV_H, 14, PILL_BORDER, TROPHY_BG); - rrect( - s, - bx + 2, - TROPHY_NAV_Y + 2, - TROPHY_NAV_W - 4, - TROPHY_NAV_H - 4, - 12, - PILL_BG, - PILL_BORDER, - ); - FONT_MD.centre(s, bx + TROPHY_NAV_W / 2, TROPHY_NAV_Y + 18, sym, WHITE, PILL_BG); - } - - let dot_start = C - (5 * 22) / 2; - for i in 0..6 { - let dx = dot_start + i as i32 * 22; - let col = if i == idx { - Rgb(255, 212, 76) - } else if best.species_count[i] > 0 { - Rgb(82, 188, 198) - } else { - Rgb(38, 72, 102) - }; - s.rect(dx - 4, 384, 8, 8, col.rgb565()); - } - FONT_SM.centre(s, C, 404, "CROWN TO BROWSE", DIM_TEXT, TROPHY_BG); -} - -fn draw_derby_over(s: &mut impl Surface, g: &Game) { - draw_bg_box(s, Rect::new(0, 0, SIZE, SIZE)); - rrect(s, 78, 66, 310, 344, 24, CARD_BORDER, scene_rgb(78, 66)); - rrect(s, 81, 69, 304, 338, 21, CARD_BG, CARD_BORDER); - - FONT_LG.centre(s, C, 84, "TIME UP!", WHITE, CARD_BG); - if g.new_best_score { - FONT_SM.centre(s, C, 128, "NEW DERBY BEST!", Rgb(255, 212, 72), CARD_BG); - } - - let mut sb = [0u8; 18]; - let mut db = [0u8; 11]; - let s_bytes = int(g.score as i32, &mut db).as_bytes(); - let sn = s_bytes.len().min(10); - sb[..sn].copy_from_slice(&s_bytes[..sn]); - sb[sn..sn + 4].copy_from_slice(b" PTS"); - let score_str = core::str::from_utf8(&sb[..sn + 4]).unwrap_or("0 PTS"); - FONT_LG.centre(s, C, 154, score_str, Rgb(106, 240, 186), CARD_BG); - - let mut cb = [0u8; 20]; - cb[..5].copy_from_slice(b"FISH "); - let c_bytes = int(g.session_catches as i32, &mut db).as_bytes(); - let cn = c_bytes.len().min(6); - cb[5..5 + cn].copy_from_slice(&c_bytes[..cn]); - let catch_str = core::str::from_utf8(&cb[..5 + cn]).unwrap_or("FISH 0"); - FONT_SM.centre(s, C, 206, catch_str, DIM_TEXT, CARD_BG); - - if let Some(sp) = g.session_best_species { - let mut wb = [0u8; 16]; - let mut bb = [0u8; 28]; - let name = sp.name().as_bytes(); - let nn = name.len().min(14); - bb[..nn].copy_from_slice(&name[..nn]); - bb[nn] = b' '; - let ws = format_weight(g.session_best_hg, &mut wb).as_bytes(); - bb[nn + 1..nn + 1 + ws.len()].copy_from_slice(ws); - let best_line = core::str::from_utf8(&bb[..nn + 1 + ws.len()]).unwrap_or(""); - FONT_SM.centre(s, C, 232, best_line, sp.accent(), CARD_BG); - } - - let btns = [(OVER_RETRY_Y, "RETRY"), (OVER_MENU_Y, "MENU")]; - let confirming = g.confirm_ms > 0; - for (idx, &(y, label)) in btns.iter().enumerate() { - let active = g.over_sel == idx; - let lit = active && confirming; - let fill = if lit { - PILL_ACTIVE_BG.mix(PILL_ACTIVE_RIM, ONE * 36 / 100) - } else if active { - PILL_ACTIVE_BG - } else { - PILL_BG - }; - let rim = if lit { - PILL_ACTIVE_RIM.mix(WHITE, ONE / 2) - } else if active { - PILL_ACTIVE_RIM - } else { - PILL_BORDER - }; - rrect(s, OVER_BTN_X, y, OVER_BTN_W, OVER_BTN_H, 16, rim, CARD_BG); - rrect(s, OVER_BTN_X + 2, y + 2, OVER_BTN_W - 4, OVER_BTN_H - 4, 14, fill, rim); - let tcol = if lit || !active { WHITE } else { PILL_ACTIVE_RIM }; - FONT_MD.centre(s, C, y + 12, label, tcol, fill); - } -} - -#[derive(Clone, Copy, PartialEq, Eq, Debug)] -pub struct Seen { - state: State, - mode: Mode, - difficulty: Difficulty, - menu_sel: usize, - diff_sel: usize, - trophy_idx: usize, - over_sel: usize, - confirming: bool, - score: u32, - derby_sec: u32, - fish_boxes: [Rect; MAX_FISH], - fish_dirs: [bool; MAX_FISH], - fish_phases: [u16; MAX_FISH], - has_cast: bool, - rod_box: Rect, - rod_sig: (i32, i32, bool, bool), - bob_box: Rect, - bob_x: i32, - bob_y: i32, - lake_bucket: u32, - bar_y: i32, - bar_h: i32, - track_fish_y: i32, - fish_in_bar: bool, - prog_h: i32, - prog_bucket: u8, -} - -fn snapshot(g: &Game) -> Seen { - let mut fish_boxes = [Rect::empty(); MAX_FISH]; - let mut fish_dirs = [true; MAX_FISH]; - let mut fish_phases = [0u16; MAX_FISH]; - for i in 0..MAX_FISH { - fish_boxes[i] = fish_bbox(&g.fish[i]); - fish_dirs[i] = g.fish[i].facing_right(); - fish_phases[i] = g.fish[i].phase_ms / 90; - } - let (bob_x, bob_y) = g.bobber_pos(); - let (rx, ry) = if g.has_cast { (g.bx, g.by) } else { (186, 274) }; - let bend = match g.state { - State::Reeling => 64, - State::Bite => 48, - _ => 0, - }; - let pose = rod_pose(rx, ry, bend); - Seen { - state: g.state, - mode: g.mode, - difficulty: g.difficulty, - menu_sel: g.menu_sel, - diff_sel: g.diff_sel, - trophy_idx: g.trophy_idx, - over_sel: g.over_sel, - confirming: g.confirm_ms > 0, - score: g.score, - derby_sec: (g.derby_left_ms + 999) / 1000, - fish_boxes, - fish_dirs, - fish_phases, - has_cast: g.has_cast, - rod_box: rod_bounds(pose, bob_x, bob_y), - rod_sig: ( - pose.tip_x, - pose.tip_y, - g.has_cast && g.state != State::Banner, - matches!(g.state, State::Casting | State::Bite | State::Reeling), - ), - bob_box: if g.has_cast && g.state != State::Menu || g.state == State::Banner { - bobber_bounds(bob_x, bob_y, g.state, g.splash_ms) - } else { - Rect::empty() - }, - bob_x, - bob_y, - lake_bucket: { - let splash_b = if g.splash_ms > 0 { - 1 + (520 - g.splash_ms.min(520)) / 20 - } else { - 0 - }; - let phase_b = match g.state { - State::Floating => (g.lake_ms / 120) & 0xFFFF, - State::Reeling => (g.reel_phase_ms / 140) & 0xFFFF, - _ => 0, - }; - (splash_b << 16) | phase_b - }, - bar_y: g.bar_y, - bar_h: g.bar_h, - track_fish_y: g.track_fish_y(), - fish_in_bar: g.fish_in_bar, - prog_h: (g.reel_progress.clamp(0, 1000) * TRACK_H / 1000).clamp(0, TRACK_H), - prog_bucket: prog_color(g.reel_progress).0, - } -} - -fn paint_pond_excluding(s: &mut impl Surface, g: &Game, best: Records, r: Rect, ex: Option) { - let Some(ex) = ex.filter(|e| r.intersects(*e)) else { - paint_pond_region(s, g, best, r); - return; - }; - let my0 = r.y0.max(ex.y0); - let my1 = r.y1.min(ex.y1); - let parts = [ - Rect { x0: r.x0, y0: r.y0, x1: r.x1, y1: ex.y0.min(r.y1) }, - Rect { x0: r.x0, y0: ex.y1.max(r.y0), x1: r.x1, y1: r.y1 }, - Rect { x0: r.x0, y0: my0, x1: ex.x0.min(r.x1), y1: my1 }, - Rect { x0: ex.x1.max(r.x0), y0: my0, x1: r.x1, y1: my1 }, - ]; - for p in parts { - if !p.is_empty() { - paint_pond_region(s, g, best, p); - } - } -} - -fn paint_fish_deltas(s: &mut impl Surface, g: &Game, best: Records, old: &Seen, cur: &Seen) -> bool { - let mut pending = [Rect::empty(); MAX_FISH]; - let mut count = 0usize; - for i in 0..MAX_FISH { - if old.fish_boxes[i] != cur.fish_boxes[i] - || old.fish_dirs[i] != cur.fish_dirs[i] - || old.fish_phases[i] != cur.fish_phases[i] - { - pending[count] = old.fish_boxes[i].union(cur.fish_boxes[i]); - count += 1; - } - } - if count == 0 { - return false; - } - loop { - let mut merged = false; - 'outer: for i in 0..count { - if pending[i].is_empty() { - continue; - } - for j in (i + 1)..count { - if !pending[j].is_empty() && pending[i].intersects(pending[j]) { - pending[i] = pending[i].union(pending[j]); - pending[j] = Rect::empty(); - merged = true; - break 'outer; - } - } - } - if !merged { - break; - } - } - for r in &pending[..count] { - if !r.is_empty() { - paint_pond_region(s, g, best, *r); - } - } - true -} - -/// Renders full screen on initial draw or tiny separated single-pass dirty regions! -pub fn frame(s: &mut impl Surface, g: &Game, best: Records, prev: Option) -> (Seen, bool) { - let cur = snapshot(g); - let Some(old) = prev else { - match g.state { - State::Trophies => draw_trophies_screen(s, g, best), - State::Caught => { - paint_pond_region(s, g, best, Rect::new(0, 0, SIZE, SIZE)); - draw_caught_modal(s, g); - } - State::DerbyOver => draw_derby_over(s, g), - State::Menu => { - paint_water_with_fish_single_pass(s, g, Rect::new(0, 0, SIZE, SIZE)); - let pose = rod_pose(186, 274, 0); - draw_rod_and_line(s, pose, 186, 274, false, false, Rect::new(0, 0, SIZE, SIZE)); - draw_menu_overlay(s, g, best); - } - State::Difficulty => { - paint_water_with_fish_single_pass(s, g, Rect::new(0, 0, SIZE, SIZE)); - let pose = rod_pose(186, 274, 0); - draw_rod_and_line(s, pose, 186, 274, false, false, Rect::new(0, 0, SIZE, SIZE)); - draw_difficulty_overlay(s, g); - } - State::Reeling => { - paint_pond_region(s, g, best, Rect::new(0, 0, SIZE, SIZE)); - draw_gauge_frame(s); - draw_gauge_inner(s, g, None); - } - _ => { - paint_pond_region(s, g, best, Rect::new(0, 0, SIZE, SIZE)); - } - } - return (cur, true); - }; - - if old.state != cur.state { - if cur.state == State::Menu - || old.state == State::Menu - || cur.state == State::Difficulty - || old.state == State::Difficulty - || matches!(cur.state, State::Trophies | State::Caught | State::DerbyOver) - || matches!(old.state, State::Trophies | State::Caught | State::DerbyOver) - { - return frame(s, g, best, None); - } - } - - if cur.state == State::Menu { - if old.menu_sel != cur.menu_sel || old.confirming != cur.confirming { - draw_menu_overlay(s, g, best); - return (cur, true); - } - return (cur, false); - } - if cur.state == State::Difficulty { - if old.diff_sel != cur.diff_sel || old.confirming != cur.confirming { - draw_difficulty_overlay(s, g); - return (cur, true); - } - return (cur, false); - } - if cur.state == State::Trophies { - if old.trophy_idx != cur.trophy_idx { - draw_trophies_screen(s, g, best); - return (cur, true); - } - return (cur, false); - } - if cur.state == State::DerbyOver { - if old.over_sel != cur.over_sel || old.confirming != cur.confirming { - draw_derby_over(s, g); - return (cur, true); - } - return (cur, false); - } - if cur.state == State::Caught { - return (cur, false); - } - - let mut drew = false; - let gauge_rect = Rect::new(GAUGE_X, GAUGE_Y, GAUGE_W, GAUGE_H); - let avoid_gauge = (cur.state == State::Reeling).then_some(gauge_rect); - - // 1. State transition updates on pond & left gauge visibility (pond cleared BEFORE gauge is drawn!). - if old.state != cur.state { - if old.state == State::Aim && !old.has_cast || old.state == State::Reeling || cur.state == State::Reeling { - paint_pond_excluding(s, g, best, Rect::new(132, 68, 202, 24), avoid_gauge); - } - let u = old.rod_box.union(cur.rod_box).union(old.bob_box).union(cur.bob_box); - paint_pond_excluding(s, g, best, u, avoid_gauge); - if cur.state == State::Reeling { - for i in 0..MAX_FISH { - if old.fish_boxes[i] != cur.fish_boxes[i] { - paint_pond_excluding(s, g, best, old.fish_boxes[i].union(cur.fish_boxes[i]), avoid_gauge); - } - } - draw_gauge_frame(s); - draw_gauge_inner(s, g, None); - } else if old.state == State::Reeling { - paint_pond_region(s, g, best, gauge_rect); - } - drew = true; - } - - // 2. Top HUD update (only when score, mode, difficulty, or timer second changes!). - if old.score != cur.score - || old.derby_sec != cur.derby_sec - || old.difficulty != cur.difficulty - || old.mode != cur.mode - { - paint_pond_excluding( - s, - g, - best, - Rect::new(HUD_MENU_X, HUD_Y, HUD_INFO_X + HUD_INFO_W - HUD_MENU_X, HUD_H), - avoid_gauge, - ); - drew = true; - } - - // 3. Individual pond fish boxes in ZERO-FLICKER disjoint single-pass render! - if cur.state != State::Reeling && paint_fish_deltas(s, g, best, &old, &cur) { - drew = true; - } - - // 4. Rod & bobber updates (strictly outside gauge during Reeling). - let rod_changed = old.has_cast != cur.has_cast || old.rod_box != cur.rod_box || old.rod_sig != cur.rod_sig; - let bob_changed = old.bob_box != cur.bob_box - || old.bob_x != cur.bob_x - || old.bob_y != cur.bob_y - || old.lake_bucket != cur.lake_bucket; - if rod_changed || bob_changed { - let mut r = Rect::empty(); - if rod_changed { - r = r.union(old.rod_box.union(cur.rod_box)); - } - if bob_changed { - r = r.union(old.bob_box.union(cur.bob_box)); - } - paint_pond_excluding(s, g, best, r, avoid_gauge); - drew = true; - } - - // 5. Zero-flicker incremental single-pass vertical gauge interior update during Reeling! - if cur.state == State::Reeling - && old.state == State::Reeling - && (old.bar_y != cur.bar_y - || old.bar_h != cur.bar_h - || old.track_fish_y != cur.track_fish_y - || old.fish_in_bar != cur.fish_in_bar - || old.prog_h != cur.prog_h - || old.prog_bucket != cur.prog_bucket) - { - draw_gauge_inner(s, g, Some(old)); - drew = true; - } - - (cur, drew) -} - -#[cfg(test)] -mod tests { - use super::*; - use cmf_wp2_ui::{Count, Fb}; - - #[test] - fn partial_frames_match_full_render() { - let mut g = Game::new(77); - let mut rec = Records::default(); - let mut px_full = vec![0u16; (SIZE * SIZE) as usize]; - let mut px_part = vec![0u16; (SIZE * SIZE) as usize]; - - let (mut seen, _) = frame(&mut Fb::new(&mut px_part), &g, rec, None); - - let check_sync = |g: &Game, rec: Records, seen: &mut Seen, px_part: &mut [u16], px_full: &mut [u16]| { - let (ns, _) = frame(&mut Fb::new(px_part), g, rec, Some(*seen)); - *seen = ns; - frame(&mut Fb::new(px_full), g, rec, None); - if px_part != px_full { - let first = px_part.iter().zip(px_full.iter()).position(|(a, b)| a != b).unwrap(); - panic!( - "partial frame drifted at state {:?} pixel ({}, {}): part={:#06x} full={:#06x}", - g.state, - first as i32 % SIZE, - first as i32 / SIZE, - px_part[first], - px_full[first] - ); - } - }; - - g.crown(1); - check_sync(&g, rec, &mut seen, &mut px_part, &mut px_full); - g.crown(-1); - check_sync(&g, rec, &mut seen, &mut px_part, &mut px_full); - - g.open_difficulty(Mode::Relax); - check_sync(&g, rec, &mut seen, &mut px_part, &mut px_full); - g.crown(1); - check_sync(&g, rec, &mut seen, &mut px_part, &mut px_full); - g.crown(-1); - check_sync(&g, rec, &mut seen, &mut px_part, &mut px_full); - - g.tap_ui(233, MENU_RELAX_Y + 10); - check_sync(&g, rec, &mut seen, &mut px_part, &mut px_full); - g.tick(80, &mut rec); - check_sync(&g, rec, &mut seen, &mut px_part, &mut px_full); - g.tick(80, &mut rec); - check_sync(&g, rec, &mut seen, &mut px_part, &mut px_full); - - g.start_with_difficulty(Mode::Relax, Difficulty::Medium); - check_sync(&g, rec, &mut seen, &mut px_part, &mut px_full); - - // Cast right next to the left gauge (`CAST_X_MIN = 106`) so overlap guards are exercised bit-for-bit. - g.cast_to(106, 190); - for _ in 0..160 { - g.tick(40, &mut rec); - check_sync(&g, rec, &mut seen, &mut px_part, &mut px_full); - if g.state == State::Bite { - break; - } - } - assert_eq!(g.state, State::Bite); - g.try_hook(); - check_sync(&g, rec, &mut seen, &mut px_part, &mut px_full); - - for _ in 0..45 { - let fy = g.track_fish_y(); - let center = g.bar_y + g.bar_h / 2; - if fy < center - 6 { - g.crown(-1); - } else if fy > center + 6 { - g.crown(1); - } - if g.state == State::Reeling { - g.tick(40, &mut rec); - } - check_sync(&g, rec, &mut seen, &mut px_part, &mut px_full); - if g.state == State::Caught { - break; - } - } - } - - #[test] - fn active_reeling_and_fish_frames_are_tiny_and_flicker_free() { - let mut g = Game::new(19); - let mut rec = Records::default(); - g.start_mode(Mode::Relax); - g.cast_to(220, 190); - while g.state != State::Bite { - g.tick(40, &mut rec); - } - g.try_hook(); - - let mut dummy = vec![0u16; (SIZE * SIZE) as usize]; - let (mut seen, _) = frame(&mut Fb::new(&mut dummy), &g, rec, None); - - for _ in 0..20 { - g.crown(-1); - g.tick(40, &mut rec); - let mut fc = Count::default(); - let (ns, _) = frame(&mut fc, &g, rec, Some(seen)); - seen = ns; - if g.state == State::Reeling { - assert!( - fc.rects < 220 && fc.px < 12_000, - "reeling frame too heavy: {} rects, {} px", - fc.rects, - fc.px - ); - } - } - } -} diff --git a/apps/lake-cast/store.md b/apps/lake-cast/store.md deleted file mode 100644 index 805ad89..0000000 --- a/apps/lake-cast/store.md +++ /dev/null @@ -1,12 +0,0 @@ -Stand on the sunny sandy beach, cast your rod anywhere onto the open water ahead, and battle fish on the vertical catch bar. - -- **Cast anywhere on the water:** Tap shallow shore water or deep blue water ahead to swing your rod from the sand and land your bobber right there. -- **Live fish underwater:** Watch 6 distinct fish species glide across the lake, cast near them, and react to the nibble tap and `HOOK!` splash alert. -- **Vertical bar duel:** When a fish bites, use the crown up and down to keep it inside the green catch zone on the left bar as it darts up and down. -- **Modes, Difficulty & Trophies:** Choose **Easy** (classic gentle bar), **Medium** (`50/50` balanced pace), or **Hard** (fast fish, narrow bar) before starting **Relax** or **Derby 90s**, and unlock all 6 species in **Trophies** with weight records synced to the widget card. - -Press the crown or swipe right to exit. - -## Requirements - -The [patched firmware](/firmware) and the [App Loader](/firmware). Open it from the **Apps** row at the end of the watch's app list (list style, not waterfall). diff --git a/apps/lake-cast/store.toml b/apps/lake-cast/store.toml deleted file mode 100644 index 1dc9349..0000000 --- a/apps/lake-cast/store.toml +++ /dev/null @@ -1,5 +0,0 @@ -name = "Lake Cast" -summary = "Stand on the sandy shore, cast anywhere on the water ahead, and track fish on the vertical bar" -version = "0.1.0" -author = "mead0wss" -screenshots = ["shots/menu.png", "shots/difficulty.png", "shots/lake.png", "shots/reeling.png", "shots/caught.png", "shots/trophies.png"] diff --git a/apps/markets/Cargo.toml b/apps/markets/Cargo.toml deleted file mode 100644 index 5b0763e..0000000 --- a/apps/markets/Cargo.toml +++ /dev/null @@ -1,14 +0,0 @@ -[package] -name = "markets" -edition.workspace = true -license.workspace = true -version.workspace = true - -[dependencies] -cmf-wp2-app.workspace = true -cmf-wp2-ui.workspace = true -companion-rpc.workspace = true - -[[bin]] -name = "markets" -bench = false diff --git a/apps/markets/icon.svg b/apps/markets/icon.svg deleted file mode 100644 index 2b9679c..0000000 --- a/apps/markets/icon.svg +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/apps/markets/shots/allow.png b/apps/markets/shots/allow.png deleted file mode 100644 index c22cec3..0000000 Binary files a/apps/markets/shots/allow.png and /dev/null differ diff --git a/apps/markets/shots/list.png b/apps/markets/shots/list.png deleted file mode 100644 index 0378655..0000000 Binary files a/apps/markets/shots/list.png and /dev/null differ diff --git a/apps/markets/shots/page.png b/apps/markets/shots/page.png deleted file mode 100644 index 14ff82d..0000000 Binary files a/apps/markets/shots/page.png and /dev/null differ diff --git a/apps/markets/src/fixtures/coingecko.json b/apps/markets/src/fixtures/coingecko.json deleted file mode 100644 index a2319e0..0000000 --- a/apps/markets/src/fixtures/coingecko.json +++ /dev/null @@ -1 +0,0 @@ -{"bitcoin":{"usd":59105,"usd_24h_change":-0.2658878037716179},"ethereum":{"usd":1656.08,"usd_24h_change":1.3795397193151802},"solana":{"usd":71.78,"usd_24h_change":2.1464692396898575}} \ No newline at end of file diff --git a/apps/markets/src/fixtures/yahoo-ftse.json b/apps/markets/src/fixtures/yahoo-ftse.json deleted file mode 100644 index 0beda62..0000000 --- a/apps/markets/src/fixtures/yahoo-ftse.json +++ /dev/null @@ -1 +0,0 @@ -{"chart":{"result":[{"meta":{"currency":"GBP","symbol":"^FTSE","exchangeName":"FGI","fullExchangeName":"FTSE Index","instrumentType":"INDEX","firstTradeDate":441964800,"regularMarketTime":1796056529,"hasPrePostMarketData":false,"gmtoffset":0,"timezone":"GMT","exchangeTimezoneName":"Europe/London","regularMarketPrice":10695.16,"regularMarketChangePercent":-0.034,"fulldayPrice":10695.16,"fulldayChange":-3.649,"fulldayChangePercent":-0.034,"fiftyTwoWeekHigh":10989.5,"fiftyTwoWeekLow":9622.7,"regularMarketDayHigh":10749.97,"regularMarketDayLow":10689.84,"regularMarketVolume":0,"longName":"FTSE 100","shortName":"FTSE 100","chartPreviousClose":10698.81,"priceHint":2,"currentTradingPeriod":{"pre":{"timezone":"GMT","end":1796025600,"start":1796022900,"gmtoffset":0},"regular":{"timezone":"GMT","end":1796056200,"start":1796025600,"gmtoffset":0},"post":{"timezone":"GMT","end":1796058900,"start":1796056200,"gmtoffset":0}},"dataGranularity":"1d","range":"1d","validRanges":["1d","5d","1mo","3mo","6mo","1y","2y","5y","10y","ytd","max"]},"timestamp":[1796056529],"indicators":{"quote":[{"open":[10699.5302734375],"low":[10689.83984375],"close":[10695.16015625],"volume":[0],"high":[10749.9697265625]}],"adjclose":[{"adjclose":[10695.16015625]}]}}],"error":null}} \ No newline at end of file diff --git a/apps/markets/src/fixtures/yahoo-gspc.json b/apps/markets/src/fixtures/yahoo-gspc.json deleted file mode 100644 index 4c6f32d..0000000 --- a/apps/markets/src/fixtures/yahoo-gspc.json +++ /dev/null @@ -1 +0,0 @@ -{"chart":{"result":[{"meta":{"currency":"USD","symbol":"^GSPC","exchangeName":"SNP","fullExchangeName":"SNP","instrumentType":"INDEX","firstTradeDate":-1325583000,"regularMarketTime":1796074890,"hasPrePostMarketData":false,"gmtoffset":-18000,"timezone":"EST","exchangeTimezoneName":"America/New_York","regularMarketPrice":7344.73,"regularMarketChangePercent":0.647,"fulldayPrice":7344.73,"fulldayChange":47.24,"fulldayChangePercent":0.647,"fiftyTwoWeekHigh":7844.52,"fiftyTwoWeekLow":6316.91,"regularMarketDayHigh":7372.7,"regularMarketDayLow":7304.94,"regularMarketVolume":4565890000,"longName":"S&P 500","shortName":"S&P 500","chartPreviousClose":7297.49,"priceHint":2,"currentTradingPeriod":{"pre":{"timezone":"EST","start":1796029200,"end":1796049000,"gmtoffset":-18000},"regular":{"timezone":"EST","start":1796049000,"end":1796072400,"gmtoffset":-18000},"post":{"timezone":"EST","start":1796072400,"end":1796086800,"gmtoffset":-18000}},"dataGranularity":"1d","range":"1d","validRanges":["1d","5d","1mo","3mo","6mo","1y","2y","5y","10y","ytd","max"]},"timestamp":[1796074890],"indicators":{"quote":[{"open":[7328.27001953125],"close":[7344.72998046875],"high":[7372.7001953125],"low":[7304.93994140625],"volume":[4565890000]}],"adjclose":[{"adjclose":[7344.72998046875]}]}}],"error":null}} \ No newline at end of file diff --git a/apps/markets/src/format.rs b/apps/markets/src/format.rs deleted file mode 100644 index c398814..0000000 --- a/apps/markets/src/format.rs +++ /dev/null @@ -1,178 +0,0 @@ -//! The texts the screens and the widget card show: prices with thousands separators, signed changes, times. -//! ASCII only (the watch's font has ASCII and Cyrillic), integers only. - -use crate::parse::{SCALE, SCALE_DIGITS, div_round}; - -/// A short text built in place; what doesn't fit is cut. -#[derive(Clone, Copy, PartialEq, Eq)] -pub struct Line { - buf: [u8; 48], - len: usize, -} - -impl Line { - pub const fn new() -> Line { - Line { buf: [0; 48], len: 0 } - } - - pub fn of(s: &str) -> Line { - let mut l = Line::new(); - l.push(s); - l - } - - pub fn push(&mut self, s: &str) { - for c in s.bytes() { - self.byte(c); - } - } - - pub fn byte(&mut self, c: u8) { - if self.len < self.buf.len() && c.is_ascii() { - self.buf[self.len] = c; - self.len += 1; - } - } - - /// `n` in decimal, at least `width` digits (zero padded), with a `,` every three digits if `commas`. - pub fn uint(&mut self, n: u64, width: usize, commas: bool) { - let mut d = [0u8; 20]; - let (mut i, mut v) = (0, n); - while (v > 0 || i < width.max(1)) && i < d.len() { - d[i] = b'0' + (v % 10) as u8; - v /= 10; - i += 1; - } - while i > 0 { - i -= 1; - self.byte(d[i]); - if commas && i > 0 && i % 3 == 0 { - self.byte(b','); - } - } - } - - pub fn as_str(&self) -> &str { - core::str::from_utf8(&self.buf[..self.len]).unwrap_or("") - } - - pub fn len(&self) -> usize { - self.len - } - - pub fn is_empty(&self) -> bool { - self.len == 0 - } -} - -impl core::fmt::Debug for Line { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - core::fmt::Debug::fmt(self.as_str(), f) - } -} - -/// The decimals a price is shown with: the instrument's, or 4 below 1 so a cheap coin isn't "0.00". -pub fn decimals(price: i64, wanted: u8) -> u8 { - if price.unsigned_abs() < SCALE as u64 { 4 } else { wanted.min(SCALE_DIGITS as u8) } -} - -/// A price ×[`SCALE`] as "7,344.73" with `decimals` (0-4), rounded half away from zero. -pub fn price(p: i64, decimals: u8) -> Line { - let d = decimals.min(SCALE_DIGITS as u8) as u32; - let q = div_round(p, 10i64.pow(SCALE_DIGITS as u32 - d)); - let unit = 10u64.pow(d); - let mut l = Line::new(); - if q < 0 { - l.byte(b'-'); - } - let a = q.unsigned_abs(); - l.uint(a / unit, 1, true); - if d > 0 { - l.byte(b'.'); - l.uint(a % unit, d as usize, false); - } - l -} - -/// A change in hundredths of a percent as "+0.65%", "-12.30%", "0.00%". -pub fn change(bp: i32) -> Line { - let mut l = Line::new(); - match bp.signum() { - 1 => l.byte(b'+'), - -1 => l.byte(b'-'), - _ => {} - } - let a = bp.unsigned_abs() as u64; - l.uint(a / 100, 1, false); - l.byte(b'.'); - l.uint(a % 100, 2, false); - l.byte(b'%'); - l -} - -/// "14:05" of wall-clock minutes. -pub fn hhmm(wall: i32) -> Line { - let m = wall.rem_euclid(1440) as u64; - let mut l = Line::new(); - l.uint(m / 60, 2, false); - l.byte(b':'); - l.uint(m % 60, 2, false); - l -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn prices_with_separators() { - assert_eq!(price(73_447_300, 2).as_str(), "7,344.73"); - assert_eq!(price(600_707_500, 2).as_str(), "60,070.75"); - assert_eq!(price(591_050_000, 0).as_str(), "59,105"); - assert_eq!(price(591_055_000, 0).as_str(), "59,106"); // rounded - assert_eq!(price(717_800, 2).as_str(), "71.78"); - assert_eq!(price(9_999_950, 2).as_str(), "1,000.00"); // 999.995 rounds up a digit - assert_eq!(price(0, 2).as_str(), "0.00"); - assert_eq!(price(1_234, 4).as_str(), "0.1234"); - assert_eq!(price(-12_345_000, 2).as_str(), "-1,234.50"); - assert_eq!(price(123_456_789_012_345_678, 2).as_str(), "12,345,678,901,234.57"); - assert_eq!(price(i64::MAX, 0).as_str(), "922,337,203,685,478"); - assert_eq!(price(i64::MIN + 1, 4).as_str(), "-922,337,203,685,477.5807"); - } - - #[test] - fn small_prices_get_more_decimals() { - assert_eq!(decimals(9_999, 2), 4); - assert_eq!(decimals(10_000, 2), 2); - assert_eq!(decimals(591_050_000, 0), 0); - assert_eq!(decimals(-5, 0), 4); - assert_eq!(price(41, decimals(41, 2)).as_str(), "0.0041"); - } - - #[test] - fn signed_changes() { - assert_eq!(change(65).as_str(), "+0.65%"); - assert_eq!(change(-70).as_str(), "-0.70%"); - assert_eq!(change(0).as_str(), "0.00%"); - assert_eq!(change(-1230).as_str(), "-12.30%"); - assert_eq!(change(5).as_str(), "+0.05%"); - assert_eq!(change(i32::MIN).as_str(), "-21474836.48%"); - } - - #[test] - fn times() { - assert_eq!(hhmm(14 * 60 + 5).as_str(), "14:05"); - assert_eq!(hhmm(1440 * 20_000 + 59).as_str(), "00:59"); - assert_eq!(hhmm(-1).as_str(), "23:59"); - } - - #[test] - fn line_cuts_and_keeps_ascii() { - let mut l = Line::of("ab€c"); - assert_eq!(l.as_str(), "abc"); - for _ in 0..60 { - l.push("x"); - } - assert_eq!(l.len(), 48); - } -} diff --git a/apps/markets/src/main.rs b/apps/markets/src/main.rs deleted file mode 100644 index ceb4afd..0000000 --- a/apps/markets/src/main.rs +++ /dev/null @@ -1,184 +0,0 @@ -//! markets: stock indices and crypto prices from the web, through FMC Companion's `http.get` on the phone. -//! -//! - The menu app: the nine instruments in a list the crown scrolls (`screen::menu`); a tap on a row pins it for the -//! page and the widget card, the Refresh pill asks the phone now. BUTTON exits. -//! - The page next to the watch face (`app_features!(PAGE)`): the pinned instrument big and four others -//! (`screen::page`). A tap on one of them pins it, anywhere else refreshes. Swiped away (PAUSE) it draws and asks -//! nothing; back (RESUME) it asks again if the prices are older than 5 minutes. -//! - The widget card (`WIDGET`): the pinned instrument's change and price, and Bitcoin's (or the S&P 500's), written -//! at start and whenever the text changes. -//! -//! The phone is asked when the app starts and every 5 minutes while it is shown (`model.rs`); the last quotes and -//! the pin are kept in storage, so the list, the page and the card show at once without the phone. -#![cfg_attr(any(target_os = "none", wp2_sim), no_main, cfg_attr(target_os = "none", no_std))] - -#[cfg_attr(not(any(target_os = "none", wp2_sim)), allow(dead_code))] -mod format; -#[cfg_attr(not(any(target_os = "none", wp2_sim)), allow(dead_code))] -mod model; -#[cfg_attr(not(any(target_os = "none", wp2_sim)), allow(dead_code))] -mod parse; -#[cfg_attr(not(any(target_os = "none", wp2_sim)), allow(dead_code))] -mod screen; - -#[cfg(not(any(target_os = "none", wp2_sim)))] -fn main() {} - -#[cfg(any(target_os = "none", wp2_sim))] -mod device { - use crate::format::Line; - use crate::model::{BLOB_MAX, Model, wall_min}; - use crate::screen::{self, Hit, Ui}; - use cmf_wp2_app::{Api, BUTTON, CROWN, MSG_MAX, PAUSE, RESUME, TOUCH_DOWN, TOUCH_UP}; - use cmf_wp2_ui::haptic::{Motor, TICK}; - use core::ptr::addr_of_mut; - - cmf_wp2_app::entry!(main); - cmf_wp2_app::app_icon!(); - cmf_wp2_app::app_features!(cmf_wp2_app::WIDGET | cmf_wp2_app::PAGE); - - /// How often to look at the clock: the status line ages, quotes go stale. - const TICK_MS: u32 = 30_000; - /// Longest press that still counts as a tap. - const TAP_MS: u32 = 600; - - // the model holds a 2 KiB body buffer: off the 8 KiB stack - static mut MODEL: Model = Model::new(); - static mut BLOB: [u8; BLOB_MAX] = [0; BLOB_MAX]; - - fn wall(api: &Api) -> i32 { - api.time().map_or(0, |t| wall_min(t.year as i32, t.month as u32, t.day as u32, t.hour as u32, t.minute as u32)) - } - - struct App { - api: &'static Api, - m: &'static mut Model, - ui: Ui, - on_page: bool, - /// The clock-dependent part of the last drawn screen. - shown: (Line, u16), - /// The card as last written. - card: Option<(Line, Line)>, - } - - impl App { - fn draw(&mut self) { - let w = wall(self.api); - let mut s = self.api; - if self.on_page { - screen::page(&mut s, self.m, w); - } else { - screen::menu(&mut s, self.m, &self.ui, w); - } - self.api.show(); - self.shown = screen::clock_key(self.m, w); - } - - /// The clock moved the status line or a quote's age. - fn ticked(&self) -> bool { - screen::clock_key(self.m, wall(self.api)) != self.shown - } - - /// Storage and the card, when they changed. - fn keep(&mut self) { - if self.m.take_dirty() { - let blob = unsafe { &mut *addr_of_mut!(BLOB) }; - let n = self.m.save(blob); - self.api.save(&blob[..n]); // on change: the app can end without notice - } - let card = self.m.widget(); - if self.card != Some(card) { - self.api.widget(card.0.as_str(), card.1.as_str()); // -22 on a loader without widgets - self.card = Some(card); - } - } - } - - fn main(api: &'static Api) -> i32 { - let m = unsafe { &mut *addr_of_mut!(MODEL) }; - let blob = unsafe { &mut *addr_of_mut!(BLOB) }; - let n = api.load(blob); - if n > 0 { - m.load(&blob[..n as usize]); - } - let mut app = App { api, m, ui: Ui::new(), on_page: api.on_page(), shown: (Line::new(), 0), card: None }; - let mut motor = Motor::new(api); - app.m.refresh(api.now()); - let mut paused = false; - let mut redraw = true; - let mut touch: Option<(i32, i32, u32)> = None; - let mut msg = [0u8; MSG_MAX]; - loop { - motor.update(); - if !paused { - if let Some(req) = app.m.poll(api.now()) { - api.send(&req); // -107 with no phone, -11 outbox full: the retry timer asks again - } - // a round that started or ended, a silent phone, the clock: the status line and the pill change too - if redraw || app.ticked() { - app.draw(); - } - } - redraw = false; - app.keep(); - let wait = if paused { u32::MAX } else { app.m.wait(api.now()).min(TICK_MS).min(motor.wait().unwrap_or(u32::MAX)) }; - let e = api.event(wait); - // every turn: the inbox holds 4 messages and an answer is up to 18 - while let Some(r) = api.recv(&mut msg) { - if app.m.reply(r, api.now(), wall(api)) == crate::model::Got::Changed { - redraw = true; - } - } - if let Some(e) = e { - match e.kind { - BUTTON => { - motor.off(); - app.m.flush(); - app.keep(); - return 0; - } - PAUSE => { - touch = None; - motor.off(); - app.m.flush(); // swiped away or a popup: the app may not come back - paused = true; - } - RESUME => { - paused = false; - app.m.resume(api.now(), wall(api)); - redraw = true; // the loader repainted the old frame - } - CROWN if !paused && !app.on_page => redraw |= app.ui.crown(e.delta), - // A tap acts on the finger's lift, at the place it went down (UP's x/y are unreliable). A swipe - // away from the page starts with a DOWN on a row and ends in PAUSE, which drops it: no stray pin. - TOUCH_DOWN if !paused => touch = Some((e.x as i32, e.y as i32, api.now())), - TOUCH_UP if !paused => { - let Some((x, y, at)) = touch.take() else { continue }; - if api.now().wrapping_sub(at) > TAP_MS { - continue; - } - let hit = - if app.on_page { screen::page_hit(app.m, x, y) } else { screen::menu_hit(app.m, &app.ui, x, y) }; - match hit { - Hit::Pin(i) => { - if app.m.pin(i) { - motor.play(TICK); - redraw = true; - } - } - Hit::Refresh => { - if !app.m.busy() { - motor.play(TICK); - app.m.refresh(api.now()); - redraw = true; - } - } - Hit::Nothing => {} - } - } - _ => {} - } - } - } - } -} diff --git a/apps/markets/src/model.rs b/apps/markets/src/model.rs deleted file mode 100644 index 0b601a8..0000000 --- a/apps/markets/src/model.rs +++ /dev/null @@ -1,508 +0,0 @@ -//! Markets' state, without `Api`: the instruments, the last quote of each, the round of `http.get` calls that -//! refreshes them through FMC Companion, the cache blob and the widget card's text. -//! -//! A round asks the phone for one URL at a time ([`REQS`]: one Yahoo chart per index, then one CoinGecko price for -//! every coin), each with a new id; replies for an older id are dropped by [`rpc::Call`]. A refused host (`ASK`, -//! `DENIED`) skips that host's other URLs for the round. After a round the next one is due in [`PERIOD_MS`], or -//! sooner while the phone waits for the user's "allow" ([`ASK_AGAIN_MS`]) or failed ([`RETRY_ROUND_MS`]). A phone that -//! doesn't answer gets the same URL again after 3 s, then less often, up to [`LONGEST_MS`]. - -use crate::format::{self, Line}; -use crate::parse::{self, Parsed}; -use companion_rpc as rpc; - -/// A new round this often while the app or its page is shown. -pub const PERIOD_MS: u32 = 5 * 60_000; -/// Characters per widget card line that the stock card draws without wrapping: it fits about 17 of its font, and a -/// wider line wraps and is cut with "..." (seen in the emulator). -pub const WIDGET_LINE_MAX: usize = 15; -/// While the phone waits for the user to allow a host. -pub const ASK_AGAIN_MS: u32 = 10_000; -/// After a round in which a host was denied or every answer failed. -pub const RETRY_ROUND_MS: u32 = 60_000; -/// Between two calls of a round: the phone answers one at a time, and its replies fill the inbox. -pub const PACE_MS: u32 = 250; -/// The longest wait between two tries while the phone is silent. -pub const LONGEST_MS: u32 = 60_000; -/// Quotes fetched longer ago than this are marked as old. -pub const STALE_MIN: i32 = 30; -/// Coming back to the screen asks again when the newest quote is this old. -pub const RESUME_MIN: i32 = 5; -/// The largest body `http.get` gives (`TOO_LARGE` above). -pub const BODY_MAX: usize = 2048; - -#[derive(Clone, Copy, PartialEq, Eq, Debug)] -pub enum Source { - Yahoo, - CoinGecko, -} - -impl Source { - pub fn index(self) -> usize { - self as usize - } -} - -pub struct Instrument { - pub name: &'static str, - /// For the widget card's second line. - pub short: &'static str, - /// Yahoo: the URL of its chart. CoinGecko: its coin id in the shared answer. - pub key: &'static str, - pub decimals: u8, -} - -macro_rules! yahoo { - ($symbol:literal) => { - concat!("https://query1.finance.yahoo.com/v8/finance/chart/%5E", $symbol, "?range=1d&interval=1d") - }; -} - -const COINGECKO_URL: &str = - "https://api.coingecko.com/api/v3/simple/price?ids=bitcoin,ethereum,solana&vs_currencies=usd&include_24hr_change=true"; - -pub const N: usize = 9; - -pub const INSTRUMENTS: [Instrument; N] = [ - Instrument { name: "S&P 500", short: "S&P", key: yahoo!("GSPC"), decimals: 2 }, - Instrument { name: "Nasdaq", short: "NDQ", key: yahoo!("IXIC"), decimals: 2 }, - Instrument { name: "Dow Jones", short: "DOW", key: yahoo!("DJI"), decimals: 2 }, - Instrument { name: "DAX", short: "DAX", key: yahoo!("GDAXI"), decimals: 2 }, - Instrument { name: "FTSE 100", short: "FTSE", key: yahoo!("FTSE"), decimals: 2 }, - Instrument { name: "Nikkei 225", short: "N225", key: yahoo!("N225"), decimals: 2 }, - Instrument { name: "Bitcoin", short: "BTC", key: "bitcoin", decimals: 0 }, - Instrument { name: "Ethereum", short: "ETH", key: "ethereum", decimals: 2 }, - Instrument { name: "Solana", short: "SOL", key: "solana", decimals: 2 }, -]; - -/// Calls per round: one per Yahoo instrument, then CoinGecko once for all coins. -pub const REQS: usize = 7; -const FIRST_COIN: usize = 6; -pub const BTC: usize = 6; - -/// The source and URL of call `r` of a round. -pub fn request(r: usize) -> (Source, &'static str) { - if r < FIRST_COIN { (Source::Yahoo, INSTRUMENTS[r].key) } else { (Source::CoinGecko, COINGECKO_URL) } -} - -/// The first call of the next source after call `r`. -fn next_source(r: usize) -> usize { - if r < FIRST_COIN { FIRST_COIN } else { REQS } -} - -#[derive(Clone, Copy, PartialEq, Eq, Debug)] -pub struct Quote { - /// ×[`parse::SCALE`]. - pub price: i64, - /// Hundredths of a percent. - pub change: Option, - /// Wall-clock minutes of the answer. - pub at: i32, -} - -/// How a host answered last. -#[derive(Clone, Copy, PartialEq, Eq, Debug)] -pub enum Status { - /// Not asked yet in this run. - Waiting, - Ok, - /// The phone asked the user to allow the host. - Ask, - /// The user said no. - Denied, - /// No network, a timeout, an HTTP error or a body we can't read. - Failed, -} - -/// What a message changed. -#[derive(Clone, Copy, PartialEq, Eq, Debug)] -pub enum Got { - Nothing, - /// Redraw. - Changed, -} - -/// The body of the open `http.get`: its records may come in any order. -struct Body { - buf: [u8; BODY_MAX], - head: Option, - /// Bytes from 0 that some record covered (the end of the furthest chunk). - end: usize, - bad: bool, -} - -impl Body { - const fn new() -> Body { - Body { buf: [0; BODY_MAX], head: None, end: 0, bad: false } - } - - fn clear(&mut self) { - self.head = None; - self.end = 0; - self.bad = false; - } - - /// Record `index` of `total`: the head first, then the body in chunks of 121 bytes (each but the last full). - fn put(&mut self, index: u8, total: u8, record: &[u8]) { - if index == 0 { - self.head = rpc::HttpHead::decode(record); - self.bad |= self.head.is_none(); - return; - } - let at = (index as usize - 1) * rpc::RECORD_MAX; - let full = record.len() == rpc::RECORD_MAX; - let to = at + record.len(); - if (index + 1 < total && !full) || record.len() > rpc::RECORD_MAX || to > BODY_MAX { - self.bad = true; - return; - } - self.buf[at..to].copy_from_slice(record); - self.end = self.end.max(to); - } - - /// The whole body of a 200 answer. - fn ok(&self) -> Option<&[u8]> { - let h = self.head?; - let n = h.length as usize; - (!self.bad && h.code == 200 && n == self.end).then(|| &self.buf[..n]) - } -} - -pub struct Model { - pub quotes: [Option; N], - pub pinned: usize, - /// Per [`Source`]. - pub status: [Status; 2], - /// A source answered with data in this round. - round_ok: [bool; 2], - call: rpc::Call, - ids: u8, - /// The call of the round being asked; meaningful while `running`. - cursor: usize, - running: bool, - body: Body, - /// Quotes came in this round and are not marked for storage yet. - fresh: bool, - /// Something worth keeping changed since the last [`Model::save`]. - dirty: bool, -} - -/// Storage: magic, version, pinned, then per instrument flags, price, change, minute. -const MAGIC: &[u8; 2] = b"MK"; -const VERSION: u8 = 1; -const QUOTE_BYTES: usize = 1 + 8 + 4 + 4; -pub const BLOB_MAX: usize = 4 + N * QUOTE_BYTES; -const HAS_QUOTE: u8 = 1; -const HAS_CHANGE: u8 = 2; - -/// Days since 1970-01-01 of a civil date. -pub fn days(y: i32, m: u32, d: u32) -> i32 { - let y = if m <= 2 { y - 1 } else { y }; - let (era, yoe) = (y.div_euclid(400), y.rem_euclid(400)); - let doy = (153 * ((m as i32 + 9) % 12) + 2) / 5 + d as i32 - 1; - era * 146_097 + yoe * 365 + yoe / 4 - yoe / 100 + doy - 719_468 -} - -/// Wall-clock minutes since 1970. -pub fn wall_min(y: i32, m: u32, d: u32, hour: u32, minute: u32) -> i32 { - days(y, m, d) * 1440 + (hour * 60 + minute) as i32 -} - -impl Model { - pub const fn new() -> Model { - Model { - quotes: [None; N], - pinned: 0, - status: [Status::Waiting; 2], - round_ok: [false; 2], - call: rpc::Call::new(LONGEST_MS), - ids: 0, - cursor: 0, - running: false, - body: Body::new(), - fresh: false, - dirty: false, - } - } - - /// A round is being asked. - pub fn running(&self) -> bool { - self.running - } - - /// The phone left the last call unanswered. - pub fn silent(&self) -> bool { - self.call.silent() - } - - /// Start a round at once, unless one runs (start, the refresh button); a silent phone is asked again at once. - pub fn refresh(&mut self, now: u32) { - if !self.running || self.silent() { - self.call.now(now); - } - } - - /// Waiting for a phone that answers: what the refresh button can't speed up. - pub fn busy(&self) -> bool { - self.running && !self.silent() - } - - /// Back on screen after `PAUSE`: the open call again (its answer was refused while paused), or a new round - /// when the newest quote is older than [`RESUME_MIN`]. - pub fn resume(&mut self, now: u32, wall: i32) { - if self.running || self.newest().is_none_or(|at| wall - at >= RESUME_MIN) { - self.call.now(now); - } - } - - /// The request to send now, if one is due. - pub fn poll(&mut self, now: u32) -> Option { - let id = self.call.due(now, &mut self.ids)?; - if !self.running { - self.running = true; - self.cursor = 0; - self.round_ok = [false; 2]; - } - self.body.clear(); - rpc::http_get(id, request(self.cursor).1) - } - - /// Ms until [`Model::poll`] has something to do. - pub fn wait(&self, now: u32) -> u32 { - self.call.wait(now) - } - - /// One message from the phone, at `now` ms and `wall` minutes. - pub fn reply(&mut self, m: &[u8], now: u32, wall: i32) -> Got { - if !self.running { - return Got::Nothing; - } - let src = request(self.cursor).0.index(); - match self.call.take(m) { - rpc::Got::Nothing => Got::Nothing, - rpc::Got::Status(s) => { - match s { - rpc::ASK => self.status[src] = Status::Ask, - rpc::DENIED => self.status[src] = Status::Denied, - _ => self.failed(src), // UNAVAILABLE, TOO_LARGE, BAD_REQUEST, an empty OK - } - let next = if matches!(s, rpc::ASK | rpc::DENIED) { next_source(self.cursor) } else { self.cursor + 1 }; - self.advance(next, now); - Got::Changed - } - rpc::Got::Record { index, total, record, last } => { - self.body.put(index, total, record); - if !last { - return Got::Nothing; - } - if !self.take_body(wall) { - self.failed(src); - } - self.advance(self.cursor + 1, now); - Got::Changed - } - } - } - - fn failed(&mut self, src: usize) { - if !self.round_ok[src] { - self.status[src] = Status::Failed; - } - } - - /// The finished body of call `cursor` into its quotes; `false` if it had none. - fn take_body(&mut self, wall: i32) -> bool { - let Some(body) = self.body.ok() else { return false }; - let mut got: [Option; N] = [None; N]; - let (src, _) = request(self.cursor); - match src { - Source::Yahoo => got[self.cursor] = parse::yahoo(body), - Source::CoinGecko => { - for (i, ins) in INSTRUMENTS.iter().enumerate().skip(FIRST_COIN) { - got[i] = parse::coingecko(body, ins.key.as_bytes()); - } - } - } - let mut any = false; - for (q, g) in self.quotes.iter_mut().zip(got) { - if let Some((price, change)) = g { - *q = Some(Quote { price, change, at: wall }); - any = true; - } - } - if any { - self.status[src.index()] = Status::Ok; - self.round_ok[src.index()] = true; - self.fresh = true; - } - any - } - - /// On to call `next`, or the round is over. - fn advance(&mut self, next: usize, now: u32) { - self.cursor = next; - if next < REQS { - self.call.after(now, PACE_MS); - return; - } - self.running = false; - self.flush(); - let st = self.status; - let again = if st.contains(&Status::Ask) { - ASK_AGAIN_MS - } else if st.contains(&Status::Denied) || st.contains(&Status::Failed) { - RETRY_ROUND_MS - } else { - PERIOD_MS - }; - self.call.after(now, again); - } - - /// Wall minutes of the newest quote. - pub fn newest(&self) -> Option { - self.quotes.iter().flatten().map(|q| q.at).max() - } - - pub fn any(&self) -> bool { - self.quotes.iter().any(Option::is_some) - } - - /// Makes `i` the instrument of the page and the widget card; `true` if it changed. - pub fn pin(&mut self, i: usize) -> bool { - if i >= N || i == self.pinned { - return false; - } - self.pinned = i; - self.dirty = true; - true - } - - /// The quotes of a round still running are worth keeping now (the app may end: `PAUSE`, `BUTTON`). - pub fn flush(&mut self) { - self.dirty |= core::mem::replace(&mut self.fresh, false); - } - - /// Whether to [`Model::save`] now: a round's new quotes or a new pin since the last time; one NAND write per - /// round, not per answer. - pub fn take_dirty(&mut self) -> bool { - core::mem::replace(&mut self.dirty, false) - } - - /// The cache blob into `out`; its length. - pub fn save(&self, out: &mut [u8; BLOB_MAX]) -> usize { - out[..2].copy_from_slice(MAGIC); - out[2] = VERSION; - out[3] = self.pinned as u8; - for (i, q) in self.quotes.iter().enumerate() { - let o = &mut out[4 + i * QUOTE_BYTES..4 + (i + 1) * QUOTE_BYTES]; - o.fill(0); - if let Some(q) = q { - o[0] = HAS_QUOTE | if q.change.is_some() { HAS_CHANGE } else { 0 }; - o[1..9].copy_from_slice(&q.price.to_le_bytes()); - o[9..13].copy_from_slice(&q.change.unwrap_or(0).to_le_bytes()); - o[13..17].copy_from_slice(&q.at.to_le_bytes()); - } - } - BLOB_MAX - } - - /// A blob of [`Model::save`]; anything else leaves the model as it is. `true` if it loaded. - pub fn load(&mut self, b: &[u8]) -> bool { - if b.len() != BLOB_MAX || &b[..2] != MAGIC || b[2] != VERSION || b[3] as usize >= N { - return false; - } - let mut quotes = [None; N]; - for (i, q) in quotes.iter_mut().enumerate() { - let o = &b[4 + i * QUOTE_BYTES..4 + (i + 1) * QUOTE_BYTES]; - let le4 = |a: usize| i32::from_le_bytes([o[a], o[a + 1], o[a + 2], o[a + 3]]); - if o[0] & HAS_QUOTE != 0 { - let mut p = [0u8; 8]; - p.copy_from_slice(&o[1..9]); - let price = i64::from_le_bytes(p); - if price <= 0 { - return false; - } - *q = Some(Quote { price, change: (o[0] & HAS_CHANGE != 0).then(|| le4(9)), at: le4(13) }); - } - } - self.quotes = quotes; - self.pinned = b[3] as usize; - true - } - - /// The price of `i` as shown, or "--". - pub fn price_text(&self, i: usize) -> Line { - match self.quotes[i] { - Some(q) => format::price(q.price, format::decimals(q.price, INSTRUMENTS[i].decimals)), - None => Line::of("--"), - } - } - - /// The change of `i` as shown, or empty. - pub fn change_text(&self, i: usize) -> Line { - match self.quotes[i].and_then(|q| q.change) { - Some(c) => format::change(c), - None => Line::new(), - } - } - - /// The instrument under the pinned one on the widget card and the page: Bitcoin, or the S&P 500 when Bitcoin is - /// pinned. - pub fn second(&self) -> usize { - if self.pinned == BTC { 0 } else { BTC } - } - - /// The widget card: title (≤ 23 bytes) and value (≤ 39 bytes, two lines), e.g. "S&P 500 +0.65%" and - /// "7,344.73\nBTC 58,893". Every line stays within [`WIDGET_LINE_MAX`] characters. - pub fn widget(&self) -> (Line, Line) { - let p = self.pinned; - let (name, short) = (INSTRUMENTS[p].name, INSTRUMENTS[p].short); - if self.quotes[p].is_none() { - return (Line::of(name), Line::of("No price yet\nOpen to load")); - } - // the first line that fits: "Nikkei 225 +1.23%" is too wide, "N225 +1.23%" is not - let ch = self.change_text(p); - let mut title = Line::new(); - if !ch.is_empty() && name.len() + 1 + ch.len() <= WIDGET_LINE_MAX { - title.push(name); - title.push(" "); - title.push(ch.as_str()); - } else if !ch.is_empty() && short.len() + 1 + ch.len() <= WIDGET_LINE_MAX { - title.push(short); - title.push(" "); - title.push(ch.as_str()); - } else { - title.push(if name.len() <= WIDGET_LINE_MAX { name } else { short }); - } - let mut value = self.price_text(p); - let s = self.second(); - if self.quotes[s].is_some() { - // "BTC 59,105 -0.27%" is too wide: the price, else the change - let (name, price, ch) = (INSTRUMENTS[s].short, self.price_text(s), self.change_text(s)); - let full = !ch.is_empty() && name.len() + 1 + price.len() + 1 + ch.len() <= WIDGET_LINE_MAX; - let (a, b) = if full { - (price.as_str(), ch.as_str()) - } else if name.len() + 1 + price.len() <= WIDGET_LINE_MAX { - (price.as_str(), "") - } else { - (ch.as_str(), "") - }; - let len = name.len() + 1 + a.len() + if b.is_empty() { 0 } else { 1 + b.len() }; - if !a.is_empty() && len <= WIDGET_LINE_MAX && value.len() + 1 + len <= 39 { - value.push("\n"); - value.push(name); - value.push(" "); - value.push(a); - if !b.is_empty() { - value.push(" "); - value.push(b); - } - } - } - (title, value) - } -} - -#[cfg(test)] -#[path = "model_tests.rs"] -mod tests; diff --git a/apps/markets/src/model_tests.rs b/apps/markets/src/model_tests.rs deleted file mode 100644 index 5d639d4..0000000 --- a/apps/markets/src/model_tests.rs +++ /dev/null @@ -1,388 +0,0 @@ -extern crate std; - -use super::*; -use std::vec::Vec; - -const GSPC: &[u8] = include_bytes!("fixtures/yahoo-gspc.json"); -const CG: &[u8] = include_bytes!("fixtures/coingecko.json"); -const WALL: i32 = 1440 * 20_000 + 14 * 60 + 5; - -/// `R1A id status index total record`. -fn msg(id: u8, status: u8, index: u8, total: u8, record: &[u8]) -> Vec { - let mut m = Vec::from(&b"R1A"[..]); - m.extend_from_slice(&[id, status, index, total]); - m.extend_from_slice(record); - m -} - -/// An `http.get` answer as the phone sends it: the head, then the body in 121-byte chunks. -fn answer(id: u8, code: u16, body: &[u8]) -> Vec> { - let chunks: Vec<&[u8]> = body.chunks(rpc::RECORD_MAX).collect(); - let total = 1 + chunks.len() as u8; - let mut head = Vec::from(code.to_le_bytes()); - head.extend_from_slice(&(body.len() as u16).to_le_bytes()); - let mut out = std::vec![msg(id, rpc::OK, 0, total, &head)]; - for (i, c) in chunks.iter().enumerate() { - out.push(msg(id, rpc::OK, 1 + i as u8, total, c)); - } - out -} - -/// The id of a request message. -fn id(m: &rpc::Msg) -> u8 { - m.as_bytes()[3] -} - -fn url(m: &rpc::Msg) -> &str { - core::str::from_utf8(&m.as_bytes()[5..]).unwrap() -} - -fn feed(m: &mut Model, msgs: &[Vec], now: u32) -> Got { - let mut got = Got::Nothing; - for x in msgs { - if m.reply(x, now, WALL) == Got::Changed { - got = Got::Changed; - } - } - got -} - -/// A small chart body for index `i`. -fn chart(price: &str, prev: &str) -> Vec { - std::format!(r#"{{"chart":{{"result":[{{"meta":{{"regularMarketPrice":{price},"chartPreviousClose":{prev}}}}}]}}}}"#) - .into_bytes() -} - -/// Answers a whole round with good data, from `now`; the time after it. -fn full_round(m: &mut Model, mut now: u32) -> u32 { - for r in 0..REQS { - let q = m.poll(now).unwrap_or_else(|| panic!("call {r} due at {now}")); - let body = if r < 6 { GSPC.to_vec() } else { CG.to_vec() }; - assert_eq!(feed(m, &answer(id(&q), 200, &body), now), Got::Changed); - now += PACE_MS; - } - now -} - -#[test] -fn every_url_fits_one_request() { - for r in 0..REQS { - let (_, u) = request(r); - assert!(u.len() <= 123 && u.starts_with("https://"), "{u}"); - assert!(rpc::http_get(1, u).is_some()); - } - assert_eq!(request(0).1, "https://query1.finance.yahoo.com/v8/finance/chart/%5EGSPC?range=1d&interval=1d"); -} - -#[test] -fn a_round_asks_one_at_a_time_and_fills_every_quote() { - let mut m = Model::new(); - assert!(m.poll(0).is_none()); // nothing until asked - m.refresh(0); - let q = m.poll(0).unwrap(); - assert!(m.running()); - assert_eq!(url(&q), request(0).1); - assert!(m.poll(1).is_none()); // one in flight - let msgs = answer(id(&q), 200, GSPC); - assert!(msgs.len() > 2); - // records in any order; nothing to redraw until the last one - for x in msgs.iter().rev().skip(1) { - assert_eq!(m.reply(x, 10, WALL), Got::Nothing); - } - assert_eq!(m.reply(&msgs[msgs.len() - 1], 10, WALL), Got::Changed); - assert_eq!(m.quotes[0], Some(Quote { price: 73_447_300, change: Some(65), at: WALL })); - assert!(!m.take_dirty()); // kept at the round's end - m.flush(); - assert!(m.take_dirty() && !m.take_dirty()); - assert!(m.poll(10).is_none()); // paced - assert_eq!(m.wait(10), PACE_MS); - let q = m.poll(10 + PACE_MS).unwrap(); - assert_eq!(url(&q), request(1).1); - - let mut m = Model::new(); - m.refresh(0); - let end = full_round(&mut m, 0); - assert!(!m.running()); - assert!(m.take_dirty()); - assert!(m.quotes.iter().all(Option::is_some)); - assert_eq!(m.quotes[BTC].unwrap().price, 591_050_000); - assert_eq!(m.status, [Status::Ok; 2]); - assert_eq!(m.wait(end - PACE_MS), PERIOD_MS); // the next round - assert!(m.poll(end - PACE_MS + PERIOD_MS).is_some_and(|q| url(&q) == request(0).1)); -} - -#[test] -fn replies_for_an_old_id_are_dropped() { - let mut m = Model::new(); - m.refresh(0); - let first = m.poll(0).unwrap(); - // silent: asked again with a new id after 3 s - let again = m.poll(rpc::RETRY_MS).unwrap(); - assert_ne!(id(&first), id(&again)); - assert_eq!(url(&first), url(&again)); - assert!(m.silent()); - assert_eq!(feed(&mut m, &answer(id(&first), 200, GSPC), 3_100), Got::Nothing); - assert_eq!(m.quotes[0], None); - assert_eq!(feed(&mut m, &answer(id(&again), 200, GSPC), 3_200), Got::Changed); - assert!(m.quotes[0].is_some() && !m.silent()); - // other prefixes and garbage are nothing - assert_eq!(m.reply(b"hello", 0, WALL), Got::Nothing); - assert_eq!(m.reply(b"R1A", 0, WALL), Got::Nothing); -} - -#[test] -fn silence_backs_off() { - let mut m = Model::new(); - m.refresh(0); - let mut t = 0; - m.poll(t).unwrap(); - let mut waits = Vec::new(); - for _ in 0..7 { - let w = m.wait(t); - waits.push(w); - t += w; - assert!(m.poll(t).is_some()); - } - assert_eq!(waits, [3_000, 6_000, 12_000, 24_000, 48_000, 60_000, 60_000]); - assert!(m.silent() && m.running()); -} - -#[test] -fn ask_skips_the_host_and_asks_again_soon() { - let mut m = Model::new(); - m.refresh(0); - let q = m.poll(0).unwrap(); - assert_eq!(feed(&mut m, &[msg(id(&q), rpc::ASK, 0, 0, &[])], 5), Got::Changed); - assert_eq!(m.status[0], Status::Ask); - // the other Yahoo URLs are skipped: CoinGecko next - let q = m.poll(5 + PACE_MS).unwrap(); - assert_eq!(request(6).1, url(&q)); - feed(&mut m, &answer(id(&q), 200, CG), 10 + PACE_MS); - assert!(!m.running()); - assert_eq!(m.status, [Status::Ask, Status::Ok]); - assert_eq!(m.wait(10 + PACE_MS), ASK_AGAIN_MS); - // allowed now: the next round fills the indices - let end = full_round(&mut m, 10 + PACE_MS + ASK_AGAIN_MS); - assert_eq!(m.status, [Status::Ok; 2]); - assert_eq!(m.wait(end - PACE_MS), PERIOD_MS); -} - -#[test] -fn denied_and_failures() { - let mut m = Model::new(); - m.refresh(0); - let q = m.poll(0).unwrap(); - feed(&mut m, &[msg(id(&q), rpc::DENIED, 0, 0, &[])], 0); - let q = m.poll(PACE_MS).unwrap(); - feed(&mut m, &[msg(id(&q), rpc::UNAVAILABLE, 0, 0, &[])], PACE_MS); - assert_eq!(m.status, [Status::Denied, Status::Failed]); - assert!(!m.running()); - assert_eq!(m.wait(PACE_MS), RETRY_ROUND_MS); - - // an HTTP error, a body we can't read, TOO_LARGE: that call fails, the round goes on - let mut m = Model::new(); - m.refresh(0); - let mut t = 0; - let q = m.poll(t).unwrap(); - feed(&mut m, &answer(id(&q), 429, b"{}"), t); - assert_eq!(m.status[0], Status::Failed); - t += PACE_MS; - let q = m.poll(t).unwrap(); - feed(&mut m, &answer(id(&q), 200, b""), t); - t += PACE_MS; - let q = m.poll(t).unwrap(); - feed(&mut m, &[msg(id(&q), rpc::TOO_LARGE, 0, 0, &[])], t); - t += PACE_MS; - let q = m.poll(t).unwrap(); - feed(&mut m, &answer(id(&q), 200, GSPC), t); - assert_eq!(m.status[0], Status::Ok); - assert_eq!(&m.quotes[..4].iter().map(Option::is_some).collect::>(), &[false, false, false, true]); - // a failure after a success in the same round keeps the source Ok - t += PACE_MS; - let q = m.poll(t).unwrap(); - feed(&mut m, &[msg(id(&q), rpc::UNAVAILABLE, 0, 0, &[])], t); - assert_eq!(m.status[0], Status::Ok); -} - -#[test] -fn a_cut_or_odd_body_is_not_taken() { - let body = chart("7344.73", "7297.49"); - // a head that claims more than came - let mut m = Model::new(); - m.refresh(0); - let q = m.poll(0).unwrap(); - let mut msgs = answer(id(&q), 200, &body); - msgs[0][9] = 0xFF; // the length's low byte - feed(&mut m, &msgs, 0); - assert_eq!(m.quotes[0], None); - assert_eq!(m.status[0], Status::Failed); - // a short chunk in the middle - let long = GSPC; - let q = m.poll(PACE_MS).unwrap(); - let mut msgs = answer(id(&q), 200, long); - msgs[1].pop(); - feed(&mut m, &msgs, PACE_MS); - assert_eq!(m.quotes[1], None); - // a body over 2048 bytes in pieces past the buffer - let q = m.poll(2 * PACE_MS).unwrap(); - let big = [b' '; 2100]; - let msgs = answer(id(&q), 200, &big); - feed(&mut m, &msgs, 2 * PACE_MS); - assert_eq!(m.quotes[2], None); - assert!(m.running()); -} - -#[test] -fn resume_asks_again_when_old_or_open() { - let mut m = Model::new(); - m.refresh(0); - let end = full_round(&mut m, 0); - let now = end + 1000; - // fresh: nothing until the period is over - m.resume(now, WALL + 1); - assert!(m.poll(now).is_none()); - m.resume(now, WALL + RESUME_MIN); - assert!(m.poll(now).is_some()); - // paused with a call open: asked again at once, not counted as silence - let mut m = Model::new(); - m.refresh(0); - let first = m.poll(0).unwrap(); - m.resume(500, WALL); - let again = m.poll(500).unwrap(); - assert!(!m.silent()); - assert_ne!(id(&first), id(&again)); - assert_eq!(url(&first), url(&again)); -} - -#[test] -fn refresh_doesnt_restart_a_running_round() { - let mut m = Model::new(); - m.refresh(0); - let first = m.poll(0).unwrap(); - assert!(m.busy()); - m.refresh(100); - assert!(m.poll(100).is_none()); - // a silent phone: the button asks again at once, with a fresh back-off - for t in [3_000, 9_000] { - m.poll(t).unwrap(); - } - assert!(m.silent() && !m.busy()); - assert_eq!(m.wait(9_000), 12_000); - m.refresh(9_500); - let q = m.poll(9_500).unwrap(); - assert_eq!(url(&q), url(&first)); - assert_eq!(m.wait(9_500), rpc::RETRY_MS); -} - -#[test] -fn storage_round_trip() { - let mut m = Model::new(); - m.refresh(0); - full_round(&mut m, 0); - m.quotes[3] = None; - m.quotes[4] = Some(Quote { price: 5, change: None, at: -7 }); - assert!(m.pin(7)); - assert!(!m.pin(7)); - assert!(!m.pin(N)); - let mut blob = [0u8; BLOB_MAX]; - assert_eq!(m.save(&mut blob), BLOB_MAX); - let mut n = Model::new(); - assert!(n.load(&blob)); - assert_eq!(n.quotes, m.quotes); - assert_eq!(n.pinned, 7); - assert!(BLOB_MAX <= 4096); -} - -#[test] -fn a_bad_blob_loads_nothing() { - let mut m = Model::new(); - m.quotes[0] = Some(Quote { price: 1, change: Some(2), at: 3 }); - let mut blob = [0u8; BLOB_MAX]; - m.save(&mut blob); - let bad = |f: &dyn Fn(&mut [u8; BLOB_MAX]) -> usize| { - let mut b = blob; - let n = f(&mut b); - let mut n2 = Model::new(); - assert!(!n2.load(&b[..n])); - assert_eq!(n2.quotes, [None; N]); - assert_eq!(n2.pinned, 0); - }; - bad(&|b| { - b[0] = b'X'; - BLOB_MAX - }); - bad(&|b| { - b[2] = 9; - BLOB_MAX - }); - bad(&|b| { - b[3] = N as u8; - BLOB_MAX - }); - bad(&|b| { - b[5..13].fill(0xFF); // a negative price - BLOB_MAX - }); - bad(&|_| BLOB_MAX - 1); - bad(&|_| 0); -} - -#[test] -fn widget_text_fits() { - let mut m = Model::new(); - let (t, v) = m.widget(); - assert_eq!((t.as_str(), v.as_str()), ("S&P 500", "No price yet\nOpen to load")); - m.refresh(0); - full_round(&mut m, 0); - let (t, v) = m.widget(); - assert_eq!(t.as_str(), "S&P 500 +0.65%"); - assert_eq!(v.as_str(), "7,344.73\nBTC 59,105"); - m.pin(BTC); - let (t, v) = m.widget(); - assert_eq!(t.as_str(), "Bitcoin -0.27%"); - assert_eq!(v.as_str(), "59,105\nS&P 7,344.73"); - // every line fits the card's width for any price up to 9,999,999.99 and any change down to -99.99% - for (price, change) in [(99_999_999_900, -9_999), (73_447_300, 65), (10_000, 0), (1, -1)] { - for i in 0..N { - m.quotes[i] = Some(Quote { price, change: Some(change), at: 0 }); - } - for p in 0..N { - m.pin(p); - let (t, v) = m.widget(); - for line in core::iter::once(t.as_str()).chain(v.as_str().split('\n')) { - assert!(line.len() <= WIDGET_LINE_MAX, "{line:?} is wider than the card"); - } - } - } - m.pin(5); - for i in 0..N { - m.quotes[i] = Some(Quote { price: 999_999_999_900, change: Some(123), at: 0 }); - } - assert_eq!(m.widget().0.as_str(), "N225 +1.23%"); - // the longest texts there can be stay inside the card's limits - for i in 0..N { - m.quotes[i] = Some(Quote { price: i64::MAX, change: Some(i32::MIN), at: 0 }); - } - for p in 0..N { - m.pin(p); - let (t, v) = m.widget(); - assert!(t.len() <= 23 && v.len() <= 39, "{t:?} {v:?}"); - assert!(v.as_str().matches('\n').count() <= 1); - } - for i in 0..N { - m.quotes[i] = Some(Quote { price: 999_999_999_999, change: Some(-99_999), at: 0 }); - } - for p in 0..N { - m.pin(p); - let (t, v) = m.widget(); - assert!(t.len() <= 23 && v.len() <= 39, "{t:?} {v:?}"); - assert!(v.as_str().contains('\n'), "{v:?}"); - } -} - -#[test] -fn wall_clock_minutes() { - assert_eq!(days(1970, 1, 1), 0); - assert_eq!(wall_min(2026, 12, 1, 14, 5) % 1440, 14 * 60 + 5); - assert_eq!(wall_min(2026, 12, 2, 0, 0) - wall_min(2026, 12, 1, 0, 0), 1440); -} diff --git a/apps/markets/src/parse.rs b/apps/markets/src/parse.rs deleted file mode 100644 index b28635e..0000000 --- a/apps/markets/src/parse.rs +++ /dev/null @@ -1,275 +0,0 @@ -//! Numbers out of a web server's JSON body, without floats, a heap or a JSON parser: find `"key":`, read the number -//! after it into fixed point. Every byte is untrusted: nothing here indexes past a slice or panics, and anything odd -//! is `None`. -//! -//! Prices are ×[`SCALE`] (4 decimals), changes are hundredths of a percent (`65` = 0.65 %). - -/// Fixed point of a price: 4 decimals. -pub const SCALE: i64 = 10_000; -pub const SCALE_DIGITS: i32 = 4; - -/// The significant digits kept of a number; more are rounded off (10^18 still fits an `i64`). -const MAX_DIGITS: u32 = 18; - -/// `10^n` for `n` in 0..=18. -fn pow10(n: u32) -> i64 { - 10i64.pow(n.min(18)) -} - -/// `a / b` rounded half away from zero, `b` > 0. -pub fn div_round(a: i64, b: i64) -> i64 { - let (q, r) = (a / b, a % b); - if r.unsigned_abs() * 2 >= b.unsigned_abs() { q + a.signum() } else { q } -} - -/// The JSON number at the start of `b` (after spaces), times `10^digits`, rounded half away from zero. `None` if -/// there is no number, it doesn't end (a cut body), or it doesn't fit an `i64`. -pub fn number(b: &[u8], digits: i32) -> Option { - let mut i = 0; - while b.get(i).is_some_and(|c| c.is_ascii_whitespace()) { - i += 1; - } - let neg = b.get(i) == Some(&b'-'); - if neg { - i += 1; - } - let (mut mant, mut exp, mut kept, mut seen) = (0i64, 0i32, 0u32, false); - // the integer part - while let Some(c) = b.get(i).filter(|c| c.is_ascii_digit()) { - seen = true; - if kept < MAX_DIGITS { - mant = mant * 10 + (c - b'0') as i64; - if mant != 0 { - kept += 1; - } - } else { - exp = exp.saturating_add(1); - } - i += 1; - } - if !seen { - return None; - } - // the fraction - if b.get(i) == Some(&b'.') { - i += 1; - let mut frac = false; - while let Some(c) = b.get(i).filter(|c| c.is_ascii_digit()) { - frac = true; - if kept < MAX_DIGITS { - mant = mant * 10 + (c - b'0') as i64; - exp -= 1; - if mant != 0 { - kept += 1; - } - } - i += 1; - } - if !frac { - return None; - } - } - // the exponent - if matches!(b.get(i), Some(b'e' | b'E')) { - i += 1; - let eneg = b.get(i) == Some(&b'-'); - if matches!(b.get(i), Some(b'-' | b'+')) { - i += 1; - } - let (mut e, mut any) = (0i32, false); - while let Some(c) = b.get(i).filter(|c| c.is_ascii_digit()) { - any = true; - e = (e * 10 + (c - b'0') as i32).min(1000); - i += 1; - } - if !any { - return None; - } - exp = exp.saturating_add(if eneg { -e } else { e }); - } - // a number runs to a delimiter; one at the very end may have been cut - if !matches!(b.get(i), Some(b',' | b'}' | b']' | b' ' | b'\t' | b'\r' | b'\n')) { - return None; - } - let shift = exp.saturating_add(digits); - let v = if mant == 0 { - 0 - } else if shift >= 0 { - if shift > MAX_DIGITS as i32 { - return None; - } - mant.checked_mul(pow10(shift as u32))? - } else if shift < -(MAX_DIGITS as i32) { - 0 - } else { - div_round(mant, pow10((-shift) as u32)) - }; - Some(if neg { -v } else { v }) -} - -/// Where the value of `"key":` starts in `b` (the first such key), past the colon and any spaces. -pub fn value_at(b: &[u8], key: &[u8]) -> Option { - let n = key.len(); - let mut i = 0; - while i + n + 2 <= b.len() { - if b[i] == b'"' && &b[i + 1..i + 1 + n] == key && b[i + 1 + n] == b'"' { - let mut j = i + n + 2; - while b.get(j).is_some_and(|c| c.is_ascii_whitespace()) { - j += 1; - } - if b.get(j) == Some(&b':') { - j += 1; - while b.get(j).is_some_and(|c| c.is_ascii_whitespace()) { - j += 1; - } - return Some(j); - } - } - i += 1; - } - None -} - -/// The number of `"key":` in `b`, ×`10^digits`. -pub fn field(b: &[u8], key: &[u8], digits: i32) -> Option { - number(b.get(value_at(b, key)?..)?, digits) -} - -/// The change from `prev` to `price` (both ×[`SCALE`]) in hundredths of a percent; `None` without a usable `prev`. -pub fn change(price: i64, prev: i64) -> Option { - if prev <= 0 { - return None; - } - let d = price.checked_sub(prev)?.checked_mul(10_000)?; - i32::try_from(div_round(d, prev)).ok() -} - -/// A hundredths-of-a-percent field, `None` if it doesn't fit. -fn percent(b: &[u8], key: &[u8]) -> Option { - i32::try_from(field(b, key, 2)?).ok() -} - -/// A quote: its price ×[`SCALE`] and its change, when the source gave one. -pub type Parsed = (i64, Option); - -/// Yahoo Finance's chart (`/v8/finance/chart/?range=1d&interval=1d`): `meta.regularMarketPrice`, the change -/// from `meta.chartPreviousClose`, else `meta.regularMarketChangePercent`. -pub fn yahoo(b: &[u8]) -> Option { - let price = field(b, b"regularMarketPrice", SCALE_DIGITS).filter(|&p| p > 0)?; - let ch = field(b, b"chartPreviousClose", SCALE_DIGITS) - .and_then(|prev| change(price, prev)) - .or_else(|| percent(b, b"regularMarketChangePercent")); - Some((price, ch)) -} - -/// CoinGecko's `/simple/price?ids=…&vs_currencies=usd&include_24hr_change=true`: the coin `id`'s object, `usd` and -/// `usd_24h_change`. -pub fn coingecko(b: &[u8], id: &[u8]) -> Option { - let at = value_at(b, id)?; - let obj = b.get(at..)?; - if obj.first() != Some(&b'{') { - return None; - } - let obj = &obj[..=obj.iter().position(|&c| c == b'}')?]; - let price = field(obj, b"usd", SCALE_DIGITS).filter(|&p| p > 0)?; - Some((price, percent(obj, b"usd_24h_change"))) -} - -#[cfg(test)] -mod tests { - use super::*; - - const GSPC: &[u8] = include_bytes!("fixtures/yahoo-gspc.json"); - const FTSE: &[u8] = include_bytes!("fixtures/yahoo-ftse.json"); - const CG: &[u8] = include_bytes!("fixtures/coingecko.json"); - - #[test] - fn numbers_into_fixed_point() { - assert_eq!(number(b"7344.73,", 4), Some(73_447_300)); - assert_eq!(number(b"7344.73}", 2), Some(734_473)); - assert_eq!(number(b" 58893}", 0), Some(58_893)); - assert_eq!(number(b"-0.7024911061174398,", 2), Some(-70)); - assert_eq!(number(b"0.647,", 2), Some(65)); // half away from zero - assert_eq!(number(b"-0.645,", 2), Some(-65)); - assert_eq!(number(b"0.644,", 2), Some(64)); - assert_eq!(number(b"0,", 4), Some(0)); - assert_eq!(number(b"-0.0001,", 2), Some(0)); - assert_eq!(number(b"1.5e3,", 0), Some(1500)); - assert_eq!(number(b"1.5E-2,", 4), Some(150)); - assert_eq!(number(b"2e+2]", 0), Some(200)); - assert_eq!(number(b"1e-30,", 4), Some(0)); - assert_eq!(number(b"123456789012345678901234,", 0), None); // past i64 - assert_eq!(number(b"99999999999999.9999,", 4), Some(999_999_999_999_999_999)); - // more digits than kept: the rest only rounds away - assert_eq!(number(b"0.12345678901234567890123,", 4), Some(1235)); - } - - #[test] - fn garbage_is_none() { - for b in [&b""[..], b"-", b"abc,", b".5,", b"1.,", b"1e,", b"--1,", b"null,", b"\"7\",", b"1e999999999999,"] { - assert_eq!(number(b, 4), None, "{:?}", core::str::from_utf8(b)); - } - // cut: no delimiter after the number - assert_eq!(number(b"7344.7", 4), None); - } - - #[test] - fn keys_need_quotes_and_colon() { - let b = br#"{"chartPreviousClose":1,"previousClose" : 2, "usd_24h_change":3,"usd":4}"#; - assert_eq!(field(b, b"previousClose", 0), Some(2)); - assert_eq!(field(b, b"usd", 0), Some(4)); - assert_eq!(field(b, b"missing", 0), None); - assert_eq!(value_at(b"\"k\"", b"k"), None); - assert_eq!(field(b"{\"k\":", b"k", 0), None); - } - - #[test] - fn yahoo_fixture() { - assert_eq!(yahoo(GSPC), Some((73_447_300, Some(65)))); - // FTSE: 10695.16 from 10698.81 is -0.0341 % - assert_eq!(yahoo(FTSE), Some((106_951_600, Some(-3)))); - // without the previous close the server's percent stands in - let b = br#"{"regularMarketPrice":100.5,"regularMarketChangePercent":-1.234}"#; - assert_eq!(yahoo(b), Some((1_005_000, Some(-123)))); - assert_eq!(yahoo(br#"{"regularMarketPrice":100.5}"#), Some((1_005_000, None))); - assert_eq!(yahoo(br#"{"chart":{"result":null,"error":{"code":"Not Found"}}}"#), None); - assert_eq!(yahoo(br#"{"regularMarketPrice":-3,"x":1}"#), None); - } - - #[test] - fn coingecko_fixture() { - assert_eq!(coingecko(CG, b"bitcoin"), Some((591_050_000, Some(-27)))); - assert_eq!(coingecko(CG, b"ethereum"), Some((16_560_800, Some(138)))); - assert_eq!(coingecko(CG, b"solana"), Some((717_800, Some(215)))); - assert_eq!(coingecko(CG, b"dogecoin"), None); - // a coin's key looked up in its own object only - let b = br#"{"bitcoin":{"usd":1},"solana":{"usd":2,"usd_24h_change":5}}"#; - assert_eq!(coingecko(b, b"bitcoin"), Some((10_000, None))); - assert_eq!(coingecko(br#"{"bitcoin":5}"#, b"bitcoin"), None); - assert_eq!(coingecko(br#"{"bitcoin":{"usd":5"#, b"bitcoin"), None); // cut - } - - #[test] - fn every_cut_of_a_body_is_safe() { - for b in [GSPC, FTSE, CG] { - for n in 0..b.len() { - let _ = yahoo(&b[..n]); - let _ = coingecko(&b[..n], b"solana"); - } - } - // a cut before the price's delimiter never gives a wrong price - let at = value_at(GSPC, b"regularMarketPrice").unwrap(); - assert_eq!(yahoo(&GSPC[..at + 6]), None); - } - - #[test] - fn change_from_previous_close() { - assert_eq!(change(73_447_300, 72_974_900), Some(65)); - assert_eq!(change(100 * SCALE, 100 * SCALE), Some(0)); - assert_eq!(change(50 * SCALE, 100 * SCALE), Some(-5000)); - assert_eq!(change(300 * SCALE, 100 * SCALE), Some(20000)); - assert_eq!(change(1, 0), None); - assert_eq!(change(1, -5), None); - assert_eq!(change(i64::MAX, 1), None); - } -} diff --git a/apps/markets/src/screen.rs b/apps/markets/src/screen.rs deleted file mode 100644 index 55e1dc5..0000000 --- a/apps/markets/src/screen.rs +++ /dev/null @@ -1,419 +0,0 @@ -//! What the screens draw, through `cmf_wp2_ui::Surface` so host tests see the watch's pixels. Two screens: -//! -//! - the menu app ([`menu`]): the title, a status line, the nine instruments in a list the crown scrolls (name and -//! price, the change under the price; the pinned one on the stock row grey), the stock round scroll bar and a -//! Refresh pill; -//! - the page next to the watch face ([`page`]): the pinned instrument's price big in dot-matrix figures (the -//! watch's own style for big numbers), four others under it, the status line. -//! -//! Text is Inter (`cmf_wp2_ui::font`, the system font's family) in the stock colours (`cmf_wp2_app::stock`); up and -//! down in the status green and red the app guide names. Each screen is drawn whole: it changes on a reply, a crown -//! detent or a tap, never per frame. - -use crate::format::{self, Line}; -use crate::model::{INSTRUMENTS, Model, N, STALE_MIN, Status}; -use cmf_wp2_app::stock; -use cmf_wp2_ui::color::{BLACK as BLACK_RGB, Rgb, rgb565}; -use cmf_wp2_ui::draw::{rrect, scroll_bar}; -use cmf_wp2_ui::font::{self, HEIGHT, width}; -use cmf_wp2_ui::geom::chord; -use cmf_wp2_ui::{C, SIZE, Surface}; - -pub const BLACK: u16 = stock::BLACK as u16; -pub const WHITE: u16 = stock::WHITE as u16; -pub const GREY: u16 = stock::GREY as u16; -pub const ACCENT: u16 = stock::ACCENT as u16; -pub const ROW_BG: u16 = stock::ROW_BG as u16; -/// Up and down: the status green and red of the app guide (herdr-agents). -pub const UP: u16 = rgb565(60, 220, 110); -pub const DOWN: u16 = rgb565(255, 80, 40); - -/// The change's arrow: a triangle `6 · ARROW_U` px square, `ARROW_GAP` px before the change. -const ARROW_U: i32 = 2; -const ARROW_GAP: i32 = 5; -/// Between two texts on one line. -const GAP: i32 = 12; - -// the menu: clear of the loader's status bar (the time, centred at y 4) -const TITLE_Y: i32 = 38; -const STATUS_Y: i32 = 66; -pub const LIST_TOP: i32 = 94; -pub const ROW_H: i32 = 60; -pub const ROWS: usize = 5; -const ROW_MARGIN: i32 = 10; -const PAD: i32 = 22; -pub const PILL_Y: i32 = 400; -const PILL_W: i32 = 160; -const PILL_H: i32 = 36; - -// the page -const NAME_Y: i32 = 52; -/// The pinned price: dot-matrix figures, the largest pitch from [`PITCHES`] that fits. -pub const PRICE_Y: i32 = 84; -const PITCHES: [i32; 5] = [6, 5, 4, 3, 2]; -const CHANGE_Y: i32 = 146; -pub const OTHERS_Y: i32 = 190; -pub const OTHER_H: i32 = 40; -pub const OTHERS: usize = 4; -const OTHER_MARGIN: i32 = 8; -const PAGE_STATUS_Y: i32 = 370; -/// The instruments under the pinned one, in this order: indices and coins mixed. -const PAGE_ORDER: [usize; N] = [0, 6, 1, 7, 2, 3, 4, 5, 8]; - -/// What the menu shows besides the data. -pub struct Ui { - pub scroll: usize, -} - -impl Ui { - pub const fn new() -> Ui { - Ui { scroll: 0 } - } - - /// One crown detent; `true` if the list moved. - pub fn crown(&mut self, delta: i16) -> bool { - let s = (self.scroll as i32 + delta.signum() as i32).clamp(0, (N - ROWS) as i32) as usize; - let moved = s != self.scroll; - self.scroll = s; - moved - } -} - -/// What a tap hit. -#[derive(Clone, Copy, PartialEq, Eq, Debug)] -pub enum Hit { - Nothing, - /// Pin this instrument. - Pin(usize), - Refresh, -} - -/// The status line and its colour: the phone's answer if something is wrong, else when the quotes are from. -pub fn status(m: &Model, wall: i32) -> (Line, u16) { - let newest = m.newest(); - let with_time = |s: &str| { - let mut l = Line::of(s); - if let Some(at) = newest { - l.push(" "); - l.push(format::hhmm(at).as_str()); - } - l - }; - if m.status.contains(&Status::Ask) { - (Line::of("Allow on phone"), ACCENT) - } else if m.status.contains(&Status::Denied) { - (Line::of("Off in Companion"), ACCENT) - } else if m.silent() { - (with_time("No phone"), GREY) - } else if m.running() { - (Line::of("Updating..."), GREY) - } else if m.status.contains(&Status::Failed) { - (with_time("Can't load"), GREY) - } else { - match newest { - None => (Line::of("No prices yet"), GREY), - Some(at) if wall - at > STALE_MIN => (with_time("Stale"), ACCENT), - Some(_) => (with_time("Updated"), GREY), - } - } -} - -/// Every input of a screen besides the model's quotes: the status line and which quotes are stale. When it changes -/// with the clock the screen is drawn again. -pub fn clock_key(m: &Model, wall: i32) -> (Line, u16) { - let mut stale = 0u16; - for (i, q) in m.quotes.iter().enumerate() { - if q.is_some_and(|q| wall - q.at > STALE_MIN) { - stale |= 1 << i; - } - } - (status(m, wall).0, stale) -} - -/// The phone needs the user before there is anything to show: the lines that say what to do. -fn help(m: &Model) -> Option<&'static [&'static str]> { - if m.any() { - return None; - } - if m.status.contains(&Status::Ask) { - Some(&["On your phone, open", "FMC Companion", "> Apps > Markets", "and allow it"]) - } else if m.status.contains(&Status::Denied) { - Some(&["Turned off on phone.", "Turn it on in", "FMC Companion", "> Apps > Markets"]) - } else { - None - } -} - -fn colour(change: Option) -> u16 { - match change { - Some(c) if c > 0 => UP, - Some(c) if c < 0 => DOWN, - _ => GREY, - } -} - -/// A triangle `6 · u` px square at (x, y), pointing up or down. -fn arrow(s: &mut impl Surface, x: i32, y: i32, u: i32, up: bool, c: u16) { - for k in 0..6 { - let w = (k + 1) * u; - let row = if up { k } else { 5 - k }; - s.rect(x + (6 * u - w) / 2, y + row * u, w, u, c); - } -} - -/// The room the change of `i` takes: its text, and the arrow before it if `with_arrow`. -fn change_width(m: &Model, i: usize, with_arrow: bool) -> i32 { - let ch = m.change_text(i); - let arrowed = with_arrow && m.quotes[i].and_then(|q| q.change).is_some_and(|v| v != 0); - width(ch.as_str()) + if arrowed { 6 * ARROW_U + ARROW_GAP } else { 0 } -} - -/// The change of `i`, right-aligned to end at `right`, with its arrow if `with_arrow`; its left x. -fn change_at(s: &mut impl Surface, m: &Model, i: usize, right: i32, y: i32, with_arrow: bool) -> i32 { - let ch = m.change_text(i); - let change = m.quotes[i].and_then(|q| q.change); - let c = colour(change); - let x = right - width(ch.as_str()); - font::draw(s, x, y, ch.as_str(), c); - match change { - Some(v) if with_arrow && v != 0 => { - let ax = x - ARROW_GAP - 6 * ARROW_U; - arrow(s, ax, y + 2, ARROW_U, v > 0, c); - ax - } - _ => x, - } -} - -fn clear(s: &mut impl Surface) { - s.rect(0, 0, SIZE, SIZE, BLACK); -} - -/// A centred line, cut at the circle. -fn line(s: &mut impl Surface, y: i32, t: &str, c: u16) { - let (x0, x1) = chord(y - 4, y + HEIGHT, 8); - if width(t) <= x1 - x0 { - font::centre(s, C, y, t, c); - } else { - font::fitted(s, x0, y, t, x1 - x0, c); - } -} - -fn lines(s: &mut impl Surface, top: i32, ls: &[&str]) { - for (k, t) in ls.iter().enumerate() { - line(s, top + k as i32 * 30, t, WHITE); - } -} - -/// The row band of visible row `r` of the menu: (y, x0, x1). Every row is as wide as the narrowest, so the names, -/// prices and changes line up in columns. -pub fn menu_row(r: usize) -> (i32, i32, i32) { - let y = LIST_TOP + r as i32 * ROW_H; - let (x0, x1) = chord(LIST_TOP, LIST_TOP + ROWS as i32 * ROW_H, ROW_MARGIN); - (y, x0, x1) -} - -/// The text box of a menu row: (left, right) inside the row's pill. -pub fn menu_text(r: usize) -> (i32, i32) { - let (_, x0, x1) = menu_row(r); - (x0 + PAD, x1 - PAD) -} - -/// One instrument in a menu row: the name and the price on line 1, the time of an old quote and the change under -/// the price on line 2. Prices and changes are right-aligned. -fn menu_item(s: &mut impl Surface, m: &Model, i: usize, r: usize, wall: i32) { - let (y, x0, x1) = menu_row(r); - if i == m.pinned { - rrect(s, x0, y + 3, x1 - x0, ROW_H - 6, (ROW_H - 6) / 2, Rgb::from565(ROW_BG), BLACK_RGB); - } - let (l, rt) = menu_text(r); - let (y1, y2) = (y + 8, y + 32); - // line 1: the price, right; the name in what is left - let price = m.price_text(i); - let pw = width(price.as_str()); - if pw > rt - l { - font::fitted(s, l, y1, price.as_str(), rt - l, WHITE); - } else { - font::draw(s, rt - pw, y1, price.as_str(), WHITE); - font::fitted(s, l, y1, INSTRUMENTS[i].name, rt - pw - GAP - l, WHITE); - } - // line 2: the change and its arrow, right; the time of an old quote, left - let with_arrow = change_width(m, i, true) <= rt - l; - let cx = change_at(s, m, i, rt, y2, with_arrow); - if let Some(q) = m.quotes[i].filter(|q| wall - q.at > STALE_MIN) { - font::fitted(s, l, y2, format::hhmm(q.at).as_str(), cx - GAP - l, GREY); - } -} - -/// The menu screen. -pub fn menu(s: &mut impl Surface, m: &Model, ui: &Ui, wall: i32) { - clear(s); - font::centre(s, C, TITLE_Y, "Markets", ACCENT); - let (st, c) = status(m, wall); - line(s, STATUS_Y, st.as_str(), c); - if let Some(h) = help(m) { - lines(s, LIST_TOP + 60, h); - } else { - for r in 0..ROWS { - let i = ui.scroll + r; - if i < N { - menu_item(s, m, i, r, wall); - } - } - scroll_bar(s, ui.scroll as i32, (N - ROWS) as i32, ROWS as i32, BLACK_RGB); - } - let x = C - PILL_W / 2; - rrect(s, x, PILL_Y, PILL_W, PILL_H, PILL_H / 2, Rgb::from565(ROW_BG), BLACK_RGB); - let (t, c) = if m.busy() { ("Updating", GREY) } else { ("Refresh", WHITE) }; - font::centre(s, C, PILL_Y + (PILL_H - HEIGHT) / 2 + 1, t, c); -} - -/// What a tap at (x, y) on the menu hit. -pub fn menu_hit(m: &Model, ui: &Ui, _x: i32, y: i32) -> Hit { - if y >= PILL_Y - 4 { - return Hit::Refresh; - } - if help(m).is_some() || y < LIST_TOP || y >= LIST_TOP + ROWS as i32 * ROW_H { - return Hit::Nothing; - } - let i = ui.scroll + ((y - LIST_TOP) / ROW_H) as usize; - if i < N { Hit::Pin(i) } else { Hit::Nothing } -} - -/// The instruments under the pinned one on the page. -pub fn others(m: &Model) -> [usize; OTHERS] { - let mut out = [0; OTHERS]; - let mut it = PAGE_ORDER.iter().copied().filter(|&i| i != m.pinned); - for o in out.iter_mut() { - *o = it.next().unwrap_or(0); - } - out -} - -/// Dot-matrix figures, set tighter than [`cmf_wp2_ui::text::dots`]: a digit takes its 8 columns (7 lit, 1 gap), a -/// comma or a point only its lit columns and a gap, so "7,344.73" doesn't fall apart. The x offset of the glyph's -/// cell from the pen and the advance, in pitches. -fn dot_cell(ch: char) -> (i32, i32) { - match ch { - ',' => (-1, 4), - '.' => (-2, 3), - _ => (0, 8), - } -} - -/// Width of `t` in dot-matrix figures at `pitch`, without the gap after the last one. -pub fn dot_width(t: &str, pitch: i32) -> i32 { - let n: i32 = t.chars().map(|ch| dot_cell(ch).1).sum(); - (n - 1).max(0) * pitch -} - -/// `t` in dot-matrix figures from `x`. -fn dot_text(s: &mut impl Surface, x: i32, y: i32, t: &str, pitch: i32, dot: i32, c: u16) { - let mut x = x; - let mut b = [0u8; 4]; - for ch in t.chars() { - let (off, adv) = dot_cell(ch); - cmf_wp2_ui::text::dots(s, x + off * pitch, y, ch.encode_utf8(&mut b), pitch, dot, c); - x += adv * pitch; - } -} - -/// The dot of a pitch: about two thirds of it, a clear gap between dots as on the stock charging screen's clock. -pub fn dot_size(pitch: i32) -> i32 { - ((2 * pitch + 2) / 3).min(pitch - 1).max(1) -} - -/// The largest pitch at which `t` fits the circle from `y`, and how much of `t` shows at it (cut only below the -/// smallest pitch). -pub fn fit_pitch(t: &str, y: i32) -> (i32, &str) { - let room = |p: i32| { - let (x0, x1) = chord(y, y + 8 * p, 10); - x1 - x0 - }; - for p in PITCHES { - if dot_width(t, p) <= room(p) { - return (p, t); - } - } - let p = PITCHES[PITCHES.len() - 1]; - let mut end = t.len(); - while end > 0 && (!t.is_char_boundary(end) || dot_width(&t[..end], p) > room(p)) { - end -= 1; - } - (p, &t[..end]) -} - -/// The page next to the watch face. -pub fn page(s: &mut impl Surface, m: &Model, wall: i32) { - clear(s); - let p = m.pinned; - line(s, NAME_Y, INSTRUMENTS[p].name, ACCENT); - let price = m.price_text(p); - let (pitch, shown) = fit_pitch(price.as_str(), PRICE_Y); - // the figures are 7 rows high: centred in the band of the largest pitch - let y = PRICE_Y + (PITCHES[0] - pitch) * 7 / 2; - dot_text(s, C - dot_width(shown, pitch) / 2, y, shown, pitch, dot_size(pitch), WHITE); - if m.quotes[p].and_then(|q| q.change).is_some() { - let right = C + change_width(m, p, true) / 2; - change_at(s, m, p, right, CHANGE_Y, true); - } - if let Some(h) = help(m) { - lines(s, OTHERS_Y + 10, h); - } else { - for (r, &i) in others(m).iter().enumerate() { - page_item(s, m, i, r); - } - } - let (st, c) = status(m, wall); - line(s, PAGE_STATUS_Y, st.as_str(), c); -} - -/// The text box of the others on the page: as wide as the narrowest row, so the columns line up. -pub fn page_text() -> (i32, i32) { - chord(OTHERS_Y, OTHERS_Y + OTHERS as i32 * OTHER_H, OTHER_MARGIN) -} - -/// The room the change column keeps: prices end at one x, changes at another. -fn change_column() -> i32 { - width("+0.00%") -} - -/// One of the others on the page: name, price if it fits (right-aligned), change (right-aligned). -fn page_item(s: &mut impl Surface, m: &Model, i: usize, r: usize) { - let y = OTHERS_Y + r as i32 * OTHER_H; - let (x0, x1) = page_text(); - let ty = y + (OTHER_H - HEIGHT) / 2 + 1; - let (price, ch) = (m.price_text(i), m.change_text(i)); - let ins = &INSTRUMENTS[i]; - let cw = width(ch.as_str()).max(change_column()); - let pw = width(price.as_str()); - let fits = |name: &str| width(name) + GAP + pw + GAP + cw <= x1 - x0; - let (name, with_price) = if fits(ins.name) { - (ins.name, true) - } else if fits(ins.short) { - (ins.short, true) - } else { - (ins.name, m.quotes[i].is_none()) - }; - change_at(s, m, i, x1, ty, false); - let mut right = x1 - cw - GAP; - if with_price { - let px = right - pw; - font::draw(s, px, ty, price.as_str(), GREY); - right = px - GAP; - } - font::fitted(s, x0, ty, name, right - x0, WHITE); -} - -/// What a tap at (x, y) on the page hit: one of the others pins it, anything else refreshes. -pub fn page_hit(m: &Model, _x: i32, y: i32) -> Hit { - let r = (y - OTHERS_Y).div_euclid(OTHER_H); - if help(m).is_none() && (0..OTHERS as i32).contains(&r) { - return Hit::Pin(others(m)[r as usize]); - } - Hit::Refresh -} - -#[cfg(test)] -#[path = "screen_tests.rs"] -mod tests; diff --git a/apps/markets/src/screen_tests.rs b/apps/markets/src/screen_tests.rs deleted file mode 100644 index 5da7aed..0000000 --- a/apps/markets/src/screen_tests.rs +++ /dev/null @@ -1,237 +0,0 @@ -extern crate std; - -use super::*; -use crate::model::{BTC, Quote}; -use cmf_wp2_ui::Fb; -use std::vec; - -const WALL: i32 = 1440 * 20_000 + 14 * 60 + 5; - -fn full(price: i64, change: i32) -> Model { - let mut m = Model::new(); - for q in m.quotes.iter_mut() { - *q = Some(Quote { price, change: Some(change), at: WALL }); - } - m.status = [Status::Ok; 2]; - m -} - -fn real() -> Model { - let mut m = full(0, 0); - let qs: [(i64, i32); N] = [ - (73_447_300, 65), - (244_792_070, 145), - (508_237_300, 10), - (253_736_800, -27), - (106_951_600, -3), - (600_707_500, 232), - (591_050_000, -27), - (16_560_800, 138), - (717_800, 0), - ]; - for (q, (p, c)) in m.quotes.iter_mut().zip(qs) { - *q = Some(Quote { price: p, change: Some(c), at: WALL }); - } - m -} - -/// Every lit pixel lies 2 px inside the round panel. -fn inside(draw: impl Fn(&mut Fb)) { - let mut px = vec![0u16; (SIZE * SIZE) as usize]; - let mut fb = Fb::new(&mut px); - draw(&mut fb); - let r = C - 2; - let mut lit = 0; - for y in 0..SIZE { - for x in 0..SIZE { - if fb.at(x, y) != BLACK { - lit += 1; - let (dx, dy) = (2 * x + 1 - 2 * C, 2 * y + 1 - 2 * C); - assert!(dx * dx + dy * dy <= 4 * r * r, "lit at ({x}, {y})"); - } - } - } - assert!(lit > 0); -} - -fn states() -> std::vec::Vec { - let mut v = vec![Model::new(), real(), full(i64::MAX, i32::MIN), full(1, 99_999), full(999_999_999_999, -99_999)]; - let mut ask = Model::new(); - ask.status[0] = Status::Ask; - v.push(ask); - let mut denied = Model::new(); - denied.status = [Status::Denied, Status::Failed]; - v.push(denied); - let mut stale = real(); - stale.quotes[2].as_mut().unwrap().at = WALL - 600; - stale.quotes[3] = None; - v.push(stale); - v -} - -#[test] -fn menu_stays_inside_the_circle() { - for m in states() { - for scroll in 0..=N - ROWS { - let ui = Ui { scroll }; - inside(|fb| menu(fb, &m, &ui, WALL + 1)); - inside(|fb| menu(fb, &m, &ui, WALL + 1000)); - } - } -} - -#[test] -fn page_stays_inside_the_circle() { - for mut m in states() { - for p in 0..N { - m.pinned = p; - inside(|fb| page(fb, &m, WALL + 1)); - } - } -} - -#[test] -fn every_row_shows_its_name_price_and_change_in_full() { - // with the real prices nothing is cut: name, gap, price on line 1; arrow and change on line 2 - let m = real(); - for scroll in 0..=N - ROWS { - for r in 0..ROWS { - let i = scroll + r; - let (l, rt) = menu_text(r); - let need = width(INSTRUMENTS[i].name) + GAP + width(m.price_text(i).as_str()); - assert!(need <= rt - l, "row {r} item {i}: {need} > {}", rt - l); - assert!(change_width(&m, i, true) <= rt - l); - } - } - // the page's others: full name, price and change on one line - let (x0, x1) = page_text(); - for i in 0..N { - let need = width(INSTRUMENTS[i].name) + GAP + width(m.price_text(i).as_str()) + GAP + change_column(); - assert!(need <= x1 - x0, "item {i}: {need} > {}", x1 - x0); - } -} - -/// The columns of lit pixels in rows y0..y1, as (first, last). -fn lit_x(fb: &Fb, y0: i32, y1: i32, x0: i32, x1: i32, c: u16) -> Option<(i32, i32)> { - let xs = (x0..x1).filter(|&x| (y0..y1).any(|y| fb.at(x, y) == c)); - let v: std::vec::Vec = xs.collect(); - Some((*v.first()?, *v.last()?)) -} - -#[test] -fn prices_and_changes_are_right_aligned() { - let m = real(); - let ui = Ui::new(); - let mut px = vec![0u16; (SIZE * SIZE) as usize]; - let mut fb = Fb::new(&mut px); - menu(&mut fb, &m, &ui, WALL + 1); - let mut ends = std::vec::Vec::new(); - for r in 0..ROWS { - let (y, _, x1) = menu_row(r); - let (l, _) = menu_text(r); - let mid = (l + x1) / 2; - // the price on line 1 (white, right half) and the change on line 2 (green or red) - let price = lit_x(&fb, y + 6, y + 28, mid, x1, WHITE).unwrap(); - let c = colour(m.quotes[r].unwrap().change); - let change = lit_x(&fb, y + 30, y + 54, mid, x1, c).unwrap(); - ends.push((price.1, change.1)); - } - for w in ends.windows(2) { - assert!((w[0].0 - w[1].0).abs() <= 2 && (w[0].1 - w[1].1).abs() <= 2, "{ends:?}"); - } -} - -#[test] -fn title_and_page_name_clear_the_status_bar() { - // the loader's clock sits at the top centre, about 72 px wide from y 4: nothing lit above y 30 near it - for m in states() { - let mut px = vec![0u16; (SIZE * SIZE) as usize]; - let mut fb = Fb::new(&mut px); - menu(&mut fb, &m, &Ui::new(), WALL + 1); - assert!(lit_x(&fb, 0, 32, C - 60, C + 60, ACCENT).is_none()); - let mut px = vec![0u16; (SIZE * SIZE) as usize]; - let mut fb = Fb::new(&mut px); - page(&mut fb, &m, WALL + 1); - assert!((0..32).all(|y| (0..SIZE).all(|x| fb.at(x, y) == BLACK))); - } -} - -#[test] -fn menu_taps() { - let mut m = real(); - let mut ui = Ui::new(); - for r in 0..ROWS { - let (y, _, _) = menu_row(r); - assert_eq!(menu_hit(&m, &ui, C, y + ROW_H / 2), Hit::Pin(r)); - } - assert!(ui.crown(1)); - for _ in 0..10 { - ui.crown(5); - } - assert_eq!(ui.scroll, N - ROWS); - assert!(!ui.crown(1)); - assert_eq!(menu_hit(&m, &ui, C, LIST_TOP + 1), Hit::Pin(N - ROWS)); - assert_eq!(menu_hit(&m, &ui, C, PILL_Y + 10), Hit::Refresh); - assert_eq!(menu_hit(&m, &ui, C, 20), Hit::Nothing); - assert!(ui.crown(-1)); - // the help text has no rows - m.quotes = [None; N]; - m.status[0] = Status::Ask; - assert_eq!(menu_hit(&m, &ui, C, LIST_TOP + 10), Hit::Nothing); -} - -#[test] -fn page_taps_pin_the_others() { - let mut m = real(); - m.pinned = BTC; - let o = others(&m); - assert_eq!(o, [0, 1, 7, 2]); - assert!(!o.contains(&BTC)); - for (r, &i) in o.iter().enumerate() { - assert_eq!(page_hit(&m, C, OTHERS_Y + r as i32 * OTHER_H + 5), Hit::Pin(i)); - } - assert_eq!(page_hit(&m, C, PRICE_Y + 10), Hit::Refresh); - assert_eq!(page_hit(&m, C, OTHERS_Y - 1), Hit::Refresh); - m.pinned = 0; - assert_eq!(others(&m), [6, 1, 7, 2]); -} - -#[test] -fn status_lines() { - let st = |m: &Model, w: i32| status(m, w).0; - let mut m = Model::new(); - assert_eq!(st(&m, WALL).as_str(), "No prices yet"); - m.refresh(0); - m.poll(0); - assert_eq!(st(&m, WALL).as_str(), "Updating..."); - m.poll(companion_rpc::RETRY_MS); - assert_eq!(st(&m, WALL).as_str(), "No phone"); - let mut m = real(); - assert_eq!(st(&m, WALL + 3).as_str(), "Updated 14:05"); - assert_eq!(status(&m, WALL + 31), (Line::of("Stale 14:05"), ACCENT)); - m.status[1] = Status::Failed; - assert_eq!(st(&m, WALL).as_str(), "Can't load 14:05"); - m.status[1] = Status::Denied; - assert_eq!(st(&m, WALL).as_str(), "Off in Companion"); - m.status[0] = Status::Ask; - assert_eq!(st(&m, WALL).as_str(), "Allow on phone"); - // the clock key moves when a quote goes stale - let m = real(); - assert_eq!(clock_key(&m, WALL + 5), clock_key(&m, WALL + 6)); - assert_ne!(clock_key(&m, WALL + 5), clock_key(&m, WALL + 31)); -} - -#[test] -fn page_price_pitch() { - assert_eq!(fit_pitch("7,344.73", PRICE_Y), (6, "7,344.73")); - assert_eq!(fit_pitch("59,105", PRICE_Y), (6, "59,105")); - assert_eq!(fit_pitch("60,070.75", PRICE_Y), (5, "60,070.75")); - let (p, shown) = fit_pitch("92,233,720,368,547,758.07", PRICE_Y); - assert_eq!(p, 2); - assert!(shown.len() < 26 && "92,233,720,368,547,758.07".starts_with(shown)); - // a comma and a point take less room than a digit; gaps stay between the dots - assert_eq!(dot_width("1,2.3", 1), 8 + 4 + 8 + 3 + 8 - 1); - for p in PITCHES { - assert!((1..p).contains(&dot_size(p)), "{p}"); - } -} diff --git a/apps/markets/store.md b/apps/markets/store.md deleted file mode 100644 index 7f90421..0000000 --- a/apps/markets/store.md +++ /dev/null @@ -1,23 +0,0 @@ -Stock indices and crypto prices on the wrist: the S&P 500, Nasdaq, Dow Jones, DAX, FTSE 100 and Nikkei 225, and -Bitcoin, Ethereum and Solana in US dollars. Each row has the price and the change since the last close (24 hours for -the coins), green up and red down. Turn the crown to scroll, tap **Refresh** to ask again now. - -Tap a row to pin it. Long-press **Markets** in Apps and choose **Add page** for the pinned one in big type with four -others under it, one swipe from the watch face (tap one of them to pin it instead), or **Add widget** for a card with -the pinned one's price and change and Bitcoin's (the S&P 500's when Bitcoin is pinned). - -The watch asks the phone when you open the app or the page and every 5 minutes while it's shown, and keeps the last -prices, so it opens at once without the phone and shows when they're from ("Stale" after half an hour). The prices -don't refresh while the app is closed: the widget card shows the last ones the app or its page got. Index prices come -from Yahoo Finance and can be delayed by the exchange; coin prices come from CoinGecko. - -The first time, the watch says "Allow on phone": open FMC Companion, Apps, Markets, and allow both web sites it asks -for. The watch only fetches public prices; nothing about you goes over Bluetooth. - -## Requirements - -- A phone with **FMC Companion** (iOS or Android, [github.com/fmctools/companion](https://github.com/fmctools/companion)), - paired with the watch. In its Apps tab, allow Markets to reach `http:query1.finance.yahoo.com` (indices) and - `http:api.coingecko.com` (coins). -- The [patched firmware](/firmware) with the channel key (2026-11-13 or later) and the [App Loader](/firmware) - (2026-11-13 or later; 2026-11-15 or later for the page and the widget). diff --git a/apps/markets/store.toml b/apps/markets/store.toml deleted file mode 100644 index 29f0ffd..0000000 --- a/apps/markets/store.toml +++ /dev/null @@ -1,6 +0,0 @@ -# The app's listing in the FMC store (README.md, "store.toml"). The page's body is store.md. -name = "Markets" -summary = "Stock indices and crypto prices from your phone, with a page next to the watch face and a widget card" -version = "0.1.0" -author = "Ziyad Eslam" -screenshots = ["shots/list.png", "shots/page.png", "shots/allow.png"] diff --git a/apps/metrolist/ANDROID_COMPANION.md b/apps/metrolist/ANDROID_COMPANION.md deleted file mode 100644 index 6a62754..0000000 --- a/apps/metrolist/ANDROID_COMPANION.md +++ /dev/null @@ -1,212 +0,0 @@ -# Metrolist watch link — companion contract - -This is the implementation contract for the Metrolist fork that pairs with `apps/metrolist`. The phone is the only -YouTube Music client: it owns the account and the sign-in, the downloads, the library and the player. The watch names -a node to browse and an item to play, and shows what the phone reports. The watch never stores an account token, -cookie, track URL or file. - -The fork is [MetrolistGroup/Metrolist](https://github.com/MetrolistGroup/Metrolist) plus a **Settings → Watch** switch -and the module described here. Nothing else about the app changes. Metrolist is Kotlin Multiplatform: the BLE link is -Android-only, so it lives in `androidApp`; the node mapping is plain data and can live in `shared` if desktop and iOS -want it later. - -## Connection model - -1. The user pairs the watch once in Nothing X. The fork does not run a second pairing flow and must not perform the - App Loader's bind handshake. -2. Resolve the already bonded watch and open the stub's channel with the pairing secret `K`, exactly as - `.sdk/wp2-apps/docs/abi-1.4.md` ("Writing a host") describes: subscribe to `FFF1`, `77D4FF02-…` and - `02F00000-…-FFE2`, write `AT GETSECRET` to the shell `77D4FF01-…`, then seal every frame with `K`. No bind, no - "Paired" popup, Nothing X keeps working. -3. Treat `K` as a password: memory only, cleared when the GATT session closes, never logged or exported. -4. Register with one `PING` (`0x90A7`). App messages then arrive as `0xB0A6` events without polling; `send` writes - go out as `MSG` (`0x90A5`) with slot `0xFF` (whatever app runs). An `EVENT` plaintext is **not** the app message: - it is `seq: u8 | slot: u8 | data` (`abi-1.1.md`, "Data channel"), so strip the first two bytes before parsing `M1`. -5. Reconnect with backoff after BLE errors; Android needs a connected-device foreground service so the link survives - the app being backgrounded. Re-send the full state after every reconnect. -6. If the watch never answers, show a compatibility note (patched firmware with the channel key, App Loader of - 2026-11-13 or later) instead of starting a bind. - -`connectGatt` next to Nothing X is still untested on Android (AGENTS.md, "Apps that talk to a phone"). Exercise it on -each supported vendor/version before calling the feature shipped. - -## Protocol (`M1`) - -ASCII `M1`, one kind byte, then fixed fields. Every message is at most 128 bytes; the watch's inbox holds four, so the -phone sends one burst per answer and waits for the watch's next request. Integers are unsigned bytes unless noted. - -### Watch → phone - -| Frame | Meaning | -|---|---| -| `M1?` | hello: the app started, resumed, or lost the phone. Answer with `S`, then `C` (and the open node's list if the watch asks) | -| `M1b node` | browse `node`; `0` is the root categories | -| `M1p node index` | play item `index` of `node`: queue the node's songs from that item and start it | -| `M1t cmd` | transport: `0` play/pause, `1` next, `2` previous | -| `M1v level` | volume `0..=100` | -| `M1q` | the watch's queue screen opened (or came back to): answer with `Q` and `J` | -| `M1j index` | play queue entry `index` of the queue the phone has; the rest of the queue stays | -| `M1f len query` | search the library: answer with the best matches as list frames for `SEARCH_NODE` (`250`) | - -The watch retries `?` every 0.6 s, doubling to 3 s, until the phone answers. A list request that is not answered in -3 s is sent again. Duplicate `p`/`t` frames are idempotent. - -### Phone → watch - -| Frame | Meaning | -|---|---| -| `M1S flags pos vol tlen title alen artist colour:u16le` | now playing. `flags`: bit 0 playing, bit 1 the phone's liked state (the watch ignores it), bit 2 a track is there. `pos` 0..=100 percent. `title` ≤ 34 bytes, `artist` ≤ 20. `colour` is the artwork's dominant RGB565, for the player's glow and ring; `0` when unknown | -| `M1C n (id kind nlen name colour:u16le)*` | the root categories, in order. `kind` 0 opens a folder, 1 is a song list. `name` ≤ 20 bytes, `colour` RGB565. `n` ≤ 6 | -| `M1B node kind total tlen title` | a list starts: `total` items follow, `title` ≤ 20 bytes | -| `M1I node start n (tlen title alen artist colour:u16le id)*` | items `start..start+n` of that list; `n` ≤ 20. A folder item's `id` is the node to browse next; a song's is `0xFF`. `colour` is the item's (or its artwork's average) RGB565 for the watch's row | -| `M1E node total` | the list is complete | -| `M1X node code` | no list: `0` empty, `1` error, `2` not ready (still loading, signed out) | -| `M1B` / `M1I` / `M1E` for node `250` | a search's results, in the same list frames as a node; the watch draws them and `M1p 250 index` plays from there | -| `M1Q total current` | the queue starts: `total` entries follow (≤ 20), `current` is the playing position | -| `M1J start n (tlen title alen artist colour:u16le)*` | queue entries `start..start+n`, same text caps as `I`, no node id; the queue is ready at `total` | -| `M1H` | heartbeat, about every 10 s; the watch shows "Waiting for phone" after 25 s of silence | - -`node` ids are the phone's: stable while the process lives, `1..=200`, `0` = root. A list frame for a node the watch -has already left is dropped by the watch; the phone may send it anyway. - -The watch keeps the first 20 items of a list. Two items per `I` frame keeps a frame under 128 bytes with the title and -artist caps above; send `start` + `n` so a lost frame can be resent. - -The queue screen is the same: `Q` names the length and the playing position, `J` carries the entries two at a time, -and the watch fills the row at `current`. Answer `M1q` with the queue the player really has (`queueSongs` and -`queueState.currentIndex`), and answer `M1j` by moving the existing queue to that position, never by replacing it. -After a confirmed `M1j` send `Q`/`J` again so the filled row follows the new current entry. - -## The root categories - -Answer `M1b 0` with `M1C` built from the same data the app's own home screen uses, in this order and with these ids: - -| id | name | kind | source | -|---|---|---|---| -| 1 | Quick picks | songs | the home screen's quick-picks shelf | -| 2 | Listen again | songs | the home screen's "Listen again" shelf | -| 3 | Downloads | folder | the local downloads database | -| 4 | Library | folder | the user's library | -| 5 | Explore | folder | the app's explore/moods entries | - -Names are the app's localized strings, clipped to 20 UTF-8 bytes on a char boundary. Colours come from each shelf's -artwork (the app's dominant colour) so the watch's rows match the app. - -## Search - -The watch's keyboard sends the finished query as one `M1f len query` frame (at most 40 UTF-8 bytes, no NUL). The -phone runs its own search (`YouTubeRepository.search(query)`, which falls back to the local library when offline), keeps -the first five `SongItem`s and streams them as an ordinary list under node `250`: `M1B 250 1 5 "Results"`, then two `I` -frames for node `250`, then `M1E 250 5`. An empty result set is still `B`/`E` with `total 0`; a failed search answers -`M1X 250 1` ("could not load") and a still-loading or signed-out app `M1X 250 2`. - -Node `250` is reserved for this and is never part of the browse tree. `M1p 250 index` plays that match and queues the -rest of the five behind it, in the order the watch showed them; the ack and the queue screen are the node's. - -## Quick picks and album shelves - -Quick picks and Listen again are the API shelf and the local history together, matched on the `FEmusic_quickpicks` / -`FEmusic_listen_again` browse id or on the shelf's title and merged by song id. The shelf is not always on the first page -of the home feed, so the link walks at most two continuation pages while it is missing; when the API has nothing (signed -out, offline) the local side fills in: `dao.quickPicks()`, then the most played songs of all time, then -`dao.forgottenFavorites()`, which is the same pool the app's own classic Quick picks samples. Listen again is the last -month of `mostPlayedSongs`. Quick picks is always a root category, even with no rows at all, so the option does not vanish -from the watch's menu; its node answers `M1X 1 2` when the phone has neither home data nor history. Each rebuild logs one -`WatchLink` line with the feed's section count and the shelf's row count, and dumps the feed's titles when the shelf is -empty. - -A home shelf whose items are albums becomes a folder of albums: each row carries a node id, and that node answers with -the album's own tracks in album order (`YouTubeRepository.getAlbum(browseId)` → `AlbumPage.songs`). `M1p` on that node -plays the chosen song and queues the rest of the album behind it under the album's title — the same shape as a search's -results. Not every item type has a watch screen: playlists, artists and podcasts are skipped for now. - -The root `C` frame carries up to eight categories. Its names share the space left after the fixed fields in order, each -taking what it needs and leaving one byte for every name after it, so eight shelves keep their full titles. - -Every title and artist leaves this side through `WatchProtocol.clip`, which first reduces the text to printable ASCII -(`plain`): typographic quotes and dashes become ASCII, accents are folded away, emoji and CJK are dropped, spaces are -collapsed. The watch's stock fonts have no glyph outside ASCII, and a name cut inside a UTF-8 character was drawn as -nothing, which is what made some results look empty or wrong. - -## Where it hooks in Metrolist - -The pieces this needs already exist; the link is mostly an adapter: - -| Need | Metrolist side | -|---|---| -| Home shelves | `HomeViewModel` and `YouTubeRepository.getHomePageData` → `HomePageData.sections` (`HomeSection.title`, `.items`, `.browseId`, `.params`; `shared/src/commonMain/kotlin/com/metrolist/shared/model/Models.kt`). Quick picks is also built locally in `HomeViewModel` | -| Downloads | `DownloadsScreen` over the `MusicDatabase` DAOs (`shared/.../db/daos/DatabaseDao.kt`): downloaded songs, albums, playlists | -| Library | `LibraryScreen` and the `LibraryFilter` enum (`SONGS`, `ARTISTS`, `ALBUMS`, `PLAYLISTS`, `PODCASTS`, `LIBRARY`) | -| Explore | `BrowseScreen`'s mood/genre entries (`BrowsePageData`) | -| Queue and play | `PlayerConnection.playQueueFromRemote(songs, startIndex, title)` (`androidApp/.../playback/PlayerConnection.kt`), which calls `MusicService.playQueueFromRemote` | -| Transport | `PlayerConnection.skipToNextFromRemote()`, `skipToPreviousFromRemote()`, `seekToFromRemote(ms)`, `currentSong: StateFlow`, `isPlaying: StateFlow` | -| Like | the app's own library add/remove on the current `SongItem` (`libraryAddToken` / `libraryRemoveToken`) | -| Settings row | `SettingsScreen` (`androidApp/.../ui/screens/SettingsScreen.kt`), beside the existing device-connect entry | -| Row colours | `SongItem.thumbnail`; compute the dominant RGB565 once per item (weighted by saturation, so a white sleeve background does not win) and cache it | - -`shared/.../deviceconnect/` is the app's existing peer-to-peer device link. It is LAN/HTTP with its own pairing, not -BLE: do not reuse its transport. Its playback bridge (`DeviceConnectPlayback`, `DeviceConnectRemote`) is the shape to -copy, and its settings sheet (`DeviceConnectSheet`) is the UI precedent for the Watch row. - -The watch link must not touch `LoginScreen`/`YouTubeSession`; the account flow stays exactly as it is. - -## Nodes - -A node is either a **song list** (`kind 1`) or a **folder** (`kind 0`). - -- A song list answers `M1B`/`M1I`/`M1E` with up to 20 songs. `M1p node index` queues that node's songs from `index`: - the same order the watch was shown, so `index` means the same row on both sides. Build a fresh queue and start it - through the app's normal player controller; do not shuffle unless the node itself is a shuffle. -- An album node is a song list with `fromAlbum`: the watch shows its tracks, and a tap queues the album from that row. -- A folder answers with folder items (each with a `node` id) and/or song items mixed in the same list, in the app's - order. Tapping a folder item makes the watch send `M1b `. -- Depth is the watch's business (it keeps four levels); the phone just answers the node it was asked for. - -Suggested folder trees (the app's own sections, so the watch and the phone agree): - -- **Downloads** (`kind 0`): Songs, Albums, Playlists. Each is a song list; Albums and Playlists may also be folders - of their tracks, in which case give the album/playlist item a node id. -- **Library** (`kind 0`): Songs, Albums, Playlists, Artists. Artists is a folder of artist nodes; each artist node is a - song list (or an album folder if the app has one). -- **Explore** (`kind 0`): the app's mood/genre entries; each is a song list. - -An empty node answers `M1X node 0`. A signed-out or still-loading node answers `M1X node 2` so the watch can say -"Metrolist is not ready" instead of "Nothing here yet". - -## Sign-in - -Signing in to Google stays entirely in the fork's own settings (the existing Metrolist/InnerTube account flow: the -WebView sign-in and cookie import). The watch has no login surface and receives no credential, cookie or token; a -signed-out app answers `M1X node 2`. When the account changes, resend `S` and the root `C`. - -## Playback and state - -- `M1S` is authoritative. Send it on `?`, on every change of track, play state, volume or position bucket, and - at least every 10 s (`M1H` alongside). `pos` is a whole percent; do not stream every second of progress. Drive it - from `PlayerConnection.currentSong` and `isPlaying`, not from a timer that re-reads the UI. -- `M1t 0` toggles the app's current player; `1`/`2` map to `skipToNextFromRemote` / - `skipToPreviousFromRemote`. -- `M1v` sets the media volume, not the watch's. Clamp to the phone's volume steps and report the result in `S`. -- Commands are serialized; a failure still answers with a fresh `M1S` so the watch never keeps an optimistic state. -- The app keeps playing when the watch app closes; the watch is only a remote. - -## Settings → Watch - -One switch ("Connect to watch"), the connection state (Bluetooth, channel, last message), and a **Test connection** -action. When off, the fork must not hold the GATT link. Never show `K`, raw frames or track URLs in logs or -diagnostics. - -## Privacy - -Only counts, names the user already sees, colours and play state cross the link; anyone in BLE range can read the -channel. Never send the account email, cookies, tokens, file paths or download URLs. Keep `K` in memory. - -## Release gates - -- Firmware: channel key `K` needs the patched stub and a loader from 2026-11-13 or later; `own_back`, the LVGL app and - its pages need the loader the app names in `store.md`: **2026-11-27**, `loader-2026-11-27-2018e1a.wp2app`, built from - cmf-watch-sdk `2018e1a` and still listed under Experimental in FMC. -- Android: Nothing X + the fork at the same time on each supported vendor/version (no new pairing popup, both keep - notifications, the channel survives screen-off and a service restart). -- Watch: `make test APP=metrolist`, `make build APP=metrolist`, `make check`, then the emulator or a real watch - (owner's yes) for the screens, the crown volume and Back. diff --git a/apps/metrolist/Cargo.toml b/apps/metrolist/Cargo.toml deleted file mode 100644 index 3de16a5..0000000 --- a/apps/metrolist/Cargo.toml +++ /dev/null @@ -1,15 +0,0 @@ -[package] -name = "metrolist" -edition.workspace = true -license.workspace = true -version.workspace = true - -[dependencies] -cmf-wp2-app.workspace = true - -[dev-dependencies] -wp2-core.workspace = true - -[[bin]] -name = "metrolist" -bench = false diff --git a/apps/metrolist/bitmaps/README.md b/apps/metrolist/bitmaps/README.md deleted file mode 100644 index 6d551f9..0000000 --- a/apps/metrolist/bitmaps/README.md +++ /dev/null @@ -1,9 +0,0 @@ -# Icons - -The control glyphs are Google's [Material Icons](https://github.com/google/material-design-icons) — `play_arrow`, -`pause`, `skip_previous`, `skip_next`, `volume_up`, `volume_down`, `queue_music`, `arrow_back` — licensed Apache-2.0. -Each was rendered from the **rounded** theme's 24 px SVG (`src///materialiconsround/24px.svg`, the -`materialiconsround` folder, not `materialicons`) to a PNG cropped to its ink, at the size the watch draws it. - -`scripts/store build` (and `python -m wp2apps.bitmaps apps/metrolist`) turns them into `src/bitmaps.gen.rs`, which -the crate includes with `cmf_wp2_app::bitmaps!()`; see the SDK's `docs/bitmap-assets.md`. diff --git a/apps/metrolist/bitmaps/arrow-back.png b/apps/metrolist/bitmaps/arrow-back.png deleted file mode 100644 index a95c2b7..0000000 Binary files a/apps/metrolist/bitmaps/arrow-back.png and /dev/null differ diff --git a/apps/metrolist/bitmaps/pause.png b/apps/metrolist/bitmaps/pause.png deleted file mode 100644 index ec8f1a0..0000000 Binary files a/apps/metrolist/bitmaps/pause.png and /dev/null differ diff --git a/apps/metrolist/bitmaps/play-arrow.png b/apps/metrolist/bitmaps/play-arrow.png deleted file mode 100644 index 549b9b7..0000000 Binary files a/apps/metrolist/bitmaps/play-arrow.png and /dev/null differ diff --git a/apps/metrolist/bitmaps/queue-music.png b/apps/metrolist/bitmaps/queue-music.png deleted file mode 100644 index b15b806..0000000 Binary files a/apps/metrolist/bitmaps/queue-music.png and /dev/null differ diff --git a/apps/metrolist/bitmaps/skip-next.png b/apps/metrolist/bitmaps/skip-next.png deleted file mode 100644 index 9e94b25..0000000 Binary files a/apps/metrolist/bitmaps/skip-next.png and /dev/null differ diff --git a/apps/metrolist/bitmaps/skip-previous.png b/apps/metrolist/bitmaps/skip-previous.png deleted file mode 100644 index a5844b5..0000000 Binary files a/apps/metrolist/bitmaps/skip-previous.png and /dev/null differ diff --git a/apps/metrolist/bitmaps/volume-down.png b/apps/metrolist/bitmaps/volume-down.png deleted file mode 100644 index 8608317..0000000 Binary files a/apps/metrolist/bitmaps/volume-down.png and /dev/null differ diff --git a/apps/metrolist/bitmaps/volume-up.png b/apps/metrolist/bitmaps/volume-up.png deleted file mode 100644 index a42134f..0000000 Binary files a/apps/metrolist/bitmaps/volume-up.png and /dev/null differ diff --git a/apps/metrolist/icon.svg b/apps/metrolist/icon.svg deleted file mode 100644 index 4d59831..0000000 --- a/apps/metrolist/icon.svg +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - diff --git a/apps/metrolist/shots/home.jpg b/apps/metrolist/shots/home.jpg deleted file mode 100644 index 4119523..0000000 Binary files a/apps/metrolist/shots/home.jpg and /dev/null differ diff --git a/apps/metrolist/shots/player.jpg b/apps/metrolist/shots/player.jpg deleted file mode 100644 index 68da921..0000000 Binary files a/apps/metrolist/shots/player.jpg and /dev/null differ diff --git a/apps/metrolist/shots/queue.jpg b/apps/metrolist/shots/queue.jpg deleted file mode 100644 index e931783..0000000 Binary files a/apps/metrolist/shots/queue.jpg and /dev/null differ diff --git a/apps/metrolist/src/bitmaps.gen.rs b/apps/metrolist/src/bitmaps.gen.rs deleted file mode 100644 index 231060d..0000000 --- a/apps/metrolist/src/bitmaps.gen.rs +++ /dev/null @@ -1,856 +0,0 @@ -// Generated by python -m wp2apps.bitmaps from bitmaps/*.png; do not edit. -pub mod bitmaps { - use cmf_wp2_app::Bitmap; - - /// arrow-back.png: 29x28 RGB565, 1624 bytes in the package image. - pub static ARROW_BACK: Bitmap = Bitmap { w: 29, h: 28, px: &[ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2145, 40179, 48631, 12678, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 4226, 52857, 65535, 65535, 57083, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 4226, 52857, 65535, 65535, 65535, 57083, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 4226, 54906, 65535, 65535, 65535, 63390, 12678, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2145, 52857, 65535, 65535, - 65535, 61309, 10629, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 4226, 52857, 65535, 65535, 65535, 61341, 12678, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 4226, 52857, 65535, 65535, 65535, 61309, 12678, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 4226, 54906, 65535, 65535, 65535, 63390, 12678, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2145, 52857, 65535, 65535, - 65535, 61309, 10629, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 4226, 52857, 65535, 65535, 65535, 61341, 12678, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 4226, 52857, 65535, 65535, 65535, 61309, 12678, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 4226, 54906, 65535, 65535, 65535, 63390, 12678, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2145, 52857, 65535, 65535, - 65535, 65535, 57083, 48631, 48631, 48631, 48631, 48631, 48631, 48631, 48631, 48631, 48631, 48631, 48631, 48631, - 48631, 48631, 48631, 48631, 48631, 48631, 48631, 44405, 2145, 38034, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 38034, 35953, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 35953, 4226, 52857, 65535, 65535, 65535, 65535, 59164, 48631, 50712, 48631, 50712, 48631, 50712, - 48631, 50712, 48631, 50712, 48631, 50712, 48631, 50712, 48631, 50712, 48631, 50712, 48631, 50712, 44405, 4226, - 0, 4226, 52857, 65535, 65535, 65535, 61309, 12678, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4226, - 52857, 65535, 65535, 65535, 61309, 12678, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4226, 52857, 65535, - 65535, 65535, 61309, 12678, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4226, 52857, 65535, 65535, 65535, - 61309, 12678, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 4226, 52857, 65535, 65535, 65535, 61309, 12678, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 4226, 52857, 65535, 65535, 65535, 61309, 12678, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 4226, 52857, 65535, 65535, 65535, 61309, 12678, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 4226, 52857, 65535, 65535, 65535, 61309, 12678, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 4226, 52857, 65535, 65535, 65535, 61309, 12678, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4226, - 52857, 65535, 65535, 65535, 57083, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4226, 52857, 65535, - 65535, 52857, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4226, 40179, 46486, 12678, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ] }; - /// pause.png: 48x56 RGB565, 5376 bytes in the package image. - pub static PAUSE: Bitmap = Bitmap { w: 48, h: 56, px: &[ - 0, 0, 0, 0, 0, 4226, 19049, 33808, 31727, 29550, 10629, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 12678, 27501, 33808, 31727, 21130, 4226, 0, 0, 0, 0, 0, - 0, 0, 0, 4226, 33808, 65535, 65535, 65535, 65535, 65535, 65535, 52857, 16904, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 16904, 57083, 65535, 65535, 65535, 65535, 65535, 65535, 31727, 4226, 0, 0, 0, - 0, 0, 10597, 52857, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 33808, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 31727, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 52857, 8452, 0, 0, - 0, 4226, 54906, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 25356, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 25356, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 52857, 4226, 0, - 0, 38034, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 8452, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 6371, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 35953, 0, - 4226, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 35953, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 42260, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4226, - 23275, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 57083, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 57083, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 25356, - 33808, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 31727, - 31727, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 10597, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12678, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 33808, - 33808, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 16904, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16904, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 31759, - 31727, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 14855, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16904, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 33808, - 33808, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 16904, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16904, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 31727, - 31727, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 14823, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16904, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 33808, - 33808, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 16904, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16904, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 31759, - 31727, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 14855, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16904, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 33808, - 33808, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 16904, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16904, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 31727, - 31727, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 14823, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16904, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 33808, - 33808, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 16904, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16904, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 31759, - 31727, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 14855, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16904, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 33808, - 33808, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 16904, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16904, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 31727, - 31727, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 14823, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16904, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 33808, - 33808, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 16904, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16904, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 31759, - 31727, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 14855, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16904, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 33808, - 33808, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 16904, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16904, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 31727, - 31727, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 14823, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16904, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 33808, - 33808, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 16904, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16904, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 31759, - 31727, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 14855, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16904, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 33808, - 33808, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 16904, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16904, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 31727, - 31727, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 14823, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16904, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 33808, - 33808, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 16904, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16904, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 31759, - 31727, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 14855, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16904, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 33808, - 33808, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 16904, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16904, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 31727, - 31727, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 14823, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16904, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 33808, - 33808, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 16904, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16904, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 31759, - 31727, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 14855, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16904, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 33808, - 33808, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 16904, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16904, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 31727, - 31727, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 14823, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16904, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 33808, - 33808, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 16904, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16904, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 31759, - 31727, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 14855, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16904, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 33808, - 33808, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 16904, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16904, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 31727, - 31727, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 14823, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16904, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 33808, - 33808, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 16904, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16904, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 31759, - 31727, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 14855, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16904, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 33808, - 33808, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 16904, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16904, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 31727, - 31727, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 14823, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16904, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 33808, - 33808, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 16904, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16904, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 31759, - 31727, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 14855, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16904, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 33808, - 33808, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 12678, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12678, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 31727, - 31727, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 33808, - 25356, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 57083, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 59164, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 25356, - 4226, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 38034, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 40179, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 4226, - 0, 35985, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 8452, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 8452, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 33808, 0, - 0, 4226, 52857, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 23275, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 25356, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 52857, 4226, 0, - 0, 0, 8452, 52857, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 31727, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 33808, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 54938, 8452, 0, 0, - 0, 0, 0, 4226, 31727, 61341, 65535, 65535, 65535, 65535, 65535, 52857, 14855, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 16904, 52857, 65535, 65535, 65535, 65535, 65535, 61309, 33808, 4226, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 21130, 31727, 33808, 29582, 12678, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 12678, 29582, 31727, 33808, 21130, 0, 0, 0, 0, 0, 0 - ] }; - /// play-arrow.png: 50x60 RGB565, 6000 bytes in the package image. - pub static PLAY_ARROW: Bitmap = Bitmap { w: 50, h: 60, px: &[ - 0, 0, 0, 4226, 19049, 31727, 14823, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 25356, 61309, 65535, 65535, 65535, 57083, 25356, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 21130, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 48631, 6371, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 61309, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 61309, 31727, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 10597, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 52857, 12678, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16904, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 38034, 4226, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14855, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 57083, 19049, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16904, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 44405, - 4226, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 14823, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 61309, 29582, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 16904, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 50680, 8452, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 14855, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 31727, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 16904, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 52857, 16904, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 14823, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 35953, 4226, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16904, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 59164, 21130, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14855, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 44405, 4226, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16904, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 61309, 29582, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 14823, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 48631, - 10597, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 16904, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 31727, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 14855, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 57083, 16904, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 16904, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 38034, 4226, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 14823, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 61309, 19049, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16904, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 44405, 8452, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14855, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 61309, 29582, 0, 0, 0, 0, 0, 0, 0, 0, 16904, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 50712, 12678, 0, 0, 0, 0, 0, 0, - 14823, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 31727, 0, 0, 0, - 0, 0, 16904, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 57083, - 16904, 0, 0, 0, 14855, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 25356, 0, 0, 16904, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 21130, 0, 14823, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 48631, 0, 16904, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 0, 14855, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 0, 16904, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 50712, 0, - 14823, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 14823, 0, 16904, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 25356, 0, 0, 14855, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 54938, 10597, 0, 0, 0, 16904, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 61309, 33808, 0, 0, 0, 0, 0, 14823, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 48631, 8452, 0, 0, 0, 0, 0, 0, 16904, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 61341, 23275, 0, 0, 0, 0, 0, 0, 0, 0, 14855, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 44437, 4226, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16904, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 57083, 16904, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 14823, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 35953, 4226, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 16904, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 54938, 12678, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 14855, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 61309, 33808, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 16904, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 48631, 8452, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 14823, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 61309, 23275, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16904, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 46486, 4226, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14855, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 57083, 16904, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16904, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 35985, 4226, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 14823, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 52889, 10597, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 16904, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 61309, 33808, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 14855, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 48631, 8452, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 16904, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 63390, 25356, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 14823, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 44437, 4226, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16904, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 57083, 16904, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14855, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 35953, 4226, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12678, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 54938, 12678, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 57083, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 61309, 33808, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 21130, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 48631, 8452, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 23275, 61309, 65535, 65535, 65535, 57083, 23275, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 4226, 16904, 33808, 16904, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0 - ] }; - /// queue-music.png: 43x32 RGB565, 2752 bytes in the package image. - pub static QUEUE_MUSIC: Bitmap = Bitmap { w: 43, h: 32, px: &[ - 0, 25356, 44405, 48631, 48631, 48631, 48631, 48631, 48631, 48631, 48631, 48631, 48631, 48631, 48631, 48631, - 48631, 48631, 48631, 48631, 48631, 48631, 48631, 48631, 48631, 35953, 4226, 0, 0, 0, 0, 0, - 0, 0, 23275, 38002, 48631, 48631, 48631, 48631, 44405, 25356, 0, 33808, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 50712, 0, 0, 0, 0, 0, 4226, 48631, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 33808, 48631, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 0, 0, 0, 0, 0, 44405, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 48631, 33808, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 54938, 0, 0, 0, 0, - 12678, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 33808, 2145, 38034, 48631, 48663, - 48631, 48631, 48631, 48663, 48631, 48631, 48631, 48663, 48631, 48631, 48631, 48663, 48631, 48631, 48631, 48663, - 48631, 48631, 48631, 48663, 48631, 44437, 8452, 0, 0, 0, 0, 25356, 65535, 65535, 65535, 65535, - 48631, 48631, 48631, 48663, 48631, 38034, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 31759, 65535, 65535, 65535, 65535, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 33808, 65535, 65535, 65535, 65535, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 31727, 65535, 65535, 65535, - 65535, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 33808, 65535, 65535, 65535, 65535, 0, 0, 0, 0, - 0, 0, 0, 0, 27501, 50712, 48631, 50680, 48631, 50712, 48631, 50680, 48631, 50712, 48631, 50680, - 48631, 50712, 48631, 50680, 48631, 50712, 48631, 50680, 48631, 50712, 48631, 50680, 35953, 4226, 0, 0, - 0, 0, 31759, 65535, 65535, 65535, 65535, 0, 0, 0, 0, 0, 0, 0, 31727, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 52857, 0, 0, 0, 0, 33808, 65535, 65535, - 65535, 65535, 0, 0, 0, 0, 0, 0, 0, 50712, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 0, 0, 0, 0, 31727, 65535, 65535, 65535, 65535, 0, 0, 0, - 0, 0, 0, 0, 31727, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 52857, 0, - 0, 0, 0, 33808, 65535, 65535, 65535, 65535, 0, 0, 0, 0, 0, 0, 0, 0, - 31727, 50712, 48631, 50712, 48631, 50712, 48631, 50712, 48631, 50712, 48631, 50712, 48631, 50712, 48631, 50712, - 48631, 50712, 48631, 50712, 48631, 50712, 48631, 50712, 40179, 8452, 0, 0, 0, 0, 31759, 65535, - 65535, 65535, 65535, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 33808, 65535, 65535, 65535, 65535, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 31727, 65535, 65535, 65535, 65535, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33808, - 65535, 65535, 65535, 65535, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 31759, 65535, 65535, 65535, 65535, 0, - 0, 0, 0, 0, 0, 0, 0, 33808, 48631, 48631, 48631, 48631, 48631, 48631, 48631, 48631, - 48631, 48631, 48631, 48631, 48631, 48631, 40179, 8452, 0, 0, 0, 0, 0, 0, 0, 0, - 6371, 29582, 48631, 48631, 40179, 48631, 65535, 65535, 65535, 65535, 0, 0, 0, 0, 0, 0, - 0, 33808, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 57083, 0, 0, 0, 0, 0, 0, 0, 35953, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 0, 0, 0, 0, 0, 0, 0, 48631, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 0, 0, - 0, 0, 0, 0, 40179, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 0, 0, 0, 0, 0, 0, 0, 33808, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 52857, 0, 0, 0, 0, 0, 25356, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 0, 0, 0, 0, 0, - 0, 0, 0, 29582, 48631, 48663, 48631, 50712, 48631, 48663, 48631, 50712, 48631, 48663, 48631, 50712, - 48631, 48663, 35953, 8452, 0, 0, 0, 0, 0, 57083, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 12678, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14823, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 16904, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 6371, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 57083, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 52857, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 31727, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21130, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 61309, 4226, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 38034, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 16904, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 25356, 61309, 65535, 65535, 65535, 65535, 65535, 57083, 12678, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4226, - 25356, 42260, 44405, 33808, 21130, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ] }; - /// skip-next.png: 40x40 RGB565, 3200 bytes in the package image. - pub static SKIP_NEXT: Bitmap = Bitmap { w: 40, h: 40, px: &[ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 4226, 33808, 40179, 29550, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 8452, 61309, 65535, 65535, 65535, 54938, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 46486, 65535, 65535, 65535, 65535, 65535, 29582, 0, 0, 29582, 35953, 29582, 4226, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 57083, 65535, 65535, 65535, 65535, 65535, 40179, - 0, 52857, 65535, 65535, 65535, 61309, 19049, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 65535, 65535, 65535, 65535, 65535, 65535, 48663, 29582, 65535, 65535, 65535, 65535, 65535, 65535, 40179, - 4226, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 65535, 65535, 65535, 65535, 65535, 65535, 48631, - 40179, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 57083, 12678, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 65535, 65535, 65535, 65535, 65535, 65535, 48663, 50712, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 33808, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 65535, 65535, 65535, 65535, 65535, 65535, 48631, - 48631, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 52857, 6371, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 65535, 65535, 65535, 65535, 65535, 65535, 48663, 50712, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 61309, 23275, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 65535, 65535, 65535, 65535, 65535, 65535, 48631, - 48631, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 44405, 4226, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 65535, 65535, 65535, 65535, 65535, 65535, 48663, 50712, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 61309, 16904, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 65535, 65535, 65535, 65535, 65535, 65535, 48631, - 48631, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 35953, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 65535, 65535, 65535, 65535, 65535, 65535, 48663, 50712, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 54938, 12678, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 65535, 65535, 65535, 65535, 65535, 65535, 48631, - 48631, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 61309, 27501, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 65535, 65535, 65535, 65535, 65535, 65535, 48663, 50712, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 48631, 4226, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 65535, 65535, 65535, 65535, 65535, 65535, 48631, - 48631, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 61309, 21130, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 65535, 65535, 65535, 65535, 65535, 65535, 48663, 50712, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 38034, 0, 0, 0, 0, 0, 0, 0, 0, 65535, 65535, 65535, 65535, 65535, 65535, 48631, - 48631, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 21130, 0, 0, 0, 0, 0, 0, - 0, 65535, 65535, 65535, 65535, 65535, 65535, 48663, 50712, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 44405, 0, 0, 0, 0, 0, 0, 0, 65535, 65535, 65535, 65535, 65535, 65535, 48631, - 48631, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 44437, 0, 0, 0, 0, 0, 0, - 0, 65535, 65535, 65535, 65535, 65535, 65535, 48663, 50712, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 21130, 0, 0, 0, 0, 0, 0, 0, 65535, 65535, 65535, 65535, 65535, 65535, 48631, - 48631, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 40179, 0, 0, 0, 0, 0, 0, 0, - 0, 65535, 65535, 65535, 65535, 65535, 65535, 48663, 50712, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 63390, 21130, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 65535, 65535, 65535, 65535, 65535, 65535, 48631, - 48631, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 48631, 8452, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 65535, 65535, 65535, 65535, 65535, 65535, 48663, 50712, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 29582, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 65535, 65535, 65535, 65535, 65535, 65535, 48631, - 48631, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 52857, 12678, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 65535, 65535, 65535, 65535, 65535, 65535, 48663, 50712, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 35985, 4226, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 65535, 65535, 65535, 65535, 65535, 65535, 48631, - 48631, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 61309, - 14823, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 65535, 65535, 65535, 65535, 65535, 65535, 48663, 50712, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 46486, 4226, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 65535, 65535, 65535, 65535, 65535, 65535, 48631, - 48631, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 61309, 29582, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 65535, 65535, 65535, 65535, 65535, 65535, 48663, 50712, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 52857, 8452, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 65535, 65535, 65535, 65535, 65535, 65535, 48631, - 48631, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 31727, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 65535, 65535, 65535, 65535, 65535, 65535, 48663, 42260, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 59164, 12678, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 65535, 65535, 65535, 65535, 65535, 65535, 48631, - 27501, 65535, 65535, 65535, 65535, 65535, 65535, 42260, 4226, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 65535, 65535, 65535, 65535, 65535, 65535, 48663, 0, 52857, 65535, 65535, 65535, 61309, 21130, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 65535, 65535, 65535, 65535, 65535, 65535, 48631, - 0, 0, 27501, 38034, 27501, 4226, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 57083, 65535, 65535, 65535, 65535, 65535, 42260, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 44405, 65535, 65535, 65535, 65535, 65535, 29582, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 8452, 61309, 65535, 65535, 65535, 52857, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4226, 31727, 38034, 29582, 0, 0 - ] }; - /// skip-previous.png: 40x40 RGB565, 3200 bytes in the package image. - pub static SKIP_PREVIOUS: Bitmap = Bitmap { w: 40, h: 40, px: &[ - 0, 0, 27501, 40179, 31727, 4226, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 52857, 65535, 65535, 65535, 61309, 8452, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 27501, 65535, 65535, 65535, 65535, 65535, 44405, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 46486, 65535, 65535, 65535, 65535, 65535, 57083, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4226, 27501, 33808, 27501, 0, 0, - 48631, 65535, 65535, 65535, 65535, 65535, 65535, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 21130, 61309, 65535, 65535, 65535, 52857, 0, 50712, 65535, 65535, 65535, 65535, 65535, 65535, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 4226, 38034, 65535, 65535, 65535, 65535, 65535, 65535, 29582, - 48631, 65535, 65535, 65535, 65535, 65535, 65535, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10597, 57083, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 44437, 50712, 65535, 65535, 65535, 65535, 65535, 65535, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 31727, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 48631, - 48631, 65535, 65535, 65535, 65535, 65535, 65535, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8452, 52857, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 48663, 50712, 65535, 65535, 65535, 65535, 65535, 65535, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 25356, 61309, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 48631, - 48631, 65535, 65535, 65535, 65535, 65535, 65535, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 4226, 44405, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 48663, 50712, 65535, 65535, 65535, 65535, 65535, 65535, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16904, - 63390, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 48631, - 48631, 65535, 65535, 65535, 65535, 65535, 65535, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 35953, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 48663, 50712, 65535, 65535, 65535, 65535, 65535, 65535, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12678, 52857, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 48631, - 48631, 65535, 65535, 65535, 65535, 65535, 65535, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 29582, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 48663, 50712, 65535, 65535, 65535, 65535, 65535, 65535, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 4226, 50712, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 48631, - 48631, 65535, 65535, 65535, 65535, 65535, 65535, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 19049, 61309, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 48663, 50712, 65535, 65535, 65535, 65535, 65535, 65535, 0, - 0, 0, 0, 0, 0, 0, 0, 40179, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 48631, - 48631, 65535, 65535, 65535, 65535, 65535, 65535, 0, 0, 0, 0, 0, 0, 0, 19049, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 48663, 50712, 65535, 65535, 65535, 65535, 65535, 65535, 0, - 0, 0, 0, 0, 0, 0, 46486, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 48631, - 48631, 65535, 65535, 65535, 65535, 65535, 65535, 0, 0, 0, 0, 0, 0, 0, 44405, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 48663, 50712, 65535, 65535, 65535, 65535, 65535, 65535, 0, - 0, 0, 0, 0, 0, 0, 21130, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 48631, - 48631, 65535, 65535, 65535, 65535, 65535, 65535, 0, 0, 0, 0, 0, 0, 0, 0, 42260, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 48663, 50712, 65535, 65535, 65535, 65535, 65535, 65535, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 21130, 61309, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 48631, - 48631, 65535, 65535, 65535, 65535, 65535, 65535, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 4226, 48631, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 48663, 50712, 65535, 65535, 65535, 65535, 65535, 65535, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 29582, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 48631, - 48631, 65535, 65535, 65535, 65535, 65535, 65535, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 12678, 54938, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 48663, 50712, 65535, 65535, 65535, 65535, 65535, 65535, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 38034, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 48631, - 48631, 65535, 65535, 65535, 65535, 65535, 65535, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 16904, 57083, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 48663, 50712, 65535, 65535, 65535, 65535, 65535, 65535, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 4226, 44405, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 48631, - 48631, 65535, 65535, 65535, 65535, 65535, 65535, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 23275, 61309, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 48663, 50712, 65535, 65535, 65535, 65535, 65535, 65535, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 8452, 50712, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 48631, - 48631, 65535, 65535, 65535, 65535, 65535, 65535, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33808, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 48663, 50712, 65535, 65535, 65535, 65535, 65535, 65535, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 12678, 57083, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 44405, - 48631, 65535, 65535, 65535, 65535, 65535, 65535, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4226, - 35953, 65535, 65535, 65535, 65535, 65535, 65535, 29582, 50712, 65535, 65535, 65535, 65535, 65535, 65535, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 21130, 63390, 65535, 65535, 65535, 54938, 0, - 44405, 65535, 65535, 65535, 65535, 65535, 57083, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 4226, 29582, 35953, 29582, 0, 0, 29582, 65535, 65535, 65535, 65535, 65535, 46486, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 54938, 65535, 65535, 65535, 61341, 6371, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 29582, 35953, 33808, 4226, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ] }; - /// volume-down.png: 33x32 RGB565, 2112 bytes in the package image. - pub static VOLUME_DOWN: Bitmap = Bitmap { w: 33, h: 32, px: &[ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 31727, 48631, 27501, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 4226, 52857, 65535, 65535, 65535, 35953, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 4226, 52857, 65535, 65535, 65535, 65535, 50712, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 4226, 52857, 65535, 65535, 65535, 65535, 65535, 48631, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 44405, 65535, 65535, 65535, 65535, 65535, 65535, 48631, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 40179, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 48631, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 40179, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 50712, 0, 0, 0, 0, - 6371, 8452, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 40179, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 48631, 0, 0, 0, - 0, 16904, 65535, 29582, 0, 0, 0, 0, 0, 0, 8452, 16904, 14823, 16904, 14823, 16904, - 14823, 16904, 40179, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 48631, 0, 0, - 0, 0, 14823, 65535, 65535, 40179, 0, 0, 0, 4226, 48631, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 48631, 0, - 0, 0, 0, 16904, 65535, 65535, 65535, 25356, 0, 0, 27501, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 50712, - 0, 0, 0, 0, 14823, 65535, 65535, 65535, 61309, 8452, 0, 33808, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 48631, 0, 0, 0, 0, 16904, 65535, 65535, 65535, 65535, 40179, 0, 31727, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 48631, 0, 0, 0, 0, 14823, 65535, 65535, 65535, 65535, 61309, 2145, 33808, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 48631, 0, 0, 0, 0, 16904, 65535, 65535, 65535, 65535, 65535, 21130, 31727, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 50712, 0, 0, 0, 0, 14823, 65535, 65535, 65535, 65535, 65535, 31727, 33808, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 48631, 0, 0, 0, 0, 16904, 65535, 65535, 65535, 65535, 65535, 33808, - 31727, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 48631, 0, 0, 0, 0, 14823, 65535, 65535, 65535, 65535, 65535, - 31727, 33808, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 48631, 0, 0, 0, 0, 16904, 65535, 65535, 65535, 65535, - 65535, 33808, 31727, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 50712, 0, 0, 0, 0, 14823, 65535, 65535, 65535, - 65535, 65535, 19049, 33808, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 48631, 0, 0, 0, 0, 16904, 65535, 65535, - 65535, 65535, 61309, 4226, 31727, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 48631, 0, 0, 0, 0, 14823, 65535, - 65535, 65535, 65535, 42260, 0, 29582, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 48631, 0, 0, 0, 0, 16904, - 65535, 65535, 65535, 63390, 8452, 0, 4226, 50712, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 50712, 0, 0, 0, 0, - 14823, 65535, 65535, 65535, 23275, 0, 0, 0, 0, 8452, 16904, 16904, 16904, 16904, 16904, 16904, - 16904, 42260, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 48631, 0, 0, 0, - 0, 16904, 65535, 65535, 35985, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 42260, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 48631, 0, 0, - 0, 0, 14823, 65535, 23275, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 42260, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 48631, 0, - 0, 0, 0, 8452, 8452, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 42260, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 50712, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 42260, 65535, 65535, 65535, 65535, 65535, 65535, - 48631, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 42260, 65535, 65535, 65535, 65535, - 65535, 48631, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 42260, 65535, 65535, - 65535, 65535, 48631, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 42260, - 65535, 65535, 65535, 33808, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 29582, 48631, 25356, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ] }; - /// volume-up.png: 34x32 RGB565, 2176 bytes in the package image. - pub static VOLUME_UP: Bitmap = Bitmap { w: 34, h: 32, px: &[ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 25356, 48631, 25356, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 12678, 65535, 65535, 65535, 57083, 23275, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 14855, 65535, 65535, 65535, 65535, 65535, 48631, 8452, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 8452, 12678, 0, 0, 0, 0, 0, 48631, 65535, 65535, 65535, 65535, - 65535, 61309, 12678, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 25356, 65535, 65535, 35953, 0, 0, 0, 0, 0, 14823, 48663, - 65535, 65535, 65535, 65535, 61309, 12678, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 25356, 65535, 65535, 65535, 65535, 0, 0, 0, 0, 0, - 0, 0, 29582, 61309, 65535, 65535, 65535, 61309, 4226, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 25356, 65535, 65535, 65535, 65535, 65535, 0, 0, 0, - 0, 0, 0, 0, 0, 12678, 61309, 65535, 65535, 65535, 48631, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 25356, 65535, 65535, 65535, 65535, 65535, 65535, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 12678, 61309, 65535, 65535, 65535, 25356, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 25356, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 0, 0, 0, 6371, 4226, 0, 0, 0, 0, 0, 25356, 65535, 65535, 65535, 61309, - 2145, 0, 0, 0, 0, 0, 0, 0, 0, 0, 25356, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 0, 0, 0, 16904, 61309, 16904, 0, 0, 0, 0, 0, 50712, 65535, - 65535, 65535, 25356, 0, 0, 29582, 31727, 33776, 31727, 33808, 31727, 35953, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 0, 0, 0, 14855, 65535, 65535, 12678, 0, 0, 0, 0, - 14855, 65535, 65535, 65535, 52857, 0, 33808, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 0, 0, 0, 16904, 65535, 65535, 61309, 4226, 0, - 0, 0, 0, 52857, 65535, 65535, 65535, 4226, 48631, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 0, 0, 0, 14823, 65535, 65535, 65535, - 31727, 0, 0, 0, 0, 33808, 65535, 65535, 65535, 21130, 50712, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 0, 0, 0, 16904, 65535, - 65535, 65535, 61309, 0, 0, 0, 0, 16904, 65535, 65535, 65535, 31727, 48631, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 0, 0, 0, - 14855, 65535, 65535, 65535, 65535, 12678, 0, 0, 0, 4226, 65535, 65535, 65535, 42260, 50712, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 0, - 0, 0, 16904, 65535, 65535, 65535, 65535, 16904, 0, 0, 0, 0, 65535, 65535, 65535, 48631, - 48631, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 0, 0, 0, 14823, 65535, 65535, 65535, 65535, 16904, 0, 0, 0, 0, 65535, 65535, - 65535, 48631, 50712, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 0, 0, 0, 16904, 65535, 65535, 65535, 65535, 12678, 0, 0, 0, 4226, - 65535, 65535, 65535, 40179, 48631, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 0, 0, 0, 14855, 65535, 65535, 65535, 61309, 0, 0, 0, - 0, 16904, 65535, 65535, 65535, 33808, 50712, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 0, 0, 0, 16904, 65535, 65535, 65535, 33808, 0, - 0, 0, 0, 33808, 65535, 65535, 65535, 21130, 31727, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 0, 0, 0, 14823, 65535, 65535, 61309, - 2145, 0, 0, 0, 0, 52857, 65535, 65535, 65535, 4226, 0, 27501, 33808, 31759, 33808, 31727, - 33808, 35953, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 0, 0, 0, 16904, 65535, - 65535, 12678, 0, 0, 0, 0, 16904, 65535, 65535, 65535, 54938, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 23275, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 0, 0, 0, - 14855, 57115, 14823, 0, 0, 0, 0, 0, 48631, 65535, 65535, 65535, 23275, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 25356, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 0, - 0, 0, 4226, 4226, 0, 0, 0, 0, 0, 27533, 65535, 65535, 65535, 61309, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 23275, 65535, 65535, 65535, 65535, 65535, - 65535, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10629, 65535, 65535, 65535, 65535, 25356, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 25356, 65535, 65535, - 65535, 65535, 65535, 0, 0, 0, 0, 0, 0, 0, 0, 12678, 61309, 65535, 65535, 65535, - 50712, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 23275, 65535, 65535, 65535, 65535, 0, 0, 0, 0, 0, 0, 0, 27501, 61309, 65535, 65535, - 65535, 57115, 4226, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 25356, 65535, 65535, 38034, 0, 0, 0, 0, 0, 16904, 48631, 65535, 65535, - 65535, 65535, 63390, 12678, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 8452, 12678, 0, 0, 0, 0, 0, 48631, 65535, 65535, - 65535, 65535, 65535, 61309, 10597, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16904, 65535, - 65535, 65535, 65535, 65535, 50712, 4226, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 12678, 65535, 65535, 65535, 57083, 25356, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 25356, 50712, 25356, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ] }; -} diff --git a/apps/metrolist/src/main.rs b/apps/metrolist/src/main.rs deleted file mode 100644 index accc9bf..0000000 --- a/apps/metrolist/src/main.rs +++ /dev/null @@ -1,879 +0,0 @@ -//! Metrolist Remote: browse and play your Metrolist (YouTube Music) library from the watch, and control the phone's -//! playback. The watch never plays audio and never sees the account: it names a node to browse and an item to play, -//! and the Metrolist app on the phone does the rest over the app channel (`ANDROID_COMPANION.md`). -//! -//! Screens: the start screen (Controller, Metrolist), the player, the phone's queue, the root categories and one -//! node's folders or songs. The crown steps the phone's volume, as the volume screen's buttons do. Back is the app's own -//! (`own_back`): it walks the browse chain and leaves from the start screen; from the queue it returns to the player. -//! The app is also a watch page (`app_features!(PAGE)`): there it shows the player alone, and the watch keeps the -//! keys. -#![cfg_attr(any(target_os = "none", wp2_sim), no_main, cfg_attr(target_os = "none", no_std))] - -#[cfg_attr(not(any(target_os = "none", wp2_sim)), allow(dead_code))] -mod model; -#[cfg_attr(not(any(target_os = "none", wp2_sim)), allow(dead_code))] -mod screens; - -// The app's bitmap assets: bitmaps/*.png -> src/bitmaps.gen.rs, the Material icons its controls draw (bitmaps/README.md). -cmf_wp2_app::bitmaps!(); - -#[cfg(not(any(target_os = "none", wp2_sim)))] -fn main() {} - -#[cfg(any(target_os = "none", wp2_sim))] -mod device { - use crate::model::*; - use crate::screens::{self, Kind, Screen}; - use cmf_wp2_app::lv::{Batch, Lv, ROOT}; - use cmf_wp2_app::{ - Api, BUTTON, CROWN, LV, MEDIA_VOLUME_DOWN, MEDIA_VOLUME_UP, MESSAGE, MSG_MAX, PAUSE, RESUME, - }; - - cmf_wp2_app::entry!(main); - cmf_wp2_app::app_icon!(); - // A menu app, a page next to the watch face (the player alone) and a widget card with the phone's track: a long press - // on the app's row in Apps offers "Add widget" / "Add page", and a tap on the card starts the app. - cmf_wp2_app::app_features!(cmf_wp2_app::WIDGET | cmf_wp2_app::PAGE); - - /// The hello goes out again this soon while the phone has not answered; each try waits twice as long. - const HELLO_MS: u32 = 600; - const HELLO_MAX_MS: u32 = 3000; - /// How long a browse may take before the watch asks again. - const LIST_MS: u32 = 3000; - /// How long the phone has to ack a play command before the watch says "no answer". - const PLAY_ACK_MS: u32 = 10_000; - /// How often the loop wakes when nothing is due (the clock, a late frame). - const IDLE_MS: u32 = 5000; - /// The marquee: 3 px every 60 ms, and a pause at each end so the start of the title can be read. - const ROLL_MS: u32 = 60; - const ROLL_PX: i16 = 3; - const ROLL_HOLD_MS: u32 = 1400; - /// A second back within this long is the same swipe delivered twice, not a second press. - const BACK_GAP_MS: u32 = 250; - /// Where the volume screen's slider starts (0..=VOL_STEPS), until the user moves it. - const VOL_START: u8 = 8; - /// The widget card's value: 39 bytes, the stub's limit. - const WIDGET_VALUE: usize = 40; - - /// `text` in at most `buf.len() - 1` bytes, cut on a char boundary (a half character draws as nothing). - fn fit(text: &str, buf: &mut [u8]) -> usize { - let mut n = text.len().min(buf.len() - 1); - while n > 0 && !text.is_char_boundary(n) { - n -= 1; - } - buf[..n].copy_from_slice(&text.as_bytes()[..n]); - n - } - - static mut MODEL: Model = Model::new(); - - fn after(now: u32, t: u32) -> bool { - (now.wrapping_sub(t) as i32) >= 0 - } - - struct App { - api: &'static Api, - lv: Lv, - b: Batch, - s: Screen, - m: &'static mut Model, - /// The phone answered the last hello. - heard: bool, - tries: u8, - next_hello: u32, - list_deadline: u32, - /// The play ack deadline while the watch shows "Playing...". - play_pending: Option, - /// The category version the browse page was built from. - root_seen: u8, - last_min: u16, - /// The artwork colour the player's glow was drawn from: a colour the phone repeats is not written again. - last_colour: u16, - /// The title the label was last given. Writing it restarts the marquee, and the phone repeats the same title - /// with every progress frame, so it is written only when it really changed. - title_seen: [u8; TITLE_MAX], - title_len: u8, - /// The marquee: how far the title has slid, when it steps next, and whether it is resting at the start. - roll_x: i16, - roll_at: u32, - roll_hold: bool, - /// The `S` version the screen was last drawn from. - last_now: u8, - /// Back from the controller returns to the song list the song was tapped in, not to the start screen. - back_to_list: bool, - /// When the last back was handled, to drop a doubled `BUTTON` from one swipe. - last_back: u32, - /// The watch started the app as its page: the player alone, and the watch keeps the keys. - on_page: bool, - /// The `queue_version` the screen was last drawn from. - queue_seen: u8, - /// The search screen's query, as typed on the app's own keyboard. Kept when the screen is left, so a second - /// search starts from the last one. - query: [u8; SEARCH_MAX], - qlen: u8, - /// The volume screen's own track (0..=VOL_STEPS): the loader offers the phone's volume keys, not its level, so - /// this is what the slider shows and every step of it is one press of a key. - vol_level: u8, - /// The widget card's last written value, so a NAND write happens only when the track really changed. - widget_value: [u8; WIDGET_VALUE], - widget_len: u8, - /// Set by the start screen's Back arrow: the event loop leaves the app. - quit: bool, - } - - impl App { - fn now(&self) -> u32 { - self.api.now() - } - - fn send(&self, data: &[u8]) { - self.api.send(data); - } - - fn clock(&self, buf: &mut [u8; 5]) -> u16 { - match self.api.time() { - Some(t) => { - screens::clock_text(t.hour, t.minute, buf); - t.hour as u16 * 60 + t.minute as u16 - } - None => { - *buf = *b"--:--"; - u16::MAX - } - } - } - - /// Replaces the screen by the one of `kind`, built from the model. - fn go(&mut self, kind: Kind) { - let mut clock = [0u8; 5]; - let min = self.clock(&mut clock); - let text = core::str::from_utf8(&clock).unwrap_or(""); - let mut qbuf = [0u8; SEARCH_MAX]; - let qn = self.qlen as usize; - qbuf[..qn].copy_from_slice(&self.query[..qn]); - let query = core::str::from_utf8(&qbuf[..qn]).unwrap_or(""); - let App { b, lv, s, m, vol_level, .. } = self; - let vol = *vol_level; - let mut flush = |b: &mut Batch| b.submit(lv); - if screens::leave(b, s).is_ok() { - // The page is gone even if the next build fails: never keep a handle that may be reused. - s.page = ROOT; - s.title = ROOT; - s.status = ROOT; - s.hint = ROOT; - s.back_btn = ROOT; - s.queue_btn = ROOT; - s.queue_count = 0; - s.volume = ROOT; - s.query = ROOT; - s.key_count = 0; - } - let built = match kind { - Kind::Home => screens::home(b, &mut flush), - Kind::Controller => screens::controller(b, &mut flush, m, text), - Kind::Queue => screens::queue(b, &mut flush, m), - Kind::Volume => screens::volume(b, &mut flush, vol), - Kind::Browse => screens::browse(b, &mut flush, m), - Kind::List => screens::list(b, &mut flush, m), - Kind::Search => screens::search(b, &mut flush, query), - }; - if let Ok(next) = built { - *s = next; - } else if let Ok(fallback) = screens::notice(b, &mut flush) { - // A loader without bitmap assets refuses the player's image records before any record runs. - *s = fallback; - } - let _ = b.submit(lv); - self.last_min = min; - self.last_now = self.m.now_version; - self.last_colour = self.m.now.colour; - self.root_seen = self.m.root_version; - // The build wrote the title: remember it so the first refresh does not restart a marquee. - let n = (self.m.now.tlen as usize).min(TITLE_MAX); - self.title_seen = [0; TITLE_MAX]; - self.title_seen[..n].copy_from_slice(&self.m.now.title[..n]); - self.title_len = n as u8; - self.roll_reset(); - self.widget(); - } - - /// The labels the phone can change without a rebuild. - fn refresh(&mut self) { - if self.s.kind != Kind::Controller { - return; - } - let alive = self.m.alive(self.now()); - let mut clock = [0u8; 5]; - self.clock(&mut clock); - let text = core::str::from_utf8(&clock).unwrap_or(""); - let s = self.s; - let m = &*self.m; - let n = (m.now.tlen as usize).min(TITLE_MAX); - let new_title = n != self.title_len as usize || self.title_seen[..n] != m.now.title[..n]; - let mut flush = |b: &mut Batch| b.submit(&self.lv); - let _ = screens::show_now(&mut self.b, &mut flush, &s, m, true); - let _ = screens::show_clock(&mut self.b, &s, text); - let artist = if alive { m.now.artist() } else { "Waiting for phone" }; - let _ = self.b.text(s.artist, artist); - if new_title { - let _ = screens::show_track(&mut self.b, &s, m.now.title()); - } - let _ = self.b.submit(&self.lv); - self.last_now = m.now_version; - if new_title { - self.title_seen[..n].copy_from_slice(&m.now.title[..n]); - self.title_len = n as u8; - self.roll_reset(); - } - } - - // ---- the marquee ---- - - /// Only the player's title can scroll, and only when it is wider than its box. - fn rolling(&self) -> bool { - self.s.kind == Kind::Controller && screens::title_rolls(self.m.now.title()) - } - - /// How far the title has to slide for its end to come into the box. - fn roll_span(&self) -> i16 { - (screens::title_width(self.m.now.title()) - screens::TITLE_BOX).clamp(0, i16::MAX as i32) as i16 - } - - /// Back to the beginning, with the pause that lets it be read. - fn roll_reset(&mut self) { - self.roll_x = 0; - self.roll_hold = true; - self.roll_at = self.now().wrapping_add(ROLL_HOLD_MS); - } - - /// One step: rest at the start, slide left a little, then start over once the whole title has gone by. - fn roll_tick(&mut self) { - if !self.rolling() { - return; - } - let now = self.now(); - if !after(now, self.roll_at) { - return; - } - if self.roll_hold { - self.roll_hold = false; - } else { - self.roll_x = self.roll_x.saturating_add(ROLL_PX); - if self.roll_x >= self.roll_span() { - self.roll_x = 0; - self.roll_hold = true; - } - } - let s = self.s; - let _ = screens::roll_to(&mut self.b, &s, self.roll_x); - let _ = self.b.submit(&self.lv); - self.roll_at = now.wrapping_add(if self.roll_hold { ROLL_HOLD_MS } else { ROLL_MS }); - } - - // ---- the phone ---- - - fn hello(&mut self) { - self.send(&Model::hello_frame()); - self.heard = false; - let gap = (HELLO_MS << self.tries.min(3)).min(HELLO_MAX_MS); - self.tries = self.tries.saturating_add(1); - self.next_hello = self.now().wrapping_add(gap); - } - - fn hello_now(&mut self) { - self.tries = 0; - self.hello(); - } - - fn needs_phone(&self) -> bool { - self.s.kind != Kind::Home - } - - /// The queue is a screen of its own, with a Back pill: the phone's queue, asked for when it opens. - fn enter_queue(&mut self) { - self.go(Kind::Queue); - self.ask_queue(); - } - - /// Opens the player. `from_list` keeps the song list as the way back, which is where a tap on a song was. - fn enter_controller(&mut self, from_list: bool) { - self.back_to_list = from_list && self.m.list_ready; - self.go(Kind::Controller); - self.hello_now(); - } - - /// Ask the phone for the queue; the screen is drawn again when it is complete (`queue_ready`). - fn ask_queue(&mut self) { - self.send(&Model::queue_frame()); - } - - fn enter_browse(&mut self) { - self.back_to_list = false; - self.go(Kind::Browse); - self.hello_now(); - let frame = Model::browse_frame(0); - self.send(&frame); - } - - /// The search screen: the keyboard owns its own screen, and the query is kept between visits. - fn enter_search(&mut self) { - self.back_to_list = false; - self.go(Kind::Search); - self.hello_now(); - } - - fn push_query(&mut self, c: u8) { - let n = self.qlen as usize; - if n >= SEARCH_MAX { - return; - } - // One space between words, never at the start: both are only noise to the search. - if c == b' ' && (n == 0 || self.query[n - 1] == b' ') { - return; - } - self.query[n] = c; - self.qlen += 1; - } - - /// Sends the typed query and shows the phone's answer as a list, exactly like a node the phone named: the - /// five best matches, and a tap plays from that one (the phone queues the rest). - fn submit_search(&mut self) { - let n = self.qlen as usize; - if n == 0 { - return; - } - self.m.open(SEARCH_NODE, "Results"); - self.go(Kind::List); - let frame = Model::search_frame(&self.query[..n]); - self.send(&frame[..4 + n]); - self.list_deadline = self.now().wrapping_add(LIST_MS); - self.play_pending = None; - } - - /// Opens `node` as a list and asks the phone for it. `push` remembers the way back. - fn open_list(&mut self, node: u8, title: &str, push: bool) { - if push { - self.m.push(node, title); - } else { - self.m.open(node, title); - } - self.go(Kind::List); - let frame = Model::browse_frame(node); - self.send(&frame); - self.list_deadline = self.now().wrapping_add(LIST_MS); - self.play_pending = None; - } - - fn phone(&mut self, msg: &[u8]) { - let now = self.now(); - let was_connected = self.m.connected; - let fx = self.m.apply(msg, now); - if fx == Effect::default() { - return; - } - self.heard = true; - if fx.ack { - // The play round trip finished: show what the phone did with the tap. - self.play_pending = None; - let text = match self.m.ack { - ACK_PLAYING => "Playing now", - ACK_REFUSED => "Refused", - _ => "Not switched", - }; - let s = self.s; - let _ = screens::show_status(&mut self.b, &s, text); - let _ = self.b.submit(&self.lv); - if self.m.ack == ACK_PLAYING { - if self.s.kind == Kind::Controller { - self.refresh(); - } else if self.s.kind != Kind::Queue { - // A tap in the queue stays there: the phone sends the queue again with the new entry. - self.enter_controller(true); - } - } - } - // Back from a phone restart or a reconnect: what the screen shows may be stale, ask again. - if !was_connected && self.m.connected { - match self.s.kind { - Kind::Browse => { - let frame = Model::browse_frame(0); - self.send(&frame); - } - Kind::List => { - self.m.list_ready = false; - self.list_deadline = now.wrapping_add(LIST_MS); - let frame = Model::browse_frame(self.m.list_node); - self.send(&frame); - } - Kind::Queue => self.ask_queue(), - _ => {} - } - } - if fx.now && matches!(self.s.kind, Kind::Controller | Kind::Volume) { - if self.s.kind == Kind::Controller && self.m.now.colour != self.last_colour { - // The glow's arcs are cut where the colour really steps in 16 bits, so a colour that lands later - // (the phone reads the cover after the track) needs the player drawn again. - self.go(Kind::Controller); - } else if self.m.now_version != self.last_now { - self.refresh(); - } - } - // The queue streams in frames: draw the screen once, when the phone has sent it all. - if fx.queue - && self.s.kind == Kind::Queue - && self.m.queue_ready - && self.m.queue_version != self.queue_seen - { - self.queue_seen = self.m.queue_version; - self.go(Kind::Queue); - } - if fx.root && self.s.kind == Kind::Browse && self.m.root_version != self.root_seen { - self.go(Kind::Browse); - } - if fx.now { - self.widget(); - } - if fx.list && self.s.kind == Kind::List { - if fx.done { - self.go(Kind::List); - } else if self.s.title != ROOT { - let s = self.s; - let _ = screens::show_title(&mut self.b, &s, self.m); - let _ = self.b.submit(&self.lv); - } - } - } - - // ---- input ---- - - /// True for the first `BUTTON` of a press: one swipe must never walk two screens. - fn back_pressed(&mut self) -> bool { - let now = self.now(); - if now.wrapping_sub(self.last_back) < BACK_GAP_MS { - return false; - } - self.last_back = now; - true - } - - /// Back: up one node, to the start screen, or out of the app (true). - fn back(&mut self) -> bool { - match self.s.kind { - Kind::Home => true, - Kind::Controller => { - // A song tapped in a list returns there; the start screen is only the way back from its row. - // The watch's page has no start screen, so back there stays on the player. - if self.back_to_list { - self.go(Kind::List); - } else if !self.on_page { - self.go(Kind::Home); - } - false - } - Kind::Volume => { - self.go(Kind::Controller); - false - } - Kind::Queue => { - self.go(Kind::Controller); - false - } - Kind::Browse => { - self.go(Kind::Home); - false - } - Kind::Search => { - self.go(Kind::Home); - false - } - Kind::List => { - // The results are not a node in the browse chain: back returns to the keyboard, query intact. - if self.m.list_node == SEARCH_NODE { - self.go(Kind::Search); - return false; - } - match self.m.pop() { - Some(0) => { - self.go(Kind::Browse); - let frame = Model::browse_frame(0); - self.send(&frame); - } - Some(node) => { - self.go(Kind::List); - let frame = Model::browse_frame(node); - self.send(&frame); - self.list_deadline = self.now().wrapping_add(LIST_MS); - } - None => self.go(Kind::Home), - } - false - } - } - } - - fn tap(&mut self, handle: u16, code: i16, value: i16) { - if code == screens::VALUE_CHANGED { - // The volume screen's slider: the phone's volume keys only, so each step it moved is one press. - if self.s.kind == Kind::Volume && handle == self.s.volume.0 { - self.apply_volume(value as i32); - } - return; - } - if code != screens::CLICKED { - return; - } - match self.s.kind { - Kind::Home => { - if handle == self.s.back_btn.0 { - // The start screen's arrow leaves the app. - self.quit = true; - return; - } - match screens::row_at(&self.s, handle) { - Some(0) => self.enter_search(), - Some(1) => self.enter_browse(), - Some(2) => self.enter_controller(false), - _ => {} - } - } - Kind::Browse => { - let Some(i) = screens::row_at(&self.s, handle) else { return }; - if i >= self.m.root_count as usize { - return; - } - let cat = self.m.root[i]; - if cat.id == NONE { - return; - } - let mut name = [0u8; NAME_MAX]; - let len = (cat.nlen as usize).min(NAME_MAX); - name[..len].copy_from_slice(&cat.name[..len]); - let title = core::str::from_utf8(&name[..len]).unwrap_or(ROOT_TITLE); - self.open_list(cat.id, title, true); - } - Kind::List => { - let Some(i) = screens::row_at(&self.s, handle) else { return }; - if i >= self.m.item_count as usize { - return; - } - let item = self.m.items[i]; - if item.is_folder() { - let mut name = [0u8; TITLE_MAX]; - let len = (item.tlen as usize).min(TITLE_MAX); - name[..len].copy_from_slice(&item.title[..len]); - let title = core::str::from_utf8(&name[..len]).unwrap_or("Folder"); - self.open_list(item.id, title, true); - } else { - let frame = Model::play_frame(self.m.list_node, i as u8); - self.send(&frame); - // Stay on the list and show the round trip: the phone acks once the song really plays. - self.play_pending = Some(self.now().wrapping_add(PLAY_ACK_MS)); - let s = self.s; - let _ = screens::show_status(&mut self.b, &s, "Playing..."); - let _ = self.b.submit(&self.lv); - } - } - Kind::Controller => { - if handle == self.s.prev.0 { - self.send(&Model::transport_frame(CMD_PREV)); - } else if handle == self.s.play.0 { - self.send(&Model::transport_frame(CMD_TOGGLE)); - } else if handle == self.s.next.0 { - self.send(&Model::transport_frame(CMD_NEXT)); - } else if handle == self.s.vol.0 { - // The volume is its own screen: a capsule that follows and sets the phone's volume. - self.go(Kind::Volume); - } else if handle == self.s.queue_btn.0 { - self.enter_queue(); - } - } - Kind::Queue => { - // The Back pill only goes back; the rows play that queue position in the same queue. - if handle == self.s.back_btn.0 { - self.go(Kind::Controller); - return; - } - let Some(i) = screens::queue_at(&self.s, handle) else { return }; - self.m.queue_current = i as u8; - self.send(&Model::queue_play_frame(i as u8)); - let s = self.s; - let _ = screens::show_queue(&mut self.b, &s, self.m); - let _ = self.b.submit(&self.lv); - } - Kind::Volume => { - // The slider is read above; the corner arrow is the only button. - if handle == self.s.back_btn.0 { - self.go(Kind::Controller); - } - } - Kind::Search => { - if handle == self.s.back_btn.0 { - self.go(Kind::Home); - return; - } - let Some(code) = screens::key_at(&self.s, handle) else { return }; - match code { - screens::KEY_GO => { - self.submit_search(); - return; - } - screens::KEY_DEL => { - if self.qlen > 0 { - self.qlen -= 1; - } - } - screens::KEY_SPACE => self.push_query(b' '), - letter if letter < 26 => self.push_query(b'a' + letter), - _ => return, - } - // The box is redrawn in place: no page rebuild per key, so the keyboard never flickers. - let mut text = [0u8; SEARCH_MAX]; - let n = self.qlen as usize; - text[..n].copy_from_slice(&self.query[..n]); - let shown = core::str::from_utf8(&text[..n]).unwrap_or(""); - let s = self.s; - let _ = screens::show_query(&mut self.b, &s, shown); - let _ = self.b.submit(&self.lv); - } - } - } - - // ---- the phone's volume ---- - - /// Moves the phone's own media volume to step `level` of the app's track, as the stock volume popup does - /// (`MEDIA_KEY` 5 and 6): the phone applies it to its system volume, so this is the volume the user hears, not a - /// gain inside the music app. Only the steps that reach the phone are kept, so a slider dragged while the phone - /// refuses it snaps back to where the volume really is, and the screen says why. - fn apply_volume(&mut self, level: i32) { - let target = level.clamp(0, screens::VOL_STEPS) as u8; - let mut at = self.vol_level; - let mut rc = 0; - while at < target { - rc = self.api.media_key(MEDIA_VOLUME_UP); - if rc < 0 { - break; - } - at += 1; - } - while at > target { - rc = self.api.media_key(MEDIA_VOLUME_DOWN); - if rc < 0 { - break; - } - at -= 1; - } - self.vol_level = at; - if self.s.kind != Kind::Volume { - return; - } - let text = if rc < 0 { - match rc { - -19 => "No phone media", - -22 => "Needs a newer loader", - _ => "Volume refused", - } - } else { - screens::VOL_MSG - }; - let s = self.s; - let _ = screens::show_volume(&mut self.b, &s, at, text); - let _ = self.b.submit(&self.lv); - } - - /// The crown steps the phone's volume on the player and on the volume screen, one step per detent. - fn crown(&mut self, delta: i16) { - if delta == 0 || !matches!(self.s.kind, Kind::Controller | Kind::Volume) { - return; - } - self.apply_volume(self.vol_level as i32 + if delta > 0 { 1 } else { -1 }); - } - - // ---- the widget card ---- - - /// The card left of the watch face shows the track the phone plays (its tap starts the app). The stub draws it - /// from a record the app writes to NAND, so it is written only when the text changed, never per frame. - fn widget(&mut self) { - let mut buf = [0u8; WIDGET_VALUE]; - let text = if !self.m.connected { - "Waiting for phone" - } else if self.m.now.has { - self.m.now.title() - } else { - "Nothing playing" - }; - let n = fit(text, &mut buf); - if n == self.widget_len as usize && self.widget_value[..n] == buf[..n] { - return; - } - let _ = self.api.widget("Metrolist", core::str::from_utf8(&buf[..n]).unwrap_or("")); - self.widget_value = [0; WIDGET_VALUE]; - self.widget_value[..n].copy_from_slice(&buf[..n]); - self.widget_len = n as u8; - } - - // ---- timers ---- - - fn tick(&mut self) { - let now = self.now(); - if self.m.connected && !self.m.alive(now) { - self.m.mark_disconnected(); - self.heard = false; - } - if !self.heard && self.needs_phone() && after(now, self.next_hello) { - self.hello(); - } - if self.s.kind == Kind::List && !self.m.list_ready && after(now, self.list_deadline) { - // A search is not a node: ask again with what is in the query box instead of browsing node 250. - let n = self.qlen as usize; - if self.m.list_node == SEARCH_NODE && n > 0 { - let frame = Model::search_frame(&self.query[..n]); - self.send(&frame[..4 + n]); - } else { - let frame = Model::browse_frame(self.m.list_node); - self.send(&frame); - } - self.list_deadline = now.wrapping_add(LIST_MS); - } - if let Some(deadline) = self.play_pending { - if after(now, deadline) { - self.play_pending = None; - let s = self.s; - let _ = screens::show_status(&mut self.b, &s, "No answer"); - let _ = self.b.submit(&self.lv); - } - } - if self.s.kind == Kind::Controller { - let mut buf = [0u8; 5]; - let min = self.clock(&mut buf); - if min != self.last_min { - let text = core::str::from_utf8(&buf).unwrap_or(""); - let _ = screens::show_clock(&mut self.b, &self.s, text); - let _ = self.b.submit(&self.lv); - self.last_min = min; - } - } - self.roll_tick(); - } - - fn wait(&self) -> u32 { - let now = self.now(); - let mut w = IDLE_MS; - if !self.heard && self.needs_phone() { - w = w.min((self.next_hello.wrapping_sub(now) as i32).max(0) as u32); - } - if self.s.kind == Kind::List && !self.m.list_ready { - w = w.min((self.list_deadline.wrapping_sub(now) as i32).max(0) as u32); - } - if self.play_pending.is_some() { - w = w.min(1000); - } - if self.rolling() { - w = w.min((self.roll_at.wrapping_sub(now) as i32).max(0) as u32); - } - w - } - } - - /// True on RESUME, false on BUTTON. A page never exits itself, so there a BUTTON keeps waiting. - fn paused(api: &Api, page: bool) -> bool { - loop { - match api.event(u32::MAX).map(|e| e.kind) { - Some(RESUME) => return true, - Some(BUTTON) if !page => return false, - _ => {} - } - } - } - - fn main(api: &'static Api) -> i32 { - let Some(lv) = api.lv() else { return -95 }; - let Some(mut b) = Batch::new() else { return -1 }; - if screens::fonts(&mut b).and_then(|_| b.submit(&lv)).is_err() { - return 1; - } - // First in the first screen batch: the system font and white text for every label. - if screens::theme(&mut b).is_err() { - return 2; - } - // Back walks the browse chain and leaves from the start screen: the app owns it. - api.own_back(true); - let m = unsafe { &mut *core::ptr::addr_of_mut!(MODEL) }; - let mut app = App { - api, - lv, - b, - s: Screen::empty(), - m, - heard: false, - tries: 0, - next_hello: 0, - list_deadline: 0, - play_pending: None, - root_seen: 0, - last_min: u16::MAX, - last_colour: 0, - title_seen: [0; TITLE_MAX], - title_len: 0, - roll_x: 0, - roll_at: 0, - roll_hold: true, - last_now: 0, - back_to_list: false, - last_back: 0, - on_page: api.on_page(), - queue_seen: 0, - query: [0; SEARCH_MAX], - qlen: 0, - vol_level: VOL_START, - widget_value: [0; WIDGET_VALUE], - widget_len: 0, - quit: false, - }; - if app.on_page { - // The watch's page next to the face: the player alone, no way out (the watch keeps the keys). - app.enter_controller(false); - } else { - app.go(Kind::Home); - } - - let mut buf = [0u8; MSG_MAX]; - let mut got = [0u8; MSG_MAX]; - loop { - app.tick(); - let wait = app.wait(); - match api.event(wait) { - Some(e) if e.kind == BUTTON => { - // Back always walks the app's own screens; only a menu app may leave (a page never exits itself). - if app.back_pressed() && app.back() && !app.on_page { - return 0; - } - } - Some(e) if e.kind == CROWN => app.crown(e.delta), - Some(e) if e.kind == MESSAGE => { - while let Some(msg) = api.recv(&mut buf) { - let n = msg.len(); - got[..n].copy_from_slice(msg); - app.phone(&got[..n]); - } - } - Some(e) if e.kind == PAUSE => { - // Going home from a page (even from the queue) only pauses it: exiting from a page crashed the - // watch, so a page app waits for its RESUME instead of returning. - if !paused(api, app.on_page) { - return 0; - } - app.hello_now(); - app.refresh(); - } - Some(e) if e.kind == LV => { - app.quit = false; - app.tap(e.x as u16, e.y, e.delta); - if app.quit && !app.on_page { - return 0; - } - } - _ => {} - } - } - } -} diff --git a/apps/metrolist/src/model.rs b/apps/metrolist/src/model.rs deleted file mode 100644 index 829be08..0000000 --- a/apps/metrolist/src/model.rs +++ /dev/null @@ -1,983 +0,0 @@ -//! Metrolist Remote: the watch's state and its message protocol. No `Api` in here, so `cargo test` runs it on the -//! computer. -//! -//! The phone (a Metrolist fork with the watch link on) is the only client of YouTube Music: it owns the account, the -//! downloads and the player. The watch only names a node to browse and an item to play. -//! -//! Every frame starts with `M1` and a kind byte; 1..=128 bytes, like every app message. -//! -//! Watch -> phone: -//! `?` hello: app started, resumed or lost the phone; send the state and the root -//! `b` node browse node `0` (root categories) or a folder the phone named -//! `p` node index play item `index` of node `node`; the phone queues the node from there -//! `f` len query search the library; the phone answers with list frames for `SEARCH_NODE` -//! `t` cmd transport: 0 play/pause, 1 next, 2 previous -//! `q` send the queue (the controller's second page) -//! `j` index play queue entry `index` of the current queue -//! -//! Phone -> watch: -//! `S` flags pos vol tlen title alen artist colour:u16le -//! now playing. flags bit 0 playing, bit 2 a track is there (bit 1 the -//! phone's liked state, which the watch does not show); -//! `pos` 0..=100 percent of the track; `colour` the artwork's dominant -//! colour, RGB565, for the player's glow (0 when unknown) -//! `C` n (id kind nlen name colour:u16le)* -//! the root categories: `kind` 0 opens a folder, 1 is a song list -//! `B` node kind total tlen title a list starts; `total` items follow, the watch keeps the first 20 -//! `I` node start n (tlen title alen artist colour:u16le id)* -//! items `start..start+n` of that list; a folder item's `id` is its node -//! `E` node total the list is complete -//! `X` node code no list: 0 empty, 1 error, 2 the phone is not ready -//! a search's results are an ordinary list for node `SEARCH_NODE` (250): the -//! phone sends `B`/`I`/`E` with that node, and `p 250 index` plays from them -//! `Q` total current the queue starts: `total` entries follow, `current` plays -//! `J` start n (tlen title alen artist colour:u16le)* -//! queue entries `start..start+n`; the queue is ready at `total` -//! `H` heartbeat (about every 10 s) so the watch can show "Offline" -//! -//! Names: a list title is at most 20 bytes, a category name 20, a track title 34, an artist 20. A two-item `I` frame -//! stays under 128 bytes with those limits, which is why the phone clips them. -//! -//! The volume is not a frame: the watch steps the phone's own media volume with the loader's media keys -//! (`Api::media_key`), so it needs no link of this app's own. The `vol` byte of `S` is the phone's player gain, which -//! the watch reads no longer. - -pub const MAGIC: [u8; 2] = *b"M1"; -pub const MSG_MAX: usize = 128; - -pub const MAX_ITEMS: usize = 20; -/// Root categories the phone may send: its own shelves (Quick picks, Listen again, Downloads, Library, Explore) and up -/// to three home shelves of songs or albums. A `C` frame carries all eight with full names. -pub const MAX_ROOT: usize = 8; -pub const DEPTH_MAX: usize = 4; - -pub const TITLE_MAX: usize = 34; -pub const ARTIST_MAX: usize = 20; -pub const NAME_MAX: usize = 20; - -/// No node, no item id. -pub const NONE: u8 = 0xFF; - -pub const HELLO: u8 = b'?'; -pub const BROWSE: u8 = b'b'; -pub const PLAY: u8 = b'p'; -pub const TRANSPORT: u8 = b't'; -pub const QUEUE_REQ: u8 = b'q'; -pub const QUEUE_PLAY: u8 = b'j'; -pub const SEARCH: u8 = b'f'; - -/// The node the phone streams a search's results as. It is never part of the browse tree, so a list frame for it can -/// only be an answer to `f`. -pub const SEARCH_NODE: u8 = 250; - -/// The longest query the watch's keyboard sends; a `f` frame is 4 bytes plus the query, well under 128. -pub const SEARCH_MAX: usize = 24; - -pub const NOW: u8 = b'S'; -pub const CATEGORIES: u8 = b'C'; -pub const LIST_BEGIN: u8 = b'B'; -pub const ITEMS: u8 = b'I'; -pub const LIST_END: u8 = b'E'; -pub const LIST_NONE: u8 = b'X'; -pub const QUEUE: u8 = b'Q'; -pub const QUEUE_ITEMS: u8 = b'J'; -pub const HEARTBEAT: u8 = b'H'; - -/// `K` ack codes: the phone switched to the requested song, refused the command, or did not confirm. -pub const ACK: u8 = b'K'; -pub const ACK_PLAYING: u8 = 0; -pub const ACK_REFUSED: u8 = 1; -pub const ACK_NO_SWITCH: u8 = 2; - -/// `S` flags. -pub const NOW_PLAYING: u8 = 0x01; -pub const NOW_HAS_TRACK: u8 = 0x04; - -/// `C` / `B` node kinds. -pub const KIND_FOLDER: u8 = 0; -pub const KIND_SONGS: u8 = 1; - -/// Transport commands. -pub const CMD_TOGGLE: u8 = 0; -pub const CMD_NEXT: u8 = 1; -pub const CMD_PREV: u8 = 2; - -pub const ROOT_TITLE: &str = "Metrolist"; - -fn text(bytes: &[u8], len: u8) -> &str { - core::str::from_utf8(&bytes[..len as usize]).unwrap_or("") -} - -#[derive(Clone, Copy)] -pub struct Now { - pub has: bool, - pub playing: bool, - /// 0..=100. - pub pos: u8, - pub tlen: u8, - pub title: [u8; TITLE_MAX], - pub alen: u8, - pub artist: [u8; ARTIST_MAX], - /// The artwork's dominant colour, RGB565: the player's glow. 0 when the phone has none. - pub colour: u16, -} - -impl Now { - pub const EMPTY: Now = Now { - has: false, - playing: false, - pos: 0, - tlen: 0, - title: [0; TITLE_MAX], - alen: 0, - artist: [0; ARTIST_MAX], - colour: 0, - }; - - pub fn title(&self) -> &str { - if self.tlen == 0 { "Nothing playing" } else { text(&self.title, self.tlen) } - } - - pub fn artist(&self) -> &str { - if self.alen == 0 { "Open Metrolist on your phone" } else { text(&self.artist, self.alen) } - } -} - -#[derive(Clone, Copy)] -pub struct Category { - pub id: u8, - pub kind: u8, - pub nlen: u8, - pub name: [u8; NAME_MAX], - pub colour: u16, -} - -impl Category { - pub const EMPTY: Category = - Category { id: NONE, kind: KIND_SONGS, nlen: 0, name: [0; NAME_MAX], colour: 0x2966 }; - - pub fn label(&self) -> &str { - text(&self.name, self.nlen) - } - - pub fn is_folder(&self) -> bool { - self.kind == KIND_FOLDER - } -} - -#[derive(Clone, Copy)] -pub struct Item { - pub tlen: u8, - pub title: [u8; TITLE_MAX], - pub alen: u8, - pub artist: [u8; ARTIST_MAX], - /// The track's or album's average colour, RGB565: the row's circle and pill. - pub colour: u16, - /// A folder's node id, `NONE` for a song. - pub id: u8, -} - -impl Item { - pub const EMPTY: Item = Item { - tlen: 0, - title: [0; TITLE_MAX], - alen: 0, - artist: [0; ARTIST_MAX], - colour: 0x2966, - id: NONE, - }; - - pub fn title(&self) -> &str { - text(&self.title, self.tlen) - } - - pub fn artist(&self) -> &str { - text(&self.artist, self.alen) - } - - pub fn is_folder(&self) -> bool { - self.id != NONE - } -} - -/// What a frame changed; the device redraws only that. -#[derive(Default, Clone, Copy, PartialEq, Eq, Debug)] -pub struct Effect { - pub now: bool, - pub root: bool, - pub list: bool, - /// The list is complete (`E`) or refused (`X`). - pub done: bool, - pub heartbeat: bool, - /// The phone answered a play command (`K`). - pub ack: bool, - /// The queue (`Q` / `J`) changed. - pub queue: bool, -} - -pub struct Model { - pub now: Now, - pub root: [Category; MAX_ROOT], - pub root_count: u8, - /// Bumped on every `C`, so the device rebuilds the category page only when it changed. - pub root_version: u8, - pub items: [Item; MAX_ITEMS], - pub item_count: u8, - pub list_node: u8, - pub list_kind: u8, - pub list_total: u8, - pub list_ready: bool, - pub list_code: u8, - pub list_title: [u8; NAME_MAX], - pub list_tlen: u8, - /// The folders opened under the root, for Back. - path: [u8; DEPTH_MAX], - path_title: [[u8; NAME_MAX]; DEPTH_MAX], - path_len: [u8; DEPTH_MAX], - pub depth: u8, - pub connected: bool, - pub last_rx: u32, - /// Bumped on every accepted `S`: a new track can keep the same percent and play state, so the device - /// cannot tell a new track from a position update by the fields alone. - pub now_version: u8, - /// The code of the last `K` ack: 0 playing, 1 refused, 2 no switch. - pub ack: u8, - /// The phone's queue, in queue order (the first `MAX_ITEMS` entries). - pub queue: [Item; MAX_ITEMS], - pub queue_count: u8, - /// How many entries the phone said the queue has (at most `MAX_ITEMS`). - pub queue_total: u8, - /// The queue position that plays now. - pub queue_current: u8, - pub queue_ready: bool, - /// Bumped on every queue frame, so the device rebuilds the queue page only when it changed. - pub queue_version: u8, -} - -impl Model { - pub const fn new() -> Model { - Model { - now: Now::EMPTY, - root: [Category::EMPTY; MAX_ROOT], - root_count: 0, - root_version: 0, - items: [Item::EMPTY; MAX_ITEMS], - item_count: 0, - list_node: NONE, - list_kind: KIND_SONGS, - list_total: 0, - list_ready: false, - list_code: 0, - list_title: [0; NAME_MAX], - list_tlen: 0, - path: [NONE; DEPTH_MAX], - path_title: [[0; NAME_MAX]; DEPTH_MAX], - path_len: [0; DEPTH_MAX], - depth: 0, - connected: false, - last_rx: 0, - now_version: 0, - ack: 0, - queue: [Item::EMPTY; MAX_ITEMS], - queue_count: 0, - queue_total: 0, - queue_current: 0, - queue_ready: false, - queue_version: 0, - } - } - - pub fn list_title(&self) -> &str { - if self.list_tlen == 0 { ROOT_TITLE } else { text(&self.list_title, self.list_tlen) } - } - - fn set_list_title(&mut self, src: &[u8]) { - let len = src.len().min(NAME_MAX); - self.list_title = [0; NAME_MAX]; - self.list_title[..len].copy_from_slice(&src[..len]); - self.list_tlen = len as u8; - } - - /// Opens `node` (a list to load): clears the items and the title until `B` arrives. - pub fn open(&mut self, node: u8, title: &str) { - self.list_node = node; - self.set_list_title(title.as_bytes()); - self.items = [Item::EMPTY; MAX_ITEMS]; - self.item_count = 0; - self.list_total = 0; - self.list_ready = false; - self.list_code = 0; - } - - /// Opens `node` as a folder inside the current one, remembering the way back. - pub fn push(&mut self, node: u8, title: &str) { - self.open(node, title); - let d = (self.depth as usize).min(DEPTH_MAX - 1); - self.path[d] = node; - let len = title.len().min(NAME_MAX); - self.path_title[d] = [0; NAME_MAX]; - self.path_title[d][..len].copy_from_slice(&title.as_bytes()[..len]); - self.path_len[d] = len as u8; - self.depth = (self.depth + 1).min(DEPTH_MAX as u8); - } - - /// Back out of the open folder: the node to browse again, or `None` on the root categories. - pub fn pop(&mut self) -> Option { - if self.depth == 0 { - return None; - } - self.depth -= 1; - if self.depth == 0 { - self.open(0, ROOT_TITLE); - return Some(0); - } - let at = (self.depth - 1) as usize; - let parent = self.path[at]; - // Copy the parent's title out first: `open` rewrites the model it lives in. - let mut title = [0u8; NAME_MAX]; - let len = (self.path_len[at] as usize).min(NAME_MAX); - title[..len].copy_from_slice(&self.path_title[at][..len]); - let text = core::str::from_utf8(&title[..len]).unwrap_or(ROOT_TITLE); - self.open(parent, text); - Some(parent) - } - - pub fn browse_frame(node: u8) -> [u8; 4] { - [b'M', b'1', BROWSE, node] - } - - pub fn play_frame(node: u8, index: u8) -> [u8; 5] { - [b'M', b'1', PLAY, node, index] - } - - /// The keyboard's finished query. Only the first `4 + len` bytes are the frame; the rest stays zero. - pub fn search_frame(query: &[u8]) -> [u8; SEARCH_MAX + 4] { - let mut f = [0u8; SEARCH_MAX + 4]; - f[0] = b'M'; - f[1] = b'1'; - f[2] = SEARCH; - let n = query.len().min(SEARCH_MAX); - f[3] = n as u8; - f[4..4 + n].copy_from_slice(&query[..n]); - f - } - - pub fn transport_frame(cmd: u8) -> [u8; 4] { - [b'M', b'1', TRANSPORT, cmd] - } - - pub fn hello_frame() -> [u8; 3] { - [b'M', b'1', HELLO] - } - - pub fn queue_frame() -> [u8; 3] { - [b'M', b'1', QUEUE_REQ] - } - - pub fn queue_play_frame(index: u8) -> [u8; 4] { - [b'M', b'1', QUEUE_PLAY, index.min(MAX_ITEMS as u8 - 1)] - } - - /// The phone answered recently enough to trust the state. - pub fn alive(&self, now: u32) -> bool { - self.connected && now.wrapping_sub(self.last_rx) < 25_000 - } - - pub fn mark_disconnected(&mut self) { - self.connected = false; - } - - fn take_text(msg: &[u8], p: &mut usize, max: usize, out: &mut [u8]) -> Option { - if *p >= msg.len() { - return None; - } - let len = msg[*p] as usize; - *p += 1; - if len > max || *p + len > msg.len() { - return None; - } - if core::str::from_utf8(&msg[*p..*p + len]).is_err() { - return None; - } - out[..len].copy_from_slice(&msg[*p..*p + len]); - *p += len; - Some(len as u8) - } - - fn take_u16(msg: &[u8], p: &mut usize) -> Option { - if *p + 2 > msg.len() { - return None; - } - let v = u16::from_le_bytes([msg[*p], msg[*p + 1]]); - *p += 2; - Some(v) - } - - fn now_playing(&mut self, msg: &[u8]) -> Effect { - // flags pos vol tlen title alen artist colour:u16le - if msg.len() < 10 { - return Effect::default(); - } - let flags = msg[3]; - if flags & !0x07 != 0 || msg[4] > 100 || msg[5] > 100 { - return Effect::default(); - } - let mut p = 6; - let mut title = [0u8; TITLE_MAX]; - let tlen = match Self::take_text(msg, &mut p, TITLE_MAX, &mut title) { - Some(n) => n, - None => return Effect::default(), - }; - let mut artist = [0u8; ARTIST_MAX]; - let alen = match Self::take_text(msg, &mut p, ARTIST_MAX, &mut artist) { - Some(n) => n, - None => return Effect::default(), - }; - let colour = match Self::take_u16(msg, &mut p) { - Some(c) => c, - None => return Effect::default(), - }; - if p != msg.len() { - return Effect::default(); - } - self.now = Now { - has: flags & NOW_HAS_TRACK != 0, - playing: flags & NOW_PLAYING != 0, - pos: msg[4], - tlen, - title, - alen, - artist, - colour, - }; - self.now_version = self.now_version.wrapping_add(1); - Effect { now: true, ..Effect::default() } - } - - fn categories(&mut self, msg: &[u8]) -> Effect { - if msg.len() < 4 { - return Effect::default(); - } - let n = msg[3] as usize; - if n > MAX_ROOT { - return Effect::default(); - } - let mut p = 4; - let mut cats = [Category::EMPTY; MAX_ROOT]; - for slot in cats.iter_mut().take(n) { - if p >= msg.len() { - return Effect::default(); - } - let id = msg[p]; - p += 1; - if p >= msg.len() || msg[p] > KIND_SONGS { - return Effect::default(); - } - let kind = msg[p]; - p += 1; - let mut name = [0u8; NAME_MAX]; - let nlen = match Self::take_text(msg, &mut p, NAME_MAX, &mut name) { - Some(len) => len, - None => return Effect::default(), - }; - let colour = match Self::take_u16(msg, &mut p) { - Some(c) => c, - None => return Effect::default(), - }; - *slot = Category { id, kind, nlen, name, colour }; - } - if p != msg.len() { - return Effect::default(); - } - self.root = cats; - self.root_count = n as u8; - self.root_version = self.root_version.wrapping_add(1); - Effect { root: true, ..Effect::default() } - } - - fn list_begin(&mut self, msg: &[u8]) -> Effect { - // node kind total tlen title - if msg.len() < 7 || msg[3] != self.list_node || msg[4] > KIND_SONGS { - return Effect::default(); - } - let total = msg[5]; - let mut p = 6; - let mut title = [0u8; NAME_MAX]; - let tlen = match Self::take_text(msg, &mut p, NAME_MAX, &mut title) { - Some(n) => n, - None => return Effect::default(), - }; - if p != msg.len() { - return Effect::default(); - } - self.items = [Item::EMPTY; MAX_ITEMS]; - self.item_count = 0; - self.list_kind = msg[4]; - self.list_total = total; - self.list_title = title; - self.list_tlen = tlen; - self.list_ready = total == 0; - self.list_code = 0; - Effect { list: true, done: total == 0, ..Effect::default() } - } - - fn list_items(&mut self, msg: &[u8]) -> Effect { - // node start n (tlen title alen artist colour:u16le id)* - if msg.len() < 6 || msg[3] != self.list_node { - return Effect::default(); - } - let start = msg[4] as usize; - let n = msg[5] as usize; - if n == 0 || start + n > MAX_ITEMS { - return Effect::default(); - } - let mut p = 6; - let mut parsed = [Item::EMPTY; MAX_ITEMS]; - for slot in parsed.iter_mut().take(n) { - let mut title = [0u8; TITLE_MAX]; - let tlen = match Self::take_text(msg, &mut p, TITLE_MAX, &mut title) { - Some(len) => len, - None => return Effect::default(), - }; - let mut artist = [0u8; ARTIST_MAX]; - let alen = match Self::take_text(msg, &mut p, ARTIST_MAX, &mut artist) { - Some(len) => len, - None => return Effect::default(), - }; - let colour = match Self::take_u16(msg, &mut p) { - Some(c) => c, - None => return Effect::default(), - }; - if p >= msg.len() { - return Effect::default(); - } - let id = msg[p]; - p += 1; - *slot = Item { tlen, title, alen, artist, colour, id }; - } - if p != msg.len() { - return Effect::default(); - } - for (i, item) in parsed.iter().enumerate().take(n) { - self.items[start + i] = *item; - } - self.item_count = self.item_count.max((start + n) as u8); - Effect { list: true, ..Effect::default() } - } - - fn queue_begin(&mut self, msg: &[u8]) -> Effect { - // total current - if msg.len() != 5 || msg[3] as usize > MAX_ITEMS || msg[4] >= msg[3].max(1) { - return Effect::default(); - } - self.queue = [Item::EMPTY; MAX_ITEMS]; - self.queue_count = 0; - self.queue_total = msg[3]; - self.queue_current = msg[4]; - self.queue_ready = msg[3] == 0; - self.queue_version = self.queue_version.wrapping_add(1); - Effect { queue: true, ..Effect::default() } - } - - fn queue_items(&mut self, msg: &[u8]) -> Effect { - // start n (tlen title alen artist colour:u16le)* - if msg.len() < 6 { - return Effect::default(); - } - let start = msg[3] as usize; - let n = msg[4] as usize; - if n == 0 || start + n > MAX_ITEMS { - return Effect::default(); - } - let mut p = 5; - let mut parsed = [Item::EMPTY; MAX_ITEMS]; - for slot in parsed.iter_mut().take(n) { - let mut title = [0u8; TITLE_MAX]; - let tlen = match Self::take_text(msg, &mut p, TITLE_MAX, &mut title) { - Some(len) => len, - None => return Effect::default(), - }; - let mut artist = [0u8; ARTIST_MAX]; - let alen = match Self::take_text(msg, &mut p, ARTIST_MAX, &mut artist) { - Some(len) => len, - None => return Effect::default(), - }; - let colour = match Self::take_u16(msg, &mut p) { - Some(c) => c, - None => return Effect::default(), - }; - *slot = Item { tlen, title, alen, artist, colour, id: NONE }; - } - if p != msg.len() { - return Effect::default(); - } - for (i, item) in parsed.iter().enumerate().take(n) { - self.queue[start + i] = *item; - } - self.queue_count = self.queue_count.max((start + n) as u8); - self.queue_ready = self.queue_total > 0 && self.queue_count >= self.queue_total; - self.queue_version = self.queue_version.wrapping_add(1); - Effect { queue: true, ..Effect::default() } - } - - fn list_end(&mut self, msg: &[u8]) -> Effect { - if msg.len() != 5 || msg[3] != self.list_node { - return Effect::default(); - } - self.list_total = msg[4]; - self.item_count = self.item_count.min(msg[4].min(MAX_ITEMS as u8)); - self.list_ready = true; - Effect { list: true, done: true, ..Effect::default() } - } - - fn list_none(&mut self, msg: &[u8]) -> Effect { - if msg.len() != 5 || msg[3] != self.list_node || msg[4] > 2 { - return Effect::default(); - } - self.items = [Item::EMPTY; MAX_ITEMS]; - self.item_count = 0; - self.list_total = 0; - self.list_ready = true; - self.list_code = msg[4]; - Effect { list: true, done: true, ..Effect::default() } - } - - /// One phone message. A malformed frame changes nothing. - pub fn apply(&mut self, msg: &[u8], now: u32) -> Effect { - if msg.len() < 3 || msg[..2] != MAGIC || msg.len() > MSG_MAX { - return Effect::default(); - } - let fx = match msg[2] { - NOW => self.now_playing(msg), - CATEGORIES => self.categories(msg), - LIST_BEGIN => self.list_begin(msg), - ITEMS => self.list_items(msg), - LIST_END => self.list_end(msg), - LIST_NONE => self.list_none(msg), - QUEUE => self.queue_begin(msg), - QUEUE_ITEMS => self.queue_items(msg), - HEARTBEAT if msg.len() == 3 => Effect { heartbeat: true, ..Effect::default() }, - ACK if msg.len() == 4 && msg[3] <= ACK_NO_SWITCH => { - self.ack = msg[3]; - Effect { ack: true, ..Effect::default() } - } - _ => Effect::default(), - }; - if fx != Effect::default() { - self.connected = true; - self.last_rx = now; - } - fx - } -} - -#[cfg(test)] -mod tests { - extern crate std; - use super::*; - - fn now_frame(flags: u8, pos: u8, vol: u8, title: &str, artist: &str, colour: u16) -> std::vec::Vec { - let mut f = std::vec![b'M', b'1', NOW, flags, pos, vol, title.len() as u8]; - f.extend_from_slice(title.as_bytes()); - f.push(artist.len() as u8); - f.extend_from_slice(artist.as_bytes()); - f.extend_from_slice(&colour.to_le_bytes()); - f - } - - fn cat_frame(cats: &[(u8, u8, &str, u16)]) -> std::vec::Vec { - let mut f = std::vec![b'M', b'1', CATEGORIES, cats.len() as u8]; - for (id, kind, name, colour) in cats { - f.extend_from_slice(&[*id, *kind, name.len() as u8]); - f.extend_from_slice(name.as_bytes()); - f.extend_from_slice(&colour.to_le_bytes()); - } - f - } - - fn item_bytes(title: &str, artist: &str, colour: u16, id: u8) -> std::vec::Vec { - let mut f = std::vec![title.len() as u8]; - f.extend_from_slice(title.as_bytes()); - f.push(artist.len() as u8); - f.extend_from_slice(artist.as_bytes()); - f.extend_from_slice(&colour.to_le_bytes()); - f.push(id); - f - } - - fn begin_frame(node: u8, kind: u8, total: u8, title: &str) -> std::vec::Vec { - let mut f = std::vec![b'M', b'1', LIST_BEGIN, node, kind, total, title.len() as u8]; - f.extend_from_slice(title.as_bytes()); - f - } - - fn items_frame(node: u8, start: u8, items: &[std::vec::Vec]) -> std::vec::Vec { - let mut f = std::vec![b'M', b'1', ITEMS, node, start, items.len() as u8]; - for i in items { - f.extend_from_slice(i); - } - f - } - - fn root(m: &mut Model) { - let f = cat_frame(&[ - (1, KIND_SONGS, "Quick picks", 0x1234), - (2, KIND_SONGS, "Listen again", 0x2345), - (3, KIND_FOLDER, "Downloads", 0x3456), - (4, KIND_FOLDER, "Library", 0x4567), - (5, KIND_FOLDER, "Explore", 0x5678), - ]); - assert_eq!(m.apply(&f, 10), Effect { root: true, ..Effect::default() }); - } - - #[test] - fn root_categories_parse_and_keep_their_colours() { - let mut m = Model::new(); - root(&mut m); - assert_eq!(m.root_count, 5); - assert_eq!(m.root[0].label(), "Quick picks"); - assert_eq!(m.root[0].colour, 0x1234); - assert!(m.root[2].is_folder()); - assert!(!m.root[1].is_folder()); - assert!(m.connected); - assert_eq!(m.last_rx, 10); - // a shorter list replaces the old one entirely - assert!(m.apply(&cat_frame(&[(9, KIND_SONGS, "Home", 0)]), 20).root); - assert_eq!(m.root_count, 1); - assert_eq!(m.root[1].label(), ""); - } - - #[test] - fn eight_root_categories_fit_the_watch() { - let mut m = Model::new(); - let cats: [(u8, u8, &str, u16); 8] = [ - (1, KIND_SONGS, "Quick picks", 0x1111), - (2, KIND_SONGS, "Listen again", 0x2222), - (3, KIND_FOLDER, "Downloads", 0x3333), - (4, KIND_FOLDER, "Library", 0x4444), - (5, KIND_FOLDER, "Explore", 0x5555), - (6, KIND_FOLDER, "New releases", 0x6666), - (7, KIND_FOLDER, "Trending now", 0x7777), - (8, KIND_SONGS, "Chill", 0x8888), - ]; - assert!(m.apply(&cat_frame(&cats), 1).root); - assert_eq!(m.root_count, 8); - assert_eq!(m.root[5].label(), "New releases"); - assert!(m.root[5].is_folder()); - assert_eq!(m.root[7].colour, 0x8888); - } - - #[test] - fn a_list_streams_in_and_is_ready_on_the_end_frame() { - let mut m = Model::new(); - root(&mut m); - m.push(3, "Downloads"); - assert_eq!(m.list_node, 3); - assert!(!m.list_ready); - assert_eq!(m.apply(&begin_frame(3, KIND_SONGS, 3, "Downloaded songs"), 30).list, true); - assert_eq!(m.list_title(), "Downloaded songs"); - let items = std::vec![ - item_bytes("First", "One", 0x1111, NONE), - item_bytes("Second", "Two", 0x2222, NONE), - ]; - assert!(m.apply(&items_frame(3, 0, &items), 31).list); - assert_eq!(m.item_count, 2); - assert_eq!(m.items[1].title(), "Second"); - assert_eq!(m.items[1].colour, 0x2222); - assert!(!m.items[1].is_folder()); - let last = std::vec![item_bytes("Third", "Three", 0x3333, NONE)]; - assert!(m.apply(&items_frame(3, 2, &last), 32).list); - assert!(!m.list_ready); - assert_eq!(m.apply(b"M1E\x03\x03", 33), Effect { list: true, done: true, ..Effect::default() }); - assert!(m.list_ready); - assert_eq!(m.item_count, 3); - } - - #[test] - fn folder_items_carry_a_node_and_back_walks_the_chain() { - let mut m = Model::new(); - root(&mut m); - m.push(4, "Library"); - assert_eq!(m.depth, 1); - assert!(m.apply(&begin_frame(4, KIND_FOLDER, 2, "Library"), 40).list); - let items = std::vec![ - item_bytes("Songs", "1,204", 0x0101, 20), - item_bytes("Albums", "318", 0x0202, 21), - ]; - m.apply(&items_frame(4, 0, &items), 41); - m.apply(b"M1E\x04\x02", 42); - assert!(m.items[0].is_folder()); - assert_eq!(m.items[0].id, 20); - - m.push(20, "Songs"); - assert_eq!(m.depth, 2); - assert_eq!(m.list_node, 20); - assert_eq!(m.pop(), Some(4)); - assert_eq!(m.list_node, 4); - assert_eq!(m.depth, 1); - assert_eq!(m.pop(), Some(0)); - assert_eq!(m.depth, 0); - assert_eq!(m.pop(), None); - } - - #[test] - fn stale_and_malformed_frames_change_nothing() { - let mut m = Model::new(); - root(&mut m); - m.push(3, "Downloads"); - m.apply(&begin_frame(3, KIND_SONGS, 2, "Songs"), 50); - let before = std::string::String::from(m.list_title()); - // another node's list is stale: we already left it - assert_eq!(m.apply(&begin_frame(4, KIND_SONGS, 2, "Other"), 51), Effect::default()); - assert_eq!(m.list_title(), before.as_str()); - assert_eq!(m.apply(b"M1B\x03\x00\x02\x09Songs", 52), Effect::default()); // truncated title - assert_eq!(m.apply(b"M1S\x08\x00\x32\x00", 53), Effect::default()); // unknown flag bit - assert_eq!(m.apply(b"M1S\x00\x65\x32\x00\x00", 54), Effect::default()); // 101 percent - assert_eq!(m.apply(b"M1C\x07", 55), Effect::default()); // too many categories - assert_eq!(m.apply(b"M1I\x03\x13\x01\x00", 56), Effect::default()); // start beyond 20 - assert_eq!(m.apply(b"M1E\x03\x02\x00", 57), Effect::default()); // wrong length - assert_eq!(m.apply(b"X1H", 58), Effect::default()); // wrong magic - assert_eq!(m.apply(&[0xFF; MSG_MAX + 1], 59), Effect::default()); - assert!(!m.list_ready); - assert_eq!(m.root_count, 5); - } - - #[test] - fn now_playing_and_volume_frames() { - let mut m = Model::new(); - let f = now_frame(NOW_PLAYING | NOW_HAS_TRACK, 42, 70, "Song name", "Artist name", 0x1F3E); - assert_eq!(m.apply(&f, 60), Effect { now: true, ..Effect::default() }); - assert!(m.now.has); - assert!(m.now.playing); - assert_eq!(m.now.pos, 42); - assert_eq!(m.now.colour, 0x1F3E); - assert_eq!(m.now.title(), "Song name"); - assert_eq!(m.now.artist(), "Artist name"); - let paused = now_frame(NOW_HAS_TRACK, 0, 70, "Song name", "Artist name", 0); - assert!(m.apply(&paused, 61).now); - assert!(!m.now.playing); - // The colour is the last field: a frame that stops before it changes nothing. - let mut short = now_frame(NOW_HAS_TRACK, 0, 70, "Song name", "Artist name", 0); - short.truncate(short.len() - 2); - assert_eq!(m.apply(&short, 62), Effect::default()); - assert_eq!(m.now.colour, 0); - - assert_eq!(Model::transport_frame(CMD_NEXT), *b"M1t\x01"); - assert_eq!(Model::play_frame(4, 7), *b"M1p\x04\x07"); - assert_eq!(Model::browse_frame(0), *b"M1b\x00"); - assert_eq!(Model::hello_frame(), *b"M1?"); - assert_eq!(Model::queue_frame(), *b"M1q"); - assert_eq!(Model::queue_play_frame(7), *b"M1j\x07"); - } - - #[test] - fn the_queue_streams_in_and_marks_the_current_entry() { - let mut m = Model::new(); - assert_eq!(m.apply(b"M1Q\x03\x01", 10), Effect { queue: true, ..Effect::default() }); - assert_eq!(m.queue_total, 3); - assert_eq!(m.queue_current, 1); - assert!(!m.queue_ready); - let items = std::vec![ - item_bytes("First", "One", 0x1111, NONE), - item_bytes("Second", "Two", 0x2222, NONE), - ]; - // queue entries carry no node id: drop the trailing byte of each list item - let mut q = std::vec![b'M', b'1', QUEUE_ITEMS, 0, 2]; - for i in &items { - q.extend_from_slice(&i[..i.len() - 1]); - } - assert!(m.apply(&q, 11).queue); - assert_eq!(m.queue_count, 2); - assert_eq!(m.queue[1].title(), "Second"); - assert!(!m.queue_ready); - let mut last = std::vec![b'M', b'1', QUEUE_ITEMS, 2, 1]; - let third = item_bytes("Third", "Three", 0x3333, NONE); - last.extend_from_slice(&third[..third.len() - 1]); - assert!(m.apply(&last, 12).queue); - assert_eq!(m.queue_count, 3); - assert!(m.queue_ready); - // a malformed frame leaves the queue alone - assert_eq!(m.apply(b"M1Q\x02\x05", 13), Effect::default()); - assert_eq!(m.apply(b"M1J\x00\x02\x09", 14), Effect::default()); - assert_eq!(m.queue_count, 3); - } - - #[test] - fn play_acks_arrive_and_bad_codes_change_nothing() { - let mut m = Model::new(); - assert_eq!(m.apply(b"M1K\x00", 10), Effect { ack: true, ..Effect::default() }); - assert_eq!(m.ack, ACK_PLAYING); - assert_eq!(m.apply(b"M1K\x01", 11), Effect { ack: true, ..Effect::default() }); - assert_eq!(m.ack, ACK_REFUSED); - assert_eq!(m.apply(b"M1K\x02", 12), Effect { ack: true, ..Effect::default() }); - assert_eq!(m.ack, ACK_NO_SWITCH); - // Unknown codes and wrong shapes are dropped, and the last good code stays. - assert_eq!(m.apply(b"M1K\x03", 13), Effect::default()); - assert_eq!(m.apply(b"M1K", 14), Effect::default()); - assert_eq!(m.apply(b"M1K\x00\x00", 15), Effect::default()); - assert_eq!(m.ack, ACK_NO_SWITCH); - } - - #[test] - fn empty_and_refused_lists_are_done() { - let mut m = Model::new(); - root(&mut m); - m.push(5, "Explore"); - assert_eq!(m.apply(&begin_frame(5, KIND_SONGS, 0, "Explore"), 70), Effect { list: true, done: true, ..Effect::default() }); - assert!(m.list_ready); - m.push(5, "Explore"); - assert_eq!(m.apply(b"M1X\x05\x01", 71), Effect { list: true, done: true, ..Effect::default() }); - assert_eq!(m.list_code, 1); - assert!(m.list_ready); - assert_eq!(m.item_count, 0); - assert_eq!(m.apply(b"M1X\x05\x09", 72), Effect::default()); // unknown code - } - - #[test] - fn an_empty_queue_is_ready_at_once() { - let mut m = Model::new(); - assert!(m.apply(b"M1Q\x00\x00", 10).queue); - assert!(m.queue_ready); - assert_eq!(m.queue_count, 0); - } - - #[test] - fn a_phone_silence_marks_the_link_offline() { - let mut m = Model::new(); - root(&mut m); - assert!(m.alive(20)); - assert!(!m.alive(26_000)); - m.mark_disconnected(); - assert!(!m.alive(20)); - assert_eq!(m.apply(b"M1H", 30), Effect { heartbeat: true, ..Effect::default() }); - assert!(m.alive(30)); - } - - #[test] - fn a_search_frame_carries_the_query_and_is_clipped() { - let f = Model::search_frame(b"daft punk"); - assert_eq!(&f[..3], b"M1f"); - assert_eq!(f[3] as usize, 9); - assert_eq!(&f[4..13], b"daft punk"); - let long = "x".repeat(SEARCH_MAX + 8); - let f = Model::search_frame(long.as_bytes()); - assert_eq!(f[3] as usize, SEARCH_MAX); - assert_eq!(&f[4..4 + SEARCH_MAX], &long.as_bytes()[..SEARCH_MAX]); - } - - #[test] - fn two_items_fit_one_message() { - let title = "x".repeat(TITLE_MAX); - let artist = "y".repeat(ARTIST_MAX); - let items = std::vec![ - item_bytes(&title, &artist, 0x1234, NONE), - item_bytes(&title, &artist, 0x5678, 9), - ]; - let frame = items_frame(1, 0, &items); - assert!(frame.len() <= MSG_MAX, "frame is {} bytes", frame.len()); - let mut m = Model::new(); - m.open(1, "Songs"); - assert!(m.apply(&frame, 1).list); - assert_eq!(m.item_count, 2); - } -} diff --git a/apps/metrolist/src/screens.rs b/apps/metrolist/src/screens.rs deleted file mode 100644 index 9c5db5c..0000000 --- a/apps/metrolist/src/screens.rs +++ /dev/null @@ -1,1220 +0,0 @@ -//! Metrolist Remote's screens, built from the watch's own LVGL widgets in the stock look (`cmf_wp2_app::stock`), the -//! way ui-gallery does: a start screen with the two surfaces, a player that follows the phone's media session, the -//! phone's queue, and the Metrolist browser (the root categories, then a node's folders or songs). Lists are stock -//! focus pages, so the rows follow the stock app list's fisheye (the arc) while the crown or a drag scrolls them. -//! Leaving a screen deletes its page and everything on it. -//! -//! The controls are Google's Material Icons — `play_arrow`, `pause`, `skip_previous`, `skip_next`, `volume_up`, -//! `queue_music` and `arrow_back` — carried in the package as bitmap assets (`bitmaps/*.png`, `cmf_wp2_app::bitmaps!`). -//! A bitmap has no alpha yet (a transparent pixel becomes black), so each glyph sits on a black control whose colour is -//! the plate around it, and the glow reads around them. The player's glow is the artwork's colour, sent by the phone as -//! one RGB565 value. -//! -//! The search screen has the watch's own keyboard: a QWERTY grid of stock buttons (not an LVGL text area, which would -//! need the loader's input device), so every tap is the app's and the finished query goes to the phone as one frame. -//! The keys fill the bottom of the round screen, as on a phone's keyboard, with the query box above them; the phone's -//! five best matches come back as an ordinary list, so choosing one is the list screen's tap. -//! -//! Back is one small round icon button in the top-left corner of every screen that has a way back (the start screen's -//! leaves the app). It is a child of the root, so it stays put when a focus page scrolls under it. - -use crate::bitmaps; -use crate::model::*; -use cmf_wp2_app::lv::*; -use cmf_wp2_app::Bitmap; -use cmf_wp2_app::stock::{self, CIRCLE, GREY, ROW_BG, ROW_W, SCREEN, WHITE}; - -/// Font slots besides the system font (slot 0). -pub const F24: u8 = 1; -/// The heavier face of the headings: the stock set has no bold, and this is its heaviest text face. -pub const F36: u8 = 2; -/// Bytes one widget group can take: flush first when fewer are left. -const GROUP: usize = 620; -/// `Event.y` of an LVGL CLICKED event. -pub const CLICKED: i16 = 7; -/// `Event.y` of an LVGL VALUE_CHANGED event (a slider's or a switch's new value is in `delta`). -pub const VALUE_CHANGED: i16 = 28; -/// The search keyboard's most keys: 26 letters, space, DEL and Search. -pub const KEY_MAX: usize = 32; -/// Key codes that are not a letter: the letter keys carry `0..=25`. -pub const KEY_SPACE: u8 = 26; -pub const KEY_DEL: u8 = 27; -pub const KEY_GO: u8 = 28; - -/// A row's text starts clear of the curved left edge; no icon or art circle sits behind it. -const TEXT_X: i16 = 28; -const TEXT_W: i32 = ROW_W - TEXT_X as i32 - 28; - -// The player, as offsets from the screen centre: the clock, the track and its artist above, the play button on the -// screen's centre point inside the progress ring, the skips beside it and a bottom row of volume and queue. -const DISC: i32 = 150; -const RING: i32 = 172; -const RING_W: i32 = 6; -const DISC_Y: i16 = 0; -const SIDE: i32 = 72; -const SIDE_X: i16 = 156; -const BOTTOM_Y: i16 = 168; -// The clock, the track and its artist share the band above the ring: the ring's top edge is -86 from the centre and -// the play disc's -75, so the text ends well clear of the button that used to cover it. -const CLOCK_Y: i16 = -218; -const TITLE_Y: i16 = -165; -const TITLE_H: i32 = 52; -const ARTIST_Y: i16 = -124; -const ARTIST_H: i32 = 26; - -// Volume and Queue: one rounded-rectangle text button each, side by side under the play button. -const PILL_W: i32 = 118; -const PILL_H: i32 = 54; -const PILL_X: i16 = 64; -const PILL_R: i32 = 20; - -// The glow behind the player: the artwork's colour as concentric opaque bands, because LVGL here has no radial -// gradient. Stacking see-through circles was a mistake: at 16-bit colour a nearly transparent layer rounds away to -// nothing, so the circles left no glow at all. Bands drawn as full-circle arcs hold the colour exactly. -/// One arc per colour step of the ramp; a dim artwork colour uses fewer, a bright one up to this many. -const GLOW_BANDS: usize = 64; -/// Radius of the outermost and the innermost band: well past the round screen (whose radius is 233), then right behind -/// the play button, so the light fills the whole face instead of dying out halfway. -const GLOW_OUT: i32 = 310; -const GLOW_IN: i32 = 24; -/// How much of the artwork's colour the middle band keeps (0..=256). Kept low: the glow is a backdrop for the text and -/// the ring, not a light of its own. -const GLOW_BRIGHT: u32 = 116; - -// The volume screen: a heading, then a tall vertical slider down the middle of the face, with the note under it. -// An LVGL bar or slider is vertical when its width is under its height (LVGL 8.3, "Bar (lv_bar)"), and a vertical one -// fills from the bottom up. -const VOL_TITLE_Y: i16 = -170; -const VOL_MSG_Y: i16 = 200; -const VOL_SLIDER_Y: i16 = 10; -const VOL_SLIDER_W: i32 = 48; -const VOL_SLIDER_H: i32 = 300; -/// The slider's track: the stock row grey, so the white fill and knob read against it. -const VOL_TRACK: i32 = stock::ROW_BG; -/// The slider's steps. The loader offers the phone's volume keys, not its level, so the app keeps a fifteen-step track -/// of its own (Android's usual media volume range) and presses a key per step it moves. -pub const VOL_STEPS: i32 = 15; -/// The status line under the heading; [`show_volume`] replaces it when the phone refuses a step. -pub const VOL_MSG: &str = "The phone's own volume"; - -// The search screen: the query box under the Back button, then the keyboard down to the bottom edge: three QWERTY rows -// and a bottom row of DEL, space and Search. The key rows are as wide as the round face allows at their height: the -// top row spans 456 px where the chord is 464, the bottom row 228 where it is 266. -const SEARCH_BOX_Y: i16 = -100; -const SEARCH_BOX_W: i32 = 340; -const SEARCH_BOX_H: i32 = 50; -const SEARCH_BOX_R: i32 = 25; -const QUERY_HINT: &str = "Type a song"; -const SEARCH_KEY_W: i32 = 42; -const SEARCH_KEY_H: i32 = 50; -const SEARCH_KEY_GAP: i16 = 4; -/// The keyboard's four rows, as offsets from the screen's centre: the last one ends 42 px above the bottom edge. -const KEY_Y: [i16; 4] = [4, 58, 112, 166]; -/// The Search key's red: the stock palette has no red, and the key has to read as the action. -const SEARCH_RED: i32 = 0xC145; - -/// The Back button: a small round icon button in the top-left corner, inside the round face. -const BACK_SIZE: i32 = 44; -const BACK_X: i16 = 70; -const BACK_Y: i16 = 58; - -#[derive(Clone, Copy, PartialEq, Eq, Debug)] -pub enum Kind { - Home, - Controller, - Queue, - Volume, - Browse, - List, - Search, -} - -/// What the app reacts to on the current screen; unused handles are `ROOT` (never an event target). -#[derive(Clone, Copy)] -pub struct Screen { - pub kind: Kind, - pub page: Obj, - pub rows: [Obj; MAX_ITEMS], - /// For a list row: the folder's node id, `NONE` for a song. - pub row_ids: [u8; MAX_ITEMS], - pub row_count: u8, - pub title: Obj, - /// The title's marquee, shown instead of `title` when the text is wider than its box. - pub title_roll: Obj, - pub artist: Obj, - pub clock: Obj, - pub progress: Obj, - pub prev: Obj, - pub play: Obj, - pub next: Obj, - /// The glow's bands behind the player, outermost first (`ROOT` on every other screen). - pub glow: [Obj; GLOW_BANDS], - pub vol: Obj, - pub queue_btn: Obj, - /// The queue screen's fixed Back pill (`ROOT` elsewhere): it only goes back. - pub back_btn: Obj, - /// The play button's two icons (bitmaps): one flag record each, so the two can never be left showing at once. - pub pause_icon: Obj, - pub play_icon: Obj, - pub hint: Obj, - /// A fixed status bar at the bottom of a song list (`ROOT` when the screen has none). - pub status: Obj, - /// The queue screen's rows, in queue order. - pub queue_rows: [Obj; MAX_ITEMS], - pub queue_count: u8, - /// The volume screen's slider (`ROOT` elsewhere): the app's track over the phone's volume keys. - pub volume: Obj, - /// The search screen's keyboard: one handle per key, with its code (a letter's index, or `KEY_SPACE` / - /// `KEY_DEL` / `KEY_GO`). - pub keys: [Obj; KEY_MAX], - pub key_codes: [u8; KEY_MAX], - pub key_count: u8, - /// The box that shows what has been typed (and its hint while it is empty). - pub query: Obj, -} - -const EMPTY: Screen = Screen { - kind: Kind::Home, - page: ROOT, - rows: [ROOT; MAX_ITEMS], - row_ids: [NONE; MAX_ITEMS], - row_count: 0, - title: ROOT, - title_roll: ROOT, - artist: ROOT, - clock: ROOT, - progress: ROOT, - prev: ROOT, - play: ROOT, - next: ROOT, - glow: [ROOT; GLOW_BANDS], - vol: ROOT, - queue_btn: ROOT, - back_btn: ROOT, - pause_icon: ROOT, - play_icon: ROOT, - hint: ROOT, - status: ROOT, - queue_rows: [ROOT; MAX_ITEMS], - queue_count: 0, - volume: ROOT, - keys: [ROOT; KEY_MAX], - key_codes: [0; KEY_MAX], - key_count: 0, - query: ROOT, -}; - -impl Screen { - pub const fn empty() -> Screen { - EMPTY - } -} - -type Flush<'a> = &'a mut dyn FnMut(&mut Batch) -> Result<(), LvError>; - -fn room(b: &mut Batch, flush: Flush) -> Result<(), LvError> { - if b.bytes().len() + GROUP > BUF { flush(b) } else { Ok(()) } -} - -/// The fonts, in a batch of their own. -pub fn fonts(b: &mut Batch) -> Result<(), LvError> { - stock::font(b)?; - b.font(F24, StockFont::F24M)?; - b.font(F36, StockFont::F36M) -} - -/// Once, first: the system font and white text for everything. -pub fn theme(b: &mut Batch) -> Result<(), LvError> { - stock::theme(b) -} - -/// Deletes the current screen (its page, with every object and its scroll bar, and the fixed Back pill). -pub fn leave(b: &mut Batch, s: &Screen) -> Result<(), LvError> { - if s.page != ROOT { - b.del(s.page)?; - } - for o in [s.status, s.back_btn] { - if o != ROOT { - let _ = b.del(o); - } - } - Ok(()) -} - -/// The white heading of a page: the stock title's place and size in the heavier face. It is a page child, so on a -/// focus page it scrolls away with the rows and takes the fisheye's arc with them. -fn heading(b: &mut Batch, flush: Flush, page: Obj, text: &str, h: i32) -> Result { - room(b, flush)?; - let t = b.create(Class::Label, page)?; - b.size(t, ROW_W, h)?; - b.long_mode(t, LongMode::Dot)?; - b.style(t, Prop::TextAlign, 0, 2)?; // LV_TEXT_ALIGN_CENTER - b.style(t, Prop::TextColor, 0, WHITE)?; - b.style(t, Prop::TextFont, 0, F36 as i32)?; - b.text(t, text)?; - b.flags(t, &[], &[Flag::Clickable, Flag::Scrollable])?; - Ok(t) -} - -/// One Material icon as a bitmap of the package: an `lv_img` whose pixels stay in the app block and are drawn in place -/// (docs/bitmap-assets.md). It is never clickable, so it does not steal its button's tap, and it is centred on `x`, `y` -/// from its parent's middle. -fn icon(b: &mut Batch, flush: Flush, parent: Obj, bm: &Bitmap, x: i16, y: i16) -> Result { - room(b, flush)?; - let img = b.image(parent)?; - b.set_image(img, bm.px, bm.w, bm.h)?; - b.align(img, Align::Center, x, y)?; - b.flags(img, &[], &[Flag::Clickable, Flag::Scrollable])?; - Ok(img) -} - -/// A rounded-rectangle button in the app's black with a single Material icon: the Volume and Queue controls. The icon is -/// the whole button (a label beside it said the same thing twice). The black the icon's transparency became is the -/// button's own colour, so no plate shows around the glyph. -fn icon_pill(b: &mut Batch, flush: Flush, parent: Obj, x: i16, y: i16, bm: &Bitmap) -> Result { - let pill = b.create(Class::Btn, parent)?; - b.size(pill, PILL_W, PILL_H)?; - b.align(pill, Align::Center, x, y)?; - b.style(pill, Prop::Radius, 0, PILL_R)?; - b.style(pill, Prop::BgColor, 0, stock::BLACK)?; - b.style(pill, Prop::BgOpa, 0, 255)?; - b.style(pill, Prop::BgColor, stock::PRESSED, WHITE)?; - b.style(pill, Prop::BgOpa, stock::PRESSED, 40)?; - b.style(pill, Prop::BorderWidth, 0, 0)?; - b.events(pill, &[Ev::Clicked])?; - icon(b, flush, pill, bm, 0, 0)?; - Ok(pill) -} - -/// The top-left Back button: a round plate with the arrow, a child of the root so a scrolling page never takes it with -/// it. It only goes back; the app reads the tap. -fn back_button(b: &mut Batch, flush: Flush) -> Result { - let btn = b.create(Class::Btn, ROOT)?; - b.size(btn, BACK_SIZE, BACK_SIZE)?; - b.align(btn, Align::TopLeft, BACK_X, BACK_Y)?; - b.style(btn, Prop::Radius, 0, CIRCLE)?; - b.style(btn, Prop::BgColor, 0, ROW_BG)?; - b.style(btn, Prop::BgOpa, 0, 255)?; - b.style(btn, Prop::BgColor, stock::PRESSED, WHITE)?; - b.style(btn, Prop::BgOpa, stock::PRESSED, 40)?; - b.style(btn, Prop::BorderWidth, 0, 0)?; - b.events(btn, &[Ev::Clicked])?; - icon(b, flush, btn, &bitmaps::ARROW_BACK, 0, 0)?; - Ok(btn) -} - -/// A stock focus row: no icon, a title at `LeftMid(28, -16)`, an optional grey second line at `+20`. The fisheye -/// marks the centred row and moves the text along the arc; the app does not tint it. -fn focus_row(b: &mut Batch, flush: Flush, page: Obj, name: &str, detail: &str) -> Result { - room(b, flush)?; - let row = stock::focus_row(b, page)?; - b.events(row, &[Ev::Clicked])?; - let t = b.create(Class::Label, row)?; - b.size(t, TEXT_W, if detail.is_empty() { 44 } else { 40 })?; - b.long_mode(t, LongMode::Dot)?; - b.text(t, name)?; - b.align(t, Align::LeftMid, TEXT_X, if detail.is_empty() { 0 } else { -16 })?; - b.flags(t, &[], &[Flag::Clickable, Flag::Scrollable])?; - if !detail.is_empty() { - let d = b.create(Class::Label, row)?; - b.size(d, TEXT_W, 30)?; - b.long_mode(d, LongMode::Dot)?; - b.style(d, Prop::TextFont, 0, F24 as i32)?; - b.style(d, Prop::TextColor, 0, GREY)?; - b.text(d, detail)?; - b.align(d, Align::LeftMid, TEXT_X, 20)?; - b.flags(d, &[], &[Flag::Clickable, Flag::Scrollable])?; - } - Ok(row) -} - -/// The start screen: Search first, then the library, then the player. A stock focus page like the app list, so the crown -/// (or a drag) scrolls the three rows round the screen and the centred one is marked; the top-left arrow leaves the app. -pub fn home(b: &mut Batch, flush: Flush) -> Result { - room(b, flush)?; - let (page, _bar) = stock::focus_page(b, 0)?; - opaque(b, page)?; - // A gap between the rows: the fisheye page lays them out edge to edge, which reads as one block. - b.style(page, Prop::PadRow, 0, 8)?; - let mut s = Screen { kind: Kind::Home, page, ..EMPTY }; - heading(b, flush, page, "Metrolist", stock::FOCUS_ROW_H)?; - let entries: [(&str, &str); 3] = [ - ("Search", "Find a song by name"), - ("Metrolist", "Quick picks, library"), - ("Controller", "Playback on your phone"), - ]; - for (i, (name, detail)) in entries.into_iter().enumerate() { - room(b, flush)?; - let row = stock::focus_row(b, page)?; - // Only the row the fisheye centres (the loader's CHECKED state) gets a plate. Filling every row painted three - // bars edge to edge, which read as everything being selected at once. - b.style(row, Prop::BgColor, CHECKED, ROW_BG)?; - b.style(row, Prop::BgOpa, CHECKED, 255)?; - b.flags(row, &[Flag::Clickable], &[Flag::Scrollable])?; - let t = b.create(Class::Label, row)?; - b.size(t, TEXT_W, 40)?; - b.long_mode(t, LongMode::Dot)?; - b.text(t, name)?; - b.align(t, Align::LeftMid, TEXT_X, -16)?; - b.flags(t, &[], &[Flag::Clickable, Flag::Scrollable])?; - let d = b.create(Class::Label, row)?; - b.size(d, TEXT_W, 30)?; - b.long_mode(d, LongMode::Dot)?; - b.style(d, Prop::TextFont, 0, F24 as i32)?; - b.style(d, Prop::TextColor, 0, GREY)?; - b.text(d, detail)?; - b.align(d, Align::LeftMid, TEXT_X, 20)?; - b.flags(d, &[], &[Flag::Clickable, Flag::Scrollable])?; - s.rows[i] = row; - s.row_count = (i + 1) as u8; - } - s.back_btn = back_button(b, flush)?; - Ok(s) -} - -/// The root categories the phone sent. -pub fn browse(b: &mut Batch, flush: Flush, m: &Model) -> Result { - room(b, flush)?; - let (page, _bar) = stock::focus_page(b, 0)?; - opaque(b, page)?; - let mut s = Screen { kind: Kind::Browse, page, ..EMPTY }; - s.title = heading(b, flush, page, "Metrolist", stock::FOCUS_ROW_H)?; - if m.root_count == 0 { - s.hint = hint(b, flush, page, if m.alive(m.last_rx) { "No categories yet" } else { "Waiting for Metrolist on your phone" })?; - return Ok(s); - } - for (i, cat) in m.root.iter().enumerate().take(m.root_count as usize) { - s.rows[i] = focus_row(b, flush, page, cat.label(), if cat.is_folder() { "" } else { "Songs" })?; - s.row_count = (i + 1) as u8; - } - Ok(s) -} - -/// The open node: folders, or songs that start a queue. -pub fn list(b: &mut Batch, flush: Flush, m: &Model) -> Result { - room(b, flush)?; - let (page, _bar) = stock::focus_page(b, 0)?; - opaque(b, page)?; - let mut s = Screen { kind: Kind::List, page, ..EMPTY }; - s.title = heading(b, flush, page, m.list_title(), stock::FOCUS_ROW_H)?; - if !m.list_ready { - s.hint = hint(b, flush, page, "Loading...")?; - return Ok(s); - } - if m.item_count == 0 { - s.hint = hint(b, flush, page, match m.list_code { - 1 => "Metrolist could not load this", - 2 => "Metrolist is not ready", - _ => "Nothing here yet", - })?; - return Ok(s); - } - status_bar(b, &mut s)?; - for i in 0..m.item_count as usize { - let item = &m.items[i]; - let detail = if item.artist().is_empty() { "" } else { item.artist() }; - s.rows[i] = focus_row(b, flush, page, item.title(), detail)?; - s.row_ids[i] = item.id; - s.row_count = (i + 1) as u8; - } - Ok(s) -} - -/// A fixed status line at the bottom of a song list. It shows the play round trip: "Playing..." while the -/// phone works, then its ack or "no answer". Idle until `show_status` fills it. -fn status_bar(b: &mut Batch, s: &mut Screen) -> Result<(), LvError> { - let bar = b.create(Class::Obj, ROOT)?; - b.size(bar, SCREEN, 56)?; - b.align(bar, Align::BottomMid, 0, 0)?; - b.style(bar, Prop::BgColor, 0, stock::BLACK)?; - b.style(bar, Prop::BgOpa, 0, 0)?; - b.style(bar, Prop::BorderWidth, 0, 0)?; - b.style(bar, Prop::Radius, 0, 0)?; - b.flags(bar, &[], &[Flag::Clickable, Flag::Scrollable])?; - let t = b.create(Class::Label, bar)?; - b.size(t, SCREEN - 40, 40)?; - b.long_mode(t, LongMode::Dot)?; - b.style(t, Prop::TextAlign, 0, 2)?; // LV_TEXT_ALIGN_CENTER - b.style(t, Prop::TextColor, 0, GREY)?; - b.text(t, "")?; - b.align(t, Align::Center, 0, 0)?; - b.flags(t, &[], &[Flag::Clickable, Flag::Scrollable])?; - s.status = bar; - s.hint = t; - Ok(()) -} - -/// Fills (text non-empty) or clears the song list's fixed status line. -pub fn show_status(b: &mut Batch, s: &Screen, text: &str) -> Result<(), LvError> { - if s.hint == ROOT || s.status == ROOT { - return Ok(()); - } - b.text(s.hint, text)?; - b.style(s.status, Prop::BgOpa, 0, if text.is_empty() { 0 } else { 255 }) -} - -/// Shown when the watch's loader has no bitmap assets: it refuses the player's image records before any of the batch -/// runs, so the app says why instead of leaving a black screen. -pub fn notice(b: &mut Batch, flush: Flush) -> Result { - room(b, flush)?; - let mut s = Screen { kind: Kind::Home, ..EMPTY }; - let body = page_black(b, ROOT)?; - s.page = body; - s.hint = hint(b, flush, body, "Metrolist needs an App Loader from 2026-11-27 for its icons")?; - Ok(s) -} - -fn hint(b: &mut Batch, flush: Flush, page: Obj, text: &str) -> Result { - room(b, flush)?; - let l = b.create(Class::Label, page)?; - b.size(l, ROW_W - 48, 96)?; - b.long_mode(l, LongMode::Wrap)?; - b.style(l, Prop::TextFont, 0, F24 as i32)?; - b.style(l, Prop::TextColor, 0, GREY)?; - b.style(l, Prop::TextAlign, 0, 2)?; - b.text(l, text)?; - b.align(l, Align::Center, 0, 20)?; - b.flags(l, &[], &[Flag::Clickable, Flag::Scrollable])?; - Ok(l) -} - -// ---- the artwork's colour ----------------------------------------------------------------------------------------- - -/// `c`'s channels: red and blue 0..=31, green 0..=63. -fn channels(c: u16) -> (u32, u32, u32) { - (((c >> 11) & 31) as u32, ((c >> 5) & 63) as u32, (c & 31) as u32) -} - -fn pack(r: u32, g: u32, b: u32) -> i32 { - ((r.min(31) << 11) | (g.min(63) << 5) | b.min(31)) as i32 -} - -/// `c` at `k / 256` of its brightness, as a style value. -fn shade(c: u16, k: u32) -> i32 { - let (r, g, b) = channels(c); - pack(r * k / 256, g * k / 256, b * k / 256) -} - -/// The progress ring's track: the same colour, dimmer. It is never white, so the ring cannot read as an outline -/// around the play button; without a colour it is the stock row grey. -fn track_colour(c: u16) -> i32 { - if c == 0 { - ROW_BG - } else { - shade(c, 118) - } -} - -/// Smoothstep of `t` (0..=256) as 0..=256: soft at both ends, so the bands do not read as steps. -fn smooth(t: u32) -> u32 { - t * t * (768 - 2 * t) / (256 * 256) -} - -/// The glow's shade at radius `r`: the artwork's colour at full strength in the middle, black at the outermost band. -/// Half straight ramp, half smoothstep: a plain smoothstep dropped to a fifth of the colour by mid-screen, which read -/// as a small hot spot rather than a glow. -fn glow_shade(c: u16, r: i32) -> i32 { - let span = (GLOW_OUT - GLOW_IN).max(1); - let d = (((r - GLOW_IN).max(0)) * 256 / span).min(256) as u32; - let f = ((256 - d) + (256 - smooth(d))) / 2; - shade(c, f * GLOW_BRIGHT / 256) -} - -/// The artwork's colour behind everything, as opaque arcs from the outside in. -/// -/// A fixed grid of equal bands looked stepped, and more bands did not help: the screen stores colours as RGB565, so -/// the ramp only *has* a few dozen distinguishable shades and a grid puts several bands on the same one and then -/// jumps. Here every integer radius is read and all the radii that round to the same RGB565 value are merged into a -/// single arc, so each band begins exactly where the colour really changes and is exactly as wide as that shade lasts. -/// That is the smoothest a band renderer can do at this depth, and it costs fewer objects than a 40-band grid, not -/// more: a dim sleeve uses a handful of bands. -fn glow( - b: &mut Batch, - flush: Flush, - parent: Obj, - colour: u16, - out: &mut [Obj; GLOW_BANDS], -) -> Result<(), LvError> { - let mut r_out = GLOW_OUT; - for slot in out.iter_mut() { - if r_out <= GLOW_IN { - break; - } - let c = glow_shade(colour, r_out); - let mut r_in = r_out - 1; - while r_in > GLOW_IN && glow_shade(colour, r_in) == c { - r_in -= 1; - } - room(b, flush)?; - let a = b.create(Class::Arc, parent)?; - b.size(a, r_out * 2, r_out * 2)?; - b.align(a, Align::Center, 0, DISC_Y)?; - b.angles(a, 0, 360, 0)?; - b.value(a, 0, false)?; - b.style(a, Prop::ArcWidth, 0, (r_out - r_in).max(1))?; - b.style(a, Prop::ArcRounded, 0, 0)?; - b.style(a, Prop::ArcColor, 0, c)?; - b.style(a, Prop::ArcOpa, 0, 255)?; - b.style(a, Prop::ArcOpa, stock::INDICATOR, 0)?; - b.style(a, Prop::BgOpa, stock::KNOB, 0)?; - b.flags(a, &[], &[Flag::Clickable, Flag::Scrollable])?; - *slot = a; - r_out = r_in; - } - Ok(()) -} - -fn page_black(b: &mut Batch, parent: Obj) -> Result { - let page = b.create(Class::Obj, parent)?; - b.size(page, SCREEN, SCREEN)?; - for p in [Prop::PadTop, Prop::PadBottom, Prop::PadLeft, Prop::PadRight, Prop::BorderWidth, Prop::Radius] { - b.style(page, p, 0, 0)?; - } - b.style(page, Prop::BgColor, 0, stock::BLACK)?; - b.style(page, Prop::BgOpa, 0, 255)?; - b.flags(page, &[], &[Flag::Scrollable])?; - // the crown comes to the app (the volume), the page does not scroll - b.knob(page)?; - Ok(page) -} - -/// A stock page is transparent and relies on the loader's black screen behind it; a screen of this app paints its own -/// black, so one that is left behind (or not yet deleted) can never show through the next. -fn opaque(b: &mut Batch, page: Obj) -> Result<(), LvError> { - b.style(page, Prop::BgColor, 0, stock::BLACK)?; - b.style(page, Prop::BgOpa, 0, 255) -} - -/// A centred label whose `y` is its own centre on the screen, so a negative `y` sits above the middle. -fn centred(b: &mut Batch, parent: Obj, y: i16, w: i32, h: i32, text: &str, colour: i32, font: Option) -> Result { - let l = b.create(Class::Label, parent)?; - b.size(l, w, h)?; - b.long_mode(l, LongMode::Dot)?; - b.style(l, Prop::TextAlign, 0, 2)?; - b.style(l, Prop::TextColor, 0, colour)?; - if let Some(f) = font { - b.style(l, Prop::TextFont, 0, f as i32)?; - } - b.text(l, text)?; - b.align(l, Align::Center, 0, y)?; - b.flags(l, &[], &[Flag::Clickable, Flag::Scrollable])?; - Ok(l) -} - -fn round_btn(b: &mut Batch, parent: Obj, size: i32, x: i16, y: i16, fill: i32, opa: i32) -> Result { - let btn = b.create(Class::Btn, parent)?; - b.size(btn, size, size)?; - b.align(btn, Align::Center, x, y)?; - b.style(btn, Prop::Radius, 0, CIRCLE)?; - b.style(btn, Prop::BgColor, 0, fill)?; - b.style(btn, Prop::BgOpa, 0, opa)?; - b.style(btn, Prop::BgColor, stock::PRESSED, WHITE)?; - // Dim: the icon keeps its black plate while the button lights up behind it, so a strong flash would show the plate. - b.style(btn, Prop::BgOpa, stock::PRESSED, 40)?; - b.style(btn, Prop::BorderWidth, 0, 0)?; - b.events(btn, &[Ev::Clicked])?; - Ok(btn) -} - -/// The player: the phone's current track, play / pause, previous / next, the volume on the crown and the queue. One -/// page; the queue is its own screen ([`queue`]), opened by the bottom row's Queue button. -pub fn controller(b: &mut Batch, flush: Flush, m: &Model, clock: &str) -> Result { - room(b, flush)?; - let mut s = Screen { kind: Kind::Controller, ..EMPTY }; - let body = page_black(b, ROOT)?; - s.page = body; - // Behind everything: the artwork's colour as a soft glow around the play button, fading into the black page. - glow(b, flush, body, m.now.colour, &mut s.glow)?; - s.clock = centred(b, body, CLOCK_Y, 160, 22, clock, GREY, Some(F24))?; - // One line each: the title centred when it fits and a marquee when it does not, never wrapped (a second line would - // push the artist down into the play disc). - s.title = centred(b, body, TITLE_Y, TITLE_BOX, TITLE_H, m.now.title(), WHITE, Some(F36))?; - s.title_roll = scroller(b, body, TITLE_Y, TITLE_BOX, TITLE_H, m.now.title(), WHITE, F36)?; - s.artist = centred(b, body, ARTIST_Y, TITLE_BOX, ARTIST_H, m.now.artist(), GREY, Some(F24))?; - show_track(b, &s, m.now.title())?; - - // The progress ring around the play button: the artwork's colour as a dim track, the played part white. The track - // is never white, so a fresh track (0 %) does not draw a white circle around the button. - room(b, flush)?; - let ring = b.create(Class::Arc, body)?; - b.size(ring, RING, RING)?; - b.align(ring, Align::Center, 0, DISC_Y)?; - b.angles(ring, 0, 360, 270)?; - b.value(ring, m.now.pos.min(100) as i32, false)?; - b.style(ring, Prop::ArcWidth, 0, RING_W)?; - b.style(ring, Prop::ArcRounded, 0, 1)?; - b.style(ring, Prop::ArcColor, 0, track_colour(m.now.colour))?; - b.style(ring, Prop::ArcOpa, 0, 255)?; - b.style(ring, Prop::ArcColor, stock::INDICATOR, WHITE)?; - b.style(ring, Prop::ArcOpa, stock::INDICATOR, 255)?; - b.style(ring, Prop::BgOpa, stock::KNOB, 0)?; - b.flags(ring, &[], &[Flag::Clickable, Flag::Scrollable])?; - s.progress = ring; - - s.play = round_btn(b, body, DISC, 0, DISC_Y, stock::BLACK, 255)?; - s.pause_icon = icon(b, flush, s.play, &bitmaps::PAUSE, 0, 0)?; - s.play_icon = icon(b, flush, s.play, &bitmaps::PLAY_ARROW, 2, 0)?; - - s.prev = round_btn(b, body, SIDE, -SIDE_X, DISC_Y, stock::BLACK, 255)?; - icon(b, flush, s.prev, &bitmaps::SKIP_PREVIOUS, 0, 0)?; - s.next = round_btn(b, body, SIDE, SIDE_X, DISC_Y, stock::BLACK, 255)?; - icon(b, flush, s.next, &bitmaps::SKIP_NEXT, 0, 0)?; - - s.vol = icon_pill(b, flush, body, -PILL_X, BOTTOM_Y, &bitmaps::VOLUME_UP)?; - s.queue_btn = icon_pill(b, flush, body, PILL_X, BOTTOM_Y, &bitmaps::QUEUE_MUSIC)?; - - show_now(b, flush, &s, m, false)?; - Ok(s) -} - -/// The phone's queue: the current entry filled, each row a tap that plays that queue position, and a fixed Back pill -/// at the bottom that only goes back. -pub fn queue(b: &mut Batch, flush: Flush, m: &Model) -> Result { - room(b, flush)?; - let (page, _bar) = stock::focus_page(b, 0)?; - opaque(b, page)?; - let mut s = Screen { kind: Kind::Queue, page, ..EMPTY }; - s.title = heading(b, flush, page, "Queue", stock::FOCUS_ROW_H)?; - if m.queue_count == 0 { - let text = if m.alive(m.last_rx) { "Nothing queued yet" } else { "Waiting for phone" }; - s.hint = hint(b, flush, page, text)?; - } else { - for i in 0..m.queue_count as usize { - let item = &m.queue[i]; - let detail = if item.artist().is_empty() { "" } else { item.artist() }; - let row = focus_row(b, flush, page, item.title(), detail)?; - s.queue_rows[i] = row; - s.queue_count = (i + 1) as u8; - } - } - s.back_btn = back_button(b, flush)?; - show_queue(b, &s, m)?; - Ok(s) -} - -/// The volume screen: the phone's own media volume on a slider. The watch cannot read that level back (the loader -/// offers the phone's volume keys, not its value), so the slider is the app's own fifteen-step track: every step it -/// moves presses a key once, and the crown moves the same track. -pub fn volume(b: &mut Batch, flush: Flush, level: u8) -> Result { - room(b, flush)?; - let mut s = Screen { kind: Kind::Volume, ..EMPTY }; - let body = page_black(b, ROOT)?; - s.page = body; - s.clock = centred(b, body, VOL_TITLE_Y, 300, 40, "Volume", WHITE, Some(F36))?; - s.hint = centred(b, body, VOL_MSG_Y, 380, 36, VOL_MSG, GREY, Some(F24))?; - room(b, flush)?; - let slider = b.create(Class::Slider, body)?; - b.size(slider, VOL_SLIDER_W, VOL_SLIDER_H)?; - b.align(slider, Align::Center, 0, VOL_SLIDER_Y)?; - b.range(slider, 0, VOL_STEPS)?; - b.value(slider, (level as i32).min(VOL_STEPS), false)?; - // White on the stock row grey, rather than the stock accent: this is the volume the phone will play at. - for (part, colour) in [(0, VOL_TRACK), (stock::INDICATOR, WHITE), (stock::KNOB, WHITE)] { - b.style(slider, Prop::BgColor, part, colour)?; - b.style(slider, Prop::BgOpa, part, 255)?; - b.style(slider, Prop::Radius, part, CIRCLE)?; - } - b.style(slider, Prop::BorderWidth, 0, 0)?; - b.events(slider, &[Ev::ValueChanged])?; - s.volume = slider; - s.back_btn = back_button(b, flush)?; - Ok(s) -} - -/// The search screen: the typed query and the app's own QWERTY keyboard. The Search key sends the query to the phone, -/// which answers with a list for `SEARCH_NODE`; the list screen draws the five best matches, so a tap plays from them -/// like any other song list. -pub fn search(b: &mut Batch, flush: Flush, query: &str) -> Result { - room(b, flush)?; - let mut s = Screen { kind: Kind::Search, ..EMPTY }; - let body = page_black(b, ROOT)?; - s.page = body; - room(b, flush)?; - let field = b.create(Class::Obj, body)?; - b.size(field, SEARCH_BOX_W, SEARCH_BOX_H)?; - b.align(field, Align::Center, 0, SEARCH_BOX_Y)?; - b.style(field, Prop::Radius, 0, SEARCH_BOX_R)?; - b.style(field, Prop::BgColor, 0, stock::ROW_BG)?; - b.style(field, Prop::BgOpa, 0, 255)?; - b.style(field, Prop::BorderWidth, 0, 0)?; - b.flags(field, &[], &[Flag::Clickable, Flag::Scrollable])?; - s.query = centred( - b, - field, - 0, - SEARCH_BOX_W - 28, - 40, - if query.is_empty() { QUERY_HINT } else { query }, - if query.is_empty() { GREY } else { WHITE }, - Some(F24), - )?; - - let rows = ["qwertyuiop", "asdfghjkl", "zxcvbnm"]; - for (r, letters) in rows.iter().enumerate() { - let count = letters.len() as i32; - for (i, ch) in letters.chars().enumerate() { - let x = ((i as i32 * 2 - (count - 1)) * (SEARCH_KEY_W + SEARCH_KEY_GAP as i32)) / 2; - let mut glyph = [0u8; 4]; - let label = ch.encode_utf8(&mut glyph); - let key = search_key(b, flush, body, x as i16, KEY_Y[r], SEARCH_KEY_W, &*label, stock::ROW_BG)?; - s.keys[s.key_count as usize] = key; - // The code is the letter's index in the alphabet, not its place in the row: `h` is 7 whatever row it is - // on (the row index here is what made the bottom rows type the wrong letters). - s.key_codes[s.key_count as usize] = ch as u8 - b'a'; - s.key_count += 1; - } - } - // DEL, space and Search on one line, in the phone keyboard's order. - let bottom: [(i16, i32, &str, u8, i32); 3] = [ - (-90, 48, "DEL", KEY_DEL, stock::ROW_BG), - (-10, 104, "space", KEY_SPACE, stock::ROW_BG), - (80, 68, "Search", KEY_GO, SEARCH_RED), - ]; - s.back_btn = back_button(b, flush)?; - for (x, w, label, code, fill) in bottom { - let key = search_key(b, flush, body, x, KEY_Y[3], w, label, fill)?; - s.keys[s.key_count as usize] = key; - s.key_codes[s.key_count as usize] = code; - s.key_count += 1; - } - Ok(s) -} - -/// One key of the search keyboard: a rounded stock button with a label. The app reads the tap, so no text area and no -/// loader input device are involved. -fn search_key( - b: &mut Batch, - flush: Flush, - parent: Obj, - x: i16, - y: i16, - w: i32, - label: &str, - fill: i32, -) -> Result { - room(b, flush)?; - let key = b.create(Class::Btn, parent)?; - b.size(key, w, SEARCH_KEY_H)?; - b.align(key, Align::Center, x, y)?; - b.style(key, Prop::Radius, 0, 14)?; - b.style(key, Prop::BgColor, 0, fill)?; - b.style(key, Prop::BgOpa, 0, 255)?; - b.style(key, Prop::BgColor, stock::PRESSED, WHITE)?; - b.style(key, Prop::BgOpa, stock::PRESSED, 60)?; - b.style(key, Prop::BorderWidth, 0, 0)?; - b.events(key, &[Ev::Clicked])?; - let text = b.create(Class::Label, key)?; - b.text(text, label)?; - b.style(text, Prop::TextFont, 0, F24 as i32)?; - b.align(text, Align::Center, 0, 0)?; - b.flags(text, &[], &[Flag::Clickable, Flag::Scrollable])?; - Ok(key) -} - -/// The query box follows the typed text; the hint stays grey until there is something to search. -pub fn show_query(b: &mut Batch, s: &Screen, query: &str) -> Result<(), LvError> { - if s.query == ROOT { - return Ok(()); - } - let empty = query.is_empty(); - b.text(s.query, if empty { QUERY_HINT } else { query })?; - b.style(s.query, Prop::TextColor, 0, if empty { GREY } else { WHITE }) -} - -/// The volume screen follows the app's track, and says why a step did nothing ([`VOL_MSG`] again when it worked). -pub fn show_volume(b: &mut Batch, s: &Screen, level: u8, text: &str) -> Result<(), LvError> { - if s.volume != ROOT { - b.value(s.volume, (level as i32).min(VOL_STEPS), false)?; - } - if s.hint == ROOT { - return Ok(()); - } - b.text(s.hint, text) -} - -/// The pause icon while it plays, the play icon while it is paused: one flag record each, so the two can never be left -/// showing at once (with a record per piece, a batch that ran out between them did exactly that). -pub fn show_state(b: &mut Batch, s: &Screen, playing: bool) -> Result<(), LvError> { - // `flags(set, clear)`. While it plays the pause bars are up, because a tap then pauses it; while it is paused, the - // triangle is. (Read the other way round the two swap, which is exactly what a reversed button looks like.) - let hidden = &[Flag::Hidden][..]; - let shown: &[Flag] = &[]; - if s.pause_icon != ROOT { - let (set, clear) = if playing { (shown, hidden) } else { (hidden, shown) }; - b.flags(s.pause_icon, set, clear)?; - } - if s.play_icon != ROOT { - let (set, clear) = if playing { (hidden, shown) } else { (shown, hidden) }; - b.flags(s.play_icon, set, clear)?; - } - Ok(()) -} - -/// The title's box: wide enough for about twenty characters of the heading face. -pub const TITLE_BOX: i32 = 380; -/// A rough advance for one character of F36. Only used to decide whether the title has to scroll and how far the -/// marquee travels: a title this underestimates is ellipsised, one it overestimates scrolls a little and repeats. -const TITLE_CHAR: i32 = 20; - -/// The title's width in px, as well as it can be told without measuring glyphs. -pub fn title_width(text: &str) -> i32 { - (text.chars().count() as i32) * TITLE_CHAR -} - -/// True when the title is too wide for its box, so the marquee takes over from the centred one-line label. -pub fn title_rolls(text: &str) -> bool { - title_width(text) > TITLE_BOX -} - -/// The marquee: a window the width of the title's box with a label as wide as the text inside it. [`roll_to`] slides -/// the label and the window cuts off whatever runs past it. -/// -/// LVGL's own `SCROLL_CIRCULAR` was tried first and never ran here; a slide the app steps itself needs nothing from -/// the host's animation timer, only the loop the app already has. -fn scroller( - b: &mut Batch, - parent: Obj, - y: i16, - w: i32, - h: i32, - text: &str, - colour: i32, - font: u8, -) -> Result { - let win = b.create(Class::Obj, parent)?; - b.size(win, w, h)?; - b.align(win, Align::Center, 0, y)?; - b.style(win, Prop::BgOpa, 0, 0)?; - b.style(win, Prop::BorderWidth, 0, 0)?; - b.style(win, Prop::Radius, 0, 0)?; - b.flags(win, &[], &[Flag::Clickable, Flag::Scrollable])?; - // No size is set on the label: it keeps its content width, so the text is never wrapped or cut by the label - // itself, only by the window around it. - let l = b.create(Class::Label, win)?; - b.style(l, Prop::TextColor, 0, colour)?; - b.style(l, Prop::TextFont, 0, font as i32)?; - b.text(l, text)?; - b.align(l, Align::LeftMid, 0, 0)?; - b.flags(l, &[Flag::Hidden], &[Flag::Clickable, Flag::Scrollable])?; - Ok(l) -} - -/// Slide the marquee `x` px left of its start; 0 shows the beginning of the title. -pub fn roll_to(b: &mut Batch, s: &Screen, x: i16) -> Result<(), LvError> { - if s.title_roll == ROOT { - return Ok(()); - } - b.style(s.title_roll, Prop::TranslateX, 0, -(x as i32)) -} - -/// The track's title: the centred label when it fits, the marquee when it does not. Only the label that is shown gets -/// the text, and the marquee always starts at the beginning of it. -pub fn show_track(b: &mut Batch, s: &Screen, text: &str) -> Result<(), LvError> { - let fit = !title_rolls(text); - if s.title != ROOT { - if fit { - b.text(s.title, text)?; - } - b.flags(s.title, if fit { &[] } else { &[Flag::Hidden] }, if fit { &[Flag::Hidden] } else { &[] })?; - } - if s.title_roll != ROOT { - if !fit { - b.text(s.title_roll, text)?; - roll_to(b, s, 0)?; - } - b.flags(s.title_roll, if fit { &[Flag::Hidden] } else { &[] }, if fit { &[] } else { &[Flag::Hidden] })?; - } - Ok(()) -} - -/// `HH:MM`. -pub fn clock_text(hour: u8, minute: u8, buf: &mut [u8; 5]) -> &str { - *buf = [b'0' + hour / 10 % 10, b'0' + hour % 10, b':', b'0' + minute / 10 % 10, b'0' + minute % 10]; - core::str::from_utf8(buf).unwrap_or("") -} - -/// The track, its state and the progress follow the model. `force` rewrites every label. -pub fn show_now(b: &mut Batch, _flush: Flush, s: &Screen, m: &Model, force: bool) -> Result<(), LvError> { - // The title is not written here: a marquee restarts on every write, and the phone repeats the same title with each - // progress frame. [`show_track`] is called only when the text really changed. - if force && s.artist != ROOT { - b.text(s.artist, m.now.artist())?; - } - if s.progress != ROOT { - b.value(s.progress, m.now.pos.min(100) as i32, false)?; - } - show_state(b, s, m.now.playing) -} - -/// The queue's playing entry is the filled one (the fisheye's CHECKED alone would move with the scroll). -pub fn show_queue(b: &mut Batch, s: &Screen, m: &Model) -> Result<(), LvError> { - for i in 0..s.queue_count as usize { - let on = i == m.queue_current as usize; - b.style(s.queue_rows[i], Prop::BgColor, 0, ROW_BG)?; - b.style(s.queue_rows[i], Prop::BgOpa, 0, if on { 255 } else { 0 })?; - } - Ok(()) -} - -pub fn show_title(b: &mut Batch, s: &Screen, m: &Model) -> Result<(), LvError> { - b.text(s.title, m.list_title()) -} - -pub fn show_clock(b: &mut Batch, s: &Screen, text: &str) -> Result<(), LvError> { - if s.clock == ROOT { Ok(()) } else { b.text(s.clock, text) } -} - -/// True when `handle` is one of the screen's clickable rows. -pub fn row_at(s: &Screen, handle: u16) -> Option { - s.rows.iter().take(s.row_count as usize).position(|r| r.0 == handle && handle != ROOT.0) -} - -/// True when `handle` is one of the queue screen's rows. -pub fn queue_at(s: &Screen, handle: u16) -> Option { - s.queue_rows.iter().take(s.queue_count as usize).position(|r| r.0 == handle && handle != ROOT.0) -} - -/// The code of the search keyboard's key `handle`, or `None` when it is not a key. -pub fn key_at(s: &Screen, handle: u16) -> Option { - s.keys - .iter() - .take(s.key_count as usize) - .position(|k| k.0 == handle && handle != ROOT.0) - .map(|i| s.key_codes[i]) -} - -#[cfg(test)] -mod tests { - extern crate std; - use super::*; - use std::boxed::Box; - use wp2_core::lvcmd::{self, Table}; - - struct Loader { - t: Table, - live_max: usize, - } - - impl Loader { - fn flush(&mut self, b: &mut Batch) -> Result<(), LvError> { - if b.bytes().is_empty() { - return Ok(()); - } - // slots 0 (system), 1 (F24) and 2 (F36) are open - assert_eq!(lvcmd::validate(b.bytes(), &self.t, 0b0111), Ok(())); - for r in lvcmd::records(b.bytes()) { - lvcmd::apply(&mut self.t, &r.unwrap()); - } - let live = (1..=192u16).filter(|&h| self.t.class(h).is_some()).count(); - self.live_max = self.live_max.max(live); - b.clear(); - Ok(()) - } - } - - fn model() -> Model { - let mut m = Model::new(); - m.connected = true; - m.apply( - &[ - b'M', b'1', b'C', 5, 1, KIND_SONGS, 11, b'Q', b'u', b'i', b'c', b'k', b' ', b'p', b'i', b'c', b'k', b's', - 0x34, 0x12, 2, KIND_SONGS, 12, b'L', b'i', b's', b't', b'e', b'n', b' ', b'a', b'g', b'a', b'i', b'n', - 0x45, 0x23, 3, KIND_FOLDER, 9, b'D', b'o', b'w', b'n', b'l', b'o', b'a', b'd', b's', 0x56, 0x34, 4, - KIND_FOLDER, 7, b'L', b'i', b'b', b'r', b'a', b'r', b'y', 0x67, 0x45, 5, KIND_FOLDER, 7, b'E', b'x', b'p', - b'l', b'o', b'r', b'e', 0x78, 0x56, - ], - 1, - ); - m.push(3, "Downloads"); - let mut f = std::vec![b'M', b'1', b'B', 3, KIND_SONGS, 20, 15]; - f.extend_from_slice(b"Downloaded songs"); - m.apply(&f, 2); - for start in [0u8, 2] { - let mut f = std::vec![b'M', b'1', b'I', 3, start, 2]; - for k in 0..2u8 { - let title = std::format!("Track number {}", start + k); - f.push(title.len() as u8); - f.extend_from_slice(title.as_bytes()); - f.push(11); - f.extend_from_slice(b"Some Artist"); - f.extend_from_slice(&0x1234u16.to_le_bytes()); - f.push(NONE); - } - m.apply(&f, 3); - } - m.apply(&[b'M', b'1', b'E', 3, 4], 4); - // a two-entry queue with the second one playing - m.apply(&[b'M', b'1', b'Q', 2, 1], 5); - let mut q = std::vec![b'M', b'1', b'J', 0, 2]; - for title in ["Queue song one", "Queue song two"] { - q.push(title.len() as u8); - q.extend_from_slice(title.as_bytes()); - q.push(6); - q.extend_from_slice(b"Artist"); - q.extend_from_slice(&0x1234u16.to_le_bytes()); - } - m.apply(&q, 6); - m.now.title[..9].copy_from_slice(b"Song name"); - m.now.tlen = 9; - m.now.artist[..11].copy_from_slice(b"Artist name"); - m.now.alen = 11; - m.now.has = true; - m.now.playing = true; - m.now.pos = 40; - m.now.colour = 0x1F3E; - m - } - - fn with_loader(f: impl FnOnce(&mut Batch, &mut Loader)) { - let mut b = Batch::with_buf(Box::leak(Box::new([0; BUF]))); - fonts(&mut b).unwrap(); - let mut l = Loader { t: Table::new(), live_max: 0 }; - l.flush(&mut b).unwrap(); - f(&mut b, &mut l); - std::println!("most live objects: {}", l.live_max); - assert!(l.live_max < 190); - } - - #[test] - fn every_screen_validates_and_leaving_frees_it() { - with_loader(|b, l| { - theme(b).unwrap(); - let mut clock = [0u8; 5]; - let m = model(); - let text = clock_text(9, 30, &mut clock); - let mut s = home(b, &mut |b| l.flush(b)).unwrap(); - l.flush(b).unwrap(); - let first = s.page; - for kind in [ - Kind::Browse, - Kind::List, - Kind::Controller, - Kind::Queue, - Kind::Volume, - Kind::Search, - Kind::Home, - ] { - leave(b, &s).unwrap(); - l.flush(b).unwrap(); - s = match kind { - Kind::Home => home(b, &mut |b| l.flush(b)).unwrap(), - Kind::Browse => browse(b, &mut |b| l.flush(b), &m).unwrap(), - Kind::List => list(b, &mut |b| l.flush(b), &m).unwrap(), - Kind::Controller => controller(b, &mut |b| l.flush(b), &m, text).unwrap(), - Kind::Queue => queue(b, &mut |b| l.flush(b), &m).unwrap(), - Kind::Volume => volume(b, &mut |b| l.flush(b), 8).unwrap(), - Kind::Search => search(b, &mut |b| l.flush(b), "song").unwrap(), - }; - assert_eq!(s.page, first, "{kind:?} reuses the freed handles"); - l.flush(b).unwrap(); - // the runtime updates fit a batch too - if kind == Kind::Controller { - show_now(b, &mut |batch| l.flush(batch), &s, &m, true).unwrap(); - show_state(b, &s, false).unwrap(); - } - if kind == Kind::Volume { - assert_ne!(s.volume, ROOT); - assert_ne!(s.back_btn, ROOT); - show_volume(b, &s, 9, "No phone media").unwrap(); - show_volume(b, &s, 2, VOL_MSG).unwrap(); - } - if kind == Kind::Search { - assert_eq!(s.key_count, 29); - show_query(b, &s, "a").unwrap(); - show_query(b, &s, "").unwrap(); - } - if kind == Kind::Queue { - show_queue(b, &s, &m).unwrap(); - } - if kind == Kind::List { - show_title(b, &s, &m).unwrap(); - } - l.flush(b).unwrap(); - } - }); - } - - #[test] - fn the_controller_has_no_rows_and_the_queue_has_a_back_pill() { - let m = model(); - let mut b = Batch::with_buf(Box::leak(Box::new([0; BUF]))); - let mut flush = |batch: &mut Batch| { - batch.clear(); - Ok(()) - }; - let s = controller(&mut b, &mut flush, &m, "12:00").unwrap(); - assert_eq!(s.row_count, 0); - assert_eq!(s.queue_count, 0); - assert_ne!(s.queue_btn, ROOT); - assert_eq!(s.back_btn, ROOT); - assert_eq!(s.volume, ROOT); - let q = queue(&mut b, &mut flush, &m).unwrap(); - assert_eq!(q.kind, Kind::Queue); - assert_eq!(q.queue_count, 2); - assert_ne!(q.back_btn, ROOT); - } - - #[test] - fn rows_map_back_to_their_handles() { - let m = model(); - let mut b = Batch::with_buf(Box::leak(Box::new([0; BUF]))); - let mut flush = |batch: &mut Batch| { - batch.clear(); - Ok(()) - }; - let home_screen = home(&mut b, &mut flush).unwrap(); - assert_eq!(home_screen.row_count, 3); - assert_eq!(row_at(&home_screen, home_screen.rows[0].0), Some(0)); - assert_eq!(row_at(&home_screen, home_screen.rows[2].0), Some(2)); - assert_ne!(home_screen.back_btn, ROOT); - assert_eq!(row_at(&home_screen, ROOT.0), None); - let search_screen = search(&mut b, &mut flush, "").unwrap(); - assert_eq!(search_screen.key_count, 29); - assert_eq!(key_at(&search_screen, search_screen.keys[0].0), Some(16), "q is 16"); - assert_eq!(key_at(&search_screen, search_screen.keys[1].0), Some(22), "w is 22"); - // row two starts at `a` and row three at `z`, each with its letter's own code - assert_eq!(key_at(&search_screen, search_screen.keys[12].0), Some(3), "d is 3"); - assert_eq!(key_at(&search_screen, search_screen.keys[15].0), Some(7), "h is 7"); - assert_eq!(key_at(&search_screen, search_screen.keys[19].0), Some(25), "z is 25"); - assert_eq!(key_at(&search_screen, search_screen.keys[26].0), Some(KEY_DEL)); - assert_eq!(key_at(&search_screen, search_screen.keys[28].0), Some(KEY_GO)); - assert_ne!(search_screen.back_btn, ROOT); - assert_eq!(key_at(&search_screen, ROOT.0), None); - let list_screen = list(&mut b, &mut flush, &m).unwrap(); - assert_eq!(list_screen.row_count, 4); - assert_eq!(row_at(&list_screen, list_screen.rows[3].0), Some(3)); - let browse_screen = browse(&mut b, &mut flush, &m).unwrap(); - assert_eq!(browse_screen.row_count, 5); - assert_eq!(browse_screen.row_ids[0], NONE); - let queue_screen = queue(&mut b, &mut flush, &m).unwrap(); - assert_eq!(queue_at(&queue_screen, queue_screen.queue_rows[1].0), Some(1)); - assert_eq!(row_at(&queue_screen, queue_screen.queue_rows[1].0), None); - } - - #[test] - fn waiting_and_empty_lists_show_a_hint() { - let mut m = Model::new(); - let mut b = Batch::with_buf(Box::leak(Box::new([0; BUF]))); - let mut flush = |batch: &mut Batch| { - batch.clear(); - Ok(()) - }; - let s = browse(&mut b, &mut flush, &m).unwrap(); - assert_ne!(s.hint, ROOT); - assert_eq!(s.row_count, 0); - m.open(7, "Explore"); - let s = list(&mut b, &mut flush, &m).unwrap(); - assert_ne!(s.hint, ROOT); - m.list_ready = true; - m.list_code = 1; - let s = list(&mut b, &mut flush, &m).unwrap(); - assert_ne!(s.hint, ROOT); - } - - #[test] - fn clock_and_initial_text() { - let mut buf = [0u8; 5]; - assert_eq!(clock_text(7, 5, &mut buf), "07:05"); - assert_eq!(clock_text(23, 59, &mut buf), "23:59"); - } -} diff --git a/apps/metrolist/store.md b/apps/metrolist/store.md deleted file mode 100644 index bb53f01..0000000 --- a/apps/metrolist/store.md +++ /dev/null @@ -1,54 +0,0 @@ -# Metrolist - -Your Metrolist library on the watch: the categories the phone actually has content for, a list of songs for each, and -a player that controls what the phone plays. Picking a song starts a queue from that song; the audio always plays on -the phone. Empty shelves such as Quick picks stay off the watch until Metrolist has something to show there. - -The phone half is the open-source Metrolist app with the watch link added: download the APK from -, no Play Store and no account beyond your own YouTube Music. - -What lives in the app: - -- **Controller** — the phone's current track and its artist above the play button (a title too long for the row - scrolls round as a marquee), previous / play-pause / next around the centre, and a bottom row with one icon each for - Volume and Queue. The sleeve's dominant colour glows behind it (concentric bands: the watch's LVGL has no gradient), - the phone sends that one 16-bit value with the track, and the progress ring takes it too. The controls carry Google's - Material Icons — play, pause, skip back, skip forward, volume and queue — drawn from bitmaps in the package, each on - a black control of its own so the glow reads around it. The volume button opens its own screen: a tall white vertical - slider, or the crown, steps the phone's own media volume through the watch's media keys, and the Back arrow sits in - the top-left corner. The Queue button opens the phone's queue (up to 20 songs, the playing one filled); tap an entry to jump to - it in the same queue, and the Back arrow in the top-left corner returns to the player. -- **Start screen** — Search, Metrolist and Controller, a stock focus list that scrolls round the screen with the crown - or a drag, the row in the middle of the face carrying the only plate; the arrow in the top-left corner leaves the app. -- **Widget** — long press its row in Apps → Add widget and a card left of the watch face shows the track the phone - plays; a tap on the card opens the app. The card is written only when the track changes. -- **Page** — long press its row in Apps → Add page and the player sits next to the watch face, a swipe away, with no - browsing around it. -- **Metrolist** — the YouTube Music categories the phone's Metrolist app offers: Quick picks (the app's own shelf), Listen - again, Downloads, Library, Explore and the home shelves, including the ones that are shelves of albums. An album opens - its own track list, and a song tapped there plays the album from that song with the rest queued behind it. Downloads - and Library open their own sub-categories; Back walks up one step. -- **Search** — a keyboard on the watch (its own QWERTY grid, not the phone's, filling the bottom of the screen): type - a name, tap Search, and the phone answers with its five best matches. Choose one and it plays, with the rest of the - matches queued behind it; the Player and Queue screens are the same ones a browse tap leads to. Names arrive as - printable ASCII — typographic quotes and dashes become plain ones, accents are folded away and emoji are dropped — - because the watch's stock fonts have no glyph for anything else. - -Nothing personal crosses the watch's Bluetooth link: the account, the sign-in and the library stay in Metrolist on the -phone, and the watch only names a category, an item number, a search word and a play / pause / next command. - -## Requirements - -- **[Metrolist with the watch link](https://github.com/krtkygpta/metrolist/releases/latest)** on the phone: download - the APK (the release page also has the source, the `.wp2app` and the build instructions), install it next to your - existing Metrolist — the debug build is `com.metrolist.music.debug`, so nothing is overwritten — then open - **Settings → Watch** and turn the watch link on. Sign in to YouTube Music there; the watch has no account of its own. -- FMC patched firmware with the channel key and **the App Loader of 2026-11-27** — `loader-2026-11-27-2018e1a.wp2app`, - built from cmf-watch-sdk `2018e1a`. FMC still lists that loader under **Experimental**; install it from there. This app - needs exactly that one or newer: it owns Back, pages the controller sideways, draws with the stock LVGL widgets and - shows its icons from bitmap assets in the package, and an older loader ignores its own Back and the sideways paging. - Nothing re-pairs and Nothing X keeps working. -- Settings → Watch also installs the bundled Metrolist watch package over that same link: **Install Metrolist on - watch**. Keep the watch awake during the upload; no separate installer or second pairing is used. -- The watch and the phone on the same Bluetooth link: one central at a time, so no second device (a Mac, say) while - the phone is connected. diff --git a/apps/metrolist/store.toml b/apps/metrolist/store.toml deleted file mode 100644 index e857276..0000000 --- a/apps/metrolist/store.toml +++ /dev/null @@ -1,5 +0,0 @@ -name = "Metrolist" -summary = "Browse and play your Metrolist library from the watch, and control the phone's playback" -version = "0.13.0" -author = "CMF Tech Community" -screenshots = ["shots/player.jpg", "shots/home.jpg", "shots/queue.jpg"] diff --git a/apps/metronome/Cargo.toml b/apps/metronome/Cargo.toml deleted file mode 100644 index 0a516c0..0000000 --- a/apps/metronome/Cargo.toml +++ /dev/null @@ -1,12 +0,0 @@ -[package] -name = "metronome" -edition.workspace = true -license.workspace = true -version.workspace = true - -[dependencies] -cmf-wp2-app.workspace = true - -[[bin]] -name = "metronome" -bench = false diff --git a/apps/metronome/icon.svg b/apps/metronome/icon.svg deleted file mode 100644 index 9fa04db..0000000 --- a/apps/metronome/icon.svg +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/apps/metronome/src/lab.rs b/apps/metronome/src/lab.rs deleted file mode 100644 index 0af73bc..0000000 --- a/apps/metronome/src/lab.rs +++ /dev/null @@ -1,126 +0,0 @@ -#[derive(Clone, Copy, PartialEq, Debug)] -pub enum Field { - Bpm, - Beats, - Strength, -} - -#[derive(Clone, Copy, PartialEq, Debug)] -pub struct Settings { - pub bpm: u16, - pub beats_per_bar: u8, - pub strength_pct: u16, -} - -impl Default for Settings { - fn default() -> Self { - Settings { - bpm: 120, - beats_per_bar: 4, - strength_pct: 100, - } - } -} - -fn stepped(value: i32, clicks: i16, step: i32, min: i32, max: i32) -> i32 { - (value + clicks as i32 * step).clamp(min, max) -} - -impl Settings { - pub fn adjust(&mut self, field: Field, clicks: i16) { - match field { - Field::Bpm => self.bpm = stepped(self.bpm as i32, clicks, 1, 30, 260) as u16, - Field::Beats => self.beats_per_bar = stepped(self.beats_per_bar as i32, clicks, 1, 1, 8) as u8, - Field::Strength => self.strength_pct = stepped(self.strength_pct as i32, clicks, 10, 20, 100) as u16, - } - } - - pub fn adjust_bpm(&mut self, delta: i16) { - self.bpm = (self.bpm as i32 + delta as i32).clamp(30, 260) as u16; - } - - pub fn interval_ms(&self) -> u32 { - 60_000 / (self.bpm.max(1) as u32) - } - - pub fn pulse_params(&self, beat_index: u8) -> (u16, u16, u32) { - let is_accent = beat_index == 0 && self.beats_per_bar > 1; - let base_permille = self.strength_pct * 10; - if is_accent { - (base_permille.clamp(150, 1000), 31, 75) - } else { - ((base_permille * 3 / 4).clamp(100, 900), 62, 45) - } - } -} - -#[derive(Default)] -pub struct TapTracker { - last_ms: Option, - intervals: [u32; 4], - count: usize, - idx: usize, -} - -impl TapTracker { - pub fn tap(&mut self, now_ms: u32) -> Option { - let Some(prev) = self.last_ms else { - self.last_ms = Some(now_ms); - return None; - }; - let dt = now_ms.wrapping_sub(prev); - self.last_ms = Some(now_ms); - - // Сброс, если пауза больше 2 секунд (< 30 BPM) или случайный дребезг (< 200 мс) - if !(200..=2000).contains(&dt) { - self.count = 0; - self.idx = 0; - return None; - } - - self.intervals[self.idx] = dt; - self.idx = (self.idx + 1) % self.intervals.len(); - if self.count < self.intervals.len() { - self.count += 1; - } - - let sum: u32 = self.intervals[..self.count].iter().sum(); - let avg = sum / self.count as u32; - Some((60_000 / avg).clamp(30, 260) as u16) - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn bpm_clamps_and_interval() { - let mut s = Settings::default(); - assert_eq!(s.interval_ms(), 500); - s.adjust_bpm(-500); - assert_eq!(s.bpm, 30); - s.adjust_bpm(500); - assert_eq!(s.bpm, 260); - } - - #[test] - fn accent_on_first_beat() { - let s = Settings { bpm: 120, beats_per_bar: 4, strength_pct: 100 }; - let (d0, f0, ms0) = s.pulse_params(0); - let (d1, f1, ms1) = s.pulse_params(1); - assert!(d0 > d1 && ms0 > ms1); - assert_ne!(f0, f1); - } - - #[test] - fn tap_tempo_averages_and_resets() { - let mut t = TapTracker::default(); - assert_eq!(t.tap(1000), None); - assert_eq!(t.tap(1500), Some(120)); - assert_eq!(t.tap(2000), Some(120)); - // Пауза > 2000 мс сбрасывает серию - assert_eq!(t.tap(5000), None); - assert_eq!(t.tap(5400), Some(150)); - } -} diff --git a/apps/metronome/src/main.rs b/apps/metronome/src/main.rs deleted file mode 100644 index 0bd7ff9..0000000 --- a/apps/metronome/src/main.rs +++ /dev/null @@ -1,470 +0,0 @@ -#![cfg_attr(any(target_os = "none", wp2_sim), no_main, cfg_attr(target_os = "none", no_std))] - -mod lab; - -#[cfg(not(any(target_os = "none", wp2_sim)))] -fn main() {} - -#[cfg(any(target_os = "none", wp2_sim))] -mod device { - use crate::lab::{Field, Settings, TapTracker}; - use cmf_wp2_app::lv::{Align, Batch, Class, Ev, Flag, Lv, LvError, Obj, Prop, StockFont, ROOT}; - use cmf_wp2_app::stock::{self, ACCENT, BLACK, CIRCLE, GREY, PRESSED, ROW_BG, ROW_PRESSED, WHITE}; - use cmf_wp2_app::{Api, BUTTON, CROWN, LV, PAUSE, RESUME}; - use core::fmt::Write; - - cmf_wp2_app::entry!(main); - cmf_wp2_app::app_icon!(); - - const FONT_BIG: u8 = 1; - const FONT_SMALL: u8 = 2; - const CLICKED: i16 = 7; - const RED: i32 = 0xF800; - const MAX_DOTS: usize = 8; - - struct Line { - buf: [u8; 24], - len: usize, - } - - impl Line { - fn new() -> Self { - Line { buf: [0; 24], len: 0 } - } - fn as_str(&self) -> &str { - core::str::from_utf8(&self.buf[..self.len]).unwrap_or("") - } - } - - impl Write for Line { - fn write_str(&mut self, s: &str) -> core::fmt::Result { - let n = s.len().min(self.buf.len() - self.len); - self.buf[self.len..self.len + n].copy_from_slice(&s.as_bytes()[..n]); - self.len += n; - Ok(()) - } - } - - enum Screen { - Main { - root: Obj, - arc: Obj, - dots: [Obj; MAX_DOTS], - bpm_val: Obj, - btn_cfg: Obj, - cfg_lbl: Obj, - btn_minus: Obj, - btn_tap: Obj, - btn_plus: Obj, - btn_play: Obj, - play_lbl: Obj, - }, - Settings { - root: Obj, - card_beats: Obj, - beats_val: Obj, - card_power: Obj, - power_val: Obj, - btn_done: Obj, - }, - } - - fn make_container(b: &mut Batch) -> Result { - let root = b.create(Class::Obj, ROOT)?; - b.size(root, 466, 466)?; - for p in [Prop::PadTop, Prop::PadBottom, Prop::PadLeft, Prop::PadRight, Prop::BorderWidth, Prop::Radius, Prop::BgOpa] { - b.style(root, p, 0, 0)?; - } - b.flags(root, &[], &[Flag::Scrollable])?; - Ok(root) - } - - fn make_pill(b: &mut Batch, parent: Obj, w: i32, h: i32, bg: i32, bg_press: i32, text: &str, fg: i32, font: Option) -> Result<(Obj, Obj), LvError> { - let btn = b.create(Class::Obj, parent)?; - b.size(btn, w, h)?; - b.style(btn, Prop::BgColor, 0, bg)?; - b.style(btn, Prop::BgColor, PRESSED, bg_press)?; - b.style(btn, Prop::BgOpa, 0, 255)?; - b.style(btn, Prop::Radius, 0, CIRCLE)?; - b.style(btn, Prop::BorderWidth, 0, 0)?; - b.flags(btn, &[], &[Flag::Scrollable])?; - b.events(btn, &[Ev::Clicked])?; - - let lbl = b.create(Class::Label, btn)?; - if let Some(f) = font { - b.style(lbl, Prop::TextFont, 0, f as i32)?; - } - b.style(lbl, Prop::TextColor, 0, fg)?; - b.text(lbl, text)?; - b.align(lbl, Align::Center, 0, 0)?; - Ok((btn, lbl)) - } - - fn build_main(b: &mut Batch, lv: &Lv, settings: &Settings, running: bool, beat: u8) -> Result { - b.clear(); - stock::theme(b)?; - let root = make_container(b)?; - - let arc = b.create(Class::Arc, root)?; - b.size(arc, 448, 448)?; - b.align(arc, Align::Center, 0, 0)?; - b.angles(arc, 0, 360, 270)?; - b.value(arc, 0, false)?; - stock::arc(b, arc, 10)?; - b.flags(arc, &[], &[Flag::Clickable])?; - - let mut dots = [ROOT; MAX_DOTS]; - for d in dots.iter_mut() { - let dot = b.create(Class::Obj, root)?; - b.size(dot, 22, 10)?; - b.style(dot, Prop::Radius, 0, CIRCLE)?; - b.style(dot, Prop::BgColor, 0, ROW_BG)?; - b.style(dot, Prop::BgOpa, 0, 255)?; - b.style(dot, Prop::BorderWidth, 0, 0)?; - b.flags(dot, &[], &[Flag::Clickable])?; - *d = dot; - } - b.submit(lv)?; - b.clear(); - - let bpm_val = b.create(Class::Label, root)?; - b.style(bpm_val, Prop::TextFont, 0, FONT_BIG as i32)?; - b.style(bpm_val, Prop::TextColor, 0, WHITE)?; - b.text(bpm_val, "120")?; - b.align(bpm_val, Align::Center, 0, -76)?; - - let (btn_cfg, cfg_lbl) = make_pill(b, root, 210, 38, ROW_BG, ROW_PRESSED, "4/4 | 100%", GREY, Some(FONT_SMALL))?; - b.align(btn_cfg, Align::Center, 0, -18)?; - - let (btn_minus, _) = make_pill(b, root, 88, 56, ROW_BG, ROW_PRESSED, "-5", WHITE, None)?; - b.align(btn_minus, Align::Center, -108, 44)?; - - let (btn_tap, _) = make_pill(b, root, 108, 56, ROW_BG, ROW_PRESSED, "TAP", ACCENT, None)?; - b.align(btn_tap, Align::Center, 0, 44)?; - - let (btn_plus, _) = make_pill(b, root, 88, 56, ROW_BG, ROW_PRESSED, "+5", WHITE, None)?; - b.align(btn_plus, Align::Center, 108, 44)?; - - let (btn_play, play_lbl) = make_pill(b, root, 260, 68, ACCENT, ROW_PRESSED, "START", BLACK, None)?; - b.align(btn_play, Align::Center, 0, 124)?; - b.submit(lv)?; - - let screen = Screen::Main { - root, - arc, - dots, - bpm_val, - btn_cfg, - cfg_lbl, - btn_minus, - btn_tap, - btn_plus, - btn_play, - play_lbl, - }; - sync_screen(b, lv, &screen, settings, running, beat)?; - Ok(screen) - } - - fn build_settings(b: &mut Batch, lv: &Lv, settings: &Settings) -> Result { - b.clear(); - stock::theme(b)?; - let root = make_container(b)?; - - let title = b.create(Class::Label, root)?; - b.style(title, Prop::TextColor, 0, ACCENT)?; - b.text(title, "Settings")?; - b.align(title, Align::Center, 0, -148)?; - - let card_beats = stock::card(b, root, 86)?; - b.size(card_beats, 360, 86)?; - b.style(card_beats, Prop::BgColor, PRESSED, ROW_PRESSED)?; - b.events(card_beats, &[Ev::Clicked])?; - b.align(card_beats, Align::Center, 0, -64)?; - - let lbl_b = b.create(Class::Label, card_beats)?; - b.text(lbl_b, "Beats")?; - b.align(lbl_b, Align::LeftMid, 28, 0)?; - - let beats_val = b.create(Class::Label, card_beats)?; - b.style(beats_val, Prop::TextColor, 0, ACCENT)?; - b.text(beats_val, "4/4")?; - b.align(beats_val, Align::RightMid, -28, 0)?; - - let card_power = stock::card(b, root, 86)?; - b.size(card_power, 360, 86)?; - b.style(card_power, Prop::BgColor, PRESSED, ROW_PRESSED)?; - b.events(card_power, &[Ev::Clicked])?; - b.align(card_power, Align::Center, 0, 34)?; - - let lbl_p = b.create(Class::Label, card_power)?; - b.text(lbl_p, "Power")?; - b.align(lbl_p, Align::LeftMid, 28, 0)?; - - let power_val = b.create(Class::Label, card_power)?; - b.style(power_val, Prop::TextColor, 0, ACCENT)?; - b.text(power_val, "100%")?; - b.align(power_val, Align::RightMid, -28, 0)?; - - let (btn_done, _) = make_pill(b, root, 220, 62, ACCENT, ROW_PRESSED, "DONE", BLACK, None)?; - b.align(btn_done, Align::Center, 0, 132)?; - b.submit(lv)?; - - let screen = Screen::Settings { - root, - card_beats, - beats_val, - card_power, - power_val, - btn_done, - }; - sync_screen(b, lv, &screen, settings, false, 0)?; - Ok(screen) - } - - fn sync_screen(b: &mut Batch, lv: &Lv, screen: &Screen, settings: &Settings, running: bool, beat: u8) -> Result<(), LvError> { - b.clear(); - - match screen { - Screen::Main { - arc, - dots, - bpm_val, - cfg_lbl, - btn_play, - play_lbl, - .. - } => { - let mut line = Line::new(); - let _ = write!(line, "{}", settings.bpm); - b.text(*bpm_val, line.as_str())?; - - let mut cfg = Line::new(); - let _ = write!(cfg, "{}/4 | {}%", settings.beats_per_bar, settings.strength_pct); - b.text(*cfg_lbl, cfg.as_str())?; - - b.style(*btn_play, Prop::BgColor, 0, if running { RED } else { ACCENT })?; - b.style(*play_lbl, Prop::TextColor, 0, if running { WHITE } else { BLACK })?; - b.text(*play_lbl, if running { "STOP" } else { "START" })?; - - let arc_pct = if running { - ((beat as i32 + 1) * 100) / (settings.beats_per_bar as i32) - } else { - 0 - }; - b.value(*arc, arc_pct, false)?; - - let count = settings.beats_per_bar as usize; - let w: i32 = if count <= 4 { 32 } else { 20 }; - let gap: i32 = if count <= 4 { 10 } else { 6 }; - let total_w = count as i32 * w + (count as i32 - 1) * gap; - let start_x = -total_w / 2 + w / 2; - - for (i, &dot) in dots.iter().enumerate() { - if i < count { - let x = (start_x + i as i32 * (w + gap)) as i16; - b.size(dot, w, 10)?; - b.align(dot, Align::Center, x, -134)?; - let active = running && (i as u8 == beat); - let col = if active { - if i == 0 && count > 1 { RED } else { ACCENT } - } else { - ROW_BG - }; - b.style(dot, Prop::BgColor, 0, col)?; - b.style(dot, Prop::BgOpa, 0, 255)?; - } else { - b.style(dot, Prop::BgOpa, 0, 0)?; - } - } - } - Screen::Settings { - beats_val, - power_val, - .. - } => { - let mut b_str = Line::new(); - let _ = write!(b_str, "{}/4", settings.beats_per_bar); - b.text(*beats_val, b_str.as_str())?; - - let mut p_str = Line::new(); - let _ = write!(p_str, "{}%", settings.strength_pct); - b.text(*power_val, p_str.as_str())?; - } - } - - b.submit(lv) - } - - fn delete_screen(b: &mut Batch, lv: &Lv, screen: &Screen) -> Result<(), LvError> { - b.clear(); - let root = match screen { - Screen::Main { root, .. } | Screen::Settings { root, .. } => *root, - }; - b.del(root)?; - b.submit(lv) - } - - fn main(api: &'static Api) -> i32 { - let Some(lv) = api.lv() else { return -95 }; - let Some(mut b) = Batch::new() else { return -1 }; - - if stock::font(&mut b) - .and_then(|_| b.font(FONT_BIG, StockFont::F48M)) - .and_then(|_| b.font(FONT_SMALL, StockFont::F24M)) - .and_then(|_| b.submit(&lv)) - .is_err() - { - return -3; - } - - let mut settings = Settings::default(); - let mut tap_tracker = TapTracker::default(); - let mut running = false; - let mut paused = false; - let mut beat: u8 = 0; - let mut motor_on = false; - let mut motor_off_at: u32 = 0; - let mut next_beat_at: u32 = 0; - - let mut screen = match build_main(&mut b, &lv, &settings, running, beat) { - Ok(s) => s, - Err(LvError::Code(c)) => return c, - Err(_) => return -4, - }; - - loop { - let now = api.now(); - - if running { - if motor_on && (now.wrapping_sub(motor_off_at) as i32) >= 0 { - api.vibrate(0, 0); - motor_on = false; - } - - if (now.wrapping_sub(next_beat_at) as i32) >= 0 { - let (duty, freq, pulse_ms) = settings.pulse_params(beat); - api.vibrate(duty, freq); - motor_on = true; - motor_off_at = now.wrapping_add(pulse_ms); - if !paused { - let _ = sync_screen(&mut b, &lv, &screen, &settings, running, beat); - } - - beat = (beat + 1) % settings.beats_per_bar; - next_beat_at = next_beat_at.wrapping_add(settings.interval_ms()); - } - } - - let timeout = if !running { - u32::MAX - } else { - let to_beat = next_beat_at.wrapping_sub(api.now()) as i32; - let wait = if motor_on { - let to_off = motor_off_at.wrapping_sub(api.now()) as i32; - to_beat.min(to_off) - } else { - to_beat - }; - wait.max(1) as u32 - }; - - let Some(event) = api.event(timeout) else { continue }; - - match event.kind { - BUTTON => { - api.vibrate(0, 0); - api.keep_screen_on(false); - return 0; - } - PAUSE => { - paused = true; - api.keep_screen_on(false); - } - RESUME => { - paused = false; - if running { - api.keep_screen_on(true); - } - let _ = sync_screen(&mut b, &lv, &screen, &settings, running, beat); - } - CROWN if event.delta != 0 => { - let step = event.delta.signum(); - match screen { - Screen::Main { .. } => settings.adjust(Field::Bpm, step), - Screen::Settings { .. } => settings.adjust(Field::Beats, step), - } - if !paused { - let _ = sync_screen(&mut b, &lv, &screen, &settings, running, beat); - } - } - LV if event.y == CLICKED => { - let id = event.x as u16; - match screen { - Screen::Main { - btn_play, - btn_minus, - btn_plus, - btn_tap, - btn_cfg, - .. - } => { - if id == btn_cfg.0 { - let _ = delete_screen(&mut b, &lv, &screen); - if let Ok(s) = build_settings(&mut b, &lv, &settings) { - screen = s; - } - continue; - } else if id == btn_play.0 { - running = !running; - api.keep_screen_on(running); - if running { - beat = 0; - next_beat_at = api.now(); - continue; - } else { - motor_on = false; - api.vibrate(0, 0); - } - } else if id == btn_minus.0 { - settings.adjust_bpm(-5); - } else if id == btn_plus.0 { - settings.adjust_bpm(5); - } else if id == btn_tap.0 { - if let Some(new_bpm) = tap_tracker.tap(api.now()) { - settings.bpm = new_bpm; - if running { - next_beat_at = api.now().wrapping_add(settings.interval_ms()); - } - } - } - } - Screen::Settings { - card_beats, - card_power, - btn_done, - .. - } => { - if id == btn_done.0 { - let _ = delete_screen(&mut b, &lv, &screen); - if let Ok(s) = build_main(&mut b, &lv, &settings, running, beat) { - screen = s; - } - continue; - } else if id == card_beats.0 { - settings.beats_per_bar = if settings.beats_per_bar >= 8 { 1 } else { settings.beats_per_bar + 1 }; - } else if id == card_power.0 { - settings.strength_pct = if settings.strength_pct >= 100 { 20 } else { settings.strength_pct + 10 }; - } - } - } - - if !paused { - let _ = sync_screen(&mut b, &lv, &screen, &settings, running, beat); - } - } - _ => {} - } - } - } -} diff --git a/apps/metronome/store.md b/apps/metronome/store.md deleted file mode 100644 index ab4ade0..0000000 --- a/apps/metronome/store.md +++ /dev/null @@ -1,12 +0,0 @@ -Silent tactile metronome for CMF Watch Pro 2 with a native LVGL interface. - -### Features -- **Tactile Rhythm:** Distinct vibration accent on the first beat of every bar. -- **Tap Tempo:** Tap the beat directly on screen to match any song's tempo. -- **Crown & Touch Control:** Adjust BPM with the crown (`±1`) or quick `±5` pills. -- **Customizable:** Configure time signatures (`1/4` to `8/4`) and vibration strength (`20%` to `100%`). -- **Always-On Session:** Keeps the screen and motor active during practice. - -## Requirements - -The [patched firmware](/firmware) and the [App Loader](/firmware). diff --git a/apps/metronome/store.toml b/apps/metronome/store.toml deleted file mode 100644 index 75325c9..0000000 --- a/apps/metronome/store.toml +++ /dev/null @@ -1,4 +0,0 @@ -name = "Haptic Metronome" -summary = "Tactile vibration metronome with Tap Tempo, time signatures, and adjustable pulse strength." -version = "0.1.0" -author = "XwlNnGemini" diff --git a/apps/mood/Cargo.toml b/apps/mood/Cargo.toml deleted file mode 100644 index 44b705a..0000000 --- a/apps/mood/Cargo.toml +++ /dev/null @@ -1,15 +0,0 @@ -[package] -name = "mood" -edition.workspace = true -license.workspace = true -version.workspace = true - -[dependencies] -cmf-wp2-app.workspace = true - -[dev-dependencies] -wp2-core.workspace = true - -[[bin]] -name = "mood" -bench = false diff --git a/apps/mood/icon.svg b/apps/mood/icon.svg deleted file mode 100644 index a7afd4d..0000000 --- a/apps/mood/icon.svg +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/apps/mood/src/main.rs b/apps/mood/src/main.rs deleted file mode 100644 index de2eb18..0000000 --- a/apps/mood/src/main.rs +++ /dev/null @@ -1,202 +0,0 @@ -//! mood: a month of days as seven columns of squares. Tap a day to cycle its level (clear, low, ok, good, great); -//! the crown flips between the months of the current year. A whole year of levels lives in the app's 4 KiB blob. -#![cfg_attr(target_os = "none", no_std, no_main)] - -#[cfg_attr(not(target_os = "none"), allow(dead_code))] -mod model; -mod screen; - -#[cfg(not(target_os = "none"))] -fn main() {} - -#[cfg(target_os = "none")] -mod device { - use crate::model::{days_in_month, Year, BLOB_LEN, MONTHS}; - use crate::screen::{self, Screen}; - use cmf_wp2_app::lv::{Batch, Lv, LvError, StockFont}; - use cmf_wp2_app::{stock, Api, BUTTON, CROWN, LV, PAUSE, RESUME}; - - cmf_wp2_app::entry!(main); - cmf_wp2_app::app_icon!(); - - /// LVGL 8.3 `LV_EVENT_CLICKED`. - const CLICKED: i16 = 7; - const LEVEL_WORDS: [&str; 5] = ["clear", "low", "ok", "good", "great"]; - - fn load(api: &Api, year: i32) -> Year { - let mut buf = [0u8; BLOB_LEN]; - let n = api.load(&mut buf); - let mut y = Year::new(year); - if n > 0 { - if let Some(stored) = Year::from_blob(&buf[..n as usize]) { - y.adopt(&stored); - } - } - y - } - - fn save(api: &Api, y: &Year) { - let blob = y.blob(); - api.save(&blob); - } - - fn push(buf: &mut [u8], at: &mut usize, s: &str) { - for &c in s.as_bytes() { - if *at < buf.len() { - buf[*at] = c; - *at += 1; - } - } - } - - fn push_u8(buf: &mut [u8], at: &mut usize, mut n: u8) { - if n >= 10 { - push(buf, at, core::str::from_utf8(&[b'0' + n / 10]).unwrap_or("")); - n %= 10; - } - push(buf, at, core::str::from_utf8(&[b'0' + n]).unwrap_or("")); - } - - /// "Nov 2026" - fn title_text(year: i32, month: u8, buf: &mut [u8; 8]) -> &str { - let mut n = 0; - push(buf, &mut n, MONTHS[(month as usize).clamp(1, 12) - 1]); - push(buf, &mut n, " "); - let mut y = year.clamp(0, 9999) as u16; - let mut digits = [0u8; 4]; - for i in (0..4).rev() { - digits[i] = b'0' + (y % 10) as u8; - y /= 10; - } - push(buf, &mut n, core::str::from_utf8(&digits).unwrap_or("")); - core::str::from_utf8(&buf[..n]).unwrap_or("") - } - - /// "today 16" - fn today_text(day: u8, buf: &mut [u8; 10]) -> &str { - let mut n = 0; - push(buf, &mut n, "today "); - push_u8(buf, &mut n, day); - core::str::from_utf8(&buf[..n]).unwrap_or("") - } - - /// "16 Nov: good" - fn tap_text(day: u8, month: u8, level: u8, buf: &mut [u8; 16]) -> &str { - let mut n = 0; - push_u8(buf, &mut n, day); - push(buf, &mut n, " "); - push(buf, &mut n, MONTHS[(month as usize).clamp(1, 12) - 1]); - push(buf, &mut n, ": "); - push(buf, &mut n, LEVEL_WORDS[(level as usize).min(4)]); - core::str::from_utf8(&buf[..n]).unwrap_or("") - } - - /// A whole month in as many batches as the 2 KiB record buffer needs: the grid, then cells, then the header. - fn draw_month( - b: &mut Batch, - lv: &Lv, - s: &mut Screen, - model: &Year, - month: u8, - subtitle: &str, - year: i32, - ) -> Result<(), LvError> { - screen::grid(b, s)?; - b.submit(lv)?; - let mut day = 1; - while day <= days_in_month(year, month) { - let next = screen::cells(b, s, model, year, month, day)?; - if screen::month_done(year, month, next) { - break; - } - b.submit(lv)?; // bank this chunk and keep filling - day = next; - } - let mut tb = [0u8; 8]; - screen::texts(b, s, title_text(year, month, &mut tb), subtitle)?; - b.submit(lv) - } - - fn main(api: &'static Api) -> i32 { - let Some(lv) = api.lv() else { return -95 }; // loader older than ABI 1.2 - let Some(mut b) = Batch::new() else { return -1 }; - - for (slot, font) in [(screen::FONT_UI, stock::SYSTEM_FONT), (screen::FONT_SMALL, StockFont::F18M)] { - if screen::open_font(&mut b, slot, font).and_then(|_| b.submit(&lv)).is_err() { - return 1; - } - } - let Ok(mut s) = screen::build(&mut b) else { return 2 }; - if b.submit(&lv).is_err() { - return 3; - } - - let Some(clock) = api.time() else { - // no RTC yet: nothing to show, but say why instead of a blank screen - let _ = screen::texts(&mut b, &s, "Mood", "set the clock").and_then(|_| b.submit(&lv)); - loop { - match api.event(u32::MAX) { - Some(e) if e.kind == BUTTON => return 0, - Some(_) => {} - None => {} - } - } - }; - - let year = clock.year as i32; - let mut model = load(api, year); - let mut month = clock.month.clamp(1, 12); - let mut buf = [0u8; 16]; - let mut today_buf = [0u8; 10]; - let subtitle = today_text(clock.day, &mut today_buf); - if draw_month(&mut b, &lv, &mut s, &model, month, subtitle, year).is_err() { - return 4; - } - - loop { - let Some(e) = api.event(u32::MAX) else { continue }; - match e.kind { - BUTTON => break, - CROWN => { - let next = (month as i32 - 1 + e.delta as i32).rem_euclid(12) as u8 + 1; - if next != month { - month = next; - let sub = if month == clock.month { today_text(clock.day, &mut today_buf) } else { "" }; - if draw_month(&mut b, &lv, &mut s, &model, month, sub, year).is_err() { - break; - } - } - } - LV => { - if e.y == CLICKED && e.x >= 0 { - if let Some(day) = screen::day_of(&s, e.x as u16) { - let level = model.cycle(month, day); - let sub = tap_text(day, month, level, &mut buf); - if screen::level(&mut b, &s, day, level) - .and_then(|_| b.text(s.subtitle, sub)) - .and_then(|_| b.submit(&lv)) - .is_ok() - { - save(api, &model); - } - } - } - } - PAUSE => loop { - match api.event(u32::MAX) { - Some(e) if e.kind == RESUME => break, - Some(e) if e.kind == BUTTON => { - save(api, &model); - return 0; - } - _ => {} - } - }, - _ => {} - } - } - - save(api, &model); - 0 - } -} diff --git a/apps/mood/src/model.rs b/apps/mood/src/model.rs deleted file mode 100644 index 15a03f0..0000000 --- a/apps/mood/src/model.rs +++ /dev/null @@ -1,192 +0,0 @@ -//! A year of mood levels and the date arithmetic to index it. Pure logic, host-tested. - -/// No entry, then four levels. Level 0 is "untouched", so a tap always starts at 1. -pub const LEVELS: u8 = 5; -/// 366 days: a leap year fits. -pub const YEAR_LEN: usize = 366; -/// `"MD"`, version, year (u16 LE), then one level per day of the year. -pub const BLOB_LEN: usize = 2 + 1 + 2 + YEAR_LEN; - -pub const MONTHS: [&str; 12] = - ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]; - -pub fn is_leap(year: i32) -> bool { - year % 4 == 0 && (year % 100 != 0 || year % 400 == 0) -} - -pub fn days_in_month(year: i32, month: u8) -> u8 { - match month { - 1 | 3 | 5 | 7 | 8 | 10 | 12 => 31, - 4 | 6 | 9 | 11 => 30, - 2 if is_leap(year) => 29, - 2 => 28, - _ => 0, - } -} - -/// Day of the year, 0-based, or `None` for a date that does not exist. -pub fn day_index(year: i32, month: u8, day: u8) -> Option { - if !(1..=12).contains(&month) || day == 0 || day > days_in_month(year, month) { - return None; - } - let mut n = 0; - for m in 1..month { - n += days_in_month(year, m) as usize; - } - Some(n + day as usize - 1) -} - -/// 0 = Sunday .. 6 = Saturday (Sakamoto's method, proleptic Gregorian). -pub fn weekday(year: i32, month: u8, day: u8) -> u8 { - const OFFSETS: [i32; 12] = [0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4]; - let mut y = year; - if month < 3 { - y -= 1; - } - let w = (y + y / 4 - y / 100 + y / 400 + OFFSETS[(month as usize).clamp(1, 12) - 1] + day as i32) % 7; - w.rem_euclid(7) as u8 -} - -/// One year of levels. Out-of-range days read as 0 and are ignored on write. -#[derive(Clone, Copy)] -pub struct Year { - pub year: i32, - days: [u8; YEAR_LEN], -} - -impl Year { - pub fn new(year: i32) -> Self { - Self { year, days: [0; YEAR_LEN] } - } - - pub fn get(&self, month: u8, day: u8) -> u8 { - day_index(self.year, month, day).map(|i| self.days[i]).unwrap_or(0) - } - - /// Cycles 0 -> 1 -> 2 -> 3 -> 4 -> 0. Returns the new level, or 0 for a date that does not exist. - pub fn cycle(&mut self, month: u8, day: u8) -> u8 { - let Some(i) = day_index(self.year, month, day) else { return 0 }; - self.days[i] = (self.days[i] + 1) % LEVELS; - self.days[i] - } - - #[cfg(test)] - pub fn set(&mut self, month: u8, day: u8, level: u8) { - if let Some(i) = day_index(self.year, month, day) { - self.days[i] = level % LEVELS; - } - } - - pub fn blob(&self) -> [u8; BLOB_LEN] { - let mut b = [0u8; BLOB_LEN]; - b[0] = b'M'; - b[1] = b'D'; - b[2] = 1; - b[3..5].copy_from_slice(&(self.year as u16).to_le_bytes()); - b[5..].copy_from_slice(&self.days); - b - } - - /// The stored year and days. `None` when the blob is not ours; a blob from another year is - /// accepted but comes back empty for the requested year. - pub fn from_blob(blob: &[u8]) -> Option { - if blob.len() != BLOB_LEN || blob[0..2] != *b"MD" || blob[2] != 1 { - return None; - } - let year = i32::from(u16::from_le_bytes([blob[3], blob[4]])); - let mut days = [0u8; YEAR_LEN]; - for (slot, byte) in days.iter_mut().zip(&blob[5..]) { - *slot = byte % LEVELS; - } - Some(Self { year, days }) - } - - /// Keeps this year's levels, and takes `other`'s when it is the same year. Returns whether it took them. - pub fn adopt(&mut self, other: &Self) -> bool { - if other.year != self.year { - return false; - } - self.days = other.days; - true - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn month_lengths_and_leap_years() { - assert_eq!(days_in_month(2026, 2), 28); - assert_eq!(days_in_month(2024, 2), 29); - assert_eq!(days_in_month(1900, 2), 28); // centuries are not leap years - assert_eq!(days_in_month(2000, 2), 29); // unless divisible by 400 - assert_eq!(days_in_month(2026, 4), 30); - assert_eq!(days_in_month(2026, 12), 31); - assert_eq!(days_in_month(2026, 13), 0); - } - - #[test] - fn day_index_counts_from_january_first() { - assert_eq!(day_index(2026, 1, 1), Some(0)); - assert_eq!(day_index(2026, 3, 1), Some(59)); // 31 + 28 - assert_eq!(day_index(2024, 3, 1), Some(60)); // leap year - assert_eq!(day_index(2026, 12, 31), Some(364)); - assert_eq!(day_index(2024, 12, 31), Some(365)); - assert_eq!(day_index(2026, 2, 29), None); - assert_eq!(day_index(2026, 4, 31), None); - assert_eq!(day_index(2026, 0, 1), None); - } - - #[test] - fn weekdays_match_known_dates() { - assert_eq!(weekday(2000, 1, 1), 6); // Saturday - assert_eq!(weekday(2024, 2, 29), 4); // Thursday - assert_eq!(weekday(2026, 11, 16), 1); // Monday - assert_eq!(weekday(1970, 1, 1), 4); // Thursday - } - - #[test] - fn levels_cycle_back_to_empty() { - let mut y = Year::new(2026); - assert_eq!(y.get(11, 16), 0); - for want in [1, 2, 3, 4, 0] { - assert_eq!(y.cycle(11, 16), want); - } - y.set(11, 16, 3); - assert_eq!(y.get(11, 16), 3); - assert_eq!(y.cycle(2, 30), 0); // no such day, nothing written - } - - #[test] - fn the_blob_round_trips_and_rejects_foreign_data() { - let mut y = Year::new(2026); - y.set(1, 1, 4); - y.set(12, 31, 1); - let blob = y.blob(); - assert_eq!(blob.len(), BLOB_LEN); - - let back = Year::from_blob(&blob).unwrap(); - assert_eq!(back.year, 2026); - assert_eq!(back.get(1, 1), 4); - assert_eq!(back.get(12, 31), 1); - - assert!(Year::from_blob(b"").is_none()); - assert!(Year::from_blob(&[b'X'; BLOB_LEN]).is_none()); - let mut bad = blob; - bad[2] = 9; // other version - assert!(Year::from_blob(&bad).is_none()); - } - - #[test] - fn another_year_starts_empty() { - let mut old = Year::new(2025); - old.set(5, 5, 2); - let mut new = Year::new(2026); - assert!(!new.adopt(&old)); - assert_eq!(new.get(5, 5), 0); - let mut same = Year::new(2025); - assert!(same.adopt(&old)); - assert_eq!(same.get(5, 5), 2); - } -} diff --git a/apps/mood/src/screen.rs b/apps/mood/src/screen.rs deleted file mode 100644 index e7d2d4d..0000000 --- a/apps/mood/src/screen.rs +++ /dev/null @@ -1,331 +0,0 @@ -//! The Mood screen: a month as seven columns of rounded squares, in the stock look and strictly black to white. -//! -//! ```text -//! y 46.. 80 title: "Nov 2026" 32 px, white -//! y 82..102 subtitle: "tap a day" 18 px, grey -//! y 108..384 6 x 7 grid of 40 px cells 316 px wide, 276 px tall, 6 px gaps -//! y 388..410 hint: "crown: month" 18 px, grey -//! ``` -//! -//! A cell's fill is the day's level: near-black for no entry, four steps up to pure white. A month does not fit in -//! one batch (31 cells and 31 labels are ~430 records), so [`cells`] hands back where it stopped with -//! [`LvError::Full`] and the caller submits and calls it again. - -use cmf_wp2_app::lv::*; -use cmf_wp2_app::stock; - -use crate::model::{days_in_month, weekday, Year}; - -pub const FONT_UI: u8 = stock::FONT; -pub const FONT_SMALL: u8 = 1; - -pub const CELL: i32 = 40; -pub const GAP: i32 = 6; -pub const PITCH: i32 = CELL + GAP; -pub const GRID_X: i16 = 75; -pub const GRID_Y: i16 = 108; -pub const MAX_DAYS: usize = 31; -/// Records one cell and its number take (~140 B measured, padded). -const CELL_BYTES: usize = 200; -/// The round screen is only this wide at the top and the bottom. -pub const TITLE_W: i32 = 250; -pub const HINT_W: i32 = 280; - -/// Fill for each level: 0 is "no entry", 4 is white. -const FILL: [i32; 5] = [0x2124, 0x39E7, 0x7BEF, 0xBDF7, stock::WHITE]; - -pub struct Screen { - pub page: Obj, - pub title: Obj, - pub subtitle: Obj, - pub grid: Obj, - pub cells: [Obj; MAX_DAYS], - pub labels: [Obj; MAX_DAYS], - has_grid: bool, -} - -fn fill(level: u8) -> i32 { - FILL[(level as usize).min(FILL.len() - 1)] -} - -/// Level 0..=1 are dark squares, so their number is white; 2..=4 take a black number. -fn ink(level: u8) -> i32 { - if level <= 1 { stock::WHITE } else { stock::BLACK } -} - -pub fn open_font(b: &mut Batch, slot: u8, font: StockFont) -> Result<(), LvError> { - b.font(slot, font) -} - -/// Page, title, subtitle and hint. The grid is added by [`grid`] and [`cells`]. -pub fn build(b: &mut Batch) -> Result { - stock::theme(b)?; - - let page = b.create(Class::Obj, ROOT)?; - b.size(page, stock::SCREEN, stock::SCREEN)?; - for p in [Prop::PadTop, Prop::PadBottom, Prop::PadLeft, Prop::PadRight, Prop::BorderWidth, Prop::BgOpa] { - b.style(page, p, 0, 0)?; - } - b.flags(page, &[], &[Flag::Scrollable])?; - - let title = b.create(Class::Label, page)?; - b.size(title, TITLE_W, 36)?; - b.align(title, Align::TopMid, 0, 46)?; - b.style(title, Prop::TextAlign, 0, 2)?; - b.text(title, "Mood")?; - - let subtitle = b.create(Class::Label, page)?; - b.size(subtitle, 300, 22)?; - b.align(subtitle, Align::TopMid, 0, 82)?; - b.style(subtitle, Prop::TextAlign, 0, 2)?; - b.style(subtitle, Prop::TextColor, 0, stock::GREY)?; - b.style(subtitle, Prop::TextFont, 0, FONT_SMALL as i32)?; - b.text(subtitle, "tap a day")?; - - let hint = b.create(Class::Label, page)?; - b.size(hint, HINT_W, 22)?; - b.align(hint, Align::TopMid, 0, 388)?; - b.style(hint, Prop::TextAlign, 0, 2)?; - b.style(hint, Prop::TextColor, 0, stock::GREY)?; - b.style(hint, Prop::TextFont, 0, FONT_SMALL as i32)?; - b.text(hint, "crown: month")?; - - Ok(Screen { - page, - title, - subtitle, - grid: ROOT, - cells: [ROOT; MAX_DAYS], - labels: [ROOT; MAX_DAYS], - has_grid: false, - }) -} - -/// Replaces the old grid with an empty one. Submit after it, then fill it with [`cells`]. -pub fn grid(b: &mut Batch, s: &mut Screen) -> Result<(), LvError> { - if s.has_grid { - b.del(s.grid)?; - s.has_grid = false; - } - let grid = b.create(Class::Obj, s.page)?; - b.size(grid, 7 * PITCH - GAP, 6 * PITCH - GAP)?; - b.align(grid, Align::TopLeft, GRID_X, GRID_Y)?; - for p in [Prop::PadTop, Prop::PadBottom, Prop::PadLeft, Prop::PadRight, Prop::BorderWidth, Prop::BgOpa] { - b.style(grid, p, 0, 0)?; - } - b.flags(grid, &[], &[Flag::Scrollable])?; - s.grid = grid; - s.has_grid = true; - for slot in 0..MAX_DAYS { - s.cells[slot] = ROOT; - s.labels[slot] = ROOT; - } - Ok(()) -} - -/// Adds cells from day `from` until the batch is nearly full, and returns the day to continue at: past the month's -/// last day when the month is complete, otherwise the caller submits and calls it again with that day. -pub fn cells(b: &mut Batch, s: &mut Screen, model: &Year, year: i32, month: u8, from: u8) -> Result { - let first = weekday(year, month, 1) as i32; // column of the 1st, 0 = Sunday - let days = days_in_month(year, month); - let mut day = from.max(1); - while day <= days { - // never start a cell that would not fit whole: a half-written cell would reach the loader without its - // events and never send a tap - if b.bytes().len() + CELL_BYTES > BUF { - break; - } - let slot = (first + day as i32 - 1) as usize; - let (col, row) = (slot % 7, slot / 7); - let level = model.get(month, day); - - let cell = match b.create(Class::Obj, s.grid) { - Ok(c) => c, - Err(e) => return Err(e), - }; - b.size(cell, CELL, CELL)?; - b.align(cell, Align::TopLeft, (col as i32 * PITCH) as i16, (row as i32 * PITCH) as i16)?; - b.style(cell, Prop::Radius, 0, 12)?; - b.style(cell, Prop::BgColor, 0, fill(level))?; - b.style(cell, Prop::BgOpa, 0, 255)?; - b.style(cell, Prop::BorderWidth, 0, 0)?; - b.flags(cell, &[Flag::Clickable], &[Flag::Scrollable])?; - b.events(cell, &[Ev::Clicked])?; - let label = b.create(Class::Label, cell)?; - b.align(label, Align::Center, 0, 0)?; - b.style(label, Prop::TextColor, 0, ink(level))?; - b.style(label, Prop::TextFont, 0, FONT_SMALL as i32)?; - let mut buf = [0u8; 2]; - b.text(label, day_text(day, &mut buf))?; - - s.cells[day as usize - 1] = cell; - s.labels[day as usize - 1] = label; - day += 1; - } - Ok(day) -} - -/// Whether [`cells`] has finished the month. -pub fn month_done(year: i32, month: u8, next: u8) -> bool { - next > days_in_month(year, month) -} - -fn day_text(day: u8, buf: &mut [u8; 2]) -> &str { - let mut n = day; - let mut len = 0; - if n >= 10 { - buf[0] = b'0' + n / 10; - len = 1; - n %= 10; - } - buf[len] = b'0' + n; - core::str::from_utf8(&buf[..len + 1]).unwrap_or("?") -} - -/// The day a CLICKED handle belongs to, if it is one of the month's cells. -pub fn day_of(s: &Screen, handle: u16) -> Option { - s.cells.iter().position(|c| c.0 == handle).map(|i| i as u8 + 1) -} - -/// Repaints one cell for a new level. -pub fn level(b: &mut Batch, s: &Screen, day: u8, level: u8) -> Result<(), LvError> { - let i = day as usize - 1; - b.style(s.cells[i], Prop::BgColor, 0, fill(level))?; - b.style(s.labels[i], Prop::TextColor, 0, ink(level)) -} - -pub fn texts(b: &mut Batch, s: &Screen, title: &str, subtitle: &str) -> Result<(), LvError> { - b.text(s.title, title)?; - b.text(s.subtitle, subtitle) -} - -#[cfg(test)] -mod tests { - extern crate std; - use super::*; - use crate::model::Year; - use std::boxed::Box; - use wp2_core::lvcmd::{self, Table}; - - fn batch() -> Batch { - Batch::with_buf(Box::leak(Box::new([0; BUF]))) - } - - fn apply(t: &mut Table, records: &[u8]) { - for r in lvcmd::records(records) { - lvcmd::apply(t, &r.unwrap()); - } - } - - fn launch() -> (Batch, Screen, Table, u8) { - let mut t = Table::new(); - let mut b = batch(); - let mut mask = 0u8; - for (slot, font) in [(FONT_UI, stock::SYSTEM_FONT), (FONT_SMALL, StockFont::F18M)] { - open_font(&mut b, slot, font).unwrap(); - assert_eq!(lvcmd::validate(b.bytes(), &t, mask), Ok(()), "font {slot}"); - apply(&mut t, b.bytes()); - mask |= 1 << slot; - } - let s = build(&mut b).unwrap(); - assert_eq!(lvcmd::validate(b.bytes(), &t, mask), Ok(())); - apply(&mut t, b.bytes()); - (b, s, t, mask) - } - - /// Fills a month the way the app does: one batch per chunk, submitted when the buffer is full. - fn fill_month(b: &mut Batch, s: &mut Screen, t: &mut Table, mask: u8, model: &Year, year: i32, month: u8) { - grid(b, s).unwrap(); - assert_eq!(lvcmd::validate(b.bytes(), t, mask), Ok(())); - apply(t, b.bytes()); - b.clear(); // stands in for the submit - - let mut day = 1; - let mut batches = 0; - loop { - let next = cells(b, s, model, year, month, day).unwrap(); - batches += 1; - assert!(next > day, "must make progress"); - assert_eq!(lvcmd::validate(b.bytes(), t, mask), Ok(()), "chunk at day {day}"); - apply(t, b.bytes()); - b.clear(); - if month_done(year, month, next) { - break; - } - day = next; - } - std::println!("{month}/{year}: {batches} cell batches"); - } - - #[test] - fn a_month_fills_in_chunks_and_validates() { - let (mut b, mut s, mut t, mask) = launch(); - let model = Year::new(2026); - b.clear(); - fill_month(&mut b, &mut s, &mut t, mask, &model, 2026, 11); - // 30 days in November - assert_ne!(s.cells[29].0, 0); - assert_eq!(s.cells[30], ROOT); - assert_eq!(day_of(&s, s.cells[15].0), Some(16)); - } - - #[test] - fn a_leap_february_has_29_cells() { - let (mut b, mut s, mut t, mask) = launch(); - let model = Year::new(2024); - b.clear(); - fill_month(&mut b, &mut s, &mut t, mask, &model, 2024, 2); - assert_ne!(s.cells[28].0, 0); - assert_eq!(s.cells[29], ROOT); - } - - #[test] - fn switching_months_frees_the_old_grid() { - let (mut b, mut s, mut t, mask) = launch(); - let model = Year::new(2026); - b.clear(); - fill_month(&mut b, &mut s, &mut t, mask, &model, 2026, 1); - let first = s.grid; - b.clear(); - fill_month(&mut b, &mut s, &mut t, mask, &model, 2026, 2); - assert_eq!(s.grid, first); // freed and recreated at the same handle - } - - #[test] - fn one_tap_repaints_one_cell() { - let (mut b, mut s, mut t, mask) = launch(); - let model = Year::new(2026); - b.clear(); - fill_month(&mut b, &mut s, &mut t, mask, &model, 2026, 11); - b.clear(); - level(&mut b, &s, 16, 4).unwrap(); - texts(&mut b, &s, "Nov 2026", "16 Nov").unwrap(); - assert_eq!(lvcmd::validate(b.bytes(), &t, mask), Ok(())); - } - - #[test] - fn the_grid_stays_inside_the_round_screen() { - fn half(y0: i32, y1: i32) -> i32 { - let d = (y0 - 233).abs().max((y1 - 233).abs()); - let w = (233 * 233 - d * d).max(0) as f64; - w.sqrt() as i32 - 6 - } - let w = 7 * PITCH - GAP; - assert!(TITLE_W / 2 <= half(46, 80), "title"); - assert!(300 / 2 <= half(82, 102), "subtitle"); - assert!(HINT_W / 2 <= half(388, 410), "hint"); - for row in 0..6 { - let y0 = GRID_Y as i32 + row * PITCH; - assert!(w / 2 <= half(y0, y0 + CELL), "grid row {row}"); - } - } - - #[test] - fn day_numbers_are_two_glyphs() { - let mut buf = [0u8; 2]; - assert_eq!(day_text(1, &mut buf), "1"); - assert_eq!(day_text(9, &mut buf), "9"); - assert_eq!(day_text(10, &mut buf), "10"); - assert_eq!(day_text(31, &mut buf), "31"); - } -} diff --git a/apps/mood/store.md b/apps/mood/store.md deleted file mode 100644 index d934529..0000000 --- a/apps/mood/store.md +++ /dev/null @@ -1,8 +0,0 @@ -A year of days as a grid of squares, in black and white. - -- **Tap a day** to cycle its level: clear, low, ok, good, great. The square fills in four steps up to white, so a month reads at a glance. -- **Crown** flips between the months of the current year. -- A whole year of levels fits in the app's storage, so the grid is still there next time. - -Nothing leaves the watch and no phone is needed. It needs the clock, so set the time (the phone app syncs it) before -the first launch. diff --git a/apps/mood/store.toml b/apps/mood/store.toml deleted file mode 100644 index fd77662..0000000 --- a/apps/mood/store.toml +++ /dev/null @@ -1,5 +0,0 @@ -# The app's listing in the FMC store (README.md, "store.toml"). The page's body is store.md. -name = "Mood" -summary = "A month of days as a grid of squares: tap to log how it went, crown to flip months" -version = "0.1.0" -author = "CMF Tech Community" diff --git a/apps/music-controller/Cargo.toml b/apps/music-controller/Cargo.toml deleted file mode 100644 index 3fc944f..0000000 --- a/apps/music-controller/Cargo.toml +++ /dev/null @@ -1,13 +0,0 @@ -[package] -name = "music-controller" -edition.workspace = true -license.workspace = true -version.workspace = true - -[dependencies] -cmf-wp2-app.workspace = true -cmf-wp2-ui.workspace = true - -[[bin]] -name = "music-controller" -bench = false diff --git a/apps/music-controller/FONT-NOTICE.md b/apps/music-controller/FONT-NOTICE.md deleted file mode 100644 index c8f5c0b..0000000 --- a/apps/music-controller/FONT-NOTICE.md +++ /dev/null @@ -1,10 +0,0 @@ -# NType 82 notice - -Music Controller uses a small pre-rendered subset of **NType 82 Regular** for its interface. - -- Copyright © Nothing. All rights reserved. -- NType 82 is a trademark of Nothing. -- The uploaded OpenType font file is not committed, redistributed, or included in the app package. -- Only the Latin glyphs required by this Nothing-related CMF watch app are included as source data. - -See `src/ntype82.rs` for the embedded glyph subset. diff --git a/apps/music-controller/icon.svg b/apps/music-controller/icon.svg deleted file mode 100644 index c0894c1..0000000 --- a/apps/music-controller/icon.svg +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/apps/music-controller/shots/playing.png b/apps/music-controller/shots/playing.png deleted file mode 100644 index a2a7195..0000000 Binary files a/apps/music-controller/shots/playing.png and /dev/null differ diff --git a/apps/music-controller/shots/waiting.png b/apps/music-controller/shots/waiting.png deleted file mode 100644 index 0c24fed..0000000 Binary files a/apps/music-controller/shots/waiting.png and /dev/null differ diff --git a/apps/music-controller/src/artwork.rs b/apps/music-controller/src/artwork.rs deleted file mode 100644 index e0832c3..0000000 --- a/apps/music-controller/src/artwork.rs +++ /dev/null @@ -1,954 +0,0 @@ -//! Strict watch-side decoder for Music Companion artwork transfers. -//! -//! The decoder is independent of the watch `Api`: callers begin a request, feed it framed M1 -//! replies one at a time, and query the committed image. The receiver owns two fixed payload -//! buffers, so an instance can live in static storage and no allocation is required. - -use crate::rpc::{self, Reply}; - -pub const WIDTH: u8 = 64; -pub const HEIGHT: u8 = 64; -pub const PAYLOAD_LEN: usize = 3072; -pub const MANIFEST_LEN: usize = 25; -pub const CHUNK_COUNT: usize = 27; -pub const RECORD_COUNT: u8 = 28; -pub const MANIFEST_VERSION: u8 = 1; -pub const ENCODING_RGB332_6BPP: u8 = 1; -pub const CHUNK_LEN: usize = 115; -pub const LAST_CHUNK_LEN: usize = 82; - -/// The state of the latest artwork request. -#[derive(Clone, Copy, PartialEq, Eq, Debug)] -pub enum Status { - /// No request is active. - Idle, - /// A reply is still expected. - Pending, - /// A complete image passed its CRC check and replaced the current image. - Complete, - /// The phone confirmed that the current image is unchanged. - Unchanged, - /// The phone has no artwork. - Unavailable, - /// The user has not granted artwork access yet. - PermissionRequired, - /// Artwork access was denied. - Denied, - /// The phone does not support the artwork method. - Unsupported, - /// The response violated the artwork protocol. - Invalid, - /// The request timed out before all records arrived. - TimedOut, -} - -/// The result of handling one reply. -#[derive(Clone, Copy, PartialEq, Eq, Debug)] -pub enum Outcome { - /// The reply did not belong to the active request. - Ignored, - /// More records are required. - Pending, - /// A complete image was committed. - Complete, - /// The current image is unchanged. - Unchanged, - /// The phone has no artwork. - Unavailable, - /// Artwork permission is required. - PermissionRequired, - /// Artwork permission was denied. - Denied, - /// The phone does not support artwork. - Unsupported, - /// The active transfer was rejected. - Invalid, -} - -#[derive(Clone, Copy)] -struct Active { - id: u8, - nonce: u32, -} - -#[derive(Clone, Copy)] -struct Manifest { - generation: u64, - crc32: u32, -} - -/// A fixed-size artwork receiver. -/// -/// `Receiver` is deliberately `const`-constructible so an app can keep it in static storage: -/// `static mut ARTWORK: artwork::Receiver = artwork::Receiver::new();`. -pub struct Receiver { - /// Exactly two image buffers are kept. The active buffer is selected by an index, so a - /// successful commit is a single index change rather than a copy through the stack. - buffers: [[u8; PAYLOAD_LEN]; 2], - current_buffer: usize, - target_buffer: usize, - current_generation: Option, - visible: bool, - active: Option, - manifest_seen: bool, - manifest: Manifest, - seen: [bool; CHUNK_COUNT], - status: Status, -} - -impl Receiver { - /// Creates an empty receiver without allocating. - pub const fn new() -> Self { - Receiver { - buffers: [[0; PAYLOAD_LEN]; 2], - current_buffer: 0, - target_buffer: 1, - current_generation: None, - visible: false, - active: None, - manifest_seen: false, - manifest: Manifest { - generation: 0, - crc32: 0, - }, - seen: [false; CHUNK_COUNT], - status: Status::Idle, - } - } - - /// Starts a request and returns the exact bytes to send. - /// - /// The request advertises the currently committed generation, or zero when no image is - /// committed. Starting a new request cancels any incomplete earlier transfer. - pub fn begin(&mut self, id: u8, nonce: u32) -> rpc::Request { - self.clear_transfer(); - self.target_buffer = 1 - self.current_buffer; - self.active = Some(Active { id, nonce }); - self.status = Status::Pending; - rpc::artwork_request(id, nonce, self.current_generation.unwrap_or(0)) - } - - /// Handles one M1 reply. - pub fn handle_reply(&mut self, reply: Reply<'_>) -> Outcome { - let Some(active) = self.active else { - return Outcome::Ignored; - }; - if reply.id != active.id { - return Outcome::Ignored; - } - - match reply.status { - rpc::OK => self.handle_ok(reply.index, reply.total, reply.record, active.nonce), - rpc::UNAVAILABLE => { - if is_empty_result(reply.index, reply.total, reply.record) { - self.finish(Status::Unavailable, Outcome::Unavailable) - } else { - self.invalid() - } - } - rpc::ASK => { - if is_empty_result(reply.index, reply.total, reply.record) { - self.finish(Status::PermissionRequired, Outcome::PermissionRequired) - } else { - self.invalid() - } - } - rpc::DENIED => { - if is_empty_result(reply.index, reply.total, reply.record) { - self.finish(Status::Denied, Outcome::Denied) - } else { - self.invalid() - } - } - rpc::BAD_REQUEST => { - if is_empty_result(reply.index, reply.total, reply.record) { - self.finish(Status::Unsupported, Outcome::Unsupported) - } else { - self.invalid() - } - } - _ => self.invalid(), - } - } - - fn handle_ok(&mut self, index: u8, total: u8, record: &[u8], nonce: u32) -> Outcome { - if self.manifest_seen { - // Once a transfer has started, changing its total is a protocol error rather than - // an "unchanged" answer. - if total != RECORD_COUNT { - return self.invalid(); - } - } else if total == 0 { - if index != 0 || !record.is_empty() { - return self.invalid(); - } - return self.finish(Status::Unchanged, Outcome::Unchanged); - } else if total != RECORD_COUNT { - return self.invalid(); - } - - if !self.manifest_seen { - // The manifest must be the first record. A data record before it is not accepted. - if index != 0 { - return self.invalid(); - } - let Some(manifest) = decode_manifest(record, nonce) else { - return self.invalid(); - }; - self.manifest = manifest; - self.manifest_seen = true; - // A manifest proves that this is a replacement transfer. Hide the stale cover while - // the new image is assembled; the buffer and generation are swapped atomically only - // after every chunk and the CRC have passed validation. - self.visible = false; - return Outcome::Pending; - } - - // A second manifest is a duplicate index. - if index == 0 { - return self.invalid(); - } - let chunk_index = usize::from(index); - if chunk_index > CHUNK_COUNT { - return self.invalid(); - } - if self.seen[chunk_index - 1] { - return self.invalid(); - } - let Some((offset, data)) = decode_chunk(record, nonce, chunk_index) else { - return self.invalid(); - }; - - self.buffers[self.target_buffer][offset..offset + data.len()].copy_from_slice(data); - self.seen[chunk_index - 1] = true; - - if !self.seen.iter().all(|seen| *seen) { - return Outcome::Pending; - } - - let payload = &self.buffers[self.target_buffer]; - if crc32(payload) != self.manifest.crc32 { - return self.invalid(); - } - - // The old image remains selected until every chunk and the CRC have been checked. - self.current_buffer = self.target_buffer; - self.current_generation = Some(self.manifest.generation); - self.visible = true; - self.finish(Status::Complete, Outcome::Complete) - } - - /// Whether a request is waiting for more replies. - pub fn is_pending(&self) -> bool { - self.active.is_some() - } - - /// Whether a new image was completely decoded and committed. - pub fn is_complete(&self) -> bool { - self.status == Status::Complete - } - - /// The status of the latest request. - pub fn status(&self) -> Status { - self.status - } - - /// The generation of the committed image, if any. - pub fn committed_generation(&self) -> Option { - self.current_generation - } - - /// Whether an image is committed. - pub fn has_artwork(&self) -> bool { - self.current_generation.is_some() - } - - /// Whether the committed image may currently be displayed. - pub fn is_visible(&self) -> bool { - self.visible && self.current_generation.is_some() - } - - /// The committed RGB332 payload. - pub fn current_payload(&self) -> Option<&[u8; PAYLOAD_LEN]> { - self.current_generation - .map(|_| &self.buffers[self.current_buffer]) - } - - /// Looks up one committed pixel and returns its RGB565 colour. - pub fn current_pixel(&self, x: u8, y: u8) -> Option { - if x >= WIDTH || y >= HEIGHT || !self.is_visible() { - return None; - } - let payload = self.current_payload()?; - let pixel = usize::from(x) + usize::from(y) * usize::from(WIDTH); - Some(decode_rgb565(unpack_rgb332(payload, pixel))) - } - - /// Renders every committed pixel through a caller-provided callback. - pub fn for_each_pixel(&self, mut render: impl FnMut(u8, u8, u16)) { - if !self.is_visible() { - return; - } - let Some(payload) = self.current_payload() else { - return; - }; - for y in 0..HEIGHT { - for x in 0..WIDTH { - let pixel = usize::from(x) + usize::from(y) * usize::from(WIDTH); - render(x, y, decode_rgb565(unpack_rgb332(payload, pixel))); - } - } - } - - /// Ends an incomplete request after a timeout. The committed image and generation are left - /// untouched for a complete retry, while any stale cover hidden by the failed transfer stays - /// hidden. - pub fn timeout(&mut self) -> bool { - if self.active.is_none() { - return false; - } - self.clear_transfer(); - self.status = Status::TimedOut; - true - } - - /// Cancels any pending transfer and returns to the idle state. - /// - /// This does not discard the committed image or its generation. - pub fn reset(&mut self) { - self.clear_transfer(); - self.status = Status::Idle; - } - - /// Cancels any transfer and discards the committed image and generation. - pub fn clear(&mut self) { - self.reset(); - self.current_generation = None; - self.visible = false; - } - - fn finish(&mut self, status: Status, outcome: Outcome) -> Outcome { - self.clear_transfer(); - match status { - Status::Complete => self.visible = true, - Status::Unchanged => self.visible = self.current_generation.is_some(), - Status::Unavailable - | Status::PermissionRequired - | Status::Denied - | Status::Unsupported => { - // These outcomes mean there is no usable current image. Reset the generation so a - // later successful request asks for the complete image instead of an empty reply. - self.current_generation = None; - self.visible = false; - } - _ => {} - } - self.status = status; - outcome - } - - fn invalid(&mut self) -> Outcome { - self.clear_transfer(); - self.status = Status::Invalid; - Outcome::Invalid - } - - fn clear_transfer(&mut self) { - self.active = None; - self.manifest_seen = false; - self.seen = [false; CHUNK_COUNT]; - } -} - -impl Default for Receiver { - fn default() -> Self { - Self::new() - } -} - -fn is_empty_result(index: u8, total: u8, record: &[u8]) -> bool { - index == 0 && total == 0 && record.is_empty() -} - -fn decode_manifest(record: &[u8], expected_nonce: u32) -> Option { - if record.len() != MANIFEST_LEN - || record[0] != MANIFEST_VERSION - || record[1] != ENCODING_RGB332_6BPP - || record[2] != WIDTH - || record[3] != HEIGHT - || record[4] != 0 - { - return None; - } - - let nonce = u32::from_le_bytes([record[5], record[6], record[7], record[8]]); - if nonce != expected_nonce { - return None; - } - - let generation = u64::from_le_bytes([ - record[9], record[10], record[11], record[12], record[13], record[14], record[15], - record[16], - ]); - if generation == 0 { - return None; - } - - let payload_len = u32::from_le_bytes([record[17], record[18], record[19], record[20]]); - if payload_len as usize != PAYLOAD_LEN { - return None; - } - - let crc32 = u32::from_le_bytes([record[21], record[22], record[23], record[24]]); - Some(Manifest { generation, crc32 }) -} - -fn decode_chunk(record: &[u8], expected_nonce: u32, index: usize) -> Option<(usize, &[u8])> { - if record.len() < 7 { - return None; - } - let nonce = u32::from_le_bytes([record[0], record[1], record[2], record[3]]); - if nonce != expected_nonce { - return None; - } - - let offset = u16::from_le_bytes([record[4], record[5]]) as usize; - let expected_offset = (index - 1) * CHUNK_LEN; - if offset != expected_offset { - return None; - } - - let expected_len = if index == CHUNK_COUNT { - LAST_CHUNK_LEN - } else { - CHUNK_LEN - }; - let data = &record[6..]; - if data.len() != expected_len { - return None; - } - Some((offset, data)) -} - -/// Extracts one 6-bit RGB332 code from a continuously packed payload. -fn unpack_rgb332(payload: &[u8; PAYLOAD_LEN], pixel: usize) -> u8 { - let bit_offset = pixel * 6; - let mut code = 0_u8; - for bit in 0..6 { - let source = bit_offset + bit; - let value = (payload[source / 8] >> (7 - (source % 8))) & 1; - code = (code << 1) | value; - } - code -} - -/// Decodes a six-bit RGB332-style code (3-bit red, 2-bit green, 1-bit blue). -pub fn decode_rgb565(code: u8) -> u16 { - let red = (code >> 3) & 0x07; - let green = (code >> 1) & 0x03; - let blue = code & 0x01; - - let red = (u16::from(red) * 31 + 3) / 7; - let green = (u16::from(green) * 63 + 1) / 3; - let blue = if blue == 0 { 0 } else { 31 }; - ((red & 0x1f) << 11) | ((green & 0x3f) << 5) | (blue & 0x1f) -} - -/// CRC-32/ISO-HDLC, matching `java.util.zip.CRC32`. -pub fn crc32(data: &[u8]) -> u32 { - let mut crc = 0xffff_ffff_u32; - for byte in data { - crc ^= u32::from(*byte); - for _ in 0..8 { - let mask = 0_u32.wrapping_sub(crc & 1); - crc = (crc >> 1) ^ (0xedb8_8320 & mask); - } - } - !crc -} - -#[cfg(test)] -mod tests { - use super::*; - use std::vec::Vec; - - const ID: u8 = 0x2a; - const NONCE: u32 = 0x1234_5678; - const GENERATION: u64 = 0x0102_0304_0506_0708; - - fn ok(index: u8, total: u8, record: &[u8]) -> Reply<'_> { - Reply { - id: ID, - status: rpc::OK, - index, - total, - record, - } - } - - fn reply(status: u8, index: u8, total: u8, record: &[u8]) -> Reply<'_> { - Reply { - id: ID, - status, - index, - total, - record, - } - } - - fn payload(seed: u8) -> [u8; PAYLOAD_LEN] { - let mut payload = [0_u8; PAYLOAD_LEN]; - for (index, byte) in payload.iter_mut().enumerate() { - *byte = seed.wrapping_add(index as u8).wrapping_mul(17); - } - payload - } - - fn manifest(nonce: u32, generation: u64, payload: &[u8]) -> [u8; MANIFEST_LEN] { - let mut record = [0_u8; MANIFEST_LEN]; - record[0] = MANIFEST_VERSION; - record[1] = ENCODING_RGB332_6BPP; - record[2] = WIDTH; - record[3] = HEIGHT; - record[4] = 0; - record[5..9].copy_from_slice(&nonce.to_le_bytes()); - record[9..17].copy_from_slice(&generation.to_le_bytes()); - record[17..21].copy_from_slice(&(payload.len() as u32).to_le_bytes()); - record[21..25].copy_from_slice(&crc32(payload).to_le_bytes()); - record - } - - fn chunk(nonce: u32, index: usize, payload: &[u8]) -> Vec { - let offset = (index - 1) * CHUNK_LEN; - let len = if index == CHUNK_COUNT { - LAST_CHUNK_LEN - } else { - CHUNK_LEN - }; - let mut record = Vec::with_capacity(6 + len); - record.extend_from_slice(&nonce.to_le_bytes()); - record.extend_from_slice(&(offset as u16).to_le_bytes()); - record.extend_from_slice(&payload[offset..offset + len]); - record - } - - fn send_manifest(receiver: &mut Receiver, record: &[u8]) -> Outcome { - receiver.handle_reply(ok(0, RECORD_COUNT, record)) - } - - fn send_chunk(receiver: &mut Receiver, index: usize, payload: &[u8]) -> Outcome { - let record = chunk(NONCE, index, payload); - receiver.handle_reply(ok(index as u8, RECORD_COUNT, &record)) - } - - fn commit(receiver: &mut Receiver, payload: &[u8], generation: u64) -> Outcome { - let record = manifest(NONCE, generation, payload); - assert_eq!(send_manifest(receiver, &record), Outcome::Pending); - for index in 1..CHUNK_COUNT { - assert_eq!(send_chunk(receiver, index, payload), Outcome::Pending); - } - send_chunk(receiver, CHUNK_COUNT, payload) - } - - #[test] - fn failed_replacement_transfer_forces_a_complete_retry() { - let payload = payload(11); - let mut receiver = Receiver::new(); - receiver.begin(ID, NONCE); - assert_eq!(commit(&mut receiver, &payload, GENERATION), Outcome::Complete); - assert!(receiver.is_visible()); - - receiver.begin(ID, NONCE + 1); - let record = manifest(NONCE + 1, GENERATION + 1, &payload); - assert_eq!(send_manifest(&mut receiver, &record), Outcome::Pending); - assert!(!receiver.is_visible()); - assert!(receiver.timeout()); - - let request = receiver.begin(ID, NONCE + 2); - assert_eq!(&request.bytes()[9..], &GENERATION.to_le_bytes()); - assert_eq!( - receiver.handle_reply(ok(0, 0, &[])), - Outcome::Unchanged - ); - assert!(receiver.is_visible()); - } - - #[test] - fn request_bytes_are_exact_and_advertise_the_committed_generation() { - let mut receiver = Receiver::new(); - let request = receiver.begin(ID, NONCE); - assert_eq!( - request.bytes(), - &[ - b'M', - b'1', - b'Q', - ID, - rpc::MUSIC_ARTWORK, - 0x78, - 0x56, - 0x34, - 0x12, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - ] - ); - - let payload = payload(3); - assert_eq!( - commit(&mut receiver, &payload, GENERATION), - Outcome::Complete - ); - let request = receiver.begin(ID, NONCE + 1); - assert_eq!(&request.bytes()[9..], &GENERATION.to_le_bytes()); - } - - #[test] - fn manifest_fields_are_strictly_validated() { - let payload = payload(9); - let valid = manifest(NONCE, GENERATION, &payload); - let mutations: [(usize, u8); 7] = - [(0, 2), (1, 2), (2, 63), (3, 63), (4, 1), (5, 0), (18, 1)]; - - for (position, value) in mutations { - let mut receiver = Receiver::new(); - receiver.begin(ID, NONCE); - let mut record = valid; - record[position] = value; - assert_eq!(send_manifest(&mut receiver, &record), Outcome::Invalid); - assert_eq!(receiver.status(), Status::Invalid); - assert!(!receiver.has_artwork()); - } - - let mut receiver = Receiver::new(); - receiver.begin(ID, NONCE); - let mut zero_generation = valid; - zero_generation[9..17].fill(0); - assert_eq!( - send_manifest(&mut receiver, &zero_generation), - Outcome::Invalid - ); - - let mut receiver = Receiver::new(); - receiver.begin(ID, NONCE); - assert_eq!( - send_manifest(&mut receiver, &valid[..MANIFEST_LEN - 1]), - Outcome::Invalid - ); - let mut too_long = Vec::from(valid); - too_long.push(0); - receiver.begin(ID, NONCE); - assert_eq!(send_manifest(&mut receiver, &too_long), Outcome::Invalid); - } - - #[test] - fn in_order_and_out_of_order_chunks_commit_atomically() { - let payload = payload(21); - let mut receiver = Receiver::new(); - receiver.begin(ID, NONCE); - let record = manifest(NONCE, GENERATION, &payload); - assert_eq!(send_manifest(&mut receiver, &record), Outcome::Pending); - - for index in 1..CHUNK_COUNT { - assert_eq!(send_chunk(&mut receiver, index, &payload), Outcome::Pending); - } - assert_eq!( - send_chunk(&mut receiver, CHUNK_COUNT, &payload), - Outcome::Complete - ); - assert_eq!(receiver.status(), Status::Complete); - - // The protocol has no separate end marker: the last received chunk completes the set. - // Feed a fresh transfer in a deliberately scrambled order. - receiver.begin(ID, NONCE + 1); - let record = manifest(NONCE + 1, GENERATION + 1, &payload); - assert_eq!(send_manifest(&mut receiver, &record), Outcome::Pending); - for index in [ - 5, 1, 27, 2, 26, 3, 25, 4, 24, 6, 23, 7, 22, 8, 21, 9, 20, 10, 19, 11, 18, 12, 17, 13, - 16, 14, 15, - ] { - let offset = (index - 1) * CHUNK_LEN; - let len = if index == CHUNK_COUNT { - LAST_CHUNK_LEN - } else { - CHUNK_LEN - }; - let mut record = Vec::new(); - record.extend_from_slice(&(NONCE + 1).to_le_bytes()); - record.extend_from_slice(&(offset as u16).to_le_bytes()); - record.extend_from_slice(&payload[offset..offset + len]); - let outcome = receiver.handle_reply(ok(index as u8, RECORD_COUNT, &record)); - if index == 15 { - assert_eq!(outcome, Outcome::Complete); - } else { - assert_eq!(outcome, Outcome::Pending); - } - } - assert_eq!(receiver.status(), Status::Complete); - assert_eq!(receiver.committed_generation(), Some(GENERATION + 1)); - assert_eq!(receiver.current_payload(), Some(&payload)); - } - - #[test] - fn duplicate_index_invalidates_the_transfer() { - let payload = payload(31); - let mut receiver = Receiver::new(); - receiver.begin(ID, NONCE); - let record = manifest(NONCE, GENERATION, &payload); - assert_eq!(send_manifest(&mut receiver, &record), Outcome::Pending); - assert_eq!(send_chunk(&mut receiver, 1, &payload), Outcome::Pending); - assert_eq!(send_chunk(&mut receiver, 1, &payload), Outcome::Invalid); - assert_eq!(receiver.status(), Status::Invalid); - assert!(!receiver.has_artwork()); - } - - #[test] - fn wrong_nonce_offset_length_total_and_index_are_rejected() { - let payload = payload(41); - let valid_manifest = manifest(NONCE, GENERATION, &payload); - - let mut receiver = Receiver::new(); - receiver.begin(ID, NONCE); - let mut wrong_nonce = valid_manifest; - wrong_nonce[5] ^= 1; - assert_eq!(send_manifest(&mut receiver, &wrong_nonce), Outcome::Invalid); - - let mut receiver = Receiver::new(); - receiver.begin(ID, NONCE); - assert_eq!( - send_manifest(&mut receiver, &valid_manifest), - Outcome::Pending - ); - let mut record = chunk(NONCE, 1, &payload); - record[0] ^= 1; - assert_eq!( - receiver.handle_reply(ok(1, RECORD_COUNT, &record)), - Outcome::Invalid - ); - - let mut receiver = Receiver::new(); - receiver.begin(ID, NONCE); - assert_eq!( - send_manifest(&mut receiver, &valid_manifest), - Outcome::Pending - ); - let mut record = chunk(NONCE, 1, &payload); - record[4] ^= 1; - assert_eq!( - receiver.handle_reply(ok(1, RECORD_COUNT, &record)), - Outcome::Invalid - ); - - let mut receiver = Receiver::new(); - receiver.begin(ID, NONCE); - assert_eq!( - send_manifest(&mut receiver, &valid_manifest), - Outcome::Pending - ); - let mut record = chunk(NONCE, 1, &payload); - record.pop(); - assert_eq!( - receiver.handle_reply(ok(1, RECORD_COUNT, &record)), - Outcome::Invalid - ); - - let mut receiver = Receiver::new(); - receiver.begin(ID, NONCE); - assert_eq!( - send_manifest(&mut receiver, &valid_manifest), - Outcome::Pending - ); - assert_eq!( - receiver.handle_reply(ok(1, RECORD_COUNT - 1, &chunk(NONCE, 1, &payload))), - Outcome::Invalid - ); - - let mut receiver = Receiver::new(); - receiver.begin(ID, NONCE); - assert_eq!( - send_manifest(&mut receiver, &valid_manifest), - Outcome::Pending - ); - assert_eq!( - receiver.handle_reply(ok(28, RECORD_COUNT, &chunk(NONCE, 27, &payload))), - Outcome::Invalid - ); - } - - #[test] - fn a_missing_final_chunk_times_out_without_changing_the_image() { - let old_payload = payload(51); - let mut receiver = Receiver::new(); - receiver.begin(ID, NONCE); - assert_eq!( - commit(&mut receiver, &old_payload, GENERATION), - Outcome::Complete - ); - - let new_payload = payload(52); - receiver.begin(ID, NONCE + 1); - let record = manifest(NONCE + 1, GENERATION + 1, &new_payload); - assert_eq!(send_manifest(&mut receiver, &record), Outcome::Pending); - assert!(!receiver.is_visible()); - for index in 1..CHUNK_COUNT { - let offset = (index - 1) * CHUNK_LEN; - let mut chunk = Vec::new(); - chunk.extend_from_slice(&(NONCE + 1).to_le_bytes()); - chunk.extend_from_slice(&(offset as u16).to_le_bytes()); - chunk.extend_from_slice(&new_payload[offset..offset + CHUNK_LEN]); - assert_eq!( - receiver.handle_reply(ok(index as u8, RECORD_COUNT, &chunk)), - Outcome::Pending - ); - } - assert!(receiver.is_pending()); - assert!(receiver.timeout()); - assert_eq!(receiver.status(), Status::TimedOut); - assert_eq!(receiver.committed_generation(), Some(GENERATION)); - assert_eq!(receiver.current_payload(), Some(&old_payload)); - assert!(!receiver.is_visible()); - } - - #[test] - fn crc_failure_keeps_the_old_image_and_a_valid_transfer_replaces_it() { - let old_payload = payload(61); - let new_payload = payload(62); - let mut receiver = Receiver::new(); - receiver.begin(ID, NONCE); - assert_eq!( - commit(&mut receiver, &old_payload, GENERATION), - Outcome::Complete - ); - - receiver.begin(ID, NONCE + 1); - let mut bad_manifest = manifest(NONCE + 1, GENERATION + 1, &new_payload); - bad_manifest[21] ^= 1; - assert_eq!( - send_manifest(&mut receiver, &bad_manifest), - Outcome::Pending - ); - assert!(!receiver.is_visible()); - for index in 1..CHUNK_COUNT { - let offset = (index - 1) * CHUNK_LEN; - let len = CHUNK_LEN; - let mut record = Vec::new(); - record.extend_from_slice(&(NONCE + 1).to_le_bytes()); - record.extend_from_slice(&(offset as u16).to_le_bytes()); - record.extend_from_slice(&new_payload[offset..offset + len]); - assert_eq!( - receiver.handle_reply(ok(index as u8, RECORD_COUNT, &record)), - Outcome::Pending - ); - } - let offset = (CHUNK_COUNT - 1) * CHUNK_LEN; - let mut record = Vec::new(); - record.extend_from_slice(&(NONCE + 1).to_le_bytes()); - record.extend_from_slice(&(offset as u16).to_le_bytes()); - record.extend_from_slice(&new_payload[offset..offset + LAST_CHUNK_LEN]); - assert_eq!( - receiver.handle_reply(ok(CHUNK_COUNT as u8, RECORD_COUNT, &record)), - Outcome::Invalid - ); - assert_eq!(receiver.status(), Status::Invalid); - assert_eq!(receiver.committed_generation(), Some(GENERATION)); - assert_eq!(receiver.current_payload(), Some(&old_payload)); - assert!(!receiver.is_visible()); - - receiver.begin(ID, NONCE + 2); - let record = manifest(NONCE + 2, GENERATION + 2, &new_payload); - assert_eq!(send_manifest(&mut receiver, &record), Outcome::Pending); - for index in 1..=CHUNK_COUNT { - let offset = (index - 1) * CHUNK_LEN; - let len = if index == CHUNK_COUNT { - LAST_CHUNK_LEN - } else { - CHUNK_LEN - }; - let mut record = Vec::new(); - record.extend_from_slice(&(NONCE + 2).to_le_bytes()); - record.extend_from_slice(&(offset as u16).to_le_bytes()); - record.extend_from_slice(&new_payload[offset..offset + len]); - receiver.handle_reply(ok(index as u8, RECORD_COUNT, &record)); - } - assert_eq!(receiver.status(), Status::Complete); - assert_eq!(receiver.committed_generation(), Some(GENERATION + 2)); - assert_eq!(receiver.current_payload(), Some(&new_payload)); - assert!(receiver.is_visible()); - } - - #[test] - fn unchanged_unavailable_permission_and_unsupported_results_are_distinct() { - let mut receiver = Receiver::new(); - receiver.begin(ID, NONCE); - assert_eq!(receiver.handle_reply(ok(0, 0, &[])), Outcome::Unchanged); - assert_eq!(receiver.status(), Status::Unchanged); - assert!(!receiver.has_artwork()); - - receiver.begin(ID, NONCE + 1); - assert_eq!( - receiver.handle_reply(reply(rpc::UNAVAILABLE, 0, 0, &[])), - Outcome::Unavailable - ); - assert_eq!(receiver.status(), Status::Unavailable); - - receiver.begin(ID, NONCE + 2); - assert_eq!( - receiver.handle_reply(reply(rpc::ASK, 0, 0, &[])), - Outcome::PermissionRequired - ); - assert_eq!(receiver.status(), Status::PermissionRequired); - - receiver.begin(ID, NONCE + 3); - assert_eq!( - receiver.handle_reply(reply(rpc::DENIED, 0, 0, &[])), - Outcome::Denied - ); - assert_eq!(receiver.status(), Status::Denied); - - receiver.begin(ID, NONCE + 4); - assert_eq!( - receiver.handle_reply(reply(rpc::BAD_REQUEST, 0, 0, &[])), - Outcome::Unsupported - ); - assert_eq!(receiver.status(), Status::Unsupported); - } - - #[test] - fn wrong_id_is_ignored_without_changing_pending_state() { - let mut receiver = Receiver::new(); - receiver.begin(ID, NONCE); - let response = Reply { - id: ID + 1, - status: rpc::OK, - index: 0, - total: 0, - record: &[], - }; - assert_eq!(receiver.handle_reply(response), Outcome::Ignored); - assert!(receiver.is_pending()); - assert_eq!(receiver.status(), Status::Pending); - } - - #[test] - fn rgb332_golden_decode_handles_continuous_msb_first_packing() { - assert_eq!(crc32(b"123456789"), 0xcbf4_3926); - assert_eq!(decode_rgb565(0x00), 0x0000); - assert_eq!(decode_rgb565(0x06), 0x07e0); - assert_eq!(decode_rgb565(0x38), 0xf800); - assert_eq!(decode_rgb565(0x01), 0x001f); - assert_eq!(decode_rgb565(0x3f), 0xffff); - - let mut packed = [0_u8; PAYLOAD_LEN]; - packed[..3].copy_from_slice(&[0x00, 0x1f, 0xe0]); - assert_eq!(unpack_rgb332(&packed, 0), 0x00); - assert_eq!(unpack_rgb332(&packed, 1), 0x01); - assert_eq!(unpack_rgb332(&packed, 2), 0x3f); - assert_eq!(unpack_rgb332(&packed, 3), 0x20); - } -} diff --git a/apps/music-controller/src/main.rs b/apps/music-controller/src/main.rs deleted file mode 100644 index 0fc298f..0000000 --- a/apps/music-controller/src/main.rs +++ /dev/null @@ -1,170 +0,0 @@ -#![cfg_attr( - any(target_os = "none", wp2_sim), - no_main, - cfg_attr(target_os = "none", no_std) -)] - -#[cfg_attr(not(any(target_os = "none", wp2_sim)), allow(dead_code))] -mod artwork; -#[cfg_attr(not(any(target_os = "none", wp2_sim)), allow(dead_code))] -mod model; -#[cfg_attr(not(any(target_os = "none", wp2_sim)), allow(dead_code))] -mod ntype82; -#[cfg_attr(not(any(target_os = "none", wp2_sim)), allow(dead_code))] -mod rpc; -#[cfg_attr(not(any(target_os = "none", wp2_sim)), allow(dead_code))] -mod track; -#[cfg_attr(not(any(target_os = "none", wp2_sim)), allow(dead_code))] -mod view; - -#[cfg(not(any(target_os = "none", wp2_sim)))] -fn main() {} - -#[cfg(any(target_os = "none", wp2_sim))] -mod device { - use crate::model::{wall_min, Got, Model, BLOB_MAX}; - use crate::rpc; - use crate::view::{action, frame, Action}; - use cmf_wp2_app::{Api, BUTTON, CROWN, MSG_MAX, PAUSE, RESUME, TOUCH_DOWN}; - use cmf_wp2_ui::haptic::{Motor, TICK}; - use core::ptr::addr_of_mut; - - cmf_wp2_app::entry!(main); - #[cfg(not(wp2_sim))] - cmf_wp2_app::app_icon!(); - - // Keep the model and cache buffer off the 8 KiB stack. - static mut MODEL: Model = Model::new(); - static mut BLOB: [u8; BLOB_MAX] = [0; BLOB_MAX]; - - /// Local wall-clock minutes, used for the cache timestamp rather than the monotonic millisecond clock. - fn wall(api: &Api) -> i32 { - api.time().map_or(0, |t| { - wall_min( - t.year as i32, - t.month as u32, - t.day as u32, - t.hour as u32, - t.minute as u32, - ) - }) - } - - /// Persist metadata only when it changed and the NAND write succeeded. - fn save_cache(api: &Api, model: &mut Model, blob: &mut [u8; BLOB_MAX]) { - if !model.cache_dirty() { - return; - } - let len = model.save(blob); - if len > 0 && api.save(&blob[..len]) == 0 { - model.cache_saved(); - } - } - - // true on RESUME, false on BUTTON - fn paused(api: &Api) -> bool { - loop { - match api.event(u32::MAX).map(|e| e.kind) { - Some(RESUME) => return true, - Some(BUTTON) => return false, - _ => {} - } - } - } - - fn main(api: &'static Api) -> i32 { - let m = unsafe { &mut *addr_of_mut!(MODEL) }; - let blob = unsafe { &mut *addr_of_mut!(BLOB) }; - let n = api.load(blob); - if n > 0 { - m.load(&blob[..n as usize]); - } - m.ask_now(api.now()); - - let mut screen = api; - let mut motor = Motor::new(api); - let mut drawn = None; - let mut msg = [0u8; MSG_MAX]; - loop { - motor.update(); - let now = api.now(); - let wall = wall(api); - while let Some(data) = api.recv(&mut msg) { - if m.reply(data, now, wall) == Got::Save { - save_cache(api, m, blob); // on change: the app can end without notice - } - } - if let Some(request) = m.poll(now) { - if api.send(request.bytes()) != 0 { - // No host or a full outbox is not a 30-second silence; recover on the next backoff. - m.send_failed(now); - drawn = None; - } - } - if drawn != Some(m.rev) { - frame(&mut screen, m); - api.show(); - drawn = Some(m.rev); - } - - let wait = m.wait(api.now()).min(motor.wait().unwrap_or(u32::MAX)); - let Some(event) = api.event(wait) else { - continue; - }; - match event.kind { - BUTTON => return 0, - PAUSE => { - motor.off(); - if !paused(api) { - return 0; - } - m.ask_now(api.now()); - drawn = None; - } - RESUME => { - m.ask_now(api.now()); - drawn = None; - } - TOUCH_DOWN => { - let action = action( - event.x as i32, - event.y as i32, - m.max_volume(), - m.controls_enabled(), - m.volume_enabled(), - ); - let queued = match action { - Action::Previous => m.command(rpc::PREVIOUS, 0), - Action::Toggle => m.command(rpc::TOGGLE, 0), - Action::Next => m.command(rpc::NEXT, 0), - Action::VolumeUp => m.command(rpc::VOLUME_UP, 0), - Action::VolumeDown => m.command(rpc::VOLUME_DOWN, 0), - Action::SetVolume(value) => m.command(rpc::SET_VOLUME, value), - Action::None => false, - }; - if queued { - motor.play(TICK); - save_cache(api, m, blob); - drawn = None; - } - } - CROWN => { - // The crown adjusts the visible music volume, while the button remains the back action. - if event.delta != 0 { - let command = if event.delta > 0 { - rpc::VOLUME_UP - } else { - rpc::VOLUME_DOWN - }; - if m.command(command, 0) { - motor.play(TICK); - save_cache(api, m, blob); - drawn = None; - } - } - } - _ => {} // MESSAGE: drained at the top - } - } - } -} diff --git a/apps/music-controller/src/model.rs b/apps/music-controller/src/model.rs deleted file mode 100644 index 4147af3..0000000 --- a/apps/music-controller/src/model.rs +++ /dev/null @@ -1,1524 +0,0 @@ -//! The phone-music state machine: requests, optimistic commands and the local cache. -//! -//! One RPC request is in flight at a time. Commands tapped while a snapshot is in flight wait in a -//! small local queue. The watch accepts the current title, artist, and a low-resolution artwork -//! thumbnail; those values stay in memory and are never written to the local cache. - -use crate::artwork; -use crate::rpc::{self, Metadata}; -use crate::track; - -pub const POLL_MS: u32 = 2_000; -pub const RETRY_MS: u32 = 3_000; -pub const ASK_AGAIN_MS: u32 = 10_000; -pub const COMMAND_REFRESH_MS: u32 = 250; -pub const SNAPSHOT_TIMEOUT_MS: u32 = 10_000; -pub const COMMAND_TIMEOUT_MS: u32 = 8_000; -pub const TRACK_TIMEOUT_MS: u32 = 10_000; -pub const ARTWORK_TIMEOUT_MS: u32 = 30_000; -pub const TRACK_POLL_MS: u32 = 2_000; -pub const ARTWORK_POLL_MS: u32 = 2_000; -pub const ARTWORK_NO_IMAGE_MS: u32 = 10_000; -pub const ARTWORK_UNSUPPORTED_MS: u32 = 30_000; -pub const MAX_BACKOFF_MS: u32 = 30_000; - -const COMMAND_QUEUE_MAX: usize = 8; -/// Maximum printable-ASCII bytes retained for the title and artist. -pub const TRACK_TEXT_MAX: usize = 60; -const MAGIC: &[u8; 2] = b"M2"; -/// Magic, fetched wall minute, then the four-byte metadata record. -pub const BLOB_MAX: usize = 2 + 4 + 4; - -#[derive(Clone, Copy, PartialEq, Eq)] -#[cfg_attr(test, derive(Debug))] -pub enum Status { - Waiting, - Ok, - Ask, - Denied, - Unavailable, - /// The latest request got no answer. - Silent, -} - -#[derive(Clone, Copy, PartialEq, Eq)] -#[cfg_attr(test, derive(Debug))] -pub enum Got { - Nothing, - /// The screen changed. - Changed, - /// Metadata changed and should be written to the watch's local storage. - Save, -} - -#[derive(Clone, Copy, PartialEq, Eq)] -#[cfg_attr(test, derive(Debug))] -enum Active { - Snapshot { - id: u8, - started: u32, - }, - Track { - id: u8, - started: u32, - }, - Artwork { - id: u8, - nonce: u32, - started: u32, - }, - Command { - id: u8, - command: u8, - value: u8, - before: Metadata, - started: u32, - }, -} - -#[derive(Clone, Copy, PartialEq, Eq)] -#[cfg_attr(test, derive(Debug))] -struct Command { - code: u8, - value: u8, - before: Metadata, -} - -pub struct Model { - pub metadata: Metadata, - pub has_snapshot: bool, - pub status: Status, - /// Wall minute of the last committed snapshot. - pub fetched: Option, - /// Bumped on every visible change. - pub rev: u32, - - title: [u8; TRACK_TEXT_MAX], - title_len: u8, - artist: [u8; TRACK_TEXT_MAX], - artist_len: u8, - - id: u8, - next_poll: u32, - next_command: u32, - next_track: u32, - next_artwork: u32, - artwork_nonce: u32, - artwork_backoff: u32, - backoff: u32, - active: Option, - artwork: artwork::Receiver, - pending_title: [u8; TRACK_TEXT_MAX], - pending_title_len: u8, - pending_artist: [u8; TRACK_TEXT_MAX], - pending_artist_len: u8, - track_seen: u8, - commands: [Command; COMMAND_QUEUE_MAX], - command_head: usize, - /// Pending commands, including the active command while it is at the queue head. - command_len: usize, - cache_dirty: bool, -} - -impl Model { - pub const fn new() -> Self { - Model { - metadata: Metadata::EMPTY, - has_snapshot: false, - status: Status::Waiting, - fetched: None, - rev: 0, - title: [0; TRACK_TEXT_MAX], - title_len: 0, - artist: [0; TRACK_TEXT_MAX], - artist_len: 0, - id: 0, - next_poll: 0, - next_command: 0, - next_track: TRACK_POLL_MS, - next_artwork: ARTWORK_POLL_MS, - artwork_nonce: 0, - artwork_backoff: 1_000, - backoff: RETRY_MS, - active: None, - artwork: artwork::Receiver::new(), - pending_title: [0; TRACK_TEXT_MAX], - pending_title_len: 0, - pending_artist: [0; TRACK_TEXT_MAX], - pending_artist_len: 0, - track_seen: 0, - commands: [Command { - code: 0, - value: 0, - before: Metadata::EMPTY, - }; COMMAND_QUEUE_MAX], - command_head: 0, - command_len: 0, - cache_dirty: false, - } - } - - /// Ask at once (start or RESUME). A reply from the previous run has a different id and is ignored. - pub fn ask_now(&mut self, now: u32) { - self.active = None; - self.artwork.reset(); - self.backoff = RETRY_MS; - self.next_poll = now; - self.next_track = now.wrapping_add(TRACK_POLL_MS); - self.next_artwork = now.wrapping_add(ARTWORK_POLL_MS); - if self.command_len > 0 { - self.next_command = now; - } - self.rev += 1; - } - - /// Whether the current metadata represents an active media session. - pub fn active(&self) -> bool { - self.metadata.active() - } - - /// The current music stream volume. - pub fn volume(&self) -> u8 { - self.metadata.volume - } - - /// The maximum music stream volume. - pub fn max_volume(&self) -> u8 { - self.metadata.max_volume - } - - /// Whether the current media session is playing. - pub fn playing(&self) -> bool { - self.metadata.playing() - } - - /// The current track title, kept only in memory. - pub fn track_title(&self) -> &str { - core::str::from_utf8(&self.title[..self.title_len as usize]).unwrap_or("") - } - - /// The current track artist, kept only in memory. - pub fn track_artist(&self) -> &str { - core::str::from_utf8(&self.artist[..self.artist_len as usize]).unwrap_or("") - } - - /// Replace the in-memory title and artist. Returns whether the visible text changed. - pub fn set_track_text(&mut self, title: &[u8], artist: &[u8]) -> bool { - let title_len = title.len().min(TRACK_TEXT_MAX); - let artist_len = artist.len().min(TRACK_TEXT_MAX); - let changed = self.title_len as usize != title_len - || self.artist_len as usize != artist_len - || self.title[..title_len] != title[..title_len] - || self.artist[..artist_len] != artist[..artist_len]; - if changed { - self.title[..title_len].copy_from_slice(&title[..title_len]); - self.artist[..artist_len].copy_from_slice(&artist[..artist_len]); - self.title_len = title_len as u8; - self.artist_len = artist_len as u8; - self.rev += 1; - } - changed - } - - /// Whether a complete artwork image may currently be displayed. - pub fn artwork_visible(&self) -> bool { - self.artwork.is_visible() - } - - /// The committed artwork generation, or zero when there is none. - pub fn artwork_generation(&self) -> u64 { - self.artwork.committed_generation().unwrap_or(0) - } - - /// One artwork pixel in RGB565. - pub fn artwork_pixel(&self, x: u8, y: u8) -> Option { - self.artwork.current_pixel(x, y) - } - - /// Transport controls are live only while the phone has confirmed an active session. - pub fn controls_enabled(&self) -> bool { - self.status == Status::Ok && self.active() - } - - /// Volume controls require a live session and a known non-zero maximum. - pub fn volume_enabled(&self) -> bool { - self.controls_enabled() && self.max_volume() > 0 - } - - /// The next request to send, if any. - pub fn poll(&mut self, now: u32) -> Option { - if let Some(active) = self.active { - if now.wrapping_sub(started_at(active)) >= timeout_for(active) { - match active { - Active::Command { .. } => self.send_failed(now), - Active::Snapshot { .. } => { - self.active = None; - self.status = Status::Silent; - self.backoff = (self.backoff * 2).min(MAX_BACKOFF_MS); - self.next_poll = now.wrapping_add(self.backoff); - self.rev += 1; - } - Active::Track { .. } => { - self.active = None; - self.next_track = now.wrapping_add(TRACK_POLL_MS); - } - Active::Artwork { .. } => { - let was_visible = self.artwork.is_visible(); - self.active = None; - self.artwork.timeout(); - self.next_artwork = now.wrapping_add(self.artwork_backoff); - self.artwork_backoff = (self.artwork_backoff * 2).min(MAX_BACKOFF_MS); - if was_visible != self.artwork.is_visible() { - self.rev += 1; - } - } - } - } - return None; - } - - if self.command_len > 0 && due(now, self.next_command) { - // Keep the active command at the queue head until a valid reply completes it. If it - // times out or cannot be sent, the same slot is retried before later commands. - let command = self.commands[self.command_head]; - self.id = self.id.wrapping_add(1); - self.active = Some(Active::Command { - id: self.id, - command: command.code, - value: command.value, - before: command.before, - started: now, - }); - return Some(rpc::command_request(self.id, command.code, command.value)); - } - - if due(now, self.next_poll) { - self.id = self.id.wrapping_add(1); - self.active = Some(Active::Snapshot { - id: self.id, - started: now, - }); - return Some(rpc::snapshot_request(self.id)); - } - - // Track text and artwork are meaningful only while a confirmed media session exists. - // A no-media snapshot therefore also suppresses both follow-up requests. - if self.has_snapshot && self.status == Status::Ok && self.active() && due(now, self.next_track) { - self.id = self.id.wrapping_add(1); - self.active = Some(Active::Track { - id: self.id, - started: now, - }); - self.track_seen = 0; - self.pending_title_len = 0; - self.pending_artist_len = 0; - return Some(rpc::track_request(self.id)); - } - - if self.has_snapshot && self.status == Status::Ok && self.active() && due(now, self.next_artwork) { - self.id = self.id.wrapping_add(1); - self.artwork_nonce = self.artwork_nonce.wrapping_add(1).max(1); - self.active = Some(Active::Artwork { - id: self.id, - nonce: self.artwork_nonce, - started: now, - }); - return Some(self.artwork.begin(self.id, self.artwork_nonce)); - } - - None - } - - /// Queue a playback or volume command and update the visible state immediately. - pub fn command(&mut self, command: u8, value: u8) -> bool { - // The active command remains in the queue, so this bounds all pending commands rather - // than allowing an in-flight command plus a full queue of later commands. - if self.command_len == COMMAND_QUEUE_MAX - || !matches!( - command, - rpc::PLAY - | rpc::PAUSE - | rpc::TOGGLE - | rpc::PREVIOUS - | rpc::NEXT - | rpc::VOLUME_UP - | rpc::VOLUME_DOWN - | rpc::SET_VOLUME - ) - { - return false; - } - - let old = self.metadata; - let before = old; - apply_command(&mut self.metadata, command, value); - - let at = (self.command_head + self.command_len) % COMMAND_QUEUE_MAX; - self.commands[at] = Command { - code: command, - value, - before, - }; - if self.command_len == 0 { - self.next_command = 0; - } - self.command_len += 1; - - if !old.same_data(&self.metadata) { - self.cache_dirty = true; - self.rev += 1; - } - true - } - - /// Recover immediately when the loader could not queue a request. An active command stays at - /// the front of the bounded queue so a transient outbox or host failure does not drop it or - /// move it behind commands that were entered later. - pub fn send_failed(&mut self, now: u32) { - let Some(active) = self.active.take() else { - return; - }; - match active { - Active::Snapshot { .. } => { - self.next_poll = now.wrapping_add(self.backoff); - self.status = Status::Silent; - self.backoff = (self.backoff * 2).min(MAX_BACKOFF_MS); - self.rev += 1; - } - Active::Command { .. } => { - self.next_command = now.wrapping_add(self.backoff); - self.next_poll = now.wrapping_add(self.backoff); - self.status = Status::Silent; - self.backoff = (self.backoff * 2).min(MAX_BACKOFF_MS); - self.rev += 1; - } - Active::Track { .. } => { - self.next_track = now.wrapping_add(TRACK_POLL_MS); - } - Active::Artwork { .. } => { - let was_visible = self.artwork.is_visible(); - self.artwork.timeout(); - self.next_artwork = now.wrapping_add(self.artwork_backoff); - self.artwork_backoff = (self.artwork_backoff * 2).min(MAX_BACKOFF_MS); - if was_visible != self.artwork.is_visible() { - self.rev += 1; - } - } - } - } - - /// Handle one host message. - pub fn reply(&mut self, message: &[u8], now: u32, wall: i32) -> Got { - let Some(reply) = rpc::reply(message) else { - return Got::Nothing; - }; - let Some(active) = self.active else { - return Got::Nothing; - }; - match active { - Active::Command { id, before, .. } if id == reply.id => { - self.active = None; - self.remove_active_command(); - self.next_poll = now.wrapping_add(COMMAND_REFRESH_MS); - self.next_command = now.wrapping_add(COMMAND_REFRESH_MS); - - let malformed = !reply.is_command_result(); - self.status = if malformed { - Status::Unavailable - } else if reply.status == rpc::OK { - Status::Ok - } else { - status_of(reply.status) - }; - // A malformed result is not a successful command. Treat it like a rejected - // command so the optimistic effect cannot survive without a valid acknowledgement. - let rolled_back = - (malformed || reply.status != rpc::OK) && self.rollback_command(before); - self.rev += 1; - if rolled_back { - self.cache_dirty = true; - Got::Save - } else { - Got::Changed - } - } - Active::Snapshot { id, .. } if id == reply.id => self.snapshot(reply, now, wall), - Active::Track { id, .. } if id == reply.id => self.track(reply, now), - Active::Artwork { id, .. } if id == reply.id => self.artwork_reply(reply, now), - _ => Got::Nothing, - } - } - - /// Remove the command currently at the queue head after a terminal reply. - fn remove_active_command(&mut self) { - debug_assert!(self.command_len > 0); - self.command_head = (self.command_head + 1) % COMMAND_QUEUE_MAX; - self.command_len -= 1; - } - - /// Restore the state before a denied command, then reapply commands still queued behind it. - fn rollback_command(&mut self, before: Metadata) -> bool { - let old = self.metadata; - self.metadata = before; - self.reapply_queued_commands(); - !old.same_data(&self.metadata) - } - - /// Reapply queued optimistic commands and record each command's new rollback baseline. - fn reapply_queued_commands(&mut self) { - let mut state = self.metadata; - for offset in 0..self.command_len { - let index = (self.command_head + offset) % COMMAND_QUEUE_MAX; - let mut command = self.commands[index]; - command.before = state; - apply_command(&mut state, command.code, command.value); - self.commands[index] = command; - } - self.metadata = state; - } - - fn track(&mut self, reply: rpc::Reply<'_>, now: u32) -> Got { - if reply.status != rpc::OK { - // Error replies have one exact empty shape. Any other shape is malformed and must not - // be interpreted as a meaningful permission or compatibility response. - if reply.index != 0 || reply.total != 0 || !reply.record.is_empty() { - return self.reject_track(now); - } - self.active = None; - let retry = match reply.status { - rpc::BAD_REQUEST => ARTWORK_UNSUPPORTED_MS, - rpc::ASK | rpc::DENIED => ASK_AGAIN_MS, - _ => RETRY_MS, - }; - self.next_track = now.wrapping_add(retry); - self.clear_track_text(); - return Got::Changed; - } - if reply.total != track::TRACK_TOTAL || reply.index >= track::TRACK_TOTAL { - return self.reject_track(now); - } - let Some((field, text)) = track::decode(reply.record) else { - return self.reject_track(now); - }; - let expected = if reply.index == 0 { - track::Field::Title - } else { - track::Field::Artist - }; - if field != expected { - return self.reject_track(now); - } - - let bit = if field == track::Field::Title { 1 } else { 2 }; - if self.track_seen & bit != 0 { - return self.reject_track(now); - } - if field == track::Field::Title { - self.pending_title[..text.len()].copy_from_slice(text); - self.pending_title_len = text.len() as u8; - } else { - self.pending_artist[..text.len()].copy_from_slice(text); - self.pending_artist_len = text.len() as u8; - } - self.track_seen |= bit; - - if self.track_seen != 3 { - return Got::Nothing; - } - - self.active = None; - self.next_track = now.wrapping_add(TRACK_POLL_MS); - let mut title = [0_u8; TRACK_TEXT_MAX]; - let mut artist = [0_u8; TRACK_TEXT_MAX]; - title[..self.pending_title_len as usize] - .copy_from_slice(&self.pending_title[..self.pending_title_len as usize]); - artist[..self.pending_artist_len as usize] - .copy_from_slice(&self.pending_artist[..self.pending_artist_len as usize]); - self.set_track_text( - &title[..self.pending_title_len as usize], - &artist[..self.pending_artist_len as usize], - ); - Got::Changed - } - - fn reject_track(&mut self, now: u32) -> Got { - self.active = None; - self.next_track = now.wrapping_add(TRACK_POLL_MS); - self.clear_track_text(); - Got::Changed - } - - fn clear_track_text(&mut self) { - self.set_track_text(&[], &[]); - } - - fn artwork_reply(&mut self, reply: rpc::Reply<'_>, now: u32) -> Got { - let was_visible = self.artwork.is_visible(); - let outcome = self.artwork.handle_reply(reply); - let visible_changed = was_visible != self.artwork.is_visible(); - match outcome { - artwork::Outcome::Ignored | artwork::Outcome::Pending => { - if visible_changed { - self.rev += 1; - Got::Changed - } else { - Got::Nothing - } - } - artwork::Outcome::Complete => { - self.active = None; - self.next_artwork = now.wrapping_add(ARTWORK_POLL_MS); - self.artwork_backoff = 1_000; - self.rev += 1; - Got::Changed - } - artwork::Outcome::Unchanged => { - self.active = None; - self.next_artwork = now.wrapping_add(ARTWORK_POLL_MS); - self.artwork_backoff = 1_000; - if visible_changed { - self.rev += 1; - Got::Changed - } else { - Got::Nothing - } - } - artwork::Outcome::Unavailable => { - self.active = None; - self.next_artwork = now.wrapping_add(ARTWORK_NO_IMAGE_MS); - self.artwork_backoff = 1_000; - if visible_changed { - self.rev += 1; - Got::Changed - } else { - Got::Nothing - } - } - artwork::Outcome::PermissionRequired | artwork::Outcome::Denied => { - self.active = None; - self.next_artwork = now.wrapping_add(ARTWORK_NO_IMAGE_MS); - self.artwork_backoff = 1_000; - if visible_changed { - self.rev += 1; - Got::Changed - } else { - Got::Nothing - } - } - artwork::Outcome::Unsupported => { - self.active = None; - self.next_artwork = now.wrapping_add(ARTWORK_UNSUPPORTED_MS); - self.artwork_backoff = 1_000; - if visible_changed { - self.rev += 1; - Got::Changed - } else { - Got::Nothing - } - } - artwork::Outcome::Invalid => { - self.active = None; - self.next_artwork = now.wrapping_add(self.artwork_backoff); - self.artwork_backoff = (self.artwork_backoff * 2).min(MAX_BACKOFF_MS); - if visible_changed { - self.rev += 1; - Got::Changed - } else { - Got::Nothing - } - } - } - } - - fn snapshot(&mut self, reply: rpc::Reply<'_>, now: u32, wall: i32) -> Got { - if reply.status != rpc::OK { - self.active = None; - self.status = status_of(reply.status); - self.next_poll = now.wrapping_add(if self.status == Status::Ask { - ASK_AGAIN_MS - } else { - RETRY_MS - }); - self.rev += 1; - return Got::Changed; - } - if reply.total != 1 || reply.index != 0 { - return self.reject_snapshot(now); - } - let Some(metadata) = Metadata::decode(reply.record) else { - return self.reject_snapshot(now); - }; - self.commit(metadata, now, wall) - } - - fn reject_snapshot(&mut self, now: u32) -> Got { - self.active = None; - self.status = Status::Unavailable; - self.next_poll = now.wrapping_add(RETRY_MS); - self.rev += 1; - Got::Changed - } - - fn commit(&mut self, metadata: Metadata, now: u32, wall: i32) -> Got { - let old = self.metadata; - self.metadata = metadata; - self.reapply_queued_commands(); - self.has_snapshot = true; - self.fetched = Some(wall); - self.status = Status::Ok; - self.backoff = RETRY_MS; - self.next_poll = now.wrapping_add(POLL_MS); - if !due(now, self.next_track) { - self.next_track = now.wrapping_add(TRACK_POLL_MS); - } - if !due(now, self.next_artwork) { - self.next_artwork = now.wrapping_add(ARTWORK_POLL_MS); - } - self.active = None; - - // A confirmed no-media state must not retain a previous cover or track label. - if !self.active() { - self.clear_track_text(); - self.artwork.clear(); - } - - // Compare the effective state after queued optimistic commands are reapplied. The raw - // snapshot can equal the old optimistic value even though the final visible state differs. - if !old.same_data(&self.metadata) { - self.rev += 1; - self.cache_dirty = true; - Got::Save - } else { - Got::Changed - } - } - - /// The cache blob. It holds playback state and volume only; title, artist, and artwork stay in RAM. - pub fn save(&mut self, out: &mut [u8]) -> usize { - if !self.has_snapshot { - return 0; - } - let Some(wall) = self.fetched else { return 0 }; - out[..2].copy_from_slice(MAGIC); - out[2..6].copy_from_slice(&wall.to_le_bytes()); - let Some(len) = self.metadata.encode(&mut out[6..]) else { - return 0; - }; - 6 + len - } - - /// Whether metadata has changed since the last successful storage write. - pub fn cache_dirty(&self) -> bool { - self.cache_dirty - } - - /// Mark the current metadata as durably stored. - pub fn cache_saved(&mut self) { - self.cache_dirty = false; - } - - /// Restore cached playback state; transferred title and artwork are never cached. - pub fn load(&mut self, blob: &[u8]) { - if blob.len() < 10 || &blob[..2] != MAGIC { - return; - } - let Some(metadata) = Metadata::decode(&blob[6..10]) else { - return; - }; - self.metadata = metadata; - self.has_snapshot = true; - self.fetched = Some(i32::from_le_bytes([blob[2], blob[3], blob[4], blob[5]])); - self.cache_dirty = false; - self.status = Status::Waiting; - self.rev += 1; - } - - /// Ms until the next request or timeout. - pub fn wait(&self, now: u32) -> u32 { - if let Some(active) = self.active { - return deadline_delay(started_at(active).wrapping_add(timeout_for(active)), now) - .min(timeout_for(active)); - } - - let mut delay = deadline_delay(self.next_poll, now); - if self.command_len > 0 { - delay = delay.min(deadline_delay(self.next_command, now)); - } - // Track and artwork polls are eligible only after a successful snapshot confirms an - // active media session. Otherwise their deadlines must not wake the event loop. - if self.has_snapshot && self.status == Status::Ok && self.active() { - delay = delay.min(deadline_delay(self.next_track, now)); - delay = delay.min(deadline_delay(self.next_artwork, now)); - } - delay - } -} - -fn apply_command(metadata: &mut Metadata, command: u8, value: u8) { - match command { - rpc::PLAY => { - metadata.flags |= rpc::RESPONSE_PLAYING | rpc::RESPONSE_ACTIVE; - } - rpc::PAUSE => metadata.flags &= !rpc::RESPONSE_PLAYING, - rpc::TOGGLE => { - if metadata.active() && metadata.playing() { - metadata.flags &= !rpc::RESPONSE_PLAYING; - } else { - metadata.flags |= rpc::RESPONSE_PLAYING | rpc::RESPONSE_ACTIVE; - } - } - rpc::VOLUME_UP => { - let max = metadata.max_volume; - metadata.volume = metadata.volume.saturating_add(1).min(max); - } - rpc::VOLUME_DOWN => metadata.volume = metadata.volume.saturating_sub(1), - rpc::SET_VOLUME => metadata.volume = value.min(metadata.max_volume), - rpc::PREVIOUS | rpc::NEXT => {} - _ => {} - } -} - -fn due(now: u32, at: u32) -> bool { - now.wrapping_sub(at) as i32 >= 0 -} - -/// Delay until a wrap-safe deadline. An overdue deadline is immediately due, never a huge wait. -fn deadline_delay(deadline: u32, now: u32) -> u32 { - let delta = deadline.wrapping_sub(now); - if delta as i32 >= 0 { - delta - } else { - 0 - } -} - -fn started_at(active: Active) -> u32 { - match active { - Active::Snapshot { started, .. } - | Active::Track { started, .. } - | Active::Artwork { started, .. } - | Active::Command { started, .. } => started, - } -} - -fn timeout_for(active: Active) -> u32 { - match active { - Active::Snapshot { .. } => SNAPSHOT_TIMEOUT_MS, - Active::Track { .. } => TRACK_TIMEOUT_MS, - Active::Artwork { .. } => ARTWORK_TIMEOUT_MS, - Active::Command { .. } => COMMAND_TIMEOUT_MS, - } -} - -fn status_of(status: u8) -> Status { - match status { - rpc::OK => Status::Ok, - rpc::ASK => Status::Ask, - rpc::DENIED => Status::Denied, - rpc::BAD_REQUEST | rpc::UNAVAILABLE => Status::Unavailable, - _ => Status::Unavailable, - } -} - -/// A compact, fixed-size text buffer used by the view. -pub struct Buf { - bytes: [u8; N], - len: usize, -} - -impl Buf { - pub const fn new() -> Self { - Buf { - bytes: [0; N], - len: 0, - } - } - - pub fn as_str(&self) -> &str { - core::str::from_utf8(&self.bytes[..self.len]).unwrap_or("") - } - - fn push_byte(&mut self, byte: u8) { - if self.len < N { - self.bytes[self.len] = byte; - self.len += 1; - } - } - - fn push_u8(&mut self, value: u8) { - if value >= 100 { - self.push_byte(b'0' + value / 100); - self.push_byte(b'0' + (value / 10) % 10); - } else if value >= 10 { - self.push_byte(b'0' + value / 10); - } - self.push_byte(b'0' + value % 10); - } -} - -/// Writes a volume percentage without allocating or pulling in the formatting machinery. -pub fn percent(out: &mut Buf<8>, volume: u8, max: u8) { - let value = if max == 0 { - 0 - } else { - (volume as u32 * 100 / max as u32).min(100) - } as u8; - out.push_u8(value); - out.push_byte(b'%'); -} - -/// Days since 1970-01-01 of a civil date (H. Hinnant's `days_from_civil`). -pub fn days(y: i32, m: u32, d: u32) -> i32 { - let y = if m <= 2 { y - 1 } else { y }; - let era = y.div_euclid(400); - let yoe = y - era * 400; - let mp = (m as i32 + 9) % 12; - let doy = (153 * mp + 2) / 5 + d as i32 - 1; - era * 146_097 + yoe * 365 + yoe / 4 - yoe / 100 + doy - 719_468 -} - -/// Local wall-clock minutes since 1970-01-01. -pub fn wall_min(y: i32, m: u32, d: u32, hour: u32, minute: u32) -> i32 { - days(y, m, d) * 1440 + (hour * 60 + minute) as i32 -} - -#[cfg(test)] -mod tests { - use super::*; - use crate::rpc; - - fn reply(id: u8, status: u8, index: u8, total: u8, record: &[u8]) -> Vec { - let mut out = vec![b'M', b'1', b'A', id, status, index, total]; - out.extend_from_slice(record); - out - } - - fn metadata_record(flags: u8, volume: u8, max_volume: u8) -> Vec { - vec![0, flags, volume, max_volume] - } - - #[test] - fn metadata_snapshot_commits() { - let mut model = Model::new(); - let request = model.poll(0).unwrap(); - let id = match request { - rpc::Request::Snapshot(bytes) => bytes[3], - _ => panic!("expected snapshot"), - }; - let record = metadata_record(3, 7, 15); - assert_eq!( - model.reply(&reply(id, 0, 0, 1, &record), 10, 100), - Got::Save - ); - assert!(model.has_snapshot); - assert!(model.active() && model.playing()); - assert_eq!((model.volume(), model.max_volume()), (7, 15)); - assert_eq!(model.status, Status::Ok); - } - - #[test] - fn malformed_snapshot_is_rejected_without_committing() { - let mut model = Model::new(); - let id = match model.poll(0).unwrap() { - rpc::Request::Snapshot(bytes) => bytes[3], - _ => panic!("expected snapshot"), - }; - assert_eq!( - model.reply(&reply(id, 0, 0, 1, &[0, 3, 16, 15]), 10, 100), - Got::Changed - ); - assert!(!model.has_snapshot); - assert_eq!(model.status, Status::Unavailable); - assert!(model.poll(10 + RETRY_MS).is_some()); - } - - #[test] - fn commands_are_queued_behind_a_snapshot() { - let mut model = Model::new(); - model.poll(0); - assert!(model.command(rpc::TOGGLE, 0)); - assert!(model.metadata.playing()); - assert!(model.poll(10).is_none()); - assert!(model.poll(SNAPSHOT_TIMEOUT_MS).is_none()); - assert_eq!(model.status, Status::Silent); - let id = match model.poll(SNAPSHOT_TIMEOUT_MS + 1).unwrap() { - rpc::Request::Command(bytes) => bytes[3], - _ => panic!("expected queued command"), - }; - model.reply(&reply(id, 0, 0, 0, &[]), SNAPSHOT_TIMEOUT_MS + 11, 100); - assert!(model.poll(SNAPSHOT_TIMEOUT_MS + 12).is_none()); - assert!(matches!( - model.poll(SNAPSHOT_TIMEOUT_MS + 12 + COMMAND_REFRESH_MS + 1), - Some(rpc::Request::Snapshot(_)) - )); - } - - #[test] - fn optimistic_volume_is_clamped() { - let mut model = Model::new(); - let id = match model.poll(0).unwrap() { - rpc::Request::Snapshot(bytes) => bytes[3], - _ => panic!("expected snapshot"), - }; - model.reply(&reply(id, 0, 0, 1, &metadata_record(3, 7, 15)), 10, 100); - model.command(rpc::SET_VOLUME, 200); - assert_eq!(model.volume(), 15); - model.command(rpc::VOLUME_UP, 0); - assert_eq!(model.volume(), 15); - model.command(rpc::VOLUME_DOWN, 0); - assert_eq!(model.volume(), 14); - } - - #[test] - fn queue_overflow_does_not_change_visible_state() { - let mut model = Model::new(); - for _ in 0..COMMAND_QUEUE_MAX { - assert!(model.command(rpc::VOLUME_UP, 0)); - } - let volume = model.volume(); - assert!(!model.command(rpc::VOLUME_UP, 0)); - assert_eq!(model.volume(), volume); - } - - #[test] - fn unchanged_metadata_does_not_bump_the_visible_revision() { - let mut model = Model::new(); - let id = match model.poll(0).unwrap() { - rpc::Request::Snapshot(bytes) => bytes[3], - _ => panic!("expected snapshot"), - }; - model.reply(&reply(id, 0, 0, 1, &metadata_record(3, 7, 15)), 10, 100); - let rev = model.rev; - let id = match model.poll(POLL_MS + 10).unwrap() { - rpc::Request::Snapshot(bytes) => bytes[3], - _ => panic!("expected snapshot"), - }; - model.reply( - &reply(id, 0, 0, 1, &metadata_record(3, 7, 15)), - POLL_MS + 11, - 100, - ); - assert_eq!(model.rev, rev); - } - - #[test] - fn cache_round_trip_keeps_non_personal_state() { - let mut model = Model::new(); - let id = match model.poll(0).unwrap() { - rpc::Request::Snapshot(bytes) => bytes[3], - _ => panic!("expected snapshot"), - }; - model.reply(&reply(id, 0, 0, 1, &metadata_record(3, 7, 15)), 10, 1234); - let mut blob = [0u8; BLOB_MAX]; - let len = model.save(&mut blob); - assert_eq!(len, BLOB_MAX); - let mut restored = Model::new(); - restored.load(&blob[..len]); - assert!(restored.has_snapshot); - assert!(restored.active() && restored.playing()); - assert_eq!(restored.volume(), 7); - assert_eq!(restored.fetched, Some(1234)); - } - - #[test] - fn a_failed_command_is_queued_again() { - let mut model = Model::new(); - assert!(model.command(rpc::TOGGLE, 0)); - let request = model.poll(0).unwrap(); - assert!(matches!(request, rpc::Request::Command(_))); - model.send_failed(1); - assert_eq!(model.status, Status::Silent); - let retry_at = 1 + RETRY_MS; - let request = model.poll(retry_at).unwrap(); - assert!(matches!(request, rpc::Request::Command(_))); - } - - #[test] - fn a_timed_out_command_is_queued_again() { - let mut model = Model::new(); - assert!(model.command(rpc::TOGGLE, 0)); - assert!(matches!(model.poll(0), Some(rpc::Request::Command(_)))); - assert!(model.poll(COMMAND_TIMEOUT_MS).is_none()); - assert_eq!(model.status, Status::Silent); - let retry_at = COMMAND_TIMEOUT_MS + RETRY_MS * 2; - assert!(matches!( - model.poll(retry_at), - Some(rpc::Request::Command(_)) - )); - } - - #[test] - fn a_timed_out_command_at_queue_capacity_is_not_lost() { - let mut model = Model::new(); - for _ in 0..COMMAND_QUEUE_MAX { - assert!(model.command(rpc::VOLUME_UP, 0)); - } - - let first_id = match model.poll(0).unwrap() { - rpc::Request::Command(bytes) => bytes[3], - _ => panic!("expected command"), - }; - // The active command still occupies a queue slot, so later input cannot hide it. - assert!(!model.command(rpc::VOLUME_DOWN, 0)); - assert!(model.poll(COMMAND_TIMEOUT_MS).is_none()); - - let retry_at = COMMAND_TIMEOUT_MS + RETRY_MS * 2; - let retry_id = match model.poll(retry_at).unwrap() { - rpc::Request::Command(bytes) => bytes[3], - _ => panic!("expected retried command"), - }; - assert_ne!(retry_id, first_id); - assert_eq!( - model.reply(&reply(retry_id, 0, 0, 0, &[]), retry_at + 1, 100), - Got::Changed - ); - // Completing the head frees exactly one slot. - assert!(model.command(rpc::VOLUME_DOWN, 0)); - } - - #[test] - fn an_optimistic_command_marks_the_cache_dirty() { - let mut model = Model::new(); - let id = match model.poll(0).unwrap() { - rpc::Request::Snapshot(bytes) => bytes[3], - _ => panic!("expected snapshot"), - }; - model.reply(&reply(id, 0, 0, 1, &metadata_record(3, 7, 15)), 10, 100); - model.cache_saved(); - assert!(model.command(rpc::VOLUME_UP, 0)); - assert!(model.cache_dirty()); - let mut blob = [0u8; BLOB_MAX]; - assert!(model.save(&mut blob) > 0); - model.cache_saved(); - assert!(!model.cache_dirty()); - } - - #[test] - fn snapshot_saves_when_reapplied_optimistic_state_changes() { - let mut model = Model::new(); - let id = match model.poll(0).unwrap() { - rpc::Request::Snapshot(bytes) => bytes[3], - _ => panic!("expected snapshot"), - }; - model.reply(&reply(id, 0, 0, 1, &metadata_record(3, 7, 15)), 10, 100); - model.cache_saved(); - - let id = match model.poll(POLL_MS + 10).unwrap() { - rpc::Request::Snapshot(bytes) => bytes[3], - _ => panic!("expected snapshot"), - }; - assert!(model.command(rpc::VOLUME_UP, 0)); - assert_eq!(model.volume(), 8); - model.cache_saved(); - - // The raw snapshot equals the old optimistic value, but replaying the queued command - // changes the effective value that must be written to the cache. - assert_eq!( - model.reply( - &reply(id, 0, 0, 1, &metadata_record(3, 8, 15)), - POLL_MS + 11, - 100, - ), - Got::Save - ); - assert_eq!(model.volume(), 9); - assert!(model.cache_dirty()); - } - - #[test] - fn malformed_command_reply_is_not_accepted_as_success() { - let mut model = Model::new(); - let id = match model.poll(0).unwrap() { - rpc::Request::Snapshot(bytes) => bytes[3], - _ => panic!("expected snapshot"), - }; - model.reply(&reply(id, 0, 0, 1, &metadata_record(3, 7, 15)), 10, 100); - assert!(model.command(rpc::VOLUME_UP, 0)); - assert_eq!(model.volume(), 8); - - let id = match model.poll(11).unwrap() { - rpc::Request::Command(bytes) => bytes[3], - _ => panic!("expected command"), - }; - // OK with a non-empty result shape is not a valid command acknowledgement. - assert_eq!( - model.reply(&reply(id, rpc::OK, 0, 1, &[]), 12, 100), - Got::Save - ); - assert_eq!(model.volume(), 7); - assert_eq!(model.status, Status::Unavailable); - assert!(model.cache_dirty()); - } - - #[test] - fn denied_command_rolls_back_and_reapplies_later_optimistic_commands() { - let mut model = Model::new(); - let id = match model.poll(0).unwrap() { - rpc::Request::Snapshot(bytes) => bytes[3], - _ => panic!("expected snapshot"), - }; - model.reply(&reply(id, 0, 0, 1, &metadata_record(3, 7, 15)), 10, 100); - model.cache_saved(); - assert!(model.command(rpc::PAUSE, 0)); - assert!(model.command(rpc::VOLUME_UP, 0)); - assert!(!model.playing()); - assert_eq!(model.volume(), 8); - - let id = match model.poll(11).unwrap() { - rpc::Request::Command(bytes) => bytes[3], - _ => panic!("expected command"), - }; - assert_eq!( - model.reply(&reply(id, rpc::DENIED, 0, 0, &[]), 12, 100), - Got::Save - ); - assert!(model.playing()); - assert_eq!(model.volume(), 8); - assert!(model.cache_dirty()); - assert_eq!(model.status, Status::Denied); - } - - #[test] - fn snapshot_while_a_command_is_queued_refreshes_its_rollback_baseline() { - let mut model = Model::new(); - let id = match model.poll(0).unwrap() { - rpc::Request::Snapshot(bytes) => bytes[3], - _ => panic!("expected snapshot"), - }; - model.reply(&reply(id, 0, 0, 1, &metadata_record(3, 7, 15)), 10, 100); - - let id = match model.poll(POLL_MS + 10).unwrap() { - rpc::Request::Snapshot(bytes) => bytes[3], - _ => panic!("expected snapshot"), - }; - assert!(model.command(rpc::VOLUME_UP, 0)); - assert_eq!(model.volume(), 8); - model.reply( - &reply(id, 0, 0, 1, &metadata_record(3, 6, 15)), - POLL_MS + 11, - 100, - ); - assert_eq!(model.volume(), 7); - - let id = match model.poll(POLL_MS + 12).unwrap() { - rpc::Request::Command(bytes) => bytes[3], - _ => panic!("expected command"), - }; - assert_eq!( - model.reply(&reply(id, rpc::DENIED, 0, 0, &[]), POLL_MS + 13, 100), - Got::Save - ); - assert_eq!(model.volume(), 6); - } - - #[test] - fn permission_and_unavailable_statuses_are_distinct() { - let mut model = Model::new(); - let id = match model.poll(0).unwrap() { - rpc::Request::Snapshot(bytes) => bytes[3], - _ => panic!("expected snapshot"), - }; - model.reply(&reply(id, rpc::ASK, 0, 0, &[]), 10, 100); - assert_eq!(model.status, Status::Ask); - assert!(model.poll(ASK_AGAIN_MS).is_none()); - let id = match model.poll(ASK_AGAIN_MS + 11).unwrap() { - rpc::Request::Snapshot(bytes) => bytes[3], - _ => panic!("expected snapshot"), - }; - model.reply(&reply(id, rpc::DENIED, 0, 0, &[]), ASK_AGAIN_MS + 12, 100); - assert_eq!(model.status, Status::Denied); - } - - #[test] - fn stale_reply_ids_are_ignored() { - let mut model = Model::new(); - model.poll(0); - assert_eq!( - model.reply(&reply(99, 0, 0, 1, &metadata_record(3, 7, 15)), 10, 100), - Got::Nothing - ); - assert!(!model.has_snapshot); - } - - #[test] - fn track_text_and_artwork_are_committed_only_after_valid_replies() { - let mut model = Model::new(); - let snapshot_id = match model.poll(0).unwrap() { - rpc::Request::Snapshot(bytes) => bytes[3], - _ => panic!("expected snapshot"), - }; - model.reply( - &reply(snapshot_id, rpc::OK, 0, 1, &metadata_record(3, 7, 15)), - 10, - 100, - ); - - // At the shared poll deadline the playback snapshot has priority, then track text and - // artwork follow as separate bounded requests. - let snapshot_id = match model.poll(POLL_MS + 10).unwrap() { - rpc::Request::Snapshot(bytes) => bytes[3], - _ => panic!("expected snapshot"), - }; - model.reply( - &reply(snapshot_id, rpc::OK, 0, 1, &metadata_record(3, 7, 15)), - POLL_MS + 11, - 100, - ); - - let track_id = match model.poll(POLL_MS + 12).unwrap() { - rpc::Request::Track(bytes) => bytes[3], - _ => panic!("expected track request"), - }; - model.reply( - &reply( - track_id, - rpc::OK, - 0, - 2, - &[ - 0, 13, b'M', b'i', b'd', b'n', b'i', b'g', b'h', b't', b' ', b'C', b'i', b't', - b'y', - ], - ), - POLL_MS + 13, - 100, - ); - model.reply( - &reply(track_id, rpc::OK, 1, 2, &[1, 3, b'M', b'8', b'3']), - POLL_MS + 14, - 100, - ); - assert_eq!(model.track_title(), "Midnight City"); - assert_eq!(model.track_artist(), "M83"); - - let (artwork_id, nonce) = match model.poll(POLL_MS + 15).unwrap() { - rpc::Request::Artwork(bytes) => ( - bytes[3], - u32::from_le_bytes([bytes[5], bytes[6], bytes[7], bytes[8]]), - ), - _ => panic!("expected artwork request"), - }; - let payload = [0_u8; artwork::PAYLOAD_LEN]; - let mut manifest = [0_u8; artwork::MANIFEST_LEN]; - manifest[0] = artwork::MANIFEST_VERSION; - manifest[1] = artwork::ENCODING_RGB332_6BPP; - manifest[2] = artwork::WIDTH; - manifest[3] = artwork::HEIGHT; - manifest[5..9].copy_from_slice(&nonce.to_le_bytes()); - manifest[9..17].copy_from_slice(&1_u64.to_le_bytes()); - manifest[17..21].copy_from_slice(&(artwork::PAYLOAD_LEN as u32).to_le_bytes()); - manifest[21..25].copy_from_slice(&artwork::crc32(&payload).to_le_bytes()); - model.reply( - &reply(artwork_id, rpc::OK, 0, artwork::RECORD_COUNT, &manifest), - POLL_MS + 16, - 100, - ); - assert!(!model.artwork_visible()); - - for index in 1..=artwork::CHUNK_COUNT { - let offset = (index - 1) * artwork::CHUNK_LEN; - let len = if index == artwork::CHUNK_COUNT { - artwork::LAST_CHUNK_LEN - } else { - artwork::CHUNK_LEN - }; - let mut chunk = Vec::with_capacity(6 + len); - chunk.extend_from_slice(&nonce.to_le_bytes()); - chunk.extend_from_slice(&(offset as u16).to_le_bytes()); - chunk.extend_from_slice(&payload[offset..offset + len]); - model.reply( - &reply( - artwork_id, - rpc::OK, - index as u8, - artwork::RECORD_COUNT, - &chunk, - ), - POLL_MS + 16 + index as u32, - 100, - ); - } - assert!(model.artwork_visible()); - assert_eq!(model.artwork_generation(), 1); - assert_eq!(model.status, Status::Ok); - - // The persistent cache remains the fixed playback-state record only. - let mut blob = [0_u8; BLOB_MAX]; - let len = model.save(&mut blob); - assert_eq!(len, BLOB_MAX); - assert!(!blob.windows(13).any(|window| window == b"Midnight City")); - } - - #[test] - fn wait_never_busy_spins_or_delays_an_overdue_snapshot() { - let mut model = Model::new(); - let id = match model.poll(0).unwrap() { - rpc::Request::Snapshot(bytes) => bytes[3], - _ => panic!("expected snapshot"), - }; - model.reply( - &reply(id, rpc::ASK, 0, 0, &[]), - 10, - 100, - ); - assert_eq!(model.wait(10), ASK_AGAIN_MS); - - model.reply( - &reply(id, rpc::OK, 0, 1, &metadata_record(3, 7, 15)), - 11, - 100, - ); - // The late OK reply is ignored because the ASK already terminated the request. - assert_eq!(model.wait(11), ASK_AGAIN_MS - 1); - - let mut model = Model::new(); - model.next_poll = 100; - assert_eq!(model.wait(500), 0); - } - - #[test] - fn wait_ignores_track_and_artwork_deadlines_until_media_is_active() { - let mut model = Model::new(); - model.next_poll = 5_000; - model.next_track = 10; - model.next_artwork = 20; - model.has_snapshot = true; - model.status = Status::Ok; - assert_eq!(model.wait(100), 4_900); - - model.metadata.flags = rpc::RESPONSE_ACTIVE | rpc::RESPONSE_PLAYING; - assert_eq!(model.wait(100), 0); - assert!(matches!(model.poll(100), Some(rpc::Request::Track(_)))); - } - - #[test] - fn malformed_track_error_is_rejected_without_being_interpreted() { - let mut model = Model::new(); - let id = match model.poll(0).unwrap() { - rpc::Request::Snapshot(bytes) => bytes[3], - _ => panic!("expected snapshot"), - }; - model.reply( - &reply(id, rpc::OK, 0, 1, &metadata_record(3, 7, 15)), - 10, - 100, - ); - let id = match model.poll(POLL_MS + 10).unwrap() { - rpc::Request::Snapshot(bytes) => bytes[3], - _ => panic!("expected snapshot"), - }; - model.reply( - &reply(id, rpc::OK, 0, 1, &metadata_record(3, 7, 15)), - POLL_MS + 11, - 100, - ); - let id = match model.poll(POLL_MS + 12).unwrap() { - rpc::Request::Track(bytes) => bytes[3], - _ => panic!("expected track request"), - }; - model.reply( - &reply(id, rpc::DENIED, 1, 2, b"x"), - POLL_MS + 13, - 100, - ); - assert_eq!(model.status, Status::Ok); - assert_eq!(model.next_track, POLL_MS + 13 + TRACK_POLL_MS); - // The artwork poll is already due while the media session is active, so the malformed - // track reply must not introduce a busy wait. - assert_eq!(model.wait(POLL_MS + 13), 0); - assert!(matches!( - model.poll(POLL_MS + 13), - Some(rpc::Request::Artwork(_)) - )); - assert_eq!(model.next_artwork, 2_010); - } - - #[test] - fn no_media_snapshot_clears_text_and_committed_artwork() { - let mut model = Model::new(); - let id = match model.poll(0).unwrap() { - rpc::Request::Snapshot(bytes) => bytes[3], - _ => panic!("expected snapshot"), - }; - model.reply( - &reply(id, rpc::OK, 0, 1, &metadata_record(3, 7, 15)), - 10, - 100, - ); - model.set_track_text(b"Midnight City", b"M83"); - model.artwork_visible(); - - let id = match model.poll(POLL_MS + 10).unwrap() { - rpc::Request::Snapshot(bytes) => bytes[3], - _ => panic!("expected snapshot"), - }; - model.reply( - &reply(id, rpc::OK, 0, 1, &metadata_record(0, 7, 15)), - POLL_MS + 11, - 100, - ); - assert!(!model.active()); - assert!(model.track_title().is_empty()); - assert!(model.track_artist().is_empty()); - assert!(!model.artwork_visible()); - assert_eq!(model.artwork_generation(), 0); - } - - #[test] - fn old_companion_fallback_keeps_controls_live_without_names_or_artwork() { - let mut model = Model::new(); - let snapshot_id = match model.poll(0).unwrap() { - rpc::Request::Snapshot(bytes) => bytes[3], - _ => panic!("expected snapshot"), - }; - model.reply( - &reply(snapshot_id, rpc::OK, 0, 1, &metadata_record(3, 7, 15)), - 10, - 100, - ); - let snapshot_id = match model.poll(POLL_MS + 10).unwrap() { - rpc::Request::Snapshot(bytes) => bytes[3], - _ => panic!("expected snapshot"), - }; - model.reply( - &reply(snapshot_id, rpc::OK, 0, 1, &metadata_record(3, 7, 15)), - POLL_MS + 11, - 100, - ); - - let track_id = match model.poll(POLL_MS + 12).unwrap() { - rpc::Request::Track(bytes) => bytes[3], - _ => panic!("expected track request"), - }; - model.reply( - &reply(track_id, rpc::BAD_REQUEST, 0, 0, &[]), - POLL_MS + 13, - 100, - ); - assert!(model.track_title().is_empty()); - assert!(model.track_artist().is_empty()); - - let artwork_id = match model.poll(POLL_MS + 14).unwrap() { - rpc::Request::Artwork(bytes) => bytes[3], - _ => panic!("expected artwork request"), - }; - model.reply( - &reply(artwork_id, rpc::BAD_REQUEST, 0, 0, &[]), - POLL_MS + 15, - 100, - ); - assert!(!model.artwork_visible()); - assert_eq!(model.status, Status::Ok); - assert!(model.controls_enabled()); - } - - #[test] - fn wall_clock_uses_local_calendar_time() { - assert_eq!(wall_min(1970, 1, 1, 0, 0), 0); - assert_eq!(wall_min(1970, 1, 2, 0, 0), 1440); - assert_eq!( - wall_min(2026, 11, 19, 12, 30), - days(2026, 11, 19) * 1440 + 750 - ); - } -} diff --git a/apps/music-controller/src/ntype82.rs b/apps/music-controller/src/ntype82.rs deleted file mode 100644 index 12f6b1d..0000000 --- a/apps/music-controller/src/ntype82.rs +++ /dev/null @@ -1,2046 +0,0 @@ -#![allow(non_upper_case_globals)] - -//! NType 82 Regular glyph subset used by this Nothing-related CMF watch app. -//! -//! The uploaded OTF is not redistributed. This module contains only the small pre-rendered -//! glyph subset needed by the interface, with the original proportions preserved. - -use cmf_wp2_ui::Surface; - -pub(crate) struct Glyph { - pub code: u8, - pub width: u8, - pub rows: &'static [u32], -} - -#[derive(Clone, Copy)] -pub(crate) enum FontSize { - Small, - Large, -} - -impl FontSize { - fn glyphs(self) -> &'static [Glyph] { - match self { - FontSize::Small => &SMALL_GLYPHS, - FontSize::Large => &LARGE_GLYPHS, - } - } - - fn height(self) -> usize { - match self { - FontSize::Small => SMALL_HEIGHT, - FontSize::Large => LARGE_HEIGHT, - } - } -} - -fn glyph(font: FontSize, ch: char) -> &'static Glyph { - let code = ch as u8; - font.glyphs() - .iter() - .find(|glyph| glyph.code == code) - .or_else(|| font.glyphs().iter().find(|glyph| glyph.code == b'?')) - .expect("question glyph") -} - -fn char_width(font: FontSize, ch: char) -> i32 { - glyph(font, ch).width as i32 -} - -/// Width in screen pixels, including one pixel of tracking between glyphs. -pub(crate) fn width(font: FontSize, text: &str) -> i32 { - let count = text.chars().count(); - if count == 0 { - return 0; - } - let ink: i32 = text.chars().map(|ch| char_width(font, ch)).sum(); - ink + count as i32 - 1 -} - -/// Draws text from the left edge and returns its width. -pub(crate) fn draw( - s: &mut impl Surface, - x: i32, - y: i32, - text: &str, - colour: u16, - font: FontSize, -) -> i32 { - let mut pen = x; - for ch in text.chars() { - let glyph = glyph(font, ch); - for (row, bits) in glyph.rows.iter().enumerate() { - let mut bit = 0; - while bit < glyph.width as usize { - if (*bits & (1 << bit)) == 0 { - bit += 1; - continue; - } - let start = bit; - while bit < glyph.width as usize && (*bits & (1 << bit)) != 0 { - bit += 1; - } - s.rect( - pen + start as i32, - y + row as i32, - (bit - start) as i32, - 1, - colour, - ); - } - } - pen += glyph.width as i32 + 1; - } - width(font, text) -} - -/// Draws text centred on the round panel. -pub(crate) fn centre( - s: &mut impl Surface, - centre_x: i32, - y: i32, - text: &str, - colour: u16, - font: FontSize, -) -> i32 { - let x = centre_x - width(font, text) / 2; - draw(s, x, y, text, colour, font) -} - -fn clipped_parts(font: FontSize, text: &str, max_width: i32) -> (usize, i32, bool) { - let full_width = width(font, text); - if full_width <= max_width { - return (text.len(), full_width, false); - } - - let ellipsis_width = width(font, "..."); - let mut prefix_ink = 0; - let mut prefix_count = 0; - let mut prefix_len = 0; - for (index, ch) in text.char_indices() { - let next_ink = prefix_ink + char_width(font, ch); - let next_count = prefix_count + 1; - let next_width = next_ink + next_count - 1; - if next_width + ellipsis_width > max_width { - break; - } - prefix_ink = next_ink; - prefix_count = next_count; - prefix_len = index + ch.len_utf8(); - } - let prefix_width = prefix_ink + prefix_count.saturating_sub(1); - (prefix_len, prefix_width + ellipsis_width, true) -} - -/// Draws text from the left edge, truncating it with an ellipsis when it exceeds `max_width`. -pub(crate) fn draw_clipped( - s: &mut impl Surface, - x: i32, - y: i32, - text: &str, - max_width: i32, - colour: u16, - font: FontSize, -) -> i32 { - let (prefix_len, clipped_width, truncated) = clipped_parts(font, text, max_width); - if !truncated { - return draw(s, x, y, text, colour, font); - } - - let prefix = &text[..prefix_len]; - let prefix_width = width(font, prefix); - draw(s, x, y, prefix, colour, font); - draw(s, x + prefix_width, y, "...", colour, font); - clipped_width -} - -/// Draws clipped text centred on the round panel. -pub(crate) fn centre_clipped( - s: &mut impl Surface, - centre_x: i32, - y: i32, - text: &str, - max_width: i32, - colour: u16, - font: FontSize, -) -> i32 { - let (_, clipped_width, _) = clipped_parts(font, text, max_width); - let x = centre_x - clipped_width / 2; - draw_clipped(s, x, y, text, max_width, colour, font) -} - -pub(crate) const SMALL_HEIGHT: usize = 26; - -const F24_SPACE: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F24_CA: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000080, 0x00000180, 0x000001c0, 0x000001c0, 0x00000340, - 0x00000360, 0x00000320, 0x00000220, 0x00000630, 0x00000630, 0x00000610, 0x00000ff0, 0x00000c18, - 0x00000c08, 0x00001808, 0x0000180c, 0x00007e3f, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F24_CB: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000000, 0x000003ff, 0x0000071c, 0x00000c08, 0x00000c08, 0x00000c08, - 0x00000c08, 0x00000608, 0x000003f8, 0x00000708, 0x00000c08, 0x00000c08, 0x00000c08, 0x00000c08, - 0x00000c08, 0x00000c08, 0x0000071c, 0x000003ff, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F24_CC: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000be0, 0x00000f38, 0x00000c0c, 0x00000c0c, 0x00000c06, - 0x00000806, 0x00000006, 0x00000006, 0x00000006, 0x00000006, 0x00000006, 0x00000806, 0x00000806, - 0x0000080c, 0x00000c0c, 0x00000638, 0x000003e0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F24_CD: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000000, 0x000001ff, 0x0000031c, 0x00000608, 0x00000c08, 0x00000c08, - 0x00001c08, 0x00001808, 0x00001808, 0x00001808, 0x00001808, 0x00001808, 0x00001c08, 0x00000c08, - 0x00000c08, 0x00000608, 0x0000039c, 0x000001ff, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F24_CE: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000fff, 0x00000e1c, 0x00000c08, 0x00000c08, 0x00000808, - 0x00000108, 0x00000188, 0x000001f8, 0x00000188, 0x00000108, 0x00000108, 0x00000808, 0x00000808, - 0x00000c08, 0x00000c08, 0x00000e1c, 0x00000fff, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F24_CF: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000fff, 0x00000e0c, 0x00000c08, 0x00000808, 0x00000808, - 0x00000188, 0x00000188, 0x00000188, 0x000001f8, 0x00000188, 0x00000188, 0x00000008, 0x00000008, - 0x00000008, 0x00000008, 0x0000001c, 0x0000007f, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F24_CG: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000000, 0x000009e0, 0x00000f38, 0x00000c08, 0x00000c0c, 0x00000c06, - 0x00000806, 0x00000806, 0x00000006, 0x00000006, 0x00003fc6, 0x00001c06, 0x00000806, 0x00000806, - 0x00000c0c, 0x00000c0c, 0x00000f18, 0x000009f0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F24_CH: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00007e3f, 0x0000181c, 0x00001808, 0x00001808, 0x00001808, - 0x00001808, 0x00001808, 0x00001808, 0x00001ff8, 0x00001808, 0x00001808, 0x00001808, 0x00001808, - 0x00001808, 0x00001808, 0x0000181c, 0x00007e3f, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F24_CI: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000000, 0x0000003f, 0x0000001c, 0x00000008, 0x00000008, 0x00000008, - 0x00000008, 0x00000008, 0x00000008, 0x00000008, 0x00000008, 0x00000008, 0x00000008, 0x00000008, - 0x00000008, 0x00000008, 0x0000001c, 0x0000003f, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F24_CJ: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000000, 0x000007f0, 0x00000380, 0x00000180, 0x00000180, 0x00000180, - 0x00000180, 0x00000180, 0x00000180, 0x00000180, 0x00000180, 0x00000180, 0x00000180, 0x00000186, - 0x00000187, 0x00000186, 0x000000c6, 0x0000007c, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F24_CK: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00003e3f, 0x00000c1c, 0x00000608, 0x00000308, 0x00000108, - 0x00000188, 0x000000c8, 0x00000048, 0x000000f8, 0x000000c8, 0x00000188, 0x00000308, 0x00000308, - 0x00000608, 0x00000608, 0x00000c1c, 0x00003e3f, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F24_CL: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000000, 0x0000003f, 0x0000001c, 0x00000008, 0x00000008, 0x00000008, - 0x00000008, 0x00000008, 0x00000008, 0x00000008, 0x00000008, 0x00000808, 0x00000808, 0x00000c08, - 0x00000c08, 0x00000c08, 0x00000e1c, 0x00000fff, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F24_CM: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000000, 0x0001f01f, 0x0000701c, 0x00007838, 0x00003838, 0x00002838, - 0x00002828, 0x00002c68, 0x00002468, 0x00002468, 0x000026c8, 0x000026c8, 0x000022c8, 0x00002388, - 0x00002388, 0x00006388, 0x0000718c, 0x0001f93f, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F24_CN: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00007e1f, 0x0000183c, 0x00001838, 0x00001868, 0x00001868, - 0x000018c8, 0x000018c8, 0x00001988, 0x00001988, 0x00001b08, 0x00001b08, 0x00001e08, 0x00001e08, - 0x00001c08, 0x00001c08, 0x0000180c, 0x0000183f, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F24_CO: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000000, 0x000003e0, 0x00000638, 0x00000c0c, 0x0000080c, 0x00001806, - 0x00001806, 0x00003806, 0x00003806, 0x00003806, 0x00003806, 0x00003806, 0x00001806, 0x00001806, - 0x0000080c, 0x00000c0c, 0x00000638, 0x000003e0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F24_CP: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000000, 0x000007ff, 0x00000c1c, 0x00001808, 0x00001808, 0x00001808, - 0x00001808, 0x00001808, 0x00000c08, 0x000007f8, 0x00000008, 0x00000008, 0x00000008, 0x00000008, - 0x00000008, 0x00000008, 0x0000001c, 0x0000003f, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F24_CQ: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000000, 0x000003e0, 0x00000638, 0x00000c0c, 0x0000080c, 0x00001806, - 0x00001806, 0x00001806, 0x00003806, 0x00003806, 0x00003806, 0x00003806, 0x00001806, 0x00001806, - 0x000019cc, 0x00000f2c, 0x00006778, 0x000027e0, 0x00003c00, 0x00003800, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F24_CR: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000000, 0x000007ff, 0x00000e1c, 0x00001c08, 0x00001808, 0x00001808, - 0x00001c08, 0x00000c08, 0x000007f8, 0x00000708, 0x00000608, 0x00000c08, 0x00000c08, 0x00002c08, - 0x00002c08, 0x00002c08, 0x00002c1c, 0x0000387f, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F24_CS: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000000, 0x000004f8, 0x0000058c, 0x00000706, 0x00000606, 0x00000406, - 0x0000040e, 0x0000001c, 0x00000078, 0x000001f0, 0x000003c0, 0x00000702, 0x00000602, 0x00000c02, - 0x00000406, 0x00000606, 0x0000071e, 0x000001f2, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F24_CT: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00001fff, 0x000018c7, 0x000010c3, 0x000010c3, 0x000010c3, - 0x000000c0, 0x000000c0, 0x000000c0, 0x000000c0, 0x000000c0, 0x000000c0, 0x000000c0, 0x000000c0, - 0x000000c0, 0x000000c0, 0x000000c0, 0x000003f8, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F24_CU: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00007e7f, 0x0000180c, 0x0000180c, 0x0000180c, 0x0000180c, - 0x0000180c, 0x0000180c, 0x0000180c, 0x0000180c, 0x0000180c, 0x0000180c, 0x0000180c, 0x0000180c, - 0x00000808, 0x00000818, 0x00000630, 0x000003e0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F24_CV: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00007e7f, 0x0000181c, 0x00001808, 0x00000818, 0x00000818, - 0x00000c10, 0x00000430, 0x00000430, 0x00000630, 0x00000260, 0x00000260, 0x00000360, 0x00000340, - 0x000001c0, 0x000001c0, 0x000001c0, 0x00000080, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F24_CW: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000000, 0x0001f13f, 0x0000c30c, 0x0000430c, 0x0000430c, 0x00006388, - 0x00002788, 0x00002698, 0x00002698, 0x00002698, 0x000024d8, 0x00003c50, 0x00001c70, 0x00001c70, - 0x00001c70, 0x00001870, 0x00001820, 0x00000820, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F24_CX: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00003f3f, 0x00000c1c, 0x00000418, 0x00000618, 0x00000230, - 0x00000160, 0x000001e0, 0x000000c0, 0x000000c0, 0x000001c0, 0x00000360, 0x00000320, 0x00000630, - 0x00000610, 0x00000c08, 0x00001c0c, 0x00003e3f, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F24_CY: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00003f7f, 0x00000c1c, 0x00000c18, 0x00000418, 0x00000610, - 0x00000230, 0x00000230, 0x00000360, 0x00000160, 0x000001c0, 0x000000c0, 0x00000080, 0x00000080, - 0x00000080, 0x00000080, 0x000001c0, 0x000007f0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F24_CZ: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000ffe, 0x00000c0e, 0x00000606, 0x00000302, 0x00000302, - 0x00000182, 0x000001c0, 0x000000c0, 0x00000060, 0x00000060, 0x00000030, 0x00000818, 0x00000818, - 0x0000080c, 0x00000c06, 0x00000e06, 0x00000fff, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F24_Ca: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x000000fc, 0x000001c6, 0x00000186, 0x00000186, 0x00000180, 0x000001f8, 0x0000018e, 0x00000586, - 0x00000583, 0x000005c3, 0x000005ee, 0x0000073c, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F24_Cb: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000000, 0x0000000f, 0x0000000c, 0x0000000c, 0x0000000c, 0x0000000c, - 0x000001ec, 0x0000033c, 0x0000061c, 0x00000c0c, 0x00000c0c, 0x00000c0c, 0x00000c0c, 0x00000c0c, - 0x00000c0c, 0x0000061c, 0x0000033c, 0x000001e4, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F24_Cc: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x000000f8, 0x0000018c, 0x00000386, 0x00000386, 0x00000006, 0x00000006, 0x00000006, 0x00000206, - 0x00000206, 0x00000306, 0x0000018c, 0x000000f8, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F24_Cd: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000380, 0x00000300, 0x00000200, 0x00000200, 0x00000200, - 0x00000278, 0x0000038c, 0x00000306, 0x00000306, 0x00000306, 0x00000306, 0x00000306, 0x00000306, - 0x00000306, 0x00000306, 0x0000078c, 0x00000e78, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F24_Ce: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x000000f8, 0x0000018c, 0x00000306, 0x00000306, 0x00000306, 0x000003fe, 0x00000006, 0x00000206, - 0x00000206, 0x00000306, 0x0000018c, 0x000000f8, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F24_Cf: [u32; 26] = [ - 0x00000000, 0x000001e0, 0x00000330, 0x00000718, 0x00000318, 0x00000018, 0x00000018, 0x00000018, - 0x000000ff, 0x00000018, 0x00000018, 0x00000018, 0x00000018, 0x00000018, 0x00000018, 0x00000018, - 0x00000018, 0x00000018, 0x00000018, 0x000000fe, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F24_Cg: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000400, 0x00000e00, 0x00000f00, - 0x000001f0, 0x00000188, 0x0000030c, 0x0000030c, 0x00000306, 0x0000030c, 0x0000030c, 0x00000188, - 0x000000fe, 0x00000006, 0x000000fe, 0x00000ffe, 0x00000c06, 0x00000c03, 0x00000c03, 0x00000e07, - 0x000003fc, 0x00000000, -]; -const F24_Ch: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000000, 0x0000000f, 0x0000000c, 0x0000000c, 0x0000000c, 0x0000000c, - 0x000003cc, 0x000007ec, 0x0000061c, 0x0000061c, 0x0000060c, 0x0000060c, 0x0000060c, 0x0000060c, - 0x0000060c, 0x0000060c, 0x0000060c, 0x00001f3f, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F24_Ci: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000000, 0x0000000c, 0x0000000c, 0x00000008, 0x00000000, 0x00000000, - 0x0000000f, 0x0000000c, 0x00000008, 0x00000008, 0x00000008, 0x00000008, 0x00000008, 0x00000008, - 0x00000008, 0x00000008, 0x0000001c, 0x0000007f, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F24_Cj: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000000, 0x0000000c, 0x0000000e, 0x0000000c, 0x00000000, 0x00000000, - 0x0000000f, 0x0000000c, 0x0000000c, 0x0000000c, 0x0000000c, 0x0000000c, 0x0000000c, 0x0000000c, - 0x0000000c, 0x0000000c, 0x0000000c, 0x0000000c, 0x0000000c, 0x0000000c, 0x0000000c, 0x00000006, - 0x00000003, 0x00000000, -]; -const F24_Ck: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000000, 0x0000000f, 0x0000000c, 0x0000000c, 0x0000000c, 0x0000000c, - 0x00000fcc, 0x0000038c, 0x0000018c, 0x000000cc, 0x0000006c, 0x0000007c, 0x000000cc, 0x0000018c, - 0x0000018c, 0x0000030c, 0x0000070c, 0x00001fbf, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F24_Cl: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000000, 0x0000000f, 0x0000000c, 0x0000000c, 0x0000000c, 0x0000000c, - 0x0000000c, 0x0000000c, 0x0000000c, 0x0000000c, 0x0000000c, 0x0000000c, 0x0000000c, 0x0000000c, - 0x0000000c, 0x0000000c, 0x0000000c, 0x0000003f, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F24_Cm: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x000038ef, 0x00007dfc, 0x0000c31c, 0x0000c30c, 0x0000c30c, 0x0000c30c, 0x0000c30c, 0x0000c30c, - 0x0000c30c, 0x0000c30c, 0x0000c30c, 0x0001f7bf, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F24_Cn: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x000003cf, 0x000007ec, 0x0000061c, 0x0000061c, 0x0000060c, 0x0000060c, 0x0000060c, 0x0000060c, - 0x0000060c, 0x0000060c, 0x0000060c, 0x00001f3f, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F24_Co: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x000000f8, 0x0000018c, 0x00000306, 0x00000306, 0x00000606, 0x00000606, 0x00000606, 0x00000606, - 0x00000306, 0x00000306, 0x0000018c, 0x000000f8, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F24_Cp: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x000001ef, 0x0000033c, 0x0000061c, 0x00000c0c, 0x00000c0c, 0x00000c0c, 0x00000c0c, 0x00000c0c, - 0x00000c0c, 0x0000061c, 0x0000033c, 0x000001ec, 0x0000000c, 0x0000000c, 0x0000000c, 0x0000000c, - 0x0000007f, 0x00000000, -]; -const F24_Cq: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000278, 0x000003cc, 0x00000386, 0x00000306, 0x00000306, 0x00000306, 0x00000306, 0x00000306, - 0x00000306, 0x00000386, 0x000003cc, 0x00000378, 0x00000300, 0x00000300, 0x00000300, 0x00000300, - 0x00000fe0, 0x00000000, -]; -const F24_Cr: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x000001ef, 0x000001bc, 0x0000019c, 0x0000000c, 0x0000000c, 0x0000000c, 0x0000000c, 0x0000000c, - 0x0000000c, 0x0000000c, 0x0000000c, 0x0000007f, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F24_Cs: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x0000017c, 0x000001c6, 0x00000182, 0x00000186, 0x0000000e, 0x0000007c, 0x000000f0, 0x000001c0, - 0x00000182, 0x00000186, 0x000001ce, 0x0000007a, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F24_Ct: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000010, 0x00000010, 0x00000018, 0x00000018, - 0x000001ff, 0x00000018, 0x00000018, 0x00000018, 0x00000018, 0x00000018, 0x00000218, 0x00000218, - 0x00000218, 0x00000318, 0x000001b0, 0x000000e0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F24_Cu: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x0000070f, 0x0000060c, 0x0000060c, 0x0000060c, 0x0000060c, 0x0000060c, 0x0000060c, 0x0000060c, - 0x0000060c, 0x0000070c, 0x000005f8, 0x00001cf0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F24_Cv: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000fbf, 0x0000030c, 0x0000030c, 0x00000108, 0x00000118, 0x00000198, 0x00000090, 0x000000b0, - 0x000000f0, 0x00000060, 0x00000060, 0x00000060, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F24_Cw: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00007c9f, 0x0000198e, 0x000011cc, 0x000019cc, 0x0000094c, 0x00000948, 0x00000b78, 0x00000f38, - 0x00000738, 0x00000630, 0x00000630, 0x00000210, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F24_Cx: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x000007ff, 0x0000030c, 0x00000198, 0x00000098, 0x000000f0, 0x00000060, 0x000000e0, 0x000000f0, - 0x00000198, 0x00000308, 0x0000070c, 0x00000f9f, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F24_Cy: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x0000079f, 0x0000030e, 0x0000030c, 0x0000010c, 0x00000118, 0x00000198, 0x00000090, 0x000000b0, - 0x000000f0, 0x000000e0, 0x00000060, 0x00000060, 0x00000060, 0x00000022, 0x00000027, 0x00000013, - 0x0000001e, 0x00000000, -]; -const F24_Cz: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x000001ff, 0x00000183, 0x000000c3, 0x000000c3, 0x00000060, 0x00000030, 0x00000038, 0x00000018, - 0x0000010c, 0x00000106, 0x00000106, 0x000001ff, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F24_C0: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000000, 0x000000f0, 0x00000198, 0x0000030c, 0x00000604, 0x00000606, - 0x00000606, 0x00000606, 0x00000606, 0x00000e06, 0x00000606, 0x00000606, 0x00000606, 0x00000606, - 0x00000604, 0x0000030c, 0x00000198, 0x000000f0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F24_C1: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000020, 0x00000030, 0x0000003f, 0x00000030, 0x00000030, - 0x00000030, 0x00000030, 0x00000030, 0x00000030, 0x00000030, 0x00000030, 0x00000030, 0x00000030, - 0x00000030, 0x00000030, 0x00000030, 0x000001ff, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F24_C2: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000000, 0x000000f8, 0x000001cc, 0x00000386, 0x0000030e, 0x00000306, - 0x00000300, 0x00000380, 0x00000180, 0x000001c0, 0x000000c0, 0x00000060, 0x00000030, 0x00000018, - 0x00000008, 0x00000204, 0x000003fe, 0x000003fe, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F24_C3: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000000, 0x000000f8, 0x0000038c, 0x00000304, 0x0000070e, 0x0000060e, - 0x00000304, 0x00000300, 0x000001c0, 0x000000f0, 0x00000380, 0x00000700, 0x00000604, 0x0000060e, - 0x0000060e, 0x00000306, 0x0000038c, 0x000000f8, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F24_C4: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000100, 0x00000180, 0x00000180, 0x000001c0, 0x00000160, - 0x00000120, 0x00000110, 0x00000118, 0x00000108, 0x00000104, 0x00000106, 0x000007fe, 0x00000180, - 0x00000100, 0x00000100, 0x00000380, 0x000007e0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F24_C5: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000300, 0x000003fc, 0x000003fc, 0x00000004, 0x00000004, 0x00000004, - 0x00000004, 0x000000f4, 0x000001fc, 0x00000304, 0x00000300, 0x00000700, 0x00000700, 0x0000070e, - 0x0000030e, 0x00000306, 0x000001ce, 0x000000f8, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F24_C6: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000000, 0x000001f0, 0x00000318, 0x0000070c, 0x00000304, 0x00000006, - 0x00000006, 0x000001f6, 0x0000039e, 0x0000070e, 0x00000606, 0x00000606, 0x00000606, 0x00000606, - 0x00000606, 0x0000030c, 0x00000398, 0x000000f0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F24_C7: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000000, 0x000003fe, 0x000003fe, 0x00000102, 0x00000182, 0x00000080, - 0x000000c0, 0x00000040, 0x00000060, 0x00000060, 0x00000020, 0x00000030, 0x00000030, 0x00000030, - 0x00000030, 0x00000030, 0x00000030, 0x00000030, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F24_C8: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000000, 0x000000f8, 0x0000018c, 0x00000106, 0x00000306, 0x00000306, - 0x00000106, 0x0000018c, 0x000000f8, 0x000000f8, 0x000001c4, 0x00000306, 0x00000202, 0x00000602, - 0x00000202, 0x00000306, 0x0000018c, 0x000000f8, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F24_C9: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000000, 0x000000f0, 0x0000039c, 0x0000030c, 0x00000606, 0x00000606, - 0x00000606, 0x00000606, 0x00000e06, 0x0000070c, 0x0000079c, 0x000006f8, 0x00000600, 0x00000600, - 0x0000020c, 0x0000030c, 0x0000018c, 0x000000f8, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F24_PERCENT: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000000, 0x0000001c, 0x00000026, 0x00000062, 0x00001062, 0x00000862, - 0x00000462, 0x00000226, 0x0000011c, 0x000000c0, 0x00000e60, 0x00001b30, 0x00001118, 0x00003184, - 0x00003180, 0x00001100, 0x00001100, 0x00000e00, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F24_DOT: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000006, 0x00000006, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F24_SLASH: [u32; 26] = [ - 0x00000000, 0x00000020, 0x00000020, 0x00000030, 0x00000030, 0x00000010, 0x00000010, 0x00000018, - 0x00000018, 0x00000008, 0x00000008, 0x00000008, 0x0000000c, 0x0000000c, 0x00000004, 0x00000004, - 0x00000006, 0x00000006, 0x00000002, 0x00000002, 0x00000002, 0x00000003, 0x00000001, 0x00000000, - 0x00000000, 0x00000000, -]; -const F24_DASH: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000003f, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F24_QUESTION: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000078, 0x000001c6, 0x00000106, 0x00000307, 0x00000306, - 0x00000300, 0x00000180, 0x000001c0, 0x000000f0, 0x00000030, 0x00000030, 0x00000030, 0x00000000, - 0x00000000, 0x00000000, 0x00000030, 0x00000030, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F24_BANG: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000004, 0x0000000e, 0x00000006, 0x00000006, 0x00000006, - 0x00000004, 0x00000004, 0x00000004, 0x00000004, 0x00000004, 0x00000004, 0x00000004, 0x00000000, - 0x00000000, 0x00000000, 0x0000000e, 0x00000006, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F24_COLON: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000006, 0x00000006, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000006, 0x00000006, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F24_PLUS: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000030, 0x00000030, 0x00000030, 0x00000030, 0x000003ff, 0x00000030, 0x00000030, - 0x00000030, 0x00000030, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F24_COMMA: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000006, 0x0000000e, 0x00000004, 0x00000006, 0x00000002, 0x00000000, - 0x00000000, 0x00000000, -]; -const F24_AMPERSAND: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000000, 0x000000f0, 0x00000198, 0x0000030c, 0x0000030c, 0x0000010c, - 0x00000198, 0x000000d8, 0x00000030, 0x00001f3c, 0x00000c6c, 0x000004e6, 0x000004c2, 0x00000582, - 0x00000786, 0x00000306, 0x000007dc, 0x00001ef8, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F24_LEFT_PAREN: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000060, 0x00000030, 0x00000018, 0x0000000c, 0x00000004, 0x00000004, - 0x00000006, 0x00000006, 0x00000006, 0x00000006, 0x00000006, 0x00000006, 0x00000006, 0x00000006, - 0x00000006, 0x00000006, 0x00000006, 0x00000004, 0x0000000c, 0x00000008, 0x00000018, 0x00000030, - 0x00000060, 0x00000000, -]; -const F24_RIGHT_PAREN: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000003, 0x00000006, 0x0000000c, 0x00000018, 0x00000018, 0x00000010, - 0x00000030, 0x00000030, 0x00000030, 0x00000030, 0x00000030, 0x00000030, 0x00000030, 0x00000030, - 0x00000030, 0x00000030, 0x00000030, 0x00000010, 0x00000018, 0x00000008, 0x0000000c, 0x00000006, - 0x00000003, 0x00000000, -]; -const F24_UNDERSCORE: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x000001ff, 0x00000000, - 0x00000000, 0x00000000, -]; -const F24_SEMICOLON: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000006, 0x00000006, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000006, 0x00000006, 0x00000004, 0x00000006, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F24_HASH: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000820, 0x00000820, 0x00000830, 0x00000830, 0x00000830, 0x00000c30, - 0x00007ffe, 0x00000c10, 0x00000c10, 0x00000c10, 0x00000410, 0x00000410, 0x00000410, 0x00007fff, - 0x00000418, 0x00000418, 0x00000418, 0x00000618, 0x00000608, 0x00000608, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F24_AT: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000000, 0x000003e0, 0x00000e38, 0x00000c0c, 0x00001804, 0x00001fc6, - 0x00001c66, 0x00001822, 0x00001832, 0x00001832, 0x00001832, 0x00001832, 0x00001832, 0x00001822, - 0x00001c66, 0x000013c6, 0x00000004, 0x0000180c, 0x00000c38, 0x000007e0, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F24_ASTERISK: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000020, 0x00000020, 0x00000326, 0x000001bc, 0x00000070, - 0x000000f8, 0x000003ae, 0x00000020, 0x00000020, 0x00000020, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F24_APOSTROPHE: [u32; 26] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000004, 0x0000000e, 0x00000004, 0x00000004, 0x00000004, - 0x00000004, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; - -pub(crate) const SMALL_GLYPHS: [Glyph; 81] = [ - Glyph { - code: 32, - width: 4, - rows: &F24_SPACE, - }, - Glyph { - code: 65, - width: 15, - rows: &F24_CA, - }, - Glyph { - code: 66, - width: 12, - rows: &F24_CB, - }, - Glyph { - code: 67, - width: 12, - rows: &F24_CC, - }, - Glyph { - code: 68, - width: 13, - rows: &F24_CD, - }, - Glyph { - code: 69, - width: 12, - rows: &F24_CE, - }, - Glyph { - code: 70, - width: 12, - rows: &F24_CF, - }, - Glyph { - code: 71, - width: 14, - rows: &F24_CG, - }, - Glyph { - code: 72, - width: 15, - rows: &F24_CH, - }, - Glyph { - code: 73, - width: 6, - rows: &F24_CI, - }, - Glyph { - code: 74, - width: 11, - rows: &F24_CJ, - }, - Glyph { - code: 75, - width: 14, - rows: &F24_CK, - }, - Glyph { - code: 76, - width: 12, - rows: &F24_CL, - }, - Glyph { - code: 77, - width: 17, - rows: &F24_CM, - }, - Glyph { - code: 78, - width: 15, - rows: &F24_CN, - }, - Glyph { - code: 79, - width: 14, - rows: &F24_CO, - }, - Glyph { - code: 80, - width: 13, - rows: &F24_CP, - }, - Glyph { - code: 81, - width: 15, - rows: &F24_CQ, - }, - Glyph { - code: 82, - width: 14, - rows: &F24_CR, - }, - Glyph { - code: 83, - width: 12, - rows: &F24_CS, - }, - Glyph { - code: 84, - width: 13, - rows: &F24_CT, - }, - Glyph { - code: 85, - width: 15, - rows: &F24_CU, - }, - Glyph { - code: 86, - width: 15, - rows: &F24_CV, - }, - Glyph { - code: 87, - width: 17, - rows: &F24_CW, - }, - Glyph { - code: 88, - width: 14, - rows: &F24_CX, - }, - Glyph { - code: 89, - width: 14, - rows: &F24_CY, - }, - Glyph { - code: 90, - width: 12, - rows: &F24_CZ, - }, - Glyph { - code: 97, - width: 11, - rows: &F24_Ca, - }, - Glyph { - code: 98, - width: 12, - rows: &F24_Cb, - }, - Glyph { - code: 99, - width: 10, - rows: &F24_Cc, - }, - Glyph { - code: 100, - width: 12, - rows: &F24_Cd, - }, - Glyph { - code: 101, - width: 10, - rows: &F24_Ce, - }, - Glyph { - code: 102, - width: 11, - rows: &F24_Cf, - }, - Glyph { - code: 103, - width: 12, - rows: &F24_Cg, - }, - Glyph { - code: 104, - width: 13, - rows: &F24_Ch, - }, - Glyph { - code: 105, - width: 7, - rows: &F24_Ci, - }, - Glyph { - code: 106, - width: 4, - rows: &F24_Cj, - }, - Glyph { - code: 107, - width: 13, - rows: &F24_Ck, - }, - Glyph { - code: 108, - width: 6, - rows: &F24_Cl, - }, - Glyph { - code: 109, - width: 17, - rows: &F24_Cm, - }, - Glyph { - code: 110, - width: 13, - rows: &F24_Cn, - }, - Glyph { - code: 111, - width: 11, - rows: &F24_Co, - }, - Glyph { - code: 112, - width: 12, - rows: &F24_Cp, - }, - Glyph { - code: 113, - width: 12, - rows: &F24_Cq, - }, - Glyph { - code: 114, - width: 9, - rows: &F24_Cr, - }, - Glyph { - code: 115, - width: 9, - rows: &F24_Cs, - }, - Glyph { - code: 116, - width: 10, - rows: &F24_Ct, - }, - Glyph { - code: 117, - width: 13, - rows: &F24_Cu, - }, - Glyph { - code: 118, - width: 12, - rows: &F24_Cv, - }, - Glyph { - code: 119, - width: 15, - rows: &F24_Cw, - }, - Glyph { - code: 120, - width: 12, - rows: &F24_Cx, - }, - Glyph { - code: 121, - width: 11, - rows: &F24_Cy, - }, - Glyph { - code: 122, - width: 9, - rows: &F24_Cz, - }, - Glyph { - code: 48, - width: 12, - rows: &F24_C0, - }, - Glyph { - code: 49, - width: 9, - rows: &F24_C1, - }, - Glyph { - code: 50, - width: 10, - rows: &F24_C2, - }, - Glyph { - code: 51, - width: 11, - rows: &F24_C3, - }, - Glyph { - code: 52, - width: 11, - rows: &F24_C4, - }, - Glyph { - code: 53, - width: 11, - rows: &F24_C5, - }, - Glyph { - code: 54, - width: 11, - rows: &F24_C6, - }, - Glyph { - code: 55, - width: 10, - rows: &F24_C7, - }, - Glyph { - code: 56, - width: 11, - rows: &F24_C8, - }, - Glyph { - code: 57, - width: 12, - rows: &F24_C9, - }, - Glyph { - code: 37, - width: 14, - rows: &F24_PERCENT, - }, - Glyph { - code: 46, - width: 3, - rows: &F24_DOT, - }, - Glyph { - code: 47, - width: 6, - rows: &F24_SLASH, - }, - Glyph { - code: 45, - width: 6, - rows: &F24_DASH, - }, - Glyph { - code: 63, - width: 10, - rows: &F24_QUESTION, - }, - Glyph { - code: 33, - width: 4, - rows: &F24_BANG, - }, - Glyph { - code: 58, - width: 3, - rows: &F24_COLON, - }, - Glyph { - code: 43, - width: 10, - rows: &F24_PLUS, - }, - Glyph { - code: 44, - width: 4, - rows: &F24_COMMA, - }, - Glyph { - code: 38, - width: 13, - rows: &F24_AMPERSAND, - }, - Glyph { - code: 40, - width: 7, - rows: &F24_LEFT_PAREN, - }, - Glyph { - code: 41, - width: 6, - rows: &F24_RIGHT_PAREN, - }, - Glyph { - code: 95, - width: 9, - rows: &F24_UNDERSCORE, - }, - Glyph { - code: 59, - width: 3, - rows: &F24_SEMICOLON, - }, - Glyph { - code: 35, - width: 15, - rows: &F24_HASH, - }, - Glyph { - code: 64, - width: 13, - rows: &F24_AT, - }, - Glyph { - code: 42, - width: 10, - rows: &F24_ASTERISK, - }, - Glyph { - code: 39, - width: 4, - rows: &F24_APOSTROPHE, - }, -]; - -pub(crate) const LARGE_HEIGHT: usize = 34; - -const F32_SPACE: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F32_CA: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000600, 0x00000600, 0x00000e00, - 0x00000f00, 0x00000f00, 0x00001d00, 0x00001980, 0x00001980, 0x00003880, 0x000038c0, 0x000030c0, - 0x000070c0, 0x00007040, 0x00006060, 0x00007fe0, 0x0000ffe0, 0x0000c030, 0x0000c030, 0x0001c010, - 0x0001c018, 0x000fe07e, 0x000ff0ff, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F32_CB: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000ffe, 0x00003ffe, 0x00007038, - 0x00006038, 0x0000e038, 0x0000e038, 0x0000e038, 0x00006038, 0x00003838, 0x00001ff8, 0x00003ff8, - 0x00007038, 0x0000e038, 0x0000c038, 0x0000c038, 0x0000c038, 0x0000c038, 0x0000e038, 0x0000e038, - 0x00007038, 0x00003ffe, 0x00001ffe, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F32_CC: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00009f80, 0x0000bfe0, 0x0000f070, - 0x0000e038, 0x0000e01c, 0x0000c01c, 0x0000c00c, 0x0000800e, 0x0000000e, 0x0000000e, 0x0000000e, - 0x0000000e, 0x0000000e, 0x0000000e, 0x0000000e, 0x0000800c, 0x0000800c, 0x0000c01c, 0x0000c018, - 0x00006030, 0x00003fe0, 0x00000f80, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F32_CD: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000ffe, 0x00001ffe, 0x00003038, - 0x00006038, 0x0000e038, 0x0000c038, 0x0001c038, 0x0001c038, 0x0001c038, 0x0001c038, 0x0001c038, - 0x0001c038, 0x0001c038, 0x0001c038, 0x0001c038, 0x0001c038, 0x0000c038, 0x0000e038, 0x00007038, - 0x00003838, 0x00001ffe, 0x00000ffe, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F32_CE: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000fffe, 0x0000fffe, 0x0000e038, - 0x0000c038, 0x0000c038, 0x0000c038, 0x0000c038, 0x00000c38, 0x00000c38, 0x00000c38, 0x00000ff8, - 0x00000ff8, 0x00000c38, 0x00000c38, 0x00000838, 0x0000c038, 0x0000c038, 0x0000c038, 0x0000c038, - 0x0000e038, 0x0000fffe, 0x0000fffe, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F32_CF: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000fffe, 0x0000fffe, 0x0000e038, - 0x0000c038, 0x0000c038, 0x0000c038, 0x00008038, 0x00000c38, 0x00000c38, 0x00000e38, 0x00000ff8, - 0x00000ff8, 0x00000c38, 0x00000c38, 0x00000c38, 0x00000038, 0x00000038, 0x00000038, 0x00000038, - 0x00000038, 0x000001fe, 0x000003fe, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F32_CG: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00008f80, 0x0000ffe0, 0x0000f030, - 0x0000e018, 0x0000c01c, 0x0000c00c, 0x0000c00c, 0x0000c00e, 0x0000000e, 0x0000000e, 0x0000000e, - 0x0007ff0e, 0x0003fe0e, 0x0001c00e, 0x0001c00e, 0x0001c00e, 0x0001c00c, 0x0001c01c, 0x0001e018, - 0x0001f030, 0x0001bfe0, 0x00018fc0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F32_CH: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x000ff1fe, 0x0007f0fe, 0x00018038, - 0x00018038, 0x00018038, 0x00018038, 0x00018038, 0x00018038, 0x00018038, 0x00018038, 0x0001fff8, - 0x0001fff8, 0x00018038, 0x00018038, 0x00018038, 0x00018038, 0x00018038, 0x00018038, 0x00018038, - 0x00018038, 0x0007f0fe, 0x000ff1fe, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F32_CI: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x000001fe, 0x000000fe, 0x00000038, - 0x00000038, 0x00000038, 0x00000038, 0x00000038, 0x00000038, 0x00000038, 0x00000038, 0x00000038, - 0x00000038, 0x00000038, 0x00000038, 0x00000038, 0x00000038, 0x00000038, 0x00000038, 0x00000038, - 0x00000038, 0x000000fe, 0x000001fe, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F32_CJ: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00007fe0, 0x00007fc0, 0x00000c00, - 0x00000c00, 0x00000c00, 0x00000c00, 0x00000c00, 0x00000c00, 0x00000c00, 0x00000c00, 0x00000c00, - 0x00000c00, 0x00000c00, 0x00000c00, 0x00000c00, 0x00000c04, 0x00000c0e, 0x00000c0e, 0x00000e0e, - 0x00000606, 0x000003fc, 0x000001f0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F32_CK: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0007f9fe, 0x0003f0fe, 0x00006038, - 0x00003038, 0x00001838, 0x00001838, 0x00000c38, 0x00000638, 0x00000338, 0x000003b8, 0x000003f8, - 0x000007f8, 0x00000638, 0x00000e38, 0x00001c38, 0x00001838, 0x00003838, 0x00003038, 0x00007038, - 0x0000e038, 0x0007f0fe, 0x0007f1fe, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F32_CL: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x000001fe, 0x000000fe, 0x00000038, - 0x00000038, 0x00000038, 0x00000038, 0x00000038, 0x00000038, 0x00000038, 0x00000038, 0x00000038, - 0x00000038, 0x00000038, 0x0000c038, 0x0000c038, 0x0000c038, 0x0000c038, 0x0000c038, 0x0000e038, - 0x0000f038, 0x0000fffe, 0x0000fffe, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F32_CM: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x003f007e, 0x003f007e, 0x00078078, - 0x000780f8, 0x000780d8, 0x000680d8, 0x0006c0d8, 0x0006c1d8, 0x0006c198, 0x00066198, 0x00066398, - 0x00066398, 0x00062318, 0x00063318, 0x00063718, 0x00063618, 0x00061e18, 0x00061e18, 0x00061e18, - 0x00060c18, 0x003f8c7e, 0x003fccfe, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F32_CN: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x000fe07e, 0x0007e0fe, 0x000180f8, - 0x000181d8, 0x000181d8, 0x00018398, 0x00018318, 0x00018718, 0x00018618, 0x00018e18, 0x00018c18, - 0x00019c18, 0x00019818, 0x0001b818, 0x0001b018, 0x0001f018, 0x0001e018, 0x0001e018, 0x0001c018, - 0x0001c018, 0x0001807e, 0x000180fe, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F32_CO: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000f80, 0x00003fe0, 0x00006030, - 0x0000c018, 0x0001c01c, 0x0001800c, 0x0003800c, 0x0003800e, 0x0003800e, 0x0003800e, 0x0003800e, - 0x0003800e, 0x0003800e, 0x0003800e, 0x0003800e, 0x0003800c, 0x0001800c, 0x0001c01c, 0x0000c018, - 0x00006030, 0x00003fe0, 0x00000f80, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F32_CP: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00003ffe, 0x0000fffe, 0x0000c038, - 0x0001c038, 0x00018038, 0x00018038, 0x00018038, 0x0001c038, 0x0001c038, 0x0000e038, 0x00007ff8, - 0x000007f8, 0x00000038, 0x00000038, 0x00000038, 0x00000038, 0x00000038, 0x00000038, 0x00000038, - 0x00000038, 0x000000fe, 0x000001fe, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F32_CQ: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000f80, 0x00003fe0, 0x00006030, - 0x0000c018, 0x0001c01c, 0x0001800c, 0x0003800c, 0x0003800e, 0x0003800e, 0x0003800e, 0x0003800e, - 0x0003800e, 0x0003800e, 0x0003800e, 0x0003800e, 0x0003800c, 0x0001801c, 0x0001cf9c, 0x0000dd98, - 0x000478f0, 0x00043fe0, 0x00047f80, 0x0006e000, 0x0007c000, 0x00038000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F32_CR: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00003ffe, 0x0000fffe, 0x0001e038, - 0x0001c038, 0x0001c038, 0x0001c038, 0x0001c038, 0x0001c038, 0x0000e038, 0x00003ff8, 0x00003ff8, - 0x00007838, 0x00007038, 0x0000e038, 0x0000e038, 0x0006c038, 0x0006c038, 0x0006c038, 0x0006c038, - 0x0006c038, 0x0007c1fe, 0x000383fe, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F32_CS: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x000067e0, 0x00006ff8, 0x0000781c, - 0x0000700c, 0x0000700c, 0x0000600e, 0x0000600c, 0x0000601c, 0x0000003c, 0x000000f8, 0x000003e0, - 0x00000f80, 0x00003e00, 0x00003806, 0x00007006, 0x00006006, 0x00006006, 0x0000600e, 0x0000700e, - 0x0000301e, 0x00003ff6, 0x00000fe6, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F32_CT: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0003fffe, 0x0003fffe, 0x00038306, - 0x00030306, 0x00030302, 0x00030302, 0x00030302, 0x00000300, 0x00000300, 0x00000300, 0x00000300, - 0x00000300, 0x00000300, 0x00000300, 0x00000300, 0x00000300, 0x00000300, 0x00000300, 0x00000300, - 0x00000300, 0x00001fe0, 0x00003ff0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F32_CU: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x000ff1fe, 0x0007e1fe, 0x00018038, - 0x00018038, 0x00018038, 0x00018038, 0x00018038, 0x00018038, 0x00018038, 0x00018038, 0x00018038, - 0x00018038, 0x00018038, 0x00018038, 0x00018038, 0x00018038, 0x00018038, 0x00018038, 0x0000c030, - 0x0000e070, 0x00007fe0, 0x00001f80, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F32_CV: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x000ff1ff, 0x0007e0fe, 0x00018038, - 0x00018030, 0x00008030, 0x0000c070, 0x0000c060, 0x00004060, 0x00006060, 0x000060e0, 0x000020c0, - 0x000030c0, 0x000031c0, 0x00001180, 0x00001980, 0x00001b80, 0x00001b00, 0x00000f00, 0x00000f00, - 0x00000e00, 0x00000600, 0x00000600, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F32_CW: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x003f087f, 0x003e187e, 0x000c1818, - 0x000c1c18, 0x000c1c18, 0x000c3c38, 0x00043c30, 0x00043430, 0x00063630, 0x00067630, 0x00067270, - 0x00026270, 0x00026360, 0x00026360, 0x0003e360, 0x0003e1e0, 0x0003c1e0, 0x0001c1c0, 0x0001c1c0, - 0x0001c1c0, 0x000180c0, 0x000180c0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F32_CX: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0003f8fe, 0x0003f0fe, 0x0000e038, - 0x00006070, 0x00003060, 0x000030e0, 0x000018c0, 0x00000dc0, 0x00000f80, 0x00000700, 0x00000700, - 0x00000700, 0x00000f00, 0x00001d80, 0x000018c0, 0x000038c0, 0x00003060, 0x00006060, 0x0000e030, - 0x0000c038, 0x0007f07e, 0x0007f8ff, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F32_CY: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0007f9ff, 0x0003f0fe, 0x0000c038, - 0x00004030, 0x00006070, 0x00002060, 0x000030e0, 0x000030c0, 0x000011c0, 0x00001980, 0x00000980, - 0x00000f80, 0x00000f00, 0x00000700, 0x00000600, 0x00000600, 0x00000600, 0x00000600, 0x00000600, - 0x00000600, 0x00003fc0, 0x00003fc0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F32_CZ: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000fffe, 0x0000fffe, 0x0000601e, - 0x0000700e, 0x00003806, 0x00001806, 0x00001c06, 0x00000e00, 0x00000600, 0x00000700, 0x00000380, - 0x00000180, 0x000001c0, 0x000000e0, 0x00000060, 0x00008070, 0x00008038, 0x0000c018, 0x0000c01c, - 0x0000e00e, 0x0000fffe, 0x0000fffe, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F32_Ca: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x000003f0, 0x000007fc, 0x00000e0e, 0x00000e0e, - 0x00000c0e, 0x00000c00, 0x00000f80, 0x00000ff8, 0x00000c1c, 0x00006c06, 0x00006c06, 0x00006e06, - 0x00006f06, 0x00007dfe, 0x0000387c, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F32_Cb: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000001f, 0x0000001e, 0x00000018, - 0x00000018, 0x00000018, 0x00000018, 0x00000018, 0x00000f98, 0x00001fd8, 0x00003078, 0x00007038, - 0x0000e038, 0x0000e018, 0x0000e018, 0x0000e018, 0x0000e018, 0x0000e018, 0x0000e038, 0x00007038, - 0x00007078, 0x00001fd8, 0x00000f88, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F32_Cc: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x000007e0, 0x00000ff8, 0x00001c1c, 0x00001c0c, - 0x00001c0e, 0x0000000e, 0x00000006, 0x00000006, 0x00000006, 0x0000100e, 0x0000180e, 0x0000180c, - 0x00000c1c, 0x00000ff8, 0x000003e0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F32_Cd: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00003e00, 0x00003e00, 0x00003800, - 0x00003800, 0x00003800, 0x00003800, 0x00003800, 0x000039e0, 0x00003ff8, 0x00003c1c, 0x0000380c, - 0x0000380e, 0x0000380e, 0x00003806, 0x00003806, 0x00003806, 0x0000380e, 0x0000380e, 0x0000380c, - 0x00003c1c, 0x0000f7f8, 0x0000f3e0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F32_Ce: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x000003e0, 0x000007f8, 0x00000c1c, 0x0000180c, - 0x0000180e, 0x0000180e, 0x00003ffe, 0x00003ffe, 0x00000006, 0x0000100e, 0x0000100e, 0x0000180c, - 0x00000c1c, 0x00000ff8, 0x000003e0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F32_Cf: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000f80, 0x00001fc0, 0x00003860, 0x00003c70, 0x00003830, - 0x00000030, 0x00000030, 0x00000030, 0x00000038, 0x000007ff, 0x000003fe, 0x00000030, 0x00000030, - 0x00000030, 0x00000030, 0x00000030, 0x00000030, 0x00000030, 0x00000030, 0x00000030, 0x00000030, - 0x00000030, 0x000003fc, 0x000003fe, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F32_Cg: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00007000, 0x0000f800, 0x00006c00, 0x00000fe0, 0x00000e70, 0x00001c18, 0x0000181c, - 0x0000381c, 0x0000381c, 0x0000381c, 0x0000181c, 0x00001c18, 0x00000e30, 0x000007fc, 0x00000006, - 0x0000000e, 0x00003ffc, 0x0000fff8, 0x0000e00e, 0x0001c007, 0x0001c003, 0x0000e007, 0x0000781e, - 0x00001ff8, 0x00000000, -]; -const F32_Ch: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000001f, 0x0000001e, 0x00000018, - 0x00000018, 0x00000018, 0x00000018, 0x00000018, 0x00001f18, 0x00003f98, 0x000030d8, 0x00007078, - 0x00006038, 0x00006038, 0x00006018, 0x00006018, 0x00006018, 0x00006018, 0x00006018, 0x00006018, - 0x00006018, 0x0001f87e, 0x0001fc7f, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F32_Ci: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000010, 0x00000038, 0x0000003c, - 0x00000018, 0x00000000, 0x00000000, 0x00000000, 0x0000003e, 0x0000003e, 0x00000030, 0x00000030, - 0x00000030, 0x00000030, 0x00000030, 0x00000030, 0x00000030, 0x00000030, 0x00000030, 0x00000030, - 0x00000030, 0x000001fe, 0x000001ff, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F32_Cj: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000018, 0x0000003c, 0x0000003c, - 0x00000018, 0x00000000, 0x00000000, 0x00000000, 0x0000001f, 0x0000001e, 0x00000018, 0x00000018, - 0x00000018, 0x00000018, 0x00000018, 0x00000018, 0x00000018, 0x00000018, 0x00000018, 0x00000018, - 0x00000018, 0x00000018, 0x00000018, 0x00000018, 0x00000018, 0x00000018, 0x0000001c, 0x0000000e, - 0x00000007, 0x00000000, -]; -const F32_Ck: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000001f, 0x0000001e, 0x00000018, - 0x00000018, 0x00000018, 0x00000018, 0x00000018, 0x0000fe18, 0x0000fe18, 0x00000c18, 0x00000618, - 0x00000318, 0x00000198, 0x000003f8, 0x000003f8, 0x00000718, 0x00000e18, 0x00001c18, 0x00001c18, - 0x00003818, 0x0000fc7e, 0x0001fc7f, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F32_Cl: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000001f, 0x0000001e, 0x00000018, - 0x00000018, 0x00000018, 0x00000018, 0x00000018, 0x00000018, 0x00000018, 0x00000018, 0x00000018, - 0x00000018, 0x00000018, 0x00000018, 0x00000018, 0x00000018, 0x00000018, 0x00000018, 0x00000018, - 0x00000018, 0x0000007e, 0x000000ff, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F32_Cm: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0007879f, 0x000fefde, 0x001c7c78, 0x001c1838, - 0x00181818, 0x00181818, 0x00181818, 0x00181818, 0x00181818, 0x00181818, 0x00181818, 0x00181818, - 0x00181818, 0x007e3e7e, 0x007f7e7f, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F32_Cn: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00001f1f, 0x00003f9e, 0x000038d8, 0x00007078, - 0x00007038, 0x00007018, 0x00007018, 0x00007018, 0x00007018, 0x00007018, 0x00007018, 0x00007018, - 0x00007018, 0x0001f87e, 0x0001fc7f, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F32_Co: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x000003e0, 0x00000ff8, 0x00001c1c, 0x0000180c, - 0x0000380e, 0x0000300e, 0x00003006, 0x00003006, 0x00003006, 0x0000380e, 0x0000380e, 0x0000180c, - 0x00001c1c, 0x00000ff8, 0x000003e0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F32_Cp: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000f9f, 0x00001fde, 0x00003078, 0x00007038, - 0x00006038, 0x0000e018, 0x0000e018, 0x0000e018, 0x0000e018, 0x0000e018, 0x00006038, 0x00007038, - 0x00003078, 0x00001fd8, 0x00000f98, 0x00000018, 0x00000018, 0x00000018, 0x00000018, 0x000000fe, - 0x000001ff, 0x00000000, -]; -const F32_Cq: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x000011f0, 0x00001bf8, 0x00001e1c, 0x00001c0e, - 0x00001c0e, 0x0000180e, 0x00001806, 0x00001806, 0x00001806, 0x0000180e, 0x00001c0e, 0x00001c0e, - 0x00001e1c, 0x00001bf8, 0x000019f0, 0x00001800, 0x00001800, 0x00001800, 0x00001800, 0x00007f00, - 0x0000ff80, 0x00000000, -]; -const F32_Cr: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000079f, 0x00000fde, 0x00001e78, 0x00000e38, - 0x00000438, 0x00000038, 0x00000018, 0x00000018, 0x00000018, 0x00000018, 0x00000018, 0x00000018, - 0x00000018, 0x000001fe, 0x000001ff, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F32_Cs: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000df8, 0x00000ffc, 0x00000e0e, 0x00000c06, - 0x00000c0e, 0x0000001e, 0x000000fc, 0x000003f0, 0x00000780, 0x00000e02, 0x00000e06, 0x00000c06, - 0x00000e0e, 0x000007fe, 0x000003f2, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F32_Ct: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000060, - 0x00000060, 0x00000060, 0x00000060, 0x00000070, 0x00000fff, 0x000007fe, 0x00000070, 0x00000070, - 0x00000070, 0x00000070, 0x00000070, 0x00001070, 0x00001870, 0x00001870, 0x00001870, 0x00001870, - 0x00001860, 0x00000fe0, 0x000007c0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F32_Cu: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00007c1f, 0x0000781e, 0x00006018, 0x00006018, - 0x00006018, 0x00006018, 0x00006018, 0x00006018, 0x00006018, 0x00007018, 0x00007018, 0x00007818, - 0x00006c38, 0x0001e7f0, 0x0001e3e0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F32_Cv: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000feff, 0x00007cfe, 0x00001818, 0x00001818, - 0x00000838, 0x00000c30, 0x00000c70, 0x00000460, 0x00000660, 0x000006e0, 0x000003c0, 0x000003c0, - 0x00000380, 0x00000180, 0x00000180, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F32_Cw: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x000fc63f, 0x0007c63e, 0x0001061c, 0x00018f18, - 0x00018f18, 0x00008d18, 0x00008d38, 0x0000ddb0, 0x0000d9b0, 0x000058b0, 0x000078f0, 0x000078e0, - 0x000030e0, 0x00003060, 0x00003060, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F32_Cx: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00007e7e, 0x00007e7e, 0x00000c38, 0x00000c70, - 0x00000660, 0x000003e0, 0x000001c0, 0x00000380, 0x000003c0, 0x000007c0, 0x00000e60, 0x00001c30, - 0x00001818, 0x00007c3e, 0x0000fe7f, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F32_Cy: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00007e7f, 0x00007c7e, 0x0000181c, 0x00001818, - 0x00000838, 0x00000c30, 0x00000c70, 0x00000460, 0x00000660, 0x000006e0, 0x000002c0, 0x000003c0, - 0x000003c0, 0x00000180, 0x00000180, 0x00000180, 0x00000086, 0x000000c7, 0x000000c7, 0x00000076, - 0x0000003c, 0x00000000, -]; -const F32_Cz: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00001ffe, 0x00000ffe, 0x00000e02, 0x00000702, - 0x00000382, 0x00000182, 0x000001c0, 0x000000e0, 0x00000070, 0x00000830, 0x00000838, 0x0000081c, - 0x0000080e, 0x00000ffe, 0x00000ffe, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F32_C0: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x000007c0, 0x00000ff0, 0x00001838, - 0x00003818, 0x0000301c, 0x0000700c, 0x0000700e, 0x0000700e, 0x0000700e, 0x0000700e, 0x0000700e, - 0x0000700e, 0x0000700e, 0x0000700e, 0x0000700e, 0x0000700e, 0x0000700c, 0x0000301c, 0x00003818, - 0x00001838, 0x00000ff0, 0x000007c0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F32_C1: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x000000c0, 0x000000c0, 0x000000e0, - 0x000000fe, 0x000000fe, 0x000000c0, 0x000000c0, 0x000000c0, 0x000000c0, 0x000000c0, 0x000000c0, - 0x000000c0, 0x000000c0, 0x000000c0, 0x000000c0, 0x000000c0, 0x000000c0, 0x000000c0, 0x000000c0, - 0x000000c0, 0x00000ffe, 0x00001ffe, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F32_C2: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x000003f0, 0x00000ff8, 0x00001e0c, - 0x00001c0e, 0x00001c1e, 0x00001c1e, 0x00001c0c, 0x00001c00, 0x00001c00, 0x00001e00, 0x00000e00, - 0x00000700, 0x00000380, 0x00000180, 0x000000c0, 0x00000060, 0x00000030, 0x00000038, 0x00001018, - 0x0000180c, 0x00001ffe, 0x00001ffe, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F32_C3: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x000007e0, 0x00000ff8, 0x00001c0c, - 0x0000380c, 0x0000381c, 0x0000381c, 0x0000381c, 0x00003800, 0x00001c00, 0x00000e00, 0x000007c0, - 0x00000fc0, 0x00001c00, 0x00003800, 0x00007808, 0x0000701c, 0x0000701e, 0x0000381c, 0x00003804, - 0x00001c0c, 0x00000ff8, 0x000007e0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F32_C4: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000800, 0x00000c00, 0x00000e00, - 0x00000e00, 0x00000f00, 0x00000d80, 0x00000d80, 0x00000cc0, 0x00000c60, 0x00000c60, 0x00000c30, - 0x00000c18, 0x00000c18, 0x00000c0c, 0x00007ffe, 0x00007ffe, 0x00000c00, 0x00000c00, 0x00000c00, - 0x00000c00, 0x00007f00, 0x00007f80, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F32_C5: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00001000, 0x00001800, 0x00001ff8, 0x00001ff8, 0x00000018, - 0x00000018, 0x00000008, 0x00000008, 0x0000000c, 0x0000000c, 0x000003ec, 0x00000ffc, 0x00001e1c, - 0x00001c0c, 0x00003800, 0x00003800, 0x00003800, 0x0000380c, 0x0000381e, 0x0000381e, 0x00001c0e, - 0x00000c0c, 0x000007fc, 0x000003f0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F32_C6: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000fc0, 0x00001fe0, 0x00003830, - 0x00003818, 0x0000381c, 0x0000100c, 0x0000000c, 0x0000000e, 0x000007ce, 0x00001ffe, 0x0000383e, - 0x0000381e, 0x0000700e, 0x0000700e, 0x0000700e, 0x0000700e, 0x0000700e, 0x0000700c, 0x0000381c, - 0x00001838, 0x00000ff0, 0x000007e0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F32_C7: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00003ffe, 0x00001ffe, 0x0000180e, - 0x00000c06, 0x00000c02, 0x00000600, 0x00000600, 0x00000300, 0x00000300, 0x00000180, 0x00000180, - 0x00000180, 0x000000c0, 0x000000c0, 0x000000c0, 0x000000c0, 0x000000e0, 0x000000e0, 0x000000e0, - 0x000000e0, 0x000000e0, 0x00000060, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F32_C8: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x000003e0, 0x000007f8, 0x00000c1c, - 0x0000180c, 0x0000180c, 0x0000180e, 0x0000180c, 0x00000c0c, 0x00000c3c, 0x000006f8, 0x000003f0, - 0x00000f98, 0x00001e0c, 0x0000180c, 0x00003806, 0x00003006, 0x00003006, 0x00003006, 0x0000380e, - 0x00001c1c, 0x00000ff8, 0x000007e0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F32_C9: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x000007e0, 0x00001ff0, 0x00001838, - 0x0000381c, 0x0000300c, 0x0000700e, 0x0000700e, 0x0000700e, 0x0000700e, 0x0000700e, 0x0000781c, - 0x0000783c, 0x00006ff8, 0x000063e0, 0x00007000, 0x00007000, 0x00003018, 0x0000303c, 0x0000183c, - 0x00001c1c, 0x00000ff8, 0x000003e0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F32_PERCENT: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000078, 0x000000cc, 0x00000184, - 0x00000186, 0x00010186, 0x00018186, 0x0000c186, 0x00006184, 0x000018cc, 0x00000c78, 0x00000600, - 0x00000300, 0x0000f180, 0x000198c0, 0x00030c60, 0x00030c18, 0x00030c0c, 0x00030c04, 0x00030c00, - 0x00030c00, 0x00019800, 0x0000f000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F32_DOT: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x0000000c, 0x0000001e, 0x0000000c, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F32_SLASH: [u32; 34] = [ - 0x00000000, 0x00000080, 0x000000c0, 0x000000c0, 0x000000c0, 0x00000040, 0x00000060, 0x00000060, - 0x00000060, 0x00000060, 0x00000020, 0x00000030, 0x00000030, 0x00000030, 0x00000010, 0x00000018, - 0x00000018, 0x00000018, 0x00000018, 0x00000008, 0x0000000c, 0x0000000c, 0x0000000c, 0x00000004, - 0x00000006, 0x00000006, 0x00000006, 0x00000006, 0x00000002, 0x00000003, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F32_DASH: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x000000fe, 0x000000ff, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F32_QUESTION: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x000003f0, 0x000007fc, 0x00000c0e, - 0x0000180e, 0x0000180e, 0x0000180e, 0x00001800, 0x00001c00, 0x00000c00, 0x00000f00, 0x000007c0, - 0x000001c0, 0x00000040, 0x00000040, 0x00000040, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x000000e0, 0x000000e0, 0x000000e0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F32_BANG: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000000c, 0x0000001c, 0x0000001c, - 0x0000001c, 0x0000001c, 0x0000000c, 0x0000000c, 0x0000000c, 0x0000000c, 0x0000000c, 0x0000000c, - 0x0000000c, 0x0000000c, 0x0000000c, 0x0000000c, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x0000001c, 0x0000001c, 0x0000000c, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F32_COLON: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x0000000c, 0x0000001e, 0x0000000c, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x0000000c, 0x0000001e, 0x0000000c, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F32_PLUS: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000040, 0x00000040, 0x00000040, 0x00000040, - 0x00000040, 0x00000ffe, 0x00001fff, 0x00000040, 0x00000040, 0x00000040, 0x00000040, 0x00000040, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F32_COMMA: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x0000000c, 0x0000001e, 0x0000001c, 0x00000008, 0x0000000c, 0x00000006, 0x00000002, 0x00000000, - 0x00000000, 0x00000000, -]; -const F32_AMPERSAND: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x000003c0, 0x00000ff0, 0x00000c30, - 0x00001818, 0x00001818, 0x00001818, 0x00000c38, 0x00000e30, 0x00000770, 0x000001e0, 0x0001f0f0, - 0x0003f9f8, 0x0000e19c, 0x0000438c, 0x00006306, 0x00006606, 0x00002e06, 0x00003c06, 0x0000380e, - 0x00003c1c, 0x0001fff8, 0x0003f3f0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F32_LEFT_PAREN: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000180, 0x000000c0, 0x00000060, 0x00000030, 0x00000038, 0x00000018, - 0x0000000c, 0x0000000c, 0x0000000c, 0x0000000e, 0x00000006, 0x00000006, 0x00000006, 0x00000006, - 0x00000006, 0x00000006, 0x00000006, 0x00000006, 0x00000006, 0x00000006, 0x00000006, 0x0000000e, - 0x0000000c, 0x0000000c, 0x0000001c, 0x00000018, 0x00000030, 0x00000030, 0x00000060, 0x000000c0, - 0x00000180, 0x00000000, -]; -const F32_RIGHT_PAREN: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000002, 0x00000006, 0x0000000c, 0x00000018, 0x00000030, 0x00000030, - 0x00000060, 0x00000060, 0x00000060, 0x000000c0, 0x000000c0, 0x000000c0, 0x000000c0, 0x000000c0, - 0x000000c0, 0x000000c0, 0x000000c0, 0x000000c0, 0x000000c0, 0x000000c0, 0x000000c0, 0x000000c0, - 0x00000060, 0x00000060, 0x00000060, 0x00000030, 0x00000030, 0x00000018, 0x0000000c, 0x00000006, - 0x00000002, 0x00000000, -]; -const F32_UNDERSCORE: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000fff, 0x000007fe, 0x00000000, - 0x00000000, 0x00000000, -]; -const F32_SEMICOLON: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x0000000c, 0x0000000e, 0x0000000e, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x0000000e, 0x0000001e, 0x0000001c, 0x00000008, 0x0000000c, 0x00000006, 0x00000002, 0x00000000, - 0x00000000, 0x00000000, -]; -const F32_HASH: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x000080c0, 0x000080c0, 0x0000c0c0, 0x0000c0c0, 0x0000c0c0, - 0x0000c040, 0x0000c040, 0x0007fffc, 0x000ffffe, 0x0000c060, 0x0000c060, 0x00004060, 0x00004060, - 0x00006060, 0x00006060, 0x00006060, 0x0007fffe, 0x0007fffe, 0x00006020, 0x00006020, 0x00006030, - 0x00006030, 0x00002030, 0x00002030, 0x00002030, 0x00002030, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F32_AT: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00001f80, 0x00007fe0, 0x0000e070, - 0x0000c018, 0x0001800c, 0x00019e0c, 0x0001ff04, 0x0001c186, 0x0001c0c6, 0x000180c6, 0x000180c6, - 0x000180e6, 0x000180e6, 0x000180e6, 0x000180c6, 0x000180c6, 0x0001c1c6, 0x0001e386, 0x00013f0c, - 0x0000000c, 0x00010018, 0x00018030, 0x0000e0e0, 0x00007fc0, 0x00000400, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F32_ASTERISK: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000080, 0x00000080, 0x00000080, - 0x0000188c, 0x00000eb8, 0x000007f0, 0x000001c0, 0x000007f0, 0x00001c9c, 0x0000188c, 0x00000080, - 0x00000080, 0x00000080, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; -const F32_APOSTROPHE: [u32; 34] = [ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000000c, 0x0000001c, 0x0000001c, - 0x0000001c, 0x0000000c, 0x0000000c, 0x00000008, 0x00000008, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, -]; - -pub(crate) const LARGE_GLYPHS: [Glyph; 81] = [ - Glyph { - code: 32, - width: 5, - rows: &F32_SPACE, - }, - Glyph { - code: 65, - width: 20, - rows: &F32_CA, - }, - Glyph { - code: 66, - width: 16, - rows: &F32_CB, - }, - Glyph { - code: 67, - width: 16, - rows: &F32_CC, - }, - Glyph { - code: 68, - width: 17, - rows: &F32_CD, - }, - Glyph { - code: 69, - width: 16, - rows: &F32_CE, - }, - Glyph { - code: 70, - width: 16, - rows: &F32_CF, - }, - Glyph { - code: 71, - width: 19, - rows: &F32_CG, - }, - Glyph { - code: 72, - width: 20, - rows: &F32_CH, - }, - Glyph { - code: 73, - width: 9, - rows: &F32_CI, - }, - Glyph { - code: 74, - width: 15, - rows: &F32_CJ, - }, - Glyph { - code: 75, - width: 19, - rows: &F32_CK, - }, - Glyph { - code: 76, - width: 16, - rows: &F32_CL, - }, - Glyph { - code: 77, - width: 22, - rows: &F32_CM, - }, - Glyph { - code: 78, - width: 20, - rows: &F32_CN, - }, - Glyph { - code: 79, - width: 18, - rows: &F32_CO, - }, - Glyph { - code: 80, - width: 17, - rows: &F32_CP, - }, - Glyph { - code: 81, - width: 19, - rows: &F32_CQ, - }, - Glyph { - code: 82, - width: 19, - rows: &F32_CR, - }, - Glyph { - code: 83, - width: 15, - rows: &F32_CS, - }, - Glyph { - code: 84, - width: 18, - rows: &F32_CT, - }, - Glyph { - code: 85, - width: 20, - rows: &F32_CU, - }, - Glyph { - code: 86, - width: 20, - rows: &F32_CV, - }, - Glyph { - code: 87, - width: 22, - rows: &F32_CW, - }, - Glyph { - code: 88, - width: 19, - rows: &F32_CX, - }, - Glyph { - code: 89, - width: 19, - rows: &F32_CY, - }, - Glyph { - code: 90, - width: 16, - rows: &F32_CZ, - }, - Glyph { - code: 97, - width: 15, - rows: &F32_Ca, - }, - Glyph { - code: 98, - width: 16, - rows: &F32_Cb, - }, - Glyph { - code: 99, - width: 13, - rows: &F32_Cc, - }, - Glyph { - code: 100, - width: 16, - rows: &F32_Cd, - }, - Glyph { - code: 101, - width: 14, - rows: &F32_Ce, - }, - Glyph { - code: 102, - width: 14, - rows: &F32_Cf, - }, - Glyph { - code: 103, - width: 17, - rows: &F32_Cg, - }, - Glyph { - code: 104, - width: 17, - rows: &F32_Ch, - }, - Glyph { - code: 105, - width: 9, - rows: &F32_Ci, - }, - Glyph { - code: 106, - width: 6, - rows: &F32_Cj, - }, - Glyph { - code: 107, - width: 17, - rows: &F32_Ck, - }, - Glyph { - code: 108, - width: 8, - rows: &F32_Cl, - }, - Glyph { - code: 109, - width: 23, - rows: &F32_Cm, - }, - Glyph { - code: 110, - width: 17, - rows: &F32_Cn, - }, - Glyph { - code: 111, - width: 14, - rows: &F32_Co, - }, - Glyph { - code: 112, - width: 16, - rows: &F32_Cp, - }, - Glyph { - code: 113, - width: 16, - rows: &F32_Cq, - }, - Glyph { - code: 114, - width: 13, - rows: &F32_Cr, - }, - Glyph { - code: 115, - width: 12, - rows: &F32_Cs, - }, - Glyph { - code: 116, - width: 13, - rows: &F32_Ct, - }, - Glyph { - code: 117, - width: 17, - rows: &F32_Cu, - }, - Glyph { - code: 118, - width: 16, - rows: &F32_Cv, - }, - Glyph { - code: 119, - width: 20, - rows: &F32_Cw, - }, - Glyph { - code: 120, - width: 16, - rows: &F32_Cx, - }, - Glyph { - code: 121, - width: 15, - rows: &F32_Cy, - }, - Glyph { - code: 122, - width: 13, - rows: &F32_Cz, - }, - Glyph { - code: 48, - width: 15, - rows: &F32_C0, - }, - Glyph { - code: 49, - width: 13, - rows: &F32_C1, - }, - Glyph { - code: 50, - width: 13, - rows: &F32_C2, - }, - Glyph { - code: 51, - width: 15, - rows: &F32_C3, - }, - Glyph { - code: 52, - width: 15, - rows: &F32_C4, - }, - Glyph { - code: 53, - width: 14, - rows: &F32_C5, - }, - Glyph { - code: 54, - width: 15, - rows: &F32_C6, - }, - Glyph { - code: 55, - width: 14, - rows: &F32_C7, - }, - Glyph { - code: 56, - width: 14, - rows: &F32_C8, - }, - Glyph { - code: 57, - width: 15, - rows: &F32_C9, - }, - Glyph { - code: 37, - width: 18, - rows: &F32_PERCENT, - }, - Glyph { - code: 46, - width: 5, - rows: &F32_DOT, - }, - Glyph { - code: 47, - width: 8, - rows: &F32_SLASH, - }, - Glyph { - code: 45, - width: 8, - rows: &F32_DASH, - }, - Glyph { - code: 63, - width: 13, - rows: &F32_QUESTION, - }, - Glyph { - code: 33, - width: 5, - rows: &F32_BANG, - }, - Glyph { - code: 58, - width: 5, - rows: &F32_COLON, - }, - Glyph { - code: 43, - width: 13, - rows: &F32_PLUS, - }, - Glyph { - code: 44, - width: 5, - rows: &F32_COMMA, - }, - Glyph { - code: 38, - width: 18, - rows: &F32_AMPERSAND, - }, - Glyph { - code: 40, - width: 9, - rows: &F32_LEFT_PAREN, - }, - Glyph { - code: 41, - width: 8, - rows: &F32_RIGHT_PAREN, - }, - Glyph { - code: 95, - width: 12, - rows: &F32_UNDERSCORE, - }, - Glyph { - code: 59, - width: 5, - rows: &F32_SEMICOLON, - }, - Glyph { - code: 35, - width: 20, - rows: &F32_HASH, - }, - Glyph { - code: 64, - width: 17, - rows: &F32_AT, - }, - Glyph { - code: 42, - width: 13, - rows: &F32_ASTERISK, - }, - Glyph { - code: 39, - width: 5, - rows: &F32_APOSTROPHE, - }, -]; diff --git a/apps/music-controller/src/rpc.rs b/apps/music-controller/src/rpc.rs deleted file mode 100644 index b7aa02f..0000000 --- a/apps/music-controller/src/rpc.rs +++ /dev/null @@ -1,244 +0,0 @@ -//! The dedicated Music Companion RPC, watch side. -//! -//! Requests are `M1Q id method args`; replies are `M1A id status index total record`. -//! The `M1` namespace is intentionally separate from FMC Companion's generic `R1` namespace, so both phone -//! apps can coexist without answering each other's requests. -//! -//! Playback state, music volume, the current title and artist, and optional album artwork may cross -//! the BLE channel. Album names and notification text remain phone-only. - -pub const MUSIC_SNAPSHOT: u8 = 0x60; -pub const MUSIC_COMMAND: u8 = 0x61; -pub const MUSIC_ARTWORK: u8 = 0x62; -pub const MUSIC_TRACK: u8 = 0x63; - -pub const OK: u8 = 0; -pub const BAD_REQUEST: u8 = 1; -pub const DENIED: u8 = 2; -pub const UNAVAILABLE: u8 = 3; -pub const ASK: u8 = 4; - -pub const RESPONSE_PLAYING: u8 = 1; -pub const RESPONSE_ACTIVE: u8 = 2; - -pub const PLAY: u8 = 0; -pub const PAUSE: u8 = 1; -pub const TOGGLE: u8 = 2; -pub const PREVIOUS: u8 = 3; -pub const NEXT: u8 = 4; -pub const VOLUME_UP: u8 = 5; -pub const VOLUME_DOWN: u8 = 6; -pub const SET_VOLUME: u8 = 7; - -/// A request that fits the app-message channel. The snapshot retains its original one-byte -/// argument for compatibility with Music Companion 0.1.x; its unsupported artwork and track -/// methods return `BAD_REQUEST` without affecting playback controls. -#[derive(Clone, Copy, PartialEq)] -#[cfg_attr(test, derive(Debug))] -pub enum Request { - Snapshot([u8; 6]), - Command([u8; 7]), - Artwork([u8; 17]), - Track([u8; 5]), -} - -impl Request { - pub fn bytes(&self) -> &[u8] { - match self { - Request::Snapshot(bytes) => bytes, - Request::Command(bytes) => bytes, - Request::Artwork(bytes) => bytes, - Request::Track(bytes) => bytes, - } - } -} - -/// Requests the current playback state. -pub fn snapshot_request(id: u8) -> Request { - Request::Snapshot([b'M', b'1', b'Q', id, MUSIC_SNAPSHOT, 0]) -} - -/// `music.command`; `value` is used only by `SET_VOLUME`. -pub fn command_request(id: u8, command: u8, value: u8) -> Request { - Request::Command([b'M', b'1', b'Q', id, MUSIC_COMMAND, command, value]) -} - -/// Requests artwork newer than `known_generation` (zero when the watch has no artwork). -/// The request and every reply are bounded by the app-message limits. -pub fn artwork_request(id: u8, nonce: u32, known_generation: u64) -> Request { - let mut bytes = [0_u8; 17]; - bytes[..5].copy_from_slice(&[b'M', b'1', b'Q', id, MUSIC_ARTWORK]); - bytes[5..9].copy_from_slice(&nonce.to_le_bytes()); - bytes[9..17].copy_from_slice(&known_generation.to_le_bytes()); - Request::Artwork(bytes) -} - -/// Requests the current title and artist. -pub fn track_request(id: u8) -> Request { - Request::Track([b'M', b'1', b'Q', id, MUSIC_TRACK]) -} - -#[derive(Clone, Copy, PartialEq)] -#[cfg_attr(test, derive(Debug))] -pub struct Reply<'a> { - pub id: u8, - pub status: u8, - pub index: u8, - pub total: u8, - pub record: &'a [u8], -} - -impl Reply<'_> { - /// Whether this reply has the empty result shape required for a command. - pub fn is_command_result(&self) -> bool { - self.index == 0 && self.total == 0 && self.record.is_empty() - } -} - -/// A reply on this channel; anything else is ignored. The loader caps records at 121 bytes; -/// the protocol never sends a larger record. -pub fn reply(message: &[u8]) -> Option> { - match message { - [b'M', b'1', b'A', id, status, index, total, record @ ..] - if *status <= ASK && record.len() <= 121 => - { - Some(Reply { - id: *id, - status: *status, - index: *index, - total: *total, - record, - }) - } - _ => None, - } -} - -/// Playback state from the snapshot record. -#[derive(Clone, Copy, PartialEq, Eq)] -#[cfg_attr(test, derive(Debug))] -pub struct Metadata { - pub flags: u8, - pub volume: u8, - pub max_volume: u8, -} - -impl Metadata { - pub const EMPTY: Metadata = Metadata { - flags: 0, - volume: 0, - max_volume: 0, - }; - - pub fn playing(&self) -> bool { - self.flags & RESPONSE_PLAYING != 0 - } - - pub fn active(&self) -> bool { - self.flags & RESPONSE_ACTIVE != 0 - } - - /// Whether two records contain exactly the same cache data. - pub fn same_data(&self, other: &Metadata) -> bool { - self.flags == other.flags - && self.volume == other.volume - && self.max_volume == other.max_volume - } - - /// Encodes the metadata record for the watch's local cache. - pub fn encode(&self, out: &mut [u8]) -> Option { - if out.len() < 4 { - return None; - } - out[0] = 0; - out[1] = self.flags; - out[2] = self.volume; - out[3] = self.max_volume; - Some(4) - } - - /// Decodes `0:u8 || flags || volume || max_volume`. - pub fn decode(record: &[u8]) -> Option { - if record.len() != 4 || record[0] != 0 { - return None; - } - let flags = record[1]; - if flags & !(RESPONSE_PLAYING | RESPONSE_ACTIVE) != 0 || record[2] > record[3] { - return None; - } - Some(Metadata { - flags, - volume: record[2], - max_volume: record[3], - }) - } -} - -#[cfg(test)] -mod tests { - use super::*; - - fn hex(s: &str) -> Vec { - (0..s.len()) - .step_by(2) - .map(|i| u8::from_str_radix(&s[i..i + 2], 16).unwrap()) - .collect() - } - - #[test] - fn metadata_vector_decodes() { - let metadata = Metadata::decode(&hex("0003070f")).unwrap(); - assert_eq!(metadata.flags, 3); - assert!(metadata.playing() && metadata.active()); - assert_eq!((metadata.volume, metadata.max_volume), (7, 15)); - } - - #[test] - fn malformed_metadata_is_rejected() { - // Wrong type, wrong length, unknown flag, and volume above maximum are all rejected. - assert!(Metadata::decode(&hex("0103070f")).is_none()); - assert!(Metadata::decode(&hex("000307")).is_none()); - assert!(Metadata::decode(&hex("0008070f")).is_none()); - assert!(Metadata::decode(&hex("00030f07")).is_none()); - } - - #[test] - fn requests_match_the_wire_layout() { - assert_eq!(snapshot_request(8).bytes(), &hex("4d3151086000")); - assert_eq!(command_request(10, NEXT, 0).bytes(), &hex("4d31510a610400")); - assert_eq!( - command_request(11, SET_VOLUME, 9).bytes(), - &hex("4d31510b610709") - ); - assert_eq!( - artwork_request(0x2a, 0x1234_5678, 0x0102_0304_0506_0708).bytes(), - &hex("4d31512a62785634120807060504030201") - ); - assert_eq!(track_request(0x2b).bytes(), &hex("4d31512b63")); - } - - #[test] - fn replies_are_parsed() { - let first_bytes = hex("4d314107000000"); - let first = reply(&first_bytes).unwrap(); - assert_eq!( - ( - first.id, - first.status, - first.index, - first.total, - first.record - ), - (7, OK, 0, 0, &[][..]) - ); - assert!(first.is_command_result()); - let second_bytes = hex("4d3141080000010003070f"); - let second = reply(&second_bytes).unwrap(); - assert_eq!(second.total, 1); - assert_eq!(second.record, &hex("0003070f")[..]); - assert!(!second.is_command_result()); - let invalid = hex("4d31510701"); - assert!(reply(&invalid).is_none()); - assert!(reply(&hex("52314105000000")).is_none()); - } -} diff --git a/apps/music-controller/src/track.rs b/apps/music-controller/src/track.rs deleted file mode 100644 index 8b83cf5..0000000 --- a/apps/music-controller/src/track.rs +++ /dev/null @@ -1,67 +0,0 @@ -//! Bounded track-title and artist records for the watch display. -//! -//! Text is intentionally restricted to printable ASCII and 60 bytes per field. The companion -//! performs the same restriction before transmission, and the watch validates it again because -//! every BLE message is untrusted. - -pub const TRACK_TOTAL: u8 = 2; -pub const TRACK_TEXT_MAX: usize = 60; - -pub const TITLE_KIND: u8 = 0; -pub const ARTIST_KIND: u8 = 1; - -#[derive(Clone, Copy, PartialEq, Eq)] -#[cfg_attr(test, derive(Debug))] -pub enum Field { - Title, - Artist, -} - -/// Decodes one title/artist record: `kind || length || printable ASCII bytes`. -pub fn decode(record: &[u8]) -> Option<(Field, &[u8])> { - if record.len() < 2 || record.len() > TRACK_TEXT_MAX + 2 { - return None; - } - let field = match record[0] { - TITLE_KIND => Field::Title, - ARTIST_KIND => Field::Artist, - _ => return None, - }; - let len = record[1] as usize; - if len > TRACK_TEXT_MAX || record.len() != len + 2 { - return None; - } - if record[2..].iter().any(|byte| !(0x20..=0x7e).contains(byte)) { - return None; - } - Some((field, &record[2..])) -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn title_and_artist_records_decode() { - assert_eq!( - decode(&[TITLE_KIND, 4, b'N', b'i', b't', b'e']), - Some((Field::Title, &b"Nite"[..])) - ); - assert_eq!( - decode(&[ARTIST_KIND, 3, b'M', b'8', b'3']), - Some((Field::Artist, &b"M83"[..])) - ); - } - - #[test] - fn malformed_text_records_are_rejected() { - assert!(decode(&[]).is_none()); - assert!(decode(&[TITLE_KIND]).is_none()); - assert!(decode(&[2, 0]).is_none()); - assert!(decode(&[TITLE_KIND, 2, b'A']).is_none()); - assert!(decode(&[TITLE_KIND, 1, 0x1f]).is_none()); - let mut too_long = vec![TITLE_KIND, 0x3f]; - too_long.extend_from_slice(&[b'A'; 60]); - assert!(decode(&too_long).is_none()); - } -} diff --git a/apps/music-controller/src/view.rs b/apps/music-controller/src/view.rs deleted file mode 100644 index d2305bc..0000000 --- a/apps/music-controller/src/view.rs +++ /dev/null @@ -1,550 +0,0 @@ -//! The full-screen watch face: artwork, large bordered transport controls and volume. -//! -//! The current track title, artist, and a low-resolution copy of the matching notification artwork -//! can be displayed on the watch. These values stay in RAM; albums and notification text stay on -//! the phone. - -use crate::model::{Model, Status}; -use crate::ntype82::{self, FontSize}; -use cmf_wp2_ui::color::Rgb; -use cmf_wp2_ui::{Surface, C, SIZE}; - -const BLACK: u16 = Rgb(0, 0, 0).rgb565(); -const WHITE: u16 = Rgb(255, 255, 255).rgb565(); -const GREY: u16 = Rgb(140, 140, 140).rgb565(); -const DIM: u16 = Rgb(82, 82, 82).rgb565(); -const ACCENT: u16 = Rgb(250, 35, 0).rgb565(); -const RED: u16 = Rgb(210, 20, 20).rgb565(); -const PANEL: u16 = Rgb(18, 18, 18).rgb565(); - -const ART_X: i32 = 169; -const ART_Y: i32 = 16; -const ART_SIZE: i32 = 128; -const ART_SOURCE_SIZE: i32 = 64; - -const TITLE_Y: i32 = 149; -const ARTIST_Y: i32 = 175; -const PERMISSION_TITLE_Y: i32 = 155; -const FOOTER_Y: i32 = 414; - -const PREV_X: i32 = 95; -const PLAY_X: i32 = 233; -const NEXT_X: i32 = 371; -const CONTROL_Y: i32 = 270; -const PREV_R: i32 = 44; -const PLAY_R: i32 = 64; -const NEXT_R: i32 = 44; - -const VOLUME_X: i32 = 112; -const VOLUME_Y: i32 = 346; -const VOLUME_W: i32 = 242; -const VOLUME_H: i32 = 32; -const MINUS_X: i32 = 54; -const PLUS_X: i32 = 364; -const BUTTON_Y: i32 = 338; -const BUTTON_SIZE: i32 = 48; - -/// Artwork supplied by the protocol layer. All coordinates are source pixels in the 64×64 image. -pub trait ArtworkSource { - /// Whether a complete image may currently be displayed. - fn visible(&self) -> bool; - - /// The committed image generation, or zero when there is no image. - fn generation(&self) -> u64; - - /// The RGB565 colour at one source pixel. - fn pixel(&self, x: u8, y: u8) -> Option; -} - -impl ArtworkSource for Model { - fn visible(&self) -> bool { - self.artwork_visible() - } - - fn generation(&self) -> u64 { - self.artwork_generation() - } - - fn pixel(&self, x: u8, y: u8) -> Option { - self.artwork_pixel(x, y) - } -} - -/// What a tap in the transport row should do. -#[derive(Clone, Copy, PartialEq, Eq)] -#[cfg_attr(test, derive(Debug))] -pub enum Action { - Previous, - Toggle, - Next, - VolumeUp, - VolumeDown, - SetVolume(u8), - None, -} - -/// Maps a touch to a playback or volume action. -pub fn action( - x: i32, - y: i32, - max_volume: u8, - controls_enabled: bool, - volume_enabled: bool, -) -> Action { - if !controls_enabled { - return Action::None; - } - - if hit_circle(x, y, PLAY_X, CONTROL_Y, PLAY_R) { - return Action::Toggle; - } - if hit_circle(x, y, PREV_X, CONTROL_Y, PREV_R) { - return Action::Previous; - } - if hit_circle(x, y, NEXT_X, CONTROL_Y, NEXT_R) { - return Action::Next; - } - - if volume_enabled { - if in_rect(x, y, MINUS_X, BUTTON_Y, BUTTON_SIZE, BUTTON_SIZE) { - return Action::VolumeDown; - } - if in_rect(x, y, PLUS_X, BUTTON_Y, BUTTON_SIZE, BUTTON_SIZE) { - return Action::VolumeUp; - } - if in_rect(x, y, VOLUME_X, VOLUME_Y, VOLUME_W, VOLUME_H) { - let offset = (x - VOLUME_X).clamp(0, VOLUME_W - 1); - let value = (offset * max_volume as i32 + (VOLUME_W - 1) / 2) / (VOLUME_W - 1); - return Action::SetVolume(value.clamp(0, max_volume as i32) as u8); - } - } - - Action::None -} - -pub fn frame(s: &mut impl Surface, m: &Model) { - frame_with_artwork(s, m, m); -} - -fn frame_with_artwork(s: &mut impl Surface, m: &Model, artwork: &impl ArtworkSource) { - s.rect(0, 0, SIZE, SIZE, BLACK); - - let active = m.active(); - draw_artwork(s, artwork, active); - - if !m.has_snapshot && matches!(m.status, Status::Ask | Status::Denied) { - draw_permission(s, m.status); - draw_footer(s, m); - return; - } - - draw_track_text(s, m); - - let controls_enabled = m.controls_enabled(); - draw_transport(s, m.playing(), controls_enabled); - draw_volume(s, m.volume(), m.max_volume(), m.volume_enabled()); - draw_footer(s, m); -} - -/// Draws the committed artwork, or a deliberately generic placeholder. -fn draw_artwork(s: &mut impl Surface, artwork: &impl ArtworkSource, active: bool) { - let border = if active { ACCENT } else { DIM }; - let has_artwork = artwork.visible() && artwork.generation() != 0; - - if has_artwork { - for source_y in 0..ART_SOURCE_SIZE { - let mut source_x = 0; - while source_x < ART_SOURCE_SIZE { - let Some(colour) = artwork.pixel(source_x as u8, source_y as u8) else { - source_x += 1; - continue; - }; - let start = source_x; - while source_x < ART_SOURCE_SIZE - && artwork.pixel(source_x as u8, source_y as u8) == Some(colour) - { - source_x += 1; - } - s.rect( - ART_X + start * 2, - ART_Y + source_y * 2, - (source_x - start) * 2, - 2, - colour, - ); - } - } - } else { - draw_artwork_placeholder(s, active); - } - - s.rect(ART_X - 2, ART_Y - 2, ART_SIZE + 4, 2, border); - s.rect(ART_X - 2, ART_Y + ART_SIZE, ART_SIZE + 4, 2, border); - s.rect(ART_X - 2, ART_Y, 2, ART_SIZE, border); - s.rect(ART_X + ART_SIZE, ART_Y, 2, ART_SIZE, border); -} - -fn draw_artwork_placeholder(s: &mut impl Surface, active: bool) { - s.rect(ART_X, ART_Y, ART_SIZE, ART_SIZE, PANEL); - let colour = if active { ACCENT } else { DIM }; - let fill = if active { - Rgb(250, 35, 0) - } else { - Rgb(82, 82, 82) - }; - - // Two large notes centred in the cover well. - s.rect(ART_X + 40, ART_Y + 28, 6, 58, colour); - s.rect(ART_X + 96, ART_Y + 18, 6, 68, colour); - s.rect(ART_X + 46, ART_Y + 28, 50, 6, colour); - s.rect(ART_X + 102, ART_Y + 18, 20, 6, colour); - cmf_wp2_ui::draw::disc(s, ART_X + 37, ART_Y + 86, 13, fill, Rgb(18, 18, 18)); - cmf_wp2_ui::draw::disc(s, ART_X + 93, ART_Y + 86, 13, fill, Rgb(18, 18, 18)); -} - -fn draw_track_text(s: &mut impl Surface, m: &Model) { - if !m.active() { - ntype82::centre(s, C, TITLE_Y + 7, "NO MEDIA", GREY, FontSize::Large); - return; - } - - let title = m.track_title(); - let title = if title.is_empty() { - "UNKNOWN TRACK" - } else { - title - }; - ntype82::centre_clipped(s, C, TITLE_Y, title, 244, WHITE, FontSize::Small); - - let artist = m.track_artist(); - if !artist.is_empty() { - ntype82::centre_clipped(s, C, ARTIST_Y, artist, 244, GREY, FontSize::Small); - } -} - -fn draw_transport(s: &mut impl Surface, playing: bool, enabled: bool) { - let secondary = if enabled { WHITE } else { DIM }; - let accent = if enabled { ACCENT } else { DIM }; - - disc_button(s, PREV_X, CONTROL_Y, PREV_R, secondary); - disc_button(s, PLAY_X, CONTROL_Y, PLAY_R, accent); - disc_button(s, NEXT_X, CONTROL_Y, NEXT_R, secondary); - - // Previous: a vertical bar at the left and a triangle whose point faces left. - s.rect(PREV_X - 17, CONTROL_Y - 15, 7, 30, secondary); - triangle_left(s, PREV_X + 14, CONTROL_Y, 20, 20, secondary); - - // Next: a triangle whose point faces right and a vertical bar at the right. - triangle_right(s, NEXT_X - 14, CONTROL_Y, 20, 20, secondary); - s.rect(NEXT_X + 10, CONTROL_Y - 15, 7, 30, secondary); - - if playing { - s.rect(PLAY_X - 17, CONTROL_Y - 18, 9, 36, accent); - s.rect(PLAY_X + 8, CONTROL_Y - 18, 9, 36, accent); - } else { - triangle_right(s, PLAY_X - 22, CONTROL_Y, 23, 24, accent); - } -} - -fn disc_button(s: &mut impl Surface, cx: i32, cy: i32, radius: i32, colour: u16) { - cmf_wp2_ui::draw::disc(s, cx, cy, radius, Rgb::from565(colour), Rgb(0, 0, 0)); - cmf_wp2_ui::draw::disc(s, cx, cy, radius - 5, Rgb(0, 0, 0), Rgb(0, 0, 0)); -} - -/// Draws a solid left-pointing triangle with its point at `x - half_width`. -fn triangle_left( - s: &mut impl Surface, - x: i32, - y: i32, - half_width: i32, - half_height: i32, - colour: u16, -) { - for row in 0..=half_height { - let width = half_width - row; - if width > 0 { - s.rect(x - width, y - row, width, 1, colour); - s.rect(x - width, y + row, width, 1, colour); - } - } -} - -/// Draws a solid right-pointing triangle with its point at `x + half_width - 1`. -fn triangle_right( - s: &mut impl Surface, - x: i32, - y: i32, - half_width: i32, - half_height: i32, - colour: u16, -) { - for row in 0..=half_height { - let width = half_width - row; - if width > 0 { - s.rect(x, y - row, width, 1, colour); - s.rect(x, y + row, width, 1, colour); - } - } -} - -fn draw_volume(s: &mut impl Surface, value: u8, max: u8, enabled: bool) { - let border = if enabled { WHITE } else { DIM }; - rounded_button(s, MINUS_X, BUTTON_Y, BUTTON_SIZE, BUTTON_SIZE, border); - rounded_button(s, PLUS_X, BUTTON_Y, BUTTON_SIZE, BUTTON_SIZE, border); - - s.rect(MINUS_X + 11, BUTTON_Y + 22, 26, 4, border); - s.rect(PLUS_X + 11, BUTTON_Y + 22, 26, 4, border); - s.rect(PLUS_X + 22, BUTTON_Y + 11, 4, 26, border); - - cmf_wp2_ui::draw::rrect( - s, - VOLUME_X, - VOLUME_Y, - VOLUME_W, - VOLUME_H, - 16, - Rgb::from565(GREY), - Rgb(0, 0, 0), - ); - cmf_wp2_ui::draw::rrect( - s, - VOLUME_X + 4, - VOLUME_Y + 4, - VOLUME_W - 8, - VOLUME_H - 8, - 12, - Rgb(0, 0, 0), - Rgb(0, 0, 0), - ); - - if max > 0 { - let width = - ((value.min(max) as i32 * (VOLUME_W - 10)) / max as i32).clamp(0, VOLUME_W - 10); - cmf_wp2_ui::draw::rrect( - s, - VOLUME_X + 5, - VOLUME_Y + 5, - width, - VOLUME_H - 10, - 10, - Rgb::from565(ACCENT), - Rgb(0, 0, 0), - ); - } - - let mut percent = crate::model::Buf::<8>::new(); - crate::model::percent(&mut percent, value, max); - ntype82::centre( - s, - C, - VOLUME_Y + 4, - percent.as_str(), - if enabled { WHITE } else { DIM }, - FontSize::Small, - ); -} - -fn rounded_button(s: &mut impl Surface, x: i32, y: i32, w: i32, h: i32, colour: u16) { - cmf_wp2_ui::draw::rrect(s, x, y, w, h, 12, Rgb::from565(colour), Rgb(0, 0, 0)); - cmf_wp2_ui::draw::rrect(s, x + 4, y + 4, w - 8, h - 8, 8, Rgb(0, 0, 0), Rgb(0, 0, 0)); -} - -fn draw_permission(s: &mut impl Surface, status: Status) { - let (title, line1, line2, colour) = match status { - Status::Ask => ("ALLOW", "ALLOW ON PHONE", "MUSIC COMPANION", ACCENT), - _ => ("ACCESS DENIED", "OPEN MUSIC", "TURN IT ON", RED), - }; - ntype82::centre(s, C, PERMISSION_TITLE_Y, title, colour, FontSize::Large); - - cmf_wp2_ui::draw::rrect( - s, - 102, - 207, - 262, - 116, - 16, - Rgb::from565(colour), - Rgb(0, 0, 0), - ); - cmf_wp2_ui::draw::rrect(s, 106, 211, 254, 108, 12, Rgb(0, 0, 0), Rgb(0, 0, 0)); - ntype82::centre(s, C, 228, line1, WHITE, FontSize::Small); - ntype82::centre(s, C, 260, line2, GREY, FontSize::Small); -} - -fn draw_footer(s: &mut impl Surface, m: &Model) { - let (footer, colour) = match m.status { - Status::Ask => ("SETUP", ACCENT), - Status::Denied => ("DENIED", RED), - Status::Unavailable => ("NO PHONE", ACCENT), - Status::Silent if m.has_snapshot => ("CACHED", ACCENT), - Status::Silent => ("NO PHONE", ACCENT), - Status::Waiting => ("WAITING", DIM), - Status::Ok if !m.active() => ("NO MEDIA / PHONE OK", DIM), - Status::Ok => ( - if m.playing() { - "PLAYING / PHONE OK" - } else { - "PAUSED / PHONE OK" - }, - DIM, - ), - }; - ntype82::centre_clipped(s, C, FOOTER_Y, footer, 276, colour, FontSize::Small); -} - -fn hit_circle(x: i32, y: i32, cx: i32, cy: i32, radius: i32) -> bool { - let dx = x - cx; - let dy = y - cy; - dx * dx + dy * dy <= radius * radius -} - -fn in_rect(x: i32, y: i32, left: i32, top: i32, width: i32, height: i32) -> bool { - (left..left + width).contains(&x) && (top..top + height).contains(&y) -} - -#[cfg(test)] -mod tests { - use super::*; - use crate::model::Model; - use cmf_wp2_ui::Fb; - - struct FakeArtwork { - visible: bool, - generation: u64, - } - - impl ArtworkSource for FakeArtwork { - fn visible(&self) -> bool { - self.visible - } - - fn generation(&self) -> u64 { - self.generation - } - - fn pixel(&self, x: u8, y: u8) -> Option { - if !self.visible { - return None; - } - Some(if x == 0 && y == 0 { ACCENT } else { WHITE }) - } - } - - fn no_artwork() -> FakeArtwork { - FakeArtwork { - visible: false, - generation: 0, - } - } - - #[test] - fn every_state_draws_inside_the_circle() { - let mut px = vec![0u16; (SIZE * SIZE) as usize]; - let mut fb = Fb::new(&mut px); - let mut m = Model::new(); - for status in [ - Status::Waiting, - Status::Ok, - Status::Ask, - Status::Denied, - Status::Unavailable, - Status::Silent, - ] { - m.status = status; - frame_with_artwork(&mut fb, &m, &no_artwork()); - } - for y in 0..SIZE { - for x in 0..SIZE { - let (dx, dy) = (x - C, y - C); - if dx * dx + dy * dy > (C - 2) * (C - 2) { - assert_eq!(fb.at(x, y), 0, "{x},{y}"); - } - } - } - } - - #[test] - fn controls_have_large_distinct_touch_targets() { - assert!(PLAY_R * 2 >= 120); - assert!(PREV_R * 2 >= 88); - assert!(NEXT_R * 2 >= 88); - assert!(BUTTON_SIZE * 2 >= 88); - - assert_eq!(action(PREV_X, CONTROL_Y, 15, true, true), Action::Previous); - assert_eq!(action(PLAY_X, CONTROL_Y, 15, true, true), Action::Toggle); - assert_eq!(action(NEXT_X, CONTROL_Y, 15, true, true), Action::Next); - assert_eq!( - action(MINUS_X + 1, BUTTON_Y + 1, 15, true, true), - Action::VolumeDown - ); - assert_eq!( - action(PLUS_X + 1, BUTTON_Y + 1, 15, true, true), - Action::VolumeUp - ); - assert_eq!( - action(VOLUME_X, VOLUME_Y + 16, 15, true, true), - Action::SetVolume(0) - ); - assert_eq!( - action(VOLUME_X + VOLUME_W - 1, VOLUME_Y + 16, 15, true, true), - Action::SetVolume(15) - ); - } - - #[test] - fn control_regions_do_not_overlap() { - assert!(PREV_X + PREV_R < PLAY_X - PLAY_R); - assert!(PLAY_X + PLAY_R < NEXT_X - NEXT_R); - assert!(CONTROL_Y + PLAY_R < BUTTON_Y); - assert!(MINUS_X + BUTTON_SIZE < VOLUME_X); - assert!(VOLUME_X + VOLUME_W < PLUS_X); - } - - #[test] - fn disabled_controls_do_not_queue_commands() { - assert_eq!(action(PLAY_X, CONTROL_Y, 15, false, false), Action::None); - assert_eq!( - action(VOLUME_X, VOLUME_Y + 16, 15, true, false), - Action::None - ); - assert_eq!( - action(VOLUME_X, VOLUME_Y + 16, 0, true, false), - Action::None - ); - } - - #[test] - fn artwork_is_scaled_to_the_cover_tile() { - let mut px = vec![0u16; (SIZE * SIZE) as usize]; - let mut fb = Fb::new(&mut px); - let mut m = Model::new(); - m.metadata.flags = 3; - m.status = Status::Ok; - let artwork = FakeArtwork { - visible: true, - generation: 42, - }; - frame_with_artwork(&mut fb, &m, &artwork); - assert_eq!(fb.at(ART_X, ART_Y), ACCENT); - assert_eq!(fb.at(ART_X + 1, ART_Y + 1), ACCENT); - assert_eq!(fb.at(ART_X + ART_SIZE - 1, ART_Y + ART_SIZE - 1), WHITE); - } - - #[test] - fn uploaded_font_fits_the_visible_labels() { - for text in [ - "PLAYING", - "PAUSED", - "NO MEDIA", - "ACCESS DENIED", - "ALLOW ON PHONE", - "MUSIC COMPANION", - "PHONE OK", - "NO PHONE", - "100%", - ] { - assert!(ntype82::width(FontSize::Small, text) <= 250, "{text}"); - } - assert!(ntype82::width(FontSize::Large, "ACCESS DENIED") <= 250); - } -} diff --git a/apps/music-controller/store.md b/apps/music-controller/store.md deleted file mode 100644 index 827cb16..0000000 --- a/apps/music-controller/store.md +++ /dev/null @@ -1,8 +0,0 @@ -Show the current song, artist, and notification artwork on the watch, then control playback and the phone's music-stream volume from large full-screen controls. - -The standalone Android **Music Companion** app sends the current title, artist, and a low-resolution copy of the matching notification artwork to the watch. Album names and notification text stay on the phone. The watch keeps the transferred values in memory only and hides stale artwork while a replacement transfers. The watch's Bluetooth channel is not private: a nearby client that knows the watch pairing key can observe the transferred song information and artwork and can inject messages into the watch-facing channel. - -## Requirements - -- The [patched firmware](/firmware) with the channel key and the [App Loader](/firmware). -- The standalone [Android Music Companion](https://github.com/boxmol71-gif/music-companion) app. [Download the v0.2.0 companion APK](https://github.com/boxmol71-gif/music-companion/releases/download/v0.2.0/MusicCompanion-0.2.0-debug.apk), then enable its watch bridge and grant notification-listener access. Music Companion 0.1.1 remains a compatibility fallback, but it cannot show track text or artwork. diff --git a/apps/music-controller/store.toml b/apps/music-controller/store.toml deleted file mode 100644 index 707d8e8..0000000 --- a/apps/music-controller/store.toml +++ /dev/null @@ -1,5 +0,0 @@ -name = "Music Controller" -summary = "Track artwork, details, and music controls" -version = "0.2.0" -author = "CMF Tech Community" -screenshots = ["shots/playing.png", "shots/waiting.png"] diff --git a/apps/orbit/Cargo.toml b/apps/orbit/Cargo.toml deleted file mode 100644 index fb0e41e..0000000 --- a/apps/orbit/Cargo.toml +++ /dev/null @@ -1,13 +0,0 @@ -[package] -name = "orbit" -edition.workspace = true -license.workspace = true -version.workspace = true - -[dependencies] -cmf-wp2-app.workspace = true -cmf-wp2-ui.workspace = true - -[[bin]] -name = "orbit" -bench = false diff --git a/apps/orbit/icon.svg b/apps/orbit/icon.svg deleted file mode 100644 index 7829a99..0000000 --- a/apps/orbit/icon.svg +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/apps/orbit/shots/over.png b/apps/orbit/shots/over.png deleted file mode 100644 index 4179d03..0000000 Binary files a/apps/orbit/shots/over.png and /dev/null differ diff --git a/apps/orbit/shots/playing.png b/apps/orbit/shots/playing.png deleted file mode 100644 index b6433a3..0000000 Binary files a/apps/orbit/shots/playing.png and /dev/null differ diff --git a/apps/orbit/shots/ready.png b/apps/orbit/shots/ready.png deleted file mode 100644 index f1b26c0..0000000 Binary files a/apps/orbit/shots/ready.png and /dev/null differ diff --git a/apps/orbit/src/game.rs b/apps/orbit/src/game.rs deleted file mode 100644 index 48b2999..0000000 --- a/apps/orbit/src/game.rs +++ /dev/null @@ -1,374 +0,0 @@ -// The game itself: no Api, so `cargo test` runs it on the host. Fixed point only (the watch has no FPU): the ball's -// position and speed are in 1/256 px, angles in u16 turns (65536 = a full turn, 0 = 3 o'clock, clockwise, as the -// kit's `arc` and `angle` use them). One `step` is one 33 ms tick. - -use cmf_wp2_ui::motion::{angle, cos, isqrt, sin}; - -/// Screen size and centre; the panel is a disc of radius `C`. -pub const SIZE: i32 = 466; -pub const C: i32 = SIZE / 2; - -/// Fixed-point one for the ball's position and speed. -pub const Q: i32 = 256; -/// The ball's radius, px. -pub const BALL_R: i32 = 10; -/// The rail the paddle rides on: a ring from `RAIL_R0` to `RAIL_R1` px from the centre. The ball bounces off its -/// inner edge where the paddle is, and flies through it everywhere else. -pub const RAIL_R0: i32 = 200; -pub const RAIL_R1: i32 = 214; -/// The run ends once the ball is this far out: past the screen's edge, so you see it go. -pub const OUT_R: i32 = C + BALL_R + 4; - -/// Ball speed per tick (Q): the first serve, the gain per point and the cap. -pub const SPEED0: i32 = 4 * Q; -pub const SPEED_STEP: i32 = 48; -pub const SPEED_MAX: i32 = 10 * Q; - -/// The paddle's length in turns: about 51° at the start, 110/65536 shorter per point, never under 30°. -pub const SPAN0: i32 = 65536 / 7; -pub const SPAN_STEP: i32 = 110; -pub const SPAN_MIN: i32 = 65536 / 12; - -/// One crown detent moves the paddle by 8°. -pub const CROWN_STEP: i32 = 1456; -/// A tap sends the paddle toward the tapped side at 4° a tick. Taps this close to the centre don't steer. -pub const STEER: i32 = 728; -pub const STEER_DEAD: i32 = 60; - -/// Where on the paddle the ball lands tilts the bounce by up to 30°; the bounce never leaves more than 60° off -/// the line through the centre, so the ball can't skim round the rail forever. -pub const ENGLISH: i32 = 5461; -pub const MAX_TILT: i32 = 10923; -/// The ball's own half-width as an angle at the rail, so a ball that clips the paddle's end still counts. -const BALL_ANGLE: i32 = (BALL_R * 65536) / (RAIL_R0 * 314 / 50); - -/// The paddle starts at 6 o'clock. -pub const HOME: u16 = 16384; - -/// Ready: the ball waits in the middle for a tap. Over: the ball got out, the screen holds still. -#[derive(Clone, Copy, PartialEq, Eq, Debug)] -pub enum State { - Ready, - Playing, - Over, -} - -#[derive(Clone, Copy, PartialEq, Eq, Debug)] -pub enum Step { - Nothing, - Scored, - Crashed, -} - -#[derive(Clone)] -pub struct Game { - pub state: State, - /// The ball's centre relative to the screen's centre, Q. - pub x: i32, - pub y: i32, - /// Its velocity per tick, Q. - pub vx: i32, - pub vy: i32, - pub speed: i32, - /// The paddle's centre, turns. - pub paddle: u16, - /// Where a tap asked the paddle to go. - pub target: Option, - pub score: u32, - /// The ball went past the paddle: no more bounces this run. - missed: bool, - rng: u32, -} - -/// xorshift32: no random source on the watch, the app seeds it from the clock. -fn next(rng: &mut u32) -> u32 { - let mut x = *rng; - x ^= x << 13; - x ^= x >> 17; - x ^= x << 5; - *rng = x; - x -} - -/// `a - b` as a signed angle, -32768..=32767. -pub fn diff(a: u16, b: u16) -> i32 { - a.wrapping_sub(b) as i16 as i32 -} - -impl Game { - pub fn new(seed: u32) -> Game { - let mut g = Game { - state: State::Ready, - x: 0, - y: 0, - vx: 0, - vy: 0, - speed: SPEED0, - paddle: HOME, - target: None, - score: 0, - missed: false, - rng: seed | 1, // xorshift sticks at 0 - }; - g.restart(); - g - } - - /// Back to Ready with the ball in the middle, keeping the random sequence going. - pub fn restart(&mut self) { - self.state = State::Ready; - (self.x, self.y, self.vx, self.vy) = (0, 0, 0, 0); - self.speed = SPEED0; - self.paddle = HOME; - self.target = None; - self.score = 0; - self.missed = false; - } - - /// Serve: the ball leaves the centre in a random direction. - pub fn launch(&mut self) { - if self.state != State::Ready { - return; - } - self.state = State::Playing; - let a = next(&mut self.rng) as u16; - self.aim(a); - } - - fn aim(&mut self, a: u16) { - self.vx = (self.speed * cos(a)) >> 14; - self.vy = (self.speed * sin(a)) >> 14; - } - - /// The paddle's length now, turns. - pub fn span(&self) -> i32 { - (SPAN0 - SPAN_STEP * self.score.min(1000) as i32).max(SPAN_MIN) - } - - /// The ball's centre on screen, px. - pub fn ball(&self) -> (i32, i32) { - (C + ((self.x + Q / 2) >> 8), C + ((self.y + Q / 2) >> 8)) - } - - /// The ball's distance from the centre, 1/16 px. - pub fn dist16(&self) -> i32 { - let (x, y) = (self.x >> 4, self.y >> 4); - isqrt(x * x + y * y) - } - - /// A crown detent: +1 moves the paddle clockwise. It overrides a tap that is still steering. - pub fn crown(&mut self, delta: i16) { - self.paddle = self.paddle.wrapping_add((delta as i32 * CROWN_STEP) as u16); - self.target = None; - } - - /// A tap at screen point (x, y) while playing: the paddle heads for that side of the ring. - pub fn steer(&mut self, x: i32, y: i32) { - let (dx, dy) = (x - C, y - C); - if dx * dx + dy * dy >= STEER_DEAD * STEER_DEAD { - self.target = Some(angle(dx, dy)); - } - } - - pub fn step(&mut self) -> Step { - if self.state != State::Playing { - return Step::Nothing; - } - if let Some(t) = self.target { - let d = diff(t, self.paddle); - if d.abs() <= STEER { - self.paddle = t; - self.target = None; - } else { - self.paddle = self.paddle.wrapping_add((d.signum() * STEER) as u16); - } - } - self.x += self.vx; - self.y += self.vy; - let d = self.dist16(); - let outward = (self.x >> 4) * self.vx + (self.y >> 4) * self.vy > 0; - if !self.missed && outward && d + BALL_R * 16 >= RAIL_R0 * 16 { - let at = angle(self.x >> 4, self.y >> 4); - let off = diff(at, self.paddle); - let half = self.span() / 2; - if off.abs() > half + BALL_ANGLE { - self.missed = true; - } else { - // Mirror the incoming direction about the radius, then tilt it by where it hit the paddle. - let phi = diff(angle(self.vx, self.vy), at); - let english = (off * ENGLISH / half).clamp(-ENGLISH, ENGLISH); - let tilt = (english - phi).clamp(-MAX_TILT, MAX_TILT); - self.score += 1; - self.speed = (self.speed + SPEED_STEP).min(SPEED_MAX); - self.aim(at.wrapping_add(32768).wrapping_add(tilt as u16)); - // Put the ball back against the rail so it can't hit twice. - let r = (RAIL_R0 - BALL_R) * 16; - if d > r { - self.x = self.x * r / d; - self.y = self.y * r / d; - } - return Step::Scored; - } - } - if d > OUT_R * 16 { - self.state = State::Over; - return Step::Crashed; - } - Step::Nothing - } -} - -/// The best score as the storage blob: "OB1" and a u32, little endian. -pub fn encode(best: u32) -> [u8; 7] { - let b = best.to_le_bytes(); - [b'O', b'B', b'1', b[0], b[1], b[2], b[3]] -} - -/// A blob that isn't ours reads as no best score yet. -pub fn decode(blob: &[u8]) -> u32 { - match blob { - [b'O', b'B', b'1', a, b, c, d] => u32::from_le_bytes([*a, *b, *c, *d]), - _ => 0, - } -} - -#[cfg(test)] -mod tests { - use super::*; - - fn playing(seed: u32) -> Game { - let mut g = Game::new(seed); - g.launch(); - g - } - - #[test] - fn serve_leaves_the_centre_at_the_start_speed() { - for seed in 1..50 { - let g = playing(seed); - assert_eq!(g.state, State::Playing); - let v = isqrt(g.vx * g.vx + g.vy * g.vy); - assert!((v - SPEED0).abs() <= 2, "speed {v}"); - } - } - - #[test] - fn crown_moves_and_wraps() { - let mut g = Game::new(7); - g.crown(1); - assert_eq!(g.paddle, HOME + CROWN_STEP as u16); - g.paddle = 100; - g.crown(-1); - assert_eq!(g.paddle, 100u16.wrapping_sub(CROWN_STEP as u16)); - } - - #[test] - fn tap_steers_the_short_way_and_crown_cancels_it() { - let mut g = playing(3); - g.paddle = 0; // 3 o'clock - g.steer(C, C - 150); // 12 o'clock: counter-clockwise is shorter - g.step(); - assert_eq!(g.paddle, 0u16.wrapping_sub(STEER as u16)); - g.steer(C + 10, C); // the dead zone in the middle doesn't change the target - assert_eq!(g.target, Some(49152)); - g.crown(1); - assert_eq!(g.target, None); - } - - #[test] - fn steering_arrives_and_stops() { - let mut g = playing(3); - g.paddle = 0; - g.steer(C - 150, C); // 9 o'clock - for _ in 0..60 { - g.step(); - if g.state != State::Playing { - break; - } - } - assert_eq!(g.paddle, 32768); - assert_eq!(g.target, None); - } - - #[test] - fn a_hit_scores_speeds_up_and_sends_the_ball_inward() { - let mut g = playing(11); - let mut hits = 0; - for _ in 0..400 { - g.paddle = angle(g.x >> 4, g.y >> 4); // a perfect player - let before = g.speed; - if g.step() == Step::Scored { - hits += 1; - assert_eq!(g.speed, before + SPEED_STEP); - assert!((g.x >> 4) * g.vx + (g.y >> 4) * g.vy < 0, "bounce goes back in"); - assert!(g.dist16() <= (RAIL_R0 - BALL_R) * 16); - } - } - assert!(hits >= 3, "{hits} hits"); - assert_eq!(g.score, hits); - } - - #[test] - fn missing_ends_the_run_once() { - let mut g = playing(5); - let mut crashed = 0; - for _ in 0..300 { - g.paddle = angle(g.x >> 4, g.y >> 4).wrapping_add(32768); // always on the wrong side - if g.step() == Step::Crashed { - crashed += 1; - } - } - assert_eq!((crashed, g.state, g.score), (1, State::Over, 0)); - assert_eq!(g.step(), Step::Nothing); - } - - #[test] - fn the_paddle_end_still_counts() { - let mut g = playing(9); - // Sit the paddle so the ball meets it just inside its end. - for _ in 0..200 { - let at = angle(g.x >> 4, g.y >> 4); - g.paddle = at.wrapping_add((g.span() / 2 + BALL_ANGLE - 200) as u16); - if g.step() == Step::Scored { - return; - } - assert_eq!(g.state, State::Playing); - } - panic!("never reached the rail"); - } - - #[test] - fn autopilot_runs_long_and_it_gets_harder() { - for seed in [1, 42, 999, 123_456] { - let mut g = playing(seed); - for _ in 0..5000 { - g.paddle = angle(g.x >> 4, g.y >> 4); - g.step(); - assert_eq!(g.state, State::Playing, "seed {seed}"); - assert!(g.dist16() <= (RAIL_R0 - BALL_R) * 16 + SPEED_MAX / 16 + 16); - } - assert!(g.score > 60, "seed {seed}: {}", g.score); - assert_eq!(g.speed, SPEED_MAX); - assert_eq!(g.span(), SPAN_MIN); - } - } - - #[test] - fn restart_keeps_the_dice_rolling() { - let mut g = playing(77); - let first = (g.vx, g.vy); - g.restart(); - assert_eq!((g.state, g.score, g.ball()), (State::Ready, 0, (C, C))); - g.launch(); - assert_ne!((g.vx, g.vy), first); - } - - #[test] - fn best_score_blob() { - assert_eq!(decode(&encode(0)), 0); - assert_eq!(decode(&encode(1234)), 1234); - assert_eq!(decode(b"H1xxxxx"), 0); - assert_eq!(decode(b"OB1"), 0); - assert_eq!(decode(&[]), 0); - } -} diff --git a/apps/orbit/src/main.rs b/apps/orbit/src/main.rs deleted file mode 100644 index eda6a5e..0000000 --- a/apps/orbit/src/main.rs +++ /dev/null @@ -1,141 +0,0 @@ -#![cfg_attr(any(target_os = "none", wp2_sim), no_main, cfg_attr(target_os = "none", no_std))] - -#[cfg_attr(not(any(target_os = "none", wp2_sim)), allow(dead_code))] -mod game; -#[cfg_attr(not(any(target_os = "none", wp2_sim)), allow(dead_code))] -mod view; - -#[cfg(not(any(target_os = "none", wp2_sim)))] -fn main() {} - -#[cfg(any(target_os = "none", wp2_sim))] -mod device { - use crate::game::{Game, State, Step, decode, encode}; - use crate::view::frame; - use cmf_wp2_app::{Api, BUTTON, CROWN, PAUSE, RESUME, TOUCH_DOWN}; - use cmf_wp2_ui::haptic::{DONE, Motor, TICK}; - - cmf_wp2_app::entry!(main); - cmf_wp2_app::app_icon!(); - - /// One game tick. - const FRAME_MS: u32 = 33; - /// After a slow frame, catch up at most this many ticks; beyond that the game slows down instead of jumping. - const CATCH_UP: u32 = 3; - /// Taps right after a miss don't restart: they were meant for the run that just ended. - const RETRY_MS: u32 = 700; - - fn due(now: u32, at: u32) -> bool { - (now.wrapping_sub(at) as i32) >= 0 - } - - // true on RESUME, false on BUTTON - fn paused(api: &Api) -> bool { - loop { - match api.event(u32::MAX).map(|e| e.kind) { - Some(RESUME) => return true, - Some(BUTTON) => return false, - _ => {} - } - } - } - - fn seed(api: &Api) -> u32 { - let t = api.time().map_or(0, |t| (t.minute as u32 * 60 + t.second as u32) * 1000 + t.millis as u32); - api.now().wrapping_mul(2_654_435_761) ^ t - } - - fn main(api: &'static Api) -> i32 { - let mut screen = api; - let mut motor = Motor::new(api); // dropped on return: the motor goes off - let mut blob = [0u8; 16]; - let n = api.load(&mut blob); - let mut best = if n > 0 { decode(&blob[..n as usize]) } else { 0 }; - let mut game = Game::new(seed(api)); - let mut seen = Some(frame(&mut screen, &game, best, None)); - api.show(); - let mut next = api.now().wrapping_add(FRAME_MS); - let mut over_at = 0u32; - loop { - motor.update(); - let now = api.now(); - let still = game.state != State::Playing; - let left = if still { u32::MAX } else { (next.wrapping_sub(now) as i32).max(0) as u32 }; - let wait = motor.wait().map_or(left, |m| m.min(left)); - if let Some(e) = api.event(wait) { - match e.kind { - BUTTON => { - api.keep_screen_on(false); - return 0; - } - PAUSE => { - motor.off(); - api.keep_screen_on(false); - if !paused(api) { - return 0; - } - seen = Some(frame(&mut screen, &game, best, None)); - api.show(); - next = api.now().wrapping_add(FRAME_MS); - } - TOUCH_DOWN => { - let now = api.now(); - match game.state { - State::Playing => game.steer(e.x as i32, e.y as i32), - State::Over if !due(now, over_at.wrapping_add(RETRY_MS)) => {} - state => { - if state == State::Over { - game.restart(); // Ready keeps the paddle where the crown put it - } - game.launch(); - seen = Some(frame(&mut screen, &game, best, seen)); - api.show(); - api.keep_screen_on(true); - next = now.wrapping_add(FRAME_MS); - } - } - } - CROWN => { - game.crown(e.delta); - if still { - seen = Some(frame(&mut screen, &game, best, seen)); - api.show(); - } - } - _ => {} - } - continue; - } - let now = api.now(); - if still || !due(now, next) { - continue; // the motor's deadline, not a tick - } - for _ in 0..CATCH_UP { - match game.step() { - Step::Scored => motor.play(TICK), - Step::Crashed => { - motor.play(DONE); - over_at = now; - if game.score > best { - best = game.score; - api.save(&encode(best)); // on change: the app can be ended without notice - } - } - Step::Nothing => {} - } - next = next.wrapping_add(FRAME_MS); - if game.state != State::Playing || !due(now, next) { - break; - } - } - if due(now, next) { - next = now.wrapping_add(FRAME_MS); - } - seen = Some(frame(&mut screen, &game, best, seen)); - api.show(); - if game.state != State::Playing { - api.keep_screen_on(false); - } - } - } -} diff --git a/apps/orbit/src/view.rs b/apps/orbit/src/view.rs deleted file mode 100644 index 98534fb..0000000 --- a/apps/orbit/src/view.rs +++ /dev/null @@ -1,249 +0,0 @@ -// Drawing, through cmf-wp2-ui's Surface: the watch draws with `&Api`, the tests with `Fb`. There is one buffer and -// no double buffering, so a frame while playing repaints only what changed: the ball's old spot, the score if the -// ball crossed it, the rail if the paddle moved or the ball touched it, and the ball. Each frame comes out the same -// as drawing the whole screen again (the tests check that pixel for pixel). - -use crate::game::{BALL_R, C, Game, RAIL_R0, RAIL_R1, SIZE, State}; -use cmf_wp2_ui::draw::{arc, disc}; -use cmf_wp2_ui::motion::isqrt; -use cmf_wp2_ui::text::{big, big_width, centre, int}; -use cmf_wp2_ui::{Rgb, Surface}; - -const BG: Rgb = Rgb(0, 0, 0); -const TRACK: Rgb = Rgb(38, 38, 46); -/// CMF orange. -const PADDLE: Rgb = Rgb(255, 92, 0); -const BALL: Rgb = Rgb(255, 255, 255); -const WHITE: u16 = 0xFFFF; -const GREY: u16 = 0x8C71; -/// The score behind the ball while playing: there, but quiet. -const DIM: u16 = cmf_wp2_ui::color::rgb565(70, 70, 82); - -/// The playing score: font scale and top edge, centred on the screen. -const SCORE_SCALE: i32 = 6; -const SCORE_Y: i32 = C - 4 * SCORE_SCALE; -/// The ball's old spot is cleared this far out, so its antialiased edge goes too. -const ERASE_R: i32 = BALL_R + 2; - -/// What was on screen after the last frame. -#[derive(Clone, Copy, PartialEq, Debug)] -pub struct Seen { - state: State, - ball: (i32, i32), - paddle: u16, - span: i32, - score: u32, -} - -fn seen(g: &Game) -> Seen { - Seen { state: g.state, ball: g.ball(), paddle: g.paddle, span: g.span(), score: g.score } -} - -fn rail(s: &mut impl Surface, g: &Game) { - let span = g.span(); - arc(s, C, C, RAIL_R0, RAIL_R1, g.paddle.wrapping_sub((span / 2) as u16), span as u32, PADDLE, Some(TRACK), BG); -} - -fn ball(s: &mut impl Surface, (x, y): (i32, i32)) { - disc(s, x, y, BALL_R, BALL, BG); -} - -/// The playing score's box, `[x0, y0, x1, y1)`. -fn score_box(score: u32) -> [i32; 4] { - let mut buf = [0u8; 11]; - let w = big_width(int(score as i32, &mut buf), SCORE_SCALE); - [C - w / 2, SCORE_Y, C - w / 2 + w, SCORE_Y + 8 * SCORE_SCALE] -} - -fn score(s: &mut impl Surface, score: u32) { - let mut buf = [0u8; 11]; - let b = score_box(score); - big(s, b[0], b[1], int(score as i32, &mut buf), SCORE_SCALE, DIM); -} - -/// The ball's antialiased edge or its cleared spot can reach the rail. -fn near_rail((x, y): (i32, i32)) -> bool { - let (dx, dy) = (x - C, y - C); - isqrt(dx * dx + dy * dy) + ERASE_R + 2 >= RAIL_R0 -} - -fn overlaps((x, y): (i32, i32), r: i32, b: [i32; 4]) -> bool { - x + r + 1 >= b[0] && x - r - 1 < b[2] && y + r + 1 >= b[1] && y - r - 1 < b[3] -} - -/// "best N" centred at `y`, or nothing before the first run. -fn best_line(s: &mut impl Surface, y: i32, best: u32, c: u16) { - if best > 0 { - let mut buf = [0u8; 16]; - buf[..5].copy_from_slice(b"best "); - let mut digits = [0u8; 11]; - let d = int(best.min(9_999_999) as i32, &mut digits).as_bytes(); - buf[5..5 + d.len()].copy_from_slice(d); - centre(s, C, y, core::str::from_utf8(&buf[..5 + d.len()]).unwrap_or(""), c); - } -} - -/// The whole screen. -pub fn full(s: &mut impl Surface, g: &Game, best: u32) { - s.rect(0, 0, SIZE, SIZE, BG.rgb565()); - match g.state { - State::Ready => { - big(s, C - big_width("ORBIT", 4) / 2, 112, "ORBIT", 4, WHITE); - centre(s, C, 296, "tap to start", WHITE); - centre(s, C, 320, "crown steers", GREY); - best_line(s, 352, best, GREY); - } - State::Playing => score(s, g.score), - State::Over => { - centre(s, C, 120, "GAME OVER", GREY); - let mut buf = [0u8; 11]; - let text = int(g.score as i32, &mut buf); - big(s, C - big_width(text, 8) / 2, C - 48, text, 8, WHITE); - best_line(s, 280, best, GREY); - centre(s, C, 310, "tap to play again", WHITE); - } - } - rail(s, g); - if g.state != State::Over { - ball(s, g.ball()); - } -} - -/// Draws the frame for `g` over what `last` says is on screen (None: nothing known, draw it all) and returns what is -/// on screen now. The caller `show`s. -pub fn frame(s: &mut impl Surface, g: &Game, best: u32, last: Option) -> Seen { - let now = seen(g); - let Some(last) = last.filter(|l| l.state == now.state) else { - full(s, g, best); - return now; - }; - let rail_moved = (last.paddle, last.span) != (now.paddle, now.span); - if g.state != State::Playing { - // Ready and Over hold still; only the crown moves the paddle. - if rail_moved { - rail(s, g); - } - return now; - } - let moved = last.ball != now.ball; - if moved { - disc(s, last.ball.0, last.ball.1, ERASE_R, BG, BG); - } - let boxed = score_box(now.score); - let score_dirty = last.score != now.score || (moved && overlaps(last.ball, ERASE_R, boxed)); - if score_dirty { - let b = score_box(last.score.max(now.score)); - s.rect(b[0], b[1], b[2] - b[0], b[3] - b[1], BG.rgb565()); - score(s, now.score); - } - let rail_dirty = rail_moved || (moved && near_rail(last.ball)) || near_rail(now.ball); - if rail_dirty { - rail(s, g); - } - if moved || score_dirty || rail_dirty { - ball(s, now.ball); - } - now -} - -#[cfg(test)] -mod tests { - use super::*; - use crate::game::Step; - use cmf_wp2_ui::Fb; - use cmf_wp2_ui::motion::angle; - - const N: usize = (SIZE * SIZE) as usize; - - fn fresh(g: &Game, best: u32) -> Vec { - let mut px = vec![0x1234u16; N]; - full(&mut Fb::new(&mut px), g, best); - px - } - - fn first_diff(a: &[u16], b: &[u16]) -> Option<(i32, i32)> { - a.iter().zip(b).position(|(x, y)| x != y).map(|i| (i as i32 % SIZE, i as i32 / SIZE)) - } - - /// Plays `ticks` with `pilot` choosing the paddle, drawing each frame over the last, and checks every frame - /// against a full redraw. - fn check_run(seed: u32, ticks: usize, pilot: impl Fn(&Game, usize) -> Option) -> Game { - let mut g = Game::new(seed); - let mut px = vec![0u16; N]; - let mut seen = Some(frame(&mut Fb::new(&mut px), &g, 5, None)); - g.launch(); - for t in 0..ticks { - if let Some(p) = pilot(&g, t) { - g.paddle = p; - } - if t % 97 == 13 { - g.crown(1); - } - let step = g.step(); - seen = Some(frame(&mut Fb::new(&mut px), &g, 5, seen)); - assert_eq!(first_diff(&px, &fresh(&g, 5)), None, "seed {seed} tick {t} ({step:?})"); - if g.state == State::Over { - break; - } - } - g - } - - #[test] - fn partial_frames_match_full_redraws_while_scoring() { - let g = check_run(42, 900, |g, t| (t % 5 != 0).then(|| angle(g.x >> 4, g.y >> 4))); - assert!(g.score > 5, "{}", g.score); - } - - #[test] - fn partial_frames_match_through_a_miss_and_game_over() { - let g = check_run(7, 600, |g, _| Some(angle(g.x >> 4, g.y >> 4).wrapping_add(32768))); - assert_eq!(g.state, State::Over); - } - - #[test] - fn crown_on_a_still_screen_redraws_only_the_rail() { - let g0 = Game::new(1); - let mut px = vec![0u16; N]; - let seen = frame(&mut Fb::new(&mut px), &g0, 12, None); - let mut g = g0.clone(); - g.crown(-3); - let mut fb = Fb::new(&mut px); - frame(&mut fb, &g, 12, Some(seen)); - let rects = fb.rects; - assert_eq!(first_diff(&px, &fresh(&g, 12)), None); - let mut whole = vec![0u16; N]; - let mut fb = Fb::new(&mut whole); - full(&mut fb, &g, 12); - assert!(rects < fb.rects, "{rects} vs {}", fb.rects); - } - - #[test] - fn a_quiet_tick_costs_far_less_than_a_full_frame() { - let mut g = Game::new(3); - g.launch(); - let mut px = vec![0u16; N]; - let seen = frame(&mut Fb::new(&mut px), &g, 0, None); - // A tick in open space: away from the rail and the score. - let before = g.ball(); - assert_eq!(g.step(), Step::Nothing); - assert_ne!(before, g.ball()); - let mut fb = Fb::new(&mut px); - frame(&mut fb, &g, 0, Some(seen)); - let partial = fb.rects; - let mut whole = vec![0u16; N]; - let mut fb = Fb::new(&mut whole); - full(&mut fb, &g, 0); - assert!(partial * 10 < fb.rects, "{partial} vs {}", fb.rects); - } - - #[test] - fn text_fits_inside_the_rail() { - // Every text line of the still screens stays clear of the rail's inner edge. - for (y, chars) in [(296, 12), (320, 12), (352, 12), (120, 9), (280, 12), (310, 17)] { - let d = (y - C).abs().max((y + 16 - C).abs()); - let half = isqrt(RAIL_R0 * RAIL_R0 - d * d); - assert!(8 * chars + 6 <= half, "line at {y}"); - } - } -} diff --git a/apps/orbit/store.md b/apps/orbit/store.md deleted file mode 100644 index c7b9a38..0000000 --- a/apps/orbit/store.md +++ /dev/null @@ -1,13 +0,0 @@ -Pong for a round screen. A ball bounces around inside the watch face, and your paddle rides the ring at its edge. -Turn the crown to slide the paddle round and keep the ball in, or tap the side of the screen you want the paddle to -head for. Where the ball lands on the paddle tilts the bounce, so you can aim it. - -Every bounce is a point. The ball speeds up and the paddle gets shorter as the score climbs. Let the ball slip past and -the run is over: tap to go again. Your best score is kept on the watch. - -Press the crown or swipe right to leave. - -## Requirements - -The [patched firmware](/firmware) and the [App Loader](/firmware). Open it from the **Apps** row at the end of the -watch's app list (list style, not the waterfall). diff --git a/apps/orbit/store.toml b/apps/orbit/store.toml deleted file mode 100644 index 29d52a8..0000000 --- a/apps/orbit/store.toml +++ /dev/null @@ -1,6 +0,0 @@ -# The app's listing in the FMC store (README.md, "store.toml"). The page's body is store.md. -name = "Orbit" -summary = "Round-screen Pong: turn the crown to keep the ball inside the ring" -version = "0.1.0" -author = "Nandhini" -screenshots = ["shots/ready.png", "shots/playing.png", "shots/over.png"] diff --git a/apps/reminders/Cargo.toml b/apps/reminders/Cargo.toml deleted file mode 100644 index d828287..0000000 --- a/apps/reminders/Cargo.toml +++ /dev/null @@ -1,16 +0,0 @@ -[package] -name = "reminders" -edition.workspace = true -license.workspace = true -version.workspace = true - -[dependencies] -cmf-wp2-app.workspace = true -companion-rpc.workspace = true - -[dev-dependencies] -wp2-core.workspace = true - -[[bin]] -name = "reminders" -bench = false diff --git a/apps/reminders/README.md b/apps/reminders/README.md deleted file mode 100644 index 41553fa..0000000 --- a/apps/reminders/README.md +++ /dev/null @@ -1,38 +0,0 @@ -# Reminders - -The iPhone's open reminders on the CMF Watch Pro 2, from [FMC Companion](https://github.com/fmctools/companion)'s -`reminders` and `reminders.complete` ([miniapp-rpc.md](https://github.com/fmctools/companion/blob/main/docs/miniapp-rpc.md)), -through [`crates/companion-rpc`](../../crates/companion-rpc). LVGL, stock look; a menu app and a widget card. - -| File | | -|---|---| -| `src/model.rs` | no `Api`: the list call and the complete call, retry and back-off, the cache blob, sections and texts | -| `src/screen.rs` | the list and "Done?" screens, host-tested batch by batch against the loader's checker | -| `src/main.rs` | the device loop: events, the buzz, storage, the widget | - -What it does: - -- At start the cached list shows at once (`store`, `M1` blob, ≤ 1.5 KB), then the phone is asked; again every 3 - minutes while open, on `RESUME`, and with back-off from 3 s while the phone is silent. -- Sections: overdue (before today, or today with its time passed) in red, today, tomorrow, later days, no date. The - phone's `day` counts from the day of its answer, so a cached list shifts with the date. -- A tap asks "Done?"; Done removes the row, buzzes 60 ms and queues `reminders.complete` (up to 8 queued, kept in - the cache until the phone answers). `BAD_REQUEST` (done or deleted meanwhile), `DENIED` and `ASK` settle it too; - then the list is fetched again, which tells the truth. `UNAVAILABLE`: tried again in 30 s. -- Empty list: `ASK` → "Allow Reminders in FMC Companion on your phone", `DENIED` → where to turn it on, - `UNAVAILABLE` → "Reminders need an iPhone" (Android answers that), no answer → "Phone not reachable", else - "All done". With a cached list those show as a line under it. -- Titles hidden by the phone (flag bit 2, the default) show as "Reminder" and the time. -- Widget: "Reminders", "N due today" (overdue included) and the next one; written only when the text changes. - -No page: the list needs the crown and taps, and a page can't leave on `BUTTON`. - -```bash -make test APP=reminders -make build APP=reminders -``` - -Run so far: host tests, and the emulator (stub and loader at the pinned SDK) with a fake phone on the channel that -answers `ASK`, then a list, and takes `reminders.complete`: the "allow" screen, the list, the crown, "Done?", the -completion with the right id and the list fetched again, the widget record, and the cached list on reopening without -the phone (the shots). Not yet on a real watch or with the real companion. diff --git a/apps/reminders/icon.svg b/apps/reminders/icon.svg deleted file mode 100644 index 44ebeaa..0000000 --- a/apps/reminders/icon.svg +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - diff --git a/apps/reminders/shots/allow.png b/apps/reminders/shots/allow.png deleted file mode 100644 index 8b1de17..0000000 Binary files a/apps/reminders/shots/allow.png and /dev/null differ diff --git a/apps/reminders/shots/confirm.png b/apps/reminders/shots/confirm.png deleted file mode 100644 index e7c5066..0000000 Binary files a/apps/reminders/shots/confirm.png and /dev/null differ diff --git a/apps/reminders/shots/list.png b/apps/reminders/shots/list.png deleted file mode 100644 index 407c482..0000000 Binary files a/apps/reminders/shots/list.png and /dev/null differ diff --git a/apps/reminders/src/main.rs b/apps/reminders/src/main.rs deleted file mode 100644 index 696a184..0000000 --- a/apps/reminders/src/main.rs +++ /dev/null @@ -1,254 +0,0 @@ -//! reminders: the iPhone's open reminders on the watch, from FMC Companion (`reminders`, `reminders.complete`). -//! -//! - The list (`screen::list_view`): overdue first in red, today, then by day, then the ones without a date; the -//! crown scrolls. A tap on a row asks "Done?" (`screen::confirm_view`); Done ticks it off on the phone, buzzes -//! once and the row goes. BUTTON (the right swipe, `own_back`) on "Done?" comes back, on the list exits. -//! - The card left of the watch face (`app_features!(WIDGET)`): how many are due today and the next one, written -//! whenever it changes while the app runs. -//! -//! The list comes from the phone at start and every 3 minutes while open, and is kept in the app's storage so it -//! opens at once without the phone (`model.rs`). Ticks the phone hasn't confirmed are kept too and sent again. -#![cfg_attr(target_os = "none", no_std, no_main)] - -#[cfg_attr(not(target_os = "none"), allow(dead_code))] -mod model; -#[cfg_attr(not(target_os = "none"), allow(dead_code))] -mod screen; - -#[cfg(not(target_os = "none"))] -fn main() {} - -#[cfg(target_os = "none")] -mod device { - use crate::model::{self, BLOB_MAX, Got, Line, Model, When, wall_min}; - use crate::screen::{self, ConfirmView, ListView}; - use cmf_wp2_app::lv::{Batch, Lv, Obj, ROOT}; - use cmf_wp2_app::{Api, BUTTON, LV, MESSAGE, MSG_MAX, PAUSE, RESUME}; - - cmf_wp2_app::entry!(main); - cmf_wp2_app::app_icon!(); - cmf_wp2_app::app_features!(cmf_wp2_app::WIDGET); - - const CLICKED: i16 = 7; - /// How often to look at the clock: a reminder's time passing makes it overdue. - const TICK_MS: u32 = 30_000; - /// The buzz of a tick: one short pulse. - const BUZZ: (u16, u16, u32) = (650, 31, 60); - - static mut STORE: [u8; BLOB_MAX] = [0; BLOB_MAX]; - // ponytail: ~3.6 KB of reminders, kept off the 8 KiB stack - static mut MODEL: Model = Model::new(); - - fn wall(api: &Api) -> i32 { - api.time().map_or(0, |t| wall_min(t.year as i32, t.month as u32, t.day as u32, t.hour as u32, t.minute as u32)) - } - - #[derive(Clone, Copy)] - enum View { - List(ListView), - Confirm(ConfirmView), - } - - struct App { - api: &'static Api, - lv: Lv, - b: Batch, - model: &'static mut Model, - view: View, - /// What the list shows depends on: the day and how many are overdue. - shown: (i32, usize), - card: Line, - buzz_off: Option, - } - - impl App { - fn root(&self) -> Obj { - match self.view { - View::List(v) => v.root, - View::Confirm(v) => v.root, - } - } - - fn key(&self, w: i32) -> (i32, usize) { - let m = &*self.model; - (w.div_euclid(1440), (0..m.n).filter(|&i| m.when(i, w) == When::Overdue).count()) - } - - fn list(&mut self) { - let (lv, w) = (self.lv, wall(self.api)); - let mut flush = |b: &mut Batch| b.submit(&lv); - let old = self.root(); - let r = screen::leave(&mut self.b, old) - .and_then(|_| screen::list_view(&mut self.b, &mut flush, self.model, w)) - .and_then(|v| self.b.submit(&lv).map(|_| v)); - if let Ok(v) = r { - self.view = View::List(v); - } - self.shown = self.key(w); - } - - fn confirm(&mut self, i: usize) { - let (lv, w) = (self.lv, wall(self.api)); - let mut flush = |b: &mut Batch| b.submit(&lv); - let old = self.root(); - let r = screen::leave(&mut self.b, old) - .and_then(|_| screen::confirm_view(&mut self.b, &mut flush, self.model, i, w)) - .and_then(|v| self.b.submit(&lv).map(|_| v)); - match r { - Ok(v) => self.view = View::Confirm(v), - Err(_) => self.list(), - } - } - - fn save(&mut self) { - let blob = unsafe { &mut *core::ptr::addr_of_mut!(STORE) }; - let n = self.model.save(blob); - if n > 0 { - self.api.save(&blob[..n]); // on change: the app can end without notice - } - } - - /// The card, when its text changes. - fn card(&mut self) { - let v = model::card_value(self.model, wall(self.api)); - if v.as_str() != self.card.as_str() { - self.api.widget("Reminders", v.as_str()); - self.card = v; - } - } - - fn done(&mut self, id: u32) { - let now = self.api.now(); - if let Some(i) = (0..self.model.n).find(|&i| self.model.list[i].id == id) { - if self.model.complete(i, now) { - self.save(); - let (duty, hz, ms) = BUZZ; - if self.api.vibrate(duty, hz) == 0 { - self.buzz_off = Some(now.wrapping_add(ms)); - } else { - self.api.vibrate(0, hz); // -4: clear the lock, skip this buzz - } - } - } - self.list(); - self.card(); - } - - fn stop_buzz(&mut self) { - if self.buzz_off.take().is_some() { - self.api.vibrate(0, BUZZ.1); - } - } - - fn poll(&mut self) { - let now = self.api.now(); - while let Some(req) = self.model.poll(now) { - if self.api.send(&req) == -11 { - break; // outbox full: the retry timer sends it again - } // -107 with no phone: the retry timer covers it too - } - } - - fn message(&mut self, m: &[u8]) { - let got = self.model.reply(m, self.api.now(), wall(self.api)); - if got == Got::Saved { - self.save(); - } - if got != Got::Nothing { - if let View::List(_) = self.view { - self.list(); - } - self.card(); - } - } - - /// The clock moved: a reminder became overdue, or a new day. - fn tick(&mut self) { - if self.key(wall(self.api)) != self.shown { - if let View::List(_) = self.view { - self.list(); - } - self.card(); - } - } - } - - fn main(api: &'static Api) -> i32 { - let Some(lv) = api.lv() else { return -95 }; // loader older than ABI 1.2 - let Some(mut b) = Batch::new() else { return -1 }; - if screen::fonts(&mut b).and_then(|_| b.submit(&lv)).is_err() { - return 1; - } - if screen::theme(&mut b).and_then(|_| b.submit(&lv)).is_err() { - return 2; - } - let model = unsafe { &mut *core::ptr::addr_of_mut!(MODEL) }; - let blob = unsafe { &mut *core::ptr::addr_of_mut!(STORE) }; - let n = api.load(blob); - if n > 0 { - model.load(&blob[..n as usize]); - } - model.ask_now(api.now()); - let placeholder = View::List(ListView { root: ROOT, rows: [ROOT; model::MAX], index: [0; model::MAX], n: 0 }); - let mut app = App { api, lv, b, model, view: placeholder, shown: (0, 0), card: Line::new(), buzz_off: None }; - api.own_back(true); // the right swipe on "Done?" comes back to the list, not out (no-op before ABI 1.3) - app.list(); - app.card(); - let mut paused = false; - let mut msg = [0u8; MSG_MAX]; - loop { - if !paused { - app.poll(); - } - let now = api.now(); - let buzz = app.buzz_off.map_or(u32::MAX, |t| (t.wrapping_sub(now) as i32).max(0) as u32); - let wait = if paused { u32::MAX } else { app.model.wait(now).min(TICK_MS).min(buzz) }; - let e = api.event(wait); - if let Some(t) = app.buzz_off { - if (api.now().wrapping_sub(t) as i32) >= 0 { - app.stop_buzz(); - } - } - if !paused { - app.tick(); - } - let Some(e) = e else { continue }; - match e.kind { - BUTTON => match app.view { - View::Confirm(_) => app.list(), - View::List(_) => break, - }, - PAUSE => { - app.stop_buzz(); - paused = true; - } - RESUME => { - paused = false; - app.model.ask_now(api.now()); - app.tick(); - } - MESSAGE => { - while let Some(m) = api.recv(&mut msg) { - app.message(m); - } - } - LV if e.y == CLICKED && !paused => { - let h = e.x as u16; - match app.view { - View::List(v) => { - if let Some(k) = v.rows[..v.n].iter().position(|r| r.0 == h) { - app.confirm(v.index[k] as usize); - } - } - View::Confirm(v) if h == v.done.0 => app.done(v.id), - View::Confirm(v) if h == v.cancel.0 => app.list(), - _ => {} - } - } - _ => {} - } - } - app.stop_buzz(); - 0 - } -} diff --git a/apps/reminders/src/model.rs b/apps/reminders/src/model.rs deleted file mode 100644 index a9a0f50..0000000 --- a/apps/reminders/src/model.rs +++ /dev/null @@ -1,586 +0,0 @@ -//! What the app knows and when it asks, without `Api`: the last list from the phone, the reminders ticked off on the -//! watch that the phone hasn't confirmed yet, the cache blob, and where each reminder goes on the screen. -//! -//! Two calls to the phone side by side, one id counter: `reminders` every few minutes, and `reminders.complete` for -//! each ticked reminder, oldest first, until the phone answers. `now` is `api.now()` ms; `wall` the watch's local time -//! in minutes since 1970-01-01 ([`wall_min`]). - -use companion_rpc::{self as rpc, Call, Reminder}; -use core::fmt::Write; - -/// Reminders asked for, the most the phone sends. -pub const MAX: usize = 20; -/// Ask again while the app is open. -pub const PERIOD_MS: u32 = 180_000; -/// While the phone asks the user: look again soon, the grant may come any moment. -pub const ASK_AGAIN_MS: u32 = 10_000; -/// A completion the phone couldn't do now (`UNAVAILABLE`): try again after this. -pub const LATER_MS: u32 = 30_000; -/// Ticked reminders the phone hasn't confirmed, kept in the cache. -pub const DONE_MAX: usize = 8; -/// The cache blob: magic, fetched (i32 wall minute), count, `len ‖ record` per reminder, then the done queue. -const MAGIC: &[u8; 2] = b"M1"; -pub const BLOB_MAX: usize = 7 + MAX * (1 + Reminder::RECORD_MAX) + 1 + DONE_MAX * 4; - -#[derive(Clone, Copy, PartialEq, Eq, Debug)] -pub enum Status { - /// No answer since start. - Waiting, - Ok, - /// The phone asked the user to allow Reminders for this app. - Ask, - /// The user said no, or iOS's Reminders access is off. - Denied, - /// The phone can't: an Android phone (no system reminders there), or anything else it refused. - Unavailable, -} - -#[derive(Clone, Copy, PartialEq, Eq, Debug)] -pub enum Got { - Nothing, - /// The screen changes. - Changed, - /// The screen changes and the cache too: save it. - Saved, -} - -/// Where a reminder goes, in screen order. -#[derive(Clone, Copy, PartialEq, Eq, Debug)] -pub enum When { - /// Due before today, or today at a time that has passed. - Overdue, - Today, - /// Days from today, 1 or more. - Later(i32), - NoDate, -} - -pub struct Model { - /// In the phone's order: due ones by day (untimed first, then by minute), then the rest. - pub list: [Reminder; MAX], - pub n: usize, - /// When `list` came, wall minutes; `None` = nothing ever came. - pub fetched: Option, - pub status: Status, - done: [u32; DONE_MAX], - done_n: usize, - list_call: Call, - done_call: Call, - ids: u8, - pending: [Reminder; MAX], - ok: u32, -} - -/// Days since 1970-01-01 of a civil date (H. Hinnant's `days_from_civil`). -pub fn days(y: i32, m: u32, d: u32) -> i32 { - let y = if m <= 2 { y - 1 } else { y }; - let era = y.div_euclid(400); - let yoe = y - era * 400; - let mp = (m as i32 + 9) % 12; - let doy = (153 * mp + 2) / 5 + d as i32 - 1; - era * 146_097 + yoe * 365 + yoe / 4 - yoe / 100 + doy - 719_468 -} - -/// The civil date of a day number: (year, month 1-12, day). -pub fn civil(z: i32) -> (i32, u32, u32) { - let z = z + 719_468; - let era = z.div_euclid(146_097); - let doe = z - era * 146_097; - let yoe = (doe - doe / 1460 + doe / 36_524 - doe / 146_096) / 365; - let doy = doe - (365 * yoe + yoe / 4 - yoe / 100); - let mp = (5 * doy + 2) / 153; - let d = (doy - (153 * mp + 2) / 5 + 1) as u32; - let m = if mp < 10 { mp + 3 } else { mp - 9 } as u32; - (yoe + era * 400 + (m <= 2) as i32, m, d) -} - -pub fn wall_min(y: i32, m: u32, d: u32, hour: u32, minute: u32) -> i32 { - days(y, m, d) * 1440 + (hour * 60 + minute) as i32 -} - -const EMPTY: Reminder = Reminder { id: 0, day: 0, minute: 0, flags: 0, color: 0, title: rpc::Text::EMPTY }; - -impl Model { - pub const fn new() -> Self { - Model { - list: [EMPTY; MAX], - n: 0, - fetched: None, - status: Status::Waiting, - done: [0; DONE_MAX], - done_n: 0, - list_call: Call::new(PERIOD_MS), - done_call: Call::new(PERIOD_MS), - ids: 0, - pending: [EMPTY; MAX], - ok: 0, - } - } - - /// Ask for the list at once (start, `RESUME`), and send what is still to be completed. - pub fn ask_now(&mut self, now: u32) { - self.list_call.now(now); - if self.done_n > 0 { - self.done_call.now(now); - } - } - - /// A request to send now, if one is due: completions first. - pub fn poll(&mut self, now: u32) -> Option { - if self.done_n > 0 { - if let Some(id) = self.done_call.due(now, &mut self.ids) { - return Some(rpc::reminders_complete(id, self.done[0])); - } - } - let id = self.list_call.due(now, &mut self.ids)?; - self.ok = 0; - Some(rpc::reminders(id, MAX as u8)) - } - - /// Ms until [`Model::poll`] has something to do. - pub fn wait(&self, now: u32) -> u32 { - self.list_call.wait(now).min(self.done_call.wait(now)) - } - - /// The phone left the last request for the list unanswered. - pub fn silent(&self) -> bool { - self.list_call.silent() - } - - /// Ticks reminder `i` off: it leaves the list now and the phone is told (again after a restart, from the - /// cache, until it answers). `false` if the queue is full. - pub fn complete(&mut self, i: usize, now: u32) -> bool { - if i >= self.n || self.done_n == DONE_MAX { - return false; - } - self.done[self.done_n] = self.list[i].id; - self.done_n += 1; - if self.done_n == 1 { - self.done_call.now(now); - } - self.list.copy_within(i + 1..self.n, i); - self.n -= 1; - true - } - - fn waiting_done(&self, id: u32) -> bool { - self.done[..self.done_n].contains(&id) - } - - /// One message from the channel. - pub fn reply(&mut self, m: &[u8], now: u32, wall: i32) -> Got { - match self.done_call.take(m) { - // `reminders.complete` has no records: a reply with one is not the phone's - rpc::Got::Nothing | rpc::Got::Record { .. } => {} - rpc::Got::Status(rpc::UNAVAILABLE) => { - self.done_call.after(now, LATER_MS); - return Got::Nothing; - } - // OK, BAD_REQUEST (done meanwhile, or deleted), DENIED, ASK: settled either way; the list says the truth - rpc::Got::Status(_) if self.done_n > 0 => { - self.done.copy_within(1..self.done_n, 0); - self.done_n -= 1; - if self.done_n > 0 { - self.done_call.now(now); - } else { - self.done_call.stop(); - } - self.list_call.now(now); - return Got::Saved; - } - rpc::Got::Status(_) => {} - } - match self.list_call.take(m) { - rpc::Got::Nothing => Got::Nothing, - rpc::Got::Status(s) => { - self.status = match s { - rpc::OK => Status::Ok, - rpc::ASK => Status::Ask, - rpc::DENIED => Status::Denied, - _ => Status::Unavailable, - }; - self.list_call.after(now, if self.status == Status::Ask { ASK_AGAIN_MS } else { PERIOD_MS }); - if self.status != Status::Ok { - return Got::Changed; - } - self.n = 0; - self.fetched = Some(wall); - Got::Saved - } - // one record each, any order; one that doesn't decode is left out - rpc::Got::Record { index, record, last, .. } => { - if let (Some(r), true) = (Reminder::decode(record), (index as usize) < MAX) { - self.pending[index as usize] = r; - self.ok |= 1 << index; - } - if !last { - return Got::Nothing; - } - self.n = 0; - for i in 0..MAX { - if self.ok & 1 << i != 0 && !self.waiting_done(self.pending[i].id) { - self.list[self.n] = self.pending[i]; - self.n += 1; - } - } - self.fetched = Some(wall); - self.status = Status::Ok; - self.list_call.after(now, PERIOD_MS); - Got::Saved - } - } - } - - /// Reminder `i`'s due day in days from today at `wall`: the phone's `day` counts from the day of the answer, so - /// a cache from yesterday moves one day closer. `None` without a due date. - pub fn day(&self, i: usize, wall: i32) -> Option { - let r = &self.list[i]; - let shift = wall.div_euclid(1440) - self.fetched.unwrap_or(wall).div_euclid(1440); - r.due().then(|| r.day as i32 - shift) - } - - pub fn when(&self, i: usize, wall: i32) -> When { - let r = &self.list[i]; - match self.day(i, wall) { - None => When::NoDate, - Some(d) if d < 0 => When::Overdue, - Some(0) if r.timed() && (r.minute as i32) < wall.rem_euclid(1440) => When::Overdue, - Some(0) => When::Today, - Some(d) => When::Later(d), - } - } - - /// The screen's order: the overdue ones, then the rest, each in the phone's order. Indexes into `list`. - pub fn order(&self, wall: i32) -> ([u8; MAX], usize) { - let mut out = [0u8; MAX]; - let mut k = 0; - for overdue in [true, false] { - for i in 0..self.n { - if (self.when(i, wall) == When::Overdue) == overdue { - out[k] = i as u8; - k += 1; - } - } - } - (out, k) - } - - /// Overdue and due today: the card's count. - pub fn due_now(&self, wall: i32) -> usize { - (0..self.n).filter(|&i| matches!(self.when(i, wall), When::Overdue | When::Today)).count() - } - - /// The cache blob into `out` ([`BLOB_MAX`] bytes); its length, 0 if there is nothing to keep. - pub fn save(&self, out: &mut [u8]) -> usize { - let Some(f) = self.fetched else { return 0 }; - out[..2].copy_from_slice(MAGIC); - out[2..6].copy_from_slice(&f.to_le_bytes()); - out[6] = self.n as u8; - let mut at = 7; - for r in &self.list[..self.n] { - let len = r.encode(&mut out[at + 1..]); - out[at] = len as u8; - at += 1 + len; - } - out[at] = self.done_n as u8; - at += 1; - for id in &self.done[..self.done_n] { - out[at..at + 4].copy_from_slice(&id.to_le_bytes()); - at += 4; - } - at - } - - /// Restores a cache blob; anything it cannot read leaves the model empty. - pub fn load(&mut self, b: &[u8]) { - if b.len() < 7 || &b[..2] != MAGIC || b[6] as usize > MAX { - return; - } - let mut at = 7; - for i in 0..b[6] as usize { - let Some(&len) = b.get(at) else { return }; - let Some(r) = b.get(at + 1..at + 1 + len as usize).and_then(Reminder::decode) else { return }; - self.pending[i] = r; - at += 1 + len as usize; - } - let Some(&dn) = b.get(at) else { return }; - let Some(ids) = b.get(at + 1..at + 1 + 4 * dn as usize).filter(|_| dn as usize <= DONE_MAX) else { return }; - for (k, c) in ids.chunks(4).enumerate() { - self.done[k] = u32::from_le_bytes([c[0], c[1], c[2], c[3]]); - } - self.done_n = dn as usize; - self.n = b[6] as usize; - self.list[..self.n].copy_from_slice(&self.pending[..self.n]); - self.fetched = Some(i32::from_le_bytes([b[2], b[3], b[4], b[5]])); - } -} - -/// A short line of text in a fixed buffer; writes that don't fit are dropped whole. -pub struct Line { - buf: [u8; 64], - len: usize, -} - -impl Line { - pub const fn new() -> Line { - Line { buf: [0; 64], len: 0 } - } - - pub fn as_str(&self) -> &str { - core::str::from_utf8(&self.buf[..self.len]).unwrap_or("") - } -} - -impl Write for Line { - fn write_str(&mut self, s: &str) -> core::fmt::Result { - if self.len + s.len() > self.buf.len() { - return Err(core::fmt::Error); - } - self.buf[self.len..self.len + s.len()].copy_from_slice(s.as_bytes()); - self.len += s.len(); - Ok(()) - } -} - -const WEEKDAYS: [&str; 7] = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]; -const MONTHS: [&str; 12] = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]; - -/// "Today", "Tomorrow", "Yesterday", else "Wed 25 Nov": `d` days from the day of `wall`. -pub fn day_label(d: i32, wall: i32, out: &mut Line) { - let _ = match d { - 0 => out.write_str("Today"), - 1 => out.write_str("Tomorrow"), - -1 => out.write_str("Yesterday"), - _ => { - let z = wall.div_euclid(1440) + d; - let (_, m, day) = civil(z); - write!(out, "{} {} {}", WEEKDAYS[(z + 3).rem_euclid(7) as usize], day, MONTHS[m as usize - 1]) - } - }; -} - -/// "18:05". -pub fn time_label(minute: u16, out: &mut Line) { - let _ = write!(out, "{:02}:{:02}", minute / 60 % 24, minute % 60); -} - -/// The header of a section. -pub fn section_label(w: When, wall: i32) -> Line { - let mut out = Line::new(); - match w { - When::Overdue => { - let _ = out.write_str("Overdue"); - } - When::Today => day_label(0, wall, &mut out), - When::Later(d) => day_label(d, wall, &mut out), - When::NoDate => { - let _ = out.write_str("No date"); - } - } - out -} - -/// The grey (or red) line under a reminder's title: its time; for an overdue one its day too. -pub fn detail(m: &Model, i: usize, wall: i32) -> Line { - let r = &m.list[i]; - let mut out = Line::new(); - if m.when(i, wall) == When::Overdue { - day_label(m.day(i, wall).unwrap_or(0), wall, &mut out); - if r.timed() { - let _ = out.write_str(" "); - } - } - if r.timed() { - time_label(r.minute, &mut out); - } - out -} - -/// The title, or "Reminder" while the phone keeps titles (flag bit 2, the default). -pub fn title(r: &Reminder) -> &str { - if r.title.is_empty() { "Reminder" } else { r.title.as_str() } -} - -/// The card left of the watch face: how many are due today (overdue too), then the next one. -pub fn card_value(m: &Model, wall: i32) -> Line { - let mut out = Line::new(); - let (order, n) = m.order(wall); - let _ = match (m.fetched, n, m.due_now(wall)) { - (None, ..) => out.write_str("Open to sync"), - (_, 0, _) => out.write_str("All done"), - (_, _, 0) => out.write_str("Nothing due today"), - (_, _, 1) => out.write_str("1 due today"), - (_, _, k) => write!(out, "{k} due today"), - }; - if n > 0 { - let i = order[0] as usize; - let r = &m.list[i]; - let _ = out.write_str("\n"); - if r.title.is_empty() { - let _ = out.write_str("Reminder"); - if r.timed() && matches!(m.when(i, wall), When::Today | When::Overdue) { - let _ = out.write_str(" "); - time_label(r.minute, &mut out); - } - } else { - // the card cuts it at 39 bytes with "…" - let t = companion_rpc::utf8_cut(r.title.as_str().as_bytes(), 64 - out.len); - let _ = out.write_str(t); - } - } - out -} - -#[cfg(test)] -mod tests { - extern crate std; - use super::*; - use std::vec; - use std::vec::Vec; - - // 2026-11-19 (Thursday) 10:00 - const WALL: i32 = 20_776 * 1440 + 600; - - fn rec(id: u32, day: Option, minute: Option, title: &str) -> Vec { - let flags = day.is_some() as u8 | (minute.is_some() as u8) << 1 | (title.is_empty() as u8) << 2; - let mut r = id.to_le_bytes().to_vec(); - r.push(day.unwrap_or(0) as u8); - r.extend(minute.unwrap_or(0).to_le_bytes()); - r.push(flags); - r.extend(0xF800u16.to_le_bytes()); - r.extend(title.as_bytes()); - r - } - - fn msg(id: u8, status: u8, index: u8, total: u8, record: &[u8]) -> Vec { - let mut m = vec![b'R', b'1', b'A', id, status, index, total]; - m.extend(record); - m - } - - /// The model with `recs` as the phone's answer to its first request. - fn answered(recs: &[Vec]) -> Model { - let mut m = Model::new(); - m.ask_now(0); - let q = m.poll(0).unwrap(); - assert_eq!(&q[..], [b'R', b'1', b'Q', 1, 0x11, MAX as u8]); - for (i, r) in recs.iter().enumerate() { - let got = m.reply(&msg(1, 0, i as u8, recs.len() as u8, r), 0, WALL); - assert_eq!(got, if i + 1 == recs.len() { Got::Saved } else { Got::Nothing }); - } - m - } - - #[test] - fn calendar_maths() { - assert_eq!(days(2026, 11, 19), 20_776); - for z in [-1, 0, 20_776, 20_800, 11_016] { - let (y, m, d) = civil(z); - assert_eq!(days(y, m, d), z); - } - let mut l = Line::new(); - day_label(6, WALL, &mut l); - assert_eq!(l.as_str(), "Wed 25 Nov"); - let mut l = Line::new(); - day_label(-3, WALL, &mut l); - assert_eq!(l.as_str(), "Mon 16 Nov"); - } - - #[test] - fn sections_overdue_first() { - // the phone's order: by day, untimed first in a day, then by minute; then undated - let m = answered(&[ - rec(1, Some(-2), None, "Pay rent"), - rec(2, Some(0), None, "Call mum"), - rec(3, Some(0), Some(540), ""), // 09:00, passed at 10:00 - rec(4, Some(0), Some(1080), "Купить молоко"), - rec(5, Some(1), Some(600), "Dentist"), - rec(6, Some(6), None, "Taxes"), - rec(7, None, None, "Someday"), - ]); - let (order, n) = m.order(WALL); - assert_eq!(order[..n].iter().map(|&i| m.list[i as usize].id).collect::>(), [1, 3, 2, 4, 5, 6, 7]); - let when: Vec = order[..n].iter().map(|&i| m.when(i as usize, WALL)).collect(); - assert_eq!(when, [When::Overdue, When::Overdue, When::Today, When::Today, When::Later(1), When::Later(6), When::NoDate]); - assert_eq!(m.due_now(WALL), 4); - assert_eq!(detail(&m, 0, WALL).as_str(), "Tue 17 Nov"); - assert_eq!(detail(&m, 2, WALL).as_str(), "Today 09:00"); - assert_eq!(detail(&m, 3, WALL).as_str(), "18:00"); - assert_eq!(detail(&m, 1, WALL).as_str(), ""); - assert_eq!(section_label(When::Later(1), WALL).as_str(), "Tomorrow"); - assert_eq!(title(&m.list[2]), "Reminder"); - assert_eq!(card_value(&m, WALL).as_str(), "4 due today\nPay rent"); - // a day later from the cache: everything one day closer, today's 18:00 one now overdue - let next = WALL + 1440; - assert_eq!(m.when(4, next), When::Today); - assert_eq!(m.when(3, next), When::Overdue); - assert_eq!(m.due_now(next), 5); - } - - #[test] - fn card_states() { - let mut m = Model::new(); - assert_eq!(card_value(&m, WALL).as_str(), "Open to sync"); - m.ask_now(0); - m.poll(0); - assert_eq!(m.reply(&msg(1, rpc::OK, 0, 0, &[]), 0, WALL), Got::Saved); - assert_eq!(card_value(&m, WALL).as_str(), "All done"); - let m = answered(&[rec(9, Some(0), Some(1080), "")]); - assert_eq!(card_value(&m, WALL).as_str(), "1 due today\nReminder 18:00"); - let m = answered(&[rec(9, Some(2), None, "Taxes")]); - assert_eq!(card_value(&m, WALL).as_str(), "Nothing due today\nTaxes"); - } - - #[test] - fn statuses_keep_the_cache() { - let mut m = answered(&[rec(1, None, None, "a")]); - m.ask_now(5); - let q = m.poll(5).unwrap(); - assert_eq!(m.reply(&msg(q[3], rpc::UNAVAILABLE, 0, 0, &[]), 6, WALL), Got::Changed); - assert_eq!((m.status, m.n, m.wait(6)), (Status::Unavailable, 1, PERIOD_MS)); - m.ask_now(7); - let q = m.poll(7).unwrap(); - assert_eq!(m.reply(&msg(q[3], rpc::ASK, 0, 0, &[]), 8, WALL), Got::Changed); - assert_eq!((m.status, m.wait(8)), (Status::Ask, ASK_AGAIN_MS)); - // no answer at all: silent, the next try waits longer - let q = m.poll(8 + ASK_AGAIN_MS).unwrap(); - m.poll(8 + ASK_AGAIN_MS + companion_rpc::RETRY_MS).unwrap(); - assert!(m.silent()); - assert_eq!(m.reply(&msg(q[3], rpc::DENIED, 0, 0, &[]), 9, WALL), Got::Nothing); // an old id - } - - #[test] - fn complete_goes_out_survives_a_restart_and_hides_the_row() { - let mut m = answered(&[rec(0xCBE7AE7D, Some(0), None, "a"), rec(2, None, None, "b")]); - assert!(m.complete(0, 100)); - assert_eq!((m.n, m.list[0].id), (1, 2)); - let q = m.poll(100).unwrap(); - assert_eq!(&q[..], [b'R', b'1', b'Q', 2, 0x12, 0x7D, 0xAE, 0xE7, 0xCB]); - // no answer, then the app is closed: the cache still holds the tick - let mut blob = [0u8; BLOB_MAX]; - let n = m.save(&mut blob); - let mut back = Model::new(); - back.load(&blob[..n]); - assert_eq!((back.n, back.done_n, back.done[0], back.fetched), (1, 1, 0xCBE7AE7D, Some(WALL))); - back.ask_now(0); - let q = back.poll(0).unwrap(); - assert_eq!(q[4], 0x12); // the completion first - // a list that still has it (the phone answered before completing) doesn't bring the row back - let l = back.poll(0).unwrap(); - assert_eq!(l[4], 0x11); - assert_eq!(back.reply(&msg(l[3], 0, 0, 2, &rec(0xCBE7AE7D, Some(0), None, "a")), 1, WALL), Got::Nothing); - assert_eq!(back.reply(&msg(l[3], 0, 1, 2, &rec(2, None, None, "b")), 1, WALL), Got::Saved); - assert_eq!(back.n, 1); - // UNAVAILABLE: later; OK: off the queue, and the list again - assert_eq!(back.reply(&msg(q[3], rpc::UNAVAILABLE, 0, 0, &[]), 2, WALL), Got::Nothing); - assert_eq!(back.wait(2), LATER_MS); - let q = back.poll(2 + LATER_MS).unwrap(); - assert_eq!(back.reply(&msg(q[3], rpc::OK, 0, 0, &[]), 3, WALL), Got::Saved); - assert_eq!((back.done_n, back.wait(3)), (0, 0)); - // a bad blob loads as nothing - let mut junk = Model::new(); - junk.load(&blob[..n - 1]); - junk.load(b"M2\0\0\0\0\0\0"); - assert_eq!((junk.n, junk.fetched, junk.done_n), (0, None, 0)); - } -} diff --git a/apps/reminders/src/screen.rs b/apps/reminders/src/screen.rs deleted file mode 100644 index da2387b..0000000 --- a/apps/reminders/src/screen.rs +++ /dev/null @@ -1,354 +0,0 @@ -//! The two screens, in the stock look (`cmf_wp2_app::stock`): -//! - the list: the accent "Reminders" title, then a section per day (overdue in red first, today, tomorrow, later -//! days, no date), a row card per reminder with its list's colour as a dot, the title and its time; or one line -//! saying why there is nothing (allow on the phone, not an iPhone, all done); -//! - the confirm: "Done?", the reminder, Cancel and Done. -//! -//! Each screen is one root under `ROOT`, built hidden over as many batches as it needs and shown in the last one; -//! leaving it deletes the root and everything in it. - -use crate::model::{self, Model, Status, When, MAX}; -use cmf_wp2_app::lv::*; -use cmf_wp2_app::stock::{self, ACCENT, BLACK, CIRCLE, GREY, ROW_BG, ROW_PRESSED, SCREEN, WHITE}; - -/// Font slot of the 24 px font (the system font is slot 0). -pub const F24: u8 = 1; -/// Overdue: iOS Reminders' red, #FF3B30. -pub const RED: i32 = 0xF9C6; - -const ROW_1: i32 = 72; -const ROW_2: i32 = 100; -const HEAD_H: i32 = 40; -const TEXT_X: i16 = 64; -const MSG_W: i32 = 340; - -// bytes one row, its header included, can take: flush first when fewer are left -const GROUP: usize = 420; - -pub type Flush<'a> = dyn FnMut(&mut Batch) -> Result<(), LvError> + 'a; - -fn room(b: &mut Batch, flush: &mut Flush) -> Result<(), LvError> { - if b.bytes().len() + GROUP > BUF { flush(b) } else { Ok(()) } -} - -/// The fonts, in a batch of their own. -pub fn fonts(b: &mut Batch) -> Result<(), LvError> { - stock::font(b)?; - b.font(F24, StockFont::F24M) -} - -/// Black behind everything, the system font and white text: first, once. -pub fn theme(b: &mut Batch) -> Result<(), LvError> { - stock::theme(b)?; - b.style(ROOT, Prop::BgColor, 0, BLACK) -} - -/// What to say instead of the list when it is empty. -pub fn empty_text(m: &Model) -> &'static str { - match m.status { - Status::Ask => "Allow Reminders in FMC Companion on your phone", - Status::Denied => "Reminders are off for this app. Turn them on in FMC Companion: Apps, Reminders", - Status::Unavailable => "Reminders need an iPhone", - _ if m.silent() => "Phone not reachable", - Status::Waiting => "Asking your phone...", - Status::Ok => "All done", - } -} - -/// A line under a list from the cache, when the phone isn't giving a fresh one. -pub fn note(m: &Model) -> Option<&'static str> { - match m.status { - Status::Ask => Some("Allow Reminders in FMC Companion"), - Status::Denied => Some("Reminders are off in FMC Companion"), - Status::Unavailable => Some("Reminders need an iPhone"), - _ if m.silent() => Some("Phone not reachable"), - _ => None, - } -} - -fn root(b: &mut Batch) -> Result { - let r = b.create(Class::Obj, ROOT)?; - b.size(r, SCREEN, SCREEN)?; - for p in [Prop::PadTop, Prop::PadLeft, Prop::PadRight, Prop::BorderWidth, Prop::BgOpa, Prop::Radius] { - b.style(r, p, 0, 0)?; - } - b.style(r, Prop::TextAlign, 0, 2)?; // LV_TEXT_ALIGN_CENTER, inherited by every label - b.flags(r, &[Flag::Hidden], &[Flag::Scrollable])?; - Ok(r) -} - -fn label(b: &mut Batch, parent: Obj, text: &str, w: i32, x: i16, y: i32) -> Result { - let l = b.create(Class::Label, parent)?; - b.size(l, w, CONTENT)?; - b.text(l, text)?; - b.align(l, Align::TopMid, x, y as i16)?; - Ok(l) -} - -fn title(b: &mut Batch, r: Obj, text: &str) -> Result { - let t = label(b, r, text, stock::ROW_W - 80, 0, stock::TITLE_Y)?; - b.style(t, Prop::TextColor, 0, ACCENT)?; - Ok(t) -} - -/// The crown scrolls it; then it shows. -fn finish(b: &mut Batch, r: Obj) -> Result<(), LvError> { - b.flags(r, &[Flag::Scrollable], &[])?; - b.style(r, Prop::PadBottom, 0, SCREEN / 2)?; // the last row can scroll up to the middle - b.scroll_bar(r)?; - b.knob(r)?; - b.flags(r, &[], &[Flag::Hidden]) -} - -#[derive(Clone, Copy, Debug)] -pub struct ListView { - pub root: Obj, - /// Row cards in screen order; a tap asks "Done?" for `index[k]`. - pub rows: [Obj; MAX], - /// The `Model::list` index of each row. - pub index: [u8; MAX], - pub n: usize, -} - -/// The list at `wall` (minutes, `model::wall_min`). -pub fn list_view(b: &mut Batch, flush: &mut Flush, m: &Model, wall: i32) -> Result { - room(b, flush)?; - let r = root(b)?; - title(b, r, "Reminders")?; - let (order, n) = m.order(wall); - let mut v = ListView { root: r, rows: [ROOT; MAX], index: order, n }; - let mut y = stock::TOP; - if n == 0 { - let l = label(b, r, empty_text(m), MSG_W, 0, y + 40)?; - b.long_mode(l, LongMode::Wrap)?; - if m.status != Status::Ok || m.silent() { - b.style(l, Prop::TextColor, 0, GREY)?; - } - return finish(b, r).map(|_| v); - } - let mut section = None; - for (k, &i) in order[..n].iter().enumerate() { - room(b, flush)?; - let i = i as usize; - let w = match m.when(i, wall) { - When::Later(d) if d > 1 => When::Later(d), // one section per day - w => w, - }; - if section != Some(w) { - section = Some(w); - let h = label(b, r, model::section_label(w, wall).as_str(), stock::ROW_W - 80, 0, y)?; - b.style(h, Prop::TextFont, 0, F24 as i32)?; - b.style(h, Prop::TextColor, 0, if w == When::Overdue { RED } else { GREY })?; - y += HEAD_H; - } - let rem = &m.list[i]; - let detail = model::detail(m, i, wall); - let h = if detail.as_str().is_empty() { ROW_1 } else { ROW_2 }; - let c = stock::card(b, r, h)?; - b.align(c, Align::TopMid, 0, y as i16)?; - b.events(c, &[Ev::Clicked])?; - b.style(c, Prop::BgColor, stock::PRESSED, ROW_PRESSED)?; - v.rows[k] = c; - let dot = b.create(Class::Obj, c)?; - b.flags(dot, &[], &[Flag::Clickable])?; // a press goes to the card - b.size(dot, 18, 18)?; - b.style(dot, Prop::Radius, 0, CIRCLE)?; - b.style(dot, Prop::BorderWidth, 0, 0)?; - b.style(dot, Prop::BgColor, 0, rem.color as i32)?; - b.style(dot, Prop::BgOpa, 0, 255)?; - b.align(dot, Align::LeftMid, 30, 0)?; - let t = b.create(Class::Label, c)?; - // one line ending in "...": with CONTENT height a long title would wrap out of the card - b.size(t, stock::ROW_W - TEXT_X as i32 - 44, 40)?; - b.long_mode(t, LongMode::Dot)?; - b.style(t, Prop::TextAlign, 0, 1)?; // LV_TEXT_ALIGN_LEFT: the root centres - b.text(t, model::title(rem))?; - if rem.title.is_empty() { - b.style(t, Prop::TextColor, 0, GREY)?; - } - if h == ROW_1 { - b.align(t, Align::LeftMid, TEXT_X, 0)?; - } else { - b.align(t, Align::TopLeft, TEXT_X, 12)?; - let d = b.create(Class::Label, c)?; - b.style(d, Prop::TextFont, 0, F24 as i32)?; - b.style(d, Prop::TextColor, 0, if w == When::Overdue { RED } else { GREY })?; - b.text(d, detail.as_str())?; - b.align(d, Align::TopLeft, TEXT_X, 56)?; - } - y += h + stock::ROW_GAP; - } - if let Some(t) = note(m) { - let l = label(b, r, t, MSG_W, 0, y + 8)?; - b.style(l, Prop::TextFont, 0, F24 as i32)?; - b.style(l, Prop::TextColor, 0, GREY)?; - b.long_mode(l, LongMode::Wrap)?; - } - finish(b, r)?; - Ok(v) -} - -#[derive(Clone, Copy, Debug)] -pub struct ConfirmView { - pub root: Obj, - pub done: Obj, - pub cancel: Obj, - /// The reminder asked about (its index may change while the screen is up). - pub id: u32, -} - -fn button(b: &mut Batch, r: Obj, text: &str, bg: i32, x: i16) -> Result { - let btn = b.create(Class::Btn, r)?; - b.size(btn, 170, 84)?; - b.style(btn, Prop::Radius, 0, CIRCLE)?; - b.style(btn, Prop::BorderWidth, 0, 0)?; - b.style(btn, Prop::BgColor, 0, bg)?; - b.style(btn, Prop::BgOpa, 0, 255)?; - b.style(btn, Prop::BgColor, stock::PRESSED, ROW_PRESSED)?; - b.align(btn, Align::TopMid, x, 286)?; - b.events(btn, &[Ev::Clicked])?; - let l = b.create(Class::Label, btn)?; - b.style(l, Prop::TextColor, 0, WHITE)?; - b.text(l, text)?; - b.align(l, Align::Center, 0, 0)?; - Ok(btn) -} - -/// "Done?" for reminder `i`. -pub fn confirm_view(b: &mut Batch, flush: &mut Flush, m: &Model, i: usize, wall: i32) -> Result { - room(b, flush)?; - let r = root(b)?; - title(b, r, "Done?")?; - let rem = &m.list[i]; - let t = label(b, r, model::title(rem), MSG_W, 0, 120)?; - b.long_mode(t, LongMode::Wrap)?; - if rem.title.is_empty() { - b.style(t, Prop::TextColor, 0, GREY)?; - } - let mut when = model::detail(m, i, wall); - if when.as_str().is_empty() { - if let Some(d) = m.day(i, wall) { - model::day_label(d, wall, &mut when); - } - } - let d = label(b, r, when.as_str(), MSG_W, 0, 232)?; - b.style(d, Prop::TextFont, 0, F24 as i32)?; - b.style(d, Prop::TextColor, 0, if m.when(i, wall) == When::Overdue { RED } else { GREY })?; - room(b, flush)?; - let cancel = button(b, r, "Cancel", ROW_BG, -92)?; - let done = button(b, r, "Done", ACCENT, 92)?; - b.flags(r, &[], &[Flag::Hidden])?; - Ok(ConfirmView { root: r, done, cancel, id: rem.id }) -} - -/// Deletes a screen. -pub fn leave(b: &mut Batch, root: Obj) -> Result<(), LvError> { - if root != ROOT { b.del(root) } else { Ok(()) } -} - -#[cfg(test)] -mod tests { - extern crate std; - use super::*; - use crate::model::BLOB_MAX; - use std::boxed::Box; - use std::vec::Vec; - use wp2_core::lvcmd::{self, Table}; - - // 2026-11-19 10:00 - const WALL: i32 = 20_776 * 1440 + 600; - const FONTS: u8 = 0b11; - - fn batch() -> Batch { - Batch::with_buf(Box::leak(Box::new([0; BUF]))) - } - - /// Runs `build` with a flush that validates each batch against the loader's table and applies it; returns - /// the result and the batches' sizes. - fn run(t: &mut Table, b: &mut Batch, build: impl FnOnce(&mut Batch, &mut Flush) -> Result) - -> (T, Vec) { - let sizes = std::cell::RefCell::new(Vec::new()); - let mut flush = |b: &mut Batch| -> Result<(), LvError> { - assert_eq!(lvcmd::validate(b.bytes(), t, FONTS), Ok(())); - for r in lvcmd::records(b.bytes()) { - lvcmd::apply(t, &r.unwrap()); - } - sizes.borrow_mut().push(b.bytes().len()); - b.clear(); - Ok(()) - }; - let out = build(b, &mut flush).unwrap(); - flush(b).unwrap(); - (out, sizes.into_inner()) - } - - /// A model with `n` reminders over every section, long titles, half of them hidden. - fn full(n: usize) -> Model { - let mut blob = Vec::from(*b"M1"); - blob.extend(WALL.to_le_bytes()); - blob.push(n as u8); - for k in 0..n { - let day = k as i8 - 3; - let hidden = k % 2 == 1; - let mut r = (k as u32 + 1).to_le_bytes().to_vec(); - r.push(day as u8); - r.extend(((k as u16 * 97) % 1440).to_le_bytes()); - r.push(if k % 5 == 4 { 0 } else { 1 | ((k % 3 == 0) as u8) << 1 } | (hidden as u8) << 2); - r.extend(0x2D7Fu16.to_le_bytes()); - if !hidden { - r.extend("Позвонить в банк насчёт карты и заодно спросить про вклад".as_bytes()[..64].iter()); - } - blob.push(r.len() as u8); - blob.extend(r); - } - blob.push(0); - assert!(blob.len() <= BLOB_MAX); - let mut m = Model::new(); - m.load(&blob); - assert_eq!(m.n, n); - m - } - - #[test] - fn fonts_validate_on_their_own() { - let mut b = batch(); - fonts(&mut b).unwrap(); - assert_eq!(lvcmd::validate(b.bytes(), &Table::new(), 0), Ok(())); - } - - #[test] - fn list_and_confirm_validate_within_the_budgets_and_free_everything() { - for n in [0, 1, 7, MAX] { - let m = full(n); - let mut t = Table::new(); - let mut b = batch(); - let (v, sizes) = run(&mut t, &mut b, |b, f| { - theme(b)?; - list_view(b, f, &m, WALL) - }); - assert!(sizes.iter().all(|&s| s <= BUF)); - std::println!("list of {n}: {} batches, {sizes:?} B", sizes.len()); - assert_eq!(v.n, n); - assert!(v.rows[..n].iter().all(|&r| r != ROOT)); - // a tap: the confirm, then back; leaving frees every handle, so the list comes back on the same ones - let (_, _) = run(&mut t, &mut b, |b, _| leave(b, v.root)); - if n > 0 { - let (c, _) = run(&mut t, &mut b, |b, f| confirm_view(b, f, &m, v.index[0] as usize, WALL)); - assert_ne!(c.done, c.cancel); - let (_, _) = run(&mut t, &mut b, |b, _| leave(b, c.root)); - } - let (w, _) = run(&mut t, &mut b, |b, f| list_view(b, f, &m, WALL)); - assert_eq!((w.root, w.rows), (v.root, v.rows)); - } - } - - #[test] - fn empty_states() { - let mut m = Model::new(); - assert_eq!(empty_text(&m), "Asking your phone..."); - m.status = Status::Unavailable; - assert_eq!(empty_text(&m), "Reminders need an iPhone"); - m.status = Status::Ok; - assert_eq!((empty_text(&m), note(&m)), ("All done", None)); - } -} diff --git a/apps/reminders/store.md b/apps/reminders/store.md deleted file mode 100644 index f42bbc7..0000000 --- a/apps/reminders/store.md +++ /dev/null @@ -1,22 +0,0 @@ -Your iPhone's open reminders on the watch. Overdue ones come first in red, then today's, then the next days and the -ones without a date, each with its list's colour as a dot. The crown scrolls. Tap one and confirm **Done** to tick it -off on the phone: the watch buzzes once and the row goes. - -Long-press **Reminders** in Apps and choose **Add widget** for a card next to the watch face with how many are due -today and the next one. - -The watch asks the phone when you open the app and every 3 minutes while it's open, and keeps the last list, so it -opens at once without the phone. A reminder ticked off while the phone is away is sent when it's back. - -Titles stay on the phone by default and the watch shows "Reminder" and the time. To see them, turn on "Show text on -the watch" for Reminders in FMC Companion: anyone near enough to the watch's Bluetooth could read them too. - -The first time, the watch says "Allow Reminders in FMC Companion on your phone": open FMC Companion, Apps, Reminders, -and allow it (iOS then asks for access to your reminders). - -## Requirements - -- An **iPhone** with **FMC Companion**, paired with the watch. Android has no system reminders other apps can read, - so on Android the app only says "Reminders need an iPhone". -- The [patched firmware](/firmware) with the channel key (2026-11-13 or later) and the [App Loader](/firmware) - (2026-11-15 or later for the widget). diff --git a/apps/reminders/store.toml b/apps/reminders/store.toml deleted file mode 100644 index db2614f..0000000 --- a/apps/reminders/store.toml +++ /dev/null @@ -1,6 +0,0 @@ -# The app's listing in the FMC store (README.md, "store.toml"). The page's body is store.md. -name = "Reminders" -summary = "Your iPhone's open reminders on the wrist: overdue, today and later, tick them off with a tap" -version = "0.1.0" -author = "Egor Kolesnikov" -screenshots = ["shots/list.png", "shots/confirm.png", "shots/allow.png"] diff --git a/apps/site-calc/Cargo.toml b/apps/site-calc/Cargo.toml deleted file mode 100644 index 9fe1eed..0000000 --- a/apps/site-calc/Cargo.toml +++ /dev/null @@ -1,12 +0,0 @@ -[package] -name = "site-calc" -edition.workspace = true -license.workspace = true -version.workspace = true - -[dependencies] -cmf-wp2-app.workspace = true - -[[bin]] -name = "site-calc" -bench = false diff --git a/apps/site-calc/icon.svg b/apps/site-calc/icon.svg deleted file mode 100644 index 2a0b666..0000000 --- a/apps/site-calc/icon.svg +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/apps/site-calc/src/calc.rs b/apps/site-calc/src/calc.rs deleted file mode 100644 index eeed61a..0000000 --- a/apps/site-calc/src/calc.rs +++ /dev/null @@ -1,271 +0,0 @@ -//! Pure calculator logic in 4-decimal fixed point, plus the site unit conversions. No hardware, host-tested. - -pub const SCALE: i64 = 10_000; -/// Longest string shown (digits, dot, minus). -pub const MAX_CHARS: usize = 9; -const LIMIT: i128 = 1_000_000_000 * SCALE as i128; - -#[derive(Clone, Copy, Debug, PartialEq, Eq)] -pub enum Op { Add, Sub, Mul, Div } - -#[derive(Clone, Copy, Debug, PartialEq, Eq)] -pub enum Key { Digit(u8), Dot, Op(Op), Eq, Clear, Back } - -#[derive(Clone, Copy, Debug)] -pub struct Calc { - acc: i64, - op: Option, - buf: [u8; MAX_CHARS], - len: usize, - typing: bool, - after_eq: bool, - shown: i64, - err: bool, -} - -impl Calc { - pub const fn new() -> Self { - Self { acc: 0, op: None, buf: [0; MAX_CHARS], len: 0, typing: false, after_eq: false, shown: 0, err: false } - } - - pub fn error(&self) -> bool { self.err } - pub fn pending(&self) -> Option { self.op } - - fn parse(&self) -> i64 { - let (mut int, mut frac, mut fd, mut dot) = (0i64, 0i64, 0u32, false); - for &c in &self.buf[..self.len] { - if c == b'.' { dot = true; continue; } - let d = (c - b'0') as i64; - if dot { if fd < 4 { frac = frac * 10 + d; fd += 1; } } else { int = int * 10 + d; } - } - while fd < 4 { frac *= 10; fd += 1; } - int * SCALE + frac - } - - /// The value the next operation would use. - pub fn value(&self) -> i64 { if self.typing { self.parse() } else { self.shown } } - - fn apply(a: i64, op: Op, b: i64) -> Option { - let (x, y) = (a as i128, b as i128); - let r = match op { - Op::Add => x + y, - Op::Sub => x - y, - Op::Mul => round_div(x * y, SCALE as i128), - Op::Div => { if y == 0 { return None; } round_div(x * SCALE as i128, y) } - }; - (r.abs() < LIMIT).then_some(r as i64) - } - - fn set_err(&mut self) { self.err = true; self.typing = false; self.op = None; self.acc = 0; self.shown = 0; } - - pub fn press(&mut self, key: Key) { - if self.err && key != Key::Clear { return; } - match key { - Key::Clear => *self = Self::new(), - Key::Digit(d) => { - self.start_typing(); - if self.len == 1 && self.buf[0] == b'0' { self.len = 0; } - let decimals = self.buf[..self.len].iter().position(|&c| c == b'.').map(|p| self.len - p - 1).unwrap_or(0); - if self.len < MAX_CHARS && decimals < 4 { self.buf[self.len] = b'0' + d.min(9); self.len += 1; } - } - Key::Dot => { - self.start_typing(); - if self.len == 0 { self.buf[0] = b'0'; self.len = 1; } - if !self.buf[..self.len].contains(&b'.') && self.len < MAX_CHARS { self.buf[self.len] = b'.'; self.len += 1; } - } - Key::Back => { - if self.typing && self.len > 0 { self.len -= 1; } - } - Key::Op(op) => { - let cur = self.value(); - match self.op { - Some(prev) if self.typing => match Self::apply(self.acc, prev, cur) { - Some(v) => { self.acc = v; } - None => { self.set_err(); return; } - }, - Some(_) => {} - None => self.acc = cur, - } - self.op = Some(op); - self.shown = self.acc; - self.typing = false; - self.after_eq = false; - } - Key::Eq => { - if let Some(op) = self.op { - let cur = self.value(); - match Self::apply(self.acc, op, cur) { - Some(v) => { self.acc = v; self.shown = v; } - None => { self.set_err(); return; } - } - self.op = None; - self.typing = false; - self.after_eq = true; - } - } - } - } - - fn start_typing(&mut self) { - if !self.typing { - if self.after_eq { self.acc = 0; self.op = None; self.after_eq = false; } - self.typing = true; - self.len = 0; - } - } - - /// Text for the main display. Returns its length. - pub fn display(&self, out: &mut [u8; 12]) -> usize { - if self.err { out[..3].copy_from_slice(b"ERR"); return 3; } - if self.typing { - if self.len == 0 { out[0] = b'0'; return 1; } - out[..self.len].copy_from_slice(&self.buf[..self.len]); - return self.len; - } - format(self.shown, out) - } -} - -fn round_div(n: i128, d: i128) -> i128 { - let half = d.abs() / 2; - if (n >= 0) == (d > 0) { (n + if n >= 0 { half } else { -half }) / d } else { (n - if n >= 0 { half } else { -half }) / d } -} - -/// Formats a fixed-point value into at most `MAX_CHARS` characters, rounding the decimals to fit and trimming zeros. -pub fn format(v: i64, out: &mut [u8; 12]) -> usize { - let neg = v < 0; - let mut mag = (v as i128).abs(); - let mut int = (mag / SCALE as i128) as u64; - let mut int_digits = [0u8; 12]; - let mut n = 0; - let mut t = int; - if t == 0 { int_digits[0] = b'0'; n = 1; } else { while t > 0 { int_digits[n] = b'0' + (t % 10) as u8; t /= 10; n += 1; } } - let room = MAX_CHARS as i32 - n as i32 - neg as i32 - 1; // decimals that fit after the dot - let dec = room.clamp(0, 4) as u32; - let unit = 10i128.pow(4 - dec); - mag = round_div(mag, unit) * unit; // round to `dec` decimals - int = (mag / SCALE as i128) as u64; - // rounding may add an integer digit: recompute - n = 0; t = int; - if t == 0 { int_digits[0] = b'0'; n = 1; } else { while t > 0 { int_digits[n] = b'0' + (t % 10) as u8; t /= 10; n += 1; } } - let mut frac = ((mag % SCALE as i128) / unit) as u32; - let mut len = 0; - if neg && mag != 0 { out[len] = b'-'; len += 1; } - for i in (0..n).rev() { out[len] = int_digits[i]; len += 1; } - if frac != 0 && dec > 0 { - let mut digits = [b'0'; 4]; - for i in (0..dec as usize).rev() { digits[i] = b'0' + (frac % 10) as u8; frac /= 10; } - let mut end = dec as usize; - while end > 0 && digits[end - 1] == b'0' { end -= 1; } - out[len] = b'.'; len += 1; - for &d in &digits[..end] { out[len] = d; len += 1; } - } - len -} - -/// Site conversions: `factor` is the multiplier times 1,000,000. -pub struct Pair { pub label: &'static str, pub unit: &'static str, pub factor: i64 } - -pub const PAIRS: [Pair; 12] = [ - Pair { label: "m > ft", unit: "ft", factor: 3_280_840 }, - Pair { label: "ft > m", unit: "m", factor: 304_800 }, - Pair { label: "mm > in", unit: "in", factor: 39_370 }, - Pair { label: "in > mm", unit: "mm", factor: 25_400_000 }, - Pair { label: "m2 > ft2", unit: "ft2", factor: 10_763_910 }, - Pair { label: "ft2 > m2", unit: "m2", factor: 92_903 }, - Pair { label: "m3 > L", unit: "L", factor: 1_000_000_000 }, - Pair { label: "L > m3", unit: "m3", factor: 1_000 }, - Pair { label: "m3 > yd3", unit: "yd3", factor: 1_307_951 }, - Pair { label: "kg > lb", unit: "lb", factor: 2_204_623 }, - Pair { label: "lb > kg", unit: "kg", factor: 453_592 }, - Pair { label: "L > gal", unit: "gal", factor: 264_172 }, -]; - -/// Converts a fixed-point value; `None` when it would overflow the display range. -pub fn convert(value: i64, pair: usize) -> Option { - let f = PAIRS[pair % PAIRS.len()].factor as i128; - let r = round_div(value as i128 * f, 1_000_000); - (r.abs() < LIMIT).then_some(r as i64) -} - -#[cfg(test)] -mod tests { - use super::*; - - fn run(keys: &[Key]) -> ([u8; 12], usize) { - let mut c = Calc::new(); - for &k in keys { c.press(k); } - let mut out = [0u8; 12]; - let n = c.display(&mut out); - (out, n) - } - fn text(keys: &[Key]) -> String { let (o, n) = run(keys); String::from_utf8(o[..n].to_vec()).unwrap() } - fn d(n: u8) -> Key { Key::Digit(n) } - - #[test] - fn adds_and_multiplies() { - assert_eq!(text(&[d(1), d(2), Key::Op(Op::Add), d(3), Key::Eq]), "15"); - assert_eq!(text(&[d(2), Key::Dot, d(5), Key::Op(Op::Mul), d(4), Key::Eq]), "10"); - } - #[test] - fn chains_left_to_right() { - assert_eq!(text(&[d(2), Key::Op(Op::Add), d(3), Key::Op(Op::Mul), d(4), Key::Eq]), "20"); - } - #[test] - fn division_rounds_and_trims() { - assert_eq!(text(&[d(1), Key::Op(Op::Div), d(3), Key::Eq]), "0.3333"); - assert_eq!(text(&[d(7), Key::Op(Op::Div), d(2), Key::Eq]), "3.5"); - } - #[test] - fn divide_by_zero_is_error_and_clear_recovers() { - let mut c = Calc::new(); - for k in [d(5), Key::Op(Op::Div), d(0), Key::Eq] { c.press(k); } - assert!(c.error()); - c.press(d(3)); assert!(c.error()); - c.press(Key::Clear); assert!(!c.error()); - } - #[test] - fn typing_rules() { - assert_eq!(text(&[d(0), d(0), d(7)]), "7"); - assert_eq!(text(&[Key::Dot, d(5)]), "0.5"); - assert_eq!(text(&[d(1), Key::Dot, d(2), Key::Dot, d(3)]), "1.23"); - assert_eq!(text(&[d(1), Key::Dot, d(2), d(3), d(4), d(5), d(6)]), "1.2345"); - assert_eq!(text(&[d(1), d(2), d(3), Key::Back]), "12"); - assert_eq!(text(&[d(1), d(2), d(3), d(4), d(5), d(6), d(7), d(8), d(9), d(1)]), "123456789"); - } - #[test] - fn digit_after_equals_starts_fresh() { - assert_eq!(text(&[d(2), Key::Op(Op::Add), d(3), Key::Eq, d(9)]), "9"); - } - #[test] - fn negative_results() { - assert_eq!(text(&[d(3), Key::Op(Op::Sub), d(5), Key::Eq]), "-2"); - } - #[test] - fn large_results_fit_the_display() { - let (o, n) = run(&[d(9), d(9), d(9), d(9), d(9), Key::Op(Op::Mul), d(9), d(9), d(9), d(9), d(9), Key::Eq]); - assert!(n <= MAX_CHARS, "{:?}", String::from_utf8_lossy(&o[..n])); - assert_eq!(text(&[d(9), d(9), d(9), d(9), d(9), d(9), d(9), d(9), d(9), Key::Op(Op::Mul), d(9), d(9), d(9), Key::Eq]), "ERR"); - } - #[test] - fn format_rounds_to_fit() { - let mut out = [0u8; 12]; - let n = format(12345 * SCALE + 6789, &mut out); // 12345.6789 -> 9 chars: 12345.679 - assert_eq!(&out[..n], b"12345.679"); - let n = format(-5 * SCALE / 2, &mut out); - assert_eq!(&out[..n], b"-2.5"); - let n = format(99_999 * SCALE + 9_999, &mut out); - assert_eq!(&out[..n], b"100000"); - } - #[test] - fn conversions() { - let f = |v: i64, p: usize| { let mut o = [0u8; 12]; let n = format(convert(v * SCALE, p).unwrap(), &mut o); String::from_utf8(o[..n].to_vec()).unwrap() }; - assert_eq!(f(1, 0), "3.2808"); - assert_eq!(f(10, 1), "3.048"); - assert_eq!(f(100, 3), "2540"); - assert_eq!(f(1, 6), "1000"); - assert_eq!(f(1, 8), "1.308"); - assert_eq!(f(100, 9), "220.4623"); - assert_eq!(f(1, 10), "0.4536"); - } -} diff --git a/apps/site-calc/src/main.rs b/apps/site-calc/src/main.rs deleted file mode 100644 index 77b5575..0000000 --- a/apps/site-calc/src/main.rs +++ /dev/null @@ -1,201 +0,0 @@ -//! site-calc: a calculator for the site. Four operations in 4-decimal fixed point, and a Convert mode for the -//! conversions a site coordinator needs (m/ft, mm/in, m2/ft2, m3/L/yd3, kg/lb, L/gal). The crown picks the -//! conversion. Touch only; the crown press or a right swipe exits. The logic is in `calc.rs` (host-tested). -#![cfg_attr(any(target_os = "none", wp2_sim), no_main, cfg_attr(target_os = "none", no_std))] - -#[cfg_attr(not(any(target_os = "none", wp2_sim)), allow(dead_code))] -mod calc; - -#[cfg(not(any(target_os = "none", wp2_sim)))] -fn main() {} - -#[cfg(any(target_os = "none", wp2_sim))] -mod device { - use crate::calc::{self, Calc, Key, Op, PAIRS}; - use cmf_wp2_app::{Api, BUTTON, CROWN, PAUSE, RESUME, TOUCH_DOWN}; - - cmf_wp2_app::entry!(main); - cmf_wp2_app::app_icon!(); - - const BG: u16 = 0x0000; - const WHITE: u16 = 0xFFFF; - const KEY: u16 = 0x2124; - const ORANGE: u16 = 0xFD20; - const MINT: u16 = 0x07E0; - const RED: u16 = 0xB000; - const GREY: u16 = 0x8410; - - const KX: i16 = 75; - const KW: i16 = 76; - const KGAP: i16 = 4; - const KY: i16 = 178; - const KH: i16 = 47; - const FY: i16 = 134; - const FH: i16 = 38; - const FW: i16 = 100; - const FGAP: i16 = 8; - - // rows of the keypad - const PAD: [[Key; 4]; 4] = [ - [Key::Digit(7), Key::Digit(8), Key::Digit(9), Key::Op(Op::Div)], - [Key::Digit(4), Key::Digit(5), Key::Digit(6), Key::Op(Op::Mul)], - [Key::Digit(1), Key::Digit(2), Key::Digit(3), Key::Op(Op::Sub)], - [Key::Digit(0), Key::Dot, Key::Eq, Key::Op(Op::Add)], - ]; - const LABELS: [[&str; 4]; 4] = [["7", "8", "9", "/"], ["4", "5", "6", "x"], ["1", "2", "3", "-"], ["0", ".", "=", "+"]]; - - #[derive(Clone, Copy, PartialEq, Eq)] - enum Mode { Calc, Convert } - - // seven segments: a b c d e f g - fn segs(ch: u8) -> u8 { - match ch { - b'0' => 0b0111111, b'1' => 0b0000110, b'2' => 0b1011011, b'3' => 0b1001111, b'4' => 0b1100110, - b'5' => 0b1101101, b'6' => 0b1111101, b'7' => 0b0000111, b'8' => 0b1111111, b'9' => 0b1101111, - b'-' => 0b1000000, _ => 0, - } - } - - fn big_digit(api: &Api, x: i16, y: i16, ch: u8, col: u16) { - const W: i16 = 22; - const H: i16 = 40; - const T: i16 = 4; - let s = segs(ch); - let hw = (W - 2 * T) as u16; - let vh = (H / 2 - T) as u16; - let t = T as u16; - if s & 1 != 0 { api.rect(x + T, y, hw, t, col); } - if s & 2 != 0 { api.rect(x + W - T, y + T, t, vh, col); } - if s & 4 != 0 { api.rect(x + W - T, y + H / 2, t, vh, col); } - if s & 8 != 0 { api.rect(x + T, y + H - T, hw, t, col); } - if s & 16 != 0 { api.rect(x, y + H / 2, t, vh, col); } - if s & 32 != 0 { api.rect(x, y + T, t, vh, col); } - if s & 64 != 0 { api.rect(x + T, y + H / 2 - T / 2, hw, t, col); } - } - - fn big_text(api: &Api, text: &[u8], right: i16, y: i16, col: u16) { - let width: i16 = text.iter().map(|&c| if c == b'.' { 12 } else { 28 }).sum(); - let mut x = right - width; - for &c in text { - if c == b'.' { api.rect(x + 3, y + 35, 5, 5, col); x += 12; } else { big_digit(api, x, y, c, col); x += 28; } - } - } - - fn key_box(api: &Api, x: i16, y: i16, w: i16, h: i16, fill: u16, label: &str, fg: u16) { - api.rect(x, y, w as u16, h as u16, fill); - let tx = x + (w - label.len() as i16 * 16) / 2; - api.text(tx, y + (h - 16) / 2, label, fg); - } - - fn write(buf: &mut [u8; 32], len: &mut usize, s: &[u8]) { for &b in s { if *len < 32 { buf[*len] = b; *len += 1; } } } - - fn draw(api: &Api, c: &Calc, mode: Mode, pair: usize) { - api.rect(0, 0, api.width, api.height, BG); - let mut out = [0u8; 12]; - let n = c.display(&mut out); - let col = if c.error() { RED } else { WHITE }; - big_text(api, &out[..n], 372, 44, col); - - // label line and result line - match mode { - Mode::Calc => { - let sym = match c.pending() { Some(Op::Add) => "+", Some(Op::Sub) => "-", Some(Op::Mul) => "x", Some(Op::Div) => "/", None => "" }; - if !sym.is_empty() { api.text(233 - 8, 92, sym, ORANGE); } - } - Mode::Convert => { - let p = &PAIRS[pair]; - api.text(233 - 8 * p.label.len() as i16, 92, p.label, ORANGE); - let mut buf = [0u8; 32]; - let mut len = 0; - write(&mut buf, &mut len, b"= "); - match calc::convert(c.value(), pair) { - Some(v) => { - let mut o = [0u8; 12]; - let m = calc::format(v, &mut o); - write(&mut buf, &mut len, &o[..m]); - } - None => write(&mut buf, &mut len, b"ERR"), - } - write(&mut buf, &mut len, b" "); - write(&mut buf, &mut len, p.unit.as_bytes()); - api.text(233 - 8 * len as i16, 112, core::str::from_utf8(&buf[..len]).unwrap_or(""), MINT); - } - } - - // function row: C, back, mode - key_box(api, KX, FY, FW, FH, RED, "C", WHITE); - key_box(api, KX + FW + FGAP, FY, FW, FH, KEY, "<-", WHITE); - let label = if mode == Mode::Calc { "CONV" } else { "CALC" }; - key_box(api, KX + 2 * (FW + FGAP), FY, FW, FH, KEY, label, ORANGE); - - for (r, row) in PAD.iter().enumerate() { - for (k, key) in row.iter().enumerate() { - let x = KX + k as i16 * (KW + KGAP); - let y = KY + r as i16 * (KH + KGAP); - let (fill, fg) = match key { - Key::Op(_) => (ORANGE, BG), - Key::Eq => (MINT, BG), - _ => (KEY, WHITE), - }; - // in Convert mode the operators and = do nothing: grey them out - let dead = mode == Mode::Convert && matches!(key, Key::Op(_) | Key::Eq); - if dead { key_box(api, x, y, KW, KH, KEY, LABELS[r][k], GREY); } else { key_box(api, x, y, KW, KH, fill, LABELS[r][k], fg); } - } - } - api.show(); - } - - fn inside(x: i16, y: i16, bx: i16, by: i16, w: i16, h: i16) -> bool { x >= bx && x < bx + w && y >= by && y < by + h } - - fn main(api: &'static Api) -> i32 { - let mut c = Calc::new(); - let mut mode = Mode::Calc; - let mut pair = 0usize; - api.own_back(true); - draw(api, &c, mode, pair); - loop { - let Some(e) = api.event(u32::MAX) else { continue }; - let mut changed = false; - match e.kind { - BUTTON => { api.own_back(false); return 0; } - PAUSE => loop { - match api.event(u32::MAX).map(|e| e.kind) { - Some(RESUME) => { changed = true; break; } - Some(BUTTON) => { api.own_back(false); return 0; } - _ => {} - } - }, - CROWN if e.delta != 0 && mode == Mode::Convert => { - let n = PAIRS.len(); - pair = if e.delta > 0 { (pair + 1) % n } else { (pair + n - 1) % n }; - changed = true; - } - TOUCH_DOWN => { - let (x, y) = (e.x, e.y); - if inside(x, y, KX, FY, FW, FH) { c.press(Key::Clear); changed = true; } - else if inside(x, y, KX + FW + FGAP, FY, FW, FH) { c.press(Key::Back); changed = true; } - else if inside(x, y, KX + 2 * (FW + FGAP), FY, FW, FH) { - mode = if mode == Mode::Calc { Mode::Convert } else { Mode::Calc }; - c.press(Key::Clear); - changed = true; - } else { - 'find: for (r, row) in PAD.iter().enumerate() { - for (k, key) in row.iter().enumerate() { - let bx = KX + k as i16 * (KW + KGAP); - let by = KY + r as i16 * (KH + KGAP); - if inside(x, y, bx, by, KW, KH) { - let dead = mode == Mode::Convert && matches!(key, Key::Op(_) | Key::Eq); - if !dead { c.press(*key); changed = true; } - break 'find; - } - } - } - } - } - RESUME => changed = true, - _ => {} - } - if changed { draw(api, &c, mode, pair); } - } - } -} diff --git a/apps/site-calc/store.md b/apps/site-calc/store.md deleted file mode 100644 index aa6e115..0000000 --- a/apps/site-calc/store.md +++ /dev/null @@ -1,9 +0,0 @@ -A big-digit calculator for the site. Tap the keys for **+ - x /**, **C** clears, **<-** deletes the last digit. Values use four decimals. - -Tap **CONV** for Convert mode: type a value, turn the crown to pick the conversion, and the result shows under the number. Conversions: m to ft, ft to m, mm to in, in to mm, m2 to ft2, ft2 to m2, m3 to L, L to m3, m3 to yd3, kg to lb, lb to kg, L to gal. Tap **CALC** to go back. - -Press the crown or swipe right to exit. - -## Requirements - -The [patched firmware](/firmware) and the [App Loader](/firmware). Open it from the **Apps** row at the end of the watch's app list (list style, not the waterfall). diff --git a/apps/site-calc/store.toml b/apps/site-calc/store.toml deleted file mode 100644 index 7ca05f6..0000000 --- a/apps/site-calc/store.toml +++ /dev/null @@ -1,5 +0,0 @@ -# The app's listing in the FMC store (README.md, "store.toml"). The page's body is store.md. -name = "Site Calculator" -summary = "A calculator with site unit conversions: m/ft, mm/in, m2/ft2, m3/L/yd3, kg/lb, L/gal" -version = "0.1.0" -author = "Seerouven" diff --git a/apps/sketch/Cargo.toml b/apps/sketch/Cargo.toml deleted file mode 100644 index 27a3048..0000000 --- a/apps/sketch/Cargo.toml +++ /dev/null @@ -1,12 +0,0 @@ -[package] -name = "sketch" -edition.workspace = true -license.workspace = true -version.workspace = true - -[dependencies] -cmf-wp2-app.workspace = true - -[[bin]] -name = "sketch" -bench = false diff --git a/apps/sketch/icon.svg b/apps/sketch/icon.svg deleted file mode 100644 index d5476ba..0000000 --- a/apps/sketch/icon.svg +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/apps/sketch/src/lab.rs b/apps/sketch/src/lab.rs deleted file mode 100644 index 1cc5461..0000000 --- a/apps/sketch/src/lab.rs +++ /dev/null @@ -1,187 +0,0 @@ -pub const FREQUENCIES: [u16; 8] = [31, 62, 125, 250, 500, 1000, 4000, 16000]; -pub const STOCK_FREQUENCY: u16 = 31; -const GAP_MS: u16 = 80; -const CONTINUOUS_MS: u16 = 1000; - -#[derive(Clone, Copy, PartialEq, Debug)] -pub enum Pattern { - Continuous, - Tick, - DoubleTick, -} - -#[derive(Clone, Copy, PartialEq, Debug)] -pub enum Field { - Strength, - Frequency, - Pattern, - Pulse, -} - -#[derive(Clone, Copy, PartialEq, Debug)] -pub struct Step { - pub duty_permille: u16, - pub freq_hz: u16, - pub ms: u16, -} - -#[derive(Clone, Copy, PartialEq, Debug)] -pub struct Settings { - pub duty_permille: u16, - pub freq_hz: u16, - pub pattern: Pattern, - pub pulse_ms: u16, -} - -impl Default for Settings { - fn default() -> Self { - Settings { duty_permille: 200, freq_hz: STOCK_FREQUENCY, pattern: Pattern::Tick, pulse_ms: 20 } - } -} - -fn stepped(value: u16, clicks: i16, step: i32, min: i32, max: i32) -> u16 { - (value as i32 + clicks as i32 * step).clamp(min, max) as u16 -} - -impl Settings { - pub fn adjust(&mut self, field: Field, clicks: i16) { - match field { - Field::Strength => self.duty_permille = stepped(self.duty_permille, clicks, 50, 50, 1000), - Field::Pulse => self.pulse_ms = stepped(self.pulse_ms, clicks, 5, 5, 100), - Field::Frequency => { - let at = FREQUENCIES.iter().position(|&f| f >= self.freq_hz).unwrap_or(0); - let to = (at as i32 + clicks as i32).clamp(0, FREQUENCIES.len() as i32 - 1); - self.freq_hz = FREQUENCIES[to as usize]; - } - Field::Pattern => { - const ALL: [Pattern; 3] = [Pattern::Continuous, Pattern::Tick, Pattern::DoubleTick]; - let at = ALL.iter().position(|&p| p == self.pattern).unwrap_or(0) as i32; - self.pattern = ALL[(at + clicks as i32).rem_euclid(3) as usize]; - } - } - } - - pub fn steps(&self) -> ([Step; 3], usize) { - let on = |ms| Step { duty_permille: self.duty_permille, freq_hz: self.freq_hz, ms }; - let off = Step { duty_permille: 0, freq_hz: self.freq_hz, ms: GAP_MS }; - match self.pattern { - Pattern::Continuous => ([on(CONTINUOUS_MS), off, off], 1), - Pattern::Tick => ([on(self.pulse_ms), off, off], 1), - Pattern::DoubleTick => ([on(self.pulse_ms), off, on(self.pulse_ms)], 3), - } - } -} - -pub struct Player { - steps: [Step; 3], - len: usize, - at: usize, - freq_hz: u16, - active: bool, -} - -impl Player { - pub fn start(settings: &Settings) -> Self { - let (steps, len) = settings.steps(); - Player { steps, len, at: 0, freq_hz: settings.freq_hz, active: true } - } - - pub fn next(&mut self) -> Option { - if !self.active { - return None; - } - if self.at < self.len { - self.at += 1; - return Some(self.steps[self.at - 1]); - } - self.pause(); - Some(Step { duty_permille: 0, freq_hz: self.freq_hz, ms: 0 }) - } - - pub fn pause(&mut self) -> Step { - self.active = false; - Step { duty_permille: 0, freq_hz: self.freq_hz, ms: 0 } - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn strength_clamps() { - let mut s = Settings::default(); - s.adjust(Field::Strength, 1000); - assert_eq!(s.duty_permille, 1000); - s.adjust(Field::Strength, -1000); - assert_eq!(s.duty_permille, 50); - } - - #[test] - fn pulse_clamps() { - let mut s = Settings::default(); - s.adjust(Field::Pulse, -100); - assert_eq!(s.pulse_ms, 5); - s.adjust(Field::Pulse, 100); - assert_eq!(s.pulse_ms, 100); - } - - #[test] - fn frequency_steps_through_list() { - let mut s = Settings::default(); - assert_eq!(s.freq_hz, 31); - s.adjust(Field::Frequency, 1); - assert_eq!(s.freq_hz, 62); - s.adjust(Field::Frequency, 100); - assert_eq!(s.freq_hz, 16000); - s.adjust(Field::Frequency, -100); - assert_eq!(s.freq_hz, 31); - } - - #[test] - fn double_tick_steps() { - let s = Settings { duty_permille: 300, freq_hz: 200, pattern: Pattern::DoubleTick, pulse_ms: 15 }; - let (steps, n) = s.steps(); - assert_eq!(&steps[..n], &[Step { duty_permille: 300, freq_hz: 200, ms: 15 }, - Step { duty_permille: 0, freq_hz: 200, ms: 80 }, - Step { duty_permille: 300, freq_hz: 200, ms: 15 }]); - } - - #[test] - fn no_step_exceeds_limits() { - for pattern in [Pattern::Continuous, Pattern::Tick, Pattern::DoubleTick] { - let mut s = Settings { pattern, ..Settings::default() }; - s.adjust(Field::Strength, i16::MAX); - s.adjust(Field::Pulse, i16::MAX); - let (steps, n) = s.steps(); - assert!(steps[..n].iter().all(|st| st.duty_permille <= 1000 && st.ms <= 2000)); - } - } - - #[test] - fn pattern_cycles() { - let mut s = Settings { pattern: Pattern::DoubleTick, ..Settings::default() }; - s.adjust(Field::Pattern, 1); - assert_eq!(s.pattern, Pattern::Continuous); - s.adjust(Field::Pattern, -1); - assert_eq!(s.pattern, Pattern::DoubleTick); - } - - #[test] - fn pause_stops_playback() { - let s = Settings { duty_permille: 300, freq_hz: 200, pattern: Pattern::DoubleTick, pulse_ms: 15 }; - let mut p = Player::start(&s); - assert!(p.next().is_some()); - assert_eq!(p.pause().duty_permille, 0); - assert_eq!(p.next(), None); - } - - #[test] - fn player_ends_with_motor_off() { - let s = Settings { pattern: Pattern::Tick, ..Settings::default() }; - let mut p = Player::start(&s); - assert_eq!(p.next().unwrap().duty_permille, 200); - assert_eq!(p.next(), Some(Step { duty_permille: 0, freq_hz: 31, ms: 0 })); - assert_eq!(p.next(), None); - } -} diff --git a/apps/sketch/src/main.rs b/apps/sketch/src/main.rs deleted file mode 100644 index 7c4a458..0000000 --- a/apps/sketch/src/main.rs +++ /dev/null @@ -1,116 +0,0 @@ -#![cfg_attr(any(target_os = "none", wp2_sim), no_main, cfg_attr(target_os = "none", no_std))] - -#[cfg(not(any(target_os = "none", wp2_sim)))] -fn main() {} - -#[cfg(any(target_os = "none", wp2_sim))] -mod device { - use cmf_wp2_app::{Api, BUTTON, CROWN, RESUME, TOUCH_DOWN, TOUCH_UP}; - - cmf_wp2_app::entry!(main); - cmf_wp2_app::app_icon!(); - - const BLACK: u16 = 0x0000; - const WHITE: u16 = 0xFFFF; - const GREY: u16 = 0x39E7; - // branco, laranja, vermelho, verde, azul, amarelo - const COLORS: [u16; 6] = [0xFFFF, 0xFD20, 0xF800, 0x07E0, 0x001F, 0xFFE0]; - const BRUSH: i32 = 6; - const BAR: i16 = 60; - const MAX: usize = 150; - - #[derive(Clone, Copy)] - struct Seg { - x0: i16, - y0: i16, - x1: i16, - y1: i16, - c: u16, - } - - const EMPTY: Seg = Seg { x0: 0, y0: 0, x1: 0, y1: 0, c: 0 }; - - fn blob(api: &Api, x: i32, y: i32, c: u16) { - api.rect((x - BRUSH / 2) as i16, (y - BRUSH / 2) as i16, BRUSH as u16, BRUSH as u16, c); - } - - fn draw_seg(api: &Api, s: &Seg) { - let dx = s.x1 as i32 - s.x0 as i32; - let dy = s.y1 as i32 - s.y0 as i32; - let n = dx.abs().max(dy.abs()).max(1); - let mut i = 0; - while i <= n { - blob(api, s.x0 as i32 + dx * i / n, s.y0 as i32 + dy * i / n, s.c); - i += 3; - } - blob(api, s.x1 as i32, s.y1 as i32, s.c); - } - - fn redraw(api: &Api, segs: &[Seg; MAX], count: usize, color: u16) { - api.rect(0, 0, api.width, api.height, BLACK); - for s in segs.iter().take(count) { - draw_seg(api, s); - } - let top = api.height as i16 - BAR; - api.rect(0, top, api.width, BAR as u16, GREY); - api.text(api.width as i16 / 2 - 40, top + 18, "LIMPAR", WHITE); - api.rect(api.width as i16 / 2 + 60, top + 14, 30, 30, color); - api.show(); - } - - fn main(api: &'static Api) -> i32 { - let mut segs = [EMPTY; MAX]; - let mut count = 0usize; - let mut color_idx = 0usize; - let mut start = (0i16, 0i16); - let mut down = false; - let limit = api.height as i16 - BAR; - - redraw(api, &segs, count, COLORS[color_idx]); - loop { - let Some(event) = api.event(u32::MAX) else { continue }; - match event.kind { - BUTTON => return 0, - CROWN if event.delta != 0 => { - let n = COLORS.len(); - color_idx = if event.delta > 0 { - (color_idx + 1) % n - } else { - (color_idx + n - 1) % n - }; - } - TOUCH_DOWN => { - if event.y >= limit { - count = 0; - down = false; - } else { - start = (event.x, event.y); - down = true; - continue; - } - } - TOUCH_UP => { - if !down { - continue; - } - down = false; - if count >= MAX { - continue; - } - let ey = if event.y >= limit { limit - 1 } else { event.y }; - segs[count] = Seg { - x0: start.0, - y0: start.1, - x1: event.x, - y1: ey, - c: COLORS[color_idx], - }; - count += 1; - } - RESUME => {} - _ => continue, - } - redraw(api, &segs, count, COLORS[color_idx]); - } - } -} \ No newline at end of file diff --git a/apps/sketch/store.md b/apps/sketch/store.md deleted file mode 100644 index 140145d..0000000 --- a/apps/sketch/store.md +++ /dev/null @@ -1,14 +0,0 @@ -# Sketch - -A simple drawing pad. Touch the screen where a line should start and lift your finger where it should end: the app draws a straight line between the two. A tap draws a dot. - -- Turn the crown to change the color. -- Tap the grey bar at the bottom to clear the screen. -- Press the button to exit. - -## Requirements - -- The patched firmware -- The App Loader - -Both are on the store's firmware shelf. \ No newline at end of file diff --git a/apps/sketch/store.toml b/apps/sketch/store.toml deleted file mode 100644 index c4c5c26..0000000 --- a/apps/sketch/store.toml +++ /dev/null @@ -1,4 +0,0 @@ -name = "Sketch" -summary = "Draw on the watch screen with your finger" -version = "0.1.0" -author = "Gabriel Schettino" \ No newline at end of file diff --git a/apps/sky-hop/Cargo.toml b/apps/sky-hop/Cargo.toml deleted file mode 100644 index 1cd6c32..0000000 --- a/apps/sky-hop/Cargo.toml +++ /dev/null @@ -1,13 +0,0 @@ -[package] -name = "sky-hop" -edition.workspace = true -license.workspace = true -version.workspace = true - -[dependencies] -cmf-wp2-app.workspace = true -cmf-wp2-ui.workspace = true - -[[bin]] -name = "sky-hop" -bench = false diff --git a/apps/sky-hop/icon.svg b/apps/sky-hop/icon.svg deleted file mode 100644 index 94ba2e2..0000000 --- a/apps/sky-hop/icon.svg +++ /dev/null @@ -1,62 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/apps/sky-hop/shots/over.png b/apps/sky-hop/shots/over.png deleted file mode 100644 index 1c51056..0000000 Binary files a/apps/sky-hop/shots/over.png and /dev/null differ diff --git a/apps/sky-hop/shots/playing.png b/apps/sky-hop/shots/playing.png deleted file mode 100644 index 4aafd5c..0000000 Binary files a/apps/sky-hop/shots/playing.png and /dev/null differ diff --git a/apps/sky-hop/shots/ready.png b/apps/sky-hop/shots/ready.png deleted file mode 100644 index a3aee69..0000000 Binary files a/apps/sky-hop/shots/ready.png and /dev/null differ diff --git a/apps/sky-hop/src/game.rs b/apps/sky-hop/src/game.rs deleted file mode 100644 index 979c8ad..0000000 --- a/apps/sky-hop/src/game.rs +++ /dev/null @@ -1,429 +0,0 @@ -// The game itself: no Api, so `cargo test` runs it on the host. Fixed point only (the watch has no FPU): the -// critter's height and speed are in 1/256 px, everything else in whole pixels. One `step` is one 33 ms tick. - -/// Screen size and centre; the panel is a disc of radius `C`. -pub const SIZE: i32 = 466; -pub const C: i32 = SIZE / 2; - -/// Fixed-point one for the critter's height and speed. -pub const Q: i32 = 256; -/// The critter: its x never changes, its body is a disc of this radius. -pub const HOP_X: i32 = C; -pub const R: i32 = 13; -/// Per tick², per tick, and the fastest fall per tick (Q). -pub const GRAVITY: i32 = 140; -pub const FLAP: i32 = -2150; -pub const MAX_FALL: i32 = 2600; - -/// Gates: width, distance from one gate's left edge to the next one's, gap height, how far the gap's centre may -/// sit from the screen's centre line and how far it may move from one gate to the next. -pub const GATE_W: i32 = 52; // the pipe sprite's width -pub const SPACING: i32 = 230; -pub const GATES: usize = 3; -/// The ground's top edge: the bird's wall at the bottom, and where the pipes end. -pub const GROUND_Y: i32 = 388; -pub const GAP_START: i32 = 160; -pub const GAP_MIN: i32 = 120; -pub const GAP_SWING: i32 = 70; -pub const GAP_STEP: i32 = 70; -/// Where the first gate enters, just off the right edge. -pub const FIRST_X: i32 = SIZE + 40; - -/// Ready: hovering, waiting for the first tap. Over: crashed, the screen holds still. -#[derive(Clone, Copy, PartialEq, Eq, Debug)] -pub enum State { - Ready, - Playing, - Over, -} - -#[derive(Clone, Copy, PartialEq, Eq, Debug)] -pub enum Step { - Nothing, - Scored, - Crashed, -} - -#[derive(Clone, Copy, PartialEq, Eq, Debug)] -pub struct Gate { - /// Left edge. - pub x: i32, - /// The gap is `top..bottom`. - pub top: i32, - pub bottom: i32, - pub(crate) passed: bool, -} - -impl Gate { - pub fn centre(&self) -> i32 { - (self.top + self.bottom) / 2 - } -} - -#[derive(Clone)] -pub struct Game { - pub state: State, - /// Centre of the critter, Q. - pub y: i32, - pub vy: i32, - pub gates: [Gate; GATES], - pub score: u32, - /// How far the pipes have travelled this run, px: the scenery scrolls by fractions of it. - pub scroll: i32, - tick: u32, - rng: u32, -} - -/// xorshift32: no random source on the watch, the app seeds it from the clock. -fn next(rng: &mut u32) -> u32 { - let mut x = *rng; - x ^= x << 13; - x ^= x >> 17; - x ^= x << 5; - *rng = x; - x -} - -/// Gates move this many px per tick: 4, one more every 10 points, at most 6. -pub fn speed(score: u32) -> i32 { - 4 + (score / 10).min(2) as i32 -} - -/// The gap narrows by 3 px a point down to `GAP_MIN`. -pub fn gap(score: u32) -> i32 { - (GAP_START - 3 * score.min(100) as i32).max(GAP_MIN) -} - -/// Ready-screen hover: a triangle wave of ±6 px over 48 ticks. -fn hover(tick: u32) -> i32 { - let t = (tick % 48) as i32; - (if t < 24 { t } else { 48 - t }) / 2 - 6 -} - -impl Game { - pub fn new(seed: u32) -> Game { - let mut g = Game { - state: State::Ready, - y: C * Q, - vy: 0, - gates: [Gate { x: 0, top: 0, bottom: 0, passed: false }; GATES], - score: 0, - scroll: 0, - tick: 0, - rng: seed | 1, // xorshift sticks at 0 - }; - g.restart(); - g - } - - /// Back to Ready, keeping the random sequence going. - pub fn restart(&mut self) { - self.state = State::Ready; - self.y = C * Q; - self.vy = 0; - self.score = 0; - self.scroll = 0; - self.tick = 0; - let mut prev = C; - for i in 0..GATES { - self.gates[i] = self.gate(FIRST_X + i as i32 * SPACING, prev); - prev = self.gates[i].centre(); - } - } - - /// A new gate at `x`, its gap at most `GAP_STEP` from `prev` (the gap before it) so it can be reached. - fn gate(&mut self, x: i32, prev: i32) -> Gate { - let h = gap(self.score); - let shift = (next(&mut self.rng) % (2 * GAP_STEP as u32 + 1)) as i32 - GAP_STEP; - let centre = (prev + shift).clamp(C - GAP_SWING, C + GAP_SWING); - Gate { x, top: centre - h / 2, bottom: centre - h / 2 + h, passed: false } - } - - /// Centre of the critter in px. - pub fn hop_y(&self) -> i32 { - (self.y + Q / 2).div_euclid(Q) - } - - /// Which of the bird's three wing frames to show: up 0, middle 1, down 2. A flapping cycle, folded when it crashed. - pub fn wing(&self) -> usize { - if self.state == State::Over { 2 } else { [1, 0, 1, 2][(self.tick / 3 % 4) as usize] } - } - - /// A tap or a crown detent. Ready: starts the run. Over: does nothing (the app decides when to restart). - pub fn flap(&mut self) { - match self.state { - State::Ready => { - self.state = State::Playing; - self.vy = FLAP; - } - State::Playing => self.vy = FLAP, - State::Over => {} - } - } - - pub fn step(&mut self) -> Step { - self.tick = self.tick.wrapping_add(1); - match self.state { - State::Ready => { - self.y = (C + hover(self.tick)) * Q; - Step::Nothing - } - State::Over => Step::Nothing, - State::Playing => self.fly(), - } - } - - fn fly(&mut self) -> Step { - self.vy = (self.vy + GRAVITY).min(MAX_FALL); - self.y += self.vy; - let dx = speed(self.score); - self.scroll += dx; - let mut out = Step::Nothing; - for i in 0..GATES { - self.gates[i].x -= dx; - let g = self.gates[i]; - if !g.passed && g.x + GATE_W < HOP_X - R { - self.gates[i].passed = true; - self.score += 1; - out = Step::Scored; - } - } - for i in 0..GATES { - if self.gates[i].x + GATE_W < 0 { - let far = *self.gates.iter().max_by_key(|g| g.x).unwrap_or(&self.gates[i]); - self.gates[i] = self.gate(far.x + SPACING, far.centre()); - } - } - if self.crashed() { - self.state = State::Over; - return Step::Crashed; - } - out - } - - /// Out of the round screen, on the ground, or touching a gate. - pub fn crashed(&self) -> bool { - let (x, y) = (HOP_X, self.hop_y()); - let (dx, dy) = (x - C, y - C); - let reach = C - R - 2; - if dx * dx + dy * dy > reach * reach || y + R >= GROUND_Y { - return true; - } - self.gates.iter().any(|g| hits(x, y, R, g.x, i32::MIN / 2, GATE_W, g.top) || hits(x, y, R, g.x, g.bottom, GATE_W, i32::MAX / 2)) - } -} - -/// A disc against the rectangle `x0..x0+w`, `y0..y1`. -fn hits(cx: i32, cy: i32, r: i32, x0: i32, y0: i32, w: i32, y1: i32) -> bool { - let nx = cx.clamp(x0, x0 + w - 1); - let ny = cy.clamp(y0, y1 - 1); - let (dx, dy) = ((cx - nx) as i64, (cy - ny) as i64); - dx * dx + dy * dy < (r * r) as i64 -} - -/// The saved blob: "SH1" and the best score, little endian. -pub const MAGIC: &[u8; 3] = b"SH1"; - -pub fn encode(best: u32) -> [u8; 7] { - let b = best.to_le_bytes(); - [MAGIC[0], MAGIC[1], MAGIC[2], b[0], b[1], b[2], b[3]] -} - -/// Anything that isn't a blob of ours is no best score yet. -pub fn decode(blob: &[u8]) -> u32 { - match blob { - [b'S', b'H', b'1', a, b, c, d] => u32::from_le_bytes([*a, *b, *c, *d]), - _ => 0, - } -} - -#[cfg(test)] -mod tests { - use super::*; - - fn playing(seed: u32) -> Game { - let mut g = Game::new(seed); - g.flap(); - g - } - - /// Whether some sequence of hops (at most one every 3 ticks) survives the next `depth` ticks. - fn survives(g: &Game, depth: u32, since: u32) -> bool { - if depth == 0 { - return true; - } - let mut wait = g.clone(); - if wait.step() != Step::Crashed && survives(&wait, depth - 1, since + 1) { - return true; - } - if since < 3 { - return false; - } - let mut hop = g.clone(); - hop.flap(); - hop.step() != Step::Crashed && survives(&hop, depth - 1, 0) - } - - /// Hops only when waiting would leave no way through the next second: a player who plans ahead. - fn autopilot(g: &mut Game) { - let mut wait = g.clone(); - if wait.step() == Step::Crashed || !survives(&wait, 30, 3) { - g.flap(); - } - } - - #[test] - fn ready_hovers_until_the_first_flap() { - let mut g = Game::new(7); - for _ in 0..200 { - assert_eq!(g.step(), Step::Nothing); - assert!((g.hop_y() - C).abs() <= 6); - assert_eq!(g.state, State::Ready); - } - let xs = g.gates.map(|gt| gt.x); - g.flap(); - assert_eq!(g.state, State::Playing); - assert_eq!(g.vy, FLAP); - g.step(); - assert!(g.gates.iter().zip(xs).all(|(gt, x)| gt.x == x - speed(0))); - } - - #[test] - fn falling_without_flaps_hits_the_bottom_edge() { - let mut g = playing(3); - let mut ticks = 0; - while g.step() != Step::Crashed { - ticks += 1; - assert!(ticks < 200); - } - assert_eq!(g.state, State::Over); - assert!(g.hop_y() > C); - // over: nothing moves, flaps are ignored - let y = g.y; - g.flap(); - g.step(); - assert_eq!((g.y, g.state), (y, State::Over)); - } - - #[test] - fn flapping_all_the_time_hits_the_top_edge() { - let mut g = playing(3); - let mut ticks = 0; - loop { - g.flap(); - if g.step() == Step::Crashed { - break; - } - ticks += 1; - assert!(ticks < 200); - } - assert!(g.hop_y() < C); - } - - #[test] - fn fall_speed_is_capped() { - let mut g = playing(1); - g.gates.iter_mut().for_each(|gt| gt.x = 10_000); - g.y = 0; - for _ in 0..100 { - g.fly(); - g.state = State::Playing; - } - assert_eq!(g.vy, MAX_FALL); - } - - #[test] - fn autopilot_scores_and_the_game_gets_harder() { - for seed in [1, 2, 3, 99, 12345] { - let mut g = playing(seed); - let mut scored = 0; - while g.score < 100 { - autopilot(&mut g); - match g.step() { - Step::Crashed => panic!("seed {seed}: crashed at {} (y {}) {:?}", g.score, g.hop_y(), g.gates), - Step::Scored => scored += 1, - Step::Nothing => {} - } - } - assert_eq!(g.score, scored); - assert_eq!(speed(g.score), 6); - } - } - - #[test] - fn gates_keep_their_spacing_and_gaps_stay_on_screen() { - let mut g = playing(42); - for _ in 0..5000 { - autopilot(&mut g); - g.step(); - let mut xs = g.gates.map(|gt| gt.x); - xs.sort(); - assert_eq!(xs[1] - xs[0], SPACING); - assert_eq!(xs[2] - xs[1], SPACING); - for gt in g.gates { - assert!(gt.bottom - gt.top >= GAP_MIN); - assert!(gt.top >= C - GAP_SWING - GAP_START / 2 && gt.bottom <= C + GAP_SWING + GAP_START / 2); - } - for (a, b) in [(xs[0], xs[1]), (xs[1], xs[2])] { - let at = |x| g.gates.iter().find(|gt| gt.x == x).unwrap().centre(); - assert!((at(a) - at(b)).abs() <= GAP_STEP + 1); - } - } - } - - #[test] - fn touching_a_gate_crashes() { - let mut g = playing(5); - g.gates[0] = Gate { x: HOP_X - 10, top: 0, bottom: SIZE, passed: false }; - g.gates[1].x = 1000; - g.gates[2].x = 1230; - assert!(!g.crashed(), "a gap as tall as the screen"); - g.gates[0].top = C - 20; - assert!(!g.crashed(), "the critter's top is 8 px below the top part"); - g.y = (C - 8) * Q; - assert!(!g.crashed(), "just touching"); - g.y = (C - 9) * Q; - assert!(g.crashed(), "the top part reaches into the critter"); - g.gates[0] = Gate { x: HOP_X + R, top: 0, bottom: C - 8, passed: false }; - assert!(!g.crashed(), "the gate starts right after the critter's edge"); - } - - #[test] - fn the_scenery_scrolls_with_the_pipes_while_playing() { - let mut g = Game::new(2); - for _ in 0..30 { - g.step(); - } - assert_eq!(g.scroll, 0, "not while ready"); - g.flap(); - let mut dist = 0; - for _ in 0..20 { - autopilot(&mut g); - dist += speed(g.score); - g.step(); - } - assert_eq!(g.scroll, dist); - g.restart(); - assert_eq!(g.scroll, 0); - } - - #[test] - fn restart_resets_the_run_but_not_the_randomness() { - let mut g = playing(9); - let first = g.gates; - while g.step() != Step::Crashed {} - g.restart(); - assert_eq!((g.state, g.score, g.hop_y()), (State::Ready, 0, C)); - assert_eq!(g.gates[0].x, FIRST_X); - assert_ne!(g.gates.map(|gt| gt.top), first.map(|gt| gt.top)); - } - - #[test] - fn best_score_round_trips_and_garbage_is_zero() { - assert_eq!(decode(&encode(0)), 0); - assert_eq!(decode(&encode(1234)), 1234); - assert_eq!(decode(b""), 0); - assert_eq!(decode(b"SH2\x01\0\0\0"), 0); - assert_eq!(decode(b"SH1\x01\0\0"), 0); - } -} diff --git a/apps/sky-hop/src/main.rs b/apps/sky-hop/src/main.rs deleted file mode 100644 index b775fbb..0000000 --- a/apps/sky-hop/src/main.rs +++ /dev/null @@ -1,132 +0,0 @@ -#![cfg_attr(any(target_os = "none", wp2_sim), no_main, cfg_attr(target_os = "none", no_std))] - -#[cfg_attr(not(any(target_os = "none", wp2_sim)), allow(dead_code))] -mod game; -#[cfg_attr(not(any(target_os = "none", wp2_sim)), allow(dead_code))] -mod sprites; -#[cfg_attr(not(any(target_os = "none", wp2_sim)), allow(dead_code))] -mod view; - -#[cfg(not(any(target_os = "none", wp2_sim)))] -fn main() {} - -#[cfg(any(target_os = "none", wp2_sim))] -mod device { - use crate::game::{Game, State, Step, decode, encode}; - use crate::view::frame; - use cmf_wp2_app::{Api, BUTTON, CROWN, PAUSE, RESUME, TOUCH_DOWN}; - use cmf_wp2_ui::haptic::{DONE, Motor, TICK}; - - cmf_wp2_app::entry!(main); - cmf_wp2_app::app_icon!(); - - /// One game tick. - const FRAME_MS: u32 = 33; - /// After a slow frame, catch up at most this many ticks; beyond that the game slows down instead of jumping. - const CATCH_UP: u32 = 3; - /// Taps right after a crash don't restart: they were meant for the run that just ended. - const RETRY_MS: u32 = 600; - /// The Ready screen stops hovering after this long without input, so a forgotten app doesn't keep drawing. - const IDLE_MS: u32 = 20_000; - - fn due(now: u32, at: u32) -> bool { - (now.wrapping_sub(at) as i32) >= 0 - } - - // true on RESUME, false on BUTTON - fn paused(api: &Api) -> bool { - loop { - match api.event(u32::MAX).map(|e| e.kind) { - Some(RESUME) => return true, - Some(BUTTON) => return false, - _ => {} - } - } - } - - fn seed(api: &Api) -> u32 { - let t = api.time().map_or(0, |t| (t.minute as u32 * 60 + t.second as u32) * 1000 + t.millis as u32); - api.now().wrapping_mul(2_654_435_761) ^ t - } - - fn main(api: &'static Api) -> i32 { - let mut screen = api; - let mut motor = Motor::new(api); // dropped on return: the motor goes off - let mut blob = [0u8; 16]; - let n = api.load(&mut blob); - let mut best = if n > 0 { decode(&blob[..n as usize]) } else { 0 }; - let mut game = Game::new(seed(api)); - let mut seen = Some(frame(&mut screen, &game, best, None)); - api.show(); - let mut next = api.now().wrapping_add(FRAME_MS); - let (mut over_at, mut input_at) = (0u32, api.now()); - loop { - motor.update(); - let now = api.now(); - let still = game.state == State::Over || (game.state == State::Ready && due(now, input_at.wrapping_add(IDLE_MS))); - let left = if still { u32::MAX } else { (next.wrapping_sub(now) as i32).max(0) as u32 }; - let wait = motor.wait().map_or(left, |m| m.min(left)); - if let Some(e) = api.event(wait) { - match e.kind { - BUTTON => { - api.keep_screen_on(false); - return 0; - } - PAUSE => { - motor.off(); - if !paused(api) { - return 0; - } - seen = Some(frame(&mut screen, &game, best, None)); - api.show(); - next = api.now().wrapping_add(FRAME_MS); - } - TOUCH_DOWN | CROWN => { - let now = api.now(); - if game.state == State::Over { - if !due(now, over_at.wrapping_add(RETRY_MS)) { - continue; - } - game.restart(); - } - if still { - next = now; // waking up from a still screen: the next tick is due now - } - input_at = now; - game.flap(); - } - _ => {} - } - continue; - } - let now = api.now(); - if still || !due(now, next) { - continue; // the motor's deadline, not a tick - } - for _ in 0..CATCH_UP { - match game.step() { - Step::Scored => motor.play(TICK), - Step::Crashed => { - motor.play(DONE); - over_at = now; - if game.score > best { - best = game.score; - api.save(&encode(best)); // on change: the app can be ended without notice - } - } - Step::Nothing => {} - } - next = next.wrapping_add(FRAME_MS); - if game.state == State::Over || !due(now, next) { - break; - } - } - if due(now, next) { - next = now.wrapping_add(FRAME_MS); - } - seen = Some(frame(&mut screen, &game, best, seen)); - api.show(); - api.keep_screen_on(game.state == State::Playing); - } - } -} diff --git a/apps/sky-hop/src/sprites.rs b/apps/sky-hop/src/sprites.rs deleted file mode 100644 index cfefc28..0000000 --- a/apps/sky-hop/src/sprites.rs +++ /dev/null @@ -1,3381 +0,0 @@ -// Generated by tools/gen_sprites.py from the sprite PNGs: do not edit. - -/// Opaque rects of a sprite: (x, y, w, h, rgb565). -pub struct Sprite { - pub w: i32, - pub h: i32, - pub rects: &'static [(i16, i16, i16, i16, u16)], -} - -pub const DIGIT0: Sprite = Sprite { w: 24, h: 36, rects: &[ - (0, 0, 22, 2, 0x10C3), - (0, 2, 2, 32, 0x10C3), - (2, 2, 18, 8, 0xFFFF), - (20, 2, 4, 34, 0x10C3), - (2, 10, 8, 22, 0xFFFF), - (10, 10, 2, 14, 0x10C3), - (12, 10, 8, 22, 0xFFFF), - (10, 24, 2, 8, 0xFFFF), - (2, 32, 18, 4, 0x10C3), -] }; - -pub const DIGIT1: Sprite = Sprite { w: 16, h: 36, rects: &[ - (0, 0, 14, 2, 0x10C3), - (0, 2, 2, 10, 0x10C3), - (2, 2, 10, 8, 0xFFFF), - (12, 2, 4, 34, 0x10C3), - (2, 10, 2, 24, 0x10C3), - (4, 10, 8, 22, 0xFFFF), - (4, 32, 8, 4, 0x10C3), -] }; - -pub const DIGIT2: Sprite = Sprite { w: 24, h: 36, rects: &[ - (0, 0, 22, 2, 0x10C3), - (0, 2, 2, 32, 0x10C3), - (2, 2, 18, 8, 0xFFFF), - (20, 2, 4, 34, 0x10C3), - (2, 10, 10, 2, 0x10C3), - (12, 10, 8, 12, 0xFFFF), - (2, 12, 10, 10, 0xFFFF), - (2, 22, 8, 10, 0xFFFF), - (10, 22, 10, 2, 0x10C3), - (10, 24, 10, 8, 0xFFFF), - (2, 32, 18, 4, 0x10C3), -] }; - -pub const DIGIT3: Sprite = Sprite { w: 24, h: 36, rects: &[ - (0, 0, 22, 2, 0x10C3), - (0, 2, 2, 32, 0x10C3), - (2, 2, 18, 8, 0xFFFF), - (20, 2, 4, 34, 0x10C3), - (2, 10, 10, 2, 0x10C3), - (12, 10, 8, 22, 0xFFFF), - (2, 12, 10, 10, 0xFFFF), - (2, 22, 10, 2, 0x10C3), - (2, 24, 10, 8, 0xFFFF), - (2, 32, 18, 4, 0x10C3), -] }; - -pub const DIGIT4: Sprite = Sprite { w: 24, h: 36, rects: &[ - (0, 0, 22, 2, 0x10C3), - (0, 2, 2, 26, 0x10C3), - (2, 2, 8, 24, 0xFFFF), - (10, 2, 2, 16, 0x10C3), - (12, 2, 8, 30, 0xFFFF), - (20, 2, 4, 34, 0x10C3), - (10, 18, 2, 8, 0xFFFF), - (2, 26, 10, 4, 0x10C3), - (10, 30, 2, 4, 0x10C3), - (12, 32, 8, 4, 0x10C3), -] }; - -pub const DIGIT5: Sprite = Sprite { w: 24, h: 36, rects: &[ - (0, 0, 22, 2, 0x10C3), - (0, 2, 2, 32, 0x10C3), - (2, 2, 18, 8, 0xFFFF), - (20, 2, 4, 34, 0x10C3), - (2, 10, 8, 12, 0xFFFF), - (10, 10, 10, 2, 0x10C3), - (10, 12, 10, 10, 0xFFFF), - (2, 22, 10, 2, 0x10C3), - (12, 22, 8, 10, 0xFFFF), - (2, 24, 10, 8, 0xFFFF), - (2, 32, 18, 4, 0x10C3), -] }; - -pub const DIGIT6: Sprite = Sprite { w: 24, h: 36, rects: &[ - (0, 0, 22, 2, 0x10C3), - (0, 2, 2, 32, 0x10C3), - (2, 2, 18, 8, 0xFFFF), - (20, 2, 4, 34, 0x10C3), - (2, 10, 8, 22, 0xFFFF), - (10, 10, 10, 2, 0x10C3), - (10, 12, 10, 10, 0xFFFF), - (10, 22, 2, 2, 0x10C3), - (12, 22, 8, 10, 0xFFFF), - (10, 24, 2, 8, 0xFFFF), - (2, 32, 18, 4, 0x10C3), -] }; - -pub const DIGIT7: Sprite = Sprite { w: 24, h: 36, rects: &[ - (0, 0, 22, 2, 0x10C3), - (0, 2, 2, 18, 0x10C3), - (2, 2, 18, 8, 0xFFFF), - (20, 2, 4, 34, 0x10C3), - (2, 10, 8, 8, 0xFFFF), - (10, 10, 2, 24, 0x10C3), - (12, 10, 8, 22, 0xFFFF), - (2, 18, 8, 4, 0x10C3), - (12, 32, 8, 4, 0x10C3), -] }; - -pub const DIGIT8: Sprite = Sprite { w: 24, h: 36, rects: &[ - (0, 0, 22, 2, 0x10C3), - (0, 2, 2, 32, 0x10C3), - (2, 2, 18, 8, 0xFFFF), - (20, 2, 4, 34, 0x10C3), - (2, 10, 8, 22, 0xFFFF), - (10, 10, 2, 2, 0x10C3), - (12, 10, 8, 22, 0xFFFF), - (10, 12, 2, 10, 0xFFFF), - (10, 22, 2, 2, 0x10C3), - (10, 24, 2, 8, 0xFFFF), - (2, 32, 18, 4, 0x10C3), -] }; - -pub const DIGIT9: Sprite = Sprite { w: 24, h: 36, rects: &[ - (0, 0, 22, 2, 0x10C3), - (0, 2, 2, 32, 0x10C3), - (2, 2, 18, 8, 0xFFFF), - (20, 2, 4, 34, 0x10C3), - (2, 10, 8, 12, 0xFFFF), - (10, 10, 2, 2, 0x10C3), - (12, 10, 8, 22, 0xFFFF), - (10, 12, 2, 10, 0xFFFF), - (2, 22, 10, 2, 0x10C3), - (2, 24, 10, 8, 0xFFFF), - (2, 32, 18, 4, 0x10C3), -] }; - -pub const BIRD_UP: Sprite = Sprite { w: 34, h: 24, rects: &[ - (12, 0, 12, 2, 0x51C8), - (8, 2, 4, 2, 0x51C8), - (12, 2, 6, 2, 0xFEB1), - (18, 2, 2, 2, 0x51C8), - (20, 2, 4, 8, 0xFFDF), - (24, 2, 2, 2, 0x51C8), - (6, 4, 2, 4, 0x51C8), - (8, 4, 4, 2, 0xFEB1), - (12, 4, 4, 6, 0xFDA6), - (16, 4, 2, 6, 0x51C8), - (18, 4, 2, 2, 0xFFDF), - (24, 4, 2, 2, 0xFFDF), - (26, 4, 2, 2, 0x51C8), - (2, 6, 4, 2, 0x51C8), - (8, 6, 2, 2, 0x51C8), - (10, 6, 2, 2, 0xFDA6), - (18, 6, 2, 4, 0xD739), - (24, 6, 2, 4, 0x51C8), - (26, 6, 2, 6, 0xFFDF), - (28, 6, 2, 8, 0x51C8), - (0, 8, 2, 6, 0x51C8), - (2, 8, 8, 4, 0xFFDF), - (10, 8, 2, 2, 0x51C8), - (10, 10, 2, 2, 0xFFDF), - (12, 10, 2, 4, 0x51C8), - (14, 10, 4, 6, 0xFDA6), - (18, 10, 2, 2, 0x51C8), - (20, 10, 2, 2, 0xD739), - (22, 10, 4, 2, 0xFFDF), - (2, 12, 2, 2, 0xFEB1), - (4, 12, 6, 2, 0xFFDF), - (10, 12, 2, 2, 0xFEB1), - (18, 12, 2, 2, 0xFDA6), - (20, 12, 8, 2, 0x51C8), - (30, 12, 2, 2, 0x51C8), - (2, 14, 2, 2, 0x51C8), - (4, 14, 6, 2, 0xFEB1), - (10, 14, 2, 2, 0x51C8), - (12, 14, 2, 2, 0xFDA6), - (18, 14, 2, 2, 0x51C8), - (20, 14, 12, 2, 0xF9C0), - (32, 14, 2, 2, 0x51C8), - (4, 16, 6, 2, 0x51C8), - (10, 16, 6, 6, 0xE405), - (16, 16, 2, 2, 0x51C8), - (18, 16, 2, 2, 0xF9C0), - (20, 16, 12, 2, 0x51C8), - (4, 18, 2, 2, 0x51C8), - (6, 18, 4, 2, 0xE405), - (16, 18, 2, 4, 0xE405), - (18, 18, 2, 2, 0x51C8), - (20, 18, 10, 2, 0xF9C0), - (30, 18, 2, 2, 0x51C8), - (6, 20, 4, 2, 0x51C8), - (18, 20, 2, 2, 0xE405), - (20, 20, 10, 2, 0x51C8), - (10, 22, 10, 2, 0x51C8), -] }; - -pub const BIRD_MID: Sprite = Sprite { w: 34, h: 24, rects: &[ - (12, 0, 12, 2, 0x51C8), - (8, 2, 4, 2, 0x51C8), - (12, 2, 6, 2, 0xFEB1), - (18, 2, 2, 2, 0x51C8), - (20, 2, 4, 8, 0xFFDF), - (24, 2, 2, 2, 0x51C8), - (6, 4, 2, 2, 0x51C8), - (8, 4, 4, 2, 0xFEB1), - (12, 4, 4, 8, 0xFDA6), - (16, 4, 2, 6, 0x51C8), - (18, 4, 2, 2, 0xFFDF), - (24, 4, 2, 2, 0xFFDF), - (26, 4, 2, 2, 0x51C8), - (4, 6, 2, 2, 0x51C8), - (6, 6, 2, 2, 0xFEB1), - (8, 6, 4, 4, 0xFDA6), - (18, 6, 2, 4, 0xD739), - (24, 6, 2, 4, 0x51C8), - (26, 6, 2, 6, 0xFFDF), - (28, 6, 2, 8, 0x51C8), - (2, 8, 2, 4, 0x51C8), - (4, 8, 4, 2, 0xFDA6), - (4, 10, 8, 2, 0x51C8), - (16, 10, 2, 6, 0xFDA6), - (18, 10, 2, 2, 0x51C8), - (20, 10, 2, 2, 0xD739), - (22, 10, 4, 2, 0xFFDF), - (0, 12, 2, 4, 0x51C8), - (2, 12, 10, 2, 0xFFDF), - (12, 12, 2, 4, 0x51C8), - (14, 12, 2, 4, 0xFDA6), - (18, 12, 2, 2, 0xFDA6), - (20, 12, 8, 2, 0x51C8), - (30, 12, 2, 2, 0x51C8), - (2, 14, 2, 2, 0xFEB1), - (4, 14, 6, 2, 0xFFDF), - (10, 14, 2, 2, 0xFEB1), - (18, 14, 2, 2, 0x51C8), - (20, 14, 12, 2, 0xF9C0), - (32, 14, 2, 2, 0x51C8), - (2, 16, 10, 2, 0x51C8), - (12, 16, 4, 6, 0xE405), - (16, 16, 2, 2, 0x51C8), - (18, 16, 2, 2, 0xF9C0), - (20, 16, 12, 2, 0x51C8), - (4, 18, 2, 2, 0x51C8), - (6, 18, 6, 2, 0xE405), - (16, 18, 2, 4, 0xE405), - (18, 18, 2, 2, 0x51C8), - (20, 18, 10, 2, 0xF9C0), - (30, 18, 2, 2, 0x51C8), - (6, 20, 4, 2, 0x51C8), - (10, 20, 2, 2, 0xE405), - (18, 20, 2, 2, 0xE405), - (20, 20, 10, 2, 0x51C8), - (10, 22, 10, 2, 0x51C8), -] }; - -pub const BIRD_DOWN: Sprite = Sprite { w: 34, h: 24, rects: &[ - (12, 0, 12, 2, 0x51C8), - (8, 2, 4, 2, 0x51C8), - (12, 2, 6, 2, 0xFEB1), - (18, 2, 2, 2, 0x51C8), - (20, 2, 4, 8, 0xFFDF), - (24, 2, 2, 2, 0x51C8), - (6, 4, 2, 2, 0x51C8), - (8, 4, 4, 2, 0xFEB1), - (12, 4, 4, 10, 0xFDA6), - (16, 4, 2, 6, 0x51C8), - (18, 4, 2, 2, 0xFFDF), - (24, 4, 2, 2, 0xFFDF), - (26, 4, 2, 2, 0x51C8), - (4, 6, 2, 2, 0x51C8), - (6, 6, 2, 2, 0xFEB1), - (8, 6, 4, 6, 0xFDA6), - (18, 6, 2, 4, 0xD739), - (24, 6, 2, 4, 0x51C8), - (26, 6, 2, 6, 0xFFDF), - (28, 6, 2, 8, 0x51C8), - (2, 8, 2, 6, 0x51C8), - (4, 8, 4, 4, 0xFDA6), - (16, 10, 2, 6, 0xFDA6), - (18, 10, 2, 2, 0x51C8), - (20, 10, 2, 2, 0xD739), - (22, 10, 4, 2, 0xFFDF), - (4, 12, 8, 2, 0x51C8), - (18, 12, 2, 2, 0xFDA6), - (20, 12, 8, 2, 0x51C8), - (30, 12, 2, 2, 0x51C8), - (0, 14, 2, 6, 0x51C8), - (2, 14, 2, 2, 0xFEB1), - (4, 14, 6, 4, 0xFFDF), - (10, 14, 2, 2, 0xFEB1), - (12, 14, 2, 2, 0x51C8), - (14, 14, 2, 2, 0xFDA6), - (18, 14, 2, 2, 0x51C8), - (20, 14, 12, 2, 0xF9C0), - (32, 14, 2, 2, 0x51C8), - (2, 16, 2, 4, 0xFFDF), - (10, 16, 2, 2, 0x51C8), - (12, 16, 4, 6, 0xE405), - (16, 16, 2, 2, 0x51C8), - (18, 16, 2, 2, 0xF9C0), - (20, 16, 12, 2, 0x51C8), - (4, 18, 2, 2, 0xFFDF), - (6, 18, 2, 2, 0xFEB1), - (8, 18, 2, 4, 0x51C8), - (10, 18, 2, 4, 0xE405), - (16, 18, 2, 4, 0xE405), - (18, 18, 2, 2, 0x51C8), - (20, 18, 10, 2, 0xF9C0), - (30, 18, 2, 2, 0x51C8), - (2, 20, 6, 2, 0x51C8), - (18, 20, 2, 2, 0xE405), - (20, 20, 10, 2, 0x51C8), - (10, 22, 10, 2, 0x51C8), -] }; - -pub const GAMEOVER: Sprite = Sprite { w: 192, h: 42, rects: &[ - (6, 0, 20, 2, 0x51C8), - (114, 0, 14, 2, 0x51C8), - (4, 2, 2, 2, 0x51C8), - (6, 2, 18, 2, 0xFFFF), - (24, 2, 2, 10, 0x51C8), - (112, 2, 2, 2, 0x51C8), - (114, 2, 14, 2, 0xFFFF), - (128, 2, 2, 2, 0x51C8), - (2, 4, 2, 2, 0x51C8), - (4, 4, 4, 2, 0xFFFF), - (8, 4, 14, 6, 0xFD09), - (22, 4, 2, 36, 0xFFFF), - (78, 4, 14, 2, 0x51C8), - (110, 4, 2, 2, 0x51C8), - (112, 4, 4, 2, 0xFFFF), - (116, 4, 10, 6, 0xFD09), - (126, 4, 4, 2, 0xFFFF), - (130, 4, 2, 2, 0x51C8), - (154, 4, 14, 2, 0x51C8), - (0, 6, 2, 30, 0x51C8), - (2, 6, 4, 2, 0xFFFF), - (6, 6, 2, 28, 0xFD09), - (76, 6, 2, 2, 0x51C8), - (78, 6, 14, 2, 0xFFFF), - (92, 6, 2, 2, 0x51C8), - (108, 6, 2, 30, 0x51C8), - (110, 6, 4, 2, 0xFFFF), - (114, 6, 2, 28, 0xFD09), - (126, 6, 2, 28, 0xFD09), - (128, 6, 4, 2, 0xFFFF), - (132, 6, 2, 4, 0x51C8), - (152, 6, 2, 2, 0x51C8), - (154, 6, 14, 2, 0xFFFF), - (168, 6, 2, 2, 0x51C8), - (2, 8, 2, 28, 0xFFFF), - (4, 8, 2, 24, 0xFD09), - (26, 8, 50, 2, 0x51C8), - (76, 8, 4, 2, 0xFFFF), - (80, 8, 10, 10, 0xFD09), - (90, 8, 4, 2, 0xFFFF), - (94, 8, 2, 4, 0x51C8), - (110, 8, 2, 28, 0xFFFF), - (112, 8, 2, 24, 0xFD09), - (128, 8, 2, 24, 0xFD09), - (130, 8, 2, 32, 0xFFFF), - (134, 8, 18, 2, 0x51C8), - (152, 8, 4, 2, 0xFFFF), - (156, 8, 10, 8, 0xFD09), - (166, 8, 4, 2, 0xFFFF), - (170, 8, 2, 4, 0x51C8), - (174, 8, 18, 2, 0x51C8), - (8, 10, 4, 26, 0xFD09), - (12, 10, 10, 2, 0xE303), - (26, 10, 46, 2, 0xFFFF), - (72, 10, 4, 2, 0x51C8), - (76, 10, 2, 4, 0xFFFF), - (78, 10, 2, 24, 0xFD09), - (90, 10, 2, 18, 0xFD09), - (92, 10, 2, 4, 0xFFFF), - (116, 10, 4, 26, 0xFD09), - (120, 10, 2, 2, 0xE303), - (122, 10, 4, 26, 0xFD09), - (132, 10, 22, 2, 0xFFFF), - (154, 10, 2, 24, 0xFD09), - (166, 10, 2, 18, 0xFD09), - (168, 10, 2, 4, 0xFFFF), - (172, 10, 2, 2, 0x51C8), - (174, 10, 16, 2, 0xFFFF), - (190, 10, 2, 16, 0x51C8), - (12, 12, 10, 4, 0xFFFF), - (24, 12, 4, 2, 0xFFFF), - (28, 12, 14, 8, 0xFD09), - (42, 12, 2, 28, 0xFFFF), - (44, 12, 26, 8, 0xFD09), - (70, 12, 6, 2, 0xFFFF), - (94, 12, 2, 20, 0xFFFF), - (96, 12, 2, 22, 0x51C8), - (120, 12, 2, 18, 0xFFFF), - (132, 12, 8, 24, 0xFD09), - (140, 12, 2, 18, 0xFFFF), - (142, 12, 8, 16, 0xFD09), - (150, 12, 4, 2, 0xFFFF), - (170, 12, 6, 2, 0xFFFF), - (176, 12, 12, 8, 0xFD09), - (188, 12, 2, 12, 0xFFFF), - (24, 14, 2, 4, 0xFFFF), - (26, 14, 2, 20, 0xFD09), - (70, 14, 2, 22, 0xFD09), - (72, 14, 4, 4, 0xFFFF), - (76, 14, 2, 18, 0xFD09), - (92, 14, 2, 14, 0xFD09), - (150, 14, 2, 22, 0xFFFF), - (152, 14, 2, 18, 0xFD09), - (168, 14, 2, 14, 0xFD09), - (170, 14, 4, 4, 0xFFFF), - (174, 14, 2, 22, 0xFD09), - (12, 16, 2, 14, 0xFFFF), - (14, 16, 8, 20, 0xFD09), - (156, 16, 4, 20, 0xFD09), - (160, 16, 2, 2, 0xE303), - (162, 16, 4, 12, 0xFD09), - (24, 18, 2, 14, 0xFD09), - (72, 18, 2, 18, 0xFD09), - (74, 18, 2, 22, 0xFFFF), - (80, 18, 4, 18, 0xFD09), - (84, 18, 2, 4, 0xFFFF), - (86, 18, 4, 10, 0xFD09), - (160, 18, 2, 6, 0xFFFF), - (170, 18, 2, 22, 0xFFFF), - (172, 18, 2, 18, 0xFD09), - (28, 20, 4, 16, 0xFD09), - (32, 20, 2, 2, 0xE303), - (34, 20, 8, 16, 0xFD09), - (44, 20, 8, 16, 0xFD09), - (52, 20, 2, 2, 0xE303), - (54, 20, 10, 16, 0xFD09), - (64, 20, 2, 2, 0xE303), - (66, 20, 4, 16, 0xFD09), - (176, 20, 4, 16, 0xFD09), - (180, 20, 8, 2, 0xE303), - (32, 22, 2, 8, 0xFFFF), - (52, 22, 2, 18, 0xFFFF), - (64, 22, 2, 18, 0xFFFF), - (84, 22, 2, 2, 0xE303), - (180, 22, 8, 2, 0xFFFF), - (84, 24, 2, 12, 0xFD09), - (160, 24, 2, 12, 0xFD09), - (180, 24, 2, 16, 0xFFFF), - (182, 24, 8, 2, 0x51C8), - (182, 26, 2, 16, 0x51C8), - (86, 28, 8, 2, 0xE303), - (142, 28, 6, 2, 0xFD09), - (148, 28, 2, 2, 0xE303), - (162, 28, 8, 2, 0xE303), - (12, 30, 2, 6, 0xFD09), - (32, 30, 2, 6, 0xFD09), - (86, 30, 8, 2, 0xFFFF), - (120, 30, 2, 6, 0xFD09), - (140, 30, 6, 2, 0xFD09), - (146, 30, 2, 2, 0xE303), - (148, 30, 2, 4, 0xFFFF), - (162, 30, 8, 2, 0xFFFF), - (4, 32, 2, 2, 0xE303), - (24, 32, 2, 2, 0xE303), - (76, 32, 2, 2, 0xE303), - (86, 32, 2, 8, 0xFFFF), - (88, 32, 8, 2, 0x51C8), - (112, 32, 2, 2, 0xE303), - (128, 32, 2, 2, 0xE303), - (140, 32, 4, 2, 0xFD09), - (144, 32, 2, 2, 0xE303), - (146, 32, 2, 4, 0xFFFF), - (152, 32, 2, 2, 0xE303), - (162, 32, 2, 8, 0xFFFF), - (164, 32, 6, 2, 0x51C8), - (4, 34, 2, 4, 0xFFFF), - (6, 34, 2, 2, 0xE303), - (24, 34, 2, 4, 0xFFFF), - (26, 34, 2, 2, 0xE303), - (76, 34, 2, 4, 0xFFFF), - (78, 34, 2, 2, 0xE303), - (88, 34, 2, 8, 0x51C8), - (112, 34, 2, 4, 0xFFFF), - (114, 34, 2, 2, 0xE303), - (126, 34, 2, 2, 0xE303), - (128, 34, 2, 4, 0xFFFF), - (140, 34, 2, 2, 0xFD09), - (142, 34, 2, 2, 0xE303), - (144, 34, 2, 4, 0xFFFF), - (148, 34, 2, 2, 0x51C8), - (152, 34, 2, 4, 0xFFFF), - (154, 34, 2, 2, 0xE303), - (164, 34, 2, 8, 0x51C8), - (168, 34, 2, 8, 0x51C8), - (2, 36, 2, 2, 0x51C8), - (6, 36, 2, 4, 0xFFFF), - (8, 36, 14, 2, 0xE303), - (26, 36, 2, 4, 0xFFFF), - (28, 36, 14, 2, 0xE303), - (44, 36, 8, 2, 0xE303), - (54, 36, 10, 2, 0xE303), - (66, 36, 8, 2, 0xE303), - (78, 36, 2, 4, 0xFFFF), - (80, 36, 6, 2, 0xE303), - (110, 36, 2, 2, 0x51C8), - (114, 36, 2, 4, 0xFFFF), - (116, 36, 10, 2, 0xE303), - (126, 36, 2, 4, 0xFFFF), - (132, 36, 10, 2, 0xE303), - (142, 36, 2, 4, 0xFFFF), - (146, 36, 2, 2, 0x51C8), - (150, 36, 2, 2, 0x51C8), - (154, 36, 2, 4, 0xFFFF), - (156, 36, 6, 2, 0xE303), - (172, 36, 8, 2, 0xE303), - (4, 38, 2, 2, 0x51C8), - (8, 38, 14, 2, 0xFFFF), - (24, 38, 2, 4, 0x51C8), - (28, 38, 14, 2, 0xFFFF), - (44, 38, 8, 2, 0xFFFF), - (54, 38, 10, 2, 0xFFFF), - (66, 38, 8, 2, 0xFFFF), - (76, 38, 2, 4, 0x51C8), - (80, 38, 6, 2, 0xFFFF), - (112, 38, 2, 2, 0x51C8), - (116, 38, 10, 2, 0xFFFF), - (128, 38, 2, 4, 0x51C8), - (132, 38, 10, 2, 0xFFFF), - (144, 38, 2, 2, 0x51C8), - (152, 38, 2, 2, 0x51C8), - (156, 38, 6, 2, 0xFFFF), - (172, 38, 8, 2, 0xFFFF), - (6, 40, 18, 2, 0x51C8), - (26, 40, 50, 2, 0x51C8), - (78, 40, 10, 2, 0x51C8), - (114, 40, 14, 2, 0x51C8), - (130, 40, 14, 2, 0x51C8), - (154, 40, 10, 2, 0x51C8), - (170, 40, 12, 2, 0x51C8), -] }; - -pub const GET_READY: Sprite = Sprite { w: 184, h: 50, rects: &[ - (6, 0, 20, 2, 0x51C8), - (44, 0, 16, 2, 0x51C8), - (68, 0, 20, 2, 0x51C8), - (138, 0, 16, 2, 0x51C8), - (168, 0, 16, 2, 0x51C8), - (4, 2, 2, 2, 0x51C8), - (6, 2, 18, 2, 0xFFFF), - (24, 2, 2, 8, 0x51C8), - (44, 2, 2, 10, 0x51C8), - (46, 2, 12, 2, 0xFFFF), - (58, 2, 2, 10, 0x51C8), - (68, 2, 2, 38, 0x51C8), - (70, 2, 18, 2, 0xFFFF), - (88, 2, 2, 2, 0x51C8), - (138, 2, 2, 10, 0x51C8), - (140, 2, 12, 2, 0xFFFF), - (152, 2, 2, 8, 0x51C8), - (168, 2, 2, 8, 0x51C8), - (170, 2, 12, 2, 0xFFFF), - (182, 2, 2, 40, 0x51C8), - (2, 4, 2, 2, 0x51C8), - (4, 4, 4, 2, 0xFFFF), - (8, 4, 14, 6, 0x5ECB), - (22, 4, 2, 36, 0xFFFF), - (26, 4, 12, 2, 0x51C8), - (46, 4, 2, 10, 0xFFFF), - (48, 4, 8, 28, 0x5ECB), - (56, 4, 2, 10, 0xFFFF), - (70, 4, 2, 36, 0xFFFF), - (72, 4, 14, 6, 0x5ECB), - (86, 4, 4, 2, 0xFFFF), - (90, 4, 2, 2, 0x51C8), - (96, 4, 10, 2, 0x51C8), - (140, 4, 2, 10, 0xFFFF), - (142, 4, 8, 32, 0x5ECB), - (150, 4, 2, 36, 0xFFFF), - (170, 4, 2, 40, 0xFFFF), - (172, 4, 8, 20, 0x5ECB), - (180, 4, 2, 36, 0xFFFF), - (0, 6, 2, 30, 0x51C8), - (2, 6, 4, 2, 0xFFFF), - (6, 6, 2, 28, 0x5ECB), - (26, 6, 2, 2, 0x51C8), - (28, 6, 10, 2, 0xFFFF), - (38, 6, 2, 2, 0x51C8), - (86, 6, 2, 20, 0x5ECB), - (88, 6, 4, 2, 0xFFFF), - (92, 6, 4, 2, 0x51C8), - (96, 6, 10, 2, 0xFFFF), - (106, 6, 2, 2, 0x51C8), - (2, 8, 2, 28, 0xFFFF), - (4, 8, 2, 24, 0x5ECB), - (26, 8, 4, 2, 0xFFFF), - (30, 8, 6, 8, 0x5ECB), - (36, 8, 4, 2, 0xFFFF), - (40, 8, 2, 2, 0x51C8), - (88, 8, 2, 16, 0x5ECB), - (90, 8, 2, 32, 0xFFFF), - (92, 8, 2, 2, 0x51C8), - (94, 8, 4, 2, 0xFFFF), - (98, 8, 6, 8, 0x5ECB), - (104, 8, 4, 2, 0xFFFF), - (108, 8, 2, 2, 0x51C8), - (116, 8, 18, 2, 0x51C8), - (154, 8, 14, 2, 0x51C8), - (8, 10, 4, 26, 0x5ECB), - (12, 10, 10, 2, 0x0549), - (24, 10, 4, 2, 0xFFFF), - (28, 10, 2, 26, 0x5ECB), - (36, 10, 2, 18, 0x5ECB), - (38, 10, 4, 2, 0xFFFF), - (42, 10, 2, 2, 0x51C8), - (60, 10, 4, 2, 0x51C8), - (72, 10, 8, 26, 0x5ECB), - (80, 10, 2, 2, 0x0549), - (82, 10, 4, 26, 0x5ECB), - (92, 10, 4, 2, 0xFFFF), - (96, 10, 2, 26, 0x5ECB), - (104, 10, 2, 18, 0x5ECB), - (106, 10, 4, 2, 0xFFFF), - (110, 10, 2, 2, 0x51C8), - (114, 10, 2, 2, 0x51C8), - (116, 10, 16, 2, 0xFFFF), - (132, 10, 6, 2, 0x51C8), - (152, 10, 18, 2, 0xFFFF), - (12, 12, 10, 4, 0xFFFF), - (24, 12, 2, 2, 0xFFFF), - (26, 12, 2, 22, 0x5ECB), - (38, 12, 2, 16, 0x5ECB), - (40, 12, 6, 2, 0xFFFF), - (58, 12, 4, 2, 0xFFFF), - (62, 12, 2, 30, 0x51C8), - (80, 12, 2, 8, 0xFFFF), - (92, 12, 2, 2, 0xFFFF), - (94, 12, 2, 22, 0x5ECB), - (106, 12, 2, 16, 0x5ECB), - (108, 12, 4, 2, 0xFFFF), - (112, 12, 2, 2, 0x51C8), - (114, 12, 4, 2, 0xFFFF), - (118, 12, 12, 8, 0x5ECB), - (130, 12, 2, 28, 0xFFFF), - (132, 12, 2, 2, 0x51C8), - (134, 12, 6, 2, 0xFFFF), - (152, 12, 8, 16, 0x5ECB), - (160, 12, 2, 14, 0xFFFF), - (162, 12, 8, 28, 0x5ECB), - (24, 14, 2, 18, 0x5ECB), - (40, 14, 2, 14, 0x5ECB), - (42, 14, 2, 18, 0xFFFF), - (44, 14, 4, 6, 0x5ECB), - (56, 14, 4, 6, 0x5ECB), - (60, 14, 2, 10, 0xFFFF), - (92, 14, 2, 18, 0x5ECB), - (108, 14, 2, 14, 0x5ECB), - (110, 14, 6, 2, 0xFFFF), - (116, 14, 2, 22, 0x5ECB), - (132, 14, 4, 2, 0xFFFF), - (136, 14, 6, 6, 0x5ECB), - (12, 16, 2, 14, 0xFFFF), - (14, 16, 8, 20, 0x5ECB), - (30, 16, 2, 20, 0x5ECB), - (32, 16, 2, 2, 0x0549), - (34, 16, 2, 12, 0x5ECB), - (98, 16, 2, 20, 0x5ECB), - (100, 16, 2, 2, 0x0549), - (102, 16, 2, 12, 0x5ECB), - (110, 16, 4, 2, 0xFFFF), - (114, 16, 2, 18, 0x5ECB), - (132, 16, 2, 2, 0xFFFF), - (134, 16, 2, 18, 0x5ECB), - (32, 18, 2, 6, 0xFFFF), - (100, 18, 2, 6, 0xFFFF), - (110, 18, 2, 18, 0xFFFF), - (112, 18, 2, 14, 0x5ECB), - (132, 18, 2, 14, 0x5ECB), - (44, 20, 4, 2, 0x0549), - (56, 20, 4, 2, 0x0549), - (80, 20, 2, 12, 0x5ECB), - (118, 20, 2, 16, 0x5ECB), - (120, 20, 2, 2, 0x0549), - (122, 20, 8, 16, 0x5ECB), - (136, 20, 4, 16, 0x5ECB), - (140, 20, 2, 2, 0x0549), - (44, 22, 4, 2, 0xFFFF), - (56, 22, 4, 2, 0xFFFF), - (120, 22, 2, 8, 0xFFFF), - (140, 22, 2, 8, 0xFFFF), - (32, 24, 2, 12, 0x5ECB), - (44, 24, 2, 12, 0x51C8), - (46, 24, 2, 12, 0xFFFF), - (56, 24, 2, 6, 0xFFFF), - (58, 24, 4, 4, 0x51C8), - (88, 24, 2, 2, 0x0549), - (100, 24, 2, 12, 0x5ECB), - (172, 24, 8, 2, 0x0549), - (86, 26, 2, 2, 0x0549), - (88, 26, 2, 8, 0xFFFF), - (160, 26, 2, 6, 0x5ECB), - (172, 26, 8, 4, 0xFFFF), - (34, 28, 8, 2, 0x0549), - (58, 28, 4, 2, 0xFFFF), - (86, 28, 2, 4, 0xFFFF), - (102, 28, 8, 2, 0x0549), - (152, 28, 2, 2, 0x0549), - (154, 28, 6, 2, 0x5ECB), - (12, 30, 2, 6, 0x5ECB), - (34, 30, 8, 2, 0xFFFF), - (56, 30, 4, 6, 0x5ECB), - (60, 30, 2, 10, 0xFFFF), - (102, 30, 8, 2, 0xFFFF), - (120, 30, 2, 6, 0x5ECB), - (140, 30, 2, 6, 0x5ECB), - (152, 30, 2, 4, 0xFFFF), - (154, 30, 2, 2, 0x0549), - (156, 30, 4, 2, 0x5ECB), - (172, 30, 8, 6, 0x5ECB), - (4, 32, 2, 2, 0x0549), - (24, 32, 2, 2, 0x0549), - (34, 32, 2, 8, 0xFFFF), - (36, 32, 8, 2, 0x51C8), - (48, 32, 2, 2, 0x0549), - (50, 32, 6, 2, 0x5ECB), - (80, 32, 2, 8, 0xFFFF), - (86, 32, 2, 4, 0x5ECB), - (92, 32, 2, 2, 0x0549), - (102, 32, 2, 8, 0xFFFF), - (104, 32, 6, 2, 0x51C8), - (112, 32, 2, 2, 0x0549), - (132, 32, 2, 2, 0x0549), - (154, 32, 2, 4, 0xFFFF), - (156, 32, 6, 2, 0x0549), - (4, 34, 2, 4, 0xFFFF), - (6, 34, 2, 2, 0x0549), - (24, 34, 2, 4, 0xFFFF), - (26, 34, 2, 2, 0x0549), - (36, 34, 2, 8, 0x51C8), - (48, 34, 2, 4, 0xFFFF), - (50, 34, 2, 2, 0x0549), - (52, 34, 4, 2, 0x5ECB), - (88, 34, 2, 2, 0x5ECB), - (92, 34, 2, 4, 0xFFFF), - (94, 34, 2, 2, 0x0549), - (104, 34, 2, 8, 0x51C8), - (108, 34, 2, 2, 0x51C8), - (112, 34, 2, 4, 0xFFFF), - (114, 34, 2, 2, 0x0549), - (132, 34, 2, 4, 0xFFFF), - (134, 34, 2, 2, 0x0549), - (152, 34, 2, 8, 0x51C8), - (156, 34, 6, 4, 0xFFFF), - (2, 36, 2, 2, 0x51C8), - (6, 36, 2, 4, 0xFFFF), - (8, 36, 14, 2, 0x0549), - (26, 36, 2, 4, 0xFFFF), - (28, 36, 6, 2, 0x0549), - (46, 36, 2, 2, 0x51C8), - (50, 36, 2, 4, 0xFFFF), - (52, 36, 8, 2, 0x0549), - (72, 36, 8, 2, 0x0549), - (82, 36, 8, 2, 0x0549), - (94, 36, 2, 4, 0xFFFF), - (96, 36, 6, 2, 0x0549), - (110, 36, 2, 2, 0x51C8), - (114, 36, 2, 4, 0xFFFF), - (116, 36, 14, 2, 0x0549), - (134, 36, 2, 4, 0xFFFF), - (136, 36, 14, 2, 0x0549), - (154, 36, 2, 14, 0x51C8), - (172, 36, 8, 2, 0x0549), - (4, 38, 2, 2, 0x51C8), - (8, 38, 14, 2, 0xFFFF), - (24, 38, 2, 4, 0x51C8), - (28, 38, 6, 2, 0xFFFF), - (48, 38, 2, 2, 0x51C8), - (52, 38, 8, 2, 0xFFFF), - (72, 38, 8, 2, 0xFFFF), - (82, 38, 8, 2, 0xFFFF), - (92, 38, 2, 4, 0x51C8), - (96, 38, 6, 2, 0xFFFF), - (112, 38, 2, 2, 0x51C8), - (116, 38, 14, 2, 0xFFFF), - (132, 38, 2, 4, 0x51C8), - (136, 38, 14, 2, 0xFFFF), - (156, 38, 2, 10, 0xFFFF), - (158, 38, 4, 6, 0x5ECB), - (172, 38, 8, 2, 0xFFFF), - (6, 40, 18, 2, 0x51C8), - (26, 40, 10, 2, 0x51C8), - (50, 40, 12, 2, 0x51C8), - (70, 40, 22, 2, 0x51C8), - (94, 40, 10, 2, 0x51C8), - (114, 40, 18, 2, 0x51C8), - (134, 40, 18, 2, 0x51C8), - (162, 40, 6, 2, 0x5ECB), - (168, 40, 2, 2, 0x0549), - (172, 40, 10, 2, 0x51C8), - (162, 42, 4, 2, 0x5ECB), - (166, 42, 2, 2, 0x0549), - (168, 42, 2, 4, 0xFFFF), - (172, 42, 2, 2, 0x51C8), - (158, 44, 8, 2, 0x0549), - (166, 44, 2, 4, 0xFFFF), - (170, 44, 2, 2, 0x51C8), - (158, 46, 8, 2, 0xFFFF), - (168, 46, 2, 2, 0x51C8), - (156, 48, 12, 2, 0x51C8), -] }; - -pub const TAP_HINT: Sprite = Sprite { w: 114, h: 36, rects: &[ - (54, 0, 2, 6, 0x51C8), - (0, 4, 34, 2, 0xFFFF), - (46, 4, 2, 2, 0x51C8), - (62, 4, 2, 2, 0x51C8), - (80, 4, 34, 2, 0xFFFF), - (0, 6, 2, 16, 0xFFFF), - (2, 6, 32, 2, 0xF941), - (34, 6, 2, 2, 0xFFFF), - (48, 6, 2, 2, 0x51C8), - (60, 6, 2, 2, 0x51C8), - (78, 6, 2, 2, 0xFFFF), - (80, 6, 32, 2, 0xF941), - (112, 6, 2, 16, 0xFFFF), - (2, 8, 2, 12, 0xF941), - (4, 8, 6, 2, 0xFFFF), - (10, 8, 4, 2, 0xF941), - (14, 8, 4, 2, 0xFFFF), - (18, 8, 4, 2, 0xF941), - (22, 8, 6, 2, 0xFFFF), - (28, 8, 8, 2, 0xF941), - (36, 8, 2, 2, 0xFFFF), - (76, 8, 2, 2, 0xFFFF), - (78, 8, 6, 10, 0xF941), - (84, 8, 6, 2, 0xFFFF), - (90, 8, 4, 2, 0xF941), - (94, 8, 4, 2, 0xFFFF), - (98, 8, 4, 2, 0xF941), - (102, 8, 6, 2, 0xFFFF), - (108, 8, 4, 2, 0xF941), - (4, 10, 2, 10, 0xF941), - (6, 10, 2, 8, 0xFFFF), - (8, 10, 4, 10, 0xF941), - (12, 10, 2, 8, 0xFFFF), - (14, 10, 4, 4, 0xF941), - (18, 10, 2, 8, 0xFFFF), - (20, 10, 2, 10, 0xF941), - (22, 10, 2, 8, 0xFFFF), - (24, 10, 4, 4, 0xF941), - (28, 10, 2, 4, 0xFFFF), - (30, 10, 8, 6, 0xF941), - (38, 10, 2, 2, 0xFFFF), - (54, 10, 4, 2, 0x51C8), - (74, 10, 2, 2, 0xFFFF), - (76, 10, 2, 6, 0xF941), - (84, 10, 2, 10, 0xF941), - (86, 10, 2, 8, 0xFFFF), - (88, 10, 4, 10, 0xF941), - (92, 10, 2, 8, 0xFFFF), - (94, 10, 4, 4, 0xF941), - (98, 10, 2, 8, 0xFFFF), - (100, 10, 2, 10, 0xF941), - (102, 10, 2, 8, 0xFFFF), - (104, 10, 4, 4, 0xF941), - (108, 10, 2, 4, 0xFFFF), - (110, 10, 2, 10, 0xF941), - (38, 12, 2, 2, 0xF941), - (40, 12, 2, 2, 0xFFFF), - (52, 12, 2, 12, 0x51C8), - (54, 12, 4, 18, 0xFFFF), - (58, 12, 2, 8, 0x51C8), - (72, 12, 2, 2, 0xFFFF), - (74, 12, 2, 2, 0xF941), - (14, 14, 4, 2, 0xFFFF), - (24, 14, 4, 2, 0xFFFF), - (28, 14, 2, 6, 0xF941), - (38, 14, 2, 2, 0xFFFF), - (74, 14, 2, 2, 0xFFFF), - (94, 14, 4, 2, 0xFFFF), - (104, 14, 4, 2, 0xFFFF), - (108, 14, 2, 6, 0xF941), - (14, 16, 4, 4, 0xF941), - (24, 16, 4, 4, 0xF941), - (30, 16, 6, 2, 0xF941), - (36, 16, 2, 2, 0xFFFF), - (76, 16, 2, 2, 0xFFFF), - (94, 16, 4, 4, 0xF941), - (104, 16, 4, 4, 0xF941), - (6, 18, 2, 2, 0xF941), - (12, 18, 2, 2, 0xF941), - (18, 18, 2, 2, 0xF941), - (22, 18, 2, 2, 0xF941), - (30, 18, 4, 2, 0xF941), - (34, 18, 2, 2, 0xFFFF), - (60, 18, 4, 2, 0x51C8), - (78, 18, 2, 2, 0xFFFF), - (80, 18, 4, 2, 0xF941), - (86, 18, 2, 2, 0xF941), - (92, 18, 2, 2, 0xF941), - (98, 18, 2, 2, 0xF941), - (102, 18, 2, 2, 0xF941), - (2, 20, 32, 2, 0xFFFF), - (50, 20, 2, 2, 0x51C8), - (58, 20, 6, 12, 0xFFFF), - (64, 20, 2, 2, 0x51C8), - (80, 20, 32, 2, 0xFFFF), - (48, 22, 2, 6, 0x51C8), - (50, 22, 2, 6, 0xFFFF), - (64, 22, 2, 8, 0xFFFF), - (66, 22, 2, 10, 0x51C8), - (52, 24, 2, 4, 0xFFFF), - (50, 28, 2, 2, 0x51C8), - (52, 28, 2, 2, 0xD6BA), - (52, 30, 2, 2, 0x51C8), - (54, 30, 2, 2, 0xD6BA), - (56, 30, 2, 2, 0xFFFF), - (64, 30, 2, 2, 0xD6BA), - (54, 32, 2, 4, 0x51C8), - (56, 32, 8, 2, 0xD6BA), - (64, 32, 2, 4, 0x51C8), - (56, 34, 8, 2, 0x51C8), -] }; - -pub const PIPE_W: i32 = 52; -pub const PIPE_CAP_H: i32 = 26; - -pub const PIPE_CAP: Sprite = Sprite { w: 52, h: 26, rects: &[ - (0, 0, 52, 2, 0x51C8), - (0, 2, 2, 22, 0x51C8), - (2, 2, 2, 2, 0xC6EE), - (4, 2, 2, 2, 0xCF2E), - (6, 2, 2, 2, 0xD76F), - (8, 2, 2, 2, 0xDF90), - (10, 2, 2, 4, 0xDFD0), - (12, 2, 2, 2, 0xE7F1), - (14, 2, 2, 2, 0xDFD0), - (16, 2, 2, 2, 0xDFB0), - (18, 2, 2, 2, 0xD76F), - (20, 2, 2, 2, 0xDF90), - (22, 2, 2, 2, 0xD76F), - (24, 2, 2, 2, 0xCF2E), - (26, 2, 2, 2, 0xC6EE), - (28, 2, 2, 2, 0xB6AD), - (30, 2, 2, 2, 0xAE6C), - (32, 2, 2, 2, 0xA60B), - (34, 2, 2, 2, 0x95CA), - (36, 2, 2, 2, 0x8D89), - (38, 2, 2, 2, 0x8548), - (40, 2, 2, 2, 0x7CE7), - (42, 2, 2, 2, 0x74C6), - (44, 2, 2, 2, 0x6C85), - (46, 2, 2, 2, 0x6445), - (48, 2, 2, 2, 0x5C24), - (50, 2, 2, 22, 0x51C8), - (2, 4, 2, 16, 0xD76F), - (4, 4, 2, 2, 0xDFB0), - (6, 4, 2, 10, 0xDFD0), - (8, 4, 2, 16, 0xE7F1), - (12, 4, 2, 2, 0xDF90), - (14, 4, 2, 16, 0xD76F), - (16, 4, 2, 8, 0xCF2E), - (18, 4, 2, 16, 0xC6EE), - (20, 4, 2, 16, 0xB6AD), - (22, 4, 2, 16, 0xAE6C), - (24, 4, 2, 2, 0xA60B), - (26, 4, 2, 2, 0x95CA), - (28, 4, 2, 16, 0x8D89), - (30, 4, 2, 14, 0x8548), - (32, 4, 2, 2, 0x7CE7), - (34, 4, 2, 2, 0x74C6), - (36, 4, 2, 2, 0x6C85), - (38, 4, 2, 16, 0x6445), - (40, 4, 2, 16, 0x5C24), - (42, 4, 8, 18, 0x5404), - (4, 6, 2, 2, 0xDF90), - (10, 6, 2, 2, 0xDFD1), - (12, 6, 2, 2, 0xDFB0), - (24, 6, 2, 2, 0xA62B), - (26, 6, 2, 8, 0x9DCA), - (32, 6, 2, 6, 0x7D07), - (34, 6, 2, 2, 0x74A6), - (36, 6, 2, 2, 0x6485), - (4, 8, 2, 2, 0xDFB0), - (10, 8, 2, 6, 0xDFD0), - (12, 8, 2, 2, 0xDF90), - (24, 8, 2, 12, 0xA60B), - (34, 8, 2, 2, 0x6CA6), - (36, 8, 2, 4, 0x6C86), - (4, 10, 2, 10, 0xDF90), - (12, 10, 2, 4, 0xDFB0), - (34, 10, 2, 2, 0x74A6), - (16, 12, 2, 2, 0xCF2F), - (32, 12, 2, 2, 0x7CE7), - (34, 12, 2, 2, 0x74C6), - (36, 12, 2, 2, 0x6486), - (6, 14, 2, 2, 0xE7D0), - (10, 14, 2, 2, 0xE7D0), - (12, 14, 2, 6, 0xDF90), - (16, 14, 2, 2, 0xCF2E), - (26, 14, 2, 2, 0x95CA), - (32, 14, 2, 2, 0x7D07), - (34, 14, 2, 4, 0x74A6), - (36, 14, 2, 6, 0x6C86), - (6, 16, 2, 2, 0xDFD0), - (10, 16, 2, 2, 0xDFD1), - (16, 16, 2, 2, 0xCF2F), - (26, 16, 2, 2, 0x9DCA), - (32, 16, 2, 2, 0x7CE7), - (6, 18, 2, 2, 0xDFD1), - (10, 18, 2, 2, 0xDFD0), - (16, 18, 2, 2, 0xCF2E), - (26, 18, 2, 2, 0x95CA), - (30, 18, 2, 2, 0x8528), - (32, 18, 2, 2, 0x7D07), - (34, 18, 2, 2, 0x6CC6), - (2, 20, 40, 2, 0x5404), - (2, 22, 48, 2, 0x51C8), - (2, 24, 2, 2, 0x51C8), - (4, 24, 44, 2, 0x5404), - (48, 24, 2, 2, 0x51C8), -] }; - -pub const PIPE_BODY: Sprite = Sprite { w: 52, h: 1, rects: &[ - (2, 0, 2, 1, 0x51C8), - (4, 0, 2, 1, 0x8548), - (6, 0, 2, 1, 0x95AA), - (8, 0, 2, 1, 0xA62B), - (10, 0, 2, 1, 0xB6AD), - (12, 0, 2, 1, 0xC70E), - (14, 0, 2, 1, 0xD76F), - (16, 0, 2, 1, 0xDFB0), - (18, 0, 2, 1, 0xE7F1), - (20, 0, 2, 1, 0xDFB0), - (22, 0, 2, 1, 0xD76F), - (24, 0, 2, 1, 0xC70E), - (26, 0, 2, 1, 0xB6AD), - (28, 0, 2, 1, 0xA62B), - (30, 0, 2, 1, 0x95AA), - (32, 0, 2, 1, 0x8548), - (34, 0, 2, 1, 0x74E7), - (36, 0, 2, 1, 0x6C86), - (38, 0, 2, 1, 0x5C25), - (40, 0, 8, 1, 0x5404), - (48, 0, 2, 1, 0x51C8), -] }; - -pub const SKY: u16 = 0x4E19; - -pub const BAND: Sprite = Sprite { w: 288, h: 208, rects: &[ - (0, 0, 192, 2, 0x4E19), - (192, 0, 12, 2, 0x5619), - (204, 0, 84, 2, 0x4E19), - (0, 2, 188, 2, 0x4E19), - (188, 2, 2, 2, 0x5619), - (190, 2, 2, 2, 0x5639), - (192, 2, 4, 2, 0x5E39), - (196, 2, 4, 2, 0x6639), - (200, 2, 4, 2, 0x5E39), - (204, 2, 2, 2, 0x5639), - (206, 2, 2, 2, 0x5619), - (208, 2, 80, 2, 0x4E19), - (0, 4, 12, 2, 0x4E19), - (12, 4, 12, 2, 0x5619), - (24, 4, 126, 2, 0x4E19), - (150, 4, 12, 2, 0x5619), - (162, 4, 22, 2, 0x4E19), - (184, 4, 2, 2, 0x5619), - (186, 4, 2, 2, 0x5639), - (188, 4, 2, 2, 0x5E39), - (190, 4, 2, 2, 0x6E59), - (192, 4, 2, 2, 0xD7BA), - (194, 4, 2, 2, 0xDFBA), - (196, 4, 4, 2, 0xDFBB), - (200, 4, 2, 2, 0xDFBA), - (202, 4, 2, 2, 0xD7BA), - (204, 4, 2, 2, 0x6E59), - (206, 4, 2, 2, 0x5E39), - (208, 4, 2, 2, 0x5639), - (210, 4, 2, 2, 0x5619), - (212, 4, 76, 2, 0x4E19), - (0, 6, 8, 2, 0x4E19), - (8, 6, 2, 2, 0x5619), - (10, 6, 2, 2, 0x5639), - (12, 6, 4, 2, 0x5E39), - (16, 6, 4, 2, 0x6639), - (20, 6, 4, 2, 0x5E39), - (24, 6, 2, 2, 0x5639), - (26, 6, 2, 2, 0x5619), - (28, 6, 118, 2, 0x4E19), - (146, 6, 2, 2, 0x5619), - (148, 6, 2, 2, 0x5639), - (150, 6, 4, 2, 0x5E39), - (154, 6, 4, 2, 0x6639), - (158, 6, 4, 2, 0x5E39), - (162, 6, 2, 2, 0x5639), - (164, 6, 4, 2, 0x5619), - (168, 6, 12, 2, 0x4E19), - (180, 6, 4, 2, 0x5619), - (184, 6, 2, 2, 0x5E39), - (186, 6, 2, 2, 0x6E59), - (188, 6, 2, 2, 0xD7BA), - (190, 6, 2, 2, 0xDFBB), - (192, 6, 12, 2, 0xE7DB), - (204, 6, 2, 2, 0xDFBB), - (206, 6, 2, 2, 0xD7BA), - (208, 6, 2, 2, 0x6E59), - (210, 6, 2, 2, 0x5E39), - (212, 6, 4, 2, 0x5619), - (216, 6, 72, 2, 0x4E19), - (0, 8, 4, 2, 0x4E19), - (4, 8, 2, 2, 0x5619), - (6, 8, 2, 2, 0x5639), - (8, 8, 2, 2, 0x5E39), - (10, 8, 2, 2, 0x6E59), - (12, 8, 2, 2, 0xD7BA), - (14, 8, 2, 2, 0xDFBA), - (16, 8, 4, 2, 0xDFBB), - (20, 8, 2, 2, 0xDFBA), - (22, 8, 2, 2, 0xD7BA), - (24, 8, 2, 2, 0x6E59), - (26, 8, 2, 2, 0x5E39), - (28, 8, 2, 2, 0x5639), - (30, 8, 2, 2, 0x5619), - (32, 8, 54, 2, 0x4E19), - (86, 8, 12, 2, 0x5619), - (98, 8, 44, 2, 0x4E19), - (142, 8, 2, 2, 0x5619), - (144, 8, 2, 2, 0x5639), - (146, 8, 2, 2, 0x5E39), - (148, 8, 2, 2, 0x6E59), - (150, 8, 2, 2, 0xD7BA), - (152, 8, 2, 2, 0xDFBA), - (154, 8, 4, 2, 0xDFBB), - (158, 8, 2, 2, 0xDFBA), - (160, 8, 2, 2, 0xD7BA), - (162, 8, 2, 2, 0x6E59), - (164, 8, 2, 2, 0x6659), - (166, 8, 2, 2, 0x5E39), - (168, 8, 2, 2, 0x5639), - (170, 8, 2, 2, 0x5619), - (172, 8, 6, 2, 0x4E19), - (178, 8, 2, 2, 0x5619), - (180, 8, 2, 2, 0x5639), - (182, 8, 2, 2, 0x6659), - (184, 8, 2, 2, 0xD7BA), - (186, 8, 2, 2, 0xDFBB), - (188, 8, 6, 2, 0xE7DB), - (194, 8, 8, 22, 0xEFFB), - (202, 8, 6, 2, 0xE7DB), - (208, 8, 2, 2, 0xDFBB), - (210, 8, 2, 2, 0xD7BA), - (212, 8, 2, 2, 0x6639), - (214, 8, 2, 2, 0x5619), - (216, 8, 8, 2, 0x4E19), - (224, 8, 12, 2, 0x5619), - (236, 8, 52, 2, 0x4E19), - (0, 10, 4, 2, 0x5619), - (4, 10, 2, 2, 0x5E39), - (6, 10, 2, 2, 0x6E59), - (8, 10, 2, 2, 0xD7BA), - (10, 10, 2, 2, 0xDFBB), - (12, 10, 12, 2, 0xE7DB), - (24, 10, 2, 2, 0xDFBB), - (26, 10, 2, 2, 0xD7BA), - (28, 10, 2, 2, 0x6E59), - (30, 10, 2, 2, 0x5E39), - (32, 10, 4, 2, 0x5619), - (36, 10, 46, 2, 0x4E19), - (82, 10, 2, 2, 0x5619), - (84, 10, 2, 2, 0x5639), - (86, 10, 4, 2, 0x5E39), - (90, 10, 4, 2, 0x6639), - (94, 10, 4, 2, 0x5E39), - (98, 10, 2, 2, 0x5639), - (100, 10, 2, 2, 0x5619), - (102, 10, 22, 2, 0x4E19), - (124, 10, 18, 2, 0x5619), - (142, 10, 2, 2, 0x5E39), - (144, 10, 2, 2, 0x6E59), - (146, 10, 2, 2, 0xD7BA), - (148, 10, 2, 2, 0xDFBB), - (150, 10, 12, 2, 0xE7DB), - (162, 10, 2, 2, 0xDFDB), - (164, 10, 2, 2, 0xDFBA), - (166, 10, 2, 2, 0xD7BA), - (168, 10, 2, 2, 0x6E59), - (170, 10, 2, 2, 0x5E39), - (172, 10, 2, 2, 0x5639), - (174, 10, 4, 2, 0x5619), - (178, 10, 2, 2, 0x5639), - (180, 10, 2, 2, 0x6659), - (182, 10, 2, 2, 0xDFBA), - (184, 10, 6, 2, 0xE7DB), - (190, 10, 4, 20, 0xEFFB), - (202, 10, 4, 20, 0xEFFB), - (206, 10, 4, 2, 0xE7DB), - (210, 10, 2, 2, 0xDFDB), - (212, 10, 2, 2, 0xD7BA), - (214, 10, 2, 2, 0x5E39), - (216, 10, 6, 2, 0x5619), - (222, 10, 2, 2, 0x5639), - (224, 10, 4, 2, 0x5E39), - (228, 10, 4, 2, 0x6639), - (232, 10, 4, 2, 0x5E39), - (236, 10, 2, 2, 0x5639), - (238, 10, 2, 2, 0x5619), - (240, 10, 22, 2, 0x4E19), - (262, 10, 12, 2, 0x5619), - (274, 10, 12, 2, 0x4E19), - (286, 10, 2, 2, 0x5619), - (0, 12, 2, 2, 0x5E39), - (2, 12, 2, 2, 0x6659), - (4, 12, 2, 2, 0xD7BA), - (6, 12, 2, 2, 0xDFBB), - (8, 12, 6, 2, 0xE7DB), - (14, 12, 8, 30, 0xEFFB), - (22, 12, 6, 2, 0xE7DB), - (28, 12, 2, 2, 0xDFBB), - (30, 12, 2, 2, 0xD7BA), - (32, 12, 2, 2, 0x6659), - (34, 12, 2, 2, 0x5639), - (36, 12, 2, 2, 0x5619), - (38, 12, 40, 2, 0x4E19), - (78, 12, 2, 2, 0x5619), - (80, 12, 2, 2, 0x5639), - (82, 12, 2, 2, 0x5E39), - (84, 12, 2, 2, 0x6E59), - (86, 12, 2, 2, 0xD7BA), - (88, 12, 2, 2, 0xDFBA), - (90, 12, 4, 2, 0xDFBB), - (94, 12, 2, 2, 0xDFBA), - (96, 12, 2, 2, 0xD7BA), - (98, 12, 2, 2, 0x6E59), - (100, 12, 2, 2, 0x5E39), - (102, 12, 2, 2, 0x5639), - (104, 12, 2, 2, 0x5619), - (106, 12, 14, 2, 0x4E19), - (120, 12, 2, 2, 0x5619), - (122, 12, 2, 2, 0x5639), - (124, 12, 4, 2, 0x5E39), - (128, 12, 4, 2, 0x6639), - (132, 12, 4, 2, 0x5E39), - (136, 12, 2, 2, 0x5639), - (138, 12, 2, 2, 0x5E39), - (140, 12, 2, 2, 0x6659), - (142, 12, 2, 2, 0xD7BA), - (144, 12, 2, 2, 0xDFBB), - (146, 12, 6, 2, 0xE7DB), - (152, 12, 8, 30, 0xEFFB), - (160, 12, 8, 2, 0xE7DB), - (168, 12, 2, 2, 0xDFBB), - (170, 12, 2, 2, 0xD7BA), - (172, 12, 2, 2, 0x6E59), - (174, 12, 2, 2, 0x6639), - (176, 12, 2, 2, 0x5E39), - (178, 12, 2, 2, 0x6E59), - (180, 12, 2, 2, 0xDFBA), - (182, 12, 4, 2, 0xE7DB), - (186, 12, 4, 22, 0xEFFB), - (206, 12, 4, 18, 0xEFFB), - (210, 12, 2, 4, 0xE7DB), - (212, 12, 2, 2, 0xDFBB), - (214, 12, 2, 2, 0x6E59), - (216, 12, 2, 2, 0x5E39), - (218, 12, 2, 2, 0x5639), - (220, 12, 2, 2, 0x5E39), - (222, 12, 2, 2, 0x6E59), - (224, 12, 2, 2, 0xD7BA), - (226, 12, 2, 2, 0xDFBA), - (228, 12, 4, 2, 0xDFBB), - (232, 12, 2, 2, 0xDFBA), - (234, 12, 2, 2, 0xD7BA), - (236, 12, 2, 2, 0x6E59), - (238, 12, 2, 2, 0x5E39), - (240, 12, 2, 2, 0x5639), - (242, 12, 2, 2, 0x5619), - (244, 12, 14, 2, 0x4E19), - (258, 12, 2, 2, 0x5619), - (260, 12, 2, 2, 0x5639), - (262, 12, 4, 2, 0x5E39), - (266, 12, 4, 2, 0x6639), - (270, 12, 4, 2, 0x5E39), - (274, 12, 2, 2, 0x5639), - (276, 12, 2, 2, 0x5619), - (278, 12, 4, 2, 0x4E19), - (282, 12, 4, 2, 0x5619), - (286, 12, 2, 2, 0x5639), - (0, 14, 2, 2, 0x7659), - (2, 14, 2, 2, 0xDFBA), - (4, 14, 6, 2, 0xE7DB), - (10, 14, 4, 28, 0xEFFB), - (22, 14, 4, 24, 0xEFFB), - (26, 14, 6, 2, 0xE7DB), - (32, 14, 2, 2, 0xDFBA), - (34, 14, 2, 2, 0x6659), - (36, 14, 2, 2, 0x5639), - (38, 14, 2, 4, 0x5619), - (40, 14, 34, 2, 0x4E19), - (74, 14, 4, 2, 0x5619), - (78, 14, 2, 2, 0x5E39), - (80, 14, 2, 2, 0x6E59), - (82, 14, 2, 2, 0xD7BA), - (84, 14, 2, 2, 0xDFBB), - (86, 14, 12, 2, 0xE7DB), - (98, 14, 2, 2, 0xDFBB), - (100, 14, 2, 2, 0xD7BA), - (102, 14, 2, 2, 0x6E59), - (104, 14, 2, 2, 0x5E39), - (106, 14, 4, 2, 0x5619), - (110, 14, 6, 2, 0x4E19), - (116, 14, 2, 2, 0x5619), - (118, 14, 2, 2, 0x5639), - (120, 14, 2, 2, 0x5E39), - (122, 14, 2, 2, 0x6E59), - (124, 14, 2, 2, 0xD7BA), - (126, 14, 2, 2, 0xDFBA), - (128, 14, 4, 2, 0xDFBB), - (132, 14, 2, 2, 0xDFBA), - (134, 14, 2, 2, 0xD7BA), - (136, 14, 2, 2, 0x6E59), - (138, 14, 2, 2, 0x7659), - (140, 14, 2, 2, 0xDFBA), - (142, 14, 6, 2, 0xE7DB), - (148, 14, 4, 28, 0xEFFB), - (160, 14, 6, 24, 0xEFFB), - (166, 14, 6, 2, 0xE7DB), - (172, 14, 2, 2, 0xDFBB), - (174, 14, 2, 2, 0xDFBA), - (176, 14, 2, 2, 0x7679), - (178, 14, 2, 2, 0xDFBB), - (180, 14, 4, 2, 0xE7DB), - (184, 14, 2, 24, 0xEFFB), - (212, 14, 2, 4, 0xE7DB), - (214, 14, 2, 2, 0xDFBA), - (216, 14, 2, 2, 0x7659), - (218, 14, 2, 2, 0x6E59), - (220, 14, 2, 2, 0xD7BA), - (222, 14, 2, 2, 0xDFBB), - (224, 14, 12, 2, 0xE7DB), - (236, 14, 2, 2, 0xDFBB), - (238, 14, 2, 2, 0xD7BA), - (240, 14, 2, 2, 0x6E59), - (242, 14, 2, 2, 0x5E39), - (244, 14, 4, 2, 0x5619), - (248, 14, 6, 2, 0x4E19), - (254, 14, 2, 2, 0x5619), - (256, 14, 2, 2, 0x5639), - (258, 14, 2, 2, 0x5E39), - (260, 14, 2, 2, 0x6E59), - (262, 14, 2, 2, 0xD7BA), - (264, 14, 2, 2, 0xDFBA), - (266, 14, 4, 2, 0xDFBB), - (270, 14, 2, 2, 0xDFBA), - (272, 14, 2, 2, 0xD7BA), - (274, 14, 2, 2, 0x6E59), - (276, 14, 2, 2, 0x5E39), - (278, 14, 6, 2, 0x5639), - (284, 14, 2, 2, 0x6659), - (286, 14, 2, 2, 0xD79A), - (0, 16, 6, 2, 0xE7DB), - (6, 16, 4, 24, 0xEFFB), - (26, 16, 4, 20, 0xEFFB), - (30, 16, 4, 2, 0xE7DB), - (34, 16, 2, 2, 0xDFBA), - (36, 16, 2, 2, 0x6659), - (40, 16, 32, 2, 0x4E19), - (72, 16, 2, 2, 0x5619), - (74, 16, 2, 2, 0x5639), - (76, 16, 2, 2, 0x6659), - (78, 16, 2, 2, 0xD7BA), - (80, 16, 2, 2, 0xDFBB), - (82, 16, 6, 2, 0xE7DB), - (88, 16, 8, 22, 0xEFFB), - (96, 16, 6, 2, 0xE7DB), - (102, 16, 2, 2, 0xDFBB), - (104, 16, 2, 2, 0xD7BA), - (106, 16, 2, 2, 0x6659), - (108, 16, 2, 2, 0x5639), - (110, 16, 6, 2, 0x5619), - (116, 16, 2, 2, 0x5E39), - (118, 16, 2, 2, 0x6E59), - (120, 16, 2, 2, 0xD7BA), - (122, 16, 2, 2, 0xDFBB), - (124, 16, 12, 2, 0xE7DB), - (136, 16, 2, 2, 0xDFDB), - (138, 16, 6, 2, 0xE7DB), - (144, 16, 4, 24, 0xEFFB), - (166, 16, 4, 20, 0xEFFB), - (170, 16, 12, 2, 0xE7DB), - (182, 16, 2, 22, 0xEFFB), - (210, 16, 2, 18, 0xEFFB), - (214, 16, 4, 4, 0xE7DB), - (218, 16, 2, 2, 0xDFDB), - (220, 16, 6, 2, 0xE7DB), - (226, 16, 8, 22, 0xEFFB), - (234, 16, 6, 2, 0xE7DB), - (240, 16, 2, 2, 0xDFBB), - (242, 16, 2, 2, 0xD7BA), - (244, 16, 2, 2, 0x6659), - (246, 16, 2, 2, 0x5639), - (248, 16, 6, 2, 0x5619), - (254, 16, 2, 2, 0x5E39), - (256, 16, 2, 2, 0x6E59), - (258, 16, 2, 2, 0xD7BA), - (260, 16, 2, 2, 0xDFBB), - (262, 16, 12, 2, 0xE7DB), - (274, 16, 2, 2, 0xDFBB), - (276, 16, 2, 2, 0xD7BA), - (278, 16, 6, 2, 0x6E59), - (284, 16, 2, 2, 0xDFBA), - (286, 16, 2, 2, 0xDFDB), - (0, 18, 4, 2, 0xE7DB), - (4, 18, 2, 20, 0xEFFB), - (30, 18, 2, 18, 0xEFFB), - (32, 18, 4, 2, 0xE7DB), - (36, 18, 2, 2, 0xD7BA), - (38, 18, 2, 2, 0x5E39), - (40, 18, 2, 2, 0x5619), - (42, 18, 8, 2, 0x4E19), - (50, 18, 12, 2, 0x5619), - (62, 18, 8, 2, 0x4E19), - (70, 18, 2, 4, 0x5619), - (72, 18, 2, 2, 0x5639), - (74, 18, 2, 2, 0x6659), - (76, 18, 2, 2, 0xDFBA), - (78, 18, 6, 2, 0xE7DB), - (84, 18, 4, 26, 0xEFFB), - (96, 18, 4, 18, 0xEFFB), - (100, 18, 6, 2, 0xE7DB), - (106, 18, 2, 2, 0xDFBA), - (108, 18, 2, 2, 0x6659), - (110, 18, 4, 2, 0x5E39), - (114, 18, 2, 2, 0x6659), - (116, 18, 2, 2, 0xD7BA), - (118, 18, 2, 2, 0xDFBB), - (120, 18, 6, 2, 0xE7DB), - (126, 18, 8, 12, 0xEFFB), - (134, 18, 8, 2, 0xE7DB), - (142, 18, 2, 20, 0xEFFB), - (170, 18, 6, 18, 0xEFFB), - (176, 18, 2, 2, 0xE7DB), - (178, 18, 4, 20, 0xEFFB), - (212, 18, 2, 20, 0xEFFB), - (218, 18, 4, 2, 0xE7DB), - (222, 18, 4, 26, 0xEFFB), - (234, 18, 4, 18, 0xEFFB), - (238, 18, 6, 2, 0xE7DB), - (244, 18, 2, 2, 0xDFBA), - (246, 18, 2, 2, 0x6659), - (248, 18, 4, 2, 0x5E39), - (252, 18, 2, 2, 0x6659), - (254, 18, 2, 2, 0xD7BA), - (256, 18, 2, 2, 0xDFBB), - (258, 18, 6, 2, 0xE7DB), - (264, 18, 8, 12, 0xEFFB), - (272, 18, 6, 2, 0xE7DB), - (278, 18, 2, 2, 0xDFDB), - (280, 18, 2, 2, 0xDFBB), - (282, 18, 2, 2, 0xDFDB), - (284, 18, 4, 2, 0xE7DB), - (0, 20, 4, 18, 0xEFFB), - (32, 20, 2, 16, 0xEFFB), - (34, 20, 2, 4, 0xE7DB), - (36, 20, 2, 2, 0xDFBB), - (38, 20, 2, 2, 0x6E59), - (40, 20, 2, 2, 0x5639), - (42, 20, 2, 2, 0x5619), - (44, 20, 2, 2, 0x4E19), - (46, 20, 2, 2, 0x5619), - (48, 20, 2, 2, 0x5639), - (50, 20, 4, 2, 0x5E39), - (54, 20, 4, 2, 0x6639), - (58, 20, 4, 2, 0x5E39), - (62, 20, 2, 2, 0x5639), - (64, 20, 2, 2, 0x5619), - (66, 20, 2, 2, 0x4E19), - (68, 20, 2, 2, 0x5619), - (72, 20, 2, 2, 0x6659), - (74, 20, 2, 2, 0xDFBA), - (76, 20, 4, 2, 0xE7DB), - (80, 20, 4, 22, 0xEFFB), - (100, 20, 4, 16, 0xEFFB), - (104, 20, 4, 2, 0xE7DB), - (108, 20, 2, 2, 0xDFBA), - (110, 20, 4, 2, 0x7659), - (114, 20, 2, 2, 0xDFBA), - (116, 20, 6, 2, 0xE7DB), - (122, 20, 4, 10, 0xEFFB), - (134, 20, 8, 10, 0xEFFB), - (176, 20, 2, 16, 0xEFFB), - (214, 20, 8, 20, 0xEFFB), - (238, 20, 4, 16, 0xEFFB), - (242, 20, 4, 2, 0xE7DB), - (246, 20, 2, 2, 0xDFBA), - (248, 20, 4, 2, 0x7659), - (252, 20, 2, 2, 0xDFBA), - (254, 20, 6, 2, 0xE7DB), - (260, 20, 4, 10, 0xEFFB), - (272, 20, 4, 10, 0xEFFB), - (276, 20, 10, 2, 0xE7DB), - (286, 20, 2, 22, 0xEFFB), - (36, 22, 2, 6, 0xE7DB), - (38, 22, 2, 2, 0xD7BA), - (40, 22, 2, 2, 0x6639), - (42, 22, 4, 2, 0x5639), - (46, 22, 2, 2, 0x5E39), - (48, 22, 2, 2, 0x6E59), - (50, 22, 2, 2, 0xD7BA), - (52, 22, 2, 2, 0xDFBA), - (54, 22, 4, 2, 0xDFBB), - (58, 22, 2, 2, 0xDFBA), - (60, 22, 2, 2, 0xD7BA), - (62, 22, 2, 2, 0x6E59), - (64, 22, 2, 2, 0x5E39), - (66, 22, 4, 2, 0x5639), - (70, 22, 2, 2, 0x6639), - (72, 22, 2, 2, 0xD7BA), - (74, 22, 4, 2, 0xE7DB), - (78, 22, 2, 20, 0xEFFB), - (104, 22, 2, 14, 0xEFFB), - (106, 22, 12, 2, 0xE7DB), - (118, 22, 4, 10, 0xEFFB), - (242, 22, 2, 14, 0xEFFB), - (244, 22, 12, 2, 0xE7DB), - (256, 22, 4, 10, 0xEFFB), - (276, 22, 10, 10, 0xEFFB), - (34, 24, 2, 12, 0xEFFB), - (38, 24, 2, 2, 0xDFDB), - (40, 24, 2, 2, 0x7679), - (42, 24, 4, 2, 0x6E59), - (46, 24, 2, 2, 0xD7BA), - (48, 24, 2, 2, 0xDFBB), - (50, 24, 12, 2, 0xE7DB), - (62, 24, 2, 2, 0xDFBB), - (64, 24, 2, 2, 0xD7BA), - (66, 24, 4, 2, 0x6E59), - (70, 24, 2, 2, 0x7679), - (72, 24, 2, 2, 0xDFDB), - (74, 24, 2, 4, 0xE7DB), - (76, 24, 2, 16, 0xEFFB), - (106, 24, 2, 12, 0xEFFB), - (108, 24, 8, 2, 0xE7DB), - (116, 24, 2, 14, 0xEFFB), - (244, 24, 2, 12, 0xEFFB), - (246, 24, 8, 2, 0xE7DB), - (254, 24, 2, 14, 0xEFFB), - (38, 26, 4, 4, 0xE7DB), - (42, 26, 2, 2, 0xDFBB), - (44, 26, 2, 2, 0xDFDB), - (46, 26, 6, 2, 0xE7DB), - (52, 26, 8, 4, 0xEFFB), - (60, 26, 6, 2, 0xE7DB), - (66, 26, 2, 2, 0xDFDB), - (68, 26, 2, 2, 0xDFBB), - (70, 26, 4, 4, 0xE7DB), - (108, 26, 8, 12, 0xEFFB), - (246, 26, 8, 12, 0xEFFB), - (36, 28, 2, 8, 0xEFFB), - (42, 28, 6, 2, 0xE7DB), - (48, 28, 4, 6, 0xEFFB), - (60, 28, 4, 2, 0xEFFB), - (64, 28, 6, 6, 0xE7DB), - (74, 28, 2, 10, 0xEFFB), - (38, 30, 10, 6, 0xEFFB), - (52, 30, 2, 2, 0xEFFB), - (54, 30, 2, 2, 0xEFDB), - (56, 30, 8, 2, 0xE7DB), - (70, 30, 4, 2, 0xEFFB), - (122, 30, 2, 2, 0xEFDB), - (124, 30, 14, 2, 0xE7DB), - (138, 30, 4, 2, 0xEFFB), - (190, 30, 2, 2, 0xEFFB), - (192, 30, 2, 2, 0xEFDB), - (194, 30, 14, 2, 0xE7DB), - (208, 30, 2, 2, 0xEFFB), - (260, 30, 2, 2, 0xEFDB), - (262, 30, 14, 2, 0xE7DB), - (52, 32, 2, 4, 0xE7DB), - (54, 32, 6, 2, 0xE7DA), - (60, 32, 4, 2, 0xE7DB), - (70, 32, 2, 8, 0xE7DB), - (72, 32, 2, 2, 0xEFFB), - (118, 32, 2, 2, 0xEFFB), - (120, 32, 2, 4, 0xE7DB), - (122, 32, 6, 2, 0xE7DA), - (128, 32, 12, 2, 0xE7DB), - (140, 32, 2, 2, 0xEFFB), - (190, 32, 2, 4, 0xE7DB), - (192, 32, 6, 2, 0xE7DA), - (198, 32, 12, 2, 0xE7DB), - (256, 32, 2, 2, 0xEFFB), - (258, 32, 2, 4, 0xE7DB), - (260, 32, 6, 2, 0xE7DA), - (266, 32, 12, 2, 0xE7DB), - (278, 32, 8, 2, 0xEFFB), - (48, 34, 2, 4, 0xEFFB), - (50, 34, 2, 8, 0xE7DB), - (54, 34, 2, 2, 0xBF58), - (56, 34, 4, 2, 0xBF38), - (60, 34, 6, 2, 0xA6FA), - (66, 34, 4, 2, 0xA6FB), - (72, 34, 2, 8, 0xE7DB), - (118, 34, 2, 8, 0xE7DB), - (122, 34, 2, 2, 0xBF58), - (124, 34, 4, 2, 0xBF38), - (128, 34, 6, 2, 0xA6FA), - (134, 34, 4, 2, 0xA6FB), - (138, 34, 4, 6, 0xE7DB), - (186, 34, 2, 4, 0xEFFB), - (188, 34, 2, 8, 0xE7DB), - (192, 34, 2, 2, 0xBF58), - (194, 34, 4, 2, 0xBF38), - (198, 34, 6, 2, 0xA6FA), - (204, 34, 4, 2, 0xA6FB), - (208, 34, 4, 6, 0xE7DB), - (256, 34, 2, 8, 0xE7DB), - (260, 34, 2, 2, 0xBF58), - (262, 34, 4, 2, 0xBF38), - (266, 34, 6, 2, 0xA6FA), - (272, 34, 4, 2, 0xA6FB), - (276, 34, 4, 6, 0xE7DB), - (280, 34, 6, 4, 0xEFFB), - (26, 36, 2, 2, 0xEFFB), - (28, 36, 12, 2, 0xEFDB), - (40, 36, 8, 2, 0xEFFB), - (52, 36, 2, 2, 0xE7DA), - (54, 36, 2, 2, 0xBF38), - (56, 36, 2, 2, 0xD779), - (58, 36, 2, 2, 0xCF79), - (60, 36, 2, 2, 0x9EFA), - (62, 36, 6, 2, 0xD779), - (68, 36, 2, 2, 0xA6FB), - (96, 36, 12, 2, 0xEFDB), - (120, 36, 2, 2, 0xE7DA), - (122, 36, 2, 2, 0xBF38), - (124, 36, 2, 2, 0xD779), - (126, 36, 2, 2, 0xCF79), - (128, 36, 2, 2, 0x9EFA), - (130, 36, 6, 2, 0xD779), - (136, 36, 2, 2, 0xA6FB), - (166, 36, 12, 2, 0xEFDB), - (190, 36, 2, 2, 0xE7DA), - (192, 36, 2, 2, 0xBF38), - (194, 36, 2, 2, 0xD779), - (196, 36, 2, 2, 0xCF79), - (198, 36, 2, 2, 0x9EFA), - (200, 36, 6, 2, 0xD779), - (206, 36, 2, 2, 0xA6FB), - (234, 36, 12, 2, 0xEFDB), - (258, 36, 2, 2, 0xE7DA), - (260, 36, 2, 2, 0xBF38), - (262, 36, 2, 2, 0xD779), - (264, 36, 2, 2, 0xCF79), - (266, 36, 2, 2, 0x9EFA), - (268, 36, 6, 2, 0xD779), - (274, 36, 2, 2, 0xA6FB), - (0, 38, 6, 4, 0xE7DB), - (22, 38, 2, 2, 0xEFFB), - (24, 38, 6, 2, 0xEFDB), - (30, 38, 10, 2, 0xE79A), - (40, 38, 10, 4, 0xE7DB), - (52, 38, 2, 2, 0xA6FB), - (54, 38, 2, 2, 0xA6FA), - (56, 38, 6, 2, 0x9EDA), - (62, 38, 2, 4, 0xD778), - (64, 38, 2, 2, 0xB738), - (66, 38, 2, 4, 0xD779), - (68, 38, 2, 4, 0xA6FA), - (74, 38, 2, 4, 0xE7DB), - (88, 38, 4, 2, 0xEFFB), - (92, 38, 6, 2, 0xEFDB), - (98, 38, 10, 2, 0xE79A), - (108, 38, 10, 4, 0xE7DB), - (120, 38, 2, 2, 0xA6FB), - (122, 38, 2, 2, 0xA6FA), - (124, 38, 6, 2, 0x9EDA), - (130, 38, 2, 4, 0xD778), - (132, 38, 2, 2, 0xB738), - (134, 38, 2, 4, 0xD779), - (136, 38, 2, 4, 0xA6FA), - (142, 38, 2, 4, 0xE7DB), - (160, 38, 2, 2, 0xEFFB), - (162, 38, 6, 2, 0xEFDB), - (168, 38, 10, 2, 0xE79A), - (178, 38, 10, 4, 0xE7DB), - (190, 38, 2, 2, 0xA6FB), - (192, 38, 2, 2, 0xA6FA), - (194, 38, 6, 2, 0x9EDA), - (200, 38, 2, 4, 0xD778), - (202, 38, 2, 2, 0xB738), - (204, 38, 2, 4, 0xD779), - (206, 38, 2, 4, 0xA6FA), - (212, 38, 2, 4, 0xE7DB), - (226, 38, 4, 2, 0xEFFB), - (230, 38, 6, 2, 0xEFDB), - (236, 38, 10, 2, 0xE79A), - (246, 38, 10, 4, 0xE7DB), - (258, 38, 2, 2, 0xA6FB), - (260, 38, 2, 2, 0xA6FA), - (262, 38, 6, 2, 0x9EDA), - (268, 38, 2, 4, 0xD778), - (270, 38, 2, 2, 0xB738), - (272, 38, 2, 4, 0xD779), - (274, 38, 2, 4, 0xA6FA), - (280, 38, 2, 4, 0xE7DB), - (282, 38, 4, 2, 0xEFFB), - (6, 40, 2, 4, 0xE7DB), - (8, 40, 2, 2, 0xEFFB), - (22, 40, 4, 2, 0xEFDB), - (26, 40, 6, 2, 0xE79A), - (32, 40, 2, 2, 0xE799), - (34, 40, 2, 2, 0xDF9A), - (36, 40, 4, 2, 0xDF7A), - (52, 40, 2, 6, 0xA6FA), - (54, 40, 2, 10, 0xD779), - (56, 40, 2, 2, 0xCF79), - (58, 40, 4, 2, 0xD778), - (64, 40, 2, 2, 0xD778), - (70, 40, 2, 2, 0xDFBB), - (76, 40, 2, 4, 0xE7DB), - (88, 40, 2, 2, 0xEFFB), - (90, 40, 4, 2, 0xEFDB), - (94, 40, 6, 2, 0xE79A), - (100, 40, 2, 2, 0xE799), - (102, 40, 2, 2, 0xDF9A), - (104, 40, 4, 2, 0xDF7A), - (120, 40, 2, 6, 0xA6FA), - (122, 40, 2, 10, 0xD779), - (124, 40, 2, 2, 0xCF79), - (126, 40, 4, 2, 0xD778), - (132, 40, 2, 2, 0xD778), - (138, 40, 2, 2, 0xDFBB), - (140, 40, 2, 2, 0xE7DB), - (144, 40, 2, 4, 0xE7DB), - (146, 40, 2, 2, 0xEFFB), - (160, 40, 4, 2, 0xEFDB), - (164, 40, 6, 2, 0xE79A), - (170, 40, 2, 2, 0xE799), - (172, 40, 2, 2, 0xDF9A), - (174, 40, 4, 2, 0xDF7A), - (190, 40, 2, 6, 0xA6FA), - (192, 40, 2, 10, 0xD779), - (194, 40, 2, 2, 0xCF79), - (196, 40, 4, 2, 0xD778), - (202, 40, 2, 2, 0xD778), - (208, 40, 2, 2, 0xDFBB), - (210, 40, 2, 2, 0xE7DB), - (214, 40, 2, 4, 0xE7DB), - (216, 40, 6, 2, 0xEFFB), - (226, 40, 2, 2, 0xEFFB), - (228, 40, 4, 2, 0xEFDB), - (232, 40, 6, 2, 0xE79A), - (238, 40, 2, 2, 0xE799), - (240, 40, 2, 2, 0xDF9A), - (242, 40, 4, 2, 0xDF7A), - (258, 40, 2, 6, 0xA6FA), - (260, 40, 2, 10, 0xD779), - (262, 40, 2, 2, 0xCF79), - (264, 40, 4, 2, 0xD778), - (270, 40, 2, 2, 0xD778), - (276, 40, 2, 2, 0xDFBB), - (278, 40, 2, 2, 0xE7DB), - (282, 40, 2, 4, 0xE7DB), - (284, 40, 2, 2, 0xEFFB), - (0, 42, 2, 2, 0x9EFB), - (2, 42, 4, 2, 0xA6FB), - (8, 42, 6, 4, 0xE7DB), - (14, 42, 6, 2, 0xEFFB), - (20, 42, 4, 2, 0xEFDB), - (24, 42, 4, 2, 0xE79A), - (28, 42, 4, 2, 0xE799), - (32, 42, 4, 2, 0xDF79), - (36, 42, 10, 2, 0xA6FA), - (46, 42, 4, 2, 0xA6FB), - (50, 42, 2, 8, 0xDFBB), - (56, 42, 2, 4, 0xBF38), - (58, 42, 2, 2, 0xD778), - (60, 42, 2, 4, 0xBF38), - (62, 42, 2, 20, 0xD798), - (64, 42, 2, 4, 0xBF38), - (66, 42, 2, 18, 0xD778), - (68, 42, 2, 20, 0x9EDA), - (70, 42, 2, 2, 0x9EDB), - (72, 42, 2, 2, 0x9EFB), - (74, 42, 2, 2, 0xA6FB), - (78, 42, 6, 4, 0xE7DB), - (88, 42, 4, 2, 0xEFDB), - (92, 42, 4, 2, 0xE79A), - (96, 42, 4, 2, 0xE799), - (100, 42, 4, 2, 0xDF79), - (104, 42, 10, 2, 0xA6FA), - (114, 42, 4, 2, 0xA6FB), - (118, 42, 2, 8, 0xDFBB), - (124, 42, 2, 4, 0xBF38), - (126, 42, 2, 2, 0xD778), - (128, 42, 2, 4, 0xBF38), - (130, 42, 2, 22, 0xD798), - (132, 42, 2, 4, 0xBF38), - (134, 42, 2, 22, 0xD778), - (136, 42, 2, 24, 0x9EDA), - (138, 42, 2, 2, 0x9EDB), - (140, 42, 2, 2, 0x9EFB), - (142, 42, 2, 2, 0xA6FB), - (146, 42, 6, 4, 0xE7DB), - (152, 42, 6, 2, 0xEFFB), - (158, 42, 4, 2, 0xEFDB), - (162, 42, 4, 2, 0xE79A), - (166, 42, 4, 2, 0xE799), - (170, 42, 4, 2, 0xDF79), - (174, 42, 10, 2, 0xA6FA), - (184, 42, 4, 2, 0xA6FB), - (188, 42, 2, 8, 0xDFBB), - (194, 42, 2, 4, 0xBF38), - (196, 42, 2, 2, 0xD778), - (198, 42, 2, 4, 0xBF38), - (200, 42, 2, 20, 0xD798), - (202, 42, 2, 4, 0xBF38), - (204, 42, 2, 20, 0xD778), - (206, 42, 2, 20, 0x9EDA), - (208, 42, 2, 2, 0x9EDB), - (210, 42, 2, 2, 0x9EFB), - (212, 42, 2, 2, 0xA6FB), - (216, 42, 6, 4, 0xE7DB), - (226, 42, 4, 2, 0xEFDB), - (230, 42, 4, 2, 0xE79A), - (234, 42, 4, 2, 0xE799), - (238, 42, 4, 2, 0xDF79), - (242, 42, 10, 2, 0xA6FA), - (252, 42, 4, 2, 0xA6FB), - (256, 42, 2, 8, 0xDFBB), - (262, 42, 2, 4, 0xBF38), - (264, 42, 2, 2, 0xD778), - (266, 42, 2, 4, 0xBF38), - (268, 42, 2, 22, 0xD798), - (270, 42, 2, 4, 0xBF38), - (272, 42, 2, 22, 0xD778), - (274, 42, 2, 24, 0x9EDA), - (276, 42, 2, 2, 0x9EDB), - (278, 42, 2, 2, 0x9EFB), - (280, 42, 2, 2, 0xA6FB), - (284, 42, 4, 4, 0xE7DB), - (0, 44, 2, 2, 0xB738), - (2, 44, 2, 2, 0xCF79), - (4, 44, 2, 2, 0x9EFB), - (6, 44, 2, 2, 0xDFBB), - (14, 44, 2, 4, 0xE7DB), - (16, 44, 6, 2, 0xEFDB), - (22, 44, 4, 2, 0xE79A), - (26, 44, 4, 2, 0xE799), - (30, 44, 2, 4, 0xDF79), - (32, 44, 4, 2, 0xDF7A), - (36, 44, 2, 2, 0xA6DA), - (38, 44, 4, 2, 0xCF79), - (42, 44, 2, 2, 0xD779), - (44, 44, 2, 4, 0xCF79), - (46, 44, 2, 4, 0xB738), - (48, 44, 2, 2, 0x9EDB), - (58, 44, 2, 16, 0xD798), - (70, 44, 2, 2, 0xAF38), - (72, 44, 2, 2, 0xCF79), - (74, 44, 2, 2, 0x9EFB), - (76, 44, 2, 2, 0xDFBB), - (84, 44, 2, 4, 0xE7DB), - (86, 44, 4, 2, 0xEFDB), - (90, 44, 4, 2, 0xE79A), - (94, 44, 4, 2, 0xE799), - (98, 44, 2, 4, 0xDF79), - (100, 44, 4, 2, 0xDF7A), - (104, 44, 2, 2, 0xA6DA), - (106, 44, 4, 2, 0xCF79), - (110, 44, 2, 2, 0xD779), - (112, 44, 2, 4, 0xCF79), - (114, 44, 2, 4, 0xB738), - (116, 44, 2, 2, 0x9EDB), - (126, 44, 2, 18, 0xD798), - (138, 44, 2, 2, 0xAF38), - (140, 44, 2, 2, 0xCF79), - (142, 44, 2, 2, 0x9EFB), - (144, 44, 2, 2, 0xDFBB), - (152, 44, 2, 4, 0xE7DB), - (154, 44, 6, 2, 0xEFDB), - (160, 44, 4, 2, 0xE79A), - (164, 44, 4, 2, 0xE799), - (168, 44, 2, 4, 0xDF79), - (170, 44, 4, 2, 0xDF7A), - (174, 44, 2, 2, 0xA6DA), - (176, 44, 4, 2, 0xCF79), - (180, 44, 2, 2, 0xD779), - (182, 44, 2, 4, 0xCF79), - (184, 44, 2, 4, 0xB738), - (186, 44, 2, 2, 0x9EDB), - (196, 44, 2, 18, 0xD798), - (208, 44, 2, 2, 0xAF38), - (210, 44, 2, 2, 0xCF79), - (212, 44, 2, 2, 0x9EFB), - (214, 44, 2, 2, 0xDFBB), - (222, 44, 2, 4, 0xE7DB), - (224, 44, 4, 2, 0xEFDB), - (228, 44, 4, 2, 0xE79A), - (232, 44, 4, 2, 0xE799), - (236, 44, 2, 4, 0xDF79), - (238, 44, 4, 2, 0xDF7A), - (242, 44, 2, 2, 0xA6DA), - (244, 44, 4, 2, 0xCF79), - (248, 44, 2, 2, 0xD779), - (250, 44, 2, 4, 0xCF79), - (252, 44, 2, 4, 0xB738), - (254, 44, 2, 2, 0x9EDB), - (264, 44, 2, 18, 0xD798), - (276, 44, 2, 2, 0xAF38), - (278, 44, 2, 2, 0xCF79), - (280, 44, 2, 2, 0x9EFB), - (282, 44, 2, 2, 0xDFBB), - (0, 46, 6, 2, 0x9EDA), - (6, 46, 4, 2, 0xA6FA), - (10, 46, 4, 2, 0xA6FB), - (16, 46, 2, 2, 0xE7DB), - (18, 46, 4, 2, 0xEFDB), - (22, 46, 2, 12, 0xE79A), - (24, 46, 4, 2, 0xE799), - (28, 46, 2, 16, 0xDF79), - (32, 46, 2, 2, 0xDF7A), - (34, 46, 2, 2, 0xD77A), - (36, 46, 2, 4, 0x9EDA), - (38, 46, 2, 2, 0xCF79), - (40, 46, 2, 2, 0xB738), - (42, 46, 2, 2, 0xCF79), - (48, 46, 2, 6, 0x9EDA), - (52, 46, 2, 4, 0x9EFA), - (56, 46, 2, 2, 0xD778), - (60, 46, 2, 2, 0xD798), - (64, 46, 2, 2, 0xD778), - (70, 46, 6, 2, 0x9EDA), - (76, 46, 4, 2, 0xA6FA), - (80, 46, 4, 2, 0xA6FB), - (86, 46, 2, 2, 0xE7DB), - (88, 46, 2, 2, 0xEFDB), - (90, 46, 2, 12, 0xE79A), - (92, 46, 4, 2, 0xE799), - (96, 46, 2, 16, 0xDF79), - (100, 46, 2, 2, 0xDF7A), - (102, 46, 2, 2, 0xD77A), - (104, 46, 2, 4, 0x9EDA), - (106, 46, 2, 2, 0xCF79), - (108, 46, 2, 2, 0xB738), - (110, 46, 2, 2, 0xCF79), - (116, 46, 2, 6, 0x9EDA), - (120, 46, 2, 4, 0x9EFA), - (124, 46, 2, 2, 0xD778), - (128, 46, 2, 2, 0xD798), - (132, 46, 2, 2, 0xD778), - (138, 46, 6, 2, 0x9EDA), - (144, 46, 4, 2, 0xA6FA), - (148, 46, 4, 2, 0xA6FB), - (154, 46, 2, 2, 0xE7DB), - (156, 46, 4, 2, 0xEFDB), - (160, 46, 2, 12, 0xE79A), - (162, 46, 4, 2, 0xE799), - (166, 46, 2, 16, 0xDF79), - (170, 46, 2, 2, 0xDF7A), - (172, 46, 2, 2, 0xD77A), - (174, 46, 2, 4, 0x9EDA), - (176, 46, 2, 2, 0xCF79), - (178, 46, 2, 2, 0xB738), - (180, 46, 2, 2, 0xCF79), - (186, 46, 2, 6, 0x9EDA), - (190, 46, 2, 4, 0x9EFA), - (194, 46, 2, 2, 0xD778), - (198, 46, 2, 2, 0xD798), - (202, 46, 2, 2, 0xD778), - (208, 46, 6, 2, 0x9EDA), - (214, 46, 4, 2, 0xA6FA), - (218, 46, 4, 2, 0xA6FB), - (224, 46, 2, 2, 0xE7DB), - (226, 46, 2, 2, 0xEFDB), - (228, 46, 2, 12, 0xE79A), - (230, 46, 4, 2, 0xE799), - (234, 46, 2, 16, 0xDF79), - (238, 46, 2, 2, 0xDF7A), - (240, 46, 2, 2, 0xD77A), - (242, 46, 2, 4, 0x9EDA), - (244, 46, 2, 2, 0xCF79), - (246, 46, 2, 2, 0xB738), - (248, 46, 2, 2, 0xCF79), - (254, 46, 2, 6, 0x9EDA), - (258, 46, 2, 4, 0x9EFA), - (262, 46, 2, 2, 0xD778), - (266, 46, 2, 2, 0xD798), - (270, 46, 2, 2, 0xD778), - (276, 46, 6, 2, 0x9EDA), - (282, 46, 6, 2, 0xA6FA), - (0, 48, 2, 4, 0xB738), - (2, 48, 2, 2, 0xCF78), - (4, 48, 2, 4, 0xD778), - (6, 48, 6, 2, 0xD779), - (12, 48, 2, 14, 0xA6FA), - (14, 48, 2, 4, 0xDF7A), - (16, 48, 4, 2, 0xE79A), - (20, 48, 2, 12, 0xE7DA), - (24, 48, 2, 12, 0xE799), - (26, 48, 2, 14, 0xDF79), - (30, 48, 2, 2, 0xA6FA), - (32, 48, 2, 2, 0xA6DA), - (34, 48, 2, 2, 0x9EDA), - (38, 48, 10, 2, 0x9EDA), - (56, 48, 2, 4, 0xBF38), - (60, 48, 2, 4, 0xBF38), - (64, 48, 2, 4, 0xBF38), - (70, 48, 2, 14, 0xB738), - (72, 48, 2, 2, 0xCF79), - (74, 48, 2, 4, 0xD778), - (76, 48, 6, 2, 0xD779), - (82, 48, 2, 16, 0xA6FA), - (84, 48, 2, 2, 0xDF9A), - (86, 48, 2, 2, 0xE79A), - (88, 48, 2, 12, 0xE7DA), - (92, 48, 2, 14, 0xE799), - (94, 48, 2, 16, 0xDF79), - (98, 48, 2, 2, 0xA6FA), - (100, 48, 2, 2, 0xA6DA), - (102, 48, 2, 2, 0x9EDA), - (106, 48, 10, 2, 0x9EDA), - (124, 48, 2, 4, 0xBF38), - (128, 48, 2, 4, 0xBF38), - (132, 48, 2, 4, 0xBF38), - (138, 48, 2, 18, 0xB738), - (140, 48, 2, 2, 0xCF79), - (142, 48, 2, 4, 0xD778), - (144, 48, 6, 2, 0xD779), - (150, 48, 2, 14, 0xA6FA), - (152, 48, 2, 4, 0xDF7A), - (154, 48, 4, 2, 0xE79A), - (158, 48, 2, 12, 0xE7DA), - (162, 48, 2, 12, 0xE799), - (164, 48, 2, 14, 0xDF79), - (168, 48, 2, 2, 0xA6FA), - (170, 48, 2, 2, 0xA6DA), - (172, 48, 2, 2, 0x9EDA), - (176, 48, 10, 2, 0x9EDA), - (194, 48, 2, 4, 0xBF38), - (198, 48, 2, 4, 0xBF38), - (202, 48, 2, 4, 0xBF38), - (208, 48, 2, 14, 0xB738), - (210, 48, 2, 2, 0xCF79), - (212, 48, 2, 4, 0xD778), - (214, 48, 6, 2, 0xD779), - (220, 48, 2, 16, 0xA6FA), - (222, 48, 2, 2, 0xDF9A), - (224, 48, 2, 2, 0xE79A), - (226, 48, 2, 12, 0xE7DA), - (230, 48, 2, 14, 0xE799), - (232, 48, 2, 16, 0xDF79), - (236, 48, 2, 2, 0xA6FA), - (238, 48, 2, 2, 0xA6DA), - (240, 48, 2, 2, 0x9EDA), - (244, 48, 10, 2, 0x9EDA), - (262, 48, 2, 4, 0xBF38), - (266, 48, 2, 4, 0xBF38), - (270, 48, 2, 4, 0xBF38), - (276, 48, 2, 16, 0xB738), - (278, 48, 2, 2, 0xCF79), - (280, 48, 2, 4, 0xD778), - (282, 48, 6, 2, 0xD779), - (2, 50, 2, 14, 0xD778), - (6, 50, 4, 2, 0xD778), - (10, 50, 2, 2, 0xD779), - (16, 50, 2, 6, 0xDF9A), - (18, 50, 2, 8, 0xE79A), - (30, 50, 2, 4, 0xA6DA), - (32, 50, 2, 2, 0xCF79), - (34, 50, 2, 2, 0xD779), - (36, 50, 6, 2, 0xD778), - (42, 50, 2, 2, 0xCF78), - (44, 50, 4, 2, 0xB738), - (50, 50, 2, 2, 0xDFBA), - (52, 50, 2, 12, 0x9EDA), - (54, 50, 2, 10, 0xD778), - (72, 50, 2, 10, 0xD778), - (76, 50, 4, 2, 0xD778), - (80, 50, 2, 2, 0xD779), - (84, 50, 2, 10, 0xDF7A), - (86, 50, 2, 10, 0xDF9A), - (98, 50, 2, 4, 0xA6DA), - (100, 50, 2, 2, 0xCF79), - (102, 50, 2, 2, 0xD779), - (104, 50, 6, 2, 0xD778), - (110, 50, 2, 2, 0xCF78), - (112, 50, 4, 2, 0xB738), - (118, 50, 2, 2, 0xDFBA), - (120, 50, 2, 12, 0x9EDA), - (122, 50, 2, 10, 0xD778), - (140, 50, 2, 16, 0xD778), - (144, 50, 4, 2, 0xD778), - (148, 50, 2, 2, 0xD779), - (154, 50, 2, 6, 0xDF9A), - (156, 50, 2, 8, 0xE79A), - (168, 50, 2, 4, 0xA6DA), - (170, 50, 2, 2, 0xCF79), - (172, 50, 2, 2, 0xD779), - (174, 50, 6, 2, 0xD778), - (180, 50, 2, 2, 0xCF78), - (182, 50, 4, 2, 0xB738), - (188, 50, 2, 2, 0xDFBA), - (190, 50, 2, 12, 0x9EDA), - (192, 50, 2, 10, 0xD778), - (210, 50, 2, 10, 0xD778), - (214, 50, 4, 2, 0xD778), - (218, 50, 2, 2, 0xD779), - (222, 50, 2, 10, 0xDF7A), - (224, 50, 2, 10, 0xDF9A), - (236, 50, 2, 4, 0xA6DA), - (238, 50, 2, 2, 0xCF79), - (240, 50, 2, 2, 0xD779), - (242, 50, 6, 2, 0xD778), - (248, 50, 2, 2, 0xCF78), - (250, 50, 4, 2, 0xB738), - (256, 50, 2, 2, 0xDFBA), - (258, 50, 2, 12, 0x9EDA), - (260, 50, 2, 10, 0xD778), - (278, 50, 2, 12, 0xD778), - (282, 50, 4, 2, 0xD778), - (286, 50, 2, 10, 0xD798), - (0, 52, 2, 8, 0xBF38), - (4, 52, 2, 4, 0xBF38), - (6, 52, 2, 10, 0xD798), - (8, 52, 2, 4, 0xBF38), - (10, 52, 2, 12, 0xD778), - (14, 52, 2, 10, 0xDF79), - (32, 52, 2, 4, 0xB738), - (34, 52, 2, 12, 0xD778), - (36, 52, 2, 4, 0xBF38), - (38, 52, 2, 12, 0xD778), - (40, 52, 2, 4, 0xBF38), - (42, 52, 2, 4, 0xD778), - (44, 52, 2, 4, 0xB738), - (46, 52, 2, 2, 0xAF38), - (48, 52, 2, 6, 0x96DA), - (50, 52, 2, 2, 0xD75A), - (56, 52, 2, 4, 0xD778), - (60, 52, 2, 4, 0xD798), - (64, 52, 2, 4, 0xD778), - (74, 52, 2, 4, 0xBF38), - (76, 52, 2, 8, 0xD798), - (78, 52, 2, 4, 0xBF38), - (80, 52, 2, 12, 0xD778), - (100, 52, 2, 4, 0xB738), - (102, 52, 2, 8, 0xD778), - (104, 52, 2, 4, 0xBF38), - (106, 52, 2, 10, 0xD778), - (108, 52, 2, 4, 0xBF38), - (110, 52, 2, 4, 0xD778), - (112, 52, 2, 4, 0xB738), - (114, 52, 2, 2, 0xAF38), - (116, 52, 2, 6, 0x96DA), - (118, 52, 2, 2, 0xD75A), - (124, 52, 2, 4, 0xD778), - (128, 52, 2, 4, 0xD798), - (132, 52, 2, 4, 0xD778), - (142, 52, 2, 4, 0xBF38), - (144, 52, 2, 14, 0xD798), - (146, 52, 2, 4, 0xBF38), - (148, 52, 2, 12, 0xD778), - (152, 52, 2, 10, 0xDF79), - (170, 52, 2, 4, 0xB738), - (172, 52, 2, 14, 0xD778), - (174, 52, 2, 4, 0xBF38), - (176, 52, 2, 14, 0xD778), - (178, 52, 2, 4, 0xBF38), - (180, 52, 2, 4, 0xD778), - (182, 52, 2, 4, 0xB738), - (184, 52, 2, 2, 0xAF38), - (186, 52, 2, 6, 0x96DA), - (188, 52, 2, 2, 0xD75A), - (194, 52, 2, 4, 0xD778), - (198, 52, 2, 4, 0xD798), - (202, 52, 2, 4, 0xD778), - (212, 52, 2, 4, 0xBF38), - (214, 52, 2, 8, 0xD798), - (216, 52, 2, 4, 0xBF38), - (218, 52, 2, 12, 0xD778), - (238, 52, 2, 4, 0xB738), - (240, 52, 2, 8, 0xD778), - (242, 52, 2, 4, 0xBF38), - (244, 52, 2, 10, 0xD778), - (246, 52, 2, 4, 0xBF38), - (248, 52, 2, 4, 0xD778), - (250, 52, 2, 4, 0xB738), - (252, 52, 2, 2, 0xAF38), - (254, 52, 2, 6, 0x96DA), - (256, 52, 2, 2, 0xD75A), - (262, 52, 2, 4, 0xD778), - (266, 52, 2, 4, 0xD798), - (270, 52, 2, 4, 0xD778), - (280, 52, 2, 4, 0xBF38), - (282, 52, 2, 8, 0xD798), - (284, 52, 2, 4, 0xBF38), - (30, 54, 2, 6, 0xA6FA), - (46, 54, 2, 2, 0xB738), - (50, 54, 2, 2, 0xAF38), - (98, 54, 2, 6, 0xA6FA), - (114, 54, 2, 2, 0xB738), - (118, 54, 2, 2, 0xAF38), - (168, 54, 2, 8, 0xA6FA), - (184, 54, 2, 2, 0xB738), - (188, 54, 2, 2, 0xAF38), - (236, 54, 2, 6, 0xA6FA), - (252, 54, 2, 2, 0xB738), - (256, 54, 2, 2, 0xAF38), - (4, 56, 2, 2, 0xD778), - (8, 56, 2, 2, 0xD778), - (16, 56, 2, 4, 0xDF7A), - (32, 56, 2, 2, 0xD778), - (36, 56, 2, 2, 0xD798), - (40, 56, 2, 2, 0xD778), - (42, 56, 6, 2, 0x9EDA), - (50, 56, 2, 2, 0x9EDA), - (56, 56, 2, 4, 0xBF38), - (60, 56, 2, 4, 0xBF38), - (64, 56, 2, 4, 0xBF38), - (74, 56, 2, 2, 0xD778), - (78, 56, 2, 2, 0xD778), - (100, 56, 2, 2, 0xD778), - (104, 56, 2, 2, 0xD798), - (108, 56, 2, 2, 0xD778), - (110, 56, 6, 2, 0x9EDA), - (118, 56, 2, 2, 0x9EDA), - (124, 56, 2, 4, 0xBF38), - (128, 56, 2, 4, 0xBF38), - (132, 56, 2, 4, 0xBF38), - (142, 56, 2, 2, 0xD778), - (146, 56, 2, 2, 0xD778), - (154, 56, 2, 4, 0xDF7A), - (170, 56, 2, 2, 0xD778), - (174, 56, 2, 2, 0xD798), - (178, 56, 2, 2, 0xD778), - (180, 56, 6, 2, 0x9EDA), - (188, 56, 2, 2, 0x9EDA), - (194, 56, 2, 4, 0xBF38), - (198, 56, 2, 4, 0xBF38), - (202, 56, 2, 4, 0xBF38), - (212, 56, 2, 2, 0xD778), - (216, 56, 2, 2, 0xD778), - (238, 56, 2, 2, 0xD778), - (242, 56, 2, 2, 0xD798), - (246, 56, 2, 2, 0xD778), - (248, 56, 6, 2, 0x9EDA), - (256, 56, 2, 2, 0x9EDA), - (262, 56, 2, 4, 0xBF38), - (266, 56, 2, 4, 0xBF38), - (270, 56, 2, 4, 0xBF38), - (280, 56, 2, 2, 0xD778), - (284, 56, 2, 2, 0xD798), - (4, 58, 2, 4, 0xBF38), - (8, 58, 2, 4, 0xBF38), - (18, 58, 2, 2, 0xE799), - (22, 58, 2, 2, 0xE799), - (32, 58, 2, 4, 0xB738), - (36, 58, 2, 4, 0xBF38), - (40, 58, 2, 4, 0xB738), - (42, 58, 2, 6, 0x9EDA), - (44, 58, 2, 2, 0xCF79), - (46, 58, 4, 2, 0xCF78), - (50, 58, 2, 2, 0xB738), - (74, 58, 2, 4, 0xBF38), - (78, 58, 2, 4, 0xBF38), - (90, 58, 2, 6, 0xE799), - (100, 58, 2, 4, 0xB738), - (104, 58, 2, 4, 0xBF38), - (108, 58, 2, 4, 0xB738), - (110, 58, 2, 6, 0x9EDA), - (112, 58, 2, 2, 0xCF79), - (114, 58, 4, 2, 0xCF78), - (118, 58, 2, 2, 0xB738), - (142, 58, 2, 4, 0xBF38), - (146, 58, 2, 4, 0xBF38), - (156, 58, 2, 2, 0xE799), - (160, 58, 2, 2, 0xE799), - (170, 58, 2, 4, 0xB738), - (174, 58, 2, 4, 0xBF38), - (178, 58, 2, 4, 0xB738), - (180, 58, 2, 6, 0x9EDA), - (182, 58, 2, 2, 0xCF79), - (184, 58, 4, 2, 0xCF78), - (188, 58, 2, 2, 0xB738), - (212, 58, 2, 4, 0xBF38), - (216, 58, 2, 4, 0xBF38), - (228, 58, 2, 6, 0xE799), - (238, 58, 2, 4, 0xB738), - (242, 58, 2, 4, 0xBF38), - (246, 58, 2, 4, 0xB738), - (248, 58, 2, 6, 0x9EDA), - (250, 58, 2, 2, 0xCF79), - (252, 58, 4, 2, 0xCF78), - (256, 58, 2, 2, 0xB738), - (280, 58, 2, 4, 0xBF38), - (284, 58, 2, 4, 0xBF38), - (0, 60, 2, 4, 0xB738), - (16, 60, 10, 2, 0xDF79), - (30, 60, 2, 2, 0xA6DA), - (44, 60, 2, 4, 0xCF78), - (46, 60, 2, 2, 0xB738), - (48, 60, 2, 2, 0xCF78), - (50, 60, 2, 2, 0xAF38), - (54, 60, 2, 2, 0xCF78), - (56, 60, 6, 2, 0xD778), - (64, 60, 2, 2, 0xD778), - (66, 60, 2, 4, 0xCF78), - (72, 60, 2, 2, 0xCF78), - (76, 60, 2, 4, 0xD778), - (84, 60, 2, 6, 0xDF79), - (86, 60, 2, 2, 0xDF7A), - (88, 60, 2, 4, 0xE799), - (98, 60, 2, 2, 0x9EDA), - (102, 60, 2, 2, 0xCF78), - (112, 60, 2, 4, 0xCF78), - (114, 60, 2, 2, 0xB738), - (116, 60, 2, 2, 0xCF78), - (118, 60, 2, 2, 0xAF38), - (122, 60, 2, 4, 0xCF78), - (124, 60, 2, 2, 0xD778), - (128, 60, 2, 2, 0xD798), - (132, 60, 2, 2, 0xD778), - (154, 60, 10, 2, 0xDF79), - (182, 60, 2, 4, 0xCF78), - (184, 60, 2, 2, 0xB738), - (186, 60, 2, 2, 0xCF78), - (188, 60, 2, 2, 0xAF38), - (192, 60, 2, 2, 0xCF78), - (194, 60, 2, 2, 0xD778), - (198, 60, 2, 2, 0xD798), - (202, 60, 2, 2, 0xD778), - (210, 60, 2, 2, 0xCF78), - (214, 60, 2, 4, 0xD778), - (222, 60, 2, 6, 0xDF79), - (224, 60, 2, 2, 0xDF7A), - (226, 60, 2, 4, 0xE799), - (236, 60, 2, 2, 0x9EDA), - (240, 60, 2, 2, 0xCF78), - (250, 60, 2, 4, 0xCF78), - (252, 60, 2, 2, 0xB738), - (254, 60, 2, 2, 0xCF78), - (256, 60, 2, 2, 0xAF38), - (260, 60, 2, 4, 0xCF78), - (262, 60, 2, 2, 0xD778), - (266, 60, 2, 2, 0xD798), - (270, 60, 2, 2, 0xD778), - (282, 60, 2, 2, 0xD778), - (286, 60, 2, 2, 0xD778), - (4, 62, 6, 2, 0xD778), - (12, 62, 2, 2, 0xA6DA), - (14, 62, 4, 2, 0xD779), - (18, 62, 8, 2, 0xD778), - (26, 62, 4, 2, 0xD779), - (30, 62, 2, 2, 0x9EDA), - (32, 62, 2, 2, 0xCF79), - (36, 62, 2, 2, 0xD778), - (40, 62, 2, 2, 0xCF79), - (46, 62, 2, 2, 0xB737), - (48, 62, 2, 2, 0xCF77), - (50, 62, 2, 2, 0xAF17), - (52, 62, 2, 2, 0x96D9), - (54, 62, 2, 2, 0xC758), - (56, 62, 2, 2, 0xB737), - (58, 62, 2, 2, 0xD778), - (60, 62, 2, 2, 0xBF38), - (62, 62, 2, 2, 0xD778), - (64, 62, 2, 2, 0xB738), - (68, 62, 2, 2, 0x96D9), - (70, 62, 2, 2, 0xAF17), - (72, 62, 2, 2, 0xC777), - (74, 62, 2, 2, 0xCF77), - (78, 62, 2, 2, 0xD778), - (86, 62, 2, 4, 0xDF79), - (92, 62, 2, 2, 0xE779), - (96, 62, 2, 2, 0xD779), - (98, 62, 2, 2, 0x9ED9), - (100, 62, 2, 2, 0xC757), - (102, 62, 4, 2, 0xCF77), - (106, 62, 4, 2, 0xCF78), - (114, 62, 2, 2, 0xAF37), - (116, 62, 2, 2, 0xC757), - (118, 62, 2, 2, 0xAF17), - (120, 62, 2, 2, 0x96D9), - (124, 62, 2, 2, 0xB738), - (126, 62, 2, 2, 0xD778), - (128, 62, 2, 4, 0xBF38), - (132, 62, 2, 2, 0xBF38), - (142, 62, 2, 2, 0xD778), - (146, 62, 2, 2, 0xD778), - (150, 62, 2, 2, 0xA6DA), - (152, 62, 4, 2, 0xD779), - (156, 62, 8, 2, 0xD778), - (164, 62, 4, 2, 0xD779), - (168, 62, 2, 4, 0x9EDA), - (170, 62, 2, 2, 0xD778), - (174, 62, 2, 2, 0xD798), - (178, 62, 2, 2, 0xCF78), - (184, 62, 2, 2, 0xB737), - (186, 62, 2, 2, 0xCF77), - (188, 62, 2, 2, 0xAF17), - (190, 62, 2, 2, 0x96D9), - (192, 62, 2, 2, 0xC757), - (194, 62, 2, 2, 0xB737), - (196, 62, 2, 2, 0xD778), - (198, 62, 2, 2, 0xBF38), - (200, 62, 2, 2, 0xD778), - (202, 62, 2, 2, 0xB738), - (204, 62, 2, 2, 0xCF78), - (206, 62, 2, 2, 0x96D9), - (208, 62, 2, 2, 0xAF17), - (210, 62, 2, 2, 0xC777), - (212, 62, 2, 2, 0xCF77), - (216, 62, 2, 2, 0xD778), - (224, 62, 2, 4, 0xDF79), - (230, 62, 2, 2, 0xE779), - (234, 62, 2, 2, 0xD779), - (236, 62, 2, 2, 0x9ED9), - (238, 62, 2, 2, 0xC757), - (240, 62, 4, 2, 0xCF77), - (244, 62, 4, 2, 0xCF78), - (252, 62, 2, 2, 0xAF37), - (254, 62, 2, 2, 0xC757), - (256, 62, 2, 2, 0xAF17), - (258, 62, 2, 2, 0x96D9), - (262, 62, 2, 2, 0xB738), - (264, 62, 2, 2, 0xD778), - (266, 62, 2, 4, 0xBF38), - (270, 62, 2, 4, 0xBF38), - (278, 62, 4, 2, 0xCF78), - (282, 62, 6, 2, 0xCF77), - (0, 64, 2, 2, 0x9EDA), - (2, 64, 2, 2, 0xCF79), - (4, 64, 2, 2, 0xA6FA), - (6, 64, 2, 2, 0xD778), - (8, 64, 2, 4, 0x9EDA), - (10, 64, 2, 2, 0xCF78), - (12, 64, 2, 2, 0x9EDA), - (14, 64, 4, 2, 0xCF58), - (18, 64, 2, 2, 0x7670), - (20, 64, 4, 2, 0x6E6F), - (24, 64, 2, 2, 0x7670), - (26, 64, 4, 2, 0xCF58), - (30, 64, 2, 2, 0x96DA), - (32, 64, 2, 2, 0x9EDA), - (34, 64, 2, 2, 0xCF78), - (36, 64, 2, 2, 0x9EDA), - (38, 64, 2, 2, 0xCF78), - (40, 64, 4, 2, 0x96DA), - (44, 64, 4, 2, 0xC757), - (48, 64, 2, 2, 0x6E6F), - (50, 64, 2, 2, 0x666F), - (52, 64, 2, 2, 0x5E6F), - (54, 64, 2, 2, 0x6670), - (56, 64, 2, 2, 0x8ED8), - (58, 64, 2, 2, 0xC777), - (60, 64, 2, 2, 0x9ED9), - (62, 64, 2, 2, 0xCF78), - (64, 64, 2, 2, 0x96D9), - (66, 64, 2, 2, 0xC757), - (68, 64, 2, 2, 0x6670), - (70, 64, 4, 2, 0x666F), - (74, 64, 2, 2, 0x6E6F), - (76, 64, 2, 2, 0xC777), - (78, 64, 2, 2, 0xAF37), - (80, 64, 2, 2, 0xCF78), - (82, 64, 2, 2, 0x9EDA), - (88, 64, 6, 2, 0xDF79), - (94, 64, 2, 2, 0xD778), - (96, 64, 2, 2, 0xCF58), - (98, 64, 2, 2, 0x6E70), - (100, 64, 4, 2, 0x666F), - (104, 64, 2, 2, 0x6E6F), - (106, 64, 2, 2, 0xC757), - (108, 64, 2, 2, 0xAF17), - (110, 64, 2, 2, 0x8ED9), - (112, 64, 2, 2, 0xBF57), - (114, 64, 6, 2, 0x666F), - (120, 64, 2, 2, 0x6670), - (122, 64, 2, 2, 0xC757), - (124, 64, 2, 2, 0xAF37), - (126, 64, 2, 2, 0xCF78), - (130, 64, 2, 2, 0xD778), - (132, 64, 2, 2, 0xB738), - (134, 64, 2, 2, 0xCF78), - (142, 64, 2, 4, 0xBF38), - (146, 64, 2, 2, 0xBF38), - (148, 64, 2, 2, 0xCF78), - (150, 64, 2, 2, 0x9EDA), - (152, 64, 4, 2, 0xCF58), - (156, 64, 2, 2, 0x7670), - (158, 64, 4, 2, 0x6E6F), - (162, 64, 2, 2, 0x7670), - (164, 64, 4, 2, 0xCF58), - (170, 64, 2, 2, 0xB738), - (174, 64, 2, 2, 0xBF38), - (178, 64, 2, 2, 0xB738), - (180, 64, 2, 2, 0x96D9), - (182, 64, 4, 2, 0xC757), - (186, 64, 2, 2, 0x6E6F), - (188, 64, 6, 2, 0x666F), - (194, 64, 2, 2, 0xAF16), - (196, 64, 2, 2, 0xCF77), - (198, 64, 2, 2, 0xB737), - (200, 64, 2, 2, 0xCF77), - (202, 64, 2, 2, 0xAF37), - (204, 64, 2, 2, 0xC757), - (206, 64, 2, 2, 0x6670), - (208, 64, 4, 2, 0x666F), - (212, 64, 2, 2, 0x6E6F), - (214, 64, 2, 2, 0xC777), - (216, 64, 2, 2, 0xAF37), - (218, 64, 2, 2, 0xCF78), - (220, 64, 2, 2, 0x9EDA), - (226, 64, 6, 2, 0xDF79), - (232, 64, 2, 2, 0xD778), - (234, 64, 2, 2, 0xCF58), - (236, 64, 2, 2, 0x6E70), - (238, 64, 4, 2, 0x666F), - (242, 64, 2, 2, 0x6E6F), - (244, 64, 2, 2, 0xC757), - (246, 64, 2, 2, 0x8ED9), - (248, 64, 2, 2, 0x8EB9), - (250, 64, 2, 2, 0xBF57), - (252, 64, 6, 2, 0x666F), - (258, 64, 2, 2, 0x6670), - (260, 64, 2, 2, 0xC757), - (262, 64, 2, 2, 0xAF37), - (264, 64, 2, 2, 0xCF78), - (268, 64, 2, 2, 0xD778), - (272, 64, 2, 2, 0xCF78), - (276, 64, 2, 2, 0xAF17), - (278, 64, 4, 2, 0xC757), - (282, 64, 2, 2, 0x6E6F), - (284, 64, 4, 2, 0x666F), - (0, 66, 2, 2, 0x96DA), - (2, 66, 2, 2, 0xCF78), - (4, 66, 2, 2, 0x9EDA), - (6, 66, 2, 2, 0xCF78), - (10, 66, 2, 2, 0xC758), - (12, 66, 2, 2, 0x8ED9), - (14, 66, 2, 2, 0x6670), - (16, 66, 2, 2, 0x666F), - (18, 66, 2, 2, 0x6F0F), - (20, 66, 4, 2, 0x670E), - (24, 66, 2, 2, 0x6F0F), - (26, 66, 2, 2, 0x666F), - (28, 66, 2, 2, 0x6650), - (30, 66, 4, 2, 0x8EB9), - (34, 66, 2, 2, 0xC758), - (36, 66, 2, 2, 0x96D9), - (38, 66, 2, 2, 0xC758), - (40, 66, 4, 2, 0x8EB9), - (44, 66, 2, 2, 0x6650), - (46, 66, 2, 2, 0x5E4F), - (48, 66, 6, 2, 0x66EE), - (54, 66, 2, 2, 0x66EF), - (56, 66, 2, 2, 0x5E6F), - (58, 66, 2, 2, 0x666F), - (60, 66, 4, 2, 0xC757), - (64, 66, 2, 2, 0x666F), - (66, 66, 2, 2, 0x5E6F), - (68, 66, 2, 2, 0x66EF), - (70, 66, 6, 2, 0x66EE), - (76, 66, 4, 2, 0x666F), - (80, 66, 2, 2, 0xC757), - (82, 66, 2, 2, 0x96D9), - (84, 66, 2, 2, 0xD759), - (86, 66, 2, 2, 0xD779), - (88, 66, 4, 2, 0xD778), - (92, 66, 2, 2, 0xCF58), - (94, 66, 2, 2, 0x6E70), - (96, 66, 2, 2, 0x666F), - (98, 66, 2, 2, 0x66EF), - (100, 66, 2, 2, 0x66EE), - (102, 66, 2, 2, 0x670E), - (104, 66, 2, 2, 0x6F0E), - (106, 66, 2, 2, 0x5E6F), - (108, 66, 6, 2, 0x5E4F), - (114, 66, 6, 2, 0x66EE), - (120, 66, 2, 2, 0x66EF), - (122, 66, 4, 2, 0x666F), - (126, 66, 2, 2, 0xC757), - (128, 66, 2, 2, 0xCF77), - (130, 66, 4, 2, 0xCF78), - (134, 66, 2, 2, 0xC758), - (136, 66, 2, 2, 0x96D9), - (138, 66, 2, 2, 0xAF37), - (140, 66, 2, 2, 0xCF78), - (144, 66, 2, 2, 0xD778), - (146, 66, 2, 2, 0xB737), - (148, 66, 2, 2, 0xCF77), - (150, 66, 2, 2, 0x8ED9), - (152, 66, 2, 2, 0x6670), - (154, 66, 2, 2, 0x666F), - (156, 66, 2, 2, 0x6F0F), - (158, 66, 4, 2, 0x670E), - (162, 66, 2, 2, 0x6F0F), - (164, 66, 2, 2, 0x666F), - (166, 66, 2, 2, 0x6670), - (168, 66, 2, 2, 0x8ED9), - (170, 66, 2, 2, 0xAF17), - (172, 66, 2, 2, 0xCF78), - (174, 66, 2, 2, 0xB737), - (176, 66, 2, 2, 0xCF77), - (178, 66, 2, 2, 0xAF17), - (180, 66, 2, 2, 0x8EB8), - (182, 66, 2, 2, 0x664F), - (184, 66, 2, 2, 0x5E4F), - (186, 66, 8, 2, 0x66EE), - (194, 66, 2, 2, 0x5E6F), - (196, 66, 2, 2, 0x6E6F), - (198, 66, 4, 2, 0xC756), - (202, 66, 2, 2, 0x6E6F), - (204, 66, 2, 2, 0x666F), - (206, 66, 2, 2, 0x66EF), - (208, 66, 6, 2, 0x66EE), - (214, 66, 4, 2, 0x666F), - (218, 66, 2, 2, 0xC757), - (220, 66, 2, 2, 0x96D9), - (222, 66, 2, 2, 0xD759), - (224, 66, 2, 2, 0xD779), - (226, 66, 4, 2, 0xD778), - (230, 66, 2, 2, 0xCF58), - (232, 66, 2, 2, 0x6E70), - (234, 66, 2, 2, 0x666F), - (236, 66, 2, 2, 0x66EF), - (238, 66, 2, 2, 0x66EE), - (240, 66, 2, 2, 0x670E), - (242, 66, 2, 2, 0x670F), - (244, 66, 2, 2, 0x5E6F), - (246, 66, 6, 2, 0x5E4F), - (252, 66, 6, 2, 0x66EE), - (258, 66, 2, 2, 0x66EF), - (260, 66, 4, 2, 0x666F), - (264, 66, 2, 2, 0xC757), - (266, 66, 4, 2, 0xCF77), - (270, 66, 2, 2, 0xCF78), - (272, 66, 2, 2, 0xC757), - (274, 66, 2, 2, 0x8ED9), - (276, 66, 2, 2, 0xA716), - (278, 66, 4, 2, 0x666F), - (282, 66, 4, 2, 0x66EE), - (286, 66, 2, 2, 0x670E), - (0, 68, 2, 2, 0x8EB9), - (2, 68, 4, 2, 0xC757), - (6, 68, 2, 2, 0xCF77), - (8, 68, 2, 2, 0xC757), - (10, 68, 2, 2, 0x6670), - (12, 68, 2, 2, 0x5E6F), - (14, 68, 2, 2, 0x66EF), - (16, 68, 2, 2, 0x670E), - (18, 68, 8, 2, 0x5F0E), - (26, 68, 2, 2, 0x66EE), - (28, 68, 2, 2, 0x66EF), - (30, 68, 2, 2, 0x5E4F), - (32, 68, 2, 2, 0x5E50), - (34, 68, 4, 2, 0xBF57), - (38, 68, 2, 2, 0x6670), - (40, 68, 2, 2, 0x5E4F), - (42, 68, 2, 2, 0x564F), - (44, 68, 2, 2, 0x564E), - (46, 68, 8, 2, 0x5EEE), - (54, 68, 2, 2, 0x5F0E), - (56, 68, 4, 2, 0x66EE), - (60, 68, 4, 2, 0x5E6E), - (64, 68, 4, 2, 0x66EE), - (68, 68, 4, 2, 0x5EEE), - (72, 68, 2, 2, 0x5EED), - (74, 68, 2, 2, 0x5EEE), - (76, 68, 4, 2, 0x66EE), - (80, 68, 2, 2, 0x5E4F), - (82, 68, 2, 2, 0x6650), - (84, 68, 2, 2, 0x8ED8), - (86, 68, 2, 2, 0xCF58), - (88, 68, 2, 2, 0x6E70), - (90, 68, 2, 2, 0x6E6F), - (92, 68, 2, 2, 0x666F), - (94, 68, 2, 2, 0x5E4E), - (96, 68, 2, 2, 0x66EE), - (98, 68, 6, 2, 0x5EEE), - (104, 68, 2, 2, 0x5F0E), - (106, 68, 4, 2, 0x5EEE), - (110, 68, 2, 2, 0x564E), - (112, 68, 2, 2, 0x564D), - (114, 68, 4, 2, 0x5EEE), - (118, 68, 2, 2, 0x5F0E), - (120, 68, 2, 2, 0x5EEE), - (122, 68, 4, 2, 0x66EE), - (126, 68, 2, 2, 0x664F), - (128, 68, 2, 2, 0x666F), - (130, 68, 2, 2, 0xC757), - (132, 68, 2, 2, 0x8ED8), - (134, 68, 4, 2, 0x6670), - (138, 68, 2, 2, 0xA716), - (140, 68, 2, 2, 0xC777), - (142, 68, 4, 2, 0xCF77), - (146, 68, 2, 2, 0xC757), - (148, 68, 2, 2, 0x6E6F), - (150, 68, 2, 2, 0x5E6F), - (152, 68, 2, 2, 0x66EF), - (154, 68, 2, 2, 0x670E), - (156, 68, 8, 2, 0x5F0E), - (164, 68, 2, 2, 0x670E), - (166, 68, 2, 2, 0x66EF), - (168, 68, 2, 2, 0x5E4F), - (170, 68, 2, 2, 0x666F), - (172, 68, 2, 2, 0xC757), - (174, 68, 2, 2, 0xC756), - (176, 68, 2, 2, 0x6E6F), - (178, 68, 2, 2, 0x5E6F), - (180, 68, 2, 2, 0x5E4F), - (182, 68, 2, 2, 0x564E), - (184, 68, 8, 2, 0x5EEE), - (192, 68, 2, 2, 0x5F0E), - (194, 68, 4, 2, 0x670E), - (198, 68, 4, 2, 0x5E6E), - (202, 68, 4, 2, 0x66EE), - (206, 68, 4, 2, 0x5EEE), - (210, 68, 2, 2, 0x5EED), - (212, 68, 2, 2, 0x5EEE), - (214, 68, 4, 2, 0x66EE), - (218, 68, 2, 2, 0x5E4F), - (220, 68, 2, 2, 0x6650), - (222, 68, 2, 2, 0x8ED8), - (224, 68, 2, 2, 0xCF58), - (226, 68, 2, 2, 0x6E70), - (228, 68, 2, 2, 0x6E6F), - (230, 68, 2, 2, 0x666F), - (232, 68, 2, 2, 0x5E4E), - (234, 68, 2, 2, 0x66EE), - (236, 68, 6, 2, 0x5EEE), - (242, 68, 2, 2, 0x5F0E), - (244, 68, 4, 2, 0x5EEE), - (248, 68, 2, 2, 0x564E), - (250, 68, 2, 2, 0x564D), - (252, 68, 4, 2, 0x5EEE), - (256, 68, 2, 2, 0x5F0E), - (258, 68, 2, 2, 0x5EEE), - (260, 68, 4, 2, 0x66EE), - (264, 68, 4, 2, 0x664F), - (268, 68, 2, 2, 0xC756), - (270, 68, 2, 2, 0xA716), - (272, 68, 2, 2, 0x666F), - (274, 68, 4, 2, 0x5E4F), - (278, 68, 2, 2, 0x564E), - (280, 68, 6, 2, 0x5EEE), - (286, 68, 2, 4, 0x5EED), - (0, 70, 2, 2, 0x5E4F), - (2, 70, 4, 2, 0x666F), - (6, 70, 2, 2, 0xBF56), - (8, 70, 2, 2, 0x666F), - (10, 70, 2, 2, 0x66EF), - (12, 70, 2, 2, 0x5EEE), - (14, 70, 4, 2, 0x5F0E), - (18, 70, 8, 2, 0x5F0D), - (26, 70, 4, 2, 0x5EEE), - (30, 70, 4, 2, 0x564E), - (34, 70, 2, 2, 0x5E4E), - (36, 70, 2, 2, 0x5E6E), - (38, 70, 2, 2, 0x66EF), - (40, 70, 2, 2, 0x66EE), - (42, 70, 4, 2, 0x5EEE), - (46, 70, 4, 2, 0x564D), - (50, 70, 2, 2, 0x5EED), - (52, 70, 4, 2, 0x5F0D), - (56, 70, 4, 2, 0x5F0E), - (60, 70, 4, 2, 0x5EEE), - (64, 70, 2, 6, 0x564D), - (66, 70, 6, 2, 0x5EED), - (72, 70, 8, 2, 0x564D), - (80, 70, 2, 2, 0x5EEE), - (82, 70, 2, 2, 0x66EF), - (84, 70, 2, 2, 0x5E4F), - (86, 70, 2, 2, 0x5E6F), - (88, 70, 2, 2, 0x6F0F), - (90, 70, 2, 2, 0x670E), - (92, 70, 2, 2, 0x66EE), - (94, 70, 2, 2, 0x5EEE), - (96, 70, 4, 2, 0x564D), - (100, 70, 2, 2, 0x5EED), - (102, 70, 8, 2, 0x5F0D), - (110, 70, 4, 6, 0x5EED), - (114, 70, 2, 6, 0x564D), - (116, 70, 8, 2, 0x5EED), - (124, 70, 4, 2, 0x564D), - (128, 70, 2, 2, 0x564E), - (130, 70, 2, 2, 0x5E4E), - (132, 70, 2, 2, 0x5E6E), - (134, 70, 4, 2, 0x66EF), - (138, 70, 2, 2, 0x5E6F), - (140, 70, 2, 2, 0x666F), - (142, 70, 2, 2, 0x6E6F), - (144, 70, 2, 2, 0xBF56), - (146, 70, 2, 2, 0x666F), - (148, 70, 2, 2, 0x66EF), - (150, 70, 2, 2, 0x66EE), - (152, 70, 4, 2, 0x5F0E), - (156, 70, 8, 2, 0x5F0D), - (164, 70, 2, 2, 0x5F0E), - (166, 70, 4, 2, 0x5EEE), - (170, 70, 2, 2, 0x66EE), - (172, 70, 4, 2, 0x5E6E), - (176, 70, 2, 2, 0x670E), - (178, 70, 2, 2, 0x66EE), - (180, 70, 4, 2, 0x5EEE), - (184, 70, 4, 2, 0x564D), - (188, 70, 2, 2, 0x5EED), - (190, 70, 4, 2, 0x5F0D), - (194, 70, 4, 2, 0x5F0E), - (198, 70, 4, 2, 0x5EEE), - (202, 70, 2, 6, 0x564D), - (204, 70, 6, 2, 0x5EED), - (210, 70, 8, 2, 0x564D), - (218, 70, 2, 2, 0x5EEE), - (220, 70, 2, 2, 0x66EF), - (222, 70, 2, 2, 0x5E4F), - (224, 70, 2, 2, 0x5E6F), - (226, 70, 2, 2, 0x6F0F), - (228, 70, 2, 2, 0x670E), - (230, 70, 2, 2, 0x66EE), - (232, 70, 2, 2, 0x5EEE), - (234, 70, 4, 2, 0x564D), - (238, 70, 2, 2, 0x5EED), - (240, 70, 8, 2, 0x5F0D), - (248, 70, 4, 6, 0x5EED), - (252, 70, 2, 6, 0x564D), - (254, 70, 8, 2, 0x5EED), - (262, 70, 4, 2, 0x564D), - (266, 70, 2, 2, 0x564E), - (268, 70, 2, 2, 0x5E4E), - (270, 70, 2, 2, 0x5E6E), - (272, 70, 2, 2, 0x66EF), - (274, 70, 2, 2, 0x66EE), - (276, 70, 4, 2, 0x5EEE), - (280, 70, 4, 2, 0x564D), - (284, 70, 2, 2, 0x5EED), - (0, 72, 6, 2, 0x66EE), - (6, 72, 2, 2, 0x5E6E), - (8, 72, 2, 2, 0x564E), - (10, 72, 2, 2, 0x5EEE), - (12, 72, 2, 2, 0x5EED), - (14, 72, 6, 2, 0x5F0D), - (20, 72, 10, 2, 0x5EED), - (30, 72, 4, 2, 0x564D), - (34, 72, 2, 2, 0x5EEE), - (36, 72, 2, 2, 0x66EE), - (38, 72, 4, 136, 0x5F0E), - (42, 72, 6, 2, 0x5F0D), - (48, 72, 2, 2, 0x5EED), - (50, 72, 4, 2, 0x566D), - (54, 72, 2, 2, 0x5EED), - (56, 72, 4, 2, 0x5F0D), - (60, 72, 4, 2, 0x5EED), - (66, 72, 2, 2, 0x5EED), - (68, 72, 4, 2, 0x564D), - (72, 72, 8, 2, 0x5EED), - (80, 72, 4, 2, 0x564D), - (84, 72, 4, 2, 0x5EEE), - (88, 72, 4, 136, 0x5F0E), - (92, 72, 6, 2, 0x5F0D), - (98, 72, 2, 2, 0x5EED), - (100, 72, 4, 2, 0x566D), - (104, 72, 2, 2, 0x5EED), - (106, 72, 4, 2, 0x5F0D), - (116, 72, 4, 2, 0x5EED), - (120, 72, 4, 2, 0x564D), - (124, 72, 4, 4, 0x5EED), - (128, 72, 6, 2, 0x5EEE), - (134, 72, 4, 136, 0x5F0E), - (138, 72, 4, 2, 0x670E), - (142, 72, 2, 2, 0x66EE), - (144, 72, 2, 2, 0x5E6E), - (146, 72, 2, 2, 0x564E), - (148, 72, 2, 2, 0x5EEE), - (150, 72, 2, 2, 0x5EED), - (152, 72, 6, 2, 0x5F0D), - (158, 72, 10, 2, 0x5EED), - (168, 72, 4, 2, 0x564D), - (172, 72, 2, 2, 0x5EEE), - (174, 72, 2, 2, 0x670E), - (176, 72, 4, 136, 0x5F0E), - (180, 72, 6, 2, 0x5F0D), - (186, 72, 2, 2, 0x5EED), - (188, 72, 4, 2, 0x566D), - (192, 72, 2, 2, 0x5EED), - (194, 72, 4, 2, 0x5F0D), - (198, 72, 4, 2, 0x5EED), - (204, 72, 2, 2, 0x5EED), - (206, 72, 4, 2, 0x564D), - (210, 72, 8, 2, 0x5EED), - (218, 72, 4, 2, 0x564D), - (222, 72, 4, 2, 0x5EEE), - (226, 72, 4, 136, 0x5F0E), - (230, 72, 6, 2, 0x5F0D), - (236, 72, 2, 2, 0x5EED), - (238, 72, 4, 2, 0x566D), - (242, 72, 2, 2, 0x5EED), - (244, 72, 4, 2, 0x5F0D), - (254, 72, 4, 2, 0x5EED), - (258, 72, 4, 2, 0x564D), - (262, 72, 2, 2, 0x5EED), - (264, 72, 4, 2, 0x564D), - (268, 72, 4, 2, 0x5EEE), - (272, 72, 4, 136, 0x5F0E), - (276, 72, 6, 2, 0x5F0D), - (282, 72, 2, 2, 0x5EED), - (284, 72, 2, 2, 0x566D), - (286, 72, 2, 2, 0x564D), - (0, 74, 6, 134, 0x5F0E), - (6, 74, 4, 2, 0x5EEE), - (10, 74, 4, 2, 0x564D), - (14, 74, 4, 2, 0x5EED), - (18, 74, 2, 2, 0x566D), - (20, 74, 6, 2, 0x564D), - (26, 74, 2, 2, 0x5EED), - (28, 74, 2, 4, 0x564D), - (30, 74, 6, 2, 0x5EED), - (36, 74, 2, 10, 0x5F0D), - (42, 74, 4, 134, 0x5F0E), - (46, 74, 4, 2, 0x5F0D), - (50, 74, 4, 2, 0x5EED), - (54, 74, 2, 6, 0x564D), - (56, 74, 6, 2, 0x5EED), - (62, 74, 2, 2, 0x564D), - (66, 74, 4, 2, 0x564D), - (70, 74, 8, 2, 0x5EED), - (78, 74, 2, 4, 0x564D), - (80, 74, 4, 2, 0x5EED), - (84, 74, 4, 2, 0x5F0D), - (92, 74, 4, 134, 0x5F0E), - (96, 74, 4, 2, 0x5F0D), - (100, 74, 4, 2, 0x5EED), - (104, 74, 2, 2, 0x566D), - (106, 74, 2, 4, 0x5EED), - (108, 74, 2, 2, 0x5F0D), - (116, 74, 6, 2, 0x564D), - (122, 74, 2, 2, 0x5EED), - (128, 74, 6, 2, 0x5F0D), - (138, 74, 6, 134, 0x5F0E), - (144, 74, 4, 2, 0x5EEE), - (148, 74, 4, 2, 0x564D), - (152, 74, 4, 2, 0x5EED), - (156, 74, 2, 2, 0x566D), - (158, 74, 6, 2, 0x564D), - (164, 74, 2, 2, 0x5EED), - (166, 74, 2, 4, 0x564D), - (168, 74, 4, 4, 0x5EED), - (172, 74, 4, 6, 0x5F0D), - (180, 74, 4, 134, 0x5F0E), - (184, 74, 4, 2, 0x5F0D), - (188, 74, 4, 2, 0x5EED), - (192, 74, 2, 6, 0x564D), - (194, 74, 6, 2, 0x5EED), - (200, 74, 2, 2, 0x564D), - (204, 74, 4, 2, 0x564D), - (208, 74, 8, 2, 0x5EED), - (216, 74, 2, 4, 0x564D), - (218, 74, 4, 2, 0x5EED), - (222, 74, 4, 2, 0x5F0D), - (230, 74, 4, 134, 0x5F0E), - (234, 74, 4, 2, 0x5F0D), - (238, 74, 4, 2, 0x5EED), - (242, 74, 2, 2, 0x566D), - (244, 74, 2, 4, 0x5EED), - (246, 74, 2, 2, 0x5F0D), - (254, 74, 6, 2, 0x564D), - (260, 74, 2, 2, 0x5EED), - (262, 74, 2, 4, 0x564D), - (264, 74, 6, 2, 0x5EED), - (270, 74, 2, 10, 0x5F0D), - (276, 74, 4, 134, 0x5F0E), - (280, 74, 6, 2, 0x5F0D), - (286, 74, 2, 2, 0x5EED), - (6, 76, 2, 8, 0x5F0D), - (8, 76, 6, 2, 0x5EED), - (14, 76, 2, 2, 0x564D), - (16, 76, 2, 2, 0x566D), - (18, 76, 8, 2, 0x5EED), - (26, 76, 2, 2, 0x564D), - (30, 76, 4, 2, 0x5EED), - (34, 76, 2, 4, 0x5F0D), - (46, 76, 4, 132, 0x5F0E), - (50, 76, 2, 8, 0x5F0D), - (52, 76, 2, 4, 0x5EED), - (56, 76, 2, 2, 0x5EED), - (58, 76, 2, 2, 0x564D), - (60, 76, 2, 2, 0x566D), - (62, 76, 8, 2, 0x5EED), - (70, 76, 4, 2, 0x564D), - (74, 76, 4, 2, 0x5EED), - (80, 76, 2, 2, 0x5EED), - (82, 76, 2, 2, 0x5F0D), - (84, 76, 4, 132, 0x5F0E), - (96, 76, 4, 132, 0x5F0E), - (100, 76, 2, 2, 0x5F0D), - (102, 76, 2, 2, 0x5EED), - (104, 76, 2, 2, 0x564D), - (108, 76, 2, 2, 0x5EED), - (110, 76, 4, 2, 0x566D), - (114, 76, 8, 2, 0x5EED), - (122, 76, 4, 2, 0x564D), - (126, 76, 2, 2, 0x5EED), - (128, 76, 4, 2, 0x5F0D), - (132, 76, 2, 2, 0x5F0E), - (144, 76, 2, 8, 0x5F0D), - (146, 76, 6, 2, 0x5EED), - (152, 76, 2, 2, 0x564D), - (154, 76, 2, 2, 0x566D), - (156, 76, 8, 2, 0x5EED), - (164, 76, 2, 2, 0x564D), - (184, 76, 4, 132, 0x5F0E), - (188, 76, 2, 8, 0x5F0D), - (190, 76, 2, 4, 0x5EED), - (194, 76, 2, 2, 0x5EED), - (196, 76, 2, 2, 0x564D), - (198, 76, 2, 2, 0x566D), - (200, 76, 8, 2, 0x5EED), - (208, 76, 4, 2, 0x564D), - (212, 76, 4, 2, 0x5EED), - (218, 76, 2, 2, 0x5EED), - (220, 76, 2, 2, 0x5F0D), - (222, 76, 4, 132, 0x5F0E), - (234, 76, 4, 132, 0x5F0E), - (238, 76, 2, 2, 0x5F0D), - (240, 76, 2, 2, 0x5EED), - (242, 76, 2, 2, 0x564D), - (246, 76, 2, 2, 0x5EED), - (248, 76, 4, 2, 0x566D), - (252, 76, 8, 2, 0x5EED), - (260, 76, 2, 2, 0x564D), - (264, 76, 4, 2, 0x5EED), - (268, 76, 2, 4, 0x5F0D), - (280, 76, 4, 132, 0x5F0E), - (284, 76, 4, 4, 0x5F0D), - (8, 78, 2, 2, 0x5EED), - (10, 78, 4, 2, 0x564D), - (14, 78, 4, 2, 0x5EED), - (18, 78, 8, 2, 0x5F0D), - (26, 78, 4, 2, 0x5EED), - (30, 78, 4, 2, 0x566D), - (56, 78, 2, 2, 0x564D), - (58, 78, 2, 2, 0x5EED), - (60, 78, 12, 2, 0x5F0D), - (72, 78, 2, 2, 0x5EED), - (74, 78, 4, 2, 0x564D), - (78, 78, 2, 2, 0x5EED), - (80, 78, 2, 4, 0x5F0D), - (82, 78, 2, 130, 0x5F0E), - (100, 78, 2, 130, 0x5F0E), - (102, 78, 2, 4, 0x5F0D), - (104, 78, 2, 2, 0x5EED), - (106, 78, 4, 2, 0x564D), - (110, 78, 2, 2, 0x5EED), - (112, 78, 12, 2, 0x5F0D), - (124, 78, 2, 2, 0x5EED), - (126, 78, 4, 2, 0x566D), - (130, 78, 4, 2, 0x5F0D), - (146, 78, 2, 2, 0x5EED), - (148, 78, 4, 2, 0x564D), - (152, 78, 4, 2, 0x5EED), - (156, 78, 8, 2, 0x5F0D), - (164, 78, 4, 2, 0x5EED), - (168, 78, 4, 2, 0x566D), - (194, 78, 2, 2, 0x564D), - (196, 78, 2, 2, 0x5EED), - (198, 78, 12, 2, 0x5F0D), - (210, 78, 2, 2, 0x5EED), - (212, 78, 4, 2, 0x564D), - (216, 78, 2, 2, 0x5EED), - (218, 78, 2, 4, 0x5F0D), - (220, 78, 2, 130, 0x5F0E), - (238, 78, 2, 130, 0x5F0E), - (240, 78, 2, 4, 0x5F0D), - (242, 78, 2, 2, 0x5EED), - (244, 78, 4, 2, 0x564D), - (248, 78, 2, 2, 0x5EED), - (250, 78, 10, 2, 0x5F0D), - (260, 78, 4, 2, 0x5EED), - (264, 78, 4, 2, 0x566D), - (8, 80, 2, 2, 0x566D), - (10, 80, 2, 2, 0x5EED), - (12, 80, 6, 2, 0x5F0D), - (18, 80, 8, 128, 0x5F0E), - (26, 80, 6, 2, 0x5F0D), - (32, 80, 2, 2, 0x5EED), - (34, 80, 2, 2, 0x566D), - (52, 80, 2, 2, 0x566D), - (54, 80, 4, 2, 0x5EED), - (58, 80, 4, 2, 0x5F0D), - (62, 80, 8, 128, 0x5F0E), - (70, 80, 4, 2, 0x5F0D), - (74, 80, 2, 2, 0x5EED), - (76, 80, 2, 2, 0x566D), - (78, 80, 2, 4, 0x5F0D), - (104, 80, 2, 4, 0x5F0D), - (106, 80, 2, 2, 0x566D), - (108, 80, 2, 2, 0x5EED), - (110, 80, 4, 2, 0x5F0D), - (114, 80, 8, 128, 0x5F0E), - (122, 80, 6, 2, 0x5F0D), - (128, 80, 2, 2, 0x5EED), - (130, 80, 2, 2, 0x566D), - (132, 80, 2, 4, 0x5F0D), - (146, 80, 2, 2, 0x566D), - (148, 80, 2, 2, 0x5EED), - (150, 80, 6, 2, 0x5F0D), - (156, 80, 8, 128, 0x5F0E), - (164, 80, 6, 2, 0x5F0D), - (170, 80, 2, 2, 0x5EED), - (172, 80, 2, 2, 0x566D), - (174, 80, 2, 4, 0x5F0D), - (190, 80, 2, 2, 0x566D), - (192, 80, 4, 2, 0x5EED), - (196, 80, 4, 2, 0x5F0D), - (200, 80, 8, 128, 0x5F0E), - (208, 80, 4, 2, 0x5F0D), - (212, 80, 2, 2, 0x5EED), - (214, 80, 2, 2, 0x566D), - (216, 80, 2, 4, 0x5F0D), - (242, 80, 2, 4, 0x5F0D), - (244, 80, 2, 2, 0x566D), - (246, 80, 2, 2, 0x5EED), - (248, 80, 4, 2, 0x5F0D), - (252, 80, 8, 128, 0x5F0E), - (260, 80, 6, 2, 0x5F0D), - (266, 80, 2, 2, 0x5EED), - (268, 80, 2, 2, 0x566D), - (284, 80, 2, 4, 0x5F0D), - (286, 80, 2, 2, 0x566D), - (8, 82, 6, 2, 0x5F0D), - (14, 82, 4, 126, 0x5F0E), - (26, 82, 4, 126, 0x5F0E), - (30, 82, 6, 2, 0x5F0D), - (52, 82, 6, 2, 0x5F0D), - (58, 82, 4, 126, 0x5F0E), - (70, 82, 4, 126, 0x5F0E), - (74, 82, 4, 2, 0x5F0D), - (80, 82, 2, 126, 0x5F0E), - (102, 82, 2, 126, 0x5F0E), - (106, 82, 4, 2, 0x5F0D), - (110, 82, 4, 126, 0x5F0E), - (122, 82, 4, 126, 0x5F0E), - (126, 82, 6, 2, 0x5F0D), - (146, 82, 6, 2, 0x5F0D), - (152, 82, 4, 126, 0x5F0E), - (164, 82, 4, 126, 0x5F0E), - (168, 82, 6, 2, 0x5F0D), - (190, 82, 6, 2, 0x5F0D), - (196, 82, 4, 126, 0x5F0E), - (208, 82, 4, 126, 0x5F0E), - (212, 82, 4, 2, 0x5F0D), - (218, 82, 2, 126, 0x5F0E), - (240, 82, 2, 126, 0x5F0E), - (244, 82, 4, 2, 0x5F0D), - (248, 82, 4, 126, 0x5F0E), - (260, 82, 4, 126, 0x5F0E), - (264, 82, 6, 2, 0x5F0D), - (286, 82, 2, 2, 0x5F0D), - (6, 84, 8, 124, 0x5F0E), - (30, 84, 8, 124, 0x5F0E), - (50, 84, 8, 124, 0x5F0E), - (74, 84, 6, 124, 0x5F0E), - (104, 84, 6, 124, 0x5F0E), - (126, 84, 8, 124, 0x5F0E), - (144, 84, 8, 124, 0x5F0E), - (168, 84, 8, 124, 0x5F0E), - (188, 84, 8, 124, 0x5F0E), - (212, 84, 6, 124, 0x5F0E), - (242, 84, 6, 124, 0x5F0E), - (264, 84, 8, 124, 0x5F0E), - (284, 84, 4, 124, 0x5F0E), -] }; - -pub const GROUND: Sprite = Sprite { w: 336, h: 78, rects: &[ - (0, 0, 336, 2, 0x51C8), - (0, 2, 336, 2, 0xE7F1), - (0, 4, 12, 2, 0x75E5), - (12, 4, 12, 2, 0x9F2B), - (24, 4, 12, 2, 0x75E5), - (36, 4, 12, 2, 0x9F2B), - (48, 4, 12, 2, 0x75E5), - (60, 4, 12, 2, 0x9F2B), - (72, 4, 12, 2, 0x75E5), - (84, 4, 12, 2, 0x9F2B), - (96, 4, 12, 2, 0x75E5), - (108, 4, 12, 2, 0x9F2B), - (120, 4, 12, 2, 0x75E5), - (132, 4, 12, 2, 0x9F2B), - (144, 4, 12, 2, 0x75E5), - (156, 4, 12, 2, 0x9F2B), - (168, 4, 12, 2, 0x75E5), - (180, 4, 12, 2, 0x9F2B), - (192, 4, 12, 2, 0x75E5), - (204, 4, 12, 2, 0x9F2B), - (216, 4, 12, 2, 0x75E5), - (228, 4, 12, 2, 0x9F2B), - (240, 4, 12, 2, 0x75E5), - (252, 4, 12, 2, 0x9F2B), - (264, 4, 12, 2, 0x75E5), - (276, 4, 12, 2, 0x9F2B), - (288, 4, 12, 2, 0x75E5), - (300, 4, 12, 2, 0x9F2B), - (312, 4, 12, 2, 0x75E5), - (324, 4, 12, 2, 0x9F2B), - (0, 6, 10, 2, 0x75E5), - (10, 6, 12, 2, 0x9F2B), - (22, 6, 12, 2, 0x75E5), - (34, 6, 12, 2, 0x9F2B), - (46, 6, 12, 2, 0x75E5), - (58, 6, 12, 2, 0x9F2B), - (70, 6, 12, 2, 0x75E5), - (82, 6, 12, 2, 0x9F2B), - (94, 6, 12, 2, 0x75E5), - (106, 6, 12, 2, 0x9F2B), - (118, 6, 12, 2, 0x75E5), - (130, 6, 12, 2, 0x9F2B), - (142, 6, 12, 2, 0x75E5), - (154, 6, 12, 2, 0x9F2B), - (166, 6, 12, 2, 0x75E5), - (178, 6, 12, 2, 0x9F2B), - (190, 6, 12, 2, 0x75E5), - (202, 6, 12, 2, 0x9F2B), - (214, 6, 12, 2, 0x75E5), - (226, 6, 12, 2, 0x9F2B), - (238, 6, 12, 2, 0x75E5), - (250, 6, 12, 2, 0x9F2B), - (262, 6, 12, 2, 0x75E5), - (274, 6, 12, 2, 0x9F2B), - (286, 6, 12, 2, 0x75E5), - (298, 6, 12, 2, 0x9F2B), - (310, 6, 12, 2, 0x75E5), - (322, 6, 12, 2, 0x9F2B), - (334, 6, 2, 12, 0x75E5), - (0, 8, 8, 2, 0x75E5), - (8, 8, 12, 2, 0x9F2B), - (20, 8, 12, 2, 0x75E5), - (32, 8, 12, 2, 0x9F2B), - (44, 8, 12, 2, 0x75E5), - (56, 8, 12, 2, 0x9F2B), - (68, 8, 12, 2, 0x75E5), - (80, 8, 12, 2, 0x9F2B), - (92, 8, 12, 2, 0x75E5), - (104, 8, 12, 2, 0x9F2B), - (116, 8, 12, 2, 0x75E5), - (128, 8, 12, 2, 0x9F2B), - (140, 8, 12, 2, 0x75E5), - (152, 8, 12, 2, 0x9F2B), - (164, 8, 12, 2, 0x75E5), - (176, 8, 12, 2, 0x9F2B), - (188, 8, 12, 2, 0x75E5), - (200, 8, 12, 2, 0x9F2B), - (212, 8, 12, 2, 0x75E5), - (224, 8, 12, 2, 0x9F2B), - (236, 8, 12, 2, 0x75E5), - (248, 8, 12, 2, 0x9F2B), - (260, 8, 12, 2, 0x75E5), - (272, 8, 12, 2, 0x9F2B), - (284, 8, 12, 2, 0x75E5), - (296, 8, 12, 2, 0x9F2B), - (308, 8, 12, 2, 0x75E5), - (320, 8, 12, 2, 0x9F2B), - (332, 8, 2, 10, 0x75E5), - (0, 10, 6, 2, 0x75E5), - (6, 10, 12, 2, 0x9F2B), - (18, 10, 12, 2, 0x75E5), - (30, 10, 12, 2, 0x9F2B), - (42, 10, 12, 2, 0x75E5), - (54, 10, 12, 2, 0x9F2B), - (66, 10, 12, 2, 0x75E5), - (78, 10, 12, 2, 0x9F2B), - (90, 10, 12, 2, 0x75E5), - (102, 10, 12, 2, 0x9F2B), - (114, 10, 12, 2, 0x75E5), - (126, 10, 12, 2, 0x9F2B), - (138, 10, 12, 2, 0x75E5), - (150, 10, 12, 2, 0x9F2B), - (162, 10, 12, 2, 0x75E5), - (174, 10, 12, 2, 0x9F2B), - (186, 10, 12, 2, 0x75E5), - (198, 10, 12, 2, 0x9F2B), - (210, 10, 12, 2, 0x75E5), - (222, 10, 12, 2, 0x9F2B), - (234, 10, 12, 2, 0x75E5), - (246, 10, 12, 2, 0x9F2B), - (258, 10, 12, 2, 0x75E5), - (270, 10, 12, 2, 0x9F2B), - (282, 10, 12, 2, 0x75E5), - (294, 10, 12, 2, 0x9F2B), - (306, 10, 12, 2, 0x75E5), - (318, 10, 12, 2, 0x9F2B), - (330, 10, 2, 8, 0x75E5), - (0, 12, 4, 2, 0x75E5), - (4, 12, 12, 2, 0x9F2B), - (16, 12, 12, 2, 0x75E5), - (28, 12, 12, 2, 0x9F2B), - (40, 12, 12, 2, 0x75E5), - (52, 12, 12, 2, 0x9F2B), - (64, 12, 12, 2, 0x75E5), - (76, 12, 12, 2, 0x9F2B), - (88, 12, 12, 2, 0x75E5), - (100, 12, 12, 2, 0x9F2B), - (112, 12, 12, 2, 0x75E5), - (124, 12, 12, 2, 0x9F2B), - (136, 12, 12, 2, 0x75E5), - (148, 12, 12, 2, 0x9F2B), - (160, 12, 12, 2, 0x75E5), - (172, 12, 12, 2, 0x9F2B), - (184, 12, 12, 2, 0x75E5), - (196, 12, 12, 2, 0x9F2B), - (208, 12, 12, 2, 0x75E5), - (220, 12, 12, 2, 0x9F2B), - (232, 12, 12, 2, 0x75E5), - (244, 12, 12, 2, 0x9F2B), - (256, 12, 12, 2, 0x75E5), - (268, 12, 12, 2, 0x9F2B), - (280, 12, 12, 2, 0x75E5), - (292, 12, 12, 2, 0x9F2B), - (304, 12, 12, 2, 0x75E5), - (316, 12, 12, 2, 0x9F2B), - (328, 12, 2, 6, 0x75E5), - (0, 14, 2, 2, 0x75E5), - (2, 14, 12, 2, 0x9F2B), - (14, 14, 12, 2, 0x75E5), - (26, 14, 12, 2, 0x9F2B), - (38, 14, 12, 2, 0x75E5), - (50, 14, 12, 2, 0x9F2B), - (62, 14, 12, 2, 0x75E5), - (74, 14, 12, 2, 0x9F2B), - (86, 14, 12, 2, 0x75E5), - (98, 14, 12, 2, 0x9F2B), - (110, 14, 12, 2, 0x75E5), - (122, 14, 12, 2, 0x9F2B), - (134, 14, 12, 2, 0x75E5), - (146, 14, 12, 2, 0x9F2B), - (158, 14, 12, 2, 0x75E5), - (170, 14, 12, 2, 0x9F2B), - (182, 14, 12, 2, 0x75E5), - (194, 14, 12, 2, 0x9F2B), - (206, 14, 12, 2, 0x75E5), - (218, 14, 12, 2, 0x9F2B), - (230, 14, 12, 2, 0x75E5), - (242, 14, 12, 2, 0x9F2B), - (254, 14, 12, 2, 0x75E5), - (266, 14, 12, 2, 0x9F2B), - (278, 14, 12, 2, 0x75E5), - (290, 14, 12, 2, 0x9F2B), - (302, 14, 12, 2, 0x75E5), - (314, 14, 12, 2, 0x9F2B), - (326, 14, 2, 4, 0x75E5), - (0, 16, 12, 2, 0x9F2B), - (12, 16, 12, 2, 0x75E5), - (24, 16, 12, 2, 0x9F2B), - (36, 16, 12, 2, 0x75E5), - (48, 16, 12, 2, 0x9F2B), - (60, 16, 12, 2, 0x75E5), - (72, 16, 12, 2, 0x9F2B), - (84, 16, 12, 2, 0x75E5), - (96, 16, 12, 2, 0x9F2B), - (108, 16, 12, 2, 0x75E5), - (120, 16, 12, 2, 0x9F2B), - (132, 16, 12, 2, 0x75E5), - (144, 16, 12, 2, 0x9F2B), - (156, 16, 12, 2, 0x75E5), - (168, 16, 12, 2, 0x9F2B), - (180, 16, 12, 2, 0x75E5), - (192, 16, 12, 2, 0x9F2B), - (204, 16, 12, 2, 0x75E5), - (216, 16, 12, 2, 0x9F2B), - (228, 16, 12, 2, 0x75E5), - (240, 16, 12, 2, 0x9F2B), - (252, 16, 12, 2, 0x75E5), - (264, 16, 12, 2, 0x9F2B), - (276, 16, 12, 2, 0x75E5), - (288, 16, 12, 2, 0x9F2B), - (300, 16, 12, 2, 0x75E5), - (312, 16, 12, 2, 0x9F2B), - (324, 16, 2, 2, 0x75E5), - (0, 18, 336, 2, 0x5404), - (0, 20, 336, 2, 0xD549), - (0, 22, 336, 56, 0xDED2), -] }; - diff --git a/apps/sky-hop/src/view.rs b/apps/sky-hop/src/view.rs deleted file mode 100644 index a3f4ab8..0000000 --- a/apps/sky-hop/src/view.rs +++ /dev/null @@ -1,379 +0,0 @@ -// Drawing, through cmf-wp2-ui's Surface: the watch draws with `&Api`, the tests with `Fb`. One buffer and no -// double buffering, so each frame repaints only what moved and never paints a pixel twice in different colours -// where it can help it (section 2 of the app guide). The sprites (src/sprites.rs) are lists of rects: the Surface -// has no blit. - -use crate::game::{C, GATE_W, GROUND_Y, Game, Gate, HOP_X, SIZE, State}; -use crate::sprites::{self, PIPE_BODY, PIPE_CAP, PIPE_CAP_H, Sprite}; -use cmf_wp2_ui::Rgb; -use cmf_wp2_ui::Surface; -use cmf_wp2_ui::draw::rrect; -use cmf_wp2_ui::text::{big, big_width, centre, int}; - -pub const PANEL: Rgb = Rgb(22, 22, 30); -const GREY: u16 = 0x8C71; -const WHITE: u16 = 0xFFFF; -/// Text on the scenery. -const INK: Rgb = Rgb(84, 56, 71); - -/// The score's digits sit this far apart, on top of the screen. -pub const SCORE_Y: i32 = 40; -const DIGIT_H: i32 = 36; -const DIGIT_GAP: i32 = 2; -/// The town strip scrolls one px per this many px the pipes travel; the ground goes with the pipes. -const BAND_SLOW: i32 = 40; -/// The bird sprite's size, centred on the critter. -const BIRD_W: i32 = 34; -const BIRD_H: i32 = 24; - -const DIGITS: [&Sprite; 10] = [ - &sprites::DIGIT0, - &sprites::DIGIT1, - &sprites::DIGIT2, - &sprites::DIGIT3, - &sprites::DIGIT4, - &sprites::DIGIT5, - &sprites::DIGIT6, - &sprites::DIGIT7, - &sprites::DIGIT8, - &sprites::DIGIT9, -]; - -/// What was on screen after the last frame. -#[derive(Clone, Copy, PartialEq, Debug)] -pub struct Seen { - xs: [i32; crate::game::GATES], - band: i32, - ground: i32, - y: i32, - wing: usize, - score: u32, - state: State, -} - -pub fn seen(g: &Game) -> Seen { - Seen { xs: g.gates.map(|gt| gt.x), band: band_x(g), ground: ground_x(g), y: g.hop_y(), wing: g.wing(), score: g.score, state: g.state } -} - -/// A surface that drops what falls outside a box, so a part of the picture can be redrawn alone. -struct Clip<'a, S: Surface> { - s: &'a mut S, - x0: i32, - y0: i32, - x1: i32, - y1: i32, -} - -impl Surface for Clip<'_, S> { - fn rect(&mut self, x: i32, y: i32, w: i32, h: i32, c: u16) { - let (ax, ay) = (x.max(self.x0), y.max(self.y0)); - let (bx, by) = ((x + w).min(self.x1), (y + h).min(self.y1)); - if bx > ax && by > ay { - self.s.rect(ax, ay, bx - ax, by - ay, c); - } - } - - fn text(&mut self, x: i32, y: i32, t: &str, c: u16) { - self.s.text(x, y, t, c); - } -} - -fn blit(s: &mut impl Surface, sp: &Sprite, x: i32, y: i32) { - for &(rx, ry, w, h, c) in sp.rects { - s.rect(x + rx as i32, y + ry as i32, w as i32, h as i32, c); - } -} - -/// Upside down. -fn blit_flipped(s: &mut impl Surface, sp: &Sprite, x: i32, y: i32) { - for &(rx, ry, w, h, c) in sp.rects { - s.rect(x + rx as i32, y + sp.h - (ry as i32 + h as i32), w as i32, h as i32, c); - } -} - -/// The shaft of a pipe: one row of the sprite, stretched to `h`. -fn shaft(s: &mut impl Surface, x: i32, y: i32, h: i32) { - if h > 0 { - for &(rx, _, w, _, c) in PIPE_BODY.rects { - s.rect(x + rx as i32, y, w as i32, h, c); - } - } -} - -/// Both pipes of a gate, from the top and the bottom of the screen to the gap, covering all `GATE_W` columns. -fn pipes(s: &mut impl Surface, gt: &Gate) { - blit_flipped(s, &PIPE_CAP, gt.x, gt.top - PIPE_CAP_H); - shaft(s, gt.x, 0, gt.top - PIPE_CAP_H); - blit(s, &PIPE_CAP, gt.x, gt.bottom); - shaft(s, gt.x, gt.bottom + PIPE_CAP_H, GROUND_Y - gt.bottom - PIPE_CAP_H); -} - -/// Where the town strip and the ground are scrolled to: how far their tiles are shifted to the left. -fn band_x(g: &Game) -> i32 { - g.scroll / BAND_SLOW % sprites::BAND.w -} - -fn ground_x(g: &Game) -> i32 { - g.scroll % sprites::GROUND.w -} - -/// The scenery in a box: sky, the town and grass, the ground. Every pixel of the box once. -fn scenery(s: &mut impl Surface, g: &Game, x0: i32, y0: i32, w: i32, h: i32) { - let band_y = GROUND_Y - sprites::BAND.h; - let mut clip = Clip { s, x0, y0, x1: x0 + w, y1: y0 + h }; - clip.rect(0, 0, SIZE, band_y, sprites::SKY); - let tiles = |sp: &Sprite, shift: i32, y: i32, clip: &mut Clip<_>| { - if y0 + h > y && y0 < y + sp.h { - for k in 0..3 { - let x = k * sp.w - shift; - if x < x0 + w && x + sp.w > x0 { - blit(clip, sp, x, y); - } - } - } - }; - tiles(&sprites::BAND, band_x(g), band_y, &mut clip); - tiles(&sprites::GROUND, ground_x(g), GROUND_Y, &mut clip); -} - -/// The background of a box: the scenery, then the parts of gates in it. -fn background(s: &mut impl Surface, g: &Game, x0: i32, y0: i32, w: i32, h: i32) { - scenery(s, g, x0, y0, w, h); - let mut clip = Clip { s, x0, y0, x1: x0 + w, y1: y0 + h }; - for gt in &g.gates { - pipes(&mut clip, gt); - } -} - -/// A gate at its new place; with `from`, the strip it left behind on the right gets the scenery back first. -fn gate(s: &mut impl Surface, g: &Game, gt: &Gate, from: Option) { - if gt.x >= SIZE && from.is_none_or(|x| x >= SIZE) { - return; - } - if let Some(old) = from { - // What the pipe left behind, and its two margin columns that the sprite does not paint. Not the ground: - // it is repainted whenever it scrolls. - let x0 = gt.x + GATE_W - 2; - scenery(s, g, x0, 0, old + GATE_W - x0, GROUND_Y); - } - pipes(s, gt); -} - -fn bird(wing: usize) -> &'static Sprite { - [&sprites::BIRD_UP, &sprites::BIRD_MID, &sprites::BIRD_DOWN][wing.min(2)] -} - -/// The bird at its height; `from`: its last height, whose box gets the background back in the same pass. -fn critter(s: &mut impl Surface, g: &Game, from: Option) { - let y = g.hop_y(); - let (lo, hi) = from.map_or((y, y), |f| (f.min(y), f.max(y))); - background(s, g, HOP_X - BIRD_W / 2, lo - BIRD_H / 2, BIRD_W, hi - lo + BIRD_H); - blit(s, bird(g.wing()), HOP_X - BIRD_W / 2, y - BIRD_H / 2); -} - -fn number_width(text: &str) -> i32 { - text.len() as i32 * (24 + DIGIT_GAP) - DIGIT_GAP - text.bytes().filter(|&b| b == b'1').count() as i32 * 8 -} - -/// `text` (digits) in the sprite digits, centred on `cx`. -fn digits(s: &mut impl Surface, text: &str, cx: i32, y: i32) { - let mut x = cx - number_width(text) / 2; - for d in text.bytes() { - let sp = DIGITS[(d - b'0').min(9) as usize]; - blit(s, sp, x, y); - x += sp.w + DIGIT_GAP; - } -} - -fn score(s: &mut impl Surface, g: &Game, clear: bool) { - let mut buf = [0u8; 11]; - let text = int(g.score as i32, &mut buf); - if clear { - background(s, g, C - 80, SCORE_Y, 160, DIGIT_H); - } - digits(s, text, C, SCORE_Y); -} - -fn best_line(s: &mut impl Surface, y: i32, best: u32, c: u16) { - let mut buf = [0u8; 11]; - let mut line = [0u8; 16]; - let n = int(best as i32, &mut buf).as_bytes(); - line[..5].copy_from_slice(b"BEST "); - line[5..5 + n.len()].copy_from_slice(n); - centre(s, C, y, core::str::from_utf8(&line[..5 + n.len()]).unwrap_or("?"), c); -} - -fn ready(s: &mut impl Surface, best: u32) { - const TITLE: &str = "SKY HOP"; - big(s, C - big_width(TITLE, 4) / 2, 72, TITLE, 4, WHITE); - blit(s, &sprites::GET_READY, C - sprites::GET_READY.w / 2, 124); - blit(s, &sprites::TAP_HINT, C - sprites::TAP_HINT.w / 2, 296); - if best > 0 { - best_line(s, 424, best, INK.rgb565()); - } -} - -fn over(s: &mut impl Surface, g: &Game, best: u32) { - rrect(s, C - 140, 150, 280, 170, 28, PANEL, Rgb(78, 192, 202)); - blit(s, &sprites::GAMEOVER, C - sprites::GAMEOVER.w / 2, 162); - let mut buf = [0u8; 11]; - digits(s, int(g.score as i32, &mut buf), C, 212); - best_line(s, 262, best, GREY); - centre(s, C, 290, "TAP TO RETRY", GREY); -} - -/// The town strip moved: repaint its rows, the pipes in them and the bird. -fn scroll_band(s: &mut impl Surface, g: &Game) { - let y = GROUND_Y - sprites::BAND.h; - background(s, g, 0, y, SIZE, sprites::BAND.h); - blit(s, bird(g.wing()), HOP_X - BIRD_W / 2, g.hop_y() - BIRD_H / 2); -} - -/// Draws the frame for `g`. `prev`: what is on screen now; `None`, or another state, repaints everything. -pub fn frame(s: &mut impl Surface, g: &Game, best: u32, prev: Option) -> Seen { - let now = seen(g); - let prev = prev.filter(|p| p.state == g.state); - match prev { - None => { - scenery(s, g, 0, 0, SIZE, SIZE); - for gt in &g.gates { - gate(s, g, gt, None); - } - critter(s, g, None); - match g.state { - State::Ready => ready(s, best), - State::Playing => score(s, g, false), - State::Over => { - score(s, g, false); - over(s, g, best); - } - } - } - Some(p) if p == now => {} - Some(p) => { - if g.state == State::Playing { - for (gt, x) in g.gates.iter().zip(p.xs) { - gate(s, g, gt, Some(x)); - } - } - if g.state == State::Playing && p.band != now.band { - scroll_band(s, g); - } - critter(s, g, Some(p.y)); - if g.state == State::Playing { - if p.ground != now.ground { - let (y, h) = (GROUND_Y, SIZE - GROUND_Y); - scenery(s, g, 0, y, SIZE, h); - } - score(s, g, p.score != g.score); - } - } - } - now -} - -#[cfg(test)] -mod tests { - use super::*; - use crate::game::{GATES, Step}; - use cmf_wp2_ui::Fb; - use std::vec; - use std::vec::Vec; - - fn screen() -> Vec { - vec![0u16; (SIZE * SIZE) as usize] - } - - fn full(g: &Game, best: u32) -> Vec { - let mut px = screen(); - frame(&mut Fb::new(&mut px), g, best, None); - px - } - - /// Frame by frame, what the watch ends up with must be what a full repaint draws. - #[test] - fn partial_frames_match_a_full_repaint() { - for seed in [1u32, 8, 77] { - let mut g = Game::new(seed); - let mut px = screen(); - let mut prev = None; - let mut checked = 0; - for tick in 0..900u32 { - if tick == 5 || (g.state == State::Playing && tick % 13 == 0) { - g.flap(); - } - if g.state == State::Over { - break; - } - let _: Step = g.step(); - prev = Some(frame(&mut Fb::new(&mut px), &g, 3, prev)); - if tick % 7 == 0 || g.state == State::Over { - let want = full(&g, 3); - let bad = px.iter().zip(&want).position(|(a, b)| a != b); - assert_eq!(bad.map(|i| (i as i32 % SIZE, i as i32 / SIZE)), None, "seed {seed} tick {tick}"); - checked += 1; - } - } - assert!(checked > 5); - } - } - - #[test] - fn a_still_frame_draws_nothing() { - let g = Game::new(4); - let mut px = screen(); - let mut fb = Fb::new(&mut px); - let p = frame(&mut fb, &g, 0, None); - let rects = fb.rects; - frame(&mut fb, &g, 0, Some(p)); - assert_eq!(fb.rects, rects); - } - - #[test] - fn critter_is_drawn_where_it_is() { - let g = Game::new(4); - let px = full(&g, 0); - let fb_at = |x: i32, y: i32| px[(y * SIZE + x) as usize]; - let (rx, ry, _, _, c) = bird(g.wing()).rects[0]; - assert_eq!(fb_at(HOP_X - BIRD_W / 2 + rx as i32, g.hop_y() - BIRD_H / 2 + ry as i32), c); - let mut bare = screen(); - scenery(&mut Fb::new(&mut bare), &g, 0, 0, SIZE, SIZE); - let (x, y) = (HOP_X - BIRD_W, g.hop_y()); - assert_eq!(fb_at(x, y), bare[(y * SIZE + x) as usize]); - } - - /// Collects the rects drawn. - struct Rects(Vec<(i32, i32, i32, i32)>); - - impl Surface for Rects { - fn rect(&mut self, x: i32, y: i32, w: i32, h: i32, _: u16) { - self.0.push((x, y, w, h)); - } - fn text(&mut self, _: i32, _: i32, _: &str, _: u16) {} - } - - #[test] - fn pipe_parts_cover_the_gate_without_overlap() { - let gt = Gate { x: 100, top: 150, bottom: 290, ..Game::new(1).gates[0] }; - let mut rects = Rects(Vec::new()); - pipes(&mut rects, >); - let rects = rects.0; - for (i, a) in rects.iter().enumerate() { - for b in &rects[i + 1..] { - let apart = a.0 + a.2 <= b.0 || b.0 + b.2 <= a.0 || a.1 + a.3 <= b.1 || b.1 + b.3 <= a.1; - assert!(apart, "{a:?} {b:?}"); - } - } - assert!(rects.iter().all(|r| r.0 >= gt.x && r.0 + r.2 <= gt.x + GATE_W && r.1 >= 0 && r.1 + r.3 <= GROUND_Y)); - assert_eq!(GATES, 3); - assert_eq!(sprites::PIPE_W, GATE_W); - } - - #[test] - fn digits_are_as_wide_as_the_sprites() { - for text in ["0", "1", "10", "2024", "111"] { - let sum: i32 = text.bytes().map(|b| DIGITS[(b - b'0') as usize].w).sum::() + DIGIT_GAP * (text.len() as i32 - 1); - assert_eq!(number_width(text), sum, "{text}"); - } - } -} diff --git a/apps/sky-hop/store.md b/apps/sky-hop/store.md deleted file mode 100644 index c1fe267..0000000 --- a/apps/sky-hop/store.md +++ /dev/null @@ -1,10 +0,0 @@ -A one-touch arcade game. Tap the screen or turn the crown to hop, fall back with gravity, and slip through the gaps -between the pipes. Every pair you pass is a point; the pipes speed up and the gaps narrow as the score grows. Touch a -pipe, the ground or the edge of the screen and the run is over: tap to go again. Your best score is kept on the watch. - -Press the crown or swipe right to leave. - -## Requirements - -The [patched firmware](/firmware) and the [App Loader](/firmware). Open it from the **Apps** row at the end of the -watch's app list (list style, not the waterfall). diff --git a/apps/sky-hop/store.toml b/apps/sky-hop/store.toml deleted file mode 100644 index 33f939a..0000000 --- a/apps/sky-hop/store.toml +++ /dev/null @@ -1,6 +0,0 @@ -# The app's listing in the FMC store (README.md, "store.toml"). The page's body is store.md. -name = "Sky Hop" -summary = "Tap to hop through the pipes. One-touch arcade game" -version = "0.1.2" -author = "CMF Tech Community" -screenshots = ["shots/ready.png", "shots/playing.png", "shots/over.png"] diff --git a/apps/sky-hop/tools/gen_icon.py b/apps/sky-hop/tools/gen_icon.py deleted file mode 100644 index d408066..0000000 --- a/apps/sky-hop/tools/gen_icon.py +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env python3 -"""Draws icon.svg from the sprite PNGs: the bird on a round patch of sky. -Usage: gen_icon.py > icon.svg""" -import sys -sys.argv, d = sys.argv[:1], sys.argv[1] -exec(open(__file__.replace("gen_icon.py", "gen_sprites.py")).read().split("d = sys.argv[1]")[0]) - -def hexc(c): - return "#%02X%02X%02X" % (((c >> 11) * 255 + 15) // 31, (((c >> 5) & 63) * 255 + 31) // 63, ((c & 31) * 255 + 15) // 31) - -def draw(img, ox, oy, scale=1, rows=None, x0=0, x1=None): - h = rows if rows is not None else len(img) - out = [] - for x, y, w, hh, c in rects(img, x0, 0, x1, h): - out.append(f'') - return "\n ".join(out) - -_, _, sky_img = png(f"{d}/background-day.png") -sky = hexc(sky_img[0][0]) -_, _, bird = png(f"{d}/yellowbird-midflap.png") - -print(f''' - - - - {draw(bird, 14, 24, 2)} - -''') diff --git a/apps/sky-hop/tools/gen_sprites.py b/apps/sky-hop/tools/gen_sprites.py deleted file mode 100644 index 438a3b6..0000000 --- a/apps/sky-hop/tools/gen_sprites.py +++ /dev/null @@ -1,117 +0,0 @@ -#!/usr/bin/env python3 -"""Turns the Flappy-style PNG sprites into src/sprites.rs: lists of opaque rects (x, y, w, h, rgb565), because the -watch's only pixel primitive is a filled rect. Usage: gen_sprites.py > src/sprites.rs""" -import struct, sys, zlib - -def png(path): - d = open(path, 'rb').read() - pos, chunks = 8, {} - idat = b'' - while pos < len(d): - n, t = struct.unpack('>I4s', d[pos:pos + 8]) - body = d[pos + 8:pos + 8 + n] - if t == b'IDAT': idat += body - else: chunks[t] = body - pos += 12 + n - w, h, depth, ctype = struct.unpack('>IIBB', chunks[b'IHDR'][:10]) - assert ctype in (3, 6) and depth in (1, 2, 4, 8), (path, ctype, depth) - pal = chunks.get(b'PLTE') - trns = chunks.get(b'tRNS', b'') - raw = zlib.decompress(idat) - bpp = 4 if ctype == 6 else 1 - stride = (w * depth + 7) // 8 * (4 if ctype == 6 else 1) - rows, prev = [], bytearray(stride) - for y in range(h): - f = raw[y * (stride + 1)] - line = bytearray(raw[y * (stride + 1) + 1:(y + 1) * (stride + 1)]) - for i in range(stride): - a = line[i - bpp] if i >= bpp else 0 - b = prev[i] - c = prev[i - bpp] if i >= bpp else 0 - if f == 1: line[i] = (line[i] + a) & 255 - elif f == 2: line[i] = (line[i] + b) & 255 - elif f == 3: line[i] = (line[i] + (a + b) // 2) & 255 - elif f == 4: - p = a + b - c - pa, pb, pc = abs(p - a), abs(p - b), abs(p - c) - pr = a if pa <= pb and pa <= pc else b if pb <= pc else c - line[i] = (line[i] + pr) & 255 - rows.append(line) - prev = line - img = [] - for line in rows: - out = [] - for x in range(w): - if ctype == 6: - r, g, b, alpha = line[x * 4:x * 4 + 4] - out.append(None if alpha < 128 else ((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3)) - continue - bit = x * depth - idx = (line[bit // 8] >> (8 - depth - bit % 8)) & ((1 << depth) - 1) - alpha = trns[idx] if idx < len(trns) else 255 - r, g, b = pal[idx * 3:idx * 3 + 3] - out.append(None if alpha < 128 else ((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3)) - img.append(out) - return w, h, img - -def rects(img, x0=0, y0=0, x1=None, y1=None): - """Greedy merge of equal-coloured pixels into rects, opaque pixels only.""" - x1 = x1 if x1 is not None else len(img[0]) - y1 = y1 if y1 is not None else len(img) - seen = set() - out = [] - for y in range(y0, y1): - for x in range(x0, x1): - c = img[y][x] - if c is None or (x, y) in seen: continue - w = 1 - while x + w < x1 and img[y][x + w] == c and (x + w, y) not in seen: w += 1 - h = 1 - while y + h < y1 and all(img[y + h][x + i] == c and (x + i, y + h) not in seen for i in range(w)): h += 1 - for j in range(h): - for i in range(w): seen.add((x + i, y + j)) - out.append((x - x0, y - y0, w, h, c)) - return out - -def emit(name, w, h, rs): - print(f"pub const {name.upper()}: Sprite = Sprite {{ w: {w}, h: {h}, rects: &[") - for r in rs: print(" (%d, %d, %d, %d, 0x%04X)," % r) - print("] };\n") - -d = sys.argv[1] -print("// Generated by tools/gen_sprites.py from the sprite PNGs: do not edit.\n") -print("/// Opaque rects of a sprite: (x, y, w, h, rgb565).") -print("pub struct Sprite {\n pub w: i32,\n pub h: i32,\n pub rects: &'static [(i16, i16, i16, i16, u16)],\n}\n") -for i in range(10): - w, h, img = png(f"{d}/{i}.png"); emit(f"digit{i}", w, h, rects(img)) -for n, name in enumerate(['up', 'mid', 'down']): - w, h, img = png(f"{d}/yellowbird-{name}flap.png"); emit(f"bird_{name}", w, h, rects(img)) -w, h, img = png(f"{d}/gameover.png"); emit("gameover", w, h, rects(img)) -# The pieces of the title screen that we use, cropped to their box: "Get Ready!" and the tap hint. Left out: the -# "FlappyBird" logo and the grey bird with its arrow (the game has its own bird). -w, h, img = png(f"{d}/message.png") -for name, y0, y1 in [("get_ready", 102, 152), ("tap_hint", 231, 267)]: - xs = [x for row in img[y0:y1] for x, c in enumerate(row) if c is not None] - x0, x1 = min(xs), max(xs) + 1 - emit(name, x1 - x0, y1 - y0, rects(img, x0, y0, x1, y1)) - -# The pipe: a cap on top of a shaft. The cap is rects; the shaft is one representative row that the view stretches -# to any length. -w, h, img = png(f"{d}/pipe-green.png") -cap = 26 # rows 0..25: the wider cap and its dark lower edge; below it the shaft only varies by faint noise -print(f"pub const PIPE_W: i32 = {w};\npub const PIPE_CAP_H: i32 = {cap};\n") -emit("pipe_cap", w, cap, rects(img, 0, 0, w, cap)) -body = rects([img[160]], 0, 0, w, 1) -emit("pipe_body", w, 1, body) - -# The scenery: plain sky above, and the strip with the clouds, the town and the grass along the bottom (drawn twice -# side by side to cover the screen's width). -w, h, img = png(f"{d}/background-day.png") -sky = img[0][0] -top = next(y for y in range(h) if img[y][0] != sky or len(set(img[y])) > 1) -print(f"pub const SKY: u16 = 0x{sky:04X};\n") -emit("band", w, h - top, rects(img, 0, top, w, h)) - -# The ground, only the rows that are on the screen (the game puts it at y 388 of 466); drawn twice side by side. -w, h, img = png(f"{d}/base.png") -emit("ground", w, 78, rects(img, 0, 0, w, 78)) diff --git a/apps/snake/Cargo.toml b/apps/snake/Cargo.toml deleted file mode 100644 index ad760ad..0000000 --- a/apps/snake/Cargo.toml +++ /dev/null @@ -1,12 +0,0 @@ -[package] -name = "snake" -edition.workspace = true -license.workspace = true -version.workspace = true - -[dependencies] -cmf-wp2-app.workspace = true - -[[bin]] -name = "snake" -bench = false diff --git a/apps/snake/icon.svg b/apps/snake/icon.svg deleted file mode 100644 index 25e94fe..0000000 --- a/apps/snake/icon.svg +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/apps/snake/readme.md b/apps/snake/readme.md deleted file mode 100644 index 2934834..0000000 --- a/apps/snake/readme.md +++ /dev/null @@ -1 +0,0 @@ -Snake game for CMF Watch Pro 2 diff --git a/apps/snake/src/game.rs b/apps/snake/src/game.rs deleted file mode 100644 index ef4b2df..0000000 --- a/apps/snake/src/game.rs +++ /dev/null @@ -1,553 +0,0 @@ -cmf_wp2_app::app_icon!(); - -use cmf_wp2_app::{Api, BUTTON, CROWN, TOUCH_DOWN}; - -cmf_wp2_app::entry!(main); -cmf_wp2_app::app_features!(cmf_wp2_app::WIDGET | cmf_wp2_app::PAGE); - -const CELL: i16 = 12; -const MAX: usize = 900; - -const BG_COLOR: u16 = 0x0000; -const GRID_COLOR: u16 = 0x4208; -const BUTTON_COLOR: u16 = 0x2104; -const BORDER_COLOR: u16 = 0x630C; -const WHITE: u16 = 0xFFFF; -const SNAKE_COLOR: u16 = 0x05A0; -const HEAD_COLOR: u16 = 0x07E0; -const FOOD_COLOR: u16 = 0xF800; - -const SIDE_W: i16 = 82; -const SIDE_H: i16 = 96; -const TOP_W: i16 = 136; -const TOP_H: i16 = 74; -const GAP: i16 = 8; -const GRID_TOP: i16 = 92; -const BOTTOM_AREA: i16 = 58; - -// Рисуем стрелку -// 0 — вверх, 1 — вправо, 2 — вниз, 3 — влево -fn draw_arrow( - api: &Api, - cx: i16, - cy: i16, - size: i16, - direction: usize, -) { - let head = size / 2; - let half_head = head / 2; - let shaft = size / 4; - let half_shaft = shaft / 2; - - match direction { - 0 => { - let top = cy - size / 2; - - for row in 0..head { - let half = (row * half_head) / head.max(1); - - api.rect( - cx - half, - top + row, - (half * 2 + 2) as u16, - 1, - WHITE, - ); - } - - api.rect( - cx - half_shaft, - top + head - 1, - shaft as u16, - (size - head + 1) as u16, - WHITE, - ); - } - - 1 => { - let left = cx - size / 2; - - api.rect( - left, - cy - half_shaft, - (size - head + 1) as u16, - shaft as u16, - WHITE, - ); - - for col in 0..head { - let half = (col * half_head) / head.max(1); - - api.rect( - left + size - head + col, - cy - half, - 1, - (half * 2 + 2) as u16, - WHITE, - ); - } - } - - 2 => { - let top = cy - size / 2; - - api.rect( - cx - half_shaft, - top, - shaft as u16, - (size - head + 1) as u16, - WHITE, - ); - - for row in 0..head { - let half = - ((head - row) * half_head) / head.max(1); - - api.rect( - cx - half, - top + size - head + row, - (half * 2 + 2) as u16, - 1, - WHITE, - ); - } - } - - _ => { - let left = cx - size / 2; - - for col in 0..head { - let half = - ((head - col) * half_head) / head.max(1); - - api.rect( - left + col, - cy - half, - 1, - (half * 2 + 2) as u16, - WHITE, - ); - } - - api.rect( - left + head - 1, - cy - half_shaft, - (size - head + 1) as u16, - shaft as u16, - WHITE, - ); - } - } -} - -// Отдельная прямоугольная кнопка -fn draw_button( - api: &Api, - x: i16, - y: i16, - w: i16, - h: i16, - direction: usize, -) { - api.rect( - x, - y, - w as u16, - h as u16, - BORDER_COLOR, - ); - - api.rect( - x + 3, - y + 3, - (w - 6) as u16, - (h - 6) as u16, - BUTTON_COLOR, - ); - - let label = match direction { - 0 => "UP", - 1 => "RIGHT", - 2 => "DOWN", - _ => "LEFT", - }; - - let text_x = x + (w - label.len() as i16 * 8) / 2; - let text_y = y + (h - 12) / 2; - - api.text(text_x, text_y, label, WHITE); -} - -fn inside( - x: i16, - y: i16, - bx: i16, - by: i16, - bw: i16, - bh: i16, -) -> bool { - x >= bx && x < bx + bw - && y >= by && y < by + bh -} - -fn draw_grid( - api: &Api, - offset_x: i16, - offset_y: i16, - cols: usize, - rows: usize, -) { - for x in 0..=cols { - api.rect( - offset_x + x as i16 * CELL, - offset_y, - 1, - (rows as i16 * CELL) as u16, - GRID_COLOR, - ); - } - - for y in 0..=rows { - api.rect( - offset_x, - offset_y + y as i16 * CELL, - (cols as i16 * CELL) as u16, - 1, - GRID_COLOR, - ); - } -} - -fn main(api: &'static Api) -> i32 { - let width = api.width as i16; - let height = api.height as i16; - - // Размер игрового поля - let cols = ((width - 2 * (SIDE_W + GAP)) / CELL) - .max(5) as usize; - - let max_rows = MAX / cols; - - let rows = (((height - GRID_TOP - BOTTOM_AREA) / CELL) - .max(5) as usize) - .min(max_rows); - - if cols < 5 || rows < 5 || rows * cols > MAX { - return 0; - } - - let offset_x = - (width - cols as i16 * CELL) / 2; - - let offset_y = GRID_TOP; - - // Координаты четырёх отдельных кнопок - let up_x = (width - TOP_W) / 2; - let up_y = 36; - - let down_x = up_x; - let down_y = height - TOP_H - GAP; - - let side_y = offset_y - + ((rows as i16 * CELL - SIDE_H) / 2).max(0); - - let left_x = GAP; - let right_x = width - SIDE_W - GAP; - - let mut snake = [0u16; MAX]; - let mut length = 4usize; - let mut direction = 1usize; - let mut score = 0u32; - let mut last_move = api.now(); - let mut game_over = false; - - let start_x = cols / 2; - let start_y = rows / 2; - - for i in 0..length { - snake[i] = - (start_y * cols + start_x - i) as u16; - } - - let mut food = - (start_y.saturating_sub(3) * cols + start_x) as u16; - - loop { - // Чёрный фон - api.rect( - 0, - 0, - api.width, - api.height, - BG_COLOR, - ); - - // Заголовок и счёт - api.text(8, 5, "SNAKE", WHITE); - - let mut score_buf = [0u8; 10]; - let mut n = score; - let mut pos = 10; - - if n == 0 { - pos -= 1; - score_buf[pos] = b'0'; - } else { - while n > 0 && pos > 0 { - pos -= 1; - score_buf[pos] = b'0' + (n % 10) as u8; - n /= 10; - } - } - - let score_text = - core::str::from_utf8(&score_buf[pos..]) - .unwrap_or("0"); - - api.text(8, 23, "SCORE:", WHITE); - api.text(64, 23, score_text, HEAD_COLOR); - - // Серые клетки игрового поля - draw_grid( - api, - offset_x, - offset_y, - cols, - rows, - ); - - // Змейка - for i in 0..length { - let x = snake[i] as usize % cols; - let y = snake[i] as usize / cols; - - api.rect( - offset_x + x as i16 * CELL + 1, - offset_y + y as i16 * CELL + 1, - (CELL - 2) as u16, - (CELL - 2) as u16, - if i == 0 { - HEAD_COLOR - } else { - SNAKE_COLOR - }, - ); - } - - // Красная еда - let fx = food as usize % cols; - let fy = food as usize / cols; - - api.rect( - offset_x + fx as i16 * CELL + 1, - offset_y + fy as i16 * CELL + 1, - (CELL - 2) as u16, - (CELL - 2) as u16, - FOOD_COLOR, - ); - - // Четыре независимые кнопки - draw_button( - api, - up_x, - up_y, - TOP_W, - TOP_H, - 0, - ); - - draw_button( - api, - left_x, - side_y, - SIDE_W, - SIDE_H, - 3, - ); - - draw_button( - api, - right_x, - side_y, - SIDE_W, - SIDE_H, - 1, - ); - - draw_button( - api, - down_x, - down_y, - TOP_W, - TOP_H, - 2, - ); - - if game_over { - api.text( - 8, - height / 2, - "GAME OVER", - FOOD_COLOR, - ); - - api.text( - 8, - height / 2 + 20, - "CROWN TO RESTART", - WHITE, - ); - } - - api.show(); - - // События и управление - if let Some(event) = api.event(30) { - match event.kind { - BUTTON => return 0, - - CROWN => { - if game_over { - length = 4; - score = 0; - direction = 1; - game_over = false; - - for i in 0..length { - snake[i] = - (start_y * cols + start_x - i) as u16; - } - - food = - (start_y.saturating_sub(3) * cols - + start_x) as u16; - - last_move = api.now(); - } else { - let turn = - if event.delta > 0 { 1 } else { 3 }; - - direction = (direction + turn) % 4; - } - } - - TOUCH_DOWN => { - if !game_over { - let x = event.x; - let y = event.y; - - let new_direction = - if inside( - x, y, - up_x, up_y, - TOP_W, TOP_H, - ) { - Some(0) - } else if inside( - x, y, - right_x, side_y, - SIDE_W, SIDE_H, - ) { - Some(1) - } else if inside( - x, y, - down_x, down_y, - TOP_W, TOP_H, - ) { - Some(2) - } else if inside( - x, y, - left_x, side_y, - SIDE_W, SIDE_H, - ) { - Some(3) - } else { - None - }; - - if let Some(new_direction) = new_direction { - if (new_direction + 2) % 4 != direction { - direction = new_direction; - } - } - } - } - - _ => {} - } - } - - // Движение змейки - if !game_over - && api.now().wrapping_sub(last_move) >= 150 - { - last_move = api.now(); - - let head = snake[0] as usize; - let x = head % cols; - let y = head / cols; - - let (nx, ny) = match direction { - 0 => ( - x, - if y == 0 { rows - 1 } else { y - 1 }, - ), - 1 => ((x + 1) % cols, y), - 2 => (x, (y + 1) % rows), - _ => ( - if x == 0 { cols - 1 } else { x - 1 }, - y, - ), - }; - - let next = (ny * cols + nx) as u16; - let eating = next == food; - - let check_length = - if eating { length } else { length - 1 }; - - let mut collision = false; - - for i in 0..check_length { - if snake[i] == next { - collision = true; - break; - } - } - - if collision { - game_over = true; - } else { - if eating && length < MAX { - length += 1; - score += 1; - } - - for i in (1..length).rev() { - snake[i] = snake[i - 1]; - } - - snake[0] = next; - - if eating { - let mut candidate = - api.now() as usize % (cols * rows); - - for _ in 0..cols * rows { - let occupied = snake[..length] - .iter() - .any(|&part| part as usize == candidate); - - if !occupied { - food = candidate as u16; - break; - } - - candidate = - (candidate + 1) % (cols * rows); - } - } - } - } - } -} diff --git a/apps/snake/src/main.rs b/apps/snake/src/main.rs deleted file mode 100644 index 5744e68..0000000 --- a/apps/snake/src/main.rs +++ /dev/null @@ -1,7 +0,0 @@ -#![cfg_attr(any(target_os = "none", wp2_sim), no_main, cfg_attr(target_os = "none", no_std))] - -#[cfg(not(any(target_os = "none", wp2_sim)))] -fn main() {} - -#[cfg(any(target_os = "none", wp2_sim))] -mod game; diff --git a/apps/snake/store.md b/apps/snake/store.md deleted file mode 100644 index 77750a9..0000000 --- a/apps/snake/store.md +++ /dev/null @@ -1,11 +0,0 @@ -A classic Snake game for CMF Watch Pro 2. - -- Turn the crown to steer the snake. -- Eat food to grow and increase your score. -- Avoid hitting walls and yourself. -- Press the button to exit. -- Turn the crown after game over to restart. - -## Requirements - -The [patched firmware](/firmware) and the [App Loader](/firmware). diff --git a/apps/snake/store.toml b/apps/snake/store.toml deleted file mode 100644 index a16b621..0000000 --- a/apps/snake/store.toml +++ /dev/null @@ -1,4 +0,0 @@ -name = "Snake" -summary = "Classic Snake game. Eat food, grow and avoid collisions" -version = "0.1.1" -author = "leo1956pard" diff --git a/apps/storage/Cargo.toml b/apps/storage/Cargo.toml deleted file mode 100644 index 2c28d66..0000000 --- a/apps/storage/Cargo.toml +++ /dev/null @@ -1,15 +0,0 @@ -[package] -name = "storage" -edition.workspace = true -license.workspace = true -version.workspace = true - -[dependencies] -cmf-wp2-app.workspace = true - -[dev-dependencies] -wp2-core.workspace = true - -[[bin]] -name = "storage" -bench = false diff --git a/apps/storage/LICENSE-Material-Symbols.txt b/apps/storage/LICENSE-Material-Symbols.txt deleted file mode 100644 index 7a4a3ea..0000000 --- a/apps/storage/LICENSE-Material-Symbols.txt +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. \ No newline at end of file diff --git a/apps/storage/THIRD-PARTY-NOTICES.md b/apps/storage/THIRD-PARTY-NOTICES.md deleted file mode 100644 index f0e1c22..0000000 --- a/apps/storage/THIRD-PARTY-NOTICES.md +++ /dev/null @@ -1,7 +0,0 @@ -# Third-party artwork - -The Storage launcher icon uses Google's Material Symbols `donut_large`, Rounded, unfilled, 24px variant. It is adapted with watch-native sizing, a circular charcoal plate and an orange upper-right segment. - -Source: https://github.com/google/material-design-icons/blob/master/symbols/web/donut_large/materialsymbolsrounded/donut_large_24px.svg - -Copyright Google LLC. Licensed under the Apache License, Version 2.0. The complete license is in `LICENSE-Material-Symbols.txt`. diff --git a/apps/storage/icon.svg b/apps/storage/icon.svg deleted file mode 100644 index 36d5af8..0000000 --- a/apps/storage/icon.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/apps/storage/shots/apps-more.png b/apps/storage/shots/apps-more.png deleted file mode 100644 index 386a8e5..0000000 Binary files a/apps/storage/shots/apps-more.png and /dev/null differ diff --git a/apps/storage/shots/apps.png b/apps/storage/shots/apps.png deleted file mode 100644 index 9fbc299..0000000 Binary files a/apps/storage/shots/apps.png and /dev/null differ diff --git a/apps/storage/shots/overview.png b/apps/storage/shots/overview.png deleted file mode 100644 index 9b0b7d2..0000000 Binary files a/apps/storage/shots/overview.png and /dev/null differ diff --git a/apps/storage/shots/system.png b/apps/storage/shots/system.png deleted file mode 100644 index 01c2ec8..0000000 Binary files a/apps/storage/shots/system.png and /dev/null differ diff --git a/apps/storage/shots/usage.png b/apps/storage/shots/usage.png deleted file mode 100644 index e3c5cf9..0000000 Binary files a/apps/storage/shots/usage.png and /dev/null differ diff --git a/apps/storage/shots/watchfaces.png b/apps/storage/shots/watchfaces.png deleted file mode 100644 index 9e3709e..0000000 Binary files a/apps/storage/shots/watchfaces.png and /dev/null differ diff --git a/apps/storage/src/inventory.rs b/apps/storage/src/inventory.rs deleted file mode 100644 index e0df992..0000000 --- a/apps/storage/src/inventory.rs +++ /dev/null @@ -1,263 +0,0 @@ -//! File lengths are logical bytes, never inferred allocation-chain lengths. -use cmf_wp2_app::storage::Storage; -#[derive(Clone, Copy, Default, PartialEq, Debug)] -pub enum Category { - App(u8), - Loader, - Face, - #[default] - Other, -} -#[derive(Clone, Copy)] -pub struct File { - pub path: [u8; 96], - pub size: u32, - pub category: Category, -} -pub const EMPTY_FILE: File = File { - path: [0; 96], - size: 0, - category: Category::Other, -}; -impl File { - pub fn path(&self) -> &str { - let n = self.path.iter().position(|&b| b == 0).unwrap_or(96); - core::str::from_utf8(&self.path[..n]).unwrap_or("Invalid filename") - } - pub fn name(&self) -> &str { - self.path().rsplit('/').next().unwrap_or(self.path()) - } -} -#[derive(Clone, Copy)] -pub struct App { - pub name: [u8; 24], - pub version: u32, - pub valid: bool, - pub icon: bool, -} -impl App { - pub fn name(&self) -> &str { - let n = self.name.iter().position(|&b| b == 0).unwrap_or(24); - core::str::from_utf8(&self.name[..n]).unwrap_or("Unknown app") - } -} -const EMPTY_APP: App = App { - name: [0; 24], - version: 0, - valid: false, - icon: false, -}; -#[derive(Clone, Copy)] -pub struct Inventory { - pub files: [File; 96], - pub count: usize, - pub apps: [App; 16], - pub ready: bool, - pub partial: bool, - pub error: i32, -} -impl Inventory { - pub const fn new() -> Self { - Self { - files: [EMPTY_FILE; 96], - count: 0, - apps: [EMPTY_APP; 16], - ready: false, - partial: false, - error: 0, - } - } - #[inline(never)] - pub fn reset(&mut self) { - self.count = 0; - self.ready = false; - self.partial = false; - self.error = 0; - for a in &mut self.apps { - a.valid = false; - } - } - #[inline(never)] - pub fn copy_from(&mut self, other: &Self) { - unsafe { - core::ptr::copy_nonoverlapping(other, self, 1); - } - } - pub fn load_file(&mut self, s: &Storage<'_>, i: usize) -> Result<(), i32> { - let entry = s.file(i as u16)?; - let mut f = File { - path: entry.path, - size: entry.size, - category: Category::Other, - }; - f.category = classify(f.path()); - self.files[i] = f; - self.count = i + 1; - Ok(()) - } - pub fn load_apps(&mut self, s: &Storage<'_>) { - let slots = match s.capabilities() { - Ok(c) => { - if c.app_slots > 16 { - self.partial = true; - } - c.app_slots.min(16) - } - Err(e) => { - self.error = e; - self.partial = true; - return; - } - }; - for i in 0..slots { - let mut a = EMPTY_APP; - match s.installed_app(i) { - Ok(Some(info)) => { - a.valid = true; - a.icon = info.has_icon; - a.version = info.version; - a.name = info.name; - } - Ok(None) => {} - Err(e) => { - self.error = e; - self.partial = true; - } - } - self.apps[i as usize] = a; - } - } - pub fn sum(&self, cat: Category) -> u32 { - self.files[..self.count] - .iter() - .filter(|f| same_group(f.category, cat)) - .fold(0u32, |a, f| a.saturating_add(f.size)) - } - pub fn app_total(&self, slot: u8) -> u32 { - self.files[..self.count] - .iter() - .filter(|f| f.category == Category::App(slot)) - .fold(0u32, |a, f| a.saturating_add(f.size)) - } - pub fn all_bytes(&self) -> u32 { - self.files[..self.count] - .iter() - .fold(0u32, |a, f| a.saturating_add(f.size)) - } -} -pub fn same_group(a: Category, b: Category) -> bool { - match (a, b) { - (Category::App(_), Category::App(_)) => true, - _ => a == b, - } -} -pub fn classify(path: &str) -> Category { - if let Some((dir, name)) = path.rsplit_once('/') { - if dir.eq_ignore_ascii_case("/NAND:/WP2APPS") { - if name.eq_ignore_ascii_case("L.PKG") { - return Category::Loader; - } - let b = name.as_bytes(); - let slot = match b.first().copied() { - Some(c @ b'0'..=b'9') => Some(c - b'0'), - Some(c @ b'A'..=b'F') => Some(c - b'A' + 10), - Some(c @ b'a'..=b'f') => Some(c - b'a' + 10), - _ => None, - }; - if b.len() == 5 - && b[1] == b'.' - && slot.is_some() - && [b"PKG", b"DAT", b"WGT", b"PSH"] - .iter() - .any(|e| b[2..].eq_ignore_ascii_case(*e)) - { - return Category::App(slot.unwrap()); - } - } - } - if path - .rsplit('.') - .next() - .is_some_and(|e| e.eq_ignore_ascii_case("wfc")) - { - Category::Face - } else { - Category::Other - } -} -#[cfg(test)] -mod tests { - use super::*; - #[test] - fn groups_only_sdk_owned_paths() { - assert_eq!(classify("/NAND:/wp2apps/0.pkg"), Category::App(0)); - assert_eq!(classify("/NAND:/wp2apps/7.DAT"), Category::App(7)); - assert_eq!(classify("/NAND:/0.pkg"), Category::Other); - assert_eq!(classify("/NAND:/wp2apps/8.pkg"), Category::App(8)); - assert_eq!(classify("/NAND:/wp2apps/F.psh"), Category::App(15)); - assert_eq!(classify("/NAND:/wp2apps/G.pkg"), Category::Other); - assert_eq!(classify("/NAND:/wp2apps/0.tmp"), Category::Other); - assert_eq!(classify("/NAND:/wp2apps/L.PKG"), Category::Loader); - } - #[test] - fn face_extension_is_a_file_category() { - assert_eq!(classify("/NAND:/foo.WFC"), Category::Face); - assert_eq!(classify("/NAND:/a.wfc.tmp"), Category::Other); - } -} - -/// Logical file groups plus the remaining measured allocation. Never imply per-file cluster-chain accounting. -pub fn breakdown(fs: &cmf_wp2_app::storage::Filesystem, inv: &Inventory) -> Option<[u32; 4]> { - if !inv.ready || inv.partial { - return None; - } - let used = fs.total.checked_sub(fs.free)?; - if inv.all_bytes() > used { - return None; - } - let apps = inv.sum(Category::App(0)); - let faces = inv.sum(Category::Face); - let loader = inv.sum(Category::Loader); - Some([ - apps, - loader, - faces, - used.checked_sub(apps)? - .checked_sub(faces)? - .checked_sub(loader)?, - ]) -} - -#[cfg(test)] -mod breakdown_tests { - use super::*; - #[test] - fn allocation_remainder_is_explicit_and_inconsistent_scans_are_hidden() { - let mut inv = Inventory::new(); - inv.ready = true; - inv.count = 4; - for (i, (category, size)) in [ - (Category::App(0), 20), - (Category::Face, 10), - (Category::Loader, 30), - (Category::Other, 5), - ] - .into_iter() - .enumerate() - { - inv.files[i].category = category; - inv.files[i].size = size; - } - let mut fs = cmf_wp2_app::storage::Filesystem { - total: 200, - free: 100, - ..Default::default() - }; - assert_eq!(breakdown(&fs, &inv), Some([20, 30, 10, 40])); - inv.partial = true; - assert_eq!(breakdown(&fs, &inv), None); - inv.partial = false; - fs.free = 190; - assert_eq!(breakdown(&fs, &inv), None); - } -} diff --git a/apps/storage/src/main.rs b/apps/storage/src/main.rs deleted file mode 100644 index 9b26515..0000000 --- a/apps/storage/src/main.rs +++ /dev/null @@ -1,335 +0,0 @@ -#![cfg_attr(target_os = "none", no_std, no_main)] -mod inventory; -#[cfg_attr(not(target_os = "none"), allow(dead_code))] -mod model; -#[cfg(any(target_os = "none", test))] -mod ui; -#[cfg(test)] -mod ui_tests; -#[cfg(not(target_os = "none"))] -fn main() {} -#[cfg(target_os = "none")] -mod device { - use crate::{model, ui}; - use cmf_wp2_app::{ - Api, BUTTON, PAUSE, RESUME, - lv::*, - stock, - storage::{Filesystem, Partition, Storage}, - }; - cmf_wp2_app::entry!(main); - cmf_wp2_app::app_icon!(); - #[unsafe(no_mangle)] - static mut STORAGE_STATS: [i32; 12] = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; - #[unsafe(no_mangle)] - static mut STORAGE_UI: [i32; 3] = [0, 0, 0]; // detail, pager page, last UI error - static mut PARTS: [Partition; 30] = [Partition { - name: [0; 8], - kind: 0, - file_id: 0, - device: 0, - mirror: 0, - offset: 0, - allocated: 0, - }; 30]; - fn stat(i: usize, v: i32) { - unsafe { (&raw mut STORAGE_STATS[i]).write_volatile(v) } - } - fn state(detail: u8, at: usize, error: i32) { - unsafe { (&raw mut STORAGE_UI).write_volatile([detail as i32, at as i32, error]) } - } - fn refresh(s: &Storage<'_>) -> Option { - match s.filesystem() { - Ok(f) if model::valid_filesystem(&f) => { - for (i, v) in [ - f.total, - f.free, - f.apps, - f.app_data, - f.widgets, - f.loader, - f.installed_apps, - f.allocation_unit, - ] - .into_iter() - .enumerate() - { - stat(i + 3, v as i32) - } - stat(11, 0); - Some(f) - } - Ok(_) => { - stat(11, -11); - None - } - Err(e) => { - stat(11, e); - None - } - } - } - - #[inline(never)] - fn run(api: &'static Api, b: &mut Batch, lv: &Lv) -> Result<(), LvError> { - use crate::inventory::Inventory; - use ui::Page; - stock::font(b)?; - b.font(1, StockFont::F24M)?; - b.font(2, StockFont::F48M)?; - b.font(3, StockFont::F36M)?; - b.submit(lv)?; - let storage = Storage::open(api); - let mut n = 0; - let mut fs = None; - let mut error = 0; - if let Ok(s) = &storage { - match s.partition_count() { - Ok(count) => { - for i in 0..count.min(30) { - match s.partition(i) { - Ok(p) => { - unsafe { - PARTS[i as usize] = p; - } - n = i as usize + 1; - } - Err(e) => { - error = e; - break; - } - } - } - } - Err(e) => error = e, - } - fs = refresh(s); - } else if let Err(e) = &storage { - error = *e; - } - stat(1, error); - stat(2, n as i32); - let parts = unsafe { &(&raw const PARTS).as_ref().unwrap()[..n] }; - static mut INVENTORY: Inventory = Inventory::new(); - static mut NEXT: Inventory = Inventory::new(); - let inv = unsafe { &mut *core::ptr::addr_of_mut!(INVENTORY) }; - let next = unsafe { &mut *core::ptr::addr_of_mut!(NEXT) }; - if error < 0 { - inv.error = error; - } - let mut reading = false; - let mut scan_count = None; - let mut read_at = 0usize; - let mut stale = false; - if let Ok(s) = &storage { - reading = s.begin_scan().is_ok(); - if !reading { - inv.error = -95; - inv.partial = true; - } - } - let mut views: [Option; 4] = [None, None, None, None]; - let mut depth = 0usize; - views[0] = Some(ui::render( - b, - lv, - Page::Home, - parts, - fs, - inv, - reading, - stale, - )?); - stat(0, 0); - api.own_back(true); - let mut paused = false; - loop { - let e = api.event(if reading && !paused { 16 } else { u32::MAX }); - if let Some(e) = e { - if e.kind == PAUSE { - paused = true; - continue; - } - if e.kind == RESUME { - paused = false; - continue; - } - if paused { - continue; - } - let action = if e.kind == BUTTON { - ui::BACK - } else { - views[depth].as_ref().unwrap().action(&e) - }; - if action == ui::BACK { - if depth == 0 { - break; - } - let old = views[depth].take().unwrap(); - b.del(old.root)?; - depth -= 1; - if !views[depth].as_ref().unwrap().complete && inv.ready { - let previous = views[depth].take().unwrap(); - let page = previous.page; - b.del(previous.root)?; - b.submit(lv)?; - views[depth] = - Some(ui::render(b, lv, page, parts, fs, inv, reading, stale)?); - } else { - views[depth].as_ref().unwrap().visible(b, true)?; - b.submit(lv)?; - } - state(depth as u8, 0, 0); - continue; - } - if action == ui::REFRESH { - if let Ok(s) = &storage { - if reading { - s.cancel_scan().ok(); - reading = false; - if inv.ready { - stale = true; - } else { - inv.partial = true; - inv.error = -125; - } - } else { - let fresh = refresh(s); - stale = fresh.is_none(); - if fresh.is_some() { - fs = fresh; - } - next.reset(); - reading = s.begin_scan().is_ok(); - scan_count = None; - read_at = 0; - } - } - let old = views[depth].take().unwrap(); - b.del(old.root)?; - b.submit(lv)?; - views[depth] = Some(ui::render( - b, - lv, - Page::Home, - parts, - fs, - inv, - reading, - stale, - )?); - continue; - } - let mut replace = false; - let page = match action { - 1 => Some(Page::Apps), - 2 => Some(Page::Faces(0)), - 3 => Some(Page::Other(0)), - 4 => Some(Page::System), - 5 => Some(Page::Nand), - 6 => Some(Page::Nor), - 8 => Some(Page::Accounting), - 16..=31 => Some(Page::App((action - 16) as u8)), - 32..=127 => Some(Page::File((action - 32) as u8)), - 128..=157 => Some(Page::Partition((action - 128) as u8)), - 200 | 201 => { - replace = true; - let delta = if action == 200 { 1 } else { -1 }; - match views[depth].as_ref().unwrap().page { - Page::Faces(i) => Some(Page::Faces((i as i16 + delta).max(0) as u8)), - Page::Other(i) => Some(Page::Other((i as i16 + delta).max(0) as u8)), - _ => None, - } - } - _ => None, - }; - if let Some(page) = page { - if replace { - let old = views[depth].take().unwrap(); - b.del(old.root)?; - b.submit(lv)?; - } else if depth < 3 { - views[depth].as_ref().unwrap().visible(b, false)?; - b.submit(lv)?; - depth += 1; - } else { - continue; - } - views[depth] = Some(ui::render(b, lv, page, parts, fs, inv, reading, stale)?); - state(depth as u8, action as usize, 0); - } - } - if reading && !paused { - if let Ok(s) = &storage { - if scan_count.is_none() { - match s.scan_step() { - Ok(v) if v.complete => { - scan_count = Some((v.files as usize).min(next.files.len())); - next.partial = v.partial || (v.files as usize)>next.files.len(); - next.error = v.error; - } - Ok(_) => {} - Err(e) => { - next.error = e; - next.partial = true; - scan_count = Some(0); - } - } - } else if read_at < scan_count.unwrap() { - if let Err(e) = next.load_file(s, read_at) { - next.error = e; - next.partial = true; - scan_count = Some(read_at); - } else { - read_at += 1; - } - } else { - next.load_apps(s); - next.ready = true; - s.cancel_scan().ok(); - if next.error < 0 && inv.ready { - stale = true; - } else { - inv.copy_from(next); - } - reading = false; - // Update the visible screen. Hidden parent pages keep their scroll position. - let page = views[depth].as_ref().unwrap().page; - let old = views[depth].take().unwrap(); - b.del(old.root)?; - b.submit(lv)?; - views[depth] = Some(ui::render(b, lv, page, parts, fs, inv, false, stale)?); - stat(0, 0); - } - } else { - reading = false; - } - } - } - if let Ok(s) = &storage { - s.cancel_scan().ok(); - } - Ok(()) - } - fn main(api: &'static Api) -> i32 { - let Some(lv) = api.lv() else { return -95 }; - let Some(mut b) = Batch::new() else { - return -12; - }; - let result = run(api, &mut b, &lv); - api.own_back(false); - match result { - Ok(()) => 0, - Err(e) => { - let code = match e { - LvError::Code(code) => code, - LvError::Full => -7, - LvError::Budget => -12, - }; - state(0, 0, code); - code - } - } - } -} diff --git a/apps/storage/src/model.rs b/apps/storage/src/model.rs deleted file mode 100644 index d98f864..0000000 --- a/apps/storage/src/model.rs +++ /dev/null @@ -1,641 +0,0 @@ -use cmf_wp2_app::storage::{Filesystem, Partition}; -use core::fmt::{self, Write}; - -pub struct Text { - buf: [u8; 64], - len: usize, -} -impl Text { - pub fn new() -> Self { - Self { - buf: [0; 64], - len: 0, - } - } - pub fn as_str(&self) -> &str { - core::str::from_utf8(&self.buf[..self.len]).unwrap_or("?") - } - pub fn bytes(n: u32) -> Self { - let mut s = Self::new(); - if n >= 1048576 && n % 1048576 == 0 { - let _ = write!(s, "{} MiB", n / 1048576); - } else if n >= 1048576 { - let _ = write!( - s, - "{}.{:02} MiB", - n / 1048576, - (u64::from(n % 1048576) * 100 / 1048576) - ); - } else if n >= 1024 { - if n % 1024 == 0 { - let _ = write!(s, "{} KiB", n / 1024); - } else { - let _ = write!(s, "{}.{:02} KiB", n / 1024, (n % 1024) * 100 / 1024); - } - } else { - let _ = write!(s, "{} B", n); - } - s - } -} -impl Write for Text { - fn write_str(&mut self, s: &str) -> fmt::Result { - if self.len + s.len() > self.buf.len() { - return Err(fmt::Error); - } - self.buf[self.len..self.len + s.len()].copy_from_slice(s.as_bytes()); - self.len += s.len(); - Ok(()) - } -} -pub fn total(parts: &[Partition], device: u8) -> Option { - let mut total = 0u32; - for (i, p) in parts.iter().enumerate().filter(|(_, p)| p.device == device) { - let end = p.offset.checked_add(p.allocated)?; - for q in &parts[..i] { - if q.device == device && p.offset < q.offset.checked_add(q.allocated)? && q.offset < end - { - return None; - } - } - total = total.checked_add(p.allocated)?; - } - Some(total) -} -pub fn other(fs: &Filesystem) -> Option { - fs.total - .checked_sub(fs.free)? - .checked_sub(fs.apps)? - .checked_sub(fs.app_data)? - .checked_sub(fs.widgets)? - .checked_sub(fs.loader) -} -pub fn percent(used: u32, total: u32) -> i16 { - if total == 0 { - 0 - } else { - (u64::from(used).min(total as u64) * 100 / total as u64) as i16 - } -} - -#[derive(Clone, Copy, Default, Debug, PartialEq, Eq)] -pub struct Rect { - pub x: i16, - pub y: i16, - pub w: i16, - pub h: i16, -} -impl Rect { - pub const fn new(x: i16, y: i16, w: i16, h: i16) -> Self { - Self { x, y, w, h } - } - pub fn in_round_screen(self, margin: i32) -> bool { - let r = 233 - margin; - [self.x as i32, self.x as i32 + self.w as i32] - .into_iter() - .all(|x| { - [self.y as i32, self.y as i32 + self.h as i32] - .into_iter() - .all(|y| (x - 233) * (x - 233) + (y - 233) * (y - 233) <= r * r) - }) - } -} -pub const TITLE: Rect = Rect::new(113, 46, 240, 42); -pub const MAP: Rect = Rect::new(78, 142, 310, 174); -pub const BOTTOM: Rect = Rect::new(128, 376, 210, 52); -pub const CATEGORY_NAMES: [&str; 4] = ["Apps", "Saved data", "App loader", "Other + allocation"]; -pub fn used_categories(f: &Filesystem) -> Option<[u32; 4]> { - Some([ - f.apps, - f.app_data.checked_add(f.widgets)?, - f.loader, - other(f)?, - ]) -} -/// Binary treemap. Preserve proportions; tiny categories are selected in the details list. -pub fn treemap(values: [u32; 4], bounds: Rect) -> [Rect; 4] { - fn split(items: &[(usize, u32)], r: Rect, out: &mut [Rect; 4]) { - if items.is_empty() { - return; - } - if items.len() == 1 { - out[items[0].0] = r; - return; - } - let total: u64 = items.iter().map(|i| i.1 as u64).sum(); - let mut left = 0u64; - let mut cut = 1; - let mut best = u64::MAX; - for i in 1..items.len() { - left += items[i - 1].1 as u64; - let distance = (2 * left).abs_diff(total); - if distance < best { - best = distance; - cut = i; - } - } - let part: u64 = items[..cut].iter().map(|i| i.1 as u64).sum(); - let mut a = r; - let mut b = r; - if r.w >= r.h { - a.w = (r.w as u64 * part / total) as i16; - b.x += a.w; - b.w -= a.w; - } else { - a.h = (r.h as u64 * part / total) as i16; - b.y += a.h; - b.h -= a.h; - } - split(&items[..cut], a, out); - split(&items[cut..], b, out); - } - let mut items = [(0usize, 0u32); 4]; - let mut n = 0; - for (i, v) in values.into_iter().enumerate() { - if v > 0 { - items[n] = (i, v); - n += 1; - } - } - items[..n].sort_unstable_by(|a, b| b.1.cmp(&a.1).then(a.0.cmp(&b.0))); - let mut out = [Rect::default(); 4]; - split(&items[..n], bounds, &mut out); - out -} -/// Exclusive allocation categories: firmware/boot, resources, writable files, reserved/settings/other. -pub fn allocation_groups(parts: &[Partition]) -> Option<[u32; 4]> { - let mut out = [0u32; 4]; - for p in parts { - let i = match p.file_id { - 1..=5 => 0, - 10..=39 => 1, - 40 => 2, - _ => 3, - }; - out[i] = out[i].checked_add(p.allocated)?; - } - for dev in 0..16 { - total(parts, dev)?; - } - Some(out) -} -pub fn widths(values: &[u32], width: u32) -> [u32; 5] { - let mut out = [0; 5]; - let total: u64 = values.iter().map(|&x| u64::from(x)).sum(); - if total == 0 { - return out; - } - let mut sum = 0u64; - let mut previous = 0; - for (i, &v) in values.iter().take(5).enumerate() { - sum += u64::from(v); - let end = (sum * u64::from(width) / total) as u32; - out[i] = end - previous; - previous = end; - } - out -} -/// Reserve separators only for segments that are visible at the current pixel width. -pub fn separated_widths(values: &[u32], width: u32) -> [u32; 5] { - // Pick visible segments once, then remove only segments that cannot retain a pixel after reserving gaps. - // Removed segments never reappear, so tiny values cannot oscillate at a separator boundary. - let initial = widths(values, width); - let mut filtered = [0u32; 5]; - for i in 0..values.len().min(5) { - if initial[i] > 0 { - filtered[i] = values[i]; - } - } - for _ in 0..5 { - let n = filtered.iter().filter(|&&v| v > 0).count(); - let out = widths( - &filtered, - width.saturating_sub(n.saturating_sub(1) as u32 * 2), - ); - if out.iter().all(|&v| v == 0) && filtered.iter().any(|&v| v > 0) { - let best = (0..5).max_by_key(|&i| filtered[i]).unwrap(); - let v = filtered[best]; - filtered = [0; 5]; - filtered[best] = v; - continue; - } - let mut removed = false; - for i in 0..5 { - if filtered[i] > 0 && out[i] == 0 { - filtered[i] = 0; - removed = true; - } - } - if !removed { - return out; - } - } - widths(&filtered, width) -} -#[cfg(test)] -mod separator_tests { - use super::*; - #[test] - fn separators_fill_requested_bounds() { - for v in [ - [20, 30, 10, 40, 900], - [1, 0, 0, 0, 999999], - [10, 10, 10, 10, 0], - [0; 5], - [1, 373, 0, 0, 0], - ] { - let w = separated_widths(&v, 374); - let n = w.iter().filter(|&&x| x > 0).count(); - assert_eq!( - w.iter().sum::() + n.saturating_sub(1) as u32 * 2, - if n > 0 { 374 } else { 0 } - ); - } - } -} -pub fn purpose(p: &Partition) -> &'static str { - match p.file_id { - 1 => "Bootloader", - 2 => "Partition table", - 3 => "Recovery", - 4 => "Firmware", - 5 => "System files", - 6..=8 => "Settings", - 12 | 13 => "Fonts / watch faces", - 10 | 11 => "UI resources", - 14 => "Exercise animations", - 20 => "Boot / sound assets", - 40 => "Writable files", - 248 => "Reserved", - 249 => "Settings / history", - 250 | 251 => "Logs", - 253 => "Crash records", - 254 => "OTA staging", - _ => "Other allocation", - } -} - -pub const NAND_MAIN: u32 = 128 * 1048576; -pub const NAND_LOGICAL: u32 = 123 * 1048576; -pub const NOR_MAIN: u32 = 4 * 1048576; -pub const FTL_MANAGEMENT: u32 = 5 * 1048576; -pub const LOGICAL_TAIL: u32 = 11010048; -const VERIFIED_LAYOUT: &[(u8, u8, u32, u32)] = &[ - (0, 1, 0x00000000, 4096), - (0, 2, 0x00001000, 4096), - (0, 1, 0x00002000, 4096), - (0, 2, 0x00003000, 4096), - (0, 3, 0x00004000, 131072), - (0, 4, 0x00024000, 3452928), - (0, 248, 0x0036f000, 409600), - (0, 5, 0x003d3000, 65536), - (0, 6, 0x003e3000, 4096), - (0, 7, 0x003e4000, 8192), - (0, 8, 0x003e6000, 8192), - (0, 251, 0x003e8000, 16384), - (2, 249, 0x00480000, 2097152), - (0, 253, 0x003ec000, 81920), - (2, 10, 0x01280000, 10485760), - (2, 12, 0x00680000, 12582912), - (2, 11, 0x01c80000, 8388608), - (2, 14, 0x02480000, 67108864), - (2, 20, 0x00380000, 1048576), - (2, 254, 0x00000000, 3670016), - (2, 250, 0x06480000, 2097152), - (2, 40, 0x06680000, 10485760), -]; -pub fn reference_layout(parts: &[Partition]) -> bool { - parts.len() == VERIFIED_LAYOUT.len() - && VERIFIED_LAYOUT - .iter() - .all(|&(device, id, offset, allocated)| { - parts - .iter() - .filter(|p| { - p.device == device - && p.file_id == id - && p.offset == offset - && p.allocated == allocated - }) - .count() - == 1 - }) -} -pub fn valid_filesystem(f: &Filesystem) -> bool { - f.total > 0 - && f.allocation_unit.is_power_of_two() - && f.total % f.allocation_unit == 0 - && f.free % f.allocation_unit == 0 - && other(f).is_some() -} - -#[cfg(test)] -mod tests { - use super::*; - #[test] - fn verified_reference_requires_exact_device_layout() { - let mut parts: [Partition; 22] = [Partition::default(); 22]; - for (p, &(device, file_id, offset, allocated)) in parts.iter_mut().zip(VERIFIED_LAYOUT) { - *p = Partition { - device, - file_id, - offset, - allocated, - ..Default::default() - }; - } - assert!(reference_layout(&parts)); - assert_eq!(total(&parts, 2), Some(1125 * 1048576 / 10)); - assert_eq!(total(&parts, 0), Some(NOR_MAIN)); - assert_eq!(NAND_LOGICAL - total(&parts, 2).unwrap(), LOGICAL_TAIL); - assert_eq!(NAND_MAIN - NAND_LOGICAL, FTL_MANAGEMENT); - parts[0].allocated += 1; - assert!(!reference_layout(&parts)); - } - #[test] - fn invalid_live_counters_are_not_presented_as_usage() { - assert!(!valid_filesystem(&Filesystem::default())); - assert!(!valid_filesystem(&Filesystem { - total: 1024, - free: 2048, - allocation_unit: 1024, - ..Default::default() - })); - assert!(valid_filesystem(&Filesystem { - total: 10240, - free: 8192, - apps: 1024, - allocation_unit: 1024, - ..Default::default() - })); - } - #[test] - fn units() { - assert_eq!(Text::bytes(1048576).as_str(), "1 MiB"); - assert_eq!(Text::bytes(0).as_str(), "0 B"); - } - #[test] - fn never_double_counts_overlaps() { - let a = Partition { - device: 2, - offset: 0, - allocated: 100, - ..Default::default() - }; - assert_eq!(total(&[a, a], 2), None); - assert_eq!(total(&[a, Partition { offset: 100, ..a }], 2), Some(200)); - } - #[test] - fn inconsistent_live_snapshot_is_unknown() { - assert_eq!( - other(&Filesystem { - total: 10, - free: 11, - ..Default::default() - }), - None - ); - } - #[test] - fn bar_is_bounded() { - assert_eq!(percent(u32::MAX, u32::MAX), 100); - assert_eq!(percent(3, 0), 0); - } - #[test] - fn segments_cover_exact_width() { - assert_eq!(widths(&[1, 1, 1], 370).iter().sum::(), 370); - assert_eq!(widths(&[0, 0], 370), [0; 5]); - } - #[test] - fn fixed_controls_fit_the_round_safe_area() { - for r in [ - TITLE, - MAP, - BOTTOM, - Rect::new(123, 376, 104, 52), - Rect::new(239, 376, 104, 52), - Rect::new(63, 332, 340, 34), - Rect::new(68, 136, 330, 86), - Rect::new(68, 234, 330, 86), - ] { - assert!(r.in_round_screen(8), "{r:?}"); - } - } - #[test] - fn treemap_covers_area_without_overlaps() { - for values in [ - [17982, 0, 49944, 6802], - [0, 0, 0, 1], - [1, 1, 1, 1], - [u32::MAX, 1, 3, 0], - ] { - let rects = treemap(values, MAP); - assert_eq!( - rects - .iter() - .map(|r| i32::from(r.w) * i32::from(r.h)) - .sum::(), - i32::from(MAP.w) * i32::from(MAP.h) - ); - for (i, a) in rects.iter().enumerate().filter(|(_, r)| r.w > 0 && r.h > 0) { - assert!( - a.x >= MAP.x - && a.y >= MAP.y - && a.x + a.w <= MAP.x + MAP.w - && a.y + a.h <= MAP.y + MAP.h - ); - for b in &rects[..i] { - assert!( - b.w == 0 - || b.h == 0 - || a.x >= b.x + b.w - || b.x >= a.x + a.w - || a.y >= b.y + b.h - || b.y >= a.y + a.h - ); - } - } - } - assert_eq!(treemap([0; 4], MAP), [Rect::default(); 4]); - } -} - -/// Nominal integer glyph advances from the extracted WP2 font48M (hash in design/VISUAL-REVISION.md). -/// Used for the unit's position, not claimed to be a full kerning engine. -pub fn number_width(s: &str) -> i16 { - const DIGITS: [i16; 10] = [31, 19, 29, 30, 31, 29, 30, 27, 30, 30]; - s.bytes() - .map(|b| match b { - b'0'..=b'9' => DIGITS[(b - b'0') as usize], - b'.' => 14, - _ => 24, - }) - .sum() -} - -/// Visible-ink centering for the actual WP2 font32M. Native baseline measured at26px. -/// Nominal ASCII advances/bearings come from the extracted font, not string length. -pub fn button_label_position(text: &str, height: i16) -> (i16, i16) { - const GLYPHS: [(i16, i16, i16, i16, i16); 95] = [ - (8, 0, 0, 0, 0), - (9, 2, 0, 6, 24), - (15, 3, 14, 10, 10), - (20, 0, 0, 20, 24), - (20, 1, -3, 19, 31), - (31, 3, 0, 26, 24), - (20, 1, 0, 20, 24), - (10, 3, 14, 4, 10), - (11, 3, -4, 8, 30), - (11, 1, -4, 8, 30), - (16, 2, 10, 13, 14), - (21, 2, 2, 17, 16), - (9, 1, -6, 7, 10), - (14, 2, 8, 11, 4), - (9, 2, 0, 6, 5), - (11, 0, -4, 12, 29), - (20, 1, 0, 18, 24), - (13, 1, 0, 10, 24), - (19, 2, 0, 16, 24), - (20, 1, 0, 18, 24), - (21, 1, 0, 19, 24), - (19, 2, 0, 17, 24), - (20, 1, 0, 18, 24), - (18, 1, 0, 16, 24), - (20, 1, 0, 18, 24), - (20, 1, 0, 18, 24), - (9, 2, 0, 6, 17), - (10, 1, -6, 7, 23), - (21, 2, 0, 16, 19), - (21, 3, 4, 15, 11), - (21, 3, 0, 16, 19), - (16, 1, 0, 15, 24), - (31, 1, -7, 29, 30), - (22, 0, 0, 22, 24), - (21, 2, 0, 18, 24), - (23, 1, 0, 21, 24), - (23, 2, 0, 20, 24), - (19, 2, 0, 16, 24), - (18, 2, 0, 16, 24), - (23, 1, 0, 22, 24), - (23, 2, 0, 20, 24), - (8, 2, 0, 5, 24), - (18, 1, 0, 15, 24), - (22, 2, 0, 20, 24), - (18, 2, 0, 15, 24), - (29, 2, 0, 25, 24), - (24, 2, 0, 20, 24), - (24, 1, 0, 22, 24), - (20, 2, 0, 17, 24), - (24, 1, -2, 22, 26), - (20, 2, 0, 18, 24), - (20, 1, 0, 19, 24), - (20, 1, 0, 19, 24), - (23, 2, 0, 20, 24), - (22, 0, 0, 22, 24), - (32, 0, 0, 32, 24), - (22, 0, 0, 22, 24), - (22, 0, 0, 22, 24), - (20, 1, 0, 18, 24), - (11, 3, -4, 7, 30), - (11, 0, -4, 12, 29), - (11, 1, -4, 8, 30), - (15, 1, 13, 14, 10), - (14, 0, -3, 15, 3), - (10, 2, 20, 7, 5), - (18, 1, 0, 15, 18), - (19, 2, 0, 17, 24), - (18, 1, 0, 17, 18), - (19, 1, 0, 17, 24), - (18, 1, 0, 17, 18), - (12, 0, 0, 12, 25), - (19, 1, -7, 17, 25), - (19, 2, 0, 15, 24), - (8, 1, 0, 6, 25), - (8, -1, -7, 8, 32), - (17, 2, 0, 16, 24), - (8, 2, 0, 4, 24), - (28, 2, 0, 25, 18), - (19, 2, 0, 15, 18), - (19, 1, 0, 17, 18), - (19, 2, -7, 17, 25), - (19, 1, -7, 17, 25), - (12, 2, 0, 10, 18), - (17, 1, 0, 15, 18), - (10, 0, 0, 11, 22), - (19, 2, 0, 15, 18), - (18, 0, 0, 18, 18), - (26, 0, 0, 26, 18), - (17, 0, 0, 17, 18), - (18, 0, -7, 18, 25), - (17, 1, 0, 15, 18), - (14, 2, -4, 11, 30), - (11, 3, -8, 5, 39), - (14, 1, -4, 11, 30), - (21, 2, 6, 17, 7), - ]; - let (mut pen, mut left, mut right, mut top, mut bottom) = - (0i16, i16::MAX, i16::MIN, i16::MAX, i16::MIN); - for c in text.bytes() { - if !(32..127).contains(&c) { - continue; - } - let (a, x, y, w, h) = GLYPHS[(c - 32) as usize]; - if w > 0 && h > 0 { - left = left.min(pen + x); - right = right.max(pen + x + w); - top = top.min(-y - h); - bottom = bottom.max(-y); - } - pen += a; - } - if left == i16::MAX { - return (0, (height - 32) / 2); - } - ( - (pen - left - right) / 2, - (height - (bottom - top)) / 2 - (26 + top), - ) -} - -/// Each overview band covers one third of this same filesystem, not a separate chip. -pub fn band_used(used: u32, total: u32, index: u8) -> u32 { - if total == 0 || index >= 3 { - return 0; - } - ((u64::from(used.min(total)) * 3).saturating_sub(u64::from(index) * u64::from(total))) - .min(u64::from(total)) as u32 -} -#[cfg(test)] -mod visual_tests { - use super::*; - #[test] - fn storage_bands_preserve_usage() { - for total in [1, 3, 1000, 10223616, u32::MAX] { - for used in [0, total / 100, total / 3, total / 2, total - 1, total] { - let sum: u64 = (0..3).map(|i| u64::from(band_used(used, total, i))).sum(); - assert_eq!(sum, u64::from(used) * 3); - } - } - assert_eq!(band_used(200, 100, 0), 100); - assert_eq!(band_used(1, 0, 0), 0); - assert_eq!(band_used(100, 100, 3), 0); - } - #[test] - fn action_text_uses_visible_ink() { - assert_eq!(button_label_position("Back", 72), (-1, 22)); - assert_eq!(button_label_position("Refresh", 72), (0, 22)); - } -} - -/// Nominal advances for the compact24M legend labels. -pub fn legend_width(s: &str) -> i16 { - match s { - "Apps" => 57, - "Faces" => 66, - "Loader" => 77, - "Other" => 63, - "Free" => 51, - "Used" => 57, - _ => 100, - } -} diff --git a/apps/storage/src/ui.rs b/apps/storage/src/ui.rs deleted file mode 100644 index 3851be8..0000000 --- a/apps/storage/src/ui.rs +++ /dev/null @@ -1,1100 +0,0 @@ -//! Native LVGL list, stock fonts, curved stock scrollbar. Cards are reserved for actions. -use crate::{ - inventory::{Category, Inventory}, - model::{self, Rect, Text}, -}; -use cmf_wp2_app::{ - Event, - lv::*, - stock, - storage::{Filesystem, Partition}, -}; -use core::fmt::Write; -const SURFACE: i32 = 0x2966; // Stock WP2 Settings card reference: (39,42,47) at full brightness -const SECONDARY: i32 = 0x8c51; // sampled WP3 #8E8B8E -// Semantic chart colors; surfaces and text retain the native watch theme. -const CHART_COLORS: [i32; 5] = [0xda67, 0xe4c6, 0xf649, 0xbe18, 0x2966]; -pub const BACK: u16 = 250; -pub const REFRESH: u16 = 251; -#[derive(Clone, Copy, Debug, PartialEq)] -pub enum Page { - Home, - Apps, - Faces(u8), - Other(u8), - System, - Nand, - Nor, - App(u8), - File(u8), - Partition(u8), - Accounting, -} -pub struct Screen { - pub root: Obj, - bar: Obj, - pub page: Page, - pub complete: bool, - buttons: [(Obj, u16); 32], - n: usize, -} -impl Screen { - pub fn action(&self, e: &Event) -> u16 { - if e.kind != cmf_wp2_app::LV || e.y != 7 { - return 0; - } - self.buttons[..self.n] - .iter() - .find(|(o, _)| o.0 == e.x as u16) - .map_or(0, |(_, a)| *a) - } - pub fn visible(&self, b: &mut Batch, on: bool) -> Result<(), LvError> { - for o in [self.root, self.bar] { - if on { - b.flags(o, &[], &[Flag::Hidden])?; - } else { - b.flags(o, &[Flag::Hidden], &[])?; - } - } - if on { - b.knob(self.root)?; - } - Ok(()) - } - fn bind(&mut self, b: &mut Batch, o: Obj, action: u16) -> Result<(), LvError> { - b.events(o, &[Ev::Clicked])?; - self.buttons[self.n] = (o, action); - self.n += 1; - Ok(()) - } -} -fn label( - b: &mut Batch, - p: Obj, - text: &str, - r: Rect, - font: i32, - color: i32, - align: i32, - wrap: bool, -) -> Result { - let o = b.create(Class::Label, p)?; - b.size(o, r.w as i32, r.h as i32)?; - b.align(o, Align::TopLeft, r.x, r.y)?; - b.text(o, text)?; - b.style(o, Prop::TextFont, 0, font)?; - b.style(o, Prop::TextColor, 0, color)?; - b.style(o, Prop::TextAlign, 0, align)?; - b.long_mode(o, if wrap { LongMode::Wrap } else { LongMode::Dot })?; - b.flags(o, &[], &[Flag::Clickable, Flag::Scrollable])?; - Ok(o) -} -fn block(b: &mut Batch, p: Obj, h: i32) -> Result { - let o = b.create(Class::Obj, p)?; - b.size(o, 418, h)?; - for prop in [ - Prop::PadTop, - Prop::PadBottom, - Prop::PadLeft, - Prop::PadRight, - Prop::BorderWidth, - Prop::BgOpa, - ] { - b.style(o, prop, 0, 0)?; - } - b.flags(o, &[], &[Flag::Scrollable, Flag::Clickable])?; - Ok(o) -} -fn heading(b: &mut Batch, p: Obj, text: &str, accent: bool) -> Result<(), LvError> { - let o = b.create(Class::Label, p)?; - b.size(o, 418, 42)?; - b.text(o, text)?; - b.style(o, Prop::TextAlign, 0, 2)?; - b.style(o, Prop::TextFont, 0, 0)?; - b.style( - o, - Prop::TextColor, - 0, - if accent { stock::ACCENT } else { stock::WHITE }, - )?; - b.long_mode(o, LongMode::Dot)?; - Ok(()) -} -fn note(b: &mut Batch, lv: &Lv, p: Obj, text: &str) -> Result<(), LvError> { - let lines = ((text.len() + 25) / 26).max(1) as i32; - let o = block(b, p, lines * 32 + 20)?; - label( - b, - o, - text, - Rect::new(40, 6, 338, (lines * 32 + 8) as i16), - 1, - SECONDARY, - 0, - true, - )?; - b.submit(lv) -} -// Category pictograms follow the filled stock Settings vocabulary. Storage/folder symbols -// are app-specific LVGL geometry; they are not claimed to be extracted stock artwork. -#[derive(Clone, Copy)] -enum Icon { - Apps, - Face, - Folder, - Chip, - Drive, - Usage, - App(char), - Installed(u8), - Document, -} -fn shape( - b: &mut Batch, - p: Obj, - x: i16, - y: i16, - w: i16, - h: i16, - color: i32, - radius: i32, -) -> Result { - let o = b.create(Class::Obj, p)?; - b.size(o, w as i32, h as i32)?; - b.align(o, Align::TopLeft, x, y)?; - for prop in [ - Prop::PadTop, - Prop::PadBottom, - Prop::PadLeft, - Prop::PadRight, - Prop::BorderWidth, - ] { - b.style(o, prop, 0, 0)?; - } - b.style(o, Prop::BgColor, 0, color)?; - b.style(o, Prop::BgOpa, 0, 255)?; - b.style(o, Prop::Radius, 0, radius)?; - b.flags(o, &[], &[Flag::Clickable, Flag::Scrollable])?; - Ok(o) -} -/// Square internal ends, two-pixel separators, and rounded outside ends only. -fn chart(b: &mut Batch, p: Obj, x: i16, y: i16, width: u16, values: &[u32]) -> Result<(), LvError> { - let widths = model::separated_widths(values, u32::from(width)); - let first = widths.iter().position(|&w| w > 0).unwrap_or(0); - let last = widths.iter().rposition(|&w| w > 0).unwrap_or(0); - let mut cursor = x; - for i in 0..5 { - let w = widths[i] as i16; - if w == 0 { - continue; - } - let radius = if i == first || i == last { - 6.min(w as i32 / 2) - } else { - 0 - }; - shape(b, p, cursor, y, w, 24, CHART_COLORS[i], radius)?; - if first != last && radius > 0 { - let r = radius as i16; - if i == first { - shape(b, p, cursor + w - r, y, r, 24, CHART_COLORS[i], 0)?; - } - if i == last { - shape(b, p, cursor, y, r, 24, CHART_COLORS[i], 0)?; - } - } - cursor += w + 2; - } - Ok(()) -} -fn icon(b: &mut Batch, lv: &Lv, p: Obj, kind: Icon, x: i16, y: i16) -> Result<(), LvError> { - b.submit(lv)?; - match kind { - Icon::Installed(slot) => { - let o = shape(b, p, 16, 16, 96, 96, SURFACE, 0)?; - b.style(o, Prop::BgOpa, 0, 0)?; - b.installed_app_icon(o, slot, IconSize::Native)?; - } - Icon::Apps => { - for row in 0..3 { - for col in 0..3 { - shape( - b, - p, - x + 4 + col * 14, - y + 4 + row * 14, - 8, - 8, - stock::WHITE, - 4, - )?; - } - b.submit(lv)?; - } - } - Icon::Face => { - shape(b, p, x + 13, y - 3, 18, 50, stock::WHITE, 4)?; - shape(b, p, x + 4, y + 5, 36, 36, stock::WHITE, 18)?; - shape(b, p, x + 9, y + 10, 26, 26, SURFACE, 13)?; - shape(b, p, x + 20, y + 14, 3, 12, stock::WHITE, 1)?; - shape(b, p, x + 20, y + 24, 10, 3, stock::ACCENT, 1)?; - } - Icon::Folder => { - shape(b, p, x + 1, y + 6, 20, 12, stock::WHITE, 4)?; - shape(b, p, x + 1, y + 13, 42, 28, stock::WHITE, 5)?; - } - Icon::Document => { - shape(b, p, x + 7, y + 2, 30, 40, stock::WHITE, 4)?; - shape(b, p, x + 13, y + 13, 18, 3, SURFACE, 1)?; - shape(b, p, x + 13, y + 21, 18, 3, SURFACE, 1)?; - shape(b, p, x + 13, y + 29, 12, 3, SURFACE, 1)?; - } - Icon::Chip => { - // Fit the reference's visible silhouette to the full44px slot, rather than its padded viewBox. - for offset in [14, 25] { - shape(b, p, x + offset, y, 5, 44, stock::WHITE, 0)?; - shape(b, p, x, y + offset, 44, 5, stock::WHITE, 0)?; - } - b.submit(lv)?; - shape(b, p, x + 5, y + 5, 34, 34, stock::WHITE, 5)?; - shape(b, p, x + 10, y + 10, 24, 24, SURFACE, 0)?; - shape(b, p, x + 14, y + 14, 16, 16, stock::WHITE, 0)?; - } - Icon::Drive => { - for i in 0..3 { - shape( - b, - p, - x, - y + i * 16, - 46, - 12, - if i == 0 { stock::WHITE } else { SECONDARY }, - 4, - )?; - } - shape(b, p, x + 35, y + 3, 5, 5, stock::ACCENT, 3)?; - } - Icon::Usage => { - shape(b, p, x, y, 44, 44, stock::WHITE, 22)?; - shape(b, p, x + 20, y + 10, 4, 4, SURFACE, 2)?; - shape(b, p, x + 20, y + 20, 4, 14, SURFACE, 2)?; - } - Icon::App(letter) => { - let circle = shape(b, p, x - 2, y - 2, 48, 48, stock::LETTER_BG, 24)?; - let mut initial = Text::new(); - let _ = write!(initial, "{}", letter.to_ascii_uppercase()); - let (dx, ty) = model::button_label_position(initial.as_str(), 48); - label( - b, - circle, - initial.as_str(), - Rect::new(dx, ty, 48, 38), - 0, - stock::WHITE, - 2, - false, - )?; - } - } - b.submit(lv) -} -fn navigation( - b: &mut Batch, - lv: &Lv, - s: &mut Screen, - name: &str, - value: &str, - action: u16, - kind: Icon, -) -> Result<(), LvError> { - let app_row = matches!(s.page, Page::Apps); - let height = 128; - let text_x = if app_row { 132 } else { 96 }; - let o = block(b, s.root, height)?; - b.style(o, Prop::BgColor, 0, SURFACE)?; - b.style(o, Prop::BgOpa, 0, 255)?; - b.style(o, Prop::Radius, 0, height / 2)?; - b.flags(o, &[Flag::Clickable], &[])?; - b.style(o, Prop::BgColor, stock::PRESSED, stock::ROW_PRESSED)?; - s.bind(b, o, action)?; - icon(b, lv, o, kind, 34, 42)?; - label( - b, - o, - name, - Rect::new( - text_x, - if app_row { - 22 - } else if value.is_empty() { - 48 - } else { - 25 - }, - 390 - text_x, - 46, - ), - 3, - stock::WHITE, - 0, - false, - )?; - if !value.is_empty() { - label( - b, - o, - value, - Rect::new(text_x, if app_row { 72 } else { 75 }, 390 - text_x, 38), - 0, - SECONDARY, - 0, - false, - )?; - } - b.submit(lv) -} -fn action_button( - b: &mut Batch, - lv: &Lv, - s: &mut Screen, - name: &str, - action: u16, -) -> Result<(), LvError> { - let outer = block(b, s.root, 92)?; - let w = 280; - let button = shape( - b, - outer, - ((418 - w) / 2) as i16, - 8, - w as i16, - 72, - if action == REFRESH { - stock::ACCENT - } else { - stock::ROW_BG - }, - 36, - )?; - b.flags(button, &[Flag::Clickable], &[])?; - b.style(button, Prop::BgColor, stock::PRESSED, stock::ROW_PRESSED)?; - s.bind(b, button, action)?; - let (dx, ty) = model::button_label_position(name, 72); - label( - b, - button, - name, - Rect::new(12 + dx, ty, (w - 24) as i16, 42), - 0, - stock::WHITE, - 2, - false, - )?; - b.submit(lv) -} -fn row( - b: &mut Batch, - lv: &Lv, - s: &mut Screen, - name: &str, - value: &str, - action: u16, - _filled: bool, -) -> Result<(), LvError> { - if action == BACK || action == REFRESH || action == 200 || action == 201 { - return action_button(b, lv, s, name, action); - } - if (128..=157).contains(&action) { - let o = block(b, s.root, 104)?; - b.flags(o, &[Flag::Clickable], &[])?; - b.style(o, Prop::BgColor, stock::PRESSED, stock::ROW_PRESSED)?; - b.style(o, Prop::BgOpa, stock::PRESSED, 255)?; - b.style(o, Prop::Radius, 0, 52)?; - s.bind(b, o, action)?; - label( - b, - o, - name, - Rect::new(40, 10, 338, 42), - 0, - stock::WHITE, - 0, - false, - )?; - label( - b, - o, - value, - Rect::new(40, 59, 338, 32), - 1, - SECONDARY, - 0, - false, - )?; - return b.submit(lv); - } - if action != 0 { - let kind = match action { - 1 => Icon::Apps, - 2 => Icon::Face, - 3 => Icon::Folder, - 4..=6 => Icon::Chip, - 8 => Icon::Usage, - 16..=31 => { - if name == "Storage" { - Icon::Drive - } else { - Icon::App(name.chars().next().unwrap_or('A')) - } - } - 32..=127 => { - if matches!(s.page, Page::Faces(_)) { - Icon::Face - } else { - Icon::Document - } - } - _ => Icon::Drive, - }; - return navigation(b, lv, s, name, value, action, kind); - } - // Read-only facts use compact text/value spacing, not button surfaces. - let o = block(b, s.root, 94)?; - label( - b, - o, - name, - Rect::new(40, 10, 338, 40), - 0, - stock::WHITE, - 0, - false, - )?; - label( - b, - o, - value, - Rect::new(40, 55, 338, 32), - 1, - SECONDARY, - 0, - false, - )?; - b.submit(lv) -} -fn value(b: &mut Batch, lv: &Lv, s: &mut Screen, name: &str, n: u32) -> Result<(), LvError> { - row(b, lv, s, name, Text::bytes(n).as_str(), 0, false) -} -fn count_label(inv: &Inventory, cat: Category) -> Text { - let mut t = Text::new(); - if inv.error < 0 && !inv.ready { - let _ = write!(t, "Scan unavailable"); - } else if !inv.ready { - let _ = write!(t, "Reading files..."); - } else { - let _ = write!( - t, - "{}{}", - Text::bytes(inv.sum(cat)).as_str(), - if inv.partial { " found" } else { "" } - ); - } - t -} -fn start(b: &mut Batch, lv: &Lv, page: Page, title: &str) -> Result { - stock::theme(b)?; - let (root, bar) = stock::page(b)?; - // Keep the final action inside the circular safe area without centering it. - b.style(root, Prop::PadBottom, 0, 48)?; - b.style(root, Prop::PadLeft, 0, 24)?; - b.style(root, Prop::PadRight, 0, 24)?; - b.flex( - root, - Flow::Column, - FlexAlign::Start, - FlexAlign::Start, - FlexAlign::Start, - )?; - b.style(root, Prop::PadRow, 0, 10)?; - heading(b, root, title, page == Page::Home)?; - b.submit(lv)?; - Ok(Screen { - root, - bar, - page, - complete: false, - buttons: [(ROOT, 0); 32], - n: 0, - }) -} -pub fn render( - b: &mut Batch, - lv: &Lv, - page: Page, - parts: &[Partition], - fs: Option, - inv: &Inventory, - reading: bool, - stale: bool, -) -> Result { - let title = match page { - Page::Home => "Storage", - Page::Apps => "Apps", - Page::Faces(_) => "Watch faces", - Page::Other(_) => "Other files", - Page::System => "System storage", - Page::Nand => "NAND", - Page::Nor => "System flash", - Page::App(slot) => { - if inv.apps[slot as usize].valid { - inv.apps[slot as usize].name() - } else { - "App details" - } - } - Page::File(_) => "File details", - Page::Partition(_) => "Reservation", - Page::Accounting => "Usage details", - }; - let mut s = start(b, lv, page, title)?; - s.complete = inv.ready; - match page { - Page::Home => { - if let Some(f) = fs { - let complete = crate::inventory::breakdown(&f, inv); - let values = if let Some(v) = complete { - [v[0], v[1], v[2], v[3], f.free] - } else { - [f.total - f.free, 0, 0, 0, f.free] - }; - let names = if complete.is_some() { - ["Apps", "Loader", "Faces", "Other", "Free"] - } else { - ["Used", "Loader", "Faces", "Other", "Free"] - }; - let visible = values[..4].iter().filter(|&&v| v > 0).count(); - let legend_width: i16 = values - .iter() - .enumerate() - .filter(|(i, v)| *i < 4 && **v > 0) - .map(|(i, _)| model::legend_width(names[i]) + 14) - .sum::() - + visible.saturating_sub(1) as i16 * 18; - let rows = if legend_width > 374 { 2 } else { 1 }; - // Keep the legend clear of the bar, with breathing room before the cards. - let summary = block(b, s.root, 156 + rows * 32)?; - let free = Text::bytes(f.free); - let (number, unit) = free - .as_str() - .split_once(' ') - .unwrap_or((free.as_str(), "B")); - let mut free_unit = Text::new(); - let _ = write!(free_unit, "{} free", unit); - let nw = model::number_width(number); - let uw = match unit { - "MiB" => 94, - "KiB" => 89, - _ => 67, - }; - let left = (418 - nw - 12 - uw) / 2; - label( - b, - summary, - number, - Rect::new(left, 0, nw + 4, 64), - 2, - stock::WHITE, - 0, - false, - )?; - label( - b, - summary, - free_unit.as_str(), - Rect::new(left + nw + 12, 29, uw + 4, 36), - 1, - SECONDARY, - 0, - false, - )?; - let mut caption = Text::new(); - let _ = write!( - caption, - "{} used / {}", - Text::bytes(f.total - f.free).as_str(), - Text::bytes(f.total).as_str() - ); - label( - b, - summary, - caption.as_str(), - Rect::new(40, 64, 338, 36), - 1, - SECONDARY, - 2, - false, - )?; - b.submit(lv)?; - chart(b, summary, 22, 106, 374, &values)?; - b.flags(summary, &[Flag::Clickable], &[])?; - s.bind(b, summary, 8)?; - b.submit(lv)?; - let mut indices = [0usize; 5]; - let mut n = 0; - for i in 0..5 { - if i < 4 && values[i] > 0 { - indices[n] = i; - n += 1; - } - } - let first = if rows > 1 { (n + 1) / 2 } else { n }; - for row in 0..rows { - let range = if row == 0 { 0..first } else { first..n }; - let mut width = 0; - for (position, k) in range.clone().enumerate() { - width += model::legend_width(names[indices[k]]) + 14; - if position > 0 { - width += 18; - } - } - let mut x = 22 + (374 - width) / 2; - for k in range { - let i = indices[k]; - shape( - b, - summary, - x, - 150 + row as i16 * 32, - 8, - 8, - CHART_COLORS[i], - 4, - )?; - let w = model::legend_width(names[i]); - label( - b, - summary, - names[i], - Rect::new(x + 14, 144 + row as i16 * 32, w + 4, 32), - 1, - SECONDARY, - 0, - false, - )?; - x += w + 32; - } - b.submit(lv)?; - } - } else { - note( - b, - lv, - s.root, - if inv.error == -95 { - "Update App Loader to use Storage." - } else { - "Usage unavailable. Refresh to try again." - }, - )?; - } - if stale { - note( - b, - lv, - s.root, - "Refresh did not finish. Showing the previous reading.", - )?; - } - row( - b, - lv, - &mut s, - "Apps", - count_label(inv, Category::App(0)).as_str(), - 1, - false, - )?; - row( - b, - lv, - &mut s, - "Watch faces", - count_label(inv, Category::Face).as_str(), - 2, - false, - )?; - row( - b, - lv, - &mut s, - "Other files", - count_label(inv, Category::Other).as_str(), - 3, - false, - )?; - row(b, lv, &mut s, "System storage", "Firmware & data", 4, true)?; - row( - b, - lv, - &mut s, - "Usage details", - "Files & allocation", - 8, - false, - )?; - if inv.partial { - note( - b, - lv, - s.root, - "File list is incomplete. Some folders could not be read or exceed scan limits.", - )?; - } - row( - b, - lv, - &mut s, - if reading { "Cancel scan" } else { "Refresh" }, - "", - REFRESH, - true, - )?; - } - Page::Apps => { - let mut found = false; - for i in 0..16 { - let total = inv.app_total(i); - let a = inv.apps[i as usize]; - if a.valid || total > 0 { - found = true; - let mut name = Text::new(); - if a.valid { - let _ = write!(name, "{}", a.name()); - } else { - let _ = write!(name, "App slot {}", i + 1); - } - navigation( - b, - lv, - &mut s, - name.as_str(), - Text::bytes(total).as_str(), - 16 + i as u16, - if a.icon { - Icon::Installed(i) - } else { - Icon::App(name.as_str().chars().next().unwrap_or('A')) - }, - )?; - } - } - if !found { - note( - b, - lv, - s.root, - if inv.ready { - "No app files found." - } else if inv.error < 0 { - "File scan unavailable. Refresh to try again." - } else { - "Reading app files..." - }, - )?; - } - } - Page::Faces(offset) | Page::Other(offset) => { - let cat = if matches!(page, Page::Faces(_)) { - Category::Face - } else { - Category::Other - }; - let mut found = false; - let mut ordinal = 0usize; - let mut more = false; - for (i, f) in inv.files[..inv.count].iter().enumerate() { - if f.category == cat { - let at = ordinal; - ordinal += 1; - if at < (offset as usize) * 12 { - continue; - } - if at >= (offset as usize + 1) * 12 { - more = true; - continue; - } - found = true; - row( - b, - lv, - &mut s, - f.name(), - Text::bytes(f.size).as_str(), - 32 + i as u16, - false, - )?; - } - } - if offset > 0 { - row(b, lv, &mut s, "Previous files", "", 201, true)?; - } - if more { - row(b, lv, &mut s, "More files", "", 200, true)?; - } - if !found { - let empty = block(b, s.root, 126)?; - icon( - b, - lv, - empty, - if matches!(page, Page::Faces(_)) { - Icon::Face - } else { - Icon::Folder - }, - 187, - 44, - )?; - note( - b, - lv, - s.root, - if !inv.ready && inv.error < 0 { - "File scan unavailable. Refresh to try again." - } else if !inv.ready { - "Reading files..." - } else if inv.partial { - "No matching files found in the partial scan." - } else { - "No files found." - }, - )?; - } - if inv.partial { - note(b, lv, s.root, "Partial file list. Refresh to try again.")?; - } - if matches!(page, Page::Faces(_)) { - note( - b, - lv, - s.root, - "Lists .wfc files by filename. Built-in faces are part of system resources.", - )?; - } - } - Page::App(slot) => { - let a = inv.apps[slot as usize]; - if a.valid && a.name().len() > 16 { - note(b, lv, s.root, a.name())?; - } - value(b, lv, &mut s, "Files total", inv.app_total(slot))?; - for (i, f) in inv.files[..inv.count].iter().enumerate() { - if f.category == Category::App(slot) { - let name = if f.name().as_bytes()[2..].eq_ignore_ascii_case(b"pkg") { - "App package" - } else if f.name().as_bytes()[2..].eq_ignore_ascii_case(b"dat") { - "Saved data" - } else { - "Widget record" - }; - row( - b, - lv, - &mut s, - name, - Text::bytes(f.size).as_str(), - 32 + i as u16, - false, - )?; - } - } - if a.valid { - let mut t = Text::new(); - let _ = write!(t, "Version {}", a.version); - note(b, lv, s.root, t.as_str())?; - } - } - Page::File(i) => { - let f = &inv.files[i as usize]; - note(b, lv, s.root, f.name())?; - value(b, lv, &mut s, "File size", f.size)?; - let mut exact = Text::new(); - let _ = write!(exact, "{} bytes", f.size); - note(b, lv, s.root, exact.as_str())?; - note(b, lv, s.root, f.path())?; - note( - b, - lv, - s.root, - "Logical file bytes. Space on disk may be larger.", - )?; - } - Page::System => { - row(b, lv, &mut s, "NAND", "Resources & files", 5, true)?; - row(b, lv, &mut s, "System flash", "Firmware & boot", 6, true)?; - if let Some(f) = fs { - value(b, lv, &mut s, "App loader file", f.loader)?; - } - note( - b, - lv, - s.root, - "Reservations are capacities, not measured used space.", - )?; - } - Page::Nand | Page::Nor => { - let dev = if page == Page::Nand { 2 } else { 0 }; - if model::reference_layout(parts) { - value( - b, - lv, - &mut s, - "Chip capacity", - if dev == 2 { - model::NAND_MAIN - } else { - model::NOR_MAIN - }, - )?; - if dev == 2 { - value(b, lv, &mut s, "Logical NAND", model::NAND_LOGICAL)?; - value(b, lv, &mut s, "Flash management", model::FTL_MANAGEMENT)?; - note(b, lv, s.root, "Management space is not file storage.")?; - } - } else { - note( - b, - lv, - s.root, - "Hardware capacity is not verified for this layout.", - )?; - } - for (i, p) in parts.iter().enumerate().filter(|(_, p)| p.device == dev) { - row( - b, - lv, - &mut s, - model::purpose(p), - Text::bytes(p.allocated).as_str(), - 128 + i as u16, - false, - )?; - } - if dev == 2 && model::reference_layout(parts) { - value(b, lv, &mut s, "Unpartitioned tail", model::LOGICAL_TAIL)?; - note( - b, - lv, - s.root, - "Tail capacity is not available as file storage.", - )?; - } - } - Page::Partition(i) => { - let p = &parts[i as usize]; - note(b, lv, s.root, model::purpose(p))?; - value(b, lv, &mut s, "Reserved capacity", p.allocated)?; - row(b, lv, &mut s, "Partition name", p.name(), 0, false)?; - let mut t = Text::new(); - let _ = write!(t, "0x{:08X}", p.offset); - row(b, lv, &mut s, "Device offset", t.as_str(), 0, false)?; - note( - b, - lv, - s.root, - "Reserved capacity does not report how many bytes are in use.", - )?; - } - Page::Accounting => { - if let Some(f) = fs { - let used = f.total - f.free; - let summary = block(b, s.root, 142)?; - label( - b, - summary, - Text::bytes(used).as_str(), - Rect::new(40, 0, 338, 64), - 2, - stock::WHITE, - 2, - false, - )?; - label( - b, - summary, - "Breakdown of used space", - Rect::new(40, 70, 338, 34), - 1, - SECONDARY, - 2, - false, - )?; - b.submit(lv)?; - if let Some(values) = crate::inventory::breakdown(&f, inv) { - let colors = CHART_COLORS; - chart(b, summary, 40, 116, 338, &values)?; - b.submit(lv)?; - for (i, name) in ["Apps", "App loader", "Watch faces", "Other usage"] - .into_iter() - .enumerate() - { - if values[i] == 0 { - continue; - } - let item = block(b, s.root, 86)?; - shape(b, item, 40, 28, 10, 10, colors[i], 3)?; - label( - b, - item, - name, - Rect::new(68, 6, 310, 40), - 0, - stock::WHITE, - 0, - false, - )?; - label( - b, - item, - Text::bytes(values[i]).as_str(), - Rect::new(68, 50, 310, 32), - 1, - SECONDARY, - 0, - false, - )?; - b.submit(lv)?; - } - note( - b, - lv, - s.root, - "Other usage includes remaining files and unassigned allocation.", - )?; - } else { - note( - b, - lv, - s.root, - "A complete, consistent scan is needed for the breakdown.", - )?; - } - value(b, lv, &mut s, "Free space", f.free)?; - value(b, lv, &mut s, "File-data capacity", f.total)?; - note( - b, - lv, - s.root, - "Firmware and built-in resources are separate.", - )?; - } else { - note(b, lv, s.root, "No usage reading is available.")?; - } - } - } - if page != Page::Home { - row(b, lv, &mut s, "Back", "", BACK, true)?; - } - Ok(s) -} diff --git a/apps/storage/src/ui_tests.rs b/apps/storage/src/ui_tests.rs deleted file mode 100644 index ff27215..0000000 --- a/apps/storage/src/ui_tests.rs +++ /dev/null @@ -1,182 +0,0 @@ -use crate::{ - inventory::{App, Category, File, Inventory}, - ui::{self, Page}, -}; -use cmf_wp2_app::{Api, Event, Time, lv::*, stock}; -use std::cell::RefCell; -use wp2_core::lvcmd::{self, Table}; -thread_local! {static STATE:RefCell<(Table,u8,usize)>=RefCell::new((Table::new(),0,0));} -extern "C" fn submit(p: *const u8, n: usize) -> i32 { - let bytes = unsafe { std::slice::from_raw_parts(p, n) }; - STATE.with(|s| { - let mut s = s.borrow_mut(); - if let Err(e) = lvcmd::validate(bytes, &s.0, s.1) { - return e.code(); - } - for rec in lvcmd::records(bytes) { - let r = rec.unwrap(); - if let lvcmd::Rec::Font { slot, .. } = r { - s.1 |= 1 << slot; - } - lvcmd::apply(&mut s.0, &r); - let live = (1..=192).filter(|&i| s.0.class(i).is_some()).count(); - s.2 = s.2.max(live); - } - 0 - }) -} -extern "C" fn rect(_: i16, _: i16, _: u16, _: u16, _: u16) {} -extern "C" fn text(_: i16, _: i16, _: *const u8, _: usize, _: u16) {} -extern "C" fn noop() {} -extern "C" fn event(_: *mut Event, _: u32) -> bool { - false -} -extern "C" fn motor(_: u16, _: u16) -> i32 { - 0 -} -extern "C" fn millis() -> u32 { - 0 -} -extern "C" fn exit(_: i32) -> ! { - std::process::abort() -} -extern "C" fn bytes(_: *const u8, _: usize) -> i32 { - 0 -} -extern "C" fn bytes_mut(_: *mut u8, _: usize) -> i32 { - 0 -} -extern "C" fn time(_: *mut Time) -> i32 { - 0 -} -extern "C" fn battery() -> i32 { - 0 -} -extern "C" fn screen(_: bool) -> i32 { - 0 -} -extern "C" fn flag(_: bool) {} -fn api() -> Api { - Api { - abi: cmf_wp2_app::ABI, - abi_minor: cmf_wp2_app::ABI_MINOR, - width: 466, - height: 466, - fill_rect: rect, - draw_text: text, - present: noop, - next_event: event, - motor, - millis, - exit, - send_msg: bytes, - recv_msg: bytes_mut, - load_data: bytes_mut, - save_data: bytes, - get_time: time, - get_battery: battery, - screen_on: screen, - lv_submit: submit, - own_back: flag, - } -} -#[test] -fn all_screens_and_nested_full_catalog_fit_loader_budgets() { - STATE.with(|s| *s.borrow_mut() = (Table::new(), 0, 0)); - let api = api(); - let lv = api.lv().unwrap(); - let mut b = Batch::new().unwrap(); - stock::font(&mut b).unwrap(); - b.font(1, StockFont::F24M).unwrap(); - b.font(2, StockFont::F48M).unwrap(); - b.font(3, StockFont::F36M).unwrap(); - b.submit(&lv).unwrap(); - let mut inv = Inventory::new(); - inv.ready = true; - inv.partial = true; - for slot in 0..16 { - let mut name = [0; 24]; - name[..3].copy_from_slice(b"App"); - inv.apps[slot] = App { - name, - version: 1, - valid: true, - icon: true, - }; - } - for i in 0..96 { - let mut path = [0; 96]; - let s = format!("/NAND:/test/{i}.wfc"); - path[..s.len()].copy_from_slice(s.as_bytes()); - inv.files[i] = File { - path, - size: 4096, - category: if i < 16 { - Category::App(i as u8) - } else { - Category::Face - }, - }; - } - inv.count = 96; - let fs = cmf_wp2_app::storage::Filesystem { - total: 10223616, - free: 8000000, - apps: 65536, - loader: 65536, - allocation_unit: 2048, - ..Default::default() - }; - let mut parts = [cmf_wp2_app::storage::Partition { - allocated: 65536, - device: 2, - ..Default::default() - }; 30]; - for (i, p) in parts.iter_mut().enumerate() { - p.offset = i as u32 * 65536; - p.name[..4].copy_from_slice(b"test"); - } - let home = ui::render(&mut b, &lv, Page::Home, &parts, Some(fs), &inv, false, true).unwrap(); - home.visible(&mut b, false).unwrap(); - b.submit(&lv).unwrap(); - for missing_icons in [false, true] { - for a in &mut inv.apps { - a.icon = !missing_icons; - } - for page in [ - Page::Apps, - Page::Faces(0), - Page::Faces(8), - Page::Other(0), - Page::System, - Page::Nand, - Page::Nor, - Page::Accounting, - ] { - let view = ui::render(&mut b, &lv, page, &parts, Some(fs), &inv, false, false).unwrap(); - view.visible(&mut b, false).unwrap(); - b.submit(&lv).unwrap(); - for child in [Page::App(15), Page::File(2), Page::Partition(0)] { - let detail = - ui::render(&mut b, &lv, child, &parts, Some(fs), &inv, false, false).unwrap(); - b.del(detail.root).unwrap(); - b.submit(&lv).unwrap(); - } - b.del(view.root).unwrap(); - b.submit(&lv).unwrap(); - } - } - b.del(home.root).unwrap(); - b.submit(&lv).unwrap(); - for error in [-95, -5] { - let mut inv = Inventory::new(); - inv.error = error; - let v = ui::render(&mut b, &lv, Page::Home, &[], None, &inv, false, false).unwrap(); - b.del(v.root).unwrap(); - b.submit(&lv).unwrap(); - } - STATE.with(|s| { - assert!(s.borrow().2 <= 192); - println!("peak live objects: {}", s.borrow().2); - }); -} diff --git a/apps/storage/store.md b/apps/storage/store.md deleted file mode 100644 index 50e62d4..0000000 --- a/apps/storage/store.md +++ /dev/null @@ -1,14 +0,0 @@ -Storage shows the writable space available on the watch, with a segmented usage bar and sizes for installed -apps, the App Loader, watch faces and other files. System storage lists firmware and resource reservations -separately from free file space. - -Tap a category for details. The crown scrolls, the crown button goes back, and Refresh scans again. The app is -read-only: it does not delete files, remove apps or change firmware. File sizes are logical lengths; -filesystem allocation and metadata can make occupied space larger. Incomplete scans are labelled rather than -presented as complete totals. - -## Requirements - -CMF Watch Pro 2 running patched firmware 1.0.0.73 and an App Loader providing -storage-inspection service v1. On an older loader, the app displays an update message. No phone connection is -needed. Watch 3 Pro support has not been established. diff --git a/apps/storage/store.toml b/apps/storage/store.toml deleted file mode 100644 index f7b0fdc..0000000 --- a/apps/storage/store.toml +++ /dev/null @@ -1,5 +0,0 @@ -name = "Storage" -summary = "View free space, installed app sizes, watch faces and the watch storage layout" -version = "0.1.0" -author = "Arnav Kumar" -screenshots = ["shots/overview.png", "shots/usage.png", "shots/apps.png", "shots/apps-more.png", "shots/watchfaces.png", "shots/system.png"] diff --git a/apps/telegram/Cargo.toml b/apps/telegram/Cargo.toml deleted file mode 100644 index 620da20..0000000 --- a/apps/telegram/Cargo.toml +++ /dev/null @@ -1,12 +0,0 @@ -[package] -name = "telegram" -edition.workspace = true -license.workspace = true -version.workspace = true - -[dependencies] -cmf-wp2-app.workspace = true - -[[bin]] -name = "telegram" -bench = false diff --git a/apps/telegram/icon.svg b/apps/telegram/icon.svg deleted file mode 100644 index 8536d2c..0000000 --- a/apps/telegram/icon.svg +++ /dev/null @@ -1,6 +0,0 @@ - - - -telegram - - \ No newline at end of file diff --git a/apps/telegram/src/main.rs b/apps/telegram/src/main.rs deleted file mode 100644 index b5f84c6..0000000 --- a/apps/telegram/src/main.rs +++ /dev/null @@ -1,324 +0,0 @@ -#![cfg_attr(any(target_os = "none", wp2_sim), no_main, cfg_attr(target_os = "none", no_std))] - -#[cfg(not(any(target_os = "none", wp2_sim)))] -fn main() {} - -#[cfg(any(target_os = "none", wp2_sim))] -mod device { - use cmf_wp2_app::{Api, BUTTON, CROWN, RESUME, TOUCH_DOWN}; - - cmf_wp2_app::entry!(main); - cmf_wp2_app::app_icon!(); - - const BLACK: u16 = 0x0000; - const WHITE: u16 = 0xFFFF; - const CARD_BG: u16 = 0x18E3; - const BUBBLE_THEM: u16 = 0x2945; - const TG_BLUE: u16 = 0x255D; - const GREY_TEXT: u16 = 0x8C71; - const PAD_BG: u16 = 0x2104; - - const KEYS: [u8; 33] = [ - b'A', b'B', b'C', b'D', b'E', b'F', b'G', b'H', b'I', b'J', b'K', - b'L', b'M', b'N', b'O', b'P', b'Q', b'R', b'S', b'T', b'U', b'V', - b'W', b'X', b'Y', b'Z', b'.', b',', b'?', b'!', b'_', b'<', b'>', - ]; - - #[derive(Clone, Copy, PartialEq)] - enum Screen { - ChatList, - ChatView, - Touchpad, - } - - struct Chat { - name: &'static str, - last_msg: &'static str, - unread: u8, - } - - struct Message { - is_me: bool, - text: [u8; 48], - len: usize, - } - - impl Message { - const fn from_static(is_me: bool, s: &str) -> Self { - let mut text = [0u8; 48]; - let bytes = s.as_bytes(); - let mut i = 0; - while i < bytes.len() && i < 48 { - text[i] = bytes[i]; - i += 1; - } - Self { is_me, text, len: i } - } - - fn as_str(&self) -> &str { - core::str::from_utf8(&self.text[..self.len]).unwrap_or("") - } - } - - struct AppState { - screen: Screen, - selected_chat: usize, - active_chat: usize, - messages: [Message; 6], - msg_count: usize, - input_buf: [u8; 48], - input_len: usize, - cursor_idx: usize, - } - - impl AppState { - fn new() -> Self { - let messages = [ - Message::from_static(false, "Privet! Kak chasy?"), - Message::from_static(true, "Delau svoy TG na Rust!"), - Message::from_static(false, "Krutaya klava-tachpad"), - Message::from_static(false, ""), - Message::from_static(false, ""), - Message::from_static(false, ""), - ]; - Self { - screen: Screen::ChatList, - selected_chat: 0, - active_chat: 0, - messages, - msg_count: 3, - input_buf: [0; 48], - input_len: 0, - cursor_idx: 0, - } - } - - fn input_str(&self) -> &str { - core::str::from_utf8(&self.input_buf[..self.input_len]).unwrap_or("") - } - - fn push_message(&mut self, is_me: bool) { - if self.input_len == 0 { - return; - } - let mut msg = Message { - is_me, - text: [0; 48], - len: self.input_len, - }; - msg.text[..self.input_len].copy_from_slice(&self.input_buf[..self.input_len]); - - if self.msg_count < self.messages.len() { - self.messages[self.msg_count] = msg; - self.msg_count += 1; - } else { - for i in 0..self.messages.len() - 1 { - self.messages[i] = Message { - is_me: self.messages[i + 1].is_me, - text: self.messages[i + 1].text, - len: self.messages[i + 1].len, - }; - } - self.messages[self.messages.len() - 1] = msg; - } - self.input_len = 0; - } - } - - const CHATS: [Chat; 4] = [ - Chat { name: "Saved Messages", last_msg: "Notes & links", unread: 0 }, - Chat { name: "Alexey", last_msg: "Krutaya klava-tachpad", unread: 2 }, - Chat { name: "FMC Dev", last_msg: "New SDK released", unread: 5 }, - Chat { name: "Mom", last_msg: "Call me later", unread: 1 }, - ]; - - fn draw_chat_list(api: &Api, state: &AppState) { - api.rect(0, 0, api.width, api.height, BLACK); - api.text(175, 24, "Telegram", TG_BLUE); - - let start_y: i16 = 65; - let card_h: i16 = 82; - - for (i, chat) in CHATS.iter().enumerate() { - let y = start_y + i as i16 * (card_h + 8); - let bg = if i == state.selected_chat { 0x2965 } else { CARD_BG }; - api.rect(38, y, 390, card_h as u16, bg); - - api.text(54, y + 14, chat.name, WHITE); - api.text(54, y + 46, chat.last_msg, GREY_TEXT); - - if chat.unread > 0 { - api.rect(388, y + 26, 26, 26, TG_BLUE); - let badge = [b'0' + chat.unread]; - if let Ok(s) = core::str::from_utf8(&badge) { - api.text(396, y + 31, s, WHITE); - } - } - } - api.show(); - } - - fn draw_chat_view(api: &Api, state: &AppState) { - api.rect(0, 0, api.width, api.height, BLACK); - api.text(48, 28, "Back", TG_BLUE); - api.text(165, 28, CHATS[state.active_chat].name, WHITE); - - let start_idx = state.msg_count.saturating_sub(4); - let mut y: i16 = 72; - - for i in start_idx..state.msg_count { - let msg = &state.messages[i]; - let bubble_x: i16 = if msg.is_me { 115 } else { 42 }; - let bubble_col = if msg.is_me { TG_BLUE } else { BUBBLE_THEM }; - - api.rect(bubble_x, y, 308, 62, bubble_col); - api.text(bubble_x + 14, y + 22, msg.as_str(), WHITE); - y += 72; - } - - api.rect(123, 385, 220, 52, TG_BLUE); - api.text(192, 403, "Reply", WHITE); - api.show(); - } - - fn draw_touchpad(api: &Api, state: &AppState) { - api.rect(0, 0, api.width, api.height, BLACK); - - api.rect(48, 36, 370, 48, CARD_BG); - let text_to_show = if state.input_len > 0 { - state.input_str() - } else { - "Tap pad to move/type" - }; - let text_col = if state.input_len > 0 { WHITE } else { GREY_TEXT }; - api.text(62, 52, text_to_show, text_col); - - let cols: i16 = 11; - let cell_w: i16 = 34; - let cell_h: i16 = 38; - let grid_x: i16 = 46; - let grid_y: i16 = 100; - - for (idx, &ch) in KEYS.iter().enumerate() { - let col = (idx as i16) % cols; - let row = (idx as i16) / cols; - let x = grid_x + col * cell_w; - let y = grid_y + row * cell_h; - - if idx == state.cursor_idx { - api.rect(x - 2, y - 2, cell_w as u16, cell_h as u16, TG_BLUE); - } - - let buf = [ch]; - if let Ok(s) = core::str::from_utf8(&buf) { - api.text(x + 9, y + 10, s, WHITE); - } - } - - api.rect(53, 230, 360, 195, PAD_BG); - api.text(135, 318, "TOUCHPAD AREA", GREY_TEXT); - api.text(115, 345, "Tap to move / Type", GREY_TEXT); - api.show(); - } - - fn draw(api: &Api, state: &AppState) { - match state.screen { - Screen::ChatList => draw_chat_list(api, state), - Screen::ChatView => draw_chat_view(api, state), - Screen::Touchpad => draw_touchpad(api, state), - } - } - - fn main(api: &'static Api) -> i32 { - let mut state = AppState::new(); - draw(api, &state); - - loop { - let Some(event) = api.event(u32::MAX) else { continue }; - match event.kind { - BUTTON => match state.screen { - Screen::Touchpad => state.screen = Screen::ChatView, - Screen::ChatView => state.screen = Screen::ChatList, - Screen::ChatList => return 0, - }, - CROWN if event.delta != 0 => { - let dir = event.delta.signum(); - match state.screen { - Screen::ChatList => { - let next = (state.selected_chat as i32 + dir as i32) - .clamp(0, (CHATS.len() - 1) as i32); - state.selected_chat = next as usize; - } - Screen::Touchpad => { - let next = (state.cursor_idx as i32 + dir as i32) - .rem_euclid(KEYS.len() as i32); - state.cursor_idx = next as usize; - } - _ => {} - } - } - TOUCH_DOWN => match state.screen { - Screen::ChatList => { - if event.y >= 65 && event.y < 65 + 4 * 90 { - let idx = ((event.y - 65) / 90) as usize; - if idx < CHATS.len() { - state.active_chat = idx; - state.screen = Screen::ChatView; - } - } - } - Screen::ChatView => { - if event.y < 70 && event.x < 160 { - state.screen = Screen::ChatList; - } else if event.y >= 380 { - state.input_len = 0; - state.screen = Screen::Touchpad; - } - } - Screen::Touchpad => { - if event.y >= 230 && event.y <= 425 && event.x >= 53 && event.x <= 413 { - let rel_x = (event.x - 53).clamp(0, 359); - let rel_y = (event.y - 230).clamp(0, 194); - - let col = (rel_x * 11 / 360) as usize; - let row = (rel_y * 3 / 195) as usize; - let target_idx = (row * 11 + col).min(KEYS.len() - 1); - - if target_idx == state.cursor_idx { -let ch = KEYS[state.cursor_idx]; -match ch { -b'_' => { -if state.input_len < state.input_buf.len() { -state.input_buf[state.input_len] = b' '; -state.input_len += 1; -} -} -b'<' => { -if state.input_len > 0 { -state.input_len -= 1; -} -} -b'>' => { -state.push_message(true); -state.screen = Screen::ChatView; -} -_ => { -if state.input_len < state.input_buf.len() { -state.input_buf[state.input_len] = ch; -state.input_len += 1; -} -} -} -} else { -state.cursor_idx = target_idx; -} -} -} -}, -RESUME => {} -_ => continue, -} -draw(api, &state); -} -} -} diff --git a/apps/telegram/store.md b/apps/telegram/store.md deleted file mode 100644 index 999f09f..0000000 --- a/apps/telegram/store.md +++ /dev/null @@ -1,6 +0,0 @@ -A lightweight Telegram client for CMF Watch Pro 2 inspired by Apple Watch. - -### Features -- View all your chats and unread counters -- Read message bubbles in chat view -- Type replies freely using the built-in Touchpad keyboard or the digital crown diff --git a/apps/telegram/store.toml b/apps/telegram/store.toml deleted file mode 100644 index bf282e4..0000000 --- a/apps/telegram/store.toml +++ /dev/null @@ -1,4 +0,0 @@ -name = "Telegram" -summary = "Telegram client in Apple Watch style with touchpad keyboard" -version = "0.1.0" -author = "weasters" diff --git a/apps/tetris/Cargo.toml b/apps/tetris/Cargo.toml deleted file mode 100644 index bd20d9f..0000000 --- a/apps/tetris/Cargo.toml +++ /dev/null @@ -1,13 +0,0 @@ -[package] -name = "tetris" -edition.workspace = true -license.workspace = true -version.workspace = true - -[dependencies] -cmf-wp2-app.workspace = true -cmf-wp2-ui.workspace = true - -[[bin]] -name = "tetris" -bench = false diff --git a/apps/tetris/icon.svg b/apps/tetris/icon.svg deleted file mode 100644 index 4444f9d..0000000 --- a/apps/tetris/icon.svg +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/apps/tetris/shots/over.png b/apps/tetris/shots/over.png deleted file mode 100644 index f1230b9..0000000 Binary files a/apps/tetris/shots/over.png and /dev/null differ diff --git a/apps/tetris/shots/playing.png b/apps/tetris/shots/playing.png deleted file mode 100644 index 1dfd8c5..0000000 Binary files a/apps/tetris/shots/playing.png and /dev/null differ diff --git a/apps/tetris/shots/ready.png b/apps/tetris/shots/ready.png deleted file mode 100644 index 3ecb3ab..0000000 Binary files a/apps/tetris/shots/ready.png and /dev/null differ diff --git a/apps/tetris/src/game.rs b/apps/tetris/src/game.rs deleted file mode 100644 index 82a6823..0000000 --- a/apps/tetris/src/game.rs +++ /dev/null @@ -1,816 +0,0 @@ -// The game itself: no Api, so `cargo test` runs it on the host. Time comes in as `now` (ms, wrapping), so the game -// never sleeps and never needs a fixed tick: `wake_in` says when something is next due, `tick` does it. - -/// The well: 10 columns, 20 rows. Row 0 is the top. -pub const W: usize = 10; -pub const H: usize = 20; - -/// Piece kinds, in the order of their colours: I O T S Z J L. -pub const KINDS: u8 = 7; -const I: u8 = 0; -const O: u8 = 1; - -/// Milliseconds per row at levels 1..=20 (the last one holds from then on). -const GRAVITY: [u32; 20] = [800, 720, 630, 550, 470, 380, 300, 220, 130, 100, 83, 83, 83, 67, 67, 67, 50, 50, 50, 33]; -/// Milliseconds per row while the finger is held on the screen. -pub const SOFT_MS: u32 = 45; -/// A piece that has landed can still be pushed around for this long; moving it gives the time back, 12 times at most. -pub const LOCK_MS: u32 = 500; -const SOFT_LOCK_MS: u32 = 120; -const MAX_RESETS: u8 = 12; -/// Cleared rows blink: this many steps of this many ms (odd steps are white), then they are gone. -pub const FLASH_STEPS: u8 = 6; -pub const FLASH_MS: u32 = 70; -/// Rows cleared at once: 1, 2, 3, 4. Times the level. -const LINE_POINTS: [u32; 5] = [0, 100, 300, 500, 800]; -/// A score the HUD can show. -pub const SCORE_MAX: u32 = 999_999; - -#[derive(Clone, Copy, PartialEq, Eq, Debug)] -pub enum State { - /// Title screen, waiting for a tap. - Ready, - Playing, - /// The stack reached the top. - Over, -} - -#[derive(Clone, Copy, PartialEq, Eq, Debug)] -pub enum Step { - Nothing, - /// A piece came to rest and joined the stack. - Locked, - /// A piece joined the stack and this many rows (1..=4) are going. - Cleared(u8), - Crashed, -} - -/// A piece: its kind, how often it is turned clockwise (0..=3) and where the top left of its 4x4 box is. `y` can be -/// negative: the I piece spawns with its box one row above the well. -#[derive(Clone, Copy, PartialEq, Eq, Debug)] -pub struct Piece { - pub kind: u8, - pub rot: u8, - pub x: i32, - pub y: i32, -} - -/// The cells of each kind turned 0 times, in its box (the standard layout). -const BASE: [[(i32, i32); 4]; 7] = [ - [(0, 1), (1, 1), (2, 1), (3, 1)], // I - [(1, 0), (2, 0), (1, 1), (2, 1)], // O - [(1, 0), (0, 1), (1, 1), (2, 1)], // T - [(1, 0), (2, 0), (0, 1), (1, 1)], // S - [(0, 0), (1, 0), (1, 1), (2, 1)], // Z - [(0, 0), (0, 1), (1, 1), (2, 1)], // J - [(2, 0), (0, 1), (1, 1), (2, 1)], // L -]; - -/// The four cells of a kind turned `rot` times clockwise, relative to its box. -pub fn shape(kind: u8, rot: u8) -> [(i32, i32); 4] { - let mut c = BASE[kind as usize % KINDS as usize]; - if kind == O { - return c; // a square looks the same from every side - } - let n = if kind == I { 4 } else { 3 }; - for _ in 0..rot % 4 { - for p in c.iter_mut() { - *p = (n - 1 - p.1, p.0); - } - } - c -} - -impl Piece { - /// Where its cells are in the well. - pub fn cells(&self) -> [(i32, i32); 4] { - shape(self.kind, self.rot).map(|(x, y)| (self.x + x, self.y + y)) - } -} - -/// Where a turned piece may go if it does not fit where it is: sideways, then up. -const KICKS: [(i32, i32); 8] = [(0, 0), (-1, 0), (1, 0), (-2, 0), (2, 0), (0, -1), (-1, -1), (1, -1)]; - -#[derive(Clone, Copy, PartialEq, Eq, Debug)] -pub struct Flash { - /// Bit `y` is set for each full row. - pub rows: u32, - pub step: u8, - at: u32, -} - -impl Flash { - /// Rows show white on odd steps. - pub fn lit(&self) -> bool { - self.step % 2 == 1 - } -} - -#[derive(Clone)] -pub struct Game { - pub state: State, - /// 0 = empty, else the kind + 1 of the piece that left it there. - pub board: [[u8; W]; H], - /// The falling piece; `None` while rows blink. - pub cur: Option, - pub next: u8, - pub score: u32, - pub lines: u32, - pub flash: Option, - soft: bool, - drop_at: u32, - lock_at: Option, - resets: u8, - bag: [u8; 7], - bag_at: usize, - rng: u32, -} - -pub fn due(now: u32, at: u32) -> bool { - (now.wrapping_sub(at) as i32) >= 0 -} - -fn until(now: u32, at: u32) -> u32 { - if due(now, at) { 0 } else { at.wrapping_sub(now) } -} - -/// xorshift32: no random source on the watch, the app seeds it from the clock. -fn next(rng: &mut u32) -> u32 { - let mut x = *rng; - x ^= x << 13; - x ^= x >> 17; - x ^= x << 5; - *rng = x; - x -} - -impl Game { - pub fn new(seed: u32) -> Game { - Game { - state: State::Ready, - board: [[0; W]; H], - cur: None, - next: 0, - score: 0, - lines: 0, - flash: None, - soft: false, - drop_at: 0, - lock_at: None, - resets: 0, - bag: [0, 1, 2, 3, 4, 5, 6], - bag_at: 7, - rng: seed | 1, - } - } - - pub fn level(&self) -> u32 { - (self.lines / 10).min(19) - } - - /// Time between two falls of one row now. - pub fn interval(&self) -> u32 { - let g = GRAVITY[self.level() as usize]; - if self.soft { g.min(SOFT_MS) } else { g } - } - - /// The next piece of the bag; every seven draws hold each kind once. - fn draw(&mut self) -> u8 { - if self.bag_at >= 7 { - for i in (1..7).rev() { - let j = (next(&mut self.rng) % (i as u32 + 1)) as usize; - self.bag.swap(i, j); - } - self.bag_at = 0; - } - self.bag_at += 1; - self.bag[self.bag_at - 1] - } - - /// A new game, the first piece falling. - pub fn start(&mut self, now: u32) { - self.board = [[0; W]; H]; - self.score = 0; - self.lines = 0; - self.flash = None; - self.soft = false; - self.state = State::Playing; - self.bag_at = 7; - self.next = self.draw(); - self.spawn(now); - } - - pub fn fits(&self, p: &Piece) -> bool { - p.cells().iter().all(|&(x, y)| x >= 0 && x < W as i32 && y < H as i32 && (y < 0 || self.board[y as usize][x as usize] == 0)) - } - - /// The next piece comes in at the top. `false`: no room, the game is over. - fn spawn(&mut self, now: u32) -> bool { - let kind = self.next; - self.next = self.draw(); - let p = Piece { kind, rot: 0, x: 3, y: if kind == I { -1 } else { 0 } }; - self.cur = Some(p); - self.drop_at = now.wrapping_add(self.interval()); - self.lock_at = None; - self.resets = 0; - if self.fits(&p) { - true - } else { - self.state = State::Over; - false - } - } - - /// The piece can not fall further. - pub fn resting(&self) -> bool { - self.cur.is_some_and(|p| !self.fits(&Piece { y: p.y + 1, ..p })) - } - - fn lock_delay(&self) -> u32 { - if self.soft { SOFT_LOCK_MS } else { LOCK_MS } - } - - /// After the piece moved or turned (`by_hand`) or fell: start, restart or cancel the lock timer. - fn settle(&mut self, now: u32, by_hand: bool) { - let delay = self.lock_delay(); - if !self.resting() { - if self.lock_at.take().is_some() { - self.drop_at = now.wrapping_add(self.interval()); // slid off the edge: it falls on - } - } else if self.lock_at.is_none() { - self.lock_at = Some(now.wrapping_add(delay)); - } else if by_hand && self.resets < MAX_RESETS { - self.resets += 1; - self.lock_at = Some(now.wrapping_add(delay)); - } - } - - /// One column left (-1) or right (+1). - pub fn shift(&mut self, dx: i32, now: u32) -> bool { - let Some(p) = self.cur.filter(|_| self.state == State::Playing && self.flash.is_none()) else { return false }; - let q = Piece { x: p.x + dx, ..p }; - if !self.fits(&q) { - return false; - } - self.cur = Some(q); - self.settle(now, true); - true - } - - /// A quarter turn clockwise, pushed aside or up if the wall or the stack is in the way. - pub fn turn(&mut self, now: u32) -> bool { - let Some(p) = self.cur.filter(|_| self.state == State::Playing && self.flash.is_none()) else { return false }; - if p.kind == O { - return false; - } - for (dx, dy) in KICKS { - let q = Piece { rot: (p.rot + 1) % 4, x: p.x + dx, y: p.y + dy, ..p }; - if self.fits(&q) { - self.cur = Some(q); - self.settle(now, true); - return true; - } - } - false - } - - /// The finger is on (`true`) or off the screen: the piece falls faster while it is on. - pub fn set_soft(&mut self, on: bool, now: u32) { - if on == self.soft { - return; - } - self.soft = on; - if self.state != State::Playing || self.flash.is_some() { - return; - } - if on { - if until(now, self.drop_at) > SOFT_MS { - self.drop_at = now.wrapping_add(SOFT_MS); // the first row comes soon, not after the long wait - } - if let Some(l) = self.lock_at { - self.lock_at = Some(if until(now, l) > SOFT_LOCK_MS { now.wrapping_add(SOFT_LOCK_MS) } else { l }); - } - } else { - self.drop_at = now.wrapping_add(self.interval()); - } - } - - /// Where the piece would land. - pub fn ghost(&self) -> Option { - let mut p = self.cur?; - while self.fits(&Piece { y: p.y + 1, ..p }) { - p.y += 1; - } - Some(p) - } - - /// Milliseconds until `tick` has something to do; `None`: nothing is due, wait for input. - pub fn wake_in(&self, now: u32) -> Option { - if let Some(f) = self.flash { - return Some(until(now, f.at)); - } - if self.state != State::Playing || self.cur.is_none() { - return None; - } - Some(if self.resting() { until(now, self.lock_at.unwrap_or(now)) } else { until(now, self.drop_at) }) - } - - /// After a pause: nothing is overdue, and the finger is off. - pub fn rebase(&mut self, now: u32) { - self.soft = false; - if let Some(f) = &mut self.flash { - f.at = now.wrapping_add(FLASH_MS); - } - if self.lock_at.is_some() { - self.lock_at = Some(now.wrapping_add(LOCK_MS)); - } - self.drop_at = now.wrapping_add(self.interval()); - } - - /// Does what is due at `now`: one fall, the lock, or one blink. - pub fn tick(&mut self, now: u32) -> Step { - if let Some(mut f) = self.flash { - if !due(now, f.at) { - return Step::Nothing; - } - f.step += 1; - f.at = now.wrapping_add(FLASH_MS); - if f.step < FLASH_STEPS { - self.flash = Some(f); - return Step::Nothing; - } - self.flash = None; - self.remove(f.rows); - return if self.spawn(now) { Step::Nothing } else { Step::Crashed }; - } - let Some(p) = self.cur.filter(|_| self.state == State::Playing) else { return Step::Nothing }; - if self.resting() { - let at = *self.lock_at.get_or_insert(now.wrapping_add(self.lock_delay())); - return if due(now, at) { self.lock(now) } else { Step::Nothing }; - } - if due(now, self.drop_at) { - self.cur = Some(Piece { y: p.y + 1, ..p }); - if self.soft { - self.score = (self.score + 1).min(SCORE_MAX); - } - self.drop_at = now.wrapping_add(self.interval()); - self.settle(now, false); - } - Step::Nothing - } - - fn lock(&mut self, now: u32) -> Step { - let Some(p) = self.cur.take() else { return Step::Nothing }; - let mut out = false; - for (x, y) in p.cells() { - if y < 0 { - out = true; // locked above the well - } else { - self.board[y as usize][x as usize] = p.kind + 1; - } - } - if out { - self.state = State::Over; - return Step::Crashed; - } - let rows = (0..H).filter(|&y| self.board[y].iter().all(|&c| c != 0)).fold(0u32, |m, y| m | 1 << y); - let n = rows.count_ones() as usize; - if n == 0 { - return if self.spawn(now) { Step::Locked } else { Step::Crashed }; - } - self.score = (self.score + LINE_POINTS[n] * (self.level() + 1)).min(SCORE_MAX); - self.lines += n as u32; - self.flash = Some(Flash { rows, step: 0, at: now.wrapping_add(FLASH_MS) }); - Step::Cleared(n as u8) - } - - /// Takes the rows in `rows` out; what is above falls down. - fn remove(&mut self, rows: u32) { - let mut to = H; - for from in (0..H).rev() { - if rows >> from & 1 == 0 { - to -= 1; - self.board[to] = self.board[from]; - } - } - for row in &mut self.board[..to] { - *row = [0; W]; - } - } -} - -pub const MAGIC: &[u8; 2] = b"T1"; - -pub fn encode(best: u32) -> [u8; 6] { - let b = best.to_le_bytes(); - [MAGIC[0], MAGIC[1], b[0], b[1], b[2], b[3]] -} - -/// Anything that isn't a blob of ours is no best score yet. -pub fn decode(blob: &[u8]) -> u32 { - match blob { - [b'T', b'1', a, b, c, d] => u32::from_le_bytes([*a, *b, *c, *d]).min(SCORE_MAX), - _ => 0, - } -} - -#[cfg(test)] -mod tests { - use super::*; - - fn playing(seed: u32) -> Game { - let mut g = Game::new(seed); - g.start(0); - g - } - - /// Runs the game's clock until `ms` have passed, in 1 ms steps like a worst case of tiny wake-ups. - fn run(g: &mut Game, from: u32, ms: u32) -> (u32, Vec) { - let mut seen = Vec::new(); - for t in from..from + ms { - let s = g.tick(t); - if s != Step::Nothing { - seen.push(s); - } - } - (from + ms, seen) - } - - #[test] - fn every_piece_has_four_cells_in_its_box_and_turns_back_after_four() { - for kind in 0..KINDS { - for rot in 0..4 { - let c = shape(kind, rot); - for (i, a) in c.iter().enumerate() { - assert!(a.0 >= 0 && a.0 < 4 && a.1 >= 0 && a.1 < 4, "kind {kind} rot {rot} {a:?}"); - assert!(!c[i + 1..].contains(a), "kind {kind} rot {rot} repeats {a:?}"); - } - } - assert_eq!(shape(kind, 4), shape(kind, 0)); - } - } - - #[test] - fn turning_keeps_the_pieces_shape() { - // T: three in a row and one on top, whatever the turn: one cell touches the three others - for rot in 0..4 { - let c = shape(2, rot); - let touching = |a: (i32, i32)| c.iter().filter(|b| (a.0 - b.0).abs() + (a.1 - b.1).abs() == 1).count(); - assert_eq!(c.iter().map(|&a| touching(a)).max(), Some(3), "rot {rot}"); - } - // I: a line of four, flat or standing - let flat = shape(0, 0); - assert!(flat.iter().all(|c| c.1 == 1)); - let tall = shape(0, 1); - assert!(tall.iter().all(|c| c.0 == 2)); - } - - #[test] - fn the_bag_holds_each_kind_once_per_seven() { - let mut g = Game::new(99); - for _ in 0..20 { - let mut seen = [0; 7]; - for _ in 0..7 { - seen[g.draw() as usize] += 1; - } - assert_eq!(seen, [1; 7]); - } - } - - #[test] - fn every_kind_spawns_inside_the_well_and_fits() { - for kind in 0..KINDS { - let g = playing(5); - let p = Piece { kind, rot: 0, x: 3, y: if kind == I { -1 } else { 0 } }; - assert!(g.fits(&p), "kind {kind}"); - let top = p.cells().iter().map(|c| c.1).min().unwrap(); - assert_eq!(top, 0, "kind {kind} shows from the first row"); - } - } - - #[test] - fn a_piece_falls_one_row_per_interval() { - let mut g = playing(1); - let y0 = g.cur.unwrap().y; - run(&mut g, 0, 799); - assert_eq!(g.cur.unwrap().y, y0); - run(&mut g, 799, 2); - assert_eq!(g.cur.unwrap().y, y0 + 1); - run(&mut g, 801, 800); - assert_eq!(g.cur.unwrap().y, y0 + 2); - assert_eq!(g.wake_in(1601).map(|w| w <= 800), Some(true)); - } - - #[test] - fn it_lands_waits_half_a_second_and_locks() { - let mut g = playing(3); - // let it fall to the floor - let mut t = 0; - while !g.resting() { - t += 1; - g.tick(t); - assert!(t < 30_000); - } - let landed = t; - let (_, steps) = run(&mut g, landed + 1, LOCK_MS - 2); - assert!(steps.is_empty(), "{steps:?}"); - let (_, steps) = run(&mut g, landed + LOCK_MS - 1, 10); - assert_eq!(steps, vec![Step::Locked]); - assert!(g.board.iter().flatten().filter(|&&c| c != 0).count() == 4); - assert!(g.cur.is_some(), "the next piece is already in"); - } - - #[test] - fn walls_stop_the_piece_and_moves_into_them_say_so() { - let mut g = playing(7); - let mut n = 0; - while g.shift(-1, 0) { - n += 1; - assert!(n < 12); - } - assert!(g.cur.unwrap().cells().iter().any(|c| c.0 == 0)); - assert!(!g.shift(-1, 0)); - let mut m = 0; - while g.shift(1, 0) { - m += 1; - assert!(m < 20); - } - assert!(g.cur.unwrap().cells().iter().any(|c| c.0 == W as i32 - 1)); - assert!(m >= 6); - } - - #[test] - fn a_turn_next_to_the_wall_kicks_the_piece_back_in() { - // a standing I against the right wall turned flat would stick out: it is moved left - let mut g = playing(7); - g.cur = Some(Piece { kind: 0, rot: 1, x: 7, y: 5 }); // cells at x = 9 - assert!(g.fits(&g.cur.unwrap())); - assert!(g.turn(0)); - let p = g.cur.unwrap(); - assert!(g.fits(&p)); - assert_eq!(p.rot, 2); - assert!(p.cells().iter().all(|c| c.0 <= 9)); - // the square does not turn at all - g.cur = Some(Piece { kind: 1, rot: 0, x: 3, y: 5 }); - assert!(!g.turn(0)); - } - - #[test] - fn turning_is_refused_when_it_can_not_fit() { - let mut g = playing(7); - for y in 0..H { - for x in 0..W { - g.board[y][x] = 1; - } - } - // a one-cell-wide shaft, a flat I at the bottom of it - for y in 10..H { - g.board[y][4] = 0; - } - g.cur = Some(Piece { kind: 0, rot: 1, x: 2, y: 10 }); // standing in column 4 - assert!(g.fits(&g.cur.unwrap())); - let before = g.cur; - assert!(!g.turn(0)); - assert_eq!(g.cur, before); - } - - #[test] - fn full_rows_blink_then_go_and_the_rest_falls() { - let mut g = playing(2); - // two full rows with a gap at column 0, and a single block on top of them - for y in H - 2..H { - for x in 1..W { - g.board[y][x] = 3; - } - } - g.board[H - 3][5] = 6; - // a vertical I to fill column 0: x = -2 puts its cells in column 0 - g.cur = Some(Piece { kind: 0, rot: 1, x: -2, y: H as i32 - 4 }); - assert!(g.fits(&g.cur.unwrap())); - let level = g.level(); - let mut t = 0; - let mut got = None; - while got.is_none() && t < 5000 { - t += 1; - let s = g.tick(t); - if matches!(s, Step::Cleared(_)) { - got = Some(s); - } - } - assert_eq!(got, Some(Step::Cleared(2))); - assert_eq!(g.score, 300 * (level + 1)); - assert_eq!(g.lines, 2); - let f = g.flash.unwrap(); - assert_eq!(f.rows, 0b11 << (H - 2)); - assert!(g.cur.is_none()); - assert_eq!(g.wake_in(t), Some(FLASH_MS)); - // the blink runs, the rows go - let mut lit = 0; - for _ in 0..FLASH_STEPS as u32 * FLASH_MS + 5 { - t += 1; - if g.flash.is_some_and(|f| f.lit()) { - lit += 1; - } - g.tick(t); - } - assert!(lit > 100, "the rows blinked white"); - assert!(g.flash.is_none()); - assert!(g.cur.is_some(), "the next piece is in"); - // what was on top fell two rows: the single block and the top of the I piece (column 0) are at the bottom - assert_eq!(g.board[H - 1][5], 6); - assert_eq!(g.board[H - 1][0], 1); - assert_eq!(g.board[H - 2][0], 1); - assert_eq!(g.board[H - 1].iter().filter(|&&c| c != 0).count(), 2); - assert_eq!(g.board[H - 2].iter().filter(|&&c| c != 0).count(), 1); - assert!(g.board[..H - 2].iter().flatten().all(|&c| c == 0)); - } - - #[test] - fn a_tetris_scores_800_and_the_level_follows_the_lines() { - let mut g = playing(2); - for y in H - 4..H { - for x in 1..W { - g.board[y][x] = 2; - } - } - g.cur = Some(Piece { kind: 0, rot: 1, x: -2, y: H as i32 - 4 }); - let mut t = 0; - loop { - t += 1; - if let Step::Cleared(n) = g.tick(t) { - assert_eq!(n, 4); - break; - } - assert!(t < 5000); - } - assert_eq!(g.score, 800); - g.lines = 9; - assert_eq!(g.level(), 0); - g.lines = 10; - assert_eq!(g.level(), 1); - g.lines = 10_000; - assert_eq!(g.level(), 19); - assert!(g.interval() == 33); - } - - #[test] - fn holding_makes_it_fall_fast_and_scores_a_point_per_row() { - let mut g = playing(4); - let y0 = g.cur.unwrap().y; - g.set_soft(true, 10); - // first row after SOFT_MS, then one per SOFT_MS - run(&mut g, 10, SOFT_MS - 2); - assert_eq!(g.cur.unwrap().y, y0); - run(&mut g, 10 + SOFT_MS - 2, 3); - assert_eq!(g.cur.unwrap().y, y0 + 1); - run(&mut g, 10 + SOFT_MS + 1, 4 * SOFT_MS); - assert_eq!(g.cur.unwrap().y, y0 + 5); - assert_eq!(g.score, 5); - // letting go: back to the level's speed - let now = 10 + 5 * SOFT_MS + 1; - g.set_soft(false, now); - let y = g.cur.unwrap().y; - run(&mut g, now, 700); - assert_eq!(g.cur.unwrap().y, y); - run(&mut g, now + 700, 150); - assert_eq!(g.cur.unwrap().y, y + 1); - } - - #[test] - fn a_piece_on_the_floor_can_be_slid_but_not_forever() { - let mut g = playing(3); - let mut t = 0; - while !g.resting() { - t += 1; - g.tick(t); - } - // slide every 400 ms: the timer restarts, up to the cap, then the piece locks anyway - let landed = t; - let mut left = true; - let mut locked_at = None; - for _ in 0..40 { - t += 400; - for k in 0..400 { - if g.tick(t - 400 + k) != Step::Nothing { - locked_at = Some(t - 400 + k); - break; - } - } - if locked_at.is_some() { - break; - } - if !g.shift(if left { -1 } else { 1 }, t) { - left = !left; - g.shift(if left { -1 } else { 1 }, t); - } - if !g.resting() { - break; // slid off the stack: fine for this test - } - } - let n = (locked_at.expect("it locks") - landed) / 400; - assert!(n >= 2 && n <= 2 + MAX_RESETS as u32 + 2, "{n}"); - } - - #[test] - fn a_full_stack_ends_the_game() { - let mut g = playing(8); - for y in 0..H { - for x in 0..W { - g.board[y][x] = if x == 0 { 0 } else { 1 }; - } - } - // the next spawn has no room - g.board[0][0] = 1; - let mut t = 0; - let mut over = false; - while t < 3000 { - t += 1; - if g.tick(t) == Step::Crashed { - over = true; - break; - } - } - assert!(over); - assert_eq!(g.state, State::Over); - assert_eq!(g.wake_in(t), None); - assert!(!g.shift(1, t) && !g.turn(t)); - } - - #[test] - fn the_ghost_is_where_the_piece_lands() { - let mut g = playing(6); - let gh = g.ghost().unwrap(); - assert!(g.fits(&gh)); - assert!(!g.fits(&Piece { y: gh.y + 1, ..gh })); - assert_eq!((gh.kind, gh.rot, gh.x), (g.cur.unwrap().kind, g.cur.unwrap().rot, g.cur.unwrap().x)); - g.board[H - 1] = [1; W]; - let gh2 = g.ghost().unwrap(); - assert_eq!(gh2.y, gh.y - 1); - } - - #[test] - fn pausing_leaves_nothing_overdue() { - let mut g = playing(6); - let y = g.cur.unwrap().y; - g.rebase(1_000_000); - assert_eq!(g.tick(1_000_000), Step::Nothing); - assert_eq!(g.cur.unwrap().y, y); - assert!(g.wake_in(1_000_000).unwrap() > 700); - } - - #[test] - fn the_clock_may_wrap() { - let mut g = Game::new(3); - g.start(u32::MAX - 100); - let y = g.cur.unwrap().y; - let mut t = u32::MAX - 100; - for _ in 0..900 { - t = t.wrapping_add(1); - g.tick(t); - } - assert_eq!(g.cur.unwrap().y, y + 1); - } - - #[test] - fn best_score_blob_round_trips_and_rejects_junk() { - assert_eq!(decode(&encode(12345)), 12345); - assert_eq!(decode(&[]), 0); - assert_eq!(decode(b"SH1\x01\x00\x00\x00"), 0); - assert_eq!(decode(&encode(u32::MAX)), SCORE_MAX); - } - - /// Whatever is pressed, the stack never holds more than the well and every piece stays on the board. - #[test] - fn random_play_keeps_the_rules() { - for seed in 1..40u32 { - let mut g = playing(seed); - let mut r = seed * 7919; - let mut t = 0u32; - for _ in 0..30_000 { - t += 7; - match next(&mut r) % 9 { - 0 => { - g.shift(-1, t); - } - 1 => { - g.shift(1, t); - } - 2 => { - g.turn(t); - } - 3 => g.set_soft(next(&mut r) % 2 == 0, t), - _ => {} - } - g.tick(t); - if let Some(p) = g.cur { - if g.state == State::Playing { - assert!(g.fits(&p), "seed {seed} t {t}"); - } - } - if g.state == State::Over { - g.start(t); - } - } - } - } -} diff --git a/apps/tetris/src/main.rs b/apps/tetris/src/main.rs deleted file mode 100644 index c75593b..0000000 --- a/apps/tetris/src/main.rs +++ /dev/null @@ -1,170 +0,0 @@ -#![cfg_attr(any(target_os = "none", wp2_sim), no_main, cfg_attr(target_os = "none", no_std))] - -#[cfg_attr(not(any(target_os = "none", wp2_sim)), allow(dead_code))] -mod game; -#[cfg_attr(not(any(target_os = "none", wp2_sim)), allow(dead_code))] -mod view; - -#[cfg(not(any(target_os = "none", wp2_sim)))] -fn main() {} - -#[cfg(any(target_os = "none", wp2_sim))] -mod device { - use crate::game::{Game, State, Step, decode, due, encode}; - use crate::view::{frame, seen}; - use cmf_wp2_app::{Api, BUTTON, CROWN, PAUSE, RESUME, TOUCH_DOWN, TOUCH_UP}; - use cmf_wp2_ui::haptic::{DOUBLE, DONE, Motor, TICK}; - - cmf_wp2_app::entry!(main); - cmf_wp2_app::app_icon!(); - - /// A finger that stays on the glass this long is a hold (the piece drops fast), a shorter one is a tap (it turns). - const HOLD_MS: u32 = 220; - /// Taps right after the game ended don't start a new one: they were meant for the game that just ended. - const RETRY_MS: u32 = 700; - /// Turning the crown clockwise moves the piece right. Flip this if your watch counts the other way. - const CROWN_RIGHT: i16 = 1; - - // true on RESUME, false on BUTTON - fn paused(api: &Api) -> bool { - loop { - match api.event(u32::MAX).map(|e| e.kind) { - Some(RESUME) => return true, - Some(BUTTON) => return false, - _ => {} - } - } - } - - fn seed(api: &Api) -> u32 { - let t = api.time().map_or(0, |t| (t.minute as u32 * 60 + t.second as u32) * 1000 + t.millis as u32); - api.now().wrapping_mul(2_654_435_761) ^ t - } - - /// The finger on the glass: when it came down and what the game was doing then. - #[derive(Clone, Copy)] - struct Finger { - at: u32, - state: State, - holding: bool, - } - - fn main(api: &'static Api) -> i32 { - let mut screen = api; - let mut motor = Motor::new(api); // dropped on return: the motor goes off - let mut blob = [0u8; 16]; - let n = api.load(&mut blob); - let mut best = if n > 0 { decode(&blob[..n as usize]) } else { 0 }; - let mut g = Game::new(seed(api)); - let mut on_screen = Some(frame(&mut screen, &g, best, None)); - api.show(); - let mut finger: Option = None; - let mut over_at = 0u32; - loop { - motor.update(); - let now = api.now(); - // what is due next: the game, the end of a tap (a hold begins), the motor - let mut wait = g.wake_in(now).unwrap_or(u32::MAX); - if let Some(f) = finger.filter(|f| f.state == State::Playing && !f.holding) { - let left = (f.at.wrapping_add(HOLD_MS).wrapping_sub(now) as i32).max(0) as u32; - wait = wait.min(left); - } - if let Some(m) = motor.wait() { - wait = wait.min(m); - } - let mut first = api.event(wait); - let mut redraw_all = false; - let mut quit = false; - // handle this event and everything else already queued, then draw once - for _ in 0..16 { - let Some(e) = first.take().or_else(|| api.event(0)) else { break }; - let now = api.now(); - match e.kind { - BUTTON => quit = true, - PAUSE => { - motor.off(); - g.set_soft(false, now); - if !paused(api) { - quit = true; - } else { - finger = None; - g.rebase(api.now()); - redraw_all = true; - } - } - TOUCH_DOWN => { - finger = Some(Finger { at: now, state: g.state, holding: false }); - } - TOUCH_UP => { - let Some(f) = finger.take() else { continue }; - if f.holding { - g.set_soft(false, now); - } else if f.state != g.state { - // the game changed under the finger: this touch belonged to something else - } else { - match g.state { - State::Playing => { - g.turn(now); - } - State::Ready => g.start(now), - State::Over => { - if due(f.at, over_at.wrapping_add(RETRY_MS)) { - g.start(now); - } - } - } - } - } - CROWN => { - g.shift(if e.delta * CROWN_RIGHT > 0 { 1 } else { -1 }, now); - } - _ => {} - } - if quit { - break; - } - } - if quit { - api.keep_screen_on(false); - return 0; - } - let now = api.now(); - // a finger that stayed down: the piece drops - if let Some(f) = &mut finger { - if f.state == State::Playing && g.state == State::Playing && !f.holding && due(now, f.at.wrapping_add(HOLD_MS)) { - f.holding = true; - g.set_soft(true, now); - } - } - // what is due in the game; at most a few things per wake-up, the rest on the next one - for _ in 0..4 { - if g.wake_in(now) != Some(0) { - break; - } - match g.tick(now) { - Step::Locked => motor.play(TICK), - Step::Cleared(n) => motor.play(if n >= 4 { DONE } else { DOUBLE }), - Step::Crashed => { - motor.play(DONE); - over_at = now; - if g.score > best { - best = g.score; - api.save(&encode(best)); // on change: the app can be ended without notice - } - } - Step::Nothing => {} - } - } - if g.state == State::Over && finger.is_some_and(|f| f.state == State::Playing) { - finger = None; // the hold that ended the game ends with it - } - let before = on_screen; - let now_seen = seen(&g, best); - if redraw_all || before != Some(now_seen) { - on_screen = Some(frame(&mut screen, &g, best, if redraw_all { None } else { before })); - api.show(); - } - api.keep_screen_on(g.state == State::Playing); - } - } -} diff --git a/apps/tetris/src/view.rs b/apps/tetris/src/view.rs deleted file mode 100644 index 058102f..0000000 --- a/apps/tetris/src/view.rs +++ /dev/null @@ -1,569 +0,0 @@ -// Drawing, through cmf-wp2-ui's Surface: the watch draws with `&Api`, the tests with `Fb`. One buffer and no double -// buffering, so a frame repaints only the cells and numbers that changed, and never paints a pixel twice in different -// colours: each cell is its own 20 px square, filled and then drawn on once. - -use crate::game::{Game, H, SCORE_MAX, State, W, shape}; -use cmf_wp2_ui::draw::rrect; -use cmf_wp2_ui::text::{big, big_width, centre, int, width}; -use cmf_wp2_ui::{C, Rgb, Surface}; - -pub const SIZE: i32 = cmf_wp2_ui::SIZE; -/// A cell, and the well's top left corner: 200 x 400 px, centred. Its far corners sit 224 px from the centre, inside -/// the round panel (233). -pub const CELL: i32 = 20; -pub const BX: i32 = C - W as i32 * CELL / 2; -pub const BY: i32 = C - H as i32 * CELL / 2; - -const BLACK: u16 = 0; -const WELL: Rgb = Rgb(9, 10, 14); -const DOT: Rgb = Rgb(30, 33, 44); -const FRAME: Rgb = Rgb(58, 63, 82); -const PANEL: Rgb = Rgb(20, 22, 30); -const WHITE: Rgb = Rgb(255, 255, 255); -const GREY: u16 = 0x8C71; -const TEAL: Rgb = Rgb(94, 230, 168); - -/// I O T S Z J L -pub const COLORS: [Rgb; 7] = [ - Rgb(62, 214, 230), - Rgb(255, 201, 60), - Rgb(160, 108, 240), - Rgb(94, 230, 168), - Rgb(242, 87, 95), - Rgb(60, 130, 240), - Rgb(255, 148, 64), -]; - -/// What a cell shows: 0 empty, 1..=7 a block of that kind, GHOST + kind where the piece would land, FLASH a -/// blinking row. -const GHOST: u8 = 8; -const FLASH: u8 = 15; - -/// The HUD: numbers right-aligned at LEFT_X on the left of the well, the next piece and the best score on the right. -const LEFT_X: i32 = BX - 12; -const RIGHT_X: i32 = BX + W as i32 * CELL + 14; -const FIELD_W: i32 = 96; -const SCORE_Y: i32 = 140; -const LINES_Y: i32 = 206; -const LEVEL_Y: i32 = 272; -const NEXT_Y: i32 = 140; -const BEST_Y: i32 = 272; - -/// What is on screen after a frame. -#[derive(Clone, Copy, PartialEq, Debug)] -pub struct Seen { - cells: [[u8; W]; H], - score: u32, - lines: u32, - level: u32, - next: u8, - best: u32, - state: State, -} - -fn compose(g: &Game) -> [[u8; W]; H] { - if g.state == State::Ready { - return [[0; W]; H]; - } - let mut c = g.board; - if g.state == State::Playing && g.flash.is_none() { - if let Some(gh) = g.ghost() { - for (x, y) in gh.cells() { - if y >= 0 && c[y as usize][x as usize] == 0 { - c[y as usize][x as usize] = GHOST + gh.kind; - } - } - } - } - if let Some(p) = g.cur { - for (x, y) in p.cells() { - if y >= 0 { - c[y as usize][x as usize] = p.kind + 1; - } - } - } - if let Some(f) = g.flash.filter(|f| f.lit()) { - for (y, row) in c.iter_mut().enumerate() { - if f.rows >> y & 1 == 1 { - *row = [FLASH; W]; - } - } - } - c -} - -pub fn seen(g: &Game, best: u32) -> Seen { - Seen { - cells: compose(g), - score: g.score.min(SCORE_MAX), - lines: g.lines.min(9999), - level: g.level() + 1, - next: g.next, - best: best.min(SCORE_MAX), - state: g.state, - } -} - -/// A block of `size` px: a darker rim, a lit face and a small sheen, like the icon. -fn tile(s: &mut impl Surface, x: i32, y: i32, size: i32, c: Rgb, bg: Rgb) { - let r = size / 4; - let dark = c.scale(680); - rrect(s, x + 1, y + 1, size - 2, size - 2, r + 1, dark, bg); - rrect(s, x + 2, y + 2, size - 4, size - 5, r, c, dark); - rrect(s, x + size / 4 + 1, y + size / 5 + 1, size / 2, 2, 1, c.mix(WHITE, 470), c); -} - -/// The outline of where the piece will land. -fn ghost(s: &mut impl Surface, x: i32, y: i32, c: Rgb) { - let dim = c.scale(420); - rrect(s, x + 1, y + 1, CELL - 2, CELL - 2, 5, dim, WELL); - rrect(s, x + 3, y + 3, CELL - 6, CELL - 6, 3, WELL, dim); -} - -fn cell(s: &mut impl Surface, cx: usize, cy: usize, v: u8) { - let (x, y) = (BX + cx as i32 * CELL, BY + cy as i32 * CELL); - s.rect(x, y, CELL, CELL, WELL.rgb565()); - match v { - 0 => s.rect(x + CELL / 2 - 1, y + CELL / 2 - 1, 2, 2, DOT.rgb565()), - 1..=7 => tile(s, x, y, CELL, COLORS[v as usize - 1], WELL), - GHOST..=14 => ghost(s, x, y, COLORS[(v - GHOST) as usize]), - _ => tile(s, x, y, CELL, Rgb(245, 248, 255), WELL), - } -} - -/// A number in a box, right-aligned at `xr`. -fn field(s: &mut impl Surface, xr: i32, y: i32, n: u32, c: u16) { - let mut buf = [0u8; 11]; - let t = int(n as i32, &mut buf); - s.rect(xr - FIELD_W, y, FIELD_W, 16, BLACK); - s.text(xr - width(t), y, t, c); -} - -fn label(s: &mut impl Surface, xr: i32, y: i32, t: &str) { - s.text(xr - width(t), y - 20, t, GREY); -} - -fn next_box(s: &mut impl Surface, kind: u8) { - const BW: i32 = 84; - const BH: i32 = 64; - const T: i32 = 14; - rrect(s, RIGHT_X, NEXT_Y + 2, BW, BH, 14, PANEL, Rgb(0, 0, 0)); - let c = shape(kind, 0); - let (x0, x1) = (c.iter().map(|p| p.0).min().unwrap_or(0), c.iter().map(|p| p.0).max().unwrap_or(0)); - let (y0, y1) = (c.iter().map(|p| p.1).min().unwrap_or(0), c.iter().map(|p| p.1).max().unwrap_or(0)); - let (w, h) = ((x1 - x0 + 1) * T, (y1 - y0 + 1) * T); - let (ox, oy) = (RIGHT_X + (BW - w) / 2, NEXT_Y + 2 + (BH - h) / 2); - for (px, py) in c { - tile(s, ox + (px - x0) * T, oy + (py - y0) * T, T, COLORS[kind as usize % 7], PANEL); - } -} - -fn hud(s: &mut impl Surface, n: &Seen, p: Option<&Seen>) { - let changed = |f: fn(&Seen) -> u32| p.is_none_or(|p| f(p) != f(n)); - if p.is_none() { - label(s, LEFT_X, SCORE_Y, "SCORE"); - label(s, LEFT_X, LINES_Y, "LINES"); - label(s, LEFT_X, LEVEL_Y, "LEVEL"); - s.text(RIGHT_X + 2, NEXT_Y - 20, "NEXT", GREY); - s.text(RIGHT_X + 2, BEST_Y - 20, "BEST", GREY); - } - if changed(|s| s.score) { - field(s, LEFT_X, SCORE_Y, n.score, WHITE.rgb565()); - } - if changed(|s| s.lines) { - field(s, LEFT_X, LINES_Y, n.lines, TEAL.rgb565()); - } - if changed(|s| s.level) { - field(s, LEFT_X, LEVEL_Y, n.level, TEAL.rgb565()); - } - if p.is_none_or(|p| p.next != n.next) { - next_box(s, n.next); - } - if changed(|s| s.best) { - // left-aligned under its label - let mut buf = [0u8; 11]; - let t = int(n.best as i32, &mut buf); - s.rect(RIGHT_X, BEST_Y, FIELD_W, 16, BLACK); - s.text(RIGHT_X + 2, BEST_Y, t, WHITE.rgb565()); - } -} - -fn frame_bars(s: &mut impl Surface) { - let h = H as i32 * CELL; - let w = W as i32 * CELL; - s.rect(BX - 4, BY, 2, h + 4, FRAME.rgb565()); - s.rect(BX + w + 2, BY, 2, h + 4, FRAME.rgb565()); - s.rect(BX - 4, BY + h + 2, w + 8, 2, FRAME.rgb565()); -} - -/// The big title: each letter in the colour of a piece. -fn title(s: &mut impl Surface, y: i32) { - const T: &str = "TETRIS"; - let x = C - big_width(T, 5) / 2; - for (i, ch) in T.char_indices() { - let mut one = [0u8; 4]; - let t = ch.encode_utf8(&mut one); - big(s, x + i as i32 * 40, y, t, 5, COLORS[[2, 4, 1, 0, 3, 5][i]].rgb565()); - } -} - -fn ready(s: &mut impl Surface, best: u32) { - s.rect(0, 0, SIZE, SIZE, BLACK); - title(s, 70); - // a T piece about to drop into the gap in the row under it - const P: i32 = 34; - let (x0, y0) = (C - (3 * P - 2) / 2, 142); - let black = Rgb(0, 0, 0); - for (cx, cy, k, dim) in [(0, 0, 2, false), (1, 0, 2, false), (2, 0, 2, false), (1, 1, 2, false), (0, 2, 5, true), (2, 2, 5, true)] { - let c = COLORS[k]; - tile(s, x0 + cx * P, y0 + cy * P, P - 2, if dim { c.scale(500) } else { c }, black); - } - centre(s, C, 268, "TAP TO PLAY", WHITE.rgb565()); - centre(s, C, 312, "TAP: TURN", GREY); - centre(s, C, 334, "HOLD: DROP", GREY); - centre(s, C, 356, "CROWN: MOVE", GREY); - if best > 0 { - let mut buf = [0u8; 11]; - let mut line = [0u8; 16]; - let n = int(best as i32, &mut buf).as_bytes(); - line[..5].copy_from_slice(b"BEST "); - line[5..5 + n.len()].copy_from_slice(n); - centre(s, C, 396, core::str::from_utf8(&line[..5 + n.len()]).unwrap_or("?"), TEAL.rgb565()); - } -} - -fn over(s: &mut impl Surface, n: &Seen) { - let (w, h) = (192, 176); - let (x, y) = (C - w / 2, 136); - rrect(s, x, y, w, h, 22, PANEL, WELL); - let red = COLORS[4].rgb565(); - big(s, C - big_width("GAME", 3) / 2, y + 14, "GAME", 3, red); - big(s, C - big_width("OVER", 3) / 2, y + 42, "OVER", 3, red); - let mut buf = [0u8; 11]; - centre(s, C, y + 86, int(n.score as i32, &mut buf), WHITE.rgb565()); - let mut line = [0u8; 16]; - let b = int(n.best as i32, &mut buf).as_bytes(); - line[..5].copy_from_slice(b"BEST "); - line[5..5 + b.len()].copy_from_slice(b); - centre(s, C, y + 110, core::str::from_utf8(&line[..5 + b.len()]).unwrap_or("?"), TEAL.rgb565()); - centre(s, C, y + 146, "TAP TO PLAY", GREY); -} - -/// Draws the frame for `g`. `prev`: what is on screen now; `None`, or another state, repaints everything. -pub fn frame(s: &mut impl Surface, g: &Game, best: u32, prev: Option) -> Seen { - let now = seen(g, best); - match prev.filter(|p| p.state == now.state) { - None => { - if now.state == State::Ready { - ready(s, best); - } else { - s.rect(0, 0, SIZE, SIZE, BLACK); - frame_bars(s); - for (y, row) in now.cells.iter().enumerate() { - for (x, &v) in row.iter().enumerate() { - cell(s, x, y, v); - } - } - hud(s, &now, None); - if now.state == State::Over { - over(s, &now); - } - } - } - Some(p) => { - if now.state == State::Playing { - for (y, (a, b)) in p.cells.iter().zip(&now.cells).enumerate() { - for (x, (&u, &v)) in a.iter().zip(b).enumerate() { - if u != v { - cell(s, x, y, v); - } - } - } - hud(s, &now, Some(&p)); - } - } - } - now -} - -#[cfg(test)] -mod tests { - use super::*; - use crate::game::Piece; - use cmf_wp2_ui::{Count, Fb}; - use std::vec; - use std::vec::Vec; - - fn screen() -> Vec { - vec![0u16; (SIZE * SIZE) as usize] - } - - fn full(g: &Game, best: u32) -> Vec { - let mut px = screen(); - frame(&mut Fb::new(&mut px), g, best, None); - px - } - - fn playing(seed: u32) -> Game { - let mut g = Game::new(seed); - g.start(0); - g - } - - fn inside(x: i32, y: i32) -> bool { - (x - C) * (x - C) + (y - C) * (y - C) <= C * C - } - - #[test] - fn the_well_and_its_frame_lie_inside_the_round_panel() { - let (w, h) = (W as i32 * CELL, H as i32 * CELL); - for (x, y) in [(BX - 4, BY), (BX + w + 4, BY), (BX - 4, BY + h + 4), (BX + w + 4, BY + h + 4)] { - assert!(inside(x, y), "({x}, {y}) is off the panel"); - } - assert_eq!((BX, BY), (133, 33)); - } - - #[test] - fn the_hud_lies_inside_the_round_panel() { - // every text and box: its corners (a label is 5 chars, a number up to 6, the next box 84 x 66) - let right = RIGHT_X + FIELD_W; - for (x0, x1, y0, y1) in [ - (LEFT_X - 80, LEFT_X, SCORE_Y - 20, SCORE_Y - 4), - (LEFT_X - FIELD_W, LEFT_X, SCORE_Y, SCORE_Y + 16), - (LEFT_X - 80, LEFT_X, LINES_Y - 20, LINES_Y + 16), - (LEFT_X - 80, LEFT_X, LEVEL_Y - 20, LEVEL_Y + 16), - (RIGHT_X, RIGHT_X + 64, NEXT_Y - 20, NEXT_Y - 4), - (RIGHT_X, RIGHT_X + 84, NEXT_Y + 2, NEXT_Y + 66), - (RIGHT_X, right, BEST_Y - 20, BEST_Y + 16), - ] { - for (x, y) in [(x0, y0), (x1, y0), (x0, y1), (x1, y1)] { - assert!(inside(x, y), "({x}, {y})"); - } - } - } - - #[test] - fn the_title_screens_text_fits_the_panel() { - let wide = |t: &str, y: i32| { - let w = width(t); - assert!(inside(C - w / 2, y) && inside(C + w / 2, y) && inside(C - w / 2, y + 16) && inside(C + w / 2, y + 16), "{t}"); - }; - wide("TAP TO PLAY", 268); - wide("CROWN: MOVE", 356); - wide("BEST 999999", 396); - let tw = big_width("TETRIS", 5); - assert!(inside(C - tw / 2, 70) && inside(C + tw / 2, 110)); - } - - /// Plays on its own for a while and, now and then, compares what the partial frames made with a full repaint. - #[test] - fn partial_frames_match_a_full_repaint() { - for seed in [1u32, 8, 77] { - let mut g = playing(seed); - let mut px = screen(); - let mut prev = None; - let mut r = seed.wrapping_mul(2_654_435_761) | 1; - let mut rnd = move || { - r ^= r << 13; - r ^= r >> 17; - r ^= r << 5; - r - }; - let mut checked = 0; - let mut t = 0u32; - for step in 0..6000u32 { - t += 16; - match rnd() % 11 { - 0 | 1 => { - g.shift(-1, t); - } - 2 | 3 => { - g.shift(1, t); - } - 4 => { - g.turn(t); - } - 5 => g.set_soft(rnd() % 3 != 0, t), - _ => {} - } - g.tick(t); - if g.state == State::Over { - prev = Some(frame(&mut Fb::new(&mut px), &g, 3, prev)); - assert_eq!(px, full(&g, 3), "over, seed {seed}"); - g.start(t); - prev = None; - } - prev = Some(frame(&mut Fb::new(&mut px), &g, 3, prev)); - if step % 9 == 0 { - let want = full(&g, 3); - let bad = px.iter().zip(&want).position(|(a, b)| a != b); - assert_eq!(bad.map(|i| (i as i32 % SIZE, i as i32 / SIZE)), None, "seed {seed} step {step}"); - checked += 1; - } - } - assert!(checked > 100); - } - } - - #[test] - fn a_still_frame_draws_nothing() { - for state in [State::Ready, State::Playing] { - let mut g = Game::new(4); - if state == State::Playing { - g.start(0); - } - let mut px = screen(); - let mut fb = Fb::new(&mut px); - let p = frame(&mut fb, &g, 10, None); - let rects = fb.rects; - assert!(rects > 0); - frame(&mut fb, &g, 10, Some(p)); - assert_eq!(fb.rects, rects, "{state:?}"); - } - } - - #[test] - fn a_move_costs_a_handful_of_cells_not_the_screen() { - let mut g = playing(5); - let mut px = screen(); - let mut fb = Fb::new(&mut px); - let p = frame(&mut fb, &g, 0, None); - let first = fb.rects; - g.shift(1, 10); - fb.rects = 0; - let p = frame(&mut fb, &g, 0, Some(p)); - let move_cost = fb.rects; - // the piece and its guide change cells: at most 16 of them, a few rects each - assert!(move_cost > 0 && move_cost < 700, "{move_cost}"); - assert!(move_cost * 8 < first, "{move_cost} vs a full paint of {first}"); - g.turn(20); - fb.rects = 0; - frame(&mut fb, &g, 0, Some(p)); - assert!(fb.rects < 900, "{}", fb.rects); - // and a full repaint is cheap enough to do at any time - let mut c = Count::default(); - frame(&mut c, &g, 0, None); - assert!(c.rects < 3000, "{}", c.rects); - } - - #[test] - fn cells_stay_inside_their_squares() { - // draw each kind of cell on a marked background and look for pixels outside the 20 px square - for v in 0..=FLASH { - if (9..GHOST).contains(&v) { - continue; - } - let mut px = vec![0xABCDu16; (SIZE * SIZE) as usize]; - cell(&mut Fb::new(&mut px), 3, 4, v); - let (x0, y0) = (BX + 3 * CELL, BY + 4 * CELL); - for y in 0..SIZE { - for x in 0..SIZE { - let inside = x >= x0 && x < x0 + CELL && y >= y0 && y < y0 + CELL; - if !inside { - assert_eq!(px[(y * SIZE + x) as usize], 0xABCD, "value {v} spilled to ({x}, {y})"); - } - } - } - } - } - - #[test] - fn each_kind_has_its_own_colour_on_screen() { - let mut seen = Vec::new(); - for k in 1..=7u8 { - let mut px = screen(); - cell(&mut Fb::new(&mut px), 0, 0, k); - seen.push(px[((BY + 10) * SIZE + BX + 8) as usize]); - } - seen.sort(); - seen.dedup(); - assert_eq!(seen.len(), 7); - } - - #[test] - fn the_ghost_shows_under_the_piece_and_not_over_blocks() { - let mut g = playing(6); - g.cur = Some(Piece { kind: 2, rot: 0, x: 3, y: 0 }); - let c = compose(&g); - let gh = g.ghost().unwrap(); - for (x, y) in gh.cells() { - assert_eq!(c[y as usize][x as usize], GHOST + 2); - } - for (x, y) in g.cur.unwrap().cells() { - assert_eq!(c[y as usize][x as usize], 3); - } - // locked blocks are never overdrawn by the guide - g.board[H - 1] = [4; W]; - let c = compose(&g); - assert!(c[H - 1].iter().all(|&v| v == 4)); - } - - #[test] - fn a_blinking_row_is_white_every_other_step() { - let mut g = playing(2); - for y in H - 1..H { - for x in 1..W { - g.board[y][x] = 2; - } - } - g.cur = Some(Piece { kind: 0, rot: 1, x: -2, y: H as i32 - 4 }); - let mut t = 0; - while g.flash.is_none() { - t += 1; - g.tick(t); - assert!(t < 5000); - } - let mut saw = (false, false); - for _ in 0..600 { - t += 1; - g.tick(t); - if let Some(f) = g.flash { - let c = compose(&g); - if f.lit() { - assert_eq!(c[H - 1], [FLASH; W]); - saw.0 = true; - } else { - assert_ne!(c[H - 1], [FLASH; W]); - saw.1 = true; - } - } - } - assert_eq!(saw, (true, true)); - } - - /// `PREVIEW=/abs/dir cargo test dump_preview`: raw RGB565 frames of the screen, for pictures. - #[test] - fn dump_preview() { - let Ok(dir) = std::env::var("PREVIEW") else { return }; - let save = |name: &str, px: &[u16]| { - let bytes: Vec = px.iter().flat_map(|v| v.to_le_bytes()).collect(); - std::fs::write(format!("{dir}/{name}.raw"), bytes).unwrap(); - }; - let g = Game::new(3); - save("ready", &full(&g, 12400)); - // a game in progress: pile some random blocks, a falling piece, and a few cleared rows - let mut g = playing(11); - let rows: [&str; 8] = ["IIIIZZ.TTT", "OO.JJJ.ZZT", "OOSSJLLLZZ", "TTTSSLJJJZ", "ZZ.OOLJ.SS", ".ZZOOL.SSL", "LLL.TTTSSL", "LJJJ.T.ZZL"]; - for (i, r) in rows.iter().enumerate() { - for (x, ch) in r.chars().enumerate() { - g.board[H - 8 + i][x] = match ch { - 'I' => 1, - 'O' => 2, - 'T' => 3, - 'S' => 4, - 'Z' => 5, - 'J' => 6, - 'L' => 7, - _ => 0, - }; - } - } - g.score = 4350; - g.lines = 23; - g.cur = Some(Piece { kind: 2, rot: 1, x: 4, y: 6 }); - save("playing", &full(&g, 12400)); - let mut g2 = g.clone(); - g2.state = State::Over; - save("over", &full(&g2, 12400)); - } -} diff --git a/apps/tetris/store.md b/apps/tetris/store.md deleted file mode 100644 index a29b5da..0000000 --- a/apps/tetris/store.md +++ /dev/null @@ -1,13 +0,0 @@ -Falling blocks on your wrist. Pieces drop into a 10 by 20 well: fill a row and it clears. Clear ten rows and the -pieces fall faster. A faint outline shows where the piece will land. Your best score is kept on the watch. - -- **Turn the crown** to move the piece left and right. -- **Tap** the screen to turn it. -- **Hold** your finger on the screen to drop it faster. - -Press the crown or swipe right to leave. - -## Requirements - -The [patched firmware](/firmware) and the [App Loader](/firmware). Open it from the **Apps** row at the end of the -watch's app list (list style, not the waterfall). diff --git a/apps/tetris/store.toml b/apps/tetris/store.toml deleted file mode 100644 index e9ceacd..0000000 --- a/apps/tetris/store.toml +++ /dev/null @@ -1,6 +0,0 @@ -# The app's listing in the FMC store (README.md, "store.toml"). The page's body is store.md. -name = "Tetris" -summary = "Falling blocks. Crown moves, tap turns, hold drops" -version = "0.1.0" -author = "arunk140" -screenshots = ["shots/ready.png", "shots/playing.png", "shots/over.png"] diff --git a/apps/tic-tac-toe/Cargo.toml b/apps/tic-tac-toe/Cargo.toml deleted file mode 100644 index a65107d..0000000 --- a/apps/tic-tac-toe/Cargo.toml +++ /dev/null @@ -1,12 +0,0 @@ -[package] -name = "tic-tac-toe" -edition.workspace = true -license.workspace = true -version.workspace = true - -[dependencies] -cmf-wp2-app.workspace = true - -[[bin]] -name = "tic-tac-toe" -bench = false diff --git a/apps/tic-tac-toe/icon.svg b/apps/tic-tac-toe/icon.svg deleted file mode 100644 index 9fff403..0000000 --- a/apps/tic-tac-toe/icon.svg +++ /dev/null @@ -1,429 +0,0 @@ - -Dot Tic-Tac-Toe - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/apps/tic-tac-toe/src/main.rs b/apps/tic-tac-toe/src/main.rs deleted file mode 100644 index 4c324c5..0000000 --- a/apps/tic-tac-toe/src/main.rs +++ /dev/null @@ -1,413 +0,0 @@ -#![cfg_attr(not(test), no_std)] -#![cfg_attr(not(test), no_main)] - -#[cfg(not(test))] -cmf_wp2_app::app_icon!(); - -use cmf_wp2_app::{Api, BUTTON, CROWN, TOUCH_DOWN}; - -#[cfg(not(test))] -cmf_wp2_app::entry!(main); -#[cfg(not(test))] -cmf_wp2_app::app_features!(cmf_wp2_app::WIDGET | cmf_wp2_app::PAGE); - -const BG_COLOR: u16 = 0x0000; -const GRID_DOT_COLOR: u16 = 0x52AA; -const BEZEL_DOT_COLOR: u16 = 0x2945; -const WHITE: u16 = 0xFFFF; -const CMF_ORANGE: u16 = 0xFA60; -const WIN_COLOR: u16 = 0xF800; - -const BOARD_SIZE: i16 = 276; -const CELL_SIZE: i16 = BOARD_SIZE / 3; - -const MATRIX_X: [u8; 25] = [ - 1, 0, 0, 0, 1, - 0, 1, 0, 1, 0, - 0, 0, 1, 0, 0, - 0, 1, 0, 1, 0, - 1, 0, 0, 0, 1, -]; - -const MATRIX_O: [u8; 25] = [ - 0, 1, 1, 1, 0, - 1, 0, 0, 0, 1, - 1, 0, 0, 0, 1, - 1, 0, 0, 0, 1, - 0, 1, 1, 1, 0, -]; - -const WIN_LINES: [usize; 24] = [ - 0, 1, 2, - 3, 4, 5, - 6, 7, 8, - 0, 3, 6, - 1, 4, 7, - 2, 5, 8, - 0, 4, 8, - 2, 4, 6, -]; - -fn draw_dot(api: &Api, cx: i16, cy: i16, r: i16, color: u16) { - if r <= 0 { - return; - } - if r == 1 { - api.rect(cx, cy, 2, 2, color); - return; - } - if r == 2 { - api.rect(cx - 1, cy - 2, 3, 5, color); - api.rect(cx - 2, cy - 1, 5, 3, color); - return; - } - if r == 3 { - api.rect(cx - 1, cy - 3, 3, 7, color); - api.rect(cx - 2, cy - 2, 5, 5, color); - api.rect(cx - 3, cy - 1, 7, 3, color); - return; - } - api.rect(cx - 1, cy - 4, 3, 9, color); - api.rect(cx - 3, cy - 3, 7, 7, color); - api.rect(cx - 4, cy - 1, 9, 3, color); -} - -fn draw_dot_grid(api: &Api, offset_x: i16, offset_y: i16, cx: i16, cy: i16, intro_step: i16) { - let dots_count: i16 = 25; - let step = BOARD_SIZE / (dots_count - 1); - - for line_idx in 1..=2 { - let fixed_x = offset_x + line_idx * CELL_SIZE; - let fixed_y = offset_y + line_idx * CELL_SIZE; - - for i in 0..dots_count { - let var_pos = i * step; - - let vx = fixed_x; - let vy = offset_y + var_pos; - let dist_v = (vx - cx).abs() + (vy - cy).abs(); - let r_v = (intro_step - dist_v / 14).clamp(0, 3); - draw_dot(api, vx, vy, r_v, GRID_DOT_COLOR); - - let hx = offset_x + var_pos; - let hy = fixed_y; - let dist_h = (hx - cx).abs() + (hy - cy).abs(); - let r_h = (intro_step - dist_h / 14).clamp(0, 3); - draw_dot(api, hx, hy, r_h, GRID_DOT_COLOR); - } - } -} - -fn draw_dot_symbol( - api: &Api, - cell_idx: usize, - player: u8, - offset_x: i16, - offset_y: i16, - anim_r: i16, - highlight: bool, -) { - let col = (cell_idx % 3) as i16; - let row = (cell_idx / 3) as i16; - - let cell_cx = offset_x + col * CELL_SIZE + CELL_SIZE / 2; - let cell_cy = offset_y + row * CELL_SIZE + CELL_SIZE / 2; - - let matrix = if player == 1 { &MATRIX_X } else { &MATRIX_O }; - let color = if highlight { - WIN_COLOR - } else if player == 1 { - CMF_ORANGE - } else { - WHITE - }; - - let dot_gap: i16 = 12; - let start_x = cell_cx - 2 * dot_gap; - let start_y = cell_cy - 2 * dot_gap; - - for r in 0..5 { - for c in 0..5 { - if matrix[r * 5 + c] == 1 { - let dist_center = ((r as i16 - 2).abs() + (c as i16 - 2).abs()) / 2; - let radius = (anim_r - dist_center).clamp(0, 4); - let px = start_x + (c as i16) * dot_gap; - let py = start_y + (r as i16) * dot_gap; - draw_dot(api, px, py, radius, color); - } - } - } -} - -fn check_winner(board: &[u8; 9]) -> (u8, Option) { - for line_idx in 0..8 { - let base = line_idx * 3; - let a = board[WIN_LINES[base]]; - if a != 0 && a == board[WIN_LINES[base + 1]] && a == board[WIN_LINES[base + 2]] { - return (a, Some(line_idx)); - } - } - let mut full = true; - for &cell in board.iter() { - if cell == 0 { - full = false; - break; - } - } - if full { - (3, None) - } else { - (0, None) - } -} - -fn minimax(board: &mut [u8; 9], depth: i32, is_max: bool) -> i32 { - let (status, _) = check_winner(board); - if status == 2 { - return 10 - depth; - } - if status == 1 { - return depth - 10; - } - if status == 3 { - return 0; - } - - if is_max { - let mut best = -100; - for i in 0..9 { - if board[i] == 0 { - board[i] = 2; - let score = minimax(board, depth + 1, false); - board[i] = 0; - if score > best { - best = score; - } - } - } - best - } else { - let mut best = 100; - for i in 0..9 { - if board[i] == 0 { - board[i] = 1; - let score = minimax(board, depth + 1, true); - board[i] = 0; - if score < best { - best = score; - } - } - } - best - } -} - -fn choose_bot_move(board: &mut [u8; 9], seed: u32) -> Option { - let mut empty = [0usize; 9]; - let mut count = 0usize; - for i in 0..9 { - if board[i] == 0 { - empty[count] = i; - count += 1; - } - } - if count == 0 { - return None; - } - - if (seed % 5) == 0 { - return Some(empty[(seed as usize / 7) % count]); - } - - let mut best_score = -100; - let mut best_move = empty[0]; - for idx in 0..count { - let pos = empty[idx]; - board[pos] = 2; - let score = minimax(board, 0, false); - board[pos] = 0; - if score > best_score { - best_score = score; - best_move = pos; - } - } - Some(best_move) -} - -fn main(api: &'static Api) -> i32 { - let width = api.width as i16; - let height = api.height as i16; - let cx = width / 2; - let cy = height / 2; - - let offset_x = (width - BOARD_SIZE) / 2; - let offset_y = (height - BOARD_SIZE) / 2; - - let mut board = [0u8; 9]; - let mut cell_anim = [0i16; 9]; - - let mut player_wins: u8 = 0; - let mut bot_wins: u8 = 0; - - let mut state: u8 = 0; - let mut winner: u8 = 0; - let mut win_line_idx: Option = None; - - let mut intro_step: i16 = 0; - let mut last_tick = api.now(); - let mut bot_wait_start = 0u32; - - loop { - let now = api.now(); - - if now.wrapping_sub(last_tick) >= 25 { - last_tick = now; - - if state == 0 { - intro_step += 2; - if intro_step >= 26 { - state = 1; - } - } - - for i in 0..9 { - if board[i] != 0 && cell_anim[i] < 6 { - cell_anim[i] += 1; - } - } - - if state == 2 && now.wrapping_sub(bot_wait_start) >= 350 { - if let Some(m) = choose_bot_move(&mut board, now) { - board[m] = 2; - cell_anim[m] = 1; - } - let (res, line) = check_winner(&board); - if res != 0 { - winner = res; - win_line_idx = line; - state = 3; - if res == 1 { - player_wins = player_wins.saturating_add(1); - } else if res == 2 { - bot_wins = bot_wins.saturating_add(1); - } - } else { - state = 1; - } - } - } - - api.rect(0, 0, api.width, api.height, BG_COLOR); - - draw_dot(api, cx, 24, 2, CMF_ORANGE); - draw_dot(api, cx, height - 24, 2, BEZEL_DOT_COLOR); - - api.text(cx - 56, 42, "DOT X/O", WHITE); - - let mut score_str = [b'X', b':', b'0', b' ', b' ', b'O', b':', b'0']; - score_str[2] = b'0' + (player_wins % 10); - score_str[7] = b'0' + (bot_wins % 10); - let score_label = core::str::from_utf8(&score_str).unwrap_or("X:0 O:0"); - api.text(cx - 32, 62, score_label, CMF_ORANGE); - - draw_dot_grid(api, offset_x, offset_y, cx, cy, intro_step); - - for i in 0..9 { - if board[i] != 0 { - let is_win_cell = if let Some(l_idx) = win_line_idx { - let base = l_idx * 3; - WIN_LINES[base] == i || WIN_LINES[base + 1] == i || WIN_LINES[base + 2] == i - } else { - false - }; - draw_dot_symbol( - api, - i, - board[i], - offset_x, - offset_y, - cell_anim[i], - is_win_cell, - ); - } - } - - match state { - 0 => api.text(cx - 44, height - 62, "LOADING...", GRID_DOT_COLOR), - 1 => api.text(cx - 48, height - 62, "YOUR TURN", WHITE), - 2 => api.text(cx - 44, height - 62, "BOT TURN..", CMF_ORANGE), - _ => { - if winner == 1 { - api.text(cx - 40, height - 68, "YOU WIN!", CMF_ORANGE); - } else if winner == 2 { - api.text(cx - 40, height - 68, "BOT WINS", WHITE); - } else { - api.text(cx - 24, height - 68, "DRAW!", GRID_DOT_COLOR); - } - api.text(cx - 56, height - 48, "TAP TO RETRY", GRID_DOT_COLOR); - } - } - - api.show(); - - if let Some(event) = api.event(20) { - match event.kind { - BUTTON => return 0, - - CROWN => { - if state == 3 { - board = [0u8; 9]; - cell_anim = [0i16; 9]; - winner = 0; - win_line_idx = None; - intro_step = 0; - state = 0; - } - } - - TOUCH_DOWN => { - if state == 0 { - intro_step = 26; - state = 1; -} else if state == 3 { -board = [0u8; 9]; -cell_anim = [0i16; 9]; -winner = 0; -win_line_idx = None; -intro_step = 0; -state = 0; -} else if state == 1 { -let tx = event.x; -let ty = event.y; -if tx >= offset_x -&& tx < offset_x + BOARD_SIZE -&& ty >= offset_y -&& ty < offset_y + BOARD_SIZE -{ -let col = ((tx - offset_x) / CELL_SIZE) as usize; -let row = ((ty - offset_y) / CELL_SIZE) as usize; -let idx = row * 3 + col; -if idx < 9 && board[idx] == 0 { -board[idx] = 1; -cell_anim[idx] = 1; -let (res, line) = check_winner(&board); -if res != 0 { -winner = res; -win_line_idx = line; -state = 3; -if res == 1 { -player_wins = player_wins.saturating_add(1); -} -} else { -state = 2; -bot_wait_start = api.now(); -} -} -} -} -} -_ => {} -} -} -} -} diff --git a/apps/tic-tac-toe/store.md b/apps/tic-tac-toe/store.md deleted file mode 100644 index 2b2b009..0000000 --- a/apps/tic-tac-toe/store.md +++ /dev/null @@ -1 +0,0 @@ -Play classic Tic-Tac-Toe styled in the signature Nothing / CMF dot-matrix aesthetic with smooth grid intro animations and a Minimax AI bot. diff --git a/apps/tic-tac-toe/store.toml b/apps/tic-tac-toe/store.toml deleted file mode 100644 index 8ae6407..0000000 --- a/apps/tic-tac-toe/store.toml +++ /dev/null @@ -1,4 +0,0 @@ -name = "Dot Tic-Tac-Toe" -summary = "Nothing dot-matrix style Tic-Tac-Toe against a smart bot" -version = "0.1.1" -author = "weasters" diff --git a/apps/trip-computer/Cargo.toml b/apps/trip-computer/Cargo.toml deleted file mode 100644 index 396d2fc..0000000 --- a/apps/trip-computer/Cargo.toml +++ /dev/null @@ -1,16 +0,0 @@ -[package] -name = "trip-computer" -edition.workspace = true -license.workspace = true -version.workspace = true - -[dependencies] -cmf-wp2-app.workspace = true -cmf-wp2-ui.workspace = true - -[dev-dependencies] -wp2-core.workspace = true - -[[bin]] -name = "trip-computer" -bench = false diff --git a/apps/trip-computer/icon.svg b/apps/trip-computer/icon.svg deleted file mode 100644 index 6ba587f..0000000 --- a/apps/trip-computer/icon.svg +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/apps/trip-computer/shots/details.png b/apps/trip-computer/shots/details.png deleted file mode 100644 index a6978ac..0000000 Binary files a/apps/trip-computer/shots/details.png and /dev/null differ diff --git a/apps/trip-computer/shots/page.png b/apps/trip-computer/shots/page.png deleted file mode 100644 index 2d9c3c2..0000000 Binary files a/apps/trip-computer/shots/page.png and /dev/null differ diff --git a/apps/trip-computer/shots/speed.png b/apps/trip-computer/shots/speed.png deleted file mode 100644 index fa99a34..0000000 Binary files a/apps/trip-computer/shots/speed.png and /dev/null differ diff --git a/apps/trip-computer/src/fmt.rs b/apps/trip-computer/src/fmt.rs deleted file mode 100644 index 5799259..0000000 --- a/apps/trip-computer/src/fmt.rs +++ /dev/null @@ -1,356 +0,0 @@ -//! Numbers as the screen and the widget card show them, in km or miles, without `core::fmt` (code size) and without -//! floats. Everything here is ASCII: the watch font has no `·` or `°`. - -use crate::trip::Totals; - -/// A short ASCII string in a fixed buffer; pushes past `N` bytes are cut. -#[derive(Clone, Copy, PartialEq, Eq)] -pub struct Text { - buf: [u8; N], - len: usize, -} - -impl Default for Text { - fn default() -> Self { - Self::new() - } -} - -impl core::fmt::Debug for Text { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl Text { - pub const fn new() -> Self { - Text { buf: [0; N], len: 0 } - } - - pub fn from(s: &str) -> Self { - let mut t = Self::new(); - t.push(s); - t - } - - pub fn as_str(&self) -> &str { - core::str::from_utf8(&self.buf[..self.len]).unwrap_or("") - } - - #[cfg(test)] - pub fn len(&self) -> usize { - self.len - } - - pub fn push(&mut self, s: &str) -> &mut Self { - for &b in s.as_bytes() { - if self.len < N { - self.buf[self.len] = b; - self.len += 1; - } - } - self - } - - pub fn num(&mut self, n: u64) -> &mut Self { - let mut digits = [0u8; 20]; - let mut i = digits.len(); - let mut v = n; - loop { - i -= 1; - digits[i] = b'0' + (v % 10) as u8; - v /= 10; - if v == 0 { - break; - } - } - self.push(core::str::from_utf8(&digits[i..]).unwrap_or("?")) - } - - /// `n` with at least two digits. - pub fn num2(&mut self, n: u64) -> &mut Self { - if n < 10 { - self.push("0"); - } - self.num(n) - } - - /// `v` in units of 10^-`decimals`, e.g. `fixed(1234, 2)` = "12.34". - pub fn fixed(&mut self, v: u64, decimals: u32) -> &mut Self { - let p = 10u64.pow(decimals); - self.num(v / p); - if decimals > 0 { - self.push("."); - let mut frac = v % p; - let mut d = p / 10; - while d > 0 { - self.num(frac / d); - frac %= d; - d /= 10; - } - } - self - } -} - -const MM_PER_KM: u64 = 1_000_000; -const MM_PER_MI: u64 = 1_609_344; - -/// `mm` in km or miles × `scale`, rounded. -fn scaled(mm: u64, imperial: bool, scale: u64) -> u64 { - let unit = if imperial { MM_PER_MI } else { MM_PER_KM }; - (mm.saturating_mul(scale) + unit / 2) / unit -} - -pub fn speed_unit(imperial: bool) -> &'static str { - if imperial { "mph" } else { "km/h" } -} - -pub fn distance_unit(imperial: bool) -> &'static str { - if imperial { "mi" } else { "km" } -} - -/// Tenths of km/h or mph, rounded. -pub fn speed_tenths(mm_s: u32, imperial: bool) -> u64 { - // 1 mm/s = 0.0036 km/h = 0.00223694 mph - if imperial { (mm_s as u64 * 22_369 + 500_000) / 1_000_000 } else { (mm_s as u64 * 36 + 500) / 1_000 } -} - -/// "27.4" below 100, "123" from there (at most 4 chars: the big digits have room for that). -pub fn speed(mm_s: u32, imperial: bool) -> Text<8> { - let t = speed_tenths(mm_s, imperial).min(9_999); - let mut s = Text::new(); - if t < 1_000 { s.fixed(t, 1) } else { s.num((t + 5) / 10) }; - s -} - -/// Whole km/h or mph, capped at 999 (the widget). -pub fn speed_int(mm_s: u32, imperial: bool) -> u64 { - ((speed_tenths(mm_s, imperial) + 5) / 10).min(999) -} - -/// "3.42" below 100, "123.4" below 1000, then "1234" (at most 5 digits). -pub fn distance(mm: u64, imperial: bool) -> Text<8> { - let mut s = Text::new(); - let h = scaled(mm, imperial, 100); - if h < 10_000 { - s.fixed(h, 2); - } else if scaled(mm, imperial, 10) < 10_000 { - s.fixed(scaled(mm, imperial, 10), 1); - } else { - s.num(scaled(mm, imperial, 1).min(99_999)); - } - s -} - -/// "12.4" below 1000, then whole units (the widget's title). -pub fn distance_short(mm: u64, imperial: bool) -> Text<8> { - let mut s = Text::new(); - let t = scaled(mm, imperial, 10); - if t < 10_000 { s.fixed(t, 1) } else { s.num(scaled(mm, imperial, 1).min(99_999)) }; - s -} - -/// "1:02:33" (hours up to 999). -pub fn duration(ms: u32) -> Text<10> { - let s = ms / 1_000; - let mut t = Text::new(); - t.num((s / 3_600).min(999) as u64).push(":").num2((s / 60 % 60) as u64).push(":").num2((s % 60) as u64); - t -} - -/// "1:02" (hours and minutes). -pub fn hours_minutes(ms: u32) -> Text<8> { - let s = ms / 1_000; - let mut t = Text::new(); - t.num((s / 3_600).min(999) as u64).push(":").num2((s / 60 % 60) as u64); - t -} - -/// Whole metres or feet, signed. -pub fn height(dm: i64, imperial: bool) -> Text<10> { - let mut t = Text::new(); - if dm < 0 { - t.push("-"); - } - let a = dm.unsigned_abs(); - // 1 dm = 0.328084 ft - t.num(if imperial { (a * 328_084 + 500_000) / 1_000_000 } else { (a + 5) / 10 }.min(999_999)); - t.push(if imperial { " ft" } else { " m" }); - t -} - -/// Characters per card line that the stock card draws without wrapping: it fits about 17 of its font, and a wider -/// line wraps and is cut with "..." (seen in the emulator: "Moving 0:00 avg 80" lost the whole second line). -pub const WIDGET_LINE_MAX: usize = 15; - -/// The card left of the watch face: `Trip 12.4 km` over `0:42 avg 21\nmax 54 km/h` (moving time first). -pub fn widget(t: &Totals, imperial: bool) -> (Text<24>, Text<40>) { - let mut title = Text::new(); - let mut value = Text::new(); - if !t.started && t.distance_mm == 0 { - title.push("Trip Computer"); - value.push("No trip yet\nOpen to start"); - return (title, value); - } - title.push("Trip ").push(distance_short(t.distance_mm, imperial).as_str()).push(" ").push(distance_unit(imperial)); - value - .push(hours_minutes(t.moving_ms).as_str()) - .push(" avg ") - .num(speed_int(t.avg_mm_s(), imperial)) - .push("\nmax ") - .num(speed_int(t.max_mm_s, imperial)) - .push(" ") - .push(speed_unit(imperial)); - (title, value) -} - -/// While the app runs, write the card at most once per [`WIDGET_MS`] (it shows minutes, and every write is a NAND -/// write), and at start, `PAUSE` and exit when the text changed. -pub const WIDGET_MS: u32 = 60_000; - -#[derive(Default)] -pub struct WidgetGate { - last: Option<(Text<24>, Text<40>)>, - at: Option, -} - -impl WidgetGate { - pub fn due(&self, card: &(Text<24>, Text<40>), now: u32, force: bool) -> bool { - if self.last.as_ref() == Some(card) { - return false; - } - force || self.at.is_none_or(|a| now.wrapping_sub(a) >= WIDGET_MS) - } - - pub fn wrote(&mut self, card: &(Text<24>, Text<40>), now: u32) { - self.last = Some(*card); - self.at = Some(now); - } -} - -#[cfg(test)] -mod tests { - use super::*; - - /// The card's limits (`Api::widget`): title 23 bytes, value 39 bytes with one `\n`. - const WIDGET_TITLE_MAX: usize = 23; - const WIDGET_VALUE_MAX: usize = 39; - - #[test] - fn speeds_in_both_units() { - assert_eq!(speed(0, false).as_str(), "0.0"); - assert_eq!(speed(10_000, false).as_str(), "36.0"); // 10 m/s - assert_eq!(speed(7_611, false).as_str(), "27.4"); - assert_eq!(speed(27_778, false).as_str(), "100"); // 100.0 km/h: no room for the decimal - assert_eq!(speed(83_334, false).as_str(), "300"); - assert_eq!(speed(10_000, true).as_str(), "22.4"); // 22.37 mph - assert_eq!(speed(44_704, true).as_str(), "100"); // 100 mph - assert!(speed(u32::MAX, false).len() <= 4); - assert_eq!(speed_int(10_000, false), 36); - assert_eq!(speed_int(u32::MAX, false), 999); - } - - #[test] - fn distances_in_both_units() { - assert_eq!(distance(0, false).as_str(), "0.00"); - assert_eq!(distance(1_234_000, false).as_str(), "1.23"); - assert_eq!(distance(99_994_000, false).as_str(), "99.99"); - assert_eq!(distance(99_996_000, false).as_str(), "100.0"); - assert_eq!(distance(123_456_000, false).as_str(), "123.5"); - assert_eq!(distance(1_234_567_000, false).as_str(), "1235"); - assert_eq!(distance(1_609_344, true).as_str(), "1.00"); - assert_eq!(distance(16_093_440, true).as_str(), "10.00"); - assert_eq!(distance(u64::MAX / 1_000, false).as_str(), "99999"); - assert_eq!(distance_short(12_449_000, false).as_str(), "12.4"); - assert_eq!(distance_short(12_450_000, false).as_str(), "12.5"); - assert_eq!(distance_short(1_000_000_000, false).as_str(), "1000"); - } - - #[test] - fn times_and_heights() { - assert_eq!(duration(0).as_str(), "0:00:00"); - assert_eq!(duration(3_753_000).as_str(), "1:02:33"); - assert_eq!(duration(u32::MAX).as_str(), "999:02:47"); // 1193 h, capped - assert_eq!(hours_minutes(2_520_000).as_str(), "0:42"); - assert_eq!(hours_minutes(36_000_000).as_str(), "10:00"); - assert_eq!(height(3_124, false).as_str(), "312 m"); - assert_eq!(height(-45, false).as_str(), "-5 m"); // -4.5 m rounds away from zero - assert_eq!(height(3_048, true).as_str(), "1000 ft"); - assert_eq!(height(0, true).as_str(), "0 ft"); - } - - #[test] - fn fixed_point() { - let mut t = Text::<12>::new(); - t.fixed(1_005, 2); - assert_eq!(t.as_str(), "10.05"); - let mut t = Text::<12>::new(); - t.fixed(7, 1); - assert_eq!(t.as_str(), "0.7"); - let mut t = Text::<4>::new(); - t.push("abcdef"); - assert_eq!(t.as_str(), "abcd"); - } - - #[test] - fn widget_text_fits_the_card() { - let empty = widget(&Totals::default(), false); - assert_eq!(empty.0.as_str(), "Trip Computer"); - assert_eq!(empty.1.as_str(), "No trip yet\nOpen to start"); - let t = Totals { - distance_mm: 12_400_000, - moving_ms: 2_520_000, - elapsed_ms: 3_000_000, - max_mm_s: 15_000, - ascent_dm: 0, - started: true, - }; - let (title, value) = widget(&t, false); - assert_eq!(title.as_str(), "Trip 12.4 km"); - assert_eq!(value.as_str(), "0:42 avg 18\nmax 54 km/h"); - let (title, value) = widget(&t, true); - assert_eq!(title.as_str(), "Trip 7.7 mi"); - assert_eq!(value.as_str(), "0:42 avg 11\nmax 34 mph"); - // the longest anything can get - let max = Totals { - distance_mm: u64::MAX / 1_000, - moving_ms: u32::MAX, - elapsed_ms: u32::MAX, - max_mm_s: u32::MAX, - ascent_dm: u32::MAX, - started: true, - }; - for imperial in [false, true] { - for t in [empty_started(), t, max] { - let (title, value) = widget(&t, imperial); - assert!(title.len() <= WIDGET_TITLE_MAX, "{title:?}"); - assert!(value.len() <= WIDGET_VALUE_MAX, "{value:?}"); - assert_eq!(value.as_str().matches('\n').count(), 1); - assert!(title.as_str().is_ascii() && value.as_str().is_ascii()); - for line in core::iter::once(title.as_str()).chain(value.as_str().split('\n')) { - assert!(line.len() <= WIDGET_LINE_MAX, "{line:?} is wider than the card"); - } - } - } - } - - fn empty_started() -> Totals { - Totals { started: true, ..Totals::default() } - } - - #[test] - fn widget_writes_on_change_at_most_once_a_minute() { - let mut g = WidgetGate::default(); - let a = widget(&Totals::default(), false); - assert!(g.due(&a, 0, false), "first write"); - g.wrote(&a, 0); - assert!(!g.due(&a, 120_000, true), "same text: never"); - let b = widget(&Totals { started: true, distance_mm: 1_000_000, ..Totals::default() }, false); - assert!(!g.due(&b, 30_000, false), "changed, but within the minute"); - assert!(g.due(&b, 30_000, true), "PAUSE or exit writes at once"); - assert!(g.due(&b, 60_000, false)); - g.wrote(&b, 60_000); - assert!(!g.due(&b, 200_000, false)); - } -} diff --git a/apps/trip-computer/src/main.rs b/apps/trip-computer/src/main.rs deleted file mode 100644 index e444542..0000000 --- a/apps/trip-computer/src/main.rs +++ /dev/null @@ -1,246 +0,0 @@ -//! trip-computer: a GPS speedometer and trip computer on the watch's own GPS (loader of 2026-11-19). -//! -//! - Menu app: the speed screen (speed, GPS status, trip distance, moving time, average, maximum) and, a crown turn -//! or a tap away, the details (altitude, ascent, elapsed time) with the unit switch and the trip reset (confirmed). -//! - Page next to the watch face (`app_features!(PAGE)`): the compact speed screen. Swiped away = `PAUSE`: the loader -//! turns the GPS off, the app draws nothing and the time in between is not counted. -//! - Widget card (`app_features!(WIDGET)`): distance, moving time, average and maximum; written at start, at most once -//! a minute while it changes, and on `PAUSE` and exit. -//! -//! The maths (distance, speed, filter, totals, storage) is in `trip.rs`, the text in `fmt.rs`, the screens in -//! `view.rs`, all host-tested. Positions stay in RAM: storage holds totals and the unit setting only. -#![cfg_attr(any(target_os = "none", wp2_sim), no_main, cfg_attr(target_os = "none", no_std))] - -#[cfg_attr(not(any(target_os = "none", wp2_sim)), allow(dead_code))] -mod fmt; -#[cfg(any(wp2_sim, test))] -mod sim_track; -#[cfg_attr(not(any(target_os = "none", wp2_sim)), allow(dead_code))] -mod trip; -#[cfg_attr(not(any(target_os = "none", wp2_sim)), allow(dead_code))] -mod view; - -#[cfg(not(any(target_os = "none", wp2_sim)))] -fn main() {} - -#[cfg(any(target_os = "none", wp2_sim))] -mod device { - use crate::fmt::{self, WidgetGate}; - use crate::trip::{self, Sample, SaveGate, Totals, Trip}; - use crate::view::{Action, Frame, Screen, View}; - use cmf_wp2_app::{Api, Event, BUTTON, CROWN, PAUSE, RESUME, TOUCH_DOWN}; - use cmf_wp2_ui::haptic::{Motor, TICK}; - - cmf_wp2_app::entry!(main); - cmf_wp2_app::app_icon!(); - cmf_wp2_app::app_features!(cmf_wp2_app::WIDGET | cmf_wp2_app::PAGE); - - /// Redraw at least this often (the clock and the GPS status), even without GPS events. - const TICK_MS: u32 = 1_000; - - /// The watch: a `GPS` event about once a second, then `gps_fix()`. - #[cfg(not(wp2_sim))] - struct Source; - - #[cfg(not(wp2_sim))] - impl Source { - fn new() -> Self { - Source - } - - fn start(&mut self, api: &Api) -> bool { - api.gps(true) == 0 - } - - fn wait(&self, _now: u32) -> u32 { - TICK_MS - } - - fn poll(&mut self, api: &Api, e: Option<&Event>, _now: u32) -> Option { - if e.is_none_or(|e| e.kind != cmf_wp2_app::GPS) { - return None; - } - api.gps_fix().map(|f| Sample { - lat_e7: f.lat_e7, - lon_e7: f.lon_e7, - alt_dm: f.alt_dm, - ms: f.ms, - fix: f.fix, - sats: f.sats, - }) - } - } - - /// The simulator has no GPS: a synthetic ride, one reading a second (`sim_track.rs`). - #[cfg(wp2_sim)] - struct Source { - track: crate::sim_track::Track, - next: Option, - } - - #[cfg(wp2_sim)] - impl Source { - fn new() -> Self { - Source { track: crate::sim_track::Track::new(), next: None } - } - - fn start(&mut self, _api: &Api) -> bool { - true - } - - fn wait(&self, now: u32) -> u32 { - self.next.map_or(0, |n| (n.wrapping_sub(now) as i32).clamp(0, TICK_MS as i32) as u32) - } - - fn poll(&mut self, _api: &Api, _e: Option<&Event>, now: u32) -> Option { - if self.next.is_some_and(|n| (now.wrapping_sub(n) as i32) < 0) { - return None; - } - // a steady 1 Hz, as the receiver: from the due time, not from when the loop got here - let due = self.next.unwrap_or(now).wrapping_add(TICK_MS); - self.next = Some(if (now.wrapping_sub(due) as i32) >= 0 { now.wrapping_add(TICK_MS) } else { due }); - Some(self.track.at(now)) - } - } - - struct App { - api: &'static Api, - trip: Trip, - save: SaveGate, - card: WidgetGate, - } - - impl App { - /// Writes the totals when [`SaveGate`] says so: every minute while moving, or now when `force`d. - fn persist(&mut self, now: u32, force: bool) { - let (t, imp) = (self.trip.totals, self.trip.imperial); - if self.save.due(&t, imp, now, force) && self.api.save(&trip::encode(&t, imp)) == 0 { - self.save.saved(&t, imp, now); - } - } - - /// Writes the widget card when its text changed (at most once a minute unless `force`d). - fn card(&mut self, now: u32, force: bool) { - let card = fmt::widget(&self.trip.totals, self.trip.imperial); - if self.card.due(&card, now, force) { - // -22 (a loader without widgets) is final too: no retry every tick - self.api.widget(card.0.as_str(), card.1.as_str()); - self.card.wrote(&card, now); - } - } - - /// Recording stops (pause, exit): save and update the card now. - fn stop(&mut self) { - let now = self.api.now(); - self.trip.clock(now); - self.trip.gap(); - self.persist(now, true); - self.card(now, true); - } - } - - fn load(api: &Api) -> (Totals, bool) { - let mut buf = [0u8; 64]; - let n = api.load(&mut buf); - if n > 0 && (n as usize) <= buf.len() { - if let Some(stored) = trip::decode(&buf[..n as usize]) { - return stored; - } - } - (Totals::default(), false) - } - - /// Blocks until `RESUME` (`true`) or `BUTTON` (`false`). - fn paused(api: &Api) -> bool { - loop { - match api.event(u32::MAX).map(|e| e.kind) { - Some(RESUME) => return true, - Some(BUTTON) => return false, - _ => {} - } - } - } - - fn main(api: &'static Api) -> i32 { - let now = api.now(); - let (totals, imperial) = load(api); - let mut app = App { api, trip: Trip::new(totals, imperial), save: SaveGate::loaded(totals, imperial, now), card: WidgetGate::default() }; - let mut source = Source::new(); - let gps_ok = source.start(api); - // the simulator is never on the page: TRIP_PAGE=1 shows the page's layout there - #[cfg(wp2_sim)] - let page = std::env::var_os("TRIP_PAGE").is_some(); - #[cfg(not(wp2_sim))] - let page = api.on_page(); - let mut view = View::new(page); - let mut motor = Motor::new(api); - let mut screen = api; - app.card(now, true); - - loop { - let now = api.now(); - app.trip.clock(now); - app.persist(now, false); - app.card(now, false); - motor.update(); - if view.draw(&mut screen, &Frame::of(&app.trip, gps_ok, now), now) { - api.show(); - } - let mut wait = source.wait(now); - for w in [view.wait(now), motor.wait()].into_iter().flatten() { - wait = wait.min(w); - } - let e = api.event(wait); - let now = api.now(); - if let Some(s) = source.poll(api, e.as_ref(), now) { - app.trip.feed(s); - } - let Some(e) = e else { continue }; - let action = match e.kind { - BUTTON => break, - PAUSE => { - motor.off(); - app.stop(); - if !paused(api) { - return 0; // stop() saved already; the loader turns the GPS off - } - app.trip.gap(); // nothing between PAUSE and RESUME counts - view.invalidate(); - Action::None - } - RESUME => { - view.invalidate(); - Action::None - } - TOUCH_DOWN => view.tap(e.x.into(), e.y.into(), now), - CROWN => view.crown(e.delta), - _ => Action::None, - }; - match action { - Action::None => {} - Action::Show(s) => { - motor.play(TICK); - view.go(s); - } - Action::ToggleUnits => { - motor.play(TICK); - app.trip.imperial = !app.trip.imperial; - app.persist(now, true); - app.card(now, true); - } - Action::Reset => { - motor.play(TICK); - app.trip.reset(); - app.persist(now, true); - app.card(now, true); - view.go(Screen::Speed); - } - } - } - - motor.off(); - api.gps(false); - app.stop(); - 0 - } -} diff --git a/apps/trip-computer/src/sim_track.rs b/apps/trip-computer/src/sim_track.rs deleted file mode 100644 index 3f3c0d9..0000000 --- a/apps/trip-computer/src/sim_track.rs +++ /dev/null @@ -1,129 +0,0 @@ -//! Simulator only (`--cfg wp2_sim`, and the host tests): the simulator has no GPS, so this makes up a ride that the -//! app's real code path measures. Not part of the watch build. -//! -//! Per 100 s cycle after a 6 s search (0 to 5 satellites, no fix): 6 s standing with ±1 m of jitter, a ramp to -//! 32 km/h, 40 s between 22 and 43 km/h with one 3 km glitch, a slow-down to 14 km/h and 4 s without a fix -//! (long enough to show "GPS signal lost", short enough not to break the track). The -//! heading turns every 25 s, the road climbs 4 m per cycle and dips back. The position is synthetic. - -use crate::trip::Sample; - -const SEARCH_S: u32 = 6; -const CYCLE_S: u32 = 100; -/// Synthetic start: 45°N 0°E, a round number on purpose. -const START_LAT_E7: i64 = 450_000_000; -const START_LON_E7: i64 = 0; -/// 1e-7° per metre at 45°N: north 1e7 / 111.132 km, east 1e7 / 78.85 km (×1000 for mm below). -const E7_PER_KM_NORTH: i64 = 89_982; -const E7_PER_KM_EAST: i64 = 126_824; -/// Unit headings ×1000: N, NE, E, SE, S, SW, W, NW. -const HEADINGS: [(i64, i64); 8] = [(1000, 0), (707, 707), (0, 1000), (-707, 707), (-1000, 0), (-707, -707), (0, -1000), (707, -707)]; - -pub struct Track { - start: Option, - last: u32, - north_mm: i64, - east_mm: i64, - seed: u32, -} - -impl Default for Track { - fn default() -> Self { - Self::new() - } -} - -impl Track { - pub const fn new() -> Self { - Track { start: None, last: 0, north_mm: 0, east_mm: 0, seed: 0x2545_F491 } - } - - fn noise_mm(&mut self) -> i64 { - self.seed = self.seed.wrapping_mul(1_664_525).wrapping_add(1_013_904_223); - (self.seed >> 16) as i64 % 2_001 - 1_000 - } - - /// Ground speed in mm/s `s` seconds into a cycle; `None` for no fix. - fn speed(s: u32) -> Option { - let s = s as i64; - Some(match s { - 0..6 => 0, - 6..24 => (s - 6) * 500, // to 9 m/s - 24..64 => 9_000 + tri(s - 24, 20) * 3_000 / 10, // 6..12 m/s - 64..74 => 9_000 - (s - 64) * 500, // down to 4 m/s - 74..96 => 4_000, - _ => return None, - }) - } - - /// The reading at `now` (ms); call it about once a second. - pub fn at(&mut self, now: u32) -> Sample { - let start = *self.start.get_or_insert(now); - let t = now.wrapping_sub(start); - let dt = now.wrapping_sub(self.last).min(5_000) as i64; - self.last = now; - let secs = t / 1_000; - if secs < SEARCH_S { - return Sample { ms: now, fix: 0, sats: secs as u8, ..Sample::default() }; - } - let cycle = (secs - SEARCH_S) / CYCLE_S; - let s = (secs - SEARCH_S) % CYCLE_S; - let (hn, he) = HEADINGS[((secs / 25) % 8) as usize]; - let Some(v) = Self::speed(s) else { - return Sample { ms: now, fix: 0, sats: 3, ..Sample::default() }; - }; - self.north_mm += v * dt / 1_000 * hn / 1_000; - self.east_mm += v * dt / 1_000 * he / 1_000; - let glitch = if s == 40 { 3_000_000 } else { 0 }; - let north = self.north_mm + self.noise_mm() + glitch; - let east = self.east_mm + self.noise_mm(); - let alt_dm = 1_200 + cycle.min(3) as i32 * 40 + tri(s as i64, CYCLE_S as i64 / 2) as i32 * 4; - Sample { - lat_e7: (START_LAT_E7 + north * E7_PER_KM_NORTH / 1_000_000) as i32, - lon_e7: (START_LON_E7 + east * E7_PER_KM_EAST / 1_000_000) as i32, - alt_dm, - ms: now, - fix: 1, - sats: 9, - } - } -} - -/// Triangle wave: 0 → 10 → 0 → -10 → 0 over `period`. -fn tri(t: i64, period: i64) -> i64 { - let q = (t % period) * 40 / period; // 0..40 - match q { - 0..10 => q, - 10..30 => 20 - q, - _ => q - 40, - } -} - -#[cfg(test)] -mod tests { - use super::*; - use crate::trip::{Feed, Status, Trip, Totals}; - - #[test] - fn the_synthetic_ride_measures_sensibly() { - let mut track = Track::new(); - let mut trip = Trip::new(Totals::default(), false); - let (mut rejected, mut searching_seen) = (0, false); - for i in 0..(SEARCH_S + 2 * CYCLE_S) { - let now = 10_000 + i * 1_000; - trip.clock(now); - if trip.feed(track.at(now)) == Feed::Rejected { - rejected += 1; - } - searching_seen |= matches!(trip.status(now), Status::Searching(_)); - } - assert!(searching_seen); - assert_eq!(rejected, 2, "one glitch per cycle"); - // two cycles: ~2 × (81 + 360 + 65 + 92) m ≈ 1.2 km - let d = trip.totals.distance_mm as i64; - assert!((1_100_000..1_350_000).contains(&d), "{d}"); - let max = trip.totals.max_mm_s as i64; - assert!((11_000..13_000).contains(&max), "{max}"); - assert!(trip.totals.moving_ms > 150_000); - } -} diff --git a/apps/trip-computer/src/trip.rs b/apps/trip-computer/src/trip.rs deleted file mode 100644 index 23f4a67..0000000 --- a/apps/trip-computer/src/trip.rs +++ /dev/null @@ -1,755 +0,0 @@ -//! The trip computer's model: distance between fixes, speed, the jitter filter, trip totals and the storage blob. -//! No `Api` and no floats, so `cargo test` runs it on the host and the watch build links no soft-float code. -//! -//! The receiver gives positions only (GGA: no speed, no course), about once a second. Speed is derived here from -//! successive fixes, smoothed over a short window, and every fix goes through a filter first: -//! -//! - no fix (`fix` 0) or fewer than [`MIN_SATS`] satellites: ignored, the status turns "lost"; -//! - more than [`GAP_MS`] since the last good fix (a `PAUSE`/`RESUME`, the app reopened, a long loss): the track -//! restarts at the new fix and the jump is not counted; -//! - a step faster than [`MAX_SPEED_MM_S`] (300 km/h) from the last good fix: rejected as a glitch; after -//! [`JUMP_RESET`] of them in a row the receiver is believed and the track restarts there; -//! - standing still: while the smoothed speed is under [`MOVING_MM_S`] the distance anchor stays put, so the -//! receiver's drift around a fixed point adds nothing, unless the position wanders more than [`DRIFT_MM`] away from -//! it (slow real movement). -//! -//! Positions never leave this module: only totals (distance, times, speeds, ascent) are stored. - -/// Fewer satellites than this: the fix is too poor to measure with. -pub const MIN_SATS: u8 = 4; -/// A longer gap between two good fixes restarts the track: the jump across it is not counted. -pub const GAP_MS: u32 = 5_000; -/// 300 km/h in mm/s: a step faster than this is a glitch. -pub const MAX_SPEED_MM_S: u64 = 83_334; -/// After this many glitches in a row the new position is taken as the truth (the track restarts there). -pub const JUMP_RESET: u8 = 3; -/// Fixes in the speed window (at 1 Hz: the speed is the straight-line distance over the last 4 s). -pub const WINDOW: usize = 5; -/// The window must span this long before it gives a speed. -pub const MIN_SPAN_MS: u32 = 2_000; -/// ...and this long before its speed may set the maximum (fewer spikes). -pub const MAX_SPAN_MS: u32 = 3_000; -/// 2.9 km/h: slower than this counts as standing (speed shows 0, no moving time). Over the 4 s window that is -/// 3.2 m of straight-line progress, above the sample-to-sample jitter of a receiver standing still. -pub const MOVING_MM_S: u32 = 800; -/// While standing, a position this far from the anchor is real movement after all. -pub const DRIFT_MM: u64 = 25_000; -/// Ascent hysteresis on the window's mean altitude, in decimetres (GPS altitude is noisy). -pub const ASCENT_STEP_DM: i32 = 50; -/// Without a good fix for this long the status is "lost" and the speed shows "--". -pub const STALE_MS: u32 = 3_000; -/// A clock step longer than this (a stall, a debugger, the simulator's jumps) is not counted as elapsed time. -pub const CLOCK_MAX_STEP_MS: u32 = 10_000; - -/// cos(φ) for φ = 0..=90° in whole degrees, Q15 (32768 = 1.0). -const COS_Q15: [u16; 91] = [ - 32768, 32763, 32748, 32723, 32688, 32643, 32588, 32524, 32449, 32365, // - 32270, 32166, 32052, 31928, 31795, 31651, 31499, 31336, 31164, 30983, // - 30792, 30592, 30382, 30163, 29935, 29698, 29452, 29197, 28932, 28660, // - 28378, 28088, 27789, 27482, 27166, 26842, 26510, 26170, 25822, 25466, // - 25102, 24730, 24351, 23965, 23571, 23170, 22763, 22348, 21926, 21498, // - 21063, 20622, 20174, 19720, 19261, 18795, 18324, 17847, 17364, 16877, // - 16384, 15886, 15384, 14876, 14365, 13848, 13328, 12803, 12275, 11743, // - 11207, 10668, 10126, 9580, 9032, 8481, 7927, 7371, 6813, 6252, // - 5690, 5126, 4560, 3993, 3425, 2856, 2286, 1715, 1144, 572, // - 0, -]; - -const Q15: i64 = 32_768; -const E7: i64 = 10_000_000; - -/// cos(latitude) in Q15, linear between whole degrees (error under 4e-5). -pub fn cos_q15(lat_e7: i32) -> i64 { - let a = (lat_e7.unsigned_abs() as i64).min(90 * E7); - let deg = (a / E7) as usize; - let frac = a % E7; - let c0 = COS_Q15[deg] as i64; - let c1 = COS_Q15[(deg + 1).min(90)] as i64; - c0 - (c0 - c1) * frac / E7 -} - -/// Longest leg [`distance_mm`] measures; anything longer is clamped (2000 km, far past [`MAX_SPEED_MM_S`]). -const LEG_MAX_MM: i64 = 2_000_000_000; - -/// Distance in mm between two positions in 1e-7°, on the WGS84 ellipsoid's local scale (equirectangular at the -/// mid latitude). Length of a degree, from the series for the ellipsoid: -/// north-south `111132.954 - 559.822·cos 2φ` m, east-west `111412.84·cos φ - 93.5·cos 3φ` m. -/// -/// Error: the dropped series terms are under 1.2 m per degree (1e-5); the cosine table under 4e-5; the flat-earth -/// step is exact to 1e-6 for legs under 1 km, which is all a 1 Hz receiver produces below 300 km/h. Rounding is -/// under 1 mm per leg. So a leg is right to about 0.01 %; summed over a trip, the receiver's own noise dominates. -pub fn distance_mm(a_lat: i32, a_lon: i32, b_lat: i32, b_lon: i32) -> u64 { - let dlat = b_lat as i64 - a_lat as i64; - let mut dlon = b_lon as i64 - a_lon as i64; - if dlon > 180 * E7 { - dlon -= 360 * E7; - } else if dlon < -180 * E7 { - dlon += 360 * E7; - } - let mid = ((a_lat as i64 + b_lat as i64) / 2) as i32; - let c = cos_q15(mid); - let c2 = 2 * c * c / Q15 - Q15; // cos 2φ - let c3 = 4 * (c * c / Q15) * c / Q15 - 3 * c; // cos 3φ - let north_mm_per_deg = 111_132_954 - 559_822 * c2 / Q15; - let east_mm_per_deg = (111_412_840 * c - 93_500 * c3) / Q15; - // |dlat|, |dlon| <= 3.6e9 and a degree < 1.12e8 mm: the products stay under 4.1e17 - let dy = (dlat * north_mm_per_deg / E7).abs().min(LEG_MAX_MM) as u64; - let dx = (dlon * east_mm_per_deg / E7).abs().min(LEG_MAX_MM) as u64; - (dx * dx + dy * dy).isqrt() -} - -/// One reading of the receiver (the fields of `cmf_wp2_app::GpsFix` the trip uses). -#[derive(Clone, Copy, Debug, Default, PartialEq)] -pub struct Sample { - pub lat_e7: i32, - pub lon_e7: i32, - pub alt_dm: i32, - pub ms: u32, - pub fix: u8, - pub sats: u8, -} - -#[derive(Clone, Copy, Debug, Default, PartialEq)] -struct Point { - lat_e7: i32, - lon_e7: i32, - alt_dm: i32, - ms: u32, -} - -impl Point { - fn to(&self, o: &Point) -> u64 { - distance_mm(self.lat_e7, self.lon_e7, o.lat_e7, o.lon_e7) - } -} - -/// What the trip keeps between launches. No positions. -#[derive(Clone, Copy, Debug, Default, PartialEq)] -pub struct Totals { - pub distance_mm: u64, - pub moving_ms: u32, - pub elapsed_ms: u32, - pub max_mm_s: u32, - pub ascent_dm: u32, - /// A good fix came since the last reset: the trip's clock runs. - pub started: bool, -} - -impl Totals { - /// Average moving speed, mm/s; 0 before a second of movement. - pub fn avg_mm_s(&self) -> u32 { - if self.moving_ms < 1_000 { - return 0; - } - (self.distance_mm * 1_000 / self.moving_ms as u64).min(u32::MAX as u64) as u32 - } - - /// The fields that only change while moving: a periodic save waits for one of them. - fn motion(&self) -> (u64, u32, u32, u32) { - (self.distance_mm, self.moving_ms, self.max_mm_s, self.ascent_dm) - } -} - -/// What [`Trip::feed`] did with a sample. -#[derive(Clone, Copy, Debug, PartialEq)] -pub enum Feed { - /// No fix, or too few satellites. - NoFix, - /// A good fix, measured against the last one. - Accepted, - /// A glitch (too fast a jump), not used. - Rejected, - /// The track (re)starts here: first fix, after a gap or after a run of glitches. Nothing counted. - Restarted, -} - -/// GPS state as the screen shows it. -#[derive(Clone, Copy, Debug, PartialEq)] -pub enum Status { - /// No fix yet since the GPS was turned on; satellites in use. - Searching(u8), - /// A good fix within [`STALE_MS`]. - Fix(u8), - /// Had a fix this session, none for [`STALE_MS`]. - Lost(u8), -} - -pub struct Trip { - pub totals: Totals, - pub imperial: bool, - window: [Point; WINDOW], - len: usize, - anchor: Option, - rejects: u8, - alt_ref: Option, - speed_mm_s: u32, - last_good: Option, - sats: u8, - good_sats: u8, - session_fix: bool, - clock: Option, - /// Altitude of the last good fix, decimetres. Not stored. - pub alt_dm: Option, -} - -impl Trip { - pub fn new(totals: Totals, imperial: bool) -> Self { - Trip { - totals, - imperial, - window: [Point::default(); WINDOW], - len: 0, - anchor: None, - rejects: 0, - alt_ref: None, - speed_mm_s: 0, - last_good: None, - sats: 0, - good_sats: 0, - session_fix: false, - clock: None, - alt_dm: None, - } - } - - fn last(&self) -> Option { - (self.len > 0).then(|| self.window[self.len - 1]) - } - - fn restart(&mut self, p: Point) { - self.window[0] = p; - self.len = 1; - self.anchor = Some(p); - self.rejects = 0; - self.alt_ref = None; - self.speed_mm_s = 0; - self.totals.started = true; - } - - fn push(&mut self, p: Point) { - if self.len == WINDOW { - self.window.copy_within(1.., 0); - self.len -= 1; - } - self.window[self.len] = p; - self.len += 1; - } - - fn span_ms(&self) -> u32 { - if self.len < 2 { - return 0; - } - self.window[self.len - 1].ms.wrapping_sub(self.window[0].ms) - } - - fn mean_alt_dm(&self) -> i32 { - let sum: i64 = self.window[..self.len].iter().map(|p| p.alt_dm as i64).sum(); - (sum / self.len.max(1) as i64) as i32 - } - - /// Takes one receiver reading. - pub fn feed(&mut self, s: Sample) -> Feed { - self.sats = s.sats; - if s.fix == 0 || s.sats < MIN_SATS { - return Feed::NoFix; - } - let p = Point { lat_e7: s.lat_e7, lon_e7: s.lon_e7, alt_dm: s.alt_dm, ms: s.ms }; - self.last_good = Some(s.ms); - self.good_sats = s.sats; - self.session_fix = true; - self.alt_dm = Some(s.alt_dm); - let Some(prev) = self.last() else { - self.restart(p); - return Feed::Restarted; - }; - let dt = p.ms.wrapping_sub(prev.ms); - if dt == 0 || dt as i32 <= 0 { - return Feed::Rejected; // the same reading again, or out of order - } - if dt > GAP_MS { - self.restart(p); - return Feed::Restarted; - } - if prev.to(&p) * 1_000 / dt as u64 > MAX_SPEED_MM_S { - self.rejects += 1; - if self.rejects >= JUMP_RESET { - self.restart(p); - return Feed::Restarted; - } - return Feed::Rejected; - } - self.rejects = 0; - self.push(p); - - let span = self.span_ms(); - self.speed_mm_s = if span >= MIN_SPAN_MS { - (self.window[0].to(&p) * 1_000 / span as u64).min(u32::MAX as u64) as u32 - } else { - 0 - }; - let moving = self.speed_mm_s >= MOVING_MM_S; - let t = &mut self.totals; - if moving { - t.moving_ms = t.moving_ms.saturating_add(dt); - } - if moving && span >= MAX_SPAN_MS && self.speed_mm_s > t.max_mm_s { - t.max_mm_s = self.speed_mm_s; - } - let anchor = self.anchor.unwrap_or(p); - let d = anchor.to(&p); - if moving || d >= DRIFT_MM { - t.distance_mm += d; - self.anchor = Some(p); - } - if moving { - let mean = self.mean_alt_dm(); - match self.alt_ref { - None => self.alt_ref = Some(mean), - Some(r) if mean - r >= ASCENT_STEP_DM => { - self.totals.ascent_dm = self.totals.ascent_dm.saturating_add((mean - r) as u32); - self.alt_ref = Some(mean); - } - Some(r) if r - mean >= ASCENT_STEP_DM => self.alt_ref = Some(mean), - Some(_) => {} - } - } - Feed::Accepted - } - - /// Advances the trip's clock to `now` (call it every loop turn): elapsed time runs once the trip has started. - pub fn clock(&mut self, now: u32) { - if let Some(t) = self.clock { - let dt = now.wrapping_sub(t); - if self.totals.started && dt <= CLOCK_MAX_STEP_MS { - self.totals.elapsed_ms = self.totals.elapsed_ms.saturating_add(dt); - } - } - self.clock = Some(now); - } - - /// The app stops recording (`PAUSE`, exit): the time and the track until the next fix are not counted. - pub fn gap(&mut self) { - self.len = 0; - self.anchor = None; - self.rejects = 0; - self.alt_ref = None; - self.speed_mm_s = 0; - self.last_good = None; - self.session_fix = false; - self.clock = None; - self.sats = 0; - } - - /// Starts a new trip; the units stay. The track goes on from the last good fix. - pub fn reset(&mut self) { - self.totals = Totals::default(); - self.alt_ref = None; - self.anchor = self.last(); - self.totals.started = self.last().is_some(); - } - - pub fn status(&self, now: u32) -> Status { - match self.last_good { - Some(t) if now.wrapping_sub(t) <= STALE_MS => Status::Fix(self.good_sats), - _ if self.session_fix => Status::Lost(self.sats), - _ => Status::Searching(self.sats), - } - } - - /// The speed to show: `None` without a current fix, 0 while standing. - pub fn speed(&self, now: u32) -> Option { - match self.status(now) { - Status::Fix(_) => Some(if self.speed_mm_s >= MOVING_MM_S { self.speed_mm_s } else { 0 }), - _ => None, - } - } -} - -// ---- storage ---- - -/// Blob: `"TC"`, version, flags (bit 0 imperial, bit 1 started), distance mm (u64), moving ms, elapsed ms, -/// max mm/s, ascent dm (u32 each), little-endian. Totals and settings only, never a position. -pub const MAGIC: [u8; 2] = *b"TC"; -pub const VERSION: u8 = 1; -pub const STORE_LEN: usize = 28; - -pub fn encode(t: &Totals, imperial: bool) -> [u8; STORE_LEN] { - let mut b = [0u8; STORE_LEN]; - b[..2].copy_from_slice(&MAGIC); - b[2] = VERSION; - b[3] = imperial as u8 | (t.started as u8) << 1; - b[4..12].copy_from_slice(&t.distance_mm.to_le_bytes()); - for (i, v) in [t.moving_ms, t.elapsed_ms, t.max_mm_s, t.ascent_dm].iter().enumerate() { - b[12 + 4 * i..16 + 4 * i].copy_from_slice(&v.to_le_bytes()); - } - b -} - -/// The stored trip, or `None` for anything that is not a version-1 blob (it then loads as a new trip). -pub fn decode(b: &[u8]) -> Option<(Totals, bool)> { - if b.len() != STORE_LEN || b[..2] != MAGIC || b[2] != VERSION || b[3] & !3 != 0 { - return None; - } - let u = |i: usize| u32::from_le_bytes([b[i], b[i + 1], b[i + 2], b[i + 3]]); - let mut d = [0u8; 8]; - d.copy_from_slice(&b[4..12]); - let t = Totals { - distance_mm: u64::from_le_bytes(d), - moving_ms: u(12), - elapsed_ms: u(16), - max_mm_s: u(20), - ascent_dm: u(24), - started: b[3] & 2 != 0, - }; - Some((t, b[3] & 1 != 0)) -} - -/// Save every [`SAVE_MS`] while the trip moves, and on `PAUSE`, exit and setting changes. Never per fix. -pub const SAVE_MS: u32 = 60_000; - -#[derive(Default)] -pub struct SaveGate { - saved: Option<(Totals, bool)>, - at: Option, -} - -impl SaveGate { - /// The blob as loaded at start: nothing to save until it changes. - pub fn loaded(t: Totals, imperial: bool, now: u32) -> Self { - SaveGate { saved: Some((t, imperial)), at: Some(now) } - } - - /// Whether to write now. `force`: pause, exit, reset, unit change: any change at all is written. - pub fn due(&self, t: &Totals, imperial: bool, now: u32, force: bool) -> bool { - let Some((st, si)) = self.saved else { return true }; - if force { - return st != *t || si != imperial; - } - let waited = self.at.is_none_or(|a| now.wrapping_sub(a) >= SAVE_MS); - waited && (st.motion() != t.motion() || si != imperial) - } - - pub fn saved(&mut self, t: &Totals, imperial: bool, now: u32) { - self.saved = Some((*t, imperial)); - self.at = Some(now); - } -} - -#[cfg(test)] -mod tests { - use super::*; - - /// 1e-7° steps of latitude for `m` metres (at mid latitudes, ~111.1 km per degree). - fn north(m: i64) -> i32 { - (m * E7 / 111_132) as i32 - } - - fn fix(lat_e7: i32, lon_e7: i32, ms: u32) -> Sample { - Sample { lat_e7, lon_e7, alt_dm: 1000, ms, fix: 1, sats: 8 } - } - - /// Feeds `secs` fixes one second apart going north at `mm_s`, from `lat` at `t0`; returns the last lat and time. - fn drive(trip: &mut Trip, lat: i32, t0: u32, secs: u32, mm_s: i64) -> (i32, u32) { - let mut lat = lat; - let mut t = t0; - for _ in 0..secs { - t += 1_000; - lat += (mm_s * E7 / 111_132_000) as i32; - trip.feed(fix(lat, 0, t)); - } - (lat, t) - } - - #[test] - fn a_thousandth_of_a_degree_of_latitude() { - // 0.001° north is 110.57 m at the equator, 111.13 m at 45°, 111.69 m at the pole - let at = |lat_deg: i32| distance_mm(lat_deg * 10_000_000, 0, lat_deg * 10_000_000 + 10_000, 0) as i64; - assert!((at(0) - 110_574).abs() < 20, "{}", at(0)); - assert!((at(45) - 111_132).abs() < 20, "{}", at(45)); - assert!((at(-45) - 111_132).abs() < 20, "{}", at(-45)); - assert!((at(89) - 111_694).abs() < 30, "{}", at(89)); - } - - #[test] - fn a_step_of_longitude_shrinks_with_latitude() { - let east = |lat_deg: i32| distance_mm(lat_deg * 10_000_000, 0, lat_deg * 10_000_000, 10_000) as i64; - // 0.001° east: 111.32 m at the equator, 55.80 m at 60° (about half), 0 at the pole - assert!((east(0) - 111_319).abs() < 20, "{}", east(0)); - assert!((east(60) - 55_800).abs() < 20, "{}", east(60)); - assert!((east(60) * 2 - east(0)).abs() < 400); - assert_eq!(distance_mm(90 * 10_000_000, 0, 90 * 10_000_000, 10_000), 0); - } - - #[test] - fn diagonal_and_symmetry() { - let a = (473_000_000, 85_000_000); - let b = (a.0 + 3_000, a.1 + 4_000); - let d = distance_mm(a.0, a.1, b.0, b.1); - assert_eq!(d, distance_mm(b.0, b.1, a.0, a.1)); - // 3e-4° north (33.35 m) and 4e-4° east at 47.3° (30.24 m): hypotenuse 45.02 m - assert!((d as i64 - 45_020).abs() < 50, "{d}"); - } - - #[test] - fn longitude_wraps_at_the_antimeridian() { - let d = distance_mm(0, 1_799_999_000, 0, -1_799_999_000); - assert!((d as i64 - 22_264).abs() < 10, "{d}"); // 0.002° east across 180° - } - - #[test] - fn far_legs_clamp_instead_of_overflowing() { - let d = distance_mm(-900_000_000, -1_800_000_000, 900_000_000, 0); - assert!(d >= LEG_MAX_MM as u64 && d < 3 * LEG_MAX_MM as u64); - } - - #[test] - fn steady_speed_is_measured() { - let mut trip = Trip::new(Totals::default(), false); - assert_eq!(trip.feed(fix(450_000_000, 0, 1_000)), Feed::Restarted); - let (_, t) = drive(&mut trip, 450_000_000, 1_000, 10, 10_000); // 36 km/h - let v = trip.speed(t).unwrap() as i64; - assert!((v - 10_000).abs() < 100, "{v}"); - let d = trip.totals.distance_mm as i64; - assert!((d - 100_000).abs() < 500, "{d}"); - assert_eq!(trip.totals.moving_ms, 9_000); // the first second has no speed yet - assert!((trip.totals.max_mm_s as i64 - 10_000).abs() < 100); - let avg = trip.totals.avg_mm_s() as i64; - assert!(avg > 10_000, "ten seconds of distance over nine of moving time: {avg}"); - } - - #[test] - fn speed_is_smoothed_over_the_window() { - let mut trip = Trip::new(Totals::default(), false); - trip.feed(fix(0, 0, 0)); - // alternating 2 m and 8 m per second: the window shows the mean, not the steps - let mut lat = 0; - for i in 1..=8u32 { - lat += north(if i % 2 == 0 { 2 } else { 8 }); - trip.feed(fix(lat, 0, i * 1_000)); - } - let v = trip.speed(8_000).unwrap() as i64; - assert!((v - 5_000).abs() < 100, "{v}"); - } - - #[test] - fn no_fix_and_few_satellites_are_ignored() { - let mut trip = Trip::new(Totals::default(), false); - assert_eq!(trip.feed(Sample { sats: 3, ..fix(0, 0, 0) }), Feed::NoFix); - assert_eq!(trip.feed(Sample { fix: 0, sats: 9, ..fix(0, 0, 0) }), Feed::NoFix); - assert_eq!(trip.status(0), Status::Searching(9)); - assert!(!trip.totals.started); - assert_eq!(trip.speed(0), None); - } - - #[test] - fn a_glitch_is_rejected_and_the_track_goes_on() { - let mut trip = Trip::new(Totals::default(), false); - trip.feed(fix(0, 0, 0)); - let (lat, t) = drive(&mut trip, 0, 0, 5, 5_000); - let before = trip.totals.distance_mm; - // 1 km in one second: 3600 km/h - assert_eq!(trip.feed(fix(lat + north(1_000), 0, t + 1_000)), Feed::Rejected); - assert_eq!(trip.totals.distance_mm, before); - // the next real fix, 2 s after the last good one, is measured against it - assert_eq!(trip.feed(fix(lat + north(10), 0, t + 2_000)), Feed::Accepted); - let added = trip.totals.distance_mm - before; - assert!((added as i64 - 10_000).abs() < 100, "{added}"); - } - - #[test] - fn three_jumps_in_a_row_move_the_track() { - let mut trip = Trip::new(Totals::default(), false); - trip.feed(fix(0, 0, 0)); - let far = north(5_000); - assert_eq!(trip.feed(fix(far, 0, 1_000)), Feed::Rejected); - assert_eq!(trip.feed(fix(far, 0, 2_000)), Feed::Rejected); - assert_eq!(trip.feed(fix(far, 0, 3_000)), Feed::Restarted); - assert_eq!(trip.totals.distance_mm, 0); - assert_eq!(trip.feed(fix(far + north(5), 0, 4_000)), Feed::Accepted); - } - - #[test] - fn a_gap_restarts_the_track_without_counting_the_jump() { - let mut trip = Trip::new(Totals::default(), false); - trip.feed(fix(0, 0, 0)); - let (lat, t) = drive(&mut trip, 0, 0, 6, 10_000); - let before = trip.totals; - // 6 s later, 2 km on (a car ride while the app was paused): not counted, no speed yet - assert_eq!(trip.feed(fix(lat + north(2_000), 0, t + 6_000)), Feed::Restarted); - assert_eq!(trip.totals.distance_mm, before.distance_mm); - assert_eq!(trip.totals.moving_ms, before.moving_ms); - assert_eq!(trip.speed(t + 6_000), Some(0)); - } - - #[test] - fn pause_resume_is_a_gap_even_when_quick() { - let mut trip = Trip::new(Totals::default(), false); - trip.feed(fix(0, 0, 0)); - let (lat, t) = drive(&mut trip, 0, 0, 6, 10_000); - trip.clock(t); - let before = trip.totals; - trip.gap(); - assert_eq!(trip.status(t), Status::Searching(0)); - trip.clock(t + 3_000); - assert_eq!(trip.totals.elapsed_ms, before.elapsed_ms); - assert_eq!(trip.feed(fix(lat + north(100), 0, t + 3_000)), Feed::Restarted); - assert_eq!(trip.totals.distance_mm, before.distance_mm); - } - - #[test] - fn standing_drift_adds_nothing() { - // 2 minutes on one spot with ±1 m of white jitter, then 2 minutes of a slow ±2 m wander - let mut trip = Trip::new(Totals::default(), false); - let jitter = [0, 1, -1, 1, -1, 0, 1, 0, -1, 1]; - for i in 0..120u32 { - let j = jitter[i as usize % 10]; - trip.feed(fix(north(j), north(-j) / 2, i * 1_000)); - } - for i in 0..120u32 { - let k = (i % 40) as i64; // a triangle of 0..2 m and back, 0.2 m/s - let w = if k < 20 { k } else { 40 - k } * 100; - trip.feed(fix((w * E7 / 111_132_000) as i32, 0, 120_000 + i * 1_000)); - } - assert_eq!(trip.totals.distance_mm, 0); - assert_eq!(trip.totals.moving_ms, 0); - assert_eq!(trip.totals.max_mm_s, 0); - assert_eq!(trip.speed(239_000), Some(0)); - } - - #[test] - fn slow_wandering_still_counts_once_far_enough() { - let mut trip = Trip::new(Totals::default(), false); - trip.feed(fix(0, 0, 0)); - // 0.5 m/s (under the moving threshold) for 60 s: 30 m from the start, counted in one 25 m+ step - drive(&mut trip, 0, 0, 60, 500); - assert!(trip.totals.distance_mm >= DRIFT_MM, "{}", trip.totals.distance_mm); - assert_eq!(trip.totals.moving_ms, 0); - } - - #[test] - fn moving_time_only_while_moving() { - let mut trip = Trip::new(Totals::default(), false); - trip.feed(fix(0, 0, 0)); - let (lat, t) = drive(&mut trip, 0, 0, 20, 4_000); - let moving = trip.totals.moving_ms; - assert_eq!(moving, 19_000); - // stop for 30 s: the window drains within 4 s, then no more moving time - let mut t2 = t; - for _ in 0..30 { - t2 += 1_000; - trip.feed(fix(lat, 0, t2)); - } - assert!(trip.totals.moving_ms - moving <= 3_000, "{}", trip.totals.moving_ms - moving); - assert_eq!(trip.speed(t2), Some(0)); - } - - #[test] - fn elapsed_time_runs_once_started() { - let mut trip = Trip::new(Totals::default(), false); - trip.clock(0); - trip.clock(1_000); - assert_eq!(trip.totals.elapsed_ms, 0, "not before the first fix"); - trip.feed(fix(0, 0, 1_000)); - trip.clock(2_000); - trip.clock(3_000); - assert_eq!(trip.totals.elapsed_ms, 2_000); - trip.clock(60_000); // a stall: not counted - assert_eq!(trip.totals.elapsed_ms, 2_000); - } - - #[test] - fn fix_lost_after_stale() { - let mut trip = Trip::new(Totals::default(), false); - trip.feed(fix(0, 0, 1_000)); - assert_eq!(trip.status(2_000), Status::Fix(8)); - trip.feed(Sample { fix: 0, sats: 2, ..fix(0, 0, 2_500) }); - assert_eq!(trip.status(2_500), Status::Fix(8), "one missed reading: the last fix still stands"); - trip.feed(Sample { fix: 0, sats: 2, ..fix(0, 0, 4_100) }); - assert_eq!(trip.status(4_100), Status::Lost(2)); - assert_eq!(trip.speed(4_100), None); - } - - #[test] - fn ascent_counts_climbs_not_noise() { - let mut trip = Trip::new(Totals::default(), false); - let mut lat = 0; - // 60 s moving at 3 m/s with ±2 m of altitude noise on a flat road - let noise = [0, 20, -20, 10, -10]; - for i in 0..60u32 { - lat += north(3); - let s = Sample { alt_dm: 1_000 + noise[i as usize % 5], ..fix(lat, 0, i * 1_000) }; - trip.feed(s); - } - assert_eq!(trip.totals.ascent_dm, 0); - // then climb 30 m over 60 s - for i in 60..120u32 { - lat += north(3); - trip.feed(Sample { alt_dm: 1_000 + (i as i32 - 60) * 5, ..fix(lat, 0, i * 1_000) }); - } - let a = trip.totals.ascent_dm as i32; - assert!((200..=300).contains(&a), "{a}"); - } - - #[test] - fn reset_keeps_units_and_track() { - let mut trip = Trip::new(Totals::default(), true); - trip.feed(fix(0, 0, 0)); - let (lat, t) = drive(&mut trip, 0, 0, 10, 5_000); - trip.reset(); - assert_eq!(trip.totals.distance_mm, 0); - assert!(trip.imperial); - assert_eq!(trip.feed(fix(lat + north(5), 0, t + 1_000)), Feed::Accepted); - assert!(trip.totals.distance_mm > 4_000); - } - - #[test] - fn storage_round_trip() { - let t = Totals { - distance_mm: 123_456_789_012, - moving_ms: 7_200_000, - elapsed_ms: 9_000_000, - max_mm_s: 15_000, - ascent_dm: 4_321, - started: true, - }; - let b = encode(&t, true); - assert_eq!(decode(&b), Some((t, true))); - assert_eq!(decode(&encode(&Totals::default(), false)), Some((Totals::default(), false))); - } - - #[test] - fn storage_rejects_foreign_blobs() { - let b = encode(&Totals::default(), false); - let mut bad = b; - bad[0] = b'X'; - assert_eq!(decode(&bad), None); - let mut v2 = b; - v2[2] = 2; - assert_eq!(decode(&v2), None); - let mut flags = b; - flags[3] = 0x80; - assert_eq!(decode(&flags), None); - assert_eq!(decode(&b[..STORE_LEN - 1]), None); - assert_eq!(decode(&[]), None); - } - - #[test] - fn saves_wait_for_movement_and_a_minute() { - let mut t = Totals::default(); - let mut g = SaveGate::loaded(t, false, 0); - assert!(!g.due(&t, false, 120_000, false), "nothing changed"); - t.elapsed_ms = 50_000; - assert!(!g.due(&t, false, 120_000, false), "only the clock ran: wait for pause or exit"); - assert!(g.due(&t, false, 120_000, true)); - t.distance_mm = 10_000; - assert!(g.due(&t, false, 120_000, false)); - g.saved(&t, false, 120_000); - t.distance_mm = 20_000; - assert!(!g.due(&t, false, 150_000, false), "within a minute of the last save"); - assert!(g.due(&t, false, 180_000, false)); - assert!(g.due(&t, false, 150_000, true), "forced"); - g.saved(&t, false, 150_000); - assert!(g.due(&t, true, 150_001, true), "units changed"); - assert!(!g.due(&t, false, 150_001, true)); - } -} diff --git a/apps/trip-computer/src/view.rs b/apps/trip-computer/src/view.rs deleted file mode 100644 index 926ea43..0000000 --- a/apps/trip-computer/src/view.rs +++ /dev/null @@ -1,797 +0,0 @@ -//! The screens, drawn through `cmf_wp2_ui::Surface` so host tests see the watch's pixels. Black background, the -//! system font's family (`cmf_wp2_ui::font`, Inter 20 px) for all text, the speed in dot-matrix figures (the watch's -//! own style for big numbers), the stock colours (`cmf_wp2_app::stock`): white values, grey captions, the accent for -//! warnings and the destructive button. -//! -//! Layout on the round 466×466 panel (visible half-width at row `y` is `isqrt(233² - (y - 233)²)`). Text `y` is the -//! top of its caps (`font`: where the old 16 px cell started); the loader's status bar keeps the top 30 px. -//! -//! ```text -//! Speed (menu) Details Reset? -//! y 56 GPS status y 52 "Trip" title (accent) y 134 "Reset trip?" -//! y 80 satellites y 92..272 six rows, y 180 / 204 what it clears -//! y 108 speed dots (11 px pitch) label left, value right y 250 Cancel | Reset pills -//! y 200 km/h y 318 Units | Reset pills -//! y 232 divider y 412 page dots -//! y 248 / 272 trip | moving -//! y 306 / 330 avg | max -//! y 412 page dots -//! ``` -//! -//! The page next to the watch face is the speed screen without the avg/max row and the dots, [`PAGE_DY`] lower. - -use crate::fmt::{self, Text}; -use crate::trip::{Status, Totals, Trip}; -use cmf_wp2_ui::color::Rgb; -use cmf_wp2_ui::font; -use cmf_wp2_ui::text::dots_opaque; -use cmf_wp2_ui::widget::{page_dots, Button}; -use cmf_wp2_ui::{Surface, SIZE}; - -pub const BG: u16 = 0x0000; -pub const WHITE: u16 = 0xFFFF; -/// `stock::GREY`, `stock::ACCENT`, `stock::ROW_BG`. -pub const GREY: u16 = 0x8C92; -pub const ACCENT: u16 = 0xFA23; -pub const ROW_BG: u16 = 0x2966; - -/// Caps of [`font`] text start `CAP_TOP` below its `y` and are `CAP` tall. -const CAP_TOP: i32 = 2; -const CAP: i32 = 14; - -const STATUS_Y: i32 = 56; -const SATS_Y: i32 = 80; -const SPEED_Y: i32 = 108; -/// The speed's dot matrix: one font pixel = a `SPEED_DOT` px square every `SPEED_PITCH` px (88 px per char, as the -/// old 11× digits, so "1000" still fits; the gaps make the dot look). -pub const SPEED_PITCH: i32 = 11; -pub const SPEED_DOT: i32 = 8; -const UNIT_Y: i32 = 200; -const RULE_Y: i32 = 232; -const ROW1_CAPTION_Y: i32 = 248; -const ROW1_Y: i32 = 272; -const ROW2_CAPTION_Y: i32 = 306; -const ROW2_Y: i32 = 330; -const LEFT_CX: i32 = 140; -const RIGHT_CX: i32 = 326; -const DOTS_Y: i32 = 412; -/// The page has no second row and no dots: its block moves down to sit in the middle. -const PAGE_DY: i32 = 36; - -const TITLE_Y: i32 = 52; -const ROWS_Y: i32 = 92; -const ROW_PITCH: i32 = 36; -const LABEL_X: i32 = 64; -const VALUE_RIGHT: i32 = 402; -/// Taps above this on the details screen go back to the speed screen. -const BACK_ZONE_Y: i32 = 84; - -const PILL_W: i32 = 160; -const PILL_H: i32 = 56; -const PILL_LEFT_X: i32 = 64; -const PILL_RIGHT_X: i32 = 242; -const SETTINGS_Y: i32 = 318; -const CONFIRM_Y: i32 = 250; -const CONFIRM_TITLE_Y: i32 = 134; -const CONFIRM_TEXT_Y: i32 = 180; -/// Line pitch of [`font`] text in a paragraph. -const LINE: i32 = 24; - -const UNITS_KM: &str = "Units km"; -const UNITS_MI: &str = "Units mi"; - -#[derive(Clone, Copy, PartialEq, Debug)] -pub enum Align { - Centre, - Right, -} - -/// How a [`Cell`] draws its text. -#[derive(Clone, Copy, PartialEq, Debug)] -pub enum Style { - /// [`font`]: Inter 20 px. - Inter, - /// Dot matrix ([`dots_opaque`]): `pitch` px per font pixel, `dot` px squares. - Dots { pitch: i32, dot: i32 }, -} - -/// A box `(x, y, w, h)`. -type Box4 = (i32, i32, i32, i32); - -/// Forwards to a surface and keeps the bounding box of what was drawn (proportional glyphs reach a little above -/// their `y` and below the line box: clearing exactly this leaves nothing behind). -struct Bounds<'a, S: Surface> { - s: &'a mut S, - /// Corners `(x0, y0, x1, y1)`, not a [`Box4`]. - b: Option<(i32, i32, i32, i32)>, -} - -impl Surface for Bounds<'_, S> { - fn rect(&mut self, x: i32, y: i32, w: i32, h: i32, c: u16) { - if w > 0 && h > 0 { - self.s.rect(x, y, w, h, c); - let (x0, y0, x1, y1) = self.b.unwrap_or((x, y, x + w, y + h)); - self.b = Some((x0.min(x), y0.min(y), x1.max(x + w), y1.max(y + h))); - } - } - - fn text(&mut self, x: i32, y: i32, s: &str, c: u16) { - self.s.text(x, y, s, c); - } -} - -/// [`font::draw`]; returns the box it painted. -fn inter(s: &mut impl Surface, x: i32, y: i32, text: &str, c: u16) -> Option { - let mut b = Bounds { s, b: None }; - font::draw(&mut b, x, y, text, c); - b.b.map(|(x0, y0, x1, y1)| (x0, y0, x1 - x0, y1 - y0)) -} - -/// Columns of the dot-matrix point: two lit, one gap. A full 8-column cell made "29.9" read as "29 . 9". -const POINT_COLS: i32 = 3; - -/// Width of `text` in dot-matrix columns: 8 per figure, [`POINT_COLS`] for a decimal point. -fn dot_cols(text: &str) -> i32 { - text.chars().map(|c| if c == '.' { POINT_COLS } else { 8 }).sum() -} - -/// `text` in opaque dot-matrix figures from `x` (off dots painted [`BG`], so new figures replace old ones without a -/// clear). The point is drawn here, two dots square on the font's rows 5 and 6, in a narrow cell of its own. -fn dot_figures(s: &mut impl Surface, x: i32, y: i32, text: &str, pitch: i32, dot: i32, fg: u16) { - let mut x = x; - let mut b = [0u8; 4]; - for ch in text.chars() { - if ch == '.' { - for col in 0..POINT_COLS { - for row in 0..8 { - let on = col < 2 && (5..=6).contains(&row); - s.rect(x + col * pitch, y + row * pitch, dot, dot, if on { fg } else { BG }); - } - } - x += POINT_COLS * pitch; - } else { - dots_opaque(s, x, y, ch.encode_utf8(&mut b), pitch, dot, fg, BG); - x += 8 * pitch; - } - } -} - -/// A piece of text at a fixed spot that repaints only when it changes, clearing just what it drew before. -pub struct Cell { - x: i32, - y: i32, - style: Style, - align: Align, - fg: u16, - text: Text, - drawn: Option, - dirty: bool, -} - -impl Cell { - pub const fn new(x: i32, y: i32, style: Style, align: Align, fg: u16) -> Self { - Cell { x, y, style, align, fg, text: Text::new(), drawn: None, dirty: true } - } - - pub fn set(&mut self, s: &str, fg: u16) { - let t = Text::from(s); - if t != self.text || fg != self.fg { - self.text = t; - self.fg = fg; - self.dirty = true; - } - } - - /// The screen under it was cleared: draw again, nothing to erase. - pub fn invalidate(&mut self) { - self.drawn = None; - self.dirty = true; - } - - /// Left x and width of `text` as this cell lays it out. - fn place(&self, text: &str) -> (i32, i32) { - let (w, ink) = match self.style { - Style::Inter => (font::width(text), font::width(text)), - // the 8×8 glyphs leave their right column (or two) empty: centre the ink, not the cells - Style::Dots { pitch, .. } => { - // centred in whole columns: the dots stay on one grid whatever the text, so new figures paint - // exactly over old ones (a point is 3 columns, a figure 8: half a width is not a column) - let cols = dot_cols(text); - let ink = (cols - 1).max(0); - let x = match self.align { - Align::Centre => self.x - ink / 2 * pitch, - Align::Right => self.x - ink * pitch, - }; - return (x, cols * pitch); - } - }; - let x = match self.align { - Align::Centre => self.x - ink / 2, - Align::Right => self.x - ink, - }; - (x, w) - } - - pub fn draw(&mut self, s: &mut impl Surface) -> bool { - if !self.dirty { - return false; - } - self.dirty = false; - let old = self.drawn.take(); - let text = self.text.as_str(); - let (x, w) = self.place(text); - match self.style { - Style::Inter => { - if let Some((ox, oy, ow, oh)) = old { - s.rect(ox, oy, ow, oh, BG); - } - self.drawn = inter(s, x, self.y, text, self.fg); - } - Style::Dots { pitch, dot } => { - // the new figures paint their off dots too, so they replace the old ones without a clear (no - // flicker); only the old cells left or right of the new text are cleared - let h = 8 * pitch; - if let Some((ox, oy, ow, _)) = old { - s.rect(ox, oy, ow.min(x - ox), h, BG); - let r = (x + w).max(ox); - s.rect(r, oy, ox + ow - r, h, BG); - } - dot_figures(s, x, self.y, text, pitch, dot, self.fg); - self.drawn = (w > 0).then_some((x, self.y, w, h)); - } - } - true - } -} - -#[derive(Clone, Copy, PartialEq, Debug)] -pub enum Screen { - Speed, - Details, - Confirm, -} - -/// What the user asked for. -#[derive(Clone, Copy, PartialEq, Debug)] -pub enum Action { - None, - Show(Screen), - ToggleUnits, - Reset, -} - -/// The GPS as the app sees it. -#[derive(Clone, Copy, PartialEq, Debug)] -pub enum Gps { - /// `gps(true)` failed: a loader older than 2026-11-19. - Unavailable, - On(Status), -} - -/// Everything a screen shows, taken from the trip once per loop turn. -#[derive(Clone, Copy, PartialEq, Debug)] -pub struct Frame { - pub gps: Gps, - pub speed: Option, - pub totals: Totals, - pub alt_dm: Option, - pub imperial: bool, -} - -impl Frame { - pub fn of(trip: &Trip, gps_ok: bool, now: u32) -> Self { - Frame { - gps: if gps_ok { Gps::On(trip.status(now)) } else { Gps::Unavailable }, - speed: trip.speed(now), - totals: trip.totals, - alt_dm: trip.alt_dm, - imperial: trip.imperial, - } - } -} - -/// The two status lines: text and colour. -pub fn status_lines(gps: Gps) -> ((Text<20>, u16), (Text<20>, u16)) { - let sats = |n: u8| { - let mut t = Text::<20>::new(); - t.num(n as u64).push(if n == 1 { " satellite" } else { " satellites" }); - t - }; - match gps { - Gps::Unavailable => ((Text::from("GPS unavailable"), ACCENT), (Text::from("Update App Loader"), GREY)), - Gps::On(Status::Searching(n)) => ((Text::from("Waiting for GPS"), WHITE), (sats(n), GREY)), - Gps::On(Status::Lost(n)) => ((Text::from("GPS signal lost"), ACCENT), (sats(n), GREY)), - Gps::On(Status::Fix(n)) => { - let mut t = Text::from("GPS "); - t.push(sats(n).as_str()); - ((t, GREY), (Text::new(), GREY)) - } - } -} - -pub struct View { - pub screen: Screen, - page: bool, - full: bool, - imperial: Option, - status: Cell<20>, - sats: Cell<20>, - speed: Cell<8>, - unit: Cell<8>, - values: [Cell<10>; 4], - rows: [Cell<12>; 6], - units: Pill, - reset: Pill, - cancel: Pill, - confirm: Pill, -} - -/// A stock pill button ([`Button`]: shape, pressed look, hit box) with its caption in [`font`]. -struct Pill { - b: Button, - label: &'static str, -} - -impl Pill { - fn new(x: i32, y: i32, label: &'static str, c: u16) -> Self { - // Button's own caption would be the cell font: it gets none, the label is drawn over it - Pill { b: Button::new(x, y, PILL_W, PILL_H, "", Rgb::from565(c), Rgb::from565(BG)), label } - } - - fn tap(&mut self, x: i32, y: i32, now: u32) -> bool { - self.b.tap(x, y, now) - } - - fn wait(&self, now: u32) -> Option { - self.b.wait(now) - } - - fn invalidate(&mut self) { - self.b.invalidate(); - } - - fn set_label(&mut self, label: &'static str) { - if label != self.label { - self.label = label; - self.b.invalidate(); - } - } - - fn draw(&mut self, s: &mut impl Surface, now: u32) -> bool { - if !self.b.draw(s, now) { - return false; - } - font::centre(s, self.b.x + self.b.w / 2, self.b.y + (self.b.h - CAP) / 2 - CAP_TOP, self.label, self.b.fg); - true - } -} - -const ROW_LABELS: [&str; 6] = ["Altitude", "Ascent", "Elapsed", "Moving", "Average", "Max"]; - -impl View { - pub fn new(page: bool) -> Self { - let pill = Pill::new; - let row = |i: i32| Cell::new(VALUE_RIGHT, ROWS_Y + i * ROW_PITCH, Style::Inter, Align::Right, WHITE); - let speed = Style::Dots { pitch: SPEED_PITCH, dot: SPEED_DOT }; - let dy = if page { PAGE_DY } else { 0 }; - View { - screen: Screen::Speed, - page, - full: true, - imperial: None, - status: Cell::new(SIZE / 2, STATUS_Y + dy, Style::Inter, Align::Centre, WHITE), - sats: Cell::new(SIZE / 2, SATS_Y + dy, Style::Inter, Align::Centre, GREY), - speed: Cell::new(SIZE / 2, SPEED_Y + dy, speed, Align::Centre, WHITE), - unit: Cell::new(SIZE / 2, UNIT_Y + dy, Style::Inter, Align::Centre, GREY), - values: [ - Cell::new(LEFT_CX, ROW1_Y + dy, Style::Inter, Align::Centre, WHITE), - Cell::new(RIGHT_CX, ROW1_Y + dy, Style::Inter, Align::Centre, WHITE), - Cell::new(LEFT_CX, ROW2_Y, Style::Inter, Align::Centre, WHITE), - Cell::new(RIGHT_CX, ROW2_Y, Style::Inter, Align::Centre, WHITE), - ], - rows: [row(0), row(1), row(2), row(3), row(4), row(5)], - units: pill(PILL_LEFT_X, SETTINGS_Y, UNITS_KM, ROW_BG), - reset: pill(PILL_RIGHT_X, SETTINGS_Y, "Reset", ACCENT), - cancel: pill(PILL_LEFT_X, CONFIRM_Y, "Cancel", ROW_BG), - confirm: pill(PILL_RIGHT_X, CONFIRM_Y, "Reset", ACCENT), - } - } - - pub fn go(&mut self, screen: Screen) { - if screen != self.screen { - self.screen = screen; - self.full = true; - } - } - - /// Everything again (after `RESUME`: the loader repaints its copy, but the app may have changed meanwhile). - pub fn invalidate(&mut self) { - self.full = true; - } - - /// ms until a pressed button must be drawn released again. - pub fn wait(&self, now: u32) -> Option { - [&self.units, &self.reset, &self.cancel, &self.confirm].iter().filter_map(|p| p.wait(now)).min() - } - - pub fn tap(&mut self, x: i32, y: i32, now: u32) -> Action { - if self.page { - return Action::None; // one compact screen next to the face - } - match self.screen { - Screen::Speed => Action::Show(Screen::Details), - Screen::Details if self.units.tap(x, y, now) => Action::ToggleUnits, - Screen::Details if self.reset.tap(x, y, now) => Action::Show(Screen::Confirm), - Screen::Details if y < BACK_ZONE_Y || y >= DOTS_Y - 16 => Action::Show(Screen::Speed), - Screen::Confirm if self.confirm.tap(x, y, now) => Action::Reset, - Screen::Confirm if self.cancel.tap(x, y, now) => Action::Show(Screen::Details), - _ => Action::None, - } - } - - pub fn crown(&mut self, delta: i16) -> Action { - match self.screen { - _ if self.page || delta == 0 => Action::None, - Screen::Speed if delta > 0 => Action::Show(Screen::Details), - Screen::Details if delta < 0 => Action::Show(Screen::Speed), - Screen::Confirm => Action::Show(Screen::Details), - _ => Action::None, - } - } - - fn cells_invalidate(&mut self) { - self.status.invalidate(); - self.sats.invalidate(); - self.speed.invalidate(); - self.unit.invalidate(); - self.values.iter_mut().for_each(Cell::invalidate); - self.rows.iter_mut().for_each(Cell::invalidate); - for b in [&mut self.units, &mut self.reset, &mut self.cancel, &mut self.confirm] { - b.invalidate(); - } - } - - /// Paints what changed since the last call; `true` when something was drawn (then `show`). - pub fn draw(&mut self, s: &mut impl Surface, f: &Frame, now: u32) -> bool { - if self.imperial != Some(f.imperial) { - self.imperial = Some(f.imperial); - self.units.set_label(if f.imperial { UNITS_MI } else { UNITS_KM }); - self.full = true; // captions carry the units - } - let full = core::mem::take(&mut self.full); - if full { - s.rect(0, 0, SIZE, SIZE, BG); - self.cells_invalidate(); - } - let drew = match self.screen { - Screen::Speed => self.draw_speed(s, f, full), - Screen::Details => self.draw_details(s, f, full, now), - Screen::Confirm => self.draw_confirm(s, full, now), - }; - full || drew - } - - fn draw_speed(&mut self, s: &mut impl Surface, f: &Frame, full: bool) -> bool { - let imp = f.imperial; - if full { - let dy = if self.page { PAGE_DY } else { 0 }; - s.rect(70, RULE_Y + dy, SIZE - 140, 2, ROW_BG); - let mut trip = Text::<12>::from("Trip "); - trip.push(fmt::distance_unit(imp)); - let mut avg = Text::<12>::from("Avg "); - avg.push(fmt::speed_unit(imp)); - let mut max = Text::<12>::from("Max "); - max.push(fmt::speed_unit(imp)); - caption(s, LEFT_CX, ROW1_CAPTION_Y + dy, trip.as_str()); - caption(s, RIGHT_CX, ROW1_CAPTION_Y + dy, "Moving"); - if !self.page { - caption(s, LEFT_CX, ROW2_CAPTION_Y, avg.as_str()); - caption(s, RIGHT_CX, ROW2_CAPTION_Y, max.as_str()); - page_dots(s, DOTS_Y, 2, 0, Rgb::from565(WHITE), Rgb::from565(ROW_BG)); - } - } - let ((st, sc), (sa, sac)) = status_lines(f.gps); - self.status.set(st.as_str(), sc); - self.sats.set(sa.as_str(), sac); - match f.speed { - Some(v) => self.speed.set(fmt::speed(v, imp).as_str(), WHITE), - None => self.speed.set("--", GREY), - } - self.unit.set(fmt::speed_unit(imp), GREY); - let t = &f.totals; - self.values[0].set(fmt::distance(t.distance_mm, imp).as_str(), WHITE); - self.values[1].set(fmt::duration(t.moving_ms).as_str(), WHITE); - self.values[2].set(fmt::speed(t.avg_mm_s(), imp).as_str(), WHITE); - self.values[3].set(fmt::speed(t.max_mm_s, imp).as_str(), WHITE); - let shown = if self.page { 2 } else { 4 }; - let mut drew = false; - drew |= self.status.draw(s); - drew |= self.sats.draw(s); - drew |= self.speed.draw(s); - drew |= self.unit.draw(s); - for c in &mut self.values[..shown] { - drew |= c.draw(s); - } - drew - } - - fn draw_details(&mut self, s: &mut impl Surface, f: &Frame, full: bool, now: u32) -> bool { - let imp = f.imperial; - if full { - font::centre(s, SIZE / 2, TITLE_Y, "Trip", ACCENT); - for (i, l) in ROW_LABELS.iter().enumerate() { - font::draw(s, LABEL_X, ROWS_Y + i as i32 * ROW_PITCH, l, GREY); - } - page_dots(s, DOTS_Y, 2, 1, Rgb::from565(WHITE), Rgb::from565(ROW_BG)); - } - let t = &f.totals; - let speed = |v: u32| { - let mut x = Text::<12>::from(fmt::speed(v, imp).as_str()); - x.push(" ").push(fmt::speed_unit(imp)); - x - }; - let alt = match f.alt_dm { - Some(a) => Text::from(fmt::height(a as i64, imp).as_str()), - None => Text::from("--"), - }; - let values: [Text<12>; 6] = [ - alt, - Text::from(fmt::height(t.ascent_dm as i64, imp).as_str()), - Text::from(fmt::duration(t.elapsed_ms).as_str()), - Text::from(fmt::duration(t.moving_ms).as_str()), - speed(t.avg_mm_s()), - speed(t.max_mm_s), - ]; - let mut drew = false; - for (c, v) in self.rows.iter_mut().zip(values.iter()) { - c.set(v.as_str(), WHITE); - drew |= c.draw(s); - } - drew |= self.units.draw(s, now); - drew |= self.reset.draw(s, now); - drew - } - - fn draw_confirm(&mut self, s: &mut impl Surface, full: bool, now: u32) -> bool { - if full { - font::centre(s, SIZE / 2, CONFIRM_TITLE_Y, "Reset trip?", WHITE); - for (y, l) in [(CONFIRM_TEXT_Y, "Distance, times and"), (CONFIRM_TEXT_Y + LINE, "speeds go back to 0")] { - font::centre(s, SIZE / 2, y, l, GREY); - } - } - let mut drew = self.cancel.draw(s, now); - drew |= self.confirm.draw(s, now); - drew - } -} - -fn caption(s: &mut impl Surface, cx: i32, y: i32, text: &str) { - font::centre(s, cx, y, text, GREY); -} - -#[cfg(test)] -mod tests { - use super::*; - use crate::trip::Totals; - use cmf_wp2_ui::geom::inside; - use cmf_wp2_ui::Fb; - use std::vec; - use std::vec::Vec; - - fn busy() -> Frame { - Frame { - gps: Gps::On(Status::Fix(11)), - speed: Some(27_000), - totals: Totals { - distance_mm: 123_456_000, - moving_ms: 35_999_000, - elapsed_ms: 40_000_000, - max_mm_s: 27_500, - ascent_dm: 12_345, - started: true, - }, - alt_dm: Some(-1_234), - imperial: false, - } - } - - fn waiting() -> Frame { - Frame { gps: Gps::On(Status::Searching(3)), speed: None, totals: Totals::default(), alt_dm: None, imperial: false } - } - - /// The widest text every cell can get: "1000" km/h, "99999" km, "999:59:59", "-3000 m". - fn widest() -> Frame { - Frame { - gps: Gps::On(Status::Fix(22)), - speed: Some(u32::MAX), - totals: Totals { - distance_mm: 999_999_000_000, // capped at "99999" - moving_ms: 3_599_999_000, - elapsed_ms: 3_599_999_000, - max_mm_s: 1_000_000, - ascent_dm: 9_999_990, - started: true, - }, - alt_dm: Some(-30_000), - imperial: false, - } - } - - /// Every frame the tests draw, in both units. - fn frames() -> Vec { - let base = [busy(), waiting(), widest(), Frame { gps: Gps::Unavailable, ..waiting() }, Frame { gps: Gps::On(Status::Lost(2)), ..busy() }]; - [false, true].iter().flat_map(|&imperial| base.iter().map(move |f| Frame { imperial, ..*f })).collect() - } - - const SCREENS: [(bool, Screen); 4] = [(false, Screen::Speed), (false, Screen::Details), (false, Screen::Confirm), (true, Screen::Speed)]; - - fn render(v: &mut View, f: &Frame) -> Vec { - let mut px = vec![0u16; (SIZE * SIZE) as usize]; - let mut fb = Fb::new(&mut px); - v.draw(&mut fb, f, 0); - px - } - - /// Every lit pixel is on the round panel, 4 px in from its edge. - fn assert_inside(px: &[u16], what: &str) { - for y in 0..SIZE { - for x in 0..SIZE { - if px[(y * SIZE + x) as usize] != BG { - let (dx, dy) = (x - SIZE / 2, y - SIZE / 2); - assert!(inside(x, y) && dx * dx + dy * dy <= 229 * 229, "{what}: lit pixel at ({x}, {y})"); - } - } - } - } - - #[test] - fn every_screen_stays_inside_the_circle() { - for f in frames() { - for (page, screen) in SCREENS { - let mut v = View::new(page); - v.go(screen); - assert_inside(&render(&mut v, &f), &format!("{screen:?} page={page} {f:?}")); - } - } - } - - /// The loader's status bar (time and GPS bars, centred at y = 4) keeps the top of the panel. - const STATUS_BAR_H: i32 = 30; - - #[test] - fn the_status_bar_stays_clear() { - // the loader draws the time and the GPS bars at the top: nothing of the app's up there - for f in frames() { - for (page, screen) in SCREENS { - let mut v = View::new(page); - v.go(screen); - let px = render(&mut v, &f); - let top = px[..(STATUS_BAR_H * SIZE) as usize].iter().position(|&p| p != BG); - assert_eq!(top, None, "{screen:?} page={page} {f:?}"); - } - } - } - - /// Counts the loader's cell-font text calls (a `Button` passes its empty caption, which draws nothing). - struct CellText(u32); - impl Surface for CellText { - fn rect(&mut self, _: i32, _: i32, _: i32, _: i32, _: u16) {} - fn text(&mut self, _: i32, _: i32, s: &str, _: u16) { - self.0 += !s.is_empty() as u32; - } - } - - #[test] - fn no_cell_font_text() { - for f in frames() { - for (page, screen) in SCREENS { - let mut v = View::new(page); - v.go(screen); - let mut c = CellText(0); - v.draw(&mut c, &f, 0); - assert_eq!(c.0, 0, "{screen:?} page={page}"); - } - } - } - - #[test] - fn widest_values_fit_their_columns() { - // the widest text each cell can get stays left/right of the other column - let v = View::new(false); - let (lx, lw) = v.values[0].place("99999"); - let (rx, _) = v.values[1].place("999:59:59"); - assert!(lx + lw + 16 < rx, "trip {lx}+{lw} vs moving {rx}"); - assert!(font::width("Avg km/h") / 2 + font::width("Max km/h") / 2 + 16 < RIGHT_CX - LEFT_CX, "captions touch"); - let (sx, sw) = v.speed.place("1000"); - assert!(sx >= 20 && sx + sw <= SIZE - 20, "speed {sx}+{sw}"); - for (i, r) in v.rows.iter().enumerate() { - for widest in ["999999 ft", "-3000 m", "999:59:59", "1000 km/h"] { - let (x, _) = r.place(widest); - assert!(x > LABEL_X + font::width(ROW_LABELS[i]) + 16, "row {i}: {widest}"); - } - } - // the pill captions fit their pills with room to spare - for l in [UNITS_KM, UNITS_MI, "Reset", "Cancel"] { - assert!(font::width(l) + 32 <= PILL_W, "{l}"); - } - } - - #[test] - fn speed_figures_replace_each_other_without_a_clear() { - // a new speed of the same length paints over the old one: no rect clears the figures' box first - let mut v = View::new(false); - let mut px = vec![0u16; (SIZE * SIZE) as usize]; - v.draw(&mut Fb::new(&mut px), &busy(), 0); - struct Clears(u32); - impl Surface for Clears { - fn rect(&mut self, _: i32, _: i32, w: i32, h: i32, c: u16) { - self.0 += (c == BG && w > SPEED_PITCH && h >= 8 * SPEED_PITCH) as u32; - } - fn text(&mut self, _: i32, _: i32, _: &str, _: u16) {} - } - let mut c = Clears(0); - assert!(v.draw(&mut c, &Frame { speed: Some(20_000), ..busy() }, 0)); - assert_eq!(c.0, 0); - } - - #[test] - fn partial_redraw_matches_a_full_one() { - // longer and shorter texts both ways ("--", "97.2", "9.0", "1000"), every value and status line changing - let slow = Frame { speed: Some(2_500), gps: Gps::On(Status::Lost(1)), ..widest() }; - let steps = [waiting(), busy(), slow, waiting(), widest(), busy()]; - for page in [false, true] { - for (i, pair) in steps.windows(2).enumerate() { - let mut v = View::new(page); - let mut px = vec![0u16; (SIZE * SIZE) as usize]; - let mut fb = Fb::new(&mut px); - v.draw(&mut fb, &pair[0], 0); - let before = fb.rects; - assert!(v.draw(&mut fb, &pair[1], 0)); - assert!(!v.draw(&mut fb, &pair[1], 0), "nothing changed: nothing drawn"); - let partial = fb.rects - before; - drop(fb); - let mut w = View::new(page); - let fresh = render(&mut w, &pair[1]); - assert!(px == fresh, "step {i} page={page}"); - assert!(partial > 0); - } - } - } - - #[test] - fn waiting_shows_no_speed() { - let ((a, _), (b, _)) = status_lines(Gps::On(Status::Searching(3))); - assert_eq!((a.as_str(), b.as_str()), ("Waiting for GPS", "3 satellites")); - let ((a, c), _) = status_lines(Gps::On(Status::Lost(1))); - assert_eq!((a.as_str(), c), ("GPS signal lost", ACCENT)); - let ((a, _), (b, _)) = status_lines(Gps::On(Status::Fix(9))); - assert_eq!((a.as_str(), b.as_str()), ("GPS 9 satellites", "")); - } - - #[test] - fn caps_sit_where_the_layout_expects() { - // pills centre their caption on CAP; the status bar test relies on nothing reaching far above `y` - let mut px = vec![0u16; (SIZE * SIZE) as usize]; - let b = inter(&mut Fb::new(&mut px), 100, 100, "H", WHITE); - assert_eq!(b.map(|(_, y, _, h)| (y, h)), Some((100 + CAP_TOP, CAP))); - } - - #[test] - fn navigation() { - let mut v = View::new(false); - assert_eq!(v.crown(-1), Action::None); - assert_eq!(v.tap(233, 233, 0), Action::Show(Screen::Details)); - v.go(Screen::Details); - assert_eq!(v.tap(PILL_LEFT_X + 10, SETTINGS_Y + 10, 0), Action::ToggleUnits); - assert_eq!(v.tap(PILL_RIGHT_X + 10, SETTINGS_Y + 10, 1_000), Action::Show(Screen::Confirm)); - assert_eq!(v.tap(233, 60, 2_000), Action::Show(Screen::Speed)); - assert_eq!(v.tap(233, 200, 3_000), Action::None); - v.go(Screen::Confirm); - assert_eq!(v.tap(PILL_LEFT_X + 10, CONFIRM_Y + 10, 4_000), Action::Show(Screen::Details)); - assert_eq!(v.tap(PILL_RIGHT_X + 10, CONFIRM_Y + 10, 5_000), Action::Reset); - assert_eq!(v.crown(1), Action::Show(Screen::Details)); - let mut p = View::new(true); - assert_eq!(p.tap(233, 233, 0), Action::None); - assert_eq!(p.crown(1), Action::None); - } -} diff --git a/apps/trip-computer/store.md b/apps/trip-computer/store.md deleted file mode 100644 index 5c0e333..0000000 --- a/apps/trip-computer/store.md +++ /dev/null @@ -1,26 +0,0 @@ -A speedometer and trip computer on the watch's own GPS. Open it outdoors, wait a moment for the satellites, and go: - -- **Speed screen**: your speed in big dot-matrix digits, the GPS status, the trip distance and moving time, and the average - (while moving) and top speed. Before the first fix it says **Waiting for GPS** with the number of satellites in - use; if the fix drops it says **GPS signal lost** and the speed shows `--`. -- **Details**: turn the crown or tap the speed screen. Altitude, ascent, elapsed time, moving time, average and top - speed. **Units** switches between km and miles; **Reset** starts a new trip after you confirm. Turn the crown back - or tap the title to return. - -It can also live next to the watch face: long-press **Trip Computer** in Apps and choose **Add page** for the compact -speed screen one swipe from the face, or **Add widget** for a card with the trip distance, moving time, average and -top speed. - -The watch's GPS gives positions only, so the speed is worked out from successive fixes and smoothed over a few -seconds. Readings without a proper fix, sudden jumps (over 300 km/h) and the drift of a receiver standing still -are left out, and nothing counts while the app is closed or the page is swiped away: the GPS is off then. The trip -records while the app is open, also with the screen dark. The receiver costs battery while it runs. - -The trip totals and the unit are kept on the watch. The app stores no positions and sends nothing anywhere. Like -during a workout, the watch's own firmware keeps track points of its own while the GPS has a fix. - -## Requirements - -- The [patched firmware](/firmware) and the [App Loader](/firmware) **from 2026-11-19 or later** for the GPS (an - older App Loader shows "GPS unavailable"). The page and the widget need the App Loader from 2026-11-15 or later. -- Open it from the **Apps** row at the end of the watch's app list (list style, not the waterfall). diff --git a/apps/trip-computer/store.toml b/apps/trip-computer/store.toml deleted file mode 100644 index ea8d066..0000000 --- a/apps/trip-computer/store.toml +++ /dev/null @@ -1,6 +0,0 @@ -# The app's listing in the FMC store (README.md, "store.toml"). The page's body is store.md. -name = "Trip Computer" -summary = "A GPS speedometer and trip computer on the watch's own GPS, with a page next to the face and a widget" -version = "0.1.0" -author = "Ziyad Eslam" -screenshots = ["shots/speed.png", "shots/details.png", "shots/page.png"] diff --git a/apps/twenty48/Cargo.toml b/apps/twenty48/Cargo.toml deleted file mode 100644 index 0f50bc0..0000000 --- a/apps/twenty48/Cargo.toml +++ /dev/null @@ -1,12 +0,0 @@ -[package] -name = "twenty48" -edition.workspace = true -license.workspace = true -version.workspace = true - -[dependencies] -cmf-wp2-app.workspace = true - -[[bin]] -name = "twenty48" -bench = false diff --git a/apps/twenty48/icon.svg b/apps/twenty48/icon.svg deleted file mode 100644 index fb07a0a..0000000 --- a/apps/twenty48/icon.svg +++ /dev/null @@ -1,5 +0,0 @@ - - - - 2048 - diff --git a/apps/twenty48/src/game.rs b/apps/twenty48/src/game.rs deleted file mode 100644 index e956702..0000000 --- a/apps/twenty48/src/game.rs +++ /dev/null @@ -1,142 +0,0 @@ -pub const N: usize = 4; - -#[derive(Clone, Copy, Debug, PartialEq, Eq)] -pub enum Dir { Left, Up, Right, Down } - -#[derive(Clone, Copy, Debug, PartialEq, Eq)] -pub struct Game { - pub cells: [u16; 16], - pub score: u32, - pub best: u32, - seed: u32, - pub won: bool, -} - -impl Game { - pub const fn new(seed: u32, best: u32) -> Self { - Self { cells: [0; 16], score: 0, best, seed: seed | 1, won: false } - } - - fn random(&mut self) -> u32 { - let mut x = self.seed; - x ^= x << 13; x ^= x >> 17; x ^= x << 5; - self.seed = x; - x - } - - pub fn spawn(&mut self) -> bool { - let empty = self.cells.iter().filter(|&&v| v == 0).count(); - if empty == 0 { return false; } - let mut pick = (self.random() as usize) % empty; - for i in 0..self.cells.len() { - if self.cells[i] == 0 { - if pick == 0 { - let value = if self.random() % 10 == 0 { 4 } else { 2 }; - self.cells[i] = value; - return true; - } - pick -= 1; - } - } - false - } - - fn line_index(dir: Dir, line: usize, pos: usize) -> usize { - match dir { - Dir::Left => line * 4 + pos, - Dir::Right => line * 4 + (3 - pos), - Dir::Up => pos * 4 + line, - Dir::Down => (3 - pos) * 4 + line, - } - } - - pub fn move_dir(&mut self, dir: Dir) -> bool { - let old = self.cells; - for line in 0..4 { - let mut vals = [0u16; 4]; - let mut n = 0; - for pos in 0..4 { - let v = self.cells[Self::line_index(dir, line, pos)]; - if v != 0 { vals[n] = v; n += 1; } - } - let mut out = [0u16; 4]; - let (mut i, mut j) = (0, 0); - while i < n { - if i + 1 < n && vals[i] == vals[i + 1] { - out[j] = vals[i].saturating_mul(2); - self.score = self.score.saturating_add(out[j] as u32); - i += 2; - } else { out[j] = vals[i]; i += 1; } - j += 1; - } - for pos in 0..4 { self.cells[Self::line_index(dir, line, pos)] = out[pos]; } - } - let changed = self.cells != old; - if changed { - self.best = self.best.max(self.score); - self.spawn(); - if self.cells.contains(&2048) { self.won = true; } - } - changed - } - - pub fn over(&self) -> bool { - if self.cells.contains(&0) { return false; } - for y in 0..4 { for x in 0..4 { - let i = y * 4 + x; - if x < 3 && self.cells[i] == self.cells[i + 1] { return false; } - if y < 3 && self.cells[i] == self.cells[i + 4] { return false; } - }} - true - } - - pub fn restart(&mut self) { - self.cells = [0; 16]; self.score = 0; self.won = false; - self.spawn(); self.spawn(); - } -} - -#[cfg(test)] -mod tests { - use super::*; - - fn ready(cells: [u16; 16]) -> Game { Game { cells, score: 0, best: 0, seed: 12345, won: false } } - - #[test] - fn left_merges_once_and_scores() { - let mut g = ready([2, 2, 2, 2, 0, 0, 0, 0, 4, 4, 8, 0, 0, 0, 0, 0]); - assert!(g.move_dir(Dir::Left)); - assert_eq!(&g.cells[0..4], &[4, 4, 0, 0]); - assert_eq!(&g.cells[8..12], &[8, 8, 0, 0]); - assert_eq!(g.score, 16); // 2+2+2+2 -> 4+4 scores 8, 4+4 -> 8 scores 8 - } - - #[test] - fn vertical_and_reverse_moves() { - let mut g = ready([2,0,0,0, 2,0,0,0, 4,0,0,0, 0,0,0,0]); - g.move_dir(Dir::Up); - assert_eq!(&g.cells[0..4], &[4,0,0,0]); - assert_eq!(&g.cells[4..8], &[4,0,0,0]); - let mut h = ready([2,2,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0]); - h.move_dir(Dir::Right); - assert_eq!(&h.cells[0..4], &[0,0,0,4]); - } - - #[test] - fn full_board_detects_legal_move_and_game_over() { - let mut g = ready([2,2,4,8, 16,32,64,128, 256,512,1024,2, 4,8,16,32]); - assert!(!g.over()); - assert!(g.move_dir(Dir::Left)); - let mut h = ready([2,4,8,16, 32,64,128,256, 512,1024,2,4, 8,16,32,64]); - assert!(h.over()); - assert!(!h.move_dir(Dir::Left)); - } - - #[test] - fn restart_keeps_best_and_spawns_two_tiles() { - let mut g = ready([0; 16]); g.best = 2048; g.restart(); - assert_eq!(g.cells.iter().filter(|&&v| v != 0).count(), 2); - assert_eq!(g.best, 2048); - assert_eq!(g.score, 0); - } -} diff --git a/apps/twenty48/src/main.rs b/apps/twenty48/src/main.rs deleted file mode 100644 index 63351a4..0000000 --- a/apps/twenty48/src/main.rs +++ /dev/null @@ -1,150 +0,0 @@ -#![cfg_attr(any(target_os = "none", wp2_sim), no_main, cfg_attr(target_os = "none", no_std))] - -#[cfg_attr(not(any(target_os = "none", wp2_sim)), allow(dead_code))] -mod game; - -#[cfg(not(any(target_os = "none", wp2_sim)))] -fn main() {} - -#[cfg(any(target_os = "none", wp2_sim))] -mod device { - use crate::game::{Dir, Game}; - use cmf_wp2_app::{Api, BUTTON, CROWN, PAUSE, RESUME, TOUCH_DOWN}; - - cmf_wp2_app::entry!(main); - cmf_wp2_app::app_icon!(); - - const BG: u16 = 0x0000; - const WHITE: u16 = 0xFFFF; - const BOARD: u16 = 0x2124; - const EMPTY: u16 = 0x39E7; - const ORANGE: u16 = 0xFD20; - const MINT: u16 = 0x07E0; - const RED: u16 = 0xF800; - const CELL: i16 = 72; - const GAP: i16 = 5; - const LEFT: i16 = 84; - const TOP: i16 = 105; - const RESET_X: i16 = 183; - const RESET_Y: i16 = 52; - const LEFT_X: i16 = 42; - const RIGHT_X: i16 = 332; - const ARROW_Y: i16 = 205; - const ARROW_W: u16 = 68; - const ARROW_H: u16 = 100; - - fn tile_color(v: u16) -> u16 { - match v { - 0 => EMPTY, 2 => 0xDEFB, 4 => 0xDEB6, 8 => 0xFD20, - 16 => 0xFC60, 32 => 0xFBA0, 64 => 0xF920, - 128 => 0xFFE0, 256 => 0xD7E0, 512 => 0xAFE0, - 1024 => 0x87E0, _ => MINT, - } - } - - fn draw(api: &Api, game: &Game, _dir: Dir) { - api.rect(0, 0, api.width, api.height, BG); - api.rect(LEFT - 8, TOP - 8, 4 * CELL as u16 + 5 * GAP as u16 + 16, 4 * CELL as u16 + 5 * GAP as u16 + 16, BOARD); - for row in 0..4 { - for col in 0..4 { - let x = LEFT + col * (CELL + GAP); - let y = TOP + row * (CELL + GAP); - let v = game.cells[(row * 4 + col) as usize]; - api.rect(x, y, CELL as u16, CELL as u16, tile_color(v)); - if v != 0 { - let mut digits = [0u8; 10]; - let len = decimal(v as u32, &mut digits); - let tx = x + (CELL - len as i16 * 16) / 2; - api.text(tx, y + 28, core::str::from_utf8(&digits[..len]).unwrap_or("?"), if v >= 128 { WHITE } else { 0 }); - } - } - } - let mut score_digits = [0u8; 10]; - let score_len = decimal(game.score, &mut score_digits); - api.text(88, 61, core::str::from_utf8(&score_digits[..score_len]).unwrap_or("0"), WHITE); - let mut best_digits = [0u8; 10]; - let best_len = decimal(game.best, &mut best_digits); - api.text(354, 61, core::str::from_utf8(&best_digits[..best_len]).unwrap_or("0"), WHITE); - api.rect(RESET_X, RESET_Y, 100, 42, ORANGE); - api.text(209, 87, "RESET", BG); - - // Left/right tap buttons sit beside the board inside the circular safe area. - api.rect(LEFT_X, ARROW_Y, ARROW_W, ARROW_H, EMPTY); - api.rect(RIGHT_X, ARROW_Y, ARROW_W, ARROW_H, EMPTY); - api.text(LEFT_X + 26, ARROW_Y + 42, "<", WHITE); - api.text(RIGHT_X + 26, ARROW_Y + 42, ">", WHITE); - if game.won { api.rect(199, 393, 68, 5, MINT); } - else if game.over() { api.rect(199, 393, 68, 5, RED); } - api.show(); - } - - fn decimal(mut n: u32, out: &mut [u8; 10]) -> usize { - if n == 0 { out[0] = b'0'; return 1; } - let mut len = 0; - while n > 0 && len < out.len() { out[len] = b'0' + (n % 10) as u8; n /= 10; len += 1; } - out[..len].reverse(); - len - } - - fn direction(i: usize) -> Dir { - match i % 4 { 0 => Dir::Left, 1 => Dir::Up, 2 => Dir::Right, _ => Dir::Down } - } - - fn main(api: &'static Api) -> i32 { - let mut saved = [0u8; 4]; - let got = api.load(&mut saved); - let best = if got == 4 { u32::from_le_bytes(saved) } else { 0 }; - let seed = api.now().wrapping_mul(2_654_435_761) ^ best.rotate_left(11); - let mut game = Game::new(seed, best); - game.restart(); - api.own_back(true); - let mut selected = 0usize; - draw(api, &game, direction(selected)); - loop { - let Some(e) = api.event(u32::MAX) else { continue }; - let mut changed = false; - match e.kind { - BUTTON => { api.own_back(false); return 0; } - PAUSE => loop { - match api.event(u32::MAX).map(|e| e.kind) { - Some(RESUME) => { changed = true; break; } - Some(BUTTON) => { api.own_back(false); return 0; } - _ => {} - } - }, - CROWN if e.delta != 0 => { - // Crown controls only vertical moves: one detent per move. - let d = if e.delta > 0 { Dir::Up } else { Dir::Down }; - selected = if d == Dir::Up { 1 } else { 3 }; - if game.over() { game.restart(); } else { game.move_dir(d); } - changed = true; - } - TOUCH_DOWN => { - // Read touch-down only: this loader doesn't provide drag events and - // touch-up coordinates are unreliable. own_back keeps right-swipe BACK - // in the event queue instead of immediately force-stopping the game. - if (RESET_Y..RESET_Y + 42).contains(&e.y) && (RESET_X..RESET_X + 100).contains(&e.x) { - game.restart(); - changed = true; - } else if (ARROW_Y..ARROW_Y + ARROW_H as i16).contains(&e.y) { - let d = if (LEFT_X..LEFT_X + ARROW_W as i16).contains(&e.x) { Some(Dir::Left) } - else if (RIGHT_X..RIGHT_X + ARROW_W as i16).contains(&e.x) { Some(Dir::Right) } - else { None }; - if let Some(d) = d { - selected = match d { Dir::Left => 0, Dir::Up => 1, Dir::Right => 2, Dir::Down => 3 }; - if game.over() { game.restart(); } else { game.move_dir(d); } - changed = true; - } - } - } - RESUME => changed = true, - _ => {} - } - if changed { - let bytes = game.best.to_le_bytes(); - api.save(&bytes); - draw(api, &game, direction(selected)); - } - } - } -} diff --git a/apps/twenty48/store.md b/apps/twenty48/store.md deleted file mode 100644 index 7020ee4..0000000 --- a/apps/twenty48/store.md +++ /dev/null @@ -1,5 +0,0 @@ -Turn the crown up or down to move vertically. Tap the large left and right buttons beside the board to move sideways. Tap **RESET** above the board to start over. Press the crown or swipe right to exit. - -## Requirements - -The [patched firmware](/firmware) and the [App Loader](/firmware). Open it from the **Apps** row at the end of the watch's app list (list style, not the waterfall). diff --git a/apps/twenty48/store.toml b/apps/twenty48/store.toml deleted file mode 100644 index 33e8e1e..0000000 --- a/apps/twenty48/store.toml +++ /dev/null @@ -1,4 +0,0 @@ -name = "2048" -summary = "Move vertically with the crown and sideways with screen buttons" -version = "0.4.0" -author = "CMF Tech Community" diff --git a/apps/ui-gallery/Cargo.toml b/apps/ui-gallery/Cargo.toml deleted file mode 100644 index 0607387..0000000 --- a/apps/ui-gallery/Cargo.toml +++ /dev/null @@ -1,16 +0,0 @@ -[package] -name = "ui-gallery" -edition.workspace = true -license.workspace = true -version.workspace = true - -[dependencies] -cmf-wp2-app.workspace = true -cmf-wp2-ui.workspace = true - -[dev-dependencies] -wp2-core.workspace = true - -[[bin]] -name = "ui-gallery" -bench = false diff --git a/apps/ui-gallery/icon.svg b/apps/ui-gallery/icon.svg deleted file mode 100644 index 076256b..0000000 --- a/apps/ui-gallery/icon.svg +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/apps/ui-gallery/src/main.rs b/apps/ui-gallery/src/main.rs deleted file mode 100644 index 7779712..0000000 --- a/apps/ui-gallery/src/main.rs +++ /dev/null @@ -1,186 +0,0 @@ -//! ui-gallery: the watch's own widgets (ABI 1.2, LVGL) in the stock look: a stock focus list of sections (lists, -//! buttons, switches, gauges, a time picker, the stock fonts, the label long modes); a section opens on a tap and goes -//! back with its title or "Back". The crown scrolls. "Pages" is the vertical pager (`stock::pager`), "Cards" the -//! stock Exercise list (`FOCUS_CARDS`), "Swipe" the horizontal pager (`stock::hpager`). Host messages for tests/test_gallery_e2e.py: `!open N`, `!menu`; -//! for tests/test_pager_e2e.py `!hpager` (the horizontal pager with music labels), `!key N` (media_key). -#![cfg_attr(target_os = "none", no_std, no_main)] - -#[cfg_attr(not(target_os = "none"), allow(dead_code))] -mod screens; - -#[cfg(not(target_os = "none"))] -fn main() {} - -#[cfg(target_os = "none")] -mod device { - use crate::screens::{self, Screen, N}; - use cmf_wp2_app::lv::{Batch, LvError}; - use cmf_wp2_app::{Api, BUTTON, LV, MEDIA, MESSAGE, MSG_MAX, PAUSE}; - use cmf_wp2_ui::haptic::{Motor, TICK}; - - cmf_wp2_app::entry!(main); - cmf_wp2_app::app_icon!(); - - const CLICKED: i16 = 7; - const VALUE_CHANGED: i16 = 28; - - // read by tests/test_gallery_e2e.py: last build result, open screen (0 menu, 1 + section), screens opened - const RC: usize = 0; - const OPEN: usize = 1; - const OPENED: usize = 2; - const TICKS: usize = 3; - const PAGE: usize = 4; - // !hpager: media_bind result, MEDIA events, last MEDIA (x | y << 1), last media_key result - const BIND: usize = 5; - const MEDIAS: usize = 6; - const MEDIA_STATE: usize = 7; - const KEY: usize = 8; - // the menu's centred row (last FOCUSED), -1 before the first - const FOCUS: usize = 9; - // non-zero: in .data, fresh at every launch; RC 1 until the menu is built - #[unsafe(no_mangle)] - static mut STATS: [i32; 10] = [1, 0, 0, 0, 0, -1, 0, -1, 1, -1]; - - fn set(i: usize, v: i32) { - unsafe { (&raw mut STATS[i]).write_volatile(v) } - } - fn get(i: usize) -> i32 { - unsafe { (&raw const STATS[i]).read_volatile() } - } - fn code(r: Result<(), LvError>) -> i32 { - match r { - Ok(()) => 0, - Err(LvError::Code(c)) => c, - Err(_) => -1000, - } - } - - fn main(api: &'static Api) -> i32 { - let Some(lv) = api.lv() else { return -95 }; // loader older than ABI 1.2 - let Some(mut b) = Batch::new() else { return -1 }; - if screens::fonts(&mut b).and_then(|_| b.submit(&lv)).is_err() { - return 1; - } - let mut flush = |b: &mut Batch| b.submit(&lv); - let mut s = match screens::theme(&mut b).and_then(|_| screens::menu(&mut b, &mut flush)) { - Ok(s) => s, - Err(e) => { - set(RC, code(Err(e))); - return 2; - } - }; - set(RC, code(b.submit(&lv))); - let mut motor = Motor::new(api); - let (mut hour, mut minute) = (7u16, 30u16); - // a screen to switch to after the events of this turn: None stays, Some(None) the menu, Some(Some(i)) - let mut go: Option>; - let mut msg = [0u8; MSG_MAX]; - let mut hp = false; - loop { - go = None; - motor.update(); - let Some(e) = api.event(motor.wait().unwrap_or(u32::MAX).max(1)) else { continue }; - match e.kind { - BUTTON => break, - PAUSE => motor.off(), - MEDIA => { - set(MEDIAS, get(MEDIAS) + 1); - set(MEDIA_STATE, i32::from(e.x) | i32::from(e.y) << 1); - } - LV if s.hpager.is_some_and(|p| p.obj.0 == e.x as u16) => { - if let Some(i) = s.hpager.as_mut().and_then(|p| p.event(&e)) { - set(PAGE, i as i32); - } - } - LV if s.pager.is_some_and(|p| p.page(&e).is_some()) => { - if let Some(p) = s.pager.as_mut() { - if let Ok(Some(i)) = p.event(&mut b, &e) { - set(PAGE, i as i32); - } - } - set(RC, code(b.submit(&lv))); - } - LV => { - let h = e.x as u16; - if e.y == cmf_wp2_app::lv::FOCUSED { - set(FOCUS, e.delta as i32); - } else if e.y == CLICKED { - if let Some(i) = s.rows.iter().position(|r| r.0 == h) { - go = Some(Some(i)); - } else if s.back.iter().any(|r| r.0 == h && h != 0) { - go = Some(None); - } else if s.ticks.iter().any(|r| r.0 == h && h != 0) { - motor.play(TICK); - set(TICKS, get(TICKS) + 1); - } - } else if e.y == VALUE_CHANGED { - let v = e.delta as i32; - let r = if s.switches.iter().any(|r| r.0 == h) { - motor.play(TICK); - Ok(()) - } else if h == s.slider.0 { - let mut buf = [0u8; 11]; - b.value(s.bar, v, false) - .and_then(|_| b.value(s.arc, v, false)) - .and_then(|_| b.value(s.ring, v, false)) - .and_then(|_| b.text(s.value, cmf_wp2_ui::text::int(v, &mut buf))) - } else if h == s.hours.0 || h == s.minutes.0 { - if h == s.hours.0 { hour = v as u16 } else { minute = v as u16 } - let mut buf = [0u8; 32]; - b.text(s.picked, screens::alarm_text(hour, minute, &mut buf)) - } else { - Ok(()) - }; - let _ = r.and_then(|_| b.submit(&lv)); - } - } - MESSAGE => { - while let Some(m) = api.recv(&mut msg) { - match m { - b"!menu" => go = Some(None), - b"!hpager" => hp = true, - [b'!', b'k', b'e', b'y', b' ', d] => set(KEY, api.media_key(d.wrapping_sub(b'0'))), - [b'!', b'o', b'p', b'e', b'n', b' ', d] if (*d as usize) >= b'0' as usize - && ((*d - b'0') as usize) < N => go = Some(Some((*d - b'0') as usize)), - _ => {} - } - } - } - _ => {} - } - if core::mem::take(&mut hp) { - match screens::leave(&mut b, &s).and_then(|_| screens::hpages(&mut b, false)) { - Ok(next) => { - s = next; - set(RC, code(b.submit(&lv))); - set(PAGE, 0); - set(BIND, api.media_bind(Some(s.media[0]), Some(s.media[1]))); - } - Err(e) => set(RC, code(Err(e))), - } - } - if let Some(to) = go { - if s.hpager.is_some() { - api.media_unbind(); // its labels go away - } - let r = screens::leave(&mut b, &s).and_then(|_| match to { - None => screens::menu(&mut b, &mut flush), - Some(i) => screens::section(&mut b, &mut flush, i), - }); - match r { - Ok(next) => { - s = next; - set(RC, code(b.submit(&lv))); - set(OPEN, to.map_or(0, |i| i as i32 + 1)); - set(OPENED, get(OPENED) + 1); - } - Err(e) => set(RC, code(Err(e))), - } - (hour, minute) = (7, 30); - set(PAGE, 0); - } - } - motor.off(); - 0 - } -} diff --git a/apps/ui-gallery/src/screens.rs b/apps/ui-gallery/src/screens.rs deleted file mode 100644 index 0dda003..0000000 --- a/apps/ui-gallery/src/screens.rs +++ /dev/null @@ -1,543 +0,0 @@ -//! ui-gallery's screens: the watch's own LVGL widgets in the stock look (`cmf_wp2_app::stock`). The menu is a stock -//! focus list of sections; a section is a stock page with the accent title (tap: back), its widgets and "Back" at -//! the end. Leaving a screen deletes its page, and every object and the scroll bar with it. - -use cmf_wp2_app::lv::*; -use cmf_wp2_app::stock::{self, ACCENT, CIRCLE, GREY, ICON, LETTER_BG, ROW_BG, ROW_PRESSED, ROW_W, WHITE}; - -pub const SECTIONS: [(&str, &str); 10] = [ - ("L", "Lists"), - ("B", "Buttons"), - ("S", "Switches"), - ("G", "Gauges"), - ("P", "Picker"), - ("F", "Fonts"), - ("V", "Pages"), - ("C", "Cards"), - ("T", "Text"), - ("H", "Swipe"), -]; -/// The section with the vertical pager. -pub const PAGES: usize = 6; -/// The stock Exercise list (`focus_page(FOCUS_CARDS)`). -pub const CARDS: usize = 7; -/// The horizontal pager. -pub const SWIPE: usize = 9; -pub const N: usize = SECTIONS.len(); -/// Font slots besides the system font (slot 0). -pub const F24: u8 = 1; -pub const F18: u8 = 2; -pub const F48: u8 = 3; -pub const START: i32 = 40; -// bytes one widget group can take: flush first when fewer are left -const GROUP: usize = 560; - -/// What the app reacts to on the current screen; unused handles are `ROOT` (never an event target). -#[derive(Clone, Copy)] -pub struct Screen { - pub page: Obj, - /// `None`: the menu. - pub section: Option, - pub rows: [Obj; N], - pub back: [Obj; 2], - /// Buttons, rows and checkboxes: a tick on CLICKED. - pub ticks: [Obj; 8], - pub switches: [Obj; 2], - pub slider: Obj, - pub bar: Obj, - pub arc: Obj, - pub ring: Obj, - pub value: Obj, - pub hours: Obj, - pub minutes: Obj, - pub picked: Obj, - pub pager: Option>, - pub hpager: Option>, - /// `!hpager`: the labels the loader writes the phone's track into - pub media: [Obj; 2], -} - -const EMPTY: Screen = Screen { - page: ROOT, - section: None, - rows: [ROOT; N], - back: [ROOT; 2], - ticks: [ROOT; 8], - switches: [ROOT; 2], - slider: ROOT, - bar: ROOT, - arc: ROOT, - ring: ROOT, - value: ROOT, - hours: ROOT, - minutes: ROOT, - picked: ROOT, - pager: None, - hpager: None, - media: [ROOT; 2], -}; - -fn room(b: &mut Batch, flush: &mut impl FnMut(&mut Batch) -> Result<(), LvError>) -> Result<(), LvError> { - if b.bytes().len() + GROUP > BUF { flush(b) } else { Ok(()) } -} - -/// The fonts, in a batch of their own. -pub fn fonts(b: &mut Batch) -> Result<(), LvError> { - stock::font(b)?; - b.font(F24, StockFont::F24M)?; - b.font(F18, StockFont::F18M)?; - b.font(F48, StockFont::F48M) -} - -/// Once, first: the system font and white text for everything. -pub fn theme(b: &mut Batch) -> Result<(), LvError> { - stock::theme(b) -} - -/// Deletes the current screen (its page, with every object and its scroll bar). -pub fn leave(b: &mut Batch, s: &Screen) -> Result<(), LvError> { - if s.page != ROOT { b.del(s.page) } else { Ok(()) } -} - -/// The menu: a stock focus list, a letter circle and the name per section. -pub fn menu(b: &mut Batch, flush: &mut impl FnMut(&mut Batch) -> Result<(), LvError>) -> Result { - room(b, flush)?; - let (page, _bar) = stock::focus_page(b, ICON as u16)?; - let mut s = Screen { page, ..EMPTY }; - for (row, (letter, name)) in s.rows.iter_mut().zip(SECTIONS) { - room(b, flush)?; - *row = stock::focus_row(b, page)?; - let circle = b.create(Class::Obj, *row)?; - b.size(circle, ICON, ICON)?; - b.align(circle, Align::LeftMid, 0, 0)?; - b.style(circle, Prop::BgColor, 0, LETTER_BG)?; - b.style(circle, Prop::BgOpa, 0, 255)?; - b.style(circle, Prop::Radius, 0, CIRCLE)?; - b.style(circle, Prop::BorderWidth, 0, 0)?; - b.flags(circle, &[], &[Flag::Clickable, Flag::Scrollable])?; - let l = b.create(Class::Label, circle)?; - b.text(l, letter)?; - b.align(l, Align::Center, 0, 0)?; - let n = b.create(Class::Label, *row)?; - b.size(n, ROW_W - ICON - 64, 44)?; - b.long_mode(n, LongMode::Dot)?; - b.text(n, name)?; - b.align(n, Align::LeftMid, stock::FOCUS_TEXT_X as i16, 0)?; - } - Ok(s) -} - -#[derive(Clone, Copy)] -enum Kind { - Accent, - Secondary, - Outline, - Disabled, -} - -fn button(b: &mut Batch, parent: Obj, text: &str, kind: Kind) -> Result { - let btn = b.create(Class::Btn, parent)?; - b.size(btn, 300, 88)?; - b.style(btn, Prop::Radius, 0, 44)?; - let (bg, opa, fg) = match kind { - Kind::Accent => (ACCENT, 255, WHITE), - Kind::Secondary => (ROW_BG, 255, WHITE), - Kind::Outline => (ACCENT, 0, ACCENT), - Kind::Disabled => (ROW_BG, 255, GREY), - }; - b.style(btn, Prop::BgColor, 0, bg)?; - b.style(btn, Prop::BgOpa, 0, opa)?; - b.style(btn, Prop::BgColor, stock::PRESSED, ROW_PRESSED)?; - b.style(btn, Prop::BgOpa, stock::PRESSED, 255)?; - if let Kind::Outline = kind { - // an accent pill with a black one 3 px inside: borders stop the emulator (its display engine lacks them) - b.style(btn, Prop::BgOpa, 0, 255)?; - let inner = b.create(Class::Obj, btn)?; - b.size(inner, 294, 82)?; - b.align(inner, Align::Center, 0, 0)?; - b.style(inner, Prop::Radius, 0, 41)?; - b.style(inner, Prop::BgColor, 0, stock::BLACK)?; - b.style(inner, Prop::BgOpa, 0, 255)?; - b.style(inner, Prop::BorderWidth, 0, 0)?; - b.flags(inner, &[], &[Flag::Clickable, Flag::Scrollable])?; - } - let l = b.create(Class::Label, btn)?; - b.style(l, Prop::TextColor, 0, fg)?; - b.text(l, text)?; - b.align(l, Align::Center, 0, 0)?; - if let Kind::Disabled = kind { - b.flags(btn, &[], &[Flag::Clickable])?; - } else { - b.events(btn, &[Ev::Clicked])?; - } - Ok(btn) -} - -/// A card with a label on the left; returns (card, label). -fn labelled(b: &mut Batch, parent: Obj, text: &str) -> Result<(Obj, Obj), LvError> { - let card = stock::card(b, parent, stock::ROW_H)?; - let l = b.create(Class::Label, card)?; - b.size(l, 250, 44)?; - b.long_mode(l, LongMode::Dot)?; - b.text(l, text)?; - b.align(l, Align::LeftMid, 36, 0)?; - Ok((card, l)) -} - -/// Section `i`: a stock page with the title, the widgets, "Back". -pub fn section(b: &mut Batch, flush: &mut impl FnMut(&mut Batch) -> Result<(), LvError>, i: usize) - -> Result { - room(b, flush)?; - match i { - PAGES => return pages(b, flush), - CARDS => return cards(b, flush), - SWIPE => return hpages(b, true), - _ => {} - } - let (page, _bar) = stock::page(b)?; - let mut s = Screen { page, section: Some(i), ..EMPTY }; - let title = stock::title(b, page, SECTIONS[i].1)?; - b.flags(title, &[Flag::Clickable], &[])?; - b.events(title, &[Ev::Clicked])?; - s.back[0] = title; - match i { - 0 => { - let rows = [("W", "Wi-Fi", "On"), ("B", "Bluetooth", "Off"), ("D", "Brightness", "70%"), ("T", "Time format", "24h")]; - for (k, (letter, name, detail)) in rows.into_iter().enumerate() { - room(b, flush)?; - s.ticks[k] = stock::row(b, page, letter, name, detail)?; - } - } - 1 => { - for (k, (text, kind)) in - [("Done", Kind::Accent), ("Cancel", Kind::Secondary), ("More", Kind::Outline), ("Unavailable", Kind::Disabled)] - .into_iter() - .enumerate() - { - room(b, flush)?; - s.ticks[k] = button(b, page, text, kind)?; - } - } - 2 => { - for (k, (text, on)) in [("Do not disturb", true), ("Raise to wake", false)].into_iter().enumerate() { - room(b, flush)?; - let (card, _) = labelled(b, page, text)?; - // a 0..1 slider in the stock colours is the switch: a tap on either half sets it - let sw = b.create(Class::Slider, card)?; - b.size(sw, 84, 44)?; - b.align(sw, Align::RightMid, -36, 0)?; - b.range(sw, 0, 1)?; - b.value(sw, on as i32, false)?; - stock::slider(b, sw)?; - b.events(sw, &[Ev::ValueChanged])?; - s.switches[k] = sw; - } - for (k, text) in ["Steps", "Heart rate", "Sleep"].into_iter().enumerate() { - room(b, flush)?; - let (card, _) = labelled(b, page, text)?; - let check = b.create(Class::Btn, card)?; - b.size(check, 48, 48)?; - b.align(check, Align::RightMid, -36, 0)?; - // filled, no border (see `button`): grey, the accent while CHECKED - b.style(check, Prop::Radius, 0, 12)?; - b.style(check, Prop::BgColor, 0, LETTER_BG)?; - b.style(check, Prop::BgOpa, 0, 255)?; - b.style(check, Prop::BgColor, CHECKED, ACCENT)?; - // CHECKABLE: LVGL toggles CHECKED on every click - b.flags(check, &[Flag::Checkable], &[])?; - b.events(check, &[Ev::Clicked])?; - s.ticks[k] = check; - } - } - 3 => { - room(b, flush)?; - let card = stock::card(b, page, 230)?; - let value = b.create(Class::Label, card)?; - b.style(value, Prop::TextFont, 0, F48 as i32)?; - b.text(value, "40")?; - b.align(value, Align::TopMid, 0, 24)?; - let slider = b.create(Class::Slider, card)?; - b.size(slider, 300, 16)?; - b.align(slider, Align::TopMid, 0, 120)?; - b.value(slider, START, false)?; - stock::slider(b, slider)?; - b.events(slider, &[Ev::ValueChanged])?; - let bar = b.create(Class::Bar, card)?; - b.size(bar, 300, 10)?; - b.align(bar, Align::TopMid, 0, 176)?; - b.value(bar, START, false)?; - for (part, colour) in [(0, LETTER_BG), (stock::INDICATOR, GREY)] { - b.style(bar, Prop::BgColor, part, colour)?; - b.style(bar, Prop::BgOpa, part, 255)?; - b.style(bar, Prop::Radius, part, CIRCLE)?; - } - room(b, flush)?; - let card = stock::card(b, page, 220)?; - let arc = b.create(Class::Arc, card)?; - b.size(arc, 160, 160)?; - b.align(arc, Align::LeftMid, 40, 0)?; - b.value(arc, START, false)?; - stock::arc(b, arc, 14)?; - b.flags(arc, &[], &[Flag::Clickable])?; - // a full ring from 12 o'clock - let ring = b.create(Class::Arc, card)?; - b.size(ring, 140, 140)?; - b.align(ring, Align::RightMid, -40, 0)?; - b.angles(ring, 0, 360, 270)?; - b.value(ring, START, false)?; - stock::arc(b, ring, 10)?; - b.flags(ring, &[], &[Flag::Clickable])?; - (s.value, s.slider, s.bar, s.arc, s.ring) = (value, slider, bar, arc, ring); - } - 4 => { - room(b, flush)?; - let card = stock::card(b, page, 280)?; - let mut hours = [0u8; 24 * 3]; - let mut minutes = [0u8; 60 * 3]; - let opts = |out: &mut [u8], n: usize| { - for k in 0..n { - out[3 * k..3 * k + 3].copy_from_slice(&[b'0' + (k / 10) as u8, b'0' + (k % 10) as u8, b'\n']); - } - }; - opts(&mut hours, 24); - opts(&mut minutes, 60); - let mut rollers = [ROOT; 2]; - for (k, (o, v)) in [(&hours[..71], 7), (&minutes[..179], 30)].into_iter().enumerate() { - room(b, flush)?; - let r = b.create(Class::Roller, card)?; - // not infinite: every frame LVGL measures all rows with the selected row's font, and infinite mode - // repeats the rows 7 times (420 for minutes). font48M has a 6-glyph cache in the stock firmware, so - // the digits miss it on every row: a NAND read and an RLE unpack each. Infinite drew at 4-6 fps in - // the emulator, this draws at 22-38 (docs/app-guide.md, LVGL) - b.options(r, core::str::from_utf8(o).unwrap_or("00"), false)?; - b.size(r, 120, 250)?; - b.align(r, Align::Center, if k == 0 { -70 } else { 70 }, 0)?; - b.value(r, v, false)?; - b.style(r, Prop::BgOpa, 0, 0)?; - b.style(r, Prop::BorderWidth, 0, 0)?; - b.style(r, Prop::TextColor, 0, GREY)?; - // the selected row uses the 48 px font: rows need the line space to hold it - b.style(r, Prop::TextLineSpace, 0, 28)?; - b.style(r, Prop::TextAlign, 0, 2)?; - b.style(r, Prop::BgOpa, stock::SELECTED, 0)?; - b.style(r, Prop::TextColor, stock::SELECTED, WHITE)?; - b.style(r, Prop::TextFont, stock::SELECTED, F48 as i32)?; - b.events(r, &[Ev::ValueChanged])?; - rollers[k] = r; - } - let colon = b.create(Class::Label, card)?; - b.style(colon, Prop::TextFont, 0, F48 as i32)?; - b.text(colon, ":")?; - b.align(colon, Align::Center, 0, -4)?; - // a roller takes the crown when it is created: back to the page - b.knob(page)?; - room(b, flush)?; - let picked = b.create(Class::Label, page)?; - b.style(picked, Prop::TextColor, 0, GREY)?; - b.text(picked, "Alarm 07:30")?; - (s.hours, s.minutes, s.picked) = (rollers[0], rollers[1], picked); - } - 8 => { - // the label long modes: one fixed-size label each, same long text - const LONG: &str = "Morning run, 5.2 km along the river"; - for (mode, h, name) in [(LongMode::Wrap, 100, "Wrap"), (LongMode::Dot, 44, "Dot"), (LongMode::Scroll, 44, "Scroll"), - (LongMode::ScrollCircular, 44, "Circular"), (LongMode::Clip, 44, "Clip")] { - room(b, flush)?; - let card = stock::card(b, page, h + 72)?; - let n = b.create(Class::Label, card)?; - b.style(n, Prop::TextColor, 0, GREY)?; - b.style(n, Prop::TextFont, 0, F24 as i32)?; - b.text(n, name)?; - b.align(n, Align::TopLeft, 36, 16)?; - let l = b.create(Class::Label, card)?; - b.size(l, ROW_W - 72, h)?; - b.long_mode(l, mode)?; - b.text(l, LONG)?; - b.align(l, Align::TopLeft, 36, 52)?; - } - } - _ => { - for (font, text) in [(F18, "Aa 18 Font"), (F24, "Aa 24 Font"), (stock::FONT, "Aa 32 Font"), (F48, "Aa 48")] { - room(b, flush)?; - let l = b.create(Class::Label, page)?; - b.style(l, Prop::TextFont, 0, font as i32)?; - b.text(l, text)?; - } - room(b, flush)?; - let card = stock::card(b, page, 200)?; - let l = b.create(Class::Label, card)?; - b.size(l, ROW_W - 72, 160)?; - b.style(l, Prop::TextFont, 0, F24 as i32)?; - b.style(l, Prop::TextColor, 0, GREY)?; - b.text(l, "The quick brown fox jumps over the lazy dog.")?; - b.align(l, Align::Center, 0, 0)?; - } - } - room(b, flush)?; - s.back[1] = button(b, page, "Back", Kind::Secondary)?; - Ok(s) -} - -/// The stock Exercise list: a FOCUS_CARDS focus page; the centred card is full width, the others narrow. The last -/// card is "Back" (a focus page has no title). -fn cards(b: &mut Batch, flush: &mut impl FnMut(&mut Batch) -> Result<(), LvError>) -> Result { - let (page, _bar) = stock::focus_page(b, FOCUS_CARDS)?; - b.style(page, Prop::PadRow, 0, stock::ROW_GAP)?; - let mut s = Screen { page, section: Some(CARDS), ..EMPTY }; - for (k, name) in ["Outdoor run", "Walk", "Cycling", "Pool swim", "Back"].into_iter().enumerate() { - room(b, flush)?; - let c = stock::focus_card(b, page, stock::FOCUS_ROW_H)?; - let l = b.create(Class::Label, c)?; - b.text(l, name)?; - b.align(l, Align::LeftMid, 36, 0)?; - if k == 4 { s.back[1] = c } else { s.ticks[k] = c } - } - Ok(s) -} - -/// A page of the pager: a centred column from the title line down, `pad` px under the last child. -fn pager_page(b: &mut Batch, page: Obj, pad: i32) -> Result<(), LvError> { - b.style(page, Prop::PadTop, 0, stock::TITLE_Y)?; - b.style(page, Prop::PadBottom, 0, pad)?; - b.style(page, Prop::PadRow, 0, stock::ROW_GAP)?; - b.flex(page, Flow::Column, FlexAlign::Start, FlexAlign::Center, FlexAlign::Start) -} - -/// The pager section: three pages with dots. Page 1 a big number, page 2 rows taller than the screen (they scroll -/// first, then the pager pages on), page 3 "Back". -fn pages(b: &mut Batch, flush: &mut impl FnMut(&mut Batch) -> Result<(), LvError>) -> Result { - let p = stock::pager::<3>(b, 3)?; - let mut s = Screen { page: p.root, section: Some(PAGES), pager: Some(p), ..EMPTY }; - let [one, two, three] = p.pages; - pager_page(b, one, 0)?; - let title = stock::title(b, one, "Pages")?; - b.flags(title, &[Flag::Clickable], &[])?; - b.events(title, &[Ev::Clicked])?; - s.back[0] = title; - let big = b.create(Class::Label, one)?; - b.style(big, Prop::TextFont, 0, F48 as i32)?; - b.text(big, "1 / 3")?; - let hint = b.create(Class::Label, one)?; - b.style(hint, Prop::TextColor, 0, GREY)?; - b.style(hint, Prop::TextFont, 0, F24 as i32)?; - b.text(hint, "Swipe up or turn the crown")?; - room(b, flush)?; - pager_page(b, two, stock::TITLE_Y)?; - stock::title(b, two, "Long page")?; - for (k, (letter, name)) in [("1", "One"), ("2", "Two"), ("3", "Three"), ("4", "Four"), ("5", "Five")].into_iter().enumerate() { - room(b, flush)?; - s.ticks[k] = stock::row(b, two, letter, name, "")?; - } - room(b, flush)?; - pager_page(b, three, 0)?; - stock::title(b, three, "Last page")?; - let big = b.create(Class::Label, three)?; - b.style(big, Prop::TextFont, 0, F48 as i32)?; - b.text(big, "3 / 3")?; - s.back[1] = button(b, three, "Back", Kind::Secondary)?; - Ok(s) -} - -/// The horizontal pager as the stock workout screen, three pages "1"…"3"; page 2 holds the track title and artist -/// labels for `media_bind` (`!hpager`, tests/test_pager_e2e.py). The crown press leaves the app; as the "Swipe" -/// section (`back`) page 3 also has "Back". -pub fn hpages(b: &mut Batch, back: bool) -> Result { - let p = stock::hpager::<3>(b, 3)?; - let mut s = Screen { page: p.obj, section: back.then_some(SWIPE), hpager: Some(p), ..EMPTY }; - for (i, page) in p.pages.into_iter().enumerate() { - pager_page(b, page, 0)?; - stock::title(b, page, ["Workout", "Music", "Last"][i])?; - let big = b.create(Class::Label, page)?; - b.style(big, Prop::TextFont, 0, F48 as i32)?; - b.text(big, if back { ["1 / 3", "2 / 3", "3 / 3"][i] } else { ["1", "2", "3"][i] })?; - } - for (k, text) in ["No title", "No artist"].into_iter().enumerate() { - s.media[k] = b.create(Class::Label, p.pages[1])?; - b.text(s.media[k], text)?; - } - if back { - let hint = b.create(Class::Label, p.pages[0])?; - b.style(hint, Prop::TextColor, 0, GREY)?; - b.style(hint, Prop::TextFont, 0, F24 as i32)?; - b.text(hint, "Swipe left or right")?; - // a workout metric, as on the stock workout screen - let (card, _) = labelled(b, p.pages[0], "Heart rate")?; - let bpm = b.create(Class::Label, card)?; - b.style(bpm, Prop::TextColor, 0, ACCENT)?; - b.text(bpm, "128")?; - b.align(bpm, Align::RightMid, -36, 0)?; - s.back[1] = button(b, p.pages[2], "Back", Kind::Secondary)?; - } - Ok(s) -} - -/// "Alarm HH:MM". -pub fn alarm_text(h: u16, m: u16, buf: &mut [u8; 32]) -> &str { - let pre = b"Alarm "; - buf[..pre.len()].copy_from_slice(pre); - let n = pre.len(); - buf[n..n + 5].copy_from_slice(&[b'0' + (h / 10 % 10) as u8, b'0' + (h % 10) as u8, b':', b'0' + (m / 10 % 10) as u8, - b'0' + (m % 10) as u8]); - core::str::from_utf8(&buf[..n + 5]).unwrap_or("") -} - -#[cfg(test)] -mod tests { - extern crate std; - use super::*; - use std::boxed::Box; - use wp2_core::lvcmd::{self, Table}; - - struct Loader { - t: Table, - live_max: usize, - } - - impl Loader { - fn flush(&mut self, b: &mut Batch) -> Result<(), LvError> { - if b.bytes().is_empty() { - return Ok(()); - } - assert_eq!(lvcmd::validate(b.bytes(), &self.t, 0b1111), Ok(())); - for r in lvcmd::records(b.bytes()) { - lvcmd::apply(&mut self.t, &r.unwrap()); - } - let live = (1..=192u16).filter(|&h| self.t.class(h).is_some()).count(); - self.live_max = self.live_max.max(live); - b.clear(); - Ok(()) - } - } - - #[test] - fn every_screen_validates_and_leaving_frees_it() { - let mut f = Batch::with_buf(Box::leak(Box::new([0; BUF]))); - fonts(&mut f).unwrap(); - assert_eq!(lvcmd::validate(f.bytes(), &Table::new(), 0), Ok(())); - let mut b = Batch::with_buf(Box::leak(Box::new([0; BUF]))); - let mut l = Loader { t: Table::new(), live_max: 0 }; - theme(&mut b).unwrap(); - let menu_screen = menu(&mut b, &mut |b| l.flush(b)).unwrap(); - l.flush(&mut b).unwrap(); - let first = menu_screen.page; - let mut s = menu_screen; - for i in 0..N { - leave(&mut b, &s).unwrap(); - s = section(&mut b, &mut |b| l.flush(b), i).unwrap(); - l.flush(&mut b).unwrap(); - assert_eq!(s.page, first, "section {i} reuses the freed handles"); - leave(&mut b, &s).unwrap(); - s = menu(&mut b, &mut |b| l.flush(b)).unwrap(); - l.flush(&mut b).unwrap(); - } - std::println!("most live objects: {}", l.live_max); - assert!(l.live_max < 80); - } - - #[test] - fn alarm() { - let mut buf = [0u8; 32]; - assert_eq!(alarm_text(7, 5, &mut buf), "Alarm 07:05"); - assert_eq!(alarm_text(23, 59, &mut buf), "Alarm 23:59"); - } -} diff --git a/apps/ui-gallery/store.md b/apps/ui-gallery/store.md deleted file mode 100644 index d6e7e23..0000000 --- a/apps/ui-gallery/store.md +++ /dev/null @@ -1,7 +0,0 @@ -A tour of the stock firmware's LVGL widgets as an app can use them: lists, buttons, switches, gauges, a time picker, the built-in fonts, text modes, the vertical and horizontal pagers and the Exercise-style cards. Tap a section to open it, tap its title or **Back** to return; the crown scrolls. - -Mostly a reference for people writing their own apps. - -## Requirements - -The [patched firmware](/firmware) and the [App Loader](/firmware). Open it from the **Apps** row at the end of the watch's app list (list style, not the waterfall). diff --git a/apps/ui-gallery/store.toml b/apps/ui-gallery/store.toml deleted file mode 100644 index 89c2315..0000000 --- a/apps/ui-gallery/store.toml +++ /dev/null @@ -1,5 +0,0 @@ -# The app's listing in the FMC store (README.md, "store.toml"). The page's body is store.md. -name = "UI Gallery" -summary = "The watch's own widgets, in the stock look" -version = "0.2.0" -author = "CMF Tech Community" diff --git a/apps/v-maps/CHANGES.md b/apps/v-maps/CHANGES.md deleted file mode 100644 index 0187756..0000000 --- a/apps/v-maps/CHANGES.md +++ /dev/null @@ -1,20 +0,0 @@ -# V-maps - -## 1.1.0 - -- A menu with two big rounded buttons, Home and Work. It is the screen you get when there is no drive ("Waiting for - Vela…" over it while the phone is out of reach, "Start a destination" once it is there), and during a drive you - swipe right to open it ("Go to", with a hint) and swipe left to close it. -- Pressing Home or Work sends `n1H` / `n1W` to the phone, which ends the drive that is on, if any, and starts one to - the place saved as Home or Work in Vela (needs the new phone patch). The watch shows "Getting the route…" until the - route arrives, and "Open Vela on the phone" if nothing comes within 12 seconds. -- Holding the screen still switches the map between turning with you and held, as before; a slow swipe is not a hold. -- No map is drawn while the menu is up, and the map drawing and rotation code are as they were. -- The big font has an H and a W now. - -## 1.0.0 - -First release as its own app, from Vela Nav 1.27.1: a live heading-up or north-up map with the route as blue dots, -the streets around you, a black dome at the bottom with the next turn, its distance and the time left, a light disc -as your position, and a smooth rotation. New: its own name, icon and listing; the title on the waiting screens; -rounded bends in the streets while the map moves. diff --git a/apps/v-maps/Cargo.toml b/apps/v-maps/Cargo.toml deleted file mode 100644 index fe3be30..0000000 --- a/apps/v-maps/Cargo.toml +++ /dev/null @@ -1,13 +0,0 @@ -[package] -name = "v-maps" -edition.workspace = true -license.workspace = true -version.workspace = true - -[dependencies] -cmf-wp2-app.workspace = true -cmf-wp2-ui.workspace = true - -[[bin]] -name = "v-maps" -bench = false diff --git a/apps/v-maps/NOTICE.md b/apps/v-maps/NOTICE.md deleted file mode 100644 index 8b78b48..0000000 --- a/apps/v-maps/NOTICE.md +++ /dev/null @@ -1,9 +0,0 @@ -# Notice - -- **V-maps began as Vela Nav**, the watch app by arunk140 in the CMF Tech Community apps repository (MIT). It has - since been rewritten and extended by Abdalrahman (a new screen, map, marker, route dots, animation and icon) and - is a separate app, `v-maps`, so it installs next to Vela Nav and never replaces it. -- **Fonts**: the glyph tables in `src/fonts.rs` are rendered from Noto Sans (SIL Open Font License 1.1), see - `fonts/OFL.txt`. -- **Vela for Android** (arunk140/esp32-vela, GPL-3.0) is a separate program that V-maps talks to over Bluetooth. No - code from it is in this app. diff --git a/apps/v-maps/fonts/OFL.txt b/apps/v-maps/fonts/OFL.txt deleted file mode 100644 index c9af0d2..0000000 --- a/apps/v-maps/fonts/OFL.txt +++ /dev/null @@ -1,93 +0,0 @@ -Copyright 2022 The Noto Project Authors (https://github.com/notofonts/latin-greek-cyrillic) - -This Font Software is licensed under the SIL Open Font License, Version 1.1. -This license is copied below, and is also available with a FAQ at: -https://openfontlicense.org - - ------------------------------------------------------------ -SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 ------------------------------------------------------------ - -PREAMBLE -The goals of the Open Font License (OFL) are to stimulate worldwide -development of collaborative font projects, to support the font creation -efforts of academic and linguistic communities, and to provide a free and -open framework in which fonts may be shared and improved in partnership -with others. - -The OFL allows the licensed fonts to be used, studied, modified and -redistributed freely as long as they are not sold by themselves. The -fonts, including any derivative works, can be bundled, embedded, -redistributed and/or sold with any software provided that any reserved -names are not used by derivative works. The fonts and derivatives, -however, cannot be released under any other type of license. The -requirement for fonts to remain under this license does not apply -to any document created using the fonts or their derivatives. - -DEFINITIONS -"Font Software" refers to the set of files released by the Copyright -Holder(s) under this license and clearly marked as such. This may -include source files, build scripts and documentation. - -"Reserved Font Name" refers to any names specified as such after the -copyright statement(s). - -"Original Version" refers to the collection of Font Software components as -distributed by the Copyright Holder(s). - -"Modified Version" refers to any derivative made by adding to, deleting, -or substituting -- in part or in whole -- any of the components of the -Original Version, by changing formats or by porting the Font Software to a -new environment. - -"Author" refers to any designer, engineer, programmer, technical -writer or other person who contributed to the Font Software. - -PERMISSION & CONDITIONS -Permission is hereby granted, free of charge, to any person obtaining -a copy of the Font Software, to use, study, copy, merge, embed, modify, -redistribute, and sell modified and unmodified copies of the Font -Software, subject to the following conditions: - -1) Neither the Font Software nor any of its individual components, -in Original or Modified Versions, may be sold by itself. - -2) Original or Modified Versions of the Font Software may be bundled, -redistributed and/or sold with any software, provided that each copy -contains the above copyright notice and this license. These can be -included either as stand-alone text files, human-readable headers or -in the appropriate machine-readable metadata fields within text or -binary files as long as those fields can be easily viewed by the user. - -3) No Modified Version of the Font Software may use the Reserved Font -Name(s) unless explicit written permission is granted by the corresponding -Copyright Holder. This restriction only applies to the primary font name as -presented to the users. - -4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font -Software shall not be used to promote, endorse or advertise any -Modified Version, except to acknowledge the contribution(s) of the -Copyright Holder(s) and the Author(s) or with their explicit written -permission. - -5) The Font Software, modified or unmodified, in part or in whole, -must be distributed entirely under this license, and must not be -distributed under any other license. The requirement for fonts to -remain under this license does not apply to any document created -using the Font Software. - -TERMINATION -This license becomes null and void if any of the above conditions are -not met. - -DISCLAIMER -THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT -OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE -COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL -DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM -OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/apps/v-maps/fonts/mkfont.py b/apps/v-maps/fonts/mkfont.py deleted file mode 100644 index 78fe3e9..0000000 --- a/apps/v-maps/fonts/mkfont.py +++ /dev/null @@ -1,80 +0,0 @@ -"""Renders Noto Sans into the antialiased glyph tables in ../src/fonts.rs. - - uv run --with pillow python fonts/mkfont.py [dir with NotoSans-*.ttf] - -The output is committed, so a build needs neither Python nor the font files. Noto Sans is under the SIL Open -Font License 1.1 (OFL.txt next to this script); the tables are a converted copy of it. -""" -import sys -from pathlib import Path -from PIL import Image, ImageDraw, ImageFont - -SRC = Path(sys.argv[1] if len(sys.argv) > 1 else "/usr/share/fonts/google-noto") -OUT = Path(__file__).resolve().parent.parent / "src" / "fonts.rs" -ASCII = "".join(chr(c) for c in range(32, 127)) - -# (Rust name, file, px, characters) -FONTS = [ - ("XL", "NotoSans-Bold.ttf", 84, "0123456789. "), - # units, the clock, the limit, titles - ("L", "NotoSans-SemiBold.ttf", 40, "0123456789:. abcdefghijklmnopqrstuvwxyzAVNROHW"), - ("S", "NotoSans-Medium.ttf", 26, ASCII + "…·"), -] - - -def glyphs(file, px, chars): - font = ImageFont.truetype(str(SRC / file), px) - ascent, descent = font.getmetrics() - rows, data = [], bytearray() - for ch in chars: - adv = round(font.getlength(ch)) - # draw on a roomy canvas, then crop to the ink (Pillow's bbox includes the side bearings) - big = Image.new("L", (px * 3, px * 3), 0) - ImageDraw.Draw(big).text((px, px * 2), ch, font=font, fill=255, anchor="ls") - q = big.point(lambda v: (v * 15 + 127) // 255 * 17) # 4-bit, so a faint edge pixel counts as nothing - box = q.getbbox() - x0, y0, w, h, off = 0, 0, 0, 0, len(data) - if box: - x0, y0 = box[0] - px, box[1] - px * 2 - w, h = box[2] - box[0], box[3] - box[1] - px4 = [v // 17 for v in q.crop(box).get_flattened_data()] - if len(px4) % 2: - px4.append(0) - data += bytes(px4[i] << 4 | px4[i + 1] for i in range(0, len(px4), 2)) - rows.append((ch, adv, x0, y0, w, h, off)) - cap = font.getbbox("H", anchor="ls")[1] # its top edge, so ink-exact - return ascent, descent, -cap, rows, data - - -def rust_char(c): - return {"'": "\\'", "\\": "\\\\"}.get(c, c) - - -out = [ - "//! Generated by `fonts/mkfont.py` from Noto Sans (SIL Open Font License 1.1, `fonts/OFL.txt`). Do not edit.", - "", - "use crate::font::{Font, Glyph};", - "", -] -total = 0 -for name, file, px, chars in FONTS: - ascent, descent, cap, rows, data = glyphs(file, px, chars) - total += len(data) + len(rows) * 12 - print(name, len(data)) - out.append(f"/// {file[:-4]} at {px} px: {len(rows)} glyphs, {len(data)} B of 4-bit coverage.") - out.append(f"pub static {name}: Font = Font {{") - out.append(f" ascent: {ascent},") - out.append(f" descent: {descent},") - out.append(f" cap: {cap},") - out.append(" glyphs: &[") - for ch, adv, x, y, w, h, off in rows: - out.append(f" Glyph {{ c: '{rust_char(ch)}', adv: {adv}, x: {x}, y: {y}, w: {w}, h: {h}, off: {off} }},") - out.append(" ],") - out.append(" bits: &[") - for i in range(0, len(data), 24): - out.append(" " + " ".join(f"{b},"for b in data[i:i + 24])) - out.append(" ],") - out.append("};") - out.append("") -OUT.write_text("\n".join(out)) -print(f"{OUT}: {total} B") diff --git a/apps/v-maps/icon.png b/apps/v-maps/icon.png deleted file mode 100644 index 1ac8c6e..0000000 Binary files a/apps/v-maps/icon.png and /dev/null differ diff --git a/apps/v-maps/icon.svg b/apps/v-maps/icon.svg deleted file mode 100644 index 716220c..0000000 --- a/apps/v-maps/icon.svg +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/apps/v-maps/shots/driving.png b/apps/v-maps/shots/driving.png deleted file mode 100644 index 2393ee4..0000000 Binary files a/apps/v-maps/shots/driving.png and /dev/null differ diff --git a/apps/v-maps/shots/off-route.png b/apps/v-maps/shots/off-route.png deleted file mode 100644 index 5690625..0000000 Binary files a/apps/v-maps/shots/off-route.png and /dev/null differ diff --git a/apps/v-maps/shots/zoomed-out.png b/apps/v-maps/shots/zoomed-out.png deleted file mode 100644 index 247284c..0000000 Binary files a/apps/v-maps/shots/zoomed-out.png and /dev/null differ diff --git a/apps/v-maps/src/font.rs b/apps/v-maps/src/font.rs deleted file mode 100644 index ec989de..0000000 --- a/apps/v-maps/src/font.rs +++ /dev/null @@ -1,219 +0,0 @@ -//! Antialiased text in the app's own fonts (`fonts.rs`, Noto Sans), drawn as runs of equal coverage blended -//! over a background colour the caller names, as every `cmf-wp2-ui` shape is. - -use cmf_wp2_ui::color::blend565; -use cmf_wp2_ui::{ONE, Surface}; - -pub struct Glyph { - pub c: char, - pub adv: u8, - /// Ink box from the pen position on the baseline. - pub x: i8, - pub y: i8, - pub w: u8, - pub h: u8, - /// Byte offset of the 4-bit coverage, two pixels a byte, rows packed. - pub off: u16, -} - -pub struct Font { - pub ascent: i32, - pub descent: i32, - /// Height of a capital above the baseline. - pub cap: i32, - pub glyphs: &'static [Glyph], - pub bits: &'static [u8], -} - -impl Font { - fn glyph(&self, c: char) -> Option<&Glyph> { - self.glyphs.iter().find(|g| g.c == c) - } - - /// Every character of `t` is in the font. - pub fn covers(&self, t: &str) -> bool { - t.chars().all(|c| self.glyph(c).is_some()) - } - - pub fn width(&self, t: &str) -> i32 { - t.chars().map(|c| self.glyph(c).map_or(0, |g| g.adv as i32)).sum() - } - - /// Draws `t` with its baseline at `y`, from `x`; returns the pen position after it. Characters the font - /// lacks are skipped. - pub fn draw(&self, s: &mut impl Surface, x: i32, y: i32, t: &str, fg: u16, bg: u16) -> i32 { - let mut shade = [0u16; 16]; - for (a, c) in shade.iter_mut().enumerate() { - *c = blend565(bg, fg, a as i32 * ONE / 15); - } - let mut pen = x; - for ch in t.chars() { - let Some(g) = self.glyph(ch) else { continue }; - let (gx, gy, w) = (pen + g.x as i32, y + g.y as i32, g.w as usize); - let at = |i: usize| { - let b = self.bits[g.off as usize + i / 2]; - if i.is_multiple_of(2) { b >> 4 } else { b & 15 } - }; - for row in 0..g.h as usize { - let base = row * w; - let mut col = 0; - while col < w { - let a = at(base + col); - let start = col; - while col < w && at(base + col) == a { - col += 1; - } - if a != 0 { - s.rect(gx + start as i32, gy + row as i32, (col - start) as i32, 1, shade[a as usize]); - } - } - } - pen += g.adv as i32; - } - pen - } - - /// The longest start of `t` that fits `max` px, and whether it was cut (then an ellipsis follows it). - pub fn fit<'a>(&self, t: &'a str, max: i32) -> (&'a str, bool) { - if self.width(t) <= max { - return (t, false); - } - let room = max - self.width("…"); - let mut w = 0; - for (i, c) in t.char_indices() { - w += self.glyph(c).map_or(0, |g| g.adv as i32); - if w > room { - return (t[..i].trim_end(), true); - } - } - (t, false) - } - - /// `t` centred on `cx`, cut with an ellipsis to `max` px. - #[allow(clippy::too_many_arguments)] - pub fn centre(&self, s: &mut impl Surface, cx: i32, y: i32, t: &str, max: i32, fg: u16, bg: u16) { - let (t, cut) = self.fit(t, max); - let w = self.width(t) + if cut { self.width("…") } else { 0 }; - let end = self.draw(s, cx - w / 2, y, t, fg, bg); - if cut { - self.draw(s, end, y, "…", fg, bg); - } - } -} - -/// A filled polygon (any shape, even-odd), antialiased: exact horizontal coverage on 4 sub-rows a pixel. -/// `paint(x)` picks the colour per column, so a shape can have two flat faces. Corners on whole pixels. -pub fn poly(s: &mut impl Surface, pts: &[(i32, i32)], bg: u16, paint: impl Fn(i32) -> u16) { - if pts.len() > 8 { - return; // icons and the car only - } - let mut h = [(0, 0); 8]; - for (d, p) in h.iter_mut().zip(pts) { - *d = (p.0 * 2, p.1 * 2); - } - poly_half(s, &h[..pts.len()], bg, paint) -} - -/// `poly` with the corners in half pixels (2 = the next pixel's left edge), so a shape can be centred on the -/// middle of a pixel, as the car's disc is. -pub fn poly_half(s: &mut impl Surface, pts: &[(i32, i32)], bg: u16, paint: impl Fn(i32) -> u16) { - const SUB: i32 = 4; // sub-rows a pixel - const FX: i32 = 16; // sub-pixel units a pixel, across - let y0 = pts.iter().map(|p| p.1).min().unwrap_or(0).div_euclid(2); - let y1 = (pts.iter().map(|p| p.1).max().unwrap_or(0) + 1).div_euclid(2); - let x0 = pts.iter().map(|p| p.0).min().unwrap_or(0).div_euclid(2); - let x1 = (pts.iter().map(|p| p.0).max().unwrap_or(0) + 1).div_euclid(2); - let wide = (x1 - x0 + 2) as usize; - if wide > 128 || pts.len() > 8 { - return; - } - for y in y0..y1 { - let mut cov = [0i32; 128]; - for k in 0..SUB { - // sample at the sub-row's middle, in 1/(2*SUB) px - let sy2 = y * 2 * SUB + 2 * k + 1; - let mut xs = [0i32; 8]; - let mut n = 0; - for i in 0..pts.len() { - let (a, b) = (pts[i], pts[(i + 1) % pts.len()]); - let (ay, by) = (a.1 * SUB, b.1 * SUB); - if (ay <= sy2) != (by <= sy2) { - xs[n] = (a.0 * (FX / 2)) + (b.0 - a.0) * (FX / 2) * (sy2 - ay) / (by - ay); - n += 1; - } - } - xs[..n].sort_unstable(); - for span in xs[..n].chunks(2) { - let [l, r] = span else { continue }; - for px in (l.div_euclid(FX))..=(r.div_euclid(FX)) { - let lo = (px * FX).max(*l); - let hi = ((px + 1) * FX).min(*r); - let i = px - x0 + 1; - if hi > lo && i >= 0 && (i as usize) < wide { - cov[i as usize] += hi - lo; - } - } - } - } - // runs of equal colour - let full = FX * SUB; - let mut i = 0; - while i < wide { - let c = cov[i]; - let x = x0 - 1 + i as i32; - let col = if c == 0 { None } else { Some(blend565(bg, paint(x), c * ONE / full)) }; - let start = i; - while i < wide && cov[i] == c && paint(x0 - 1 + i as i32) == paint(x) { - i += 1; - } - if let Some(col) = col { - s.rect(x, y, (i - start) as i32, 1, col); - } - } - } -} - -#[cfg(test)] -mod tests { - use super::*; - use crate::fonts::{L, S, XL}; - use cmf_wp2_ui::{Fb, SIZE}; - use std::vec; - - #[test] - fn fonts_have_what_the_screens_need() { - assert!(XL.covers("0123456789.")); - assert!(L.covers("12:05 pm km mi ft V maps Vela Arrived Off route Home Work")); - assert!(S.covers("Bannerghatta Main Road · 4.7 km · 12 min Rerouting…")); - assert!(!S.covers("ಹೊಸೂರು ರಸ್ತೆ")); - } - - #[test] - fn text_is_antialiased_and_fits() { - let mut px = vec![0u16; (SIZE * SIZE) as usize]; - let mut fb = Fb::new(&mut px); - let end = XL.draw(&mut fb, 100, 200, "300", 0xFFFF, 0); - assert_eq!(end, 100 + XL.width("300")); - let mut shades = std::collections::BTreeSet::new(); - for y in 100..220 { - for x in 90..end + 10 { - shades.insert(fb.at(x, y)); - } - } - assert!(shades.len() > 8, "{}", shades.len()); - let (t, cut) = S.fit("Bannerghatta Main Road", 120); - assert!(cut && S.width(t) + S.width("…") <= 120, "{t}"); - assert_eq!(S.fit("Road", 120), ("Road", false)); - } - - #[test] - fn a_polygon_has_soft_edges_and_a_solid_middle() { - let mut px = vec![0u16; (SIZE * SIZE) as usize]; - let mut fb = Fb::new(&mut px); - poly(&mut fb, &[(100, 100), (140, 160), (60, 160)], 0, |_| 0xFFFF); - assert_eq!(fb.at(100, 150), 0xFFFF); - assert_eq!(fb.at(100, 90), 0); - let edge = fb.at(79, 130); // the left edge crosses it at x 79.7 - assert!(edge != 0 && edge != 0xFFFF, "{edge:x}"); - } -} diff --git a/apps/v-maps/src/fonts.rs b/apps/v-maps/src/fonts.rs deleted file mode 100644 index bb35c35..0000000 --- a/apps/v-maps/src/fonts.rs +++ /dev/null @@ -1,1640 +0,0 @@ -//! Generated by `fonts/mkfont.py` from Noto Sans (SIL Open Font License 1.1, `fonts/OFL.txt`). Do not edit. - -use crate::font::{Font, Glyph}; - -/// NotoSans-Bold at 84 px: 12 glyphs, 12902 B of 4-bit coverage. -pub static XL: Font = Font { - ascent: 90, - descent: 25, - cap: 60, - glyphs: &[ - Glyph { c: '0', adv: 48, x: 3, y: -61, w: 42, h: 62, off: 0 }, - Glyph { c: '1', adv: 48, x: 5, y: -60, w: 30, h: 60, off: 1302 }, - Glyph { c: '2', adv: 48, x: 3, y: -61, w: 43, h: 61, off: 2202 }, - Glyph { c: '3', adv: 48, x: 3, y: -61, w: 42, h: 62, off: 3514 }, - Glyph { c: '4', adv: 48, x: 1, y: -60, w: 46, h: 60, off: 4816 }, - Glyph { c: '5', adv: 48, x: 4, y: -60, w: 41, h: 61, off: 6196 }, - Glyph { c: '6', adv: 48, x: 2, y: -61, w: 44, h: 62, off: 7447 }, - Glyph { c: '7', adv: 48, x: 2, y: -60, w: 44, h: 60, off: 8811 }, - Glyph { c: '8', adv: 48, x: 2, y: -61, w: 43, h: 62, off: 10131 }, - Glyph { c: '9', adv: 48, x: 2, y: -61, w: 43, h: 62, off: 11464 }, - Glyph { c: '.', adv: 24, x: 4, y: -13, w: 15, h: 14, off: 12797 }, - Glyph { c: ' ', adv: 22, x: 0, y: 0, w: 0, h: 0, off: 12902 }, - ], - bits: &[ - 0, 0, 0, 0, 0, 0, 0, 38, 156, 222, 255, 237, 184, 81, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 1, 125, 255, 255, 255, 255, 255, 255, 255, 180, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 126, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 195, 0, 0, 0, 0, 0, 0, 0, 0, 0, 60, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 128, 0, 0, 0, 0, 0, 0, 0, 3, 239, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 251, 16, 0, 0, 0, 0, 0, 0, 62, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 176, 0, 0, 0, 0, 0, 1, 239, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 249, - 0, 0, 0, 0, 0, 11, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 80, 0, 0, - 0, 0, 111, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 225, 0, 0, 0, 1, 239, - 255, 255, 255, 255, 255, 255, 253, 187, 223, 255, 255, 255, 255, 255, 255, 248, 0, 0, 0, 7, 255, 255, 255, 255, - 255, 255, 250, 32, 0, 3, 191, 255, 255, 255, 255, 255, 255, 32, 0, 0, 14, 255, 255, 255, 255, 255, 255, 112, - 0, 0, 0, 9, 255, 255, 255, 255, 255, 255, 128, 0, 0, 79, 255, 255, 255, 255, 255, 250, 0, 0, 0, 0, - 0, 207, 255, 255, 255, 255, 255, 225, 0, 0, 175, 255, 255, 255, 255, 255, 225, 0, 0, 0, 0, 0, 63, 255, - 255, 255, 255, 255, 245, 0, 0, 239, 255, 255, 255, 255, 255, 144, 0, 0, 0, 0, 0, 11, 255, 255, 255, 255, - 255, 250, 0, 4, 255, 255, 255, 255, 255, 255, 64, 0, 0, 0, 0, 0, 6, 255, 255, 255, 255, 255, 255, 0, - 7, 255, 255, 255, 255, 255, 254, 0, 0, 0, 0, 0, 0, 1, 255, 255, 255, 255, 255, 255, 64, 11, 255, 255, - 255, 255, 255, 251, 0, 0, 0, 0, 0, 0, 0, 223, 255, 255, 255, 255, 255, 128, 14, 255, 255, 255, 255, 255, - 248, 0, 0, 0, 0, 0, 0, 0, 159, 255, 255, 255, 255, 255, 176, 31, 255, 255, 255, 255, 255, 246, 0, 0, - 0, 0, 0, 0, 0, 127, 255, 255, 255, 255, 255, 224, 79, 255, 255, 255, 255, 255, 243, 0, 0, 0, 0, 0, - 0, 0, 79, 255, 255, 255, 255, 255, 242, 111, 255, 255, 255, 255, 255, 241, 0, 0, 0, 0, 0, 0, 0, 47, - 255, 255, 255, 255, 255, 244, 143, 255, 255, 255, 255, 255, 240, 0, 0, 0, 0, 0, 0, 0, 31, 255, 255, 255, - 255, 255, 246, 159, 255, 255, 255, 255, 255, 224, 0, 0, 0, 0, 0, 0, 0, 14, 255, 255, 255, 255, 255, 248, - 175, 255, 255, 255, 255, 255, 192, 0, 0, 0, 0, 0, 0, 0, 13, 255, 255, 255, 255, 255, 250, 207, 255, 255, - 255, 255, 255, 192, 0, 0, 0, 0, 0, 0, 0, 12, 255, 255, 255, 255, 255, 251, 223, 255, 255, 255, 255, 255, - 176, 0, 0, 0, 0, 0, 0, 0, 11, 255, 255, 255, 255, 255, 252, 223, 255, 255, 255, 255, 255, 160, 0, 0, - 0, 0, 0, 0, 0, 11, 255, 255, 255, 255, 255, 253, 239, 255, 255, 255, 255, 255, 160, 0, 0, 0, 0, 0, - 0, 0, 10, 255, 255, 255, 255, 255, 253, 239, 255, 255, 255, 255, 255, 160, 0, 0, 0, 0, 0, 0, 0, 10, - 255, 255, 255, 255, 255, 254, 239, 255, 255, 255, 255, 255, 144, 0, 0, 0, 0, 0, 0, 0, 10, 255, 255, 255, - 255, 255, 254, 239, 255, 255, 255, 255, 255, 144, 0, 0, 0, 0, 0, 0, 0, 10, 255, 255, 255, 255, 255, 254, - 239, 255, 255, 255, 255, 255, 160, 0, 0, 0, 0, 0, 0, 0, 10, 255, 255, 255, 255, 255, 253, 239, 255, 255, - 255, 255, 255, 160, 0, 0, 0, 0, 0, 0, 0, 10, 255, 255, 255, 255, 255, 253, 223, 255, 255, 255, 255, 255, - 160, 0, 0, 0, 0, 0, 0, 0, 11, 255, 255, 255, 255, 255, 253, 207, 255, 255, 255, 255, 255, 176, 0, 0, - 0, 0, 0, 0, 0, 11, 255, 255, 255, 255, 255, 252, 191, 255, 255, 255, 255, 255, 176, 0, 0, 0, 0, 0, - 0, 0, 12, 255, 255, 255, 255, 255, 251, 175, 255, 255, 255, 255, 255, 192, 0, 0, 0, 0, 0, 0, 0, 13, - 255, 255, 255, 255, 255, 250, 159, 255, 255, 255, 255, 255, 208, 0, 0, 0, 0, 0, 0, 0, 14, 255, 255, 255, - 255, 255, 248, 127, 255, 255, 255, 255, 255, 240, 0, 0, 0, 0, 0, 0, 0, 31, 255, 255, 255, 255, 255, 247, - 95, 255, 255, 255, 255, 255, 241, 0, 0, 0, 0, 0, 0, 0, 47, 255, 255, 255, 255, 255, 245, 63, 255, 255, - 255, 255, 255, 243, 0, 0, 0, 0, 0, 0, 0, 79, 255, 255, 255, 255, 255, 243, 15, 255, 255, 255, 255, 255, - 245, 0, 0, 0, 0, 0, 0, 0, 111, 255, 255, 255, 255, 255, 240, 12, 255, 255, 255, 255, 255, 248, 0, 0, - 0, 0, 0, 0, 0, 159, 255, 255, 255, 255, 255, 208, 9, 255, 255, 255, 255, 255, 251, 0, 0, 0, 0, 0, - 0, 0, 207, 255, 255, 255, 255, 255, 160, 5, 255, 255, 255, 255, 255, 254, 0, 0, 0, 0, 0, 0, 1, 255, - 255, 255, 255, 255, 255, 96, 1, 255, 255, 255, 255, 255, 255, 64, 0, 0, 0, 0, 0, 5, 255, 255, 255, 255, - 255, 255, 32, 0, 191, 255, 255, 255, 255, 255, 144, 0, 0, 0, 0, 0, 11, 255, 255, 255, 255, 255, 254, 0, - 0, 111, 255, 255, 255, 255, 255, 225, 0, 0, 0, 0, 0, 63, 255, 255, 255, 255, 255, 249, 0, 0, 31, 255, - 255, 255, 255, 255, 249, 0, 0, 0, 0, 0, 191, 255, 255, 255, 255, 255, 243, 0, 0, 9, 255, 255, 255, 255, - 255, 255, 112, 0, 0, 0, 9, 255, 255, 255, 255, 255, 255, 208, 0, 0, 3, 255, 255, 255, 255, 255, 255, 250, - 32, 0, 3, 191, 255, 255, 255, 255, 255, 255, 96, 0, 0, 0, 175, 255, 255, 255, 255, 255, 255, 253, 187, 223, - 255, 255, 255, 255, 255, 255, 253, 0, 0, 0, 0, 47, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 245, 0, 0, 0, 0, 7, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 160, 0, 0, 0, 0, 0, 191, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 253, 16, 0, 0, - 0, 0, 0, 28, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 227, 0, 0, 0, 0, 0, 0, - 1, 207, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 254, 48, 0, 0, 0, 0, 0, 0, 0, 26, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 194, 0, 0, 0, 0, 0, 0, 0, 0, 0, 93, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 231, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 92, 255, 255, 255, 255, 255, - 255, 255, 198, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 22, 155, 222, 255, 237, 185, 98, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 95, 255, 255, 255, 255, 250, 0, 0, 0, - 0, 0, 0, 0, 0, 8, 255, 255, 255, 255, 255, 250, 0, 0, 0, 0, 0, 0, 0, 1, 191, 255, 255, 255, - 255, 255, 250, 0, 0, 0, 0, 0, 0, 0, 45, 255, 255, 255, 255, 255, 255, 250, 0, 0, 0, 0, 0, 0, - 4, 239, 255, 255, 255, 255, 255, 255, 250, 0, 0, 0, 0, 0, 0, 127, 255, 255, 255, 255, 255, 255, 255, 250, - 0, 0, 0, 0, 0, 9, 255, 255, 255, 255, 255, 255, 255, 255, 250, 0, 0, 0, 0, 2, 207, 255, 255, 255, - 255, 255, 255, 255, 255, 250, 0, 0, 0, 0, 61, 255, 255, 255, 255, 255, 255, 255, 255, 255, 250, 0, 0, 0, - 5, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 250, 0, 0, 0, 143, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 250, 0, 0, 27, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 250, 0, 2, 223, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 250, 0, 78, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 250, - 7, 255, 255, 255, 255, 255, 255, 255, 170, 255, 255, 255, 255, 255, 250, 159, 255, 255, 255, 255, 255, 255, 250, 11, - 255, 255, 255, 255, 255, 250, 127, 255, 255, 255, 255, 255, 255, 128, 11, 255, 255, 255, 255, 255, 250, 10, 255, 255, - 255, 255, 255, 247, 0, 12, 255, 255, 255, 255, 255, 250, 1, 207, 255, 255, 255, 254, 64, 0, 12, 255, 255, 255, - 255, 255, 250, 0, 46, 255, 255, 255, 194, 0, 0, 13, 255, 255, 255, 255, 255, 250, 0, 4, 255, 255, 250, 16, - 0, 0, 13, 255, 255, 255, 255, 255, 250, 0, 0, 127, 255, 112, 0, 0, 0, 14, 255, 255, 255, 255, 255, 250, - 0, 0, 9, 228, 0, 0, 0, 0, 14, 255, 255, 255, 255, 255, 250, 0, 0, 0, 32, 0, 0, 0, 0, 14, - 255, 255, 255, 255, 255, 250, 0, 0, 0, 0, 0, 0, 0, 0, 15, 255, 255, 255, 255, 255, 250, 0, 0, 0, - 0, 0, 0, 0, 0, 15, 255, 255, 255, 255, 255, 250, 0, 0, 0, 0, 0, 0, 0, 0, 15, 255, 255, 255, - 255, 255, 250, 0, 0, 0, 0, 0, 0, 0, 0, 15, 255, 255, 255, 255, 255, 250, 0, 0, 0, 0, 0, 0, - 0, 0, 15, 255, 255, 255, 255, 255, 250, 0, 0, 0, 0, 0, 0, 0, 0, 15, 255, 255, 255, 255, 255, 250, - 0, 0, 0, 0, 0, 0, 0, 0, 15, 255, 255, 255, 255, 255, 250, 0, 0, 0, 0, 0, 0, 0, 0, 15, - 255, 255, 255, 255, 255, 250, 0, 0, 0, 0, 0, 0, 0, 0, 15, 255, 255, 255, 255, 255, 250, 0, 0, 0, - 0, 0, 0, 0, 0, 15, 255, 255, 255, 255, 255, 250, 0, 0, 0, 0, 0, 0, 0, 0, 15, 255, 255, 255, - 255, 255, 250, 0, 0, 0, 0, 0, 0, 0, 0, 15, 255, 255, 255, 255, 255, 250, 0, 0, 0, 0, 0, 0, - 0, 0, 15, 255, 255, 255, 255, 255, 250, 0, 0, 0, 0, 0, 0, 0, 0, 15, 255, 255, 255, 255, 255, 250, - 0, 0, 0, 0, 0, 0, 0, 0, 15, 255, 255, 255, 255, 255, 250, 0, 0, 0, 0, 0, 0, 0, 0, 15, - 255, 255, 255, 255, 255, 250, 0, 0, 0, 0, 0, 0, 0, 0, 15, 255, 255, 255, 255, 255, 250, 0, 0, 0, - 0, 0, 0, 0, 0, 15, 255, 255, 255, 255, 255, 250, 0, 0, 0, 0, 0, 0, 0, 0, 15, 255, 255, 255, - 255, 255, 250, 0, 0, 0, 0, 0, 0, 0, 0, 15, 255, 255, 255, 255, 255, 250, 0, 0, 0, 0, 0, 0, - 0, 0, 15, 255, 255, 255, 255, 255, 250, 0, 0, 0, 0, 0, 0, 0, 0, 15, 255, 255, 255, 255, 255, 250, - 0, 0, 0, 0, 0, 0, 0, 0, 15, 255, 255, 255, 255, 255, 250, 0, 0, 0, 0, 0, 0, 0, 0, 15, - 255, 255, 255, 255, 255, 250, 0, 0, 0, 0, 0, 0, 0, 0, 15, 255, 255, 255, 255, 255, 250, 0, 0, 0, - 0, 0, 0, 0, 0, 15, 255, 255, 255, 255, 255, 250, 0, 0, 0, 0, 0, 0, 0, 0, 15, 255, 255, 255, - 255, 255, 250, 0, 0, 0, 0, 0, 0, 0, 0, 15, 255, 255, 255, 255, 255, 250, 0, 0, 0, 0, 0, 0, - 0, 0, 15, 255, 255, 255, 255, 255, 250, 0, 0, 0, 0, 0, 0, 0, 0, 15, 255, 255, 255, 255, 255, 250, - 0, 0, 0, 0, 0, 0, 0, 0, 15, 255, 255, 255, 255, 255, 250, 0, 0, 0, 0, 0, 0, 0, 0, 15, - 255, 255, 255, 255, 255, 250, 0, 0, 0, 0, 0, 0, 0, 0, 15, 255, 255, 255, 255, 255, 250, 0, 0, 0, - 0, 0, 0, 0, 0, 15, 255, 255, 255, 255, 255, 250, 0, 0, 0, 0, 0, 0, 0, 0, 15, 255, 255, 255, - 255, 255, 250, 0, 0, 0, 0, 0, 0, 0, 0, 15, 255, 255, 255, 255, 255, 250, 0, 0, 0, 0, 0, 0, - 1, 71, 172, 222, 239, 238, 218, 133, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 91, 255, 255, - 255, 255, 255, 255, 255, 255, 181, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, 239, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 253, 96, 0, 0, 0, 0, 0, 0, 0, 1, 143, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 194, 0, 0, 0, 0, 0, 0, 5, 223, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 228, 0, 0, 0, 0, 0, 9, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 244, - 0, 0, 0, 0, 44, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 243, 0, 0, - 0, 62, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 209, 0, 0, 95, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 128, 0, 5, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 254, 32, 0, 7, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 248, 0, 0, 10, 255, 255, 255, 255, 255, 255, 234, 99, - 16, 19, 108, 255, 255, 255, 255, 255, 255, 255, 208, 0, 0, 12, 255, 255, 255, 255, 253, 96, 0, 0, 0, 0, - 6, 255, 255, 255, 255, 255, 255, 255, 32, 0, 0, 29, 255, 255, 255, 230, 0, 0, 0, 0, 0, 0, 5, 255, - 255, 255, 255, 255, 255, 245, 0, 0, 0, 62, 255, 255, 161, 0, 0, 0, 0, 0, 0, 0, 11, 255, 255, 255, - 255, 255, 255, 112, 0, 0, 0, 95, 254, 80, 0, 0, 0, 0, 0, 0, 0, 0, 95, 255, 255, 255, 255, 255, - 248, 0, 0, 0, 0, 124, 32, 0, 0, 0, 0, 0, 0, 0, 0, 2, 255, 255, 255, 255, 255, 255, 144, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 31, 255, 255, 255, 255, 255, 248, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 112, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 31, 255, 255, 255, 255, 255, 245, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 4, 255, 255, 255, 255, 255, 255, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 127, 255, 255, 255, 255, 255, 240, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 12, 255, 255, 255, 255, 255, 251, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 255, 255, - 255, 255, 255, 255, 96, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 191, 255, 255, 255, 255, - 255, 225, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 111, 255, 255, 255, 255, 255, 249, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 46, 255, 255, 255, 255, 255, 255, 32, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 255, 255, 255, 255, 255, 255, 128, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 9, 255, 255, 255, 255, 255, 255, 209, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 7, 255, 255, 255, 255, 255, 255, 244, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 6, 255, 255, 255, 255, 255, 255, 248, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 255, - 255, 255, 255, 255, 255, 252, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 255, 255, 255, 255, - 255, 255, 253, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 239, 255, 255, 255, 255, 255, 254, - 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 239, 255, 255, 255, 255, 255, 254, 48, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 239, 255, 255, 255, 255, 255, 255, 64, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 2, 223, 255, 255, 255, 255, 255, 255, 64, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 2, 223, 255, 255, 255, 255, 255, 255, 80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 2, 223, 255, 255, 255, 255, 255, 255, 80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 223, - 255, 255, 255, 255, 255, 255, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 223, 255, 255, 255, - 255, 255, 254, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 223, 255, 255, 255, 255, 255, 254, - 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 223, 255, 255, 255, 255, 255, 254, 48, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 223, 255, 255, 255, 255, 255, 253, 32, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 1, 223, 255, 255, 255, 255, 255, 253, 32, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 1, 207, 255, 255, 255, 255, 255, 252, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 1, 207, 255, 255, 255, 255, 255, 252, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 207, - 255, 255, 255, 255, 255, 251, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 207, 255, 255, 255, - 255, 255, 251, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 207, 255, 255, 255, 255, 255, 250, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 207, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 65, 207, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 244, 159, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 74, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 244, 175, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 74, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 244, 175, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 74, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 244, 175, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 74, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 244, 175, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 64, 0, 0, 0, 0, 0, 3, 104, 172, 222, 239, 238, 220, 184, 83, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 106, 239, 255, 255, 255, 255, 255, 255, 255, 255, 233, 64, 0, - 0, 0, 0, 0, 0, 0, 3, 174, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 253, 80, 0, 0, 0, - 0, 0, 4, 207, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 252, 48, 0, 0, 0, 3, 207, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 247, 0, 0, 0, 111, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 128, 0, 0, 46, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 246, 0, 0, 7, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 254, 32, 0, 0, 207, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 160, 0, 0, 46, 255, 255, 255, 255, 255, 255, 220, 187, 206, 255, 255, 255, 255, 255, 255, - 255, 255, 241, 0, 0, 7, 255, 255, 255, 255, 216, 48, 0, 0, 0, 38, 223, 255, 255, 255, 255, 255, 255, 246, - 0, 0, 0, 207, 255, 255, 197, 0, 0, 0, 0, 0, 0, 25, 255, 255, 255, 255, 255, 255, 250, 0, 0, 0, - 46, 255, 214, 0, 0, 0, 0, 0, 0, 0, 0, 191, 255, 255, 255, 255, 255, 252, 0, 0, 0, 7, 248, 16, - 0, 0, 0, 0, 0, 0, 0, 0, 63, 255, 255, 255, 255, 255, 253, 0, 0, 0, 0, 48, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 13, 255, 255, 255, 255, 255, 254, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 9, 255, 255, 255, 255, 255, 253, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, - 255, 255, 255, 255, 255, 251, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 255, 255, 255, - 255, 255, 250, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 255, 255, 255, 255, 255, 246, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 255, 255, 255, 255, 255, 242, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 79, 255, 255, 255, 255, 255, 176, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 207, 255, 255, 255, 255, 255, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 9, 255, 255, 255, 255, 255, 250, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 4, 207, 255, 255, 255, 255, 255, 209, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 72, 207, 255, 255, - 255, 255, 255, 253, 32, 0, 0, 0, 0, 0, 0, 6, 187, 187, 187, 205, 239, 255, 255, 255, 255, 255, 255, 255, - 193, 0, 0, 0, 0, 0, 0, 0, 8, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 248, 0, 0, 0, - 0, 0, 0, 0, 0, 8, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 251, 48, 0, 0, 0, 0, 0, 0, - 0, 0, 8, 255, 255, 255, 255, 255, 255, 255, 255, 255, 234, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, - 255, 255, 255, 255, 255, 255, 255, 255, 247, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 253, 166, 16, 0, 0, 0, 0, 0, 0, 0, 0, 8, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 251, 48, 0, 0, 0, 0, 0, 0, 0, 8, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 251, 32, 0, 0, 0, 0, 0, 0, 8, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 228, 0, 0, 0, 0, 0, 0, 8, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 80, - 0, 0, 0, 0, 0, 0, 0, 0, 1, 18, 53, 122, 223, 255, 255, 255, 255, 255, 255, 255, 227, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 159, 255, 255, 255, 255, 255, 255, 253, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 2, 207, 255, 255, 255, 255, 255, 255, 96, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 29, 255, 255, 255, 255, 255, 255, 192, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 5, 255, 255, 255, 255, 255, 255, 242, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 239, 255, 255, 255, 255, 255, 246, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 191, 255, 255, - 255, 255, 255, 248, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 159, 255, 255, 255, 255, 255, - 249, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 159, 255, 255, 255, 255, 255, 250, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 191, 255, 255, 255, 255, 255, 249, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 223, 255, 255, 255, 255, 255, 249, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 2, 255, 255, 255, 255, 255, 255, 247, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 9, 255, 255, 255, 255, 255, 255, 244, 115, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 63, - 255, 255, 255, 255, 255, 255, 241, 207, 180, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 223, 255, 255, 255, - 255, 255, 255, 176, 207, 255, 217, 64, 0, 0, 0, 0, 0, 0, 0, 0, 94, 255, 255, 255, 255, 255, 255, 255, - 96, 207, 255, 255, 254, 167, 65, 0, 0, 0, 0, 3, 125, 255, 255, 255, 255, 255, 255, 255, 253, 0, 207, 255, - 255, 255, 255, 255, 237, 187, 187, 205, 255, 255, 255, 255, 255, 255, 255, 255, 255, 246, 0, 207, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 176, 0, 207, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 254, 32, 0, 207, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 227, 0, 0, 207, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 254, 48, 0, 0, 207, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 177, 0, 0, 0, 207, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 214, 0, 0, 0, - 0, 21, 175, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 215, 0, 0, 0, 0, 0, 0, 1, - 89, 207, 255, 255, 255, 255, 255, 255, 255, 255, 255, 253, 147, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 70, - 138, 205, 222, 239, 254, 221, 185, 117, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 159, 255, 255, 255, 255, 255, 96, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 4, 255, 255, 255, 255, 255, 255, 96, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 29, 255, 255, 255, 255, 255, 255, 96, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 175, 255, 255, 255, 255, 255, 255, 96, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, - 255, 255, 255, 255, 255, 255, 255, 96, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 255, - 255, 255, 255, 255, 255, 255, 96, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 175, 255, 255, - 255, 255, 255, 255, 255, 96, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 255, 255, 255, 255, - 255, 255, 255, 255, 96, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 255, 255, 255, 255, 255, - 255, 255, 255, 96, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 175, 255, 255, 255, 255, 255, 255, - 255, 255, 96, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 96, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 96, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 175, 255, 255, 255, 255, 255, 255, 255, 255, 255, 96, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 96, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 255, 255, 255, 255, 239, 255, 255, 255, 255, 255, 96, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 175, 255, 255, 255, 253, 143, 255, 255, 255, 255, 255, 96, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 6, 255, 255, 255, 255, 246, 159, 255, 255, 255, 255, 255, 96, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 46, 255, 255, 255, 255, 208, 159, 255, 255, 255, 255, 255, 96, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 191, 255, 255, 255, 255, 96, 175, 255, 255, 255, 255, 255, 96, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 6, 255, 255, 255, 255, 252, 0, 191, 255, 255, 255, 255, 255, 96, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 46, 255, 255, 255, 255, 243, 0, 207, 255, 255, 255, 255, 255, 96, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 191, 255, 255, 255, 255, 128, 0, 207, 255, 255, 255, 255, 255, 96, 0, 0, 0, 0, 0, 0, 0, 0, 6, - 255, 255, 255, 255, 253, 0, 0, 223, 255, 255, 255, 255, 255, 96, 0, 0, 0, 0, 0, 0, 0, 0, 46, 255, - 255, 255, 255, 243, 0, 0, 223, 255, 255, 255, 255, 255, 96, 0, 0, 0, 0, 0, 0, 0, 0, 191, 255, 255, - 255, 255, 128, 0, 0, 239, 255, 255, 255, 255, 255, 96, 0, 0, 0, 0, 0, 0, 0, 6, 255, 255, 255, 255, - 253, 0, 0, 0, 239, 255, 255, 255, 255, 255, 96, 0, 0, 0, 0, 0, 0, 0, 46, 255, 255, 255, 255, 243, - 0, 0, 0, 239, 255, 255, 255, 255, 255, 96, 0, 0, 0, 0, 0, 0, 0, 191, 255, 255, 255, 255, 128, 0, - 0, 0, 239, 255, 255, 255, 255, 255, 96, 0, 0, 0, 0, 0, 0, 7, 255, 255, 255, 255, 253, 16, 0, 0, - 0, 239, 255, 255, 255, 255, 255, 96, 0, 0, 0, 0, 0, 0, 46, 255, 255, 255, 255, 243, 0, 0, 0, 0, - 239, 255, 255, 255, 255, 255, 96, 0, 0, 0, 0, 0, 0, 207, 255, 255, 255, 255, 128, 0, 0, 0, 0, 239, - 255, 255, 255, 255, 255, 96, 0, 0, 0, 0, 0, 7, 255, 255, 255, 255, 253, 16, 0, 0, 0, 0, 239, 255, - 255, 255, 255, 255, 96, 0, 0, 0, 0, 0, 47, 255, 255, 255, 255, 244, 0, 0, 0, 0, 0, 239, 255, 255, - 255, 255, 255, 96, 0, 0, 0, 0, 0, 207, 255, 255, 255, 255, 144, 0, 0, 0, 0, 0, 239, 255, 255, 255, - 255, 255, 96, 0, 0, 0, 0, 7, 255, 255, 255, 255, 253, 16, 0, 0, 0, 0, 0, 239, 255, 255, 255, 255, - 255, 96, 0, 0, 0, 0, 63, 255, 255, 255, 255, 244, 0, 0, 0, 0, 0, 0, 239, 255, 255, 255, 255, 255, - 96, 0, 0, 0, 0, 207, 255, 255, 255, 255, 144, 0, 0, 0, 0, 0, 0, 239, 255, 255, 255, 255, 255, 96, - 0, 0, 0, 7, 255, 255, 255, 255, 253, 16, 0, 0, 0, 0, 0, 0, 239, 255, 255, 255, 255, 255, 96, 0, - 0, 0, 63, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 249, 159, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 249, - 159, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 249, 159, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 249, 159, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 249, 159, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 249, 159, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 249, 159, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 249, 159, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 249, 107, 187, 187, 187, 187, 187, 187, - 187, 187, 187, 187, 187, 187, 255, 255, 255, 255, 255, 255, 203, 187, 187, 183, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 239, 255, 255, 255, 255, 255, 96, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 239, 255, 255, 255, 255, 255, 96, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 239, 255, 255, 255, 255, 255, 96, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 239, 255, 255, 255, 255, 255, 96, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 239, 255, 255, 255, 255, 255, 96, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 239, 255, 255, 255, 255, 255, 96, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 239, - 255, 255, 255, 255, 255, 96, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 239, 255, - 255, 255, 255, 255, 96, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 239, 255, 255, - 255, 255, 255, 96, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 239, 255, 255, 255, - 255, 255, 96, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 239, 255, 255, 255, 255, - 255, 96, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 239, 255, 255, 255, 255, 255, - 96, 0, 0, 0, 0, 7, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 16, 0, - 0, 0, 143, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 241, 0, 0, 0, 9, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 16, 0, 0, 0, 191, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 241, 0, 0, 0, 12, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 16, 0, 0, 0, 223, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 241, 0, 0, 0, 14, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 16, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 241, 0, 0, - 0, 31, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 16, 0, 0, 2, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 241, 0, 0, 0, 63, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 16, 0, 0, 4, 255, 255, 255, 255, 255, 249, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 111, 255, 255, 255, 255, 255, 128, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 7, 255, 255, 255, 255, 255, 246, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 143, 255, 255, 255, 255, 255, 80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 9, 255, 255, 255, 255, 255, 243, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 175, 255, 255, - 255, 255, 255, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 255, 255, 255, 255, 255, 241, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 207, 255, 255, 255, 255, 254, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 255, 255, 255, 255, 255, 208, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 252, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 31, 255, 255, 255, 255, 255, 160, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, - 255, 255, 255, 255, 255, 250, 88, 172, 238, 255, 237, 201, 98, 0, 0, 0, 0, 0, 0, 0, 63, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 253, 114, 0, 0, 0, 0, 0, 4, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 249, 16, 0, 0, 0, 0, 95, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 254, 80, 0, 0, 0, 6, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 128, 0, 0, 0, 127, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 144, - 0, 0, 8, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 112, 0, 0, 175, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 48, 0, 6, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 253, 0, 0, 2, 159, 255, 255, 255, 254, 203, 187, - 206, 255, 255, 255, 255, 255, 255, 255, 255, 255, 245, 0, 0, 0, 42, 253, 150, 49, 0, 0, 0, 1, 73, 239, - 255, 255, 255, 255, 255, 255, 255, 208, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 143, 255, 255, 255, - 255, 255, 255, 255, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 62, 255, 255, 255, 255, 255, 255, - 247, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 79, 255, 255, 255, 255, 255, 255, 176, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 159, 255, 255, 255, 255, 255, 253, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 3, 255, 255, 255, 255, 255, 255, 241, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 13, 255, 255, 255, 255, 255, 255, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 191, 255, 255, 255, 255, 255, 242, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 255, 255, - 255, 255, 255, 255, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 159, 255, 255, 255, 255, 255, - 242, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 255, 255, 255, 255, 255, 255, 16, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 207, 255, 255, 255, 255, 255, 224, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 31, 255, 255, 255, 255, 255, 253, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 5, 255, 255, 255, 255, 255, 255, 160, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 223, 255, 255, 255, 255, 255, 246, 11, 80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 143, 255, 255, 255, - 255, 255, 255, 32, 223, 215, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 127, 255, 255, 255, 255, 255, 255, 192, - 13, 255, 255, 199, 48, 0, 0, 0, 0, 0, 0, 4, 207, 255, 255, 255, 255, 255, 255, 246, 0, 223, 255, 255, - 255, 235, 133, 50, 16, 17, 53, 141, 255, 255, 255, 255, 255, 255, 255, 253, 0, 13, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 80, 0, 223, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 160, 0, 13, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 209, 0, 0, 223, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 226, 0, 0, 13, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 210, 0, 0, 0, - 223, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 177, 0, 0, 0, 13, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 254, 96, 0, 0, 0, 0, 24, 223, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 231, 16, 0, 0, 0, 0, 0, 0, 56, 207, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 234, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 88, 172, 221, 239, 255, 237, 202, 133, 32, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 54, 138, 205, 238, 255, 255, - 255, 237, 161, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 22, 190, 255, 255, 255, 255, 255, 255, 255, 255, - 241, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 58, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 241, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 59, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 241, 0, 0, 0, - 0, 0, 0, 0, 0, 25, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 241, 0, 0, 0, 0, 0, - 0, 0, 3, 223, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 241, 0, 0, 0, 0, 0, 0, 0, - 95, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 241, 0, 0, 0, 0, 0, 0, 5, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 241, 0, 0, 0, 0, 0, 0, 79, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 241, 0, 0, 0, 0, 0, 2, 239, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 220, 187, 188, 222, 255, 241, 0, 0, 0, 0, 0, 12, 255, 255, 255, 255, 255, 255, 255, 252, 132, - 32, 0, 0, 0, 0, 20, 129, 0, 0, 0, 0, 0, 143, 255, 255, 255, 255, 255, 255, 232, 32, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 255, 255, 255, 255, 255, 255, 250, 16, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 10, 255, 255, 255, 255, 255, 255, 96, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 47, 255, 255, 255, 255, 255, 245, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 159, 255, 255, 255, 255, 255, 112, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 1, 239, 255, 255, 255, 255, 252, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 255, - 255, 255, 255, 255, 243, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 255, 255, 255, - 255, 255, 176, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 31, 255, 255, 255, 255, 255, - 80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 95, 255, 255, 255, 255, 255, 16, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 159, 255, 255, 255, 255, 251, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 207, 255, 255, 255, 255, 247, 0, 0, 0, 39, 172, 239, - 254, 219, 133, 16, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 244, 0, 0, 76, 255, 255, 255, 255, 255, - 255, 233, 32, 0, 0, 0, 0, 3, 255, 255, 255, 255, 255, 241, 0, 26, 255, 255, 255, 255, 255, 255, 255, 255, - 249, 16, 0, 0, 0, 5, 255, 255, 255, 255, 255, 224, 2, 223, 255, 255, 255, 255, 255, 255, 255, 255, 255, 211, - 0, 0, 0, 7, 255, 255, 255, 255, 255, 192, 46, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 254, 48, 0, - 0, 9, 255, 255, 255, 255, 255, 177, 223, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 226, 0, 0, 10, - 255, 255, 255, 255, 255, 169, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 253, 0, 0, 12, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 128, 0, 13, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 242, 0, 14, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 236, 187, 223, 255, 255, 255, 255, 255, 255, 255, 248, 0, 14, 255, 255, 255, 255, 255, 255, 255, 255, - 180, 0, 0, 1, 110, 255, 255, 255, 255, 255, 255, 254, 0, 15, 255, 255, 255, 255, 255, 255, 255, 229, 0, 0, - 0, 0, 1, 207, 255, 255, 255, 255, 255, 255, 64, 15, 255, 255, 255, 255, 255, 255, 254, 32, 0, 0, 0, 0, - 0, 29, 255, 255, 255, 255, 255, 255, 128, 31, 255, 255, 255, 255, 255, 255, 244, 0, 0, 0, 0, 0, 0, 4, - 255, 255, 255, 255, 255, 255, 176, 15, 255, 255, 255, 255, 255, 255, 144, 0, 0, 0, 0, 0, 0, 0, 207, 255, - 255, 255, 255, 255, 224, 15, 255, 255, 255, 255, 255, 255, 32, 0, 0, 0, 0, 0, 0, 0, 127, 255, 255, 255, - 255, 255, 241, 14, 255, 255, 255, 255, 255, 252, 0, 0, 0, 0, 0, 0, 0, 0, 79, 255, 255, 255, 255, 255, - 243, 13, 255, 255, 255, 255, 255, 249, 0, 0, 0, 0, 0, 0, 0, 0, 47, 255, 255, 255, 255, 255, 243, 12, - 255, 255, 255, 255, 255, 249, 0, 0, 0, 0, 0, 0, 0, 0, 31, 255, 255, 255, 255, 255, 244, 10, 255, 255, - 255, 255, 255, 250, 0, 0, 0, 0, 0, 0, 0, 0, 15, 255, 255, 255, 255, 255, 244, 8, 255, 255, 255, 255, - 255, 251, 0, 0, 0, 0, 0, 0, 0, 0, 31, 255, 255, 255, 255, 255, 243, 5, 255, 255, 255, 255, 255, 253, - 0, 0, 0, 0, 0, 0, 0, 0, 47, 255, 255, 255, 255, 255, 243, 2, 255, 255, 255, 255, 255, 255, 32, 0, - 0, 0, 0, 0, 0, 0, 63, 255, 255, 255, 255, 255, 241, 0, 223, 255, 255, 255, 255, 255, 112, 0, 0, 0, - 0, 0, 0, 0, 111, 255, 255, 255, 255, 255, 224, 0, 159, 255, 255, 255, 255, 255, 192, 0, 0, 0, 0, 0, - 0, 0, 175, 255, 255, 255, 255, 255, 192, 0, 95, 255, 255, 255, 255, 255, 244, 0, 0, 0, 0, 0, 0, 1, - 255, 255, 255, 255, 255, 255, 144, 0, 14, 255, 255, 255, 255, 255, 253, 16, 0, 0, 0, 0, 0, 8, 255, 255, - 255, 255, 255, 255, 64, 0, 8, 255, 255, 255, 255, 255, 255, 160, 0, 0, 0, 0, 0, 79, 255, 255, 255, 255, - 255, 254, 16, 0, 2, 255, 255, 255, 255, 255, 255, 250, 16, 0, 0, 0, 5, 239, 255, 255, 255, 255, 255, 249, - 0, 0, 0, 143, 255, 255, 255, 255, 255, 255, 213, 0, 0, 3, 175, 255, 255, 255, 255, 255, 255, 243, 0, 0, - 0, 29, 255, 255, 255, 255, 255, 255, 255, 252, 188, 239, 255, 255, 255, 255, 255, 255, 255, 160, 0, 0, 0, 4, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 254, 32, 0, 0, 0, 0, 143, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 246, 0, 0, 0, 0, 0, 11, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 144, 0, 0, 0, 0, 0, 0, 175, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 250, 0, 0, 0, 0, 0, 0, 0, 9, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 144, 0, 0, 0, 0, 0, 0, 0, 0, 94, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 229, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 142, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 249, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 124, 255, 255, 255, 255, 255, 255, 255, 216, 32, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 38, 155, 222, 255, 237, 185, 99, 0, 0, 0, 0, - 0, 0, 0, 191, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 244, 191, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 244, 191, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 244, 191, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 244, 191, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 244, 191, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 244, 191, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 244, 191, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 244, 191, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 242, 191, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 176, 191, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 255, 255, 255, 255, - 255, 253, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 255, 255, 255, 255, 255, 246, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 95, 255, 255, 255, 255, 255, 225, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 207, 255, 255, 255, 255, 255, 128, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 255, 255, 255, 255, 255, 255, 32, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 10, 255, 255, 255, 255, 255, 250, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 47, 255, 255, 255, 255, 255, 243, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 159, 255, 255, 255, 255, 255, 192, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 1, 255, 255, 255, 255, 255, 255, 80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, - 255, 255, 255, 255, 255, 253, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 255, 255, - 255, 255, 255, 247, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 127, 255, 255, 255, 255, - 255, 225, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 223, 255, 255, 255, 255, 255, 144, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 255, 255, 255, 255, 255, 255, 32, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 255, 255, 255, 255, 255, 251, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 79, 255, 255, 255, 255, 255, 244, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 191, 255, 255, 255, 255, 255, 208, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 3, 255, 255, 255, 255, 255, 255, 96, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 10, 255, 255, 255, 255, 255, 254, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 47, 255, 255, 255, 255, 255, 248, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 159, - 255, 255, 255, 255, 255, 242, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 239, 255, 255, - 255, 255, 255, 160, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 255, 255, 255, 255, 255, - 255, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 255, 255, 255, 255, 255, 252, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 111, 255, 255, 255, 255, 255, 245, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 223, 255, 255, 255, 255, 255, 208, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 255, 255, 255, 255, 255, 255, 112, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 12, 255, 255, 255, 255, 255, 254, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 79, 255, 255, 255, 255, 255, 249, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 191, 255, 255, 255, 255, 255, 242, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 3, 255, 255, 255, 255, 255, 255, 176, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 255, - 255, 255, 255, 255, 255, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 47, 255, 255, 255, - 255, 255, 252, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 143, 255, 255, 255, 255, 255, - 246, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 239, 255, 255, 255, 255, 255, 224, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 255, 255, 255, 255, 255, 255, 128, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 255, 255, 255, 255, 255, 255, 16, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 111, 255, 255, 255, 255, 255, 250, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 223, 255, 255, 255, 255, 255, 243, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 5, 255, 255, 255, 255, 255, 255, 176, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 12, 255, 255, 255, 255, 255, 255, 80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 63, 255, 255, 255, 255, 255, 253, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 175, 255, - 255, 255, 255, 255, 247, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 255, 255, 255, 255, - 255, 255, 225, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 255, 255, 255, 255, 255, 255, - 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 31, 255, 255, 255, 255, 255, 255, 32, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 143, 255, 255, 255, 255, 255, 250, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 239, 255, 255, 255, 255, 255, 244, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 7, 255, 255, 255, 255, 255, 255, 192, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 122, 205, 239, 254, 220, 167, 65, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 5, 174, 255, 255, 255, 255, 255, 255, 255, 251, 97, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 1, 126, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 232, 16, 0, 0, 0, 0, 0, 0, 0, 4, - 223, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 254, 80, 0, 0, 0, 0, 0, 0, 8, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 128, 0, 0, 0, 0, 0, 9, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 160, 0, 0, 0, 0, 8, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 128, 0, 0, 0, 4, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 64, 0, 0, 0, 223, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 252, 0, 0, 0, 79, 255, 255, 255, 255, 255, 255, 255, 252, 187, 207, 255, 255, 255, 255, 255, 255, 255, - 244, 0, 0, 10, 255, 255, 255, 255, 255, 255, 252, 80, 0, 0, 21, 223, 255, 255, 255, 255, 255, 255, 144, 0, - 0, 223, 255, 255, 255, 255, 255, 248, 0, 0, 0, 0, 0, 159, 255, 255, 255, 255, 255, 253, 0, 0, 31, 255, - 255, 255, 255, 255, 250, 0, 0, 0, 0, 0, 0, 191, 255, 255, 255, 255, 255, 240, 0, 2, 255, 255, 255, 255, - 255, 255, 32, 0, 0, 0, 0, 0, 3, 255, 255, 255, 255, 255, 255, 16, 0, 63, 255, 255, 255, 255, 255, 208, - 0, 0, 0, 0, 0, 0, 13, 255, 255, 255, 255, 255, 242, 0, 2, 255, 255, 255, 255, 255, 251, 0, 0, 0, - 0, 0, 0, 0, 207, 255, 255, 255, 255, 255, 32, 0, 31, 255, 255, 255, 255, 255, 192, 0, 0, 0, 0, 0, - 0, 12, 255, 255, 255, 255, 255, 240, 0, 0, 239, 255, 255, 255, 255, 254, 0, 0, 0, 0, 0, 0, 0, 239, - 255, 255, 255, 255, 253, 0, 0, 11, 255, 255, 255, 255, 255, 244, 0, 0, 0, 0, 0, 0, 79, 255, 255, 255, - 255, 255, 160, 0, 0, 127, 255, 255, 255, 255, 255, 192, 0, 0, 0, 0, 0, 12, 255, 255, 255, 255, 255, 246, - 0, 0, 2, 255, 255, 255, 255, 255, 255, 160, 0, 0, 0, 0, 9, 255, 255, 255, 255, 255, 254, 16, 0, 0, - 10, 255, 255, 255, 255, 255, 255, 178, 0, 0, 0, 26, 255, 255, 255, 255, 255, 255, 112, 0, 0, 0, 46, 255, - 255, 255, 255, 255, 255, 229, 0, 0, 77, 255, 255, 255, 255, 255, 255, 192, 0, 0, 0, 0, 111, 255, 255, 255, - 255, 255, 255, 251, 51, 191, 255, 255, 255, 255, 255, 255, 226, 0, 0, 0, 0, 0, 159, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 227, 0, 0, 0, 0, 0, 0, 175, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 227, 0, 0, 0, 0, 0, 0, 0, 175, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 194, 0, 0, 0, 0, 0, 0, 0, 0, 143, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 94, 255, 255, 255, 255, 255, 255, 255, 255, 255, 251, 48, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 29, 255, 255, 255, 255, 255, 255, 255, 255, 252, 16, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 76, 255, 255, 255, 255, 255, 255, 255, 255, 255, 254, 112, 0, 0, 0, 0, 0, 0, 0, - 0, 1, 159, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 211, 0, 0, 0, 0, 0, 0, 0, 3, 223, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 247, 0, 0, 0, 0, 0, 0, 5, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 251, 16, 0, 0, 0, 0, 6, 255, 255, 255, 255, 255, 255, 255, - 254, 255, 255, 255, 255, 255, 255, 255, 253, 32, 0, 0, 0, 6, 255, 255, 255, 255, 255, 255, 255, 197, 6, 239, - 255, 255, 255, 255, 255, 255, 253, 16, 0, 0, 3, 255, 255, 255, 255, 255, 255, 254, 112, 0, 1, 175, 255, 255, - 255, 255, 255, 255, 252, 0, 0, 1, 223, 255, 255, 255, 255, 255, 252, 32, 0, 0, 0, 77, 255, 255, 255, 255, - 255, 255, 248, 0, 0, 127, 255, 255, 255, 255, 255, 251, 16, 0, 0, 0, 0, 26, 255, 255, 255, 255, 255, 255, - 243, 0, 13, 255, 255, 255, 255, 255, 251, 0, 0, 0, 0, 0, 0, 8, 255, 255, 255, 255, 255, 255, 176, 4, - 255, 255, 255, 255, 255, 254, 16, 0, 0, 0, 0, 0, 0, 9, 255, 255, 255, 255, 255, 255, 32, 143, 255, 255, - 255, 255, 255, 112, 0, 0, 0, 0, 0, 0, 0, 11, 255, 255, 255, 255, 255, 247, 11, 255, 255, 255, 255, 255, - 241, 0, 0, 0, 0, 0, 0, 0, 0, 79, 255, 255, 255, 255, 255, 176, 239, 255, 255, 255, 255, 253, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 239, 255, 255, 255, 255, 253, 15, 255, 255, 255, 255, 255, 176, 0, 0, 0, 0, - 0, 0, 0, 0, 12, 255, 255, 255, 255, 255, 241, 255, 255, 255, 255, 255, 251, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 207, 255, 255, 255, 255, 255, 31, 255, 255, 255, 255, 255, 208, 0, 0, 0, 0, 0, 0, 0, 0, 13, - 255, 255, 255, 255, 255, 224, 255, 255, 255, 255, 255, 255, 48, 0, 0, 0, 0, 0, 0, 0, 3, 255, 255, 255, - 255, 255, 253, 13, 255, 255, 255, 255, 255, 250, 0, 0, 0, 0, 0, 0, 0, 0, 175, 255, 255, 255, 255, 255, - 176, 175, 255, 255, 255, 255, 255, 245, 0, 0, 0, 0, 0, 0, 0, 95, 255, 255, 255, 255, 255, 248, 7, 255, - 255, 255, 255, 255, 255, 246, 0, 0, 0, 0, 0, 0, 127, 255, 255, 255, 255, 255, 255, 64, 47, 255, 255, 255, - 255, 255, 255, 252, 97, 0, 0, 0, 38, 207, 255, 255, 255, 255, 255, 255, 208, 0, 191, 255, 255, 255, 255, 255, - 255, 255, 253, 203, 188, 239, 255, 255, 255, 255, 255, 255, 255, 246, 0, 3, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 252, 0, 0, 9, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 254, 48, 0, 0, 12, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 80, 0, 0, 0, 28, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 96, 0, 0, 0, 0, 27, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 254, 64, - 0, 0, 0, 0, 0, 7, 239, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 250, 16, 0, 0, 0, - 0, 0, 0, 1, 158, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 179, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 22, 191, 255, 255, 255, 255, 255, 255, 255, 255, 216, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 20, 121, 189, 238, 255, 238, 202, 133, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 54, - 155, 222, 255, 237, 184, 98, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, 223, 255, 255, 255, - 255, 255, 255, 252, 97, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 159, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 231, 16, 0, 0, 0, 0, 0, 0, 0, 0, 5, 239, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 253, 64, 0, 0, 0, 0, 0, 0, 0, 9, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 128, - 0, 0, 0, 0, 0, 0, 10, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 144, 0, 0, - 0, 0, 0, 9, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 160, 0, 0, 0, 0, - 6, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 112, 0, 0, 0, 2, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 64, 0, 0, 0, 191, 255, 255, 255, 255, - 255, 255, 255, 236, 188, 239, 255, 255, 255, 255, 255, 255, 253, 0, 0, 0, 63, 255, 255, 255, 255, 255, 255, 250, - 48, 0, 0, 92, 255, 255, 255, 255, 255, 255, 247, 0, 0, 10, 255, 255, 255, 255, 255, 255, 228, 0, 0, 0, - 0, 9, 255, 255, 255, 255, 255, 255, 225, 0, 1, 255, 255, 255, 255, 255, 255, 243, 0, 0, 0, 0, 0, 10, - 255, 255, 255, 255, 255, 255, 112, 0, 95, 255, 255, 255, 255, 255, 247, 0, 0, 0, 0, 0, 0, 29, 255, 255, - 255, 255, 255, 253, 0, 9, 255, 255, 255, 255, 255, 254, 16, 0, 0, 0, 0, 0, 0, 79, 255, 255, 255, 255, - 255, 244, 0, 207, 255, 255, 255, 255, 255, 144, 0, 0, 0, 0, 0, 0, 0, 207, 255, 255, 255, 255, 255, 144, - 15, 255, 255, 255, 255, 255, 246, 0, 0, 0, 0, 0, 0, 0, 7, 255, 255, 255, 255, 255, 253, 2, 255, 255, - 255, 255, 255, 255, 48, 0, 0, 0, 0, 0, 0, 0, 47, 255, 255, 255, 255, 255, 241, 63, 255, 255, 255, 255, - 255, 241, 0, 0, 0, 0, 0, 0, 0, 0, 239, 255, 255, 255, 255, 255, 84, 255, 255, 255, 255, 255, 255, 0, - 0, 0, 0, 0, 0, 0, 0, 11, 255, 255, 255, 255, 255, 247, 79, 255, 255, 255, 255, 255, 240, 0, 0, 0, - 0, 0, 0, 0, 0, 175, 255, 255, 255, 255, 255, 148, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, - 0, 0, 9, 255, 255, 255, 255, 255, 251, 79, 255, 255, 255, 255, 255, 241, 0, 0, 0, 0, 0, 0, 0, 0, - 175, 255, 255, 255, 255, 255, 211, 255, 255, 255, 255, 255, 255, 64, 0, 0, 0, 0, 0, 0, 0, 12, 255, 255, - 255, 255, 255, 254, 47, 255, 255, 255, 255, 255, 247, 0, 0, 0, 0, 0, 0, 0, 2, 255, 255, 255, 255, 255, - 255, 224, 239, 255, 255, 255, 255, 255, 192, 0, 0, 0, 0, 0, 0, 0, 175, 255, 255, 255, 255, 255, 255, 12, - 255, 255, 255, 255, 255, 255, 64, 0, 0, 0, 0, 0, 0, 95, 255, 255, 255, 255, 255, 255, 240, 159, 255, 255, - 255, 255, 255, 252, 16, 0, 0, 0, 0, 0, 62, 255, 255, 255, 255, 255, 255, 255, 5, 255, 255, 255, 255, 255, - 255, 251, 16, 0, 0, 0, 0, 111, 255, 255, 255, 255, 255, 255, 255, 224, 30, 255, 255, 255, 255, 255, 255, 253, - 97, 0, 0, 4, 191, 255, 255, 255, 255, 255, 255, 255, 254, 0, 159, 255, 255, 255, 255, 255, 255, 255, 253, 187, - 206, 255, 255, 255, 255, 255, 255, 255, 255, 255, 208, 2, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 253, 0, 9, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 176, 0, 29, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 249, 191, 255, 255, - 255, 255, 250, 0, 0, 62, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 252, 28, 255, 255, 255, 255, 255, - 128, 0, 0, 78, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 254, 32, 223, 255, 255, 255, 255, 246, 0, 0, - 0, 61, 255, 255, 255, 255, 255, 255, 255, 255, 255, 253, 32, 14, 255, 255, 255, 255, 255, 64, 0, 0, 0, 26, - 255, 255, 255, 255, 255, 255, 255, 255, 251, 16, 2, 255, 255, 255, 255, 255, 242, 0, 0, 0, 0, 3, 175, 255, - 255, 255, 255, 255, 255, 213, 0, 0, 79, 255, 255, 255, 255, 254, 0, 0, 0, 0, 0, 0, 21, 156, 222, 254, - 237, 167, 48, 0, 0, 8, 255, 255, 255, 255, 255, 192, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 191, 255, 255, 255, 255, 248, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 31, 255, 255, 255, 255, 255, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 255, 255, - 255, 255, 255, 225, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 207, 255, 255, 255, 255, - 250, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 79, 255, 255, 255, 255, 255, 80, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 255, 255, 255, 255, 255, 225, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 255, 255, 255, 255, 255, 249, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 7, 255, 255, 255, 255, 255, 255, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 7, 255, 255, 255, 255, 255, 255, 160, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 43, 255, 255, 255, 255, 255, 255, 226, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 159, 255, - 255, 255, 255, 255, 255, 247, 0, 0, 0, 0, 1, 116, 32, 0, 0, 0, 0, 36, 140, 255, 255, 255, 255, 255, - 255, 255, 252, 0, 0, 0, 0, 0, 47, 255, 237, 187, 187, 205, 255, 255, 255, 255, 255, 255, 255, 255, 255, 254, - 32, 0, 0, 0, 0, 2, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 64, 0, 0, - 0, 0, 0, 47, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 80, 0, 0, 0, 0, 0, - 2, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 254, 64, 0, 0, 0, 0, 0, 0, 47, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 253, 48, 0, 0, 0, 0, 0, 0, 2, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 249, 16, 0, 0, 0, 0, 0, 0, 0, 47, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 179, 0, 0, 0, 0, 0, 0, 0, 0, 2, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 250, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 47, 255, 255, 255, 255, 255, 255, 255, 255, 235, 97, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 173, 239, 255, 255, 254, 237, 202, 134, 48, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 1, 107, 223, 237, 147, 0, 0, 4, 223, 255, 255, 255, 250, 16, 3, 239, 255, 255, - 255, 255, 251, 0, 207, 255, 255, 255, 255, 255, 246, 47, 255, 255, 255, 255, 255, 255, 181, 255, 255, 255, 255, 255, - 255, 254, 111, 255, 255, 255, 255, 255, 255, 247, 255, 255, 255, 255, 255, 255, 255, 95, 255, 255, 255, 255, 255, 255, - 226, 255, 255, 255, 255, 255, 255, 251, 12, 255, 255, 255, 255, 255, 255, 80, 62, 255, 255, 255, 255, 255, 176, 0, - 61, 255, 255, 255, 255, 161, 0, 0, 6, 173, 254, 217, 48, 0, - ], -}; - -/// NotoSans-SemiBold at 40 px: 46 glyphs, 12066 B of 4-bit coverage. -pub static L: Font = Font { - ascent: 43, - descent: 12, - cap: 28, - glyphs: &[ - Glyph { c: '0', adv: 23, x: 1, y: -28, w: 21, h: 28, off: 0 }, - Glyph { c: '1', adv: 23, x: 3, y: -28, w: 13, h: 28, off: 294 }, - Glyph { c: '2', adv: 23, x: 1, y: -28, w: 21, h: 28, off: 476 }, - Glyph { c: '3', adv: 23, x: 1, y: -28, w: 20, h: 28, off: 770 }, - Glyph { c: '4', adv: 23, x: 0, y: -28, w: 23, h: 28, off: 1050 }, - Glyph { c: '5', adv: 23, x: 2, y: -28, w: 19, h: 28, off: 1372 }, - Glyph { c: '6', adv: 23, x: 1, y: -28, w: 21, h: 28, off: 1638 }, - Glyph { c: '7', adv: 23, x: 1, y: -28, w: 21, h: 28, off: 1932 }, - Glyph { c: '8', adv: 23, x: 1, y: -28, w: 21, h: 28, off: 2226 }, - Glyph { c: '9', adv: 23, x: 1, y: -28, w: 21, h: 28, off: 2520 }, - Glyph { c: ':', adv: 11, x: 2, y: -22, w: 7, h: 22, off: 2814 }, - Glyph { c: '.', adv: 11, x: 2, y: -6, w: 7, h: 6, off: 2891 }, - Glyph { c: ' ', adv: 10, x: 0, y: 0, w: 0, h: 0, off: 2912 }, - Glyph { c: 'a', adv: 23, x: 1, y: -22, w: 20, h: 22, off: 2912 }, - Glyph { c: 'b', adv: 25, x: 3, y: -30, w: 20, h: 30, off: 3132 }, - Glyph { c: 'c', adv: 20, x: 2, y: -22, w: 17, h: 22, off: 3432 }, - Glyph { c: 'd', adv: 25, x: 2, y: -30, w: 20, h: 30, off: 3619 }, - Glyph { c: 'e', adv: 23, x: 2, y: -22, w: 20, h: 22, off: 3919 }, - Glyph { c: 'f', adv: 15, x: 0, y: -30, w: 17, h: 30, off: 4139 }, - Glyph { c: 'g', adv: 25, x: 2, y: -22, w: 20, h: 32, off: 4394 }, - Glyph { c: 'h', adv: 26, x: 3, y: -30, w: 20, h: 30, off: 4714 }, - Glyph { c: 'i', adv: 11, x: 2, y: -30, w: 7, h: 30, off: 5014 }, - Glyph { c: 'j', adv: 11, x: -3, y: -30, w: 12, h: 40, off: 5119 }, - Glyph { c: 'k', adv: 24, x: 3, y: -30, w: 21, h: 30, off: 5359 }, - Glyph { c: 'l', adv: 11, x: 3, y: -30, w: 6, h: 30, off: 5674 }, - Glyph { c: 'm', adv: 38, x: 3, y: -22, w: 33, h: 22, off: 5764 }, - Glyph { c: 'n', adv: 26, x: 3, y: -22, w: 20, h: 22, off: 6127 }, - Glyph { c: 'o', adv: 25, x: 2, y: -22, w: 21, h: 22, off: 6347 }, - Glyph { c: 'p', adv: 25, x: 3, y: -22, w: 20, h: 32, off: 6578 }, - Glyph { c: 'q', adv: 25, x: 2, y: -22, w: 20, h: 32, off: 6898 }, - Glyph { c: 'r', adv: 17, x: 3, y: -22, w: 14, h: 22, off: 7218 }, - Glyph { c: 's', adv: 20, x: 1, y: -22, w: 17, h: 22, off: 7372 }, - Glyph { c: 't', adv: 16, x: 0, y: -27, w: 16, h: 27, off: 7559 }, - Glyph { c: 'u', adv: 26, x: 2, y: -22, w: 21, h: 22, off: 7775 }, - Glyph { c: 'v', adv: 22, x: 0, y: -22, w: 22, h: 22, off: 8006 }, - Glyph { c: 'w', adv: 33, x: 0, y: -22, w: 33, h: 22, off: 8248 }, - Glyph { c: 'x', adv: 22, x: 0, y: -22, w: 22, h: 22, off: 8611 }, - Glyph { c: 'y', adv: 22, x: 0, y: -22, w: 22, h: 32, off: 8853 }, - Glyph { c: 'z', adv: 19, x: 1, y: -22, w: 17, h: 22, off: 9205 }, - Glyph { c: 'A', adv: 27, x: 0, y: -28, w: 27, h: 28, off: 9392 }, - Glyph { c: 'V', adv: 25, x: 0, y: -28, w: 26, h: 28, off: 9770 }, - Glyph { c: 'N', adv: 32, x: 3, y: -28, w: 25, h: 28, off: 10134 }, - Glyph { c: 'R', adv: 26, x: 3, y: -28, w: 23, h: 28, off: 10484 }, - Glyph { c: 'O', adv: 31, x: 2, y: -28, w: 28, h: 28, off: 10806 }, - Glyph { c: 'H', adv: 30, x: 3, y: -28, w: 24, h: 28, off: 11198 }, - Glyph { c: 'W', adv: 38, x: 0, y: -28, w: 38, h: 28, off: 11534 }, - ], - bits: &[ - 0, 0, 0, 90, 222, 253, 200, 32, 0, 0, 0, 0, 3, 207, 255, 255, 255, 255, 128, 0, 0, 0, 3, 239, - 255, 255, 255, 255, 255, 176, 0, 0, 1, 223, 255, 255, 255, 255, 255, 255, 144, 0, 0, 159, 255, 255, 113, 2, - 143, 255, 255, 48, 0, 31, 255, 255, 80, 0, 0, 143, 255, 251, 0, 6, 255, 255, 176, 0, 0, 1, 239, 255, - 241, 0, 175, 255, 246, 0, 0, 0, 9, 255, 255, 96, 13, 255, 255, 48, 0, 0, 0, 95, 255, 250, 1, 255, - 255, 240, 0, 0, 0, 3, 255, 255, 192, 63, 255, 253, 0, 0, 0, 0, 31, 255, 255, 4, 255, 255, 192, 0, - 0, 0, 0, 239, 255, 241, 95, 255, 251, 0, 0, 0, 0, 14, 255, 255, 37, 255, 255, 176, 0, 0, 0, 0, - 223, 255, 243, 95, 255, 251, 0, 0, 0, 0, 13, 255, 255, 52, 255, 255, 176, 0, 0, 0, 0, 239, 255, 242, - 79, 255, 252, 0, 0, 0, 0, 14, 255, 255, 34, 255, 255, 208, 0, 0, 0, 1, 255, 255, 240, 15, 255, 255, - 0, 0, 0, 0, 47, 255, 253, 0, 207, 255, 243, 0, 0, 0, 5, 255, 255, 176, 9, 255, 255, 96, 0, 0, - 0, 159, 255, 247, 0, 79, 255, 251, 0, 0, 0, 14, 255, 255, 48, 0, 223, 255, 245, 0, 0, 8, 255, 255, - 208, 0, 6, 255, 255, 246, 16, 40, 255, 255, 246, 0, 0, 12, 255, 255, 255, 255, 255, 255, 252, 0, 0, 0, - 45, 255, 255, 255, 255, 255, 253, 32, 0, 0, 0, 27, 255, 255, 255, 255, 251, 16, 0, 0, 0, 0, 4, 156, - 239, 236, 147, 0, 0, 0, 0, 0, 0, 4, 239, 255, 160, 0, 0, 6, 255, 255, 250, 0, 0, 9, 255, 255, - 255, 160, 0, 28, 255, 255, 255, 250, 0, 61, 255, 255, 255, 255, 160, 95, 255, 255, 239, 255, 250, 143, 255, 255, - 181, 255, 255, 172, 255, 255, 144, 95, 255, 250, 29, 254, 80, 5, 255, 255, 160, 60, 48, 0, 111, 255, 250, 0, - 0, 0, 6, 255, 255, 160, 0, 0, 0, 111, 255, 250, 0, 0, 0, 6, 255, 255, 160, 0, 0, 0, 111, 255, - 250, 0, 0, 0, 6, 255, 255, 160, 0, 0, 0, 111, 255, 250, 0, 0, 0, 6, 255, 255, 160, 0, 0, 0, - 111, 255, 250, 0, 0, 0, 6, 255, 255, 160, 0, 0, 0, 111, 255, 250, 0, 0, 0, 6, 255, 255, 160, 0, - 0, 0, 111, 255, 250, 0, 0, 0, 6, 255, 255, 160, 0, 0, 0, 111, 255, 250, 0, 0, 0, 6, 255, 255, - 160, 0, 0, 0, 111, 255, 250, 0, 0, 0, 6, 255, 255, 160, 0, 0, 0, 111, 255, 250, 0, 0, 3, 139, - 222, 254, 201, 64, 0, 0, 0, 0, 76, 255, 255, 255, 255, 255, 195, 0, 0, 1, 175, 255, 255, 255, 255, 255, - 255, 244, 0, 1, 223, 255, 255, 255, 255, 255, 255, 255, 226, 0, 6, 255, 255, 215, 32, 2, 159, 255, 255, 160, - 0, 9, 255, 129, 0, 0, 0, 111, 255, 255, 16, 0, 11, 64, 0, 0, 0, 0, 239, 255, 243, 0, 0, 0, - 0, 0, 0, 0, 12, 255, 255, 64, 0, 0, 0, 0, 0, 0, 0, 223, 255, 243, 0, 0, 0, 0, 0, 0, - 0, 14, 255, 255, 32, 0, 0, 0, 0, 0, 0, 5, 255, 255, 208, 0, 0, 0, 0, 0, 0, 0, 207, 255, - 247, 0, 0, 0, 0, 0, 0, 0, 127, 255, 254, 16, 0, 0, 0, 0, 0, 0, 95, 255, 255, 96, 0, 0, - 0, 0, 0, 0, 62, 255, 255, 160, 0, 0, 0, 0, 0, 0, 62, 255, 255, 192, 0, 0, 0, 0, 0, 0, - 46, 255, 255, 193, 0, 0, 0, 0, 0, 0, 46, 255, 255, 209, 0, 0, 0, 0, 0, 0, 45, 255, 255, 193, - 0, 0, 0, 0, 0, 0, 45, 255, 255, 193, 0, 0, 0, 0, 0, 0, 45, 255, 255, 177, 0, 0, 0, 0, - 0, 0, 45, 255, 255, 177, 0, 0, 0, 0, 0, 0, 45, 255, 255, 160, 0, 0, 0, 0, 0, 0, 45, 255, - 255, 160, 0, 0, 0, 0, 0, 0, 45, 255, 255, 254, 238, 238, 238, 238, 238, 238, 68, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 244, 79, 255, 255, 255, 255, 255, 255, 255, 255, 255, 68, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 244, 0, 0, 38, 173, 239, 254, 201, 81, 0, 0, 0, 91, 255, 255, 255, 255, 255, 254, 96, 0, 27, 255, - 255, 255, 255, 255, 255, 255, 249, 0, 10, 255, 255, 255, 255, 255, 255, 255, 255, 96, 1, 223, 251, 98, 16, 2, - 143, 255, 255, 208, 0, 58, 48, 0, 0, 0, 6, 255, 255, 241, 0, 0, 0, 0, 0, 0, 0, 239, 255, 242, - 0, 0, 0, 0, 0, 0, 0, 239, 255, 241, 0, 0, 0, 0, 0, 0, 3, 255, 255, 176, 0, 0, 0, 0, - 0, 0, 28, 255, 255, 64, 0, 0, 0, 0, 18, 72, 239, 255, 246, 0, 0, 0, 15, 255, 255, 255, 255, 252, - 64, 0, 0, 0, 15, 255, 255, 255, 250, 64, 0, 0, 0, 0, 15, 255, 255, 255, 255, 234, 64, 0, 0, 0, - 14, 238, 255, 255, 255, 255, 251, 16, 0, 0, 0, 0, 1, 54, 207, 255, 255, 176, 0, 0, 0, 0, 0, 0, - 7, 255, 255, 246, 0, 0, 0, 0, 0, 0, 0, 175, 255, 252, 0, 0, 0, 0, 0, 0, 0, 111, 255, 255, - 0, 0, 0, 0, 0, 0, 0, 95, 255, 255, 0, 0, 0, 0, 0, 0, 0, 127, 255, 255, 0, 0, 0, 0, - 0, 0, 0, 207, 255, 252, 71, 16, 0, 0, 0, 0, 8, 255, 255, 247, 95, 251, 116, 16, 0, 37, 191, 255, - 255, 225, 95, 255, 255, 255, 255, 255, 255, 255, 255, 80, 95, 255, 255, 255, 255, 255, 255, 255, 246, 0, 61, 255, - 255, 255, 255, 255, 255, 251, 32, 0, 0, 54, 172, 238, 255, 236, 167, 32, 0, 0, 0, 0, 0, 0, 0, 0, - 11, 255, 255, 112, 0, 0, 0, 0, 0, 0, 0, 7, 255, 255, 247, 0, 0, 0, 0, 0, 0, 0, 3, 255, - 255, 255, 112, 0, 0, 0, 0, 0, 0, 0, 207, 255, 255, 247, 0, 0, 0, 0, 0, 0, 0, 143, 255, 255, - 255, 112, 0, 0, 0, 0, 0, 0, 79, 255, 207, 255, 247, 0, 0, 0, 0, 0, 0, 29, 255, 230, 255, 255, - 112, 0, 0, 0, 0, 0, 10, 255, 247, 111, 255, 247, 0, 0, 0, 0, 0, 5, 255, 252, 7, 255, 255, 112, - 0, 0, 0, 0, 2, 239, 255, 48, 127, 255, 247, 0, 0, 0, 0, 0, 191, 255, 112, 8, 255, 255, 112, 0, - 0, 0, 0, 111, 255, 192, 0, 143, 255, 247, 0, 0, 0, 0, 46, 255, 226, 0, 8, 255, 255, 112, 0, 0, - 0, 12, 255, 246, 0, 0, 143, 255, 247, 0, 0, 0, 8, 255, 251, 0, 0, 8, 255, 255, 112, 0, 0, 3, - 255, 254, 32, 0, 0, 143, 255, 247, 0, 0, 1, 223, 255, 96, 0, 0, 8, 255, 255, 112, 0, 0, 159, 255, - 160, 0, 0, 0, 143, 255, 247, 0, 0, 63, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 36, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 242, 79, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 35, 238, 238, 238, 238, - 238, 238, 255, 255, 255, 238, 226, 0, 0, 0, 0, 0, 0, 8, 255, 255, 112, 0, 0, 0, 0, 0, 0, 0, - 0, 143, 255, 247, 0, 0, 0, 0, 0, 0, 0, 0, 8, 255, 255, 112, 0, 0, 0, 0, 0, 0, 0, 0, - 143, 255, 247, 0, 0, 0, 0, 0, 0, 0, 0, 8, 255, 255, 112, 0, 0, 0, 0, 0, 0, 0, 0, 143, - 255, 247, 0, 0, 3, 255, 255, 255, 255, 255, 255, 255, 208, 0, 79, 255, 255, 255, 255, 255, 255, 253, 0, 5, - 255, 255, 255, 255, 255, 255, 255, 208, 0, 127, 255, 255, 238, 238, 238, 238, 237, 0, 8, 255, 255, 48, 0, 0, - 0, 0, 0, 0, 159, 255, 242, 0, 0, 0, 0, 0, 0, 10, 255, 255, 16, 0, 0, 0, 0, 0, 0, 191, - 255, 224, 0, 0, 0, 0, 0, 0, 13, 255, 253, 0, 0, 0, 0, 0, 0, 0, 239, 255, 192, 0, 0, 0, - 0, 0, 0, 15, 255, 254, 189, 255, 236, 165, 16, 0, 1, 255, 255, 255, 255, 255, 255, 254, 80, 0, 47, 255, - 255, 255, 255, 255, 255, 255, 144, 1, 207, 255, 255, 255, 255, 255, 255, 255, 96, 0, 104, 82, 16, 2, 108, 255, - 255, 254, 16, 0, 0, 0, 0, 0, 8, 255, 255, 247, 0, 0, 0, 0, 0, 0, 12, 255, 255, 160, 0, 0, - 0, 0, 0, 0, 127, 255, 252, 0, 0, 0, 0, 0, 0, 5, 255, 255, 208, 0, 0, 0, 0, 0, 0, 95, - 255, 252, 0, 0, 0, 0, 0, 0, 7, 255, 255, 160, 0, 0, 0, 0, 0, 0, 223, 255, 246, 115, 0, 0, - 0, 0, 0, 159, 255, 255, 45, 253, 133, 32, 0, 38, 207, 255, 255, 128, 223, 255, 255, 255, 255, 255, 255, 255, - 193, 13, 255, 255, 255, 255, 255, 255, 255, 193, 0, 159, 255, 255, 255, 255, 255, 254, 112, 0, 0, 21, 155, 222, - 254, 220, 149, 0, 0, 0, 0, 0, 0, 0, 21, 156, 222, 254, 220, 48, 0, 0, 0, 1, 142, 255, 255, 255, - 255, 244, 0, 0, 0, 4, 239, 255, 255, 255, 255, 255, 64, 0, 0, 5, 255, 255, 255, 255, 255, 255, 244, 0, - 0, 3, 255, 255, 254, 132, 32, 0, 19, 16, 0, 0, 223, 255, 248, 16, 0, 0, 0, 0, 0, 0, 127, 255, - 247, 0, 0, 0, 0, 0, 0, 0, 13, 255, 251, 0, 0, 0, 0, 0, 0, 0, 4, 255, 255, 80, 0, 0, - 0, 0, 0, 0, 0, 143, 255, 225, 2, 140, 222, 218, 80, 0, 0, 11, 255, 251, 7, 255, 255, 255, 255, 194, - 0, 0, 239, 255, 152, 255, 255, 255, 255, 255, 227, 0, 31, 255, 253, 255, 255, 255, 255, 255, 255, 209, 3, 255, - 255, 255, 249, 49, 20, 191, 255, 255, 112, 63, 255, 255, 228, 0, 0, 0, 175, 255, 253, 4, 255, 255, 246, 0, - 0, 0, 2, 255, 255, 241, 79, 255, 254, 0, 0, 0, 0, 12, 255, 255, 67, 255, 255, 192, 0, 0, 0, 0, - 175, 255, 245, 47, 255, 253, 0, 0, 0, 0, 9, 255, 255, 80, 255, 255, 241, 0, 0, 0, 0, 175, 255, 244, - 11, 255, 255, 80, 0, 0, 0, 13, 255, 255, 32, 127, 255, 252, 0, 0, 0, 3, 255, 255, 208, 1, 239, 255, - 248, 0, 0, 1, 207, 255, 249, 0, 7, 255, 255, 250, 48, 4, 207, 255, 255, 32, 0, 12, 255, 255, 255, 255, - 255, 255, 255, 112, 0, 0, 28, 255, 255, 255, 255, 255, 255, 144, 0, 0, 0, 24, 255, 255, 255, 255, 254, 96, - 0, 0, 0, 0, 2, 123, 239, 237, 166, 16, 0, 0, 175, 255, 255, 255, 255, 255, 255, 255, 255, 255, 90, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 245, 175, 255, 255, 255, 255, 255, 255, 255, 255, 255, 90, 238, 238, 238, 238, - 238, 238, 238, 255, 255, 242, 0, 0, 0, 0, 0, 0, 0, 95, 255, 250, 0, 0, 0, 0, 0, 0, 0, 12, - 255, 255, 64, 0, 0, 0, 0, 0, 0, 4, 255, 255, 192, 0, 0, 0, 0, 0, 0, 0, 191, 255, 245, 0, - 0, 0, 0, 0, 0, 0, 63, 255, 253, 0, 0, 0, 0, 0, 0, 0, 10, 255, 255, 112, 0, 0, 0, 0, - 0, 0, 2, 255, 255, 225, 0, 0, 0, 0, 0, 0, 0, 159, 255, 248, 0, 0, 0, 0, 0, 0, 0, 30, - 255, 255, 32, 0, 0, 0, 0, 0, 0, 7, 255, 255, 160, 0, 0, 0, 0, 0, 0, 1, 239, 255, 243, 0, - 0, 0, 0, 0, 0, 0, 111, 255, 252, 0, 0, 0, 0, 0, 0, 0, 13, 255, 255, 80, 0, 0, 0, 0, - 0, 0, 5, 255, 255, 208, 0, 0, 0, 0, 0, 0, 0, 207, 255, 247, 0, 0, 0, 0, 0, 0, 0, 79, - 255, 254, 16, 0, 0, 0, 0, 0, 0, 11, 255, 255, 128, 0, 0, 0, 0, 0, 0, 3, 255, 255, 242, 0, - 0, 0, 0, 0, 0, 0, 175, 255, 250, 0, 0, 0, 0, 0, 0, 0, 47, 255, 255, 48, 0, 0, 0, 0, - 0, 0, 9, 255, 255, 176, 0, 0, 0, 0, 0, 0, 1, 239, 255, 245, 0, 0, 0, 0, 0, 0, 0, 143, - 255, 253, 0, 0, 0, 0, 0, 0, 0, 30, 255, 255, 96, 0, 0, 0, 0, 0, 0, 0, 1, 106, 222, 254, - 217, 97, 0, 0, 0, 0, 8, 239, 255, 255, 255, 255, 231, 0, 0, 0, 27, 255, 255, 255, 255, 255, 255, 249, - 0, 0, 10, 255, 255, 255, 255, 255, 255, 255, 247, 0, 2, 255, 255, 252, 81, 1, 109, 255, 255, 224, 0, 111, - 255, 252, 0, 0, 0, 30, 255, 255, 48, 7, 255, 255, 112, 0, 0, 0, 159, 255, 244, 0, 111, 255, 246, 0, - 0, 0, 8, 255, 255, 64, 3, 255, 255, 160, 0, 0, 0, 207, 255, 241, 0, 13, 255, 255, 96, 0, 0, 127, - 255, 249, 0, 0, 79, 255, 255, 161, 1, 175, 255, 253, 16, 0, 0, 95, 255, 255, 234, 255, 255, 252, 16, 0, - 0, 0, 78, 255, 255, 255, 255, 248, 0, 0, 0, 0, 0, 63, 255, 255, 255, 248, 0, 0, 0, 0, 0, 143, - 255, 255, 255, 255, 253, 64, 0, 0, 1, 207, 255, 255, 169, 255, 255, 255, 128, 0, 1, 223, 255, 252, 48, 2, - 175, 255, 255, 144, 0, 159, 255, 250, 0, 0, 0, 78, 255, 255, 80, 30, 255, 253, 0, 0, 0, 0, 63, 255, - 252, 4, 255, 255, 128, 0, 0, 0, 0, 191, 255, 241, 111, 255, 246, 0, 0, 0, 0, 9, 255, 255, 53, 255, - 255, 144, 0, 0, 0, 0, 207, 255, 242, 63, 255, 255, 48, 0, 0, 0, 95, 255, 254, 0, 223, 255, 254, 114, - 0, 3, 159, 255, 255, 144, 5, 255, 255, 255, 255, 255, 255, 255, 255, 209, 0, 7, 255, 255, 255, 255, 255, 255, - 255, 210, 0, 0, 4, 223, 255, 255, 255, 255, 255, 145, 0, 0, 0, 0, 72, 189, 239, 237, 166, 32, 0, 0, - 0, 0, 2, 123, 222, 253, 182, 16, 0, 0, 0, 0, 25, 255, 255, 255, 255, 254, 112, 0, 0, 0, 29, 255, - 255, 255, 255, 255, 255, 177, 0, 0, 12, 255, 255, 255, 255, 255, 255, 255, 160, 0, 6, 255, 255, 250, 48, 2, - 159, 255, 255, 96, 0, 223, 255, 247, 0, 0, 0, 95, 255, 254, 0, 47, 255, 253, 0, 0, 0, 0, 159, 255, - 245, 5, 255, 255, 144, 0, 0, 0, 3, 255, 255, 160, 111, 255, 248, 0, 0, 0, 0, 14, 255, 253, 6, 255, - 255, 144, 0, 0, 0, 0, 239, 255, 241, 95, 255, 252, 0, 0, 0, 0, 63, 255, 255, 34, 255, 255, 245, 0, - 0, 0, 45, 255, 255, 243, 12, 255, 255, 247, 32, 2, 126, 255, 255, 255, 48, 79, 255, 255, 255, 255, 255, 255, - 239, 255, 242, 0, 143, 255, 255, 255, 255, 255, 138, 255, 255, 16, 0, 127, 255, 255, 255, 255, 112, 207, 255, 240, - 0, 0, 23, 206, 254, 217, 48, 14, 255, 253, 0, 0, 0, 0, 0, 0, 0, 2, 255, 255, 160, 0, 0, 0, - 0, 0, 0, 0, 111, 255, 247, 0, 0, 0, 0, 0, 0, 0, 12, 255, 255, 32, 0, 0, 0, 0, 0, 0, - 4, 255, 255, 192, 0, 0, 0, 0, 0, 0, 2, 239, 255, 245, 0, 0, 0, 0, 0, 0, 4, 223, 255, 252, - 0, 0, 2, 49, 0, 2, 107, 255, 255, 254, 32, 0, 0, 111, 255, 255, 255, 255, 255, 254, 64, 0, 0, 6, - 255, 255, 255, 255, 255, 253, 48, 0, 0, 0, 111, 255, 255, 255, 255, 231, 16, 0, 0, 0, 4, 222, 255, 237, - 201, 81, 0, 0, 0, 0, 6, 222, 214, 3, 255, 255, 244, 127, 255, 255, 135, 255, 255, 248, 63, 255, 255, 48, - 92, 237, 80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 206, 213, 3, 255, 255, 244, 127, 255, 255, - 135, 255, 255, 248, 63, 255, 255, 64, 93, 237, 80, 5, 206, 213, 3, 255, 255, 244, 127, 255, 255, 135, 255, 255, - 248, 63, 255, 255, 64, 93, 237, 80, 0, 0, 1, 89, 205, 239, 236, 148, 0, 0, 0, 3, 175, 255, 255, 255, - 255, 255, 177, 0, 0, 12, 255, 255, 255, 255, 255, 255, 252, 16, 0, 6, 255, 255, 255, 255, 255, 255, 255, 128, - 0, 0, 239, 215, 49, 1, 110, 255, 255, 224, 0, 0, 83, 0, 0, 0, 3, 255, 255, 243, 0, 0, 0, 0, - 0, 0, 0, 207, 255, 245, 0, 0, 0, 0, 0, 0, 0, 175, 255, 246, 0, 0, 0, 0, 0, 0, 0, 175, - 255, 246, 0, 0, 21, 156, 222, 255, 255, 255, 255, 246, 0, 8, 239, 255, 255, 255, 255, 255, 255, 246, 1, 207, - 255, 255, 255, 255, 255, 255, 255, 246, 9, 255, 255, 250, 82, 0, 0, 175, 255, 246, 30, 255, 255, 112, 0, 0, - 0, 175, 255, 246, 63, 255, 255, 0, 0, 0, 0, 191, 255, 246, 79, 255, 254, 0, 0, 0, 1, 239, 255, 246, - 79, 255, 255, 32, 0, 0, 10, 255, 255, 246, 31, 255, 255, 212, 16, 21, 207, 255, 255, 246, 11, 255, 255, 255, - 255, 255, 255, 207, 255, 246, 3, 255, 255, 255, 255, 255, 251, 13, 255, 246, 0, 94, 255, 255, 255, 255, 145, 9, - 255, 246, 0, 1, 124, 239, 237, 148, 0, 5, 255, 246, 223, 255, 243, 0, 0, 0, 0, 0, 0, 0, 223, 255, - 243, 0, 0, 0, 0, 0, 0, 0, 223, 255, 243, 0, 0, 0, 0, 0, 0, 0, 223, 255, 243, 0, 0, 0, - 0, 0, 0, 0, 223, 255, 243, 0, 0, 0, 0, 0, 0, 0, 223, 255, 243, 0, 0, 0, 0, 0, 0, 0, - 223, 255, 243, 0, 0, 0, 0, 0, 0, 0, 223, 255, 243, 0, 0, 0, 0, 0, 0, 0, 223, 255, 242, 1, - 108, 223, 235, 113, 0, 0, 223, 255, 242, 78, 255, 255, 255, 254, 80, 0, 223, 255, 244, 255, 255, 255, 255, 255, - 245, 0, 223, 255, 254, 255, 255, 255, 255, 255, 255, 32, 223, 255, 255, 248, 32, 2, 159, 255, 255, 176, 223, 255, - 255, 96, 0, 0, 8, 255, 255, 242, 223, 255, 253, 0, 0, 0, 1, 239, 255, 247, 223, 255, 248, 0, 0, 0, - 0, 159, 255, 250, 223, 255, 245, 0, 0, 0, 0, 111, 255, 253, 223, 255, 244, 0, 0, 0, 0, 79, 255, 254, - 223, 255, 243, 0, 0, 0, 0, 63, 255, 255, 223, 255, 243, 0, 0, 0, 0, 63, 255, 255, 223, 255, 244, 0, - 0, 0, 0, 79, 255, 254, 223, 255, 246, 0, 0, 0, 0, 111, 255, 253, 223, 255, 249, 0, 0, 0, 0, 175, - 255, 250, 223, 255, 253, 0, 0, 0, 1, 239, 255, 247, 223, 255, 255, 112, 0, 0, 9, 255, 255, 242, 223, 255, - 255, 249, 48, 2, 159, 255, 255, 176, 223, 255, 255, 255, 255, 255, 255, 255, 255, 32, 223, 255, 255, 255, 255, 255, - 255, 255, 245, 0, 223, 255, 148, 223, 255, 255, 255, 254, 80, 0, 223, 255, 32, 5, 173, 239, 235, 113, 0, 0, - 0, 0, 1, 90, 206, 254, 219, 131, 0, 0, 7, 239, 255, 255, 255, 255, 250, 0, 27, 255, 255, 255, 255, 255, - 255, 96, 11, 255, 255, 255, 255, 255, 255, 225, 6, 255, 255, 252, 81, 0, 55, 201, 1, 239, 255, 251, 16, 0, - 0, 0, 0, 95, 255, 255, 32, 0, 0, 0, 0, 9, 255, 255, 176, 0, 0, 0, 0, 0, 207, 255, 247, 0, - 0, 0, 0, 0, 14, 255, 255, 64, 0, 0, 0, 0, 0, 255, 255, 243, 0, 0, 0, 0, 0, 15, 255, 255, - 48, 0, 0, 0, 0, 0, 239, 255, 244, 0, 0, 0, 0, 0, 13, 255, 255, 96, 0, 0, 0, 0, 0, 175, - 255, 250, 0, 0, 0, 0, 0, 6, 255, 255, 242, 0, 0, 0, 0, 0, 31, 255, 255, 176, 0, 0, 0, 2, - 32, 143, 255, 255, 197, 16, 2, 90, 246, 1, 223, 255, 255, 255, 255, 255, 255, 96, 2, 223, 255, 255, 255, 255, - 255, 246, 0, 1, 159, 255, 255, 255, 255, 254, 64, 0, 0, 39, 189, 255, 237, 166, 16, 0, 0, 0, 0, 0, - 0, 0, 63, 255, 254, 0, 0, 0, 0, 0, 0, 0, 63, 255, 254, 0, 0, 0, 0, 0, 0, 0, 63, 255, - 254, 0, 0, 0, 0, 0, 0, 0, 63, 255, 254, 0, 0, 0, 0, 0, 0, 0, 63, 255, 254, 0, 0, 0, - 0, 0, 0, 0, 63, 255, 254, 0, 0, 0, 0, 0, 0, 0, 63, 255, 254, 0, 0, 0, 0, 0, 0, 0, - 63, 255, 254, 0, 0, 22, 189, 254, 199, 16, 47, 255, 254, 0, 4, 239, 255, 255, 255, 229, 31, 255, 254, 0, - 95, 255, 255, 255, 255, 255, 111, 255, 254, 2, 255, 255, 255, 255, 255, 255, 255, 255, 254, 11, 255, 255, 251, 48, - 2, 143, 255, 255, 254, 47, 255, 255, 176, 0, 0, 4, 255, 255, 254, 127, 255, 255, 32, 0, 0, 0, 191, 255, - 254, 175, 255, 250, 0, 0, 0, 0, 95, 255, 254, 223, 255, 247, 0, 0, 0, 0, 47, 255, 254, 239, 255, 244, - 0, 0, 0, 0, 15, 255, 254, 255, 255, 243, 0, 0, 0, 0, 14, 255, 254, 255, 255, 243, 0, 0, 0, 0, - 14, 255, 254, 239, 255, 244, 0, 0, 0, 0, 15, 255, 254, 223, 255, 246, 0, 0, 0, 0, 31, 255, 254, 175, - 255, 249, 0, 0, 0, 0, 79, 255, 254, 127, 255, 254, 16, 0, 0, 0, 159, 255, 254, 47, 255, 255, 144, 0, - 0, 3, 255, 255, 254, 11, 255, 255, 250, 48, 2, 126, 255, 255, 254, 2, 255, 255, 255, 255, 255, 255, 255, 255, - 254, 0, 111, 255, 255, 255, 255, 255, 93, 255, 254, 0, 5, 239, 255, 255, 255, 229, 8, 255, 254, 0, 0, 23, - 206, 253, 199, 16, 3, 255, 254, 0, 0, 1, 123, 222, 237, 183, 32, 0, 0, 0, 0, 142, 255, 255, 255, 255, - 249, 0, 0, 0, 27, 255, 255, 255, 255, 255, 255, 193, 0, 0, 191, 255, 255, 255, 255, 255, 255, 251, 0, 7, - 255, 255, 248, 48, 2, 126, 255, 255, 80, 14, 255, 255, 80, 0, 0, 4, 255, 255, 192, 95, 255, 251, 0, 0, - 0, 0, 191, 255, 241, 159, 255, 246, 0, 0, 0, 0, 127, 255, 245, 207, 255, 255, 238, 238, 238, 238, 255, 255, - 246, 223, 255, 255, 255, 255, 255, 255, 255, 255, 247, 239, 255, 255, 255, 255, 255, 255, 255, 255, 247, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 247, 239, 255, 244, 0, 0, 0, 0, 0, 0, 0, 207, 255, 246, 0, 0, 0, 0, - 0, 0, 0, 175, 255, 250, 0, 0, 0, 0, 0, 0, 0, 95, 255, 255, 32, 0, 0, 0, 0, 0, 0, 30, - 255, 255, 193, 0, 0, 0, 0, 2, 32, 6, 255, 255, 254, 114, 0, 1, 71, 207, 80, 0, 175, 255, 255, 255, - 255, 255, 255, 255, 80, 0, 26, 255, 255, 255, 255, 255, 255, 255, 80, 0, 0, 110, 255, 255, 255, 255, 255, 253, - 48, 0, 0, 0, 89, 206, 255, 237, 184, 48, 0, 0, 0, 0, 4, 156, 239, 237, 184, 32, 0, 0, 27, 255, - 255, 255, 255, 245, 0, 0, 11, 255, 255, 255, 255, 254, 16, 0, 4, 255, 255, 255, 255, 255, 160, 0, 0, 159, - 255, 254, 81, 1, 66, 0, 0, 11, 255, 255, 112, 0, 0, 0, 0, 0, 207, 255, 244, 0, 0, 0, 0, 0, - 12, 255, 255, 64, 0, 0, 0, 0, 75, 255, 255, 255, 255, 255, 112, 2, 223, 255, 255, 255, 255, 255, 247, 0, - 79, 255, 255, 255, 255, 255, 255, 112, 4, 238, 239, 255, 255, 238, 238, 231, 0, 0, 0, 207, 255, 244, 0, 0, - 0, 0, 0, 12, 255, 255, 64, 0, 0, 0, 0, 0, 207, 255, 244, 0, 0, 0, 0, 0, 12, 255, 255, 64, - 0, 0, 0, 0, 0, 207, 255, 244, 0, 0, 0, 0, 0, 12, 255, 255, 64, 0, 0, 0, 0, 0, 207, 255, - 244, 0, 0, 0, 0, 0, 12, 255, 255, 64, 0, 0, 0, 0, 0, 207, 255, 244, 0, 0, 0, 0, 0, 12, - 255, 255, 64, 0, 0, 0, 0, 0, 207, 255, 244, 0, 0, 0, 0, 0, 12, 255, 255, 64, 0, 0, 0, 0, - 0, 207, 255, 244, 0, 0, 0, 0, 0, 12, 255, 255, 64, 0, 0, 0, 0, 0, 207, 255, 244, 0, 0, 0, - 0, 0, 12, 255, 255, 64, 0, 0, 0, 0, 0, 207, 255, 244, 0, 0, 0, 0, 0, 12, 255, 255, 64, 0, - 0, 0, 0, 0, 23, 189, 254, 199, 32, 6, 255, 254, 0, 4, 223, 255, 255, 255, 231, 9, 255, 254, 0, 95, - 255, 255, 255, 255, 255, 139, 255, 254, 2, 239, 255, 255, 255, 255, 255, 255, 255, 254, 10, 255, 255, 250, 48, 2, - 143, 255, 255, 254, 31, 255, 255, 160, 0, 0, 4, 255, 255, 254, 111, 255, 254, 16, 0, 0, 0, 175, 255, 254, - 175, 255, 250, 0, 0, 0, 0, 79, 255, 254, 223, 255, 246, 0, 0, 0, 0, 31, 255, 254, 239, 255, 244, 0, - 0, 0, 0, 14, 255, 254, 255, 255, 243, 0, 0, 0, 0, 13, 255, 254, 255, 255, 243, 0, 0, 0, 0, 13, - 255, 254, 239, 255, 244, 0, 0, 0, 0, 14, 255, 254, 223, 255, 246, 0, 0, 0, 0, 15, 255, 254, 175, 255, - 249, 0, 0, 0, 0, 47, 255, 254, 127, 255, 254, 16, 0, 0, 0, 127, 255, 254, 47, 255, 255, 144, 0, 0, - 2, 239, 255, 254, 11, 255, 255, 250, 48, 2, 110, 255, 255, 254, 2, 255, 255, 255, 255, 255, 255, 255, 255, 254, - 0, 111, 255, 255, 255, 255, 255, 95, 255, 254, 0, 5, 239, 255, 255, 255, 229, 47, 255, 254, 0, 0, 23, 206, - 254, 199, 16, 47, 255, 254, 0, 0, 0, 0, 0, 0, 0, 47, 255, 254, 0, 0, 0, 0, 0, 0, 0, 63, - 255, 253, 0, 0, 0, 0, 0, 0, 0, 111, 255, 251, 0, 0, 0, 0, 0, 0, 0, 207, 255, 248, 7, 80, - 0, 0, 0, 0, 8, 255, 255, 244, 9, 254, 149, 49, 0, 20, 191, 255, 255, 192, 9, 255, 255, 255, 255, 255, - 255, 255, 255, 64, 9, 255, 255, 255, 255, 255, 255, 255, 246, 0, 8, 255, 255, 255, 255, 255, 255, 252, 48, 0, - 0, 38, 155, 222, 255, 237, 184, 64, 0, 0, 223, 255, 243, 0, 0, 0, 0, 0, 0, 0, 223, 255, 243, 0, - 0, 0, 0, 0, 0, 0, 223, 255, 243, 0, 0, 0, 0, 0, 0, 0, 223, 255, 243, 0, 0, 0, 0, 0, - 0, 0, 223, 255, 243, 0, 0, 0, 0, 0, 0, 0, 223, 255, 243, 0, 0, 0, 0, 0, 0, 0, 223, 255, - 243, 0, 0, 0, 0, 0, 0, 0, 223, 255, 243, 0, 0, 0, 0, 0, 0, 0, 223, 255, 242, 1, 107, 223, - 237, 164, 0, 0, 223, 255, 242, 77, 255, 255, 255, 255, 194, 0, 223, 255, 244, 255, 255, 255, 255, 255, 253, 16, - 223, 255, 254, 255, 255, 255, 255, 255, 255, 144, 223, 255, 255, 251, 65, 1, 127, 255, 255, 241, 223, 255, 255, 160, - 0, 0, 5, 255, 255, 244, 223, 255, 254, 16, 0, 0, 0, 223, 255, 246, 223, 255, 250, 0, 0, 0, 0, 175, - 255, 247, 223, 255, 247, 0, 0, 0, 0, 159, 255, 248, 223, 255, 245, 0, 0, 0, 0, 143, 255, 248, 223, 255, - 244, 0, 0, 0, 0, 143, 255, 248, 223, 255, 243, 0, 0, 0, 0, 143, 255, 248, 223, 255, 243, 0, 0, 0, - 0, 143, 255, 248, 223, 255, 243, 0, 0, 0, 0, 143, 255, 248, 223, 255, 243, 0, 0, 0, 0, 143, 255, 248, - 223, 255, 243, 0, 0, 0, 0, 143, 255, 248, 223, 255, 243, 0, 0, 0, 0, 143, 255, 248, 223, 255, 243, 0, - 0, 0, 0, 143, 255, 248, 223, 255, 243, 0, 0, 0, 0, 143, 255, 248, 223, 255, 243, 0, 0, 0, 0, 143, - 255, 248, 223, 255, 243, 0, 0, 0, 0, 143, 255, 248, 223, 255, 243, 0, 0, 0, 0, 143, 255, 248, 4, 206, - 215, 0, 239, 255, 244, 31, 255, 255, 112, 239, 255, 244, 4, 206, 215, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 13, 255, 255, 48, 223, 255, 243, 13, 255, 255, 48, 223, 255, 243, 13, 255, 255, 48, 223, 255, 243, 13, - 255, 255, 48, 223, 255, 243, 13, 255, 255, 48, 223, 255, 243, 13, 255, 255, 48, 223, 255, 243, 13, 255, 255, 48, - 223, 255, 243, 13, 255, 255, 48, 223, 255, 243, 13, 255, 255, 48, 223, 255, 243, 13, 255, 255, 48, 223, 255, 243, - 13, 255, 255, 48, 223, 255, 243, 0, 0, 0, 76, 237, 112, 0, 0, 0, 239, 255, 244, 0, 0, 1, 255, 255, - 247, 0, 0, 0, 239, 255, 244, 0, 0, 0, 76, 237, 112, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 223, 255, 243, 0, 0, 0, 223, 255, 243, 0, 0, 0, 223, 255, - 243, 0, 0, 0, 223, 255, 243, 0, 0, 0, 223, 255, 243, 0, 0, 0, 223, 255, 243, 0, 0, 0, 223, 255, - 243, 0, 0, 0, 223, 255, 243, 0, 0, 0, 223, 255, 243, 0, 0, 0, 223, 255, 243, 0, 0, 0, 223, 255, - 243, 0, 0, 0, 223, 255, 243, 0, 0, 0, 223, 255, 243, 0, 0, 0, 223, 255, 243, 0, 0, 0, 223, 255, - 243, 0, 0, 0, 223, 255, 243, 0, 0, 0, 223, 255, 243, 0, 0, 0, 223, 255, 243, 0, 0, 0, 223, 255, - 243, 0, 0, 0, 223, 255, 243, 0, 0, 0, 223, 255, 243, 0, 0, 0, 223, 255, 243, 0, 0, 0, 223, 255, - 243, 0, 0, 0, 223, 255, 243, 0, 0, 0, 223, 255, 243, 0, 0, 0, 239, 255, 242, 0, 0, 2, 255, 255, - 241, 19, 0, 60, 255, 255, 208, 47, 255, 255, 255, 255, 112, 47, 255, 255, 255, 253, 16, 47, 255, 255, 255, 227, - 0, 27, 222, 254, 183, 16, 0, 207, 255, 244, 0, 0, 0, 0, 0, 0, 0, 12, 255, 255, 64, 0, 0, 0, - 0, 0, 0, 0, 207, 255, 244, 0, 0, 0, 0, 0, 0, 0, 12, 255, 255, 64, 0, 0, 0, 0, 0, 0, - 0, 207, 255, 244, 0, 0, 0, 0, 0, 0, 0, 12, 255, 255, 64, 0, 0, 0, 0, 0, 0, 0, 207, 255, - 244, 0, 0, 0, 0, 0, 0, 0, 12, 255, 255, 64, 0, 0, 0, 0, 0, 0, 0, 207, 255, 244, 0, 0, - 0, 6, 255, 255, 245, 12, 255, 255, 64, 0, 0, 5, 255, 255, 246, 0, 207, 255, 244, 0, 0, 4, 255, 255, - 248, 0, 12, 255, 255, 64, 0, 3, 239, 255, 249, 0, 0, 207, 255, 244, 0, 2, 239, 255, 250, 0, 0, 12, - 255, 255, 64, 2, 223, 255, 251, 0, 0, 0, 207, 255, 243, 1, 207, 255, 252, 16, 0, 0, 12, 255, 255, 48, - 191, 255, 253, 16, 0, 0, 0, 207, 255, 242, 159, 255, 254, 32, 0, 0, 0, 12, 255, 255, 111, 255, 255, 80, - 0, 0, 0, 0, 207, 255, 254, 255, 255, 252, 0, 0, 0, 0, 12, 255, 255, 255, 255, 255, 249, 0, 0, 0, - 0, 207, 255, 255, 253, 255, 255, 245, 0, 0, 0, 12, 255, 255, 250, 25, 255, 255, 226, 0, 0, 0, 207, 255, - 248, 0, 29, 255, 255, 192, 0, 0, 12, 255, 255, 64, 0, 63, 255, 255, 128, 0, 0, 207, 255, 244, 0, 0, - 127, 255, 255, 64, 0, 12, 255, 255, 64, 0, 0, 191, 255, 254, 32, 0, 207, 255, 244, 0, 0, 1, 239, 255, - 251, 0, 12, 255, 255, 64, 0, 0, 5, 255, 255, 248, 0, 207, 255, 244, 0, 0, 0, 9, 255, 255, 244, 12, - 255, 255, 64, 0, 0, 0, 29, 255, 255, 225, 223, 255, 243, 223, 255, 243, 223, 255, 243, 223, 255, 243, 223, 255, - 243, 223, 255, 243, 223, 255, 243, 223, 255, 243, 223, 255, 243, 223, 255, 243, 223, 255, 243, 223, 255, 243, 223, 255, - 243, 223, 255, 243, 223, 255, 243, 223, 255, 243, 223, 255, 243, 223, 255, 243, 223, 255, 243, 223, 255, 243, 223, 255, - 243, 223, 255, 243, 223, 255, 243, 223, 255, 243, 223, 255, 243, 223, 255, 243, 223, 255, 243, 223, 255, 243, 223, 255, - 243, 223, 255, 243, 223, 255, 48, 2, 124, 239, 236, 131, 0, 0, 5, 173, 238, 218, 96, 0, 13, 255, 246, 7, - 255, 255, 255, 255, 248, 0, 60, 255, 255, 255, 255, 211, 0, 223, 255, 168, 255, 255, 255, 255, 255, 247, 62, 255, - 255, 255, 255, 255, 225, 13, 255, 255, 255, 255, 255, 255, 255, 255, 254, 255, 255, 255, 255, 255, 255, 144, 223, 255, - 255, 249, 32, 3, 207, 255, 255, 255, 230, 16, 22, 239, 255, 254, 13, 255, 255, 247, 0, 0, 1, 239, 255, 255, - 226, 0, 0, 5, 255, 255, 243, 223, 255, 254, 0, 0, 0, 9, 255, 255, 248, 0, 0, 0, 14, 255, 255, 93, - 255, 255, 160, 0, 0, 0, 111, 255, 255, 32, 0, 0, 0, 191, 255, 246, 223, 255, 246, 0, 0, 0, 5, 255, - 255, 224, 0, 0, 0, 10, 255, 255, 109, 255, 255, 64, 0, 0, 0, 79, 255, 253, 0, 0, 0, 0, 175, 255, - 246, 223, 255, 244, 0, 0, 0, 4, 255, 255, 192, 0, 0, 0, 10, 255, 255, 109, 255, 255, 48, 0, 0, 0, - 79, 255, 252, 0, 0, 0, 0, 175, 255, 246, 223, 255, 243, 0, 0, 0, 4, 255, 255, 192, 0, 0, 0, 10, - 255, 255, 109, 255, 255, 48, 0, 0, 0, 79, 255, 252, 0, 0, 0, 0, 175, 255, 246, 223, 255, 243, 0, 0, - 0, 4, 255, 255, 192, 0, 0, 0, 10, 255, 255, 109, 255, 255, 48, 0, 0, 0, 79, 255, 252, 0, 0, 0, - 0, 175, 255, 246, 223, 255, 243, 0, 0, 0, 4, 255, 255, 192, 0, 0, 0, 10, 255, 255, 109, 255, 255, 48, - 0, 0, 0, 79, 255, 252, 0, 0, 0, 0, 175, 255, 246, 223, 255, 243, 0, 0, 0, 4, 255, 255, 192, 0, - 0, 0, 10, 255, 255, 109, 255, 255, 48, 0, 0, 0, 79, 255, 252, 0, 0, 0, 0, 175, 255, 246, 223, 255, - 243, 0, 0, 0, 4, 255, 255, 192, 0, 0, 0, 10, 255, 255, 109, 255, 255, 48, 0, 0, 0, 79, 255, 252, - 0, 0, 0, 0, 175, 255, 246, 223, 255, 48, 1, 107, 223, 237, 165, 0, 0, 223, 255, 96, 110, 255, 255, 255, - 255, 194, 0, 223, 255, 150, 255, 255, 255, 255, 255, 253, 16, 223, 255, 255, 255, 255, 255, 255, 255, 255, 144, 223, - 255, 255, 251, 65, 1, 110, 255, 255, 241, 223, 255, 255, 144, 0, 0, 5, 255, 255, 244, 223, 255, 254, 16, 0, - 0, 0, 223, 255, 246, 223, 255, 250, 0, 0, 0, 0, 159, 255, 247, 223, 255, 247, 0, 0, 0, 0, 143, 255, - 248, 223, 255, 245, 0, 0, 0, 0, 143, 255, 248, 223, 255, 244, 0, 0, 0, 0, 143, 255, 248, 223, 255, 243, - 0, 0, 0, 0, 143, 255, 248, 223, 255, 243, 0, 0, 0, 0, 143, 255, 248, 223, 255, 243, 0, 0, 0, 0, - 143, 255, 248, 223, 255, 243, 0, 0, 0, 0, 143, 255, 248, 223, 255, 243, 0, 0, 0, 0, 143, 255, 248, 223, - 255, 243, 0, 0, 0, 0, 143, 255, 248, 223, 255, 243, 0, 0, 0, 0, 143, 255, 248, 223, 255, 243, 0, 0, - 0, 0, 143, 255, 248, 223, 255, 243, 0, 0, 0, 0, 143, 255, 248, 223, 255, 243, 0, 0, 0, 0, 143, 255, - 248, 223, 255, 243, 0, 0, 0, 0, 143, 255, 248, 0, 0, 1, 106, 222, 254, 201, 64, 0, 0, 0, 0, 7, - 239, 255, 255, 255, 255, 195, 0, 0, 0, 27, 255, 255, 255, 255, 255, 255, 246, 0, 0, 11, 255, 255, 255, 255, - 255, 255, 255, 245, 0, 7, 255, 255, 251, 64, 1, 109, 255, 255, 226, 0, 239, 255, 250, 0, 0, 0, 45, 255, - 255, 144, 95, 255, 254, 16, 0, 0, 0, 111, 255, 254, 25, 255, 255, 160, 0, 0, 0, 0, 239, 255, 244, 207, - 255, 246, 0, 0, 0, 0, 11, 255, 255, 126, 255, 255, 64, 0, 0, 0, 0, 159, 255, 249, 255, 255, 243, 0, - 0, 0, 0, 8, 255, 255, 175, 255, 255, 48, 0, 0, 0, 0, 143, 255, 250, 239, 255, 244, 0, 0, 0, 0, - 9, 255, 255, 156, 255, 255, 112, 0, 0, 0, 0, 191, 255, 247, 159, 255, 250, 0, 0, 0, 0, 30, 255, 255, - 68, 255, 255, 242, 0, 0, 0, 6, 255, 255, 225, 13, 255, 255, 160, 0, 0, 2, 239, 255, 249, 0, 95, 255, - 255, 180, 0, 22, 239, 255, 254, 32, 0, 159, 255, 255, 255, 255, 255, 255, 255, 80, 0, 0, 175, 255, 255, 255, - 255, 255, 255, 96, 0, 0, 0, 110, 255, 255, 255, 255, 252, 64, 0, 0, 0, 0, 22, 173, 239, 236, 148, 0, - 0, 0, 223, 255, 80, 1, 124, 223, 236, 113, 0, 0, 223, 255, 144, 78, 255, 255, 255, 254, 80, 0, 223, 255, - 197, 255, 255, 255, 255, 255, 246, 0, 223, 255, 255, 255, 255, 255, 255, 255, 255, 48, 223, 255, 255, 248, 32, 3, - 175, 255, 255, 192, 223, 255, 255, 96, 0, 0, 9, 255, 255, 242, 223, 255, 253, 0, 0, 0, 1, 239, 255, 247, - 223, 255, 248, 0, 0, 0, 0, 175, 255, 250, 223, 255, 245, 0, 0, 0, 0, 111, 255, 253, 223, 255, 244, 0, - 0, 0, 0, 79, 255, 254, 223, 255, 243, 0, 0, 0, 0, 63, 255, 255, 223, 255, 243, 0, 0, 0, 0, 63, - 255, 255, 223, 255, 244, 0, 0, 0, 0, 79, 255, 254, 223, 255, 246, 0, 0, 0, 0, 111, 255, 252, 223, 255, - 249, 0, 0, 0, 0, 175, 255, 250, 223, 255, 253, 0, 0, 0, 1, 239, 255, 247, 223, 255, 255, 112, 0, 0, - 9, 255, 255, 242, 223, 255, 255, 249, 48, 3, 175, 255, 255, 160, 223, 255, 255, 255, 255, 255, 255, 255, 254, 32, - 223, 255, 249, 255, 255, 255, 255, 255, 245, 0, 223, 255, 241, 127, 255, 255, 255, 253, 64, 0, 223, 255, 242, 2, - 140, 239, 235, 97, 0, 0, 223, 255, 243, 0, 0, 0, 0, 0, 0, 0, 223, 255, 243, 0, 0, 0, 0, 0, - 0, 0, 223, 255, 243, 0, 0, 0, 0, 0, 0, 0, 223, 255, 243, 0, 0, 0, 0, 0, 0, 0, 223, 255, - 243, 0, 0, 0, 0, 0, 0, 0, 223, 255, 243, 0, 0, 0, 0, 0, 0, 0, 223, 255, 243, 0, 0, 0, - 0, 0, 0, 0, 223, 255, 243, 0, 0, 0, 0, 0, 0, 0, 223, 255, 243, 0, 0, 0, 0, 0, 0, 0, - 223, 255, 243, 0, 0, 0, 0, 0, 0, 0, 0, 0, 22, 190, 254, 199, 16, 6, 255, 254, 0, 4, 223, 255, - 255, 255, 230, 9, 255, 254, 0, 95, 255, 255, 255, 255, 255, 108, 255, 254, 2, 239, 255, 255, 255, 255, 255, 255, - 255, 254, 11, 255, 255, 250, 48, 2, 126, 255, 255, 254, 47, 255, 255, 160, 0, 0, 4, 255, 255, 254, 127, 255, - 255, 16, 0, 0, 0, 175, 255, 254, 175, 255, 250, 0, 0, 0, 0, 95, 255, 254, 223, 255, 247, 0, 0, 0, - 0, 47, 255, 254, 239, 255, 244, 0, 0, 0, 0, 15, 255, 254, 255, 255, 243, 0, 0, 0, 0, 14, 255, 254, - 255, 255, 243, 0, 0, 0, 0, 14, 255, 254, 239, 255, 244, 0, 0, 0, 0, 14, 255, 254, 223, 255, 246, 0, - 0, 0, 0, 31, 255, 254, 175, 255, 249, 0, 0, 0, 0, 63, 255, 254, 127, 255, 254, 16, 0, 0, 0, 143, - 255, 254, 47, 255, 255, 144, 0, 0, 3, 239, 255, 254, 11, 255, 255, 250, 48, 2, 110, 255, 255, 254, 3, 255, - 255, 255, 255, 255, 255, 239, 255, 254, 0, 111, 255, 255, 255, 255, 255, 79, 255, 254, 0, 5, 239, 255, 255, 255, - 228, 47, 255, 254, 0, 0, 23, 206, 253, 199, 16, 47, 255, 254, 0, 0, 0, 0, 0, 0, 0, 47, 255, 254, - 0, 0, 0, 0, 0, 0, 0, 47, 255, 254, 0, 0, 0, 0, 0, 0, 0, 47, 255, 254, 0, 0, 0, 0, - 0, 0, 0, 47, 255, 254, 0, 0, 0, 0, 0, 0, 0, 47, 255, 254, 0, 0, 0, 0, 0, 0, 0, 47, - 255, 254, 0, 0, 0, 0, 0, 0, 0, 47, 255, 254, 0, 0, 0, 0, 0, 0, 0, 47, 255, 254, 0, 0, - 0, 0, 0, 0, 0, 47, 255, 254, 0, 0, 0, 0, 0, 0, 0, 47, 255, 254, 223, 255, 32, 0, 74, 239, - 252, 223, 255, 64, 9, 255, 255, 250, 223, 255, 112, 175, 255, 255, 249, 223, 255, 150, 255, 255, 255, 248, 223, 255, - 238, 255, 255, 255, 246, 223, 255, 255, 254, 131, 17, 50, 223, 255, 255, 210, 0, 0, 0, 223, 255, 255, 48, 0, - 0, 0, 223, 255, 250, 0, 0, 0, 0, 223, 255, 246, 0, 0, 0, 0, 223, 255, 244, 0, 0, 0, 0, 223, - 255, 243, 0, 0, 0, 0, 223, 255, 243, 0, 0, 0, 0, 223, 255, 243, 0, 0, 0, 0, 223, 255, 243, 0, - 0, 0, 0, 223, 255, 243, 0, 0, 0, 0, 223, 255, 243, 0, 0, 0, 0, 223, 255, 243, 0, 0, 0, 0, - 223, 255, 243, 0, 0, 0, 0, 223, 255, 243, 0, 0, 0, 0, 223, 255, 243, 0, 0, 0, 0, 223, 255, 243, - 0, 0, 0, 0, 0, 0, 39, 189, 239, 237, 167, 32, 0, 1, 175, 255, 255, 255, 255, 255, 196, 1, 223, 255, - 255, 255, 255, 255, 255, 80, 143, 255, 255, 255, 255, 255, 255, 224, 14, 255, 255, 146, 0, 20, 142, 249, 1, 255, - 255, 208, 0, 0, 0, 4, 32, 15, 255, 254, 0, 0, 0, 0, 0, 0, 207, 255, 251, 32, 0, 0, 0, 0, - 6, 255, 255, 255, 164, 0, 0, 0, 0, 10, 255, 255, 255, 254, 130, 0, 0, 0, 6, 239, 255, 255, 255, 249, - 16, 0, 0, 1, 126, 255, 255, 255, 254, 64, 0, 0, 0, 5, 191, 255, 255, 254, 32, 0, 0, 0, 0, 58, - 255, 255, 249, 0, 0, 0, 0, 0, 6, 255, 255, 208, 0, 0, 0, 0, 0, 14, 255, 255, 5, 16, 0, 0, - 0, 1, 255, 255, 225, 254, 166, 49, 0, 20, 207, 255, 251, 31, 255, 255, 255, 255, 255, 255, 255, 65, 255, 255, - 255, 255, 255, 255, 255, 144, 13, 255, 255, 255, 255, 255, 254, 112, 0, 4, 139, 222, 255, 237, 166, 16, 0, 0, - 0, 9, 255, 192, 0, 0, 0, 0, 0, 13, 255, 192, 0, 0, 0, 0, 0, 63, 255, 192, 0, 0, 0, 0, - 0, 143, 255, 192, 0, 0, 0, 0, 0, 223, 255, 192, 0, 0, 0, 0, 77, 255, 255, 255, 255, 255, 224, 27, - 255, 255, 255, 255, 255, 255, 224, 63, 255, 255, 255, 255, 255, 255, 224, 62, 239, 255, 255, 254, 238, 238, 208, 0, - 4, 255, 255, 192, 0, 0, 0, 0, 4, 255, 255, 192, 0, 0, 0, 0, 4, 255, 255, 192, 0, 0, 0, 0, - 4, 255, 255, 192, 0, 0, 0, 0, 4, 255, 255, 192, 0, 0, 0, 0, 4, 255, 255, 192, 0, 0, 0, 0, - 4, 255, 255, 192, 0, 0, 0, 0, 4, 255, 255, 192, 0, 0, 0, 0, 4, 255, 255, 192, 0, 0, 0, 0, - 4, 255, 255, 192, 0, 0, 0, 0, 4, 255, 255, 192, 0, 0, 0, 0, 4, 255, 255, 192, 0, 0, 0, 0, - 3, 255, 255, 241, 0, 0, 0, 0, 1, 255, 255, 252, 48, 2, 97, 0, 0, 191, 255, 255, 255, 255, 242, 0, - 0, 63, 255, 255, 255, 255, 242, 0, 0, 6, 239, 255, 255, 255, 242, 0, 0, 0, 40, 206, 253, 202, 96, 31, - 255, 255, 16, 0, 0, 0, 10, 255, 255, 97, 255, 255, 241, 0, 0, 0, 0, 175, 255, 246, 31, 255, 255, 16, - 0, 0, 0, 10, 255, 255, 97, 255, 255, 241, 0, 0, 0, 0, 175, 255, 246, 31, 255, 255, 16, 0, 0, 0, - 10, 255, 255, 97, 255, 255, 241, 0, 0, 0, 0, 175, 255, 246, 31, 255, 255, 16, 0, 0, 0, 10, 255, 255, - 97, 255, 255, 241, 0, 0, 0, 0, 175, 255, 246, 31, 255, 255, 16, 0, 0, 0, 10, 255, 255, 97, 255, 255, - 241, 0, 0, 0, 0, 175, 255, 246, 31, 255, 255, 16, 0, 0, 0, 10, 255, 255, 97, 255, 255, 241, 0, 0, - 0, 0, 191, 255, 246, 31, 255, 255, 16, 0, 0, 0, 12, 255, 255, 97, 255, 255, 241, 0, 0, 0, 0, 239, - 255, 246, 15, 255, 255, 32, 0, 0, 0, 63, 255, 255, 96, 239, 255, 246, 0, 0, 0, 8, 255, 255, 246, 12, - 255, 255, 192, 0, 0, 3, 239, 255, 255, 96, 143, 255, 255, 179, 0, 39, 239, 255, 255, 246, 2, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 96, 8, 255, 255, 255, 255, 255, 254, 95, 255, 246, 0, 7, 255, 255, 255, 255, 252, - 48, 239, 255, 96, 0, 2, 140, 239, 237, 148, 0, 10, 255, 246, 207, 255, 248, 0, 0, 0, 0, 0, 175, 255, - 250, 127, 255, 253, 0, 0, 0, 0, 0, 239, 255, 245, 31, 255, 255, 48, 0, 0, 0, 5, 255, 255, 224, 10, - 255, 255, 112, 0, 0, 0, 10, 255, 255, 128, 5, 255, 255, 192, 0, 0, 0, 14, 255, 255, 48, 0, 239, 255, - 242, 0, 0, 0, 95, 255, 252, 0, 0, 159, 255, 247, 0, 0, 0, 175, 255, 246, 0, 0, 63, 255, 252, 0, - 0, 0, 239, 255, 241, 0, 0, 12, 255, 255, 32, 0, 5, 255, 255, 160, 0, 0, 7, 255, 255, 112, 0, 10, - 255, 255, 64, 0, 0, 1, 255, 255, 192, 0, 14, 255, 254, 0, 0, 0, 0, 191, 255, 242, 0, 95, 255, 248, - 0, 0, 0, 0, 95, 255, 246, 0, 175, 255, 243, 0, 0, 0, 0, 14, 255, 251, 0, 239, 255, 192, 0, 0, - 0, 0, 9, 255, 255, 20, 255, 255, 96, 0, 0, 0, 0, 3, 255, 255, 105, 255, 255, 16, 0, 0, 0, 0, - 0, 207, 255, 173, 255, 250, 0, 0, 0, 0, 0, 0, 127, 255, 239, 255, 244, 0, 0, 0, 0, 0, 0, 31, - 255, 255, 255, 208, 0, 0, 0, 0, 0, 0, 11, 255, 255, 255, 128, 0, 0, 0, 0, 0, 0, 5, 255, 255, - 255, 32, 0, 0, 0, 0, 0, 0, 0, 239, 255, 252, 0, 0, 0, 0, 127, 255, 249, 0, 0, 0, 4, 255, - 255, 248, 0, 0, 0, 6, 255, 255, 147, 255, 255, 208, 0, 0, 0, 143, 255, 255, 192, 0, 0, 0, 159, 255, - 245, 14, 255, 255, 32, 0, 0, 12, 255, 255, 255, 16, 0, 0, 13, 255, 255, 16, 159, 255, 246, 0, 0, 1, - 255, 255, 255, 245, 0, 0, 2, 255, 255, 192, 5, 255, 255, 144, 0, 0, 111, 255, 207, 255, 144, 0, 0, 111, - 255, 248, 0, 31, 255, 253, 0, 0, 10, 255, 245, 255, 253, 0, 0, 10, 255, 255, 48, 0, 207, 255, 242, 0, - 0, 239, 254, 13, 255, 242, 0, 0, 239, 255, 224, 0, 8, 255, 255, 96, 0, 63, 255, 176, 175, 255, 96, 0, - 63, 255, 250, 0, 0, 79, 255, 250, 0, 7, 255, 248, 6, 255, 250, 0, 7, 255, 255, 96, 0, 0, 239, 255, - 224, 0, 191, 255, 64, 47, 255, 224, 0, 175, 255, 242, 0, 0, 10, 255, 255, 32, 31, 255, 241, 0, 239, 255, - 48, 14, 255, 252, 0, 0, 0, 111, 255, 246, 5, 255, 252, 0, 10, 255, 247, 3, 255, 255, 128, 0, 0, 2, - 255, 255, 144, 143, 255, 128, 0, 111, 255, 160, 127, 255, 244, 0, 0, 0, 13, 255, 252, 11, 255, 244, 0, 3, - 255, 253, 10, 255, 254, 0, 0, 0, 0, 159, 255, 224, 239, 255, 16, 0, 14, 255, 241, 223, 255, 160, 0, 0, - 0, 5, 255, 255, 63, 255, 176, 0, 0, 175, 255, 95, 255, 246, 0, 0, 0, 0, 31, 255, 248, 255, 247, 0, - 0, 6, 255, 249, 255, 255, 32, 0, 0, 0, 0, 191, 255, 223, 255, 48, 0, 0, 47, 255, 239, 255, 208, 0, - 0, 0, 0, 7, 255, 255, 255, 224, 0, 0, 0, 223, 255, 255, 249, 0, 0, 0, 0, 0, 63, 255, 255, 250, - 0, 0, 0, 10, 255, 255, 255, 64, 0, 0, 0, 0, 0, 239, 255, 255, 96, 0, 0, 0, 111, 255, 255, 241, - 0, 0, 0, 0, 0, 10, 255, 255, 242, 0, 0, 0, 2, 255, 255, 251, 0, 0, 0, 29, 255, 255, 192, 0, - 0, 0, 6, 255, 255, 245, 4, 255, 255, 246, 0, 0, 0, 30, 255, 255, 160, 0, 159, 255, 254, 32, 0, 0, - 175, 255, 253, 16, 0, 29, 255, 255, 160, 0, 4, 255, 255, 244, 0, 0, 4, 255, 255, 245, 0, 29, 255, 255, - 144, 0, 0, 0, 159, 255, 253, 16, 143, 255, 253, 16, 0, 0, 0, 29, 255, 255, 131, 255, 255, 244, 0, 0, - 0, 0, 4, 255, 255, 253, 255, 255, 144, 0, 0, 0, 0, 0, 159, 255, 255, 255, 253, 16, 0, 0, 0, 0, - 0, 29, 255, 255, 255, 244, 0, 0, 0, 0, 0, 0, 4, 255, 255, 255, 144, 0, 0, 0, 0, 0, 0, 9, - 255, 255, 255, 209, 0, 0, 0, 0, 0, 0, 79, 255, 255, 255, 249, 0, 0, 0, 0, 0, 1, 223, 255, 255, - 255, 255, 64, 0, 0, 0, 0, 9, 255, 255, 216, 255, 255, 209, 0, 0, 0, 0, 79, 255, 255, 64, 207, 255, - 249, 0, 0, 0, 1, 223, 255, 249, 0, 63, 255, 255, 64, 0, 0, 9, 255, 255, 225, 0, 9, 255, 255, 209, - 0, 0, 79, 255, 255, 80, 0, 1, 223, 255, 249, 0, 1, 223, 255, 251, 0, 0, 0, 95, 255, 255, 80, 9, - 255, 255, 226, 0, 0, 0, 10, 255, 255, 225, 79, 255, 255, 112, 0, 0, 0, 1, 239, 255, 250, 207, 255, 249, - 0, 0, 0, 0, 0, 159, 255, 251, 111, 255, 254, 0, 0, 0, 0, 0, 223, 255, 246, 30, 255, 255, 64, 0, - 0, 0, 3, 255, 255, 225, 10, 255, 255, 144, 0, 0, 0, 8, 255, 255, 160, 4, 255, 255, 224, 0, 0, 0, - 13, 255, 255, 64, 0, 223, 255, 244, 0, 0, 0, 63, 255, 253, 0, 0, 127, 255, 249, 0, 0, 0, 143, 255, - 248, 0, 0, 31, 255, 254, 0, 0, 0, 223, 255, 242, 0, 0, 10, 255, 255, 64, 0, 3, 255, 255, 192, 0, - 0, 5, 255, 255, 144, 0, 7, 255, 255, 96, 0, 0, 0, 223, 255, 224, 0, 12, 255, 255, 16, 0, 0, 0, - 143, 255, 244, 0, 47, 255, 250, 0, 0, 0, 0, 47, 255, 249, 0, 127, 255, 245, 0, 0, 0, 0, 11, 255, - 254, 0, 207, 255, 224, 0, 0, 0, 0, 5, 255, 255, 66, 255, 255, 144, 0, 0, 0, 0, 0, 239, 255, 134, - 255, 255, 48, 0, 0, 0, 0, 0, 159, 255, 186, 255, 253, 0, 0, 0, 0, 0, 0, 63, 255, 238, 255, 247, - 0, 0, 0, 0, 0, 0, 12, 255, 255, 255, 242, 0, 0, 0, 0, 0, 0, 6, 255, 255, 255, 176, 0, 0, - 0, 0, 0, 0, 1, 239, 255, 255, 96, 0, 0, 0, 0, 0, 0, 0, 159, 255, 254, 16, 0, 0, 0, 0, - 0, 0, 0, 111, 255, 250, 0, 0, 0, 0, 0, 0, 0, 0, 207, 255, 244, 0, 0, 0, 0, 0, 0, 0, - 3, 255, 255, 208, 0, 0, 0, 0, 0, 0, 0, 10, 255, 255, 112, 0, 0, 0, 0, 0, 0, 0, 111, 255, - 254, 16, 0, 0, 0, 0, 1, 0, 23, 255, 255, 248, 0, 0, 0, 0, 0, 14, 255, 255, 255, 255, 192, 0, - 0, 0, 0, 0, 14, 255, 255, 255, 254, 32, 0, 0, 0, 0, 0, 14, 255, 255, 255, 211, 0, 0, 0, 0, - 0, 0, 11, 239, 253, 166, 0, 0, 0, 0, 0, 0, 0, 31, 255, 255, 255, 255, 255, 255, 255, 161, 255, 255, - 255, 255, 255, 255, 255, 250, 31, 255, 255, 255, 255, 255, 255, 255, 161, 238, 238, 238, 238, 238, 255, 255, 249, 0, - 0, 0, 0, 0, 127, 255, 253, 16, 0, 0, 0, 0, 63, 255, 255, 64, 0, 0, 0, 0, 12, 255, 255, 128, - 0, 0, 0, 0, 9, 255, 255, 192, 0, 0, 0, 0, 4, 255, 255, 226, 0, 0, 0, 0, 1, 239, 255, 246, - 0, 0, 0, 0, 0, 191, 255, 250, 0, 0, 0, 0, 0, 111, 255, 253, 16, 0, 0, 0, 0, 46, 255, 255, - 64, 0, 0, 0, 0, 12, 255, 255, 128, 0, 0, 0, 0, 8, 255, 255, 192, 0, 0, 0, 0, 4, 255, 255, - 226, 0, 0, 0, 0, 1, 223, 255, 246, 0, 0, 0, 0, 0, 175, 255, 250, 0, 0, 0, 0, 0, 111, 255, - 255, 254, 238, 238, 238, 238, 234, 255, 255, 255, 255, 255, 255, 255, 255, 175, 255, 255, 255, 255, 255, 255, 255, 250, - 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 191, 255, 255, 128, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 31, 255, 255, 254, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 255, 255, 255, 244, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 207, 255, 255, 255, 160, 0, 0, 0, 0, 0, 0, 0, 0, 63, 255, 251, 255, 255, 16, - 0, 0, 0, 0, 0, 0, 0, 9, 255, 255, 79, 255, 246, 0, 0, 0, 0, 0, 0, 0, 0, 239, 255, 176, - 239, 255, 192, 0, 0, 0, 0, 0, 0, 0, 95, 255, 247, 9, 255, 255, 32, 0, 0, 0, 0, 0, 0, 11, - 255, 255, 48, 95, 255, 248, 0, 0, 0, 0, 0, 0, 1, 255, 255, 208, 0, 239, 255, 224, 0, 0, 0, 0, - 0, 0, 127, 255, 248, 0, 9, 255, 255, 64, 0, 0, 0, 0, 0, 12, 255, 255, 32, 0, 79, 255, 250, 0, - 0, 0, 0, 0, 3, 255, 255, 192, 0, 0, 223, 255, 241, 0, 0, 0, 0, 0, 159, 255, 246, 0, 0, 8, - 255, 255, 96, 0, 0, 0, 0, 14, 255, 255, 16, 0, 0, 47, 255, 252, 0, 0, 0, 0, 5, 255, 255, 160, - 0, 0, 0, 207, 255, 242, 0, 0, 0, 0, 175, 255, 255, 238, 238, 238, 239, 255, 255, 128, 0, 0, 0, 31, - 255, 255, 255, 255, 255, 255, 255, 255, 253, 0, 0, 0, 7, 255, 255, 255, 255, 255, 255, 255, 255, 255, 244, 0, - 0, 0, 207, 255, 255, 255, 255, 255, 255, 255, 255, 255, 160, 0, 0, 63, 255, 254, 0, 0, 0, 0, 0, 47, - 255, 255, 16, 0, 9, 255, 255, 144, 0, 0, 0, 0, 0, 207, 255, 246, 0, 0, 239, 255, 244, 0, 0, 0, - 0, 0, 7, 255, 255, 192, 0, 95, 255, 254, 0, 0, 0, 0, 0, 0, 47, 255, 255, 32, 10, 255, 255, 160, - 0, 0, 0, 0, 0, 0, 207, 255, 248, 1, 255, 255, 245, 0, 0, 0, 0, 0, 0, 7, 255, 255, 208, 127, - 255, 254, 0, 0, 0, 0, 0, 0, 0, 47, 255, 255, 76, 255, 255, 160, 0, 0, 0, 0, 0, 0, 0, 207, - 255, 250, 207, 255, 246, 0, 0, 0, 0, 0, 0, 2, 255, 255, 241, 127, 255, 251, 0, 0, 0, 0, 0, 0, - 8, 255, 255, 176, 47, 255, 255, 16, 0, 0, 0, 0, 0, 13, 255, 255, 80, 12, 255, 255, 96, 0, 0, 0, - 0, 0, 63, 255, 254, 16, 6, 255, 255, 176, 0, 0, 0, 0, 0, 143, 255, 250, 0, 1, 255, 255, 241, 0, - 0, 0, 0, 0, 223, 255, 244, 0, 0, 191, 255, 246, 0, 0, 0, 0, 3, 255, 255, 224, 0, 0, 95, 255, - 251, 0, 0, 0, 0, 8, 255, 255, 144, 0, 0, 30, 255, 255, 16, 0, 0, 0, 13, 255, 255, 64, 0, 0, - 10, 255, 255, 96, 0, 0, 0, 63, 255, 253, 0, 0, 0, 4, 255, 255, 176, 0, 0, 0, 143, 255, 248, 0, - 0, 0, 0, 239, 255, 241, 0, 0, 0, 223, 255, 243, 0, 0, 0, 0, 159, 255, 246, 0, 0, 3, 255, 255, - 192, 0, 0, 0, 0, 79, 255, 251, 0, 0, 8, 255, 255, 112, 0, 0, 0, 0, 13, 255, 255, 16, 0, 13, - 255, 255, 32, 0, 0, 0, 0, 8, 255, 255, 96, 0, 63, 255, 252, 0, 0, 0, 0, 0, 3, 255, 255, 176, - 0, 143, 255, 246, 0, 0, 0, 0, 0, 0, 207, 255, 241, 0, 223, 255, 241, 0, 0, 0, 0, 0, 0, 127, - 255, 246, 3, 255, 255, 176, 0, 0, 0, 0, 0, 0, 47, 255, 250, 7, 255, 255, 80, 0, 0, 0, 0, 0, - 0, 12, 255, 254, 11, 255, 254, 16, 0, 0, 0, 0, 0, 0, 6, 255, 255, 79, 255, 250, 0, 0, 0, 0, - 0, 0, 0, 1, 255, 255, 175, 255, 244, 0, 0, 0, 0, 0, 0, 0, 0, 191, 255, 255, 255, 224, 0, 0, - 0, 0, 0, 0, 0, 0, 95, 255, 255, 255, 144, 0, 0, 0, 0, 0, 0, 0, 0, 30, 255, 255, 255, 64, - 0, 0, 0, 0, 0, 0, 0, 0, 10, 255, 255, 253, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 255, 255, - 248, 0, 0, 0, 0, 0, 79, 255, 255, 245, 0, 0, 0, 0, 0, 0, 175, 255, 244, 255, 255, 255, 225, 0, - 0, 0, 0, 0, 10, 255, 255, 79, 255, 255, 255, 144, 0, 0, 0, 0, 0, 175, 255, 244, 255, 255, 255, 255, - 48, 0, 0, 0, 0, 10, 255, 255, 79, 255, 255, 255, 252, 0, 0, 0, 0, 0, 175, 255, 244, 255, 255, 255, - 255, 246, 0, 0, 0, 0, 10, 255, 255, 79, 255, 252, 255, 255, 225, 0, 0, 0, 0, 175, 255, 244, 255, 255, - 63, 255, 255, 160, 0, 0, 0, 10, 255, 255, 79, 255, 241, 143, 255, 255, 64, 0, 0, 0, 175, 255, 244, 255, - 255, 33, 223, 255, 253, 0, 0, 0, 10, 255, 255, 79, 255, 243, 4, 255, 255, 248, 0, 0, 0, 175, 255, 244, - 255, 255, 48, 10, 255, 255, 242, 0, 0, 10, 255, 255, 79, 255, 244, 0, 46, 255, 255, 176, 0, 0, 175, 255, - 244, 255, 255, 64, 0, 111, 255, 255, 80, 0, 10, 255, 255, 79, 255, 245, 0, 0, 207, 255, 254, 16, 0, 175, - 255, 244, 255, 255, 80, 0, 3, 255, 255, 249, 0, 9, 255, 255, 79, 255, 245, 0, 0, 8, 255, 255, 243, 0, - 159, 255, 244, 255, 255, 80, 0, 0, 29, 255, 255, 192, 8, 255, 255, 79, 255, 245, 0, 0, 0, 79, 255, 255, - 96, 143, 255, 244, 255, 255, 80, 0, 0, 0, 175, 255, 254, 23, 255, 255, 79, 255, 245, 0, 0, 0, 2, 239, - 255, 250, 111, 255, 244, 255, 255, 80, 0, 0, 0, 6, 255, 255, 250, 255, 255, 79, 255, 245, 0, 0, 0, 0, - 12, 255, 255, 255, 255, 244, 255, 255, 80, 0, 0, 0, 0, 63, 255, 255, 255, 255, 79, 255, 245, 0, 0, 0, - 0, 0, 143, 255, 255, 255, 244, 255, 255, 80, 0, 0, 0, 0, 1, 223, 255, 255, 255, 79, 255, 245, 0, 0, - 0, 0, 0, 4, 255, 255, 255, 244, 255, 255, 80, 0, 0, 0, 0, 0, 10, 255, 255, 255, 127, 255, 255, 255, - 255, 237, 184, 64, 0, 0, 0, 7, 255, 255, 255, 255, 255, 255, 255, 214, 0, 0, 0, 127, 255, 255, 255, 255, - 255, 255, 255, 250, 0, 0, 7, 255, 255, 254, 238, 255, 255, 255, 255, 248, 0, 0, 127, 255, 252, 0, 0, 20, - 159, 255, 255, 242, 0, 7, 255, 255, 192, 0, 0, 0, 95, 255, 255, 112, 0, 127, 255, 252, 0, 0, 0, 0, - 191, 255, 251, 0, 7, 255, 255, 192, 0, 0, 0, 7, 255, 255, 192, 0, 127, 255, 252, 0, 0, 0, 0, 111, - 255, 253, 0, 7, 255, 255, 192, 0, 0, 0, 8, 255, 255, 176, 0, 127, 255, 252, 0, 0, 0, 0, 223, 255, - 248, 0, 7, 255, 255, 192, 0, 0, 0, 127, 255, 255, 32, 0, 127, 255, 252, 0, 0, 37, 191, 255, 255, 128, - 0, 7, 255, 255, 255, 255, 255, 255, 255, 255, 160, 0, 0, 127, 255, 255, 255, 255, 255, 255, 255, 112, 0, 0, - 7, 255, 255, 255, 255, 255, 255, 252, 32, 0, 0, 0, 127, 255, 255, 238, 238, 255, 255, 226, 0, 0, 0, 7, - 255, 255, 192, 0, 10, 255, 255, 176, 0, 0, 0, 127, 255, 252, 0, 0, 46, 255, 255, 96, 0, 0, 7, 255, - 255, 192, 0, 0, 127, 255, 254, 16, 0, 0, 127, 255, 252, 0, 0, 0, 223, 255, 250, 0, 0, 7, 255, 255, - 192, 0, 0, 4, 255, 255, 245, 0, 0, 127, 255, 252, 0, 0, 0, 10, 255, 255, 225, 0, 7, 255, 255, 192, - 0, 0, 0, 47, 255, 255, 144, 0, 127, 255, 252, 0, 0, 0, 0, 127, 255, 255, 64, 7, 255, 255, 192, 0, - 0, 0, 0, 223, 255, 253, 16, 127, 255, 252, 0, 0, 0, 0, 5, 255, 255, 248, 7, 255, 255, 192, 0, 0, - 0, 0, 11, 255, 255, 243, 0, 0, 0, 0, 72, 189, 239, 238, 201, 97, 0, 0, 0, 0, 0, 0, 0, 109, - 255, 255, 255, 255, 255, 255, 146, 0, 0, 0, 0, 0, 44, 255, 255, 255, 255, 255, 255, 255, 254, 96, 0, 0, - 0, 3, 239, 255, 255, 255, 255, 255, 255, 255, 255, 248, 0, 0, 0, 29, 255, 255, 254, 131, 16, 2, 91, 255, - 255, 255, 96, 0, 0, 175, 255, 255, 177, 0, 0, 0, 0, 95, 255, 255, 242, 0, 3, 255, 255, 251, 0, 0, - 0, 0, 0, 5, 255, 255, 250, 0, 9, 255, 255, 242, 0, 0, 0, 0, 0, 0, 175, 255, 255, 16, 14, 255, - 255, 160, 0, 0, 0, 0, 0, 0, 63, 255, 255, 96, 63, 255, 255, 80, 0, 0, 0, 0, 0, 0, 13, 255, - 255, 160, 111, 255, 255, 16, 0, 0, 0, 0, 0, 0, 10, 255, 255, 224, 159, 255, 253, 0, 0, 0, 0, 0, - 0, 0, 7, 255, 255, 241, 175, 255, 252, 0, 0, 0, 0, 0, 0, 0, 6, 255, 255, 242, 191, 255, 251, 0, - 0, 0, 0, 0, 0, 0, 5, 255, 255, 243, 175, 255, 251, 0, 0, 0, 0, 0, 0, 0, 5, 255, 255, 243, - 175, 255, 252, 0, 0, 0, 0, 0, 0, 0, 5, 255, 255, 242, 143, 255, 253, 0, 0, 0, 0, 0, 0, 0, - 7, 255, 255, 241, 111, 255, 255, 16, 0, 0, 0, 0, 0, 0, 10, 255, 255, 208, 63, 255, 255, 80, 0, 0, - 0, 0, 0, 0, 13, 255, 255, 160, 14, 255, 255, 160, 0, 0, 0, 0, 0, 0, 63, 255, 255, 96, 9, 255, - 255, 242, 0, 0, 0, 0, 0, 0, 175, 255, 255, 16, 3, 255, 255, 251, 0, 0, 0, 0, 0, 5, 255, 255, - 249, 0, 0, 159, 255, 255, 177, 0, 0, 0, 0, 95, 255, 255, 226, 0, 0, 29, 255, 255, 254, 131, 16, 2, - 91, 255, 255, 255, 96, 0, 0, 2, 223, 255, 255, 255, 255, 255, 255, 255, 255, 247, 0, 0, 0, 0, 44, 255, - 255, 255, 255, 255, 255, 255, 254, 96, 0, 0, 0, 0, 0, 109, 255, 255, 255, 255, 255, 255, 146, 0, 0, 0, - 0, 0, 0, 0, 72, 189, 239, 254, 201, 97, 0, 0, 0, 0, 79, 255, 253, 0, 0, 0, 0, 0, 0, 159, - 255, 248, 79, 255, 253, 0, 0, 0, 0, 0, 0, 159, 255, 248, 79, 255, 253, 0, 0, 0, 0, 0, 0, 159, - 255, 248, 79, 255, 253, 0, 0, 0, 0, 0, 0, 159, 255, 248, 79, 255, 253, 0, 0, 0, 0, 0, 0, 159, - 255, 248, 79, 255, 253, 0, 0, 0, 0, 0, 0, 159, 255, 248, 79, 255, 253, 0, 0, 0, 0, 0, 0, 159, - 255, 248, 79, 255, 253, 0, 0, 0, 0, 0, 0, 159, 255, 248, 79, 255, 253, 0, 0, 0, 0, 0, 0, 159, - 255, 248, 79, 255, 253, 0, 0, 0, 0, 0, 0, 159, 255, 248, 79, 255, 253, 0, 0, 0, 0, 0, 0, 159, - 255, 248, 79, 255, 255, 238, 238, 238, 238, 238, 238, 255, 255, 248, 79, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 248, 79, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 248, 79, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 248, 79, 255, 253, 0, 0, 0, 0, 0, 0, 159, 255, 248, 79, 255, 253, 0, 0, 0, 0, 0, 0, 159, - 255, 248, 79, 255, 253, 0, 0, 0, 0, 0, 0, 159, 255, 248, 79, 255, 253, 0, 0, 0, 0, 0, 0, 159, - 255, 248, 79, 255, 253, 0, 0, 0, 0, 0, 0, 159, 255, 248, 79, 255, 253, 0, 0, 0, 0, 0, 0, 159, - 255, 248, 79, 255, 253, 0, 0, 0, 0, 0, 0, 159, 255, 248, 79, 255, 253, 0, 0, 0, 0, 0, 0, 159, - 255, 248, 79, 255, 253, 0, 0, 0, 0, 0, 0, 159, 255, 248, 79, 255, 253, 0, 0, 0, 0, 0, 0, 159, - 255, 248, 79, 255, 253, 0, 0, 0, 0, 0, 0, 159, 255, 248, 79, 255, 253, 0, 0, 0, 0, 0, 0, 159, - 255, 248, 79, 255, 253, 0, 0, 0, 0, 0, 0, 159, 255, 248, 175, 255, 246, 0, 0, 0, 0, 0, 159, 255, - 249, 0, 0, 0, 0, 0, 95, 255, 252, 111, 255, 250, 0, 0, 0, 0, 0, 223, 255, 254, 0, 0, 0, 0, - 0, 159, 255, 248, 47, 255, 254, 0, 0, 0, 0, 3, 255, 255, 255, 48, 0, 0, 0, 0, 207, 255, 244, 13, - 255, 255, 48, 0, 0, 0, 7, 255, 255, 255, 112, 0, 0, 0, 1, 255, 255, 240, 9, 255, 255, 96, 0, 0, - 0, 11, 255, 255, 255, 176, 0, 0, 0, 5, 255, 255, 176, 5, 255, 255, 160, 0, 0, 0, 31, 255, 255, 255, - 241, 0, 0, 0, 8, 255, 255, 112, 1, 255, 255, 224, 0, 0, 0, 79, 255, 238, 255, 245, 0, 0, 0, 12, - 255, 255, 48, 0, 207, 255, 242, 0, 0, 0, 143, 255, 187, 255, 249, 0, 0, 0, 31, 255, 254, 0, 0, 143, - 255, 246, 0, 0, 0, 207, 255, 136, 255, 253, 0, 0, 0, 79, 255, 250, 0, 0, 95, 255, 250, 0, 0, 2, - 255, 255, 85, 255, 255, 32, 0, 0, 143, 255, 246, 0, 0, 31, 255, 253, 0, 0, 6, 255, 255, 17, 255, 255, - 96, 0, 0, 207, 255, 242, 0, 0, 12, 255, 255, 32, 0, 10, 255, 253, 0, 207, 255, 176, 0, 1, 255, 255, - 208, 0, 0, 8, 255, 255, 96, 0, 14, 255, 248, 0, 143, 255, 224, 0, 4, 255, 255, 144, 0, 0, 4, 255, - 255, 144, 0, 63, 255, 244, 0, 79, 255, 244, 0, 8, 255, 255, 80, 0, 0, 0, 239, 255, 208, 0, 127, 255, - 241, 0, 14, 255, 248, 0, 11, 255, 255, 16, 0, 0, 0, 191, 255, 242, 0, 191, 255, 176, 0, 10, 255, 253, - 0, 15, 255, 252, 0, 0, 0, 0, 127, 255, 245, 1, 255, 255, 112, 0, 6, 255, 255, 32, 79, 255, 248, 0, - 0, 0, 0, 63, 255, 249, 4, 255, 255, 48, 0, 2, 255, 255, 96, 127, 255, 244, 0, 0, 0, 0, 14, 255, - 252, 8, 255, 253, 0, 0, 0, 223, 255, 144, 191, 255, 241, 0, 0, 0, 0, 10, 255, 255, 11, 255, 249, 0, - 0, 0, 143, 255, 192, 239, 255, 176, 0, 0, 0, 0, 6, 255, 255, 62, 255, 245, 0, 0, 0, 79, 255, 242, - 255, 255, 112, 0, 0, 0, 0, 2, 255, 255, 127, 255, 241, 0, 0, 0, 14, 255, 247, 255, 255, 48, 0, 0, - 0, 0, 0, 223, 255, 207, 255, 192, 0, 0, 0, 10, 255, 252, 255, 254, 0, 0, 0, 0, 0, 0, 159, 255, - 255, 255, 112, 0, 0, 0, 6, 255, 255, 255, 251, 0, 0, 0, 0, 0, 0, 95, 255, 255, 255, 48, 0, 0, - 0, 2, 255, 255, 255, 247, 0, 0, 0, 0, 0, 0, 31, 255, 255, 254, 0, 0, 0, 0, 0, 223, 255, 255, - 243, 0, 0, 0, 0, 0, 0, 13, 255, 255, 250, 0, 0, 0, 0, 0, 143, 255, 255, 224, 0, 0, 0, 0, - 0, 0, 9, 255, 255, 246, 0, 0, 0, 0, 0, 79, 255, 255, 160, 0, 0, 0, - ], -}; - -/// NotoSans-Medium at 26 px: 97 glyphs, 9784 B of 4-bit coverage. -pub static S: Font = Font { - ascent: 28, - descent: 8, - cap: 18, - glyphs: &[ - Glyph { c: ' ', adv: 7, x: 0, y: 0, w: 0, h: 0, off: 0 }, - Glyph { c: '!', adv: 7, x: 1, y: -18, w: 5, h: 18, off: 0 }, - Glyph { c: '"', adv: 11, x: 1, y: -18, w: 9, h: 7, off: 45 }, - Glyph { c: '#', adv: 17, x: 0, y: -18, w: 17, h: 18, off: 77 }, - Glyph { c: '$', adv: 15, x: 1, y: -19, w: 13, h: 21, off: 230 }, - Glyph { c: '%', adv: 22, x: 1, y: -18, w: 20, h: 18, off: 367 }, - Glyph { c: '&', adv: 19, x: 1, y: -18, w: 18, h: 18, off: 547 }, - Glyph { c: '\'', adv: 6, x: 1, y: -18, w: 4, h: 7, off: 709 }, - Glyph { c: '(', adv: 8, x: 1, y: -18, w: 7, h: 22, off: 723 }, - Glyph { c: ')', adv: 8, x: 0, y: -18, w: 8, h: 22, off: 800 }, - Glyph { c: '*', adv: 14, x: 1, y: -19, w: 13, h: 12, off: 888 }, - Glyph { c: '+', adv: 15, x: 1, y: -15, w: 13, h: 12, off: 966 }, - Glyph { c: ',', adv: 7, x: 1, y: -3, w: 5, h: 6, off: 1044 }, - Glyph { c: '-', adv: 8, x: 1, y: -9, w: 7, h: 3, off: 1059 }, - Glyph { c: '.', adv: 7, x: 1, y: -4, w: 5, h: 4, off: 1070 }, - Glyph { c: '/', adv: 10, x: 0, y: -18, w: 10, h: 18, off: 1080 }, - Glyph { c: '0', adv: 15, x: 1, y: -18, w: 13, h: 18, off: 1170 }, - Glyph { c: '1', adv: 15, x: 2, y: -18, w: 8, h: 18, off: 1287 }, - Glyph { c: '2', adv: 15, x: 1, y: -18, w: 13, h: 18, off: 1359 }, - Glyph { c: '3', adv: 15, x: 1, y: -18, w: 13, h: 18, off: 1476 }, - Glyph { c: '4', adv: 15, x: 0, y: -18, w: 15, h: 18, off: 1593 }, - Glyph { c: '5', adv: 15, x: 1, y: -18, w: 13, h: 18, off: 1728 }, - Glyph { c: '6', adv: 15, x: 1, y: -18, w: 13, h: 18, off: 1845 }, - Glyph { c: '7', adv: 15, x: 1, y: -18, w: 13, h: 18, off: 1962 }, - Glyph { c: '8', adv: 15, x: 1, y: -18, w: 13, h: 18, off: 2079 }, - Glyph { c: '9', adv: 15, x: 1, y: -18, w: 13, h: 18, off: 2196 }, - Glyph { c: ':', adv: 7, x: 1, y: -14, w: 5, h: 14, off: 2313 }, - Glyph { c: ';', adv: 7, x: 0, y: -14, w: 6, h: 18, off: 2348 }, - Glyph { c: '<', adv: 15, x: 1, y: -16, w: 13, h: 13, off: 2402 }, - Glyph { c: '=', adv: 15, x: 1, y: -13, w: 13, h: 8, off: 2487 }, - Glyph { c: '>', adv: 15, x: 1, y: -16, w: 13, h: 13, off: 2539 }, - Glyph { c: '?', adv: 12, x: 0, y: -18, w: 11, h: 18, off: 2624 }, - Glyph { c: '@', adv: 23, x: 1, y: -18, w: 21, h: 20, off: 2723 }, - Glyph { c: 'A', adv: 17, x: 0, y: -18, w: 17, h: 18, off: 2933 }, - Glyph { c: 'B', adv: 17, x: 2, y: -18, w: 14, h: 18, off: 3086 }, - Glyph { c: 'C', adv: 17, x: 1, y: -18, w: 15, h: 18, off: 3212 }, - Glyph { c: 'D', adv: 19, x: 2, y: -18, w: 16, h: 18, off: 3347 }, - Glyph { c: 'E', adv: 14, x: 2, y: -18, w: 11, h: 18, off: 3491 }, - Glyph { c: 'F', adv: 14, x: 2, y: -18, w: 11, h: 18, off: 3590 }, - Glyph { c: 'G', adv: 19, x: 1, y: -18, w: 16, h: 18, off: 3689 }, - Glyph { c: 'H', adv: 19, x: 2, y: -18, w: 15, h: 18, off: 3833 }, - Glyph { c: 'I', adv: 9, x: 1, y: -18, w: 8, h: 18, off: 3968 }, - Glyph { c: 'J', adv: 8, x: -2, y: -18, w: 8, h: 23, off: 4040 }, - Glyph { c: 'K', adv: 16, x: 2, y: -18, w: 15, h: 18, off: 4132 }, - Glyph { c: 'L', adv: 14, x: 2, y: -18, w: 12, h: 18, off: 4267 }, - Glyph { c: 'M', adv: 24, x: 2, y: -18, w: 20, h: 18, off: 4375 }, - Glyph { c: 'N', adv: 20, x: 2, y: -18, w: 16, h: 18, off: 4555 }, - Glyph { c: 'O', adv: 20, x: 1, y: -18, w: 18, h: 18, off: 4699 }, - Glyph { c: 'P', adv: 16, x: 2, y: -18, w: 13, h: 18, off: 4861 }, - Glyph { c: 'Q', adv: 20, x: 1, y: -18, w: 18, h: 22, off: 4978 }, - Glyph { c: 'R', adv: 16, x: 2, y: -18, w: 14, h: 18, off: 5176 }, - Glyph { c: 'S', adv: 14, x: 1, y: -18, w: 13, h: 18, off: 5302 }, - Glyph { c: 'T', adv: 15, x: 0, y: -18, w: 15, h: 18, off: 5419 }, - Glyph { c: 'U', adv: 19, x: 2, y: -18, w: 15, h: 18, off: 5554 }, - Glyph { c: 'V', adv: 16, x: 0, y: -18, w: 16, h: 18, off: 5689 }, - Glyph { c: 'W', adv: 24, x: 0, y: -18, w: 25, h: 18, off: 5833 }, - Glyph { c: 'X', adv: 16, x: 0, y: -18, w: 16, h: 18, off: 6058 }, - Glyph { c: 'Y', adv: 15, x: 0, y: -18, w: 15, h: 18, off: 6202 }, - Glyph { c: 'Z', adv: 15, x: 0, y: -18, w: 14, h: 18, off: 6337 }, - Glyph { c: '[', adv: 9, x: 2, y: -18, w: 6, h: 23, off: 6463 }, - Glyph { c: '\\', adv: 10, x: 0, y: -18, w: 10, h: 18, off: 6532 }, - Glyph { c: ']', adv: 9, x: 0, y: -18, w: 7, h: 23, off: 6622 }, - Glyph { c: '^', adv: 15, x: 1, y: -19, w: 13, h: 12, off: 6703 }, - Glyph { c: '_', adv: 11, x: -1, y: 1, w: 13, h: 3, off: 6781 }, - Glyph { c: '`', adv: 8, x: 1, y: -19, w: 6, h: 4, off: 6801 }, - Glyph { c: 'a', adv: 15, x: 1, y: -14, w: 12, h: 14, off: 6813 }, - Glyph { c: 'b', adv: 16, x: 2, y: -19, w: 13, h: 19, off: 6897 }, - Glyph { c: 'c', adv: 13, x: 1, y: -14, w: 11, h: 14, off: 7021 }, - Glyph { c: 'd', adv: 16, x: 1, y: -19, w: 13, h: 19, off: 7098 }, - Glyph { c: 'e', adv: 15, x: 1, y: -14, w: 13, h: 14, off: 7222 }, - Glyph { c: 'f', adv: 9, x: 0, y: -19, w: 11, h: 19, off: 7313 }, - Glyph { c: 'g', adv: 16, x: 1, y: -14, w: 13, h: 20, off: 7418 }, - Glyph { c: 'h', adv: 16, x: 2, y: -19, w: 13, h: 19, off: 7548 }, - Glyph { c: 'i', adv: 7, x: 2, y: -19, w: 4, h: 19, off: 7672 }, - Glyph { c: 'j', adv: 7, x: -2, y: -19, w: 8, h: 25, off: 7710 }, - Glyph { c: 'k', adv: 15, x: 2, y: -19, w: 13, h: 19, off: 7810 }, - Glyph { c: 'l', adv: 7, x: 2, y: -19, w: 3, h: 19, off: 7934 }, - Glyph { c: 'm', adv: 25, x: 2, y: -14, w: 21, h: 14, off: 7963 }, - Glyph { c: 'n', adv: 16, x: 2, y: -14, w: 13, h: 14, off: 8110 }, - Glyph { c: 'o', adv: 16, x: 1, y: -14, w: 14, h: 14, off: 8201 }, - Glyph { c: 'p', adv: 16, x: 2, y: -14, w: 13, h: 20, off: 8299 }, - Glyph { c: 'q', adv: 16, x: 1, y: -14, w: 13, h: 20, off: 8429 }, - Glyph { c: 'r', adv: 11, x: 2, y: -14, w: 9, h: 14, off: 8559 }, - Glyph { c: 's', adv: 13, x: 1, y: -14, w: 11, h: 14, off: 8622 }, - Glyph { c: 't', adv: 10, x: 0, y: -17, w: 10, h: 17, off: 8699 }, - Glyph { c: 'u', adv: 16, x: 2, y: -14, w: 13, h: 14, off: 8784 }, - Glyph { c: 'v', adv: 14, x: 0, y: -14, w: 14, h: 14, off: 8875 }, - Glyph { c: 'w', adv: 21, x: 0, y: -14, w: 21, h: 14, off: 8973 }, - Glyph { c: 'x', adv: 14, x: 0, y: -14, w: 14, h: 14, off: 9120 }, - Glyph { c: 'y', adv: 14, x: 0, y: -14, w: 14, h: 20, off: 9218 }, - Glyph { c: 'z', adv: 12, x: 0, y: -14, w: 12, h: 14, off: 9358 }, - Glyph { c: '{', adv: 10, x: 0, y: -18, w: 10, h: 23, off: 9442 }, - Glyph { c: '|', adv: 14, x: 6, y: -19, w: 3, h: 25, off: 9557 }, - Glyph { c: '}', adv: 10, x: 0, y: -18, w: 10, h: 23, off: 9595 }, - Glyph { c: '~', adv: 15, x: 1, y: -11, w: 13, h: 4, off: 9710 }, - Glyph { c: '…', adv: 21, x: 1, y: -4, w: 19, h: 4, off: 9736 }, - Glyph { c: '·', adv: 7, x: 1, y: -12, w: 5, h: 4, off: 9774 }, - ], - bits: &[ - 31, 255, 32, 255, 241, 14, 255, 16, 239, 240, 13, 254, 0, 207, 224, 11, 253, 0, 191, 192, 10, 251, 0, 159, - 176, 8, 250, 0, 127, 144, 7, 248, 0, 0, 0, 10, 234, 3, 255, 244, 63, 255, 64, 174, 160, 95, 247, 5, - 255, 115, 255, 96, 79, 246, 47, 245, 2, 255, 65, 255, 64, 31, 243, 15, 242, 0, 255, 32, 239, 16, 14, 241, - 13, 240, 0, 223, 0, 0, 0, 0, 191, 96, 3, 253, 0, 0, 0, 0, 14, 243, 0, 111, 160, 0, 0, 0, - 3, 255, 0, 9, 247, 0, 0, 0, 0, 111, 192, 0, 207, 64, 0, 0, 0, 9, 249, 0, 31, 241, 0, 0, - 111, 255, 255, 255, 255, 255, 255, 242, 6, 255, 255, 255, 255, 255, 255, 255, 32, 19, 52, 255, 51, 59, 248, 51, - 48, 0, 0, 95, 192, 0, 223, 64, 0, 0, 0, 8, 249, 0, 31, 241, 0, 0, 19, 51, 191, 131, 54, 254, - 51, 49, 6, 255, 255, 255, 255, 255, 255, 255, 64, 111, 255, 255, 255, 255, 255, 255, 244, 0, 0, 79, 192, 0, - 207, 80, 0, 0, 0, 7, 249, 0, 31, 241, 0, 0, 0, 0, 175, 96, 4, 253, 0, 0, 0, 0, 13, 243, - 0, 127, 160, 0, 0, 0, 1, 255, 16, 10, 247, 0, 0, 0, 0, 0, 6, 244, 0, 0, 0, 0, 0, 111, - 64, 0, 0, 0, 23, 173, 252, 168, 64, 0, 94, 255, 255, 255, 255, 208, 46, 255, 204, 250, 173, 248, 7, 255, - 112, 111, 64, 3, 32, 143, 243, 6, 244, 0, 0, 6, 255, 144, 111, 64, 0, 0, 30, 255, 203, 244, 0, 0, - 0, 61, 255, 255, 198, 16, 0, 0, 23, 223, 255, 254, 112, 0, 0, 0, 143, 239, 255, 176, 0, 0, 6, 244, - 77, 255, 64, 0, 0, 111, 64, 79, 247, 0, 0, 6, 244, 5, 255, 120, 183, 49, 111, 102, 239, 242, 143, 255, - 255, 255, 255, 247, 4, 190, 255, 255, 254, 164, 0, 0, 1, 56, 245, 0, 0, 0, 0, 0, 111, 64, 0, 0, - 0, 0, 6, 244, 0, 0, 0, 2, 174, 235, 48, 0, 0, 4, 255, 32, 0, 29, 255, 255, 226, 0, 0, 12, - 248, 0, 0, 111, 246, 77, 250, 0, 0, 111, 209, 0, 0, 175, 160, 6, 254, 0, 1, 239, 96, 0, 0, 207, - 112, 2, 255, 16, 8, 252, 0, 0, 0, 223, 96, 1, 255, 32, 47, 243, 0, 0, 0, 207, 112, 2, 255, 16, - 175, 160, 0, 0, 0, 175, 160, 6, 254, 4, 254, 35, 190, 234, 32, 111, 246, 77, 250, 12, 248, 46, 254, 239, - 209, 12, 255, 255, 243, 111, 209, 143, 192, 29, 248, 1, 174, 235, 65, 239, 96, 207, 96, 7, 252, 0, 0, 0, - 8, 252, 0, 239, 64, 4, 254, 0, 0, 0, 47, 243, 0, 255, 64, 4, 255, 0, 0, 0, 175, 160, 0, 239, - 80, 5, 254, 0, 0, 4, 254, 32, 0, 207, 128, 8, 252, 0, 0, 12, 248, 0, 0, 127, 229, 94, 248, 0, - 0, 111, 209, 0, 0, 29, 255, 255, 225, 0, 1, 239, 80, 0, 0, 2, 190, 235, 32, 0, 2, 157, 254, 199, - 16, 0, 0, 0, 0, 62, 255, 255, 255, 192, 0, 0, 0, 0, 191, 248, 52, 207, 246, 0, 0, 0, 0, 255, - 176, 0, 47, 249, 0, 0, 0, 0, 239, 160, 0, 31, 249, 0, 0, 0, 0, 191, 225, 0, 143, 245, 0, 0, - 0, 0, 63, 251, 25, 255, 160, 0, 0, 0, 0, 7, 255, 255, 249, 0, 0, 0, 0, 0, 6, 255, 255, 80, - 0, 0, 0, 0, 1, 191, 250, 239, 193, 0, 0, 223, 224, 12, 255, 96, 78, 253, 32, 4, 255, 144, 111, 249, - 0, 4, 239, 227, 10, 255, 48, 175, 244, 0, 0, 62, 254, 143, 250, 0, 175, 244, 0, 0, 3, 239, 255, 226, - 0, 143, 249, 0, 0, 0, 143, 255, 144, 0, 47, 255, 165, 52, 124, 255, 255, 248, 0, 5, 255, 255, 255, 255, - 250, 61, 255, 128, 0, 40, 206, 254, 200, 32, 2, 223, 249, 95, 247, 63, 246, 47, 245, 31, 244, 15, 242, 14, - 241, 13, 240, 0, 8, 254, 16, 4, 255, 96, 0, 223, 176, 0, 111, 245, 0, 12, 253, 0, 2, 255, 128, 0, - 95, 244, 0, 9, 255, 16, 0, 191, 208, 0, 13, 252, 0, 0, 239, 176, 0, 14, 251, 0, 0, 223, 192, 0, - 12, 253, 0, 0, 159, 241, 0, 6, 255, 64, 0, 47, 248, 0, 0, 207, 208, 0, 6, 255, 64, 0, 13, 251, - 0, 0, 79, 245, 0, 0, 143, 225, 29, 249, 0, 0, 4, 255, 80, 0, 0, 175, 225, 0, 0, 63, 247, 0, - 0, 12, 253, 0, 0, 7, 255, 48, 0, 3, 255, 112, 0, 0, 239, 176, 0, 0, 207, 208, 0, 0, 191, 224, - 0, 0, 159, 240, 0, 0, 159, 241, 0, 0, 175, 240, 0, 0, 207, 208, 0, 0, 239, 176, 0, 3, 255, 112, - 0, 6, 255, 64, 0, 12, 254, 0, 0, 63, 248, 0, 0, 175, 225, 0, 4, 255, 96, 0, 13, 250, 0, 0, - 0, 0, 79, 246, 0, 0, 0, 0, 2, 255, 80, 0, 0, 0, 0, 31, 243, 0, 0, 5, 48, 0, 239, 16, - 3, 96, 207, 234, 109, 245, 157, 255, 14, 255, 255, 255, 255, 255, 242, 18, 69, 207, 253, 84, 50, 0, 0, 79, - 237, 247, 0, 0, 0, 46, 248, 111, 244, 0, 0, 11, 255, 16, 223, 209, 0, 2, 207, 144, 6, 253, 64, 0, - 0, 66, 0, 6, 0, 0, 0, 0, 10, 247, 0, 0, 0, 0, 0, 175, 112, 0, 0, 0, 0, 10, 247, 0, - 0, 0, 0, 0, 175, 112, 0, 0, 35, 51, 59, 248, 51, 51, 27, 255, 255, 255, 255, 255, 249, 191, 255, 255, - 255, 255, 255, 144, 0, 0, 175, 112, 0, 0, 0, 0, 10, 247, 0, 0, 0, 0, 0, 175, 112, 0, 0, 0, - 0, 10, 247, 0, 0, 0, 0, 0, 175, 112, 0, 0, 12, 255, 32, 255, 208, 63, 247, 6, 255, 32, 175, 160, - 13, 243, 0, 51, 51, 51, 31, 255, 255, 246, 255, 255, 255, 96, 10, 234, 3, 255, 244, 63, 255, 64, 174, 160, - 0, 0, 0, 31, 249, 0, 0, 0, 111, 243, 0, 0, 0, 207, 192, 0, 0, 3, 255, 112, 0, 0, 9, 255, - 16, 0, 0, 14, 250, 0, 0, 0, 95, 244, 0, 0, 0, 191, 208, 0, 0, 2, 255, 128, 0, 0, 8, 255, - 32, 0, 0, 13, 251, 0, 0, 0, 79, 245, 0, 0, 0, 175, 225, 0, 0, 1, 255, 144, 0, 0, 6, 255, - 48, 0, 0, 12, 252, 0, 0, 0, 63, 247, 0, 0, 0, 159, 241, 0, 0, 0, 0, 5, 190, 253, 163, 0, - 0, 9, 255, 255, 255, 246, 0, 7, 255, 197, 54, 223, 243, 0, 239, 209, 0, 2, 255, 176, 79, 247, 0, 0, - 10, 255, 23, 255, 48, 0, 0, 111, 245, 175, 241, 0, 0, 3, 255, 139, 255, 0, 0, 0, 47, 249, 207, 224, - 0, 0, 1, 255, 172, 254, 0, 0, 0, 31, 250, 191, 240, 0, 0, 2, 255, 154, 255, 16, 0, 0, 63, 248, - 127, 243, 0, 0, 6, 255, 83, 255, 112, 0, 0, 175, 242, 13, 253, 16, 0, 47, 251, 0, 95, 252, 83, 109, - 255, 64, 0, 143, 255, 255, 255, 96, 0, 0, 75, 239, 234, 64, 0, 0, 0, 94, 250, 0, 8, 255, 250, 1, - 191, 255, 250, 78, 255, 111, 250, 159, 227, 15, 250, 8, 16, 31, 250, 0, 0, 31, 250, 0, 0, 31, 250, 0, - 0, 31, 250, 0, 0, 31, 250, 0, 0, 31, 250, 0, 0, 31, 250, 0, 0, 31, 250, 0, 0, 31, 250, 0, - 0, 31, 250, 0, 0, 31, 250, 0, 0, 31, 250, 0, 0, 31, 250, 0, 56, 206, 254, 164, 0, 1, 175, 255, - 255, 255, 249, 0, 111, 253, 116, 55, 239, 246, 0, 169, 0, 0, 3, 255, 192, 0, 0, 0, 0, 13, 254, 0, - 0, 0, 0, 0, 223, 208, 0, 0, 0, 0, 47, 251, 0, 0, 0, 0, 8, 255, 80, 0, 0, 0, 4, 255, - 192, 0, 0, 0, 3, 239, 226, 0, 0, 0, 3, 239, 227, 0, 0, 0, 3, 239, 228, 0, 0, 0, 3, 239, - 227, 0, 0, 0, 3, 239, 227, 0, 0, 0, 3, 239, 210, 0, 0, 0, 3, 239, 229, 51, 51, 51, 50, 207, - 255, 255, 255, 255, 255, 172, 255, 255, 255, 255, 255, 250, 1, 106, 222, 254, 182, 0, 5, 239, 255, 255, 255, 252, - 16, 79, 233, 83, 54, 223, 249, 0, 49, 0, 0, 2, 255, 208, 0, 0, 0, 0, 13, 254, 0, 0, 0, 0, - 3, 255, 160, 0, 0, 0, 39, 239, 210, 0, 1, 255, 255, 252, 112, 0, 0, 31, 255, 255, 218, 48, 0, 0, - 51, 53, 142, 255, 96, 0, 0, 0, 0, 45, 255, 32, 0, 0, 0, 0, 127, 246, 0, 0, 0, 0, 6, 255, - 112, 0, 0, 0, 0, 143, 246, 48, 0, 0, 0, 46, 255, 45, 216, 83, 52, 142, 255, 128, 223, 255, 255, 255, - 255, 144, 3, 139, 222, 254, 200, 48, 0, 0, 0, 0, 0, 79, 252, 0, 0, 0, 0, 0, 30, 255, 192, 0, - 0, 0, 0, 11, 255, 252, 0, 0, 0, 0, 6, 253, 207, 192, 0, 0, 0, 3, 255, 92, 252, 0, 0, 0, - 0, 207, 160, 223, 192, 0, 0, 0, 159, 209, 13, 252, 0, 0, 0, 79, 243, 0, 223, 192, 0, 0, 30, 247, - 0, 13, 252, 0, 0, 11, 252, 0, 0, 223, 192, 0, 6, 254, 32, 0, 13, 252, 0, 3, 255, 131, 51, 51, - 223, 195, 49, 127, 255, 255, 255, 255, 255, 255, 103, 255, 255, 255, 255, 255, 255, 246, 0, 0, 0, 0, 13, 252, - 0, 0, 0, 0, 0, 0, 223, 192, 0, 0, 0, 0, 0, 13, 252, 0, 0, 0, 0, 0, 0, 223, 192, 0, - 6, 255, 255, 255, 255, 243, 0, 127, 255, 255, 255, 255, 48, 8, 255, 51, 51, 51, 48, 0, 159, 224, 0, 0, - 0, 0, 11, 253, 0, 0, 0, 0, 0, 207, 176, 0, 0, 0, 0, 13, 250, 18, 33, 0, 0, 0, 239, 255, - 255, 253, 129, 0, 14, 255, 255, 255, 255, 227, 0, 21, 33, 1, 92, 255, 192, 0, 0, 0, 0, 28, 255, 64, - 0, 0, 0, 0, 127, 246, 0, 0, 0, 0, 6, 255, 96, 0, 0, 0, 0, 143, 244, 32, 0, 0, 0, 46, - 254, 23, 217, 83, 53, 142, 255, 96, 127, 255, 255, 255, 255, 112, 1, 123, 222, 254, 200, 32, 0, 0, 0, 23, - 189, 239, 229, 0, 0, 110, 255, 255, 255, 96, 0, 127, 254, 133, 51, 66, 0, 63, 251, 16, 0, 0, 0, 11, - 254, 16, 0, 0, 0, 1, 255, 112, 0, 0, 0, 0, 95, 244, 58, 239, 217, 32, 8, 255, 111, 255, 255, 254, - 64, 159, 254, 214, 52, 175, 254, 26, 255, 193, 0, 0, 159, 246, 175, 244, 0, 0, 2, 255, 169, 255, 16, 0, - 0, 15, 251, 143, 243, 0, 0, 0, 255, 164, 255, 128, 0, 0, 63, 248, 13, 254, 32, 0, 10, 255, 64, 79, - 254, 99, 91, 255, 176, 0, 111, 255, 255, 255, 193, 0, 0, 57, 223, 236, 96, 0, 255, 255, 255, 255, 255, 255, - 191, 255, 255, 255, 255, 255, 251, 51, 51, 51, 51, 56, 255, 96, 0, 0, 0, 0, 223, 224, 0, 0, 0, 0, - 95, 247, 0, 0, 0, 0, 12, 254, 16, 0, 0, 0, 4, 255, 144, 0, 0, 0, 0, 191, 242, 0, 0, 0, - 0, 63, 250, 0, 0, 0, 0, 10, 255, 48, 0, 0, 0, 2, 255, 176, 0, 0, 0, 0, 159, 244, 0, 0, - 0, 0, 31, 253, 0, 0, 0, 0, 8, 255, 96, 0, 0, 0, 1, 239, 224, 0, 0, 0, 0, 127, 247, 0, - 0, 0, 0, 14, 254, 16, 0, 0, 0, 6, 255, 144, 0, 0, 0, 0, 23, 190, 254, 182, 0, 0, 45, 255, - 255, 255, 252, 16, 12, 255, 164, 53, 207, 250, 2, 255, 160, 0, 0, 223, 224, 63, 247, 0, 0, 10, 255, 17, - 255, 176, 0, 0, 223, 208, 8, 255, 145, 1, 175, 245, 0, 9, 255, 233, 239, 229, 0, 0, 7, 255, 255, 226, - 0, 0, 8, 255, 237, 255, 230, 0, 11, 255, 129, 4, 223, 248, 6, 255, 96, 0, 0, 175, 244, 191, 224, 0, - 0, 1, 255, 156, 254, 0, 0, 0, 31, 249, 175, 244, 0, 0, 7, 255, 116, 255, 232, 67, 89, 255, 225, 7, - 255, 255, 255, 255, 227, 0, 3, 156, 239, 236, 113, 0, 0, 23, 206, 237, 130, 0, 0, 45, 255, 255, 255, 229, - 0, 29, 255, 164, 54, 239, 243, 6, 255, 128, 0, 2, 239, 192, 175, 241, 0, 0, 7, 255, 60, 254, 0, 0, - 0, 63, 247, 207, 240, 0, 0, 3, 255, 137, 255, 80, 0, 0, 175, 249, 79, 254, 81, 19, 175, 255, 144, 159, - 255, 255, 255, 127, 248, 0, 109, 255, 252, 68, 255, 96, 0, 1, 33, 0, 111, 244, 0, 0, 0, 0, 11, 254, - 16, 0, 0, 0, 3, 255, 144, 0, 0, 0, 3, 223, 242, 0, 52, 51, 89, 255, 245, 0, 8, 255, 255, 255, - 229, 0, 0, 110, 254, 219, 97, 0, 0, 10, 234, 3, 255, 244, 63, 255, 64, 174, 160, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 234, 3, 255, 244, 63, 255, 64, 174, 160, 0, 174, 160, 3, - 255, 243, 3, 255, 243, 0, 174, 160, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 224, 2, 255, 160, 5, 255, 80, 9, 254, 0, 12, 247, 0, 31, - 241, 0, 0, 0, 0, 0, 0, 6, 112, 0, 0, 0, 0, 109, 249, 0, 0, 0, 6, 223, 253, 80, 0, 0, - 109, 255, 197, 0, 0, 6, 223, 252, 80, 0, 0, 109, 255, 180, 0, 0, 0, 191, 251, 48, 0, 0, 0, 10, - 255, 233, 48, 0, 0, 0, 4, 175, 255, 181, 0, 0, 0, 0, 40, 239, 253, 113, 0, 0, 0, 1, 125, 255, - 250, 48, 0, 0, 0, 5, 191, 249, 0, 0, 0, 0, 0, 57, 144, 35, 51, 51, 51, 51, 51, 26, 255, 255, - 255, 255, 255, 247, 175, 255, 255, 255, 255, 255, 112, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, - 51, 51, 51, 51, 51, 49, 175, 255, 255, 255, 255, 255, 122, 255, 255, 255, 255, 255, 247, 133, 0, 0, 0, 0, - 0, 11, 252, 80, 0, 0, 0, 0, 110, 255, 197, 0, 0, 0, 0, 23, 223, 252, 80, 0, 0, 0, 0, 109, - 255, 197, 0, 0, 0, 0, 5, 207, 252, 80, 0, 0, 0, 0, 76, 255, 128, 0, 0, 0, 58, 255, 247, 0, - 0, 22, 207, 255, 147, 0, 2, 142, 255, 231, 16, 0, 75, 255, 252, 80, 0, 0, 11, 255, 164, 0, 0, 0, - 0, 168, 32, 0, 0, 0, 0, 0, 3, 140, 239, 236, 113, 7, 255, 255, 255, 255, 209, 47, 182, 67, 91, 255, - 144, 16, 0, 0, 13, 253, 0, 0, 0, 0, 191, 224, 0, 0, 0, 30, 251, 0, 0, 0, 27, 255, 64, 0, - 0, 61, 255, 80, 0, 0, 78, 253, 48, 0, 0, 13, 252, 16, 0, 0, 3, 255, 32, 0, 0, 0, 95, 208, - 0, 0, 0, 1, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 237, 48, 0, 0, 0, 223, 249, 0, 0, - 0, 13, 255, 144, 0, 0, 0, 94, 210, 0, 0, 0, 0, 0, 21, 173, 239, 236, 148, 0, 0, 0, 0, 0, - 126, 255, 255, 255, 255, 252, 32, 0, 0, 2, 207, 253, 133, 51, 70, 175, 255, 80, 0, 1, 223, 230, 0, 0, - 0, 0, 43, 255, 48, 0, 191, 210, 0, 91, 239, 219, 129, 10, 253, 0, 95, 243, 0, 159, 255, 255, 255, 80, - 30, 245, 12, 248, 0, 111, 250, 67, 95, 244, 0, 143, 161, 255, 32, 14, 250, 0, 0, 255, 48, 5, 252, 95, - 208, 3, 255, 32, 0, 31, 243, 0, 63, 231, 251, 0, 95, 224, 0, 2, 255, 32, 3, 254, 143, 144, 5, 254, - 0, 0, 79, 241, 0, 95, 200, 250, 0, 79, 242, 0, 9, 255, 32, 10, 248, 127, 192, 1, 239, 178, 22, 254, - 248, 22, 255, 52, 255, 16, 7, 255, 255, 253, 63, 255, 255, 128, 14, 247, 0, 7, 239, 252, 32, 110, 254, 128, - 0, 143, 227, 0, 0, 33, 0, 0, 2, 0, 0, 1, 223, 229, 0, 0, 0, 0, 0, 0, 0, 0, 2, 223, - 253, 133, 51, 53, 122, 225, 0, 0, 0, 1, 159, 255, 255, 255, 255, 255, 16, 0, 0, 0, 0, 39, 189, 255, - 236, 166, 16, 0, 0, 0, 0, 0, 47, 255, 32, 0, 0, 0, 0, 0, 8, 255, 248, 0, 0, 0, 0, 0, - 0, 239, 239, 224, 0, 0, 0, 0, 0, 95, 247, 255, 80, 0, 0, 0, 0, 11, 254, 30, 251, 0, 0, 0, - 0, 2, 255, 160, 159, 242, 0, 0, 0, 0, 143, 244, 4, 255, 112, 0, 0, 0, 13, 254, 0, 13, 253, 0, - 0, 0, 4, 255, 128, 0, 143, 244, 0, 0, 0, 175, 242, 0, 2, 255, 160, 0, 0, 31, 254, 102, 102, 110, - 255, 16, 0, 7, 255, 255, 255, 255, 255, 247, 0, 0, 223, 255, 255, 255, 255, 255, 208, 0, 79, 251, 0, 0, - 0, 12, 255, 64, 10, 255, 80, 0, 0, 0, 95, 249, 1, 239, 224, 0, 0, 0, 0, 239, 225, 111, 248, 0, - 0, 0, 0, 8, 255, 108, 255, 32, 0, 0, 0, 0, 47, 252, 159, 255, 255, 254, 201, 64, 0, 159, 255, 255, - 255, 255, 251, 16, 159, 246, 51, 52, 142, 255, 128, 159, 244, 0, 0, 4, 255, 224, 159, 244, 0, 0, 0, 239, - 240, 159, 244, 0, 0, 0, 239, 224, 159, 244, 0, 0, 5, 255, 144, 159, 246, 51, 52, 126, 253, 16, 159, 255, - 255, 255, 254, 113, 0, 159, 255, 255, 255, 255, 232, 16, 159, 244, 0, 1, 58, 255, 193, 159, 244, 0, 0, 0, - 191, 246, 159, 244, 0, 0, 0, 111, 249, 159, 244, 0, 0, 0, 127, 249, 159, 244, 0, 0, 1, 223, 246, 159, - 246, 51, 51, 108, 255, 225, 159, 255, 255, 255, 255, 253, 48, 159, 255, 255, 255, 235, 97, 0, 0, 0, 4, 156, - 239, 237, 165, 16, 0, 27, 255, 255, 255, 255, 247, 0, 62, 255, 215, 67, 71, 206, 16, 12, 255, 144, 0, 0, - 0, 32, 8, 255, 176, 0, 0, 0, 0, 0, 239, 243, 0, 0, 0, 0, 0, 63, 252, 0, 0, 0, 0, 0, - 6, 255, 144, 0, 0, 0, 0, 0, 127, 248, 0, 0, 0, 0, 0, 6, 255, 128, 0, 0, 0, 0, 0, 95, - 249, 0, 0, 0, 0, 0, 3, 255, 192, 0, 0, 0, 0, 0, 14, 255, 32, 0, 0, 0, 0, 0, 159, 250, - 0, 0, 0, 0, 0, 2, 239, 248, 0, 0, 0, 0, 0, 5, 255, 252, 116, 52, 89, 192, 0, 4, 239, 255, - 255, 255, 255, 0, 0, 1, 107, 223, 254, 218, 96, 159, 255, 255, 253, 200, 48, 0, 0, 159, 255, 255, 255, 255, - 252, 32, 0, 159, 246, 51, 53, 141, 255, 227, 0, 159, 244, 0, 0, 0, 159, 253, 16, 159, 244, 0, 0, 0, - 10, 255, 144, 159, 244, 0, 0, 0, 2, 255, 224, 159, 244, 0, 0, 0, 0, 207, 244, 159, 244, 0, 0, 0, - 0, 159, 246, 159, 244, 0, 0, 0, 0, 143, 247, 159, 244, 0, 0, 0, 0, 143, 246, 159, 244, 0, 0, 0, - 0, 159, 245, 159, 244, 0, 0, 0, 0, 207, 242, 159, 244, 0, 0, 0, 3, 255, 208, 159, 244, 0, 0, 0, - 11, 255, 112, 159, 244, 0, 0, 1, 175, 253, 16, 159, 246, 51, 53, 158, 255, 210, 0, 159, 255, 255, 255, 255, - 250, 16, 0, 159, 255, 255, 237, 183, 32, 0, 0, 143, 255, 255, 255, 255, 232, 255, 255, 255, 255, 254, 143, 246, - 51, 51, 51, 40, 255, 64, 0, 0, 0, 143, 244, 0, 0, 0, 8, 255, 64, 0, 0, 0, 143, 244, 0, 0, - 0, 8, 255, 255, 255, 255, 247, 143, 255, 255, 255, 255, 120, 255, 99, 51, 51, 49, 143, 244, 0, 0, 0, 8, - 255, 64, 0, 0, 0, 143, 244, 0, 0, 0, 8, 255, 64, 0, 0, 0, 143, 244, 0, 0, 0, 8, 255, 99, - 51, 51, 50, 143, 255, 255, 255, 255, 232, 255, 255, 255, 255, 254, 143, 255, 255, 255, 255, 232, 255, 255, 255, 255, - 254, 143, 246, 51, 51, 51, 40, 255, 64, 0, 0, 0, 143, 244, 0, 0, 0, 8, 255, 64, 0, 0, 0, 143, - 244, 0, 0, 0, 8, 255, 64, 0, 0, 0, 143, 255, 255, 255, 255, 104, 255, 255, 255, 255, 246, 143, 246, 51, - 51, 51, 24, 255, 64, 0, 0, 0, 143, 244, 0, 0, 0, 8, 255, 64, 0, 0, 0, 143, 244, 0, 0, 0, - 8, 255, 64, 0, 0, 0, 143, 244, 0, 0, 0, 8, 255, 64, 0, 0, 0, 0, 0, 2, 123, 223, 254, 201, - 81, 0, 1, 159, 255, 255, 255, 255, 248, 0, 29, 255, 233, 83, 52, 123, 225, 0, 207, 252, 32, 0, 0, 0, - 16, 6, 255, 193, 0, 0, 0, 0, 0, 13, 255, 64, 0, 0, 0, 0, 0, 47, 253, 0, 0, 0, 0, 0, - 0, 95, 249, 0, 0, 0, 0, 0, 0, 111, 248, 0, 0, 12, 255, 255, 254, 111, 248, 0, 0, 12, 255, 255, - 254, 95, 249, 0, 0, 2, 51, 61, 254, 63, 252, 0, 0, 0, 0, 13, 254, 14, 255, 32, 0, 0, 0, 13, - 254, 8, 255, 160, 0, 0, 0, 13, 254, 1, 239, 249, 0, 0, 0, 13, 254, 0, 78, 255, 216, 83, 52, 126, - 254, 0, 3, 223, 255, 255, 255, 255, 254, 0, 0, 5, 173, 239, 254, 202, 99, 143, 244, 0, 0, 0, 0, 223, - 232, 255, 64, 0, 0, 0, 13, 254, 143, 244, 0, 0, 0, 0, 223, 232, 255, 64, 0, 0, 0, 13, 254, 143, - 244, 0, 0, 0, 0, 223, 232, 255, 64, 0, 0, 0, 13, 254, 143, 244, 0, 0, 0, 0, 223, 232, 255, 99, - 51, 51, 51, 61, 254, 143, 255, 255, 255, 255, 255, 255, 232, 255, 255, 255, 255, 255, 255, 254, 143, 244, 0, 0, - 0, 0, 223, 232, 255, 64, 0, 0, 0, 13, 254, 143, 244, 0, 0, 0, 0, 223, 232, 255, 64, 0, 0, 0, - 13, 254, 143, 244, 0, 0, 0, 0, 223, 232, 255, 64, 0, 0, 0, 13, 254, 143, 244, 0, 0, 0, 0, 223, - 232, 255, 64, 0, 0, 0, 13, 254, 255, 255, 255, 243, 207, 255, 255, 210, 1, 223, 242, 0, 0, 207, 240, 0, - 0, 207, 240, 0, 0, 207, 240, 0, 0, 207, 240, 0, 0, 207, 240, 0, 0, 207, 240, 0, 0, 207, 240, 0, - 0, 207, 240, 0, 0, 207, 240, 0, 0, 207, 240, 0, 0, 207, 240, 0, 0, 207, 240, 0, 0, 207, 241, 0, - 174, 255, 255, 178, 255, 255, 255, 243, 0, 0, 175, 243, 0, 0, 175, 243, 0, 0, 175, 243, 0, 0, 175, 243, - 0, 0, 175, 243, 0, 0, 175, 243, 0, 0, 175, 243, 0, 0, 175, 243, 0, 0, 175, 243, 0, 0, 175, 243, - 0, 0, 175, 243, 0, 0, 175, 243, 0, 0, 175, 243, 0, 0, 175, 243, 0, 0, 175, 243, 0, 0, 175, 243, - 0, 0, 175, 243, 0, 0, 175, 242, 0, 0, 191, 242, 0, 1, 239, 224, 83, 75, 255, 144, 255, 255, 252, 16, - 223, 252, 113, 0, 143, 244, 0, 0, 0, 127, 251, 8, 255, 64, 0, 0, 95, 252, 16, 143, 244, 0, 0, 79, - 253, 16, 8, 255, 64, 0, 46, 254, 32, 0, 143, 244, 0, 29, 254, 48, 0, 8, 255, 64, 28, 255, 64, 0, - 0, 143, 244, 11, 255, 96, 0, 0, 8, 255, 73, 255, 112, 0, 0, 0, 143, 251, 255, 248, 0, 0, 0, 8, - 255, 255, 239, 244, 0, 0, 0, 143, 254, 53, 255, 225, 0, 0, 8, 255, 80, 9, 255, 176, 0, 0, 143, 244, - 0, 28, 255, 112, 0, 8, 255, 64, 0, 62, 255, 48, 0, 143, 244, 0, 0, 111, 253, 16, 8, 255, 64, 0, - 0, 175, 249, 0, 143, 244, 0, 0, 1, 223, 245, 8, 255, 64, 0, 0, 3, 255, 226, 159, 244, 0, 0, 0, - 0, 159, 244, 0, 0, 0, 0, 159, 244, 0, 0, 0, 0, 159, 244, 0, 0, 0, 0, 159, 244, 0, 0, 0, - 0, 159, 244, 0, 0, 0, 0, 159, 244, 0, 0, 0, 0, 159, 244, 0, 0, 0, 0, 159, 244, 0, 0, 0, - 0, 159, 244, 0, 0, 0, 0, 159, 244, 0, 0, 0, 0, 159, 244, 0, 0, 0, 0, 159, 244, 0, 0, 0, - 0, 159, 244, 0, 0, 0, 0, 159, 244, 0, 0, 0, 0, 159, 248, 102, 102, 102, 97, 159, 255, 255, 255, 255, - 243, 159, 255, 255, 255, 255, 243, 143, 255, 160, 0, 0, 0, 0, 12, 255, 246, 143, 255, 225, 0, 0, 0, 0, - 63, 255, 246, 143, 222, 246, 0, 0, 0, 0, 143, 255, 246, 143, 217, 251, 0, 0, 0, 0, 239, 175, 246, 143, - 228, 255, 32, 0, 0, 5, 255, 95, 246, 143, 240, 223, 112, 0, 0, 10, 251, 79, 246, 143, 240, 143, 208, 0, - 0, 31, 245, 95, 246, 143, 240, 63, 243, 0, 0, 127, 224, 95, 246, 143, 240, 12, 249, 0, 0, 223, 144, 95, - 246, 143, 240, 7, 254, 0, 3, 255, 48, 95, 246, 143, 240, 2, 255, 80, 9, 252, 0, 95, 246, 143, 240, 0, - 191, 176, 14, 247, 0, 95, 246, 143, 240, 0, 111, 241, 95, 241, 0, 95, 246, 143, 240, 0, 31, 247, 191, 160, - 0, 95, 246, 143, 240, 0, 10, 253, 255, 64, 0, 95, 246, 143, 240, 0, 5, 255, 254, 0, 0, 95, 246, 143, - 240, 0, 0, 239, 248, 0, 0, 95, 246, 143, 240, 0, 0, 159, 242, 0, 0, 95, 246, 143, 255, 48, 0, 0, - 0, 13, 251, 143, 255, 192, 0, 0, 0, 13, 251, 143, 255, 246, 0, 0, 0, 13, 251, 143, 238, 254, 16, 0, - 0, 13, 251, 143, 215, 255, 160, 0, 0, 13, 251, 143, 224, 207, 244, 0, 0, 13, 251, 143, 224, 63, 253, 16, - 0, 13, 251, 143, 240, 8, 255, 128, 0, 13, 251, 143, 240, 0, 223, 243, 0, 13, 251, 143, 240, 0, 63, 252, - 0, 13, 251, 143, 240, 0, 9, 255, 96, 13, 251, 143, 240, 0, 1, 223, 226, 13, 251, 143, 240, 0, 0, 79, - 250, 12, 251, 143, 240, 0, 0, 9, 255, 92, 251, 143, 240, 0, 0, 1, 239, 220, 251, 143, 240, 0, 0, 0, - 95, 255, 251, 143, 240, 0, 0, 0, 10, 255, 251, 143, 240, 0, 0, 0, 1, 239, 251, 0, 0, 6, 173, 239, - 236, 130, 0, 0, 0, 3, 223, 255, 255, 255, 255, 112, 0, 0, 95, 255, 182, 51, 72, 239, 249, 0, 1, 239, - 246, 0, 0, 0, 45, 255, 96, 9, 255, 144, 0, 0, 0, 3, 255, 224, 14, 255, 32, 0, 0, 0, 0, 191, - 244, 63, 252, 0, 0, 0, 0, 0, 111, 249, 95, 249, 0, 0, 0, 0, 0, 79, 251, 111, 248, 0, 0, 0, - 0, 0, 63, 252, 111, 248, 0, 0, 0, 0, 0, 63, 252, 95, 249, 0, 0, 0, 0, 0, 79, 250, 63, 252, - 0, 0, 0, 0, 0, 111, 249, 14, 255, 32, 0, 0, 0, 0, 191, 244, 9, 255, 144, 0, 0, 0, 3, 255, - 224, 1, 239, 246, 0, 0, 0, 45, 255, 80, 0, 95, 255, 182, 51, 72, 239, 249, 0, 0, 3, 223, 255, 255, - 255, 255, 112, 0, 0, 0, 22, 189, 255, 236, 130, 0, 0, 159, 255, 255, 237, 166, 0, 9, 255, 255, 255, 255, - 253, 32, 159, 246, 51, 71, 223, 252, 9, 255, 64, 0, 1, 223, 245, 159, 244, 0, 0, 6, 255, 137, 255, 64, - 0, 0, 95, 248, 159, 244, 0, 0, 7, 255, 121, 255, 64, 0, 1, 223, 242, 159, 246, 51, 72, 239, 249, 9, - 255, 255, 255, 255, 249, 0, 159, 255, 255, 236, 147, 0, 9, 255, 64, 0, 0, 0, 0, 159, 244, 0, 0, 0, - 0, 9, 255, 64, 0, 0, 0, 0, 159, 244, 0, 0, 0, 0, 9, 255, 64, 0, 0, 0, 0, 159, 244, 0, - 0, 0, 0, 9, 255, 64, 0, 0, 0, 0, 0, 0, 6, 173, 239, 236, 130, 0, 0, 0, 3, 223, 255, 255, - 255, 255, 112, 0, 0, 95, 255, 182, 51, 72, 239, 249, 0, 1, 239, 246, 0, 0, 0, 45, 255, 80, 9, 255, - 144, 0, 0, 0, 3, 255, 224, 14, 255, 32, 0, 0, 0, 0, 191, 244, 63, 252, 0, 0, 0, 0, 0, 111, - 249, 95, 249, 0, 0, 0, 0, 0, 79, 251, 111, 248, 0, 0, 0, 0, 0, 63, 252, 111, 248, 0, 0, 0, - 0, 0, 63, 252, 95, 249, 0, 0, 0, 0, 0, 79, 251, 63, 252, 0, 0, 0, 0, 0, 111, 249, 14, 255, - 32, 0, 0, 0, 0, 191, 245, 9, 255, 144, 0, 0, 0, 3, 255, 225, 1, 239, 246, 0, 0, 0, 45, 255, - 112, 0, 95, 255, 182, 51, 72, 239, 250, 0, 0, 3, 223, 255, 255, 255, 255, 128, 0, 0, 0, 22, 189, 255, - 255, 226, 0, 0, 0, 0, 0, 0, 0, 191, 250, 0, 0, 0, 0, 0, 0, 0, 29, 255, 160, 0, 0, 0, - 0, 0, 0, 2, 239, 250, 0, 0, 0, 0, 0, 0, 0, 62, 255, 144, 159, 255, 255, 237, 182, 16, 0, 159, - 255, 255, 255, 255, 211, 0, 159, 246, 51, 54, 207, 253, 16, 159, 244, 0, 0, 28, 255, 80, 159, 244, 0, 0, - 7, 255, 144, 159, 244, 0, 0, 5, 255, 144, 159, 244, 0, 0, 7, 255, 112, 159, 244, 0, 0, 29, 255, 48, - 159, 246, 51, 54, 223, 248, 0, 159, 255, 255, 255, 255, 112, 0, 159, 255, 255, 255, 244, 0, 0, 159, 244, 0, - 63, 252, 0, 0, 159, 244, 0, 8, 255, 128, 0, 159, 244, 0, 1, 223, 243, 0, 159, 244, 0, 0, 95, 252, - 0, 159, 244, 0, 0, 10, 255, 128, 159, 244, 0, 0, 2, 239, 243, 159, 244, 0, 0, 0, 111, 252, 0, 23, - 206, 254, 218, 81, 0, 62, 255, 255, 255, 255, 144, 29, 255, 148, 52, 107, 243, 5, 255, 144, 0, 0, 1, 0, - 127, 245, 0, 0, 0, 0, 6, 255, 128, 0, 0, 0, 0, 47, 255, 96, 0, 0, 0, 0, 143, 255, 215, 16, - 0, 0, 0, 127, 255, 254, 146, 0, 0, 0, 41, 239, 255, 246, 0, 0, 0, 1, 109, 255, 246, 0, 0, 0, - 0, 8, 255, 208, 0, 0, 0, 0, 12, 255, 16, 0, 0, 0, 0, 191, 241, 32, 0, 0, 0, 46, 253, 11, - 217, 100, 52, 125, 255, 96, 191, 255, 255, 255, 255, 112, 3, 139, 222, 254, 200, 32, 0, 175, 255, 255, 255, 255, - 255, 255, 74, 255, 255, 255, 255, 255, 255, 244, 35, 51, 52, 255, 179, 51, 51, 16, 0, 0, 31, 251, 0, 0, - 0, 0, 0, 1, 255, 176, 0, 0, 0, 0, 0, 31, 251, 0, 0, 0, 0, 0, 1, 255, 176, 0, 0, 0, - 0, 0, 31, 251, 0, 0, 0, 0, 0, 1, 255, 176, 0, 0, 0, 0, 0, 31, 251, 0, 0, 0, 0, 0, - 1, 255, 176, 0, 0, 0, 0, 0, 31, 251, 0, 0, 0, 0, 0, 1, 255, 176, 0, 0, 0, 0, 0, 31, - 251, 0, 0, 0, 0, 0, 1, 255, 176, 0, 0, 0, 0, 0, 31, 251, 0, 0, 0, 0, 0, 1, 255, 176, - 0, 0, 0, 0, 0, 31, 251, 0, 0, 0, 175, 242, 0, 0, 0, 0, 239, 218, 255, 32, 0, 0, 0, 14, - 253, 175, 242, 0, 0, 0, 0, 239, 218, 255, 32, 0, 0, 0, 14, 253, 175, 242, 0, 0, 0, 0, 239, 218, - 255, 32, 0, 0, 0, 14, 253, 175, 242, 0, 0, 0, 0, 239, 218, 255, 32, 0, 0, 0, 14, 253, 175, 242, - 0, 0, 0, 0, 239, 218, 255, 32, 0, 0, 0, 14, 253, 175, 242, 0, 0, 0, 0, 239, 218, 255, 32, 0, - 0, 0, 14, 253, 159, 243, 0, 0, 0, 0, 255, 182, 255, 112, 0, 0, 0, 95, 248, 30, 254, 32, 0, 0, - 29, 255, 48, 111, 254, 132, 52, 125, 255, 128, 0, 127, 255, 255, 255, 255, 128, 0, 0, 40, 206, 254, 200, 48, - 0, 207, 241, 0, 0, 0, 0, 47, 252, 127, 246, 0, 0, 0, 0, 127, 247, 47, 252, 0, 0, 0, 0, 207, - 241, 11, 255, 32, 0, 0, 2, 255, 176, 6, 255, 112, 0, 0, 8, 255, 80, 1, 239, 192, 0, 0, 13, 254, - 16, 0, 175, 243, 0, 0, 63, 249, 0, 0, 79, 248, 0, 0, 159, 244, 0, 0, 14, 253, 0, 0, 239, 208, - 0, 0, 8, 255, 48, 4, 255, 128, 0, 0, 3, 255, 144, 10, 255, 32, 0, 0, 0, 207, 224, 14, 252, 0, - 0, 0, 0, 127, 244, 79, 247, 0, 0, 0, 0, 47, 248, 159, 241, 0, 0, 0, 0, 11, 252, 223, 176, 0, - 0, 0, 0, 6, 255, 255, 80, 0, 0, 0, 0, 1, 239, 254, 16, 0, 0, 0, 0, 0, 175, 249, 0, 0, - 0, 175, 243, 0, 0, 0, 111, 251, 0, 0, 0, 11, 255, 22, 255, 112, 0, 0, 10, 255, 241, 0, 0, 1, - 255, 192, 47, 251, 0, 0, 0, 239, 255, 80, 0, 0, 79, 248, 0, 223, 224, 0, 0, 79, 253, 249, 0, 0, - 8, 255, 64, 9, 255, 64, 0, 8, 254, 159, 224, 0, 0, 207, 241, 0, 95, 248, 0, 0, 223, 165, 255, 48, - 0, 31, 251, 0, 1, 255, 176, 0, 47, 246, 31, 248, 0, 4, 255, 112, 0, 12, 255, 16, 6, 255, 32, 191, - 192, 0, 143, 243, 0, 0, 143, 244, 0, 191, 208, 7, 255, 32, 12, 254, 0, 0, 4, 255, 128, 14, 248, 0, - 47, 246, 1, 255, 160, 0, 0, 14, 252, 4, 255, 64, 0, 223, 176, 95, 246, 0, 0, 0, 175, 241, 143, 224, - 0, 9, 254, 8, 255, 32, 0, 0, 6, 255, 76, 250, 0, 0, 79, 243, 207, 208, 0, 0, 0, 47, 247, 255, - 96, 0, 0, 239, 127, 248, 0, 0, 0, 0, 223, 207, 241, 0, 0, 10, 252, 255, 64, 0, 0, 0, 9, 255, - 252, 0, 0, 0, 111, 255, 241, 0, 0, 0, 0, 95, 255, 128, 0, 0, 1, 255, 251, 0, 0, 0, 0, 1, - 255, 243, 0, 0, 0, 12, 255, 112, 0, 0, 63, 253, 16, 0, 0, 2, 239, 225, 8, 255, 128, 0, 0, 10, - 255, 80, 0, 223, 243, 0, 0, 95, 250, 0, 0, 63, 252, 0, 1, 223, 225, 0, 0, 8, 255, 112, 9, 255, - 80, 0, 0, 0, 223, 242, 63, 250, 0, 0, 0, 0, 63, 251, 207, 225, 0, 0, 0, 0, 8, 255, 255, 80, - 0, 0, 0, 0, 0, 223, 251, 0, 0, 0, 0, 0, 4, 255, 254, 32, 0, 0, 0, 0, 29, 254, 255, 176, - 0, 0, 0, 0, 159, 245, 143, 246, 0, 0, 0, 4, 255, 160, 29, 254, 32, 0, 0, 29, 254, 16, 4, 255, - 176, 0, 0, 159, 246, 0, 0, 175, 247, 0, 4, 255, 176, 0, 0, 30, 254, 32, 29, 254, 32, 0, 0, 6, - 255, 192, 143, 247, 0, 0, 0, 0, 191, 247, 191, 245, 0, 0, 0, 2, 255, 211, 255, 192, 0, 0, 0, 175, - 245, 9, 255, 80, 0, 0, 63, 252, 0, 46, 253, 0, 0, 11, 255, 48, 0, 143, 246, 0, 3, 255, 160, 0, - 1, 239, 208, 0, 191, 242, 0, 0, 6, 255, 96, 79, 248, 0, 0, 0, 13, 254, 28, 254, 16, 0, 0, 0, - 95, 251, 255, 96, 0, 0, 0, 0, 191, 255, 208, 0, 0, 0, 0, 3, 255, 245, 0, 0, 0, 0, 0, 13, - 255, 0, 0, 0, 0, 0, 0, 223, 240, 0, 0, 0, 0, 0, 13, 255, 0, 0, 0, 0, 0, 0, 223, 240, - 0, 0, 0, 0, 0, 13, 255, 0, 0, 0, 0, 0, 0, 223, 240, 0, 0, 0, 0, 0, 13, 255, 0, 0, - 0, 12, 255, 255, 255, 255, 255, 252, 12, 255, 255, 255, 255, 255, 252, 2, 51, 51, 51, 51, 223, 245, 0, 0, - 0, 0, 7, 255, 144, 0, 0, 0, 0, 63, 253, 16, 0, 0, 0, 0, 207, 244, 0, 0, 0, 0, 8, 255, - 144, 0, 0, 0, 0, 63, 253, 16, 0, 0, 0, 1, 223, 244, 0, 0, 0, 0, 8, 255, 128, 0, 0, 0, - 0, 79, 253, 0, 0, 0, 0, 1, 223, 243, 0, 0, 0, 0, 9, 255, 128, 0, 0, 0, 0, 79, 252, 0, - 0, 0, 0, 1, 223, 243, 0, 0, 0, 0, 9, 255, 147, 51, 51, 51, 51, 31, 255, 255, 255, 255, 255, 255, - 47, 255, 255, 255, 255, 255, 255, 255, 255, 254, 255, 255, 254, 255, 147, 50, 255, 128, 0, 255, 128, 0, 255, 128, - 0, 255, 128, 0, 255, 128, 0, 255, 128, 0, 255, 128, 0, 255, 128, 0, 255, 128, 0, 255, 128, 0, 255, 128, - 0, 255, 128, 0, 255, 128, 0, 255, 128, 0, 255, 128, 0, 255, 128, 0, 255, 128, 0, 255, 255, 254, 255, 255, - 254, 51, 51, 50, 159, 241, 0, 0, 0, 63, 247, 0, 0, 0, 12, 252, 0, 0, 0, 6, 255, 48, 0, 0, - 1, 255, 144, 0, 0, 0, 175, 225, 0, 0, 0, 79, 245, 0, 0, 0, 13, 251, 0, 0, 0, 8, 255, 32, - 0, 0, 2, 255, 128, 0, 0, 0, 191, 208, 0, 0, 0, 95, 244, 0, 0, 0, 14, 250, 0, 0, 0, 9, - 255, 16, 0, 0, 3, 255, 112, 0, 0, 0, 207, 192, 0, 0, 0, 111, 243, 0, 0, 0, 31, 249, 95, 255, - 255, 149, 255, 255, 249, 19, 51, 255, 144, 0, 15, 249, 0, 0, 255, 144, 0, 15, 249, 0, 0, 255, 144, 0, - 15, 249, 0, 0, 255, 144, 0, 15, 249, 0, 0, 255, 144, 0, 15, 249, 0, 0, 255, 144, 0, 15, 249, 0, - 0, 255, 144, 0, 15, 249, 0, 0, 255, 144, 0, 15, 249, 0, 0, 255, 144, 0, 15, 249, 95, 255, 255, 149, - 255, 255, 249, 19, 51, 51, 16, 0, 0, 5, 112, 0, 0, 0, 0, 2, 255, 96, 0, 0, 0, 0, 159, 253, - 0, 0, 0, 0, 30, 252, 247, 0, 0, 0, 8, 249, 63, 225, 0, 0, 1, 239, 48, 191, 128, 0, 0, 127, - 176, 3, 254, 16, 0, 30, 244, 0, 10, 249, 0, 7, 252, 0, 0, 47, 242, 0, 223, 80, 0, 0, 159, 160, - 111, 208, 0, 0, 2, 255, 61, 246, 0, 0, 0, 9, 251, 3, 51, 51, 51, 51, 51, 17, 255, 255, 255, 255, - 255, 245, 31, 255, 255, 255, 255, 255, 80, 191, 249, 0, 28, 255, 64, 1, 191, 209, 0, 8, 251, 0, 39, 190, - 254, 199, 16, 2, 255, 255, 255, 255, 193, 0, 170, 100, 53, 207, 247, 0, 0, 0, 0, 31, 251, 0, 0, 0, - 0, 14, 252, 0, 57, 206, 255, 255, 253, 8, 255, 255, 255, 255, 253, 95, 255, 133, 51, 62, 253, 191, 246, 0, - 0, 14, 253, 223, 241, 0, 0, 31, 253, 207, 242, 0, 0, 159, 253, 143, 252, 83, 91, 254, 253, 29, 255, 255, - 255, 135, 253, 1, 157, 254, 181, 4, 253, 223, 208, 0, 0, 0, 0, 13, 253, 0, 0, 0, 0, 0, 223, 208, - 0, 0, 0, 0, 13, 253, 0, 0, 0, 0, 0, 223, 208, 0, 0, 0, 0, 13, 253, 6, 206, 236, 113, 0, - 223, 202, 255, 255, 255, 193, 13, 255, 249, 67, 92, 255, 160, 223, 249, 0, 0, 29, 255, 61, 255, 32, 0, 0, - 111, 247, 223, 240, 0, 0, 3, 255, 173, 254, 0, 0, 0, 47, 251, 223, 224, 0, 0, 2, 255, 189, 255, 0, - 0, 0, 63, 249, 223, 243, 0, 0, 7, 255, 125, 255, 144, 0, 1, 223, 242, 223, 255, 164, 53, 207, 250, 13, - 250, 207, 255, 255, 252, 16, 223, 80, 124, 238, 199, 16, 0, 0, 3, 140, 238, 219, 96, 7, 255, 255, 255, 250, - 5, 255, 231, 52, 106, 64, 239, 242, 0, 0, 0, 79, 249, 0, 0, 0, 7, 255, 80, 0, 0, 0, 159, 244, - 0, 0, 0, 9, 255, 64, 0, 0, 0, 127, 245, 0, 0, 0, 5, 255, 144, 0, 0, 0, 30, 254, 32, 0, - 0, 0, 127, 254, 115, 69, 153, 0, 143, 255, 255, 255, 160, 0, 57, 222, 253, 147, 0, 0, 0, 0, 0, 207, - 240, 0, 0, 0, 0, 12, 255, 0, 0, 0, 0, 0, 207, 240, 0, 0, 0, 0, 12, 255, 0, 0, 0, 0, - 0, 191, 240, 0, 108, 238, 199, 11, 255, 1, 191, 255, 255, 251, 191, 240, 143, 253, 99, 73, 255, 255, 31, 255, - 32, 0, 7, 255, 245, 255, 160, 0, 0, 31, 255, 143, 246, 0, 0, 0, 207, 249, 255, 64, 0, 0, 11, 255, - 159, 244, 0, 0, 0, 175, 248, 255, 80, 0, 0, 11, 255, 95, 248, 0, 0, 0, 239, 241, 255, 226, 0, 0, - 111, 255, 9, 255, 213, 52, 143, 255, 240, 27, 255, 255, 255, 185, 255, 0, 7, 206, 236, 96, 95, 240, 0, 3, - 157, 254, 199, 16, 0, 7, 255, 255, 255, 252, 16, 5, 255, 197, 52, 159, 251, 0, 223, 193, 0, 0, 159, 244, - 79, 246, 0, 0, 3, 255, 119, 255, 255, 255, 255, 255, 249, 159, 255, 255, 255, 255, 255, 153, 255, 99, 51, 51, - 51, 50, 127, 246, 0, 0, 0, 0, 4, 255, 160, 0, 0, 0, 0, 13, 255, 80, 0, 0, 1, 0, 79, 255, - 148, 51, 106, 224, 0, 110, 255, 255, 255, 254, 0, 0, 40, 206, 254, 200, 64, 0, 0, 75, 223, 235, 48, 0, - 127, 255, 255, 241, 0, 14, 255, 115, 69, 0, 2, 255, 160, 0, 0, 0, 63, 248, 0, 0, 2, 142, 255, 255, - 255, 0, 159, 255, 255, 255, 240, 1, 53, 255, 147, 51, 0, 0, 63, 248, 0, 0, 0, 3, 255, 128, 0, 0, - 0, 63, 248, 0, 0, 0, 3, 255, 128, 0, 0, 0, 63, 248, 0, 0, 0, 3, 255, 128, 0, 0, 0, 63, - 248, 0, 0, 0, 3, 255, 128, 0, 0, 0, 63, 248, 0, 0, 0, 3, 255, 128, 0, 0, 0, 63, 248, 0, - 0, 0, 0, 6, 206, 236, 112, 95, 240, 11, 255, 255, 255, 200, 255, 8, 255, 214, 52, 159, 255, 241, 239, 226, - 0, 0, 127, 255, 95, 249, 0, 0, 0, 239, 248, 255, 80, 0, 0, 12, 255, 159, 244, 0, 0, 0, 175, 249, - 255, 64, 0, 0, 10, 255, 143, 245, 0, 0, 0, 191, 245, 255, 128, 0, 0, 14, 255, 31, 254, 16, 0, 5, - 255, 240, 143, 253, 83, 72, 255, 255, 1, 191, 255, 255, 251, 191, 240, 0, 124, 238, 199, 11, 255, 0, 0, 0, - 0, 0, 207, 224, 0, 0, 0, 0, 14, 253, 1, 0, 0, 0, 7, 255, 144, 172, 133, 51, 90, 255, 242, 10, - 255, 255, 255, 255, 245, 0, 56, 189, 255, 236, 130, 0, 223, 208, 0, 0, 0, 0, 13, 253, 0, 0, 0, 0, - 0, 223, 208, 0, 0, 0, 0, 13, 253, 0, 0, 0, 0, 0, 223, 208, 0, 0, 0, 0, 13, 253, 5, 190, - 253, 146, 0, 223, 201, 255, 255, 255, 244, 13, 255, 251, 83, 91, 255, 192, 223, 250, 0, 0, 13, 255, 45, 255, - 64, 0, 0, 159, 244, 223, 240, 0, 0, 7, 255, 77, 254, 0, 0, 0, 127, 244, 223, 208, 0, 0, 7, 255, - 77, 253, 0, 0, 0, 127, 244, 223, 208, 0, 0, 7, 255, 77, 253, 0, 0, 0, 127, 244, 223, 208, 0, 0, - 7, 255, 77, 253, 0, 0, 0, 127, 244, 223, 208, 0, 0, 7, 255, 64, 158, 160, 255, 241, 158, 160, 0, 0, - 0, 0, 223, 208, 223, 208, 223, 208, 223, 208, 223, 208, 223, 208, 223, 208, 223, 208, 223, 208, 223, 208, 223, 208, - 223, 208, 223, 208, 223, 208, 0, 0, 158, 160, 0, 0, 255, 241, 0, 0, 158, 160, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 223, 208, 0, 0, 223, 208, 0, 0, 223, 208, 0, 0, 223, 208, 0, 0, 223, 208, 0, 0, - 223, 208, 0, 0, 223, 208, 0, 0, 223, 208, 0, 0, 223, 208, 0, 0, 223, 208, 0, 0, 223, 208, 0, 0, - 223, 208, 0, 0, 223, 208, 0, 0, 223, 208, 0, 0, 223, 208, 0, 0, 223, 208, 0, 0, 255, 192, 36, 74, - 255, 144, 111, 255, 254, 32, 94, 254, 179, 0, 223, 208, 0, 0, 0, 0, 13, 253, 0, 0, 0, 0, 0, 223, - 208, 0, 0, 0, 0, 13, 253, 0, 0, 0, 0, 0, 223, 208, 0, 0, 0, 0, 13, 253, 0, 0, 10, 255, - 128, 223, 208, 0, 9, 255, 144, 13, 253, 0, 8, 255, 160, 0, 223, 208, 7, 255, 176, 0, 13, 253, 5, 255, - 177, 0, 0, 223, 196, 255, 193, 0, 0, 13, 253, 239, 251, 0, 0, 0, 223, 255, 239, 247, 0, 0, 13, 255, - 145, 223, 244, 0, 0, 223, 208, 3, 255, 225, 0, 13, 253, 0, 7, 255, 176, 0, 223, 208, 0, 11, 255, 112, - 13, 253, 0, 0, 30, 255, 64, 223, 208, 0, 0, 79, 254, 16, 223, 221, 253, 223, 221, 253, 223, 221, 253, 223, - 221, 253, 223, 221, 253, 223, 221, 253, 223, 221, 253, 223, 221, 253, 223, 221, 253, 223, 208, 223, 96, 108, 238, 199, - 0, 24, 223, 236, 96, 13, 249, 175, 255, 255, 251, 45, 255, 255, 255, 144, 223, 255, 148, 55, 239, 254, 248, 67, - 143, 255, 61, 255, 144, 0, 6, 255, 246, 0, 0, 143, 247, 223, 243, 0, 0, 47, 254, 16, 0, 4, 255, 141, - 255, 0, 0, 1, 255, 192, 0, 0, 47, 249, 223, 224, 0, 0, 15, 251, 0, 0, 2, 255, 157, 253, 0, 0, - 0, 255, 176, 0, 0, 47, 249, 223, 208, 0, 0, 15, 251, 0, 0, 2, 255, 157, 253, 0, 0, 0, 255, 176, - 0, 0, 47, 249, 223, 208, 0, 0, 15, 251, 0, 0, 2, 255, 157, 253, 0, 0, 0, 255, 176, 0, 0, 47, - 249, 223, 208, 0, 0, 15, 251, 0, 0, 2, 255, 157, 253, 0, 0, 0, 255, 176, 0, 0, 47, 249, 223, 96, - 91, 239, 218, 48, 13, 249, 175, 255, 255, 255, 64, 223, 255, 181, 53, 191, 252, 13, 255, 160, 0, 0, 223, 242, - 223, 243, 0, 0, 9, 255, 77, 255, 0, 0, 0, 127, 244, 223, 224, 0, 0, 7, 255, 77, 253, 0, 0, 0, - 127, 244, 223, 208, 0, 0, 7, 255, 77, 253, 0, 0, 0, 127, 244, 223, 208, 0, 0, 7, 255, 77, 253, 0, - 0, 0, 127, 244, 223, 208, 0, 0, 7, 255, 77, 253, 0, 0, 0, 127, 244, 0, 3, 157, 238, 200, 32, 0, - 0, 127, 255, 255, 255, 229, 0, 6, 255, 230, 51, 126, 255, 48, 30, 255, 32, 0, 4, 255, 192, 95, 249, 0, - 0, 0, 191, 243, 143, 246, 0, 0, 0, 127, 246, 159, 244, 0, 0, 0, 111, 247, 159, 244, 0, 0, 0, 111, - 247, 127, 246, 0, 0, 0, 143, 246, 79, 250, 0, 0, 0, 207, 243, 13, 255, 32, 0, 4, 255, 192, 4, 255, - 230, 51, 126, 255, 64, 0, 110, 255, 255, 255, 245, 0, 0, 2, 141, 238, 216, 32, 0, 223, 112, 108, 239, 199, - 16, 13, 250, 175, 255, 255, 252, 16, 223, 255, 164, 53, 207, 251, 13, 255, 144, 0, 1, 239, 243, 223, 243, 0, - 0, 7, 255, 125, 255, 0, 0, 0, 79, 250, 223, 224, 0, 0, 2, 255, 189, 254, 0, 0, 0, 47, 251, 223, - 240, 0, 0, 4, 255, 157, 255, 48, 0, 0, 143, 247, 223, 250, 0, 0, 30, 255, 45, 255, 250, 67, 92, 255, - 160, 223, 203, 255, 255, 255, 193, 13, 253, 6, 206, 236, 112, 0, 223, 208, 0, 0, 0, 0, 13, 253, 0, 0, - 0, 0, 0, 223, 208, 0, 0, 0, 0, 13, 253, 0, 0, 0, 0, 0, 223, 208, 0, 0, 0, 0, 13, 253, - 0, 0, 0, 0, 0, 0, 6, 206, 236, 96, 95, 240, 11, 255, 255, 255, 184, 255, 8, 255, 214, 52, 159, 255, - 241, 255, 242, 0, 0, 127, 255, 95, 250, 0, 0, 1, 255, 248, 255, 96, 0, 0, 12, 255, 159, 244, 0, 0, - 0, 191, 249, 255, 64, 0, 0, 10, 255, 143, 245, 0, 0, 0, 191, 245, 255, 128, 0, 0, 14, 255, 31, 254, - 16, 0, 6, 255, 240, 159, 253, 83, 72, 255, 255, 1, 191, 255, 255, 251, 191, 240, 0, 124, 238, 199, 11, 255, - 0, 0, 0, 0, 0, 207, 240, 0, 0, 0, 0, 12, 255, 0, 0, 0, 0, 0, 207, 240, 0, 0, 0, 0, - 12, 255, 0, 0, 0, 0, 0, 207, 240, 0, 0, 0, 0, 12, 255, 223, 96, 59, 239, 157, 248, 95, 255, 247, - 223, 223, 231, 52, 45, 255, 209, 0, 0, 223, 245, 0, 0, 13, 255, 0, 0, 0, 223, 224, 0, 0, 13, 253, - 0, 0, 0, 223, 208, 0, 0, 13, 253, 0, 0, 0, 223, 208, 0, 0, 13, 253, 0, 0, 0, 223, 208, 0, - 0, 13, 253, 0, 0, 0, 0, 107, 223, 236, 147, 1, 207, 255, 255, 255, 225, 143, 250, 67, 71, 201, 10, 255, - 0, 0, 0, 0, 159, 246, 0, 0, 0, 3, 239, 252, 81, 0, 0, 3, 207, 255, 233, 32, 0, 0, 74, 255, - 254, 96, 0, 0, 1, 143, 255, 32, 0, 0, 0, 95, 246, 16, 0, 0, 4, 255, 107, 199, 67, 54, 223, 243, - 191, 255, 255, 255, 247, 3, 140, 239, 253, 164, 0, 0, 10, 243, 0, 0, 0, 31, 243, 0, 0, 0, 111, 243, - 0, 0, 41, 255, 255, 255, 243, 143, 255, 255, 255, 243, 19, 175, 245, 51, 48, 0, 159, 243, 0, 0, 0, 159, - 243, 0, 0, 0, 159, 243, 0, 0, 0, 159, 243, 0, 0, 0, 159, 243, 0, 0, 0, 159, 243, 0, 0, 0, - 159, 243, 0, 0, 0, 143, 245, 0, 0, 0, 95, 253, 83, 82, 0, 12, 255, 255, 245, 0, 1, 157, 254, 179, - 255, 192, 0, 0, 9, 255, 63, 252, 0, 0, 0, 159, 243, 255, 192, 0, 0, 9, 255, 63, 252, 0, 0, 0, - 159, 243, 255, 192, 0, 0, 9, 255, 63, 252, 0, 0, 0, 159, 243, 255, 192, 0, 0, 9, 255, 63, 252, 0, - 0, 0, 159, 243, 255, 192, 0, 0, 11, 255, 63, 253, 0, 0, 0, 239, 243, 223, 243, 0, 0, 127, 255, 57, - 255, 231, 69, 159, 255, 243, 29, 255, 255, 255, 214, 255, 48, 24, 223, 236, 129, 47, 243, 207, 242, 0, 0, 0, - 111, 248, 127, 247, 0, 0, 0, 191, 242, 31, 252, 0, 0, 2, 255, 176, 10, 255, 32, 0, 7, 255, 80, 4, - 255, 112, 0, 12, 254, 16, 0, 239, 208, 0, 47, 249, 0, 0, 143, 243, 0, 143, 243, 0, 0, 47, 248, 0, - 223, 192, 0, 0, 12, 253, 3, 255, 112, 0, 0, 6, 255, 56, 255, 16, 0, 0, 1, 255, 141, 250, 0, 0, - 0, 0, 175, 223, 244, 0, 0, 0, 0, 79, 255, 224, 0, 0, 0, 0, 13, 255, 128, 0, 0, 159, 243, 0, - 0, 47, 255, 32, 0, 3, 255, 133, 255, 112, 0, 7, 255, 247, 0, 0, 127, 244, 31, 251, 0, 0, 191, 239, - 176, 0, 11, 254, 0, 191, 224, 0, 31, 248, 255, 16, 1, 255, 176, 7, 255, 64, 5, 254, 31, 245, 0, 79, - 247, 0, 63, 247, 0, 159, 176, 207, 144, 8, 255, 32, 0, 239, 176, 14, 247, 8, 253, 0, 207, 208, 0, 10, - 255, 3, 255, 48, 79, 243, 31, 249, 0, 0, 111, 243, 127, 208, 0, 239, 116, 255, 80, 0, 1, 255, 123, 249, - 0, 10, 250, 143, 241, 0, 0, 12, 250, 239, 64, 0, 111, 235, 251, 0, 0, 0, 143, 239, 224, 0, 1, 255, - 239, 112, 0, 0, 4, 255, 250, 0, 0, 12, 255, 243, 0, 0, 0, 14, 255, 96, 0, 0, 143, 254, 0, 0, - 46, 254, 32, 0, 1, 223, 243, 6, 255, 176, 0, 9, 255, 112, 0, 175, 246, 0, 79, 252, 0, 0, 30, 254, - 33, 223, 226, 0, 0, 4, 255, 184, 255, 96, 0, 0, 0, 159, 255, 251, 0, 0, 0, 0, 29, 255, 225, 0, - 0, 0, 0, 46, 255, 243, 0, 0, 0, 0, 207, 254, 253, 16, 0, 0, 7, 255, 133, 255, 144, 0, 0, 63, - 252, 0, 175, 245, 0, 1, 223, 243, 0, 30, 254, 16, 9, 255, 112, 0, 5, 255, 160, 79, 252, 0, 0, 0, - 175, 246, 207, 242, 0, 0, 0, 111, 248, 95, 248, 0, 0, 0, 191, 242, 14, 253, 0, 0, 1, 255, 192, 8, - 255, 64, 0, 7, 255, 96, 2, 255, 144, 0, 12, 254, 16, 0, 191, 225, 0, 47, 249, 0, 0, 95, 245, 0, - 127, 244, 0, 0, 14, 251, 0, 223, 208, 0, 0, 8, 255, 19, 255, 112, 0, 0, 2, 255, 104, 255, 32, 0, - 0, 0, 191, 172, 251, 0, 0, 0, 0, 95, 239, 245, 0, 0, 0, 0, 14, 255, 224, 0, 0, 0, 0, 8, - 255, 144, 0, 0, 0, 0, 9, 255, 48, 0, 0, 0, 0, 30, 252, 0, 0, 0, 0, 0, 159, 245, 0, 0, - 0, 35, 73, 255, 192, 0, 0, 0, 143, 255, 254, 32, 0, 0, 0, 126, 253, 146, 0, 0, 0, 0, 9, 255, - 255, 255, 255, 244, 9, 255, 255, 255, 255, 244, 2, 51, 51, 53, 255, 209, 0, 0, 0, 12, 255, 48, 0, 0, - 0, 143, 246, 0, 0, 0, 4, 255, 176, 0, 0, 0, 29, 254, 16, 0, 0, 0, 175, 244, 0, 0, 0, 6, - 255, 128, 0, 0, 0, 46, 252, 0, 0, 0, 0, 207, 226, 0, 0, 0, 8, 255, 131, 51, 51, 49, 31, 255, - 255, 255, 255, 247, 31, 255, 255, 255, 255, 247, 0, 0, 4, 173, 241, 0, 0, 111, 255, 241, 0, 0, 239, 248, - 64, 0, 2, 255, 144, 0, 0, 3, 255, 96, 0, 0, 3, 255, 96, 0, 0, 3, 255, 96, 0, 0, 3, 255, - 96, 0, 0, 5, 255, 80, 0, 1, 93, 254, 16, 0, 111, 255, 179, 0, 0, 111, 253, 129, 0, 0, 20, 143, - 253, 0, 0, 0, 6, 255, 64, 0, 0, 3, 255, 96, 0, 0, 3, 255, 96, 0, 0, 3, 255, 96, 0, 0, - 3, 255, 96, 0, 0, 2, 255, 128, 0, 0, 1, 255, 229, 16, 0, 0, 143, 255, 241, 0, 0, 7, 223, 241, - 0, 0, 0, 1, 32, 239, 78, 244, 239, 78, 244, 239, 78, 244, 239, 78, 244, 239, 78, 244, 239, 78, 244, 239, - 78, 244, 239, 78, 244, 239, 78, 244, 239, 78, 244, 239, 78, 244, 239, 78, 244, 239, 64, 47, 218, 64, 0, 0, - 47, 255, 246, 0, 0, 4, 143, 254, 0, 0, 0, 9, 255, 32, 0, 0, 6, 255, 32, 0, 0, 6, 255, 32, - 0, 0, 6, 255, 32, 0, 0, 6, 255, 32, 0, 0, 5, 255, 80, 0, 0, 1, 239, 213, 16, 0, 0, 59, - 255, 245, 0, 0, 24, 223, 245, 0, 1, 223, 231, 65, 0, 5, 255, 96, 0, 0, 6, 255, 48, 0, 0, 6, - 255, 32, 0, 0, 6, 255, 32, 0, 0, 6, 255, 32, 0, 0, 8, 255, 32, 0, 1, 94, 254, 0, 0, 47, - 255, 247, 0, 0, 47, 252, 96, 0, 0, 2, 16, 0, 0, 0, 7, 223, 217, 48, 0, 2, 120, 255, 255, 255, - 182, 54, 233, 189, 83, 108, 255, 255, 255, 103, 16, 0, 4, 173, 252, 80, 10, 234, 0, 0, 174, 160, 0, 10, - 234, 3, 255, 244, 0, 63, 255, 64, 3, 255, 243, 63, 255, 64, 3, 255, 244, 0, 63, 255, 48, 174, 160, 0, - 10, 234, 0, 0, 174, 160, 10, 234, 3, 255, 244, 63, 255, 64, 174, 160, - ], -}; diff --git a/apps/v-maps/src/gesture.rs b/apps/v-maps/src/gesture.rs deleted file mode 100644 index ce31723..0000000 --- a/apps/v-maps/src/gesture.rs +++ /dev/null @@ -1,60 +0,0 @@ -//! What a touch was, from where the finger went down and came up. - -/// A touch that moved this far sideways (and mostly sideways) is a swipe. -pub const SWIPE_PX: i32 = 70; -/// A touch that stayed within this far is a tap or a hold. -pub const TAP_PX: i32 = 36; -/// A touch held this long (and still) switches between the map turning with you and the map held where it is. -pub const HOLD_MS: u32 = 600; - -#[derive(Clone, Copy, PartialEq, Eq, Debug)] -pub enum Gesture { - None, - Tap, - Hold, - SwipeRight, - SwipeLeft, -} - -/// `dx`, `dy`: how far the finger went from where it came down (right and down are positive); `held_ms`: for how long. -pub fn classify(dx: i32, dy: i32, held_ms: u32) -> Gesture { - let (ax, ay) = (dx.abs(), dy.abs()); - if ax >= SWIPE_PX && ax >= 2 * ay { - return if dx > 0 { Gesture::SwipeRight } else { Gesture::SwipeLeft }; - } - if ax.max(ay) <= TAP_PX { - return if held_ms >= HOLD_MS { Gesture::Hold } else { Gesture::Tap }; - } - Gesture::None -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn taps_holds_and_swipes() { - assert_eq!(classify(3, -4, 120), Gesture::Tap); - assert_eq!(classify(0, 0, 700), Gesture::Hold); - assert_eq!(classify(150, 20, 200), Gesture::SwipeRight); - assert_eq!(classify(-150, -30, 400), Gesture::SwipeLeft); - // a slow swipe is still a swipe, not a hold - assert_eq!(classify(120, 0, 1500), Gesture::SwipeRight); - } - - #[test] - fn a_diagonal_or_short_drag_is_nothing() { - assert_eq!(classify(100, 100, 200), Gesture::None); - assert_eq!(classify(100, -80, 200), Gesture::None); - assert_eq!(classify(50, 0, 200), Gesture::None); - assert_eq!(classify(0, 120, 200), Gesture::None); - } - - #[test] - fn the_edges_of_the_ranges() { - assert_eq!(classify(SWIPE_PX, 0, 100), Gesture::SwipeRight); - assert_eq!(classify(SWIPE_PX - 1, 0, 100), Gesture::None); - assert_eq!(classify(TAP_PX, 0, 100), Gesture::Tap); - assert_eq!(classify(TAP_PX + 1, 0, 100), Gesture::None); - } -} diff --git a/apps/v-maps/src/main.rs b/apps/v-maps/src/main.rs deleted file mode 100644 index f8d7024..0000000 --- a/apps/v-maps/src/main.rs +++ /dev/null @@ -1,361 +0,0 @@ -#![cfg_attr(any(target_os = "none", wp2_sim), no_main, cfg_attr(target_os = "none", no_std))] - -//! V-maps: shows the drive that the Vela maps app on the phone is navigating. Protocol: `proto.rs`. - -// the host build (tests) has no device loop, so some of the protocol is unused there -mod font; -mod gesture; -#[rustfmt::skip] -mod fonts; -mod proto; -mod sign; -mod view; - -#[cfg(not(any(target_os = "none", wp2_sim)))] -fn main() {} - -#[cfg(any(target_os = "none", wp2_sim))] -mod device { - use crate::gesture::{Gesture, classify}; - use crate::proto::{ASK, Effect, HOME, Model, WORK}; - use crate::view::{self, Choice, Ctx, ZOOMS}; - use cmf_wp2_app::{Api, BUTTON, MSG_MAX, PAUSE, RESUME, TOUCH_DOWN, TOUCH_UP}; - - cmf_wp2_app::entry!(main); - cmf_wp2_app::app_icon!(); - - /// Ask for a snapshot again this often while none comes. - const ASK_MS: u32 = 3000; - /// The phone sends the drive every second; after this long without one it is out of reach. - const STALE_MS: u32 = 6000; - /// Minimum gap between frames. The renderer now reuses one map transform per frame, making a 20 ms target - /// more realistic; actual frame rate remains bounded by the drawing time and loader. - const GAP_MS: u32 = 20; - /// Position glides over the GPS reporting interval. Kept independent from heading updates. - const POSITION_ANIM_MS: u32 = 1000; - /// Heading catches up between phone reports instead of sharing/restarting the position animation. - const HEADING_ANIM_MS: u32 = 240; - /// After the last frame of zooming or turning (drawn with cheaper hard-edged streets), this long later the - /// screen is drawn once more in full quality. - const SETTLE_MS: u32 = 300; - /// After Home or Work was pressed, this long for the phone's route to arrive before the watch gives up waiting. - const GOING_MS: u32 = 12_000; - /// A hint on the menu ("Open Vela on the phone") stays this long. - const NOTE_MS: u32 = 5000; - /// Between full frames the car moves on a cheap band-only frame; the text and the arc are refreshed this - /// often at most (they change in tens of metres). - const FULL_MS: u32 = 1000; - /// The phone already smooths its compass. Keep only a small watch-side deadband (about 0.35°) for jitter. - const HEADING_DEAD: i32 = 64; - /// The arrow is repainted only when it has turned this much (1.5 degrees). - const REPAINT: i32 = 273; - /// The most the heading on screen turns between two frames (22.5 degrees): after a slow frame the glide - /// catches up over several frames instead of jumping. - const MAX_TURN: i32 = 4096; - - /// What the text shows, to the precision they show it. - fn text_key(s: &crate::proto::State) -> [u32; 2] { - [s.dist_m as u32 / 10, s.remaining_s as u32 / 60] - } - - // 4 KiB of route: too big for the 8 KiB stack - static mut MODEL: Model = Model::new(); - - // true on RESUME, false on BUTTON - fn paused(api: &Api) -> bool { - loop { - match api.event(u32::MAX).map(|e| e.kind) { - Some(RESUME) => return true, - Some(BUTTON) => return false, - _ => {} - } - } - } - - fn main(api: &'static Api) -> i32 { - // SAFETY: the app has one thread and this is the only reference. - let m = unsafe { &mut *core::ptr::addr_of_mut!(MODEL) }; - let zoom = 0; // one zoom only: the closest (no zooming) - let mut want; - let mut asked: Option = None; - // asks so far without an answer: the gap doubles (3 s, 6 s ... 60 s) so a phone with no Vela hears almost nothing - let mut tries = 0u32; - let mut heard: Option = None; - let mut dirty = true; - let mut drawn_end = 0u32; - // Position and heading use separate animation clocks. A frequent GPS coordinate update must never - // restart an unfinished heading transition. - let mut shown_xy = (0i32, 0i32); - let (mut pos_from, mut pos_target, mut pos_last_raw) = (shown_xy, shown_xy, shown_xy); - let mut pos_t0 = 0u32; - let mut shown_heading = 0u16; - let (mut heading_from, mut heading_target, mut raw_heading_last) = (shown_heading, shown_heading, shown_heading); - let mut heading_t0 = 0u32; - let mut fresh = true; - let mut settle_at: Option = None; - let mut live = false; - // true: the arrow turns to where the phone looks and the map stays; false: the map turns, the arrow is up - let mut look = true; - // the way the map is turned while it is held still (north up at first); holding the screen freezes it where it is - let mut map_heading = 0u16; - // a touch: when and where the finger came down - let mut touch0: Option<(u32, i32, i32)> = None; - // the menu: swiped open during a drive (it is always there when there is no drive), the button under the finger, - // the button that was pressed while the phone's route is awaited (with when, and whether the old drive has - // ended), and a hint that Vela did not answer - let mut menu_open = false; - let mut menu_shown = false; - let mut menu_dirty = false; - let mut pressed: Option = None; - let mut going: Option<(Choice, u32, bool)> = None; - let mut note: Option = None; - let mut last_drawn_heading = 0u16; - let mut last_map_heading = 0u16; - let mut last_full = 0u32; - let mut stale = false; // the text or arc on screen is out of date - let mut drawn_at_xy = (i32::MIN, i32::MIN); - let mut screen_on = false; - loop { - let now = api.now(); - want = !m.synced; - if want && asked.is_none_or(|t| now.wrapping_sub(t) >= (ASK_MS << tries.min(4)).min(60_000)) { - api.send(&ASK); // -107 while Vela is not listening: asked again in 3 s - asked = Some(now); - tries += 1; - } - let is_live = heard.is_some_and(|t| now.wrapping_sub(t) < STALE_MS); - if is_live != live { - live = is_live; - dirty = true; - if !live { - (m.synced, asked) = (false, None); - m.reset_seq(); - } - } - let on = live && m.state.active(); - if on != screen_on { - screen_on = on; - api.keep_screen_on(on); - } - // The phone reports position and heading together, but they must not share an animation clock. - // Heading updates arrive more often and now animate independently between reports. - let raw = (m.state.x, m.state.y, m.state.course); - if !(live && m.state.active()) { - shown_xy = (raw.0, raw.1); - (pos_from, pos_target, pos_last_raw) = (shown_xy, shown_xy, shown_xy); - pos_t0 = now; - shown_heading = raw.2; - (heading_from, heading_target, raw_heading_last) = (raw.2, raw.2, raw.2); - heading_t0 = now; - fresh = true; - } else if fresh { - shown_xy = (raw.0, raw.1); - (pos_from, pos_target, pos_last_raw) = (shown_xy, shown_xy, shown_xy); - pos_t0 = now; - shown_heading = raw.2; - (heading_from, heading_target, raw_heading_last) = (raw.2, raw.2, raw.2); - heading_t0 = now; - fresh = false; - } else { - if (raw.0, raw.1) != pos_last_raw { - // Retarget from the current interpolated position, not from a stale frame or the old GPS fix. - let current = view::interpolate_position(pos_from, pos_target, now.wrapping_sub(pos_t0), POSITION_ANIM_MS); - let far = (raw.0 as i64 - current.0 as i64).abs() > 400 - || (raw.1 as i64 - current.1 as i64).abs() > 400; - pos_from = if far { (raw.0, raw.1) } else { current }; - pos_target = (raw.0, raw.1); - pos_last_raw = (raw.0, raw.1); - pos_t0 = now; - } - if raw.2 != raw_heading_last { - raw_heading_last = raw.2; - let d = heading_target.wrapping_sub(raw.2) as i16 as i32; - if d.abs() > HEADING_DEAD { - // Preserve the currently displayed heading when a newer compass sample arrives. - // This prevents the new sample from snapping or restarting the position animation. - // Start from the value actually shown on the previous frame. Using the ideal - // interpolation endpoint here would jump ahead if MAX_TURN had rate-limited it. - heading_from = shown_heading; - heading_target = raw.2; - heading_t0 = now; - } - } - } - shown_xy = view::interpolate_position(pos_from, pos_target, now.wrapping_sub(pos_t0), POSITION_ANIM_MS); - let before_heading = shown_heading; - shown_heading = view::interpolate_heading(heading_from, heading_target, now.wrapping_sub(heading_t0), HEADING_ANIM_MS); - shown_heading = view::limit_turn(before_heading, shown_heading, MAX_TURN); - let moving = shown_xy != pos_target || shown_heading != heading_target; - let gap = GAP_MS; - // the text in the dome is out of date: repaint just the dome, once a second at most - let dome = stale && !dirty && last_full != 0 && now.wrapping_sub(last_full) >= FULL_MS; - if settle_at.is_some_and(|t| now.wrapping_sub(t) as i32 >= 0) && !moving { - (dirty, settle_at) = (true, None); - } - // the menu: a still screen that takes the place of the map; nothing of the map is drawn meanwhile - if let Some((c, t0, mut left)) = going { - left |= !on; - going = if on && left { - menu_open = false; // the new drive is here - None - } else if now.wrapping_sub(t0) >= GOING_MS { - (menu_open, note, menu_dirty) = (on, Some(now), true); // the phone did not answer - None - } else { - Some((c, t0, left)) - }; - } - if note.is_some_and(|t| now.wrapping_sub(t) >= NOTE_MS) { - (note, menu_dirty) = (None, true); - } - let menu_screen = going.is_some() || menu_open || !on; - if menu_screen != menu_shown { - menu_shown = menu_screen; - // back to the map: it is drawn in full first (nothing of it is on the screen) - if menu_screen { menu_dirty = true } else { dirty = true } - (settle_at, last_full) = (None, 0); - } - let heading_moved = (shown_heading.wrapping_sub(last_drawn_heading) as i16 as i32).abs() >= REPAINT; - // with the map fixed, a change of heading alone repaints only the patch round the arrow - // has the map moved a whole pixel (or turned a quarter degree) since it was drawn? Less is the same picture - let mpp = ZOOMS[zoom.min(ZOOMS.len() - 1)]; - let shifted = (shown_xy.0 - drawn_at_xy.0).abs().max((shown_xy.1 - drawn_at_xy.1).abs()) >= mpp - || (!look && (shown_heading.wrapping_sub(last_map_heading) as i16 as i32).abs() >= 36); - let arrow_only = look && !dirty && !dome && !shifted && heading_moved; - // a moving car repaints the screen in the cheap style, when it would look different - let light = !dirty && !dome && !arrow_only && shifted && last_full != 0; - if menu_screen { - if (dirty || menu_dirty) && now.wrapping_sub(drawn_end) >= gap { - let mut screen = api; - if let Some((c, _, _)) = going { - view::going(&mut screen, c); - } else { - let title = if note.is_some() { - "Open Vela on the phone" - } else if !live { - "Waiting for Vela…" - } else if !on { - "Start a destination" - } else { - "Go to" - }; - view::menu(&mut screen, title, if menu_open && on { "Swipe left to go back" } else { "" }, pressed); - } - api.show(); - (dirty, menu_dirty, drawn_end, last_full) = (false, false, api.now(), 0); - continue; - } - } else if (dirty || dome || arrow_only || light) && now.wrapping_sub(drawn_end) >= gap { - let mut screen = api; - (m.state.x, m.state.y, m.state.course) = (shown_xy.0, shown_xy.1, shown_heading); - if look { - m.state.course = map_heading; - } - let fast = !arrow_only && !dome && moving; - let ctx = Ctx { live, zoom, fast, look: look.then_some(shown_heading.wrapping_sub(map_heading)), arrow_only, light, dome }; - view::draw(&mut screen, m, &ctx); - (m.state.x, m.state.y, m.state.course) = raw; - api.show(); - let end = api.now(); - (dirty, drawn_end) = (false, end); - if dome { - // the dome is fresh; the map and the arrow were not touched - (last_full, stale) = (end.max(1), false); - continue; - } - last_drawn_heading = shown_heading; - if !arrow_only { - (drawn_at_xy, last_map_heading) = (shown_xy, shown_heading); - } - if !arrow_only && !light { - (last_full, stale) = (end.max(1), false); - } - settle_at = (fast || light).then(|| end.wrapping_add(SETTLE_MS)); - continue; - } - let mut wait = if dirty || menu_dirty || moving || stale { gap.saturating_sub(now.wrapping_sub(drawn_end)).max(1) } else { 1000 }; - if let Some(t) = settle_at { - wait = wait.min((t.wrapping_sub(now) as i32).max(1) as u32); - } - let mut ev = api.event(wait); - // everything that is already waiting is handled before the next frame: several crown clicks are one - // zoom change, not one frame each - while let Some(e) = ev { - match e { - e if e.kind == BUTTON => return 0, - e if e.kind == TOUCH_DOWN => { - touch0 = Some((api.now(), e.x as i32, e.y as i32)); - if menu_screen && going.is_none() { - pressed = view::button_at(e.x as i32, e.y as i32); - menu_dirty = pressed.is_some(); - } - } - e if e.kind == TOUCH_UP => { - let Some((t, x0, y0)) = touch0.take() else { continue }; - let down = pressed.take(); - menu_dirty |= down.is_some(); // the button lets go - match classify(e.x as i32 - x0, e.y as i32 - y0, api.now().wrapping_sub(t)) { - Gesture::SwipeRight if !menu_screen => (menu_open, menu_dirty) = (true, true), - Gesture::SwipeLeft if menu_open && going.is_none() => (menu_open, dirty) = (false, true), - Gesture::Tap if menu_screen && going.is_none() => { - if let Some(c) = down.filter(|&c| view::button_at(e.x as i32, e.y as i32) == Some(c)) { - if api.send(if c == Choice::Home { &HOME } else { &WORK }) < 0 { - (note, menu_dirty) = (Some(api.now()), true); // Vela is not listening - } else { - (going, menu_open, menu_dirty) = (Some((c, api.now(), !on)), false, true); - } - } - } - Gesture::Hold if !menu_screen => { - look = !look; - if look { - map_heading = shown_heading; // hold the map as it is turned now - } - dirty = true; - } - _ => {} - } - } - e if e.kind == PAUSE => { - (screen_on, touch0, pressed) = (false, None, None); - if !paused(api) { - return 0; - } - // messages were refused meanwhile - (m.synced, asked, dirty) = (false, None, true); - m.reset_seq(); - } - _ => {} - } - ev = api.event(0); - } - let mut buf = [0u8; MSG_MAX]; - while let Some(msg) = api.recv(&mut buf) { - let before = m.state; - match m.apply(msg) { - Effect::Ignored => continue, - // a drive state: the car's own movement is glided in the loop above; a new manoeuvre, route - // state or the like is drawn at once, a changed distance or time within a second - Effect::Changed if msg.get(2) == Some(&b'S') => { - let (a, b) = (before, m.state); - if (a.flags, a.maneuver) != (b.flags, b.maneuver) { - dirty = true; - } else if text_key(&a) != text_key(&b) { - stale = true; - } - } - Effect::Changed => dirty = true, - Effect::Resync => { - dirty = true; - if !want { - asked = None; // ask right away - } - } - } - heard = Some(api.now()); - tries = 0; - want = !m.synced; - } - } - } -} diff --git a/apps/v-maps/src/proto.rs b/apps/v-maps/src/proto.rs deleted file mode 100644 index 8d892bd..0000000 --- a/apps/v-maps/src/proto.rs +++ /dev/null @@ -1,741 +0,0 @@ -//! The Vela ↔ watch protocol and the navigation model it fills. Pure: no `Api`, so `make test` covers it. -//! -//! Every message starts with the magic `n1`. Phone → watch messages then carry a kind byte and a `seq` byte that -//! counts every phone message (wrapping); a gap makes the watch ask for a snapshot again. All numbers are -//! little-endian. -//! -//! | Kind | Body | Meaning | -//! |---|---|---| -//! | `S` | flags u8, maneuver u8, dist u16 m, after u8, after dist u16 m, remaining u16 (10 m), remaining u16 s, limit u8, x i32 m, y i32 m, course u16, progress u16 | the drive, about once a second | -//! | `T` | UTF-8, ≤ 100 B | the road being entered (or the destination on arrival) | -//! | `B` | id u8, count u16, scale u8 (m per unit) | a new route line begins | -//! | `R` | id u8, start u16, n u8, n × (x i16, y i16) | route points `start..start+n`, n ≤ 30 | -//! | `E` | id u8, count u16 | the route line is complete | -//! | `N` | id u8, lines u8, scale u8, centre x i32, centre y i32 | nearby-road context begins | -//! | `G` | id u8, line u8, start u8, n u8, n × (x i16, y i16) | nearby-road points, n ≤ 28 | -//! | `O` | id u8, lines u8, points u16 | nearby-road context is complete | -//! -//! Nearby-road points are local metre offsets from the phone fix at the time of collection. The `N` centre is -//! that fix in the route's coordinate frame. This keeps the BLE channel free of latitude/longitude. -//! -//! Watch → phone: `n1Q`, "send me everything" (on start, after a gap, after `RESUME`, and while nothing arrives); -//! `n1H` and `n1W`, "take me Home" and "take me to Work". -//! -//! Positions are metres east (`x`) and north (`y`) of an origin the phone picks per drive, never latitude and -//! longitude: the channel can be read by anyone in Bluetooth range. `course` is the heading in 1/65536 turns -//! clockwise from north. `progress` is the index of the first route point still ahead of the car. - -pub const ASK: [u8; 3] = *b"n1Q"; -/// Watch → phone: "navigate to Home" and "to Work" (the places saved in Vela). A drive that is on is ended first. -pub const HOME: [u8; 3] = *b"n1H"; -pub const WORK: [u8; 3] = *b"n1W"; -pub const ROUTE_MAX: usize = 512; -pub const TEXT_MAX: usize = 100; -pub const CHUNK_MAX: usize = 30; -pub const ROADS_POINTS_MAX: usize = 480; -pub const ROADS_LINES_MAX: usize = 40; -pub const ROADS_CHUNK_MAX: usize = 28; - -pub const F_ACTIVE: u8 = 1 << 0; -pub const F_ARRIVED: u8 = 1 << 1; -pub const F_IMPERIAL: u8 = 1 << 3; -pub const F_FIX: u8 = 1 << 4; -/// This state ends the snapshot the watch asked for with `n1Q`: everything before it in the run is current. -pub const F_SNAPSHOT: u8 = 1 << 6; - -/// Maneuver codes, the same numbers as Vela's `DeviceManeuver`. -pub mod man { - pub const CONTINUE: u8 = 1; - pub const SLIGHT_LEFT: u8 = 2; - pub const LEFT: u8 = 3; - pub const SHARP_LEFT: u8 = 4; - pub const SLIGHT_RIGHT: u8 = 5; - pub const RIGHT: u8 = 6; - pub const SHARP_RIGHT: u8 = 7; - pub const KEEP_LEFT: u8 = 8; - pub const KEEP_RIGHT: u8 = 9; - pub const UTURN: u8 = 10; - pub const ROUNDABOUT: u8 = 11; - pub const OFF_ROUTE: u8 = 12; - pub const ARRIVE: u8 = 13; -} - -#[derive(Clone, Copy, Default, PartialEq, Debug)] -pub struct State { - pub flags: u8, - pub maneuver: u8, - pub dist_m: u16, - pub after: u8, - pub after_m: u16, - pub remaining_10m: u16, - pub remaining_s: u16, - pub limit: u8, - pub x: i32, - pub y: i32, - pub course: u16, - pub progress: u16, -} - -impl State { - pub fn active(&self) -> bool { - self.flags & F_ACTIVE != 0 - } - pub fn arrived(&self) -> bool { - self.flags & F_ARRIVED != 0 - } - pub fn imperial(&self) -> bool { - self.flags & F_IMPERIAL != 0 - } - pub fn fix(&self) -> bool { - self.flags & F_FIX != 0 - } -} - -/// What a message did to the model. -#[derive(Clone, Copy, PartialEq, Debug)] -pub enum Effect { - /// Not ours or malformed: ignored. - Ignored, - /// Applied; the screen is out of date. - Changed, - /// Messages were lost: ask the phone for a snapshot (`ASK`). - Resync, -} - -pub struct Model { - pub state: State, - /// A state arrived since the last `reset` (the screen shows "waiting" until then). - pub has_state: bool, - /// A state with `F_SNAPSHOT` arrived after the last gap: the watch has everything. - pub synced: bool, - text: [u8; TEXT_MAX], - text_len: usize, - pub route: [[i32; 2]; ROUTE_MAX], - /// Points of a complete route line; 0 while none (or while a new one arrives). - pub route_len: usize, - route_id: Option, - route_count: usize, - route_got: usize, - route_scale: i32, - /// Nearby roads as local offsets from `roads_center`, with one start and length per polyline. - pub roads: [[i16; 2]; ROADS_POINTS_MAX], - pub roads_len: usize, - pub roads_starts: [u16; ROADS_LINES_MAX], - pub roads_sizes: [u8; ROADS_LINES_MAX], - pub roads_count: usize, - pub roads_center: [i32; 2], - // a set being received: the streets already shown stay until the whole new set has arrived - stage: [[i16; 2]; ROADS_POINTS_MAX], - stage_len: usize, - stage_starts: [u16; ROADS_LINES_MAX], - stage_sizes: [u8; ROADS_LINES_MAX], - stage_center: [i32; 2], - /// One bit per street segment (by the index of its first point): the segment lies along the route, which - /// is drawn over it, so it is not drawn. Worked out once per street set, not per frame. - hidden: [u32; ROADS_POINTS_MAX.div_ceil(32)], - roads_id: Option, - roads_expected: usize, - roads_got: usize, - roads_points_expected: usize, - last_seq: Option, -} - -fn u16_at(b: &[u8], i: usize) -> u16 { - u16::from_le_bytes([b[i], b[i + 1]]) -} -fn i16_at(b: &[u8], i: usize) -> i16 { - i16::from_le_bytes([b[i], b[i + 1]]) -} -fn i32_at(b: &[u8], i: usize) -> i32 { - i32::from_le_bytes([b[i], b[i + 1], b[i + 2], b[i + 3]]) -} - -impl Model { - pub const fn new() -> Model { - Model { - state: State { - flags: 0, - maneuver: 0, - dist_m: 0, - after: 0, - after_m: 0, - remaining_10m: 0, - remaining_s: 0, - limit: 0, - x: 0, - y: 0, - course: 0, - progress: 0, - }, - has_state: false, - synced: false, - text: [0; TEXT_MAX], - text_len: 0, - route: [[0; 2]; ROUTE_MAX], - route_len: 0, - route_id: None, - route_count: 0, - route_got: 0, - route_scale: 1, - roads: [[0; 2]; ROADS_POINTS_MAX], - roads_len: 0, - roads_starts: [0; ROADS_LINES_MAX], - roads_sizes: [0; ROADS_LINES_MAX], - roads_count: 0, - roads_center: [0; 2], - stage: [[0; 2]; ROADS_POINTS_MAX], - stage_len: 0, - stage_starts: [0; ROADS_LINES_MAX], - stage_sizes: [0; ROADS_LINES_MAX], - stage_center: [0; 2], - hidden: [0; ROADS_POINTS_MAX.div_ceil(32)], - roads_id: None, - roads_expected: 0, - roads_got: 0, - roads_points_expected: 0, - last_seq: None, - } - } - - /// Forget the sequence (after a pause or a resync request): the next message starts a new run. - pub fn reset_seq(&mut self) { - self.last_seq = None; - } - - /// The road line, cut on a character boundary. - pub fn text(&self) -> &str { - cmf_wp2_ui::text::fit(&self.text[..self.text_len], TEXT_MAX) - } - - pub fn apply(&mut self, m: &[u8]) -> Effect { - let [b'n', b'1', kind, seq, body @ ..] = m else { - return Effect::Ignored; - }; - let gap = self.last_seq.is_some_and(|l| *seq != l.wrapping_add(1)); - self.last_seq = Some(*seq); - if gap { - self.synced = false; - } - let applied = match kind { - b'S' => self.on_state(body), - b'T' => self.on_text(body), - b'B' => self.on_begin(body), - b'R' => self.on_points(body), - b'E' => self.on_end(body), - b'N' => self.on_roads_begin(body), - b'G' => self.on_roads_points(body), - b'O' => self.on_roads_end(body), - _ => Some(false), - }; - match applied { - None => { - self.synced = false; - Effect::Resync - } - Some(_) if gap => Effect::Resync, - Some(true) => Effect::Changed, - Some(false) => Effect::Ignored, - } - } - - // Each handler: Some(true) applied, Some(false) malformed (ignored), None the route broke (resync). - - fn on_state(&mut self, b: &[u8]) -> Option { - if b.len() < 24 { - return Some(false); - } - self.state = State { - flags: b[0], - maneuver: b[1], - dist_m: u16_at(b, 2), - after: b[4], - after_m: u16_at(b, 5), - remaining_10m: u16_at(b, 7), - remaining_s: u16_at(b, 9), - limit: b[11], - x: i32_at(b, 12), - y: i32_at(b, 16), - course: u16_at(b, 20), - progress: u16_at(b, 22), - }; - self.has_state = true; - if self.state.flags & F_SNAPSHOT != 0 { - self.synced = true; - } - if !self.state.active() { - // no drive: drop the line so a later drive never shows the previous one - self.route_len = 0; - self.route_id = None; - self.roads_len = 0; - self.roads_count = 0; - self.roads_id = None; - } - Some(true) - } - - fn on_text(&mut self, b: &[u8]) -> Option { - let t = cmf_wp2_ui::text::fit(b, TEXT_MAX); - self.text[..t.len()].copy_from_slice(t.as_bytes()); - self.text_len = t.len(); - Some(true) - } - - fn on_begin(&mut self, b: &[u8]) -> Option { - if b.len() < 4 { - return Some(false); - } - let count = u16_at(b, 1) as usize; - if count > ROUTE_MAX || b[3] == 0 { - return Some(false); - } - (self.route_id, self.route_count, self.route_got, self.route_scale) = (Some(b[0]), count, 0, b[3] as i32); - self.route_len = 0; - Some(true) - } - - fn on_points(&mut self, b: &[u8]) -> Option { - if b.len() < 4 { - return Some(false); - } - let (id, start, n) = (b[0], u16_at(b, 1) as usize, b[3] as usize); - if self.route_id != Some(id) { - self.route_len = 0; // a chunk of a line whose begin we missed: the line shown is old - return None; - } - if b.len() < 4 + 4 * n || n > CHUNK_MAX || start != self.route_got || start + n > self.route_count { - self.route_id = None; - return None; - } - for i in 0..n { - let at = 4 + 4 * i; - self.route[start + i] = - [i16_at(b, at) as i32 * self.route_scale, i16_at(b, at + 2) as i32 * self.route_scale]; - } - self.route_got += n; - Some(false) // nothing to show until the end - } - - fn on_end(&mut self, b: &[u8]) -> Option { - if b.len() < 3 { - return Some(false); - } - if self.route_id != Some(b[0]) || u16_at(b, 1) as usize != self.route_got || self.route_got != self.route_count - { - self.route_id = None; - return None; - } - self.route_len = self.route_got; - self.hide_under_route(); - Some(true) - } - - fn on_roads_begin(&mut self, b: &[u8]) -> Option { - if b.len() < 11 { - return Some(false); - } - let lines = b[1] as usize; - let scale = b[2] as i32; - if lines > ROADS_LINES_MAX || scale != 1 { - return Some(false); - } - self.roads_id = Some(b[0]); - self.roads_expected = lines; - self.roads_got = 0; - self.roads_points_expected = 0; - self.stage_len = 0; - self.stage_center = [i32_at(b, 3), i32_at(b, 7)]; - self.stage_starts = [0; ROADS_LINES_MAX]; - self.stage_sizes = [0; ROADS_LINES_MAX]; - Some(true) - } - - fn on_roads_points(&mut self, b: &[u8]) -> Option { - if b.len() < 4 { - return Some(false); - } - let (id, line, start, n) = (b[0], b[1] as usize, b[2] as usize, b[3] as usize); - if self.roads_id != Some(id) || line >= self.roads_expected { - self.roads_id = None; - return None; - } - if n == 0 || n > ROADS_CHUNK_MAX || b.len() < 4 + n * 4 - || start != self.stage_sizes[line] as usize - || self.stage_len + n > ROADS_POINTS_MAX - || start + n > u8::MAX as usize - { - self.roads_id = None; - return None; - } - if start == 0 { - self.stage_starts[line] = self.stage_len as u16; - self.roads_got += 1; - } - for i in 0..n { - let at = 4 + i * 4; - self.stage[self.stage_len + i] = [i16_at(b, at), i16_at(b, at + 2)]; - } - self.stage_len += n; - self.stage_sizes[line] = (start + n) as u8; - self.roads_points_expected += n; - Some(false) - } - - fn on_roads_end(&mut self, b: &[u8]) -> Option { - if b.len() < 4 { - return Some(false); - } - let (id, lines, points) = (b[0], b[1] as usize, u16_at(b, 2) as usize); - if self.roads_id != Some(id) || lines != self.roads_expected || self.roads_got != lines - || points != self.stage_len || points != self.roads_points_expected - || self.stage_sizes[..lines].iter().any(|n| *n < 2) - { - self.roads_id = None; - return None; - } - // the new set is whole: swap it in at once, the old streets stay on screen until this moment - self.roads_len = self.stage_len; - self.roads_center = self.stage_center; - self.roads_starts = self.stage_starts; - self.roads_sizes = self.stage_sizes; - let n = self.stage_len; - self.roads[..n].copy_from_slice(&self.stage[..n]); - self.roads_count = lines; - self.roads_id = None; - self.hide_under_route(); - Some(true) - } - /// Whether the street segment starting at point `i` lies along the route (see `hidden`). - pub fn under_route(&self, i: usize) -> bool { - self.route_len >= 2 && self.hidden.get(i / 32).is_some_and(|w| w >> (i % 32) & 1 != 0) - } - - /// Marks every street segment that lies within `UNDER_M` of the route, all of it: both ends and the middle. - /// Each street line only meets the route segments whose box overlaps its own, so this stays cheap. - fn hide_under_route(&mut self) { - self.hidden = [0; ROADS_POINTS_MAX.div_ceil(32)]; - if self.route_len < 2 || self.roads_count == 0 { - return; - } - let route = &self.route[..self.route_len]; - let at = |i: usize| [self.roads_center[0] + self.roads[i][0] as i32, self.roads_center[1] + self.roads[i][1] as i32]; - for l in 0..self.roads_count.min(ROADS_LINES_MAX) { - let start = self.roads_starts[l] as usize; - let end = (start + self.roads_sizes[l] as usize).min(self.roads_len); - if end < start + 2 { - continue; - } - let (mut lo, mut hi) = (at(start), at(start)); - for i in start..end { - let p = at(i); - (lo, hi) = ([lo[0].min(p[0]), lo[1].min(p[1])], [hi[0].max(p[0]), hi[1].max(p[1])]); - } - let (lo, hi) = ([lo[0] - UNDER_M, lo[1] - UNDER_M], [hi[0] + UNDER_M, hi[1] + UNDER_M]); - let meets = |w: &[[i32; 2]]| { - w[0][0].max(w[1][0]) >= lo[0] && w[0][0].min(w[1][0]) <= hi[0] - && w[0][1].max(w[1][1]) >= lo[1] && w[0][1].min(w[1][1]) <= hi[1] - }; - let near = |p: [i32; 2]| route.windows(2).any(|w| meets(w) && seg_dist2(p, w[0], w[1]) <= (UNDER_M * UNDER_M) as i64); - for i in start..end - 1 { - let (a, b) = (at(i), at(i + 1)); - let mid = [(a[0] + b[0]) / 2, (a[1] + b[1]) / 2]; - if near(a) && near(b) && near(mid) { - self.hidden[i / 32] |= 1 << (i % 32); - } - } - } - } -} - -/// How close to the route a street must be to be hidden under it (the route line is 16 px wide: 8 m at the -/// closest zoom). -const UNDER_M: i32 = 5; - -/// Squared distance from `p` to the segment `a`..`b`. -fn seg_dist2(p: [i32; 2], a: [i32; 2], b: [i32; 2]) -> i64 { - let (px, py, ax, ay) = (p[0] as i64, p[1] as i64, a[0] as i64, a[1] as i64); - let (dx, dy) = (b[0] as i64 - ax, b[1] as i64 - ay); - let len2 = dx * dx + dy * dy; - let t = if len2 == 0 { 0 } else { (((px - ax) * dx + (py - ay) * dy) * 1024 / len2).clamp(0, 1024) }; - let (cx, cy) = (ax + dx * t / 1024, ay + dy * t / 1024); - (px - cx) * (px - cx) + (py - cy) * (py - cy) -} - -impl Default for Model { - fn default() -> Self { - Model::new() - } -} - -#[cfg(test)] -pub mod enc { - //! The phone side, for tests: what Vela's encoder must produce. - use super::*; - use std::vec::Vec; - - pub fn msg(kind: u8, seq: u8, body: &[u8]) -> Vec { - let mut v = vec![b'n', b'1', kind, seq]; - v.extend_from_slice(body); - assert!(v.len() <= 128); - v - } - - pub fn state(seq: u8, s: &State) -> Vec { - let mut b = vec![s.flags, s.maneuver]; - b.extend(s.dist_m.to_le_bytes()); - b.push(s.after); - b.extend(s.after_m.to_le_bytes()); - b.extend(s.remaining_10m.to_le_bytes()); - b.extend(s.remaining_s.to_le_bytes()); - b.push(s.limit); - b.extend(s.x.to_le_bytes()); - b.extend(s.y.to_le_bytes()); - b.extend(s.course.to_le_bytes()); - b.extend(s.progress.to_le_bytes()); - msg(b'S', seq, &b) - } - - /// Begin, chunks and end for a line of points in metres; returns the messages and the next seq. - pub fn route(mut seq: u8, id: u8, pts: &[[i32; 2]]) -> (Vec>, u8) { - let max = pts.iter().flat_map(|p| p.iter()).map(|v| v.abs()).max().unwrap_or(0); - let scale = (max / i16::MAX as i32 + 1) as u8; - let mut out = Vec::new(); - let n = (pts.len() as u16).to_le_bytes(); - out.push(msg(b'B', seq, &[id, n[0], n[1], scale])); - seq = seq.wrapping_add(1); - for (c, chunk) in pts.chunks(CHUNK_MAX).enumerate() { - let start = ((c * CHUNK_MAX) as u16).to_le_bytes(); - let mut b = vec![id, start[0], start[1], chunk.len() as u8]; - for p in chunk { - b.extend(((p[0] / scale as i32) as i16).to_le_bytes()); - b.extend(((p[1] / scale as i32) as i16).to_le_bytes()); - } - out.push(msg(b'R', seq, &b)); - seq = seq.wrapping_add(1); - } - out.push(msg(b'E', seq, &[id, n[0], n[1]])); - (out, seq.wrapping_add(1)) - } - - - /// Nearby road context, local offsets from the supplied centre. Each polyline is independent. - pub fn roads(mut seq: u8, id: u8, centre: [i32; 2], lines: &[Vec<[i16; 2]>]) -> (Vec>, u8) { - let safe: Vec<&Vec<[i16; 2]>> = lines.iter().filter(|l| l.len() >= 2 && l.len() <= 255).take(ROADS_LINES_MAX).collect(); - let mut out = Vec::new(); - let mut begin = vec![id, safe.len() as u8, 1]; - begin.extend(centre[0].to_le_bytes()); - begin.extend(centre[1].to_le_bytes()); - out.push(msg(b'N', seq, &begin)); - seq = seq.wrapping_add(1); - let mut total = 0usize; - for (line_idx, line) in safe.iter().enumerate() { - for (chunk_idx, chunk) in line.chunks(ROADS_CHUNK_MAX).enumerate() { - let start = chunk_idx * ROADS_CHUNK_MAX; - let mut b = vec![id, line_idx as u8, start as u8, chunk.len() as u8]; - for p in chunk { - b.extend(p[0].to_le_bytes()); - b.extend(p[1].to_le_bytes()); - } - out.push(msg(b'G', seq, &b)); - seq = seq.wrapping_add(1); - total += chunk.len(); - } - } - let mut end = vec![id, safe.len() as u8]; - end.extend((total as u16).to_le_bytes()); - out.push(msg(b'O', seq, &end)); - (out, seq.wrapping_add(1)) - } -} - -#[cfg(test)] -mod tests { - use super::enc::*; - use super::*; - use std::boxed::Box; - - fn active() -> State { - State { - flags: F_ACTIVE | F_FIX, - maneuver: man::LEFT, - dist_m: 350, - x: -12, - y: 40000, - course: 16384, - ..State::default() - } - } - - #[test] - fn state_round_trips() { - let mut m = Box::new(Model::new()); - let s = State { - limit: 50, - remaining_10m: 820, - remaining_s: 840, - after: man::RIGHT, - after_m: 90, - progress: 7, - ..active() - }; - assert_eq!(m.apply(&state(0, &s)), Effect::Changed); - assert_eq!(m.state, s); - assert!(m.has_state); - } - - #[test] - fn route_is_shown_only_when_complete() { - let mut m = Box::new(Model::new()); - let pts: std::vec::Vec<[i32; 2]> = (0..100).map(|i| [i * 37 - 2000, i * i * 9]).collect(); - let (msgs, _) = route(0, 3, &pts); - assert_eq!(msgs.len(), 1 + 4 + 1); - for (i, msg) in msgs.iter().enumerate() { - m.apply(msg); - assert_eq!(m.route_len, if i + 1 == msgs.len() { 100 } else { 0 }); - } - // max |v| is 89100 m, so scale 3: points come back within 3 m - for (a, b) in m.route[..100].iter().zip(&pts) { - assert!((a[0] - b[0]).abs() < 3 && (a[1] - b[1]).abs() < 3, "{a:?} {b:?}"); - } - } - - #[test] - fn a_lost_chunk_asks_again_and_shows_no_line() { - let mut m = Box::new(Model::new()); - let pts: std::vec::Vec<[i32; 2]> = (0..90).map(|i| [i, -i]).collect(); - let (msgs, _) = route(10, 1, &pts); - assert_eq!(m.apply(&msgs[0]), Effect::Changed); - assert_eq!(m.apply(&msgs[1]), Effect::Ignored); - assert_eq!(m.apply(&msgs[3]), Effect::Resync); // chunk 2 lost - assert_eq!(m.apply(&msgs[4]), Effect::Resync); - assert_eq!(m.route_len, 0); - } - - #[test] - fn seq_gap_and_wrap() { - let mut m = Box::new(Model::new()); - assert_eq!(m.apply(&state(255, &active())), Effect::Changed); - assert_eq!(m.apply(&state(0, &active())), Effect::Changed); - assert_eq!(m.apply(&state(2, &active())), Effect::Resync); - m.reset_seq(); - assert_eq!(m.apply(&state(9, &active())), Effect::Changed); - } - - #[test] - fn synced_only_by_a_snapshot_end() { - let mut m = Box::new(Model::new()); - m.apply(&state(0, &active())); - assert!(!m.synced); - m.apply(&state(1, &State { flags: active().flags | F_SNAPSHOT, ..active() })); - assert!(m.synced); - m.apply(&state(5, &active())); // gap - assert!(!m.synced); - } - - #[test] - fn ending_the_drive_drops_the_line() { - let mut m = Box::new(Model::new()); - let (msgs, seq) = route(0, 1, &[[0, 0], [10, 10]]); - msgs.iter().for_each(|x| { - m.apply(x); - }); - assert_eq!(m.route_len, 2); - m.apply(&state(seq, &State::default())); - assert_eq!(m.route_len, 0); - } - - #[test] - fn streets_along_the_route_are_hidden_and_crossings_are_not() { - let mut m = Box::new(Model::new()); - let (r, seq) = route(0, 1, &[[0, 0], [0, 200], [0, 400]]); - for msg in r { m.apply(&msg); } - // a street 2 m beside the route (along it), one 30 m away (parallel), and one crossing it - let lines = vec![ - vec![[2, 50], [2, 150], [2, 250]], - vec![[30, 50], [30, 150]], - vec![[-100, 100], [0, 100], [100, 100]], - ]; - let (s, _) = roads(seq, 1, [0, 0], &lines); - for msg in s { m.apply(&msg); } - // points: line 0 = 0..3, line 1 = 3..5, line 2 = 5..8 - assert!(m.under_route(0) && m.under_route(1), "along the route"); - assert!(!m.under_route(3), "30 m away"); - assert!(!m.under_route(5) && !m.under_route(6), "a crossing street"); - } - - #[test] - fn the_old_streets_stay_until_the_new_set_is_whole() { - let mut m = Box::new(Model::new()); - let (a, seq) = roads(0, 1, [10, 20], &[vec![[0, 0], [50, 50]]]); - for msg in a { m.apply(&msg); } - let (b, _) = roads(seq, 2, [900, 900], &[vec![[1, 1], [2, 2], [3, 3]], vec![[5, 5], [6, 6]]]); - let last = b.len() - 1; - for msg in &b[..last] { - m.apply(msg); - assert_eq!((m.roads_count, m.roads_len, m.roads_center), (1, 2, [10, 20]), "old set still shown"); - } - m.apply(&b[last]); - assert_eq!((m.roads_count, m.roads_len, m.roads_center), (2, 5, [900, 900])); - assert_eq!(m.roads[4], [6, 6]); - } - - #[test] - fn nearby_roads_round_trip_as_separate_lines() { - let mut m = Box::new(Model::new()); - let lines = vec![ - vec![[0, 0], [120, 80], [240, 160]], - vec![[-150, 300], [-100, 350]], - ]; - let (msgs, _) = roads(0, 7, [1200, -3400], &lines); - for msg in msgs { m.apply(&msg); } - assert_eq!(m.roads_count, 2); - assert_eq!(m.roads_len, 5); - assert_eq!(m.roads_center, [1200, -3400]); - assert_eq!(m.roads_sizes[0], 3); - assert_eq!(m.roads_sizes[1], 2); - assert_eq!(m.roads[0], [0, 0]); - assert_eq!(m.roads[4], [-100, 350]); - } - - #[test] - fn empty_road_snapshot_clears_context() { - let mut m = Box::new(Model::new()); - let lines = vec![vec![[0, 0], [100, 100]]]; - let (msgs, seq) = roads(0, 1, [0, 0], &lines); - for msg in msgs { m.apply(&msg); } - assert_eq!(m.roads_count, 1); - let (clear, _) = roads(seq, 2, [0, 0], &[]); - for msg in clear { m.apply(&msg); } - assert_eq!(m.roads_count, 0); - assert_eq!(m.roads_len, 0); - } - - #[test] - fn junk_is_ignored() { - let mut m = Box::new(Model::new()); - for junk in [ - &b""[..], - b"n", - b"x1S\x00", - b"n1S\x00\x01", - b"n1Z\x00abc", - b"n1B\x00\x01\xff\xff\x01", - b"n1B\x00\x01\x02\x00\x00", - ] { - m.reset_seq(); - assert_eq!(m.apply(junk), Effect::Ignored, "{junk:?}"); - } - assert!(!m.has_state); - } - - #[test] - fn text_is_cut_on_a_char_boundary() { - let mut m = Box::new(Model::new()); - let mut long = std::vec::Vec::from(&b"Stra\xc3\x9fe "[..]); - long.resize(99, b'a'); - long.extend_from_slice("ß".as_bytes()); // 2 bytes, crosses 100 - m.apply(&msg(b'T', 0, &long)); - assert_eq!(m.text().len(), 99); - m.apply(&msg(b'T', 1, b"Main St\xff")); - assert_eq!(m.text(), "Main St"); - } -} diff --git a/apps/v-maps/src/sign.rs b/apps/v-maps/src/sign.rs deleted file mode 100644 index 30e4f35..0000000 --- a/apps/v-maps/src/sign.rs +++ /dev/null @@ -1,197 +0,0 @@ -//! Turn signs drawn in one pass: the sign is a union of strokes with round ends, rings and triangles, and each -//! pixel's coverage comes from its distance to that union. Shapes drawn one over another would leave a dark -//! seam wherever two antialiased edges meet; this has none. - -use cmf_wp2_ui::color::blend565; -use cmf_wp2_ui::motion::{cos, sin}; -use cmf_wp2_ui::{ONE, Surface}; - -/// Sub-pixel units a pixel. -const U: i64 = 16; - -#[derive(Clone, Copy)] -enum Part { - /// A stroke from one point to another, round ends. - Seg((i32, i32), (i32, i32)), - /// A circle of a radius, stroked. - Ring((i32, i32), i32), - /// A filled triangle. - Tri([(i32, i32); 3]), -} - -pub struct Sign { - parts: [Part; 24], - n: usize, - /// Stroke width in px. - w: i32, -} - -impl Sign { - pub fn new(w: i32) -> Sign { - Sign { parts: [Part::Ring((0, 0), 0); 24], n: 0, w } - } - - fn push(&mut self, p: Part) -> &mut Sign { - if self.n < self.parts.len() { - self.parts[self.n] = p; - self.n += 1; - } - self - } - - pub fn seg(&mut self, a: (i32, i32), b: (i32, i32)) -> &mut Sign { - self.push(Part::Seg(a, b)) - } - - pub fn ring(&mut self, c: (i32, i32), r: i32) -> &mut Sign { - self.push(Part::Ring(c, r)) - } - - pub fn tri(&mut self, t: [(i32, i32); 3]) -> &mut Sign { - self.push(Part::Tri(t)) - } - - /// A stroked arc around `c` of radius `r`, from angle `start` over `sweep` (u16 turns, 0 = 3 o'clock, - /// clockwise on screen; negative goes the other way), as `steps` straight pieces. - pub fn arc(&mut self, c: (i32, i32), r: i32, start: u16, sweep: i32, steps: i32) -> &mut Sign { - let at = |a: u16| (c.0 + ((r * cos(a)) >> 14), c.1 + ((r * sin(a)) >> 14)); - let mut prev = at(start); - for i in 1..=steps { - let p = at(start.wrapping_add((sweep * i / steps) as u16)); - self.seg(prev, p); - prev = p; - } - self - } - - /// Distance from `p` (in 1/U px) to the part's edge, in 1/U px; negative inside. - fn dist(&self, part: &Part, p: (i64, i64)) -> i64 { - let half = self.w as i64 * U / 2; - let q = |v: (i32, i32)| (v.0 as i64 * U + U / 2, v.1 as i64 * U + U / 2); - match *part { - Part::Seg(a, b) => { - let (a, b) = (q(a), q(b)); - let (dx, dy) = (b.0 - a.0, b.1 - a.1); - let len2 = dx * dx + dy * dy; - let t = if len2 == 0 { 0 } else { ((p.0 - a.0) * dx + (p.1 - a.1) * dy).clamp(0, len2) }; - let (cx, cy) = if len2 == 0 { a } else { (a.0 + dx * t / len2, a.1 + dy * t / len2) }; - near((p.0 - cx).pow(2) + (p.1 - cy).pow(2), half) - } - Part::Ring(c, r) => { - let c = q(c); - (isqrt((p.0 - c.0).pow(2) + (p.1 - c.1).pow(2)) - r as i64 * U).abs() - half - } - Part::Tri(t) => { - let v = [q(t[0]), q(t[1]), q(t[2])]; - let area = (v[1].0 - v[0].0) * (v[2].1 - v[0].1) - (v[1].1 - v[0].1) * (v[2].0 - v[0].0); - let sign = if area > 0 { 1 } else { -1 }; - (0..3) - .map(|i| { - let (a, b) = (v[i], v[(i + 1) % 3]); - let (ex, ey) = (b.0 - a.0, b.1 - a.1); - let len = isqrt(ex * ex + ey * ey).max(1); - // outward distance from the edge's line - -sign * (ex * (p.1 - a.1) - ey * (p.0 - a.0)) / len - }) - .max() - .unwrap_or(0) - } - } - } - - /// The part's box in px, grown by the stroke and a pixel of soft edge. - fn bbox(&self, part: &Part) -> (i32, i32, i32, i32) { - let g = self.w / 2 + 2; - let (x0, y0, x1, y1) = match *part { - Part::Seg(a, b) => (a.0.min(b.0), a.1.min(b.1), a.0.max(b.0), a.1.max(b.1)), - Part::Ring(c, r) => (c.0 - r, c.1 - r, c.0 + r, c.1 + r), - Part::Tri(t) => ( - t[0].0.min(t[1].0).min(t[2].0), - t[0].1.min(t[1].1).min(t[2].1), - t[0].0.max(t[1].0).max(t[2].0), - t[0].1.max(t[1].1).max(t[2].1), - ), - }; - (x0 - g, y0 - g, x1 + g, y1 + g) - } - - /// Draws the sign in colour `c` over `bg`, looking only inside the box `x0..x1`, `y0..y1`. - #[allow(clippy::too_many_arguments)] - pub fn draw(&self, s: &mut impl Surface, x0: i32, y0: i32, x1: i32, y1: i32, c: u16, bg: u16) { - let mut boxes = [(0, 0, 0, 0); 24]; - for (b, part) in boxes.iter_mut().zip(&self.parts[..self.n]) { - *b = self.bbox(part); - } - let mut shade = [0u16; 17]; - for (k, v) in shade.iter_mut().enumerate() { - *v = blend565(bg, c, k as i32 * ONE / 16); - } - for y in y0..y1 { - let mut run: Option<(i32, usize)> = None; - for x in x0..=x1 { - let k = if x == x1 { - usize::MAX // flush - } else { - let p = (x as i64 * U + U / 2, y as i64 * U + U / 2); - let d = self.parts[..self.n] - .iter() - .zip(&boxes) - .filter(|(_, b)| x >= b.0 && x <= b.2 && y >= b.1 && y <= b.3) - .map(|(part, _)| self.dist(part, p)) - .min() - .unwrap_or(U); - (U / 2 - d).clamp(0, U) as usize - }; - match run { - Some((_, rk)) if rk == k => {} - _ => { - if let Some((rx, rk)) = run - && rk > 0 - { - s.rect(rx, y, x - rx, 1, shade[rk]); - } - run = Some((x, k)); - } - } - } - } - } -} - -/// The three corners of an arrowhead with its tip at `tip`, pointing along `a` (turns clockwise from up), `h` px -/// long. -pub fn head(tip: (i32, i32), a: u16, h: i32) -> [(i32, i32); 3] { - let d = |a: u16, r: i32| ((r * sin(a)) >> 14, -(r * cos(a)) >> 14); - let back = d(a, -h); - let side = d(a.wrapping_add(0x4000), h * 4 / 5); - let base = (tip.0 + back.0, tip.1 + back.1); - [tip, (base.0 + side.0, base.1 + side.1), (base.0 - side.0, base.1 - side.1)] -} - -/// The distance from `d2`, a squared distance, to a stroke of half width `half`, with the square root taken only -/// on the soft edge: well inside is `-U`, well outside `U`. -fn near(d2: i64, half: i64) -> i64 { - let out = half + U; - if d2 >= out * out { - return U; - } - let inn = (half - U).max(0); - if d2 <= inn * inn && half >= U { - return -U; - } - isqrt(d2) - half -} - -fn isqrt(n: i64) -> i64 { - if n < 2 { - return n.max(0); - } - let mut x = 1i64 << ((64 - n.leading_zeros()).div_ceil(2)); - loop { - let y = (x + n / x) / 2; - if y >= x { - return x; - } - x = y; - } -} diff --git a/apps/v-maps/src/view.rs b/apps/v-maps/src/view.rs deleted file mode 100644 index 6899796..0000000 --- a/apps/v-maps/src/view.rs +++ /dev/null @@ -1,1646 +0,0 @@ -//! Drawing, against `Surface`: the watch through `&Api`, a host framebuffer in tests. -//! -//! Layout on the round 466 px panel, black like the stock faces: the time left, big, at the top; a heading-up map -//! below it: the route in blue, the streets around you in grey (enough to see which turn to take), the car; the -//! next turn big at the bottom (arrow, distance) over an arc that fills as the drive goes. Text is Noto -//! Sans (`font`, `fonts`), with the loader's pixel font for a road name in a script those fonts lack. - -use crate::font::{poly, poly_half}; -use crate::fonts::{L, S, XL}; -use crate::proto::{Model, ROADS_LINES_MAX, man}; -use crate::sign::{Sign, head}; -use cmf_wp2_ui::draw::{disc, line, ring}; -use cmf_wp2_ui::motion::{Q14, cos, sin}; -use cmf_wp2_ui::text::fitted; -use cmf_wp2_ui::{C, CHAR, Rgb, SIZE, Surface, geom}; -use core::fmt::Write; - -const BLACK: Rgb = Rgb(0, 0, 0); -const WHITE: Rgb = Rgb(255, 255, 255); -const SHADE: Rgb = Rgb(178, 180, 186); -const GREY: Rgb = Rgb(140, 140, 146); -const BLUE: Rgb = Rgb(52, 138, 255); -/// The map's background: a dark slate blue (the dome is black). -const MAP_BG: Rgb = Rgb(22, 30, 42); -const STREET: Rgb = Rgb(46, 58, 76); -const MAJOR: Rgb = Rgb(78, 94, 118); // main roads: dimmer than the text, which is 178 and 255 -const ACCENT: Rgb = Rgb(255, 160, 0); -const RED: Rgb = Rgb(228, 36, 36); - -/// The map fills the whole face; the time left and the next turn are drawn over it. -pub const TOP: i32 = 0; -pub const BOTTOM: i32 = SIZE; -/// The car, heading up. -pub const CAR: (i32, i32) = (C, 278); -/// The marker's disc. -const CAR_R: i32 = 27; -/// Metres between the route's dots (about 3.4 times the radius of an ahead dot). -const ROUTE_STEP: i32 = 24; -/// Map scales the crown steps through, in metres per pixel. -pub const ZOOMS: [i32; 6] = [1, 2, 3, 5, 8, 13]; -#[cfg(test)] -const ZOOM_DEFAULT: usize = 2; - -/// What the screen is about, besides the model itself. -pub struct Ctx { - /// The phone has been heard from recently. - pub live: bool, - /// Local time of day (hours, minutes), when the watch has it. - pub zoom: usize, - /// The map is being zoomed or turned: the grey streets are drawn with hard edges (cheaper) until it settles. - pub fast: bool, - /// Where the phone is looking (a turn, 65536 = 360 degrees clockwise from north): the arrow points that way - /// while the map stays put. `None`: the map is turned to the heading instead, and the arrow points up. - pub look: Option, - /// Only the arrow changed: repaint the patch of map round it, not the whole screen. - pub arrow_only: bool, - /// The car is moving: repaint the whole screen - /// in the cheap hard-edged style. - pub light: bool, - /// Only the text in the dome changed: repaint the dome and nothing else. - pub dome: bool, -} - -/// A small text buffer for `write!` without a heap. -pub struct Buf { - b: [u8; 32], - n: usize, -} - -impl Buf { - pub fn new() -> Buf { - Buf { b: [0; 32], n: 0 } - } - pub fn as_str(&self) -> &str { - core::str::from_utf8(&self.b[..self.n]).unwrap_or("") - } -} - -impl Default for Buf { - fn default() -> Self { - Buf::new() - } -} - -impl Write for Buf { - fn write_str(&mut self, s: &str) -> core::fmt::Result { - let k = s.len().min(self.b.len() - self.n); - self.b[self.n..self.n + k].copy_from_slice(&s.as_bytes()[..k]); - self.n += k; - Ok(()) - } -} - -/// "350 m", "1.2 km", "14 km"; "500 ft", "0.3 mi", "12 mi". -pub fn distance(m: u32, imperial: bool) -> Buf { - let mut b = Buf::new(); - let _ = if imperial { - if m < 161 { - write!(b, "{} ft", (m * 3281 / 1000 + 25) / 50 * 50) - } else { - let tenths = (m * 100 + 8047) / 16093; // m / 160.93, rounded - if tenths < 100 { - write!(b, "{}.{} mi", tenths / 10, tenths % 10) - } else { - write!(b, "{} mi", (tenths + 5) / 10) - } - } - } else if m < 1000 { - write!(b, "{} m", if m < 100 { m / 5 * 5 } else { m / 10 * 10 }) - } else if m < 10_000 { - let h = (m + 50) / 100; - write!(b, "{}.{} km", h / 10, h % 10) - } else { - write!(b, "{} km", (m + 500) / 1000) - }; - b -} - -/// "14 min", "1 h 05". -pub fn duration(s: u32) -> Buf { - let mut b = Buf::new(); - let min = (s + 30) / 60; - let _ = if min < 60 { write!(b, "{} min", min) } else { write!(b, "{} h {:02}", min / 60, min % 60) }; - b -} - -/// One map-frame transform. Heading sine/cosine and the metre scale are calculated once, then reused for -/// every route and street point in that frame. This removes two fixed-point trig calls per projected point. -#[derive(Clone, Copy, Debug)] -pub struct Projector { - car: [i32; 2], - s: i32, - c: i32, - mpp: i32, -} - -impl Projector { - #[inline] - pub fn new(car: [i32; 2], course: u16, mpp: i32) -> Self { - Self { car, s: sin(course) as i32, c: cos(course) as i32, mpp: mpp.max(1) } - } - - #[inline(always)] - pub fn project(&self, p: [i32; 2]) -> (i32, i32) { - const LIM: i64 = 1 << 20; - let (dx, dy) = (p[0] as i64 - self.car[0] as i64, p[1] as i64 - self.car[1] as i64); - if dx.abs().max(dy.abs()) <= 60_000 { - // 32 bits and the hardware divide for nearby points. - let (dx, dy) = (dx as i32, dy as i32); - let d = Q14 as i32 * self.mpp; - let (right, ahead) = ((dx * self.c - dy * self.s) / d, (dx * self.s + dy * self.c) / d); - return (CAR.0 + right, CAR.1 - ahead); - } - let (s, c) = (self.s as i64, self.c as i64); - let d = Q14 as i64 * self.mpp as i64; - let right = (dx * c - dy * s) / d; - let ahead = (dx * s + dy * c) / d; - ((CAR.0 as i64 + right.clamp(-LIM, LIM)) as i32, (CAR.1 as i64 - ahead.clamp(-LIM, LIM)) as i32) - } -} - -/// Convenience projection for tests and one-off geometry. Render frames should share a `Projector`. -#[cfg(test)] -#[inline] -pub fn project(p: [i32; 2], car: [i32; 2], course: u16, mpp: i32) -> (i32, i32) { - Projector::new(car, course, mpp).project(p) -} - -/// Which sides of the box `reach` metres round the car a point lies outside, as bits: two points that share a bit -/// have a segment between them that is wholly outside. Nothing farther than the screen can show is turned or drawn. -fn world_code(p: [i32; 2], car: [i32; 2], reach: i32) -> u8 { - let (dx, dy) = (p[0].saturating_sub(car[0]), p[1].saturating_sub(car[1])); - (dx < -reach) as u8 | ((dx > reach) as u8) << 1 | ((dy < -reach) as u8) << 2 | ((dy > reach) as u8) << 3 -} - -/// How far from the car, in metres, anything can still be on the screen (its farthest edge is `CAR.1` px away). -fn reach(mpp: i32) -> i32 { - (CAR.1 + 24) * mpp -} - -/// Cohen–Sutherland: the part of a segment inside `[lo, hi]²`, or `None`. -pub fn clip(mut a: (i32, i32), mut b: (i32, i32), lo: i32, hi: i32) -> Option<((i32, i32), (i32, i32))> { - let code = - |p: (i32, i32)| (p.0 < lo) as u8 | ((p.0 > hi) as u8) << 1 | ((p.1 < lo) as u8) << 2 | ((p.1 > hi) as u8) << 3; - let (mut ca, mut cb) = (code(a), code(b)); - for _ in 0..8 { - if ca | cb == 0 { - return Some((a, b)); - } - if ca & cb != 0 { - return None; - } - let out = if ca != 0 { ca } else { cb }; - let (x0, y0, x1, y1) = (a.0 as i64, a.1 as i64, b.0 as i64, b.1 as i64); - let p = if out & 8 != 0 { - (x0 + (x1 - x0) * (hi as i64 - y0) / (y1 - y0), hi as i64) - } else if out & 4 != 0 { - (x0 + (x1 - x0) * (lo as i64 - y0) / (y1 - y0), lo as i64) - } else if out & 2 != 0 { - (hi as i64, y0 + (y1 - y0) * (hi as i64 - x0) / (x1 - x0)) - } else { - (lo as i64, y0 + (y1 - y0) * (lo as i64 - x0) / (x1 - x0)) - }; - let p = (p.0 as i32, p.1 as i32); - if out == ca { - (a, ca) = (p, code(p)); - } else { - (b, cb) = (p, code(p)); - } - } - None -} - -/// Rounds the corners of a polyline as it streams by: each vertex becomes a short curve between the midpoints of -/// its two segments (a quadratic through two extra points), so the bends of a road are not spikes. No storage: -/// `emit(from, to)` gets the straight pieces. Fewer than 3 points is just the segment. -#[derive(Default)] -struct Curve { - a: (i32, i32), - b: (i32, i32), - pen: (i32, i32), - n: u8, - /// A bend of less than about 20 degrees is left as it is (it already looks smooth): in the cheap frames only. - gentle_is_straight: bool, -} - -impl Curve { - fn push(&mut self, p: (i32, i32), smooth: bool, emit: &mut impl FnMut((i32, i32), (i32, i32))) { - match self.n { - 0 => (self.a, self.pen, self.n) = (p, p, 1), - 1 => (self.b, self.n) = (p, 2), - _ => { - if smooth && !(self.gentle_is_straight && self.gentle(p)) { - let (a, b) = (self.a, self.b); - let m1 = ((a.0 + b.0) / 2, (a.1 + b.1) / 2); - let m2 = ((b.0 + p.0) / 2, (b.1 + p.1) / 2); - let q = ((m1.0 + 2 * b.0 + m2.0) / 4, (m1.1 + 2 * b.1 + m2.1) / 4); - emit(self.pen, m1); - emit(m1, q); - emit(q, m2); - self.pen = m2; - } else { - emit(self.pen, self.b); - self.pen = self.b; - } - (self.a, self.b) = (self.b, p); - } - } - } - - /// Whether the bend at `b` towards `p` is under about 20 degrees. - fn gentle(&self, p: (i32, i32)) -> bool { - let (ux, uy) = ((self.b.0 - self.a.0) as i64, (self.b.1 - self.a.1) as i64); - let (vx, vy) = ((p.0 - self.b.0) as i64, (p.1 - self.b.1) as i64); - let dot = ux * vx + uy * vy; - // cos^2 >= 0.88 (cos 20 degrees is 0.94), going on - dot > 0 && dot * dot * 100 >= 88 * (ux * ux + uy * uy) * (vx * vx + vy * vy) - } - - fn finish(&mut self, emit: &mut impl FnMut((i32, i32), (i32, i32))) { - if self.n == 2 { - emit(self.pen, self.b); - } - } -} - -/// Integer square root. -fn isqrt64(n: u64) -> u64 { - if n <= u32::MAX as u64 { - // the usual case (a segment under 46 km): shifts and adds, no divide - let (mut n, mut r, mut b) = (n as u32, 0u32, 1u32 << 30); - while b > n { - b >>= 2; - } - while b != 0 { - if n >= r + b { - n -= r + b; - r = (r >> 1) + b; - } else { - r >>= 1; - } - b >>= 2; - } - return r as u64; - } - let mut x = 1u64 << ((64 - n.leading_zeros()).div_ceil(2)); - loop { - let y = (x + n / x) / 2; - if y >= x { - return x; - } - x = y; - } -} - -/// A hard-edged disc: one rect a row, equal rows joined. -fn flat_disc(s: &mut impl Surface, cx: i32, cy: i32, r: i32, c: Rgb) { - let k = c.rgb565(); - let mut run: Option<(i32, i32)> = None; // first row, half width - for dy in -r..=r + 1 { - let hw = if dy <= r { cmf_wp2_ui::motion::isqrt(r * r + r - dy * dy) } else { -1 }; - match run { - Some((_, h)) if h == hw => {} - _ => { - if let Some((y0, h)) = run && h >= 0 { - s.rect(cx - h, cy + y0, 2 * h + 1, dy - y0, k); - } - run = Some((dy, hw)); - } - } - } -} - -/// The route as a line of round dots, `step` metres apart, from vertex `from` to vertex `to`. The dots sit at fixed -/// distances along the whole route (counted from its start), so they stay where they are on the map as it moves. -#[cfg(test)] -#[allow(clippy::too_many_arguments)] -fn dots(s: &mut impl Surface, m: &Model, from: usize, to: usize, r: i32, step: i32, c: Rgb, mpp: i32, fast: bool) { - let projector = Projector::new([m.state.x, m.state.y], m.state.course, mpp); - dots_projected(s, m, from, to, r, step, c, &projector, fast); -} - -#[allow(clippy::too_many_arguments)] -fn dots_projected(s: &mut impl Surface, m: &Model, from: usize, to: usize, r: i32, step: i32, c: Rgb, projector: &Projector, fast: bool) { - let car = projector.car; - let mpp = projector.mpp; - let step = step as i64 * mpp as i64; - let reach = reach(mpp); - let mut cum = 0i64; - for i in 0..to.min(m.route_len).saturating_sub(1) { - let (a, b) = (m.route[i], m.route[i + 1]); - let (dx, dy) = (b[0] as i64 - a[0] as i64, b[1] as i64 - a[1] as i64); - let len = isqrt64((dx * dx + dy * dy) as u64) as i64; - // a segment wholly beyond the reach only adds its length; its dots are not even turned - if i >= from && len > 0 && world_code(a, car, reach) & world_code(b, car, reach) == 0 { - // a dot on screen is within 1.5 reach (along the segment) of the point of it nearest the car - let near = ((car[0] as i64 - a[0] as i64) * dx + (car[1] as i64 - a[1] as i64) * dy) / len; - let (lo, hi) = ((near - reach as i64 * 3 / 2).max(0), near + reach as i64 * 3 / 2); - let mut d = (cum + lo + step - 1) / step * step; // the first dot at or after the start of what can show - while d < cum + len && d <= cum + hi { - let t = d - cum; - let p = projector.project([(a[0] as i64 + dx * t / len) as i32, (a[1] as i64 + dy * t / len) as i32]); - if geom::inside(p.0, p.1) { - if fast { - flat_disc(s, p.0, p.1, r, c); - } else { - disc(s, p.0, p.1, r, c, MAP_BG); - } - } - d += step; - } - } - cum += len; - } -} - -/// Whether a segment can touch the round screen (with `w` to spare): its distance from the centre is under the -/// radius. Pieces entirely in the corners of the square are never drawn. -fn near_screen(a: (i32, i32), b: (i32, i32), w: i32) -> bool { - let (ax, ay) = (a.0 as i64 - C as i64, a.1 as i64 - C as i64); - let (dx, dy) = (b.0 as i64 - a.0 as i64, b.1 as i64 - a.1 as i64); - let len2 = dx * dx + dy * dy; - let t = if len2 == 0 { 0 } else { (-(ax * dx + ay * dy)).clamp(0, len2) }; - // the closest point is a + d * t / len2; compare its squared distance with (C + w + 2)^2 - let (px, py) = (ax * len2 + dx * t, ay * len2 + dy * t); - let r = (C + w + 2) as i128; - (px as i128 * px as i128 + py as i128 * py as i128) <= r * r * len2 as i128 * len2 as i128 -} - -/// A hard-edged line of width `w`: one rect per row (or per run of columns), no antialiasing, no round ends. About -/// a third of the rects of `line`; for the frames while the map is being zoomed or turned. -fn fast_line(s: &mut impl Surface, a: (i32, i32), b: (i32, i32), w: i32, c: Rgb) { - let k = c.rgb565(); - let (dx, dy) = ((b.0 - a.0) as i64, (b.1 - a.1) as i64); - let len = cmf_wp2_ui::motion::isqrt((dx * dx + dy * dy).min(i32::MAX as i64) as i32) as i64; - if len == 0 { - return; - } - if dy.abs() >= dx.abs() { - // steep: a rect across the line on every row, equal neighbours joined - let th = ((w as i64 * len + dy.abs() / 2) / dy.abs()).max(w as i64) as i32; - let (y0, y1) = (a.1.min(b.1).max(0), a.1.max(b.1).min(SIZE - 1)); - let mut run: Option<(i32, i32, i32)> = None; // y, left, right - for y in y0..=y1 { - let xc = a.0 as i64 + dx * (y - a.1) as i64 / dy; - let h = geom::half(y); - let (l, r) = ((xc as i32 - th / 2).max(C - h), (xc as i32 - th / 2 + th).min(C + h)); - match run { - Some((_, rl, rr)) if rl == l && rr == r => {} - _ => { - if let Some((ry, rl, rr)) = run && rr > rl { - s.rect(rl, ry, rr - rl, y - ry, k); - } - run = Some((y, l, r)); - } - } - } - if let Some((ry, rl, rr)) = run && rr > rl { - s.rect(rl, ry, rr - rl, y1 + 1 - ry, k); - } - } else { - // flat: a rect up and down on every column, equal neighbours joined - let th = ((w as i64 * len + dx.abs() / 2) / dx.abs()).max(w as i64) as i32; - let (x0, x1) = (a.0.min(b.0).max(0), a.0.max(b.0).min(SIZE - 1)); - let mut run: Option<(i32, i32, i32)> = None; // x, top, bottom - for x in x0..=x1 { - let yc = a.1 as i64 + dy * (x - a.0) as i64 / dx; - let h = geom::half(x); - let (t, bt) = ((yc as i32 - th / 2).max(C - h), (yc as i32 - th / 2 + th).min(C + h)); - match run { - Some((rx, rt, rb)) if rt == t && rb == bt => run = Some((rx, rt, rb)), - _ => { - if let Some((rx, rt, rb)) = run && rb > rt { - s.rect(rx, rt, x - rx, rb - rt, k); - } - run = Some((x, t, bt)); - } - } - } - if let Some((rx, rt, rb)) = run && rb > rt { - s.rect(rx, rt, x1 + 1 - rx, rb - rt, k); - } - } -} - -/// The streets around the car, thin and grey, under the route: enough to see which turns not to take. -#[cfg(test)] -fn streets(s: &mut impl Surface, m: &Model, mpp: i32, fast: bool) { - let projector = Projector::new([m.state.x, m.state.y], m.state.course, mpp); - streets_projected(s, m, &projector, fast); -} - -/// Whether bends are rounded in the cheap frames (while the map moves) as they are in the full one. A rounded bend is -/// three short lines instead of one; straight streets are not affected. `false`: the old sharp corners. -const ROUND_WHILE_MOVING: bool = true; - -fn streets_projected(s: &mut impl Surface, m: &Model, projector: &Projector, fast: bool) { - let car = projector.car; - let world = |i: usize| [m.roads_center[0] + m.roads[i][0] as i32, m.roads_center[1] + m.roads[i][1] as i32]; - let at = |i: usize| projector.project(world(i)); - let reach = reach(projector.mpp); - let code = |i: usize| world_code(world(i), car, reach); - for pass in 0..2 { - for l in 0..m.roads_count.min(ROADS_LINES_MAX) { - let start = m.roads_starts[l] as usize; - let end = (start + m.roads_sizes[l] as usize).min(m.roads_len); - let mut len = 0i32; - for i in start + 1..end { - len += (m.roads[i][0] as i32 - m.roads[i - 1][0] as i32).abs() + (m.roads[i][1] as i32 - m.roads[i - 1][1] as i32).abs(); - } - let major = len > 500; - if major != (pass == 1) { - continue; - } - let w = if major { 10 } else { 6 }; - let col = if major { MAJOR } else { STREET }; - // a point in the same pixel as the one before it adds nothing at this zoom: left out (never a line's end) - let near = if fast { 2 } else { 1 }; - let same = |q: (i32, i32), p: (i32, i32), i: usize| i + 1 < end && (p.0 - q.0).abs() <= near && (p.1 - q.1).abs() <= near; - for pass in 0..(if fast { 1 } else { 2 }) { - let mut emit = |q: (i32, i32), p: (i32, i32)| { - if pass == 0 { - if !(q.1 < TOP - w && p.1 < TOP - w || q.1 > BOTTOM + w && p.1 > BOTTOM + w) && near_screen(q, p, w) { - if fast { - fast_line(s, q, p, w, col); - } else if let Some((a, b)) = clip(q, p, -w, SIZE + w) { - line(s, a.0, a.1, b.0, b.1, w, col, MAP_BG); - } - } - } else if geom::inside(q.0, q.1) && q.1 >= TOP - w && q.1 <= BOTTOM + w { - disc(s, q.0, q.1, w / 2 - 1, col, col); - } - }; - let mut k = Curve { gentle_is_straight: fast, ..Curve::default() }; - let mut last: Option<(i32, i32)> = None; - let mut cut = false; - for i in start..end { - // a segment along the route is not drawn (the route covers it): the line is cut there - if i > start && m.under_route(i - 1) { - cut = true; - } - // a point whose segments both lie beyond the reach is not turned at all; the line is cut there - let seen_before = i > start && code(i - 1) & code(i) == 0; - let seen_after = i + 1 < end && code(i) & code(i + 1) == 0; - if !seen_before && !seen_after { - cut = true; - continue; - } - if !seen_before { - cut = true; - } - let p = at(i); - if !cut && last.is_some_and(|q| same(q, p, i)) { - continue; - } - if cut { - k.finish(&mut emit); - (k, cut) = (Curve { gentle_is_straight: fast, ..Curve::default() }, false); - } - last = Some(p); - k.push(p, ROUND_WHILE_MOVING || !fast, &mut emit); - } - k.finish(&mut emit); - } - } - } -} - -/// Direction `a` (turns, clockwise from up) as a screen vector of length `r`. -fn dir(a: u16, r: i32) -> (i32, i32) { - ((r * sin(a)) >> 14, -(r * cos(a)) >> 14) -} - -/// A maneuver icon in a box of radius `r` around (cx, cy): thick strokes with round ends, like a road sign. -pub fn icon(s: &mut impl Surface, code: u8, cx: i32, cy: i32, r: i32, c: Rgb) { - icon_sign(s, code, cx, cy, r, c, 0) -} - -fn icon_sign(s: &mut impl Surface, code: u8, cx: i32, cy: i32, r: i32, c: Rgb, pad: i32) { - let w = (r * 2 / 7).max(4) + pad; - let mut g = Sign::new(w); - let hl = r * 3 / 5; // arrowhead length - // a stem up from the bottom that bends towards `a` at `elbow` below the centre - // (the stem leans away from the turn by `lean` so the whole sign sits centred) - let turn = |g: &mut Sign, a: u16, elbow: i32, len: i32, lean: i32, hl: i32| { - let sh = dir(a, len - hl / 2); - let x = cx - lean; - let e = (x, cy + elbow); - let tip = (x + dir(a, len).0, e.1 + dir(a, len).1); - g.seg((x, cy + r), e).seg(e, (x + sh.0, e.1 + sh.1)).tri(head(tip, a, hl)); - }; - let gentle = |g: &mut Sign, a: u16, elbow: i32| turn(g, a, elbow, r, dir(a, r * 2 / 5).0 / 2, hl); - let sharp = |g: &mut Sign, a: u16| turn(g, a, -r * 3 / 4, r * 13 / 10, dir(a, r).0 * 7 / 10, r / 2); - // a right angle with a round bend: up, then `sign` (1 right, -1 left) - let square = |g: &mut Sign, sign: i32| { - let rho = r * 3 / 5; - let (x, y) = (cx - sign * r / 2, cy - r / 3); - let tip = (cx + sign * r, y); - let start = if sign > 0 { 0x8000 } else { 0 }; - g.seg((x, cy + r), (x, y + rho)) - .arc((x + sign * rho, y + rho), rho, start, sign * 0x4000, 6) - .seg((x + sign * rho, y), (tip.0 - sign * hl / 2, y)) - .tri(head(tip, if sign > 0 { 0x4000 } else { 0xC000 }, hl)); - }; - match code { - man::CONTINUE => { - g.seg((cx, cy + r), (cx, cy - r + hl / 2)).tri(head((cx, cy - r), 0, hl)); - } - man::SLIGHT_LEFT => gentle(&mut g, 0xE000, 0), - man::SLIGHT_RIGHT => gentle(&mut g, 0x2000, 0), - man::LEFT => square(&mut g, -1), - man::RIGHT => square(&mut g, 1), - man::SHARP_LEFT => sharp(&mut g, 0xA000), - man::SHARP_RIGHT => sharp(&mut g, 0x6000), - man::KEEP_LEFT => gentle(&mut g, 0xF000, r / 4), - man::KEEP_RIGHT => gentle(&mut g, 0x1000, r / 4), - man::UTURN => { - let (rx, top) = (r / 2, cy - r / 4); - g.seg((cx + rx, cy + r), (cx + rx, top)) - .arc((cx, top), rx, 0, -0x8000, 10) - .seg((cx - rx, top), (cx - rx, cy + r - hl / 2)) - .tri(head((cx - rx, cy + r), 0x8000, hl)); - } - man::ROUNDABOUT => { - let rr = r * 2 / 5; - g.ring((cx, cy), rr) - .seg((cx, cy + r), (cx, cy + rr)) - .seg((cx, cy - rr), (cx, cy - r - 4 + r / 4)) - .tri(head((cx, cy - r - 4), 0, r / 2)); - } - man::ARRIVE if pad == 0 => { - let pin = cy - r / 4; - let k = RED.rgb565(); - poly(s, &[(cx - r / 2 + 1, pin + r / 6), (cx + r / 2 - 1, pin + r / 6), (cx, cy + r)], 0, |_| k); - disc(s, cx, pin, r / 2, RED, BLACK); - disc(s, cx, pin, r / 5, WHITE, RED); - } - man::OFF_ROUTE if pad == 0 => { - ring(s, cx, cy, r - w, r, ACCENT, BLACK); - let k = ACCENT.rgb565(); - s.rect(cx - w / 2, cy - r / 2, w, r * 2 / 3, k); - s.rect(cx - w / 2, cy + r / 3, w, w, k); - } - _ => {} - } - let m = w + 6; - g.draw(s, cx - r - m, cy - r - m, cx + r + m, cy + r + m, c.rgb565(), 0); -} - -/// The marker: a light disc with the arrow cut out of it in dark, the arrow turned to `angle` (a turn, clockwise -/// from up). No fix: a dimmer disc. `soft`: smooth edges; a moving frame (`soft` false) draws it hard-edged, a -/// third of the rects. -fn car(s: &mut impl Surface, fix: bool, angle: u16, soft: bool) { - let (x, y) = CAR; - let (sn, cs) = (sin(angle) as i64, cos(angle) as i64); - // The disc is drawn on whole pixels, centred on the middle of pixel (x, y). The arrow is built in half pixels - // round that same point (2x+1, 2y+1), so it is turned about its own middle and sits in the disc's middle. - let rot = |dx: i32, dy: i32| { - let rx = (dx as i64 * cs - dy as i64 * sn) >> 14; - let ry = (dx as i64 * sn + dy as i64 * cs) >> 14; - (2 * x + 1 + rx as i32, 2 * y + 1 + ry as i32) - }; - let (face, ink) = if fix { (Rgb(214, 218, 228), Rgb(30, 38, 54)) } else { (Rgb(120, 124, 134), Rgb(52, 58, 72)) }; - let arrow = [rot(0, -31), rot(26, 31), rot(0, 15), rot(-26, 31)]; // 26 px wide, 31 tall - if soft { - disc(s, x, y, CAR_R, face, MAP_BG); - poly_half(s, &arrow, face.rgb565(), |_| ink.rgb565()); - } else { - for dy in -CAR_R..=CAR_R { - let hw = cmf_wp2_ui::motion::isqrt(CAR_R * CAR_R - dy * dy); - s.rect(x - hw, y + dy, 2 * hw + 1, 1, face.rgb565()); - } - fill_hard(s, &arrow, ink.rgb565()); - } -} - -/// A hard-edged filled polygon (even-odd), corners in half pixels: a pixel is filled when its middle is inside. -/// A rect for every run of every row. -fn fill_hard(s: &mut impl Surface, p: &[(i32, i32)], c: u16) { - let y0 = p.iter().map(|q| q.1).min().unwrap_or(0).div_euclid(2); - let y1 = (p.iter().map(|q| q.1).max().unwrap_or(0) + 1).div_euclid(2); - for y in y0..y1 { - let yc = 2 * y + 1; // the middle of the row - let mut xs = [0i32; 8]; - let mut n = 0; - for k in 0..p.len() { - let (a, b) = (p[k], p[(k + 1) % p.len()]); - if (a.1 <= yc && b.1 > yc || b.1 <= yc && a.1 > yc) && n < xs.len() { - xs[n] = a.0 + (b.0 - a.0) * (yc - a.1) / (b.1 - a.1); - n += 1; - } - } - xs[..n].sort_unstable(); - for pair in xs[..n].chunks_exact(2) { - // pixel px has its middle at 2px+1: filled from pair[0].div_euclid(2) up to pair[1].div_euclid(2) - let (l, r) = (pair[0].div_euclid(2), pair[1].div_euclid(2)); - if r > l { - s.rect(l, y, r - l, 1, c); - } - } - } -} - -/// A surface that only takes what falls inside a box: the arrow's patch of the map is repainted through it. -struct Clip<'a, S: Surface> { - s: &'a mut S, - x0: i32, - y0: i32, - x1: i32, - y1: i32, -} - -impl Surface for Clip<'_, S> { - fn rect(&mut self, x: i32, y: i32, w: i32, h: i32, c: u16) { - let (xa, ya) = (x.max(self.x0), y.max(self.y0)); - let (xb, yb) = ((x + w).min(self.x1), (y + h).min(self.y1)); - if xb > xa && yb > ya { - self.s.rect(xa, ya, xb - xa, yb - ya, c); - } - } - - fn text(&mut self, _x: i32, _y: i32, _s: &str, _c: u16) {} -} - -/// How wide a text line with its baseline at `y` may be, from what the circle leaves there. -fn room(f: &crate::font::Font, y: i32, margin: i32) -> i32 { - let (x0, x1) = geom::chord(y - f.cap, y + f.descent / 2, margin); - x1 - x0 -} - -/// A line of small text centred at baseline `y`; a road name in a script the font lacks falls back to the -/// loader's font (ASCII and Cyrillic). -fn small(s: &mut impl Surface, y: i32, t: &str, c: Rgb) { - if S.covers(t) { - S.centre(s, C, y, t, room(&S, y, 14), c.rgb565(), 0); - } else { - let (_, cells) = geom::text_box(y - S.cap, 14); - let n = cmf_wp2_ui::text::chars(t).min(cells); - fitted(s, C - n as i32 * CHAR / 2, y - S.cap, t, n, c.rgb565()); - } -} - -fn message(s: &mut impl Surface, title: &str, sub: &str) { - s.rect(0, 0, SIZE, SIZE, 0); - // the big font has no hyphen: a title like "V-maps" is drawn in its parts with a small bar between them - const BAR: i32 = 16; - let parts = title.split('-'); - let width: i32 = parts.clone().map(|p| L.width(p)).sum::() + BAR * (title.matches('-').count() as i32); - let mut x = C - width / 2; - for (i, p) in parts.enumerate() { - if i > 0 { - s.rect(x + 3, C - 4 - L.cap / 3, BAR - 6, 4, WHITE.rgb565()); - x += BAR; - } - L.draw(s, x, C - 4, p, WHITE.rgb565(), 0); - x += L.width(p); - } - small(s, C + 38, sub, GREY); -} - -/// A button on the menu. -#[derive(Clone, Copy, PartialEq, Eq, Debug)] -pub enum Choice { - Home, - Work, -} - -const BTN_W: i32 = 300; -const BTN_H: i32 = 91; -const BTN_X: i32 = C - BTN_W / 2; -/// Top edges of the Home and the Work button. -const BTN_Y: [i32; 2] = [150, 258]; -const BTN_FACE: Rgb = Rgb(38, 46, 64); -const BTN_DOWN: Rgb = Rgb(48, 104, 200); -/// The slack round a button that still counts as on it. -const BTN_SLACK: i32 = 8; - -/// The button under a touch. -pub fn button_at(x: i32, y: i32) -> Option { - [Choice::Home, Choice::Work].into_iter().zip(BTN_Y).find_map(|(c, top)| { - (x >= BTN_X - BTN_SLACK && x < BTN_X + BTN_W + BTN_SLACK && y >= top - BTN_SLACK && y < top + BTN_H + BTN_SLACK) - .then_some(c) - }) -} - -/// The menu: a line of text above two big rounded buttons, Home and Work, and a hint under them. `down` is the -/// button a finger is on. -pub fn menu(s: &mut impl Surface, title: &str, hint: &str, down: Option) { - s.rect(0, 0, SIZE, SIZE, 0); - small(s, 120, title, WHITE); - for (c, top) in [Choice::Home, Choice::Work].into_iter().zip(BTN_Y) { - let face = if down == Some(c) { BTN_DOWN } else { BTN_FACE }; - // a bar with a half disc at each end - let r = (BTN_H - 1) / 2; - disc(s, BTN_X + r, top + r, r, face, BLACK); - disc(s, BTN_X + BTN_W - 1 - r, top + r, r, face, BLACK); - s.rect(BTN_X + r, top, BTN_W - 2 * r, BTN_H, face.rgb565()); - // the sign and the word, side by side, in the middle of the button - let label = if c == Choice::Home { "Home" } else { "Work" }; - let width = ICON_W + ICON_GAP + L.width(label); - let (x0, cy) = (C - width / 2, top + r); - let (ix, f) = (x0 + ICON_W / 2, face.rgb565()); - let white = WHITE.rgb565(); - if c == Choice::Home { - let roof = [(0, -19), (21, 0), (13, 0), (13, 18), (-13, 18), (-13, 0), (-21, 0)]; - let pts = roof.map(|(dx, dy)| (ix + dx, cy + dy)); - poly(s, &pts, f, |_| white); - s.rect(ix - 4, cy + 6, 8, 12, f); - } else { - s.rect(ix - 20, cy - 8, 40, 28, white); - s.rect(ix - 9, cy - 18, 18, 11, white); - s.rect(ix - 5, cy - 14, 10, 7, f); - s.rect(ix - 20, cy + 3, 40, 3, f); - } - L.draw(s, x0 + ICON_W + ICON_GAP, cy + L.cap / 2, label, white, f); - } - if !hint.is_empty() { - small(s, 412, hint, GREY); - } -} - -const ICON_W: i32 = 44; -const ICON_GAP: i32 = 18; - -/// After a button was pressed, until the phone's route arrives. -pub fn going(s: &mut impl Surface, c: Choice) { - message(s, if c == Choice::Home { "Home" } else { "Work" }, "Getting the route…"); -} - -/// `new` as a heading, but at most `max` away from `from` (going the short way round). -pub fn limit_turn(from: u16, new: u16, max: i32) -> u16 { - let d = new.wrapping_sub(from) as i16 as i32; - from.wrapping_add(d.clamp(-max, max) as i16 as u16) -} - -/// Interpolate a heading along the shortest clockwise/counter-clockwise path, including across north/zero. -#[inline] -pub fn interpolate_heading(from: u16, to: u16, elapsed_ms: u32, duration_ms: u32) -> u16 { - if duration_ms == 0 || elapsed_ms >= duration_ms { - return to; - } - let delta = to.wrapping_sub(from) as i16 as i32; - from.wrapping_add((delta * elapsed_ms as i32 / duration_ms as i32) as i16 as u16) -} - -/// Linear interpolation for the car position, independent of the heading animation clock. -#[inline] -pub fn interpolate_position(from: (i32, i32), to: (i32, i32), elapsed_ms: u32, duration_ms: u32) -> (i32, i32) { - if duration_ms == 0 || elapsed_ms >= duration_ms { - return to; - } - let t = elapsed_ms as i64; - let d = duration_ms as i64; - ( - (from.0 as i64 + (to.0 as i64 - from.0 as i64) * t / d) as i32, - (from.1 as i64 + (to.1 as i64 - from.1 as i64) * t / d) as i32, - ) -} - -/// The turn bubble: the bottom of the round screen below a shallow arc (a dome, highest in the middle), all black. -/// The map is never drawn into it (see `Cut`), so only a full frame paints it and a moving map costs nothing for it. -const BUB_TOP: i32 = 318; -const BUB_RD: i32 = 300; // the dome is an arc of a circle of this radius -const BUB_CY: i32 = BUB_TOP + BUB_RD; // its centre, below the screen - -/// The bubble's left and right edge on row `y`, or `None` where it has no width. -fn bubble_span(y: i32) -> Option<(i32, i32)> { - if !(BUB_TOP..SIZE).contains(&y) { - return None; - } - let d = BUB_CY - y; - let w = cmf_wp2_ui::motion::isqrt(BUB_RD * BUB_RD - d * d).min(geom::half(y)); - (w > 0).then_some((C - w, C + w)) -} - -/// A surface that leaves the bubble alone: whatever falls inside it is not drawn. -struct Cut<'a, S: Surface> { - s: &'a mut S, -} - -impl Surface for Cut<'_, S> { - fn rect(&mut self, x: i32, y: i32, w: i32, h: i32, c: u16) { - if y + h <= BUB_TOP { - return self.s.rect(x, y, w, h, c); - } - let end = y + h; - let mut r = y; - while r < end { - let span = bubble_span(r); - // the rows from `r` that have the same edges - let mut e = r + 1; - if r < BUB_TOP { - e = end.min(BUB_TOP); - } else { - while e < end && bubble_span(e) == span { - e += 1; - } - } - match span { - None => self.s.rect(x, r, w, e - r, c), - Some((a, b)) => { - if a > x { - self.s.rect(x, r, (a - x).min(w), e - r, c); - } - if b < x + w { - let l = b.max(x); - self.s.rect(l, r, x + w - l, e - r, c); - } - } - } - r = e; - } - } - - fn text(&mut self, _x: i32, _y: i32, _s: &str, _c: u16) {} -} - -/// Clears the map's background except the bubble: the part above it in one rect, beside it a row at a time (only -/// as far as the round screen goes, so about 130 rects). -fn clear_round_bubble(s: &mut impl Surface) { - let bg = MAP_BG.rgb565(); - s.rect(0, TOP, SIZE, BUB_TOP - TOP, bg); - for r in BUB_TOP..SIZE { - // only what the round screen has: beside the dome, and where the dome is wider than the screen, nothing - let h = geom::half(r); - match bubble_span(r) { - Some((a, b)) => { - if a > C - h { - s.rect(C - h, r, a - (C - h), 1, bg); - } - if b < C + h { - s.rect(b, r, C + h - b, 1, bg); - } - } - None => s.rect(C - h, r, 2 * h, 1, bg), - } - } -} - -/// The bubble: black, with the next turn's sign and the distance to it. -fn turn(s: &mut impl Surface, m: &Model) { - for y in BUB_TOP..SIZE { - if let Some((a, b)) = bubble_span(y) { - s.rect(a, y, b - a, 1, 0); - } - } - let st = &m.state; - if st.maneuver == man::OFF_ROUTE { - let y = 402; - icon(s, man::OFF_ROUTE, C - 100, y - 14, 28, ACCENT); - L.draw(s, C - 56, y, "Off route", ACCENT.rgb565(), 0); - S.draw(s, C - 56, y + 28, "Rerouting…", SHADE.rgb565(), 0); - return; - } - let d = distance(st.dist_m as u32, st.imperial()); - let (num, unit) = d.as_str().split_once(' ').unwrap_or((d.as_str(), "")); - let (iw, gap, ugap) = (60, 14, 8); - let w = iw + gap + XL.width(num) + ugap + L.width(unit); - let x = C - w / 2; - let y = 408; // baseline of the distance - icon(s, st.maneuver, x + iw / 2, y - XL.cap / 2, 28, WHITE); - let after = XL.draw(s, x + iw + gap, y, num, WHITE.rgb565(), 0); - L.draw(s, after + ugap, y, unit, SHADE.rgb565(), 0); - // the time left, light grey, under it (small when the round screen leaves too little room for the big one) - let left = duration(st.remaining_s as u32); - let t = left.as_str(); - let (f, ty) = if L.width(t) <= room(&L, 450, 8) { (&L, 450) } else { (&S, 446) }; - f.draw(s, C - f.width(t) / 2, ty, t, SHADE.rgb565(), 0); -} - -/// The whole screen. -pub fn draw(s: &mut impl Surface, m: &Model, ctx: &Ctx) { - let st = &m.state; - if !m.has_state || !ctx.live { - return message(s, "V-maps", if m.has_state { "Phone out of reach" } else { "Waiting for Vela…" }); - } - if !st.active() { - return message(s, "V-maps", "Start a route in Vela"); - } - if st.arrived() { - s.rect(0, 0, SIZE, SIZE, 0); - icon(s, man::ARRIVE, C, 168, 46, RED); - L.draw(s, C - L.width("Arrived") / 2, 268, "Arrived", WHITE.rgb565(), 0); - small(s, 308, m.text(), GREY); - return; - } - if ctx.dome { - // only the text changed: the dome paints itself black first, and the map stays as it is - return turn(s, m); - } - let mpp = ZOOMS[ctx.zoom.min(ZOOMS.len() - 1)]; - let angle = ctx.look.unwrap_or(0); - if ctx.arrow_only { - // the map has not moved: repaint the patch round the arrow and draw the arrow on it - let (x, y) = CAR; - let mut c = Clip { s, x0: x - 34, y0: y - 36, x1: x + 34, y1: y + 32 }; - c.rect(0, 0, SIZE, SIZE, MAP_BG.rgb565()); - layers(&mut c, m, mpp, false); - car(&mut c, st.fix(), angle, true); - return; - } - if ctx.light { - // the whole screen in the cheap style, except the bubble: it stays as the last full frame drew it - { - clear_round_bubble(s); - layers(&mut Cut { s: &mut *s }, m, mpp, true); - } - car(s, st.fix(), angle, false); - return; - } - { - clear_round_bubble(s); - layers(&mut Cut { s: &mut *s }, m, mpp, ctx.fast); - } - car(s, st.fix(), angle, true); - turn(s, m); -} - -/// The map: nearby streets, the road behind, the route ahead and where it ends. -fn layers(s: &mut impl Surface, m: &Model, mpp: i32, fast: bool) { - let st = &m.state; - // Reuse the same heading transform for every road, route dot and destination point in this frame. - let projector = Projector::new([st.x, st.y], st.course, mpp); - streets_projected(s, m, &projector, fast); - if m.route_len >= 2 { - let p = (st.progress as usize).clamp(1, m.route_len); - dots_projected(s, m, p - 1, m.route_len, 7, ROUTE_STEP, BLUE, &projector, fast); - let end = projector.project(m.route[m.route_len - 1]); - if geom::inside(end.0, end.1) && end.1 > TOP + 12 && end.1 < BOTTOM - 12 { - disc(s, end.0, end.1, 13, BLACK, WHITE); - disc(s, end.0, end.1, 9, RED, BLACK); - } - } -} - -#[cfg(test)] -mod tests { - use super::*; - use crate::proto::enc::{route, state}; - use crate::proto::{F_ACTIVE, F_FIX, State}; - use cmf_wp2_ui::Fb; - use std::boxed::Box; - use std::vec; - use std::vec::Vec; - - #[test] - fn formats() { - assert_eq!(distance(347, false).as_str(), "340 m"); - assert_eq!(distance(42, false).as_str(), "40 m"); - assert_eq!(distance(1249, false).as_str(), "1.2 km"); - assert_eq!(distance(9960, false).as_str(), "10.0 km"); - assert_eq!(distance(23_600, false).as_str(), "24 km"); - assert_eq!(distance(100, true).as_str(), "350 ft"); - assert_eq!(distance(500, true).as_str(), "0.3 mi"); - assert_eq!(distance(40_000, true).as_str(), "25 mi"); - assert_eq!(duration(840).as_str(), "14 min"); - assert_eq!(duration(3900).as_str(), "1 h 05"); - } - - #[test] - fn projector_reuses_one_frame_transform_without_changing_projection() { - for course in [0u16, 1, 8192, 16384, 24576, 32768, 49152, 65535] { - let car = [12_345, -67_890]; - let projector = Projector::new(car, course, 1); - let (sn, cs) = (sin(course) as i64, cos(course) as i64); - for p in [[12_345, -67_790], [12_245, -67_890], [12_400, -67_940], [50_000, 20_000]] { - let (dx, dy) = (p[0] as i64 - car[0] as i64, p[1] as i64 - car[1] as i64); - let d = Q14 as i64; - let right = (dx * cs - dy * sn) / d; - let ahead = (dx * sn + dy * cs) / d; - let lim = 1i64 << 20; - let expected = ( - (CAR.0 as i64 + right.clamp(-lim, lim)) as i32, - (CAR.1 as i64 - ahead.clamp(-lim, lim)) as i32, - ); - assert_eq!(projector.project(p), expected, "course {course}, point {p:?}"); - } - } - } - - #[test] - fn heading_interpolation_takes_short_path_through_north() { - let halfway = interpolate_heading(65_000, 500, 100, 200); - assert!(halfway < 65_535 && halfway > 65_000); - assert_eq!(interpolate_heading(65_000, 500, 200, 200), 500); - assert_eq!(interpolate_heading(500, 65_000, 100, 200), 65_518); - } - - #[test] - fn retargeting_heading_starts_from_the_currently_displayed_angle() { - let displayed = interpolate_heading(1000, 5000, 120, 240); - // A new phone sample retargets from the value on screen, so t=0 cannot jump. - assert_eq!(interpolate_heading(displayed, 9000, 0, 240), displayed); - assert_eq!(interpolate_heading(displayed, 9000, 240, 240), 9000); - } - - #[test] - fn position_and_heading_interpolations_finish_independently() { - assert_eq!(interpolate_position((0, 0), (100, 200), 100, 200), (50, 100)); - assert_eq!(interpolate_heading(0, 16_384, 100, 200), 8_192); - assert_eq!(interpolate_heading(0, 16_384, 200, 200), 16_384); - } - - #[test] - fn heading_up() { - // heading east (a quarter turn): a point 100 m east is straight ahead, one 100 m south is to the right - assert_eq!(project([100, 0], [0, 0], 0x4000, 1), (CAR.0, CAR.1 - 100)); - assert_eq!(project([0, -100], [0, 0], 0x4000, 1), (CAR.0 + 100, CAR.1)); - assert_eq!(project([0, 100], [0, 0], 0, 2), (CAR.0, CAR.1 - 50)); - // far away does not overflow - let far = project([2_000_000_000, -2_000_000_000], [-2_000_000_000, 2_000_000_000], 0x2000, 1); - assert!(far.0 > SIZE); - } - - #[test] - fn clipping() { - assert_eq!(clip((10, 10), (20, 20), 0, 100), Some(((10, 10), (20, 20)))); - assert_eq!(clip((-50, -50), (-10, -10), 0, 100), None); - assert_eq!(clip((-100, 50), (200, 50), 0, 100), Some(((0, 50), (100, 50)))); - } - - fn model() -> Box { - let mut m = Box::new(Model::new()); - let pts: vec::Vec<[i32; 2]> = - (0..60).map(|i| if i < 30 { [0, i * 20] } else { [(i - 29) * 20, 580] }).collect(); - let (msgs, seq) = route(0, 1, &pts); - msgs.iter().for_each(|x| { - m.apply(x); - }); - let st = State { - flags: F_ACTIVE | F_FIX, - maneuver: man::RIGHT, - dist_m: 180, - remaining_10m: 120, - remaining_s: 300, - limit: 50, - x: 0, - y: 400, - progress: 21, - ..State::default() - }; - m.apply(&state(seq, &st)); - m.apply(&crate::proto::enc::msg(b'T', seq.wrapping_add(1), b"Bannerghatta Main Road")); - m - } - - #[test] - fn the_arrow_turns_and_only_its_patch_is_repainted() { - let m = model(); - let mut px = vec![0u16; (SIZE * SIZE) as usize]; - let mut fb = Fb::new(&mut px); - let ctx = |look: Option, arrow_only| Ctx { live: true, zoom: ZOOM_DEFAULT, fast: false, look, arrow_only, light: false, dome: false }; - // looking east (a quarter turn): the tip points right of the car, the wings trail to the left - draw(&mut fb, &m, &ctx(Some(16384), false)); - let ink = Rgb(30, 38, 54).rgb565(); - assert_eq!(fb.at(CAR.0 + 8, CAR.1), ink, "tip at the right"); - assert_ne!(fb.at(CAR.0, CAR.1 - 8), ink, "nothing up any more"); - // a heading change alone: pixels outside the patch are left as they were, the arrow follows the new heading - let mut px2 = vec![0x1234u16; (SIZE * SIZE) as usize]; - let mut fb2 = Fb::new(&mut px2); - draw(&mut fb2, &m, &ctx(Some(0), true)); - assert_eq!(fb2.at(10, 10), 0x1234); - assert_eq!(fb2.at(CAR.0 + 60, CAR.1), 0x1234); - assert_eq!(fb2.at(CAR.0, CAR.1 - 8), Rgb(30, 38, 54).rgb565()); // the arrow up, on the disc - assert_eq!(fb2.at(CAR.0 - 22, CAR.1), Rgb(214, 218, 228).rgb565()); - assert!(fb2.rects < 1500, "{}", fb2.rects); // a full frame is ~15x that - } - - #[test] - fn a_light_frame_repaints_the_screen_but_the_bubble() { - let m = rich(); - let mut px = vec![0x1234u16; (SIZE * SIZE) as usize]; - let mut fb = Fb::new(&mut px); - draw(&mut fb, &m, &Ctx { live: true, zoom: ZOOM_DEFAULT, fast: true, look: None, arrow_only: false, light: true, dome: false }); - assert_eq!(fb.at(C, C + 218), 0x1234); // the bubble is left as it was - assert_ne!(fb.at(C, 100), 0x1234); - assert_ne!(fb.at(C, 20), 0x1234); - assert_eq!(fb.at(CAR.0, CAR.1 - 8), Rgb(30, 38, 54).rgb565()); - assert_eq!(fb.at(CAR.0 - 22, CAR.1), Rgb(214, 218, 228).rgb565()); - assert!(fb.rects < 7000, "{}", fb.rects); - } - - #[test] - fn draws_a_drive() { - let m = model(); - let mut px = vec![0u16; (SIZE * SIZE) as usize]; - let mut fb = Fb::new(&mut px); - draw(&mut fb, &m, &Ctx { live: true, zoom: ZOOM_DEFAULT, fast: false, look: None, arrow_only: false, light: false, dome: false }); - // the route ahead passes above the car, the car is drawn, the turn goes right of the centre - assert!((CAR.1 - 90..CAR.1 - 35).any(|y| fb.at(CAR.0, y) == BLUE.rgb565())); - // the car: a light disc with a dark arrow in it - assert_eq!(fb.at(CAR.0, CAR.1 - 8), Rgb(30, 38, 54).rgb565()); - assert_eq!(fb.at(CAR.0 - 22, CAR.1), Rgb(214, 218, 228).rgb565()); - // no progress arc at the bottom - assert_eq!(fb.at(C, C + 218), 0); - assert!(fb.rects < 20_000, "{}", fb.rects); - // nothing lit outside the circle - for y in 0..SIZE { - for x in 0..SIZE { - // outside the round screen only the background's own colour (its clear is a square) - if !geom::inside(x, y) { - let p = fb.at(x, y); - assert!(p == 0 || p == MAP_BG.rgb565(), "lit at {x},{y}"); - } - } - } - } - - #[test] - fn a_turn_is_limited_per_frame_the_short_way() { - assert_eq!(limit_turn(100, 500, 4096), 500); - assert_eq!(limit_turn(0, 20000, 4096), 4096); - assert_eq!(limit_turn(0, 0u16.wrapping_sub(20000), 4096), 0u16.wrapping_sub(4096)); - // across north: 65000 -> 2000 is a short turn right, not a long one left - assert_eq!(limit_turn(65000, 2000, 4096), 2000); - assert_eq!(limit_turn(60000, 8000, 4096), 60000u16.wrapping_add(4096)); - } - - /// The steep branch as it was before equal rows were joined: one rect a row. - fn steep_rows(s: &mut impl Surface, a: (i32, i32), b: (i32, i32), w: i32, c: Rgb) { - let k = c.rgb565(); - let (dx, dy) = ((b.0 - a.0) as i64, (b.1 - a.1) as i64); - let len = cmf_wp2_ui::motion::isqrt((dx * dx + dy * dy).min(i32::MAX as i64) as i32) as i64; - let th = ((w as i64 * len + dy.abs() / 2) / dy.abs()).max(w as i64) as i32; - for y in a.1.min(b.1).max(0)..=a.1.max(b.1).min(SIZE - 1) { - let xc = a.0 as i64 + dx * (y - a.1) as i64 / dy; - let h = geom::half(y); - let (x0, x1) = ((xc as i32 - th / 2).max(C - h), (xc as i32 - th / 2 + th).min(C + h)); - if x1 > x0 { - s.rect(x0, y, x1 - x0, 1, k); - } - } - } - - #[test] - fn joined_steep_rows_draw_the_same_pixels() { - let ends = [(C, -40), (C + 3, SIZE + 40), (60, 20), (400, 450), (233, 233), (120, 440), (300, 10), (30, 200), (C + 90, 100)]; - let mut n = 0; - for &a in &ends { - for &b in &ends { - if (b.1 - a.1).abs() < (b.0 - a.0).abs() || a == b { - continue; // steep ones only - } - for w in [3, 8, 16] { - let mut p1 = vec![0u16; (SIZE * SIZE) as usize]; - let mut p2 = p1.clone(); - let (mut f1, mut f2) = (Fb::new(&mut p1), Fb::new(&mut p2)); - fast_line(&mut f1, a, b, w, WHITE); - steep_rows(&mut f2, a, b, w, WHITE); - let (r1, r2) = (f1.rects, f2.rects); - assert!(p1 == p2, "{a:?} {b:?} {w}"); - assert!(r1 <= r2); - n += 1; - } - } - } - assert!(n > 30); - // a vertical street is one rect - let mut px = vec![0u16; (SIZE * SIZE) as usize]; - let mut fb = Fb::new(&mut px); - fast_line(&mut fb, (C, -10), (C, SIZE + 10), 8, WHITE); - assert_eq!(fb.rects, 1); - } - - #[test] - fn the_route_is_dots_that_stay_put_on_the_map() { - let mut m = model(); - let snap = |m: &Model, fast: bool| { - let mut px = vec![0u16; (SIZE * SIZE) as usize]; - let mut fb = Fb::new(&mut px); - layers(&mut fb, m, 1, fast); - px - }; - // the dots are separate: going up the column of the car there are gaps between blue runs - for fast in [false, true] { - let px = snap(&m, fast); - let col: Vec = (CAR.1 - 150..CAR.1 - 35).map(|y| px[(y * SIZE + CAR.0) as usize] == BLUE.rgb565()).collect(); - let runs = col.windows(2).filter(|w| !w[0] && w[1]).count(); - assert!(runs >= 3, "{fast} {runs}"); - assert!(col.iter().any(|b| !b) && col.iter().any(|b| *b)); - } - // 24 m on, the dots are exactly where they were (the pattern repeats every 24 px along the route) - let a = snap(&m, true); - m.state.y += 24; - let b = snap(&m, true); - let blue = |px: &Vec, y: i32| (CAR.0 - 8..CAR.0 + 8).filter(|x| px[(y * SIZE + x) as usize] == BLUE.rgb565()).count(); - for y in CAR.1 - 150..CAR.1 - 80 { - assert_eq!(blue(&a, y), blue(&b, y + 24), "row {y}"); - } - } - - #[test] - fn the_arrow_is_in_the_middle_of_the_disc() { - let m = model(); - let mut px = vec![0u16; (SIZE * SIZE) as usize]; - let mut fb = Fb::new(&mut px); - car(&mut fb, true, 0, true); - let ink = Rgb(30, 38, 54).rgb565(); - let (mut x0, mut x1, mut y0, mut y1) = (SIZE, 0, SIZE, 0); - for y in CAR.1 - CAR_R..=CAR.1 + CAR_R { - for x in CAR.0 - CAR_R..=CAR.0 + CAR_R { - if fb.at(x, y) != ink { - continue; - } - (x0, x1, y0, y1) = (x0.min(x), x1.max(x), y0.min(y), y1.max(y)); - } - } - // the disc spans CAR.1 - CAR_R ..= CAR.1 + CAR_R: the arrow leaves as much room above as below - let (above, below) = (y0 - (CAR.1 - CAR_R), (CAR.1 + CAR_R) - y1); - assert!((above - below).abs() <= 1, "{above} {below}"); - let (left, right) = (x0 - (CAR.0 - CAR_R), (CAR.0 + CAR_R) - x1); - assert!((left - right).abs() <= 1, "{left} {right}"); - let _ = m; - } - - #[test] - fn every_icon_stays_in_its_box() { - for code in 0..=13 { - let mut px = vec![0u16; (SIZE * SIZE) as usize]; - let mut fb = Fb::new(&mut px); - icon(&mut fb, code, C, C, 32, WHITE); - for y in 0..SIZE { - for x in 0..SIZE { - if fb.at(x, y) != 0 { - assert!((x - C).abs() <= 40 && (y - C).abs() <= 40, "icon {code} at {x},{y}"); - } - } - } - } - } - - fn with_streets(mut m: Box) -> Box { - let lines = vec![ - vec![[-300i16, 120], [-200, 120], [-100, 120], [0, 120], [100, 120], [200, 120], [300, 120]], - vec![[60i16, 100], [90, 150], [150, 200], [220, 230]], - vec![[-80i16, 0], [-80, 100], [-80, 200], [-80, 300]], - ]; - let (msgs, _) = crate::proto::enc::roads(10, 4, [0, 400], &lines); - msgs.iter().for_each(|x| { - m.apply(x); - }); - m - } - - #[test] - fn nearby_streets_are_grey_and_under_the_route() { - let m = with_streets(model()); - let mut px = vec![0u16; (SIZE * SIZE) as usize]; - let mut fb = Fb::new(&mut px); - draw(&mut fb, &m, &Ctx { live: true, zoom: ZOOM_DEFAULT, fast: false, look: None, arrow_only: false, light: false, dome: false }); - // the street left of the road, 80 m west at 3 m/px: 27 px left of the car's column, going up - assert!((CAR.0 - 31..CAR.0 - 22).any(|x| fb.at(x, CAR.1 - 60) == STREET.rgb565())); - // the cross street 120 m ahead of (0, 400): y 520 = 40 px above the car - assert!((CAR.1 - 44..CAR.1 - 35).any(|y| fb.at(CAR.0 - 90, y) == STREET.rgb565() || fb.at(CAR.0 - 90, y) == MAJOR.rgb565())); - // the route stays on top where they cross - assert!((CAR.1 - 90..CAR.1 - 35).any(|y| fb.at(CAR.0, y) == BLUE.rgb565())); - assert!(fb.rects < 25_000, "{}", fb.rects); - } - - /// A winding route with a grid of streets around the car, for pictures. - fn rich() -> Box { - let mut m = Box::new(Model::new()); - let mut pts: vec::Vec<[i32; 2]> = vec![]; - for i in 0..=20 { pts.push([0, i * 20]); } // north 400 m - for i in 1..=15 { pts.push([i * 20, 400]); } // east 300 m - for i in 1..=20 { pts.push([300, 400 + i * 20]); } // north 400 m - for i in 1..=10 { pts.push([300 - i * 20, 800]); } // west 200 m - let (msgs, seq) = route(0, 1, &pts); - msgs.iter().for_each(|x| { - m.apply(x); - }); - let st = State { - flags: F_ACTIVE | F_FIX, - maneuver: man::RIGHT, - after: man::LEFT, - after_m: 240, - dist_m: 180, - remaining_10m: 120, - remaining_s: 300, - x: 0, - y: 220, - progress: 12, - ..State::default() - }; - m.apply(&state(seq, &st)); - let mut lines: vec::Vec> = vec![]; - for k in -2..=5i16 { - lines.push(vec![[-740, k * 160 + 30], [-370, k * 160 + 8], [0, k * 160], [370, k * 160 - 12], [740, k * 160 - 20]]); - } - for k in -4..=4i16 { - lines.push(vec![[k * 190 + 20, -400], [k * 190 + 10, -150], [k * 190, 150], [k * 190 - 10, 400]]); - } - lines.truncate(ROADS_LINES_MAX); - let (msgs, _) = crate::proto::enc::roads(seq.wrapping_add(1), 4, [0, 400], &lines); - msgs.iter().for_each(|x| { - m.apply(x); - }); - m.apply(&crate::proto::enc::msg(b'T', seq.wrapping_add(40), b"Bannerghatta Main Road")); - m - } - - /// `PREVIEW=/path cargo test dump_preview`: raw RGB565 frames of the screen, for pictures. - #[test] - fn dump_preview() { - let Ok(dir) = std::env::var("PREVIEW") else { return }; - let mut m = rich(); - let mut shot = |name: &str, m: &Model, zoom: usize| { - let mut px = vec![0u16; (SIZE * SIZE) as usize]; - let mut fb = Fb::new(&mut px); - draw(&mut fb, m, &Ctx { live: true, zoom, fast: false, look: None, arrow_only: false, light: false, dome: false }); - let bytes: Vec = px.iter().flat_map(|v| v.to_le_bytes()).collect(); - std::fs::write(format!("{dir}/{name}.raw"), bytes).unwrap(); - }; - shot("drive", &m, ZOOM_DEFAULT); - shot("far", &m, 4); - shot("near", &m, 1); - m.state.maneuver = man::OFF_ROUTE; - shot("off", &m, ZOOM_DEFAULT); - let mut px = vec![0u16; (SIZE * SIZE) as usize]; - let mut fb = Fb::new(&mut px); - draw(&mut fb, &m, &Ctx { live: true, zoom: ZOOM_DEFAULT, fast: true, look: None, arrow_only: false, light: false, dome: false }); - std::fs::write(format!("{dir}/fast.raw"), px.iter().flat_map(|v| v.to_le_bytes()).collect::>()).unwrap(); - } - - /// Winding streets, a vertex every ~15 m, for the cost of rounding bends. - fn curvy() -> Box { - let mut m = rich(); - let mut lines: vec::Vec> = vec![]; - for k in 0..12i32 { - let mut l = vec![]; - for i in 0..24i32 { - let t = i as f32 * 0.9; // a bend every 29 m, 40 to 60 degrees - let x = -330 + i * 29; - let y = k * 70 - 330 + (45.0 * (t + k as f32).sin()) as i32; - l.push([x as i16, y as i16]); - } - lines.push(l); - } - let (msgs, _) = crate::proto::enc::roads(60, 9, [0, 220], &lines); - msgs.iter().for_each(|x| { - m.apply(x); - }); - m - } - - #[test] - fn rounded_bends_in_a_moving_frame_stay_cheap() { - let m = curvy(); - let mut px = vec![0u16; (SIZE * SIZE) as usize]; - let mut fb = Fb::new(&mut px); - draw(&mut fb, &m, &Ctx { live: true, zoom: ZOOM_DEFAULT, fast: true, look: None, arrow_only: false, light: true, dome: false }); - eprintln!("curvy moving frame: {} rects", fb.rects); - assert!(fb.rects < 2700, "{}", fb.rects); - } - - #[test] - fn the_bubble_stays_and_a_moving_frame_leaves_it_alone() { - let m = rich(); - let mut full = vec![0u16; (SIZE * SIZE) as usize]; - draw(&mut Fb::new(&mut full), &m, &Ctx { live: true, zoom: ZOOM_DEFAULT, fast: false, look: None, arrow_only: false, light: false, dome: false }); - // the bubble is black with the sign and the distance on it - assert!((BUB_TOP..SIZE).any(|y| bubble_span(y).is_some_and(|(a, b)| (a..b).any(|x| full[(y * SIZE + x) as usize] != 0)))); - // a light frame drawn over it leaves every pixel of the bubble as it was, and costs fewer rects - let mut px = full.clone(); - let mut fb = Fb::new(&mut px); - draw(&mut fb, &m, &Ctx { live: true, zoom: ZOOM_DEFAULT, fast: true, look: None, arrow_only: false, light: true, dome: false }); - assert!(fb.rects < 3300, "{}", fb.rects); - for y in BUB_TOP..SIZE { - let Some((a, b)) = bubble_span(y) else { continue }; - for x in a..b { - assert_eq!(px[(y * SIZE + x) as usize], full[(y * SIZE + x) as usize], "bubble changed at {x},{y}"); - } - } - } - - #[test] - fn fast_streets_keep_every_street_and_the_layering() { - let m = with_streets(model()); - let frame = |fast: bool| { - let mut px = vec![0u16; (SIZE * SIZE) as usize]; - let mut fb = Fb::new(&mut px); - draw(&mut fb, &m, &Ctx { live: true, zoom: ZOOM_DEFAULT, fast, look: None, arrow_only: false, light: false, dome: false }); - let rects = fb.rects; - (px, rects) - }; - let (full, full_rects) = frame(false); - let (fast, fast_rects) = frame(true); - // fewer rects in all, and a lot fewer for the streets themselves - assert!(fast_rects < full_rects, "{fast_rects} vs {full_rects}"); - let cost = |fast: bool, zoom: usize| { - let mut c = cmf_wp2_ui::Count { rects: 0, px: 0 }; - streets(&mut c, &rich(), ZOOMS[zoom], fast); - c.rects - }; - for zoom in [0, 2, 4] { - let (f, q) = (cost(false, zoom), cost(true, zoom)); - eprintln!("zoom {zoom}: streets {f} rects, fast {q}"); - assert!(q * 2 < f, "zoom {zoom}: {q} vs {f}"); - } - // the same streets are there: every pixel that is grey in the full frame is grey (some grey) in the fast one - let grey = |p: u16| p == STREET.rgb565() || p == MAJOR.rgb565(); - let (mut both, mut only_full) = (0, 0); - for (a, b) in full.iter().zip(&fast) { - if grey(*a) { - if grey(*b) { both += 1 } else { only_full += 1 } - } - } - assert!(both > 1500 && only_full * 4 < both, "{both} {only_full}"); - // a main road is over a small street where they cross; the route over both - let cross = |px: &Vec, x, y| px[(y * SIZE + x) as usize]; - assert!((CAR.1 - 90..CAR.1 - 35).any(|y| cross(&fast, CAR.0, y) == BLUE.rgb565())); - } - - #[test] - fn nothing_is_drawn_for_streets_in_the_corners() { - // a street in the top left corner of the square, outside the round screen - assert!(!near_screen((0, 0), (30, 0), 6)); - assert!(near_screen((0, 233), (30, 233), 6)); - assert!(near_screen((-100, 233), (600, 233), 6)); - assert!(!near_screen((-50, 20), (20, -50), 10)); - } - - #[test] - fn the_menu_has_two_buttons_that_can_be_hit() { - assert_eq!(button_at(C, BTN_Y[0] + 40), Some(Choice::Home)); - assert_eq!(button_at(C, BTN_Y[1] + 40), Some(Choice::Work)); - assert_eq!(button_at(C, 60), None); - assert_eq!(button_at(C, 440), None); - assert_eq!(button_at(5, BTN_Y[0] + 40), None); - // the buttons sit inside the round screen with room to spare - for top in BTN_Y { - for y in [top, top + BTN_H - 1] { - let (x0, x1) = geom::chord(y, y + 1, 6); - assert!(BTN_X + BTN_H / 2 >= x0 && BTN_X + BTN_W - BTN_H / 2 <= x1, "{y}"); - } - } - } - - #[test] - fn the_menu_draws_inside_the_circle_and_shows_a_pressed_button() { - let draw_menu = |down: Option, title: &str| { - let mut px = vec![0u16; (SIZE * SIZE) as usize]; - let mut fb = Fb::new(&mut px); - menu(&mut fb, title, "Swipe left to go back", down); - px - }; - let (a, b) = (draw_menu(None, "Start a destination"), draw_menu(Some(Choice::Work), "Start a destination")); - for y in 0..SIZE { - for x in 0..SIZE { - if !geom::inside(x, y) { - assert_eq!(a[(y * SIZE + x) as usize], 0, "lit at {x},{y}"); - } - } - } - let at = |px: &Vec, x: i32, y: i32| px[(y * SIZE + x) as usize]; - // the buttons have a face; the one under a finger has another - assert_eq!(at(&a, BTN_X + 20, BTN_Y[0] + 45), BTN_FACE.rgb565()); - assert_eq!(at(&a, BTN_X + 20, BTN_Y[1] + 45), BTN_FACE.rgb565()); - assert_eq!(at(&b, BTN_X + 20, BTN_Y[1] + 45), BTN_DOWN.rgb565()); - assert_eq!(at(&b, BTN_X + 20, BTN_Y[0] + 45), BTN_FACE.rgb565()); - // the word is white on the face: some white inside the button - let white = (BTN_X..BTN_X + BTN_W).any(|x| (BTN_Y[0]..BTN_Y[0] + BTN_H).any(|y| at(&a, x, y) == 0xFFFF)); - assert!(white); - // another title draws a different screen - assert!(a != draw_menu(None, "Waiting for Vela…")); - // it is a still screen: cheap - let mut c = cmf_wp2_ui::Count { rects: 0, px: 0 }; - menu(&mut c, "Start a destination", "", None); - assert!(c.rects < 6000, "{}", c.rects); - let mut px = vec![0u16; (SIZE * SIZE) as usize]; - going(&mut Fb::new(&mut px), Choice::Home); - assert!(px.iter().any(|&p| p == 0xFFFF)); - } - - #[test] - fn points_in_the_same_pixel_cost_nothing() { - let mut m = model(); - // a street of 200 points a decimetre apart: one pixel at most - let line: vec::Vec<[i16; 2]> = (0..200).map(|i| [-60i16, 100 + i / 2]).collect(); - let (msgs, _) = crate::proto::enc::roads(10, 4, [0, 400], &[line]); - msgs.iter().for_each(|x| { - m.apply(x); - }); - let mut c = cmf_wp2_ui::Count { rects: 0, px: 0 }; - streets(&mut c, &m, 3, false); - assert!(c.rects < 400, "{}", c.rects); - } - - #[test] - fn a_dome_frame_repaints_only_the_dome() { - let m = rich(); - let mut px = vec![0x1234u16; (SIZE * SIZE) as usize]; - let mut fb = Fb::new(&mut px); - draw(&mut fb, &m, &Ctx { live: true, zoom: ZOOM_DEFAULT, fast: false, look: None, arrow_only: false, light: false, dome: true }); - assert_eq!(fb.at(C, 100), 0x1234); // the map is left as it was - assert_eq!(fb.at(CAR.0, CAR.1), 0x1234); - assert_ne!(fb.at(C, C + 218), 0x1234); // the dome is painted - // and it costs well under a whole frame - let mut full = vec![0u16; (SIZE * SIZE) as usize]; - let mut ffb = Fb::new(&mut full); - draw(&mut ffb, &m, &Ctx { live: true, zoom: ZOOM_DEFAULT, fast: false, look: None, arrow_only: false, light: false, dome: false }); - assert!(fb.rects * 2 < ffb.rects, "dome {} full {}", fb.rects, ffb.rects); - } - - #[test] - fn the_quick_projection_is_the_long_one() { - let cars = [[0, 0], [3, -4], [-1200, 800]]; - for (p, car, course, mpp) in [ - ([10, 20], cars[0], 0x1234u16, 1), - ([-250, 300], cars[1], 40000, 3), - ([299, -280], cars[2], 65535, 13), - ([59_000, -59_000], cars[0], 12345, 1), - ([100_000, 90_000], cars[0], 777, 2), - ] { - let (dx, dy) = (p[0] as i64 - car[0] as i64, p[1] as i64 - car[1] as i64); - let (s, c) = (sin(course) as i64, cos(course) as i64); - let d = Q14 as i64 * mpp as i64; - let (right, ahead) = ((dx * c - dy * s) / d, (dx * s + dy * c) / d); - let lim = 1i64 << 20; - let want = ((CAR.0 as i64 + right.clamp(-lim, lim)) as i32, (CAR.1 as i64 - ahead.clamp(-lim, lim)) as i32); - assert_eq!(project(p, car, course, mpp), want, "{p:?} {car:?}"); - } - } - - #[test] - fn the_square_root_is_exact() { - for n in [0u64, 1, 2, 3, 4, 15, 16, 17, 99, 100, 1 << 31, u32::MAX as u64 - 1, u32::MAX as u64, u32::MAX as u64 + 1, 1 << 40, u64::MAX >> 1] { - let r = isqrt64(n) as u128; - assert!(r * r <= n as u128 && (r + 1) * (r + 1) > n as u128, "{n}"); - } - for n in 0..5000u64 { - let r = isqrt64(n * 1_000_003) as u128; - assert!(r * r <= (n * 1_000_003) as u128 && (r + 1) * (r + 1) > (n * 1_000_003) as u128); - } - } - - /// The dots as 1.25 drew them: every dot of the whole route turned, whether or not it could be on screen. - #[allow(clippy::too_many_arguments)] - fn dots_of_everything(s: &mut impl Surface, m: &Model, from: usize, to: usize, r: i32, step: i32, c: Rgb, mpp: i32, fast: bool) { - let st = &m.state; - let car = [st.x, st.y]; - let step = step as i64 * mpp as i64; - let mut cum = 0i64; - for i in 0..to.min(m.route_len).saturating_sub(1) { - let (a, b) = (m.route[i], m.route[i + 1]); - let (dx, dy) = (b[0] as i64 - a[0] as i64, b[1] as i64 - a[1] as i64); - let len = isqrt64((dx * dx + dy * dy) as u64) as i64; - if i >= from && len > 0 { - let mut d = (cum + step - 1) / step * step; - while d < cum + len { - let t = d - cum; - // This test-only baseline intentionally uses the one-shot projection helper: - // it models the pre-Projector renderer for pixel-equivalence comparisons. - let p = project( - [(a[0] as i64 + dx * t / len) as i32, (a[1] as i64 + dy * t / len) as i32], - car, - st.course, - mpp, - ); - if geom::inside(p.0, p.1) { - if fast { - flat_disc(s, p.0, p.1, r, c); - } else { - disc(s, p.0, p.1, r, c, MAP_BG); - } - } - d += step; - } - } - cum += len; - } - } - - fn long_route() -> Box { - // a route 20 km long, then a turn: the car is half way along the first stretch - let mut m = model(); - m.route[0] = [0, 0]; - m.route[1] = [0, 20_000]; - m.route[2] = [3000, 20_000]; - m.route_len = 3; - m.state.x = 3; - m.state.y = 9000; - m - } - - #[test] - fn leaving_out_what_is_far_away_changes_no_pixel() { - for which in 0..2 { - for mpp in [1, 3] { - for fast in [false, true] { - for course in [0u16, 9000, 30000, 50000] { - let mut m = if which == 0 { model() } else { long_route() }; - m.state.course = course; - let (mut a, mut b) = (vec![0u16; (SIZE * SIZE) as usize], vec![0u16; (SIZE * SIZE) as usize]); - dots(&mut Fb::new(&mut a), &m, 0, m.route_len, 7, ROUTE_STEP, BLUE, mpp, fast); - dots_of_everything(&mut Fb::new(&mut b), &m, 0, m.route_len, 7, ROUTE_STEP, BLUE, mpp, fast); - assert!(a == b, "route {which} mpp {mpp} fast {fast} course {course}"); - if mpp == 1 { - assert!(a.iter().any(|p| *p == BLUE.rgb565()), "route {which}: nothing drawn"); - } - } - } - } - } - } -} diff --git a/apps/v-maps/store.md b/apps/v-maps/store.md deleted file mode 100644 index 101e18f..0000000 --- a/apps/v-maps/store.md +++ /dev/null @@ -1,11 +0,0 @@ -A Google Maps-inspired navigation app for the Nothing CMF Watch Pro 2 that brings your route, nearby streets, and turn-by-turn directions directly to your wrist over Bluetooth. - -The live map fills the screen and smoothly tracks your GPS movement with phone orientation in real time. You can switch between two map orientations: one where the center indicator rotates to match your direction while the map stays fixed, and another where the entire map rotates around you as you move. You can also save Home and Work locations for quick access. - -## Requirements - -- The [patched firmware](/firmware) (`fw-wp2.bin` from 2026-11-13 or later) and the [App Loader](/firmware)(2026-11-13 or later). - -- Vela for Android with the watch link, [APK on GitHub](https://github.com/abdalrahmanmamdouh2004-svg/V-Maps/releases/tag/V-Maps), on the phone that is paired with the watch in Nothing X. In - -- Vela: Settings > Nav device > CMF watch test, pick the watch, turn on **Show navigation on the watch**. diff --git a/apps/v-maps/store.toml b/apps/v-maps/store.toml deleted file mode 100644 index f3f106b..0000000 --- a/apps/v-maps/store.toml +++ /dev/null @@ -1,6 +0,0 @@ -# The app's listing in the FMC store (README.md, "store.toml"). The page's body is store.md. -name = "V-maps" -summary = "A live map of your route and the streets around you, with the next turn and the time left, from the Vela maps app on your phone" -version = "1.1.1" -author = "Abdalrahman" -screenshots = ["shots/driving.png", "shots/zoomed-out.png", "shots/off-route.png"] diff --git a/apps/vault-rush/Cargo.toml b/apps/vault-rush/Cargo.toml deleted file mode 100644 index 6c992aa..0000000 --- a/apps/vault-rush/Cargo.toml +++ /dev/null @@ -1,13 +0,0 @@ -[package] -name = "vault-rush" -edition.workspace = true -license.workspace = true -version.workspace = true - -[dependencies] -cmf-wp2-app.workspace = true -cmf-wp2-ui.workspace = true - -[[bin]] -name = "vault-rush" -bench = false diff --git a/apps/vault-rush/icon.svg b/apps/vault-rush/icon.svg deleted file mode 100644 index a22f953..0000000 --- a/apps/vault-rush/icon.svg +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/apps/vault-rush/shots/heist.png b/apps/vault-rush/shots/heist.png deleted file mode 100644 index a47b51e..0000000 Binary files a/apps/vault-rush/shots/heist.png and /dev/null differ diff --git a/apps/vault-rush/shots/menu.png b/apps/vault-rush/shots/menu.png deleted file mode 100644 index 7f1af5b..0000000 Binary files a/apps/vault-rush/shots/menu.png and /dev/null differ diff --git a/apps/vault-rush/shots/over.png b/apps/vault-rush/shots/over.png deleted file mode 100644 index 0a1f260..0000000 Binary files a/apps/vault-rush/shots/over.png and /dev/null differ diff --git a/apps/vault-rush/shots/playing.png b/apps/vault-rush/shots/playing.png deleted file mode 100644 index 63fc7bf..0000000 Binary files a/apps/vault-rush/shots/playing.png and /dev/null differ diff --git a/apps/vault-rush/shots/siren.png b/apps/vault-rush/shots/siren.png deleted file mode 100644 index d7c6a2f..0000000 Binary files a/apps/vault-rush/shots/siren.png and /dev/null differ diff --git a/apps/vault-rush/src/font.rs b/apps/vault-rush/src/font.rs deleted file mode 100644 index 8f7238a..0000000 --- a/apps/vault-rush/src/font.rs +++ /dev/null @@ -1,1397 +0,0 @@ -//! Smooth 4-bpp (16-level) anti-aliased fonts generated by `tools/gen_font.py`. -//! -//! Glyphs rasterized from Barlow SemiBold (Copyright 2017 The Barlow Project Authors, -//! https://github.com/jpt/barlow), licensed under the SIL Open Font License 1.1 -//! (https://scripts.sil.org/OFL). - -use cmf_wp2_ui::draw::Run; -use cmf_wp2_ui::{ONE, Rgb, Surface}; - -#[derive(Clone, Copy)] -pub struct Glyph { - pub ch: u8, - pub x_off: i8, - pub y_off: i8, - pub w: u8, - pub h: u8, - pub adv: u8, - pub offset: u16, -} - -pub struct Font { - pub glyphs: &'static [Glyph], - pub data: &'static [u8], -} - -impl Font { - fn glyph(&self, b: u8) -> Option<&Glyph> { - self.glyphs.iter().find(|g| g.ch == b) - } - - pub fn width(&self, text: &str) -> i32 { - let mut w = 0i32; - for b in text.bytes() { - w += self.glyph(b).map_or(0, |g| g.adv as i32); - } - w - } - - pub fn draw(&self, s: &mut impl Surface, x: i32, y: i32, text: &str, fg: Rgb, bg: Rgb) { - let mut pal = [0u16; 16]; - pal[0] = bg.rgb565(); - pal[15] = fg.rgb565(); - for i in 1..15 { - pal[i] = bg.mix(fg, (i as i32) * ONE / 15).rgb565(); - } - let mut cx = x; - for b in text.bytes() { - let Some(g) = self.glyph(b) else { continue }; - let gw = g.w as usize; - let gh = g.h as usize; - if gw > 0 && gh > 0 { - let gx = cx + g.x_off as i32; - let gy = y + g.y_off as i32; - let start = g.offset as usize; - for row in 0..gh { - let mut run = Run::new(s, gy + row as i32, false); - for col in 0..gw { - let idx = row * gw + col; - let byte = self.data[start + (idx >> 1)]; - let lvl = if (idx & 1) == 0 { byte >> 4 } else { byte & 0x0F } as usize; - if lvl != 0 { - run.put(gx + col as i32, 1, pal[lvl]); - } - } - } - } - cx += g.adv as i32; - } - } - - pub fn centre(&self, s: &mut impl Surface, cx: i32, y: i32, text: &str, fg: Rgb, bg: Rgb) { - let w = self.width(text); - self.draw(s, cx - w / 2, y, text, fg, bg); - } -} - -static FONT_SM_DATA: [u8; 2052] = [ - 0x00, 0x7D, 0xED, 0x80, 0x00, 0x8F, 0xD9, 0xCF, 0x90, 0x0F, 0xE1, 0x00, 0xDF, 0x12, 0xFB, 0x00, - 0x0A, 0xF3, 0x2F, 0xB0, 0x00, 0xAF, 0x32, 0xFB, 0x00, 0x0A, 0xF3, 0x2F, 0xB0, 0x00, 0xAF, 0x32, - 0xFB, 0x00, 0x0A, 0xF3, 0x0E, 0xE1, 0x00, 0xDF, 0x10, 0x8F, 0xD9, 0xCF, 0x90, 0x00, 0x7D, 0xED, - 0x80, 0x00, 0x06, 0xDF, 0x84, 0xFE, 0xF8, 0x13, 0x5F, 0x80, 0x05, 0xF8, 0x00, 0x5F, 0x80, 0x05, - 0xF8, 0x00, 0x5F, 0x80, 0x05, 0xF8, 0x00, 0x5F, 0x80, 0x05, 0xF8, 0x00, 0x5F, 0x80, 0x01, 0x9E, - 0xFC, 0x50, 0x00, 0xCF, 0xB9, 0xEF, 0x50, 0x3F, 0xC0, 0x03, 0xFB, 0x02, 0xA6, 0x00, 0x3F, 0xB0, - 0x00, 0x00, 0x0B, 0xF6, 0x00, 0x00, 0x08, 0xFB, 0x00, 0x00, 0x06, 0xFD, 0x10, 0x00, 0x05, 0xFE, - 0x20, 0x00, 0x04, 0xEE, 0x30, 0x00, 0x02, 0xEF, 0xC8, 0x88, 0x80, 0x3F, 0xFF, 0xFF, 0xFF, 0x10, - 0x3F, 0xFF, 0xFF, 0xF8, 0x28, 0x88, 0x9F, 0xF8, 0x00, 0x01, 0xCF, 0xB0, 0x00, 0x1C, 0xFA, 0x00, - 0x00, 0x7F, 0xFD, 0x50, 0x00, 0x06, 0x4D, 0xF3, 0x00, 0x00, 0x05, 0xF9, 0x39, 0x40, 0x03, 0xFA, - 0x4F, 0xB0, 0x07, 0xF8, 0x0C, 0xFB, 0xAF, 0xE2, 0x01, 0x9E, 0xEB, 0x30, 0x00, 0x07, 0xF7, 0x00, - 0x00, 0x01, 0xEE, 0x10, 0x00, 0x00, 0x6F, 0x80, 0x00, 0x00, 0x0D, 0xF1, 0x00, 0x00, 0x05, 0xF9, - 0x04, 0xF9, 0x00, 0xCF, 0x20, 0x4F, 0x90, 0x4F, 0xE9, 0x9B, 0xFD, 0x56, 0xFF, 0xFF, 0xFF, 0xF8, - 0x00, 0x00, 0x04, 0xF9, 0x00, 0x00, 0x00, 0x4F, 0x90, 0x00, 0x00, 0x04, 0xF9, 0x00, 0x2F, 0xFF, - 0xFF, 0xF6, 0x3F, 0xD8, 0x88, 0x83, 0x3F, 0xA0, 0x00, 0x00, 0x3F, 0xA0, 0x00, 0x00, 0x3F, 0xDC, - 0xED, 0x60, 0x3F, 0xFC, 0x9E, 0xF5, 0x18, 0x70, 0x03, 0xFB, 0x01, 0x10, 0x01, 0xFC, 0x1F, 0xD1, - 0x05, 0xFA, 0x09, 0xFC, 0x9E, 0xF4, 0x00, 0x8D, 0xEC, 0x50, 0x01, 0xAE, 0xFC, 0x50, 0x0C, 0xFB, - 0x9E, 0xF4, 0x2F, 0xC0, 0x06, 0xF8, 0x3F, 0xA0, 0x01, 0x31, 0x3F, 0xCB, 0xED, 0x60, 0x3F, 0xFC, - 0x9E, 0xF5, 0x3F, 0xD0, 0x04, 0xFB, 0x3F, 0xB0, 0x01, 0xFC, 0x1F, 0xD0, 0x04, 0xFA, 0x09, 0xFC, - 0x9E, 0xF4, 0x00, 0x8D, 0xFC, 0x50, 0x9F, 0xFF, 0xFF, 0xF8, 0x9F, 0x88, 0x8C, 0xF7, 0x47, 0x00, - 0x0C, 0xF2, 0x00, 0x00, 0x3F, 0xC0, 0x00, 0x00, 0x9F, 0x60, 0x00, 0x00, 0xEE, 0x10, 0x00, 0x05, - 0xF9, 0x00, 0x00, 0x0B, 0xF4, 0x00, 0x00, 0x2F, 0xD0, 0x00, 0x00, 0x8F, 0x70, 0x00, 0x00, 0xDF, - 0x20, 0x00, 0x01, 0x9E, 0xFC, 0x40, 0x0A, 0xFC, 0x9E, 0xF3, 0x1F, 0xD0, 0x05, 0xF8, 0x1F, 0xC0, - 0x05, 0xF8, 0x09, 0xFB, 0x9E, 0xE2, 0x05, 0xFF, 0xFF, 0xC1, 0x1E, 0xE3, 0x19, 0xF8, 0x4F, 0xA0, - 0x02, 0xFB, 0x3F, 0xC0, 0x04, 0xFA, 0x0C, 0xFB, 0x9E, 0xF4, 0x01, 0x9E, 0xFC, 0x50, 0x01, 0xAE, - 0xEB, 0x30, 0x0C, 0xFB, 0xAF, 0xE2, 0x4F, 0xB0, 0x07, 0xF7, 0x6F, 0x70, 0x04, 0xF9, 0x4F, 0xA0, - 0x07, 0xF9, 0x0D, 0xFB, 0xAF, 0xF9, 0x02, 0xBE, 0xD9, 0xF9, 0x03, 0x20, 0x03, 0xF9, 0x2F, 0xC0, - 0x05, 0xF9, 0x0C, 0xFB, 0x9E, 0xF4, 0x01, 0xAE, 0xFC, 0x50, 0x00, 0x02, 0xFF, 0x70, 0x00, 0x00, - 0x07, 0xFF, 0xC0, 0x00, 0x00, 0x0C, 0xFD, 0xF2, 0x00, 0x00, 0x2F, 0xC7, 0xF7, 0x00, 0x00, 0x7F, - 0x72, 0xFC, 0x00, 0x00, 0xCF, 0x30, 0xDF, 0x20, 0x02, 0xFD, 0x00, 0x8F, 0x70, 0x06, 0xFA, 0x22, - 0x5F, 0xC0, 0x0B, 0xFF, 0xFF, 0xFF, 0xF2, 0x1F, 0xE4, 0x44, 0x4A, 0xF7, 0x6F, 0x90, 0x00, 0x03, - 0xFB, 0xCF, 0xFF, 0xFD, 0x70, 0x0C, 0xF8, 0x89, 0xDF, 0x70, 0xCF, 0x00, 0x01, 0xFC, 0x0C, 0xF0, - 0x00, 0x1F, 0xC0, 0xCF, 0x88, 0x9D, 0xF6, 0x0C, 0xFF, 0xFF, 0xFB, 0x10, 0xCF, 0x10, 0x06, 0xFA, - 0x0C, 0xF0, 0x00, 0x0D, 0xF0, 0xCF, 0x00, 0x01, 0xEF, 0x0C, 0xF8, 0x89, 0xDF, 0xA0, 0xCF, 0xFF, - 0xFD, 0x71, 0x00, 0x00, 0x5C, 0xEE, 0xB4, 0x00, 0x6F, 0xE9, 0xAF, 0xF4, 0x0E, 0xE2, 0x00, 0x4F, - 0xB1, 0xFC, 0x00, 0x00, 0xA9, 0x2F, 0xB0, 0x00, 0x00, 0x02, 0xFB, 0x00, 0x00, 0x00, 0x2F, 0xB0, - 0x00, 0x00, 0x01, 0xFC, 0x00, 0x00, 0xA9, 0x0E, 0xE2, 0x00, 0x4F, 0xB0, 0x6F, 0xE9, 0xAF, 0xF4, - 0x00, 0x5C, 0xEE, 0xB4, 0x00, 0xCF, 0xFF, 0xFD, 0x70, 0x0C, 0xF9, 0x89, 0xDF, 0x80, 0xCF, 0x00, - 0x01, 0xEE, 0x0C, 0xF0, 0x00, 0x0C, 0xF1, 0xCF, 0x00, 0x00, 0xCF, 0x1C, 0xF0, 0x00, 0x0C, 0xF1, - 0xCF, 0x00, 0x00, 0xCF, 0x1C, 0xF0, 0x00, 0x0C, 0xF1, 0xCF, 0x00, 0x02, 0xEE, 0x0C, 0xF8, 0x89, - 0xDF, 0x80, 0xCF, 0xFF, 0xFD, 0x70, 0x00, 0xCF, 0xFF, 0xFF, 0xFB, 0xCF, 0x88, 0x88, 0x86, 0xCF, - 0x00, 0x00, 0x00, 0xCF, 0x00, 0x00, 0x00, 0xCF, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xFE, 0x00, 0xCF, - 0x88, 0x88, 0x00, 0xCF, 0x00, 0x00, 0x00, 0xCF, 0x00, 0x00, 0x00, 0xCF, 0x88, 0x88, 0x86, 0xCF, - 0xFF, 0xFF, 0xFB, 0xCF, 0xFF, 0xFF, 0xFB, 0xCF, 0x88, 0x88, 0x86, 0xCF, 0x00, 0x00, 0x00, 0xCF, - 0x00, 0x00, 0x00, 0xCF, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xFE, 0x00, 0xCF, 0x88, 0x88, 0x00, 0xCF, - 0x00, 0x00, 0x00, 0xCF, 0x00, 0x00, 0x00, 0xCF, 0x00, 0x00, 0x00, 0xCF, 0x00, 0x00, 0x00, 0x00, - 0x5C, 0xEE, 0xB4, 0x00, 0x6F, 0xE9, 0xAF, 0xF4, 0x0E, 0xE2, 0x00, 0x4F, 0xB1, 0xFC, 0x00, 0x00, - 0x98, 0x2F, 0xB0, 0x00, 0x00, 0x02, 0xFB, 0x03, 0xFF, 0xFD, 0x2F, 0xB0, 0x18, 0x8F, 0xD1, 0xFC, - 0x00, 0x00, 0xED, 0x0E, 0xF2, 0x00, 0x3F, 0xA0, 0x6F, 0xE9, 0x9E, 0xF3, 0x00, 0x5C, 0xEE, 0xB3, - 0x00, 0xCF, 0x00, 0x00, 0xBF, 0x2C, 0xF0, 0x00, 0x0B, 0xF2, 0xCF, 0x00, 0x00, 0xBF, 0x2C, 0xF0, - 0x00, 0x0B, 0xF2, 0xCF, 0x00, 0x00, 0xBF, 0x2C, 0xFF, 0xFF, 0xFF, 0xF2, 0xCF, 0x88, 0x88, 0xDF, - 0x2C, 0xF0, 0x00, 0x0B, 0xF2, 0xCF, 0x00, 0x00, 0xBF, 0x2C, 0xF0, 0x00, 0x0B, 0xF2, 0xCF, 0x00, - 0x00, 0xBF, 0x20, 0xCF, 0x0C, 0xF0, 0xCF, 0x0C, 0xF0, 0xCF, 0x0C, 0xF0, 0xCF, 0x0C, 0xF0, 0xCF, - 0x0C, 0xF0, 0xCF, 0x00, 0x00, 0x00, 0x00, 0xBF, 0x20, 0x00, 0x00, 0x0B, 0xF2, 0x00, 0x00, 0x00, - 0xBF, 0x20, 0x00, 0x00, 0x0B, 0xF2, 0x00, 0x00, 0x00, 0xBF, 0x20, 0x00, 0x00, 0x0B, 0xF2, 0x6A, - 0x20, 0x00, 0xBF, 0x29, 0xF3, 0x00, 0x0B, 0xF2, 0x7F, 0x70, 0x01, 0xEE, 0x02, 0xEF, 0xA9, 0xDF, - 0x80, 0x02, 0xAE, 0xFC, 0x60, 0x00, 0xCF, 0x00, 0x02, 0xEE, 0x2C, 0xF0, 0x01, 0xDF, 0x40, 0xCF, - 0x00, 0xBF, 0x60, 0x0C, 0xF0, 0x9F, 0x90, 0x00, 0xCF, 0x8F, 0xC0, 0x00, 0x0C, 0xFF, 0xFE, 0x20, - 0x00, 0xCF, 0xC5, 0xFB, 0x00, 0x0C, 0xF2, 0x0A, 0xF6, 0x00, 0xCF, 0x00, 0x1E, 0xE2, 0x0C, 0xF0, - 0x00, 0x6F, 0xB0, 0xCF, 0x00, 0x00, 0xBF, 0x50, 0xCF, 0x00, 0x00, 0x00, 0xCF, 0x00, 0x00, 0x00, - 0xCF, 0x00, 0x00, 0x00, 0xCF, 0x00, 0x00, 0x00, 0xCF, 0x00, 0x00, 0x00, 0xCF, 0x00, 0x00, 0x00, - 0xCF, 0x00, 0x00, 0x00, 0xCF, 0x00, 0x00, 0x00, 0xCF, 0x00, 0x00, 0x00, 0xCF, 0x88, 0x88, 0x85, - 0xCF, 0xFF, 0xFF, 0xFA, 0xCF, 0x50, 0x00, 0x0C, 0xF4, 0xCF, 0xE1, 0x00, 0x8F, 0xF4, 0xCF, 0xFA, - 0x03, 0xFF, 0xF4, 0xCF, 0xCF, 0x5D, 0xFC, 0xF4, 0xCF, 0x2E, 0xFF, 0x89, 0xF4, 0xCF, 0x06, 0xFC, - 0x09, 0xF4, 0xCF, 0x00, 0x62, 0x09, 0xF4, 0xCF, 0x00, 0x00, 0x09, 0xF4, 0xCF, 0x00, 0x00, 0x09, - 0xF4, 0xCF, 0x00, 0x00, 0x09, 0xF4, 0xCF, 0x00, 0x00, 0x09, 0xF4, 0xCF, 0x40, 0x00, 0x5F, 0x8C, - 0xFD, 0x00, 0x05, 0xF8, 0xCF, 0xF7, 0x00, 0x5F, 0x8C, 0xFD, 0xE2, 0x05, 0xF8, 0xCF, 0x4F, 0xB0, - 0x5F, 0x8C, 0xF0, 0xAF, 0x55, 0xF8, 0xCF, 0x01, 0xED, 0x5F, 0x8C, 0xF0, 0x06, 0xFD, 0xF8, 0xCF, - 0x00, 0x0C, 0xFF, 0x8C, 0xF0, 0x00, 0x3F, 0xF8, 0xCF, 0x00, 0x00, 0x8F, 0x80, 0x00, 0x4B, 0xEE, - 0xB4, 0x00, 0x05, 0xFE, 0x9A, 0xEF, 0x40, 0x0D, 0xF2, 0x00, 0x3F, 0xC0, 0x1F, 0xC0, 0x00, 0x0D, - 0xF0, 0x2F, 0xB0, 0x00, 0x0C, 0xF1, 0x2F, 0xB0, 0x00, 0x0C, 0xF1, 0x2F, 0xB0, 0x00, 0x0C, 0xF1, - 0x1F, 0xC0, 0x00, 0x0D, 0xF0, 0x0D, 0xF2, 0x00, 0x3F, 0xC0, 0x05, 0xFE, 0x9A, 0xEF, 0x40, 0x00, - 0x5B, 0xEE, 0xB4, 0x00, 0xEF, 0xFF, 0xFD, 0x80, 0x0E, 0xF8, 0x89, 0xDF, 0x80, 0xEE, 0x00, 0x01, - 0xEE, 0x0E, 0xE0, 0x00, 0x0D, 0xF0, 0xEE, 0x00, 0x06, 0xFC, 0x0E, 0xFF, 0xFF, 0xFE, 0x40, 0xEF, - 0x88, 0x86, 0x20, 0x0E, 0xE0, 0x00, 0x00, 0x00, 0xEE, 0x00, 0x00, 0x00, 0x0E, 0xE0, 0x00, 0x00, - 0x00, 0xEE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6C, 0xFE, 0x91, 0x00, 0x7F, 0xD9, 0xBF, 0xC1, 0x1E, - 0xE1, 0x00, 0x9F, 0x63, 0xFA, 0x00, 0x04, 0xF9, 0x4F, 0x90, 0x00, 0x3F, 0xA4, 0xF9, 0x00, 0x03, - 0xFA, 0x4F, 0x90, 0x00, 0x3F, 0xA4, 0xF9, 0x00, 0x03, 0xFA, 0x2F, 0xB0, 0x00, 0x5F, 0x80, 0xCF, - 0x61, 0x3D, 0xF3, 0x03, 0xDF, 0xFF, 0xF7, 0x00, 0x01, 0x7F, 0xC2, 0x00, 0x00, 0x03, 0xF9, 0x00, - 0x00, 0xCF, 0xFF, 0xFE, 0x80, 0x0C, 0xF8, 0x89, 0xDF, 0x80, 0xCF, 0x00, 0x01, 0xEE, 0x0C, 0xF0, - 0x00, 0x0D, 0xF1, 0xCF, 0x00, 0x05, 0xFD, 0x0C, 0xFF, 0xFF, 0xFF, 0x40, 0xCF, 0x88, 0xEF, 0x20, - 0x0C, 0xF0, 0x07, 0xF6, 0x00, 0xCF, 0x00, 0x1E, 0xD1, 0x0C, 0xF0, 0x00, 0x7F, 0x70, 0xCF, 0x00, - 0x01, 0xDE, 0x10, 0x01, 0x8D, 0xFE, 0xA2, 0x00, 0xBF, 0xB9, 0xBF, 0xE2, 0x2F, 0xC0, 0x00, 0x7F, - 0x81, 0xFD, 0x10, 0x01, 0x96, 0x08, 0xFD, 0x72, 0x00, 0x00, 0x05, 0xCF, 0xFB, 0x30, 0x00, 0x00, - 0x39, 0xFF, 0x43, 0xA5, 0x00, 0x05, 0xFA, 0x4F, 0xB0, 0x00, 0x4F, 0xA0, 0xCF, 0xD9, 0x9E, 0xF4, - 0x01, 0x8D, 0xFE, 0xB4, 0x00, 0x7F, 0xFF, 0xFF, 0xFF, 0xB4, 0x88, 0xBF, 0xC8, 0x86, 0x00, 0x05, - 0xF8, 0x00, 0x00, 0x00, 0x5F, 0x80, 0x00, 0x00, 0x05, 0xF8, 0x00, 0x00, 0x00, 0x5F, 0x80, 0x00, - 0x00, 0x05, 0xF8, 0x00, 0x00, 0x00, 0x5F, 0x80, 0x00, 0x00, 0x05, 0xF8, 0x00, 0x00, 0x00, 0x5F, - 0x80, 0x00, 0x00, 0x05, 0xF7, 0x00, 0x00, 0xEE, 0x00, 0x00, 0xBF, 0x1E, 0xE0, 0x00, 0x0B, 0xF2, - 0xEE, 0x00, 0x00, 0xBF, 0x2E, 0xE0, 0x00, 0x0B, 0xF2, 0xEE, 0x00, 0x00, 0xBF, 0x2E, 0xE0, 0x00, - 0x0B, 0xF2, 0xEE, 0x00, 0x00, 0xBF, 0x2E, 0xE0, 0x00, 0x0C, 0xF1, 0xBF, 0x40, 0x02, 0xEE, 0x04, - 0xFF, 0xA9, 0xEF, 0x60, 0x04, 0xBE, 0xEC, 0x50, 0x00, 0x6F, 0x80, 0x00, 0x0B, 0xF3, 0x2F, 0xD0, - 0x00, 0x1F, 0xD0, 0x0C, 0xF2, 0x00, 0x5F, 0x80, 0x07, 0xF7, 0x00, 0xAF, 0x30, 0x02, 0xFB, 0x00, - 0xEE, 0x00, 0x00, 0xDF, 0x13, 0xF9, 0x00, 0x00, 0x8F, 0x58, 0xF4, 0x00, 0x00, 0x3F, 0x9C, 0xE0, - 0x00, 0x00, 0x0D, 0xEF, 0x90, 0x00, 0x00, 0x09, 0xFF, 0x50, 0x00, 0x00, 0x04, 0xFE, 0x00, 0x00, - 0x7F, 0x70, 0x01, 0xFF, 0x10, 0x05, 0xF8, 0x3F, 0xB0, 0x04, 0xFF, 0x50, 0x09, 0xF4, 0x0E, 0xE0, - 0x08, 0xFF, 0x90, 0x0D, 0xF1, 0x0A, 0xF3, 0x0C, 0xDD, 0xD0, 0x1F, 0xC0, 0x06, 0xF7, 0x1F, 0xA9, - 0xF2, 0x5F, 0x80, 0x02, 0xFB, 0x4F, 0x66, 0xF6, 0x9F, 0x40, 0x00, 0xDE, 0x8F, 0x32, 0xFA, 0xDE, - 0x00, 0x00, 0x9F, 0xEE, 0x00, 0xDE, 0xFB, 0x00, 0x00, 0x5F, 0xFB, 0x00, 0xAF, 0xF7, 0x00, 0x00, - 0x1F, 0xF7, 0x00, 0x6F, 0xF3, 0x00, 0x00, 0x0B, 0xF4, 0x00, 0x2F, 0xE0, 0x00, 0x4F, 0xB0, 0x00, - 0x0D, 0xF2, 0x0A, 0xF5, 0x00, 0x7F, 0x80, 0x01, 0xED, 0x12, 0xED, 0x00, 0x00, 0x6F, 0x8A, 0xF4, - 0x00, 0x00, 0x0C, 0xFF, 0xA0, 0x00, 0x00, 0x05, 0xFF, 0x30, 0x00, 0x00, 0x0C, 0xFF, 0xA0, 0x00, - 0x00, 0x6F, 0x8A, 0xF4, 0x00, 0x01, 0xED, 0x12, 0xED, 0x00, 0x0A, 0xF5, 0x00, 0x7F, 0x70, 0x4F, - 0xB0, 0x00, 0x0D, 0xF2, 0x4F, 0xA0, 0x00, 0x2E, 0xD0, 0x0C, 0xF3, 0x00, 0x9F, 0x60, 0x04, 0xFA, - 0x02, 0xFD, 0x00, 0x00, 0xBF, 0x39, 0xF5, 0x00, 0x00, 0x3F, 0xCF, 0xC0, 0x00, 0x00, 0x0A, 0xFF, - 0x40, 0x00, 0x00, 0x03, 0xFC, 0x00, 0x00, 0x00, 0x02, 0xFB, 0x00, 0x00, 0x00, 0x02, 0xFB, 0x00, - 0x00, 0x00, 0x02, 0xFB, 0x00, 0x00, 0x00, 0x02, 0xFB, 0x00, 0x00, 0x6F, 0xFF, 0xFF, 0xFF, 0x23, - 0x88, 0x88, 0x9F, 0xF2, 0x00, 0x00, 0x08, 0xF8, 0x00, 0x00, 0x04, 0xFC, 0x00, 0x00, 0x01, 0xDF, - 0x30, 0x00, 0x00, 0xAF, 0x70, 0x00, 0x00, 0x6F, 0xB0, 0x00, 0x00, 0x2E, 0xE1, 0x00, 0x00, 0x0C, - 0xF5, 0x00, 0x00, 0x05, 0xFE, 0x88, 0x88, 0x81, 0x6F, 0xFF, 0xFF, 0xFF, 0x20, 0x11, 0x0D, 0xF2, - 0xBD, 0x10, 0x01, 0x03, 0xFC, 0x2E, 0xA0, 0x00, 0x00, 0x00, 0x10, 0x3F, 0xC2, 0xEA, 0x3F, 0x93, - 0xF9, 0x2F, 0x82, 0xF8, 0x2F, 0x81, 0xF7, 0x1F, 0x70, 0x00, 0x02, 0x06, 0xF9, 0x4E, 0x70, 0x00, - 0x0D, 0xB0, 0x00, 0x00, 0x0D, 0xB0, 0x00, 0x00, 0x0D, 0xB0, 0x00, 0x7F, 0xFF, 0xFF, 0xF5, 0x48, - 0x8E, 0xD8, 0x83, 0x00, 0x0D, 0xB0, 0x00, 0x00, 0x0D, 0xB0, 0x00, 0x48, 0x88, 0x88, 0x7F, 0xFF, - 0xFE, 0x00, 0x00, 0xBF, 0x10, 0x00, 0x2F, 0xA0, 0x00, 0x08, 0xF5, 0x00, 0x00, 0xDE, 0x00, 0x00, - 0x4F, 0x90, 0x00, 0x09, 0xF3, 0x00, 0x01, 0xED, 0x00, 0x00, 0x5F, 0x70, 0x00, 0x0B, 0xF2, 0x00, - 0x02, 0xFB, 0x00, 0x00, 0x7F, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x16, 0xD5, - 0x00, 0x18, 0xEF, 0xD3, 0x29, 0xFF, 0xB5, 0x00, 0x7F, 0xD3, 0x00, 0x00, 0x4D, 0xFD, 0x71, 0x00, - 0x00, 0x5C, 0xFF, 0xA2, 0x00, 0x00, 0x4B, 0xF5, 0x00, 0x00, 0x00, 0x22, 0x10, 0x00, 0x00, 0x00, - 0x7C, 0x50, 0x00, 0x00, 0x5E, 0xFD, 0x71, 0x00, 0x01, 0x6C, 0xFE, 0x81, 0x00, 0x00, 0x4E, 0xF5, - 0x00, 0x28, 0xEF, 0xC2, 0x3B, 0xFF, 0xB4, 0x00, 0x7F, 0x93, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00, - 0x00, 0x0C, 0xF1, 0x0D, 0xF0, 0x00, 0x0F, 0xD0, 0x1F, 0xC0, 0x08, 0xFF, 0xFF, 0xFF, 0xFE, 0x04, - 0xBF, 0xC8, 0xBF, 0xB7, 0x00, 0x7F, 0x60, 0x8F, 0x50, 0x00, 0x9F, 0x40, 0xAF, 0x30, 0x1F, 0xFF, - 0xFF, 0xFF, 0xF5, 0x18, 0xFE, 0x88, 0xFE, 0x83, 0x01, 0xFC, 0x02, 0xFB, 0x00, 0x03, 0xF9, 0x04, - 0xF8, 0x00, 0x0A, 0xEC, 0x20, 0x03, 0xF2, 0x00, 0x9E, 0x9C, 0xC0, 0x0B, 0x90, 0x00, 0xC6, 0x02, - 0xF1, 0x5E, 0x10, 0x00, 0x9E, 0x9C, 0xD0, 0xD7, 0x00, 0x00, 0x1A, 0xFC, 0x27, 0xD0, 0x00, 0x00, - 0x00, 0x00, 0x1E, 0x50, 0x00, 0x00, 0x00, 0x00, 0x9B, 0x08, 0xED, 0x30, 0x00, 0x03, 0xF3, 0x6E, - 0x9B, 0xE1, 0x00, 0x0B, 0x90, 0xA8, 0x00, 0xE3, 0x00, 0x5E, 0x20, 0x6E, 0x9B, 0xE1, 0x00, 0xD7, - 0x00, 0x08, 0xED, 0x30, -]; - -static FONT_SM_GLYPHS: [Glyph; 47] = [ - Glyph { ch: 32, x_off: 0, y_off: 0, w: 0, h: 0, adv: 3, offset: 0 }, - Glyph { ch: 48, x_off: 0, y_off: 0, w: 9, h: 11, adv: 9, offset: 0 }, - Glyph { ch: 49, x_off: 0, y_off: 0, w: 5, h: 11, adv: 6, offset: 50 }, - Glyph { ch: 50, x_off: 0, y_off: 0, w: 9, h: 11, adv: 9, offset: 78 }, - Glyph { ch: 51, x_off: 0, y_off: 0, w: 8, h: 11, adv: 9, offset: 128 }, - Glyph { ch: 52, x_off: 0, y_off: 0, w: 9, h: 11, adv: 9, offset: 172 }, - Glyph { ch: 53, x_off: 0, y_off: 0, w: 8, h: 11, adv: 8, offset: 222 }, - Glyph { ch: 54, x_off: 0, y_off: 0, w: 8, h: 11, adv: 8, offset: 266 }, - Glyph { ch: 55, x_off: 0, y_off: 0, w: 8, h: 11, adv: 8, offset: 310 }, - Glyph { ch: 56, x_off: 0, y_off: 0, w: 8, h: 11, adv: 9, offset: 354 }, - Glyph { ch: 57, x_off: 0, y_off: 0, w: 8, h: 11, adv: 8, offset: 398 }, - Glyph { ch: 65, x_off: 0, y_off: 0, w: 10, h: 11, adv: 10, offset: 442 }, - Glyph { ch: 66, x_off: 1, y_off: 0, w: 9, h: 11, adv: 10, offset: 497 }, - Glyph { ch: 67, x_off: 0, y_off: 0, w: 9, h: 11, adv: 10, offset: 547 }, - Glyph { ch: 68, x_off: 1, y_off: 0, w: 9, h: 11, adv: 10, offset: 597 }, - Glyph { ch: 69, x_off: 1, y_off: 0, w: 8, h: 11, adv: 9, offset: 647 }, - Glyph { ch: 70, x_off: 1, y_off: 0, w: 8, h: 11, adv: 9, offset: 691 }, - Glyph { ch: 71, x_off: 0, y_off: 0, w: 9, h: 11, adv: 10, offset: 735 }, - Glyph { ch: 72, x_off: 1, y_off: 0, w: 9, h: 11, adv: 10, offset: 785 }, - Glyph { ch: 73, x_off: 1, y_off: 0, w: 3, h: 11, adv: 4, offset: 835 }, - Glyph { ch: 74, x_off: 0, y_off: 0, w: 9, h: 11, adv: 9, offset: 852 }, - Glyph { ch: 75, x_off: 1, y_off: 0, w: 9, h: 11, adv: 10, offset: 902 }, - Glyph { ch: 76, x_off: 1, y_off: 0, w: 8, h: 11, adv: 9, offset: 952 }, - Glyph { ch: 77, x_off: 1, y_off: 0, w: 10, h: 11, adv: 11, offset: 996 }, - Glyph { ch: 78, x_off: 1, y_off: 0, w: 9, h: 11, adv: 11, offset: 1051 }, - Glyph { ch: 79, x_off: 0, y_off: 0, w: 10, h: 11, adv: 10, offset: 1101 }, - Glyph { ch: 80, x_off: 1, y_off: 0, w: 9, h: 11, adv: 10, offset: 1156 }, - Glyph { ch: 81, x_off: 0, y_off: 0, w: 9, h: 13, adv: 9, offset: 1206 }, - Glyph { ch: 82, x_off: 1, y_off: 0, w: 9, h: 11, adv: 10, offset: 1265 }, - Glyph { ch: 83, x_off: 0, y_off: 0, w: 9, h: 11, adv: 9, offset: 1315 }, - Glyph { ch: 84, x_off: 0, y_off: 0, w: 9, h: 11, adv: 9, offset: 1365 }, - Glyph { ch: 85, x_off: 1, y_off: 0, w: 9, h: 11, adv: 10, offset: 1415 }, - Glyph { ch: 86, x_off: 0, y_off: 0, w: 10, h: 11, adv: 10, offset: 1465 }, - Glyph { ch: 87, x_off: 0, y_off: 0, w: 14, h: 11, adv: 14, offset: 1520 }, - Glyph { ch: 88, x_off: 0, y_off: 0, w: 10, h: 11, adv: 10, offset: 1597 }, - Glyph { ch: 89, x_off: 0, y_off: 0, w: 10, h: 11, adv: 10, offset: 1652 }, - Glyph { ch: 90, x_off: 0, y_off: 0, w: 9, h: 11, adv: 9, offset: 1707 }, - Glyph { ch: 46, x_off: 1, y_off: 8, w: 3, h: 3, adv: 4, offset: 1757 }, - Glyph { ch: 58, x_off: 1, y_off: 3, w: 3, h: 8, adv: 6, offset: 1762 }, - Glyph { ch: 33, x_off: 1, y_off: 0, w: 3, h: 11, adv: 5, offset: 1774 }, - Glyph { ch: 43, x_off: 0, y_off: 3, w: 8, h: 7, adv: 8, offset: 1791 }, - Glyph { ch: 45, x_off: 0, y_off: 5, w: 6, h: 2, adv: 6, offset: 1819 }, - Glyph { ch: 47, x_off: 0, y_off: 0, w: 7, h: 11, adv: 7, offset: 1825 }, - Glyph { ch: 60, x_off: 0, y_off: 2, w: 8, h: 9, adv: 8, offset: 1864 }, - Glyph { ch: 62, x_off: 0, y_off: 2, w: 8, h: 9, adv: 8, offset: 1900 }, - Glyph { ch: 35, x_off: 0, y_off: 1, w: 10, h: 10, adv: 11, offset: 1936 }, - Glyph { ch: 37, x_off: 1, y_off: 0, w: 12, h: 11, adv: 13, offset: 1986 }, -]; - -pub static FONT_SM: Font = Font { glyphs: &FONT_SM_GLYPHS, data: &FONT_SM_DATA }; - -static FONT_MD_DATA: [u8; 3974] = [ - 0x00, 0x5B, 0xEF, 0xD8, 0x10, 0x00, 0x9F, 0xFF, 0xFF, 0xFE, 0x20, 0x4F, 0xFD, 0x75, 0xAF, 0xFB, - 0x0A, 0xFF, 0x20, 0x00, 0x9F, 0xF2, 0xCF, 0xC0, 0x00, 0x05, 0xFF, 0x4C, 0xFC, 0x00, 0x00, 0x4F, - 0xF4, 0xCF, 0xC0, 0x00, 0x04, 0xFF, 0x4C, 0xFC, 0x00, 0x00, 0x4F, 0xF4, 0xCF, 0xC0, 0x00, 0x04, - 0xFF, 0x4C, 0xFC, 0x00, 0x00, 0x4F, 0xF4, 0xCF, 0xC0, 0x00, 0x04, 0xFF, 0x4C, 0xFC, 0x00, 0x00, - 0x5F, 0xF4, 0x9F, 0xF2, 0x00, 0x09, 0xFF, 0x24, 0xFF, 0xD7, 0x5A, 0xFF, 0xB0, 0x09, 0xFF, 0xFF, - 0xFF, 0xE2, 0x00, 0x05, 0xBE, 0xFD, 0x91, 0x00, 0x00, 0x6D, 0xFF, 0x30, 0xDF, 0xFF, 0xF3, 0x0F, - 0xFD, 0xFF, 0x30, 0x51, 0x5F, 0xF3, 0x00, 0x05, 0xFF, 0x30, 0x00, 0x5F, 0xF3, 0x00, 0x05, 0xFF, - 0x30, 0x00, 0x5F, 0xF3, 0x00, 0x05, 0xFF, 0x30, 0x00, 0x5F, 0xF3, 0x00, 0x05, 0xFF, 0x30, 0x00, - 0x5F, 0xF3, 0x00, 0x05, 0xFF, 0x30, 0x00, 0x5F, 0xF3, 0x00, 0x05, 0xFF, 0x30, 0x00, 0x5F, 0xF3, - 0x01, 0x7C, 0xEE, 0xB5, 0x00, 0x01, 0xCF, 0xFF, 0xFF, 0xF9, 0x00, 0x9F, 0xFB, 0x66, 0xDF, 0xF4, - 0x0D, 0xFD, 0x00, 0x02, 0xFF, 0x90, 0xFF, 0x90, 0x00, 0x0D, 0xFA, 0x04, 0x42, 0x00, 0x02, 0xFF, - 0x80, 0x00, 0x00, 0x00, 0xBF, 0xF3, 0x00, 0x00, 0x00, 0x7F, 0xF9, 0x00, 0x00, 0x00, 0x4F, 0xFD, - 0x10, 0x00, 0x00, 0x2E, 0xFE, 0x30, 0x00, 0x00, 0x1D, 0xFF, 0x50, 0x00, 0x00, 0x0B, 0xFF, 0x60, - 0x00, 0x00, 0x09, 0xFF, 0x80, 0x00, 0x00, 0x08, 0xFF, 0xD5, 0x55, 0x55, 0x50, 0xEF, 0xFF, 0xFF, - 0xFF, 0xFF, 0x1D, 0xFF, 0xFF, 0xFF, 0xFF, 0xF1, 0x0D, 0xFF, 0xFF, 0xFF, 0xFF, 0x60, 0xEF, 0xFF, - 0xFF, 0xFF, 0xF6, 0x04, 0x55, 0x55, 0x8F, 0xFF, 0x40, 0x00, 0x00, 0x3E, 0xFF, 0x60, 0x00, 0x00, - 0x3E, 0xFF, 0x70, 0x00, 0x00, 0x3E, 0xFF, 0x70, 0x00, 0x00, 0x09, 0xFF, 0xFE, 0x80, 0x00, 0x00, - 0x1D, 0x9A, 0xFF, 0xA0, 0x00, 0x00, 0x00, 0x08, 0xFF, 0x20, 0x00, 0x00, 0x00, 0x2F, 0xF6, 0x04, - 0x41, 0x00, 0x01, 0xFF, 0x81, 0xFF, 0x80, 0x00, 0x1F, 0xF8, 0x0E, 0xFC, 0x00, 0x06, 0xFF, 0x50, - 0x7F, 0xFA, 0x57, 0xEF, 0xD1, 0x01, 0xBF, 0xFF, 0xFF, 0xF4, 0x00, 0x01, 0x7C, 0xEE, 0xA3, 0x00, - 0x00, 0x00, 0x1E, 0xF9, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xF3, 0x00, 0x00, 0x00, 0x00, 0xEF, 0xC0, - 0x00, 0x00, 0x00, 0x05, 0xFF, 0x50, 0x00, 0x00, 0x00, 0x0C, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x3F, - 0xF8, 0x00, 0x00, 0x00, 0x00, 0xAF, 0xF1, 0x01, 0xFF, 0x60, 0x01, 0xFF, 0xA0, 0x02, 0xFF, 0x70, - 0x07, 0xFF, 0x30, 0x02, 0xFF, 0x70, 0x0E, 0xFE, 0x66, 0x67, 0xFF, 0xA4, 0x2F, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFB, 0x2F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFB, 0x00, 0x00, 0x00, 0x02, 0xFF, 0x70, 0x00, 0x00, - 0x00, 0x02, 0xFF, 0x70, 0x00, 0x00, 0x00, 0x02, 0xFF, 0x70, 0x00, 0x00, 0x00, 0x01, 0xFF, 0x70, - 0xDF, 0xFF, 0xFF, 0xFF, 0xF3, 0xDF, 0xFF, 0xFF, 0xFF, 0xF4, 0xDF, 0xC5, 0x55, 0x55, 0x51, 0xDF, - 0xA0, 0x00, 0x00, 0x00, 0xDF, 0xA0, 0x00, 0x00, 0x00, 0xDF, 0xA0, 0x34, 0x20, 0x00, 0xDF, 0xDD, - 0xFF, 0xFB, 0x20, 0xDF, 0xFF, 0xFF, 0xFF, 0xD0, 0xDF, 0xF7, 0x11, 0x9F, 0xF6, 0x67, 0x60, 0x00, - 0x1F, 0xFA, 0x00, 0x00, 0x00, 0x0D, 0xFC, 0x78, 0x60, 0x00, 0x0E, 0xFB, 0xAF, 0xF1, 0x00, 0x3F, - 0xF9, 0x4F, 0xFC, 0x66, 0xEF, 0xF3, 0x09, 0xFF, 0xFF, 0xFF, 0x70, 0x00, 0x5C, 0xEE, 0xB4, 0x00, - 0x01, 0x8D, 0xEE, 0xB5, 0x00, 0x1D, 0xFF, 0xFF, 0xFF, 0x80, 0x8F, 0xFB, 0x67, 0xEF, 0xF2, 0xCF, - 0xD0, 0x00, 0x5F, 0xF6, 0xDF, 0xA0, 0x00, 0x18, 0x83, 0xDF, 0xA0, 0x24, 0x20, 0x00, 0xDF, 0xCC, - 0xFF, 0xFB, 0x20, 0xDF, 0xFF, 0xFF, 0xFF, 0xD1, 0xDF, 0xF8, 0x11, 0xAF, 0xF6, 0xDF, 0xD0, 0x00, - 0x1E, 0xFA, 0xDF, 0xB0, 0x00, 0x0C, 0xFB, 0xCF, 0xB0, 0x00, 0x0D, 0xFB, 0xAF, 0xE1, 0x00, 0x3F, - 0xF8, 0x4F, 0xFC, 0x66, 0xDF, 0xF3, 0x09, 0xFF, 0xFF, 0xFF, 0x80, 0x00, 0x6C, 0xEE, 0xB5, 0x00, - 0x6F, 0xFF, 0xFF, 0xFF, 0xFF, 0x56, 0xFF, 0xFF, 0xFF, 0xFF, 0xF5, 0x6F, 0xC5, 0x55, 0x5A, 0xFF, - 0x44, 0xB7, 0x00, 0x00, 0xCF, 0xE0, 0x00, 0x00, 0x00, 0x2F, 0xF8, 0x00, 0x00, 0x00, 0x08, 0xFF, - 0x30, 0x00, 0x00, 0x00, 0xDF, 0xC0, 0x00, 0x00, 0x00, 0x4F, 0xF7, 0x00, 0x00, 0x00, 0x09, 0xFF, - 0x20, 0x00, 0x00, 0x01, 0xEF, 0xB0, 0x00, 0x00, 0x00, 0x5F, 0xF6, 0x00, 0x00, 0x00, 0x0B, 0xFE, - 0x10, 0x00, 0x00, 0x01, 0xFF, 0xA0, 0x00, 0x00, 0x00, 0x7F, 0xF4, 0x00, 0x00, 0x00, 0x0C, 0xFE, - 0x00, 0x00, 0x00, 0x02, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x07, 0xCE, 0xEB, 0x50, 0x00, 0x0B, 0xFF, - 0xFF, 0xFF, 0x70, 0x06, 0xFF, 0xC6, 0x7E, 0xFF, 0x20, 0xBF, 0xD0, 0x00, 0x3F, 0xF6, 0x0B, 0xFC, - 0x00, 0x01, 0xFF, 0x70, 0x8F, 0xF7, 0x12, 0xAF, 0xF3, 0x01, 0xDF, 0xFF, 0xFF, 0xF8, 0x00, 0x09, - 0xFF, 0xFF, 0xFF, 0x40, 0x06, 0xFF, 0xC6, 0x6D, 0xFE, 0x20, 0xCF, 0xD1, 0x00, 0x3F, 0xF7, 0x0F, - 0xFA, 0x00, 0x00, 0xEF, 0xA0, 0xFF, 0xA0, 0x00, 0x0E, 0xFA, 0x0C, 0xFD, 0x10, 0x03, 0xFF, 0x80, - 0x7F, 0xFC, 0x67, 0xEF, 0xF3, 0x00, 0xCF, 0xFF, 0xFF, 0xF7, 0x00, 0x00, 0x7C, 0xEE, 0xB5, 0x00, - 0x00, 0x18, 0xDF, 0xDA, 0x30, 0x00, 0x1D, 0xFF, 0xFF, 0xFE, 0x40, 0x09, 0xFF, 0xA5, 0x7E, 0xFD, - 0x00, 0xEF, 0xB0, 0x00, 0x6F, 0xF4, 0x2F, 0xF6, 0x00, 0x02, 0xFF, 0x72, 0xFF, 0x60, 0x00, 0x2F, - 0xF7, 0x1F, 0xFB, 0x00, 0x06, 0xFF, 0x80, 0xAF, 0xFA, 0x57, 0xEF, 0xF8, 0x02, 0xEF, 0xFF, 0xFF, - 0xFF, 0x80, 0x02, 0xAE, 0xEB, 0x4F, 0xF8, 0x00, 0x00, 0x00, 0x01, 0xFF, 0x80, 0x9C, 0x80, 0x00, - 0x1F, 0xF7, 0x0B, 0xFE, 0x10, 0x05, 0xFF, 0x60, 0x7F, 0xFB, 0x67, 0xEF, 0xF3, 0x01, 0xCF, 0xFF, - 0xFF, 0xF8, 0x00, 0x01, 0x8D, 0xFE, 0xB5, 0x00, 0x00, 0x00, 0x09, 0xFF, 0xD0, 0x00, 0x00, 0x00, - 0x00, 0x0E, 0xFF, 0xF3, 0x00, 0x00, 0x00, 0x00, 0x4F, 0xFF, 0xF7, 0x00, 0x00, 0x00, 0x00, 0x8F, - 0xFD, 0xFC, 0x00, 0x00, 0x00, 0x00, 0xDF, 0xB8, 0xFF, 0x20, 0x00, 0x00, 0x03, 0xFF, 0x63, 0xFF, - 0x60, 0x00, 0x00, 0x07, 0xFF, 0x20, 0xDF, 0xB0, 0x00, 0x00, 0x0C, 0xFC, 0x00, 0x9F, 0xF1, 0x00, - 0x00, 0x2F, 0xF8, 0x00, 0x4F, 0xF5, 0x00, 0x00, 0x6F, 0xF3, 0x00, 0x0E, 0xFA, 0x00, 0x00, 0xBF, - 0xE0, 0x00, 0x0A, 0xFE, 0x00, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x40, 0x05, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0x90, 0x0A, 0xFF, 0x22, 0x22, 0x22, 0xCF, 0xD0, 0x0E, 0xFB, 0x00, 0x00, 0x00, 0x7F, - 0xF3, 0x3F, 0xF7, 0x00, 0x00, 0x00, 0x3F, 0xF7, 0x6F, 0xFF, 0xFF, 0xFD, 0xA3, 0x00, 0x6F, 0xFF, - 0xFF, 0xFF, 0xFF, 0x50, 0x6F, 0xF6, 0x55, 0x59, 0xFF, 0xD0, 0x6F, 0xF2, 0x00, 0x00, 0x8F, 0xF2, - 0x6F, 0xF2, 0x00, 0x00, 0x4F, 0xF3, 0x6F, 0xF2, 0x00, 0x00, 0x8F, 0xF1, 0x6F, 0xF6, 0x55, 0x59, - 0xFF, 0x90, 0x6F, 0xFF, 0xFF, 0xFF, 0xF8, 0x00, 0x6F, 0xFF, 0xFF, 0xFF, 0xFE, 0x40, 0x6F, 0xF2, - 0x00, 0x04, 0xDF, 0xE1, 0x6F, 0xF2, 0x00, 0x00, 0x4F, 0xF5, 0x6F, 0xF2, 0x00, 0x00, 0x2F, 0xF6, - 0x6F, 0xF2, 0x00, 0x00, 0x6F, 0xF5, 0x6F, 0xF6, 0x55, 0x58, 0xFF, 0xF1, 0x6F, 0xFF, 0xFF, 0xFF, - 0xFF, 0x60, 0x6F, 0xFF, 0xFF, 0xFE, 0xA3, 0x00, 0x00, 0x29, 0xDF, 0xEB, 0x60, 0x00, 0x05, 0xEF, - 0xFF, 0xFF, 0xFB, 0x00, 0x2E, 0xFF, 0x95, 0x7C, 0xFF, 0x80, 0x7F, 0xF5, 0x00, 0x00, 0xCF, 0xE1, - 0xAF, 0xE0, 0x00, 0x00, 0x6F, 0xF3, 0xBF, 0xC0, 0x00, 0x00, 0x26, 0x61, 0xCF, 0xC0, 0x00, 0x00, - 0x00, 0x00, 0xCF, 0xC0, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xC0, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xC0, - 0x00, 0x00, 0x00, 0x00, 0xBF, 0xC0, 0x00, 0x00, 0x16, 0x61, 0xAF, 0xE0, 0x00, 0x00, 0x6F, 0xF3, - 0x7F, 0xF5, 0x00, 0x00, 0xCF, 0xE1, 0x2E, 0xFF, 0x95, 0x6C, 0xFF, 0x80, 0x04, 0xEF, 0xFF, 0xFF, - 0xFB, 0x00, 0x00, 0x29, 0xDF, 0xEB, 0x60, 0x00, 0x6F, 0xFF, 0xFF, 0xFD, 0x92, 0x00, 0x6F, 0xFF, - 0xFF, 0xFF, 0xFE, 0x40, 0x6F, 0xF6, 0x55, 0x59, 0xFF, 0xE0, 0x6F, 0xF2, 0x00, 0x00, 0x8F, 0xF5, - 0x6F, 0xF2, 0x00, 0x00, 0x3F, 0xF7, 0x6F, 0xF2, 0x00, 0x00, 0x1F, 0xF7, 0x6F, 0xF2, 0x00, 0x00, - 0x1F, 0xF7, 0x6F, 0xF2, 0x00, 0x00, 0x1F, 0xF7, 0x6F, 0xF2, 0x00, 0x00, 0x1F, 0xF7, 0x6F, 0xF2, - 0x00, 0x00, 0x1F, 0xF7, 0x6F, 0xF2, 0x00, 0x00, 0x1F, 0xF7, 0x6F, 0xF2, 0x00, 0x00, 0x3F, 0xF7, - 0x6F, 0xF2, 0x00, 0x00, 0x8F, 0xF5, 0x6F, 0xF6, 0x55, 0x59, 0xFF, 0xE0, 0x6F, 0xFF, 0xFF, 0xFF, - 0xFE, 0x40, 0x6F, 0xFF, 0xFF, 0xFD, 0x92, 0x00, 0x6F, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0x6F, 0xFF, - 0xFF, 0xFF, 0xFF, 0xF0, 0x6F, 0xF6, 0x55, 0x55, 0x55, 0x40, 0x6F, 0xF2, 0x00, 0x00, 0x00, 0x00, - 0x6F, 0xF2, 0x00, 0x00, 0x00, 0x00, 0x6F, 0xF2, 0x00, 0x00, 0x00, 0x00, 0x6F, 0xF6, 0x55, 0x55, - 0x20, 0x00, 0x6F, 0xFF, 0xFF, 0xFF, 0x80, 0x00, 0x6F, 0xFF, 0xFF, 0xFF, 0x80, 0x00, 0x6F, 0xF2, - 0x00, 0x00, 0x00, 0x00, 0x6F, 0xF2, 0x00, 0x00, 0x00, 0x00, 0x6F, 0xF2, 0x00, 0x00, 0x00, 0x00, - 0x6F, 0xF2, 0x00, 0x00, 0x00, 0x00, 0x6F, 0xF6, 0x55, 0x55, 0x55, 0x40, 0x6F, 0xFF, 0xFF, 0xFF, - 0xFF, 0xF0, 0x6F, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0x6F, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0x6F, 0xFF, - 0xFF, 0xFF, 0xFF, 0xF0, 0x6F, 0xF6, 0x55, 0x55, 0x55, 0x40, 0x6F, 0xF2, 0x00, 0x00, 0x00, 0x00, - 0x6F, 0xF2, 0x00, 0x00, 0x00, 0x00, 0x6F, 0xF2, 0x00, 0x00, 0x00, 0x00, 0x6F, 0xF6, 0x55, 0x55, - 0x20, 0x00, 0x6F, 0xFF, 0xFF, 0xFF, 0x80, 0x00, 0x6F, 0xFF, 0xFF, 0xFF, 0x80, 0x00, 0x6F, 0xF2, - 0x00, 0x00, 0x00, 0x00, 0x6F, 0xF2, 0x00, 0x00, 0x00, 0x00, 0x6F, 0xF2, 0x00, 0x00, 0x00, 0x00, - 0x6F, 0xF2, 0x00, 0x00, 0x00, 0x00, 0x6F, 0xF2, 0x00, 0x00, 0x00, 0x00, 0x6F, 0xF2, 0x00, 0x00, - 0x00, 0x00, 0x6F, 0xF2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x29, 0xDF, 0xEB, 0x60, 0x00, 0x04, 0xEF, - 0xFF, 0xFF, 0xFC, 0x10, 0x1E, 0xFF, 0x95, 0x6C, 0xFF, 0x90, 0x7F, 0xF5, 0x00, 0x00, 0xBF, 0xF1, - 0xAF, 0xE0, 0x00, 0x00, 0x5F, 0xF3, 0xBF, 0xC0, 0x00, 0x00, 0x02, 0x20, 0xCF, 0xC0, 0x00, 0x00, - 0x00, 0x00, 0xCF, 0xC0, 0x05, 0xFF, 0xFF, 0xF3, 0xCF, 0xC0, 0x06, 0xFF, 0xFF, 0xF4, 0xCF, 0xC0, - 0x01, 0x55, 0x8F, 0xF4, 0xBF, 0xC0, 0x00, 0x00, 0x4F, 0xF3, 0xAF, 0xE0, 0x00, 0x00, 0x6F, 0xF2, - 0x7F, 0xF6, 0x00, 0x00, 0xBF, 0xD0, 0x1E, 0xFF, 0x96, 0x6C, 0xFF, 0x70, 0x04, 0xEF, 0xFF, 0xFF, - 0xFA, 0x00, 0x00, 0x29, 0xDF, 0xEB, 0x60, 0x00, 0x6F, 0xF2, 0x00, 0x00, 0x0F, 0xF8, 0x6F, 0xF2, - 0x00, 0x00, 0x0F, 0xF8, 0x6F, 0xF2, 0x00, 0x00, 0x0F, 0xF8, 0x6F, 0xF2, 0x00, 0x00, 0x0F, 0xF8, - 0x6F, 0xF2, 0x00, 0x00, 0x0F, 0xF8, 0x6F, 0xF2, 0x00, 0x00, 0x0F, 0xF8, 0x6F, 0xF6, 0x55, 0x55, - 0x5F, 0xF8, 0x6F, 0xFF, 0xFF, 0xFF, 0xFF, 0xF8, 0x6F, 0xFF, 0xFF, 0xFF, 0xFF, 0xF8, 0x6F, 0xF2, - 0x00, 0x00, 0x0F, 0xF8, 0x6F, 0xF2, 0x00, 0x00, 0x0F, 0xF8, 0x6F, 0xF2, 0x00, 0x00, 0x0F, 0xF8, - 0x6F, 0xF2, 0x00, 0x00, 0x0F, 0xF8, 0x6F, 0xF2, 0x00, 0x00, 0x0F, 0xF8, 0x6F, 0xF2, 0x00, 0x00, - 0x0F, 0xF8, 0x6F, 0xF2, 0x00, 0x00, 0x0F, 0xF8, 0x5F, 0xF2, 0x6F, 0xF2, 0x6F, 0xF2, 0x6F, 0xF2, - 0x6F, 0xF2, 0x6F, 0xF2, 0x6F, 0xF2, 0x6F, 0xF2, 0x6F, 0xF2, 0x6F, 0xF2, 0x6F, 0xF2, 0x6F, 0xF2, - 0x6F, 0xF2, 0x6F, 0xF2, 0x6F, 0xF2, 0x6F, 0xF2, 0x00, 0x00, 0x00, 0x00, 0x5F, 0xF2, 0x00, 0x00, - 0x00, 0x00, 0x5F, 0xF3, 0x00, 0x00, 0x00, 0x00, 0x5F, 0xF3, 0x00, 0x00, 0x00, 0x00, 0x5F, 0xF3, - 0x00, 0x00, 0x00, 0x00, 0x5F, 0xF3, 0x00, 0x00, 0x00, 0x00, 0x5F, 0xF3, 0x00, 0x00, 0x00, 0x00, - 0x5F, 0xF3, 0x00, 0x00, 0x00, 0x00, 0x5F, 0xF3, 0x00, 0x00, 0x00, 0x00, 0x5F, 0xF3, 0x6C, 0xC0, - 0x00, 0x00, 0x5F, 0xF3, 0x8F, 0xF0, 0x00, 0x00, 0x5F, 0xF3, 0x7F, 0xF2, 0x00, 0x00, 0x7F, 0xF2, - 0x4F, 0xF8, 0x00, 0x00, 0xCF, 0xE0, 0x0D, 0xFF, 0xA6, 0x6C, 0xFF, 0x80, 0x03, 0xEF, 0xFF, 0xFF, - 0xFB, 0x00, 0x00, 0x28, 0xDE, 0xEB, 0x60, 0x00, 0x5F, 0xF2, 0x00, 0x00, 0x4F, 0xF9, 0x06, 0xFF, - 0x20, 0x00, 0x2E, 0xFD, 0x10, 0x6F, 0xF2, 0x00, 0x1C, 0xFE, 0x20, 0x06, 0xFF, 0x20, 0x0A, 0xFF, - 0x50, 0x00, 0x6F, 0xF2, 0x07, 0xFF, 0x80, 0x00, 0x06, 0xFF, 0x25, 0xFF, 0xB0, 0x00, 0x00, 0x6F, - 0xF5, 0xEF, 0xE1, 0x00, 0x00, 0x06, 0xFF, 0xEF, 0xFE, 0x20, 0x00, 0x00, 0x6F, 0xFF, 0xFF, 0xFA, - 0x00, 0x00, 0x06, 0xFF, 0xF5, 0xAF, 0xF4, 0x00, 0x00, 0x6F, 0xF7, 0x01, 0xEF, 0xD1, 0x00, 0x06, - 0xFF, 0x20, 0x06, 0xFF, 0x80, 0x00, 0x6F, 0xF2, 0x00, 0x0B, 0xFF, 0x30, 0x06, 0xFF, 0x20, 0x00, - 0x2F, 0xFC, 0x00, 0x6F, 0xF2, 0x00, 0x00, 0x7F, 0xF6, 0x06, 0xFF, 0x20, 0x00, 0x00, 0xCF, 0xE1, - 0x5F, 0xF2, 0x00, 0x00, 0x00, 0x06, 0xFF, 0x20, 0x00, 0x00, 0x00, 0x6F, 0xF2, 0x00, 0x00, 0x00, - 0x06, 0xFF, 0x20, 0x00, 0x00, 0x00, 0x6F, 0xF2, 0x00, 0x00, 0x00, 0x06, 0xFF, 0x20, 0x00, 0x00, - 0x00, 0x6F, 0xF2, 0x00, 0x00, 0x00, 0x06, 0xFF, 0x20, 0x00, 0x00, 0x00, 0x6F, 0xF2, 0x00, 0x00, - 0x00, 0x06, 0xFF, 0x20, 0x00, 0x00, 0x00, 0x6F, 0xF2, 0x00, 0x00, 0x00, 0x06, 0xFF, 0x20, 0x00, - 0x00, 0x00, 0x6F, 0xF2, 0x00, 0x00, 0x00, 0x06, 0xFF, 0x65, 0x55, 0x55, 0x54, 0x6F, 0xFF, 0xFF, - 0xFF, 0xFF, 0xE6, 0xFF, 0xFF, 0xFF, 0xFF, 0xFD, 0x5F, 0xF6, 0x00, 0x00, 0x00, 0xAF, 0xF2, 0x6F, - 0xFE, 0x10, 0x00, 0x05, 0xFF, 0xF2, 0x6F, 0xFF, 0xA0, 0x00, 0x1D, 0xFF, 0xF2, 0x6F, 0xFF, 0xF4, - 0x00, 0x9F, 0xFF, 0xF2, 0x6F, 0xFF, 0xFD, 0x13, 0xFF, 0xEF, 0xF2, 0x6F, 0xF6, 0xFF, 0x9C, 0xFE, - 0x8F, 0xF2, 0x6F, 0xF2, 0xAF, 0xFF, 0xF6, 0x6F, 0xF2, 0x6F, 0xF2, 0x1E, 0xFF, 0xB0, 0x6F, 0xF2, - 0x6F, 0xF2, 0x05, 0xFE, 0x20, 0x6F, 0xF2, 0x6F, 0xF2, 0x00, 0x43, 0x00, 0x6F, 0xF2, 0x6F, 0xF2, - 0x00, 0x00, 0x00, 0x6F, 0xF2, 0x6F, 0xF2, 0x00, 0x00, 0x00, 0x6F, 0xF2, 0x6F, 0xF2, 0x00, 0x00, - 0x00, 0x6F, 0xF2, 0x6F, 0xF2, 0x00, 0x00, 0x00, 0x6F, 0xF2, 0x6F, 0xF2, 0x00, 0x00, 0x00, 0x6F, - 0xF2, 0x6F, 0xF2, 0x00, 0x00, 0x00, 0x6F, 0xF2, 0x5F, 0xF5, 0x00, 0x00, 0x06, 0xFF, 0x16, 0xFF, - 0xD0, 0x00, 0x00, 0x7F, 0xF2, 0x6F, 0xFF, 0x70, 0x00, 0x07, 0xFF, 0x26, 0xFF, 0xFE, 0x20, 0x00, - 0x7F, 0xF2, 0x6F, 0xFF, 0xFA, 0x00, 0x07, 0xFF, 0x26, 0xFF, 0x9F, 0xF4, 0x00, 0x6F, 0xF2, 0x6F, - 0xF2, 0xDF, 0xC0, 0x06, 0xFF, 0x26, 0xFF, 0x25, 0xFF, 0x60, 0x6F, 0xF2, 0x6F, 0xF2, 0x0B, 0xFE, - 0x16, 0xFF, 0x26, 0xFF, 0x20, 0x2F, 0xF9, 0x6F, 0xF2, 0x6F, 0xF2, 0x00, 0x8F, 0xF9, 0xFF, 0x26, - 0xFF, 0x20, 0x01, 0xEF, 0xFF, 0xF2, 0x6F, 0xF2, 0x00, 0x06, 0xFF, 0xFF, 0x26, 0xFF, 0x20, 0x00, - 0x0C, 0xFF, 0xF2, 0x6F, 0xF2, 0x00, 0x00, 0x3F, 0xFF, 0x26, 0xFF, 0x20, 0x00, 0x00, 0x9F, 0xF1, - 0x00, 0x18, 0xDE, 0xEB, 0x60, 0x00, 0x03, 0xEF, 0xFF, 0xFF, 0xFB, 0x10, 0x1D, 0xFF, 0x96, 0x7C, - 0xFF, 0x90, 0x6F, 0xF6, 0x00, 0x00, 0xBF, 0xF2, 0xAF, 0xE0, 0x00, 0x00, 0x4F, 0xF5, 0xBF, 0xC0, - 0x00, 0x00, 0x2F, 0xF6, 0xCF, 0xC0, 0x00, 0x00, 0x2F, 0xF7, 0xCF, 0xC0, 0x00, 0x00, 0x2F, 0xF7, - 0xCF, 0xC0, 0x00, 0x00, 0x2F, 0xF7, 0xCF, 0xC0, 0x00, 0x00, 0x2F, 0xF7, 0xBF, 0xC0, 0x00, 0x00, - 0x2F, 0xF6, 0xAF, 0xE0, 0x00, 0x00, 0x4F, 0xF5, 0x6F, 0xF6, 0x00, 0x00, 0xBF, 0xF1, 0x1E, 0xFF, - 0x96, 0x6C, 0xFF, 0x90, 0x03, 0xEF, 0xFF, 0xFF, 0xFB, 0x10, 0x00, 0x28, 0xDE, 0xEC, 0x60, 0x00, - 0x8F, 0xFF, 0xFF, 0xFE, 0xA3, 0x00, 0x8F, 0xFF, 0xFF, 0xFF, 0xFF, 0x50, 0x8F, 0xF5, 0x55, 0x59, - 0xFF, 0xE0, 0x8F, 0xF0, 0x00, 0x00, 0x7F, 0xF4, 0x8F, 0xF0, 0x00, 0x00, 0x2F, 0xF6, 0x8F, 0xF0, - 0x00, 0x00, 0x4F, 0xF5, 0x8F, 0xF1, 0x00, 0x04, 0xDF, 0xF2, 0x8F, 0xFF, 0xFF, 0xFF, 0xFF, 0x80, - 0x8F, 0xFF, 0xFF, 0xFF, 0xE8, 0x00, 0x8F, 0xF5, 0x55, 0x53, 0x10, 0x00, 0x8F, 0xF0, 0x00, 0x00, - 0x00, 0x00, 0x8F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x8F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x8F, 0xF0, - 0x00, 0x00, 0x00, 0x00, 0x8F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x8F, 0xF0, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x3A, 0xDF, 0xD9, 0x20, 0x00, 0x6F, 0xFF, 0xFF, 0xFE, 0x50, 0x3F, 0xFE, 0x85, 0x8F, 0xFE, - 0x29, 0xFF, 0x30, 0x00, 0x4F, 0xF7, 0xDF, 0xB0, 0x00, 0x00, 0xCF, 0xBE, 0xF9, 0x00, 0x00, 0x0A, - 0xFD, 0xFF, 0x90, 0x00, 0x00, 0xAF, 0xDF, 0xF9, 0x00, 0x00, 0x0A, 0xFD, 0xFF, 0x90, 0x00, 0x00, - 0xAF, 0xDF, 0xF9, 0x00, 0x00, 0x0A, 0xFD, 0xFF, 0x90, 0x00, 0x00, 0xAF, 0xDE, 0xFA, 0x00, 0x00, - 0x0C, 0xFD, 0xCF, 0xE1, 0x00, 0x02, 0xEF, 0xB8, 0xFF, 0xB3, 0x13, 0xCF, 0xF6, 0x1D, 0xFF, 0xFF, - 0xFF, 0xFC, 0x00, 0x2C, 0xFF, 0xFF, 0xFB, 0x10, 0x00, 0x04, 0xEF, 0xD3, 0x00, 0x00, 0x00, 0x0C, - 0xFB, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xB0, 0x00, 0x00, 0x6F, 0xFF, 0xFF, 0xFE, 0xB4, 0x00, 0x6F, - 0xFF, 0xFF, 0xFF, 0xFF, 0x50, 0x6F, 0xF6, 0x55, 0x58, 0xFF, 0xE0, 0x6F, 0xF2, 0x00, 0x00, 0x6F, - 0xF5, 0x6F, 0xF2, 0x00, 0x00, 0x2F, 0xF6, 0x6F, 0xF2, 0x00, 0x00, 0x4F, 0xF6, 0x6F, 0xF2, 0x00, - 0x03, 0xDF, 0xF2, 0x6F, 0xFF, 0xFF, 0xFF, 0xFF, 0xA0, 0x6F, 0xFF, 0xFF, 0xFF, 0xF9, 0x00, 0x6F, - 0xF6, 0x55, 0xDF, 0x90, 0x00, 0x6F, 0xF2, 0x00, 0x7F, 0xF1, 0x00, 0x6F, 0xF2, 0x00, 0x1E, 0xF8, - 0x00, 0x6F, 0xF2, 0x00, 0x08, 0xFE, 0x10, 0x6F, 0xF2, 0x00, 0x02, 0xFF, 0x80, 0x6F, 0xF2, 0x00, - 0x00, 0xAF, 0xE1, 0x6F, 0xF2, 0x00, 0x00, 0x3F, 0xF7, 0x00, 0x06, 0xCE, 0xFD, 0xA4, 0x00, 0x00, - 0x0B, 0xFF, 0xFF, 0xFF, 0xF8, 0x00, 0x07, 0xFF, 0xC6, 0x58, 0xEF, 0xF5, 0x00, 0xBF, 0xD0, 0x00, - 0x02, 0xEF, 0xB0, 0x0C, 0xFB, 0x00, 0x00, 0x0A, 0xFD, 0x00, 0x9F, 0xF4, 0x00, 0x00, 0x24, 0x40, - 0x02, 0xEF, 0xFA, 0x40, 0x00, 0x00, 0x00, 0x03, 0xCF, 0xFF, 0xD7, 0x10, 0x00, 0x00, 0x00, 0x4B, - 0xFF, 0xFE, 0x60, 0x00, 0x00, 0x00, 0x02, 0x8E, 0xFF, 0x50, 0x05, 0x52, 0x00, 0x00, 0x2D, 0xFD, - 0x01, 0xFF, 0x70, 0x00, 0x00, 0x8F, 0xF0, 0x0E, 0xFC, 0x10, 0x00, 0x0C, 0xFE, 0x00, 0x8F, 0xFD, - 0x75, 0x6B, 0xFF, 0x90, 0x01, 0xBF, 0xFF, 0xFF, 0xFF, 0xC1, 0x00, 0x00, 0x5B, 0xEF, 0xEC, 0x70, - 0x00, 0x3F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0x4F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x15, 0x55, 0x5F, - 0xFB, 0x55, 0x54, 0x00, 0x00, 0x0F, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xF8, 0x00, 0x00, 0x00, - 0x00, 0x0F, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xF8, 0x00, - 0x00, 0x00, 0x00, 0x0F, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x0F, - 0xF8, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xF8, 0x00, 0x00, 0x00, - 0x00, 0x0F, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x0E, 0xF8, 0x00, - 0x00, 0x8F, 0xF0, 0x00, 0x00, 0x0F, 0xF7, 0x8F, 0xF0, 0x00, 0x00, 0x0F, 0xF8, 0x8F, 0xF0, 0x00, - 0x00, 0x0F, 0xF8, 0x8F, 0xF0, 0x00, 0x00, 0x0F, 0xF8, 0x8F, 0xF0, 0x00, 0x00, 0x0F, 0xF8, 0x8F, - 0xF0, 0x00, 0x00, 0x0F, 0xF8, 0x8F, 0xF0, 0x00, 0x00, 0x0F, 0xF8, 0x8F, 0xF0, 0x00, 0x00, 0x0F, - 0xF8, 0x8F, 0xF0, 0x00, 0x00, 0x0F, 0xF8, 0x8F, 0xF0, 0x00, 0x00, 0x0F, 0xF8, 0x8F, 0xF1, 0x00, - 0x00, 0x1F, 0xF8, 0x7F, 0xF3, 0x00, 0x00, 0x3F, 0xF6, 0x3F, 0xF9, 0x00, 0x00, 0x9F, 0xF3, 0x0C, - 0xFF, 0xB6, 0x6B, 0xFF, 0xC0, 0x02, 0xDF, 0xFF, 0xFF, 0xFD, 0x20, 0x00, 0x17, 0xCE, 0xEC, 0x71, - 0x00, 0x3F, 0xF7, 0x00, 0x00, 0x00, 0xEF, 0xA0, 0xEF, 0xB0, 0x00, 0x00, 0x4F, 0xF6, 0x0A, 0xFF, - 0x10, 0x00, 0x08, 0xFF, 0x20, 0x5F, 0xF4, 0x00, 0x00, 0xCF, 0xC0, 0x01, 0xFF, 0x80, 0x00, 0x1F, - 0xF7, 0x00, 0x0C, 0xFD, 0x00, 0x05, 0xFF, 0x30, 0x00, 0x7F, 0xF2, 0x00, 0x9F, 0xD0, 0x00, 0x03, - 0xFF, 0x60, 0x0E, 0xF9, 0x00, 0x00, 0x0D, 0xFA, 0x03, 0xFF, 0x40, 0x00, 0x00, 0x9F, 0xE0, 0x7F, - 0xE0, 0x00, 0x00, 0x04, 0xFF, 0x3B, 0xFA, 0x00, 0x00, 0x00, 0x0E, 0xF8, 0xFF, 0x60, 0x00, 0x00, - 0x00, 0xAF, 0xEF, 0xF1, 0x00, 0x00, 0x00, 0x06, 0xFF, 0xFB, 0x00, 0x00, 0x00, 0x00, 0x1F, 0xFF, - 0x70, 0x00, 0x00, 0x00, 0x00, 0xBF, 0xF2, 0x00, 0x00, 0x5F, 0xF4, 0x00, 0x00, 0xBF, 0xE1, 0x00, - 0x00, 0xDF, 0xA2, 0xFF, 0x80, 0x00, 0x0F, 0xFF, 0x50, 0x00, 0x2F, 0xF7, 0x0D, 0xFC, 0x00, 0x03, - 0xFF, 0xF8, 0x00, 0x06, 0xFF, 0x30, 0x9F, 0xF1, 0x00, 0x7F, 0xFF, 0xC0, 0x00, 0x9F, 0xE0, 0x05, - 0xFF, 0x40, 0x0A, 0xFF, 0xFF, 0x10, 0x0D, 0xFB, 0x00, 0x1F, 0xF8, 0x00, 0xEF, 0xCF, 0xF4, 0x01, - 0xFF, 0x70, 0x00, 0xCF, 0xB0, 0x2F, 0xF5, 0xFF, 0x80, 0x5F, 0xF3, 0x00, 0x08, 0xFF, 0x06, 0xFF, - 0x1B, 0xFC, 0x08, 0xFE, 0x00, 0x00, 0x5F, 0xF4, 0x9F, 0xC0, 0x8F, 0xF0, 0xCF, 0xB0, 0x00, 0x01, - 0xFF, 0x7D, 0xF9, 0x04, 0xFF, 0x4F, 0xF7, 0x00, 0x00, 0x0C, 0xFC, 0xFF, 0x50, 0x1F, 0xFC, 0xFF, - 0x30, 0x00, 0x00, 0x8F, 0xFF, 0xF2, 0x00, 0xCF, 0xFF, 0xE0, 0x00, 0x00, 0x04, 0xFF, 0xFD, 0x00, - 0x08, 0xFF, 0xFB, 0x00, 0x00, 0x00, 0x1F, 0xFF, 0xA0, 0x00, 0x4F, 0xFF, 0x70, 0x00, 0x00, 0x00, - 0xBF, 0xF6, 0x00, 0x01, 0xFF, 0xF4, 0x00, 0x00, 0x00, 0x07, 0xFF, 0x20, 0x00, 0x0B, 0xFE, 0x00, - 0x00, 0x1F, 0xFA, 0x00, 0x00, 0x02, 0xEF, 0x90, 0x8F, 0xF4, 0x00, 0x00, 0xBF, 0xF2, 0x01, 0xEF, - 0xD0, 0x00, 0x4F, 0xF8, 0x00, 0x06, 0xFF, 0x70, 0x0D, 0xFD, 0x10, 0x00, 0x0C, 0xFE, 0x17, 0xFF, - 0x50, 0x00, 0x00, 0x4F, 0xFB, 0xEF, 0xC0, 0x00, 0x00, 0x00, 0xAF, 0xFF, 0xF3, 0x00, 0x00, 0x00, - 0x02, 0xFF, 0xFA, 0x00, 0x00, 0x00, 0x00, 0x1E, 0xFF, 0x90, 0x00, 0x00, 0x00, 0x0A, 0xFF, 0xFF, - 0x30, 0x00, 0x00, 0x03, 0xFF, 0xBF, 0xFB, 0x00, 0x00, 0x00, 0xCF, 0xE1, 0x7F, 0xF5, 0x00, 0x00, - 0x5F, 0xF7, 0x00, 0xDF, 0xD1, 0x00, 0x1D, 0xFD, 0x00, 0x05, 0xFF, 0x70, 0x08, 0xFF, 0x40, 0x00, - 0x0B, 0xFE, 0x21, 0xFF, 0xA0, 0x00, 0x00, 0x2E, 0xF9, 0x2F, 0xF8, 0x00, 0x00, 0x06, 0xFF, 0x50, - 0xAF, 0xF1, 0x00, 0x00, 0xDF, 0xD0, 0x03, 0xFF, 0x80, 0x00, 0x5F, 0xF6, 0x00, 0x0A, 0xFE, 0x10, - 0x0D, 0xFD, 0x00, 0x00, 0x3F, 0xF7, 0x05, 0xFF, 0x60, 0x00, 0x00, 0xAF, 0xE1, 0xCF, 0xD0, 0x00, - 0x00, 0x03, 0xFF, 0xBF, 0xF6, 0x00, 0x00, 0x00, 0x0A, 0xFF, 0xFD, 0x00, 0x00, 0x00, 0x00, 0x3F, - 0xFF, 0x60, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x0B, 0xFD, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xBF, 0xD0, 0x00, 0x00, 0x00, 0x00, 0x0B, 0xFD, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xBF, 0xD0, 0x00, 0x00, 0x00, 0x00, 0x0B, 0xFD, 0x00, 0x00, 0x00, 0x00, 0x00, 0xAF, 0xD0, 0x00, - 0x00, 0x2F, 0xFF, 0xFF, 0xFF, 0xFF, 0xF3, 0x3F, 0xFF, 0xFF, 0xFF, 0xFF, 0xF4, 0x15, 0x55, 0x55, - 0x55, 0xDF, 0xF2, 0x00, 0x00, 0x00, 0x05, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x2E, 0xFC, 0x00, 0x00, - 0x00, 0x00, 0xBF, 0xF3, 0x00, 0x00, 0x00, 0x06, 0xFF, 0x70, 0x00, 0x00, 0x00, 0x2E, 0xFC, 0x00, - 0x00, 0x00, 0x00, 0xBF, 0xF2, 0x00, 0x00, 0x00, 0x06, 0xFF, 0x70, 0x00, 0x00, 0x00, 0x2E, 0xFC, - 0x00, 0x00, 0x00, 0x00, 0xCF, 0xE2, 0x00, 0x00, 0x00, 0x07, 0xFF, 0x60, 0x00, 0x00, 0x00, 0x1F, - 0xFE, 0x55, 0x55, 0x55, 0x51, 0x3F, 0xFF, 0xFF, 0xFF, 0xFF, 0xF4, 0x2F, 0xFF, 0xFF, 0xFF, 0xFF, - 0xF3, 0x3E, 0xD2, 0x9F, 0xF6, 0x3E, 0xD2, 0x4E, 0xC1, 0xAF, 0xF5, 0x4E, 0xC1, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4E, 0xC1, 0xAF, 0xF5, 0x4E, 0xC1, 0x8F, 0xF0, 0x8F, - 0xF0, 0x8F, 0xE0, 0x7F, 0xE0, 0x7F, 0xE0, 0x7F, 0xD0, 0x6F, 0xD0, 0x6F, 0xC0, 0x6F, 0xC0, 0x5F, - 0xC0, 0x4F, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x8E, 0xA0, 0xEF, 0xF1, 0x8E, 0xA0, 0x00, 0x00, 0xAF, - 0x70, 0x00, 0x00, 0x00, 0x0A, 0xF7, 0x00, 0x00, 0x00, 0x00, 0xAF, 0x70, 0x00, 0x00, 0x00, 0x0A, - 0xF7, 0x00, 0x00, 0x4F, 0xFF, 0xFF, 0xFF, 0xFF, 0x14, 0xFF, 0xFF, 0xFF, 0xFF, 0xF1, 0x15, 0x55, - 0xCF, 0xA5, 0x55, 0x00, 0x00, 0x0A, 0xF7, 0x00, 0x00, 0x00, 0x00, 0xAF, 0x70, 0x00, 0x00, 0x00, - 0x0A, 0xF7, 0x00, 0x00, 0x15, 0x55, 0x55, 0x55, 0x04, 0xFF, 0xFF, 0xFF, 0xF2, 0x4F, 0xFF, 0xFF, - 0xFF, 0x20, 0x00, 0x00, 0x02, 0xFF, 0x60, 0x00, 0x00, 0x7F, 0xF1, 0x00, 0x00, 0x0C, 0xFB, 0x00, - 0x00, 0x02, 0xFF, 0x60, 0x00, 0x00, 0x8F, 0xF1, 0x00, 0x00, 0x0D, 0xFA, 0x00, 0x00, 0x03, 0xFF, - 0x50, 0x00, 0x00, 0x8F, 0xE1, 0x00, 0x00, 0x0D, 0xFA, 0x00, 0x00, 0x04, 0xFF, 0x40, 0x00, 0x00, - 0x9F, 0xE0, 0x00, 0x00, 0x0E, 0xF9, 0x00, 0x00, 0x04, 0xFF, 0x40, 0x00, 0x00, 0xAF, 0xD0, 0x00, - 0x00, 0x1E, 0xF8, 0x00, 0x00, 0x05, 0xFF, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, - 0x00, 0x00, 0x00, 0x39, 0xF1, 0x00, 0x00, 0x04, 0xBF, 0xFF, 0x10, 0x00, 0x5C, 0xFF, 0xFC, 0x60, - 0x07, 0xDF, 0xFF, 0xA3, 0x00, 0x04, 0xFF, 0xE7, 0x10, 0x00, 0x00, 0x4F, 0xFE, 0x71, 0x00, 0x00, - 0x00, 0x7E, 0xFF, 0xFA, 0x30, 0x00, 0x00, 0x06, 0xCF, 0xFF, 0xC6, 0x00, 0x00, 0x00, 0x4B, 0xFF, - 0xF1, 0x00, 0x00, 0x00, 0x03, 0xAF, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10, 0x11, 0x00, 0x00, 0x00, - 0x00, 0x04, 0xE8, 0x10, 0x00, 0x00, 0x00, 0x4F, 0xFF, 0x93, 0x00, 0x00, 0x01, 0x7D, 0xFF, 0xFB, - 0x40, 0x00, 0x00, 0x05, 0xBF, 0xFF, 0xC5, 0x00, 0x00, 0x00, 0x29, 0xEF, 0xF1, 0x00, 0x00, 0x03, - 0x9E, 0xFF, 0x10, 0x00, 0x5B, 0xFF, 0xFC, 0x50, 0x17, 0xDF, 0xFF, 0xB4, 0x00, 0x04, 0xFF, 0xFA, - 0x30, 0x00, 0x00, 0x4E, 0x82, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, - 0xAA, 0x00, 0x1A, 0xA4, 0x00, 0x00, 0x9F, 0xE0, 0x03, 0xFF, 0x50, 0x00, 0x0C, 0xFC, 0x00, 0x5F, - 0xF3, 0x00, 0x00, 0xEF, 0xA0, 0x08, 0xFF, 0x10, 0x0E, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x90, 0xEF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFA, 0x04, 0x9F, 0xF6, 0x55, 0xFF, 0xB5, 0x30, 0x08, 0xFF, 0x00, 0x2F, - 0xF6, 0x00, 0x00, 0xBF, 0xD0, 0x05, 0xFF, 0x40, 0x0B, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC0, 0xCF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFD, 0x03, 0x7F, 0xF9, 0x55, 0xDF, 0xD5, 0x40, 0x04, 0xFF, 0x40, 0x0D, - 0xFA, 0x00, 0x00, 0x6F, 0xF2, 0x00, 0xFF, 0x80, 0x00, 0x08, 0xFF, 0x00, 0x2F, 0xF6, 0x00, 0x00, - 0x24, 0x40, 0x01, 0x44, 0x10, 0x00, 0x01, 0x9E, 0xE9, 0x10, 0x00, 0x0B, 0xE1, 0x00, 0x0B, 0xFE, - 0xEF, 0xB0, 0x00, 0x5F, 0x80, 0x00, 0x4F, 0x90, 0x09, 0xF3, 0x00, 0xDE, 0x10, 0x00, 0x5F, 0x30, - 0x04, 0xF5, 0x06, 0xF7, 0x00, 0x00, 0x3F, 0xA1, 0x2B, 0xF2, 0x0D, 0xD1, 0x00, 0x00, 0x0A, 0xFF, - 0xFF, 0x90, 0x7F, 0x60, 0x00, 0x00, 0x00, 0x7C, 0xC7, 0x01, 0xED, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x08, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x9F, 0x40, 0x5C, 0xFC, 0x40, 0x00, 0x00, 0x02, 0xFB, 0x04, 0xFF, 0xDF, 0xF3, 0x00, 0x00, - 0x0A, 0xF3, 0x0B, 0xF3, 0x04, 0xFA, 0x00, 0x00, 0x3F, 0xA0, 0x0D, 0xB0, 0x00, 0xCC, 0x00, 0x00, - 0xBF, 0x20, 0x0B, 0xC0, 0x00, 0xDA, 0x00, 0x04, 0xF9, 0x00, 0x04, 0xF8, 0x39, 0xF3, 0x00, 0x0C, - 0xE1, 0x00, 0x00, 0x5C, 0xFC, 0x40, -]; - -static FONT_MD_GLYPHS: [Glyph; 47] = [ - Glyph { ch: 32, x_off: 0, y_off: 0, w: 0, h: 0, adv: 4, offset: 0 }, - Glyph { ch: 48, x_off: 1, y_off: 0, w: 11, h: 16, adv: 13, offset: 0 }, - Glyph { ch: 49, x_off: 2, y_off: 0, w: 7, h: 16, adv: 13, offset: 88 }, - Glyph { ch: 50, x_off: 1, y_off: 0, w: 11, h: 16, adv: 13, offset: 144 }, - Glyph { ch: 51, x_off: 0, y_off: 0, w: 11, h: 16, adv: 13, offset: 232 }, - Glyph { ch: 52, x_off: 0, y_off: 0, w: 12, h: 16, adv: 13, offset: 320 }, - Glyph { ch: 53, x_off: 1, y_off: 0, w: 10, h: 16, adv: 13, offset: 416 }, - Glyph { ch: 54, x_off: 1, y_off: 0, w: 10, h: 16, adv: 13, offset: 496 }, - Glyph { ch: 55, x_off: 1, y_off: 0, w: 11, h: 16, adv: 13, offset: 576 }, - Glyph { ch: 56, x_off: 0, y_off: 0, w: 11, h: 16, adv: 13, offset: 664 }, - Glyph { ch: 57, x_off: 0, y_off: 0, w: 11, h: 16, adv: 13, offset: 752 }, - Glyph { ch: 65, x_off: 0, y_off: 0, w: 14, h: 16, adv: 14, offset: 840 }, - Glyph { ch: 66, x_off: 1, y_off: 0, w: 12, h: 16, adv: 14, offset: 952 }, - Glyph { ch: 67, x_off: 1, y_off: 0, w: 12, h: 16, adv: 13, offset: 1048 }, - Glyph { ch: 68, x_off: 1, y_off: 0, w: 12, h: 16, adv: 14, offset: 1144 }, - Glyph { ch: 69, x_off: 1, y_off: 0, w: 12, h: 16, adv: 13, offset: 1240 }, - Glyph { ch: 70, x_off: 1, y_off: 0, w: 12, h: 16, adv: 12, offset: 1336 }, - Glyph { ch: 71, x_off: 1, y_off: 0, w: 12, h: 16, adv: 13, offset: 1432 }, - Glyph { ch: 72, x_off: 1, y_off: 0, w: 12, h: 16, adv: 14, offset: 1528 }, - Glyph { ch: 73, x_off: 1, y_off: 0, w: 4, h: 16, adv: 6, offset: 1624 }, - Glyph { ch: 74, x_off: 0, y_off: 0, w: 12, h: 16, adv: 13, offset: 1656 }, - Glyph { ch: 75, x_off: 1, y_off: 0, w: 13, h: 16, adv: 14, offset: 1752 }, - Glyph { ch: 76, x_off: 1, y_off: 0, w: 11, h: 16, adv: 13, offset: 1856 }, - Glyph { ch: 77, x_off: 1, y_off: 0, w: 14, h: 16, adv: 16, offset: 1944 }, - Glyph { ch: 78, x_off: 1, y_off: 0, w: 13, h: 16, adv: 15, offset: 2056 }, - Glyph { ch: 79, x_off: 1, y_off: 0, w: 12, h: 16, adv: 14, offset: 2160 }, - Glyph { ch: 80, x_off: 1, y_off: 0, w: 12, h: 16, adv: 13, offset: 2256 }, - Glyph { ch: 81, x_off: 1, y_off: 0, w: 11, h: 19, adv: 13, offset: 2352 }, - Glyph { ch: 82, x_off: 1, y_off: 0, w: 12, h: 16, adv: 13, offset: 2457 }, - Glyph { ch: 83, x_off: 0, y_off: 0, w: 13, h: 16, adv: 13, offset: 2553 }, - Glyph { ch: 84, x_off: 0, y_off: 0, w: 12, h: 16, adv: 13, offset: 2657 }, - Glyph { ch: 85, x_off: 1, y_off: 0, w: 12, h: 16, adv: 14, offset: 2753 }, - Glyph { ch: 86, x_off: 0, y_off: 0, w: 13, h: 16, adv: 13, offset: 2849 }, - Glyph { ch: 87, x_off: 0, y_off: 0, w: 19, h: 16, adv: 19, offset: 2953 }, - Glyph { ch: 88, x_off: 0, y_off: 0, w: 13, h: 16, adv: 14, offset: 3105 }, - Glyph { ch: 89, x_off: 0, y_off: 0, w: 13, h: 16, adv: 13, offset: 3209 }, - Glyph { ch: 90, x_off: 0, y_off: 0, w: 12, h: 16, adv: 12, offset: 3313 }, - Glyph { ch: 46, x_off: 1, y_off: 13, w: 4, h: 3, adv: 6, offset: 3409 }, - Glyph { ch: 58, x_off: 2, y_off: 5, w: 4, h: 11, adv: 8, offset: 3415 }, - Glyph { ch: 33, x_off: 2, y_off: 0, w: 4, h: 16, adv: 7, offset: 3437 }, - Glyph { ch: 43, x_off: 0, y_off: 4, w: 11, h: 10, adv: 11, offset: 3469 }, - Glyph { ch: 45, x_off: 0, y_off: 7, w: 9, h: 3, adv: 9, offset: 3524 }, - Glyph { ch: 47, x_off: 0, y_off: 0, w: 9, h: 16, adv: 10, offset: 3538 }, - Glyph { ch: 60, x_off: 0, y_off: 4, w: 11, h: 12, adv: 11, offset: 3610 }, - Glyph { ch: 62, x_off: 0, y_off: 4, w: 11, h: 12, adv: 11, offset: 3676 }, - Glyph { ch: 35, x_off: 1, y_off: 0, w: 13, h: 16, adv: 15, offset: 3742 }, - Glyph { ch: 37, x_off: 1, y_off: 0, w: 16, h: 16, adv: 18, offset: 3846 }, -]; - -pub static FONT_MD: Font = Font { glyphs: &FONT_MD_GLYPHS, data: &FONT_MD_DATA }; - -static FONT_LG_DATA: [u8; 12604] = [ - 0x00, 0x00, 0x01, 0x6A, 0xDE, 0xFE, 0xDA, 0x61, 0x00, 0x00, 0x00, 0x00, 0x07, 0xEF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xE7, 0x00, 0x00, 0x00, 0x1B, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFB, 0x00, 0x00, - 0x0B, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFA, 0x00, 0x06, 0xFF, 0xFF, 0xFF, 0xB8, 0x78, - 0xCF, 0xFF, 0xFF, 0xF5, 0x00, 0xDF, 0xFF, 0xFE, 0x40, 0x00, 0x00, 0x4E, 0xFF, 0xFF, 0xD0, 0x3F, - 0xFF, 0xFF, 0x40, 0x00, 0x00, 0x00, 0x5F, 0xFF, 0xFF, 0x36, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, - 0x00, 0xCF, 0xFF, 0xF6, 0x8F, 0xFF, 0xF9, 0x00, 0x00, 0x00, 0x00, 0x09, 0xFF, 0xFF, 0x89, 0xFF, - 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x8F, 0xFF, 0xF9, 0x9F, 0xFF, 0xF8, 0x00, 0x00, 0x00, 0x00, - 0x08, 0xFF, 0xFF, 0x99, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x8F, 0xFF, 0xF9, 0x9F, 0xFF, - 0xF8, 0x00, 0x00, 0x00, 0x00, 0x08, 0xFF, 0xFF, 0x99, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, - 0x8F, 0xFF, 0xF9, 0x9F, 0xFF, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x08, 0xFF, 0xFF, 0x99, 0xFF, 0xFF, - 0x80, 0x00, 0x00, 0x00, 0x00, 0x8F, 0xFF, 0xF9, 0x9F, 0xFF, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x08, - 0xFF, 0xFF, 0x99, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x8F, 0xFF, 0xF9, 0x9F, 0xFF, 0xF8, - 0x00, 0x00, 0x00, 0x00, 0x08, 0xFF, 0xFF, 0x99, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x8F, - 0xFF, 0xF9, 0x9F, 0xFF, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x08, 0xFF, 0xFF, 0x99, 0xFF, 0xFF, 0x80, - 0x00, 0x00, 0x00, 0x00, 0x8F, 0xFF, 0xF9, 0x8F, 0xFF, 0xF9, 0x00, 0x00, 0x00, 0x00, 0x09, 0xFF, - 0xFF, 0x76, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF6, 0x2F, 0xFF, 0xFF, 0x40, - 0x00, 0x00, 0x00, 0x4F, 0xFF, 0xFF, 0x20, 0xDF, 0xFF, 0xFE, 0x40, 0x00, 0x00, 0x4E, 0xFF, 0xFF, - 0xC0, 0x05, 0xFF, 0xFF, 0xFF, 0xB8, 0x78, 0xCF, 0xFF, 0xFF, 0xF5, 0x00, 0x0A, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFA, 0x00, 0x00, 0x1B, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFA, 0x00, - 0x00, 0x00, 0x07, 0xEF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE6, 0x00, 0x00, 0x00, 0x00, 0x01, 0x6A, 0xDE, - 0xFE, 0xDA, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x29, 0xEF, 0xFF, 0xF6, 0x00, 0x29, 0xFF, 0xFF, - 0xFF, 0xF7, 0x08, 0xFF, 0xFF, 0xFF, 0xFF, 0xF7, 0x1F, 0xFF, 0xFF, 0xFF, 0xFF, 0xF7, 0x0F, 0xFF, - 0xFF, 0xFF, 0xFF, 0xF7, 0x0E, 0xFE, 0x95, 0xBF, 0xFF, 0xF7, 0x06, 0x40, 0x00, 0xAF, 0xFF, 0xF7, - 0x00, 0x00, 0x00, 0xAF, 0xFF, 0xF7, 0x00, 0x00, 0x00, 0xAF, 0xFF, 0xF7, 0x00, 0x00, 0x00, 0xAF, - 0xFF, 0xF7, 0x00, 0x00, 0x00, 0xAF, 0xFF, 0xF7, 0x00, 0x00, 0x00, 0xAF, 0xFF, 0xF7, 0x00, 0x00, - 0x00, 0xAF, 0xFF, 0xF7, 0x00, 0x00, 0x00, 0xAF, 0xFF, 0xF7, 0x00, 0x00, 0x00, 0xAF, 0xFF, 0xF7, - 0x00, 0x00, 0x00, 0xAF, 0xFF, 0xF7, 0x00, 0x00, 0x00, 0xAF, 0xFF, 0xF7, 0x00, 0x00, 0x00, 0xAF, - 0xFF, 0xF7, 0x00, 0x00, 0x00, 0xAF, 0xFF, 0xF7, 0x00, 0x00, 0x00, 0xAF, 0xFF, 0xF7, 0x00, 0x00, - 0x00, 0xAF, 0xFF, 0xF7, 0x00, 0x00, 0x00, 0xAF, 0xFF, 0xF7, 0x00, 0x00, 0x00, 0xAF, 0xFF, 0xF7, - 0x00, 0x00, 0x00, 0xAF, 0xFF, 0xF7, 0x00, 0x00, 0x00, 0xAF, 0xFF, 0xF7, 0x00, 0x00, 0x00, 0xAF, - 0xFF, 0xF7, 0x00, 0x00, 0x00, 0xAF, 0xFF, 0xF7, 0x00, 0x00, 0x00, 0xAF, 0xFF, 0xF7, 0x00, 0x00, - 0x00, 0xAF, 0xFF, 0xF7, 0x00, 0x00, 0x00, 0xAF, 0xFF, 0xF7, 0x00, 0x00, 0x00, 0x9F, 0xFF, 0xF6, - 0x00, 0x00, 0x03, 0x8C, 0xDF, 0xED, 0xB7, 0x10, 0x00, 0x00, 0x00, 0x00, 0x3C, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x6F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC1, 0x00, 0x00, - 0x6F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC0, 0x00, 0x1E, 0xFF, 0xFF, 0xFD, 0x97, 0x7B, - 0xFF, 0xFF, 0xFF, 0x70, 0x07, 0xFF, 0xFF, 0xF9, 0x00, 0x00, 0x03, 0xDF, 0xFF, 0xFE, 0x00, 0xCF, - 0xFF, 0xFB, 0x00, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xF4, 0x0E, 0xFF, 0xFF, 0x50, 0x00, 0x00, 0x00, - 0x0C, 0xFF, 0xFF, 0x60, 0xEF, 0xFF, 0xF3, 0x00, 0x00, 0x00, 0x00, 0xBF, 0xFF, 0xF7, 0x0E, 0xFF, - 0xFF, 0x30, 0x00, 0x00, 0x00, 0x0D, 0xFF, 0xFF, 0x50, 0x24, 0x44, 0x30, 0x00, 0x00, 0x00, 0x04, - 0xFF, 0xFF, 0xF2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xBF, 0xFF, 0xFC, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x6F, 0xFF, 0xFF, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2E, 0xFF, - 0xFF, 0xD0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, 0xFF, 0xFF, 0xF4, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x0A, 0xFF, 0xFF, 0xF9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0xFF, 0xFF, 0xFC, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0xFF, 0xFF, 0xFE, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x04, 0xFF, 0xFF, 0xFF, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xEF, 0xFF, 0xFF, 0x50, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x01, 0xDF, 0xFF, 0xFF, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xCF, - 0xFF, 0xFF, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xBF, 0xFF, 0xFF, 0xA0, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x9F, 0xFF, 0xFF, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8F, 0xFF, 0xFF, - 0xC1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xFF, 0xFF, 0xD2, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x5F, 0xFF, 0xFF, 0xF9, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x0C, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF3, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0x3C, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF3, 0xBF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x20, 0x0B, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFB, - 0x00, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC0, 0x0C, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0x00, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC0, - 0x04, 0x66, 0x66, 0x66, 0x66, 0x66, 0x8F, 0xFF, 0xFF, 0xFB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x2D, 0xFF, 0xFF, 0xFE, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2D, 0xFF, 0xFF, 0xFE, 0x20, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x2D, 0xFF, 0xFF, 0xFE, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2D, 0xFF, - 0xFF, 0xFE, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3E, 0xFF, 0xFF, 0xFE, 0x30, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x3E, 0xFF, 0xFF, 0xFE, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3E, 0xFF, 0xFF, 0xFF, - 0x82, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0x30, 0x00, 0x00, 0x00, - 0x00, 0x0B, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x60, 0x00, 0x00, 0x00, 0x00, 0x1D, 0xFC, 0x9B, 0xFF, - 0xFF, 0xFF, 0x40, 0x00, 0x00, 0x00, 0x00, 0x35, 0x00, 0x02, 0xCF, 0xFF, 0xFD, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x01, 0xEF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, - 0xFF, 0xFF, 0xA0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4F, 0xFF, 0xFE, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x02, 0xFF, 0xFF, 0xF0, 0x03, 0x33, 0x32, 0x00, 0x00, 0x00, 0x00, 0x1F, - 0xFF, 0xFF, 0x14, 0xFF, 0xFF, 0xD0, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xF1, 0x3F, 0xFF, 0xFF, - 0x00, 0x00, 0x00, 0x00, 0x3F, 0xFF, 0xFF, 0x01, 0xFF, 0xFF, 0xF4, 0x00, 0x00, 0x00, 0x07, 0xFF, - 0xFF, 0xD0, 0x0C, 0xFF, 0xFF, 0xB0, 0x00, 0x00, 0x01, 0xDF, 0xFF, 0xF9, 0x00, 0x6F, 0xFF, 0xFF, - 0x80, 0x00, 0x00, 0xAF, 0xFF, 0xFF, 0x40, 0x00, 0xDF, 0xFF, 0xFF, 0xD8, 0x79, 0xEF, 0xFF, 0xFF, - 0xC0, 0x00, 0x04, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE3, 0x00, 0x00, 0x05, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xE4, 0x00, 0x00, 0x00, 0x03, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC3, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x49, 0xCE, 0xFE, 0xC9, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x0D, 0xFF, 0xFF, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0xFF, 0xFF, 0xF1, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x4F, 0xFF, 0xFF, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0B, 0xFF, 0xFF, - 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xFF, 0xFF, 0xF4, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x9F, 0xFF, 0xFD, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, - 0xFF, 0xFF, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xFF, 0xFF, 0xE0, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xEF, 0xFF, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x6F, 0xFF, 0xFF, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0xFF, 0xFF, 0x90, - 0x00, 0x02, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x04, 0xFF, 0xFF, 0xF3, 0x00, 0x00, 0x3F, 0xFF, 0xFE, - 0x00, 0x00, 0x00, 0xBF, 0xFF, 0xFB, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xE0, 0x00, 0x00, 0x2F, 0xFF, - 0xFF, 0x40, 0x00, 0x00, 0x3F, 0xFF, 0xFE, 0x00, 0x00, 0x09, 0xFF, 0xFF, 0xD0, 0x00, 0x00, 0x03, - 0xFF, 0xFF, 0xE0, 0x00, 0x01, 0xEF, 0xFF, 0xF6, 0x00, 0x00, 0x00, 0x3F, 0xFF, 0xFE, 0x00, 0x00, - 0x7F, 0xFF, 0xFE, 0x10, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xE0, 0x00, 0x0E, 0xFF, 0xFF, 0xC6, 0x66, - 0x66, 0x66, 0x9F, 0xFF, 0xFE, 0x66, 0x24, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xF7, 0x5F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x85, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF8, 0x4F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xE0, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xFF, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xFF, - 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xE0, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xFF, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x03, 0xFF, 0xFF, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2F, 0xFF, 0xFC, 0x00, - 0x00, 0xAF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x60, 0xBF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0x70, 0xBF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x70, 0xBF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x70, 0xBF, 0xFF, 0xFA, 0x66, 0x66, 0x66, 0x66, - 0x66, 0x66, 0x20, 0xBF, 0xFF, 0xF6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xBF, 0xFF, 0xF6, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xBF, 0xFF, 0xF6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0xBF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xBF, 0xFF, 0xF5, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xBF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xBF, - 0xFF, 0xF5, 0x17, 0xBE, 0xFE, 0xC9, 0x30, 0x00, 0x00, 0xBF, 0xFF, 0xFA, 0xEF, 0xFF, 0xFF, 0xFF, - 0xFA, 0x10, 0x00, 0xBF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xD2, 0x00, 0xBF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFD, 0x00, 0xBF, 0xFF, 0xFF, 0xFE, 0xA7, 0x7A, 0xFF, 0xFF, 0xFF, - 0x70, 0xBF, 0xFF, 0xFF, 0xB1, 0x00, 0x00, 0x3E, 0xFF, 0xFF, 0xD0, 0xBF, 0xFF, 0xFD, 0x10, 0x00, - 0x00, 0x05, 0xFF, 0xFF, 0xF2, 0x25, 0x55, 0x52, 0x00, 0x00, 0x00, 0x00, 0xEF, 0xFF, 0xF6, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xBF, 0xFF, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9F, 0xFF, 0xF9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xAF, 0xFF, 0xF9, 0x7B, 0xBB, 0xB5, - 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF7, 0x9F, 0xFF, 0xFB, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, - 0xF5, 0x5F, 0xFF, 0xFF, 0x30, 0x00, 0x00, 0x08, 0xFF, 0xFF, 0xF2, 0x1E, 0xFF, 0xFF, 0xD2, 0x00, - 0x00, 0x6F, 0xFF, 0xFF, 0xC0, 0x08, 0xFF, 0xFF, 0xFF, 0xA7, 0x8C, 0xFF, 0xFF, 0xFF, 0x40, 0x00, - 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF9, 0x00, 0x00, 0x1C, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xA0, 0x00, 0x00, 0x01, 0x9F, 0xFF, 0xFF, 0xFF, 0xFF, 0xE6, 0x00, 0x00, 0x00, 0x00, 0x02, - 0x7B, 0xEF, 0xED, 0xA6, 0x10, 0x00, 0x00, 0x00, 0x00, 0x04, 0x9C, 0xDF, 0xEC, 0xA5, 0x10, 0x00, - 0x00, 0x00, 0x04, 0xDF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE7, 0x00, 0x00, 0x00, 0x7F, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xB0, 0x00, 0x05, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF9, 0x00, 0x1E, - 0xFF, 0xFF, 0xFD, 0x87, 0x8C, 0xFF, 0xFF, 0xFF, 0x30, 0x6F, 0xFF, 0xFF, 0x90, 0x00, 0x00, 0x6F, - 0xFF, 0xFF, 0x90, 0x9F, 0xFF, 0xFC, 0x00, 0x00, 0x00, 0x09, 0xFF, 0xFF, 0xC0, 0xBF, 0xFF, 0xF7, - 0x00, 0x00, 0x00, 0x05, 0xFF, 0xFF, 0xD0, 0xBF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x02, 0xCC, 0xCC, - 0x90, 0xBF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xBF, 0xFF, 0xF5, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xBF, 0xFF, 0xF5, 0x06, 0xBE, 0xFE, 0xD9, 0x40, 0x00, 0x00, 0xBF, - 0xFF, 0xF7, 0xCF, 0xFF, 0xFF, 0xFF, 0xFA, 0x10, 0x00, 0xBF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xD2, 0x00, 0xBF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFB, 0x00, 0xBF, 0xFF, 0xFF, - 0xFE, 0x97, 0x7B, 0xFF, 0xFF, 0xFF, 0x60, 0xBF, 0xFF, 0xFF, 0xC2, 0x00, 0x00, 0x4E, 0xFF, 0xFF, - 0xD0, 0xBF, 0xFF, 0xFF, 0x20, 0x00, 0x00, 0x06, 0xFF, 0xFF, 0xF2, 0xBF, 0xFF, 0xFB, 0x00, 0x00, - 0x00, 0x00, 0xEF, 0xFF, 0xF5, 0xBF, 0xFF, 0xF7, 0x00, 0x00, 0x00, 0x00, 0xBF, 0xFF, 0xF7, 0xBF, - 0xFF, 0xF6, 0x00, 0x00, 0x00, 0x00, 0x9F, 0xFF, 0xF8, 0xBF, 0xFF, 0xF6, 0x00, 0x00, 0x00, 0x00, - 0x9F, 0xFF, 0xF8, 0xAF, 0xFF, 0xF7, 0x00, 0x00, 0x00, 0x00, 0xBF, 0xFF, 0xF6, 0x8F, 0xFF, 0xFB, - 0x00, 0x00, 0x00, 0x00, 0xEF, 0xFF, 0xF4, 0x4F, 0xFF, 0xFF, 0x20, 0x00, 0x00, 0x06, 0xFF, 0xFF, - 0xF1, 0x0E, 0xFF, 0xFF, 0xC1, 0x00, 0x00, 0x4E, 0xFF, 0xFF, 0xB0, 0x07, 0xFF, 0xFF, 0xFE, 0x97, - 0x7B, 0xFF, 0xFF, 0xFF, 0x40, 0x00, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF9, 0x00, 0x00, - 0x2D, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xA0, 0x00, 0x00, 0x01, 0x9F, 0xFF, 0xFF, 0xFF, 0xFF, - 0xE7, 0x00, 0x00, 0x00, 0x00, 0x02, 0x8B, 0xEF, 0xFD, 0xB7, 0x10, 0x00, 0x00, 0xCF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFA, 0xDF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFB, 0xDF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFB, 0xDF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFB, 0xDF, 0xFF, 0xA6, 0x66, 0x66, 0x66, 0x66, 0xDF, 0xFF, 0xFA, 0xDF, - 0xFF, 0x60, 0x00, 0x00, 0x00, 0x02, 0xFF, 0xFF, 0xF5, 0xDF, 0xFF, 0x50, 0x00, 0x00, 0x00, 0x07, - 0xFF, 0xFF, 0xE0, 0x13, 0x32, 0x00, 0x00, 0x00, 0x00, 0x0D, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x3F, 0xFF, 0xFF, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9F, 0xFF, 0xFC, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xEF, 0xFF, 0xF7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x05, 0xFF, 0xFF, 0xF1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0B, 0xFF, 0xFF, 0xA0, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x2F, 0xFF, 0xFF, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xFF, - 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xDF, 0xFF, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x04, 0xFF, 0xFF, 0xF3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0xFF, 0xFF, 0xC0, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0xFF, 0xFF, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6F, - 0xFF, 0xFF, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xFA, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x02, 0xFF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0xFF, 0xFF, 0xE0, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x4F, 0xFF, 0xFF, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xAF, 0xFF, 0xFC, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xF6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0xFF, 0xFF, - 0xF1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0xFF, 0xFF, 0xA0, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x3F, 0xFF, 0xFF, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xFF, 0xFD, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0xCD, 0xFE, 0xDA, 0x51, 0x00, 0x00, 0x00, 0x00, 0x02, - 0xAF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE6, 0x00, 0x00, 0x00, 0x03, 0xEF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xF9, 0x00, 0x00, 0x02, 0xEF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF8, 0x00, 0x00, 0xBF, 0xFF, - 0xFF, 0xE9, 0x78, 0xCF, 0xFF, 0xFF, 0xF2, 0x00, 0x2F, 0xFF, 0xFF, 0xA1, 0x00, 0x00, 0x5F, 0xFF, - 0xFF, 0x80, 0x07, 0xFF, 0xFF, 0xD1, 0x00, 0x00, 0x00, 0x7F, 0xFF, 0xFC, 0x00, 0x9F, 0xFF, 0xF8, - 0x00, 0x00, 0x00, 0x02, 0xFF, 0xFF, 0xE0, 0x09, 0xFF, 0xFF, 0x70, 0x00, 0x00, 0x00, 0x1F, 0xFF, - 0xFE, 0x00, 0x7F, 0xFF, 0xFB, 0x00, 0x00, 0x00, 0x04, 0xFF, 0xFF, 0xC0, 0x03, 0xFF, 0xFF, 0xF4, - 0x00, 0x00, 0x01, 0xCF, 0xFF, 0xF8, 0x00, 0x0A, 0xFF, 0xFF, 0xE7, 0x20, 0x15, 0xCF, 0xFF, 0xFE, - 0x20, 0x00, 0x1D, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x50, 0x00, 0x00, 0x2D, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFE, 0x50, 0x00, 0x00, 0x01, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE5, 0x00, - 0x00, 0x02, 0xDF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF6, 0x00, 0x00, 0xBF, 0xFF, 0xFF, 0x82, - 0x01, 0x5C, 0xFF, 0xFF, 0xE2, 0x00, 0x4F, 0xFF, 0xFF, 0x40, 0x00, 0x00, 0x0C, 0xFF, 0xFF, 0x90, - 0x09, 0xFF, 0xFF, 0xB0, 0x00, 0x00, 0x00, 0x4F, 0xFF, 0xFE, 0x00, 0xDF, 0xFF, 0xF6, 0x00, 0x00, - 0x00, 0x00, 0xEF, 0xFF, 0xF3, 0x0F, 0xFF, 0xFF, 0x40, 0x00, 0x00, 0x00, 0x0C, 0xFF, 0xFF, 0x51, - 0xFF, 0xFF, 0xF3, 0x00, 0x00, 0x00, 0x00, 0xBF, 0xFF, 0xF6, 0x0F, 0xFF, 0xFF, 0x50, 0x00, 0x00, - 0x00, 0x0D, 0xFF, 0xFF, 0x60, 0xDF, 0xFF, 0xF8, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xF4, 0x0A, - 0xFF, 0xFF, 0xE1, 0x00, 0x00, 0x00, 0x8F, 0xFF, 0xFF, 0x10, 0x5F, 0xFF, 0xFF, 0xA1, 0x00, 0x00, - 0x5F, 0xFF, 0xFF, 0xA0, 0x00, 0xCF, 0xFF, 0xFF, 0xE9, 0x77, 0xBF, 0xFF, 0xFF, 0xF4, 0x00, 0x03, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF9, 0x00, 0x00, 0x05, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFA, 0x00, 0x00, 0x00, 0x03, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE7, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x49, 0xCE, 0xFE, 0xDA, 0x61, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x6A, 0xDE, 0xFE, 0xC8, - 0x30, 0x00, 0x00, 0x00, 0x00, 0x5E, 0xFF, 0xFF, 0xFF, 0xFF, 0xFB, 0x20, 0x00, 0x00, 0x09, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE3, 0x00, 0x00, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, - 0x20, 0x02, 0xFF, 0xFF, 0xFF, 0xC8, 0x78, 0xDF, 0xFF, 0xFF, 0xB0, 0x08, 0xFF, 0xFF, 0xF5, 0x00, - 0x00, 0x09, 0xFF, 0xFF, 0xF3, 0x0D, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, 0xDF, 0xFF, 0xF7, 0x2F, - 0xFF, 0xFF, 0x20, 0x00, 0x00, 0x00, 0x7F, 0xFF, 0xFB, 0x4F, 0xFF, 0xFD, 0x00, 0x00, 0x00, 0x00, - 0x3F, 0xFF, 0xFD, 0x5F, 0xFF, 0xFB, 0x00, 0x00, 0x00, 0x00, 0x2F, 0xFF, 0xFE, 0x5F, 0xFF, 0xFC, - 0x00, 0x00, 0x00, 0x00, 0x3F, 0xFF, 0xFF, 0x4F, 0xFF, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x5F, 0xFF, - 0xFF, 0x2F, 0xFF, 0xFF, 0x50, 0x00, 0x00, 0x00, 0xAF, 0xFF, 0xFF, 0x0D, 0xFF, 0xFF, 0xD1, 0x00, - 0x00, 0x04, 0xFF, 0xFF, 0xFF, 0x07, 0xFF, 0xFF, 0xFD, 0x51, 0x02, 0x7F, 0xFF, 0xFF, 0xFF, 0x01, - 0xDF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x3F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0x00, 0x04, 0xEF, 0xFF, 0xFF, 0xFF, 0xFF, 0xBF, 0xFF, 0xFF, 0x00, 0x00, 0x29, - 0xEF, 0xFF, 0xFF, 0xD6, 0x2F, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x03, 0x66, 0x53, 0x00, 0x2F, 0xFF, - 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2F, 0xFF, 0xFF, 0x01, 0x33, 0x33, 0x00, 0x00, - 0x00, 0x00, 0x2F, 0xFF, 0xFF, 0x09, 0xFF, 0xFF, 0x70, 0x00, 0x00, 0x00, 0x2F, 0xFF, 0xFF, 0x09, - 0xFF, 0xFF, 0x90, 0x00, 0x00, 0x00, 0x4F, 0xFF, 0xFE, 0x08, 0xFF, 0xFF, 0xD0, 0x00, 0x00, 0x00, - 0x9F, 0xFF, 0xFD, 0x05, 0xFF, 0xFF, 0xFA, 0x00, 0x00, 0x07, 0xFF, 0xFF, 0xF9, 0x00, 0xDF, 0xFF, - 0xFF, 0xD8, 0x78, 0xCF, 0xFF, 0xFF, 0xF3, 0x00, 0x5F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0x90, 0x00, 0x06, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFA, 0x00, 0x00, 0x00, 0x4D, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFE, 0x60, 0x00, 0x00, 0x00, 0x00, 0x49, 0xCE, 0xFE, 0xCA, 0x51, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x02, 0xEF, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x7F, 0xFF, 0xFF, 0xFD, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0B, 0xFF, - 0xFF, 0xFF, 0xF3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, - 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6F, 0xFF, 0xFF, 0xFF, 0xFD, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0B, 0xFF, 0xFF, 0xFF, 0xFF, 0xF3, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xFC, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x5F, 0xFF, 0xFC, 0x6F, 0xFF, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0xFF, - 0xFF, 0x71, 0xFF, 0xFF, 0xF2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xEF, 0xFF, 0xF3, 0x0B, - 0xFF, 0xFF, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5F, 0xFF, 0xFD, 0x00, 0x7F, 0xFF, 0xFC, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0xFF, 0xFF, 0x90, 0x02, 0xFF, 0xFF, 0xF2, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xEF, 0xFF, 0xF4, 0x00, 0x0D, 0xFF, 0xFF, 0x60, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x4F, 0xFF, 0xFE, 0x00, 0x00, 0x8F, 0xFF, 0xFB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0xFF, - 0xFF, 0xA0, 0x00, 0x03, 0xFF, 0xFF, 0xF1, 0x00, 0x00, 0x00, 0x00, 0x00, 0xDF, 0xFF, 0xF5, 0x00, - 0x00, 0x0E, 0xFF, 0xFF, 0x60, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xFF, 0xFF, 0x10, 0x00, 0x00, 0x9F, - 0xFF, 0xFB, 0x00, 0x00, 0x00, 0x00, 0x08, 0xFF, 0xFF, 0xB0, 0x00, 0x00, 0x04, 0xFF, 0xFF, 0xF1, - 0x00, 0x00, 0x00, 0x00, 0xDF, 0xFF, 0xF7, 0x00, 0x00, 0x00, 0x0E, 0xFF, 0xFF, 0x50, 0x00, 0x00, - 0x00, 0x3F, 0xFF, 0xFF, 0x20, 0x00, 0x00, 0x00, 0xAF, 0xFF, 0xFA, 0x00, 0x00, 0x00, 0x07, 0xFF, - 0xFF, 0xD0, 0x00, 0x00, 0x00, 0x06, 0xFF, 0xFF, 0xE0, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xFC, 0x66, - 0x66, 0x66, 0x66, 0x8F, 0xFF, 0xFF, 0x50, 0x00, 0x00, 0x2F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xF9, 0x00, 0x00, 0x07, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xE0, 0x00, 0x00, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x40, - 0x00, 0x1F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF9, 0x00, 0x06, 0xFF, - 0xFF, 0xF2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0xFF, 0xFF, 0xD0, 0x00, 0xBF, 0xFF, 0xFC, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x4F, 0xFF, 0xFF, 0x30, 0x1F, 0xFF, 0xFF, 0x70, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xEF, 0xFF, 0xF8, 0x05, 0xFF, 0xFF, 0xF2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x09, 0xFF, 0xFF, 0xD0, 0x9F, 0xFF, 0xFB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4F, 0xFF, - 0xFF, 0x20, 0xBF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xED, 0xB8, 0x30, 0x00, 0x00, 0xCF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFB, 0x30, 0x00, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xF4, 0x00, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x20, 0xCF, 0xFF, - 0xF9, 0x66, 0x66, 0x66, 0x8B, 0xFF, 0xFF, 0xFF, 0xA0, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, - 0x3D, 0xFF, 0xFF, 0xF1, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x02, 0xFF, 0xFF, 0xF4, 0xCF, - 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0xBF, 0xFF, 0xF6, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x8F, 0xFF, 0xF7, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9F, 0xFF, 0xF5, - 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0xDF, 0xFF, 0xF3, 0xCF, 0xFF, 0xF5, 0x00, 0x00, - 0x00, 0x00, 0x08, 0xFF, 0xFF, 0xC0, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x14, 0xBF, 0xFF, 0xFF, - 0x40, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF6, 0x00, 0xCF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0x30, 0x00, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFD, - 0x40, 0x00, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF8, 0x00, 0xCF, 0xFF, 0xF9, - 0x66, 0x66, 0x66, 0x7A, 0xEF, 0xFF, 0xFF, 0x60, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x1B, - 0xFF, 0xFF, 0xE1, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0xDF, 0xFF, 0xF7, 0xCF, 0xFF, - 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6F, 0xFF, 0xFB, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x4F, 0xFF, 0xFD, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4F, 0xFF, 0xFD, 0xCF, - 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6F, 0xFF, 0xFC, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, - 0x00, 0x01, 0xDF, 0xFF, 0xFA, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x1B, 0xFF, 0xFF, 0xF6, - 0xCF, 0xFF, 0xF9, 0x66, 0x66, 0x66, 0x7A, 0xEF, 0xFF, 0xFF, 0xE1, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x50, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF6, - 0x00, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0x30, 0x00, 0xBF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xED, 0xB8, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0xAD, 0xEF, 0xED, 0xA7, 0x20, - 0x00, 0x00, 0x00, 0x00, 0x01, 0x9F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xA2, 0x00, 0x00, 0x00, 0x04, - 0xEF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE4, 0x00, 0x00, 0x03, 0xEF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xF4, 0x00, 0x01, 0xDF, 0xFF, 0xFF, 0xFB, 0x87, 0x8A, 0xFF, 0xFF, 0xFF, 0xE1, - 0x00, 0x8F, 0xFF, 0xFF, 0xB2, 0x00, 0x00, 0x02, 0xBF, 0xFF, 0xFF, 0x90, 0x0E, 0xFF, 0xFF, 0xB0, - 0x00, 0x00, 0x00, 0x00, 0xBF, 0xFF, 0xFE, 0x03, 0xFF, 0xFF, 0xF2, 0x00, 0x00, 0x00, 0x00, 0x02, - 0xFF, 0xFF, 0xF4, 0x6F, 0xFF, 0xFB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0xFF, 0xFF, 0x67, 0xFF, - 0xFF, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9F, 0xFF, 0xF7, 0x8F, 0xFF, 0xF8, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x03, 0x66, 0x66, 0x28, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x8F, 0xFF, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0xFF, 0xFF, 0x80, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8F, 0xFF, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x08, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8F, - 0xFF, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0xFF, 0xFF, 0x80, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8F, 0xFF, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x08, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8F, 0xFF, 0xF8, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x66, 0x66, 0x27, 0xFF, 0xFF, 0x90, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x9F, 0xFF, 0xF7, 0x6F, 0xFF, 0xFB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0xFF, 0xFF, 0x63, - 0xFF, 0xFF, 0xF2, 0x00, 0x00, 0x00, 0x00, 0x02, 0xFF, 0xFF, 0xF4, 0x0E, 0xFF, 0xFF, 0xB0, 0x00, - 0x00, 0x00, 0x00, 0xBF, 0xFF, 0xFE, 0x00, 0x8F, 0xFF, 0xFF, 0xB2, 0x00, 0x00, 0x01, 0xAF, 0xFF, - 0xFF, 0x80, 0x01, 0xDF, 0xFF, 0xFF, 0xFB, 0x87, 0x7A, 0xFF, 0xFF, 0xFF, 0xE1, 0x00, 0x03, 0xEF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF4, 0x00, 0x00, 0x04, 0xEF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xE4, 0x00, 0x00, 0x00, 0x01, 0x9F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xA2, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x17, 0xAD, 0xEF, 0xED, 0xA7, 0x20, 0x00, 0x00, 0x00, 0xBF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xED, 0xA6, 0x10, 0x00, 0x00, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF9, - 0x10, 0x00, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xD3, 0x00, 0xCF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0x20, 0xCF, 0xFF, 0xF9, 0x66, 0x66, 0x66, 0x7B, 0xFF, - 0xFF, 0xFF, 0xB0, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x3D, 0xFF, 0xFF, 0xF4, 0xCF, 0xFF, - 0xF5, 0x00, 0x00, 0x00, 0x00, 0x02, 0xFF, 0xFF, 0xF9, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x9F, 0xFF, 0xFC, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5F, 0xFF, 0xFE, 0xCF, - 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xFF, 0xFE, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x2F, 0xFF, 0xFE, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2F, 0xFF, 0xFE, - 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2F, 0xFF, 0xFE, 0xCF, 0xFF, 0xF5, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x2F, 0xFF, 0xFE, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2F, 0xFF, - 0xFE, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2F, 0xFF, 0xFE, 0xCF, 0xFF, 0xF5, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x2F, 0xFF, 0xFE, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2F, - 0xFF, 0xFE, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2F, 0xFF, 0xFE, 0xCF, 0xFF, 0xF5, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x2F, 0xFF, 0xFE, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x2F, 0xFF, 0xFE, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xFF, 0xFE, 0xCF, 0xFF, - 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5F, 0xFF, 0xFE, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x9F, 0xFF, 0xFC, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xF9, 0xCF, - 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x3D, 0xFF, 0xFF, 0xF4, 0xCF, 0xFF, 0xF9, 0x66, 0x66, 0x66, - 0x7B, 0xFF, 0xFF, 0xFF, 0xC0, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0x20, - 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xD3, 0x00, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xF9, 0x10, 0x00, 0xBF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xED, 0xA7, 0x10, 0x00, - 0x00, 0xBF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE0, 0xCF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF1, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xF1, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF1, 0xCF, 0xFF, 0xF9, - 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x60, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, - 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, - 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x10, 0x00, 0x00, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0x20, 0x00, 0x00, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x20, 0x00, - 0x00, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x20, 0x00, 0x00, 0xCF, 0xFF, 0xF9, 0x66, - 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, - 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, - 0xFF, 0xF9, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x60, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xF1, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF1, - 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF1, 0xBF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE0, 0xBF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xE0, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0xCF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xF0, 0xCF, 0xFF, 0xF9, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x50, 0xCF, 0xFF, 0xF5, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, - 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, - 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x10, 0x00, 0x00, - 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x20, 0x00, 0x00, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0x20, 0x00, 0x00, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x20, 0x00, - 0x00, 0xCF, 0xFF, 0xF9, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, - 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, - 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xBF, 0xFF, 0xF4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0xAD, - 0xEF, 0xED, 0xA6, 0x10, 0x00, 0x00, 0x00, 0x00, 0x01, 0x9F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x91, - 0x00, 0x00, 0x00, 0x03, 0xEF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE4, 0x00, 0x00, 0x03, 0xEF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF4, 0x00, 0x01, 0xDF, 0xFF, 0xFF, 0xFB, 0x87, 0x7A, - 0xEF, 0xFF, 0xFF, 0xE1, 0x00, 0x7F, 0xFF, 0xFF, 0xB2, 0x00, 0x00, 0x01, 0xAF, 0xFF, 0xFF, 0x90, - 0x0D, 0xFF, 0xFF, 0xB0, 0x00, 0x00, 0x00, 0x00, 0xAF, 0xFF, 0xFE, 0x13, 0xFF, 0xFF, 0xF2, 0x00, - 0x00, 0x00, 0x00, 0x01, 0xEF, 0xFF, 0xF4, 0x6F, 0xFF, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0B, - 0xFF, 0xFF, 0x67, 0xFF, 0xFF, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9F, 0xFF, 0xF7, 0x8F, 0xFF, - 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x33, 0x33, 0x18, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x8F, 0xFF, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x08, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8F, 0xFF, 0xF8, 0x00, - 0x00, 0x0A, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x68, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0xBF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xF7, 0x8F, 0xFF, 0xF8, 0x00, 0x00, 0x0B, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x78, 0xFF, - 0xFF, 0x80, 0x00, 0x00, 0xBF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF7, 0x8F, 0xFF, 0xF8, 0x00, 0x00, 0x04, - 0x66, 0x66, 0x6C, 0xFF, 0xFF, 0x78, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9F, 0xFF, - 0xF7, 0x8F, 0xFF, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0xFF, 0xFF, 0x77, 0xFF, 0xFF, 0x90, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x9F, 0xFF, 0xF6, 0x6F, 0xFF, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x0B, 0xFF, 0xFF, 0x43, 0xFF, 0xFF, 0xF3, 0x00, 0x00, 0x00, 0x00, 0x01, 0xEF, 0xFF, 0xF1, 0x0D, - 0xFF, 0xFF, 0xC1, 0x00, 0x00, 0x00, 0x00, 0x8F, 0xFF, 0xFC, 0x00, 0x7F, 0xFF, 0xFF, 0xC3, 0x00, - 0x00, 0x00, 0x8F, 0xFF, 0xFF, 0x50, 0x01, 0xDF, 0xFF, 0xFF, 0xFB, 0x87, 0x79, 0xEF, 0xFF, 0xFF, - 0xC0, 0x00, 0x03, 0xEF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE2, 0x00, 0x00, 0x03, 0xEF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xD3, 0x00, 0x00, 0x00, 0x01, 0x9F, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0x91, 0x00, 0x00, 0x00, 0x00, 0x00, 0x17, 0xAD, 0xEF, 0xED, 0xA6, 0x10, 0x00, 0x00, 0x00, - 0xAF, 0xFF, 0xF4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0E, 0xFF, 0xFE, 0x1C, 0xFF, 0xFF, 0x50, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xF1, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, - 0xFF, 0xFF, 0x1C, 0xFF, 0xFF, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xF1, 0xCF, 0xFF, - 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFF, 0x1C, 0xFF, 0xFF, 0x50, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xFF, 0xFF, 0xF1, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFF, - 0x1C, 0xFF, 0xFF, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xF1, 0xCF, 0xFF, 0xF5, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFF, 0x1C, 0xFF, 0xFF, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xFF, 0xFF, 0xF1, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFF, 0x1C, 0xFF, - 0xFF, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xF1, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x1F, 0xFF, 0xFF, 0x1C, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xF1, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x1C, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF1, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0x1C, 0xFF, 0xFF, 0x96, 0x66, 0x66, 0x66, 0x66, 0x67, 0xFF, 0xFF, 0xF1, 0xCF, - 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFF, 0x1C, 0xFF, 0xFF, 0x50, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xF1, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, - 0xFF, 0x1C, 0xFF, 0xFF, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xF1, 0xCF, 0xFF, 0xF5, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFF, 0x1C, 0xFF, 0xFF, 0x50, 0x00, 0x00, 0x00, 0x00, - 0x00, 0xFF, 0xFF, 0xF1, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFF, 0x1C, - 0xFF, 0xFF, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xF1, 0xCF, 0xFF, 0xF5, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFF, 0x1C, 0xFF, 0xFF, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, - 0xFF, 0xF1, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFF, 0x1C, 0xFF, 0xFF, - 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xF1, 0xBF, 0xFF, 0xF4, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x0E, 0xFF, 0xFE, 0x10, 0xBF, 0xFF, 0xF4, 0xCF, 0xFF, 0xF5, 0xCF, 0xFF, 0xF5, 0xCF, 0xFF, - 0xF5, 0xCF, 0xFF, 0xF5, 0xCF, 0xFF, 0xF5, 0xCF, 0xFF, 0xF5, 0xCF, 0xFF, 0xF5, 0xCF, 0xFF, 0xF5, - 0xCF, 0xFF, 0xF5, 0xCF, 0xFF, 0xF5, 0xCF, 0xFF, 0xF5, 0xCF, 0xFF, 0xF5, 0xCF, 0xFF, 0xF5, 0xCF, - 0xFF, 0xF5, 0xCF, 0xFF, 0xF5, 0xCF, 0xFF, 0xF5, 0xCF, 0xFF, 0xF5, 0xCF, 0xFF, 0xF5, 0xCF, 0xFF, - 0xF5, 0xCF, 0xFF, 0xF5, 0xCF, 0xFF, 0xF5, 0xCF, 0xFF, 0xF5, 0xCF, 0xFF, 0xF5, 0xCF, 0xFF, 0xF5, - 0xCF, 0xFF, 0xF5, 0xCF, 0xFF, 0xF5, 0xCF, 0xFF, 0xF5, 0xCF, 0xFF, 0xF5, 0xCF, 0xFF, 0xF5, 0xBF, - 0xFF, 0xF4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0xFF, 0xFF, 0x40, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xBF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x0B, 0xFF, 0xFF, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xBF, 0xFF, 0xF5, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0B, 0xFF, 0xFF, 0x50, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xBF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0B, - 0xFF, 0xFF, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xBF, 0xFF, 0xF5, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0B, 0xFF, 0xFF, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xBF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0B, 0xFF, 0xFF, - 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xBF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x0B, 0xFF, 0xFF, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xBF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0B, 0xFF, 0xFF, 0x50, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xBF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x0B, 0xFF, 0xFF, 0x50, 0x23, 0x33, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0xBF, 0xFF, - 0xF5, 0x0F, 0xFF, 0xFF, 0x10, 0x00, 0x00, 0x00, 0x00, 0x0B, 0xFF, 0xFF, 0x50, 0xFF, 0xFF, 0xF1, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xBF, 0xFF, 0xF5, 0x0F, 0xFF, 0xFF, 0x10, 0x00, 0x00, 0x00, 0x00, - 0x0B, 0xFF, 0xFF, 0x50, 0xFF, 0xFF, 0xF1, 0x00, 0x00, 0x00, 0x00, 0x00, 0xBF, 0xFF, 0xF5, 0x0E, - 0xFF, 0xFF, 0x30, 0x00, 0x00, 0x00, 0x00, 0x0D, 0xFF, 0xFF, 0x40, 0xCF, 0xFF, 0xF8, 0x00, 0x00, - 0x00, 0x00, 0x02, 0xFF, 0xFF, 0xF2, 0x08, 0xFF, 0xFF, 0xE2, 0x00, 0x00, 0x00, 0x00, 0xBF, 0xFF, - 0xFD, 0x00, 0x3F, 0xFF, 0xFF, 0xD3, 0x00, 0x00, 0x02, 0xBF, 0xFF, 0xFF, 0x70, 0x00, 0xAF, 0xFF, - 0xFF, 0xFC, 0x87, 0x7A, 0xFF, 0xFF, 0xFF, 0xD1, 0x00, 0x01, 0xDF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xE3, 0x00, 0x00, 0x02, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE4, 0x00, 0x00, - 0x00, 0x00, 0x7E, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xA2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0xAD, - 0xEF, 0xED, 0xB7, 0x20, 0x00, 0x00, 0x00, 0xBF, 0xFF, 0xF4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3E, - 0xFF, 0xFF, 0x80, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x01, 0xDF, 0xFF, 0xFD, 0x10, 0xCF, - 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x1C, 0xFF, 0xFF, 0xE2, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, - 0x00, 0x00, 0xAF, 0xFF, 0xFF, 0x40, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x08, 0xFF, 0xFF, - 0xF7, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x5F, 0xFF, 0xFF, 0xA0, 0x00, 0x00, 0xCF, - 0xFF, 0xF5, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xFC, 0x10, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, - 0x2E, 0xFF, 0xFF, 0xE2, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x01, 0xCF, 0xFF, 0xFF, 0x40, - 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x0B, 0xFF, 0xFF, 0xF6, 0x00, 0x00, 0x00, 0x00, 0xCF, - 0xFF, 0xF5, 0x00, 0x8F, 0xFF, 0xFF, 0x90, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x06, 0xFF, - 0xFF, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x4F, 0xFF, 0xFF, 0xD1, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF7, 0xEF, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF2, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFB, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x60, 0x00, - 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xFF, 0xFF, 0x4B, 0xFF, 0xFF, 0xE1, 0x00, 0x00, 0x00, 0x00, 0xCF, - 0xFF, 0xFF, 0xF5, 0x02, 0xEF, 0xFF, 0xFA, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xFF, 0x80, 0x00, - 0x7F, 0xFF, 0xFF, 0x50, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xFA, 0x00, 0x00, 0x0C, 0xFF, 0xFF, 0xD1, - 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xF9, 0x00, 0x00, 0x00, 0xCF, - 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x8F, 0xFF, 0xFF, 0x40, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, - 0x00, 0x0D, 0xFF, 0xFF, 0xD0, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x04, 0xFF, 0xFF, - 0xF8, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x9F, 0xFF, 0xFF, 0x30, 0x00, 0xCF, - 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x1E, 0xFF, 0xFF, 0xC0, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, - 0x00, 0x00, 0x05, 0xFF, 0xFF, 0xF6, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0xAF, - 0xFF, 0xFE, 0x20, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2E, 0xFF, 0xFF, 0xB0, 0xBF, - 0xFF, 0xF4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0xFF, 0xFF, 0xF3, 0xBF, 0xFF, 0xF4, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0xFF, 0xFF, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0xFF, 0xFF, 0x50, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, - 0xFF, 0xFF, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x0C, 0xFF, 0xFF, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, - 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0xFF, 0xFF, 0x50, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0xFF, - 0xFF, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x0C, 0xFF, 0xFF, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, - 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0xFF, 0xFF, 0x50, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0xFF, 0xFF, - 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x0C, 0xFF, 0xFF, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0xFF, 0xFF, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0xFF, 0xFF, 0x50, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x0C, 0xFF, 0xFF, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF9, 0x66, - 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x4C, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFC, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xCC, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xBF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xB0, 0xBF, 0xFF, 0xF7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xEF, 0xFF, 0xF3, 0xCF, 0xFF, - 0xFF, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0xFF, 0xFF, 0xF4, 0xCF, 0xFF, 0xFF, 0xC0, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x5F, 0xFF, 0xFF, 0xF4, 0xCF, 0xFF, 0xFF, 0xF7, 0x00, 0x00, 0x00, 0x00, - 0x01, 0xEF, 0xFF, 0xFF, 0xF4, 0xCF, 0xFF, 0xFF, 0xFF, 0x20, 0x00, 0x00, 0x00, 0x0A, 0xFF, 0xFF, - 0xFF, 0xF4, 0xCF, 0xFF, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, 0x5F, 0xFF, 0xFF, 0xFF, 0xF4, 0xCF, - 0xFF, 0xFF, 0xFF, 0xF6, 0x00, 0x00, 0x01, 0xEF, 0xFF, 0xFF, 0xFF, 0xF4, 0xCF, 0xFF, 0xFF, 0xFF, - 0xFE, 0x20, 0x00, 0x09, 0xFF, 0xFF, 0xFF, 0xFF, 0xF4, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xB0, 0x00, - 0x4F, 0xFF, 0xFF, 0xFF, 0xFF, 0xF4, 0xCF, 0xFF, 0xFA, 0xFF, 0xFF, 0xF6, 0x01, 0xDF, 0xFF, 0xFB, - 0xDF, 0xFF, 0xF4, 0xCF, 0xFF, 0xF5, 0xAF, 0xFF, 0xFE, 0x29, 0xFF, 0xFF, 0xE2, 0xDF, 0xFF, 0xF4, - 0xCF, 0xFF, 0xF5, 0x1E, 0xFF, 0xFF, 0xDF, 0xFF, 0xFF, 0x60, 0xDF, 0xFF, 0xF4, 0xCF, 0xFF, 0xF5, - 0x05, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0x00, 0xDF, 0xFF, 0xF4, 0xCF, 0xFF, 0xF5, 0x00, 0xAF, 0xFF, - 0xFF, 0xFF, 0xF2, 0x00, 0xDF, 0xFF, 0xF4, 0xCF, 0xFF, 0xF5, 0x00, 0x1E, 0xFF, 0xFF, 0xFF, 0x70, - 0x00, 0xDF, 0xFF, 0xF4, 0xCF, 0xFF, 0xF5, 0x00, 0x05, 0xFF, 0xFF, 0xFC, 0x00, 0x00, 0xDF, 0xFF, - 0xF4, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0xBF, 0xFF, 0xF3, 0x00, 0x00, 0xDF, 0xFF, 0xF4, 0xCF, 0xFF, - 0xF5, 0x00, 0x00, 0x2E, 0xFF, 0x80, 0x00, 0x00, 0xDF, 0xFF, 0xF4, 0xCF, 0xFF, 0xF5, 0x00, 0x00, - 0x01, 0x22, 0x00, 0x00, 0x00, 0xDF, 0xFF, 0xF4, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xDF, 0xFF, 0xF4, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xDF, - 0xFF, 0xF4, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xDF, 0xFF, 0xF4, 0xCF, - 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xDF, 0xFF, 0xF4, 0xCF, 0xFF, 0xF5, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xDF, 0xFF, 0xF4, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xDF, 0xFF, 0xF4, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xDF, 0xFF, 0xF4, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xDF, 0xFF, 0xF4, - 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xDF, 0xFF, 0xF4, 0xCF, 0xFF, 0xF5, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xDF, 0xFF, 0xF4, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xDF, 0xFF, 0xF4, 0xBF, 0xFF, 0xF4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0xCF, 0xFF, 0xF3, 0xBF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF2, - 0xCF, 0xFF, 0xFE, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0xDF, 0xFF, 0xF3, 0xCF, 0xFF, 0xFF, 0x80, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xDF, 0xFF, 0xF3, 0xCF, 0xFF, 0xFF, 0xF3, 0x00, 0x00, 0x00, 0x00, - 0x00, 0xDF, 0xFF, 0xF3, 0xCF, 0xFF, 0xFF, 0xFB, 0x00, 0x00, 0x00, 0x00, 0x00, 0xDF, 0xFF, 0xF3, - 0xCF, 0xFF, 0xFF, 0xFF, 0x60, 0x00, 0x00, 0x00, 0x00, 0xDF, 0xFF, 0xF3, 0xCF, 0xFF, 0xFF, 0xFF, - 0xE1, 0x00, 0x00, 0x00, 0x00, 0xDF, 0xFF, 0xF3, 0xCF, 0xFF, 0xFF, 0xFF, 0xF9, 0x00, 0x00, 0x00, - 0x00, 0xDF, 0xFF, 0xF3, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0x30, 0x00, 0x00, 0x00, 0xDF, 0xFF, 0xF3, - 0xCF, 0xFF, 0xFE, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, 0xDF, 0xFF, 0xF3, 0xCF, 0xFF, 0xF5, 0xEF, - 0xFF, 0xF6, 0x00, 0x00, 0x00, 0xDF, 0xFF, 0xF3, 0xCF, 0xFF, 0xF4, 0x7F, 0xFF, 0xFE, 0x10, 0x00, - 0x00, 0xDF, 0xFF, 0xF3, 0xCF, 0xFF, 0xF4, 0x0C, 0xFF, 0xFF, 0x90, 0x00, 0x00, 0xDF, 0xFF, 0xF3, - 0xCF, 0xFF, 0xF4, 0x04, 0xFF, 0xFF, 0xF3, 0x00, 0x00, 0xDF, 0xFF, 0xF3, 0xCF, 0xFF, 0xF4, 0x00, - 0x9F, 0xFF, 0xFC, 0x00, 0x00, 0xDF, 0xFF, 0xF3, 0xCF, 0xFF, 0xF4, 0x00, 0x1E, 0xFF, 0xFF, 0x60, - 0x00, 0xDF, 0xFF, 0xF3, 0xCF, 0xFF, 0xF4, 0x00, 0x06, 0xFF, 0xFF, 0xE1, 0x00, 0xDF, 0xFF, 0xF3, - 0xCF, 0xFF, 0xF4, 0x00, 0x00, 0xCF, 0xFF, 0xFA, 0x00, 0xDF, 0xFF, 0xF3, 0xCF, 0xFF, 0xF4, 0x00, - 0x00, 0x3F, 0xFF, 0xFF, 0x40, 0xDF, 0xFF, 0xF3, 0xCF, 0xFF, 0xF4, 0x00, 0x00, 0x09, 0xFF, 0xFF, - 0xC0, 0xDF, 0xFF, 0xF3, 0xCF, 0xFF, 0xF4, 0x00, 0x00, 0x01, 0xEF, 0xFF, 0xF7, 0xDF, 0xFF, 0xF3, - 0xCF, 0xFF, 0xF4, 0x00, 0x00, 0x00, 0x6F, 0xFF, 0xFE, 0xEF, 0xFF, 0xF3, 0xCF, 0xFF, 0xF4, 0x00, - 0x00, 0x00, 0x0C, 0xFF, 0xFF, 0xFF, 0xFF, 0xF3, 0xCF, 0xFF, 0xF4, 0x00, 0x00, 0x00, 0x03, 0xFF, - 0xFF, 0xFF, 0xFF, 0xF3, 0xCF, 0xFF, 0xF4, 0x00, 0x00, 0x00, 0x00, 0x9F, 0xFF, 0xFF, 0xFF, 0xF3, - 0xCF, 0xFF, 0xF4, 0x00, 0x00, 0x00, 0x00, 0x1E, 0xFF, 0xFF, 0xFF, 0xF3, 0xCF, 0xFF, 0xF4, 0x00, - 0x00, 0x00, 0x00, 0x05, 0xFF, 0xFF, 0xFF, 0xF3, 0xCF, 0xFF, 0xF4, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xBF, 0xFF, 0xFF, 0xF3, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2F, 0xFF, 0xFF, 0xF3, - 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0xFF, 0xFF, 0xF3, 0xBF, 0xFF, 0xF4, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x01, 0xDF, 0xFF, 0xF2, 0x00, 0x00, 0x00, 0x15, 0xAC, 0xEF, 0xED, 0xB7, - 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xA2, 0x00, 0x00, 0x00, - 0x02, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE5, 0x00, 0x00, 0x02, 0xDF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xF5, 0x00, 0x00, 0xBF, 0xFF, 0xFF, 0xFB, 0x87, 0x7A, 0xEF, 0xFF, 0xFF, - 0xE2, 0x00, 0x5F, 0xFF, 0xFF, 0xC3, 0x00, 0x00, 0x01, 0x9F, 0xFF, 0xFF, 0xA0, 0x0C, 0xFF, 0xFF, - 0xD1, 0x00, 0x00, 0x00, 0x00, 0x9F, 0xFF, 0xFF, 0x22, 0xFF, 0xFF, 0xF4, 0x00, 0x00, 0x00, 0x00, - 0x01, 0xEF, 0xFF, 0xF7, 0x5F, 0xFF, 0xFD, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0xFF, 0xFF, 0xA7, - 0xFF, 0xFF, 0xA0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5F, 0xFF, 0xFC, 0x8F, 0xFF, 0xF9, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x04, 0xFF, 0xFF, 0xD8, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4F, - 0xFF, 0xFD, 0x8F, 0xFF, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0xFF, 0xFF, 0xD8, 0xFF, 0xFF, - 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4F, 0xFF, 0xFD, 0x8F, 0xFF, 0xF8, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x04, 0xFF, 0xFF, 0xD8, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4F, 0xFF, 0xFD, - 0x8F, 0xFF, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0xFF, 0xFF, 0xD8, 0xFF, 0xFF, 0x80, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x4F, 0xFF, 0xFD, 0x8F, 0xFF, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, - 0xFF, 0xFF, 0xD8, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4F, 0xFF, 0xFD, 0x8F, 0xFF, - 0xF9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0xFF, 0xFF, 0xD7, 0xFF, 0xFF, 0xA0, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x5F, 0xFF, 0xFC, 0x5F, 0xFF, 0xFD, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0xFF, 0xFF, - 0xA2, 0xFF, 0xFF, 0xF4, 0x00, 0x00, 0x00, 0x00, 0x01, 0xEF, 0xFF, 0xF7, 0x0C, 0xFF, 0xFF, 0xD1, - 0x00, 0x00, 0x00, 0x00, 0x9F, 0xFF, 0xFF, 0x20, 0x6F, 0xFF, 0xFF, 0xC3, 0x00, 0x00, 0x01, 0x9F, - 0xFF, 0xFF, 0xA0, 0x00, 0xCF, 0xFF, 0xFF, 0xFB, 0x87, 0x7A, 0xEF, 0xFF, 0xFF, 0xE2, 0x00, 0x02, - 0xDF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF5, 0x00, 0x00, 0x02, 0xDF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xE5, 0x00, 0x00, 0x00, 0x01, 0x8E, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xA2, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x16, 0xAD, 0xEF, 0xED, 0xB7, 0x20, 0x00, 0x00, 0x00, 0x0E, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xEC, 0x94, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFC, 0x20, 0x00, 0x1F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0x40, 0x01, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0x20, 0x1F, 0xFF, 0xFF, 0x76, 0x66, - 0x66, 0x67, 0xAF, 0xFF, 0xFF, 0xFB, 0x01, 0xFF, 0xFF, 0xF1, 0x00, 0x00, 0x00, 0x00, 0x2C, 0xFF, - 0xFF, 0xF3, 0x1F, 0xFF, 0xFF, 0x10, 0x00, 0x00, 0x00, 0x00, 0x1E, 0xFF, 0xFF, 0x81, 0xFF, 0xFF, - 0xF1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8F, 0xFF, 0xFB, 0x1F, 0xFF, 0xFF, 0x10, 0x00, 0x00, 0x00, - 0x00, 0x04, 0xFF, 0xFF, 0xD1, 0xFF, 0xFF, 0xF1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xFF, 0xFD, - 0x1F, 0xFF, 0xFF, 0x10, 0x00, 0x00, 0x00, 0x00, 0x05, 0xFF, 0xFF, 0xC1, 0xFF, 0xFF, 0xF1, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xBF, 0xFF, 0xFA, 0x1F, 0xFF, 0xFF, 0x10, 0x00, 0x00, 0x00, 0x00, 0x6F, - 0xFF, 0xFF, 0x61, 0xFF, 0xFF, 0xF1, 0x00, 0x00, 0x00, 0x13, 0xAF, 0xFF, 0xFF, 0xE1, 0x1F, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF6, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xF9, 0x00, 0x1F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF7, 0x00, - 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xA3, 0x00, 0x00, 0x1F, 0xFF, 0xFF, 0x76, - 0x66, 0x66, 0x66, 0x53, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xF1, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x1F, 0xFF, 0xFF, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, - 0xFF, 0xF1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0xFF, 0xFF, 0x10, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xF1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x1F, 0xFF, 0xFF, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xF1, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0xFF, 0xFF, 0x10, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xF1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, - 0xFF, 0xFF, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xF1, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0E, 0xFF, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0xCE, 0xFF, 0xDB, 0x72, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xA2, 0x00, 0x00, 0x00, 0x07, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFE, 0x40, 0x00, 0x00, 0x6F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF4, 0x00, 0x03, 0xFF, - 0xFF, 0xFF, 0xD9, 0x77, 0xAE, 0xFF, 0xFF, 0xFE, 0x10, 0x0C, 0xFF, 0xFF, 0xF7, 0x00, 0x00, 0x01, - 0x9F, 0xFF, 0xFF, 0x90, 0x3F, 0xFF, 0xFF, 0x60, 0x00, 0x00, 0x00, 0x09, 0xFF, 0xFF, 0xF1, 0x8F, - 0xFF, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x01, 0xEF, 0xFF, 0xF5, 0xBF, 0xFF, 0xF6, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x9F, 0xFF, 0xF8, 0xDF, 0xFF, 0xF4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6F, 0xFF, 0xFA, - 0xEF, 0xFF, 0xF3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5F, 0xFF, 0xFB, 0xEF, 0xFF, 0xF3, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x5F, 0xFF, 0xFC, 0xEF, 0xFF, 0xF3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5F, 0xFF, - 0xFC, 0xEF, 0xFF, 0xF3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5F, 0xFF, 0xFC, 0xEF, 0xFF, 0xF3, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x5F, 0xFF, 0xFC, 0xEF, 0xFF, 0xF3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5F, - 0xFF, 0xFC, 0xEF, 0xFF, 0xF3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5F, 0xFF, 0xFC, 0xEF, 0xFF, 0xF3, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x5F, 0xFF, 0xFC, 0xEF, 0xFF, 0xF3, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x5F, 0xFF, 0xFC, 0xEF, 0xFF, 0xF3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5F, 0xFF, 0xFC, 0xEF, 0xFF, - 0xF3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5F, 0xFF, 0xFC, 0xEF, 0xFF, 0xF3, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x6F, 0xFF, 0xFB, 0xDF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8F, 0xFF, 0xFA, 0xBF, - 0xFF, 0xF9, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF8, 0x7F, 0xFF, 0xFF, 0x20, 0x00, 0x00, - 0x00, 0x04, 0xFF, 0xFF, 0xF5, 0x2F, 0xFF, 0xFF, 0xD2, 0x00, 0x00, 0x00, 0x3E, 0xFF, 0xFF, 0xE1, - 0x0A, 0xFF, 0xFF, 0xFE, 0x72, 0x01, 0x38, 0xFF, 0xFF, 0xFF, 0x70, 0x02, 0xEF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0x00, 0x00, 0x4E, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xD2, - 0x00, 0x00, 0x03, 0xDF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0x20, 0x00, 0x00, 0x00, 0x17, 0xEF, - 0xFF, 0xFF, 0xFF, 0xFD, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xCF, 0xFF, 0xFA, 0x20, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9F, 0xFF, 0xF7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x9F, 0xFF, 0xF7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9F, 0xFF, 0xF7, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8F, 0xFF, 0xF6, 0x00, 0x00, 0x00, 0x00, 0xBF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xDA, 0x50, 0x00, 0x00, 0x0C, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xD3, 0x00, 0x00, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF5, 0x00, - 0x0C, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE2, 0x00, 0xCF, 0xFF, 0xF9, 0x66, - 0x66, 0x66, 0x79, 0xEF, 0xFF, 0xFF, 0xC0, 0x0C, 0xFF, 0xFF, 0x50, 0x00, 0x00, 0x00, 0x01, 0xAF, - 0xFF, 0xFF, 0x40, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF9, 0x0C, 0xFF, - 0xFF, 0x50, 0x00, 0x00, 0x00, 0x00, 0x06, 0xFF, 0xFF, 0xC0, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x3F, 0xFF, 0xFE, 0x0C, 0xFF, 0xFF, 0x50, 0x00, 0x00, 0x00, 0x00, 0x03, 0xFF, 0xFF, - 0xE0, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6F, 0xFF, 0xFD, 0x0C, 0xFF, 0xFF, 0x50, - 0x00, 0x00, 0x00, 0x00, 0x0C, 0xFF, 0xFF, 0xA0, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x1A, - 0xFF, 0xFF, 0xF6, 0x0C, 0xFF, 0xFF, 0x96, 0x66, 0x66, 0x67, 0x9E, 0xFF, 0xFF, 0xFE, 0x10, 0xCF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x50, 0x0C, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0x80, 0x00, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0x50, - 0x00, 0x0C, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF6, 0x10, 0x00, 0x00, 0xCF, 0xFF, 0xF5, - 0x00, 0x00, 0x0C, 0xFF, 0xFF, 0x40, 0x00, 0x00, 0x0C, 0xFF, 0xFF, 0x50, 0x00, 0x00, 0x5F, 0xFF, - 0xFB, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF4, 0x00, 0x00, 0x0C, - 0xFF, 0xFF, 0x50, 0x00, 0x00, 0x06, 0xFF, 0xFF, 0xB0, 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, - 0x00, 0x0D, 0xFF, 0xFF, 0x30, 0x00, 0x0C, 0xFF, 0xFF, 0x50, 0x00, 0x00, 0x00, 0x7F, 0xFF, 0xFB, - 0x00, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x01, 0xEF, 0xFF, 0xF3, 0x00, 0x0C, 0xFF, 0xFF, - 0x50, 0x00, 0x00, 0x00, 0x08, 0xFF, 0xFF, 0xB0, 0x00, 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, - 0x1E, 0xFF, 0xFF, 0x30, 0x0C, 0xFF, 0xFF, 0x50, 0x00, 0x00, 0x00, 0x00, 0x8F, 0xFF, 0xFA, 0x00, - 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x02, 0xFF, 0xFF, 0xF3, 0x0C, 0xFF, 0xFF, 0x50, 0x00, - 0x00, 0x00, 0x00, 0x09, 0xFF, 0xFF, 0xA0, 0xBF, 0xFF, 0xF4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2E, - 0xFF, 0xFF, 0x20, 0x00, 0x00, 0x00, 0x17, 0xAD, 0xEF, 0xED, 0xB8, 0x30, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x1A, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFD, 0x50, 0x00, 0x00, 0x00, 0x03, 0xEF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFA, 0x10, 0x00, 0x00, 0x3E, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xB0, 0x00, 0x00, 0xCF, 0xFF, 0xFF, 0xEA, 0x77, 0x7A, 0xEF, 0xFF, 0xFF, 0xF8, 0x00, 0x03, - 0xFF, 0xFF, 0xF9, 0x10, 0x00, 0x00, 0x06, 0xEF, 0xFF, 0xFF, 0x20, 0x07, 0xFF, 0xFF, 0xC0, 0x00, - 0x00, 0x00, 0x00, 0x4F, 0xFF, 0xFF, 0x70, 0x09, 0xFF, 0xFF, 0x60, 0x00, 0x00, 0x00, 0x00, 0x09, - 0xFF, 0xFF, 0xB0, 0x0A, 0xFF, 0xFF, 0x60, 0x00, 0x00, 0x00, 0x00, 0x04, 0xFF, 0xFF, 0xC0, 0x08, - 0xFF, 0xFF, 0x90, 0x00, 0x00, 0x00, 0x00, 0x02, 0xFF, 0xFF, 0xC0, 0x05, 0xFF, 0xFF, 0xF4, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x33, 0x33, 0x20, 0x00, 0xEF, 0xFF, 0xFF, 0x81, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x5F, 0xFF, 0xFF, 0xFE, 0x93, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x06, 0xFF, 0xFF, 0xFF, 0xFF, 0xD7, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4D, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFB, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x7D, 0xFF, 0xFF, 0xFF, 0xFF, 0xFD, - 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5B, 0xFF, 0xFF, 0xFF, 0xFF, 0xFB, 0x10, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x27, 0xDF, 0xFF, 0xFF, 0xFF, 0xD1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x04, 0xBF, 0xFF, 0xFF, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0xDF, - 0xFF, 0xFF, 0x60, 0x05, 0x55, 0x53, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, 0xFF, 0xFF, 0xC0, 0x2F, - 0xFF, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0xFF, 0xFF, 0xF0, 0x2F, 0xFF, 0xFD, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xF1, 0x1F, 0xFF, 0xFF, 0x20, 0x00, 0x00, 0x00, 0x00, 0x03, - 0xFF, 0xFF, 0xE0, 0x0D, 0xFF, 0xFF, 0xC1, 0x00, 0x00, 0x00, 0x00, 0x09, 0xFF, 0xFF, 0xC0, 0x08, - 0xFF, 0xFF, 0xFC, 0x30, 0x00, 0x00, 0x00, 0x8F, 0xFF, 0xFF, 0x80, 0x01, 0xEF, 0xFF, 0xFF, 0xFD, - 0x97, 0x77, 0x9E, 0xFF, 0xFF, 0xFE, 0x10, 0x00, 0x4F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xF5, 0x00, 0x00, 0x04, 0xEF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x60, 0x00, 0x00, - 0x00, 0x19, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xB2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x9C, - 0xEF, 0xFE, 0xDA, 0x72, 0x00, 0x00, 0x00, 0x6F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xE8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x8F, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF7, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x26, 0x66, 0x66, 0x66, 0x6F, 0xFF, 0xFF, 0x86, 0x66, 0x66, 0x66, - 0x50, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xF2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x0F, 0xFF, 0xFF, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xF2, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFF, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xF2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, - 0xFF, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xF2, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFF, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0xFF, 0xFF, 0xF2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFF, 0x20, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xF2, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFF, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, - 0xFF, 0xF2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFF, 0x20, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xF2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x0F, 0xFF, 0xFF, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xF2, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFF, 0x20, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xF2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, - 0xFF, 0xFF, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xF2, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFF, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xFF, 0xFF, 0xF2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFF, - 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xF2, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x0D, 0xFF, 0xFF, 0x10, 0x00, 0x00, 0x00, 0x00, 0x0E, 0xFF, 0xFE, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xEF, 0xFF, 0xE0, 0x1F, 0xFF, 0xFF, 0x10, 0x00, 0x00, 0x00, 0x00, - 0x01, 0xFF, 0xFF, 0xF0, 0x1F, 0xFF, 0xFF, 0x10, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xF0, - 0x1F, 0xFF, 0xFF, 0x10, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xF0, 0x1F, 0xFF, 0xFF, 0x10, - 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xF0, 0x1F, 0xFF, 0xFF, 0x10, 0x00, 0x00, 0x00, 0x00, - 0x01, 0xFF, 0xFF, 0xF0, 0x1F, 0xFF, 0xFF, 0x10, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xF0, - 0x1F, 0xFF, 0xFF, 0x10, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xF0, 0x1F, 0xFF, 0xFF, 0x10, - 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xF0, 0x1F, 0xFF, 0xFF, 0x10, 0x00, 0x00, 0x00, 0x00, - 0x01, 0xFF, 0xFF, 0xF0, 0x1F, 0xFF, 0xFF, 0x10, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xF0, - 0x1F, 0xFF, 0xFF, 0x10, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xF0, 0x1F, 0xFF, 0xFF, 0x10, - 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xF0, 0x1F, 0xFF, 0xFF, 0x10, 0x00, 0x00, 0x00, 0x00, - 0x01, 0xFF, 0xFF, 0xF0, 0x1F, 0xFF, 0xFF, 0x10, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xF0, - 0x1F, 0xFF, 0xFF, 0x10, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xF0, 0x1F, 0xFF, 0xFF, 0x10, - 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xF0, 0x1F, 0xFF, 0xFF, 0x10, 0x00, 0x00, 0x00, 0x00, - 0x01, 0xFF, 0xFF, 0xF0, 0x1F, 0xFF, 0xFF, 0x10, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xF0, - 0x1F, 0xFF, 0xFF, 0x10, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xF0, 0x1F, 0xFF, 0xFF, 0x10, - 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xF0, 0x0F, 0xFF, 0xFF, 0x20, 0x00, 0x00, 0x00, 0x00, - 0x02, 0xFF, 0xFF, 0xF0, 0x0E, 0xFF, 0xFF, 0x40, 0x00, 0x00, 0x00, 0x00, 0x05, 0xFF, 0xFF, 0xD0, - 0x0B, 0xFF, 0xFF, 0xA0, 0x00, 0x00, 0x00, 0x00, 0x0A, 0xFF, 0xFF, 0xA0, 0x06, 0xFF, 0xFF, 0xF4, - 0x00, 0x00, 0x00, 0x00, 0x5F, 0xFF, 0xFF, 0x60, 0x01, 0xEF, 0xFF, 0xFF, 0x60, 0x00, 0x00, 0x06, - 0xFF, 0xFF, 0xFE, 0x10, 0x00, 0x6F, 0xFF, 0xFF, 0xFD, 0x97, 0x79, 0xDF, 0xFF, 0xFF, 0xF6, 0x00, - 0x00, 0x0A, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xA0, 0x00, 0x00, 0x00, 0x9F, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF9, 0x00, 0x00, 0x00, 0x00, 0x05, 0xDF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFD, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x8C, 0xEF, 0xFE, 0xC9, 0x40, 0x00, 0x00, 0x00, - 0x9F, 0xFF, 0xFB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0B, 0xFF, 0xFF, 0x76, 0xFF, 0xFF, 0xF1, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xFF, 0xFF, 0xF4, 0x1F, 0xFF, 0xFF, 0x60, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x6F, 0xFF, 0xFE, 0x00, 0xBF, 0xFF, 0xFA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0xFF, - 0xFF, 0x90, 0x07, 0xFF, 0xFF, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xEF, 0xFF, 0xF5, 0x00, 0x2F, - 0xFF, 0xFF, 0x30, 0x00, 0x00, 0x00, 0x00, 0x4F, 0xFF, 0xFE, 0x00, 0x00, 0xCF, 0xFF, 0xF8, 0x00, - 0x00, 0x00, 0x00, 0x08, 0xFF, 0xFF, 0xA0, 0x00, 0x08, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, 0x00, - 0xCF, 0xFF, 0xF5, 0x00, 0x00, 0x3F, 0xFF, 0xFF, 0x10, 0x00, 0x00, 0x00, 0x1F, 0xFF, 0xFF, 0x10, - 0x00, 0x00, 0xDF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x06, 0xFF, 0xFF, 0xB0, 0x00, 0x00, 0x09, 0xFF, - 0xFF, 0xA0, 0x00, 0x00, 0x00, 0xAF, 0xFF, 0xF6, 0x00, 0x00, 0x00, 0x4F, 0xFF, 0xFE, 0x00, 0x00, - 0x00, 0x0E, 0xFF, 0xFF, 0x20, 0x00, 0x00, 0x00, 0xEF, 0xFF, 0xF3, 0x00, 0x00, 0x03, 0xFF, 0xFF, - 0xC0, 0x00, 0x00, 0x00, 0x0A, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x8F, 0xFF, 0xF7, 0x00, 0x00, 0x00, - 0x00, 0x5F, 0xFF, 0xFC, 0x00, 0x00, 0x0C, 0xFF, 0xFF, 0x30, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, - 0xF1, 0x00, 0x01, 0xFF, 0xFF, 0xD0, 0x00, 0x00, 0x00, 0x00, 0x0B, 0xFF, 0xFF, 0x50, 0x00, 0x5F, - 0xFF, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6F, 0xFF, 0xFA, 0x00, 0x0A, 0xFF, 0xFF, 0x30, 0x00, - 0x00, 0x00, 0x00, 0x02, 0xFF, 0xFF, 0xE0, 0x00, 0xEF, 0xFF, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x0C, 0xFF, 0xFF, 0x30, 0x3F, 0xFF, 0xF9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8F, 0xFF, 0xF7, - 0x07, 0xFF, 0xFF, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xC0, 0xCF, 0xFF, 0xE0, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0xFF, 0xFF, 0x2F, 0xFF, 0xFA, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x9F, 0xFF, 0xFB, 0xFF, 0xFF, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, - 0xFF, 0xFF, 0xFF, 0xFF, 0xF1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0E, 0xFF, 0xFF, 0xFF, - 0xFB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xAF, 0xFF, 0xFF, 0xFF, 0x60, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0xFF, 0xFF, 0xFF, 0xF2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x1F, 0xFF, 0xFF, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xBF, - 0xFF, 0xFF, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0xFF, 0xFF, 0xF2, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF7, 0x00, 0x00, 0x00, 0x00, 0x06, 0xFF, 0xFF, 0xE1, 0x00, - 0x00, 0x00, 0x00, 0x0A, 0xFF, 0xFF, 0x69, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, 0x00, 0xAF, 0xFF, - 0xFF, 0x40, 0x00, 0x00, 0x00, 0x00, 0xEF, 0xFF, 0xF4, 0x5F, 0xFF, 0xFF, 0x10, 0x00, 0x00, 0x00, - 0x0D, 0xFF, 0xFF, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xFF, 0xFF, 0x01, 0xFF, 0xFF, 0xF4, 0x00, - 0x00, 0x00, 0x02, 0xFF, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, 0x07, 0xFF, 0xFF, 0xB0, 0x0C, 0xFF, - 0xFF, 0x80, 0x00, 0x00, 0x00, 0x6F, 0xFF, 0xFF, 0xFF, 0x10, 0x00, 0x00, 0x00, 0xAF, 0xFF, 0xF7, - 0x00, 0x8F, 0xFF, 0xFC, 0x00, 0x00, 0x00, 0x09, 0xFF, 0xFF, 0xFF, 0xF4, 0x00, 0x00, 0x00, 0x0E, - 0xFF, 0xFF, 0x30, 0x04, 0xFF, 0xFF, 0xF1, 0x00, 0x00, 0x00, 0xDF, 0xFF, 0xFF, 0xFF, 0x80, 0x00, - 0x00, 0x03, 0xFF, 0xFF, 0xE0, 0x00, 0x1F, 0xFF, 0xFF, 0x40, 0x00, 0x00, 0x1F, 0xFF, 0xFF, 0xFF, - 0xFC, 0x00, 0x00, 0x00, 0x6F, 0xFF, 0xFB, 0x00, 0x00, 0xBF, 0xFF, 0xF8, 0x00, 0x00, 0x05, 0xFF, - 0xFF, 0xFF, 0xFF, 0xF1, 0x00, 0x00, 0x0A, 0xFF, 0xFF, 0x70, 0x00, 0x07, 0xFF, 0xFF, 0xB0, 0x00, - 0x00, 0x8F, 0xFF, 0xFC, 0xFF, 0xFF, 0x40, 0x00, 0x00, 0xEF, 0xFF, 0xF3, 0x00, 0x00, 0x3F, 0xFF, - 0xFF, 0x10, 0x00, 0x0C, 0xFF, 0xFE, 0x6F, 0xFF, 0xF8, 0x00, 0x00, 0x2F, 0xFF, 0xFE, 0x00, 0x00, - 0x00, 0xEF, 0xFF, 0xF4, 0x00, 0x01, 0xFF, 0xFF, 0xA2, 0xFF, 0xFF, 0xC0, 0x00, 0x06, 0xFF, 0xFF, - 0xB0, 0x00, 0x00, 0x0A, 0xFF, 0xFF, 0x80, 0x00, 0x4F, 0xFF, 0xF7, 0x0D, 0xFF, 0xFF, 0x10, 0x00, - 0xAF, 0xFF, 0xF7, 0x00, 0x00, 0x00, 0x6F, 0xFF, 0xFB, 0x00, 0x08, 0xFF, 0xFF, 0x30, 0xAF, 0xFF, - 0xF4, 0x00, 0x0D, 0xFF, 0xFF, 0x30, 0x00, 0x00, 0x02, 0xFF, 0xFF, 0xF0, 0x00, 0xBF, 0xFF, 0xE0, - 0x06, 0xFF, 0xFF, 0x80, 0x02, 0xFF, 0xFF, 0xE0, 0x00, 0x00, 0x00, 0x0D, 0xFF, 0xFF, 0x40, 0x0E, - 0xFF, 0xFB, 0x00, 0x2F, 0xFF, 0xFC, 0x00, 0x6F, 0xFF, 0xFA, 0x00, 0x00, 0x00, 0x00, 0x9F, 0xFF, - 0xF8, 0x03, 0xFF, 0xFF, 0x80, 0x00, 0xDF, 0xFF, 0xF1, 0x09, 0xFF, 0xFF, 0x70, 0x00, 0x00, 0x00, - 0x05, 0xFF, 0xFF, 0xB0, 0x7F, 0xFF, 0xF4, 0x00, 0x0A, 0xFF, 0xFF, 0x50, 0xDF, 0xFF, 0xF3, 0x00, - 0x00, 0x00, 0x00, 0x1F, 0xFF, 0xFF, 0x0A, 0xFF, 0xFF, 0x10, 0x00, 0x6F, 0xFF, 0xF8, 0x1F, 0xFF, - 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF4, 0xEF, 0xFF, 0xC0, 0x00, 0x02, 0xFF, 0xFF, - 0xC5, 0xFF, 0xFF, 0xA0, 0x00, 0x00, 0x00, 0x00, 0x08, 0xFF, 0xFF, 0xBF, 0xFF, 0xF9, 0x00, 0x00, - 0x0E, 0xFF, 0xFF, 0xAF, 0xFF, 0xF6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4F, 0xFF, 0xFF, 0xFF, 0xFF, - 0x50, 0x00, 0x00, 0xAF, 0xFF, 0xFF, 0xFF, 0xFF, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, - 0xFF, 0xFF, 0xF2, 0x00, 0x00, 0x06, 0xFF, 0xFF, 0xFF, 0xFF, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x0B, 0xFF, 0xFF, 0xFF, 0xFD, 0x00, 0x00, 0x00, 0x3F, 0xFF, 0xFF, 0xFF, 0xFA, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x7F, 0xFF, 0xFF, 0xFF, 0xA0, 0x00, 0x00, 0x00, 0xEF, 0xFF, 0xFF, 0xFF, 0x60, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xFF, 0xF6, 0x00, 0x00, 0x00, 0x0A, 0xFF, 0xFF, - 0xFF, 0xF2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0E, 0xFF, 0xFF, 0xFF, 0x30, 0x00, 0x00, 0x00, - 0x7F, 0xFF, 0xFF, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xAF, 0xFF, 0xFF, 0xE0, 0x00, - 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xFF, 0xA0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0xFF, 0xFF, - 0xFB, 0x00, 0x00, 0x00, 0x00, 0x0E, 0xFF, 0xFF, 0xF6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x2F, 0xFF, 0xFF, 0x70, 0x00, 0x00, 0x00, 0x00, 0xBF, 0xFF, 0xFF, 0x20, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF3, 0x00, 0x00, 0x00, 0x00, 0x06, 0xFF, 0xFF, 0xD0, 0x00, 0x00, - 0x00, 0x00, 0x6F, 0xFF, 0xFE, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1D, 0xFF, 0xFF, 0x70, 0xDF, - 0xFF, 0xFA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0xFF, 0xFF, 0xE1, 0x05, 0xFF, 0xFF, 0xF4, 0x00, - 0x00, 0x00, 0x00, 0x02, 0xFF, 0xFF, 0xF6, 0x00, 0x0B, 0xFF, 0xFF, 0xD0, 0x00, 0x00, 0x00, 0x00, - 0xBF, 0xFF, 0xFC, 0x00, 0x00, 0x2F, 0xFF, 0xFF, 0x70, 0x00, 0x00, 0x00, 0x5F, 0xFF, 0xFF, 0x30, - 0x00, 0x00, 0x8F, 0xFF, 0xFE, 0x10, 0x00, 0x00, 0x0D, 0xFF, 0xFF, 0x90, 0x00, 0x00, 0x01, 0xDF, - 0xFF, 0xF9, 0x00, 0x00, 0x07, 0xFF, 0xFF, 0xE1, 0x00, 0x00, 0x00, 0x05, 0xFF, 0xFF, 0xF3, 0x00, - 0x02, 0xEF, 0xFF, 0xF7, 0x00, 0x00, 0x00, 0x00, 0x0B, 0xFF, 0xFF, 0xC0, 0x00, 0xAF, 0xFF, 0xFC, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x2F, 0xFF, 0xFF, 0x60, 0x4F, 0xFF, 0xFF, 0x40, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x8F, 0xFF, 0xFE, 0x1D, 0xFF, 0xFF, 0xA0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xEF, - 0xFF, 0xFD, 0xFF, 0xFF, 0xE2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0xFF, 0xFF, 0xFF, 0xFF, - 0xF7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0xFF, 0xFF, 0xFF, 0xFD, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xFF, 0xFF, 0xFF, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xBF, 0xFF, 0xFF, 0xD0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xFF, - 0xFF, 0xFF, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0B, 0xFF, 0xFF, 0xFF, 0xFD, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0xFF, 0xFF, 0xFF, 0xFF, 0xF7, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x01, 0xEF, 0xFF, 0xFD, 0xFF, 0xFF, 0xE2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8F, - 0xFF, 0xFE, 0x1D, 0xFF, 0xFF, 0xA0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2F, 0xFF, 0xFF, 0x60, 0x4F, - 0xFF, 0xFF, 0x40, 0x00, 0x00, 0x00, 0x00, 0x0B, 0xFF, 0xFF, 0xC0, 0x00, 0xAF, 0xFF, 0xFC, 0x00, - 0x00, 0x00, 0x00, 0x05, 0xFF, 0xFF, 0xF3, 0x00, 0x02, 0xFF, 0xFF, 0xF6, 0x00, 0x00, 0x00, 0x01, - 0xDF, 0xFF, 0xF9, 0x00, 0x00, 0x08, 0xFF, 0xFF, 0xE1, 0x00, 0x00, 0x00, 0x8F, 0xFF, 0xFE, 0x10, - 0x00, 0x00, 0x1D, 0xFF, 0xFF, 0x90, 0x00, 0x00, 0x2F, 0xFF, 0xFF, 0x60, 0x00, 0x00, 0x00, 0x5F, - 0xFF, 0xFF, 0x30, 0x00, 0x0B, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, 0x00, 0xBF, 0xFF, 0xFC, 0x00, - 0x05, 0xFF, 0xFF, 0xF3, 0x00, 0x00, 0x00, 0x00, 0x02, 0xFF, 0xFF, 0xF6, 0x00, 0xDF, 0xFF, 0xF9, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0xFF, 0xFF, 0xE1, 0x6F, 0xFF, 0xFE, 0x10, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x1D, 0xFF, 0xFF, 0x70, 0x7F, 0xFF, 0xFD, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8F, - 0xFF, 0xFD, 0x1E, 0xFF, 0xFF, 0x60, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xF7, 0x08, 0xFF, - 0xFF, 0xD0, 0x00, 0x00, 0x00, 0x00, 0x09, 0xFF, 0xFF, 0xE1, 0x01, 0xEF, 0xFF, 0xF6, 0x00, 0x00, - 0x00, 0x00, 0x1F, 0xFF, 0xFF, 0x60, 0x00, 0x8F, 0xFF, 0xFD, 0x00, 0x00, 0x00, 0x00, 0x9F, 0xFF, - 0xFD, 0x00, 0x00, 0x1E, 0xFF, 0xFF, 0x60, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xF6, 0x00, 0x00, 0x07, - 0xFF, 0xFF, 0xD0, 0x00, 0x00, 0x09, 0xFF, 0xFF, 0xD0, 0x00, 0x00, 0x01, 0xEF, 0xFF, 0xF6, 0x00, - 0x00, 0x1F, 0xFF, 0xFF, 0x60, 0x00, 0x00, 0x00, 0x7F, 0xFF, 0xFD, 0x00, 0x00, 0x9F, 0xFF, 0xFD, - 0x00, 0x00, 0x00, 0x00, 0x1E, 0xFF, 0xFF, 0x60, 0x01, 0xFF, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00, - 0x07, 0xFF, 0xFF, 0xD0, 0x09, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x01, 0xEF, 0xFF, 0xF6, - 0x1F, 0xFF, 0xFF, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6F, 0xFF, 0xFD, 0x9F, 0xFF, 0xFC, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0xFF, 0xFF, 0xFF, 0xFF, 0xF4, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x06, 0xFF, 0xFF, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xDF, 0xFF, - 0xFF, 0xFF, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6F, 0xFF, 0xFF, 0xFB, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0xFF, 0xFF, 0xF3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x07, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0xFF, - 0xFF, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0xFF, 0xFF, 0xB0, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0xFF, 0xFF, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x06, 0xFF, 0xFF, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0xFF, - 0xFF, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0xFF, 0xFF, 0xB0, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0xFF, 0xFF, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x06, 0xFF, 0xFF, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0xFF, - 0xFF, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0xFF, 0xFF, 0xB0, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0xFF, 0xFF, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x05, 0xFF, 0xFF, 0x90, 0x00, 0x00, 0x00, 0x00, 0x4F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xF6, 0x6F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF7, - 0x6F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF7, 0x6F, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF7, 0x16, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x6A, 0xFF, 0xFF, - 0xF6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1D, 0xFF, 0xFF, 0xD1, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x9F, 0xFF, 0xFF, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0xFF, 0xFF, - 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xAF, 0xFF, 0xFE, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0xFF, 0xFF, - 0xF6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2E, 0xFF, 0xFF, 0xB0, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xBF, 0xFF, 0xFE, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xFF, 0xFF, - 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xFF, 0xFF, 0xA0, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xFD, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0xFF, 0xFF, - 0xF4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x01, 0xDF, 0xFF, 0xFD, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0xFF, 0xFF, - 0xF3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5F, 0xFF, 0xFF, 0x70, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x01, 0xEF, 0xFF, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0xFF, 0xFF, - 0xE2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6F, 0xFF, 0xFF, 0x60, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x02, 0xEF, 0xFF, 0xFA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0B, 0xFF, 0xFF, - 0xE1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4F, 0xFF, 0xFF, 0xB6, 0x66, 0x66, 0x66, 0x66, - 0x66, 0x66, 0x62, 0x6F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF7, 0x6F, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF7, 0x6F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xF7, 0x4F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF6, 0x1E, - 0xFF, 0xFD, 0x01, 0xFF, 0xFF, 0xE0, 0x1F, 0xFF, 0xFE, 0x01, 0xFF, 0xFF, 0xE0, 0x0F, 0xFF, 0xFD, - 0x00, 0xFF, 0xFF, 0xD0, 0x0F, 0xFF, 0xFD, 0x00, 0xEF, 0xFF, 0xC0, 0x0E, 0xFF, 0xFC, 0x00, 0xDF, - 0xFF, 0xC0, 0x0D, 0xFF, 0xFB, 0x00, 0xDF, 0xFF, 0xB0, 0x0C, 0xFF, 0xFA, 0x00, 0xCF, 0xFF, 0xA0, - 0x0C, 0xFF, 0xFA, 0x00, 0xBF, 0xFF, 0x90, 0x0B, 0xFF, 0xF9, 0x00, 0xBF, 0xFF, 0x90, 0x0A, 0xFF, - 0xF8, 0x00, 0xAF, 0xFF, 0x80, 0x08, 0xFF, 0xF6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8D, 0xEA, 0x20, 0x7F, 0xFF, 0xFD, 0x0C, 0xFF, 0xFF, - 0xF3, 0xCF, 0xFF, 0xFF, 0x37, 0xFF, 0xFF, 0xC0, 0x08, 0xDE, 0xA2, 0x00, -]; - -static FONT_LG_GLYPHS: [Glyph; 38] = [ - Glyph { ch: 32, x_off: 0, y_off: 0, w: 0, h: 0, adv: 9, offset: 0 }, - Glyph { ch: 48, x_off: 2, y_off: 0, w: 21, h: 31, adv: 26, offset: 0 }, - Glyph { ch: 49, x_off: 6, y_off: 0, w: 12, h: 31, adv: 26, offset: 326 }, - Glyph { ch: 50, x_off: 3, y_off: 0, w: 21, h: 31, adv: 26, offset: 512 }, - Glyph { ch: 51, x_off: 2, y_off: 0, w: 21, h: 31, adv: 26, offset: 838 }, - Glyph { ch: 52, x_off: 1, y_off: 0, w: 23, h: 31, adv: 26, offset: 1164 }, - Glyph { ch: 53, x_off: 3, y_off: 0, w: 20, h: 31, adv: 26, offset: 1521 }, - Glyph { ch: 54, x_off: 3, y_off: 0, w: 20, h: 31, adv: 26, offset: 1831 }, - Glyph { ch: 55, x_off: 3, y_off: 0, w: 20, h: 31, adv: 26, offset: 2141 }, - Glyph { ch: 56, x_off: 2, y_off: 0, w: 21, h: 31, adv: 26, offset: 2451 }, - Glyph { ch: 57, x_off: 2, y_off: 0, w: 20, h: 31, adv: 26, offset: 2777 }, - Glyph { ch: 65, x_off: 1, y_off: 0, w: 27, h: 31, adv: 29, offset: 3087 }, - Glyph { ch: 66, x_off: 3, y_off: 0, w: 22, h: 31, adv: 27, offset: 3506 }, - Glyph { ch: 67, x_off: 2, y_off: 0, w: 23, h: 31, adv: 27, offset: 3847 }, - Glyph { ch: 68, x_off: 3, y_off: 0, w: 22, h: 31, adv: 27, offset: 4204 }, - Glyph { ch: 69, x_off: 3, y_off: 0, w: 22, h: 31, adv: 26, offset: 4545 }, - Glyph { ch: 70, x_off: 3, y_off: 0, w: 22, h: 31, adv: 25, offset: 4886 }, - Glyph { ch: 71, x_off: 2, y_off: 0, w: 23, h: 31, adv: 27, offset: 5227 }, - Glyph { ch: 72, x_off: 3, y_off: 0, w: 23, h: 31, adv: 28, offset: 5584 }, - Glyph { ch: 73, x_off: 3, y_off: 0, w: 6, h: 31, adv: 12, offset: 5941 }, - Glyph { ch: 74, x_off: 0, y_off: 0, w: 23, h: 31, adv: 26, offset: 6034 }, - Glyph { ch: 75, x_off: 3, y_off: 0, w: 24, h: 31, adv: 27, offset: 6391 }, - Glyph { ch: 76, x_off: 3, y_off: 0, w: 21, h: 31, adv: 25, offset: 6763 }, - Glyph { ch: 77, x_off: 3, y_off: 0, w: 26, h: 31, adv: 31, offset: 7089 }, - Glyph { ch: 78, x_off: 3, y_off: 0, w: 24, h: 31, adv: 29, offset: 7492 }, - Glyph { ch: 79, x_off: 2, y_off: 0, w: 23, h: 31, adv: 27, offset: 7864 }, - Glyph { ch: 80, x_off: 2, y_off: 0, w: 23, h: 31, adv: 26, offset: 8221 }, - Glyph { ch: 81, x_off: 2, y_off: 0, w: 22, h: 36, adv: 26, offset: 8578 }, - Glyph { ch: 82, x_off: 3, y_off: 0, w: 23, h: 31, adv: 27, offset: 8974 }, - Glyph { ch: 83, x_off: 1, y_off: 0, w: 24, h: 31, adv: 26, offset: 9331 }, - Glyph { ch: 84, x_off: 1, y_off: 0, w: 23, h: 31, adv: 25, offset: 9703 }, - Glyph { ch: 85, x_off: 2, y_off: 0, w: 24, h: 31, adv: 28, offset: 10060 }, - Glyph { ch: 86, x_off: 1, y_off: 0, w: 25, h: 31, adv: 27, offset: 10432 }, - Glyph { ch: 87, x_off: 1, y_off: 0, w: 37, h: 31, adv: 39, offset: 10820 }, - Glyph { ch: 88, x_off: 1, y_off: 0, w: 25, h: 31, adv: 27, offset: 11394 }, - Glyph { ch: 89, x_off: 1, y_off: 0, w: 24, h: 31, adv: 26, offset: 11782 }, - Glyph { ch: 90, x_off: 1, y_off: 0, w: 22, h: 31, adv: 24, offset: 12154 }, - Glyph { ch: 33, x_off: 4, y_off: 0, w: 7, h: 31, adv: 15, offset: 12495 }, -]; - -pub static FONT_LG: Font = Font { glyphs: &FONT_LG_GLYPHS, data: &FONT_LG_DATA }; diff --git a/apps/vault-rush/src/game.rs b/apps/vault-rush/src/game.rs deleted file mode 100644 index a154c4d..0000000 --- a/apps/vault-rush/src/game.rs +++ /dev/null @@ -1,814 +0,0 @@ -//! Pure game state machine for Vault Rush (no `Api`, runs under `cargo test` on host). -//! Supports Classic (streak), Heist (selectable 10s..60s timed win with gold), and Blitz (60s arcade), -//! plus smooth fixed-point transitions for flying into the bank, safe zoom-in, and door-opening gold reveal. - -use cmf_wp2_ui::ONE; -use cmf_wp2_ui::motion::ease_out; - -/// Number of detents around the safe dial (10° per detent). -pub const DIAL_STEPS: i32 = 36; -/// Maximum lives in Classic mode. -pub const CLASSIC_LIVES: u8 = 3; -/// Maximum pins on a Classic safe. -pub const MAX_PINS: usize = 5; -/// Selectable time options (seconds) in Heist mode. -pub const HEIST_TIMES_S: [u8; 6] = [10, 20, 30, 40, 50, 60]; -/// Minimum steps in the required direction before a directional pin arms. -pub const ARM_STEPS_CLASSIC: u16 = 3; -pub const ARM_STEPS_HEIST: u16 = 2; - -/// Timers (ms). -pub const BLITZ_START_MS: i32 = 60_000; -pub const BLITZ_EXACT_BONUS_MS: i32 = 3_000; -pub const BLITZ_GOOD_BONUS_MS: i32 = 1_000; -pub const BLITZ_MISS_PENALTY_MS: i32 = 4_000; -pub const SIREN_THRESHOLD_MS: i32 = 5_000; - -/// Animation durations (ms). -pub const ENTER_BANK_MS: u32 = 620; -pub const ZOOM_MS: u32 = 520; -pub const UNLOCK_MS: u32 = 320; -pub const OPEN_MS: u32 = 560; -pub const GOLD_CLASSIC_HOLD_MS: u32 = 1_350; -pub const OVER_SLAM_MS: u32 = 440; -pub const OVER_ANIM_MS: u32 = 1_400; -pub const FLASH_MS: u32 = 520; - -#[derive(Clone, Copy, PartialEq, Eq, Debug)] -pub enum Mode { - Classic, - Heist, - Blitz, -} - -#[derive(Clone, Copy, PartialEq, Eq, Debug)] -pub enum State { - Menu, - HeistSelect, - /// Camera flies into the bank entrance and fades to dark before the safe appears. - EnterBank, - /// Safe fades in and zooms in to the dial wheel. - ZoomIn, - Playing, - /// Dial wheel spins/shrinks off and locking bolts retract. - Unlocking, - /// Steel door swings open to reveal gold. - Opening, - /// Classic celebration pause before advancing to the next safe. - ClassicGold, - /// Heist victory screen showing the open safe full of gold. - HeistWin, - /// Failure / busted screen (behind jail bars). - Over, -} - -#[derive(Clone, Copy, PartialEq, Eq, Debug)] -pub enum Dir { - Cw, - Ccw, -} - -impl Dir { - pub fn flip(self) -> Self { - match self { - Dir::Cw => Dir::Ccw, - Dir::Ccw => Dir::Cw, - } - } -} - -#[derive(Clone, Copy, PartialEq, Eq, Debug)] -pub enum Zone { - Cold, - Warm, - Hot, - Exact, -} - -#[derive(Clone, Copy, PartialEq, Eq, Debug)] -pub enum Flash { - None, - PinLock, - ExactBonus, - GoodBonus, - Miss, - WrongDir, -} - -#[derive(Clone, Copy, PartialEq, Eq, Debug)] -pub enum Feedback { - None, - ColdTick, - WarmTick, - HotTick, - ExactTick, - PinLock, - SafeOpen, - Miss, - Warn, - GameOver, -} - -#[derive(Clone, Copy, PartialEq, Eq, Debug, Default)] -pub struct Records { - pub classic: u32, - pub blitz: u32, - /// Fastest Heist clear time in ms for each `HEIST_TIMES_S` bucket (`0` = not cleared yet). - pub heist_best_ms: [u32; 6], -} - -#[derive(Clone)] -pub struct Game { - pub state: State, - pub mode: Mode, - /// Menu focus (`0` = Classic, `1` = Heist, `2` = Blitz). - pub menu_sel: usize, - /// Selected Heist duration index (`0..6` -> `10s..60s`). - pub heist_idx: usize, - /// End-screen focus (`0` = Retry/Again, `1` = Menu). - pub over_sel: usize, - /// Current dial position `0..DIAL_STEPS`. - pub dial: i32, - /// Secret pin angle `0..DIAL_STEPS`. - pub target: i32, - /// Safes/locks cracked in this run. - pub score: u32, - /// Current pin index (`0..pin_count`). - pub pin_idx: usize, - /// Total pins in the current safe. - pub pin_count: usize, - /// Required turn direction for directional pins. - pub expected_dir: Dir, - /// Steps moved in `expected_dir` since the current pin started. - pub dir_progress: u16, - /// Remaining lives in Classic. - pub lives: u8, - /// Remaining countdown in Blitz / Heist (ms). - pub time_ms: i32, - /// Elapsed time in Heist (ms). - pub elapsed_ms: u32, - /// Consecutive exact hits in Blitz. - pub combo: u32, - /// Whether this run set a new record. - pub new_best: bool, - /// Transition progress (ms) for animations. - pub anim_ms: u32, - /// Transient LED/status flash while playing. - pub flash: Flash, - pub flash_left_ms: i32, - rng: u32, -} - -fn next(rng: &mut u32) -> u32 { - let mut x = *rng; - x ^= x << 13; - x ^= x >> 17; - x ^= x << 5; - *rng = x; - x -} - -pub fn ring_dist(a: i32, b: i32) -> i32 { - let d = (a - b).rem_euclid(DIAL_STEPS); - d.min(DIAL_STEPS - d) -} - -pub fn zone_for_dist(d: i32) -> Zone { - if d == 0 { - Zone::Exact - } else if d <= 2 { - Zone::Hot - } else if d <= 5 { - Zone::Warm - } else { - Zone::Cold - } -} - -pub fn pins_for_safe(score: u32) -> usize { - if score < 2 { - 3 - } else if score < 5 { - 4 - } else { - MAX_PINS - } -} - -pub fn heist_pins_for_idx(idx: usize) -> usize { - if idx <= 2 { 3 } else { 4 } -} - -pub fn heist_penalty_for_idx(idx: usize) -> i32 { - match idx { - 0 => 2_000, - 1 => 3_000, - _ => 4_000, - } -} - -impl Game { - pub fn new(seed: u32) -> Self { - Game { - state: State::Menu, - mode: Mode::Classic, - menu_sel: 0, - heist_idx: 3, // default 40s - over_sel: 0, - dial: 0, - target: 12, - score: 0, - pin_idx: 0, - pin_count: 3, - expected_dir: Dir::Cw, - dir_progress: 0, - lives: CLASSIC_LIVES, - time_ms: BLITZ_START_MS, - elapsed_ms: 0, - combo: 0, - new_best: false, - anim_ms: 0, - flash: Flash::None, - flash_left_ms: 0, - rng: seed | 1, - } - } - - pub fn zone(&self) -> Zone { - zone_for_dist(ring_dist(self.dial, self.target)) - } - - pub fn arm_threshold(&self) -> u16 { - match self.mode { - Mode::Classic => ARM_STEPS_CLASSIC, - Mode::Heist => ARM_STEPS_HEIST, - Mode::Blitz => 0, - } - } - - pub fn armed(&self) -> bool { - self.mode == Mode::Blitz || self.dir_progress >= self.arm_threshold() - } - - /// Returns `0` when off, or `1`/`2` alternating police siren phases during the last 5 seconds. - pub fn siren_phase(&self) -> u8 { - if self.state == State::Playing - && matches!(self.mode, Mode::Heist | Mode::Blitz) - && self.time_ms > 0 - && self.time_ms <= SIREN_THRESHOLD_MS - { - (((self.time_ms / 250) & 1) + 1) as u8 - } else { - 0 - } - } - - pub fn animating(&self) -> bool { - matches!( - self.state, - State::EnterBank | State::ZoomIn | State::Unlocking | State::Opening | State::ClassicGold | State::HeistWin - ) || (self.state == State::Over && self.anim_ms < OVER_ANIM_MS) - || (self.state == State::Playing && (self.mode != Mode::Classic || self.flash != Flash::None)) - } - - pub fn anim_t(&self) -> i32 { - let dur = match self.state { - State::EnterBank => ENTER_BANK_MS, - State::ZoomIn => ZOOM_MS, - State::Unlocking => UNLOCK_MS, - State::Opening => OPEN_MS, - State::ClassicGold => GOLD_CLASSIC_HOLD_MS, - _ => return ONE, - }; - let linear = ((self.anim_ms.min(dur) as i32) * ONE / dur as i32).clamp(0, ONE); - ease_out(linear) - } - - pub fn open_heist_select(&mut self) { - self.mode = Mode::Heist; - self.menu_sel = 1; - self.state = State::HeistSelect; - self.flash = Flash::None; - self.flash_left_ms = 0; - } - - pub fn back_to_menu(&mut self) { - self.state = State::Menu; - self.menu_sel = match self.mode { - Mode::Classic => 0, - Mode::Heist => 1, - Mode::Blitz => 2, - }; - self.flash = Flash::None; - self.flash_left_ms = 0; - self.anim_ms = 0; - } - - pub fn start_heist(&mut self, idx: usize) { - self.heist_idx = idx.min(HEIST_TIMES_S.len() - 1); - self.start(Mode::Heist); - } - - pub fn start(&mut self, mode: Mode) { - self.mode = mode; - self.state = State::EnterBank; - self.anim_ms = 0; - self.over_sel = 0; - self.score = 0; - self.pin_idx = 0; - self.lives = CLASSIC_LIVES; - self.elapsed_ms = 0; - self.combo = 0; - self.new_best = false; - self.flash = Flash::None; - self.flash_left_ms = 0; - self.expected_dir = Dir::Cw; - self.dir_progress = 0; - self.time_ms = match mode { - Mode::Heist => HEIST_TIMES_S[self.heist_idx] as i32 * 1000, - Mode::Blitz => BLITZ_START_MS, - Mode::Classic => 0, - }; - self.pin_count = match mode { - Mode::Classic => pins_for_safe(0), - Mode::Heist => heist_pins_for_idx(self.heist_idx), - Mode::Blitz => 1, - }; - self.target = self.pick_target(6); - } - - fn setup_next_classic_safe(&mut self) { - self.pin_idx = 0; - self.pin_count = pins_for_safe(self.score); - self.expected_dir = Dir::Cw; - self.dir_progress = 0; - self.target = self.pick_target(6); - self.flash = Flash::None; - self.flash_left_ms = 0; - self.state = State::Playing; - } - - fn pick_target(&mut self, min_away: i32) -> i32 { - for _ in 0..16 { - let candidate = (next(&mut self.rng) % DIAL_STEPS as u32) as i32; - if ring_dist(candidate, self.dial) >= min_away { - return candidate; - } - } - (self.dial + DIAL_STEPS / 2) % DIAL_STEPS - } - - fn set_flash(&mut self, f: Flash) { - self.flash = f; - self.flash_left_ms = FLASH_MS as i32; - } - - fn enter_over(&mut self) { - self.state = State::Over; - self.over_sel = 0; - self.anim_ms = 0; - self.flash = Flash::None; - self.flash_left_ms = 0; - } - - pub fn crown(&mut self, delta: i16) -> Feedback { - if delta == 0 { - return Feedback::None; - } - match self.state { - State::Menu => { - let n = 3i32; - self.menu_sel = (self.menu_sel as i32 + delta.signum() as i32).rem_euclid(n) as usize; - self.mode = match self.menu_sel { - 0 => Mode::Classic, - 1 => Mode::Heist, - _ => Mode::Blitz, - }; - Feedback::ColdTick - } - State::HeistSelect => { - let n = HEIST_TIMES_S.len() as i32; - self.heist_idx = (self.heist_idx as i32 + delta.signum() as i32).rem_euclid(n) as usize; - Feedback::ColdTick - } - State::Over | State::HeistWin => { - self.over_sel = 1 - self.over_sel; - Feedback::ColdTick - } - State::Playing => { - self.dial = (self.dial + delta as i32).rem_euclid(DIAL_STEPS); - if self.mode != Mode::Blitz { - let turned = if delta > 0 { Dir::Cw } else { Dir::Ccw }; - let mag = delta.unsigned_abs(); - if turned == self.expected_dir { - self.dir_progress = self.dir_progress.saturating_add(mag).min(self.arm_threshold() + 10); - } else if self.dir_progress < self.arm_threshold() { - self.dir_progress = 0; - } - } - match self.zone() { - Zone::Exact => Feedback::ExactTick, - Zone::Hot => Feedback::HotTick, - Zone::Warm => Feedback::WarmTick, - Zone::Cold => Feedback::ColdTick, - } - } - _ => Feedback::None, - } - } - - pub fn try_lock(&mut self, best: &mut Records) -> (Feedback, bool) { - if self.state != State::Playing { - return (Feedback::None, false); - } - let d = ring_dist(self.dial, self.target); - match self.mode { - Mode::Classic => { - if !self.armed() { - self.set_flash(Flash::WrongDir); - return (Feedback::Warn, false); - } - if d == 0 { - self.pin_idx += 1; - if self.pin_idx >= self.pin_count { - self.score += 1; - let broke = self.record_classic(best); - self.state = State::Unlocking; - self.anim_ms = 0; - self.flash = Flash::None; - (Feedback::SafeOpen, broke) - } else { - self.expected_dir = self.expected_dir.flip(); - self.dir_progress = 0; - self.target = self.pick_target(6); - self.set_flash(Flash::PinLock); - (Feedback::PinLock, false) - } - } else { - self.lives = self.lives.saturating_sub(1); - if self.lives == 0 { - let broke = self.record_classic(best); - self.enter_over(); - (Feedback::GameOver, broke) - } else { - self.set_flash(Flash::Miss); - (Feedback::Miss, false) - } - } - } - Mode::Heist => { - if !self.armed() { - self.set_flash(Flash::WrongDir); - return (Feedback::Warn, false); - } - if d == 0 { - self.pin_idx += 1; - if self.pin_idx >= self.pin_count { - self.score = 1; - let broke = self.record_heist(best); - self.state = State::Unlocking; - self.anim_ms = 0; - self.flash = Flash::None; - (Feedback::SafeOpen, broke) - } else { - self.expected_dir = self.expected_dir.flip(); - self.dir_progress = 0; - self.target = self.pick_target(6); - self.set_flash(Flash::PinLock); - (Feedback::PinLock, false) - } - } else { - let pen = heist_penalty_for_idx(self.heist_idx); - self.time_ms = (self.time_ms - pen).max(0); - if self.time_ms == 0 { - self.enter_over(); - (Feedback::GameOver, false) - } else { - self.set_flash(Flash::Miss); - (Feedback::Miss, false) - } - } - } - Mode::Blitz => { - if d <= 1 { - self.score += 1; - let broke = self.record_blitz(best); - if d == 0 { - self.combo += 1; - self.time_ms = (self.time_ms + BLITZ_EXACT_BONUS_MS).min(99_900); - self.set_flash(Flash::ExactBonus); - } else { - self.combo = 0; - self.time_ms = (self.time_ms + BLITZ_GOOD_BONUS_MS).min(99_900); - self.set_flash(Flash::GoodBonus); - } - self.target = self.pick_target(5); - (Feedback::SafeOpen, broke) - } else { - self.combo = 0; - self.time_ms = (self.time_ms - BLITZ_MISS_PENALTY_MS).max(0); - if self.time_ms == 0 { - let broke = self.record_blitz(best); - self.enter_over(); - (Feedback::GameOver, broke) - } else { - self.set_flash(Flash::Miss); - (Feedback::Miss, false) - } - } - } - } - } - - pub fn skip_gold_hold(&mut self) { - if self.state == State::ClassicGold { - self.setup_next_classic_safe(); - } - } - - pub fn tick(&mut self, dt_ms: u32, best: &mut Records) -> (Feedback, bool) { - if self.flash != Flash::None { - self.flash_left_ms -= dt_ms as i32; - if self.flash_left_ms <= 0 { - self.flash = Flash::None; - self.flash_left_ms = 0; - } - } - - match self.state { - State::EnterBank => { - self.anim_ms = self.anim_ms.saturating_add(dt_ms); - if self.anim_ms >= ENTER_BANK_MS { - self.anim_ms = 0; - self.state = State::ZoomIn; - } - (Feedback::None, false) - } - State::ZoomIn => { - self.anim_ms = self.anim_ms.saturating_add(dt_ms); - if self.anim_ms >= ZOOM_MS { - self.anim_ms = 0; - self.state = State::Playing; - } - (Feedback::None, false) - } - State::Unlocking => { - self.anim_ms = self.anim_ms.saturating_add(dt_ms); - if self.anim_ms >= UNLOCK_MS { - self.anim_ms = 0; - self.state = State::Opening; - } - (Feedback::None, false) - } - State::Opening => { - self.anim_ms = self.anim_ms.saturating_add(dt_ms); - if self.anim_ms >= OPEN_MS { - self.anim_ms = 0; - match self.mode { - Mode::Classic => self.state = State::ClassicGold, - Mode::Heist => { - self.over_sel = 0; - self.state = State::HeistWin; - } - Mode::Blitz => self.state = State::Playing, - } - } - (Feedback::None, false) - } - State::ClassicGold => { - self.anim_ms = self.anim_ms.saturating_add(dt_ms); - if self.anim_ms >= GOLD_CLASSIC_HOLD_MS { - self.setup_next_classic_safe(); - } - (Feedback::None, false) - } - State::HeistWin => { - self.anim_ms = self.anim_ms.wrapping_add(dt_ms); - (Feedback::None, false) - } - State::Over => { - if self.anim_ms < OVER_ANIM_MS { - self.anim_ms = self.anim_ms.saturating_add(dt_ms).min(OVER_ANIM_MS); - } - (Feedback::None, false) - } - State::Playing => match self.mode { - Mode::Classic => (Feedback::None, false), - Mode::Heist => { - self.elapsed_ms = self.elapsed_ms.saturating_add(dt_ms); - self.time_ms = (self.time_ms - dt_ms as i32).max(0); - if self.time_ms == 0 { - self.enter_over(); - return (Feedback::GameOver, false); - } - (Feedback::None, false) - } - Mode::Blitz => { - self.time_ms = (self.time_ms - dt_ms as i32).max(0); - if self.time_ms == 0 { - let broke = self.record_blitz(best); - self.enter_over(); - return (Feedback::GameOver, broke); - } - (Feedback::None, false) - } - }, - State::Menu | State::HeistSelect => (Feedback::None, false), - } - } - - fn record_classic(&mut self, best: &mut Records) -> bool { - if self.score > best.classic { - best.classic = self.score; - self.new_best = true; - true - } else { - false - } - } - - fn record_blitz(&mut self, best: &mut Records) -> bool { - if self.score > best.blitz { - best.blitz = self.score; - self.new_best = true; - true - } else { - false - } - } - - fn record_heist(&mut self, best: &mut Records) -> bool { - let t = self.elapsed_ms.max(100); - let slot = &mut best.heist_best_ms[self.heist_idx]; - if *slot == 0 || t < *slot { - *slot = t; - self.new_best = true; - true - } else { - false - } - } -} - -/// Encodes saved records: `"VC3"` + classic (`u32`) + blitz (`u32`) + 6 × heist_best_ms (`u32`). -pub fn encode(r: Records) -> [u8; 35] { - let mut out = [0u8; 35]; - out[0..3].copy_from_slice(b"VC3"); - out[3..7].copy_from_slice(&r.classic.to_le_bytes()); - out[7..11].copy_from_slice(&r.blitz.to_le_bytes()); - for (i, &ms) in r.heist_best_ms.iter().enumerate() { - let off = 11 + i * 4; - out[off..off + 4].copy_from_slice(&ms.to_le_bytes()); - } - out -} - -/// Decodes `VC3` (migrating `VC2`/`VC1`); corrupted blobs return zeros. -pub fn decode(blob: &[u8]) -> Records { - if blob.len() == 35 && &blob[0..3] == b"VC3" { - let mut r = Records { - classic: u32::from_le_bytes([blob[3], blob[4], blob[5], blob[6]]), - blitz: u32::from_le_bytes([blob[7], blob[8], blob[9], blob[10]]), - heist_best_ms: [0; 6], - }; - for (i, slot) in r.heist_best_ms.iter_mut().enumerate() { - let off = 11 + i * 4; - *slot = u32::from_le_bytes([blob[off], blob[off + 1], blob[off + 2], blob[off + 3]]); - } - return r; - } - if blob.len() == 15 && &blob[0..3] == b"VC2" { - let mut r = Records { - classic: u32::from_le_bytes([blob[3], blob[4], blob[5], blob[6]]), - blitz: u32::from_le_bytes([blob[7], blob[8], blob[9], blob[10]]), - heist_best_ms: [0; 6], - }; - r.heist_best_ms[3] = u32::from_le_bytes([blob[11], blob[12], blob[13], blob[14]]); - return r; - } - if blob.len() == 11 && &blob[0..3] == b"VC1" { - return Records { - classic: u32::from_le_bytes([blob[3], blob[4], blob[5], blob[6]]), - blitz: u32::from_le_bytes([blob[7], blob[8], blob[9], blob[10]]), - heist_best_ms: [0; 6], - }; - } - Records::default() -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn menu_and_heist_time_selector_cycle_cleanly() { - let mut g = Game::new(1); - g.crown(1); - assert_eq!((g.menu_sel, g.mode), (1, Mode::Heist)); - g.open_heist_select(); - assert_eq!(g.state, State::HeistSelect); - assert_eq!(HEIST_TIMES_S[g.heist_idx], 40); - - g.crown(1); - assert_eq!(HEIST_TIMES_S[g.heist_idx], 50); - g.crown(1); - assert_eq!(HEIST_TIMES_S[g.heist_idx], 60); - g.crown(1); - assert_eq!(HEIST_TIMES_S[g.heist_idx], 10); - g.crown(-1); - assert_eq!(HEIST_TIMES_S[g.heist_idx], 60); - } - - #[test] - fn enter_bank_zoom_in_and_siren_phases() { - let mut best = Records::default(); - let mut g = Game::new(55); - g.start_heist(0); // 10s - assert_eq!(g.state, State::EnterBank); - assert_eq!(g.siren_phase(), 0); - g.tick(ENTER_BANK_MS, &mut best); - assert_eq!(g.state, State::ZoomIn); - g.tick(ZOOM_MS, &mut best); - assert_eq!(g.state, State::Playing); - assert_eq!(g.siren_phase(), 0); - - // Advance into the final 5 seconds -> police siren alternates 1 / 2. - g.tick(6_000, &mut best); - assert_eq!(g.time_ms, 4_000); - let p1 = g.siren_phase(); - assert!(p1 == 1 || p1 == 2); - g.tick(250, &mut best); - let p2 = g.siren_phase(); - assert!(p2 == 1 || p2 == 2); - assert_ne!(p1, p2); - } - - #[test] - fn heist_selected_duration_sets_timer_pins_and_bucket_record() { - let mut best = Records::default(); - let mut g = Game::new(55); - g.start_heist(0); - g.tick(ENTER_BANK_MS, &mut best); - g.tick(ZOOM_MS, &mut best); - assert_eq!(g.time_ms, 10_000); - assert_eq!(g.pin_count, 3); - - g.tick(4_300, &mut best); - for pin in 0..g.pin_count { - let dir = if g.expected_dir == Dir::Cw { 1 } else { -1 }; - for _ in 0..ARM_STEPS_HEIST { - g.crown(dir); - } - while g.dial != g.target { - g.crown(dir); - } - let (fb, broke) = g.try_lock(&mut best); - if pin + 1 == 3 { - assert_eq!(fb, Feedback::SafeOpen); - assert!(broke); - assert_eq!(best.heist_best_ms[0], 4_300); - assert_eq!(best.heist_best_ms[3], 0); - } else { - assert_eq!(fb, Feedback::PinLock); - } - } - g.tick(UNLOCK_MS, &mut best); - g.tick(OPEN_MS, &mut best); - assert_eq!(g.state, State::HeistWin); - } - - #[test] - fn heist_timeout_ends_in_over() { - let mut best = Records::default(); - let mut g = Game::new(10); - g.start_heist(1); // 20s - g.tick(ENTER_BANK_MS, &mut best); - g.tick(ZOOM_MS, &mut best); - let (fb, _) = g.tick(20_000, &mut best); - assert_eq!(fb, Feedback::GameOver); - assert_eq!(g.state, State::Over); - assert_eq!(g.anim_ms, 0); - assert!(g.animating()); - assert_eq!(best.heist_best_ms[1], 0); - - g.tick(OVER_SLAM_MS, &mut best); - assert_eq!(g.anim_ms, OVER_SLAM_MS); - assert!(g.animating()); - g.tick(OVER_ANIM_MS, &mut best); - assert_eq!(g.anim_ms, OVER_ANIM_MS); - assert!(!g.animating()); - } - - #[test] - fn storage_roundtrip_and_migrations() { - let r = Records { classic: 5, blitz: 14, heist_best_ms: [4200, 0, 11200, 18400, 0, 29000] }; - assert_eq!(decode(&encode(r)), r); - let mut vc2 = [0u8; 15]; - vc2[0..3].copy_from_slice(b"VC2"); - vc2[3..7].copy_from_slice(&3u32.to_le_bytes()); - vc2[7..11].copy_from_slice(&9u32.to_le_bytes()); - vc2[11..15].copy_from_slice(&17_500u32.to_le_bytes()); - assert_eq!(decode(&vc2).heist_best_ms[3], 17_500); - assert_eq!(decode(b"bad"), Records::default()); - } -} diff --git a/apps/vault-rush/src/main.rs b/apps/vault-rush/src/main.rs deleted file mode 100644 index c590dbc..0000000 --- a/apps/vault-rush/src/main.rs +++ /dev/null @@ -1,333 +0,0 @@ -#![cfg_attr(any(target_os = "none", wp2_sim), no_main, cfg_attr(target_os = "none", no_std))] - -#[cfg_attr(not(any(target_os = "none", wp2_sim)), allow(dead_code))] -mod font; -#[cfg_attr(not(any(target_os = "none", wp2_sim)), allow(dead_code))] -mod game; -#[cfg_attr(not(any(target_os = "none", wp2_sim)), allow(dead_code))] -mod view; - -#[cfg(not(any(target_os = "none", wp2_sim)))] -fn main() {} - -#[cfg(any(target_os = "none", wp2_sim))] -mod device { - use crate::game::{decode, encode, Feedback, Game, HEIST_TIMES_S, Mode, Records, State}; - use crate::view::{ - frame, heist_tile_rect, in_rect, HEIST_BACK_H, HEIST_BACK_W, HEIST_BACK_X, HEIST_BACK_Y, - MENU_BLITZ_Y, MENU_BTN_H, MENU_BTN_W, MENU_BTN_X, MENU_CLASSIC_Y, MENU_HEIST_Y, OVER_BTN_H, - OVER_BTN_W, OVER_BTN_X, OVER_MENU_Y, OVER_RETRY_Y, - }; - use cmf_wp2_app::{Api, BUTTON, CROWN, PAUSE, RESUME, TOUCH_DOWN}; - use cmf_wp2_ui::haptic::{Motor, Pattern, ALERT, DONE, TICK}; - use cmf_wp2_ui::text::int; - - cmf_wp2_app::entry!(main); - cmf_wp2_app::app_icon!(); - cmf_wp2_app::app_features!(cmf_wp2_app::WIDGET); - - const FRAME_MS: u32 = 33; - const RETRY_MS: u32 = 450; - - // Tactile dial feedback patterns (all end with duty 0, under 1500 ms). - const COLD_TICK: Pattern = Pattern::new(&[(180, 14), (0, 0)]); - const WARM_TICK: Pattern = Pattern::new(&[(350, 22), (0, 0)]); - const HOT_TICK: Pattern = Pattern::new(&[(460, 22), (0, 45), (460, 22), (0, 0)]); - const EXACT_TICK: Pattern = Pattern::new(&[(750, 35), (0, 35), (540, 25), (0, 0)]); - const PIN_LOCK: Pattern = Pattern::new(&[(820, 45), (0, 50), (620, 40), (0, 0)]); - const SAFE_OPEN: Pattern = Pattern::new(&[(700, 65), (0, 45), (920, 120), (0, 0)]); - const WARN_TICK: Pattern = Pattern::new(&[(300, 40), (0, 50), (300, 40), (0, 0)]); - - fn play_feedback(motor: &mut Motor, fb: Feedback) { - match fb { - Feedback::None => {} - Feedback::ColdTick => motor.play(COLD_TICK), - Feedback::WarmTick => motor.play(WARM_TICK), - Feedback::HotTick => motor.play(HOT_TICK), - Feedback::ExactTick => motor.play(EXACT_TICK), - Feedback::PinLock => motor.play(PIN_LOCK), - Feedback::SafeOpen => motor.play(SAFE_OPEN), - Feedback::Miss => motor.play(ALERT), - Feedback::Warn => motor.play(WARN_TICK), - Feedback::GameOver => motor.play(DONE), - } - } - - fn due(now: u32, at: u32) -> bool { - (now.wrapping_sub(at) as i32) >= 0 - } - - fn seed(api: &Api) -> u32 { - let t = api - .time() - .map_or(0, |t| (t.minute as u32 * 60 + t.second as u32) * 1000 + t.millis as u32); - api.now().wrapping_mul(2_654_435_761) ^ t - } - - fn paused(api: &Api) -> bool { - loop { - match api.event(u32::MAX).map(|e| e.kind) { - Some(RESUME) => return true, - Some(BUTTON) => return false, - _ => {} - } - } - } - - fn push_widget(api: &Api, best: Records) { - let mut buf = [0u8; 39]; - let mut idx = 0usize; - let push = |buf: &mut [u8], idx: &mut usize, bytes: &[u8]| { - let n = bytes.len().min(buf.len() - *idx); - buf[*idx..*idx + n].copy_from_slice(&bytes[..n]); - *idx += n; - }; - let mut db = [0u8; 11]; - push(&mut buf, &mut idx, b"C:"); - push(&mut buf, &mut idx, int(best.classic as i32, &mut db).as_bytes()); - push(&mut buf, &mut idx, b" B:"); - push(&mut buf, &mut idx, int(best.blitz as i32, &mut db).as_bytes()); - push(&mut buf, &mut idx, b"\nHeist "); - if let Some((i, &ms)) = best - .heist_best_ms - .iter() - .enumerate() - .filter(|&(_, &v)| v > 0) - .min_by_key(|&(_, &v)| v) - { - let tenths = (ms + 99) / 100; - push(&mut buf, &mut idx, int(HEIST_TIMES_S[i] as i32, &mut db).as_bytes()); - push(&mut buf, &mut idx, b"s:"); - push(&mut buf, &mut idx, int((tenths / 10) as i32, &mut db).as_bytes()); - push(&mut buf, &mut idx, b"."); - push(&mut buf, &mut idx, &[b'0' + (tenths % 10) as u8, b's']); - } else { - push(&mut buf, &mut idx, b"--"); - } - let value = core::str::from_utf8(&buf[..idx]).unwrap_or("C:0 B:0"); - api.widget("Vault Rush", value); - } - - fn needs_screen_awake(state: State) -> bool { - matches!( - state, - State::EnterBank - | State::ZoomIn - | State::Playing - | State::Unlocking - | State::Opening - | State::ClassicGold - ) - } - - #[allow(clippy::too_many_arguments)] - fn handle_touch( - api: &Api, - game: &mut Game, - best: &mut Records, - motor: &mut Motor, - tx: i32, - ty: i32, - now: u32, - last_tick: &mut u32, - end_at: &mut u32, - ) { - let mut start_mode = |game: &mut Game, mode: Mode, last_tick: &mut u32| { - motor.play(TICK); - if mode == Mode::Heist { - game.start_heist(game.heist_idx); - } else { - game.start(mode); - } - api.keep_screen_on(true); - *last_tick = now; - }; - - match game.state { - State::Menu => { - if in_rect(tx, ty, MENU_BTN_X, MENU_CLASSIC_Y, MENU_BTN_W, MENU_BTN_H) { - start_mode(game, Mode::Classic, last_tick); - } else if in_rect(tx, ty, MENU_BTN_X, MENU_HEIST_Y, MENU_BTN_W, MENU_BTN_H) { - motor.play(TICK); - game.open_heist_select(); - } else if in_rect(tx, ty, MENU_BTN_X, MENU_BLITZ_Y, MENU_BTN_W, MENU_BTN_H) { - start_mode(game, Mode::Blitz, last_tick); - } - } - State::HeistSelect => { - if in_rect(tx, ty, HEIST_BACK_X, HEIST_BACK_Y, HEIST_BACK_W, HEIST_BACK_H) { - motor.play(TICK); - game.back_to_menu(); - } else { - for i in 0..HEIST_TIMES_S.len() { - let [rx, ry, rw, rh] = heist_tile_rect(i); - if in_rect(tx, ty, rx, ry, rw, rh) { - motor.play(TICK); - game.start_heist(i); - api.keep_screen_on(true); - *last_tick = now; - break; - } - } - } - } - State::Playing => { - let (fb, broke) = game.try_lock(best); - play_feedback(motor, fb); - if broke { - api.save(&encode(*best)); - push_widget(api, *best); - } - if game.state == State::Over { - *end_at = now; - api.keep_screen_on(false); - } - } - State::ClassicGold => { - motor.play(TICK); - game.skip_gold_hold(); - } - State::Over | State::HeistWin if !due(now, end_at.wrapping_add(RETRY_MS)) => {} - State::Over | State::HeistWin => { - if in_rect(tx, ty, OVER_BTN_X, OVER_RETRY_Y, OVER_BTN_W, OVER_BTN_H) { - start_mode(game, game.mode, last_tick); - } else if in_rect(tx, ty, OVER_BTN_X, OVER_MENU_Y, OVER_BTN_W, OVER_BTN_H) { - motor.play(TICK); - game.back_to_menu(); - } else if game.over_sel == 0 { - start_mode(game, game.mode, last_tick); - } else { - motor.play(TICK); - game.back_to_menu(); - } - } - State::EnterBank | State::ZoomIn | State::Unlocking | State::Opening => {} - } - } - - fn main(api: &'static Api) -> i32 { - let mut screen = api; - let mut motor = Motor::new(api); - let mut blob = [0u8; 40]; - let n = api.load(&mut blob); - let mut best = if n > 0 { decode(&blob[..n as usize]) } else { Records::default() }; - push_widget(api, best); - - let mut game = Game::new(seed(api)); - let (mut seen, _) = frame(&mut screen, &game, best, None); - api.show(); - - let mut last_tick = api.now(); - let mut next_frame = last_tick.wrapping_add(FRAME_MS); - let mut end_at = 0u32; - let mut dirty = false; - - loop { - motor.update(); - - let now = api.now(); - let animating = game.animating(); - let frame_wait = if animating || dirty { - (next_frame.wrapping_sub(now) as i32).max(0) as u32 - } else { - u32::MAX - }; - let wait = motor.wait().map_or(frame_wait, |m| m.min(frame_wait)); - let mut force_draw = false; - - if let Some(first) = api.event(wait) { - let mut crown_fb: Option = None; - let mut cur = Some(first); - while let Some(e) = cur { - let ev_now = api.now(); - match e.kind { - BUTTON => { - api.keep_screen_on(false); - return 0; - } - PAUSE => { - motor.off(); - api.keep_screen_on(false); - if !paused(api) { - return 0; - } - let res_now = api.now(); - last_tick = res_now; - next_frame = res_now.wrapping_add(FRAME_MS); - if needs_screen_awake(game.state) { - api.keep_screen_on(true); - } - let (s, _) = frame(&mut screen, &game, best, None); - seen = s; - api.show(); - dirty = false; - crown_fb = None; - break; - } - CROWN => { - crown_fb = Some(game.crown(e.delta)); - dirty = true; - } - TOUCH_DOWN => { - if let Some(fb) = crown_fb.take() { - play_feedback(&mut motor, fb); - } - handle_touch( - api, - &mut game, - &mut best, - &mut motor, - e.x as i32, - e.y as i32, - ev_now, - &mut last_tick, - &mut end_at, - ); - dirty = true; - force_draw = true; - } - _ => {} - } - cur = api.event(0); - } - if let Some(fb) = crown_fb { - play_feedback(&mut motor, fb); - } - } - - let now = api.now(); - let animating_now = game.animating(); - if animating_now && (force_draw || due(now, next_frame)) { - let dt = now.wrapping_sub(last_tick); - last_tick = now; - if animating && dt > 0 { - let prev_state = game.state; - let (fb, broke) = game.tick(dt, &mut best); - if broke { - api.save(&encode(best)); - push_widget(api, best); - } - if fb != Feedback::None { - play_feedback(&mut motor, fb); - } - if prev_state != game.state && matches!(game.state, State::Over | State::HeistWin) { - end_at = now; - api.keep_screen_on(false); - } - } - dirty = true; - } - - if (dirty || game.animating()) && (force_draw || due(now, next_frame)) { - let (next_seen, drew) = frame(&mut screen, &game, best, Some(seen)); - seen = next_seen; - if drew { - api.show(); - } - dirty = false; - let stepped = next_frame.wrapping_add(FRAME_MS); - next_frame = if due(now, stepped) { now.wrapping_add(FRAME_MS) } else { stepped }; - } - } - } -} diff --git a/apps/vault-rush/src/view.rs b/apps/vault-rush/src/view.rs deleted file mode 100644 index b397987..0000000 --- a/apps/vault-rush/src/view.rs +++ /dev/null @@ -1,1791 +0,0 @@ -//! Steel safe, super-dark dial wheel, bank entrance fly-in, police siren, jail bars scene, and 4-bpp fonts. - -use crate::font::{FONT_LG, FONT_MD, FONT_SM}; -use crate::game::{ - DIAL_STEPS, Dir, Flash, Game, HEIST_TIMES_S, Mode, OVER_ANIM_MS, OVER_SLAM_MS, Records, State, - Zone, heist_pins_for_idx, -}; -use cmf_wp2_ui::draw::{Band, Paint, disc, gradient, line, radial_n, ring, rrect, stroke}; -use cmf_wp2_ui::motion::{cos, ease_out, lerp, sin}; -use cmf_wp2_ui::text::int; -use cmf_wp2_ui::{C, ONE, Rgb, SIZE, Surface}; - -const BG: Rgb = Rgb(4, 5, 8); -const SAFE_BODY: Rgb = Rgb(76, 82, 94); -const SAFE_BODY_EDGE: Rgb = Rgb(118, 126, 142); -const DOOR_TOP: Rgb = Rgb(118, 126, 140); -const DOOR_BOT: Rgb = Rgb(84, 92, 106); -const DOOR_PANEL: Rgb = Rgb(104, 112, 126); -const DOOR_SEAM: Rgb = Rgb(30, 34, 42); -const HINGE: Rgb = Rgb(148, 156, 170); -const BOLT: Rgb = Rgb(192, 200, 214); - -// Whole dial wheel rendered in deep dark charcoal so the entire wheel contrasts sharply with the steel door. -const WHEEL_DARK: Rgb = Rgb(8, 10, 14); -const WHEEL_RIM: Rgb = Rgb(18, 21, 27); -const WHEEL_SPOKE: Rgb = Rgb(18, 21, 27); -const WHEEL_HUB: Rgb = Rgb(24, 28, 36); -const WHEEL_CAP: Rgb = Rgb(34, 39, 48); -const WHEEL_PEG: Rgb = Rgb(36, 41, 50); - -const CAVITY_BG: Rgb = Rgb(18, 15, 12); -const CAVITY_WALL: Rgb = Rgb(38, 32, 26); -const GOLD_DARK: Rgb = Rgb(188, 124, 8); -const GOLD_MID: Rgb = Rgb(245, 186, 28); -const GOLD_BRIGHT: Rgb = Rgb(255, 232, 118); -const GOLD_SHINE: Rgb = Rgb(255, 250, 214); - -// Bank facade colours. -const BANK_WALL: Rgb = Rgb(62, 68, 82); -const BANK_STONE: Rgb = Rgb(92, 100, 118); -const BANK_COL: Rgb = Rgb(118, 126, 146); -const BANK_DOOR: Rgb = Rgb(22, 24, 30); -const BANK_TRIM: Rgb = Rgb(186, 146, 52); - -// Jail / busted scene colours. -const CELL_BG: Rgb = Rgb(14, 16, 24); -const SKIN: Rgb = Rgb(212, 174, 142); -const PRISON_A: Rgb = Rgb(168, 174, 186); -const PRISON_B: Rgb = Rgb(56, 62, 74); -const BAR_METAL: Rgb = Rgb(134, 144, 162); -const BAR_SHINE: Rgb = Rgb(196, 206, 222); - -const SIREN_RED: Rgb = Rgb(255, 36, 42); -const SIREN_BLUE: Rgb = Rgb(32, 124, 255); - -const HUD_BG: Rgb = Rgb(14, 17, 22); -const HUD_RIM: Rgb = Rgb(62, 68, 80); -const TRACK: Rgb = Rgb(38, 43, 52); -const CARD: Rgb = Rgb(26, 30, 38); -const CARD_SEL: Rgb = Rgb(56, 38, 24); -const ACCENT: Rgb = Rgb(255, 92, 0); -const GOLD: Rgb = Rgb(255, 196, 44); -const GREEN: Rgb = Rgb(60, 220, 110); -const RED: Rgb = Rgb(255, 72, 54); -const CYAN: Rgb = Rgb(48, 196, 255); -const WHITE_RGB: Rgb = Rgb(255, 255, 255); -const GREY_RGB: Rgb = Rgb(150, 156, 170); - -pub const WHEEL_CY: i32 = 264; -pub const TICK_R0: i32 = 114; -pub const TICK_R1: i32 = 125; -pub const WHEEL_R1: i32 = 98; -#[cfg(test)] -pub const WHEEL_BOX: [i32; 4] = [C - 133, WHEEL_CY - 133, 266, 266]; -pub const HUD_BOX: [i32; 4] = [C - 94, 64, 188, 58]; -pub const SIREN_R0: i32 = 214; -pub const SIREN_R1: i32 = 233; - -// Main menu buttons. -pub const MENU_BTN_X: i32 = C - 104; -pub const MENU_BTN_W: i32 = 208; -pub const MENU_BTN_H: i32 = 52; -pub const MENU_CLASSIC_Y: i32 = 148; -pub const MENU_HEIST_Y: i32 = 210; -pub const MENU_BLITZ_Y: i32 = 272; - -// Heist duration grid (2 rows x 3 cols: 10S..60S) + Back button. -pub const HEIST_TILE_W: i32 = 88; -pub const HEIST_TILE_H: i32 = 60; -pub const HEIST_COL_PITCH: i32 = 98; -pub const HEIST_ROW_PITCH: i32 = 72; -pub const HEIST_GRID_X0: i32 = C - HEIST_COL_PITCH - HEIST_TILE_W / 2; -pub const HEIST_GRID_Y0: i32 = 142; -pub const HEIST_BACK_X: i32 = C - 72; -pub const HEIST_BACK_Y: i32 = 336; -pub const HEIST_BACK_W: i32 = 144; -pub const HEIST_BACK_H: i32 = 44; - -// End screen buttons. -pub const OVER_BTN_X: i32 = C - 84; -pub const OVER_BTN_W: i32 = 168; -pub const OVER_BTN_H: i32 = 46; -pub const OVER_RETRY_Y: i32 = 282; -pub const OVER_MENU_Y: i32 = 338; - -pub fn heist_tile_rect(i: usize) -> [i32; 4] { - let col = (i % 3) as i32; - let row = (i / 3) as i32; - [ - HEIST_GRID_X0 + col * HEIST_COL_PITCH, - HEIST_GRID_Y0 + row * HEIST_ROW_PITCH, - HEIST_TILE_W, - HEIST_TILE_H, - ] -} - -pub fn in_rect(x: i32, y: i32, rx: i32, ry: i32, rw: i32, rh: i32) -> bool { - x >= rx && x < rx + rw && y >= ry && y < ry + rh -} - -pub fn tick_angle(i: i32) -> u16 { - let i = i.rem_euclid(DIAL_STEPS); - ((49152i32 + (i * 65536 + DIAL_STEPS / 2) / DIAL_STEPS) & 0xFFFF) as u16 -} - -#[derive(Clone, Copy, PartialEq, Eq, Debug)] -pub struct Seen { - state: State, - mode: Mode, - menu_sel: usize, - heist_idx: usize, - over_sel: usize, - dial: i32, - zone: Zone, - armed: bool, - expected_dir: Dir, - pin_idx: usize, - pin_count: usize, - lives: u8, - score: u32, - tenths: i32, - combo: u32, - flash: Flash, - siren: u8, - anim_step: u32, - anim_t: i32, -} - -fn seen(g: &Game) -> Seen { - let (anim_step, anim_t) = match g.state { - State::EnterBank | State::ZoomIn | State::Unlocking | State::Opening => (g.anim_ms / 33, g.anim_t()), - State::Over => { - let step = if g.anim_ms < OVER_SLAM_MS + 40 { - g.anim_ms / 33 - } else if g.anim_ms < OVER_ANIM_MS { - 100 + ((g.anim_ms / 180) & 1) - } else { - 200 - }; - (step, 0) - } - State::ClassicGold | State::HeistWin => (g.anim_ms / 240, 0), - _ => (0, 0), - }; - Seen { - state: g.state, - mode: g.mode, - menu_sel: g.menu_sel, - heist_idx: g.heist_idx, - over_sel: g.over_sel, - dial: g.dial, - zone: g.zone(), - armed: g.armed(), - expected_dir: g.expected_dir, - pin_idx: g.pin_idx, - pin_count: g.pin_count, - lives: g.lives, - score: g.score, - tenths: (g.time_ms.max(0) + 99) / 100, - combo: g.combo, - flash: g.flash, - siren: g.siren_phase(), - anim_step, - anim_t, - } -} - -fn zone_led_color(z: Zone, flash: Flash) -> Rgb { - match flash { - Flash::Miss | Flash::WrongDir => RED, - Flash::PinLock | Flash::ExactBonus | Flash::GoodBonus => GREEN, - Flash::None => match z { - Zone::Exact => GREEN, - Zone::Hot => ACCENT, - Zone::Warm => GOLD, - Zone::Cold => Rgb(62, 68, 80), - }, - } -} - -fn format_two_digits(v: i32, out: &mut [u8; 2]) -> &str { - let v = v.rem_euclid(100); - out[0] = b'0' + (v / 10) as u8; - out[1] = b'0' + (v % 10) as u8; - core::str::from_utf8(out).unwrap_or("00") -} - -fn format_tenths<'a>(ms: i32, buf: &'a mut [u8; 16]) -> &'a str { - let tenths = (ms.max(0) + 99) / 100; - let secs = tenths / 10; - let dec = tenths % 10; - let mut db = [0u8; 11]; - let sb = int(secs, &mut db).as_bytes(); - let sn = sb.len().min(6); - buf[..sn].copy_from_slice(&sb[..sn]); - buf[sn] = b'.'; - buf[sn + 1] = b'0' + dec as u8; - buf[sn + 2] = b'S'; - core::str::from_utf8(&buf[..sn + 3]).unwrap_or("0.0S") -} - -fn format_best<'a>(prefix: &[u8], n: u32, buf: &'a mut [u8; 20]) -> &'a str { - let pn = prefix.len().min(12); - buf[..pn].copy_from_slice(&prefix[..pn]); - let mut db = [0u8; 11]; - let d = int(n as i32, &mut db).as_bytes(); - let dn = d.len().min(buf.len() - pn); - buf[pn..pn + dn].copy_from_slice(&d[..dn]); - core::str::from_utf8(&buf[..pn + dn]).unwrap_or("") -} - -fn format_heist_best<'a>(ms: u32, buf: &'a mut [u8; 20]) -> &'a str { - if ms == 0 { - return "BEST --"; - } - buf[..5].copy_from_slice(b"BEST "); - let mut tb = [0u8; 16]; - let t = format_tenths(ms as i32, &mut tb).as_bytes(); - let n = t.len().min(buf.len() - 5); - buf[5..5 + n].copy_from_slice(&t[..n]); - core::str::from_utf8(&buf[..5 + n]).unwrap_or("BEST") -} - -fn fastest_heist_ms(best: Records) -> u32 { - best.heist_best_ms.iter().copied().filter(|&v| v > 0).min().unwrap_or(0) -} - -fn tint(c: Rgb, k: i32) -> Rgb { - c.scale(k) -} - -fn siren_wash(c: Rgb, siren: u8, amount_q: i32) -> Rgb { - match siren { - 1 => c.mix(SIREN_RED, amount_q), - 2 => c.mix(SIREN_BLUE, amount_q), - _ => c, - } -} - -/// Semi-transparent red/blue police light wash over screen surfaces. -fn wash(c: Rgb, siren: u8) -> Rgb { - siren_wash(c, siren, 260) -} - -/// Lighter translucent tint so bright LEDs and HUD digits stay crisp inside the wash. -fn wash_fg(c: Rgb, siren: u8) -> Rgb { - siren_wash(c, siren, 150) -} - -/// Restricts drawing to `[x0..x1, y0..y1)`. -struct Clip<'a, S: Surface> { - s: &'a mut S, - x0: i32, - y0: i32, - x1: i32, - y1: i32, -} - -impl Surface for Clip<'_, S> { - fn rect(&mut self, x: i32, y: i32, w: i32, h: i32, c: u16) { - let ax = x.max(self.x0); - let ay = y.max(self.y0); - let bx = (x + w).min(self.x1); - let by = (y + h).min(self.y1); - if bx > ax && by > ay { - self.s.rect(ax, ay, bx - ax, by - ay, c); - } - } - - fn text(&mut self, x: i32, y: i32, t: &str, c: u16) { - self.s.text(x, y, t, c); - } -} - -/// Skips drawing over `[skip[0]..skip[2], skip[1]..skip[3])` so static foreground elements never flicker. -struct Exclude<'a, S: Surface> { - s: &'a mut S, - skip: [i32; 4], -} - -impl Surface for Exclude<'_, S> { - fn rect(&mut self, x: i32, y: i32, w: i32, h: i32, c: u16) { - if w <= 0 || h <= 0 { - return; - } - let (x0, y0, x1, y1) = (x, y, x + w, y + h); - let [sx0, sy0, sx1, sy1] = self.skip; - if x1 <= sx0 || x0 >= sx1 || y1 <= sy0 || y0 >= sy1 { - self.s.rect(x, y, w, h, c); - return; - } - if y0 < sy0 { - self.s.rect(x0, y0, w, sy0 - y0, c); - } - if y1 > sy1 { - self.s.rect(x0, sy1, w, y1 - sy1, c); - } - let my0 = y0.max(sy0); - let my1 = y1.min(sy1); - if my1 > my0 { - if x0 < sx0 { - self.s.rect(x0, my0, sx0 - x0, my1 - my0, c); - } - if x1 > sx1 { - self.s.rect(sx1, my0, x1 - sx1, my1 - my0, c); - } - } - } - - fn text(&mut self, x: i32, y: i32, t: &str, c: u16) { - self.s.text(x, y, t, c); - } -} - -/// Draws the classical bank building centered at `(C, cy)` scaled by `scale_q` and lit by `bright_k`. -fn draw_bank_scene(s: &mut impl Surface, cy: i32, scale_q: i32, bright_k: i32, show_sign: bool, clear_bg: bool) { - let bg565 = BG.rgb565(); - if bright_k <= 20 { - s.rect(0, 0, SIZE, SIZE, bg565); - return; - } - if clear_bg { - s.rect(0, 0, SIZE, SIZE, bg565); - } - - let mut clip = Clip { s, x0: 0, y0: 0, x1: SIZE, y1: SIZE }; - let wall = tint(BANK_WALL, bright_k); - let wall565 = wall.rgb565(); - let stone = tint(BANK_STONE, bright_k); - let stone565 = stone.rgb565(); - let col_c = tint(BANK_COL, bright_k); - let col565 = col_c.rgb565(); - let door_c = tint(BANK_DOOR, bright_k); - let trim_c = tint(BANK_TRIM, bright_k); - - let sc = |v: i32| (v * scale_q) / ONE; - - let body_w = sc(248); - let body_h = sc(126); - let body_x = C - body_w / 2; - let body_y = cy - sc(38); - let body_bot = body_y + body_h; - let corn_y = body_y - sc(12); - let corn_h = sc(14).max(2); - - // Triangular pediment roof (`clear_bg = false` skips already-black sky because the zoom strictly expands). - let roof_w = sc(272); - let roof_h = sc(46); - let roof_top = body_y - roof_h - sc(10); - let in_h = sc(28); - let in_top = roof_top + sc(12); - let r0 = (-roof_top).max(0); - let r1 = roof_h.min(corn_y - roof_top).min(SIZE - roof_top); - for row in r0..r1 { - let half = ((row + 1) * (roof_w / 2)) / roof_h.max(1); - let y = roof_top + row; - let x0 = (C - half).max(0); - let x1 = (C + half).min(SIZE); - if x1 > x0 { - if y >= in_top && y < in_top + in_h { - let ihalf = ((y - in_top + 1) * sc(88)) / in_h.max(1); - let ix0 = (C - ihalf).max(x0); - let ix1 = (C + ihalf).min(x1); - clip.rect(x0, y, (ix0 - x0).max(0), 1, stone565); - clip.rect(ix0, y, (ix1 - ix0).max(0), 1, wall565); - clip.rect(ix1, y, (x1 - ix1).max(0), 1, stone565); - } else { - clip.rect(x0, y, x1 - x0, 1, stone565); - } - } - } - - // Architrave cornice bar. - let kx0 = C - sc(136); - let kw = sc(272); - clip.rect(kx0, corn_y, kw, corn_h, col565); - - let dw = sc(68); - let dh = sc(84); - let dx = C - dw / 2; - let dy = body_bot - dh; - let trim_pad = sc(4); - let tx0 = dx - trim_pad; - let tx1 = dx + dw + trim_pad; - let ty0 = dy - trim_pad; - - let cw = sc(22).max(4); - let cap_pad = sc(3); - let cap_h = sc(8).max(2); - let mid_y = body_y + cap_h; - let mid_h = (body_bot - cap_h - mid_y).max(0); - let offs = [-102, -58, 58, 102]; - let cols = offs.map(|off| { - let cx0 = C + sc(off) - cw / 2; - (cx0, cx0 + cw, cx0 - cap_pad, cx0 + cw + cap_pad) - }); - - // Paint facade wall ONLY in the non-column bays so columns never flash wall colour underneath. - for (gx0, gx1) in [ - (body_x, cols[0].2), - (cols[0].3, cols[1].2), - (cols[1].3, tx0), - (tx1, cols[2].2), - (cols[2].3, cols[3].2), - (cols[3].3, body_x + body_w), - ] { - if gx1 > gx0 { - clip.rect(gx0, body_y, gx1 - gx0, body_h, wall565); - } - } - for &(cx0, cx1, cap_x0, cap_x1) in &cols { - clip.rect(cx0, mid_y, cx1 - cx0, mid_h, col565); - clip.rect(cap_x0, body_y, cap_x1 - cap_x0, cap_h, stone565); - clip.rect(cap_x0, body_bot - cap_h, cap_x1 - cap_x0, cap_h, stone565); - if mid_h > 0 { - clip.rect(cap_x0, mid_y, cx0 - cap_x0, mid_h, wall565); - clip.rect(cx1, mid_y, cap_x1 - cx1, mid_h, wall565); - } - } - - let sign_w = sc(68); - let sign_h = sc(16); - let sign_active = show_sign && scale_q < ONE * 2 && sign_h >= 12; - let sign_box = if sign_active { - [C - sign_w / 2, body_y + sc(6), C + sign_w / 2, body_y + sc(6) + sign_h] - } else { - [0, 0, 0, 0] - }; - let trim_r = sc(6).max(2); - if ty0 + trim_r > body_y && tx1 > tx0 { - let mut ex_sign = Exclude { s: &mut clip, skip: sign_box }; - ex_sign.rect(tx0, body_y, tx1 - tx0, ty0 - body_y, wall565); - // Backfill outer rounded corners of the door trim box. - ex_sign.rect(tx0, ty0, trim_r, trim_r, wall565); - ex_sign.rect(tx1 - trim_r, ty0, trim_r, trim_r, wall565); - ex_sign.rect(tx0, body_bot - trim_r, trim_r, trim_r, wall565); - ex_sign.rect(tx1 - trim_r, body_bot - trim_r, trim_r, trim_r, wall565); - } - if sign_active { - clip.rect(C - sign_w / 2, body_y + sc(6), sign_w, sign_h, door_c.rgb565()); - FONT_SM.centre(&mut clip, C, body_y + sc(6), "BANK", trim_c, door_c); - } - - // Door trim frame + central double doors (zero wall/column overlap). - { - let mut ex_door = Exclude { s: &mut clip, skip: [dx, dy, dx + dw, dy + dh] }; - rrect(&mut ex_door, tx0, ty0, dw + 2 * trim_pad, dh + trim_pad, trim_r, trim_c, wall); - } - clip.rect(dx, dy, dw, dh, door_c.rgb565()); - clip.rect(C - sc(1).max(1), dy + sc(4), sc(2).max(1), dh - sc(6), trim_c.rgb565()); - disc(&mut clip, C - sc(10), dy + dh / 2, sc(3).max(1), trim_c, door_c); - disc(&mut clip, C + sc(10), dy + dh / 2, sc(3).max(1), trim_c, door_c); - - // Base steps + side sky strip around step 1 (catches shrinking corner overlap when step 2 shifts down). - let step1_y = body_bot; - let step2_y = step1_y + sc(10); - let sx1 = C - sc(136); - let sw1 = sc(272); - let sx2 = C - sc(148); - let sw2 = sc(296); - // Side sky around facade (below projecting cornice eaves) + step 1 sides. - if !clear_bg { - let facade_sky_y = (corn_y + corn_h).max(body_y); - let facade_sky_h = (body_bot - facade_sky_y).max(0); - if facade_sky_h > 0 { - if body_x > 0 { - clip.rect(0, facade_sky_y, body_x, facade_sky_h, bg565); - } - if body_x + body_w < SIZE { - clip.rect(body_x + body_w, facade_sky_y, SIZE - (body_x + body_w), facade_sky_h, bg565); - } - } - if sx1 > 0 { - clip.rect(0, step1_y, sx1, step2_y - step1_y, bg565); - } - if sx1 + sw1 < SIZE { - clip.rect(sx1 + sw1, step1_y, SIZE - (sx1 + sw1), step2_y - step1_y, bg565); - } - } - clip.rect(sx1, step1_y, sw1, sc(10).max(2), stone565); - clip.rect(sx2, step2_y, sw2, sc(10).max(2), col565); -} - -fn polar_at(cx: i32, cy: i32, r: i32, a: u16) -> (i32, i32) { - (cx + ((r * cos(a) + (1 << 13)) >> 14), cy + ((r * sin(a) + (1 << 13)) >> 14)) -} - -fn draw_safe_bolts(s: &mut impl Surface, bolt_retract_t: i32, bright_k: i32, siren: u8, restore_bg: bool) { - let body_c = wash(tint(SAFE_BODY, bright_k), siren); - let door_c = wash(tint(DOOR_PANEL, bright_k), siren); - let seam_c = wash(tint(DOOR_SEAM, bright_k), siren); - let bolt_c = wash(tint(BOLT, bright_k), siren); - let bolt_x = SIZE - 34 + (20 * bolt_retract_t) / ONE; - - if restore_bg { - for by in [152, 286] { - s.rect(SIZE - 35, by - 1, 4, 30, door_c.rgb565()); - s.rect(SIZE - 31, by - 1, 5, 30, seam_c.rgb565()); - s.rect(SIZE - 26, by - 1, 26, 30, body_c.rgb565()); - } - } - rrect(s, bolt_x, 152, 22, 28, 4, bolt_c, seam_c); - rrect(s, bolt_x, 286, 22, 28, 4, bolt_c, seam_c); -} - -fn safe_corner_r(scale_q: i32) -> i32 { - (6 * scale_q / ONE).max(3) -} - -fn safe_door_core(scale_q: i32) -> [i32; 4] { - let half = (96 * scale_q) / ONE; - if half >= C { - [31, 60, SIZE - 31, SIZE - 52] - } else { - let x0 = C - half; - let y0 = C - half; - let w = half * 2; - let r = safe_corner_r(scale_q); - let dpad = (20 * scale_q) / ONE; - let ix = x0 + dpad + 3; - let iy = y0 + dpad + 3; - let iw = w - 2 * dpad - 6; - let dr = (r - 6).max(2); - let hw = (12 * scale_q / ONE).max(4); - // Leave room on the left for the hinge inner edge so hinges never overlap the skipped core. - [ix + hw / 2 + 2, iy + dr, ix + iw, iy + iw - dr] - } -} - -fn draw_safe_backdrop( - s: &mut impl Surface, - scale_q: i32, - bolt_retract_t: i32, - bright_k: i32, - siren: u8, - clear_bg: bool, -) { - let half = (96 * scale_q) / ONE; - let x0 = C - half; - let y0 = C - half; - let w = half * 2; - let r = safe_corner_r(scale_q); - - let body_c = wash(tint(SAFE_BODY, bright_k), siren); - let edge_c = wash(tint(SAFE_BODY_EDGE, bright_k), siren); - let door_c = wash(tint(DOOR_PANEL, bright_k), siren); - let seam_c = wash(tint(DOOR_SEAM, bright_k), siren); - let hinge_c = wash(tint(HINGE, bright_k), siren); - - if half < C { - let leg_w = (24 * scale_q) / ONE; - let leg_h = (16 * scale_q) / ONE; - let leg_off = (62 * scale_q) / ONE; - let bg565 = BG.rgb565(); - if clear_bg { - s.rect(0, 0, SIZE, SIZE, bg565); - } else if y0 + w < SIZE { - let clear_h = (leg_h + 6).min(SIZE - (y0 + w)); - s.rect(C - leg_off - 4, y0 + w, leg_off * 2 + 8, clear_h, bg565); - } - rrect(s, C - leg_off, y0 + w - 4, leg_w, leg_h, 4, seam_c, BG); - rrect(s, C + leg_off - leg_w, y0 + w - 4, leg_w, leg_h, 4, seam_c, BG); - - let pad = (10 * scale_q) / ONE; - let bx = x0 + pad; - let by = y0 + pad; - let bw = w - 2 * pad; - let br = (r - 2).max(2); - let dpad = (20 * scale_q) / ONE; - let dx = x0 + dpad; - let dy = y0 + dpad; - let dw = w - 2 * dpad; - let sr = (r - 4).max(2); - let ix = dx + 3; - let iy = dy + 3; - let iw = dw - 6; - let dr = (r - 6).max(2); - - // Skip each layer's solid interior covered by the layer inside it so no frame paints the centre four times. - { - let mut ex_v = Exclude { s, skip: [bx + br, by, bx + bw - br, by + bw] }; - let mut ex_edge = Exclude { s: &mut ex_v, skip: [bx, by + br, bx + bw, by + bw - br] }; - rrect(&mut ex_edge, x0, y0, w, w, r, edge_c, BG); - } - { - let mut ex_v = Exclude { s, skip: [dx + sr, dy, dx + dw - sr, dy + dw] }; - let mut ex_body = Exclude { s: &mut ex_v, skip: [dx, dy + sr, dx + dw, dy + dw - sr] }; - rrect(&mut ex_body, bx, by, bw, bw, br, body_c, edge_c); - } - { - let mut ex_v = Exclude { s, skip: [ix + dr, iy, ix + iw - dr, iy + iw] }; - let mut ex_seam = Exclude { s: &mut ex_v, skip: [ix, iy + dr, ix + iw, iy + iw - dr] }; - rrect(&mut ex_seam, dx, dy, dw, dw, sr, seam_c, body_c); - } - rrect(s, ix, iy, iw, iw, dr, door_c, seam_c); - - let hw = (12 * scale_q / ONE).max(4); - let hh = (26 * scale_q / ONE).max(8); - rrect(s, dx - hw / 2, C - half / 2 - hh / 2, hw, hh, 3, hinge_c, body_c); - rrect(s, dx - hw / 2, C + half / 2 - hh / 2, hw, hh, 3, hinge_c, body_c); - return; - } - - s.rect(31, 60, SIZE - 62, SIZE - 112, door_c.rgb565()); - gradient(s, 31, 0, SIZE - 62, 60, wash(tint(DOOR_TOP, bright_k), siren), door_c, true); - gradient(s, 31, SIZE - 52, SIZE - 62, 52, door_c, wash(tint(DOOR_BOT, bright_k), siren), true); - s.rect(0, 0, 26, SIZE, body_c.rgb565()); - s.rect(26, 0, 5, SIZE, seam_c.rgb565()); - s.rect(SIZE - 26, 0, 26, SIZE, body_c.rgb565()); - s.rect(SIZE - 31, 0, 5, SIZE, seam_c.rgb565()); - rrect(s, 14, 132, 22, 46, 5, hinge_c, body_c); - rrect(s, 14, 288, 22, 46, 5, hinge_c, body_c); - draw_safe_bolts(s, bolt_retract_t, bright_k, siren, false); -} - -fn draw_single_tick(s: &mut impl Surface, cx: i32, cy: i32, i: i32, active: bool, active_c: Rgb, bg: Rgb, siren: u8) { - let a = tick_angle(i); - let (r0, r1, w, col) = if active { - (TICK_R0 - 3, TICK_R1 + 2, 4, active_c) - } else if i % 3 == 0 { - (TICK_R0 + 2, TICK_R1, 3, wash(Rgb(218, 224, 234), siren)) - } else { - (TICK_R0 + 6, TICK_R1 - 1, 2, wash(Rgb(62, 68, 80), siren)) - }; - stroke(s, cx, cy, cos(a), sin(a), r0, r1, w, 0, |_| col, bg); -} - -fn wheel_metrics(r_outer: i32) -> (i32, i32, i32, i32, i32, i32) { - let r_inner = (r_outer * 74) / 100; - let r_hub = (r_outer * 30) / 100; - let r_knob = ((r_outer - r_inner) / 2 - 4).max(3); - let spoke_w = (r_outer / 11).max(3); - let spoke_r0 = r_hub + 3; - let spoke_r1 = r_inner - 5; - (r_inner, r_hub, r_knob, spoke_w, spoke_r0, spoke_r1) -} - -fn draw_wheel_spokes( - s: &mut impl Surface, - cx: i32, - cy: i32, - r0: i32, - r1: i32, - w: i32, - dial: i32, - col: Rgb, - bg: Rgb, -) { - if r1 <= r0 + 1 { - return; - } - let base_a = tick_angle(dial); - for k in 0..3 { - let a = base_a.wrapping_add((k * 21845) as u16); - stroke(s, cx, cy, cos(a), sin(a), r0, r1, w, 0, |_| col, bg); - } -} - -fn solid_disc(s: &mut impl Surface, cx: i32, cy: i32, r: i32, c: Rgb) { - radial_n::<1>(s, cx, cy, &[Band { r, paint: Paint::Solid(c), soft: 0 }], None, |_, _| c); -} - -fn solid_ring(s: &mut impl Surface, cx: i32, cy: i32, r0: i32, r1: i32, c: Rgb) { - let bands = [Band { r: r0, paint: Paint::Skip, soft: 0 }, Band { r: r1, paint: Paint::Solid(c), soft: 0 }]; - radial_n::<2>(s, cx, cy, &bands, None, |_, _| c); -} - -fn draw_wheel_grips( - s: &mut impl Surface, - cx: i32, - cy: i32, - r_mid: i32, - r_knob: i32, - dial: i32, - peg_c: Rgb, - acc_c: Rgb, - rim_c: Rgb, - erase: bool, - crisp: bool, -) { - let base_a = tick_angle(dial); - for k in 0..3 { - let a = base_a.wrapping_add((k * 21845) as u16); - let (px, py) = polar_at(cx, cy, r_mid, a); - if erase { - disc(s, px, py, r_knob + 1, rim_c, rim_c); - } else if crisp { - disc(s, px, py, r_knob, peg_c, rim_c); - if k == 0 { - disc(s, px, py, (r_knob - 3).max(2), acc_c, peg_c); - } - } else { - solid_disc(s, px, py, r_knob, peg_c); - if k == 0 { - solid_disc(s, px, py, (r_knob - 3).max(2), acc_c); - } - } - } -} - -/// Draws the entire 3-spoke dial wheel in deep dark charcoal (including rim, spokes, hub, and side grips). -#[allow(clippy::too_many_arguments)] -fn draw_wheel( - s: &mut impl Surface, - cx: i32, - cy: i32, - r_outer: i32, - dial: i32, - led: Rgb, - with_ticks: bool, - bg: Rgb, - bright_k: i32, - siren: u8, - crisp: bool, -) { - if with_ticks { - let active_c = wash_fg(led, siren); - for i in 0..DIAL_STEPS { - draw_single_tick(s, cx, cy, i, i == dial, active_c, bg, siren); - } - } - - let w_dark = wash(tint(WHEEL_DARK, bright_k), siren); - let w_rim = wash(tint(WHEEL_RIM, bright_k), siren); - let w_spoke = wash(tint(WHEEL_SPOKE, bright_k), siren); - let w_hub = wash(tint(WHEEL_HUB, bright_k), siren); - let w_cap = wash(tint(WHEEL_CAP, bright_k), siren); - let w_peg = wash(tint(WHEEL_PEG, bright_k), siren); - let w_acc = wash_fg(tint(ACCENT, bright_k), siren); - - let aa = i32::from(crisp); - let (r_inner, r_hub, r_knob, spoke_w, spoke_r0, spoke_r1) = wheel_metrics(r_outer); - draw_wheel_spokes(s, cx, cy, spoke_r0, spoke_r1, spoke_w, dial, w_spoke, bg); - - let rim_bands = [ - Band { r: (r_inner - 2).max(1), paint: Paint::Skip, soft: aa }, - Band { r: r_inner, paint: Paint::Solid(w_dark), soft: 0 }, - Band { r: (r_outer - 2).max(r_inner + 1), paint: Paint::Solid(w_rim), soft: 0 }, - Band { r: r_outer + 1, paint: Paint::Solid(w_dark), soft: aa }, - ]; - radial_n::<4>(s, cx, cy, &rim_bands, None, |_, _| bg); - - draw_wheel_grips(s, cx, cy, (r_inner + r_outer - 2) / 2, r_knob, dial, w_peg, w_acc, w_rim, false, crisp); - - let bands = [ - Band { r: (r_hub * 45 / 100).max(2), paint: Paint::Solid(w_cap), soft: 0 }, - Band { r: (r_hub * 78 / 100).max(3), paint: Paint::Solid(w_hub), soft: 0 }, - Band { r: r_hub.max(4), paint: Paint::Solid(w_dark), soft: aa }, - ]; - radial_n::<3>(s, cx, cy, &bands, None, |_, _| bg); -} - -/// Incrementally updates only the changed ticks, spokes, and rim grips without clearing `WHEEL_BOX`. -fn draw_wheel_diff( - s: &mut impl Surface, - prev_dial: i32, - now_dial: i32, - led: Rgb, - bg: Rgb, - siren: u8, -) { - let active_c = wash_fg(led, siren); - if prev_dial != now_dial { - let prev_a = tick_angle(prev_dial); - stroke(s, C, WHEEL_CY, cos(prev_a), sin(prev_a), TICK_R0 - 3, TICK_R1 + 2, 6, 0, |_| bg, bg); - draw_single_tick(s, C, WHEEL_CY, prev_dial, false, active_c, bg, siren); - - let now_a = tick_angle(now_dial); - stroke(s, C, WHEEL_CY, cos(now_a), sin(now_a), TICK_R0, TICK_R1 + 1, 5, 0, |_| bg, bg); - draw_single_tick(s, C, WHEEL_CY, now_dial, true, active_c, bg, siren); - - let w_rim = wash(WHEEL_RIM, siren); - let w_spoke = wash(WHEEL_SPOKE, siren); - let w_peg = wash(WHEEL_PEG, siren); - let w_acc = wash_fg(ACCENT, siren); - let (r_inner, _, r_knob, spoke_w, spoke_r0, spoke_r1) = wheel_metrics(WHEEL_R1); - - draw_wheel_spokes(s, C, WHEEL_CY, spoke_r0, spoke_r1, spoke_w + 2, prev_dial, bg, bg); - draw_wheel_spokes(s, C, WHEEL_CY, spoke_r0, spoke_r1, spoke_w, now_dial, w_spoke, bg); - - let r_mid = (r_inner + WHEEL_R1 - 2) / 2; - draw_wheel_grips(s, C, WHEEL_CY, r_mid, r_knob, prev_dial, w_peg, w_acc, w_rim, true, true); - draw_wheel_grips(s, C, WHEEL_CY, r_mid, r_knob, now_dial, w_peg, w_acc, w_rim, false, true); - } else { - draw_single_tick(s, C, WHEEL_CY, now_dial, true, active_c, bg, siren); - } -} - -/// Draws a stepped semi-transparent red/blue perimeter glow around the screen during the final 5 seconds. -fn draw_siren_ring(s: &mut impl Surface, siren: u8) { - if siren == 0 { - return; - } - let base = wash(DOOR_PANEL, siren); - let mid = siren_wash(DOOR_PANEL, siren, 440); - let outer = siren_wash(DOOR_PANEL, siren, 670); - ring(s, C, C, SIREN_R0, 222, mid, base); - ring(s, C, C, 222, SIREN_R1, outer, mid); -} - -fn draw_hud_frame(s: &mut impl Surface, siren: u8) { - let [hx, hy, hw, hh] = HUD_BOX; - let outer = wash(DOOR_PANEL, siren); - let rim = wash(HUD_RIM, siren); - let bg = wash(HUD_BG, siren); - rrect(s, hx, hy, hw, hh, 12, rim, outer); - rrect(s, hx + 2, hy + 2, hw - 4, hh - 4, 10, bg, rim); -} - -fn draw_hud_timer(s: &mut impl Surface, g: &Game, siren: u8, clear: bool) { - let [hx, hy, hw, _] = HUD_BOX; - let bg = wash(HUD_BG, siren); - if clear { - s.rect(hx + hw - 76, hy + 7, 66, 17, bg.rgb565()); - } - let mut tb = [0u8; 16]; - let tstr = format_tenths(g.time_ms, &mut tb); - let tcol = wash_fg(if g.time_ms <= 5_000 { RED } else { CYAN }, siren); - FONT_SM.draw(s, hx + hw - 12 - FONT_SM.width(tstr), hy + 8, tstr, tcol, bg); -} - -fn draw_hud_top(s: &mut impl Surface, g: &Game, siren: u8, clear: bool) { - let [hx, hy, hw, _] = HUD_BOX; - let bg = wash(HUD_BG, siren); - let track = wash(TRACK, siren); - let green = wash_fg(GREEN, siren); - let accent = wash_fg(ACCENT, siren); - let red = wash_fg(RED, siren); - let gold = wash_fg(GOLD, siren); - let white = wash_fg(WHITE_RGB, siren); - - if clear { - s.rect(hx + 10, hy + 6, hw - 20, 20, bg.rgb565()); - } - match g.mode { - Mode::Classic => { - let px0 = hx + 16; - for i in 0..g.pin_count { - let col = if i < g.pin_idx { green } else if i == g.pin_idx { accent } else { track }; - disc(s, px0 + i as i32 * 18, hy + 15, 5, col, bg); - } - for i in 0..crate::game::CLASSIC_LIVES { - let col = if i < g.lives { red } else { track }; - disc(s, hx + hw - 48 + i as i32 * 14, hy + 15, 4, col, bg); - } - } - Mode::Heist => { - let px0 = hx + 14; - for i in 0..g.pin_count { - let col = if i < g.pin_idx { green } else if i == g.pin_idx { accent } else { track }; - disc(s, px0 + i as i32 * 16, hy + 15, 5, col, bg); - } - draw_hud_timer(s, g, siren, false); - } - Mode::Blitz => { - let mut sb = [0u8; 16]; - let mut db = [0u8; 11]; - let d = int(g.score as i32, &mut db).as_bytes(); - sb[0] = b'#'; - let n = d.len().min(6); - sb[1..1 + n].copy_from_slice(&d[..n]); - let sstr = core::str::from_utf8(&sb[..1 + n]).unwrap_or("#0"); - FONT_SM.draw(s, hx + 14, hy + 8, sstr, if g.combo >= 2 { gold } else { white }, bg); - draw_hud_timer(s, g, siren, false); - } - } -} - -fn draw_hud_dir(s: &mut impl Surface, g: &Game, siren: u8, clear: bool) { - let [hx, hy, _, _] = HUD_BOX; - let bg = wash(HUD_BG, siren); - if clear { - s.rect(hx + 14, hy + 26, 38, 24, bg.rgb565()); - } - let accent = wash_fg(ACCENT, siren); - let dir_off = wash(Rgb(100, 108, 122), siren); - let dir_str = if g.expected_dir == Dir::Cw { ">>" } else { "<<" }; - let dir_col = if !g.armed() { accent } else { dir_off }; - FONT_MD.draw(s, hx + 16, hy + 27, dir_str, dir_col, bg); -} - -fn draw_hud_dial(s: &mut impl Surface, g: &Game, siren: u8, clear: bool) { - let [_, hy, _, _] = HUD_BOX; - let bg = wash(HUD_BG, siren); - if clear { - s.rect(C - 26, hy + 26, 52, 24, bg.rgb565()); - } - let green = wash_fg(GREEN, siren); - let red = wash_fg(RED, siren); - let white = wash_fg(WHITE_RGB, siren); - let mut db = [0u8; 2]; - let num = format_two_digits(g.dial, &mut db); - let num_col = match g.flash { - Flash::Miss => red, - Flash::ExactBonus | Flash::GoodBonus => green, - _ if g.zone() == Zone::Exact => green, - _ => white, - }; - FONT_MD.centre(s, C, hy + 27, num, num_col, bg); -} - -fn draw_hud_led(s: &mut impl Surface, g: &Game, siren: u8) { - let [hx, hy, hw, _] = HUD_BOX; - let bg = wash(HUD_BG, siren); - let led = wash_fg(zone_led_color(g.zone(), g.flash), siren); - disc(s, hx + hw - 22, hy + 38, 7, led, bg); -} - -fn draw_hud(s: &mut impl Surface, g: &Game, siren: u8) { - draw_hud_frame(s, siren); - draw_hud_top(s, g, siren, false); - if g.mode != Mode::Blitz { - draw_hud_dir(s, g, siren, false); - } - draw_hud_dial(s, g, siren, false); - draw_hud_led(s, g, siren); -} - -fn draw_gold_interior(s: &mut impl Surface, cx: i32, cy: i32, w: i32, h: i32, sparkle_phase: u32) { - rrect(s, cx - w / 2, cy - h / 2, w, h, 18, SAFE_BODY_EDGE, BG); - rrect(s, cx - w / 2 + 8, cy - h / 2 + 8, w - 16, h - 16, 12, CAVITY_BG, SAFE_BODY_EDGE); - s.rect(cx - w / 2 + 12, cy + 44, w - 24, 10, CAVITY_WALL.rgb565()); - - let bar_w = 54; - let bar_h = 22; - let base_y = cy + 20; - let draw_ingot = |s: &mut _, x: i32, y: i32| { - rrect(s, x, y, bar_w, bar_h, 5, GOLD_DARK, CAVITY_BG); - rrect(s, x + 2, y + 2, bar_w - 4, bar_h - 6, 4, GOLD_MID, GOLD_DARK); - rrect(s, x + 6, y + 4, bar_w - 14, 5, 2, GOLD_BRIGHT, GOLD_MID); - }; - draw_ingot(s, cx - 86, base_y); - draw_ingot(s, cx - 27, base_y); - draw_ingot(s, cx + 32, base_y); - draw_ingot(s, cx - 56, base_y - 24); - draw_ingot(s, cx + 3, base_y - 24); - draw_ingot(s, cx - 27, base_y - 48); - - for (ox, oy) in [(-72, 38), (-54, 40), (48, 39), (66, 37), (-16, 40)] { - disc(s, cx + ox, cy + oy, 6, GOLD_BRIGHT, CAVITY_BG); - } - - let phase = sparkle_phase & 3; - let glints = [(-38, -22), (24, -18), (-64, 16), (54, 18)]; - for (idx, &(gx, gy)) in glints.iter().enumerate() { - let sx = cx + gx; - let sy = cy + gy; - let r = if idx as u32 == phase { 5 } else { 2 }; - disc(s, sx, sy, r, GOLD_SHINE, GOLD_BRIGHT); - } -} - -fn opening_door_geom(open_t: i32) -> (i32, i32, i32) { - (lerp(SIZE - 56, 22, open_t), lerp(0, 88, open_t), lerp(SIZE, 240, open_t)) -} - -fn draw_opening_door(s: &mut impl Surface, door_w: i32, dy: i32, dh: i32) { - if door_w > 18 { - let dx = 28; - rrect(s, dx, dy, door_w, dh, 14, SAFE_BODY_EDGE, BG); - if door_w > 28 { - rrect(s, dx + 6, dy + 6, door_w - 12, dh - 12, 10, DOOR_PANEL, SAFE_BODY_EDGE); - } - rrect(s, 14, 132, 22, 46, 5, HINGE, BG); - rrect(s, 14, 288, 22, 46, 5, HINGE, BG); - } -} - -fn draw_opening_scene(s: &mut impl Surface, open_t: i32, sparkle: u32) { - let (door_w, dy, dh) = opening_door_geom(open_t); - { - // Skip painting BG and gold bars underneath the closed central slab of the door. - let inner = if door_w > 48 && dh > 36 { - [44, dy + 16, 28 + door_w - 16, dy + dh - 16] - } else { - [0, 0, 0, 0] - }; - let mut ex = Exclude { s, skip: inner }; - ex.rect(0, 0, SIZE, SIZE, BG.rgb565()); - draw_gold_interior(&mut ex, C, 206, 268, 224, sparkle); - } - draw_opening_door(s, door_w, dy, dh); -} - -fn draw_opening_step(s: &mut impl Surface, prev_t: i32, now_t: i32) { - let (prev_dw, prev_dy, prev_dh) = opening_door_geom(prev_t); - let (now_dw, now_dy, now_dh) = opening_door_geom(now_t); - let prev_right = if prev_dw > 18 { 28 + prev_dw } else { 52 }; - - let paint_strip = |s: &mut _, x0: i32, y0: i32, x1: i32, y1: i32| { - if x1 <= x0 || y1 <= y0 { - return; - } - let mut clip = Clip { s, x0, y0, x1, y1 }; - // Paint BG only outside the rectangular gold frame core to avoid gold flashing black. - let mut ex_gold = Exclude { s: &mut clip, skip: [C - 116, 206 - 94, C + 116, 206 + 94] }; - ex_gold.rect(x0, y0, x1 - x0, y1 - y0, BG.rgb565()); - draw_gold_interior(&mut clip, C, 206, 268, 224, 0); - }; - - if now_dw <= 18 { - paint_strip(s, 14, prev_dy, prev_right + 1, prev_dy + prev_dh); - if prev_dh < SIZE { - s.rect(14, 132, 22, 46, BG.rgb565()); - s.rect(14, 288, 22, 46, BG.rgb565()); - } - return; - } - - let now_right = 28 + now_dw; - let rx0 = (now_right - 14).max(28); - paint_strip(s, rx0, prev_dy, prev_right + 1, prev_dy + prev_dh); - if now_dy > prev_dy { - paint_strip(s, 28, prev_dy, now_right + 1, (now_dy + 14).min(prev_dy + prev_dh)); - } - if now_dy + now_dh < prev_dy + prev_dh { - paint_strip(s, 28, (now_dy + now_dh - 14).max(prev_dy), now_right + 1, prev_dy + prev_dh); - } - - if now_dw > 48 && now_dh > 36 { - let mut ex = Exclude { s, skip: [44, now_dy + 16, now_right - 16, now_dy + now_dh - 16] }; - draw_opening_door(&mut ex, now_dw, now_dy, now_dh); - } else { - draw_opening_door(s, now_dw, now_dy, now_dh); - } -} - -/// Draws the jail bars slamming shut with flashing beacons and the prisoner gripping the bars. -fn draw_jail_scene(s: &mut impl Surface, anim_ms: u32, with_frame: bool) { - let cx = C; - let bx = cx - 106; - let by = 82; - let bw = 212; - let bh = 144; - let iy0 = by + 4; - let iy1 = by + bh - 4; - let ih = iy1 - iy0; - - let slam_t = ((anim_ms.min(OVER_SLAM_MS) as i32) * ONE / OVER_SLAM_MS as i32).clamp(0, ONE); - let slam_q = ease_out(slam_t); - let bar_h = ((ih * slam_q) / ONE).clamp(16, ih); - let thud_y = if (340..400).contains(&anim_ms) { - 2 - } else if (400..470).contains(&anim_ms) { - -1 - } else { - 0 - }; - - let beacon = if anim_ms < OVER_ANIM_MS { (((anim_ms / 180) & 1) + 1) as u8 } else { 0 }; - let cell_bg = siren_wash(CELL_BG, beacon, 150); - let (top_l, top_r) = match beacon { - 1 => (SIREN_RED, Rgb(22, 48, 92)), - 2 => (Rgb(84, 20, 26), SIREN_BLUE), - _ => (SIREN_RED, SIREN_BLUE), - }; - - // Outer frame only needed on first draw; incremental frames paint cell interior directly. - if with_frame { - rrect(s, bx, by, bw, bh, 14, SAFE_BODY_EDGE, BG); - } - rrect(s, bx + 4, iy0, bw - 8, ih, 10, cell_bg, SAFE_BODY_EDGE); - - // Ceiling police strobe beacons. - s.rect(bx + 12, by + 6, 46, 5, top_l.rgb565()); - s.rect(bx + bw - 58, by + 6, 46, 5, top_r.rgb565()); - - // Prisoner body (striped shirt) + head inside the cell. - let body_x = cx - 44; - let body_y = (by + 84 + thud_y).max(iy0 + 40); - let body_w = 88; - let body_h = (iy1 - body_y - 4).max(12); - rrect(s, body_x, body_y, body_w, body_h, 12, PRISON_A, cell_bg); - for sy in (body_y + 8..iy1 - 6).step_by(12) { - s.rect(body_x + 4, sy, body_w - 8, 5, PRISON_B.rgb565()); - } - - // Arms reach outward/up as the steel gate locks down. - let arm_y = (by + 98 - (bar_h.min(82) * 14) / 82 + thud_y).clamp(iy0 + 20, iy1 - 10); - line(s, cx - 36, body_y + 16, cx - 46, arm_y, 10, PRISON_A, cell_bg); - line(s, cx + 36, body_y + 16, cx + 46, arm_y, 10, PRISON_A, cell_bg); - - // Head + startled expression while falling, grim expression once locked behind bars. - let head_y = by + 56 + thud_y; - disc(s, cx, head_y, 24, SKIN, cell_bg); - s.rect(cx - 18, head_y - 23, 36, 8, WHEEL_RIM.rgb565()); - disc(s, cx - 8, head_y - 2, 3, WHEEL_DARK, SKIN); - disc(s, cx + 8, head_y - 2, 3, WHEEL_DARK, SKIN); - if bar_h < 82 { - disc(s, cx, head_y + 10, 4, WHEEL_DARK, SKIN); - } else { - s.rect(cx - 7, head_y + 9, 14, 3, WHEEL_DARK.rgb565()); - } - - // Vertical steel jail bars slamming down from top of cell + crossbars. - let bar_xs = [cx - 78, cx - 44, cx, cx + 44, cx + 78]; - for &bar_x in &bar_xs { - s.rect(bar_x - 4, iy0, 8, bar_h, BAR_METAL.rgb565()); - s.rect(bar_x - 2, iy0, 2, bar_h, BAR_SHINE.rgb565()); - } - if bar_h >= 20 { - s.rect(bx + 8, iy0 + 14, bw - 16, 5, BAR_METAL.rgb565()); - } - let bot_y = (iy0 + bar_h - 6).min(iy1 - 8); - s.rect(bx + 8, bot_y, bw - 16, 6, BAR_METAL.rgb565()); - - // Hands snap onto the vertical bars (`cx - 44` and `cx + 44`) once the gate drops past grip height. - if bar_h >= 82 { - let grip_y = by + 82 + thud_y; - for &hx in &[cx - 44, cx + 44] { - rrect(s, hx - 9, grip_y - 8, 18, 17, 6, SKIN, BAR_METAL); - s.rect(hx - 6, grip_y - 2, 12, 2, Rgb(164, 126, 98).rgb565()); - s.rect(hx - 6, grip_y + 3, 12, 2, Rgb(164, 126, 98).rgb565()); - } - } -} - -fn draw_menu_button(s: &mut impl Surface, y: i32, title: &str, sub: &str, selected: bool, accent: Rgb) { - let fill = if selected { CARD_SEL } else { CARD }; - rrect(s, MENU_BTN_X, y, MENU_BTN_W, MENU_BTN_H, 14, fill, BANK_WALL); - if selected { - rrect(s, MENU_BTN_X + 8, y + 10, 5, MENU_BTN_H - 20, 2, accent, fill); - } - FONT_MD.centre(s, C, y + 6, title, if selected { accent } else { WHITE_RGB }, fill); - FONT_SM.centre(s, C, y + 29, sub, GREY_RGB, fill); -} - -fn draw_menu(s: &mut impl Surface, g: &Game, best: Records) { - // Small classical bank on the background, softly dimmed behind the UI cards. - draw_bank_scene(s, C + 18, ONE, (ONE * 58) / 100, false, true); - ring(s, C, C, 214, 218, SAFE_BODY, BG); - FONT_LG.centre(s, C, 56, "VAULT", WHITE_RGB, BG); - FONT_MD.centre(s, C, 102, "RUSH", GOLD, BG); - - let mut b1 = [0u8; 20]; - let mut b2 = [0u8; 20]; - let mut b3 = [0u8; 20]; - let heist_best = fastest_heist_ms(best); - let heist_sub = if heist_best == 0 { "10S - 60S" } else { format_heist_best(heist_best, &mut b2) }; - draw_menu_button(s, MENU_CLASSIC_Y, "CLASSIC", format_best(b"BEST ", best.classic, &mut b1), g.menu_sel == 0, ACCENT); - draw_menu_button(s, MENU_HEIST_Y, "HEIST", heist_sub, g.menu_sel == 1, GOLD); - draw_menu_button(s, MENU_BLITZ_Y, "BLITZ 60S", format_best(b"BEST ", best.blitz, &mut b3), g.menu_sel == 2, CYAN); - - FONT_SM.centre(s, C, 354, "CROWN OR TAP", GREY_RGB, BG); -} - -fn draw_heist_header(s: &mut impl Surface, idx: usize, best: Records) { - let pins = heist_pins_for_idx(idx); - let mut buf = [0u8; 28]; - let mut pos = 0usize; - let push = |buf: &mut [u8], pos: &mut usize, bytes: &[u8]| { - let n = bytes.len().min(buf.len() - *pos); - buf[*pos..*pos + n].copy_from_slice(&bytes[..n]); - *pos += n; - }; - let mut db = [0u8; 11]; - push(&mut buf, &mut pos, int(pins as i32, &mut db).as_bytes()); - push(&mut buf, &mut pos, b" PINS "); - let mut hb = [0u8; 20]; - push(&mut buf, &mut pos, format_heist_best(best.heist_best_ms[idx], &mut hb).as_bytes()); - let sub = core::str::from_utf8(&buf[..pos]).unwrap_or("PINS"); - let bx = C - 108; - rrect(s, bx, 90, 216, 28, 10, CARD, BG); - FONT_SM.centre(s, C, 95, sub, GREY_RGB, CARD); -} - -fn draw_heist_tile(s: &mut impl Surface, i: usize, selected: bool, cleared: bool) { - let [x, y, w, h] = heist_tile_rect(i); - let fill = if selected { CARD_SEL } else { CARD }; - let border = if selected { GOLD } else { HUD_RIM }; - rrect(s, x, y, w, h, 14, border, BANK_WALL); - rrect(s, x + 2, y + 2, w - 4, h - 4, 12, fill, border); - - let mut lb = [0u8; 6]; - let mut db = [0u8; 11]; - let d = int(HEIST_TIMES_S[i] as i32, &mut db).as_bytes(); - let n = d.len().min(4); - lb[..n].copy_from_slice(&d[..n]); - lb[n] = b'S'; - let label = core::str::from_utf8(&lb[..n + 1]).unwrap_or("40S"); - FONT_MD.centre(s, x + w / 2, y + 18, label, if selected { GOLD } else { WHITE_RGB }, fill); - - if cleared { - disc(s, x + w - 12, y + 12, 4, GREEN, fill); - } -} - -fn draw_heist_select(s: &mut impl Surface, g: &Game, best: Records) { - draw_bank_scene(s, C + 18, ONE, (ONE * 58) / 100, false, true); - ring(s, C, C, 214, 218, SAFE_BODY, BG); - FONT_MD.centre(s, C, 56, "HEIST TIME", GOLD, BG); - draw_heist_header(s, g.heist_idx, best); - - for i in 0..HEIST_TIMES_S.len() { - draw_heist_tile(s, i, i == g.heist_idx, best.heist_best_ms[i] > 0); - } - - FONT_SM.centre(s, C, 294, "TAP TO START", GREY_RGB, BG); - rrect(s, HEIST_BACK_X, HEIST_BACK_Y, HEIST_BACK_W, HEIST_BACK_H, 22, CARD, BG); - FONT_MD.centre(s, C, HEIST_BACK_Y + 11, "BACK", WHITE_RGB, CARD); -} - -fn draw_end_buttons(s: &mut impl Surface, sel: usize, primary: &str, bg: Rgb) { - let f0 = if sel == 0 { ACCENT } else { CARD }; - rrect(s, OVER_BTN_X, OVER_RETRY_Y, OVER_BTN_W, OVER_BTN_H, 23, f0, bg); - FONT_MD.centre(s, C, OVER_RETRY_Y + 12, primary, if sel == 0 { BG } else { WHITE_RGB }, f0); - - let f1 = if sel == 1 { CARD_SEL } else { CARD }; - rrect(s, OVER_BTN_X, OVER_MENU_Y, OVER_BTN_W, OVER_BTN_H, 23, f1, bg); - FONT_MD.centre(s, C, OVER_MENU_Y + 12, "MENU", WHITE_RGB, f1); -} - -fn draw_over_title(s: &mut impl Surface, g: &Game) { - let title = match g.mode { - Mode::Classic => "CAUGHT!", - Mode::Heist | Mode::Blitz => "TOO SLOW!", - }; - let k = ((g.anim_ms.min(300) as i32) * ONE / 300).clamp(260, ONE); - s.rect(C - 120, 42, 240, 32, BG.rgb565()); - FONT_MD.centre(s, C, 46, title, tint(RED, k), BG); -} - -fn draw_over(s: &mut impl Surface, g: &Game, best: Records) { - s.rect(0, 0, SIZE, SIZE, BG.rgb565()); - draw_over_title(s, g); - - draw_jail_scene(s, g.anim_ms, true); - - if g.mode == Mode::Heist { - let mut hb = [0u8; 20]; - FONT_SM.centre(s, C, 240, format_heist_best(best.heist_best_ms[g.heist_idx], &mut hb), GREY_RGB, BG); - } else { - let mut sb = [0u8; 20]; - let label = format_best(b"SCORE ", g.score, &mut sb); - if g.new_best { - FONT_SM.centre(s, C, 236, label, WHITE_RGB, BG); - FONT_SM.centre(s, C, 256, "NEW RECORD!", GREEN, BG); - } else { - let mut bb = [0u8; 20]; - let b = if g.mode == Mode::Classic { best.classic } else { best.blitz }; - FONT_SM.centre(s, C, 236, label, WHITE_RGB, BG); - FONT_SM.centre(s, C, 256, format_best(b"BEST ", b, &mut bb), GREY_RGB, BG); - } - } - - draw_end_buttons(s, g.over_sel, "RETRY", BG); -} - -fn draw_playing_backdrop_masked(s: &mut impl Surface, siren: u8) { - let [hx, hy, hw, hh] = HUD_BOX; - let mut ex_hud = Exclude { s, skip: [hx + 12, hy + 4, hx + hw - 12, hy + hh - 4] }; - // Hub disc (`r_hub = 29`) completely covers an inscribed `36x36` centre square (`diag/2 = 25 < 29`). - let mut ex_both = Exclude { s: &mut ex_hud, skip: [C - 18, WHEEL_CY - 18, C + 18, WHEEL_CY + 18] }; - draw_safe_backdrop(&mut ex_both, 2660, 0, ONE, siren, false); -} - -fn bank_bright(t: i32) -> i32 { - if t < ONE / 2 { - lerp((ONE * 70) / 100, ONE, t * 2) - } else { - lerp(ONE, 0, (t - ONE / 2) * 2) - } -} - -fn zoom_params(t: i32) -> (i32, i32, i32, i32, bool, bool, bool) { - let bright = (t * 3).min(ONE); - let scale = lerp(ONE, 2660, t); - let wheel_t = ((t * 8) / 7).min(ONE); - let wheel_r = lerp(38, WHEEL_R1, wheel_t); - // Settle wheel, HUD, ticks, and AA finish on separate frames after backdrop growth stops. - let wheel_cy = lerp(C, WHEEL_CY, wheel_t); - let show_hud = t > 910; - let show_ticks = t > 960; - let crisp = t > 990; - (scale, bright, wheel_r, wheel_cy, show_hud, show_ticks, crisp) -} - -fn draw_zoom_step(s: &mut impl Surface, g: &Game, pt: i32, nt: i32) { - let (prev_scale, prev_bright, prev_r, prev_cy, prev_hud, prev_ticks, prev_crisp) = zoom_params(pt); - let (now_scale, now_bright, now_r, now_cy, now_hud, now_ticks, now_crisp) = zoom_params(nt); - let led = zone_led_color(g.zone(), g.flash); - - if prev_bright == ONE && now_bright == ONE { - if (96 * prev_scale) / ONE < C { - let core = safe_door_core(prev_scale); - let half = (96 * prev_scale) / ONE; - let x0 = C - half; - let y0 = C - half; - let w = half * 2; - let dpad = (20 * prev_scale) / ONE; - let r = safe_corner_r(prev_scale); - let ix = x0 + dpad + 3; - let iy = y0 + dpad + 3; - let iw = w - 2 * dpad - 6; - let dr = (r - 6).max(2); - let (top_y, bot_y) = if (96 * now_scale) / ONE >= C { (60, SIZE - 52) } else { (0, SIZE) }; - let mut ex_v = Exclude { s, skip: [core[0].max(ix + dr), iy.max(top_y), ix + iw - dr, (iy + iw).min(bot_y)] }; - let mut ex_h = Exclude { s: &mut ex_v, skip: [core[0], core[1].max(top_y), core[2], core[3].min(bot_y)] }; - draw_safe_backdrop(&mut ex_h, now_scale, 0, ONE, 0, false); - } - let wheel_changed = prev_cy != now_cy || prev_r != now_r || prev_crisp != now_crisp; - if prev_cy != now_cy { - solid_disc(s, C, prev_cy, prev_r + 2, DOOR_PANEL); - } else if wheel_changed { - let prev_hub = (prev_r * 30) / 100; - let clear_r1 = if now_crisp { now_r + 2 } else { (now_r * 74) / 100 }; - solid_ring(s, C, now_cy, (prev_hub - 2).max(0), clear_r1, DOOR_PANEL); - } - if wheel_changed { - draw_wheel(s, C, now_cy, now_r, g.dial, led, now_ticks && !prev_ticks, DOOR_PANEL, ONE, 0, now_crisp); - } else if now_ticks && !prev_ticks { - let active_c = wash_fg(led, 0); - for i in 0..DIAL_STEPS { - draw_single_tick(s, C, now_cy, i, i == g.dial, active_c, DOOR_PANEL, 0); - } - } - if now_hud && !prev_hud { - draw_hud(s, g, 0); - } - } else { - draw_safe_backdrop(s, now_scale, 0, now_bright, 0, false); - draw_wheel(s, C, now_cy, now_r, g.dial, tint(led, now_bright), now_ticks, tint(DOOR_PANEL, now_bright), now_bright, 0, now_crisp); - if now_hud { - draw_hud(s, g, 0); - } - } -} - -pub fn full(s: &mut impl Surface, g: &Game, best: Records) { - match g.state { - State::Menu => draw_menu(s, g, best), - State::HeistSelect => draw_heist_select(s, g, best), - State::EnterBank => { - let t = g.anim_t(); - let scale = lerp(ONE, 1850, t); - let cy = lerp(C + 18, C + 36, t); - draw_bank_scene(s, cy, scale, bank_bright(t), true, true); - } - State::ZoomIn => { - let t = g.anim_t(); - let (scale, bright, wheel_r, wheel_cy, show_hud, show_ticks, crisp) = zoom_params(t); - if bright <= 8 { - s.rect(0, 0, SIZE, SIZE, BG.rgb565()); - return; - } - let led = zone_led_color(g.zone(), g.flash); - draw_safe_backdrop(s, scale, 0, bright, 0, true); - draw_wheel(s, C, wheel_cy, wheel_r, g.dial, tint(led, bright), show_ticks, tint(DOOR_PANEL, bright), bright, 0, crisp); - if show_hud { - draw_hud(s, g, 0); - } - } - State::Playing => { - let siren = g.siren_phase(); - draw_playing_backdrop_masked(s, siren); - draw_hud(s, g, siren); - draw_wheel(s, C, WHEEL_CY, WHEEL_R1, g.dial, zone_led_color(g.zone(), g.flash), true, wash(DOOR_PANEL, siren), ONE, siren, true); - draw_siren_ring(s, siren); - } - State::Unlocking => { - let t = g.anim_t(); - draw_safe_backdrop(s, 2660, t, ONE, 0, false); - let r = lerp(WHEEL_R1, 10, t); - let spin_dial = g.dial + (t * 6) / ONE; - if r > 14 { - draw_wheel(s, C, WHEEL_CY, r, spin_dial, GREEN, false, DOOR_PANEL, ONE, 0, true); - } - FONT_MD.centre(s, C, 86, "UNLOCKED", GREEN, DOOR_PANEL); - } - State::Opening => { - draw_opening_scene(s, g.anim_t(), 0); - } - State::ClassicGold => { - s.rect(0, 0, SIZE, SIZE, BG.rgb565()); - draw_gold_interior(s, C, 220, 276, 228, g.anim_ms / 240); - FONT_MD.centre(s, C, 62, "OPEN!", GOLD, BG); - let mut sb = [0u8; 20]; - FONT_MD.centre(s, C, 354, format_best(b"SAFES ", g.score, &mut sb), WHITE_RGB, BG); - } - State::HeistWin => { - s.rect(0, 0, SIZE, SIZE, BG.rgb565()); - draw_gold_interior(s, C, 182, 256, 184, g.anim_ms / 240); - let mut tb = [0u8; 16]; - let time_str = format_tenths(g.elapsed_ms as i32, &mut tb); - if g.new_best { - FONT_MD.centre(s, C, 32, "NEW RECORD!", GREEN, BG); - } else { - FONT_MD.centre(s, C, 32, "CRACKED!", GOLD, BG); - } - FONT_MD.centre(s, C, 58, time_str, WHITE_RGB, BG); - draw_end_buttons(s, g.over_sel, "AGAIN", BG); - } - State::Over => draw_over(s, g, best), - } -} - -pub fn frame(s: &mut impl Surface, g: &Game, best: Records, last: Option) -> (Seen, bool) { - let now = seen(g); - if last.is_some_and(|l| l.state == State::EnterBank && bank_bright(l.anim_t) <= 20 && now.state == State::ZoomIn && now.anim_t <= 2) { - return (now, false); - } - if let Some(prev) = last.filter(|l| l.state == State::ZoomIn && now.state == State::Playing && l.mode == now.mode && now.siren == 0) { - draw_zoom_step(s, g, prev.anim_t, ONE); - return (now, true); - } - let Some(prev) = last.filter(|l| l.state == now.state && (matches!(now.state, State::Menu | State::HeistSelect) || l.mode == now.mode)) else { - full(s, g, best); - return (now, true); - }; - if prev == now { - return (now, false); - } - match now.state { - State::Menu => { - if prev.menu_sel != now.menu_sel { - let mut b1 = [0u8; 20]; - let mut b2 = [0u8; 20]; - let mut b3 = [0u8; 20]; - let hb = fastest_heist_ms(best); - let hsub = if hb == 0 { "10S - 60S" } else { format_heist_best(hb, &mut b2) }; - draw_menu_button(s, MENU_CLASSIC_Y, "CLASSIC", format_best(b"BEST ", best.classic, &mut b1), now.menu_sel == 0, ACCENT); - draw_menu_button(s, MENU_HEIST_Y, "HEIST", hsub, now.menu_sel == 1, GOLD); - draw_menu_button(s, MENU_BLITZ_Y, "BLITZ 60S", format_best(b"BEST ", best.blitz, &mut b3), now.menu_sel == 2, CYAN); - return (now, true); - } - (now, false) - } - State::HeistSelect => { - if prev.heist_idx != now.heist_idx { - draw_heist_header(s, now.heist_idx, best); - draw_heist_tile(s, prev.heist_idx, false, best.heist_best_ms[prev.heist_idx] > 0); - draw_heist_tile(s, now.heist_idx, true, best.heist_best_ms[now.heist_idx] > 0); - return (now, true); - } - (now, false) - } - State::Over => { - let mut drew = false; - if prev.over_sel != now.over_sel { - draw_end_buttons(s, now.over_sel, "RETRY", BG); - drew = true; - } - if prev.anim_step != now.anim_step { - if prev.anim_step <= 9 { - draw_over_title(s, g); - } - draw_jail_scene(s, g.anim_ms, false); - drew = true; - } - (now, drew) - } - State::HeistWin => { - if prev.over_sel != now.over_sel { - draw_end_buttons(s, now.over_sel, "AGAIN", BG); - return (now, true); - } - if prev.anim_step != now.anim_step { - draw_gold_interior(s, C, 182, 256, 184, g.anim_ms / 240); - return (now, true); - } - (now, false) - } - State::ClassicGold => { - if prev.anim_step != now.anim_step { - draw_gold_interior(s, C, 220, 276, 228, g.anim_ms / 240); - return (now, true); - } - (now, false) - } - State::EnterBank => { - let pb = bank_bright(prev.anim_t); - let nb = bank_bright(now.anim_t); - if pb <= 20 && nb <= 20 { - return (now, false); - } - let t = now.anim_t; - let scale = lerp(ONE, 1850, t); - let cy = lerp(C + 18, C + 36, t); - draw_bank_scene(s, cy, scale, nb, true, false); - (now, true) - } - State::ZoomIn => { - draw_zoom_step(s, g, prev.anim_t, now.anim_t); - (now, true) - } - State::Unlocking => { - let pt = prev.anim_t; - let nt = now.anim_t; - draw_safe_bolts(s, nt, ONE, 0, true); - let prev_r = lerp(WHEEL_R1, 10, pt); - let now_r = lerp(WHEEL_R1, 10, nt); - let spin_dial = g.dial + (nt * 6) / ONE; - disc(s, C, WHEEL_CY, prev_r + 2, DOOR_PANEL, DOOR_PANEL); - if now_r > 14 { - draw_wheel(s, C, WHEEL_CY, now_r, spin_dial, GREEN, false, DOOR_PANEL, ONE, 0, true); - } - (now, true) - } - State::Opening => { - draw_opening_step(s, prev.anim_t, now.anim_t); - (now, true) - } - State::Playing => { - if prev.siren != now.siren { - draw_playing_backdrop_masked(s, now.siren); - draw_hud(s, g, now.siren); - draw_wheel(s, C, WHEEL_CY, WHEEL_R1, g.dial, zone_led_color(g.zone(), g.flash), true, wash(DOOR_PANEL, now.siren), ONE, now.siren, true); - draw_siren_ring(s, now.siren); - return (now, true); - } - let mut drew = false; - let top_changed = (prev.pin_idx, prev.pin_count, prev.lives, prev.score, prev.combo) - != (now.pin_idx, now.pin_count, now.lives, now.score, now.combo); - if top_changed { - draw_hud_top(s, g, now.siren, true); - drew = true; - } else if prev.tenths != now.tenths && g.mode != Mode::Classic { - draw_hud_timer(s, g, now.siren, true); - drew = true; - } - - if g.mode != Mode::Blitz && (prev.expected_dir, prev.armed) != (now.expected_dir, now.armed) { - draw_hud_dir(s, g, now.siren, true); - drew = true; - } - if (prev.dial, prev.zone, prev.flash) != (now.dial, now.zone, now.flash) { - draw_hud_dial(s, g, now.siren, true); - let bg = wash(DOOR_PANEL, now.siren); - draw_wheel_diff(s, prev.dial, now.dial, zone_led_color(g.zone(), g.flash), bg, now.siren); - drew = true; - } - if (prev.zone, prev.flash) != (now.zone, now.flash) { - draw_hud_led(s, g, now.siren); - drew = true; - } - (now, drew) - } - } -} - -#[cfg(test)] -mod tests { - use super::*; - use crate::game::{ENTER_BANK_MS, OPEN_MS, UNLOCK_MS, ZOOM_MS}; - use cmf_wp2_ui::Fb; - use cmf_wp2_ui::motion::isqrt; - - const N: usize = (SIZE * SIZE) as usize; - - fn fresh(g: &Game, best: Records) -> Vec { - let mut px = vec![0x1234u16; N]; - full(&mut Fb::new(&mut px), g, best); - px - } - - fn first_diff(a: &[u16], b: &[u16]) -> Option<(i32, i32)> { - a.iter().zip(b).position(|(x, y)| x != y).map(|i| (i as i32 % SIZE, i as i32 / SIZE)) - } - - #[test] - fn partial_frames_match_full_across_modes_siren_and_animations() { - let mut best = Records { classic: 2, blitz: 8, heist_best_ms: [0, 0, 12_100, 21_400, 0, 0] }; - let mut g = Game::new(42); - let mut px = vec![0u16; N]; - let (mut last, _) = frame(&mut Fb::new(&mut px), &g, best, None); - assert_eq!(first_diff(&px, &fresh(&g, best)), None); - - for _ in 0..3 { - g.crown(1); - (last, _) = frame(&mut Fb::new(&mut px), &g, best, Some(last)); - assert_eq!(first_diff(&px, &fresh(&g, best)), None); - } - - g.open_heist_select(); - (last, _) = frame(&mut Fb::new(&mut px), &g, best, Some(last)); - assert_eq!(first_diff(&px, &fresh(&g, best)), None); - for _ in 0..3 { - g.crown(1); - (last, _) = frame(&mut Fb::new(&mut px), &g, best, Some(last)); - assert_eq!(first_diff(&px, &fresh(&g, best)), None); - } - - // Start 10s Heist -> walk frame-by-frame through EnterBank -> ZoomIn -> Playing -> siren -> Unlocking -> Opening -> HeistWin. - g.start_heist(0); - (last, _) = frame(&mut Fb::new(&mut px), &g, best, Some(last)); - assert_eq!(first_diff(&px, &fresh(&g, best)), None); - while g.state == State::EnterBank { - g.tick(33, &mut best); - (last, _) = frame(&mut Fb::new(&mut px), &g, best, Some(last)); - assert_eq!(first_diff(&px, &fresh(&g, best)), None); - } - while g.state == State::ZoomIn { - g.tick(33, &mut best); - (last, _) = frame(&mut Fb::new(&mut px), &g, best, Some(last)); - assert_eq!(first_diff(&px, &fresh(&g, best)), None); - } - - // Verify incremental wheel & HUD updates across single and multi-step jumps. - for delta in [1i16, 1, 5, -3, 7, -2] { - g.crown(delta); - (last, _) = frame(&mut Fb::new(&mut px), &g, best, Some(last)); - assert_eq!(first_diff(&px, &fresh(&g, best)), None); - } - - // Advance into the 5-second police siren window, rotate dial during strobe, and alternate siren phases. - g.tick(6_000, &mut best); - (last, _) = frame(&mut Fb::new(&mut px), &g, best, Some(last)); - assert_eq!(first_diff(&px, &fresh(&g, best)), None); - g.crown(1); - (last, _) = frame(&mut Fb::new(&mut px), &g, best, Some(last)); - assert_eq!(first_diff(&px, &fresh(&g, best)), None); - g.tick(250, &mut best); - (last, _) = frame(&mut Fb::new(&mut px), &g, best, Some(last)); - assert_eq!(first_diff(&px, &fresh(&g, best)), None); - - for _ in 0..g.pin_count { - let dir = if g.expected_dir == Dir::Cw { 1 } else { -1 }; - for _ in 0..2 { - g.crown(dir); - } - while g.dial != g.target { - g.crown(dir); - } - g.try_lock(&mut best); - (last, _) = frame(&mut Fb::new(&mut px), &g, best, Some(last)); - assert_eq!(first_diff(&px, &fresh(&g, best)), None); - } - - while g.state == State::Unlocking { - g.tick(33, &mut best); - (last, _) = frame(&mut Fb::new(&mut px), &g, best, Some(last)); - assert_eq!(first_diff(&px, &fresh(&g, best)), None); - } - while g.state == State::Opening { - g.tick(33, &mut best); - (last, _) = frame(&mut Fb::new(&mut px), &g, best, Some(last)); - assert_eq!(first_diff(&px, &fresh(&g, best)), None); - } - g.crown(1); - let _ = frame(&mut Fb::new(&mut px), &g, best, Some(last)); - assert_eq!(first_diff(&px, &fresh(&g, best)), None); - - // Verify ClassicGold animation frames match full redraws. - let mut g_cl = Game::new(42); - g_cl.start(Mode::Classic); - g_cl.tick(ENTER_BANK_MS, &mut best); - g_cl.tick(ZOOM_MS, &mut best); - for _ in 0..g_cl.pin_count { - let dir = if g_cl.expected_dir == Dir::Cw { 1 } else { -1 }; - for _ in 0..3 { - g_cl.crown(dir); - } - while g_cl.dial != g_cl.target { - g_cl.crown(dir); - } - g_cl.try_lock(&mut best); - } - g_cl.tick(UNLOCK_MS, &mut best); - g_cl.tick(OPEN_MS, &mut best); - let (mut last_cl, _) = frame(&mut Fb::new(&mut px), &g_cl, best, Some(last)); - assert_eq!(first_diff(&px, &fresh(&g_cl, best)), None); - for _ in 0..4 { - g_cl.tick(240, &mut best); - (last_cl, _) = frame(&mut Fb::new(&mut px), &g_cl, best, Some(last_cl)); - assert_eq!(first_diff(&px, &fresh(&g_cl, best)), None); - } - - // Trigger timeout into Over and verify jail-slam animation & selection match full redraws. - let mut g_over = Game::new(42); - g_over.start_heist(0); - g_over.tick(ENTER_BANK_MS, &mut best); - g_over.tick(ZOOM_MS, &mut best); - g_over.tick(10_000, &mut best); - let (mut last_over, _) = frame(&mut Fb::new(&mut px), &g_over, best, Some(last_cl)); - assert_eq!(first_diff(&px, &fresh(&g_over, best)), None); - for step in [180, 180, 100, 300, 700] { - g_over.tick(step, &mut best); - (last_over, _) = frame(&mut Fb::new(&mut px), &g_over, best, Some(last_over)); - assert_eq!(first_diff(&px, &fresh(&g_over, best)), None); - } - g_over.crown(1); - let _ = frame(&mut Fb::new(&mut px), &g_over, best, Some(last_over)); - assert_eq!(first_diff(&px, &fresh(&g_over, best)), None); - } - - #[test] - fn wheel_turn_draw_budget_is_compact() { - let mut best = Records::default(); - let mut g = Game::new(7); - g.start(Mode::Classic); - g.tick(ENTER_BANK_MS, &mut best); - g.tick(ZOOM_MS, &mut best); - - let last = seen(&g); - g.crown(1); - let mut c = cmf_wp2_ui::Count::default(); - let (_, drew) = frame(&mut c, &g, best, Some(last)); - assert!(drew); - assert!(c.rects < 1_050, "too many rects per crown frame: {}", c.rects); - assert!(c.px < 8_000, "too many px per crown frame: {}", c.px); - } - - #[test] - fn intro_animation_draw_budgets() { - let mut best = Records::default(); - let mut g = Game::new(7); - g.start(Mode::Classic); - let mut last = seen(&g); - let (mut eb_max_r, mut eb_max_px) = (0u32, 0u64); - let (mut zi_max_r, mut zi_max_px) = (0u32, 0u64); - while g.state == State::EnterBank { - g.tick(33, &mut best); - let mut c = cmf_wp2_ui::Count::default(); - let (next, _) = frame(&mut c, &g, best, Some(last)); - last = next; - eb_max_r = eb_max_r.max(c.rects); - eb_max_px = eb_max_px.max(c.px); - } - while g.state == State::ZoomIn { - g.tick(33, &mut best); - let mut c = cmf_wp2_ui::Count::default(); - let (next, _) = frame(&mut c, &g, best, Some(last)); - last = next; - zi_max_r = zi_max_r.max(c.rects); - zi_max_px = zi_max_px.max(c.px); - } - let mut play_c = cmf_wp2_ui::Count::default(); - let (_, drew_post) = frame(&mut play_c, &g, best, Some(last)); - assert!(!drew_post); - assert!(eb_max_r < 750, "too many rects in EnterBank: {eb_max_r}"); - assert!(eb_max_px < 225_000, "too many px in EnterBank: {eb_max_px}"); - assert!(zi_max_r < 3_200, "too many rects in ZoomIn: {zi_max_r}"); - assert!(zi_max_px < 170_000, "too many px in ZoomIn: {zi_max_px}"); - assert_eq!((play_c.rects, play_c.px), (0, 0)); - } - - #[test] - fn hud_wheel_and_buttons_fit_inside_round_panel() { - assert!(HUD_BOX[1] + HUD_BOX[3] < WHEEL_BOX[1], "HUD overlaps WHEEL_BOX"); - for [x, y, w, h] in [HUD_BOX, WHEEL_BOX] { - assert!(x >= 32 && x + w <= SIZE - 32, "box touches door side frame"); - for (cx, cy) in [(x, y), (x + w, y), (x, y + h), (x + w, y + h)] { - let d2 = (cx - C) * (cx - C) + (cy - C) * (cy - C); - assert!(d2 <= SIREN_R0 * SIREN_R0, "box corner ({cx},{cy}) overlaps siren ring"); - } - } - let mut boxes: [[i32; 4]; 12] = [ - [MENU_BTN_X, MENU_CLASSIC_Y, MENU_BTN_W, MENU_BTN_H], - [MENU_BTN_X, MENU_HEIST_Y, MENU_BTN_W, MENU_BTN_H], - [MENU_BTN_X, MENU_BLITZ_Y, MENU_BTN_W, MENU_BTN_H], - [OVER_BTN_X, OVER_RETRY_Y, OVER_BTN_W, OVER_BTN_H], - [OVER_BTN_X, OVER_MENU_Y, OVER_BTN_W, OVER_BTN_H], - [HEIST_BACK_X, HEIST_BACK_Y, HEIST_BACK_W, HEIST_BACK_H], - [0; 4], [0; 4], [0; 4], [0; 4], [0; 4], [0; 4], - ]; - for i in 0..6 { - boxes[6 + i] = heist_tile_rect(i); - } - for [x, y, w, h] in boxes { - for (cx, cy) in [(x, y), (x + w, y), (x, y + h), (x + w, y + h)] { - let d2 = (cx - C) * (cx - C) + (cy - C) * (cy - C); - assert!(d2 <= (C - 10) * (C - 10), "button ({cx},{cy}) outside circle"); - } - } - assert!(FONT_LG.width("VAULT") / 2 <= isqrt((C - 10).pow(2) - (C - 56).pow(2))); - assert!(FONT_MD.width("RUSH") / 2 <= isqrt((C - 10).pow(2) - (C - 102).pow(2))); - assert!(FONT_MD.width("TOO SLOW!") / 2 <= isqrt((C - 10).pow(2) - (C - 46).pow(2))); - assert!(FONT_MD.width("BLITZ 60S") <= MENU_BTN_W - 24); - assert!(FONT_SM.width("CROWN OR TAP") / 2 <= isqrt((C - 10).pow(2) - (354 + 16 - C).pow(2))); - } -} diff --git a/apps/vault-rush/store.md b/apps/vault-rush/store.md deleted file mode 100644 index 190f4ca..0000000 --- a/apps/vault-rush/store.md +++ /dev/null @@ -1,13 +0,0 @@ -Crack a steel safe using the rotating crown and tactile vibration feedback on your wrist. - -- **Classic:** Endless streak of safes with 3 lives. Alternate turn directions for each pin, feel the lock click when you hit the slot, and crack open the vault door to claim the gold inside. -- **Heist (10s–60s):** Pick your time limit (`10s`, `20s`, `30s`, `40s`, `50s`, or `60s`), fly into the bank, and crack the safe before the police sirens sound in the final 5 seconds. Win to see the door swing open with gold; run out of time and land behind bars. -- **Blitz (60s):** Endless speed arcade. Spin either way to crack as many single-pin locks as possible before time runs out. - -Best scores and fastest Heist clear times are saved on the watch and shown on the optional widget card left of the watch face. - -Press the crown or swipe right to exit. - -## Requirements - -The [patched firmware](/firmware) and the [App Loader](/firmware). Open it from the **Apps** row at the end of the watch's app list (list style, not waterfall). diff --git a/apps/vault-rush/store.toml b/apps/vault-rush/store.toml deleted file mode 100644 index 6480a05..0000000 --- a/apps/vault-rush/store.toml +++ /dev/null @@ -1,5 +0,0 @@ -name = "Vault Rush" -summary = "Crack a steel safe with the crown in Classic, Heist (timed win), and Blitz modes" -version = "0.1.0" -author = "mead0wss" -screenshots = ["shots/menu.png", "shots/heist.png", "shots/playing.png", "shots/siren.png", "shots/over.png"] diff --git a/apps/vault-rush/tools/gen_font.py b/apps/vault-rush/tools/gen_font.py deleted file mode 100644 index 9fe2d65..0000000 --- a/apps/vault-rush/tools/gen_font.py +++ /dev/null @@ -1,189 +0,0 @@ -#!/usr/bin/env python3 -"""Generates src/font.rs: packed 4-bit-per-pixel (16-level AA) fonts from Barlow SemiBold (SIL OFL 1.1).""" -import os -from pathlib import Path -import sys -from PIL import Image, ImageDraw, ImageFont - -DEFAULT_FONT = Path(__file__).with_name("Barlow-SemiBold.ttf") - -CHARS_UI = " 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ.:!+-/<>#%" -CHARS_LG = " 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ!" - -SPECS = [ - ("FONT_SM", 16, CHARS_UI, False), - ("FONT_MD", 22, CHARS_UI, True), - ("FONT_LG", 44, CHARS_LG, True), -] - - -def render_font(font_path: Path, name: str, size: int, chars: str, tabular_digits: bool): - f = ImageFont.truetype(str(font_path), size) - - raw_glyphs = {} - max_digit_adv = 0 - min_top = 999 - - for ch in chars: - adv = max(1, int(round(f.getlength(ch)))) - if ch.isdigit(): - max_digit_adv = max(max_digit_adv, adv) - if ch == " ": - raw_glyphs[ch] = (0, 0, 0, 0, adv, []) - continue - cw, ch_h = size * 2 + 16, size * 2 + 16 - ox, oy = 8, 8 - img = Image.new("L", (cw, ch_h), 0) - d = ImageDraw.Draw(img) - d.text((ox, oy), ch, font=f, fill=255) - bbox = img.getbbox() - if not bbox: - raw_glyphs[ch] = (0, 0, 0, 0, adv, []) - continue - x0, y0, x1, y1 = bbox - min_top = min(min_top, y0 - oy) - w, h = x1 - x0, y1 - y0 - px = img.crop(bbox).tobytes() - raw_glyphs[ch] = (x0 - ox, y0 - oy, w, h, adv, px) - - glyph_entries = [] - blob = bytearray() - - for ch in chars: - xo, yo, w, h, adv, px = raw_glyphs[ch] - if tabular_digits and ch.isdigit(): - dx = (max_digit_adv - adv) // 2 - xo += dx - adv = max_digit_adv - yo_norm = yo - min_top if w > 0 else 0 - offset = len(blob) - # Pack 2 pixels per byte (4 bits per pixel = 16 coverage levels, high nibble first). - i = 0 - n = len(px) - while i < n: - hi = (px[i] * 15 + 127) // 255 - lo = (px[i + 1] * 15 + 127) // 255 if i + 1 < n else 0 - blob.append((hi << 4) | lo) - i += 2 - glyph_entries.append((ch, xo, yo_norm, w, h, adv, offset)) - - return { - "name": name, - "chars": chars, - "entries": glyph_entries, - "blob": bytes(blob), - } - - -def main(): - font_path = Path(sys.argv[1] if len(sys.argv) > 1 else os.environ.get("BARLOW_FONT", DEFAULT_FONT)) - if not font_path.is_file(): - raise SystemExit(f"Font not found: {font_path} (pass path to Barlow-SemiBold.ttf, SIL OFL 1.1)") - fonts = [render_font(font_path, *s) for s in SPECS] - out_path = Path(__file__).resolve().parent.parent / "src" / "font.rs" - lines = [ - "//! Smooth 4-bpp (16-level) anti-aliased fonts generated by `tools/gen_font.py`.", - "//!", - "//! Glyphs rasterized from Barlow SemiBold (Copyright 2017 The Barlow Project Authors,", - "//! https://github.com/jpt/barlow), licensed under the SIL Open Font License 1.1", - "//! (https://scripts.sil.org/OFL).", - "", - "use cmf_wp2_ui::draw::Run;", - "use cmf_wp2_ui::{ONE, Rgb, Surface};", - "", - "#[derive(Clone, Copy)]", - "pub struct Glyph {", - " pub ch: u8,", - " pub x_off: i8,", - " pub y_off: i8,", - " pub w: u8,", - " pub h: u8,", - " pub adv: u8,", - " pub offset: u16,", - "}", - "", - "pub struct Font {", - " pub glyphs: &'static [Glyph],", - " pub data: &'static [u8],", - "}", - "", - "impl Font {", - " fn glyph(&self, b: u8) -> Option<&Glyph> {", - " self.glyphs.iter().find(|g| g.ch == b)", - " }", - "", - " pub fn width(&self, text: &str) -> i32 {", - " let mut w = 0i32;", - " for b in text.bytes() {", - " w += self.glyph(b).map_or(0, |g| g.adv as i32);", - " }", - " w", - " }", - "", - " pub fn draw(&self, s: &mut impl Surface, x: i32, y: i32, text: &str, fg: Rgb, bg: Rgb) {", - " let mut pal = [0u16; 16];", - " pal[0] = bg.rgb565();", - " pal[15] = fg.rgb565();", - " for i in 1..15 {", - " pal[i] = bg.mix(fg, (i as i32) * ONE / 15).rgb565();", - " }", - " let mut cx = x;", - " for b in text.bytes() {", - " let Some(g) = self.glyph(b) else { continue };", - " let gw = g.w as usize;", - " let gh = g.h as usize;", - " if gw > 0 && gh > 0 {", - " let gx = cx + g.x_off as i32;", - " let gy = y + g.y_off as i32;", - " let start = g.offset as usize;", - " for row in 0..gh {", - " let mut run = Run::new(s, gy + row as i32, false);", - " for col in 0..gw {", - " let idx = row * gw + col;", - " let byte = self.data[start + (idx >> 1)];", - " let lvl = if (idx & 1) == 0 { byte >> 4 } else { byte & 0x0F } as usize;", - " if lvl != 0 {", - " run.put(gx + col as i32, 1, pal[lvl]);", - " }", - " }", - " }", - " }", - " cx += g.adv as i32;", - " }", - " }", - "", - " pub fn centre(&self, s: &mut impl Surface, cx: i32, y: i32, text: &str, fg: Rgb, bg: Rgb) {", - " let w = self.width(text);", - " self.draw(s, cx - w / 2, y, text, fg, bg);", - " }", - "}", - "", - ] - - total_bytes = 0 - for f in fonts: - name = f["name"] - data_name = f"{name}_DATA" - glyphs_name = f"{name}_GLYPHS" - total_bytes += len(f["blob"]) - lines.append(f"static {data_name}: [u8; {len(f['blob'])}] = [") - for i in range(0, len(f["blob"]), 16): - chunk = ", ".join(f"0x{b:02X}" for b in f["blob"][i:i + 16]) - lines.append(f" {chunk},") - lines.append("];\n") - lines.append(f"static {glyphs_name}: [Glyph; {len(f['entries'])}] = [") - for ch, xo, yo, w, h, adv, off in f["entries"]: - lines.append( - f" Glyph {{ ch: {ord(ch)}, x_off: {xo}, y_off: {yo}, w: {w}, h: {h}, adv: {adv}, offset: {off} }}," - ) - lines.append("];\n") - lines.append( - f"pub static {name}: Font = Font {{ glyphs: &{glyphs_name}, data: &{data_name} }};\n" - ) - - out_path.write_text("\n".join(lines), encoding="utf-8") - print(f"Wrote {out_path} (total font data: {total_bytes} bytes)") - - -if __name__ == "__main__": - main() diff --git a/apps/vela-nav/Cargo.toml b/apps/vela-nav/Cargo.toml deleted file mode 100644 index cf366ec..0000000 --- a/apps/vela-nav/Cargo.toml +++ /dev/null @@ -1,13 +0,0 @@ -[package] -name = "vela-nav" -edition.workspace = true -license.workspace = true -version.workspace = true - -[dependencies] -cmf-wp2-app.workspace = true -cmf-wp2-ui.workspace = true - -[[bin]] -name = "vela-nav" -bench = false diff --git a/apps/vela-nav/fonts/OFL.txt b/apps/vela-nav/fonts/OFL.txt deleted file mode 100644 index c9af0d2..0000000 --- a/apps/vela-nav/fonts/OFL.txt +++ /dev/null @@ -1,93 +0,0 @@ -Copyright 2022 The Noto Project Authors (https://github.com/notofonts/latin-greek-cyrillic) - -This Font Software is licensed under the SIL Open Font License, Version 1.1. -This license is copied below, and is also available with a FAQ at: -https://openfontlicense.org - - ------------------------------------------------------------ -SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 ------------------------------------------------------------ - -PREAMBLE -The goals of the Open Font License (OFL) are to stimulate worldwide -development of collaborative font projects, to support the font creation -efforts of academic and linguistic communities, and to provide a free and -open framework in which fonts may be shared and improved in partnership -with others. - -The OFL allows the licensed fonts to be used, studied, modified and -redistributed freely as long as they are not sold by themselves. The -fonts, including any derivative works, can be bundled, embedded, -redistributed and/or sold with any software provided that any reserved -names are not used by derivative works. The fonts and derivatives, -however, cannot be released under any other type of license. The -requirement for fonts to remain under this license does not apply -to any document created using the fonts or their derivatives. - -DEFINITIONS -"Font Software" refers to the set of files released by the Copyright -Holder(s) under this license and clearly marked as such. This may -include source files, build scripts and documentation. - -"Reserved Font Name" refers to any names specified as such after the -copyright statement(s). - -"Original Version" refers to the collection of Font Software components as -distributed by the Copyright Holder(s). - -"Modified Version" refers to any derivative made by adding to, deleting, -or substituting -- in part or in whole -- any of the components of the -Original Version, by changing formats or by porting the Font Software to a -new environment. - -"Author" refers to any designer, engineer, programmer, technical -writer or other person who contributed to the Font Software. - -PERMISSION & CONDITIONS -Permission is hereby granted, free of charge, to any person obtaining -a copy of the Font Software, to use, study, copy, merge, embed, modify, -redistribute, and sell modified and unmodified copies of the Font -Software, subject to the following conditions: - -1) Neither the Font Software nor any of its individual components, -in Original or Modified Versions, may be sold by itself. - -2) Original or Modified Versions of the Font Software may be bundled, -redistributed and/or sold with any software, provided that each copy -contains the above copyright notice and this license. These can be -included either as stand-alone text files, human-readable headers or -in the appropriate machine-readable metadata fields within text or -binary files as long as those fields can be easily viewed by the user. - -3) No Modified Version of the Font Software may use the Reserved Font -Name(s) unless explicit written permission is granted by the corresponding -Copyright Holder. This restriction only applies to the primary font name as -presented to the users. - -4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font -Software shall not be used to promote, endorse or advertise any -Modified Version, except to acknowledge the contribution(s) of the -Copyright Holder(s) and the Author(s) or with their explicit written -permission. - -5) The Font Software, modified or unmodified, in part or in whole, -must be distributed entirely under this license, and must not be -distributed under any other license. The requirement for fonts to -remain under this license does not apply to any document created -using the Font Software. - -TERMINATION -This license becomes null and void if any of the above conditions are -not met. - -DISCLAIMER -THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT -OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE -COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL -DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM -OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/apps/vela-nav/fonts/mkfont.py b/apps/vela-nav/fonts/mkfont.py deleted file mode 100644 index f2f0334..0000000 --- a/apps/vela-nav/fonts/mkfont.py +++ /dev/null @@ -1,105 +0,0 @@ -"""Renders Noto Sans into the antialiased glyph tables in ../src/fonts.rs. - - uv run --with pillow python fonts/mkfont.py [dir with NotoSans-*.ttf] - -The output is committed, so a build needs neither Python nor the font files. Noto Sans is under the SIL Open -Font License 1.1 (OFL.txt next to this script); the tables are a converted copy of it. - -Coverage is 4 bits a pixel. The large sizes are stored as runs, a byte each (coverage << 4 | length - 1, a run -never crossing a row): their rows are long stretches of empty and solid, so that is a third to two thirds of the -packed size, and lossless. The small size has busy edges and stays packed, two pixels a byte. -""" -import sys -from pathlib import Path -from PIL import Image, ImageDraw, ImageFont - -SRC = Path(sys.argv[1] if len(sys.argv) > 1 else "/usr/share/fonts/google-noto") -OUT = Path(__file__).resolve().parent.parent / "src" / "fonts.rs" -ASCII = "".join(chr(c) for c in range(32, 127)) - -RLE = {"XL", "L"} - -# (Rust name, file, px, characters) -FONTS = [ - ("XL", "NotoSans-Bold.ttf", 84, "0123456789. "), - # units, the clock, the limit, titles, the Home and Work buttons - ("L", "NotoSans-SemiBold.ttf", 40, "0123456789:. abcdefghijklmnopqrstuvwxyzAVNROHSW…"), - ("S", "NotoSans-Medium.ttf", 26, ASCII + "…·"), -] - - -def runs(px4, w): - out = bytearray() - for r in range(0, len(px4), w): - row, i = px4[r:r + w], 0 - while i < len(row): - j = i - while j < len(row) and row[j] == row[i] and j - i < 16: - j += 1 - out.append(row[i] << 4 | (j - i - 1)) - i = j - return bytes(out) - - -def glyphs(file, px, chars, rle): - font = ImageFont.truetype(str(SRC / file), px) - ascent, descent = font.getmetrics() - rows, data = [], bytearray() - for ch in chars: - adv = round(font.getlength(ch)) - # draw on a roomy canvas, then crop to the ink (Pillow's bbox includes the side bearings) - big = Image.new("L", (px * 3, px * 3), 0) - ImageDraw.Draw(big).text((px, px * 2), ch, font=font, fill=255, anchor="ls") - q = big.point(lambda v: (v * 15 + 127) // 255 * 17) # 4-bit, so a faint edge pixel counts as nothing - box = q.getbbox() - x0, y0, w, h, off = 0, 0, 0, 0, len(data) - if box: - x0, y0 = box[0] - px, box[1] - px * 2 - w, h = box[2] - box[0], box[3] - box[1] - px4 = [v // 17 for v in q.crop(box).get_flattened_data()] - if rle: - data += runs(px4, w) - else: - if len(px4) % 2: - px4.append(0) - data += bytes(px4[i] << 4 | px4[i + 1] for i in range(0, len(px4), 2)) - rows.append((ch, adv, x0, y0, w, h, off)) - cap = font.getbbox("H", anchor="ls")[1] # its top edge, so ink-exact - return ascent, descent, -cap, rows, data - - -def rust_char(c): - return {"'": "\\'", "\\": "\\\\"}.get(c, c) - - -out = [ - "//! Generated by `fonts/mkfont.py` from Noto Sans (SIL Open Font License 1.1, `fonts/OFL.txt`). Do not edit.", - "", - "use crate::font::{Font, Glyph};", - "", -] -total = 0 -for name, file, px, chars in FONTS: - rle = name in RLE - ascent, descent, cap, rows, data = glyphs(file, px, chars, rle) - total += len(data) + len(rows) * 12 - print(name, len(data)) - kind = "runs of 4-bit coverage" if rle else "4-bit coverage" - out.append(f"/// {file[:-4]} at {px} px: {len(rows)} glyphs, {len(data)} B of {kind}.") - out.append(f"pub static {name}: Font = Font {{") - out.append(f" ascent: {ascent},") - out.append(f" descent: {descent},") - out.append(f" cap: {cap},") - out.append(f" rle: {str(rle).lower()},") - out.append(" glyphs: &[") - for ch, adv, x, y, w, h, off in rows: - out.append(f" Glyph {{ c: '{rust_char(ch)}', adv: {adv}, x: {x}, y: {y}, w: {w}, h: {h}, off: {off} }},") - out.append(" ],") - out.append(" bits: &[") - for i in range(0, len(data), 24): - out.append(" " + " ".join(f"{b},"for b in data[i:i + 24])) - out.append(" ],") - out.append("};") - out.append("") -OUT.write_text("\n".join(out)) -print(f"{OUT}: {total} B") diff --git a/apps/vela-nav/icon.svg b/apps/vela-nav/icon.svg deleted file mode 100644 index 8a9b6be..0000000 --- a/apps/vela-nav/icon.svg +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/apps/vela-nav/shots/driving.png b/apps/vela-nav/shots/driving.png deleted file mode 100644 index 74ac5c7..0000000 Binary files a/apps/vela-nav/shots/driving.png and /dev/null differ diff --git a/apps/vela-nav/shots/home.png b/apps/vela-nav/shots/home.png deleted file mode 100644 index d184592..0000000 Binary files a/apps/vela-nav/shots/home.png and /dev/null differ diff --git a/apps/vela-nav/shots/map.png b/apps/vela-nav/shots/map.png deleted file mode 100644 index 72e1282..0000000 Binary files a/apps/vela-nav/shots/map.png and /dev/null differ diff --git a/apps/vela-nav/shots/turn.png b/apps/vela-nav/shots/turn.png deleted file mode 100644 index b058b55..0000000 Binary files a/apps/vela-nav/shots/turn.png and /dev/null differ diff --git a/apps/vela-nav/src/font.rs b/apps/vela-nav/src/font.rs deleted file mode 100644 index 91208f6..0000000 --- a/apps/vela-nav/src/font.rs +++ /dev/null @@ -1,297 +0,0 @@ -//! Antialiased text in the app's own fonts (`fonts.rs`, Noto Sans), drawn as runs of equal coverage blended -//! over a background colour the caller names, as every `cmf-wp2-ui` shape is. - -use cmf_wp2_ui::color::blend565; -use cmf_wp2_ui::{ONE, Surface}; - -pub struct Glyph { - pub c: char, - pub adv: u8, - /// Ink box from the pen position on the baseline. - pub x: i8, - pub y: i8, - pub w: u8, - pub h: u8, - /// Byte offset of the glyph's coverage in `Font::bits`. - pub off: u16, -} - -pub struct Font { - pub ascent: i32, - pub descent: i32, - /// Height of a capital above the baseline. - pub cap: i32, - /// `bits` holds runs, a byte each (coverage << 4 | length - 1, within a row); else 4-bit coverage, two pixels a - /// byte, rows packed. - pub rle: bool, - pub glyphs: &'static [Glyph], - pub bits: &'static [u8], -} - -impl Font { - fn glyph(&self, c: char) -> Option<&Glyph> { - self.glyphs.iter().find(|g| g.c == c) - } - - /// Every character of `t` is in the font. - pub fn covers(&self, t: &str) -> bool { - t.chars().all(|c| self.glyph(c).is_some()) - } - - pub fn width(&self, t: &str) -> i32 { - t.chars().map(|c| self.glyph(c).map_or(0, |g| g.adv as i32)).sum() - } - - /// Calls `f(row, start, len, coverage)` for each run of equal coverage in `g`, row by row, left to right, - /// whichever way the font stores it (runs that touch with the same coverage are merged). - fn runs(&self, g: &Glyph, mut f: impl FnMut(usize, usize, usize, u8)) { - let w = g.w as usize; - let mut at = g.off as usize; - for row in 0..g.h as usize { - let mut col = 0; - let mut open: Option<(usize, usize, u8)> = None; - while col < w { - let (a, n) = if self.rle { - let b = self.bits[at]; - at += 1; - (b >> 4, (b & 15) as usize + 1) - } else { - let i = row * w + col; - let b = self.bits[g.off as usize + i / 2]; - (if i.is_multiple_of(2) { b >> 4 } else { b & 15 }, 1) - }; - let n = n.min(w - col); - open = match open { - Some((s, l, oa)) if oa == a => Some((s, l + n, a)), - Some((s, l, oa)) => { - f(row, s, l, oa); - Some((col, n, a)) - } - None => Some((col, n, a)), - }; - col += n; - } - if let Some((s, l, a)) = open { - f(row, s, l, a); - } - } - } - - /// Draws `t` with its baseline at `y`, from `x`; returns the pen position after it. Characters the font - /// lacks are skipped. - pub fn draw(&self, s: &mut impl Surface, x: i32, y: i32, t: &str, fg: u16, bg: u16) -> i32 { - let mut shade = [0u16; 16]; - for (a, c) in shade.iter_mut().enumerate() { - *c = blend565(bg, fg, a as i32 * ONE / 15); - } - let mut pen = x; - for ch in t.chars() { - let Some(g) = self.glyph(ch) else { continue }; - let (gx, gy) = (pen + g.x as i32, y + g.y as i32); - self.runs(g, |row, start, len, a| { - if a != 0 { - s.rect(gx + start as i32, gy + row as i32, len as i32, 1, shade[a as usize]); - } - }); - pen += g.adv as i32; - } - pen - } - - /// A black outline `r` px (≤ 4) around the ink of `t`, for text drawn over the map: draw it, then the text over - /// it with a black background. Each glyph's ink is a bit mask a row, widened with shifts, so it is cheap. - pub fn halo(&self, s: &mut impl Surface, x: i32, y: i32, t: &str, r: i32) { - const ROWS: usize = 80; - let r = r.clamp(0, 4); - let mut pen = x; - for ch in t.chars() { - let Some(g) = self.glyph(ch) else { continue }; - let (w, h) = (g.w as i32, g.h as i32); - let (gx, gy) = (pen + g.x as i32 - r, y + g.y as i32 - r); - pen += g.adv as i32; - if w == 0 || w + 2 * r > 64 || (h + 2 * r) as usize > ROWS { - continue; - } - let mut ink = [0u64; ROWS]; - self.runs(g, |row, start, len, a| { - if a >= 4 { - let run = if len >= 64 { u64::MAX } else { (1u64 << len) - 1 }; - ink[row + r as usize] |= run << (start as i32 + r); - } - }); - let n = (h + 2 * r) as usize; - for oy in 0..n { - let mut out = 0u64; - for dy in -r..=r { - let sy = oy as i32 + dy; - if sy < 0 || sy >= n as i32 || ink[sy as usize] == 0 { - continue; - } - let m = ink[sy as usize]; - // a round pen: the reach across shrinks with the distance down - let reach = [[0, 0, 0, 0, 0], [1, 0, 0, 0, 0], [2, 2, 1, 0, 0], [3, 3, 2, 1, 0], [4, 4, 3, 3, 1]] - [r as usize][dy.unsigned_abs() as usize]; - let mut d = m; - for i in 1..=reach { - d |= m << i | m >> i; - } - out |= d; - } - while out != 0 { - let start = out.trailing_zeros(); - let len = (!(out >> start)).trailing_zeros().min(64 - start); - s.rect(gx + start as i32, gy + oy as i32, len as i32, 1, 0); - let mask = if len >= 64 { u64::MAX } else { ((1u64 << len) - 1) << start }; - out &= !mask; - } - } - } - } - - /// The longest start of `t` that fits `max` px, and whether it was cut (then an ellipsis follows it). - pub fn fit<'a>(&self, t: &'a str, max: i32) -> (&'a str, bool) { - if self.width(t) <= max { - return (t, false); - } - let room = max - self.width("…"); - let mut w = 0; - for (i, c) in t.char_indices() { - w += self.glyph(c).map_or(0, |g| g.adv as i32); - if w > room { - return (t[..i].trim_end(), true); - } - } - (t, false) - } - - /// `t` centred on `cx`, cut with an ellipsis to `max` px. - #[allow(clippy::too_many_arguments)] - pub fn centre(&self, s: &mut impl Surface, cx: i32, y: i32, t: &str, max: i32, fg: u16, bg: u16) { - let (t, cut) = self.fit(t, max); - let w = self.width(t) + if cut { self.width("…") } else { 0 }; - let end = self.draw(s, cx - w / 2, y, t, fg, bg); - if cut { - self.draw(s, end, y, "…", fg, bg); - } - } -} - -/// A filled polygon (any shape, even-odd), antialiased: exact horizontal coverage on 4 sub-rows a pixel. -/// `paint(x)` picks the colour per column, so a shape can have two flat faces. -pub fn poly(s: &mut impl Surface, pts: &[(i32, i32)], bg: u16, paint: impl Fn(i32) -> u16) { - const SUB: i32 = 4; // sub-rows a pixel - const FX: i32 = 16; // sub-pixel units a pixel, across - let y0 = pts.iter().map(|p| p.1).min().unwrap_or(0); - let y1 = pts.iter().map(|p| p.1).max().unwrap_or(0); - let x0 = pts.iter().map(|p| p.0).min().unwrap_or(0); - let x1 = pts.iter().map(|p| p.0).max().unwrap_or(0); - let wide = (x1 - x0 + 2) as usize; - if wide > 128 || pts.len() > 8 { - return; // icons and the car only - } - for y in y0..y1 { - let mut cov = [0i32; 128]; - for k in 0..SUB { - // sample at the sub-row's middle, in 1/(2*SUB) px - let sy2 = y * 2 * SUB + 2 * k + 1; - let mut xs = [0i32; 8]; - let mut n = 0; - for i in 0..pts.len() { - let (a, b) = (pts[i], pts[(i + 1) % pts.len()]); - let (ay, by) = (a.1 * 2 * SUB, b.1 * 2 * SUB); - if (ay <= sy2) != (by <= sy2) { - xs[n] = (a.0 * FX) + (b.0 - a.0) * FX * (sy2 - ay) / (by - ay); - n += 1; - } - } - xs[..n].sort_unstable(); - for span in xs[..n].chunks(2) { - let [l, r] = span else { continue }; - for px in (l.div_euclid(FX))..=(r.div_euclid(FX)) { - let lo = (px * FX).max(*l); - let hi = ((px + 1) * FX).min(*r); - let i = px - x0 + 1; - if hi > lo && i >= 0 && (i as usize) < wide { - cov[i as usize] += hi - lo; - } - } - } - } - // runs of equal colour - let full = FX * SUB; - let mut i = 0; - while i < wide { - let c = cov[i]; - let x = x0 - 1 + i as i32; - let col = if c == 0 { None } else { Some(blend565(bg, paint(x), c * ONE / full)) }; - let start = i; - while i < wide && cov[i] == c && paint(x0 - 1 + i as i32) == paint(x) { - i += 1; - } - if let Some(col) = col { - s.rect(x, y, (i - start) as i32, 1, col); - } - } - } -} - -#[cfg(test)] -mod tests { - use super::*; - use crate::fonts::{L, S, XL}; - use cmf_wp2_ui::{Fb, SIZE}; - use std::vec; - - #[test] - fn fonts_have_what_the_screens_need() { - assert!(XL.covers("0123456789.")); - assert!(L.covers("12:05 pm km mi ft Vela Nav Arrived Off route")); - assert!(S.covers("Bannerghatta Main Road · 4.7 km · 12 min Rerouting…")); - assert!(!S.covers("ಹೊಸೂರು ರಸ್ತೆ")); - } - - #[test] - fn every_glyph_decodes_to_whole_rows() { - for f in [&XL, &L, &S] { - for g in f.glyphs { - let mut cols = std::vec![0usize; g.h as usize]; - f.runs(g, |row, start, len, _| { - assert_eq!(start, cols[row], "{:?} row {row}", g.c); - cols[row] += len; - }); - assert!(cols.iter().all(|&c| c == g.w as usize), "{:?}", g.c); - } - } - // the big sizes are stored as runs, the small one packed - assert!(XL.rle && L.rle && !S.rle); - } - - #[test] - fn text_is_antialiased_and_fits() { - let mut px = vec![0u16; (SIZE * SIZE) as usize]; - let mut fb = Fb::new(&mut px); - let end = XL.draw(&mut fb, 100, 200, "300", 0xFFFF, 0); - assert_eq!(end, 100 + XL.width("300")); - let mut shades = std::collections::BTreeSet::new(); - for y in 100..220 { - for x in 90..end + 10 { - shades.insert(fb.at(x, y)); - } - } - assert!(shades.len() > 8, "{}", shades.len()); - let (t, cut) = S.fit("Bannerghatta Main Road", 120); - assert!(cut && S.width(t) + S.width("…") <= 120, "{t}"); - assert_eq!(S.fit("Road", 120), ("Road", false)); - } - - #[test] - fn a_polygon_has_soft_edges_and_a_solid_middle() { - let mut px = vec![0u16; (SIZE * SIZE) as usize]; - let mut fb = Fb::new(&mut px); - poly(&mut fb, &[(100, 100), (140, 160), (60, 160)], 0, |_| 0xFFFF); - assert_eq!(fb.at(100, 150), 0xFFFF); - assert_eq!(fb.at(100, 90), 0); - let edge = fb.at(79, 130); // the left edge crosses it at x 79.7 - assert!(edge != 0 && edge != 0xFFFF, "{edge:x}"); - } -} diff --git a/apps/vela-nav/src/fonts.rs b/apps/vela-nav/src/fonts.rs deleted file mode 100644 index 2920f2d..0000000 --- a/apps/vela-nav/src/fonts.rs +++ /dev/null @@ -1,1157 +0,0 @@ -//! Generated by `fonts/mkfont.py` from Noto Sans (SIL Open Font License 1.1, `fonts/OFL.txt`). Do not edit. - -use crate::font::{Font, Glyph}; - -/// NotoSans-Bold at 84 px: 12 glyphs, 4656 B of runs of 4-bit coverage. -pub static XL: Font = Font { - ascent: 90, - descent: 25, - cap: 60, - rle: true, - glyphs: &[ - Glyph { c: '0', adv: 48, x: 3, y: -61, w: 42, h: 62, off: 0 }, - Glyph { c: '1', adv: 48, x: 5, y: -60, w: 30, h: 60, off: 501 }, - Glyph { c: '2', adv: 48, x: 3, y: -61, w: 43, h: 61, off: 798 }, - Glyph { c: '3', adv: 48, x: 3, y: -61, w: 42, h: 62, off: 1238 }, - Glyph { c: '4', adv: 48, x: 1, y: -60, w: 46, h: 60, off: 1735 }, - Glyph { c: '5', adv: 48, x: 4, y: -60, w: 41, h: 61, off: 2174 }, - Glyph { c: '6', adv: 48, x: 2, y: -61, w: 44, h: 62, off: 2619 }, - Glyph { c: '7', adv: 48, x: 2, y: -60, w: 44, h: 60, off: 3161 }, - Glyph { c: '8', adv: 48, x: 2, y: -61, w: 43, h: 62, off: 3516 }, - Glyph { c: '9', adv: 48, x: 2, y: -61, w: 43, h: 62, off: 4062 }, - Glyph { c: '.', adv: 24, x: 4, y: -13, w: 15, h: 14, off: 4585 }, - Glyph { c: ' ', adv: 22, x: 0, y: 0, w: 0, h: 0, off: 4656 }, - ], - bits: &[ - 13, 32, 96, 144, 192, 208, 224, 241, 224, 208, 176, 128, 80, 16, 13, 10, 16, 112, 208, 253, 176, 64, 11, 9, - 112, 224, 255, 241, 192, 48, 9, 7, 48, 192, 255, 245, 128, 8, 6, 48, 224, 255, 247, 176, 16, 6, 5, 48, - 224, 255, 249, 176, 6, 4, 16, 224, 255, 251, 144, 5, 4, 176, 255, 253, 80, 4, 3, 96, 255, 254, 224, 16, - 3, 2, 16, 224, 253, 208, 177, 208, 253, 128, 3, 2, 112, 252, 160, 32, 3, 48, 176, 252, 32, 2, 2, 224, - 251, 112, 7, 144, 251, 128, 2, 1, 64, 251, 160, 9, 192, 250, 224, 16, 1, 1, 160, 250, 224, 16, 9, 48, - 251, 80, 1, 1, 224, 250, 144, 11, 176, 250, 160, 1, 0, 64, 251, 64, 11, 96, 251, 1, 0, 112, 250, 224, - 12, 16, 251, 64, 0, 0, 176, 250, 176, 13, 208, 250, 128, 0, 0, 224, 250, 128, 13, 144, 250, 176, 0, 16, - 251, 96, 13, 112, 250, 224, 0, 64, 251, 48, 13, 64, 251, 32, 96, 251, 16, 13, 32, 251, 64, 128, 251, 14, - 16, 251, 96, 144, 250, 224, 15, 224, 250, 128, 160, 250, 192, 15, 208, 250, 160, 192, 250, 192, 15, 192, 250, 176, - 208, 250, 176, 15, 176, 250, 192, 208, 250, 160, 15, 176, 250, 208, 224, 250, 160, 15, 160, 250, 208, 224, 250, 160, - 15, 160, 250, 224, 224, 250, 144, 15, 160, 250, 224, 224, 250, 144, 15, 160, 250, 224, 224, 250, 160, 15, 160, 250, - 208, 224, 250, 160, 15, 160, 250, 208, 208, 250, 160, 15, 176, 250, 208, 192, 250, 176, 15, 176, 250, 192, 176, 250, - 176, 15, 192, 250, 176, 160, 250, 192, 15, 208, 250, 160, 144, 250, 208, 15, 224, 250, 128, 112, 251, 14, 16, 251, - 112, 80, 251, 16, 13, 32, 251, 80, 48, 251, 48, 13, 64, 251, 48, 0, 251, 80, 13, 96, 251, 0, 0, 192, - 250, 128, 13, 144, 250, 208, 0, 0, 144, 250, 176, 13, 192, 250, 160, 0, 0, 80, 250, 224, 12, 16, 251, 96, - 0, 0, 16, 251, 64, 11, 80, 251, 32, 0, 1, 176, 250, 144, 11, 176, 250, 224, 1, 1, 96, 250, 224, 16, - 9, 48, 251, 144, 1, 1, 16, 251, 144, 9, 176, 251, 48, 1, 2, 144, 251, 112, 7, 144, 251, 208, 2, 2, - 48, 252, 160, 32, 3, 48, 176, 252, 96, 2, 3, 160, 253, 208, 177, 208, 253, 208, 3, 3, 32, 255, 255, 80, - 3, 4, 112, 255, 253, 160, 4, 5, 176, 255, 251, 208, 16, 4, 5, 16, 192, 255, 249, 224, 48, 5, 6, 16, - 192, 255, 247, 224, 48, 6, 7, 16, 160, 255, 245, 192, 32, 7, 9, 80, 208, 255, 241, 224, 112, 9, 11, 80, - 192, 253, 192, 96, 16, 10, 13, 16, 96, 144, 176, 208, 224, 241, 224, 208, 176, 144, 96, 32, 13, 15, 1, 80, - 249, 160, 15, 0, 128, 250, 160, 14, 16, 176, 251, 160, 13, 32, 208, 252, 160, 12, 64, 224, 253, 160, 11, 112, - 255, 160, 10, 144, 255, 240, 160, 8, 32, 192, 255, 241, 160, 7, 48, 208, 255, 242, 160, 6, 80, 255, 244, 160, - 5, 128, 255, 245, 160, 3, 16, 176, 255, 246, 160, 2, 32, 208, 255, 247, 160, 1, 64, 224, 255, 248, 160, 0, - 112, 253, 161, 250, 160, 144, 253, 160, 0, 176, 250, 160, 112, 252, 128, 1, 176, 250, 160, 0, 160, 250, 112, 2, - 192, 250, 160, 0, 16, 192, 247, 224, 64, 3, 192, 250, 160, 1, 32, 224, 245, 192, 32, 4, 208, 250, 160, 2, - 64, 244, 160, 16, 5, 208, 250, 160, 3, 112, 242, 112, 7, 224, 250, 160, 4, 144, 224, 64, 8, 224, 250, 160, - 5, 32, 9, 224, 250, 160, 15, 0, 251, 160, 15, 0, 251, 160, 15, 0, 251, 160, 15, 0, 251, 160, 15, 0, - 251, 160, 15, 0, 251, 160, 15, 0, 251, 160, 15, 0, 251, 160, 15, 0, 251, 160, 15, 0, 251, 160, 15, 0, - 251, 160, 15, 0, 251, 160, 15, 0, 251, 160, 15, 0, 251, 160, 15, 0, 251, 160, 15, 0, 251, 160, 15, 0, - 251, 160, 15, 0, 251, 160, 15, 0, 251, 160, 15, 0, 251, 160, 15, 0, 251, 160, 15, 0, 251, 160, 15, 0, - 251, 160, 15, 0, 251, 160, 15, 0, 251, 160, 15, 0, 251, 160, 15, 0, 251, 160, 15, 0, 251, 160, 15, 0, - 251, 160, 15, 0, 251, 160, 15, 0, 251, 160, 15, 0, 251, 160, 15, 0, 251, 160, 15, 0, 251, 160, 15, 0, - 251, 160, 15, 0, 251, 160, 12, 16, 64, 112, 160, 192, 208, 225, 240, 225, 208, 160, 128, 80, 16, 13, 10, 80, - 176, 255, 176, 80, 11, 7, 32, 128, 224, 255, 243, 208, 96, 9, 5, 16, 128, 255, 248, 192, 32, 7, 4, 80, - 208, 255, 250, 224, 64, 6, 3, 144, 255, 254, 64, 5, 1, 32, 192, 255, 255, 240, 48, 4, 0, 48, 224, 255, - 255, 241, 208, 16, 3, 80, 255, 255, 244, 128, 3, 80, 255, 255, 244, 224, 32, 2, 0, 112, 255, 255, 244, 128, - 2, 1, 160, 251, 224, 160, 96, 48, 16, 0, 16, 48, 96, 192, 253, 208, 2, 2, 192, 248, 208, 96, 9, 96, - 253, 32, 1, 2, 16, 208, 245, 224, 96, 12, 80, 252, 80, 1, 3, 48, 224, 243, 160, 16, 14, 176, 251, 112, - 1, 4, 80, 241, 224, 80, 15, 0, 80, 251, 128, 1, 5, 112, 192, 32, 15, 1, 32, 251, 144, 1, 15, 10, - 16, 251, 128, 1, 15, 11, 251, 112, 1, 15, 10, 16, 251, 80, 1, 15, 10, 64, 251, 48, 1, 15, 10, 112, - 251, 2, 15, 10, 192, 250, 176, 2, 15, 9, 48, 251, 96, 2, 15, 9, 176, 250, 224, 16, 2, 15, 8, 96, - 251, 144, 3, 15, 7, 32, 224, 251, 32, 3, 15, 7, 192, 251, 128, 4, 15, 6, 144, 251, 208, 16, 4, 15, - 5, 112, 252, 64, 5, 15, 4, 96, 252, 128, 6, 15, 3, 80, 252, 192, 7, 15, 2, 64, 252, 208, 16, 7, - 15, 1, 48, 224, 251, 224, 48, 8, 15, 0, 32, 224, 251, 224, 48, 9, 15, 32, 224, 252, 64, 10, 14, 32, - 208, 252, 64, 11, 13, 32, 208, 252, 80, 12, 12, 32, 208, 252, 80, 13, 11, 32, 208, 252, 64, 14, 10, 32, - 208, 251, 224, 64, 15, 9, 16, 208, 251, 224, 48, 15, 0, 8, 16, 208, 251, 224, 48, 15, 1, 7, 16, 208, - 251, 208, 32, 15, 2, 6, 16, 208, 251, 208, 32, 15, 3, 5, 16, 192, 251, 192, 16, 15, 4, 4, 16, 192, - 251, 192, 16, 15, 5, 3, 16, 192, 251, 176, 16, 15, 6, 2, 16, 192, 251, 176, 16, 15, 7, 1, 16, 192, - 251, 160, 15, 9, 0, 16, 192, 255, 255, 246, 64, 16, 192, 255, 255, 247, 64, 144, 255, 255, 248, 64, 160, 255, - 255, 248, 64, 160, 255, 255, 248, 64, 160, 255, 255, 248, 64, 160, 255, 255, 248, 64, 160, 255, 255, 248, 64, 160, - 255, 255, 248, 64, 160, 255, 255, 248, 64, 160, 255, 255, 248, 64, 10, 48, 96, 128, 160, 192, 208, 225, 240, 225, - 208, 192, 176, 128, 80, 48, 13, 6, 16, 96, 160, 224, 255, 240, 224, 144, 64, 10, 4, 48, 160, 224, 255, 246, - 208, 80, 8, 2, 64, 192, 255, 251, 192, 48, 6, 0, 48, 192, 255, 255, 112, 5, 96, 255, 255, 242, 128, 4, - 32, 224, 255, 255, 242, 96, 3, 0, 112, 255, 255, 242, 224, 32, 2, 1, 192, 255, 255, 242, 160, 2, 1, 32, - 224, 251, 208, 192, 177, 192, 224, 255, 240, 16, 1, 2, 112, 247, 208, 128, 48, 6, 32, 96, 208, 253, 96, 1, - 3, 192, 244, 192, 80, 11, 16, 144, 252, 160, 1, 3, 32, 224, 241, 208, 96, 15, 176, 251, 192, 1, 4, 112, - 240, 128, 16, 15, 0, 48, 251, 208, 1, 5, 48, 15, 3, 208, 250, 224, 1, 15, 10, 144, 250, 208, 1, 15, - 10, 128, 250, 176, 1, 15, 10, 128, 250, 160, 1, 15, 10, 160, 250, 96, 1, 15, 10, 208, 250, 32, 1, 15, - 9, 64, 250, 176, 2, 15, 9, 192, 250, 64, 2, 15, 8, 144, 250, 160, 3, 15, 6, 64, 192, 250, 208, 16, - 3, 15, 2, 16, 64, 128, 192, 251, 208, 32, 4, 8, 96, 181, 192, 208, 224, 254, 192, 16, 5, 8, 128, 255, - 246, 128, 7, 8, 128, 255, 244, 176, 48, 8, 8, 128, 255, 241, 224, 160, 48, 10, 8, 128, 255, 240, 112, 16, - 12, 8, 128, 255, 242, 208, 160, 96, 16, 8, 8, 128, 255, 246, 176, 48, 6, 8, 128, 255, 248, 176, 32, 4, - 8, 128, 255, 249, 224, 64, 3, 8, 128, 255, 251, 80, 2, 14, 17, 32, 48, 80, 112, 160, 208, 254, 224, 48, - 1, 15, 6, 48, 144, 253, 208, 1, 15, 8, 32, 192, 252, 96, 0, 15, 9, 16, 208, 251, 192, 0, 15, 10, - 80, 252, 32, 15, 11, 224, 251, 96, 15, 11, 176, 251, 128, 15, 11, 144, 251, 144, 15, 11, 144, 251, 160, 15, - 11, 176, 251, 144, 15, 11, 208, 251, 144, 15, 10, 32, 252, 112, 15, 10, 144, 252, 64, 112, 48, 15, 7, 48, - 253, 16, 192, 240, 176, 64, 15, 4, 32, 208, 252, 176, 0, 192, 242, 208, 144, 64, 15, 0, 80, 224, 253, 96, - 0, 192, 245, 224, 160, 112, 64, 16, 8, 48, 112, 208, 254, 208, 1, 192, 250, 224, 208, 179, 192, 208, 255, 242, - 96, 1, 192, 255, 255, 244, 176, 2, 192, 255, 255, 243, 224, 32, 2, 192, 255, 255, 242, 224, 48, 3, 192, 255, - 255, 241, 224, 48, 4, 192, 255, 255, 240, 176, 16, 5, 192, 255, 254, 208, 96, 7, 16, 80, 160, 255, 250, 208, - 112, 9, 2, 16, 80, 144, 192, 255, 243, 208, 144, 48, 11, 6, 16, 64, 96, 128, 160, 192, 209, 225, 241, 224, - 209, 176, 144, 112, 80, 16, 14, 15, 9, 144, 250, 96, 6, 15, 8, 64, 251, 96, 6, 15, 7, 16, 208, 251, - 96, 6, 15, 7, 160, 252, 96, 6, 15, 6, 80, 253, 96, 6, 15, 5, 16, 224, 253, 96, 6, 15, 5, 160, - 254, 96, 6, 15, 4, 80, 255, 96, 6, 15, 3, 16, 224, 255, 96, 6, 15, 3, 160, 255, 240, 96, 6, 15, - 2, 80, 255, 241, 96, 6, 15, 1, 16, 224, 255, 241, 96, 6, 15, 1, 160, 255, 242, 96, 6, 15, 0, 80, - 255, 243, 96, 6, 15, 16, 224, 247, 224, 250, 96, 6, 15, 160, 247, 208, 128, 250, 96, 6, 14, 96, 248, 96, - 144, 250, 96, 6, 13, 32, 224, 247, 208, 0, 144, 250, 96, 6, 13, 176, 248, 96, 0, 160, 250, 96, 6, 12, - 96, 248, 192, 1, 176, 250, 96, 6, 11, 32, 224, 248, 48, 1, 192, 250, 96, 6, 11, 176, 248, 128, 2, 192, - 250, 96, 6, 10, 96, 248, 208, 3, 208, 250, 96, 6, 9, 32, 224, 248, 48, 3, 208, 250, 96, 6, 9, 176, - 248, 128, 4, 224, 250, 96, 6, 8, 96, 248, 208, 5, 224, 250, 96, 6, 7, 32, 224, 248, 48, 5, 224, 250, - 96, 6, 7, 176, 248, 128, 6, 224, 250, 96, 6, 6, 112, 248, 208, 16, 6, 224, 250, 96, 6, 5, 32, 224, - 248, 48, 7, 224, 250, 96, 6, 5, 192, 248, 128, 8, 224, 250, 96, 6, 4, 112, 248, 208, 16, 8, 224, 250, - 96, 6, 3, 32, 249, 64, 9, 224, 250, 96, 6, 3, 192, 248, 144, 10, 224, 250, 96, 6, 2, 112, 248, 208, - 16, 10, 224, 250, 96, 6, 1, 48, 249, 64, 11, 224, 250, 96, 6, 1, 192, 248, 144, 12, 224, 250, 96, 6, - 0, 112, 248, 208, 16, 12, 224, 250, 96, 6, 48, 255, 255, 251, 144, 144, 255, 255, 251, 144, 144, 255, 255, 251, - 144, 144, 255, 255, 251, 144, 144, 255, 255, 251, 144, 144, 255, 255, 251, 144, 144, 255, 255, 251, 144, 144, 255, 255, - 251, 144, 144, 255, 255, 251, 144, 96, 191, 184, 251, 192, 181, 112, 15, 9, 224, 250, 96, 6, 15, 9, 224, 250, - 96, 6, 15, 9, 224, 250, 96, 6, 15, 9, 224, 250, 96, 6, 15, 9, 224, 250, 96, 6, 15, 9, 224, 250, - 96, 6, 15, 9, 224, 250, 96, 6, 15, 9, 224, 250, 96, 6, 15, 9, 224, 250, 96, 6, 15, 9, 224, 250, - 96, 6, 15, 9, 224, 250, 96, 6, 15, 9, 224, 250, 96, 6, 2, 112, 255, 255, 16, 3, 2, 128, 255, 255, - 16, 3, 2, 144, 255, 255, 16, 3, 2, 176, 255, 255, 16, 3, 2, 192, 255, 255, 16, 3, 2, 208, 255, 255, - 16, 3, 2, 224, 255, 255, 16, 3, 2, 255, 255, 240, 16, 3, 1, 16, 255, 255, 240, 16, 3, 1, 32, 255, - 255, 240, 16, 3, 1, 48, 255, 255, 240, 16, 3, 1, 64, 250, 144, 15, 9, 1, 96, 250, 128, 15, 9, 1, - 112, 250, 96, 15, 9, 1, 128, 250, 80, 15, 9, 1, 144, 250, 48, 15, 9, 1, 160, 250, 32, 15, 9, 1, - 176, 250, 16, 15, 9, 1, 192, 249, 224, 15, 10, 1, 208, 249, 208, 15, 10, 1, 250, 192, 15, 10, 0, 16, - 250, 160, 15, 10, 0, 32, 250, 160, 80, 128, 160, 192, 225, 241, 224, 208, 192, 144, 96, 32, 12, 0, 48, 255, - 249, 208, 112, 32, 9, 0, 64, 255, 252, 144, 16, 7, 0, 80, 255, 253, 224, 80, 6, 0, 96, 255, 255, 128, - 5, 0, 112, 255, 255, 240, 144, 4, 0, 128, 255, 255, 241, 112, 3, 0, 160, 255, 255, 242, 48, 2, 0, 96, - 255, 255, 242, 208, 2, 1, 32, 144, 247, 224, 192, 178, 192, 224, 255, 242, 80, 1, 3, 32, 160, 240, 208, 144, - 96, 48, 16, 6, 16, 64, 144, 224, 254, 208, 1, 5, 16, 15, 128, 254, 48, 0, 15, 7, 48, 224, 252, 112, - 0, 15, 8, 64, 252, 176, 0, 15, 9, 144, 251, 208, 0, 15, 9, 48, 252, 16, 15, 10, 208, 251, 16, 15, - 10, 176, 251, 32, 15, 10, 160, 251, 48, 15, 10, 144, 251, 32, 15, 10, 160, 251, 16, 15, 10, 192, 250, 224, - 0, 15, 9, 16, 251, 208, 0, 15, 9, 80, 251, 160, 0, 15, 9, 208, 251, 96, 0, 176, 80, 15, 6, 128, - 252, 32, 0, 208, 240, 208, 112, 32, 15, 2, 112, 252, 192, 1, 208, 243, 192, 112, 48, 13, 64, 192, 253, 96, - 1, 208, 246, 224, 176, 128, 80, 48, 32, 16, 0, 17, 48, 80, 128, 208, 254, 208, 2, 208, 255, 255, 243, 80, - 2, 208, 255, 255, 242, 160, 3, 208, 255, 255, 241, 208, 16, 3, 208, 255, 255, 240, 224, 32, 4, 208, 255, 255, - 208, 32, 5, 208, 255, 254, 176, 16, 6, 208, 255, 252, 224, 96, 8, 16, 128, 208, 255, 248, 224, 112, 16, 9, - 2, 48, 128, 192, 255, 242, 224, 160, 64, 12, 6, 48, 80, 128, 160, 192, 209, 224, 242, 224, 208, 192, 160, 128, - 80, 32, 15, 15, 5, 48, 96, 128, 160, 192, 208, 225, 245, 224, 208, 160, 16, 3, 15, 1, 16, 96, 176, 224, - 255, 240, 16, 3, 15, 48, 160, 255, 244, 16, 3, 13, 48, 176, 255, 246, 16, 3, 11, 16, 144, 255, 248, 16, - 3, 10, 48, 208, 255, 249, 16, 3, 9, 80, 255, 251, 16, 3, 8, 80, 255, 252, 16, 3, 7, 64, 255, 253, - 16, 3, 6, 32, 224, 255, 242, 208, 192, 178, 192, 208, 224, 242, 16, 3, 6, 192, 254, 192, 128, 64, 32, 8, - 16, 64, 128, 16, 3, 5, 128, 252, 224, 128, 32, 15, 4, 4, 32, 252, 160, 16, 15, 6, 4, 160, 251, 96, - 15, 8, 3, 32, 251, 80, 15, 9, 3, 144, 250, 112, 15, 10, 2, 16, 224, 249, 192, 15, 11, 2, 96, 250, - 48, 15, 11, 2, 176, 249, 176, 15, 12, 1, 16, 250, 80, 15, 12, 1, 80, 250, 16, 15, 12, 1, 144, 249, - 176, 15, 13, 1, 192, 249, 112, 5, 32, 112, 160, 192, 224, 241, 224, 208, 176, 128, 80, 16, 10, 1, 250, 64, - 3, 64, 192, 251, 224, 144, 32, 8, 0, 48, 250, 16, 1, 16, 160, 255, 240, 144, 16, 6, 0, 80, 249, 224, - 1, 32, 208, 255, 242, 208, 48, 5, 0, 112, 249, 192, 0, 32, 224, 255, 244, 224, 48, 4, 0, 144, 249, 176, - 16, 208, 255, 246, 224, 32, 3, 0, 160, 249, 160, 144, 255, 248, 208, 3, 0, 192, 255, 255, 245, 128, 2, 0, - 208, 255, 255, 246, 32, 1, 0, 224, 255, 241, 224, 192, 177, 208, 255, 128, 1, 0, 224, 255, 176, 64, 4, 16, - 96, 224, 252, 224, 1, 0, 254, 224, 80, 8, 16, 192, 252, 64, 0, 0, 253, 224, 32, 10, 16, 208, 251, 128, - 0, 16, 253, 64, 12, 64, 251, 176, 0, 0, 252, 144, 14, 192, 250, 224, 0, 0, 252, 32, 14, 112, 251, 16, - 0, 224, 250, 192, 15, 64, 251, 48, 0, 208, 250, 144, 15, 32, 251, 48, 0, 192, 250, 144, 15, 16, 251, 64, - 0, 160, 250, 160, 15, 0, 251, 64, 0, 128, 250, 176, 15, 16, 251, 48, 0, 80, 250, 208, 15, 32, 251, 48, - 0, 32, 251, 32, 14, 48, 251, 16, 1, 208, 250, 112, 14, 96, 250, 224, 0, 1, 144, 250, 192, 14, 160, 250, - 192, 0, 1, 80, 251, 64, 12, 16, 251, 144, 0, 2, 224, 250, 208, 16, 11, 128, 251, 64, 0, 2, 128, 251, - 160, 10, 64, 251, 224, 16, 0, 2, 32, 252, 160, 16, 7, 80, 224, 251, 144, 1, 3, 128, 252, 208, 80, 4, - 48, 160, 253, 48, 1, 3, 16, 208, 254, 192, 176, 192, 224, 254, 160, 2, 4, 64, 255, 255, 240, 224, 32, 2, - 5, 128, 255, 255, 96, 3, 6, 176, 255, 253, 144, 4, 7, 160, 255, 251, 160, 5, 8, 144, 255, 249, 144, 6, - 9, 80, 224, 255, 245, 224, 80, 7, 10, 16, 128, 224, 255, 242, 144, 16, 8, 12, 16, 112, 192, 253, 208, 128, - 32, 10, 15, 32, 96, 144, 176, 208, 224, 241, 224, 208, 176, 144, 96, 48, 13, 176, 255, 255, 249, 64, 176, 255, - 255, 249, 64, 176, 255, 255, 249, 64, 176, 255, 255, 249, 64, 176, 255, 255, 249, 64, 176, 255, 255, 249, 64, 176, - 255, 255, 249, 64, 176, 255, 255, 249, 64, 176, 255, 255, 249, 32, 176, 255, 255, 248, 176, 0, 176, 255, 255, 248, - 64, 0, 15, 12, 96, 250, 208, 1, 15, 12, 208, 250, 96, 1, 15, 11, 80, 250, 224, 16, 1, 15, 11, 192, - 250, 128, 2, 15, 10, 48, 251, 32, 2, 15, 10, 160, 250, 160, 3, 15, 9, 32, 251, 48, 3, 15, 9, 144, - 250, 192, 4, 15, 8, 16, 251, 80, 4, 15, 8, 128, 250, 208, 5, 15, 7, 16, 224, 250, 112, 5, 15, 7, - 112, 250, 224, 16, 5, 15, 7, 208, 250, 144, 6, 15, 6, 80, 251, 32, 6, 15, 6, 192, 250, 176, 7, 15, - 5, 64, 251, 64, 7, 15, 5, 176, 250, 208, 8, 15, 4, 48, 251, 96, 8, 15, 4, 160, 250, 224, 16, 8, - 15, 3, 32, 251, 128, 9, 15, 3, 144, 251, 32, 9, 15, 2, 16, 224, 250, 160, 10, 15, 2, 112, 251, 48, - 10, 15, 1, 16, 224, 250, 192, 11, 15, 1, 96, 251, 80, 11, 15, 1, 208, 250, 208, 12, 15, 0, 80, 251, - 112, 12, 15, 0, 192, 250, 224, 16, 12, 15, 64, 251, 144, 13, 15, 176, 251, 32, 13, 14, 48, 251, 176, 14, - 14, 160, 251, 64, 14, 13, 32, 251, 192, 15, 13, 128, 251, 96, 15, 12, 16, 224, 250, 224, 15, 0, 12, 112, - 251, 128, 15, 0, 12, 224, 251, 16, 15, 0, 11, 96, 251, 160, 15, 1, 11, 208, 251, 48, 15, 1, 10, 80, - 251, 176, 15, 2, 10, 192, 251, 80, 15, 2, 9, 48, 251, 208, 15, 3, 9, 160, 251, 112, 15, 3, 8, 32, - 251, 224, 16, 15, 3, 8, 144, 251, 128, 15, 4, 7, 16, 252, 32, 15, 4, 7, 128, 251, 160, 15, 5, 6, - 16, 224, 251, 64, 15, 5, 6, 112, 251, 192, 15, 6, 13, 16, 64, 112, 160, 192, 208, 224, 241, 224, 208, 192, - 160, 112, 64, 16, 12, 11, 80, 160, 224, 254, 176, 96, 16, 9, 8, 16, 112, 224, 255, 243, 224, 128, 16, 7, - 7, 64, 208, 255, 247, 224, 80, 6, 6, 128, 255, 251, 128, 5, 5, 144, 255, 253, 160, 4, 4, 128, 255, 255, - 128, 3, 3, 64, 255, 255, 241, 64, 2, 3, 208, 255, 255, 241, 192, 2, 2, 64, 255, 192, 177, 192, 255, 64, - 1, 2, 160, 252, 192, 80, 4, 16, 80, 208, 252, 144, 1, 2, 208, 251, 128, 9, 144, 251, 208, 1, 1, 16, - 251, 160, 11, 176, 251, 1, 1, 32, 251, 32, 11, 48, 251, 16, 0, 1, 48, 250, 208, 13, 208, 250, 32, 0, - 1, 32, 250, 176, 13, 192, 250, 32, 0, 1, 16, 250, 192, 13, 192, 250, 1, 2, 224, 249, 224, 13, 224, 249, - 208, 1, 2, 176, 250, 64, 11, 64, 250, 160, 1, 2, 112, 250, 192, 11, 192, 250, 96, 1, 2, 32, 251, 160, - 9, 144, 250, 224, 16, 1, 3, 160, 251, 176, 32, 5, 16, 160, 251, 112, 2, 3, 32, 224, 251, 224, 80, 3, - 64, 208, 251, 192, 3, 4, 96, 253, 176, 49, 176, 252, 224, 32, 3, 5, 144, 255, 252, 224, 48, 4, 6, 160, - 255, 250, 224, 48, 5, 7, 160, 255, 248, 192, 32, 6, 8, 128, 255, 246, 128, 8, 9, 80, 224, 255, 242, 176, - 48, 9, 10, 16, 208, 255, 240, 192, 16, 10, 9, 64, 192, 255, 242, 224, 112, 9, 7, 16, 144, 255, 246, 208, - 48, 7, 6, 48, 208, 255, 249, 112, 6, 5, 80, 255, 252, 176, 16, 4, 4, 96, 254, 224, 254, 208, 32, 3, - 3, 96, 253, 192, 80, 0, 96, 224, 253, 208, 16, 2, 2, 48, 252, 224, 112, 3, 16, 160, 253, 192, 2, 1, - 16, 208, 251, 192, 32, 6, 64, 208, 252, 128, 1, 1, 112, 251, 176, 16, 8, 16, 160, 252, 48, 0, 1, 208, - 250, 176, 12, 128, 251, 176, 0, 0, 64, 250, 224, 16, 13, 144, 251, 32, 0, 128, 250, 112, 15, 176, 250, 112, - 0, 176, 250, 16, 15, 64, 250, 176, 0, 224, 249, 208, 15, 1, 224, 249, 208, 0, 250, 176, 15, 1, 192, 250, - 16, 250, 176, 15, 1, 192, 250, 16, 250, 208, 15, 1, 208, 249, 224, 0, 251, 48, 15, 48, 250, 208, 0, 208, - 250, 160, 15, 160, 250, 176, 0, 160, 251, 80, 13, 80, 251, 128, 0, 112, 252, 96, 11, 112, 252, 64, 0, 32, - 253, 192, 96, 16, 5, 32, 96, 192, 252, 208, 0, 1, 176, 255, 208, 192, 177, 192, 224, 255, 96, 0, 1, 48, - 255, 255, 244, 192, 1, 2, 144, 255, 255, 242, 224, 48, 1, 3, 192, 255, 255, 241, 80, 2, 3, 16, 192, 255, - 255, 96, 3, 4, 16, 176, 255, 252, 224, 64, 4, 6, 112, 224, 255, 249, 160, 16, 5, 7, 16, 144, 224, 255, - 245, 176, 48, 7, 9, 16, 96, 176, 255, 240, 208, 128, 32, 9, 12, 16, 64, 112, 144, 176, 208, 225, 241, 225, - 192, 160, 128, 80, 32, 12, 13, 48, 96, 144, 176, 208, 224, 241, 224, 208, 176, 128, 96, 32, 14, 10, 32, 128, - 208, 253, 192, 96, 16, 11, 8, 16, 144, 255, 242, 224, 112, 16, 9, 7, 80, 224, 255, 245, 208, 64, 8, 6, - 144, 255, 249, 128, 7, 5, 160, 255, 251, 144, 6, 4, 144, 255, 253, 160, 5, 3, 96, 255, 255, 112, 4, 2, - 32, 255, 255, 241, 64, 3, 2, 176, 254, 224, 192, 176, 192, 224, 253, 208, 3, 1, 48, 253, 160, 48, 4, 80, - 192, 252, 112, 2, 1, 160, 251, 224, 64, 8, 144, 251, 224, 16, 1, 0, 16, 252, 48, 10, 160, 251, 112, 1, - 0, 80, 251, 112, 11, 16, 208, 250, 208, 1, 0, 144, 250, 224, 16, 12, 64, 251, 64, 0, 0, 192, 250, 144, - 14, 192, 250, 144, 0, 0, 251, 96, 14, 112, 250, 208, 0, 32, 251, 48, 14, 32, 251, 16, 48, 251, 16, 15, - 224, 250, 80, 64, 251, 15, 0, 176, 250, 112, 64, 251, 15, 0, 160, 250, 144, 64, 251, 15, 0, 144, 250, 176, - 64, 251, 16, 15, 160, 250, 208, 48, 251, 64, 15, 192, 250, 224, 32, 251, 112, 14, 32, 251, 224, 0, 224, 250, - 192, 14, 160, 252, 0, 192, 251, 64, 12, 80, 253, 0, 144, 251, 192, 16, 10, 48, 224, 253, 0, 80, 252, 176, - 16, 8, 96, 254, 224, 0, 16, 224, 252, 208, 96, 16, 4, 64, 176, 255, 224, 1, 144, 255, 208, 177, 192, 224, - 255, 241, 208, 1, 32, 255, 255, 246, 208, 2, 144, 255, 255, 245, 176, 2, 16, 208, 255, 248, 144, 176, 249, 160, - 3, 48, 224, 255, 246, 192, 16, 192, 249, 128, 4, 64, 224, 255, 244, 224, 32, 0, 208, 249, 96, 5, 48, 208, - 255, 242, 208, 32, 1, 224, 249, 64, 6, 16, 160, 255, 240, 176, 16, 1, 32, 250, 32, 8, 48, 160, 252, 208, - 80, 3, 64, 249, 224, 0, 10, 16, 80, 144, 192, 208, 224, 240, 225, 208, 160, 112, 48, 5, 128, 249, 192, 0, - 15, 13, 176, 249, 128, 0, 15, 12, 16, 250, 64, 0, 15, 12, 96, 249, 224, 16, 0, 15, 12, 192, 249, 160, - 1, 15, 11, 64, 250, 80, 1, 15, 11, 192, 249, 224, 16, 1, 15, 10, 128, 250, 144, 2, 15, 9, 112, 251, - 32, 2, 15, 8, 112, 251, 160, 3, 15, 6, 32, 176, 251, 224, 32, 3, 15, 4, 32, 144, 253, 112, 4, 3, - 16, 112, 64, 32, 8, 32, 64, 128, 192, 254, 192, 5, 3, 32, 242, 224, 208, 179, 192, 208, 255, 242, 224, 32, - 5, 3, 32, 255, 253, 64, 6, 3, 32, 255, 252, 80, 7, 3, 32, 255, 250, 224, 64, 8, 3, 32, 255, 249, - 208, 48, 9, 3, 32, 255, 248, 144, 16, 10, 3, 32, 255, 246, 176, 48, 12, 3, 32, 255, 244, 160, 48, 14, - 3, 32, 255, 240, 224, 176, 96, 16, 15, 0, 3, 16, 160, 208, 224, 245, 225, 208, 192, 160, 128, 96, 48, 15, - 4, 2, 16, 96, 176, 208, 240, 224, 208, 144, 48, 2, 1, 64, 208, 247, 160, 16, 0, 0, 48, 224, 249, 176, - 0, 0, 192, 251, 96, 32, 252, 176, 80, 252, 224, 96, 253, 112, 253, 80, 252, 224, 32, 252, 176, 0, 192, 251, - 80, 0, 48, 224, 249, 176, 0, 1, 48, 208, 247, 160, 16, 0, 3, 96, 160, 208, 240, 224, 208, 144, 48, 2, - ], -}; - -/// NotoSans-SemiBold at 40 px: 48 glyphs, 8601 B of runs of 4-bit coverage. -pub static L: Font = Font { - ascent: 43, - descent: 12, - cap: 28, - rle: true, - glyphs: &[ - Glyph { c: '0', adv: 23, x: 1, y: -28, w: 21, h: 28, off: 0 }, - Glyph { c: '1', adv: 23, x: 3, y: -28, w: 13, h: 28, off: 224 }, - Glyph { c: '2', adv: 23, x: 1, y: -28, w: 21, h: 28, off: 355 }, - Glyph { c: '3', adv: 23, x: 1, y: -28, w: 20, h: 28, off: 535 }, - Glyph { c: '4', adv: 23, x: 0, y: -28, w: 23, h: 28, off: 714 }, - Glyph { c: '5', adv: 23, x: 2, y: -28, w: 19, h: 28, off: 905 }, - Glyph { c: '6', adv: 23, x: 1, y: -28, w: 21, h: 28, off: 1071 }, - Glyph { c: '7', adv: 23, x: 1, y: -28, w: 21, h: 28, off: 1299 }, - Glyph { c: '8', adv: 23, x: 1, y: -28, w: 21, h: 28, off: 1441 }, - Glyph { c: '9', adv: 23, x: 1, y: -28, w: 21, h: 28, off: 1682 }, - Glyph { c: ':', adv: 11, x: 2, y: -22, w: 7, h: 22, off: 1901 }, - Glyph { c: '.', adv: 11, x: 2, y: -6, w: 7, h: 6, off: 1963 }, - Glyph { c: ' ', adv: 10, x: 0, y: 0, w: 0, h: 0, off: 1989 }, - Glyph { c: 'a', adv: 23, x: 1, y: -22, w: 20, h: 22, off: 1989 }, - Glyph { c: 'b', adv: 25, x: 3, y: -30, w: 20, h: 30, off: 2160 }, - Glyph { c: 'c', adv: 20, x: 2, y: -22, w: 17, h: 22, off: 2363 }, - Glyph { c: 'd', adv: 25, x: 2, y: -30, w: 20, h: 30, off: 2492 }, - Glyph { c: 'e', adv: 23, x: 2, y: -22, w: 20, h: 22, off: 2696 }, - Glyph { c: 'f', adv: 15, x: 0, y: -30, w: 17, h: 30, off: 2844 }, - Glyph { c: 'g', adv: 25, x: 2, y: -22, w: 20, h: 32, off: 3007 }, - Glyph { c: 'h', adv: 26, x: 3, y: -30, w: 20, h: 30, off: 3250 }, - Glyph { c: 'i', adv: 11, x: 2, y: -30, w: 7, h: 30, off: 3448 }, - Glyph { c: 'j', adv: 11, x: -3, y: -30, w: 12, h: 40, off: 3564 }, - Glyph { c: 'k', adv: 24, x: 3, y: -30, w: 21, h: 30, off: 3733 }, - Glyph { c: 'l', adv: 11, x: 3, y: -30, w: 6, h: 30, off: 3942 }, - Glyph { c: 'm', adv: 38, x: 3, y: -22, w: 33, h: 22, off: 4032 }, - Glyph { c: 'n', adv: 26, x: 3, y: -22, w: 20, h: 22, off: 4294 }, - Glyph { c: 'o', adv: 25, x: 2, y: -22, w: 21, h: 22, off: 4462 }, - Glyph { c: 'p', adv: 25, x: 3, y: -22, w: 20, h: 32, off: 4639 }, - Glyph { c: 'q', adv: 25, x: 2, y: -22, w: 20, h: 32, off: 4852 }, - Glyph { c: 'r', adv: 17, x: 3, y: -22, w: 14, h: 22, off: 5068 }, - Glyph { c: 's', adv: 20, x: 1, y: -22, w: 17, h: 22, off: 5175 }, - Glyph { c: 't', adv: 16, x: 0, y: -27, w: 16, h: 27, off: 5326 }, - Glyph { c: 'u', adv: 26, x: 2, y: -22, w: 21, h: 22, off: 5470 }, - Glyph { c: 'v', adv: 22, x: 0, y: -22, w: 22, h: 22, off: 5638 }, - Glyph { c: 'w', adv: 33, x: 0, y: -22, w: 33, h: 22, off: 5810 }, - Glyph { c: 'x', adv: 22, x: 0, y: -22, w: 22, h: 22, off: 6114 }, - Glyph { c: 'y', adv: 22, x: 0, y: -22, w: 22, h: 32, off: 6301 }, - Glyph { c: 'z', adv: 19, x: 1, y: -22, w: 17, h: 22, off: 6535 }, - Glyph { c: 'A', adv: 27, x: 0, y: -28, w: 27, h: 28, off: 6633 }, - Glyph { c: 'V', adv: 25, x: 0, y: -28, w: 26, h: 28, off: 6849 }, - Glyph { c: 'N', adv: 32, x: 3, y: -28, w: 25, h: 28, off: 7077 }, - Glyph { c: 'R', adv: 26, x: 3, y: -28, w: 23, h: 28, off: 7308 }, - Glyph { c: 'O', adv: 31, x: 2, y: -28, w: 28, h: 28, off: 7518 }, - Glyph { c: 'H', adv: 30, x: 3, y: -28, w: 24, h: 28, off: 7765 }, - Glyph { c: 'S', adv: 22, x: 1, y: -28, w: 20, h: 28, off: 7950 }, - Glyph { c: 'W', adv: 38, x: 0, y: -28, w: 38, h: 28, off: 8137 }, - Glyph { c: '…', adv: 33, x: 2, y: -6, w: 29, h: 6, off: 8519 }, - ], - bits: &[ - 5, 80, 160, 208, 224, 240, 208, 192, 128, 32, 5, 3, 48, 192, 248, 128, 4, 2, 48, 224, 250, 176, 3, 1, - 16, 208, 252, 144, 2, 1, 144, 244, 112, 16, 0, 32, 128, 244, 48, 1, 0, 16, 244, 80, 4, 128, 243, 176, - 1, 0, 96, 243, 176, 5, 16, 224, 243, 16, 0, 0, 160, 243, 96, 6, 144, 243, 96, 0, 0, 208, 243, 48, - 6, 80, 243, 160, 0, 16, 244, 7, 48, 243, 192, 0, 48, 243, 208, 7, 16, 244, 0, 64, 243, 192, 8, 224, - 243, 16, 80, 243, 176, 8, 224, 243, 32, 80, 243, 176, 8, 208, 243, 48, 80, 243, 176, 8, 208, 243, 48, 64, - 243, 176, 8, 224, 243, 32, 64, 243, 192, 8, 224, 243, 32, 32, 243, 208, 7, 16, 244, 0, 0, 244, 7, 32, - 243, 208, 0, 0, 192, 243, 48, 6, 80, 243, 176, 0, 0, 144, 243, 96, 6, 144, 243, 112, 0, 0, 64, 243, - 176, 6, 224, 243, 48, 0, 1, 208, 243, 80, 4, 128, 243, 208, 1, 1, 96, 244, 96, 16, 0, 32, 128, 244, - 96, 1, 2, 192, 252, 192, 2, 2, 32, 208, 250, 208, 32, 2, 3, 16, 176, 248, 176, 16, 3, 5, 64, 144, - 192, 224, 240, 224, 192, 144, 48, 5, 6, 64, 224, 242, 160, 5, 96, 244, 160, 4, 144, 245, 160, 2, 16, 192, - 246, 160, 1, 48, 208, 247, 160, 0, 80, 244, 224, 243, 160, 128, 244, 176, 80, 243, 160, 192, 243, 144, 0, 80, - 243, 160, 16, 208, 240, 224, 80, 1, 80, 243, 160, 0, 48, 192, 48, 2, 96, 243, 160, 6, 96, 243, 160, 6, - 96, 243, 160, 6, 96, 243, 160, 6, 96, 243, 160, 6, 96, 243, 160, 6, 96, 243, 160, 6, 96, 243, 160, 6, - 96, 243, 160, 6, 96, 243, 160, 6, 96, 243, 160, 6, 96, 243, 160, 6, 96, 243, 160, 6, 96, 243, 160, 6, - 96, 243, 160, 6, 96, 243, 160, 6, 96, 243, 160, 6, 96, 243, 160, 6, 96, 243, 160, 4, 48, 128, 176, 208, - 224, 240, 224, 192, 144, 64, 5, 2, 64, 192, 249, 192, 48, 3, 0, 16, 160, 253, 64, 2, 16, 208, 254, 224, - 32, 1, 0, 96, 243, 208, 112, 32, 1, 32, 144, 244, 160, 1, 1, 144, 241, 128, 16, 5, 96, 244, 16, 0, - 2, 176, 64, 8, 224, 243, 48, 0, 13, 192, 243, 64, 0, 13, 208, 243, 48, 0, 13, 224, 243, 32, 0, 12, - 80, 243, 208, 1, 12, 192, 243, 112, 1, 11, 112, 243, 224, 16, 1, 10, 80, 244, 96, 2, 9, 48, 224, 243, - 160, 3, 8, 48, 224, 243, 192, 4, 7, 32, 224, 243, 192, 16, 4, 6, 32, 224, 243, 208, 16, 5, 5, 32, - 208, 243, 192, 16, 6, 4, 32, 208, 243, 192, 16, 7, 3, 32, 208, 243, 176, 16, 8, 2, 32, 208, 243, 176, - 16, 9, 1, 32, 208, 243, 160, 11, 0, 32, 208, 243, 160, 12, 32, 208, 244, 236, 64, 64, 255, 242, 64, 64, - 255, 242, 64, 64, 255, 242, 64, 3, 32, 96, 160, 208, 224, 241, 224, 192, 144, 80, 16, 3, 1, 80, 176, 250, - 224, 96, 2, 16, 176, 254, 144, 1, 0, 160, 255, 96, 0, 0, 16, 208, 241, 176, 96, 32, 16, 1, 32, 128, - 244, 208, 0, 1, 48, 160, 48, 7, 96, 244, 16, 13, 224, 243, 32, 13, 224, 243, 16, 12, 48, 243, 176, 0, - 11, 16, 192, 243, 64, 0, 7, 16, 32, 64, 128, 224, 243, 96, 1, 4, 249, 192, 64, 2, 4, 247, 160, 64, - 4, 4, 248, 224, 160, 64, 2, 4, 226, 248, 176, 16, 0, 8, 16, 48, 96, 192, 244, 176, 0, 12, 112, 244, - 96, 13, 160, 243, 192, 13, 96, 244, 13, 80, 244, 13, 112, 244, 13, 192, 243, 192, 64, 112, 16, 9, 128, 244, - 112, 80, 241, 176, 112, 64, 16, 2, 32, 80, 176, 244, 224, 16, 80, 255, 240, 80, 0, 80, 255, 96, 1, 48, - 208, 252, 176, 32, 2, 1, 48, 96, 160, 192, 225, 241, 224, 192, 160, 112, 32, 4, 12, 176, 243, 112, 3, 11, - 112, 244, 112, 3, 10, 48, 245, 112, 3, 10, 192, 245, 112, 3, 9, 128, 246, 112, 3, 8, 64, 242, 192, 243, - 112, 3, 7, 16, 208, 241, 224, 96, 243, 112, 3, 7, 160, 242, 112, 96, 243, 112, 3, 6, 80, 242, 192, 0, - 112, 243, 112, 3, 5, 32, 224, 242, 48, 0, 112, 243, 112, 3, 5, 176, 242, 112, 1, 128, 243, 112, 3, 4, - 96, 242, 192, 2, 128, 243, 112, 3, 3, 32, 224, 241, 224, 32, 2, 128, 243, 112, 3, 3, 192, 242, 96, 3, - 128, 243, 112, 3, 2, 128, 242, 176, 4, 128, 243, 112, 3, 1, 48, 242, 224, 32, 4, 128, 243, 112, 3, 0, - 16, 208, 242, 96, 5, 128, 243, 112, 3, 0, 144, 242, 160, 6, 128, 243, 112, 3, 48, 255, 244, 32, 64, 255, - 244, 32, 64, 255, 244, 32, 48, 235, 245, 226, 32, 12, 128, 243, 112, 3, 12, 128, 243, 112, 3, 12, 128, 243, - 112, 3, 12, 128, 243, 112, 3, 12, 128, 243, 112, 3, 12, 128, 243, 112, 3, 0, 48, 253, 208, 1, 0, 64, - 253, 208, 1, 0, 80, 253, 208, 1, 0, 112, 244, 232, 208, 1, 0, 128, 243, 48, 11, 0, 144, 243, 32, 11, - 0, 160, 243, 16, 11, 0, 176, 242, 224, 12, 0, 208, 242, 208, 12, 0, 224, 242, 192, 12, 0, 243, 224, 176, - 208, 241, 224, 192, 160, 80, 16, 3, 16, 252, 224, 80, 2, 32, 254, 144, 1, 16, 192, 254, 96, 0, 1, 96, - 128, 80, 32, 16, 1, 32, 96, 192, 244, 224, 16, 11, 128, 244, 112, 12, 192, 243, 160, 12, 112, 243, 192, 12, - 80, 243, 208, 12, 80, 243, 192, 12, 112, 243, 160, 12, 208, 243, 96, 112, 48, 9, 144, 244, 32, 208, 240, 208, - 128, 80, 32, 2, 32, 96, 192, 244, 128, 0, 208, 254, 192, 16, 0, 208, 253, 192, 16, 1, 144, 251, 224, 112, - 3, 0, 16, 80, 144, 176, 208, 224, 240, 224, 208, 192, 144, 80, 5, 7, 16, 80, 144, 192, 208, 224, 240, 224, - 208, 192, 48, 1, 5, 16, 128, 224, 248, 64, 1, 4, 64, 224, 250, 64, 1, 3, 80, 252, 64, 1, 2, 48, - 244, 224, 128, 64, 32, 2, 16, 48, 16, 1, 2, 208, 243, 128, 16, 10, 1, 112, 243, 112, 12, 1, 208, 242, - 176, 13, 0, 64, 243, 80, 13, 0, 128, 242, 224, 16, 0, 32, 128, 192, 208, 224, 208, 160, 80, 4, 0, 176, - 242, 176, 0, 112, 247, 192, 32, 2, 0, 224, 242, 144, 128, 249, 224, 48, 1, 16, 243, 208, 251, 208, 16, 0, - 48, 246, 144, 48, 17, 64, 176, 244, 112, 0, 48, 244, 224, 64, 5, 160, 243, 208, 0, 64, 244, 96, 6, 32, - 244, 16, 64, 243, 224, 8, 192, 243, 64, 48, 243, 192, 8, 160, 243, 80, 32, 243, 208, 8, 144, 243, 80, 0, - 244, 16, 7, 160, 243, 64, 0, 176, 243, 80, 7, 208, 243, 32, 0, 112, 243, 192, 6, 48, 243, 208, 0, 0, - 16, 224, 243, 128, 4, 16, 192, 243, 144, 0, 1, 112, 244, 160, 48, 1, 64, 192, 244, 32, 0, 2, 192, 253, - 112, 1, 2, 16, 192, 251, 144, 2, 3, 16, 128, 248, 224, 96, 3, 5, 32, 112, 176, 224, 240, 224, 208, 160, - 96, 16, 4, 160, 255, 242, 80, 160, 255, 242, 80, 160, 255, 242, 80, 160, 237, 244, 32, 13, 80, 243, 160, 0, - 13, 192, 243, 64, 0, 12, 64, 243, 192, 1, 12, 176, 243, 80, 1, 11, 48, 243, 208, 2, 11, 160, 243, 112, - 2, 10, 32, 243, 224, 16, 2, 10, 144, 243, 128, 3, 9, 16, 224, 243, 32, 3, 9, 112, 243, 160, 4, 8, - 16, 224, 243, 48, 4, 8, 96, 243, 192, 5, 8, 208, 243, 80, 5, 7, 80, 243, 208, 6, 7, 192, 243, 112, - 6, 6, 64, 243, 224, 16, 6, 6, 176, 243, 128, 7, 5, 48, 244, 32, 7, 5, 160, 243, 160, 8, 4, 32, - 244, 48, 8, 4, 144, 243, 176, 9, 3, 16, 224, 243, 80, 9, 3, 128, 243, 208, 10, 2, 16, 224, 243, 96, - 10, 4, 16, 96, 160, 208, 224, 240, 224, 208, 144, 96, 16, 4, 3, 128, 224, 248, 224, 112, 3, 1, 16, 176, - 252, 144, 2, 1, 160, 254, 112, 1, 0, 32, 244, 192, 80, 16, 0, 16, 96, 208, 243, 224, 1, 0, 96, 243, - 192, 5, 16, 224, 243, 48, 0, 0, 112, 243, 112, 6, 144, 243, 64, 0, 0, 96, 243, 96, 6, 128, 243, 64, - 0, 0, 48, 243, 160, 6, 192, 243, 16, 0, 1, 208, 243, 96, 4, 112, 243, 144, 1, 1, 64, 244, 160, 16, - 0, 16, 160, 243, 208, 16, 1, 2, 80, 244, 224, 160, 244, 192, 16, 2, 3, 64, 224, 248, 128, 4, 4, 48, - 247, 128, 5, 3, 128, 249, 208, 64, 3, 1, 16, 192, 244, 160, 144, 245, 128, 2, 0, 16, 208, 243, 192, 48, - 1, 32, 160, 244, 144, 1, 0, 144, 243, 160, 5, 64, 224, 243, 80, 0, 16, 224, 242, 208, 7, 48, 243, 192, - 0, 64, 243, 128, 8, 176, 243, 16, 96, 243, 96, 8, 144, 243, 48, 80, 243, 144, 8, 192, 243, 32, 48, 244, - 48, 6, 80, 243, 224, 0, 0, 208, 243, 224, 112, 32, 2, 48, 144, 244, 144, 0, 0, 80, 255, 208, 16, 0, - 1, 112, 253, 208, 32, 1, 2, 64, 208, 250, 144, 16, 2, 4, 64, 128, 176, 208, 224, 240, 224, 208, 160, 96, - 32, 4, 4, 32, 112, 176, 208, 224, 240, 208, 176, 96, 16, 5, 2, 16, 144, 248, 224, 112, 4, 1, 16, 208, - 251, 176, 16, 2, 1, 192, 253, 160, 2, 0, 96, 244, 160, 48, 1, 32, 144, 244, 96, 1, 0, 208, 243, 112, - 5, 80, 243, 224, 1, 32, 243, 208, 7, 144, 243, 80, 0, 80, 243, 144, 7, 48, 243, 160, 0, 96, 243, 128, - 8, 224, 242, 208, 0, 96, 243, 144, 8, 224, 243, 16, 80, 243, 192, 7, 48, 244, 32, 32, 244, 80, 5, 32, - 208, 244, 48, 0, 192, 244, 112, 32, 1, 32, 112, 224, 245, 48, 0, 64, 252, 224, 243, 32, 1, 128, 250, 128, - 160, 243, 16, 2, 112, 248, 112, 0, 192, 243, 0, 3, 16, 112, 192, 224, 240, 224, 208, 144, 48, 1, 224, 242, - 208, 0, 13, 32, 243, 160, 0, 13, 96, 243, 112, 0, 13, 192, 243, 32, 0, 12, 64, 243, 192, 1, 11, 32, - 224, 243, 80, 1, 10, 64, 208, 243, 192, 2, 1, 32, 48, 16, 2, 32, 96, 176, 244, 224, 32, 2, 1, 96, - 251, 224, 64, 3, 1, 96, 250, 208, 48, 4, 1, 96, 248, 224, 112, 16, 5, 1, 64, 208, 224, 241, 224, 208, - 192, 144, 80, 16, 7, 0, 96, 208, 224, 208, 96, 0, 48, 244, 64, 112, 244, 128, 112, 244, 128, 48, 244, 48, - 0, 80, 192, 224, 208, 80, 0, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 0, 80, 192, 224, 208, 80, 0, - 48, 244, 64, 112, 244, 128, 112, 244, 128, 48, 244, 64, 0, 80, 208, 224, 208, 80, 0, 0, 80, 192, 224, 208, - 80, 0, 48, 244, 64, 112, 244, 128, 112, 244, 128, 48, 244, 64, 0, 80, 208, 224, 208, 80, 0, 4, 16, 80, - 144, 192, 208, 224, 240, 224, 192, 144, 64, 3, 2, 48, 160, 250, 176, 16, 1, 2, 192, 252, 192, 16, 0, 2, - 96, 253, 128, 0, 3, 224, 240, 208, 112, 48, 16, 0, 16, 96, 224, 243, 224, 0, 3, 80, 48, 6, 48, 244, - 48, 13, 192, 243, 80, 13, 160, 243, 96, 13, 160, 243, 96, 3, 16, 80, 144, 192, 208, 224, 248, 96, 2, 128, - 224, 253, 96, 0, 16, 192, 255, 96, 0, 144, 244, 160, 80, 32, 3, 160, 243, 96, 16, 224, 243, 112, 6, 160, - 243, 96, 48, 244, 7, 176, 243, 96, 64, 243, 224, 6, 16, 224, 243, 96, 64, 244, 32, 5, 160, 244, 96, 16, - 244, 208, 64, 16, 0, 16, 80, 192, 245, 96, 0, 176, 251, 192, 243, 96, 0, 48, 250, 176, 0, 208, 242, 96, - 1, 80, 224, 247, 144, 16, 0, 144, 242, 96, 2, 16, 112, 192, 224, 240, 224, 208, 144, 64, 2, 80, 242, 96, - 208, 243, 48, 13, 208, 243, 48, 13, 208, 243, 48, 13, 208, 243, 48, 13, 208, 243, 48, 13, 208, 243, 48, 13, - 208, 243, 48, 13, 208, 243, 48, 13, 208, 243, 32, 0, 16, 96, 192, 208, 240, 224, 176, 112, 16, 3, 208, 243, - 32, 64, 224, 246, 224, 80, 2, 208, 243, 64, 250, 80, 1, 208, 243, 224, 251, 32, 0, 208, 245, 128, 32, 1, - 32, 144, 244, 176, 0, 208, 244, 96, 5, 128, 244, 32, 208, 243, 208, 6, 16, 224, 243, 112, 208, 243, 128, 7, - 144, 243, 160, 208, 243, 80, 7, 96, 243, 208, 208, 243, 64, 7, 64, 243, 224, 208, 243, 48, 7, 48, 244, 208, - 243, 48, 7, 48, 244, 208, 243, 64, 7, 64, 243, 224, 208, 243, 96, 7, 96, 243, 208, 208, 243, 144, 7, 160, - 243, 160, 208, 243, 208, 6, 16, 224, 243, 112, 208, 244, 112, 5, 144, 244, 32, 208, 245, 144, 48, 1, 32, 144, - 244, 176, 0, 208, 255, 240, 32, 0, 208, 255, 80, 1, 208, 242, 144, 64, 208, 247, 224, 80, 2, 208, 242, 32, - 1, 80, 160, 208, 224, 240, 224, 176, 112, 16, 3, 4, 16, 80, 160, 192, 224, 240, 224, 208, 176, 128, 48, 0, - 3, 112, 224, 249, 160, 1, 16, 176, 251, 96, 1, 176, 251, 224, 16, 0, 96, 244, 192, 80, 16, 1, 48, 112, - 192, 144, 0, 16, 224, 243, 176, 16, 8, 80, 244, 32, 9, 144, 243, 176, 10, 192, 243, 112, 10, 224, 243, 64, - 10, 244, 48, 10, 244, 48, 10, 224, 243, 64, 10, 208, 243, 96, 10, 160, 243, 160, 10, 96, 244, 32, 9, 16, - 244, 176, 7, 33, 0, 128, 244, 192, 80, 16, 1, 32, 80, 160, 240, 96, 0, 16, 208, 252, 96, 1, 32, 208, - 251, 96, 2, 16, 144, 249, 224, 64, 4, 32, 112, 176, 208, 241, 224, 208, 160, 96, 16, 0, 13, 48, 243, 224, - 13, 48, 243, 224, 13, 48, 243, 224, 13, 48, 243, 224, 13, 48, 243, 224, 13, 48, 243, 224, 13, 48, 243, 224, - 13, 48, 243, 224, 3, 16, 96, 176, 208, 240, 224, 192, 112, 16, 0, 32, 243, 224, 2, 64, 224, 246, 224, 80, - 16, 243, 224, 1, 80, 250, 96, 243, 224, 0, 32, 255, 240, 224, 0, 176, 244, 176, 48, 1, 32, 128, 245, 224, - 32, 244, 176, 5, 64, 244, 224, 112, 244, 32, 6, 176, 243, 224, 160, 243, 160, 7, 80, 243, 224, 208, 243, 112, - 7, 32, 243, 224, 224, 243, 64, 8, 243, 224, 244, 48, 8, 224, 242, 224, 244, 48, 8, 224, 242, 224, 224, 243, - 64, 8, 243, 224, 208, 243, 96, 7, 16, 243, 224, 160, 243, 144, 7, 64, 243, 224, 112, 243, 224, 16, 6, 144, - 243, 224, 32, 244, 144, 5, 48, 244, 224, 0, 176, 244, 160, 48, 1, 32, 112, 224, 244, 224, 0, 32, 255, 240, - 224, 1, 96, 250, 80, 208, 242, 224, 2, 80, 224, 246, 224, 80, 0, 128, 242, 224, 3, 16, 112, 192, 224, 240, - 208, 192, 112, 16, 1, 48, 242, 224, 4, 16, 112, 176, 208, 225, 208, 176, 112, 32, 4, 3, 128, 224, 248, 144, - 3, 1, 16, 176, 251, 192, 16, 1, 1, 176, 253, 176, 1, 0, 112, 244, 128, 48, 1, 32, 112, 224, 243, 80, - 0, 0, 224, 243, 80, 5, 64, 243, 192, 0, 80, 243, 176, 7, 176, 243, 16, 144, 243, 96, 7, 112, 243, 80, - 192, 244, 231, 244, 96, 208, 255, 241, 112, 224, 255, 241, 112, 255, 242, 112, 224, 243, 64, 13, 192, 243, 96, 13, - 160, 243, 160, 13, 80, 244, 32, 12, 16, 224, 243, 192, 16, 8, 33, 0, 0, 96, 244, 224, 112, 32, 2, 16, - 64, 112, 192, 240, 80, 0, 1, 160, 254, 80, 0, 1, 16, 160, 253, 80, 0, 3, 96, 224, 250, 208, 48, 0, - 5, 80, 144, 192, 224, 241, 224, 208, 176, 128, 48, 2, 6, 64, 144, 192, 224, 240, 224, 208, 176, 128, 32, 4, - 16, 176, 248, 80, 4, 176, 248, 224, 16, 3, 64, 249, 160, 0, 3, 144, 243, 224, 80, 16, 0, 16, 64, 32, - 0, 3, 176, 243, 112, 6, 3, 192, 243, 64, 6, 3, 192, 243, 64, 6, 1, 64, 176, 249, 112, 1, 32, 208, - 251, 112, 1, 64, 252, 112, 1, 64, 226, 244, 228, 112, 1, 3, 192, 243, 64, 6, 3, 192, 243, 64, 6, 3, - 192, 243, 64, 6, 3, 192, 243, 64, 6, 3, 192, 243, 64, 6, 3, 192, 243, 64, 6, 3, 192, 243, 64, 6, - 3, 192, 243, 64, 6, 3, 192, 243, 64, 6, 3, 192, 243, 64, 6, 3, 192, 243, 64, 6, 3, 192, 243, 64, - 6, 3, 192, 243, 64, 6, 3, 192, 243, 64, 6, 3, 192, 243, 64, 6, 3, 192, 243, 64, 6, 3, 192, 243, - 64, 6, 3, 192, 243, 64, 6, 3, 16, 112, 176, 208, 240, 224, 192, 112, 32, 1, 96, 242, 224, 2, 64, 208, - 246, 224, 112, 0, 144, 242, 224, 1, 80, 250, 128, 176, 242, 224, 0, 32, 224, 255, 224, 0, 160, 244, 160, 48, - 1, 32, 128, 245, 224, 16, 244, 160, 5, 64, 244, 224, 96, 243, 224, 16, 6, 160, 243, 224, 160, 243, 160, 7, - 64, 243, 224, 208, 243, 96, 7, 16, 243, 224, 224, 243, 64, 8, 224, 242, 224, 244, 48, 8, 208, 242, 224, 244, - 48, 8, 208, 242, 224, 224, 243, 64, 8, 224, 242, 224, 208, 243, 96, 8, 243, 224, 160, 243, 144, 7, 32, 243, - 224, 112, 243, 224, 16, 6, 112, 243, 224, 32, 244, 144, 5, 32, 224, 243, 224, 0, 176, 244, 160, 48, 1, 32, - 96, 224, 244, 224, 0, 32, 255, 240, 224, 1, 96, 250, 80, 243, 224, 2, 80, 224, 246, 224, 80, 32, 243, 224, - 3, 16, 112, 192, 224, 240, 224, 192, 112, 16, 0, 32, 243, 224, 13, 32, 243, 224, 13, 48, 243, 208, 13, 96, - 243, 176, 13, 192, 243, 128, 0, 112, 80, 9, 128, 244, 64, 0, 144, 240, 224, 144, 80, 48, 16, 1, 16, 64, - 176, 244, 192, 0, 0, 144, 255, 64, 0, 0, 144, 254, 96, 1, 0, 128, 252, 192, 48, 2, 1, 32, 96, 144, - 176, 208, 224, 241, 224, 208, 176, 128, 64, 4, 208, 243, 48, 13, 208, 243, 48, 13, 208, 243, 48, 13, 208, 243, - 48, 13, 208, 243, 48, 13, 208, 243, 48, 13, 208, 243, 48, 13, 208, 243, 48, 13, 208, 243, 32, 0, 16, 96, - 176, 208, 240, 224, 208, 160, 64, 3, 208, 243, 32, 64, 208, 247, 192, 32, 1, 208, 243, 64, 250, 208, 16, 0, - 208, 243, 224, 251, 144, 0, 208, 245, 176, 64, 16, 0, 16, 112, 245, 16, 208, 244, 160, 5, 80, 244, 64, 208, - 243, 224, 16, 6, 208, 243, 96, 208, 243, 160, 7, 160, 243, 112, 208, 243, 112, 7, 144, 243, 128, 208, 243, 80, - 7, 128, 243, 128, 208, 243, 64, 7, 128, 243, 128, 208, 243, 48, 7, 128, 243, 128, 208, 243, 48, 7, 128, 243, - 128, 208, 243, 48, 7, 128, 243, 128, 208, 243, 48, 7, 128, 243, 128, 208, 243, 48, 7, 128, 243, 128, 208, 243, - 48, 7, 128, 243, 128, 208, 243, 48, 7, 128, 243, 128, 208, 243, 48, 7, 128, 243, 128, 208, 243, 48, 7, 128, - 243, 128, 208, 243, 48, 7, 128, 243, 128, 208, 243, 48, 7, 128, 243, 128, 0, 64, 192, 224, 208, 112, 0, 0, - 224, 243, 64, 16, 244, 112, 0, 224, 243, 64, 0, 64, 192, 224, 208, 112, 0, 6, 6, 6, 0, 208, 243, 48, - 0, 208, 243, 48, 0, 208, 243, 48, 0, 208, 243, 48, 0, 208, 243, 48, 0, 208, 243, 48, 0, 208, 243, 48, - 0, 208, 243, 48, 0, 208, 243, 48, 0, 208, 243, 48, 0, 208, 243, 48, 0, 208, 243, 48, 0, 208, 243, 48, - 0, 208, 243, 48, 0, 208, 243, 48, 0, 208, 243, 48, 0, 208, 243, 48, 0, 208, 243, 48, 0, 208, 243, 48, - 0, 208, 243, 48, 0, 208, 243, 48, 0, 208, 243, 48, 5, 64, 192, 224, 208, 112, 0, 5, 224, 243, 64, 4, - 16, 244, 112, 5, 224, 243, 64, 5, 64, 192, 224, 208, 112, 0, 11, 11, 11, 5, 208, 243, 48, 5, 208, 243, - 48, 5, 208, 243, 48, 5, 208, 243, 48, 5, 208, 243, 48, 5, 208, 243, 48, 5, 208, 243, 48, 5, 208, 243, - 48, 5, 208, 243, 48, 5, 208, 243, 48, 5, 208, 243, 48, 5, 208, 243, 48, 5, 208, 243, 48, 5, 208, 243, - 48, 5, 208, 243, 48, 5, 208, 243, 48, 5, 208, 243, 48, 5, 208, 243, 48, 5, 208, 243, 48, 5, 208, 243, - 48, 5, 208, 243, 48, 5, 208, 243, 48, 5, 208, 243, 48, 5, 208, 243, 48, 5, 208, 243, 48, 5, 224, 243, - 32, 4, 32, 244, 16, 16, 48, 1, 48, 192, 243, 208, 0, 32, 248, 112, 0, 32, 247, 208, 16, 0, 32, 246, - 224, 48, 1, 16, 176, 208, 224, 240, 224, 176, 112, 16, 2, 192, 243, 64, 14, 192, 243, 64, 14, 192, 243, 64, - 14, 192, 243, 64, 14, 192, 243, 64, 14, 192, 243, 64, 14, 192, 243, 64, 14, 192, 243, 64, 14, 192, 243, 64, - 6, 96, 244, 80, 0, 192, 243, 64, 5, 80, 244, 96, 1, 192, 243, 64, 4, 64, 244, 128, 2, 192, 243, 64, - 3, 48, 224, 243, 144, 3, 192, 243, 64, 2, 32, 224, 243, 160, 4, 192, 243, 64, 1, 32, 208, 243, 176, 5, - 192, 243, 48, 0, 16, 192, 243, 192, 16, 5, 192, 243, 48, 0, 176, 243, 208, 16, 6, 192, 243, 32, 144, 243, - 224, 32, 7, 192, 243, 96, 244, 80, 8, 192, 243, 224, 244, 192, 8, 192, 250, 144, 7, 192, 245, 208, 244, 80, - 6, 192, 244, 160, 16, 144, 243, 224, 32, 5, 192, 243, 128, 1, 16, 208, 243, 192, 5, 192, 243, 64, 2, 48, - 244, 128, 4, 192, 243, 64, 3, 112, 244, 64, 3, 192, 243, 64, 4, 176, 243, 224, 32, 2, 192, 243, 64, 4, - 16, 224, 243, 176, 2, 192, 243, 64, 5, 80, 244, 128, 1, 192, 243, 64, 6, 144, 244, 64, 0, 192, 243, 64, - 6, 16, 208, 243, 224, 16, 208, 243, 48, 208, 243, 48, 208, 243, 48, 208, 243, 48, 208, 243, 48, 208, 243, 48, - 208, 243, 48, 208, 243, 48, 208, 243, 48, 208, 243, 48, 208, 243, 48, 208, 243, 48, 208, 243, 48, 208, 243, 48, - 208, 243, 48, 208, 243, 48, 208, 243, 48, 208, 243, 48, 208, 243, 48, 208, 243, 48, 208, 243, 48, 208, 243, 48, - 208, 243, 48, 208, 243, 48, 208, 243, 48, 208, 243, 48, 208, 243, 48, 208, 243, 48, 208, 243, 48, 208, 243, 48, - 208, 242, 48, 1, 32, 112, 192, 224, 240, 224, 192, 128, 48, 4, 80, 160, 208, 225, 208, 160, 96, 3, 208, 242, - 96, 0, 112, 248, 128, 1, 48, 192, 247, 208, 48, 1, 208, 242, 160, 128, 250, 112, 48, 224, 249, 224, 16, 0, - 208, 255, 240, 224, 251, 144, 0, 208, 245, 144, 32, 1, 48, 192, 246, 224, 96, 16, 0, 16, 96, 224, 243, 224, - 0, 208, 244, 112, 4, 16, 224, 244, 224, 32, 4, 80, 244, 48, 208, 243, 224, 6, 144, 244, 128, 6, 224, 243, - 80, 208, 243, 160, 6, 96, 244, 32, 6, 176, 243, 96, 208, 243, 96, 6, 80, 243, 224, 7, 160, 243, 96, 208, - 243, 64, 6, 64, 243, 208, 7, 160, 243, 96, 208, 243, 64, 6, 64, 243, 192, 7, 160, 243, 96, 208, 243, 48, - 6, 64, 243, 192, 7, 160, 243, 96, 208, 243, 48, 6, 64, 243, 192, 7, 160, 243, 96, 208, 243, 48, 6, 64, - 243, 192, 7, 160, 243, 96, 208, 243, 48, 6, 64, 243, 192, 7, 160, 243, 96, 208, 243, 48, 6, 64, 243, 192, - 7, 160, 243, 96, 208, 243, 48, 6, 64, 243, 192, 7, 160, 243, 96, 208, 243, 48, 6, 64, 243, 192, 7, 160, - 243, 96, 208, 243, 48, 6, 64, 243, 192, 7, 160, 243, 96, 208, 243, 48, 6, 64, 243, 192, 7, 160, 243, 96, - 208, 243, 48, 6, 64, 243, 192, 7, 160, 243, 96, 208, 243, 48, 6, 64, 243, 192, 7, 160, 243, 96, 208, 242, - 48, 1, 16, 96, 176, 208, 240, 224, 208, 160, 80, 3, 208, 242, 96, 0, 96, 224, 247, 192, 32, 1, 208, 242, - 144, 96, 250, 208, 16, 0, 208, 255, 240, 144, 0, 208, 245, 176, 64, 16, 0, 16, 96, 224, 244, 16, 208, 244, - 144, 5, 80, 244, 64, 208, 243, 224, 16, 6, 208, 243, 96, 208, 243, 160, 7, 144, 243, 112, 208, 243, 112, 7, - 128, 243, 128, 208, 243, 80, 7, 128, 243, 128, 208, 243, 64, 7, 128, 243, 128, 208, 243, 48, 7, 128, 243, 128, - 208, 243, 48, 7, 128, 243, 128, 208, 243, 48, 7, 128, 243, 128, 208, 243, 48, 7, 128, 243, 128, 208, 243, 48, - 7, 128, 243, 128, 208, 243, 48, 7, 128, 243, 128, 208, 243, 48, 7, 128, 243, 128, 208, 243, 48, 7, 128, 243, - 128, 208, 243, 48, 7, 128, 243, 128, 208, 243, 48, 7, 128, 243, 128, 208, 243, 48, 7, 128, 243, 128, 4, 16, - 96, 160, 208, 224, 240, 224, 192, 144, 64, 5, 3, 112, 224, 248, 192, 48, 3, 1, 16, 176, 252, 96, 2, 1, - 176, 254, 80, 1, 0, 112, 244, 176, 64, 1, 16, 96, 208, 243, 224, 32, 0, 0, 224, 243, 160, 5, 32, 208, - 243, 144, 0, 80, 243, 224, 16, 6, 96, 243, 224, 16, 144, 243, 160, 8, 224, 243, 64, 192, 243, 96, 8, 176, - 243, 112, 224, 243, 64, 8, 144, 243, 144, 244, 48, 8, 128, 243, 160, 244, 48, 8, 128, 243, 160, 224, 243, 64, - 8, 144, 243, 144, 192, 243, 112, 8, 176, 243, 112, 144, 243, 160, 7, 16, 224, 243, 64, 64, 244, 32, 6, 96, - 243, 224, 16, 0, 208, 243, 160, 5, 32, 224, 243, 144, 0, 0, 80, 244, 176, 64, 1, 16, 96, 224, 243, 224, - 32, 0, 1, 144, 254, 80, 1, 2, 160, 252, 96, 2, 3, 96, 224, 248, 192, 64, 3, 4, 16, 96, 160, 208, - 224, 240, 224, 192, 144, 64, 5, 208, 242, 80, 1, 16, 112, 192, 208, 240, 224, 192, 112, 16, 3, 208, 242, 144, - 0, 64, 224, 246, 224, 80, 2, 208, 242, 192, 80, 250, 96, 1, 208, 255, 240, 48, 0, 208, 245, 128, 32, 1, - 48, 160, 244, 192, 0, 208, 244, 96, 5, 144, 244, 32, 208, 243, 208, 6, 16, 224, 243, 112, 208, 243, 128, 7, - 160, 243, 160, 208, 243, 80, 7, 96, 243, 208, 208, 243, 64, 7, 64, 243, 224, 208, 243, 48, 7, 48, 244, 208, - 243, 48, 7, 48, 244, 208, 243, 64, 7, 64, 243, 224, 208, 243, 96, 7, 96, 243, 192, 208, 243, 144, 7, 160, - 243, 160, 208, 243, 208, 6, 16, 224, 243, 112, 208, 244, 112, 5, 144, 244, 32, 208, 245, 144, 48, 1, 48, 160, - 244, 160, 0, 208, 255, 224, 32, 0, 208, 243, 144, 250, 80, 1, 208, 243, 16, 112, 247, 208, 64, 2, 208, 243, - 32, 0, 32, 128, 192, 224, 240, 224, 176, 96, 16, 3, 208, 243, 48, 13, 208, 243, 48, 13, 208, 243, 48, 13, - 208, 243, 48, 13, 208, 243, 48, 13, 208, 243, 48, 13, 208, 243, 48, 13, 208, 243, 48, 13, 208, 243, 48, 13, - 208, 243, 48, 13, 3, 16, 96, 176, 224, 240, 224, 192, 112, 16, 1, 96, 242, 224, 2, 64, 208, 246, 224, 96, - 0, 144, 242, 224, 1, 80, 250, 96, 192, 242, 224, 0, 32, 224, 255, 224, 0, 176, 244, 160, 48, 1, 32, 112, - 224, 244, 224, 32, 244, 160, 5, 64, 244, 224, 112, 244, 16, 6, 160, 243, 224, 160, 243, 160, 7, 80, 243, 224, - 208, 243, 112, 7, 32, 243, 224, 224, 243, 64, 8, 243, 224, 244, 48, 8, 224, 242, 224, 244, 48, 8, 224, 242, - 224, 224, 243, 64, 8, 224, 242, 224, 208, 243, 96, 7, 16, 243, 224, 160, 243, 144, 7, 48, 243, 224, 112, 243, - 224, 16, 6, 128, 243, 224, 32, 244, 144, 5, 48, 224, 243, 224, 0, 176, 244, 160, 48, 1, 32, 96, 224, 244, - 224, 0, 48, 251, 224, 243, 224, 1, 96, 250, 64, 243, 224, 2, 80, 224, 246, 224, 64, 32, 243, 224, 3, 16, - 112, 192, 224, 240, 208, 192, 112, 16, 0, 32, 243, 224, 13, 32, 243, 224, 13, 32, 243, 224, 13, 32, 243, 224, - 13, 32, 243, 224, 13, 32, 243, 224, 13, 32, 243, 224, 13, 32, 243, 224, 13, 32, 243, 224, 13, 32, 243, 224, - 13, 32, 243, 224, 208, 242, 32, 2, 64, 160, 224, 241, 192, 208, 242, 64, 1, 144, 244, 160, 208, 242, 112, 0, - 160, 245, 144, 208, 242, 144, 96, 246, 128, 208, 242, 225, 246, 96, 208, 245, 224, 128, 48, 17, 48, 32, 208, 244, - 208, 32, 5, 208, 244, 48, 6, 208, 243, 160, 7, 208, 243, 96, 7, 208, 243, 64, 7, 208, 243, 48, 7, 208, - 243, 48, 7, 208, 243, 48, 7, 208, 243, 48, 7, 208, 243, 48, 7, 208, 243, 48, 7, 208, 243, 48, 7, 208, - 243, 48, 7, 208, 243, 48, 7, 208, 243, 48, 7, 208, 243, 48, 7, 3, 32, 112, 176, 208, 224, 240, 224, 208, - 160, 112, 32, 1, 1, 16, 160, 250, 192, 64, 0, 16, 208, 252, 80, 0, 128, 252, 224, 0, 0, 224, 243, 144, - 32, 1, 16, 64, 128, 224, 240, 144, 0, 16, 243, 208, 7, 64, 32, 0, 0, 243, 224, 10, 0, 192, 243, 176, - 32, 8, 0, 96, 245, 160, 64, 6, 1, 160, 246, 224, 128, 32, 3, 2, 96, 224, 247, 144, 16, 1, 3, 16, - 112, 224, 246, 224, 64, 0, 6, 80, 176, 245, 224, 32, 8, 48, 160, 244, 144, 10, 96, 243, 208, 11, 224, 243, - 0, 80, 16, 7, 16, 243, 224, 16, 240, 224, 160, 96, 48, 16, 1, 16, 64, 192, 243, 176, 16, 254, 64, 16, - 253, 144, 0, 0, 208, 250, 224, 112, 1, 1, 64, 128, 176, 208, 224, 241, 224, 208, 160, 96, 16, 2, 4, 144, - 241, 192, 6, 4, 208, 241, 192, 6, 3, 48, 242, 192, 6, 3, 128, 242, 192, 6, 3, 208, 242, 192, 6, 1, - 64, 208, 249, 224, 0, 16, 176, 251, 224, 0, 48, 252, 224, 0, 48, 225, 245, 228, 208, 0, 2, 64, 243, 192, - 6, 2, 64, 243, 192, 6, 2, 64, 243, 192, 6, 2, 64, 243, 192, 6, 2, 64, 243, 192, 6, 2, 64, 243, - 192, 6, 2, 64, 243, 192, 6, 2, 64, 243, 192, 6, 2, 64, 243, 192, 6, 2, 64, 243, 192, 6, 2, 64, - 243, 192, 6, 2, 64, 243, 192, 6, 2, 48, 244, 16, 5, 2, 16, 244, 192, 48, 1, 32, 96, 16, 3, 176, - 249, 32, 3, 48, 249, 32, 4, 96, 224, 247, 32, 5, 32, 128, 192, 224, 240, 208, 192, 160, 96, 0, 16, 244, - 16, 7, 160, 243, 96, 16, 244, 16, 7, 160, 243, 96, 16, 244, 16, 7, 160, 243, 96, 16, 244, 16, 7, 160, - 243, 96, 16, 244, 16, 7, 160, 243, 96, 16, 244, 16, 7, 160, 243, 96, 16, 244, 16, 7, 160, 243, 96, 16, - 244, 16, 7, 160, 243, 96, 16, 244, 16, 7, 160, 243, 96, 16, 244, 16, 7, 160, 243, 96, 16, 244, 16, 7, - 160, 243, 96, 16, 244, 16, 7, 176, 243, 96, 16, 244, 16, 7, 192, 243, 96, 16, 244, 16, 7, 224, 243, 96, - 0, 244, 32, 6, 48, 244, 96, 0, 224, 243, 96, 6, 128, 244, 96, 0, 192, 243, 192, 5, 48, 224, 244, 96, - 0, 128, 244, 176, 48, 1, 32, 112, 224, 245, 96, 0, 32, 255, 241, 96, 1, 128, 250, 224, 80, 243, 96, 2, - 112, 248, 192, 48, 0, 224, 242, 96, 3, 32, 128, 192, 224, 240, 224, 208, 144, 64, 2, 160, 242, 96, 192, 243, - 128, 9, 160, 243, 160, 112, 243, 208, 9, 224, 243, 80, 16, 244, 48, 7, 80, 243, 224, 0, 0, 160, 243, 112, - 7, 160, 243, 128, 0, 0, 80, 243, 192, 7, 224, 243, 48, 0, 1, 224, 243, 32, 5, 80, 243, 192, 1, 1, - 144, 243, 112, 5, 160, 243, 96, 1, 1, 48, 243, 192, 5, 224, 243, 16, 1, 2, 192, 243, 32, 3, 80, 243, - 160, 2, 2, 112, 243, 112, 3, 160, 243, 64, 2, 2, 16, 243, 192, 3, 224, 242, 224, 3, 3, 176, 243, 32, - 1, 80, 243, 128, 3, 3, 80, 243, 96, 1, 160, 243, 48, 3, 4, 224, 242, 176, 1, 224, 242, 192, 4, 4, - 144, 243, 16, 64, 243, 96, 4, 4, 48, 243, 96, 144, 243, 16, 4, 5, 192, 242, 160, 208, 242, 160, 5, 5, - 112, 242, 224, 243, 64, 5, 5, 16, 246, 208, 6, 6, 176, 245, 128, 6, 6, 80, 245, 32, 6, 7, 224, 243, - 192, 7, 112, 243, 144, 6, 64, 244, 128, 6, 96, 243, 144, 48, 243, 208, 6, 128, 244, 192, 6, 144, 243, 80, - 0, 224, 243, 32, 5, 192, 245, 16, 5, 208, 243, 16, 0, 144, 243, 96, 4, 16, 246, 80, 4, 32, 243, 192, - 0, 0, 80, 243, 144, 4, 96, 242, 192, 242, 144, 4, 96, 243, 128, 0, 0, 16, 243, 208, 4, 160, 242, 80, - 242, 208, 4, 160, 243, 48, 0, 1, 192, 243, 32, 3, 224, 241, 224, 0, 208, 242, 32, 3, 224, 242, 224, 1, - 1, 128, 243, 96, 2, 48, 242, 176, 0, 160, 242, 96, 2, 48, 243, 160, 1, 1, 64, 243, 160, 2, 112, 242, - 128, 0, 96, 242, 160, 2, 112, 243, 96, 1, 2, 224, 242, 224, 2, 176, 242, 64, 0, 32, 242, 224, 2, 160, - 243, 32, 1, 2, 160, 243, 32, 0, 16, 243, 16, 1, 224, 242, 48, 1, 224, 242, 192, 2, 2, 96, 243, 96, - 0, 80, 242, 192, 2, 160, 242, 112, 0, 48, 243, 128, 2, 2, 32, 243, 144, 0, 128, 242, 128, 2, 96, 242, - 160, 0, 112, 243, 64, 2, 3, 208, 242, 192, 0, 176, 242, 64, 2, 48, 242, 208, 0, 160, 242, 224, 3, 3, - 144, 242, 224, 0, 224, 242, 16, 3, 224, 242, 16, 208, 242, 160, 3, 3, 80, 243, 48, 242, 176, 4, 160, 242, - 80, 243, 96, 3, 3, 16, 243, 128, 242, 112, 4, 96, 242, 144, 243, 32, 3, 4, 176, 242, 208, 242, 48, 4, - 32, 242, 224, 242, 208, 4, 4, 112, 245, 224, 6, 208, 245, 144, 4, 4, 48, 245, 160, 6, 160, 245, 64, 4, - 5, 224, 244, 96, 6, 96, 245, 16, 4, 5, 160, 244, 32, 6, 32, 244, 176, 5, 16, 208, 243, 192, 7, 96, - 244, 80, 0, 64, 244, 96, 5, 16, 224, 243, 160, 0, 1, 144, 243, 224, 32, 4, 160, 243, 208, 16, 0, 1, - 16, 208, 243, 160, 3, 64, 244, 64, 1, 2, 64, 244, 80, 1, 16, 208, 243, 144, 2, 3, 144, 243, 208, 16, - 0, 128, 243, 208, 16, 2, 3, 16, 208, 243, 128, 48, 244, 64, 3, 4, 64, 244, 208, 243, 144, 4, 5, 144, - 247, 208, 16, 4, 5, 16, 208, 246, 64, 5, 6, 64, 245, 144, 6, 6, 144, 245, 208, 16, 5, 5, 64, 247, - 144, 5, 4, 16, 208, 248, 64, 4, 4, 144, 243, 208, 128, 243, 208, 16, 3, 3, 64, 244, 64, 0, 192, 243, - 144, 3, 2, 16, 208, 243, 144, 1, 48, 244, 64, 2, 2, 144, 243, 224, 16, 2, 144, 243, 208, 16, 1, 1, - 64, 244, 80, 3, 16, 208, 243, 144, 1, 0, 16, 208, 243, 176, 5, 80, 244, 80, 0, 0, 144, 243, 224, 32, - 6, 160, 243, 224, 16, 64, 244, 112, 7, 16, 224, 243, 160, 192, 243, 144, 9, 144, 243, 176, 96, 243, 224, 9, - 208, 243, 96, 16, 224, 243, 64, 7, 48, 243, 224, 16, 0, 160, 243, 144, 7, 128, 243, 160, 0, 0, 64, 243, - 224, 7, 208, 243, 64, 0, 1, 208, 243, 64, 5, 48, 243, 208, 1, 1, 112, 243, 144, 5, 128, 243, 128, 1, - 1, 16, 243, 224, 5, 208, 243, 32, 1, 2, 160, 243, 64, 3, 48, 243, 192, 2, 2, 80, 243, 144, 3, 112, - 243, 96, 2, 3, 208, 242, 224, 3, 192, 243, 16, 2, 3, 128, 243, 64, 1, 32, 243, 160, 3, 3, 32, 243, - 144, 1, 112, 243, 80, 3, 4, 176, 242, 224, 1, 192, 242, 224, 4, 4, 80, 243, 64, 32, 243, 144, 4, 5, - 224, 242, 128, 96, 243, 48, 4, 5, 144, 242, 176, 160, 242, 208, 5, 5, 48, 242, 225, 242, 112, 5, 6, 192, - 246, 32, 5, 6, 96, 245, 176, 6, 6, 16, 224, 244, 96, 6, 7, 144, 243, 224, 16, 6, 7, 96, 243, 160, - 7, 7, 192, 243, 64, 7, 6, 48, 243, 208, 8, 6, 160, 243, 112, 8, 5, 96, 243, 224, 16, 8, 0, 16, - 1, 16, 112, 244, 128, 9, 0, 224, 247, 192, 10, 0, 224, 246, 224, 32, 10, 0, 224, 245, 208, 48, 11, 0, - 176, 224, 241, 208, 160, 96, 13, 16, 254, 160, 16, 254, 160, 16, 254, 160, 16, 233, 244, 144, 9, 112, 243, 208, - 16, 8, 48, 244, 64, 0, 8, 192, 243, 128, 1, 7, 144, 243, 192, 2, 6, 64, 243, 224, 32, 2, 5, 16, - 224, 243, 96, 3, 5, 176, 243, 160, 4, 4, 96, 243, 208, 16, 4, 3, 32, 224, 243, 64, 5, 3, 192, 243, - 128, 6, 2, 128, 243, 192, 7, 1, 64, 243, 224, 32, 7, 0, 16, 208, 243, 96, 8, 0, 160, 243, 160, 9, - 96, 245, 233, 160, 255, 160, 255, 160, 255, 9, 176, 244, 128, 9, 8, 16, 245, 224, 9, 8, 112, 246, 64, 8, - 8, 192, 246, 160, 8, 7, 48, 243, 176, 243, 16, 7, 7, 144, 243, 64, 243, 96, 7, 7, 224, 242, 176, 0, - 224, 242, 192, 7, 6, 80, 243, 112, 0, 144, 243, 32, 6, 6, 176, 243, 48, 0, 80, 243, 128, 6, 5, 16, - 243, 208, 2, 224, 242, 224, 6, 5, 112, 243, 128, 2, 144, 243, 64, 5, 5, 192, 243, 32, 2, 64, 243, 160, - 5, 4, 48, 243, 192, 4, 208, 243, 16, 4, 4, 144, 243, 96, 4, 128, 243, 96, 4, 4, 224, 243, 16, 4, - 32, 243, 192, 4, 3, 80, 243, 160, 6, 192, 243, 32, 3, 3, 160, 244, 230, 244, 128, 3, 2, 16, 255, 241, - 208, 3, 2, 112, 255, 242, 64, 2, 2, 192, 255, 242, 160, 2, 1, 48, 243, 224, 9, 32, 244, 16, 1, 1, - 144, 243, 144, 10, 192, 243, 96, 1, 1, 224, 243, 64, 10, 112, 243, 192, 1, 0, 80, 243, 224, 11, 32, 244, - 32, 0, 0, 160, 243, 160, 12, 192, 243, 128, 0, 16, 244, 80, 12, 112, 243, 208, 0, 112, 243, 224, 13, 32, - 244, 64, 192, 243, 160, 14, 192, 243, 160, 192, 243, 96, 12, 32, 244, 16, 112, 243, 176, 12, 128, 243, 176, 0, - 32, 244, 16, 11, 208, 243, 80, 0, 0, 192, 243, 96, 10, 48, 243, 224, 16, 0, 0, 96, 243, 176, 10, 128, - 243, 160, 1, 0, 16, 244, 16, 9, 208, 243, 64, 1, 1, 176, 243, 96, 8, 48, 243, 224, 2, 1, 80, 243, - 176, 8, 128, 243, 144, 2, 1, 16, 224, 243, 16, 7, 208, 243, 64, 2, 2, 160, 243, 96, 6, 48, 243, 208, - 3, 2, 64, 243, 176, 6, 128, 243, 128, 3, 3, 224, 243, 16, 5, 208, 243, 48, 3, 3, 144, 243, 96, 4, - 48, 243, 192, 4, 3, 64, 243, 176, 4, 128, 243, 112, 4, 4, 208, 243, 16, 3, 208, 243, 32, 4, 4, 128, - 243, 96, 2, 48, 243, 192, 5, 4, 48, 243, 176, 2, 128, 243, 96, 5, 5, 192, 243, 16, 1, 208, 243, 16, - 5, 5, 112, 243, 96, 0, 48, 243, 176, 6, 5, 32, 243, 160, 0, 112, 243, 80, 6, 6, 192, 242, 224, 0, - 176, 242, 224, 16, 6, 6, 96, 243, 64, 243, 160, 7, 6, 16, 243, 160, 243, 64, 7, 7, 176, 246, 224, 8, - 7, 80, 246, 144, 8, 7, 16, 224, 245, 64, 8, 8, 160, 244, 208, 9, 8, 80, 244, 128, 9, 64, 245, 80, - 11, 160, 243, 64, 245, 224, 16, 10, 160, 243, 64, 246, 144, 10, 160, 243, 64, 247, 48, 9, 160, 243, 64, 247, - 192, 9, 160, 243, 64, 248, 96, 8, 160, 243, 64, 243, 192, 243, 224, 16, 7, 160, 243, 64, 243, 48, 244, 160, - 7, 160, 243, 64, 243, 16, 128, 244, 64, 6, 160, 243, 64, 243, 32, 16, 208, 243, 208, 6, 160, 243, 64, 243, - 48, 0, 64, 244, 128, 5, 160, 243, 64, 243, 48, 1, 160, 244, 32, 4, 160, 243, 64, 243, 64, 1, 32, 224, - 243, 176, 4, 160, 243, 64, 243, 64, 2, 96, 244, 80, 3, 160, 243, 64, 243, 80, 3, 192, 243, 224, 16, 2, - 160, 243, 64, 243, 80, 3, 48, 244, 144, 2, 144, 243, 64, 243, 80, 4, 128, 244, 48, 1, 144, 243, 64, 243, - 80, 4, 16, 208, 243, 192, 1, 128, 243, 64, 243, 80, 5, 64, 244, 96, 0, 128, 243, 64, 243, 80, 6, 160, - 243, 224, 16, 112, 243, 64, 243, 80, 6, 32, 224, 243, 160, 96, 243, 64, 243, 80, 7, 96, 244, 160, 243, 64, - 243, 80, 8, 192, 248, 64, 243, 80, 8, 48, 248, 64, 243, 80, 9, 128, 247, 64, 243, 80, 9, 16, 208, 246, - 64, 243, 80, 10, 64, 246, 64, 243, 80, 11, 160, 245, 112, 248, 224, 208, 176, 128, 64, 7, 112, 253, 208, 96, - 5, 112, 255, 160, 4, 112, 244, 226, 248, 128, 3, 112, 243, 192, 3, 16, 64, 144, 245, 32, 2, 112, 243, 192, - 6, 80, 244, 112, 2, 112, 243, 192, 7, 176, 243, 176, 2, 112, 243, 192, 7, 112, 243, 192, 2, 112, 243, 192, - 7, 96, 243, 208, 2, 112, 243, 192, 7, 128, 243, 176, 2, 112, 243, 192, 7, 208, 243, 128, 2, 112, 243, 192, - 6, 112, 244, 32, 2, 112, 243, 192, 3, 32, 80, 176, 244, 128, 3, 112, 255, 160, 4, 112, 254, 112, 5, 112, - 252, 192, 32, 6, 112, 244, 227, 243, 224, 32, 6, 112, 243, 192, 3, 160, 243, 176, 6, 112, 243, 192, 3, 32, - 224, 243, 96, 5, 112, 243, 192, 4, 112, 243, 224, 16, 4, 112, 243, 192, 5, 208, 243, 160, 4, 112, 243, 192, - 5, 64, 244, 80, 3, 112, 243, 192, 6, 160, 243, 224, 16, 2, 112, 243, 192, 6, 32, 244, 144, 2, 112, 243, - 192, 7, 112, 244, 64, 1, 112, 243, 192, 8, 208, 243, 208, 16, 0, 112, 243, 192, 8, 80, 244, 128, 0, 112, - 243, 192, 9, 176, 244, 48, 7, 64, 128, 176, 208, 224, 240, 225, 192, 144, 96, 16, 7, 5, 96, 208, 251, 144, - 32, 5, 3, 32, 192, 254, 224, 96, 4, 2, 48, 224, 255, 241, 128, 3, 1, 16, 208, 244, 224, 128, 48, 16, - 1, 32, 80, 176, 245, 96, 2, 1, 160, 244, 176, 16, 7, 80, 245, 32, 1, 0, 48, 244, 176, 10, 80, 244, - 160, 1, 0, 144, 244, 32, 11, 160, 244, 16, 0, 0, 224, 243, 160, 12, 48, 244, 96, 0, 48, 244, 80, 13, - 208, 243, 160, 0, 96, 244, 16, 13, 160, 243, 224, 0, 144, 243, 208, 14, 112, 244, 16, 160, 243, 192, 14, 96, - 244, 32, 176, 243, 176, 14, 80, 244, 48, 160, 243, 176, 14, 80, 244, 48, 160, 243, 192, 14, 80, 244, 32, 128, - 243, 208, 14, 112, 244, 16, 96, 244, 16, 13, 160, 243, 208, 0, 48, 244, 80, 13, 208, 243, 160, 0, 0, 224, - 243, 160, 12, 48, 244, 96, 0, 0, 144, 244, 32, 11, 160, 244, 16, 0, 0, 48, 244, 176, 10, 80, 244, 144, - 1, 1, 144, 244, 176, 16, 7, 80, 244, 224, 32, 1, 1, 16, 208, 244, 224, 128, 48, 16, 1, 32, 80, 176, - 245, 96, 2, 2, 32, 208, 255, 241, 112, 3, 3, 32, 192, 254, 224, 96, 4, 5, 96, 208, 251, 144, 32, 5, - 7, 64, 128, 176, 208, 224, 241, 224, 192, 144, 96, 16, 7, 64, 243, 208, 11, 144, 243, 128, 64, 243, 208, 11, - 144, 243, 128, 64, 243, 208, 11, 144, 243, 128, 64, 243, 208, 11, 144, 243, 128, 64, 243, 208, 11, 144, 243, 128, - 64, 243, 208, 11, 144, 243, 128, 64, 243, 208, 11, 144, 243, 128, 64, 243, 208, 11, 144, 243, 128, 64, 243, 208, - 11, 144, 243, 128, 64, 243, 208, 11, 144, 243, 128, 64, 243, 208, 11, 144, 243, 128, 64, 244, 235, 244, 128, 64, - 255, 245, 128, 64, 255, 245, 128, 64, 255, 245, 128, 64, 243, 208, 11, 144, 243, 128, 64, 243, 208, 11, 144, 243, - 128, 64, 243, 208, 11, 144, 243, 128, 64, 243, 208, 11, 144, 243, 128, 64, 243, 208, 11, 144, 243, 128, 64, 243, - 208, 11, 144, 243, 128, 64, 243, 208, 11, 144, 243, 128, 64, 243, 208, 11, 144, 243, 128, 64, 243, 208, 11, 144, - 243, 128, 64, 243, 208, 11, 144, 243, 128, 64, 243, 208, 11, 144, 243, 128, 64, 243, 208, 11, 144, 243, 128, 64, - 243, 208, 11, 144, 243, 128, 4, 16, 96, 160, 208, 224, 240, 225, 192, 144, 96, 32, 2, 3, 112, 224, 250, 192, - 96, 0, 2, 160, 253, 144, 0, 1, 144, 254, 48, 0, 0, 32, 244, 192, 80, 16, 1, 32, 80, 144, 208, 240, - 192, 1, 0, 112, 243, 192, 8, 65, 1, 0, 160, 243, 96, 12, 0, 176, 243, 80, 12, 0, 160, 243, 144, 12, - 0, 128, 244, 80, 11, 0, 48, 245, 160, 32, 9, 1, 144, 246, 160, 48, 7, 2, 176, 247, 192, 80, 5, 3, - 144, 248, 192, 64, 3, 4, 64, 192, 248, 128, 2, 6, 64, 176, 247, 160, 1, 8, 48, 144, 246, 96, 0, 10, - 32, 176, 244, 208, 0, 12, 128, 244, 32, 13, 224, 243, 64, 13, 192, 243, 64, 13, 224, 243, 48, 16, 192, 96, - 16, 8, 96, 243, 224, 0, 16, 242, 176, 112, 64, 16, 2, 48, 144, 244, 128, 0, 16, 255, 208, 16, 0, 16, - 254, 208, 32, 1, 16, 176, 251, 224, 128, 16, 2, 1, 32, 96, 144, 176, 208, 224, 241, 224, 192, 144, 96, 16, - 4, 160, 243, 96, 9, 144, 243, 144, 9, 80, 243, 192, 96, 243, 160, 9, 208, 243, 224, 9, 144, 243, 128, 32, - 243, 224, 8, 48, 245, 48, 8, 192, 243, 64, 0, 208, 243, 48, 7, 112, 245, 112, 7, 16, 244, 0, 0, 144, - 243, 96, 7, 176, 245, 176, 7, 80, 243, 176, 0, 0, 80, 243, 160, 6, 16, 247, 16, 6, 128, 243, 112, 0, - 0, 16, 243, 224, 6, 64, 242, 225, 242, 80, 6, 192, 243, 48, 0, 1, 192, 243, 32, 5, 128, 242, 177, 242, - 144, 5, 16, 243, 224, 1, 1, 128, 243, 96, 5, 192, 242, 129, 242, 208, 5, 64, 243, 160, 1, 1, 80, 243, - 160, 4, 32, 243, 81, 243, 32, 4, 128, 243, 96, 1, 1, 16, 243, 208, 4, 96, 243, 17, 243, 96, 4, 192, - 243, 32, 1, 2, 192, 243, 32, 3, 160, 242, 208, 1, 192, 242, 176, 3, 16, 243, 208, 2, 2, 128, 243, 96, - 3, 224, 242, 128, 1, 128, 242, 224, 3, 64, 243, 144, 2, 2, 64, 243, 144, 2, 48, 243, 64, 1, 64, 243, - 64, 2, 128, 243, 80, 2, 3, 224, 242, 208, 2, 112, 243, 16, 2, 224, 242, 128, 2, 176, 243, 16, 2, 3, - 176, 243, 32, 1, 176, 242, 176, 3, 160, 242, 208, 2, 243, 192, 3, 3, 112, 243, 80, 0, 16, 243, 112, 3, - 96, 243, 32, 0, 64, 243, 128, 3, 3, 48, 243, 144, 0, 64, 243, 48, 3, 32, 243, 96, 0, 112, 243, 64, - 3, 4, 224, 242, 192, 0, 128, 242, 208, 5, 208, 242, 144, 0, 176, 243, 16, 3, 4, 160, 243, 0, 176, 242, - 144, 5, 128, 242, 192, 0, 224, 242, 176, 4, 4, 96, 243, 48, 224, 242, 80, 5, 64, 243, 32, 243, 112, 4, - 4, 32, 243, 112, 243, 16, 6, 224, 242, 112, 243, 48, 4, 5, 208, 242, 192, 242, 192, 7, 160, 242, 192, 242, - 224, 5, 5, 144, 246, 112, 7, 96, 246, 176, 5, 5, 80, 246, 48, 7, 32, 246, 112, 5, 5, 16, 245, 224, - 9, 208, 245, 48, 5, 6, 208, 244, 160, 9, 128, 244, 224, 6, 6, 144, 244, 96, 9, 64, 244, 160, 6, 0, - 80, 192, 224, 208, 80, 5, 80, 192, 224, 208, 96, 5, 80, 192, 224, 208, 96, 0, 48, 244, 64, 3, 48, 244, - 64, 3, 32, 244, 80, 112, 244, 128, 3, 112, 244, 128, 3, 96, 244, 144, 112, 244, 128, 3, 112, 244, 128, 3, - 96, 244, 144, 48, 244, 64, 3, 48, 244, 64, 3, 32, 244, 80, 0, 80, 208, 224, 208, 80, 5, 80, 192, 224, - 208, 96, 5, 80, 192, 224, 208, 96, 0, - ], -}; - -/// NotoSans-Medium at 26 px: 97 glyphs, 9784 B of 4-bit coverage. -pub static S: Font = Font { - ascent: 28, - descent: 8, - cap: 18, - rle: false, - glyphs: &[ - Glyph { c: ' ', adv: 7, x: 0, y: 0, w: 0, h: 0, off: 0 }, - Glyph { c: '!', adv: 7, x: 1, y: -18, w: 5, h: 18, off: 0 }, - Glyph { c: '"', adv: 11, x: 1, y: -18, w: 9, h: 7, off: 45 }, - Glyph { c: '#', adv: 17, x: 0, y: -18, w: 17, h: 18, off: 77 }, - Glyph { c: '$', adv: 15, x: 1, y: -19, w: 13, h: 21, off: 230 }, - Glyph { c: '%', adv: 22, x: 1, y: -18, w: 20, h: 18, off: 367 }, - Glyph { c: '&', adv: 19, x: 1, y: -18, w: 18, h: 18, off: 547 }, - Glyph { c: '\'', adv: 6, x: 1, y: -18, w: 4, h: 7, off: 709 }, - Glyph { c: '(', adv: 8, x: 1, y: -18, w: 7, h: 22, off: 723 }, - Glyph { c: ')', adv: 8, x: 0, y: -18, w: 8, h: 22, off: 800 }, - Glyph { c: '*', adv: 14, x: 1, y: -19, w: 13, h: 12, off: 888 }, - Glyph { c: '+', adv: 15, x: 1, y: -15, w: 13, h: 12, off: 966 }, - Glyph { c: ',', adv: 7, x: 1, y: -3, w: 5, h: 6, off: 1044 }, - Glyph { c: '-', adv: 8, x: 1, y: -9, w: 7, h: 3, off: 1059 }, - Glyph { c: '.', adv: 7, x: 1, y: -4, w: 5, h: 4, off: 1070 }, - Glyph { c: '/', adv: 10, x: 0, y: -18, w: 10, h: 18, off: 1080 }, - Glyph { c: '0', adv: 15, x: 1, y: -18, w: 13, h: 18, off: 1170 }, - Glyph { c: '1', adv: 15, x: 2, y: -18, w: 8, h: 18, off: 1287 }, - Glyph { c: '2', adv: 15, x: 1, y: -18, w: 13, h: 18, off: 1359 }, - Glyph { c: '3', adv: 15, x: 1, y: -18, w: 13, h: 18, off: 1476 }, - Glyph { c: '4', adv: 15, x: 0, y: -18, w: 15, h: 18, off: 1593 }, - Glyph { c: '5', adv: 15, x: 1, y: -18, w: 13, h: 18, off: 1728 }, - Glyph { c: '6', adv: 15, x: 1, y: -18, w: 13, h: 18, off: 1845 }, - Glyph { c: '7', adv: 15, x: 1, y: -18, w: 13, h: 18, off: 1962 }, - Glyph { c: '8', adv: 15, x: 1, y: -18, w: 13, h: 18, off: 2079 }, - Glyph { c: '9', adv: 15, x: 1, y: -18, w: 13, h: 18, off: 2196 }, - Glyph { c: ':', adv: 7, x: 1, y: -14, w: 5, h: 14, off: 2313 }, - Glyph { c: ';', adv: 7, x: 0, y: -14, w: 6, h: 18, off: 2348 }, - Glyph { c: '<', adv: 15, x: 1, y: -16, w: 13, h: 13, off: 2402 }, - Glyph { c: '=', adv: 15, x: 1, y: -13, w: 13, h: 8, off: 2487 }, - Glyph { c: '>', adv: 15, x: 1, y: -16, w: 13, h: 13, off: 2539 }, - Glyph { c: '?', adv: 12, x: 0, y: -18, w: 11, h: 18, off: 2624 }, - Glyph { c: '@', adv: 23, x: 1, y: -18, w: 21, h: 20, off: 2723 }, - Glyph { c: 'A', adv: 17, x: 0, y: -18, w: 17, h: 18, off: 2933 }, - Glyph { c: 'B', adv: 17, x: 2, y: -18, w: 14, h: 18, off: 3086 }, - Glyph { c: 'C', adv: 17, x: 1, y: -18, w: 15, h: 18, off: 3212 }, - Glyph { c: 'D', adv: 19, x: 2, y: -18, w: 16, h: 18, off: 3347 }, - Glyph { c: 'E', adv: 14, x: 2, y: -18, w: 11, h: 18, off: 3491 }, - Glyph { c: 'F', adv: 14, x: 2, y: -18, w: 11, h: 18, off: 3590 }, - Glyph { c: 'G', adv: 19, x: 1, y: -18, w: 16, h: 18, off: 3689 }, - Glyph { c: 'H', adv: 19, x: 2, y: -18, w: 15, h: 18, off: 3833 }, - Glyph { c: 'I', adv: 9, x: 1, y: -18, w: 8, h: 18, off: 3968 }, - Glyph { c: 'J', adv: 8, x: -2, y: -18, w: 8, h: 23, off: 4040 }, - Glyph { c: 'K', adv: 16, x: 2, y: -18, w: 15, h: 18, off: 4132 }, - Glyph { c: 'L', adv: 14, x: 2, y: -18, w: 12, h: 18, off: 4267 }, - Glyph { c: 'M', adv: 24, x: 2, y: -18, w: 20, h: 18, off: 4375 }, - Glyph { c: 'N', adv: 20, x: 2, y: -18, w: 16, h: 18, off: 4555 }, - Glyph { c: 'O', adv: 20, x: 1, y: -18, w: 18, h: 18, off: 4699 }, - Glyph { c: 'P', adv: 16, x: 2, y: -18, w: 13, h: 18, off: 4861 }, - Glyph { c: 'Q', adv: 20, x: 1, y: -18, w: 18, h: 22, off: 4978 }, - Glyph { c: 'R', adv: 16, x: 2, y: -18, w: 14, h: 18, off: 5176 }, - Glyph { c: 'S', adv: 14, x: 1, y: -18, w: 13, h: 18, off: 5302 }, - Glyph { c: 'T', adv: 15, x: 0, y: -18, w: 15, h: 18, off: 5419 }, - Glyph { c: 'U', adv: 19, x: 2, y: -18, w: 15, h: 18, off: 5554 }, - Glyph { c: 'V', adv: 16, x: 0, y: -18, w: 16, h: 18, off: 5689 }, - Glyph { c: 'W', adv: 24, x: 0, y: -18, w: 25, h: 18, off: 5833 }, - Glyph { c: 'X', adv: 16, x: 0, y: -18, w: 16, h: 18, off: 6058 }, - Glyph { c: 'Y', adv: 15, x: 0, y: -18, w: 15, h: 18, off: 6202 }, - Glyph { c: 'Z', adv: 15, x: 0, y: -18, w: 14, h: 18, off: 6337 }, - Glyph { c: '[', adv: 9, x: 2, y: -18, w: 6, h: 23, off: 6463 }, - Glyph { c: '\\', adv: 10, x: 0, y: -18, w: 10, h: 18, off: 6532 }, - Glyph { c: ']', adv: 9, x: 0, y: -18, w: 7, h: 23, off: 6622 }, - Glyph { c: '^', adv: 15, x: 1, y: -19, w: 13, h: 12, off: 6703 }, - Glyph { c: '_', adv: 11, x: -1, y: 1, w: 13, h: 3, off: 6781 }, - Glyph { c: '`', adv: 8, x: 1, y: -19, w: 6, h: 4, off: 6801 }, - Glyph { c: 'a', adv: 15, x: 1, y: -14, w: 12, h: 14, off: 6813 }, - Glyph { c: 'b', adv: 16, x: 2, y: -19, w: 13, h: 19, off: 6897 }, - Glyph { c: 'c', adv: 13, x: 1, y: -14, w: 11, h: 14, off: 7021 }, - Glyph { c: 'd', adv: 16, x: 1, y: -19, w: 13, h: 19, off: 7098 }, - Glyph { c: 'e', adv: 15, x: 1, y: -14, w: 13, h: 14, off: 7222 }, - Glyph { c: 'f', adv: 9, x: 0, y: -19, w: 11, h: 19, off: 7313 }, - Glyph { c: 'g', adv: 16, x: 1, y: -14, w: 13, h: 20, off: 7418 }, - Glyph { c: 'h', adv: 16, x: 2, y: -19, w: 13, h: 19, off: 7548 }, - Glyph { c: 'i', adv: 7, x: 2, y: -19, w: 4, h: 19, off: 7672 }, - Glyph { c: 'j', adv: 7, x: -2, y: -19, w: 8, h: 25, off: 7710 }, - Glyph { c: 'k', adv: 15, x: 2, y: -19, w: 13, h: 19, off: 7810 }, - Glyph { c: 'l', adv: 7, x: 2, y: -19, w: 3, h: 19, off: 7934 }, - Glyph { c: 'm', adv: 25, x: 2, y: -14, w: 21, h: 14, off: 7963 }, - Glyph { c: 'n', adv: 16, x: 2, y: -14, w: 13, h: 14, off: 8110 }, - Glyph { c: 'o', adv: 16, x: 1, y: -14, w: 14, h: 14, off: 8201 }, - Glyph { c: 'p', adv: 16, x: 2, y: -14, w: 13, h: 20, off: 8299 }, - Glyph { c: 'q', adv: 16, x: 1, y: -14, w: 13, h: 20, off: 8429 }, - Glyph { c: 'r', adv: 11, x: 2, y: -14, w: 9, h: 14, off: 8559 }, - Glyph { c: 's', adv: 13, x: 1, y: -14, w: 11, h: 14, off: 8622 }, - Glyph { c: 't', adv: 10, x: 0, y: -17, w: 10, h: 17, off: 8699 }, - Glyph { c: 'u', adv: 16, x: 2, y: -14, w: 13, h: 14, off: 8784 }, - Glyph { c: 'v', adv: 14, x: 0, y: -14, w: 14, h: 14, off: 8875 }, - Glyph { c: 'w', adv: 21, x: 0, y: -14, w: 21, h: 14, off: 8973 }, - Glyph { c: 'x', adv: 14, x: 0, y: -14, w: 14, h: 14, off: 9120 }, - Glyph { c: 'y', adv: 14, x: 0, y: -14, w: 14, h: 20, off: 9218 }, - Glyph { c: 'z', adv: 12, x: 0, y: -14, w: 12, h: 14, off: 9358 }, - Glyph { c: '{', adv: 10, x: 0, y: -18, w: 10, h: 23, off: 9442 }, - Glyph { c: '|', adv: 14, x: 6, y: -19, w: 3, h: 25, off: 9557 }, - Glyph { c: '}', adv: 10, x: 0, y: -18, w: 10, h: 23, off: 9595 }, - Glyph { c: '~', adv: 15, x: 1, y: -11, w: 13, h: 4, off: 9710 }, - Glyph { c: '…', adv: 21, x: 1, y: -4, w: 19, h: 4, off: 9736 }, - Glyph { c: '·', adv: 7, x: 1, y: -12, w: 5, h: 4, off: 9774 }, - ], - bits: &[ - 31, 255, 32, 255, 241, 14, 255, 16, 239, 240, 13, 254, 0, 207, 224, 11, 253, 0, 191, 192, 10, 251, 0, 159, - 176, 8, 250, 0, 127, 144, 7, 248, 0, 0, 0, 10, 234, 3, 255, 244, 63, 255, 64, 174, 160, 95, 247, 5, - 255, 115, 255, 96, 79, 246, 47, 245, 2, 255, 65, 255, 64, 31, 243, 15, 242, 0, 255, 32, 239, 16, 14, 241, - 13, 240, 0, 223, 0, 0, 0, 0, 191, 96, 3, 253, 0, 0, 0, 0, 14, 243, 0, 111, 160, 0, 0, 0, - 3, 255, 0, 9, 247, 0, 0, 0, 0, 111, 192, 0, 207, 64, 0, 0, 0, 9, 249, 0, 31, 241, 0, 0, - 111, 255, 255, 255, 255, 255, 255, 242, 6, 255, 255, 255, 255, 255, 255, 255, 32, 19, 52, 255, 51, 59, 248, 51, - 48, 0, 0, 95, 192, 0, 223, 64, 0, 0, 0, 8, 249, 0, 31, 241, 0, 0, 19, 51, 191, 131, 54, 254, - 51, 49, 6, 255, 255, 255, 255, 255, 255, 255, 64, 111, 255, 255, 255, 255, 255, 255, 244, 0, 0, 79, 192, 0, - 207, 80, 0, 0, 0, 7, 249, 0, 31, 241, 0, 0, 0, 0, 175, 96, 4, 253, 0, 0, 0, 0, 13, 243, - 0, 127, 160, 0, 0, 0, 1, 255, 16, 10, 247, 0, 0, 0, 0, 0, 6, 244, 0, 0, 0, 0, 0, 111, - 64, 0, 0, 0, 23, 173, 252, 168, 64, 0, 94, 255, 255, 255, 255, 208, 46, 255, 204, 250, 173, 248, 7, 255, - 112, 111, 64, 3, 32, 143, 243, 6, 244, 0, 0, 6, 255, 144, 111, 64, 0, 0, 30, 255, 203, 244, 0, 0, - 0, 61, 255, 255, 198, 16, 0, 0, 23, 223, 255, 254, 112, 0, 0, 0, 143, 239, 255, 176, 0, 0, 6, 244, - 77, 255, 64, 0, 0, 111, 64, 79, 247, 0, 0, 6, 244, 5, 255, 120, 183, 49, 111, 102, 239, 242, 143, 255, - 255, 255, 255, 247, 4, 190, 255, 255, 254, 164, 0, 0, 1, 56, 245, 0, 0, 0, 0, 0, 111, 64, 0, 0, - 0, 0, 6, 244, 0, 0, 0, 2, 174, 235, 48, 0, 0, 4, 255, 32, 0, 29, 255, 255, 226, 0, 0, 12, - 248, 0, 0, 111, 246, 77, 250, 0, 0, 111, 209, 0, 0, 175, 160, 6, 254, 0, 1, 239, 96, 0, 0, 207, - 112, 2, 255, 16, 8, 252, 0, 0, 0, 223, 96, 1, 255, 32, 47, 243, 0, 0, 0, 207, 112, 2, 255, 16, - 175, 160, 0, 0, 0, 175, 160, 6, 254, 4, 254, 35, 190, 234, 32, 111, 246, 77, 250, 12, 248, 46, 254, 239, - 209, 12, 255, 255, 243, 111, 209, 143, 192, 29, 248, 1, 174, 235, 65, 239, 96, 207, 96, 7, 252, 0, 0, 0, - 8, 252, 0, 239, 64, 4, 254, 0, 0, 0, 47, 243, 0, 255, 64, 4, 255, 0, 0, 0, 175, 160, 0, 239, - 80, 5, 254, 0, 0, 4, 254, 32, 0, 207, 128, 8, 252, 0, 0, 12, 248, 0, 0, 127, 229, 94, 248, 0, - 0, 111, 209, 0, 0, 29, 255, 255, 225, 0, 1, 239, 80, 0, 0, 2, 190, 235, 32, 0, 2, 157, 254, 199, - 16, 0, 0, 0, 0, 62, 255, 255, 255, 192, 0, 0, 0, 0, 191, 248, 52, 207, 246, 0, 0, 0, 0, 255, - 176, 0, 47, 249, 0, 0, 0, 0, 239, 160, 0, 31, 249, 0, 0, 0, 0, 191, 225, 0, 143, 245, 0, 0, - 0, 0, 63, 251, 25, 255, 160, 0, 0, 0, 0, 7, 255, 255, 249, 0, 0, 0, 0, 0, 6, 255, 255, 80, - 0, 0, 0, 0, 1, 191, 250, 239, 193, 0, 0, 223, 224, 12, 255, 96, 78, 253, 32, 4, 255, 144, 111, 249, - 0, 4, 239, 227, 10, 255, 48, 175, 244, 0, 0, 62, 254, 143, 250, 0, 175, 244, 0, 0, 3, 239, 255, 226, - 0, 143, 249, 0, 0, 0, 143, 255, 144, 0, 47, 255, 165, 52, 124, 255, 255, 248, 0, 5, 255, 255, 255, 255, - 250, 61, 255, 128, 0, 40, 206, 254, 200, 32, 2, 223, 249, 95, 247, 63, 246, 47, 245, 31, 244, 15, 242, 14, - 241, 13, 240, 0, 8, 254, 16, 4, 255, 96, 0, 223, 176, 0, 111, 245, 0, 12, 253, 0, 2, 255, 128, 0, - 95, 244, 0, 9, 255, 16, 0, 191, 208, 0, 13, 252, 0, 0, 239, 176, 0, 14, 251, 0, 0, 223, 192, 0, - 12, 253, 0, 0, 159, 241, 0, 6, 255, 64, 0, 47, 248, 0, 0, 207, 208, 0, 6, 255, 64, 0, 13, 251, - 0, 0, 79, 245, 0, 0, 143, 225, 29, 249, 0, 0, 4, 255, 80, 0, 0, 175, 225, 0, 0, 63, 247, 0, - 0, 12, 253, 0, 0, 7, 255, 48, 0, 3, 255, 112, 0, 0, 239, 176, 0, 0, 207, 208, 0, 0, 191, 224, - 0, 0, 159, 240, 0, 0, 159, 241, 0, 0, 175, 240, 0, 0, 207, 208, 0, 0, 239, 176, 0, 3, 255, 112, - 0, 6, 255, 64, 0, 12, 254, 0, 0, 63, 248, 0, 0, 175, 225, 0, 4, 255, 96, 0, 13, 250, 0, 0, - 0, 0, 79, 246, 0, 0, 0, 0, 2, 255, 80, 0, 0, 0, 0, 31, 243, 0, 0, 5, 48, 0, 239, 16, - 3, 96, 207, 234, 109, 245, 157, 255, 14, 255, 255, 255, 255, 255, 242, 18, 69, 207, 253, 84, 50, 0, 0, 79, - 237, 247, 0, 0, 0, 46, 248, 111, 244, 0, 0, 11, 255, 16, 223, 209, 0, 2, 207, 144, 6, 253, 64, 0, - 0, 66, 0, 6, 0, 0, 0, 0, 10, 247, 0, 0, 0, 0, 0, 175, 112, 0, 0, 0, 0, 10, 247, 0, - 0, 0, 0, 0, 175, 112, 0, 0, 35, 51, 59, 248, 51, 51, 27, 255, 255, 255, 255, 255, 249, 191, 255, 255, - 255, 255, 255, 144, 0, 0, 175, 112, 0, 0, 0, 0, 10, 247, 0, 0, 0, 0, 0, 175, 112, 0, 0, 0, - 0, 10, 247, 0, 0, 0, 0, 0, 175, 112, 0, 0, 12, 255, 32, 255, 208, 63, 247, 6, 255, 32, 175, 160, - 13, 243, 0, 51, 51, 51, 31, 255, 255, 246, 255, 255, 255, 96, 10, 234, 3, 255, 244, 63, 255, 64, 174, 160, - 0, 0, 0, 31, 249, 0, 0, 0, 111, 243, 0, 0, 0, 207, 192, 0, 0, 3, 255, 112, 0, 0, 9, 255, - 16, 0, 0, 14, 250, 0, 0, 0, 95, 244, 0, 0, 0, 191, 208, 0, 0, 2, 255, 128, 0, 0, 8, 255, - 32, 0, 0, 13, 251, 0, 0, 0, 79, 245, 0, 0, 0, 175, 225, 0, 0, 1, 255, 144, 0, 0, 6, 255, - 48, 0, 0, 12, 252, 0, 0, 0, 63, 247, 0, 0, 0, 159, 241, 0, 0, 0, 0, 5, 190, 253, 163, 0, - 0, 9, 255, 255, 255, 246, 0, 7, 255, 197, 54, 223, 243, 0, 239, 209, 0, 2, 255, 176, 79, 247, 0, 0, - 10, 255, 23, 255, 48, 0, 0, 111, 245, 175, 241, 0, 0, 3, 255, 139, 255, 0, 0, 0, 47, 249, 207, 224, - 0, 0, 1, 255, 172, 254, 0, 0, 0, 31, 250, 191, 240, 0, 0, 2, 255, 154, 255, 16, 0, 0, 63, 248, - 127, 243, 0, 0, 6, 255, 83, 255, 112, 0, 0, 175, 242, 13, 253, 16, 0, 47, 251, 0, 95, 252, 83, 109, - 255, 64, 0, 143, 255, 255, 255, 96, 0, 0, 75, 239, 234, 64, 0, 0, 0, 94, 250, 0, 8, 255, 250, 1, - 191, 255, 250, 78, 255, 111, 250, 159, 227, 15, 250, 8, 16, 31, 250, 0, 0, 31, 250, 0, 0, 31, 250, 0, - 0, 31, 250, 0, 0, 31, 250, 0, 0, 31, 250, 0, 0, 31, 250, 0, 0, 31, 250, 0, 0, 31, 250, 0, - 0, 31, 250, 0, 0, 31, 250, 0, 0, 31, 250, 0, 0, 31, 250, 0, 56, 206, 254, 164, 0, 1, 175, 255, - 255, 255, 249, 0, 111, 253, 116, 55, 239, 246, 0, 169, 0, 0, 3, 255, 192, 0, 0, 0, 0, 13, 254, 0, - 0, 0, 0, 0, 223, 208, 0, 0, 0, 0, 47, 251, 0, 0, 0, 0, 8, 255, 80, 0, 0, 0, 4, 255, - 192, 0, 0, 0, 3, 239, 226, 0, 0, 0, 3, 239, 227, 0, 0, 0, 3, 239, 228, 0, 0, 0, 3, 239, - 227, 0, 0, 0, 3, 239, 227, 0, 0, 0, 3, 239, 210, 0, 0, 0, 3, 239, 229, 51, 51, 51, 50, 207, - 255, 255, 255, 255, 255, 172, 255, 255, 255, 255, 255, 250, 1, 106, 222, 254, 182, 0, 5, 239, 255, 255, 255, 252, - 16, 79, 233, 83, 54, 223, 249, 0, 49, 0, 0, 2, 255, 208, 0, 0, 0, 0, 13, 254, 0, 0, 0, 0, - 3, 255, 160, 0, 0, 0, 39, 239, 210, 0, 1, 255, 255, 252, 112, 0, 0, 31, 255, 255, 218, 48, 0, 0, - 51, 53, 142, 255, 96, 0, 0, 0, 0, 45, 255, 32, 0, 0, 0, 0, 127, 246, 0, 0, 0, 0, 6, 255, - 112, 0, 0, 0, 0, 143, 246, 48, 0, 0, 0, 46, 255, 45, 216, 83, 52, 142, 255, 128, 223, 255, 255, 255, - 255, 144, 3, 139, 222, 254, 200, 48, 0, 0, 0, 0, 0, 79, 252, 0, 0, 0, 0, 0, 30, 255, 192, 0, - 0, 0, 0, 11, 255, 252, 0, 0, 0, 0, 6, 253, 207, 192, 0, 0, 0, 3, 255, 92, 252, 0, 0, 0, - 0, 207, 160, 223, 192, 0, 0, 0, 159, 209, 13, 252, 0, 0, 0, 79, 243, 0, 223, 192, 0, 0, 30, 247, - 0, 13, 252, 0, 0, 11, 252, 0, 0, 223, 192, 0, 6, 254, 32, 0, 13, 252, 0, 3, 255, 131, 51, 51, - 223, 195, 49, 127, 255, 255, 255, 255, 255, 255, 103, 255, 255, 255, 255, 255, 255, 246, 0, 0, 0, 0, 13, 252, - 0, 0, 0, 0, 0, 0, 223, 192, 0, 0, 0, 0, 0, 13, 252, 0, 0, 0, 0, 0, 0, 223, 192, 0, - 6, 255, 255, 255, 255, 243, 0, 127, 255, 255, 255, 255, 48, 8, 255, 51, 51, 51, 48, 0, 159, 224, 0, 0, - 0, 0, 11, 253, 0, 0, 0, 0, 0, 207, 176, 0, 0, 0, 0, 13, 250, 18, 33, 0, 0, 0, 239, 255, - 255, 253, 129, 0, 14, 255, 255, 255, 255, 227, 0, 21, 33, 1, 92, 255, 192, 0, 0, 0, 0, 28, 255, 64, - 0, 0, 0, 0, 127, 246, 0, 0, 0, 0, 6, 255, 96, 0, 0, 0, 0, 143, 244, 32, 0, 0, 0, 46, - 254, 23, 217, 83, 53, 142, 255, 96, 127, 255, 255, 255, 255, 112, 1, 123, 222, 254, 200, 32, 0, 0, 0, 23, - 189, 239, 229, 0, 0, 110, 255, 255, 255, 96, 0, 127, 254, 133, 51, 66, 0, 63, 251, 16, 0, 0, 0, 11, - 254, 16, 0, 0, 0, 1, 255, 112, 0, 0, 0, 0, 95, 244, 58, 239, 217, 32, 8, 255, 111, 255, 255, 254, - 64, 159, 254, 214, 52, 175, 254, 26, 255, 193, 0, 0, 159, 246, 175, 244, 0, 0, 2, 255, 169, 255, 16, 0, - 0, 15, 251, 143, 243, 0, 0, 0, 255, 164, 255, 128, 0, 0, 63, 248, 13, 254, 32, 0, 10, 255, 64, 79, - 254, 99, 91, 255, 176, 0, 111, 255, 255, 255, 193, 0, 0, 57, 223, 236, 96, 0, 255, 255, 255, 255, 255, 255, - 191, 255, 255, 255, 255, 255, 251, 51, 51, 51, 51, 56, 255, 96, 0, 0, 0, 0, 223, 224, 0, 0, 0, 0, - 95, 247, 0, 0, 0, 0, 12, 254, 16, 0, 0, 0, 4, 255, 144, 0, 0, 0, 0, 191, 242, 0, 0, 0, - 0, 63, 250, 0, 0, 0, 0, 10, 255, 48, 0, 0, 0, 2, 255, 176, 0, 0, 0, 0, 159, 244, 0, 0, - 0, 0, 31, 253, 0, 0, 0, 0, 8, 255, 96, 0, 0, 0, 1, 239, 224, 0, 0, 0, 0, 127, 247, 0, - 0, 0, 0, 14, 254, 16, 0, 0, 0, 6, 255, 144, 0, 0, 0, 0, 23, 190, 254, 182, 0, 0, 45, 255, - 255, 255, 252, 16, 12, 255, 164, 53, 207, 250, 2, 255, 160, 0, 0, 223, 224, 63, 247, 0, 0, 10, 255, 17, - 255, 176, 0, 0, 223, 208, 8, 255, 145, 1, 175, 245, 0, 9, 255, 233, 239, 229, 0, 0, 7, 255, 255, 226, - 0, 0, 8, 255, 237, 255, 230, 0, 11, 255, 129, 4, 223, 248, 6, 255, 96, 0, 0, 175, 244, 191, 224, 0, - 0, 1, 255, 156, 254, 0, 0, 0, 31, 249, 175, 244, 0, 0, 7, 255, 116, 255, 232, 67, 89, 255, 225, 7, - 255, 255, 255, 255, 227, 0, 3, 156, 239, 236, 113, 0, 0, 23, 206, 237, 130, 0, 0, 45, 255, 255, 255, 229, - 0, 29, 255, 164, 54, 239, 243, 6, 255, 128, 0, 2, 239, 192, 175, 241, 0, 0, 7, 255, 60, 254, 0, 0, - 0, 63, 247, 207, 240, 0, 0, 3, 255, 137, 255, 80, 0, 0, 175, 249, 79, 254, 81, 19, 175, 255, 144, 159, - 255, 255, 255, 127, 248, 0, 109, 255, 252, 68, 255, 96, 0, 1, 33, 0, 111, 244, 0, 0, 0, 0, 11, 254, - 16, 0, 0, 0, 3, 255, 144, 0, 0, 0, 3, 223, 242, 0, 52, 51, 89, 255, 245, 0, 8, 255, 255, 255, - 229, 0, 0, 110, 254, 219, 97, 0, 0, 10, 234, 3, 255, 244, 63, 255, 64, 174, 160, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 234, 3, 255, 244, 63, 255, 64, 174, 160, 0, 174, 160, 3, - 255, 243, 3, 255, 243, 0, 174, 160, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 224, 2, 255, 160, 5, 255, 80, 9, 254, 0, 12, 247, 0, 31, - 241, 0, 0, 0, 0, 0, 0, 6, 112, 0, 0, 0, 0, 109, 249, 0, 0, 0, 6, 223, 253, 80, 0, 0, - 109, 255, 197, 0, 0, 6, 223, 252, 80, 0, 0, 109, 255, 180, 0, 0, 0, 191, 251, 48, 0, 0, 0, 10, - 255, 233, 48, 0, 0, 0, 4, 175, 255, 181, 0, 0, 0, 0, 40, 239, 253, 113, 0, 0, 0, 1, 125, 255, - 250, 48, 0, 0, 0, 5, 191, 249, 0, 0, 0, 0, 0, 57, 144, 35, 51, 51, 51, 51, 51, 26, 255, 255, - 255, 255, 255, 247, 175, 255, 255, 255, 255, 255, 112, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, - 51, 51, 51, 51, 51, 49, 175, 255, 255, 255, 255, 255, 122, 255, 255, 255, 255, 255, 247, 133, 0, 0, 0, 0, - 0, 11, 252, 80, 0, 0, 0, 0, 110, 255, 197, 0, 0, 0, 0, 23, 223, 252, 80, 0, 0, 0, 0, 109, - 255, 197, 0, 0, 0, 0, 5, 207, 252, 80, 0, 0, 0, 0, 76, 255, 128, 0, 0, 0, 58, 255, 247, 0, - 0, 22, 207, 255, 147, 0, 2, 142, 255, 231, 16, 0, 75, 255, 252, 80, 0, 0, 11, 255, 164, 0, 0, 0, - 0, 168, 32, 0, 0, 0, 0, 0, 3, 140, 239, 236, 113, 7, 255, 255, 255, 255, 209, 47, 182, 67, 91, 255, - 144, 16, 0, 0, 13, 253, 0, 0, 0, 0, 191, 224, 0, 0, 0, 30, 251, 0, 0, 0, 27, 255, 64, 0, - 0, 61, 255, 80, 0, 0, 78, 253, 48, 0, 0, 13, 252, 16, 0, 0, 3, 255, 32, 0, 0, 0, 95, 208, - 0, 0, 0, 1, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 237, 48, 0, 0, 0, 223, 249, 0, 0, - 0, 13, 255, 144, 0, 0, 0, 94, 210, 0, 0, 0, 0, 0, 21, 173, 239, 236, 148, 0, 0, 0, 0, 0, - 126, 255, 255, 255, 255, 252, 32, 0, 0, 2, 207, 253, 133, 51, 70, 175, 255, 80, 0, 1, 223, 230, 0, 0, - 0, 0, 43, 255, 48, 0, 191, 210, 0, 91, 239, 219, 129, 10, 253, 0, 95, 243, 0, 159, 255, 255, 255, 80, - 30, 245, 12, 248, 0, 111, 250, 67, 95, 244, 0, 143, 161, 255, 32, 14, 250, 0, 0, 255, 48, 5, 252, 95, - 208, 3, 255, 32, 0, 31, 243, 0, 63, 231, 251, 0, 95, 224, 0, 2, 255, 32, 3, 254, 143, 144, 5, 254, - 0, 0, 79, 241, 0, 95, 200, 250, 0, 79, 242, 0, 9, 255, 32, 10, 248, 127, 192, 1, 239, 178, 22, 254, - 248, 22, 255, 52, 255, 16, 7, 255, 255, 253, 63, 255, 255, 128, 14, 247, 0, 7, 239, 252, 32, 110, 254, 128, - 0, 143, 227, 0, 0, 33, 0, 0, 2, 0, 0, 1, 223, 229, 0, 0, 0, 0, 0, 0, 0, 0, 2, 223, - 253, 133, 51, 53, 122, 225, 0, 0, 0, 1, 159, 255, 255, 255, 255, 255, 16, 0, 0, 0, 0, 39, 189, 255, - 236, 166, 16, 0, 0, 0, 0, 0, 47, 255, 32, 0, 0, 0, 0, 0, 8, 255, 248, 0, 0, 0, 0, 0, - 0, 239, 239, 224, 0, 0, 0, 0, 0, 95, 247, 255, 80, 0, 0, 0, 0, 11, 254, 30, 251, 0, 0, 0, - 0, 2, 255, 160, 159, 242, 0, 0, 0, 0, 143, 244, 4, 255, 112, 0, 0, 0, 13, 254, 0, 13, 253, 0, - 0, 0, 4, 255, 128, 0, 143, 244, 0, 0, 0, 175, 242, 0, 2, 255, 160, 0, 0, 31, 254, 102, 102, 110, - 255, 16, 0, 7, 255, 255, 255, 255, 255, 247, 0, 0, 223, 255, 255, 255, 255, 255, 208, 0, 79, 251, 0, 0, - 0, 12, 255, 64, 10, 255, 80, 0, 0, 0, 95, 249, 1, 239, 224, 0, 0, 0, 0, 239, 225, 111, 248, 0, - 0, 0, 0, 8, 255, 108, 255, 32, 0, 0, 0, 0, 47, 252, 159, 255, 255, 254, 201, 64, 0, 159, 255, 255, - 255, 255, 251, 16, 159, 246, 51, 52, 142, 255, 128, 159, 244, 0, 0, 4, 255, 224, 159, 244, 0, 0, 0, 239, - 240, 159, 244, 0, 0, 0, 239, 224, 159, 244, 0, 0, 5, 255, 144, 159, 246, 51, 52, 126, 253, 16, 159, 255, - 255, 255, 254, 113, 0, 159, 255, 255, 255, 255, 232, 16, 159, 244, 0, 1, 58, 255, 193, 159, 244, 0, 0, 0, - 191, 246, 159, 244, 0, 0, 0, 111, 249, 159, 244, 0, 0, 0, 127, 249, 159, 244, 0, 0, 1, 223, 246, 159, - 246, 51, 51, 108, 255, 225, 159, 255, 255, 255, 255, 253, 48, 159, 255, 255, 255, 235, 97, 0, 0, 0, 4, 156, - 239, 237, 165, 16, 0, 27, 255, 255, 255, 255, 247, 0, 62, 255, 215, 67, 71, 206, 16, 12, 255, 144, 0, 0, - 0, 32, 8, 255, 176, 0, 0, 0, 0, 0, 239, 243, 0, 0, 0, 0, 0, 63, 252, 0, 0, 0, 0, 0, - 6, 255, 144, 0, 0, 0, 0, 0, 127, 248, 0, 0, 0, 0, 0, 6, 255, 128, 0, 0, 0, 0, 0, 95, - 249, 0, 0, 0, 0, 0, 3, 255, 192, 0, 0, 0, 0, 0, 14, 255, 32, 0, 0, 0, 0, 0, 159, 250, - 0, 0, 0, 0, 0, 2, 239, 248, 0, 0, 0, 0, 0, 5, 255, 252, 116, 52, 89, 192, 0, 4, 239, 255, - 255, 255, 255, 0, 0, 1, 107, 223, 254, 218, 96, 159, 255, 255, 253, 200, 48, 0, 0, 159, 255, 255, 255, 255, - 252, 32, 0, 159, 246, 51, 53, 141, 255, 227, 0, 159, 244, 0, 0, 0, 159, 253, 16, 159, 244, 0, 0, 0, - 10, 255, 144, 159, 244, 0, 0, 0, 2, 255, 224, 159, 244, 0, 0, 0, 0, 207, 244, 159, 244, 0, 0, 0, - 0, 159, 246, 159, 244, 0, 0, 0, 0, 143, 247, 159, 244, 0, 0, 0, 0, 143, 246, 159, 244, 0, 0, 0, - 0, 159, 245, 159, 244, 0, 0, 0, 0, 207, 242, 159, 244, 0, 0, 0, 3, 255, 208, 159, 244, 0, 0, 0, - 11, 255, 112, 159, 244, 0, 0, 1, 175, 253, 16, 159, 246, 51, 53, 158, 255, 210, 0, 159, 255, 255, 255, 255, - 250, 16, 0, 159, 255, 255, 237, 183, 32, 0, 0, 143, 255, 255, 255, 255, 232, 255, 255, 255, 255, 254, 143, 246, - 51, 51, 51, 40, 255, 64, 0, 0, 0, 143, 244, 0, 0, 0, 8, 255, 64, 0, 0, 0, 143, 244, 0, 0, - 0, 8, 255, 255, 255, 255, 247, 143, 255, 255, 255, 255, 120, 255, 99, 51, 51, 49, 143, 244, 0, 0, 0, 8, - 255, 64, 0, 0, 0, 143, 244, 0, 0, 0, 8, 255, 64, 0, 0, 0, 143, 244, 0, 0, 0, 8, 255, 99, - 51, 51, 50, 143, 255, 255, 255, 255, 232, 255, 255, 255, 255, 254, 143, 255, 255, 255, 255, 232, 255, 255, 255, 255, - 254, 143, 246, 51, 51, 51, 40, 255, 64, 0, 0, 0, 143, 244, 0, 0, 0, 8, 255, 64, 0, 0, 0, 143, - 244, 0, 0, 0, 8, 255, 64, 0, 0, 0, 143, 255, 255, 255, 255, 104, 255, 255, 255, 255, 246, 143, 246, 51, - 51, 51, 24, 255, 64, 0, 0, 0, 143, 244, 0, 0, 0, 8, 255, 64, 0, 0, 0, 143, 244, 0, 0, 0, - 8, 255, 64, 0, 0, 0, 143, 244, 0, 0, 0, 8, 255, 64, 0, 0, 0, 0, 0, 2, 123, 223, 254, 201, - 81, 0, 1, 159, 255, 255, 255, 255, 248, 0, 29, 255, 233, 83, 52, 123, 225, 0, 207, 252, 32, 0, 0, 0, - 16, 6, 255, 193, 0, 0, 0, 0, 0, 13, 255, 64, 0, 0, 0, 0, 0, 47, 253, 0, 0, 0, 0, 0, - 0, 95, 249, 0, 0, 0, 0, 0, 0, 111, 248, 0, 0, 12, 255, 255, 254, 111, 248, 0, 0, 12, 255, 255, - 254, 95, 249, 0, 0, 2, 51, 61, 254, 63, 252, 0, 0, 0, 0, 13, 254, 14, 255, 32, 0, 0, 0, 13, - 254, 8, 255, 160, 0, 0, 0, 13, 254, 1, 239, 249, 0, 0, 0, 13, 254, 0, 78, 255, 216, 83, 52, 126, - 254, 0, 3, 223, 255, 255, 255, 255, 254, 0, 0, 5, 173, 239, 254, 202, 99, 143, 244, 0, 0, 0, 0, 223, - 232, 255, 64, 0, 0, 0, 13, 254, 143, 244, 0, 0, 0, 0, 223, 232, 255, 64, 0, 0, 0, 13, 254, 143, - 244, 0, 0, 0, 0, 223, 232, 255, 64, 0, 0, 0, 13, 254, 143, 244, 0, 0, 0, 0, 223, 232, 255, 99, - 51, 51, 51, 61, 254, 143, 255, 255, 255, 255, 255, 255, 232, 255, 255, 255, 255, 255, 255, 254, 143, 244, 0, 0, - 0, 0, 223, 232, 255, 64, 0, 0, 0, 13, 254, 143, 244, 0, 0, 0, 0, 223, 232, 255, 64, 0, 0, 0, - 13, 254, 143, 244, 0, 0, 0, 0, 223, 232, 255, 64, 0, 0, 0, 13, 254, 143, 244, 0, 0, 0, 0, 223, - 232, 255, 64, 0, 0, 0, 13, 254, 255, 255, 255, 243, 207, 255, 255, 210, 1, 223, 242, 0, 0, 207, 240, 0, - 0, 207, 240, 0, 0, 207, 240, 0, 0, 207, 240, 0, 0, 207, 240, 0, 0, 207, 240, 0, 0, 207, 240, 0, - 0, 207, 240, 0, 0, 207, 240, 0, 0, 207, 240, 0, 0, 207, 240, 0, 0, 207, 240, 0, 0, 207, 241, 0, - 174, 255, 255, 178, 255, 255, 255, 243, 0, 0, 175, 243, 0, 0, 175, 243, 0, 0, 175, 243, 0, 0, 175, 243, - 0, 0, 175, 243, 0, 0, 175, 243, 0, 0, 175, 243, 0, 0, 175, 243, 0, 0, 175, 243, 0, 0, 175, 243, - 0, 0, 175, 243, 0, 0, 175, 243, 0, 0, 175, 243, 0, 0, 175, 243, 0, 0, 175, 243, 0, 0, 175, 243, - 0, 0, 175, 243, 0, 0, 175, 242, 0, 0, 191, 242, 0, 1, 239, 224, 83, 75, 255, 144, 255, 255, 252, 16, - 223, 252, 113, 0, 143, 244, 0, 0, 0, 127, 251, 8, 255, 64, 0, 0, 95, 252, 16, 143, 244, 0, 0, 79, - 253, 16, 8, 255, 64, 0, 46, 254, 32, 0, 143, 244, 0, 29, 254, 48, 0, 8, 255, 64, 28, 255, 64, 0, - 0, 143, 244, 11, 255, 96, 0, 0, 8, 255, 73, 255, 112, 0, 0, 0, 143, 251, 255, 248, 0, 0, 0, 8, - 255, 255, 239, 244, 0, 0, 0, 143, 254, 53, 255, 225, 0, 0, 8, 255, 80, 9, 255, 176, 0, 0, 143, 244, - 0, 28, 255, 112, 0, 8, 255, 64, 0, 62, 255, 48, 0, 143, 244, 0, 0, 111, 253, 16, 8, 255, 64, 0, - 0, 175, 249, 0, 143, 244, 0, 0, 1, 223, 245, 8, 255, 64, 0, 0, 3, 255, 226, 159, 244, 0, 0, 0, - 0, 159, 244, 0, 0, 0, 0, 159, 244, 0, 0, 0, 0, 159, 244, 0, 0, 0, 0, 159, 244, 0, 0, 0, - 0, 159, 244, 0, 0, 0, 0, 159, 244, 0, 0, 0, 0, 159, 244, 0, 0, 0, 0, 159, 244, 0, 0, 0, - 0, 159, 244, 0, 0, 0, 0, 159, 244, 0, 0, 0, 0, 159, 244, 0, 0, 0, 0, 159, 244, 0, 0, 0, - 0, 159, 244, 0, 0, 0, 0, 159, 244, 0, 0, 0, 0, 159, 248, 102, 102, 102, 97, 159, 255, 255, 255, 255, - 243, 159, 255, 255, 255, 255, 243, 143, 255, 160, 0, 0, 0, 0, 12, 255, 246, 143, 255, 225, 0, 0, 0, 0, - 63, 255, 246, 143, 222, 246, 0, 0, 0, 0, 143, 255, 246, 143, 217, 251, 0, 0, 0, 0, 239, 175, 246, 143, - 228, 255, 32, 0, 0, 5, 255, 95, 246, 143, 240, 223, 112, 0, 0, 10, 251, 79, 246, 143, 240, 143, 208, 0, - 0, 31, 245, 95, 246, 143, 240, 63, 243, 0, 0, 127, 224, 95, 246, 143, 240, 12, 249, 0, 0, 223, 144, 95, - 246, 143, 240, 7, 254, 0, 3, 255, 48, 95, 246, 143, 240, 2, 255, 80, 9, 252, 0, 95, 246, 143, 240, 0, - 191, 176, 14, 247, 0, 95, 246, 143, 240, 0, 111, 241, 95, 241, 0, 95, 246, 143, 240, 0, 31, 247, 191, 160, - 0, 95, 246, 143, 240, 0, 10, 253, 255, 64, 0, 95, 246, 143, 240, 0, 5, 255, 254, 0, 0, 95, 246, 143, - 240, 0, 0, 239, 248, 0, 0, 95, 246, 143, 240, 0, 0, 159, 242, 0, 0, 95, 246, 143, 255, 48, 0, 0, - 0, 13, 251, 143, 255, 192, 0, 0, 0, 13, 251, 143, 255, 246, 0, 0, 0, 13, 251, 143, 238, 254, 16, 0, - 0, 13, 251, 143, 215, 255, 160, 0, 0, 13, 251, 143, 224, 207, 244, 0, 0, 13, 251, 143, 224, 63, 253, 16, - 0, 13, 251, 143, 240, 8, 255, 128, 0, 13, 251, 143, 240, 0, 223, 243, 0, 13, 251, 143, 240, 0, 63, 252, - 0, 13, 251, 143, 240, 0, 9, 255, 96, 13, 251, 143, 240, 0, 1, 223, 226, 13, 251, 143, 240, 0, 0, 79, - 250, 12, 251, 143, 240, 0, 0, 9, 255, 92, 251, 143, 240, 0, 0, 1, 239, 220, 251, 143, 240, 0, 0, 0, - 95, 255, 251, 143, 240, 0, 0, 0, 10, 255, 251, 143, 240, 0, 0, 0, 1, 239, 251, 0, 0, 6, 173, 239, - 236, 130, 0, 0, 0, 3, 223, 255, 255, 255, 255, 112, 0, 0, 95, 255, 182, 51, 72, 239, 249, 0, 1, 239, - 246, 0, 0, 0, 45, 255, 96, 9, 255, 144, 0, 0, 0, 3, 255, 224, 14, 255, 32, 0, 0, 0, 0, 191, - 244, 63, 252, 0, 0, 0, 0, 0, 111, 249, 95, 249, 0, 0, 0, 0, 0, 79, 251, 111, 248, 0, 0, 0, - 0, 0, 63, 252, 111, 248, 0, 0, 0, 0, 0, 63, 252, 95, 249, 0, 0, 0, 0, 0, 79, 250, 63, 252, - 0, 0, 0, 0, 0, 111, 249, 14, 255, 32, 0, 0, 0, 0, 191, 244, 9, 255, 144, 0, 0, 0, 3, 255, - 224, 1, 239, 246, 0, 0, 0, 45, 255, 80, 0, 95, 255, 182, 51, 72, 239, 249, 0, 0, 3, 223, 255, 255, - 255, 255, 112, 0, 0, 0, 22, 189, 255, 236, 130, 0, 0, 159, 255, 255, 237, 166, 0, 9, 255, 255, 255, 255, - 253, 32, 159, 246, 51, 71, 223, 252, 9, 255, 64, 0, 1, 223, 245, 159, 244, 0, 0, 6, 255, 137, 255, 64, - 0, 0, 95, 248, 159, 244, 0, 0, 7, 255, 121, 255, 64, 0, 1, 223, 242, 159, 246, 51, 72, 239, 249, 9, - 255, 255, 255, 255, 249, 0, 159, 255, 255, 236, 147, 0, 9, 255, 64, 0, 0, 0, 0, 159, 244, 0, 0, 0, - 0, 9, 255, 64, 0, 0, 0, 0, 159, 244, 0, 0, 0, 0, 9, 255, 64, 0, 0, 0, 0, 159, 244, 0, - 0, 0, 0, 9, 255, 64, 0, 0, 0, 0, 0, 0, 6, 173, 239, 236, 130, 0, 0, 0, 3, 223, 255, 255, - 255, 255, 112, 0, 0, 95, 255, 182, 51, 72, 239, 249, 0, 1, 239, 246, 0, 0, 0, 45, 255, 80, 9, 255, - 144, 0, 0, 0, 3, 255, 224, 14, 255, 32, 0, 0, 0, 0, 191, 244, 63, 252, 0, 0, 0, 0, 0, 111, - 249, 95, 249, 0, 0, 0, 0, 0, 79, 251, 111, 248, 0, 0, 0, 0, 0, 63, 252, 111, 248, 0, 0, 0, - 0, 0, 63, 252, 95, 249, 0, 0, 0, 0, 0, 79, 251, 63, 252, 0, 0, 0, 0, 0, 111, 249, 14, 255, - 32, 0, 0, 0, 0, 191, 245, 9, 255, 144, 0, 0, 0, 3, 255, 225, 1, 239, 246, 0, 0, 0, 45, 255, - 112, 0, 95, 255, 182, 51, 72, 239, 250, 0, 0, 3, 223, 255, 255, 255, 255, 128, 0, 0, 0, 22, 189, 255, - 255, 226, 0, 0, 0, 0, 0, 0, 0, 191, 250, 0, 0, 0, 0, 0, 0, 0, 29, 255, 160, 0, 0, 0, - 0, 0, 0, 2, 239, 250, 0, 0, 0, 0, 0, 0, 0, 62, 255, 144, 159, 255, 255, 237, 182, 16, 0, 159, - 255, 255, 255, 255, 211, 0, 159, 246, 51, 54, 207, 253, 16, 159, 244, 0, 0, 28, 255, 80, 159, 244, 0, 0, - 7, 255, 144, 159, 244, 0, 0, 5, 255, 144, 159, 244, 0, 0, 7, 255, 112, 159, 244, 0, 0, 29, 255, 48, - 159, 246, 51, 54, 223, 248, 0, 159, 255, 255, 255, 255, 112, 0, 159, 255, 255, 255, 244, 0, 0, 159, 244, 0, - 63, 252, 0, 0, 159, 244, 0, 8, 255, 128, 0, 159, 244, 0, 1, 223, 243, 0, 159, 244, 0, 0, 95, 252, - 0, 159, 244, 0, 0, 10, 255, 128, 159, 244, 0, 0, 2, 239, 243, 159, 244, 0, 0, 0, 111, 252, 0, 23, - 206, 254, 218, 81, 0, 62, 255, 255, 255, 255, 144, 29, 255, 148, 52, 107, 243, 5, 255, 144, 0, 0, 1, 0, - 127, 245, 0, 0, 0, 0, 6, 255, 128, 0, 0, 0, 0, 47, 255, 96, 0, 0, 0, 0, 143, 255, 215, 16, - 0, 0, 0, 127, 255, 254, 146, 0, 0, 0, 41, 239, 255, 246, 0, 0, 0, 1, 109, 255, 246, 0, 0, 0, - 0, 8, 255, 208, 0, 0, 0, 0, 12, 255, 16, 0, 0, 0, 0, 191, 241, 32, 0, 0, 0, 46, 253, 11, - 217, 100, 52, 125, 255, 96, 191, 255, 255, 255, 255, 112, 3, 139, 222, 254, 200, 32, 0, 175, 255, 255, 255, 255, - 255, 255, 74, 255, 255, 255, 255, 255, 255, 244, 35, 51, 52, 255, 179, 51, 51, 16, 0, 0, 31, 251, 0, 0, - 0, 0, 0, 1, 255, 176, 0, 0, 0, 0, 0, 31, 251, 0, 0, 0, 0, 0, 1, 255, 176, 0, 0, 0, - 0, 0, 31, 251, 0, 0, 0, 0, 0, 1, 255, 176, 0, 0, 0, 0, 0, 31, 251, 0, 0, 0, 0, 0, - 1, 255, 176, 0, 0, 0, 0, 0, 31, 251, 0, 0, 0, 0, 0, 1, 255, 176, 0, 0, 0, 0, 0, 31, - 251, 0, 0, 0, 0, 0, 1, 255, 176, 0, 0, 0, 0, 0, 31, 251, 0, 0, 0, 0, 0, 1, 255, 176, - 0, 0, 0, 0, 0, 31, 251, 0, 0, 0, 175, 242, 0, 0, 0, 0, 239, 218, 255, 32, 0, 0, 0, 14, - 253, 175, 242, 0, 0, 0, 0, 239, 218, 255, 32, 0, 0, 0, 14, 253, 175, 242, 0, 0, 0, 0, 239, 218, - 255, 32, 0, 0, 0, 14, 253, 175, 242, 0, 0, 0, 0, 239, 218, 255, 32, 0, 0, 0, 14, 253, 175, 242, - 0, 0, 0, 0, 239, 218, 255, 32, 0, 0, 0, 14, 253, 175, 242, 0, 0, 0, 0, 239, 218, 255, 32, 0, - 0, 0, 14, 253, 159, 243, 0, 0, 0, 0, 255, 182, 255, 112, 0, 0, 0, 95, 248, 30, 254, 32, 0, 0, - 29, 255, 48, 111, 254, 132, 52, 125, 255, 128, 0, 127, 255, 255, 255, 255, 128, 0, 0, 40, 206, 254, 200, 48, - 0, 207, 241, 0, 0, 0, 0, 47, 252, 127, 246, 0, 0, 0, 0, 127, 247, 47, 252, 0, 0, 0, 0, 207, - 241, 11, 255, 32, 0, 0, 2, 255, 176, 6, 255, 112, 0, 0, 8, 255, 80, 1, 239, 192, 0, 0, 13, 254, - 16, 0, 175, 243, 0, 0, 63, 249, 0, 0, 79, 248, 0, 0, 159, 244, 0, 0, 14, 253, 0, 0, 239, 208, - 0, 0, 8, 255, 48, 4, 255, 128, 0, 0, 3, 255, 144, 10, 255, 32, 0, 0, 0, 207, 224, 14, 252, 0, - 0, 0, 0, 127, 244, 79, 247, 0, 0, 0, 0, 47, 248, 159, 241, 0, 0, 0, 0, 11, 252, 223, 176, 0, - 0, 0, 0, 6, 255, 255, 80, 0, 0, 0, 0, 1, 239, 254, 16, 0, 0, 0, 0, 0, 175, 249, 0, 0, - 0, 175, 243, 0, 0, 0, 111, 251, 0, 0, 0, 11, 255, 22, 255, 112, 0, 0, 10, 255, 241, 0, 0, 1, - 255, 192, 47, 251, 0, 0, 0, 239, 255, 80, 0, 0, 79, 248, 0, 223, 224, 0, 0, 79, 253, 249, 0, 0, - 8, 255, 64, 9, 255, 64, 0, 8, 254, 159, 224, 0, 0, 207, 241, 0, 95, 248, 0, 0, 223, 165, 255, 48, - 0, 31, 251, 0, 1, 255, 176, 0, 47, 246, 31, 248, 0, 4, 255, 112, 0, 12, 255, 16, 6, 255, 32, 191, - 192, 0, 143, 243, 0, 0, 143, 244, 0, 191, 208, 7, 255, 32, 12, 254, 0, 0, 4, 255, 128, 14, 248, 0, - 47, 246, 1, 255, 160, 0, 0, 14, 252, 4, 255, 64, 0, 223, 176, 95, 246, 0, 0, 0, 175, 241, 143, 224, - 0, 9, 254, 8, 255, 32, 0, 0, 6, 255, 76, 250, 0, 0, 79, 243, 207, 208, 0, 0, 0, 47, 247, 255, - 96, 0, 0, 239, 127, 248, 0, 0, 0, 0, 223, 207, 241, 0, 0, 10, 252, 255, 64, 0, 0, 0, 9, 255, - 252, 0, 0, 0, 111, 255, 241, 0, 0, 0, 0, 95, 255, 128, 0, 0, 1, 255, 251, 0, 0, 0, 0, 1, - 255, 243, 0, 0, 0, 12, 255, 112, 0, 0, 63, 253, 16, 0, 0, 2, 239, 225, 8, 255, 128, 0, 0, 10, - 255, 80, 0, 223, 243, 0, 0, 95, 250, 0, 0, 63, 252, 0, 1, 223, 225, 0, 0, 8, 255, 112, 9, 255, - 80, 0, 0, 0, 223, 242, 63, 250, 0, 0, 0, 0, 63, 251, 207, 225, 0, 0, 0, 0, 8, 255, 255, 80, - 0, 0, 0, 0, 0, 223, 251, 0, 0, 0, 0, 0, 4, 255, 254, 32, 0, 0, 0, 0, 29, 254, 255, 176, - 0, 0, 0, 0, 159, 245, 143, 246, 0, 0, 0, 4, 255, 160, 29, 254, 32, 0, 0, 29, 254, 16, 4, 255, - 176, 0, 0, 159, 246, 0, 0, 175, 247, 0, 4, 255, 176, 0, 0, 30, 254, 32, 29, 254, 32, 0, 0, 6, - 255, 192, 143, 247, 0, 0, 0, 0, 191, 247, 191, 245, 0, 0, 0, 2, 255, 211, 255, 192, 0, 0, 0, 175, - 245, 9, 255, 80, 0, 0, 63, 252, 0, 46, 253, 0, 0, 11, 255, 48, 0, 143, 246, 0, 3, 255, 160, 0, - 1, 239, 208, 0, 191, 242, 0, 0, 6, 255, 96, 79, 248, 0, 0, 0, 13, 254, 28, 254, 16, 0, 0, 0, - 95, 251, 255, 96, 0, 0, 0, 0, 191, 255, 208, 0, 0, 0, 0, 3, 255, 245, 0, 0, 0, 0, 0, 13, - 255, 0, 0, 0, 0, 0, 0, 223, 240, 0, 0, 0, 0, 0, 13, 255, 0, 0, 0, 0, 0, 0, 223, 240, - 0, 0, 0, 0, 0, 13, 255, 0, 0, 0, 0, 0, 0, 223, 240, 0, 0, 0, 0, 0, 13, 255, 0, 0, - 0, 12, 255, 255, 255, 255, 255, 252, 12, 255, 255, 255, 255, 255, 252, 2, 51, 51, 51, 51, 223, 245, 0, 0, - 0, 0, 7, 255, 144, 0, 0, 0, 0, 63, 253, 16, 0, 0, 0, 0, 207, 244, 0, 0, 0, 0, 8, 255, - 144, 0, 0, 0, 0, 63, 253, 16, 0, 0, 0, 1, 223, 244, 0, 0, 0, 0, 8, 255, 128, 0, 0, 0, - 0, 79, 253, 0, 0, 0, 0, 1, 223, 243, 0, 0, 0, 0, 9, 255, 128, 0, 0, 0, 0, 79, 252, 0, - 0, 0, 0, 1, 223, 243, 0, 0, 0, 0, 9, 255, 147, 51, 51, 51, 51, 31, 255, 255, 255, 255, 255, 255, - 47, 255, 255, 255, 255, 255, 255, 255, 255, 254, 255, 255, 254, 255, 147, 50, 255, 128, 0, 255, 128, 0, 255, 128, - 0, 255, 128, 0, 255, 128, 0, 255, 128, 0, 255, 128, 0, 255, 128, 0, 255, 128, 0, 255, 128, 0, 255, 128, - 0, 255, 128, 0, 255, 128, 0, 255, 128, 0, 255, 128, 0, 255, 128, 0, 255, 128, 0, 255, 255, 254, 255, 255, - 254, 51, 51, 50, 159, 241, 0, 0, 0, 63, 247, 0, 0, 0, 12, 252, 0, 0, 0, 6, 255, 48, 0, 0, - 1, 255, 144, 0, 0, 0, 175, 225, 0, 0, 0, 79, 245, 0, 0, 0, 13, 251, 0, 0, 0, 8, 255, 32, - 0, 0, 2, 255, 128, 0, 0, 0, 191, 208, 0, 0, 0, 95, 244, 0, 0, 0, 14, 250, 0, 0, 0, 9, - 255, 16, 0, 0, 3, 255, 112, 0, 0, 0, 207, 192, 0, 0, 0, 111, 243, 0, 0, 0, 31, 249, 95, 255, - 255, 149, 255, 255, 249, 19, 51, 255, 144, 0, 15, 249, 0, 0, 255, 144, 0, 15, 249, 0, 0, 255, 144, 0, - 15, 249, 0, 0, 255, 144, 0, 15, 249, 0, 0, 255, 144, 0, 15, 249, 0, 0, 255, 144, 0, 15, 249, 0, - 0, 255, 144, 0, 15, 249, 0, 0, 255, 144, 0, 15, 249, 0, 0, 255, 144, 0, 15, 249, 95, 255, 255, 149, - 255, 255, 249, 19, 51, 51, 16, 0, 0, 5, 112, 0, 0, 0, 0, 2, 255, 96, 0, 0, 0, 0, 159, 253, - 0, 0, 0, 0, 30, 252, 247, 0, 0, 0, 8, 249, 63, 225, 0, 0, 1, 239, 48, 191, 128, 0, 0, 127, - 176, 3, 254, 16, 0, 30, 244, 0, 10, 249, 0, 7, 252, 0, 0, 47, 242, 0, 223, 80, 0, 0, 159, 160, - 111, 208, 0, 0, 2, 255, 61, 246, 0, 0, 0, 9, 251, 3, 51, 51, 51, 51, 51, 17, 255, 255, 255, 255, - 255, 245, 31, 255, 255, 255, 255, 255, 80, 191, 249, 0, 28, 255, 64, 1, 191, 209, 0, 8, 251, 0, 39, 190, - 254, 199, 16, 2, 255, 255, 255, 255, 193, 0, 170, 100, 53, 207, 247, 0, 0, 0, 0, 31, 251, 0, 0, 0, - 0, 14, 252, 0, 57, 206, 255, 255, 253, 8, 255, 255, 255, 255, 253, 95, 255, 133, 51, 62, 253, 191, 246, 0, - 0, 14, 253, 223, 241, 0, 0, 31, 253, 207, 242, 0, 0, 159, 253, 143, 252, 83, 91, 254, 253, 29, 255, 255, - 255, 135, 253, 1, 157, 254, 181, 4, 253, 223, 208, 0, 0, 0, 0, 13, 253, 0, 0, 0, 0, 0, 223, 208, - 0, 0, 0, 0, 13, 253, 0, 0, 0, 0, 0, 223, 208, 0, 0, 0, 0, 13, 253, 6, 206, 236, 113, 0, - 223, 202, 255, 255, 255, 193, 13, 255, 249, 67, 92, 255, 160, 223, 249, 0, 0, 29, 255, 61, 255, 32, 0, 0, - 111, 247, 223, 240, 0, 0, 3, 255, 173, 254, 0, 0, 0, 47, 251, 223, 224, 0, 0, 2, 255, 189, 255, 0, - 0, 0, 63, 249, 223, 243, 0, 0, 7, 255, 125, 255, 144, 0, 1, 223, 242, 223, 255, 164, 53, 207, 250, 13, - 250, 207, 255, 255, 252, 16, 223, 80, 124, 238, 199, 16, 0, 0, 3, 140, 238, 219, 96, 7, 255, 255, 255, 250, - 5, 255, 231, 52, 106, 64, 239, 242, 0, 0, 0, 79, 249, 0, 0, 0, 7, 255, 80, 0, 0, 0, 159, 244, - 0, 0, 0, 9, 255, 64, 0, 0, 0, 127, 245, 0, 0, 0, 5, 255, 144, 0, 0, 0, 30, 254, 32, 0, - 0, 0, 127, 254, 115, 69, 153, 0, 143, 255, 255, 255, 160, 0, 57, 222, 253, 147, 0, 0, 0, 0, 0, 207, - 240, 0, 0, 0, 0, 12, 255, 0, 0, 0, 0, 0, 207, 240, 0, 0, 0, 0, 12, 255, 0, 0, 0, 0, - 0, 191, 240, 0, 108, 238, 199, 11, 255, 1, 191, 255, 255, 251, 191, 240, 143, 253, 99, 73, 255, 255, 31, 255, - 32, 0, 7, 255, 245, 255, 160, 0, 0, 31, 255, 143, 246, 0, 0, 0, 207, 249, 255, 64, 0, 0, 11, 255, - 159, 244, 0, 0, 0, 175, 248, 255, 80, 0, 0, 11, 255, 95, 248, 0, 0, 0, 239, 241, 255, 226, 0, 0, - 111, 255, 9, 255, 213, 52, 143, 255, 240, 27, 255, 255, 255, 185, 255, 0, 7, 206, 236, 96, 95, 240, 0, 3, - 157, 254, 199, 16, 0, 7, 255, 255, 255, 252, 16, 5, 255, 197, 52, 159, 251, 0, 223, 193, 0, 0, 159, 244, - 79, 246, 0, 0, 3, 255, 119, 255, 255, 255, 255, 255, 249, 159, 255, 255, 255, 255, 255, 153, 255, 99, 51, 51, - 51, 50, 127, 246, 0, 0, 0, 0, 4, 255, 160, 0, 0, 0, 0, 13, 255, 80, 0, 0, 1, 0, 79, 255, - 148, 51, 106, 224, 0, 110, 255, 255, 255, 254, 0, 0, 40, 206, 254, 200, 64, 0, 0, 75, 223, 235, 48, 0, - 127, 255, 255, 241, 0, 14, 255, 115, 69, 0, 2, 255, 160, 0, 0, 0, 63, 248, 0, 0, 2, 142, 255, 255, - 255, 0, 159, 255, 255, 255, 240, 1, 53, 255, 147, 51, 0, 0, 63, 248, 0, 0, 0, 3, 255, 128, 0, 0, - 0, 63, 248, 0, 0, 0, 3, 255, 128, 0, 0, 0, 63, 248, 0, 0, 0, 3, 255, 128, 0, 0, 0, 63, - 248, 0, 0, 0, 3, 255, 128, 0, 0, 0, 63, 248, 0, 0, 0, 3, 255, 128, 0, 0, 0, 63, 248, 0, - 0, 0, 0, 6, 206, 236, 112, 95, 240, 11, 255, 255, 255, 200, 255, 8, 255, 214, 52, 159, 255, 241, 239, 226, - 0, 0, 127, 255, 95, 249, 0, 0, 0, 239, 248, 255, 80, 0, 0, 12, 255, 159, 244, 0, 0, 0, 175, 249, - 255, 64, 0, 0, 10, 255, 143, 245, 0, 0, 0, 191, 245, 255, 128, 0, 0, 14, 255, 31, 254, 16, 0, 5, - 255, 240, 143, 253, 83, 72, 255, 255, 1, 191, 255, 255, 251, 191, 240, 0, 124, 238, 199, 11, 255, 0, 0, 0, - 0, 0, 207, 224, 0, 0, 0, 0, 14, 253, 1, 0, 0, 0, 7, 255, 144, 172, 133, 51, 90, 255, 242, 10, - 255, 255, 255, 255, 245, 0, 56, 189, 255, 236, 130, 0, 223, 208, 0, 0, 0, 0, 13, 253, 0, 0, 0, 0, - 0, 223, 208, 0, 0, 0, 0, 13, 253, 0, 0, 0, 0, 0, 223, 208, 0, 0, 0, 0, 13, 253, 5, 190, - 253, 146, 0, 223, 201, 255, 255, 255, 244, 13, 255, 251, 83, 91, 255, 192, 223, 250, 0, 0, 13, 255, 45, 255, - 64, 0, 0, 159, 244, 223, 240, 0, 0, 7, 255, 77, 254, 0, 0, 0, 127, 244, 223, 208, 0, 0, 7, 255, - 77, 253, 0, 0, 0, 127, 244, 223, 208, 0, 0, 7, 255, 77, 253, 0, 0, 0, 127, 244, 223, 208, 0, 0, - 7, 255, 77, 253, 0, 0, 0, 127, 244, 223, 208, 0, 0, 7, 255, 64, 158, 160, 255, 241, 158, 160, 0, 0, - 0, 0, 223, 208, 223, 208, 223, 208, 223, 208, 223, 208, 223, 208, 223, 208, 223, 208, 223, 208, 223, 208, 223, 208, - 223, 208, 223, 208, 223, 208, 0, 0, 158, 160, 0, 0, 255, 241, 0, 0, 158, 160, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 223, 208, 0, 0, 223, 208, 0, 0, 223, 208, 0, 0, 223, 208, 0, 0, 223, 208, 0, 0, - 223, 208, 0, 0, 223, 208, 0, 0, 223, 208, 0, 0, 223, 208, 0, 0, 223, 208, 0, 0, 223, 208, 0, 0, - 223, 208, 0, 0, 223, 208, 0, 0, 223, 208, 0, 0, 223, 208, 0, 0, 223, 208, 0, 0, 255, 192, 36, 74, - 255, 144, 111, 255, 254, 32, 94, 254, 179, 0, 223, 208, 0, 0, 0, 0, 13, 253, 0, 0, 0, 0, 0, 223, - 208, 0, 0, 0, 0, 13, 253, 0, 0, 0, 0, 0, 223, 208, 0, 0, 0, 0, 13, 253, 0, 0, 10, 255, - 128, 223, 208, 0, 9, 255, 144, 13, 253, 0, 8, 255, 160, 0, 223, 208, 7, 255, 176, 0, 13, 253, 5, 255, - 177, 0, 0, 223, 196, 255, 193, 0, 0, 13, 253, 239, 251, 0, 0, 0, 223, 255, 239, 247, 0, 0, 13, 255, - 145, 223, 244, 0, 0, 223, 208, 3, 255, 225, 0, 13, 253, 0, 7, 255, 176, 0, 223, 208, 0, 11, 255, 112, - 13, 253, 0, 0, 30, 255, 64, 223, 208, 0, 0, 79, 254, 16, 223, 221, 253, 223, 221, 253, 223, 221, 253, 223, - 221, 253, 223, 221, 253, 223, 221, 253, 223, 221, 253, 223, 221, 253, 223, 221, 253, 223, 208, 223, 96, 108, 238, 199, - 0, 24, 223, 236, 96, 13, 249, 175, 255, 255, 251, 45, 255, 255, 255, 144, 223, 255, 148, 55, 239, 254, 248, 67, - 143, 255, 61, 255, 144, 0, 6, 255, 246, 0, 0, 143, 247, 223, 243, 0, 0, 47, 254, 16, 0, 4, 255, 141, - 255, 0, 0, 1, 255, 192, 0, 0, 47, 249, 223, 224, 0, 0, 15, 251, 0, 0, 2, 255, 157, 253, 0, 0, - 0, 255, 176, 0, 0, 47, 249, 223, 208, 0, 0, 15, 251, 0, 0, 2, 255, 157, 253, 0, 0, 0, 255, 176, - 0, 0, 47, 249, 223, 208, 0, 0, 15, 251, 0, 0, 2, 255, 157, 253, 0, 0, 0, 255, 176, 0, 0, 47, - 249, 223, 208, 0, 0, 15, 251, 0, 0, 2, 255, 157, 253, 0, 0, 0, 255, 176, 0, 0, 47, 249, 223, 96, - 91, 239, 218, 48, 13, 249, 175, 255, 255, 255, 64, 223, 255, 181, 53, 191, 252, 13, 255, 160, 0, 0, 223, 242, - 223, 243, 0, 0, 9, 255, 77, 255, 0, 0, 0, 127, 244, 223, 224, 0, 0, 7, 255, 77, 253, 0, 0, 0, - 127, 244, 223, 208, 0, 0, 7, 255, 77, 253, 0, 0, 0, 127, 244, 223, 208, 0, 0, 7, 255, 77, 253, 0, - 0, 0, 127, 244, 223, 208, 0, 0, 7, 255, 77, 253, 0, 0, 0, 127, 244, 0, 3, 157, 238, 200, 32, 0, - 0, 127, 255, 255, 255, 229, 0, 6, 255, 230, 51, 126, 255, 48, 30, 255, 32, 0, 4, 255, 192, 95, 249, 0, - 0, 0, 191, 243, 143, 246, 0, 0, 0, 127, 246, 159, 244, 0, 0, 0, 111, 247, 159, 244, 0, 0, 0, 111, - 247, 127, 246, 0, 0, 0, 143, 246, 79, 250, 0, 0, 0, 207, 243, 13, 255, 32, 0, 4, 255, 192, 4, 255, - 230, 51, 126, 255, 64, 0, 110, 255, 255, 255, 245, 0, 0, 2, 141, 238, 216, 32, 0, 223, 112, 108, 239, 199, - 16, 13, 250, 175, 255, 255, 252, 16, 223, 255, 164, 53, 207, 251, 13, 255, 144, 0, 1, 239, 243, 223, 243, 0, - 0, 7, 255, 125, 255, 0, 0, 0, 79, 250, 223, 224, 0, 0, 2, 255, 189, 254, 0, 0, 0, 47, 251, 223, - 240, 0, 0, 4, 255, 157, 255, 48, 0, 0, 143, 247, 223, 250, 0, 0, 30, 255, 45, 255, 250, 67, 92, 255, - 160, 223, 203, 255, 255, 255, 193, 13, 253, 6, 206, 236, 112, 0, 223, 208, 0, 0, 0, 0, 13, 253, 0, 0, - 0, 0, 0, 223, 208, 0, 0, 0, 0, 13, 253, 0, 0, 0, 0, 0, 223, 208, 0, 0, 0, 0, 13, 253, - 0, 0, 0, 0, 0, 0, 6, 206, 236, 96, 95, 240, 11, 255, 255, 255, 184, 255, 8, 255, 214, 52, 159, 255, - 241, 255, 242, 0, 0, 127, 255, 95, 250, 0, 0, 1, 255, 248, 255, 96, 0, 0, 12, 255, 159, 244, 0, 0, - 0, 191, 249, 255, 64, 0, 0, 10, 255, 143, 245, 0, 0, 0, 191, 245, 255, 128, 0, 0, 14, 255, 31, 254, - 16, 0, 6, 255, 240, 159, 253, 83, 72, 255, 255, 1, 191, 255, 255, 251, 191, 240, 0, 124, 238, 199, 11, 255, - 0, 0, 0, 0, 0, 207, 240, 0, 0, 0, 0, 12, 255, 0, 0, 0, 0, 0, 207, 240, 0, 0, 0, 0, - 12, 255, 0, 0, 0, 0, 0, 207, 240, 0, 0, 0, 0, 12, 255, 223, 96, 59, 239, 157, 248, 95, 255, 247, - 223, 223, 231, 52, 45, 255, 209, 0, 0, 223, 245, 0, 0, 13, 255, 0, 0, 0, 223, 224, 0, 0, 13, 253, - 0, 0, 0, 223, 208, 0, 0, 13, 253, 0, 0, 0, 223, 208, 0, 0, 13, 253, 0, 0, 0, 223, 208, 0, - 0, 13, 253, 0, 0, 0, 0, 107, 223, 236, 147, 1, 207, 255, 255, 255, 225, 143, 250, 67, 71, 201, 10, 255, - 0, 0, 0, 0, 159, 246, 0, 0, 0, 3, 239, 252, 81, 0, 0, 3, 207, 255, 233, 32, 0, 0, 74, 255, - 254, 96, 0, 0, 1, 143, 255, 32, 0, 0, 0, 95, 246, 16, 0, 0, 4, 255, 107, 199, 67, 54, 223, 243, - 191, 255, 255, 255, 247, 3, 140, 239, 253, 164, 0, 0, 10, 243, 0, 0, 0, 31, 243, 0, 0, 0, 111, 243, - 0, 0, 41, 255, 255, 255, 243, 143, 255, 255, 255, 243, 19, 175, 245, 51, 48, 0, 159, 243, 0, 0, 0, 159, - 243, 0, 0, 0, 159, 243, 0, 0, 0, 159, 243, 0, 0, 0, 159, 243, 0, 0, 0, 159, 243, 0, 0, 0, - 159, 243, 0, 0, 0, 143, 245, 0, 0, 0, 95, 253, 83, 82, 0, 12, 255, 255, 245, 0, 1, 157, 254, 179, - 255, 192, 0, 0, 9, 255, 63, 252, 0, 0, 0, 159, 243, 255, 192, 0, 0, 9, 255, 63, 252, 0, 0, 0, - 159, 243, 255, 192, 0, 0, 9, 255, 63, 252, 0, 0, 0, 159, 243, 255, 192, 0, 0, 9, 255, 63, 252, 0, - 0, 0, 159, 243, 255, 192, 0, 0, 11, 255, 63, 253, 0, 0, 0, 239, 243, 223, 243, 0, 0, 127, 255, 57, - 255, 231, 69, 159, 255, 243, 29, 255, 255, 255, 214, 255, 48, 24, 223, 236, 129, 47, 243, 207, 242, 0, 0, 0, - 111, 248, 127, 247, 0, 0, 0, 191, 242, 31, 252, 0, 0, 2, 255, 176, 10, 255, 32, 0, 7, 255, 80, 4, - 255, 112, 0, 12, 254, 16, 0, 239, 208, 0, 47, 249, 0, 0, 143, 243, 0, 143, 243, 0, 0, 47, 248, 0, - 223, 192, 0, 0, 12, 253, 3, 255, 112, 0, 0, 6, 255, 56, 255, 16, 0, 0, 1, 255, 141, 250, 0, 0, - 0, 0, 175, 223, 244, 0, 0, 0, 0, 79, 255, 224, 0, 0, 0, 0, 13, 255, 128, 0, 0, 159, 243, 0, - 0, 47, 255, 32, 0, 3, 255, 133, 255, 112, 0, 7, 255, 247, 0, 0, 127, 244, 31, 251, 0, 0, 191, 239, - 176, 0, 11, 254, 0, 191, 224, 0, 31, 248, 255, 16, 1, 255, 176, 7, 255, 64, 5, 254, 31, 245, 0, 79, - 247, 0, 63, 247, 0, 159, 176, 207, 144, 8, 255, 32, 0, 239, 176, 14, 247, 8, 253, 0, 207, 208, 0, 10, - 255, 3, 255, 48, 79, 243, 31, 249, 0, 0, 111, 243, 127, 208, 0, 239, 116, 255, 80, 0, 1, 255, 123, 249, - 0, 10, 250, 143, 241, 0, 0, 12, 250, 239, 64, 0, 111, 235, 251, 0, 0, 0, 143, 239, 224, 0, 1, 255, - 239, 112, 0, 0, 4, 255, 250, 0, 0, 12, 255, 243, 0, 0, 0, 14, 255, 96, 0, 0, 143, 254, 0, 0, - 46, 254, 32, 0, 1, 223, 243, 6, 255, 176, 0, 9, 255, 112, 0, 175, 246, 0, 79, 252, 0, 0, 30, 254, - 33, 223, 226, 0, 0, 4, 255, 184, 255, 96, 0, 0, 0, 159, 255, 251, 0, 0, 0, 0, 29, 255, 225, 0, - 0, 0, 0, 46, 255, 243, 0, 0, 0, 0, 207, 254, 253, 16, 0, 0, 7, 255, 133, 255, 144, 0, 0, 63, - 252, 0, 175, 245, 0, 1, 223, 243, 0, 30, 254, 16, 9, 255, 112, 0, 5, 255, 160, 79, 252, 0, 0, 0, - 175, 246, 207, 242, 0, 0, 0, 111, 248, 95, 248, 0, 0, 0, 191, 242, 14, 253, 0, 0, 1, 255, 192, 8, - 255, 64, 0, 7, 255, 96, 2, 255, 144, 0, 12, 254, 16, 0, 191, 225, 0, 47, 249, 0, 0, 95, 245, 0, - 127, 244, 0, 0, 14, 251, 0, 223, 208, 0, 0, 8, 255, 19, 255, 112, 0, 0, 2, 255, 104, 255, 32, 0, - 0, 0, 191, 172, 251, 0, 0, 0, 0, 95, 239, 245, 0, 0, 0, 0, 14, 255, 224, 0, 0, 0, 0, 8, - 255, 144, 0, 0, 0, 0, 9, 255, 48, 0, 0, 0, 0, 30, 252, 0, 0, 0, 0, 0, 159, 245, 0, 0, - 0, 35, 73, 255, 192, 0, 0, 0, 143, 255, 254, 32, 0, 0, 0, 126, 253, 146, 0, 0, 0, 0, 9, 255, - 255, 255, 255, 244, 9, 255, 255, 255, 255, 244, 2, 51, 51, 53, 255, 209, 0, 0, 0, 12, 255, 48, 0, 0, - 0, 143, 246, 0, 0, 0, 4, 255, 176, 0, 0, 0, 29, 254, 16, 0, 0, 0, 175, 244, 0, 0, 0, 6, - 255, 128, 0, 0, 0, 46, 252, 0, 0, 0, 0, 207, 226, 0, 0, 0, 8, 255, 131, 51, 51, 49, 31, 255, - 255, 255, 255, 247, 31, 255, 255, 255, 255, 247, 0, 0, 4, 173, 241, 0, 0, 111, 255, 241, 0, 0, 239, 248, - 64, 0, 2, 255, 144, 0, 0, 3, 255, 96, 0, 0, 3, 255, 96, 0, 0, 3, 255, 96, 0, 0, 3, 255, - 96, 0, 0, 5, 255, 80, 0, 1, 93, 254, 16, 0, 111, 255, 179, 0, 0, 111, 253, 129, 0, 0, 20, 143, - 253, 0, 0, 0, 6, 255, 64, 0, 0, 3, 255, 96, 0, 0, 3, 255, 96, 0, 0, 3, 255, 96, 0, 0, - 3, 255, 96, 0, 0, 2, 255, 128, 0, 0, 1, 255, 229, 16, 0, 0, 143, 255, 241, 0, 0, 7, 223, 241, - 0, 0, 0, 1, 32, 239, 78, 244, 239, 78, 244, 239, 78, 244, 239, 78, 244, 239, 78, 244, 239, 78, 244, 239, - 78, 244, 239, 78, 244, 239, 78, 244, 239, 78, 244, 239, 78, 244, 239, 78, 244, 239, 64, 47, 218, 64, 0, 0, - 47, 255, 246, 0, 0, 4, 143, 254, 0, 0, 0, 9, 255, 32, 0, 0, 6, 255, 32, 0, 0, 6, 255, 32, - 0, 0, 6, 255, 32, 0, 0, 6, 255, 32, 0, 0, 5, 255, 80, 0, 0, 1, 239, 213, 16, 0, 0, 59, - 255, 245, 0, 0, 24, 223, 245, 0, 1, 223, 231, 65, 0, 5, 255, 96, 0, 0, 6, 255, 48, 0, 0, 6, - 255, 32, 0, 0, 6, 255, 32, 0, 0, 6, 255, 32, 0, 0, 8, 255, 32, 0, 1, 94, 254, 0, 0, 47, - 255, 247, 0, 0, 47, 252, 96, 0, 0, 2, 16, 0, 0, 0, 7, 223, 217, 48, 0, 2, 120, 255, 255, 255, - 182, 54, 233, 189, 83, 108, 255, 255, 255, 103, 16, 0, 4, 173, 252, 80, 10, 234, 0, 0, 174, 160, 0, 10, - 234, 3, 255, 244, 0, 63, 255, 64, 3, 255, 243, 63, 255, 64, 3, 255, 244, 0, 63, 255, 48, 174, 160, 0, - 10, 234, 0, 0, 174, 160, 10, 234, 3, 255, 244, 63, 255, 64, 174, 160, - ], -}; diff --git a/apps/vela-nav/src/main.rs b/apps/vela-nav/src/main.rs deleted file mode 100644 index 6025fa6..0000000 --- a/apps/vela-nav/src/main.rs +++ /dev/null @@ -1,174 +0,0 @@ -#![cfg_attr(any(target_os = "none", wp2_sim), no_main, cfg_attr(target_os = "none", no_std))] - -//! Vela Nav: shows the drive that the Vela maps app on the phone is navigating. Protocol: `proto.rs`. - -// the host build (tests) has no device loop, so some of the protocol is unused there -#[cfg_attr(not(any(target_os = "none", wp2_sim)), allow(dead_code))] -mod font; -#[rustfmt::skip] -mod fonts; -#[cfg_attr(not(any(target_os = "none", wp2_sim)), allow(dead_code))] -mod proto; -mod sign; -#[cfg_attr(not(any(target_os = "none", wp2_sim)), allow(dead_code))] -mod view; - -#[cfg(not(any(target_os = "none", wp2_sim)))] -fn main() {} - -#[cfg(any(target_os = "none", wp2_sim))] -mod device { - use crate::proto::{self, ASK, Effect, Model}; - use crate::view::{self, Ctx, Fade, Glide, Pose, ZOOM_DEFAULT, ZOOMS}; - use cmf_wp2_app::{Api, BUTTON, CROWN, MSG_MAX, PAUSE, RESUME, TOUCH_DOWN}; - use cmf_wp2_ui::haptic::{self, Pattern}; - - cmf_wp2_app::entry!(main); - cmf_wp2_app::app_icon!(); - - /// Ask for a snapshot again this often while none comes. - const ASK_MS: u32 = 3000; - /// The phone sends the drive every second; after this long without one it is out of reach. - const STALE_MS: u32 = 6000; - /// At most this often a redraw (a route arrives as a burst of messages), and the shortest frame of a glide; - /// a glide's frames are spaced by what the last one took to draw, so a busy map gets fewer, not a stall. - const FRAME_MS: u32 = 80; - - // 4 KiB of route: too big for the 8 KiB stack - static mut MODEL: Model = Model::new(); - static mut FADE: Fade = Fade::new(); - - /// How long a tapped button waits for the drive to start before it is a button again. - const START_WAIT_MS: u32 = 30_000; - - /// Plays a short pattern, waiting it out (it is under 200 ms), and leaves the motor off. - fn buzz(api: &Api, p: Pattern) { - for &(duty, ms) in p.steps() { - api.vibrate(duty, haptic::HZ); - let t = api.now(); - while api.now().wrapping_sub(t) < ms as u32 {} - } - api.vibrate(0, haptic::HZ); - } - - // true on RESUME, false on BUTTON - fn paused(api: &Api) -> bool { - loop { - match api.event(u32::MAX).map(|e| e.kind) { - Some(RESUME) => return true, - Some(BUTTON) => return false, - _ => {} - } - } - } - - fn main(api: &'static Api) -> i32 { - // SAFETY: the app has one thread and this is the only reference. - let m = unsafe { &mut *core::ptr::addr_of_mut!(MODEL) }; - // SAFETY: as above. - let fade = unsafe { &mut *core::ptr::addr_of_mut!(FADE) }; - let mut zoom = ZOOM_DEFAULT; - let mut want; - let mut asked: Option = None; - let mut heard: Option = None; - let mut dirty = true; - let mut drawn_at = 0u32; - let mut live = false; - let mut screen_on = false; - let mut glide = Glide::new(); - let mut shown: Option = None; - let mut frame_ms = FRAME_MS; - // the Home / Work button tapped, and when - let mut pending: Option<(u8, u32)> = None; - loop { - let now = api.now(); - // the car glides between the phone's updates: redraw when it has moved a pixel - let pose = glide.at(now); - let moving = glide.moving(now); - if moving && shown.is_none_or(|s| s.moved_px(pose, ZOOMS[zoom]) >= 1) { - dirty = true; - } - want = !m.synced; - if want && asked.is_none_or(|t| now.wrapping_sub(t) >= ASK_MS) { - api.send(&ASK); // -107 while Vela is not listening: asked again in 3 s - asked = Some(now); - } - let is_live = heard.is_some_and(|t| now.wrapping_sub(t) < STALE_MS); - if is_live != live { - live = is_live; - dirty = true; - if !live { - (m.synced, asked) = (false, None); - m.reset_seq(); - } - } - // a tapped button is lit until the drive starts, the phone says it could not, or a while passes - if let Some((_, at)) = pending - && (m.state.active() || m.start == proto::START_FAILED || now.wrapping_sub(at) > START_WAIT_MS) - { - (pending, dirty) = (None, true); - } - let on = live && m.state.active(); - if on != screen_on { - screen_on = on; - api.keep_screen_on(on); - } - if dirty && now.wrapping_sub(drawn_at) >= frame_ms { - let clock = api.time().map(|t| (t.hour, t.minute)); - let mut screen = api; - let ctx = Ctx { live, clock, zoom, pose: Some(pose), pending: pending.map(|p| p.0) }; - view::draw(&mut screen, m, &ctx, fade); - api.show(); - // the next frame waits at least as long as this one took, plus a little for the messages - frame_ms = (api.now().wrapping_sub(now) * 5 / 4).clamp(FRAME_MS, 400); - (dirty, drawn_at, shown) = (false, now, Some(pose)); - } - let wait = if dirty || moving { frame_ms } else { 1000 }; - match api.event(wait) { - Some(e) if e.kind == BUTTON => return 0, - Some(e) if e.kind == TOUCH_DOWN && live && m.has_state && !m.state.active() && pending.is_none() => { - if let Some(kind) = view::button_at(e.y as i32) - && m.places & kind != 0 - && api.send(&proto::action(kind)) >= 0 - { - buzz(api, haptic::TICK); - (pending, dirty) = (Some((kind, api.now())), true); - } - } - Some(e) if e.kind == CROWN => { - let z = (zoom as i32 + e.delta.signum() as i32).clamp(0, ZOOMS.len() as i32 - 1) as usize; - dirty |= z != zoom; - zoom = z; - } - Some(e) if e.kind == PAUSE => { - screen_on = false; - if !paused(api) { - return 0; - } - // messages were refused meanwhile - (m.synced, asked, dirty) = (false, None, true); - m.reset_seq(); - } - _ => {} - } - let mut buf = [0u8; MSG_MAX]; - while let Some(msg) = api.recv(&mut buf) { - match m.apply(msg) { - Effect::Ignored => continue, - Effect::Changed => { - dirty = true; - glide.target(Pose::of(&m.state), api.now()); - } - Effect::Resync => { - dirty = true; - if !want { - asked = None; // ask right away - } - } - } - heard = Some(api.now()); - want = !m.synced; - } - } - } -} diff --git a/apps/vela-nav/src/proto.rs b/apps/vela-nav/src/proto.rs deleted file mode 100644 index a3fc3f8..0000000 --- a/apps/vela-nav/src/proto.rs +++ /dev/null @@ -1,790 +0,0 @@ -//! The Vela ↔ watch protocol and the navigation model it fills. Pure: no `Api`, so `make test` covers it. -//! -//! Every message starts with the magic `n1`. Phone → watch messages then carry a kind byte and a `seq` byte that -//! counts every phone message (wrapping); a gap makes the watch ask for a snapshot again. All numbers are -//! little-endian. -//! -//! | Kind | Body | Meaning | -//! |---|---|---| -//! | `S` | flags u8, maneuver u8, dist u16 m, after u8, after dist u16 m, remaining u16 (10 m), remaining u16 s, limit u8, x i32 m, y i32 m, course u16, progress u16 | the drive, about once a second | -//! | `T` | UTF-8, ≤ 100 B | the road being entered (or the destination on arrival) | -//! | `B` | id u8, count u16, scale u8 (m per unit), frame u16 (optional) | a new route line begins; it replaces the shown one at its `E` | -//! | `R` | id u8, start u16, n u8, n × (x i16, y i16) | route points `start..start+n`, n ≤ 30 | -//! | `E` | id u8, count u16 | the route line is complete | -//! | `G` | id u8, x i32 m, y i32 m | a new set of streets around (x, y) begins | -//! | `H` | id u8, then records: n u8 (2..=30), class u8 (0 minor, 1 major), n × (x i16, y i16) m from the set's (x, y) | streets | -//! | `J` | id u8, lines u16, points u16 | the set is complete: it replaces the one shown | -//! | `P` | flags u8 (1 Home set, 2 Work set), status u8 (0 idle, 1 starting a drive, 2 could not plan it) | the shortcuts the watch may offer: whether each is set, never where | -//! -//! Streets are drawn under the route, fading out away from it. They share the route's frame: a route in another -//! frame (its `frame` tag differs, or has none) drops them when it is complete, and the phone sends a set for the new -//! frame after it. The same route sent again (a snapshot) keeps them. -//! -//! Watch → phone: `n1Q`, "send me everything" (on start, after a gap, after `RESUME`, and while nothing arrives); -//! `n1A` + 1 or 2, "start a drive to Home / Work" (a button on the screen shown without a drive). -//! -//! Positions are metres east (`x`) and north (`y`) of an origin the phone picks per drive, never latitude and -//! longitude: the channel can be read by anyone in Bluetooth range. `course` is the heading in 1/65536 turns -//! clockwise from north. `progress` is the index of the first route point still ahead of the car. - -pub const ASK: [u8; 3] = *b"n1Q"; -pub const P_HOME: u8 = 1; -pub const P_WORK: u8 = 2; -pub const START_BUSY: u8 = 1; -pub const START_FAILED: u8 = 2; - -/// "Start a drive to Home / Work" (`P_HOME`, `P_WORK`). -pub fn action(kind: u8) -> [u8; 4] { - [b'n', b'1', b'A', kind] -} -pub const ROUTE_MAX: usize = 512; -pub const TEXT_MAX: usize = 100; -pub const CHUNK_MAX: usize = 30; -/// Street points and lines one set holds; the phone sends the nearest streets first and stops below these. -pub const ROADS_PTS: usize = 1200; -pub const ROADS_LINES: usize = 240; -pub const ROAD_LINE_MAX: usize = 30; - -pub const F_ACTIVE: u8 = 1 << 0; -pub const F_ARRIVED: u8 = 1 << 1; -pub const F_IMPERIAL: u8 = 1 << 3; -pub const F_FIX: u8 = 1 << 4; -pub const F_CLOCK24: u8 = 1 << 5; -/// This state ends the snapshot the watch asked for with `n1Q`: everything before it in the run is current. -pub const F_SNAPSHOT: u8 = 1 << 6; - -/// Maneuver codes, the same numbers as Vela's `DeviceManeuver`. -pub mod man { - pub const NONE: u8 = 0; - pub const CONTINUE: u8 = 1; - pub const SLIGHT_LEFT: u8 = 2; - pub const LEFT: u8 = 3; - pub const SHARP_LEFT: u8 = 4; - pub const SLIGHT_RIGHT: u8 = 5; - pub const RIGHT: u8 = 6; - pub const SHARP_RIGHT: u8 = 7; - pub const KEEP_LEFT: u8 = 8; - pub const KEEP_RIGHT: u8 = 9; - pub const UTURN: u8 = 10; - pub const ROUNDABOUT: u8 = 11; - pub const OFF_ROUTE: u8 = 12; - pub const ARRIVE: u8 = 13; -} - -#[derive(Clone, Copy, Default, PartialEq, Debug)] -pub struct State { - pub flags: u8, - pub maneuver: u8, - pub dist_m: u16, - pub after: u8, - pub after_m: u16, - pub remaining_10m: u16, - pub remaining_s: u16, - pub limit: u8, - pub x: i32, - pub y: i32, - pub course: u16, - pub progress: u16, -} - -impl State { - pub fn active(&self) -> bool { - self.flags & F_ACTIVE != 0 - } - pub fn arrived(&self) -> bool { - self.flags & F_ARRIVED != 0 - } - pub fn imperial(&self) -> bool { - self.flags & F_IMPERIAL != 0 - } - pub fn fix(&self) -> bool { - self.flags & F_FIX != 0 - } - pub fn clock24(&self) -> bool { - self.flags & F_CLOCK24 != 0 - } -} - -/// What a message did to the model. -#[derive(Clone, Copy, PartialEq, Debug)] -pub enum Effect { - /// Not ours or malformed: ignored. - Ignored, - /// Applied; the screen is out of date. - Changed, - /// Messages were lost: ask the phone for a snapshot (`ASK`). - Resync, -} - -/// One street line: `n` points from `first` in `Roads::pts`. -#[derive(Clone, Copy, Default)] -pub struct RoadLine { - pub first: u16, - pub n: u16, - pub major: bool, -} - -/// A set of streets: points in metres from `origin`, which is in the route's frame. -pub struct Roads { - pub origin: [i32; 2], - pub pts: [[i16; 2]; ROADS_PTS], - pub lines: [RoadLine; ROADS_LINES], - pub n_pts: usize, - pub n_lines: usize, -} - -impl Roads { - pub const fn new() -> Roads { - Roads { - origin: [0; 2], - pts: [[0; 2]; ROADS_PTS], - lines: [RoadLine { first: 0, n: 0, major: false }; ROADS_LINES], - n_pts: 0, - n_lines: 0, - } - } - - /// A line's points in the route's frame. - pub fn line(&self, l: &RoadLine) -> impl Iterator + '_ { - self.pts[l.first as usize..(l.first + l.n) as usize] - .iter() - .map(|p| [self.origin[0] + p[0] as i32, self.origin[1] + p[1] as i32]) - } -} - -impl Default for Roads { - fn default() -> Self { - Roads::new() - } -} - -pub struct Model { - pub state: State, - /// A state arrived since the last `reset` (the screen shows "waiting" until then). - pub has_state: bool, - /// The shortcuts the phone has (`P_HOME`, `P_WORK` bits) and what came of the last start (`START_*`). - pub places: u8, - pub start: u8, - /// A state with `F_SNAPSHOT` arrived after the last gap: the watch has everything. - pub synced: bool, - text: [u8; TEXT_MAX], - text_len: usize, - pub route: [[i32; 2]; ROUTE_MAX], - /// Points of the complete route line shown; 0 while none. A new one arrives in `incoming` beside it. - pub route_len: usize, - incoming: [[i32; 2]; ROUTE_MAX], - /// The frame of the line shown, and of the one arriving. - frame: Option, - incoming_frame: Option, - route_id: Option, - route_count: usize, - route_got: usize, - route_scale: i32, - /// The set shown is `roads[live]`; the next one arrives in the other. - roads: [Roads; 2], - live: usize, - roads_id: Option, - /// Lines of the set arriving, kept or not. - roads_seen: usize, - last_seq: Option, -} - -fn u16_at(b: &[u8], i: usize) -> u16 { - u16::from_le_bytes([b[i], b[i + 1]]) -} -fn i16_at(b: &[u8], i: usize) -> i16 { - i16::from_le_bytes([b[i], b[i + 1]]) -} -fn i32_at(b: &[u8], i: usize) -> i32 { - i32::from_le_bytes([b[i], b[i + 1], b[i + 2], b[i + 3]]) -} - -impl Model { - pub const fn new() -> Model { - Model { - state: State { - flags: 0, - maneuver: 0, - dist_m: 0, - after: 0, - after_m: 0, - remaining_10m: 0, - remaining_s: 0, - limit: 0, - x: 0, - y: 0, - course: 0, - progress: 0, - }, - has_state: false, - places: 0, - start: 0, - synced: false, - text: [0; TEXT_MAX], - text_len: 0, - route: [[0; 2]; ROUTE_MAX], - route_len: 0, - incoming: [[0; 2]; ROUTE_MAX], - frame: None, - incoming_frame: None, - route_id: None, - route_count: 0, - route_got: 0, - route_scale: 1, - roads: [Roads::new(), Roads::new()], - live: 0, - roads_id: None, - roads_seen: 0, - last_seq: None, - } - } - - /// Forget the sequence (after a pause or a resync request): the next message starts a new run. - pub fn reset_seq(&mut self) { - self.last_seq = None; - } - - /// The road line, cut on a character boundary. - pub fn text(&self) -> &str { - cmf_wp2_ui::text::fit(&self.text[..self.text_len], TEXT_MAX) - } - - /// The streets shown. - pub fn roads(&self) -> &Roads { - &self.roads[self.live] - } - - #[cfg(test)] - pub fn drop_roads_for_test(&mut self) { - self.drop_roads() - } - - fn drop_roads(&mut self) { - self.roads[self.live].n_lines = 0; - self.roads_id = None; - } - - /// Length of the route line in metres; 0 while there is none. - pub fn length_m(&self) -> i64 { - self.route[..self.route_len] - .windows(2) - .map(|w| { - let (dx, dy) = ((w[1][0] - w[0][0]) as i64, (w[1][1] - w[0][1]) as i64); - isqrt((dx * dx + dy * dy) as u64) as i64 - }) - .sum() - } - - pub fn apply(&mut self, m: &[u8]) -> Effect { - let [b'n', b'1', kind, seq, body @ ..] = m else { - return Effect::Ignored; - }; - let gap = self.last_seq.is_some_and(|l| *seq != l.wrapping_add(1)); - self.last_seq = Some(*seq); - if gap { - self.synced = false; - } - let applied = match kind { - b'S' => self.on_state(body), - b'T' => self.on_text(body), - b'B' => self.on_begin(body), - b'R' => self.on_points(body), - b'E' => self.on_end(body), - b'G' => self.on_roads_begin(body), - b'H' => self.on_roads(body), - b'J' => self.on_roads_end(body), - b'P' => self.on_places(body), - _ => Some(false), - }; - match applied { - None => { - self.synced = false; - Effect::Resync - } - Some(_) if gap => Effect::Resync, - Some(true) => Effect::Changed, - Some(false) => Effect::Ignored, - } - } - - // Each handler: Some(true) applied, Some(false) malformed (ignored), None the route broke (resync). - - fn on_state(&mut self, b: &[u8]) -> Option { - if b.len() < 24 { - return Some(false); - } - self.state = State { - flags: b[0], - maneuver: b[1], - dist_m: u16_at(b, 2), - after: b[4], - after_m: u16_at(b, 5), - remaining_10m: u16_at(b, 7), - remaining_s: u16_at(b, 9), - limit: b[11], - x: i32_at(b, 12), - y: i32_at(b, 16), - course: u16_at(b, 20), - progress: u16_at(b, 22), - }; - self.has_state = true; - if self.state.flags & F_SNAPSHOT != 0 { - self.synced = true; - } - if !self.state.active() { - // no drive: drop the line so a later drive never shows the previous one - self.route_len = 0; - self.route_id = None; - self.frame = None; - self.drop_roads(); - } - Some(true) - } - - fn on_text(&mut self, b: &[u8]) -> Option { - let t = cmf_wp2_ui::text::fit(b, TEXT_MAX); - self.text[..t.len()].copy_from_slice(t.as_bytes()); - self.text_len = t.len(); - Some(true) - } - - fn on_begin(&mut self, b: &[u8]) -> Option { - if b.len() < 4 { - return Some(false); - } - let count = u16_at(b, 1) as usize; - if count > ROUTE_MAX || b[3] == 0 { - return Some(false); - } - (self.route_id, self.route_count, self.route_got, self.route_scale) = (Some(b[0]), count, 0, b[3] as i32); - self.incoming_frame = if b.len() >= 6 { Some(u16_at(b, 4)) } else { None }; - // the line shown stays until this one is complete - Some(false) - } - - fn on_points(&mut self, b: &[u8]) -> Option { - if b.len() < 4 { - return Some(false); - } - let (id, start, n) = (b[0], u16_at(b, 1) as usize, b[3] as usize); - if self.route_id != Some(id) { - return None; // a chunk of a line whose begin we missed: ask again - } - if b.len() < 4 + 4 * n || n > CHUNK_MAX || start != self.route_got || start + n > self.route_count { - self.route_id = None; - return None; - } - for i in 0..n { - let at = 4 + 4 * i; - self.incoming[start + i] = - [i16_at(b, at) as i32 * self.route_scale, i16_at(b, at + 2) as i32 * self.route_scale]; - } - self.route_got += n; - Some(false) // nothing to show until the end - } - - fn on_end(&mut self, b: &[u8]) -> Option { - if b.len() < 3 { - return Some(false); - } - if self.route_id != Some(b[0]) || u16_at(b, 1) as usize != self.route_got || self.route_got != self.route_count - { - self.route_id = None; - return None; - } - let n = self.route_got; - self.route[..n].copy_from_slice(&self.incoming[..n]); - self.route_len = n; - self.route_id = None; - if self.incoming_frame.is_none() || self.incoming_frame != self.frame { - self.drop_roads(); // another frame: the streets shown are in the old one - } - self.frame = self.incoming_frame; - Some(true) - } -} - -impl Model { - fn on_places(&mut self, b: &[u8]) -> Option { - let [flags, start, ..] = *b else { return Some(false) }; - (self.places, self.start) = (flags & (P_HOME | P_WORK), start); - Some(true) - } - - fn on_roads_begin(&mut self, b: &[u8]) -> Option { - if b.len() < 9 { - return Some(false); - } - let next = &mut self.roads[1 - self.live]; - (next.origin, next.n_pts, next.n_lines) = ([i32_at(b, 1), i32_at(b, 5)], 0, 0); - (self.roads_id, self.roads_seen) = (Some(b[0]), 0); - Some(false) - } - - fn on_roads(&mut self, b: &[u8]) -> Option { - if b.is_empty() || self.roads_id != Some(b[0]) { - return Some(false); // a set whose begin we missed: the seq gap asks for a snapshot - } - let next = &mut self.roads[1 - self.live]; - let mut at = 1; - while at + 2 <= b.len() { - let (n, major) = (b[at] as usize, b[at + 1] == 1); - if !(2..=ROAD_LINE_MAX).contains(&n) || at + 2 + 4 * n > b.len() { - self.roads_id = None; // malformed: drop the set - return Some(false); - } - // a set bigger than the watch holds keeps what fits, the nearest streets - if next.n_lines < ROADS_LINES && next.n_pts + n <= ROADS_PTS { - next.lines[next.n_lines] = RoadLine { first: next.n_pts as u16, n: n as u16, major }; - for i in 0..n { - let p = at + 2 + 4 * i; - next.pts[next.n_pts + i] = [i16_at(b, p), i16_at(b, p + 2)]; - } - next.n_lines += 1; - next.n_pts += n; - } - self.roads_seen += 1; - at += 2 + 4 * n; - } - Some(false) - } - - fn on_roads_end(&mut self, b: &[u8]) -> Option { - if b.len() < 5 || self.roads_id != Some(b[0]) { - return Some(false); - } - self.roads_id = None; - // a set cut to what fits is still shown; a short one (a lost message) is not - if u16_at(b, 1) as usize != self.roads_seen || self.route_len == 0 { - return Some(false); - } - self.live = 1 - self.live; - Some(true) - } -} - -impl Default for Model { - fn default() -> Self { - Model::new() - } -} - -fn isqrt(n: u64) -> u64 { - if n < 2 { - return n; - } - let mut x = 1u64 << ((64 - n.leading_zeros()).div_ceil(2)); - loop { - let y = (x + n / x) / 2; - if y >= x { - return x; - } - x = y; - } -} - -#[cfg(test)] -pub mod enc { - //! The phone side, for tests: what Vela's encoder must produce. - use super::*; - use std::vec::Vec; - - pub fn msg(kind: u8, seq: u8, body: &[u8]) -> Vec { - let mut v = vec![b'n', b'1', kind, seq]; - v.extend_from_slice(body); - assert!(v.len() <= 128); - v - } - - pub fn state(seq: u8, s: &State) -> Vec { - let mut b = vec![s.flags, s.maneuver]; - b.extend(s.dist_m.to_le_bytes()); - b.push(s.after); - b.extend(s.after_m.to_le_bytes()); - b.extend(s.remaining_10m.to_le_bytes()); - b.extend(s.remaining_s.to_le_bytes()); - b.push(s.limit); - b.extend(s.x.to_le_bytes()); - b.extend(s.y.to_le_bytes()); - b.extend(s.course.to_le_bytes()); - b.extend(s.progress.to_le_bytes()); - msg(b'S', seq, &b) - } - - /// Begin, chunks and end for a line of points in metres; returns the messages and the next seq. - pub fn route(seq: u8, id: u8, pts: &[[i32; 2]]) -> (Vec>, u8) { - route_in(seq, id, pts, None) - } - - /// [route] tagged with the frame it is in. - pub fn route_in(mut seq: u8, id: u8, pts: &[[i32; 2]], frame: Option) -> (Vec>, u8) { - let max = pts.iter().flat_map(|p| p.iter()).map(|v| v.abs()).max().unwrap_or(0); - let scale = (max / i16::MAX as i32 + 1) as u8; - let mut out = Vec::new(); - let n = (pts.len() as u16).to_le_bytes(); - let mut b = vec![id, n[0], n[1], scale]; - if let Some(f) = frame { - b.extend(f.to_le_bytes()); - } - out.push(msg(b'B', seq, &b)); - seq = seq.wrapping_add(1); - for (c, chunk) in pts.chunks(CHUNK_MAX).enumerate() { - let start = ((c * CHUNK_MAX) as u16).to_le_bytes(); - let mut b = vec![id, start[0], start[1], chunk.len() as u8]; - for p in chunk { - b.extend(((p[0] / scale as i32) as i16).to_le_bytes()); - b.extend(((p[1] / scale as i32) as i16).to_le_bytes()); - } - out.push(msg(b'R', seq, &b)); - seq = seq.wrapping_add(1); - } - out.push(msg(b'E', seq, &[id, n[0], n[1]])); - (out, seq.wrapping_add(1)) - } - - /// A street set around `origin`: begin, one message of whole lines each, end. - pub fn roads(mut seq: u8, id: u8, origin: [i32; 2], lines: &[(bool, Vec<[i32; 2]>)]) -> (Vec>, u8) { - let mut out = Vec::new(); - let mut b = vec![id]; - b.extend(origin[0].to_le_bytes()); - b.extend(origin[1].to_le_bytes()); - out.push(msg(b'G', seq, &b)); - seq = seq.wrapping_add(1); - let mut pts = 0u16; - for (major, l) in lines { - let mut b = vec![id, l.len() as u8, *major as u8]; - for p in l { - b.extend(((p[0] - origin[0]) as i16).to_le_bytes()); - b.extend(((p[1] - origin[1]) as i16).to_le_bytes()); - } - pts += l.len() as u16; - out.push(msg(b'H', seq, &b)); - seq = seq.wrapping_add(1); - } - let (n, p) = ((lines.len() as u16).to_le_bytes(), pts.to_le_bytes()); - out.push(msg(b'J', seq, &[id, n[0], n[1], p[0], p[1]])); - (out, seq.wrapping_add(1)) - } -} - -#[cfg(test)] -mod tests { - use super::enc::*; - use super::*; - use std::boxed::Box; - - fn active() -> State { - State { - flags: F_ACTIVE | F_FIX, - maneuver: man::LEFT, - dist_m: 350, - x: -12, - y: 40000, - course: 16384, - ..State::default() - } - } - - #[test] - fn state_round_trips() { - let mut m = Box::new(Model::new()); - let s = State { - limit: 50, - remaining_10m: 820, - remaining_s: 840, - after: man::RIGHT, - after_m: 90, - progress: 7, - ..active() - }; - assert_eq!(m.apply(&state(0, &s)), Effect::Changed); - assert_eq!(m.state, s); - assert!(m.has_state); - } - - fn drive_with_route(m: &mut Model) -> u8 { - let pts: Vec<[i32; 2]> = (0..10).map(|i| [0, i * 50]).collect(); - let (msgs, seq) = route(0, 1, &pts); - msgs.iter().for_each(|x| { - m.apply(x); - }); - m.apply(&state(seq, &active())); - seq.wrapping_add(1) - } - - #[test] - fn streets_swap_in_whole_and_follow_the_route() { - let mut m = Box::new(Model::new()); - let seq = drive_with_route(&mut m); - let lines = vec![(true, vec![[100, 100], [300, 100]]), (false, vec![[100, 0], [100, 400], [150, 450]])]; - let (msgs, seq) = roads(seq, 7, [100, 200], &lines); - let (last, rest) = msgs.split_last().unwrap(); - rest.iter().for_each(|x| { - assert_eq!(m.apply(x), Effect::Ignored); - }); - assert_eq!(m.roads().n_lines, 0, "nothing shows until the end"); - assert_eq!(m.apply(last), Effect::Changed); - let r = m.roads(); - assert_eq!((r.n_lines, r.n_pts), (2, 5)); - assert!(r.lines[0].major && !r.lines[1].major); - assert_eq!(r.line(&r.lines[1]).collect::>(), vec![[100, 0], [100, 400], [150, 450]]); - // the next set arrives beside the shown one - let (msgs, seq) = roads(seq, 8, [0, 0], &lines[..1]); - m.apply(&msgs[0]); - assert_eq!(m.roads().n_lines, 2); - msgs[1..].iter().for_each(|x| { - m.apply(x); - }); - assert_eq!(m.roads().n_lines, 1); - // the same route sent again in the same frame keeps them; a route in another frame drops them, once whole - let (msgs, seq) = route_in(seq, 2, &[[0, 0], [0, 10]], Some(5)); - msgs.iter().for_each(|x| { - m.apply(x); - }); - assert_eq!(m.roads().n_lines, 0, "the first route had no frame tag"); - let (msgs, seq) = roads(seq, 9, [0, 0], &lines[..1]); - msgs.iter().for_each(|x| { - m.apply(x); - }); - let (msgs, seq) = route_in(seq, 3, &[[0, 0], [0, 10]], Some(5)); - msgs.iter().for_each(|x| { - m.apply(x); - }); - assert_eq!(m.roads().n_lines, 1, "same frame"); - let (msgs, _) = route_in(seq, 4, &[[0, 0], [0, 10]], Some(6)); - m.apply(&msgs[0]); - assert_eq!(m.roads().n_lines, 1, "kept until the new line is whole"); - msgs[1..].iter().for_each(|x| { - m.apply(x); - }); - assert_eq!(m.roads().n_lines, 0, "another frame"); - } - - #[test] - fn a_short_street_set_is_dropped() { - let mut m = Box::new(Model::new()); - let seq = drive_with_route(&mut m); - let lines = vec![(true, vec![[0, 0], [10, 0]]), (false, vec![[0, 0], [0, 10]])]; - let (msgs, _) = roads(seq, 3, [0, 0], &lines); - m.apply(&msgs[0]); - m.apply(&msgs[1]); - // msgs[2] lost: the end's seq jumps, so the watch asks again, and the set is not shown - assert_eq!(m.apply(&msgs[3]), Effect::Resync); - assert_eq!(m.roads().n_lines, 0); - // garbage never panics - m.apply(&msg(b'H', 0, &[3, 31, 0])); - m.apply(&msg(b'G', 1, &[1])); - } - - #[test] - fn route_is_shown_only_when_complete() { - let mut m = Box::new(Model::new()); - let pts: std::vec::Vec<[i32; 2]> = (0..100).map(|i| [i * 37 - 2000, i * i * 9]).collect(); - let (msgs, _) = route(0, 3, &pts); - assert_eq!(msgs.len(), 1 + 4 + 1); - for (i, msg) in msgs.iter().enumerate() { - m.apply(msg); - assert_eq!(m.route_len, if i + 1 == msgs.len() { 100 } else { 0 }); - assert_eq!(m.apply(&state(0, &active())), Effect::Resync); // (seq aside) a state between keeps it - m.reset_seq(); - } - // max |v| is 89100 m, so scale 3: points come back within 3 m - for (a, b) in m.route[..100].iter().zip(&pts) { - assert!((a[0] - b[0]).abs() < 3 && (a[1] - b[1]).abs() < 3, "{a:?} {b:?}"); - } - } - - #[test] - fn a_lost_chunk_asks_again_and_shows_no_line() { - let mut m = Box::new(Model::new()); - let pts: std::vec::Vec<[i32; 2]> = (0..90).map(|i| [i, -i]).collect(); - let (msgs, _) = route(10, 1, &pts); - assert_eq!(m.apply(&msgs[0]), Effect::Ignored); - assert_eq!(m.apply(&msgs[1]), Effect::Ignored); - assert_eq!(m.apply(&msgs[3]), Effect::Resync); // chunk 2 lost - assert_eq!(m.apply(&msgs[4]), Effect::Resync); - assert_eq!(m.route_len, 0); - } - - #[test] - fn a_new_line_replaces_the_shown_one_only_when_whole() { - let mut m = Box::new(Model::new()); - let a: Vec<[i32; 2]> = (0..40).map(|i| [0, i * 10]).collect(); - let b: Vec<[i32; 2]> = (0..40).map(|i| [i * 10, 0]).collect(); - let (msgs, seq) = route_in(0, 1, &a, Some(7)); - msgs.iter().for_each(|x| { - m.apply(x); - }); - assert_eq!((m.route_len, m.route[39]), (40, [0, 390])); - let (msgs, _) = route_in(seq, 2, &b, Some(7)); - for (i, x) in msgs.iter().enumerate() { - m.apply(x); - // the old line shows while the new one arrives: never an empty map - let want = if i + 1 == msgs.len() { [390, 0] } else { [0, 390] }; - assert_eq!((m.route_len, m.route[39]), (40, want)); - } - } - - #[test] - fn seq_gap_and_wrap() { - let mut m = Box::new(Model::new()); - assert_eq!(m.apply(&state(255, &active())), Effect::Changed); - assert_eq!(m.apply(&state(0, &active())), Effect::Changed); - assert_eq!(m.apply(&state(2, &active())), Effect::Resync); - m.reset_seq(); - assert_eq!(m.apply(&state(9, &active())), Effect::Changed); - } - - #[test] - fn synced_only_by_a_snapshot_end() { - let mut m = Box::new(Model::new()); - m.apply(&state(0, &active())); - assert!(!m.synced); - m.apply(&state(1, &State { flags: active().flags | F_SNAPSHOT, ..active() })); - assert!(m.synced); - m.apply(&state(5, &active())); // gap - assert!(!m.synced); - } - - #[test] - fn ending_the_drive_drops_the_line() { - let mut m = Box::new(Model::new()); - let (msgs, seq) = route(0, 1, &[[0, 0], [10, 10]]); - msgs.iter().for_each(|x| { - m.apply(x); - }); - assert_eq!(m.route_len, 2); - m.apply(&state(seq, &State::default())); - assert_eq!(m.route_len, 0); - } - - #[test] - fn junk_is_ignored() { - let mut m = Box::new(Model::new()); - for junk in [ - &b""[..], - b"n", - b"x1S\x00", - b"n1S\x00\x01", - b"n1Z\x00abc", - b"n1B\x00\x01\xff\xff\x01", - b"n1B\x00\x01\x02\x00\x00", - ] { - m.reset_seq(); - assert_eq!(m.apply(junk), Effect::Ignored, "{junk:?}"); - } - assert!(!m.has_state); - } - - #[test] - fn text_is_cut_on_a_char_boundary() { - let mut m = Box::new(Model::new()); - let mut long = std::vec::Vec::from(&b"Stra\xc3\x9fe "[..]); - long.resize(99, b'a'); - long.extend_from_slice("ß".as_bytes()); // 2 bytes, crosses 100 - m.apply(&msg(b'T', 0, &long)); - assert_eq!(m.text().len(), 99); - m.apply(&msg(b'T', 1, b"Main St\xff")); - assert_eq!(m.text(), "Main St"); - } -} diff --git a/apps/vela-nav/src/sign.rs b/apps/vela-nav/src/sign.rs deleted file mode 100644 index a9add37..0000000 --- a/apps/vela-nav/src/sign.rs +++ /dev/null @@ -1,204 +0,0 @@ -//! Turn signs drawn in one pass: the sign is a union of strokes with round ends, rings and triangles, and each -//! pixel's coverage comes from its distance to that union. Shapes drawn one over another would leave a dark -//! seam wherever two antialiased edges meet; this has none. - -use cmf_wp2_ui::color::blend565; -use cmf_wp2_ui::motion::{cos, sin}; -use cmf_wp2_ui::{ONE, Surface}; - -/// Sub-pixel units a pixel. -const U: i64 = 16; - -#[derive(Clone, Copy)] -enum Part { - /// A stroke from one point to another, round ends. - Seg((i32, i32), (i32, i32)), - /// A circle of a radius, stroked. - Ring((i32, i32), i32), - /// A filled triangle. - Tri([(i32, i32); 3]), -} - -pub struct Sign { - parts: [Part; 24], - n: usize, - /// Stroke width in px. - w: i32, - /// A black outline this many px wide around the sign, drawn in the same pass, so it reads over the map. - pub halo: i32, -} - -impl Sign { - pub fn new(w: i32) -> Sign { - Sign { parts: [Part::Ring((0, 0), 0); 24], n: 0, w, halo: 0 } - } - - fn push(&mut self, p: Part) -> &mut Sign { - if self.n < self.parts.len() { - self.parts[self.n] = p; - self.n += 1; - } - self - } - - pub fn seg(&mut self, a: (i32, i32), b: (i32, i32)) -> &mut Sign { - self.push(Part::Seg(a, b)) - } - - pub fn ring(&mut self, c: (i32, i32), r: i32) -> &mut Sign { - self.push(Part::Ring(c, r)) - } - - pub fn tri(&mut self, t: [(i32, i32); 3]) -> &mut Sign { - self.push(Part::Tri(t)) - } - - /// A stroked arc around `c` of radius `r`, from angle `start` over `sweep` (u16 turns, 0 = 3 o'clock, - /// clockwise on screen; negative goes the other way), as `steps` straight pieces. - pub fn arc(&mut self, c: (i32, i32), r: i32, start: u16, sweep: i32, steps: i32) -> &mut Sign { - let at = |a: u16| (c.0 + ((r * cos(a)) >> 14), c.1 + ((r * sin(a)) >> 14)); - let mut prev = at(start); - for i in 1..=steps { - let p = at(start.wrapping_add((sweep * i / steps) as u16)); - self.seg(prev, p); - prev = p; - } - self - } - - /// Distance from `p` (in 1/U px) to the part's edge, in 1/U px; negative inside. - fn dist(&self, part: &Part, p: (i64, i64)) -> i64 { - let half = self.w as i64 * U / 2; - let q = |v: (i32, i32)| (v.0 as i64 * U + U / 2, v.1 as i64 * U + U / 2); - match *part { - Part::Seg(a, b) => { - let (a, b) = (q(a), q(b)); - let (dx, dy) = (b.0 - a.0, b.1 - a.1); - let len2 = dx * dx + dy * dy; - let t = if len2 == 0 { 0 } else { ((p.0 - a.0) * dx + (p.1 - a.1) * dy).clamp(0, len2) }; - let (cx, cy) = if len2 == 0 { a } else { (a.0 + dx * t / len2, a.1 + dy * t / len2) }; - near((p.0 - cx).pow(2) + (p.1 - cy).pow(2), half, (self.halo as i64 + 1) * U) - } - Part::Ring(c, r) => { - let c = q(c); - (isqrt((p.0 - c.0).pow(2) + (p.1 - c.1).pow(2)) - r as i64 * U).abs() - half - } - Part::Tri(t) => { - let v = [q(t[0]), q(t[1]), q(t[2])]; - let area = (v[1].0 - v[0].0) * (v[2].1 - v[0].1) - (v[1].1 - v[0].1) * (v[2].0 - v[0].0); - let sign = if area > 0 { 1 } else { -1 }; - (0..3) - .map(|i| { - let (a, b) = (v[i], v[(i + 1) % 3]); - let (ex, ey) = (b.0 - a.0, b.1 - a.1); - let len = isqrt(ex * ex + ey * ey).max(1); - // outward distance from the edge's line - -sign * (ex * (p.1 - a.1) - ey * (p.0 - a.0)) / len - }) - .max() - .unwrap_or(0) - } - } - } - - /// The part's box in px, grown by the stroke and a pixel of soft edge. - fn bbox(&self, part: &Part) -> (i32, i32, i32, i32) { - let g = self.w / 2 + 2 + self.halo; - let (x0, y0, x1, y1) = match *part { - Part::Seg(a, b) => (a.0.min(b.0), a.1.min(b.1), a.0.max(b.0), a.1.max(b.1)), - Part::Ring(c, r) => (c.0 - r, c.1 - r, c.0 + r, c.1 + r), - Part::Tri(t) => ( - t[0].0.min(t[1].0).min(t[2].0), - t[0].1.min(t[1].1).min(t[2].1), - t[0].0.max(t[1].0).max(t[2].0), - t[0].1.max(t[1].1).max(t[2].1), - ), - }; - (x0 - g, y0 - g, x1 + g, y1 + g) - } - - /// Draws the sign in colour `c` over `bg` (over its own black outline when it has a `halo`), looking only inside - /// the box `x0..x1`, `y0..y1`. - #[allow(clippy::too_many_arguments)] - pub fn draw(&self, s: &mut impl Surface, x0: i32, y0: i32, x1: i32, y1: i32, c: u16, bg: u16) { - let mut boxes = [(0, 0, 0, 0); 24]; - for (b, part) in boxes.iter_mut().zip(&self.parts[..self.n]) { - *b = self.bbox(part); - } - let bg = if self.halo > 0 { 0 } else { bg }; - // 0 nothing, 1..=16 the sign's coverage, 17 the outline - let mut shade = [0u16; 18]; - for (k, v) in shade.iter_mut().enumerate().take(17) { - *v = blend565(bg, c, k as i32 * ONE / 16); - } - let outline = self.halo as i64 * U + U / 2; - for y in y0..y1 { - let mut run: Option<(i32, usize)> = None; - for x in x0..=x1 { - let k = if x == x1 { - usize::MAX // flush - } else { - let p = (x as i64 * U + U / 2, y as i64 * U + U / 2); - let d = self.parts[..self.n] - .iter() - .zip(&boxes) - .filter(|(_, b)| x >= b.0 && x <= b.2 && y >= b.1 && y <= b.3) - .map(|(part, _)| self.dist(part, p)) - .min() - .unwrap_or(i64::MAX / 2); - let k = (U / 2 - d).clamp(0, U) as usize; - if k == 0 && d < outline { 17 } else { k } - }; - match run { - Some((_, rk)) if rk == k => {} - _ => { - if let Some((rx, rk)) = run - && rk > 0 - { - s.rect(rx, y, x - rx, 1, shade[rk]); - } - run = Some((x, k)); - } - } - } - } - } -} - -/// The three corners of an arrowhead with its tip at `tip`, pointing along `a` (turns clockwise from up), `h` px -/// long. -pub fn head(tip: (i32, i32), a: u16, h: i32) -> [(i32, i32); 3] { - let d = |a: u16, r: i32| ((r * sin(a)) >> 14, -(r * cos(a)) >> 14); - let back = d(a, -h); - let side = d(a.wrapping_add(0x4000), h * 4 / 5); - let base = (tip.0 + back.0, tip.1 + back.1); - [tip, (base.0 + side.0, base.1 + side.1), (base.0 - side.0, base.1 - side.1)] -} - -/// The distance from `d2`, a squared distance, to a stroke of half width `half`, with the square root taken only -/// where it matters: well inside is `-U`, beyond `reach` outside is `reach`. -fn near(d2: i64, half: i64, reach: i64) -> i64 { - let out = half + reach; - if d2 >= out * out { - return reach; - } - let inn = (half - U).max(0); - if d2 <= inn * inn && half >= U { - return -U; - } - isqrt(d2) - half -} - -fn isqrt(n: i64) -> i64 { - if n < 2 { - return n.max(0); - } - let mut x = 1i64 << ((64 - n.leading_zeros()).div_ceil(2)); - loop { - let y = (x + n / x) / 2; - if y >= x { - return x; - } - x = y; - } -} diff --git a/apps/vela-nav/src/view.rs b/apps/vela-nav/src/view.rs deleted file mode 100644 index a35b9d0..0000000 --- a/apps/vela-nav/src/view.rs +++ /dev/null @@ -1,996 +0,0 @@ -//! Drawing, against `Surface`: the watch through `&Api`, a host framebuffer in tests. -//! -//! Layout on the round 466 px panel, black like the stock faces: a heading-up map fills it, the route in white -//! around the car over the streets nearby, which fade out away from the route (as Vela's ESP32 display does them). -//! Over the map, in white with a black outline: the time now, the time left big with the distance and arrival, and -//! the road at the top; the next turn big at the bottom (arrow, distance, speed limit) over an arc that fills as -//! the drive goes. Text is Noto Sans (`font`, `fonts`), with the loader's pixel font for a road name in a script -//! those fonts lack. - -use crate::font::{Font, poly}; -use crate::fonts::{L, S, XL}; -use crate::proto::{Model, man}; -use crate::sign::{Sign, head}; -use cmf_wp2_ui::draw::{arc, disc, line, ring, stroke}; -use cmf_wp2_ui::motion::{Q14, cos, isqrt, sin}; -use cmf_wp2_ui::text::fitted; -use cmf_wp2_ui::{C, CHAR, Rgb, SIZE, Surface, geom}; -use core::fmt::Write; - -const BLACK: Rgb = Rgb(0, 0, 0); -const WHITE: Rgb = Rgb(255, 255, 255); -const SHADE: Rgb = Rgb(178, 180, 186); -const GREY: Rgb = Rgb(140, 140, 146); -const TRACK: Rgb = Rgb(58, 58, 62); -const PASSED: Rgb = Rgb(62, 62, 68); -const ACCENT: Rgb = Rgb(255, 160, 0); -const RED: Rgb = Rgb(228, 36, 36); - -/// Streets at full strength, beside the route; they fade to black away from it. -const ROAD_MINOR: Rgb = Rgb(0x4A, 0x50, 0x57); -const ROAD_MAJOR: Rgb = Rgb(0x6E, 0x75, 0x7E); -/// The car, heading up. -pub const CAR: (i32, i32) = (C, 278); -/// The progress arc along the bottom edge: radii, and half its span either side of 6 o'clock. -const ARC_R: (i32, i32) = (214, 222); -const ARC_HALF: u32 = 8192; // 45° -/// Map scales the crown steps through, in metres per pixel. -pub const ZOOMS: [i32; 6] = [1, 2, 3, 5, 8, 13]; -pub const ZOOM_DEFAULT: usize = 2; - -/// How far each part of the screen is from the route ahead: cells of `CELL` px, each a distance in half cells. -/// Rebuilt each frame; 3.5 KB, so it lives in a static on the watch. -pub struct Fade { - d: [u8; GRID * GRID], -} -const CELL: i32 = 8; -const GRID: usize = (SIZE as usize).div_ceil(CELL as usize); -/// Streets are at full strength up to this far from the route, and gone from the second. -const FADE_PX: (i32, i32) = (24, 160); -const SHADES: usize = 16; - -impl Fade { - pub const fn new() -> Fade { - Fade { d: [255; GRID * GRID] } - } - - fn seed(&mut self, x: i32, y: i32) { - if (0..SIZE).contains(&x) && (0..SIZE).contains(&y) { - self.d[(y / CELL) as usize * GRID + (x / CELL) as usize] = 0; - } - } - - /// The shade (0 none .. SHADES-1 full) of a street at (x, y). - fn shade(&self, x: i32, y: i32) -> usize { - if !(0..SIZE).contains(&x) || !(0..SIZE).contains(&y) { - return 0; - } - let px = self.d[(y / CELL) as usize * GRID + (x / CELL) as usize] as i32 * (CELL / 2); - let (near, far) = FADE_PX; - if px <= near { - SHADES - 1 - } else if px >= far { - 0 - } else { - ((far - px) * (SHADES as i32 - 1) / (far - near)) as usize - } - } - - /// Seeds the car and the route ahead, then spreads: a two-pass chamfer distance, 2 a cell straight and 3 - /// diagonally. - fn build(&mut self, m: &Model, at: Pose, mpp: i32) { - self.d.fill(255); - self.seed(CAR.0, CAR.1); - let st = &m.state; - if m.route_len >= 2 { - let from = (st.progress as usize).clamp(1, m.route_len) - 1; - let mut prev: Option<(i32, i32)> = None; - for i in from..m.route_len { - let p = project(m.route[i], at.pos(), at.course, mpp); - if let Some(q) = prev - && let Some((a, b)) = clip(q, p, 0, SIZE - 1) - { - let (dx, dy) = (b.0 - a.0, b.1 - a.1); - let steps = dx.abs().max(dy.abs()) / (CELL / 2) + 1; - for k in 0..=steps { - self.seed(a.0 + dx * k / steps, a.1 + dy * k / steps); - } - } - prev = Some(p); - } - } - let g = GRID; - let d = &mut self.d; - let relax = |v: &mut u8, n: u8, cost: u8| *v = (*v).min(n.saturating_add(cost)); - for y in 0..g { - for x in 0..g { - let mut v = d[y * g + x]; - if x > 0 { - relax(&mut v, d[y * g + x - 1], 2); - } - if y > 0 { - relax(&mut v, d[(y - 1) * g + x], 2); - if x > 0 { - relax(&mut v, d[(y - 1) * g + x - 1], 3); - } - if x + 1 < g { - relax(&mut v, d[(y - 1) * g + x + 1], 3); - } - } - d[y * g + x] = v; - } - } - for y in (0..g).rev() { - for x in (0..g).rev() { - let mut v = d[y * g + x]; - if x + 1 < g { - relax(&mut v, d[y * g + x + 1], 2); - } - if y + 1 < g { - relax(&mut v, d[(y + 1) * g + x], 2); - if x > 0 { - relax(&mut v, d[(y + 1) * g + x - 1], 3); - } - if x + 1 < g { - relax(&mut v, d[(y + 1) * g + x + 1], 3); - } - } - d[y * g + x] = v; - } - } - } -} - -impl Default for Fade { - fn default() -> Self { - Fade::new() - } -} - -/// The streets around, under the route: minor 3 px, major 5 px, each pixel run shaded by how far it is from the -/// route. -fn roads(s: &mut impl Surface, m: &Model, fade: &Fade, at: Pose, mpp: i32) { - let r = m.roads(); - let ramp = |c: Rgb| { - let mut out = [BLACK; SHADES]; - for (i, v) in out.iter_mut().enumerate() { - *v = BLACK.mix(c, i as i32 * cmf_wp2_ui::ONE / (SHADES as i32 - 1)); - } - out - }; - let (minor, major) = (ramp(ROAD_MINOR), ramp(ROAD_MAJOR)); - for l in &r.lines[..r.n_lines] { - let (colours, w) = if l.major { (&major, 5) } else { (&minor, 3) }; - let mut prev: Option<(i32, i32)> = None; - for p in r.line(l) { - let p = project(p, at.pos(), at.course, mpp); - if let Some(q) = prev - && let Some((a, b)) = clip(q, p, -w, SIZE + w) - { - let (dx, dy) = (b.0 - a.0, b.1 - a.1); - let len = isqrt(256 * (dx * dx + dy * dy)); - if len > 0 { - let (ux, uy) = (dx * Q14 * 16 / len, dy * Q14 * 16 / len); - let q2 = (Q14 as i64) * (Q14 as i64); - // `along` is the distance from `a` in Q14 px - let shade = |along: i32| { - let x = a.0 + (ux as i64 * along as i64 / q2) as i32; - let y = a.1 + (uy as i64 * along as i64 / q2) as i32; - colours[fade.shade(x, y)] - }; - // only the stretches that are not faded out: a black stroke on black is wasted rects - let total = (len + 8) / 16; - let lit = |k: i32| { - let k = k.min(total); - fade.shade( - a.0 + ((ux as i64 * k as i64) >> 14) as i32, - a.1 + ((uy as i64 * k as i64) >> 14) as i32, - ) > 0 - }; - let step = CELL / 2; - let mut k = 0; - while k <= total { - if !lit(k) { - k += step; - continue; - } - let start = (k - step).max(0); - while k <= total && lit(k) { - k += step; - } - stroke(s, a.0, a.1, ux, uy, start, k.min(total), w, 0, shade, BLACK); - } - } - } - prev = Some(p); - } - } -} - -/// Text over the map: a black outline, then the text. Returns the pen position after it. -fn ink(f: &Font, s: &mut impl Surface, x: i32, y: i32, t: &str, c: Rgb) -> i32 { - f.halo(s, x, y, t, if f.cap > 20 { 3 } else { 2 }); - f.draw(s, x, y, t, c.rgb565(), 0) -} - -/// [ink], centred on `cx` and cut with an ellipsis to `max` px. -fn ink_centre(f: &Font, s: &mut impl Surface, cx: i32, y: i32, t: &str, max: i32, c: Rgb) { - let (t, cut) = f.fit(t, max); - let w = f.width(t) + if cut { f.width("…") } else { 0 }; - let end = ink(f, s, cx - w / 2, y, t, c); - if cut { - ink(f, s, end, y, "…", c); - } -} - -/// The car gliding from where it is drawn to the phone's latest position, over the time the phone takes between -/// updates (about a second), so the map moves and turns smoothly instead of jumping once a second. It runs a -/// little behind the phone for that. A jump of more than `SNAP_M` (a new route, a reroute) is not glided. -pub struct Glide { - from: Pose, - to: Pose, - t0: u32, - dur: u32, - last: Option, -} - -const SNAP_M: i32 = 300; - -impl Glide { - pub const fn new() -> Glide { - let p = Pose { x: 0, y: 0, course: 0 }; - Glide { from: p, to: p, t0: 0, dur: 1, last: None } - } - - /// A new position from the phone at `now` (ms). - pub fn target(&mut self, to: Pose, now: u32) { - if self.last.is_some() && to == self.to { - return; - } - let gap = self.last.map_or(0, |t| now.wrapping_sub(t)).clamp(300, 1500); - let jump = (to.x - self.to.x).abs().max((to.y - self.to.y).abs()) > SNAP_M; - self.from = if self.last.is_none() || jump { to } else { self.at(now) }; - (self.to, self.t0, self.dur, self.last) = (to, now, gap, Some(now)); - } - - /// Where to draw the car at `now`. - pub fn at(&self, now: u32) -> Pose { - let k = (now.wrapping_sub(self.t0).min(self.dur) as i64 * cmf_wp2_ui::ONE as i64 / self.dur as i64) as i32; - self.from.toward(self.to, k) - } - - /// Still on its way. - pub fn moving(&self, now: u32) -> bool { - now.wrapping_sub(self.t0) < self.dur && self.from != self.to - } -} - -impl Default for Glide { - fn default() -> Self { - Glide::new() - } -} - -/// What the screen is about, besides the model itself. -pub struct Ctx { - /// The phone has been heard from recently. - pub live: bool, - /// Local time of day (hours, minutes), when the watch has it. - pub clock: Option<(u8, u8)>, - pub zoom: usize, - /// Where the car is drawn, when it glides between the phone's updates; else the last state's. - pub pose: Option, - /// The Home / Work button just tapped, while the phone starts that drive. - pub pending: Option, -} - -/// The buttons on the screen without a drive: what each asks for, its label, and its top. -pub const BUTTONS: [(u8, &str, i32); 2] = [(crate::proto::P_HOME, "Home", 186), (crate::proto::P_WORK, "Work", 276)]; -const BUTTON_W: i32 = 300; -const BUTTON_H: i32 = 76; -const PILL: Rgb = Rgb(40, 40, 46); - -/// The button under a tap at `y`, if any. Only `y` is reliable on this panel, and the buttons are stacked. -pub fn button_at(y: i32) -> Option { - BUTTONS.iter().find(|b| y >= b.2 - 6 && y < b.2 + BUTTON_H + 6).map(|b| b.0) -} - -/// A house or a briefcase, `fg` on the button's `bg`. -fn place_icon(s: &mut impl Surface, kind: u8, cx: i32, cy: i32, fg: Rgb, bg: Rgb) { - let (k, b) = (fg.rgb565(), bg.rgb565()); - if kind == crate::proto::P_HOME { - let house = [ - (cx, cy - 15), - (cx + 15, cy - 1), - (cx + 11, cy - 1), - (cx + 11, cy + 13), - (cx - 11, cy + 13), - (cx - 11, cy - 1), - (cx - 15, cy - 1), - ]; - poly(s, &house, b, |_| k); - s.rect(cx - 3, cy + 4, 7, 9, b); // the door - } else { - cmf_wp2_ui::draw::rrect(s, cx - 7, cy - 14, 14, 10, 3, fg, bg); // the handle - cmf_wp2_ui::draw::rrect(s, cx - 3, cy - 10, 6, 7, 1, bg, fg); - cmf_wp2_ui::draw::rrect(s, cx - 15, cy - 7, 30, 21, 4, fg, bg); - s.rect(cx - 15, cy + 1, 30, 2, b); // the lid's seam - } -} - -/// The screen without a drive: Home and Work, each a tap away from a drive there. -fn launcher(s: &mut impl Surface, m: &Model, pending: Option) { - s.rect(0, 0, SIZE, SIZE, 0); - L.draw(s, C - L.width("Vela Nav") / 2, 136, "Vela Nav", WHITE.rgb565(), 0); - for (kind, label, top) in BUTTONS { - let set = m.places & kind != 0; - let on = pending == Some(kind); - let (fill, fg) = if on { - (WHITE, BLACK) - } else if set { - (PILL, WHITE) - } else { - (Rgb(24, 24, 28), Rgb(90, 90, 96)) - }; - let x = C - BUTTON_W / 2; - cmf_wp2_ui::draw::rrect(s, x, top, BUTTON_W, BUTTON_H, BUTTON_H / 2, fill, BLACK); - let cy = top + BUTTON_H / 2; - place_icon(s, kind, x + 58, cy, fg, fill); - let text = if on { "Starting…" } else { label }; - L.draw(s, x + 96, cy + L.cap / 2, text, fg.rgb565(), fill.rgb565()); - } - let note = if m.start == crate::proto::START_FAILED { - "Couldn't plan that drive" - } else if m.places == 0 { - "Set Home and Work in Vela" - } else { - "or start one in Vela" - }; - small(s, 396, note, if m.start == crate::proto::START_FAILED { ACCENT } else { GREY }); -} - -/// The car's position (metres, the route's frame) and heading (1/65536 turns clockwise from north). -#[derive(Clone, Copy, PartialEq, Debug)] -pub struct Pose { - pub x: i32, - pub y: i32, - pub course: u16, -} - -impl Pose { - pub fn of(st: &crate::proto::State) -> Pose { - Pose { x: st.x, y: st.y, course: st.course } - } - - fn pos(self) -> [i32; 2] { - [self.x, self.y] - } - - /// `k` (0..=ONE) of the way from `self` to `to`, turning the short way round. - pub fn toward(self, to: Pose, k: i32) -> Pose { - let k = k.clamp(0, cmf_wp2_ui::ONE) as i64; - let lerp = |a: i32, b: i32| a + ((b as i64 - a as i64) * k / cmf_wp2_ui::ONE as i64) as i32; - let turn = to.course.wrapping_sub(self.course) as i16 as i64; - let course = self.course.wrapping_add((turn * k / cmf_wp2_ui::ONE as i64) as i16 as u16); - Pose { x: lerp(self.x, to.x), y: lerp(self.y, to.y), course } - } - - /// The largest change between the two on screen at `mpp` metres a pixel, in pixels (turning counts as the - /// move of a point at the screen's edge). - pub fn moved_px(self, to: Pose, mpp: i32) -> i32 { - let d = ((to.x - self.x).abs().max((to.y - self.y).abs()) / mpp.max(1)) as i64; - let turn = (to.course.wrapping_sub(self.course) as i16 as i64).abs(); - d.max(turn * C as i64 * 6 / 65536) as i32 - } -} - -/// A small text buffer for `write!` without a heap. -pub struct Buf { - b: [u8; 32], - n: usize, -} - -impl Buf { - pub fn new() -> Buf { - Buf { b: [0; 32], n: 0 } - } - pub fn as_str(&self) -> &str { - core::str::from_utf8(&self.b[..self.n]).unwrap_or("") - } -} - -impl Default for Buf { - fn default() -> Self { - Buf::new() - } -} - -impl Write for Buf { - fn write_str(&mut self, s: &str) -> core::fmt::Result { - let k = s.len().min(self.b.len() - self.n); - self.b[self.n..self.n + k].copy_from_slice(&s.as_bytes()[..k]); - self.n += k; - Ok(()) - } -} - -/// "350 m", "1.2 km", "14 km"; "500 ft", "0.3 mi", "12 mi". -pub fn distance(m: u32, imperial: bool) -> Buf { - let mut b = Buf::new(); - let _ = if imperial { - if m < 161 { - write!(b, "{} ft", (m * 3281 / 1000 + 25) / 50 * 50) - } else { - let tenths = (m * 100 + 8047) / 16093; // m / 160.93, rounded - if tenths < 100 { - write!(b, "{}.{} mi", tenths / 10, tenths % 10) - } else { - write!(b, "{} mi", (tenths + 5) / 10) - } - } - } else if m < 1000 { - write!(b, "{} m", if m < 100 { m / 5 * 5 } else { m / 10 * 10 }) - } else if m < 10_000 { - let h = (m + 50) / 100; - write!(b, "{}.{} km", h / 10, h % 10) - } else { - write!(b, "{} km", (m + 500) / 1000) - }; - b -} - -/// "14 min", "1 h 05". -pub fn duration(s: u32) -> Buf { - let mut b = Buf::new(); - let min = (s + 30) / 60; - let _ = if min < 60 { write!(b, "{} min", min) } else { write!(b, "{} h {:02}", min / 60, min % 60) }; - b -} - -/// The time of day `s` seconds after `clock`, "17:05" or "5:05 pm". -pub fn arrival(clock: (u8, u8), s: u32, h24: bool) -> Buf { - let total = (clock.0 as u32 * 60 + clock.1 as u32 + (s + 30) / 60) % (24 * 60); - let (h, m) = (total / 60, total % 60); - let mut b = Buf::new(); - let _ = if h24 { - write!(b, "{:02}:{:02}", h, m) - } else { - write!(b, "{}:{:02} {}", if h % 12 == 0 { 12 } else { h % 12 }, m, if h < 12 { "am" } else { "pm" }) - }; - b -} - -/// A route point in metres → screen pixels, heading up around `CAR`. Far points are clamped (they only feed the -/// clipper). -pub fn project(p: [i32; 2], car: [i32; 2], course: u16, mpp: i32) -> (i32, i32) { - let (dx, dy) = (p[0] as i64 - car[0] as i64, p[1] as i64 - car[1] as i64); - let (s, c) = (sin(course) as i64, cos(course) as i64); - let right = (dx * c - dy * s) / (Q14 as i64 * mpp as i64); - let ahead = (dx * s + dy * c) / (Q14 as i64 * mpp as i64); - const LIM: i64 = 1 << 20; - ((CAR.0 as i64 + right.clamp(-LIM, LIM)) as i32, (CAR.1 as i64 - ahead.clamp(-LIM, LIM)) as i32) -} - -/// Cohen–Sutherland: the part of a segment inside `[lo, hi]²`, or `None`. -pub fn clip(mut a: (i32, i32), mut b: (i32, i32), lo: i32, hi: i32) -> Option<((i32, i32), (i32, i32))> { - let code = - |p: (i32, i32)| (p.0 < lo) as u8 | ((p.0 > hi) as u8) << 1 | ((p.1 < lo) as u8) << 2 | ((p.1 > hi) as u8) << 3; - let (mut ca, mut cb) = (code(a), code(b)); - for _ in 0..8 { - if ca | cb == 0 { - return Some((a, b)); - } - if ca & cb != 0 { - return None; - } - let out = if ca != 0 { ca } else { cb }; - let (x0, y0, x1, y1) = (a.0 as i64, a.1 as i64, b.0 as i64, b.1 as i64); - let p = if out & 8 != 0 { - (x0 + (x1 - x0) * (hi as i64 - y0) / (y1 - y0), hi as i64) - } else if out & 4 != 0 { - (x0 + (x1 - x0) * (lo as i64 - y0) / (y1 - y0), lo as i64) - } else if out & 2 != 0 { - (hi as i64, y0 + (y1 - y0) * (hi as i64 - x0) / (x1 - x0)) - } else { - (lo as i64, y0 + (y1 - y0) * (lo as i64 - x0) / (x1 - x0)) - }; - let p = (p.0 as i32, p.1 as i32); - if out == ca { - (a, ca) = (p, code(p)); - } else { - (b, cb) = (p, code(p)); - } - } - None -} - -#[allow(clippy::too_many_arguments)] -fn polyline(s: &mut impl Surface, m: &Model, from: usize, to: usize, w: i32, c: Rgb, at: Pose, mpp: i32) { - let (car, course) = (at.pos(), at.course); - let mut prev: Option<(i32, i32)> = None; - for i in from..to { - let p = project(m.route[i], car, course, mpp); - if let Some(q) = prev - && let Some((a, b)) = clip(q, p, -w, SIZE + w) - { - line(s, a.0, a.1, b.0, b.1, w, c, BLACK); - } - prev = Some(p); - } - // Round every joint in a second pass: a segment's soft end would otherwise darken the one before it, and - // the bends would have notches. The disc's soft edge is painted solid (bg = c), so a radius one short of - // the line's half width fills it to the line's own soft edge without a bump. - for i in from + 1..to.saturating_sub(1) { - let p = project(m.route[i], car, course, mpp); - if geom::inside(p.0, p.1) { - disc(s, p.0, p.1, w / 2 - 1, c, c); - } - } -} - -/// Direction `a` (turns, clockwise from up) as a screen vector of length `r`. -fn dir(a: u16, r: i32) -> (i32, i32) { - ((r * sin(a)) >> 14, -(r * cos(a)) >> 14) -} - -/// A maneuver icon in a box of radius `r` around (cx, cy): thick strokes with round ends, like a road sign. -pub fn icon(s: &mut impl Surface, code: u8, cx: i32, cy: i32, r: i32, c: Rgb) { - let w = (r * 2 / 7).max(4); - let mut g = Sign::new(w); - g.halo = 3; - let hl = r * 3 / 5; // arrowhead length - // a stem up from the bottom that bends towards `a` at `elbow` below the centre - // (the stem leans away from the turn by `lean` so the whole sign sits centred) - let turn = |g: &mut Sign, a: u16, elbow: i32, len: i32, lean: i32, hl: i32| { - let sh = dir(a, len - hl / 2); - let x = cx - lean; - let e = (x, cy + elbow); - let tip = (x + dir(a, len).0, e.1 + dir(a, len).1); - g.seg((x, cy + r), e).seg(e, (x + sh.0, e.1 + sh.1)).tri(head(tip, a, hl)); - }; - let gentle = |g: &mut Sign, a: u16, elbow: i32| turn(g, a, elbow, r, dir(a, r * 2 / 5).0 / 2, hl); - let sharp = |g: &mut Sign, a: u16| turn(g, a, -r * 3 / 4, r * 13 / 10, dir(a, r).0 * 7 / 10, r / 2); - // a right angle with a round bend: up, then `sign` (1 right, -1 left) - let square = |g: &mut Sign, sign: i32| { - let rho = r * 3 / 5; - let (x, y) = (cx - sign * r / 2, cy - r / 3); - let tip = (cx + sign * r, y); - let start = if sign > 0 { 0x8000 } else { 0 }; - g.seg((x, cy + r), (x, y + rho)) - .arc((x + sign * rho, y + rho), rho, start, sign * 0x4000, 6) - .seg((x + sign * rho, y), (tip.0 - sign * hl / 2, y)) - .tri(head(tip, if sign > 0 { 0x4000 } else { 0xC000 }, hl)); - }; - match code { - man::CONTINUE => { - g.seg((cx, cy + r), (cx, cy - r + hl / 2)).tri(head((cx, cy - r), 0, hl)); - } - man::SLIGHT_LEFT => gentle(&mut g, 0xE000, 0), - man::SLIGHT_RIGHT => gentle(&mut g, 0x2000, 0), - man::LEFT => square(&mut g, -1), - man::RIGHT => square(&mut g, 1), - man::SHARP_LEFT => sharp(&mut g, 0xA000), - man::SHARP_RIGHT => sharp(&mut g, 0x6000), - man::KEEP_LEFT => gentle(&mut g, 0xF000, r / 4), - man::KEEP_RIGHT => gentle(&mut g, 0x1000, r / 4), - man::UTURN => { - let (rx, top) = (r / 2, cy - r / 4); - g.seg((cx + rx, cy + r), (cx + rx, top)) - .arc((cx, top), rx, 0, -0x8000, 10) - .seg((cx - rx, top), (cx - rx, cy + r - hl / 2)) - .tri(head((cx - rx, cy + r), 0x8000, hl)); - } - man::ROUNDABOUT => { - let rr = r * 2 / 5; - g.ring((cx, cy), rr) - .seg((cx, cy + r), (cx, cy + rr)) - .seg((cx, cy - rr), (cx, cy - r - 4 + r / 4)) - .tri(head((cx, cy - r - 4), 0, r / 2)); - } - man::ARRIVE => { - let pin = cy - r / 4; - let k = RED.rgb565(); - poly(s, &[(cx - r / 2 + 1, pin + r / 6), (cx + r / 2 - 1, pin + r / 6), (cx, cy + r)], 0, |_| k); - disc(s, cx, pin, r / 2, RED, BLACK); - disc(s, cx, pin, r / 5, WHITE, RED); - } - man::OFF_ROUTE => { - disc(s, cx, cy, r + 3, BLACK, BLACK); - ring(s, cx, cy, r - w, r, ACCENT, BLACK); - let k = ACCENT.rgb565(); - s.rect(cx - w / 2, cy - r / 2, w, r * 2 / 3, k); - s.rect(cx - w / 2, cy + r / 3, w, w, k); - } - _ => {} - } - let m = w + 6 + g.halo; - g.draw(s, cx - r - m, cy - r - m, cx + r + m, cy + r + m, c.rgb565(), 0); -} - -/// The car: a chevron pointing up, lit on its left face, with a black rim so it reads over the white route. -fn car(s: &mut impl Surface, fix: bool) { - let (x, y) = CAR; - let shape = |k: i32| [(x, y - 24 - k), (x + 18 + k, y + 18 + k), (x, y + 8 + k / 2), (x - 18 - k, y + 18 + k)]; - poly(s, &shape(5), 0, |_| 0); - let (lit, dark) = if fix { (WHITE.rgb565(), SHADE.rgb565()) } else { (GREY.rgb565(), TRACK.rgb565()) }; - poly(s, &shape(0), 0, |px| if px < x { lit } else { dark }); -} - -fn limit_badge(s: &mut impl Surface, limit: u8, x: i32, y: i32) { - disc(s, x, y, 31, RED, BLACK); - disc(s, x, y, 24, WHITE, RED); - let mut b = Buf::new(); - let _ = write!(b, "{}", limit); - let t = b.as_str(); - L.draw(s, x - L.width(t) / 2, y + L.cap / 2, t, 0, WHITE.rgb565()); -} - -/// How wide a text line with its baseline at `y` may be, from what the circle leaves there. -fn room(f: &crate::font::Font, y: i32, margin: i32) -> i32 { - let (x0, x1) = geom::chord(y - f.cap, y + f.descent / 2, margin); - x1 - x0 -} - -/// A line of small text centred at baseline `y`; a road name in a script the font lacks falls back to the -/// loader's font (ASCII and Cyrillic). -fn small(s: &mut impl Surface, y: i32, t: &str, c: Rgb) { - if S.covers(t) { - ink_centre(&S, s, C, y, t, room(&S, y, 14), c); - } else { - let (_, cells) = geom::text_box(y - S.cap, 14); - let n = cmf_wp2_ui::text::chars(t).min(cells); - fitted(s, C - n as i32 * CHAR / 2, y - S.cap, t, n, c.rgb565()); - } -} - -fn message(s: &mut impl Surface, title: &str, sub: &str) { - s.rect(0, 0, SIZE, SIZE, 0); - L.draw(s, C - L.width(title) / 2, C - 4, title, WHITE.rgb565(), 0); - small(s, C + 38, sub, GREY); -} - -/// The top: the time now, small; the time left, big, with the distance left and the arrival; the road. -fn header(s: &mut impl Surface, m: &Model, clock: Option<(u8, u8)>) { - let st = &m.state; - let rem = st.remaining_s as u32; - if let Some(c) = clock { - let now = arrival(c, 0, st.clock24()); - ink(&S, s, C - S.width(now.as_str()) / 2, 38, now.as_str(), GREY); - } - // "5 min" / "1 h 05" big, its numbers white and its units grey - let left = duration(rem); - let mut rest = Buf::new(); - let _ = write!(rest, " · {}", distance(st.remaining_10m as u32 * 10, st.imperial()).as_str()); - let eta = clock.map(|c| arrival(c, rem, st.clock24())); - let y = 88; - let max = room(&L, y, 4); - let mut w = L.width(left.as_str()) + S.width(rest.as_str()); - let eta_w = eta.as_ref().map_or(0, |e| S.width(" · ") + S.width(e.as_str())); - let show_eta = w + eta_w <= max; - if show_eta { - w += eta_w; - } - let mut x = C - w / 2; - for (k, word) in left.as_str().split(' ').enumerate() { - if k > 0 { - x += L.width(" "); - } - let digits = word.starts_with(|c: char| c.is_ascii_digit()); - x = ink(&L, s, x, y, word, if digits { WHITE } else { GREY }); - } - x = ink(&S, s, x, y, rest.as_str(), GREY); - if let (true, Some(e)) = (show_eta, &eta) { - x = ink(&S, s, x, y, " · ", GREY); - ink(&S, s, x, y, e.as_str(), WHITE); - } - small(s, 120, m.text(), WHITE); -} - -/// The share of the route behind the car, 0..=ONE, from the road distance left and the route line's length. -pub fn done(m: &Model) -> i32 { - let total = m.length_m(); - if total == 0 { - return 0; - } - let left = (m.state.remaining_10m as i64 * 10).min(total); - ((total - left) * cmf_wp2_ui::ONE as i64 / total) as i32 -} - -fn progress(s: &mut impl Surface, k: i32) { - let (r0, r1) = ARC_R; - let span = 2 * ARC_HALF; - let right = (0x4000 - ARC_HALF) as u16; - arc(s, C, C, r0, r1, right, span, TRACK, None, BLACK); - // filled from the left end, which is the start of the arc's span when going anticlockwise - let fill = span * k.clamp(0, cmf_wp2_ui::ONE) as u32 / cmf_wp2_ui::ONE as u32; - if fill > 0 { - arc(s, C, C, r0, r1, (0x4000 + ARC_HALF - fill) as u16, fill, WHITE, None, BLACK); - } - let rm = (r0 + r1) / 2; - let end = |a: u32| { - ( - (C as i64 + rm as i64 * cos(a as u16) as i64 / Q14 as i64) as i32, - (C as i64 + rm as i64 * sin(a as u16) as i64 / Q14 as i64) as i32, - ) - }; - let (l, rgt) = (end(0x4000 + ARC_HALF), end(0x4000 - ARC_HALF)); - disc(s, l.0, l.1, (r1 - r0) / 2, if fill > 0 { WHITE } else { TRACK }, BLACK); - disc(s, rgt.0, rgt.1, (r1 - r0) / 2, if fill >= span { WHITE } else { TRACK }, BLACK); -} - -/// The next turn, big at the bottom: arrow, distance, unit; the one after it small when it comes quickly. -fn turn(s: &mut impl Surface, m: &Model) { - let st = &m.state; - let y = 378; // baseline of the distance - if st.maneuver == man::OFF_ROUTE { - icon(s, man::OFF_ROUTE, C - 96, y - 28, 30, ACCENT); - ink(&L, s, C - 50, y - 26, "Off route", ACCENT); - ink(&S, s, C - 50, y + 8, "Rerouting…", GREY); - return; - } - let d = distance(st.dist_m as u32, st.imperial()); - let (num, unit) = d.as_str().split_once(' ').unwrap_or((d.as_str(), "")); - let (iw, gap, ugap) = (72, 22, 8); - let w = iw + gap + XL.width(num) + ugap + L.width(unit); - let x = C - w / 2; - icon(s, st.maneuver, x + iw / 2, y - XL.cap / 2, 34, WHITE); - let after = ink(&XL, s, x + iw + gap, y, num, WHITE); - let end = ink(&L, s, after + ugap, y, unit, GREY); - if st.after != man::NONE && st.after_m <= 300 { - icon(s, st.after, end + 26, y - L.cap - 30, 13, GREY); - } -} - -/// The whole screen. -pub fn draw(s: &mut impl Surface, m: &Model, ctx: &Ctx, fade: &mut Fade) { - let st = &m.state; - if !m.has_state || !ctx.live { - return message(s, "Vela Nav", if m.has_state { "Phone out of reach" } else { "Waiting for Vela…" }); - } - if !st.active() { - return launcher(s, m, ctx.pending); - } - if st.arrived() { - s.rect(0, 0, SIZE, SIZE, 0); - icon(s, man::ARRIVE, C, 168, 46, RED); - L.draw(s, C - L.width("Arrived") / 2, 268, "Arrived", WHITE.rgb565(), 0); - small(s, 308, m.text(), GREY); - return; - } - let mpp = ZOOMS[ctx.zoom.min(ZOOMS.len() - 1)]; - let at = ctx.pose.unwrap_or(Pose::of(st)); - s.rect(0, 0, SIZE, SIZE, 0); - if m.roads().n_lines > 0 { - fade.build(m, at, mpp); - roads(s, m, fade, at, mpp); - } - if m.route_len >= 2 { - let p = (st.progress as usize).clamp(1, m.route_len); - polyline(s, m, 0, p, 10, PASSED, at, mpp); - polyline(s, m, p - 1, m.route_len, 16, WHITE, at, mpp); - let end = project(m.route[m.route_len - 1], at.pos(), at.course, mpp); - if geom::inside(end.0, end.1) { - disc(s, end.0, end.1, 13, BLACK, WHITE); - disc(s, end.0, end.1, 9, RED, BLACK); - } - } - car(s, st.fix()); - if st.limit > 0 { - limit_badge(s, st.limit, 388, 282); - } - header(s, m, ctx.clock); - turn(s, m); - progress(s, done(m)); -} - -#[cfg(test)] -mod tests { - use super::*; - use crate::proto::enc::{route, state}; - use crate::proto::{F_ACTIVE, F_CLOCK24, F_FIX, State}; - use cmf_wp2_ui::Fb; - use std::boxed::Box; - use std::vec; - - #[test] - fn formats() { - assert_eq!(distance(347, false).as_str(), "340 m"); - assert_eq!(distance(42, false).as_str(), "40 m"); - assert_eq!(distance(1249, false).as_str(), "1.2 km"); - assert_eq!(distance(9960, false).as_str(), "10.0 km"); - assert_eq!(distance(23_600, false).as_str(), "24 km"); - assert_eq!(distance(100, true).as_str(), "350 ft"); - assert_eq!(distance(500, true).as_str(), "0.3 mi"); - assert_eq!(distance(40_000, true).as_str(), "25 mi"); - assert_eq!(duration(840).as_str(), "14 min"); - assert_eq!(duration(3900).as_str(), "1 h 05"); - assert_eq!(arrival((23, 50), 1200, true).as_str(), "00:10"); - assert_eq!(arrival((12, 5), 0, false).as_str(), "12:05 pm"); - assert_eq!(arrival((0, 59), 60, false).as_str(), "1:00 am"); - } - - #[test] - fn heading_up() { - // heading east (a quarter turn): a point 100 m east is straight ahead, one 100 m south is to the right - assert_eq!(project([100, 0], [0, 0], 0x4000, 1), (CAR.0, CAR.1 - 100)); - assert_eq!(project([0, -100], [0, 0], 0x4000, 1), (CAR.0 + 100, CAR.1)); - assert_eq!(project([0, 100], [0, 0], 0, 2), (CAR.0, CAR.1 - 50)); - // far away does not overflow - let far = project([2_000_000_000, -2_000_000_000], [-2_000_000_000, 2_000_000_000], 0x2000, 1); - assert!(far.0 > SIZE); - } - - #[test] - fn clipping() { - assert_eq!(clip((10, 10), (20, 20), 0, 100), Some(((10, 10), (20, 20)))); - assert_eq!(clip((-50, -50), (-10, -10), 0, 100), None); - assert_eq!(clip((-100, 50), (200, 50), 0, 100), Some(((0, 50), (100, 50)))); - } - - fn model() -> Box { - let mut m = Box::new(Model::new()); - let pts: vec::Vec<[i32; 2]> = - (0..60).map(|i| if i < 30 { [0, i * 20] } else { [(i - 29) * 20, 580] }).collect(); - let (msgs, seq) = route(0, 1, &pts); - msgs.iter().for_each(|x| { - m.apply(x); - }); - let st = State { - flags: F_ACTIVE | F_FIX | F_CLOCK24, - maneuver: man::RIGHT, - dist_m: 180, - remaining_10m: 120, - remaining_s: 300, - limit: 50, - x: 0, - y: 400, - progress: 21, - ..State::default() - }; - m.apply(&state(seq, &st)); - m.apply(&crate::proto::enc::msg(b'T', seq.wrapping_add(1), b"Bannerghatta Main Road")); - m - } - - #[test] - fn draws_a_drive() { - let m = model(); - let mut px = vec![0u16; (SIZE * SIZE) as usize]; - let mut fb = Fb::new(&mut px); - draw( - &mut fb, - &m, - &Ctx { live: true, clock: Some((17, 0)), zoom: ZOOM_DEFAULT, pose: None, pending: None }, - &mut Box::new(Fade::new()), - ); - // the route ahead passes above the car, the car is drawn, the turn goes right of the centre - assert_eq!(fb.at(CAR.0, CAR.1 - 50), WHITE.rgb565()); - // the car: lit left face, shaded right face, a black rim above its tip - assert_eq!(fb.at(CAR.0 - 5, CAR.1 + 4), WHITE.rgb565()); - assert_eq!(fb.at(CAR.0 + 5, CAR.1 + 4), SHADE.rgb565()); - assert_eq!(fb.at(CAR.0, CAR.1 - 27), 0); - assert_eq!(fb.at(388, 262), WHITE.rgb565()); // limit badge, above its digits - assert_eq!(fb.at(388, 282 - 28), RED.rgb565()); - // 1.2 km left of a 1.18 km line: nothing done yet, the arc is all track - assert_eq!(done(&m), 0); - assert_eq!(fb.at(C, C + 218), TRACK.rgb565()); - assert!(fb.rects < 20_000, "{}", fb.rects); - // nothing lit outside the circle - for y in 0..SIZE { - for x in 0..SIZE { - if !geom::inside(x, y) { - assert_eq!(fb.at(x, y), 0, "lit at {x},{y}"); - } - } - } - } - - #[test] - fn streets_fade_away_from_the_route() { - let mut m = model(); - // the route runs north at x 0; a street crosses it east-west at y 500, and one runs north far to the east - let lines = vec![(false, vec![[-600, 500], [600, 500]]), (true, vec![[500, 300], [500, 700]])]; - // the model's run used seq 0..=5 - let (msgs, _) = crate::proto::enc::roads(6, 1, [0, 400], &lines); - msgs.iter().for_each(|x| { - m.apply(x); - }); - assert_eq!(m.roads().n_lines, 2); - let mut px = vec![0u16; (SIZE * SIZE) as usize]; - let mut fb = Fb::new(&mut px); - let mut fade = Box::new(Fade::new()); - draw(&mut fb, &m, &Ctx { live: true, clock: None, zoom: ZOOM_DEFAULT, pose: None, pending: None }, &mut fade); - // 100 m ahead of the car at 3 m/px: the cross street, full strength beside the route, gone 200 px away - let y = CAR.1 - 100 / 3; - assert_eq!(fb.at(C + 30, y), ROAD_MINOR.rgb565()); - assert_eq!(fb.at(C - 220, y), 0); - assert!(fb.rects < 30_000, "{}", fb.rects); - } - - #[test] - fn the_car_glides_the_short_way_round() { - let a = Pose { x: 0, y: 0, course: 65000 }; - let b = Pose { x: 100, y: -40, course: 500 }; - let half = a.toward(b, 512); - assert_eq!((half.x, half.y), (50, -20)); - // 65000 -> 500 turns through north (1036 units), not back round the whole compass - assert_eq!(half.course, 65000u16.wrapping_add(518)); - assert_eq!(a.toward(b, 1024), b); - assert_eq!(a.toward(b, 0), a); - assert!(a.moved_px(b, 3) >= 33); - assert_eq!(a.moved_px(a, 3), 0); - } - - #[test] - fn the_glide_follows_the_updates() { - let mut g = Glide::new(); - let p = |x, course| Pose { x, y: 0, course }; - g.target(p(0, 0), 1000); - assert_eq!(g.at(1000), p(0, 0)); // the first one is where it is - g.target(p(20, 1000), 2000); - assert!(g.moving(2400)); - assert_eq!(g.at(2500), p(10, 500)); // half way through the second between updates - assert_eq!(g.at(3000), p(20, 1000)); - assert!(!g.moving(3000)); - // an update arriving mid-glide starts from where the car is drawn, not where it was going - g.target(p(40, 1000), 3000); - g.target(p(60, 1000), 3500); - assert_eq!(g.at(3500).x, 30); - // a reroute far away is not glided across the map - g.target(p(5000, 0), 4000); - assert_eq!(g.at(4000), p(5000, 0)); - } - - #[test] - fn without_a_drive_home_and_work_are_buttons() { - let mut m = Box::new(Model::new()); - m.apply(&state(0, &State { flags: F_CLOCK24, ..State::default() })); - m.apply(&crate::proto::enc::msg(b'P', 1, &[crate::proto::P_HOME, 0])); - assert_eq!(m.places, crate::proto::P_HOME); - let mut px = vec![0u16; (SIZE * SIZE) as usize]; - let mut fb = Fb::new(&mut px); - let ctx = |pending| Ctx { live: true, clock: None, zoom: ZOOM_DEFAULT, pose: None, pending }; - draw(&mut fb, &m, &ctx(None), &mut Box::new(Fade::new())); - let (home, work) = (BUTTONS[0].2 + 4, BUTTONS[1].2 + 4); - assert_eq!(fb.at(C, home), PILL.rgb565()); // Home is set - assert_ne!(fb.at(C, work), PILL.rgb565()); // Work is not: dimmed - drop(fb); - let mut fb = Fb::new(&mut px); - draw(&mut fb, &m, &ctx(Some(crate::proto::P_HOME)), &mut Box::new(Fade::new())); - assert_eq!(fb.at(C, home), WHITE.rgb565()); // tapped: lit while the phone starts it - assert_eq!(button_at(BUTTONS[0].2 + 30), Some(crate::proto::P_HOME)); - assert_eq!(button_at(BUTTONS[1].2 + 30), Some(crate::proto::P_WORK)); - assert_eq!(button_at(60), None); - assert!(L.covers("Home Work Starting…") && S.covers("Couldn't plan that drive Set Home and Work in Vela")); - } - - #[test] - fn the_arc_fills_with_the_drive() { - let mut m = model(); - assert_eq!(m.length_m(), 1180); - m.state.remaining_10m = 59; - assert_eq!(done(&m), 512); - let mut px = vec![0u16; (SIZE * SIZE) as usize]; - let mut fb = Fb::new(&mut px); - progress(&mut fb, 512); - // half full: white left of 6 o'clock, track right of it - assert_eq!(fb.at(C - 40, C + 214), WHITE.rgb565()); - assert_eq!(fb.at(C + 40, C + 214), TRACK.rgb565()); - } - - #[test] - fn every_icon_stays_in_its_box() { - for code in 0..=13 { - let mut px = vec![0u16; (SIZE * SIZE) as usize]; - let mut fb = Fb::new(&mut px); - icon(&mut fb, code, C, C, 32, WHITE); - for y in 0..SIZE { - for x in 0..SIZE { - if fb.at(x, y) != 0 { - assert!((x - C).abs() <= 40 && (y - C).abs() <= 40, "icon {code} at {x},{y}"); - } - } - } - } - } -} diff --git a/apps/vela-nav/store.md b/apps/vela-nav/store.md deleted file mode 100644 index 223f2f3..0000000 --- a/apps/vela-nav/store.md +++ /dev/null @@ -1,22 +0,0 @@ -Shows the drive that **Vela** on your phone is navigating: the next turn big at the bottom with its distance, a -heading-up map of the route over the streets around you, which fade out away from it (turn the crown to zoom), the speed limit, the road and your arrival time -with the distance and time left, and an arc along the edge that fills as the drive goes. The screen stays on while a -route is active. - -Without a drive, the app shows **Home** and **Work** buttons: a tap asks Vela on the phone to start the drive there -from where you are, with your avoid settings and voice. Vela tells the watch only which of the two are set, never -where they are. - -What goes over Bluetooth is the turn, the road name, and the route, the streets around you and your position in -metres from the start of the route: never latitude and longitude, and never the destination's name. The watch's app channel can be read by -any device in Bluetooth range, so a nearby listener could still see the shape of the drive and the road names. - -## Requirements - -- The [patched firmware](/firmware) (`fw-wp2.bin` from 2026-11-13 or later) and the [App Loader](/firmware) - (2026-11-13 or later). -- Vela for Android with the watch link, [APK on GitHub](https://github.com/arunk140/esp32-vela/releases/latest) - ([source](https://github.com/arunk140/esp32-vela)), on the phone that is paired with the watch in Nothing X. In - Vela: Settings > Nav device > CMF watch test, pick the watch, turn on **Show navigation on the watch**. - -Open it from the **Apps** row at the end of the watch's app list before you start driving. diff --git a/apps/vela-nav/store.toml b/apps/vela-nav/store.toml deleted file mode 100644 index 7da7efd..0000000 --- a/apps/vela-nav/store.toml +++ /dev/null @@ -1,6 +0,0 @@ -# The app's listing in the FMC store (README.md, "store.toml"). The page's body is store.md. -name = "Vela Nav" -summary = "Turn-by-turn directions from the Vela maps app on your phone: next turn, route map, arrival time" -version = "1.1.0" -author = "arunk140" -screenshots = ["shots/driving.png", "shots/turn.png", "shots/map.png", "shots/home.png"] diff --git a/apps/vibration-lab/Cargo.toml b/apps/vibration-lab/Cargo.toml deleted file mode 100644 index 1cf02ff..0000000 --- a/apps/vibration-lab/Cargo.toml +++ /dev/null @@ -1,12 +0,0 @@ -[package] -name = "vibration-lab" -edition.workspace = true -license.workspace = true -version.workspace = true - -[dependencies] -cmf-wp2-app.workspace = true - -[[bin]] -name = "vibration-lab" -bench = false diff --git a/apps/vibration-lab/icon.svg b/apps/vibration-lab/icon.svg deleted file mode 100644 index 8179614..0000000 --- a/apps/vibration-lab/icon.svg +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/apps/vibration-lab/src/lab.rs b/apps/vibration-lab/src/lab.rs deleted file mode 100644 index 1cc5461..0000000 --- a/apps/vibration-lab/src/lab.rs +++ /dev/null @@ -1,187 +0,0 @@ -pub const FREQUENCIES: [u16; 8] = [31, 62, 125, 250, 500, 1000, 4000, 16000]; -pub const STOCK_FREQUENCY: u16 = 31; -const GAP_MS: u16 = 80; -const CONTINUOUS_MS: u16 = 1000; - -#[derive(Clone, Copy, PartialEq, Debug)] -pub enum Pattern { - Continuous, - Tick, - DoubleTick, -} - -#[derive(Clone, Copy, PartialEq, Debug)] -pub enum Field { - Strength, - Frequency, - Pattern, - Pulse, -} - -#[derive(Clone, Copy, PartialEq, Debug)] -pub struct Step { - pub duty_permille: u16, - pub freq_hz: u16, - pub ms: u16, -} - -#[derive(Clone, Copy, PartialEq, Debug)] -pub struct Settings { - pub duty_permille: u16, - pub freq_hz: u16, - pub pattern: Pattern, - pub pulse_ms: u16, -} - -impl Default for Settings { - fn default() -> Self { - Settings { duty_permille: 200, freq_hz: STOCK_FREQUENCY, pattern: Pattern::Tick, pulse_ms: 20 } - } -} - -fn stepped(value: u16, clicks: i16, step: i32, min: i32, max: i32) -> u16 { - (value as i32 + clicks as i32 * step).clamp(min, max) as u16 -} - -impl Settings { - pub fn adjust(&mut self, field: Field, clicks: i16) { - match field { - Field::Strength => self.duty_permille = stepped(self.duty_permille, clicks, 50, 50, 1000), - Field::Pulse => self.pulse_ms = stepped(self.pulse_ms, clicks, 5, 5, 100), - Field::Frequency => { - let at = FREQUENCIES.iter().position(|&f| f >= self.freq_hz).unwrap_or(0); - let to = (at as i32 + clicks as i32).clamp(0, FREQUENCIES.len() as i32 - 1); - self.freq_hz = FREQUENCIES[to as usize]; - } - Field::Pattern => { - const ALL: [Pattern; 3] = [Pattern::Continuous, Pattern::Tick, Pattern::DoubleTick]; - let at = ALL.iter().position(|&p| p == self.pattern).unwrap_or(0) as i32; - self.pattern = ALL[(at + clicks as i32).rem_euclid(3) as usize]; - } - } - } - - pub fn steps(&self) -> ([Step; 3], usize) { - let on = |ms| Step { duty_permille: self.duty_permille, freq_hz: self.freq_hz, ms }; - let off = Step { duty_permille: 0, freq_hz: self.freq_hz, ms: GAP_MS }; - match self.pattern { - Pattern::Continuous => ([on(CONTINUOUS_MS), off, off], 1), - Pattern::Tick => ([on(self.pulse_ms), off, off], 1), - Pattern::DoubleTick => ([on(self.pulse_ms), off, on(self.pulse_ms)], 3), - } - } -} - -pub struct Player { - steps: [Step; 3], - len: usize, - at: usize, - freq_hz: u16, - active: bool, -} - -impl Player { - pub fn start(settings: &Settings) -> Self { - let (steps, len) = settings.steps(); - Player { steps, len, at: 0, freq_hz: settings.freq_hz, active: true } - } - - pub fn next(&mut self) -> Option { - if !self.active { - return None; - } - if self.at < self.len { - self.at += 1; - return Some(self.steps[self.at - 1]); - } - self.pause(); - Some(Step { duty_permille: 0, freq_hz: self.freq_hz, ms: 0 }) - } - - pub fn pause(&mut self) -> Step { - self.active = false; - Step { duty_permille: 0, freq_hz: self.freq_hz, ms: 0 } - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn strength_clamps() { - let mut s = Settings::default(); - s.adjust(Field::Strength, 1000); - assert_eq!(s.duty_permille, 1000); - s.adjust(Field::Strength, -1000); - assert_eq!(s.duty_permille, 50); - } - - #[test] - fn pulse_clamps() { - let mut s = Settings::default(); - s.adjust(Field::Pulse, -100); - assert_eq!(s.pulse_ms, 5); - s.adjust(Field::Pulse, 100); - assert_eq!(s.pulse_ms, 100); - } - - #[test] - fn frequency_steps_through_list() { - let mut s = Settings::default(); - assert_eq!(s.freq_hz, 31); - s.adjust(Field::Frequency, 1); - assert_eq!(s.freq_hz, 62); - s.adjust(Field::Frequency, 100); - assert_eq!(s.freq_hz, 16000); - s.adjust(Field::Frequency, -100); - assert_eq!(s.freq_hz, 31); - } - - #[test] - fn double_tick_steps() { - let s = Settings { duty_permille: 300, freq_hz: 200, pattern: Pattern::DoubleTick, pulse_ms: 15 }; - let (steps, n) = s.steps(); - assert_eq!(&steps[..n], &[Step { duty_permille: 300, freq_hz: 200, ms: 15 }, - Step { duty_permille: 0, freq_hz: 200, ms: 80 }, - Step { duty_permille: 300, freq_hz: 200, ms: 15 }]); - } - - #[test] - fn no_step_exceeds_limits() { - for pattern in [Pattern::Continuous, Pattern::Tick, Pattern::DoubleTick] { - let mut s = Settings { pattern, ..Settings::default() }; - s.adjust(Field::Strength, i16::MAX); - s.adjust(Field::Pulse, i16::MAX); - let (steps, n) = s.steps(); - assert!(steps[..n].iter().all(|st| st.duty_permille <= 1000 && st.ms <= 2000)); - } - } - - #[test] - fn pattern_cycles() { - let mut s = Settings { pattern: Pattern::DoubleTick, ..Settings::default() }; - s.adjust(Field::Pattern, 1); - assert_eq!(s.pattern, Pattern::Continuous); - s.adjust(Field::Pattern, -1); - assert_eq!(s.pattern, Pattern::DoubleTick); - } - - #[test] - fn pause_stops_playback() { - let s = Settings { duty_permille: 300, freq_hz: 200, pattern: Pattern::DoubleTick, pulse_ms: 15 }; - let mut p = Player::start(&s); - assert!(p.next().is_some()); - assert_eq!(p.pause().duty_permille, 0); - assert_eq!(p.next(), None); - } - - #[test] - fn player_ends_with_motor_off() { - let s = Settings { pattern: Pattern::Tick, ..Settings::default() }; - let mut p = Player::start(&s); - assert_eq!(p.next().unwrap().duty_permille, 200); - assert_eq!(p.next(), Some(Step { duty_permille: 0, freq_hz: 31, ms: 0 })); - assert_eq!(p.next(), None); - } -} diff --git a/apps/vibration-lab/src/main.rs b/apps/vibration-lab/src/main.rs deleted file mode 100644 index c622297..0000000 --- a/apps/vibration-lab/src/main.rs +++ /dev/null @@ -1,134 +0,0 @@ -#![cfg_attr(any(target_os = "none", wp2_sim), no_main, cfg_attr(target_os = "none", no_std))] - -mod lab; - -#[cfg(not(any(target_os = "none", wp2_sim)))] -fn main() {} - -#[cfg(any(target_os = "none", wp2_sim))] -mod device { - use crate::lab::{Field, Pattern, Player, Settings}; - use cmf_wp2_app::{Api, BUTTON, CROWN, PAUSE, RESUME, TOUCH_DOWN}; - use core::fmt::Write; - - cmf_wp2_app::entry!(main); - cmf_wp2_app::app_icon!(); - - const FIELDS: [Field; 4] = [Field::Strength, Field::Frequency, Field::Pattern, Field::Pulse]; - const ROW_TOP: i16 = 110; - const ROW_HEIGHT: i16 = 50; - const PLAY_TOP: i16 = 330; - const PLAY_HEIGHT: i16 = 60; - const BLACK: u16 = 0x0000; - const WHITE: u16 = 0xFFFF; - const GREY: u16 = 0x39E7; - const ACCENT: u16 = 0xFD20; - - struct Line { - buf: [u8; 32], - len: usize, - } - - impl Line { - fn new() -> Self { - Line { buf: [0; 32], len: 0 } - } - - fn as_str(&self) -> &str { - core::str::from_utf8(&self.buf[..self.len]).unwrap_or("") - } - } - - impl Write for Line { - fn write_str(&mut self, s: &str) -> core::fmt::Result { - let n = s.len().min(self.buf.len() - self.len); - self.buf[self.len..self.len + n].copy_from_slice(&s.as_bytes()[..n]); - self.len += n; - Ok(()) - } - } - - fn label(settings: &Settings, field: Field) -> Line { - let mut line = Line::new(); - let _ = match field { - Field::Strength => write!(line, "Strength {}%", settings.duty_permille / 10), - Field::Frequency => write!(line, "Freq {}Hz", settings.freq_hz), - Field::Pattern => write!(line, "Pattern {}", match settings.pattern { - Pattern::Continuous => "Long", - Pattern::Tick => "Tick", - Pattern::DoubleTick => "Double", - }), - Field::Pulse => write!(line, "Pulse {}ms", settings.pulse_ms), - }; - line - } - - fn draw(api: &Api, settings: &Settings, selected: usize) { - let x = api.width as i16 / 2 - 100; - api.rect(0, 0, api.width, api.height, BLACK); - for (row, &field) in FIELDS.iter().enumerate() { - let y = ROW_TOP + row as i16 * ROW_HEIGHT; - if row == selected { - api.rect(x - 16, y - 8, 232, (ROW_HEIGHT - 8) as u16, GREY); - } - api.text(x, y, label(settings, field).as_str(), if row == selected { ACCENT } else { WHITE }); - } - api.rect(x, PLAY_TOP, 200, PLAY_HEIGHT as u16, ACCENT); - api.text(x + 76, PLAY_TOP + 20, "PLAY", BLACK); - api.show(); - } - - fn play(api: &Api, settings: &Settings) -> Option { - let mut player = Player::start(settings); - while let Some(step) = player.next() { - api.vibrate(step.duty_permille, step.freq_hz); - let deadline = api.now().wrapping_add(step.ms as u32); - loop { - let left = deadline.wrapping_sub(api.now()) as i32; - if left <= 0 { - break; - } - match api.event(left as u32).map(|e| e.kind) { - Some(PAUSE) => { - let off = player.pause(); - api.vibrate(off.duty_permille, off.freq_hz); - return None; - } - Some(BUTTON) => { - api.vibrate(0, 0); - return Some(0); - } - _ => {} - } - } - } - None - } - - fn main(api: &'static Api) -> i32 { - let mut settings = Settings::default(); - let mut selected = 0; - draw(api, &settings, selected); - loop { - let Some(event) = api.event(u32::MAX) else { continue }; - match event.kind { - BUTTON => { - api.vibrate(0, 0); - return 0; - } - CROWN if event.delta != 0 => settings.adjust(FIELDS[selected], event.delta.signum()), - TOUCH_DOWN if event.y >= PLAY_TOP && event.y < PLAY_TOP + PLAY_HEIGHT => { - if let Some(code) = play(api, &settings) { - return code; - } - } - TOUCH_DOWN if event.y >= ROW_TOP - 8 && event.y < ROW_TOP - 8 + ROW_HEIGHT * FIELDS.len() as i16 => { - selected = ((event.y - (ROW_TOP - 8)) / ROW_HEIGHT) as usize; - } - RESUME => {} - _ => continue, - } - draw(api, &settings, selected); - } - } -} diff --git a/apps/vibration-lab/store.md b/apps/vibration-lab/store.md deleted file mode 100644 index 7097582..0000000 --- a/apps/vibration-lab/store.md +++ /dev/null @@ -1,5 +0,0 @@ -A test bench for the vibration motor. Set the strength and frequency, pick a pattern — long, tick, double or a pulse of your own length — and press **PLAY** to feel it. - -## Requirements - -The [patched firmware](/firmware) and the [App Loader](/firmware). Open it from the **Apps** row at the end of the watch's app list (list style, not the waterfall). diff --git a/apps/vibration-lab/store.toml b/apps/vibration-lab/store.toml deleted file mode 100644 index 70bb1ae..0000000 --- a/apps/vibration-lab/store.toml +++ /dev/null @@ -1,5 +0,0 @@ -# The app's listing in the FMC store (README.md, "store.toml"). The page's body is store.md. -name = "Vibration Lab" -summary = "Tune the motor: strength, frequency, patterns" -version = "0.1.1" -author = "CMF Tech Community" diff --git a/apps/watch-remote/Cargo.toml b/apps/watch-remote/Cargo.toml deleted file mode 100644 index 341f1f8..0000000 --- a/apps/watch-remote/Cargo.toml +++ /dev/null @@ -1,13 +0,0 @@ -[package] -name = "watch-remote" -edition.workspace = true -license.workspace = true -version.workspace = true - -[dependencies] -cmf-wp2-app.workspace = true -cmf-wp2-ui.workspace = true - -[[bin]] -name = "watch-remote" -bench = false diff --git a/apps/watch-remote/icon.svg b/apps/watch-remote/icon.svg deleted file mode 100644 index 8fc9f0d..0000000 --- a/apps/watch-remote/icon.svg +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/apps/watch-remote/shots/page1.png b/apps/watch-remote/shots/page1.png deleted file mode 100644 index 2579433..0000000 Binary files a/apps/watch-remote/shots/page1.png and /dev/null differ diff --git a/apps/watch-remote/shots/page2.png b/apps/watch-remote/shots/page2.png deleted file mode 100644 index fdd563f..0000000 Binary files a/apps/watch-remote/shots/page2.png and /dev/null differ diff --git a/apps/watch-remote/src/main.rs b/apps/watch-remote/src/main.rs deleted file mode 100644 index d5fd889..0000000 --- a/apps/watch-remote/src/main.rs +++ /dev/null @@ -1,649 +0,0 @@ -#![cfg_attr(any(target_os = "none", wp2_sim), no_main, cfg_attr(target_os = "none", no_std))] - -//! Watch Remote: a remote for a PC or a Google TV, paired to your phone (the Watch Menu app), which acts as a -//! Bluetooth keyboard + media remote. Two pages, flipped by turning the crown (the SDK gives apps no swipe): -//! page 1: four arrow wedges and a centre ring (OK) -//! page 2: Back, Home, Prev, Play/Pause, Next, Mute and a Volume icon (tap it, then the crown changes the volume; -//! it switches itself off after a moment without input) -//! Crown press / right swipe leaves the app. Every button just sends its id to the phone, which decides what it -//! does (so every button can be re-programmed on the phone). -//! -//! Watch -> phone messages (all start with `c1`): -//! `c1h` ver hello: the app is open -//! `c1f` heartbeat while open (the phone treats 9 s of silence as closed) -//! `c1z` the app is closing -//! `c1p` button page-1 key down / still held (repeated every 250 ms while the finger stays down) -//! `c1r` button page-1 key released (the phone also lets go by itself after ~1 s of silence) -//! ids: 1 up 2 down 3 left 4 right 5 centre -//! `c1k` button 0 a page-2 tap: 10 back 11 home 12 play/pause 13 prev 14 next 15 mute -//! `c1v` n n crown volume steps (signed byte, + = up), batched per 60 ms - -/// Screen geometry and hit testing, pure integer maths (host-tested). -pub mod logic { - pub const SIZE: i32 = 466; - pub const C: i32 = SIZE / 2; - /// Radius of the grey disc on page 1. - pub const R: i32 = 228; - /// Radius of the centre ring. - pub const RC: i32 = 78; - /// Page dots at the bottom: centre y and spacing. - pub const DOT_Y: i32 = SIZE - 28; - pub const DOT_GAP: i32 = 28; - - pub const UP: u8 = 1; - pub const DOWN: u8 = 2; - pub const LEFT: u8 = 3; - pub const RIGHT: u8 = 4; - pub const CENTRE: u8 = 5; - pub const BACK: u8 = 10; - pub const HOME: u8 = 11; - pub const PLAY: u8 = 12; - pub const PREV: u8 = 13; - pub const NEXT: u8 = 14; - pub const MUTE: u8 = 15; - /// The volume icon: not sent to the phone, it starts the crown volume mode. - pub const VOLUME: u8 = 16; - pub const VOL_UP: u8 = 20; - pub const VOL_DOWN: u8 = 21; - /// A tap on the page dots flips the page. - pub const DOTS: u8 = 99; - - /// Page 2 buttons: (id, centre x, centre y, radius). - pub const BUTTONS: [(u8, i32, i32, i32); 7] = [ - (BACK, C - 90, C - 125, 52), - (HOME, C + 90, C - 125, 52), - (PREV, C - 135, C, 52), - (PLAY, C, C, 62), - (NEXT, C + 135, C, 52), - (MUTE, C - 90, C + 125, 52), - (VOLUME, C + 90, C + 125, 52), - ]; - - pub fn isqrt(v: i32) -> i32 { - if v <= 0 { - return 0; - } - let mut r = 0; - while (r + 1) * (r + 1) <= v { - r += 1; - } - r - } - - fn on_dots(x: i32, y: i32) -> bool { - y >= DOT_Y - 18 && y <= DOT_Y + 18 && (x - C).abs() <= DOT_GAP + 14 - } - - /// Page 1: which control a touch at (x, y) hits. Wedges are found by angle: the diagonals split the disc. - pub fn hit_page1(x: i32, y: i32) -> Option { - if on_dots(x, y) { - return Some(DOTS); - } - let (dx, dy) = (x - C, y - C); - let d2 = dx * dx + dy * dy; - if d2 <= RC * RC { - return Some(CENTRE); - } - if d2 > R * R { - return None; - } - Some(if dx.abs() > dy.abs() { - if dx > 0 { RIGHT } else { LEFT } - } else if dy > 0 { - DOWN - } else { - UP - }) - } - - /// Page 2: which round button a touch hits. - pub fn hit_page2(x: i32, y: i32) -> Option { - if on_dots(x, y) { - return Some(DOTS); - } - BUTTONS.iter().find(|&&(_, cx, cy, r)| (x - cx) * (x - cx) + (y - cy) * (y - cy) <= r * r).map(|b| b.0) - } - - /// Row span of a wedge at `dy` rows from the centre, `gap` px kept free for the black separators. - /// Returns (from, to) x offsets from the centre, inclusive. `dir`: 0 up, 1 down, 2 left, 3 right. - pub fn wedge_span(dir: u8, dy: i32, gap: i32) -> Option<(i32, i32)> { - let hw = isqrt(R * R - dy * dy); - if hw <= 0 { - return None; - } - let a = dy.abs(); - match dir { - 0 | 1 => { - if (dir == 0) != (dy < 0) { - return None; - } - let w = (a - gap).min(hw); - if w <= 0 { None } else { Some((-w, w)) } - } - _ => { - let from = a + gap; - if from >= hw { - return None; - } - if dir == 3 { Some((from, hw)) } else { Some((-hw, -from)) } - } - } - } - - /// Page-2 icons as vector shapes, drawn with 4x4 supersampling so the edges are smooth. - /// Coordinates are in quarter pixels relative to the button centre; every icon is designed in a 48 px box - /// and offset so its *visual* centre sits on the button centre (no stretching, no off-centre glyphs). - pub mod icons { - use super::*; - const Q: i32 = 4; - - fn tri(x: i32, y: i32, p: [(i32, i32); 3]) -> bool { - let e = |a: (i32, i32), b: (i32, i32)| (b.0 - a.0) * (y - a.1 * Q) - (b.1 - a.1) * (x - a.0 * Q); - let (d0, d1, d2) = (e(p[0], p[1]), e(p[1], p[2]), e(p[2], p[0])); - (d0 >= 0 && d1 >= 0 && d2 >= 0) || (d0 <= 0 && d1 <= 0 && d2 <= 0) - } - fn rect(x: i32, y: i32, x0: i32, y0: i32, x1: i32, y1: i32) -> bool { - x >= x0 * Q && x < x1 * Q && y >= y0 * Q && y < y1 * Q - } - /// A thick line with round caps: distance from (x, y) to segment a-b at most r. - fn cap(x: i32, y: i32, a: (i32, i32), b: (i32, i32), r: i32) -> bool { - let (ax, ay, bx, by) = (a.0 * Q, a.1 * Q, b.0 * Q, b.1 * Q); - let (vx, vy, wx, wy) = (bx - ax, by - ay, x - ax, y - ay); - let l2 = vx * vx + vy * vy; - let t = if l2 == 0 { 0 } else { ((wx * vx + wy * vy) * 1024 / l2).clamp(0, 1024) }; - let (px, py) = (ax + vx * t / 1024, ay + vy * t / 1024); - let (dx, dy) = (x - px, y - py); - dx * dx + dy * dy <= r * r * Q * Q - } - /// A sound-wave arc: ring around (cx, 0), radii r0..r1, opening to the right within about +-50 degrees. - fn wave(x: i32, y: i32, cx: i32, r0: i32, r1: i32) -> bool { - let dx = x - cx * Q; - let d2 = dx * dx + y * y; - dx > 0 && y.abs() * 5 <= dx * 6 && d2 >= r0 * r0 * Q * Q && d2 <= r1 * r1 * Q * Q - } - fn speaker(x: i32, y: i32, ox: i32) -> bool { - rect(x, y, ox - 20, -7, ox - 9, 8) || tri(x, y, [(ox - 10, -7), (ox + 2, -18), (ox + 2, 18)]) - || tri(x, y, [(ox - 10, -7), (ox + 2, 18), (ox - 10, 8)]) - } - - /// Is the point (x, y), in quarter pixels from the button centre, inside icon `id`? - pub fn inside(id: u8, x: i32, y: i32) -> bool { - match id { - BACK => { - // arrow pointing left: shaft and two head strokes - let x = x + 2 * Q; - cap(x, y, (-16, 0), (20, 0), 4) || cap(x, y, (-16, 0), (-2, -14), 4) || cap(x, y, (-16, 0), (-2, 14), 4) - } - HOME => { - // roof + walls with a door, bottom-heavy box centred vertically (-20..20) - let y = y - 2 * Q; - let roof = tri(x, y, [(0, -22), (23, -1), (-23, -1)]); - let walls = rect(x, y, -15, -2, 15, 18) && !rect(x, y, -5, 6, 5, 18); - roof || walls - } - PLAY => { - // play triangle + pause bars; whole group is 44 px wide, centred - tri(x, y, [(-22, -15), (-22, 15), (2, 0)]) || rect(x, y, 8, -15, 14, 15) || rect(x, y, 17, -15, 23, 15) - } - PREV => rect(x, y, -16, -14, -10, 14) || tri(x, y, [(16, -14), (16, 14), (-9, 0)]), - NEXT => rect(x, y, 10, -14, 16, 14) || tri(x, y, [(-16, -14), (-16, 14), (9, 0)]), - MUTE => speaker(x, y, -3) || cap(x, y, (8, -8), (21, 8), 3) || cap(x, y, (8, 8), (21, -8), 3), - VOLUME => { - let x = x - 2 * Q; - speaker(x, y, -3) || wave(x, y, -1, 8, 12) || wave(x, y, -1, 16, 20) - } - _ => false, - } - } - - /// Coverage 0..=16 of the pixel whose top-left is (px, py) (whole pixels from the centre). - pub fn coverage(id: u8, px: i32, py: i32) -> i32 { - let (x0, y0) = (px * Q, py * Q); - let corners = [(0, 0), (Q - 1, 0), (0, Q - 1), (Q - 1, Q - 1)]; - let n = corners.iter().filter(|&&(a, b)| inside(id, x0 + a, y0 + b)).count(); - if n == 0 && !inside(id, x0 + 2, y0 + 2) { - return 0; - } - if n == 4 && inside(id, x0 + 2, y0 + 2) { - return 16; - } - let mut c = 0; - for j in 0..Q { - for i in 0..Q { - if inside(id, x0 + i, y0 + j) { - c += 1; - } - } - } - c - } - - /// Half the side of the square every icon fits in. - pub const HALF: i32 = 28; - } - - /// Row spans of a triangle pointing `dir` (0 up, 1 down, 2 left, 3 right), centre (cx, cy), half-size s: - /// calls `f(y, x0, x1)` per row (x1 exclusive). - pub fn triangle(dir: u8, cx: i32, cy: i32, s: i32, mut f: impl FnMut(i32, i32, i32)) { - match dir { - 0 | 1 => { - for i in 0..=s * 2 { - let w = i / 2; // i = 0 is the tip - let y = if dir == 0 { cy - s + i } else { cy + s - i }; - f(y, cx - w, cx + w + 1); - } - } - _ => { - for r in -s..=s { - let w = s * 2 - r.abs() * 2; - let (x0, x1) = if dir == 3 { (cx - s, cx - s + w + 1) } else { (cx + s - w, cx + s + 1) }; - f(cy + r, x0, x1); - } - } - } - } -} - -#[cfg(not(any(target_os = "none", wp2_sim)))] -fn main() {} - -#[cfg(any(target_os = "none", wp2_sim))] -mod device { - use super::logic::*; - use cmf_wp2_app::{Api, BUTTON, CROWN, PAUSE, RESUME, TOUCH_DOWN, TOUCH_UP}; - use cmf_wp2_ui::color::BLACK; - use cmf_wp2_ui::draw::{disc, ring}; - use cmf_wp2_ui::{Rgb, Surface}; - - cmf_wp2_app::entry!(main); - cmf_wp2_app::app_icon!(); - - const HEARTBEAT_MS: u32 = 2500; - /// While a page-1 key is held the watch repeats `c1p` this often; the phone lets go if it hears nothing for ~1 s. - const HOLD_PING_MS: u32 = 250; - /// Crown volume steps within this window go out as one message. - const VOL_BATCH_MS: u32 = 60; - /// Sent in hello: 5 = hold (`c1p`/`c1r`) and batched volume (`c1v`). - const PROTOCOL: u8 = 5; - /// Volume mode ends after this long without a crown step. - const VOL_MS: u32 = 1200; - - const FACE: Rgb = Rgb(58, 58, 60); - const FACE_DOWN: Rgb = Rgb(96, 96, 100); - const ARROW: Rgb = Rgb(200, 200, 204); - const ACCENT: Rgb = Rgb(138, 180, 248); - - fn span(s: &mut &Api, y: i32, x0: i32, x1: i32, c: Rgb) { - if x1 > x0 { - Surface::rect(s, x0, y, x1 - x0, 1, c.rgb565()); - } - } - - fn tri(s: &mut &Api, dir: u8, cx: i32, cy: i32, size: i32, c: Rgb) { - triangle(dir, cx, cy, size, |y, x0, x1| span(s, y, x0, x1, c)); - } - - fn dots(s: &mut &Api, page: u8) { - for i in 0..2i32 { - let x = C + (i * 2 - 1) * (DOT_GAP / 2); - disc(s, x, DOT_Y, if i == page as i32 { 6 } else { 4 }, if i == page as i32 { ARROW } else { FACE_DOWN }, BLACK); - } - } - - fn wedge(s: &mut &Api, dir: u8, on: bool) { - let c = if on { FACE_DOWN } else { FACE }; - for y in (C - R)..=(C + R) { - if let Some((a, b)) = wedge_span(dir, y - C, 5) { - span(s, y, C + a, C + b + 1, c); - } - } - } - - fn draw_page1(api: &Api, pressed: Option) { - let mut s = api; - Surface::rect(&mut s, 0, 0, SIZE, SIZE, BLACK.rgb565()); - for (dir, id) in [(0u8, UP), (1, DOWN), (2, LEFT), (3, RIGHT)] { - wedge(&mut s, dir, pressed == Some(id)); - } - disc(&mut s, C, C, RC + 12, BLACK, FACE); - let cc = if pressed == Some(CENTRE) { FACE_DOWN } else { FACE }; - disc(&mut s, C, C, RC + 2, cc, BLACK); - ring(&mut s, C, C, RC - 6, RC + 2, ARROW, cc); - for (dir, x, y) in [(0u8, C, C - 125), (1, C, C + 125), (2, C - 125, C), (3, C + 125, C)] { - tri(&mut s, dir, x, y, 20, ARROW); - } - dots(&mut s, 0); - api.show(); - } - - /// Draws icon `id` centred on (cx, cy) over `bg`, antialiased, merging same-colour pixels into runs. - fn icon(s: &mut &Api, id: u8, cx: i32, cy: i32, c: Rgb, bg: Rgb) { - use cmf_wp2_ui::draw::Run; - let h = icons::HALF; - for py in -h..h { - let mut run = Run::new(s, cy + py, false); - for px in -h..h { - let k = icons::coverage(id, px, py); - let col = if k == 0 { bg } else if k >= 16 { c } else { bg.mix(c, k * 64) }; - run.put(cx + px, 1, col.rgb565()); - } - } - } - - fn draw_page2(api: &Api, pressed: Option, vol_on: bool) { - let mut s = api; - Surface::rect(&mut s, 0, 0, SIZE, SIZE, BLACK.rgb565()); - for &(id, cx, cy, r) in BUTTONS.iter() { - let active = id == VOLUME && vol_on; - let fill = if pressed == Some(id) { FACE_DOWN } else { FACE }; - disc(&mut s, cx, cy, r, fill, BLACK); - if active { - ring(&mut s, cx, cy, r - 5, r, ACCENT, fill); - } - icon(&mut s, id, cx, cy, if active { ACCENT } else { ARROW }, fill); - } - dots(&mut s, 1); - api.show(); - } - - fn redraw(api: &Api, page: u8, pressed: Option, vol_on: bool) { - if page == 0 { draw_page1(api, pressed) } else { draw_page2(api, pressed, vol_on) } - } - - fn msg(api: &Api, d: &[u8]) { - let _ = api.send(d); - } - fn key(api: &Api, button: u8, gesture: u8) { - msg(api, &[b'c', b'1', b'k', button, gesture]); - } - /// Hold protocol: `c1p id` = pressed / still held (repeated every HOLD_PING_MS), `c1r id` = released. - fn hold(api: &Api, button: u8, down: bool) { - msg(api, &[b'c', b'1', if down { b'p' } else { b'r' }, button]); - } - /// `c1v n`: n volume steps in one message (signed, + = up), so a fast crown spin is one message, not ten. - fn volume(api: &Api, steps: i32) { - msg(api, &[b'c', b'1', b'v', steps.clamp(-100, 100) as i8 as u8]); - } - - fn holdable(id: u8) -> bool { - matches!(id, UP | DOWN | LEFT | RIGHT | CENTRE) - } - - fn main(api: &'static Api) -> i32 { - api.own_back(true); - api.keep_screen_on(true); - msg(api, &[b'c', b'1', b'h', PROTOCOL]); - let mut beat = api.now(); - let mut pressed: Option = None; - let mut page = 0u8; - let mut vol_until: Option = None; // crown volume mode, until this time - let mut hold_next: Option = None; // next "still held" ping while a page-1 key is down - let mut vol_pending = 0i32; // crown steps not sent yet - let mut vol_flush: Option = None; // when the next batched volume message may go - draw_page1(api, None); - loop { - let now = api.now(); - if now.wrapping_sub(beat) >= HEARTBEAT_MS { - msg(api, &[b'c', b'1', b'f']); - beat = now; - } - if let (Some(t), Some(id)) = (hold_next, pressed) { - if now.wrapping_sub(t) as i32 >= 0 { - hold(api, id, true); - hold_next = Some(now.wrapping_add(HOLD_PING_MS)); - } - } - if let Some(t) = vol_flush { - if now.wrapping_sub(t) as i32 >= 0 { - if vol_pending != 0 { - volume(api, vol_pending); - vol_pending = 0; - vol_flush = Some(now.wrapping_add(VOL_BATCH_MS)); - } else { - vol_flush = None; - } - } - } - if let Some(t) = vol_until { - if now.wrapping_sub(t) as i32 >= 0 { - vol_until = None; - if page == 1 { - draw_page2(api, None, false); - } - } - } - let mut wait = HEARTBEAT_MS.saturating_sub(now.wrapping_sub(beat)).max(1); - for t in [vol_until, hold_next, vol_flush].into_iter().flatten() { - wait = wait.min((t.wrapping_sub(now) as i32).max(1) as u32); - } - let Some(e) = api.event(wait) else { continue }; - match e.kind { - k if k == BUTTON => { - if let Some(id) = pressed.filter(|&id| holdable(id)) { - hold(api, id, false); - } - msg(api, &[b'c', b'1', b'z']); - return 0; - } - k if k == RESUME => redraw(api, page, None, vol_until.is_some()), - k if k == PAUSE => { - if let Some(id) = pressed.take().filter(|&id| holdable(id)) { - hold(api, id, false); - } - hold_next = None; - vol_until = None; - } - k if k == CROWN => { - if vol_until.is_some() { - let step = if e.delta > 0 { 1 } else { -1 }; - if vol_flush.is_none() { - // first step goes out at once; the rest of a fast spin is batched - volume(api, step); - vol_flush = Some(api.now().wrapping_add(VOL_BATCH_MS)); - } else { - vol_pending += step; - } - vol_until = Some(api.now().wrapping_add(VOL_MS)); - } else { - let new = if e.delta > 0 { 1 } else { 0 }; - if new != page && pressed.is_none() { - page = new; - redraw(api, page, None, false); - } - } - } - k if k == TOUCH_DOWN => { - let (x, y) = (e.x as i32, e.y as i32); - pressed = if page == 0 { hit_page1(x, y) } else { hit_page2(x, y) }; - // send first, draw after: the press reaches the phone before the screen work starts - if let Some(id) = pressed { - if page == 0 && holdable(id) { - hold(api, id, true); - hold_next = Some(api.now().wrapping_add(HOLD_PING_MS)); - } else if page == 1 && id != DOTS && id != VOLUME { - key(api, id, 0); - } - redraw(api, page, pressed, vol_until.is_some()); - } - } - k if k == TOUCH_UP => { - if let Some(id) = pressed.take() { - hold_next = None; - match id { - DOTS => { - page = 1 - page; - vol_until = None; - } - VOLUME => { - vol_until = if vol_until.is_some() { None } else { Some(api.now().wrapping_add(VOL_MS)) }; - } - _ if holdable(id) => hold(api, id, false), - _ => {} // page-2 keys were already sent on touch-down - } - redraw(api, page, None, vol_until.is_some()); - } - } - _ => {} - } - } - } -} - -#[cfg(test)] -mod tests { - use super::logic::*; - - #[test] - fn page1_wedges_by_angle() { - assert_eq!(hit_page1(C, C - 150), Some(UP)); - assert_eq!(hit_page1(C, C + 120), Some(DOWN)); - assert_eq!(hit_page1(C - 150, C), Some(LEFT)); - assert_eq!(hit_page1(C + 150, C), Some(RIGHT)); - assert_eq!(hit_page1(C + 120, C - 100), Some(RIGHT)); - assert_eq!(hit_page1(C + 100, C - 120), Some(UP)); - assert_eq!(hit_page1(C + 5, C + 5), Some(CENTRE)); - assert_eq!(hit_page1(2, 2), None); - assert_eq!(hit_page1(C, DOT_Y), Some(DOTS)); - } - - #[test] - fn page2_buttons_hit_and_do_not_overlap() { - for &(id, cx, cy, _) in BUTTONS.iter() { - assert_eq!(hit_page2(cx, cy), Some(id)); - } - assert_eq!(hit_page2(C, DOT_Y), Some(DOTS)); - assert_eq!(hit_page2(2, 2), None); - for (i, a) in BUTTONS.iter().enumerate() { - for b in BUTTONS.iter().skip(i + 1) { - let d2 = (a.1 - b.1) * (a.1 - b.1) + (a.2 - b.2) * (a.2 - b.2); - assert!(d2 > (a.3 + b.3) * (a.3 + b.3), "buttons {} and {} overlap", a.0, b.0); - } - } - } - - #[test] - fn page2_buttons_are_inside_the_round_screen_and_above_the_dots() { - for &(id, cx, cy, r) in BUTTONS.iter() { - let far = isqrt((cx - C) * (cx - C) + (cy - C) * (cy - C)) + r; - assert!(far <= R - 6, "button {id} too close to the rim"); - assert!(cy + r < DOT_Y - 18, "button {id} touches the page dots"); - } - } - - #[test] - fn wedges_do_not_overlap_and_stay_in_disc() { - for dy in -R..=R { - let mut taken = vec![false; (2 * R + 2) as usize]; - for dir in 0..4u8 { - if let Some((a, b)) = wedge_span(dir, dy, 5) { - assert!(b * b + dy * dy <= R * R + 2 * R && a * a + dy * dy <= R * R + 2 * R); - for x in a..=b { - let i = (x + R) as usize; - assert!(!taken[i], "overlap at dy {dy} x {x}"); - taken[i] = true; - } - } - } - } - } - - #[test] - fn triangles_stay_inside_their_box() { - for dir in 0..4u8 { - let mut n = 0; - triangle(dir, 100, 100, 20, |y, x0, x1| { - assert!((80..=120).contains(&y) && x0 >= 80 && x1 <= 121 && x1 > x0, "dir {dir} y {y} {x0} {x1}"); - n += 1; - }); - assert!(n >= 30); - } - } - - #[test] - fn icons_fit_their_box_and_are_centred() { - let h = icons::HALF; - for &(id, _, _, r) in BUTTONS.iter() { - let (mut n, mut sx, mut sy) = (0i64, 0i64, 0i64); - let (mut x0, mut x1, mut y0, mut y1) = (i32::MAX, i32::MIN, i32::MAX, i32::MIN); - for py in -h - 8..h + 8 { - for px in -h - 8..h + 8 { - let k = icons::coverage(id, px, py); - if k > 0 { - assert!(px >= -h && px < h && py >= -h && py < h, "icon {id} leaves its box at {px},{py}"); - assert!(px * px + py * py < (r - 6) * (r - 6), "icon {id} touches its button edge"); - n += k as i64; sx += k as i64 * px as i64; sy += k as i64 * py as i64; - x0 = x0.min(px); x1 = x1.max(px); y0 = y0.min(py); y1 = y1.max(py); - } - } - } - assert!(n > 16 * 150, "icon {id} is empty"); - // bounding box centred within 2 px (the pixel grid is offset by half a pixel) - assert!((x0 + x1).abs() <= 3 && (y0 + y1).abs() <= 3, "icon {id} box {x0}..{x1} x {y0}..{y1} is off centre"); - // not stretched: width and height within 1.7x of each other - let (w, hh) = (x1 - x0 + 1, y1 - y0 + 1); - assert!(w * 10 <= hh * 17 && hh * 10 <= w * 17, "icon {id} is stretched {w}x{hh}"); - } - } - - /// `WR_PREVIEW=/dir cargo test preview -- --ignored` writes page1.ppm and page2.ppm (store screenshots). - /// Same geometry and colours as the device drawing code; the round screen edge is masked. - #[test] - #[ignore] - fn preview() { - let dir = std::env::var("WR_PREVIEW").unwrap(); - type Px = [f32; 3]; - let (face, down, fg): (Px, Px, Px) = ([58., 58., 60.], [96., 96., 100.], [200., 200., 204.]); - let mix = |a: Px, b: Px, t: f32| -> Px { core::array::from_fn(|i| a[i] + (b[i] - a[i]) * t) }; - let save = |name: &str, f: &dyn Fn(i32, i32) -> Px| { - let mut out = format!("P6 {SIZE} {SIZE} 255\n").into_bytes(); - for y in 0..SIZE { - for x in 0..SIZE { - let (dx, dy) = (x - C, y - C); - let p = if dx * dx + dy * dy > C * C { [0.; 3] } else { f(x, y) }; - out.extend(p.iter().map(|v| *v as u8)); - } - } - std::fs::write(format!("{dir}/{name}"), out).unwrap(); - }; - let dots = |x: i32, y: i32, page: i32| -> Option { - for i in 0..2 { - let cx = C + (i * 2 - 1) * (DOT_GAP / 2); - let r = if i == page { 6 } else { 4 }; - if (x - cx) * (x - cx) + (y - DOT_Y) * (y - DOT_Y) <= r * r { - return Some(if i == page { fg } else { down }); - } - } - None - }; - save("page1.ppm", &|x, y| { - if let Some(d) = dots(x, y, 0) { return d; } - let (dx, dy) = (x - C, y - C); - let d2 = dx * dx + dy * dy; - let mut arrow = false; - for (dir, ax, ay) in [(0u8, C, C - 125), (1, C, C + 125), (2, C - 125, C), (3, C + 125, C)] { - triangle(dir, ax, ay, 20, |ty, x0, x1| if ty == y && x >= x0 && x < x1 { arrow = true }); - } - if arrow { return fg; } - if d2 <= (RC + 2) * (RC + 2) { - return if d2 >= (RC - 6) * (RC - 6) { fg } else { face }; - } - if d2 <= (RC + 12) * (RC + 12) { return [0.; 3]; } - for dir in 0..4u8 { - if let Some((a, b)) = wedge_span(dir, dy, 5) { - if dx >= a && dx <= b { return face; } - } - } - [0.; 3] - }); - save("page2.ppm", &|x, y| { - if let Some(d) = dots(x, y, 1) { return d; } - for &(id, cx, cy, r) in BUTTONS.iter() { - let (dx, dy) = (x - cx, y - cy); - if dx * dx + dy * dy <= r * r { - return mix(face, fg, icons::coverage(id, dx, dy) as f32 / 16.0); - } - } - [0.; 3] - }); - } -} diff --git a/apps/watch-remote/store.md b/apps/watch-remote/store.md deleted file mode 100644 index 4ff7f27..0000000 --- a/apps/watch-remote/store.md +++ /dev/null @@ -1,19 +0,0 @@ -Watch Remote turns your watch into a remote for your laptop, PC or Google TV. The watch talks to your phone, and -your phone shows up on the PC or TV as a Bluetooth keyboard and media remote. No app is needed on the PC or TV. - -**Page 1** is a D-pad: up, down, left and right, with OK (Enter) in the middle. Use it to move around menus, -slides or a TV home screen. Hold a button and it keeps going, like holding a key on a keyboard. - -**Page 2** has Back, Home, Previous, Play/Pause, Next, Mute and Volume. Tap the speaker icon and turn the crown to -change the volume. It switches off by itself after a second. - -Turn the crown or tap the dots at the bottom to switch pages. Press the crown to leave. - -You can change what every button does in the phone app. - -## Requirements - -- The [**Watch Menu**](https://github.com/abdalrahmanmamdouh2004-svg/watch-menu/releases/tag/1.0.0) phone app (Android 9 or newer). - Turn on Watch Remote there, then pair your PC or TV with the phone over Bluetooth once. -- The watch paired with the **Nothing X** app first, then connected in Watch Menu. -- The patched firmware with the channel key (2026-11-13 or later) and the App Loader. diff --git a/apps/watch-remote/store.toml b/apps/watch-remote/store.toml deleted file mode 100644 index 38b7479..0000000 --- a/apps/watch-remote/store.toml +++ /dev/null @@ -1,5 +0,0 @@ -name = "Watch Remote" -summary = "Use your watch as a remote for your PC or Google TV: arrows, OK, media keys and volume" -version = "0.6.0" -author = "Abdalrahman" -screenshots = ["shots/page1.png", "shots/page2.png"] diff --git a/apps/weather/Cargo.toml b/apps/weather/Cargo.toml deleted file mode 100644 index 1d5c8a6..0000000 --- a/apps/weather/Cargo.toml +++ /dev/null @@ -1,16 +0,0 @@ -[package] -name = "weather" -edition.workspace = true -license.workspace = true -version.workspace = true - -[dependencies] -cmf-wp2-app.workspace = true -companion-rpc.workspace = true - -[dev-dependencies] -wp2-core.workspace = true - -[[bin]] -name = "weather" -bench = false diff --git a/apps/weather/README.md b/apps/weather/README.md deleted file mode 100644 index 7572b4a..0000000 --- a/apps/weather/README.md +++ /dev/null @@ -1,41 +0,0 @@ -# Weather - -The store's page is [`store.md`](store.md). This is the contract of the widget card, which the watch -(`src/model.rs`, `Model::columns`) and FMC Companion both write: the same forecast at the same hour gives the same -bytes, so change both sides together. - -## The card (stub 10 and its loader) - -A v2 `columns` record (the SDK's `docs/widget-push.md`) of at most four columns: now, then the three hours after the -one that contains now. Hours that aren't known give no column. Without the current weather the phone writes nothing -and the watch keeps its text card; so does a watch that answers `-22` to the record. - -- Caption: `Now`, then `HH:00` (24 h, zero-padded, `00:00` after `23:00`). -- Hours count from the forecast's own first hour and the phone's clock, never from a stale first entry. -- Value: whole degrees C and `°` (U+00B0), no unit. Now is the current record's 0.1° rounded, halves away from zero, - never `-0`; an hour is its entry's temperature. -- Icon: the index of the condition, from the WMO code of the current record or of that hour. At night index 0 becomes - 8 and index 1 becomes 9; the other six have one drawing. -- Night is bit 7 of an hourly entry's precip byte: that entry's for its column, and for Now that of the entry that - contains now, as on the Now page. No such entry means day. Nothing else says what is night (no sunrise of the - phone's or the watch's own), so both write the same bytes. - -| Index | `widget-icons/` | `model::Icon` | WMO codes | -|---|---|---|---| -| 0 | `00-clear.svg` | `Clear` | 0 | -| 1 | `01-partly.svg` | `Partly` | 1, 2 | -| 2 | `02-cloud.svg` | `Cloud` | anything not listed here | -| 3 | `03-fog.svg` | `Fog` | 45, 48 | -| 4 | `04-drizzle.svg` | `Drizzle` | 51-57 | -| 5 | `05-rain.svg` | `Rain` | 61-67, 80-82 | -| 6 | `06-snow.svg` | `Snow` | 71-77, 85, 86 | -| 7 | `07-storm.svg` | `Storm` | 95-99 | -| 8 | `08-clear-night.svg` | `Clear` at night | 0 | -| 9 | `09-partly-night.svg` | `Partly` at night | 1, 2 | - -The index is the file's place in name order and is stored on watches and sent by phones: append, never reorder. - -Test vectors (87 bytes each, `src/model_tests.rs`, `columns_golden_bytes` and `columns_golden_bytes_at_night`): - -- `wp2apps.install.columns_record([("Now",6,"-3°"),("23:00",2,"-4°"),("00:00",0,"-5°"),("01:00",7,"0°")])` -- `wp2apps.install.columns_record([("Now",8,"-3°"),("23:00",9,"-4°"),("00:00",2,"-5°"),("01:00",7,"0°")])` diff --git a/apps/weather/icon.svg b/apps/weather/icon.svg deleted file mode 100644 index 6c97534..0000000 --- a/apps/weather/icon.svg +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/apps/weather/shots/card.png b/apps/weather/shots/card.png deleted file mode 100644 index 6c208e3..0000000 Binary files a/apps/weather/shots/card.png and /dev/null differ diff --git a/apps/weather/shots/days.png b/apps/weather/shots/days.png deleted file mode 100644 index a06ee0f..0000000 Binary files a/apps/weather/shots/days.png and /dev/null differ diff --git a/apps/weather/shots/hours.png b/apps/weather/shots/hours.png deleted file mode 100644 index a5fbf0f..0000000 Binary files a/apps/weather/shots/hours.png and /dev/null differ diff --git a/apps/weather/shots/now.png b/apps/weather/shots/now.png deleted file mode 100644 index e75aa80..0000000 Binary files a/apps/weather/shots/now.png and /dev/null differ diff --git a/apps/weather/src/main.rs b/apps/weather/src/main.rs deleted file mode 100644 index 413a8a5..0000000 --- a/apps/weather/src/main.rs +++ /dev/null @@ -1,193 +0,0 @@ -//! weather: now, the next hours and the next days, from FMC Companion (`location` for the place, `weather`). -//! -//! - The menu app is three pages in the stock pager (`screen::pages_view`): now, hours, days. The crown or a -//! swipe pages; the hours and days scroll first. BUTTON exits. -//! - The page next to the watch face (`app_features!(PAGE)`) is the now screen alone (`screen::face_view`). -//! - The card left of the face (`WIDGET`): from stub 10 now and the next three hours in columns with the app's own -//! icons (`widget-icons/`, README.md), before that the place, the temperature with the condition, high and low; -//! written whenever it changes while the app runs, a new hour too. -//! -//! The weather comes from the phone at start and every 15 minutes while shown, and is kept in the app's storage so -//! it opens at once without the phone (`model.rs`). -#![cfg_attr(target_os = "none", no_std, no_main)] - -#[cfg_attr(not(target_os = "none"), allow(dead_code))] -mod model; -#[cfg_attr(not(target_os = "none"), allow(dead_code))] -mod screen; - -#[cfg(not(target_os = "none"))] -fn main() {} - -#[cfg(target_os = "none")] -mod device { - use crate::model::{BLOB_MAX, Card, Got, Model, Widget, wall_min}; - use crate::screen::{self, View}; - use cmf_wp2_app::lv::{Batch, Lv, ROOT}; - use cmf_wp2_app::{Api, BUTTON, MESSAGE, MSG_MAX, PAUSE, RESUME}; - - cmf_wp2_app::entry!(main); - cmf_wp2_app::app_icon!(); - cmf_wp2_app::app_features!(cmf_wp2_app::WIDGET | cmf_wp2_app::PAGE); - - /// How often to look at the clock: a new hour moves the hours, the "Updated" line ages. - const TICK_MS: u32 = 60_000; - /// On the page next to the face, coming back asks the phone only when the copy is older than this. - const FRESH_MIN: i32 = 30; - - static mut STORE: [u8; BLOB_MAX] = [0; BLOB_MAX]; - static mut MODEL: Model = Model::new(); - - fn wall(api: &Api) -> i32 { - api.time().map_or(0, |t| wall_min(t.year as i32, t.month as u32, t.day as u32, t.hour as u32, t.minute as u32)) - } - - struct App { - api: &'static Api, - lv: Lv, - b: Batch, - model: &'static mut Model, - view: View, - /// The pager's page, kept over a redraw. - page: usize, - on_page: bool, - /// What the screen shows depends on, besides the data. - shown: (i32, bool, i32), - widget: Widget, - } - - impl App { - /// The hour, whether the phone is silent, and the age once it is worth a line. - fn key(&self, w: i32) -> (i32, bool, i32) { - let stale = self.model.stale_min(w); - (w.div_euclid(60), self.model.silent(), if self.model.now.is_some() && stale > 45 { stale / 10 } else { 0 }) - } - - fn draw(&mut self) { - let (lv, w) = (self.lv, wall(self.api)); - let mut flush = |b: &mut Batch| b.submit(&lv); - let r = screen::leave(&mut self.b, self.view.root) - .and_then(|_| { - if self.on_page { - screen::face_view(&mut self.b, &mut flush, self.model, w) - } else { - screen::pages_view(&mut self.b, &mut flush, self.model, w, self.page) - } - }) - .and_then(|v| self.b.submit(&lv).map(|_| v)); - match r { - Ok(v) => self.view = v, - Err(_) => self.b.clear(), // or the records left in it fail every later draw - } - self.shown = self.key(w); - } - - fn save(&mut self) { - let blob = unsafe { &mut *core::ptr::addr_of_mut!(STORE) }; - let n = self.model.save(blob); - if n > 0 { - self.api.save(&blob[..n]); // on change: the app can end without notice - } - } - - /// The card, when it changes. - fn card(&mut self) { - let api = self.api; - self.widget.update(self.model, wall(api), |card| match card { - Card::Columns((rec, n)) => api.widget_v2(&rec[..*n]), - Card::Text(t, v) => api.widget(t.as_str(), v.as_str()), - }); - } - - fn poll(&mut self) { - let now = self.api.now(); - while let Some(req) = self.model.poll(now) { - if self.api.send(&req) == -11 { - break; // outbox full: the retry timer sends it again - } // -107 with no phone: the retry timer covers it too - } - } - - fn message(&mut self, m: &[u8]) { - let got = self.model.reply(m, self.api.now(), wall(self.api)); - if got == Got::Saved { - self.save(); - } - if got != Got::Nothing { - self.draw(); - self.card(); - } - } - - /// The clock moved, or the phone went silent. - fn tick(&mut self) { - if self.key(wall(self.api)) != self.shown { - self.draw(); - self.card(); - } - } - } - - fn main(api: &'static Api) -> i32 { - let Some(lv) = api.lv() else { return -95 }; // loader older than ABI 1.2 - let Some(mut b) = Batch::new() else { return -1 }; - if screen::fonts(&mut b).and_then(|_| b.submit(&lv)).is_err() { - return 1; - } - if screen::theme(&mut b).and_then(|_| b.submit(&lv)).is_err() { - return 2; - } - let model = unsafe { &mut *core::ptr::addr_of_mut!(MODEL) }; - let blob = unsafe { &mut *core::ptr::addr_of_mut!(STORE) }; - let n = api.load(blob); - if n > 0 { - model.load(&blob[..n as usize]); - } - model.ask_now(api.now()); - let view = View { root: ROOT, pager: None, bars: [ROOT; 3] }; - let mut app = - App { api, lv, b, model, view, page: 0, on_page: api.on_page(), shown: (0, false, 0), widget: Widget::new() }; - app.draw(); - app.card(); - let mut paused = false; - let mut msg = [0u8; MSG_MAX]; - loop { - if !paused { - app.poll(); - } - let wait = if paused { u32::MAX } else { app.model.wait(api.now()).min(TICK_MS) }; - let e = api.event(wait); - if !paused { - app.tick(); - } - let Some(e) = e else { continue }; - match e.kind { - BUTTON => break, - PAUSE => paused = true, - RESUME => { - paused = false; - if app.model.now.is_none() || app.model.stale_min(wall(api)) > FRESH_MIN { - app.model.ask_now(api.now()); - } - app.tick(); - } - MESSAGE => { - while let Some(m) = api.recv(&mut msg) { - app.message(m); - } - } - _ if !paused => { - // the pager settled on a page: move its dots - if let Some(p) = app.view.pager.as_mut() { - if let Ok(Some(i)) = p.event(&mut app.b, &e) { - app.page = i; - let _ = app.b.submit(&lv); - } - } - } - _ => {} - } - } - 0 - } -} diff --git a/apps/weather/src/model.rs b/apps/weather/src/model.rs deleted file mode 100644 index a20fcb8..0000000 --- a/apps/weather/src/model.rs +++ /dev/null @@ -1,641 +0,0 @@ -//! Weather's state, without `Api`: the two calls to the phone (`location` once for the place, `weather` every 15 -//! minutes while open), what they answered, the cache blob, and the texts and geometry the screens show. -//! -//! Hours and days count from the phone's answer: a cached answer moves with the clock, so the hours that passed and -//! yesterday drop out instead of being shown as now and today. They count from the phone's hour, not the watch's -//! at the moment the answer came (`Model::base`): the two clocks can sit on either side of an hour or of midnight. - -use cmf_wp2_app::{Column, columns_record}; -use companion_rpc as rpc; -use core::fmt::Write; - -/// After a temperature in text: nothing. The watch's fonts have no degree sign (it draws as a blank the width of -/// a letter, seen in the emulator), so texts carry plain numbers and the now screen draws a ring instead. -pub const DEG: &str = ""; -/// A fresh answer this often while the app is open; the phone itself caches for 30 minutes. -pub const PERIOD_MS: u32 = 15 * 60_000; -/// While the phone waits for the user's "allow". -pub const ASK_AGAIN_MS: u32 = 10_000; -/// Columns of the widget card: now and the three hours after it. -const COLUMNS: usize = 4; -/// What a write answers when the watch can't draw the record (a stub before 10, a loader without templates). -const E_UNSUPPORTED: i32 = -22; -/// And when NAND failed. -const E_IO: i32 = -5; -/// Hours asked for and shown. -pub const ASK_HOURS: u8 = 12; -pub const HOURS: usize = 24; -pub const DAYS: usize = 7; -const MAGIC: &[u8; 2] = b"W1"; -pub const BLOB_MAX: usize = 2 + 4 + 1 + rpc::TEXT_MAX + 8 + HOURS * 3 + 1 + DAYS * 5; - -#[derive(Clone, Copy, PartialEq, Eq, Debug)] -pub enum Status { - /// No answer to this run's request yet. - Waiting, - Ok, - Ask, - Denied, - Unavailable, -} - -/// What a message changed. -#[derive(Clone, Copy, PartialEq, Eq, Debug)] -pub enum Got { - Nothing, - /// The status: redraw. - Changed, - /// The data: redraw and store. - Saved, -} - -/// The order is a contract: a value is the index of its drawing by day in `widget-icons/` and of the icon in the card -/// FMC Companion pushes (README.md next to `Cargo.toml`). The night's drawings follow these ([`widget_icon`]). -#[derive(Clone, Copy, PartialEq, Eq, Debug)] -pub enum Icon { - Clear, - Partly, - Cloud, - Fog, - Drizzle, - Rain, - Snow, - Storm, -} - -/// `temp` in 0.1 °C, `wind` m/s, `humidity` %. -#[derive(Clone, Copy, PartialEq, Eq, Debug)] -pub struct Now { - pub temp: i16, - pub code: u8, - pub wind: u8, - pub humidity: u8, -} - -/// `day` counts from the day of the answer; `min`/`max` °C, `precip` %. -#[derive(Clone, Copy, PartialEq, Eq, Debug)] -pub struct Day { - pub day: i8, - pub min: i8, - pub max: i8, - pub code: u8, - pub precip: u8, -} - -const NO_HOUR: rpc::Hour = rpc::Hour { temp: 0, code: 0, precip: 0, night: false }; -const NO_DAY: Day = Day { day: 0, min: 0, max: 0, code: 0, precip: 0 }; - -/// One answer of `weather`. -#[derive(Clone, Copy)] -struct Data { - now: Option, - /// Minutes the phone's data was old when it answered. - age: u8, - hour0: u8, - nh: usize, - hours: [rpc::Hour; HOURS], - nd: usize, - /// Sorted by `day`, each day once. - days: [Day; DAYS], -} - -const EMPTY: Data = Data { now: None, age: 0, hour0: 0, nh: 0, hours: [NO_HOUR; HOURS], nd: 0, days: [NO_DAY; DAYS] }; - -pub struct Model { - pub status: Status, - pub now: Option, - /// The last answer had no hours: a companion from before them (or a source without). - pub no_hours: bool, - data: Data, - pending: Data, - /// Wall minutes of the answer `data` is. - at: i32, - place: rpc::Text, - /// `location` answered in this run, with a place or a refusal. - located: bool, - /// Ask with hours; off once the phone called that a bad request. - with_hours: bool, - weather: rpc::Call, - location: rpc::Call, - ids: u8, -} - -/// Days since 1970-01-01 of a civil date. -pub fn days(y: i32, m: u32, d: u32) -> i32 { - let y = if m <= 2 { y - 1 } else { y }; - let (era, yoe) = (y.div_euclid(400), y.rem_euclid(400)); - let doy = (153 * ((m as i32 + 9) % 12) + 2) / 5 + d as i32 - 1; - era * 146_097 + yoe * 365 + yoe / 4 - yoe / 100 + doy - 719_468 -} - -/// Wall-clock minutes since 1970: what `at` and every `wall` argument are. -pub fn wall_min(y: i32, m: u32, d: u32, hour: u32, minute: u32) -> i32 { - days(y, m, d) * 1440 + (hour * 60 + minute) as i32 -} - -pub fn icon(code: u8) -> Icon { - match code { - 0 => Icon::Clear, - 1 | 2 => Icon::Partly, - 45 | 48 => Icon::Fog, - 51..=57 => Icon::Drizzle, - 61..=67 | 80..=82 => Icon::Rain, - 71..=77 | 85 | 86 => Icon::Snow, - 95..=99 => Icon::Storm, - _ => Icon::Cloud, - } -} - -/// The index in `widget-icons/`, append only: the conditions, then clear and partly cloudy at night. -fn widget_icon(code: u8, night: bool) -> u8 { - match icon(code) { - Icon::Clear if night => 8, - Icon::Partly if night => 9, - i => i as u8, - } -} - -pub fn condition(code: u8) -> &'static str { - match icon(code) { - Icon::Clear => "Clear", - Icon::Partly => "Partly cloudy", - Icon::Cloud => "Cloudy", - Icon::Fog => "Fog", - Icon::Drizzle => "Drizzle", - Icon::Rain => "Rain", - Icon::Snow => "Snow", - Icon::Storm => "Storm", - } -} - -/// 0.1 °C to whole degrees, halves away from zero; −0.4 is 0, never "-0". -pub fn deg(t10: i16) -> i16 { - let t = t10 as i32; - (if t >= 0 { (t + 5) / 10 } else { -((5 - t) / 10) }) as i16 -} - -/// A short text built in place; what doesn't fit is cut at a character. -#[derive(Clone, Copy, PartialEq, Eq)] -pub struct Line { - buf: [u8; 64], - len: usize, -} - -impl Line { - pub const fn new() -> Line { - Line { buf: [0; 64], len: 0 } - } - pub fn as_str(&self) -> &str { - core::str::from_utf8(&self.buf[..self.len]).unwrap_or("") - } -} - -impl Write for Line { - fn write_str(&mut self, s: &str) -> core::fmt::Result { - let s = rpc::utf8_cut(s.as_bytes(), self.buf.len() - self.len); - self.buf[self.len..self.len + s.len()].copy_from_slice(s.as_bytes()); - self.len += s.len(); - Ok(()) - } -} - -/// "-3". -pub fn temp_text(deg: i16) -> Line { - let mut l = Line::new(); - let _ = write!(l, "{deg}{DEG}"); - l -} - -/// The hour of day of entry `i` of hours that start at `first`. -pub fn hour_label(first: u8, i: u8) -> u8 { - ((first as u16 + i as u16) % 24) as u8 -} - -/// Of a day number (days since 1970, a Thursday). -pub fn weekday(abs_day: i32) -> &'static str { - ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"][(abs_day + 3).rem_euclid(7) as usize] -} - -/// Where a day's `min..max` lies on a track `width` wide that spans the week's `lo..hi`: (x, length), the length -/// at least `min_len` and always inside the track. -pub fn bar(min: i8, max: i8, lo: i8, hi: i8, width: i16, min_len: i16) -> (i16, i16) { - if hi <= lo { - return (0, width); - } - let (lo, hi, w) = (lo as i32, hi as i32, width as i32); - let (a, b) = ((min as i32).clamp(lo, hi), (max as i32).clamp(lo, hi)); - let (a, b) = (a.min(b), a.max(b)); - let x = (a - lo) * w / (hi - lo); - let len = ((b - lo) * w / (hi - lo) - x).max(min_len as i32).min(w); - (x.min(w - len) as i16, len as i16) -} - -/// "Updated 50 min ago" once the data is older than the phone's own cache keeps it. -pub fn updated(stale_min: i32) -> Option { - if stale_min <= 45 { - return None; - } - let mut l = Line::new(); - let _ = match stale_min { - ..90 => write!(l, "Updated {stale_min} min ago"), - ..2880 => write!(l, "Updated {} h ago", stale_min / 60), - _ => write!(l, "Updated {} d ago", stale_min / 1440), - }; - Some(l) -} - -struct Rd<'a>(&'a [u8]); - -impl<'a> Rd<'a> { - fn take(&mut self, n: usize) -> Option<&'a [u8]> { - if self.0.len() < n { - return None; - } - let (a, b) = self.0.split_at(n); - self.0 = b; - Some(a) - } - fn u8(&mut self) -> Option { - self.take(1).map(|b| b[0]) - } -} - -impl Model { - pub const fn new() -> Self { - Model { - status: Status::Waiting, - now: None, - no_hours: false, - data: EMPTY, - pending: EMPTY, - at: 0, - place: rpc::Text::EMPTY, - located: false, - with_hours: true, - weather: rpc::Call::new(60_000), - location: rpc::Call::new(60_000), - ids: 0, - } - } - - /// Ask at once (start, `RESUME`, the page shown again); the place only until the phone answered about it. - pub fn ask_now(&mut self, now: u32) { - self.weather.now(now); - if !self.located { - self.location.now(now); - } - } - - /// A request to send now, if one is due. - pub fn poll(&mut self, now: u32) -> Option { - if let Some(id) = self.location.due(now, &mut self.ids) { - return Some(rpc::location(id)); - } - let id = self.weather.due(now, &mut self.ids)?; - self.pending = EMPTY; - Some(rpc::weather(id, DAYS as u8, if self.with_hours { ASK_HOURS } else { 0 })) - } - - /// Ms until [`Model::poll`] has something to do. - pub fn wait(&self, now: u32) -> u32 { - self.weather.wait(now).min(self.location.wait(now)) - } - - /// The phone left the last weather request unanswered. - pub fn silent(&self) -> bool { - self.weather.silent() - } - - /// One message from the phone, at `now` ms and `wall` minutes. - pub fn reply(&mut self, m: &[u8], now: u32, wall: i32) -> Got { - match self.location.take(m) { - rpc::Got::Nothing => {} - rpc::Got::Status(rpc::ASK) => { - self.location.after(now, ASK_AGAIN_MS); - return Got::Nothing; - } - // denied, no fix: the weather shows without a place - rpc::Got::Status(_) => { - self.located = true; - self.location.stop(); - return Got::Nothing; - } - rpc::Got::Record { record, .. } => { - self.located = true; - self.location.stop(); - let Some(l) = rpc::Location::decode(record) else { return Got::Nothing }; - self.place = l.place; - return Got::Saved; - } - } - match self.weather.take(m) { - rpc::Got::Nothing => Got::Nothing, - // a companion from before hours (Android): once more the old way - rpc::Got::Status(rpc::BAD_REQUEST) if self.with_hours => { - self.with_hours = false; - self.weather.now(now); - Got::Nothing - } - rpc::Got::Status(s) => { - self.status = match s { - rpc::ASK => Status::Ask, - rpc::DENIED => Status::Denied, - _ => Status::Unavailable, // OK without records too - }; - self.weather.after(now, if self.status == Status::Ask { ASK_AGAIN_MS } else { PERIOD_MS }); - Got::Changed - } - // any order; one that doesn't decode is left out - rpc::Got::Record { record, last, .. } => { - self.record(record); - if !last { - return Got::Nothing; - } - self.weather.after(now, PERIOD_MS); - if self.pending.now.is_none() { - self.status = Status::Unavailable; - return Got::Changed; - } - self.data = self.pending; - self.now = self.data.now; - self.at = wall; - self.no_hours = self.data.nh == 0; - self.status = Status::Ok; - Got::Saved - } - } - } - - fn record(&mut self, record: &[u8]) { - let p = &mut self.pending; - match rpc::Weather::decode(record) { - Some(rpc::Weather::Now { temp, code, wind, humidity, age }) => { - p.now = Some(Now { temp, code, wind, humidity }); - p.age = age; - } - Some(w @ rpc::Weather::Hours { hour, n, .. }) => { - p.hour0 = hour % 24; - p.nh = (n as usize).min(HOURS); - for i in 0..p.nh { - p.hours[i] = w.hour(i).unwrap_or(NO_HOUR); - } - } - Some(rpc::Weather::Day { day, min, max, code, precip }) => { - Self::add_day(p, Day { day, min, max, code, precip }); - } - None => {} - } - } - - /// Keeps `days` sorted; a day before the answer's, a repeat or an eighth is dropped. - fn add_day(p: &mut Data, d: Day) { - if d.day < 0 || p.nd == DAYS || p.days[..p.nd].iter().any(|x| x.day == d.day) { - return; - } - let at = p.days[..p.nd].iter().position(|x| x.day > d.day).unwrap_or(p.nd); - p.days.copy_within(at..p.nd, at + 1); - p.days[at] = d; - p.nd += 1; - } - - /// The locality, empty when the phone gave none. - pub fn place(&self) -> &str { - self.place.as_str() - } - - /// Minutes since the phone fetched what is shown. - pub fn stale_min(&self, wall: i32) -> i32 { - wall - self.at + self.data.age as i32 - } - - /// The hour (hours since 1970, wall clock) the phone was in when it answered: the first hourly entry's, and - /// the one its day 0 is the day of. The watch's own hour at `at`, moved to the nearest one that is `hour0` - /// o'clock; without hours, the watch's. - fn base(&self) -> i32 { - let h = self.at.div_euclid(60); - if self.data.nh == 0 { - return h; - } - h + (self.data.hour0 as i32 - h.rem_euclid(24) + 36).rem_euclid(24) - 12 - } - - /// Hours of the answer that passed by `wall`. - fn hours_gone(&self, wall: i32) -> usize { - (wall.div_euclid(60) - self.base()).clamp(0, self.data.nh as i32) as usize - } - - pub fn hours_len(&self, wall: i32) -> usize { - self.data.nh - self.hours_gone(wall) - } - - /// Row `k` of the hours at `wall`: the hour of day, whether it is the current hour, the hour. - pub fn hour_at(&self, k: usize, wall: i32) -> Option<(u8, bool, rpc::Hour)> { - let i = self.hours_gone(wall) + k; - if i >= self.data.nh { - return None; - } - let is_now = self.base() + i as i32 == wall.div_euclid(60); - Some((hour_label(self.data.hour0, i as u8), is_now, self.data.hours[i])) - } - - /// Whether it is night now: what the hourly entry that contains now says, day without one. - pub fn night_now(&self, wall: i32) -> bool { - self.hour_at(0, wall).is_some_and(|(_, is_now, h)| is_now && h.night) - } - - /// `wall`'s day counted from the answer's. - fn today_index(&self, wall: i32) -> i32 { - wall.div_euclid(1440) - self.base().div_euclid(24) - } - - fn shown_days(&self, wall: i32) -> &[Day] { - let t = self.today_index(wall); - let d = &self.data.days[..self.data.nd]; - &d[d.iter().position(|x| x.day as i32 >= t).unwrap_or(d.len())..] - } - - pub fn days_len(&self, wall: i32) -> usize { - self.shown_days(wall).len() - } - - /// Row `k` of the days at `wall`: the day's number (days since 1970), whether it is today, the day. - pub fn day_at(&self, k: usize, wall: i32) -> Option<(i32, bool, Day)> { - let d = *self.shown_days(wall).get(k)?; - Some((self.base().div_euclid(24) + d.day as i32, d.day as i32 == self.today_index(wall), d)) - } - - pub fn today(&self, wall: i32) -> Option { - self.day_at(0, wall).filter(|x| x.1).map(|x| x.2) - } - - /// Lowest min and highest max of the days shown. - pub fn range(&self, wall: i32) -> (i8, i8) { - let d = self.shown_days(wall); - (d.iter().map(|x| x.min).min().unwrap_or(0), d.iter().map(|x| x.max).max().unwrap_or(0)) - } - - /// The text card: title (≤ 23 bytes) and value (≤ 39 bytes, two lines). - pub fn card(&self, wall: i32) -> (Line, Line) { - let (mut t, mut v) = (Line::new(), Line::new()); - let place = rpc::utf8_cut(self.place.as_str().as_bytes(), 23); - let _ = t.write_str(if place.is_empty() { "Weather" } else { place }); - let Some(n) = self.now else { - let _ = v.write_str("Open the app"); - return (t, v); - }; - let _ = write!(v, "{}{DEG} {}", deg(n.temp), condition(n.code)); - if let Some(d) = self.today(wall) { - let _ = write!(v, "\nH {}{DEG} L {}{DEG}", d.max, d.min); - } - (t, v) - } - - /// The columns card (stub 10): now and those of the next three hours that are known. `None` without the current - /// weather. FMC Companion pushes the same bytes for the same forecast and hour (README.md next to `Cargo.toml`). - /// The `°` is real here: the stub draws it, unlike the fonts an app gets ([`DEG`]). - pub fn columns(&self, wall: i32) -> Option { - let now = self.now?; - let mut cols = [(Line::new(), 0, Line::new()); COLUMNS]; - let _ = cols[0].0.write_str("Now"); - cols[0].1 = widget_icon(now.code, self.night_now(wall)); - let _ = write!(cols[0].2, "{}°", deg(now.temp)); - let mut n = 1; - // not `hour_at`: with the watch's clock behind the answer, that would show hours further ahead than three - let next = wall.div_euclid(60) + 1 - self.base(); - for i in next..next + COLUMNS as i32 - 1 { - if !(0..self.data.nh as i32).contains(&i) { - continue; - } - let (h, (caption, pic, value)) = (self.data.hours[i as usize], &mut cols[n]); - let _ = write!(caption, "{:02}:00", hour_label(self.data.hour0, i as u8)); - *pic = widget_icon(h.code, h.night); - let _ = write!(value, "{}°", h.temp); - n += 1; - } - let cols: [Column; COLUMNS] = core::array::from_fn(|i| Column { - caption: cols[i].0.as_str(), - icon: Some(cols[i].1), - value: cols[i].2.as_str(), - }); - columns_record(&cols[..n]) - } - - /// The cache blob; 0 before the first answer. - pub fn save(&self, out: &mut [u8]) -> usize { - let (Some(n), d) = (self.data.now, &self.data) else { return 0 }; - let place = self.place.as_str().as_bytes(); - let len = 2 + 4 + 1 + place.len() + 8 + d.nh * 3 + 1 + d.nd * 5; - if out.len() < len { - return 0; - } - let mut k = 0; - let mut put = |b: &[u8]| { - out[k..k + b.len()].copy_from_slice(b); - k += b.len(); - }; - put(MAGIC); - put(&self.at.to_le_bytes()); - put(&[place.len() as u8]); - put(place); - put(&n.temp.to_le_bytes()); - put(&[n.code, n.wind, n.humidity, d.age, d.hour0, d.nh as u8]); - for h in &d.hours[..d.nh] { - put(&[h.temp as u8, h.code, h.precip | (h.night as u8) << 7]); - } - put(&[d.nd as u8]); - for x in &d.days[..d.nd] { - put(&[x.day as u8, x.min as u8, x.max as u8, x.code, x.precip]); - } - len - } - - /// Reads a blob of [`Model::save`]; anything else (another version, cut short, counts out of range) is left - /// alone and the model stays as it was. - pub fn load(&mut self, b: &[u8]) -> bool { - let Some((at, place, data)) = Self::parse(b) else { return false }; - (self.at, self.place, self.data, self.now) = (at, place, data, data.now); - self.no_hours = false; // not known until the phone answers - true - } - - fn parse(b: &[u8]) -> Option<(i32, rpc::Text, Data)> { - let mut r = Rd(b); - if r.take(2)? != MAGIC { - return None; - } - let at = i32::from_le_bytes(r.take(4)?.try_into().ok()?); - let n = r.u8()? as usize; - let place = core::str::from_utf8(r.take(n)?).ok()?; - let mut d = EMPTY; - let temp = i16::from_le_bytes(r.take(2)?.try_into().ok()?); - d.now = Some(Now { temp, code: r.u8()?, wind: r.u8()?, humidity: r.u8()? }); - d.age = r.u8()?; - d.hour0 = r.u8()?; - d.nh = r.u8()? as usize; - if d.hour0 > 23 || d.nh > HOURS { - return None; - } - for i in 0..d.nh { - let e = r.take(3)?; - d.hours[i] = rpc::Hour { temp: e[0] as i8, code: e[1], precip: e[2] & 0x7F, night: e[2] & 0x80 != 0 }; - } - let nd = r.u8()? as usize; - if nd > DAYS { - return None; - } - for _ in 0..nd { - let e = r.take(5)?; - Self::add_day(&mut d, Day { day: e[0] as i8, min: e[1] as i8, max: e[2] as i8, code: e[3], precip: e[4] }); - } - if !r.0.is_empty() || d.nd != nd { - return None; - } - Some((at, rpc::Text::new(place.as_bytes()), d)) - } -} - -/// A v2 widget record and its length. -pub type Record = ([u8; 128], usize); - -#[derive(PartialEq, Eq)] -pub enum Card { - Columns(Record), - Text(Line, Line), -} - -/// What this run wrote to the card left of the face. -pub struct Widget { - /// The watch refused columns: text for the rest of the run. - text_only: bool, - last: Option, -} - -impl Widget { - pub const fn new() -> Self { - Widget { text_only: false, last: None } - } - - /// Writes the card when it changed: columns, or the text card without weather or on a watch that can't draw them. - pub fn update(&mut self, m: &Model, wall: i32, mut write: impl FnMut(&Card) -> i32) { - let text = || { - let (t, v) = m.card(wall); - Card::Text(t, v) - }; - let columns = if self.text_only { None } else { m.columns(wall) }; - let mut card = columns.map_or_else(text, Card::Columns); - if self.last.as_ref() == Some(&card) { - return; - } - let mut rc = write(&card); - if rc == E_UNSUPPORTED && matches!(card, Card::Columns(_)) { - self.text_only = true; - card = text(); - rc = write(&card); - } - self.last = (rc != E_IO).then_some(card); - } -} - -#[cfg(test)] -#[path = "model_tests.rs"] -mod tests; diff --git a/apps/weather/src/model_tests.rs b/apps/weather/src/model_tests.rs deleted file mode 100644 index 8fb736b..0000000 --- a/apps/weather/src/model_tests.rs +++ /dev/null @@ -1,636 +0,0 @@ -extern crate std; -use super::*; -use std::vec::Vec; - -// 2026-11-20 (a Friday) 13:20 -const WALL: i32 = 20_777 * 1440 + 13 * 60 + 20; - -fn msg(id: u8, status: u8, index: u8, total: u8, record: &[u8]) -> Vec { - [&b"R1A"[..], &[id, status, index, total], record].concat() -} - -/// The id of the request the model sends now. -fn sent(m: &mut Model, now: u32) -> Vec> { - let mut out = Vec::new(); - while let Some(q) = m.poll(now) { - out.push(q.to_vec()); - } - out -} - -const NOW: [u8; 7] = [0, 0xDE, 0xFF, 71, 5, 88, 10]; // -3.4°, snow, 5 m/s, 88 %, 10 min old -fn hours(first: u8, n: usize) -> Vec { - let mut r = Vec::from([2, first]); - for i in 0..n { - r.extend([(i as i8 - 4) as u8, 3, if i >= 6 { 0x80 | 40 } else { 20 }]); - } - r -} -fn day(d: i8, min: i8, max: i8) -> [u8; 6] { - [1, d as u8, min as u8, max as u8, 3, 40] -} - -/// A model that asked and got `recs` as its weather, at WALL; the place refused. -fn answered(recs: &[Vec]) -> Model { - answered_in(recs, "") -} - -fn answered_in(recs: &[Vec], place: &str) -> Model { - answered_at(recs, place, WALL) -} - -/// The same, with the watch's clock at `wall` when the answer comes. -fn answered_at(recs: &[Vec], place: &str, wall: i32) -> Model { - let mut m = Model::new(); - m.ask_now(0); - let q = sent(&mut m, 0); - let l = q.iter().find(|q| q[4] == 0x20).expect("asks the place"); - if place.is_empty() { - m.reply(&msg(l[3], rpc::DENIED, 0, 0, &[]), 50, wall); - } else { - m.reply(&msg(l[3], 0, 0, 1, &[&[0u8; 6][..], place.as_bytes()].concat()), 50, wall); - } - let weather = q.iter().find(|q| q[4] == 0x30).expect("asks the weather"); - for (i, r) in recs.iter().enumerate() { - m.reply(&msg(weather[3], 0, i as u8, recs.len() as u8, r), 100, wall); - } - m -} - -fn week() -> Vec> { - let mut v = Vec::from([NOW.to_vec(), hours(13, 12)]); - for d in 0..7 { - v.push(day(d, -5 - d, 1 - d).to_vec()); - } - v -} - -#[test] -fn asks_location_and_weather_with_hours() { - let mut m = Model::new(); - m.ask_now(0); - let q = sent(&mut m, 0); - assert_eq!(q.len(), 2); - assert!(q.iter().any(|q| q[4] == 0x20 && q.len() == 5), "location"); - assert!(q.iter().any(|q| q[4] == 0x30 && q[5..] == [7, 12]), "7 days, 12 hours"); - assert_eq!(m.status, Status::Waiting); -} - -#[test] -fn an_answer_fills_now_hours_and_days() { - let m = answered(&week()); - assert_eq!(m.status, Status::Ok); - assert_eq!(m.now, Some(Now { temp: -34, code: 71, wind: 5, humidity: 88 })); - assert_eq!(m.hours_len(WALL), 12); - let (hod, is_now, h) = m.hour_at(0, WALL).unwrap(); - assert_eq!((hod, is_now, h.temp, h.night), (13, true, -4, false)); - let (hod, is_now, h) = m.hour_at(11, WALL).unwrap(); - assert_eq!((hod, is_now, h.temp, h.night, h.precip), (0, false, 7, true, 40), "13 + 11 is midnight"); - assert_eq!(m.hour_at(12, WALL), None); - assert_eq!(m.days_len(WALL), 7); - assert_eq!(m.day_at(0, WALL).map(|(d, today, x)| (d, today, x.min, x.max)), Some((20_777, true, -5, 1))); - assert_eq!(m.day_at(6, WALL).map(|(d, today, x)| (d, today, x.min)), Some((20_783, false, -11))); - assert_eq!(m.today(WALL).map(|d| (d.min, d.max)), Some((-5, 1))); - assert_eq!(m.range(WALL), (-11, 1)); - assert_eq!(m.stale_min(WALL), 10); - assert!(!m.no_hours); -} - -#[test] -fn records_in_any_order_and_days_sorted() { - let mut v = week(); - v.reverse(); - let m = answered(&v); - assert_eq!(m.day_at(0, WALL).map(|(d, ..)| d), Some(20_777)); - assert_eq!(m.day_at(6, WALL).map(|(d, ..)| d), Some(20_783)); - assert!(m.now.is_some()); -} - -#[test] -fn a_cache_moves_with_the_clock() { - let m = answered(&week()); - // three hours later: the hours that passed are gone, the labels stay absolute - let later = WALL + 3 * 60; - assert_eq!(m.hours_len(later), 9); - assert_eq!(m.hour_at(0, later).map(|(h, n, x)| (h, n, x.temp)), Some((16, true, -1))); - assert_eq!(m.stale_min(later), 190); - // two days later: today is the third day of the answer; the hours are all past - let later = WALL + 2 * 1440; - assert_eq!(m.hours_len(later), 0); - assert_eq!(m.days_len(later), 5); - assert_eq!(m.day_at(0, later).map(|(d, t, x)| (d, t, x.min)), Some((20_779, true, -7))); - assert_eq!(m.today(later).map(|d| d.max), Some(-1)); - // a clock set back: nothing before the answer's first hour - assert_eq!(m.hours_len(WALL - 600), 12); - // ten days later: no day left - assert_eq!((m.days_len(WALL + 10 * 1440), m.today(WALL + 10 * 1440)), (0, None)); -} - -#[test] -fn fewer_hours_than_asked_or_none() { - let m = answered(&[NOW.to_vec(), hours(22, 5), day(0, 1, 2).to_vec()]); - assert_eq!(m.hours_len(WALL), 5); - assert_eq!((0..5).map(|k| m.hour_at(k, WALL).unwrap().0).collect::>(), [22, 23, 0, 1, 2]); - assert_eq!(m.hour_at(5, WALL), None); - // an hourly record without entries, and no hourly record (an iPhone with an old companion) - let m = answered(&[NOW.to_vec(), hours(13, 0)]); - assert_eq!((m.hours_len(WALL), m.hour_at(0, WALL), m.no_hours), (0, None, true)); - let m = answered(&[NOW.to_vec(), day(0, 1, 2).to_vec()]); - assert_eq!((m.hours_len(WALL), m.no_hours, m.status), (0, true, Status::Ok)); -} - -#[test] -fn an_old_android_companion_is_asked_again_without_hours() { - let mut m = Model::new(); - m.ask_now(0); - let q = sent(&mut m, 0); - let w = q.iter().find(|q| q[4] == 0x30).unwrap(); - assert_eq!(m.reply(&msg(w[3], rpc::BAD_REQUEST, 0, 0, &[]), 10, WALL), Got::Nothing); - let q = sent(&mut m, 10); - assert_eq!(q.len(), 1); - assert_eq!(q[0][4..], [0x30, 7], "days only"); - m.reply(&msg(q[0][3], 0, 0, 2, &NOW), 20, WALL); - assert_eq!(m.reply(&msg(q[0][3], 0, 1, 2, &day(0, 1, 2)), 20, WALL), Got::Saved); - assert!(m.no_hours && m.status == Status::Ok); - // and BAD_REQUEST to that is not asked a third time at once - m.ask_now(30); - let q = sent(&mut m, 30); - let w = q.iter().find(|q| q[4] == 0x30).unwrap(); - assert_eq!(w[5..], [7]); - assert_eq!(m.reply(&msg(w[3], rpc::BAD_REQUEST, 0, 0, &[]), 40, WALL), Got::Changed); - assert!(sent(&mut m, 40).iter().all(|q| q[4] != 0x30)); -} - -#[test] -fn statuses_keep_the_cache() { - let mut m = answered(&week()); - for (s, want, again) in [ - (rpc::ASK, Status::Ask, ASK_AGAIN_MS), - (rpc::DENIED, Status::Denied, PERIOD_MS), - (rpc::UNAVAILABLE, Status::Unavailable, PERIOD_MS), - ] { - m.ask_now(1000); - let q = sent(&mut m, 1000); - let w = q.iter().find(|q| q[4] == 0x30).unwrap(); - assert_eq!(m.reply(&msg(w[3], s, 0, 0, &[]), 1100, WALL), Got::Changed); - assert_eq!((m.status, m.wait(1100)), (want, again)); - assert!(m.now.is_some() && m.days_len(WALL) == 7, "the last answer stays"); - } - // an answer without the current record is no answer - m.ask_now(2000); - let q = sent(&mut m, 2000); - let w = q.iter().find(|q| q[4] == 0x30).unwrap(); - m.reply(&msg(w[3], 0, 0, 1, &day(0, 9, 9)), 2100, WALL); - assert_eq!(m.status, Status::Unavailable); - assert_eq!(m.today(WALL).map(|d| d.max), Some(1)); -} - -#[test] -fn the_place_comes_from_location_and_its_refusal_is_not_an_error() { - let mut m = Model::new(); - m.ask_now(0); - let q = sent(&mut m, 0); - let l = q.iter().find(|q| q[4] == 0x20).unwrap(); - let rec = [&[0x2Cu8, 2, 0x78, 1, 5, 0][..], "Москва".as_bytes()].concat(); - assert_eq!(m.reply(&msg(l[3], 0, 0, 1, &rec), 10, WALL), Got::Saved); - assert_eq!(m.place(), "Москва"); - let mut m = Model::new(); - m.ask_now(0); - let q = sent(&mut m, 0); - let l = q.iter().find(|q| q[4] == 0x20).unwrap(); - assert_eq!(m.reply(&msg(l[3], rpc::DENIED, 0, 0, &[]), 10, WALL), Got::Nothing); - assert_eq!((m.place(), m.status), ("", Status::Waiting)); - // answered once, it is not asked again while the app runs - m.ask_now(100); - assert!(sent(&mut m, 100).iter().all(|q| q[4] != 0x20)); -} - -#[test] -fn save_and_load() { - let m = answered_in(&week(), "Berlin"); - let mut blob = [0u8; BLOB_MAX]; - let n = m.save(&mut blob); - assert!(n > 0 && n <= BLOB_MAX); - let mut back = Model::new(); - assert!(back.load(&blob[..n])); - assert_eq!(back.place(), "Berlin"); - assert_eq!(back.now, m.now); - assert_eq!(back.status, Status::Waiting, "a cache is not an answer"); - assert_eq!((back.hours_len(WALL), back.days_len(WALL), back.stale_min(WALL)), (12, 7, 10)); - assert_eq!(back.hour_at(11, WALL), m.hour_at(11, WALL)); - assert_eq!(back.day_at(6, WALL), m.day_at(6, WALL)); - // another version, cut short, empty, garbage counts: ignored, the model stays empty - let mut other = blob; - other[1] = b'9'; - for bad in [&other[..n], &blob[..n - 1], &blob[..3], &[][..]] { - let mut x = Model::new(); - assert!(!x.load(bad)); - assert!(x.now.is_none() && x.days_len(WALL) == 0 && x.hours_len(WALL) == 0 && x.place().is_empty()); - } - // nothing to save before the first answer - assert_eq!(Model::new().save(&mut blob), 0); -} - -#[test] -fn temperatures() { - assert_eq!([deg(-34), deg(-35), deg(-4), deg(4), deg(5), deg(0), deg(-5), deg(216)], [-3, -4, 0, 0, 1, 0, -1, 22]); - // the watch's fonts have no degree sign (it draws as a blank): plain numbers - assert_eq!(temp_text(0).as_str(), "0"); - assert_eq!(temp_text(-12).as_str(), "-12"); - assert_eq!(temp_text(deg(-4)).as_str(), "0", "never -0"); -} - -#[test] -fn hour_labels_wrap_at_midnight() { - assert_eq!([hour_label(22, 0), hour_label(22, 1), hour_label(22, 2), hour_label(22, 3)], [22, 23, 0, 1]); - assert_eq!(hour_label(23, 23), 22); -} - -#[test] -fn weekdays() { - assert_eq!(weekday(20_777), "Fri"); - assert_eq!(weekday(20_779), "Sun"); - assert_eq!(weekday(20_780), "Mon"); - assert_eq!(wall_min(2026, 11, 20, 13, 20), WALL); -} - -#[test] -fn icons_and_names() { - for (code, i, name) in [ - (0, Icon::Clear, "Clear"), (1, Icon::Partly, "Partly cloudy"), (2, Icon::Partly, "Partly cloudy"), - (3, Icon::Cloud, "Cloudy"), (45, Icon::Fog, "Fog"), (48, Icon::Fog, "Fog"), (55, Icon::Drizzle, "Drizzle"), - (63, Icon::Rain, "Rain"), (81, Icon::Rain, "Rain"), (73, Icon::Snow, "Snow"), (86, Icon::Snow, "Snow"), - (95, Icon::Storm, "Storm"), (99, Icon::Storm, "Storm"), (200, Icon::Cloud, "Cloudy"), - ] { - assert_eq!((icon(code), condition(code)), (i, name), "{code}"); - } -} - -#[test] -fn bars_stay_in_the_track() { - // (x, length) of a day's range within the week's, on a track 100 wide, at least 12 long - assert_eq!(bar(-9, 1, -9, 1, 100, 12), (0, 100)); - assert_eq!(bar(-5, 1, -9, 1, 100, 12), (40, 60)); - assert_eq!(bar(3, 3, 3, 3, 100, 12), (0, 100), "a week of one temperature"); - assert_eq!(bar(1, 1, -9, 1, 100, 12), (88, 12), "a point at the warm end keeps its length inside"); - assert_eq!(bar(-9, -9, -9, 1, 100, 12), (0, 12)); - for (min, max) in [(-128i8, 127i8), (5, -5), (0, 0)] { - let (x, len) = bar(min, max, -20, 20, 100, 12); - assert!(x >= 0 && len >= 12 && x + len <= 100, "{min}..{max}: {x}+{len}"); - } -} - -#[test] -fn updated_line() { - assert_eq!(updated(10).map(|l| l.as_str().len()), None); - assert_eq!(updated(45).map(|_| ()), None); - assert_eq!(updated(46).unwrap().as_str(), "Updated 46 min ago"); - assert_eq!(updated(190).unwrap().as_str(), "Updated 3 h ago"); - assert_eq!(updated(3 * 1440 + 5).unwrap().as_str(), "Updated 3 d ago"); - assert_eq!(updated(-500).map(|_| ()), None, "a clock set back"); -} - -#[test] -fn the_card() { - let m = Model::new(); - let (t, v) = m.card(WALL); - assert_eq!((t.as_str(), v.as_str()), ("Weather", "Open the app")); - let m = answered(&week()); - let (t, v) = m.card(WALL); - assert_eq!((t.as_str(), v.as_str()), ("Weather", "-3 Snow\nH 1 L -5")); - let m = answered_in(&week(), "Санкт-Петербург и область"); - let (t, v) = m.card(WALL); - assert!(t.as_str().len() <= 23 && t.as_str().starts_with("Санкт-Петер"), "{}", t.as_str()); - assert!(v.as_str().len() <= 39); - // no day for today: the first line alone - let m = answered(&[NOW.to_vec()]); - assert_eq!(m.card(WALL).1.as_str(), "-3 Snow"); -} - -#[test] -fn hours_and_days_count_from_the_phones_clock_not_the_watchs() { - // the phone answered in its 13th hour; the watch got it at 14:02: 13 is past, 14 is now - let at = 20_777 * 1440 + 14 * 60 + 2; - let m = answered_at(&week(), "", at); - assert_eq!(m.hours_len(at), 11); - assert_eq!(m.hour_at(0, at).map(|(h, n, x)| (h, n, x.temp)), Some((14, true, -3))); - // the other way: the phone is already in 14, the watch still at 13:59; nothing is past, 14 is not now yet - let at = 20_777 * 1440 + 13 * 60 + 59; - let mut v = week(); - v[1] = hours(14, 12); - let m = answered_at(&v, "", at); - assert_eq!(m.hours_len(at), 12); - assert_eq!(m.hour_at(0, at).map(|(h, n, _)| (h, n)), Some((14, false))); - assert_eq!(m.hour_at(0, at + 1).map(|(h, n, _)| (h, n)), Some((14, true))); - // midnight: the phone answered at 23:59 of the 20th, the watch got it at 00:01 of the 21st - let at = 20_778 * 1440 + 1; - let mut v = week(); - v[1] = hours(23, 12); - let m = answered_at(&v, "", at); - assert_eq!(m.day_at(0, at).map(|(d, today, x)| (d, today, x.min)), Some((20_778, true, -6)), "the phone's tomorrow"); - assert_eq!(m.days_len(at), 6); - assert_eq!(m.hour_at(0, at).map(|(h, n, _)| (h, n)), Some((0, true))); - // and it survives the cache - let mut blob = [0u8; BLOB_MAX]; - let n = m.save(&mut blob); - let mut back = Model::new(); - assert!(back.load(&blob[..n])); - assert_eq!(back.day_at(0, at), m.day_at(0, at)); - assert_eq!(back.hour_at(0, at), m.hour_at(0, at)); -} - -// The columns card. The phone pushes the same bytes (fmctools/companion): change neither side alone. - -/// The current weather, and hourly entries from `first` o'clock: (temperature, code). -fn forecast(temp: i16, code: u8, first: u8, list: &[(i8, u8)]) -> Vec> { - let t = temp.to_le_bytes(); - let mut h = Vec::from([2, first]); - for &(t, c) in list { - h.extend([t as u8, c, 0]); - } - Vec::from([Vec::from([0, t[0], t[1], code, 5, 80, 0]), h]) -} - -/// `recs` of [`forecast`] with the night bit in the hourly entries `which`. -fn at_night(mut recs: Vec>, which: std::ops::Range) -> Vec> { - for i in which { - recs[1][2 + 3 * i + 2] |= 0x80; - } - recs -} - -/// What stub 10 draws from the record at `wall`: caption, icon, value. Its own parser, with Weather's ten icons. -fn drawn(m: &Model, wall: i32) -> Vec<(std::string::String, Option, std::string::String)> { - let Some((rec, n)) = m.columns(wall) else { return Vec::new() }; - // the loader's and the stub's own check; and every icon is one the package has - assert!(wp2_core::widget::accepts(&rec[..n], 10), "stub 10 would not draw {:?}", &rec[..n]); - let cols = rec[3..n].chunks_exact(21); - assert!(cols.clone().all(|c| c[10] < 10), "no such icon in the package"); - cols.map(|c| (text(&c[..10]), Some(c[10]), text(&c[11..]))).collect() -} - -fn text(b: &[u8]) -> std::string::String { - core::str::from_utf8(b).unwrap().trim_end_matches('\0').into() -} - -fn at(day: i32, hour: i32, minute: i32) -> i32 { - day * 1440 + hour * 60 + minute -} - -fn captions(m: &Model, wall: i32) -> Vec { - drawn(m, wall).into_iter().map(|c| c.0).collect() -} - -#[test] -fn columns_golden_bytes() { - // wp2apps.install.columns_record([("Now",6,"-3°"),("23:00",2,"-4°"),("00:00",0,"-5°"),("01:00",7,"0°")]) - let golden = concat!( - "ff0104", - "4e6f7700000000000000", "06", "2d33c2b0000000000000", - "32333a30300000000000", "02", "2d34c2b0000000000000", - "30303a30300000000000", "00", "2d35c2b0000000000000", - "30313a30300000000000", "07", "30c2b000000000000000", - ); - let now = at(20_777, 22, 20); - let m = answered_at(&forecast(-34, 71, 22, &[(9, 1), (-4, 3), (-5, 0), (0, 95), (8, 45)]), "", now); - let (rec, n) = m.columns(now).expect("a card"); - let hex: std::string::String = rec[..n].iter().map(|b| std::format!("{b:02x}")).collect(); - assert_eq!((n, hex.as_str()), (87, golden)); -} - -#[test] -fn columns_golden_bytes_at_night() { - // wp2apps.install.columns_record([("Now",8,"-3°"),("23:00",9,"-4°"),("00:00",2,"-5°"),("01:00",7,"0°")]) - let golden = concat!( - "ff0104", - "4e6f7700000000000000", "08", "2d33c2b0000000000000", - "32333a30300000000000", "09", "2d34c2b0000000000000", - "30303a30300000000000", "02", "2d35c2b0000000000000", - "30313a30300000000000", "07", "30c2b000000000000000", - ); - let now = at(20_777, 22, 20); - let recs = at_night(forecast(-34, 0, 22, &[(9, 45), (-4, 2), (-5, 3), (0, 95), (8, 0)]), 0..5); - let m = answered_at(&recs, "", now); - let (rec, n) = m.columns(now).expect("a card"); - let hex: std::string::String = rec[..n].iter().map(|b| std::format!("{b:02x}")).collect(); - assert_eq!((n, hex.as_str()), (87, golden)); -} - -fn pictures(m: &Model, wall: i32) -> Vec> { - drawn(m, wall).into_iter().map(|c| c.1).collect() -} - -#[test] -fn night_turns_to_day_at_sunrise() { - // clear from 4 o'clock, night until 7 - let m = answered_at(&at_night(forecast(0, 0, 4, &[(0, 0); 8]), 0..3), "", at(20_777, 4, 10)); - assert_eq!(pictures(&m, at(20_777, 4, 10)), [Some(8), Some(8), Some(8), Some(0)]); - assert_eq!(pictures(&m, at(20_777, 6, 59)), [Some(8), Some(0), Some(0), Some(0)]); - assert_eq!(pictures(&m, at(20_777, 7, 0)), [Some(0); 4], "Now turns with the hour that contains it"); -} - -#[test] -fn night_goes_on_over_midnight() { - let list = [(0, 1), (0, 1), (0, 1), (0, 1), (0, 1), (0, 1)]; - let m = answered_at(&at_night(forecast(0, 1, 22, &list), 1..6), "", at(20_777, 22, 30)); - assert_eq!(pictures(&m, at(20_777, 22, 30)), [Some(1), Some(9), Some(9), Some(9)]); - assert_eq!(pictures(&m, at(20_778, 0, 0)), [Some(9); 4]); -} - -#[test] -fn now_is_day_without_an_hour_that_contains_it() { - let wall = at(20_777, 23, 59); - let m = answered_at(&at_night(forecast(0, 0, 0, &[(0, 0); 4]), 0..4), "", wall); - assert_eq!(pictures(&m, wall), [Some(0), Some(8), Some(8), Some(8)], "the phone's first hour is the next one"); - assert_eq!(pictures(&m, wall + 5 * 60), [Some(0)], "the hours ran out"); - assert_eq!(pictures(&answered(&[Vec::from([0, 0, 0, 0, 5, 80, 0])]), WALL), [Some(0)], "no hourly record"); -} - -#[test] -fn night_survives_the_cache() { - let mut recs = at_night(forecast(0, 2, 18, &[(0, 2); 8]), 2..8); - recs[1][2 + 3 * 3 + 2] |= 100; // the bit shares its byte with the chance of rain - let m = answered_at(&recs, "", at(20_777, 18, 5)); - let mut blob = [0u8; BLOB_MAX]; - let n = m.save(&mut blob); - let mut back = Model::new(); - assert!(back.load(&blob[..n])); - assert_eq!(pictures(&back, at(20_777, 19, 5)), [Some(1), Some(9), Some(9), Some(9)]); - assert_eq!(pictures(&back, at(20_777, 21, 5)), [Some(9); 4]); -} - -#[test] -fn columns_wrap_at_midnight_and_move_with_the_hour() { - let m = answered_at(&forecast(10, 0, 21, &[(0, 0); 12]), "", at(20_777, 21, 5)); - assert_eq!(captions(&m, at(20_777, 21, 59)), ["Now", "22:00", "23:00", "00:00"]); - assert_eq!(captions(&m, at(20_777, 22, 0)), ["Now", "23:00", "00:00", "01:00"]); - assert_eq!(captions(&m, at(20_778, 0, 0)), ["Now", "01:00", "02:00", "03:00"]); -} - -#[test] -fn columns_of_a_cache_skip_the_hours_that_passed() { - let list: Vec<(i8, u8)> = (0..12).map(|i| (i, 3)).collect(); - let m = answered(&forecast(216, 0, 13, &list)); - let mut blob = [0u8; BLOB_MAX]; - let n = m.save(&mut blob); - let mut back = Model::new(); - assert!(back.load(&blob[..n])); - let values = |wall| drawn(&back, wall).into_iter().map(|c| (c.0, c.2)).collect::>(); - let pairs = |p: &[(&str, &str)]| p.iter().map(|&(a, b)| (a.into(), b.into())).collect::>(); - // 19:20: the three after 19, not the three after the cache's first entry (13) - assert_eq!(values(WALL + 6 * 60), pairs(&[("Now", "22°"), ("20:00", "7°"), ("21:00", "8°"), ("22:00", "9°")])); - // 22:20: two are left, then none; two days later none come round again - assert_eq!(values(WALL + 9 * 60), pairs(&[("Now", "22°"), ("23:00", "10°"), ("00:00", "11°")])); - assert_eq!(values(WALL + 11 * 60), pairs(&[("Now", "22°")])); - assert_eq!(values(WALL + 2 * 1440), pairs(&[("Now", "22°")])); -} - -#[test] -fn columns_count_from_the_phones_hour() { - // the phone answered in its 13th hour, the watch got it at 14:02 - let wall = at(20_777, 14, 2); - let m = answered_at(&forecast(0, 0, 13, &[(1, 0), (2, 0), (3, 0), (4, 0), (5, 0)]), "", wall); - assert_eq!(captions(&m, wall), ["Now", "15:00", "16:00", "17:00"]); - assert_eq!(drawn(&m, wall)[1].2, "3°"); - // the phone is in 14 already, the watch at 13:59: 14 is the next hour - let wall = at(20_777, 13, 59); - let m = answered_at(&forecast(0, 0, 14, &[(4, 0), (5, 0), (6, 0), (7, 0)]), "", wall); - assert_eq!(captions(&m, wall), ["Now", "14:00", "15:00", "16:00"]); - // a clock set back: only those of the next three hours that are known - assert_eq!(captions(&m, wall - 60), ["Now", "14:00", "15:00"]); - assert_eq!(captions(&m, wall - 5 * 60), ["Now"]); -} - -#[test] -fn fewer_hours_give_fewer_columns_and_no_weather_none() { - for (known, want) in [(0, 1), (1, 1), (2, 2), (3, 3), (4, 4), (12, 4)] { - let m = answered(&forecast(0, 0, 13, &std::vec![(0, 0); known])); - assert_eq!(drawn(&m, WALL).len(), want, "{known} hours known"); - assert_eq!(m.columns(WALL).map(|r| r.1), Some(3 + 21 * want)); - } - assert_eq!(drawn(&answered(&[NOW.to_vec()]), WALL).len(), 1, "no hourly record"); - assert!(Model::new().columns(WALL).is_none(), "no current weather"); -} - -#[test] -fn column_values_round_away_from_zero() { - for (t10, want) in [ - (-35, "-4°"), (-34, "-3°"), (-5, "-1°"), (-4, "0°"), (0, "0°"), (4, "0°"), (5, "1°"), (25, "3°"), - (216, "22°"), (i16::MAX, "3277°"), (i16::MIN, "-3277°"), - ] { - assert_eq!(drawn(&answered(&forecast(t10, 0, 13, &[])), WALL)[0].2, want, "{t10}"); - } -} - -#[test] -fn column_icons_follow_the_contract_for_every_code() { - for code in 0..=255u8 { - let want = match code { - 0 => 0, - 1 | 2 => 1, - 45 | 48 => 3, - 51..=57 => 4, - 61..=67 | 80..=82 => 5, - 71..=77 | 85 | 86 => 6, - 95..=99 => 7, - _ => 2, - }; - let recs = forecast(0, code, 13, &[(0, 0), (0, code)]); - assert_eq!(pictures(&answered(&recs), WALL), [Some(want), Some(want)], "WMO {code}, Now and an hour"); - // only clear and partly cloudy have a night's drawing - let dark = match want { - 0 => 8, - 1 => 9, - i => i, - }; - let m = answered(&at_night(recs, 0..2)); - assert_eq!(pictures(&m, WALL), [Some(dark), Some(dark)], "WMO {code} at night"); - } -} - -#[test] -fn widget_icon_files_are_in_the_contracts_order() { - let dir = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("widget-icons"); - let mut names: Vec = std::fs::read_dir(dir) - .expect("widget-icons/") - .map(|e| e.unwrap().file_name().into_string().unwrap()) - .filter(|n| n.ends_with(".svg")) - .collect(); - names.sort(); - let want = ["clear", "partly", "cloud", "fog", "drizzle", "rain", "snow", "storm", "clear-night", "partly-night"]; - let want: Vec<_> = want.iter().enumerate().map(|(i, n)| std::format!("{i:02}-{n}.svg")).collect(); - assert_eq!(names, want, "the package numbers the icons in file name order"); -} - -/// The writes of one update: (is columns, the text card's value), the watch answering `rc` to columns. -fn writes(w: &mut Widget, m: &Model, wall: i32, rc: i32) -> Vec<(bool, std::string::String)> { - let mut out = Vec::new(); - w.update(m, wall, |card| match card { - Card::Columns(..) => { - out.push((true, "".into())); - rc - } - Card::Text(_, v) => { - out.push((false, v.as_str().into())); - 0 - } - }); - out -} - -#[test] -fn the_card_is_written_on_a_changed_record_only() { - let mut w = Widget::new(); - let wall = at(20_777, 13, 20); - assert_eq!(writes(&mut w, &Model::new(), wall, 0), [(false, "Open the app".into())], "no weather: the text card"); - let m = answered(&week()); - assert_eq!(writes(&mut w, &m, wall, 0), [(true, "".into())]); - for minute in [20, 21, 59] { - assert_eq!(writes(&mut w, &m, at(20_777, 13, minute), 0), [], "the same record"); - } - assert_eq!(writes(&mut w, &m, at(20_777, 14, 0), 0), [(true, "".into())], "the next hour"); -} - -#[test] -fn a_watch_without_columns_gets_the_text_card_and_is_not_asked_again() { - let mut w = Widget::new(); - let m = answered(&week()); - let text = (false, "-3 Snow\nH 1 L -5".into()); - assert_eq!(writes(&mut w, &m, WALL, -22), [(true, "".into()), text], "refused: the text card at once"); - assert_eq!(writes(&mut w, &m, WALL, -22), [], "the same text"); - assert_eq!(writes(&mut w, &m, WALL + 60, -22), [], "the next hour, the same text: no second try"); - let warmer = answered(&forecast(50, 0, 13, &[])); - assert_eq!(writes(&mut w, &warmer, WALL + 60, -22), [(false, "5 Clear".into())], "new text, still no second try"); -} - -#[test] -fn a_failed_write_is_written_again_and_is_no_reason_for_text() { - let mut w = Widget::new(); - let m = answered(&week()); - assert_eq!(writes(&mut w, &m, WALL, -5), [(true, "".into())]); - assert_eq!(writes(&mut w, &m, WALL, 0), [(true, "".into())]); - assert_eq!(writes(&mut w, &m, WALL, 0), []); -} - -#[test] -fn stub_9_refuses_the_card_and_stub_10_takes_it() { - // what the loader asks before it writes (op 0x14): stub 9 is the watch face guard, without templates - let m = answered(&week()); - let (rec, n) = m.columns(WALL).unwrap(); - assert!(wp2_core::widget::accepts(&rec[..n], 10)); - for stub in [8, 9] { - assert!(!wp2_core::widget::accepts(&rec[..n], stub), "stub {stub}"); - } - // so the app gets -22 there and writes the text card, which every stub takes - let mut w = Widget::new(); - let mut written = Vec::new(); - w.update(&m, WALL, |card| { - let rec = match card { - Card::Columns((r, n)) => r[..*n].to_vec(), - Card::Text(t, v) => cmf_wp2_app::widget_record(t.as_str(), v.as_str())[4..].to_vec(), - }; - written.push(rec.len()); - if wp2_core::widget::accepts(&rec, 9) { 0 } else { -22 } - }); - assert_eq!(written, [87, 64]); -} diff --git a/apps/weather/src/screen.rs b/apps/weather/src/screen.rs deleted file mode 100644 index 2845163..0000000 --- a/apps/weather/src/screen.rs +++ /dev/null @@ -1,393 +0,0 @@ -//! The screens, from the watch's own LVGL parts and stock fonts (`cmf_wp2_app::stock`): -//! - in the menu app, three pages in the stock vertical pager: now (place, temperature, condition, high and low, -//! wind and humidity), the next hours, the next days with a range bar each; -//! - on the page next to the watch face, the now screen alone; -//! - before the first answer, one line saying what is missing. -//! -//! LVGL here has no images, so a condition icon is two to four plain rounded objects: a disc for the sun, a pill -//! and a bump for a cloud, short pills for rain. Each screen is one root under `ROOT`; leaving it deletes the root -//! and everything in it. - -use crate::model::{self, Icon, Line, Model, Status}; -use cmf_wp2_app::lv::*; -use cmf_wp2_app::stock::{self, BLACK, CIRCLE, GREY, Pager, SCREEN, WHITE}; -use core::fmt::Write; - -/// Font slots: the system font is 0. -pub const F24: u8 = 1; -pub const F48: u8 = 2; - -const SUN: i32 = 0xFE60; // #FFCC00 -const MOON: i32 = 0xE73D; // #E5E5EA -const CLOUD: i32 = 0xD69A; // #D1D1D6 -const STORM: i32 = 0x8C72; // #8E8E93 -const WET: i32 = 0x669F; // #64D2FF -const TRACK: i32 = 0x39C7; // #3A3A3C - -const MSG_W: i32 = 300; -/// The top of the now screen's content: the place; the rest hangs below it. -const NOW_Y: i32 = 92; -/// The first row of the hours and days pages, and their rows' height. -const ROWS_Y: i32 = 96; -const HOUR_H: i32 = 58; -const DAY_H: i32 = 54; -/// The range bar's track. -const BAR_W: i16 = 70; -const BAR_H: i16 = 8; - -// bytes one row with its icon can take: flush first when fewer are left -const GROUP: usize = 760; - -pub type Flush<'a> = dyn FnMut(&mut Batch) -> Result<(), LvError> + 'a; - -/// Flushes unless a group of records still fits: called before each one, and none is longer than GROUP (the -/// tests build the views from every fill level). -fn room(b: &mut Batch, flush: &mut Flush) -> Result<(), LvError> { - if b.bytes().len() + GROUP > BUF { flush(b) } else { Ok(()) } -} - -/// The fonts, in a batch of their own. -pub fn fonts(b: &mut Batch) -> Result<(), LvError> { - stock::font(b)?; - b.font(F24, StockFont::F24M)?; - b.font(F48, StockFont::F48M) -} - -/// Black behind everything, the system font and white text: first, once. -pub fn theme(b: &mut Batch) -> Result<(), LvError> { - stock::theme(b)?; - b.style(ROOT, Prop::BgColor, 0, BLACK) -} - -/// What to say instead of the weather while there is none to show. -pub fn message(m: &Model) -> &'static str { - match m.status { - Status::Ask => "Allow Weather in FMC Companion on your phone", - Status::Denied => "Turn Weather on in FMC Companion", - Status::Unavailable => "No weather right now", - _ if m.silent() => "Open FMC Companion on your phone", - _ => "Asking your phone...", - } -} - -/// A line under the weather from the cache, when the phone isn't giving a fresh one. -pub fn note(m: &Model, wall: i32) -> Option { - let fixed = match m.status { - Status::Ask => Some("Allow Weather in FMC Companion"), - Status::Denied => Some("Weather is off in FMC Companion"), - _ if m.silent() => Some("Phone not reachable"), - _ => None, - }; - match fixed { - Some(t) => { - let mut l = Line::new(); - let _ = l.write_str(t); - Some(l) - } - None => model::updated(m.stale_min(wall)), - } -} - -/// The range bar's colour for a day, by the middle of its range: cold blue to hot red. -pub fn bar_color(min: i8, max: i8) -> i32 { - match (min as i32 + max as i32).div_euclid(2) { - ..0 => 0x351F, // #30A0FF - ..10 => 0x5EDC, // #5AD8E6 - ..18 => 0x9F09, // #9BE04A - ..25 => SUN, - ..32 => 0xFCA0, // #FF9500 - _ => 0xFA27, // #FF453A - } -} - -fn plain(b: &mut Batch, o: Obj) -> Result<(), LvError> { - for p in [Prop::PadTop, Prop::PadBottom, Prop::PadLeft, Prop::PadRight, Prop::BorderWidth, Prop::BgOpa, Prop::Radius] { - b.style(o, p, 0, 0)?; - } - Ok(()) -} - -/// A full-screen root, hidden until the screen is built. -fn root(b: &mut Batch) -> Result { - let r = b.create(Class::Obj, ROOT)?; - b.size(r, SCREEN, SCREEN)?; - plain(b, r)?; - b.flags(r, &[Flag::Hidden], &[Flag::Scrollable])?; - Ok(r) -} - -/// A label `w` wide whose centre is `cx` right of the parent's and whose top is at `y`; `align` 1 left, 2 centre, -/// 3 right. -fn label(b: &mut Batch, parent: Obj, text: &str, w: i32, cx: i32, y: i32, align: i32) -> Result { - let l = b.create(Class::Label, parent)?; - b.size(l, w, CONTENT)?; - b.style(l, Prop::TextAlign, 0, align)?; - b.text(l, text)?; - b.align(l, Align::TopMid, cx as i16, y as i16)?; - Ok(l) -} - -fn small(b: &mut Batch, l: Obj, color: i32) -> Result<(), LvError> { - b.style(l, Prop::TextFont, 0, F24 as i32)?; - b.style(l, Prop::TextColor, 0, color) -} - -/// A filled rounded shape, centre `cx` right of the parent's, top at `y`. -fn shape(b: &mut Batch, parent: Obj, cx: i32, y: i32, w: i32, h: i32, color: i32) -> Result { - let o = b.create(Class::Obj, parent)?; - b.size(o, w, h)?; - b.style(o, Prop::Radius, 0, CIRCLE)?; - b.style(o, Prop::BorderWidth, 0, 0)?; - b.style(o, Prop::BgColor, 0, color)?; - b.style(o, Prop::BgOpa, 0, 255)?; - b.flags(o, &[], &[Flag::Clickable, Flag::Scrollable])?; - b.align(o, Align::TopMid, cx as i16, y as i16)?; - Ok(o) -} - -/// A condition icon in a box 48 wide and 40 high at scale `s`/40, centred at `cx`, top at `y`: at most four -/// objects. It sits on black: the moon's bite is a black disc. -pub fn icon(b: &mut Batch, parent: Obj, kind: Icon, night: bool, cx: i32, y: i32, s: i32) -> Result<(), LvError> { - let u = |n: i32| n * s / 40; - let disc = |b: &mut Batch, dx: i32, dy: i32, d: i32, color: i32| shape(b, parent, cx + u(dx), y + u(dy), u(d), u(d), color).map(|_| ()); - // a cloud whose top is `dy` down the box - let cloud = |b: &mut Batch, dy: i32, color: i32| -> Result<(), LvError> { - shape(b, parent, cx - u(5), y + u(dy), u(22), u(22), color)?; - shape(b, parent, cx, y + u(dy + 10), u(40), u(18), color).map(|_| ()) - }; - // what falls from a cloud at the top of the box - let fall = |b: &mut Batch, w: i32, h: i32, color: i32| -> Result<(), LvError> { - shape(b, parent, cx - u(8), y + u(31), u(w), u(h), color)?; - shape(b, parent, cx + u(8), y + u(31), u(w), u(h), color).map(|_| ()) - }; - match kind { - Icon::Clear if night => { - disc(b, 0, 7, 26, MOON)?; - disc(b, 8, 3, 22, BLACK) - } - Icon::Clear => disc(b, 0, 6, 28, SUN), - Icon::Partly => { - disc(b, 10, 2, 20, if night { MOON } else { SUN })?; - cloud(b, 8, CLOUD) - } - Icon::Cloud => cloud(b, 6, CLOUD), - Icon::Fog => { - for dy in [8, 18, 28] { - shape(b, parent, cx, y + u(dy), u(40), u(5), STORM)?; - } - Ok(()) - } - Icon::Drizzle => { - cloud(b, 2, CLOUD)?; - fall(b, 4, 5, WET) - } - Icon::Rain => { - cloud(b, 2, CLOUD)?; - fall(b, 4, 9, WET) - } - Icon::Snow => { - cloud(b, 2, CLOUD)?; - fall(b, 6, 6, WHITE) - } - Icon::Storm => { - cloud(b, 2, STORM)?; - shape(b, parent, cx, y + u(30), u(6), u(10), SUN).map(|_| ()) - } - } -} - -/// The now screen's content, into a full-screen `parent`. -fn now_content(b: &mut Batch, flush: &mut Flush, parent: Obj, m: &Model, wall: i32) -> Result<(), LvError> { - let Some(n) = m.now else { return Ok(()) }; - room(b, flush)?; - if !m.place().is_empty() { - let l = label(b, parent, m.place(), MSG_W, 0, NOW_Y, 2)?; - b.long_mode(l, LongMode::Dot)?; - small(b, l, GREY)?; - } - // the temperature and, since the fonts have no degree sign, a ring after it: a row as wide as the two, moved - // right by half the ring so the number stays in the middle - room(b, flush)?; - let row = b.create(Class::Obj, parent)?; - b.size(row, CONTENT, CONTENT)?; - plain(b, row)?; - b.flags(row, &[], &[Flag::Clickable, Flag::Scrollable])?; - b.flex(row, Flow::Row, FlexAlign::Start, FlexAlign::Start, FlexAlign::Start)?; - b.style(row, Prop::PadColumn, 0, 4)?; - b.align(row, Align::TopMid, 9, (NOW_Y + 36) as i16)?; - let t = b.create(Class::Label, row)?; - b.text(t, model::temp_text(model::deg(n.temp)).as_str())?; - b.style(t, Prop::TextFont, 0, F48 as i32)?; - let ring = b.create(Class::Obj, row)?; - b.size(ring, 14, 14)?; - b.style(ring, Prop::Radius, 0, CIRCLE)?; - b.style(ring, Prop::BgOpa, 0, 0)?; - b.style(ring, Prop::BorderWidth, 0, 3)?; - b.style(ring, Prop::BorderColor, 0, WHITE)?; - b.style(ring, Prop::TranslateY, 0, 8)?; - b.flags(ring, &[], &[Flag::Clickable, Flag::Scrollable])?; - room(b, flush)?; - icon(b, parent, model::icon(n.code), m.night_now(wall), 0, NOW_Y + 98, 52)?; - room(b, flush)?; - label(b, parent, model::condition(n.code), MSG_W, 0, NOW_Y + 158, 2)?; - let mut y = NOW_Y + 204; - if let Some(d) = m.today(wall) { - let mut l = Line::new(); - let _ = write!(l, "H:{} L:{}", model::temp_text(d.max as i16).as_str(), model::temp_text(d.min as i16).as_str()); - let h = label(b, parent, l.as_str(), MSG_W, 0, y, 2)?; - small(b, h, WHITE)?; - y += 36; - } - let mut l = Line::new(); - let _ = write!(l, "{} m/s {}%", n.wind, n.humidity); - let w = label(b, parent, l.as_str(), MSG_W, 0, y, 2)?; - small(b, w, GREY)?; - if let Some(t) = note(m, wall) { - let l = label(b, parent, t.as_str(), 280, 0, y + 36, 2)?; - small(b, l, GREY)?; - b.long_mode(l, LongMode::Wrap)?; - } - Ok(()) -} - -/// A grey line in the middle of a page that has nothing else. -fn empty(b: &mut Batch, parent: Obj, text: &str) -> Result<(), LvError> { - let l = label(b, parent, text, MSG_W, 0, 180, 2)?; - b.style(l, Prop::TextColor, 0, GREY)?; - b.long_mode(l, LongMode::Wrap) -} - -/// What the hours page says without hours. -pub fn no_hours_text(m: &Model) -> &'static str { - if m.no_hours { "Update FMC Companion for the hourly forecast" } else { "No hours to show yet" } -} - -fn hours_content(b: &mut Batch, flush: &mut Flush, page: Obj, m: &Model, wall: i32) -> Result<(), LvError> { - let n = m.hours_len(wall).min(model::ASK_HOURS as usize); - if n == 0 { - room(b, flush)?; - return empty(b, page, no_hours_text(m)); - } - for k in 0..n { - let Some((hod, is_now, h)) = m.hour_at(k, wall) else { break }; - room(b, flush)?; - let y = ROWS_Y + k as i32 * HOUR_H; - let mut l = Line::new(); - let _ = if is_now { l.write_str("Now") } else { write!(l, "{hod:02}") }; - let t = label(b, page, l.as_str(), 80, -110, y + 8, 1)?; - if !is_now { - b.style(t, Prop::TextColor, 0, GREY)?; - } - icon(b, page, model::icon(h.code), h.night, -22, y + 6, 40)?; - if h.precip >= 30 { - let mut l = Line::new(); - let _ = write!(l, "{}%", h.precip); - let p = label(b, page, l.as_str(), 64, 42, y + 14, 2)?; - small(b, p, WET)?; - } - label(b, page, model::temp_text(h.temp as i16).as_str(), 80, 110, y + 8, 3)?; - } - b.style(page, Prop::PadBottom, 0, 130) // the last row can scroll up clear of the round edge -} - -fn days_content(b: &mut Batch, flush: &mut Flush, page: Obj, m: &Model, wall: i32) -> Result<(), LvError> { - let n = m.days_len(wall); - if n == 0 { - room(b, flush)?; - return empty(b, page, "No forecast to show yet"); - } - let (lo, hi) = m.range(wall); - for k in 0..n { - let Some((abs, today, d)) = m.day_at(k, wall) else { break }; - room(b, flush)?; - let y = ROWS_Y + k as i32 * DAY_H; - label(b, page, if today { "Today" } else { model::weekday(abs) }, 96, -112, y + 6, 1)?; - icon(b, page, model::icon(d.code), false, -34, y + 4, 40)?; - let lo_l = label(b, page, model::temp_text(d.min as i16).as_str(), 56, 6, y + 12, 3)?; - small(b, lo_l, GREY)?; - room(b, flush)?; - let track = shape(b, page, 73, y + 22, BAR_W as i32, BAR_H as i32, TRACK)?; - b.style(track, Prop::PadLeft, 0, 0)?; - let (x, len) = model::bar(d.min, d.max, lo, hi, BAR_W, BAR_H); - let seg = b.create(Class::Obj, track)?; - b.size(seg, len as i32, BAR_H as i32)?; - b.style(seg, Prop::Radius, 0, CIRCLE)?; - b.style(seg, Prop::BorderWidth, 0, 0)?; - b.style(seg, Prop::BgColor, 0, bar_color(d.min, d.max))?; - b.style(seg, Prop::BgOpa, 0, 255)?; - b.flags(seg, &[], &[Flag::Clickable, Flag::Scrollable])?; - b.align(seg, Align::LeftMid, x, 0)?; - let hi_l = label(b, page, model::temp_text(d.max as i16).as_str(), 56, 138, y + 12, 3)?; - small(b, hi_l, WHITE)?; - } - b.style(page, Prop::PadBottom, 0, 130) -} - -/// A screen: its root, and the pager when it has pages. -#[derive(Clone, Copy)] -pub struct View { - pub root: Obj, - pub pager: Option>, - /// The stock round scroll bar of each page that scrolls (hours, days); `ROOT` for the rest. - pub bars: [Obj; 3], -} - - -/// One line in the middle of the screen. -pub fn message_view(b: &mut Batch, flush: &mut Flush, text: &str) -> Result { - room(b, flush)?; - let r = root(b)?; - let l = label(b, r, text, MSG_W, 0, 170, 2)?; - b.style(l, Prop::TextColor, 0, GREY)?; - b.long_mode(l, LongMode::Wrap)?; - b.flags(r, &[], &[Flag::Hidden])?; - Ok(View { root: r, pager: None, bars: [ROOT; 3] }) -} - -/// The menu app: now, hours, days, opened on `page`. -pub fn pages_view(b: &mut Batch, flush: &mut Flush, m: &Model, wall: i32, page: usize) -> Result { - if m.now.is_none() { - return message_view(b, flush, message(m)); - } - room(b, flush)?; - let mut p = stock::pager::<3>(b, 3)?; - b.flags(p.root, &[Flag::Hidden], &[])?; - now_content(b, flush, p.pages[0], m, wall)?; - hours_content(b, flush, p.pages[1], m, wall)?; - days_content(b, flush, p.pages[2], m, wall)?; - room(b, flush)?; - let mut bars = [ROOT; 3]; - for i in 1..3 { - bars[i] = b.scroll_bar(p.pages[i])?; - } - // a scroll bar takes the crown for its list, which then never pages on at its end: the pager keeps it, scrolls - // the page first and pages at its end, and the bar shows while the page scrolls - b.knob(p.obj)?; - let page = page.min(2); - if page > 0 { - p.jump(b, page)?; - } - b.flags(p.root, &[], &[Flag::Hidden])?; - Ok(View { root: p.root, pager: Some(p), bars }) -} - -/// The page next to the watch face: the now screen alone. -pub fn face_view(b: &mut Batch, flush: &mut Flush, m: &Model, wall: i32) -> Result { - if m.now.is_none() { - return message_view(b, flush, message(m)); - } - room(b, flush)?; - let r = root(b)?; - now_content(b, flush, r, m, wall)?; - b.flags(r, &[], &[Flag::Hidden])?; - Ok(View { root: r, pager: None, bars: [ROOT; 3] }) -} - -/// Deletes a screen. -pub fn leave(b: &mut Batch, root: Obj) -> Result<(), LvError> { - if root != ROOT { b.del(root) } else { Ok(()) } -} - -#[cfg(test)] -#[path = "screen_tests.rs"] -mod tests; diff --git a/apps/weather/src/screen_tests.rs b/apps/weather/src/screen_tests.rs deleted file mode 100644 index 58f5936..0000000 --- a/apps/weather/src/screen_tests.rs +++ /dev/null @@ -1,256 +0,0 @@ -extern crate std; -use super::*; -use companion_rpc as rpc; -use std::boxed::Box; -use std::vec::Vec; -use wp2_core::lvcmd::{self, Table}; - -// 2026-11-20 13:20 -const WALL: i32 = 20_777 * 1440 + 13 * 60 + 20; -const FONTS: u8 = 0b111; - -fn batch() -> Batch { - Batch::with_buf(Box::leak(Box::new([0; BUF]))) -} - -/// Runs `build` with a flush that validates each batch against the loader's table and applies it; returns the -/// result and the batches' sizes. -fn run(t: &mut Table, b: &mut Batch, build: impl FnOnce(&mut Batch, &mut Flush) -> Result) -> (T, Vec) { - let sizes = std::cell::RefCell::new(Vec::new()); - let mut flush = |b: &mut Batch| -> Result<(), LvError> { - assert_eq!(lvcmd::validate(b.bytes(), t, FONTS), Ok(())); - for r in lvcmd::records(b.bytes()) { - lvcmd::apply(t, &r.unwrap()); - } - sizes.borrow_mut().push(b.bytes().len()); - b.clear(); - Ok(()) - }; - let out = build(b, &mut flush).unwrap(); - flush(b).unwrap(); - (out, sizes.into_inner()) -} - -fn msg(id: u8, status: u8, index: u8, total: u8, record: &[u8]) -> Vec { - [&b"R1A"[..], &[id, status, index, total], record].concat() -} - -/// A model the phone answered with `recs` at WALL, in "Санкт-Петербург". -fn answered(recs: &[Vec]) -> Model { - let mut m = Model::new(); - m.ask_now(0); - while let Some(q) = m.poll(0) { - if q[4] == 0x20 { - m.reply(&msg(q[3], 0, 0, 1, &[&[0u8; 6][..], "Санкт-Петербург".as_bytes()].concat()), 10, WALL); - } else { - for (i, r) in recs.iter().enumerate() { - m.reply(&msg(q[3], 0, i as u8, recs.len() as u8, r), 10, WALL); - } - } - } - m -} - -/// Every hour and day with `code`, the hours at night with rain likely: the most objects a code can cost. -fn full(code: u8, hours: usize, days: i8) -> Model { - let mut v = Vec::from([[0, 0x38, 0xFF, code, 12, 100, 200].to_vec()]); // -20.0° - if hours > 0 { - let mut h = Vec::from([2, 13]); - for _ in 0..hours { - h.extend([(-128i8) as u8, code, 0x80 | 100]); - } - v.push(h); - } - for d in 0..days { - v.push([1, d as u8, (-128i8) as u8, 127, code, 100].to_vec()); - } - answered(&v) -} - -fn live(t: &Table) -> usize { - (0..lvcmd::MAX_OBJS as u16).filter(|&h| t.class(h).is_some()).count() -} - -#[test] -fn fonts_validate_on_their_own() { - let mut b = batch(); - fonts(&mut b).unwrap(); - assert_eq!(lvcmd::validate(b.bytes(), &Table::new(), 0), Ok(())); -} - -#[test] -fn every_icon_builds_within_four_objects() { - for kind in [Icon::Clear, Icon::Partly, Icon::Cloud, Icon::Fog, Icon::Drizzle, Icon::Rain, Icon::Snow, Icon::Storm] { - for night in [false, true] { - let mut t = Table::new(); - let mut b = batch(); - run(&mut t, &mut b, |b, _| { - theme(b)?; - icon(b, ROOT, kind, night, 0, 0, 40) - }); - let n = live(&t) - 1; // the root - assert!((1..=4).contains(&n), "{kind:?} night {night}: {n}"); - } - } -} - -#[test] -fn the_pages_validate_within_the_budgets_and_free_everything() { - // every WMO group, with all 12 hours and 7 days, then the short and empty shapes - let mut models = Vec::new(); - for code in [0, 2, 3, 45, 55, 63, 73, 95] { - models.push(full(code, 24, 7)); - } - models.extend([full(63, 0, 7), full(63, 5, 0), full(63, 0, 0), full(63, 1, 1)]); - for m in &models { - let mut t = Table::new(); - let mut b = batch(); - let before = { - run(&mut t, &mut b, |b, _| theme(b)); - live(&t) - }; - for page in 0..3 { - let (v, sizes) = run(&mut t, &mut b, |b, f| pages_view(b, f, m, WALL, page)); - assert!(sizes.iter().all(|&s| s <= BUF)); - let p = v.pager.expect("pages"); - assert_eq!((p.at, p.n), (page, 3)); - assert_eq!(v.bars[0], ROOT, "now has no scroll bar"); - for bar in &v.bars[1..] { - assert_eq!(t.class(bar.0), Some(lvcmd::Class::ScrollBar)); - } - assert!(live(&t) <= lvcmd::MAX_OBJS, "{} objects", live(&t)); - std::println!("page {page}: {} objects, batches {sizes:?}", live(&t)); - // leaving frees every handle - run(&mut t, &mut b, |b, _| leave(b, v.root)); - assert_eq!(live(&t), before); - } - let (v, _) = run(&mut t, &mut b, |b, f| face_view(b, f, m, WALL)); - assert!(v.pager.is_none()); - run(&mut t, &mut b, |b, _| leave(b, v.root)); - assert_eq!(live(&t), before); - } -} - -#[test] -fn a_stale_cache_still_builds() { - // three days later: no hours left, four days left, "Updated 3 d ago" - let m = full(63, 12, 7); - let later = WALL + 3 * 1440; - let mut t = Table::new(); - let mut b = batch(); - run(&mut t, &mut b, |b, f| { - theme(b)?; - pages_view(b, f, &m, later, 1) - }); - assert_eq!(note(&m, later).unwrap().as_str(), "Updated 3 d ago"); - assert_eq!((m.hours_len(later), m.days_len(later)), (0, 4)); -} - -#[test] -fn without_weather_it_says_why() { - let mut m = Model::new(); - assert_eq!(message(&m), "Asking your phone..."); - for (s, want) in [ - (rpc::ASK, "Allow Weather in FMC Companion on your phone"), - (rpc::DENIED, "Turn Weather on in FMC Companion"), - (rpc::UNAVAILABLE, "No weather right now"), - ] { - m.ask_now(0); - while let Some(q) = m.poll(0) { - if q[4] == 0x30 { - m.reply(&msg(q[3], s, 0, 0, &[]), 10, WALL); - } - } - assert_eq!(message(&m), want); - } - // the phone never answers: after the first retry it is told what to open - let mut m = Model::new(); - m.ask_now(0); - while m.poll(0).is_some() {} - while m.poll(10_000).is_some() {} - assert_eq!(message(&m), "Open FMC Companion on your phone"); - let mut t = Table::new(); - let mut b = batch(); - for build in [pages_view as fn(&mut Batch, &mut Flush, &Model, i32, usize) -> Result] { - let (v, _) = run(&mut t, &mut b, |b, f| { - theme(b)?; - build(b, f, &m, WALL, 0) - }); - assert!(v.pager.is_none()); - } - let (v, _) = run(&mut t, &mut b, |b, f| face_view(b, f, &m, WALL)); - assert!(v.pager.is_none()); -} - -#[test] -fn notes_and_empty_pages() { - let m = full(63, 0, 7); - assert!(m.no_hours); - assert_eq!(no_hours_text(&m), "Update FMC Companion for the hourly forecast"); - assert_eq!(note(&m, WALL).unwrap().as_str(), "Updated 200 min ago".replace("200 min", "3 h")); - let m = full(63, 12, 7); - assert_eq!(no_hours_text(&m), "No hours to show yet"); -} - -#[test] -fn bar_colours_run_cold_to_hot() { - let c = [(-20, -10), (-2, 6), (8, 14), (15, 25), (22, 30), (30, 40)].map(|(a, b)| bar_color(a, b)); - for i in 0..c.len() { - for j in 0..i { - assert_ne!(c[i], c[j]); - } - } - assert_eq!(bar_color(-128, -128), c[0]); - assert_eq!(bar_color(127, 127), c[5]); -} - -/// What the emulator's fake phone answers: mixed hours and days, in "Berlin" (the pager came out black there). -fn mixed(hour0: u8) -> Model { - let hours = [(-3, 2, 10, 0), (-3, 2, 10, 0), (-4, 3, 20, 0), (-4, 3, 30, 0), (-5, 71, 60, 1), (-5, 71, 70, 1), - (-6, 73, 80, 1), (-6, 3, 20, 1), (-6, 0, 0, 1), (-5, 0, 0, 1), (-4, 1, 10, 1), (-3, 61, 40, 1)]; - let days = [(-6, -2, 2, 20), (-8, -3, 71, 70), (-4, 1, 3, 30), (0, 5, 61, 80), (2, 8, 1, 10), (4, 11, 0, 0), (-1, 6, 95, 60)]; - let mut v = Vec::from([[0, 0xDE, 0xFF, 2, 5, 78, 3].to_vec()]); - let mut h = Vec::from([2, hour0]); - for (t, code, p, night) in hours { - h.extend([t as i8 as u8, code, p | night << 7]); - } - v.push(h); - for (d, (lo, hi, code, p)) in days.iter().enumerate() { - v.push([1, d as u8, *lo as i8 as u8, *hi as i8 as u8, *code, *p].to_vec()); - } - answered(&v) -} - -/// A view is built into whatever the batch already holds, so no group of records may be longer than the room -/// asked for before it: every fill level the batch can start at, every icon. -#[test] -fn the_views_build_from_any_fill_level() { - let mut models = Vec::from([mixed(22), mixed(9)]); - for code in [0, 2, 3, 45, 55, 63, 73, 95] { - models.push(full(code, 12, 7)); - } - for (i, m) in models.iter().enumerate() { - for fill in 0..200 { - let mut t = Table::new(); - let mut b = batch(); - let mut flush = |b: &mut Batch| -> Result<(), LvError> { - assert_eq!(lvcmd::validate(b.bytes(), &t, FONTS), Ok(())); - for r in lvcmd::records(b.bytes()) { - lvcmd::apply(&mut t, &r.unwrap()); - } - b.clear(); - Ok(()) - }; - for _ in 0..fill { - if b.style(ROOT, Prop::BgColor, 0, BLACK).is_err() { - break; // full to the brim is a fill level too - } - } - let at = b.bytes().len(); - let r = pages_view(&mut b, &mut flush, m, WALL, 0).map(|_| ()); - assert_eq!(r, Ok(()), "model {i}, {at} bytes in the batch"); - let r = face_view(&mut b, &mut flush, m, WALL).map(|_| ()); - assert_eq!(r, Ok(()), "model {i}, the face page"); - } - } -} diff --git a/apps/weather/store.md b/apps/weather/store.md deleted file mode 100644 index dd6615f..0000000 --- a/apps/weather/store.md +++ /dev/null @@ -1,25 +0,0 @@ -The weather where your phone is, in three pages you turn with the crown or a swipe: - -- **Now**: the place, the temperature, the condition, today's high and low, wind and humidity. -- **Hours**: the next 12 hours with the temperature and, when it is likely, the chance of rain or snow. -- **Days**: the week ahead, each day with its low, its high and a bar that shows where they sit in the week. - -Long-press **Weather** in Apps and choose **Add page** to keep the Now screen one swipe from the watch face, or -**Add widget** for a card by the hour: now and the next three hours, each with its icon (a moon at night) and -temperature. On patched firmware from before stub 10 the card shows the temperature, the condition and today's high -and low in text instead. The app brings the card up to date while it runs. - -The watch asks the phone when you open the app and every 15 minutes while it's shown, and keeps the last answer, so -it opens at once without the phone and says how old the weather is. Temperatures are in °C. - -The first time, the watch says "Allow Weather in FMC Companion on your phone": open FMC Companion, Apps, Weather, and -allow it (the phone then asks for your location). The watch gets the weather and the name of the place, never where -you are. - -## Requirements - -- A phone with **FMC Companion** (iOS or Android), paired with the watch. The hours need FMC Companion from - 2026-11-20 or later; with an older one the Hours page asks you to update it and the rest works. -- The [patched firmware](/firmware) with the channel key (2026-11-13 or later) and the [App Loader](/firmware) - (2026-11-15 or later for the page and the widget). The card by the hour needs the patched firmware's stub 10 and - the App Loader that comes with it. diff --git a/apps/weather/store.toml b/apps/weather/store.toml deleted file mode 100644 index 9732e39..0000000 --- a/apps/weather/store.toml +++ /dev/null @@ -1,6 +0,0 @@ -# The app's listing in the FMC store (README.md, "store.toml"). The page's body is store.md. -name = "Weather" -summary = "Now, the next hours and the week ahead where you are, with a page next to the watch face and a widget card" -version = "0.2.0" -author = "Egor Kolesnikov" -screenshots = ["shots/now.png", "shots/hours.png", "shots/days.png", "shots/card.png"] diff --git a/apps/weather/widget-icons/00-clear.svg b/apps/weather/widget-icons/00-clear.svg deleted file mode 100644 index 3491cc3..0000000 --- a/apps/weather/widget-icons/00-clear.svg +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/apps/weather/widget-icons/01-partly.svg b/apps/weather/widget-icons/01-partly.svg deleted file mode 100644 index 3a5e07f..0000000 --- a/apps/weather/widget-icons/01-partly.svg +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/apps/weather/widget-icons/02-cloud.svg b/apps/weather/widget-icons/02-cloud.svg deleted file mode 100644 index ec9871a..0000000 --- a/apps/weather/widget-icons/02-cloud.svg +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/apps/weather/widget-icons/03-fog.svg b/apps/weather/widget-icons/03-fog.svg deleted file mode 100644 index d16dab4..0000000 --- a/apps/weather/widget-icons/03-fog.svg +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/apps/weather/widget-icons/04-drizzle.svg b/apps/weather/widget-icons/04-drizzle.svg deleted file mode 100644 index 716b6c7..0000000 --- a/apps/weather/widget-icons/04-drizzle.svg +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/apps/weather/widget-icons/05-rain.svg b/apps/weather/widget-icons/05-rain.svg deleted file mode 100644 index defdd15..0000000 --- a/apps/weather/widget-icons/05-rain.svg +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/apps/weather/widget-icons/06-snow.svg b/apps/weather/widget-icons/06-snow.svg deleted file mode 100644 index 44b9938..0000000 --- a/apps/weather/widget-icons/06-snow.svg +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/apps/weather/widget-icons/07-storm.svg b/apps/weather/widget-icons/07-storm.svg deleted file mode 100644 index 2332a08..0000000 --- a/apps/weather/widget-icons/07-storm.svg +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/apps/weather/widget-icons/08-clear-night.svg b/apps/weather/widget-icons/08-clear-night.svg deleted file mode 100644 index 0b3baa8..0000000 --- a/apps/weather/widget-icons/08-clear-night.svg +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/apps/weather/widget-icons/09-partly-night.svg b/apps/weather/widget-icons/09-partly-night.svg deleted file mode 100644 index 5ec3479..0000000 --- a/apps/weather/widget-icons/09-partly-night.svg +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/apps/wrist-doom/Cargo.toml b/apps/wrist-doom/Cargo.toml deleted file mode 100644 index 8f89be0..0000000 --- a/apps/wrist-doom/Cargo.toml +++ /dev/null @@ -1,12 +0,0 @@ -[package] -name = "wrist-doom" -edition.workspace = true -license.workspace = true -version.workspace = true - -[dependencies] -cmf-wp2-app.workspace = true - -[[bin]] -name = "wrist-doom" -bench = false diff --git a/apps/wrist-doom/icon.svg b/apps/wrist-doom/icon.svg deleted file mode 100644 index f42f698..0000000 --- a/apps/wrist-doom/icon.svg +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - -AAAWgmp1bWIAAAAeanVtZGMycGEAEQAQgAAAqgA4m3EDYzJwYQAAABZcanVtYgAAAEdqdW1kYzJtYQARABCAAACqADibcQN1cm46YzJwYTowMGI4MmMxZS0wNTA1LTQ1OTItODBkZS04NWUzMDkzNzg2MTkAAAADl2p1bWIAAAApanVtZGMyYXMAEQAQgAAAqgA4m3EDYzJwYS5hc3NlcnRpb25zAAAAALxqdW1iAAAARGp1bWRjYm9yABEAEIAAAKoAOJtxE2MycGEuaW5ncmVkaWVudC52MwAAAAAYYzJzaJSiR59ugfH4IeqNjHreycgAAABwY2JvcqNpZGM6Zm9ybWF0bWltYWdlL3N2Zyt4bWxqaW5zdGFuY2VJRHgseG1wOmlpZDo3OTBlNGNkMC01ZjI4LTQyNzAtYWM0YS04ZmEyMDdlNzdjY2JscmVsYXRpb25zaGlwaHBhcmVudE9mAAAB4mp1bWIAAABBanVtZGNib3IAEQAQgAAAqgA4m3ETYzJwYS5hY3Rpb25zLnYyAAAAABhjMnNogG2heN2xlcHmlb8I+0xMqAAAAZljYm9yomdhY3Rpb25zgqJmYWN0aW9ua2MycGEub3BlbmVkanBhcmFtZXRlcnOha2luZ3JlZGllbnRzgaJjdXJseC1zZWxmI2p1bWJmPWMycGEuYXNzZXJ0aW9ucy9jMnBhLmluZ3JlZGllbnQudjNkaGFzaFggV4BPIa9A1YkADMahEkM8ViDUShJN139m8dybNoGrUiKkZmFjdGlvbngdY29tLmFudGhyb3BpYy5jbGF1ZGUucHJvdmlkZWRqcGFyYW1ldGVyc6F4H2NvbS5hbnRocm9waWMub3JpZ2luLWNvbmZpZGVuY2VndW5rbm93bmtkZXNjcmlwdGlvbnhmQ2xhdWRlIHByb3ZpZGVkIHRoaXMgZmlsZSBhdCB0aGUgcmVxdWVzdCBvZiBhIHVzZXIgYW5kIG1heSBoYXZlIGNyZWF0ZWQgb3IgbW9kaWZpZWQgdGhlIGZpbGUgY29udGVudHMubXNvZnR3YXJlQWdlbnShZG5hbWVmQ2xhdWRlcmFsbEFjdGlvbnNJbmNsdWRlZPUAAADIanVtYgAAAEBqdW1kY2JvcgARABCAAACqADibcRNjMnBhLmhhc2guZGF0YQAAAAAYYzJzaC33HWcRNDbFWPntYlEvUKwAAACAY2JvcqVjYWxnZnNoYTI1NmNwYWRMAAAAAAAAAAAAAAAAZGhhc2hYIFas8YA1jUmAhL8atbv8F8JAsci999OOvck7ARVfSKWDZG5hbWVuanVtYmYgbWFuaWZlc3RqZXhjbHVzaW9uc4GiZXN0YXJ0GQNAZmxlbmd0aBkeBAAAAj5qdW1iAAAAJ2p1bWRjMmNsABEAEIAAAKoAOJtxA2MycGEuY2xhaW0udjIAAAACD2Nib3KlY2FsZ2ZzaGEyNTZpc2lnbmF0dXJleE1zZWxmI2p1bWJmPS9jMnBhL3VybjpjMnBhOjAwYjgyYzFlLTA1MDUtNDU5Mi04MGRlLTg1ZTMwOTM3ODYxOS9jMnBhLnNpZ25hdHVyZWppbnN0YW5jZUlEeCx4bXA6aWlkOmRiZTQ2ZWVmLTRhZjMtNDY0Mi05ZGIxLTZjMjcxMzMzNjVkYnJjcmVhdGVkX2Fzc2VydGlvbnODomN1cmx4LXNlbGYjanVtYmY9YzJwYS5hc3NlcnRpb25zL2MycGEuaW5ncmVkaWVudC52M2RoYXNoWCBXgE8hr0DViQAMxqESQzxWINRKEk3Xf2bx3Js2gatSIqJjdXJseCpzZWxmI2p1bWJmPWMycGEuYXNzZXJ0aW9ucy9jMnBhLmFjdGlvbnMudjJkaGFzaFgg3+hji4686gmUD6lK3fEet4mjYAddyYL/25a/77O85vyiY3VybHgpc2VsZiNqdW1iZj1jMnBhLmFzc2VydGlvbnMvYzJwYS5oYXNoLmRhdGFkaGFzaFggf2LHVTPPQtQX9pJCvN8bb0Gxm0R90X4etYygQMiLm0R0Y2xhaW1fZ2VuZXJhdG9yX2luZm+jZG5hbWVvQW50aHJvcGljIEZpbGVzZ3ZlcnNpb25lMS4wLjBrc3BlY1ZlcnNpb25lMi40LjAAABA4anVtYgAAAChqdW1kYzJjcwARABCAAACqADibcQNjMnBhLnNpZ25hdHVyZQAAABAIY2JvctKEWQISogEmGCFZAgowggIGMIIBjaADAgECAhRA5aAK7sI50L64g/oGQgU9Z1UTADAKBggqhkjOPQQDAzBJMRcwFQYDVQQKEw5BbnRocm9waWMsIFBCQzEuMCwGA1UEAxMlQW50aHJvcGljIENvbnRlbnQgQ3JlZGVudGlhbHMgUm9vdCBDQTAeFw0yNjA4MDcxODQzNTZaFw0yODA4MDYxOTQzNTZaMEQxFzAVBgNVBAoTDkFudGhyb3BpYywgUEJDMSkwJwYDVQQDEyBBbnRocm9waWMgQ2xhdWRlIENvbnRlbnQgU2lnbmluZzBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABJh6CmvLUBgFFNU0vUKlOVtE6djd17L5SuwX0LemFisBM3dkd/3cyjxFA3Qo5S46fX0/ihY0VZ7mfb9KF703t5OjWDBWMA4GA1UdDwEB/wQEAwIHgDAVBgNVHSUEDjAMBgorBgEEAYPoXgIBMAwGA1UdEwEB/wQCMAAwHwYDVR0jBBgwFoAUzlHiBIFOZFsj+OPEz5o+nMHXXMIwCgYIKoZIzj0EAwMDZwAwZAIwMXMdFJ4BetLLVY7ORuE9noqbbAZOZn/aArXyTwFAZfKrPzxF2vPoJNf1+UCdg1XGAjBwX1zd9WGqYkqmL5SFqw1QySjr1zJfpJM9+1rdDwSPLMOPOjKuiXjoU/pUUeG9RwmhY3BhZFkNngAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPZYQOcvVvUeJr6jO5tVQuRpQfnAO3CgqVnQRRPMGTdqubQWDFq7cyLXHg7FqIVSEuLaJ8g3lyOwhJ1ODHB9ZQWC2iY= diff --git a/apps/wrist-doom/src/logic.rs b/apps/wrist-doom/src/logic.rs deleted file mode 100644 index 550ac35..0000000 --- a/apps/wrist-doom/src/logic.rs +++ /dev/null @@ -1,1095 +0,0 @@ -//! Wrist Doom: game logic and software renderer. -//! -//! Nothing in here touches the watch (`Api`), so `make test` runs it on your computer. -//! Everything is integer maths with no heap, because the watch has neither an FPU nor an allocator: -//! * positions and vectors are Q12 fixed point (4096 = one map cell) -//! * angles are 1024 units per full turn; increasing the angle turns the player to the right -//! * the screen is drawn with `rect` only (the one drawing primitive the loader offers) - -pub const Q: i32 = 12; -pub const ONE: i32 = 1 << Q; - -/// Frame time. The game logic is tuned for this (20 steps a second). -pub const FRAME_MS: u32 = 50; - -// ---------------------------------------------------------------- level - -pub const MW: usize = 20; -pub const MH: usize = 16; - -/// `#` tech wall, `%` brick, `G` green marble, `R` red wall (marks the exit alcove), -/// `P` player start, `i` imp, `h` health, `a` ammo, `E` exit, anything else is open floor. -/// Every row must be exactly MW bytes: the compiler checks it. -pub const MAP: [&[u8; MW]; MH] = [ - b"####################", - b"#P...#........#....#", - b"#....#..%..%..#.a..#", - b"#................i.#", - b"#....#..%..%..#....#", - b"#..h.#...i....######", - b"##.###........#....#", - b"#..................#", - b"#..%%%%.GGGGG.#.i..#", - b"#..%..i.G...G.######", - b"#..%....G.a.G......#", - b"#..%%.%%G.i.G.####.#", - b"#.......GG.GG.#RRR.#", - b"#.h...i.......#R.E.#", - b"#..............RRR.#", - b"####################", -]; - -pub fn cell(x: i32, y: i32) -> u8 { - if x < 0 || y < 0 || x >= MW as i32 || y >= MH as i32 { - b'#' - } else { - MAP[y as usize][x as usize] - } -} - -pub fn is_wall(c: u8) -> bool { - matches!(c, b'#' | b'%' | b'G' | b'R') -} - -// ---------------------------------------------------------------- trigonometry - -/// sin(0..=90 degrees) in 256 steps, Q12. -const SIN_Q: [i16; 257] = [ - 0, 25, 50, 75, 101, 126, 151, 176, 201, 226, 251, 276, 301, 326, 351, 376, - 401, 426, 451, 476, 501, 526, 551, 576, 601, 626, 651, 675, 700, 725, 750, 774, - 799, 824, 848, 873, 897, 922, 946, 971, 995, 1020, 1044, 1068, 1092, 1117, 1141, 1165, - 1189, 1213, 1237, 1261, 1285, 1309, 1332, 1356, 1380, 1404, 1427, 1451, 1474, 1498, 1521, 1544, - 1567, 1591, 1614, 1637, 1660, 1683, 1706, 1729, 1751, 1774, 1797, 1819, 1842, 1864, 1886, 1909, - 1931, 1953, 1975, 1997, 2019, 2041, 2062, 2084, 2106, 2127, 2149, 2170, 2191, 2213, 2234, 2255, - 2276, 2296, 2317, 2338, 2359, 2379, 2399, 2420, 2440, 2460, 2480, 2500, 2520, 2540, 2559, 2579, - 2598, 2618, 2637, 2656, 2675, 2694, 2713, 2732, 2751, 2769, 2788, 2806, 2824, 2843, 2861, 2878, - 2896, 2914, 2932, 2949, 2967, 2984, 3001, 3018, 3035, 3052, 3068, 3085, 3102, 3118, 3134, 3150, - 3166, 3182, 3198, 3214, 3229, 3244, 3260, 3275, 3290, 3305, 3320, 3334, 3349, 3363, 3378, 3392, - 3406, 3420, 3433, 3447, 3461, 3474, 3487, 3500, 3513, 3526, 3539, 3551, 3564, 3576, 3588, 3600, - 3612, 3624, 3636, 3647, 3659, 3670, 3681, 3692, 3703, 3713, 3724, 3734, 3745, 3755, 3765, 3775, - 3784, 3794, 3803, 3812, 3822, 3831, 3839, 3848, 3857, 3865, 3873, 3881, 3889, 3897, 3905, 3912, - 3920, 3927, 3934, 3941, 3948, 3954, 3961, 3967, 3973, 3979, 3985, 3991, 3996, 4002, 4007, 4012, - 4017, 4022, 4027, 4031, 4036, 4040, 4044, 4048, 4052, 4055, 4059, 4062, 4065, 4068, 4071, 4074, - 4076, 4079, 4081, 4083, 4085, 4087, 4088, 4090, 4091, 4092, 4093, 4094, 4095, 4095, 4096, 4096, - 4096, -]; - -pub fn sin(a: i32) -> i32 { - let a = a & 1023; - let i = (a & 255) as usize; - match a >> 8 { - 0 => SIN_Q[i] as i32, - 1 => SIN_Q[256 - i] as i32, - 2 => -(SIN_Q[i] as i32), - _ => -(SIN_Q[256 - i] as i32), - } -} - -pub fn cos(a: i32) -> i32 { - sin(a + 256) -} - -// ---------------------------------------------------------------- screen layout - -pub const COLS: usize = 58; // ray columns -pub const COL_W: i32 = 8; // pixels per column -pub const VIEW_X: i32 = 1; -pub const VIEW_Y: i32 = 100; -pub const VIEW_W: i32 = COLS as i32 * COL_W; // 464 -pub const VIEW_H: i32 = 240; -const VIEW_B: i32 = VIEW_Y + VIEW_H; - -// ---------------------------------------------------------------- tuning - -const K: i32 = 3072; // camera plane length 0.75 -> about 74 degrees of view -const PROJ: i32 = 330; // wall height in pixels at a distance of one cell -const R: i32 = 900; // body radius, 0.22 cell -const STEP: i32 = 480; // walking speed per frame, 0.117 cell -const TURN: i32 = 24; // angle units per crown detent (about 8 degrees) -const MELEE: i32 = ONE * 3 / 4; -const IMP_SPEED: i32 = 184; // 0.045 cell per frame -const HIT_W: i32 = 1500; // how far off the crosshair a shot still hits an imp (0.37 cell) -const MAX_ENT: usize = 16; - -pub const EV_HURT: u8 = 1; -pub const EV_PICKUP: u8 = 2; -pub const EV_KILL: u8 = 4; -pub const EV_SHOT: u8 = 8; -pub const EV_WIN: u8 = 16; - -// ---------------------------------------------------------------- colours (RGB565) - -const fn rgb(r: i32, g: i32, b: i32) -> u16 { - (((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3)) as u16 -} - -const BLACK: u16 = 0x0000; -const WHITE: u16 = 0xFFFF; -const GREY: u16 = 0x8410; -const RED: u16 = rgb(225, 40, 40); -const YELLOW: u16 = rgb(255, 225, 40); -const CEIL: u16 = rgb(28, 28, 40); -const FLOOR: u16 = rgb(56, 44, 38); - -fn wall_rgb(c: u8) -> (i32, i32, i32) { - match c { - b'%' => (140, 110, 85), - b'G' => (60, 140, 80), - b'R' => (180, 45, 45), - _ => (120, 130, 160), - } -} - -// ---------------------------------------------------------------- drawing target - -/// What the renderer draws on. The watch implements it with `Api`; tests count the calls. -pub trait Gfx { - fn rect(&mut self, x: i16, y: i16, w: u16, h: u16, c: u16); - fn text(&mut self, x: i16, y: i16, s: &str, c: u16); -} - -fn fill(g: &mut G, x: i32, y: i32, w: i32, h: i32, c: u16) { - if w > 0 && h > 0 { - g.rect(x as i16, y as i16, w as u16, h as u16, c); - } -} - -/// The built-in font is 8x8 drawn at 2x: every character is a 16 px cell, ASCII only here. -fn centre(g: &mut G, y: i32, s: &str, c: u16) { - g.text((233 - 8 * s.len() as i32) as i16, y as i16, s, c); -} - -/// A tiny fixed buffer to build text without a heap or `core::fmt`. -pub struct Buf { - b: [u8; 40], - n: usize, -} - -impl Buf { - pub fn new() -> Buf { - Buf { b: [0; 40], n: 0 } - } - fn push(&mut self, c: u8) { - if self.n < self.b.len() { - self.b[self.n] = c; - self.n += 1; - } - } - pub fn s(&mut self, t: &str) -> &mut Buf { - for &c in t.as_bytes() { - self.push(c); - } - self - } - pub fn num(&mut self, mut v: u32) -> &mut Buf { - let mut d = [0u8; 10]; - let mut i = 0; - loop { - d[i] = b'0' + (v % 10) as u8; - v /= 10; - i += 1; - if v == 0 { - break; - } - } - while i > 0 { - i -= 1; - self.push(d[i]); - } - self - } - /// m:ss - pub fn time(&mut self, ms: u32) -> &mut Buf { - let secs = ms / 1000; - self.num(secs / 60).s(":"); - if secs % 60 < 10 { - self.push(b'0'); - } - self.num(secs % 60) - } - pub fn as_str(&self) -> &str { - core::str::from_utf8(&self.b[..self.n]).unwrap_or("?") - } -} - -// ---------------------------------------------------------------- sprites - -// 8 wide, 12 tall. '.' is transparent. The digit picks a colour in `pal`. -static IMP: [[u8; 8]; 12] = [ - *b"..1111..", - *b".113311.", - *b".111111.", - *b"..1441..", - *b"..1111..", - *b".111111.", - *b"11111111", - *b"11.11.11", - *b".111111.", - *b".11..11.", - *b".22..22.", - *b".22..22.", -]; -static HEALTH: [[u8; 8]; 12] = [ - *b"........", - *b"........", - *b"........", - *b"........", - *b"........", - *b"........", - *b"..1111..", - *b".111111.", - *b".112211.", - *b".112211.", - *b".111111.", - *b"..1111..", -]; -static AMMO: [[u8; 8]; 12] = [ - *b"........", - *b"........", - *b"........", - *b"........", - *b"........", - *b"........", - *b"........", - *b"........", - *b"11111111", - *b"12121212", - *b"12121212", - *b"11111111", -]; -static EXIT: [[u8; 8]; 12] = [ - *b"..1111..", - *b".122221.", - *b".123321.", - *b".123321.", - *b".123321.", - *b".123321.", - *b".123321.", - *b".123321.", - *b".123321.", - *b".123321.", - *b".122221.", - *b".111111.", -]; - -#[derive(Clone, Copy, PartialEq, Eq)] -pub enum Kind { - Imp, - Health, - Ammo, - Exit, -} - -/// Texture and height (256 = as tall as a wall) of a sprite kind. -fn sprite(k: Kind) -> (&'static [[u8; 8]; 12], i32) { - match k { - Kind::Imp => (&IMP, 200), - Kind::Health => (&HEALTH, 100), - Kind::Ammo => (&AMMO, 90), - Kind::Exit => (&EXIT, 240), - } -} - -fn pal(k: Kind, c: u8) -> u16 { - match (k, c) { - (Kind::Imp, b'1') => rgb(205, 75, 45), - (Kind::Imp, b'2') => rgb(120, 40, 30), - (Kind::Imp, b'3') => rgb(255, 225, 40), - (Kind::Imp, _) => rgb(30, 0, 0), - (Kind::Health, b'1') => rgb(235, 235, 240), - (Kind::Health, _) => rgb(210, 30, 30), - (Kind::Ammo, b'1') => rgb(200, 170, 60), - (Kind::Ammo, _) => rgb(120, 90, 20), - (Kind::Exit, b'1') => rgb(20, 80, 40), - (Kind::Exit, b'2') => rgb(40, 170, 80), - (Kind::Exit, _) => rgb(170, 255, 180), - } -} - -// ---------------------------------------------------------------- ray casting - -struct Hit { - perp: i32, // distance along the view direction, Q12 (no fisheye) - side: u8, // 0 = hit a wall facing x, 1 = facing y - cell: u8, // which wall type - wallx: i32, // where along the wall, 0..4095 -} - -/// 1/|v| in Q12 for a Q12 ray component. -fn inv(v: i32) -> i32 { - let a = v.abs(); - if a < 4 { - 1 << 26 - } else { - (1 << 24) / a - } -} - -fn mul(a: i32, b: i32) -> i32 { - ((a as i64 * b as i64) >> Q) as i32 -} - -/// Digital differential analyser: walk the ray from cell border to cell border until it enters a wall. -fn cast(px: i32, py: i32, rx: i32, ry: i32) -> Hit { - let (mut mx, mut my) = (px >> Q, py >> Q); - let (ddx, ddy) = (inv(rx), inv(ry)); - let (stx, mut sdx) = if rx < 0 { - (-1, mul(px - (mx << Q), ddx)) - } else { - (1, mul(((mx + 1) << Q) - px, ddx)) - }; - let (sty, mut sdy) = if ry < 0 { - (-1, mul(py - (my << Q), ddy)) - } else { - (1, mul(((my + 1) << Q) - py, ddy)) - }; - let mut side = 0u8; - let mut c = b'#'; - for _ in 0..40 { - if sdx < sdy { - sdx = sdx.saturating_add(ddx); - mx += stx; - side = 0; - } else { - sdy = sdy.saturating_add(ddy); - my += sty; - side = 1; - } - let k = cell(mx, my); - if is_wall(k) { - c = k; - break; - } - } - let perp = (if side == 0 { sdx - ddx } else { sdy - ddy }).max(96); - let wallx = if side == 0 { - py as i64 + ((perp as i64 * ry as i64) >> Q) - } else { - px as i64 + ((perp as i64 * rx as i64) >> Q) - }; - Hit { perp, side, cell: c, wallx: (wallx as i32) & (ONE - 1) } -} - -// ---------------------------------------------------------------- the game - -#[derive(Clone, Copy)] -pub struct Ent { - pub kind: Kind, - pub x: i32, - pub y: i32, - pub hp: i16, - pub alive: bool, // for items: not picked up yet - pub awake: bool, - pub cool: u8, // frames until the imp can claw again -} - -const NO_ENT: Ent = Ent { kind: Kind::Ammo, x: 0, y: 0, hp: 0, alive: false, awake: false, cool: 0 }; - -#[derive(Clone, Copy, PartialEq, Eq)] -pub enum State { - Playing, - Dead, - Won, -} - -pub struct Game { - pub px: i32, - pub py: i32, - pub ang: i32, - pub hp: i32, - pub ammo: i32, - pub kills: i32, - pub total: i32, - pub ents: [Ent; MAX_ENT], - pub n: usize, - pub state: State, - pub frames: u32, - pub walk: i32, // frames of forward (+) or backward (-) walking still queued - pub strafe: i32, // same for sideways, + is right - pub fire_cool: u8, - pub flash: u8, - pub hurt: u8, - pub msg: &'static str, - pub msg_t: u8, - rng: u32, -} - -/// Cheap distance (error under 12 %): the longer leg plus half the shorter. -fn dist(dx: i32, dy: i32) -> i32 { - let (a, b) = (dx.abs(), dy.abs()); - a.max(b) + a.min(b) / 2 -} - -const CORNERS: [(i32, i32); 4] = [(-R, -R), (R, -R), (-R, R), (R, R)]; - -fn blocked(x: i32, y: i32) -> bool { - for &(ox, oy) in CORNERS.iter() { - if is_wall(cell((x + ox) >> Q, (y + oy) >> Q)) { - return true; - } - } - false -} - -impl Game { - pub fn new(seed: u32) -> Game { - let mut game = Game { - px: ONE * 3 / 2, - py: ONE * 3 / 2, - ang: 128, - hp: 100, - ammo: 24, - kills: 0, - total: 0, - ents: [NO_ENT; MAX_ENT], - n: 0, - state: State::Playing, - frames: 0, - walk: 0, - strafe: 0, - fire_cool: 0, - flash: 0, - hurt: 0, - msg: "FIND THE GREEN EXIT", - msg_t: 60, - rng: seed | 1, - }; - for y in 0..MH { - for x in 0..MW { - let (cx, cy) = (x as i32 * ONE + ONE / 2, y as i32 * ONE + ONE / 2); - match MAP[y][x] { - b'P' => { - game.px = cx; - game.py = cy; - } - b'i' => { - game.add(Kind::Imp, cx, cy); - game.total += 1; - } - b'h' => game.add(Kind::Health, cx, cy), - b'a' => game.add(Kind::Ammo, cx, cy), - b'E' => game.add(Kind::Exit, cx, cy), - _ => {} - } - } - } - game - } - - fn add(&mut self, kind: Kind, x: i32, y: i32) { - if self.n < MAX_ENT { - self.ents[self.n] = Ent { kind, x, y, hp: 30, alive: true, awake: false, cool: 0 }; - self.n += 1; - } - } - - pub fn time_ms(&self) -> u32 { - self.frames * FRAME_MS - } - - fn say(&mut self, m: &'static str, t: u8) { - self.msg = m; - self.msg_t = t; - } - - /// xorshift32 - fn rand(&mut self, n: u32) -> u32 { - let mut x = self.rng; - x ^= x << 13; - x ^= x >> 17; - x ^= x << 5; - self.rng = x; - x % n - } - - // ---- input - - /// One crown detent: +1 turns right. - pub fn turn(&mut self, detents: i32) { - self.ang = (self.ang + detents * TURN) & 1023; - } - - /// A tap on the screen. There are no drags on the watch, so zones do the job: - /// top = forward, bottom = back, left/right = strafe, middle = shoot. - pub fn touch(&mut self, x: i32, y: i32) -> u8 { - if y < 150 { - self.walk = (self.walk + 6).min(12); - } else if y > 316 { - self.walk = (self.walk - 6).max(-12); - } else if x < 150 { - self.strafe = (self.strafe - 6).max(-12); - } else if x > 316 { - self.strafe = (self.strafe + 6).min(12); - } else { - return self.fire(); - } - 0 - } - - /// Pistol: hits the nearest imp that is in front of the crosshair and not behind a wall. - pub fn fire(&mut self) -> u8 { - if self.state != State::Playing || self.fire_cool > 0 { - return 0; - } - if self.ammo <= 0 { - self.say("NO AMMO", 20); - self.fire_cool = 10; - return 0; - } - self.ammo -= 1; - self.fire_cool = 6; - self.flash = 2; - let (dx, dy) = (cos(self.ang), sin(self.ang)); - let wall = cast(self.px, self.py, dx, dy).perp; - let mut best: Option<(i32, usize)> = None; - for i in 0..self.n { - let e = self.ents[i]; - if e.kind != Kind::Imp || !e.alive { - continue; - } - let (sx, sy) = (e.x - self.px, e.y - self.py); - let depth = (sx * dx + sy * dy) >> Q; - let lat = (sy * dx - sx * dy) >> Q; - if depth < ONE / 4 || depth >= wall || lat.abs() > HIT_W { - continue; - } - if best.map_or(true, |(d, _)| depth < d) { - best = Some((depth, i)); - } - } - let mut ev = EV_SHOT; - if let Some((_, i)) = best { - let dmg = 8 + self.rand(7) as i16; - let mut killed = false; - { - let e = &mut self.ents[i]; - e.hp -= dmg; - e.awake = true; - if e.hp <= 0 { - e.alive = false; - killed = true; - } - } - if killed { - self.kills += 1; - ev |= EV_KILL; - self.say("IMP DOWN", 20); - } - } - ev - } - - // ---- one frame of world - - fn try_move(&mut self, mx: i32, my: i32) { - let nx = self.px + mx; - if !blocked(nx, self.py) { - self.px = nx; - } - let ny = self.py + my; - if !blocked(self.px, ny) { - self.py = ny; - } - } - - fn los(&self, x: i32, y: i32) -> bool { - let (dx, dy) = (self.px - x, self.py - y); - let n = (dist(dx, dy) / (ONE / 4)).clamp(1, 40); - for s in 1..n { - if is_wall(cell((x + dx * s / n) >> Q, (y + dy * s / n) >> Q)) { - return false; - } - } - true - } - - /// Advance the world by one frame. Returns EV_* flags for the haptics. - pub fn step(&mut self) -> u8 { - let mut ev = 0u8; - if self.state != State::Playing { - return ev; - } - self.frames += 1; - self.fire_cool = self.fire_cool.saturating_sub(1); - self.flash = self.flash.saturating_sub(1); - self.hurt = self.hurt.saturating_sub(1); - self.msg_t = self.msg_t.saturating_sub(1); - - let (dx, dy) = (cos(self.ang), sin(self.ang)); - if self.walk != 0 { - let s = self.walk.signum(); - self.try_move((dx * STEP * s) >> Q, (dy * STEP * s) >> Q); - self.walk -= s; - } - if self.strafe != 0 { - let s = self.strafe.signum(); - // the right-hand vector is (-sin, cos) - self.try_move((-dy * STEP * s) >> Q, (dx * STEP * s) >> Q); - self.strafe -= s; - } - - // imps - for i in 0..self.n { - let mut e = self.ents[i]; - if e.kind != Kind::Imp || !e.alive { - continue; - } - let (ex, ey) = (self.px - e.x, self.py - e.y); - let d = dist(ex, ey); - if !e.awake && d < 6 * ONE && self.los(e.x, e.y) { - e.awake = true; - } - e.cool = e.cool.saturating_sub(1); - if e.awake { - if d > MELEE { - let nx = e.x + ex * IMP_SPEED / d; - if !blocked(nx, e.y) { - e.x = nx; - } - let ny = e.y + ey * IMP_SPEED / d; - if !blocked(e.x, ny) { - e.y = ny; - } - } else if e.cool == 0 { - e.cool = 20; - let dmg = 4 + self.rand(6) as i32; - self.hp -= dmg; - self.hurt = 6; - ev |= EV_HURT; - } - } - self.ents[i] = e; - } - - // pickups and the exit - for i in 0..self.n { - let e = self.ents[i]; - if !e.alive { - continue; - } - let d = dist(self.px - e.x, self.py - e.y); - match e.kind { - Kind::Health if d < 2400 && self.hp < 100 => { - self.hp = (self.hp + 25).min(100); - self.ents[i].alive = false; - self.say("HEALTH +25", 25); - ev |= EV_PICKUP; - } - Kind::Ammo if d < 2400 && self.ammo < 99 => { - self.ammo = (self.ammo + 10).min(99); - self.ents[i].alive = false; - self.say("AMMO +10", 25); - ev |= EV_PICKUP; - } - Kind::Exit if d < 2900 => { - self.state = State::Won; - self.say("LEVEL CLEAR", 255); - ev |= EV_WIN; - } - _ => {} - } - } - if self.hp <= 0 && self.state == State::Playing { - self.state = State::Dead; - self.say("YOU DIED", 255); - } - ev - } - - // ---- drawing - - /// Draw the whole 3D view, the weapon and the status bar. Everything stays inside - /// `VIEW_Y..VIEW_Y + VIEW_H`, so the loader only has to push about half the screen per frame. - pub fn render(&self, g: &mut G) { - let (dx, dy) = (cos(self.ang), sin(self.ang)); - let (plx, ply) = ((-dy * K) >> Q, (dx * K) >> Q); - let mut zbuf = [0i32; COLS]; - - // walls: one ceiling, wall and floor rectangle per column - for i in 0..COLS { - let camx = ((2 * i as i32 + 1) * ONE) / COLS as i32 - ONE; - let rx = dx + ((plx * camx) >> Q); - let ry = dy + ((ply * camx) >> Q); - let h = cast(self.px, self.py, rx, ry); - zbuf[i] = h.perp; - let lh = ((PROJ << Q) / h.perp).min(VIEW_H); - let top = VIEW_Y + (VIEW_H - lh) / 2; - let mut k = 256 * 20480 / (20480 + h.perp); // darker with distance - if h.side == 1 { - k = k * 3 / 4; - } - if (h.wallx & 0x3FF) < 0xA0 { - k = k * 3 / 4; // panel seam - } - let (r0, g0, b0) = wall_rgb(h.cell); - let x = VIEW_X + i as i32 * COL_W; - fill(g, x, VIEW_Y, COL_W, top - VIEW_Y, CEIL); - fill(g, x, top, COL_W, lh, rgb((r0 * k) >> 8, (g0 * k) >> 8, (b0 * k) >> 8)); - fill(g, x, top + lh, COL_W, VIEW_B - top - lh, FLOOR); - } - - // sprites, far to near, hidden behind walls column by column - let mut order = [(0i32, 0i32, 0usize); MAX_ENT]; - let mut m = 0usize; - for i in 0..self.n { - let e = &self.ents[i]; - if !e.alive { - continue; - } - let (sx, sy) = (e.x - self.px, e.y - self.py); - let depth = (sx * dx + sy * dy) >> Q; - if depth < 820 { - continue; // behind us or inside us - } - order[m] = (depth, (sy * dx - sx * dy) >> Q, i); - m += 1; - } - for a in 1..m { - let mut b = a; - while b > 0 && order[b - 1].0 < order[b].0 { - order.swap(b - 1, b); - b -= 1; - } - } - for &(depth, lat, i) in order[..m].iter() { - let kind = self.ents[i].kind; - let (tex, scale) = sprite(kind); - let wall_h = (PROJ << Q) / depth; - let sh = ((PROJ * scale / 256) << Q) / depth; - let sw = sh * 8 / 12; - if sw < 1 { - continue; - } - let den = (depth * K) >> Q; - let left = VIEW_W / 2 + lat * (VIEW_W / 2) / den - sw / 2; - let top = VIEW_Y + VIEW_H / 2 + wall_h / 2 - sh; // feet on the floor - for c in 0..COLS { - let cx = c as i32 * COL_W + COL_W / 2; - if cx < left || cx >= left + sw || depth >= zbuf[c] { - continue; - } - let tx = ((cx - left) * 8 / sw) as usize; - let mut r = 0usize; - while r < 12 { - let p = tex[r][tx]; - let mut r2 = r + 1; - while r2 < 12 && tex[r2][tx] == p { - r2 += 1; - } - if p != b'.' { - let y0 = (top + r as i32 * sh / 12).max(VIEW_Y); - let y1 = (top + r2 as i32 * sh / 12).min(VIEW_B); - fill(g, VIEW_X + c as i32 * COL_W, y0, COL_W, y1 - y0, pal(kind, p)); - } - r = r2; - } - } - } - - // pistol - fill(g, 227, VIEW_B - 96, 12, 40, rgb(150, 150, 160)); - fill(g, 219, VIEW_B - 60, 28, 30, rgb(95, 95, 105)); - fill(g, 215, VIEW_B - 32, 36, 14, rgb(60, 45, 35)); - if self.flash > 0 { - fill(g, 217, VIEW_B - 132, 32, 36, YELLOW); - fill(g, 226, VIEW_B - 120, 14, 24, WHITE); - } - // crosshair - fill(g, 232, VIEW_Y + VIEW_H / 2 - 8, 3, 16, WHITE); - fill(g, 225, VIEW_Y + VIEW_H / 2 - 1, 16, 3, WHITE); - // damage flash: a red frame - if self.hurt > 0 { - fill(g, VIEW_X, VIEW_Y, VIEW_W, 6, RED); - fill(g, VIEW_X, VIEW_Y, 6, VIEW_H, RED); - fill(g, VIEW_X + VIEW_W - 6, VIEW_Y, 6, VIEW_H, RED); - } - // message line (at most 23 characters fit at this height) - if self.msg_t > 0 { - fill(g, 0, VIEW_Y, 466, 20, BLACK); - centre(g, VIEW_Y + 2, self.msg, YELLOW); - } - // status bar - fill(g, 0, VIEW_B - 22, 466, 22, BLACK); - let mut b = Buf::new(); - b.s("HP ").num(self.hp.max(0) as u32); - g.text(74, (VIEW_B - 19) as i16, b.as_str(), if self.hp < 30 { RED } else { WHITE }); - let mut b = Buf::new(); - b.s("AMMO ").num(self.ammo.max(0) as u32); - g.text(186, (VIEW_B - 19) as i16, b.as_str(), if self.ammo < 5 { RED } else { WHITE }); - let mut b = Buf::new(); - b.s("K ").num(self.kills as u32).s("/").num(self.total as u32); - g.text(316, (VIEW_B - 19) as i16, b.as_str(), WHITE); - } -} - -// ---------------------------------------------------------------- screens - -pub fn draw_title(g: &mut G, best: Option) { - fill(g, 0, VIEW_Y, 466, VIEW_H, BLACK); - centre(g, 106, "WRIST DOOM", RED); - centre(g, 134, "Doom-style raycaster", GREY); - centre(g, 166, "crown: turn", WHITE); - centre(g, 188, "tap top/bottom: walk", WHITE); - centre(g, 210, "tap sides: strafe", WHITE); - centre(g, 232, "tap middle: shoot", WHITE); - centre(g, 264, "find the green exit", YELLOW); - centre(g, 294, "tap to start", WHITE); - if let Some(t) = best { - let mut b = Buf::new(); - b.s("best ").time(t); - centre(g, 316, b.as_str(), GREY); - } -} - -pub fn draw_end(g: &mut G, game: &Game, best: Option) { - let won = game.state == State::Won; - fill(g, 0, VIEW_Y, 466, VIEW_H, if won { rgb(0, 40, 10) } else { rgb(60, 0, 0) }); - centre(g, 130, if won { "LEVEL CLEAR" } else { "YOU DIED" }, if won { YELLOW } else { RED }); - let mut b = Buf::new(); - b.s("kills ").num(game.kills as u32).s("/").num(game.total as u32); - centre(g, 172, b.as_str(), WHITE); - let mut b = Buf::new(); - b.s("time ").time(game.time_ms()); - centre(g, 196, b.as_str(), WHITE); - if let Some(t) = best { - let mut b = Buf::new(); - b.s("best ").time(t); - centre(g, 220, b.as_str(), GREY); - } - centre(g, 270, if won { "tap to play again" } else { "tap to retry" }, GREY); -} - -// ---------------------------------------------------------------- saved best time - -/// The saved blob is `W1` + the best time in ms (u32, little endian). Anything else loads as nothing. -pub fn decode_best(blob: &[u8]) -> Option { - if blob.len() == 6 && blob[0] == b'W' && blob[1] == b'1' { - Some(u32::from_le_bytes([blob[2], blob[3], blob[4], blob[5]])) - } else { - None - } -} - -pub fn encode_best(ms: u32) -> [u8; 6] { - let b = ms.to_le_bytes(); - [b'W', b'1', b[0], b[1], b[2], b[3]] -} - -// ---------------------------------------------------------------- tests - -#[cfg(test)] -mod tests { - use super::*; - - struct Count { - rects: usize, - outside: bool, - } - - impl Gfx for Count { - fn rect(&mut self, x: i16, y: i16, w: u16, h: u16, _c: u16) { - self.rects += 1; - let (x, y, w, h) = (x as i32, y as i32, w as i32, h as i32); - if x < 0 || y < VIEW_Y || x + w > 466 || y + h > VIEW_B { - self.outside = true; - } - } - fn text(&mut self, _x: i16, _y: i16, _s: &str, _c: u16) {} - } - - #[test] - fn border_is_solid() { - for y in 0..MH { - for x in 0..MW { - if x == 0 || y == 0 || x == MW - 1 || y == MH - 1 { - assert!(is_wall(MAP[y][x]), "gap in the border at {},{}", x, y); - } - } - } - } - - #[test] - fn level_contents() { - let g = Game::new(1); - assert_eq!(g.total, 6); - let count = |k: Kind| g.ents[..g.n].iter().filter(|e| e.kind == k).count(); - assert_eq!(count(Kind::Imp), 6); - assert_eq!(count(Kind::Health), 2); - assert_eq!(count(Kind::Ammo), 2); - assert_eq!(count(Kind::Exit), 1); - } - - #[test] - fn everything_is_reachable_from_the_start() { - let g = Game::new(1); - let mut seen = [[false; MW]; MH]; - let mut stack = [(0usize, 0usize); MW * MH]; - let (sx, sy) = ((g.px >> Q) as usize, (g.py >> Q) as usize); - let mut sp = 1; - stack[0] = (sx, sy); - seen[sy][sx] = true; - while sp > 0 { - sp -= 1; - let (x, y) = stack[sp]; - for &(dx, dy) in [(1i32, 0i32), (-1, 0), (0, 1), (0, -1)].iter() { - let (nx, ny) = (x as i32 + dx, y as i32 + dy); - if is_wall(cell(nx, ny)) { - continue; - } - let (nx, ny) = (nx as usize, ny as usize); - if !seen[ny][nx] { - seen[ny][nx] = true; - stack[sp] = (nx, ny); - sp += 1; - } - } - } - for e in &g.ents[..g.n] { - assert!(seen[(e.y >> Q) as usize][(e.x >> Q) as usize]); - } - } - - #[test] - fn sine_table() { - assert_eq!(sin(0), 0); - assert_eq!(sin(256), 4096); - assert_eq!(sin(512), 0); - assert_eq!(sin(768), -4096); - assert_eq!(cos(0), 4096); - assert!((sin(128) - 2896).abs() <= 2); - assert_eq!(sin(-256), -4096); - } - - #[test] - fn ray_hits_the_first_wall() { - // from the middle of cell (1,1) east to the wall at x = 5: 3.5 cells - let h = cast(ONE * 3 / 2, ONE * 3 / 2, ONE, 0); - assert_eq!(h.cell, b'#'); - assert_eq!(h.side, 0); - assert!((h.perp - 14336).abs() < 64); - } - - #[test] - fn walls_stop_the_player() { - let mut g = Game::new(1); - g.ang = 512; // face -x, the border is 0.5 cell away - for _ in 0..40 { - g.walk = 12; - g.step(); - } - assert!(g.px >= ONE + R, "walked into the wall: {}", g.px); - } - - #[test] - fn strafe_goes_right() { - let mut g = Game::new(1); - g.ang = 0; // facing +x, so right is +y - g.n = 0; - let y0 = g.py; - g.strafe = 3; - for _ in 0..3 { - g.step(); - } - assert!(g.py > y0); - } - - fn lone_imp(g: &mut Game, dx: i32, dy: i32) { - g.n = 1; - g.total = 1; - g.ang = 0; - g.ents[0] = Ent { kind: Kind::Imp, x: g.px + dx, y: g.py + dy, hp: 30, alive: true, awake: false, cool: 0 }; - } - - #[test] - fn pistol_kills_an_imp_in_front() { - let mut g = Game::new(7); - lone_imp(&mut g, 3 * ONE, 0); - for _ in 0..6 { - if g.ents[0].alive { - g.fire(); - for _ in 0..8 { - g.step(); - } - } - } - assert!(!g.ents[0].alive); - assert_eq!(g.kills, 1); - assert!(g.ammo < 24); - } - - #[test] - fn pistol_misses_to_the_side_and_through_walls() { - let mut g = Game::new(7); - lone_imp(&mut g, 3 * ONE, ONE); // a full cell off to the side - assert_eq!(g.fire() & EV_KILL, 0); - assert_eq!(g.ents[0].hp, 30); - let mut g = Game::new(7); - lone_imp(&mut g, 5 * ONE, 0); // in the hall, behind the wall at x = 5 - g.fire(); - assert_eq!(g.ents[0].hp, 30); - } - - #[test] - fn imps_claw_when_adjacent() { - let mut g = Game::new(3); - lone_imp(&mut g, ONE / 2, 0); - g.ents[0].awake = true; - let ev = g.step(); - assert!(ev & EV_HURT != 0); - assert!(g.hp < 100); - } - - #[test] - fn health_pickup_works_and_is_used_up() { - let mut g = Game::new(1); - let i = (0..g.n).find(|&i| g.ents[i].kind == Kind::Health).unwrap(); - g.hp = 50; - g.px = g.ents[i].x; - g.py = g.ents[i].y; - let ev = g.step(); - assert!(ev & EV_PICKUP != 0); - assert_eq!(g.hp, 75); - assert!(!g.ents[i].alive); - } - - #[test] - fn reaching_the_exit_wins() { - let mut g = Game::new(1); - let i = (0..g.n).find(|&i| g.ents[i].kind == Kind::Exit).unwrap(); - g.px = g.ents[i].x; - g.py = g.ents[i].y; - let ev = g.step(); - assert!(ev & EV_WIN != 0); - assert!(g.state == State::Won); - } - - #[test] - fn frame_stays_in_the_view_band_and_is_cheap() { - let mut g = Game::new(1); - for &ang in [0, 128, 300, 512, 777].iter() { - g.ang = ang; - let mut c = Count { rects: 0, outside: false }; - g.render(&mut c); - assert!(!c.outside, "drew outside the view band at angle {}", ang); - assert!(c.rects > 30 && c.rects < 600, "{} rects", c.rects); - } - } - - #[test] - fn best_time_round_trips_and_rejects_garbage() { - assert_eq!(decode_best(&encode_best(83_450)), Some(83_450)); - assert_eq!(decode_best(&[]), None); - assert_eq!(decode_best(b"XX\0\0\0\0"), None); - assert_eq!(decode_best(b"W1\0"), None); - } - - #[test] - fn text_buffer() { - let mut b = Buf::new(); - b.s("time ").time(83_450); - assert_eq!(b.as_str(), "time 1:23"); - let mut b = Buf::new(); - b.num(0).s("/").num(6); - assert_eq!(b.as_str(), "0/6"); - } -} diff --git a/apps/wrist-doom/src/main.rs b/apps/wrist-doom/src/main.rs deleted file mode 100644 index 26b5b1f..0000000 --- a/apps/wrist-doom/src/main.rs +++ /dev/null @@ -1,189 +0,0 @@ -// wp2_sim: the same device code runs in the host simulator (`make sim APP=watchdoom`) -#![cfg_attr(any(target_os = "none", wp2_sim), no_main, cfg_attr(target_os = "none", no_std))] - -#[cfg_attr(not(target_os = "none"), allow(dead_code))] -mod logic; - -#[cfg(not(any(target_os = "none", wp2_sim)))] -fn main() {} - -#[cfg(any(target_os = "none", wp2_sim))] -mod device { - use crate::logic::{ - decode_best, draw_end, draw_title, encode_best, Game, Gfx, State, EV_HURT, EV_KILL, EV_PICKUP, EV_SHOT, EV_WIN, - FRAME_MS, - }; - use cmf_wp2_app::{Api, BUTTON, CROWN, PAUSE, RESUME, TOUCH_DOWN}; - - cmf_wp2_app::entry!(main); - cmf_wp2_app::app_icon!(); // needs icon.svg next to Cargo.toml - - const HZ: u16 = 31; // the stock motor PWM frequency - - /// Lets the pure renderer in `logic.rs` draw through the watch's `Api`. - struct Screen<'a>(&'a Api); - - impl Gfx for Screen<'_> { - fn rect(&mut self, x: i16, y: i16, w: u16, h: u16, c: u16) { - self.0.rect(x, y, w, h, c); - } - fn text(&mut self, x: i16, y: i16, s: &str, c: u16) { - self.0.text(x, y, s, c); - } - } - - // Wrapping-safe time maths: `now()` wraps after about 50 days. - fn remaining(t: u32, now: u32) -> u32 { - (t.wrapping_sub(now) as i32).max(0) as u32 - } - fn due(t: u32, now: u32) -> bool { - (now.wrapping_sub(t) as i32) >= 0 - } - - /// Start a short motor pulse. The event loop stops it when `end` is due. - fn buzz(api: &Api, duty: u16, ms: u32, end: &mut Option) { - if api.vibrate(duty, HZ) == 0 { - *end = Some(api.now().wrapping_add(ms)); - } else { - api.vibrate(0, HZ); // -4 means locked: clear it and skip this pulse - *end = None; - } - } - - fn feel(api: &Api, ev: u8, end: &mut Option) { - if (ev & EV_HURT) != 0 { - buzz(api, 700, 60, end); - } else if (ev & (EV_KILL | EV_WIN)) != 0 { - buzz(api, 650, 120, end); - } else if (ev & EV_PICKUP) != 0 { - buzz(api, 300, 30, end); - } else if (ev & EV_SHOT) != 0 { - buzz(api, 400, 25, end); - } - } - - /// A stock popup covers the app: wait for it to go away. false = the button was pressed. - fn wait_resume(api: &Api) -> bool { - loop { - match api.event(u32::MAX).map(|e| e.kind) { - Some(RESUME) => return true, - Some(BUTTON) => return false, - _ => {} - } - } - } - - /// Draw a screen and wait for a tap. `min_ms` ignores taps for a moment, so that a tap - /// aimed at the game does not skip the "you died" screen. false = the button was pressed. - fn wait_tap(api: &Api, min_ms: u32, redraw: &dyn Fn(&mut Screen<'_>)) -> bool { - let mut gfx = Screen(api); - redraw(&mut gfx); - api.show(); - let t0 = api.now(); - loop { - let Some(e) = api.event(u32::MAX) else { continue }; - match e.kind { - BUTTON => return false, - PAUSE => { - if !wait_resume(api) { - return false; - } - redraw(&mut gfx); - api.show(); - } - TOUCH_DOWN if api.now().wrapping_sub(t0) >= min_ms => return true, - _ => {} - } - } - } - - /// Run one game until it is won or lost. false = the player left with the button. - fn play(api: &Api, game: &mut Game) -> bool { - let mut gfx = Screen(api); - let mut buzz_end: Option = None; - game.render(&mut gfx); - api.show(); - let mut next = api.now().wrapping_add(FRAME_MS); - loop { - // Sleep until the next frame, or until a motor pulse has to stop, or until an input arrives. - let now = api.now(); - let mut wait = remaining(next, now); - if let Some(t) = buzz_end { - wait = wait.min(remaining(t, now)); - } - if let Some(e) = api.event(wait) { - match e.kind { - BUTTON => { - api.vibrate(0, HZ); - return false; - } - PAUSE => { - api.vibrate(0, HZ); - buzz_end = None; - if !wait_resume(api) { - return false; - } - game.render(&mut gfx); - api.show(); - next = api.now().wrapping_add(FRAME_MS); - continue; - } - CROWN => game.turn(e.delta as i32), - TOUCH_DOWN => { - let ev = game.touch(e.x as i32, e.y as i32); - feel(api, ev, &mut buzz_end); - } - _ => {} - } - } - let now = api.now(); - if let Some(t) = buzz_end { - if due(t, now) { - api.vibrate(0, HZ); - buzz_end = None; - } - } - if !due(next, now) { - continue; // an input woke us early: keep waiting for the frame - } - next = now.wrapping_add(FRAME_MS); - let ev = game.step(); - feel(api, ev, &mut buzz_end); - game.render(&mut gfx); - api.show(); - if game.state != State::Playing { - api.vibrate(0, HZ); - return true; - } - } - } - - fn main(api: &'static Api) -> i32 { - api.rect(0, 0, api.width, api.height, 0x0000); // black = pixels off on the AMOLED - - // saved best time; garbage loads as "none" - let mut blob = [0u8; 8]; - let len = api.load(&mut blob).max(0) as usize; - let mut best = if len > 0 && len <= blob.len() { decode_best(&blob[..len]) } else { None }; - - if !wait_tap(api, 0, &|g: &mut Screen<'_>| draw_title(g, best)) { - return 0; - } - loop { - let mut game = Game::new(api.now()); - if !play(api, &mut game) { - return 0; - } - if game.state == State::Won { - let t = game.time_ms(); - if best.map_or(true, |b| t < b) { - best = Some(t); - let _ = api.save(&encode_best(t)); // save on change, never per frame - } - } - if !wait_tap(api, 800, &|g: &mut Screen<'_>| draw_end(g, &game, best)) { - return 0; - } - } - } -} diff --git a/apps/wrist-doom/store.md b/apps/wrist-doom/store.md deleted file mode 100644 index 4b22a01..0000000 --- a/apps/wrist-doom/store.md +++ /dev/null @@ -1,18 +0,0 @@ -A small first-person shooter for the CMF Watch Pro 2, in the style of the 1993 classics: a ray-cast 3D view, imps that chase and claw you, health and ammo pickups, and a green exit to find. One level, about two minutes. The app remembers your best time. - -This is **not** id Software's Doom and contains none of its code, levels or art. It is an original, tiny engine written for the watch's limits. - -## Controls - -- **Crown**: turn left and right -- **Tap the top** of the screen: walk forward. **Tap the bottom**: step back -- **Tap the left or right side**: strafe -- **Tap the middle**: fire the pistol -- **Crown press or right swipe**: leave the game - -The watch only reports taps (no dragging), so each tap queues a short walk. Tap again to keep going. - -## Requirements - -- A CMF Watch Pro 2 with the patched firmware and the App Loader, both on the store's [firmware shelf](/firmware) -- No companion app and no phone connection diff --git a/apps/wrist-doom/store.toml b/apps/wrist-doom/store.toml deleted file mode 100644 index 202c819..0000000 --- a/apps/wrist-doom/store.toml +++ /dev/null @@ -1,4 +0,0 @@ -name = "Wrist Doom" -summary = "A Doom-style first-person shooter: crown to turn, tap to walk and shoot" -version = "0.1.0" -author = "ultima-spec"