Prev: 9DEE Up: Map Next: 9E7A
9E35: Test Slope Collision
Used by the routine at CheckTerrainCollision.
Tests whether a box touches an object with a sloping face. Bits 6 and 7 of the byte at offset 04 of the object select one of four ways the slope can face, and the bottom three bits are the steepness. The result is stored in 5C1C, and when the box does touch the object the depth that it has gone into the slope is stored in 5C1A. The position of the box comes from CE3A and its size from CE3C.
Input
IX Address of the object
TestSlopeCollision 9E35 XOR A Clear the result.
9E36 LD ($5C1C),A Store it.
9E39 LD HL,($CE3A) Fetch the position of the box.
9E3C LD DE,($CE3C) Fetch the size of the box.
9E40 LD A,(IX+$04) Fetch the slope flags.
9E43 AND %00000111 Keep the steepness.
9E45 LD C,A Store it in C.
9E46 LD A,(IX+$04) Fetch the slope flags again.
9E49 AND %11000000 Keep the direction bits.
9E4B JR Z,TestSlopeCollision_Down Jump to TestSlopeCollision_Down if both are clear.
9E4D CP $40 Jump to TestSlopeCollision_Mirrored if it is the second direction.
9E4F JP Z,TestSlopeCollision_Mirrored
9E52 CP $80 Jump to TestSlopeCollision_Up if it is the third direction.
9E54 JP Z,TestSlopeCollision_Up
9E57 CP $C0 Jump to TestSlopeCollision_UpMirrored if it is the fourth direction.
9E59 JP Z,TestSlopeCollision_UpMirrored
9E5C RET Return.
TestSlopeCollision_Down 9E5D CALL FindSlopeOverlap Find the overlap with the slope.
This entry point is used by the routine at FindMirroredSlopeOverlap.
TestSlopeCollision_Depth 9E60 LD A,($5C1C) Fetch the result.
9E63 AND A Test it.
9E64 RET Z Return if the box does not overlap.
9E65 DEC A Reduce the result to zero.
9E66 LD ($5C1C),A Store it.
9E69 LD A,D Fetch the width of the box.
9E6A ADD A,L Add the horizontal position.
9E6B LD L,A Store it in L.
9E6C LD A,(IX+$00) Fetch the left edge of the object.
9E6F ADD A,B Add the distance up the slope.
9E70 SUB L Subtract the right edge of the box.
9E71 RET NC Return if the box is clear of the slope.
9E72 NEG Make the depth positive.
9E74 LD ($5C1A),A Store the depth.
9E77 JP SetOverlapFlag Jump to SetOverlapFlag to say that the box touches the slope.
Prev: 9DEE Up: Map Next: 9E7A