Prev: CC63 Up: Map Next: CCBA
CC77: Colour the fuel gauge, and move its fuel column a row towards the fuel level
Used by the routines at start_landscape and play.
Called each pass by the play loop (play) and twice a pass in the death sequence. The fuel inside the gauge is a column three to five pixels wide that runs from the bottom of the gauge up to the level shown. It is never redrawn: each step towards the fuel's level toggles (XOR) two rows: $03,$80 (three pixels in the middle, x $F6-$F8) at one row and $04,$40 (the two pixels either side, $F5 and $F9) at the row below. Two neighbouring steps overlap, so every row inside the column ends up with all five pixels and only the top row has the narrow three: a rounded top, kept up to date by touching two rows a pass.
Going up (filling), the toggled rows are the new level and the one below it; going down (burning), the old level and the one below, which takes the top row's three pixels away and leaves the next row's narrow three as the new top.
update_fuel_gauge CC77 CALL flash_fuel_gauge First the gauge's colour (flash_fuel_gauge).
CC7A LD A,(fuel_shown) Level shown against the fuel's level: the same, then see whether it is empty.
CC7D LD B,A
CC7E LD A,($CC4C)
CC81 SUB B
CC82 JR Z,check_fuel_empty
CC84 DEC B Filling (level going up the screen): the rows from the new level; burning: from the old level, and the new level is one row lower.
CC85 LD H,B
CC86 BIT 7,A
CC88 JR NZ,update_fuel_gauge_0
CC8A INC B
CC8B LD H,B
CC8C INC B
update_fuel_gauge_0 CC8D LD A,B The new level shown.
CC8E LD (fuel_shown),A
CC91 LD A,H The first row: x $F0, the middle three pixels toggled.
CC92 LD (scratch_count),A
CC95 LD L,$F0
CC97 CALL pixel_to_screen
CC9A LD A,$03
CC9C XOR (HL)
CC9D LD (HL),A
CC9E INC HL (Second byte of that row.)
CC9F LD A,$80
CCA1 XOR (HL)
CCA2 LD (HL),A
CCA3 LD A,(scratch_count) Not below the bottom of the tube.
CCA6 CP $BC
CCA8 RET NC
CCA9 INC A The row below: the two outer pixels toggled.
CCAA LD H,A
CCAB LD L,$F0
CCAD CALL pixel_to_screen
CCB0 LD A,$04
CCB2 XOR (HL)
CCB3 LD (HL),A
CCB4 INC HL
CCB5 LD A,$40
CCB7 XOR (HL)
CCB8 LD (HL),A
CCB9 RET
Prev: CC63 Up: Map Next: CCBA