Prev: E3BD Up: Map Next: E41B
E3D8: Set Slope Parameters
Used by the routines at SetUpSegment and ReadSegmentShapes.
Looks up the three parameters of the type of the current segment in the table at SlopeParameters and stores them in the variables at HorizontalStep. A type of 07 or more is for a segment that is upside down: it sets UpsideDownSegment to 80 and uses the parameters of the type less seven. It then sets SlopeDirection to 01 when the second parameter is negative and to FF when it is not, and in the second case changes the JR instruction at SetUpPiece_Patched to skip two bytes.
Input
IX Address of the record of the segment (03 is the type)
SetSlopeParameters E3D8 LD HL,$E3BD The slope parameters.
E3DB LD A,(IX+$03) Read offset 03 of IX.
E3DE CP $07 Jump to SetSlopeParameters_Fetch if A is less than 07.
E3E0 JR C,SetSlopeParameters_Fetch
E3E2 LD A,$80 A=80.
E3E4 LD ($5C35),A Update the upside-down segment flag.
E3E7 LD A,(IX+$03) Read offset 03 of IX.
E3EA SUB $07 Subtract 07 from A.
SetSlopeParameters_Fetch E3EC LD E,A E=A.
E3ED ADD A,A Double A.
E3EE ADD A,E A gains E.
E3EF LD E,A E=A.
E3F0 LD D,$00 Clear D.
E3F2 ADD HL,DE HL gains DE.
E3F3 LD A,(HL) Read HL.
E3F4 LD ($CE35),A Update the horizontal step.
E3F7 INC HL Advance HL.
E3F8 LD A,(HL) Read HL.
E3F9 LD ($CE36),A Update the column step.
E3FC INC HL Advance HL.
E3FD LD A,(HL) Read HL.
E3FE LD ($CE37),A Update the vertical step.
E401 LD A,$01 A=01.
E403 LD ($E41B),A Update the slope direction.
E406 XOR A Clear A.
E407 LD ($D463),A Negate the slope step.
E40A LD A,($CE36) The column step.
E40D BIT 7,A Return if bit 7 of A is set.
E40F RET NZ
E410 LD A,$FF A=FF.
E412 LD ($E41B),A Update the slope direction.
E415 LD A,$02 A=02.
E417 LD ($D463),A Leave the slope step as it is.
E41A RET Return.
Prev: E3BD Up: Map Next: E41B