Routines |
Prev: CED4 | Up: Map | Next: CF3E |
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 CE4F 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:
|
||||
CF0B | LD A,($EAE9) | Currently active spell | ||
CF0E | CP $09 | ...Is it the UNSEEN spell? | ||
CF10 | JR NZ,$CF1D | |||
CF12 | LD A,($EAAA) | If so get the incremental game counter | ||
CF15 | AND $0F | Check if any of bits 0-3 set | ||
CF17 | JP NZ,$CE4F | If so, randomize the movement pattern | ||
CF1A | JP $D04B | Switch back to normal movement every 16 frames | ||
Jump here from CE2E 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:
|
||||
CF1D | LD A,($EB4A) | Retrieve vertical position within current room, in pixels, from top of room playing area | ||
CF20 | LD C,A | Store in C register | ||
CF21 | LD A,($EAC1) | Maroc's vertical (Y-axis) screen position | ||
CF24 | SUB C | Subtract graphic position to get vertical offset | ||
CF25 | RLA | Shift bit 7 to determine if creature is higher or lower than Maroc on the screen | ||
CF26 | SBC A,A | After subtracting, A register will either contain 255 (-1) = below Maroc, or 0 = above Maroc | ||
CF27 | XOR $07 | Value will now either be 7 or -7 (248) | ||
CF29 | LD ($EB4D),A | Set as creature's vertical movement speed/direction | ||
Calculate horizontal position in relation to Maroc:
|
||||
CF2C | LD A,($EB48) | Retrieve horizontal position within current room, in 4-pixel/half-character steps | ||
CF2F | LD C,A | |||
CF30 | LD A,($EAC0) | Maroc's horizontal (X-axis) screen position | ||
CF33 | SUB C | Subtract graphic position to get horizontal offset | ||
CF34 | RLA | Precision used to calculate = 2 pixels whereas the difference is in 4-pixel steps, so double the value | ||
CF35 | SBC A,A | After subtracting, A register will either contain 255 (-1) = to the right of Maroc, or 0 = to the left of Maroc | ||
CF36 | XOR $07 | Value will now either be 7 or -7 (248) | ||
CF38 | LD ($EB4C),A | Store as creature's horizontal movement speed/direction | ||
CF3B | JP $D04B |
Prev: CED4 | Up: Map | Next: CF3E |