Skip to navigation


Screen buffer: GetColourSup

Name: GetColourSup [Show more] Type: Subroutine Category: Screen buffer Summary: Calculate the colour of a specific pixel byte in the screen buffer
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * DrawObjectEdge (Part 4 of 5) calls GetColourSup * FillAfterObjectSup calls GetColourSup

Arguments: Y The track line number of the pixel byte to check blockNumber The dash data block number of the pixel byte to check
Returns: A The colour of this pixel byte in the screen buffer
IF _SUPERIOR OR _REVSPLUS .GetColourSup CPY horizonLine \ If Y <= horizonLine then the byte we want to check is BCC scol1 \ below the horizon, so jump to scol1 to work out the BEQ scol1 \ byte's colour LDA colourPalette+1 \ Otherwise the byte is in the sky, so set A to logical \ colour 1 (blue) from the colour palette RTS \ Return from the subroutine .scol1 LDA blockNumber \ Set A to the block number containing the pixel byte \ that we want to check CMP rightGrassStart,Y \ If A >= rightGrassStart for this track line, then the BCS scol3 \ pixel byte is in the grass to the right of the track, \ so jump to scol3 to return colour 3 (green) CMP rightVergeStart,Y \ If A >= rightVergeStart for this track line, then the BCS scol5 \ pixel byte is on the right track verge, so jump to \ scol5 to work out its colour CMP leftTrackStart,Y \ If A >= leftTrackStart for this track line, then the BCS scol2 \ pixel byte is on the track, so jump to scol2 to return \ colour 0 (black) CMP leftVergeStart,Y \ If A >= leftVergeStart for this track line, then the BCS scol4 \ pixel byte is on the left track verge, so jump to \ scol4 to work out its colour LDA backgroundColour,Y \ If we get here then the byte is to the left of the \ left track verge, so set A to the background colour of \ this track line so we can extract the colour from bits \ 0-1 below BCC scol7 \ Jump to scol7 to return the pixel byte for the colour \ in A (this BCC is effectively a JMP as we just passed \ through a BCS) .scol2 LDA colourPalette \ Set A to logical colour 0 (black) from the colour \ palette RTS \ Return from the subroutine .scol3 LDA colourPalette+3 \ Set A to logical colour 3 (green) from the colour \ palette RTS \ Return from the subroutine .scol4 \ If we get here then the pixel byte is on the left \ track verge CPY vergeTopLeft \ If the track line in Y >= vergeTopLeft, jump to scol3 BCS scol3 \ to return colour 3 (green) LDA leftSegment,Y \ Set A to the index within the track segment list of \ the segment for the left verge on this track line JMP scol6 \ Jump to scol6 .scol5 \ If we get here then the pixel byte is on the right \ track verge CPY vergeTopRight \ If the track line in Y >= vergeTopRight, jump to scol3 BCS scol3 \ to return colour 3 (green) LDA rightSegment,Y \ Set A to the index within the track segment list of \ the segment for the right verge on this track line .scol6 AND #%01111111 \ Clear bit 7 of A TAX \ Set X to A LDA vergeDataRight-1,X \ Set A to entry X - 1 from vergeDataRight, which \ contains the colour of the verge mark for the segment \ beyond segment X .scol7 AND #%00000011 \ Extract the colour number from bits 0-1 of A into X TAX LDA colourPalette,X \ Set A to logical colour X from the colour palette RTS \ Return from the subroutine ENDIF