mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-17 08:40:52 +00:00
fix emulation bugs
This commit is contained in:
parent
e6a85c5573
commit
db4d21c54c
2 changed files with 27 additions and 33 deletions
|
|
@ -38,7 +38,7 @@ pub enum Mono {
|
||||||
impl From<ColorNative> for Mono {
|
impl From<ColorNative> for Mono {
|
||||||
fn from(value: ColorNative) -> Self {
|
fn from(value: ColorNative) -> Self {
|
||||||
match value.0 {
|
match value.0 {
|
||||||
1 => Mono::Black,
|
0 => Mono::Black,
|
||||||
_ => Mono::White,
|
_ => Mono::White,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -46,8 +46,8 @@ impl From<ColorNative> for Mono {
|
||||||
impl Into<ColorNative> for Mono {
|
impl Into<ColorNative> for Mono {
|
||||||
fn into(self) -> ColorNative {
|
fn into(self) -> ColorNative {
|
||||||
match self {
|
match self {
|
||||||
Mono::Black => ColorNative::from(1),
|
Mono::Black => ColorNative::from(0),
|
||||||
Mono::White => ColorNative::from(0),
|
Mono::White => ColorNative::from(1),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -508,19 +508,16 @@ impl<'a> FrameBuffer for Oled128x128<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn xor_pixel(&mut self, p: Point) {
|
fn xor_pixel(&mut self, p: Point) {
|
||||||
if p.x >= COLUMN || p.y >= ROW || p.x < 0 || p.y < 0 {
|
if let Some(px) = self.get_pixel(p) {
|
||||||
return;
|
let mono_px: Mono = px.into();
|
||||||
}
|
self.put_pixel(
|
||||||
let bitnum = (p.x + p.y * COLUMN) as usize;
|
p,
|
||||||
let flip: ColorNative = if self.buffer[bitnum / 32] & 1 << (bitnum % 32) != 0 {
|
match mono_px {
|
||||||
Mono::Black.into()
|
Mono::Black => Mono::White,
|
||||||
} else {
|
Mono::White => Mono::Black,
|
||||||
Mono::White.into()
|
}
|
||||||
};
|
.into(),
|
||||||
if flip.0 != 0 {
|
);
|
||||||
self.buffer[bitnum / 32] |= 1 << (bitnum % 32);
|
|
||||||
} else {
|
|
||||||
self.buffer[bitnum / 32] &= !(1 << (bitnum % 32));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,8 @@ pub enum Mono {
|
||||||
}
|
}
|
||||||
impl From<ColorNative> for Mono {
|
impl From<ColorNative> for Mono {
|
||||||
fn from(value: ColorNative) -> Self {
|
fn from(value: ColorNative) -> Self {
|
||||||
match value.0 as u32 {
|
match value.0 {
|
||||||
DARK_COLOUR => Mono::Black,
|
0 => Mono::Black,
|
||||||
_ => Mono::White,
|
_ => Mono::White,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -31,8 +31,8 @@ impl From<ColorNative> for Mono {
|
||||||
impl Into<ColorNative> for Mono {
|
impl Into<ColorNative> for Mono {
|
||||||
fn into(self) -> ColorNative {
|
fn into(self) -> ColorNative {
|
||||||
match self {
|
match self {
|
||||||
Mono::Black => ColorNative::from(DARK_COLOUR as usize),
|
Mono::Black => ColorNative::from(0),
|
||||||
Mono::White => ColorNative::from(LIGHT_COLOUR as usize),
|
Mono::White => ColorNative::from(1),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -186,19 +186,16 @@ impl FrameBuffer for Oled128x128 {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn xor_pixel(&mut self, p: Point) {
|
fn xor_pixel(&mut self, p: Point) {
|
||||||
if p.x >= COLUMN || p.y >= ROW || p.x < 0 || p.y < 0 {
|
if let Some(px) = self.get_pixel(p) {
|
||||||
return;
|
let mono_px: Mono = px.into();
|
||||||
}
|
self.put_pixel(
|
||||||
let bitnum = (p.x + p.y * COLUMN) as usize;
|
p,
|
||||||
let flip: ColorNative = if self.buffer[bitnum / 32] & 1 << (bitnum % 32) != 0 {
|
match mono_px {
|
||||||
Mono::Black.into()
|
Mono::Black => Mono::White,
|
||||||
} else {
|
Mono::White => Mono::Black,
|
||||||
Mono::White.into()
|
}
|
||||||
};
|
.into(),
|
||||||
if flip.0 != 0 {
|
);
|
||||||
self.buffer[bitnum / 32] |= 1 << (bitnum % 32);
|
|
||||||
} else {
|
|
||||||
self.buffer[bitnum / 32] &= !(1 << (bitnum % 32));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue