| Routines

92DC: Play the theme tune (The Blue Danube)

Used by the routine at 85CC. Returns with the zero flag reset if ENTER or the fire button is pressed while the tune is being played.
Input
IY | 846E (tune data)
92DC | LD A,(IY+$00) | Pick up the next byte of tune data from the table at 846E
92DF | CP $FF | Has the tune finished?
92E1 | RET Z | Return (with the zero flag set) if so
92E2 | LD C,A | Copy the first byte of data for this note (which determines the duration) to C
92E3 | LD B,$00 | Initialise B, which will be used as a delay counter in the note-producing loop
92E5 | XOR A | Set A=0 (for no apparent reasaon)
92E6 | LD D,(IY+$01) | Pick up the second byte of data for this note
92E9 | LD A,D | Copy it to A
92EA | CALL $932B | Calculate the attribute file address for the corresponding piano key
92ED | LD (HL),$50 | Set the attribute byte for the piano key to 0x50 (INK 0: PAPER 2: BRIGHT 1)
92EF | LD E,(IY+$02) | Pick up the third byte of data for this note
92F2 | LD A,E | Copy it to A
92F3 | CALL $932B | Calculate the attribute file address for the corresponding piano key
92F6 | LD (HL),$28 | Set the attribute byte for the piano key to 0x28 (INK 0: PAPER 5: BRIGHT 0)
92F8 | OUT ($FE),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)
92FA | DEC D
92FB | JR NZ,$9302
92FD | LD D,(IY+$01)
9300 | XOR $18
9302 | DEC E
9303 | JR NZ,$930A
9305 | LD E,(IY+$02)
9308 | XOR $18
930A | DJNZ $92F8
930C | DEC C
930D | JR NZ,$92F8
930F | CALL $9337 | Check whether ENTER or the fire button is being pressed
9312 | RET NZ | Return (with the zero flag reset) if it is
9313 | LD A,(IY+$01) | Pick up the second byte of data for this note
9316 | CALL $932B | Calculate the attribute file address for the corresponding piano key
9319 | LD (HL),$38 | Set the attribute byte for the piano key back to 0x38 (INK 0: PAPER 7: BRIGHT 0)
931B | LD A,(IY+$02) | Pick up the third byte of data for this note
931E | CALL $932B | Calculate the attribute file address for the corresponding piano key
9321 | LD (HL),$38 | Set the attribute byte for the piano key back to 0x38 (INK 0: PAPER 7: BRIGHT 0)
9323 | INC IY | Move IY along to the data for the next note in the tune
9325 | INC IY
9327 | INC IY
9329 | JR $92DC | Jump back to play the next note