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 ;
|
|
56 MENU_BEGIN_DIVE MACRO nb_items
|
|
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
|
|
70 extern menu_processor
|
|
71 call menu_processor
|
|
72
|
|
73 ; store menu header data
|
|
74 db nb_items, 0x00 ; number of items, encoding for no menu titel
|
|
75
|
|
76 ENDM
|
|
77
|
0
|
78
|
634
|
79 ;-----------------------------------------------------------------------------
|
|
80 ; Open a Surface Mode Menu Block with leading empty Item Lines
|
|
81 ;
|
|
82 ; title_text_addr address of multi-lingual menu title text
|
|
83 ; offset number of empty menu items to start with
|
|
84 ; nb_items number of active menu items that will follow
|
|
85 ;
|
|
86 MENU_BEGIN_OFFSET MACRO title_text_addr, nb_items, offset
|
|
87
|
|
88 items_target set nb_items
|
|
89 items_count set 0
|
582
|
90
|
634
|
91 ; check number of menu items
|
|
92 IF nb_items <= 0
|
|
93 Error "Zero items in menu ", x
|
|
94 ENDIF
|
|
95 IFNDEF scrolling_menu_enabled
|
|
96 IF (nb_items + offset) > MENU_LINES_MAX_SURF
|
|
97 Error "too many items in menu", x
|
|
98 ENDIF
|
|
99 ENDIF
|
|
100
|
|
101 ; compute vertical start position of 1st menu item
|
|
102 IF nb_items > MENU_LINES_MAX_SURF
|
|
103 local vertical_start_pos = ( MENU_VCENTER - (MENU_HEIGHT_SURF/2) * MENU_LINES_MAX_SURF )
|
|
104 ELSE
|
|
105 local vertical_start_pos = ( MENU_VCENTER - (MENU_HEIGHT_SURF/2) * nb_items ) + (MENU_HEIGHT_SURF/2 * offset)
|
|
106 ENDIF
|
|
107
|
|
108 ; store code for menu execution
|
|
109 extern title_text_addr ; 2 byte address of multi-lingual title text
|
|
110 extern menu_processor
|
|
111 call menu_processor
|
0
|
112
|
634
|
113 ; store menu header data
|
|
114 db nb_items, vertical_start_pos ; number of items, vertical start position 1st item
|
|
115 db low(title_text_addr), high(title_text_addr) ; address of multi-lingual title text
|
|
116
|
|
117 ENDM
|
|
118
|
|
119
|
|
120
|
|
121 ;-----------------------------------------------------------------------------
|
|
122 ; Open a Surface Mode Menu Block
|
|
123 ;
|
|
124 ; title_text_addr address of multi-lingual menu title text
|
|
125 ; nb_items number of active menu items that will follow
|
|
126 ;
|
|
127 MENU_BEGIN MACRO title_text_addr, nb_items
|
|
128 MENU_BEGIN_OFFSET title_text_addr, nb_items,0
|
|
129 endm
|
|
130
|
582
|
131
|
634
|
132 ;-----------------------------------------------------------------------------
|
|
133 ; Call Item with dynamic Title
|
|
134 ;
|
|
135 ; title_func_addr address of the function to generate the line title
|
|
136 ; item_func_addr address of the function to be executed on line selection
|
|
137 ;
|
|
138 MENU_DYNAMIC MACRO title_func_addr, item_func_addr
|
|
139
|
|
140 items_count set items_count+1
|
582
|
141
|
634
|
142 ;extern title_func_addr ; 2 byte address of dynamic title function
|
|
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
|
582
|
151 ENDM
|
0
|
152
|
634
|
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
|
582
|
161
|
634
|
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
|
0
|
166
|
634
|
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
|
582
|
173 ENDM
|
|
174
|
634
|
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
|
582
|
217 ENDM
|
0
|
218
|
634
|
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
|
0
|
228
|
634
|
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)
|
582
|
239
|
634
|
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
|
0
|
251
|
634
|
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
|
582
|
256
|
634
|
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
|
582
|
263 ENDM
|
0
|
264
|
634
|
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
|
582
|
285 ENDM
|
0
|
286
|
634
|
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 ;
|
582
|
314 MENU_END MACRO
|
634
|
315
|
|
316 IF items_count != items_target
|
|
317 Error "menu items count mismatch", x
|
|
318 ENDIF
|
|
319
|
623
|
320 ENDM
|
634
|
321
|
|
322
|
|
323 ;-----------------------------------------------------------------------------
|
|
324
|