Prev: 47448 Up: Map Next: 47591
47472: Enter High Score
Used by the routine at NewHighScore.
Inserts a score into the hall of fame. The scores of the places that are lower than the new score are moved down one place; then the new score is shown, and the player is asked for their initials.
Input
HL Address of the score
NewHighScore_Enter 47472 PUSH DE Save the address of the other score...
47473 PUSH HL ...and the address of this score.
47474 LD B,8 There are eight places in the table.
47476 LD DE,47088 Start with the last place.
NewHighScore_Enter_Compare 47479 CALL NewHighScore_Compare Compare the score of the place with the new score using NewHighScore_Compare.
47482 JR NC,NewHighScore_CountPlaces Jump if the place has a score that is as high, or higher.
47484 CALL NewHighScore_Next Move up to the previous place using NewHighScore_Next.
47487 DJNZ NewHighScore_Enter_Compare Loop back until all of the places have been tried.
NewHighScore_CountPlaces 47489 LD A,B Fetch the number of places that the score is not as high as.
47490 CP 8 Jump to finish if it is not higher than the last place.
47492 JR Z,NewHighScore_Enter_Finish
47494 LD HL,47088 Point HL at the last place.
47497 LD DE,47094 Point DE at HallOfFameWork.
47500 LD A,B Work out how many places the new score is higher than...
47501 NEG
47503 ADD A,8
47505 LD (38452),A ...and keep it.
NewHighScore_Enter_Shift 47508 LD BC,6 Each place is six bytes.
47511 PUSH HL Save the address of the place.
47512 LDIR Copy the place down one place.
47514 POP DE Restore the address of the place...
47515 LD L,E ...and move it into HL.
47516 LD H,D
47517 CALL NewHighScore_Next Move DE up to the previous place using NewHighScore_Next.
47520 EX DE,HL Swap the places, so that HL is the previous place and DE is the one to copy it to.
47521 DEC A Count down the places.
47522 JR NZ,NewHighScore_Enter_Shift Loop back until the places have been moved.
47524 POP HL Fetch the address of the new score...
47525 PUSH HL ...and save it again.
47526 LD BC,3 The score is three bytes...
47529 LDIR ...so copy it into the place.
47531 PUSH DE Save the address of the name.
47532 CALL PrintHiScore Show the new hi-score using PrintHiScore.
47535 LD A,1 Set the flag that says that a name has been entered.
47537 LD (38451),A
47540 XOR A Clear the large window to black using ClearLargeWindowWithAttributes.
47541 CALL ClearLargeWindowWithAttributes
47544 LD A,(38452) Fetch the number of places that the score is higher than...
47547 LD B,A ...and keep it in B.
47548 LD A,253 Start with an offset of minus three...
NewHighScore_MultiplyPlaces 47550 ADD A,3 ...and add three for each place that the score is higher than...
47552 DJNZ NewHighScore_MultiplyPlaces Count down the places.
47554 LD C,A Keep the offset.
47555 LD B,0 Clear the high byte of the offset.
47557 LD HL,47617 Point HL at PlaceNames.
47560 ADD HL,BC Add the offset.
47561 LD DE,47841 Point DE at InitialsMessage_PlaceName.
47564 LD BC,3 The name is three characters.
47567 LDIR Copy it into the message.
47569 LD DE,47781 Point DE' at InitialsMessage_Attributes.
47572 EXX Switch that address into DE'.
47573 LD HL,47788 Point HL at InitialsMessage_Coordinates.
47576 LD DE,47802 Point DE at InitialsMessage_Text.
47579 LD B,7 There are seven lines.
47581 CALL PrintTextList Print the message using PrintTextList.
47584 POP DE Restore the address of the name.
47585 CALL EnterInitials Ask for the initials using EnterInitials.
NewHighScore_Enter_Finish 47588 POP HL Restore the address of the score.
47589 POP DE Restore the address of the other score.
47590 RET Return.
View the equivalent code in;
Prev: 47448 Up: Map Next: 47591