![]() |
Routines |
| Prev: 46556 | Up: Map | Next: 46766 |
|
Used by the routines at ShowLaserEstimate and Calculate_ActivePlayer_Level.
Converts A into packed decimal, with the tens in the high nibble and the units in the low nibble.
|
||||||||||||
|
For an example, given A=22 - the output is 00100010.
First count the number of "10's" in A.
|
||||||||||||
| Convert_Base10 | 46745 | LD BC,10 | Set the tens counter in B to zero and the divisor in C to 10. | |||||||||
| Convert_Base10_Loop | 46748 | INC B | Increment B counter. | |||||||||
| 46749 | SUB C | A-=10. | ||||||||||
| 46750 | JR NC,Convert_Base10_Loop | Jump back to Convert_Base10_Loop until there's a carry amount. | ||||||||||
|
Restore the units and correct the tens count.
|
||||||||||||
| 46752 | ADD A,C | A+=C. | ||||||||||
| 46753 | DEC B | Decrease the counter in B by one to account for the carry. | ||||||||||
|
Move the tens into the high nibble and merge in the units.
|
||||||||||||
| 46754 | SLA B | Shift and rotate B four times. | ||||||||||
| 46756 | SLA B | |||||||||||
| 46758 | SLA B | |||||||||||
| 46760 | SLA B | |||||||||||
| 46762 | AND %00001111 | Keep only bits 0-3. | ||||||||||
| 46764 | OR B | Set the bits from B. | ||||||||||
| 46765 | RET | Return. | ||||||||||
| Prev: 46556 | Up: Map | Next: 46766 |