![]() |
Routines |
| Prev: 48257 | Up: Map | Next: 48498 |
|
Used by the routine at ScriptRoutine_ThingUpstairsChase.
Move the Thing Upstairs entity toward Berk within its room bounds and queue a chase sound when it closes in.
|
||||||||
| Update_ThingUpstairs_Movement | 48444 | LD A,10 | Load A with 10. | |||||
| 48446 | CALL PseudoRandom | Call PseudoRandom to pick a pseudo-random value. | ||||||
| 48449 | ADD A,5 | Add 5 to A (adjust an entity/timer value). | ||||||
| 48451 | LD (48095),A | Set Thing Upstairs flag byte (48095). | ||||||
| 48454 | LD A,2 | Load A with 2. | ||||||
| 48456 | CALL PseudoRandom | Call PseudoRandom to pick a pseudo-random value. | ||||||
| 48459 | INC A | Advance 2 by one. | ||||||
| 48460 | ADD A,A | Multiply A by 4 to form a table index. | ||||||
| 48461 | ADD A,A | |||||||
| 48462 | LD C,A | Keep 2 in C for later. | ||||||
| 48463 | LD A,4 | Load A with 4. | ||||||
| 48465 | CALL PseudoRandom | Call PseudoRandom to pick a pseudo-random value. | ||||||
| 48468 | INC A | Advance 4 by one. | ||||||
| 48469 | CP 3 | Is 4 less than 3? If not, jump to Update_ThingUpstairs_Movement_TrackBerkX. | ||||||
| 48471 | JR NC,Update_ThingUpstairs_Movement_TrackBerkX | |||||||
| 48473 | OR C | Merge another flag byte into 4. | ||||||
| 48474 | LD A,C | Copy the saved count/flag from C into A. | ||||||
| 48475 | JR Update_ThingUpstairs_Movement_StoreState | Jump to Update_ThingUpstairs_Movement_StoreState to store the Thing Upstairs direction. | ||||||
|
Steer toward Berk on X: face right if aligned, else face left.
|
||||||||
| Update_ThingUpstairs_Movement_TrackBerkX | 48477 | LD A,(29443) | Load A with Berk's X-coordinate copy (BerkXCoordinateCopy). | |||||
| 48480 | LD B,A | Keep Berk's X-coordinate copy in B for later. | ||||||
| 48481 | LD A,(IX+7) | Load A with the current entity's x-coordinate. | ||||||
| 48484 | CP B | Does this entity's x equal B? If not, jump to Update_ThingUpstairs_Movement_FaceRight. | ||||||
| 48485 | JR NC,Update_ThingUpstairs_Movement_FaceRight | |||||||
| 48487 | SET 0,C | Set bit 0 of the saved flags in C. | ||||||
| 48489 | JR Update_ThingUpstairs_Movement_WriteDirection | Jump to Update_ThingUpstairs_Movement_WriteDirection to keep the Thing Upstairs direction flags. | ||||||
|
Face left when the Thing Upstairs entity's X does not match Berk's copy at BerkXCoordinateCopy.
|
||||||||
| Update_ThingUpstairs_Movement_FaceRight | 48491 | SET 1,C | Set bit 1 of the saved flags in C. | |||||
|
Commit the chosen chase direction flags into A.
|
||||||||
| Update_ThingUpstairs_Movement_WriteDirection | 48493 | LD A,C | Copy the saved count/flag from C into A. | |||||
|
Store the chase direction/state back onto the Thing Upstairs entity.
|
||||||||
| Update_ThingUpstairs_Movement_StoreState | 48494 | LD (IX+9),A | Set the current entity's direction / state. | |||||
| 48497 | RET | Return. | ||||||
| Prev: 48257 | Up: Map | Next: 48498 |