Prev: 6A73 Up: Map Next: 6B20
6A98: 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 35 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: 04 pixels horizontally, bouncing off the sides of the play area, and 01 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 6A98 CALL UpdateBugCommon Do the common bug checks using UpdateBugCommon.
6A9B DEC E Decrease the collision result in E by one (zero means that the slug is touching Robbie).
6A9C JP Z,ExplodeRobbie Jump to ExplodeRobbie if the slug is touching Robbie.
6A9F CALL CheckWeaponHit Call CheckWeaponHit to check whether a weapon has hit the slug.
6AA2 DEC E Decrease the collision result in E by one (zero means that a weapon has hit the slug).
6AA3 JR NZ,UpdateSlug_NoWeaponHit Jump to UpdateSlug_NoWeaponHit if there was no hit.
6AA5 LD A,C A=the state of the weapon, and jump to SlugWeaponHit if the weapon is active.
6AA6 AND A
6AA7 JP NZ,SlugWeaponHit
This entry point is used by the routine at SlugWeaponHit.
UpdateSlug_NoWeaponHit 6AAA BIT 3,(IX+$04) Jump to EatFlower if the slug is eating the flower.
6AAE JP NZ,EatFlower
6AB1 CALL BugFlowerCollision Check whether the slug has reached the flower using BugFlowerCollision.
6AB4 DEC E Decrease the collision result in E by one (zero means that the slug has reached the flower).
6AB5 JP Z,StartEatingFlower Jump to StartEatingFlower if the slug has reached the flower, to start eating it.
6AB8 LD A,(IX+$05) Jump to UpdateSlug_Move if the stun timer in IX+05 is zero.
6ABB AND A
6ABC JR Z,UpdateSlug_Move
6ABE DEC (IX+$05) Decrease the stun timer by one.
6AC1 JR UpdateSlug_Draw Jump to UpdateSlug_Draw to draw the slug without moving it.
UpdateSlug_Move 6AC3 LD A,($5E17) A=the game timer from GameTimer.
6AC6 AND %00000011 Keep only bits 0-1 (the slug only moves every fourth update).
6AC8 JR NZ,UpdateSlug_Draw Jump to UpdateSlug_Draw to draw the slug if it is not time to move.
6ACA LD A,(IX+$01) A=the X position of the slug.
6ACD CP $18 Jump to UpdateSlug_Horizontal if the slug is too far to the left to move vertically.
6ACF JR C,UpdateSlug_Horizontal
6AD1 CP $D0 Jump to UpdateSlug_Horizontal if the slug is too far to the right to move vertically.
6AD3 JR NC,UpdateSlug_Horizontal
6AD5 LD A,(IX+$02) A=the Y position of the slug.
6AD8 BIT 7,(IX+$00) Jump to UpdateSlug_MoveUp if the slug is moving up (bit 7 is not set).
6ADC JR Z,UpdateSlug_MoveUp
6ADE ADD A,$01 Add 01 to move down.
6AE0 CP $B8 Jump to UpdateSlug_TurnUp if the slug has reached the bottom.
6AE2 JR NC,UpdateSlug_TurnUp
UpdateSlug_StoreY 6AE4 LD (IX+$02),A Write the new Y position.
UpdateSlug_Horizontal 6AE7 LD A,(IX+$01) A=the X position of the slug.
6AEA BIT 6,(IX+$00) Jump to UpdateSlug_MoveLeft if the slug is moving left (bit 6 is not set).
6AEE JR Z,UpdateSlug_MoveLeft
6AF0 ADD A,$04 Add 04 to move right.
6AF2 CP $D0 Jump to UpdateSlug_TurnLeft if the slug has reached the right edge.
6AF4 JR NC,UpdateSlug_TurnLeft
UpdateSlug_StoreX 6AF6 LD (IX+$01),A Write the new X position.
This entry point is used by the routine at EatFlower.
UpdateSlug_Draw 6AF9 JP DrawObject Jump to DrawObject to draw the slug.
UpdateSlug_MoveUp 6AFC SUB $01 Subtract 01 to move up.
6AFE CP $28 Jump to UpdateSlug_StoreY if the slug has not reached the top.
6B00 JR NC,UpdateSlug_StoreY
6B02 SET 7,(IX+$00) Set bit 7 of IX+00 (turn the slug downwards).
6B06 JR UpdateSlug_Horizontal Jump to UpdateSlug_Horizontal.
UpdateSlug_TurnUp 6B08 RES 7,(IX+$00) Reset bit 7 of IX+00 (turn the slug upwards).
6B0C JR UpdateSlug_Horizontal Jump to UpdateSlug_Horizontal.
UpdateSlug_MoveLeft 6B0E SUB $04 Subtract 04 to move left.
6B10 CP $18 Jump to UpdateSlug_StoreX if the slug has not reached the left edge.
6B12 JR NC,UpdateSlug_StoreX
6B14 SET 6,(IX+$00) Set bit 6 of IX+00 (turn the slug to the right).
6B18 JR UpdateSlug_Draw Jump to UpdateSlug_Draw.
UpdateSlug_TurnLeft 6B1A RES 6,(IX+$00) Reset bit 6 of IX+00 (turn the slug to the left).
6B1E JR UpdateSlug_Draw Jump to UpdateSlug_Draw.
Prev: 6A73 Up: Map Next: 6B20