Prev: 8E75 Up: Map Next: 8F63
8EF1: Move and draw the vertical guardians in the current cavern
Used by the routine at 870E.
8EF1 LD IY,$80DD Point IY at the first byte of the first vertical guardian definition at 80DD
The guardian-moving loop begins here.
8EF5 LD A,(IY+$00) Pick up the first byte of the guardian definition
8EF8 CP $FF Have we dealt with all the guardians yet?
8EFA RET Z Return if so
8EFB INC (IY+$01) Increment the guardian's animation frame
8EFE RES 2,(IY+$01) Reset the animation frame to 0 if it overflowed to 4
8F02 LD A,(IY+$02) Pick up the guardian's pixel y-coordinate
8F05 ADD A,(IY+$04) Add the current y-coordinate increment
8F08 CP (IY+$05) Has the guardian reached the highest point of its path (minimum y-coordinate)?
8F0B JR C,$8F17 If so, jump to change its direction of movement
8F0D CP (IY+$06) Has the guardian reached the lowest point of its path (maximum y-coordinate)?
8F10 JR NC,$8F17 If so, jump to change its direction of movement
8F12 LD (IY+$02),A Update the guardian's pixel y-coordinate
8F15 JR $8F1F
8F17 LD A,(IY+$04) Negate the y-coordinate increment; this changes the guardian's direction of movement
8F1A NEG
8F1C LD (IY+$04),A
Now that the guardian's movement has been dealt with, time to draw it.
8F1F LD A,(IY+$02) Pick up the guardian's pixel y-coordinate
8F22 AND $7F Point DE at the entry in the screen buffer address lookup table at 8300 that corresponds to the guardian's pixel y-coordinate
8F24 RLCA
8F25 LD E,A
8F26 LD D,$83
8F28 LD A,(DE) Point HL at the address of the guardian's location in the screen buffer at 6000
8F29 OR (IY+$03)
8F2C LD L,A
8F2D INC DE
8F2E LD A,(DE)
8F2F LD H,A
8F30 LD A,(IY+$01) Pick up the guardian's animation frame (0-3)
8F33 RRCA Multiply it by 32
8F34 RRCA
8F35 RRCA
8F36 LD E,A Point DE at the graphic data for the appropriate guardian sprite (at 8100+A)
8F37 LD D,$81
8F39 LD C,$01 Draw the guardian to the screen buffer at 6000
8F3B CALL $8FF4
8F3E JP NZ,$8D06 Kill Willy if the guardian collided with him
8F41 LD A,(IY+$02) Pick up the guardian's pixel y-coordinate
8F44 AND $40 Point HL at the address of the guardian's location in the attribute buffer at 5C00
8F46 RLCA
8F47 RLCA
8F48 ADD A,$5C
8F4A LD H,A
8F4B LD A,(IY+$02)
8F4E RLCA
8F4F RLCA
8F50 AND $E0
8F52 OR (IY+$03)
8F55 LD L,A
8F56 LD A,(IY+$00) Pick up the guardian's attribute byte
8F59 CALL $8E5F Set the attribute bytes for the guardian
The current guardian definition has been dealt with. Time for the next one.
8F5C LD DE,$0007 Point IY at the first byte of the next vertical guardian definition
8F5F ADD IY,DE
8F61 JR $8EF5 Jump back to deal with the next vertical guardian
Prev: 8E75 Up: Map Next: 8F63