Prev: 54664 Up: Map Next: 55003
54898: Locate Picture
Used by the routines at SetUpPiece and SetUpFlatPiece.
Finds the picture for the piece. The offset of the picture is looked up in the table that SegmentPictureOffsets points at, using the value in E as the index, and added to the address of the picture at PicturePointer. The stack pointer is pointed at the result, so that the drawing routines can pop the words of the picture. The routine then works out how many rows to draw. If the piece is at the bottom of the screen the rows that are below the bottom are skipped by popping their words.
Input
E Index into the table of offsets, in words
LocatePicture 54898 LD A,E A=E.
54899 EXX Switch to the alternate registers.
54900 LD HL,(52817) Fetch the word at SegmentPictureOffsets into HL.
54903 LD E,A E=A.
54904 SLA E Shift E left.
54906 LD D,0 Clear D.
54908 ADD HL,DE HL gains DE.
54909 LD E,(HL) Read HL into E.
This entry point is used by the routine at SetUpFlatPiece.
LocatePicture_Address 54910 LD HL,(52807) Fetch the word at PicturePointer into HL.
54913 ADD HL,DE HL gains DE.
54914 LD SP,HL Set the stack pointer from HL.
54915 LD A,(52800) The segment height.
54918 LD E,A E=A.
54919 LD A,(23597) The segment screen row.
54922 CP 184 Jump to AdjustPiece if A is less than 184.
54924 JP C,AdjustPiece
54927 SUB 183 Subtract 183 from A.
54929 LD B,A B=A.
54930 SRL B Shift B right.
54932 LD A,E A=E.
54933 SUB B Subtract B from A.
54934 LD E,A E=A.
54935 LD A,(23588) The column step size.
54938 LD D,A D=A.
54939 LD A,(52791) The vertical step.
54942 AND A Jump to LocatePicture_Skip if A is zero.
54943 JR Z,LocatePicture_Skip
54945 LD A,(IX+0) Read offset 0 of IX.
54948 AND %00000111 Keep the bits of A that are set in 7.
54950 JR Z,LocatePicture_Skip Jump to LocatePicture_Skip if the zero flag is set.
54952 INC D Advance D.
LocatePicture_Skip 54953 LD A,D A=D.
LocatePicture_Pop 54954 POP HL Bring HL back off the stack.
54955 DEC A Step A back.
54956 JR NZ,LocatePicture_Pop Jump to LocatePicture_Pop if the zero flag is clear.
54958 DJNZ LocatePicture_Skip Decrease B and jump to LocatePicture_Skip until none remain.
54960 LD H,87 H=87.
54962 LD A,(52809) The segment screen address.
54965 LD L,A L=A.
54966 LD A,(52790) The column step.
54969 ADD A,L A gains L.
54970 AND %00011111 Keep the bits of A that are set in 31.
54972 OR %11000000 Set the bits of A that are set in 192.
54974 LD L,A L=A.
54975 LD A,(52790) The column step.
54978 NEG Negate A.
54980 ADD A,L A gains L.
54981 LD L,A L=A.
54982 LD A,(55042) Which drawing routine was chosen.
54985 CP 11 Jump to JumpToDrawingRoutine if A is not 11.
54987 JP NZ,JumpToDrawingRoutine
54990 LD A,L A=L.
54991 CP 221 Jump to JumpToDrawingRoutine if A is less than 221.
54993 JP C,JumpToDrawingRoutine
54996 LD A,L A=L.
54997 SUB 32 Subtract 32 from A.
54999 LD L,A L=A.
55000 JP JumpToDrawingRoutine Jump to JumpToDrawingRoutine.
Prev: 54664 Up: Map Next: 55003