Prev: B482 Up: Map Next: B4E7
B494: Handler: Theme Music
Used by the routine at Check_Music.
Input
A Music data
HL Music data address pointer
ThemeMusic B494 INC HL Increment music data address pointer held in HL by one.
The control character FE signifies a key change.
B495 CP $FE If A is not FE jump to ThemeMusic_CheckKeyChange.
B497 JR NZ,ThemeMusic_CheckKeyChange
B499 XOR A A=00.
ThemeMusic_SetKey B49A LD ($B4EA),A Write A to Flag_ThemeMusic_KeyChange.
B49D LD ($B4E7),HL Write HL to Pointer_MusicData.
B4A0 JR Check_Music Jump to Check_Music.
The control character FF signifies a key change.
ThemeMusic_CheckKeyChange B4A2 CP $FF If A is not FF jump to ThemeMusic_0.
B4A4 JR NZ,ThemeMusic_0
B4A6 LD A,$01 A=01.
B4A8 JR ThemeMusic_SetKey Jump to ThemeMusic_SetKey.
ThemeMusic_0 B4AA PUSH AF Stash AF on the stack.
B4AB LD A,(HL) A=*HL.
B4AC INC HL Increment music data address pointer held in HL by one.
B4AD LD ($B4E7),HL Write HL to Pointer_MusicData.
B4B0 OR A If A is zero jump to ThemeMusic_3.
B4B1 JR Z,ThemeMusic_3
B4B3 LD L,A Create an offset in HL.
B4B4 LD H,$00
B4B6 ADD HL,HL HL*=02.
B4B7 LD DE,$B537 HL+=B537.
B4BA ADD HL,DE
B4BB LD C,(HL) C=*HL.
B4BC LD B,$00 B=00.
B4BE INC HL Increment music data address pointer held in HL by one.
B4BF LD E,(HL) E=*HL.
B4C0 LD D,B D=00.
B4C1 POP AF Restore AF from the stack.
B4C2 LD HL,$0000 HL+=0000.
ThemeMusic_1 B4C5 ADD HL,DE
B4C6 DEC A Decrease A by one.
B4C7 JR NZ,ThemeMusic_1 Jump to ThemeMusic_1 until A is zero.
B4C9 EX DE,HL Switch the DE and HL registers.
B4CA CALL Play_ThemeMusic Call Play_ThemeMusic.
B4CD LD A,($B4E9) A=*TempStore_GameOptions.
B4D0 CP $FF Return if A is not FF.
B4D2 RET NZ
ThemeMusic_2 B4D3 LD BC,$0320 BC=0320.
B4D6 CALL Handler_GameMenuInput Call Handler_GameMenuInput.
B4D9 JR Check_Music Jump to Check_Music.
ThemeMusic_3 B4DB LD BC,$19C8 BC=19C8.
B4DE POP AF Restore AF from the stack.
ThemeMusic_4 B4DF CALL Handler_GameMenuInput Call Handler_GameMenuInput.
B4E2 DEC A Decrease A by one.
B4E3 JR NZ,ThemeMusic_4 Jump to ThemeMusic_4 until A is zero.
B4E5 JR ThemeMusic_2 Jump to ThemeMusic_2.
Prev: B482 Up: Map Next: B4E7