Prev: CA7F Up: Map Next: CAEE
CA82: Put the player in the doorway he came in by
Used by the routine at ENTER_ROOM.
Called when a room has been built. A U or V of 0 or $FF is the marker an exit (EXIT_LOW_U to EXIT_LOW_V) left: 0 in U means he left through a wall at low U and comes in by this room's wall at high U, $FF the other way, and the same for V. He is put with his inner edge 2 inside the wall's line, the rest of him in the doorway, and the walk into a room brings him in. FIND_ENTRY_ARCH finds the arch in that wall and lines him up with its middle and its floor. Without a marker -- a new game, or a life lost where one began -- he stays where his record says.
Knight Lore does the same with the same markers; the walls are where the room's size (ROOM_SIZES) puts them, so the doorway's place is worked out from ROOM_EXTENT.
Input
IX The player's legs
ADJUST_PLYR_UVZ_FOR_ROOM_SIZE CA82 LD A,(ROOM_EXTENT) L, H = the room's half-sizes in U and V, less 2
CA85 SUB $02
CA87 LD L,A
CA88 LD A,($A71E)
CA8B SUB $02
CA8D LD H,A
CA8E LD A,(IX+$01) U 0: came in at high U
CA91 AND A
CA92 JR Z,ADJUST_PLYR_UVZ_FOR_ROOM_SIZE_6
CA94 INC A U $FF: came in at low U
CA95 JR Z,ADJUST_PLYR_UVZ_FOR_ROOM_SIZE_4
CA97 LD A,(IX+$02) V 0: came in at high V
CA9A AND A
CA9B JR Z,ADJUST_PLYR_UVZ_FOR_ROOM_SIZE_3
CA9D INC A V $FF: came in at low V; otherwise nothing to do
CA9E JR Z,ADJUST_PLYR_UVZ_FOR_ROOM_SIZE_0
CAA0 RET
ADJUST_PLYR_UVZ_FOR_ROOM_SIZE_0 CAA1 LD C,$03 At low V: the arch there, and V puts his inner edge 2 inside the wall
CAA3 CALL FIND_ENTRY_ARCH
CAA6 LD A,$80
CAA8 SUB H
CAA9 SUB (IX+$05)
ADJUST_PLYR_UVZ_FOR_ROOM_SIZE_1 CAAC LD (IX+$02),A Store V
ADJUST_PLYR_UVZ_FOR_ROOM_SIZE_2 CAAF SET 4,(IX+$07) Draw both of his records
CAB3 SET 4,(IX+$27)
CAB7 LD A,(IX+$01) The body at the same U and V
CABA LD (IX+$21),A
CABD LD A,(IX+$02)
CAC0 LD (IX+$22),A
CAC3 RET
ADJUST_PLYR_UVZ_FOR_ROOM_SIZE_3 CAC4 LD C,$02 At high V
CAC6 CALL FIND_ENTRY_ARCH
CAC9 LD A,H
CACA ADD A,$80
CACC ADD A,(IX+$05)
CACF JR ADJUST_PLYR_UVZ_FOR_ROOM_SIZE_1
ADJUST_PLYR_UVZ_FOR_ROOM_SIZE_4 CAD1 LD C,$01 At low U
CAD3 CALL FIND_ENTRY_ARCH
CAD6 LD A,$80
CAD8 SUB L
CAD9 SUB (IX+$04)
ADJUST_PLYR_UVZ_FOR_ROOM_SIZE_5 CADC LD (IX+$01),A Store U
CADF JR ADJUST_PLYR_UVZ_FOR_ROOM_SIZE_2
ADJUST_PLYR_UVZ_FOR_ROOM_SIZE_6 CAE1 LD C,$00 At high U
CAE3 CALL FIND_ENTRY_ARCH
CAE6 LD A,L
CAE7 ADD A,$80
CAE9 ADD A,(IX+$04)
CAEC JR ADJUST_PLYR_UVZ_FOR_ROOM_SIZE_5
Prev: CA7F Up: Map Next: CAEE