diff --git a/Cargo.lock b/Cargo.lock index 2a13fc4..d0c8d2c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -197,6 +197,7 @@ dependencies = [ "byteorder", "cfg-if 0.1.10", "chrono", + "either", "futures", "futures-executor", "gdbstub", @@ -315,6 +316,12 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" +[[package]] +name = "either" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" + [[package]] name = "env_logger" version = "0.6.2" diff --git a/clicky-core/Cargo.toml b/clicky-core/Cargo.toml index 0bf136b..0778b71 100644 --- a/clicky-core/Cargo.toml +++ b/clicky-core/Cargo.toml @@ -17,6 +17,7 @@ bytemuck = "1.2" byteorder = "1.3" cfg-if = "0.1" chrono = "0.4" +either = "1.9.0" log = "0.4" num_enum = "0.5" static_assertions = "1.1" diff --git a/clicky-core/src/devices/display/hd66753.rs b/clicky-core/src/devices/display/hd66753.rs index 9916c57..a7230b0 100644 --- a/clicky-core/src/devices/display/hd66753.rs +++ b/clicky-core/src/devices/display/hd66753.rs @@ -4,6 +4,8 @@ use std::sync::{Arc, RwLock}; use crate::gui::RenderCallback; +use either::Either; + const CGRAM_WIDTH: usize = 168; const CGRAM_HEIGHT: usize = 132; #[allow(dead_code)] @@ -155,15 +157,22 @@ impl Hd66753 { }; let cgram_window = cgram - .chunks_exact(EMU_CGRAM_WIDTH * 2 / 8 / 2) - .take(height) - .flat_map(|row| row.iter().take(CGRAM_WIDTH * 2 / 8 / 2).rev()); + .chunks_exact(EMU_CGRAM_WIDTH * 2 / 8 / 2) + .take(height) + .flat_map(|row| { + match ireg.sgs { + true => Either::Left(row.iter().take(CGRAM_WIDTH * 2 / 8 / 2)), + false => Either::Right(row.iter().take(CGRAM_WIDTH * 2 / 8 / 2).rev()), + } + + }); // TODO: implement cursor control let new_buf = cgram_window.flat_map(|w| { // every 16 bits = 8 pixels - (0..8).rev().map(move |i| { + (0..8).map(move |i| { + let i = if ireg.sgs { i } else { 7 - i }; let idx = ((w >> (i * 2)) & 0b11) as usize; if ireg.rev { PALETTE[idx]