Prev: F4B7 Up: Map Next: F541
F52C: Frequency for semitone
This returns the period (or half period? not frequency) required to generate the specified semitone from the Spectrum's speaker. Since there is no absolute time to work from, the value returned is the number of iterations that the speaker routine should idle for between pulses. This will obviously only sound correct on a "standard" ZX Spectrum.
Used by the routine at menu_screen.
Input
A Semitone index. (Note: This is never larger than 42 in this game).
Output
BC Frequency.
DE Frequency (same value).
L Zero (border + beeper value).
frequency_for_semitone F52C ADD A,A Double A for index
F52D LD HL,$FA48 Point HL at the semitone_to_frequency table
F530 LD E,A Widen: DE = A
F531 LD D,$00
F533 ADD HL,DE Add
F534 LD B,(HL) Fetch frequency from table
F535 INC HL
F536 LD C,(HL)
Commentary: This increment could be baked into the table itself.
F537 INC C Increment
F538 INC B Increment
F539 JR NZ,frequency_for_semitone_0 If B rolled over, increment C (big endian?)
F53B INC C
frequency_for_semitone_0 F53C LD L,$00 Reset L - this is the border+beeper value for OUT
F53E LD D,B Return DE and BC the same
F53F LD E,C
F540 RET Return
Prev: F4B7 Up: Map Next: F541