![]() |
Routines |
| Prev: CBC3 | Up: Map | Next: CC53 |
|
Tick the task-four offer-item timer that gates its dialogue.
|
||||||||
| ScriptRoutine_TaskFourTickOfferItem | CBCE | LD A,($72C2) | Load the shared tick (SharedTick) into A. | |||||
| CBD1 | OR A | Is the shared tick (SharedTick) zero? If not, jump to ScriptRoutine_TaskFourTickOfferItem_TickAndOfferItem. | ||||||
| CBD2 | JR NZ,ScriptRoutine_TaskFourTickOfferItem_TickAndOfferItem | |||||||
| CBD4 | RES 2,(IX+$0D) | Reset bit 02 of the current entity's extra state. | ||||||
| CBD8 | JP AdvanceScriptInstruction | Jump to AdvanceScriptInstruction to run the next script instruction. | ||||||
|
Tick SharedTick, flash layout GraphicLayout_Vat_Pouring on the creature, and test whether the offered item is hit.
|
||||||||
| ScriptRoutine_TaskFourTickOfferItem_TickAndOfferItem | CBDB | DEC A | Step the shared tick back by one. | |||||
| CBDC | LD ($72C2),A | Store the shared tick (SharedTick). | ||||||
| CBDF | LD IY,$9071 | Point IY at the vat entity at StateData_Complex_28. | ||||||
| CBE3 | LD BC,$A166 | Point BC at graphic layout GraphicLayout_Vat_Pouring. | ||||||
| CBE6 | LD ($907B),BC | Store BC in the inactive complex-entity slot fields at 907B. | ||||||
| CBEA | SET 3,(IX+$0D) | Set bit 03 of the current entity's extra state. | ||||||
| CBEE | LD A,(IY+$08) | Load A with the referenced entity's x-extent. | ||||||
| CBF1 | INC A | Advance referenced entity's x-extent by one. | ||||||
| CBF2 | LD C,(IY+$04) | Load C with the referenced entity's room index. | ||||||
| CBF5 | LD IY,$900F | Point IY at the task-item entity (StateData_Complex_21). | ||||||
| CBF9 | CP (IY+$07) | Does this entity's x match the referenced entity's x (IY+07)? If so, jump to ScriptRoutine_TaskFourTickOfferItem_HitItemAdvanceAnim. | ||||||
| CBFC | JP Z,ScriptRoutine_TaskFourTickOfferItem_HitItemAdvanceAnim | |||||||
|
Missed the offered item: set interaction bit 02 of EntityInteractionFlag and clear the offer latch.
|
||||||||
| ScriptRoutine_TaskFourTickOfferItem_MissItemSetFlags | CBFF | LD A,($72B9) | Load A with the entity interaction flag (EntityInteractionFlag). | |||||
| CC02 | SET 2,A | Set bit 02 of EntityInteractionFlag. | ||||||
| CC04 | LD ($72B9),A | Set the entity interaction flag (EntityInteractionFlag). | ||||||
| CC07 | SET 4,(IX+$0D) | Set bit 04 of the current entity's extra state. | ||||||
| CC0B | RES 2,(IX+$0D) | Reset bit 02 of the current entity's extra state. | ||||||
| CC0F | JP AdvanceScriptInstruction | Jump to AdvanceScriptInstruction to run the next script instruction. | ||||||
|
Hit the offered item: play the vat cue, clear the miss flag, and advance its layout animation.
|
||||||||
| ScriptRoutine_TaskFourTickOfferItem_HitItemAdvanceAnim | CC12 | LD A,C | Copy the saved count/flag from C into A. | |||||
| CC13 | CP (IY+$04) | Does this entity share the referenced entity's room (IY+04)? If not, jump to ScriptRoutine_TaskFourTickOfferItem_MissItemSetFlags. | ||||||
| CC16 | JR NZ,ScriptRoutine_TaskFourTickOfferItem_MissItemSetFlags | |||||||
|
|
||||||||
| CC18 | LD A,$91 | Load A with 91. | ||||||
| CC1A | CALL Queue_Sound | Call Queue_Sound to queue a sound effect. | ||||||
| CC1D | LD (IY+$02),$80 | Write 80 to the referenced entity's flags byte 2. | ||||||
| CC21 | LD A,($72B9) | Load A with the entity interaction flag (EntityInteractionFlag). | ||||||
| CC24 | RES 2,A | Clear bit 02 of the flag byte in A. | ||||||
| CC26 | LD ($72B9),A | Set the entity interaction flag (EntityInteractionFlag). | ||||||
| CC29 | LD A,($72C1) | Load A with the animation frame counter (AnimationFrameCounter). | ||||||
| CC2C | INC A | Advance animation frame counter by one. | ||||||
| CC2D | LD ($72C1),A | Set the animation frame counter (AnimationFrameCounter). | ||||||
| CC30 | LD A,(IY+$09) | Load A with the referenced entity's direction / state. | ||||||
| CC33 | INC A | Advance referenced entity's direction / state by one. | ||||||
| CC34 | LD (IY+$09),A | Set the referenced entity's direction / state. | ||||||
| CC37 | PUSH HL | Stash HL on the stack. | ||||||
| CC38 | LD HL,$CC4B | Point HL at task-four script data CC4B. | ||||||
| CC3B | ADD A,A | Double A to form a word index into the script/handler table. | ||||||
| CC3C | LD C,A | Keep the index in C. | ||||||
| CC3D | LD B,$00 | Clear B so BC is the word index into CC4B. | ||||||
| CC3F | ADD HL,BC | Add the length/offset in BC to the pointer in HL. | ||||||
| CC40 | LD C,(HL) | Fetch the new script address into BC. | ||||||
| CC41 | INC HL | |||||||
| CC42 | LD B,(HL) | |||||||
| CC43 | POP HL | Restore HL from the stack. | ||||||
| CC44 | LD ($9019),BC | Store BC in the task-item entity's layout field (9019). | ||||||
| CC48 | JP AdvanceScriptInstruction | Jump to AdvanceScriptInstruction to run the next script instruction. | ||||||
| CC4B | LD D,C | Copy referenced entity's direction / state into D. | ||||||
| CC4C | AND B | Mask referenced entity's direction / state with B. | ||||||
| CC4D | LD C,E | Copy the low byte from E into C (build a count/address). | ||||||
| CC4E | AND B | Mask referenced entity's direction / state with B. | ||||||
| CC4F | LD B,L | Copy the low byte from L into B (build a count/address). | ||||||
| CC50 | AND B | Mask referenced entity's direction / state with B. | ||||||
| CC51 | CCF | Invert the success marker. | ||||||
| CC52 | AND B | Mask referenced entity's direction / state with B. | ||||||
| Prev: CBC3 | Up: Map | Next: CC53 |