mirror of
https://github.com/FranLMSP/snes.git
synced 2026-10-04 16:35:18 -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) {
|
pub fn increment_cycles_xba(&mut self) {
|
||||||
self.registers.increment_pc(1); self.cycles += 3;
|
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)]
|
#[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) {
|
fn pea(&mut self, bus: &mut Bus) {
|
||||||
let address = self.get_effective_address(bus, AddressingMode::Absolute);
|
let address = self.get_effective_address(bus, AddressingMode::Absolute);
|
||||||
self.do_push(bus, &[(address >> 8) as u8, address as u8]);
|
self.do_push(bus, &[(address >> 8) as u8, address as u8]);
|
||||||
@@ -1066,7 +1084,7 @@ impl CPU {
|
|||||||
// BRA
|
// BRA
|
||||||
0x80 => self.bra(bus),
|
0x80 => self.bra(bus),
|
||||||
// BRK
|
// BRK
|
||||||
0x00 => unimplemented!("BRK instruction not implemented yet"),
|
0x00 => self.brk(bus),
|
||||||
// BRL
|
// BRL
|
||||||
0x82 => self.brl(bus),
|
0x82 => self.brl(bus),
|
||||||
// BVC
|
// BVC
|
||||||
@@ -1104,7 +1122,7 @@ impl CPU {
|
|||||||
0xC3 => self.cmp(bus, A::StackRelative),
|
0xC3 => self.cmp(bus, A::StackRelative),
|
||||||
0xD3 => self.cmp(bus, A::StackRelativeIndirectIndexed(I::Y)),
|
0xD3 => self.cmp(bus, A::StackRelativeIndirectIndexed(I::Y)),
|
||||||
// COP
|
// COP
|
||||||
0x02 => unimplemented!("COP instruction not implemented yet"),
|
0x02 => self.cop(bus),
|
||||||
// CPX
|
// CPX
|
||||||
0xE0 => self.cpx(bus, A::Immediate),
|
0xE0 => self.cpx(bus, A::Immediate),
|
||||||
0xEC => self.cpx(bus, A::Absolute),
|
0xEC => self.cpx(bus, A::Absolute),
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ pub struct Registers {
|
|||||||
pub pbr: u8, // Program bank register
|
pub pbr: u8, // Program bank register
|
||||||
pub dbr: u8, // Data bank register
|
pub dbr: u8, // Data bank register
|
||||||
pub pc: u16, // Program counter
|
pub pc: u16, // Program counter
|
||||||
pub emulation_mode: bool, // Program counter
|
pub emulation_mode: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Registers {
|
impl Registers {
|
||||||
|
|||||||
Reference in New Issue
Block a user