Fixed issue with colour 0 being the mask colour

For systems that legitimately use 0 for black, this causes a
problem, so I instead use 0xFFFFFFFF for the mask colour which
corresponds to transparent white in ARGB format, which minifb
doesn't support anyways
This commit is contained in:
transistor 2021-11-23 11:45:44 -08:00
parent 03f23da544
commit cb47d23233
2 changed files with 7 additions and 8 deletions

View File

@ -22,7 +22,7 @@ impl BlitableSurface for Frame {
for y in pos_y..(pos_y + height) {
for x in pos_x..(pos_x + width) {
match bitmap.next().unwrap() {
0 => { },
0xFFFFFFFF => { },
value if x < self.width && y < self.height => { self.bitmap[(x + (y * self.width)) as usize] = value; },
_ => { },
}
@ -31,6 +31,7 @@ impl BlitableSurface for Frame {
}
fn clear(&mut self, value: u32) {
let value = if value == 0xFFFFFFFF { 0 } else { value };
for i in 0..((self.width as usize) * (self.height as usize)) {
self.bitmap[i] = value;
}
@ -40,14 +41,14 @@ impl BlitableSurface for Frame {
pub struct FrameSwapper {
pub current: Frame,
pub previous: Frame,
//pub previous: Frame,
}
impl FrameSwapper {
pub fn new(width: u32, height: u32) -> FrameSwapper {
FrameSwapper {
current: Frame { width, height, bitmap: vec![0; (width * height) as usize] },
previous: Frame { width, height, bitmap: vec![0; (width * height) as usize] },
//previous: Frame { width, height, bitmap: vec![0; (width * height) as usize] },
}
}
@ -66,7 +67,7 @@ impl WindowUpdater for FrameSwapper {
}
fn update_frame(&mut self, width: u32, _height: u32, bitmap: &mut [u32]) {
std::mem::swap(&mut self.current, &mut self.previous);
//std::mem::swap(&mut self.current, &mut self.previous);
for y in 0..self.current.height {
for x in 0..self.current.width {

View File

@ -209,7 +209,7 @@ impl Ym7101State {
pub fn get_palette_colour(&self, palette: u8, colour: u8) -> u32 {
if colour == 0 {
return 0;
return 0xFFFFFFFF;
}
let rgb = read_beu16(&self.cram[(((palette * 16) + colour) * 2) as usize..]);
(((rgb & 0xF00) as u32) >> 4) | (((rgb & 0x0F0) as u32) << 8) | (((rgb & 0x00F) as u32) << 20)
@ -259,9 +259,7 @@ impl Ym7101State {
pub fn draw_background(&mut self, frame: &mut Frame) {
let bg_colour = self.get_palette_colour((self.regs[REG_BACKGROUND] & 0x30) >> 4, self.regs[REG_BACKGROUND] & 0x0f);
for i in 0..(frame.width as usize * frame.height as usize) {
frame.bitmap[i] = bg_colour;
}
frame.clear(bg_colour);
}
pub fn draw_cell_table(&mut self, frame: &mut Frame, cell_table: u32) {