Prev: 40650 Up: Map Next: 40798
40668: Handler: Rover Frames
Advance the moon rover animation from Jetman_Position, then colour the cab and flash the HUD tile chosen by Handler_Missile.
Input
IX Actor slot
Handler_RoverFrames 40668 LD A,(24698) Fetch Jetman_Position.
40671 SUB (IX+2) Subtract the rover world X.
40674 NEG Negate the difference.
The rover has eight frames of animation.
40676 AND %00000111 Keep only bits 0-2.
Sprite IDs begin at 34 ("Lunar Rover: Right Frame 1").
40678 ADD A,34 Add 34 for the rover frames.
40680 LD (IX+0),A Write it to the actor type.
40683 CALL DrawActorSprite Call DrawActorSprite.
While PlayerInactive is set, count it up and tint the rover from it.
Handler_RoverFrames_TestInactive 40686 LD A,(24172) Fetch PlayerInactive.
40689 AND A Jump to Handler_RoverFrames_Address if it is zero.
40690 JR Z,Handler_RoverFrames_Address
40692 INC A Increase PlayerInactive by one.
40693 LD (24172),A Write it back.
40696 JR Handler_RoverFrames_Tint Jump to Handler_RoverFrames_Tint.
Fill attribute cells at the rover's position when SpriteWidth is not zero.
Handler_RoverFrames_Address 40698 LD L,(IX+1) Fetch the rover screen column.
40701 LD H,(IX+4) Fetch the rover Y.
40704 CALL AttributeAddress Call AttributeAddress.
40707 LD A,(24151) Fetch SpriteWidth.
40710 AND A Jump to Handler_RoverFrames_MissileBanner if it is zero.
40711 JR Z,Handler_RoverFrames_MissileBanner
Fill two rows of the rover's attribute cells with INK:WHITE, PAPER:BLACK (BRIGHT), then the two rows above them with INK:CYAN, PAPER:BLACK (BRIGHT). Cells that are empty are left alone.
40713 LD B,A Set the number of columns to fill in B from SpriteWidth.
40714 LD C,2 Set the number of rows to fill in C to 2.
40716 LD D,71 Set the fill attribute in D to INK:WHITE, PAPER:BLACK (BRIGHT).
40718 CALL FillAttributeRow Call FillAttributeRow to fill the first two rows.
FillAttributeRow leaves HL one row above the last row it filled, so the next call carries on from there.
40721 LD D,69 Set the fill attribute in D to INK:CYAN, PAPER:BLACK (BRIGHT).
40723 LD C,2 Set the number of rows to fill in C to 2.
40725 CALL FillAttributeRow Call FillAttributeRow to fill the next two rows up.
Flash one of the two HUD tiles, chosen by Handler_Missile.
Handler_RoverFrames_MissileBanner 40728 CALL Handler_Missile Call Handler_Missile.
40731 JR NC,Handler_RoverFrames_ClearBanner Jump to Handler_RoverFrames_ClearBanner if Handler_Missile returned no carry.
The carry is set, so flash the first tile (22625) and set the second tile (22627) to a steady colour.
40733 CALL FlashAttribute Call FlashAttribute to fetch the flashing attribute.
40736 LD HL,22625 Point HL at the first HUD tile (22625).
40739 CALL Handler_Colour2x2 Call Handler_Colour2x2 to colour the tile with A.
40742 LD HL,22627 Point HL at the second HUD tile (22627).
40745 LD A,66 Set the steady attribute in A to INK:RED, PAPER:BLACK (BRIGHT).
40747 JP Handler_Colour2x2 Jump to Handler_Colour2x2 to colour the tile with A.
There is no carry, so flash the second tile (22627) and set the first tile (22625) to a steady colour.
Handler_RoverFrames_ClearBanner 40750 CALL FlashAttribute Call FlashAttribute to fetch the flashing attribute.
40753 LD HL,22627 Point HL at the second HUD tile (22627).
40756 CALL Handler_Colour2x2 Call Handler_Colour2x2 to colour the tile with A.
40759 LD HL,22625 Point HL at the first HUD tile (22625).
40762 LD A,66 Set the steady attribute in A to INK:RED, PAPER:BLACK (BRIGHT).
40764 JP Handler_Colour2x2 Jump to Handler_Colour2x2 to colour the tile with A.
Tint the rover from the frame value in A.
Handler_RoverFrames_Tint 40767 CP 48 Compare A against 48.
40769 JP NC,Handler_Missile_FallingDebris Jump to Handler_Missile_FallingDebris if it is at least 48.
Use bits 1-3 of the value as the INK colour, stepping through the colours as it counts up.
40772 RRCA Rotate it right once.
40773 AND %00000111 Keep only bits 0-2.
40775 JR NZ,Handler_RoverFrames_WriteColour Jump to Handler_RoverFrames_WriteColour if the result is not zero.
The PAPER is black, so INK 0 would make the rover black on black and invisible. Use INK 1 (blue) as the lowest colour instead.
40777 INC A Increase it to 1.
Handler_RoverFrames_WriteColour 40778 OR %01000000 Set bit 6.
40780 LD (IX+7),A Write it to the rover colour.
40783 CALL ColouriseSprite Call ColouriseSprite.
Play a tone derived from the rover colour.
40786 LD A,(IX+7) Fetch the rover colour.
40789 CPL Invert the bits.
40790 AND %01111111 Keep only bits 0-6.
40792 LD C,A Copy the tone into C.
40793 LD D,32 D=32.
40795 JP PlayInvertedTone Jump to PlayInvertedTone.
Prev: 40650 Up: Map Next: 40798