![]() |
Routines |
| Prev: BC81 | Up: Map | Next: BD72 |
|
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 | BD3C | LD A,$0A | Load A with 0A. | |||||
| BD3E | CALL PseudoRandom | Call PseudoRandom to pick a pseudo-random value. | ||||||
| BD41 | ADD A,$05 | Add 05 to A (adjust an entity/timer value). | ||||||
| BD43 | LD ($BBDF),A | Set Thing Upstairs flag byte (BBDF). | ||||||
| BD46 | LD A,$02 | Load A with 02. | ||||||
| BD48 | CALL PseudoRandom | Call PseudoRandom to pick a pseudo-random value. | ||||||
| BD4B | INC A | Advance 02 by one. | ||||||
| BD4C | ADD A,A | Multiply A by 04 to form a table index. | ||||||
| BD4D | ADD A,A | |||||||
| BD4E | LD C,A | Keep 02 in C for later. | ||||||
| BD4F | LD A,$04 | Load A with 04. | ||||||
| BD51 | CALL PseudoRandom | Call PseudoRandom to pick a pseudo-random value. | ||||||
| BD54 | INC A | Advance 04 by one. | ||||||
| BD55 | CP $03 | Is 04 less than 03? If not, jump to Update_ThingUpstairs_Movement_TrackBerkX. | ||||||
| BD57 | JR NC,Update_ThingUpstairs_Movement_TrackBerkX | |||||||
| BD59 | OR C | Merge another flag byte into 04. | ||||||
| BD5A | LD A,C | Copy the saved count/flag from C into A. | ||||||
| BD5B | 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 | BD5D | LD A,($7303) | Load A with Berk's X-coordinate copy (BerkXCoordinateCopy). | |||||
| BD60 | LD B,A | Keep Berk's X-coordinate copy in B for later. | ||||||
| BD61 | LD A,(IX+$07) | Load A with the current entity's x-coordinate. | ||||||
| BD64 | CP B | Does this entity's x equal B? If not, jump to Update_ThingUpstairs_Movement_FaceRight. | ||||||
| BD65 | JR NC,Update_ThingUpstairs_Movement_FaceRight | |||||||
| BD67 | SET 0,C | Set bit 00 of the saved flags in C. | ||||||
| BD69 | 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 | BD6B | SET 1,C | Set bit 01 of the saved flags in C. | |||||
|
Commit the chosen chase direction flags into A.
|
||||||||
| Update_ThingUpstairs_Movement_WriteDirection | BD6D | 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 | BD6E | LD (IX+$09),A | Set the current entity's direction / state. | |||||
| BD71 | RET | Return. | ||||||
| Prev: BC81 | Up: Map | Next: BD72 |