![]() |
Routines |
| Prev: 37428 | Up: Map | Next: 37532 |
|
Adds points to the score of player one and prints the new score. The score is held as three bytes of binary coded decimal at CurrentPlayerState.
|
||||||||
| AddToScore | 37470 | LD HL,62951 | Use the score. | |||||
| 37473 | LD A,C | Add the low byte of the points. | ||||||
| 37474 | ADD A,(HL) | |||||||
| 37475 | DAA | Adjust for decimal. | ||||||
| 37476 | LD (HL),A | Store the result. | ||||||
| 37477 | INC HL | Move on to the next byte. | ||||||
| 37478 | LD A,B | Add the middle byte of the points. | ||||||
| 37479 | ADC A,(HL) | |||||||
| 37480 | DAA | Adjust for decimal. | ||||||
| 37481 | LD (HL),A | Store the result. | ||||||
| 37482 | INC HL | Move on to the last byte. | ||||||
| 37483 | LD A,0 | Add the carry. | ||||||
| 37485 | ADC A,(HL) | |||||||
| 37486 | DAA | Adjust for decimal. | ||||||
| 37487 | LD (HL),A | Store the result. | ||||||
| 37488 | LD DE,51696 | Use the text record for the score at HUDText_Player1Score. | ||||||
| 37491 | LD B,3 | Set a counter for three bytes. | ||||||
| AddToScore_Digits | 37493 | LD A,(HL) | Fetch a byte of the score. | |||||
| 37494 | RRCA | Shift the top four bits into the bottom four. | ||||||
| 37495 | RRCA | |||||||
| 37496 | RRCA | |||||||
| 37497 | RRCA | |||||||
| 37498 | AND %00001111 | Keep them. | ||||||
| 37500 | ADD A,26 | Add 26 to make the character code of the digit. | ||||||
| 37502 | LD (DE),A | Store it in the text record. | ||||||
| 37503 | INC DE | |||||||
| 37504 | LD A,(HL) | Fetch the byte of the score again. | ||||||
| 37505 | AND %00001111 | Keep the bottom four bits. | ||||||
| 37507 | ADD A,26 | Add 26 to make the character code of the digit. | ||||||
| 37509 | LD (DE),A | Store it in the text record. | ||||||
| 37510 | INC DE | |||||||
| 37511 | DEC HL | Move back to the previous byte of the score. | ||||||
| 37512 | DJNZ AddToScore_Digits | Decrease the counter by one and loop back to AddToScore_Digits until none remain. | ||||||
| 37514 | LD DE,51692 | Use the text record. | ||||||
| 37517 | EXX | Switch registers. | ||||||
| 37518 | PUSH HL | Save the registers. | ||||||
| 37519 | PUSH DE | |||||||
| 37520 | PUSH BC | |||||||
| 37521 | LD DE,51692 | Use the text record. | ||||||
| 37524 | CALL PrintText | Print the score. | ||||||
| 37527 | POP BC | Restore the registers. | ||||||
| 37528 | POP DE | |||||||
| 37529 | POP HL | |||||||
| 37530 | EXX | Switch registers back. | ||||||
| 37531 | RET | Return. | ||||||
|
View the equivalent code in;
|
||||||||
| Prev: 37428 | Up: Map | Next: 37532 |