keypress interrupts
This commit is contained in:
parent
96af4b94a1
commit
615446faa7
|
@ -147,7 +147,9 @@ impl CPU {
|
|||
}
|
||||
|
||||
fn enter_vblank(&mut self) {
|
||||
self.memory.update_pressed_keys(self.window.get_keys());
|
||||
if self.memory.update_pressed_keys(self.window.get_keys()) {
|
||||
self.memory.set(0xFF0F, set_bit(self.memory.get(0xFF0F), 4));
|
||||
}
|
||||
self.gpu.mode = DrawMode::VBlank;
|
||||
self.render_window();
|
||||
self.memory.set(0xFF0F, set_bit(self.memory.get(0xFF0F), 0));
|
||||
|
@ -233,14 +235,14 @@ impl CPU {
|
|||
let pos_y = self.memory.get(0xFF4A);
|
||||
// subtracting 7 to get the Real Number...
|
||||
let pos_x = self.memory.get(0xFF4B);
|
||||
self.render_tiles(
|
||||
scanline,
|
||||
&lcdc.window_tilemap,
|
||||
&lcdc.tile_area,
|
||||
palette,
|
||||
self.render_tiles(
|
||||
scanline,
|
||||
&lcdc.window_tilemap,
|
||||
&lcdc.tile_area,
|
||||
palette,
|
||||
pos_x.wrapping_sub(7),
|
||||
pos_y,
|
||||
false,
|
||||
pos_y,
|
||||
false,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -12,13 +12,13 @@ pub(crate) mod rom;
|
|||
|
||||
pub(crate) type Address = u16;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
enum JoypadBank {
|
||||
Action,
|
||||
Direction,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
struct Joypad {
|
||||
bank_sel: JoypadBank,
|
||||
down: bool,
|
||||
|
@ -275,7 +275,8 @@ impl Memory {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn update_pressed_keys(&mut self, keys: Vec<Key>) {
|
||||
pub fn update_pressed_keys(&mut self, keys: Vec<Key>) -> bool {
|
||||
let old = self.joypad.clone();
|
||||
self.joypad.down = keys.contains(&Key::Down) || keys.contains(&Key::S);
|
||||
self.joypad.up = keys.contains(&Key::Up) || keys.contains(&Key::W);
|
||||
self.joypad.left = keys.contains(&Key::Left) || keys.contains(&Key::A);
|
||||
|
@ -284,5 +285,7 @@ impl Memory {
|
|||
self.joypad.select = keys.contains(&Key::Minus);
|
||||
self.joypad.a = keys.contains(&Key::Apostrophe);
|
||||
self.joypad.b = keys.contains(&Key::Semicolon);
|
||||
self.joypad != old
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue