Prev: 52195 Up: Map Next: 52333
52225: 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 52225 LD A,(23307) Fetch RoomSize_X.
52228 SUB 2 Subtract 2.
52230 LD L,A Copy it to L.
52231 LD A,(23308) Fetch RoomSize_Y.
52234 SUB 2 Subtract 2.
52236 LD H,A Copy it to H.
52237 LD A,(IX+1) Fetch the x position of the player.
52240 AND A Jump to PlacePlayerAtDoor_East if it is zero.
52241 JR Z,PlacePlayerAtDoor_East
52243 INC A Jump to PlacePlayerAtDoor_West if it is 255.
52244 JR Z,PlacePlayerAtDoor_West
52246 LD A,(IX+2) Fetch the y position of the player.
52249 AND A Jump to PlacePlayerAtDoor_North if it is zero.
52250 JR Z,PlacePlayerAtDoor_North
52252 INC A Jump to PlacePlayerAtDoor_South if it is 255.
52253 JR Z,PlacePlayerAtDoor_South
52255 RET Return.
The player came from the north.
PlacePlayerAtDoor_South 52256 LD C,200 Set C to 200.
52258 CALL FindDoorHeight Call FindDoorHeight.
52261 LD A,128 Set A to 128.
52263 SUB H Subtract H.
52264 SUB (IX+5) Subtract the depth of the player.
PlacePlayerAtDoor_SetY 52267 LD (IX+2),A Set the y position of the player.
PlacePlayerAtDoor_Draw 52270 SET 4,(IX+7) Set bit 4 of the flags.
52274 SET 4,(IX+39) Set bit 4 of the flags of the top half.
52278 LD A,(IX+1) Fetch the x position of the player.
52281 LD (IX+33),A Set the x position of the top half.
52284 LD A,(IX+2) Fetch the y position of the player.
52287 LD (IX+34),A Set the y position of the top half.
52290 RET Return.
The player came from the south.
PlacePlayerAtDoor_North 52291 LD C,82 Set C to 82.
52293 CALL FindDoorHeight Call FindDoorHeight.
52296 LD A,H Fetch H.
52297 ADD A,128 Add 128.
52299 ADD A,(IX+5) Add the depth of the player.
52302 JR PlacePlayerAtDoor_SetY Jump to PlacePlayerAtDoor_SetY.
The player came from the east.
PlacePlayerAtDoor_West 52304 LD C,174 Set C to 174.
52306 CALL FindDoorHeight Call FindDoorHeight.
52309 LD A,128 Set A to 128.
52311 SUB L Subtract L.
52312 SUB (IX+4) Subtract the width of the player.
PlacePlayerAtDoor_SetX 52315 LD (IX+1),A Set the x position of the player.
52318 JR PlacePlayerAtDoor_Draw Jump to PlacePlayerAtDoor_Draw.
The player came from the west.
PlacePlayerAtDoor_East 52320 LD C,56 Set C to 56.
52322 CALL FindDoorHeight Call FindDoorHeight.
52325 LD A,L Fetch L.
52326 ADD A,128 Add 128.
52328 ADD A,(IX+4) Add the width of the player.
52331 JR PlacePlayerAtDoor_SetX Jump to PlacePlayerAtDoor_SetX.
View the equivalent code in;
Prev: 52195 Up: Map Next: 52333