Manic Miner: Routine at 8DAA

| Routines

8DAA: Draw the horizontal guardians in the current cavern

Used by the routine at 870E.
8DAA | LD IY,$80BE | Point IY at the first byte of the first horizontal guardian definition at 80BE
The guardian-drawing loop begins here.
8DAE | LD A,(IY+$00) | Pick up the first byte of the guardian definition
8DB1 | CP $FF | Have we dealt with all the guardians yet?
8DB3 | RET Z | Return if so
8DB4 | OR A | Is this guardian definition blank?
8DB5 | JR Z,$8DF1 | If so, skip it and consider the next one
8DB7 | LD DE,$001F | Prepare DE for addition
8DBA | LD L,(IY+$01) | Point HL at the address of the guardian's location in the attribute buffer at 5C00
8DBD | LD H,(IY+$02)
8DC0 | AND $7F | Reset bit 7 (which specifies the animation speed) of the attribute byte, ensuring no FLASH
8DC2 | LD (HL),A | Set the attribute bytes for the guardian in the buffer at 5C00
8DC3 | INC HL
8DC4 | LD (HL),A
8DC5 | ADD HL,DE
8DC6 | LD (HL),A
8DC7 | INC HL
8DC8 | LD (HL),A
8DC9 | LD C,$01 | Prepare C for the call to the drawing routine at 8FF4 later on
8DCB | LD A,(IY+$04) | Pick up the animation frame (0-7)
8DCE | RRCA | Multiply it by 32
8DCF | RRCA
8DD0 | RRCA
8DD1 | LD E,A | Copy the result to E
8DD2 | LD A,($8407) | Pick up the number of the current cavern from 8407
8DD5 | CP $07 | Are we in one of the first seven caverns?
8DD7 | JR C,$8DE3 | Jump if so
8DD9 | CP $09 | Are we in The Endorian Forest?
8DDB | JR Z,$8DE3 | Jump if so
8DDD | CP $0F | Are we in The Sixteenth Cavern?
8DDF | JR Z,$8DE3 | Jump if so
8DE1 | SET 7,E | Add 0x80 to E (the horizontal guardians in this cavern use frames 4-7 only)
8DE3 | LD D,$81 | Point DE at the graphic data for the appropriate guardian sprite (at 8100+E)
8DE5 | LD L,(IY+$01) | Point HL at the address of the guardian's location in the screen buffer at 6000
8DE8 | LD H,(IY+$03)
8DEB | CALL $8FF4 | Draw the guardian to the screen buffer at 6000
8DEE | JP NZ,$8D06 | Kill Willy if the guardian collided with him
The current guardian definition has been dealt with. Time for the next one.
8DF1 | LD DE,$0007 | Point IY at the first byte of the next horizontal guardian definition
8DF4 | ADD IY,DE
8DF6 | JR $8DAE | Jump back to deal with the next horizontal guardian