minor gpu improvements
This commit is contained in:
parent
6eb791ebf4
commit
96af4b94a1
|
@ -169,7 +169,7 @@ impl CPU {
|
||||||
let mode_1_vblank_enabled = get_bit(stat, 4);
|
let mode_1_vblank_enabled = get_bit(stat, 4);
|
||||||
let mode_0_hblank_enabled = get_bit(stat, 3);
|
let mode_0_hblank_enabled = get_bit(stat, 3);
|
||||||
|
|
||||||
let lyc_eq_ly = self.memory.get(0xFF44) == self.memory.get(0xFF45);
|
let lyc_eq_ly = self.gpu.scanline == self.memory.get(0xFF45);
|
||||||
let mode_2 = self.gpu.mode == DrawMode::Mode2;
|
let mode_2 = self.gpu.mode == DrawMode::Mode2;
|
||||||
let mode_1_vblank = self.gpu.mode == DrawMode::VBlank;
|
let mode_1_vblank = self.gpu.mode == DrawMode::VBlank;
|
||||||
let mode_0_hblank = self.gpu.mode == DrawMode::HBlank;
|
let mode_0_hblank = self.gpu.mode == DrawMode::HBlank;
|
||||||
|
@ -232,18 +232,16 @@ impl CPU {
|
||||||
fn render_scanline_window(&mut self, scanline: u8, lcdc: &LCDC, palette: Palette) {
|
fn render_scanline_window(&mut self, scanline: u8, lcdc: &LCDC, palette: Palette) {
|
||||||
let pos_y = self.memory.get(0xFF4A);
|
let pos_y = self.memory.get(0xFF4A);
|
||||||
// subtracting 7 to get the Real Number...
|
// subtracting 7 to get the Real Number...
|
||||||
let pos_x = self.memory.get(0xFF4B).wrapping_sub(7);
|
let pos_x = self.memory.get(0xFF4B);
|
||||||
if pos_y < 143 && pos_x < 166 {
|
|
||||||
self.render_tiles(
|
self.render_tiles(
|
||||||
scanline,
|
scanline,
|
||||||
&lcdc.window_tilemap,
|
&lcdc.window_tilemap,
|
||||||
&lcdc.tile_area,
|
&lcdc.tile_area,
|
||||||
palette,
|
palette,
|
||||||
pos_x,
|
pos_x.wrapping_sub(7),
|
||||||
pos_y,
|
pos_y,
|
||||||
false,
|
false,
|
||||||
)
|
);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_scanline_obj(&mut self, scanline: u8, lcdc: &LCDC, bg_palette: Palette) {
|
fn render_scanline_obj(&mut self, scanline: u8, lcdc: &LCDC, bg_palette: Palette) {
|
||||||
|
@ -304,6 +302,9 @@ 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);
|
||||||
|
if colour == object.flags.palette.zero {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
let x_coord_uncorrected = (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 {
|
if x_coord_uncorrected < 8 {
|
||||||
continue;
|
continue;
|
||||||
|
@ -331,7 +332,7 @@ impl CPU {
|
||||||
wrap: bool,
|
wrap: bool,
|
||||||
) {
|
) {
|
||||||
let tile_line_y = scanline.wrapping_add(offset_y);
|
let tile_line_y = scanline.wrapping_add(offset_y);
|
||||||
if (scanline as usize + offset_y as usize) % 0xFF > 0 && !wrap {
|
if ((scanline as usize + offset_y as usize) / 0xFF) > 0 && !wrap {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let tilemap_row = tile_line_y / 8;
|
let tilemap_row = tile_line_y / 8;
|
||||||
|
|
|
@ -65,7 +65,7 @@ pub(super) struct LCDC {
|
||||||
pub(super) bg_window_enable: bool,
|
pub(super) bg_window_enable: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug)]
|
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||||
pub(super) enum Colour {
|
pub(super) enum Colour {
|
||||||
White,
|
White,
|
||||||
LightGray,
|
LightGray,
|
||||||
|
|
Loading…
Reference in a new issue