![]() |
Routines |
| Prev: 40408 | Up: Map | Next: 40501 |
|
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 4 of the object selects which way the slope runs. Purpose not yet known beyond this.
|
||||||||||||||||||||
| FindSlopeOverlap | 40430 | LD A,H | Fetch the vertical position of the box. | |||||||||||||||||
| 40431 | CP (IX+3) | Compare it with the lower limit of the object. | ||||||||||||||||||
| 40434 | RET C | Return if it is below. | ||||||||||||||||||
| 40435 | BIT 7,(IX+4) | Jump to FindSlopeOverlap_Reverse if bit 7 is set. | ||||||||||||||||||
| 40439 | JR NZ,FindSlopeOverlap_Reverse | |||||||||||||||||||
| 40441 | CP (IX+1) | Compare the position with the upper limit of the object. | ||||||||||||||||||
| 40444 | JR C,FindSlopeOverlap_Horizontal | Jump to FindSlopeOverlap_Horizontal if it is below. | ||||||||||||||||||
| 40446 | SUB E | Subtract the height of the box. | ||||||||||||||||||
| 40447 | CP (IX+1) | Compare it with the upper limit. | ||||||||||||||||||
| 40450 | RET NC | Return if the box is entirely above the object. | ||||||||||||||||||
| 40451 | LD H,(IX+1) | Clip the vertical position to the upper limit. | ||||||||||||||||||
| 40454 | JR FindSlopeOverlap_Horizontal | Jump to FindSlopeOverlap_Horizontal. | ||||||||||||||||||
| FindSlopeOverlap_Reverse | 40456 | SUB E | Subtract the height of the box. | |||||||||||||||||
| 40457 | LD H,A | Store it as the vertical position. | ||||||||||||||||||
| 40458 | CP (IX+1) | Compare it with the upper limit of the object. | ||||||||||||||||||
| 40461 | RET NC | Return if it is above. | ||||||||||||||||||
| 40462 | CP (IX+3) | Compare it with the lower limit of the object. | ||||||||||||||||||
| 40465 | JR NC,FindSlopeOverlap_Horizontal | Jump to FindSlopeOverlap_Horizontal if it is above. | ||||||||||||||||||
| 40467 | LD H,(IX+3) | Clip the vertical position to the lower limit. | ||||||||||||||||||
| FindSlopeOverlap_Horizontal | 40470 | LD A,L | Fetch the horizontal position of the box. | |||||||||||||||||
| 40471 | CP (IX+2) | Compare it with the horizontal limit of the object. | ||||||||||||||||||
| 40474 | JR Z,FindSlopeOverlap_Found | Jump to FindSlopeOverlap_Found if they are the same. | ||||||||||||||||||
| 40476 | RET NC | Return if the box is beyond the limit. | ||||||||||||||||||
| FindSlopeOverlap_Found | 40477 | LD A,1 | Set the result to 1. | |||||||||||||||||
| 40479 | LD (23580),A | Store it. | ||||||||||||||||||
| 40482 | LD A,(IX+1) | Fetch the upper limit of the object. | ||||||||||||||||||
| 40485 | SUB H | Subtract the vertical position to get the distance up the slope. | ||||||||||||||||||
| 40486 | LD B,A | Store it in B. | ||||||||||||||||||
| 40487 | LD A,C | Fetch the steepness of the slope. | ||||||||||||||||||
| 40488 | CP 2 | Is it 2? | ||||||||||||||||||
| 40490 | RET Z | Return if so. | ||||||||||||||||||
| 40491 | SRL B | Halve the distance. | ||||||||||||||||||
| 40493 | CP 3 | Is the steepness 3? | ||||||||||||||||||
| 40495 | RET Z | Return if so. | ||||||||||||||||||
| 40496 | SLA B | Otherwise multiply the halved distance by four. | ||||||||||||||||||
| 40498 | SLA B | |||||||||||||||||||
| 40500 | RET | Return. | ||||||||||||||||||
| Prev: 40408 | Up: Map | Next: 40501 |