Prev: CA9A Up: Map Next: CB0E
CAF3: Leave Room To The East
Sends the player to the room to the east if it has gone past the east edge of the room. The x position is set to FF, which PlacePlayerAtDoor takes as the sign that the player has come out of the east and puts it at the west side of the new room.
Input
HL Distances to the walls along x and y
IX The address of the object
Leave if past the east edge.
LeaveRoomToEast CAF3 POP HL Unstack the size of the room in X and Y.
Work out the coordinate of the east edge of the room.
CAF4 LD A,L Copy L to A.
CAF5 ADD A,$80 Add 80.
CAF7 LD L,A Copy it to L.
Add the speed in X to the X coordinate, and take the width of the player off it.
CAF8 LD A,(IX+$01) Fetch the x position of the player.
CAFB ADD A,(IX+$09) Add the speed along the x axis.
CAFE SUB (IX+$04) Subtract the width of the player.
Compare it with the east edge.
CB01 CP L Return if the player is still in the room.
CB02 RET C
CB03 LD (IX+$01),$FF Write FF to the x position.
Fetch the room number and stash it in L.
CB07 LD A,(IX+$08) Fetch the room number.
CB0A LD L,A Copy it to L.
CB0B INC A Go to the room to the east.
CB0C JR ChangeRoomEastWest Jump to ChangeRoomEastWest.
View the equivalent code in;
Prev: CA9A Up: Map Next: CB0E