Skip to content

Commit

Permalink
hd66753: Implement SGS drawing logic
Browse files Browse the repository at this point in the history
It seems like iPod 4G diagnostics plays with the SGS bit, causing
reversed display. Implementing this resolves the horizontally inverted
display on the diagnostics screen.
  • Loading branch information
Jean THOMAS committed Feb 5, 2024
1 parent 7cef5cf commit 9be591b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions clicky-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
17 changes: 13 additions & 4 deletions clicky-core/src/devices/display/hd66753.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -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]
Expand Down

0 comments on commit 9be591b

Please sign in to comment.