Skip to navigation


Dashboard: DIL2

[Elite-A, I/O processor]

Name: DIL2 [Show more] Type: Subroutine Category: Dashboard Summary: Implement the draw_angle command (update the roll or pitch indicator on the dashboard) Deep dive: The dashboard indicators
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * tube_table calls DIL2

This routine is run when the parasite sends a draw_angle command. It updates the roll or pitch indicator on the dashboard. The indicator can show a vertical bar in 16 positions, with a value of 8 showing the bar in the middle of the indicator. In practice this routine is only ever called with A in the range 1 to 15, so the vertical bar never appears in the leftmost position (though it does appear in the rightmost).
Arguments: A The offset of the vertical bar to show in the indicator, from 0 at the far left, to 8 in the middle, and 15 at the far right
Returns: C flag The C flag is set
.DIL2 JSR tube_get \ Get the parameters from the parasite for the command: STA angle_1 \ JSR tube_get \ draw_angle(value, screen_low, screen_high) STA SC \ JSR tube_get \ and store them as follows: STA SC+1 \ \ * angle_1 = the value to display in the indicator \ \ * SC(1 0) = the screen address of the indicator LDY #1 \ We want to start drawing the vertical indicator bar on \ the second line in the indicator's character block, so \ set Y to point to that row's offset \ We are now going to work our way along the indicator \ on the dashboard, from left to right, working our way \ along one character block at a time. Y will be used as \ a pixel row counter to work our way through the \ character blocks, so each time we draw a character \ block, we will increment Y by 8 to move on to the next \ block (as each character block contains 8 rows) .DLL10 SEC \ Set A = angle_1 - 4, so that A contains the offset of LDA angle_1 \ the vertical bar from the start of this character SBC #4 \ block BCS DLL11 \ If angle_1 >= 4 then the character block we are \ drawing does not contain the vertical indicator bar, \ so jump to DLL11 to draw a blank character block LDA #&FF \ Set A to a high number (and &FF is as high as they go) LDX angle_1 \ Set X to the offset of the vertical bar, which we know \ is within this character block STA angle_1 \ Set angle_1 to a high number (&FF, why not) so we will \ keep drawing blank characters after this one until we \ reach the end of the indicator row LDA CTWOS,X \ CTWOS is a table of ready-made 1-pixel mode 5 bytes, \ just like the TWOS and TWOS2 tables for mode 4 (see \ the PIXEL routine for details of how they work). This \ fetches a mode 5 1-pixel byte with the pixel position \ at X, so the pixel is at the offset that we want for \ our vertical bar AND #&F0 \ The 4-pixel mode 5 colour byte &F0 represents four \ pixels of colour %10 (3), which is yellow in the \ normal dashboard palette and white if we have an \ escape pod fitted. We AND this with A so that we only \ keep the pixel that matches the position of the \ vertical bar (i.e. A is acting as a mask on the \ 4-pixel colour byte) JMP DLL12 \ Jump to DLL12 to skip the code for drawing a blank, \ and move on to drawing the indicator .DLL11 \ If we get here then we want to draw a blank for this \ character block STA angle_1 \ Update angle_1 with the new offset of the vertical \ bar, so it becomes the offset after the character \ block we are about to draw LDA #0 \ Change the mask so no bits are set, so all of the \ character blocks we display from now on will be blank .DLL12 STA (SC),Y \ Draw the shape of the mask on pixel row Y of the \ character block we are processing INY \ Draw the next pixel row, incrementing Y STA (SC),Y INY \ And draw the third pixel row, incrementing Y STA (SC),Y INY \ And draw the fourth pixel row, incrementing Y STA (SC),Y TYA \ Add 5 to Y, so Y is now 8 more than when we started CLC \ this loop iteration, so Y now points to the address ADC #5 \ of the first line of the indicator bar in the next TAY \ character block (as each character is 8 bytes of \ screen memory) CPY #30 \ If Y < 30 then we still have some more character BCC DLL10 \ blocks to draw, so loop back to DLL10 to display the \ next one along RTS \ Return from the subroutine