![]() |
Routines |
| Prev: 42731 | Up: Map | Next: 42944 |
|
Draws a direction gauge, which shows the heading in ScratchValue by a needle with a ball at its tip. The picture of the dial is copied into the buffer at 62743 the needle is drawn into it, and the buffer is then copied to the screen. The picture is seven bytes wide and 28 pixel lines high.
|
||||
| DrawDirectionGauge | 42788 | LD DE,62743 | Point DE at the buffer. | |
| 42791 | LD HL,33325 | Point HL at DialPicture_Row10. | ||
| 42794 | LD BC,196 | Set the number of bytes to 196. | ||
| 42797 | LDIR | Copy the picture into the buffer. | ||
| 42799 | LD A,(23768) | Fetch the heading. | ||
| 42802 | CALL GetDirectionVector_Heading | Call 42737 to find the components of the heading. | ||
| 42805 | PUSH HL | Save the second component. | ||
| 42806 | PUSH BC | Save the first component. | ||
| 42807 | POP HL | Retrieve the first component in HL... | ||
| 42808 | POP BC | ...and the second in BC. | ||
| 42809 | PUSH HL | Save the first component. | ||
| 42810 | PUSH BC | Save the second component. | ||
| 42811 | PUSH HL | Save the first component again. | ||
| 42812 | LD L,C | Copy the low byte of the second component into L... | ||
| 42813 | LD H,B | ...and the high byte into H. | ||
| 42814 | EXX | Switch to the alternate registers. | ||
| 42815 | POP DE | Retrieve the first component in DE. | ||
| 42816 | LD B,24 | Set the length of the needle to 24. | ||
| 42818 | CALL DrawLine | Call DrawLine to draw the needle. | ||
| 42821 | POP HL | Retrieve the second component. | ||
| 42822 | LD A,H | Fetch the sign byte of the component. | ||
| 42823 | LD H,0 | Clear H. | ||
| 42825 | ADD HL,HL | Multiply the component by two... | ||
| 42826 | ADD HL,HL | ...four... | ||
| 42827 | ADD HL,HL | ...and eight. | ||
| 42828 | LD C,L | Copy it into BC. | ||
| 42829 | LD B,H | |||
| 42830 | ADD HL,HL | Multiply it by sixteen... | ||
| 42831 | ADD HL,BC | ...and add the eight times value to make twenty-four times. | ||
| 42832 | AND A | Test the sign byte. | ||
| 42833 | LD A,H | Fetch the high byte of the result, which is the offset in pixels. | ||
| 42834 | JR Z,DrawDirectionGauge_Offset | Jump to DrawDirectionGauge_Offset if the component was positive. | ||
| 42836 | NEG | Make the offset negative. | ||
| DrawDirectionGauge_Offset | 42838 | INC A | Add one. | |
| 42839 | LD (23772),A | Store the offset in DrawingPosition. | ||
| 42842 | SRA A | Divide the offset by two... | ||
| 42844 | SRA A | ...four... | ||
| 42846 | SRA A | ...and eight to find the byte. | ||
| 42848 | ADD A,138 | Add the offset of the needle in the buffer. | ||
| 42850 | LD E,A | Keep the column in E. | ||
| 42851 | POP HL | Retrieve the first component. | ||
| 42852 | LD A,H | Fetch the sign byte of the component. | ||
| 42853 | LD H,0 | Clear H. | ||
| 42855 | ADD HL,HL | Multiply the component by two... | ||
| 42856 | ADD HL,HL | ...and four. | ||
| 42857 | LD C,L | Copy it into BC. | ||
| 42858 | LD B,H | |||
| 42859 | ADD HL,HL | Multiply it by eight... | ||
| 42860 | ADD HL,BC | ...and add the four times value to make twelve times. | ||
| 42861 | AND A | Test the sign byte. | ||
| 42862 | LD A,H | Fetch the high byte of the result, which is the offset in pixel lines. | ||
| 42863 | JR NZ,DrawDirectionGauge_Row | Jump to DrawDirectionGauge_Row if the component was negative. | ||
| 42865 | NEG | Make the offset negative. | ||
| DrawDirectionGauge_Row | 42867 | LD B,A | Keep the offset in B. | |
| 42868 | ADD A,A | Multiply it by two... | ||
| 42869 | ADD A,A | ...four... | ||
| 42870 | ADD A,A | ...and eight. | ||
| 42871 | SUB B | Subtract the offset to make seven times the offset. | ||
| 42872 | ADD A,E | Add the column. | ||
| 42873 | LD L,A | Set the low byte of the address in the buffer. | ||
| 42874 | LD H,245 | Set the high byte of the address in the buffer. | ||
| 42876 | CALL DrawNeedleTip | Call DrawNeedleTip to draw the ball at the tip of the needle. | ||
|
Copy the buffer to the screen.
|
||||
| 42879 | LD (23770),SP | Save the stack pointer. | ||
| 42883 | LD SP,62743 | Point the stack at the buffer. | ||
| 42886 | LD HL,21922 | Point HL at the bottom left of the position on the screen. | ||
| 42889 | LD A,0 | Load the offset of the gauge on the screen (this is set at 42890). | ||
| 42891 | ADD A,L | Add it to the address. | ||
| 42892 | LD L,A | Set the low byte of the address. | ||
| 42893 | LD B,28 | Set the number of pixel lines to 28. | ||
| DrawDirectionGauge_Line | 42895 | LD C,L | Remember the start of the line. | |
| 42896 | POP DE | Fetch the first two bytes of the line. | ||
| 42897 | LD (HL),E | Store the first byte. | ||
| 42898 | INC L | Move onto the next byte of the line. | ||
| 42899 | LD (HL),D | Store the second byte. | ||
| 42900 | INC L | Move onto the next byte of the line. | ||
| 42901 | POP DE | Fetch the third and fourth bytes of the line. | ||
| 42902 | LD (HL),E | Store the third byte. | ||
| 42903 | INC L | Move onto the next byte of the line. | ||
| 42904 | LD (HL),D | Store the fourth byte. | ||
| 42905 | INC L | Move onto the next byte of the line. | ||
| 42906 | POP DE | Fetch the fifth and sixth bytes of the line. | ||
| 42907 | LD (HL),E | Store the fifth byte. | ||
| 42908 | INC L | Move onto the next byte of the line. | ||
| 42909 | LD (HL),D | Store the sixth byte. | ||
| 42910 | INC L | Move onto the next byte of the line. | ||
| 42911 | POP DE | Fetch the seventh byte and the first byte of the next line. | ||
| 42912 | DEC SP | Step back over the byte of the next line. | ||
| 42913 | LD (HL),E | Store the seventh byte. | ||
| 42914 | DEC B | Decrease the number of lines by one. | ||
| 42915 | JR Z,DrawDirectionGauge_Done | Jump to DrawDirectionGauge_Done if all of the lines have been copied. | ||
| 42917 | LD L,C | Go back to the start of the line. | ||
| 42918 | LD A,H | Fetch the high byte of the address. | ||
| 42919 | DEC H | Move up a pixel line. | ||
| 42920 | AND %00000111 | Keep the number of the pixel line which the line was in. | ||
| 42922 | JP NZ,DrawDirectionGauge_Line | Jump back to copy the next line unless that was the top pixel line of a character row. | ||
| 42925 | LD A,L | Fetch the low byte of the address. | ||
| 42926 | SUB 32 | Move up a character row. | ||
| 42928 | LD L,A | Store it. | ||
| 42929 | JP C,DrawDirectionGauge_Line | Jump back to copy the next line if the row was at the top of a screen section. | ||
| 42932 | LD A,H | Fetch the high byte of the address. | ||
| 42933 | ADD A,8 | Move to the bottom pixel line of the character row. | ||
| 42935 | LD H,A | Store it. | ||
| 42936 | JP DrawDirectionGauge_Line | Jump back to copy the next line. | ||
| DrawDirectionGauge_Done | 42939 | LD SP,(23770) | Restore the stack pointer. | |
| 42943 | RET | Return. | ||
| Prev: 42731 | Up: Map | Next: 42944 |