From 9ba449567a9b772e5960128207046dcd11adb218 Mon Sep 17 00:00:00 2001 From: boxmol71-gif <241158981+boxmol71-gif@users.noreply.github.com> Date: Sun, 22 Nov 2026 21:15:01 +0000 Subject: [PATCH] Music Controller 0.2.0: artwork-led watch face --- AGENTS.md | 8 +- apps/music-controller/FONT-NOTICE.md | 10 + apps/music-controller/shots/playing.png | Bin 2718 -> 6258 bytes apps/music-controller/shots/waiting.png | Bin 2488 -> 5679 bytes apps/music-controller/src/artwork.rs | 954 +++++++++++ apps/music-controller/src/main.rs | 18 +- apps/music-controller/src/model.rs | 686 +++++++- apps/music-controller/src/ntype82.rs | 2046 +++++++++++++++++++++++ apps/music-controller/src/rpc.rs | 41 +- apps/music-controller/src/track.rs | 67 + apps/music-controller/src/view.rs | 551 ++++-- apps/music-controller/store.md | 6 +- apps/music-controller/store.toml | 4 +- 13 files changed, 4212 insertions(+), 179 deletions(-) create mode 100644 apps/music-controller/FONT-NOTICE.md create mode 100644 apps/music-controller/src/artwork.rs create mode 100644 apps/music-controller/src/ntype82.rs create mode 100644 apps/music-controller/src/track.rs diff --git a/AGENTS.md b/AGENTS.md index c8d16ac..7ce44a9 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -87,6 +87,11 @@ Treat every message as untrusted: anyone in BLE range can read the pairing secre reason nothing personal goes over the channel: no names, event or message titles, locations. Send counts, flags, times of day. +**Owner-approved exception:** `music-controller` may transfer the current media notification's title, artist, and a +low-resolution artwork thumbnail to its own watch face. This exception is scoped to that app and method; keep all other +apps on the default non-personal rule. Parse the transferred values as untrusted, bound their lengths, and do not +persist them in the watch's app storage. + Phone side, next to the Nothing X app on the same phone: the channel key K (`abi-1.4.md`, "Writing a host"). No bind, no "Paired" popup, Nothing X keeps working. What exists today: @@ -167,7 +172,8 @@ How it works and what it can't do: - Personal data: K is readable by anyone in BLE range. Calendar and reminder titles and notification text are off by default (records come with flag bit 2 and an empty title; show "busy" / "Reminder"); a per-app "Show text on the watch" switch turns them on. Location is 0.1° only. Event locations, attendees and notes are never sent. A watch - app sends nothing personal either: ids, counts, flags. + app sends nothing personal either: ids, counts, flags, except for the scoped `music-controller` artwork/track-text + exception described above. **What needs a newer watch.** Patched firmware **stub 8** (published 2026-11-19 as `1.0.0.73-wp2.11`, by OTA) with the loader of 2026-11-19 brings 16 app slots instead of 8 and `PUSH`, which `job.set` needs to refresh a widget or start diff --git a/apps/music-controller/FONT-NOTICE.md b/apps/music-controller/FONT-NOTICE.md new file mode 100644 index 0000000..c8f5c0b --- /dev/null +++ b/apps/music-controller/FONT-NOTICE.md @@ -0,0 +1,10 @@ +# 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/shots/playing.png b/apps/music-controller/shots/playing.png index aebd3c5311bb882645c635dd62093665d7e1def6..a2a719560603cb7c797d1c71ac8e2567ffa6c2dd 100644 GIT binary patch literal 6258 zcmd5=XHZjHy9QKHX@UYG0tX8gAX1DGLpchH0SO2KA_*<@5|EP6qavVE1?f!`3!s6} zLnuP1hN9F^LI@=)1Oh<_q274Ud^2~xU-#!(Gka$5HP3pUcfad-*V=nMH-#DqA3kxI zhlfWPa$DbwhljWS&vlTG+cUyPap2)Ot_jhmD_345&2C?#(M6^>3G{r9(8`j$Va8Fwg&8Wt zJ;VsU@{U#vzMIeCIKg9QQEdRzS7Zso-*^92or8V*c17W4!RhxKA@V$W8Ml#ivKSsuN_}D6h2TJHBfOY zSn@w5^XP4Wo#6vlnnH@GsEv2T#=JSnxjyy^N%ai6kk-`TH)9bRD(=9Xo|R{2u96)$*_^1w*O8 z4@L3T){SHY!O1=Oi@ouCU50fWB|rb~6?Fwi(8RyDqg&L@6_Xa3W>}|opJN{>Fowvk z8s}qka$(dnpFcQN(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DEbY#hn_!J% z_n%GU7bNhLlCm0SS1HhLxRyaKl5(C}ZS^=;;jxerLoK(-tj(?n@J1Dj?@yQdKy{zq z66ni6TQi{sG{L37f&=8$3eUY#gn#r-GCc6j^EfwwLm#Hjcwf-)BjC-OO&zEA{Vb6c zSp5*~Esqs4NTQQUo_l%eqf#Pddx%koGNI%27eA{=l z-zrmr?JS1~Z4y3*+B+|)Xt8znkTo%+B?lh*7$VE}=wW(T9oR%?$@Q}{cxcP)5B(CV z_4vnPE;>8#<5M|E2)=`&s_W&-fvq3S*, + 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 index ae527c9..0fc298f 100644 --- a/apps/music-controller/src/main.rs +++ b/apps/music-controller/src/main.rs @@ -4,11 +4,17 @@ 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)))] @@ -16,9 +22,9 @@ fn main() {} #[cfg(any(target_os = "none", wp2_sim))] mod device { - use crate::model::{BLOB_MAX, Got, Model, wall_min}; + use crate::model::{wall_min, Got, Model, BLOB_MAX}; use crate::rpc; - use crate::view::{Action, action, frame}; + 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; @@ -120,7 +126,13 @@ mod device { drawn = None; } TOUCH_DOWN => { - let action = action(event.x as i32, event.y as i32, m.max_volume()); + 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), diff --git a/apps/music-controller/src/model.rs b/apps/music-controller/src/model.rs index 099b19f..4147af3 100644 --- a/apps/music-controller/src/model.rs +++ b/apps/music-controller/src/model.rs @@ -1,10 +1,12 @@ //! 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. Only playback flags and music volume cross the BLE channel; no track text or -//! artwork is accepted or retained. +//! 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; @@ -12,9 +14,17 @@ 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; @@ -48,6 +58,15 @@ enum Active { id: u8, started: u32, }, + Track { + id: u8, + started: u32, + }, + Artwork { + id: u8, + nonce: u32, + started: u32, + }, Command { id: u8, command: u8, @@ -74,11 +93,26 @@ pub struct Model { /// 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. @@ -94,11 +128,25 @@ impl Model { 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, @@ -113,8 +161,11 @@ impl Model { /// 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; } @@ -141,18 +192,86 @@ impl Model { 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) { - if matches!(active, Active::Command { .. }) { - self.send_failed(now); - } else { - 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; + 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; @@ -173,15 +292,41 @@ impl Model { return Some(rpc::command_request(self.id, command.code, command.value)); } - if !due(now, self.next_poll) { - return None; + 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)); } - self.id = self.id.wrapping_add(1); - self.active = Some(Active::Snapshot { - id: self.id, - started: now, - }); - Some(rpc::snapshot_request(self.id)) + + None } /// Queue a playback or volume command and update the visible state immediately. @@ -236,15 +381,30 @@ impl Model { 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; + } } } - self.status = Status::Silent; - self.backoff = (self.backoff * 2).min(MAX_BACKOFF_MS); - self.rev += 1; } /// Handle one host message. @@ -283,6 +443,8 @@ impl Model { } } 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, } } @@ -315,6 +477,159 @@ impl Model { 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; @@ -353,8 +668,20 @@ impl Model { 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) { @@ -366,7 +693,7 @@ impl Model { } } - /// The cache blob. It holds non-personal playback state and volume only. + /// 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; @@ -390,7 +717,7 @@ impl Model { self.cache_dirty = false; } - /// Restore cached non-personal playback state. + /// 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; @@ -408,14 +735,22 @@ impl Model { /// Ms until the next request or timeout. pub fn wait(&self, now: u32) -> u32 { - let next = if let Some(active) = self.active { - started_at(active).wrapping_add(timeout_for(active)) - } else if self.command_len > 0 { - self.next_command.min(self.next_poll) - } else { - self.next_poll - }; - next.wrapping_sub(now).min(SNAPSHOT_TIMEOUT_MS) + 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 } } @@ -447,15 +782,30 @@ 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::Command { started, .. } => started, + 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, } } @@ -890,6 +1240,278 @@ mod tests { 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); diff --git a/apps/music-controller/src/ntype82.rs b/apps/music-controller/src/ntype82.rs new file mode 100644 index 0000000..12f6b1d --- /dev/null +++ b/apps/music-controller/src/ntype82.rs @@ -0,0 +1,2046 @@ +#![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 index 1f83b93..b7aa02f 100644 --- a/apps/music-controller/src/rpc.rs +++ b/apps/music-controller/src/rpc.rs @@ -4,11 +4,13 @@ //! 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. //! -//! Only non-personal playback state and music volume cross the BLE channel. Track names, artists, -//! notification text and artwork never do. +//! 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; @@ -28,12 +30,16 @@ 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. +/// 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 { @@ -41,11 +47,13 @@ impl Request { match self { Request::Snapshot(bytes) => bytes, Request::Command(bytes) => bytes, + Request::Artwork(bytes) => bytes, + Request::Track(bytes) => bytes, } } } -/// Requests the current non-personal playback state. +/// Requests the current playback state. pub fn snapshot_request(id: u8) -> Request { Request::Snapshot([b'M', b'1', b'Q', id, MUSIC_SNAPSHOT, 0]) } @@ -55,6 +63,21 @@ 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> { @@ -72,7 +95,8 @@ impl Reply<'_> { } } -/// A reply on this channel; anything else is ignored. +/// 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 @ ..] @@ -90,7 +114,7 @@ pub fn reply(message: &[u8]) -> Option> { } } -/// Non-personal playback state from the snapshot record. +/// Playback state from the snapshot record. #[derive(Clone, Copy, PartialEq, Eq)] #[cfg_attr(test, derive(Debug))] pub struct Metadata { @@ -186,6 +210,11 @@ mod tests { 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] diff --git a/apps/music-controller/src/track.rs b/apps/music-controller/src/track.rs new file mode 100644 index 0000000..8b83cf5 --- /dev/null +++ b/apps/music-controller/src/track.rs @@ -0,0 +1,67 @@ +//! 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 index e6f7881..d2305bc 100644 --- a/apps/music-controller/src/view.rs +++ b/apps/music-controller/src/view.rs @@ -1,30 +1,74 @@ -//! The watch screen: generic playback state, transport controls and a music-volume slider. +//! The full-screen watch face: artwork, large bordered transport controls and volume. //! -//! Track names, artists and artwork deliberately stay on the phone. The watch receives only whether -//! media is active/playing and the current music-stream 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 cmf_wp2_ui::color::{BLACK, Rgb}; -use cmf_wp2_ui::geom::text_box; -use cmf_wp2_ui::text::{centre, fitted}; -use cmf_wp2_ui::{C, SIZE, Surface}; - -const BLACK_U16: u16 = 0x0000; -const WHITE: u16 = 0xFFFF; -const GREY: u16 = 0x8C92; -const DIM: u16 = 0x52AB; -const ACCENT: u16 = 0xFA23; -const RED: u16 = 0xF213; -const STATUS_Y: i32 = 174; -const DETAIL_Y: i32 = 202; -const VOLUME_Y: i32 = 312; -const FOOTER_Y: i32 = 378; - -const PREV_X: i32 = 91; +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 = 375; -const CONTROL_Y: i32 = 250; -const CONTROL_R: i32 = 34; +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)] @@ -40,118 +84,173 @@ pub enum Action { } /// Maps a touch to a playback or volume action. -pub fn action(x: i32, y: i32, max_volume: u8) -> Action { - if (CONTROL_Y - CONTROL_R..CONTROL_Y + CONTROL_R).contains(&y) { - if (PREV_X - CONTROL_R..PREV_X + CONTROL_R).contains(&x) { - return Action::Previous; - } - if (PLAY_X - CONTROL_R..PLAY_X + CONTROL_R).contains(&x) { - return Action::Toggle; - } - if (NEXT_X - CONTROL_R..NEXT_X + CONTROL_R).contains(&x) { - return Action::Next; - } +pub fn action( + x: i32, + y: i32, + max_volume: u8, + controls_enabled: bool, + volume_enabled: bool, +) -> Action { + if !controls_enabled { + return Action::None; } - if (VOLUME_Y - 16..VOLUME_Y + 34).contains(&y) { - if x < 112 { + + 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 x > 354 { + if in_rect(x, y, PLUS_X, BUTTON_Y, BUTTON_SIZE, BUTTON_SIZE) { return Action::VolumeUp; } - if max_volume > 0 { - let value = ((x - 115).clamp(0, 236) * max_volume as i32 + 118) / 236; + 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) { - s.rect(0, 0, SIZE, SIZE, BLACK_U16); + 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) { - let (title, detail) = match m.status { - Status::Ask => ("Allow on your phone", "Open Music Companion"), - _ => ("No music access", "Allow it in Music Companion"), - }; - centre(s, C, 194, title, WHITE); - centre(s, C, 224, detail, GREY); + draw_permission(s, m.status); + draw_footer(s, m); return; } - let active = m.active(); - draw_music_mark(s, active); + draw_track_text(s, m); - let (state, colour) = if !active { - ("NO MEDIA", GREY) - } else if m.playing() { - ("PLAYING", ACCENT) - } else { - ("PAUSED", WHITE) - }; - centre(s, C, STATUS_Y, state, colour); - let detail = if active { - "Music session" - } else { - "Open a music app" - }; - centre(s, C, DETAIL_Y, detail, DIM); + 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); +} - transport(s, m.playing(), active); - volume(s, m.volume(), m.max_volume(), active); +/// 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; - let (footer, colour) = match m.status { - Status::Ask => ("Allow music on your phone", ACCENT), - Status::Denied => ("Music access denied", RED), - Status::Unavailable => ("Phone can't answer", ACCENT), - Status::Silent if m.has_snapshot => ("No phone reply - showing cached", ACCENT), - Status::Silent => ("Phone not answering", ACCENT), - Status::Waiting => ("Waiting for phone", DIM), - Status::Ok => ("Connected to phone", DIM), - }; - let (x, cells) = text_box(FOOTER_Y, 8); - fitted(s, x, FOOTER_Y, footer, cells, colour); + 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); } -/// Draws a generic two-note mark; it contains no information about the current track. -fn draw_music_mark(s: &mut impl Surface, active: bool) { +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) }; - s.rect(174, 72, 6, 52, colour); - s.rect(228, 62, 6, 62, colour); - s.rect(180, 72, 48, 6, colour); - s.rect(234, 62, 48, 6, colour); - cmf_wp2_ui::draw::disc(s, 171, 124, 12, fill, BLACK); - cmf_wp2_ui::draw::disc(s, 225, 114, 12, fill, BLACK); + + // 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 transport(s: &mut impl Surface, playing: bool, active: bool) { - let colour = if active { WHITE } else { DIM }; - let icon_colour = if active { BLACK_U16 } else { DIM }; - // The focused play/pause button has a stock accent disc behind it. - if active { - cmf_wp2_ui::draw::disc(s, PLAY_X, CONTROL_Y, 28, Rgb(250, 35, 0), BLACK); +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 - 10, CONTROL_Y - 11, 4, 22, colour); - triangle_left(s, PREV_X + 11, CONTROL_Y, 12, 11, colour); + 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 - 10, CONTROL_Y, 12, 11, colour); - s.rect(NEXT_X + 7, CONTROL_Y - 11, 4, 22, colour); + 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 - 7, CONTROL_Y - 13, 5, 26, icon_colour); - s.rect(PLAY_X + 2, CONTROL_Y - 13, 5, 26, icon_colour); + 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 - 7, CONTROL_Y, 14, 14, icon_colour); + 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, @@ -188,21 +287,119 @@ fn triangle_right( } } -fn volume(s: &mut impl Surface, value: u8, max: u8, active: bool) { - let colour = if active { WHITE } else { DIM }; - s.rect(115, VOLUME_Y, 236, 5, DIM); +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 * 236) / max as i32).clamp(0, 236); - s.rect(115, VOLUME_Y, width, 5, ACCENT); + 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), + ); } - s.rect(87, VOLUME_Y - 11, 15, 3, colour); - s.rect(99, VOLUME_Y - 17, 3, 15, colour); - s.rect(364, VOLUME_Y - 11, 15, 3, colour); - s.rect(364, VOLUME_Y - 17, 3, 15, colour); let mut percent = crate::model::Buf::<8>::new(); crate::model::percent(&mut percent, value, max); - centre(s, C, VOLUME_Y + 17, percent.as_str(), colour); + 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)] @@ -211,16 +408,51 @@ mod tests { 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(); - frame(&mut fb, &m); - m.status = Status::Ask; - frame(&mut fb, &m); - m.status = Status::Denied; - frame(&mut fb, &m); + 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); @@ -232,32 +464,87 @@ mod tests { } #[test] - fn controls_have_distinct_touch_targets() { - assert_eq!(action(PREV_X, CONTROL_Y, 15), Action::Previous); - assert_eq!(action(PLAY_X, CONTROL_Y, 15), Action::Toggle); - assert_eq!(action(NEXT_X, CONTROL_Y, 15), Action::Next); - assert_eq!(action(75, VOLUME_Y, 15), Action::VolumeDown); - assert_eq!(action(390, VOLUME_Y, 15), Action::VolumeUp); - assert_eq!(action(C, VOLUME_Y, 15), Action::SetVolume(8)); - assert_eq!(action(C, VOLUME_Y, 0), Action::None); + 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 transport_triangles_point_in_the_right_direction() { - let mut px = vec![0u16; (SIZE * SIZE) as usize]; - let mut fb = Fb::new(&mut px); - triangle_left(&mut fb, 100, 100, 12, 11, WHITE); - assert_eq!(fb.at(88, 100), WHITE); - assert_eq!(fb.at(99, 100), WHITE); - assert_eq!(fb.at(100, 100), 0); - assert_eq!(fb.at(87, 100), 0); - assert_eq!(fb.at(99, 89), WHITE); + 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); - triangle_right(&mut fb, 100, 100, 12, 11, WHITE); - assert_eq!(fb.at(100, 100), WHITE); - assert_eq!(fb.at(111, 100), WHITE); - assert_eq!(fb.at(112, 100), 0); + 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 index 4f1a95a..827cb16 100644 --- a/apps/music-controller/store.md +++ b/apps/music-controller/store.md @@ -1,8 +1,8 @@ -Control music playback and the phone's music-stream volume from the watch. +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 shows the current track and its notification artwork on the phone. To protect privacy, only generic playback state and volume are sent to the watch; the title, artist and artwork never cross the watch's Bluetooth link. Anyone close enough to read that link can therefore see only whether media is playing and the volume level. +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.1.1 companion APK](https://github.com/boxmol71-gif/music-companion/releases/download/v0.1.1/MusicCompanion-0.1.1-debug.apk), then enable its watch bridge and grant notification-listener access. +- 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 index 12cc6f3..707d8e8 100644 --- a/apps/music-controller/store.toml +++ b/apps/music-controller/store.toml @@ -1,5 +1,5 @@ name = "Music Controller" -summary = "Private playback and music-volume controls" -version = "0.1.1" +summary = "Track artwork, details, and music controls" +version = "0.2.0" author = "CMF Tech Community" screenshots = ["shots/playing.png", "shots/waiting.png"]