Prev: 58301 Up: Map Next: 58395
58328: 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 7 or more is for a segment that is upside down: it sets UpsideDownSegment to 128 and uses the parameters of the type less seven. It then sets SlopeDirection to 1 when the second parameter is negative and to 255 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 (3 is the type)
SetSlopeParameters 58328 LD HL,58301 The slope parameters.
58331 LD A,(IX+3) Read offset 3 of IX.
58334 CP 7 Jump to SetSlopeParameters_Fetch if A is less than 7.
58336 JR C,SetSlopeParameters_Fetch
58338 LD A,128 A=128.
58340 LD (23605),A Update the upside-down segment flag.
58343 LD A,(IX+3) Read offset 3 of IX.
58346 SUB 7 Subtract 7 from A.
SetSlopeParameters_Fetch 58348 LD E,A E=A.
58349 ADD A,A Double A.
58350 ADD A,E A gains E.
58351 LD E,A E=A.
58352 LD D,0 Clear D.
58354 ADD HL,DE HL gains DE.
58355 LD A,(HL) Read HL.
58356 LD (52789),A Update the horizontal step.
58359 INC HL Advance HL.
58360 LD A,(HL) Read HL.
58361 LD (52790),A Update the column step.
58364 INC HL Advance HL.
58365 LD A,(HL) Read HL.
58366 LD (52791),A Update the vertical step.
58369 LD A,1 A=1.
58371 LD (58395),A Update the slope direction.
58374 XOR A Clear A.
58375 LD (54371),A Negate the slope step.
58378 LD A,(52790) The column step.
58381 BIT 7,A Return if bit 7 of A is set.
58383 RET NZ
58384 LD A,255 A=255.
58386 LD (58395),A Update the slope direction.
58389 LD A,2 A=2.
58391 LD (54371),A Leave the slope step as it is.
58394 RET Return.
Prev: 58301 Up: Map Next: 58395