Routines |
Prev: 52948 | Up: Map | Next: 53054 |
Creatures will move erratically and randomly, if the UNSEEN spell is active - except for the WRAITH and DEMON, who can sense the magic and use it to home in on Maroc's position.
You can see (in the animated image) that some creatures have a tendency to cluster towards the bottom right of the screen.
This is because the randomizer routine at 52815 generates:
These values are only very slightly skewed towards down & right, but the randomizer runs often, hence the visible result.
Check if the UNSEEN spell is active:
|
||||
53003 | LD A,(60137) | Currently active spell | ||
53006 | CP 9 | ...Is it the UNSEEN spell? | ||
53008 | JR NZ,53021 | |||
53010 | LD A,(60074) | If so get the incremental game counter | ||
53013 | AND 15 | Check if any of bits 0-3 set | ||
53015 | JP NZ,52815 | If so, randomize the movement pattern | ||
53018 | JP 53323 | Switch back to normal movement every 16 frames | ||
Jump here from 52782 if creature is DEMON or WRAITH and Maroc's active spell number >=4
These two creatures can 'sniff out' powerful magic.
Calculate vertical position in relation to Maroc:
|
||||
53021 | LD A,(60234) | Retrieve vertical position within current room, in pixels, from top of room playing area | ||
53024 | LD C,A | Store in C register | ||
53025 | LD A,(60097) | Maroc's vertical (Y-axis) screen position | ||
53028 | SUB C | Subtract graphic position to get vertical offset | ||
53029 | RLA | Shift bit 7 to determine if creature is higher or lower than Maroc on the screen | ||
53030 | SBC A,A | After subtracting, A register will either contain 255 (-1) = below Maroc, or 0 = above Maroc | ||
53031 | XOR 7 | Value will now either be 7 or -7 (248) | ||
53033 | LD (60237),A | Set as creature's vertical movement speed/direction | ||
Calculate horizontal position in relation to Maroc:
|
||||
53036 | LD A,(60232) | Retrieve horizontal position within current room, in 4-pixel/half-character steps | ||
53039 | LD C,A | |||
53040 | LD A,(60096) | Maroc's horizontal (X-axis) screen position | ||
53043 | SUB C | Subtract graphic position to get horizontal offset | ||
53044 | RLA | Precision used to calculate = 2 pixels whereas the difference is in 4-pixel steps, so double the value | ||
53045 | SBC A,A | After subtracting, A register will either contain 255 (-1) = to the right of Maroc, or 0 = to the left of Maroc | ||
53046 | XOR 7 | Value will now either be 7 or -7 (248) | ||
53048 | LD (60236),A | Store as creature's horizontal movement speed/direction | ||
53051 | JP 53323 |
Prev: 52948 | Up: Map | Next: 53054 |