Mercurial > public > hwos_code
comparison src/menu_processor.inc @ 634:4050675965ea
3.10 stable release
author | heinrichsweikamp |
---|---|
date | Tue, 28 Apr 2020 17:34:31 +0200 |
parents | c40025d8e750 |
children | 7d8a4c60ec1a |
comparison
equal
deleted
inserted
replaced
633:690c48db7b5b | 634:4050675965ea |
---|---|
1 ;============================================================================= | 1 ;============================================================================= |
2 ; | 2 ; |
3 ; File menu_processor.asm combined next generation V3.0.4b | 3 ; File menu_processor.inc * combined next generation V3.09.5 |
4 ; | 4 ; |
5 ; Routines to handle all OSTC graphic/text menus. | 5 ; Routines to handle all OSTC graphic/text menus. |
6 ; | 6 ; |
7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved. | 7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved. |
8 ;============================================================================= | 8 ;============================================================================= |
9 ; HISTORY | 9 ; HISTORY |
10 ; 2011-05-30 : [jDG] Creation. | 10 ; 2011-05-30 : [jDG] Creation. |
11 | 11 |
12 ; restart menu-system from first icon/line | 12 |
13 extern menu_processor_reset | 13 |
14 | 14 ; Menu Parameters |
15 ; recall last (automatically) saved icon/line when returning from submenu | 15 ; NOTE: needs to be identical in .inc and .asm files! |
16 extern menu_processor_pop | 16 ; |
17 extern menu_processor_double_pop | 17 #define MENU_LINES_MAX_SURF .7 ; max number of lines per screen |
18 | 18 #define MENU_LINES_MAX_DIVE .6 ; max number of lines per dive mode menu |
19 ; execute the menu block | 19 #define MENU_HEIGHT_SURF .27 ; spacing between menu items in surface mode (pixel) |
20 #define MENU_VCENTER .125 ; vertical center position of menu items | |
21 | |
22 | |
23 ; Menu Processor Functions | |
24 ; | |
25 extern menu_processor_reset ; push current menu item (cursor position) to the stack | |
26 extern menu_processor_pop ; pull current menu item (cursor position) from the stack | |
27 extern menu_processor_double_pop ; pull previous menu item (cursor position) from the stack | |
28 | |
29 | |
30 ; Encoding Format for Menu Item Types | |
31 ; | |
32 ; 1st word with code1 2nd word with code2 item_type Type Functionality | |
33 ; ------------------------------------------------------------------------------------------------------------------------ | |
34 ; tttt tttt tttt ttt0 cccc cccc cccc ccc0 0 MENU_DYNAMIC Call Item with dynamic Title | |
35 ; ~--~ tttt tttt ttt1 cccc cccc cccc ccc0 1 MENU_CALL Call Item with fixed Title (multi-lingual) | |
36 ; ~--~ tttt tttt ttt1 ~000 cccc cccc ccc1 2 MENU_OPT_INC Option Increment with fixed multi-lingual Title | |
37 ; ~--~ tttt tttt ttt1 ~001 cccc cccc ccc1 2 MENU_OPT_INCS as before, but stops at max value | |
38 ; ~--~ tttt tttt ttt1 ~011 cccc cccc ccc1 2 MENU_OPT_DECS as before, but decrement (only stop at min avail) | |
39 ; ~--~ tttt tttt ttt1 ~100 cccc cccc ccc1 2 MENU_GRP_INC Option Increment for an Option out of an Option Group | |
40 ; ~--~ tttt tttt ttt1 ~101 cccc cccc ccc1 2 MENU_GRP_INCS as before, but stops at max value | |
41 ; ~--~ tttt tttt ttt1 ~111 cccc cccc ccc1 2 MENU_GRP_DECS as before, but decrement (only stop at min avail) | |
42 ; | |
43 ; t : Address Bits: title_func_addr or title_text_addr | Attention: title_func_addr and | |
44 ; c : Address Bits: item_func_addr or option_addr | item_func_addr must be within 0x0xxxx | |
45 ; - : unused, reads as zero | |
46 ; ~ : unused, reads as one (part of the real program memory address shining through) | |
47 ; 0/1: fixed Bit Values making up Menu Item Type Encoding | |
48 | |
49 | |
50 | |
51 ;----------------------------------------------------------------------------- | |
52 ; Open a Dive Mode Menu Block | |
53 ; | |
54 ; nb_items number of menu items that will follow | |
55 ; | |
56 MENU_BEGIN_DIVE MACRO nb_items | |
57 | |
58 items_target set nb_items | |
59 items_count set 0 | |
60 | |
61 ; check number of menu items | |
62 IF nb_items <= 0 | |
63 Error "Zero items in menu ", x | |
64 ENDIF | |
65 IF nb_items > MENU_LINES_MAX_DIVE | |
66 Error "too many items in menu", x | |
67 ENDIF | |
68 | |
69 ; store code for menu execution | |
20 extern menu_processor | 70 extern menu_processor |
21 | 71 call menu_processor |
22 ;============================================================================= | 72 |
23 ; Menus parameters | 73 ; store menu header data |
24 | 74 db nb_items, 0x00 ; number of items, encoding for no menu titel |
25 ;NOTE: needs to be identical in .inc and .asm files! | 75 |
26 #define MENU_LINES_MAX .7 ; max number of lines per screen | 76 ENDM |
27 #define MENU_HEIGHT .27 ; spacing on screen | 77 |
28 #define MENU_VCENTER .125 ; position on screen | 78 |
29 | 79 ;----------------------------------------------------------------------------- |
30 ;============================================================================= | 80 ; Open a Surface Mode Menu Block with leading empty Item Lines |
31 | 81 ; |
32 COMMON_BEGIN_MENU MACRO dynamic, txt, nb_items | 82 ; title_text_addr address of multi-lingual menu title text |
33 local center | 83 ; offset number of empty menu items to start with |
34 | 84 ; nb_items number of active menu items that will follow |
35 If nb_items > MENU_LINES_MAX | 85 ; |
36 center set MENU_VCENTER - (MENU_HEIGHT/2) * MENU_LINES_MAX | 86 MENU_BEGIN_OFFSET MACRO title_text_addr, nb_items, offset |
37 Else | 87 |
38 center set MENU_VCENTER - (MENU_HEIGHT/2) * nb_items | 88 items_target set nb_items |
39 Endif | 89 items_count set 0 |
40 | 90 |
41 If nb_items <= 0 | 91 ; check number of menu items |
42 Error "Zero items in menu ", x | 92 IF nb_items <= 0 |
43 Endif | 93 Error "Zero items in menu ", x |
44 | 94 ENDIF |
45 extern txt | 95 IFNDEF scrolling_menu_enabled |
46 call menu_processor | 96 IF (nb_items + offset) > MENU_LINES_MAX_SURF |
47 | 97 Error "too many items in menu", x |
48 ; Push 6 bytes of menu header data | 98 ENDIF |
49 db nb_items, dynamic | 99 ENDIF |
50 db LOW(txt), HIGH(txt) | 100 |
51 db UPPER(txt), center | 101 ; compute vertical start position of 1st menu item |
52 ENDM | 102 IF nb_items > MENU_LINES_MAX_SURF |
53 | 103 local vertical_start_pos = ( MENU_VCENTER - (MENU_HEIGHT_SURF/2) * MENU_LINES_MAX_SURF ) |
54 ;============================================================================= | 104 ELSE |
55 | 105 local vertical_start_pos = ( MENU_VCENTER - (MENU_HEIGHT_SURF/2) * nb_items ) + (MENU_HEIGHT_SURF/2 * offset) |
56 ; Macro to generat (and check) menu vertical menu blocks with data. | 106 ENDIF |
57 | 107 |
58 MENU_BEGIN MACRO menu_title, nb_items | 108 ; store code for menu execution |
59 COMMON_BEGIN_MENU 0, menu_title, nb_items | 109 extern title_text_addr ; 2 byte address of multi-lingual title text |
60 ENDM | 110 extern menu_processor |
61 | 111 call menu_processor |
62 MENU_BEGIN_DYNAMIC MACRO title_proc, nb_items | 112 |
63 COMMON_BEGIN_MENU 1, title_proc, nb_items | 113 ; store menu header data |
64 ENDM | 114 db nb_items, vertical_start_pos ; number of items, vertical start position 1st item |
65 | 115 db low(title_text_addr), high(title_text_addr) ; address of multi-lingual title text |
66 ;============================================================================= | 116 |
67 | 117 ENDM |
68 ; Submenu | 118 |
69 | 119 |
70 MENU_CALL MACRO txt, proc | 120 |
71 extern txt | 121 ;----------------------------------------------------------------------------- |
72 db 0, 0, 0, 0 | 122 ; Open a Surface Mode Menu Block |
73 db LOW(proc), HIGH(proc), UPPER(proc), 0 | 123 ; |
74 db LOW(txt), HIGH(txt) | 124 ; title_text_addr address of multi-lingual menu title text |
75 ENDM | 125 ; nb_items number of active menu items that will follow |
76 | 126 ; |
77 ; Generic option menu | 127 MENU_BEGIN MACRO title_text_addr, nb_items |
78 | 128 MENU_BEGIN_OFFSET title_text_addr, nb_items,0 |
79 MENU_OPTION MACRO txt, option, callback | 129 endm |
80 extern txt | 130 |
81 extern option | 131 |
82 db 2, LOW(callback), HIGH(callback), UPPER(callback) | 132 ;----------------------------------------------------------------------------- |
83 db LOW(option), HIGH(option), UPPER(option), 0 | 133 ; Call Item with dynamic Title |
84 db LOW(txt), HIGH(txt) | 134 ; |
85 ENDM | 135 ; title_func_addr address of the function to generate the line title |
86 | 136 ; item_func_addr address of the function to be executed on line selection |
87 MENU_DYNAMIC MACRO callback, proc | 137 ; |
88 extern callback | 138 MENU_DYNAMIC MACRO title_func_addr, item_func_addr |
89 db 3, LOW(callback), HIGH(callback), UPPER(callback) | 139 |
90 db LOW(proc), HIGH(proc), UPPER(proc), 0 | 140 items_count set items_count+1 |
91 db 0, 0 | 141 |
92 ENDM | 142 ;extern title_func_addr ; 2 byte address of dynamic title function |
93 | 143 ;extern item_func_addr ; 2 byte address of item function |
144 | |
145 local code1 = 0x0000 ; dynamic title | |
146 local code2 = 0x0000 ; call function | |
147 | |
148 db low(title_func_addr + code1), high(title_func_addr + code1) | |
149 db low(item_func_addr + code2), high(item_func_addr + code2) | |
150 | |
151 ENDM | |
152 | |
153 | |
154 ;----------------------------------------------------------------------------- | |
155 ; Call Item with fixed multi-lingual Title | |
156 ; | |
157 ; title_text_addr address of multi-lingual item text | |
158 ; item_func_addr address of the function to be executed on line selection | |
159 ; | |
160 MENU_CALL MACRO title_text_addr, item_func_addr | |
161 | |
162 items_count set items_count+1 | |
163 | |
164 extern title_text_addr ; 2 byte address of multi-lingual title text | |
165 ;extern item_func_addr ; 2 byte address of item function | |
166 | |
167 local code1 = 0x0001 ; static multi-lingual title | |
168 local code2 = 0x0000 ; call function | |
169 | |
170 db low(title_text_addr + code1), high(title_text_addr + code1) | |
171 db low(item_func_addr + code2), high(item_func_addr + code2) | |
172 | |
173 ENDM | |
174 | |
175 | |
176 ;----------------------------------------------------------------------------- | |
177 ; Option Increment Item with fixed multi-lingual Title, wrap-around after max | |
178 ; | |
179 ; title_text_addr address of multi-lingual item text | |
180 ; option_addr address of option to be incremented on line selection | |
181 ; | |
182 MENU_OPT_INC MACRO title_text_addr, option_addr | |
183 | |
184 items_count set items_count+1 | |
185 | |
186 extern title_text_addr ; 2 byte address of multi-lingual title text | |
187 extern option_addr ; 2 byte address of option definition data | |
188 | |
189 local code1 = 0x0001 ; static multi-lingual title | |
190 local code2 = 0x0001 ; option increment with wrap-around after max | |
191 | |
192 db low(title_text_addr + code1), high(title_text_addr + code1) | |
193 db low(option_addr + code2), high(option_addr + code2) | |
194 | |
195 ENDM | |
196 | |
197 | |
198 ;----------------------------------------------------------------------------- | |
199 ; Option Increment Item with fixed multi-lingual Title, stop at max value | |
200 ; | |
201 ; title_text_addr address of multi-lingual item text | |
202 ; option_addr address of option to be incremented on line selection | |
203 ; | |
204 MENU_OPT_INCS MACRO title_text_addr, option_addr | |
205 | |
206 items_count set items_count+1 | |
207 | |
208 extern title_text_addr ; 2 byte address of multi-lingual title text | |
209 extern option_addr ; 2 byte address of option definition data | |
210 | |
211 local code1 = 0x0001 ; static multi-lingual title | |
212 local code2 = 0x1001 ; option increment with stop at max value | |
213 | |
214 db low(title_text_addr + code1), high(title_text_addr + code1) | |
215 db low(option_addr + code2), high(option_addr + code2) | |
216 | |
217 ENDM | |
218 | |
219 | |
220 ;----------------------------------------------------------------------------- | |
221 ; Option Increment Item for an Option out of an Option Group, with fixed multi-lingual Title | |
222 ; | |
223 ; title_text_addr address of multi-lingual item text | |
224 ; option_addr base address of the option group | |
225 ; gaslist_gas offset of the selected option to be incremented within the group (normal variable) | |
226 ; | |
227 MENU_GRP_INC MACRO title_text_addr, option_addr | |
228 | |
229 items_count set items_count+1 | |
230 | |
231 extern title_text_addr ; 2 byte address of multi-lingual title text | |
232 extern option_addr ; 2 byte address of option definition data | |
233 | |
234 local code1 = 0x0001 ; static multi-lingual title | |
235 local code2 = 0x4001 ; option increment, group member, wrap-around after max value | |
236 | |
237 db low(title_text_addr + code1), high(title_text_addr + code1) | |
238 db low(option_addr + code2), high(option_addr + code2) | |
239 | |
240 ENDM | |
241 | |
242 | |
243 ;----------------------------------------------------------------------------- | |
244 ; Option Increment Item for an Option out of an Option Group, with fixed multi-lingual Title | |
245 ; | |
246 ; title_text_addr address of multi-lingual item text | |
247 ; option_addr base address of the option group | |
248 ; gaslist_gas offset of the selected option to be incremented within the group (normal variable) | |
249 ; | |
250 MENU_GRP_INCS MACRO title_text_addr, option_addr | |
251 | |
252 items_count set items_count+1 | |
253 | |
254 extern title_text_addr ; 2 byte address of multi-lingual title text | |
255 extern option_addr ; 2 byte address of option definition data | |
256 | |
257 local code1 = 0x0001 ; static multi-lingual title | |
258 local code2 = 0x5001 ; option increment, group member, stop at max value | |
259 | |
260 db low(title_text_addr + code1), high(title_text_addr + code1) | |
261 db low(option_addr + code2), high(option_addr + code2) | |
262 | |
263 ENDM | |
264 | |
265 | |
266 ;----------------------------------------------------------------------------- | |
267 ; Option Decrement Item with fixed multi-lingual Title, stop at min value | |
268 ; | |
269 ; title_text_addr address of multi-lingual item text | |
270 ; option_addr address of option to be incremented on line selection | |
271 ; | |
272 MENU_OPT_DECS MACRO title_text_addr, option_addr | |
273 | |
274 items_count set items_count+1 | |
275 | |
276 extern title_text_addr ; 2 byte address of multi-lingual title text | |
277 extern option_addr ; 2 byte address of option definition data | |
278 | |
279 local code1 = 0x0001 ; static multi-lingual title | |
280 local code2 = 0x3001 ; option decrement, stop at min value | |
281 | |
282 db low(title_text_addr + code1), high(title_text_addr + code1) | |
283 db low(option_addr + code2), high(option_addr + code2) | |
284 | |
285 ENDM | |
286 | |
287 | |
288 ;----------------------------------------------------------------------------- | |
289 ; Option Decrement Item for an Option out of an Option Group, with fixed multi-lingual Title | |
290 ; | |
291 ; title_text_addr address of multi-lingual item text | |
292 ; option_addr base address of the option group | |
293 ; gaslist_gas offset of the selected option to be decremented within the group (normal variable) | |
294 ; | |
295 MENU_GRP_DECS MACRO title_text_addr, option_addr | |
296 | |
297 items_count set items_count+1 | |
298 | |
299 extern title_text_addr ; 2 byte address of multi-lingual title text | |
300 extern option_addr ; 2 byte address of option definition data | |
301 | |
302 local code1 = 0x0001 ; static multi-lingual title | |
303 local code2 = 0x7001 ; option decrement, group member, stop at min value | |
304 | |
305 db low(title_text_addr + code1), high(title_text_addr + code1) | |
306 db low(option_addr + code2), high(option_addr + code2) | |
307 | |
308 ENDM | |
309 | |
310 | |
311 ;----------------------------------------------------------------------------- | |
312 ; Close a Menu Block | |
313 ; | |
94 MENU_END MACRO | 314 MENU_END MACRO |
95 ENDM | 315 |
316 IF items_count != items_target | |
317 Error "menu items count mismatch", x | |
318 ENDIF | |
319 | |
320 ENDM | |
321 | |
322 | |
323 ;----------------------------------------------------------------------------- | |
324 |