AndreaOrru / LaiNES

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

cycle number of Instructions #36

Closed PudgeMa closed 5 years ago

PudgeMa commented 5 years ago

I find cycles of instruction don't match the information is list here. for example:

ADC<imm>() :
inline u8  rd(u16 a)            { T; return access<0>(a);      }
#define G  u16 a = m(); u8 p = rd(a) 
inline u16 imm()   { return PC++;                                       }
template<Mode m> void ADC() { G       ; s16 r = A + p + P[C]; upd_cv(A, p, r); upd_nz(A = r); }

it only ticks once, but in that link this ins need two cycles

 +----------------+-----------------------+---------+---------+----------+
  | Addressing Mode| Assembly Language Form| OP CODE |No. Bytes|No. Cycles|
  +----------------+-----------------------+---------+---------+----------+
  |  Immediate     |   ADC #Oper           |    69   |    2    |    2     |
AndreaOrru commented 5 years ago

Hi, I realize I'm not super responsive - unfortunately I don't have a lot of time to dedicate to this project anymore (although I would like to in the future).

Why did you close the issue? Did you realize it actually ticks twice? :D Genuine question.

PudgeMa commented 5 years ago
void exec()
{
    switch (rd(PC++))  // Fetch the opcode.
    { 
      ....
    }
}

when fetch the opcode, it ticks first. so your implementation is right.