Prev: B2D9 Up: Map Next: B2F9
B2DA: Play one note
Used by the routines at keypress_tune_note and play_audio.
Looks up the note's three bytes in freq_tbl: two loop counts that set how long each half of a wave lasts, and how many waves make one unit. The length bits multiply the wave count by one to four. It then drives the speaker directly, off for one half-wave and on for the other, with the border held black.
The wave count in the table rises with the pitch, which keeps every unit close to 0.155 seconds whatever the note.
Input
A the note byte
DE the address of the note byte; on exit, the next one
play_note B2DA AND $3F index 0 is a rest
B2DC JR Z,snd_delay
B2DE LD L,A HL = freq_tbl + 3 * index
B2DF LD H,$00
B2E1 ADD HL,HL
B2E2 CALL add_HL_A
B2E5 LD BC,freq_tbl
B2E8 ADD HL,BC
B2E9 LD B,(HL) B and C time the half-wave; HL = the number of waves in one unit
B2EA INC HL
B2EB LD C,(HL)
B2EC INC HL
B2ED LD L,(HL)
B2EE LD H,$00
B2F0 LD A,(DE) the top two bits: the length, one to four units
B2F1 RLCA
B2F2 RLCA
B2F3 AND $03
B2F5 INC A
B2F6 PUSH DE DE = the waves in one unit, to add up
B2F7 LD E,L
B2F8 LD D,H
Prev: B2D9 Up: Map Next: B2F9