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(); }