Prev: 49969 Up: Map Next: 50036
49980: Save Restart Position
Used by the routine at RunFrame.
Called when the bottom two bits of the frame counter are zero. The position of the ship is saved when it is safe to restart there: that is when the row of the screen at 22465 holds only 85, or when none of the four tiles that are on the screen has anything in it other than the tile 166. The position is kept at 62970 to 62975. This is a best reading of the code.
SaveRestartPosition 49980 LD HL,22465 HL=22465.
49983 LD B,28 B=28.
SaveRestartPosition_Loop 49985 LD A,(HL) Read HL.
49986 CP 85 Jump to SaveRestartPosition_Tiles if A is not 85.
49988 JR NZ,SaveRestartPosition_Tiles
49990 INC L Advance L.
49991 DJNZ SaveRestartPosition_Loop Decrease B and jump to SaveRestartPosition_Loop until none remain.
SaveRestartPosition_Zero 49993 LD B,0 Clear B.
SaveRestartPosition_Store 49995 LD HL,(52823) Fetch the word at MapPosition into HL.
49998 LD (62970),HL Update the map column of the position that the ship restarts at.
50001 LD HL,(52805) Fetch the word at PositionAcross into HL.
50004 LD A,L A=L.
50005 OR B Set the bits of A that are set in B.
50006 LD L,A L=A.
50007 LD (62972),HL Update the position of the ship: horizontal then vertical.
50010 LD HL,(52801) Fetch the word at HorizontalOffset into HL.
50013 LD (62974),HL Update the scroll offsets: horizontal then vertical.
50016 RET Return.
SaveRestartPosition_Tiles 50017 LD HL,56465 The visible tiles.
50020 LD B,4 B=4.
SaveRestartPosition_Row 50022 LD A,(HL) Read HL.
50023 AND A Jump to SaveRestartPosition_Next if A is zero.
50024 JR Z,SaveRestartPosition_Next
50026 CP 166 Return if A is not 166.
50028 RET NZ
SaveRestartPosition_Next 50029 INC HL Advance HL.
50030 DJNZ SaveRestartPosition_Row Decrease B and jump to SaveRestartPosition_Row until none remain.
50032 LD B,1 B=1.
50034 JR SaveRestartPosition_Store Jump to SaveRestartPosition_Store.
Prev: 49969 Up: Map Next: 50036