Prev: C331 Up: Map Next: C374
C33C: 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 57C1 holds only 55, or when none of the four tiles that are on the screen has anything in it other than the tile A6. The position is kept at F5FA to F5FF. This is a best reading of the code.
SaveRestartPosition C33C LD HL,$57C1 HL=57C1.
C33F LD B,$1C B=1C.
SaveRestartPosition_Loop C341 LD A,(HL) Read HL.
C342 CP $55 Jump to SaveRestartPosition_Tiles if A is not 55.
C344 JR NZ,SaveRestartPosition_Tiles
C346 INC L Advance L.
C347 DJNZ SaveRestartPosition_Loop Decrease B and jump to SaveRestartPosition_Loop until none remain.
SaveRestartPosition_Zero C349 LD B,$00 Clear B.
SaveRestartPosition_Store C34B LD HL,($CE57) Fetch the word at MapPosition into HL.
C34E LD ($F5FA),HL Update the map column of the position that the ship restarts at.
C351 LD HL,($CE45) Fetch the word at PositionAcross into HL.
C354 LD A,L A=L.
C355 OR B Set the bits of A that are set in B.
C356 LD L,A L=A.
C357 LD ($F5FC),HL Update the position of the ship: horizontal then vertical.
C35A LD HL,($CE41) Fetch the word at HorizontalOffset into HL.
C35D LD ($F5FE),HL Update the scroll offsets: horizontal then vertical.
C360 RET Return.
SaveRestartPosition_Tiles C361 LD HL,$DC91 The visible tiles.
C364 LD B,$04 B=04.
SaveRestartPosition_Row C366 LD A,(HL) Read HL.
C367 AND A Jump to SaveRestartPosition_Next if A is zero.
C368 JR Z,SaveRestartPosition_Next
C36A CP $A6 Return if A is not A6.
C36C RET NZ
SaveRestartPosition_Next C36D INC HL Advance HL.
C36E DJNZ SaveRestartPosition_Row Decrease B and jump to SaveRestartPosition_Row until none remain.
C370 LD B,$01 B=01.
C372 JR SaveRestartPosition_Store Jump to SaveRestartPosition_Store.
Prev: C331 Up: Map Next: C374