![]() |
Routines |
| Prev: 43657 | Up: Map | Next: 43807 |
|
The update routine for the clockwork mouse (objects 116 to 119), which is deadly to touch. It runs along one axis for a random number of passes in IX+16, or until it hits something. Then it chooses a new random speed and turns through a right angle, alternating between the x and y axes. The sprite number says which way it faces, and the flip flag says which axis it uses.
|
||||||||
|
Move the mouse, or choose a new direction.
|
||||||||
| HandleClockworkMouse | 43681 | CALL SetPixelAdjustments_Mouse | Call SetPixelAdjustments_Mouse. | |||||
| 43684 | CALL ApplyGravityAndMove | Call ApplyGravityAndMove. | ||||||
| 43687 | LD A,(IX+9) | Jump to HandleClockworkMouse_ChooseDirection if the mouse is not moving. | ||||||
| 43690 | OR (IX+10) | |||||||
| 43693 | JR Z,HandleClockworkMouse_ChooseDirection | |||||||
| 43695 | LD A,(IX+12) | Fetch the collision flags. | ||||||
| 43698 | AND %00000011 | Keep bits 0 and 1. | ||||||
| 43700 | JR NZ,HandleClockworkMouse_ChooseDirection | Jump to HandleClockworkMouse_ChooseDirection if the mouse has hit something. | ||||||
| 43702 | DEC (IX+16) | Count down the remaining passes. | ||||||
| 43705 | JR Z,HandleClockworkMouse_ChooseDirection | Jump to HandleClockworkMouse_ChooseDirection if they have run out. | ||||||
|
Animate the mouse and redraw it.
|
||||||||
| HandleClockworkMouse_Animate | 43707 | CALL ToggleSpriteNumber | Call ToggleSpriteNumber. | |||||
| 43710 | JP SetDeadlyFlagsAndDraw | Jump to SetDeadlyFlagsAndDraw. | ||||||
|
Choose a new direction.
|
||||||||
| HandleClockworkMouse_ChooseDirection | 43713 | CALL PlayHighBeep | Call PlayHighBeep. | |||||
| 43716 | LD A,(23299) | Fetch 23299. | ||||||
| 43719 | LD C,A | Keep it in C. | ||||||
| 43720 | LD A,(23301) | Fetch RandomSeed2. | ||||||
| 43723 | XOR C | Combine the two. | ||||||
| 43724 | AND %00001111 | Keep bits 0 to 3. | ||||||
| 43726 | LD (IX+16),A | Set the remaining passes. | ||||||
| 43729 | LD A,(IX+7) | Fetch the flags of the mouse. | ||||||
| 43732 | XOR %01000000 | Flip bit 6. | ||||||
| 43734 | LD (IX+7),A | Store the flags. | ||||||
| 43737 | LD A,(23301) | Fetch RandomSeed2. | ||||||
| 43740 | AND %00000001 | Keep bit 0. | ||||||
| 43742 | JR Z,HandleClockworkMouse_CheckFlippedForward | Jump to HandleClockworkMouse_CheckFlippedForward if it is zero. | ||||||
| 43744 | BIT 6,(IX+7) | Jump to HandleClockworkMouse_ChooseSpeed if the mouse is not flipped. | ||||||
| 43748 | JR Z,HandleClockworkMouse_ChooseSpeed | |||||||
|
Turn the mouse round.
|
||||||||
| HandleClockworkMouse_TurnRound | 43750 | LD A,(IX+0) | Fetch the sprite number. | |||||
| 43753 | XOR %00000010 | Flip bit 1. | ||||||
| 43755 | LD (IX+0),A | Store the sprite number. | ||||||
|
Choose a speed of 2 to 5.
|
||||||||
| HandleClockworkMouse_ChooseSpeed | 43758 | LD A,(23298) | Fetch FrameCounter. | |||||
| 43761 | AND %00000011 | Keep bits 0 and 1. | ||||||
| 43763 | ADD A,2 | Add 2. | ||||||
| 43765 | BIT 1,(IX+0) | Jump to HandleClockworkMouse_CheckFlipped if the mouse is facing forwards. | ||||||
| 43769 | JR NZ,HandleClockworkMouse_CheckFlipped | |||||||
| 43771 | NEG | Make the speed negative. | ||||||
| HandleClockworkMouse_CheckFlipped | 43773 | BIT 6,(IX+7) | Jump to HandleClockworkMouse_NegativeSpeed if the mouse is flipped. | |||||
| 43777 | JR NZ,HandleClockworkMouse_NegativeSpeed | |||||||
| 43779 | LD (IX+9),A | Set the speed along the x axis. | ||||||
| 43782 | LD (IX+10),0 | Write 0 as the speed along the y axis. | ||||||
| 43786 | JR HandleClockworkMouse_Animate | Jump to HandleClockworkMouse_Animate. | ||||||
| HandleClockworkMouse_CheckFlippedForward | 43788 | BIT 6,(IX+7) | Jump to HandleClockworkMouse_TurnRound if the mouse is not flipped. | |||||
| 43792 | JR Z,HandleClockworkMouse_TurnRound | |||||||
| 43794 | JR HandleClockworkMouse_ChooseSpeed | Jump to HandleClockworkMouse_ChooseSpeed. | ||||||
| HandleClockworkMouse_NegativeSpeed | 43796 | NEG | Make the speed negative. | |||||
| 43798 | LD (IX+10),A | Set the speed along the y axis. | ||||||
| 43801 | LD (IX+9),0 | Write 0 as the speed along the x axis. | ||||||
| 43805 | JR HandleClockworkMouse_Animate | Jump to HandleClockworkMouse_Animate. | ||||||
| Prev: 43657 | Up: Map | Next: 43807 |