![]() |
Routines |
| Prev: 51836 | Up: Map | Next: 51950 |
|
Used by the routine at BuildRoom.
Moves the player to the doorway on the opposite side of a room to the one that it left the last room by. When the player goes through a door, TestDoorPassage sets the x or y position of the player to 0 or 255 to show which wall it went through. In the new room, the player is put in front of the door in the opposite wall, in the doorway, with the edge of the player nearest the centre of the room two units inside the wall. Nothing is done when the player is not at one of the edges, which is how a game starts.
|
||||||||
|
Fetch the wall distances, then see which way the player came.
|
||||||||
| PlacePlayerAtDoor | 51842 | LD A,(42781) | Fetch RoomSizeX. | |||||
| 51845 | SUB 2 | Subtract 2. | ||||||
| 51847 | LD L,A | Copy it to L. | ||||||
|
Fetch the distance to the walls along y and take off two.
|
||||||||
| 51848 | LD A,(42782) | Fetch RoomSizeY. | ||||||
| 51851 | SUB 2 | Subtract 2. | ||||||
| 51853 | LD H,A | Copy it to H. | ||||||
| 51854 | LD A,(IX+1) | Fetch the x position of the player. | ||||||
| 51857 | AND A | Jump to PlacePlayerAtDoor_EndOfX if the player went through the wall at the start of x. | ||||||
| 51858 | JR Z,PlacePlayerAtDoor_EndOfX | |||||||
| 51860 | INC A | Jump to PlacePlayerAtDoor_StartOfX if it went through the wall at the end of x, which is 255. | ||||||
| 51861 | JR Z,PlacePlayerAtDoor_StartOfX | |||||||
| 51863 | LD A,(IX+2) | Fetch the y position of the player. | ||||||
| 51866 | AND A | Jump to PlacePlayerAtDoor_EndOfY if the player went through the wall at the start of y. | ||||||
| 51867 | JR Z,PlacePlayerAtDoor_EndOfY | |||||||
| 51869 | INC A | Jump to PlacePlayerAtDoor_StartOfY if it went through the wall at the end of y, which is 255. | ||||||
| 51870 | JR Z,PlacePlayerAtDoor_StartOfY | |||||||
| 51872 | RET | Return. | ||||||
|
The player came from the north.
|
||||||||
| PlacePlayerAtDoor_StartOfY | 51873 | LD C,3 | Set the wall to look for a door in, which is at the start of y. | |||||
| 51875 | CALL FindDoor | Call FindDoor to find the door and put the player in front of it. | ||||||
| 51878 | LD A,128 | Set the position of the wall at the start of y, which is the centre of the room. | ||||||
| 51880 | SUB H | Subtract the distance to the walls less two... | ||||||
| 51881 | SUB (IX+5) | ...and the half size of the player along y, which puts the edge of the player nearest the centre of the room two units inside the wall. | ||||||
| PlacePlayerAtDoor_SetPlayerY | 51884 | LD (IX+2),A | Store it as the y position of the player. | |||||
|
Mark the player to be drawn.
|
||||||||
| PlacePlayerAtDoor_MarkPlayerForDrawing | 51887 | SET 4,(IX+7) | Set bit 4 of the flags. | |||||
| 51891 | SET 4,(IX+39) | Set bit 4 of the flags of the top half. | ||||||
|
Copy the x position of the player to the body.
|
||||||||
| 51895 | LD A,(IX+1) | Fetch the x position of the player. | ||||||
| 51898 | LD (IX+33),A | Set the x position of the top half. | ||||||
|
Copy the y position of the player to the body.
|
||||||||
| 51901 | LD A,(IX+2) | Fetch the y position of the player. | ||||||
| 51904 | LD (IX+34),A | Set the y position of the top half. | ||||||
| 51907 | RET | Return. | ||||||
|
The player came from the south.
|
||||||||
| PlacePlayerAtDoor_EndOfY | 51908 | LD C,2 | Set the wall to look for a door in, which is at the end of y. | |||||
| 51910 | CALL FindDoor | Call FindDoor to find the door and put the player in front of it. | ||||||
| 51913 | LD A,H | Fetch the distance to the walls less two. | ||||||
| 51914 | ADD A,128 | Add the position of the centre of the room... | ||||||
| 51916 | ADD A,(IX+5) | ...and the half size of the player along y. | ||||||
| 51919 | JR PlacePlayerAtDoor_SetPlayerY | Jump to PlacePlayerAtDoor_SetPlayerY to store it. | ||||||
|
The player came from the east.
|
||||||||
| PlacePlayerAtDoor_StartOfX | 51921 | LD C,1 | Set the wall to look for a door in, which is at the start of x. | |||||
| 51923 | CALL FindDoor | Call FindDoor to find the door and put the player in front of it. | ||||||
| 51926 | LD A,128 | Set the position of the wall at the start of x, which is the centre of the room. | ||||||
| 51928 | SUB L | Subtract the distance to the walls less two... | ||||||
| 51929 | SUB (IX+4) | ...and the half size of the player along x, which puts the edge of the player nearest the centre of the room two units inside the wall. | ||||||
| PlacePlayerAtDoor_SetPlayerX | 51932 | LD (IX+1),A | Store it as the x position of the player. | |||||
| 51935 | JR PlacePlayerAtDoor_MarkPlayerForDrawing | Jump to PlacePlayerAtDoor_MarkPlayerForDrawing to finish. | ||||||
|
The player came from the west.
|
||||||||
| PlacePlayerAtDoor_EndOfX | 51937 | LD C,0 | Set the wall to look for a door in, which is at the end of x. | |||||
| 51939 | CALL FindDoor | Call FindDoor to find the door and put the player in front of it. | ||||||
| 51942 | LD A,L | Fetch the distance to the walls less two. | ||||||
| 51943 | ADD A,128 | Add the position of the centre of the room... | ||||||
| 51945 | ADD A,(IX+4) | ...and the half size of the player along x. | ||||||
| 51948 | JR PlacePlayerAtDoor_SetPlayerX | Jump to PlacePlayerAtDoor_SetPlayerX to store it. | ||||||
|
View the equivalent code in;
|
||||||||
| Prev: 51836 | Up: Map | Next: 51950 |