Prev: E65B Up: Map Next: E6EC
E666: Play Tune
Used by the routines at Handler_Interrupts and Animate_Introduction.
Plays one note from Data_TuneStream / Data_TuneStreamCopy through the speaker. BC is the note length (1106 in-game, 0A14 on the introduction).
Play_Tune E666 LD A,($647C) Jump to JumpTable_Delay if *SkipDelayFlag is set.
E669 OR A
E66A JP NZ,JumpTable_Delay
E66D LD HL,($6469) Read the next Data_TuneStream byte, wrapping at FF.
E670 LD A,(HL)
E671 CP $FF
E673 JR NZ,Play_Tune_StorePitch
E675 LD HL,$B491
E678 LD ($646B),HL
E67B LD HL,$B370
E67E LD A,(HL)
Play_Tune_StorePitch E67F INC HL Store the pitch and read the matching Data_TuneStreamCopy duration.
E680 LD ($6469),HL
E683 LD ($646D),A
E686 LD HL,($646B)
E689 LD A,(HL)
E68A INC HL
E68B LD ($646B),HL
E68E LD D,A
E68F LD E,$01
E691 LD A,($646D)
E694 LD H,A
E695 LD L,$01
E697 DEC A Jump to Play_Tune_Rest if this is a rest.
E698 JP NZ,Play_Tune_Tone
E69B LD A,D
E69C DEC A
E69D JR Z,Play_Tune_Rest
Play_Tune_Tone E69F LD A,($641D) Load the border colour and set the half-cycle counters.
E6A2 EX AF,AF'
E6A3 LD A,($641D)
E6A6 LD IXh,D
E6A8 LD D,$10
Play_Tune_Toggle E6AA NOP Toggle the speaker and loop back through Play_Tune_Hold and Play_Tune_Release.
E6AB NOP
E6AC EX AF,AF'
E6AD DEC E
E6AE OUT ($FE),A
E6B0 JR NZ,Play_Tune_Hold
E6B2 LD E,IXh
E6B4 XOR D
E6B5 EX AF,AF'
E6B6 DEC L
E6B7 JP NZ,Play_Tune_Release
Play_Tune_Half E6BA OUT ($FE),A Reload the duration and loop back to Play_Tune_Toggle.
E6BC LD L,H
E6BD XOR D
E6BE DJNZ Play_Tune_Toggle
E6C0 DEC C
E6C1 JP NZ,Play_Tune_Toggle
E6C4 RET
Play_Tune_Hold E6C5 JR Z,Play_Tune_Hold Hold until the inner count expires.
E6C7 EX AF,AF'
E6C8 DEC L
E6C9 JP Z,Play_Tune_Half
Play_Tune_Release E6CC OUT ($FE),A Toggle the speaker on the release half-cycle.
E6CE NOP
E6CF NOP
E6D0 DJNZ Play_Tune_Toggle
E6D2 DEC C
E6D3 JP NZ,Play_Tune_Toggle
E6D6 RET
Play_Tune_Rest E6D7 PUSH HL Waste time for a rest.
E6D8 LD HL,$0000
E6DB SRA (HL)
E6DD SRA (HL)
E6DF SRA (HL)
E6E1 NOP
E6E2 POP HL
E6E3 DEC B
E6E4 JP NZ,Play_Tune_Rest
E6E7 DEC C
E6E8 JP NZ,Play_Tune_Rest
E6EB RET
Prev: E65B Up: Map Next: E6EC