Prev: BC67 Up: Map Next: BD6E
BD51: Play Music Until Key Pressed
Used by the routine at HandlerGameMenu.
Plays a tune in the same way as PlayMusic, but stops as soon as any key is pressed. The key press is then handled by the game selection menu (see HandlerGameMenu), as if it had been read there.
Input
DE Music data terminated by FF
PlayMusic_WaitKey BD51 DI Disable interrupts.
Check for any key being pressed.
PlayMusic_WaitKey_Loop BD52 XOR A Select every row of the keyboard.
BD53 OUT ($FD),A Write A to port FD (this has no effect).
BD55 IN A,($FE) Read every half-row of the keyboard at once (the high byte of the port number is zero).
BD57 CPL Flip the bits.
BD58 AND %00011111 Keep only bits 0-4.
BD5A JR Z,PlayMusic_WaitKey_Process Jump to PlayMusic_WaitKey_Process if no keys were pressed.
A key was pressed, so stop playing and hand over to the game menu.
BD5C LD A,($9692) Fetch the game options from GameOptions.
BD5F INC SP Discard the return address.
BD60 INC SP
BD61 JP GameSelect_ReadSecondKeyRow Jump to GameSelect_ReadSecondKeyRow to handle the key press in the game selection menu.
This is identical to PlayMusic except it also handles exiting on a keypress.
PlayMusic_WaitKey_Process BD64 LD A,(DE) Fetch the next note.
BD65 CP $FF Jump to PlayMusic_Return if the end of the tune has been reached (FF).
BD67 JR Z,PlayMusic_Return
BD69 CALL PlayNote Play the note.
BD6C JR PlayMusic_WaitKey_Loop Jump to PlayMusic_WaitKey_Loop to check for a key press.
Prev: BC67 Up: Map Next: BD6E