Skip to navigation

Aviator on the BBC Micro

Graphics: FlipColours

Name: FlipColours [Show more] Type: Subroutine Category: Graphics Summary: Flip the values of colourCycle and colourLogic to cycle to the next colour state
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * DrawCanopyView calls FlipColours

This routine flips the colourCycle and colourLogic variables between these two states: * colourLogic = %10000000 colourCycle = %00001111 = show colour 1, hide colour 2 * colourLogic = %01000000 colourCycle = %11110000 = show colour 2, hide colour 1 The routine only checks the value of colourCycle, so if colourLogic is %00000000 on entry, it will be set to one of %10000000 and %01000000, so we can use this routine to set the correct state after erasing lines during the colourLogic %00000000 phase.
.FlipColours LDX #%00001111 \ Set the values of X and Y to use if bit 7 of LDY #%10000000 \ colourCycle is set, i.e. %11110000 LDA colourCycle \ If bit 7 of colourCycle is set, i.e. %11110000, jump BMI flip1 \ down to flip1 LDX #%11110000 \ Set X and Y for when bit 7 of colourCycle is clear, LDY #%01000000 \ i.e. %00001111 .flip1 STX colourCycle \ Store X in colourCycle, so colourCycle is now: \ \ * %11110000 if the old colourCycle was %00001111 \ * %00001111 if the old colourCycle was %11110000 STY colourLogic \ Store Y in colourLogic, so colourLogic is now: \ \ * %01000000 if the old colourCycle was %00001111 \ * %10000000 if the old colourCycle was %11110000 RTS \ Return from the subroutine