Prev: 54029 Up: Map Next: 54156
54048: Place Player At Door
Used by the routine at BuildRoomObjects.
Puts the player in the right place when it has come into a room through an arch. The routine that moved the player out of the last room set one of its positions to 0 or 255, which tells which way the player came. The player is put at the opposite edge of the room, just outside the wall, and at the height of the arch. If the positions are not one of these, as when the player starts the game or starts again after losing a life, nothing is changed.
Input
IX Address of the player
Fetch the wall distances, then see which way the player came.
PlacePlayerAtDoor 54048 LD A,(23467) Fetch RoomSizeX.
54051 SUB 2 Subtract 2.
54053 LD L,A Copy it to L.
Fetch the size of the room in Y and take 2 off it from RoomSizeY.
54054 LD A,(23468) Fetch RoomSizeY.
54057 SUB 2 Subtract 2.
54059 LD H,A Copy it to H.
54060 LD A,(IX+1) Fetch the x position of the player.
54063 AND A Jump to PlacePlayerAtDoor_East if it is zero.
54064 JR Z,PlacePlayerAtDoor_East
54066 INC A Jump to PlacePlayerAtDoor_West if it is 255.
54067 JR Z,PlacePlayerAtDoor_West
54069 LD A,(IX+2) Fetch the y position of the player.
54072 AND A Jump to PlacePlayerAtDoor_North if it is zero.
54073 JR Z,PlacePlayerAtDoor_North
54075 INC A Jump to PlacePlayerAtDoor_South if it is 255.
54076 JR Z,PlacePlayerAtDoor_South
54078 RET Return.
The player came from the north.
PlacePlayerAtDoor_South 54079 LD C,200 Set the sum of the coordinates of the arch to look for.
54081 CALL FindDoorHeight Find the arch and set the height of the player to it.
54084 LD A,128 Set A to 128.
54086 SUB H Take the size of the room in Y off it.
54087 SUB (IX+5) Take the depth of the player off it.
PlacePlayerAtDoor_SetY 54090 LD (IX+2),A Set the y position of the player.
PlacePlayerAtDoor_Draw 54093 SET 4,(IX+7) Flag the legs of the player to be drawn.
54097 SET 4,(IX+39) Flag the top half of the player to be drawn.
Give the top half the X coordinate of the legs.
54101 LD A,(IX+1) Fetch the x position of the player.
54104 LD (IX+33),A Set the x position of the top half.
Give the top half the Y coordinate of the legs.
54107 LD A,(IX+2) Fetch the y position of the player.
54110 LD (IX+34),A Set the y position of the top half.
54113 RET Return.
The player came from the south.
PlacePlayerAtDoor_North 54114 LD C,81 Set the sum of the coordinates of the arch to look for.
54116 CALL FindDoorHeight Find the arch and set the height of the player to it.
54119 LD A,H Fetch the size of the room in Y.
54120 ADD A,128 Add 128.
54122 ADD A,(IX+5) Add the depth of the player.
54125 JR PlacePlayerAtDoor_SetY Jump to PlacePlayerAtDoor_SetY.
The player came from the east.
PlacePlayerAtDoor_West 54127 LD C,174 Set the sum of the coordinates of the arch to look for.
54129 CALL FindDoorHeight Find the arch and set the height of the player to it.
54132 LD A,128 Set A to 128.
54134 SUB L Take the size of the room in X off it.
54135 SUB (IX+4) Take the width of the player off it.
PlacePlayerAtDoor_SetX 54138 LD (IX+1),A Set the x position of the player.
54141 JR PlacePlayerAtDoor_Draw Jump to PlacePlayerAtDoor_Draw.
The player came from the west.
PlacePlayerAtDoor_East 54143 LD C,55 Set the sum of the coordinates of the arch to look for.
54145 CALL FindDoorHeight Find the arch and set the height of the player to it.
54148 LD A,L Fetch the size of the room in X.
54149 ADD A,128 Add 128.
54151 ADD A,(IX+4) Add the width of the player.
54154 JR PlacePlayerAtDoor_SetX Jump to PlacePlayerAtDoor_SetX.
View the equivalent code in;
Prev: 54029 Up: Map Next: 54156