Cleanup some old DMG code

This commit is contained in:
Kevin Hamacher 2020-02-21 18:18:21 +01:00
parent c880766ae4
commit fbfe751d75
2 changed files with 6 additions and 56 deletions

View File

@ -2,7 +2,7 @@ extern crate libc;
extern crate sdl2;
mod palette;
use palette::{DmgPalette, CgbPalette};
use palette::{CgbPalette, DmgPalette};
use std::io::Write;
@ -598,7 +598,7 @@ impl Display {
// Do not draw if the sprite should be drawn in the background
if !sprite.is_foreground() {
match pixel_origin {
PixelOrigin::Background(0) => {},
PixelOrigin::Background(0) => {}
PixelOrigin::Window | PixelOrigin::Background(_) => continue,
_ => {}
}
@ -747,30 +747,9 @@ impl Display {
// Lookup the color
let c = ((b2 as u8) * 2 + b1 as u8) as usize;
let origin = PixelOrigin::Background(c);
// let c = self.background_palette.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);
/*
let c = (b1 as u8) * 2 + b2 as u8;
let lookup: [u8; 4] = [
self.background_palette & 3,
(self.background_palette >> 2) & 3,
(self.background_palette >> 4) & 3,
(self.background_palette >> 6) & 3,
];
let entry = MONOCHROME_PALETTE[lookup[c as usize] as usize];
let origin = match c {
0 => PixelOrigin::Empty, // Hack so that objects will be in front of it.
_ => PixelOrigin::Background,
};
self.set_pixel(
render_x,
render_y,
sdl2::pixels::Color::RGB(entry[0], entry[1], entry[2]),
origin,
);
*/
self.set_pixel(render_x, render_y, c, PixelOrigin::Background(c));
}
}
@ -837,37 +816,10 @@ impl Display {
let b2: bool = (tile_line_2 & 1 << (7 - tile_offset_x)) > 0;
let c = (b2 as u8) * 2 + b1 as u8;
/*
let origin = match c {
0 => PixelOrigin::Empty, // Hack so that objects will be in front of it.
_ => PixelOrigin::Window,
};
*/
let origin = PixelOrigin::Window;
// let c = self.background_palette.get_color(c);
let c = self.background_palette_cgb[bg_attribs.palette_number()]
.get_color(c as usize);
self.set_pixel(render_x, render_y, c, origin);
/*
let lookup: [u8; 4] = [
self.background_palette & 3,
(self.background_palette >> 2) & 3,
(self.background_palette >> 4) & 3,
(self.background_palette >> 6) & 3,
];
let entry = MONOCHROME_PALETTE[lookup[c as usize] as usize];
// Draw stuff. We're currently only in monochrome mode
let origin = match c {
0 => PixelOrigin::Empty, // Hack so that objects will be in front of it.
_ => PixelOrigin::Window,
};
self.set_pixel(
render_x,
render_y,
sdl2::pixels::Color::RGB(entry[0], entry[1], entry[2]),
origin,
);
*/
self.set_pixel(render_x, render_y, c, PixelOrigin::Window);
}
}
}

View File

@ -59,5 +59,3 @@ impl std::fmt::Display for CgbPalette {
write!(f, "")
}
}