Prev: 42944 Up: Map Next: 43057
42961: Draw Line
Used by the routine at DrawDirectionGauge.
Draws a line into the buffer at 62743 starting from the centre of the dial. The line is two pixels wide, and it is plotted by adding the components of the direction to two running totals; each carry moves the line by a pixel line (using the first component) or by a pixel along a line (using the second). The code is patched according to the signs of the components.
Input
B The number of pixels to plot
DE The first component, which moves the line up or down
HL' The second component, which moves the line left or right
DrawLine 42961 INC D Test the sign byte of the first component.
42962 LD A,249 Set the step to 249 (minus seven bytes), to move up a pixel line.
42964 JR NZ,DrawLine_Step Jump to DrawLine_Step if the component is positive.
42966 LD A,7 Set the step to 7 to move down a pixel line.
DrawLine_Step 42968 LD (43034),A Store the step in the operand of the instruction at 43033.
42971 SRL E Halve the first component.
42973 LD D,0 Clear the running total in D.
42975 EXX Switch to the alternate registers.
42976 INC H Test the sign byte of the second component.
42977 LD BC,2496 Set the instructions for moving to the right.
42980 LD A,44 Set the opcode of INC L.
42982 JR NZ,DrawLine_Direction Jump to DrawLine_Direction if the component is positive.
42984 LD BC,385 Set the instructions for moving to the left.
42987 LD A,45 Set the opcode of DEC L.
DrawLine_Direction 42989 LD (43053),A Patch the instruction at 43053.
42992 LD A,B Fetch the second byte of the instruction for rotating the pixel.
42993 LD (43046),A Patch the instruction at 43045.
42996 LD A,C Fetch the pixel pattern at which to move onto the next byte.
42997 LD (43049),A Patch the operand of the instruction at 43048.
43000 LD H,0 Clear the high byte of the second running total.
43002 EXX Switch back to the normal registers.
43003 LD C,24 Set the pixel pattern to 24.
43005 LD HL,62837 Point HL at the centre of the dial in the buffer.
DrawLine_Plot 43008 LD A,C Fetch the pixel pattern.
43009 CP 129 Jump to DrawLine_Pixels if it does not.
43011 JP NZ,DrawLine_Pixels
43014 SET 0,(HL) Set the pixel at the right of the byte.
43016 INC L Move onto the next byte.
43017 SET 7,(HL) Set the pixel at the left of the byte.
43019 DEC L Move back to the first byte.
43020 JP DrawLine_Count Jump to DrawLine_Count.
DrawLine_Pixels 43023 OR (HL) Combine the pixel pattern with the byte.
43024 LD (HL),A Store it.
DrawLine_Count 43025 DEC B Decrease the number of pixels by one.
43026 RET Z Return if all of the pixels have been plotted.
43027 LD A,D Fetch the running total of the first component.
43028 ADD A,E Add the first component.
43029 LD D,A Store it.
43030 JP NC,DrawLine_Second Jump to DrawLine_Second if there was no carry.
43033 LD A,0 Set the step (this is patched at 43034).
43035 ADD A,L Add it to the address, to move up or down a pixel line.
43036 LD L,A Store it.
DrawLine_Second 43037 EXX Switch to the alternate registers.
43038 LD A,H Fetch the running total of the second component.
43039 ADD A,L Add the second component.
43040 LD H,A Store it.
43041 EXX Switch back to the normal registers.
43042 JP NC,DrawLine_Plot Jump to DrawLine_Plot to plot the next pixel if there was no carry.
43045 RRC C Rotate the pixel pattern (this is patched at 43046).
43047 LD A,C Fetch the pattern.
43048 CP 0 Jump to DrawLine_Plot if the pattern is not there yet.
43050 JP NZ,DrawLine_Plot
43053 INC L Move onto the next byte (this is patched at 43053).
43054 JP DrawLine_Plot Jump to DrawLine_Plot.
Prev: 42944 Up: Map Next: 43057