![]() |
Routines |
| Prev: 9DD8 | Up: Map | Next: 9E35 |
|
Used by the routines at TestSlopeCollision and FindMirroredSlopeOverlap.
Part of the test for a box touching an object with a sloping face. It checks the position of the box against the vertical limits of the object and works out how far up the slope the box reaches. Bit 7 of the byte at offset 04 of the object selects which way the slope runs. Purpose not yet known beyond this.
|
||||||||||||||||||||
| FindSlopeOverlap | 9DEE | LD A,H | Fetch the vertical position of the box. | |||||||||||||||||
| 9DEF | CP (IX+$03) | Compare it with the lower limit of the object. | ||||||||||||||||||
| 9DF2 | RET C | Return if it is below. | ||||||||||||||||||
| 9DF3 | BIT 7,(IX+$04) | Jump to FindSlopeOverlap_Reverse if bit 7 is set. | ||||||||||||||||||
| 9DF7 | JR NZ,FindSlopeOverlap_Reverse | |||||||||||||||||||
| 9DF9 | CP (IX+$01) | Compare the position with the upper limit of the object. | ||||||||||||||||||
| 9DFC | JR C,FindSlopeOverlap_Horizontal | Jump to FindSlopeOverlap_Horizontal if it is below. | ||||||||||||||||||
| 9DFE | SUB E | Subtract the height of the box. | ||||||||||||||||||
| 9DFF | CP (IX+$01) | Compare it with the upper limit. | ||||||||||||||||||
| 9E02 | RET NC | Return if the box is entirely above the object. | ||||||||||||||||||
| 9E03 | LD H,(IX+$01) | Clip the vertical position to the upper limit. | ||||||||||||||||||
| 9E06 | JR FindSlopeOverlap_Horizontal | Jump to FindSlopeOverlap_Horizontal. | ||||||||||||||||||
| FindSlopeOverlap_Reverse | 9E08 | SUB E | Subtract the height of the box. | |||||||||||||||||
| 9E09 | LD H,A | Store it as the vertical position. | ||||||||||||||||||
| 9E0A | CP (IX+$01) | Compare it with the upper limit of the object. | ||||||||||||||||||
| 9E0D | RET NC | Return if it is above. | ||||||||||||||||||
| 9E0E | CP (IX+$03) | Compare it with the lower limit of the object. | ||||||||||||||||||
| 9E11 | JR NC,FindSlopeOverlap_Horizontal | Jump to FindSlopeOverlap_Horizontal if it is above. | ||||||||||||||||||
| 9E13 | LD H,(IX+$03) | Clip the vertical position to the lower limit. | ||||||||||||||||||
| FindSlopeOverlap_Horizontal | 9E16 | LD A,L | Fetch the horizontal position of the box. | |||||||||||||||||
| 9E17 | CP (IX+$02) | Compare it with the horizontal limit of the object. | ||||||||||||||||||
| 9E1A | JR Z,FindSlopeOverlap_Found | Jump to FindSlopeOverlap_Found if they are the same. | ||||||||||||||||||
| 9E1C | RET NC | Return if the box is beyond the limit. | ||||||||||||||||||
| FindSlopeOverlap_Found | 9E1D | LD A,$01 | Set the result to 01. | |||||||||||||||||
| 9E1F | LD ($5C1C),A | Store it. | ||||||||||||||||||
| 9E22 | LD A,(IX+$01) | Fetch the upper limit of the object. | ||||||||||||||||||
| 9E25 | SUB H | Subtract the vertical position to get the distance up the slope. | ||||||||||||||||||
| 9E26 | LD B,A | Store it in B. | ||||||||||||||||||
| 9E27 | LD A,C | Fetch the steepness of the slope. | ||||||||||||||||||
| 9E28 | CP $02 | Is it 02? | ||||||||||||||||||
| 9E2A | RET Z | Return if so. | ||||||||||||||||||
| 9E2B | SRL B | Halve the distance. | ||||||||||||||||||
| 9E2D | CP $03 | Is the steepness 03? | ||||||||||||||||||
| 9E2F | RET Z | Return if so. | ||||||||||||||||||
| 9E30 | SLA B | Otherwise multiply the halved distance by four. | ||||||||||||||||||
| 9E32 | SLA B | |||||||||||||||||||
| 9E34 | RET | Return. | ||||||||||||||||||
| Prev: 9DD8 | Up: Map | Next: 9E35 |