.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 subroutineName: DrawGraphicsBuffer [Show more] Type: Subroutine Category: Graphics buffers Summary: Draw the contents of the specified graphics buffer Deep dive: Depth-sorting with the graphics buffersContext: See this subroutine in context in the source code References: This subroutine is called as follows: * DrawLandscapeAndBuffers (Part 3 of 4) calls DrawGraphicsBuffer * DrawLandscapeAndBuffers (Part 4 of 4) calls DrawGraphicsBuffer * Draw1x1ParticleFromBuffer calls via DrawNextFromGraphicsBuffer * Draw2x1ParticleFromBuffer calls via DrawNextFromGraphicsBuffer * Draw2x2ParticleFromBuffer calls via DrawNextFromGraphicsBuffer * Draw3x1ParticleFromBuffer calls via DrawNextFromGraphicsBuffer * Draw3x2ParticleFromBuffer calls via DrawNextFromGraphicsBuffer * DrawTriangleFromBuffer calls via DrawNextFromGraphicsBuffer * bufferJump calls via TerminateGraphicsBuffer
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
[X]
Variable graphicsBufferEndAddr (category: Graphics buffers)
The address of the table containing the end addresses of the graphics buffers
[X]
Configuration variable labOffset is local to this routine
Set labOffset to the offset back to the bufferJump table from the next instruction
[X]
Variable screenAddr (category: Drawing the screen)
The screen address for the start of the 17th pixel line in the current bank (i.e. the line just below the two rows of text)