diff --git a/src/processor/mod.rs b/src/processor/mod.rs index 8c8885f..c670ea7 100644 --- a/src/processor/mod.rs +++ b/src/processor/mod.rs @@ -93,22 +93,32 @@ impl CPU { if get_bit(req_and_enabled, 0) { // vblank self.service_interrupt(0x40); + self.memory + .set(0xFF0F, clear_bit(self.memory.get(0xFF0F), 0)); 5 } else if get_bit(req_and_enabled, 1) { // lcd stat self.service_interrupt(0x48); + self.memory + .set(0xFF0F, clear_bit(self.memory.get(0xFF0F), 1)); 5 } else if get_bit(req_and_enabled, 2) { // timer self.service_interrupt(0x50); + self.memory + .set(0xFF0F, clear_bit(self.memory.get(0xFF0F), 2)); 5 } else if get_bit(req_and_enabled, 3) { // serial self.service_interrupt(0x58); + self.memory + .set(0xFF0F, clear_bit(self.memory.get(0xFF0F), 3)); 5 } else if get_bit(req_and_enabled, 4) { // joypad self.service_interrupt(0x60); + self.memory + .set(0xFF0F, clear_bit(self.memory.get(0xFF0F), 4)); 5 } else { 0 @@ -235,6 +245,10 @@ fn get_bit(byte: u8, flag: u8) -> bool { return got > 0x0; } +fn clear_bit(byte: u8, flag: u8) -> u8 { + byte & (!(1 << flag as u8)) +} + fn rotate(byte: u8, direction: &Direction) -> (u8, bool) { match direction { Direction::Left => {