![]() |
Routines |
Prev: 7644 | Up: Map |
|
||||||||||
7646 | PUSH HL | |||||||||
7647 | LD HL,$D91F | Blank out the 32-byte buffer at D900 | ||||||||
764A | XOR A | |||||||||
764B | LD B,$1F | |||||||||
764D | LD (HL),A | |||||||||
764E | DEC L | |||||||||
764F | DJNZ $764D | |||||||||
7651 | LD A,$30 | 0x30 is the ASCII code for '0' (zero) | ||||||||
7653 | LD BC,$D8F0 | BC=-10000 | ||||||||
7656 | EX DE,HL | HL=the number, DE=D900 | ||||||||
7657 | ADD HL,BC | Subtract 10000 | ||||||||
7658 | JR C,$7675 | Jump if the number is > 10000 | ||||||||
765A | SBC HL,BC | Add the 10000 back on | ||||||||
765C | LD BC,$FC18 | BC=-1000 | ||||||||
765F | ADD HL,BC | Subtract 1000 | ||||||||
7660 | JR C,$7682 | Jump if the number is > 1000 | ||||||||
7662 | SBC HL,BC | Add the 1000 back on | ||||||||
7664 | LD BC,$FF9C | BC=-100 | ||||||||
7667 | ADD HL,BC | Subtract 100 | ||||||||
7668 | JR C,$768F | Jump if the number is > 100 | ||||||||
766A | SBC HL,BC | Add the 100 back on | ||||||||
766C | LD C,$F6 | BC=-10 | ||||||||
766E | ADD HL,BC | Subtract 10 | ||||||||
766F | JR C,$769B | Jump if the number is > 10 | ||||||||
7671 | SBC HL,BC | Add the 10 back on | ||||||||
7673 | JR $76A3 | |||||||||
We get here if the number is >= 10000.
|
||||||||||
7675 | INC A | Perform trial subtractions of 10000 and get the ASCII code for the 10000s digit in A | ||||||||
7676 | ADD HL,BC | |||||||||
7677 | JR C,$7675 | |||||||||
7679 | SBC HL,BC | Undo the last trial subtraction | ||||||||
767B | LD BC,$FC18 | BC=-1000 | ||||||||
767E | LD (DE),A | Store the ASCII code for the 10000s digit | ||||||||
767F | LD A,$2F | |||||||||
7681 | INC E | Move along in the buffer | ||||||||
7682 | INC A | Perform trial subtractions of 1000 and get the ASCII code for the 1000s digit in A | ||||||||
7683 | ADD HL,BC | |||||||||
7684 | JR C,$7682 | |||||||||
7686 | SBC HL,BC | Undo the last trial subtraction | ||||||||
7688 | LD BC,$FF9C | BC=-100 | ||||||||
768B | LD (DE),A | Store the ASCII code for the 1000s digit | ||||||||
768C | LD A,$2F | |||||||||
768E | INC E | Move along in the buffer | ||||||||
768F | INC A | Perform trial subtractions of 100 and get the ASCII code for the 100s digit in A | ||||||||
7690 | ADD HL,BC | |||||||||
7691 | JR C,$768F | |||||||||
7693 | SBC HL,BC | Undo the last trial subtraction | ||||||||
7695 | LD (DE),A | Store the ASCII code for the 100s digit | ||||||||
7696 | INC E | Move along in the buffer | ||||||||
7697 | LD C,$F6 | BC=-10 | ||||||||
7699 | LD A,$2F | |||||||||
769B | INC A | Perform trial subtractions of 10 and get the ASCII code for the 10s digit in A | ||||||||
769C | ADD HL,BC | |||||||||
769D | JR C,$769B | |||||||||
769F | SBC HL,BC | Undo the last trial subtraction | ||||||||
76A1 | LD (DE),A | Store the ASCII code for the 10s digit | ||||||||
76A2 | INC E | Move along in the buffer | ||||||||
76A3 | LD A,L | Get the ASCII code for the units digit in A | ||||||||
76A4 | ADD A,$30 | |||||||||
76A6 | LD (DE),A | Store the ASCII code for the units digit | ||||||||
76A7 | XOR A | |||||||||
76A8 | INC E | Move along in the buffer | ||||||||
76A9 | LD (DE),A | Mark the end of the number string with a 0 byte | ||||||||
Now that the ASCII codes for the digits of the number have been calculated and stored at D900, generate the corresponding graphic data.
|
||||||||||
76AA | LD E,$00 | DE=D900 (first character in the number string) | ||||||||
76AC | LD A,(DE) | Pick up a character from the number string | ||||||||
76AD | AND A | Have we reached the end of the string? | ||||||||
76AE | JR NZ,$76B2 | Jump if not | ||||||||
76B0 | POP HL | |||||||||
76B1 | RET | |||||||||
76B2 | INC E | Move to the next character in the number string | ||||||||
76B3 | EXX | |||||||||
76B4 | LD L,A | L'=ASCII code for a digit of the number (0x30-0x39) | ||||||||
76B5 | LD H,$D9 | Point HL' at the start of the font data for this digit | ||||||||
76B7 | LD B,(HL) | Pick up the pixel width in B' | ||||||||
76B8 | INC B | Add 1 for left padding | ||||||||
76B9 | XOR A | An empty byte for left padding | ||||||||
76BA | INC H | Point HL' at the next bitmap byte | ||||||||
76BB | EXX | |||||||||
76BC | CALL $7632 | Slide the bitmap byte into the buffer | ||||||||
76BF | EXX | |||||||||
76C0 | LD A,(HL) | Pick up the next bitmap byte | ||||||||
76C1 | DJNZ $76BA | Jump back until all bitmap bytes are done | ||||||||
76C3 | EXX | |||||||||
76C4 | JR $76AC | Jump back to collect the next digit |
Prev: 7644 | Up: Map |