Animatrix sim: fixxess

This commit is contained in:
Luke D. Jones
2023-06-24 22:02:21 +12:00
parent d3aababef5
commit 7796ba0603
2 changed files with 56 additions and 42 deletions

View File

@@ -1,33 +1,33 @@
use super::Row; use super::Row;
pub const GA402: [Row; 62] = [ pub const GA402: [Row; 63] = [
Row(0x01, 7 + 1, 34, 0), Row(0x01, 7, 32, 0),
Row(0x01, 7 + 35, 34, 0), Row(0x01, 7 + 34, 32, 0),
Row(0x01, 7 + 69, 34, 0), Row(0x01, 7 + 68, 32, 0),
Row(0x01, 7 + 103, 34, 0), Row(0x01, 7 + 102, 32, 0),
Row(0x01, 7 + 137, 34, 0), Row(0x01, 7 + 136, 32, 0),
Row(0x01, 7 + 171, 34, 0), Row(0x01, 7 + 170, 34, 0),
Row(0x01, 7 + 205, 34, 0), Row(0x01, 7 + 204, 34, 0), // off by 1?
Row(0x01, 7 + 239, 34, 0), Row(0x01, 7 + 238, 34, 0),
Row(0x01, 7 + 273, 34, 0), Row(0x01, 7 + 272, 34, 0),
Row(0x01, 7 + 307, 34, 0), Row(0x01, 7 + 306, 34, 0),
Row(0x01, 7 + 341, 34, 0), Row(0x01, 7 + 340, 34, 0),
Row(0x01, 7 + 375, 34, 0), // 12 Row(0x01, 7 + 374, 34, 0), // 12
Row(0x01, 7 + 409, 33, 1), Row(0x01, 7 + 408, 33, 1),
Row(0x01, 7 + 442, 33, 2), Row(0x01, 7 + 441, 33, 1),
Row(0x01, 7 + 475, 32, 2), Row(0x01, 7 + 474, 32, 2),
Row(0x01, 7 + 507, 32, 3), Row(0x01, 7 + 506, 32, 2),
Row(0x01, 7 + 539, 31, 3), // Row(0x01, 7 + 538, 31, 3), //
Row(0x01, 7 + 570, 31, 4), Row(0x01, 7 + 569, 31, 3),
Row(0x01, 7 + 601, 31, 4), // Row(0x01, 7 + 600, 28, 4), //
// //
Row(0x74, 7 + 1, 3, 31), // adds to end of previous Row(0x74, 7 + 1, 3, 28 + 4), // adds to end of previous
Row(0x74, 7 + 4, 30, 5), Row(0x74, 7 + 3, 30, 4),
Row(0x74, 7 + 34, 29, 6), Row(0x74, 7 + 33, 29, 5),
Row(0x74, 7 + 63, 29, 6), Row(0x74, 7 + 62, 29, 5),
Row(0x74, 7 + 92, 28, 7), Row(0x74, 7 + 91, 28, 6),
Row(0x74, 7 + 120, 28, 7), Row(0x74, 7 + 119, 28, 6),
Row(0x74, 7 + 148, 27, 8), Row(0x74, 7 + 147, 27, 7), // WEIRD OFFSET
Row(0x74, 7 + 175, 27, 8), Row(0x74, 7 + 175, 27, 8),
Row(0x74, 7 + 202, 26, 9), Row(0x74, 7 + 202, 26, 9),
Row(0x74, 7 + 228, 26, 9), Row(0x74, 7 + 228, 26, 9),
@@ -50,19 +50,20 @@ pub const GA402: [Row; 62] = [
Row(0x74, 7 + 598, 17, 18), Row(0x74, 7 + 598, 17, 18),
Row(0x74, 7 + 615, 13, 18), Row(0x74, 7 + 615, 13, 18),
// //
Row(0xe7, 7 + 1, 4, 18 + 13), // adds to end of previous Row(0xe7, 7 + 1, 4, 13 + 18), // adds to end of previous
Row(0xe7, 7 + 5, 16, 19), Row(0xe7, 7 + 5, 16, 19),
Row(0xe7, 7 + 21, 16, 19),
Row(0xe7, 7 + 37, 15, 20), Row(0xe7, 7 + 37, 15, 20),
Row(0xe7, 7 + 52, 15, 20), Row(0xe7, 7 + 52, 14, 20),
Row(0xe7, 7 + 67, 14, 21), Row(0xe7, 7 + 67, 13, 21),
Row(0xe7, 7 + 81, 14, 21), // Row(0xe7, 7 + 81, 11, 21), //
Row(0xe7, 7 + 95, 13, 22), Row(0xe7, 7 + 95, 13, 22),
Row(0xe7, 7 + 108, 13, 22), Row(0xe7, 7 + 108, 12, 22),
Row(0xe7, 7 + 121, 12, 23), Row(0xe7, 7 + 121, 12, 23),
Row(0xe7, 7 + 133, 12, 23), Row(0xe7, 7 + 133, 11, 23), // off the end of diag test
Row(0xe7, 7 + 145, 11, 24), Row(0xe7, 7 + 145, 11, 24),
Row(0xe7, 7 + 156, 11, 24), Row(0xe7, 7 + 156, 10, 24),
Row(0xe7, 7 + 167, 10, 25), Row(0xe7, 7 + 167, 10, 25),
Row(0xe7, 7 + 177, 10, 25), Row(0xe7, 7 + 177, 9, 25),
Row(0xe7, 7 + 187, 9, 26), Row(0xe7, 7 + 187, 8, 26),
]; ];

View File

@@ -138,7 +138,7 @@ fn main() -> Result<(), Box<dyn Error>> {
let video_subsystem = sdl_context.video().unwrap(); let video_subsystem = sdl_context.video().unwrap();
let window = video_subsystem let window = video_subsystem
.window("rust-sdl2 demo", 1000, 800) .window("rust-sdl2 demo", 1040, 680)
.position_centered() .position_centered()
.build() .build()
.unwrap(); .unwrap();
@@ -158,22 +158,35 @@ fn main() -> Result<(), Box<dyn Error>> {
let w = dev.animatrix.led_shape().horizontal * 6; let w = dev.animatrix.led_shape().horizontal * 6;
let h = dev.animatrix.led_shape().vertical * 6; let h = dev.animatrix.led_shape().vertical * 6;
let mut y_offset = 0;
for (y_count, row) in dev.animatrix.rows().iter().enumerate() { for (y_count, row) in dev.animatrix.rows().iter().enumerate() {
if row.0 == index { if row.0 == index {
let start = row.1; let start = row.1;
let end = start + row.2; let end = start + row.2;
if row.2 < 8 {
if index == 0x74 {
y_offset = 1;
} else if index == 0xe7 {
y_offset = 2;
}
}
for (x_count, b) in dev.buffer[start..=end].iter().enumerate() { for (x_count, b) in dev.buffer[start..=end].iter().enumerate() {
print!("{b},"); // print!("{b},");
canvas.set_draw_color(Color::RGB(*b as u8, *b as u8, *b as u8)); canvas.set_draw_color(Color::RGB(*b as u8, *b as u8, *b as u8));
let x = let x: i32 = w + x_count as i32 * w
x_count as i32 * w - if y_count % 2 == 0 { 0 } else { w / 2 } + row.3 * w; - if (y_count + y_offset as usize) % 2 != 0 {
let y = y_count as i32 * h; 0
} else {
w / 2
}
+ row.3 * w;
let y = y_count as i32 * h - y_offset * h;
canvas canvas
.fill_rect(Rect::new(x, y, w as u32, h as u32)) .fill_rect(Rect::new(x, y, w as u32, h as u32))
.unwrap(); .unwrap();
} }
println!(); // println!();
} }
} }