![]() |
Routines |
| Prev: 47132 | Up: Map | Next: 47277 |
|
Used by the routine at SlideActorPastObjects.
Tests whether an actor at a position would overlap with any object in a list. The list is made up of four byte entries. The first two bytes are the address of the graphic of the object, then the X and Y positions of the object. The list ends with an address of zero. The first two bytes of the graphic are the height in pixels and the width in bytes.
|
||||||||||||||||||||
| TestObjectOverlap | 47219 | LD L,(IX+0) | Fetch the low byte of the address of the object. | |||||||||||||||||
| 47222 | LD H,(IX+1) | Fetch the high byte of the address of the object. | ||||||||||||||||||
| 47225 | LD A,H | Combine the bytes to check for zero. | ||||||||||||||||||
| 47226 | OR L | |||||||||||||||||||
| 47227 | RET Z | Return if the address is zero (the end of the list), with the carry flag reset. | ||||||||||||||||||
| 47228 | LD A,(HL) | Fetch the height of the object in pixels. | ||||||||||||||||||
| 47229 | INC HL | Move to the width of the object. | ||||||||||||||||||
| 47230 | LD H,(HL) | Fetch the width of the object in bytes. | ||||||||||||||||||
| 47231 | LD L,A | Set the height of the object in L. | ||||||||||||||||||
| 47232 | LD A,H | Fetch the width of the object in bytes. | ||||||||||||||||||
| 47233 | RLCA | Multiply by eight. | ||||||||||||||||||
| 47234 | RLCA | |||||||||||||||||||
| 47235 | RLCA | |||||||||||||||||||
| 47236 | AND %11111000 | Keep only bits 3-7. | ||||||||||||||||||
| 47238 | LD H,A | H=the width of the object in pixels. | ||||||||||||||||||
|
Compare the X positions.
|
||||||||||||||||||||
| 47239 | LD A,E | Fetch the X position of the actor. | ||||||||||||||||||
| 47240 | SUB (IX+2) | Subtract the X position of the object. | ||||||||||||||||||
| 47243 | JP P,TestObjectOverlap_Right | Jump to TestObjectOverlap_Right if the actor is not to the left of the object. | ||||||||||||||||||
| 47246 | CPL | Flip the bits to get the distance from the object, less one. | ||||||||||||||||||
| 47247 | CP C | Compare with the width of the actor. | ||||||||||||||||||
| TestObjectOverlap_Horizontal | 47248 | JR NC,TestObjectOverlap_Next | Jump to TestObjectOverlap_Next if the actor is too far away. | |||||||||||||||||
|
Compare the Y positions.
|
||||||||||||||||||||
| 47250 | LD A,D | Fetch the Y position of the actor. | ||||||||||||||||||
| 47251 | SUB L | Subtract the height of the object. | ||||||||||||||||||
| 47252 | SUB (IX+3) | Subtract the Y position of the object. | ||||||||||||||||||
| 47255 | JP P,TestObjectOverlap_Below | Jump to TestObjectOverlap_Below if the feet of the actor are below the object. | ||||||||||||||||||
| 47258 | CPL | Flip the bits to get the distance from the object, less one. | ||||||||||||||||||
| 47259 | CP L | Compare with the height of the object. | ||||||||||||||||||
| TestObjectOverlap_Return | 47260 | RET C | Return if the actor overlaps with the object. | |||||||||||||||||
|
Move on to the next object.
|
||||||||||||||||||||
| TestObjectOverlap_Next | 47261 | INC IX | Move IX on four bytes. | |||||||||||||||||
| 47263 | INC IX | |||||||||||||||||||
| 47265 | INC IX | |||||||||||||||||||
| 47267 | INC IX | |||||||||||||||||||
| 47269 | JR TestObjectOverlap | Jump to TestObjectOverlap. | ||||||||||||||||||
|
The actor is to the right of the object so compare with the width of the object.
|
||||||||||||||||||||
| TestObjectOverlap_Right | 47271 | CP H | Compare with the width of the object. | |||||||||||||||||
| 47272 | JR TestObjectOverlap_Horizontal | Jump to TestObjectOverlap_Horizontal. | ||||||||||||||||||
|
The feet of the actor are below the object, so compare with the height of the actor.
|
||||||||||||||||||||
| TestObjectOverlap_Below | 47274 | CP B | Compare with the height of the actor. | |||||||||||||||||
| 47275 | JR TestObjectOverlap_Return | Jump to TestObjectOverlap_Return. | ||||||||||||||||||
| Prev: 47132 | Up: Map | Next: 47277 |