Prev: C5C8 Up: Map Next: C645
C603: 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 C603 LD A,(IX+$09) Fetch the speed in X.
C606 AND A Test it.
C607 JP P,SetGhostDirectionGraphic_Y Jump to SetGhostDirectionGraphic_Y if it is positive.
C60A NEG Make it positive.
SetGhostDirectionGraphic_Y C60C LD C,A Stash it in C.
C60D LD A,(IX+$0A) Fetch the speed in Y.
C610 AND A Test it.
C611 JP P,SetGhostDirectionGraphic_Compare Jump to SetGhostDirectionGraphic_Compare if it is positive.
C614 NEG Make it positive.
SetGhostDirectionGraphic_Compare C616 CP C Compare the speed in X with the speed in Y.
C617 JR NC,SetGhostDirectionGraphic_MoreInY Jump to SetGhostDirectionGraphic_MoreInY if the ghost moves more in Y than in X.
C619 LD A,(IX+$09) Fetch the speed in X.
C61C AND A Test it.
C61D JP M,SetGhostDirectionGraphic_SecondPair Jump to SetGhostDirectionGraphic_SecondPair if it is negative.
C620 RES 1,(IX+$00) Select the first pair of graphics.
SetGhostDirectionGraphic_SetFlip C624 SET 6,(IX+$07) Flip the sprite.
C628 RET Return.
SetGhostDirectionGraphic_SecondPair C629 SET 1,(IX+$00) Select the second pair of graphics.
C62D JR SetGhostDirectionGraphic_SetFlip Jump to SetGhostDirectionGraphic_SetFlip.
SetGhostDirectionGraphic_MoreInY C62F LD A,(IX+$0A) Fetch the speed in Y.
C632 AND A Test it.
C633 JP M,SetGhostDirectionGraphic_FirstPair Jump to SetGhostDirectionGraphic_FirstPair if it is negative.
C636 SET 1,(IX+$00) Select the second pair of graphics.
SetGhostDirectionGraphic_ClearFlip C63A RES 6,(IX+$07) Stop the sprite from being flipped.
C63E RET Return.
SetGhostDirectionGraphic_FirstPair C63F RES 1,(IX+$00) Select the first pair of graphics.
C643 JR SetGhostDirectionGraphic_ClearFlip Jump to SetGhostDirectionGraphic_ClearFlip.
Prev: C5C8 Up: Map Next: C645