From c6a447d5549f0b8febe25d9fddf8af0f1d6c8d56 Mon Sep 17 00:00:00 2001 From: 0xrsydn Date: Mon, 5 Oct 2026 12:55:35 +0700 Subject: [PATCH] feat(demo): exercise background and sprite mosaic controls --- src/mosaic_demo.rs | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/mosaic_demo.rs diff --git a/src/mosaic_demo.rs b/src/mosaic_demo.rs new file mode 100644 index 0000000..58507d8 --- /dev/null +++ b/src/mosaic_demo.rs @@ -0,0 +1,39 @@ +//! Original tile scene with CPU-controlled background and sprite mosaic sizes. + +use crate::{ + graphics_demo::{GraphicsDemo, GraphicsError}, + input::Buttons, + machine::Machine, + memory::MemoryError, + video::Framebuffer, +}; + +/// Completed updates and nine-bit horizontal/vertical scroll, as three words. +pub const MOSAIC_STATE: u32 = crate::tile_demo::TILE_STATE; + +pub struct MosaicDemo { + runner: GraphicsDemo, +} + +impl MosaicDemo { + pub fn new() -> Result { + Ok(Self { + runner: GraphicsDemo::with_program(crate::tile_demo::mosaic_program())?, + }) + } + + pub fn machine(&self) -> &Machine { + self.runner.machine() + } + + /// Block dimensions cycle from 1 to 16 pixels, changing every eight updates. + /// Z bypasses BG mosaic; X bypasses OBJ mosaic. Q/W rotate/zoom the sprite. + /// Arrows scroll; Enter resets scrolling. The host only supplies input. + pub fn frame( + &mut self, + buttons: Buttons, + output: &mut Framebuffer, + ) -> Result { + self.runner.frame_with_control(buttons, output, 0x1340) + } +}