From bb409f27b1dd33767f47bf8f53991aeeff634aaf Mon Sep 17 00:00:00 2001 From: 0xrsydn Date: Mon, 5 Oct 2026 12:55:35 +0700 Subject: [PATCH] feat(demo): exercise windows blending and brightness --- src/effects_demo.rs | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/effects_demo.rs diff --git a/src/effects_demo.rs b/src/effects_demo.rs new file mode 100644 index 0000000..c241431 --- /dev/null +++ b/src/effects_demo.rs @@ -0,0 +1,40 @@ +//! Original CPU-driven window and color-effects scene, based on the tile demo. +//! The CPU writes window bounds and effect registers during each VBlank. + +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 EFFECTS_STATE: u32 = crate::tile_demo::TILE_STATE; + +pub struct EffectsDemo { + runner: GraphicsDemo, +} + +impl EffectsDemo { + pub fn new() -> Result { + Ok(Self { + runner: GraphicsDemo::with_program(crate::tile_demo::effects_program())?, + }) + } + + pub fn machine(&self) -> &Machine { + self.runner.machine() + } + + /// Arrows scroll and move WIN0. Z selects alpha; X selects darkening. + /// Otherwise the area outside WIN0 is brightened. Enter resets scrolling. + /// Q/W retain the tile demo's sprite rotation and zoom controls. + pub fn frame( + &mut self, + buttons: Buttons, + output: &mut Framebuffer, + ) -> Result { + self.runner.frame_with_control(buttons, output, 0x3340) + } +}