From 65e65be0eba9bad57f1ddfa78dfcc222f47f0f28 Mon Sep 17 00:00:00 2001 From: Kevin Hamacher Date: Fri, 21 Feb 2020 18:50:57 +0100 Subject: [PATCH] Trying to implement some y-mirroring --- src/display/mod.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/display/mod.rs b/src/display/mod.rs index d6742c4..a5eb886 100644 --- a/src/display/mod.rs +++ b/src/display/mod.rs @@ -449,7 +449,6 @@ impl Display { // Calculate correct coords let x: u8 = sprite.x.wrapping_sub(8); - // Flip sprite, TODO: What does this do in WIDE mode? let y: u8 = sprite.y.wrapping_sub(16); let render_y = self.curline; @@ -457,13 +456,14 @@ impl Display { let wide_mode = self.control & CTRL_BG_SPRITE_SIZE > 0; let actual_h = if wide_mode { 16 } else { 8 }; - if sprite.is_y_flipped() { - eprintln!("Sorry, no y flip support yet, rendering as-is"); - } - if y.wrapping_add(actual_h) > render_y && y <= render_y { num_rendered += 1; - let tile_offset_y: usize = render_y as usize - y as usize; + let tile_offset_y = if sprite.is_y_flipped() { + render_y as usize - (y as usize) ^ (actual_h as usize - 1) + } else { + render_y as usize - y as usize + }; + let tile_base_addr: usize = sprite.tile as usize * 16; let tile_addr = tile_base_addr + tile_offset_y * 2;