Skip to navigation


Utility routines: CheckTimePassed

Name: CheckTimePassed [Show more] Type: Subroutine Category: Utility routines Summary: Flag whether 9 centiseconds have passed since the last call
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * MainLoop (Part 12 of 15) calls CheckTimePassed

Arguments: P The current time, incrementing 100 times a second
Returns: C flag Returns: * Clear if fewer than 9 centiseconds have passed since the last call to this routine that reset the counter * Set if 9 centiseconds or more have passed since the last call to this routine, in which case the counter resets
.CheckTimePassed LDX P \ Set X = P TXA \ Set A = P - previousTime SEC \ SBC previousTime \ so A is the number of centiseconds that have passed \ since the last call to this routine (unless the time \ has wrapped, in which case it will be negative) BPL time1 \ If A is positive, skip the following three \ instructions EOR #&FF \ A is negative, so negate A using two's complement, so: CLC \ ADC #1 \ A = |P - previousTime| .time1 CMP #9 \ If |A| < 9, skip the following instruction BCC time2 STX previousTime \ Update previousTime to the current timer in X, so the \ count of 9 centiseconds since the last call can start \ again .time2 RTS \ Return from the subroutine EQUB &3D, &41 \ These bytes appear to be unused EQUB &42, &43 EQUB &77, &78 EQUB &44, &45 EQUB &46, &50