Skip to navigation

Lander on the Acorn Archimedes

Particles: Draw3x1ParticleFromBuffer

Name: Draw3x1ParticleFromBuffer [Show more] Type: Subroutine Category: Particles Summary: Process the "draw 3x1-pixel particle" command from the graphics buffer Deep dive: Depth-sorting with the graphics buffers
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * bufferJump calls Draw3x1ParticleFromBuffer

The 32-bit parameter word for this command is composed as follows: #20-31 #12-19 #8-11 #0-7 019876543210 98765432 1098 76543210 ^ ^ ^ ^ | | | | Pixel x-coord Colour Unused Pixel y-coord (0-319) (0-255) (0-255) This command draws a 3x1-pixel particle at the given coordinates in the specified colour, with the coordinates specifying the pixel in the middle of the particle.
Arguments: R9 The address of the parameter word in the graphics buffer R12 The address of the screen bank we are drawing in, pointing just below the two lines of text at the top of the screen, as set in screenAddr
Returns: R9 Updated to point to the next word in the graphics buffer
.Draw3x1ParticleFromBuffer LDR R1, [R9], #4 \ Fetch the parameter word from the graphics \ buffer into R1, incrementing R9 to point \ to the next command in the buffer MOV R0, R1, LSR #20 \ Set R0 to bits #20-31 of the parameter \ word, to extract the pixel x-coordinate MOV R7, R1, LSR #12 \ Set R7 to bits #12-31 of the parameter \ word to extract the colour number, which \ we poke into memory as a byte containing \ bits #12-19 AND R1, R1, #&FF \ Set R1 to bits #0-7 of the parameter word, \ to extract the pixel y-coordinate ADD R3, R12, R0 \ Set R3 = R12 + R0 \ = screenAddr + x-coordinate ADD R1, R1, R1, LSL #2 \ Set R3 = R3 + ((R1 + R1 << 2) << 6) ADD R3, R3, R1, LSL #6 \ = R3 + ((R1 + 4 * R1) * 64) \ = R3 + 320 * R1 \ = screenAddr + x-coordinate \ + 320 * y-coordinate \ \ So R3 contains the screen address of the \ coordinate in screen memory STRB R7, [R3, #-1] \ Draw a 3x1-pixel particle in the colour STRB R7, [R3] \ specified in R7 STRB R7, [R3, #1] B DrawNextFromGraphicsBuffer \ Draw the next command from the graphics \ buffer