![]() |
Routines |
| Prev: 50747 | Up: Map | Next: 50958 |
|
Used by the routine at Update_Task_Three_Entities.
Update Task Three Helpers for the current Thing Upstairs task.
|
||||
| Update_Task_Three_Helpers | 50780 | LD IX,36627 | Point IX at the first Slimies entity (StateData_Complex_03). | |
| 50784 | LD DE,14 | Each entity record is 0014 bytes long, then load that length into DE. | ||
| 50787 | LD B,4 | Load B with 4 as a loop counter. | ||
|
Scan each upstairs helper: skip inactive / low slots, then randomly wander, climb, or drop a room.
|
||||
| Update_Task_Three_Helpers_Scan | 50789 | PUSH BC | Stash BC on the stack. | |
| 50790 | LD A,(IX+1) | Load A with the current entity's flags byte 1. | ||
| 50793 | AND %11100000 | Keep only the top bits 224 of the flag/coordinate in A. | ||
| 50795 | JR NZ,Update_Task_Three_Helpers_AdvanceSlot | If the result was non-zero, jump to Update_Task_Three_Helpers_AdvanceSlot. | ||
| 50797 | LD A,(IX+6) | Load A with the current entity's y-extent. | ||
| 50800 | CP 34 | Is the current entity's y-extent less than 34? If so, jump to Update_Task_Three_Helpers_AdvanceSlot. | ||
| 50802 | JR C,Update_Task_Three_Helpers_AdvanceSlot | |||
| 50804 | BIT 7,(IX+0) | Is bit 7 of the current entity's entity type set? If not, call Update_Task_Three_Helpers_MaybeSetFlagBit2. | ||
| 50808 | CALL Z,Update_Task_Three_Helpers_MaybeSetFlagBit2 | |||
| 50811 | LD A,21 | Load A with 21. | ||
| 50813 | CALL PseudoRandom | Call PseudoRandom to pick a pseudo-random value. | ||
| 50816 | OR A | Is 21 zero? If so, jump to Update_Task_Three_Helpers_ClearTypeBit7. | ||
| 50817 | JR Z,Update_Task_Three_Helpers_ClearTypeBit7 | |||
| 50819 | CP 6 | Is 21 less than 6? If so, jump to Update_Task_Three_Helpers_TryMoveLeft. | ||
| 50821 | JR C,Update_Task_Three_Helpers_TryMoveLeft | |||
| 50823 | CP 11 | Is 21 less than 11? If so, jump to Update_Task_Three_Helpers_TryMoveRight. | ||
| 50825 | JR C,Update_Task_Three_Helpers_TryMoveRight | |||
| 50827 | CP 16 | Is 21 less than 16? If so, jump to Update_Task_Three_Helpers_MoveRoomDown. | ||
| 50829 | JR C,Update_Task_Three_Helpers_MoveRoomDown | |||
| 50831 | LD A,(IX+4) | Load A with the current entity's room index. | ||
| 50834 | CP 5 | Is the current entity's room index equal to 5? If so, jump to Update_Task_Three_Helpers_AdvanceSlot. | ||
| 50836 | JR Z,Update_Task_Three_Helpers_AdvanceSlot | |||
| 50838 | INC (IX+5) | Move this entity one character down. | ||
| 50841 | INC (IX+6) | |||
| 50844 | INC (IX+4) | Advance this entity into the next room. | ||
| 50847 | JR Update_Task_Three_Helpers_AdvanceSlot | Jump to Update_Task_Three_Helpers_AdvanceSlot to advance to the next helper entity. | ||
|
Move this helper up one room (unless already in room 1).
|
||||
| Update_Task_Three_Helpers_MoveRoomDown | 50849 | LD A,(IX+4) | Load A with the current entity's room index. | |
| 50852 | CP 1 | Is the current entity's room index equal to 1? If so, jump to Update_Task_Three_Helpers_AdvanceSlot. | ||
| 50854 | JR Z,Update_Task_Three_Helpers_AdvanceSlot | |||
| 50856 | DEC (IX+5) | Move this entity one character up. | ||
| 50859 | DEC (IX+6) | |||
| 50862 | DEC (IX+4) | Move this entity back one room. | ||
| 50865 | JR Update_Task_Three_Helpers_AdvanceSlot | Jump to Update_Task_Three_Helpers_AdvanceSlot to advance to the next helper entity. | ||
|
Try a left wander step, respecting the high-X and low-X bounds.
|
||||
| Update_Task_Three_Helpers_TryMoveLeft | 50867 | LD A,(IX+7) | Load A with the current entity's x-coordinate. | |
| 50870 | CP 224 | Is the current entity's x-coordinate less than 224? If so, jump to Update_Task_Three_Helpers_LeftBoundCheck. | ||
| 50872 | JR C,Update_Task_Three_Helpers_LeftBoundCheck | |||
| 50874 | CP 228 | Is the current entity's x-coordinate less than 228? If so, jump to Update_Task_Three_Helpers_AdvanceSlot. | ||
| 50876 | JR C,Update_Task_Three_Helpers_AdvanceSlot | |||
| 50878 | JR Update_Task_Three_Helpers_DecX | Jump to Update_Task_Three_Helpers_DecX to decrease the helper's x-coordinate. | ||
|
Left-bound check: below 67 step right instead of left.
|
||||
| Update_Task_Three_Helpers_LeftBoundCheck | 50880 | CP 67 | Is the current entity's x-coordinate less than 67? If so, jump to Update_Task_Three_Helpers_IncX. | |
| 50882 | JR C,Update_Task_Three_Helpers_IncX | |||
|
Nudge the helper one character left.
|
||||
| Update_Task_Three_Helpers_DecX | 50884 | DEC (IX+7) | Move this entity one character left. | |
| 50887 | DEC (IX+8) | |||
| 50890 | JR Update_Task_Three_Helpers_AdvanceSlot | Jump to Update_Task_Three_Helpers_AdvanceSlot to advance to the next helper entity. | ||
|
Try a right wander step, respecting the high-X and mid-X bounds.
|
||||
| Update_Task_Three_Helpers_TryMoveRight | 50892 | LD A,(IX+7) | Load A with the current entity's x-coordinate. | |
| 50895 | CP 224 | Is the current entity's x-coordinate less than 224? If so, jump to Update_Task_Three_Helpers_RightBoundCheck. | ||
| 50897 | JR C,Update_Task_Three_Helpers_RightBoundCheck | |||
| 50899 | CP 251 | Is the current entity's x-coordinate less than 251? If not, jump to Update_Task_Three_Helpers_AdvanceSlot. | ||
| 50901 | JR NC,Update_Task_Three_Helpers_AdvanceSlot | |||
| 50903 | JR Update_Task_Three_Helpers_IncX | Jump to Update_Task_Three_Helpers_IncX to increase the helper's x-coordinate. | ||
|
Right-bound check: at or beyond 187 step left instead of right.
|
||||
| Update_Task_Three_Helpers_RightBoundCheck | 50905 | CP 187 | Is the current entity's x-coordinate less than 187? If not, jump to Update_Task_Three_Helpers_DecX. | |
| 50907 | JR NC,Update_Task_Three_Helpers_DecX | |||
|
Nudge the helper one character right.
|
||||
| Update_Task_Three_Helpers_IncX | 50909 | INC (IX+7) | Move this entity one character right. | |
| 50912 | INC (IX+8) | |||
|
Advance to the next helper slot and loop until all 4 are done.
|
||||
| Update_Task_Three_Helpers_AdvanceSlot | 50915 | ADD IX,DE | Advance IX to the next entity record. | |
| 50917 | POP BC | Restore BC from the stack. | ||
| 50918 | DEC B | Step the loop counter in B back by one. | ||
| 50919 | JP NZ,Update_Task_Three_Helpers_Scan | If the result was non-zero, jump to Update_Task_Three_Helpers_Scan. | ||
| 50922 | RET | Return. | ||
|
Clear type bit 7 (end the 'loose' pose) and advance.
|
||||
| Update_Task_Three_Helpers_ClearTypeBit7 | 50923 | RES 7,(IX+0) | Reset bit 7 of the current entity's entity type. | |
| 50927 | JR Update_Task_Three_Helpers_AdvanceSlot | Jump to Update_Task_Three_Helpers_AdvanceSlot to advance to the next helper entity. | ||
|
When X is below 224, clear type bit 7 and raise SlimyLoose on TaskThreeFlags.
|
||||
| Update_Task_Three_Helpers_MaybeSetFlagBit2 | 50929 | LD A,(IX+7) | Load A with the current entity's x-coordinate. | |
| 50932 | CP 224 | Is the current entity's x-coordinate less than 224? If not, jump to Update_Task_Three_Helpers_MaybeSetTypeBit7. | ||
| 50934 | JR NC,Update_Task_Three_Helpers_MaybeSetTypeBit7 | |||
| 50936 | RES 7,(IX+0) | Reset bit 7 of the current entity's entity type. | ||
| 50940 | LD HL,29366 | Point HL at the task-three flags (TaskThreeFlags). | ||
| 50943 | SET 2,(HL) | Set SlimyLoose (bit 2 of TaskThreeFlags. 55559 skips that line while set). | ||
| 50945 | RET | Return. | ||
|
Rarely set type bit 7 so this helper can enter the SlimyLoose path.
|
||||
| Update_Task_Three_Helpers_MaybeSetTypeBit7 | 50946 | LD A,10 | Load A with 10. | |
| 50948 | CALL PseudoRandom | Call PseudoRandom to pick a pseudo-random value. | ||
| 50951 | OR A | Is the random result in A zero? If not, return. | ||
| 50952 | RET NZ | |||
| 50953 | SET 7,(IX+0) | Set bit 7 of the current entity's entity type. | ||
| 50957 | RET | Return. | ||
| Prev: 50747 | Up: Map | Next: 50958 |