AndreaOrru / LaiNES

Cycle-accurate NES emulator in ~1000 lines of code
BSD 2-Clause "Simplified" License
1.49k stars 115 forks source link

Branches to a new page #33

Closed Schuemi closed 4 years ago

Schuemi commented 6 years ago

Hi, maybe I'm wrong (if so, sorry for that), but I can't find the two extra circles, if a branch goes to a new ram page. (see: http://obelisk.me.uk/6502/reference.html#BCC )

should this: template<Flag f, bool v> void br() { s8 j = rd(imm()); if (P[f] == v) { T; PC += j; } }

be maybe something like this: template<Flag f, bool v> void br() { s8 j = rd(imm()); if (P[f] == v) { T; if(cross(PC, j)) {T;T;} PC += j; } }

Thank you

PudgeMa commented 5 years ago

Hi, if branch ins goes to a new page, we should add one more tick only. see: http://6502.org/tutorials/6502opcodes.html#BEQ

A branch not taken requires two machine cycles. Add one if the branch is taken and add one more if the branch crosses a page boundary.

AndreaOrru commented 4 years ago

@PudgeMa this is closed by #37 I believe?