![]() |
Routines |
| Prev: 50486 | Up: Map | Next: 50625 |
|
Used by the routines at Clear_Colour_Bar_Column and RenderHUD.
Draws the player's score on screen from the packed BCD bytes at Player_1_State (two decimal digits per byte), terminated by 255. Each digit occupies six screen rows; the display row starts at *50196 and advances by 6 per digit. All digits are printed at column 2 via PrintDispatch. After the last digit the score display attributes are refreshed by UpdateAttributeBar_FillBorder. Called from Erase_Narrow_Entity_Sprite and RenderHUD.
|
||||
| PrintPlayerScore | 50500 | LD A,(50196) | Load the initial display row for this score line into C. | |
| 50503 | LD C,A | |||
| 50504 | LD HL,50179 | Point HL at the active player's BCD score at Player_1_State. | ||
| PrintPlayerScore_NextByte | 50507 | LD A,(HL) | Read the next byte from the BCD score string. | |
| 50508 | CP 255 | Jump to PrintPlayerScore_Terminator if all score digits have been printed (terminator 255). | ||
| 50510 | JP Z,PrintPlayerScore_Terminator | |||
| 50513 | AND %11110000 | Isolate the tens digit (high BCD nibble). | ||
| 50515 | JP NZ,PrintPlayerScore_HighNibble | Jump to PrintPlayerScore_HighNibble if the tens digit is non-zero. | ||
| 50518 | LD A,C | Advance the display row by 6 (skip the blank tens-digit row). | ||
| 50519 | ADD A,6 | |||
| 50521 | LD C,A | |||
| 50522 | LD A,(HL) | Reload the BCD byte to test the units digit. | ||
| 50523 | AND %00001111 | Isolate the units digit (low BCD nibble). | ||
| 50525 | JP NZ,PrintPlayerScore_LowNibbleOnly | Jump to PrintPlayerScore_LowNibbleOnly if the units digit is non-zero. | ||
| 50528 | LD A,C | Advance the display row by 6 (skip the blank units-digit row). | ||
| 50529 | ADD A,6 | |||
| 50531 | LD C,A | |||
| 50532 | INC HL | Advance HL to the next BCD byte. | ||
| 50533 | JP PrintPlayerScore_NextByte | Jump back to PrintPlayerScore_NextByte to process the next BCD byte. | ||
|
The tens digit is non-zero; position the score cursor and print both digits of this BCD byte.
|
||||
| PrintPlayerScore_HighNibble | 50536 | LD A,22 | Position the score cursor at row C, column 2. | |
| 50538 | CALL PrintDispatch | |||
| 50541 | LD A,C | |||
| 50542 | CALL PrintDispatch | |||
| 50545 | LD A,2 | |||
| 50547 | CALL PrintDispatch | |||
| 50550 | LD A,(HL) | Reload the BCD byte for digit extraction. | ||
| PrintPlayerScore_NextDigitHigh | 50551 | SRL A | Shift A right four places to extract the tens digit. | |
| 50553 | SRL A | |||
| 50555 | SRL A | |||
| 50557 | SRL A | |||
| 50559 | OR %00110000 | Convert the tens digit to its ASCII character code. | ||
| 50561 | CALL PrintDispatch | Print the tens digit of this score byte. | ||
| PrintPlayerScore_PrintLowNibble | 50564 | LD A,(HL) | Reload the BCD byte for the units digit. | |
| 50565 | AND %00001111 | Isolate the units digit (low BCD nibble). | ||
| 50567 | OR %00110000 | Convert the units digit to its ASCII character code. | ||
| 50569 | CALL PrintDispatch | Print the units digit of this score byte. | ||
| 50572 | INC HL | Advance HL and read the next BCD byte. | ||
| 50573 | LD A,(HL) | |||
| 50574 | CP 255 | Jump back to PrintPlayerScore_NextDigitHigh if more score digits remain. | ||
| 50576 | JP NZ,PrintPlayerScore_NextDigitHigh | |||
| 50579 | CALL UpdateAttributeBar_FillBorder | Call UpdateAttributeBar_FillBorder to refresh the score display attributes. | ||
| 50582 | RET | Return. | ||
|
The tens digit is 0 but the units digit is non-zero; position the score cursor, then jump to PrintPlayerScore_PrintLowNibble to print only the units digit.
|
||||
| PrintPlayerScore_LowNibbleOnly | 50583 | LD A,22 | Position the score cursor at row C, column 2. | |
| 50585 | CALL PrintDispatch | |||
| 50588 | LD A,C | |||
| 50589 | CALL PrintDispatch | |||
| 50592 | LD A,2 | |||
| 50594 | CALL PrintDispatch | |||
| 50597 | JP PrintPlayerScore_PrintLowNibble | Jump to PrintPlayerScore_PrintLowNibble to print the units digit only. | ||
|
All BCD bytes printed; place a trailing zero at the last digit row (row C - 6) and refresh the score display attributes.
|
||||
| PrintPlayerScore_Terminator | 50600 | LD A,22 | Position the score cursor at row C - 6 column 2. | |
| 50602 | CALL PrintDispatch | |||
| 50605 | LD A,C | |||
| 50606 | SUB 6 | |||
| 50608 | CALL PrintDispatch | |||
| 50611 | LD A,2 | |||
| 50613 | CALL PrintDispatch | |||
| 50616 | LD A,48 | Print a trailing zero (48) at the final score digit position. | ||
| 50618 | CALL PrintDispatch | |||
| 50621 | CALL UpdateAttributeBar_FillBorder | Call UpdateAttributeBar_FillBorder to refresh the score display attributes. | ||
| 50624 | RET | Return. | ||
| Prev: 50486 | Up: Map | Next: 50625 |