2600 Cookbook: Cycle Counting

Problem:
You're running out of time! Or you don't know how long your game's operations are taking.

Solution:
Suck it up and learn to cycle count: learn how to know exactly how long each 6502 operation takes.

Discussion:
I'll be honest: in general, I wasn't as pressed for time as I thought I would be through most of my own Atari game. The big exception to that, of course, is "the kernal", the part of the game that's active when the TV picture is being drawn.

You have exactly 76 machine cycles per scanline, and most assembly instructions take 2-6 machine cycles. If you're really macho, you can learn to time things so exactly that you don't even have to WSYNC.

Nick Bensema's Guide to Cycle Counting stands as the canonical (and readable!) document on the subject. That's probably your best bet, along with asking [stella] for specific kernal-optimization ideas for your problems.

References:

Back to 2600 Cookbook