Prev: 28744 Up: Map Next: 28989
28779: Game Play Start
Used by the routine at GamePlayEntry.
Moves Charlie, using the controls which are read by ReadControls. Byte 4 of the actor is the horizontal speed and byte 5 is the vertical speed; each is 2 (or 254) while the control is pressed, and zero otherwise. Charlie can't move past the edges of the play area. While he is moving his ID changes between 1 and 2 every four frames, which animates him. The last direction in which he moved is kept in CharlieLastMovement.
While fire is being held down, a flour shot is fired every eight frames, if there is one of the two slots for the shots free. The shot goes in the last direction in which Charlie moved, at three times his speed.
Input
IX Actor
GamePlay_Start 28779 CALL StoreEntity Record the position of the sprite using StoreEntity.
28782 CALL ReadControls Read the controls using ReadControls.
28785 BIT 4,A Jump to ControlCharlie_Fire if fire is being pressed.
28787 JR Z,ControlCharlie_Fire
28789 LD (IX+6),0 Write 0 to byte 6 of the actor (the fire counter).
ControlCharlie_Movement 28793 BIT 0,A Test bit 0 (right).
28795 LD DE,0 Clear Charlie's movement (DE=0).
28798 JR Z,ControlCharlie_Right Jump to ControlCharlie_Right if right is being pressed.
28800 BIT 1,A Jump to ControlCharlie_Left if left is being pressed.
28802 JR Z,ControlCharlie_Left
28804 LD (IX+4),0 Write 0 to the horizontal speed.
ControlCharlie_Vertical 28808 BIT 3,A Jump to ControlCharlie_Up if up is being pressed.
28810 JR Z,ControlCharlie_Up
28812 BIT 2,A Jump to ControlCharlie_Down if down is being pressed.
28814 JR Z,ControlCharlie_Down
28816 LD (IX+5),0 Write 0 to the vertical speed.
Move Charlie horizontally. E is the speed if he has moved, and zero if he has not.
ControlCharlie_MoveHorizontal 28820 LD A,(IX+1) Fetch the horizontal co-ordinate.
28823 ADD A,(IX+4) Add the horizontal speed.
28826 LD E,0 Assume that Charlie has not moved horizontally (E=0).
28828 CP 1 Jump to ControlCharlie_MoveVertical if Charlie has reached the left edge.
28830 JR C,ControlCharlie_MoveVertical
28832 CP 196 Jump to ControlCharlie_MoveVertical if Charlie has reached the right edge.
28834 JR NC,ControlCharlie_MoveVertical
28836 LD (IX+1),A Update the horizontal co-ordinate.
28839 LD E,(IX+4) Set the horizontal movement to the horizontal speed.
Move Charlie vertically. D is the speed if he has moved, and zero if he has not.
ControlCharlie_MoveVertical 28842 LD A,(IX+2) Fetch the vertical co-ordinate.
28845 ADD A,(IX+5) Add the vertical speed.
28848 LD D,0 Assume that Charlie has not moved vertically (D=0).
28850 CP 40 Jump to ControlCharlie_Animate if Charlie has reached the top.
28852 JR C,ControlCharlie_Animate
28854 CP 160 Jump to ControlCharlie_Animate if Charlie has reached the bottom.
28856 JR NC,ControlCharlie_Animate
28858 LD (IX+2),A Update the vertical co-ordinate.
28861 LD D,(IX+5) Set the vertical movement to the vertical speed.
ControlCharlie_Animate 28864 LD A,E Fetch the horizontal movement.
28865 OR D Combine with the vertical movement.
28866 JR Z,ControlCharlie_Draw Jump to ControlCharlie_Draw if Charlie has not moved.
28868 LD (24363),DE Save the movement in CharlieLastMovement, which sets the direction of flour shots.
28872 LD A,(23672) Fetch the first byte of FRAMES.
28875 RRA Shift A right twice.
28876 RRA
28877 AND %00000001 Keep only bit 0.
28879 INC A Add 1 to get Charlie's running frame (1 or 2).
28880 LD (IX+0),A Update the actor ID.
ControlCharlie_Draw 28883 CALL DisplayEntity Erase the sprite and draw it in its new position using DisplayEntity.
28886 JP ColourSprite Jump to ColourSprite to colour the sprite.
Right is being pressed.
ControlCharlie_Right 28889 LD E,2 Set the speed to 2 (moving right).
ControlCharlie_SetHorizontalSpeed 28891 LD (IX+4),E Set the horizontal speed.
28894 JR ControlCharlie_Vertical Jump to ControlCharlie_Vertical.
Left is being pressed.
ControlCharlie_Left 28896 LD E,254 Set the speed to 254 (moving left).
28898 JR ControlCharlie_SetHorizontalSpeed Jump to ControlCharlie_SetHorizontalSpeed.
Up is being pressed.
ControlCharlie_Up 28900 LD D,254 Set the speed to 254 (moving up).
ControlCharlie_SetVerticalSpeed 28902 LD (IX+5),D Set the vertical speed.
28905 JR ControlCharlie_MoveHorizontal Jump to ControlCharlie_MoveHorizontal.
Down is being pressed.
ControlCharlie_Down 28907 LD D,2 Set the speed to 2 (moving down).
28909 JR ControlCharlie_SetVerticalSpeed Jump to ControlCharlie_SetVerticalSpeed.
Fire is being pressed. A shot is fired when the fire counter in byte 6 of the actor is a multiple of 8 so the first one is fired at once.
ControlCharlie_Fire 28911 PUSH AF Save the controls on the stack.
28912 LD A,(IX+6) Fetch the fire counter (byte 6 of the actor).
28915 INC (IX+6) Increase the fire counter by one.
28918 AND %00000111 Keep only bits 0-2.
28920 JR NZ,ControlCharlie_FireFinished Jump to ControlCharlie_FireFinished if the fire counter was not a multiple of 8.
28922 LD HL,24381 Point HL at ActorFlourShots.
28925 LD B,2 Set the slot counter to 2 (the number of slots for flour shots).
28927 LD DE,8 Set the size of an actor to 8.
ControlCharlie_FindSlot 28930 LD A,(HL) Fetch the actor ID.
28931 AND A Is the slot empty?
28932 JR Z,ControlCharlie_CreateShot Jump to ControlCharlie_CreateShot if it is.
28934 ADD HL,DE Move on to the next slot.
28935 DJNZ ControlCharlie_FindSlot Decrease the slot counter by one and loop back to ControlCharlie_FindSlot until both slots have been tried.
ControlCharlie_FireFinished 28937 POP AF Restore the controls from the stack.
28938 JP ControlCharlie_Movement Jump to ControlCharlie_Movement.
Create the flour shot, which starts at Charlie's position.
ControlCharlie_CreateShot 28941 LD (HL),3 Set the actor ID to 3 (a flour shot).
28943 PUSH HL Save the address of the flour shot on the stack.
28944 INC HL Move on to the horizontal co-ordinate.
28945 LD A,(IX+1) Fetch Charlie's horizontal co-ordinate.
28948 LD (HL),A Update the horizontal co-ordinate of the flour shot.
28949 INC HL Move on to the vertical co-ordinate.
28950 LD A,(IX+2) Fetch Charlie's vertical co-ordinate.
28953 LD (HL),A Update the vertical co-ordinate of the flour shot.
28954 INC HL Move on to the colour.
28955 LD (HL),71 Set the colour of the flour shot to 71 (white).
28957 INC HL Move on to the horizontal speed.
28958 LD DE,(24363) Fetch Charlie's last movement (CharlieLastMovement).
28962 LD A,E Fetch the horizontal movement.
28963 SLA A Multiply A by two.
28965 ADD A,E Add E, to multiply it by three.
28966 LD (HL),A Update the horizontal speed of the flour shot.
28967 INC HL Move on to the vertical speed.
28968 LD A,D Fetch the vertical movement.
28969 SLA A Multiply A by two.
28971 ADD A,D Add D, to multiply it by three.
28972 LD (HL),A Update the vertical speed of the flour shot.
28973 POP HL Restore the address of the flour shot from the stack.
28974 PUSH IX Save the pointer to the current actor on the stack.
28976 PUSH HL Save the address of the flour shot on the stack.
28977 POP IX Restore IX from the stack (this is now the flour shot).
28979 CALL DrawEntity Draw the flour shot using DrawEntity.
28982 POP IX Restore the pointer to the current actor from the stack.
28984 CALL PlayChirp Play the chirp using PlayChirp.
28987 JR ControlCharlie_FireFinished Jump to ControlCharlie_FireFinished.
Prev: 28744 Up: Map Next: 28989