![]() |
Routines |
| Prev: AD98 | Up: Map | Next: AECC |
|
Used by the routine at GameStart.
Once per frame: run timed room events, fanfares and the script-temporary countdown while a task is active.
|
||||
| Update_Timed_Events | ADA1 | LD A,($72CE) | Load A with the timed event latch (TimedEventLatch). | |
| ADA4 | OR A | Is timed event latch zero? If so, return. | ||
| ADA5 | RET Z | |||
| ADA6 | LD IX,$8D7D | Point IX at the dumb-waiter entity (8D7D). | ||
| ADAA | CP $1C | Is timed event latch equal to 1C? If not, jump to Update_Timed_Events_AdvanceTypeAndSound. | ||
| ADAC | JR NZ,Update_Timed_Events_AdvanceTypeAndSound | |||
| ADAE | XOR A | Clear the timed event latch. | ||
| ADAF | LD ($72CE),A | Set the timed event latch. | ||
| ADB2 | LD IX,($8D89) | Load IX from the trap door entity pointer (8D89). | ||
| ADB6 | LD A,(IX+$00) | Fetch the current entity's type for the type test. | ||
| ADB9 | CP $14 | Is the current entity's entity type less than 14? If so, jump to Update_Timed_Events_TrapDoorLayout. | ||
| ADBB | JR C,Update_Timed_Events_TrapDoorLayout | |||
| ADBD | BIT 6,(IX+$01) | Is bit 06 of the current entity's flags byte 1 set? If not, jump to Update_Timed_Events_TrapDoorLayout. | ||
| ADC1 | JR Z,Update_Timed_Events_TrapDoorLayout | |||
| ADC3 | RES 6,(IX+$01) | Reset bit 06 of the current entity's flags byte 1. | ||
| ADC7 | INC (IX+$04) | Advance this entity into the next room. | ||
| ADCA | INC (IX+$05) | Move this entity one character down. | ||
| ADCD | INC (IX+$06) | |||
| ADD0 | INC (IX+$04) | Advance this entity into the next room. | ||
| ADD3 | INC (IX+$05) | Move this entity one character down. | ||
| ADD6 | INC (IX+$06) | |||
| ADD9 | LD HL,$72B3 | Point HL at the game event flags (GameEventFlags). | ||
| ADDC | RES 3,(HL) | Clear "object has been offered to the trap" (bit 03 of GameEventFlags). | ||
|
Force the lever scenery slot onto closed facing left at GraphicLayout_LeverClosedLeft.
|
||||
| Update_Timed_Events_TrapDoorLayout | ADDE | LD IX,$8D8B | Point IX at the lever scenery entity (8D8B). | |
| ADE2 | LD BC,$A827 | Load BC with the lever closed, facing left (GraphicLayout_LeverClosedLeft). | ||
| ADE5 | LD (IX+$0A),C | Set the low byte of the current entity's graphic layout address from C. | ||
| ADE8 | LD (IX+$0B),B | Set the high byte of the current entity's graphic layout address from B. | ||
| ADEB | RET | Return. | ||
|
Advance the timed-event entity type, queue a cue, and either raise or lower it toward the trap.
|
||||
| Update_Timed_Events_AdvanceTypeAndSound | ADEC | INC A | Advance the current entity's entity type by one. | |
| ADED | LD ($72CE),A | Set the timed event latch. | ||
| ADF0 | CP $0F | Is the current entity's entity type equal to 0F? If so, jump to Update_Timed_Events_Branch. | ||
| ADF2 | JP Z,Update_Timed_Events_Branch | |||
| ADF5 | PUSH AF | Stash AF on the stack. | ||
|
|
||||
| ADF6 | LD A,$0C | Load A with sound index 0C. | ||
| ADF8 | CALL Queue_Sound | Call Queue_Sound to queue a sound effect. | ||
| ADFB | POP AF | Restore AF from the stack. | ||
| ADFC | JR NC,Update_Timed_Events_RaiseEntityY | If no borrow/miss was signaled, jump to Update_Timed_Events_RaiseEntityY. | ||
| ADFE | DEC (IX+$05) | Move this entity one character up. | ||
| AE01 | DEC (IX+$06) | |||
| AE04 | LD IX,($8D89) | Load IX from the trap door entity pointer (8D89). | ||
| AE08 | BIT 6,(IX+$01) | Is bit 06 of the current entity's flags byte 1 set? If not, return. | ||
| AE0C | RET Z | |||
| AE0D | DEC (IX+$05) | Move this entity one character up. | ||
| AE10 | DEC (IX+$06) | |||
| AE13 | RET | Return. | ||
|
Lower the timed-event entity (and the offered trap entity if flagged) one character.
|
||||
| Update_Timed_Events_RaiseEntityY | AE14 | INC (IX+$05) | Move this entity one character down. | |
| AE17 | INC (IX+$06) | |||
| AE1A | LD IX,($8D89) | Load IX from the trap door entity pointer (8D89). | ||
| AE1E | BIT 6,(IX+$01) | Is bit 06 of the current entity's flags byte 1 set? If not, return. | ||
| AE22 | RET Z | |||
| AE23 | INC (IX+$05) | Move this entity one character down. | ||
| AE26 | INC (IX+$06) | |||
| AE29 | RET | Return. | ||
|
When the timed event finishes on task 05, latch Berk's eat/action path or run the fanfare branch.
|
||||
| Update_Timed_Events_Branch | AE2A | LD A,($72AE) | Load A with the current task index (CurrentTaskIndex). | |
| AE2D | OR A | Is current task index zero? If so, return. | ||
| AE2E | RET Z | |||
| AE2F | CP $05 | Is current task index equal to 05? If not, jump to Update_Timed_Events_TrapEntityMessage. | ||
| AE31 | JR NZ,Update_Timed_Events_TrapEntityMessage | |||
| AE33 | LD A,($72B4) | Load A with the task status flags (TaskStatusFlags). | ||
| AE36 | BIT 6,A | Is bit 06 of task status flags set? If so, return. | ||
| AE38 | RET NZ | |||
| AE39 | BIT 7,A | Is bit 07 of task status flags set? If not, jump to Update_Timed_Events_TaskProgressFanfare. | ||
| AE3B | JR Z,Update_Timed_Events_TaskProgressFanfare | |||
| AE3D | SET 6,A | Set "Berk action / eat latch" (bit 06 of TaskStatusFlags). | ||
| AE3F | LD ($72B4),A | Set the task status flags (TaskStatusFlags). | ||
| AE42 | LD IY,$907F | Point IY at the inactive complex-entity slot (StateData_Complex_29). | ||
| AE46 | LD (IY+$00),$17 | Write 17 to the referenced entity's entity type. | ||
| AE4A | SET 6,(IY+$01) | Set bit 06 of the referenced entity's flags byte 1. | ||
| AE4E | LD ($8D89),IY | Store IY in the trap door entity pointer (8D89). | ||
| AE52 | JR Update_Timed_Events_TaskProgressFanfare | Jump to Update_Timed_Events_TaskProgressFanfare to finish the timed-event pass. | ||
|
If an entity was offered to the trap, copy its type into the message trigger.
|
||||
| Update_Timed_Events_TrapEntityMessage | AE54 | LD IX,($8D89) | Load IX from the trap door entity pointer (8D89). | |
| AE58 | BIT 6,(IX+$01) | Is bit 06 of the current entity's flags byte 1 set? If not, return. | ||
| AE5C | RET Z | |||
| AE5D | LD A,(IX+$00) | Fetch the current entity's type into A. | ||
| AE60 | LD ($72C5),A | Set the message trigger (MessageTrigger). | ||
|
Select the task-progress message, clear the offered-to-trap flag, and tidy helper slots on task 01.
|
||||
| Update_Timed_Events_TaskProgressFanfare | AE63 | PUSH IX | Stash IX on the stack. | |
| AE65 | CALL Select_TaskProgressMessage | Call Select_TaskProgressMessage to select Task Progress Message. | ||
| AE68 | POP IX | Restore IX from the stack. | ||
| AE6A | LD A,($72F1) | Load A with the task progress repeat count (TaskProgressRepeatCount). | ||
| AE6D | OR A | Return if the task progress repeat count is zero. | ||
| AE6E | RET Z | |||
| AE6F | LD A,($72B3) | Load A with the game event flags (GameEventFlags). | ||
| AE72 | RES 3,A | Clear "object has been offered to the trap" (bit 03 of GameEventFlags). | ||
| AE74 | LD ($72B3),A | Set the game event flags (GameEventFlags). | ||
| AE77 | LD A,($72AE) | Load A with the current task index (CurrentTaskIndex). | ||
| AE7A | CP $01 | Is current task index equal to 01? If not, jump to Update_Timed_Events_AdvanceDialogue. | ||
| AE7C | JR NZ,Update_Timed_Events_AdvanceDialogue | |||
| AE7E | XOR A | Clear the current task phase (idle). | ||
| AE7F | LD ($72AF),A | Set the current task phase (CurrentTaskPhase). | ||
| AE82 | LD IY,$8F9F | Point IY at the inactive complex-entity slot (StateData_Complex_13). | ||
| AE86 | LD DE,$000E | Each entity record is 000E bytes long, then load that length into DE. | ||
| AE89 | LD B,$03 | Load B with 03 as a loop counter. | ||
|
Clear helper entity types/flags across the upstairs helper slots.
|
||||
| Update_Timed_Events_ClearHelperTypes | AE8B | LD (IY+$00),A | Set the referenced entity's entity type. | |
| AE8E | RES 5,(IY+$01) | Reset bit 05 of the referenced entity's flags byte 1. | ||
| AE92 | ADD IY,DE | Advance IY to the next entity record. | ||
| AE94 | DJNZ Update_Timed_Events_ClearHelperTypes | Decrease the loop counter in B and jump to Update_Timed_Events_ClearHelperTypes if more iterations remain. | ||
|
Deactivate the timed-event entity, advance dialogue, handle Berk's action and reload the tick counter.
|
||||
| Update_Timed_Events_AdvanceDialogue | AE96 | XOR A | Clear the current entity type (deactivate the slot). | |
| AE97 | LD (IX+$00),A | Set the current entity's entity type. | ||
| AE9A | LD ($72AE),A | Set the current task index (CurrentTaskIndex). | ||
| AE9D | LD A,($72B0) | Load A with the dialogue line index (DialogueLineIndex). | ||
| AEA0 | INC A | Advance dialogue line index by one. | ||
| AEA1 | LD ($72B0),A | Set the dialogue line index (DialogueLineIndex). | ||
| AEA4 | CALL Handle_Berk_Action | Call Handle_Berk_Action to handle Berk's action. | ||
| AEA7 | CALL Reset_Text_Position | Call Reset_Text_Position to reset the text position. | ||
| AEAA | LD A,$50 | Load A with 50 as the game tick reload value. | ||
| AEAC | LD ($72F2),A | Set the game tick counter (GameTickCounter). | ||
|
Choose the held-entity countdown length (19, doubled outside Learner Berk mode).
|
||||
| Update_Timed_Events_HeldCountdownStep | AEAF | LD HL,$0019 | Load HL with 0019 as a delay/count constant. | |
| AEB2 | LD A,($72A9) | Load A with the Learner Berk mode flag (Flag_LearnerBerkMode). | ||
| AEB5 | OR A | Is Learner Berk mode flag zero? If not, jump to Update_Timed_Events_StoreHeldAndRefresh. | ||
| AEB6 | JR NZ,Update_Timed_Events_StoreHeldAndRefresh | |||
| AEB8 | ADD HL,HL | Double the pointer/offset in HL. | ||
|
Store the bonus, refresh the room display/action, and repeat until the task progress repeat count hits zero.
|
||||
| Update_Timed_Events_StoreHeldAndRefresh | AEB9 | LD ($72DB),HL | Store HL in the pointer to the entity Berk is holding (Pointer_BerkHeldEntity). | |
| AEBC | CALL Initialise_Room_Display | Call Initialise_Room_Display to initialise the room display. | ||
| AEBF | CALL Handle_Berk_Action | Call Handle_Berk_Action to handle Berk's action. | ||
| AEC2 | LD A,($72F1) | Load A with the task progress repeat count (TaskProgressRepeatCount). | ||
| AEC5 | DEC A | Decrease the task progress repeat count in A by one. | ||
| AEC6 | LD ($72F1),A | Set the task progress repeat count (TaskProgressRepeatCount). | ||
| AEC9 | JR NZ,Update_Timed_Events_HeldCountdownStep | If the result was non-zero, jump to Update_Timed_Events_HeldCountdownStep. | ||
| AECB | RET | Return. | ||
| Prev: AD98 | Up: Map | Next: AECC |