Prev: 6D0A Up: Map Next: 6DC5
6D1C: Control the horizontal flight of a catapult pellet
The address of this uninterruptible subcommand routine is placed into bytes 0x6F and 0x70 of a catapult pellet's buffer by the routine at 7048. It controls the pellet from the beginning of its horizontal flight to the end, handing over to the routine at 6DC6 if the pellet bounces upwards off some obstacle.
Input
H 0xAA (BOY WANDER's pellet) or 0xAB (ERIC's pellet)
6D1C CALL $6214 Update the SRB for the pellet's current location
6D1F LD L,$71 Byte 0x71 of the pellet's buffer holds the distance left to travel
6D21 DEC (HL) Has the pellet finished travelling?
6D22 JR NZ,$6D2D Jump if not
This entry point is used by the routine at 6DC6. It places the catapult pellet off-screen and terminates its flight.
6D24 LD L,$62 Set the pellet's x-coordinate to 150 (i.e. off-screen)
6D26 LD (HL),$96
6D28 LD L,$70 Remove the address of this routine from bytes 0x6F and 0x70 of the pellet's buffer
6D2A LD (HL),$00
6D2C RET
The pellet has not finished travelling. Where to next?
6D2D INC E Set E equal to the next x-coordinate for the pellet
6D2E RLCA
6D2F JR C,$6D33
6D31 DEC E
6D32 DEC E
6D33 LD A,E A=pellet's next x-coordinate
6D34 CP $60 Will it still be on-screen?
6D36 JR NC,$6D24 Terminate the pellet if not
6D38 LD A,D A=pellet's y-coordinate
6D39 CALL $6649 Was the pellet fired on the top, middle or bottom floor?
6D3C JR NZ,$6D4D Jump if not
6D3E CP $A9 Is the pellet on the bottom floor?
6D40 JR Z,$6D4D Jump if so
6D42 CP $9B Set the zero flag if the pellet is on the top floor
6D44 LD A,$26 This is the x-coordinate of the wall between the White and Exam Rooms
6D46 JR NZ,$6D4A Jump if the pellet is on the middle floor
6D48 LD A,$39 This is the x-coordinate of the wall between the Reading and Map Rooms
6D4A CP E Has the pellet hit a wall?
6D4B JR Z,$6D24 Terminate the pellet if so
6D4D LD L,$60 Byte 0x60 of the pellet's buffer holds its animatory state
6D4F LD A,(HL) Pick this up in A
6D50 CALL $61B0 Update the pellet's location and update the SRB
6D53 LD L,$61 Byte 0x61 of the pellet's buffer holds its y-coordinate
6D55 LD A,(HL) Pick this up in A
6D56 CALL $6649 Was the pellet fired on the top, middle or bottom floor?
6D59 JP NZ,$6DDB Jump if not
The pellet was fired on the top, middle or bottom floor. Let's see if it's hit anybody.
6D5C LD L,$71 Byte 0x71 of the pellet's buffer holds the distance left to travel
6D5E LD A,(HL) Pick this up in A
6D5F CP $08 Is the pellet ready to hit something?
6D61 RET NC Return if not
6D62 LD DE,$AC62 Point DE at ERIC's x-coordinate
6D65 LD L,E L=0x62
6D66 LD A,(DE) Pick up ERIC's x-coordinate in A
6D67 CP (HL) Does it match the pellet's x-coordinate?
6D68 JR NZ,$6D84 Jump if not
6D6A DEC E E=0x61
6D6B DEC L L=0x61
6D6C LD A,(DE) Pick up ERIC's y-coordinate in A
6D6D INC E E=0x62
6D6E CP (HL) Compare ERIC's y-coordinate with that of the pellet
6D6F LD L,E L=0x62
6D70 JR NZ,$6D84 Jump unless ERIC's location matches that of the pellet
ERIC has been hit by the pellet. Knock him over.
6D72 LD DE,$7FFB Signal that ERIC has been knocked over by setting bit 4 of ERIC's status flags at 7FFB
6D75 EX DE,HL
6D76 SET 4,(HL)
6D78 EX DE,HL
6D79 LD L,$71 The pellet has hit something; set its remaining distance to travel to 1, so it's terminated next time
6D7B LD (HL),$01
6D7D LD A,D A=number of the character hit by the pellet
6D7E CP $A8 Was ANGELFACE hit?
6D80 JP Z,$6AFB Add to the score and print it if so
6D83 RET
ERIC wasn't hit by the pellet. What about the main kids and teachers?
6D84 LD D,$A9 0xA9=EINSTEIN
6D86 LD B,$07 There are 3 main kids and 4 teachers
6D88 LD A,(DE) Pick up the potential target's x-coordinate in A
6D89 CP (HL) Does it match that of the pellet?
6D8A JR Z,$6D90 Jump if so
6D8C DEC D Next main kid or teacher
6D8D DJNZ $6D88 Jump back until all the main kids and teachers have been checked
6D8F RET
6D90 DEC E E=0x61
6D91 DEC L L=0x61
6D92 LD A,(DE) Pick up the potential target's y-coordinate in A
6D93 INC E E=0x62
6D94 CP (HL) Compare the potential target's y-coordinate
6D95 LD L,E L=0x62
6D96 JR NZ,$6D8C Jump unless the potential target's coordinates match
We have found a potential target at the pellet's current coordinates. Can we knock him over?
6D98 LD E,$70 Byte 0x70 of the character's buffer may hold the MSB of an uninterruptible subcommand routine address; pick this up in A
6D9A LD A,(DE)
6D9B LD E,L E=0x62
6D9C AND A Is there an uninterruptible subcommand routine address in bytes 0x6F and 0x70?
6D9D JR NZ,$6DAC Jump if so
6D9F EX DE,HL
6DA0 LD L,$6F Place the address of the uninterruptible subcommand routine at 6A46 into bytes 0x6F and 0x70 of the character's buffer, which will knock the character over
6DA2 LD (HL),$46
6DA4 INC L
6DA5 LD (HL),$6A
6DA7 INC L Initialise the parameter determining how long the character will stay down in byte 0x71 of his buffer
6DA8 LD (HL),$14
6DAA JR $6D78
The potential target may already have been knocked over. Let's check.
6DAC LD E,$60 Byte 0x60 of the buffer holds the potential target's animatory state
6DAE LD A,(DE) Pick this up in A
6DAF LD E,L E=0x62
6DB0 AND $7F Remove the direction bit (bit 7)
6DB2 CP $48 Is the potential target a kid?
6DB4 JR C,$6D8C Jump back to consider the next main kid or teacher if so
6DB6 AND $07 Retain only bits 0-2 of the teacher's animatory state
6DB8 CP $07 Has the teacher already been knocked down?
6DBA JR NZ,$6D8C Jump back to consider the next teacher if not
The pellet has hit a teacher who's already been knocked over. Prepare for vertical flight.
6DBC LD L,$6F Place the address of the uninterruptible subcommand routine at 6DC6 into bytes 0x6F and 0x70 of the pellet's character buffer, which will make the pellet travel upwards from now on
6DBE LD (HL),$C6
6DC0 LD L,$71 Set the pellet's remaining distance to travel to 5 spaces
6DC2 LD (HL),$05
6DC4 RET
Prev: 6D0A Up: Map Next: 6DC5