Prev: 32263 Up: Map Next: 32353
32279: Play a tune
Used by the routines at 32390, 32400, 32406 and 32418.
Input
HL Base address of the tune data table
32279 DI Disable interrupts
32280 LD A,(HL) Pick up a tune datum in A
32281 INC HL Point HL at the next tune datum
32282 AND A Is the tune finished?
32283 JR NZ,32290 Jump if not
32285 INC A Make the border blue
32286 OUT (254),A
32288 EI Re-enable interrupts
32289 RET
A non-zero tune datum has been found, meaning the tune is not finished yet.
32290 PUSH HL
32291 LD B,A Copy the tune datum to B
32292 RRCA Should we pause briefly (bit 0 set) here?
32293 JR NC,32304 Jump if not
32295 LD DE,3840 Pause briefly (this happens for all but one note in the theme tune, and for all notes in the 'all shields/safe' tune)
32298 DEC E
32299 JR NZ,32298
32301 DEC D
32302 JR NZ,32298
32304 AND 7 0<=A<=7
32306 LD C,A C=border colour for this note
32307 ADD A,A Point HL at the appropriate entry in the note pitch/duration data table at 32263
32308 ADD A,7
32310 LD L,A
32311 LD H,126
32313 LD A,B A=original tune datum
32314 RLCA Obtain the note frequency parameter in E and the note duration parameter in HL
32315 RLCA
32316 RLCA
32317 RLCA
32318 AND 15
32320 LD B,A
32321 LD E,(HL)
32322 INC L
32323 LD A,(HL)
32324 LD HL,0
32327 ADD HL,DE
32328 DJNZ 32327
32330 RR H
32332 RR L
32334 LD E,A
32335 LD A,C Produce a note
32336 OUT (254),A
32338 XOR 16
32340 LD C,A
32341 LD B,E
32342 DJNZ 32342
32344 DEC HL
32345 LD A,H
32346 OR L
32347 JR NZ,32335
32349 POP HL Restore the pointer to the tune data table
32350 JP 32280 Pick up the next tune datum
Prev: 32263 Up: Map Next: 32353