Skip to navigation

Lander on the Acorn Archimedes

Graphics buffers: AddTerminatorsToBuffers

Name: AddTerminatorsToBuffers [Show more] Type: Subroutine Category: Graphics buffers Summary: Add terminators to the ends of the graphics buffers so we know when to stop drawing 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: * LoseLife calls AddTerminatorsToBuffers * MainLoop calls AddTerminatorsToBuffers
.AddTerminatorsToBuffers STMFD R13!, {R12, R14} \ Store the registers that we want to use on \ the stack so they can be preserved LDR R12, graphicsBufferEndAddr \ Set R12 to the address of the table that \ contains the end addresses of the graphics \ buffers LDR R14, graphicsBufferAddr \ Set R14 to the address of the table that \ contains the start addresses of the \ graphics buffers MOV R0, #TILES_Z \ We are going to loop through all of the \ graphics buffers, so set a counter in R0 \ to the number of tile corners in the \ visible landscape, going back to front (as \ there is one graphics buffer for each \ corner row) MOV R1, #19 \ The command number for terminating a \ graphics buffer is 19, so put this in R1 \ (see bufferJump for a full list of drawing \ commands) .term1 LDR R2, [R12, R0, LSL #2] \ Set R2 to the end address of graphics \ buffer number R0 STR R1, [R2] \ Store the termination command number at \ the end of the buffer LDR R2, [R14, R0, LSL #2] \ Reset the graphicsBufferEnd entry for this STR R2, [R12, R0, LSL #2] \ buffer back to the start address from the \ graphicsBuffer table, so when we draw the \ next frame, we fill up the graphics \ buffers from the start again SUBS R0, R0, #1 \ Decrement the loop counter BPL term1 \ Loop back until we have terminated all 12 \ graphics buffers LDMFD R13!, {R12, PC} \ Retrieve the registers that we stored on \ the stack and return from the subroutine