![]() |
Routines |
| Prev: 47124 | Up: Map | Next: 47219 |
|
Used by the routines at ChoosePosition, HandlerFlame, HandlerHippoWarthog, HandlerChasingNastie, HandlerWanderingNastie, HandlerWulf, HandlerFlyingSabreman, HandlerTribesman, HandlerRhino, PlayerMovement and GamePlay_Start.
Stops an actor moving through the objects of the room. The new position of the actor is tested with TestObjectOverlap against each of the objects in the layout of the room (the pointers to the layouts are in RoomTable, found from the room with Layout). If it overlaps with an object then the movement is tried in the X direction only and the Y direction only so that the actor can slide along the object. If neither works then the actor is left where it was.
The Y position of an actor is the position of its feet, and the Y position of an object is the top of it.
|
||||||||||||||||||
| SlideActorPastObjects | 47132 | PUSH IX | Stash the actor record and the size of the actor on the stack. | |||||||||||||||
| 47134 | PUSH BC | |||||||||||||||||
| 47135 | LD L,(IX+3) | Fetch the X position of the actor. | ||||||||||||||||
| 47138 | LD H,(IX+4) | Fetch the Y position of the actor. | ||||||||||||||||
| 47141 | LD (38574),HL | Remember the old X position in Actor_Old_X_Position and the old Y position in Actor_Old_Y_Position. | ||||||||||||||||
| 47144 | LD L,(IX+1) | Fetch the room of the actor. | ||||||||||||||||
| 47147 | LD H,0 | Clear H. | ||||||||||||||||
| 47149 | LD BC,24678 | Add the layout table at Layout to find the layout number of the room. | ||||||||||||||||
| 47152 | ADD HL,BC | |||||||||||||||||
| 47153 | LD L,(HL) | Fetch the layout number of the room. | ||||||||||||||||
| 47154 | LD H,0 | Clear H. | ||||||||||||||||
| 47156 | ADD HL,HL | Double it, as each pointer is two bytes. | ||||||||||||||||
| 47157 | LD BC,24934 | Add the table of object lists at RoomTable to find the pointer to the list of objects. | ||||||||||||||||
| 47160 | ADD HL,BC | |||||||||||||||||
| 47161 | LD A,(HL) | Fetch the low byte of the address of the list of objects. | ||||||||||||||||
| 47162 | INC HL | Move to the high byte. | ||||||||||||||||
| 47163 | LD H,(HL) | Fetch the high byte of the address of the list of objects. | ||||||||||||||||
| 47164 | LD L,A | Combine the low byte with the high byte. | ||||||||||||||||
| 47165 | PUSH HL | Point IX at the list of objects. | ||||||||||||||||
| 47166 | POP IX | |||||||||||||||||
| 47168 | POP BC | Restore the size of the actor from the stack. | ||||||||||||||||
|
Test the new position.
|
||||||||||||||||||
| 47169 | PUSH IX | Stash the pointer to the list of objects on the stack. | ||||||||||||||||
| 47171 | CALL TestObjectOverlap | Test whether the new position overlaps with an object. | ||||||||||||||||
| 47174 | POP IX | Restore the pointer to the list of objects from the stack. | ||||||||||||||||
| 47176 | JR NC,SlideActorPastObjects_Return | Jump to SlideActorPastObjects_Return if the new position does not overlap with an object. | ||||||||||||||||
|
Try moving in the X direction only.
|
||||||||||||||||||
| 47178 | PUSH DE | Stash the new position on the stack. | ||||||||||||||||
| 47179 | LD A,(38575) | Fetch the old Y position. | ||||||||||||||||
| 47182 | LD D,A | Use the old Y position instead. | ||||||||||||||||
| 47183 | PUSH IX | Stash the pointer to the list of objects on the stack. | ||||||||||||||||
| 47185 | CALL TestObjectOverlap | Test whether moving in the X direction only overlaps with an object. | ||||||||||||||||
| 47188 | POP IX | Restore the pointer to the list of objects from the stack. | ||||||||||||||||
| 47190 | POP DE | Restore the new position from the stack. | ||||||||||||||||
| 47191 | JR NC,SlideActorPastObjects_Vertical | Jump to SlideActorPastObjects_Vertical if the actor can move in the X direction. | ||||||||||||||||
| 47193 | LD A,(38574) | Keep the old X position, as the actor cannot move in the X direction. | ||||||||||||||||
| 47196 | LD E,A | |||||||||||||||||
|
Try moving in the Y direction only.
|
||||||||||||||||||
| SlideActorPastObjects_Vertical | 47197 | PUSH DE | Stash the new position on the stack. | |||||||||||||||
| 47198 | LD A,(38574) | Use the old X position instead. | ||||||||||||||||
| 47201 | LD E,A | |||||||||||||||||
| 47202 | PUSH IX | Stash the pointer to the list of objects on the stack. | ||||||||||||||||
| 47204 | CALL TestObjectOverlap | Test whether moving in the Y direction only overlaps with an object. | ||||||||||||||||
| 47207 | POP IX | Restore the pointer to the list of objects from the stack. | ||||||||||||||||
| 47209 | POP DE | Restore the new position from the stack. | ||||||||||||||||
| 47210 | JR NC,SlideActorPastObjects_Return | Jump to SlideActorPastObjects_Return if the actor can move in the Y direction. | ||||||||||||||||
| 47212 | LD A,(38575) | Keep the old Y position, as the actor cannot move in the Y direction. | ||||||||||||||||
| 47215 | LD D,A | |||||||||||||||||
| SlideActorPastObjects_Return | 47216 | POP IX | Restore the actor record from the stack. | |||||||||||||||
| 47218 | RET | Return. | ||||||||||||||||
| Prev: 47124 | Up: Map | Next: 47219 |