Routines |
Prev: 65247 | Up: Map |
Used by the routines at RunHandlers and Sounds_Telecast.
|
||||
PlaySounds | 65280 | LD A,(65421) | Return if no sound(s) are set to play (via *MelodyID). | |
65283 | AND A | |||
65284 | RET Z | |||
65285 | LD L,A | Store the melody ID in L temporarily. | ||
Reset the *MelodyID (so it doesn't carry on playing).
|
||||
65286 | XOR A | Write 0 to *MelodyID. | ||
65287 | LD (65421),A | |||
65290 | LD A,L | Restore the melody ID back to A. | ||
Handle special cases for the in-game buildings crumbling and then collapsing.
|
||||
65291 | CP 8 | Jump to InitSound_BuildingCollapsing if the melody is for the building collapsing (8). | ||
65293 | JR Z,InitSound_BuildingCollapsing | |||
65295 | CP 9 | Jump to InitSound_BuildingCrumbling if the melody is for the building crumbling (9). | ||
65297 | JR Z,InitSound_BuildingCrumbling | |||
Fetch the melody data using the melody ID as an offset.
|
||||
65299 | DEC A | Decrease the melody ID by one for the table lookup. | ||
65300 | ADD A,A | Multiple the melody ID by 8 as the table holds eight bytes of data for the melodies. | ||
65301 | ADD A,A | |||
65302 | ADD A,A | |||
65303 | LD H,0 | Create an offset using HL. | ||
65305 | LD L,A | |||
65306 | LD DE,65422 | HL+=Table_Melodies. | ||
65309 | ADD HL,DE | |||
65310 | LD DE,65413 | DE=MelodyBuffer. | ||
65313 | LD BC,8 | BC=0008. | ||
65316 | LDIR | Copy the selected melody data into MelodyBuffer. | ||
65318 | LD A,(65420) | Jump to PlaySounds_Loop if *65420 is equal to 2. | ||
65321 | CP 2 | |||
65323 | JR Z,PlaySounds_Loop | |||
PlaySounds_Loop | 65325 | LD A,(65419) | Jump to Sounds_SpeakerOff if *65419 is zero. | |
65328 | AND A | |||
65329 | JR Z,Sounds_SpeakerOff | |||
65331 | DEC A | Decrease A by one. | ||
65332 | LD (65419),A | Write A to *65419. | ||
65335 | CALL PlayBeeper | Call PlayBeeper. | ||
65338 | ADD HL,BC | HL+=BC. | ||
65339 | LD (65413),HL | Write HL to *MelodyBuffer. | ||
65342 | JR PlaySounds_Loop | Jump to PlaySounds_Loop. | ||
Unused_PlaySound_Loop | 65344 | LD A,(65419) | Jump to Sounds_SpeakerOff if *65419 is zero. | |
65347 | AND A | |||
65348 | JR Z,Sounds_SpeakerOff | |||
65350 | DEC A | Decrease A by one. | ||
65351 | LD (65419),A | Write A to *65419. | ||
65354 | CALL PlayBeeper | Call PlayBeeper. | ||
65357 | OR A | Set the bits from A. | ||
65358 | SBC HL,BC | HL-=BC. | ||
65360 | LD (65413),HL | Write HL to *MelodyBuffer. | ||
65363 | JR Unused_PlaySound_Loop | Jump to Unused_PlaySound_Loop. | ||
PlayBeeper | 65365 | LD HL,(65413) | HL=Loop delay parameter (*65413). | |
65368 | LD DE,(65415) | DE=Number of passes to make through the sound generation loop (*65415). | ||
65372 | CALL 949 | Call BEEPER. | ||
65375 | LD HL,(65413) | HL=*MelodyBuffer. | ||
65378 | LD BC,(65417) | BC=*65417. | ||
65382 | RET | Return. | ||
Flip speaker off (unset bit 4).
|
||||
Sounds_SpeakerOff | 65383 | XOR A | Speaker off. | |
65384 | OUT (254),A | |||
65386 | RET | Return. | ||
InitSound_BuildingCollapsing | 65387 | LD HL,125 | HL=0125. | |
65390 | LD C,100 | C=100. | ||
65392 | JR PlaySounds_Building_Loop | Jump to PlaySounds_Building_Loop. | ||
InitSound_BuildingCrumbling | 65394 | LD HL,250 | HL=0250. | |
65397 | LD C,25 | C=25. | ||
PlaySounds_Building_Loop | 65399 | LD A,(HL) | A=*HL. | |
65400 | AND %11111000 | Keep only bits 3-7. | ||
65402 | OUT (254),A | OUT 254 | ||
65404 | LD B,C | B=C. | ||
PlaySounds_Building_Delay | 65405 | DJNZ PlaySounds_Building_Delay | Decrease counter by one and loop back to PlaySounds_Building_Delay until counter is zero. | |
65407 | DEC HL | Decrease HL by one. | ||
65408 | LD A,H | Jump to PlaySounds_Building_Loop until HL is zero. | ||
65409 | OR L | |||
65410 | JR NZ,PlaySounds_Building_Loop | |||
65412 | RET | Return. | ||
MelodyBuffer | 65413 | DEFB 0,0 | ||
65415 | DEFB 0,0 | |||
65417 | DEFB 0,0 | |||
65419 | DEFB 0 | |||
65420 | DEFB 0 | |||
MelodyID | 65421 | DEFB 0 | ||
Table_Melodies | 65422 | DEFB 244,1,0,0,50,0,10,1 | ||
65430 | DEFB 244,1,0,0,244,1,1,2 | |||
65438 | DEFB 150,0,244,1,200,0,1,2 | |||
65446 | DEFB 100,0,25,0,100,0,4,0 | |||
65454 | DEFB 232,3,1,0,232,3,5,1 | |||
65462 | DEFB 232,3,1,0,244,1,6,1 | |||
65470 | DEFB 150,0,44,1,200,0,1,2 | |||
65478 | DEFB 66,0,0,60,66,66,66,66 | |||
65486 | DEFB 60,0,0,124,66,66,124,64 | |||
65494 | DEFB 64,0,0,60,66,66,82,74 | |||
65502 | DEFB 60,0,0,124,66,66,124,68 | |||
65510 | DEFB 66,0,0,60,64,60,2,66 | |||
65518 | DEFB 60,0,0,254,16,16,16,16 | |||
65526 | DEFB 16,0,0,66,66,66,66,66 | |||
65534 | DEFB 60,0 |
Prev: 65247 | Up: Map |