Prev: D672 Up: Map Next: D700
D6DB: Adjust Piece
Used by the routine at LocatePicture.
Adjusts the number of rows of a piece that is near the top of the screen so that it does not go above the top, and, for a sloped piece, limits the number of steps left in the segment to two. The screen address is loaded from SegmentScreenAddress.
Input
A Vertical position of the piece
AdjustPiece D6DB LD B,A B=A.
D6DC LD A,($CE5A) The vertical step copy.
D6DF NEG Negate A.
D6E1 ADD A,B A gains B.
D6E2 SUB $18 Subtract 18 from A.
D6E4 JP NC,AdjustPiece_Address Jump to AdjustPiece_Address if the carry flag is clear.
D6E7 CPL Invert A.
D6E8 SRL A Shift A right.
D6EA NEG Negate A.
D6EC ADD A,E A gains E.
D6ED LD E,A E=A.
D6EE LD A,($CE37) The vertical step.
D6F1 AND A Jump to AdjustPiece_Address if A is zero.
D6F2 JR Z,AdjustPiece_Address
D6F4 EXX Switch to the alternate registers.
D6F5 LD A,C A=C.
D6F6 CP $01 Jump to AdjustPiece_Columns if A is 01.
D6F8 JR Z,AdjustPiece_Columns
D6FA LD C,$02 C=02.
AdjustPiece_Columns D6FC EXX Switch to the alternate registers.
AdjustPiece_Address D6FD LD HL,($CE49) Fetch the word at SegmentScreenAddress into HL.
Continue on to JumpToDrawingRoutine.
Prev: D672 Up: Map Next: D700