mirror of
https://github.com/FranLMSP/snes.git
synced 2026-08-03 08:30:01 -04:00
WIP BRK and COP instructions
This commit is contained in:
@@ -384,6 +384,13 @@ impl CPU {
|
||||
pub fn increment_cycles_xba(&mut self) {
|
||||
self.registers.increment_pc(1); self.cycles += 3;
|
||||
}
|
||||
|
||||
pub fn increment_cycles_brk(&mut self) {
|
||||
self.registers.increment_pc(2); self.cycles += 7;
|
||||
if self.registers.emulation_mode {
|
||||
self.cycles += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -516,6 +516,24 @@ impl CPU {
|
||||
}
|
||||
}
|
||||
|
||||
fn brk(&mut self, bus: &mut Bus) {
|
||||
self.do_push(bus, &[self.registers.pbr]);
|
||||
self.do_push(bus, &[(self.registers.pc >> 8) as u8, self.registers.pc as u8]);
|
||||
self.do_push(bus, &[self.registers.p]);
|
||||
self.registers.set_decimal_mode_flag(false);
|
||||
self.registers.set_irq_disable_flag(true);
|
||||
self.increment_cycles_brk();
|
||||
}
|
||||
|
||||
fn cop(&mut self, bus: &mut Bus) {
|
||||
self.do_push(bus, &[self.registers.pbr]);
|
||||
self.do_push(bus, &[(self.registers.pc >> 8) as u8, self.registers.pc as u8]);
|
||||
self.do_push(bus, &[self.registers.p]);
|
||||
self.registers.set_decimal_mode_flag(false);
|
||||
self.registers.set_irq_disable_flag(true);
|
||||
self.increment_cycles_brk();
|
||||
}
|
||||
|
||||
fn pea(&mut self, bus: &mut Bus) {
|
||||
let address = self.get_effective_address(bus, AddressingMode::Absolute);
|
||||
self.do_push(bus, &[(address >> 8) as u8, address as u8]);
|
||||
@@ -1066,7 +1084,7 @@ impl CPU {
|
||||
// BRA
|
||||
0x80 => self.bra(bus),
|
||||
// BRK
|
||||
0x00 => unimplemented!("BRK instruction not implemented yet"),
|
||||
0x00 => self.brk(bus),
|
||||
// BRL
|
||||
0x82 => self.brl(bus),
|
||||
// BVC
|
||||
@@ -1104,7 +1122,7 @@ impl CPU {
|
||||
0xC3 => self.cmp(bus, A::StackRelative),
|
||||
0xD3 => self.cmp(bus, A::StackRelativeIndirectIndexed(I::Y)),
|
||||
// COP
|
||||
0x02 => unimplemented!("COP instruction not implemented yet"),
|
||||
0x02 => self.cop(bus),
|
||||
// CPX
|
||||
0xE0 => self.cpx(bus, A::Immediate),
|
||||
0xEC => self.cpx(bus, A::Absolute),
|
||||
|
||||
@@ -10,7 +10,7 @@ pub struct Registers {
|
||||
pub pbr: u8, // Program bank register
|
||||
pub dbr: u8, // Data bank register
|
||||
pub pc: u16, // Program counter
|
||||
pub emulation_mode: bool, // Program counter
|
||||
pub emulation_mode: bool,
|
||||
}
|
||||
|
||||
impl Registers {
|
||||
|
||||
Reference in New Issue
Block a user