Skip to navigation


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 monochrome 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 mod 8, which is the pixel row within the AND #7 \ character block at which we want to draw our pixel TAY \ (as each character block has 8 rows) TXA \ Set X = X mod 8, which is the horizontal pixel number AND #7 \ within the character block where the pixel lies (as TAX \ each pixel line in the character block is 8 pixels \ wide) 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