0
|
1 ;=============================================================================
|
|
2 ;
|
640
|
3 ; File menu_processor.asm * combined next generation V3.12.1
|
0
|
4 ;
|
275
|
5 ; Routines to handle all hwOS graphic/text menus.
|
0
|
6 ;
|
|
7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
|
|
8 ;=============================================================================
|
|
9 ; HISTORY
|
275
|
10 ; 2012-11-02 : [jDG] Cleanup for hwOS: removed icons. Added scrolling.
|
582
|
11 ; But need a font with lower/upper alpha chars...
|
0
|
12
|
604
|
13 #include "hwos.inc"
|
0
|
14 #include "convert.inc"
|
|
15 #include "strings.inc"
|
|
16 #include "tft.inc"
|
|
17 #include "varargs.inc"
|
|
18 #include "start.inc"
|
|
19 #include "surfmode.inc"
|
|
20 #include "divemode.inc"
|
|
21 #include "tft_outputs.inc"
|
|
22 #include "eeprom_rs232.inc"
|
62
|
23 #include "adc_lightsensor.inc"
|
604
|
24 #include "i2c.inc"
|
623
|
25 #include "rtc.inc"
|
|
26 #include "wait.inc"
|
634
|
27 #include "colorschemes.inc"
|
229
|
28
|
0
|
29
|
604
|
30 ; NOTE: needs to be identical in .inc and .asm !
|
634
|
31 ;
|
623
|
32 #define MENU_LINES_MAX .7 ; maximum number of lines per screen
|
604
|
33 #define MENU_LEFT .20 ; position of first menu item
|
634
|
34 #define MENU_HEIGHT_SURF .27 ; spacing between menu item in surface mode (pixel)
|
|
35 #define MENU_HEIGHT_DIVE .24 ; spacing between menu item in surface mode (pixel)
|
604
|
36 #define MENU_VCENTER .125 ; position on screen
|
634
|
37 #define MAX_LINE_LENGTH_TITLE .17 ; max menu title length (characters)
|
|
38 #define MAX_LINE_LENGTH_SURF .20 ; max menu item length in surface menu (characters)
|
|
39 #define MAX_LINE_LENGTH_DIVE .10 ; max menu item length in dive mode menu (characters)
|
|
40 #define MENU_ITEM_DATA_SIZE .4 ; size of a menu item data block
|
0
|
41
|
634
|
42 ; Alias for easier code reading
|
|
43 #define option_addr item_funct_addr
|
0
|
44
|
|
45
|
634
|
46 extern option_adjust_group_member
|
|
47 extern option_inc
|
|
48 extern option_dec
|
|
49 extern option_draw
|
623
|
50
|
634
|
51 extern rtc_set_rtc
|
|
52 extern divemode_option_divemenu_return
|
0
|
53
|
604
|
54
|
|
55 ;=============================================================================
|
634
|
56 menu_proc CODE
|
|
57 ;=============================================================================
|
0
|
58
|
634
|
59
|
|
60 ;-----------------------------------------------------------------------------
|
|
61 ; Entry Point for Menu Processor, called by MENU_BEGIN Macros
|
0
|
62 ;
|
634
|
63 global menu_processor
|
|
64 menu_processor:
|
|
65 ; read menu header
|
|
66 VARARGS_BEGIN ; load TBLPTR with start address of the menu header data
|
|
67 clrf STKPTR ; never return from here
|
|
68
|
|
69 VARARGS_GET8 menu_item_count ; get number of items
|
|
70 VARARGS_GET8 menu_vertical_start ; get vertical start position of 1st menu item
|
|
71
|
640
|
72 movf menu_vertical_start,W ; excite flags, vertical start = 0, i.e. no menu title text?
|
|
73 bz menu_processor_no_title ; YES - skip reading menu title text address
|
634
|
74
|
|
75 VARARGS_GET16 menu_title_addr ; get address of menu title text
|
|
76
|
|
77 menu_processor_no_title:
|
0
|
78
|
640
|
79 movff TBLPTRL, menu_item_data_start+0 ; store base address of menu items for menu_read_menu_item_data
|
634
|
80 movff TBLPTRH, menu_item_data_start+1 ; ...
|
|
81 movff TBLPTRU, menu_item_data_start+2 ; ...
|
|
82
|
|
83 btfss divemode ; in dive mode?
|
|
84 bra menu_processor_menu_title ; NO - no frame in surface mode menu
|
|
85
|
|
86 ; required for menus with less entries than the calling menu but not so nice when setting up gas 6.... mH
|
|
87 movlw .1 ; menu_pos_cur = 1 ?
|
|
88 cpfsgt menu_pos_cur ; ...
|
|
89 call TFT_clear_divemode_menu ; YES - clear the menu
|
|
90
|
|
91 ; draw a frame around the dive mode menu
|
|
92 movf pallet_color_mask,W ; get mask color into WREG
|
|
93 WIN_FRAME_COLOR dm_menu_row, dm_menu_lower, dm_menu_left ,dm_menu_right ; top, bottom, left, right
|
|
94 bra menu_processor_menu_body ; the dive mode menu has no menu title and footer
|
0
|
95
|
634
|
96 menu_processor_menu_title:
|
|
97 ; prepare screen
|
640
|
98 btfsc screen_type3 ; screen type 3 ?
|
|
99 bra menu_processor_menu_title1 ; YES - screen type 3 has no backlight
|
634
|
100 clrf CCP1CON ; stop PWM
|
|
101 bcf PORTC,2 ; fade out backlight
|
640
|
102 menu_processor_menu_title1:
|
634
|
103 call TFT_ClearScreen ; clear screen
|
|
104
|
|
105 ; draw menu title
|
|
106 WIN_BOX_BLACK .2,.23,.0,.159 ; clear menu title area
|
|
107 WIN_STD .0, .2 ; set menu title font and position
|
|
108 FONT_COLOR color_greenish ; set menu title font color
|
|
109 movff menu_title_addr+0,FSR1L ; point to multi-lingual menu title text
|
|
110 movff menu_title_addr+1,FSR1H ; ...
|
|
111 call strcpy_text_FSR ; copy translated text into the buffer
|
|
112 movf FSR2L,W ; get title text length
|
|
113 mullw .9 ; compute title length in pixels_x2
|
|
114 bcf STATUS,C ; divide by 2
|
|
115 rrcf PRODL ; ...
|
|
116 movf PRODL,W ; get result into WREG
|
|
117 sublw .80 ; compute 80 (screen center position) - half title width in pixel_x2
|
|
118 movwf win_leftx2 ; set result as horizontal start position
|
|
119 movlw MAX_LINE_LENGTH_TITLE ; load max allowed length of a menu title
|
|
120 movwf FSR2L ; set buffer pointer to end of max length
|
|
121 clrf INDF2 ; terminate string at max length
|
|
122 PRINT ; output menu title
|
0
|
123
|
634
|
124 ; draw footer line
|
|
125 FONT_COLOR_MEMO ; select default color
|
|
126 WIN_TINY .5, .224 ; tiny font, left position
|
|
127 STRCPY_TEXT_PRINT tNext ; print "Next"
|
|
128 WIN_TINY .124, .224 ; tiny font, righ position
|
|
129 STRCPY_TEXT_PRINT tEnter ; print "Enter"
|
0
|
130
|
634
|
131 menu_processor_menu_body:
|
|
132 FONT_SIZE FT_SMALL ; select font size
|
|
133 bra menu_vertical ; draw the menu items
|
|
134
|
|
135
|
|
136 ;-----------------------------------------------------------------------------
|
|
137 ; Helper Function - call Callback-Function to draw the Menu Item Title
|
|
138 ;
|
0
|
139 menu_processor_call_title:
|
634
|
140 movff menu_title_addr+2,PCLATU ; execute computed goto
|
|
141 movff menu_title_addr+1,PCLATH ; ...
|
|
142 movf menu_title_addr+0,W ; ...
|
|
143 movwf PCL ; ...
|
582
|
144
|
634
|
145
|
|
146 ;-----------------------------------------------------------------------------
|
|
147 ; Clear all memorized Menu Item Selections and restart with Cursor on first Item
|
604
|
148 ;
|
582
|
149 global menu_processor_reset
|
0
|
150 menu_processor_reset:
|
634
|
151 clrf menustack ; clear first stack position
|
|
152 clrf menustack_pointer ; set stack pointer to first stack position
|
|
153 clrf selected_item ; set cursor position to first menu item
|
|
154 return ; done
|
0
|
155
|
582
|
156
|
634
|
157 ;-----------------------------------------------------------------------------
|
|
158 ; Pull / Double-Pull Cursor Position from Stack
|
|
159 ;
|
582
|
160 global menu_processor_double_pop
|
623
|
161 global menu_processor_pop
|
582
|
162 menu_processor_double_pop:
|
623
|
163 decf menustack_pointer,F ; decrement stack pointer
|
|
164 menu_processor_pop:
|
|
165 decf menustack_pointer,F ; decrement stack pointer
|
|
166 btfsc menustack_pointer,7 ; did the stack pointer under-run?
|
|
167 clrf menustack_pointer ; YES - reset stack pointer to first stack position
|
|
168 movf menustack_pointer,W ; load stack pointer into WREG
|
|
169 lfsr FSR2,menustack ; load base address of menu stack
|
634
|
170 movff PLUSW2,selected_item ; retrieve cursor position from stack
|
623
|
171 return ; done
|
|
172
|
0
|
173
|
634
|
174 ;-----------------------------------------------------------------------------
|
|
175 ; Push Cursor Position onto Stack
|
|
176 ;
|
0
|
177 menu_processor_push:
|
623
|
178 lfsr FSR2,menustack ; load base address of menu stack
|
|
179 movf menustack_pointer,W ; load stack pointer into WREG
|
634
|
180 movff selected_item,PLUSW2 ; save cursor position to stack
|
623
|
181 incf menustack_pointer,W ; increment stack pointer, park result in WREG
|
|
182 btfss WREG,3 ; result < 8 ?
|
|
183 movwf menustack_pointer ; YES - update stack pointer
|
634
|
184 clrf selected_item ; set cursor to first item in new menu
|
623
|
185 return ; done
|
|
186
|
0
|
187
|
634
|
188 ;-----------------------------------------------------------------------------
|
|
189 ; Helper Function - call Menu Item Function
|
|
190 ;
|
|
191 menu_call_item_function:
|
|
192 bcf switch_right ; clear button event
|
|
193 movf selected_item,W ; copy current cursor position to WREG
|
|
194 rcall menu_read_menu_item_data ; read item function address
|
|
195 movff selected_item,PRODL ; pass cursor position (menu item number) to call function
|
|
196 rcall menu_processor_push ; push current cursor position onto stack
|
|
197 clrf PCLATU ; execute computed goto
|
|
198 movff item_funct_addr+1,PCLATH ; ...
|
|
199 movf item_funct_addr+0,W ; ...
|
|
200 movwf PCL ; ...
|
0
|
201
|
634
|
202
|
|
203 ;-----------------------------------------------------------------------------
|
|
204 ; Read Menu Item Data
|
0
|
205 ;
|
634
|
206 menu_read_menu_item_data:
|
|
207 cpfsgt menu_item_count ; selected menu item valid? || * Safety Check * to prevent any computed
|
|
208 clrf WREG ; NO - change selection to first item || goto to an illegal random target address
|
|
209
|
|
210 mullw MENU_ITEM_DATA_SIZE ; compute menu item data offset
|
|
211 movf PRODL,W ; add offset to base address of menu data block and set up TBLPTR
|
|
212 addwf menu_item_data_start+0,W ; ...
|
|
213 movwf TBLPTRL ; ...
|
|
214 movf PRODH,W ; ...
|
|
215 addwfc menu_item_data_start+1,W ; ...
|
|
216 movwf TBLPTRH ; ...
|
|
217 movlw 0 ; ...
|
|
218 addwfc menu_item_data_start+2,W ; ...
|
|
219 movwf TBLPTRU ; ...
|
|
220
|
|
221 VARARGS_GET16 item_title_addr ; read address of item title function or title text | with embedded
|
|
222 VARARGS_GET16 item_funct_addr ; read address of item call function or option definition data | menu item type
|
0
|
223
|
634
|
224 movlw .2 ; probe for menu item type = OPTION
|
|
225 btfsc item_funct_addr,0 ; is type OPTION?
|
|
226 bra menu_read_menu_item_data_1 ; YES
|
|
227
|
|
228 movlw .1 ; probe for menu item type = MENU_CALL
|
|
229 btfsc item_title_addr,0 ; is type MENU_CALL?
|
|
230 bra menu_read_menu_item_data_1 ; YES
|
|
231
|
|
232 movlw .0 ; must be MENU_DYNAMIC
|
0
|
233
|
634
|
234 menu_read_menu_item_data_1:
|
|
235 movwf item_type ; store menu item type
|
|
236 bcf item_title_addr+0,0 ; strip menu item type encoding from addresses (reset to even addresses)
|
|
237 bcf item_funct_addr+0,0 ; ...
|
|
238
|
|
239 return ; done
|
|
240
|
|
241
|
|
242 ;-----------------------------------------------------------------------------
|
|
243 ; Menu HMI Operation
|
0
|
244 ;
|
582
|
245 global menu_vertical
|
0
|
246 menu_vertical:
|
634
|
247 rcall menu_draw_menu_items ; draw all menu items
|
|
248 movlw CCP1CON_VALUE ; load PWM setting
|
623
|
249 btfss divemode ; in dive mode?
|
604
|
250 movwf CCP1CON ; NO - power-on backlight
|
0
|
251
|
634
|
252 menu_vertical_loop:
|
|
253 movf selected_item,W ; get cursor position into WREG
|
|
254 rcall menu_read_menu_item_data ; read menu item data
|
|
255 movf item_funct_addr+0,W ; check if execute function call address is NULL
|
|
256 iorwf item_funct_addr+1,W ; ...
|
|
257 bz next_line_menu ; YES - not selectable, step cursor to next menu item
|
640
|
258 btfsc divemode ; NO - in dive mode?
|
|
259 bra menu_line_loop_pre1 ; YES - skip next
|
634
|
260 rcall menu_draw_cursor_surf ; NO - draw the cursor (main menu style)
|
640
|
261 btfss imprint_time_date ; - currently imprinting the current time & date?
|
634
|
262 bra menu_line_loop_pre1 ; NO - skip
|
640
|
263 btfss switch_right ; YES - right button pressed, i.e. time or date changed?
|
|
264 bra menu_line_loop_pre1 ; NO - skip
|
|
265 call TFT_imprint_time_date_fast ; YES - show a fast response on the screen (may momentarily show an illegal day/month combination)
|
|
266 call rtc_set_rtc ; - update time and date on RTC module (corrects illegal day/month combinations)
|
0
|
267
|
|
268 menu_line_loop_pre1:
|
623
|
269 bcf switch_right ; clear left-over right button event
|
|
270 bcf switch_left ; clear left-over left button event
|
0
|
271
|
634
|
272 menu_line_loop_pre2:
|
623
|
273 btfsc divemode ; in dive mode?
|
631
|
274 goto divemode_option_divemenu_return ; YES - return to it
|
634
|
275 call reset_timeout_surfmode ; NO - reset timeout
|
640
|
276 ;bra menu_line_loop ; - operate menu HMI
|
604
|
277
|
623
|
278 menu_line_loop:
|
640
|
279 call housekeeping ; handle data imprinting, screen dump request, timeout and entering dive mode
|
|
280 btfsc switch_right ; right button pressed?
|
|
281 bra do_line_menu ; YES - execute menu item function
|
|
282 btfss switch_left ; NO - left button pressed?
|
|
283 bra menu_line_loop ; NO - loop
|
|
284 next_line_menu: ; YES - step cursor to next menu item
|
|
285 bcf switch_left ; - clear button event
|
|
286 incf selected_item,F ; - increment cursor position to next item
|
|
287 movf selected_item,W ; - copy new item number to WREG
|
|
288 cpfseq menu_item_count ; - new item number beyond number of menu items?
|
|
289 bra menu_vertical_loop ; NO - redraw cursor
|
|
290 clrf selected_item ; YES - reset cursor position to first item
|
|
291 bra menu_vertical_loop ; - redraw cursor
|
604
|
292
|
0
|
293
|
634
|
294 ;-----------------------------------------------------------------------------
|
|
295 ; Execute Menu Item Function
|
|
296 ;
|
582
|
297 global do_line_menu
|
0
|
298 do_line_menu:
|
634
|
299 decf menu_pos_cur,W ; get selected menu item (0-5) into WREG
|
623
|
300 btfsc divemode ; in dive mode?
|
634
|
301 movwf selected_item ; YES - take selected menu item from dive mode
|
|
302 movf selected_item,W ; copy selected menu item to WREG
|
|
303 rcall menu_read_menu_item_data ; read menu item data
|
|
304 movf item_type,W ; switch on menu item type
|
|
305 bz menu_do_line_call ; -> 0: call (with dynamic title)
|
|
306 dcfsnz WREG ;
|
|
307 bra menu_do_line_call ; -> 1: call (with fixed title)
|
|
308 dcfsnz WREG ;
|
|
309 bra menu_do_line_option ; -> 2: option
|
|
310 bra menu_line_loop_pre2 ; else do nothing
|
|
311
|
|
312 menu_do_line_call:
|
|
313 rcall menu_call_item_function ; push current cursor position onto stack and call menu item function
|
|
314 rcall menu_processor_pop ; get back cursor position
|
|
315 bra menu_vertical ; re-draw the menu
|
|
316
|
|
317 menu_do_line_option:
|
|
318 movff option_addr+0,FSR0L ; get address of option definition data
|
|
319 movff option_addr+1,FSR0H ; ...
|
|
320 btfsc option_addr+1,4 ; shall stop at max value?
|
|
321 bsf option_stop_at_max ; YES - set flag
|
|
322 btfsc option_addr+1,6 ; is the selected option an option group member?
|
|
323 call option_adjust_group_member ; YES - adjust address to selected group member
|
|
324 btfss option_addr+1,5 ; shall increment?
|
|
325 call option_inc ; YES - increment option value
|
|
326 btfsc option_addr+1,5 ; shall decrement?
|
|
327 call option_dec ; YES - decrement option value
|
|
328 bcf option_stop_at_max ; revert to default (= wrap-around after max value)
|
|
329 bra menu_vertical ; re-draw the menu
|
|
330
|
|
331
|
|
332 ;-----------------------------------------------------------------------------
|
|
333 ; Draw all Menu Items
|
|
334 ;
|
|
335 menu_draw_menu_items:
|
|
336 btfss divemode ; in dive mode?
|
|
337 bra menu_draw_lines_surfmode ; NO
|
|
338 ;bra menu_draw_lines_divemode ; YES
|
|
339
|
|
340 global menu_draw_lines_divemode
|
|
341 menu_draw_lines_divemode:
|
640
|
342 movff menu_item_count,menu_pos_max ; copy number of item in menu block to menu_pos_max (used by divemode instead of menu_item_count for no reason)
|
|
343
|
|
344 IFDEF _big_divemenu
|
|
345
|
|
346 btfss alt_layout_active ; big menu selected?
|
|
347 bra menu_draw_lines_divemode_small ; NO
|
|
348 ;bra menu_draw_lines_divemode_big ; YES
|
|
349
|
|
350 menu_draw_lines_divemode_big:
|
|
351 WIN_STD dm_menu_item1_column+.16,dm_menu_item1_row+.22
|
|
352 decf menu_pos_cur,W ; get selected item as 0..5 into WREG
|
|
353 movwf menu_item_start ; set first item to draw = selected item
|
|
354 bra menu_draw_menu_items_common ; continue with common part
|
|
355
|
|
356 ENDIF ; _big_divemenu
|
|
357
|
|
358 menu_draw_lines_divemode_small:
|
|
359 WIN_SMALL dm_menu_item1_column,dm_menu_item1_row
|
634
|
360 clrf menu_item_start ; set first item in menu block as first item to draw
|
|
361 bra menu_draw_menu_items_common ; continue with common part
|
|
362
|
|
363 menu_draw_lines_surfmode:
|
|
364 WIN_SMALL MENU_LEFT, 0 ; initialize start position and font
|
|
365 movff menu_vertical_start,win_top ; set vertical output position
|
|
366 clrf menu_item_start ; set first item in menu block as first item to draw
|
|
367
|
|
368 IFDEF scrolling_menu_enabled
|
|
369 ; does the menu have more than 7 item ?
|
|
370 movf menu_item_count,W ; get number of menu items
|
|
371 addlw -(MENU_LINES_MAX+1) ; more than 7 item?
|
640
|
372 bn menu_draw_menu_items_common ; NO - continue with common part
|
634
|
373 movf selected_item,W ; YES - compute first item to be drawn as current cursor position - 6
|
|
374 addlw -(MENU_LINES_MAX-1) ; - ...
|
|
375 btfsc STATUS,N ; - is this < 0 ?
|
|
376 clrf WREG ; YES - revert to starting from first item
|
|
377 movwf menu_item_start ; - set first item to be drawn
|
|
378 ENDIF ; scrolling_menu_enabled
|
|
379
|
|
380 menu_draw_menu_items_common:
|
|
381 movff menu_item_start,menu_item_curr ; initialize menu item counter
|
|
382
|
|
383 menu_draw_menu_items_loop:
|
640
|
384 FONT_COLOR_MEMO ; set default font color (may had been changed by a dynamic title)
|
|
385 REINIT_BUFFER ; initialize output buffer again
|
634
|
386 movf menu_item_curr,W ; get menu item to draw
|
|
387 rcall menu_read_menu_item_data ; read menu item data
|
|
388 movf item_type,W ; switch on menu item type:
|
640
|
389 bz menu_draw_menu_item_dynamic ; -> 0: call with dynamic title
|
634
|
390 dcfsnz WREG ;
|
|
391 bra menu_draw_menu_item_call ; -> 1: call with fixed title
|
|
392 dcfsnz WREG ;
|
|
393 bra menu_draw_menu_item_option ; -> 2: option increment
|
|
394 bra menu_draw_menu_item_print ; no output in case of illegal type
|
|
395
|
|
396 menu_draw_menu_item_dynamic:
|
|
397 movf item_title_addr+0,W ; check if call address is NULL
|
|
398 iorwf item_title_addr+1,W ; ...
|
|
399 btfsc STATUS,Z ; is null?
|
640
|
400 bra menu_draw_menu_item_after_print ; YES - no printing on this menu line
|
|
401 movff menu_item_curr,PRODL ; NO - pass menu item position to call function
|
634
|
402 rcall menu_text_call ; - call dynamic title function
|
|
403 bra menu_draw_menu_item_print ; - print menu item
|
|
404
|
|
405 menu_draw_menu_item_call:
|
|
406 movff item_title_addr+0,FSR1L ; point to multi-lingual text
|
|
407 movff item_title_addr+1,FSR1H ; ...
|
640
|
408 call strcat_text_FSR ; copy translated text to buffer
|
634
|
409 bra menu_draw_menu_item_print ; print menu item
|
|
410
|
|
411 menu_draw_menu_item_option:
|
|
412 movff item_title_addr+0,FSR1L ; point to multi-lingual text
|
|
413 movff item_title_addr+1,FSR1H ; ...
|
640
|
414 call strcat_text_FSR ; copy translated text to buffer
|
634
|
415 movff option_addr+0,FSR0L ; hand over address of option definition data
|
|
416 movff option_addr+1,FSR0H ; ...
|
|
417 btfsc option_addr+1,6 ; is the selected option an option group member?
|
|
418 call option_adjust_group_member ; YES - adjust address to selected group member
|
|
419 btfss block_option_value ; displaying of option value suspended?
|
|
420 call option_draw ; NO - draw option value
|
|
421 ;bra menu_draw_menu_item_print ; print menu item
|
0
|
422
|
634
|
423 menu_draw_menu_item_print:
|
|
424 movlw MAX_LINE_LENGTH_SURF ; load maximum length for a surface menu item
|
|
425 btfsc divemode ; in dive mode?
|
|
426 movlw MAX_LINE_LENGTH_DIVE ; YES - replace with maximum length for a dive mode menu item
|
|
427 call TFT_buffer_trim_length ; fill up or cut buffer to max length
|
|
428 PRINT ; print menu item to screen
|
640
|
429 ;bra menu_draw_menu_item_after_print ; continue with after-print actions
|
634
|
430
|
640
|
431 menu_draw_menu_item_after_print:
|
634
|
432 btfss divemode ; in dive mode?
|
640
|
433 bra menu_draw_menu_item_common ; NO
|
634
|
434 ;bra menu_draw_menu_item_divemode ; YES
|
|
435
|
|
436 menu_draw_menu_item_divemode:
|
640
|
437 IFDEF _big_divemenu
|
|
438 btfsc alt_layout_active ; big menu selected?
|
|
439 return ; YES - done
|
|
440 ENDIF
|
|
441
|
|
442 movlw .2 ; load a 2
|
|
443 cpfseq menu_item_curr ; just done menu item 2 (last item in left column) ?
|
634
|
444 bra menu_draw_menu_item_common ; NO - continue with common part
|
|
445 movlw dm_menu_item4_row ; YES - set vertical position for 2nd column
|
|
446 movff WREG,win_top ; - ...
|
|
447 movlw dm_menu_item4_column ; - set horizontal position for 2nd column
|
|
448 movff WREG,win_leftx2 ; - ...
|
640
|
449 bra menu_draw_menu_item_common_1 ; - continue in common part
|
634
|
450
|
640
|
451 menu_draw_menu_item_common:
|
|
452 movlw MENU_HEIGHT_SURF ; get menu items vertical spacing for surface mode
|
|
453 btfsc divemode ; in dive mode?
|
|
454 movlw MENU_HEIGHT_DIVE ; YES - replace with vertical spacing for dive mode
|
|
455 addwf win_top,F ; adjust vertical output position
|
|
456
|
|
457 menu_draw_menu_item_common_1:
|
|
458 incf menu_item_curr,F ; increment menu item number
|
|
459
|
634
|
460 IFDEF scrolling_menu_enabled
|
640
|
461 btfsc divemode ; in dive mode?
|
|
462 bra menu_draw_menu_item_common_2 ; YES - skip
|
|
463 movf menu_item_start,W ; NO - get the number of the menu item that menu drawing started with
|
|
464 subwf menu_item_curr,W ; - compute how many item have been drawn already
|
|
465 xorlw MENU_LINES_MAX ; - compare with how max item fit the screen
|
|
466 btfsc STATUS,Z ; - screen full?
|
|
467 return ; - YES - done
|
|
468 ;bra menu_draw_menu_item_common_2 ; NO - continue
|
634
|
469 ENDIF ; scrolling_menu_enabled
|
|
470
|
640
|
471 menu_draw_menu_item_common_2:
|
634
|
472 movf menu_item_curr,W ; get current menu item
|
|
473 xorwf menu_item_count,W ; compare with total number of menu items, more item to do?
|
|
474 bnz menu_draw_menu_items_loop ; YES - loop
|
|
475 return ; NO - done
|
|
476
|
|
477
|
|
478 ;-----------------------------------------------------------------------------
|
|
479 ; Helper Function - call Function for dynamic Title
|
|
480 ;
|
|
481 menu_text_call:
|
|
482 clrf PCLATU ; execute a computed goto
|
|
483 movff item_title_addr+1,PCLATH ; ...
|
|
484 movf item_title_addr+0,W ; ...
|
|
485 movwf PCL ; ...
|
|
486
|
0
|
487
|
634
|
488 ;-----------------------------------------------------------------------------
|
|
489 ; Draw the Cursor (Main Menu Style)
|
|
490 ;
|
|
491 menu_draw_cursor_surf:
|
640
|
492 WIN_LEFT MENU_LEFT-8 ; set horizontal start of cursor column
|
634
|
493 WIN_WIDTH .6 ; set width of cursor column
|
|
494 WIN_HEIGHT .223 ; set preliminary hight of cursor column
|
|
495
|
|
496 movf menu_vertical_start,W ; get vertical start of menu items
|
|
497 movwf win_top ; set vertical start of cursor column
|
|
498 subwf win_height,F ; final hight = prelim.height - vertical start
|
|
499
|
|
500 clrf WREG ; set color to black
|
|
501 BOX_COLOR ; clear cursor area
|
|
502
|
640
|
503 FONT_SIZE FT_SMALL ; set font size
|
|
504
|
634
|
505 movf menu_item_start,W ; get number of menu item that is on the first line
|
|
506 subwf selected_item,W ; compute line number of current menu item
|
|
507
|
|
508 mullw MENU_HEIGHT_SURF ; multiply line number with vertical menu items spacing
|
|
509 movf PRODL,W ; get computed vertical offset
|
|
510 addwf menu_vertical_start,W ; add offset to vertical start position
|
|
511 movwf win_top ; set final vertical position
|
640
|
512 bra menu_draw_cursor_common ; print cursor
|
634
|
513
|
|
514
|
|
515 ;-----------------------------------------------------------------------------
|
|
516 ; Draw the Cursor (Dive Mode Style)
|
|
517 ;
|
|
518 global menu_draw_cursor_dive
|
|
519 menu_draw_cursor_dive:
|
640
|
520 IFDEF _big_divemenu
|
|
521 btfss alt_layout_active ; big menu selected?
|
|
522 bra menu_draw_cursor_dive_small ; NO
|
|
523 ;bra menu_draw_cursor_dive_big ; YES
|
|
524
|
|
525 menu_draw_cursor_dive_big:
|
|
526 WIN_STD dm_menu_item1_column,dm_menu_item1_row+.20
|
|
527 bra menu_draw_cursor_common ; print cursor
|
|
528 ENDIF ; _big_divemenu
|
|
529
|
|
530 menu_draw_cursor_dive_small:
|
634
|
531 ; clear cursor areas
|
|
532 WIN_BOX_BLACK dm_menu_row+.1, dm_menu_lower-.1, dm_menu_item1_column-.8, dm_menu_item1_column-.1
|
|
533 WIN_BOX_BLACK dm_menu_row+.1, dm_menu_lower-.1, dm_menu_item4_column-.8, dm_menu_item4_column-.1
|
|
534
|
640
|
535 FONT_SIZE FT_SMALL ; set font size
|
|
536
|
634
|
537 movlw dm_menu_item1_column-.8 ; load position of left column
|
|
538 btfsc menu_pos_cur,2 ; cursor at menu item 4..6 ?
|
|
539 movlw dm_menu_item4_column-.8 ; YES - replace with position of right column
|
|
540 movwf win_leftx2 ; set horizontal position
|
|
541
|
|
542 decf menu_pos_cur,W ; get cursor position as 0..5 into WREG
|
|
543 btfsc menu_pos_cur,2 ; cursor at menu item 4..6 ?
|
|
544 addlw -.3 ; YES - subtract 3 to get line number in right column
|
|
545
|
640
|
546 mullw MENU_HEIGHT_DIVE ; multiply line number (0..2) with vertical menu items spacing
|
634
|
547 movf PRODL,W ; get computed vertical offset
|
|
548 addlw dm_menu_item1_row ; add offset to vertical start position
|
|
549 movwf win_top ; set final vertical position
|
640
|
550 ;bra menu_draw_cursor_common ; print cursor
|
634
|
551
|
|
552
|
|
553 ;-----------------------------------------------------------------------------
|
|
554 ; Helper Function - common Part of drawing the Cursor
|
|
555 ;
|
|
556 menu_draw_cursor_common:
|
640
|
557 FONT_COLOR_MEMO ; set font color (may have changed in-between)
|
634
|
558 STRCPY_PRINT "\xb7" ; print cursor
|
|
559 return ; done
|
0
|
560
|
|
561 ;-----------------------------------------------------------------------------
|
|
562
|
634
|
563 END
|