Jump to: navigation, search

Programming:Fast Sprites

No change in size, 00:14, 15 July 2006
'''Here's some tips for sprite/screen handling.'''
1. The best screen width to use is 32 (mode MODE 1 characters in CRTC register 1). This is wide enough for most games, and it's special property is that if your screen base address is on a 64 byte boundary, no pixel row will cross a 256 byte page boundary, hence you can use <code>INC reg8</code> to move to the next display byte rather than <code>INC reg16</code> (where reg8 is an 8-bit register, and reg16 is a 16-bit register). This only saves 1 microsecond, but in a tight loop, every one counts.
2. Avoid using <code>PUSH</code>/<code>POP</code> inside your sprite loop. These are slow instructions. Similarly, avoid using index registers (IX+n) and (IY+n) are slow. One case where it may be wise to use an index register is for a loop counter, so you can keep BC for something else.