Skip to navigation

Drawing pixels: PIX

[BBC Micro cassette version, Loader]

Name: PIX [Show more] Type: Subroutine Category: Drawing pixels Summary: Draw a single pixel at a specific coordinate
Context: See this subroutine in context in the source code Variations: See code variations for this subroutine in the different versions References: This subroutine is called as follows: * PLL1 (Part 1 of 3) calls PIX * PLL1 (Part 2 of 3) calls PIX * PLL1 (Part 3 of 3) calls PIX

Draw a pixel at screen coordinate (X + 128, A + 128). The routine uses the same approach as the PIXEL routine in the main game code, except it plots a single pixel from TWOS instead of a two pixel dash from TWOS2. This applies to the top part of the screen (the monochrome mode 4 space view). See the PIXEL routine in the main game code for more details.
Arguments: X The signed screen x-coordinate of the pixel to draw, from -128 to 127, to be plotted relative to the origin at (128, 128) A The signed screen y-coordinate of the pixel to draw, from -128 to 127, to be plotted relative to the origin at (128, 128)
.PIX TAY \ Copy A into Y, for use later EOR #%10000000 \ Add 128 to A and treat this as an unsigned number from \ now on LSR A \ Set ZP+1 = &60 + A >> 3 LSR A LSR A ORA #&60 STA ZP+1 TXA \ Set A = X + 128 and treat this as an unsigned number EOR #%10000000 \ from now on AND #%11111000 \ Set ZP = (A >> 3) * 8 STA ZP 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 TWOS,X \ Fetch a pixel from TWOS and OR it into ZP+Y ORA (ZP),Y STA (ZP),Y RTS \ Return from the subroutine