![]() |
Routines |
| Prev: CB1E | Up: Map | Next: CBC3 |
|
Nudge the task-four creature one character toward its target.
|
||||||||
| ScriptRoutine_TaskFourStepToward | CB44 | LD A,(IX+$0D) | Load A with the current entity's extra state. | |||||
| CB47 | BIT 4,A | Is bit 04 of the current entity's extra state set? If not, jump to ScriptRoutine_TaskFourStepToward_RequireExtraBit2. | ||||||
| CB49 | JR Z,ScriptRoutine_TaskFourStepToward_RequireExtraBit2 | |||||||
| CB4B | RES 4,A | Clear bit 04 of the flag byte in A. | ||||||
| CB4D | LD (IX+$0D),A | Set the current entity's extra state. | ||||||
| CB50 | JR ScriptRoutine_TaskFourStepToward_MaybeNegateDelta | Jump to ScriptRoutine_TaskFourStepToward_MaybeNegateDelta to continue this routine. | ||||||
|
Require extra-state bit 02 before stepping; otherwise bail to the next script.
|
||||||||
| ScriptRoutine_TaskFourStepToward_RequireExtraBit2 | CB52 | BIT 2,A | Is bit 02 of the current entity's extra state set? If so, jump to AdvanceScriptInstruction. | |||||
| CB54 | JP NZ,AdvanceScriptInstruction | |||||||
|
At extra-state ends (0B or 00), reverse the signed step via ScriptRoutine_TaskFourStepToward_NegateDirection.
|
||||||||
| ScriptRoutine_TaskFourStepToward_MaybeNegateDelta | CB57 | LD A,(IX+$0C) | Load A with the current entity's extra state. | |||||
| CB5A | CP $0B | Is the current entity's extra state equal to 0B? If so, call ScriptRoutine_TaskFourStepToward_NegateDirection. | ||||||
| CB5C | CALL Z,ScriptRoutine_TaskFourStepToward_NegateDirection | |||||||
| CB5F | OR A | Is A zero? If so, call ScriptRoutine_TaskFourStepToward_NegateDirection. | ||||||
| CB60 | CALL Z,ScriptRoutine_TaskFourStepToward_NegateDirection | |||||||
|
Apply the signed step: grow or shrink extra state, then rewrite X / X-extent.
|
||||||||
| ScriptRoutine_TaskFourStepToward_ApplySignedStep | CB63 | LD C,(IX+$09) | Load C with the current entity's direction / state. | |||||
| CB66 | BIT 7,C | Is bit 07 of the direction/state in C set (negative delta)? If so, jump to ScriptRoutine_TaskFourStepToward_DecExtraState. | ||||||
| CB68 | JR NZ,ScriptRoutine_TaskFourStepToward_DecExtraState | |||||||
| CB6A | INC A | Advance the current entity's extra state by one. | ||||||
| CB6B | JR ScriptRoutine_TaskFourStepToward_WriteCoordsAndFlags | Jump to ScriptRoutine_TaskFourStepToward_WriteCoordsAndFlags to continue this routine. | ||||||
|
Negative delta path: shrink extra state before rewriting coordinates.
|
||||||||
| ScriptRoutine_TaskFourStepToward_DecExtraState | CB6D | DEC A | Step the current entity's extra state back by one. | |||||
|
Commit the stepped X band, clear latch bit 04, and at X=6C raise it and maybe reverse.
|
||||||||
| ScriptRoutine_TaskFourStepToward_WriteCoordsAndFlags | CB6E | LD (IX+$0C),A | Set the current entity's extra state. | |||||
| CB71 | LD A,C | Copy the saved count/flag from C into A. | ||||||
| CB72 | ADD A,(IX+$07) | Add the current entity's x-coordinate to A. | ||||||
| CB75 | LD (IX+$07),A | Set the current entity's x-coordinate. | ||||||
| CB78 | LD A,C | Copy the saved count/flag from C into A. | ||||||
| CB79 | ADD A,(IX+$08) | Add the current entity's x-extent to A. | ||||||
| CB7C | LD (IX+$08),A | Set the current entity's x-extent. | ||||||
| CB7F | LD A,($72B3) | Load A with the game event flags (GameEventFlags). | ||||||
| CB82 | RES 4,A | Clear bit 04 of the flag byte in A. | ||||||
| CB84 | LD ($72B3),A | Set the game event flags (GameEventFlags). | ||||||
| CB87 | LD A,(IX+$07) | Load A with the current entity's x-coordinate. | ||||||
| CB8A | CP $6C | Is the current entity's x-coordinate equal to 6C? If not, jump to AdvanceScriptInstruction. | ||||||
| CB8C | JP NZ,AdvanceScriptInstruction | |||||||
| CB8F | LD A,($72B3) | Load A with the game event flags (GameEventFlags). | ||||||
| CB92 | SET 4,A | Set bit 04 of game event flags. | ||||||
| CB94 | LD ($72B3),A | Set the game event flags (GameEventFlags). | ||||||
| CB97 | BIT 1,A | Is bit 01 of game event flags set? If not, jump to ScriptRoutine_TaskFourStepToward_MatchCreatureThenRetrace. | ||||||
| CB99 | JR Z,ScriptRoutine_TaskFourStepToward_MatchCreatureThenRetrace | |||||||
| CB9B | LD HL,$CA9B | Point HL at task-four script entry CA9B. | ||||||
| CB9E | JP ScriptInstruction | Jump to ScriptInstruction to execute the script instruction at HL. | ||||||
|
At the turnaround X, retrace only when aligned with the vat (StateData_Complex_28) in room 03.
|
||||||||
| ScriptRoutine_TaskFourStepToward_MatchCreatureThenRetrace | CBA1 | LD IY,$9071 | Point IY at the vat entity at StateData_Complex_28. | |||||
| CBA5 | LD A,(IX+$07) | Load A with the current entity's x-coordinate. | ||||||
| CBA8 | CP (IY+$07) | Does this entity's x match the referenced entity's x (IY+07)? If not, jump to AdvanceScriptInstruction. | ||||||
| CBAB | JP NZ,AdvanceScriptInstruction | |||||||
| CBAE | LD A,(IY+$04) | Load A with the referenced entity's room index. | ||||||
| CBB1 | CP $03 | Is referenced entity's room index equal to 03? If not, jump to AdvanceScriptInstruction. | ||||||
| CBB3 | JP NZ,AdvanceScriptInstruction | |||||||
| CBB6 | JR ScriptRoutine_TaskFourStepToward_ApplySignedStep | Jump to ScriptRoutine_TaskFourStepToward_ApplySignedStep to continue this routine. | ||||||
|
Negate the stored direction / step delta so the entity walks the other way.
|
||||||||
| ScriptRoutine_TaskFourStepToward_NegateDirection | CBB8 | PUSH AF | Stash AF on the stack. | |||||
| CBB9 | LD A,(IX+$09) | Load A with the current entity's direction / state. | ||||||
| CBBC | NEG | Negate A (flip a delta/direction). | ||||||
| CBBE | LD (IX+$09),A | Set the current entity's direction / state. | ||||||
| CBC1 | POP AF | Restore AF from the stack. | ||||||
| CBC2 | RET | Return. | ||||||
| Prev: CB1E | Up: Map | Next: CBC3 |