feat(demo): exercise affine transforms and raster distortion
This commit is contained in:
parent
169fab9bf6
commit
cf9ee0ca65
2 changed files with 282 additions and 0 deletions
40
src/affine_raster_demo.rs
Normal file
40
src/affine_raster_demo.rs
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
//! CPU-driven affine raster distortion. HBlank DMA changes BG2PB for the next
|
||||
//! line transition; internal origins accumulate the resulting horizontal shifts.
|
||||
|
||||
use crate::{
|
||||
graphics_demo::{GraphicsDemo, GraphicsError},
|
||||
input::Buttons,
|
||||
machine::Machine,
|
||||
memory::MemoryError,
|
||||
video::Framebuffer,
|
||||
};
|
||||
|
||||
/// Completed updates and signed pan X/Y, as three debug words.
|
||||
pub const AFFINE_RASTER_STATE: u32 = crate::affine_demo::AFFINE_STATE;
|
||||
/// 160 halfwords generated by ARM code during each VBlank.
|
||||
pub const AFFINE_RASTER_TABLE: u32 = 0x0200_1000;
|
||||
|
||||
pub struct AffineRasterDemo {
|
||||
runner: GraphicsDemo,
|
||||
}
|
||||
|
||||
impl AffineRasterDemo {
|
||||
pub fn new() -> Result<Self, MemoryError> {
|
||||
Ok(Self {
|
||||
runner: GraphicsDemo::with_program(crate::affine_demo::raster_program())?,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn machine(&self) -> &Machine {
|
||||
self.runner.machine()
|
||||
}
|
||||
|
||||
/// Arrows pan; Q rotates; W zooms; Z bypasses raster distortion; Enter resets pan.
|
||||
pub fn frame(
|
||||
&mut self,
|
||||
buttons: Buttons,
|
||||
output: &mut Framebuffer,
|
||||
) -> Result<usize, GraphicsError> {
|
||||
self.runner.frame_with_control(buttons, output, 0x402)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue