better gpu?
This commit is contained in:
parent
e70e8d6ce5
commit
78bb6fc65f
|
@ -24,6 +24,7 @@ pub struct Gpu {
|
|||
pub vram: Vram,
|
||||
pub oam: Oam,
|
||||
pub window: Box<dyn Renderer>,
|
||||
is_bg_zero: Vec<bool>,
|
||||
lcdc: Lcdc,
|
||||
stat: Stat,
|
||||
mode_clock: usize,
|
||||
|
@ -55,6 +56,7 @@ impl Gpu {
|
|||
vram: Vram::default(),
|
||||
oam: Oam::default(),
|
||||
window,
|
||||
is_bg_zero: vec![true; WIDTH],
|
||||
lcdc: Lcdc::default(),
|
||||
stat: Stat::default(),
|
||||
mode_clock: 0,
|
||||
|
@ -153,6 +155,9 @@ impl Gpu {
|
|||
}
|
||||
|
||||
fn render_scanline(&mut self, scanline: u8) {
|
||||
for e in &mut self.is_bg_zero {
|
||||
*e = true;
|
||||
}
|
||||
for x in 0..WIDTH {
|
||||
self.buffer[(scanline as usize * WIDTH) + x] = Colour::from_u8_rgb(255, 0, 255);
|
||||
}
|
||||
|
@ -292,9 +297,7 @@ impl Gpu {
|
|||
let x_coord = x_coord_uncorrected - 8;
|
||||
if x_coord < WIDTH {
|
||||
let buffer_index = (scanline as usize * WIDTH) + x_coord;
|
||||
if !object.flags.behind_bg_and_window
|
||||
|| self.buffer[buffer_index] == self.bg_palette.zero.as_rgb()
|
||||
{
|
||||
if !object.flags.behind_bg_and_window || self.is_bg_zero[x_coord] {
|
||||
self.buffer[buffer_index] = colour.as_rgb();
|
||||
}
|
||||
}
|
||||
|
@ -340,6 +343,10 @@ impl Gpu {
|
|||
let msb = get_bit(msbs, 7 - tile_px_x);
|
||||
let colour = self.bg_palette.map_bits(lsb, msb);
|
||||
|
||||
if lsb || msb {
|
||||
self.is_bg_zero[x] = false;
|
||||
}
|
||||
|
||||
self.buffer[(scanline as usize * WIDTH) + x] = colour.as_rgb();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -125,7 +125,7 @@ impl Colour {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub(super) struct Palette {
|
||||
pub(super) zero: Colour,
|
||||
pub(super) one: Colour,
|
||||
|
|
Loading…
Reference in a new issue