Prev: 27251 Up: Map Next: 27424
27288: Update Slug
Updates a slug. If the slug is touching Robbie then both explode. A weapon hitting the slug either kills it (a smoke bomb, worth 53 points) or stuns it (a streamer), and the repellent spray has no effect. When the slug reaches the flower it starts to eat it.
Otherwise it crawls around, moving once every four updates: 4 pixels horizontally, bouncing off the sides of the play area, and 1 pixel vertically (but only when it is in the middle of the play area).
Input
IX Slug object
The object fields used are:
Field Use
+0 bit 6 Moving right
+0 bit 7 Moving down
+4 bit 3 Eating the flower
+5 Stun timer
+6 Y position when the slug started eating
UpdateSlug 27288 CALL UpdateBugCommon Do the common bug checks using UpdateBugCommon.
27291 DEC E Decrease the collision result in E by one (zero means that the slug is touching Robbie).
27292 JP Z,ExplodeRobbie Jump to ExplodeRobbie if the slug is touching Robbie.
27295 CALL CheckWeaponHit Call CheckWeaponHit to check whether a weapon has hit the slug.
27298 DEC E Decrease the collision result in E by one (zero means that a weapon has hit the slug).
27299 JR NZ,UpdateSlug_NoWeaponHit Jump to UpdateSlug_NoWeaponHit if there was no hit.
27301 LD A,C A=the state of the weapon, and jump to SlugWeaponHit if the weapon is active.
27302 AND A
27303 JP NZ,SlugWeaponHit
This entry point is used by the routine at SlugWeaponHit.
UpdateSlug_NoWeaponHit 27306 BIT 3,(IX+4) Jump to EatFlower if the slug is eating the flower.
27310 JP NZ,EatFlower
27313 CALL BugFlowerCollision Check whether the slug has reached the flower using BugFlowerCollision.
27316 DEC E Decrease the collision result in E by one (zero means that the slug has reached the flower).
27317 JP Z,StartEatingFlower Jump to StartEatingFlower if the slug has reached the flower, to start eating it.
27320 LD A,(IX+5) Jump to UpdateSlug_Move if the stun timer in IX+5 is zero.
27323 AND A
27324 JR Z,UpdateSlug_Move
27326 DEC (IX+5) Decrease the stun timer by one.
27329 JR UpdateSlug_Draw Jump to UpdateSlug_Draw to draw the slug without moving it.
UpdateSlug_Move 27331 LD A,(24087) A=the game timer from GameTimer.
27334 AND %00000011 Keep only bits 0-1 (the slug only moves every fourth update).
27336 JR NZ,UpdateSlug_Draw Jump to UpdateSlug_Draw to draw the slug if it is not time to move.
27338 LD A,(IX+1) A=the X position of the slug.
27341 CP 24 Jump to UpdateSlug_Horizontal if the slug is too far to the left to move vertically.
27343 JR C,UpdateSlug_Horizontal
27345 CP 208 Jump to UpdateSlug_Horizontal if the slug is too far to the right to move vertically.
27347 JR NC,UpdateSlug_Horizontal
27349 LD A,(IX+2) A=the Y position of the slug.
27352 BIT 7,(IX+0) Jump to UpdateSlug_MoveUp if the slug is moving up (bit 7 is not set).
27356 JR Z,UpdateSlug_MoveUp
27358 ADD A,1 Add 1 to move down.
27360 CP 184 Jump to UpdateSlug_TurnUp if the slug has reached the bottom.
27362 JR NC,UpdateSlug_TurnUp
UpdateSlug_StoreY 27364 LD (IX+2),A Write the new Y position.
UpdateSlug_Horizontal 27367 LD A,(IX+1) A=the X position of the slug.
27370 BIT 6,(IX+0) Jump to UpdateSlug_MoveLeft if the slug is moving left (bit 6 is not set).
27374 JR Z,UpdateSlug_MoveLeft
27376 ADD A,4 Add 4 to move right.
27378 CP 208 Jump to UpdateSlug_TurnLeft if the slug has reached the right edge.
27380 JR NC,UpdateSlug_TurnLeft
UpdateSlug_StoreX 27382 LD (IX+1),A Write the new X position.
This entry point is used by the routine at EatFlower.
UpdateSlug_Draw 27385 JP DrawObject Jump to DrawObject to draw the slug.
UpdateSlug_MoveUp 27388 SUB 1 Subtract 1 to move up.
27390 CP 40 Jump to UpdateSlug_StoreY if the slug has not reached the top.
27392 JR NC,UpdateSlug_StoreY
27394 SET 7,(IX+0) Set bit 7 of IX+0 (turn the slug downwards).
27398 JR UpdateSlug_Horizontal Jump to UpdateSlug_Horizontal.
UpdateSlug_TurnUp 27400 RES 7,(IX+0) Reset bit 7 of IX+0 (turn the slug upwards).
27404 JR UpdateSlug_Horizontal Jump to UpdateSlug_Horizontal.
UpdateSlug_MoveLeft 27406 SUB 4 Subtract 4 to move left.
27408 CP 24 Jump to UpdateSlug_StoreX if the slug has not reached the left edge.
27410 JR NC,UpdateSlug_StoreX
27412 SET 6,(IX+0) Set bit 6 of IX+0 (turn the slug to the right).
27416 JR UpdateSlug_Draw Jump to UpdateSlug_Draw.
UpdateSlug_TurnLeft 27418 RES 6,(IX+0) Reset bit 6 of IX+0 (turn the slug to the left).
27422 JR UpdateSlug_Draw Jump to UpdateSlug_Draw.
Prev: 27251 Up: Map Next: 27424