Prev: 8BBB Up: Map Next: 8C3E
8C01: Draw Gauge
Used by the routines at 8C71, 8D06, 91E2 and ABA9.
Input
A Lower byte of gauge
HL Screen location
Stash the lower gauge byte for later.
DrawGauge 8C01 LD C,A C=A.
Stash the screen location for later, as we'll need it to gain the screen buffer address.
8C02 PUSH HL Stash HL on the stack.
8C03 CALL AttributeAddress Call AttributeAddress.
Restore the lower gauge byte.
8C06 LD A,C A=C.
Rotate off the INK bits.
8C07 RRCA Rotate the bits right three times (including the carry).
8C08 RRCA
8C09 RRCA
8C0A AND %00011111 Keep only bits 0-4 (PAPER, BRIGHT and FLASH).
8C0C JR Z,DrawGauge_Draw Jump to DrawGauge_Draw if the result is zero (i.e. empty/ blank).
8C0E LD B,A B=A.
This moves along
DrawGauge_Find 8C0F LD A,(HL) A=attribute byte.
8C10 RLCA Rotate the bits left three times (including the carry).
8C11 RLCA
8C12 RLCA
8C13 AND %00111000 Keep only bits 3-5 (INK).
8C15 OR (HL)
8C16 LD (HL),A Write A back to HL.
8C17 INC HL Increment HL by one.
8C18 DJNZ DrawGauge_Find Decrease counter by one and loop back to DrawGauge_Find until counter is zero.
Fetch the attribute byte for where the gauge ends.
DrawGauge_Draw 8C1A LD A,(HL) A=HL.
Remove the PAPER bits.
8C1B AND %11000111 Keep only bits 0-2, 6-7.
8C1D LD (HL),A Write A back to HL.
Store the attribute buffer address in DE.
8C1E EX DE,HL Switch the DE and HL registers.
Restore the screen location for the screen buffer address call.
8C1F POP HL Restore HL from the stack.
8C20 CALL ScreenAddress Call ScreenAddress.
8C23 LD A,E A=E.
8C24 AND %00011111 Keep only bits 0-4.
8C26 LD E,A E=A.
8C27 LD A,L A=L.
8C28 AND %11100000 Keep only bits 5-7.
8C2A OR E
8C2B LD L,A L=A.
Restore the lower gauge byte.
8C2C LD A,C A=C.
The gradient lines are stored in the font at: D51F.
00 gradient-0
01 gradient-1
02 gradient-2
03 gradient-3
04 gradient-4
05 gradient-5
06 gradient-6
07 gradient-7
There are 8 gradient line images, so ensure the number reference is between 00-07.
8C2D AND %00000111 Keep only bits 0-2.
The first value is 5B which corresponds to "gradient-0" (the smallest gradient).
8C2F ADD A,$5B A=A+5B.
8C31 CALL PrintScreen Call PrintScreen.
Restore the lower gauge byte.
8C34 LD A,C A=C.
8C35 CPL Flip the bits.
8C36 AND %00000111 Keep only bits 0-2.
8C38 RET NZ Return if the result is not zero.
8C39 LD A,$20 A=20.
8C3B JP PrintScreen Jump to PrintScreen.
Prev: 8BBB Up: Map Next: 8C3E