![]() |
Routines |
| Prev: F33E | Up: Map | Next: F3BF |
|
Open a slot in the name table at HallOfFame_Names, copy the new 3-letter name from HallOfFame_Name, then insert the matching score into High_Score.
If the other player also made the table, rank their score too and start name entry for them.
|
||||
|
DE is the byte after the name table and HL is three bytes before that, so copying backwards moves each byte on by three bytes, which is one name row.
|
||||
| InsertHighScore | F345 | LD DE,$5E38 | DE=HallOfFame_NameEnd. | |
| F348 | LD HL,$5E35 | HL=HallOfFame_LastName. | ||
|
Work out how many bytes lie from the insert row down. HighScorePosition holds 08 minus the rank, so this gives back the row count that CompareHighScores returned in B (08 is first place).
|
||||
| F34B | LD A,($5E77) | Fetch HighScorePosition. | ||
| F34E | NEG | Negate it. | ||
| F350 | ADD A,$08 | Add 08. | ||
| F352 | LD B,A | Copy the row count into B. | ||
| F353 | SLA A | Double it. | ||
| F355 | ADD A,B | Add the original count. | ||
| F356 | LD C,A | Copy the byte count into C. | ||
| F357 | LD B,$00 | Clear B. | ||
|
Move the names from the insert row down one row. The old last name is overwritten, and DE is left pointing at the freed slot.
|
||||
| F359 | LDDR | Shuffle the table down. | ||
|
Copy the new name into the freed slot.
|
||||
| F35B | LD HL,$5E78 | HL=HallOfFame_Name. | ||
| F35E | LD BC,$0003 | Copy the new 03-byte name into the table. | ||
| F361 | LDIR | |||
|
Note which player is being ranked. This also acts as the insert flag for CompareHighScores, as it is never zero for 1UP or 2UP.
|
||||
| F363 | LD A,($5E71) | Fetch HighScore_Player. | ||
| F366 | LD ($5E74),A | Write it to HighScore_PlayerCopy. | ||
|
Pick the score of the player who has just entered a name.
|
||||
| F369 | CP $01 | Jump to InsertHighScore_1UP if this is 1UP. | ||
| F36B | JR Z,InsertHighScore_1UP | |||
| F36D | LD DE,$5E62 | DE=2UP_Score_1. | ||
| F370 | JR InsertHighScore_Compare | Jump to InsertHighScore_Compare. | ||
| InsertHighScore_1UP | F372 | LD DE,$5E5F | DE=1UP_Score_1. | |
|
Insert the score into the table at the rank found by CompareHighScores.
|
||||
| InsertHighScore_Compare | F375 | CALL CompareHighScores | Call CompareHighScores. | |
|
Check whether the other player also needs a name. HighScore_OtherPlayer holds the number of the other player, or zero if there is nobody else waiting.
|
||||
| F378 | LD A,($5E72) | Fetch HighScore_OtherPlayer. | ||
| F37B | AND A | Jump to ReturnToRestart if the other player is not pending. | ||
| F37C | JP Z,ReturnToRestart | |||
|
Send 2UP to its own handling, otherwise it is 1UP.
|
||||
| F37F | CP $02 | Jump to InsertHighScore_2UPPending if the other player is 2UP. | ||
| F381 | JP Z,InsertHighScore_2UPPending | |||
|
Switch to the pending 1UP score and compare it with the table.
|
||||
| F384 | LD ($5E71),A | Write it to HighScore_Player. | ||
| F387 | XOR A | Write 00 to HighScore_OtherPlayer. | ||
| F388 | LD ($5E72),A | |||
|
Clearing HighScore_PlayerCopy means that CompareHighScores only returns the rank and leaves the table alone. The score is inserted later, once this player has entered a name.
|
||||
| F38B | LD DE,$5E5F | DE=1UP_Score_1. | ||
| F38E | LD ($5E74),A | Write 00 to HighScore_PlayerCopy. | ||
| F391 | CALL CompareHighScores | Call CompareHighScores. | ||
|
Restart if the score is too low, otherwise start name entry.
|
||||
| F394 | LD A,B | Jump to ReturnToRestart if the score is not high enough. | ||
| F395 | AND A | |||
| F396 | JP Z,ReturnToRestart | |||
| F399 | CALL PrepareNameEntry | Call PrepareNameEntry. | ||
| F39C | JP StartNameEntry | Jump to StartNameEntry. | ||
|
Switch to the pending 2UP score and compare it with the table.
|
||||
| InsertHighScore_2UPPending | F39F | LD ($5E71),A | Write it to HighScore_Player. | |
| F3A2 | XOR A | Write 00 to HighScore_OtherPlayer. | ||
| F3A3 | LD ($5E72),A | |||
|
As above, only rank the score; it is inserted after name entry.
|
||||
| F3A6 | LD DE,$5E62 | DE=2UP_Score_1. | ||
| F3A9 | LD ($5E74),A | Write 00 to HighScore_PlayerCopy. | ||
| F3AC | CALL CompareHighScores | Call CompareHighScores. | ||
|
Restart if the score is too low.
|
||||
| F3AF | LD A,B | Jump to ReturnToRestart if the score is not high enough. | ||
| F3B0 | AND A | |||
| F3B1 | JP Z,ReturnToRestart | |||
|
Make 2UP the active player and start name entry.
|
||||
| F3B4 | LD A,$01 | Write 01 to Flag_ActivePlayer. | ||
| F3B6 | LD ($5E65),A | |||
| F3B9 | CALL PrepareNameEntry | Call PrepareNameEntry. | ||
| F3BC | JP StartNameEntry | Jump to StartNameEntry. | ||
| Prev: F33E | Up: Map | Next: F3BF |