I know nothing about LFOs, but you can save two cycles by not loading #$00 a second time in the int phase.
Code: Select all
initLFO:
lda #$00
sta lfoPhase
sta lfoSpeed
sta lfoCounter
lda #$F0
sta lfoDepth
rts
*shrug*
And if your code that calls the functions looks like this at any time:
You can save 12 cycles each time you need to init an LFO by avoiding a jsr rts pair by removing the rts. If you need to use initLFO without running pitch LFO immediately afterward, you could have the same function with an RTS duplicated someplace else in code.
Code: Select all
initLFO:
lda #$00
sta lfoPhase
sta lfoSpeed
sta lfoCounter
lda #$F0
sta lfoDepth
;rts;Removing. When you need to init and run a pitch lfo, you jsr to initLFO
;When you need to just run the pitch LFO, jsr to pitchLFO
pitchLFO:
;pitchLFO code here
Sorry, if that's not helpful. Just wanted to try.
edit: Are we allowed to use y? I'm not sure I could make it do the exact same thing, faster with y, but it'd be good to know.
Edit 2: Provided the above helps, you could further save cycles like this:
Code: Select all
initLFO:
lda #$00
sta lfoPhase
sta lfoSpeed
sta lfoCounter
ldx #$F0
stx lfoDepth
jmp pitchLFO2;or bne;adds 3 cycles
;
;Phase: %00 / %01 = positve, %10 / %11 = negative
;
pitchLFO:
ldx lfoDepth;But saves at least 3, depending on if these
lda lfoPhase ;are zero page or absolute
pitchLFO2:
But I'm rambling now, sorry. Apologies also if I'm incorrect in my assumptions of the order of how these subroutines will be used. I only saved 17 cycles anyway, and probably only once, instead of 36 times, assuming my assumptions are even correct in the first place.
