Prev: D30D Up: Map Next: D38C
D320: 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 00 or FF, 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 D320 LD A,($5BAB) Fetch RoomSizeX.
D323 SUB $02 Subtract 02.
D325 LD L,A Copy it to L.
Fetch the size of the room in Y and take 02 off it from RoomSizeY.
D326 LD A,($5BAC) Fetch RoomSizeY.
D329 SUB $02 Subtract 02.
D32B LD H,A Copy it to H.
D32C LD A,(IX+$01) Fetch the x position of the player.
D32F AND A Jump to PlacePlayerAtDoor_East if it is zero.
D330 JR Z,PlacePlayerAtDoor_East
D332 INC A Jump to PlacePlayerAtDoor_West if it is FF.
D333 JR Z,PlacePlayerAtDoor_West
D335 LD A,(IX+$02) Fetch the y position of the player.
D338 AND A Jump to PlacePlayerAtDoor_North if it is zero.
D339 JR Z,PlacePlayerAtDoor_North
D33B INC A Jump to PlacePlayerAtDoor_South if it is FF.
D33C JR Z,PlacePlayerAtDoor_South
D33E RET Return.
The player came from the north.
PlacePlayerAtDoor_South D33F LD C,$C8 Set the sum of the coordinates of the arch to look for.
D341 CALL FindDoorHeight Find the arch and set the height of the player to it.
D344 LD A,$80 Set A to 80.
D346 SUB H Take the size of the room in Y off it.
D347 SUB (IX+$05) Take the depth of the player off it.
PlacePlayerAtDoor_SetY D34A LD (IX+$02),A Set the y position of the player.
PlacePlayerAtDoor_Draw D34D SET 4,(IX+$07) Flag the legs of the player to be drawn.
D351 SET 4,(IX+$27) Flag the top half of the player to be drawn.
Give the top half the X coordinate of the legs.
D355 LD A,(IX+$01) Fetch the x position of the player.
D358 LD (IX+$21),A Set the x position of the top half.
Give the top half the Y coordinate of the legs.
D35B LD A,(IX+$02) Fetch the y position of the player.
D35E LD (IX+$22),A Set the y position of the top half.
D361 RET Return.
The player came from the south.
PlacePlayerAtDoor_North D362 LD C,$51 Set the sum of the coordinates of the arch to look for.
D364 CALL FindDoorHeight Find the arch and set the height of the player to it.
D367 LD A,H Fetch the size of the room in Y.
D368 ADD A,$80 Add 80.
D36A ADD A,(IX+$05) Add the depth of the player.
D36D JR PlacePlayerAtDoor_SetY Jump to PlacePlayerAtDoor_SetY.
The player came from the east.
PlacePlayerAtDoor_West D36F LD C,$AE Set the sum of the coordinates of the arch to look for.
D371 CALL FindDoorHeight Find the arch and set the height of the player to it.
D374 LD A,$80 Set A to 80.
D376 SUB L Take the size of the room in X off it.
D377 SUB (IX+$04) Take the width of the player off it.
PlacePlayerAtDoor_SetX D37A LD (IX+$01),A Set the x position of the player.
D37D JR PlacePlayerAtDoor_Draw Jump to PlacePlayerAtDoor_Draw.
The player came from the west.
PlacePlayerAtDoor_East D37F LD C,$37 Set the sum of the coordinates of the arch to look for.
D381 CALL FindDoorHeight Find the arch and set the height of the player to it.
D384 LD A,L Fetch the size of the room in X.
D385 ADD A,$80 Add 80.
D387 ADD A,(IX+$04) Add the width of the player.
D38A JR PlacePlayerAtDoor_SetX Jump to PlacePlayerAtDoor_SetX.
View the equivalent code in;
Prev: D30D Up: Map Next: D38C