Prev: F7FF Up: Map Next: F8B0
F82F: Play menu music (48K mode only)
Almost the same as EE9E.
b7_play_music_48k F82F XOR A Clear the <interrupt flag> at b7pm_wait_for_interrupt
F830 LD ($F3BC),A
F833 LD A,($A16F) Load the end screen's input mask
F836 AND A Set flags
F837 JR NZ,b7pm_wait_for_interrupt Play nothing more once the player has pressed fire
F839 LD A,$00 <Playback started> flag, self modified by F83F below
F83B AND A Set flags
F83C JR NZ,b7pm_delay_1 Jump to b7pm_delay_1 if playback is already running
F83E INC A Otherwise mark playback started by self modifying F839 above
F83F LD ($F34B),A
F842 JR b7pm_reset_pattern Jump to b7pm_reset_pattern
b7pm_delay_1 F844 LD A,$00 Note delay counter. Self modified by F822 above and by F84A, F852, F877 and F89F below
F846 DEC A Decrement and set flags
F847 JP Z,$F361 Jump to b7pm_delay_complete if zero
F84A LD ($F356),A Self modify b7pm_delay_1 above (store the decremented value)
F84D JP $F3A8 Jump to b7pm_zero_or_456
b7pm_delay_complete F850 LD A,$00 Delay reload value. Self modified by F81F above with the first byte of the pattern
F852 LD ($F356),A Self modify b7pm_delay_1 above (reload the delay counter)
F855 LD HL,$0000 Self modified below, cycles $F12x .. $F2xx ish <addr of next music byte>
Fetch a byte of the form 0bdaaaaiii (d is delay bit, aaaa is argument, iii is instrument index)
b7pm_loop F858 LD A,(HL) Fetch a music byte
F859 DEC A Temporarily decrement for testing (will undo later)
F85A JP NZ,$F37A Jump to pm_continue_pattern if the byte is NOT 1 - the terminating byte of the music data
F85D CALL $F310 Call bank7_next_pattern ($F310 when reloc, $F7FF here)
b7pm_reset_pattern F860 LD HL,$0000 Self modified by F825 above with the address of the second music data byte
F863 LD ($F367),HL Self modify F855 above, restarting the pattern
F866 JP $F369 Loop
b7pm_continue_pattern F869 INC HL Advance
F86A LD ($F367),HL Update <addr of next music byte> above
F86D INC A Compensate for earlier decrement
F86E BIT 7,A Jump if music byte < 128
F870 JR Z,b7pm_play_inst
A byte of the form 0b1aaaaiii (1 is delay bit)
F872 AND $7F Isolate delay bit
F874 EX AF,AF' Bank
F875 LD A,$01 Self modify b7pm_delay_1 above, setting the note delay counter to 1
F877 LD ($F356),A
F87A LD ($F3A9),A Self modify b7pm_zero_or_456 below, flagging the extra delay
F87D EX AF,AF' Unbank
A byte now of the form 0b0aaaaiii
b7pm_play_inst F87E LD D,A Save a copy of the byte
F87F AND $07 Extract bottom 3 instrument bits -- must be the command
F881 JR Z,b7pm_zero_or_456 Jump to pm_zero_or_456 if they're zero
F883 LD B,A Save the instrument
F884 LD A,D Extract the four argument bits
F885 SRL A
F887 SRL A
F889 SRL A
F88B DEC B Jump to b7_playdrum_X (b7_playdrum_X) if instrument is 1 -- drum 2
F88C JP Z,$F3CA
F88F DEC B Jump to b7_playdrum_Y (b7_playdrum_Y) if instrument is 2 -- drum 1
F890 JP Z,$F3D1
F893 DEC B Jump to b7_play_noise (b7_play_noise) if instrument is 3 -- noise
F894 JP Z,$F504
b7pm_zero_or_456 F897 LD A,$00 Extra delay counter. Self modified by F7F3 and F87A above and by F8A3 below
F899 AND A Set flags
F89A JR Z,b7pm_start_drums Jump to b7pm_start_drums if zero (no delay)
F89C LD HL,$F356 Self modify b7pm_delay_1 above, decrementing the note delay counter
F89F DEC (HL)
F8A0 LD HL,$F3A9 Self modify b7pm_zero_or_456 above, decrementing the extra delay counter
F8A3 DEC (HL)
b7pm_start_drums F8A4 LD A,$00 <Drum is playing> flag. Self modified by F7F0 above and by F8CA and F8EF below
F8A6 DEC A Decrement
F8A7 JP Z,$F3E0 Jump to b7pd_bank_go if a sample was interrupted part way through, resuming it
b7pm_wait_for_interrupt F8AA LD A,$00 Loop while waiting for this <interrupt flag> to be set
F8AC AND A
F8AD JR Z,b7pm_wait_for_interrupt
F8AF RET Return
Prev: F7FF Up: Map Next: F8B0