LDRB R0, [R11, #tileCornerRow] \ Set R0 to the number of the tile corner \ row we are currently processing SUBS R0, R0, #2 \ Subtract 2 from the corner row to get the \ number of the row that's two tile rows \ behind the current row BLPL DrawGraphicsBuffer \ If this results in a valid graphics buffer \ number, i.e. one that is positive, draw \ the contents of the buffer LDRB R0, [R11, #tileCornerRow] \ Set R0 to the number of the tile corner \ row we are currently processing ADDS R0, R0, #1 \ Increment the tile row number in R0 to \ move forwards by one tile row CMP R0, #TILES_Z \ If R0 = TILES_Z then we just drew the last BEQ land5 \ tile row, so jump to land5 to finish off \ by drawing graphics buffers 9 and 10 STRB R0, [R11, #tileCornerRow] \ Otherwise store the updated tile corner \ row number in tileCornerRow, ready for the \ next corner row LDR R0, [R11, #zLandscapeRow] \ Subtract a tile's width from zLandscapeRow SUB R0, R0, #TILE_SIZE \ to move the coordinates of the current row STR R0, [R11, #zLandscapeRow] \ forward by one whole tile SUB R9, R9, #TILE_SIZE \ Subtract a tile's width from R9 to step \ along the z-axis by one whole tile, going \ from back to front MOV R0, #&80000000 \ Store &80000000 in the address in R7 to STR R0, [R7] \ reset the store, so it's ready to be used \ to store the new row's pixel corner \ coordinates LDRB R0, [R11, #tileRowOddEven] \ Flip the value of tileRowOddEven between EORS R0, R0, #1 \ 0 and 1, setting the flags to feed into STRB R0, [R11, #tileRowOddEven] \ the following logic ADDNE R6, R11, #cornerStore1 \ Do the following after drawing the first ADDEQ R6, R11, #cornerStore2 \ tile row and then every other row: ADDEQ R7, R11, #cornerStore1 \ ADDNE R7, R11, #cornerStore2 \ * R6 = address of cornerStore1 \ * R7 = address of cornerStore2 \ \ Or do the following after drawing the \ second tile row and then every other row: \ \ * R6 = address of cornerStore2 \ * R7 = address of cornerStore1 \ \ So R6 and R7 swap over after each row, so \ R6 always points to the set of pixel \ corner coordinates from the previous row, \ and R7 points to the place where we store \ this row's pixel corner coordinates B land1 \ Loop back to land1 to process the next row \ of tile cornersName: DrawLandscapeAndBuffers (Part 3 of 4) [Show more] Type: Subroutine Category: Landscape Summary: Draw the objects in the graphics buffers for two rows behind the current corner row Deep dive: Drawing the landscape Depth-sorting with the graphics buffersContext: See this subroutine in context in the source code References: No direct references to this subroutine in this source file
[X]
Subroutine DrawGraphicsBuffer (category: Graphics buffers)
Draw the contents of the specified graphics buffer
[X]
Configuration variable TILES_Z = 11
The number of tile corners in a landscape row from front to back (i.e. 10 tiles)
[X]
Configuration variable TILE_SIZE = &01000000
The length of one side of a square landscape tile in 3D coordinates
[X]
Configuration variable cornerStore1 = &400
Storage for coordinates of tile corners as we work our way through the landscape
[X]
Configuration variable cornerStore2 = &500 + STORE
Storage for coordinates of tile corners as we work our way through the landscape
[X]
Label land1 in subroutine DrawLandscapeAndBuffers (Part 2 of 4)
[X]
Label land5 in subroutine DrawLandscapeAndBuffers (Part 4 of 4)
[X]
Configuration variable tileCornerRow = &E4
The number of the landscape tile corner row that is currently being processed
[X]
Configuration variable tileRowOddEven = &F8
A counter that flips every time we process a tile corner row when drawing the landscape, so we can trigger actions accordingly
[X]
Configuration variable zLandscapeRow = &168
The z-coordinate of the far-left corner of the landscape row that we are drawing, where rows run from left to right across the screen (this is a relative coordinate)