Routines

63915: Control water from pistol


The address of this routine is placed at 32727 by the routine at 63898

H 210 (ERIC)

63915 0654 LD B,84 84: animatory state of water, stage 1 (facing left)
63917 2E00 LD L,0
63919 7E LD A,(HL) Pick up ERIC's animatory state in A
63920 2C INC L
63921 07 RLCA
63922 3002 JR NC,63926 Jump if ERIC's facing left
63924 06D4 LD B,212 212: animatory state of water, stage 1 (facing right)
63926 9F SBC A,A
63927 87 ADD A,A
63928 2F CPL
63929 87 ADD A,A
63930 86 ADD A,(HL) Now A=x-coordinate of position 2 spaces in front of ERIC
63931 FEBF CP 191
63933 D0 RET NC Return if this is 191 or more (i.e. water would travel off-screen)
63934 5F LD E,A
63935 2C INC L
63936 56 LD D,(HL) D=ERIC's y-coordinate
63937 15 DEC D
63938 15 DEC D DE now holds the initial coordinates of the water
63939 78 LD A,B And A holds the initial animatory state
63940 F5 PUSH AF
63941 D5 PUSH DE
63942 CD78F9 CALL 63864 Make a water pistol sound effect
63945 3E88 LD A,136 Message no. 136: NO WATERPISTOLS
63947 CD98F8 CALL 63640 Make a teacher who can see ERIC give him lines
63950 D1 POP DE
63951 F1 POP AF
63952 2113D6 LD HL,54803 H=214, L=19
63955 3697 LD (HL),151
63957 CD4677 CALL 30534 Place address 63960 into bytes 17 and 18 of the water's buffer
63960 2E13 LD L,19
63962 34 INC (HL)
63963 46 LD B,(HL) 152≤B≤157
63964 0EFF LD C,255
63966 0A LD A,(BC) A=byte 255 (see table below)
63967 A7 AND A
63968 C44DFA CALL NZ,64077 Deal with the water at stages 2, 5 and 6
63971 0D DEC C C=254
63972 C5 PUSH BC
63973 CDB461 CALL 25012 Update SRB for water's current animatory state and location
63976 7A LD A,D A=water's current y-coordinate
63977 E1 POP HL
63978 86 ADD A,(HL) A=water's new y-coordinate
63979 57 LD D,A
63980 2D DEC L
63981 4E LD C,(HL)
63982 2D DEC L
63983 7E LD A,(HL) A=water's new animatory state (facing left)
63984 2100D6 LD HL,54784 Point to byte 0 of buffer 214
63987 CB16 RL (HL) Set carry if water's travelling to the right
63989 17 RLA
63990 0F RRCA
63991 47 LD B,A B=water's new animatory state (facing correct way)
63992 7B LD A,E A=water's current x-coordinate
63993 C339FA JP 64057 Jump over the data table at 64000 to continue this routine

The data used to guide the water from the pistol is found in the table below:
152 153 154 155 156 157
255 0 1 0 0 2 2 passed to 64077
254 255 0 0 1 1 1 y-coordinate increments
253 254 254 255 0 0 0 x-coordinate increments
252 92 108 116 124 124 124 animatory states