Prev: B4EB Up: Map Next: B537
B505: Play a note in the theme tune
Used by the routine at B482.
Input
BC The pitch
DE The length
B505 LD A,($B4EA) Get the sound type.
B508 OR A Is it 0 (sawtooth)?
B509 JR Z,$B50F Jump forward if it is.
Play a square wave.
B50B LD H,B Copy the pitch from BC to HL.
B50C LD L,C
B50D JR $B520 Jump forward to play the note.
Play a sawtooth wave.
B50F LD H,B Copy the pitch from BC to HL.
B510 LD L,C
B511 SRA B Add three quarters of the pitch (?)
B513 RR C
B515 ADD HL,BC
B516 SRA B
B518 RR C
B51A ADD HL,BC
B51B SRA B
B51D RR C
B51F ADD HL,BC
Now play the note.
B520 LD A,$10 Switch the speaker on.
B522 OUT ($FE),A
B524 CALL $B4EB Pause and collect a keypress.
B527 XOR A Switch the speaker off.
B528 OUT ($FE),A
B52A PUSH BC Store BC.
B52B LD B,H Restore the value that was previously copied to HL.
B52C LD C,L
B52D CALL $B4EB Pause and collect a keypress.
B530 POP BC Restore BC.
B531 DEC DE Decrease the length.
B532 LD A,D Loop while there is more to play.
B533 OR E
B534 JR NZ,$B520
B536 RET Otherwise return.
Prev: B4EB Up: Map Next: B537