Prev: 28363 Up: Map Next: 28432
28382: Draw Gauge Line
Used by the routines at HandlerAccelerate and HandlerSteering.
Input
HL Screen location to draw the gauge
A Current Gauge Level
Before After
draw-gauge-before draw-gauge-after
DrawGaugeLine 28382 SRL A Scale the gauge level down by 4 to give the number of pixels to fill, in C.
28384 SRL A
28386 LD C,A
Decrease gauge count by 8 and keep looping around until what's left is < 8 - then handle this part separately.
DrawGaugeLine_Loop 28387 LD A,C Take 8 away from the pixel count.
28388 SUB 8
28390 JR C,DrawGaugeScreen_Last If gauge count < 8 then jump to DrawGaugeScreen_Last.
28392 LD C,A Keep the remaining pixel count in C.
28393 LD A,255 Set a full line of pixels, 255.
28395 CALL DrawGaugeScreen Draw a full cell of the gauge using DrawGaugeScreen.
28398 JR DrawGaugeLine_Loop Jump to DrawGaugeLine_Loop.
Handles drawing the last section of the gauge level.
DrawGaugeScreen_Last 28400 LD B,0 Create an offset in BC (B=0 C=gauge count).
28402 PUSH HL Stash the gauge screen location temporarily.
28403 LD HL,28423 Point HL at the gauge data (GaugeData + the remaining pixel count).
28406 ADD HL,BC
28407 LD A,(HL) Fetch the pixels for the end of the gauge.
28408 POP HL Restore the gauge screen location from the stack.
28409 CALL DrawGaugeScreen Call DrawGaugeScreen.
28412 XOR A A=0 (no pixels - i.e. masking).
Writes A to the screen.
DrawGaugeScreen 28413 PUSH HL Stash the gauge screen location temporarily.
28414 LD B,7 B=7 (counter for number of lines to draw).
DrawGaugeScreen_Loop 28416 LD (HL),A Write A to the screen location held by HL.
28417 INC H Increment H by one to move onto the next row.
28418 DJNZ DrawGaugeScreen_Loop Decrease counter by one and loop back to DrawGaugeScreen_Loop until counter is zero.
28420 POP HL Restore the original gauge screen location from the stack.
28421 INC L Increment L by one to move onto the next column.
28422 RET Return.
Gauge data; each value corresponds to a "full" line for 9 decreasing values. This completes the "end" section when drawing a gauge line.
GaugeData 28423 DEFB 0 udg28423_56x4
28424 DEFB 128
28425 DEFB 192
28426 DEFB 224
28427 DEFB 240
28428 DEFB 248
28429 DEFB 252
28430 DEFB 254
28431 DEFB 255
Prev: 28363 Up: Map Next: 28432