[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Ignore 6502 Cycles on Emulator



"Bryan Parkoff" <nospam@nospam.com> wrote in message
news:5x1mb.3498$%x5.3139@twister.austin.rr.com...
>     I have been analyzing many 6502 emulator source code, but I know that
> they do not look very good.  One of them do not use cycle counter.  All 256
> opcodes ignore cycle counters.  It always starts at integer 60.  Each opcode
> is executed before integer one is subtracted from integer 60.  After it
> reaches to integer 0, emulation will be suspended in order to allow video
> and sound to be updated.
>     I wonder how can video and sound be so accurate without cycle counter.
> Lets say, 60 * 2 = 120 cycles, 60 * 3 = 180 cycles, 60 * 4 = 240 cycles, 60
> * 5 = 300 cycles, and 60 * 6  = 360 cycles.  If 60 opcodes have only two
> cycles, then 60 opcodes is times 2 cycles that equals to 120 cycles.  120
> cycles is truly accurate, but 60 opcodes may have 2, 3, 4, or 5 cycles so it
> will not be complete accuracy.
>     I assume that the programmer does not want to add cycle counter so they
> can allow the emulator to run much faster without forcing to throttle back
> to 1MHz.  I do see that many programmers write source codes that are very
> bad.  Please tell me what you think if emulation can do without cycle
> counter???

I don't know anything about writing an emulator but I can imagine it being very
difficult to maintain an exact time ratio between real 6502 instructions and
emulated ones.  Even if you can do it the timing would be meaningless if the
emulator was running on a non real-time operating system like Windows.

Charlie