Skip to navigation

Lander on the Acorn Archimedes

Graphics buffers: DrawGraphicsBuffer

Name: DrawGraphicsBuffer [Show more] Type: Subroutine Category: Graphics buffers Summary: Draw the contents of the specified graphics buffer Deep dive: Depth-sorting with the graphics buffers
This routine draws the contents of a specified graphics buffer. There are 11 buffers that are used to layer the game's graphics correctly according to an object's distance. This routine draws the contents of a specific buffer onto the screen.
Arguments: R0 The number of the graphics buffer to draw (0 to 10)
Other entry points: DrawNextFromGraphicsBuffer Process the next command from the graphics buffer TerminateGraphicsBuffer Terminate drawing from the graphics buffer by returning from the subroutine
.DrawGraphicsBuffer STMFD R13!, {R6-R12, R14} \ Store the registers that we want to use on \ the stack so they can be preserved LDR R1, graphicsBufferEndAddr \ Set R1 to the address of the table that \ contains the end addresses of the graphics \ buffers LDR R9, [R1, R0, LSL #2] \ Set R9 to the R0-th entry from the \ graphicsBuffersEnd table, which contains \ the end address for graphics buffer R0 LDR R12, screenAddr \ Set R12 to the address of the screen bank \ we are drawing in, pointing just below \ the two lines of text at the top of the \ screen .DrawNextFromGraphicsBuffer LDR R0, [R9], #4 \ Fetch the address of the next free byte in \ the graphics buffer (which is the same as \ the end address of the buffer) from the \ graphicsBuffersEnd table, put it into R0 \ and increment R9 to point to the next \ buffer's end address ] labOffset = P% + 8 - bufferJump \ Set labOffset to the offset back to the \ bufferJump table from the next instruction [ OPT pass% ADD R0, PC, R0, LSL #2 \ Jump to the address in entry R0 in the LDR PC, [R0, #-labOffset] \ bufferJump table .TerminateGraphicsBuffer LDMFD R13!, {R6-R12, PC} \ Retrieve the registers that we stored on \ the stack and return from the subroutine