Prev: 8D05 Up: Map Next: 8D73
8D0F: Move the horizontal guardians in the current cavern
Used by the routine at 870E.
8D0F LD IY,$80BE Point IY at the first byte of the first horizontal guardian definition at 80BE
8D13 LD DE,$0007 Prepare DE for addition (there are 7 bytes in a guardian definition)
The guardian-moving loop begins here.
8D16 LD A,(IY+$00) Pick up the first byte of the guardian definition
8D19 CP $FF Have we dealt with all the guardians yet?
8D1B RET Z Return if so
8D1C OR A Is this guardian definition blank?
8D1D JR Z,$8D6F If so, skip it and consider the next one
8D1F LD A,($80BD) Pick up the value of the game clock at 80BD
8D22 AND $04 Move bit 2 (which is toggled on each pass through the main loop) to bit 7 and clear all the other bits
8D24 RRCA
8D25 RRCA
8D26 RRCA
8D27 AND (IY+$00) Combine this bit with bit 7 of the first byte of the guardian definition, which specifies the guardian's animation speed: 0=normal, 1=slow
8D2A JR NZ,$8D6F Jump to consider the next guardian if this one is not due to be moved on this pass
The guardian will be moved on this pass.
8D2C LD A,(IY+$04) Pick up the current animation frame (0-7)
8D2F CP $03 Is it 3 (the terminal frame for a guardian moving right)?
8D31 JR Z,$8D43 Jump if so to move the guardian right across a cell boundary or turn it round
8D33 CP $04 Is the current animation frame 4 (the terminal frame for a guardian moving left)?
8D35 JR Z,$8D5A Jump if so to move the guardian left across a cell boundary or turn it round
8D37 JR NC,$8D3E Jump if the animation frame is 5, 6 or 7
8D39 INC (IY+$04) Increment the animation frame (this guardian is moving right)
8D3C JR $8D6F Jump forward to consider the next guardian
8D3E DEC (IY+$04) Decrement the animation frame (this guardian is moving left)
8D41 JR $8D6F Jump forward to consider the next guardian
8D43 LD A,(IY+$01) Pick up the LSB of the address of the guardian's location in the attribute buffer at 5C00
8D46 CP (IY+$06) Has the guardian reached the rightmost point in its path?
8D49 JR NZ,$8D51 Jump if not
8D4B LD (IY+$04),$07 Set the animation frame to 7 (turning the guardian round to face left)
8D4F JR $8D6F Jump forward to consider the next guardian
8D51 LD (IY+$04),$00 Set the animation frame to 0 (the initial frame for a guardian moving right)
8D55 INC (IY+$01) Increment the guardian's x-coordinate (moving it right across a cell boundary)
8D58 JR $8D6F Jump forward to consider the next guardian
8D5A LD A,(IY+$01) Pick up the LSB of the address of the guardian's location in the attribute buffer at 5C00
8D5D CP (IY+$05) Has the guardian reached the leftmost point in its path?
8D60 JR NZ,$8D68 Jump if not
8D62 LD (IY+$04),$00 Set the animation frame to 0 (turning the guardian round to face right)
8D66 JR $8D6F Jump forward to consider the next guardian
8D68 LD (IY+$04),$07 Set the animation frame to 7 (the initial frame for a guardian moving left)
8D6C DEC (IY+$01) Decrement the guardian's x-coordinate (moving it left across a cell boundary)
The current guardian definition has been dealt with. Time for the next one.
8D6F ADD IY,DE Point IY at the first byte of the next horizontal guardian definition
8D71 JR $8D16 Jump back to deal with the next horizontal guardian
Prev: 8D05 Up: Map Next: 8D73