Prev: 50632 Up: Map Next: 50757
50691: Set Ghost Direction Graphic
Used by the routine at HandleGhost.
Chooses the graphic of the ghost from the direction in which it moves, by setting bit 1 of the graphic number and the flag that flips the sprite. Of the two speeds the larger decides it.
Input
IX Address of the ghost object
Choose the graphic from the larger of the two speeds.
SetGhostDirectionGraphic 50691 LD A,(IX+9) Fetch the speed in X.
50694 AND A Test it.
50695 JP P,SetGhostDirectionGraphic_Y Jump to SetGhostDirectionGraphic_Y if it is positive.
50698 NEG Make it positive.
SetGhostDirectionGraphic_Y 50700 LD C,A Stash it in C.
50701 LD A,(IX+10) Fetch the speed in Y.
50704 AND A Test it.
50705 JP P,SetGhostDirectionGraphic_Compare Jump to SetGhostDirectionGraphic_Compare if it is positive.
50708 NEG Make it positive.
SetGhostDirectionGraphic_Compare 50710 CP C Compare the speed in X with the speed in Y.
50711 JR NC,SetGhostDirectionGraphic_MoreInY Jump to SetGhostDirectionGraphic_MoreInY if the ghost moves more in Y than in X.
50713 LD A,(IX+9) Fetch the speed in X.
50716 AND A Test it.
50717 JP M,SetGhostDirectionGraphic_SecondPair Jump to SetGhostDirectionGraphic_SecondPair if it is negative.
50720 RES 1,(IX+0) Select the first pair of graphics.
SetGhostDirectionGraphic_SetFlip 50724 SET 6,(IX+7) Flip the sprite.
50728 RET Return.
SetGhostDirectionGraphic_SecondPair 50729 SET 1,(IX+0) Select the second pair of graphics.
50733 JR SetGhostDirectionGraphic_SetFlip Jump to SetGhostDirectionGraphic_SetFlip.
SetGhostDirectionGraphic_MoreInY 50735 LD A,(IX+10) Fetch the speed in Y.
50738 AND A Test it.
50739 JP M,SetGhostDirectionGraphic_FirstPair Jump to SetGhostDirectionGraphic_FirstPair if it is negative.
50742 SET 1,(IX+0) Select the second pair of graphics.
SetGhostDirectionGraphic_ClearFlip 50746 RES 6,(IX+7) Stop the sprite from being flipped.
50750 RET Return.
SetGhostDirectionGraphic_FirstPair 50751 RES 1,(IX+0) Select the first pair of graphics.
50755 JR SetGhostDirectionGraphic_ClearFlip Jump to SetGhostDirectionGraphic_ClearFlip.
Prev: 50632 Up: Map Next: 50757