![]() |
Routines |
| Prev: 48228 | Up: Map | Next: 48444 |
|
Chase Berk with the Thing Upstairs entity when the two overlap; otherwise keep the script moving.
|
||||||||
| ScriptRoutine_ThingUpstairsChase | 48257 | CALL Test_ThingUpstairs_Overlap | Call Test_ThingUpstairs_Overlap to test whether the Thing Upstairs entity overlaps Berk / the camera-follow entity. | |||||
| 48260 | OR A | Is A zero? If not, jump to ScriptRoutine_ThingUpstairsChase_MoveTick. | ||||||
| 48261 | JR NZ,ScriptRoutine_ThingUpstairsChase_MoveTick | |||||||
| 48263 | LD IY,37019 | Point IY at the camera-follow entity (StateData_Berk). | ||||||
| 48267 | SET 0,(IY+3) | Set bit 0 of the referenced entity's flags byte 3. | ||||||
| 48271 | BIT 4,(IY+3) | Is bit 4 of flags byte 3 (IY+3) set? If not, jump to ScriptRoutine_ThingUpstairsChase_RunStorage. | ||||||
| 48275 | JR Z,ScriptRoutine_ThingUpstairsChase_RunStorage | |||||||
| 48277 | LD IY,(29356) | Load IY with the current-entity pointer (Pointer_CurrentEntity). | ||||||
| 48281 | BIT 7,(IY+2) | Is bit 7 of the referenced entity's flags byte 2 set? If not, jump to ScriptRoutine_ThingUpstairsChase_RunStorage. | ||||||
| 48285 | JR Z,ScriptRoutine_ThingUpstairsChase_RunStorage | |||||||
| 48287 | XOR A | Clear the referenced entity type (deactivate the slot). | ||||||
| 48288 | LD (IY+0),A | Set the referenced entity's entity type. | ||||||
| 48291 | LD HL,47669 | Point HL at Berk script data BerkPutDownScript_CameraFollow. | ||||||
| 48294 | LD (29361),HL | Store HL in Berk's script position pointer (Pointer_BerkScriptPosition). | ||||||
| 48297 | LD HL,48142 | Point HL at the Thing Upstairs script tail (48142). | ||||||
| 48300 | JP ScriptInstruction | Jump to ScriptInstruction to execute the script instruction at HL. | ||||||
|
No chase overlap: run the Thing Upstairs storage/idle script at 48124.
|
||||||||
| ScriptRoutine_ThingUpstairsChase_RunStorage | 48303 | LD HL,48124 | Point HL at Thing Upstairs storage at 48124. | |||||
| 48306 | JP ScriptInstruction | Jump to ScriptInstruction to execute the script instruction at HL. | ||||||
|
Chase tick: random skip, honour move-delay 48095, else retarget via Update_ThingUpstairs_Movement.
|
||||||||
| ScriptRoutine_ThingUpstairsChase_MoveTick | 48309 | LD A,10 | Load A with 10. | |||||
| 48311 | CALL PseudoRandom | Call PseudoRandom to pick a pseudo-random value. | ||||||
| 48314 | CP 3 | Is 10 less than 3? If so, jump to AdvanceScriptInstruction. | ||||||
| 48316 | JP C,AdvanceScriptInstruction | |||||||
| 48319 | LD A,(48095) | Load A from 48095. | ||||||
| 48322 | OR A | Is A zero? If not, jump to ScriptRoutine_ThingUpstairsChase_DecMoveDelay. | ||||||
| 48323 | JR NZ,ScriptRoutine_ThingUpstairsChase_DecMoveDelay | |||||||
| 48325 | CALL Update_ThingUpstairs_Movement | Call Update_ThingUpstairs_Movement to update Thing Upstairs Movement. | ||||||
| 48328 | JR ScriptRoutine_ThingUpstairsChase_ApplyDirection | Jump to ScriptRoutine_ThingUpstairsChase_ApplyDirection to continue this routine. | ||||||
|
Count down the Thing Upstairs move-delay byte at 48095.
|
||||||||
| ScriptRoutine_ThingUpstairsChase_DecMoveDelay | 48330 | DEC A | Step 10 back by one. | |||||
| 48331 | LD (48095),A | Set Thing Upstairs flag byte 48095. | ||||||
|
Apply direction bits: step right, left, down or up, then continue the script.
|
||||||||
| ScriptRoutine_ThingUpstairsChase_ApplyDirection | 48334 | LD A,(IX+9) | Load A with the current entity's direction / state. | |||||
| 48337 | BIT 0,A | Is bit 0 of the current entity's direction / state set? If so, call ScriptRoutine_ThingUpstairsChase_TryMoveRight. | ||||||
| 48339 | CALL NZ,ScriptRoutine_ThingUpstairsChase_TryMoveRight | |||||||
| 48342 | BIT 1,A | Is bit 1 of the current entity's direction / state set? If so, call ScriptRoutine_ThingUpstairsChase_TryMoveLeft. | ||||||
| 48344 | CALL NZ,ScriptRoutine_ThingUpstairsChase_TryMoveLeft | |||||||
| 48347 | BIT 2,A | Is bit 2 of the current entity's direction / state set? If so, call ScriptRoutine_ThingUpstairsChase_TryMoveDown. | ||||||
| 48349 | CALL NZ,ScriptRoutine_ThingUpstairsChase_TryMoveDown | |||||||
| 48352 | BIT 3,A | Is bit 3 of the current entity's direction / state set? If so, call ScriptRoutine_ThingUpstairsChase_TryMoveUp. | ||||||
| 48354 | CALL NZ,ScriptRoutine_ThingUpstairsChase_TryMoveUp | |||||||
| 48357 | JP AdvanceScriptInstruction | Jump to AdvanceScriptInstruction to run the next script instruction. | ||||||
|
Try moving the Thing Upstairs entity right, or retarget when X-extent hits the right bound.
|
||||||||
| ScriptRoutine_ThingUpstairsChase_TryMoveRight | 48360 | PUSH AF | Stash AF on the stack. | |||||
| 48361 | LD A,(IX+8) | Load A with the current entity's x-extent. | ||||||
| 48364 | CP 252 | Is the current entity's x-extent less than 252? If so, jump to ScriptRoutine_ThingUpstairsChase_IncX. | ||||||
| 48366 | JR C,ScriptRoutine_ThingUpstairsChase_IncX | |||||||
| 48368 | CALL Update_ThingUpstairs_Movement | Call Update_ThingUpstairs_Movement to update Thing Upstairs Movement. | ||||||
| 48371 | JR ScriptRoutine_ThingUpstairsChase_RestoreReturnRight | Jump to ScriptRoutine_ThingUpstairsChase_RestoreReturnRight to continue this routine. | ||||||
|
Nudge the Thing Upstairs entity one character right (X and X-extent).
|
||||||||
| ScriptRoutine_ThingUpstairsChase_IncX | 48373 | INC (IX+7) | Increment the entity's x-coordinate. | |||||
|
Advance the Thing Upstairs entity's X-extent as part of the right-step.
|
||||||||
| ScriptRoutine_ThingUpstairsChase_IncXExtent | 48376 | INC (IX+8) | Increment the entity's x-extent. | |||||
|
Restore flags and return from the right-step attempt.
|
||||||||
| ScriptRoutine_ThingUpstairsChase_RestoreReturnRight | 48379 | POP AF | Restore AF from the stack. | |||||
| 48380 | RET | Return. | ||||||
|
Try moving the Thing Upstairs entity left, or retarget when X hits the left bound.
|
||||||||
| ScriptRoutine_ThingUpstairsChase_TryMoveLeft | 48381 | PUSH AF | Stash AF on the stack. | |||||
| 48382 | LD A,(IX+7) | Load A with the current entity's x-coordinate. | ||||||
| 48385 | CP 34 | Is the current entity's x-coordinate less than 34? If not, jump to ScriptRoutine_ThingUpstairsChase_DecX. | ||||||
| 48387 | JR NC,ScriptRoutine_ThingUpstairsChase_DecX | |||||||
| 48389 | CALL Update_ThingUpstairs_Movement | Call Update_ThingUpstairs_Movement to update Thing Upstairs Movement. | ||||||
| 48392 | JR ScriptRoutine_ThingUpstairsChase_RestoreReturnLeft | Jump to ScriptRoutine_ThingUpstairsChase_RestoreReturnLeft to continue this routine. | ||||||
|
Nudge the Thing Upstairs entity one character left.
|
||||||||
| ScriptRoutine_ThingUpstairsChase_DecX | 48394 | DEC (IX+7) | Move this entity one character left. | |||||
| 48397 | DEC (IX+8) | |||||||
|
Restore flags and return from the left-step attempt.
|
||||||||
| ScriptRoutine_ThingUpstairsChase_RestoreReturnLeft | 48400 | POP AF | Restore AF from the stack. | |||||
| 48401 | RET | Return. | ||||||
|
Try moving the Thing Upstairs entity up, or retarget when Y hits the top bound.
|
||||||||
| ScriptRoutine_ThingUpstairsChase_TryMoveUp | 48402 | PUSH AF | Stash AF on the stack. | |||||
| 48403 | LD A,(IX+5) | Load A with the current entity's y-coordinate. | ||||||
| 48406 | CP 20 | Is the current entity's y-coordinate less than 20? If not, jump to ScriptRoutine_ThingUpstairsChase_DecY. | ||||||
| 48408 | JR NC,ScriptRoutine_ThingUpstairsChase_DecY | |||||||
| 48410 | CALL Update_ThingUpstairs_Movement | Call Update_ThingUpstairs_Movement to update Thing Upstairs Movement. | ||||||
| 48413 | JR ScriptRoutine_ThingUpstairsChase_RestoreReturnUp | Jump to ScriptRoutine_ThingUpstairsChase_RestoreReturnUp to continue this routine. | ||||||
|
Nudge the Thing Upstairs entity one character up.
|
||||||||
| ScriptRoutine_ThingUpstairsChase_DecY | 48415 | DEC (IX+5) | Move this entity one character up. | |||||
| 48418 | DEC (IX+6) | |||||||
|
Restore flags and return from the up-step attempt.
|
||||||||
| ScriptRoutine_ThingUpstairsChase_RestoreReturnUp | 48421 | POP AF | Restore AF from the stack. | |||||
| 48422 | RET | Return. | ||||||
|
Try moving the Thing Upstairs entity down, or retarget when Y-extent hits the bottom bound.
|
||||||||
| ScriptRoutine_ThingUpstairsChase_TryMoveDown | 48423 | PUSH AF | Stash AF on the stack. | |||||
| 48424 | LD A,(IX+6) | Load A with the current entity's y-extent. | ||||||
| 48427 | CP 36 | Is the current entity's y-extent less than 36? If so, jump to ScriptRoutine_ThingUpstairsChase_IncY. | ||||||
| 48429 | JR C,ScriptRoutine_ThingUpstairsChase_IncY | |||||||
| 48431 | CALL Update_ThingUpstairs_Movement | Call Update_ThingUpstairs_Movement to update Thing Upstairs Movement. | ||||||
| 48434 | JR ScriptRoutine_ThingUpstairsChase_RestoreReturnDown | Jump to ScriptRoutine_ThingUpstairsChase_RestoreReturnDown to continue this routine. | ||||||
|
Nudge the Thing Upstairs entity one character down.
|
||||||||
| ScriptRoutine_ThingUpstairsChase_IncY | 48436 | INC (IX+5) | Move this entity one character down. | |||||
| 48439 | INC (IX+6) | |||||||
|
Restore flags and return from the down-step attempt.
|
||||||||
| ScriptRoutine_ThingUpstairsChase_RestoreReturnDown | 48442 | POP AF | Restore AF from the stack. | |||||
| 48443 | RET | Return. | ||||||
| Prev: 48228 | Up: Map | Next: 48444 |