Prev: 9DD8 Up: Map Next: 9E35
9DEE: Test an object against a sloping landscape edge
Used by the landscape tests (test_landscape_piece and those after it). IX is a landscape piece's collision record: +0 and +2 its x range, +1 and +3 its bottom and top lines, +4 flags (bits 0-2 the steepness, bit 7 which way up). The object's box: x in L, bottom line in H, width D, height E (test_landscape_piece). When the line ranges meet, works out how far the object reaches into the slope at that line: B is the depth of that line under the slope's high edge, scaled by the steepness (2 as it is, 3 halved, others doubled). scratch_count is 1 if the object is in the piece's x range.
Input
IX The piece's collision record
Output
B The slope's offset at the object's line
test_slope 9DEE LD A,H Above the piece: nothing
9DEF CP (IX+$03)
9DF2 RET C
9DF3 BIT 7,(IX+$04) Which way up
9DF7 JR NZ,test_slope_0
9DF9 CP (IX+$01) The object's lowest line within the piece
9DFC JR C,test_slope_1
9DFE SUB E
9DFF CP (IX+$01)
9E02 RET NC
9E03 LD H,(IX+$01)
9E06 JR test_slope_1
test_slope_0 9E08 SUB E Upside down: its highest
9E09 LD H,A
9E0A CP (IX+$01)
9E0D RET NC
9E0E CP (IX+$03)
9E11 JR NC,test_slope_1
9E13 LD H,(IX+$03)
test_slope_1 9E16 LD A,L Within the piece's x range?
9E17 CP (IX+$02)
9E1A JR Z,test_slope_2
9E1C RET NC
test_slope_2 9E1D LD A,$01 Yes
9E1F LD (scratch_count),A
9E22 LD A,(IX+$01) The depth, scaled by the steepness
9E25 SUB H
9E26 LD B,A
9E27 LD A,C
9E28 CP $02
9E2A RET Z
9E2B SRL B
9E2D CP $03
9E2F RET Z
9E30 SLA B
9E32 SLA B
9E34 RET
Prev: 9DD8 Up: Map Next: 9E35