Oh boy.
Okay, I seem to remember a trick for this that was first done in Combat. I think it went like this, IIRC.
1. Have the scanline you want the missile to appear on stored in ram.
2. Compare the scanline you are on the the scanline the missile is on.
3. Push the processor status onto the enable register. The **trick** (why this works) is the Zero Flag is set when the
compare is equal to the scanline. Since the Missile Enable and Zero Flag occupy the same bit xxxx xxXx the processor status can be used to enable/disable the missle.
7-8 cycles though?
;stack pointer has to be adjusted before hand, it needs to point to the enable register (ie ENAM1, ENAM2, etc..) so you need to find more cycles before it happens.
CPY scanline ;3
PHP ;4 (already at 7 cycles)
however, you need to readjust the stack register back
each time you do this! So you again you need to find more cycles.
The simple way to adjust the stack pointer is to waste 4 more cycles (when you can) with a PLA. This will trash the accumulator, so do it when you are not needing, or about to reload the accumulator.
i.e.
PLA ;4 (reset stack to the missile, but trashes the accumulator)
LDA #whatever (ahhhh, now it doesn't matter.)
The minimum needed for this method is 11 cycles (split into 7 cycles, and 4 cycles), plus the stack pointer adjusted before hand (more cycles), plus a ram register (to compare the scanline to), plus the stack pointer free (i.e. you are not jumping to a subroutine during the kernel, or using the stack pointer for other things.)
Edited by Omegamatrix, Tue Oct 13, 2009 1:37 AM.