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) {
// 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 => {