![]() |
Routines |
| Prev: 655C | Up: Map | Next: 6594 |
|
Plays a tune using the BEEPER routine. Each byte of the tune is a note number, in bits 0-4, which chooses the pitch and length of the note from the table at MusicNotes. The tune ends at the byte FF.
|
||||||||
| PlayMusic | 6568 | LD A,(DE) | Fetch the next note of the tune. | |||||
| 6569 | CP $FF | Return if the end of the tune (FF) has been reached. | ||||||
| 656B | RET Z | |||||||
| 656C | AND %00011111 | Keep only bits 0-4 (the note number). | ||||||
| 656E | DEC A | Decrease the note number by one (note numbers start from 01). | ||||||
| 656F | SLA A | Double the note number, as there are two bytes for each note. | ||||||
| 6571 | LD C,A | Use the result as an offset into the table of notes. | ||||||
| 6572 | LD B,$00 | |||||||
| 6574 | LD HL,$6594 | Find the entry for the note in MusicNotes. | ||||||
| 6577 | ADD HL,BC | |||||||
| 6578 | PUSH DE | Stash the pointer to the tune on the stack. | ||||||
| 6579 | LD A,(HL) | Fetch the pitch of the note. | ||||||
| 657A | INC HL | Increment HL by one. | ||||||
| 657B | LD E,(HL) | Fetch the length of the note into E. | ||||||
| 657C | LD D,$00 | Set the high byte of the length to 00. | ||||||
| 657E | LD L,A | Put the pitch in L. | ||||||
| 657F | LD H,$00 | Set the high byte of the pitch to 00. | ||||||
| 6581 | SLA L | Multiply the pitch by 04 for the BEEPER routine. | ||||||
| 6583 | RL H | |||||||
| 6585 | SLA L | |||||||
| 6587 | RL H | |||||||
| 6589 | PUSH IX | Stash IX on the stack. | ||||||
| 658B | CALL $03B5 | Play the note using BEEPER. | ||||||
| 658E | POP IX | Restore IX from the stack. | ||||||
| 6590 | POP DE | Restore the pointer to the tune from the stack. | ||||||
| 6591 | INC DE | Move on to the next note of the tune. | ||||||
| 6592 | JR PlayMusic | Jump back to PlayMusic to play the next note (the tune only ends when the terminator is reached). | ||||||
|
View the equivalent code in;
|
||||||||
| Prev: 655C | Up: Map | Next: 6594 |