Prev: C026 Up: Map Next: C041
C033: Look up a note's pitch
Used by the routine at TUNE_PLAY_NOTE.
A note is a number of semitones, -12 to 40, or 41 for a rest. Twelve is added to it to index the table of pitches at offset 8 of TUNE_VOICES (TUNE_NOTES), which gives the number of turns of the player's loop between two toggles of the speaker bit. The rest's entry is 1: a toggle every turn, about 18 kHz, too high to be heard as a note; when both voices rest, TUNE_PLAY_NOTE plays nothing at all.
Input
HL A voice's note (VOICE_ONE_NOTE or the byte after it)
Output
H Its pitch: the turns of the loop between two toggles
L 1, the countdown to the first toggle
TUNE_PITCH C033 LD A,(HL) The table, indexed by the note plus 12.
C034 ADD A,$0C
C036 LD E,A
C037 LD D,$00
C039 LD HL,TUNE_NOTES
C03C ADD HL,DE
C03D LD H,(HL) H: the pitch; L: 1, so that the voice toggles on the first turn.
C03E LD L,$01
C040 RET
Prev: C026 Up: Map Next: C041