![]() |
Routines |
| Prev: 57989 | Up: Map | Next: 58400 |
|
Handler for the object types 92 to 95 an eagle that carries Sabreman (see Handle_Flying_Creature). Bit 0 of the type is the frame of the animation, which follows bit 1 of the tick counter, and bit 1 is set when the x velocity is negative.
While Sabreman is being carried his record has the sprite id 96 to 99. The eagle puts his position in bytes 8 (x) and 9 (y) of his record (at Sabreman_Carried_X_Position and Sabreman_Carried_Y_Position), where Handle_Carried_Sabreman picks it up. The y position is 16 more than that of the eagle, so he hangs below it.
The eagle flies towards a target (byte 12 is the x position and byte 14 the y position, see Choose_Eagle_Target). Each call changes each velocity by one towards the target. The x velocity is kept between 208 and 55 and the y velocity between 199 and 55. The target changes when the eagle bounces off a decoration, a bubble, the floor, the ceiling or a wall. The eagle can also fly through the gaps in the frame of a room, and into the next room. The player can nudge the eagle with the controls (see Steer_Eagle).
The eagle lets go (see Check_Eagle_Release) when the low byte of FRAMES is zero, or when Sabreman has set bit 5 of his redraw flags, if it is in the open part of the room. If the sprite id of Sabreman is less than 28 (he is not being carried), the eagle lets go at once (see Release_Sabreman).
|
||||||||
| Handle_Carrying_Eagle | 58059 | CALL StoreEntity | Save the state of the eagle. | |||||
| 58062 | LD A,(36634) | Fetch the sprite id of Sabreman. | ||||||
| 58065 | CP 28 | Jump to Release_Sabreman if he is not being carried. | ||||||
| 58067 | JP C,Release_Sabreman | |||||||
| 58070 | CALL Steer_Eagle | Nudge the eagle if the player presses a direction. | ||||||
| 58073 | CALL Read_World_Map | Read the world map entry of the room that the eagle is in. The flags of the room are returned in E. | ||||||
| 58076 | LD A,(23672) | Fetch the low byte of FRAMES. | ||||||
| 58079 | AND A | Call Check_Eagle_Release to let go of Sabreman if the low byte of FRAMES is zero. | ||||||
| 58080 | CALL Z,Check_Eagle_Release | |||||||
| 58083 | LD A,(36649) | Fetch the redraw flags of Sabreman. | ||||||
| 58086 | BIT 5,A | Test bit 5, which Sabreman sets to ask the eagle to let go. | ||||||
| 58088 | RES 5,A | Reset bit 5. | ||||||
| 58090 | LD (36649),A | Store the redraw flags of Sabreman. | ||||||
| 58093 | CALL NZ,Check_Eagle_Release | Call Check_Eagle_Release to let go of Sabreman if bit 5 was set. | ||||||
|
This entry point is used by the routine at Handle_Flying_Creature.
|
||||||||
| Handle_Carrying_Eagle_Carry | 58096 | LD A,1 | Set the flag at Type_5C_Active_Flag to show that an eagle is carrying Sabreman. | |||||
| 58098 | LD (36593),A | |||||||
| 58101 | LD A,(IX+3) | Fetch the y position of the eagle. | ||||||
| 58104 | ADD A,16 | Add 16. | ||||||
| 58106 | CP 159 | Jump to Handle_Carrying_Eagle_Set_Carry_Position if the result is less than 159. | ||||||
| 58108 | JR C,Handle_Carrying_Eagle_Set_Carry_Position | |||||||
| 58110 | BIT 4,E | Jump to Handle_Carrying_Eagle_Set_Carry_Position if the room has no floor. | ||||||
| 58112 | JR Z,Handle_Carrying_Eagle_Set_Carry_Position | |||||||
| 58114 | LD A,159 | Limit the y position to 159. | ||||||
| Handle_Carrying_Eagle_Set_Carry_Position | 58116 | LD (36643),A | Set the y position of Sabreman. | |||||
| 58119 | LD A,(IX+1) | Fetch the x position of the eagle. | ||||||
| 58122 | LD (36642),A | Set the x position of Sabreman. | ||||||
|
Work out the type of the eagle. Bit 0 follows bit 1 of the tick counter and bit 1 is set when the x velocity is negative.
|
||||||||
| 58125 | LD A,(IX+0) | Fetch the type of the eagle. | ||||||
| 58128 | AND %11111110 | Reset bit 0. | ||||||
| 58130 | LD C,A | Keep the type without bit 0 in C. | ||||||
| 58131 | LD A,(36566) | Fetch the tick counter. | ||||||
| 58134 | RRA | Move bit 1 into bit 0. | ||||||
| 58135 | AND %00000001 | Keep only that bit. | ||||||
| 58137 | ADD A,C | Add the type. | ||||||
| 58138 | BIT 7,(IX+8) | Jump to Handle_Carrying_Eagle_Face_Right if the x velocity is positive. | ||||||
| 58142 | JR Z,Handle_Carrying_Eagle_Face_Right | |||||||
| 58144 | OR %00000010 | Set bit 1. | ||||||
| 58146 | JR Handle_Carrying_Eagle_Store_Type | Jump to Handle_Carrying_Eagle_Store_Type. | ||||||
| Handle_Carrying_Eagle_Face_Right | 58148 | AND %11111101 | Reset bit 1. | |||||
| Handle_Carrying_Eagle_Store_Type | 58150 | LD (IX+0),A | Store the type of the eagle. | |||||
|
Change the x velocity by one towards the target.
|
||||||||
| 58153 | LD A,(IX+1) | Fetch the x position of the eagle. | ||||||
| 58156 | CP (IX+12) | Compare it with the x position of the target. | ||||||
| 58159 | LD A,(IX+8) | Fetch the x velocity. | ||||||
| 58162 | JP NC,Accelerate_Eagle_Left | Jump to Accelerate_Eagle_Left if the eagle is at or to the right of the target. | ||||||
| 58165 | INC A | Add one to the x velocity. | ||||||
| 58166 | BIT 7,A | Jump to Handle_Carrying_Eagle_Store_X_Velocity if the x velocity is negative. | ||||||
| 58168 | JR NZ,Handle_Carrying_Eagle_Store_X_Velocity | |||||||
| 58170 | CP 56 | Jump to Handle_Carrying_Eagle_Adjust_Y_Velocity if the x velocity has reached 56. | ||||||
| 58172 | JR NC,Handle_Carrying_Eagle_Adjust_Y_Velocity | |||||||
|
This entry point is used by the routine at Accelerate_Eagle_Left.
|
||||||||
| Handle_Carrying_Eagle_Store_X_Velocity | 58174 | LD (IX+8),A | Store the x velocity. | |||||
|
This entry point is used by the routine at Accelerate_Eagle_Left.
Change the y velocity by one towards the target.
|
||||||||
| Handle_Carrying_Eagle_Adjust_Y_Velocity | 58177 | LD A,(IX+3) | Fetch the y position of the eagle. | |||||
| 58180 | CP (IX+14) | Compare it with the y position of the target. | ||||||
| 58183 | LD A,(IX+9) | Fetch the y velocity. | ||||||
| 58186 | JP NC,Accelerate_Eagle_Up | Jump to Accelerate_Eagle_Up if the eagle is at or below the target. | ||||||
| 58189 | INC A | Add one to the y velocity. | ||||||
| 58190 | BIT 7,A | Jump to Handle_Carrying_Eagle_Store_Y_Velocity if the y velocity is negative. | ||||||
| 58192 | JR NZ,Handle_Carrying_Eagle_Store_Y_Velocity | |||||||
| 58194 | CP 56 | Jump to Handle_Carrying_Eagle_Check_Contact if the y velocity has reached 56. | ||||||
| 58196 | JR NC,Handle_Carrying_Eagle_Check_Contact | |||||||
|
This entry point is used by the routine at Accelerate_Eagle_Up.
|
||||||||
| Handle_Carrying_Eagle_Store_Y_Velocity | 58198 | LD (IX+9),A | Store the y velocity. | |||||
|
This entry point is used by the routine at Accelerate_Eagle_Up.
Check for contact with the decorations and the bubbles, and bounce off them.
|
||||||||
| Handle_Carrying_Eagle_Check_Contact | 58201 | PUSH DE | Stash the flags of the room. | |||||
| 58202 | CALL Check_Decoration_Contact | Check for contact with the decorations. | ||||||
| 58205 | LD D,C | Store the result in D. | ||||||
| 58206 | CALL Check_Bubble_Contact | Check for contact with the bubbles. | ||||||
| 58209 | LD A,C | Copy the result to A. | ||||||
| 58210 | OR D | Combine it with the result for the decorations. | ||||||
| 58211 | LD C,A | Store the combined result in C. | ||||||
| 58212 | POP DE | Restore the flags of the room. | ||||||
| 58213 | BIT 2,C | Jump to Handle_Carrying_Eagle_Move_X if the eagle is not touching anything. | ||||||
| 58215 | JR Z,Handle_Carrying_Eagle_Move_X | |||||||
| 58217 | BIT 1,C | Jump to Handle_Carrying_Eagle_Check_Underside if the eagle is not on top of the object. | ||||||
| 58219 | JR Z,Handle_Carrying_Eagle_Check_Underside | |||||||
| 58221 | BIT 5,C | Jump to Handle_Carrying_Eagle_Check_Sides if the object is a bubble and the eagle is away from the middle of it. | ||||||
| 58223 | JR NZ,Handle_Carrying_Eagle_Check_Sides | |||||||
| 58225 | LD A,(IX+9) | Fetch the y velocity. | ||||||
| 58228 | AND A | Jump to Handle_Carrying_Eagle_Move_X if the eagle is moving up already. | ||||||
| 58229 | JP M,Handle_Carrying_Eagle_Move_X | |||||||
| 58232 | CPL | Invert the y velocity, to send the eagle up. | ||||||
| 58233 | LD (IX+9),A | Store the y velocity. | ||||||
| 58236 | CALL Choose_Eagle_Target | Choose a new target. | ||||||
| 58239 | JR Handle_Carrying_Eagle_Move_X | Jump to Handle_Carrying_Eagle_Move_X. | ||||||
| Handle_Carrying_Eagle_Check_Underside | 58241 | BIT 0,C | Jump to Handle_Carrying_Eagle_Check_Sides if the eagle is not near the middle of the object. | |||||
| 58243 | JR NZ,Handle_Carrying_Eagle_Check_Sides | |||||||
| 58245 | LD A,(IX+9) | Fetch the y velocity. | ||||||
| 58248 | AND A | Jump to Handle_Carrying_Eagle_Check_Sides if the eagle is moving down already. | ||||||
| 58249 | JP P,Handle_Carrying_Eagle_Check_Sides | |||||||
| 58252 | CPL | Invert the y velocity, to send the eagle down. | ||||||
| 58253 | LD (IX+9),A | Store the y velocity. | ||||||
| Handle_Carrying_Eagle_Check_Sides | 58256 | LD A,(IX+8) | Fetch the x velocity. | |||||
| 58259 | BIT 7,C | Jump to Handle_Carrying_Eagle_Bounce_Left if the eagle is not to the right of the object. | ||||||
| 58261 | JR Z,Handle_Carrying_Eagle_Bounce_Left | |||||||
| 58263 | AND A | Jump to Handle_Carrying_Eagle_Move_X if the eagle is moving to the right already. | ||||||
| 58264 | JP P,Handle_Carrying_Eagle_Move_X | |||||||
| 58267 | CPL | Invert the x velocity. | ||||||
| 58268 | LD (IX+8),A | Store the x velocity. | ||||||
| 58271 | CALL Choose_Eagle_Target | Choose a new target. | ||||||
| 58274 | JR Handle_Carrying_Eagle_Move_X | Jump to Handle_Carrying_Eagle_Move_X. | ||||||
| Handle_Carrying_Eagle_Bounce_Left | 58276 | AND A | Jump to Handle_Carrying_Eagle_Move_X if the eagle is moving to the left already. | |||||
| 58277 | JP M,Handle_Carrying_Eagle_Move_X | |||||||
| 58280 | CPL | Invert the x velocity. | ||||||
| 58281 | LD (IX+8),A | Store the x velocity. | ||||||
| 58284 | CALL Choose_Eagle_Target | Choose a new target. | ||||||
|
Move the eagle horizontally.
|
||||||||
| Handle_Carrying_Eagle_Move_X | 58287 | LD A,(IX+11) | Fetch the contact flags. | |||||
| 58290 | AND %11101110 | Reset bits 0 and 4 (the ceiling and the floor). | ||||||
| 58292 | LD (IX+11),A | Store the contact flags. | ||||||
| 58295 | LD L,(IX+8) | Fetch the x velocity into L. | ||||||
| 58298 | BIT 7,L | Test the sign of the x velocity. | ||||||
| 58300 | LD H,0 | Clear the high byte of the x velocity (as a word). | ||||||
| 58302 | JR Z,Handle_Carrying_Eagle_Set_Sabreman_Velocity | Jump to Handle_Carrying_Eagle_Set_Sabreman_Velocity if the x velocity is positive. | ||||||
| 58304 | LD H,255 | Set the high byte of the x velocity to 255 to extend the sign. | ||||||
| Handle_Carrying_Eagle_Set_Sabreman_Velocity | 58306 | LD A,L | Copy the x velocity to A. | |||||
| 58307 | SRA A | Divide it by sixteen, keeping its sign. | ||||||
| 58309 | SRA A | |||||||
| 58311 | SRA A | |||||||
| 58313 | SRA A | |||||||
| 58315 | LD (36640),A | Set the x velocity of Sabreman. | ||||||
| 58318 | CALL Move_Object_Horizontally | Move the eagle horizontally (see Move_Object_Horizontally). The new x position is returned in A. | ||||||
| 58321 | JP Z,Limit_Eagle_Sideways_Movement | Jump to Limit_Eagle_Sideways_Movement if the new x position is less than 128. | ||||||
| 58324 | CP 208 | Jump to Handle_Carrying_Eagle_Store_X if the new x position is less than 208. | ||||||
| 58326 | JR C,Handle_Carrying_Eagle_Store_X | |||||||
| 58328 | BIT 2,E | Jump to Limit_Eagle_Sideways_Movement_Right_Gap if the room has no wall on the right. | ||||||
| 58330 | JP Z,Limit_Eagle_Sideways_Movement_Right_Gap | |||||||
| 58333 | LD A,(IX+8) | Fetch the x velocity. | ||||||
| 58336 | CPL | Invert it. | ||||||
| 58337 | LD (IX+8),A | Store the x velocity. | ||||||
| 58340 | CALL Choose_Eagle_Target | Choose a new target. | ||||||
| 58343 | LD A,207 | Set the x position to 207. | ||||||
|
This entry point is used by the routine at Limit_Eagle_Sideways_Movement.
|
||||||||
| Handle_Carrying_Eagle_Store_X | 58345 | LD (IX+1),A | Store the x position. | |||||
| 58348 | LD A,(IX+11) | Fetch the contact flags. | ||||||
| 58351 | AND %10111011 | Reset bits 2 and 6 (the right and left walls). | ||||||
| 58353 | LD (IX+11),A | Store the contact flags. | ||||||
|
Move the eagle vertically.
|
||||||||
| 58356 | LD L,(IX+9) | Fetch the y velocity into L. | ||||||
| 58359 | BIT 7,L | Test the sign of the y velocity. | ||||||
| 58361 | LD H,0 | Clear the high byte of the y velocity (as a word). | ||||||
| 58363 | JR Z,Handle_Carrying_Eagle_Move_Y | Jump to Handle_Carrying_Eagle_Move_Y if the y velocity is positive. | ||||||
| 58365 | LD H,255 | Set the high byte of the y velocity to 255 to extend the sign. | ||||||
| Handle_Carrying_Eagle_Move_Y | 58367 | CALL Move_Object_Vertically | Move the eagle vertically (see Move_Object_Vertically). The new y position is returned in A. | |||||
| 58370 | JP Z,Limit_Eagle_Vertical_Movement | Jump to Limit_Eagle_Vertical_Movement if the new y position is less than 128. | ||||||
| 58373 | CP 159 | Jump to Handle_Carrying_Eagle_Store_Y if the new y position is less than 159. | ||||||
| 58375 | JR C,Handle_Carrying_Eagle_Store_Y | |||||||
| 58377 | BIT 4,E | Jump to Limit_Eagle_Vertical_Movement_Bottom_Gap if the room has no floor. | ||||||
| 58379 | JP Z,Limit_Eagle_Vertical_Movement_Bottom_Gap | |||||||
| 58382 | LD A,(IX+9) | Fetch the y velocity. | ||||||
| 58385 | CPL | Invert it. | ||||||
| 58386 | LD (IX+9),A | Store the y velocity. | ||||||
| 58389 | CALL Choose_Eagle_Target | Choose a new target. | ||||||
| 58392 | LD A,159 | Set the y position to 159. | ||||||
|
This entry point is used by the routine at Limit_Eagle_Vertical_Movement.
|
||||||||
| Handle_Carrying_Eagle_Store_Y | 58394 | LD (IX+3),A | Store the y position. | |||||
| 58397 | JP Update_Object_Sprite | Jump to Update_Object_Sprite. | ||||||
| Prev: 57989 | Up: Map | Next: 58400 |