Prev: B4EB Up: Map Next: B537
B505: Play Theme Music
Used by the routine at ThemeMusic.
Play_ThemeMusic B505 LD A,($B4EA) If Flag_ThemeMusic_KeyChange is zero jump to Play_ThemeMusic_KeyChange.
B508 OR A
B509 JR Z,Play_ThemeMusic_KeyChange
B50B LD H,B H=B.
B50C LD L,C L=C.
B50D JR Play_ThemeMusic_Sound Jump to Play_ThemeMusic_Sound.
Play_ThemeMusic_KeyChange B50F LD H,B H=B.
B510 LD L,C L=C.
B511 SRA B
B513 RR C
B515 ADD HL,BC HL+=BC.
B516 SRA B
B518 RR C
B51A ADD HL,BC HL+=BC.
B51B SRA B
B51D RR C
B51F ADD HL,BC HL+=BC.
Flip speaker on (set bit 4).
Play_ThemeMusic_Sound B520 LD A,%00010000 A=10 (speaker on = bit 4).
B522 OUT ($FE),A
B524 CALL Handler_GameMenuInput Call Handler_GameMenuInput.
Flip speaker off (unset bit 4).
B527 XOR A A=00 (speaker off).
B528 OUT ($FE),A
B52A PUSH BC Stash BC on the stack.
B52B LD B,H B=H.
B52C LD C,L C=L.
B52D CALL Handler_GameMenuInput Call Handler_GameMenuInput.
B530 POP BC Restore BC from the stack.
B531 DEC DE Decrease DE by one.
B532 LD A,D Jump to Play_ThemeMusic_Sound until DE is zero.
B533 OR E
B534 JR NZ,Play_ThemeMusic_Sound
B536 RET Return.
Prev: B4EB Up: Map Next: B537