Prev: 45775 Up: Map Next: 46036
45912: Move Creature Vertically
Moves a creature one step closer to Sabreman's room when it is in a different room y (and the same room x). It works like Move_Creature_Horizontally but vertically. It is entered with the carry flag set if Sabreman's room y is less than the room y of the creature.
The creature is removed if the room has a floor and it is above Sabreman's room (or a ceiling and it is below), as it cannot get through. The x position is kept between 24 and 224.
Input
IX Object record
E Flags of the room that the creature is in
Move_Creature_Vertically 45912 LD (IX+15),1 Set the redraw flags to 1 so that the creature is drawn without being erased when it arrives.
45916 LD (IX+11),0 Clear the contact flags.
45920 JR C,Move_Creature_Vertically_Move_Up Jump to Move_Creature_Vertically_Move_Up if Sabreman is above the creature.
45922 BIT 4,E Jump to Move_Creature_Horizontally_Remove_Creature if the room has a floor.
45924 JR NZ,Move_Creature_Horizontally_Remove_Creature
45926 LD A,(IX+9) Fetch the y velocity.
45929 ADD A,2 Accelerate downwards by adding two.
45931 BIT 7,A Jump to Move_Creature_Vertically_Store_Velocity if the y velocity is negative.
45933 JR NZ,Move_Creature_Vertically_Store_Velocity
45935 CP 49 Jump to Move_Creature_Vertically_Move_Down if the y velocity has reached 49.
45937 JR NC,Move_Creature_Vertically_Move_Down
Move_Creature_Vertically_Store_Velocity 45939 LD (IX+9),A Store the y velocity.
Move_Creature_Vertically_Move_Down 45942 LD A,(IX+9) Fetch the y velocity.
45945 SRA A Divide it by sixteen, keeping the sign.
45947 SRA A
45949 SRA A
45951 SRA A
45953 ADD A,(IX+3) Add the y position of the creature.
45956 CP 159 Jump to Move_Creature_Vertically_Store_Y if the y position is less than 159.
45958 JR C,Move_Creature_Vertically_Store_Y
45960 INC (IX+4) Move the creature to the room below.
45963 LD A,44 Set the y position to 44.
Move_Creature_Vertically_Store_Y 45965 LD (IX+3),A Store the y position.
Keep the x position between 24 and 224.
Move_Creature_Vertically_Adjust_X 45968 LD A,(IX+1) Fetch the x position.
45971 CP 24 Jump to Move_Creature_Vertically_Test_Right if the x position is 24 or more.
45973 JR NC,Move_Creature_Vertically_Test_Right
45975 LD (IX+1),24 Set the x position to 24.
Move_Creature_Vertically_Test_Right 45979 CP 224 Return if the x position is less than 224.
45981 RET C
45982 LD (IX+1),224 Set the x position to 224.
45986 RET Return.
Sabreman is above the creature.
Move_Creature_Vertically_Move_Up 45987 BIT 0,E Jump to Move_Creature_Horizontally_Remove_Creature if the room has a ceiling.
45989 JP NZ,Move_Creature_Horizontally_Remove_Creature
45992 LD A,(IX+9) Fetch the y velocity.
45995 SUB 2 Accelerate upwards by subtracting two.
45997 BIT 7,A Jump to Move_Creature_Vertically_Store_Up_Velocity if the y velocity is positive.
45999 JR Z,Move_Creature_Vertically_Store_Up_Velocity
46001 CP 208 Jump to Move_Creature_Vertically_Add_Up_Velocity if the y velocity is less than 208.
46003 JR C,Move_Creature_Vertically_Add_Up_Velocity
Move_Creature_Vertically_Store_Up_Velocity 46005 LD (IX+9),A Store the y velocity.
Move_Creature_Vertically_Add_Up_Velocity 46008 LD A,(IX+9) Fetch the y velocity.
46011 SRA A Divide it by sixteen, keeping the sign.
46013 SRA A
46015 SRA A
46017 SRA A
46019 ADD A,(IX+3) Add the y position of the creature.
46022 CP 64 Jump to Move_Creature_Vertically_Store_Up_Y if the y position is 64 or more.
46024 JR NC,Move_Creature_Vertically_Store_Up_Y
46026 DEC (IX+4) Move the creature to the room above.
46029 LD A,191 Set the y position to 191.
Move_Creature_Vertically_Store_Up_Y 46031 LD (IX+3),A Store the y position.
46034 JR Move_Creature_Vertically_Adjust_X Jump to Move_Creature_Vertically_Adjust_X.
Prev: 45775 Up: Map Next: 46036