Prev: 8303 Up: Map Next: 838B
8347: Adjust Terrain Slope
Used by the routine at DrawVerticalEdge.
Works out how much to adjust the drawing of a terrain tile when it is next to a sloping tile. The tile codes 90 to 93 are the four slope tiles; the codes of the two tiles under consideration are held at StartShape and EndShape.
Input
E Direction flag set by the caller
IX Address of the object
Output
C Number of extra rows to draw
L Adjusted vertical position
AdjustTerrainSlope 8347 LD A,(IX+$01) Fetch the map column of the object.
834A AND A Test it.
834B RET Z Return if it is zero.
834C LD HL,($5C33) Fetch the two tile codes from StartShape into HL.
834F LD BC,$0000 Clear the adjustment (B) and the extra row count (C).
8352 CALL AdjustTerrainSlope_First Check the first tile code.
8355 CALL AdjustTerrainSlope_Second Check the second tile code.
Slope tile 91 can add an extra row.
8358 LD A,L Fetch the first tile code.
8359 CP $91 Jump to AdjustTerrainSlope_Tile93 if it is not slope tile 91.
835B JR NZ,AdjustTerrainSlope_Tile93
835D BIT 7,H Jump to AdjustTerrainSlope_Tile93 if the second tile code is a special tile (bit 7 is set).
835F JR NZ,AdjustTerrainSlope_Tile93
8361 LD A,E Fetch the direction flag.
8362 AND A Test it and jump to AdjustTerrainSlope_Tile93 if it is set.
8363 JR NZ,AdjustTerrainSlope_Tile93
8365 INC C Add an extra row.
Slope tile 93 can add an extra row too.
AdjustTerrainSlope_Tile93 8366 LD A,L Fetch the first tile code.
8367 CP $93 Jump to AdjustTerrainSlope_Return if it is not slope tile 93.
8369 JR NZ,AdjustTerrainSlope_Return
836B LD A,($CCBB) Fetch the scroll speed from HorizontalSpeed.
836E AND A Test it.
836F JR NZ,AdjustTerrainSlope_AddRow Jump to AdjustTerrainSlope_AddRow if the screen is scrolling.
8371 LD A,($BA8D) Fetch the vertical position from BA8D.
8374 AND %00000111 Test the bottom three bits.
8376 JR Z,AdjustTerrainSlope_Return Jump to AdjustTerrainSlope_Return if they are all zero.
AdjustTerrainSlope_AddRow 8378 LD A,E Fetch the direction flag.
8379 AND A Test it.
837A JR NZ,AdjustTerrainSlope_Return Jump to AdjustTerrainSlope_Return if it is set.
837C INC C Add an extra row.
Return the adjusted vertical position and the extra row count.
AdjustTerrainSlope_Return 837D LD HL,($BA8D) Fetch the position from BA8D into HL.
8380 LD A,L Add the adjustment in B to the low byte of the position.
8381 ADD A,B
8382 LD L,A
8383 LD A,$00 Clear A, then add the extra row count to it.
8385 ADD A,C
8386 LD C,A Copy the extra row count back into C.
8387 LD ($5C24),A Store the extra row count in ColumnStepSize.
838A RET Return.
Prev: 8303 Up: Map Next: 838B