Prev: 45320 Up: Map Next: 45413
45328: Handle Bouncing Mouse
The handler for the robot mice (objects 86 and 87) which run to and fro along one axis. A mouse which is not moving is given a speed from the way it faces, doubled. When it is blocked it reverses its speed, makes a noise and turns to face the other way.
Input
IX The address of the object
Move along the x axis, and reverse if blocked.
HandleBouncingMouse 45328 CALL SetPixelAdjustments_Mouse Call SetPixelAdjustments_Mouse.
45331 CALL ExtendObjectDownwards Call ExtendObjectDownwards.
HandleBouncingMouse_Move 45334 LD A,(IX+9) Fetch the speed along the x axis.
45337 AND A Jump to HandleBouncingMouse_MoveAlongY if it is zero.
45338 JR Z,HandleBouncingMouse_MoveAlongY
45340 LD (IX+16),A Remember the speed.
45343 CALL ApplyGravityAndMove Call ApplyGravityAndMove.
45346 BIT 0,(IX+12) Jump to HandleBouncingMouse_Finish if the mouse has not been blocked along the x axis.
45350 JR Z,HandleBouncingMouse_Finish
45352 LD A,(IX+16) Fetch the speed which was remembered.
45355 NEG Make the speed negative.
45357 LD (IX+9),A Set the speed along the x axis.
HandleBouncingMouse_Bounce 45360 CALL PlayBumpSound Call PlayBumpSound.
45363 CALL FaceDirectionOfMovement Call FaceDirectionOfMovement.
HandleBouncingMouse_Finish 45366 CALL RestoreObjectHeight Call RestoreObjectHeight.
45369 JP SetDeadlyFlagsAndDraw Jump to SetDeadlyFlagsAndDraw.
Move along the y axis, and reverse if blocked.
HandleBouncingMouse_MoveAlongY 45372 LD A,(IX+10) Fetch the speed along the y axis.
45375 AND A Jump to HandleBouncingMouse_StartMoving if it is zero.
45376 JR Z,HandleBouncingMouse_StartMoving
45378 LD (IX+16),A Remember the speed.
45381 CALL ApplyGravityAndMove Call ApplyGravityAndMove.
45384 BIT 1,(IX+12) Jump to HandleBouncingMouse_Finish if the mouse has not been blocked along the y axis.
45388 JR Z,HandleBouncingMouse_Finish
45390 LD A,(IX+16) Fetch the speed which was remembered.
45393 NEG Make the speed negative.
45395 LD (IX+10),A Set the speed along the y axis.
45398 JR HandleBouncingMouse_Bounce Jump to HandleBouncingMouse_Bounce.
The mouse is not moving.
HandleBouncingMouse_StartMoving 45400 CALL SetMouseSpeed Call SetMouseSpeed.
45403 SLA (IX+9) Double the speed along the x axis.
45407 SLA (IX+10) Double the speed along the y axis.
45411 JR HandleBouncingMouse_Move Jump to HandleBouncingMouse_Move.
Prev: 45320 Up: Map Next: 45413