Prev: 54898 Up: Map Next: 55040
55003: 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 55003 LD B,A B=A.
55004 LD A,(52826) The vertical step copy.
55007 NEG Negate A.
55009 ADD A,B A gains B.
55010 SUB 24 Subtract 24 from A.
55012 JP NC,AdjustPiece_Address Jump to AdjustPiece_Address if the carry flag is clear.
55015 CPL Invert A.
55016 SRL A Shift A right.
55018 NEG Negate A.
55020 ADD A,E A gains E.
55021 LD E,A E=A.
55022 LD A,(52791) The vertical step.
55025 AND A Jump to AdjustPiece_Address if A is zero.
55026 JR Z,AdjustPiece_Address
55028 EXX Switch to the alternate registers.
55029 LD A,C A=C.
55030 CP 1 Jump to AdjustPiece_Columns if A is 1.
55032 JR Z,AdjustPiece_Columns
55034 LD C,2 C=2.
AdjustPiece_Columns 55036 EXX Switch to the alternate registers.
AdjustPiece_Address 55037 LD HL,(52809) Fetch the word at SegmentScreenAddress into HL.
Continue on to JumpToDrawingRoutine.
Prev: 54898 Up: Map Next: 55040