![]() |
Routines |
| Prev: D56A | Up: Map | Next: D5ED |
|
Update the collectible counter for this entity's current state.
|
||||||||
| ScriptRoutine_CollectibleScanCounter | D59E | LD A,($72BC) | Load A with the collectible counter (CollectibleCounter). | |||||
| D5A1 | CP $80 | Is collectible counter equal to 80? If not, jump to ScriptRoutine_CollectibleScanCounter_DecCounterScan. | ||||||
| D5A3 | JR NZ,ScriptRoutine_CollectibleScanCounter_DecCounterScan | |||||||
| D5A5 | LD HL,$D3D6 | Point HL at the dialogue/message table (D3D6). | ||||||
| D5A8 | JP ScriptInstruction | Jump to ScriptInstruction to execute the script instruction at HL. | ||||||
|
Tick the counter and, if the crusher (StateData_Complex_16) is live, measure its X delta.
|
||||||||
| ScriptRoutine_CollectibleScanCounter_DecCounterScan | D5AB | DEC A | Step collectible counter back by one. | |||||
| D5AC | LD ($72BC),A | Set the collectible counter (CollectibleCounter). | ||||||
| D5AF | LD IY,$8FC9 | Point IY at the crusher entity (StateData_Complex_16). | ||||||
| D5B3 | LD A,(IY+$00) | Load A with the referenced entity's entity type. | ||||||
| D5B6 | OR A | Is the referenced entity's entity type zero? If so, jump to AdvanceScriptInstruction to run the next script instruction. | ||||||
| D5B7 | JP Z,AdvanceScriptInstruction | |||||||
| D5BA | BIT 5,(IY+$01) | Is bit 05 of the referenced entity's flags byte 1 set? If so, jump to AdvanceScriptInstruction. | ||||||
| D5BE | JP NZ,AdvanceScriptInstruction | |||||||
| D5C1 | LD A,(IY+$07) | Load A with the referenced entity's x-coordinate. | ||||||
| D5C4 | INC A | Advance referenced entity's x-coordinate by one. | ||||||
| D5C5 | SUB (IX+$07) | Subtract the current entity's x-coordinate from A. | ||||||
| D5C8 | PUSH AF | Stash AF on the stack. | ||||||
| D5C9 | JR NC,ScriptRoutine_CollectibleScanCounter_TestAbsDeltaX | Jump to ScriptRoutine_CollectibleScanCounter_TestAbsDeltaX if the result did not underflow. | ||||||
| D5CB | NEG | Negate A (flip a delta/direction). | ||||||
|
Only react when the crusher is within 0A characters horizontally.
|
||||||||
| ScriptRoutine_CollectibleScanCounter_TestAbsDeltaX | D5CD | CP $0A | Is referenced entity's x-coordinate less than 0A? If so, jump to ScriptRoutine_CollectibleScanCounter_PickScriptBySign. | |||||
| D5CF | JR C,ScriptRoutine_CollectibleScanCounter_PickScriptBySign | |||||||
| D5D1 | POP AF | Restore AF from the stack. | ||||||
| D5D2 | JP AdvanceScriptInstruction | Jump to AdvanceScriptInstruction to run the next script instruction. | ||||||
|
Pick the left or right reaction script from the sign of the crusher X delta.
|
||||||||
| ScriptRoutine_CollectibleScanCounter_PickScriptBySign | D5D5 | POP AF | Restore AF from the stack. | |||||
| D5D6 | JR C,ScriptRoutine_CollectibleScanCounter_RunScript | Jump to ScriptRoutine_CollectibleScanCounter_RunScript if the result underflowed. | ||||||
| D5D8 | LD HL,$D40E | Point HL at collectible/score table data D40E. | ||||||
| D5DB | JR ScriptRoutine_CollectibleScanCounter_RandomiseCounterAndRun | Jump to ScriptRoutine_CollectibleScanCounter_RandomiseCounterAndRun to continue this routine. | ||||||
|
Use the leftward crusher-reaction script at D406.
|
||||||||
| ScriptRoutine_CollectibleScanCounter_RunScript | D5DD | LD HL,$D406 | Point HL at collectible/score table data D406. | |||||
|
Reseed the counter to 0A plus a random and run the chosen reaction script.
|
||||||||
| ScriptRoutine_CollectibleScanCounter_RandomiseCounterAndRun | D5E0 | LD A,$32 | Load A with 32 as the PseudoRandom random maximum. | |||||
| D5E2 | CALL PseudoRandom | Call PseudoRandom to pick a pseudo-random value. | ||||||
| D5E5 | ADD A,$0A | Add 0A to A (adjust a collectible/timer value). | ||||||
| D5E7 | LD ($72BC),A | Set the collectible counter (CollectibleCounter). | ||||||
| D5EA | JP ScriptInstruction | Jump to ScriptInstruction to execute the script instruction at HL. | ||||||
| Prev: D56A | Up: Map | Next: D5ED |