![]() |
Routines |
| Prev: 25948 | Up: Map | Next: 26004 |
|
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 255.
|
||||||||
| PlayMusic | 25960 | LD A,(DE) | Fetch the next note of the tune. | |||||
| 25961 | CP 255 | Return if the end of the tune (255) has been reached. | ||||||
| 25963 | RET Z | |||||||
| 25964 | AND %00011111 | Keep only bits 0-4 (the note number). | ||||||
| 25966 | DEC A | Decrease the note number by one (note numbers start from 1). | ||||||
| 25967 | SLA A | Double the note number, as there are two bytes for each note. | ||||||
| 25969 | LD C,A | Use the result as an offset into the table of notes. | ||||||
| 25970 | LD B,0 | |||||||
| 25972 | LD HL,26004 | Find the entry for the note in MusicNotes. | ||||||
| 25975 | ADD HL,BC | |||||||
| 25976 | PUSH DE | Stash the pointer to the tune on the stack. | ||||||
| 25977 | LD A,(HL) | Fetch the pitch of the note. | ||||||
| 25978 | INC HL | Increment HL by one. | ||||||
| 25979 | LD E,(HL) | Fetch the length of the note into E. | ||||||
| 25980 | LD D,0 | Set the high byte of the length to 0. | ||||||
| 25982 | LD L,A | Put the pitch in L. | ||||||
| 25983 | LD H,0 | Set the high byte of the pitch to 0. | ||||||
| 25985 | SLA L | Multiply the pitch by 4 for the BEEPER routine. | ||||||
| 25987 | RL H | |||||||
| 25989 | SLA L | |||||||
| 25991 | RL H | |||||||
| 25993 | PUSH IX | Stash IX on the stack. | ||||||
| 25995 | CALL 949 | Play the note using BEEPER. | ||||||
| 25998 | POP IX | Restore IX from the stack. | ||||||
| 26000 | POP DE | Restore the pointer to the tune from the stack. | ||||||
| 26001 | INC DE | Move on to the next note of the tune. | ||||||
| 26002 | 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: 25948 | Up: Map | Next: 26004 |