![]() |
Routines |
| Prev: 7049 | Up: Map | Next: 70D1 |
|
Used by the routine at GameOver_ControllerRestart.
Finds the higher of the scores of the two players and, if that is higher than the high score at High_Score, makes it the new high score. The scores are stored as three BCD bytes with the most significant byte first.
|
||||
| UpdateHighScore | 708F | LD HL,($5E05) | HL=the first two bytes of the score of 1UP. | |
| 7092 | LD DE,($5E08) | DE=the first two bytes of the score of 2UP. | ||
| 7096 | LD A,L | Swap H and L so that the most significant byte is in H. | ||
| 7097 | LD L,H | |||
| 7098 | LD H,A | |||
| 7099 | LD A,E | Swap D and E so that the most significant byte is in D. | ||
| 709A | LD E,D | |||
| 709B | LD D,A | |||
| 709C | AND A | Compare the first two bytes of the scores. | ||
| 709D | SBC HL,DE | |||
| 709F | JR C,UpdateHighScore_2UP | Jump to UpdateHighScore_2UP if 2UP has the higher score. | ||
| 70A1 | JR NZ,UpdateHighScore_1UP | Jump to UpdateHighScore_1UP if 1UP has the higher score. | ||
| 70A3 | LD A,($5E07) | E=the last byte of the score of 1UP. | ||
| 70A6 | LD E,A | |||
| 70A7 | LD A,($5E0A) | A=the last byte of the score of 2UP. | ||
| 70AA | CP E | Compare the last bytes of the scores. | ||
| 70AB | JR C,UpdateHighScore_1UP | Jump to UpdateHighScore_1UP if 1UP has the higher score. | ||
| UpdateHighScore_2UP | 70AD | LD HL,$5E08 | HL=2UP_Score_1 (the score of 2UP). | |
| UpdateHighScore_Compare | 70B0 | PUSH HL | Stash the pointer to the score on the stack. | |
| 70B1 | LD DE,$5E00 | DE=High_Score (the high score). | ||
| 70B4 | LD B,$03 | Set the byte counter to 03. | ||
| UpdateHighScore_Loop | 70B6 | LD A,(DE) | Jump to UpdateHighScore_Copy if the high score is lower than the score. | |
| 70B7 | CP (HL) | |||
| 70B8 | JR C,UpdateHighScore_Copy | |||
| 70BA | JR NZ,UpdateHighScore_Done | Jump to UpdateHighScore_Done if the high score is higher than the score. | ||
| 70BC | INC HL | Move onto the next byte of each. | ||
| 70BD | INC DE | |||
| 70BE | DJNZ UpdateHighScore_Loop | Decrease the byte counter by one and loop back to UpdateHighScore_Loop until all three bytes have been compared. | ||
| UpdateHighScore_Done | 70C0 | POP HL | Restore the pointer from the stack. | |
| 70C1 | RET | Return. | ||
| UpdateHighScore_Copy | 70C2 | POP HL | Restore the pointer from the stack. | |
| 70C3 | LD DE,$5E00 | DE=High_Score (the high score). | ||
| 70C6 | LD BC,$0003 | BC=03. | ||
| 70C9 | LDIR | Copy the score to the high score. | ||
| 70CB | RET | Return. | ||
| UpdateHighScore_1UP | 70CC | LD HL,$5E05 | HL=1UP_Score_1 (the score of 1UP). | |
| 70CF | JR UpdateHighScore_Compare | Jump to UpdateHighScore_Compare. | ||
| Prev: 7049 | Up: Map | Next: 70D1 |