Prev: 39316 Up: Map Next: 39650
39471: Handler: Saturn
Drift the Saturn toward the scroll position and aim it at Jetman.
Input
IX Actor slot
Handler_Saturn 39471 LD HL,24158 HL=AlienCount.
39474 INC (HL) Increase AlienCount by one.
Steer the horizontal speed toward the scroll position.
39475 LD H,(IX+3) Fetch the high byte of the world X.
39478 LD L,(IX+2) Fetch the low byte of the world X.
39481 LD DE,(24698) Fetch Jetman_Position.
39485 AND A Subtract the scroll position.
39486 SBC HL,DE
39488 BIT 4,H Jump to Handler_Saturn_DriftRight if the alien is left of the scroll.
39490 JP NZ,Handler_Saturn_DriftRight
Speed the alien up towards the left, up to a limit.
39493 LD C,0 C=0.
39495 LD A,(IX+5) Jump to Handler_Saturn_Decelerate if the horizontal speed is positive.
39498 AND A
39499 JP P,Handler_Saturn_Decelerate
39502 CP 177 Jump to Handler_Saturn_WriteSpeed if the speed is already below 177.
39504 JR C,Handler_Saturn_WriteSpeed
Handler_Saturn_Decelerate 39506 SUB 2 Subtract 2 from the speed.
Handler_Saturn_WriteSpeed 39508 LD (IX+5),A Write the speed back.
Pick a target height from Jetman's position and steer the vertical thrust toward it.
39511 LD A,(24696) Fetch the Jetman type from Jetman_Slot.
39514 CP 17 Jump to Handler_Saturn_FetchJetmanY if Jetman is on foot.
39516 JR C,Handler_Saturn_FetchJetmanY
39518 LD A,104 A=104.
39520 JR Handler_Saturn_CompareY Jump to Handler_Saturn_CompareY.
Handler_Saturn_FetchJetmanY 39522 LD A,(24700) Fetch Jetman_Y.
Compare with the alien's Y position and, if the alien is above the target, increase the downward thrust, up to a limit.
Handler_Saturn_CompareY 39525 SUB (IX+4) Subtract the alien's Y position.
39528 JP M,Handler_Saturn_ApplyUpThrust Jump to Handler_Saturn_ApplyUpThrust if the alien is below the target.
39531 LD A,(IX+6) Jump to Handler_Saturn_AddThrust if the vertical thrust is negative.
39534 AND A
39535 JP M,Handler_Saturn_AddThrust
39538 CP 64 Jump to Handler_Saturn_ApplyThrust if the thrust is already at least 64.
39540 JR NC,Handler_Saturn_ApplyThrust
Handler_Saturn_AddThrust 39542 ADD A,2 Add 2 to the thrust.
Apply the thrust to the Y position, bouncing off the play-area edges.
Handler_Saturn_ApplyThrust 39544 LD (IX+6),A Write the thrust back.
39547 SRA A Divide it by 16.
39549 SRA A
39551 SRA A
39553 SRA A
39555 ADD A,(IX+4) Add it to the alien's Y position.
39558 CP 56 Jump to Handler_Saturn_BounceTop if the alien is above the play area.
39560 JR C,Handler_Saturn_BounceTop
39562 CP 176 Jump to Handler_Saturn_BounceGround if the alien has hit the ground line.
39564 JR NC,Handler_Saturn_BounceGround
39566 LD (IX+4),A Write the Y position back.
Pick the animation frame and colour.
Handler_Saturn_Animate 39569 INC (IX+17) Increase the animation timer.
39572 LD A,(IX+17) Fetch the animation timer.
39575 AND %00001111 Keep only bits 0-3.
Sprite IDs begin at 204 ("Saturn: Frame 1").
39577 ADD A,204 Add 204 for these frames.
39579 LD (IX+0),A Write it to the actor type.
Alternate the colour using bit 0 of GameTimer.
39582 LD A,(24130) Fetch GameTimer.
39585 AND %00000001 Keep only bit 0.
39587 ADD A,69 Add 69 for the colour.
39589 LD (IX+7),A Write it to the actor colour.
39592 JP PlaceSpawnedAlien_Age Jump to PlaceSpawnedAlien_Age.
When the alien is left of the scroll, drift right.
Handler_Saturn_DriftRight 39595 LD C,128 C=128.
39597 LD A,(IX+5) Jump to Handler_Saturn_AddSpeed if the horizontal speed is negative.
39600 AND A
39601 JP M,Handler_Saturn_AddSpeed
39604 CP 80 Jump to Handler_Saturn_WriteSpeed if the speed is already at least 80.
39606 JR NC,Handler_Saturn_WriteSpeed
Handler_Saturn_AddSpeed 39608 ADD A,2 Add 2 to the speed.
39610 JR Handler_Saturn_WriteSpeed Jump to Handler_Saturn_WriteSpeed.
When the alien is below the target, apply upward thrust.
Handler_Saturn_ApplyUpThrust 39612 LD A,(IX+6) Jump to Handler_Saturn_SubtractThrust if the vertical thrust is positive.
39615 AND A
39616 JP P,Handler_Saturn_SubtractThrust
39619 CP 193 Jump to Handler_Saturn_ApplyThrust if the thrust is already below 193.
39621 JR C,Handler_Saturn_ApplyThrust
Handler_Saturn_SubtractThrust 39623 SUB 2 Subtract 2 from the thrust.
39625 JR Handler_Saturn_ApplyThrust Jump to Handler_Saturn_ApplyThrust.
Bounce off the top of the play area.
Handler_Saturn_BounceTop 39627 LD A,(IX+6) Jump to Handler_Saturn_Animate if the vertical thrust is positive.
39630 AND A
39631 JP P,Handler_Saturn_Animate
Handler_Saturn_NegateThrust 39634 NEG Negate the thrust.
39636 LD (IX+6),A Write it back.
39639 JR Handler_Saturn_Animate Jump to Handler_Saturn_Animate.
Bounce off the ground line.
Handler_Saturn_BounceGround 39641 LD A,(IX+6) Jump to Handler_Saturn_Animate if the vertical thrust is negative.
39644 AND A
39645 JP M,Handler_Saturn_Animate
39648 JR Handler_Saturn_NegateThrust Jump to Handler_Saturn_NegateThrust.
Prev: 39316 Up: Map Next: 39650