Prev: 7E07 Up: Map Next: 7E61
7E17: Play a tune
Used by the routines at 7E86, 7E90, 7E96 and 7EA2.
Input
HL Base address of the tune data table
7E17 DI Disable interrupts
7E18 LD A,(HL) Pick up a tune datum in A
7E19 INC HL Point HL at the next tune datum
7E1A AND A Is the tune finished?
7E1B JR NZ,$7E22 Jump if not
7E1D INC A Make the border blue
7E1E OUT ($FE),A
7E20 EI Re-enable interrupts
7E21 RET
A non-zero tune datum has been found, meaning the tune is not finished yet.
7E22 PUSH HL
7E23 LD B,A Copy the tune datum to B
7E24 RRCA Should we pause briefly (bit 0 set) here?
7E25 JR NC,$7E30 Jump if not
7E27 LD DE,$0F00 Pause briefly (this happens for all but one note in the theme tune, and for all notes in the 'all shields/safe' tune)
7E2A DEC E
7E2B JR NZ,$7E2A
7E2D DEC D
7E2E JR NZ,$7E2A
7E30 AND $07 0<=A<=7
7E32 LD C,A C=border colour for this note
7E33 ADD A,A Point HL at the appropriate entry in the note pitch/duration data table at 7E07
7E34 ADD A,$07
7E36 LD L,A
7E37 LD H,$7E
7E39 LD A,B A=original tune datum
7E3A RLCA Obtain the note frequency parameter in E and the note duration parameter in HL
7E3B RLCA
7E3C RLCA
7E3D RLCA
7E3E AND $0F
7E40 LD B,A
7E41 LD E,(HL)
7E42 INC L
7E43 LD A,(HL)
7E44 LD HL,$0000
7E47 ADD HL,DE
7E48 DJNZ $7E47
7E4A RR H
7E4C RR L
7E4E LD E,A
7E4F LD A,C Produce a note
7E50 OUT ($FE),A
7E52 XOR $10
7E54 LD C,A
7E55 LD B,E
7E56 DJNZ $7E56
7E58 DEC HL
7E59 LD A,H
7E5A OR L
7E5B JR NZ,$7E4F
7E5D POP HL Restore the pointer to the tune data table
7E5E JP $7E18 Pick up the next tune datum
Prev: 7E07 Up: Map Next: 7E61