![]() |
Routines |
| Prev: A4EC | Up: Map | Next: A59D |
|
Used by the routine at CheckSheriffLost.
Called when the last life of the last player has been lost. It works out which player scored most, and if that score beats the top score of the day it shows the "WELL DONE" screen and stores the new top score. Either way the game then goes back to the title screen.
|
||||
|
The player states are swapped first so that the first player's score is in the current position.
|
||||
| CheckTopScore | A50A | CALL SwapPlayerStates | Swap the states of the two players. | |
|
This entry point is used by the routine at CheckSheriffLost.
Compare the two scores, most significant byte first.
|
||||
| CheckTopScore_SkipSwap | A50D | LD B,$03 | Set the number of bytes in a score to three. | |
| A50F | LD DE,$A257 | Point DE at Bounty. | ||
| A512 | LD HL,$A26A | Point HL at OtherPlayerState. | ||
| CheckTopScore_CompareScoresLoop | A515 | LD A,(DE) | Fetch a byte of the current score. | |
| A516 | CP (HL) | Compare it with the same byte of the other score. | ||
| A517 | INC DE | Move on to the next byte of each score. | ||
| A518 | INC HL | |||
| A519 | JR C,CheckTopScore_SecondPlayer | Jump to CheckTopScore_SecondPlayer if the other score is higher. | ||
| A51B | JR NZ,CheckTopScore_FirstPlayer | Jump to CheckTopScore_FirstPlayer if the current score is higher. | ||
| A51D | DJNZ CheckTopScore_CompareScoresLoop | Loop back until all three bytes have been compared. | ||
|
The other player has the higher score (or the two are equal).
|
||||
| CheckTopScore_SecondPlayer | A51F | LD C,$01 | Set the winner to be player two. | |
| A521 | LD DE,$A26A | Point DE at OtherPlayerState. | ||
|
Compare the winning score with the top score of the day.
|
||||
| CheckTopScore_CompareWithTopScore | A524 | PUSH DE | Stash the address of the winning score on the stack. | |
| A525 | LD HL,$A5D2 | Point HL at TopScore. | ||
| A528 | LD B,$03 | Set the number of bytes in a score to three. | ||
| CheckTopScore_CompareWithTopScoreLoop | A52A | LD A,(DE) | Fetch a byte of the winning score. | |
| A52B | CP (HL) | Compare it with the same byte of the top score. | ||
| A52C | INC DE | Move on to the next byte of each score. | ||
| A52D | INC HL | |||
| A52E | JR C,CheckTopScore_NotBeaten | Jump to CheckTopScore_NotBeaten if the winning score is lower. | ||
| A530 | JR NZ,CheckTopScore_Winner | Jump to CheckTopScore_Winner if the winning score is higher. | ||
| A532 | DJNZ CheckTopScore_CompareWithTopScoreLoop | Loop back until all three bytes have been compared. | ||
| CheckTopScore_NotBeaten | A534 | POP DE | The top score has not been beaten, so discard the address of the winning score. | |
| A535 | JP RestartGame | Restart the game from the title screen. | ||
|
The current player has the higher score.
|
||||
| CheckTopScore_FirstPlayer | A538 | LD C,$00 | Set the winner to be player one. | |
| A53A | LD DE,$A257 | Point DE at Bounty. | ||
| A53D | JR CheckTopScore_CompareWithTopScore | Join in with the comparison with the top score. | ||
|
The top score has been beaten.
|
||||
| CheckTopScore_Winner | A53F | LD A,C | Fetch the winning player. | |
| A540 | ADD A,$31 | Convert it to the character for the player number. | ||
| A542 | LD ($A5B0),A | Write it into the "PLAYER" text. | ||
| A545 | LD E,$00 | Set the attribute to INK:BLACK, PAPER:BLACK. | ||
| A547 | CALL SetAttributes | Clear the attributes. | ||
| A54A | CALL ClearScreen | Clear the pixels of the screen. | ||
| A54D | POP DE | Retrieve the address of the winning score. | ||
| A54E | LD HL,$A5D2 | Point HL at TopScore. | ||
| A551 | LD B,$03 | Set the number of bytes in a score to three. | ||
| A553 | CALL SwapBytes | Swap the two scores, which stores the new top score. | ||
| A556 | LD DE,$A5D2 | Point DE at TopScore. | ||
| A559 | LD HL,$A5CB | Point HL at ScoreMessages_ScoreDigits. | ||
| A55C | CALL ConvertDigits | Convert the score to digits. | ||
|
Print the first line.
|
||||
| A55F | LD HL,$4087 | Point HL at 4087 (in the screen buffer). | ||
| A562 | LD DE,$A59D | Point DE at ScoreMessages. | ||
| A565 | CALL PrintLargeText | Print it in large letters. | ||
|
Print the second line.
|
||||
| A568 | LD HL,$40E8 | Point HL at 40E8 (in the screen buffer). | ||
| A56B | LD DE,$A5A8 | Point DE at ScoreMessages_Player. | ||
| A56E | CALL PrintLargeText | Print it in large letters. | ||
|
Print the third line.
|
||||
| A571 | LD HL,$4846 | Point HL at 4846 (in the screen buffer). | ||
| A574 | LD DE,$A5B2 | Point DE at ScoreMessages_TodaysTop. | ||
| A577 | CALL PrintLargeText | Print it in large letters. | ||
|
Print the fourth line.
|
||||
| A57A | LD HL,$48A8 | Point HL at 48A8 (in the screen buffer). | ||
| A57D | LD DE,$A5BE | Point DE at ScoreMessages_ScoreIs. | ||
| A580 | CALL PrintLargeText | Print it in large letters. | ||
|
Print the fifth line.
|
||||
| A583 | LD HL,$5048 | Point HL at 5048 (in the screen buffer). | ||
| A586 | LD DE,$A5C8 | Point DE at ScoreMessages_Score. | ||
| A589 | CALL PrintLargeText | Print it in large letters. | ||
| A58C | LD DE,$B1E0 | Point DE at FanfareTune. | ||
| A58F | CALL PlayMusic | Play the tune. | ||
| A592 | LD B,$04 | Set the number of delay loops to four. | ||
| A594 | LD HL,$0000 | Set the length of each delay loop. | ||
| A597 | CALL WaitForAWhile | Wait for a while. | ||
| A59A | JP RestartGame | Restart the game from the title screen. | ||
| Prev: A4EC | Up: Map | Next: A59D |