Skip to content

Commit

Permalink
ei di Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
IsaacMarovitz committed Jan 4, 2024
1 parent a67a3bf commit 412e994
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/cpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ pub struct CPU {
pub mem: MMU,
halted: bool,
// Enabled Interrupts
ime: bool
ime: bool,
ime_ask: bool
}

impl CPU {
Expand All @@ -18,7 +19,8 @@ impl CPU {
reg: Registers::new(mode, booting),
mem: MMU::new(mode, mbc_mode, print_serial, rom),
halted: false,
ime: false
ime: false,
ime_ask: false
}
}

Expand All @@ -30,6 +32,11 @@ impl CPU {
} else if self.halted {
1
} else {
if self.ime_ask && !self.ime {
self.ime = true;
self.ime_ask = false;
}

self.op_call()
}
};
Expand Down Expand Up @@ -377,7 +384,7 @@ impl CPU {
self.reg.set_af(v); 3 },
0xF2 => { let a = 0xFF00 | u16::from(self.reg.c);
self.reg.a = self.mem.read(a); 2 },
0xF3 => { self.ime = false; 1 },
0xF3 => { self.ime = false; self.ime_ask = false; 1 },
0xF5 => { self.push(self.reg.get_af()); 4 },
0xF6 => { let b = self.read_byte();
self.alu_or(b); 2 },
Expand All @@ -387,7 +394,7 @@ impl CPU {
0xF9 => { self.reg.sp = self.reg.get_hl(); 2 },
0xFA => { let a = self.read_word();
self.reg.a = self.mem.read(a); 4 },
0xFB => { self.ime = true; 1 },
0xFB => { self.ime_ask = true; 1 },
0xFE => { let b = self.read_byte();
self.alu_cp(b); 2 },
0xFF => { self.rst(0x38) },
Expand Down

0 comments on commit 412e994

Please sign in to comment.