Prev: 7048 Up: Map Next: 713D
706B: Game Play Start
Used by the routine at GamePlayEntry.
Moves Charlie, using the controls which are read by ReadControls. Byte 04 of the actor is the horizontal speed and byte 05 is the vertical speed; each is 02 (or FE) 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 01 and 02 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 706B CALL StoreEntity Record the position of the sprite using StoreEntity.
706E CALL ReadControls Read the controls using ReadControls.
7071 BIT 4,A Jump to ControlCharlie_Fire if fire is being pressed.
7073 JR Z,ControlCharlie_Fire
7075 LD (IX+$06),$00 Write 00 to byte 06 of the actor (the fire counter).
ControlCharlie_Movement 7079 BIT 0,A Test bit 0 (right).
707B LD DE,$0000 Clear Charlie's movement (DE=00).
707E JR Z,ControlCharlie_Right Jump to ControlCharlie_Right if right is being pressed.
7080 BIT 1,A Jump to ControlCharlie_Left if left is being pressed.
7082 JR Z,ControlCharlie_Left
7084 LD (IX+$04),$00 Write 00 to the horizontal speed.
ControlCharlie_Vertical 7088 BIT 3,A Jump to ControlCharlie_Up if up is being pressed.
708A JR Z,ControlCharlie_Up
708C BIT 2,A Jump to ControlCharlie_Down if down is being pressed.
708E JR Z,ControlCharlie_Down
7090 LD (IX+$05),$00 Write 00 to the vertical speed.
Move Charlie horizontally. E is the speed if he has moved, and zero if he has not.
ControlCharlie_MoveHorizontal 7094 LD A,(IX+$01) Fetch the horizontal co-ordinate.
7097 ADD A,(IX+$04) Add the horizontal speed.
709A LD E,$00 Assume that Charlie has not moved horizontally (E=00).
709C CP $01 Jump to ControlCharlie_MoveVertical if Charlie has reached the left edge.
709E JR C,ControlCharlie_MoveVertical
70A0 CP $C4 Jump to ControlCharlie_MoveVertical if Charlie has reached the right edge.
70A2 JR NC,ControlCharlie_MoveVertical
70A4 LD (IX+$01),A Update the horizontal co-ordinate.
70A7 LD E,(IX+$04) 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 70AA LD A,(IX+$02) Fetch the vertical co-ordinate.
70AD ADD A,(IX+$05) Add the vertical speed.
70B0 LD D,$00 Assume that Charlie has not moved vertically (D=00).
70B2 CP $28 Jump to ControlCharlie_Animate if Charlie has reached the top.
70B4 JR C,ControlCharlie_Animate
70B6 CP $A0 Jump to ControlCharlie_Animate if Charlie has reached the bottom.
70B8 JR NC,ControlCharlie_Animate
70BA LD (IX+$02),A Update the vertical co-ordinate.
70BD LD D,(IX+$05) Set the vertical movement to the vertical speed.
ControlCharlie_Animate 70C0 LD A,E Fetch the horizontal movement.
70C1 OR D Combine with the vertical movement.
70C2 JR Z,ControlCharlie_Draw Jump to ControlCharlie_Draw if Charlie has not moved.
70C4 LD ($5F2B),DE Save the movement in CharlieLastMovement, which sets the direction of flour shots.
70C8 LD A,($5C78) Fetch the first byte of FRAMES.
70CB RRA Shift A right twice.
70CC RRA
70CD AND %00000001 Keep only bit 0.
70CF INC A Add 01 to get Charlie's running frame (01 or 02).
70D0 LD (IX+$00),A Update the actor ID.
ControlCharlie_Draw 70D3 CALL DisplayEntity Erase the sprite and draw it in its new position using DisplayEntity.
70D6 JP ColourSprite Jump to ColourSprite to colour the sprite.
Right is being pressed.
ControlCharlie_Right 70D9 LD E,$02 Set the speed to 02 (moving right).
ControlCharlie_SetHorizontalSpeed 70DB LD (IX+$04),E Set the horizontal speed.
70DE JR ControlCharlie_Vertical Jump to ControlCharlie_Vertical.
Left is being pressed.
ControlCharlie_Left 70E0 LD E,$FE Set the speed to FE (moving left).
70E2 JR ControlCharlie_SetHorizontalSpeed Jump to ControlCharlie_SetHorizontalSpeed.
Up is being pressed.
ControlCharlie_Up 70E4 LD D,$FE Set the speed to FE (moving up).
ControlCharlie_SetVerticalSpeed 70E6 LD (IX+$05),D Set the vertical speed.
70E9 JR ControlCharlie_MoveHorizontal Jump to ControlCharlie_MoveHorizontal.
Down is being pressed.
ControlCharlie_Down 70EB LD D,$02 Set the speed to 02 (moving down).
70ED JR ControlCharlie_SetVerticalSpeed Jump to ControlCharlie_SetVerticalSpeed.
Fire is being pressed. A shot is fired when the fire counter in byte 06 of the actor is a multiple of 08 so the first one is fired at once.
ControlCharlie_Fire 70EF PUSH AF Save the controls on the stack.
70F0 LD A,(IX+$06) Fetch the fire counter (byte 06 of the actor).
70F3 INC (IX+$06) Increase the fire counter by one.
70F6 AND %00000111 Keep only bits 0-2.
70F8 JR NZ,ControlCharlie_FireFinished Jump to ControlCharlie_FireFinished if the fire counter was not a multiple of 08.
70FA LD HL,$5F3D Point HL at ActorFlourShots.
70FD LD B,$02 Set the slot counter to 02 (the number of slots for flour shots).
70FF LD DE,$0008 Set the size of an actor to 08.
ControlCharlie_FindSlot 7102 LD A,(HL) Fetch the actor ID.
7103 AND A Is the slot empty?
7104 JR Z,ControlCharlie_CreateShot Jump to ControlCharlie_CreateShot if it is.
7106 ADD HL,DE Move on to the next slot.
7107 DJNZ ControlCharlie_FindSlot Decrease the slot counter by one and loop back to ControlCharlie_FindSlot until both slots have been tried.
ControlCharlie_FireFinished 7109 POP AF Restore the controls from the stack.
710A JP ControlCharlie_Movement Jump to ControlCharlie_Movement.
Create the flour shot, which starts at Charlie's position.
ControlCharlie_CreateShot 710D LD (HL),$03 Set the actor ID to 03 (a flour shot).
710F PUSH HL Save the address of the flour shot on the stack.
7110 INC HL Move on to the horizontal co-ordinate.
7111 LD A,(IX+$01) Fetch Charlie's horizontal co-ordinate.
7114 LD (HL),A Update the horizontal co-ordinate of the flour shot.
7115 INC HL Move on to the vertical co-ordinate.
7116 LD A,(IX+$02) Fetch Charlie's vertical co-ordinate.
7119 LD (HL),A Update the vertical co-ordinate of the flour shot.
711A INC HL Move on to the colour.
711B LD (HL),$47 Set the colour of the flour shot to 47 (white).
711D INC HL Move on to the horizontal speed.
711E LD DE,($5F2B) Fetch Charlie's last movement (CharlieLastMovement).
7122 LD A,E Fetch the horizontal movement.
7123 SLA A Multiply A by two.
7125 ADD A,E Add E, to multiply it by three.
7126 LD (HL),A Update the horizontal speed of the flour shot.
7127 INC HL Move on to the vertical speed.
7128 LD A,D Fetch the vertical movement.
7129 SLA A Multiply A by two.
712B ADD A,D Add D, to multiply it by three.
712C LD (HL),A Update the vertical speed of the flour shot.
712D POP HL Restore the address of the flour shot from the stack.
712E PUSH IX Save the pointer to the current actor on the stack.
7130 PUSH HL Save the address of the flour shot on the stack.
7131 POP IX Restore IX from the stack (this is now the flour shot).
7133 CALL DrawEntity Draw the flour shot using DrawEntity.
7136 POP IX Restore the pointer to the current actor from the stack.
7138 CALL PlayChirp Play the chirp using PlayChirp.
713B JR ControlCharlie_FireFinished Jump to ControlCharlie_FireFinished.
Prev: 7048 Up: Map Next: 713D