Prev: F99A Up: Map Next: F9FC
F9AB: Control water fired from the pistol (1)
The address of this routine is placed into 7FD7 and 7FD8 by the routine at F99A. In the following, 'water' may refer to either water or sherry.
H 0xD2 (ERIC)
F9AB LD B,$54 0x54: water fired from the pistol, phase 1 (facing left)
F9AD LD L,$00 Point HL at byte 0x00 of ERIC's buffer
F9AF LD A,(HL) A=ERIC's animatory state
F9B0 INC L L=0x01
F9B1 RLCA Is ERIC facing left?
F9B2 JR NC,$F9B6 Jump if so
F9B4 LD B,$D4 0xD4: water fired from the pistol, phase 1 (facing right)
F9B6 SBC A,A Set A=-2 if ERIC's facing left, 2 if he's facing right
F9BA ADD A,(HL) Add ERIC's x-coordinate to get the initial x-coordinate of the water
F9BB CP $BF Is ERIC too close to (and facing) the far left wall of the boys' skool or the far right wall of the girls' skool?
F9BD RET NC Return if so
F9BE LD E,A Copy the water's initial x-coordinate to E
F9BF INC L L=0x02
F9C0 LD D,(HL) D=ERIC's y-coordinate
F9C1 DEC D Subtract 2 to get the initial y-coordinate of the water
F9C3 LD A,B A=initial animatory state of the water
F9C4 PUSH AF Save the water's initial animatory state briefly
F9C5 PUSH DE Save the water's initial coordinates briefly
F9C6 CALL $F978 Make a water pistol sound effect
F9C9 LD A,$88 Message 0x88: NO WATERPISTOLS
F9CB CALL $F898 Give ERIC lines if any teacher is nearby
F9CE POP DE Restore the water's initial coordinates to DE
F9CF POP AF Restore the water's initial animatory state to A
F9D0 LD HL,$D613 Point HL at byte 0x13 of the water's buffer
F9D3 LD (HL),$97 Initialise the water animation phase identifier
F9D5 CALL $7746 Place address F9D8 (below) into bytes 0x11 and 0x12 of the water's buffer and update the SRB for the water's appearance
The address of this entry point is placed into bytes 0x11 and 0x12 of the water's buffer by the instruction above just after the water has been fired from the pistol, and is used throughout the water's lifespan. First, check whether the water has hit a cup, a plant, or the floor.
F9D8 LD L,$13 Increment the water animation phase identifier (which starts off at 0x97) held in byte 0x13 of the buffer
F9DB LD B,(HL) Pick up this identifier (0x98-0x9C) in B
F9DC LD C,$FF Point BC at the appropriate entry in the water animation table (see below)
F9DE LD A,(BC) Pick up the entry in A
F9DF AND A Deal with the water at phase 3 (when it can hit a cup), 6 (when it can hit a plant) or 7+ (when it hits the floor)
Next, determine the water's new animatory state and coordinates as it moves through the air. For this we use the water animation table, which comprises five 4-byte entries located in bytes 0xFC-0xFF of pages 0x98-0x9C, corresponding to the phases of animation of the water as it flies from the pistol to the ground. Each entry contains the animatory state (AS), the x-coordinate increment (x+), the y-coordinate increment (y+), and a parameter (P) that is passed to the routine at FA4D when non-zero. When P=1, the water is at the right phase to fill a cup; when P=2, the water may have hit a plant or the ground.
Address Phase AS x+ y+ P
98FC 2 0x5C -2 -1 0
99FC 3 0x6C -2 0 1
9AFC 4 0x74 -1 0 0
9BFC 5 0x7C 0 1 0
9CFC 6+ 0x7C 0 1 2
F9E4 PUSH BC Save the water animation table pointer
F9E5 CALL $61B4 Update the SRB for the water's current animatory state and location
F9E8 LD A,D A=water's current y-coordinate
F9E9 POP HL Restore the water animation table pointer to HL
F9EA ADD A,(HL) Add the entry from the table to obtain the water's new y-coordinate
F9EB LD D,A Copy this to D
F9ED LD C,(HL) Pick up the x-coordinate increment in C
F9EF LD A,(HL) A=water's new animatory state (facing left)
F9F0 LD HL,$D600 Point HL at byte 0x00 of the water's buffer
F9F3 RL (HL) Set the carry flag if the water's travelling to the right
F9F5 RLA Copy the carry flag into the 'direction' bit (bit 7) of the animatory state
F9F7 LD B,A B=water's new animatory state (facing the correct way)
F9F8 LD A,E A=water's current x-coordinate
F9F9 JP $FA39 Jump over the data table at FA00 to continue this routine
Prev: F99A Up: Map Next: F9FC