.ChooseMusic_b6 PHA ; Wait until the next NMI interrupt has passed (i.e. the JSR WaitForNMI ; next VBlank), preserving the value in A via the stack PLA ORA #%10000000 ; Set bit 7 of the tune number and store in newTune to STA newTune ; indicate that we are now in the process of changing to ; this tune AND #%01111111 ; Clear bit 7 to set A to the tune number once again LDX disableMusic ; If music is disabled then bit 7 of disableMusic will BMI RTS4 ; be set, so jump to RTS4 to return from the subroutine ; as we can't choose a new tune if music is disabled STA storeA ; Store the value of A so we can retrieve it below LDA currentBank ; If ROM bank 6 is already paged into memory, jump to CMP #6 ; bank1 BEQ bank1 PHA ; Otherwise store the current bank number on the stack LDA #6 ; Page ROM bank 6 into memory at $8000 JSR SetBank LDA storeA ; Restore the value of A that we stored above JSR ChooseMusic ; Call ChooseMusic, now that it is paged into memory JMP ResetBank ; Fetch the previous ROM bank number from the stack and ; page that bank back into memory at $8000, returning ; from the subroutine using a tail call .bank1 LDA storeA ; Restore the value of A that we stored above JMP ChooseMusic ; Call ChooseMusic, which is already paged into memory, ; and return from the subroutine using a tail callName: ChooseMusic_b6 [Show more] Type: Subroutine Category: Sound Summary: Call the ChooseMusic routine in ROM bank 6 Deep dive: Splitting NES Elite across multiple ROM banksContext: See this subroutine in context in the source code References: This subroutine is called as follows: * DEATH2 calls ChooseMusic_b6 * DrawTitleScreen calls ChooseMusic_b6 * PauseGame calls ChooseMusic_b6 * TT102 calls ChooseMusic_b6
Arguments: A The number of the tune to choose
[X]
Subroutine ChooseMusic (category: Sound)
Set the tune for the background music
[X]
Entry point RTS4 in subroutine ResetBankP (category: Utility routines)
Contains an RTS
[X]
Subroutine ResetBank (category: Utility routines)
Retrieve a ROM bank number from the stack and page that bank into memory at $8000
[X]
Subroutine SetBank (category: Utility routines)
Page a specified ROM bank into memory at $8000
[X]
Subroutine WaitForNMI (category: Utility routines)
Wait until the next NMI interrupt has passed (i.e. the next VBlank)
[X]
Label bank1 is local to this routine
[X]
Variable currentBank in workspace ZP
Contains the number of the ROM bank (0 to 6) that is currently paged into memory at $8000
[X]
Variable disableMusic in workspace WP
Music on/off configuration setting