Manic Miner: Routine at 8E75

| Routines

8E75: Move and draw the Skylabs in Skylab Landing Bay

Used by the routine at 870E.
8E75 | LD IY,$80DD | Point IY at the first byte of the first vertical guardian definition at 80DD
The Skylab-moving loop begins here.
8E79 | LD A,(IY+$00) | Pick up the first byte of the guardian definition
8E7C | CP $FF | Have we dealt with all the Skylabs yet?
8E7E | JP Z,$879F | If so, re-enter the main loop
8E81 | LD A,(IY+$02) | Pick up the Skylab's pixel y-coordinate
8E84 | CP (IY+$06) | Has it reached its crash site yet?
8E87 | JR NC,$8E91 | Jump if so
8E89 | ADD A,(IY+$04) | Increment the Skylab's y-coordinate (moving it downwards)
8E8C | LD (IY+$02),A
8E8F | JR $8EAF |
The Skylab has reached its crash site. Start or continue its disintegration.
8E91 | INC (IY+$01) | Increment the animation frame
8E94 | LD A,(IY+$01) | Pick up the animation frame
8E97 | CP $08 | Has the Skylab completely disintegrated yet?
8E99 | JR NZ,$8EAF | Jump if not
8E9B | LD A,(IY+$05) | Reset the Skylab's pixel y-coordinate
8E9E | LD (IY+$02),A
8EA1 | LD A,(IY+$03) | Add 8 to the Skylab's x-coordinate (wrapping around at the right side of the screen)
8EA4 | ADD A,$08
8EA6 | AND $1F
8EA8 | LD (IY+$03),A
8EAB | LD (IY+$01),$00 | Reset the animation frame to 0
Now that the Skylab's movement has been dealt with, time to draw it.
8EAF | LD E,(IY+$02) | Pick up the Skylab's pixel y-coordinate in E
8EB2 | RLC E | Point DE at the entry in the screen buffer address lookup table at 8300 that corresponds to the Skylab's pixel y-coordinate
8EB4 | LD D,$83
8EB6 | LD A,(DE) | Point HL at the address of the Skylab's location in the screen buffer at 6000
8EB7 | ADD A,(IY+$03)
8EBA | LD L,A
8EBB | INC DE
8EBC | LD A,(DE)
8EBD | LD H,A
8EBE | LD A,(IY+$01) | Pick up the animation frame (0-7)
8EC1 | RRCA | Multiply it by 32
8EC2 | RRCA
8EC3 | RRCA
8EC4 | LD E,A | Point DE at the graphic data for the corresponding Skylab sprite (at 8100+A)
8EC5 | LD D,$81
8EC7 | LD C,$01 | Draw the Skylab to the screen buffer at 6000
8EC9 | CALL $8FF4
8ECC | JP NZ,$8D07 | Kill Willy if the Skylab collided with him
8ECF | LD A,(IY+$02) | Point HL at the address of the Skylab's location in the attribute buffer at 5C00
8ED2 | AND $40
8ED4 | RLCA
8ED5 | RLCA
8ED6 | ADD A,$5C
8ED8 | LD H,A
8ED9 | LD A,(IY+$02)
8EDC | RLCA
8EDD | RLCA
8EDE | AND $E0
8EE0 | OR (IY+$03)
8EE3 | LD L,A
8EE4 | LD A,(IY+$00) | Pick up the Skylab's attribute byte
8EE7 | CALL $8E5F | Set the attribute bytes for the Skylab
The current guardian definition has been dealt with. Time for the next one.
8EEA | LD DE,$0007 | Point IY at the first byte of the next vertical guardian definition
8EED | ADD IY,DE
8EEF | JR $8E79 | Jump back to deal with the next Skylab