From 2dab3623e9897bb911dc4a61bfed7884adb94f10 Mon Sep 17 00:00:00 2001 From: Alex Janka Date: Wed, 8 Feb 2023 10:43:00 +1100 Subject: [PATCH] fix some little stinks --- src/processor/gpu.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/processor/gpu.rs b/src/processor/gpu.rs index 855f933..3622d82 100644 --- a/src/processor/gpu.rs +++ b/src/processor/gpu.rs @@ -367,7 +367,7 @@ impl CPU { fn render_object(&mut self, scanline: u8, object: Object, obj_size: &ObjSize) { let mut object_row = scanline - object.y; if object.flags.y_flip { - object_row = obj_size.get_height() - object_row; + object_row = obj_size.get_height() - (object_row + 1); } let tile_row = object_row % 8; let tile_addr = TiledataArea::D8000 @@ -380,7 +380,11 @@ impl CPU { let lsb = get_bit(lsbs, x_addr); let msb = get_bit(msbs, x_addr); let colour = bits_to_mapped_colour(lsb, msb, object.flags.palette); - let x_coord = (object.x as usize) + (px_x as usize); + let x_coord_uncorrected = (object.x as usize) + (px_x as usize); + if x_coord_uncorrected < 8 { + continue; + } + let x_coord = x_coord_uncorrected - 8; if x_coord < WIDTH { self.gpu.buffer[(scanline as usize * WIDTH) + x_coord] = colour.to_rgb(); }