Mercurial > public > mk2
annotate code_part1/OSTC_code_asm_part1/strings.inc @ 222:638f8e17bd51
Prototyping deco_gas_volumes() to compute gas consumption per tank with decoplanning.
author | JeanDo |
---|---|
date | Tue, 01 Mar 2011 14:41:10 +0100 |
parents | cdba979821ee |
children |
rev | line source |
---|---|
97 | 1 ;============================================================================= |
2 ; | |
3 ; File strings.inc | |
4 ; | |
5 ; Implementation code various string functions. | |
6 ; | |
7 ; This program is free software: you can redistribute it and/or modify | |
8 ; it under the terms of the GNU General Public License as published by | |
9 ; the Free Software Foundation, either version 3 of the License, or | |
10 ; (at your option) any later version. | |
11 ; | |
12 ; This program is distributed in the hope that it will be useful, | |
13 ; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 ; GNU General Public License for more details. | |
16 ; | |
17 ; You should have received a copy of the GNU General Public License | |
18 ; along with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 ; | |
20 ; Copyright (c) 2010, JD Gascuel. | |
21 ;============================================================================= | |
22 ; HISTORY | |
23 ; 2010-12-02 : [jDG] Creation... | |
24 ; | |
25 ; RATIONALS for STRCAT / STRCPY / STRCAT_PRINT / STRCPY_PRINT: | |
26 ; * Gain PROM space: each time a string operation is done, we have a bunch | |
27 ; of lines in the style: | |
28 ; movlw '+' | |
29 ; movwf POSTINC2 | |
30 ; movlw '/' | |
31 ; movwf POSTINC2 | |
32 ; movlw '-' | |
33 ; movwf POSTINC2 | |
34 ; movlw ':' | |
35 ; movwf POSTINC2 | |
36 ; call word_processor | |
37 ; which takes 20 bytes of PROM space (eg. 4 + chars/4). Whereas : | |
38 ; STRCAT_PRINT "+/-:" | |
39 ; takes just 10 bytes (4 + chars + 1, even rounded up). | |
40 ; | |
41 ; Note that the other common sequence : | |
42 ; OUTPUTTEXT .113 | |
43 ; does compile in (6 bytes per call), plus (1 + chars, even rouded up) | |
44 ; once it the whole code. Also, it is slower to execute, because it have | |
45 ; to roll through the string table. | |
46 ; | |
47 ; RATIONALS for a formating variant... not yet done... | |
48 ; * Embeding formatting commands into the string allows even mode compact | |
49 ; sequence. | |
50 ; Possible commandes: | |
51 ; \xF0 output_8 ; arg in hi, and move lo to hi, | |
52 ; \xF1 output_9 ; so we can have two 8bits concertion | |
53 ; \xF2 output_99 ; in a single sequence... | |
54 ; \xF3 output_99x | |
55 ; \xF4 output_16 ; arg in hi:lo | |
56 ; \xF5 output_16dp 1 | |
57 ; \xF6 output_16dp 2 | |
58 ; \xF7 output_16dp 3 | |
59 ; .... | |
60 ; Usage: | |
61 ; movff apnoe_min, hi | |
62 ; movff apnoe_sec, lo | |
63 ; FORMAT_PRINT "Time: \xF3:\xF3" | |
64 ; | |
65 ; * Cons: code redeability is poor: reader have to remember exactly what | |
66 ; each cryptic hexa code is doing... | |
67 ; No-macro-syntax: | |
68 ; call format_print_block | |
69 ; DB "Time: ", FORMAT_99x, ':', FORMAT_99x, 0 | |
70 ; is denitively more secure in that respect... | |
71 | |
72 ;============================================================================= | |
73 ; Copy a short embebed string at start of the string buffer (letter) | |
74 ; Input: (nothing) | |
75 ; Output: chars are copied into letter, starting at the beginning. | |
76 ; FSR2 point to the first unused char (the NULL termination). | |
77 ; | |
78 ; Trashed: WREG, TBLPTR, TABLAT, PRODL | |
79 ; Note: This are all bank-safe call. | |
80 ; | |
81 STRCPY macro string | |
82 call strcpy_block | |
83 DB string, 0 | |
84 endm | |
85 | |
86 ;============================================================================= | |
87 ; A variant of STRCPY that appends chars to the current FSR2 pointer. | |
88 ; Input/Output/Trashed : see STRCPY. | |
89 STRCAT macro string | |
90 call strcat_block | |
91 DB string, 0 | |
92 endm | |
93 | |
94 ;============================================================================= | |
123 | 95 ; A variant of STRCAT when there is just on char to output |
96 ; Input/Output/Trashed : none. | |
97 PUTC macro char | |
98 movlw char | |
99 movwf POSTINC2 | |
100 endm | |
101 | |
102 ;============================================================================= | |
97 | 103 ; A variant of STRCPY that send the string to the word processor afterwards. |
104 ; Input/Output: see STRCPY. | |
105 ; Trashed: See STRCPY + word_processor. In particular, switch RAM to Bank1 | |
106 ; | |
107 STRCPY_PRINT macro string | |
108 call strcpy_block_print | |
109 DB string, 0 | |
110 endm | |
111 | |
112 ; Trashed: See STRCPY + word_processor. In particular, switch RAM to Bank1 | |
113 STRCAT_PRINT macro string | |
114 call strcat_block_print | |
115 DB string, 0 | |
116 endm | |
117 | |
118 ;============================================================================= | |
119 ; A shortcut for the macros WIN_TOP + WIN_LEFT + WIN_FONT + WIN_INVERT. | |
120 ; The idea is to replace a 4x6=24 bytes sequence by a more compact 6bytes one. | |
121 ; | |
122 ; Trashed: TBLPTR, TABLAT, WREG. | |
123 ; Note: This are all bank-safe call. | |
124 | |
125 WIN_SMALL macro x, y | |
126 call start_small_block | |
127 DB x, y | |
128 endm | |
129 | |
130 WIN_SMALL_INVERT macro x, y | |
131 call start_small_invert_block | |
132 DB x, y | |
133 endm | |
134 | |
135 WIN_MEDIUM macro x, y | |
136 call start_medium_block | |
137 DB x, y | |
138 endm | |
139 | |
140 WIN_MEDIUM_INVERT macro x, y | |
141 call start_medium_invert_block | |
142 DB x, y | |
143 endm | |
144 | |
145 WIN_LARGE macro x, y | |
146 call start_large_block | |
147 DB x, y | |
148 endm | |
149 | |
150 WIN_LARGE_INVERT macro x, y | |
151 call start_large_invert_block | |
152 DB x, y | |
153 endm | |
123 | 154 |
155 ;============================================================================= | |
156 ; A shortcut for PLED_box and PLED_frame call sequences. | |
157 ; | |
158 ; Erase a given screen area. | |
159 WIN_BOX_BLACK macro top, bottom, left, right | |
160 call box_black_block | |
161 db top, (bottom)-(top)+1, left, (right)-(left)+1 | |
162 endm | |
163 | |
164 ; Fill a given screen area with standard color (CF35). | |
165 WIN_BOX_STD macro top, bottom, left, right | |
166 call box_std_block | |
167 db top, (bottom)-(top)+1, left, (right)-(left)+1 | |
168 endm | |
169 | |
170 ; Fill a given screen area with color from WREG (8bits rrrgggbb) | |
171 WIN_BOX_COLOR macro top, bottom, left, right | |
172 call box_color_block | |
173 db top, (bottom)-(top)+1, left, (right)-(left)+1 | |
174 endm | |
175 | |
176 ; Draw a frame in standard color (CF35). | |
177 WIN_FRAME_STD macro top, bottom, left, right | |
178 call box_frame_std | |
179 db top, (bottom)-(top)+1, left, (right)-(left)+1 | |
180 endm | |
181 | |
209
cdba979821ee
frame around logbook scale, some more speed improvements
heinrichsweikamp
parents:
123
diff
changeset
|
182 ; Draw a frame with color from WREG (8bits rrrgggbb) |
cdba979821ee
frame around logbook scale, some more speed improvements
heinrichsweikamp
parents:
123
diff
changeset
|
183 WIN_FRAME_COLOR macro top, bottom, left, right |
cdba979821ee
frame around logbook scale, some more speed improvements
heinrichsweikamp
parents:
123
diff
changeset
|
184 call box_frame_color |
cdba979821ee
frame around logbook scale, some more speed improvements
heinrichsweikamp
parents:
123
diff
changeset
|
185 db top, (bottom)-(top)+1, left, (right)-(left)+1 |
cdba979821ee
frame around logbook scale, some more speed improvements
heinrichsweikamp
parents:
123
diff
changeset
|
186 endm |
123 | 187 |
209
cdba979821ee
frame around logbook scale, some more speed improvements
heinrichsweikamp
parents:
123
diff
changeset
|
188 |