![]() |
Routines |
| Prev: 60592 | Up: Map | Next: 60867 |
|
Let Berk interact with the door directly behind him.
|
||||||||
| ScriptRoutine_BerkDoorBehind | 60635 | LD IY,(29356) | Load IY with the current-entity pointer (Pointer_CurrentEntity). | |||||
| 60639 | LD A,(IY+0) | Load A with the referenced entity's entity type. | ||||||
| 60642 | CP 5 | Is A equal to 5? If so, jump to Script_DoorBehind_Scan. | ||||||
| 60644 | JR Z,Script_DoorBehind_Scan | |||||||
| 60646 | CP 8 | Is A equal to 8? If so, jump to Script_DoorBehind_Type08. | ||||||
| 60648 | JR Z,Script_DoorBehind_Type08 | |||||||
| 60650 | CP 16 | Is A equal to 16? If so, jump to Script_DoorBehind_TaskProp. | ||||||
| 60652 | JR Z,Script_DoorBehind_TaskProp | |||||||
| 60654 | CP 3 | Is A equal to 3? If not, jump to AdvanceScriptInstruction. | ||||||
| 60656 | JP NZ,AdvanceScriptInstruction | |||||||
| 60659 | LD BC,40267 | Point BC at basket upside-down layout GraphicLayout_BasketUpsideDown. | ||||||
| 60662 | LD (36945),BC | Store BC in 36945. | ||||||
| 60666 | JR Script_DoorBehind_FaceAndDelay | Jump to Script_DoorBehind_FaceAndDelay to continue this routine. | ||||||
|
Install yellow cup upside-down layout GraphicLayout_YellowCupUpsideDown into slot 36931 (type 5).
|
||||||||
| Script_DoorBehind_Scan | 60668 | LD BC,40333 | Point BC at yellow cup upside-down layout GraphicLayout_YellowCupUpsideDown. | |||||
| 60671 | LD (36931),BC | Store BC in 36931. | ||||||
| 60675 | JR Script_DoorBehind_FaceAndDelay | Jump to Script_DoorBehind_FaceAndDelay to continue this routine. | ||||||
|
Install worm-can layout GraphicLayout_WormCan into slot 36917 (type 8).
|
||||||||
| Script_DoorBehind_Type08 | 60677 | LD BC,40354 | Point BC at the worm-can layout (GraphicLayout_WormCan). | |||||
| 60680 | LD (36917),BC | Store BC in 36917. | ||||||
| 60684 | JR Script_DoorBehind_FaceAndDelay | Jump to Script_DoorBehind_FaceAndDelay to continue this routine. | ||||||
| Script_DoorBehind_TaskProp | 60686 | LD BC,41307 | Load BC with 41307. | |||||
| 60689 | LD (36903),BC | Store BC in 36903. | ||||||
|
Mark the interactable entity facing-behind (64) and honour the interaction delay in DoorInteractionDelay.
|
||||||||
| Script_DoorBehind_FaceAndDelay | 60693 | LD (IY+2),64 | Write 64 to the referenced entity's flags byte 2. | |||||
| 60697 | LD A,(29420) | Load A with the door interaction delay (DoorInteractionDelay). | ||||||
| 60700 | OR A | Is the door interaction delay (DoorInteractionDelay) zero? If so, jump to Script_DoorBehind_SnapshotScan. | ||||||
| 60701 | JR Z,Script_DoorBehind_SnapshotScan | |||||||
| 60703 | DEC A | Decrease A by one. | ||||||
| 60704 | LD (29420),A | Set the door interaction delay (DoorInteractionDelay). | ||||||
| 60707 | JP Script_DoorBehind_ResumeScript | Jump to Script_DoorBehind_ResumeScript to continue this routine. | ||||||
|
Snapshot Berk's position/room and scan complex entities for a matching type-50 hitch.
|
||||||||
| Script_DoorBehind_SnapshotScan | 60710 | PUSH HL | Stash HL and IX on the stack. | |||||
| 60711 | PUSH IX | |||||||
| 60713 | LD IX,(29356) | Load IX with the current-entity pointer (Pointer_CurrentEntity). | ||||||
| 60717 | LD C,(IX+7) | Load C with the current entity's x-coordinate. | ||||||
| 60720 | LD B,(IX+5) | Load B with the current entity's y-coordinate. | ||||||
| 60723 | LD A,(IX+4) | Load A with the current entity's room index. | ||||||
| 60726 | LD (29416),A | Set saved room index (SavedRoomIndex). | ||||||
| 60729 | LD HL,(29356) | Load HL with the current-entity pointer (Pointer_CurrentEntity). | ||||||
| 60732 | LD IY,36585 | Point IY at Boney's complex entity state (StateData_Boney). | ||||||
| 60736 | LD DE,14 | Load DE with 0014. | ||||||
|
Walk complex entities looking for type 50; abort the behind-door move if found.
|
||||||||
| Script_DoorBehind_WalkEntities | 60739 | LD A,(IY+0) | Load A with the referenced entity's entity type. | |||||
| 60742 | CP 50 | Is A equal to 50? If not, jump to Script_DoorBehind_SkipInactive. | ||||||
| 60744 | JR NZ,Script_DoorBehind_SkipInactive | |||||||
| 60746 | POP IX | Restore IX and HL from the stack. | ||||||
| 60748 | POP HL | |||||||
| 60749 | JP AdvanceScriptInstruction | Jump to AdvanceScriptInstruction to run the next script instruction. | ||||||
|
Skip inactive (bit 7) entities while matching Berk's saved coordinates.
|
||||||||
| Script_DoorBehind_SkipInactive | 60752 | BIT 7,A | Is bit 7 of A set? If so, jump to Script_DoorBehind_HitchMatch. | |||||
| 60754 | JR NZ,Script_DoorBehind_HitchMatch | |||||||
|
Advance to the next complex entity and keep scanning.
|
||||||||
| Script_DoorBehind_NextEntity | 60756 | ADD IY,DE | IY+=DE. | |||||
| 60758 | JR Script_DoorBehind_WalkEntities | Jump to Script_DoorBehind_WalkEntities to continue this routine. | ||||||
|
On a coordinate match, reactivate the hitch, copy Berk's position, and reseed DoorInteractionDelay.
|
||||||||
| Script_DoorBehind_HitchMatch | 60760 | LD A,L | Copy L into A. | |||||
| 60761 | CP (IY+12) | Does A match the referenced entity's extra state? If not, jump to Script_DoorBehind_NextEntity. | ||||||
| 60764 | JR NZ,Script_DoorBehind_NextEntity | |||||||
| 60766 | LD A,H | Copy H into A. | ||||||
| 60767 | CP (IY+13) | Does A match the referenced entity's extra state? If not, jump to Script_DoorBehind_NextEntity. | ||||||
| 60770 | JR NZ,Script_DoorBehind_NextEntity | |||||||
| 60772 | RES 7,(IY+0) | Reset bit 7 of the referenced entity's entity type. | ||||||
| 60776 | RES 5,(IY+1) | Reset bit 5 of the referenced entity's flags byte 1. | ||||||
| 60780 | SET 7,(IY+1) | Set bit 7 of the referenced entity's flags byte 1. | ||||||
| 60784 | LD A,(IY+8) | Load A with the referenced entity's x-extent. | ||||||
| 60787 | SUB (IY+7) | Subtract the referenced entity's x-coordinate from A. | ||||||
| 60790 | LD (IY+7),C | Store C in the referenced entity's x-coordinate. | ||||||
| 60793 | ADD A,C | A+=C. | ||||||
| 60794 | LD (IY+8),A | Set the referenced entity's x-extent. | ||||||
| 60797 | LD A,(IY+6) | Load A with the referenced entity's y-extent. | ||||||
| 60800 | SUB (IY+5) | Subtract the referenced entity's y-coordinate from A. | ||||||
| 60803 | LD (IY+5),B | Store B in the referenced entity's y-coordinate. | ||||||
| 60806 | ADD A,B | A+=B. | ||||||
| 60807 | LD (IY+6),A | Set the referenced entity's y-extent. | ||||||
| 60810 | LD A,(IX+4) | Load A with the current entity's room index. | ||||||
| 60813 | CP 1 | Is A equal to 1? If not, jump to Script_DoorBehind_WriteHitchRoom. | ||||||
| 60815 | JR NZ,Script_DoorBehind_WriteHitchRoom | |||||||
| 60817 | INC A | Step the door's room index on by one. | ||||||
|
Write the hitch's new room, arm bit 0 of GameEventFlags, and clear the type-11/8 special case.
|
||||||||
| Script_DoorBehind_WriteHitchRoom | 60818 | LD (IY+4),A | Set the referenced entity's room index. | |||||
| 60821 | LD A,2 | Load A with 2. | ||||||
| 60823 | CALL PseudoRandom | Call PseudoRandom to pick a pseudo-random value. | ||||||
| 60826 | INC A | Turn the random roll into a 1–2 door delay. | ||||||
| 60827 | LD (29420),A | Set the door interaction delay (DoorInteractionDelay). | ||||||
| 60830 | LD HL,29363 | Point HL at the game event flags (GameEventFlags). | ||||||
| 60833 | SET 0,(HL) | Set bit 0 of the byte at HL. | ||||||
| 60835 | LD A,(IY+0) | Load A with the referenced entity's entity type. | ||||||
| 60838 | CP 11 | Is A equal to 11? If not, jump to Script_DoorBehind_Finish. | ||||||
| 60840 | JR NZ,Script_DoorBehind_Finish | |||||||
| 60842 | LD A,(IX+0) | Fetch the current entity's type for the type test. | ||||||
| 60845 | CP 8 | Is A equal to 8? If not, jump to Script_DoorBehind_Finish. | ||||||
| 60847 | JR NZ,Script_DoorBehind_Finish | |||||||
| 60849 | LD HL,29373 | Point HL at the collision scratch byte (CollisionScratchByte). | ||||||
| 60852 | DEC (HL) | Decrease the byte at HL by one. | ||||||
| 60853 | LD HL,29368 | Point HL at task-one / collision flags (TaskOneCollisionFlags). | ||||||
| 60856 | RES 6,(HL) | Clear bit 6 of the byte at HL. | ||||||
|
Finish the behind-door hitch update and fall through to resume scripting.
|
||||||||
| Script_DoorBehind_Finish | 60858 | POP IX | Restore IX and HL from the stack. | |||||
| 60860 | POP HL | |||||||
|
Resume scripting at 48041 via ScriptInstruction.
|
||||||||
| Script_DoorBehind_ResumeScript | 60861 | LD HL,48041 | Load HL with 48041. | |||||
| 60864 | JP ScriptInstruction | Jump to ScriptInstruction to execute the script instruction at HL. | ||||||
| Prev: 60592 | Up: Map | Next: 60867 |