![]() |
Routines |
| Prev: ECB0 | Up: Map | Next: EDC3 |
|
Let Berk interact with the door directly behind him.
|
||||||||
| ScriptRoutine_BerkDoorBehind | ECDB | LD IY,($72AC) | Load IY with the current-entity pointer (Pointer_CurrentEntity). | |||||
| ECDF | LD A,(IY+$00) | Load A with the referenced entity's entity type. | ||||||
| ECE2 | CP $05 | Is A equal to 05? If so, jump to Script_DoorBehind_Scan. | ||||||
| ECE4 | JR Z,Script_DoorBehind_Scan | |||||||
| ECE6 | CP $08 | Is A equal to 08? If so, jump to Script_DoorBehind_Type08. | ||||||
| ECE8 | JR Z,Script_DoorBehind_Type08 | |||||||
| ECEA | CP $10 | Is A equal to 10? If so, jump to Script_DoorBehind_TaskProp. | ||||||
| ECEC | JR Z,Script_DoorBehind_TaskProp | |||||||
| ECEE | CP $03 | Is A equal to 03? If not, jump to AdvanceScriptInstruction. | ||||||
| ECF0 | JP NZ,AdvanceScriptInstruction | |||||||
| ECF3 | LD BC,$9D4B | Point BC at basket upside-down layout GraphicLayout_BasketUpsideDown. | ||||||
| ECF6 | LD ($9051),BC | Store BC in 9051. | ||||||
| ECFA | JR Script_DoorBehind_FaceAndDelay | Jump to Script_DoorBehind_FaceAndDelay to continue this routine. | ||||||
|
Install yellow cup upside-down layout GraphicLayout_YellowCupUpsideDown into slot 9043 (type 05).
|
||||||||
| Script_DoorBehind_Scan | ECFC | LD BC,$9D8D | Point BC at yellow cup upside-down layout GraphicLayout_YellowCupUpsideDown. | |||||
| ECFF | LD ($9043),BC | Store BC in 9043. | ||||||
| ED03 | JR Script_DoorBehind_FaceAndDelay | Jump to Script_DoorBehind_FaceAndDelay to continue this routine. | ||||||
|
Install worm-can layout GraphicLayout_WormCan into slot 9035 (type 08).
|
||||||||
| Script_DoorBehind_Type08 | ED05 | LD BC,$9DA2 | Point BC at the worm-can layout (GraphicLayout_WormCan). | |||||
| ED08 | LD ($9035),BC | Store BC in 9035. | ||||||
| ED0C | JR Script_DoorBehind_FaceAndDelay | Jump to Script_DoorBehind_FaceAndDelay to continue this routine. | ||||||
| Script_DoorBehind_TaskProp | ED0E | LD BC,$A15B | Load BC with A15B. | |||||
| ED11 | LD ($9027),BC | Store BC in 9027. | ||||||
|
Mark the interactable entity facing-behind (40) and honour the interaction delay in DoorInteractionDelay.
|
||||||||
| Script_DoorBehind_FaceAndDelay | ED15 | LD (IY+$02),$40 | Write 40 to the referenced entity's flags byte 2. | |||||
| ED19 | LD A,($72EC) | Load A with the door interaction delay (DoorInteractionDelay). | ||||||
| ED1C | OR A | Is the door interaction delay (DoorInteractionDelay) zero? If so, jump to Script_DoorBehind_SnapshotScan. | ||||||
| ED1D | JR Z,Script_DoorBehind_SnapshotScan | |||||||
| ED1F | DEC A | Decrease A by one. | ||||||
| ED20 | LD ($72EC),A | Set the door interaction delay (DoorInteractionDelay). | ||||||
| ED23 | 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-32 hitch.
|
||||||||
| Script_DoorBehind_SnapshotScan | ED26 | PUSH HL | Stash HL and IX on the stack. | |||||
| ED27 | PUSH IX | |||||||
| ED29 | LD IX,($72AC) | Load IX with the current-entity pointer (Pointer_CurrentEntity). | ||||||
| ED2D | LD C,(IX+$07) | Load C with the current entity's x-coordinate. | ||||||
| ED30 | LD B,(IX+$05) | Load B with the current entity's y-coordinate. | ||||||
| ED33 | LD A,(IX+$04) | Load A with the current entity's room index. | ||||||
| ED36 | LD ($72E8),A | Set saved room index (SavedRoomIndex). | ||||||
| ED39 | LD HL,($72AC) | Load HL with the current-entity pointer (Pointer_CurrentEntity). | ||||||
| ED3C | LD IY,$8EE9 | Point IY at Boney's complex entity state (StateData_Boney). | ||||||
| ED40 | LD DE,$000E | Load DE with 000E. | ||||||
|
Walk complex entities looking for type 32; abort the behind-door move if found.
|
||||||||
| Script_DoorBehind_WalkEntities | ED43 | LD A,(IY+$00) | Load A with the referenced entity's entity type. | |||||
| ED46 | CP $32 | Is A equal to 32? If not, jump to Script_DoorBehind_SkipInactive. | ||||||
| ED48 | JR NZ,Script_DoorBehind_SkipInactive | |||||||
| ED4A | POP IX | Restore IX and HL from the stack. | ||||||
| ED4C | POP HL | |||||||
| ED4D | JP AdvanceScriptInstruction | Jump to AdvanceScriptInstruction to run the next script instruction. | ||||||
|
Skip inactive (bit 07) entities while matching Berk's saved coordinates.
|
||||||||
| Script_DoorBehind_SkipInactive | ED50 | BIT 7,A | Is bit 07 of A set? If so, jump to Script_DoorBehind_HitchMatch. | |||||
| ED52 | JR NZ,Script_DoorBehind_HitchMatch | |||||||
|
Advance to the next complex entity and keep scanning.
|
||||||||
| Script_DoorBehind_NextEntity | ED54 | ADD IY,DE | IY+=DE. | |||||
| ED56 | 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 | ED58 | LD A,L | Copy L into A. | |||||
| ED59 | CP (IY+$0C) | Does A match the referenced entity's extra state? If not, jump to Script_DoorBehind_NextEntity. | ||||||
| ED5C | JR NZ,Script_DoorBehind_NextEntity | |||||||
| ED5E | LD A,H | Copy H into A. | ||||||
| ED5F | CP (IY+$0D) | Does A match the referenced entity's extra state? If not, jump to Script_DoorBehind_NextEntity. | ||||||
| ED62 | JR NZ,Script_DoorBehind_NextEntity | |||||||
| ED64 | RES 7,(IY+$00) | Reset bit 07 of the referenced entity's entity type. | ||||||
| ED68 | RES 5,(IY+$01) | Reset bit 05 of the referenced entity's flags byte 1. | ||||||
| ED6C | SET 7,(IY+$01) | Set bit 07 of the referenced entity's flags byte 1. | ||||||
| ED70 | LD A,(IY+$08) | Load A with the referenced entity's x-extent. | ||||||
| ED73 | SUB (IY+$07) | Subtract the referenced entity's x-coordinate from A. | ||||||
| ED76 | LD (IY+$07),C | Store C in the referenced entity's x-coordinate. | ||||||
| ED79 | ADD A,C | A+=C. | ||||||
| ED7A | LD (IY+$08),A | Set the referenced entity's x-extent. | ||||||
| ED7D | LD A,(IY+$06) | Load A with the referenced entity's y-extent. | ||||||
| ED80 | SUB (IY+$05) | Subtract the referenced entity's y-coordinate from A. | ||||||
| ED83 | LD (IY+$05),B | Store B in the referenced entity's y-coordinate. | ||||||
| ED86 | ADD A,B | A+=B. | ||||||
| ED87 | LD (IY+$06),A | Set the referenced entity's y-extent. | ||||||
| ED8A | LD A,(IX+$04) | Load A with the current entity's room index. | ||||||
| ED8D | CP $01 | Is A equal to 01? If not, jump to Script_DoorBehind_WriteHitchRoom. | ||||||
| ED8F | JR NZ,Script_DoorBehind_WriteHitchRoom | |||||||
| ED91 | INC A | Step the door's room index on by one. | ||||||
|
Write the hitch's new room, arm bit 00 of GameEventFlags, and clear the type-0B/08 special case.
|
||||||||
| Script_DoorBehind_WriteHitchRoom | ED92 | LD (IY+$04),A | Set the referenced entity's room index. | |||||
| ED95 | LD A,$02 | Load A with 02. | ||||||
| ED97 | CALL PseudoRandom | Call PseudoRandom to pick a pseudo-random value. | ||||||
| ED9A | INC A | Turn the random roll into a 01–02 door delay. | ||||||
| ED9B | LD ($72EC),A | Set the door interaction delay (DoorInteractionDelay). | ||||||
| ED9E | LD HL,$72B3 | Point HL at the game event flags (GameEventFlags). | ||||||
| EDA1 | SET 0,(HL) | Set bit 00 of the byte at HL. | ||||||
| EDA3 | LD A,(IY+$00) | Load A with the referenced entity's entity type. | ||||||
| EDA6 | CP $0B | Is A equal to 0B? If not, jump to Script_DoorBehind_Finish. | ||||||
| EDA8 | JR NZ,Script_DoorBehind_Finish | |||||||
| EDAA | LD A,(IX+$00) | Fetch the current entity's type for the type test. | ||||||
| EDAD | CP $08 | Is A equal to 08? If not, jump to Script_DoorBehind_Finish. | ||||||
| EDAF | JR NZ,Script_DoorBehind_Finish | |||||||
| EDB1 | LD HL,$72BD | Point HL at the collision scratch byte (CollisionScratchByte). | ||||||
| EDB4 | DEC (HL) | Decrease the byte at HL by one. | ||||||
| EDB5 | LD HL,$72B8 | Point HL at task-one / collision flags (TaskOneCollisionFlags). | ||||||
| EDB8 | RES 6,(HL) | Clear bit 06 of the byte at HL. | ||||||
|
Finish the behind-door hitch update and fall through to resume scripting.
|
||||||||
| Script_DoorBehind_Finish | EDBA | POP IX | Restore IX and HL from the stack. | |||||
| EDBC | POP HL | |||||||
|
Resume scripting at BBA9 via ScriptInstruction.
|
||||||||
| Script_DoorBehind_ResumeScript | EDBD | LD HL,$BBA9 | Load HL with BBA9. | |||||
| EDC0 | JP ScriptInstruction | Jump to ScriptInstruction to execute the script instruction at HL. | ||||||
| Prev: ECB0 | Up: Map | Next: EDC3 |