![]() |
Routines |
| Prev: BECD | Up: Map | Next: BF77 |
|
Used by the routine at Update_Task_Two_Entities.
Restore the upstairs helper if needed, then either start/stop its script from the game event flags or pick the next wandering script.
|
||||
| Update_TaskTwoEntityState | BEE6 | LD HL,$72B5 | Point HL at the task-two flags (TaskTwoFlags). | |
| BEE9 | LD A,($72AE) | Fetch the current task index (CurrentTaskIndex). | ||
| BEEC | CP $02 | Is task two itself active (index 02)? If so, skip the spawn latch at Update_TaskTwo_CheckHelperRestore. | ||
| BEEE | JR Z,Update_TaskTwo_CheckHelperRestore | |||
| BEF0 | BIT 1,(HL) | Is the task-two "advance script" bit already set (bit 01)? If so, skip the spawn latch. | ||
| BEF2 | JR Z,Update_TaskTwo_CheckHelperRestore | |||
| BEF4 | SET 2,(HL) | Otherwise arm the spawn / random-walk latch (set bit 02). | ||
|
Handle helper restore: rewrite the upstairs helper layout when bit 03 is set.
|
||||
| Update_TaskTwo_CheckHelperRestore | BEF6 | BIT 3,(HL) | Does the helper need its layout restoring (bit 03)? If not, select the entity at Update_TaskTwo_SelectEntity. | |
| BEF8 | JR Z,Update_TaskTwo_SelectEntity | |||
| BEFA | RES 3,(HL) | Clear the restore latch. | ||
| BEFC | LD HL,$9DB3 | Point HL at spawned-helper layout GraphicLayout_WhiteOrb. | ||
| BEFF | LD ($8FE1),HL | Write that layout into the helper's record (8FE1). | ||
| BF02 | LD HL,$8FD7 | Point HL at the spawned-helper entity (StateData_Complex_17). | ||
| BF05 | SET 7,(HL) | Mark that helper active (set bit 07 of its type/flags byte). | ||
|
Handle start/stop: use game event flags to run or halt the upstairs helper script.
|
||||
| Update_TaskTwo_SelectEntity | BF07 | LD IX,$8FE5 | Point IX at the upstairs helper entity (StateData_Complex_18). | |
| BF0B | LD HL,($72CF) | Keep the temporary script pointer in HL (Pointer_ActiveScriptCursor). | ||
| BF0E | LD A,($72B3) | Fetch the game event flags (GameEventFlags). | ||
| BF11 | BIT 7,A | Is a task entity script marked active (bit 07)? If not, take the wander branch at Update_TaskTwo_ScriptBranch. | ||
| BF13 | JR NZ,Update_TaskTwo_ScriptBranch | |||
| BF15 | BIT 7,(IX+$00) | Is this helper already running (bit 07 of its type)? If not, decide whether to stop it at Update_TaskTwo_StopEntity. | ||
| BF19 | JR NZ,Update_TaskTwo_StopEntity | |||
| BF1B | BIT 1,A | Is the trap door open (game event bit 01)? If so, (re)start the helper at Update_TaskTwo_StartEntity. | ||
| BF1D | JR Z,Update_TaskTwo_StartEntity | |||
| BF1F | JR Update_TaskTwo_ScriptBranch | Otherwise wander at Update_TaskTwo_ScriptBranch. | ||
|
Stop the upstairs helper when the trap is open but the helper was not running.
|
||||
| Update_TaskTwo_StopEntity | BF21 | BIT 1,A | Is the trap door open? If not, leave the helper alone and return. | |
| BF23 | RET Z | |||
| BF24 | RES 7,(IX+$00) | Clear the helper's "running" type bit. | ||
| BF28 | JP AdvanceScriptInstruction | Advance its current script at AdvanceScriptInstruction. | ||
|
Start the upstairs helper: clear the task latch and publish script Data_BirdScripts.
|
||||
| Update_TaskTwo_StartEntity | BF2B | SET 7,(IX+$00) | Mark the helper running (set bit 07 of its type). | |
| BF2F | LD HL,$72B3 | Point HL at the game event flags (GameEventFlags). | ||
| BF32 | RES 7,(HL) | Clear "task entity script active" (bit 07). | ||
| BF34 | XOR A | Clear A so the task phase can reset. | ||
| BF35 | LD ($72AF),A | Clear the current task phase (CurrentTaskPhase). | ||
| BF38 | LD HL,$BE6D | Point HL at the bird scripts (Data_BirdScripts). | ||
| BF3B | LD ($72CF),HL | Publish it through the active script cursor (Pointer_ActiveScriptCursor). | ||
| BF3E | RET | Return. | ||
|
This entry point is used by the routine at ScriptRoutine_TaskTwoRiseOnEvent.
Shared entry used by script routine ScriptRoutine_TaskTwoRiseOnEvent when the helper reaches column 27: clear the upstairs event latch and restart.
|
||||
| Update_TaskTwo_ClearTrapFlags | BF3F | LD HL,$72B3 | Point HL at the game event flags (GameEventFlags). | |
| BF42 | RES 4,(HL) | Clear the task-two / upstairs event latch (bit 04). | ||
| BF44 | LD A,$28 | Load a fresh game-tick delay of 28 frames. | ||
| BF46 | LD ($72F2),A | Store it in the game tick counter (GameTickCounter). | ||
| BF49 | LD HL,$72B5 | Point HL at the task-two flags (TaskTwoFlags). | ||
| BF4C | RES 2,(HL) | Clear the spawn / random-walk latch (bit 02). | ||
| BF4E | JR Update_TaskTwo_StartEntity | Restart the helper at Update_TaskTwo_StartEntity. | ||
|
Handle wander: pick the next bird script when no start/stop event is pending.
|
||||
| Update_TaskTwo_ScriptBranch | BF50 | LD A,($72B5) | Fetch the task-two flags (TaskTwoFlags). | |
| BF53 | BIT 1,A | Is "advance script" still set (bit 01)? If so, just step the current script at AdvanceScriptInstruction. | ||
| BF55 | JP Z,AdvanceScriptInstruction | |||
| BF58 | RES 1,A | Clear that advance bit. | ||
| BF5A | LD ($72B5),A | Write the updated task-two flags back. | ||
| BF5D | BIT 2,A | Is the spawn / random-walk latch set (bit 02)? If not, use the alternate script at Update_TaskTwo_AltScript. | ||
| BF5F | JR NZ,Update_TaskTwo_AltScript | |||
| BF61 | LD A,$18 | Load random range base 18 for a wander destination. | ||
| BF63 | CALL PseudoRandom | Call PseudoRandom to pick a pseudo-random value. | ||
| BF66 | ADD A,$16 | Bias it into the bird script table (16+A). | ||
| BF68 | LD ($BE9B),A | Poke that index into task-two storage at BE9B. | ||
| BF6B | LD HL,$BE91 | Point HL at the wander script (BirdScript_Wander). | ||
| BF6E | JP ScriptInstruction | Run it via ScriptInstruction. | ||
|
Wander without the spawn latch: run the alternate bird script (BirdScript_AltWander).
|
||||
| Update_TaskTwo_AltScript | BF71 | LD HL,$BEC1 | Point HL at the alternate bird script (BirdScript_AltWander). | |
| BF74 | JP ScriptInstruction | Run it via ScriptInstruction. | ||
| Prev: BECD | Up: Map | Next: BF77 |