Origin cleanup
This commit is contained in:
parent
30efdc1108
commit
8dd14c7719
@ -144,7 +144,7 @@ impl BgMapAttributes {
|
|||||||
#[derive(Debug, Copy, Clone)]
|
#[derive(Debug, Copy, Clone)]
|
||||||
enum PixelOrigin {
|
enum PixelOrigin {
|
||||||
Empty,
|
Empty,
|
||||||
Background,
|
Background(usize),
|
||||||
Window,
|
Window,
|
||||||
Sprite,
|
Sprite,
|
||||||
}
|
}
|
||||||
@ -655,7 +655,8 @@ impl Display {
|
|||||||
// Do not draw if the sprite should be drawn in the background
|
// Do not draw if the sprite should be drawn in the background
|
||||||
if !sprite.is_foreground() {
|
if !sprite.is_foreground() {
|
||||||
match pixel_origin {
|
match pixel_origin {
|
||||||
PixelOrigin::Background | PixelOrigin::Window => continue,
|
PixelOrigin::Background(0) => {},
|
||||||
|
PixelOrigin::Window | PixelOrigin::Background(_) => continue,
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -665,42 +666,17 @@ impl Display {
|
|||||||
b2 = (tile_line_2 & 1 << (7 - x_o)) > 0;
|
b2 = (tile_line_2 & 1 << (7 - x_o)) > 0;
|
||||||
|
|
||||||
// Sprites may be transparent.
|
// Sprites may be transparent.
|
||||||
if !b1 && !b2 {
|
if !b1 && !b2 && sprite.is_foreground() {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// GB
|
|
||||||
/*
|
|
||||||
let c = (b1 as u8) * 2 + b2 as u8;
|
|
||||||
let lookup: [u8; 4] = match sprite.palette() {
|
|
||||||
0 => [
|
|
||||||
self.object_palette[0] & 3,
|
|
||||||
(self.object_palette[0] >> 2) & 3,
|
|
||||||
(self.object_palette[0] >> 4) & 3,
|
|
||||||
(self.object_palette[0] >> 6) & 3,
|
|
||||||
],
|
|
||||||
1 => [
|
|
||||||
self.object_palette[1] & 3,
|
|
||||||
(self.object_palette[1] >> 2) & 3,
|
|
||||||
(self.object_palette[1] >> 4) & 3,
|
|
||||||
(self.object_palette[1] >> 6) & 3,
|
|
||||||
],
|
|
||||||
_ => unreachable!(),
|
|
||||||
};
|
|
||||||
let entry = MONOCHROME_PALETTE[lookup[c as usize] as usize];
|
|
||||||
|
|
||||||
// Draw stuff. We're currently only in monochrome mode
|
|
||||||
self.set_pixel(
|
|
||||||
x.wrapping_add(x_o),
|
|
||||||
render_y,
|
|
||||||
sdl2::pixels::Color::RGB(entry[0], entry[1], entry[2]),
|
|
||||||
PixelOrigin::Sprite,
|
|
||||||
);
|
|
||||||
*/
|
|
||||||
let c = ((b2 as u8) * 2 + b1 as u8) as usize;
|
let c = ((b2 as u8) * 2 + b1 as u8) as usize;
|
||||||
if c == 0 {
|
if c == 0 {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
// DMG:
|
||||||
|
// let c = self.object_palette[sprite.palette() as usize].get_color(c);
|
||||||
|
// GBC:
|
||||||
let c = self.object_palette_cgb[sprite.palette() as usize].get_color(c);
|
let c = self.object_palette_cgb[sprite.palette() as usize].get_color(c);
|
||||||
self.set_pixel(
|
self.set_pixel(
|
||||||
x.wrapping_add(x_maybe_flipped),
|
x.wrapping_add(x_maybe_flipped),
|
||||||
@ -828,10 +804,7 @@ impl Display {
|
|||||||
|
|
||||||
// Lookup the color
|
// Lookup the color
|
||||||
let c = ((b2 as u8) * 2 + b1 as u8) as usize;
|
let c = ((b2 as u8) * 2 + b1 as u8) as usize;
|
||||||
let origin = match c {
|
let origin = PixelOrigin::Background(c);
|
||||||
0 => PixelOrigin::Empty, // Hack so that objects will be in front of it.
|
|
||||||
_ => PixelOrigin::Background,
|
|
||||||
};
|
|
||||||
let c = self.background_palette_cgb[bg_attribs.palette_number()].get_color(c);
|
let c = self.background_palette_cgb[bg_attribs.palette_number()].get_color(c);
|
||||||
self.set_pixel(render_x, render_y, c, origin);
|
self.set_pixel(render_x, render_y, c, origin);
|
||||||
/*
|
/*
|
||||||
@ -921,10 +894,13 @@ impl Display {
|
|||||||
let b2: bool = (tile_line_2 & 1 << (7 - tile_offset_x)) > 0;
|
let b2: bool = (tile_line_2 & 1 << (7 - tile_offset_x)) > 0;
|
||||||
|
|
||||||
let c = (b2 as u8) * 2 + b1 as u8;
|
let c = (b2 as u8) * 2 + b1 as u8;
|
||||||
|
/*
|
||||||
let origin = match c {
|
let origin = match c {
|
||||||
0 => PixelOrigin::Empty, // Hack so that objects will be in front of it.
|
0 => PixelOrigin::Empty, // Hack so that objects will be in front of it.
|
||||||
_ => PixelOrigin::Window,
|
_ => PixelOrigin::Window,
|
||||||
};
|
};
|
||||||
|
*/
|
||||||
|
let origin = PixelOrigin::Window;
|
||||||
let c = self.background_palette_cgb[bg_attribs.palette_number()]
|
let c = self.background_palette_cgb[bg_attribs.palette_number()]
|
||||||
.get_color(c as usize);
|
.get_color(c as usize);
|
||||||
self.set_pixel(render_x, render_y, c, origin);
|
self.set_pixel(render_x, render_y, c, origin);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user