![]() |
Routines |
| Prev: 29643 | Up: Map | Next: 29717 |
|
Used by the routine at GameOver_ControllerRestart.
Finds which of the 1UP score and the 2UP score is higher, and if it is higher than the high score (High_Score) then it becomes the new high score.
|
||||
| CheckHighScore | 29651 | LD HL,(24334) | Fetch the first two bytes of the 1UP score. | |
| 29654 | LD DE,(24337) | Fetch the first two bytes of the 2UP score. | ||
| 29658 | LD A,L | Swap the bytes of HL and DE, so the most significant byte of each is first. | ||
| 29659 | LD L,H | |||
| 29660 | LD H,A | |||
| 29661 | LD A,E | |||
| 29662 | LD E,D | |||
| 29663 | LD D,A | |||
| 29664 | AND A | Subtract the 2UP score from the 1UP score. | ||
| 29665 | SBC HL,DE | |||
| 29667 | JR C,CheckHighScore_2UP | Jump to CheckHighScore_2UP if the 2UP score is higher. | ||
| 29669 | JR NZ,CheckHighScore_1UP | Jump to CheckHighScore_1UP if the 1UP score is higher. | ||
| 29671 | LD A,(24336) | Compare 1UP_Score_3 against 2UP_Score_3. | ||
| 29674 | LD E,A | |||
| 29675 | LD A,(24339) | |||
| 29678 | CP E | |||
| 29679 | JR C,CheckHighScore_1UP | Jump to CheckHighScore_1UP if the 1UP score is higher. | ||
| CheckHighScore_2UP | 29681 | LD HL,24337 | Point HL at the 2UP score. | |
| CheckHighScore_Compare | 29684 | PUSH HL | Stash the address of the score on the stack. | |
| 29685 | LD DE,24329 | Point DE at High_Score. | ||
| 29688 | LD B,3 | Set the byte counter to 3 (scores are held in three bytes). | ||
| CheckHighScore_Loop | 29690 | LD A,(DE) | Fetch a byte of the high score. | |
| 29691 | CP (HL) | Compare with the same byte of the score. | ||
| 29692 | JR C,CheckHighScore_New | Jump to CheckHighScore_New if the high score is lower. | ||
| 29694 | JR NZ,CheckHighScore_Finish | Jump to CheckHighScore_Finish if the high score is higher. | ||
| 29696 | INC HL | Move on to the next byte of the score. | ||
| 29697 | INC DE | Move on to the next byte of the high score. | ||
| 29698 | DJNZ CheckHighScore_Loop | Decrease the byte counter by one and loop back to CheckHighScore_Loop until all of the bytes have been compared. | ||
| CheckHighScore_Finish | 29700 | POP HL | Restore the address of the score from the stack. | |
| 29701 | RET | Return. | ||
|
The high score has been beaten.
|
||||
| CheckHighScore_New | 29702 | POP HL | Restore the address of the score from the stack. | |
| 29703 | LD DE,24329 | Point DE at High_Score. | ||
| 29706 | LD BC,3 | Set the number of bytes to copy to 3. | ||
| 29709 | LDIR | Copy the score to the high score. | ||
| 29711 | RET | Return. | ||
| CheckHighScore_1UP | 29712 | LD HL,24334 | Point HL at the 1UP score. | |
| 29715 | JR CheckHighScore_Compare | Jump to CheckHighScore_Compare. | ||
| Prev: 29643 | Up: Map | Next: 29717 |