Prev: EC2A Up: Map Next: EC5E
EC35: Play Melody
Input
HL Pointer to music data
PlayMelody EC35 DI Disable interrupts.
EC36 XOR A A=00.
FetchNote EC37 LD C,(HL) C=*HL.
Check for the terminator (FF).
EC38 INC C Increment C by one.
EC39 JR NZ,PlayingMelody Jump to PlayingMelody if C is not zero.
The terminator (FF) was reached so return.
EC3B EI Enable interrupts.
EC3C RET Return.
Restore the real value of the note after the terminator check.
PlayingMelody EC3D DEC C Decrease C by one.
EC3E INC HL Increment the music data pointer by one.
EC3F LD E,(HL) E=*HL.
EC40 INC HL Increment the music data pointer by one.
EC41 LD D,(HL) D=*HL.
EC42 INC HL Increment the music data pointer by one.
PlayMelody_Speaker EC43 OUT ($FE),A OUT FE
EC45 LD B,C B=C.
EC46 XOR %00010000 Flip bit 4.
PlayMelody_Loop EC48 DJNZ PlayMelody_Loop Decrease counter by one and loop back to PlayMelody_Loop until counter is zero.
EC4A LD B,A B=A.
EC4B DEC DE Decrease DE by one.
EC4C LD A,D Is DE zero?
EC4D OR E
EC4E LD A,B A=B.
EC4F JR NZ,PlayMelody_Speaker Jump to PlayMelody_Speaker if DE is not zero.
EC51 LD D,$0F D=0F.
PlayMelody_Pause EC53 DEC DE Decrease DE by one.
EC54 LD A,D Is DE zero?
EC55 OR E
EC56 JR NZ,PlayMelody_Pause Jump to PlayMelody_Pause if DE is not zero.
EC58 LD A,B A=B.
EC59 INC A Increment A by one.
EC5A AND %00010111 Keep only bits 0-2 and 4.
EC5C JR FetchNote Jump to FetchNote.
Prev: EC2A Up: Map Next: EC5E