Prev: 55023 Up: Map Next: 55187
55041: Handle Berk's jump, and load E with jump state index as appropriate
This routine updates the position, direction and velocity of a jumping character (Berk if entry at 55041 or Drutt if entry via routine at 55023) based upon various conditions (control input, collisions with obstructions and the character's current position, direction and velocity). Register E is loaded (either by this routine, or the called routine at 55196) with a value determined by these conditions. The value in E in turn determines how the character's jump will progress. A given numeric value may result from more than one set of conditions. Possible output values in E are:
Value in E Description Routine that generated value
0 Character jumping downwards, no collision 55196
0 Character jumping upwards, no collision 55196
0 Current velocity of character's jump is at least 4 and back, left and right (control input) bits are reset 55196
1 Character landed on floor / platform and back (control input) bit set 55196
2 Unused N/A
3 Character's jump velocity less than 4, and back not pressed, i.e. terminate jumping 55196
4 Character has bounced off an obstruction to the right while jumping right 55041
4 Character's jump velocity at least 4 and left (control input) bit set 55196
5 Character has bounced off an obstruction to the left while jumping left 55041
5 Character's jump velocity at least 4 and right (control input) bit set 55196
6 Character has banged his head on something above him 55196
7 Character is Berk, and his left edge is to the left of colliding entity's (class=129) left edge 55196
8 Character is Berk, and he is between left and right edges of colliding entity (129) 55196
Excluding the calls to the routine at 55196, this routine deals with the horizontal component of the jump. The vertical component is handled by the routine at 55196.
Used by the routine at 49010.
Input
IX Address of complex state data (current level) for Berk (entry via 55041) or Drutt (entry via 55060 and 55065)
Output
E Jump state index (see table above)
55041 CALL 54283 Move Berk into new room (left or right) if he is at the edge of his current room
55044 LD IX,(34240) Load IX with address of current level's complex state data for Berk
55048 BIT 7,(IX+12) If Berk's is-jumping flag is reset...
55052 RET Z ...then return
Berk's is-jumping flag is set
55053 LD A,(34208) If Drutt-mode flag is set...
55056 BIT 0,A ...
55058 JR NZ,55065 ...then skip ahead to 55065
This entry point is used by the routine at 55023.
From this point onwards, IX points to either Berk's complex state data (entry via 55041) or Drutt's complex state data (entry via 55060 or 55065).
55060 LD A,(34219) Load A with control input
55063 JR 55066 Skip ahead to 55066
This entry point is used by the routine at 55023.
55065 XOR A Load A with zero
55066 LD (55022),A Store value in A at 55022
55069 BIT 0,(IX+11) If jumper's walking-right flag is reset...
55073 JR Z,55128 ...then skip ahead to 55128
Walking-right flag is set
55075 LD B,2 Load B with 2 (as Berk and Drutt jump right by two characters)
55077 PUSH BC Store BC (B = remaining number of characters to move)
55078 CALL 54569 Check jumper for collision with another impassable / pushable entity immediately to the right...
55081 JR C,55108 ...and if a collision has not occurred, then skip ahead to 55108
55083 CP 22 If collision was with an entity of class less than 22 (can be picked up)...
55085 JR C,55108 ...then skip ahead to 55108
55087 CP 129 If collision was with entity of class 129 (causes other entities to start falling)...
55089 JR Z,55108 ...then skip ahead to 55108
55091 CP 50 If collision was with entity of class 50 (causes Drutt to swap depth levels)...
55093 JR Z,55108 ...then skip ahead to 55108
55095 CP 159 If collision was not with entity of class 159 (Berk floating)...
55097 JR NZ,55124 ...then skip ahead to 55124
Collision with Berk, floating
55099 LD (IY+11),241 Set Berk's walking-right, impassable-leftwards, impassable-rightwards, interaction-(11,6) and interaction-(11,7) flags and reset his walking-left, unused-(11,2) and unused-(11,3) flags
55103 CALL 55187 Set character-swap-pending flag
55106 JR 55124 Skip ahead to 55124
No collision, or collision with entity of class 50, 129 or less than 22
55108 CALL 54313 Move jumper into room to the right, if appropriate...
55111 JR NC,55124 ...and if jumper can't enter new room then skip ahead to 55124
55113 INC (IX+5) Move jumper right by one character...
55116 INC (IX+7) ...
55119 POP BC Restore BC (B = remaining number of characters to move)
55120 DJNZ 55077 Decrease remaining number of characters to move, and if not zero, loop back to 55077
55122 JR 55196 Handle vertical component of jumper's jump, load E with jump state index and return
Collision with other class of entity
55124 POP BC Restore BC (B = remaining number of characters to move)
55125 LD E,4 Load E with 4 (jumper has bounced off an obstruction to the right while jumping right)
55127 RET Return
Walking-right flag is reset
55128 BIT 1,(IX+11) If jumper's walking-left flag is reset...
55132 JR Z,55196 ...then skip ahead to 55196 (handle vertical component of jumper's jump, load E with jump state index and return)
Walking-left flag is set
55134 LD B,2 Load B with 2 (as Berk and Drutt jump left by two characters)
55136 PUSH BC Store BC (B = remaining number of characters to move)
55137 CALL 54666 Check jumper for collision with another impassable / pushable entity immediately to the left...
55140 JR C,55167 ...and if a collision has not occurred, then skip ahead to 55167
55142 CP 22 If collision was with an entity of class less than 22 (can be picked up)...
55144 JR C,55167 ...then skip ahead to 55167
55146 CP 129 If collision was with entity of class 129 (causes other entities to start falling)...
55148 JR Z,55167 ...then skip ahead to 55167
55150 CP 50 If collision was with entity of class 50 (causes Drutt to swap depth levels)...
55152 JR Z,55167 ...then skip ahead to 55167
55154 CP 159 If collision was not with entity of class 159 (Berk floating)...
55156 JR NZ,55183 ...then skip ahead to 55183
Collision with Berk, floating
55158 LD (IY+11),242 Set Berk's walking-left, impassable-leftwards, impassable-rightwards, interaction-(11,6) and interaction-(11,7) flags and reset his walking-right and unused-(11,2) and unused-(11,3) flags
55162 CALL 55187 Set character-swap-pending flag
55165 JR 55183 Skip ahead to 55183
No collision, or collision with entity of class 50, 129 or less than 22
55167 CALL 54348 Move jumper into room to the left, if appropriate...
55170 JR NC,55183 ...and if jumper can't enter new room then skip ahead to 55183
55172 DEC (IX+5) Move jumper left by one character...
55175 DEC (IX+7) ...
55178 POP BC Restore BC (B = remaining number of characters to move)
55179 DJNZ 55136 Decrease remaining number of characters to move, and if not zero, loop back to 55136
55181 JR 55196 Handle vertical component of jumper's jump, load E with jump state index and return
Collision with other class of entity
55183 POP BC Restore BC (B = remaining number of characters to move)
55184 LD E,5 Load E with 5 (jumper has bounced off an obstruction to the left while jumping left)
55186 RET Return
Prev: 55023 Up: Map Next: 55187