Manic Miner: Routine at 8A3C

| Routines

8A3C: Decrease the air remaining in the current cavern

Used by the routines at 870E, 8D73 and 9028. Returns with the zero flag set if there is no air remaining.
8A3C | LD A,($80BD) | Update the game clock at 80BD
8A3F | SUB $04
8A41 | LD ($80BD),A
8A44 | CP $FC | Was it just decreased from zero?
8A46 | JR NZ,$8A55 | Jump if not
8A48 | LD A,($80BC) | Pick up the value of the remaining air supply from 80BC
8A4B | CP $24 | Has the air supply run out?
8A4D | RET Z | Return (with the zero flag set) if so
8A4E | DEC A | Decrement the air supply at 80BC
8A4F | LD ($80BC),A
8A52 | LD A,($80BD) | Pick up the value of the game clock at 80BD
8A55 | AND $E0 | A=INT(A/32); this value specifies how many pixels to draw from left to right in the cell at the right end of the air bar
8A57 | RLCA
8A58 | RLCA
8A59 | RLCA
8A5A | LD E,$00 | Initialise E to 0 (all bits reset)
8A5C | OR A | Do we need to draw any pixels in the cell at the right end of the air bar?
8A5D | JR Z,$8A66 | Jump if not
8A5F | LD B,A | Copy the number of pixels to draw (1-7) to B
8A60 | RRC E | Set this many bits in E (from bit 7 towards bit 0)
8A62 | SET 7,E
8A64 | DJNZ $8A60
8A66 | LD A,($80BC) | Pick up the value of the remaining air supply from 80BC
8A69 | LD L,A | Set HL to the display file address at which to draw the top row of pixels in the cell at the right end of the air bar
8A6A | LD H,$52
8A6C | LD B,$04 | There are four rows of pixels to draw
8A6E | LD (HL),E | Draw the four rows of pixels at the right end of the air bar
8A6F | INC H
8A70 | DJNZ $8A6E
8A72 | XOR A | Reset the zero flag to indicate that there is still some air remaining; these instructions are redundant, since the zero flag is already reset at this point
8A73 | INC A
8A74 | RET |