| Routines

65111: Make a knocked-out sound effect

Used by the routine at 27303. Makes a sound effect just after ERIC has been knocked over or pushed out of his seat. Your browser doesn't support HTML5 audio. Here is a link to the audio instead.
Input
A | 1 + knockout delay counter value (32757)
65111 | CP 39 | Return (to 27351) unless ERIC has just been knocked over
65113 | RET NZ
65114 | LD HL,275 | A=2 (initial border colour: red), H=1 (pitch adjustment), L=19 (border alternates red/blue), D=0 (duration), E=0 (initial pitch)
65117 | LD DE,0
65120 | LD A,2
This entry point is used by the routines at 58604 (to make the 'hit a shield' sound effect) and 65141 (to make the catapult sound effect) with the following parameters prepared:
A | Initial border colour
D | Duration
E | Initial pitch
H | Pitch adjustment
L | 16 + border XOR value
65122 | XOR L | Flip the border colour and the state of the speaker
65123 | OUT (254),A
65125 | LD B,E | Pitch delay
65126 | DJNZ 65126
65128 | LD B,A | Save A temporarily
65129 | LD A,E | Adjust the pitch
65130 | ADD A,H
65131 | LD E,A
65132 | LD A,B | Restore A
65133 | DEC D | Decrement the duration counter
65134 | JR NZ,65122 | Jump back unless the sound effect is finished
65136 | LD A,1 | Make the border blue before returning
65138 | OUT (254),A
65140 | RET |