gbc: Implement background priority bit
This commit is contained in:
parent
1890dd2d3a
commit
515321110b
@ -491,6 +491,10 @@ impl Display {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if pixel_origin == PixelOrigin::BackgroundPriority {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
let x_maybe_flipped: u8 = if sprite.is_x_flipped() { x_o ^ 7 } else { x_o };
|
let x_maybe_flipped: u8 = if sprite.is_x_flipped() { x_o ^ 7 } else { x_o };
|
||||||
b1 = (tile_line_1 & 1 << (7 - x_o)) > 0;
|
b1 = (tile_line_1 & 1 << (7 - x_o)) > 0;
|
||||||
b2 = (tile_line_2 & 1 << (7 - x_o)) > 0;
|
b2 = (tile_line_2 & 1 << (7 - x_o)) > 0;
|
||||||
@ -599,7 +603,6 @@ impl Display {
|
|||||||
let bg_attribs = BgMapAttributes(self.vram1[vram_offset]);
|
let bg_attribs = BgMapAttributes(self.vram1[vram_offset]);
|
||||||
let vram = [&*self.vram0, &*self.vram1][bg_attribs.vram_bank_number()];
|
let vram = [&*self.vram0, &*self.vram1][bg_attribs.vram_bank_number()];
|
||||||
|
|
||||||
// TODO: Priority
|
|
||||||
let tile_offset_y = if bg_attribs.vertical_flip() {
|
let tile_offset_y = if bg_attribs.vertical_flip() {
|
||||||
7 ^ tile_offset_y
|
7 ^ tile_offset_y
|
||||||
} else {
|
} else {
|
||||||
@ -631,9 +634,13 @@ impl Display {
|
|||||||
let c = ((b2 as u8) * 2 + b1 as u8) as usize;
|
let c = ((b2 as u8) * 2 + b1 as u8) as usize;
|
||||||
// let color = self.background_palette.get_color(c);
|
// let color = self.background_palette.get_color(c);
|
||||||
let color = self.background_palette_cgb[bg_attribs.palette_number()].get_color(c);
|
let color = self.background_palette_cgb[bg_attribs.palette_number()].get_color(c);
|
||||||
|
if bg_attribs.has_priority() && (self.control & 1) == 1 {
|
||||||
|
self.set_pixel(render_x, render_y, color, PixelOrigin::BackgroundPriority);
|
||||||
|
} else {
|
||||||
self.set_pixel(render_x, render_y, color, PixelOrigin::Background(c));
|
self.set_pixel(render_x, render_y, color, PixelOrigin::Background(c));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (self.control & CTRL_WND_DISPLAY_ENABLE) == CTRL_WND_DISPLAY_ENABLE {
|
if (self.control & CTRL_WND_DISPLAY_ENABLE) == CTRL_WND_DISPLAY_ENABLE {
|
||||||
// Draw 'window' over the background.
|
// Draw 'window' over the background.
|
||||||
|
|||||||
@ -27,6 +27,7 @@ impl BgMapAttributes {
|
|||||||
pub enum PixelOrigin {
|
pub enum PixelOrigin {
|
||||||
Empty,
|
Empty,
|
||||||
Background(usize),
|
Background(usize),
|
||||||
|
BackgroundPriority,
|
||||||
Window,
|
Window,
|
||||||
Sprite,
|
Sprite,
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user