![]() |
Routines |
| Prev: 46142 | Up: Map | Next: 46285 |
|
Used by the routine at Check_Decoration_Contact.
Checks whether the object at IX touches the object at IY, which is an obstacle. The bytes 10 to 14 of the obstacle record are not used for movement. Instead they describe the size of the obstacle: its half width (byte 10), the width of its middle (byte 11), its height (byte 12), the depth from the top at which the object counts as being beside it (byte 13) and the offset of the middle from its x position (byte 14). The y position of an obstacle is the position of its bottom.
The result is returned in C. Bit 2 is set if the objects touch. Bit 7 is set if IX is on the right of the middle of the obstacle. Bit 0 is set if IX is outside the width of the middle. Bit 1 is set if the bottom of IX is in the top part of the obstacle (so that it is standing or landing on it).
When the object touches the top of the obstacle, bit 4 of its contact flags is set (so it is standing on it) unless it is a weapon pickup (see Handle_Weapon_Pickup) or it is outside the width of the middle. An obstacle of type 136 is handled by Check_Rock_Formation_Contact instead.
|
||||||||||||||||
| Check_Object_Contact | 46186 | LD C,0 | Clear the contact result. | |||||||||||||
| 46188 | LD A,(IY+0) | Fetch the type of the obstacle. | ||||||||||||||
| 46191 | AND A | Return if the obstacle record is empty. | ||||||||||||||
| 46192 | RET Z | |||||||||||||||
| 46193 | BIT 0,(IY+15) | Return if the obstacle has just been created. | ||||||||||||||
| 46197 | RET NZ | |||||||||||||||
| 46198 | CP 136 | Jump to Check_Rock_Formation_Contact if the obstacle is a type 136 object. | ||||||||||||||
| 46200 | JP Z,Check_Rock_Formation_Contact | |||||||||||||||
| 46203 | LD A,(IY+1) | Fetch the x position of the obstacle. | ||||||||||||||
| 46206 | ADD A,(IY+14) | Add the offset of its middle. | ||||||||||||||
| 46209 | SUB (IX+1) | Jump to Check_Object_Contact_Test_Distance if the object is on the left of the middle of the obstacle. | ||||||||||||||
| 46212 | JP P,Check_Object_Contact_Test_Distance | |||||||||||||||
| 46215 | NEG | Make the distance positive. | ||||||||||||||
| 46217 | SET 7,C | Set bit 7 of the result, as the object is on the right. | ||||||||||||||
| Check_Object_Contact_Test_Distance | 46219 | CP (IY+10) | Jump to Check_Object_Contact_None if the distance is too great for them to touch. | |||||||||||||
| 46222 | JR NC,Check_Object_Contact_None | |||||||||||||||
| 46224 | CP (IY+11) | Jump to Check_Object_Contact_Test_Height if the object is inside the width of the middle. | ||||||||||||||
| 46227 | JR C,Check_Object_Contact_Test_Height | |||||||||||||||
| 46229 | SET 0,C | Set bit 0 of the result, as the object is outside the middle. | ||||||||||||||
| Check_Object_Contact_Test_Height | 46231 | LD A,(IY+3) | Fetch the y position of the obstacle. | |||||||||||||
| 46234 | SUB (IX+3) | Jump to Check_Object_Contact_None if the object is below the bottom of the obstacle. | ||||||||||||||
| 46237 | JP M,Check_Object_Contact_None | |||||||||||||||
| 46240 | PUSH AF | Stash the distance. | ||||||||||||||
| 46241 | LD A,(IY+3) | Work out the y position of the top of the obstacle. | ||||||||||||||
| 46244 | SUB (IY+12) | |||||||||||||||
| 46247 | SUB 160 | Subtract it from 160. | ||||||||||||||
| 46249 | NEG | |||||||||||||||
| 46251 | EX AF,AF' | Keep the result in AF'. | ||||||||||||||
| 46252 | POP AF | Restore the distance. | ||||||||||||||
| 46253 | CP (IY+12) | Jump to Check_Object_Contact_None if the distance is the height of the obstacle or more. | ||||||||||||||
| 46256 | JR NC,Check_Object_Contact_None | |||||||||||||||
| 46258 | SET 2,C | Set bit 2 of the result, as the objects touch. | ||||||||||||||
| 46260 | CP (IY+13) | Return if the distance is less than the depth in byte 13 of the obstacle. | ||||||||||||||
| 46263 | RET C | |||||||||||||||
| 46264 | SET 1,C | Set bit 1 of the result, as the object is on top of the obstacle. | ||||||||||||||
| 46266 | LD A,(IX+0) | Fetch the type of the object. | ||||||||||||||
| 46269 | AND %11111100 | Reset the two low bits. | ||||||||||||||
| 46271 | CP 104 | Return if the object is a weapon pickup. | ||||||||||||||
| 46273 | RET Z | |||||||||||||||
| 46274 | BIT 0,C | Return if the object is outside the width of the middle. | ||||||||||||||
| 46276 | RET NZ | |||||||||||||||
| 46277 | SET 4,(IX+11) | Set bit 4 of the contact flags of the object, as it is standing on the obstacle. | ||||||||||||||
| 46281 | RET | Return. | ||||||||||||||
|
This entry point is used by the routine at Check_Rock_Formation_Contact.
|
||||||||||||||||
| Check_Object_Contact_None | 46282 | LD C,0 | Clear the result, as the objects do not touch. | |||||||||||||
| 46284 | RET | Return. | ||||||||||||||
| Prev: 46142 | Up: Map | Next: 46285 |