Prev: D8DA Up: Map Next: D979
D937: Find Segment Address
Used by the routines at NoteWallContact and SetUpPiece.
Finds the screen address of the start of the current segment from its pixel position in SegmentColumn and SegmentRow and the offsets in HorizontalOffset and VerticalOffset. The pixel position is stored in the drawing record at ScrollWorld_Record and in SegmentScreenColumn and SegmentScreenRow. If no step of the segment has been flagged (FlaggedSteps is zero) the address is also stored in SavedScreenAddress with the pixel row in SavedRow.
Input
IX Address of the drawing record at ScrollWorld_Record
Output
HL Screen address
FindSegmentAddress D937 LD A,($CE44) The segment row.
D93A LD H,A H=A.
D93B LD A,($CE42) The vertical offset.
D93E ADD A,H A gains H.
D93F LD H,A H=A.
D940 LD (IX+$01),A Write A to offset 01 of IX.
D943 LD ($5C2D),A Update the segment screen row.
D946 LD A,($CE43) The segment column.
D949 LD L,A L=A.
D94A LD A,($CE41) The horizontal offset.
D94D ADD A,L A gains L.
D94E LD L,A L=A.
D94F LD ($5C2C),A Update the segment screen column.
D952 LD (IX+$00),A Write A to offset 00 of IX.
D955 LD D,$00 Clear D.
D957 CP $F0 Jump to FindSegmentAddress_Address if A is less than F0.
D959 JR C,FindSegmentAddress_Address
D95B LD D,$20 D=20.
FindSegmentAddress_Address D95D CALL GetScreenAddress Call GetScreenAddress.
D960 LD A,($5C2F) The flagged steps.
D963 AND A Jump to FindSegmentAddress_Count if A is not zero.
D964 JR NZ,FindSegmentAddress_Count
D966 LD A,L A=L.
D967 SUB D Subtract D from A.
D968 LD L,A L=A.
D969 LD ($CE4F),HL Update the saved screen address.
D96C ADD A,D A gains D.
D96D LD L,A L=A.
D96E LD A,($5C2D) The segment screen row.
D971 LD ($CE53),A Update the saved row.
FindSegmentAddress_Count D974 LD A,($CE54) The steps already drawn.
D977 AND A Return if A is not zero.
D978 RET NZ
Continue on to NoteSegmentStart.
Prev: D8DA Up: Map Next: D979