Super NES Programming/How NOT to cause slowdown
< Super NES ProgrammingHere are techniques to avoid having your game lag:
1) Use direct page for object handling. For most computer systems, object handling is done by copying the object's variables to and from "local" memory to calculate the object's next onscreen position. On the SNES's 65816, on the other hand, it has a moveable direct page register where it can actually move it's "local memory" location to where ever it wants to go. Sadly, because this feature wasn't on very many CPUs, most SNES programmers didn't use it, and did the slower block copying.
2) Semi-Unrolled loops. These are loops where the job is done twice per repetition. When in a loop, the CPU uses up a number of cycles counting down and jumping. With semi-unrolled looping, the CPU takes half the time it normally takes to count down and jump. It is almost as efficient as a fully unrolled loop, but with much little effort.
3) Inline a subroutine. If there is a subroutine that is called by an often repeated code, you can gain performance by replacing the "jsr" with a copy of the subroutine code. Using a subroutine takes 12 cycles, 6 to jump, 6 to return.