Prev: 88F2 Up: Map Next: 8960
8903: Drives sound effects
Called once per frame. Outside a tunnel it ORs the two passed-object triggers together and queues effect 7 ("tit") if either is set. It then calls the engine, regular and audio-register hooks. Finally, if sfx_index is non-zero it indexes the four-byte entries of the table at sfx_table, clears the index and the priority, and calls the entry's routine with the entry's two argument bytes in DE.
Used by the routine at main_loop.
drive_sfx 8903 LD A,($A23B) Jump if tunnel_sfx
8906 AND A
8907 JR NZ,drs_skip_effect_no7
If trigger_right_hand_passed_object_sfx or trigger_left_hand_passed_object_sfx is set then play effect 7 ("tit").
8909 LD A,($A23C) Load trigger_right_hand_passed_object_sfx
890C LD HL,$A23D Load address of trigger_left_hand_passed_object_sfx
890F OR (HL) OR together vars and set flags
8910 LD BC,$0704 Effect 7 (tit), Priority 4
8913 CALL NZ,start_sfx Call start_sfx if non-zero
drs_skip_effect_no7 8916 CALL play_engine_sfx_hook Call play_engine_sfx_hook
8919 CALL play_regular_sfx_hook Call play_regular_sfx_hook -- plays engine in 48K, siren in 128K
891C CALL write_audio_registers_hook Call write_audio_registers_hook -- nop in 48K
891F LD A,($A237) If sfx_index == 0 return
8922 AND A
8923 RET Z
8924 RLCA E = sfx_index * 4 -- stride of table
8925 RLCA
8926 LD E,A
8927 XOR A sfx_index = 0
8928 LD ($A237),A
892B LD ($A238),A sfx_priority = 0
892E LD D,A Make DE full offset
892F LD HL,$8938 HL -> Base of table, but 4 bytes earlier
8932 ADD HL,DE Point at array element
8933 LD D,(HL) Load argument value into DE (note: big endian!)
8934 INC HL
8935 LD E,(HL)
8936 INC HL
8937 LD A,(HL) Load address of routine into HL
8938 INC HL
8939 LD H,(HL)
893A LD L,A
893B JP (HL) Exit via routine at HL
Pairs of words: (argument [big endian], address of sound effect routine) The first word is the argument passed in DE to sound effect routine. The second word is the address of the routine.
Effect 1 - Cornering squeal
sfx_table 893C DEFW $0164
893E DEFW sfx_cornering
Effect 2 - Car landing (low thump)
8940 DEFW $0008
8942 DEFW sfx_thud
Effect 3 - Crash (high) - Used for hits on cars
8944 DEFW $0008 Play sfx_crash with speed 8
8946 DEFW sfx_crash
Effect 4 - Crash (low) - Used for hits on scenery
8948 DEFW $000C Play sfx_crash with speed 12
894A DEFW sfx_crash
Effect 5 - Hazard hit (high thump)
894C DEFW $0003
894E DEFW sfx_thud
Effect 6 - Tunnel wall hit
8950 DEFW $041A
8952 DEFW sfx_cornering_loop_outer
Effect 7 - Cornering ("tit")
8954 DEFW $7804
8956 DEFW sfx_cornering_loop_outer
Effect 8 - Time running out high ("bip")
8958 DEFW $7878
895A DEFW sfx_bipbow
Effect 9 - Time running out low ("bow")
895C DEFW $C8C8
895E DEFW sfx_bipbow
Prev: 88F2 Up: Map Next: 8960