Prev: CD28 Up: Map Next: CD78
CD46: Add Status Digits
Used by the routine at Select_Target.
Adds DE to the ASCII digits at Status_Digits, then prints five digits at 5030 (screen buffer).
Input
DE Amount to add; E is added to the ones digit and D to the tens digit
Add E to the ones digit.
Add_Status_Digits CD46 LD HL,$EFAC Point HL at EFAC.
CD49 LD A,(HL) Add E to the digit.
CD4A ADD A,E
CD4B LD (HL),A
CD4C CP $3A Jump to Add_Status_Digits_Tens if the digit did not overflow.
CD4E JR C,Add_Status_Digits_Tens
CD50 SUB $0A Subtract 0A from the digit and increase D by one.
CD52 LD (HL),A
CD53 INC D
Add D to the tens digit.
Add_Status_Digits_Tens CD54 DEC L Add D to the previous digit.
CD55 LD A,(HL)
CD56 ADD A,D
CD57 LD (HL),A
CD58 CP $3A Jump to Add_Status_Digits_Print if the digit did not overflow.
CD5A JR C,Add_Status_Digits_Print
CD5C SUB $0A Subtract 0A from the digit.
CD5E LD (HL),A
CD5F LD B,$03 Set the carry counter to 03 in B.
Propagate the carry through higher digits.
Add_Status_Digits_Carry CD61 DEC L Advance to the previous digit and increment it.
CD62 LD A,(HL)
CD63 INC A
CD64 LD (HL),A
CD65 CP $3A Jump to Add_Status_Digits_Print if the digit did not overflow.
CD67 JR C,Add_Status_Digits_Print
CD69 SUB $0A Subtract 0A from the digit and loop back to Add_Status_Digits_Carry until the carry counter is zero.
CD6B LD (HL),A
CD6C DJNZ Add_Status_Digits_Carry
Print five digits.
Add_Status_Digits_Print CD6E LD DE,$5030 Set the screen address to 5030 (screen buffer) in DE.
CD71 LD HL,$EFA8 Point HL at Status_Digits.
CD74 LD C,$05 Set the character counter to 05 in C.
CD76 NOP
CD77 NOP
Continue on to Print_Double_Height.
Prev: CD28 Up: Map Next: CD78