Skip to content
Snippets Groups Projects
Verified Commit 3cb92ad8 authored by João Magalhães's avatar João Magalhães :rocket:
Browse files

fix: issues related to WASM

parent ce6c8df9
No related branches found
No related tags found
1 merge request!3Support for sprites/object drawing 💪
Pipeline #928 passed
...@@ -118,12 +118,18 @@ fn main() { ...@@ -118,12 +118,18 @@ fn main() {
Event::KeyDown { Event::KeyDown {
keycode: Some(keycode), keycode: Some(keycode),
.. ..
} => game_boy.key_press(key_to_pad(keycode)), } => match key_to_pad(keycode) {
Some(key) => game_boy.key_press(key),
None => (),
},
Event::KeyUp { Event::KeyUp {
keycode: Some(keycode), keycode: Some(keycode),
.. ..
} => game_boy.key_lift(key_to_pad(keycode)), } => match key_to_pad(keycode) {
Some(key) => game_boy.key_lift(key),
None => (),
},
_ => (), _ => (),
} }
...@@ -160,17 +166,17 @@ fn main() { ...@@ -160,17 +166,17 @@ fn main() {
} }
} }
fn key_to_pad(keycode: Keycode) -> PadKey { fn key_to_pad(keycode: Keycode) -> Option<PadKey> {
match keycode { match keycode {
Keycode::Up => PadKey::Up, Keycode::Up => Some(PadKey::Up),
Keycode::Down => PadKey::Down, Keycode::Down => Some(PadKey::Down),
Keycode::Left => PadKey::Left, Keycode::Left => Some(PadKey::Left),
Keycode::Right => PadKey::Right, Keycode::Right => Some(PadKey::Right),
Keycode::Return => PadKey::Start, Keycode::Return => Some(PadKey::Start),
Keycode::Return2 => PadKey::Start, Keycode::Return2 => Some(PadKey::Start),
Keycode::Space => PadKey::Select, Keycode::Space => Some(PadKey::Select),
Keycode::A => PadKey::A, Keycode::A => Some(PadKey::A),
Keycode::S => PadKey::B, Keycode::S => Some(PadKey::B),
_ => PadKey::A, //@todo this does not make sence, make it an Option _ => None,
} }
} }
...@@ -555,12 +555,6 @@ pub const EXTENDED: [(fn(&mut Cpu), u8, &'static str); 256] = [ ...@@ -555,12 +555,6 @@ pub const EXTENDED: [(fn(&mut Cpu), u8, &'static str); 256] = [
fn nop(_cpu: &mut Cpu) {} fn nop(_cpu: &mut Cpu) {}
fn noimpl(_cpu: &mut Cpu) {
let ten_millis = time::Duration::from_millis(10000);
thread::sleep(ten_millis); // @todo remove this hack
todo!("Instruction not implemented");
}
fn illegal(_cpu: &mut Cpu) { fn illegal(_cpu: &mut Cpu) {
panic!("Illegal instruction"); panic!("Illegal instruction");
} }
......
...@@ -58,15 +58,18 @@ impl Tile { ...@@ -58,15 +58,18 @@ impl Tile {
self.buffer[y * TILE_WIDTH + x] = value; self.buffer[y * TILE_WIDTH + x] = value;
} }
pub fn get_row(&self, y: usize) -> &[u8] {
&self.buffer[y * TILE_WIDTH..(y + 1) * TILE_WIDTH]
}
pub fn buffer(&self) -> Vec<u8> { pub fn buffer(&self) -> Vec<u8> {
self.buffer.to_vec() self.buffer.to_vec()
} }
} }
impl Tile {
pub fn get_row(&self, y: usize) -> &[u8] {
&self.buffer[y * TILE_WIDTH..(y + 1) * TILE_WIDTH]
}
}
impl Tile { impl Tile {
pub fn palette_buffer(&self, palette: Palette) -> Vec<u8> { pub fn palette_buffer(&self, palette: Palette) -> Vec<u8> {
self.buffer self.buffer
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment