Prev: 36036 Up: Map Next: 36296
36116: If Berk is not horizontally aligned with entity at IY then move Berk closer and exit calling routine
Used by the routines at 35735 and 36036.
Input
IX Address of complex state data (current level) for Berk
IY Address of complex state data for entity with which Berk has collided
36116 LD A,(IY+7) Load A with width of entity at IY, minus 1...
36119 SUB (IY+5) ...
36122 SRL A ...divide value by 2...
36124 SUB 2 ...and subtract 2
36126 ADD A,(IY+5) Add result to x-coordinate of entity's left edge
At this point, A holds the x-coordinate of the middle of the entity at IY, minus two
36129 CP (IX+5) If x-coordinate in A is the same as Berk's left side x-coordinate...
36132 RET Z ...then return
36133 POP BC Remove top value from stack (i.e. return address to routine that called this routine)
36134 JP NC,36214 If x-coordinate in A is the less than Berk's left side x-coordinate then skip ahead to 36214
This entry point is used by the routine at 35735.
Attempt to move Berk left
36137 BIT 6,(IX+9) If Berk is flying...
36141 JR NZ,36200 ...then skip ahead to 36200
Attempt to move Berk left (not flying) (see bugs)
36143 RES 1,(IX+9) Reset Berk's facing-into-screen flag
36147 CALL 54666 Check Berk for collision with another impassable / pushable entity immediately to the left...
36150 JR NC,36171 ...and if a collision occurred, then skip ahead to 36171
No collision
36152 CALL 54348 Move Berk into room to the left, if appropriate and if Berk can't enter new room then jump to 35786 (terminate Berk's flight, or have him (turn to) face out of screen as appropriate)
36155 JP NC,35786
36158 BIT 1,(IX+11) If Berk's walking-left flag is already set...
36162 JP NZ,48096 ...then jump to 48096 (advance HL to next script instruction and execute)
36165 LD HL,35263 Point HL at script data for Berk starting to walk left...
36168 JP 48098 ...and execute
Collision occurred with entity to the left
36171 CP 129 If collision was not with entity of class 129 (causes other entities to start falling)...
36173 JR NZ,36184 ...then skip ahead to 36184
36175 CALL 36296 Make Berk drop the entity he is holding and load IY with its complex state data address
36178 LD HL,35291 Point HL at script data for Berk starting to fall to the left...
36181 JP 48098 ...and execute
36184 CP 22 If collision was with an entity of class of less than 22 (can be picked up)...
36186 JR C,36158 ...then jump back to 36158
36188 CP 50 If collision was with entity of class 50 (causes Drutt to swap depth levels)...
36190 JR Z,36158 ...then jump back to 36158
36192 CP 25 If collision was with entity of class 25 (ape-beast, level 2)...
36194 CALL Z,53667 ...then set Berk-has-been-killed flag
36197 JP 35786 Jump to 35786 (terminate Berk's flight, or have him (turn to) face out of screen as appropriate)
Attempt to move Berk left (flying)
36200 CALL 54666 Check Berk for collision with another impassable / pushable entity immediately to the left...
36203 JP C,48096 ...and if a collision has not occurred, then jump to 48096 (advance HL to next script instruction and execute)
36206 CP 129 If collision was with entity of class 129 (causes other entities to start falling)...
36208 JP Z,48096 ...then jump to 48096 (advance HL to next script instruction and execute)
36211 JP 35786 Jump to 35786 (terminate Berk's flight, or have him (turn to) face out of screen as appropriate)
This entry point is used by the routine at 35735.
Attempt to move Berk right
36214 BIT 6,(IX+9) If Berk is flying...
36218 JP NZ,36282 ...then skip ahead to 36282
Attempt to move Berk right (not flying) (see bugs)
36221 RES 1,(IX+9) Reset Berk's facing-into-screen flag
36225 CALL 54569 Check Berk for collision with another impassable / pushable entity immediately to the right...
36228 JR NC,36249 ...and if a collision occurred, then skip ahead to 36249
No collision
36230 CALL 54313 Move Berk into room to the right, if appropriate and if Berk can't enter new room then jump to 35786 (terminate Berk's flight, or have him (turn to) face out of screen as appropriate)
36233 JP NC,35786
36236 BIT 0,(IX+11) If Berk's walking-right flag is already set...
36240 JP NZ,48096 ...then jump to 48096 (advance HL to next script instruction and execute)
36243 LD HL,35251 Point HL at script data for Berk starting to walk right...
36246 JP 48098 ...and execute
Collision occurred with entity to the right
36249 CP 129 If collision was not with entity of class 129 (causes other entities to start falling)...
36251 JR NZ,36266 ...then skip ahead to 36266
36253 CALL 36296 Make Berk drop the entity he is holding and load IY with its complex state data address
36256 LD IY,(34260) Load IY with address of complex state data for entity last held by Berk (see trivia)
36260 LD HL,35327 Point HL at script data for Berk starting to fall to the right...
36263 JP 48098 ...and execute
36266 CP 22 If collision was with an entity of class of less than 22 (can be picked up)...
36268 JR C,36236 ...then jump back to 36236
36270 CP 50 If collision was with entity of class 50 (causes Drutt to swap depth levels)...
36272 JR Z,36236 ...then jump back to 36236
36274 CP 25 If collision was with entity of class 25 (ape-beast, level 2)...
36276 CALL Z,53667 ...then set Berk-has-been-killed flag
36279 JP 35786 Jump to 35786 (terminate Berk's flight, or have him (turn to) face out of screen as appropriate)
Attempt to move Berk right (flying)
36282 CALL 54569 Check Berk for collision with another impassable / pushable entity immediately to the right...
36285 JP C,48096 ...and if a collision has not occurred, then jump to 48096 (advance HL to next script instruction and execute)
36288 CP 129 If collision was with entity of class 129 (causes other entities to start falling)...
36290 JP Z,48096 ...then jump to 48096 (advance HL to next script instruction and execute)
36293 JP 35786 Jump to 35786 (terminate Berk's flight, or have him (turn to) face out of screen as appropriate)
Prev: 36036 Up: Map Next: 36296