Prev: 47591 Up: Map Next: 47617
47598: Compare Scores
Used by the routines at NewHighScore and NewHighScore_Enter.
Compares two scores, which are three bytes of binary coded decimal, starting with the most significant byte.
Input
DE Address of the first score
HL Address of the second score
Output
F Carry set if the first is lower, zero set if they are equal
NewHighScore_Compare 47598 PUSH BC Save the registers.
47599 PUSH DE
47600 PUSH HL
47601 LD B,3 There are three bytes to compare.
NewHighScore_Compare_Loop 47603 LD A,(DE) Fetch a byte of the first score.
47604 CP (HL) Jump if it is lower than the byte of the second score.
47605 JR C,NewHighScore_Compare_Return
47607 JR NZ,NewHighScore_Compare_Return Jump if it is higher.
47609 INC HL Move on to the next byte of the second score...
47610 INC DE ...and the first.
47611 DJNZ NewHighScore_Compare_Loop Loop back until all of the bytes have been compared.
NewHighScore_Compare_Return 47613 POP HL Restore the registers.
47614 POP DE
47615 POP BC
47616 RET Return.
View the equivalent code in;
Prev: 47591 Up: Map Next: 47617