fix some little stinks

This commit is contained in:
Alex Janka 2023-02-08 10:43:00 +11:00
parent 2346b6c661
commit 2dab3623e9

View file

@ -367,7 +367,7 @@ impl CPU {
fn render_object(&mut self, scanline: u8, object: Object, obj_size: &ObjSize) { fn render_object(&mut self, scanline: u8, object: Object, obj_size: &ObjSize) {
let mut object_row = scanline - object.y; let mut object_row = scanline - object.y;
if object.flags.y_flip { 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_row = object_row % 8;
let tile_addr = TiledataArea::D8000 let tile_addr = TiledataArea::D8000
@ -380,7 +380,11 @@ impl CPU {
let lsb = get_bit(lsbs, x_addr); let lsb = get_bit(lsbs, x_addr);
let msb = get_bit(msbs, x_addr); let msb = get_bit(msbs, x_addr);
let colour = bits_to_mapped_colour(lsb, msb, object.flags.palette); 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 { if x_coord < WIDTH {
self.gpu.buffer[(scanline as usize * WIDTH) + x_coord] = colour.to_rgb(); self.gpu.buffer[(scanline as usize * WIDTH) + x_coord] = colour.to_rgb();
} }