Prev: 9ADE Up: Map Next: 9B59
9B0D: Play tune
Used by the routines at L9BD9, process_tune_byte and call_play_tune.
Input
A Index of tune (0 - 6)
play_tune 9B0D CP $07 If tune index is 7
9B0F JR Z,play_tune_0 Then skip ahead
9B11 LD (tune_index),A Else save tune index
9B14 LD HL,$7284 tune_data_buffer_1+7
9B17 LD (HL),$02 Set to 2
play_tune_0 9B19 RLCA Multiply index by 8
9B1A RLCA ...
9B1B RLCA ...
9B1C LD E,A DE = A
9B1D LD D,$00 ...
9B1F LD HL,tune_data_table Table base address
9B22 ADD HL,DE Add offset
9B23 LD IX,tune_data_buffer_1 First tune data buffer
9B27 LD B,$04 4 channels
9B29 LD E,$0A 10 bytes each
play_tune_1 9B2B LD A,(HL) Get LSB
9B2C LD (IX+$01),A Store in tune data buffer
9B2F INC HL Next table address
9B30 LD A,(HL) Get MSB
9B31 LD (IX+$02),A Store in tune data buffer
9B34 LD (IX+$05),$01 Set countdown
9B38 INC HL Next table address
9B39 LD (IX+$09),$00 Countdown for relative jumps
9B3D ADD IX,DE Next channel
9B3F DJNZ play_tune_1 Loop for 4 channels
9B41 LD A,$05 Tune speed?
9B43 LD (sound_player_countdown),A Init countdown
9B46 LD (is_tune_playing),A Set a tune is playing
9B49 LD A,(tune_index) Get tune index
9B4C DEC A Minus 1
9B4D JR Z,play_tune_2 If tune index was 1 then skip ahead and set C = 9
9B4F RET P If tune index was > 1 then return
9B50 LD C,$05 Set C = 5 (sound index)
9B52 JR play_tune_3 Skip next
play_tune_2 9B54 LD C,$09 Set C = 9 (sound index)
play_tune_3 9B56 JP play_sound_fx_2 Play sound
Prev: 9ADE Up: Map Next: 9B59