Skip to navigation

Elite on the BBC Micro

Dashboard: DILX [Elite-A, Parasite]

Name: DILX [Show more] Type: Subroutine Category: Dashboard Summary: Update a bar-based indicator on the dashboard by sending a draw_bar command to the I/O processor Deep dive: The dashboard indicators
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * DIALS (Part 4 of 4) calls DILX * DIALS (Part 1 of 4) calls entry point DIL-1 * DIALS (Part 3 of 4) calls entry point DIL * DIALS (Part 4 of 4) calls entry point DILX+2

The range of values shown on the indicator depends on which entry point is called. For the default entry point of DILX, the range is 0-255 (as the value passed in A is one byte). The other entry points are shown below. Arguments: A The value to be shown on the indicator (so the larger the value, the longer the bar) T1 The threshold at which we change the indicator's colour from the low value colour to the high value colour. The threshold is in pixels, so it should have a value from 0-16, as each bar indicator is 16 pixels wide K The colour to use when A is a high value, as a 4-pixel mode 5 character row byte K+1 The colour to use when A is a low value, as a 4-pixel mode 5 character row byte SC(1 0) The screen address of the first character block in the indicator Other entry points: DILX+2 The range of the indicator is 0-64 (for the fuel indicator) DIL-1 The range of the indicator is 0-32 (for the speed indicator) DIL The range of the indicator is 0-16 (for the energy banks)
.DILX LSR A \ If we call DILX, we set A = A / 16, so A is 0-15 LSR A LSR A \ If we call DILX+2, we set A = A / 4, so A is 0-15 LSR A \ If we call DIL-1, we set A = A / 2, so A is 0-15 .DIL \ If we call DIL, we leave A alone, so A is 0-15 PHA \ Store the indicator value on the stack LDA #&86 \ Send command &86 to the I/O processor: JSR tube_write \ \ draw_bar(value, colour, screen_low, screen_high) \ \ which will update the bar-based dashboard indicator at \ the specified screen address to a given value and \ colour PLA \ Send the first parameter to the I/O processor: JSR tube_write \ \ * value = A LDX #&FF \ Set R = &FF, to use as a mask for drawing each row of STX R \ each character block of the bar, starting with a full \ character's width of 4 pixels CMP T1 \ If A >= T1 then we have passed the threshold where we BCS DL30 \ change bar colour, so jump to DL30 to set A to the \ "high value" colour LDA K+1 \ Set A to K+1, the "low value" colour to use EQUB &2C \ Skip the next instruction by turning it into \ &2C &A5 &40, or BIT &40A5, which does nothing apart \ from affect the flags .DL30 LDA K \ Set A to K, the "high value" colour to use .DL31 JSR tube_write \ Send the second parameter to the I/O processor: \ \ * colour = A LDA SC \ Send the third parameter to the I/O processor: JSR tube_write \ \ * screen_low = SC LDA SC+1 \ Send the fourth parameter to the I/O processor: JSR tube_write \ \ * sch = SC+1 INC SC+1 \ Increment the high byte of SC to point to the next \ character row on-screen (as each row takes up exactly \ one page of 256 bytes) - so this sets up SC to point \ to the next indicator, i.e. the one below the one we \ just drew .DL9 RTS \ Return from the subroutine