Prev: FEDF Up: Map
FF00: Play Sounds
Used by the routines at RunHandlers and Sounds_Telecast.
PlaySounds FF00 LD A,($FF8D) Return if no sound(s) are set to play (via *MelodyID).
FF03 AND A
FF04 RET Z
FF05 LD L,A Store the melody ID in L temporarily.
Reset the *MelodyID (so it doesn't carry on playing).
FF06 XOR A Write 00 to *MelodyID.
FF07 LD ($FF8D),A
FF0A LD A,L Restore the melody ID back to A.
Handle special cases for the in-game buildings crumbling and then collapsing.
FF0B CP $08 Jump to InitSound_BuildingCollapsing if the melody is for the building collapsing (08).
FF0D JR Z,InitSound_BuildingCollapsing
FF0F CP $09 Jump to InitSound_BuildingCrumbling if the melody is for the building crumbling (09).
FF11 JR Z,InitSound_BuildingCrumbling
Fetch the melody data using the melody ID as an offset.
FF13 DEC A Decrease the melody ID by one for the table lookup.
FF14 ADD A,A Multiple the melody ID by 08 as the table holds eight bytes of data for the melodies.
FF15 ADD A,A
FF16 ADD A,A
FF17 LD H,$00 Create an offset using HL.
FF19 LD L,A
FF1A LD DE,$FF8E HL+=Table_Melodies.
FF1D ADD HL,DE
FF1E LD DE,$FF85 DE=MelodyBuffer.
FF21 LD BC,$0008 BC=0008.
FF24 LDIR Copy the selected melody data into MelodyBuffer.
FF26 LD A,($FF8C) Jump to PlaySounds_Loop if *FF8C is equal to 02.
FF29 CP $02
FF2B JR Z,PlaySounds_Loop
PlaySounds_Loop FF2D LD A,($FF8B) Jump to Sounds_SpeakerOff if *FF8B is zero.
FF30 AND A
FF31 JR Z,Sounds_SpeakerOff
FF33 DEC A Decrease A by one.
FF34 LD ($FF8B),A Write A to *FF8B.
FF37 CALL PlayBeeper Call PlayBeeper.
FF3A ADD HL,BC HL+=BC.
FF3B LD ($FF85),HL Write HL to *MelodyBuffer.
FF3E JR PlaySounds_Loop Jump to PlaySounds_Loop.
Unused_PlaySound_Loop FF40 LD A,($FF8B) Jump to Sounds_SpeakerOff if *FF8B is zero.
FF43 AND A
FF44 JR Z,Sounds_SpeakerOff
FF46 DEC A Decrease A by one.
FF47 LD ($FF8B),A Write A to *FF8B.
FF4A CALL PlayBeeper Call PlayBeeper.
FF4D OR A Set the bits from A.
FF4E SBC HL,BC HL-=BC.
FF50 LD ($FF85),HL Write HL to *MelodyBuffer.
FF53 JR Unused_PlaySound_Loop Jump to Unused_PlaySound_Loop.
PlayBeeper FF55 LD HL,($FF85) HL=Loop delay parameter (*FF85).
FF58 LD DE,($FF87) DE=Number of passes to make through the sound generation loop (*FF87).
FF5C CALL $03B5 Call BEEPER.
FF5F LD HL,($FF85) HL=*MelodyBuffer.
FF62 LD BC,($FF89) BC=*FF89.
FF66 RET Return.
Flip speaker off (unset bit 4).
Sounds_SpeakerOff FF67 XOR A Speaker off.
FF68 OUT ($FE),A
FF6A RET Return.
InitSound_BuildingCollapsing FF6B LD HL,$007D HL=007D.
FF6E LD C,$64 C=64.
FF70 JR PlaySounds_Building_Loop Jump to PlaySounds_Building_Loop.
InitSound_BuildingCrumbling FF72 LD HL,$00FA HL=00FA.
FF75 LD C,$19 C=19.
PlaySounds_Building_Loop FF77 LD A,(HL) A=*HL.
FF78 AND %11111000 Keep only bits 3-7.
FF7A OUT ($FE),A OUT FE
FF7C LD B,C B=C.
PlaySounds_Building_Delay FF7D DJNZ PlaySounds_Building_Delay Decrease counter by one and loop back to PlaySounds_Building_Delay until counter is zero.
FF7F DEC HL Decrease HL by one.
FF80 LD A,H Jump to PlaySounds_Building_Loop until HL is zero.
FF81 OR L
FF82 JR NZ,PlaySounds_Building_Loop
FF84 RET Return.
MelodyBuffer FF85 DEFB $00,$00
FF87 DEFB $00,$00
FF89 DEFB $00,$00
FF8B DEFB $00
FF8C DEFB $00
MelodyID FF8D DEFB $00
Table_Melodies FF8E DEFB $F4,$01,$00,$00,$32,$00,$0A,$01
FF96 DEFB $F4,$01,$00,$00,$F4,$01,$01,$02
FF9E DEFB $96,$00,$F4,$01,$C8,$00,$01,$02
FFA6 DEFB $64,$00,$19,$00,$64,$00,$04,$00
FFAE DEFB $E8,$03,$01,$00,$E8,$03,$05,$01
FFB6 DEFB $E8,$03,$01,$00,$F4,$01,$06,$01
FFBE DEFB $96,$00,$2C,$01,$C8,$00,$01,$02
FFC6 DEFB $42,$00,$00,$3C,$42,$42,$42,$42
FFCE DEFB $3C,$00,$00,$7C,$42,$42,$7C,$40
FFD6 DEFB $40,$00,$00,$3C,$42,$42,$52,$4A
FFDE DEFB $3C,$00,$00,$7C,$42,$42,$7C,$44
FFE6 DEFB $42,$00,$00,$3C,$40,$3C,$02,$42
FFEE DEFB $3C,$00,$00,$FE,$10,$10,$10,$10
FFF6 DEFB $10,$00,$00,$42,$42,$42,$42,$42
FFFE DEFB $3C,$00
Prev: FEDF Up: Map