Prev: 53381 Up: Map Next: 53562
53420: Run Helper
The handler of the object type 90, which is the helper. It can be picked up by the player, like the stones, and when it is not held it goes to an object of one of the types 112 to 115 in the room, and collects it.
The helper starts by falling to the floor. If there is an object of the right type, it takes the position of that as a target, which it keeps in its record. Then it rises, to a height of 176, and goes towards the target in a straight line along x and y, as SteerTowardsTarget sets its speeds. When it gets there it flags the object, so that RunCollectableObject collects it, makes a noise and disappears in an explosion, and its entry in the object store is removed.
Input
IX Object record
Fly towards the target if one is set.
RunHelper 53420 CALL SetSpriteOffset_Minus16_Minus8 Call SetSpriteOffset_Minus16_Minus8 to set the offsets of the sprite.
53423 BIT 0,(IX+20) Jump to RunHelper_Seek if the helper has no target.
53427 JR Z,RunHelper_Seek
53429 CALL SteerTowardsTarget Call SteerTowardsTarget to set the speeds towards the target.
53432 LD A,(IX+3) Jump to RunHelper_Move if the helper is at the height of 176 or more.
53435 CP 176
53437 JR NC,RunHelper_Move
53439 LD (IX+11),1 Set the speed along z to 1.
RunHelper_Move 53443 CALL ApplyGravityAndMove_Move Call ApplyGravityAndMove_Move to move the helper, without gravity.
53446 LD A,(IX+10) Fetch the speeds together.
53449 OR (IX+9)
53452 OR (IX+11)
53455 JP NZ,FinishObjectMove Jump to FinishObjectMove to finish if the helper is still moving.
Collect the object when the helper arrives.
53458 CALL PointAtObjects Call PointAtObjects to point IY at the first ordinary object.
53461 LD C,112 Set the first type to look for.
RunHelper_FindObject 53463 LD A,(IY+0) Fetch the type of the object.
53466 AND %11111100 Keep the type without its lowest two bits.
53468 CP C Jump to RunHelper_Collect if it is one of the types 112 to 115.
53469 JR Z,RunHelper_Collect
53471 ADD IY,DE Move on to the next object.
53473 DJNZ RunHelper_FindObject Jump to RunHelper_FindObject until all of the objects have been tested.
53475 JP FinishObjectMove Jump to FinishObjectMove to finish if there is none.
RunHelper_Collect 53478 SET 0,(IY+22) Flag the object as collected.
53482 XOR A Clear the helper flag.
53483 LD (42766),A
53486 LD DE,55367 Take the tune for an object being collected, CollectedTune.
53489 CALL PlayMusic Call PlayMusic to play it.
53492 CALL PointAtStore Call PointAtStore to point IY at the first entry of the object store.
53495 LD A,90 Set the type to look for, which is that of the helper.
RunHelper_FindEntry 53497 CP (IY+0) Jump to RunHelper_RemoveEntry if the entry is the helper.
53500 JR Z,RunHelper_RemoveEntry
53502 ADD IY,DE Move on to the next entry, and jump to RunHelper_FindEntry until all have been tested.
53504 DJNZ RunHelper_FindEntry
53506 JP StartExplosion Jump to StartExplosion to make the helper explode.
RunHelper_RemoveEntry 53509 LD (IY+0),0 Remove the helper from the object store.
53513 JP StartExplosion Jump to StartExplosion to make the helper explode.
Fall, then pick a quest object as the target.
RunHelper_Seek 53516 LD (IX+11),255 Set the speed along z to 255, to make the helper fall.
53520 CALL ApplyGravityAndMove_Move Call ApplyGravityAndMove_Move to move it, without gravity.
53523 CALL PointAtObjects Call PointAtObjects to point IY at the first ordinary object.
53526 LD C,112 Set the first type to look for.
RunHelper_SeekLoop 53528 LD A,(IY+0) Fetch the type of the object.
53531 AND %11111100 Keep the type without its lowest two bits.
53533 CP C Jump to RunHelper_SetTarget if it is one of the types 112 to 115.
53534 JR Z,RunHelper_SetTarget
53536 ADD IY,DE Move on to the next object, and jump to RunHelper_SeekLoop until all have been tested.
53538 DJNZ RunHelper_SeekLoop
53540 JP FinishObjectMove Jump to FinishObjectMove to finish if there is none.
RunHelper_SetTarget 53543 LD A,(IY+1) Set the x position of the target to that of the object.
53546 LD (IX+21),A
53549 LD A,(IY+2) Set the y position of the target to that of the object.
53552 LD (IX+22),A
53555 SET 0,(IX+20) Flag the helper as having a target.
53559 JP FinishObjectMove Jump to FinishObjectMove to finish.
Prev: 53381 Up: Map Next: 53562