Skip to navigation

Elite on the BBC Micro

Drawing pixels: PIXEL [Elite-A, I/O processor]

Name: PIXEL [Show more] Type: Subroutine Category: Drawing pixels Summary: Implement the draw_pixel command (draw space view pixels) Deep dive: Drawing colour pixels in mode 4
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * tube_table calls PIXEL

This routine is run when the parasite sends a draw_pixel command. It draws a dot in the space view. Arguments: X The screen x-coordinate of the point to draw A The screen y-coordinate of the point to draw ZZ The distance of the point (further away = smaller point) Returns: Y Y is preserved
.PIXEL JSR tube_get \ Get the parameters from the parasite for the command: TAX \ JSR tube_get \ draw_pixel(x, y, distance) TAY \ JSR tube_get \ and store them as follows: STA ZZ \ \ * X = the pixel's x-coordinate \ \ * Y = the pixel's y-coordinate \ \ * ZZ = the pixel's distance TYA \ Copy the pixel's y-coordinate from Y into A LSR A \ Set SCH = &60 + A >> 3 LSR A LSR A ORA #&60 STA SCH TXA \ Set SC = (X >> 3) * 8 AND #%11111000 STA SC TYA \ Set Y = Y AND %111 AND #%00000111 TAY TXA \ Set X = X AND %111 AND #%00000111 TAX LDA ZZ \ If distance in ZZ >= 144, then this point is a very CMP #144 \ long way away, so jump to PX3 to fetch a 1-pixel point BCS PX3 \ from TWOS and EOR it into SC+Y LDA TWOS2,X \ Otherwise fetch a 2-pixel dash from TWOS2 and EOR it EOR (SC),Y \ into SC+Y STA (SC),Y LDA ZZ \ If distance in ZZ >= 80, then this point is a medium CMP #80 \ distance away, so jump to PX13 to stop drawing, as a BCS PX13 \ 2-pixel dash is enough \ Otherwise we keep going to draw another 2 pixel point \ either above or below the one we just drew, to make a \ 4-pixel square DEY \ Reduce Y by 1 to point to the pixel row above the one BPL PX14 \ we just plotted, and if it is still positive, jump to \ PX14 to draw our second 2-pixel dash LDY #1 \ Reducing Y by 1 made it negative, which means Y was \ 0 before we did the DEY above, so set Y to 1 to point \ to the pixel row after the one we just plotted .PX14 LDA TWOS2,X \ Fetch a 2-pixel dash from TWOS2 and EOR it into this EOR (SC),Y \ second row to make a 4-pixel square STA (SC),Y .PX13 RTS \ Return from the subroutine