tile window shows greyscale

This commit is contained in:
Alex Janka 2023-04-24 20:17:54 +10:00
parent 2eae8875ca
commit 224c850a7d
2 changed files with 6 additions and 22 deletions

View file

@ -309,12 +309,7 @@ where
self.has_window_been_enabled = false; self.has_window_been_enabled = false;
let is_cgb_mode = self.is_cgb_mode(); let is_cgb_mode = self.is_cgb_mode();
if let Some(tile_window) = &mut self.tile_window { if let Some(tile_window) = &mut self.tile_window {
tile_window.draw_sprite_window( tile_window.draw_sprite_window(self.bg_palette, &self.vram, is_cgb_mode);
self.bg_palette,
&self.vram,
is_cgb_mode,
self.cgb_data.as_ref().map(|v| v.palettes.bg),
);
} }
} }

View file

@ -5,8 +5,7 @@ use crate::{
}; };
use super::{ use super::{
cgb::CgbPalette, types::{BgAttributes, ColourInner, Vram},
types::{BgAttributes, ColourInner, Vram, VramBank},
Colour, Colour,
}; };
@ -39,7 +38,6 @@ where
palette: Palette, palette: Palette,
memory: &Vram, memory: &Vram,
is_cgb_mode: bool, is_cgb_mode: bool,
cgb_data: Option<CgbPalette>,
) { ) {
for tile_y in 0..16 { for tile_y in 0..16 {
self.draw_row( self.draw_row(
@ -49,7 +47,6 @@ where
palette, palette,
memory, memory,
is_cgb_mode, is_cgb_mode,
cgb_data,
); );
} }
for tile_y in 0..8 { for tile_y in 0..8 {
@ -60,7 +57,6 @@ where
palette, palette,
memory, memory,
is_cgb_mode, is_cgb_mode,
cgb_data,
); );
} }
@ -76,18 +72,12 @@ where
palette: Palette, palette: Palette,
memory: &Vram, memory: &Vram,
is_cgb_mode: bool, is_cgb_mode: bool,
cgb_data: Option<CgbPalette>,
) { ) {
for tile_x in 0..16 { for tile_x in 0..16 {
let tile_num = (tile_y * 16) + tile_x; let tile_num = (tile_y * 16) + tile_x;
let data_begin = area.get_addr(tile_num); let data_begin = area.get_addr(tile_num);
let attributes = if is_cgb_mode { let attributes = BgAttributes::default();
memory
.get_with_bank(data_begin, VramBank::Bank1)
.map_or(BgAttributes::default(), BgAttributes::from_byte)
} else {
BgAttributes::default()
};
for px_y in 0..8_u16 { for px_y in 0..8_u16 {
let lsbs = memory let lsbs = memory
.get_with_bank((data_begin + (px_y * 2)).unwrap(), attributes.tile_bank) .get_with_bank((data_begin + (px_y * 2)).unwrap(), attributes.tile_bank)
@ -109,9 +99,8 @@ where
palette.map_bits(lsb, msb).0 palette.map_bits(lsb, msb).0
}; };
self.sprite_buffer[real_px_x + (real_px_y * TILE_WINDOW_WIDTH)] = colour self.sprite_buffer[real_px_x + (real_px_y * TILE_WINDOW_WIDTH)] =
.rgb_bytes(cgb_data.map(|v| (v, attributes.palette)), is_cgb_mode) colour.rgb_bytes(None, is_cgb_mode).into();
.into();
} }
} }
} }