Prev: 60458 Up: Map Next: 60510
60469: Play Melody
Input
HL Pointer to music data
PlayMelody 60469 DI Disable interrupts.
60470 XOR A A=0.
FetchNote 60471 LD C,(HL) C=*HL.
Check for the terminator (255).
60472 INC C Increment C by one.
60473 JR NZ,PlayingMelody Jump to PlayingMelody if C is not zero.
The terminator (255) was reached so return.
60475 EI Enable interrupts.
60476 RET Return.
Restore the real value of the note after the terminator check.
PlayingMelody 60477 DEC C Decrease C by one.
60478 INC HL Increment the music data pointer by one.
60479 LD E,(HL) E=*HL.
60480 INC HL Increment the music data pointer by one.
60481 LD D,(HL) D=*HL.
60482 INC HL Increment the music data pointer by one.
PlayMelody_Speaker 60483 OUT (254),A OUT 254
60485 LD B,C B=C.
60486 XOR %00010000 Flip bit 4.
PlayMelody_Loop 60488 DJNZ PlayMelody_Loop Decrease counter by one and loop back to PlayMelody_Loop until counter is zero.
60490 LD B,A B=A.
60491 DEC DE Decrease DE by one.
60492 LD A,D Is DE zero?
60493 OR E
60494 LD A,B A=B.
60495 JR NZ,PlayMelody_Speaker Jump to PlayMelody_Speaker if DE is not zero.
60497 LD D,15 D=15.
PlayMelody_Pause 60499 DEC DE Decrease DE by one.
60500 LD A,D Is DE zero?
60501 OR E
60502 JR NZ,PlayMelody_Pause Jump to PlayMelody_Pause if DE is not zero.
60504 LD A,B A=B.
60505 INC A Increment A by one.
60506 AND %00010111 Keep only bits 0-2 and 4.
60508 JR FetchNote Jump to FetchNote.
Prev: 60458 Up: Map Next: 60510