Topic: The optimization thread
Thought I'd open a thread for brainstorming about optimizing various parts of beeper engines. I'm thinking especially about various issues related to data loading.
For a start, let's talk about frequency table lookup. Lately I tend to avoid it altogether, and instead store frequencies directly in the pattern data. But sometimes it comes in handy, I suppose. So, my method is quite primitive. Suppose we have a 16-bit lookup table aligned to a 256b border, and note values are already multiplied by 2.
ld h,HIGH(frequency_lut) ;7 ld a,(de) ;7, load note val from pattern data ld l,a ;4 ld c,(hl) ;7 inc l ;4 ld b,(hl) ;7, frequency now in BC
Which brings us to a total of 36t. Of course, if you don't care about sp, you could also do "ld sp,hl, pop bc" which would be 2t faster. Is there any faster way to do it, preferably without touching sp?