Prev: BCD1 Up: Map Next: BD3B
BD04: Bounce off a 45-degree slope, swapping and negating
Used by the routine at hit_slope.
The speeds across and up are swapped, each clamped (clamp_object_speed): a reflection off a line at 45 degrees. From here both are negated on the way; from bounce_45_swap_only they are not. Which is done is decided by two JRs in this routine whose displacements are patched: 0 runs the CALL to negate_high_byte after each, 3 jumps over it.
Input
IX the box
bounce_45_negate BD04 XOR A the negations on
This entry point is used by the routine at bounce_45_swap_only.
bounce_45_negate_0 BD05 LD ($BD16),A (bounce_45_swap_only's entry) the two patched JRs' displacements
BD08 LD ($BD2B),A
BD0B LD IX,(collision_object) the record; HL = its speed across
BD0F LD H,(IX+$07)
BD12 LD L,(IX+$08)
bounce_45_negate_1 BD15 JR bounce_45_negate_1 patched: run the CALL or jump over it
BD17 CALL negate_high_byte negate the speed across
BD1A CALL clamp_object_speed clamp it; it becomes the speed up and down; HL the old one
BD1D EX DE,HL
BD1E LD H,(IX+$09)
BD21 LD L,(IX+$0A)
BD24 LD (IX+$09),D
BD27 LD (IX+$0A),E
bounce_45_negate_2 BD2A JR bounce_45_negate_2 patched: run the CALL or jump over it
BD2C CALL negate_high_byte negate it
BD2F CALL clamp_object_speed clamp it; it becomes the speed across; push the object out (leave_slope)
BD32 LD (IX+$07),H
BD35 LD (IX+$08),L
BD38 JP leave_slope
Prev: BCD1 Up: Map Next: BD3B