![]() |
Routines |
| Prev: B958 | Up: Map | Next: B9E7 |
|
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.
|
||||||||
| NewHighScore_Enter | B970 | PUSH DE | Save the address of the other score... | |||||
| B971 | PUSH HL | ...and the address of this score. | ||||||
| B972 | LD B,$08 | There are eight places in the table. | ||||||
| B974 | LD DE,$B7F0 | Start with the last place. | ||||||
| NewHighScore_Enter_Compare | B977 | CALL NewHighScore_Compare | Compare the score of the place with the new score using NewHighScore_Compare. | |||||
| B97A | JR NC,NewHighScore_CountPlaces | Jump if the place has a score that is as high, or higher. | ||||||
| B97C | CALL NewHighScore_Next | Move up to the previous place using NewHighScore_Next. | ||||||
| B97F | DJNZ NewHighScore_Enter_Compare | Loop back until all of the places have been tried. | ||||||
| NewHighScore_CountPlaces | B981 | LD A,B | Fetch the number of places that the score is not as high as. | |||||
| B982 | CP $08 | Jump to finish if it is not higher than the last place. | ||||||
| B984 | JR Z,NewHighScore_Enter_Finish | |||||||
| B986 | LD HL,$B7F0 | Point HL at the last place. | ||||||
| B989 | LD DE,$B7F6 | Point DE at HallOfFameWork. | ||||||
| B98C | LD A,B | Work out how many places the new score is higher than... | ||||||
| B98D | NEG | |||||||
| B98F | ADD A,$08 | |||||||
| B991 | LD ($9634),A | ...and keep it. | ||||||
| NewHighScore_Enter_Shift | B994 | LD BC,$0006 | Each place is six bytes. | |||||
| B997 | PUSH HL | Save the address of the place. | ||||||
| B998 | LDIR | Copy the place down one place. | ||||||
| B99A | POP DE | Restore the address of the place... | ||||||
| B99B | LD L,E | ...and move it into HL. | ||||||
| B99C | LD H,D | |||||||
| B99D | CALL NewHighScore_Next | Move DE up to the previous place using NewHighScore_Next. | ||||||
| B9A0 | EX DE,HL | Swap the places, so that HL is the previous place and DE is the one to copy it to. | ||||||
| B9A1 | DEC A | Count down the places. | ||||||
| B9A2 | JR NZ,NewHighScore_Enter_Shift | Loop back until the places have been moved. | ||||||
| B9A4 | POP HL | Fetch the address of the new score... | ||||||
| B9A5 | PUSH HL | ...and save it again. | ||||||
| B9A6 | LD BC,$0003 | The score is three bytes... | ||||||
| B9A9 | LDIR | ...so copy it into the place. | ||||||
| B9AB | PUSH DE | Save the address of the name. | ||||||
| B9AC | CALL PrintHiScore | Show the new hi-score using PrintHiScore. | ||||||
| B9AF | LD A,$01 | Set the flag that says that a name has been entered. | ||||||
| B9B1 | LD ($9633),A | |||||||
| B9B4 | XOR A | Clear the large window to black using ClearLargeWindowWithAttributes. | ||||||
| B9B5 | CALL ClearLargeWindowWithAttributes | |||||||
| B9B8 | LD A,($9634) | Fetch the number of places that the score is higher than... | ||||||
| B9BB | LD B,A | ...and keep it in B. | ||||||
| B9BC | LD A,$FD | Start with an offset of minus three... | ||||||
| NewHighScore_MultiplyPlaces | B9BE | ADD A,$03 | ...and add three for each place that the score is higher than... | |||||
| B9C0 | DJNZ NewHighScore_MultiplyPlaces | Count down the places. | ||||||
| B9C2 | LD C,A | Keep the offset. | ||||||
| B9C3 | LD B,$00 | Clear the high byte of the offset. | ||||||
| B9C5 | LD HL,$BA01 | Point HL at PlaceNames. | ||||||
| B9C8 | ADD HL,BC | Add the offset. | ||||||
| B9C9 | LD DE,$BAE1 | Point DE at InitialsMessage_PlaceName. | ||||||
| B9CC | LD BC,$0003 | The name is three characters. | ||||||
| B9CF | LDIR | Copy it into the message. | ||||||
| B9D1 | LD DE,$BAA5 | Point DE' at InitialsMessage_Attributes. | ||||||
| B9D4 | EXX | Switch that address into DE'. | ||||||
| B9D5 | LD HL,$BAAC | Point HL at InitialsMessage_Coordinates. | ||||||
| B9D8 | LD DE,$BABA | Point DE at InitialsMessage_Text. | ||||||
| B9DB | LD B,$07 | There are seven lines. | ||||||
| B9DD | CALL PrintTextList | Print the message using PrintTextList. | ||||||
| B9E0 | POP DE | Restore the address of the name. | ||||||
| B9E1 | CALL EnterInitials | Ask for the initials using EnterInitials. | ||||||
| NewHighScore_Enter_Finish | B9E4 | POP HL | Restore the address of the score. | |||||
| B9E5 | POP DE | Restore the address of the other score. | ||||||
| B9E6 | RET | Return. | ||||||
|
View the equivalent code in;
|
||||||||
| Prev: B958 | Up: Map | Next: B9E7 |