Skip to navigation


Scoring: CheckFlyingSkills (Part 2 of 2)

Name: CheckFlyingSkills (Part 2 of 2) [Show more] Type: Subroutine Category: Scoring Summary: Perform finer checks to see if we are flying under the bridge or along the main street of the town Deep dive: Flying skills
Context: See this subroutine in context in the source code References: No direct references to this subroutine in this source file
.skil4 BPL skil5 \ If A is negative, flip the bits, so A contains the EOR #&FF \ absolute value of the distance along the z-axis .skil5 CMP #5 \ If the high byte of the distance is 5 or more, then BCS skil2 \ we are too far away from the bridge or town to warrant \ further checks, so jump to skil2 to return from the \ subroutine \ If we get here then we are within a distance of &0500 \ from the place we need to check, in both the x-axis \ and z-axis, so now we need to check exactly where we \ are CPY #2 \ If Y = 2, then we are checking against the suspension BEQ skil7 \ bridge, so jump to skil7 \ If we get here then we are checking where we are \ compared to the town LDA #12 \ If we are inside skill zone 12, jump to skil8 to crash JSR CheckBridgeAndTown \ the plane BCS skil8 LDA #15 \ If we are inside skill zone 15, jump to skil8 to crash JSR CheckBridgeAndTown \ the plane BCS skil8 LDA #9 \ If we are inside skill zone 9, jump to skil8 to crash JSR CheckBridgeAndTown \ the plane BCS skil8 LDA #18 \ If we are outside skill zone 18, jump to slip9 to add JSR CheckBridgeAndTown \ any awarded points to our score BCC skil9 \ If we get here then we are: \ \ * Outside skill zone 12 \ * Outside skill zone 15 \ * Outside skill zone 9 \ * Inside skill zone 18 \ \ This means we are flying along the main street of the \ town, so we have earned ourselves some points, to be \ awarded when we exit skill zone 18 LDA #&20 \ Set A = &20 so we award 200 points for flying down \ main street while upside down LDX row25_char13_1 \ If there is a line at the bottom of the artificial BNE skil10 \ horizon indicator, then the plane is upside down, so \ jump to skil10 to bank these points in pointsToAward \ and return from the subroutine .skil6 LDA #&10 \ Set A = &10 so we award 100 points for flying down \ main street the right way up BNE skil10 \ Jump to skil10 to bank these points in pointsToAward \ and return from the subroutine .skil7 \ If we get here then we are checking where we are \ compared to the suspension bridge LDA #6 \ If we are outside skill zone 6, jump to slip9 to add JSR CheckBridgeAndTown \ any awarded points to our score BCC skil9 LDA #3 \ If we are inside skill zone 3, jump to slip9 to add JSR CheckBridgeAndTown \ any awarded points to our score BCS skil9 LDA #0 \ If we are outside skill zone 0, jump to skil8 to crash JSR CheckBridgeAndTown \ the plane BCC skil8 \ If we get here then we are: \ \ * Inside skill zone 6 \ * Outside skill zone 3 \ * Inside skill zone 0 \ \ This means we are flying under the bridge, so we have \ earned ourselves some points, to be awarded when we \ exit skill zone 6 or enter skill zone 3 LDX row25_char13_1 \ If there is a line at the bottom of the artificial BNE skil6 \ horizon indicator, then the plane is upside down, so \ jump to skil6 to award 100 points for flying under the \ bridge upside down LDA #5 \ Set A = 5 so we award 50 points for flying under the \ bridge the right way up BNE skil10 \ Jump to skil10 to bank these points in pointsToAward \ and return from the subroutine .skil8 TSX \ Add four bytes to the top of the stack, so they can be TXA \ stripped away in Crash routine, along with the two SEC \ bytes currently on the stack SBC #4 TAX TXS JMP Crash \ Jump to the Crash routine as we have just crashed .skil9 LDA pointsToAward \ We get here when we are outside the skill zone, so BEQ skil11 \ check whether we have any points to award, and if \ not, jump to skil11 to return from the subroutine \ If we get here then we have earned ourselves some \ points and have exited the skill zone, so it's time \ to award those points and give a celebratory beep LDX #0 \ Add A * 10 points to the score and make a beep by JSR ScorePoints \ calling ScorePoints with (X A) = (0 A) = A LDA #0 \ Set A = 0 so we set pointsToAward to zero below, so \ we don't award any more points until they are earned .skil10 STA pointsToAward \ Store any points we've earned in pointsToAward, so \ they get awarded when we leave the skill zone (or, if \ A = 0, this does nothing) .skil11 RTS \ Return from the subroutine EQUB &20 \ This byte appears to be unused