Prev: 52520 Up: Map Next: 52600
52550: Add Status Digits
Used by the routine at Select_Target.
Adds DE to the ASCII digits at Status_Digits, then prints five digits at 20528 (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 52550 LD HL,61356 Point HL at 61356.
52553 LD A,(HL) Add E to the digit.
52554 ADD A,E
52555 LD (HL),A
52556 CP 58 Jump to Add_Status_Digits_Tens if the digit did not overflow.
52558 JR C,Add_Status_Digits_Tens
52560 SUB 10 Subtract 10 from the digit and increase D by one.
52562 LD (HL),A
52563 INC D
Add D to the tens digit.
Add_Status_Digits_Tens 52564 DEC L Add D to the previous digit.
52565 LD A,(HL)
52566 ADD A,D
52567 LD (HL),A
52568 CP 58 Jump to Add_Status_Digits_Print if the digit did not overflow.
52570 JR C,Add_Status_Digits_Print
52572 SUB 10 Subtract 10 from the digit.
52574 LD (HL),A
52575 LD B,3 Set the carry counter to 3 in B.
Propagate the carry through higher digits.
Add_Status_Digits_Carry 52577 DEC L Advance to the previous digit and increment it.
52578 LD A,(HL)
52579 INC A
52580 LD (HL),A
52581 CP 58 Jump to Add_Status_Digits_Print if the digit did not overflow.
52583 JR C,Add_Status_Digits_Print
52585 SUB 10 Subtract 10 from the digit and loop back to Add_Status_Digits_Carry until the carry counter is zero.
52587 LD (HL),A
52588 DJNZ Add_Status_Digits_Carry
Print five digits.
Add_Status_Digits_Print 52590 LD DE,20528 Set the screen address to 20528 (screen buffer) in DE.
52593 LD HL,61352 Point HL at Status_Digits.
52596 LD C,5 Set the character counter to 5 in C.
52598 NOP
52599 NOP
Continue on to Print_Double_Height.
Prev: 52520 Up: Map Next: 52600