Prev: 55514 Up: Map Next: 55673
55607: 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 55607 LD A,(52804) The segment row.
55610 LD H,A H=A.
55611 LD A,(52802) The vertical offset.
55614 ADD A,H A gains H.
55615 LD H,A H=A.
55616 LD (IX+1),A Write A to offset 1 of IX.
55619 LD (23597),A Update the segment screen row.
55622 LD A,(52803) The segment column.
55625 LD L,A L=A.
55626 LD A,(52801) The horizontal offset.
55629 ADD A,L A gains L.
55630 LD L,A L=A.
55631 LD (23596),A Update the segment screen column.
55634 LD (IX+0),A Write A to offset 0 of IX.
55637 LD D,0 Clear D.
55639 CP 240 Jump to FindSegmentAddress_Address if A is less than 240.
55641 JR C,FindSegmentAddress_Address
55643 LD D,32 D=32.
FindSegmentAddress_Address 55645 CALL GetScreenAddress Call GetScreenAddress.
55648 LD A,(23599) The flagged steps.
55651 AND A Jump to FindSegmentAddress_Count if A is not zero.
55652 JR NZ,FindSegmentAddress_Count
55654 LD A,L A=L.
55655 SUB D Subtract D from A.
55656 LD L,A L=A.
55657 LD (52815),HL Update the saved screen address.
55660 ADD A,D A gains D.
55661 LD L,A L=A.
55662 LD A,(23597) The segment screen row.
55665 LD (52819),A Update the saved row.
FindSegmentAddress_Count 55668 LD A,(52820) The steps already drawn.
55671 AND A Return if A is not zero.
55672 RET NZ
Continue on to NoteSegmentStart.
Prev: 55514 Up: Map Next: 55673