![]() |
Routines |
| Prev: A7C0 | Up: Map | Next: A831 |
|
Used by the routine at DrawDirectionGauge.
Draws a line into the buffer at F517 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.
|
||||||||||||
| DrawLine | A7D1 | INC D | Test the sign byte of the first component. | |||||||||
| A7D2 | LD A,$F9 | Set the step to F9 (minus seven bytes), to move up a pixel line. | ||||||||||
| A7D4 | JR NZ,DrawLine_Step | Jump to DrawLine_Step if the component is positive. | ||||||||||
| A7D6 | LD A,$07 | Set the step to 07 to move down a pixel line. | ||||||||||
| DrawLine_Step | A7D8 | LD ($A81A),A | Store the step in the operand of the instruction at A819. | |||||||||
| A7DB | SRL E | Halve the first component. | ||||||||||
| A7DD | LD D,$00 | Clear the running total in D. | ||||||||||
| A7DF | EXX | Switch to the alternate registers. | ||||||||||
| A7E0 | INC H | Test the sign byte of the second component. | ||||||||||
| A7E1 | LD BC,$09C0 | Set the instructions for moving to the right. | ||||||||||
| A7E4 | LD A,$2C | Set the opcode of INC L. | ||||||||||
| A7E6 | JR NZ,DrawLine_Direction | Jump to DrawLine_Direction if the component is positive. | ||||||||||
| A7E8 | LD BC,$0181 | Set the instructions for moving to the left. | ||||||||||
| A7EB | LD A,$2D | Set the opcode of DEC L. | ||||||||||
| DrawLine_Direction | A7ED | LD ($A82D),A | Patch the instruction at A82D. | |||||||||
| A7F0 | LD A,B | Fetch the second byte of the instruction for rotating the pixel. | ||||||||||
| A7F1 | LD ($A826),A | Patch the instruction at A825. | ||||||||||
| A7F4 | LD A,C | Fetch the pixel pattern at which to move onto the next byte. | ||||||||||
| A7F5 | LD ($A829),A | Patch the operand of the instruction at A828. | ||||||||||
| A7F8 | LD H,$00 | Clear the high byte of the second running total. | ||||||||||
| A7FA | EXX | Switch back to the normal registers. | ||||||||||
| A7FB | LD C,$18 | Set the pixel pattern to 18. | ||||||||||
| A7FD | LD HL,$F575 | Point HL at the centre of the dial in the buffer. | ||||||||||
| DrawLine_Plot | A800 | LD A,C | Fetch the pixel pattern. | |||||||||
| A801 | CP $81 | Jump to DrawLine_Pixels if it does not. | ||||||||||
| A803 | JP NZ,DrawLine_Pixels | |||||||||||
| A806 | SET 0,(HL) | Set the pixel at the right of the byte. | ||||||||||
| A808 | INC L | Move onto the next byte. | ||||||||||
| A809 | SET 7,(HL) | Set the pixel at the left of the byte. | ||||||||||
| A80B | DEC L | Move back to the first byte. | ||||||||||
| A80C | JP DrawLine_Count | Jump to DrawLine_Count. | ||||||||||
| DrawLine_Pixels | A80F | OR (HL) | Combine the pixel pattern with the byte. | |||||||||
| A810 | LD (HL),A | Store it. | ||||||||||
| DrawLine_Count | A811 | DEC B | Decrease the number of pixels by one. | |||||||||
| A812 | RET Z | Return if all of the pixels have been plotted. | ||||||||||
| A813 | LD A,D | Fetch the running total of the first component. | ||||||||||
| A814 | ADD A,E | Add the first component. | ||||||||||
| A815 | LD D,A | Store it. | ||||||||||
| A816 | JP NC,DrawLine_Second | Jump to DrawLine_Second if there was no carry. | ||||||||||
| A819 | LD A,$00 | Set the step (this is patched at A81A). | ||||||||||
| A81B | ADD A,L | Add it to the address, to move up or down a pixel line. | ||||||||||
| A81C | LD L,A | Store it. | ||||||||||
| DrawLine_Second | A81D | EXX | Switch to the alternate registers. | |||||||||
| A81E | LD A,H | Fetch the running total of the second component. | ||||||||||
| A81F | ADD A,L | Add the second component. | ||||||||||
| A820 | LD H,A | Store it. | ||||||||||
| A821 | EXX | Switch back to the normal registers. | ||||||||||
| A822 | JP NC,DrawLine_Plot | Jump to DrawLine_Plot to plot the next pixel if there was no carry. | ||||||||||
| A825 | RRC C | Rotate the pixel pattern (this is patched at A826). | ||||||||||
| A827 | LD A,C | Fetch the pattern. | ||||||||||
| A828 | CP $00 | Jump to DrawLine_Plot if the pattern is not there yet. | ||||||||||
| A82A | JP NZ,DrawLine_Plot | |||||||||||
| A82D | INC L | Move onto the next byte (this is patched at A82D). | ||||||||||
| A82E | JP DrawLine_Plot | Jump to DrawLine_Plot. | ||||||||||
| Prev: A7C0 | Up: Map | Next: A831 |