Prev: 44440 Up: Map Next: 44748
44449: Update Timed Events
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 44449 LD A,(29390) Load A with the timed event latch (TimedEventLatch).
44452 OR A Is timed event latch zero? If so, return.
44453 RET Z
44454 LD IX,36221 Point IX at the dumb-waiter entity (36221).
44458 CP 28 Is timed event latch equal to 28? If not, jump to Update_Timed_Events_AdvanceTypeAndSound.
44460 JR NZ,Update_Timed_Events_AdvanceTypeAndSound
44462 XOR A Clear the timed event latch.
44463 LD (29390),A Set the timed event latch.
44466 LD IX,(36233) Load IX from the trap door entity pointer (36233).
44470 LD A,(IX+0) Fetch the current entity's type for the type test.
44473 CP 20 Is the current entity's entity type less than 20? If so, jump to Update_Timed_Events_TrapDoorLayout.
44475 JR C,Update_Timed_Events_TrapDoorLayout
44477 BIT 6,(IX+1) Is bit 6 of the current entity's flags byte 1 set? If not, jump to Update_Timed_Events_TrapDoorLayout.
44481 JR Z,Update_Timed_Events_TrapDoorLayout
44483 RES 6,(IX+1) Reset bit 6 of the current entity's flags byte 1.
44487 INC (IX+4) Advance this entity into the next room.
44490 INC (IX+5) Move this entity one character down.
44493 INC (IX+6)
44496 INC (IX+4) Advance this entity into the next room.
44499 INC (IX+5) Move this entity one character down.
44502 INC (IX+6)
44505 LD HL,29363 Point HL at the game event flags (GameEventFlags).
44508 RES 3,(HL) Clear "object has been offered to the trap" (bit 3 of GameEventFlags).
Force the lever scenery slot onto closed facing left at GraphicLayout_LeverClosedLeft.
Update_Timed_Events_TrapDoorLayout 44510 LD IX,36235 Point IX at the lever scenery entity (36235).
44514 LD BC,43047 Load BC with the lever closed, facing left (GraphicLayout_LeverClosedLeft).
44517 LD (IX+10),C Set the low byte of the current entity's graphic layout address from C.
44520 LD (IX+11),B Set the high byte of the current entity's graphic layout address from B.
44523 RET Return.
Advance the timed-event entity type, queue a cue, and either raise or lower it toward the trap.
Update_Timed_Events_AdvanceTypeAndSound 44524 INC A Advance the current entity's entity type by one.
44525 LD (29390),A Set the timed event latch.
44528 CP 15 Is the current entity's entity type equal to 15? If so, jump to Update_Timed_Events_Branch.
44530 JP Z,Update_Timed_Events_Branch
44533 PUSH AF Stash AF on the stack.
44534 LD A,12 Load A with sound index 12.
44536 CALL Queue_Sound Call Queue_Sound to queue a sound effect.
44539 POP AF Restore AF from the stack.
44540 JR NC,Update_Timed_Events_RaiseEntityY If no borrow/miss was signaled, jump to Update_Timed_Events_RaiseEntityY.
44542 DEC (IX+5) Move this entity one character up.
44545 DEC (IX+6)
44548 LD IX,(36233) Load IX from the trap door entity pointer (36233).
44552 BIT 6,(IX+1) Is bit 6 of the current entity's flags byte 1 set? If not, return.
44556 RET Z
44557 DEC (IX+5) Move this entity one character up.
44560 DEC (IX+6)
44563 RET Return.
Lower the timed-event entity (and the offered trap entity if flagged) one character.
Update_Timed_Events_RaiseEntityY 44564 INC (IX+5) Move this entity one character down.
44567 INC (IX+6)
44570 LD IX,(36233) Load IX from the trap door entity pointer (36233).
44574 BIT 6,(IX+1) Is bit 6 of the current entity's flags byte 1 set? If not, return.
44578 RET Z
44579 INC (IX+5) Move this entity one character down.
44582 INC (IX+6)
44585 RET Return.
When the timed event finishes on task 5, latch Berk's eat/action path or run the fanfare branch.
Update_Timed_Events_Branch 44586 LD A,(29358) Load A with the current task index (CurrentTaskIndex).
44589 OR A Is current task index zero? If so, return.
44590 RET Z
44591 CP 5 Is current task index equal to 5? If not, jump to Update_Timed_Events_TrapEntityMessage.
44593 JR NZ,Update_Timed_Events_TrapEntityMessage
44595 LD A,(29364) Load A with the task status flags (TaskStatusFlags).
44598 BIT 6,A Is bit 6 of task status flags set? If so, return.
44600 RET NZ
44601 BIT 7,A Is bit 7 of task status flags set? If not, jump to Update_Timed_Events_TaskProgressFanfare.
44603 JR Z,Update_Timed_Events_TaskProgressFanfare
44605 SET 6,A Set "Berk action / eat latch" (bit 6 of TaskStatusFlags).
44607 LD (29364),A Set the task status flags (TaskStatusFlags).
44610 LD IY,36991 Point IY at the inactive complex-entity slot (StateData_Complex_29).
44614 LD (IY+0),23 Write 23 to the referenced entity's entity type.
44618 SET 6,(IY+1) Set bit 6 of the referenced entity's flags byte 1.
44622 LD (36233),IY Store IY in the trap door entity pointer (36233).
44626 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 44628 LD IX,(36233) Load IX from the trap door entity pointer (36233).
44632 BIT 6,(IX+1) Is bit 6 of the current entity's flags byte 1 set? If not, return.
44636 RET Z
44637 LD A,(IX+0) Fetch the current entity's type into A.
44640 LD (29381),A Set the message trigger (MessageTrigger).
Select the task-progress message, clear the offered-to-trap flag, and tidy helper slots on task 1.
Update_Timed_Events_TaskProgressFanfare 44643 PUSH IX Stash IX on the stack.
44645 CALL Select_TaskProgressMessage Call Select_TaskProgressMessage to select Task Progress Message.
44648 POP IX Restore IX from the stack.
44650 LD A,(29425) Load A with the task progress repeat count (TaskProgressRepeatCount).
44653 OR A Return if the task progress repeat count is zero.
44654 RET Z
44655 LD A,(29363) Load A with the game event flags (GameEventFlags).
44658 RES 3,A Clear "object has been offered to the trap" (bit 3 of GameEventFlags).
44660 LD (29363),A Set the game event flags (GameEventFlags).
44663 LD A,(29358) Load A with the current task index (CurrentTaskIndex).
44666 CP 1 Is current task index equal to 1? If not, jump to Update_Timed_Events_AdvanceDialogue.
44668 JR NZ,Update_Timed_Events_AdvanceDialogue
44670 XOR A Clear the current task phase (idle).
44671 LD (29359),A Set the current task phase (CurrentTaskPhase).
44674 LD IY,36767 Point IY at the inactive complex-entity slot (StateData_Complex_13).
44678 LD DE,14 Each entity record is 0014 bytes long, then load that length into DE.
44681 LD B,3 Load B with 3 as a loop counter.
Clear helper entity types/flags across the upstairs helper slots.
Update_Timed_Events_ClearHelperTypes 44683 LD (IY+0),A Set the referenced entity's entity type.
44686 RES 5,(IY+1) Reset bit 5 of the referenced entity's flags byte 1.
44690 ADD IY,DE Advance IY to the next entity record.
44692 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 44694 XOR A Clear the current entity type (deactivate the slot).
44695 LD (IX+0),A Set the current entity's entity type.
44698 LD (29358),A Set the current task index (CurrentTaskIndex).
44701 LD A,(29360) Load A with the dialogue line index (DialogueLineIndex).
44704 INC A Advance dialogue line index by one.
44705 LD (29360),A Set the dialogue line index (DialogueLineIndex).
44708 CALL Handle_Berk_Action Call Handle_Berk_Action to handle Berk's action.
44711 CALL Reset_Text_Position Call Reset_Text_Position to reset the text position.
44714 LD A,80 Load A with 80 as the game tick reload value.
44716 LD (29426),A Set the game tick counter (GameTickCounter).
Choose the held-entity countdown length (25, doubled outside Learner Berk mode).
Update_Timed_Events_HeldCountdownStep 44719 LD HL,25 Load HL with 0025 as a delay/count constant.
44722 LD A,(29353) Load A with the Learner Berk mode flag (Flag_LearnerBerkMode).
44725 OR A Is Learner Berk mode flag zero? If not, jump to Update_Timed_Events_StoreHeldAndRefresh.
44726 JR NZ,Update_Timed_Events_StoreHeldAndRefresh
44728 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 44729 LD (29403),HL Store HL in the pointer to the entity Berk is holding (Pointer_BerkHeldEntity).
44732 CALL Initialise_Room_Display Call Initialise_Room_Display to initialise the room display.
44735 CALL Handle_Berk_Action Call Handle_Berk_Action to handle Berk's action.
44738 LD A,(29425) Load A with the task progress repeat count (TaskProgressRepeatCount).
44741 DEC A Decrease the task progress repeat count in A by one.
44742 LD (29425),A Set the task progress repeat count (TaskProgressRepeatCount).
44745 JR NZ,Update_Timed_Events_HeldCountdownStep If the result was non-zero, jump to Update_Timed_Events_HeldCountdownStep.
44747 RET Return.
Prev: 44440 Up: Map Next: 44748