![]() |
Routines |
| Prev: 64ED | Up: Map | Next: 65BA |
|
Updates a leech. If the leech is touching Robbie then both explode. A weapon hitting the leech either kills it (a streamer, worth 75 points) or stuns it for a while (the repellent spray), and smoke bombs have no effect. When the leech touches the flower it starts to eat it. Otherwise it crawls horizontally along the ground in steps of two pixels, bouncing off the sides of the play area, and every so often it also moves vertically for a random period.
|
||||||||||||||||||||
|
The object fields used are:
|
||||||||||||||||||||
| UpdateLeech | 64FA | CALL UpdateBugCommon | Do the common bug checks using UpdateBugCommon. | |||||||||||||||||
| 64FD | DEC E | Decrease the collision result in E by one (zero means that the leech is touching Robbie). | ||||||||||||||||||
| 64FE | JP Z,ExplodeRobbie | Jump to ExplodeRobbie if the leech is touching Robbie. | ||||||||||||||||||
|
Check whether a weapon has hit the leech.
|
||||||||||||||||||||
| 6501 | CALL CheckWeaponHit | Check whether a weapon has hit the leech using CheckWeaponHit. | ||||||||||||||||||
| 6504 | DEC E | Decrease the collision result in E by one (zero means that a weapon has hit the leech). | ||||||||||||||||||
| 6505 | JR NZ,UpdateLeech_NoWeaponHit | Jump to UpdateLeech_NoWeaponHit if there was no hit. | ||||||||||||||||||
| 6507 | LD A,C | A=the state of the weapon, and jump to LeechWeaponHit if the weapon is active. | ||||||||||||||||||
| 6508 | AND A | |||||||||||||||||||
| 6509 | JP NZ,LeechWeaponHit | |||||||||||||||||||
|
This entry point is used by the routine at LeechWeaponHit.
|
||||||||||||||||||||
| UpdateLeech_NoWeaponHit | 650C | BIT 3,(IX+$04) | Jump to EatFlower if the leech is eating the flower. | |||||||||||||||||
| 6510 | JP NZ,EatFlower | |||||||||||||||||||
| 6513 | CALL BugFlowerCollision | Check whether the leech has reached the flower using BugFlowerCollision. | ||||||||||||||||||
| 6516 | DEC E | Decrease the collision result in E by one (zero means that the leech has reached the flower). | ||||||||||||||||||
| 6517 | JP Z,StartEatingFlower | Jump to StartEatingFlower if the leech has reached the flower, to start eating it. | ||||||||||||||||||
|
Is the leech stunned?
|
||||||||||||||||||||
| 651A | BIT 2,(IX+$04) | Jump to UpdateLeech_Vertical if the leech is not stunned. | ||||||||||||||||||
| 651E | JR Z,UpdateLeech_Vertical | |||||||||||||||||||
| 6520 | DEC (IX+$05) | Decrease the stun timer in IX+05 by one. | ||||||||||||||||||
| 6523 | JP NZ,UpdateLeech_Draw | Jump to UpdateLeech_Draw if the leech is still stunned, to redraw it without moving. | ||||||||||||||||||
| 6526 | RES 2,(IX+$04) | Reset bit 2 of IX+04 (the stun has ended). | ||||||||||||||||||
|
If the leech is not moving vertically there is a one in thirty-two chance of it starting to.
|
||||||||||||||||||||
| UpdateLeech_Vertical | 652A | BIT 0,(IX+$04) | Jump to UpdateLeech_MoveVertical if it is moving vertically. | |||||||||||||||||
| 652E | JR NZ,UpdateLeech_MoveVertical | |||||||||||||||||||
| 6530 | LD A,($5E19) | E=the random number from RandomNumber. | ||||||||||||||||||
| 6533 | LD E,A | |||||||||||||||||||
| 6534 | AND $1F | Jump to UpdateLeech_MoveVertical unless the random number is a multiple of 20. | ||||||||||||||||||
| 6536 | JR NZ,UpdateLeech_MoveVertical | |||||||||||||||||||
| 6538 | SET 0,(IX+$04) | Set bit 0 of IX+04 (moving vertically). | ||||||||||||||||||
| 653C | LD A,($5E17) | A=GameTimer. | ||||||||||||||||||
| 653F | AND %00011111 | Keep only bits 0-4. | ||||||||||||||||||
| 6541 | ADD A,$10 | Add 10 (this value is not stored, as the next instruction overwrites it). | ||||||||||||||||||
| 6543 | LD A,(IX+$06) | A=IX+06 (the vertical movement counter). | ||||||||||||||||||
| 6546 | LD A,E | A=the random number. | ||||||||||||||||||
| 6547 | AND %10000000 | Keep only bit 7 (the direction). | ||||||||||||||||||
| 6549 | LD E,A | Keep the direction bit in E. | ||||||||||||||||||
| 654A | LD A,(IX+$00) | A=IX+00 (the state). | ||||||||||||||||||
| 654D | AND %01111111 | Reset bit 7 (move up). | ||||||||||||||||||
| 654F | OR E | Set bit 7 if the random number had bit 7 set, and write the state back. | ||||||||||||||||||
| 6550 | LD (IX+$00),A | |||||||||||||||||||
| 6553 | JR UpdateLeech_NoWeaponHit | Jump to UpdateLeech_NoWeaponHit. | ||||||||||||||||||
| UpdateLeech_MoveVertical | 6555 | BIT 0,(IX+$04) | Jump to UpdateLeech_MoveHorizontal if the leech is not moving vertically. | |||||||||||||||||
| 6559 | JR Z,UpdateLeech_MoveHorizontal | |||||||||||||||||||
| 655B | LD A,(IX+$01) | A=leech X position. | ||||||||||||||||||
| 655E | CP $18 | Jump to UpdateLeech_MoveHorizontal if the leech is too far left to move vertically. | ||||||||||||||||||
| 6560 | JR C,UpdateLeech_MoveHorizontal | |||||||||||||||||||
| 6562 | CP $D8 | Jump to UpdateLeech_MoveHorizontal if the leech is too far right to move vertically. | ||||||||||||||||||
| 6564 | JR NC,UpdateLeech_MoveHorizontal | |||||||||||||||||||
| 6566 | LD A,(IX+$02) | A=leech Y position. | ||||||||||||||||||
| 6569 | BIT 7,(IX+$00) | Jump to UpdateLeech_MoveUp if the leech is moving up (bit 7 is not set). | ||||||||||||||||||
| 656D | JR Z,UpdateLeech_MoveUp | |||||||||||||||||||
| 656F | ADD A,$02 | Add 02 to move down. | ||||||||||||||||||
| 6571 | CP $B8 | Jump to UpdateLeech_StoreY if this is above the bottom of the play area. | ||||||||||||||||||
| 6573 | JR C,UpdateLeech_StoreY | |||||||||||||||||||
| 6575 | RES 7,(IX+$00) | Reset bit 7 of IX+00 (turn the leech upwards). | ||||||||||||||||||
| 6579 | JR UpdateLeech_Countdown | Jump to UpdateLeech_Countdown. | ||||||||||||||||||
| UpdateLeech_StoreY | 657B | LD (IX+$02),A | Write the new Y position. | |||||||||||||||||
| UpdateLeech_Countdown | 657E | DEC (IX+$06) | Decrease the vertical movement counter by one. | |||||||||||||||||
| 6581 | JR NZ,UpdateLeech_MoveHorizontal | Jump to UpdateLeech_MoveHorizontal if the counter is not zero. | ||||||||||||||||||
| 6583 | RES 0,(IX+$04) | Reset bit 0 of IX+04 (stop moving vertically). | ||||||||||||||||||
|
Move the leech horizontally.
|
||||||||||||||||||||
| UpdateLeech_MoveHorizontal | 6587 | LD A,(IX+$01) | A=leech X position. | |||||||||||||||||
| 658A | BIT 6,(IX+$00) | Jump to UpdateLeech_MoveLeft if the leech is moving left (bit 6 is not set). | ||||||||||||||||||
| 658E | JR Z,UpdateLeech_MoveLeft | |||||||||||||||||||
| 6590 | ADD A,$02 | Add 02 to move right. | ||||||||||||||||||
| 6592 | CP $D8 | Jump to UpdateLeech_StoreX if this is not past the right edge. | ||||||||||||||||||
| 6594 | JR C,UpdateLeech_StoreX | |||||||||||||||||||
| 6596 | RES 6,(IX+$00) | Reset bit 6 of IX+00 (turn the leech to the left). | ||||||||||||||||||
| 659A | JR UpdateLeech_Draw | Jump to UpdateLeech_Draw. | ||||||||||||||||||
| UpdateLeech_StoreX | 659C | LD (IX+$01),A | Write the new X position. | |||||||||||||||||
| UpdateLeech_Draw | 659F | JP DrawObject | Jump to DrawObject to draw the leech. | |||||||||||||||||
|
Moving up.
|
||||||||||||||||||||
| UpdateLeech_MoveUp | 65A2 | SUB $02 | Subtract 02 to move up. | |||||||||||||||||
| 65A4 | CP $28 | Jump to UpdateLeech_StoreY if this is not above the top limit. | ||||||||||||||||||
| 65A6 | JR NC,UpdateLeech_StoreY | |||||||||||||||||||
| 65A8 | SET 7,(IX+$00) | Set bit 7 of IX+00 (turn the leech downwards). | ||||||||||||||||||
| 65AC | JR UpdateLeech_StoreY | Jump to UpdateLeech_StoreY. | ||||||||||||||||||
|
Moving left.
|
||||||||||||||||||||
| UpdateLeech_MoveLeft | 65AE | SUB $02 | Subtract 02 to move left. | |||||||||||||||||
| 65B0 | CP $18 | Jump to UpdateLeech_StoreX if this is not past the left edge. | ||||||||||||||||||
| 65B2 | JR NC,UpdateLeech_StoreX | |||||||||||||||||||
| 65B4 | SET 6,(IX+$00) | Set bit 6 of IX+00 (turn the leech to the right). | ||||||||||||||||||
| 65B8 | JR UpdateLeech_Draw | Jump to UpdateLeech_Draw. | ||||||||||||||||||
| Prev: 64ED | Up: Map | Next: 65BA |