Back to Skool Routines
24477: Play tune
Used by the routine at 62910.
24477 LD HL,23611 Reset bit 5 at 23611, clearing the record of any keypresses before the tune starts
24480 RES 5,(HL)
24482 LD HL,56384 The opening tune data starts at 56385
This entry point is used by the routine at 23907 with HL=56363:
24485 DI Disable interrupts
24486 INC HL Point HL at the next tune datum
24487 LD A,(HL) Pick it up
24488 INC A Is it an end-of-section marker?
24489 JR NZ,24496 Jump if not
24491 INC HL Now HL points at the first datum in the next section
24492 LD A,(HL)
24493 INC HL
24494 LD H,(HL)
24495 LD L,A
24496 LD A,(HL) A=tune datum
24497 AND A Have we reached the end of the tune?
24498 JP Z,62169 Jump if so
A non-zero tune datum has been found, meaning the tune is not finished yet.
24501 PUSH HL Save the tune data table pointer
24502 RRCA Set the carry flag if we should pause briefly
24503 LD B,A Copy the right-rotated tune datum to B
24504 JR NC,24514 Jump unless we should pause briefly
24506 LD D,15 Pause briefly
24508 DEC E
24509 JR NZ,24508
24511 DEC D
24512 JR NZ,24508
24514 AND 7 0<=A<=7
24516 LD C,A C=border colour for this note
24517 ADD A,A 0<=A<=14 (even)
24518 ADD A,240 240<=A<=254 (even)
24520 LD L,A HL now points to an entry in the table at 24560 (see below)
24521 LD H,95
24523 LD A,B A=original tune datum rotated right one bit
24524 RRCA Obtain the note frequency parameter in E and the note duration parameter in HL
24525 RRCA
24526 RRCA
24527 AND 15
24529 LD B,A
24530 LD E,(HL)
24531 INC L
24532 LD A,(HL)
24533 LD HL,0
24536 ADD HL,DE
24537 DJNZ 24536
24539 RES 0,L
24541 LD E,A
24542 LD A,C Produce a note
24543 OUT (254),A
24545 XOR 16
24547 LD C,A
24548 LD B,E
24549 DJNZ 24549
24551 DEC HL
24552 DEC L
24553 LD A,H
24554 OR L
24555 JR NZ,24542
24557 POP HL Restore the tune data table pointer to HL
24558 JR 24486 Pick up the next tune datum
Here are the data tables used by this routine:
Section Data End Next section
56385 59 113 51 183 57 27 91 123 251 255 110 220 56430
56430 49 113 51 119 119 115 255 60 197 50492
50492 241 128 59 113 51 255 60 198 50748
50748 183 57 27 91 123 255 60 199 51004
51004 251 191 59 121 123 255 60 200 51260
51260 119 247 134 0
Section Data End Next section
56364 55 55 55 119 59 127 59 119 55 121 57 121 55 117 51 177 55 255 92 220 56416
56416 55 55 119 59 119 127 127 59 119 55 121 57 255 121 220 56441
56441 49 66 53 183 183 0
0 1 2 3 4 5 6 7
24560 47 196 53 174 60 154 63 145 71 129 80 114 90 101 95 96