![]() |
Routines |
| Prev: B5FC | Up: Map | Next: B6AB |
|
Used by the routine at NewHighScore.
Works out whether a score is high enough to go in the hall of fame. If it is then every entry below it is moved down a place, the score is put in the gap and the player is asked to register their initials (see EnterInitials).
The number of places that the score beat is stored in HighScorePosition, so 01 means that the score only beat the sixth place and 06 means that it is the new top score.
|
||||||||||||||||
| NewHighScore_Enter | B61E | PUSH DE | Stash the score pointers on the stack. | |||||||||||||
| B61F | PUSH HL | Stash HL on the stack. | ||||||||||||||
|
We hold six high scores. Start at the sixth one and compare it to the score, moving up while the score is greater.
|
||||||||||||||||
| B620 | LD B,$06 | Set the number of high scores in B to 06. | ||||||||||||||
| B622 | LD DE,$B322 | Point DE at the sixth high score at Pos_6_HighScore_1. | ||||||||||||||
| NewHighScore_Position_Loop | B625 | CALL NewHighScore_Compare | Compare the high score with the score of the player. | |||||||||||||
| B628 | JR NC,NewHighScore_PositionFound | Jump to NewHighScore_PositionFound if the high score is not lower than the score of the player. | ||||||||||||||
| B62A | CALL NewHighScore_Next | Move back to the previous high score. | ||||||||||||||
| B62D | DJNZ NewHighScore_Position_Loop | Decrease the high score counter by one and loop back to NewHighScore_Position_Loop until all of the high scores have been checked. | ||||||||||||||
| NewHighScore_PositionFound | B62F | LD A,B | Fetch the position of the first high score that was not beaten. | |||||||||||||
| B630 | CP $06 | Jump to NewHighScore_Finish if the score did not beat any of the high scores. | ||||||||||||||
| B632 | JR Z,NewHighScore_Finish | |||||||||||||||
|
Move the entries down. The sixth entry moves into the buffer at New_HighScore_1.
|
||||||||||||||||
| B634 | LD HL,$B322 | Point HL at the sixth high score at Pos_6_HighScore_1. | ||||||||||||||
| B637 | LD DE,$B328 | Point DE at the new high score buffer at New_HighScore_1. | ||||||||||||||
| B63A | LD A,B | Fetch the position of the first high score that was not beaten. | ||||||||||||||
| B63B | NEG | Negate the position. | ||||||||||||||
| B63D | ADD A,$06 | A=A+06 (the number of places beaten). | ||||||||||||||
| B63F | LD ($96BB),A | Store the result at HighScorePosition. | ||||||||||||||
| NewHighScore_Move_Loop | B642 | LD BC,$0006 | Set the size of a high score entry in BC to 06. | |||||||||||||
| B645 | PUSH HL | Stash the pointer to the high score on the stack. | ||||||||||||||
| B646 | LDIR | Copy the high score down one place. | ||||||||||||||
| B648 | POP DE | Restore the pointer to the high score into DE. | ||||||||||||||
| B649 | LD L,E | Copy the pointer into HL. | ||||||||||||||
| B64A | LD H,D | |||||||||||||||
| B64B | CALL NewHighScore_Next | Move back to the previous high score. | ||||||||||||||
| B64E | EX DE,HL | Swap DE and HL so the pointers are one entry higher. | ||||||||||||||
| B64F | DEC A | Decrease the number of places beaten by one and loop back to NewHighScore_Move_Loop until all of the high scores have been moved down. | ||||||||||||||
| B650 | JR NZ,NewHighScore_Move_Loop | |||||||||||||||
|
Write the score into the gap.
|
||||||||||||||||
| B652 | POP HL | Restore the pointer to the score of the player from the stack. | ||||||||||||||
| B653 | PUSH HL | Stash the pointer to the score of the player on the stack again. | ||||||||||||||
| B654 | LD BC,$0003 | Set the number of bytes of the score in BC to 03. | ||||||||||||||
| B657 | LDIR | Copy the score into the hall of fame. | ||||||||||||||
| B659 | PUSH DE | Stash the pointer to the initials on the stack. | ||||||||||||||
| B65A | CALL Score_HI | Print the new high score. | ||||||||||||||
| B65D | LD A,($96BA) | Jump to NewHighScore_Update_ClearPanel if the hall of fame has already been shown. | ||||||||||||||
| B660 | AND A | |||||||||||||||
| B661 | JR NZ,NewHighScore_Update_ClearPanel | |||||||||||||||
| B663 | INC A | Set the hall of fame updated flag. | ||||||||||||||
| B664 | LD ($96BA),A | Store the flag in HallOfFameUpdated. | ||||||||||||||
| B667 | LD HL,$61C6 | Point HL at the room data at Room_Special_MainMenu. | ||||||||||||||
| B66A | CALL DrawRoom | Draw the room. | ||||||||||||||
| NewHighScore_Update_ClearPanel | B66D | CALL HallOfFame_Clear | Clear the panel. | |||||||||||||
|
Updates the text for the appropriate player number.
|
||||||||||||||||
| B670 | LD A,($969E) | Fetch the active player from Flag_ActivePlayer. | ||||||||||||||
| B673 | AND A | Is this 1UP or 2UP? | ||||||||||||||
| B674 | LD A,$B1 | A=B1 (ASCII "1"+80). | ||||||||||||||
| B676 | JR Z,NewHighScore_Update_Player | Jump to NewHighScore_Update_Player if the current player is 1UP. | ||||||||||||||
| B678 | INC A | Else, A=B2 (ASCII "2"+80). | ||||||||||||||
|
Overwrite the copy:
|
||||||||||||||||
| NewHighScore_Update_Player | B679 | LD ($B783),A | Write A to B783. | |||||||||||||
|
Work out which of the HighScore_Suffixes to use.
|
||||||||||||||||
| B67C | LD A,($96BB) | Fetch the number of places beaten from HighScorePosition into B. | ||||||||||||||
| B67F | LD B,A | |||||||||||||||
| B680 | LD A,$FD | A=FD (as FD+03=00 - so the offset is then pointing at the base address). | ||||||||||||||
| NewHighScore_Suffix_Loop | B682 | ADD A,$03 | Move onto the next suffix. | |||||||||||||
| B684 | DJNZ NewHighScore_Suffix_Loop | Decrease the position counter by one and loop back to NewHighScore_Suffix_Loop until the offset has been found. | ||||||||||||||
|
Fetch the appropriate position suffix.
|
||||||||||||||||
| B686 | LD C,A | Create an offset in BC. | ||||||||||||||
| B687 | LD B,$00 | |||||||||||||||
| B689 | LD HL,$B6C5 | HL=HighScore_Suffixes + offset. | ||||||||||||||
| B68C | ADD HL,BC | |||||||||||||||
| B68D | LD DE,$B79C | DE=B79C. | ||||||||||||||
| B690 | LD BC,$0003 | BC=03 (counter). | ||||||||||||||
|
Overwrite the copy:
|
||||||||||||||||
| B693 | LDIR | Copy 03 bytes of data from HL to B79C. | ||||||||||||||
|
Print the messaging to the screen.
|
||||||||||||||||
| B695 | LD DE,$B755 | Point DE at the attributes of the lines of text at NewHighScore_Attributes. | ||||||||||||||
| B698 | EXX | Switch to the shadow registers. | ||||||||||||||
| B699 | LD HL,$B75D | Point HL' at the positions of the lines of text at NewHighScore_Position. | ||||||||||||||
| B69C | LD DE,$B76D | Point DE' at the lines of text at NewHighScore_Text. | ||||||||||||||
|
There are eight lines of text.
|
||||||||||||||||
| B69F | LD B,$08 | Set the number of lines of text in the shadow B register to 08. | ||||||||||||||
| B6A1 | CALL GameMenu_Loop | Print the lines of text. | ||||||||||||||
| B6A4 | POP DE | Restore the pointer to the initials from the stack. | ||||||||||||||
| B6A5 | CALL EnterInitials | Let the player enter their initials. | ||||||||||||||
| NewHighScore_Finish | B6A8 | POP HL | Restore the pointer to the score of the player from the stack. | |||||||||||||
| B6A9 | POP DE | Restore DE from the stack. | ||||||||||||||
| B6AA | RET | Return. | ||||||||||||||
|
View the equivalent code in;
|
||||||||||||||||
| Prev: B5FC | Up: Map | Next: B6AB |