| Routines

74C8: Control the descent of the water, sherry or conker

The address of this uninterruptible subcommand routine is placed into bytes 0x11 and 0x12 of a catapult pellet's buffer by the routine at 76AC 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 (0xD5 or 0xD6)
74C8 | LD L,$02 |
74CA | LD A,(HL) | A=y-coordinate of the falling object
74CB | CP $11 | Has the object hit the bottom floor yet?
74CD | JR NZ,$74DB | Jump if not
This entry point is used by the routines at 7380, 76AC, E236, F2E2, F862 and FA4D to 'kill' a non-human object (i.e. pellet, frog, desk lid, stinkbomb cloud, water/sherry fired from pistol).
74CF | LD L,$12 | Remove the address of this routine from bytes 0x11 and 0x12 of the object's buffer
74D1 | LD (HL),$00
This entry point is used by the routine at 7A16 to make a mouse disappear temporarily.
74D3 | CALL $61B4 | Update the SRB for the object's current animatory state and location
This entry point is used by the routine at FA39 to hide water from the water pistol.
74D6 | LD L,$01 | Set the object's x-coordinate to 224 (out of sight)
74D8 | LD (HL),$E0
74DA | RET |
The falling object has yet to hit the floor. Has it hit anything else on the way there?
74DB | CP $0D | Is the object at the right height to hit someone?
74DD | JR Z,$74E6 | Jump if so
74DF | CALL $61B4 | Update the SRB for the object's current animatory state and location
74E2 | INC D | The object will fall one more level
74E3 | JP $6130 | Update the object's location and update the SRB
The object is at the right height to hit someone. Check if it has.
74E6 | LD L,$01 | Point HL at byte 0x01 of the object's buffer
74E8 | LD E,(HL) | E=falling object's x-coordinate
74E9 | LD D,$11 | This is the y-coordinate of the bottom floor (the only floor on which characters can be hit by a falling object)
74EB | CALL $74A0 | Check if any of the six adult characters were hit
74EE | LD L,$00 | Point HL at byte 0x00 of the object's buffer
74F0 | LD A,(HL) | A=animatory state of the falling object
74F1 | JR Z,$752F | Jump if an adult character was hit by the falling object
74F3 | CP $37 | 0x37: Is the falling object a conker?
74F5 | JR NZ,$74DF | Jump if not
The falling object is a conker.
74F7 | LD L,$02 | Set the conker's y-coordinate to 17 (bottom floor) for comparison with that of the potential targets
74F9 | LD (HL),$11
Before calling the routine at 6CAC 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=0x11 and B=0xCE, which means that instead of checking the character buffers in pages 0xCE-0xD1, we end up checking pages 0x11-0xDE. In that range, only pages 0xB7-0xD6 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.
74FB | CALL $6CAC | Check whether anyone was hit by the conker
74FE | LD L,$02 | Set the conker's y-coordinate back to 13
7500 | LD (HL),$0D
7502 | JR C,$74DF | Jump if nobody was hit by the conker
7504 | LD A,D | A=number of the character hit by the conker
7505 | CP $CF | Was it BOY WANDER (0xCE)?
7507 | JR C,$751E | Jump if so
7509 | CP $D1 |
750B | LD A,$0A | ERIC gets 100 points for conkering ANGELFACE or EINSTEIN
750D | JR NC,$751E | Jump unless ANGELFACE (0xCF) or EINSTEIN (0xD0) was hit
750F | CALL $73B5 | Add 100 to the score and print it
7512 | 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.
7513 | LD D,$28 | Make a sound effect with A=0x07 and C=0x12 (border alternating white and cyan)
7515 | LD BC,$2812
7518 | LD A,$07
751A | CALL $748C
751D | POP DE |
This entry point is used by the routine at 7842.
751E | PUSH DE |
This entry point is used by the routine at 76AC.
751F | CALL $74CF | Terminate the object
7522 | POP DE |
This entry point is used by the routine at 7813 to knock a character over.
7523 | EX DE,HL |
7524 | LD A,H | A=number of the character hit by the object or fist
7525 | CP $D2 | Was it ERIC?
7527 | JR NZ,$7547 | Jump if not
This entry point is used by the routine at 5F08.
7529 | LD A,$80 | Set bit 7 at 7FFB: ERIC has been knocked down
752B | LD ($7FFB),A
752E | RET |
An adult character was hit by the falling object.
752F | CP $37 | Is the falling object a conker?
7531 | JR NZ,$7552 | Jump if not
An adult character has been hit by either a conker or a drop of water or sherry.
7533 | LD C,$00 | Point BC at byte 0x00 of the character's buffer
7535 | LD A,(BC) | A=animatory state of the adult character hit by the object
7536 | AND $07 | Is the character already sitting on the floor?
7538 | CP $06
753A | JP Z,$74DF | Jump if so (the object will continue to fall)
753D | LD C,$12 | Is there an uninterruptible subcommand routine address in bytes 0x11 and 0x12 of the character's buffer (which would prevent the character from being knocked over)?
753F | LD A,(BC)
7540 | AND A
7541 | JP NZ,$74DF | Jump if so
7544 | PUSH BC |
7545 | JR $751F | 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.
7547 | LD L,$11 | Place the address of the uninterruptible subcommand routine at 7596 into bytes 0x11 and 0x12 of the stricken character's buffer
7549 | LD (HL),$96
754B | INC L
754C | LD (HL),$75
754E | INC L | Initialise the knockout delay counter in byte 0x13 of the character's buffer
754F | LD (HL),$13
7551 | RET |
An adult character has been hit by a drop of water or sherry.
7552 | LD DE,$7F00 |
7555 | CP $1F | 0x1F: Is the falling object a drop of water?
7557 | JR Z,$755B | Jump if so
7559 | LD E,$04 |
755B | LD A,B | A=number of the character who was hit by the drop of water/sherry
755C | CP $CC | Is the stricken character one of the male teachers?
755E | JR NC,$7533 | Jump if not
7560 | SUB $24 | Point DE at the relevant combination letter or number in one of the tables at 7FA4 and 7FA8
7562 | ADD A,E
7563 | LD E,A
7564 | EX DE,HL | (HL)=combination letter/number held by the teacher just knocked down
7565 | BIT 7,(HL) | Has ERIC already discovered this one?
7567 | JR NZ,$7572 | Jump if so
7569 | SET 7,(HL) | Signal: ERIC has discovered this combination letter/number
756B | PUSH BC |
756C | LD A,$14 | Add 200 to the score and print it
756E | CALL $73B5
7571 | POP BC |
7572 | LD A,(HL) | A=character code of the combination number/letter just revealed
7573 | AND $7F
7575 | LD ($7F8A),A | Store this in the first byte of message 0x05, which is used as a submessage of message 0x0E: '[5]^ '
7578 | PUSH DE |
7579 | PUSH BC |
757A | LD H,B | H=character number of the teacher just struck (0xC8-0xCB)
757B | CALL $7400 | Get the coordinates of this teacher's head
757E | CALL $6A8C | Save the area of the screen that will be overwritten by the letter/number message box
7581 | JR C,$758B | Jump if the teacher is off-screen
7583 | LD BC,$0E46 | Print the letter/number message box (message number B=0x0E) and make a sound effect
7586 | LD A,$06
7588 | CALL $7473
758B | POP BC | Restore the stricken character's number to B
758C | POP HL | Restore the falling object's character number to H
758D | JP $7533 | Terminate the falling object and knock the character over