Prev: BD3F Up: Map Next: BDBD
BD44: Bounce off a slope that is not 45 degrees
Used by the routine at hit_slope.
The new speeds are a mix of the old: across = 3/8 across + 3/8 up and down, up and down = -3/4 up and down + 3/4 across, the terms from the other speed negated or not (slope_negate) as two JRs in this routine decide: their displacements are patched to 0 to run the CALL after each (from here) or to 3 to jump over it (from bounce_shallow). For kind 3 slopes the speeds are swapped before and after (swap_speeds), which mirrors the mix about the diagonal: the same rule serves the steep slopes and the shallow. Each result is clamped (clamp_object_speed). The factors shrink the speed, so a bounce loses energy.
Input
IX the box
bounce_shallow_negate BD44 XOR A the negations on
BD45 LD ($BD85),A
BD48 LD ($BD74),A
This entry point is used by the routine at bounce_shallow.
bounce_shallow_negate_0 BD4B LD A,(IX+$04) (bounce_shallow's entry) the box's kind in C; kind 3: swap the speeds first
BD4E LD C,A
BD4F AND $07
BD51 PUSH AF
BD52 LD IX,(collision_object)
BD56 CP $03
BD58 CALL Z,swap_speeds
BD5B LD H,(IX+$07) 3/8 of the speed across, kept for later
BD5E LD L,(IX+$08)
BD61 CALL three_eighths
BD64 LD (saved_step_x),HL
BD67 LD H,(IX+$07) 3/4 of it
BD6A LD L,(IX+$08)
BD6D CALL double_hl
BD70 CALL three_eighths
bounce_shallow_negate_1 BD73 JR bounce_shallow_negate_1 patched: run the CALL or jump over it
BD75 CALL slope_negate negate it
BD78 LD (saved_step_y),HL keep it; 3/8 of the speed up and down
BD7B LD H,(IX+$09)
BD7E LD L,(IX+$0A)
BD81 CALL three_eighths
bounce_shallow_negate_2 BD84 JR bounce_shallow_negate_2 patched: run the CALL or jump over it
BD86 CALL slope_negate negate it
BD89 LD DE,(saved_step_x) across: plus the 3/8 across, clamped
BD8D ADD HL,DE
BD8E CALL clamp_object_speed
BD91 LD (IX+$07),H
BD94 LD (IX+$08),L
BD97 LD H,(IX+$09) up and down: 3/4 of it negated, plus the 3/4 across, clamped
BD9A LD L,(IX+$0A)
BD9D CALL double_hl
BDA0 CALL three_eighths
BDA3 CALL slope_negate
BDA6 LD DE,(saved_step_y)
BDAA ADD HL,DE
BDAB CALL clamp_object_speed
BDAE LD (IX+$09),H
BDB1 LD (IX+$0A),L
BDB4 POP AF kind 3: swap back; push the object out (leave_slope)
BDB5 CP $03
BDB7 CALL Z,swap_speeds
BDBA JP leave_slope
Prev: BD3F Up: Map Next: BDBD