Prev: 52469 Up: Map Next: 52587
52488: Set Up Segment
Used by the routine at DrawTerrain.
Sets up the variables for a segment of the tile, whose type is at offset 3 of the segment record. When the tile is drawn upside down the type is first changed with the table at FlipTypeTable. SetSlopeParameters then loads the three steps of the type. The routine stores a vertical step of 4 if the type has none (and so is flat), and stores the absolute values of the column and horizontal steps in ColumnStepSize and HorizontalStepSize. If the tile is upside down it moves the pixel position of a vertical segment sideways.
Input
IX Address of the segment record
SetUpSegment 52488 LD A,(23590) The upside down flag.
52491 AND A Jump to SetUpSegment_Steps if A is zero.
52492 JR Z,SetUpSegment_Steps
52494 LD E,(IX+3) Read offset 3 of IX into E.
52497 LD D,0 Clear D.
52499 LD HL,52756 The flip type table.
52502 ADD HL,DE HL gains DE.
52503 LD A,(HL) Read HL.
52504 LD (IX+3),A Write A to offset 3 of IX.
SetUpSegment_Steps 52507 CALL SetSlopeParameters Call SetSlopeParameters.
52510 LD A,(52791) The vertical step.
52513 LD (52826),A Update the vertical step copy.
52516 AND A Jump to SetUpSegment_Column if A is not zero.
52517 JR NZ,SetUpSegment_Column
52519 OR %00000100 Set the bits of A that are set in 4.
52521 LD (52826),A Update the vertical step copy.
SetUpSegment_Column 52524 LD A,(52790) The column step.
52527 LD (23588),A Update the column step size.
52530 LD A,(52789) The horizontal step.
52533 LD (52825),A Update the horizontal step copy.
52536 AND A Jump to SetUpSegment_Absolute if A is not zero.
52537 JR NZ,SetUpSegment_Absolute
52539 LD A,(58395) The slope direction.
52542 NEG Negate A.
52544 ADD A,A Double A.
52545 ADD A,A Double A.
52546 ADD A,A Double A.
52547 LD B,A B=A.
SetUpSegment_Absolute 52548 LD (23589),A Update the horizontal step size.
52551 BIT 7,A Jump to SetUpSegment_Flip if bit 7 of A is clear.
52553 JR Z,SetUpSegment_Flip
52555 NEG Negate A.
52557 LD (23589),A Update the horizontal step size.
52560 LD A,(23588) The column step size.
52563 NEG Negate A.
52565 LD (23588),A Update the column step size.
SetUpSegment_Flip 52568 LD A,(23590) The upside down flag.
52571 CP 153 Return if A is not 153.
52573 RET NZ
52574 LD A,(52825) The horizontal step copy.
52577 AND A Return if A is not zero.
52578 RET NZ
52579 LD A,(52803) The segment column.
52582 ADD A,B A gains B.
52583 LD (52803),A Update the segment column.
52586 RET Return.
Prev: 52469 Up: Map Next: 52587