comparison src/menu_processor.inc @ 582:b455b31ce022

work on 2.97 stable
author heinrichsweikamp
date Mon, 26 Feb 2018 16:40:28 +0100
parents 653a3ab08062
children c40025d8e750
comparison
equal deleted inserted replaced
581:f5de1ff88814 582:b455b31ce022
1 ;============================================================================= 1 ;=============================================================================
2 ; 2 ;
3 ; File menu_processor.asm 3 ; File menu_processor.asm REFACTORED VERSION V2.97
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 ; Restart menu-system from first icon/line
13 extern menu_processor_reset 13 extern menu_processor_reset
14
15 ; Recal last (automatically) saved icon/line when returning from submenu.
16 extern menu_processor_pop
17 14
18 ; Rexecute the menu block 15 ; Recall last (automatically) saved icon/line when returning from submenu
19 extern menu_processor 16 extern menu_processor_pop
17 extern menu_processor_double_pop
20 18
21 extern menu_processor_bottom_line 19 ; execute the menu block
20 extern menu_processor
21 extern menu_processor_bottom_line
22 22
23 ;============================================================================= 23 ;=============================================================================
24 ; Menus parameters 24 ; Menus parameters
25 25
26 ;NOTE: should be idenric in .inc and .asm ! 26 ;NOTE: should be idenric in .inc and .asm !
27 #define MENU_LINES_MAX .7 ; Number of lines per screen? 27 #define MENU_LINES_MAX .7 ; Number of lines per screen?
28 #define MENU_HEIGHT .27 ; Spacing on screen. 28 #define MENU_HEIGHT .27 ; Spacing on screen.
29 #define MENU_VCENTER .125 ; Position on screen. 29 #define MENU_VCENTER .125 ; Position on screen.
30 30
31 ;============================================================================= 31 ;=============================================================================
32 32
33 COMMON_BEGIN_MENU MACRO dynamic, txt, nb_items 33 COMMON_BEGIN_MENU MACRO dynamic, txt, nb_items
34 local center 34 local center
35 If nb_items > MENU_LINES_MAX
36 center set MENU_VCENTER - (MENU_HEIGHT/2) * MENU_LINES_MAX
37 Else
38 center set MENU_VCENTER - (MENU_HEIGHT/2) * nb_items
39 Endif
40 If nb_items <= 0
41 Error "Zero items in menu ", x
42 Endif
43 35
44 extern txt 36 If nb_items > MENU_LINES_MAX
45 call menu_processor 37 center set MENU_VCENTER - (MENU_HEIGHT/2) * MENU_LINES_MAX
46 ; Push 6 bytes of menu header data. 38 Else
47 db nb_items, dynamic 39 center set MENU_VCENTER - (MENU_HEIGHT/2) * nb_items
48 db LOW(txt), HIGH(txt) 40 Endif
49 db UPPER(txt), center 41
50 ENDM 42 If nb_items <= 0
43 Error "Zero items in menu ", x
44 Endif
45
46 extern txt
47 call menu_processor
48
49 ; Push 6 bytes of menu header data.
50 db nb_items, dynamic
51 db LOW(txt), HIGH(txt)
52 db UPPER(txt), center
53 ENDM
51 54
52 ;============================================================================= 55 ;=============================================================================
56
53 ; Macro to generat (and check) menu vertical menu blocks with data. 57 ; Macro to generat (and check) menu vertical menu blocks with data.
54 ;
55 MENU_BEGIN MACRO menu_title, nb_items
56 COMMON_BEGIN_MENU 0, menu_title, nb_items
57 ENDM
58 58
59 MENU_BEGIN_DYNAMIC macro title_proc, nb_items 59 MENU_BEGIN MACRO menu_title, nb_items
60 COMMON_BEGIN_MENU 1, title_proc, nb_items 60 COMMON_BEGIN_MENU 0, menu_title, nb_items
61 ENDM 61 ENDM
62
63 MENU_BEGIN_DYNAMIC MACRO title_proc, nb_items
64 COMMON_BEGIN_MENU 1, title_proc, nb_items
65 ENDM
62 66
63 ;============================================================================= 67 ;=============================================================================
64 68
65 ; Submenu 69 ; Submenu
66 MENU_CALL MACRO txt, proc 70
67 extern txt 71 MENU_CALL MACRO txt, proc
68 db 0, 0, 0, 0 72 extern txt
69 db LOW(proc), HIGH(proc), UPPER(proc), 0 73 db 0, 0, 0, 0
70 db LOW(txt), HIGH(txt) 74 db LOW(proc), HIGH(proc), UPPER(proc), 0
75 db LOW(txt), HIGH(txt)
71 ENDM 76 ENDM
72 77
73 ; Generic option menu 78 ; Generic option menu
74 MENU_OPTION MACRO txt, option, callback
75 extern txt
76 extern option
77 db 2, LOW(callback), HIGH(callback), UPPER(callback)
78 db LOW(option),HIGH(option),UPPER(option), 0
79 db LOW(txt), HIGH(txt)
80 ENDM
81 79
82 MENU_DYNAMIC MACRO callback, proc 80 MENU_OPTION MACRO txt, option, callback
83 extern callback 81 extern txt
84 db 3, LOW(callback), HIGH(callback), UPPER(callback) 82 extern option
85 db LOW(proc), HIGH(proc), UPPER(proc), 0 83 db 2, LOW(callback), HIGH(callback), UPPER(callback)
86 db 0, 0 84 db LOW(option), HIGH(option), UPPER(option), 0
87 ENDM 85 db LOW(txt), HIGH(txt)
86 ENDM
88 87
89 MENU_END MACRO 88 MENU_DYNAMIC MACRO callback, proc
90 ENDM 89 extern callback
90 db 3, LOW(callback), HIGH(callback), UPPER(callback)
91 db LOW(proc), HIGH(proc), UPPER(proc), 0
92 db 0, 0
93 ENDM
94
95 MENU_END MACRO
96 ENDM