Prev: B9E7 Up: Map Next: BA01
B9EE: 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 B9EE PUSH BC Save the registers.
B9EF PUSH DE
B9F0 PUSH HL
B9F1 LD B,$03 There are three bytes to compare.
NewHighScore_Compare_Loop B9F3 LD A,(DE) Fetch a byte of the first score.
B9F4 CP (HL) Jump if it is lower than the byte of the second score.
B9F5 JR C,NewHighScore_Compare_Return
B9F7 JR NZ,NewHighScore_Compare_Return Jump if it is higher.
B9F9 INC HL Move on to the next byte of the second score...
B9FA INC DE ...and the first.
B9FB DJNZ NewHighScore_Compare_Loop Loop back until all of the bytes have been compared.
NewHighScore_Compare_Return B9FD POP HL Restore the registers.
B9FE POP DE
B9FF POP BC
BA00 RET Return.
View the equivalent code in;
Prev: B9E7 Up: Map Next: BA01