![]() |
Routines |
| Prev: 24646 | Up: Map | Next: 24701 |
|
Used by the routine at GameOver.
Compares the score with the high score, one byte at a time starting with the most significant. If the score is higher then it is copied over the high score.
|
||||
| CheckHighScore | 24667 | LD DE,24136 | Point DE at the byte before the high score (24136), as the pointer is incremented before each byte is compared. | |
| 24670 | LD HL,24139 | Point HL at the byte before the score (24139), as the pointer is incremented before each byte is compared. | ||
| 24673 | LD B,3 | Set the byte counter to 3 as the scores are held in three bytes. | ||
| CheckHighScore_Loop | 24675 | INC HL | Move on to the next byte of the score. | |
| 24676 | INC DE | Move on to the next byte of the high score. | ||
| 24677 | LD A,(DE) | Compare the byte of the high score with the same byte of the score. | ||
| 24678 | CP (HL) | |||
| 24679 | JR C,NewHighScore | If the score byte is higher than the high score byte then jump to NewHighScore, as there is a new high score. | ||
| 24681 | JR Z,CheckHighScore_Skip | If the two bytes are the same then jump to CheckHighScore_Skip to compare the next byte. | ||
| 24683 | RET NC | Return if the score byte is lower than the high score byte. | ||
| CheckHighScore_Skip | 24684 | DJNZ CheckHighScore_Loop | Decrease the byte counter by one and loop back to CheckHighScore_Loop until all three bytes have been compared. | |
|
A new High Score has been made, so update HighScore.
|
||||
| NewHighScore | 24686 | LD B,3 | Set the byte counter to 3 as the scores are held in three bytes. | |
| 24688 | LD HL,24140 | Point HL at the score (Score_1). | ||
| 24691 | LD DE,24137 | Point DE at the high score (High_Score). | ||
| NewHighScore_CopyLoop | 24694 | LD A,(HL) | Copy a byte of the score to the high score. | |
| 24695 | LD (DE),A | |||
| 24696 | INC HL | Move on to the next byte of the score. | ||
| 24697 | INC DE | Move on to the next byte of the high score. | ||
| 24698 | DJNZ NewHighScore_CopyLoop | Decrease the byte counter by one and loop back to NewHighScore_CopyLoop until the whole score has been copied. | ||
| 24700 | RET | Return. | ||
| Prev: 24646 | Up: Map | Next: 24701 |