Skip to content
This repository has been archived by the owner on Aug 30, 2021. It is now read-only.

Account for cpu cycles that occur when entering an exception #31

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions rustual-boy-core/src/v810.rs
Expand Up @@ -133,6 +133,7 @@ pub struct V810 {
psw_interrupt_mask_level: usize,

is_halted: bool,
enter_exception_cycles: usize,

pub cache: Cache,

Expand Down Expand Up @@ -172,6 +173,7 @@ impl V810 {
psw_interrupt_mask_level: 0,

is_halted: false,
enter_exception_cycles: 0,

cache: Cache::new(),

Expand Down Expand Up @@ -917,6 +919,11 @@ impl V810 {
}
}

if self.enter_exception_cycles > 0 {
num_cycles += self.enter_exception_cycles;
self.enter_exception_cycles = 0;
}

self.reg_pc = next_pc;

(num_cycles, trigger_watchpoint)
Expand Down Expand Up @@ -1025,6 +1032,7 @@ impl V810 {
self.psw_exception_pending = true;
self.psw_interrupt_mask_level = interrupt_level;
self.reg_pc = 0xffff0000 | (exception_code as u32);
self.enter_exception_cycles = 10;
}

fn return_from_exception(&mut self) -> u32 {
Expand Down