Prev: F15D Up: Map Next: F202
F177: Action A OUT. Go to the "out of town" screen
F177 LD A,(IY+$05) Put the X co-ordinate in A.
F17A LD HL,$06EA Set the extremities in HL.
F17D CP $80 Is the character position greater than 80?
F17F LD A,$FE Set starting position as the far right.
F181 JR C,$F188 If not, the character's moved left to here, so jump forward.
F183 LD HL,$EA06 Set the extremities in HL.
F186 LD A,$02 Set position at the far left.
F188 LD ($F158),HL Store the extremeties.
F18B LD ($F15A),A Store the current position.
F18E LD HL,$0000 Set the number of miles walked to 0. (F15B)
F191 LD ($F15B),HL
F194 LD (IY+$0A),$98 Ensure the player is on the ground.
F198 CALL $B902 Clear the playing area.
F19B LD HL,$F15D Point HL to the graphics data.
F19E CALL $B969 Draw it.
F1A1 JR $F1D2 Enter the room.
F1A3 CALL $EEA2 Initialize the sprite buffers.
F1A6 CALL $F202 Print the number of miles out of town
F1A9 LD A,$04 Touching an arrow drops the endurance by 4.
F1AB LD ($F26E),A
F1AE LD A,($F15A) Get the direction of arrows.
F1B1 CP $02 Is the direction left?
F1B3 LD A,$82 Set A to "left arrow".
F1B5 JR Z,$F1B9 Jump if the direction is left.
F1B7 LD A,$84 Set A to "right arrow".
F1B9 CALL $ED8A Set up moving objects (the movement is the same as the Laboratory).
F1BC CALL $B09F Get user input.
F1BF CALL $B0E6 Put characters in the sprite buffer.
F1C2 CALL $B9FB Put the sprites on scren.
F1C5 LD BC,($F158) Get the co-ordinate limits in BC.
F1C9 LD HL,($F15B) Put the number of miles walked in HL.
F1CC LD A,(IY+$05) Put the X co-ordinate in B.
F1CF CP B Has it reached the edge?
F1D0 JR NZ,$F1E6 Jump forward if it hasn't.
Move to a room with more miles.
F1D2 LD BC,($F158) Put the extremities in BC.
F1D6 LD HL,($F15B) Put the number of miles in HL.
F1D9 LD A,($F15A) Put the direction in C.
F1DC ADD A,C Set the X co-ordinate to the initial position.
F1DD LD (IY+$05),A
F1E0 INC HL Increment the number of miles.
F1E1 LD ($F15B),HL
F1E4 JR $F1A3 Jump back to run the room.
Move to a room with less miles.
F1E6 CP C Is the Y co-ordinate at the edge?
F1E7 JR NZ,$F1A3 Jump back if it isn't.
F1E9 DEC HL Decrement the number of miles.
F1EA LD ($F15B),HL
F1ED LD A,H Is this zero?
F1EE OR L
F1EF JR Z,$F1FC If so, jump forward as we're back in town.
F1F1 LD A,($F15A) Put the direction in A.
F1F4 LD C,A Set the X co-ordinate to the initial position.
F1F5 LD A,B
F1F6 SUB C
F1F7 LD (IY+$05),A Set the new X co-ordinate.
F1FA JR $F1A3 Jump back to run the room.
Finally found our way back to town.
F1FC LD (IY+$05),B Set the X co-ordinate as the starting point for a room with less miles.
F1FF JP $EE8D
Prev: F15D Up: Map Next: F202