Routines

29896: Control descent of water, sherry or conker


The address of this routine is placed into a catapult pellet's buffer by the routine at 30380 when it has hit either the tree or a water/sherry-filled cup

H Falling object's character number

29896 2E02 LD L,2
29898 7E LD A,(HL) A=y-coordinate of falling object
29899 FE11 CP 17 Has the object hit the bottom floor yet?
29901 200C JR NZ,29915 Jump if not

This entry point is used by several routines to terminate the flight of a catapult pellet etc.
29903 2E12 LD L,18 Remove the address of this routine in the object's buffer (by blanking out the MSB at byte 18)
29905 3600 LD (HL),0

This entry point is used by the routine at 31254 to make a mouse disappear temporarily:
29907 CDB461 CALL 25012 Update SRB for the object's current animatory state and location

This entry point is used by the routine at 64057 to hide water from the water pistol:
29910 2E01 LD L,1 Set the object's x-coordinate to 224 (out of sight)
29912 36E0 LD (HL),224
29914 C9 RET

The falling object has yet to hit the floor. Has it hit anything else on the way there?
29915 FE0D CP 13 Is the object at the right height to hit someone?
29917 2807 JR Z,29926 Jump if so
29919 CDB461 CALL 25012 Update SRB for object's current animatory state and location
29922 14 INC D Object will fall one more level
29923 C33061 JP 24880 Update SRB for object's new location

The object is at the right height to hit someone. Check if it has.
29926 2E01 LD L,1
29928 5E LD E,(HL) E=falling object's x-coordinate
29929 1611 LD D,17 17=bottom floor (only floor on which characters can be hit)
29931 CDA074 CALL 29856 Check if any of the six adult characters were hit
29934 2E00 LD L,0
29936 7E LD A,(HL) A=animatory state of falling object
29937 283C JR Z,29999 Jump if an adult character was hit by the falling object
29939 FE37 CP 55 55: Is the falling object a conker?
29941 20E8 JR NZ,29919 Jump if not
29943 2E02 LD L,2
29945 3611 LD (HL),17
29947 CDAC6C CALL 27820 Check if any of the main kids were hit
29950 2E02 LD L,2
29952 360D LD (HL),13
29954 38DB JR C,29919 Jump if none of the main kids was hit by the conker
29956 7A LD A,D A=character number of main kid hit by conker
29957 FECF CP 207 Was it BOY WANDER (206)?
29959 3815 JR C,29982 Jump if so
29961 FED1 CP 209
29963 3E0A LD A,10
29965 300F JR NC,29982 Jump unless ANGELFACE (207) or EINSTEIN (208) was hit
29967 CDB573 CALL 29621 Add 100 to the score and print it
29970 D5 PUSH DE
29971 1628 LD D,40 Make sound effect
29973 011228 LD BC,10258
29976 3E07 LD A,7
29978 CD8C74 CALL 29836
29981 D1 POP DE

This entry point is used by the routine at 30786:
29982 D5 PUSH DE

This entry point is used by the routine at 30380:
29983 CDCF74 CALL 29903 Terminate the object
29986 D1 POP DE

This entry point is used by the routine at 30739 to knock a character over:
29987 EB EX DE,HL
29988 7C LD A,H A=number of character hit by object/fist
29989 FED2 CP 210 Was it ERIC?
29991 201E JR NZ,30023 Jump if not

This entry point is used by the routine at 24328:
29993 3E80 LD A,128
29995 32FB7F LD (32763),A Set bit 7: ERIC has been knocked down
29998 C9 RET

An adult character was hit by the falling object.
29999 FE37 CP 55 Is the falling object a conker?
30001 201F JR NZ,30034 Jump if not

At this stage, an adult character has been hit by either a conker or a drop of water or sherry.
30003 0E00 LD C,0
30005 0A LD A,(BC) A=animatory state of adult character hit by object
30006 E607 AND 7
30008 FE06 CP 6 Was the character already sitting on the floor?
30010 CADF74 JP Z,29919 Jump if so
30013 0E12 LD C,18
30015 0A LD A,(BC) Pick up byte 18 of the character's buffer
30016 A7 AND A Can this character be knocked over by a conker?
30017 C2DF74 JP NZ,29919 Jump if not
30020 C5 PUSH BC
30021 18D8 JR 29983

One of the main kids was knocked over.
30023 2E11 LD L,17 Place address 30102 into bytes 17 and 18 of the stricken character's buffer
30025 3696 LD (HL),150
30027 2C INC L
30028 3675 LD (HL),117
30030 2C INC L
30031 3613 LD (HL),19
30033 C9 RET

An adult character has been hit by a drop of water or sherry.
30034 11007F LD DE,32512
30037 FE1F CP 31 31: Is the falling object a drop of water?
30039 2802 JR Z,30043 Jump if so
30041 1E04 LD E,4
30043 78 LD A,B A=number of character hit by the drop of water/sherry
30044 FECC CP 204 Is the stricken character one of the male teachers?
30046 30D3 JR NC,30003 Jump if not
30048 D624 SUB 36 Point DE at the relevant combination letter or number in one of the tables at 32676 and 32680
30050 83 ADD A,E
30051 5F LD E,A
30052 EB EX DE,HL (HL)=combination letter/number held by teacher just knocked down
30053 CB7E BIT 7,(HL) Has ERIC already discovered this one?
30055 2009 JR NZ,30066 Jump if so
30057 CBFE SET 7,(HL) Signal: ERIC has discovered this combination letter/number
30059 C5 PUSH BC
30060 3E14 LD A,20 Add 200 to score and print it
30062 CDB573 CALL 29621
30065 C1 POP BC
30066 7E LD A,(HL)
30067 E67F AND 127 A=character code of combination number/letter just revealed
30069 328A7F LD (32650),A
30072 D5 PUSH DE
30073 C5 PUSH BC
30074 60 LD H,B H=number of character just struck (200-203)
30075 CD0074 CALL 29696 Determine y-coordinate at which to print letter/number
30078 CD8C6A CALL 27276 Save area of screen to be overwritten by letter/number
30081 3808 JR C,30091 Jump if teacher is off-screen
30083 01460E LD BC,3654 Print message and make sound effect
30086 3E06 LD A,6
30088 CD7374 CALL 29811
30091 C1 POP BC
30092 E1 POP HL
30093 C33375 JP 30003