Skip to navigation

Drawing the landscape: DrawLandscapeRow

Name: DrawLandscapeRow [Show more] Type: Subroutine Category: Drawing the landscape Summary: Draw a row of tiles between the left visible edge and the right visible, in two parts towards each side of the viewer
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * DrawLandscapeView (Part 2 of 3) calls DrawLandscapeRow * DrawLandscapeView (Part 3 of 3) calls DrawLandscapeRow
.DrawLandscapeRow LDA xTileViewLeftEdge \ Set xTileToDraw to the column number of the tile at STA xTileToDraw \ the left edge of the visible row we want to draw .draw1 CMP xTileViewRightEdge \ If we have gone past the right edge, jump to draw4 to BCS draw4 \ return from the subroutine CMP xTileViewer \ If we have gone past the viewer's tile column, jump to BCS draw2 \ draw2 to draw the second half JSR DrawTileAndObjects \ Draw the tile and any objects stacked on it INC xTileToDraw \ Increment the column number to move right along the \ row LDA xTileToDraw \ Set A to the updated column number of the tile we want \ to draw JMP draw1 \ Loop back to draw1 the next tile to the right until we \ reach the viewer's tile column or reach the end of the \ row .draw2 LDA xTileViewRightEdge \ Set A to the column number of the tile at the right \ edge of the visible row we want to draw .draw3 SEC \ Decrement the column counter in A to move left along SBC #1 \ the row BMI draw4 \ If we have reached the start of the row, jump to draw4 \ to return from the subroutine STA xTileToDraw \ Store the updated column number of the tile we want to \ draw CMP xTileViewLeftEdge \ If we have gone past the left edge, jump to draw4 to BCC draw4 \ return from the subroutine CMP xTileViewer \ If we have gone past the viewer's tile column, jump to BCC draw4 \ draw4 to return from the subroutine JSR DrawTileAndObjects \ Draw the tile and any objects stacked on it LDA xTileToDraw \ Set A to the column number of the tile we just drew JMP draw3 \ Loop back to draw1 the next tile to the left until we \ reach the viewer's tile column or reach the end of the \ row .draw4 RTS \ Return from the subroutine