Prev: 6046 Up: Map Next: 607D
605B: Check High Score
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 605B LD DE,$5E48 Point DE at the byte before the high score (5E48), as the pointer is incremented before each byte is compared.
605E LD HL,$5E4B Point HL at the byte before the score (5E4B), as the pointer is incremented before each byte is compared.
6061 LD B,$03 Set the byte counter to 03 as the scores are held in three bytes.
CheckHighScore_Loop 6063 INC HL Move on to the next byte of the score.
6064 INC DE Move on to the next byte of the high score.
6065 LD A,(DE) Compare the byte of the high score with the same byte of the score.
6066 CP (HL)
6067 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.
6069 JR Z,CheckHighScore_Skip If the two bytes are the same then jump to CheckHighScore_Skip to compare the next byte.
606B RET NC Return if the score byte is lower than the high score byte.
CheckHighScore_Skip 606C 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 606E LD B,$03 Set the byte counter to 03 as the scores are held in three bytes.
6070 LD HL,$5E4C Point HL at the score (Score_1).
6073 LD DE,$5E49 Point DE at the high score (High_Score).
NewHighScore_CopyLoop 6076 LD A,(HL) Copy a byte of the score to the high score.
6077 LD (DE),A
6078 INC HL Move on to the next byte of the score.
6079 INC DE Move on to the next byte of the high score.
607A DJNZ NewHighScore_CopyLoop Decrease the byte counter by one and loop back to NewHighScore_CopyLoop until the whole score has been copied.
607C RET Return.
View the equivalent code in;
Prev: 6046 Up: Map Next: 607D