Prev: 46556 Up: Map Next: 46766
46745: Convert To Base 10
Used by the routines at 46382 and Calculate_ActivePlayer_Level.
Input
A Input number
Output
A Output number
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 BC=0010.
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.
46752 ADD A,C A+=C.
46753 DEC B Decrease the counter in B by one to account for the carry.
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