emu-rs / rustual-boy

Rustual Boy - A Virtual Boy emulator.
https://rustualboy.com/
Apache License 2.0
232 stars 30 forks source link

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

Open jwestfall69 opened 7 years ago

jwestfall69 commented 7 years ago

I wasnt able to find any docs that indicate how many cpu cycles it takes to enter an exception. I ended up going with 10, which is how many it takes to leave an exception (reti). However I suspect entering an exception is really going to be a few more then that.

The added cpu cycles are applied to the first instruction executed in the exception.

yupferris commented 7 years ago

CI checks look like a fluke; restarted both builds.

yupferris commented 7 years ago

I think the logic here is ok, and 10 is sensible given we need to pick something and the docs don't mention this afaik. However I'm not sure I like applying the cycles to the next instruction very much, as it wouldn't look good in traces etc. I'm wondering if instead we should make the next call to step just wait this many cycles and not execute any instructions? I think it'd make the logic a bit more clear, but I'm not sure if that's the best approach. What do you think?