Prev: 30248 Up: Map Next: 30329
30259: UFO Abduct Percy
Used by the routine at Handler_UFO.
Handles the UFO's abduction of Percy. Teleports Percy to the UFO's position while playing a tractor beam sound effect, then on the final frame drops Percy downward.
Input
IX Pointer to UFO sprite data
UFO_Abduct_Percy 30259 CP 1 Jump to UFO_Drop_Percy if the abduction timer is equal to 1 (final frame of abduction).
30261 JR Z,UFO_Drop_Percy
Play the tractor beam sound effect.
30263 LD HL,30335 Point HL at UFO_Tractor_Beam_Pitch (tractor beam sound pitch).
30266 LD E,(HL) Load the pitch into E and C.
30267 LD C,(HL)
Tractor_Beam_SoundStep_Loop 30268 LD B,E Copy to B.
30269 LD A,1 Set initial speaker state to 1.
Tractor_Beam_Sound_Inner 30271 NOP Action a delay loop.
30272 DJNZ Tractor_Beam_Sound_Inner
30274 XOR %00011000 Toggle the speaker bits and output to the speaker port.
30276 OUT (254),A
30278 DEC C Decrement C and loop back to Tractor_Beam_SoundStep_Loop until the sound step is complete.
30279 JR NZ,Tractor_Beam_SoundStep_Loop
30281 LD A,(HL) Complement and mask the pitch value.
30282 CPL
30283 AND %00111111
30285 LD (HL),A Write back to *HL.
Teleport Percy to the UFO's position.
30286 LD A,(IX+0) Copy the UFO's X position to Percy's X at *Percy_X_Position.
30289 LD (56000),A
30292 LD A,(IX+1) Copy the UFO's Y position plus 10 to Percy's Y at *Percy_Y_Position.
30295 ADD A,10
30297 LD (56001),A
30300 LD A,(IX+2) Copy the UFO's sprite active value to Percy's at *Percy_Colour.
30303 LD (56002),A
30306 XOR A Write 0 to clear *FallingState.
30307 LD (24487),A
30310 JP CancelEggDrop Jump to CancelEggDrop.
Final frame of abduction; drop Percy downward.
UFO_Drop_Percy 30313 LD A,(56001) Add 20 to Percy's Y position at *Percy_Y_Position.
30316 ADD A,20
30318 LD (56001),A
30321 LD (24487),A Write the result to *FallingState (set collision flag).
30324 XOR A Write 0 to clear *UFO_Abduction_Timer.
30325 LD (30334),A
30328 RET Return.
Prev: 30248 Up: Map Next: 30329