ppu: Fix window
This commit is contained in:
parent
bdf51448f7
commit
b7c1d9b8a0
@ -843,17 +843,24 @@ impl Display {
|
||||
if (self.control & CTRL_WND_DISPLAY_ENABLE) == CTRL_WND_DISPLAY_ENABLE {
|
||||
// Draw 'window' over the background.
|
||||
// Screen coordinates of the top left corner are WX-7, WY
|
||||
// Quick check if the window is visible at all.
|
||||
if self.windowx < 167 && self.windowy < 144 {
|
||||
//let rx = self.windowx.wrapping_add(7);
|
||||
let rx = 7u8.wrapping_sub(self.windowx);
|
||||
let ry = render_y.wrapping_add(self.windowy);
|
||||
for r_x in 0..160u8 {
|
||||
let render_x = r_x.wrapping_add(rx);
|
||||
let window_y_offset = render_y as i16 - self.windowy as i16;
|
||||
if self.windowx < 7 {
|
||||
eprintln!("Window X position < 7, bailing out");
|
||||
} else if window_y_offset >= 144 || window_y_offset < 0 {
|
||||
// Not visible
|
||||
} else {
|
||||
let window_y_offset = window_y_offset as u8;
|
||||
let window_x_offset = self.windowx - 7;
|
||||
|
||||
for r_x in 0..(160u8 - window_x_offset) {
|
||||
let render_x = r_x.wrapping_add(window_x_offset);
|
||||
// Absolute render coordinates
|
||||
let tile_index_x: u8 = render_x >> 3;
|
||||
let tile_index_y: u8 = ry >> 3;
|
||||
let tile_index_y: u8 = window_y_offset >> 3;
|
||||
let tile_offset_x: u8 = render_x & 7;
|
||||
let tile_offset_y: u8 = ry & 7;
|
||||
let tile_offset_y: u8 = window_y_offset & 7;
|
||||
|
||||
let vram_offset: usize =
|
||||
window_map + (tile_index_y as usize) * 32 + tile_index_x as usize;
|
||||
@ -927,6 +934,7 @@ impl Display {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (self.control & CTRL_BG_SPRITE_ENABLE) == CTRL_BG_SPRITE_ENABLE {
|
||||
self.render_sprites(&queue);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user