Graphics
One of the appeals to me of writing the 2022 version of Quinti-Maze in embedded Rust is that there is a graphics crate, embedded-graphics, that is not too different from what existed in 1982. An added bonus is that it already has support for the LCD display I had laying around. But the real kicker is its desktop simulator,
I recall when I wrote Quinti-Maze I’d not yet learned trigonometry to calculate how to draw the 3D view of the maze. Instead, I drew out what looked decent to me on some graph paper and figured out the vertices of the features by counting.
In order to maintain that classic 1982 Quinti-Maze look, and because I either never learned or don’t recall how to do it correctly, I’m drawing in 2022 by mapping the individual vertices from their position on the Apple II’s 280 x 192 Hi-Res graphics. This mapping is done at compile-time, though constant expressions and four macro rules macros to get around the limitations in Rust with const functions and floating point expressions.
macro_rules! map_x_to_ratio {
($value:expr) => {
$value / ORIGINAL_SCREEN_SIZE.width as f32
};
}
macro_rules! map_y_to_ratio {
($value:expr) => {
$value / ORIGINAL_SCREEN_SIZE.height as f32
};
}
macro_rules! map_x_to_screen {
($value:expr) => {
(SCREEN_SIZE.width as f32 * $value + 0.9) as i32
};
}
macro_rules! map_y_to_screen {
($value:expr) => {
(SCREEN_SIZE.height as f32 * $value + 0.9) as i32
};
}