Prev: D588 Up: Map Next: D6DB
D672: 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 D672 LD A,E A=E.
D673 EXX Switch to the alternate registers.
D674 LD HL,($CE51) Fetch the word at SegmentPictureOffsets into HL.
D677 LD E,A E=A.
D678 SLA E Shift E left.
D67A LD D,$00 Clear D.
D67C ADD HL,DE HL gains DE.
D67D LD E,(HL) Read HL into E.
This entry point is used by the routine at SetUpFlatPiece.
LocatePicture_Address D67E LD HL,($CE47) Fetch the word at PicturePointer into HL.
D681 ADD HL,DE HL gains DE.
D682 LD SP,HL Set the stack pointer from HL.
D683 LD A,($CE40) The segment height.
D686 LD E,A E=A.
D687 LD A,($5C2D) The segment screen row.
D68A CP $B8 Jump to AdjustPiece if A is less than B8.
D68C JP C,AdjustPiece
D68F SUB $B7 Subtract B7 from A.
D691 LD B,A B=A.
D692 SRL B Shift B right.
D694 LD A,E A=E.
D695 SUB B Subtract B from A.
D696 LD E,A E=A.
D697 LD A,($5C24) The column step size.
D69A LD D,A D=A.
D69B LD A,($CE37) The vertical step.
D69E AND A Jump to LocatePicture_Skip if A is zero.
D69F JR Z,LocatePicture_Skip
D6A1 LD A,(IX+$00) Read offset 00 of IX.
D6A4 AND %00000111 Keep the bits of A that are set in 07.
D6A6 JR Z,LocatePicture_Skip Jump to LocatePicture_Skip if the zero flag is set.
D6A8 INC D Advance D.
LocatePicture_Skip D6A9 LD A,D A=D.
LocatePicture_Pop D6AA POP HL Bring HL back off the stack.
D6AB DEC A Step A back.
D6AC JR NZ,LocatePicture_Pop Jump to LocatePicture_Pop if the zero flag is clear.
D6AE DJNZ LocatePicture_Skip Decrease B and jump to LocatePicture_Skip until none remain.
D6B0 LD H,$57 H=57.
D6B2 LD A,($CE49) The segment screen address.
D6B5 LD L,A L=A.
D6B6 LD A,($CE36) The column step.
D6B9 ADD A,L A gains L.
D6BA AND %00011111 Keep the bits of A that are set in 1F.
D6BC OR %11000000 Set the bits of A that are set in C0.
D6BE LD L,A L=A.
D6BF LD A,($CE36) The column step.
D6C2 NEG Negate A.
D6C4 ADD A,L A gains L.
D6C5 LD L,A L=A.
D6C6 LD A,($D702) Which drawing routine was chosen.
D6C9 CP $0B Jump to JumpToDrawingRoutine if A is not 0B.
D6CB JP NZ,JumpToDrawingRoutine
D6CE LD A,L A=L.
D6CF CP $DD Jump to JumpToDrawingRoutine if A is less than DD.
D6D1 JP C,JumpToDrawingRoutine
D6D4 LD A,L A=L.
D6D5 SUB $20 Subtract 20 from A.
D6D7 LD L,A L=A.
D6D8 JP JumpToDrawingRoutine Jump to JumpToDrawingRoutine.
Prev: D588 Up: Map Next: D6DB