Prev: D651 Up: Map Next: D6A4
D67B: Prepare a warlock to appear in the room
Input
B Warlock number (1-7) - calculated from lookup table at C6A4
warlock appearing in the room
The previous routine has determined that it's time for a warlock to appear in the room.
As long as this level's warlock hasn't been destroyed, the routine sets the warlock's screen position, movement direction, and speed.
D67B LD A,B Get warlock number (between 1 and 7 from table at 6C7C)
D67C CALL $E16A Set up warlock data in working buffer at EB43
D67F LD HL,$EAF6 Get address holding the room's vertical pixel position
D682 INC HL Held in next (high) byte, so advance one address
D683 LD A,(HL) Get the room position byte (top of room)
D684 ADD A,$1C Add 28 pixels - the warlock's vertical position remains the same, even as it floats across the screen between the side and back walls
D686 LD ($EB4A),A Store this value as the warlock's vertical pixel position
Determine warlock's (horizontal) speed and direction. Values can be between -3 and +4. A value of 0 means the warlock stays in one place.
D689 AND $07 The A register contains the vertical room pixel position, used here to provide the variety for the warlock's movement. Keep bits 0-2 (values 0-7)
D68B SUB $03 Subtract 3, to give a possible values of -3 to +4 (negative numbers = left, positive numbers = right)
D68D LD ($EB4C),A Store as warlock's (horizontal) speed (and direction)
D690 LD HL,($EB44) Address pointer to this warlock's data set (at 6C7C)
D693 INC HL
D694 LD A,(HL) Get the second byte of the warlock's data set
D695 CP $00
D697 JR NZ,$D6CF The second byte tells us if the warlock is still alive on this level. If this byte ISN'T 0, it means Maroc has destroyed it, so jump out of the routine here if this is the case
D699 INC HL Move the address pointer along to the sixth byte of the warlock's data set.
D69A INC HL
D69B INC HL
D69C INC HL
D69D LD A,(HL) This is this warlock's "aggression" stat, which affects
- the likelihood of it appearing
- the frequency of missiles being fired
D69E LD ($EBAD),A Store in warlock active data buffer
D6A1 JP $D6B0
Prev: D651 Up: Map Next: D6A4