0
|
1 ;=============================================================================
|
|
2 ;
|
634
|
3 ; File menu_processor.inc * combined next generation V3.09.5
|
0
|
4 ;
|
275
|
5 ; Routines to handle all OSTC graphic/text menus.
|
0
|
6 ;
|
|
7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
|
|
8 ;=============================================================================
|
|
9 ; HISTORY
|
|
10 ; 2011-05-30 : [jDG] Creation.
|
|
11
|
634
|
12
|
0
|
13
|
634
|
14 ; Menu Parameters
|
|
15 ; NOTE: needs to be identical in .inc and .asm files!
|
|
16 ;
|
|
17 #define MENU_LINES_MAX_SURF .7 ; max number of lines per screen
|
|
18 #define MENU_LINES_MAX_DIVE .6 ; max number of lines per dive mode menu
|
|
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
|
0
|
21
|
634
|
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
|
169
|
29
|
634
|
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
|
0
|
50
|
634
|
51 ;-----------------------------------------------------------------------------
|
|
52 ; Open a Dive Mode Menu Block
|
|
53 ;
|
|
54 ; nb_items number of menu items that will follow
|
|
55 ;
|
646
|
56 MENU_BEGIN_DIVE MACRO title_text_addr, nb_items
|
634
|
57
|
|
58 items_target set nb_items
|
|
59 items_count set 0
|
0
|
60
|
634
|
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
|
646
|
70 extern title_text_addr ; 2 byte address of multi-lingual title text
|
634
|
71 extern menu_processor
|
|
72 call menu_processor
|
|
73
|
|
74 ; store menu header data
|
|
75 db nb_items, 0x00 ; number of items, encoding for no menu titel
|
646
|
76 db low(title_text_addr), high(title_text_addr) ; address of multi-lingual title text
|
634
|
77 ENDM
|
|
78
|
0
|
79
|
634
|
80 ;-----------------------------------------------------------------------------
|
|
81 ; Open a Surface Mode Menu Block with leading empty Item Lines
|
|
82 ;
|
|
83 ; title_text_addr address of multi-lingual menu title text
|
|
84 ; offset number of empty menu items to start with
|
|
85 ; nb_items number of active menu items that will follow
|
|
86 ;
|
|
87 MENU_BEGIN_OFFSET MACRO title_text_addr, nb_items, offset
|
|
88
|
|
89 items_target set nb_items
|
|
90 items_count set 0
|
582
|
91
|
634
|
92 ; check number of menu items
|
|
93 IF nb_items <= 0
|
|
94 Error "Zero items in menu ", x
|
|
95 ENDIF
|
|
96 IFNDEF scrolling_menu_enabled
|
|
97 IF (nb_items + offset) > MENU_LINES_MAX_SURF
|
|
98 Error "too many items in menu", x
|
|
99 ENDIF
|
|
100 ENDIF
|
|
101
|
|
102 ; compute vertical start position of 1st menu item
|
|
103 IF nb_items > MENU_LINES_MAX_SURF
|
|
104 local vertical_start_pos = ( MENU_VCENTER - (MENU_HEIGHT_SURF/2) * MENU_LINES_MAX_SURF )
|
|
105 ELSE
|
|
106 local vertical_start_pos = ( MENU_VCENTER - (MENU_HEIGHT_SURF/2) * nb_items ) + (MENU_HEIGHT_SURF/2 * offset)
|
|
107 ENDIF
|
|
108
|
|
109 ; store code for menu execution
|
|
110 extern title_text_addr ; 2 byte address of multi-lingual title text
|
|
111 extern menu_processor
|
|
112 call menu_processor
|
0
|
113
|
634
|
114 ; store menu header data
|
|
115 db nb_items, vertical_start_pos ; number of items, vertical start position 1st item
|
|
116 db low(title_text_addr), high(title_text_addr) ; address of multi-lingual title text
|
|
117
|
|
118 ENDM
|
|
119
|
|
120
|
|
121
|
|
122 ;-----------------------------------------------------------------------------
|
|
123 ; Open a Surface Mode Menu Block
|
|
124 ;
|
|
125 ; title_text_addr address of multi-lingual menu title text
|
|
126 ; nb_items number of active menu items that will follow
|
|
127 ;
|
|
128 MENU_BEGIN MACRO title_text_addr, nb_items
|
|
129 MENU_BEGIN_OFFSET title_text_addr, nb_items,0
|
|
130 endm
|
|
131
|
582
|
132
|
634
|
133 ;-----------------------------------------------------------------------------
|
|
134 ; Call Item with dynamic Title
|
|
135 ;
|
|
136 ; title_func_addr address of the function to generate the line title
|
|
137 ; item_func_addr address of the function to be executed on line selection
|
|
138 ;
|
|
139 MENU_DYNAMIC MACRO title_func_addr, item_func_addr
|
|
140
|
|
141 items_count set items_count+1
|
582
|
142
|
634
|
143 ;extern title_func_addr ; 2 byte address of dynamic title function
|
|
144 ;extern item_func_addr ; 2 byte address of item function
|
|
145
|
|
146 local code1 = 0x0000 ; dynamic title
|
|
147 local code2 = 0x0000 ; call function
|
|
148
|
|
149 db low(title_func_addr + code1), high(title_func_addr + code1)
|
|
150 db low(item_func_addr + code2), high(item_func_addr + code2)
|
|
151
|
582
|
152 ENDM
|
0
|
153
|
634
|
154
|
|
155 ;-----------------------------------------------------------------------------
|
|
156 ; Call Item with fixed multi-lingual Title
|
|
157 ;
|
|
158 ; title_text_addr address of multi-lingual item text
|
|
159 ; item_func_addr address of the function to be executed on line selection
|
|
160 ;
|
|
161 MENU_CALL MACRO title_text_addr, item_func_addr
|
582
|
162
|
634
|
163 items_count set items_count+1
|
|
164
|
|
165 extern title_text_addr ; 2 byte address of multi-lingual title text
|
|
166 ;extern item_func_addr ; 2 byte address of item function
|
0
|
167
|
634
|
168 local code1 = 0x0001 ; static multi-lingual title
|
|
169 local code2 = 0x0000 ; call function
|
|
170
|
|
171 db low(title_text_addr + code1), high(title_text_addr + code1)
|
|
172 db low(item_func_addr + code2), high(item_func_addr + code2)
|
|
173
|
582
|
174 ENDM
|
|
175
|
634
|
176
|
|
177 ;-----------------------------------------------------------------------------
|
|
178 ; Option Increment Item with fixed multi-lingual Title, wrap-around after max
|
|
179 ;
|
|
180 ; title_text_addr address of multi-lingual item text
|
|
181 ; option_addr address of option to be incremented on line selection
|
|
182 ;
|
|
183 MENU_OPT_INC MACRO title_text_addr, option_addr
|
|
184
|
|
185 items_count set items_count+1
|
|
186
|
|
187 extern title_text_addr ; 2 byte address of multi-lingual title text
|
|
188 extern option_addr ; 2 byte address of option definition data
|
|
189
|
|
190 local code1 = 0x0001 ; static multi-lingual title
|
|
191 local code2 = 0x0001 ; option increment with wrap-around after max
|
|
192
|
|
193 db low(title_text_addr + code1), high(title_text_addr + code1)
|
|
194 db low(option_addr + code2), high(option_addr + code2)
|
|
195
|
|
196 ENDM
|
|
197
|
|
198
|
|
199 ;-----------------------------------------------------------------------------
|
|
200 ; Option Increment Item with fixed multi-lingual Title, stop at max value
|
|
201 ;
|
|
202 ; title_text_addr address of multi-lingual item text
|
|
203 ; option_addr address of option to be incremented on line selection
|
|
204 ;
|
|
205 MENU_OPT_INCS MACRO title_text_addr, option_addr
|
|
206
|
|
207 items_count set items_count+1
|
|
208
|
|
209 extern title_text_addr ; 2 byte address of multi-lingual title text
|
|
210 extern option_addr ; 2 byte address of option definition data
|
|
211
|
|
212 local code1 = 0x0001 ; static multi-lingual title
|
|
213 local code2 = 0x1001 ; option increment with stop at max value
|
|
214
|
|
215 db low(title_text_addr + code1), high(title_text_addr + code1)
|
|
216 db low(option_addr + code2), high(option_addr + code2)
|
|
217
|
582
|
218 ENDM
|
0
|
219
|
634
|
220
|
|
221 ;-----------------------------------------------------------------------------
|
|
222 ; Option Increment Item for an Option out of an Option Group, with fixed multi-lingual Title
|
|
223 ;
|
|
224 ; title_text_addr address of multi-lingual item text
|
|
225 ; option_addr base address of the option group
|
|
226 ; gaslist_gas offset of the selected option to be incremented within the group (normal variable)
|
|
227 ;
|
|
228 MENU_GRP_INC MACRO title_text_addr, option_addr
|
0
|
229
|
634
|
230 items_count set items_count+1
|
|
231
|
|
232 extern title_text_addr ; 2 byte address of multi-lingual title text
|
|
233 extern option_addr ; 2 byte address of option definition data
|
|
234
|
|
235 local code1 = 0x0001 ; static multi-lingual title
|
|
236 local code2 = 0x4001 ; option increment, group member, wrap-around after max value
|
|
237
|
|
238 db low(title_text_addr + code1), high(title_text_addr + code1)
|
|
239 db low(option_addr + code2), high(option_addr + code2)
|
582
|
240
|
634
|
241 ENDM
|
|
242
|
|
243
|
|
244 ;-----------------------------------------------------------------------------
|
|
245 ; Option Increment Item for an Option out of an Option Group, with fixed multi-lingual Title
|
|
246 ;
|
|
247 ; title_text_addr address of multi-lingual item text
|
|
248 ; option_addr base address of the option group
|
|
249 ; gaslist_gas offset of the selected option to be incremented within the group (normal variable)
|
|
250 ;
|
|
251 MENU_GRP_INCS MACRO title_text_addr, option_addr
|
0
|
252
|
634
|
253 items_count set items_count+1
|
|
254
|
|
255 extern title_text_addr ; 2 byte address of multi-lingual title text
|
|
256 extern option_addr ; 2 byte address of option definition data
|
582
|
257
|
634
|
258 local code1 = 0x0001 ; static multi-lingual title
|
|
259 local code2 = 0x5001 ; option increment, group member, stop at max value
|
|
260
|
|
261 db low(title_text_addr + code1), high(title_text_addr + code1)
|
|
262 db low(option_addr + code2), high(option_addr + code2)
|
|
263
|
582
|
264 ENDM
|
0
|
265
|
634
|
266
|
|
267 ;-----------------------------------------------------------------------------
|
|
268 ; Option Decrement Item with fixed multi-lingual Title, stop at min value
|
|
269 ;
|
|
270 ; title_text_addr address of multi-lingual item text
|
|
271 ; option_addr address of option to be incremented on line selection
|
|
272 ;
|
|
273 MENU_OPT_DECS MACRO title_text_addr, option_addr
|
|
274
|
|
275 items_count set items_count+1
|
|
276
|
|
277 extern title_text_addr ; 2 byte address of multi-lingual title text
|
|
278 extern option_addr ; 2 byte address of option definition data
|
|
279
|
|
280 local code1 = 0x0001 ; static multi-lingual title
|
|
281 local code2 = 0x3001 ; option decrement, stop at min value
|
|
282
|
|
283 db low(title_text_addr + code1), high(title_text_addr + code1)
|
|
284 db low(option_addr + code2), high(option_addr + code2)
|
|
285
|
582
|
286 ENDM
|
0
|
287
|
634
|
288
|
|
289 ;-----------------------------------------------------------------------------
|
|
290 ; Option Decrement Item for an Option out of an Option Group, with fixed multi-lingual Title
|
|
291 ;
|
|
292 ; title_text_addr address of multi-lingual item text
|
|
293 ; option_addr base address of the option group
|
|
294 ; gaslist_gas offset of the selected option to be decremented within the group (normal variable)
|
|
295 ;
|
|
296 MENU_GRP_DECS MACRO title_text_addr, option_addr
|
|
297
|
|
298 items_count set items_count+1
|
|
299
|
|
300 extern title_text_addr ; 2 byte address of multi-lingual title text
|
|
301 extern option_addr ; 2 byte address of option definition data
|
|
302
|
|
303 local code1 = 0x0001 ; static multi-lingual title
|
|
304 local code2 = 0x7001 ; option decrement, group member, stop at min value
|
|
305
|
|
306 db low(title_text_addr + code1), high(title_text_addr + code1)
|
|
307 db low(option_addr + code2), high(option_addr + code2)
|
|
308
|
|
309 ENDM
|
|
310
|
|
311
|
|
312 ;-----------------------------------------------------------------------------
|
|
313 ; Close a Menu Block
|
|
314 ;
|
582
|
315 MENU_END MACRO
|
634
|
316
|
|
317 IF items_count != items_target
|
|
318 Error "menu items count mismatch", x
|
|
319 ENDIF
|
|
320
|
623
|
321 ENDM
|
634
|
322
|
|
323
|
|
324 ;-----------------------------------------------------------------------------
|
|
325
|