Mercurial > public > mk2
comparison code_part1/OSTC_code_asm_part1/displaytext.asm @ 174:53b16a746166
Multi-lang
+ Move texts to single compact table.
+ Place at address 0x15000, reserved up to 0x17AFF (10kB)
+ Generate the english_test.asm reference (4kB)
+ Move altimeter texts into the table.
author | JeanDo |
---|---|
date | Thu, 03 Feb 2011 04:09:21 +0100 |
parents | e56f80318b58 |
children | c50296c3059e |
comparison
equal
deleted
inserted
replaced
173:4a7a778d9e49 | 174:53b16a746166 |
---|---|
22 ; known bugs: | 22 ; known bugs: |
23 ; ToDo: | 23 ; ToDo: |
24 | 24 |
25 | 25 |
26 ; These macros output to POSTINC only | 26 ; These macros output to POSTINC only |
27 OUTPUTTEXT macro textnumber ; For Texts 1-254 | 27 OUTPUTTEXT macro n ; For Texts 1-255 |
28 movlw textnumber | 28 If n>.255 |
29 call displaytext0 | 29 Error "Bad low text number", n |
30 Endif | |
31 movlw n | |
32 call displaytext0_low | |
30 endm | 33 endm |
31 | 34 |
32 OUTPUTTEXTH macro textnumber ; For Texts 255-511 | 35 OUTPUTTEXTH macro n ; For Texts 256-511 |
33 movlw LOW textnumber ; Use only Lower 8 Bit | 36 If n<.256 |
34 call displaytext0_h | 37 Error "Bad low text number", n |
38 Endif | |
39 movlw n-.256 ; Use only Lower 8 Bit | |
40 call displaytext0_high | |
35 endm | 41 endm |
36 | 42 |
37 displaytext0_h: | 43 displaytext0_high: |
38 bsf displaytext_high ; Highbit set | 44 bsf displaytext_high ; Highbit set |
39 rcall displaytext0 | 45 bra displaytext0 |
40 return | |
41 | 46 |
47 displaytext0_low: | |
48 bcf displaytext_high ; Highbit clear | |
42 displaytext0: | 49 displaytext0: |
43 bsf output_to_postinc_only | 50 bsf output_to_postinc_only |
44 rcall displaytext1 | 51 bra displaytext |
45 bcf output_to_postinc_only | |
46 return | |
47 | 52 |
48 ; These macros output to POSTINC and call the wordprocessor | 53 ; These macros output to letter[], and call the wordprocessor |
49 DISPLAYTEXT macro textnumber | 54 DISPLAYTEXT macro n |
50 movlw textnumber | 55 movlw n |
51 call displaytext1 | 56 call displaytext_1_low |
52 endm | 57 endm |
53 | 58 |
54 DISPLAYTEXTH macro textnumber | 59 DISPLAYTEXTH macro n |
55 movlw LOW textnumber ; Use only Lower 8 Bit | 60 movlw LOW n ; Use only Lower 8 Bit |
56 call displaytext1h | 61 call displaytext_1_high |
57 endm | 62 endm |
58 | 63 |
59 displaytext1h: | 64 displaytext_1_high: |
60 bsf displaytext_high ; Highbit set | 65 bsf displaytext_high ; Highbit set |
61 rcall displaytext1 | 66 bra displaytext |
62 return | |
63 | 67 |
64 displaytext1: | 68 displaytext_1_low: |
65 movwf textnumber | 69 bcf displaytext_high |
66 movlw b'10000000' | |
67 movwf EECON1 | |
68 | 70 |
69 clrf TBLPTRU | 71 displaytext: |
70 movlw HIGH (textpos_pointer-4) | 72 movwf textnumber |
71 movwf TBLPTRH | 73 movlw LOW(text_pointer-4) |
72 movlw LOW (textpos_pointer-4) ; base address -4 for position table | 74 movwf TBLPTRL |
73 movwf TBLPTRL | 75 movlw HIGH(text_pointer-4) |
76 movwf TBLPTRH | |
77 movlw UPPER(text_pointer-4) | |
78 movwf TBLPTRU | |
74 | 79 |
75 movff textnumber,xA+0 | 80 movlw 4 ; textnumber * 4 --> PROD |
76 movlw d'0' | 81 mulwf textnumber |
77 btfsc displaytext_high ; Highbit set? | |
78 movlw d'1' ; Yes! | |
79 movwf xA+1 ; Set High Bit | |
80 | 82 |
81 bcf STATUS,C | 83 btfsc displaytext_high ; If high text, add 4*256 to PROD |
82 rlcf xA+0,F | 84 addwf PRODH |
83 rlcf xA+1,F ; times 2 for adress | |
84 | 85 |
85 movlw d'2' | 86 movf PRODL,W ; Add PROD to TBLPTR |
86 addwf xA+0,F | 87 addwf TBLPTRL,F |
87 movlw d'0' | 88 movf PRODH,W |
88 addwfc xA+1,F ; + 2 | 89 addwfc TBLPTRH,F |
89 | 90 movlw 0 |
90 movf xA+0,W | 91 addwfc TBLPTRU |
91 addwf TBLPTRL,F ; set adress, data can be read | |
92 movf xA+1,W | |
93 addwfc TBLPTRH,F ; High byte, if required | |
94 | 92 |
95 TBLRD*+ | 93 TBLRD*+ |
96 btfss output_to_postinc_only ; output to postinc only? | 94 movff TABLAT,textaddress+0 ; textaddress:2 holds address for first character |
95 TBLRD*+ | |
96 movff TABLAT,textaddress+1 | |
97 | |
98 btfsc output_to_postinc_only ; output to postinc only? | |
99 bra displaytext2 | |
100 | |
101 TBLRD*+ | |
97 movff TABLAT,win_leftx2 ; No, write coordinates | 102 movff TABLAT,win_leftx2 ; No, write coordinates |
98 | 103 |
99 TBLRD*+ | 104 TBLRD*+ |
100 btfss output_to_postinc_only ; output to postinc only? | 105 movff TABLAT,win_top ; No, write coordinates |
101 movff TABLAT,win_top ; No, write coordinates | |
102 | 106 |
103 movlw d'0' | 107 displaytext2: |
104 movff WREG,win_font ; Bank0 Variable... | 108 clrf WREG ; Reset to small font |
109 movff WREG,win_font ; (BANK 0) | |
105 | 110 |
106 clrf textaddress+0 | 111 movff textaddress+0,TBLPTRL |
107 clrf textaddress+1 | 112 movff textaddress+1,TBLPTRH |
108 clrf TBLPTRH ; Set Pointer for textlength table | |
109 clrf TBLPTRU | |
110 movlw LOW textlength_pointer | |
111 movwf TBLPTRL | |
112 bra displaytext1b | |
113 | |
114 displaytext1a: | |
115 bcf displaytext_high ; Clear flag | |
116 ; Get textadress from textlength table | |
117 displaytext1b: | |
118 TBLRD*+ ; Read from textlength_pointer | |
119 movf TABLAT,W | |
120 addwf textaddress+0,F | |
121 movlw d'0' | |
122 addwfc textaddress+1,F ; textaddress:2 holds address for first character | |
123 decfsz textnumber,F | |
124 bra displaytext1b | |
125 | |
126 btfsc displaytext_high ; Highbit set? | |
127 bra displaytext1a ; Yes, add 256 loops | |
128 | |
129 displaytext2: ; copies text to wordprocessor | |
130 clrf TBLPTRU | |
131 movlw LOW text_pointer | |
132 addwf textaddress+0,W | |
133 movwf TBLPTRL | |
134 movlw HIGH text_pointer ; Base address Texts | |
135 addwfc textaddress+1,W | |
136 movwf TBLPTRH | |
137 | |
138 btfss output_to_postinc_only ; output to postinc2 only? | 113 btfss output_to_postinc_only ; output to postinc2 only? |
139 lfsr FSR2,letter ; no! | 114 lfsr FSR2,letter ; no! |
140 | 115 |
141 displaytext2a: | 116 displaytext3: |
142 TBLRD*+ | 117 TBLRD*+ |
143 movlw '}' ; Text finished? | 118 movf TABLAT,W |
144 cpfseq TABLAT | 119 bz display_text_exit ; Text finished? |
145 bra displaytext3 | 120 movwf POSTINC2 |
146 bra display_text_exit | 121 bra displaytext3 |
147 | |
148 displaytext3: | |
149 movff TABLAT,POSTINC2 | |
150 | |
151 TBLRD*+ | |
152 movlw '}' ; Text finished? | |
153 cpfseq TABLAT | |
154 bra displaytext4 | |
155 bra display_text_exit | |
156 displaytext4: | |
157 movff TABLAT,POSTINC2 | |
158 bra displaytext2a | |
159 | 122 |
160 display_text_exit: | 123 display_text_exit: |
161 btfss output_to_postinc_only ; output to postinc only? | 124 btfss output_to_postinc_only ; output to postinc only? |
162 call word_processor | 125 goto word_processor |
126 | |
127 bcf output_to_postinc_only | |
163 return | 128 return |