clear if bits

This commit is contained in:
Alex Janka 2023-02-02 19:05:18 +11:00
parent 6ae1d4a4b8
commit 8b9bcb5026

View file

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