mirror of
https://github.com/transistorfet/moa.git
synced 2025-02-17 18:30:33 +00:00
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:
parent
03f23da544
commit
cb47d23233
@ -22,7 +22,7 @@ impl BlitableSurface for Frame {
|
|||||||
for y in pos_y..(pos_y + height) {
|
for y in pos_y..(pos_y + height) {
|
||||||
for x in pos_x..(pos_x + width) {
|
for x in pos_x..(pos_x + width) {
|
||||||
match bitmap.next().unwrap() {
|
match bitmap.next().unwrap() {
|
||||||
0 => { },
|
0xFFFFFFFF => { },
|
||||||
value if x < self.width && y < self.height => { self.bitmap[(x + (y * self.width)) as usize] = value; },
|
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) {
|
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)) {
|
for i in 0..((self.width as usize) * (self.height as usize)) {
|
||||||
self.bitmap[i] = value;
|
self.bitmap[i] = value;
|
||||||
}
|
}
|
||||||
@ -40,14 +41,14 @@ impl BlitableSurface for Frame {
|
|||||||
|
|
||||||
pub struct FrameSwapper {
|
pub struct FrameSwapper {
|
||||||
pub current: Frame,
|
pub current: Frame,
|
||||||
pub previous: Frame,
|
//pub previous: Frame,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FrameSwapper {
|
impl FrameSwapper {
|
||||||
pub fn new(width: u32, height: u32) -> FrameSwapper {
|
pub fn new(width: u32, height: u32) -> FrameSwapper {
|
||||||
FrameSwapper {
|
FrameSwapper {
|
||||||
current: Frame { width, height, bitmap: vec![0; (width * height) as usize] },
|
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]) {
|
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 y in 0..self.current.height {
|
||||||
for x in 0..self.current.width {
|
for x in 0..self.current.width {
|
||||||
|
@ -209,7 +209,7 @@ impl Ym7101State {
|
|||||||
|
|
||||||
pub fn get_palette_colour(&self, palette: u8, colour: u8) -> u32 {
|
pub fn get_palette_colour(&self, palette: u8, colour: u8) -> u32 {
|
||||||
if colour == 0 {
|
if colour == 0 {
|
||||||
return 0;
|
return 0xFFFFFFFF;
|
||||||
}
|
}
|
||||||
let rgb = read_beu16(&self.cram[(((palette * 16) + colour) * 2) as usize..]);
|
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)
|
(((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) {
|
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);
|
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.clear(bg_colour);
|
||||||
frame.bitmap[i] = bg_colour;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn draw_cell_table(&mut self, frame: &mut Frame, cell_table: u32) {
|
pub fn draw_cell_table(&mut self, frame: &mut Frame, cell_table: u32) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user