Prev: 37579 Up: Map Next: 37675
37596: Play the theme tune (The Blue Danube)
Used by the routine at 34252. Returns with the zero flag reset if ENTER or the fire button is pressed while the tune is being played.
Input
IY 33902 (tune data)
37596 LD A,(IY+0) Pick up the next byte of tune data from the table at 33902
37599 CP 255 Has the tune finished?
37601 RET Z Return (with the zero flag set) if so
37602 LD C,A Copy the first byte of data for this note (which determines the duration) to C
37603 LD B,0 Initialise B, which will be used as a delay counter in the note-producing loop
37605 XOR A Set A=0 (for no apparent reasaon)
37606 LD D,(IY+1) Pick up the second byte of data for this note
37609 LD A,D Copy it to A
37610 CALL 37675 Calculate the attribute file address for the corresponding piano key
37613 LD (HL),80 Set the attribute byte for the piano key to 80 (INK 0: PAPER 2: BRIGHT 1)
37615 LD E,(IY+2) Pick up the third byte of data for this note
37618 LD A,E Copy it to A
37619 CALL 37675 Calculate the attribute file address for the corresponding piano key
37622 LD (HL),40 Set the attribute byte for the piano key to 40 (INK 0: PAPER 5: BRIGHT 0)
37624 OUT (254),A Produce a sound based on the frequency parameters in the second and third bytes of data for this note (copied into D and E)
37626 DEC D
37627 JR NZ,37634
37629 LD D,(IY+1)
37632 XOR 24
37634 DEC E
37635 JR NZ,37642
37637 LD E,(IY+2)
37640 XOR 24
37642 DJNZ 37624
37644 DEC C
37645 JR NZ,37624
37647 CALL 37687 Check whether ENTER or the fire button is being pressed
37650 RET NZ Return (with the zero flag reset) if it is
37651 LD A,(IY+1) Pick up the second byte of data for this note
37654 CALL 37675 Calculate the attribute file address for the corresponding piano key
37657 LD (HL),56 Set the attribute byte for the piano key back to 56 (INK 0: PAPER 7: BRIGHT 0)
37659 LD A,(IY+2) Pick up the third byte of data for this note
37662 CALL 37675 Calculate the attribute file address for the corresponding piano key
37665 LD (HL),56 Set the attribute byte for the piano key back to 56 (INK 0: PAPER 7: BRIGHT 0)
37667 INC IY Move IY along to the data for the next note in the tune
37669 INC IY
37671 INC IY
37673 JR 37596 Jump back to play the next note
Prev: 37579 Up: Map Next: 37675