Prev: C38F Up: Map Next: C3F0
C397: Out through the wall at low U?
Out if the robot's far edge after this turn's move -- U plus the step plus his half-size -- is below the wall at 128 less the room's U half-size. U is then set to 0: not a position but a marker, which ADJUST_PLYR_UVZ_FOR_ROOM_SIZE sees when the next room is built and puts him in the doorway of its wall at high U. The other exits use $FF and 0 the same way. The new room is the one before in the same row: room numbers are a row in the high four bits and a column in the low four, and the column is changed on its own so that it wraps within the row.
EXIT_SCREEN is the way on for all four. It gives the legs the new room and starts the walk into it: 4 in bits 4-7 of +$0C, four turns of walking straight on with the controls and the walls ignored (Knight Lore's is three). For anything but the robot -- graphics 16 to 79 -- it returns, but only he gets here. For him the rest of the turn is abandoned: the returns into MOVE_PLAYER and to the legs' update are dropped, and both his records are copied to the start records (START_LEGS), so that a life lost in the new room starts again at this doorway. In the copies the graphic is moved to +$10 and replaced by 56, the first of the appearing robot's (PLAYER_APPEARING). Then the new room is built and the main loop starts over (AFTER_GAME).
Input
IX the legs' record
HL the room's half-sizes (pushed by HANDLE_EXIT_SCREEN)
EXIT_LOW_U C397 POP HL L = the wall
C398 LD A,$80
C39A SUB L
C39B LD L,A
C39C LD A,(IX+$01) U + dU + half-size still at or beyond it: stay
C39F ADD A,(IX+$09)
C3A2 ADD A,(IX+$04)
C3A5 CP L
C3A6 RET NC
C3A7 LD (IX+$01),$00 Arrive at the wall at high U
C3AB LD A,(IX+$08) Room - 1...
C3AE LD L,A
C3AF DEC A
This entry point is used by the routine at EXIT_HIGH_U.
EXIT_WITHIN_ROW C3B0 AND $0F ...the new column with the old row
C3B2 LD H,A
C3B3 LD A,L
C3B4 AND $F0
C3B6 OR H
This entry point is used by the routines at EXIT_HIGH_V and EXIT_LOW_V.
EXIT_SCREEN C3B7 LD (IX+$08),A The new room
C3BA LD A,(IX+$0C) The walk into the room: four turns
C3BD OR $40
C3BF LD (IX+$0C),A
C3C2 LD A,(IX+$00) Anything but the robot: carry on
C3C5 SUB $10
C3C7 CP $40
C3C9 RET NC
C3CA INC SP Drop the returns into MOVE_PLAYER and to the legs' update
C3CB INC SP
C3CC INC SP
C3CD INC SP
C3CE PUSH IX Both his records to the start records
C3D0 POP HL
C3D1 LD DE,START_LEGS
C3D4 LD BC,$0040
C3D7 LDIR
C3D9 LD A,(START_LEGS) Each copy's graphic kept in its +$10...
C3DC LD (START_LEGS_NEXT),A
C3DF LD A,(START_TOP)
C3E2 LD (START_TOP_NEXT),A
C3E5 LD A,$38 ...and replaced by the appearing robot's first
C3E7 LD (START_LEGS),A
C3EA LD (START_TOP),A
C3ED JP MAIN_NEW_ROOM Build the new room and start its turns
Prev: C38F Up: Map Next: C3F0