This commit is contained in:
Alex Janka 2023-07-18 13:44:35 +10:00
parent 36b50b8c55
commit f4f97982ce

View file

@ -68,17 +68,14 @@ where
let tile_window = tile_window_renderer
.map(|tile_window_renderer| TileWindow::new(tile_window_renderer, cgb));
let blank_colour: ColourFormat = if cgb {
rgb_from_bytes(0xFFFF).into()
} else {
ColourInner::Error.rgb_bytes(None).into()
};
let buffer = [blank_colour; WIDTH * HEIGHT];
let buffer = [get_blank_colour(cgb); WIDTH * HEIGHT];
let layer_window = layer_window_renderer.map(|mut layer_window_renderer| {
layer_window_renderer.prepare(WIDTH, HEIGHT * 3);
(layer_window_renderer, [blank_colour; WIDTH * HEIGHT * 3])
(
layer_window_renderer,
[get_blank_colour(cgb); WIDTH * HEIGHT * 3],
)
});
Self {
@ -486,14 +483,21 @@ where
self.window.display(&self.buffer);
if let Some((ref mut window, ref mut buffer)) = self.layer_window {
window.display(buffer);
let blank_colour: ColourFormat = if self.cgb_data.is_some() {
rgb_from_bytes(0xFFFF).into()
} else {
ColourInner::Error.rgb_bytes(None).into()
};
for val in buffer {
*val = blank_colour;
*val = get_blank_colour(self.cgb_data.is_some());
}
}
}
}
fn get_blank_colour<ColourFormat>(cgb: bool) -> ColourFormat
where
ColourFormat: From<Colour> + Copy,
{
if cgb {
rgb_from_bytes(0xFFFF).into()
} else {
ColourInner::Error.rgb_bytes(None).into()
}
}