Prev: 35771 Up: Map Next: 35902
35841: Draw Gauge
Used by the routines at 35953, 36102, 37346 and 43945.
Input
A Lower byte of gauge
HL Screen location
Stash the lower gauge byte for later.
DrawGauge 35841 LD C,A C=A.
Stash the screen location for later, as we'll need it to gain the screen buffer address.
35842 PUSH HL Stash HL on the stack.
35843 CALL AttributeAddress Call AttributeAddress.
Restore the lower gauge byte.
35846 LD A,C A=C.
Rotate off the INK bits.
35847 RRCA Rotate the bits right three times (including the carry).
35848 RRCA
35849 RRCA
35850 AND %00011111 Keep only bits 0-4 (PAPER, BRIGHT and FLASH).
35852 JR Z,DrawGauge_Draw Jump to DrawGauge_Draw if the result is zero (i.e. empty/ blank).
35854 LD B,A B=A.
This moves along
DrawGauge_Find 35855 LD A,(HL) A=attribute byte.
35856 RLCA Rotate the bits left three times (including the carry).
35857 RLCA
35858 RLCA
35859 AND %00111000 Keep only bits 3-5 (INK).
35861 OR (HL)
35862 LD (HL),A Write A back to HL.
35863 INC HL Increment HL by one.
35864 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 35866 LD A,(HL) A=HL.
Remove the PAPER bits.
35867 AND %11000111 Keep only bits 0-2, 6-7.
35869 LD (HL),A Write A back to HL.
Store the attribute buffer address in DE.
35870 EX DE,HL Switch the DE and HL registers.
Restore the screen location for the screen buffer address call.
35871 POP HL Restore HL from the stack.
35872 CALL ScreenAddress Call ScreenAddress.
35875 LD A,E A=E.
35876 AND %00011111 Keep only bits 0-4.
35878 LD E,A E=A.
35879 LD A,L A=L.
35880 AND %11100000 Keep only bits 5-7.
35882 OR E
35883 LD L,A L=A.
Restore the lower gauge byte.
35884 LD A,C A=C.
The gradient lines are stored in the font at: 54559.
0 gradient-0
1 gradient-1
2 gradient-2
3 gradient-3
4 gradient-4
5 gradient-5
6 gradient-6
7 gradient-7
There are 8 gradient line images, so ensure the number reference is between 0-7.
35885 AND %00000111 Keep only bits 0-2.
The first value is 91 which corresponds to "gradient-0" (the smallest gradient).
35887 ADD A,91 A=A+91.
35889 CALL PrintScreen Call PrintScreen.
Restore the lower gauge byte.
35892 LD A,C A=C.
35893 CPL Flip the bits.
35894 AND %00000111 Keep only bits 0-2.
35896 RET NZ Return if the result is not zero.
35897 LD A,32 A=32.
35899 JP PrintScreen Jump to PrintScreen.
Prev: 35771 Up: Map Next: 35902