| Routines

29896: Control the descent of the water, sherry or conker

The address of this uninterruptible subcommand routine is placed into bytes 17 and 18 of a catapult pellet's buffer by the routine at 30380 when it has hit either the tree or a water/sherry-filled cup, and thus released a conker or a drop of water or sherry.
Input
H | Falling object's character number (213 or 214)
29896 | LD L,2 |
29898 | LD A,(HL) | A=y-coordinate of the falling object
29899 | CP 17 | Has the object hit the bottom floor yet?
29901 | JR NZ,29915 | Jump if not
This entry point is used by the routines at 29568, 30380, 57910, 62178, 63586 and 64077 to 'kill' a non-human object (i.e. pellet, frog, desk lid, stinkbomb cloud, water/sherry fired from pistol).
29903 | LD L,18 | Remove the address of this routine from bytes 17 and 18 of the object's buffer
29905 | LD (HL),0
This entry point is used by the routine at 31254 to make a mouse disappear temporarily.
29907 | CALL 25012 | Update the 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 | LD L,1 | Set the object's x-coordinate to 224 (out of sight)
29912 | LD (HL),224
29914 | RET |
The falling object has yet to hit the floor. Has it hit anything else on the way there?
29915 | CP 13 | Is the object at the right height to hit someone?
29917 | JR Z,29926 | Jump if so
29919 | CALL 25012 | Update the SRB for the object's current animatory state and location
29922 | INC D | The object will fall one more level
29923 | JP 24880 | Update the object's location and update the SRB
The object is at the right height to hit someone. Check if it has.
29926 | LD L,1 | Point HL at byte 1 of the object's buffer
29928 | LD E,(HL) | E=falling object's x-coordinate
29929 | LD D,17 | This is the y-coordinate of the bottom floor (the only floor on which characters can be hit by a falling object)
29931 | CALL 29856 | Check if any of the six adult characters were hit
29934 | LD L,0 | Point HL at byte 0 of the object's buffer
29936 | LD A,(HL) | A=animatory state of the falling object
29937 | JR Z,29999 | Jump if an adult character was hit by the falling object
29939 | CP 55 | 55: Is the falling object a conker?
29941 | JR NZ,29919 | Jump if not
The falling object is a conker.
29943 | LD L,2 | Set the conker's y-coordinate to 17 (bottom floor) for comparison with that of the potential targets
29945 | LD (HL),17
Before calling the routine at 27820 to check whether any of the four main kids (besides ERIC) have been hit, D should be set to 206 (BOY WANDER, the first main kid), and B should be set to 4 (the number of kids to check). However, at this point D=17 and B=206, which means that instead of checking the character buffers in pages 206-209, we end up checking pages 17-222. In that range, only pages 183-214 contain character buffers; treating the other pages in RAM as if they contained character buffers could lead to data/code corruption. Needless to say, this is a bug.
29947 | CALL 27820 | Check whether anyone was hit by the conker
29950 | LD L,2 | Set the conker's y-coordinate back to 13
29952 | LD (HL),13
29954 | JR C,29919 | Jump if nobody was hit by the conker
29956 | LD A,D | A=number of the character hit by the conker
29957 | CP 207 | Was it BOY WANDER (206)?
29959 | JR C,29982 | Jump if so
29961 | CP 209 |
29963 | LD A,10 | ERIC gets 100 points for conkering ANGELFACE or EINSTEIN
29965 | JR NC,29982 | Jump unless ANGELFACE (207) or EINSTEIN (208) was hit
29967 | CALL 29621 | Add 100 to the score and print it
29970 | PUSH DE |
Celebrate the conkering of ANGELFACE or EINSTEIN with a sound effect. Your browser doesn't support HTML5 audio. Here is a link to the audio instead.
29971 | LD D,40 | Make a sound effect with A=7 and C=18 (border alternating white and cyan)
29973 | LD BC,10258
29976 | LD A,7
29978 | CALL 29836
29981 | POP DE |
This entry point is used by the routine at 30786.
29982 | PUSH DE |
This entry point is used by the routine at 30380.
29983 | CALL 29903 | Terminate the object
29986 | POP DE |
This entry point is used by the routine at 30739 to knock a character over.
29987 | EX DE,HL |
29988 | LD A,H | A=number of the character hit by the object or fist
29989 | CP 210 | Was it ERIC?
29991 | JR NZ,30023 | Jump if not
This entry point is used by the routine at 24328.
29993 | LD A,128 | Set bit 7 at 32763: ERIC has been knocked down
29995 | LD (32763),A
29998 | RET |
An adult character was hit by the falling object.
29999 | CP 55 | Is the falling object a conker?
30001 | JR NZ,30034 | Jump if not
An adult character has been hit by either a conker or a drop of water or sherry.
30003 | LD C,0 | Point BC at byte 0 of the character's buffer
30005 | LD A,(BC) | A=animatory state of the adult character hit by the object
30006 | AND 7 | Is the character already sitting on the floor?
30008 | CP 6
30010 | JP Z,29919 | Jump if so (the object will continue to fall)
30013 | LD C,18 | Is there an uninterruptible subcommand routine address in bytes 17 and 18 of the character's buffer (which would prevent the character from being knocked over)?
30015 | LD A,(BC)
30016 | AND A
30017 | JP NZ,29919 | Jump if so
30020 | PUSH BC |
30021 | JR 29983 | Terminate the object and knock the character over
This section of code sets up the uninterruptible subcommand that will control the character who has been knocked over until it's time for him to get up.
30023 | LD L,17 | Place the address of the uninterruptible subcommand routine at 30102 into bytes 17 and 18 of the stricken character's buffer
30025 | LD (HL),150
30027 | INC L
30028 | LD (HL),117
30030 | INC L | Initialise the knockout delay counter in byte 19 of the character's buffer
30031 | LD (HL),19
30033 | RET |
An adult character has been hit by a drop of water or sherry.
30034 | LD DE,32512 |
30037 | CP 31 | 31: Is the falling object a drop of water?
30039 | JR Z,30043 | Jump if so
30041 | LD E,4 |
30043 | LD A,B | A=number of the character who was hit by the drop of water/sherry
30044 | CP 204 | Is the stricken character one of the male teachers?
30046 | JR NC,30003 | Jump if not
30048 | SUB 36 | Point DE at the relevant combination letter or number in one of the tables at 32676 and 32680
30050 | ADD A,E
30051 | LD E,A
30052 | EX DE,HL | (HL)=combination letter/number held by the teacher just knocked down
30053 | BIT 7,(HL) | Has ERIC already discovered this one?
30055 | JR NZ,30066 | Jump if so
30057 | SET 7,(HL) | Signal: ERIC has discovered this combination letter/number
30059 | PUSH BC |
30060 | LD A,20 | Add 200 to the score and print it
30062 | CALL 29621
30065 | POP BC |
30066 | LD A,(HL) | A=character code of the combination number/letter just revealed
30067 | AND 127
30069 | LD (32650),A | Store this in the first byte of message 5, which is used as a submessage of message 14: '[5]^ '
30072 | PUSH DE |
30073 | PUSH BC |
30074 | LD H,B | H=character number of the teacher just struck (200-203)
30075 | CALL 29696 | Get the coordinates of this teacher's head
30078 | CALL 27276 | Save the area of the screen that will be overwritten by the letter/number message box
30081 | JR C,30091 | Jump if the teacher is off-screen
30083 | LD BC,3654 | Print the letter/number message box (message number B=14) and make a sound effect
30086 | LD A,6
30088 | CALL 29811
30091 | POP BC | Restore the stricken character's number to B
30092 | POP HL | Restore the falling object's character number to H
30093 | JP 30003 | Terminate the falling object and knock the character over